posthog-js 1.231.1 → 1.231.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- function e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function t(t){for(var s=1;s<arguments.length;s++){var r=null!=arguments[s]?arguments[s]:{};s%2?e(Object(r),!0).forEach((function(e){i(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function i(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function s(e,t){if(null==e)return{};var i,s,r=function(e,t){if(null==e)return{};var i,s,r={},n=Object.keys(e);for(s=0;s<n.length;s++)i=n[s],t.indexOf(i)>=0||(r[i]=e[i]);return r}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++)i=n[s],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}var r,n="undefined"!=typeof window?window:void 0,o="undefined"!=typeof globalThis?globalThis:n,a=Array.prototype,l=a.forEach,c=a.indexOf,u=null==o?void 0:o.navigator,d=null==o?void 0:o.document,h=null==o?void 0:o.location,_=null==o?void 0:o.fetch,p=null!=o&&o.XMLHttpRequest&&"withCredentials"in new o.XMLHttpRequest?o.XMLHttpRequest:void 0,g=null==o?void 0:o.AbortController,v=null==u?void 0:u.userAgent,f=null!=n?n:{},m="$copy_autocapture",b=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(r||(r={}));var y=["fatal","error","warning","log","info","debug"];function w(e,t){return-1!==e.indexOf(t)}var S=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},k=function(e){return e.replace(/^\$/,"")};var E=Array.isArray,x=Object.prototype,I=x.hasOwnProperty,P=x.toString,C=E||function(e){return"[object Array]"===P.call(e)},F=e=>"function"==typeof e,R=e=>e===Object(e)&&!C(e),T=e=>{if(R(e)){for(var t in e)if(I.call(e,t))return!1;return!0}return!1},$=e=>void 0===e,A=e=>"[object String]"==P.call(e),O=e=>A(e)&&0===e.trim().length,M=e=>null===e,L=e=>$(e)||M(e),D=e=>"[object Number]"==P.call(e),q=e=>"[object Boolean]"===P.call(e),N=e=>e instanceof FormData,B=e=>e instanceof Error,H=e=>w(b,e),U={DEBUG:!1,LIB_VERSION:"1.231.1"},z=e=>{var t={_log:function(t){if(n&&(U.DEBUG||f.POSTHOG_DEBUG)&&!$(n.console)&&n.console){for(var i=("__rrweb_original__"in n.console[t]?n.console[t].__rrweb_original__:n.console[t]),s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];i(e,...r)}},info:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("log",...i)},warn:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("warn",...i)},error:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("error",...i)},critical:function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning:e=>{t.error("You must initialize PostHog before calling ".concat(e))},createLogger:t=>z("".concat(e," ").concat(t))};return t},j=z("[PostHog.js]"),W=j.createLogger,V={};function G(e,t,i){if(C(e))if(l&&e.forEach===l)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var s=0,r=e.length;s<r;s++)if(s in e&&t.call(i,e[s],s)===V)return}function J(e,t,i){if(!L(e)){if(C(e))return G(e,t,i);if(N(e)){for(var s of e.entries())if(t.call(i,s[1],s[0])===V)return}else for(var r in e)if(I.call(e,r)&&t.call(i,e[r],r)===V)return}}var Y=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return G(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},K=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return G(i,(function(t){G(t,(function(t){e.push(t)}))})),e};function X(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var Q=function(e){try{return e()}catch(e){return}},Z=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){j.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),j.critical(e)}}},ee=function(e){var t={};return J(e,(function(e,i){A(e)&&e.length>0&&(t[i]=e)})),t};function te(e,t){return i=e,s=e=>A(e)&&!M(t)?e.slice(0,t):e,r=new Set,function e(t,i){return t!==Object(t)?s?s(t,i):t:r.has(t)?void 0:(r.add(t),C(t)?(n=[],G(t,(t=>{n.push(e(t))}))):(n={},J(t,((t,i)=>{r.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,s,r}var ie=["herokuapp.com","vercel.app","netlify.app"];function se(e){var t=null==e?void 0:e.hostname;if(!A(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of ie)if(i===s)return!1;return!0}function re(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function ne(e,t,i,s){var{capture:r=!1,passive:n=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:r,passive:n})}var oe="$people_distinct_id",ae="__alias",le="__timers",ce="$autocapture_disabled_server_side",ue="$heatmaps_enabled_server_side",de="$exception_capture_enabled_server_side",he="$web_vitals_enabled_server_side",_e="$dead_clicks_enabled_server_side",pe="$web_vitals_allowed_metrics",ge="$session_recording_enabled_server_side",ve="$console_log_recording_enabled_server_side",fe="$session_recording_network_payload_capture",me="$session_recording_masking",be="$session_recording_canvas_recording",ye="$replay_sample_rate",we="$replay_minimum_duration",Se="$replay_script_config",ke="$sesid",Ee="$session_is_sampled",xe="$session_recording_url_trigger_activated_session",Ie="$session_recording_event_trigger_activated_session",Pe="$enabled_feature_flags",Ce="$early_access_features",Fe="$stored_person_properties",Re="$stored_group_properties",Te="$surveys",$e="$surveys_activated",Ae="$flag_call_reported",Oe="$user_state",Me="$client_session_props",Le="$capture_rate_limit",De="$initial_campaign_params",qe="$initial_referrer_info",Ne="$initial_person_info",Be="$epp",He="__POSTHOG_TOOLBAR__",Ue="$posthog_cookieless",ze=[oe,ae,"__cmpns",le,ge,ue,ke,Pe,Oe,Ce,Re,Fe,Te,Ae,Me,Le,De,qe,Be];function je(e){var t;return e instanceof Element&&(e.id===He||!(null===(t=e.closest)||void 0===t||!t.call(e,".toolbar-global-fade-container")))}function We(e){return!!e&&1===e.nodeType}function Ve(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Ge(e){return!!e&&3===e.nodeType}function Je(e){return!!e&&11===e.nodeType}function Ye(e){return e?S(e).split(/\s+/):[]}function Ke(e){var t=null==n?void 0:n.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Xe(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Ye(t)}function Qe(e){return L(e)?null:S(e).split(/(\s+)/).filter((e=>ht(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ze(e){var t="";return rt(e)&&!nt(e)&&e.childNodes&&e.childNodes.length&&J(e.childNodes,(function(e){var i;Ge(e)&&e.textContent&&(t+=null!==(i=Qe(e.textContent))&&void 0!==i?i:"")})),S(t)}function et(e){return $(e.target)?e.srcElement||null:null!==(t=e.target)&&void 0!==t&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var tt=["a","button","form","input","select","textarea","label"];function it(e){var t=e.parentNode;return!(!t||!We(t))&&t}function st(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(!n||!e||Ve(e,"html")||!We(e))return!1;if(null!=i&&i.url_allowlist&&!Ke(i.url_allowlist))return!1;if(null!=i&&i.url_ignorelist&&Ke(i.url_ignorelist))return!1;if(null!=i&&i.dom_event_allowlist){var o=i.dom_event_allowlist;if(o&&!o.some((e=>t.type===e)))return!1}for(var a=!1,l=[e],c=!0,u=e;u.parentNode&&!Ve(u,"body");)if(Je(u.parentNode))l.push(u.parentNode.host),u=u.parentNode.host;else{if(!(c=it(u)))break;if(s||tt.indexOf(c.tagName.toLowerCase())>-1)a=!0;else{var d=n.getComputedStyle(c);d&&"pointer"===d.getPropertyValue("cursor")&&(a=!0)}l.push(c),u=c}if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if($(i))return!0;var s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var r of e){var n=s(r);if("object"==typeof n)return n.v}return!1}(l,i))return!1;if(!function(e,t){var i=null==t?void 0:t.css_selector_allowlist;if($(i))return!0;var s=function(e){if(i.some((t=>e.matches(t))))return{v:!0}};for(var r of e){var n=s(r);if("object"==typeof n)return n.v}return!1}(l,i))return!1;var h=n.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var _=e.tagName.toLowerCase();switch(_){case"html":return!1;case"form":return(r||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(t.type)>=0;default:return a?(r||["click"]).indexOf(t.type)>=0:(r||["click"]).indexOf(t.type)>=0&&(tt.indexOf(_)>-1||"true"===e.getAttribute("contenteditable"))}}function rt(e){for(var t=e;t.parentNode&&!Ve(t,"body");t=t.parentNode){var i=Xe(t);if(w(i,"ph-sensitive")||w(i,"ph-no-capture"))return!1}if(w(Xe(e),"ph-include"))return!0;var s=e.type||"";if(A(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(A(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function nt(e){return!!(Ve(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ve(e,"select")||Ve(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var ot="(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})",at=new RegExp("^(?:".concat(ot,")$")),lt=new RegExp(ot),ct="\\d{3}-?\\d{2}-?\\d{4}",ut=new RegExp("^(".concat(ct,")$")),dt=new RegExp("(".concat(ct,")"));function ht(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(L(e))return!1;if(A(e)){if(e=S(e),(t?at:lt).test((e||"").replace(/[- ]/g,"")))return!1;if((t?ut:dt).test(e))return!1}return!0}function _t(e){var t=Ze(e);return ht(t="".concat(t," ").concat(pt(e)).trim())?t:""}function pt(e){var t="";return e&&e.childNodes&&e.childNodes.length&&J(e.childNodes,(function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{var s=Ze(e);t="".concat(t," ").concat(s).trim(),e.childNodes&&e.childNodes.length&&(t="".concat(t," ").concat(pt(e)).trim())}catch(e){j.error("[AutoCapture]",e)}})),t}function gt(e){return function(e){var i=e.map((e=>{var i,s,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+=".".concat(n.replace(/"/g,""));var o=t(t(t(t({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(i=e.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(s=e.nth_of_type)&&void 0!==s?s:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),a={};return X(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[vt(t.toString())]=vt(i.toString())})),r+=":",r+=X(o).map((e=>{var[t,i]=e;return"".concat(t,'="').concat(i,'"')})).join("")}));return i.join(";")}(function(e){return e.map((e=>{var t,i,s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:ft(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return X(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return s.attributes[t]=i})),s}))}(e))}function vt(e){return e.replace(/"|\\"/g,'\\"')}function ft(e){var t=e.attr__class;return t?C(t)?t:Ye(t):void 0}class mt{constructor(){this.clicks=[]}isRageClick(e,t,i){var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<30&&i-s.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:i}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var bt=["localhost","127.0.0.1"],yt=e=>{var t=null==d?void 0:d.createElement("a");return $(t)?null:(t.href=e,t)},wt=function(e){var t,i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"&",r=[];return J(e,(function(e,s){$(e)||$(s)||"undefined"===s||(t=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),i=encodeURIComponent(s),r[r.length]=i+"="+t)})),r.join(s)},St=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!C(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){j.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},kt=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[0]||"",n=s[1],o=r.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var h=c[d].split("=");C(h)&&(t.includes(h[0])?u.push(h[0]+"="+i):u.push(c[d]))}var _=l;return null!=a&&(_+="?"+u.join("&")),null!=n&&(_+="#"+n),_},Et=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},xt=W("[AutoCapture]");function It(e,t){return t.length>e?t.slice(0,e)+"...":t}function Pt(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!We(t));return t}function Ct(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};tt.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?n.$el_text=It(1024,_t(e)):n.$el_text=It(1024,Ze(e)));var o=Xe(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),J(e.attributes,(function(i){var r;if((!nt(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==s||!s.includes(i.name))&&!t&&ht(i.value)&&(r=i.name,!A(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Ye(o).join(" ")),n["attr__"+i.name]=It(1024,o)}}));for(var a=1,l=1,c=e;c=Pt(c);)a++,c.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function Ft(e,t){for(var i,s,{e:r,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!Ve(d,"body");)Je(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,_=[],p={},g=!1,v=!1;if(J(u,(e=>{var t=rt(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&ht(g)&&g),w(Xe(e),"ph-no-capture")&&(v=!0),_.push(Ct(e,o,a,l));var i=function(e){if(!rt(e))return{};var t={};return J(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&ht(s)&&(t[i]=s)}})),t}(e);Y(p,i)})),v)return{props:{},explicitNoCapture:v};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?_[0].$el_text=_t(e):_[0].$el_text=Ze(e)),g){var f,m;_[0].attr__href=g;var b=null===(f=yt(g))||void 0===f?void 0:f.host,y=null==n||null===(m=n.location)||void 0===m?void 0:m.host;b&&y&&b!==y&&(h=g)}return{props:Y({$event_type:r.type,$ce_version:1},c?{}:{$elements:_},{$elements_chain:gt(_)},null!==(i=_[0])&&void 0!==i&&i.$el_text?{$el_text:null===(s=_[0])||void 0===s?void 0:s.$el_text}:{},h&&"click"===r.type?{$external_click_url:h}:{},p)}}class Rt{constructor(e){i(this,"_initialized",!1),i(this,"_isDisabledServerSide",null),i(this,"rageclicks",new mt),i(this,"_elementsChainAsString",!1),this.instance=e,this._elementSelectors=null}get config(){var e,t,i=R(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null===(e=i.url_allowlist)||void 0===e?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null===(t=i.url_ignorelist)||void 0===t?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(n&&d){var e=e=>{e=e||(null==n?void 0:n.event);try{this._captureEvent(e)}catch(e){xt.error("Failed to capture event",e)}};if(ne(d,"submit",e,{capture:!0}),ne(d,"change",e,{capture:!0}),ne(d,"click",e,{capture:!0}),this.config.capture_copied_text){var t=e=>{e=e||(null==n?void 0:n.event),this._captureEvent(e,m)};ne(d,"copy",t,{capture:!0}),ne(d,"cut",t,{capture:!0})}}}else xt.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[ce]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null===(t=this._elementSelectors)||void 0===t||t.forEach((t=>{var s=null==d?void 0:d.querySelectorAll(t);null==s||s.forEach((s=>{e===s&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null===(e=this.instance.persistence)||void 0===e?void 0:e.props[ce],s=this._isDisabledServerSide;if(M(s)&&!q(i)&&!this.instance.config.advanced_disable_decide)return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$autocapture";if(this.isEnabled){var i,s=et(e);if(Ge(s)&&(s=s.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!==(i=this.rageclicks)&&void 0!==i&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._captureEvent(e,"$rageclick");var r=t===m;if(s&&st(s,e,this.config,r,r?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=Ft(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(a)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(o.$element_selectors=l),t===m){var c,u=Qe(null==n||null===(c=n.getSelection())||void 0===c?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return F(null==d?void 0:d.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return D(e)&&isFinite(e)&&Math.floor(e)===e});var Tt="0123456789abcdef";class $t{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,s){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||e<0||t<0||i<0||s<0||e>0xffffffffffff||t>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new $t(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Tt.charAt(this.bytes[t]>>>4)+Tt.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new $t(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class At{constructor(){i(this,"timestamp",0),i(this,"counter",0),i(this,"random",new Lt)}generate(){var e=this.generateOrAbort();if($(e)){this.timestamp=0;var t=this.generateOrAbort();if($(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return $t.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}var Ot,Mt=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};n&&!$(n.crypto)&&crypto.getRandomValues&&(Mt=e=>crypto.getRandomValues(e));class Lt{constructor(){i(this,"buffer",new Uint32Array(8)),i(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(Mt(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var Dt=()=>qt().toString(),qt=()=>(Ot||(Ot=new At)).generate(),Nt="Thu, 01 Jan 1970 00:00:00 GMT",Bt="";var Ht=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ut(e,t){if(t){var i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;if(Bt)return Bt;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+Dt(),n=new RegExp("(^|;)\\s*"+r+"=1");!Bt&&s--;){var o=i.slice(s).join("."),a=r+"=1;domain=."+o;t.cookie=a,n.test(t.cookie)&&(t.cookie=a+";expires="+Nt,Bt=o)}return Bt}(e);if(!i){var s=(e=>{var t=e.match(Ht);return t?t[0]:""})(e);s!==i&&j.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}var zt,jt={is_supported:()=>!!d,error:function(e){j.error("cookieStore error: "+e)},get:function(e){if(d){try{for(var t=e+"=",i=d.cookie.split(";").filter((e=>e.length)),s=0;s<i.length;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}},parse:function(e){var t;try{t=JSON.parse(jt.get(e))||{}}catch(e){}return t},set:function(e,t,i,s,r){if(d)try{var n="",o="",a=Ut(d.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&j.warn("cookieStore warning: large cookie, len="+c.length),d.cookie=c,c}catch(e){return}},remove:function(e,t){try{jt.set(e,"",-1,t)}catch(e){return}}},Wt=null,Vt={is_supported:function(){if(!M(Wt))return Wt;var e=!0;if($(n))e=!1;else try{var t="__mplssupport__";Vt.set(t,"xyz"),'"xyz"'!==Vt.get(t)&&(e=!1),Vt.remove(t)}catch(t){e=!1}return e||j.error("localStorage unsupported; falling back to cookie store"),Wt=e,e},error:function(e){j.error("localStorage error: "+e)},get:function(e){try{return null==n?void 0:n.localStorage.getItem(e)}catch(e){Vt.error(e)}return null},parse:function(e){try{return JSON.parse(Vt.get(e))||{}}catch(e){}return null},set:function(e,t){try{null==n||n.localStorage.setItem(e,JSON.stringify(t))}catch(e){Vt.error(e)}},remove:function(e){try{null==n||n.localStorage.removeItem(e)}catch(e){Vt.error(e)}}},Gt=["distinct_id",ke,Ee,Be,Ne],Jt=t(t({},Vt),{},{parse:function(e){try{var t={};try{t=jt.parse(e)||{}}catch(e){}var i=Y(t,JSON.parse(Vt.get(e)||"{}"));return Vt.set(e,i),i}catch(e){}return null},set:function(e,t,i,s,r,n){try{Vt.set(e,t,void 0,void 0,n);var o={};Gt.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&jt.set(e,o,i,s,r,n)}catch(e){Vt.error(e)}},remove:function(e,t){try{null==n||n.localStorage.removeItem(e),jt.remove(e,t)}catch(e){Vt.error(e)}}}),Yt={},Kt={is_supported:function(){return!0},error:function(e){j.error("memoryStorage error: "+e)},get:function(e){return Yt[e]||null},parse:function(e){return Yt[e]||null},set:function(e,t){Yt[e]=t},remove:function(e){delete Yt[e]}},Xt=null,Qt={is_supported:function(){if(!M(Xt))return Xt;if(Xt=!0,$(n))Xt=!1;else try{var e="__support__";Qt.set(e,"xyz"),'"xyz"'!==Qt.get(e)&&(Xt=!1),Qt.remove(e)}catch(e){Xt=!1}return Xt},error:function(e){j.error("sessionStorage error: ",e)},get:function(e){try{return null==n?void 0:n.sessionStorage.getItem(e)}catch(e){Qt.error(e)}return null},parse:function(e){try{return JSON.parse(Qt.get(e))||null}catch(e){}return null},set:function(e,t){try{null==n||n.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Qt.error(e)}},remove:function(e){try{null==n||n.sessionStorage.removeItem(e)}catch(e){Qt.error(e)}}};!function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"}(zt||(zt={}));class Zt{constructor(e){this.instance=e}get config(){return this.instance.config}get consent(){return this.getDnt()?zt.DENIED:this.storedConsent}isOptedOut(){return this.consent===zt.DENIED||this.consent===zt.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(e){this.storage.set(this.storageKey,e?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:e,opt_out_capturing_cookie_prefix:t}=this.instance.config;return(t||"__ph_opt_in_out_")+e}get storedConsent(){var e=this.storage.get(this.storageKey);return"1"===e?zt.GRANTED:"0"===e?zt.DENIED:zt.PENDING}get storage(){if(!this._storage){var e=this.config.opt_out_capturing_persistence_type;this._storage="localStorage"===e?Vt:jt;var t="localStorage"===e?jt:Vt;t.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut("1"===t.get(this.storageKey)),t.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!re([null==u?void 0:u.doNotTrack,null==u?void 0:u.msDoNotTrack,f.doNotTrack],(e=>w([!0,1,"1","yes"],e)))}}var ei=W("[Dead Clicks]"),ti=()=>!0,ii=e=>{var t,i=!(null===(t=e.instance.persistence)||void 0===t||!t.get_property(_e)),s=e.instance.config.capture_dead_clicks;return q(s)?s:i};class si{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[_e]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript((()=>{this.start()}))}loadScript(e){var t,i,s;null!==(t=f.__PosthogExtensions__)&&void 0!==t&&t.initDeadClicksAutocapture&&e(),null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"dead-clicks-autocapture",(t=>{t?ei.error("failed to load script",t):e()}))}start(){var e;if(d){if(!this._lazyLoadedDeadClicksAutocapture&&null!==(e=f.__PosthogExtensions__)&&void 0!==e&&e.initDeadClicksAutocapture){var t=R(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=f.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(d),ei.info("starting...")}}else ei.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,ei.info("stopping..."))}}var ri=W("[ExceptionAutocapture]");class ni{constructor(e){var t;i(this,"startCapturing",(()=>{var e,t,i,s;if(n&&this.isEnabled&&!this.hasHandlers){var r=null===(e=f.__PosthogExtensions__)||void 0===e||null===(t=e.errorWrappingFunctions)||void 0===t?void 0:t.wrapOnError,o=null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.errorWrappingFunctions)||void 0===s?void 0:s.wrapUnhandledRejection;if(r&&o)try{this.unwrapOnError=r(this.captureException.bind(this)),this.unwrapUnhandledRejection=o(this.captureException.bind(this))}catch(e){ri.error("failed to start",e),this.stopCapturing()}else ri.error("failed to load error wrapping functions - cannot start")}})),this.instance=e,this.remoteEnabled=!(null===(t=this.instance.persistence)||void 0===t||!t.props[de]),this.startIfEnabled()}get isEnabled(){var e;return q(this.instance.config.capture_exceptions)?this.instance.config.capture_exceptions:null!==(e=this.remoteEnabled)&&void 0!==e&&e}get hasHandlers(){return!$(this.unwrapOnError)}startIfEnabled(){this.isEnabled&&!this.hasHandlers&&(ri.info("enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(e){var t,i;this.hasHandlers&&e(),null===(t=f.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"exception-autocapture",(t=>{if(t)return ri.error("failed to load script",t);e()}))}stopCapturing(){var e,t;null===(e=this.unwrapOnError)||void 0===e||e.call(this),this.unwrapOnError=void 0,null===(t=this.unwrapUnhandledRejection)||void 0===t||t.call(this),this.unwrapUnhandledRejection=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.remoteEnabled=!!t||!1,this.instance.persistence&&this.instance.persistence.register({[de]:this.remoteEnabled}),this.startIfEnabled()}captureException(e){var t=this.instance.requestRouter.endpointFor("ui");e.$exception_personURL="".concat(t,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(e)}}function oi(e){var t,i;return(null===(t=JSON.stringify(e,(i=[],function(e,t){if(R(t)){for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(t)?"[Circular]":(i.push(t),t)}return t})))||void 0===t?void 0:t.length)||0}function ai(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6606028.8;if(e.size>=t&&e.data.length>1){var i=Math.floor(e.data.length/2),s=e.data.slice(0,i),r=e.data.slice(i);return[ai({size:oi(s),data:s,sessionId:e.sessionId,windowId:e.windowId}),ai({size:oi(r),data:r,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var li=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(li||{}),ci=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(ci||{}),ui="[SessionRecording]",di="redacted",hi={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com"]},_i=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],pi=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],gi=["/s/","/e/","/i/"];function vi(e,t,i,s){if(L(e))return e;var r=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return A(r)&&(r=parseInt(r)),r>i?ui+" ".concat(s," body too large to record (").concat(r," bytes)"):e}function fi(e,t){if(L(e))return e;var i=e;return ht(i,!1)||(i=ui+" "+t+" body "+di),J(pi,(e=>{var s,r;null!==(s=i)&&void 0!==s&&s.length&&-1!==(null===(r=i)||void 0===r?void 0:r.indexOf(e))&&(i=ui+" "+t+" body "+di+" as might contain: "+e)})),i}var mi=(e,i)=>{var s,r,n,o={payloadSizeLimitBytes:hi.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...hi.performanceEntryTypeToObserve],payloadHostDenyList:[...i.payloadHostDenyList||[],...hi.payloadHostDenyList]},a=!1!==e.session_recording.recordHeaders&&i.recordHeaders,l=!1!==e.session_recording.recordBody&&i.recordBody,c=!1!==e.capture_performance&&i.recordPerformance,u=(s=o,n=Math.min(1e6,null!==(r=s.payloadSizeLimitBytes)&&void 0!==r?r:1e6),e=>(null!=e&&e.requestBody&&(e.requestBody=vi(e.requestBody,e.requestHeaders,n,"Request")),null!=e&&e.responseBody&&(e.responseBody=vi(e.responseBody,e.responseHeaders,n,"Response")),e)),d=t=>{return u(((e,t)=>{var i,s=yt(e.name),r=0===t.indexOf("http")?null===(i=yt(t))||void 0===i?void 0:i.pathname:t;"/"===r&&(r="");var n=null==s?void 0:s.pathname.replace(r||"","");if(!(s&&n&&gi.some((e=>0===n.indexOf(e)))))return e})((s=(i=t).requestHeaders,L(s)||J(Object.keys(null!=s?s:{}),(e=>{_i.includes(e.toLowerCase())&&(s[e]=di)})),i),e.api_host));var i,s},h=F(e.session_recording.maskNetworkRequestFn);return h&&F(e.session_recording.maskCapturedNetworkRequestFn)&&j.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),h&&(e.session_recording.maskCapturedNetworkRequestFn=i=>{var s=e.session_recording.maskNetworkRequestFn({url:i.name});return t(t({},i),{},{name:null==s?void 0:s.url})}),o.maskRequestFn=F(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,s,r,n=d(t);return n&&null!==(i=null===(s=(r=e.session_recording).maskCapturedNetworkRequestFn)||void 0===s?void 0:s.call(r,n))&&void 0!==i?i:void 0}:e=>function(e){if(!$(e))return e.requestBody=fi(e.requestBody,"Request"),e.responseBody=fi(e.responseBody,"Response"),e}(d(e)),t(t(t({},hi),o),{},{recordHeaders:a,recordBody:l,recordPerformance:c,recordInitialRequests:c})};function bi(e,t,i,s,r){return t>i&&(j.warn("min cannot be greater than max."),t=i),D(e)?e>i?(s&&j.warn(s+" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(s&&j.warn(s+" cannot be less than min: "+t+". Using min value instead."),t):e:(s&&j.warn(s+" must be a number. using max or fallback. max: "+i+", fallback: "+r),bi(r||i,t,i,s))}class yi{constructor(e){var t,s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,"bucketSize",100),i(this,"refillRate",10),i(this,"mutationBuckets",{}),i(this,"loggedTracker",{}),i(this,"refillBuckets",(()=>{Object.keys(this.mutationBuckets).forEach((e=>{this.mutationBuckets[e]=this.mutationBuckets[e]+this.refillRate,this.mutationBuckets[e]>=this.bucketSize&&delete this.mutationBuckets[e]}))})),i(this,"getNodeOrRelevantParent",(e=>{var t=this.rrweb.mirror.getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){var i=t.closest("svg");if(i)return[this.rrweb.mirror.getId(i),i]}return[e,t]})),i(this,"numberOfChanges",(e=>{var t,i,s,r,n,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(s=null===(r=e.attributes)||void 0===r?void 0:r.length)&&void 0!==s?s:0)+(null!==(n=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==n?n:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)})),i(this,"throttleMutations",(e=>{if(3!==e.type||0!==e.data.source)return e;var t=e.data,i=this.numberOfChanges(t);t.attributes&&(t.attributes=t.attributes.filter((e=>{var t,i,s,[r,n]=this.getNodeOrRelevantParent(e.id);if(0===this.mutationBuckets[r])return!1;(this.mutationBuckets[r]=null!==(t=this.mutationBuckets[r])&&void 0!==t?t:this.bucketSize,this.mutationBuckets[r]=Math.max(this.mutationBuckets[r]-1,0),0===this.mutationBuckets[r])&&(this.loggedTracker[r]||(this.loggedTracker[r]=!0,null===(i=(s=this.options).onBlockedNode)||void 0===i||i.call(s,r,n)));return e})));var s=this.numberOfChanges(t);return 0!==s||i===s?e:void 0})),this.rrweb=e,this.options=r,this.refillRate=bi(null!==(t=this.options.refillRate)&&void 0!==t?t:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=bi(null!==(s=this.options.bucketSize)&&void 0!==s?s:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval((()=>{this.refillBuckets()}),1e3)}}var wi=Uint8Array,Si=Uint16Array,ki=Uint32Array,Ei=new wi([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),xi=new wi([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ii=new wi([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pi=function(e,t){for(var i=new Si(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var r=new ki(i[30]);for(s=1;s<30;++s)for(var n=i[s];n<i[s+1];++n)r[n]=n-i[s]<<5|s;return[i,r]},Ci=Pi(Ei,2),Fi=Ci[0],Ri=Ci[1];Fi[28]=258,Ri[258]=28;for(var Ti=Pi(xi,0)[1],$i=new Si(32768),Ai=0;Ai<32768;++Ai){var Oi=(43690&Ai)>>>1|(21845&Ai)<<1;Oi=(61680&(Oi=(52428&Oi)>>>2|(13107&Oi)<<2))>>>4|(3855&Oi)<<4,$i[Ai]=((65280&Oi)>>>8|(255&Oi)<<8)>>>1}var Mi=function(e,t,i){for(var s=e.length,r=0,n=new Si(t);r<s;++r)++n[e[r]-1];var o,a=new Si(t);for(r=0;r<t;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Si(1<<t);var l=15-t;for(r=0;r<s;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)o[$i[d]>>>l]=c}else for(o=new Si(s),r=0;r<s;++r)o[r]=$i[a[e[r]-1]++]>>>15-e[r];return o},Li=new wi(288);for(Ai=0;Ai<144;++Ai)Li[Ai]=8;for(Ai=144;Ai<256;++Ai)Li[Ai]=9;for(Ai=256;Ai<280;++Ai)Li[Ai]=7;for(Ai=280;Ai<288;++Ai)Li[Ai]=8;var Di=new wi(32);for(Ai=0;Ai<32;++Ai)Di[Ai]=5;var qi=Mi(Li,9,0),Ni=Mi(Di,5,0),Bi=function(e){return(e/8>>0)+(7&e&&1)},Hi=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Si?Si:e instanceof ki?ki:wi)(i-t);return s.set(e.subarray(t,i)),s},Ui=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},zi=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8,e[s+2]|=i>>>16},ji=function(e,t){for(var i=[],s=0;s<e.length;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new wi(0),0];if(1==r){var o=new wi(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=n[0].s;for(s=1;s<r;++s)n[s].s>h&&(h=n[s].s);var _=new Si(h+1),p=Wi(i[u-1],_,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return _[t.s]-_[e.s]||e.f-t.f}));s<r;++s){var m=n[s].s;if(!(_[m]>t))break;g+=f-(1<<p-_[m]),_[m]=t}for(g>>>=v;g>0;){var b=n[s].s;_[b]<t?g-=1<<t-_[b]++-1:++s}for(;s>=0&&g;--s){var y=n[s].s;_[y]==t&&(--_[y],++g)}p=t}return[new wi(_),p]},Wi=function(e,t,i){return-1==e.s?Math.max(Wi(e.l,t,i+1),Wi(e.r,t,i+1)):t[e.s]=i},Vi=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Si(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},Gi=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Ji=function(e,t,i){var s=i.length,r=Bi(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;n<s;++n)e[r+n+4]=i[n];return 8*(r+4+s)},Yi=function(e,t,i,s,r,n,o,a,l,c,u){Ui(t,u++,i),++r[256];for(var d=ji(r,15),h=d[0],_=d[1],p=ji(n,15),g=p[0],v=p[1],f=Vi(h),m=f[0],b=f[1],y=Vi(g),w=y[0],S=y[1],k=new Si(19),E=0;E<m.length;++E)k[31&m[E]]++;for(E=0;E<w.length;++E)k[31&w[E]]++;for(var x=ji(k,7),I=x[0],P=x[1],C=19;C>4&&!I[Ii[C-1]];--C);var F,R,T,$,A=c+5<<3,O=Gi(r,Li)+Gi(n,Di)+o,M=Gi(r,h)+Gi(n,g)+o+14+3*C+Gi(k,I)+(2*k[16]+3*k[17]+7*k[18]);if(A<=O&&A<=M)return Ji(t,u,e.subarray(l,l+c));if(Ui(t,u,1+(M<O)),u+=2,M<O){F=Mi(h,_,0),R=h,T=Mi(g,v,0),$=g;var L=Mi(I,P,0);Ui(t,u,b-257),Ui(t,u+5,S-1),Ui(t,u+10,C-4),u+=14;for(E=0;E<C;++E)Ui(t,u+3*E,I[Ii[E]]);u+=3*C;for(var D=[m,w],q=0;q<2;++q){var N=D[q];for(E=0;E<N.length;++E){var B=31&N[E];Ui(t,u,L[B]),u+=I[B],B>15&&(Ui(t,u,N[E]>>>5&127),u+=N[E]>>>12)}}}else F=qi,R=Li,T=Ni,$=Di;for(E=0;E<a;++E)if(s[E]>255){B=s[E]>>>18&31;zi(t,u,F[B+257]),u+=R[B+257],B>7&&(Ui(t,u,s[E]>>>23&31),u+=Ei[B]);var H=31&s[E];zi(t,u,T[H]),u+=$[H],H>3&&(zi(t,u,s[E]>>>5&8191),u+=xi[H])}else zi(t,u,F[s[E]]),u+=R[s[E]];return zi(t,u,F[256]),u+R[256]},Ki=new ki([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Xi=function(){for(var e=new ki(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Qi=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=Xi[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}},Zi=function(e,t,i,s,r){return function(e,t,i,s,r,n){var o=e.length,a=new wi(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),c=0;if(!t||o<8)for(var u=0;u<=o;u+=65535){var d=u+65535;d<o?c=Ji(l,c,e.subarray(u,d)):(l[u]=n,c=Ji(l,c,e.subarray(u,o)))}else{for(var h=Ki[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,v=new Si(32768),f=new Si(g+1),m=Math.ceil(i/3),b=2*m,y=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<b)&g},w=new ki(25e3),S=new Si(288),k=new Si(32),E=0,x=0,I=(u=0,0),P=0,C=0;u<o;++u){var F=y(u),R=32767&u,T=f[F];if(v[R]=T,f[F]=R,P<=u){var $=o-u;if((E>7e3||I>24576)&&$>423){c=Yi(e,l,0,w,S,k,x,I,C,u-C,c),I=E=x=0,C=u;for(var A=0;A<286;++A)S[A]=0;for(A=0;A<30;++A)k[A]=0}var O=2,M=0,L=p,D=R-T&32767;if($>2&&F==y(u-D))for(var q=Math.min(_,$)-1,N=Math.min(32767,u),B=Math.min(258,$);D<=N&&--L&&R!=T;){if(e[u+O]==e[u+O-D]){for(var H=0;H<B&&e[u+H]==e[u+H-D];++H);if(H>O){if(O=H,M=D,H>q)break;var U=Math.min(D,H-2),z=0;for(A=0;A<U;++A){var j=u-D+A+32768&32767,W=j-v[j]+32768&32767;W>z&&(z=W,T=j)}}}D+=(R=T)-(T=v[R])+32768&32767}if(M){w[I++]=268435456|Ri[O]<<18|Ti[M];var V=31&Ri[O],G=31&Ti[M];x+=Ei[V]+xi[G],++S[257+V],++k[G],P=u+O,++E}else w[I++]=e[u],++S[e[u]]}}c=Yi(e,l,n,w,S,k,x,I,C,u-C,c)}return Hi(a,0,s+Bi(c)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,s,!r)},es=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},ts=function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&es(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;s<=i.length;++s)e[s+10]=i.charCodeAt(s)}},is=function(e){return 10+(e.filename&&e.filename.length+1||0)};function ss(e,t){void 0===t&&(t={});var i=Qi(),s=e.length;i.p(e);var r=Zi(e,t,is(t),8),n=r.length;return ts(r,t),es(r,n-8,i.d()),es(r,n-4,s),r}function rs(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new wi(e.length+(e.length>>>1)),r=0,n=function(e){s[r++]=e},o=0;o<i;++o){if(r+5>s.length){var a=new wi(r+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);l<128||t?n(l):l<2048?(n(192|l>>>6),n(128|63&l)):l>55295&&l<57344?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Hi(s,0,r)}function ns(e,t){return function(e){for(var t=0,i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t)}(e)%100<bi(100*t,0,100)}var os="[SessionRecording]",as=W(os),ls=3e5,cs=[ci.MouseMove,ci.MouseInteraction,ci.Scroll,ci.ViewportResize,ci.Input,ci.TouchMove,ci.MediaInteraction,ci.Drag],us=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function ds(e){return function(e,t){for(var i="",s=0;s<e.length;){var r=e[s++];r<128||t?i+=String.fromCharCode(r):r<224?i+=String.fromCharCode((31&r)<<6|63&e[s++]):r<240?i+=String.fromCharCode((15&r)<<12|(63&e[s++])<<6|63&e[s++]):(r=((15&r)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536,i+=String.fromCharCode(55296|r>>10,56320|1023&r))}return i}(ss(rs(JSON.stringify(e))),!0)}function hs(e){return e.type===li.Custom&&"sessionIdle"===e.data.tag}function _s(e,t){return t.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))}class ps{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get rrwebRecord(){var e,t;return null==f||null===(e=f.__PosthogExtensions__)||void 0===e||null===(t=e.rrweb)||void 0===t?void 0:t.record}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(os+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var e,t;return"trigger_pending"===this.triggerStatus?6e4:null!==(e=null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.full_snapshot_interval_millis)&&void 0!==e?e:ls}get isSampled(){var e=this.instance.get_property(Ee);return q(e)?e:null}get sessionDuration(){var e,t,i=null===(e=this.buffer)||void 0===e?void 0:e.data[(null===(t=this.buffer)||void 0===t?void 0:t.data.length)-1],{sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-s:null}get isRecordingEnabled(){var e=!!this.instance.get_property(ge),t=!this.instance.config.disable_session_recording;return n&&e&&t}get isConsoleLogCaptureEnabled(){var e=!!this.instance.get_property(ve),t=this.instance.config.enable_recording_console_log;return null!=t?t:e}get canvasRecording(){var e,t,i,s,r,n,o=this.instance.config.session_recording.captureCanvas,a=this.instance.get_property(be),l=null!==(e=null!==(t=null==o?void 0:o.recordCanvas)&&void 0!==t?t:null==a?void 0:a.enabled)&&void 0!==e&&e,c=null!==(i=null!==(s=null==o?void 0:o.canvasFps)&&void 0!==s?s:null==a?void 0:a.fps)&&void 0!==i?i:4,u=null!==(r=null!==(n=null==o?void 0:o.canvasQuality)&&void 0!==n?n:null==a?void 0:a.quality)&&void 0!==r?r:.4;if("string"==typeof u){var d=parseFloat(u);u=isNaN(d)?.4:d}return{enabled:l,fps:bi(c,0,12,"canvas recording fps",4),quality:bi(u,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var e,t,i=this.instance.get_property(fe),s={recordHeaders:null===(e=this.instance.config.session_recording)||void 0===e?void 0:e.recordHeaders,recordBody:null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.recordBody},r=(null==s?void 0:s.recordHeaders)||(null==i?void 0:i.recordHeaders),n=(null==s?void 0:s.recordBody)||(null==i?void 0:i.recordBody),o=R(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,a=!!(q(o)?o:null==i?void 0:i.capturePerformance);return r||n||a?{recordHeaders:r,recordBody:n,recordPerformance:a}:void 0}get masking(){var e,t,i,s,r,n,o=this.instance.get_property(me),a={maskAllInputs:null===(e=this.instance.config.session_recording)||void 0===e?void 0:e.maskAllInputs,maskTextSelector:null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.maskTextSelector,blockSelector:null===(i=this.instance.config.session_recording)||void 0===i?void 0:i.blockSelector},l=null!==(s=null==a?void 0:a.maskAllInputs)&&void 0!==s?s:null==o?void 0:o.maskAllInputs,c=null!==(r=null==a?void 0:a.maskTextSelector)&&void 0!==r?r:null==o?void 0:o.maskTextSelector,u=null!==(n=null==a?void 0:a.blockSelector)&&void 0!==n?n:null==o?void 0:o.blockSelector;return $(l)&&$(c)&&$(u)?void 0:{maskAllInputs:null==l||l,maskTextSelector:c,blockSelector:u}}get sampleRate(){var e=this.instance.get_property(ye);return D(e)?e:null}get minimumDuration(){var e=this.instance.get_property(we);return D(e)?e:null}get status(){return this.receivedDecide?this.isRecordingEnabled?!1===this.isSampled?"disabled":this._urlBlocked?"paused":L(this._linkedFlag)||this._linkedFlagSeen?"trigger_pending"===this.triggerStatus?"buffering":q(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var e;return 0===this._urlTriggers.length?"trigger_disabled":(null===(e=this.instance)||void 0===e?void 0:e.get_property(xe))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var e;return 0===this._eventTriggers.length?"trigger_disabled":(null===(e=this.instance)||void 0===e?void 0:e.get_property(Ie))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var e="trigger_activated"===this.eventTriggerStatus||"trigger_activated"===this.urlTriggerStatus,t="trigger_pending"===this.eventTriggerStatus||"trigger_pending"===this.urlTriggerStatus;return e?"trigger_activated":t?"trigger_pending":"trigger_disabled"}constructor(e){if(i(this,"queuedRRWebEvents",[]),i(this,"isIdle",!1),i(this,"_linkedFlagSeen",!1),i(this,"_lastActivityTimestamp",Date.now()),i(this,"_linkedFlag",null),i(this,"_removePageViewCaptureHook",void 0),i(this,"_onSessionIdListener",void 0),i(this,"_persistDecideOnSessionListener",void 0),i(this,"_samplingSessionListener",void 0),i(this,"_urlTriggers",[]),i(this,"_urlBlocklist",[]),i(this,"_urlBlocked",!1),i(this,"_eventTriggers",[]),i(this,"_removeEventTriggerCaptureHook",void 0),i(this,"_forceAllowLocalhostNetworkCapture",!1),i(this,"_onBeforeUnload",(()=>{this._flushBuffer()})),i(this,"_onOffline",(()=>{this._tryAddCustomEvent("browser offline",{})})),i(this,"_onOnline",(()=>{this._tryAddCustomEvent("browser online",{})})),i(this,"_onVisibilityChange",(()=>{if(null!=d&&d.visibilityState){var e="window "+d.visibilityState;this._tryAddCustomEvent(e,{})}})),this.instance=e,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw as.error("started without valid sessionManager"),new Error(os+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(os+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:t,windowId:s}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=t,this.windowId=s,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&as.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(e){this.isRecordingEnabled?(this._startCapture(e),ne(n,"beforeunload",this._onBeforeUnload),ne(n,"offline",this._onOffline),ne(n,"online",this._onOnline),ne(n,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),L(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",(e=>{try{if("$pageview"===e.event){var t=null!=e&&e.properties.$current_url?this._maskUrl(null==e?void 0:e.properties.$current_url):"";if(!t)return;this._tryAddCustomEvent("$pageview",{href:t})}}catch(e){as.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId(((e,t,i)=>{var s,r,n,o;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null===(s=this.instance)||void 0===s||null===(r=s.persistence)||void 0===r||r.unregister(Ie),null===(n=this.instance)||void 0===n||null===(o=n.persistence)||void 0===o||o.unregister(xe))})))):this.stopRecording()}stopRecording(){var e,t,i,s;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,null==n||n.removeEventListener("beforeunload",this._onBeforeUnload),null==n||n.removeEventListener("offline",this._onOffline),null==n||n.removeEventListener("online",this._onOnline),null==n||n.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),null===(e=this._removePageViewCaptureHook)||void 0===e||e.call(this),this._removePageViewCaptureHook=void 0,null===(t=this._removeEventTriggerCaptureHook)||void 0===t||t.call(this),this._removeEventTriggerCaptureHook=void 0,null===(i=this._onSessionIdListener)||void 0===i||i.call(this),this._onSessionIdListener=void 0,null===(s=this._samplingSessionListener)||void 0===s||s.call(this),this._samplingSessionListener=void 0,as.info("stopped"))}makeSamplingDecision(e){var t,i=this.sessionId!==e,s=this.sampleRate;if(D(s)){var r=this.isSampled,n=i||!q(r),o=n?ns(e,s):r;n&&(o?this._reportStarted("sampled"):as.warn("Sample rate (".concat(s,") has determined that this sessionId (").concat(e,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:s,isSampled:o})),null===(t=this.instance.persistence)||void 0===t||t.register({[Ee]:o})}else{var a;null===(a=this.instance.persistence)||void 0===a||a.register({[Ee]:null})}}onRemoteConfig(e){var t,i,s,r,n,o;(this._tryAddCustomEvent("$remote_config_received",e),this._persistRemoteConfig(e),this._linkedFlag=(null===(t=e.sessionRecording)||void 0===t?void 0:t.linkedFlag)||null,null!==(i=e.sessionRecording)&&void 0!==i&&i.endpoint)&&(this._endpoint=null===(o=e.sessionRecording)||void 0===o?void 0:o.endpoint);if(this._setupSampling(),!L(this._linkedFlag)&&!this._linkedFlagSeen){var a=A(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,l=A(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags(((e,t)=>{var i=R(t)&&a in t,s=l?t[a]===l:i;s&&this._reportStarted("linked_flag_matched",{linkedFlag:a,linkedVariant:l}),this._linkedFlagSeen=s}))}null!==(s=e.sessionRecording)&&void 0!==s&&s.urlTriggers&&(this._urlTriggers=e.sessionRecording.urlTriggers),null!==(r=e.sessionRecording)&&void 0!==r&&r.urlBlocklist&&(this._urlBlocklist=e.sessionRecording.urlBlocklist),null!==(n=e.sessionRecording)&&void 0!==n&&n.eventTriggers&&(this._eventTriggers=e.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){D(this.sampleRate)&&L(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId((e=>{this.makeSamplingDecision(e)})))}_persistRemoteConfig(e){if(this.instance.persistence){var i,s=this.instance.persistence,r=()=>{var i,r,n,o,a,l,c,u,d,h=null===(i=e.sessionRecording)||void 0===i?void 0:i.sampleRate,_=L(h)?null:parseFloat(h),p=null===(r=e.sessionRecording)||void 0===r?void 0:r.minimumDurationMilliseconds;s.register({[ge]:!!e.sessionRecording,[ve]:null===(n=e.sessionRecording)||void 0===n?void 0:n.consoleLogRecordingEnabled,[fe]:t({capturePerformance:e.capturePerformance},null===(o=e.sessionRecording)||void 0===o?void 0:o.networkPayloadCapture),[me]:null===(a=e.sessionRecording)||void 0===a?void 0:a.masking,[be]:{enabled:null===(l=e.sessionRecording)||void 0===l?void 0:l.recordCanvas,fps:null===(c=e.sessionRecording)||void 0===c?void 0:c.canvasFps,quality:null===(u=e.sessionRecording)||void 0===u?void 0:u.canvasQuality},[ye]:_,[we]:$(p)?null:p,[Se]:null===(d=e.sessionRecording)||void 0===d?void 0:d.scriptConfig})};r(),null===(i=this._persistDecideOnSessionListener)||void 0===i||i.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(r)}}log(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"log";null===(t=this.instance.sessionRecording)||void 0===t||t.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:i,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}_startCapture(e){if(!$(Object.assign)&&!$(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var t,i;if(this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),this.rrwebRecord)this._onScriptLoaded();else null===(t=f.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,this.scriptName,(e=>{if(e)return as.error("could not load recorder",e);this._onScriptLoaded()}));as.info("starting"),"active"===this.status&&this._reportStarted(e||"recording_initialized")}}get scriptName(){var e,t,i;return(null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t||null===(i=t.get_property(Se))||void 0===i?void 0:i.script)||"recorder"}isInteractiveEvent(e){var t;return 3===e.type&&-1!==cs.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){var t=this.isInteractiveEvent(e);t||this.isIdle||e.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)),!this.isIdle){var{windowId:s,sessionId:r}=this.sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),n=this.sessionId!==r,o=this.windowId!==s;this.windowId=s,this.sessionId=r,n||o?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):i&&this._scheduleFullSnapshot()}}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt++,rrwebMethod:e.rrwebMethod}):as.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(us((()=>this.rrwebRecord.addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(us((()=>this.rrwebRecord.takeFullSnapshot())))}_onScriptLoaded(){var e,i,s,r,n={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},o=this.instance.config.session_recording;for(var[a,l]of Object.entries(o||{}))a in n&&("maskInputOptions"===a?n.maskInputOptions=t({password:!0},l):n[a]=l);(this.canvasRecording&&this.canvasRecording.enabled&&(n.recordCanvas=!0,n.sampling={canvas:this.canvasRecording.fps},n.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.masking)&&(n.maskAllInputs=null===(i=this.masking.maskAllInputs)||void 0===i||i,n.maskTextSelector=null!==(s=this.masking.maskTextSelector)&&void 0!==s?s:void 0,n.blockSelector=null!==(r=this.masking.blockSelector)&&void 0!==r?r:void 0);if(this.rrwebRecord){this.mutationRateLimiter=null!==(e=this.mutationRateLimiter)&&void 0!==e?e:new yi(this.rrwebRecord,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(e,t)=>{var i="Too many mutations on node '".concat(e,"'. Rate limiting. This could be due to SVG animations or something similar");as.info(i,{node:t}),this.log(os+" "+i,"warn")}});var c=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord(t({emit:e=>{this.onRRwebEmit(e)},plugins:c},n)),this._lastActivityTimestamp=Date.now(),this.isIdle=!1,this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:n,activePlugins:c.map((e=>null==e?void 0:e.name))}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else as.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!this.isIdle){var e=this.fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}}_gatherRRWebPlugins(){var e,t,i,s,r=[],n=null===(e=f.__PosthogExtensions__)||void 0===e||null===(t=e.rrwebPlugins)||void 0===t?void 0:t.getRecordConsolePlugin;n&&this.isConsoleLogCaptureEnabled&&r.push(n());var o=null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.rrwebPlugins)||void 0===s?void 0:s.getRecordNetworkPlugin;this.networkPayloadCapture&&F(o)&&(!bt.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?r.push(o(mi(this.instance.config,this.networkPayloadCapture))):as.info("NetworkCapture not started because we are on localhost."));return r}onRRwebEmit(e){var i;if(this._processQueuedEvents(),e&&R(e)){if(e.type===li.Meta){var s=this._maskUrl(e.data.href);if(this._lastHref=s,!s)return;e.data.href=s}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),!this._urlBlocked||function(e){return e.type===li.Custom&&"recording paused"===e.data.tag}(e)){e.type===li.FullSnapshot&&this._scheduleFullSnapshot(),e.type===li.FullSnapshot&&"trigger_pending"===this.triggerStatus&&this.clearBuffer();var r=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(r){var n=function(e){var t=e;if(t&&R(t)&&6===t.type&&R(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));for(var i=[],s=0;s<t.data.payload.payload.length;s++)t.data.payload.payload[s]&&t.data.payload.payload[s].length>2e3?i.push(t.data.payload.payload[s].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[s]);return t.data.payload.payload=i,e}return e}(r);if(this._updateWindowAndSessionIds(n),!this.isIdle||hs(n)){if(hs(n)){var o=n.data.payload;if(o){var a=o.lastActivityTimestamp,l=o.threshold;n.timestamp=a+l}}var c=null===(i=this.instance.config.session_recording.compress_events)||void 0===i||i?function(e){if(oi(e)<1024)return e;try{if(e.type===li.FullSnapshot)return t(t({},e),{},{data:ds(e.data),cv:"2024-10"});if(e.type===li.IncrementalSnapshot&&e.data.source===ci.Mutation)return t(t({},e),{},{cv:"2024-10",data:t(t({},e.data),{},{texts:ds(e.data.texts),attributes:ds(e.data.attributes),removes:ds(e.data.removes),adds:ds(e.data.adds)})});if(e.type===li.IncrementalSnapshot&&e.data.source===ci.StyleSheetRule)return t(t({},e),{},{cv:"2024-10",data:t(t({},e.data),{},{adds:e.data.adds?ds(e.data.adds):void 0,removes:e.data.removes?ds(e.data.removes):void 0})})}catch(e){as.error("could not compress event - will use uncompressed event",e)}return e}(n):n,u={$snapshot_bytes:oi(c),$snapshot_data:c,$session_id:this.sessionId,$window_id:this.windowId};"disabled"!==this.status?this._captureSnapshotBuffered(u):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&n){var e=this._maskUrl(n.location.href);this._lastHref!==e&&(this._tryAddCustomEvent("$url_changed",{href:e}),this._lastHref=e)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var e=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],e.forEach((e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)}))}}_maskUrl(e){var t=this.instance.config.session_recording;if(t.maskNetworkRequestFn){var i,s={url:e};return null===(i=s=t.maskNetworkRequestFn(s))||void 0===i?void 0:i.url}return e}clearBuffer(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}_flushBuffer(){this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var e=this.minimumDuration,t=this.sessionDuration,i=D(t)&&t>=0,s=D(e)&&i&&t<e;if("buffering"===this.status||"paused"===this.status||"disabled"===this.status||s)return this.flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3),this.buffer;this.buffer.data.length>0&&ai(this.buffer).forEach((e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId,$lib:"web",$lib_version:U.LIB_VERSION})}));return this.clearBuffer()}_captureSnapshotBuffered(e){var t,i=2+((null===(t=this.buffer)||void 0===t?void 0:t.data.length)||0);!this.isIdle&&(this.buffer.size+e.$snapshot_bytes+i>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=e.$snapshot_bytes,this.buffer.data.push(e.$snapshot_data),this.flushBufferTimer||this.isIdle||(this.flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3))}_captureSnapshot(e){this.instance.capture("$snapshot",e,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_checkUrlTriggerConditions(){if(void 0!==n&&n.location.href){var e=n.location.href,t=this._urlBlocked,i=_s(e,this._urlBlocklist);i&&!t?this._pauseRecording():!i&&t&&this._resumeRecording(),_s(e,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(e){var t,i;"trigger_pending"===this.triggerStatus&&(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({["url"===e?xe:Ie]:this.sessionId}),this._flushBuffer(),this._reportStarted(e+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),as.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlBlocked&&(this._urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),as.info("recording resumed"))}_addEventTriggerListener(){0!==this._eventTriggers.length&&L(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",(e=>{try{this._eventTriggers.includes(e.event)&&this._activateTrigger("event")}catch(e){as.error("Could not activate event trigger",e)}})))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null===(e=this.instance.persistence)||void 0===e||e.register({[Ee]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e)}_reportStarted(e,t){this.instance.register_for_session({$session_recording_start_reason:e}),as.info(e.replace("_"," "),t),w(["recording_initialized","session_id_changed"],e)||this._tryAddCustomEvent(e,t)}}var gs=W("[SegmentIntegration]");function vs(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var s=i=>{var s=()=>i.anonymousId()||Dt();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(Oe,"identified")),t()},r=i.user();"then"in r&&F(r.then)?r.then((e=>s(e))):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||gs.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{var s;if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(gs.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(gs.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e._calculate_event_properties(i,null!==(s=t.event.properties)&&void 0!==s?s:{},new Date);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}var fs="posthog-js";function ms(e){var{organization:i,projectId:s,prefix:r,severityAllowList:n=["error"]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o=>{var a,l,c,u,d;if(!("*"===n||n.includes(o.level))||!e.__loaded)return o;o.tags||(o.tags={});var h=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var _=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],p=_.map((e=>t(t({},e),{},{stacktrace:e.stacktrace?t(t({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>t(t({},e),{},{platform:"web:javascript"})))}):void 0}))),g={$exception_message:(null===(l=_[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=_[0])||void 0===c?void 0:c.type,$exception_personURL:h,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=_[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=_[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};return i&&s&&(g.$sentry_url=(r||"https://sentry.io/organizations/")+i+"/issues/?project="+s+"&query="+o.event_id),e.exceptions.sendExceptionEvent(g),o}}class bs{constructor(e,t,i,s,r){this.name=fs,this.setupOnce=function(n){n(ms(e,{organization:t,projectId:i,prefix:s,severityAllowList:r}))}}}var ys,ws=null!=n&&n.location?Et(n.location.hash,"__posthog")||Et(location.hash,"state"):null,Ss="_postHogToolbarParams",ks=W("[Toolbar]");!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"}(ys||(ys={}));class Es{constructor(e){this.instance=e}setToolbarState(e){f.ph_toolbar_state=e}getToolbarState(){var e;return null!==(e=f.ph_toolbar_state)&&void 0!==e?e:ys.UNINITIALIZED}maybeLoadToolbar(){var e,t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if(!n||!d)return!1;i=null!==(e=i)&&void 0!==e?e:n.location,r=null!==(t=r)&&void 0!==t?t:n.history;try{if(!s){try{n.localStorage.setItem("test","test"),n.localStorage.removeItem("test")}catch(e){return!1}s=null==n?void 0:n.localStorage}var o,a=ws||Et(i.hash,"__posthog")||Et(i.hash,"state"),l=a?Q((()=>JSON.parse(atob(decodeURIComponent(a)))))||Q((()=>JSON.parse(decodeURIComponent(a)))):null;return l&&"ph_authorize"===l.action?((o=l).source="url",o&&Object.keys(o).length>0&&(l.desiredHash?i.hash=l.desiredHash:r?r.replaceState(r.state,"",i.pathname+i.search):i.hash="")):((o=JSON.parse(s.getItem(Ss)||"{}")).source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token)&&(this.loadToolbar(o),!0)}catch(e){return!1}}_callLoadToolbar(e){var t=f.ph_load_toolbar||f.ph_load_editor;!L(t)&&F(t)?t(e,this.instance):ks.warn("No toolbar load function found")}loadToolbar(e){var i=!(null==d||!d.getElementById(He));if(!n||i)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=t(t({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(n.localStorage.setItem(Ss,JSON.stringify(t(t({},r),{},{source:void 0}))),this.getToolbarState()===ys.LOADED)this._callLoadToolbar(r);else if(this.getToolbarState()===ys.UNINITIALIZED){var o,a;this.setToolbarState(ys.LOADING),null===(o=f.__PosthogExtensions__)||void 0===o||null===(a=o.loadExternalDependency)||void 0===a||a.call(o,this.instance,"toolbar",(e=>{if(e)return ks.error("[Toolbar] Failed to load",e),void this.setToolbarState(ys.UNINITIALIZED);this.setToolbarState(ys.LOADED),this._callLoadToolbar(r)})),ne(n,"turbolinks:load",(()=>{this.setToolbarState(ys.UNINITIALIZED),this.loadToolbar(r)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return this.maybeLoadToolbar(e,t,i)}}var xs=W("[TracingHeaders]");class Is{constructor(e){i(this,"_restoreXHRPatch",void 0),i(this,"_restoreFetchPatch",void 0),i(this,"_startCapturing",(()=>{var e,t,i,s;$(this._restoreXHRPatch)&&(null===(e=f.__PosthogExtensions__)||void 0===e||null===(t=e.tracingHeadersPatchFns)||void 0===t||t._patchXHR(this.instance.sessionManager));$(this._restoreFetchPatch)&&(null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.tracingHeadersPatchFns)||void 0===s||s._patchFetch(this.instance.sessionManager))})),this.instance=e}_loadScript(e){var t,i,s;null!==(t=f.__PosthogExtensions__)&&void 0!==t&&t.tracingHeadersPatchFns&&e(),null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"tracing-headers",(t=>{if(t)return xs.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var Ps=W("[Web Vitals]"),Cs=9e5;class Fs{constructor(e){var s;i(this,"_enabledServerSide",!1),i(this,"_initialized",!1),i(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),i(this,"_flushToCapture",(()=>{clearTimeout(this._delayedFlushTimer),0!==this.buffer.metrics.length&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce(((e,i)=>t(t({},e),{},{["$web_vitals_".concat(i.name,"_event")]:t({},i),["$web_vitals_".concat(i.name,"_value")]:i.value})),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})})),i(this,"_addToBuffer",(e=>{var i,s=null===(i=this.instance.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0);if($(s))Ps.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!$(r))if(L(null==e?void 0:e.name)||L(null==e?void 0:e.value))Ps.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)Ps.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this.buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),$(this.buffer.url)&&(this.buffer.url=r),this.buffer.firstMetricTimestamp=$(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(t(t({},e),{},{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}})),i(this,"_startCapturing",(()=>{var e,t,i,s,r=f.__PosthogExtensions__;$(r)||$(r.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:s}=r.postHogWebVitalsCallbacks),e&&t&&i&&s?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this)),this._initialized=!0):Ps.error("web vitals callbacks not loaded - not starting")})),this.instance=e,this._enabledServerSide=!(null===(s=this.instance.persistence)||void 0===s||!s.props[he]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=R(this.instance.config.capture_performance)?null===(e=this.instance.config.capture_performance)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return $(i)?(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[pe])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(R(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=R(this.instance.config.capture_performance)&&D(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Cs;return 0<e&&e<=6e4?Cs:e}get isEnabled(){var e=R(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return q(e)?e:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Ps.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(e){var t=R(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=R(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[he]:t}),this.instance.persistence.register({[pe]:i})),this._enabledServerSide=t,this.startIfEnabled()}loadScript(e){var t,i,s;null!==(t=f.__PosthogExtensions__)&&void 0!==t&&t.postHogWebVitalsCallbacks&&e(),null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"web-vitals",(t=>{t?Ps.error("failed to load script",t):e()}))}_currentURL(){var e=n?n.location.href:void 0;return e||Ps.error("Could not determine current URL"),e}}var Rs=W("[Heatmaps]");function Ts(e){return R(e)&&"clientX"in e&&"clientY"in e&&D(e.clientX)&&D(e.clientY)}class $s{constructor(e){var t;i(this,"rageclicks",new mt),i(this,"_enabledServerSide",!1),i(this,"_initialized",!1),i(this,"_flushInterval",null),this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[ue])}get flushIntervalMilliseconds(){var e=5e3;return R(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return $(this.instance.config.capture_heatmaps)?$(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Rs.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),null===(t=this.deadClicksCapture)||void 0===t||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ue]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.buffer;return this.buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_setupListeners(){n&&d&&(ne(n,"beforeunload",this.flush.bind(this)),ne(d,"click",(e=>this._onClick(e||(null==n?void 0:n.event))),{capture:!0}),ne(d,"mousemove",(e=>this._onMouseMove(e||(null==n?void 0:n.event))),{capture:!0}),this.deadClicksCapture=new si(this.instance,ti,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(e,t,i){for(var s=e;s&&We(s)&&!Ve(s,"body");){if(s===i)return!1;if(w(t,null==n?void 0:n.getComputedStyle(s).position))return!0;s=it(s)}return!1}(et(e),["fixed","sticky"],r);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:i),target_fixed:o,type:t}}_onClick(e){var i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"click";if(!je(e.target)&&Ts(e)){var r=this._getProperties(e,s);null!==(i=this.rageclicks)&&void 0!==i&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(t(t({},r),{},{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!je(e.target)&&Ts(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(n){var t=n.location.href;this.buffer=this.buffer||{},this.buffer[t]||(this.buffer[t]=[]),this.buffer[t].push(e)}}flush(){this.buffer&&!T(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class As{constructor(e){this._instance=e}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==n?void 0:n.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null===(t=this._currentPageview)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this._currentPageview)||void 0===e?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=r;if(!($(n)||$(o)||$(a)||$(l)||$(c)||$(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=n<=1?1:bi(o/n,0,1),h=n<=1?1:bi(a/n,0,1),_=l<=1?1:bi(c/l,0,1),p=l<=1?1:bi(u/l,0,1);s=Y(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}}class Os{constructor(e){this.instance=e}sendExceptionEvent(e){this.instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}}var Ms,Ls=W("[FeatureFlags]"),Ds="$active_feature_flags",qs="$override_feature_flags",Ns="$feature_flag_payloads",Bs="$override_feature_flag_payloads",Hs="$feature_flag_request_id",Us=e=>{var t={};for(var[i,s]of X(e||{}))s&&(t[i]=s);return t};!function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"}(Ms||(Ms={}));class zs{constructor(e){i(this,"_override_warning",!1),i(this,"_hasLoadedFlags",!1),i(this,"_requestInFlight",!1),i(this,"_reloadingDisabled",!1),i(this,"_additionalReloadRequested",!1),i(this,"_decideCalled",!1),i(this,"_flagsLoadedFromRemote",!1),this.instance=e,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var e=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagVariants(){var e=this.instance.get_property(Pe),t=this.instance.get_property(qs);if(!t)return e||{};for(var i=Y({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(Ls.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this.instance.get_property(Ns),t=this.instance.get_property(Bs);if(!t)return e||{};for(var i=Y({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(Ls.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callDecideEndpoint()}),5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callDecideEndpoint(e){var i;if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var s={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:t(t({},(null===(i=this.instance.persistence)||void 0===i?void 0:i.get_initial_props())||{}),this.instance.get_property(Fe)||{}),group_properties:this.instance.get_property(Re)};(null!=e&&e.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:s,compression:this.instance.config.disable_compression?void 0:r.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,n=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),n=!1),this._requestInFlight=!1,this._decideCalled)||(this._decideCalled=!0,this.instance._onRemoteConfig(null!==(r=e.json)&&void 0!==r?r:{}));s.disable_flags&&!this._additionalReloadRequested||(this._flagsLoadedFromRemote=!n,e.json&&null!==(t=e.json.quotaLimited)&&void 0!==t&&t.includes(Ms.FeatureFlags)?Ls.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(this.receivedFeatureFlags(null!==(i=e.json)&&void 0!==i?i:{},n),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint())))}})}}getFeatureFlag(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i,s,r,n,o,a=this.getFlagVariants()[e],l="".concat(a),c=this.instance.get_property(Hs)||void 0,u=this.instance.get_property(Ae)||{};if(t.send_event||!("send_event"in t))if(!(e in u)||!u[e].includes(l))C(u[e])?u[e].push(l):u[e]=[l],null===(i=this.instance.persistence)||void 0===i||i.register({[Ae]:u}),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:a,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:c,$feature_flag_bootstrapped_response:(null===(s=this.instance.config.bootstrap)||void 0===s||null===(r=s.featureFlags)||void 0===r?void 0:r[e])||null,$feature_flag_bootstrapped_payload:(null===(n=this.instance.config.bootstrap)||void 0===n||null===(o=n.featureFlagPayloads)||void 0===o?void 0:o[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote});return a}Ls.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var i=this.instance.config.token;this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:{distinct_id:this.instance.get_distinct_id(),token:i},compression:this.instance.config.disable_compression?void 0:r.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:i=>{var s,r=null===(s=i.json)||void 0===s?void 0:s.featureFlagPayloads;t((null==r?void 0:r[e])||void 0)}})}isFeatureEnabled(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);Ls.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,i){if(this.instance.persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads();!function(e,i){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=e.featureFlags,o=e.featureFlagPayloads,a=e.requestId;if(n)if(C(n)){var l={};if(n)for(var c=0;c<n.length;c++)l[n[c]]=!0;i&&i.register({[Ds]:n,[Pe]:l})}else{var u=n,d=o;e.errorsWhileComputingFlags&&(u=t(t({},s),u),d=t(t({},r),d)),i&&i.register(t({[Ds]:Object.keys(Us(u)),[Pe]:u||{},[Ns]:d||{}},a?{[Hs]:a}:{}))}}(e,this.instance.persistence,s,r),this._fireFeatureFlagsCallbacks(i)}}override(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Ls.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this.instance.__loaded||!this.instance.persistence)return Ls.uninitializedWarning("posthog.feature_flags.overrideFeatureFlags");if(!1===e)return this.instance.persistence.unregister(qs),this.instance.persistence.unregister(Bs),void this._fireFeatureFlagsCallbacks();if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this.instance.persistence.unregister(qs);else if(i.flags)if(C(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this.instance.persistence.register({[qs]:s})}else this.instance.persistence.register({[qs]:i.flags});return"payloads"in i&&(!1===i.payloads?this.instance.persistence.unregister(Bs):i.payloads&&this.instance.persistence.register({[Bs]:i.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,i){var s,r=(this.instance.get_property(Ce)||[]).find((t=>t.flagKey===e)),n={["$feature_enrollment/".concat(e)]:i},o={$feature_flag:e,$feature_enrollment:i,$set:n};r&&(o.$early_access_feature_name=r.name),this.instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=t(t({},this.getFlagVariants()),{},{[e]:i});null===(s=this.instance.persistence)||void 0===s||s.register({[Ds]:Object.keys(Us(a)),[Pe]:a}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0,s=this.instance.get_property(Ce),r=i?"&".concat(i.map((e=>"stage=".concat(e))).join("&")):"";if(s&&!t)return e(s);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token).concat(r)),method:"GET",callback:t=>{var i;if(t.json){var s=t.json.earlyAccessFeatures;return null===(i=this.instance.persistence)||void 0===i||i.register({[Ce]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=this.instance.get_property(Fe)||{};this.instance.register({[Fe]:t(t({},s),e)}),i&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(Fe)}setGroupPropertiesForFlags(e){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=this.instance.get_property(Re)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((i=>{s[i]=t(t({},s[i]),e[i]),delete e[i]})),this.instance.register({[Re]:t(t({},s),e)}),i&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var i=this.instance.get_property(Re)||{};this.instance.register({[Re]:t(t({},i),{},{[e]:{}})})}else this.instance.unregister(Re)}}var js="Mobile",Ws="iOS",Vs="Android",Gs="Tablet",Js=Vs+" "+Gs,Ys="iPad",Ks="Apple",Xs=Ks+" Watch",Qs="Safari",Zs="BlackBerry",er="Samsung",tr=er+"Browser",ir=er+" Internet",sr="Chrome",rr=sr+" OS",nr=sr+" "+Ws,or="Internet Explorer",ar=or+" "+js,lr="Opera",cr=lr+" Mini",ur="Edge",dr="Microsoft "+ur,hr="Firefox",_r=hr+" "+Ws,pr="Nintendo",gr="PlayStation",vr="Xbox",fr=Vs+" "+js,mr=js+" "+Qs,br="Windows",yr=br+" Phone",wr="Nokia",Sr="Ouya",kr="Generic",Er=kr+" "+js.toLowerCase(),xr=kr+" "+Gs.toLowerCase(),Ir="Konqueror",Pr="(\\d+(\\.\\d+)?)",Cr=new RegExp("Version/"+Pr),Fr=new RegExp(vr,"i"),Rr=new RegExp(gr+" \\w+","i"),Tr=new RegExp(pr+" \\w+","i"),$r=new RegExp(Zs+"|PlayBook|BB10","i"),Ar={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var Or=(e,t)=>t&&w(t,Ks)||function(e){return w(e,Qs)&&!w(e,sr)&&!w(e,Vs)}(e),Mr=function(e,t){return t=t||"",w(e," OPR/")&&w(e,"Mini")?cr:w(e," OPR/")?lr:$r.test(e)?Zs:w(e,"IE"+js)||w(e,"WPDesktop")?ar:w(e,tr)?ir:w(e,ur)||w(e,"Edg/")?dr:w(e,"FBIOS")?"Facebook "+js:w(e,"UCWEB")||w(e,"UCBrowser")?"UC Browser":w(e,"CriOS")?nr:w(e,"CrMo")||w(e,sr)?sr:w(e,Vs)&&w(e,Qs)?fr:w(e,"FxiOS")?_r:w(e.toLowerCase(),Ir.toLowerCase())?Ir:Or(e,t)?w(e,js)?mr:Qs:w(e,hr)?hr:w(e,"MSIE")||w(e,"Trident/")?or:w(e,"Gecko")?hr:""},Lr={[ar]:[new RegExp("rv:"+Pr)],[dr]:[new RegExp(ur+"?\\/"+Pr)],[sr]:[new RegExp("("+sr+"|CrMo)\\/"+Pr)],[nr]:[new RegExp("CriOS\\/"+Pr)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Pr)],[Qs]:[Cr],[mr]:[Cr],[lr]:[new RegExp("(Opera|OPR)\\/"+Pr)],[hr]:[new RegExp(hr+"\\/"+Pr)],[_r]:[new RegExp("FxiOS\\/"+Pr)],[Ir]:[new RegExp("Konqueror[:/]?"+Pr,"i")],[Zs]:[new RegExp(Zs+" "+Pr),Cr],[fr]:[new RegExp("android\\s"+Pr,"i")],[ir]:[new RegExp(tr+"\\/"+Pr)],[or]:[new RegExp("(rv:|MSIE )"+Pr)],Mozilla:[new RegExp("rv:"+Pr)]},Dr=[[new RegExp(vr+"; "+vr+" (.*?)[);]","i"),e=>[vr,e&&e[1]||""]],[new RegExp(pr,"i"),[pr,""]],[new RegExp(gr,"i"),[gr,""]],[$r,[Zs,""]],[new RegExp(br,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[yr,""];if(new RegExp(js).test(t)&&!/IEMobile\b/.test(t))return[br+" "+js,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=i[1],r=Ar[s]||"";return/arm/i.test(t)&&(r="RT"),[br,r]}return[br,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[Ws,t.join(".")]}return[Ws,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=$(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Vs+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Vs+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Vs,t.join(".")]}return[Vs,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[rr,""]],[/Linux|debian/i,["Linux",""]]],qr=function(e){return Tr.test(e)?pr:Rr.test(e)?gr:Fr.test(e)?vr:new RegExp(Sr,"i").test(e)?Sr:new RegExp("("+yr+"|WPDesktop)","i").test(e)?yr:/iPad/.test(e)?Ys:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Xs:$r.test(e)?Zs:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(wr,"i").test(e)?wr:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(js).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Vs:Js:Vs:new RegExp("(pda|"+js+")","i").test(e)?Er:new RegExp(Gs,"i").test(e)&&!new RegExp(Gs+" pc","i").test(e)?xr:""},Nr="https?://(.*)",Br=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],Hr=K(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Br),Ur="<masked>",zr={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:t,customPersonalDataProperties:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!d)return{};var s=t?K([],Br,i||[]):[];return this._campaignParamsFromUrl(kt(d.URL,s,Ur),e)},_campaignParamsFromUrl:function(e,t){var i=Hr.concat(t||[]),s={};return J(i,(function(t){var i=St(e,t);s[t]=i||null})),s},_searchEngine:function(e){return e?0===e.search(Nr+"google.([^/?]*)")?"google":0===e.search(Nr+"bing.com")?"bing":0===e.search(Nr+"yahoo.com")?"yahoo":0===e.search(Nr+"duckduckgo.com")?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=zr._searchEngine(e),i="yahoo"!=t?"q":"p",s={};if(!M(t)){s.$search_engine=t;var r=d?St(d.referrer,i):"";r.length&&(s.ph_keyword=r)}return s},searchInfo:function(){var e=null==d?void 0:d.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:Mr,browserVersion:function(e,t){var i=Mr(e,t),s=Lr[i];if($(s))return null;for(var r=0;r<s.length;r++){var n=s[r],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return"string"==typeof e?e.split("-")[0]:void 0},os:function(e){for(var t=0;t<Dr.length;t++){var[i,s]=Dr[t],r=i.exec(e),n=r&&(F(s)?s(r,e):s);if(n)return n}return["",""]},device:qr,deviceType:function(e){var t=qr(e);return t===Ys||t===Js||"Kobo"===t||"Kindle Fire"===t||t===xr?Gs:t===pr||t===vr||t===gr||t===Sr?"Console":t===Xs?"Wearable":t?js:"Desktop"},referrer:function(){return(null==d?void 0:d.referrer)||"$direct"},referringDomain:function(){var e;return null!=d&&d.referrer&&(null===(e=yt(d.referrer))||void 0===e?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e?K([],Br,t||[]):[],s=null==h?void 0:h.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:s?kt(s,i,Ur):void 0}},personPropsFromInfo:function(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null===(t=yt(i))||void 0===t?void 0:t.host};if(s){r.$current_url=s;var n=yt(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=this._campaignParamsFromUrl(s);Y(r,o)}if(i){var a=this._searchInfoFromReferrer(i);Y(r,a)}return r},initialPersonPropsFromInfo:function(e){var t=this.personPropsFromInfo(e),i={};return J(t,(function(e,t){i["$initial_".concat(k(t))]=e})),i},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}},timezoneOffset:function(){try{return(new Date).getTimezoneOffset()}catch(e){return}},properties:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!v)return{};var i=e?K([],Br,t||[]):[],[s,r]=zr.os(v);return Y(ee({$os:s,$os_version:r,$browser:zr.browser(v,navigator.vendor),$device:zr.device(v),$device_type:zr.deviceType(v),$timezone:zr.timezone(),$timezone_offset:zr.timezoneOffset()}),{$current_url:kt(null==h?void 0:h.href,i,Ur),$host:null==h?void 0:h.host,$pathname:null==h?void 0:h.pathname,$raw_user_agent:v.length>1e3?v.substring(0,997)+"...":v,$browser_version:zr.browserVersion(v,navigator.vendor),$browser_language:zr.browserLanguage(),$browser_language_prefix:zr.browserLanguagePrefix(),$screen_height:null==n?void 0:n.screen.height,$screen_width:null==n?void 0:n.screen.width,$viewport_height:null==n?void 0:n.innerHeight,$viewport_width:null==n?void 0:n.innerWidth,$lib:"web",$lib_version:U.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!v)return{};var[e,t]=zr.os(v);return Y(ee({$os:e,$os_version:t,$browser:zr.browser(v,navigator.vendor)}),{$browser_version:zr.browserVersion(v,navigator.vendor)})}},jr=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Wr{constructor(e){this.config=e,this.props={},this.campaign_params_saved=!1,this.name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this.storage=this.buildStorage(e),this.load(),e.debug&&j.info("Persistence loaded",e.persistence,t({},this.props)),this.update_config(e,e),this.save()}buildStorage(e){-1===jr.indexOf(e.persistence.toLowerCase())&&(j.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Vt.is_supported()?Vt:"localstorage+cookie"===t&&Jt.is_supported()?Jt:"sessionstorage"===t&&Qt.is_supported()?Qt:"memory"===t?Kt:"cookie"===t?jt:Jt.is_supported()?Jt:jt}properties(){var e={};return J(this.props,(function(t,i){if(i===Pe&&R(t))for(var s=Object.keys(t),r=0;r<s.length;r++)e["$feature/".concat(s[r])]=t[s[r]];else o=i,a=!1,(M(n=ze)?a:c&&n.indexOf===c?-1!=n.indexOf(o):(J(n,(function(e){if(a||(a=e===o))return V})),a))||(e[i]=t);var n,o,a})),e}load(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=Y({},e))}}save(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}remove(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(R(e)){$(t)&&(t="None"),this.expire_days=$(i)?this.default_expiry:i;var s=!1;if(J(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(R(e)){this.expire_days=$(t)?this.default_expiry:t;var i=!1;if(J(e,((t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this.props[s]=t,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var e=zr.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});T(ee(e))||this.register(e),this.campaign_params_saved=!0}}update_search_keyword(){this.register(zr.searchInfo())}update_referrer_info(){this.register_once(zr.referrerInfo(),void 0)}set_initial_person_info(){this.props[De]||this.props[qe]||this.register_once({[Ne]:zr.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return ee({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var e={};J([qe,De],(t=>{var i=this.props[t];i&&J(i,(function(t,i){e["$initial_"+k(i)]=t}))}));var t=this.props[Ne];if(t){var i=zr.initialPersonPropsFromInfo(t);Y(e,i)}return e}safe_merge(e){return J(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t){if(this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var i=this.buildStorage(e),s=this.props;this.clear(),this.storage=i,this.props=s,this.save()}}set_disabled(e){this.disabled=e,this.disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(e){e!==this.secure&&(this.secure=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[le]||{};i[e]=t,this.props[le]=i,this.save()}remove_event_timer(e){var t=(this.props[le]||{})[e];return $(t)||(delete this.props[le][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var Vr,Gr,Jr,Yr,Kr,Xr,Qr,Zr,en,tn,sn,rn,nn={},on=[],an=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ln=Array.isArray;function cn(e,t){for(var i in t)e[i]=t[i];return e}function un(e){var t=e.parentNode;t&&t.removeChild(e)}function dn(e,t,i,s,r){var n={type:e,props:t,key:i,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++Jr:r,__i:-1,__u:0};return null==r&&null!=Gr.vnode&&Gr.vnode(n),n}function hn(e){return e.children}function _n(e,t){this.props=e,this.context=t}function pn(e,t){if(null==t)return e.__?pn(e.__,e.__i+1):null;for(var i;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?pn(e):null}function gn(e){var t,i;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e){e.__e=e.__c.base=i.__e;break}return gn(e)}}function vn(e){(!e.__d&&(e.__d=!0)&&Yr.push(e)&&!fn.__r++||Kr!==Gr.debounceRendering)&&((Kr=Gr.debounceRendering)||Xr)(fn)}function fn(){var e,t,i,s,r,n,o,a,l;for(Yr.sort(Qr);e=Yr.shift();)e.__d&&(t=Yr.length,s=void 0,n=(r=(i=e).__v).__e,a=[],l=[],(o=i.__P)&&((s=cn({},r)).__v=r.__v+1,Gr.vnode&&Gr.vnode(s),In(o,s,r,i.__n,void 0!==o.ownerSVGElement,32&r.__u?[n]:null,a,null==n?pn(r):n,!!(32&r.__u),l),s.__.__k[s.__i]=s,Pn(a,s,l),s.__e!=n&&gn(s)),Yr.length>t&&Yr.sort(Qr));fn.__r=0}function mn(e,t,i,s,r,n,o,a,l,c,u){var d,h,_,p,g,v=s&&s.__k||on,f=t.length;for(i.__d=l,bn(i,t,v),l=i.__d,d=0;d<f;d++)null!=(_=i.__k[d])&&"boolean"!=typeof _&&"function"!=typeof _&&(h=-1===_.__i?nn:v[_.__i]||nn,_.__i=d,In(e,_,h,r,n,o,a,l,c,u),p=_.__e,_.ref&&h.ref!=_.ref&&(h.ref&&Fn(h.ref,null,_),u.push(_.ref,_.__c||p,_)),null==g&&null!=p&&(g=p),65536&_.__u||h.__k===_.__k?l=yn(_,l,e):"function"==typeof _.type&&void 0!==_.__d?l=_.__d:p&&(l=p.nextSibling),_.__d=void 0,_.__u&=-196609);i.__d=l,i.__e=g}function bn(e,t,i){var s,r,n,o,a,l=t.length,c=i.length,u=c,d=0;for(e.__k=[],s=0;s<l;s++)null!=(r=e.__k[s]=null==(r=t[s])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?dn(null,r,null,null,r):ln(r)?dn(hn,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?dn(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,a=wn(r,i,o=s+d,u),r.__i=a,n=null,-1!==a&&(u--,(n=i[a])&&(n.__u|=131072)),null==n||null===n.__v?(-1==a&&d--,"function"!=typeof r.type&&(r.__u|=65536)):a!==o&&(a===o+1?d++:a>o?u>l-o?d+=a-o:d--:d=a<o&&a==o-1?a-o:0,a!==s+d&&(r.__u|=65536))):(n=i[s])&&null==n.key&&n.__e&&(n.__e==e.__d&&(e.__d=pn(n)),Rn(n,n,!1),i[s]=null,u--);if(u)for(s=0;s<c;s++)null!=(n=i[s])&&0==(131072&n.__u)&&(n.__e==e.__d&&(e.__d=pn(n)),Rn(n,n))}function yn(e,t,i){var s,r;if("function"==typeof e.type){for(s=e.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=e,t=yn(s[r],t,i));return t}return e.__e!=t&&(i.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function wn(e,t,i,s){var r=e.key,n=e.type,o=i-1,a=i+1,l=t[i];if(null===l||l&&r==l.key&&n===l.type)return i;if(s>(null!=l&&0==(131072&l.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((l=t[o])&&0==(131072&l.__u)&&r==l.key&&n===l.type)return o;o--}if(a<t.length){if((l=t[a])&&0==(131072&l.__u)&&r==l.key&&n===l.type)return a;a++}}return-1}function Sn(e,t,i){"-"===t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||an.test(t)?i:i+"px"}function kn(e,t,i,s,r){var n;e:if("style"===t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof s&&(e.style.cssText=s=""),s)for(t in s)i&&t in i||Sn(e.style,t,"");if(i)for(t in i)s&&i[t]===s[t]||Sn(e.style,t,i[t])}else if("o"===t[0]&&"n"===t[1])n=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+n]=i,i?s?i.u=s.u:(i.u=Date.now(),e.addEventListener(t,n?xn:En,n)):e.removeEventListener(t,n?xn:En,n);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,i))}}function En(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Gr.event?Gr.event(e):e)}function xn(e){return this.l[e.type+!0](Gr.event?Gr.event(e):e)}function In(e,t,i,s,r,n,o,a,l,c){var u,d,h,_,p,g,v,f,m,b,y,w,S,k,E,x=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(l=!!(32&i.__u),n=[a=t.__e=i.__e]),(u=Gr.__b)&&u(t);e:if("function"==typeof x)try{if(f=t.props,m=(u=x.contextType)&&s[u.__c],b=u?m?m.props.value:u.__:s,i.__c?v=(d=t.__c=i.__c).__=d.__E:("prototype"in x&&x.prototype.render?t.__c=d=new x(f,b):(t.__c=d=new _n(f,b),d.constructor=x,d.render=Tn),m&&m.sub(d),d.props=f,d.state||(d.state={}),d.context=b,d.__n=s,h=d.__d=!0,d.__h=[],d._sb=[]),null==d.__s&&(d.__s=d.state),null!=x.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=cn({},d.__s)),cn(d.__s,x.getDerivedStateFromProps(f,d.__s))),_=d.props,p=d.state,d.__v=t,h)null==x.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(null==x.getDerivedStateFromProps&&f!==_&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(f,b),!d.__e&&(null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(f,d.__s,b)||t.__v===i.__v)){for(t.__v!==i.__v&&(d.props=f,d.state=d.__s,d.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.forEach((function(e){e&&(e.__=t)})),y=0;y<d._sb.length;y++)d.__h.push(d._sb[y]);d._sb=[],d.__h.length&&o.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(f,d.__s,b),null!=d.componentDidUpdate&&d.__h.push((function(){d.componentDidUpdate(_,p,g)}))}if(d.context=b,d.props=f,d.__P=e,d.__e=!1,w=Gr.__r,S=0,"prototype"in x&&x.prototype.render){for(d.state=d.__s,d.__d=!1,w&&w(t),u=d.render(d.props,d.state,d.context),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[]}else do{d.__d=!1,w&&w(t),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(s=cn(cn({},s),d.getChildContext())),h||null==d.getSnapshotBeforeUpdate||(g=d.getSnapshotBeforeUpdate(_,p)),mn(e,ln(E=null!=u&&u.type===hn&&null==u.key?u.props.children:u)?E:[E],t,i,s,r,n,o,a,l,c),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),v&&(d.__E=d.__=null)}catch(e){t.__v=null,l||null!=n?(t.__e=a,t.__u|=l?160:32,n[n.indexOf(a)]=null):(t.__e=i.__e,t.__k=i.__k),Gr.__e(e,t,i)}else null==n&&t.__v===i.__v?(t.__k=i.__k,t.__e=i.__e):t.__e=Cn(i.__e,t,i,s,r,n,o,l,c);(u=Gr.diffed)&&u(t)}function Pn(e,t,i){t.__d=void 0;for(var s=0;s<i.length;s++)Fn(i[s],i[++s],i[++s]);Gr.__c&&Gr.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){Gr.__e(e,t.__v)}}))}function Cn(e,t,i,s,r,n,o,a,l){var c,u,d,h,_,p,g,v=i.props,f=t.props,m=t.type;if("svg"===m&&(r=!0),null!=n)for(c=0;c<n.length;c++)if((_=n[c])&&"setAttribute"in _==!!m&&(m?_.localName===m:3===_.nodeType)){e=_,n[c]=null;break}if(null==e){if(null===m)return document.createTextNode(f);e=r?document.createElementNS("http://www.w3.org/2000/svg",m):document.createElement(m,f.is&&f),n=null,a=!1}if(null===m)v===f||a&&e.data===f||(e.data=f);else{if(n=n&&Vr.call(e.childNodes),v=i.props||nn,!a&&null!=n)for(v={},c=0;c<e.attributes.length;c++)v[(_=e.attributes[c]).name]=_.value;for(c in v)_=v[c],"children"==c||("dangerouslySetInnerHTML"==c?d=_:"key"===c||c in f||kn(e,c,null,_,r));for(c in f)_=f[c],"children"==c?h=_:"dangerouslySetInnerHTML"==c?u=_:"value"==c?p=_:"checked"==c?g=_:"key"===c||a&&"function"!=typeof _||v[c]===_||kn(e,c,_,v[c],r);if(u)a||d&&(u.__html===d.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),mn(e,ln(h)?h:[h],t,i,s,r&&"foreignObject"!==m,n,o,n?n[0]:i.__k&&pn(i,0),a,l),null!=n)for(c=n.length;c--;)null!=n[c]&&un(n[c]);a||(c="value",void 0!==p&&(p!==e[c]||"progress"===m&&!p||"option"===m&&p!==v[c])&&kn(e,c,p,v[c],!1),c="checked",void 0!==g&&g!==e[c]&&kn(e,c,g,v[c],!1))}return e}function Fn(e,t,i){try{"function"==typeof e?e(t):e.current=t}catch(e){Gr.__e(e,i)}}function Rn(e,t,i){var s,r;if(Gr.unmount&&Gr.unmount(e),(s=e.ref)&&(s.current&&s.current!==e.__e||Fn(s,null,t)),null!=(s=e.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(e){Gr.__e(e,t)}s.base=s.__P=null,e.__c=void 0}if(s=e.__k)for(r=0;r<s.length;r++)s[r]&&Rn(s[r],t,i||"function"!=typeof e.type);i||null==e.__e||un(e.__e),e.__=e.__e=e.__d=void 0}function Tn(e,t,i){return this.constructor(e,i)}Vr=on.slice,Gr={__e:function(e,t,i,s){for(var r,n,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((n=r.constructor)&&null!=n.getDerivedStateFromError&&(r.setState(n.getDerivedStateFromError(e)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,s||{}),o=r.__d),o)return r.__E=r}catch(t){e=t}throw e}},Jr=0,_n.prototype.setState=function(e,t){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=cn({},this.state),"function"==typeof e&&(e=e(cn({},i),this.props)),e&&cn(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),vn(this))},_n.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),vn(this))},_n.prototype.render=hn,Yr=[],Xr="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Qr=function(e,t){return e.__v.__b-t.__v.__b},fn.__r=0,Zr=0,function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(en||(en={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(tn||(tn={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(sn||(sn={})),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}(rn||(rn={}));!function(e,t){var i={__c:t="__cC"+Zr++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var i,s;return this.getChildContext||(i=[],(s={})[t]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&i.some((function(e){e.__e=!0,vn(e)}))},this.sub=function(e){i.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i.splice(i.indexOf(e),1),t&&t.call(e)}}),e.children}};i.Provider.__=i.Consumer.contextType=i}({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed:()=>{},isPopup:!0,onPreviewSubmit:()=>{},onPopupSurveySent:()=>{}});var $n=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};class An{constructor(){i(this,"events",{}),this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this.events[e]||[])i(t);for(var s of this.events["*"]||[])s(e,t)}}class On{constructor(e){i(this,"_debugEventEmitter",new An),i(this,"checkStep",((e,t)=>this.checkStepEvent(e,t)&&this.checkStepUrl(e,t)&&this.checkStepElement(e,t))),i(this,"checkStepEvent",((e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event))),this.instance=e,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var e;if(!$(null===(e=this.instance)||void 0===e?void 0:e._addCaptureHook)){var t;null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!$(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null===(t=this.actionRegistry)||void 0===t||t.add(e),null===(i=e.steps)||void 0===i||i.forEach((e=>{var t;null===(t=this.actionEvents)||void 0===t||t.add((null==e?void 0:e.event)||"")}))})),null!==(i=this.instance)&&void 0!==i&&i.autocapture)){var s,r=new Set;e.forEach((e=>{var t;null===(t=e.steps)||void 0===t||t.forEach((e=>{null!=e&&e.selector&&r.add(null==e?void 0:e.selector)}))})),null===(s=this.instance)||void 0===s||s.autocapture.setElementSelectors(r)}}on(e,t){var i;null!=t&&0!=e.length&&(this.actionEvents.has(e)||this.actionEvents.has(null==t?void 0:t.event))&&this.actionRegistry&&(null===(i=this.actionRegistry)||void 0===i?void 0:i.size)>0&&this.actionRegistry.forEach((e=>{this.checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this.checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}checkStepUrl(e,t){if(null!=t&&t.url){var i,s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!On.matchString(s,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static matchString(e,t,i){switch(i){case"regex":return!!n&&$n(e,t);case"exact":return t===e;case"contains":var s=On.escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return $n(e,s);default:return!1}}static escapeStringRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(e,t){if((null!=t&&t.href||null!=t&&t.tag_name||null!=t&&t.text)&&!this.getElementsList(e).some((e=>!(null!=t&&t.href&&!On.matchString(e.href||"",null==t?void 0:t.href,(null==t?void 0:t.href_matching)||"exact"))&&((null==t||!t.tag_name||e.tag_name===(null==t?void 0:t.tag_name))&&!(null!=t&&t.text&&!On.matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!On.matchString(e.$el_text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact"))))))return!1;if(null!=t&&t.selector){var i,s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(!s)return!1;if(!s.includes(null==t?void 0:t.selector))return!1}return!0}getElementsList(e){return null==(null==e?void 0:e.properties.$elements)?[]:null==e?void 0:e.properties.$elements}}class Mn{constructor(e){this.instance=e,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(e){var t;$(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)||(this.setupEventBasedSurveys(e),this.setupActionBasedSurveys(e))}setupActionBasedSurveys(e){var t=e.filter((e=>{var t,i,s,r;return(null===(t=e.conditions)||void 0===t?void 0:t.actions)&&(null===(i=e.conditions)||void 0===i||null===(s=i.actions)||void 0===s||null===(r=s.values)||void 0===r?void 0:r.length)>0}));if(0!==t.length){if(null==this.actionMatcher){this.actionMatcher=new On(this.instance),this.actionMatcher.init();this.actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,s,r,n,o,a,l,c,u;e.conditions&&null!==(t=e.conditions)&&void 0!==t&&t.actions&&null!==(i=e.conditions)&&void 0!==i&&null!==(s=i.actions)&&void 0!==s&&s.values&&(null===(r=e.conditions)||void 0===r||null===(n=r.actions)||void 0===n||null===(o=n.values)||void 0===o?void 0:o.length)>0&&(null===(a=this.actionMatcher)||void 0===a||a.register(e.conditions.actions.values),null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c||null===(u=c.values)||void 0===u||u.forEach((t=>{if(t&&t.name){var i=this.actionToSurveys.get(t.name);i&&i.push(e.id),this.actionToSurveys.set(t.name,i||[e.id])}})))}))}}setupEventBasedSurveys(e){var t;if(0!==e.filter((e=>{var t,i,s,r;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s||null===(r=s.values)||void 0===r?void 0:r.length)>0})).length){null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t,i,s;null===(t=e.conditions)||void 0===t||null===(i=t.events)||void 0===i||null===(s=i.values)||void 0===s||s.forEach((t=>{if(t&&t.name){var i=this.eventToSurveys.get(t.name);i&&i.push(e.id),this.eventToSurveys.set(t.name,i||[e.id])}}))}))}}onEvent(e,t){var i,s,r=(null===(i=this.instance)||void 0===i||null===(s=i.persistence)||void 0===s?void 0:s.props[$e])||[];if(Mn.SURVEY_SHOWN_EVENT_NAME==e&&t&&r.length>0){var n,o=null==t||null===(n=t.properties)||void 0===n?void 0:n.$survey_id;if(o){var a=r.indexOf(o);a>=0&&(r.splice(a,1),this._updateActivatedSurveys(r))}}else this.eventToSurveys.has(e)&&this._updateActivatedSurveys(r.concat(this.eventToSurveys.get(e)||[]))}onAction(e){var t,i,s=(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i?void 0:i.props[$e])||[];this.actionToSurveys.has(e)&&this._updateActivatedSurveys(s.concat(this.actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t,i;null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({[$e]:[...new Set(e)]})}getSurveys(){var e,t,i=null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t?void 0:t.props[$e];return i||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}i(Mn,"SURVEY_SHOWN_EVENT_NAME","survey shown");var Ln=W("[Surveys]"),Dn={icontains:(e,t)=>e.some((e=>t.toLowerCase().includes(e.toLowerCase()))),not_icontains:(e,t)=>e.every((e=>!t.toLowerCase().includes(e.toLowerCase()))),regex:(e,t)=>e.some((e=>$n(t,e))),not_regex:(e,t)=>e.every((e=>!$n(t,e))),exact:(e,t)=>e.some((e=>t===e)),is_not:(e,t)=>e.every((e=>t!==e))};function qn(e){return null!=e?e:"icontains"}class Nn{constructor(e){i(this,"_isFetchingSurveys",!1),i(this,"_isInitializingSurveys",!1),this.instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){this._decideServerResponse=!!e.surveys,Ln.info("decideServerResponse set to ".concat(this._decideServerResponse)),this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var e=(()=>{for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);null!=i&&i.startsWith("seenSurvey_")&&e.push(i)}return e})();e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Ln.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)Ln.info("Disabled. Not loading surveys.");else{var e=null==f?void 0:f.__PosthogExtensions__;if(e)if(this._decideServerResponse){this._isInitializingSurveys=!0;try{var t=e.generateSurveys;if(t)this._surveyManager=t(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new Mn(this.instance),Ln.info("Surveys loaded successfully");else{var i=e.loadExternalDependency;i?i(this.instance,"surveys",(t=>{if(t||!e.generateSurveys)return Ln.error("Could not load surveys script",t),void(this._isInitializingSurveys=!1);this._surveyManager=e.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new Mn(this.instance),Ln.info("Surveys loaded successfully")})):(Ln.error("PostHog loadExternalDependency extension not found. Cannot load remote config."),this._isInitializingSurveys=!1)}}catch(e){throw Ln.error("Error initializing surveys",e),this._isInitializingSurveys=!1,e}}else Ln.warn("Decide not loaded yet. Not loading surveys.");else Ln.error("PostHog Extensions not found.")}}getSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.instance.config.disable_surveys)return Ln.info("Disabled. Not loading surveys."),e([]);var i=this.instance.get_property(Te);if(i&&!t)return e(i);if(this._isFetchingSurveys)return e([]);try{this._isFetchingSurveys=!0,this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",timeout:this.instance.config.surveys_request_timeout_ms,callback:t=>{var i;this._isFetchingSurveys=!1;var s=t.statusCode;if(200!==s||!t.json)return Ln.error("Surveys API could not be loaded, status: ".concat(s)),e([]);var r,n=t.json.surveys||[],o=n.filter((e=>{var t,i,s,r,n,o,a,l,c,u,d,h;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s?void 0:s.values)&&(null===(r=e.conditions)||void 0===r||null===(n=r.events)||void 0===n||null===(o=n.values)||void 0===o?void 0:o.length)>0||(null===(a=e.conditions)||void 0===a?void 0:a.actions)&&(null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c?void 0:c.values)&&(null===(u=e.conditions)||void 0===u||null===(d=u.actions)||void 0===d||null===(h=d.values)||void 0===h?void 0:h.length)>0}));o.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(o));return null===(i=this.instance.persistence)||void 0===i||i.register({[Te]:n}),e(n)}})}catch(e){throw this._isFetchingSurveys=!1,e}}isSurveyFeatureFlagEnabled(e){return!e||this.instance.featureFlags.isFeatureEnabled(e)}getActiveMatchingSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.getSurveys((t=>{var i,s=t.filter((e=>!(!e.start_date||e.end_date))).filter((e=>{var t;if(!e.conditions)return!0;var i=function(e){var t,i,s;if(null===(t=e.conditions)||void 0===t||!t.url)return!0;var r=null==n||null===(i=n.location)||void 0===i?void 0:i.href;if(!r)return!1;var o=[e.conditions.url];return Dn[qn(null===(s=e.conditions)||void 0===s?void 0:s.urlMatchType)](o,r)}(e),s=null===(t=e.conditions)||void 0===t||!t.selector||(null==d?void 0:d.querySelector(e.conditions.selector)),r=function(e){var t,i,s;if(null===(t=e.conditions)||void 0===t||!t.deviceTypes||0===(null===(i=e.conditions)||void 0===i?void 0:i.deviceTypes.length))return!0;if(!v)return!1;var r=zr.deviceType(v);return Dn[qn(null===(s=e.conditions)||void 0===s?void 0:s.deviceTypesMatchType)](e.conditions.deviceTypes,r)}(e);return i&&s&&r})),r=null===(i=this._surveyEventReceiver)||void 0===i?void 0:i.getSurveys(),o=s.filter((e=>{var t,i,s,n,o,a,l,c,u;if(!(e.linked_flag_key||e.targeting_flag_key||e.internal_targeting_flag_key||null!==(t=e.feature_flag_keys)&&void 0!==t&&t.length))return!0;var d=this.isSurveyFeatureFlagEnabled(e.linked_flag_key),h=this.isSurveyFeatureFlagEnabled(e.targeting_flag_key),_=(null!==(i=null===(s=e.conditions)||void 0===s||null===(n=s.events)||void 0===n||null===(o=n.values)||void 0===o?void 0:o.length)&&void 0!==i?i:0)>0,p=(null!==(a=null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c||null===(u=c.values)||void 0===u?void 0:u.length)&&void 0!==a?a:0)>0,g=!_&&!p||(null==r?void 0:r.includes(e.id)),v=this._canActivateRepeatedly(e)||this.isSurveyFeatureFlagEnabled(e.internal_targeting_flag_key),f=this.checkFlags(e);return d&&h&&v&&g&&f}));return e(o)}),t)}checkFlags(e){var t;return null===(t=e.feature_flag_keys)||void 0===t||!t.length||e.feature_flag_keys.every((e=>{var{key:t,value:i}=e;return!t||!i||this.instance.featureFlags.isFeatureEnabled(i)}))}_canActivateRepeatedly(e){var t;return L(null===(t=f.__PosthogExtensions__)||void 0===t?void 0:t.canActivateRepeatedly)?(Ln.warn("init was not called"),!1):f.__PosthogExtensions__.canActivateRepeatedly(e)}canRenderSurvey(e){L(this._surveyManager)?Ln.warn("init was not called"):this.getSurveys((t=>{var i=t.filter((t=>t.id===e))[0];this._surveyManager.canRenderSurvey(i)}))}renderSurvey(e,t){L(this._surveyManager)?Ln.warn("init was not called"):this.getSurveys((i=>{var s=i.filter((t=>t.id===e))[0];this._surveyManager.renderSurvey(s,null==d?void 0:d.querySelector(t))}))}}var Bn=W("[RateLimiter]");class Hn{constructor(e){var t,s;i(this,"serverLimits",{}),i(this,"lastEventRateLimited",!1),i(this,"checkForLimiting",(e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Bn.info("".concat(e||"events"," is quota limited.")),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Bn.warn('could not rate limit - continuing. Error: "'.concat(null==e?void 0:e.message,'"'),{text:t})}})),this.instance=e,this.captureEventsPerSecond=(null===(t=e.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null===(s=e.config.rate_limiting)||void 0===s?void 0:s.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var e,t,i,s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=(new Date).getTime(),n=null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_property(Le))&&void 0!==e?e:{tokens:this.captureEventsBurstLimit,last:r};n.tokens+=(r-n.last)/1e3*this.captureEventsPerSecond,n.last=r,n.tokens>this.captureEventsBurstLimit&&(n.tokens=this.captureEventsBurstLimit);var o=n.tokens<1;return o||s||(n.tokens=Math.max(0,n.tokens-1)),!o||this.lastEventRateLimited||s||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,null===(i=this.instance.persistence)||void 0===i||i.set_property(Le,n),{isRateLimited:o,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Un=W("[RemoteConfig]");class zn{constructor(e){this.instance=e}get remoteConfig(){var e,t;return null===(e=f._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(t=e[this.instance.config.token])||void 0===t?void 0:t.config}_loadRemoteConfigJs(e){var t,i,s;null!==(t=f.__PosthogExtensions__)&&void 0!==t&&t.loadExternalDependency?null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"remote-config",(()=>e(this.remoteConfig))):(Un.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(e){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Un.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void Un.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Un.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this.onRemoteConfig(e)}));this.onRemoteConfig(e)}))}catch(e){Un.error("Error loading remote config",e)}}onRemoteConfig(e){e?this.instance.config.__preview_remote_config?(this.instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this.instance.featureFlags.ensureFlagsLoaded()):Un.info("__preview_remote_config is disabled. Logging config instead",e):Un.error("Failed to fetch remote config from PostHog.")}}var jn=function(e){var t,i,s,r,n="";for(t=i=0,s=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,r=0;r<s;r++){var o=e.charCodeAt(r),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),M(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=r+1)}return i>t&&(n+=e.substring(t,e.length)),n},Wn=!!p||!!_,Vn="text/plain",Gn=(e,i)=>{var[s,r]=e.split("?"),n=t({},i);null==r||r.split("&").forEach((e=>{var[t]=e.split("=");delete n[t]}));var o=wt(n);return o=o?(r?r+"&":"")+o:r,"".concat(s,"?").concat(o)},Jn=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Yn=e=>{var{data:t,compression:i}=e;if(t){if(i===r.GZipJS){var s=ss(rs(Jn(t)),{mtime:0}),n=new Blob([s],{type:Vn});return{contentType:Vn,body:n,estimatedSize:n.size}}if(i===r.Base64){var o=function(e){var t,i,s,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=jn(e);do{t=(n=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=n>>12&63,s=n>>6&63,r=63&n,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(s)+o.charAt(r)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(Jn(t)),a=(e=>"data="+encodeURIComponent("string"==typeof e?e:Jn(e)))(o);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var l=Jn(t);return{contentType:"application/json",body:l,estimatedSize:new Blob([l]).size}}},Kn=[];_&&Kn.push({transport:"fetch",method:e=>{var i,s,{contentType:r,body:n,estimatedSize:o}=null!==(i=Yn(e))&&void 0!==i?i:{},a=new Headers;J(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,c=null;if(g){var u=new g;c={signal:u.signal,timeout:setTimeout((()=>u.abort()),e.timeout)}}_(l,t({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&(o||0)<52428.8,body:n,signal:null===(s=c)||void 0===s?void 0:s.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var s,r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){j.error(e)}null===(s=e.callback)||void 0===s||s.call(e,r)})))).catch((t=>{var i;j.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,text:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}),p&&Kn.push({transport:"XHR",method:e=>{var t,i=new p;i.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=null!==(t=Yn(e))&&void 0!==t?t:{};J(e.headers,(function(e,t){i.setRequestHeader(t,e)})),s&&i.setRequestHeader("Content-Type",s),e.timeout&&(i.timeout=e.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(4===i.readyState){var t,s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,s)}},i.send(r)}}),null!=u&&u.sendBeacon&&Kn.push({transport:"sendBeacon",method:e=>{var t=Gn(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=Yn(e))&&void 0!==i?i:{},n="string"==typeof r?new Blob([r],{type:s}):r;u.sendBeacon(t,n)}catch(e){}}});var Xn=3e3;class Qn{constructor(e,t){i(this,"isPaused",!0),i(this,"queue",[]),this.flushTimeoutMs=bi((null==t?void 0:t.flush_interval_ms)||Xn,250,5e3,"flush interval",Xn),this.sendRequest=e}enqueue(e){this.queue.push(e),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var e=this.queue.length>0?this.formatQueue():{},i=Object.values(e),s=[...i.filter((e=>0===e.url.indexOf("/e"))),...i.filter((e=>0!==e.url.indexOf("/e")))];s.map((e=>{this.sendRequest(t(t({},e),{},{transport:"sendBeacon"}))}))}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var e=this;this.isPaused||(this.flushTimeout=setTimeout((()=>{if(this.clearFlushTimeout(),this.queue.length>0){var t=this.formatQueue(),i=function(i){var s=t[i],r=(new Date).getTime();s.data&&C(s.data)&&J(s.data,(e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp})),e.sendRequest(s)};for(var s in t)i(s)}}),this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){var e={};return J(this.queue,(i=>{var s,r=i,n=(r?r.batchKey:null)||r.url;$(e[n])&&(e[n]=t(t({},r),{},{data:[]})),null===(s=e[n].data)||void 0===s||s.push(r.data)})),this.queue=[],e}}var Zn=["retriesPerformedSoFar"];class eo{constructor(e){i(this,"isPolling",!1),i(this,"pollIntervalMs",3e3),i(this,"queue",[]),this.instance=e,this.queue=[],this.areWeOnline=!0,!$(n)&&"onLine"in n.navigator&&(this.areWeOnline=n.navigator.onLine,ne(n,"online",(()=>{this.areWeOnline=!0,this.flush()})),ne(n,"offline",(()=>{this.areWeOnline=!1})))}retriableRequest(e){var{retriesPerformedSoFar:i}=e,r=s(e,Zn);D(i)&&i>0&&(r.url=Gn(r.url,{retry_count:i})),this.instance._send_request(t(t({},r),{},{callback:e=>{var s;200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=i?i:0)<10?this.enqueue(t({retriesPerformedSoFar:i},r)):null===(s=r.callback)||void 0===s||s.call(r,e)}}))}enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(t),s=Date.now()+i;this.queue.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in ".concat(i);navigator.onLine||(r+=" (Browser is offline)"),j.warn(r),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout((()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()}),this.pollIntervalMs)}flush(){var e=Date.now(),t=[],i=this.queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this.queue=t,i.length>0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(t(t({},e),{},{transport:"sendBeacon"}))}catch(e){j.error(e)}this.queue=[]}}class to{constructor(e){i(this,"_updateScrollData",(()=>{var e,t,i,s;this.context||(this.context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this.context.lastScrollY=Math.ceil(n),this.context.maxScrollY=Math.max(n,null!==(e=this.context.maxScrollY)&&void 0!==e?e:0),this.context.maxScrollHeight=Math.max(o,null!==(t=this.context.maxScrollHeight)&&void 0!==t?t:0),this.context.lastContentY=a,this.context.maxContentY=Math.max(a,null!==(i=this.context.maxContentY)&&void 0!==i?i:0),this.context.maxContentHeight=Math.max(l,null!==(s=this.context.maxContentHeight)&&void 0!==s?s:0)})),this.instance=e}getContext(){return this.context}resetContext(){var e=this.context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){ne(n,"scroll",this._updateScrollData,{capture:!0}),ne(n,"scrollend",this._updateScrollData,{capture:!0}),ne(n,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return null==n?void 0:n.document.documentElement;var e=C(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(var t of e){var i=null==n?void 0:n.document.querySelector(t);if(i)return i}}scrollY(){if(this.instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return n&&(n.scrollY||n.pageYOffset||n.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return n&&(n.scrollX||n.pageXOffset||n.document.documentElement.scrollLeft)||0}}var io=e=>zr.personInfo({maskPersonalDataProperties:null==e?void 0:e.config.mask_personal_data_properties,customPersonalDataProperties:null==e?void 0:e.config.custom_personal_data_properties});class so{constructor(e,t,s,r){i(this,"_onSessionIdCallback",(e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[Me]:i})}})),this.instance=e,this._sessionIdManager=t,this._persistence=s,this._sessionSourceParamGenerator=r||io,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Me]}getSetOnceProps(){var e,t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?zr.personPropsFromInfo(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return J(ee(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_".concat(k(i))]=t})),e}}var ro=W("[SessionId]");class no{constructor(e,t,s){var r;if(i(this,"_sessionIdChangedHandlers",[]),!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.config=e.config,this.persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Dt,this._windowIdGenerator=s||Dt;var n=this.config.persistence_name||this.config.token,o=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*bi(o,60,36e3,"session_idle_timeout_seconds",1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.resetIdleTimer(),this._window_id_storage_key="ph_"+n+"_window_id",this._primary_window_exists_storage_key="ph_"+n+"_primary_window_exists",this._canUseSessionStorage()){var a=Qt.parse(this._window_id_storage_key),l=Qt.parse(this._primary_window_exists_storage_key);a&&!l?this._windowId=a:Qt.remove(this._window_id_storage_key),Qt.set(this._primary_window_exists_storage_key,!0)}if(null!==(r=this.config.bootstrap)&&void 0!==r&&r.sessionID)try{var c=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,(new Date).getTime(),c)}catch(e){ro.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return $(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this.config.persistence&&!this.persistence.disabled&&Qt.is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Qt.set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Qt.parse(this._window_id_storage_key):null}_setSessionId(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this.persistence.register({[ke]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this.persistence.props[ke];return C(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){ne(n,"beforeunload",(()=>{this._canUseSessionStorage()&&Qt.remove(this._primary_window_exists_storage_key)}),{capture:!1})}checkAndGetSessionAndWindowId(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.config.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var i=t||(new Date).getTime(),[s,r,n]=this._getSessionId(),o=this._getWindowId(),a=D(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,c=!r,u=!e&&Math.abs(i-s)>this.sessionTimeoutMs;c||u||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),ro.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===s||!e||a?i:s,h=0===n?(new Date).getTime():n;return this._setWindowId(o),this._setSessionId(r,d,h),e||this.resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:h,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:s}}resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{this.resetSessionId()}),1.1*this.sessionTimeoutMs)}}var oo=["$set_once","$set"],ao=W("[SiteApps]");class lo{constructor(e){this.instance=e,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this.bufferedInvocations.push(i),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}get siteAppLoaders(){var e,t;return null===(e=f._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(t=e[this.instance.config.token])||void 0===t?void 0:t.siteApps}init(){if(this.isEnabled){var e=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{e(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(e){var i,r,n,o,a,l,c;if(!e)throw new Error("Event payload is required");var u={},d=this.instance.get_property("$groups")||[],h=this.instance.get_property("$stored_group_properties")||{};for(var[_,p]of Object.entries(h))u[_]={id:d[_],type:_,properties:p};var{$set_once:g,$set:v}=e;return{event:t(t({},s(e,oo)),{},{properties:t(t(t({},e.properties),v?{$set:t(t({},null!==(i=null===(r=e.properties)||void 0===r?void 0:r.$set)&&void 0!==i?i:{}),v)}:{}),g?{$set_once:t(t({},null!==(n=null===(o=e.properties)||void 0===o?void 0:o.$set_once)&&void 0!==n?n:{}),g)}:{}),elements_chain:null!==(a=null===(l=e.properties)||void 0===l?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null===(c=e.properties)||void 0===c?void 0:c.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this.bufferedInvocations.length&&(ao.info("Processing ".concat(this.bufferedInvocations.length," events for site app with id ").concat(e.id)),this.bufferedInvocations.forEach((e=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored)))&&(null===(i=this.stopBuffering)||void 0===i||i.call(this))},s=!1,r=r=>{t.errored=!r,t.loaded=!0,ao.info("Site app with id ".concat(e.id," ").concat(r?"loaded":"errored")),s&&i()};try{var{processEvent:n}=e.init({posthog:this.instance,callback:e=>{r(e)}});n&&(t.processEvent=n),s=!0}catch(t){ao.error("Error while initializing PostHog app with config id ".concat(e.id),t),r(!1)}if(s&&t.loaded)try{i()}catch(i){ao.error("Error while processing buffered events PostHog app with config id ".concat(e.id),i),t.errored=!0}}setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{var s;null===(s=i.processEvent)||void 0===s||s.call(i,t)}catch(t){ao.error("Error while processing event ".concat(e.event," for site app ").concat(i.id),t)}}}onRemoteConfig(e){var t,i,s,r=this;if(null!==(t=this.siteAppLoaders)&&void 0!==t&&t.length)return this.isEnabled?(this.setupSiteApps(),void this.instance.on("eventCaptured",(e=>this.onCapturedEvent(e)))):void ao.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this.stopBuffering)||void 0===i||i.call(this),null!==(s=e.siteApps)&&void 0!==s&&s.length)if(this.isEnabled){var n=function(e,t){var i,s;f["__$$ph_site_app_".concat(e)]=r.instance,null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadSiteApp)||void 0===s||s.call(i,r.instance,t,(t=>{if(t)return ao.error("Error while initializing PostHog app with config id ".concat(e),t)}))};for(var{id:o,url:a}of e.siteApps)n(o,a)}else ao.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var co,uo=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","bytespider"],ho=function(e,t){if(!e)return!1;var i=e.toLowerCase();return uo.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},_o=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&ho(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>ho(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function po(e,t,i){return Jn({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}!function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"}(co||(co={}));var go="i.posthog.com";class vo{constructor(e){i(this,"_regionCache",{}),this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(".".concat(go),".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=co.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=co.EU:this._regionCache[this.apiHost]=co.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t&&(t="/"===t[0]?t:"/".concat(t)),"ui"===e)return this.uiHost+t;if(this.region===co.CUSTOM)return this.apiHost+t;var i=go+t;switch(e){case"assets":return"https://".concat(this.region,"-assets.").concat(i);case"api":return"https://".concat(this.region,".").concat(i)}}}var fo={icontains:(e,t)=>!!n&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!n&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!n&&$n(t.href,e),not_regex:(e,t)=>!!n&&!$n(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class mo{constructor(e){var t=this;i(this,"getWebExperimentsAndEvaluateDisplayLogic",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t.getWebExperiments((e=>{mo.logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)mo.logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null===(i=t._flagToExperiments)||void 0===i||i.set(e.feature_flag_key,e);var s=t.instance.getFeatureFlag(e.feature_flag_key);A(s)&&e.variants[s]&&t.applyTransforms(e.name,s,e.variants[s].transforms)}else if(e.variants)for(var r in e.variants){var n=e.variants[r];mo.matchesTestVariant(n)&&t.applyTransforms(e.name,r,n.transforms)}}))}),e)})),this.instance=e,this.instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())mo.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(L(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();mo.logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!==(t=this._flagToExperiments)&&void 0!==t&&t.has(e)){var i,s=this.instance.getFeatureFlag(e),r=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);s&&null!=r&&r.variants[s]&&this.applyTransforms(r.name,s,r.variants[s].transforms)}}))}}previewWebExperiment(){var e=mo.getWindowLocation();if(null!=e&&e.search){var t=St(null==e?void 0:e.search,"__experiment_id"),i=St(null==e?void 0:e.search,"__experiment_variant");t&&i&&(mo.logInfo("previewing web experiments ".concat(t," && ").concat(i)),this.getWebExperiments((e=>{this.showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this.instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.instance.config.disable_web_experiments&&!i)return e([]);var s=this.instance.get_property("$web_experiments");if(s&&!t)return e(s);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/web_experiments/?token=".concat(this.instance.config.token)),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}showPreviewWebExperiment(e,t,i){var s=i.filter((t=>t.id===e));s&&s.length>0&&(mo.logInfo("Previewing web experiment [".concat(s[0].name,"] with variant [").concat(t,"]")),this.applyTransforms(s[0].name,t,s[0].variants[t].transforms))}static matchesTestVariant(e){return!L(e.conditions)&&(mo.matchUrlConditions(e)&&mo.matchUTMConditions(e))}static matchUrlConditions(e){var t;if(L(e.conditions)||L(null===(t=e.conditions)||void 0===t?void 0:t.url))return!0;var i,s,r,n=mo.getWindowLocation();return!!n&&(null===(i=e.conditions)||void 0===i||!i.url||fo[null!==(s=null===(r=e.conditions)||void 0===r?void 0:r.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==n?void 0:n.location}static matchUTMConditions(e){var t;if(L(e.conditions)||L(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;var i=zr.campaignParams();if(i.utm_source){var s,r,n,o,a,l,c,u,d,h,_,p,g,v,f,m,b=null===(s=e.conditions)||void 0===s||null===(r=s.utm)||void 0===r||!r.utm_campaign||(null===(n=e.conditions)||void 0===n||null===(o=n.utm)||void 0===o?void 0:o.utm_campaign)==i.utm_campaign,y=null===(a=e.conditions)||void 0===a||null===(l=a.utm)||void 0===l||!l.utm_source||(null===(c=e.conditions)||void 0===c||null===(u=c.utm)||void 0===u?void 0:u.utm_source)==i.utm_source,w=null===(d=e.conditions)||void 0===d||null===(h=d.utm)||void 0===h||!h.utm_medium||(null===(_=e.conditions)||void 0===_||null===(p=_.utm)||void 0===p?void 0:p.utm_medium)==i.utm_medium,S=null===(g=e.conditions)||void 0===g||null===(v=g.utm)||void 0===v||!v.utm_term||(null===(f=e.conditions)||void 0===f||null===(m=f.utm)||void 0===m?void 0:m.utm_term)==i.utm_term;return b&&w&&S&&y}return!1}static logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];j.info("[WebExperiments] ".concat(e),i)}applyTransforms(e,t,i){this._is_bot()?mo.logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var s;mo.logInfo("applying transform of variant ".concat(t," for experiment ").concat(e," "),i);var r=null===(s=document)||void 0===s?void 0:s.querySelectorAll(i.selector);null==r||r.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):mo.logInfo("Control variants leave the page unmodified.")}_is_bot(){return u&&this.instance?_o(u,this.instance.config.custom_blocked_useragents):void 0}}var bo={},yo=()=>{},wo="posthog",So=!Wn&&-1===(null==v?void 0:v.indexOf("MSIE"))&&-1===(null==v?void 0:v.indexOf("Mozilla")),ko=()=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:se(null==d?void 0:d.location),persistence:"localStorage+cookie",persistence_name:"",loaded:yo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:h&&A(null==h?void 0:h.search)&&-1!==h.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==n||null===(e=n.location)||void 0===e?void 0:e.protocol),ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;j.error(t)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Xn},_onCapture:yo}},Eo=e=>{var t={};$(e.process_person)||(t.person_profiles=e.process_person),$(e.xhr_headers)||(t.request_headers=e.xhr_headers),$(e.cookie_name)||(t.persistence_name=e.cookie_name),$(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),$(e.store_google)||(t.save_campaign_params=e.store_google),$(e.verbose)||(t.debug=e.verbose);var i=Y({},t,e);return C(e.property_blacklist)&&($(e.property_denylist)?i.property_denylist=e.property_blacklist:C(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:j.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class xo{constructor(){i(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){j.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Io{get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){i(this,"webPerformance",new xo),i(this,"_personProcessingSetOncePropertiesSent",!1),i(this,"version",U.LIB_VERSION),i(this,"_internalEventEmitter",new An),this.config=ko(),this.SentryIntegration=bs,this.sentryIntegration=e=>function(e,t){var i=ms(e,t);return{name:fs,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this._cachedIdentify=null,this.featureFlags=new zs(this),this.toolbar=new Es(this),this.scrollManager=new to(this),this.pageViewManager=new As(this),this.surveys=new Nn(this),this.experiments=new mo(this),this.exceptions=new Os(this),this.rateLimiter=new Hn(this),this.requestRouter=new vo(this),this.consent=new Zt(this),this.people={set:(e,t,i)=>{var s=A(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=A(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>j.info('send "'.concat(null==e?void 0:e.event,'"'),e)))}init(e,t,i){if(i&&i!==wo){var s,r=null!==(s=bo[i])&&void 0!==s?s:new Io;return r._init(e,t,i),bo[i]=r,bo[wo][i]=r,r}return this._init(e,t,i)}_init(e){var i,s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if($(e)||O(e))return j.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return j.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],o.person_profiles&&(this._initialPersonProfilesConfig=o.person_profiles),this.set_config(Y({},ko(),Eo(o),{name:a,token:e})),this.config.on_xhr_error&&j.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=o.disable_compression?void 0:r.GZipJS,this.persistence=new Wr(this.config),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Wr(t(t({},this.config),{},{persistence:"sessionStorage"}));var l=t({},this.persistence.props),c=t({},this.sessionPersistence.props);if(this._requestQueue=new Qn((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new eo(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new no(this),this.sessionPropsManager=new so(this,this.sessionManager,this.persistence)),new Is(this).startIfEnabledOrStop(),this.siteApps=new lo(this),null===(i=this.siteApps)||void 0===i||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new ps(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Rt(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new $s(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Fs(this),this.exceptionObserver=new ni(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new si(this,ii),this.deadClicksAutocapture.startIfEnabled(),U.DEBUG=U.DEBUG||this.config.debug,U.DEBUG&&j.info("Starting in debug mode",{this:this,config:o,thisC:t({},this.config),p:l,s:c}),this._sync_opt_out_with_persistence(),void 0!==(null===(s=o.bootstrap)||void 0===s?void 0:s.distinctID)){var u,d,h=this.config.get_device_id(Dt()),_=null!==(u=o.bootstrap)&&void 0!==u&&u.isIdentifiedID?h:o.bootstrap.distinctID;this.persistence.set_property(Oe,null!==(d=o.bootstrap)&&void 0!==d&&d.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:o.bootstrap.distinctID,$device_id:_})}if(this._hasBootstrappedFeatureFlags()){var p,g,v=Object.keys((null===(p=o.bootstrap)||void 0===p?void 0:p.featureFlags)||{}).filter((e=>{var t,i;return!(null===(t=o.bootstrap)||void 0===t||null===(i=t.featureFlags)||void 0===i||!i[e])})).reduce(((e,t)=>{var i,s;return e[t]=(null===(i=o.bootstrap)||void 0===i||null===(s=i.featureFlags)||void 0===s?void 0:s[t])||!1,e}),{}),f=Object.keys((null===(g=o.bootstrap)||void 0===g?void 0:g.featureFlagPayloads)||{}).filter((e=>v[e])).reduce(((e,t)=>{var i,s,r,n;null!==(i=o.bootstrap)&&void 0!==i&&null!==(s=i.featureFlagPayloads)&&void 0!==s&&s[t]&&(e[t]=null===(r=o.bootstrap)||void 0===r||null===(n=r.featureFlagPayloads)||void 0===n?void 0:n[t]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:f})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Ue,$device_id:null},"");else if(!this.get_distinct_id()){var m=this.config.get_device_id(Dt());this.register_once({distinct_id:m,$device_id:m},""),this.persistence.set_property(Oe,"anonymous")}return ne(n,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),o.segment?vs(this,(()=>this._loaded())):this._loaded(),F(this.config._onCapture)&&this.config._onCapture!==yo&&(j.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this}_onRemoteConfig(e){var t,i,s,n,o,a,l,c;if(!d||!d.body)return j.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=w(e.supportedCompression,r.GZipJS)?r.GZipJS:w(e.supportedCompression,r.Base64)?r.Base64:void 0),null!==(t=e.analytics)&&void 0!==t&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null===(i=this.siteApps)||void 0===i||i.onRemoteConfig(e),null===(s=this.sessionRecording)||void 0===s||s.onRemoteConfig(e),null===(n=this.autocapture)||void 0===n||n.onRemoteConfig(e),null===(o=this.heatmaps)||void 0===o||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),null===(a=this.webVitalsAutocapture)||void 0===a||a.onRemoteConfig(e),null===(l=this.exceptionObserver)||void 0===l||l.onRemoteConfig(e),null===(c=this.deadClicksAutocapture)||void 0===c||c.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){j.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{this.consent.isOptedIn()&&this._captureInitialPageview()}),1),new zn(this).load(),this.featureFlags.decide()}_start_queue_if_opted_in(){var e;this.has_opted_out_capturing()||this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.has_opted_out_capturing()||G(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),null===(e=this._requestQueue)||void 0===e||e.unload(),null===(t=this._retryQueue)||void 0===t||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(So?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Gn(e.url,{ip:this.config.ip?1:0}),e.headers=t({},this.config.request_headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var i,s,r,n=t({},e);n.timeout=n.timeout||6e4,n.url=Gn(n.url,{_:(new Date).getTime().toString(),ver:U.LIB_VERSION,compression:n.compression});var o=null!==(i=n.transport)&&void 0!==i?i:"fetch",a=null!==(s=null===(r=re(Kn,(e=>e.transport===o)))||void 0===r?void 0:r.method)&&void 0!==s?s:Kn[0].method;if(!a)throw new Error("No available transport method");a(n)})(t(t({},e),{},{callback:t=>{var i,s,r;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null===(s=(r=this.config).on_request_error)||void 0===s||s.call(r,t));null===(i=e.callback)||void 0===i||i.call(e,t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],r=[];G(e,(e=>{e&&(t=e[0],C(t)?r.push(e):F(e)?e.call(this):C(e)&&"alias"===t?i.push(e):C(e)&&-1!==t.indexOf("capture")&&F(this[t])?r.push(e):s.push(e))}));var n=function(e,t){G(e,(function(e){if(C(e[0])){var i=t;J(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};n(i,this),n(s,this),n(r,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null===(e=this.config.bootstrap)||void 0===e?void 0:e.featureFlags)&&Object.keys(null===(t=this.config.bootstrap)||void 0===t?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,i,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!$(e)&&A(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var n=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,a=(null==s?void 0:s.timestamp)||o,l=Dt(),c={uuid:l,event:e,properties:this._calculate_event_properties(e,i||{},a,l)};n&&(c.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==s?void 0:s.$set)&&(c.$set=null==s?void 0:s.$set);var u=this._calculate_set_once_properties(null==s?void 0:s.$set_once);u&&(c.$set_once=u),(c=te(c,null!=s&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,$(null==s?void 0:s.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=o);var d=t(t({},c.properties.$set),c.$set);if(T(d)||this.setPersonPropertiesForFlags(d),!L(this.config.before_send)){var h=this._runBeforeSend(c);if(!h)return;c=h}this._internalEventEmitter.emit("eventCaptured",c);var _={method:"POST",url:null!==(r=null==s?void 0:s._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:null==s?void 0:s._batchKey};return!this.config.request_batching||s&&(null==s||!s._batchKey)||null!=s&&s.send_instantly?this._send_retriable_request(_):this._requestQueue.enqueue(_),c}j.critical("This capture call is ignored due to client rate limiting.")}}else j.error("No event name provided to posthog.capture")}else j.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}_calculate_event_properties(e,i,s,r){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;var n=this.persistence.remove_event_timer(e),o=t({},i);if(o.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(o.$cookieless_mode=!0),"$snapshot"===e){var a=t(t({},this.persistence.properties()),this.sessionPersistence.properties());return o.distinct_id=a.distinct_id,(!A(o.distinct_id)&&!D(o.distinct_id)||O(o.distinct_id))&&j.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}var l,c=zr.properties({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});if(this.sessionManager){var{sessionId:u,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId();o.$session_id=u,o.$window_id=h}this.sessionPropsManager&&Y(o,this.sessionPropsManager.getSessionProps());try{var _,p;this.sessionRecording&&(o.$recording_status=this.sessionRecording.status,o.$sdk_debug_replay_internal_buffer_length=this.sessionRecording.buffer.data.length,o.$sdk_debug_replay_internal_buffer_size=this.sessionRecording.buffer.size),o.$sdk_debug_retry_queue_size=null===(_=this._retryQueue)||void 0===_||null===(p=_.queue)||void 0===p?void 0:p.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===co.CUSTOM&&(o.$lib_custom_api_host=this.config.api_host),l="$pageview"===e?this.pageViewManager.doPageView(s,r):"$pageleave"===e?this.pageViewManager.doPageLeave(s):this.pageViewManager.doEvent(),o=Y(o,l),"$pageview"===e&&d&&(o.title=d.title),!$(n)){var g=s.getTime()-n;o.$duration=parseFloat((g/1e3).toFixed(3))}v&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser"),(o=Y({},c,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?J(this.config.property_denylist,(function(e){delete o[e]})):j.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(j.error("sanitize_properties is deprecated. Use before_send instead"),o=f(o,e));var m=this._hasPersonProcessing();return o.$process_person_profile=m,m&&this._requirePersonProcessing("_calculate_event_properties"),o}_calculate_set_once_properties(e){var t;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent)return e;var i=this.persistence.get_initial_props(),s=null===(t=this.sessionPropsManager)||void 0===t?void 0:t.getSetOnceProps(),r=Y({},i,s||{},e||{}),n=this.config.sanitize_properties;return n&&(j.error("sanitize_properties is deprecated. Use before_send instead"),r=n(r,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,T(r)?void 0:r}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.register(e)}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}getEarlyAccessFeatures(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0;return this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}canRenderSurvey(e){this.surveys.canRenderSurvey(e)}identify(e,i,s){if(!this.__loaded||!this.persistence)return j.uninitializedWarning("posthog.identify");if(D(e)&&(e=e.toString(),j.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e){if(["distinct_id","distinctid"].includes(e.toLowerCase()))j.critical('The string "'.concat(e,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(ae)&&(this.unregister(ae),this.register({distinct_id:e}));var o="anonymous"===(this.persistence.get_property(Oe)||"anonymous");e!==r&&o?(this.persistence.set_property(Oe,"identified"),this.setPersonPropertiesForFlags(t(t({},s||{}),i||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:i||{},$set_once:s||{}}),this.featureFlags.setAnonymousDistinctId(r),this._cachedIdentify=po(e,i,s)):(i||s)&&(this._cachedIdentify!==po(e,i,s)?(this.setPersonProperties(i,s),this._cachedIdentify=po(e,i,s)):j.info("A duplicate posthog.identify call was made with the same properties. It has been ignored.")),e!==r&&(this.reloadFeatureFlags(),this.unregister(Ae))}}else j.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,i){(e||i)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(t(t({},i||{}),e||{})),this.capture("$set",{$set:e||{},$set_once:i||{}}))}group(e,i,s){if(e&&i){if(this._requirePersonProcessing("posthog.group")){var r=this.getGroups();r[e]!==i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:t(t({},r),{},{[e]:i})}),s&&(this.capture("$groupidentify",{$group_type:e,$group_key:i,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===i||s||this.reloadFeatureFlags()}}else j.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r;if(j.info("reset"),!this.__loaded)return j.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null===(t=this.persistence)||void 0===t||t.clear(),null===(i=this.sessionPersistence)||void 0===i||i.clear(),this.surveys.reset(),null===(s=this.persistence)||void 0===s||s.set_property(Oe,"anonymous"),null===(r=this.sessionManager)||void 0===r||r.resetSessionId(),this._cachedIdentify=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Ue,$device_id:null},"");else{var o=this.config.get_device_id(Dt());this.register_once({distinct_id:o,$device_id:e?o:n},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null===(t=this.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(t));if(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;var o=Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0);s+="?t=".concat(o)}return s}alias(e,t){return e===this.get_property(oe)?(j.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?($(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(ae,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(j.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var i,s,r,n,o=t({},this.config);R(e)&&(Y(this.config,Eo(e)),null===(i=this.persistence)||void 0===i||i.update_config(this.config,o),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Wr(t(t({},this.config),{},{persistence:"sessionStorage"})),Vt.is_supported()&&"true"===Vt.get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(U.DEBUG=!0,j.info("set_config",{config:e,oldConfig:o,newConfig:t({},this.config)})),null===(s=this.sessionRecording)||void 0===s||s.startIfEnabledOrStop(),null===(r=this.autocapture)||void 0===r||r.startIfEnabled(),null===(n=this.heatmaps)||void 0===n||n.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var s,r,n,o,a;if(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),i.sampling)null===(r=this.sessionRecording)||void 0===r||r.overrideSampling();if(i.linked_flag)null===(n=this.sessionRecording)||void 0===n||n.overrideLinkedFlag();if(i.url_trigger)null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url");if(i.event_trigger)null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null===(e=this.sessionRecording)||void 0===e||!e.started)}captureException(e,i){var s,r=new Error("PostHog syntheticException"),n=F(null===(s=f.__PosthogExtensions__)||void 0===s?void 0:s.parseErrorAsProperties)?t(t({},f.__PosthogExtensions__.parseErrorAsProperties(B(e)?{error:e,event:e.message}:{event:e},{syntheticException:r})),i):t({$exception_level:"error",$exception_list:[{type:B(e)?e.name:"Error",value:B(e)?e.message:R(e)&&"message"in e?String(e.message):String(e),mechanism:{handled:!0,synthetic:!1}}]},i);this.exceptions.sendExceptionEvent(n)}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:wo;return t!==wo&&(t=wo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property(Oe))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property(Oe))}_hasPersonProcessing(){var e,t,i,s;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&T(this.getGroups())&&(null===(e=this.persistence)||void 0===e||null===(t=e.props)||void 0===t||!t[ae])&&(null===(i=this.persistence)||void 0===i||null===(s=i.props)||void 0===s||!s[Be]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(j.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Be,!0),!0)}_sync_opt_out_with_persistence(){var e,t,i,s,r=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default,o=this.config.disable_persistence||r&&!!n;(null===(e=this.persistence)||void 0===e?void 0:e.disabled)!==o&&(null===(i=this.persistence)||void 0===i||i.set_disabled(o));(null===(t=this.sessionPersistence)||void 0===t?void 0:t.disabled)!==o&&(null===(s=this.sessionPersistence)||void 0===s||s.set_disabled(o))}opt_in_capturing(e){var t;(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),$(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(t=null==e?void 0:e.captureEventName)&&void 0!==t?t:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return u?_o(u,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){d&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:d.title},{send_instantly:!0}))}debug(e){!1===e?(null==n||n.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==n||n.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}_runBeforeSend(e){if(L(this.config.before_send))return e;var t=C(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),L(i)){var r="Event '".concat(e.event,"' was rejected in beforeSend function");return H(e.event)?j.warn("".concat(r,". This can cause unexpected behavior.")):j.info(r),null}i.properties&&!T(i.properties)||j.warn("Event '".concat(e.event,"' has no properties after beforeSend function, this is likely an error."))}return i}getPageViewId(){var e;return null===(e=this.pageViewManager._currentPageview)||void 0===e?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Z(e.prototype[t[i]])}(Io,["identify"]);var Po,Co=(Po=bo[wo]=new Io,function(){function e(){e.done||(e.done=!0,So=!1,J(bo,(function(e){e._dom_loaded()})))}null!=d&&d.addEventListener?"complete"===d.readyState?e():ne(d,"DOMContentLoaded",e,{capture:!1}):n&&j.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Po);export{m as COPY_AUTOCAPTURE_EVENT,r as Compression,Io as PostHog,sn as SurveyQuestionBranchingType,tn as SurveyQuestionType,rn as SurveySchedule,en as SurveyType,Co as default,b as knownUnsafeEditableEvent,Co as posthog,y as severityLevels};
1
+ function e(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);t&&(s=s.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,s)}return i}function t(t){for(var s=1;s<arguments.length;s++){var r=null!=arguments[s]?arguments[s]:{};s%2?e(Object(r),!0).forEach((function(e){i(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function i(e,t,i){return t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function s(e,t){if(null==e)return{};var i,s,r=function(e,t){if(null==e)return{};var i,s,r={},n=Object.keys(e);for(s=0;s<n.length;s++)i=n[s],t.indexOf(i)>=0||(r[i]=e[i]);return r}(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(s=0;s<n.length;s++)i=n[s],t.indexOf(i)>=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(r[i]=e[i])}return r}var r,n="undefined"!=typeof window?window:void 0,o="undefined"!=typeof globalThis?globalThis:n,a=Array.prototype,l=a.forEach,c=a.indexOf,u=null==o?void 0:o.navigator,d=null==o?void 0:o.document,h=null==o?void 0:o.location,_=null==o?void 0:o.fetch,p=null!=o&&o.XMLHttpRequest&&"withCredentials"in new o.XMLHttpRequest?o.XMLHttpRequest:void 0,g=null==o?void 0:o.AbortController,v=null==u?void 0:u.userAgent,f=null!=n?n:{},m="$copy_autocapture",b=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"];!function(e){e.GZipJS="gzip-js",e.Base64="base64"}(r||(r={}));var y=["fatal","error","warning","log","info","debug"];function w(e,t){return-1!==e.indexOf(t)}var S=function(e){return e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},k=function(e){return e.replace(/^\$/,"")};var E=Array.isArray,x=Object.prototype,I=x.hasOwnProperty,P=x.toString,C=E||function(e){return"[object Array]"===P.call(e)},F=e=>"function"==typeof e,R=e=>e===Object(e)&&!C(e),T=e=>{if(R(e)){for(var t in e)if(I.call(e,t))return!1;return!0}return!1},$=e=>void 0===e,A=e=>"[object String]"==P.call(e),O=e=>A(e)&&0===e.trim().length,M=e=>null===e,L=e=>$(e)||M(e),D=e=>"[object Number]"==P.call(e),q=e=>"[object Boolean]"===P.call(e),N=e=>e instanceof FormData,B=e=>e instanceof Error,H=e=>w(b,e),U={DEBUG:!1,LIB_VERSION:"1.231.2"},z=e=>{var t={_log:function(t){if(n&&(U.DEBUG||f.POSTHOG_DEBUG)&&!$(n.console)&&n.console){for(var i=("__rrweb_original__"in n.console[t]?n.console[t].__rrweb_original__:n.console[t]),s=arguments.length,r=new Array(s>1?s-1:0),o=1;o<s;o++)r[o-1]=arguments[o];i(e,...r)}},info:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("log",...i)},warn:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("warn",...i)},error:function(){for(var e=arguments.length,i=new Array(e),s=0;s<e;s++)i[s]=arguments[s];t._log("error",...i)},critical:function(){for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];console.error(e,...i)},uninitializedWarning:e=>{t.error("You must initialize PostHog before calling ".concat(e))},createLogger:t=>z("".concat(e," ").concat(t))};return t},j=z("[PostHog.js]"),W=j.createLogger,V={};function G(e,t,i){if(C(e))if(l&&e.forEach===l)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var s=0,r=e.length;s<r;s++)if(s in e&&t.call(i,e[s],s)===V)return}function J(e,t,i){if(!L(e)){if(C(e))return G(e,t,i);if(N(e)){for(var s of e.entries())if(t.call(i,s[1],s[0])===V)return}else for(var r in e)if(I.call(e,r)&&t.call(i,e[r],r)===V)return}}var Y=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return G(i,(function(t){for(var i in t)void 0!==t[i]&&(e[i]=t[i])})),e},K=function(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];return G(i,(function(t){G(t,(function(t){e.push(t)}))})),e};function X(e){for(var t=Object.keys(e),i=t.length,s=new Array(i);i--;)s[i]=[t[i],e[t[i]]];return s}var Q=function(e){try{return e()}catch(e){return}},Z=function(e){return function(){try{for(var t=arguments.length,i=new Array(t),s=0;s<t;s++)i[s]=arguments[s];return e.apply(this,i)}catch(e){j.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),j.critical(e)}}},ee=function(e){var t={};return J(e,(function(e,i){A(e)&&e.length>0&&(t[i]=e)})),t};function te(e,t){return i=e,s=e=>A(e)&&!M(t)?e.slice(0,t):e,r=new Set,function e(t,i){return t!==Object(t)?s?s(t,i):t:r.has(t)?void 0:(r.add(t),C(t)?(n=[],G(t,(t=>{n.push(e(t))}))):(n={},J(t,((t,i)=>{r.has(t)||(n[i]=e(t,i))}))),n);var n}(i);var i,s,r}var ie=["herokuapp.com","vercel.app","netlify.app"];function se(e){var t=null==e?void 0:e.hostname;if(!A(t))return!1;var i=t.split(".").slice(-2).join(".");for(var s of ie)if(i===s)return!1;return!0}function re(e,t){for(var i=0;i<e.length;i++)if(t(e[i]))return e[i]}function ne(e,t,i,s){var{capture:r=!1,passive:n=!0}=null!=s?s:{};null==e||e.addEventListener(t,i,{capture:r,passive:n})}var oe="$people_distinct_id",ae="__alias",le="__timers",ce="$autocapture_disabled_server_side",ue="$heatmaps_enabled_server_side",de="$exception_capture_enabled_server_side",he="$web_vitals_enabled_server_side",_e="$dead_clicks_enabled_server_side",pe="$web_vitals_allowed_metrics",ge="$session_recording_enabled_server_side",ve="$console_log_recording_enabled_server_side",fe="$session_recording_network_payload_capture",me="$session_recording_masking",be="$session_recording_canvas_recording",ye="$replay_sample_rate",we="$replay_minimum_duration",Se="$replay_script_config",ke="$sesid",Ee="$session_is_sampled",xe="$session_recording_url_trigger_activated_session",Ie="$session_recording_event_trigger_activated_session",Pe="$enabled_feature_flags",Ce="$early_access_features",Fe="$stored_person_properties",Re="$stored_group_properties",Te="$surveys",$e="$surveys_activated",Ae="$flag_call_reported",Oe="$user_state",Me="$client_session_props",Le="$capture_rate_limit",De="$initial_campaign_params",qe="$initial_referrer_info",Ne="$initial_person_info",Be="$epp",He="__POSTHOG_TOOLBAR__",Ue="$posthog_cookieless",ze=[oe,ae,"__cmpns",le,ge,ue,ke,Pe,Oe,Ce,Re,Fe,Te,Ae,Me,Le,De,qe,Be];function je(e){var t;return e instanceof Element&&(e.id===He||!(null===(t=e.closest)||void 0===t||!t.call(e,".toolbar-global-fade-container")))}function We(e){return!!e&&1===e.nodeType}function Ve(e,t){return!!e&&!!e.tagName&&e.tagName.toLowerCase()===t.toLowerCase()}function Ge(e){return!!e&&3===e.nodeType}function Je(e){return!!e&&11===e.nodeType}function Ye(e){return e?S(e).split(/\s+/):[]}function Ke(e){var t=null==n?void 0:n.location.href;return!!(t&&e&&e.some((e=>t.match(e))))}function Xe(e){var t="";switch(typeof e.className){case"string":t=e.className;break;case"object":t=(e.className&&"baseVal"in e.className?e.className.baseVal:null)||e.getAttribute("class")||"";break;default:t=""}return Ye(t)}function Qe(e){return L(e)?null:S(e).split(/(\s+)/).filter((e=>ht(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ze(e){var t="";return rt(e)&&!nt(e)&&e.childNodes&&e.childNodes.length&&J(e.childNodes,(function(e){var i;Ge(e)&&e.textContent&&(t+=null!==(i=Qe(e.textContent))&&void 0!==i?i:"")})),S(t)}function et(e){return $(e.target)?e.srcElement||null:null!==(t=e.target)&&void 0!==t&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var tt=["a","button","form","input","select","textarea","label"];function it(e){var t=e.parentNode;return!(!t||!We(t))&&t}function st(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,s=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(!n||!e||Ve(e,"html")||!We(e))return!1;if(null!=i&&i.url_allowlist&&!Ke(i.url_allowlist))return!1;if(null!=i&&i.url_ignorelist&&Ke(i.url_ignorelist))return!1;if(null!=i&&i.dom_event_allowlist){var o=i.dom_event_allowlist;if(o&&!o.some((e=>t.type===e)))return!1}for(var a=!1,l=[e],c=!0,u=e;u.parentNode&&!Ve(u,"body");)if(Je(u.parentNode))l.push(u.parentNode.host),u=u.parentNode.host;else{if(!(c=it(u)))break;if(s||tt.indexOf(c.tagName.toLowerCase())>-1)a=!0;else{var d=n.getComputedStyle(c);d&&"pointer"===d.getPropertyValue("cursor")&&(a=!0)}l.push(c),u=c}if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if($(i))return!0;var s=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var r of e){var n=s(r);if("object"==typeof n)return n.v}return!1}(l,i))return!1;if(!function(e,t){var i=null==t?void 0:t.css_selector_allowlist;if($(i))return!0;var s=function(e){if(i.some((t=>e.matches(t))))return{v:!0}};for(var r of e){var n=s(r);if("object"==typeof n)return n.v}return!1}(l,i))return!1;var h=n.getComputedStyle(e);if(h&&"pointer"===h.getPropertyValue("cursor")&&"click"===t.type)return!0;var _=e.tagName.toLowerCase();switch(_){case"html":return!1;case"form":return(r||["submit"]).indexOf(t.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(t.type)>=0;default:return a?(r||["click"]).indexOf(t.type)>=0:(r||["click"]).indexOf(t.type)>=0&&(tt.indexOf(_)>-1||"true"===e.getAttribute("contenteditable"))}}function rt(e){for(var t=e;t.parentNode&&!Ve(t,"body");t=t.parentNode){var i=Xe(t);if(w(i,"ph-sensitive")||w(i,"ph-no-capture"))return!1}if(w(Xe(e),"ph-include"))return!0;var s=e.type||"";if(A(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=e.name||e.id||"";if(A(r)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function nt(e){return!!(Ve(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Ve(e,"select")||Ve(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var ot="(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})",at=new RegExp("^(?:".concat(ot,")$")),lt=new RegExp(ot),ct="\\d{3}-?\\d{2}-?\\d{4}",ut=new RegExp("^(".concat(ct,")$")),dt=new RegExp("(".concat(ct,")"));function ht(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(L(e))return!1;if(A(e)){if(e=S(e),(t?at:lt).test((e||"").replace(/[- ]/g,"")))return!1;if((t?ut:dt).test(e))return!1}return!0}function _t(e){var t=Ze(e);return ht(t="".concat(t," ").concat(pt(e)).trim())?t:""}function pt(e){var t="";return e&&e.childNodes&&e.childNodes.length&&J(e.childNodes,(function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{var s=Ze(e);t="".concat(t," ").concat(s).trim(),e.childNodes&&e.childNodes.length&&(t="".concat(t," ").concat(pt(e)).trim())}catch(e){j.error("[AutoCapture]",e)}})),t}function gt(e){return function(e){var i=e.map((e=>{var i,s,r="";if(e.tag_name&&(r+=e.tag_name),e.attr_class)for(var n of(e.attr_class.sort(),e.attr_class))r+=".".concat(n.replace(/"/g,""));var o=t(t(t(t({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(i=e.nth_child)&&void 0!==i?i:0,"nth-of-type":null!==(s=e.nth_of_type)&&void 0!==s?s:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),a={};return X(o).sort(((e,t)=>{var[i]=e,[s]=t;return i.localeCompare(s)})).forEach((e=>{var[t,i]=e;return a[vt(t.toString())]=vt(i.toString())})),r+=":",r+=X(o).map((e=>{var[t,i]=e;return"".concat(t,'="').concat(i,'"')})).join("")}));return i.join(";")}(function(e){return e.map((e=>{var t,i,s={text:null===(t=e.$el_text)||void 0===t?void 0:t.slice(0,400),tag_name:e.tag_name,href:null===(i=e.attr__href)||void 0===i?void 0:i.slice(0,2048),attr_class:ft(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return X(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return s.attributes[t]=i})),s}))}(e))}function vt(e){return e.replace(/"|\\"/g,'\\"')}function ft(e){var t=e.attr__class;return t?C(t)?t:Ye(t):void 0}class mt{constructor(){this.clicks=[]}isRageClick(e,t,i){var s=this.clicks[this.clicks.length-1];if(s&&Math.abs(e-s.x)+Math.abs(t-s.y)<30&&i-s.timestamp<1e3){if(this.clicks.push({x:e,y:t,timestamp:i}),3===this.clicks.length)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}}var bt=["localhost","127.0.0.1"],yt=e=>{var t=null==d?void 0:d.createElement("a");return $(t)?null:(t.href=e,t)},wt=function(e){var t,i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"&",r=[];return J(e,(function(e,s){$(e)||$(s)||"undefined"===s||(t=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),i=encodeURIComponent(s),r[r.length]=i+"="+t)})),r.join(s)},St=function(e,t){for(var i,s=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;r<s.length;r++){var n=s[r].split("=");if(n[0]===t){i=n;break}}if(!C(i)||i.length<2)return"";var o=i[1];try{o=decodeURIComponent(o)}catch(e){j.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},kt=function(e,t,i){if(!e||!t||!t.length)return e;for(var s=e.split("#"),r=s[0]||"",n=s[1],o=r.split("?"),a=o[1],l=o[0],c=(a||"").split("&"),u=[],d=0;d<c.length;d++){var h=c[d].split("=");C(h)&&(t.includes(h[0])?u.push(h[0]+"="+i):u.push(c[d]))}var _=l;return null!=a&&(_+="?"+u.join("&")),null!=n&&(_+="#"+n),_},Et=function(e,t){var i=e.match(new RegExp(t+"=([^&]*)"));return i?i[1]:null},xt=W("[AutoCapture]");function It(e,t){return t.length>e?t.slice(0,e)+"...":t}function Pt(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!We(t));return t}function Ct(e,t,i,s){var r=e.tagName.toLowerCase(),n={tag_name:r};tt.indexOf(r)>-1&&!i&&("a"===r.toLowerCase()||"button"===r.toLowerCase()?n.$el_text=It(1024,_t(e)):n.$el_text=It(1024,Ze(e)));var o=Xe(e);o.length>0&&(n.classes=o.filter((function(e){return""!==e}))),J(e.attributes,(function(i){var r;if((!nt(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==s||!s.includes(i.name))&&!t&&ht(i.value)&&(r=i.name,!A(r)||"_ngcontent"!==r.substring(0,10)&&"_nghost"!==r.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Ye(o).join(" ")),n["attr__"+i.name]=It(1024,o)}}));for(var a=1,l=1,c=e;c=Pt(c);)a++,c.tagName===e.tagName&&l++;return n.nth_child=a,n.nth_of_type=l,n}function Ft(e,t){for(var i,s,{e:r,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:c}=t,u=[e],d=e;d.parentNode&&!Ve(d,"body");)Je(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,_=[],p={},g=!1,v=!1;if(J(u,(e=>{var t=rt(e);"a"===e.tagName.toLowerCase()&&(g=e.getAttribute("href"),g=t&&g&&ht(g)&&g),w(Xe(e),"ph-no-capture")&&(v=!0),_.push(Ct(e,o,a,l));var i=function(e){if(!rt(e))return{};var t={};return J(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),s=e.value;i&&s&&ht(s)&&(t[i]=s)}})),t}(e);Y(p,i)})),v)return{props:{},explicitNoCapture:v};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?_[0].$el_text=_t(e):_[0].$el_text=Ze(e)),g){var f,m;_[0].attr__href=g;var b=null===(f=yt(g))||void 0===f?void 0:f.host,y=null==n||null===(m=n.location)||void 0===m?void 0:m.host;b&&y&&b!==y&&(h=g)}return{props:Y({$event_type:r.type,$ce_version:1},c?{}:{$elements:_},{$elements_chain:gt(_)},null!==(i=_[0])&&void 0!==i&&i.$el_text?{$el_text:null===(s=_[0])||void 0===s?void 0:s.$el_text}:{},h&&"click"===r.type?{$external_click_url:h}:{},p)}}class Rt{constructor(e){i(this,"_initialized",!1),i(this,"_isDisabledServerSide",null),i(this,"rageclicks",new mt),i(this,"_elementsChainAsString",!1),this.instance=e,this._elementSelectors=null}get config(){var e,t,i=R(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=null===(e=i.url_allowlist)||void 0===e?void 0:e.map((e=>new RegExp(e))),i.url_ignorelist=null===(t=i.url_ignorelist)||void 0===t?void 0:t.map((e=>new RegExp(e))),i}_addDomEventHandlers(){if(this.isBrowserSupported()){if(n&&d){var e=e=>{e=e||(null==n?void 0:n.event);try{this._captureEvent(e)}catch(e){xt.error("Failed to capture event",e)}};if(ne(d,"submit",e,{capture:!0}),ne(d,"change",e,{capture:!0}),ne(d,"click",e,{capture:!0}),this.config.capture_copied_text){var t=e=>{e=e||(null==n?void 0:n.event),this._captureEvent(e,m)};ne(d,"copy",t,{capture:!0}),ne(d,"cut",t,{capture:!0})}}}else xt.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}onRemoteConfig(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[ce]:!!e.autocapture_opt_out}),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(e){this._elementSelectors=e}getElementSelectors(e){var t,i=[];return null===(t=this._elementSelectors)||void 0===t||t.forEach((t=>{var s=null==d?void 0:d.querySelectorAll(t);null==s||s.forEach((s=>{e===s&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null===(e=this.instance.persistence)||void 0===e?void 0:e.props[ce],s=this._isDisabledServerSide;if(M(s)&&!q(i)&&!this.instance.config.advanced_disable_decide)return!1;var r=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!r}_captureEvent(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$autocapture";if(this.isEnabled){var i,s=et(e);if(Ge(s)&&(s=s.parentNode||null),"$autocapture"===t&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!==(i=this.rageclicks)&&void 0!==i&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._captureEvent(e,"$rageclick");var r=t===m;if(s&&st(s,e,this.config,r,r?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=Ft(s,{e:e,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.config.element_attribute_ignorelist,elementsChainAsString:this._elementsChainAsString});if(a)return!1;var l=this.getElementSelectors(s);if(l&&l.length>0&&(o.$element_selectors=l),t===m){var c,u=Qe(null==n||null===(c=n.getSelection())||void 0===c?void 0:c.toString()),d=e.type||"clipboard";if(!u)return!1;o.$selected_content=u,o.$copy_type=d}return this.instance.capture(t,o),!0}}}isBrowserSupported(){return F(null==d?void 0:d.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return D(e)&&isFinite(e)&&Math.floor(e)===e});var Tt="0123456789abcdef";class $t{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,s){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(s)||e<0||t<0||i<0||s<0||e>0xffffffffffff||t>4095||i>1073741823||s>4294967295)throw new RangeError("invalid field value");var r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/Math.pow(2,8),r[5]=e,r[6]=112|t>>>8,r[7]=t,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=s>>>24,r[13]=s>>>16,r[14]=s>>>8,r[15]=s,new $t(r)}toString(){for(var e="",t=0;t<this.bytes.length;t++)e=e+Tt.charAt(this.bytes[t]>>>4)+Tt.charAt(15&this.bytes[t]),3!==t&&5!==t&&7!==t&&9!==t||(e+="-");if(36!==e.length)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new $t(this.bytes.slice(0))}equals(e){return 0===this.compareTo(e)}compareTo(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(0!==i)return Math.sign(i)}return 0}}class At{constructor(){i(this,"timestamp",0),i(this,"counter",0),i(this,"random",new Lt)}generate(){var e=this.generateOrAbort();if($(e)){this.timestamp=0;var t=this.generateOrAbort();if($(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.timestamp)this.timestamp=e,this.resetCounter();else{if(!(e+1e4>this.timestamp))return;this.counter++,this.counter>4398046511103&&(this.timestamp++,this.resetCounter())}return $t.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}resetCounter(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}var Ot,Mt=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;t<e.length;t++)e[t]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return e};n&&!$(n.crypto)&&crypto.getRandomValues&&(Mt=e=>crypto.getRandomValues(e));class Lt{constructor(){i(this,"buffer",new Uint32Array(8)),i(this,"cursor",1/0)}nextUint32(){return this.cursor>=this.buffer.length&&(Mt(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}var Dt=()=>qt().toString(),qt=()=>(Ot||(Ot=new At)).generate(),Nt="Thu, 01 Jan 1970 00:00:00 GMT",Bt="";var Ht=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function Ut(e,t){if(t){var i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d;if(Bt)return Bt;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),s=Math.min(i.length,8),r="dmn_chk_"+Dt(),n=new RegExp("(^|;)\\s*"+r+"=1");!Bt&&s--;){var o=i.slice(s).join("."),a=r+"=1;domain=."+o;t.cookie=a,n.test(t.cookie)&&(t.cookie=a+";expires="+Nt,Bt=o)}return Bt}(e);if(!i){var s=(e=>{var t=e.match(Ht);return t?t[0]:""})(e);s!==i&&j.info("Warning: cookie subdomain discovery mismatch",s,i),i=s}return i?"; domain=."+i:""}return""}var zt,jt={is_supported:()=>!!d,error:function(e){j.error("cookieStore error: "+e)},get:function(e){if(d){try{for(var t=e+"=",i=d.cookie.split(";").filter((e=>e.length)),s=0;s<i.length;s++){for(var r=i[s];" "==r.charAt(0);)r=r.substring(1,r.length);if(0===r.indexOf(t))return decodeURIComponent(r.substring(t.length,r.length))}}catch(e){}return null}},parse:function(e){var t;try{t=JSON.parse(jt.get(e))||{}}catch(e){}return t},set:function(e,t,i,s,r){if(d)try{var n="",o="",a=Ut(d.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+24*i*60*60*1e3),n="; expires="+l.toUTCString()}r&&(o="; secure");var c=e+"="+encodeURIComponent(JSON.stringify(t))+n+"; SameSite=Lax; path=/"+a+o;return c.length>3686.4&&j.warn("cookieStore warning: large cookie, len="+c.length),d.cookie=c,c}catch(e){return}},remove:function(e,t){try{jt.set(e,"",-1,t)}catch(e){return}}},Wt=null,Vt={is_supported:function(){if(!M(Wt))return Wt;var e=!0;if($(n))e=!1;else try{var t="__mplssupport__";Vt.set(t,"xyz"),'"xyz"'!==Vt.get(t)&&(e=!1),Vt.remove(t)}catch(t){e=!1}return e||j.error("localStorage unsupported; falling back to cookie store"),Wt=e,e},error:function(e){j.error("localStorage error: "+e)},get:function(e){try{return null==n?void 0:n.localStorage.getItem(e)}catch(e){Vt.error(e)}return null},parse:function(e){try{return JSON.parse(Vt.get(e))||{}}catch(e){}return null},set:function(e,t){try{null==n||n.localStorage.setItem(e,JSON.stringify(t))}catch(e){Vt.error(e)}},remove:function(e){try{null==n||n.localStorage.removeItem(e)}catch(e){Vt.error(e)}}},Gt=["distinct_id",ke,Ee,Be,Ne],Jt=t(t({},Vt),{},{parse:function(e){try{var t={};try{t=jt.parse(e)||{}}catch(e){}var i=Y(t,JSON.parse(Vt.get(e)||"{}"));return Vt.set(e,i),i}catch(e){}return null},set:function(e,t,i,s,r,n){try{Vt.set(e,t,void 0,void 0,n);var o={};Gt.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&jt.set(e,o,i,s,r,n)}catch(e){Vt.error(e)}},remove:function(e,t){try{null==n||n.localStorage.removeItem(e),jt.remove(e,t)}catch(e){Vt.error(e)}}}),Yt={},Kt={is_supported:function(){return!0},error:function(e){j.error("memoryStorage error: "+e)},get:function(e){return Yt[e]||null},parse:function(e){return Yt[e]||null},set:function(e,t){Yt[e]=t},remove:function(e){delete Yt[e]}},Xt=null,Qt={is_supported:function(){if(!M(Xt))return Xt;if(Xt=!0,$(n))Xt=!1;else try{var e="__support__";Qt.set(e,"xyz"),'"xyz"'!==Qt.get(e)&&(Xt=!1),Qt.remove(e)}catch(e){Xt=!1}return Xt},error:function(e){j.error("sessionStorage error: ",e)},get:function(e){try{return null==n?void 0:n.sessionStorage.getItem(e)}catch(e){Qt.error(e)}return null},parse:function(e){try{return JSON.parse(Qt.get(e))||null}catch(e){}return null},set:function(e,t){try{null==n||n.sessionStorage.setItem(e,JSON.stringify(t))}catch(e){Qt.error(e)}},remove:function(e){try{null==n||n.sessionStorage.removeItem(e)}catch(e){Qt.error(e)}}};!function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"}(zt||(zt={}));class Zt{constructor(e){this.instance=e}get config(){return this.instance.config}get consent(){return this.getDnt()?zt.DENIED:this.storedConsent}isOptedOut(){return this.consent===zt.DENIED||this.consent===zt.PENDING&&this.config.opt_out_capturing_by_default}isOptedIn(){return!this.isOptedOut()}optInOut(e){this.storage.set(this.storageKey,e?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}reset(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}get storageKey(){var{token:e,opt_out_capturing_cookie_prefix:t}=this.instance.config;return(t||"__ph_opt_in_out_")+e}get storedConsent(){var e=this.storage.get(this.storageKey);return"1"===e?zt.GRANTED:"0"===e?zt.DENIED:zt.PENDING}get storage(){if(!this._storage){var e=this.config.opt_out_capturing_persistence_type;this._storage="localStorage"===e?Vt:jt;var t="localStorage"===e?jt:Vt;t.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut("1"===t.get(this.storageKey)),t.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}getDnt(){return!!this.config.respect_dnt&&!!re([null==u?void 0:u.doNotTrack,null==u?void 0:u.msDoNotTrack,f.doNotTrack],(e=>w([!0,1,"1","yes"],e)))}}var ei=W("[Dead Clicks]"),ti=()=>!0,ii=e=>{var t,i=!(null===(t=e.instance.persistence)||void 0===t||!t.get_property(_e)),s=e.instance.config.capture_dead_clicks;return q(s)?s:i};class si{get lazyLoadedDeadClicksAutocapture(){return this._lazyLoadedDeadClicksAutocapture}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabled()}onRemoteConfig(e){this.instance.persistence&&this.instance.persistence.register({[_e]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this.loadScript((()=>{this.start()}))}loadScript(e){var t,i,s;null!==(t=f.__PosthogExtensions__)&&void 0!==t&&t.initDeadClicksAutocapture&&e(),null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"dead-clicks-autocapture",(t=>{t?ei.error("failed to load script",t):e()}))}start(){var e;if(d){if(!this._lazyLoadedDeadClicksAutocapture&&null!==(e=f.__PosthogExtensions__)&&void 0!==e&&e.initDeadClicksAutocapture){var t=R(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=f.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(d),ei.info("starting...")}}else ei.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,ei.info("stopping..."))}}var ri=W("[ExceptionAutocapture]");class ni{constructor(e){var t;i(this,"startCapturing",(()=>{var e,t,i,s;if(n&&this.isEnabled&&!this.hasHandlers){var r=null===(e=f.__PosthogExtensions__)||void 0===e||null===(t=e.errorWrappingFunctions)||void 0===t?void 0:t.wrapOnError,o=null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.errorWrappingFunctions)||void 0===s?void 0:s.wrapUnhandledRejection;if(r&&o)try{this.unwrapOnError=r(this.captureException.bind(this)),this.unwrapUnhandledRejection=o(this.captureException.bind(this))}catch(e){ri.error("failed to start",e),this.stopCapturing()}else ri.error("failed to load error wrapping functions - cannot start")}})),this.instance=e,this.remoteEnabled=!(null===(t=this.instance.persistence)||void 0===t||!t.props[de]),this.startIfEnabled()}get isEnabled(){var e;return q(this.instance.config.capture_exceptions)?this.instance.config.capture_exceptions:null!==(e=this.remoteEnabled)&&void 0!==e&&e}get hasHandlers(){return!$(this.unwrapOnError)}startIfEnabled(){this.isEnabled&&!this.hasHandlers&&(ri.info("enabled, starting..."),this.loadScript(this.startCapturing))}loadScript(e){var t,i;this.hasHandlers&&e(),null===(t=f.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,"exception-autocapture",(t=>{if(t)return ri.error("failed to load script",t);e()}))}stopCapturing(){var e,t;null===(e=this.unwrapOnError)||void 0===e||e.call(this),this.unwrapOnError=void 0,null===(t=this.unwrapUnhandledRejection)||void 0===t||t.call(this),this.unwrapUnhandledRejection=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.remoteEnabled=!!t||!1,this.instance.persistence&&this.instance.persistence.register({[de]:this.remoteEnabled}),this.startIfEnabled()}captureException(e){var t=this.instance.requestRouter.endpointFor("ui");e.$exception_personURL="".concat(t,"/project/").concat(this.instance.config.token,"/person/").concat(this.instance.get_distinct_id()),this.instance.exceptions.sendExceptionEvent(e)}}function oi(e){var t,i;return(null===(t=JSON.stringify(e,(i=[],function(e,t){if(R(t)){for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(t)?"[Circular]":(i.push(t),t)}return t})))||void 0===t?void 0:t.length)||0}function ai(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:6606028.8;if(e.size>=t&&e.data.length>1){var i=Math.floor(e.data.length/2),s=e.data.slice(0,i),r=e.data.slice(i);return[ai({size:oi(s),data:s,sessionId:e.sessionId,windowId:e.windowId}),ai({size:oi(r),data:r,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var li=(e=>(e[e.DomContentLoaded=0]="DomContentLoaded",e[e.Load=1]="Load",e[e.FullSnapshot=2]="FullSnapshot",e[e.IncrementalSnapshot=3]="IncrementalSnapshot",e[e.Meta=4]="Meta",e[e.Custom=5]="Custom",e[e.Plugin=6]="Plugin",e))(li||{}),ci=(e=>(e[e.Mutation=0]="Mutation",e[e.MouseMove=1]="MouseMove",e[e.MouseInteraction=2]="MouseInteraction",e[e.Scroll=3]="Scroll",e[e.ViewportResize=4]="ViewportResize",e[e.Input=5]="Input",e[e.TouchMove=6]="TouchMove",e[e.MediaInteraction=7]="MediaInteraction",e[e.StyleSheetRule=8]="StyleSheetRule",e[e.CanvasMutation=9]="CanvasMutation",e[e.Font=10]="Font",e[e.Log=11]="Log",e[e.Drag=12]="Drag",e[e.StyleDeclaration=13]="StyleDeclaration",e[e.Selection=14]="Selection",e[e.AdoptedStyleSheet=15]="AdoptedStyleSheet",e[e.CustomElement=16]="CustomElement",e))(ci||{}),ui="[SessionRecording]",di="redacted",hi={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:e=>e,recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io",".clarity.ms","analytics.google.com"]},_i=["authorization","x-forwarded-for","authorization","cookie","set-cookie","x-api-key","x-real-ip","remote-addr","forwarded","proxy-authorization","x-csrf-token","x-csrftoken","x-xsrf-token"],pi=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],gi=["/s/","/e/","/i/"];function vi(e,t,i,s){if(L(e))return e;var r=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return A(r)&&(r=parseInt(r)),r>i?ui+" ".concat(s," body too large to record (").concat(r," bytes)"):e}function fi(e,t){if(L(e))return e;var i=e;return ht(i,!1)||(i=ui+" "+t+" body "+di),J(pi,(e=>{var s,r;null!==(s=i)&&void 0!==s&&s.length&&-1!==(null===(r=i)||void 0===r?void 0:r.indexOf(e))&&(i=ui+" "+t+" body "+di+" as might contain: "+e)})),i}var mi=(e,i)=>{var s,r,n,o={payloadSizeLimitBytes:hi.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...hi.performanceEntryTypeToObserve],payloadHostDenyList:[...i.payloadHostDenyList||[],...hi.payloadHostDenyList]},a=!1!==e.session_recording.recordHeaders&&i.recordHeaders,l=!1!==e.session_recording.recordBody&&i.recordBody,c=!1!==e.capture_performance&&i.recordPerformance,u=(s=o,n=Math.min(1e6,null!==(r=s.payloadSizeLimitBytes)&&void 0!==r?r:1e6),e=>(null!=e&&e.requestBody&&(e.requestBody=vi(e.requestBody,e.requestHeaders,n,"Request")),null!=e&&e.responseBody&&(e.responseBody=vi(e.responseBody,e.responseHeaders,n,"Response")),e)),d=t=>{return u(((e,t)=>{var i,s=yt(e.name),r=0===t.indexOf("http")?null===(i=yt(t))||void 0===i?void 0:i.pathname:t;"/"===r&&(r="");var n=null==s?void 0:s.pathname.replace(r||"","");if(!(s&&n&&gi.some((e=>0===n.indexOf(e)))))return e})((s=(i=t).requestHeaders,L(s)||J(Object.keys(null!=s?s:{}),(e=>{_i.includes(e.toLowerCase())&&(s[e]=di)})),i),e.api_host));var i,s},h=F(e.session_recording.maskNetworkRequestFn);return h&&F(e.session_recording.maskCapturedNetworkRequestFn)&&j.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),h&&(e.session_recording.maskCapturedNetworkRequestFn=i=>{var s=e.session_recording.maskNetworkRequestFn({url:i.name});return t(t({},i),{},{name:null==s?void 0:s.url})}),o.maskRequestFn=F(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,s,r,n=d(t);return n&&null!==(i=null===(s=(r=e.session_recording).maskCapturedNetworkRequestFn)||void 0===s?void 0:s.call(r,n))&&void 0!==i?i:void 0}:e=>function(e){if(!$(e))return e.requestBody=fi(e.requestBody,"Request"),e.responseBody=fi(e.responseBody,"Response"),e}(d(e)),t(t(t({},hi),o),{},{recordHeaders:a,recordBody:l,recordPerformance:c,recordInitialRequests:c})};function bi(e,t,i,s,r){return t>i&&(j.warn("min cannot be greater than max."),t=i),D(e)?e>i?(s&&j.warn(s+" cannot be greater than max: "+i+". Using max value instead."),i):e<t?(s&&j.warn(s+" cannot be less than min: "+t+". Using min value instead."),t):e:(s&&j.warn(s+" must be a number. using max or fallback. max: "+i+", fallback: "+r),bi(r||i,t,i,s))}class yi{constructor(e){var t,s,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};i(this,"bucketSize",100),i(this,"refillRate",10),i(this,"mutationBuckets",{}),i(this,"loggedTracker",{}),i(this,"refillBuckets",(()=>{Object.keys(this.mutationBuckets).forEach((e=>{this.mutationBuckets[e]=this.mutationBuckets[e]+this.refillRate,this.mutationBuckets[e]>=this.bucketSize&&delete this.mutationBuckets[e]}))})),i(this,"getNodeOrRelevantParent",(e=>{var t=this.rrweb.mirror.getNode(e);if("svg"!==(null==t?void 0:t.nodeName)&&t instanceof Element){var i=t.closest("svg");if(i)return[this.rrweb.mirror.getId(i),i]}return[e,t]})),i(this,"numberOfChanges",(e=>{var t,i,s,r,n,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(s=null===(r=e.attributes)||void 0===r?void 0:r.length)&&void 0!==s?s:0)+(null!==(n=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==n?n:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)})),i(this,"throttleMutations",(e=>{if(3!==e.type||0!==e.data.source)return e;var t=e.data,i=this.numberOfChanges(t);t.attributes&&(t.attributes=t.attributes.filter((e=>{var t,i,s,[r,n]=this.getNodeOrRelevantParent(e.id);if(0===this.mutationBuckets[r])return!1;(this.mutationBuckets[r]=null!==(t=this.mutationBuckets[r])&&void 0!==t?t:this.bucketSize,this.mutationBuckets[r]=Math.max(this.mutationBuckets[r]-1,0),0===this.mutationBuckets[r])&&(this.loggedTracker[r]||(this.loggedTracker[r]=!0,null===(i=(s=this.options).onBlockedNode)||void 0===i||i.call(s,r,n)));return e})));var s=this.numberOfChanges(t);return 0!==s||i===s?e:void 0})),this.rrweb=e,this.options=r,this.refillRate=bi(null!==(t=this.options.refillRate)&&void 0!==t?t:this.refillRate,0,100,"mutation throttling refill rate"),this.bucketSize=bi(null!==(s=this.options.bucketSize)&&void 0!==s?s:this.bucketSize,0,100,"mutation throttling bucket size"),setInterval((()=>{this.refillBuckets()}),1e3)}}var wi=Uint8Array,Si=Uint16Array,ki=Uint32Array,Ei=new wi([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),xi=new wi([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),Ii=new wi([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Pi=function(e,t){for(var i=new Si(31),s=0;s<31;++s)i[s]=t+=1<<e[s-1];var r=new ki(i[30]);for(s=1;s<30;++s)for(var n=i[s];n<i[s+1];++n)r[n]=n-i[s]<<5|s;return[i,r]},Ci=Pi(Ei,2),Fi=Ci[0],Ri=Ci[1];Fi[28]=258,Ri[258]=28;for(var Ti=Pi(xi,0)[1],$i=new Si(32768),Ai=0;Ai<32768;++Ai){var Oi=(43690&Ai)>>>1|(21845&Ai)<<1;Oi=(61680&(Oi=(52428&Oi)>>>2|(13107&Oi)<<2))>>>4|(3855&Oi)<<4,$i[Ai]=((65280&Oi)>>>8|(255&Oi)<<8)>>>1}var Mi=function(e,t,i){for(var s=e.length,r=0,n=new Si(t);r<s;++r)++n[e[r]-1];var o,a=new Si(t);for(r=0;r<t;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Si(1<<t);var l=15-t;for(r=0;r<s;++r)if(e[r])for(var c=r<<4|e[r],u=t-e[r],d=a[e[r]-1]++<<u,h=d|(1<<u)-1;d<=h;++d)o[$i[d]>>>l]=c}else for(o=new Si(s),r=0;r<s;++r)o[r]=$i[a[e[r]-1]++]>>>15-e[r];return o},Li=new wi(288);for(Ai=0;Ai<144;++Ai)Li[Ai]=8;for(Ai=144;Ai<256;++Ai)Li[Ai]=9;for(Ai=256;Ai<280;++Ai)Li[Ai]=7;for(Ai=280;Ai<288;++Ai)Li[Ai]=8;var Di=new wi(32);for(Ai=0;Ai<32;++Ai)Di[Ai]=5;var qi=Mi(Li,9,0),Ni=Mi(Di,5,0),Bi=function(e){return(e/8>>0)+(7&e&&1)},Hi=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var s=new(e instanceof Si?Si:e instanceof ki?ki:wi)(i-t);return s.set(e.subarray(t,i)),s},Ui=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8},zi=function(e,t,i){i<<=7&t;var s=t/8>>0;e[s]|=i,e[s+1]|=i>>>8,e[s+2]|=i>>>16},ji=function(e,t){for(var i=[],s=0;s<e.length;++s)e[s]&&i.push({s:s,f:e[s]});var r=i.length,n=i.slice();if(!r)return[new wi(0),0];if(1==r){var o=new wi(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(e,t){return e.f-t.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],c=0,u=1,d=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=r-1;)a=i[i[c].f<i[d].f?c++:d++],l=i[c!=u&&i[c].f<i[d].f?c++:d++],i[u++]={s:-1,f:a.f+l.f,l:a,r:l};var h=n[0].s;for(s=1;s<r;++s)n[s].s>h&&(h=n[s].s);var _=new Si(h+1),p=Wi(i[u-1],_,0);if(p>t){s=0;var g=0,v=p-t,f=1<<v;for(n.sort((function(e,t){return _[t.s]-_[e.s]||e.f-t.f}));s<r;++s){var m=n[s].s;if(!(_[m]>t))break;g+=f-(1<<p-_[m]),_[m]=t}for(g>>>=v;g>0;){var b=n[s].s;_[b]<t?g-=1<<t-_[b]++-1:++s}for(;s>=0&&g;--s){var y=n[s].s;_[y]==t&&(--_[y],++g)}p=t}return[new wi(_),p]},Wi=function(e,t,i){return-1==e.s?Math.max(Wi(e.l,t,i+1),Wi(e.r,t,i+1)):t[e.s]=i},Vi=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Si(++t),s=0,r=e[0],n=1,o=function(e){i[s++]=e},a=1;a<=t;++a)if(e[a]==r&&a!=t)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=e[a]}return[i.subarray(0,s),t]},Gi=function(e,t){for(var i=0,s=0;s<t.length;++s)i+=e[s]*t[s];return i},Ji=function(e,t,i){var s=i.length,r=Bi(t+2);e[r]=255&s,e[r+1]=s>>>8,e[r+2]=255^e[r],e[r+3]=255^e[r+1];for(var n=0;n<s;++n)e[r+n+4]=i[n];return 8*(r+4+s)},Yi=function(e,t,i,s,r,n,o,a,l,c,u){Ui(t,u++,i),++r[256];for(var d=ji(r,15),h=d[0],_=d[1],p=ji(n,15),g=p[0],v=p[1],f=Vi(h),m=f[0],b=f[1],y=Vi(g),w=y[0],S=y[1],k=new Si(19),E=0;E<m.length;++E)k[31&m[E]]++;for(E=0;E<w.length;++E)k[31&w[E]]++;for(var x=ji(k,7),I=x[0],P=x[1],C=19;C>4&&!I[Ii[C-1]];--C);var F,R,T,$,A=c+5<<3,O=Gi(r,Li)+Gi(n,Di)+o,M=Gi(r,h)+Gi(n,g)+o+14+3*C+Gi(k,I)+(2*k[16]+3*k[17]+7*k[18]);if(A<=O&&A<=M)return Ji(t,u,e.subarray(l,l+c));if(Ui(t,u,1+(M<O)),u+=2,M<O){F=Mi(h,_,0),R=h,T=Mi(g,v,0),$=g;var L=Mi(I,P,0);Ui(t,u,b-257),Ui(t,u+5,S-1),Ui(t,u+10,C-4),u+=14;for(E=0;E<C;++E)Ui(t,u+3*E,I[Ii[E]]);u+=3*C;for(var D=[m,w],q=0;q<2;++q){var N=D[q];for(E=0;E<N.length;++E){var B=31&N[E];Ui(t,u,L[B]),u+=I[B],B>15&&(Ui(t,u,N[E]>>>5&127),u+=N[E]>>>12)}}}else F=qi,R=Li,T=Ni,$=Di;for(E=0;E<a;++E)if(s[E]>255){B=s[E]>>>18&31;zi(t,u,F[B+257]),u+=R[B+257],B>7&&(Ui(t,u,s[E]>>>23&31),u+=Ei[B]);var H=31&s[E];zi(t,u,T[H]),u+=$[H],H>3&&(zi(t,u,s[E]>>>5&8191),u+=xi[H])}else zi(t,u,F[s[E]]),u+=R[s[E]];return zi(t,u,F[256]),u+R[256]},Ki=new ki([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Xi=function(){for(var e=new ki(256),t=0;t<256;++t){for(var i=t,s=9;--s;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Qi=function(){var e=4294967295;return{p:function(t){for(var i=e,s=0;s<t.length;++s)i=Xi[255&i^t[s]]^i>>>8;e=i},d:function(){return 4294967295^e}}},Zi=function(e,t,i,s,r){return function(e,t,i,s,r,n){var o=e.length,a=new wi(s+o+5*(1+Math.floor(o/7e3))+r),l=a.subarray(s,a.length-r),c=0;if(!t||o<8)for(var u=0;u<=o;u+=65535){var d=u+65535;d<o?c=Ji(l,c,e.subarray(u,d)):(l[u]=n,c=Ji(l,c,e.subarray(u,o)))}else{for(var h=Ki[t-1],_=h>>>13,p=8191&h,g=(1<<i)-1,v=new Si(32768),f=new Si(g+1),m=Math.ceil(i/3),b=2*m,y=function(t){return(e[t]^e[t+1]<<m^e[t+2]<<b)&g},w=new ki(25e3),S=new Si(288),k=new Si(32),E=0,x=0,I=(u=0,0),P=0,C=0;u<o;++u){var F=y(u),R=32767&u,T=f[F];if(v[R]=T,f[F]=R,P<=u){var $=o-u;if((E>7e3||I>24576)&&$>423){c=Yi(e,l,0,w,S,k,x,I,C,u-C,c),I=E=x=0,C=u;for(var A=0;A<286;++A)S[A]=0;for(A=0;A<30;++A)k[A]=0}var O=2,M=0,L=p,D=R-T&32767;if($>2&&F==y(u-D))for(var q=Math.min(_,$)-1,N=Math.min(32767,u),B=Math.min(258,$);D<=N&&--L&&R!=T;){if(e[u+O]==e[u+O-D]){for(var H=0;H<B&&e[u+H]==e[u+H-D];++H);if(H>O){if(O=H,M=D,H>q)break;var U=Math.min(D,H-2),z=0;for(A=0;A<U;++A){var j=u-D+A+32768&32767,W=j-v[j]+32768&32767;W>z&&(z=W,T=j)}}}D+=(R=T)-(T=v[R])+32768&32767}if(M){w[I++]=268435456|Ri[O]<<18|Ti[M];var V=31&Ri[O],G=31&Ti[M];x+=Ei[V]+xi[G],++S[257+V],++k[G],P=u+O,++E}else w[I++]=e[u],++S[e[u]]}}c=Yi(e,l,n,w,S,k,x,I,C,u-C,c)}return Hi(a,0,s+Bi(c)+r)}(e,null==t.level?6:t.level,null==t.mem?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(e.length)))):12+t.mem,i,s,!r)},es=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},ts=function(e,t){var i=t.filename;if(e[0]=31,e[1]=139,e[2]=8,e[8]=t.level<2?4:9==t.level?2:0,e[9]=3,0!=t.mtime&&es(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var s=0;s<=i.length;++s)e[s+10]=i.charCodeAt(s)}},is=function(e){return 10+(e.filename&&e.filename.length+1||0)};function ss(e,t){void 0===t&&(t={});var i=Qi(),s=e.length;i.p(e);var r=Zi(e,t,is(t),8),n=r.length;return ts(r,t),es(r,n-8,i.d()),es(r,n-4,s),r}function rs(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var s=new wi(e.length+(e.length>>>1)),r=0,n=function(e){s[r++]=e},o=0;o<i;++o){if(r+5>s.length){var a=new wi(r+8+(i-o<<1));a.set(s),s=a}var l=e.charCodeAt(o);l<128||t?n(l):l<2048?(n(192|l>>>6),n(128|63&l)):l>55295&&l<57344?(n(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),n(128|l>>>12&63),n(128|l>>>6&63),n(128|63&l)):(n(224|l>>>12),n(128|l>>>6&63),n(128|63&l))}return Hi(s,0,r)}function ns(e,t){return function(e){for(var t=0,i=0;i<e.length;i++)t=(t<<5)-t+e.charCodeAt(i),t|=0;return Math.abs(t)}(e)%100<bi(100*t,0,100)}var os="[SessionRecording]",as=W(os),ls=3e5,cs=[ci.MouseMove,ci.MouseInteraction,ci.Scroll,ci.ViewportResize,ci.Input,ci.TouchMove,ci.MediaInteraction,ci.Drag],us=e=>({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function ds(e){return function(e,t){for(var i="",s=0;s<e.length;){var r=e[s++];r<128||t?i+=String.fromCharCode(r):r<224?i+=String.fromCharCode((31&r)<<6|63&e[s++]):r<240?i+=String.fromCharCode((15&r)<<12|(63&e[s++])<<6|63&e[s++]):(r=((15&r)<<18|(63&e[s++])<<12|(63&e[s++])<<6|63&e[s++])-65536,i+=String.fromCharCode(55296|r>>10,56320|1023&r))}return i}(ss(rs(JSON.stringify(e))),!0)}function hs(e){return e.type===li.Custom&&"sessionIdle"===e.data.tag}function _s(e,t){return t.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))}class ps{get sessionIdleThresholdMilliseconds(){return this.instance.config.session_recording.session_idle_threshold_ms||3e5}get rrwebRecord(){var e,t;return null==f||null===(e=f.__PosthogExtensions__)||void 0===e||null===(t=e.rrweb)||void 0===t?void 0:t.record}get started(){return this._captureStarted}get sessionManager(){if(!this.instance.sessionManager)throw new Error(os+" must be started with a valid sessionManager.");return this.instance.sessionManager}get fullSnapshotIntervalMillis(){var e,t;return"trigger_pending"===this.triggerStatus?6e4:null!==(e=null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.full_snapshot_interval_millis)&&void 0!==e?e:ls}get isSampled(){var e=this.instance.get_property(Ee);return q(e)?e:null}get sessionDuration(){var e,t,i=null===(e=this.buffer)||void 0===e?void 0:e.data[(null===(t=this.buffer)||void 0===t?void 0:t.data.length)-1],{sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-s:null}get isRecordingEnabled(){var e=!!this.instance.get_property(ge),t=!this.instance.config.disable_session_recording;return n&&e&&t}get isConsoleLogCaptureEnabled(){var e=!!this.instance.get_property(ve),t=this.instance.config.enable_recording_console_log;return null!=t?t:e}get canvasRecording(){var e,t,i,s,r,n,o=this.instance.config.session_recording.captureCanvas,a=this.instance.get_property(be),l=null!==(e=null!==(t=null==o?void 0:o.recordCanvas)&&void 0!==t?t:null==a?void 0:a.enabled)&&void 0!==e&&e,c=null!==(i=null!==(s=null==o?void 0:o.canvasFps)&&void 0!==s?s:null==a?void 0:a.fps)&&void 0!==i?i:4,u=null!==(r=null!==(n=null==o?void 0:o.canvasQuality)&&void 0!==n?n:null==a?void 0:a.quality)&&void 0!==r?r:.4;if("string"==typeof u){var d=parseFloat(u);u=isNaN(d)?.4:d}return{enabled:l,fps:bi(c,0,12,"canvas recording fps",4),quality:bi(u,0,1,"canvas recording quality",.4)}}get networkPayloadCapture(){var e,t,i=this.instance.get_property(fe),s={recordHeaders:null===(e=this.instance.config.session_recording)||void 0===e?void 0:e.recordHeaders,recordBody:null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.recordBody},r=(null==s?void 0:s.recordHeaders)||(null==i?void 0:i.recordHeaders),n=(null==s?void 0:s.recordBody)||(null==i?void 0:i.recordBody),o=R(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,a=!!(q(o)?o:null==i?void 0:i.capturePerformance);return r||n||a?{recordHeaders:r,recordBody:n,recordPerformance:a}:void 0}get masking(){var e,t,i,s,r,n,o=this.instance.get_property(me),a={maskAllInputs:null===(e=this.instance.config.session_recording)||void 0===e?void 0:e.maskAllInputs,maskTextSelector:null===(t=this.instance.config.session_recording)||void 0===t?void 0:t.maskTextSelector,blockSelector:null===(i=this.instance.config.session_recording)||void 0===i?void 0:i.blockSelector},l=null!==(s=null==a?void 0:a.maskAllInputs)&&void 0!==s?s:null==o?void 0:o.maskAllInputs,c=null!==(r=null==a?void 0:a.maskTextSelector)&&void 0!==r?r:null==o?void 0:o.maskTextSelector,u=null!==(n=null==a?void 0:a.blockSelector)&&void 0!==n?n:null==o?void 0:o.blockSelector;return $(l)&&$(c)&&$(u)?void 0:{maskAllInputs:null==l||l,maskTextSelector:c,blockSelector:u}}get sampleRate(){var e=this.instance.get_property(ye);return D(e)?e:null}get minimumDuration(){var e=this.instance.get_property(we);return D(e)?e:null}get status(){return this.receivedDecide?this.isRecordingEnabled?!1===this.isSampled?"disabled":this._urlBlocked?"paused":L(this._linkedFlag)||this._linkedFlagSeen?"trigger_pending"===this.triggerStatus?"buffering":q(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}get urlTriggerStatus(){var e;return 0===this._urlTriggers.length?"trigger_disabled":(null===(e=this.instance)||void 0===e?void 0:e.get_property(xe))===this.sessionId?"trigger_activated":"trigger_pending"}get eventTriggerStatus(){var e;return 0===this._eventTriggers.length?"trigger_disabled":(null===(e=this.instance)||void 0===e?void 0:e.get_property(Ie))===this.sessionId?"trigger_activated":"trigger_pending"}get triggerStatus(){var e="trigger_activated"===this.eventTriggerStatus||"trigger_activated"===this.urlTriggerStatus,t="trigger_pending"===this.eventTriggerStatus||"trigger_pending"===this.urlTriggerStatus;return e?"trigger_activated":t?"trigger_pending":"trigger_disabled"}constructor(e){if(i(this,"queuedRRWebEvents",[]),i(this,"isIdle",!1),i(this,"_linkedFlagSeen",!1),i(this,"_lastActivityTimestamp",Date.now()),i(this,"_linkedFlag",null),i(this,"_removePageViewCaptureHook",void 0),i(this,"_onSessionIdListener",void 0),i(this,"_persistDecideOnSessionListener",void 0),i(this,"_samplingSessionListener",void 0),i(this,"_urlTriggers",[]),i(this,"_urlBlocklist",[]),i(this,"_urlBlocked",!1),i(this,"_eventTriggers",[]),i(this,"_removeEventTriggerCaptureHook",void 0),i(this,"_forceAllowLocalhostNetworkCapture",!1),i(this,"_onBeforeUnload",(()=>{this._flushBuffer()})),i(this,"_onOffline",(()=>{this._tryAddCustomEvent("browser offline",{})})),i(this,"_onOnline",(()=>{this._tryAddCustomEvent("browser online",{})})),i(this,"_onVisibilityChange",(()=>{if(null!=d&&d.visibilityState){var e="window "+d.visibilityState;this._tryAddCustomEvent(e,{})}})),this.instance=e,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw as.error("started without valid sessionManager"),new Error(os+" started without valid sessionManager. This is a bug.");if(this.instance.config.__preview_experimental_cookieless_mode)throw new Error(os+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:t,windowId:s}=this.sessionManager.checkAndGetSessionAndWindowId();this.sessionId=t,this.windowId=s,this.buffer=this.clearBuffer(),this.sessionIdleThresholdMilliseconds>=this.sessionManager.sessionTimeoutMs&&as.warn("session_idle_threshold_ms (".concat(this.sessionIdleThresholdMilliseconds,") is greater than the session timeout (").concat(this.sessionManager.sessionTimeoutMs,"). Session will never be detected as idle"))}startIfEnabledOrStop(e){this.isRecordingEnabled?(this._startCapture(e),ne(n,"beforeunload",this._onBeforeUnload),ne(n,"offline",this._onOffline),ne(n,"online",this._onOnline),ne(n,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),L(this._removePageViewCaptureHook)&&(this._removePageViewCaptureHook=this.instance.on("eventCaptured",(e=>{try{if("$pageview"===e.event){var t=null!=e&&e.properties.$current_url?this._maskUrl(null==e?void 0:e.properties.$current_url):"";if(!t)return;this._tryAddCustomEvent("$pageview",{href:t})}}catch(e){as.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this.sessionManager.onSessionId(((e,t,i)=>{var s,r,n,o;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null===(s=this.instance)||void 0===s||null===(r=s.persistence)||void 0===r||r.unregister(Ie),null===(n=this.instance)||void 0===n||null===(o=n.persistence)||void 0===o||o.unregister(xe))})))):this.stopRecording()}stopRecording(){var e,t,i,s;this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,null==n||n.removeEventListener("beforeunload",this._onBeforeUnload),null==n||n.removeEventListener("offline",this._onOffline),null==n||n.removeEventListener("online",this._onOnline),null==n||n.removeEventListener("visibilitychange",this._onVisibilityChange),this.clearBuffer(),clearInterval(this._fullSnapshotTimer),null===(e=this._removePageViewCaptureHook)||void 0===e||e.call(this),this._removePageViewCaptureHook=void 0,null===(t=this._removeEventTriggerCaptureHook)||void 0===t||t.call(this),this._removeEventTriggerCaptureHook=void 0,null===(i=this._onSessionIdListener)||void 0===i||i.call(this),this._onSessionIdListener=void 0,null===(s=this._samplingSessionListener)||void 0===s||s.call(this),this._samplingSessionListener=void 0,as.info("stopped"))}makeSamplingDecision(e){var t,i=this.sessionId!==e,s=this.sampleRate;if(D(s)){var r=this.isSampled,n=i||!q(r),o=n?ns(e,s):r;n&&(o?this._reportStarted("sampled"):as.warn("Sample rate (".concat(s,") has determined that this sessionId (").concat(e,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:s,isSampled:o})),null===(t=this.instance.persistence)||void 0===t||t.register({[Ee]:o})}else{var a;null===(a=this.instance.persistence)||void 0===a||a.register({[Ee]:null})}}onRemoteConfig(e){var t,i,s,r,n,o;(this._tryAddCustomEvent("$remote_config_received",e),this._persistRemoteConfig(e),this._linkedFlag=(null===(t=e.sessionRecording)||void 0===t?void 0:t.linkedFlag)||null,null!==(i=e.sessionRecording)&&void 0!==i&&i.endpoint)&&(this._endpoint=null===(o=e.sessionRecording)||void 0===o?void 0:o.endpoint);if(this._setupSampling(),!L(this._linkedFlag)&&!this._linkedFlagSeen){var a=A(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,l=A(this._linkedFlag)?null:this._linkedFlag.variant;this.instance.onFeatureFlags(((e,t)=>{var i=R(t)&&a in t,s=l?t[a]===l:i;s&&this._reportStarted("linked_flag_matched",{linkedFlag:a,linkedVariant:l}),this._linkedFlagSeen=s}))}null!==(s=e.sessionRecording)&&void 0!==s&&s.urlTriggers&&(this._urlTriggers=e.sessionRecording.urlTriggers),null!==(r=e.sessionRecording)&&void 0!==r&&r.urlBlocklist&&(this._urlBlocklist=e.sessionRecording.urlBlocklist),null!==(n=e.sessionRecording)&&void 0!==n&&n.eventTriggers&&(this._eventTriggers=e.sessionRecording.eventTriggers),this.receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){D(this.sampleRate)&&L(this._samplingSessionListener)&&(this._samplingSessionListener=this.sessionManager.onSessionId((e=>{this.makeSamplingDecision(e)})))}_persistRemoteConfig(e){if(this.instance.persistence){var i,s=this.instance.persistence,r=()=>{var i,r,n,o,a,l,c,u,d,h=null===(i=e.sessionRecording)||void 0===i?void 0:i.sampleRate,_=L(h)?null:parseFloat(h),p=null===(r=e.sessionRecording)||void 0===r?void 0:r.minimumDurationMilliseconds;s.register({[ge]:!!e.sessionRecording,[ve]:null===(n=e.sessionRecording)||void 0===n?void 0:n.consoleLogRecordingEnabled,[fe]:t({capturePerformance:e.capturePerformance},null===(o=e.sessionRecording)||void 0===o?void 0:o.networkPayloadCapture),[me]:null===(a=e.sessionRecording)||void 0===a?void 0:a.masking,[be]:{enabled:null===(l=e.sessionRecording)||void 0===l?void 0:l.recordCanvas,fps:null===(c=e.sessionRecording)||void 0===c?void 0:c.canvasFps,quality:null===(u=e.sessionRecording)||void 0===u?void 0:u.canvasQuality},[ye]:_,[we]:$(p)?null:p,[Se]:null===(d=e.sessionRecording)||void 0===d?void 0:d.scriptConfig})};r(),null===(i=this._persistDecideOnSessionListener)||void 0===i||i.call(this),this._persistDecideOnSessionListener=this.sessionManager.onSessionId(r)}}log(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"log";null===(t=this.instance.sessionRecording)||void 0===t||t.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:i,trace:[],payload:[JSON.stringify(e)]}},timestamp:Date.now()})}_startCapture(e){if(!$(Object.assign)&&!$(Array.from)&&!(this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut())){var t,i;if(this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),this.rrwebRecord)this._onScriptLoaded();else null===(t=f.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this.instance,this.scriptName,(e=>{if(e)return as.error("could not load recorder",e);this._onScriptLoaded()}));as.info("starting"),"active"===this.status&&this._reportStarted(e||"recording_initialized")}}get scriptName(){var e,t,i;return(null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t||null===(i=t.get_property(Se))||void 0===i?void 0:i.script)||"recorder"}isInteractiveEvent(e){var t;return 3===e.type&&-1!==cs.indexOf(null===(t=e.data)||void 0===t?void 0:t.source)}_updateWindowAndSessionIds(e){var t=this.isInteractiveEvent(e);t||this.isIdle||e.timestamp-this._lastActivityTimestamp>this.sessionIdleThresholdMilliseconds&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._tryAddCustomEvent("sessionIdle",{eventTimestamp:e.timestamp,lastActivityTimestamp:this._lastActivityTimestamp,threshold:this.sessionIdleThresholdMilliseconds,bufferLength:this.buffer.data.length,bufferSize:this.buffer.size}),this._flushBuffer());var i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)),!this.isIdle){var{windowId:s,sessionId:r}=this.sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),n=this.sessionId!==r,o=this.windowId!==s;this.windowId=s,this.sessionId=r,n||o?(this.stopRecording(),this.startIfEnabledOrStop("session_id_changed")):i&&this._scheduleFullSnapshot()}}_tryRRWebMethod(e){try{return e.rrwebMethod(),!0}catch(t){return this.queuedRRWebEvents.length<10?this.queuedRRWebEvents.push({enqueuedAt:e.enqueuedAt||Date.now(),attempt:e.attempt++,rrwebMethod:e.rrwebMethod}):as.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(us((()=>this.rrwebRecord.addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(us((()=>this.rrwebRecord.takeFullSnapshot())))}_onScriptLoaded(){var e,i,s,r,n={blockClass:"ph-no-capture",blockSelector:void 0,ignoreClass:"ph-ignore-input",maskTextClass:"ph-mask",maskTextSelector:void 0,maskTextFn:void 0,maskAllInputs:!0,maskInputOptions:{password:!0},maskInputFn:void 0,slimDOMOptions:{},collectFonts:!1,inlineStylesheet:!0,recordCrossOriginIframes:!1},o=this.instance.config.session_recording;for(var[a,l]of Object.entries(o||{}))a in n&&("maskInputOptions"===a?n.maskInputOptions=t({password:!0},l):n[a]=l);(this.canvasRecording&&this.canvasRecording.enabled&&(n.recordCanvas=!0,n.sampling={canvas:this.canvasRecording.fps},n.dataURLOptions={type:"image/webp",quality:this.canvasRecording.quality}),this.masking)&&(n.maskAllInputs=null===(i=this.masking.maskAllInputs)||void 0===i||i,n.maskTextSelector=null!==(s=this.masking.maskTextSelector)&&void 0!==s?s:void 0,n.blockSelector=null!==(r=this.masking.blockSelector)&&void 0!==r?r:void 0);if(this.rrwebRecord){this.mutationRateLimiter=null!==(e=this.mutationRateLimiter)&&void 0!==e?e:new yi(this.rrwebRecord,{refillRate:this.instance.config.session_recording.__mutationRateLimiterRefillRate,bucketSize:this.instance.config.session_recording.__mutationRateLimiterBucketSize,onBlockedNode:(e,t)=>{var i="Too many mutations on node '".concat(e,"'. Rate limiting. This could be due to SVG animations or something similar");as.info(i,{node:t}),this.log(os+" "+i,"warn")}});var c=this._gatherRRWebPlugins();this.stopRrweb=this.rrwebRecord(t({emit:e=>{this.onRRwebEmit(e)},plugins:c},n)),this._lastActivityTimestamp=Date.now(),this.isIdle=!1,this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:n,activePlugins:c.map((e=>null==e?void 0:e.name))}),this._tryAddCustomEvent("$posthog_config",{config:this.instance.config})}else as.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!this.isIdle){var e=this.fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}}_gatherRRWebPlugins(){var e,t,i,s,r=[],n=null===(e=f.__PosthogExtensions__)||void 0===e||null===(t=e.rrwebPlugins)||void 0===t?void 0:t.getRecordConsolePlugin;n&&this.isConsoleLogCaptureEnabled&&r.push(n());var o=null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.rrwebPlugins)||void 0===s?void 0:s.getRecordNetworkPlugin;this.networkPayloadCapture&&F(o)&&(!bt.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?r.push(o(mi(this.instance.config,this.networkPayloadCapture))):as.info("NetworkCapture not started because we are on localhost."));return r}onRRwebEmit(e){var i;if(this._processQueuedEvents(),e&&R(e)){if(e.type===li.Meta){var s=this._maskUrl(e.data.href);if(this._lastHref=s,!s)return;e.data.href=s}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),!this._urlBlocked||function(e){return e.type===li.Custom&&"recording paused"===e.data.tag}(e)){e.type===li.FullSnapshot&&this._scheduleFullSnapshot(),e.type===li.FullSnapshot&&"trigger_pending"===this.triggerStatus&&this.clearBuffer();var r=this.mutationRateLimiter?this.mutationRateLimiter.throttleMutations(e):e;if(r){var n=function(e){var t=e;if(t&&R(t)&&6===t.type&&R(t.data)&&"rrweb/console@1"===t.data.plugin){t.data.payload.payload.length>10&&(t.data.payload.payload=t.data.payload.payload.slice(0,10),t.data.payload.payload.push("...[truncated]"));for(var i=[],s=0;s<t.data.payload.payload.length;s++)t.data.payload.payload[s]&&t.data.payload.payload[s].length>2e3?i.push(t.data.payload.payload[s].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[s]);return t.data.payload.payload=i,e}return e}(r);if(this._updateWindowAndSessionIds(n),!this.isIdle||hs(n)){if(hs(n)){var o=n.data.payload;if(o){var a=o.lastActivityTimestamp,l=o.threshold;n.timestamp=a+l}}var c=null===(i=this.instance.config.session_recording.compress_events)||void 0===i||i?function(e){if(oi(e)<1024)return e;try{if(e.type===li.FullSnapshot)return t(t({},e),{},{data:ds(e.data),cv:"2024-10"});if(e.type===li.IncrementalSnapshot&&e.data.source===ci.Mutation)return t(t({},e),{},{cv:"2024-10",data:t(t({},e.data),{},{texts:ds(e.data.texts),attributes:ds(e.data.attributes),removes:ds(e.data.removes),adds:ds(e.data.adds)})});if(e.type===li.IncrementalSnapshot&&e.data.source===ci.StyleSheetRule)return t(t({},e),{},{cv:"2024-10",data:t(t({},e.data),{},{adds:e.data.adds?ds(e.data.adds):void 0,removes:e.data.removes?ds(e.data.removes):void 0})})}catch(e){as.error("could not compress event - will use uncompressed event",e)}return e}(n):n,u={$snapshot_bytes:oi(c),$snapshot_data:c,$session_id:this.sessionId,$window_id:this.windowId};"disabled"!==this.status?this._captureSnapshotBuffered(u):this.clearBuffer()}}}}}_pageViewFallBack(){if(!this.instance.config.capture_pageview&&n){var e=this._maskUrl(n.location.href);this._lastHref!==e&&(this._tryAddCustomEvent("$url_changed",{href:e}),this._lastHref=e)}}_processQueuedEvents(){if(this.queuedRRWebEvents.length){var e=[...this.queuedRRWebEvents];this.queuedRRWebEvents=[],e.forEach((e=>{Date.now()-e.enqueuedAt<=2e3&&this._tryRRWebMethod(e)}))}}_maskUrl(e){var t=this.instance.config.session_recording;if(t.maskNetworkRequestFn){var i,s={url:e};return null===(i=s=t.maskNetworkRequestFn(s))||void 0===i?void 0:i.url}return e}clearBuffer(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}_flushBuffer(){this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var e=this.minimumDuration,t=this.sessionDuration,i=D(t)&&t>=0,s=D(e)&&i&&t<e;if("buffering"===this.status||"paused"===this.status||"disabled"===this.status||s)return this.flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3),this.buffer;this.buffer.data.length>0&&ai(this.buffer).forEach((e=>{this._captureSnapshot({$snapshot_bytes:e.size,$snapshot_data:e.data,$session_id:e.sessionId,$window_id:e.windowId,$lib:"web",$lib_version:U.LIB_VERSION})}));return this.clearBuffer()}_captureSnapshotBuffered(e){var t,i=2+((null===(t=this.buffer)||void 0===t?void 0:t.data.length)||0);!this.isIdle&&(this.buffer.size+e.$snapshot_bytes+i>943718.4||this.buffer.sessionId!==this.sessionId)&&(this.buffer=this._flushBuffer()),this.buffer.size+=e.$snapshot_bytes,this.buffer.data.push(e.$snapshot_data),this.flushBufferTimer||this.isIdle||(this.flushBufferTimer=setTimeout((()=>{this._flushBuffer()}),2e3))}_captureSnapshot(e){this.instance.capture("$snapshot",e,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}_checkUrlTriggerConditions(){if(void 0!==n&&n.location.href){var e=n.location.href,t=this._urlBlocked,i=_s(e,this._urlBlocklist);i&&!t?this._pauseRecording():!i&&t&&this._resumeRecording(),_s(e,this._urlTriggers)&&this._activateTrigger("url")}}_activateTrigger(e){var t,i;"trigger_pending"===this.triggerStatus&&(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({["url"===e?xe:Ie]:this.sessionId}),this._flushBuffer(),this._reportStarted(e+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),as.info("recording paused due to URL blocker"),this._tryAddCustomEvent("recording paused",{reason:"url blocker"}))}_resumeRecording(){this._urlBlocked&&(this._urlBlocked=!1,this._tryTakeFullSnapshot(),this._scheduleFullSnapshot(),this._tryAddCustomEvent("recording resumed",{reason:"left blocked url"}),as.info("recording resumed"))}_addEventTriggerListener(){0!==this._eventTriggers.length&&L(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this.instance.on("eventCaptured",(e=>{try{this._eventTriggers.includes(e.event)&&this._activateTrigger("event")}catch(e){as.error("Could not activate event trigger",e)}})))}overrideLinkedFlag(){this._linkedFlagSeen=!0,this._tryTakeFullSnapshot(),this._reportStarted("linked_flag_overridden")}overrideSampling(){var e;null===(e=this.instance.persistence)||void 0===e||e.register({[Ee]:!0}),this._tryTakeFullSnapshot(),this._reportStarted("sampling_overridden")}overrideTrigger(e){this._activateTrigger(e)}_reportStarted(e,t){this.instance.register_for_session({$session_recording_start_reason:e}),as.info(e.replace("_"," "),t),w(["recording_initialized","session_id_changed"],e)||this._tryAddCustomEvent(e,t)}}var gs=W("[SegmentIntegration]");function vs(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var s=i=>{var s=()=>i.anonymousId()||Dt();e.config.get_device_id=s,i.id()&&(e.register({distinct_id:i.id(),$device_id:s()}),e.persistence.set_property(Oe,"identified")),t()},r=i.user();"then"in r&&F(r.then)?r.then((e=>s(e))):s(r)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||gs.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{var s;if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(gs.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(gs.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var r=e._calculate_event_properties(i,null!==(s=t.event.properties)&&void 0!==s?s:{},new Date);return t.event.properties=Object.assign({},r,t.event.properties),t};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:e=>t(e,e.event.event),page:e=>t(e,"$pageview"),identify:e=>t(e,"$identify"),screen:e=>t(e,"$screen")}})(e)).then((()=>{t()}))}))}var fs="posthog-js";function ms(e){var{organization:i,projectId:s,prefix:r,severityAllowList:n=["error"]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return o=>{var a,l,c,u,d;if(!("*"===n||n.includes(o.level))||!e.__loaded)return o;o.tags||(o.tags={});var h=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));o.tags["PostHog Person URL"]=h,e.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var _=(null===(a=o.exception)||void 0===a?void 0:a.values)||[],p=_.map((e=>t(t({},e),{},{stacktrace:e.stacktrace?t(t({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>t(t({},e),{},{platform:"web:javascript"})))}):void 0}))),g={$exception_message:(null===(l=_[0])||void 0===l?void 0:l.value)||o.message,$exception_type:null===(c=_[0])||void 0===c?void 0:c.type,$exception_personURL:h,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:(null===(u=_[0])||void 0===u?void 0:u.value)||o.message,$sentry_exception_type:null===(d=_[0])||void 0===d?void 0:d.type,$sentry_tags:o.tags};return i&&s&&(g.$sentry_url=(r||"https://sentry.io/organizations/")+i+"/issues/?project="+s+"&query="+o.event_id),e.exceptions.sendExceptionEvent(g),o}}class bs{constructor(e,t,i,s,r){this.name=fs,this.setupOnce=function(n){n(ms(e,{organization:t,projectId:i,prefix:s,severityAllowList:r}))}}}var ys,ws=null!=n&&n.location?Et(n.location.hash,"__posthog")||Et(location.hash,"state"):null,Ss="_postHogToolbarParams",ks=W("[Toolbar]");!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"}(ys||(ys={}));class Es{constructor(e){this.instance=e}setToolbarState(e){f.ph_toolbar_state=e}getToolbarState(){var e;return null!==(e=f.ph_toolbar_state)&&void 0!==e?e:ys.UNINITIALIZED}maybeLoadToolbar(){var e,t,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if(!n||!d)return!1;i=null!==(e=i)&&void 0!==e?e:n.location,r=null!==(t=r)&&void 0!==t?t:n.history;try{if(!s){try{n.localStorage.setItem("test","test"),n.localStorage.removeItem("test")}catch(e){return!1}s=null==n?void 0:n.localStorage}var o,a=ws||Et(i.hash,"__posthog")||Et(i.hash,"state"),l=a?Q((()=>JSON.parse(atob(decodeURIComponent(a)))))||Q((()=>JSON.parse(decodeURIComponent(a)))):null;return l&&"ph_authorize"===l.action?((o=l).source="url",o&&Object.keys(o).length>0&&(l.desiredHash?i.hash=l.desiredHash:r?r.replaceState(r.state,"",i.pathname+i.search):i.hash="")):((o=JSON.parse(s.getItem(Ss)||"{}")).source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token)&&(this.loadToolbar(o),!0)}catch(e){return!1}}_callLoadToolbar(e){var t=f.ph_load_toolbar||f.ph_load_editor;!L(t)&&F(t)?t(e,this.instance):ks.warn("No toolbar load function found")}loadToolbar(e){var i=!(null==d||!d.getElementById(He));if(!n||i)return!1;var s="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,r=t(t({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(n.localStorage.setItem(Ss,JSON.stringify(t(t({},r),{},{source:void 0}))),this.getToolbarState()===ys.LOADED)this._callLoadToolbar(r);else if(this.getToolbarState()===ys.UNINITIALIZED){var o,a;this.setToolbarState(ys.LOADING),null===(o=f.__PosthogExtensions__)||void 0===o||null===(a=o.loadExternalDependency)||void 0===a||a.call(o,this.instance,"toolbar",(e=>{if(e)return ks.error("[Toolbar] Failed to load",e),void this.setToolbarState(ys.UNINITIALIZED);this.setToolbarState(ys.LOADED),this._callLoadToolbar(r)})),ne(n,"turbolinks:load",(()=>{this.setToolbarState(ys.UNINITIALIZED),this.loadToolbar(r)}))}return!0}_loadEditor(e){return this.loadToolbar(e)}maybeLoadEditor(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;return this.maybeLoadToolbar(e,t,i)}}var xs=W("[TracingHeaders]");class Is{constructor(e){i(this,"_restoreXHRPatch",void 0),i(this,"_restoreFetchPatch",void 0),i(this,"_startCapturing",(()=>{var e,t,i,s;$(this._restoreXHRPatch)&&(null===(e=f.__PosthogExtensions__)||void 0===e||null===(t=e.tracingHeadersPatchFns)||void 0===t||t._patchXHR(this.instance.sessionManager));$(this._restoreFetchPatch)&&(null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.tracingHeadersPatchFns)||void 0===s||s._patchFetch(this.instance.sessionManager))})),this.instance=e}_loadScript(e){var t,i,s;null!==(t=f.__PosthogExtensions__)&&void 0!==t&&t.tracingHeadersPatchFns&&e(),null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"tracing-headers",(t=>{if(t)return xs.error("failed to load script",t);e()}))}startIfEnabledOrStop(){var e,t;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):(null===(e=this._restoreXHRPatch)||void 0===e||e.call(this),null===(t=this._restoreFetchPatch)||void 0===t||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}var Ps=W("[Web Vitals]"),Cs=9e5;class Fs{constructor(e){var s;i(this,"_enabledServerSide",!1),i(this,"_initialized",!1),i(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),i(this,"_flushToCapture",(()=>{clearTimeout(this._delayedFlushTimer),0!==this.buffer.metrics.length&&(this.instance.capture("$web_vitals",this.buffer.metrics.reduce(((e,i)=>t(t({},e),{},{["$web_vitals_".concat(i.name,"_event")]:t({},i),["$web_vitals_".concat(i.name,"_value")]:i.value})),{})),this.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})})),i(this,"_addToBuffer",(e=>{var i,s=null===(i=this.instance.sessionManager)||void 0===i?void 0:i.checkAndGetSessionAndWindowId(!0);if($(s))Ps.error("Could not read session ID. Dropping metrics!");else{this.buffer=this.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var r=this._currentURL();if(!$(r))if(L(null==e?void 0:e.name)||L(null==e?void 0:e.value))Ps.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)Ps.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this.buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),$(this.buffer.url)&&(this.buffer.url=r),this.buffer.firstMetricTimestamp=$(this.buffer.firstMetricTimestamp)?Date.now():this.buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this.buffer.metrics.push(t(t({},e),{},{$current_url:r,$session_id:s.sessionId,$window_id:s.windowId,timestamp:Date.now()})),this.buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}})),i(this,"_startCapturing",(()=>{var e,t,i,s,r=f.__PosthogExtensions__;$(r)||$(r.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:s}=r.postHogWebVitalsCallbacks),e&&t&&i&&s?(this.allowedMetrics.indexOf("LCP")>-1&&e(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&t(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&i(this._addToBuffer.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&s(this._addToBuffer.bind(this)),this._initialized=!0):Ps.error("web vitals callbacks not loaded - not starting")})),this.instance=e,this._enabledServerSide=!(null===(s=this.instance.persistence)||void 0===s||!s.props[he]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=R(this.instance.config.capture_performance)?null===(e=this.instance.config.capture_performance)||void 0===e?void 0:e.web_vitals_allowed_metrics:void 0;return $(i)?(null===(t=this.instance.persistence)||void 0===t?void 0:t.props[pe])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(R(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=R(this.instance.config.capture_performance)&&D(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:Cs;return 0<e&&e<=6e4?Cs:e}get isEnabled(){var e=R(this.instance.config.capture_performance)?this.instance.config.capture_performance.web_vitals:void 0;return q(e)?e:this._enabledServerSide}startIfEnabled(){this.isEnabled&&!this._initialized&&(Ps.info("enabled, starting..."),this.loadScript(this._startCapturing))}onRemoteConfig(e){var t=R(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=R(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this.instance.persistence&&(this.instance.persistence.register({[he]:t}),this.instance.persistence.register({[pe]:i})),this._enabledServerSide=t,this.startIfEnabled()}loadScript(e){var t,i,s;null!==(t=f.__PosthogExtensions__)&&void 0!==t&&t.postHogWebVitalsCallbacks&&e(),null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"web-vitals",(t=>{t?Ps.error("failed to load script",t):e()}))}_currentURL(){var e=n?n.location.href:void 0;return e||Ps.error("Could not determine current URL"),e}}var Rs=W("[Heatmaps]");function Ts(e){return R(e)&&"clientX"in e&&"clientY"in e&&D(e.clientX)&&D(e.clientY)}class $s{constructor(e){var t;i(this,"rageclicks",new mt),i(this,"_enabledServerSide",!1),i(this,"_initialized",!1),i(this,"_flushInterval",null),this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[ue])}get flushIntervalMilliseconds(){var e=5e3;return R(this.instance.config.capture_heatmaps)&&this.instance.config.capture_heatmaps.flush_interval_milliseconds&&(e=this.instance.config.capture_heatmaps.flush_interval_milliseconds),e}get isEnabled(){return $(this.instance.config.capture_heatmaps)?$(this.instance.config.enable_heatmaps)?this._enabledServerSide:this.instance.config.enable_heatmaps:!1!==this.instance.config.capture_heatmaps}startIfEnabled(){if(this.isEnabled){if(this._initialized)return;Rs.info("starting..."),this._setupListeners(),this._flushInterval=setInterval(this.flush.bind(this),this.flushIntervalMilliseconds)}else{var e,t;clearInterval(null!==(e=this._flushInterval)&&void 0!==e?e:void 0),null===(t=this.deadClicksCapture)||void 0===t||t.stop(),this.getAndClearBuffer()}}onRemoteConfig(e){var t=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ue]:t}),this._enabledServerSide=t,this.startIfEnabled()}getAndClearBuffer(){var e=this.buffer;return this.buffer=void 0,e}_onDeadClick(e){this._onClick(e.originalEvent,"deadclick")}_setupListeners(){n&&d&&(ne(n,"beforeunload",this.flush.bind(this)),ne(d,"click",(e=>this._onClick(e||(null==n?void 0:n.event))),{capture:!0}),ne(d,"mousemove",(e=>this._onMouseMove(e||(null==n?void 0:n.event))),{capture:!0}),this.deadClicksCapture=new si(this.instance,ti,this._onDeadClick.bind(this)),this.deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(e,t){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),o=function(e,t,i){for(var s=e;s&&We(s)&&!Ve(s,"body");){if(s===i)return!1;if(w(t,null==n?void 0:n.getComputedStyle(s).position))return!0;s=it(s)}return!1}(et(e),["fixed","sticky"],r);return{x:e.clientX+(o?0:s),y:e.clientY+(o?0:i),target_fixed:o,type:t}}_onClick(e){var i,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"click";if(!je(e.target)&&Ts(e)){var r=this._getProperties(e,s);null!==(i=this.rageclicks)&&void 0!==i&&i.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(t(t({},r),{},{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!je(e.target)&&Ts(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(n){var t=n.location.href;this.buffer=this.buffer||{},this.buffer[t]||(this.buffer[t]=[]),this.buffer[t].push(e)}}flush(){this.buffer&&!T(this.buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class As{constructor(e){this._instance=e}doPageView(e,t){var i,s=this._previousPageViewProperties(e,t);return this._currentPageview={pathname:null!==(i=null==n?void 0:n.location.pathname)&&void 0!==i?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),s}doPageLeave(e){var t;return this._previousPageViewProperties(e,null===(t=this._currentPageview)||void 0===t?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:null===(e=this._currentPageview)||void 0===e?void 0:e.pageViewId}}_previousPageViewProperties(e,t){var i=this._currentPageview;if(!i)return{$pageview_id:t};var s={$pageview_id:t,$prev_pageview_id:i.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:n,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=r;if(!($(n)||$(o)||$(a)||$(l)||$(c)||$(u))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);var d=n<=1?1:bi(o/n,0,1),h=n<=1?1:bi(a/n,0,1),_=l<=1?1:bi(c/l,0,1),p=l<=1?1:bi(u/l,0,1);s=Y(s,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:h,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:_,$prev_pageview_max_content:u,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(s.$prev_pageview_pathname=i.pathname),i.timestamp&&(s.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),s}}class Os{constructor(e){this.instance=e}sendExceptionEvent(e){this.instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}}var Ms,Ls=W("[FeatureFlags]"),Ds="$active_feature_flags",qs="$override_feature_flags",Ns="$feature_flag_payloads",Bs="$override_feature_flag_payloads",Hs="$feature_flag_request_id",Us=e=>{var t={};for(var[i,s]of X(e||{}))s&&(t[i]=s);return t};!function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"}(Ms||(Ms={}));class zs{constructor(e){i(this,"_override_warning",!1),i(this,"_hasLoadedFlags",!1),i(this,"_requestInFlight",!1),i(this,"_reloadingDisabled",!1),i(this,"_additionalReloadRequested",!1),i(this,"_decideCalled",!1),i(this,"_flagsLoadedFromRemote",!1),this.instance=e,this.featureFlagEventHandlers=[]}decide(){if(this.instance.config.__preview_remote_config)this._decideCalled=!0;else{var e=!this._reloadDebouncer&&(this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load);this._callDecideEndpoint({disableFlags:e})}}get hasLoadedFlags(){return this._hasLoadedFlags}getFlags(){return Object.keys(this.getFlagVariants())}getFlagVariants(){var e=this.instance.get_property(Pe),t=this.instance.get_property(qs);if(!t)return e||{};for(var i=Y({},e),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(Ls.warn(" Overriding feature flags!",{enabledFlags:e,overriddenFlags:t,finalFlags:i}),this._override_warning=!0),i}getFlagPayloads(){var e=this.instance.get_property(Ns),t=this.instance.get_property(Bs);if(!t)return e||{};for(var i=Y({},e||{}),s=Object.keys(t),r=0;r<s.length;r++)i[s[r]]=t[s[r]];return this._override_warning||(Ls.warn(" Overriding feature flag payloads!",{flagPayloads:e,overriddenPayloads:t,finalPayloads:i}),this._override_warning=!0),i}reloadFeatureFlags(){this._reloadingDisabled||this.instance.config.advanced_disable_feature_flags||this._reloadDebouncer||(this._reloadDebouncer=setTimeout((()=>{this._callDecideEndpoint()}),5))}clearDebouncer(){clearTimeout(this._reloadDebouncer),this._reloadDebouncer=void 0}ensureFlagsLoaded(){this._hasLoadedFlags||this._requestInFlight||this._reloadDebouncer||this.reloadFeatureFlags()}setAnonymousDistinctId(e){this.$anon_distinct_id=e}setReloadingPaused(e){this._reloadingDisabled=e}_callDecideEndpoint(e){var i;if(this.clearDebouncer(),!this.instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var s={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:t(t({},(null===(i=this.instance.persistence)||void 0===i?void 0:i.get_initial_props())||{}),this.instance.get_property(Fe)||{}),group_properties:this.instance.get_property(Re)};(null!=e&&e.disableFlags||this.instance.config.advanced_disable_feature_flags)&&(s.disable_flags=!0),this._requestInFlight=!0,this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:s,compression:this.instance.config.disable_compression?void 0:r.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,r,n=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),n=!1),this._requestInFlight=!1,this._decideCalled)||(this._decideCalled=!0,this.instance._onRemoteConfig(null!==(r=e.json)&&void 0!==r?r:{}));s.disable_flags&&!this._additionalReloadRequested||(this._flagsLoadedFromRemote=!n,e.json&&null!==(t=e.json.quotaLimited)&&void 0!==t&&t.includes(Ms.FeatureFlags)?Ls.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(this.receivedFeatureFlags(null!==(i=e.json)&&void 0!==i?i:{},n),this._additionalReloadRequested&&(this._additionalReloadRequested=!1,this._callDecideEndpoint())))}})}}getFeatureFlag(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0){var i,s,r,n,o,a=this.getFlagVariants()[e],l="".concat(a),c=this.instance.get_property(Hs)||void 0,u=this.instance.get_property(Ae)||{};if(t.send_event||!("send_event"in t))if(!(e in u)||!u[e].includes(l))C(u[e])?u[e].push(l):u[e]=[l],null===(i=this.instance.persistence)||void 0===i||i.register({[Ae]:u}),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:a,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:c,$feature_flag_bootstrapped_response:(null===(s=this.instance.config.bootstrap)||void 0===s||null===(r=s.featureFlags)||void 0===r?void 0:r[e])||null,$feature_flag_bootstrapped_payload:(null===(n=this.instance.config.bootstrap)||void 0===n||null===(o=n.featureFlagPayloads)||void 0===o?void 0:o[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote});return a}Ls.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(e,t){var i=this.instance.config.token;this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:{distinct_id:this.instance.get_distinct_id(),token:i},compression:this.instance.config.disable_compression?void 0:r.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:i=>{var s,r=null===(s=i.json)||void 0===s?void 0:s.featureFlagPayloads;t((null==r?void 0:r[e])||void 0)}})}isFeatureEnabled(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};if(this._hasLoadedFlags||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);Ls.warn('isFeatureEnabled for key "'+e+"\" failed. Feature flags didn't load in time.")}addFeatureFlagsHandler(e){this.featureFlagEventHandlers.push(e)}removeFeatureFlagsHandler(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((t=>t!==e))}receivedFeatureFlags(e,i){if(this.instance.persistence){this._hasLoadedFlags=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads();!function(e,i){var s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=e.featureFlags,o=e.featureFlagPayloads,a=e.requestId;if(n)if(C(n)){var l={};if(n)for(var c=0;c<n.length;c++)l[n[c]]=!0;i&&i.register({[Ds]:n,[Pe]:l})}else{var u=n,d=o;e.errorsWhileComputingFlags&&(u=t(t({},s),u),d=t(t({},r),d)),i&&i.register(t({[Ds]:Object.keys(Us(u)),[Pe]:u||{},[Ns]:d||{}},a?{[Hs]:a}:{}))}}(e,this.instance.persistence,s,r),this._fireFeatureFlagsCallbacks(i)}}override(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];Ls.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this.instance.__loaded||!this.instance.persistence)return Ls.uninitializedWarning("posthog.feature_flags.overrideFeatureFlags");if(!1===e)return this.instance.persistence.unregister(qs),this.instance.persistence.unregister(Bs),void this._fireFeatureFlagsCallbacks();if(e&&"object"==typeof e&&("flags"in e||"payloads"in e)){var t,i=e;if(this._override_warning=Boolean(null!==(t=i.suppressWarning)&&void 0!==t&&t),"flags"in i)if(!1===i.flags)this.instance.persistence.unregister(qs);else if(i.flags)if(C(i.flags)){for(var s={},r=0;r<i.flags.length;r++)s[i.flags[r]]=!0;this.instance.persistence.register({[qs]:s})}else this.instance.persistence.register({[qs]:i.flags});return"payloads"in i&&(!1===i.payloads?this.instance.persistence.unregister(Bs):i.payloads&&this.instance.persistence.register({[Bs]:i.payloads})),void this._fireFeatureFlagsCallbacks()}this._fireFeatureFlagsCallbacks()}onFeatureFlags(e){if(this.addFeatureFlagsHandler(e),this._hasLoadedFlags){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();e(t,i)}return()=>this.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,i){var s,r=(this.instance.get_property(Ce)||[]).find((t=>t.flagKey===e)),n={["$feature_enrollment/".concat(e)]:i},o={$feature_flag:e,$feature_enrollment:i,$set:n};r&&(o.$early_access_feature_name=r.name),this.instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=t(t({},this.getFlagVariants()),{},{[e]:i});null===(s=this.instance.persistence)||void 0===s||s.register({[Ds]:Object.keys(Us(a)),[Pe]:a}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0,s=this.instance.get_property(Ce),r=i?"&".concat(i.map((e=>"stage=".concat(e))).join("&")):"";if(s&&!t)return e(s);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token).concat(r)),method:"GET",callback:t=>{var i;if(t.json){var s=t.json.earlyAccessFeatures;return null===(i=this.instance.persistence)||void 0===i||i.register({[Ce]:s}),e(s)}}})}_prepareFeatureFlagsForCallbacks(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter((e=>t[e])),flagVariants:Object.keys(t).filter((e=>t[e])).reduce(((e,i)=>(e[i]=t[i],e)),{})}}_fireFeatureFlagsCallbacks(e){var{flags:t,flagVariants:i}=this._prepareFeatureFlagsForCallbacks();this.featureFlagEventHandlers.forEach((s=>s(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=this.instance.get_property(Fe)||{};this.instance.register({[Fe]:t(t({},s),e)}),i&&this.instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this.instance.unregister(Fe)}setGroupPropertiesForFlags(e){var i=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],s=this.instance.get_property(Re)||{};0!==Object.keys(s).length&&Object.keys(s).forEach((i=>{s[i]=t(t({},s[i]),e[i]),delete e[i]})),this.instance.register({[Re]:t(t({},s),e)}),i&&this.instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var i=this.instance.get_property(Re)||{};this.instance.register({[Re]:t(t({},i),{},{[e]:{}})})}else this.instance.unregister(Re)}}var js="Mobile",Ws="iOS",Vs="Android",Gs="Tablet",Js=Vs+" "+Gs,Ys="iPad",Ks="Apple",Xs=Ks+" Watch",Qs="Safari",Zs="BlackBerry",er="Samsung",tr=er+"Browser",ir=er+" Internet",sr="Chrome",rr=sr+" OS",nr=sr+" "+Ws,or="Internet Explorer",ar=or+" "+js,lr="Opera",cr=lr+" Mini",ur="Edge",dr="Microsoft "+ur,hr="Firefox",_r=hr+" "+Ws,pr="Nintendo",gr="PlayStation",vr="Xbox",fr=Vs+" "+js,mr=js+" "+Qs,br="Windows",yr=br+" Phone",wr="Nokia",Sr="Ouya",kr="Generic",Er=kr+" "+js.toLowerCase(),xr=kr+" "+Gs.toLowerCase(),Ir="Konqueror",Pr="(\\d+(\\.\\d+)?)",Cr=new RegExp("Version/"+Pr),Fr=new RegExp(vr,"i"),Rr=new RegExp(gr+" \\w+","i"),Tr=new RegExp(pr+" \\w+","i"),$r=new RegExp(Zs+"|PlayBook|BB10","i"),Ar={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"};var Or=(e,t)=>t&&w(t,Ks)||function(e){return w(e,Qs)&&!w(e,sr)&&!w(e,Vs)}(e),Mr=function(e,t){return t=t||"",w(e," OPR/")&&w(e,"Mini")?cr:w(e," OPR/")?lr:$r.test(e)?Zs:w(e,"IE"+js)||w(e,"WPDesktop")?ar:w(e,tr)?ir:w(e,ur)||w(e,"Edg/")?dr:w(e,"FBIOS")?"Facebook "+js:w(e,"UCWEB")||w(e,"UCBrowser")?"UC Browser":w(e,"CriOS")?nr:w(e,"CrMo")||w(e,sr)?sr:w(e,Vs)&&w(e,Qs)?fr:w(e,"FxiOS")?_r:w(e.toLowerCase(),Ir.toLowerCase())?Ir:Or(e,t)?w(e,js)?mr:Qs:w(e,hr)?hr:w(e,"MSIE")||w(e,"Trident/")?or:w(e,"Gecko")?hr:""},Lr={[ar]:[new RegExp("rv:"+Pr)],[dr]:[new RegExp(ur+"?\\/"+Pr)],[sr]:[new RegExp("("+sr+"|CrMo)\\/"+Pr)],[nr]:[new RegExp("CriOS\\/"+Pr)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Pr)],[Qs]:[Cr],[mr]:[Cr],[lr]:[new RegExp("(Opera|OPR)\\/"+Pr)],[hr]:[new RegExp(hr+"\\/"+Pr)],[_r]:[new RegExp("FxiOS\\/"+Pr)],[Ir]:[new RegExp("Konqueror[:/]?"+Pr,"i")],[Zs]:[new RegExp(Zs+" "+Pr),Cr],[fr]:[new RegExp("android\\s"+Pr,"i")],[ir]:[new RegExp(tr+"\\/"+Pr)],[or]:[new RegExp("(rv:|MSIE )"+Pr)],Mozilla:[new RegExp("rv:"+Pr)]},Dr=[[new RegExp(vr+"; "+vr+" (.*?)[);]","i"),e=>[vr,e&&e[1]||""]],[new RegExp(pr,"i"),[pr,""]],[new RegExp(gr,"i"),[gr,""]],[$r,[Zs,""]],[new RegExp(br,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[yr,""];if(new RegExp(js).test(t)&&!/IEMobile\b/.test(t))return[br+" "+js,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var s=i[1],r=Ar[s]||"";return/arm/i.test(t)&&(r="RT"),[br,r]}return[br,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[Ws,t.join(".")]}return[Ws,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=$(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+Vs+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Vs+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[Vs,t.join(".")]}return[Vs,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,e=>{var t=["Mac OS X",""];if(e&&e[1]){var i=[e[1],e[2],e[3]||"0"];t[1]=i.join(".")}return t}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[rr,""]],[/Linux|debian/i,["Linux",""]]],qr=function(e){return Tr.test(e)?pr:Rr.test(e)?gr:Fr.test(e)?vr:new RegExp(Sr,"i").test(e)?Sr:new RegExp("("+yr+"|WPDesktop)","i").test(e)?yr:/iPad/.test(e)?Ys:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?Xs:$r.test(e)?Zs:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(wr,"i").test(e)?wr:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(e)||/(kf[a-z]+)( bui|\)).+silk\//i.test(e)?"Kindle Fire":/(Android|ZTE)/i.test(e)?!new RegExp(js).test(e)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(e)?/pixel[\daxl ]{1,6}/i.test(e)&&!/pixel c/i.test(e)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(e)||/lmy47v/i.test(e)&&!/QTAQZ3/i.test(e)?Vs:Js:Vs:new RegExp("(pda|"+js+")","i").test(e)?Er:new RegExp(Gs,"i").test(e)&&!new RegExp(Gs+" pc","i").test(e)?xr:""},Nr="https?://(.*)",Br=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","irclid","_kx"],Hr=K(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],Br),Ur="<masked>",zr={campaignParams:function(){var{customTrackedParams:e,maskPersonalDataProperties:t,customPersonalDataProperties:i}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!d)return{};var s=t?K([],Br,i||[]):[];return this._campaignParamsFromUrl(kt(d.URL,s,Ur),e)},_campaignParamsFromUrl:function(e,t){var i=Hr.concat(t||[]),s={};return J(i,(function(t){var i=St(e,t);s[t]=i||null})),s},_searchEngine:function(e){return e?0===e.search(Nr+"google.([^/?]*)")?"google":0===e.search(Nr+"bing.com")?"bing":0===e.search(Nr+"yahoo.com")?"yahoo":0===e.search(Nr+"duckduckgo.com")?"duckduckgo":null:null},_searchInfoFromReferrer:function(e){var t=zr._searchEngine(e),i="yahoo"!=t?"q":"p",s={};if(!M(t)){s.$search_engine=t;var r=d?St(d.referrer,i):"";r.length&&(s.ph_keyword=r)}return s},searchInfo:function(){var e=null==d?void 0:d.referrer;return e?this._searchInfoFromReferrer(e):{}},browser:Mr,browserVersion:function(e,t){var i=Mr(e,t),s=Lr[i];if($(s))return null;for(var r=0;r<s.length;r++){var n=s[r],o=e.match(n);if(o)return parseFloat(o[o.length-2])}return null},browserLanguage:function(){return navigator.language||navigator.userLanguage},browserLanguagePrefix:function(){var e=this.browserLanguage();return"string"==typeof e?e.split("-")[0]:void 0},os:function(e){for(var t=0;t<Dr.length;t++){var[i,s]=Dr[t],r=i.exec(e),n=r&&(F(s)?s(r,e):s);if(n)return n}return["",""]},device:qr,deviceType:function(e){var t=qr(e);return t===Ys||t===Js||"Kobo"===t||"Kindle Fire"===t||t===xr?Gs:t===pr||t===vr||t===gr||t===Sr?"Console":t===Xs?"Wearable":t?js:"Desktop"},referrer:function(){return(null==d?void 0:d.referrer)||"$direct"},referringDomain:function(){var e;return null!=d&&d.referrer&&(null===(e=yt(d.referrer))||void 0===e?void 0:e.host)||"$direct"},referrerInfo:function(){return{$referrer:this.referrer(),$referring_domain:this.referringDomain()}},personInfo:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},i=e?K([],Br,t||[]):[],s=null==h?void 0:h.href.substring(0,1e3);return{r:this.referrer().substring(0,1e3),u:s?kt(s,i,Ur):void 0}},personPropsFromInfo:function(e){var t,{r:i,u:s}=e,r={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null===(t=yt(i))||void 0===t?void 0:t.host};if(s){r.$current_url=s;var n=yt(s);r.$host=null==n?void 0:n.host,r.$pathname=null==n?void 0:n.pathname;var o=this._campaignParamsFromUrl(s);Y(r,o)}if(i){var a=this._searchInfoFromReferrer(i);Y(r,a)}return r},initialPersonPropsFromInfo:function(e){var t=this.personPropsFromInfo(e),i={};return J(t,(function(e,t){i["$initial_".concat(k(t))]=e})),i},timezone:function(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}},timezoneOffset:function(){try{return(new Date).getTimezoneOffset()}catch(e){return}},properties:function(){var{maskPersonalDataProperties:e,customPersonalDataProperties:t}=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!v)return{};var i=e?K([],Br,t||[]):[],[s,r]=zr.os(v);return Y(ee({$os:s,$os_version:r,$browser:zr.browser(v,navigator.vendor),$device:zr.device(v),$device_type:zr.deviceType(v),$timezone:zr.timezone(),$timezone_offset:zr.timezoneOffset()}),{$current_url:kt(null==h?void 0:h.href,i,Ur),$host:null==h?void 0:h.host,$pathname:null==h?void 0:h.pathname,$raw_user_agent:v.length>1e3?v.substring(0,997)+"...":v,$browser_version:zr.browserVersion(v,navigator.vendor),$browser_language:zr.browserLanguage(),$browser_language_prefix:zr.browserLanguagePrefix(),$screen_height:null==n?void 0:n.screen.height,$screen_width:null==n?void 0:n.screen.width,$viewport_height:null==n?void 0:n.innerHeight,$viewport_width:null==n?void 0:n.innerWidth,$lib:"web",$lib_version:U.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})},people_properties:function(){if(!v)return{};var[e,t]=zr.os(v);return Y(ee({$os:e,$os_version:t,$browser:zr.browser(v,navigator.vendor)}),{$browser_version:zr.browserVersion(v,navigator.vendor)})}},jr=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Wr{constructor(e){this.config=e,this.props={},this.campaign_params_saved=!1,this.name=(e=>{var t="";return e.token&&(t=e.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),e.persistence_name?"ph_"+e.persistence_name:"ph_"+t+"_posthog"})(e),this.storage=this.buildStorage(e),this.load(),e.debug&&j.info("Persistence loaded",e.persistence,t({},this.props)),this.update_config(e,e),this.save()}buildStorage(e){-1===jr.indexOf(e.persistence.toLowerCase())&&(j.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Vt.is_supported()?Vt:"localstorage+cookie"===t&&Jt.is_supported()?Jt:"sessionstorage"===t&&Qt.is_supported()?Qt:"memory"===t?Kt:"cookie"===t?jt:Jt.is_supported()?Jt:jt}properties(){var e={};return J(this.props,(function(t,i){if(i===Pe&&R(t))for(var s=Object.keys(t),r=0;r<s.length;r++)e["$feature/".concat(s[r])]=t[s[r]];else o=i,a=!1,(M(n=ze)?a:c&&n.indexOf===c?-1!=n.indexOf(o):(J(n,(function(e){if(a||(a=e===o))return V})),a))||(e[i]=t);var n,o,a})),e}load(){if(!this.disabled){var e=this.storage.parse(this.name);e&&(this.props=Y({},e))}}save(){this.disabled||this.storage.set(this.name,this.props,this.expire_days,this.cross_subdomain,this.secure,this.config.debug)}remove(){this.storage.remove(this.name,!1),this.storage.remove(this.name,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(R(e)){$(t)&&(t="None"),this.expire_days=$(i)?this.default_expiry:i;var s=!1;if(J(e,((e,i)=>{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,s=!0)})),s)return this.save(),!0}return!1}register(e,t){if(R(e)){this.expire_days=$(t)?this.default_expiry:t;var i=!1;if(J(e,((t,s)=>{e.hasOwnProperty(s)&&this.props[s]!==t&&(this.props[s]=t,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.campaign_params_saved){var e=zr.campaignParams({customTrackedParams:this.config.custom_campaign_params,maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});T(ee(e))||this.register(e),this.campaign_params_saved=!0}}update_search_keyword(){this.register(zr.searchInfo())}update_referrer_info(){this.register_once(zr.referrerInfo(),void 0)}set_initial_person_info(){this.props[De]||this.props[qe]||this.register_once({[Ne]:zr.personInfo({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties})},void 0)}get_referrer_info(){return ee({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var e={};J([qe,De],(t=>{var i=this.props[t];i&&J(i,(function(t,i){e["$initial_"+k(i)]=t}))}));var t=this.props[Ne];if(t){var i=zr.initialPersonPropsFromInfo(t);Y(e,i)}return e}safe_merge(e){return J(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t){if(this.default_expiry=this.expire_days=e.cookie_expiration,this.set_disabled(e.disable_persistence),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence){var i=this.buildStorage(e),s=this.props;this.clear(),this.storage=i,this.props=s,this.save()}}set_disabled(e){this.disabled=e,this.disabled?this.remove():this.save()}set_cross_subdomain(e){e!==this.cross_subdomain&&(this.cross_subdomain=e,this.remove(),this.save())}get_cross_subdomain(){return!!this.cross_subdomain}set_secure(e){e!==this.secure&&(this.secure=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[le]||{};i[e]=t,this.props[le]=i,this.save()}remove_event_timer(e){var t=(this.props[le]||{})[e];return $(t)||(delete this.props[le][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var Vr,Gr,Jr,Yr,Kr,Xr,Qr,Zr,en,tn,sn,rn,nn={},on=[],an=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,ln=Array.isArray;function cn(e,t){for(var i in t)e[i]=t[i];return e}function un(e){var t=e.parentNode;t&&t.removeChild(e)}function dn(e,t,i,s,r){var n={type:e,props:t,key:i,ref:s,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==r?++Jr:r,__i:-1,__u:0};return null==r&&null!=Gr.vnode&&Gr.vnode(n),n}function hn(e){return e.children}function _n(e,t){this.props=e,this.context=t}function pn(e,t){if(null==t)return e.__?pn(e.__,e.__i+1):null;for(var i;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e)return i.__e;return"function"==typeof e.type?pn(e):null}function gn(e){var t,i;if(null!=(e=e.__)&&null!=e.__c){for(e.__e=e.__c.base=null,t=0;t<e.__k.length;t++)if(null!=(i=e.__k[t])&&null!=i.__e){e.__e=e.__c.base=i.__e;break}return gn(e)}}function vn(e){(!e.__d&&(e.__d=!0)&&Yr.push(e)&&!fn.__r++||Kr!==Gr.debounceRendering)&&((Kr=Gr.debounceRendering)||Xr)(fn)}function fn(){var e,t,i,s,r,n,o,a,l;for(Yr.sort(Qr);e=Yr.shift();)e.__d&&(t=Yr.length,s=void 0,n=(r=(i=e).__v).__e,a=[],l=[],(o=i.__P)&&((s=cn({},r)).__v=r.__v+1,Gr.vnode&&Gr.vnode(s),In(o,s,r,i.__n,void 0!==o.ownerSVGElement,32&r.__u?[n]:null,a,null==n?pn(r):n,!!(32&r.__u),l),s.__.__k[s.__i]=s,Pn(a,s,l),s.__e!=n&&gn(s)),Yr.length>t&&Yr.sort(Qr));fn.__r=0}function mn(e,t,i,s,r,n,o,a,l,c,u){var d,h,_,p,g,v=s&&s.__k||on,f=t.length;for(i.__d=l,bn(i,t,v),l=i.__d,d=0;d<f;d++)null!=(_=i.__k[d])&&"boolean"!=typeof _&&"function"!=typeof _&&(h=-1===_.__i?nn:v[_.__i]||nn,_.__i=d,In(e,_,h,r,n,o,a,l,c,u),p=_.__e,_.ref&&h.ref!=_.ref&&(h.ref&&Fn(h.ref,null,_),u.push(_.ref,_.__c||p,_)),null==g&&null!=p&&(g=p),65536&_.__u||h.__k===_.__k?l=yn(_,l,e):"function"==typeof _.type&&void 0!==_.__d?l=_.__d:p&&(l=p.nextSibling),_.__d=void 0,_.__u&=-196609);i.__d=l,i.__e=g}function bn(e,t,i){var s,r,n,o,a,l=t.length,c=i.length,u=c,d=0;for(e.__k=[],s=0;s<l;s++)null!=(r=e.__k[s]=null==(r=t[s])||"boolean"==typeof r||"function"==typeof r?null:"string"==typeof r||"number"==typeof r||"bigint"==typeof r||r.constructor==String?dn(null,r,null,null,r):ln(r)?dn(hn,{children:r},null,null,null):void 0===r.constructor&&r.__b>0?dn(r.type,r.props,r.key,r.ref?r.ref:null,r.__v):r)?(r.__=e,r.__b=e.__b+1,a=wn(r,i,o=s+d,u),r.__i=a,n=null,-1!==a&&(u--,(n=i[a])&&(n.__u|=131072)),null==n||null===n.__v?(-1==a&&d--,"function"!=typeof r.type&&(r.__u|=65536)):a!==o&&(a===o+1?d++:a>o?u>l-o?d+=a-o:d--:d=a<o&&a==o-1?a-o:0,a!==s+d&&(r.__u|=65536))):(n=i[s])&&null==n.key&&n.__e&&(n.__e==e.__d&&(e.__d=pn(n)),Rn(n,n,!1),i[s]=null,u--);if(u)for(s=0;s<c;s++)null!=(n=i[s])&&0==(131072&n.__u)&&(n.__e==e.__d&&(e.__d=pn(n)),Rn(n,n))}function yn(e,t,i){var s,r;if("function"==typeof e.type){for(s=e.__k,r=0;s&&r<s.length;r++)s[r]&&(s[r].__=e,t=yn(s[r],t,i));return t}return e.__e!=t&&(i.insertBefore(e.__e,t||null),t=e.__e),t&&t.nextSibling}function wn(e,t,i,s){var r=e.key,n=e.type,o=i-1,a=i+1,l=t[i];if(null===l||l&&r==l.key&&n===l.type)return i;if(s>(null!=l&&0==(131072&l.__u)?1:0))for(;o>=0||a<t.length;){if(o>=0){if((l=t[o])&&0==(131072&l.__u)&&r==l.key&&n===l.type)return o;o--}if(a<t.length){if((l=t[a])&&0==(131072&l.__u)&&r==l.key&&n===l.type)return a;a++}}return-1}function Sn(e,t,i){"-"===t[0]?e.setProperty(t,null==i?"":i):e[t]=null==i?"":"number"!=typeof i||an.test(t)?i:i+"px"}function kn(e,t,i,s,r){var n;e:if("style"===t)if("string"==typeof i)e.style.cssText=i;else{if("string"==typeof s&&(e.style.cssText=s=""),s)for(t in s)i&&t in i||Sn(e.style,t,"");if(i)for(t in i)s&&i[t]===s[t]||Sn(e.style,t,i[t])}else if("o"===t[0]&&"n"===t[1])n=t!==(t=t.replace(/(PointerCapture)$|Capture$/,"$1")),t=t.toLowerCase()in e?t.toLowerCase().slice(2):t.slice(2),e.l||(e.l={}),e.l[t+n]=i,i?s?i.u=s.u:(i.u=Date.now(),e.addEventListener(t,n?xn:En,n)):e.removeEventListener(t,n?xn:En,n);else{if(r)t=t.replace(/xlink(H|:h)/,"h").replace(/sName$/,"s");else if("width"!==t&&"height"!==t&&"href"!==t&&"list"!==t&&"form"!==t&&"tabIndex"!==t&&"download"!==t&&"rowSpan"!==t&&"colSpan"!==t&&"role"!==t&&t in e)try{e[t]=null==i?"":i;break e}catch(e){}"function"==typeof i||(null==i||!1===i&&"-"!==t[4]?e.removeAttribute(t):e.setAttribute(t,i))}}function En(e){var t=this.l[e.type+!1];if(e.t){if(e.t<=t.u)return}else e.t=Date.now();return t(Gr.event?Gr.event(e):e)}function xn(e){return this.l[e.type+!0](Gr.event?Gr.event(e):e)}function In(e,t,i,s,r,n,o,a,l,c){var u,d,h,_,p,g,v,f,m,b,y,w,S,k,E,x=t.type;if(void 0!==t.constructor)return null;128&i.__u&&(l=!!(32&i.__u),n=[a=t.__e=i.__e]),(u=Gr.__b)&&u(t);e:if("function"==typeof x)try{if(f=t.props,m=(u=x.contextType)&&s[u.__c],b=u?m?m.props.value:u.__:s,i.__c?v=(d=t.__c=i.__c).__=d.__E:("prototype"in x&&x.prototype.render?t.__c=d=new x(f,b):(t.__c=d=new _n(f,b),d.constructor=x,d.render=Tn),m&&m.sub(d),d.props=f,d.state||(d.state={}),d.context=b,d.__n=s,h=d.__d=!0,d.__h=[],d._sb=[]),null==d.__s&&(d.__s=d.state),null!=x.getDerivedStateFromProps&&(d.__s==d.state&&(d.__s=cn({},d.__s)),cn(d.__s,x.getDerivedStateFromProps(f,d.__s))),_=d.props,p=d.state,d.__v=t,h)null==x.getDerivedStateFromProps&&null!=d.componentWillMount&&d.componentWillMount(),null!=d.componentDidMount&&d.__h.push(d.componentDidMount);else{if(null==x.getDerivedStateFromProps&&f!==_&&null!=d.componentWillReceiveProps&&d.componentWillReceiveProps(f,b),!d.__e&&(null!=d.shouldComponentUpdate&&!1===d.shouldComponentUpdate(f,d.__s,b)||t.__v===i.__v)){for(t.__v!==i.__v&&(d.props=f,d.state=d.__s,d.__d=!1),t.__e=i.__e,t.__k=i.__k,t.__k.forEach((function(e){e&&(e.__=t)})),y=0;y<d._sb.length;y++)d.__h.push(d._sb[y]);d._sb=[],d.__h.length&&o.push(d);break e}null!=d.componentWillUpdate&&d.componentWillUpdate(f,d.__s,b),null!=d.componentDidUpdate&&d.__h.push((function(){d.componentDidUpdate(_,p,g)}))}if(d.context=b,d.props=f,d.__P=e,d.__e=!1,w=Gr.__r,S=0,"prototype"in x&&x.prototype.render){for(d.state=d.__s,d.__d=!1,w&&w(t),u=d.render(d.props,d.state,d.context),k=0;k<d._sb.length;k++)d.__h.push(d._sb[k]);d._sb=[]}else do{d.__d=!1,w&&w(t),u=d.render(d.props,d.state,d.context),d.state=d.__s}while(d.__d&&++S<25);d.state=d.__s,null!=d.getChildContext&&(s=cn(cn({},s),d.getChildContext())),h||null==d.getSnapshotBeforeUpdate||(g=d.getSnapshotBeforeUpdate(_,p)),mn(e,ln(E=null!=u&&u.type===hn&&null==u.key?u.props.children:u)?E:[E],t,i,s,r,n,o,a,l,c),d.base=t.__e,t.__u&=-161,d.__h.length&&o.push(d),v&&(d.__E=d.__=null)}catch(e){t.__v=null,l||null!=n?(t.__e=a,t.__u|=l?160:32,n[n.indexOf(a)]=null):(t.__e=i.__e,t.__k=i.__k),Gr.__e(e,t,i)}else null==n&&t.__v===i.__v?(t.__k=i.__k,t.__e=i.__e):t.__e=Cn(i.__e,t,i,s,r,n,o,l,c);(u=Gr.diffed)&&u(t)}function Pn(e,t,i){t.__d=void 0;for(var s=0;s<i.length;s++)Fn(i[s],i[++s],i[++s]);Gr.__c&&Gr.__c(t,e),e.some((function(t){try{e=t.__h,t.__h=[],e.some((function(e){e.call(t)}))}catch(e){Gr.__e(e,t.__v)}}))}function Cn(e,t,i,s,r,n,o,a,l){var c,u,d,h,_,p,g,v=i.props,f=t.props,m=t.type;if("svg"===m&&(r=!0),null!=n)for(c=0;c<n.length;c++)if((_=n[c])&&"setAttribute"in _==!!m&&(m?_.localName===m:3===_.nodeType)){e=_,n[c]=null;break}if(null==e){if(null===m)return document.createTextNode(f);e=r?document.createElementNS("http://www.w3.org/2000/svg",m):document.createElement(m,f.is&&f),n=null,a=!1}if(null===m)v===f||a&&e.data===f||(e.data=f);else{if(n=n&&Vr.call(e.childNodes),v=i.props||nn,!a&&null!=n)for(v={},c=0;c<e.attributes.length;c++)v[(_=e.attributes[c]).name]=_.value;for(c in v)_=v[c],"children"==c||("dangerouslySetInnerHTML"==c?d=_:"key"===c||c in f||kn(e,c,null,_,r));for(c in f)_=f[c],"children"==c?h=_:"dangerouslySetInnerHTML"==c?u=_:"value"==c?p=_:"checked"==c?g=_:"key"===c||a&&"function"!=typeof _||v[c]===_||kn(e,c,_,v[c],r);if(u)a||d&&(u.__html===d.__html||u.__html===e.innerHTML)||(e.innerHTML=u.__html),t.__k=[];else if(d&&(e.innerHTML=""),mn(e,ln(h)?h:[h],t,i,s,r&&"foreignObject"!==m,n,o,n?n[0]:i.__k&&pn(i,0),a,l),null!=n)for(c=n.length;c--;)null!=n[c]&&un(n[c]);a||(c="value",void 0!==p&&(p!==e[c]||"progress"===m&&!p||"option"===m&&p!==v[c])&&kn(e,c,p,v[c],!1),c="checked",void 0!==g&&g!==e[c]&&kn(e,c,g,v[c],!1))}return e}function Fn(e,t,i){try{"function"==typeof e?e(t):e.current=t}catch(e){Gr.__e(e,i)}}function Rn(e,t,i){var s,r;if(Gr.unmount&&Gr.unmount(e),(s=e.ref)&&(s.current&&s.current!==e.__e||Fn(s,null,t)),null!=(s=e.__c)){if(s.componentWillUnmount)try{s.componentWillUnmount()}catch(e){Gr.__e(e,t)}s.base=s.__P=null,e.__c=void 0}if(s=e.__k)for(r=0;r<s.length;r++)s[r]&&Rn(s[r],t,i||"function"!=typeof e.type);i||null==e.__e||un(e.__e),e.__=e.__e=e.__d=void 0}function Tn(e,t,i){return this.constructor(e,i)}Vr=on.slice,Gr={__e:function(e,t,i,s){for(var r,n,o;t=t.__;)if((r=t.__c)&&!r.__)try{if((n=r.constructor)&&null!=n.getDerivedStateFromError&&(r.setState(n.getDerivedStateFromError(e)),o=r.__d),null!=r.componentDidCatch&&(r.componentDidCatch(e,s||{}),o=r.__d),o)return r.__E=r}catch(t){e=t}throw e}},Jr=0,_n.prototype.setState=function(e,t){var i;i=null!=this.__s&&this.__s!==this.state?this.__s:this.__s=cn({},this.state),"function"==typeof e&&(e=e(cn({},i),this.props)),e&&cn(i,e),null!=e&&this.__v&&(t&&this._sb.push(t),vn(this))},_n.prototype.forceUpdate=function(e){this.__v&&(this.__e=!0,e&&this.__h.push(e),vn(this))},_n.prototype.render=hn,Yr=[],Xr="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,Qr=function(e,t){return e.__v.__b-t.__v.__b},fn.__r=0,Zr=0,function(e){e.Popover="popover",e.API="api",e.Widget="widget"}(en||(en={})),function(e){e.Open="open",e.MultipleChoice="multiple_choice",e.SingleChoice="single_choice",e.Rating="rating",e.Link="link"}(tn||(tn={})),function(e){e.NextQuestion="next_question",e.End="end",e.ResponseBased="response_based",e.SpecificQuestion="specific_question"}(sn||(sn={})),function(e){e.Once="once",e.Recurring="recurring",e.Always="always"}(rn||(rn={}));!function(e,t){var i={__c:t="__cC"+Zr++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var i,s;return this.getChildContext||(i=[],(s={})[t]=this,this.getChildContext=function(){return s},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&i.some((function(e){e.__e=!0,vn(e)}))},this.sub=function(e){i.push(e);var t=e.componentWillUnmount;e.componentWillUnmount=function(){i.splice(i.indexOf(e),1),t&&t.call(e)}}),e.children}};i.Provider.__=i.Consumer.contextType=i}({isPreviewMode:!1,previewPageIndex:0,onPopupSurveyDismissed:()=>{},isPopup:!0,onPreviewSubmit:()=>{},onPopupSurveySent:()=>{}});var $n=function(e,t){if(!function(e){try{new RegExp(e)}catch(e){return!1}return!0}(t))return!1;try{return new RegExp(t).test(e)}catch(e){return!1}};class An{constructor(){i(this,"events",{}),this.events={}}on(e,t){return this.events[e]||(this.events[e]=[]),this.events[e].push(t),()=>{this.events[e]=this.events[e].filter((e=>e!==t))}}emit(e,t){for(var i of this.events[e]||[])i(t);for(var s of this.events["*"]||[])s(e,t)}}class On{constructor(e){i(this,"_debugEventEmitter",new An),i(this,"checkStep",((e,t)=>this.checkStepEvent(e,t)&&this.checkStepUrl(e,t)&&this.checkStepElement(e,t))),i(this,"checkStepEvent",((e,t)=>null==t||!t.event||(null==e?void 0:e.event)===(null==t?void 0:t.event))),this.instance=e,this.actionEvents=new Set,this.actionRegistry=new Set}init(){var e;if(!$(null===(e=this.instance)||void 0===e?void 0:e._addCaptureHook)){var t;null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.on(e,t)}))}}register(e){var t,i;if(!$(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)&&(e.forEach((e=>{var t,i;null===(t=this.actionRegistry)||void 0===t||t.add(e),null===(i=e.steps)||void 0===i||i.forEach((e=>{var t;null===(t=this.actionEvents)||void 0===t||t.add((null==e?void 0:e.event)||"")}))})),null!==(i=this.instance)&&void 0!==i&&i.autocapture)){var s,r=new Set;e.forEach((e=>{var t;null===(t=e.steps)||void 0===t||t.forEach((e=>{null!=e&&e.selector&&r.add(null==e?void 0:e.selector)}))})),null===(s=this.instance)||void 0===s||s.autocapture.setElementSelectors(r)}}on(e,t){var i;null!=t&&0!=e.length&&(this.actionEvents.has(e)||this.actionEvents.has(null==t?void 0:t.event))&&this.actionRegistry&&(null===(i=this.actionRegistry)||void 0===i?void 0:i.size)>0&&this.actionRegistry.forEach((e=>{this.checkAction(t,e)&&this._debugEventEmitter.emit("actionCaptured",e.name)}))}_addActionHook(e){this.onAction("actionCaptured",(t=>e(t)))}checkAction(e,t){if(null==(null==t?void 0:t.steps))return!1;for(var i of t.steps)if(this.checkStep(e,i))return!0;return!1}onAction(e,t){return this._debugEventEmitter.on(e,t)}checkStepUrl(e,t){if(null!=t&&t.url){var i,s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!s||"string"!=typeof s)return!1;if(!On.matchString(s,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static matchString(e,t,i){switch(i){case"regex":return!!n&&$n(e,t);case"exact":return t===e;case"contains":var s=On.escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return $n(e,s);default:return!1}}static escapeStringRegexp(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}checkStepElement(e,t){if((null!=t&&t.href||null!=t&&t.tag_name||null!=t&&t.text)&&!this.getElementsList(e).some((e=>!(null!=t&&t.href&&!On.matchString(e.href||"",null==t?void 0:t.href,(null==t?void 0:t.href_matching)||"exact"))&&((null==t||!t.tag_name||e.tag_name===(null==t?void 0:t.tag_name))&&!(null!=t&&t.text&&!On.matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!On.matchString(e.$el_text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact"))))))return!1;if(null!=t&&t.selector){var i,s=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(!s)return!1;if(!s.includes(null==t?void 0:t.selector))return!1}return!0}getElementsList(e){return null==(null==e?void 0:e.properties.$elements)?[]:null==e?void 0:e.properties.$elements}}class Mn{constructor(e){this.instance=e,this.eventToSurveys=new Map,this.actionToSurveys=new Map}register(e){var t;$(null===(t=this.instance)||void 0===t?void 0:t._addCaptureHook)||(this.setupEventBasedSurveys(e),this.setupActionBasedSurveys(e))}setupActionBasedSurveys(e){var t=e.filter((e=>{var t,i,s,r;return(null===(t=e.conditions)||void 0===t?void 0:t.actions)&&(null===(i=e.conditions)||void 0===i||null===(s=i.actions)||void 0===s||null===(r=s.values)||void 0===r?void 0:r.length)>0}));if(0!==t.length){if(null==this.actionMatcher){this.actionMatcher=new On(this.instance),this.actionMatcher.init();this.actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,s,r,n,o,a,l,c,u;e.conditions&&null!==(t=e.conditions)&&void 0!==t&&t.actions&&null!==(i=e.conditions)&&void 0!==i&&null!==(s=i.actions)&&void 0!==s&&s.values&&(null===(r=e.conditions)||void 0===r||null===(n=r.actions)||void 0===n||null===(o=n.values)||void 0===o?void 0:o.length)>0&&(null===(a=this.actionMatcher)||void 0===a||a.register(e.conditions.actions.values),null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c||null===(u=c.values)||void 0===u||u.forEach((t=>{if(t&&t.name){var i=this.actionToSurveys.get(t.name);i&&i.push(e.id),this.actionToSurveys.set(t.name,i||[e.id])}})))}))}}setupEventBasedSurveys(e){var t;if(0!==e.filter((e=>{var t,i,s,r;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s||null===(r=s.values)||void 0===r?void 0:r.length)>0})).length){null===(t=this.instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t,i,s;null===(t=e.conditions)||void 0===t||null===(i=t.events)||void 0===i||null===(s=i.values)||void 0===s||s.forEach((t=>{if(t&&t.name){var i=this.eventToSurveys.get(t.name);i&&i.push(e.id),this.eventToSurveys.set(t.name,i||[e.id])}}))}))}}onEvent(e,t){var i,s,r=(null===(i=this.instance)||void 0===i||null===(s=i.persistence)||void 0===s?void 0:s.props[$e])||[];if(Mn.SURVEY_SHOWN_EVENT_NAME==e&&t&&r.length>0){var n,o=null==t||null===(n=t.properties)||void 0===n?void 0:n.$survey_id;if(o){var a=r.indexOf(o);a>=0&&(r.splice(a,1),this._updateActivatedSurveys(r))}}else this.eventToSurveys.has(e)&&this._updateActivatedSurveys(r.concat(this.eventToSurveys.get(e)||[]))}onAction(e){var t,i,s=(null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i?void 0:i.props[$e])||[];this.actionToSurveys.has(e)&&this._updateActivatedSurveys(s.concat(this.actionToSurveys.get(e)||[]))}_updateActivatedSurveys(e){var t,i;null===(t=this.instance)||void 0===t||null===(i=t.persistence)||void 0===i||i.register({[$e]:[...new Set(e)]})}getSurveys(){var e,t,i=null===(e=this.instance)||void 0===e||null===(t=e.persistence)||void 0===t?void 0:t.props[$e];return i||[]}getEventToSurveys(){return this.eventToSurveys}_getActionMatcher(){return this.actionMatcher}}i(Mn,"SURVEY_SHOWN_EVENT_NAME","survey shown");var Ln=W("[Surveys]"),Dn={icontains:(e,t)=>e.some((e=>t.toLowerCase().includes(e.toLowerCase()))),not_icontains:(e,t)=>e.every((e=>!t.toLowerCase().includes(e.toLowerCase()))),regex:(e,t)=>e.some((e=>$n(t,e))),not_regex:(e,t)=>e.every((e=>!$n(t,e))),exact:(e,t)=>e.some((e=>t===e)),is_not:(e,t)=>e.every((e=>t!==e))};function qn(e){return null!=e?e:"icontains"}class Nn{constructor(e){i(this,"_isFetchingSurveys",!1),i(this,"_isInitializingSurveys",!1),this.instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){this._decideServerResponse=!!e.surveys,Ln.info("decideServerResponse set to ".concat(this._decideServerResponse)),this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var e=(()=>{for(var e=[],t=0;t<localStorage.length;t++){var i=localStorage.key(t);null!=i&&i.startsWith("seenSurvey_")&&e.push(i)}return e})();e.forEach((e=>localStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Ln.info("Already initializing surveys, skipping...");else if(this.instance.config.disable_surveys)Ln.info("Disabled. Not loading surveys.");else{var e=null==f?void 0:f.__PosthogExtensions__;if(e)if(this._decideServerResponse){this._isInitializingSurveys=!0;try{var t=e.generateSurveys;if(t)this._surveyManager=t(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new Mn(this.instance),Ln.info("Surveys loaded successfully");else{var i=e.loadExternalDependency;i?i(this.instance,"surveys",(t=>{if(t||!e.generateSurveys)return Ln.error("Could not load surveys script",t),void(this._isInitializingSurveys=!1);this._surveyManager=e.generateSurveys(this.instance),this._isInitializingSurveys=!1,this._surveyEventReceiver=new Mn(this.instance),Ln.info("Surveys loaded successfully")})):(Ln.error("PostHog loadExternalDependency extension not found. Cannot load remote config."),this._isInitializingSurveys=!1)}}catch(e){throw Ln.error("Error initializing surveys",e),this._isInitializingSurveys=!1,e}}else Ln.warn("Decide not loaded yet. Not loading surveys.");else Ln.error("PostHog Extensions not found.")}}getSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this.instance.config.disable_surveys)return Ln.info("Disabled. Not loading surveys."),e([]);var i=this.instance.get_property(Te);if(i&&!t)return e(i);if(this._isFetchingSurveys)return e([]);try{this._isFetchingSurveys=!0,this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",timeout:this.instance.config.surveys_request_timeout_ms,callback:t=>{var i;this._isFetchingSurveys=!1;var s=t.statusCode;if(200!==s||!t.json)return Ln.error("Surveys API could not be loaded, status: ".concat(s)),e([]);var r,n=t.json.surveys||[],o=n.filter((e=>{var t,i,s,r,n,o,a,l,c,u,d,h;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(s=i.events)||void 0===s?void 0:s.values)&&(null===(r=e.conditions)||void 0===r||null===(n=r.events)||void 0===n||null===(o=n.values)||void 0===o?void 0:o.length)>0||(null===(a=e.conditions)||void 0===a?void 0:a.actions)&&(null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c?void 0:c.values)&&(null===(u=e.conditions)||void 0===u||null===(d=u.actions)||void 0===d||null===(h=d.values)||void 0===h?void 0:h.length)>0}));o.length>0&&(null===(r=this._surveyEventReceiver)||void 0===r||r.register(o));return null===(i=this.instance.persistence)||void 0===i||i.register({[Te]:n}),e(n)}})}catch(e){throw this._isFetchingSurveys=!1,e}}isSurveyFeatureFlagEnabled(e){return!e||this.instance.featureFlags.isFeatureEnabled(e)}getActiveMatchingSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.getSurveys((t=>{var i,s=t.filter((e=>!(!e.start_date||e.end_date))).filter((e=>{var t;if(!e.conditions)return!0;var i=function(e){var t,i,s;if(null===(t=e.conditions)||void 0===t||!t.url)return!0;var r=null==n||null===(i=n.location)||void 0===i?void 0:i.href;if(!r)return!1;var o=[e.conditions.url];return Dn[qn(null===(s=e.conditions)||void 0===s?void 0:s.urlMatchType)](o,r)}(e),s=null===(t=e.conditions)||void 0===t||!t.selector||(null==d?void 0:d.querySelector(e.conditions.selector)),r=function(e){var t,i,s;if(null===(t=e.conditions)||void 0===t||!t.deviceTypes||0===(null===(i=e.conditions)||void 0===i?void 0:i.deviceTypes.length))return!0;if(!v)return!1;var r=zr.deviceType(v);return Dn[qn(null===(s=e.conditions)||void 0===s?void 0:s.deviceTypesMatchType)](e.conditions.deviceTypes,r)}(e);return i&&s&&r})),r=null===(i=this._surveyEventReceiver)||void 0===i?void 0:i.getSurveys(),o=s.filter((e=>{var t,i,s,n,o,a,l,c,u;if(!(e.linked_flag_key||e.targeting_flag_key||e.internal_targeting_flag_key||null!==(t=e.feature_flag_keys)&&void 0!==t&&t.length))return!0;var d=this.isSurveyFeatureFlagEnabled(e.linked_flag_key),h=this.isSurveyFeatureFlagEnabled(e.targeting_flag_key),_=(null!==(i=null===(s=e.conditions)||void 0===s||null===(n=s.events)||void 0===n||null===(o=n.values)||void 0===o?void 0:o.length)&&void 0!==i?i:0)>0,p=(null!==(a=null===(l=e.conditions)||void 0===l||null===(c=l.actions)||void 0===c||null===(u=c.values)||void 0===u?void 0:u.length)&&void 0!==a?a:0)>0,g=!_&&!p||(null==r?void 0:r.includes(e.id)),v=this._canActivateRepeatedly(e)||this.isSurveyFeatureFlagEnabled(e.internal_targeting_flag_key),f=this.checkFlags(e);return d&&h&&v&&g&&f}));return e(o)}),t)}checkFlags(e){var t;return null===(t=e.feature_flag_keys)||void 0===t||!t.length||e.feature_flag_keys.every((e=>{var{key:t,value:i}=e;return!t||!i||this.instance.featureFlags.isFeatureEnabled(i)}))}_canActivateRepeatedly(e){var t;return L(null===(t=f.__PosthogExtensions__)||void 0===t?void 0:t.canActivateRepeatedly)?(Ln.warn("init was not called"),!1):f.__PosthogExtensions__.canActivateRepeatedly(e)}canRenderSurvey(e){L(this._surveyManager)?Ln.warn("init was not called"):this.getSurveys((t=>{var i=t.filter((t=>t.id===e))[0];this._surveyManager.canRenderSurvey(i)}))}renderSurvey(e,t){L(this._surveyManager)?Ln.warn("init was not called"):this.getSurveys((i=>{var s=i.filter((t=>t.id===e))[0];this._surveyManager.renderSurvey(s,null==d?void 0:d.querySelector(t))}))}}var Bn=W("[RateLimiter]");class Hn{constructor(e){var t,s;i(this,"serverLimits",{}),i(this,"lastEventRateLimited",!1),i(this,"checkForLimiting",(e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Bn.info("".concat(e||"events"," is quota limited.")),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Bn.warn('could not rate limit - continuing. Error: "'.concat(null==e?void 0:e.message,'"'),{text:t})}})),this.instance=e,this.captureEventsPerSecond=(null===(t=e.config.rate_limiting)||void 0===t?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max((null===(s=e.config.rate_limiting)||void 0===s?void 0:s.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var e,t,i,s=arguments.length>0&&void 0!==arguments[0]&&arguments[0],r=(new Date).getTime(),n=null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_property(Le))&&void 0!==e?e:{tokens:this.captureEventsBurstLimit,last:r};n.tokens+=(r-n.last)/1e3*this.captureEventsPerSecond,n.last=r,n.tokens>this.captureEventsBurstLimit&&(n.tokens=this.captureEventsBurstLimit);var o=n.tokens<1;return o||s||(n.tokens=Math.max(0,n.tokens-1)),!o||this.lastEventRateLimited||s||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to ".concat(this.captureEventsPerSecond," events per second and ").concat(this.captureEventsBurstLimit," events burst limit.")},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=o,null===(i=this.instance.persistence)||void 0===i||i.set_property(Le,n),{isRateLimited:o,remainingTokens:n.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()<t}}var Un=W("[RemoteConfig]");class zn{constructor(e){this.instance=e}get remoteConfig(){var e,t;return null===(e=f._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(t=e[this.instance.config.token])||void 0===t?void 0:t.config}_loadRemoteConfigJs(e){var t,i,s;null!==(t=f.__PosthogExtensions__)&&void 0!==t&&t.loadExternalDependency?null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadExternalDependency)||void 0===s||s.call(i,this.instance,"remote-config",(()=>e(this.remoteConfig))):(Un.error("PostHog Extensions not found. Cannot load remote config."),e())}_loadRemoteConfigJSON(e){this.instance._send_request({method:"GET",url:this.instance.requestRouter.endpointFor("assets","/array/".concat(this.instance.config.token,"/config")),callback:t=>{e(t.json)}})}load(){try{if(this.remoteConfig)return Un.info("Using preloaded remote config",this.remoteConfig),void this.onRemoteConfig(this.remoteConfig);if(this.instance.config.advanced_disable_decide)return void Un.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Un.info("No config found after loading remote JS config. Falling back to JSON."),void this._loadRemoteConfigJSON((e=>{this.onRemoteConfig(e)}));this.onRemoteConfig(e)}))}catch(e){Un.error("Error loading remote config",e)}}onRemoteConfig(e){e?this.instance.config.__preview_remote_config?(this.instance._onRemoteConfig(e),!1!==e.hasFeatureFlags&&this.instance.featureFlags.ensureFlagsLoaded()):Un.info("__preview_remote_config is disabled. Logging config instead",e):Un.error("Failed to fetch remote config from PostHog.")}}var jn=function(e){var t,i,s,r,n="";for(t=i=0,s=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,r=0;r<s;r++){var o=e.charCodeAt(r),a=null;o<128?i++:a=o>127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),M(a)||(i>t&&(n+=e.substring(t,i)),n+=a,t=i=r+1)}return i>t&&(n+=e.substring(t,e.length)),n},Wn=!!p||!!_,Vn="text/plain",Gn=(e,i)=>{var[s,r]=e.split("?"),n=t({},i);null==r||r.split("&").forEach((e=>{var[t]=e.split("=");delete n[t]}));var o=wt(n);return o=o?(r?r+"&":"")+o:r,"".concat(s,"?").concat(o)},Jn=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Yn=e=>{var{data:t,compression:i}=e;if(t){if(i===r.GZipJS){var s=ss(rs(Jn(t)),{mtime:0}),n=new Blob([s],{type:Vn});return{contentType:Vn,body:n,estimatedSize:n.size}}if(i===r.Base64){var o=function(e){var t,i,s,r,n,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,c="",u=[];if(!e)return e;e=jn(e);do{t=(n=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=n>>12&63,s=n>>6&63,r=63&n,u[l++]=o.charAt(t)+o.charAt(i)+o.charAt(s)+o.charAt(r)}while(a<e.length);switch(c=u.join(""),e.length%3){case 1:c=c.slice(0,-2)+"==";break;case 2:c=c.slice(0,-1)+"="}return c}(Jn(t)),a=(e=>"data="+encodeURIComponent("string"==typeof e?e:Jn(e)))(o);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var l=Jn(t);return{contentType:"application/json",body:l,estimatedSize:new Blob([l]).size}}},Kn=[];_&&Kn.push({transport:"fetch",method:e=>{var i,s,{contentType:r,body:n,estimatedSize:o}=null!==(i=Yn(e))&&void 0!==i?i:{},a=new Headers;J(e.headers,(function(e,t){a.append(t,e)})),r&&a.append("Content-Type",r);var l=e.url,c=null;if(g){var u=new g;c={signal:u.signal,timeout:setTimeout((()=>u.abort()),e.timeout)}}_(l,t({method:(null==e?void 0:e.method)||"GET",headers:a,keepalive:"POST"===e.method&&(o||0)<52428.8,body:n,signal:null===(s=c)||void 0===s?void 0:s.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var s,r={statusCode:t.status,text:i};if(200===t.status)try{r.json=JSON.parse(i)}catch(e){j.error(e)}null===(s=e.callback)||void 0===s||s.call(e,r)})))).catch((t=>{var i;j.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,text:t})})).finally((()=>c?clearTimeout(c.timeout):null))}}),p&&Kn.push({transport:"XHR",method:e=>{var t,i=new p;i.open(e.method||"GET",e.url,!0);var{contentType:s,body:r}=null!==(t=Yn(e))&&void 0!==t?t:{};J(e.headers,(function(e,t){i.setRequestHeader(t,e)})),s&&i.setRequestHeader("Content-Type",s),e.timeout&&(i.timeout=e.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(4===i.readyState){var t,s={statusCode:i.status,text:i.responseText};if(200===i.status)try{s.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,s)}},i.send(r)}}),null!=u&&u.sendBeacon&&Kn.push({transport:"sendBeacon",method:e=>{var t=Gn(e.url,{beacon:"1"});try{var i,{contentType:s,body:r}=null!==(i=Yn(e))&&void 0!==i?i:{},n="string"==typeof r?new Blob([r],{type:s}):r;u.sendBeacon(t,n)}catch(e){}}});var Xn=3e3;class Qn{constructor(e,t){i(this,"isPaused",!0),i(this,"queue",[]),this.flushTimeoutMs=bi((null==t?void 0:t.flush_interval_ms)||Xn,250,5e3,"flush interval",Xn),this.sendRequest=e}enqueue(e){this.queue.push(e),this.flushTimeout||this.setFlushTimeout()}unload(){this.clearFlushTimeout();var e=this.queue.length>0?this.formatQueue():{},i=Object.values(e),s=[...i.filter((e=>0===e.url.indexOf("/e"))),...i.filter((e=>0!==e.url.indexOf("/e")))];s.map((e=>{this.sendRequest(t(t({},e),{},{transport:"sendBeacon"}))}))}enable(){this.isPaused=!1,this.setFlushTimeout()}setFlushTimeout(){var e=this;this.isPaused||(this.flushTimeout=setTimeout((()=>{if(this.clearFlushTimeout(),this.queue.length>0){var t=this.formatQueue(),i=function(i){var s=t[i],r=(new Date).getTime();s.data&&C(s.data)&&J(s.data,(e=>{e.offset=Math.abs(e.timestamp-r),delete e.timestamp})),e.sendRequest(s)};for(var s in t)i(s)}}),this.flushTimeoutMs))}clearFlushTimeout(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}formatQueue(){var e={};return J(this.queue,(i=>{var s,r=i,n=(r?r.batchKey:null)||r.url;$(e[n])&&(e[n]=t(t({},r),{},{data:[]})),null===(s=e[n].data)||void 0===s||s.push(r.data)})),this.queue=[],e}}var Zn=["retriesPerformedSoFar"];class eo{constructor(e){i(this,"isPolling",!1),i(this,"pollIntervalMs",3e3),i(this,"queue",[]),this.instance=e,this.queue=[],this.areWeOnline=!0,!$(n)&&"onLine"in n.navigator&&(this.areWeOnline=n.navigator.onLine,ne(n,"online",(()=>{this.areWeOnline=!0,this.flush()})),ne(n,"offline",(()=>{this.areWeOnline=!1})))}retriableRequest(e){var{retriesPerformedSoFar:i}=e,r=s(e,Zn);D(i)&&i>0&&(r.url=Gn(r.url,{retry_count:i})),this.instance._send_request(t(t({},r),{},{callback:e=>{var s;200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=i?i:0)<10?this.enqueue(t({retriesPerformedSoFar:i},r)):null===(s=r.callback)||void 0===s||s.call(r,e)}}))}enqueue(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(e){var t=3e3*Math.pow(2,e),i=t/2,s=Math.min(18e5,t),r=(Math.random()-.5)*(s-i);return Math.ceil(s+r)}(t),s=Date.now()+i;this.queue.push({retryAt:s,requestOptions:e});var r="Enqueued failed request for retry in ".concat(i);navigator.onLine||(r+=" (Browser is offline)"),j.warn(r),this.isPolling||(this.isPolling=!0,this.poll())}poll(){this.poller&&clearTimeout(this.poller),this.poller=setTimeout((()=>{this.areWeOnline&&this.queue.length>0&&this.flush(),this.poll()}),this.pollIntervalMs)}flush(){var e=Date.now(),t=[],i=this.queue.filter((i=>i.retryAt<e||(t.push(i),!1)));if(this.queue=t,i.length>0)for(var{requestOptions:s}of i)this.retriableRequest(s)}unload(){for(var{requestOptions:e}of(this.poller&&(clearTimeout(this.poller),this.poller=void 0),this.queue))try{this.instance._send_request(t(t({},e),{},{transport:"sendBeacon"}))}catch(e){j.error(e)}this.queue=[]}}class to{constructor(e){i(this,"_updateScrollData",(()=>{var e,t,i,s;this.context||(this.context={});var r=this.scrollElement(),n=this.scrollY(),o=r?Math.max(0,r.scrollHeight-r.clientHeight):0,a=n+((null==r?void 0:r.clientHeight)||0),l=(null==r?void 0:r.scrollHeight)||0;this.context.lastScrollY=Math.ceil(n),this.context.maxScrollY=Math.max(n,null!==(e=this.context.maxScrollY)&&void 0!==e?e:0),this.context.maxScrollHeight=Math.max(o,null!==(t=this.context.maxScrollHeight)&&void 0!==t?t:0),this.context.lastContentY=a,this.context.maxContentY=Math.max(a,null!==(i=this.context.maxContentY)&&void 0!==i?i:0),this.context.maxContentHeight=Math.max(l,null!==(s=this.context.maxContentHeight)&&void 0!==s?s:0)})),this.instance=e}getContext(){return this.context}resetContext(){var e=this.context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){ne(n,"scroll",this._updateScrollData,{capture:!0}),ne(n,"scrollend",this._updateScrollData,{capture:!0}),ne(n,"resize",this._updateScrollData)}scrollElement(){if(!this.instance.config.scroll_root_selector)return null==n?void 0:n.document.documentElement;var e=C(this.instance.config.scroll_root_selector)?this.instance.config.scroll_root_selector:[this.instance.config.scroll_root_selector];for(var t of e){var i=null==n?void 0:n.document.querySelector(t);if(i)return i}}scrollY(){if(this.instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return n&&(n.scrollY||n.pageYOffset||n.document.documentElement.scrollTop)||0}scrollX(){if(this.instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return n&&(n.scrollX||n.pageXOffset||n.document.documentElement.scrollLeft)||0}}var io=e=>zr.personInfo({maskPersonalDataProperties:null==e?void 0:e.config.mask_personal_data_properties,customPersonalDataProperties:null==e?void 0:e.config.custom_personal_data_properties});class so{constructor(e,t,s,r){i(this,"_onSessionIdCallback",(e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this.instance)};this._persistence.register({[Me]:i})}})),this.instance=e,this._sessionIdManager=t,this._persistence=s,this._sessionSourceParamGenerator=r||io,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[Me]}getSetOnceProps(){var e,t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?zr.personPropsFromInfo(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return J(ee(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_".concat(k(i))]=t})),e}}var ro=W("[SessionId]");class no{constructor(e,t,s){var r;if(i(this,"_sessionIdChangedHandlers",[]),!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.__preview_experimental_cookieless_mode)throw new Error("SessionIdManager cannot be used with __preview_experimental_cookieless_mode");this.config=e.config,this.persistence=e.persistence,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=t||Dt,this._windowIdGenerator=s||Dt;var n=this.config.persistence_name||this.config.token,o=this.config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*bi(o,60,36e3,"session_idle_timeout_seconds",1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.resetIdleTimer(),this._window_id_storage_key="ph_"+n+"_window_id",this._primary_window_exists_storage_key="ph_"+n+"_primary_window_exists",this._canUseSessionStorage()){var a=Qt.parse(this._window_id_storage_key),l=Qt.parse(this._primary_window_exists_storage_key);a&&!l?this._windowId=a:Qt.remove(this._window_id_storage_key),Qt.set(this._primary_window_exists_storage_key,!0)}if(null!==(r=this.config.bootstrap)&&void 0!==r&&r.sessionID)try{var c=(e=>{var t=e.replace(/-/g,"");if(32!==t.length)throw new Error("Not a valid UUID");if("7"!==t[12])throw new Error("Not a UUIDv7");return parseInt(t.substring(0,12),16)})(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,(new Date).getTime(),c)}catch(e){ro.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return $(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),()=>{this._sessionIdChangedHandlers=this._sessionIdChangedHandlers.filter((t=>t!==e))}}_canUseSessionStorage(){return"memory"!==this.config.persistence&&!this.persistence.disabled&&Qt.is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&Qt.set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?Qt.parse(this._window_id_storage_key):null}_setSessionId(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this.persistence.register({[ke]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this.persistence.props[ke];return C(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){ne(n,"beforeunload",(()=>{this._canUseSessionStorage()&&Qt.remove(this._primary_window_exists_storage_key)}),{capture:!1})}checkAndGetSessionAndWindowId(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;if(this.config.__preview_experimental_cookieless_mode)throw new Error("checkAndGetSessionAndWindowId should not be called in __preview_experimental_cookieless_mode");var i=t||(new Date).getTime(),[s,r,n]=this._getSessionId(),o=this._getWindowId(),a=D(n)&&n>0&&Math.abs(i-n)>864e5,l=!1,c=!r,u=!e&&Math.abs(i-s)>this.sessionTimeoutMs;c||u||a?(r=this._sessionIdGenerator(),o=this._windowIdGenerator(),ro.info("new session ID generated",{sessionId:r,windowId:o,changeReason:{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}}),n=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===s||!e||a?i:s,h=0===n?(new Date).getTime():n;return this._setWindowId(o),this._setSessionId(r,d,h),e||this.resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(r,o,l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0))),{sessionId:r,windowId:o,sessionStartTimestamp:h,changeReason:l?{noSessionId:c,activityTimeout:u,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:s}}resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{this.resetSessionId()}),1.1*this.sessionTimeoutMs)}}var oo=["$set_once","$set"],ao=W("[SiteApps]");class lo{constructor(e){this.instance=e,this.bufferedInvocations=[],this.apps={}}get isEnabled(){return!!this.instance.config.opt_in_site_apps}eventCollector(e,t){if(t){var i=this.globalsForEvent(t);this.bufferedInvocations.push(i),this.bufferedInvocations.length>1e3&&(this.bufferedInvocations=this.bufferedInvocations.slice(10))}}get siteAppLoaders(){var e,t;return null===(e=f._POSTHOG_REMOTE_CONFIG)||void 0===e||null===(t=e[this.instance.config.token])||void 0===t?void 0:t.siteApps}init(){if(this.isEnabled){var e=this.instance._addCaptureHook(this.eventCollector.bind(this));this.stopBuffering=()=>{e(),this.bufferedInvocations=[],this.stopBuffering=void 0}}}globalsForEvent(e){var i,r,n,o,a,l,c;if(!e)throw new Error("Event payload is required");var u={},d=this.instance.get_property("$groups")||[],h=this.instance.get_property("$stored_group_properties")||{};for(var[_,p]of Object.entries(h))u[_]={id:d[_],type:_,properties:p};var{$set_once:g,$set:v}=e;return{event:t(t({},s(e,oo)),{},{properties:t(t(t({},e.properties),v?{$set:t(t({},null!==(i=null===(r=e.properties)||void 0===r?void 0:r.$set)&&void 0!==i?i:{}),v)}:{}),g?{$set_once:t(t({},null!==(n=null===(o=e.properties)||void 0===o?void 0:o.$set_once)&&void 0!==n?n:{}),g)}:{}),elements_chain:null!==(a=null===(l=e.properties)||void 0===l?void 0:l.$elements_chain)&&void 0!==a?a:"",distinct_id:null===(c=e.properties)||void 0===c?void 0:c.distinct_id}),person:{properties:this.instance.get_property("$stored_person_properties")},groups:u}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this.bufferedInvocations.length&&(ao.info("Processing ".concat(this.bufferedInvocations.length," events for site app with id ").concat(e.id)),this.bufferedInvocations.forEach((e=>{var i;return null===(i=t.processEvent)||void 0===i?void 0:i.call(t,e)})),t.processedBuffer=!0),Object.values(this.apps).every((e=>e.processedBuffer||e.errored)))&&(null===(i=this.stopBuffering)||void 0===i||i.call(this))},s=!1,r=r=>{t.errored=!r,t.loaded=!0,ao.info("Site app with id ".concat(e.id," ").concat(r?"loaded":"errored")),s&&i()};try{var{processEvent:n}=e.init({posthog:this.instance,callback:e=>{r(e)}});n&&(t.processEvent=n),s=!0}catch(t){ao.error("Error while initializing PostHog app with config id ".concat(e.id),t),r(!1)}if(s&&t.loaded)try{i()}catch(i){ao.error("Error while processing buffered events PostHog app with config id ".concat(e.id),i),t.errored=!0}}setupSiteApps(){var e=this.siteAppLoaders||[];for(var t of e)this.apps[t.id]={id:t.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of e)this.setupSiteApp(i)}onCapturedEvent(e){if(0!==Object.keys(this.apps).length){var t=this.globalsForEvent(e);for(var i of Object.values(this.apps))try{var s;null===(s=i.processEvent)||void 0===s||s.call(i,t)}catch(t){ao.error("Error while processing event ".concat(e.event," for site app ").concat(i.id),t)}}}onRemoteConfig(e){var t,i,s,r=this;if(null!==(t=this.siteAppLoaders)&&void 0!==t&&t.length)return this.isEnabled?(this.setupSiteApps(),void this.instance.on("eventCaptured",(e=>this.onCapturedEvent(e)))):void ao.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if(null===(i=this.stopBuffering)||void 0===i||i.call(this),null!==(s=e.siteApps)&&void 0!==s&&s.length)if(this.isEnabled){var n=function(e,t){var i,s;f["__$$ph_site_app_".concat(e)]=r.instance,null===(i=f.__PosthogExtensions__)||void 0===i||null===(s=i.loadSiteApp)||void 0===s||s.call(i,r.instance,t,(t=>{if(t)return ao.error("Error while initializing PostHog app with config id ".concat(e),t)}))};for(var{id:o,url:a}of e.siteApps)n(o,a)}else ao.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var co,uo=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleweblight","mediapartners-google","storebot-google","bytespider"],ho=function(e,t){if(!e)return!1;var i=e.toLowerCase();return uo.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},_o=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&ho(i,t))return!0;try{var s=null==e?void 0:e.userAgentData;if(null!=s&&s.brands&&s.brands.some((e=>ho(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function po(e,t,i){return Jn({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}!function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"}(co||(co={}));var go="i.posthog.com";class vo{constructor(e){i(this,"_regionCache",{}),this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return"https://app.posthog.com"===e?"https://us.i.posthog.com":e}get uiHost(){var e,t=null===(e=this.instance.config.ui_host)||void 0===e?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(".".concat(go),".posthog.com")),"https://app.posthog.com"===t?"https://us.posthog.com":t}get region(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=co.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=co.EU:this._regionCache[this.apiHost]=co.CUSTOM),this._regionCache[this.apiHost]}endpointFor(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(t&&(t="/"===t[0]?t:"/".concat(t)),"ui"===e)return this.uiHost+t;if(this.region===co.CUSTOM)return this.apiHost+t;var i=go+t;switch(e){case"assets":return"https://".concat(this.region,"-assets.").concat(i);case"api":return"https://".concat(this.region,".").concat(i)}}}var fo={icontains:(e,t)=>!!n&&t.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,t)=>!!n&&-1===t.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,t)=>!!n&&$n(t.href,e),not_regex:(e,t)=>!!n&&!$n(t.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class mo{constructor(e){var t=this;i(this,"getWebExperimentsAndEvaluateDisplayLogic",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t.getWebExperiments((e=>{mo.logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)mo.logInfo("setting flag key ",e.feature_flag_key," to web experiment ",e),null===(i=t._flagToExperiments)||void 0===i||i.set(e.feature_flag_key,e);var s=t.instance.getFeatureFlag(e.feature_flag_key);A(s)&&e.variants[s]&&t.applyTransforms(e.name,s,e.variants[s].transforms)}else if(e.variants)for(var r in e.variants){var n=e.variants[r];mo.matchesTestVariant(n)&&t.applyTransforms(e.name,r,n.transforms)}}))}),e)})),this.instance=e,this.instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())mo.logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this.instance.config.disable_web_experiments){if(L(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();mo.logInfo("applying feature flags",e),e.forEach((e=>{var t;if(this._flagToExperiments&&null!==(t=this._flagToExperiments)&&void 0!==t&&t.has(e)){var i,s=this.instance.getFeatureFlag(e),r=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);s&&null!=r&&r.variants[s]&&this.applyTransforms(r.name,s,r.variants[s].transforms)}}))}}previewWebExperiment(){var e=mo.getWindowLocation();if(null!=e&&e.search){var t=St(null==e?void 0:e.search,"__experiment_id"),i=St(null==e?void 0:e.search,"__experiment_variant");t&&i&&(mo.logInfo("previewing web experiments ".concat(t," && ").concat(i)),this.getWebExperiments((e=>{this.showPreviewWebExperiment(parseInt(t),i,e)}),!1,!0))}}loadIfEnabled(){this.instance.config.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.instance.config.disable_web_experiments&&!i)return e([]);var s=this.instance.get_property("$web_experiments");if(s&&!t)return e(s);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/web_experiments/?token=".concat(this.instance.config.token)),method:"GET",callback:t=>{if(200!==t.statusCode||!t.json)return e([]);var i=t.json.experiments||[];return e(i)}})}showPreviewWebExperiment(e,t,i){var s=i.filter((t=>t.id===e));s&&s.length>0&&(mo.logInfo("Previewing web experiment [".concat(s[0].name,"] with variant [").concat(t,"]")),this.applyTransforms(s[0].name,t,s[0].variants[t].transforms))}static matchesTestVariant(e){return!L(e.conditions)&&(mo.matchUrlConditions(e)&&mo.matchUTMConditions(e))}static matchUrlConditions(e){var t;if(L(e.conditions)||L(null===(t=e.conditions)||void 0===t?void 0:t.url))return!0;var i,s,r,n=mo.getWindowLocation();return!!n&&(null===(i=e.conditions)||void 0===i||!i.url||fo[null!==(s=null===(r=e.conditions)||void 0===r?void 0:r.urlMatchType)&&void 0!==s?s:"icontains"](e.conditions.url,n))}static getWindowLocation(){return null==n?void 0:n.location}static matchUTMConditions(e){var t;if(L(e.conditions)||L(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;var i=zr.campaignParams();if(i.utm_source){var s,r,n,o,a,l,c,u,d,h,_,p,g,v,f,m,b=null===(s=e.conditions)||void 0===s||null===(r=s.utm)||void 0===r||!r.utm_campaign||(null===(n=e.conditions)||void 0===n||null===(o=n.utm)||void 0===o?void 0:o.utm_campaign)==i.utm_campaign,y=null===(a=e.conditions)||void 0===a||null===(l=a.utm)||void 0===l||!l.utm_source||(null===(c=e.conditions)||void 0===c||null===(u=c.utm)||void 0===u?void 0:u.utm_source)==i.utm_source,w=null===(d=e.conditions)||void 0===d||null===(h=d.utm)||void 0===h||!h.utm_medium||(null===(_=e.conditions)||void 0===_||null===(p=_.utm)||void 0===p?void 0:p.utm_medium)==i.utm_medium,S=null===(g=e.conditions)||void 0===g||null===(v=g.utm)||void 0===v||!v.utm_term||(null===(f=e.conditions)||void 0===f||null===(m=f.utm)||void 0===m?void 0:m.utm_term)==i.utm_term;return b&&w&&S&&y}return!1}static logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),s=1;s<t;s++)i[s-1]=arguments[s];j.info("[WebExperiments] ".concat(e),i)}applyTransforms(e,t,i){this._is_bot()?mo.logInfo("Refusing to render web experiment since the viewer is a likely bot"):"control"!==t?i.forEach((i=>{if(i.selector){var s;mo.logInfo("applying transform of variant ".concat(t," for experiment ").concat(e," "),i);var r=null===(s=document)||void 0===s?void 0:s.querySelectorAll(i.selector);null==r||r.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):mo.logInfo("Control variants leave the page unmodified.")}_is_bot(){return u&&this.instance?_o(u,this.instance.config.custom_blocked_useragents):void 0}}var bo={},yo=()=>{},wo="posthog",So=!Wn&&-1===(null==v?void 0:v.indexOf("MSIE"))&&-1===(null==v?void 0:v.indexOf("Mozilla")),ko=()=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:se(null==d?void 0:d.location),persistence:"localStorage+cookie",persistence_name:"",loaded:yo,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:h&&A(null==h?void 0:h.search)&&-1!==h.search.indexOf("__posthog_debug=true")||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:"https:"===(null==n||null===(e=n.location)||void 0===e?void 0:e.protocol),ip:!0,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,session_recording:{},mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error:e=>{var t="Bad HTTP status: "+e.statusCode+" "+e.text;j.error(t)},get_device_id:e=>e,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:"identified_only",before_send:void 0,request_queue_config:{flush_interval_ms:Xn},_onCapture:yo}},Eo=e=>{var t={};$(e.process_person)||(t.person_profiles=e.process_person),$(e.xhr_headers)||(t.request_headers=e.xhr_headers),$(e.cookie_name)||(t.persistence_name=e.cookie_name),$(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),$(e.store_google)||(t.save_campaign_params=e.store_google),$(e.verbose)||(t.debug=e.verbose);var i=Y({},t,e);return C(e.property_blacklist)&&($(e.property_denylist)?i.property_denylist=e.property_blacklist:C(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:j.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class xo{constructor(){i(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){j.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class Io{get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){i(this,"webPerformance",new xo),i(this,"_personProcessingSetOncePropertiesSent",!1),i(this,"version",U.LIB_VERSION),i(this,"_internalEventEmitter",new An),this.config=ko(),this.SentryIntegration=bs,this.sentryIntegration=e=>function(e,t){var i=ms(e,t);return{name:fs,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this._cachedIdentify=null,this.featureFlags=new zs(this),this.toolbar=new Es(this),this.scrollManager=new to(this),this.pageViewManager=new As(this),this.surveys=new Nn(this),this.experiments=new mo(this),this.exceptions=new Os(this),this.rateLimiter=new Hn(this),this.requestRouter=new vo(this),this.consent=new Zt(this),this.people={set:(e,t,i)=>{var s=A(e)?{[e]:t}:e;this.setPersonProperties(s),null==i||i({})},set_once:(e,t,i)=>{var s=A(e)?{[e]:t}:e;this.setPersonProperties(void 0,s),null==i||i({})}},this.on("eventCaptured",(e=>j.info('send "'.concat(null==e?void 0:e.event,'"'),e)))}init(e,t,i){if(i&&i!==wo){var s,r=null!==(s=bo[i])&&void 0!==s?s:new Io;return r._init(e,t,i),bo[i]=r,bo[wo][i]=r,r}return this._init(e,t,i)}_init(e){var i,s,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},a=arguments.length>2?arguments[2]:void 0;if($(e)||O(e))return j.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;if(this.__loaded)return j.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],o.person_profiles&&(this._initialPersonProfilesConfig=o.person_profiles),this.set_config(Y({},ko(),Eo(o),{name:a,token:e})),this.config.on_xhr_error&&j.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=o.disable_compression?void 0:r.GZipJS,this.persistence=new Wr(this.config),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Wr(t(t({},this.config),{},{persistence:"sessionStorage"}));var l=t({},this.persistence.props),c=t({},this.sessionPersistence.props);if(this._requestQueue=new Qn((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new eo(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new no(this),this.sessionPropsManager=new so(this,this.sessionManager,this.persistence)),new Is(this).startIfEnabledOrStop(),this.siteApps=new lo(this),null===(i=this.siteApps)||void 0===i||i.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new ps(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new Rt(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new $s(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new Fs(this),this.exceptionObserver=new ni(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new si(this,ii),this.deadClicksAutocapture.startIfEnabled(),U.DEBUG=U.DEBUG||this.config.debug,U.DEBUG&&j.info("Starting in debug mode",{this:this,config:o,thisC:t({},this.config),p:l,s:c}),this._sync_opt_out_with_persistence(),void 0!==(null===(s=o.bootstrap)||void 0===s?void 0:s.distinctID)){var u,d,h=this.config.get_device_id(Dt()),_=null!==(u=o.bootstrap)&&void 0!==u&&u.isIdentifiedID?h:o.bootstrap.distinctID;this.persistence.set_property(Oe,null!==(d=o.bootstrap)&&void 0!==d&&d.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:o.bootstrap.distinctID,$device_id:_})}if(this._hasBootstrappedFeatureFlags()){var p,g,v=Object.keys((null===(p=o.bootstrap)||void 0===p?void 0:p.featureFlags)||{}).filter((e=>{var t,i;return!(null===(t=o.bootstrap)||void 0===t||null===(i=t.featureFlags)||void 0===i||!i[e])})).reduce(((e,t)=>{var i,s;return e[t]=(null===(i=o.bootstrap)||void 0===i||null===(s=i.featureFlags)||void 0===s?void 0:s[t])||!1,e}),{}),f=Object.keys((null===(g=o.bootstrap)||void 0===g?void 0:g.featureFlagPayloads)||{}).filter((e=>v[e])).reduce(((e,t)=>{var i,s,r,n;null!==(i=o.bootstrap)&&void 0!==i&&null!==(s=i.featureFlagPayloads)&&void 0!==s&&s[t]&&(e[t]=null===(r=o.bootstrap)||void 0===r||null===(n=r.featureFlagPayloads)||void 0===n?void 0:n[t]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:f})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Ue,$device_id:null},"");else if(!this.get_distinct_id()){var m=this.config.get_device_id(Dt());this.register_once({distinct_id:m,$device_id:m},""),this.persistence.set_property(Oe,"anonymous")}return ne(n,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),o.segment?vs(this,(()=>this._loaded())):this._loaded(),F(this.config._onCapture)&&this.config._onCapture!==yo&&(j.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this}_onRemoteConfig(e){var t,i,s,n,o,a,l,c;if(!d||!d.body)return j.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(e)}),500);this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=w(e.supportedCompression,r.GZipJS)?r.GZipJS:w(e.supportedCompression,r.Base64)?r.Base64:void 0),null!==(t=e.analytics)&&void 0!==t&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null===(i=this.siteApps)||void 0===i||i.onRemoteConfig(e),null===(s=this.sessionRecording)||void 0===s||s.onRemoteConfig(e),null===(n=this.autocapture)||void 0===n||n.onRemoteConfig(e),null===(o=this.heatmaps)||void 0===o||o.onRemoteConfig(e),this.surveys.onRemoteConfig(e),null===(a=this.webVitalsAutocapture)||void 0===a||a.onRemoteConfig(e),null===(l=this.exceptionObserver)||void 0===l||l.onRemoteConfig(e),null===(c=this.deadClicksAutocapture)||void 0===c||c.onRemoteConfig(e)}_loaded(){try{this.config.loaded(this)}catch(e){j.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{this.consent.isOptedIn()&&this._captureInitialPageview()}),1),new zn(this).load(),this.featureFlags.decide()}_start_queue_if_opted_in(){var e;this.has_opted_out_capturing()||this.config.request_batching&&(null===(e=this._requestQueue)||void 0===e||e.enable())}_dom_loaded(){this.has_opted_out_capturing()||G(this.__request_queue,(e=>this._send_retriable_request(e))),this.__request_queue=[],this._start_queue_if_opted_in()}_handle_unload(){var e,t;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),null===(e=this._requestQueue)||void 0===e||e.unload(),null===(t=this._retryQueue)||void 0===t||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(So?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Gn(e.url,{ip:this.config.ip?1:0}),e.headers=t({},this.config.request_headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var i,s,r,n=t({},e);n.timeout=n.timeout||6e4,n.url=Gn(n.url,{_:(new Date).getTime().toString(),ver:U.LIB_VERSION,compression:n.compression});var o=null!==(i=n.transport)&&void 0!==i?i:"fetch",a=null!==(s=null===(r=re(Kn,(e=>e.transport===o)))||void 0===r?void 0:r.method)&&void 0!==s?s:Kn[0].method;if(!a)throw new Error("No available transport method");a(n)})(t(t({},e),{},{callback:t=>{var i,s,r;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null===(s=(r=this.config).on_request_error)||void 0===s||s.call(r,t));null===(i=e.callback)||void 0===i||i.call(e,t)}}))))}_send_retriable_request(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}_execute_array(e){var t,i=[],s=[],r=[];G(e,(e=>{e&&(t=e[0],C(t)?r.push(e):F(e)?e.call(this):C(e)&&"alias"===t?i.push(e):C(e)&&-1!==t.indexOf("capture")&&F(this[t])?r.push(e):s.push(e))}));var n=function(e,t){G(e,(function(e){if(C(e[0])){var i=t;J(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};n(i,this),n(s,this),n(r,this)}_hasBootstrappedFeatureFlags(){var e,t;return(null===(e=this.config.bootstrap)||void 0===e?void 0:e.featureFlags)&&Object.keys(null===(t=this.config.bootstrap)||void 0===t?void 0:t.featureFlags).length>0||!1}push(e){this._execute_array([e])}capture(e,i,s){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!$(e)&&A(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var n=null!=s&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,a=(null==s?void 0:s.timestamp)||o,l=Dt(),c={uuid:l,event:e,properties:this._calculate_event_properties(e,i||{},a,l)};n&&(c.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==s?void 0:s.$set)&&(c.$set=null==s?void 0:s.$set);var u=this._calculate_set_once_properties(null==s?void 0:s.$set_once);u&&(c.$set_once=u),(c=te(c,null!=s&&s._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,$(null==s?void 0:s.timestamp)||(c.properties.$event_time_override_provided=!0,c.properties.$event_time_override_system_time=o);var d=t(t({},c.properties.$set),c.$set);if(T(d)||this.setPersonPropertiesForFlags(d),!L(this.config.before_send)){var h=this._runBeforeSend(c);if(!h)return;c=h}this._internalEventEmitter.emit("eventCaptured",c);var _={method:"POST",url:null!==(r=null==s?void 0:s._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:c,compression:"best-available",batchKey:null==s?void 0:s._batchKey};return!this.config.request_batching||s&&(null==s||!s._batchKey)||null!=s&&s.send_instantly?this._send_retriable_request(_):this._requestQueue.enqueue(_),c}j.critical("This capture call is ignored due to client rate limiting.")}}else j.error("No event name provided to posthog.capture")}else j.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}_calculate_event_properties(e,i,s,r){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;var n=this.persistence.remove_event_timer(e),o=t({},i);if(o.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(o.$cookieless_mode=!0),"$snapshot"===e){var a=t(t({},this.persistence.properties()),this.sessionPersistence.properties());return o.distinct_id=a.distinct_id,(!A(o.distinct_id)&&!D(o.distinct_id)||O(o.distinct_id))&&j.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),o}var l,c=zr.properties({maskPersonalDataProperties:this.config.mask_personal_data_properties,customPersonalDataProperties:this.config.custom_personal_data_properties});if(this.sessionManager){var{sessionId:u,windowId:h}=this.sessionManager.checkAndGetSessionAndWindowId();o.$session_id=u,o.$window_id=h}this.sessionPropsManager&&Y(o,this.sessionPropsManager.getSessionProps());try{var _,p;this.sessionRecording&&(o.$recording_status=this.sessionRecording.status,o.$sdk_debug_replay_internal_buffer_length=this.sessionRecording.buffer.data.length,o.$sdk_debug_replay_internal_buffer_size=this.sessionRecording.buffer.size),o.$sdk_debug_retry_queue_size=null===(_=this._retryQueue)||void 0===_||null===(p=_.queue)||void 0===p?void 0:p.length}catch(e){o.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===co.CUSTOM&&(o.$lib_custom_api_host=this.config.api_host),l="$pageview"===e?this.pageViewManager.doPageView(s,r):"$pageleave"===e?this.pageViewManager.doPageLeave(s):this.pageViewManager.doEvent(),o=Y(o,l),"$pageview"===e&&d&&(o.title=d.title),!$(n)){var g=s.getTime()-n;o.$duration=parseFloat((g/1e3).toFixed(3))}v&&this.config.opt_out_useragent_filter&&(o.$browser_type=this._is_bot()?"bot":"browser"),(o=Y({},c,this.persistence.properties(),this.sessionPersistence.properties(),o)).$is_identified=this._isIdentified(),C(this.config.property_denylist)?J(this.config.property_denylist,(function(e){delete o[e]})):j.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var f=this.config.sanitize_properties;f&&(j.error("sanitize_properties is deprecated. Use before_send instead"),o=f(o,e));var m=this._hasPersonProcessing();return o.$process_person_profile=m,m&&this._requirePersonProcessing("_calculate_event_properties"),o}_calculate_set_once_properties(e){var t;if(!this.persistence||!this._hasPersonProcessing())return e;if(this._personProcessingSetOncePropertiesSent)return e;var i=this.persistence.get_initial_props(),s=null===(t=this.sessionPropsManager)||void 0===t?void 0:t.getSetOnceProps(),r=Y({},i,s||{},e||{}),n=this.config.sanitize_properties;return n&&(j.error("sanitize_properties is deprecated. Use before_send instead"),r=n(r,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,T(r)?void 0:r}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var s;null===(s=this.persistence)||void 0===s||s.register_once(e,t,i)}register_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.register(e)}unregister(e){var t;null===(t=this.persistence)||void 0===t||t.unregister(e)}unregister_for_session(e){var t;null===(t=this.sessionPersistence)||void 0===t||t.unregister(e)}_register_single(e,t){this.register({[e]:t})}getFeatureFlag(e,t){return this.featureFlags.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch(e){return t}}isFeatureEnabled(e,t){return this.featureFlags.isFeatureEnabled(e,t)}reloadFeatureFlags(){this.featureFlags.reloadFeatureFlags()}updateEarlyAccessFeatureEnrollment(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}getEarlyAccessFeatures(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0;return this.featureFlags.getEarlyAccessFeatures(e,t,i)}on(e,t){return this._internalEventEmitter.on(e,t)}onFeatureFlags(e){return this.featureFlags.onFeatureFlags(e)}onSessionId(e){var t,i;return null!==(t=null===(i=this.sessionManager)||void 0===i?void 0:i.onSessionId(e))&&void 0!==t?t:()=>{}}getSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getSurveys(e,t)}getActiveMatchingSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.surveys.getActiveMatchingSurveys(e,t)}renderSurvey(e,t){this.surveys.renderSurvey(e,t)}canRenderSurvey(e){this.surveys.canRenderSurvey(e)}identify(e,i,s){if(!this.__loaded||!this.persistence)return j.uninitializedWarning("posthog.identify");if(D(e)&&(e=e.toString(),j.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),e){if(["distinct_id","distinctid"].includes(e.toLowerCase()))j.critical('The string "'.concat(e,'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'));else if(this._requirePersonProcessing("posthog.identify")){var r=this.get_distinct_id();if(this.register({$user_id:e}),!this.get_property("$device_id")){var n=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:n},"")}e!==r&&e!==this.get_property(ae)&&(this.unregister(ae),this.register({distinct_id:e}));var o="anonymous"===(this.persistence.get_property(Oe)||"anonymous");e!==r&&o?(this.persistence.set_property(Oe,"identified"),this.setPersonPropertiesForFlags(t(t({},s||{}),i||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:i||{},$set_once:s||{}}),this.featureFlags.setAnonymousDistinctId(r),this._cachedIdentify=po(e,i,s)):(i||s)&&(this._cachedIdentify!==po(e,i,s)?(this.setPersonProperties(i,s),this._cachedIdentify=po(e,i,s)):j.info("A duplicate posthog.identify call was made with the same properties. It has been ignored.")),e!==r&&(this.reloadFeatureFlags(),this.unregister(Ae))}}else j.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,i){(e||i)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(t(t({},i||{}),e||{})),this.capture("$set",{$set:e||{},$set_once:i||{}}))}group(e,i,s){if(e&&i){if(this._requirePersonProcessing("posthog.group")){var r=this.getGroups();r[e]!==i&&this.resetGroupPropertiesForFlags(e),this.register({$groups:t(t({},r),{},{[e]:i})}),s&&(this.capture("$groupidentify",{$group_type:e,$group_key:i,$group_set:s}),this.setGroupPropertiesForFlags({[e]:s})),r[e]===i||s||this.reloadFeatureFlags()}}else j.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this.featureFlags.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){this.featureFlags.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}resetGroupPropertiesForFlags(e){this.featureFlags.resetGroupPropertiesForFlags(e)}reset(e){var t,i,s,r;if(j.info("reset"),!this.__loaded)return j.uninitializedWarning("posthog.reset");var n=this.get_property("$device_id");if(this.consent.reset(),null===(t=this.persistence)||void 0===t||t.clear(),null===(i=this.sessionPersistence)||void 0===i||i.clear(),this.surveys.reset(),null===(s=this.persistence)||void 0===s||s.set_property(Oe,"anonymous"),null===(r=this.sessionManager)||void 0===r||r.resetSessionId(),this._cachedIdentify=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:Ue,$device_id:null},"");else{var o=this.config.get_device_id(Dt());this.register_once({distinct_id:o,$device_id:e?o:n},"")}this.register({$last_posthog_reset:(new Date).toISOString()},1)}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return null!==(e=null===(t=this.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)&&void 0!==e?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),s=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(t));if(null!=e&&e.withTimestamp&&i){var r,n=null!==(r=e.timestampLookBack)&&void 0!==r?r:10;if(!i)return s;var o=Math.max(Math.floor(((new Date).getTime()-i)/1e3)-n,0);s+="?t=".concat(o)}return s}alias(e,t){return e===this.get_property(oe)?(j.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?($(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(ae,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(j.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var i,s,r,n,o=t({},this.config);R(e)&&(Y(this.config,Eo(e)),null===(i=this.persistence)||void 0===i||i.update_config(this.config,o),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Wr(t(t({},this.config),{},{persistence:"sessionStorage"})),Vt.is_supported()&&"true"===Vt.get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(U.DEBUG=!0,j.info("set_config",{config:e,oldConfig:o,newConfig:t({},this.config)})),null===(s=this.sessionRecording)||void 0===s||s.startIfEnabledOrStop(),null===(r=this.autocapture)||void 0===r||r.startIfEnabled(),null===(n=this.heatmaps)||void 0===n||n.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}startSessionRecording(e){var t=!0===e,i={sampling:t||!(null==e||!e.sampling),linked_flag:t||!(null==e||!e.linked_flag),url_trigger:t||!(null==e||!e.url_trigger),event_trigger:t||!(null==e||!e.event_trigger)};if(Object.values(i).some(Boolean)){var s,r,n,o,a;if(null===(s=this.sessionManager)||void 0===s||s.checkAndGetSessionAndWindowId(),i.sampling)null===(r=this.sessionRecording)||void 0===r||r.overrideSampling();if(i.linked_flag)null===(n=this.sessionRecording)||void 0===n||n.overrideLinkedFlag();if(i.url_trigger)null===(o=this.sessionRecording)||void 0===o||o.overrideTrigger("url");if(i.event_trigger)null===(a=this.sessionRecording)||void 0===a||a.overrideTrigger("event")}this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!(null===(e=this.sessionRecording)||void 0===e||!e.started)}captureException(e,i){var s,r=new Error("PostHog syntheticException"),n=F(null===(s=f.__PosthogExtensions__)||void 0===s?void 0:s.parseErrorAsProperties)?t(t({},f.__PosthogExtensions__.parseErrorAsProperties(B(e)?{error:e,event:e.message}:{event:e},{syntheticException:r})),i):t({$exception_level:"error",$exception_list:[{type:B(e)?e.name:"Error",value:B(e)?e.message:R(e)&&"message"in e?String(e.message):String(e),mechanism:{handled:!0,synthetic:!1}}]},i);this.exceptions.sendExceptionEvent(n)}loadToolbar(e){return this.toolbar.loadToolbar(e)}get_property(e){var t;return null===(t=this.persistence)||void 0===t?void 0:t.props[e]}getSessionProperty(e){var t;return null===(t=this.sessionPersistence)||void 0===t?void 0:t.props[e]}toString(){var e,t=null!==(e=this.config.name)&&void 0!==e?e:wo;return t!==wo&&(t=wo+"."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property(Oe))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property(Oe))}_hasPersonProcessing(){var e,t,i,s;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&T(this.getGroups())&&(null===(e=this.persistence)||void 0===e||null===(t=e.props)||void 0===t||!t[ae])&&(null===(i=this.persistence)||void 0===i||null===(s=i.props)||void 0===s||!s[Be]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&this.config.capture_pageview}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(j.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Be,!0),!0)}_sync_opt_out_with_persistence(){var e,t,i,s,r=this.consent.isOptedOut(),n=this.config.opt_out_persistence_by_default,o=this.config.disable_persistence||r&&!!n;(null===(e=this.persistence)||void 0===e?void 0:e.disabled)!==o&&(null===(i=this.persistence)||void 0===i||i.set_disabled(o));(null===(t=this.sessionPersistence)||void 0===t?void 0:t.disabled)!==o&&(null===(s=this.sessionPersistence)||void 0===s||s.set_disabled(o))}opt_in_capturing(e){var t;(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),$(null==e?void 0:e.captureEventName)||null!=e&&e.captureEventName)&&this.capture(null!==(t=null==e?void 0:e.captureEventName)&&void 0!==t?t:"$opt_in",null==e?void 0:e.captureProperties,{send_instantly:!0});this.config.capture_pageview&&this._captureInitialPageview()}opt_out_capturing(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}clear_opt_in_out_capturing(){this.consent.reset(),this._sync_opt_out_with_persistence()}_is_bot(){return u?_o(u,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){d&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:d.title},{send_instantly:!0}))}debug(e){!1===e?(null==n||n.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==n||n.console.log("You're now in debug mode. All calls to PostHog will be logged in your console.\nYou can disable this with `posthog.debug(false)`."),localStorage&&localStorage.setItem("ph_debug","true"),this.set_config({debug:!0}))}_runBeforeSend(e){if(L(this.config.before_send))return e;var t=C(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var s of t){if(i=s(i),L(i)){var r="Event '".concat(e.event,"' was rejected in beforeSend function");return H(e.event)?j.warn("".concat(r,". This can cause unexpected behavior.")):j.info(r),null}i.properties&&!T(i.properties)||j.warn("Event '".concat(e.event,"' has no properties after beforeSend function, this is likely an error."))}return i}getPageViewId(){var e;return null===(e=this.pageViewManager._currentPageview)||void 0===e?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}}!function(e,t){for(var i=0;i<t.length;i++)e.prototype[t[i]]=Z(e.prototype[t[i]])}(Io,["identify"]);var Po,Co=(Po=bo[wo]=new Io,function(){function e(){e.done||(e.done=!0,So=!1,J(bo,(function(e){e._dom_loaded()})))}null!=d&&d.addEventListener?"complete"===d.readyState?e():ne(d,"DOMContentLoaded",e,{capture:!1}):n&&j.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")}(),Po);export{m as COPY_AUTOCAPTURE_EVENT,r as Compression,Io as PostHog,sn as SurveyQuestionBranchingType,tn as SurveyQuestionType,rn as SurveySchedule,en as SurveyType,Co as default,b as knownUnsafeEditableEvent,Co as posthog,y as severityLevels};
2
2
  //# sourceMappingURL=module.no-external.js.map