!function(){"use strict";var e,t="undefined"!=typeof window?window:void 0,i="undefined"!=typeof globalThis?globalThis:t,r=Array.prototype,n=r.forEach,s=r.indexOf,o=null==i?void 0:i.navigator,a=null==i?void 0:i.document,l=null==i?void 0:i.location,u=null==i?void 0:i.fetch,c=null!=i&&i.XMLHttpRequest&&"withCredentials"in new i.XMLHttpRequest?i.XMLHttpRequest:void 0,d=null==i?void 0:i.AbortController,_=null==o?void 0:o.userAgent,h=null!=t?t:{},p={DEBUG:!1,LIB_VERSION:"1.236.2"},v="$copy_autocapture",g=["$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"}(e||(e={}));var f=["fatal","error","warning","log","info","debug"];function m(e,t){return-1!==e.indexOf(t)}var y=function(e){return e.trim()},b=function(e){return e.replace(/^\$/,"")};var w=Array.isArray,S=Object.prototype,k=S.hasOwnProperty,E=S.toString,x=w||function(e){return"[object Array]"===E.call(e)},I=e=>"function"==typeof e,C=e=>e===Object(e)&&!x(e),P=e=>{if(C(e)){for(var t in e)if(k.call(e,t))return!1;return!0}return!1},F=e=>void 0===e,T=e=>"[object String]"==E.call(e),R=e=>T(e)&&0===e.trim().length,$=e=>null===e,O=e=>F(e)||$(e),M=e=>"[object Number]"==E.call(e),A=e=>"[object Boolean]"===E.call(e),L=e=>e instanceof FormData,D=e=>m(g,e),q=e=>{var i={_log:function(i){if(t&&(p.DEBUG||h.POSTHOG_DEBUG)&&!F(t.console)&&t.console){for(var r=("__rrweb_original__"in t.console[i]?t.console[i].__rrweb_original__:t.console[i]),n=arguments.length,s=new Array(n>1?n-1:0),o=1;o{i.error("You must initialize PostHog before calling ".concat(e))},createLogger:t=>q("".concat(e," ").concat(t))};return i},N=q("[PostHog.js]"),B=N.createLogger,H=B("[ExternalScriptsLoader]"),j=(e,t,i)=>{if(e.config.disable_external_dependency_loading)return H.warn("".concat(t," was requested but loading of external scripts is disabled.")),i("Loading of external scripts is disabled");var r=null==a?void 0:a.querySelectorAll("script");if(r)for(var n=0;n{if(!a)return i("document not found");var r=a.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=t,r.onload=e=>i(void 0,e),r.onerror=e=>i(e),e.config.prepare_external_dependency_script&&(r=e.config.prepare_external_dependency_script(r)),!r)return i("prepare_external_dependency_script returned null");var n,s=a.querySelectorAll("body > script");s.length>0?null===(n=s[0].parentNode)||void 0===n||n.insertBefore(r,s[0]):a.body.appendChild(r)};null!=a&&a.body?s():null==a||a.addEventListener("DOMContentLoaded",s)};function U(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),i.push.apply(i,r)}return i}function z(e){for(var t=1;t=0||(n[i]=e[i]);return n}(e,t);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(e);for(r=0;r=0||Object.prototype.propertyIsEnumerable.call(e,i)&&(n[i]=e[i])}return n}h.__PosthogExtensions__=h.__PosthogExtensions__||{},h.__PosthogExtensions__.loadExternalDependency=(e,t,i)=>{var r="/static/".concat(t,".js")+"?v=".concat(e.version);if("remote-config"===t&&(r="/array/".concat(e.config.token,"/config.js")),"toolbar"===t){var n=3e5,s=Math.floor(Date.now()/n)*n;r="".concat(r,"&t=").concat(s)}var o=e.requestRouter.endpointFor("assets",r);j(e,o,i)},h.__PosthogExtensions__.loadSiteApp=(e,t,i)=>{var r=e.requestRouter.endpointFor("api",t);j(e,r,i)};var V={};function J(e,t,i){if(x(e))if(n&&e.forEach===n)e.forEach(t,i);else if("length"in e&&e.length===+e.length)for(var r=0,s=e.length;r1?t-1:0),r=1;r1?t-1:0),r=1;r0&&(t[i]=e)})),t};function ie(e,t){return i=e,r=e=>T(e)&&!$(t)?e.slice(0,t):e,n=new Set,function e(t,i){return t!==Object(t)?r?r(t,i):t:n.has(t)?void 0:(n.add(t),x(t)?(s=[],J(t,(t=>{s.push(e(t))}))):(s={},Y(t,((t,i)=>{n.has(t)||(s[i]=e(t,i))}))),s);var s}(i);var i,r,n}var re=["herokuapp.com","vercel.app","netlify.app"];function ne(e){var t=null==e?void 0:e.hostname;if(!T(t))return!1;var i=t.split(".").slice(-2).join(".");for(var r of re)if(i===r)return!1;return!0}function se(e,t){for(var i=0;ii.match(e))))}function Ze(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 Xe(t)}function et(e){return O(e)?null:y(e).split(/(\s+)/).filter((e=>pt(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function tt(e){var t="";return ot(e)&&!at(e)&&e.childNodes&&e.childNodes.length&&Y(e.childNodes,(function(e){var i;Ye(e)&&e.textContent&&(t+=null!==(i=et(e.textContent))&&void 0!==i?i:"")})),y(t)}function it(e){return F(e.target)?e.srcElement||null:null!==(t=e.target)&&void 0!==t&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}var rt=["a","button","form","input","select","textarea","label"];function nt(e){var t=e.parentNode;return!(!t||!Ve(t))&&t}function st(e,i){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0,n=arguments.length>3?arguments[3]:void 0,s=arguments.length>4?arguments[4]:void 0;if(!t||!e||Je(e,"html")||!Ve(e))return!1;if(null!=r&&r.url_allowlist&&!Qe(r.url_allowlist))return!1;if(null!=r&&r.url_ignorelist&&Qe(r.url_ignorelist))return!1;if(null!=r&&r.dom_event_allowlist){var o=r.dom_event_allowlist;if(o&&!o.some((e=>i.type===e)))return!1}for(var a=!1,l=[e],u=!0,c=e;c.parentNode&&!Je(c,"body");)if(Ke(c.parentNode))l.push(c.parentNode.host),c=c.parentNode.host;else{if(!(u=nt(c)))break;if(n||rt.indexOf(u.tagName.toLowerCase())>-1)a=!0;else{var d=t.getComputedStyle(u);d&&"pointer"===d.getPropertyValue("cursor")&&(a=!0)}l.push(u),c=u}if(!function(e,t){var i=null==t?void 0:t.element_allowlist;if(F(i))return!0;var r=function(e){if(i.some((t=>e.tagName.toLowerCase()===t)))return{v:!0}};for(var n of e){var s=r(n);if("object"==typeof s)return s.v}return!1}(l,r))return!1;if(!function(e,t){var i=null==t?void 0:t.css_selector_allowlist;if(F(i))return!0;var r=function(e){if(i.some((t=>e.matches(t))))return{v:!0}};for(var n of e){var s=r(n);if("object"==typeof s)return s.v}return!1}(l,r))return!1;var _=t.getComputedStyle(e);if(_&&"pointer"===_.getPropertyValue("cursor")&&"click"===i.type)return!0;var h=e.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(s||["submit"]).indexOf(i.type)>=0;case"input":case"select":case"textarea":return(s||["change","click"]).indexOf(i.type)>=0;default:return a?(s||["click"]).indexOf(i.type)>=0:(s||["click"]).indexOf(i.type)>=0&&(rt.indexOf(h)>-1||"true"===e.getAttribute("contenteditable"))}}function ot(e){for(var t=e;t.parentNode&&!Je(t,"body");t=t.parentNode){var i=Ze(t);if(m(i,"ph-sensitive")||m(i,"ph-no-capture"))return!1}if(m(Ze(e),"ph-include"))return!0;var r=e.type||"";if(T(r))switch(r.toLowerCase()){case"hidden":case"password":return!1}var n=e.name||e.id||"";if(T(n)){if(/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,"")))return!1}return!0}function at(e){return!!(Je(e,"input")&&!["button","checkbox","submit","reset"].includes(e.type)||Je(e,"select")||Je(e,"textarea")||"true"===e.getAttribute("contenteditable"))}var lt="(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})",ut=new RegExp("^(?:".concat(lt,")$")),ct=new RegExp(lt),dt="\\d{3}-?\\d{2}-?\\d{4}",_t=new RegExp("^(".concat(dt,")$")),ht=new RegExp("(".concat(dt,")"));function pt(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1];if(O(e))return!1;if(T(e)){if(e=y(e),(t?ut:ct).test((e||"").replace(/[- ]/g,"")))return!1;if((t?_t:ht).test(e))return!1}return!0}function vt(e){var t=tt(e);return pt(t="".concat(t," ").concat(gt(e)).trim())?t:""}function gt(e){var t="";return e&&e.childNodes&&e.childNodes.length&&Y(e.childNodes,(function(e){var i;if(e&&"span"===(null===(i=e.tagName)||void 0===i?void 0:i.toLowerCase()))try{var r=tt(e);t="".concat(t," ").concat(r).trim(),e.childNodes&&e.childNodes.length&&(t="".concat(t," ").concat(gt(e)).trim())}catch(e){N.error("[AutoCapture]",e)}})),t}function ft(e){return function(e){var t=e.map((e=>{var t,i,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 s=z(z(z(z({},e.text?{text:e.text}:{}),{},{"nth-child":null!==(t=e.nth_child)&&void 0!==t?t:0,"nth-of-type":null!==(i=e.nth_of_type)&&void 0!==i?i:0},e.href?{href:e.href}:{}),e.attr_id?{attr_id:e.attr_id}:{}),e.attributes),o={};return Q(s).sort(((e,t)=>{var[i]=e,[r]=t;return i.localeCompare(r)})).forEach((e=>{var[t,i]=e;return o[mt(t.toString())]=mt(i.toString())})),r+=":",r+=Q(s).map((e=>{var[t,i]=e;return"".concat(t,'="').concat(i,'"')})).join("")}));return t.join(";")}(function(e){return e.map((e=>{var t,i,r={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:yt(e),attr_id:e.attr__id,nth_child:e.nth_child,nth_of_type:e.nth_of_type,attributes:{}};return Q(e).filter((e=>{var[t]=e;return 0===t.indexOf("attr__")})).forEach((e=>{var[t,i]=e;return r.attributes[t]=i})),r}))}(e))}function mt(e){return e.replace(/"|\\"/g,'\\"')}function yt(e){var t=e.attr__class;return t?x(t)?t:Xe(t):void 0}class bt{constructor(){this.clicks=[]}isRageClick(e,t,i){var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<30&&i-r.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 wt=["localhost","127.0.0.1"],St=e=>{var t=null==a?void 0:a.createElement("a");return F(t)?null:(t.href=e,t)},kt=function(e){var t,i,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"&",n=[];return Y(e,(function(e,r){F(e)||F(r)||"undefined"===r||(t=encodeURIComponent((e=>e instanceof File)(e)?e.name:e.toString()),i=encodeURIComponent(r),n[n.length]=i+"="+t)})),n.join(r)},Et=function(e,t){for(var i,r=((e.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),n=0;ne?t.slice(0,e)+"...":t}function Ft(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do{t=t.previousSibling}while(t&&!Ve(t));return t}function Tt(e,t,i,r){var n=e.tagName.toLowerCase(),s={tag_name:n};rt.indexOf(n)>-1&&!i&&("a"===n.toLowerCase()||"button"===n.toLowerCase()?s.$el_text=Pt(1024,vt(e)):s.$el_text=Pt(1024,tt(e)));var o=Ze(e);o.length>0&&(s.classes=o.filter((function(e){return""!==e}))),Y(e.attributes,(function(i){var n;if((!at(e)||-1!==["name","id","class","aria-label"].indexOf(i.name))&&((null==r||!r.includes(i.name))&&!t&&pt(i.value)&&(n=i.name,!T(n)||"_ngcontent"!==n.substring(0,10)&&"_nghost"!==n.substring(0,7)))){var o=i.value;"class"===i.name&&(o=Xe(o).join(" ")),s["attr__"+i.name]=Pt(1024,o)}}));for(var a=1,l=1,u=e;u=Ft(u);)a++,u.tagName===e.tagName&&l++;return s.nth_child=a,s.nth_of_type=l,s}function Rt(e,i){for(var r,n,{e:s,maskAllElementAttributes:o,maskAllText:a,elementAttributeIgnoreList:l,elementsChainAsString:u}=i,c=[e],d=e;d.parentNode&&!Je(d,"body");)Ke(d.parentNode)?(c.push(d.parentNode.host),d=d.parentNode.host):(c.push(d.parentNode),d=d.parentNode);var _,h=[],p={},v=!1,g=!1;if(Y(c,(e=>{var t=ot(e);"a"===e.tagName.toLowerCase()&&(v=e.getAttribute("href"),v=t&&v&&pt(v)&&v),m(Ze(e),"ph-no-capture")&&(g=!0),h.push(Tt(e,o,a,l));var i=function(e){if(!ot(e))return{};var t={};return Y(e.attributes,(function(e){if(e.name&&0===e.name.indexOf("data-ph-capture-attribute")){var i=e.name.replace("data-ph-capture-attribute-",""),r=e.value;i&&r&&pt(r)&&(t[i]=r)}})),t}(e);K(p,i)})),g)return{props:{},explicitNoCapture:g};if(a||("a"===e.tagName.toLowerCase()||"button"===e.tagName.toLowerCase()?h[0].$el_text=vt(e):h[0].$el_text=tt(e)),v){var f,y;h[0].attr__href=v;var b=null===(f=St(v))||void 0===f?void 0:f.host,w=null==t||null===(y=t.location)||void 0===y?void 0:y.host;b&&w&&b!==w&&(_=v)}return{props:K({$event_type:s.type,$ce_version:1},u?{}:{$elements:h},{$elements_chain:ft(h)},null!==(r=h[0])&&void 0!==r&&r.$el_text?{$el_text:null===(n=h[0])||void 0===n?void 0:n.$el_text}:{},_&&"click"===s.type?{$external_click_url:_}:{},p)}}class $t{constructor(e){W(this,"_initialized",!1),W(this,"_isDisabledServerSide",null),W(this,"rageclicks",new bt),W(this,"_elementsChainAsString",!1),this.instance=e,this._elementSelectors=null}get _config(){var e,t,i=C(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(t&&a){var e=e=>{e=e||(null==t?void 0:t.event);try{this._captureEvent(e)}catch(e){Ct.error("Failed to capture event",e)}};if(oe(a,"submit",e,{capture:!0}),oe(a,"change",e,{capture:!0}),oe(a,"click",e,{capture:!0}),this._config.capture_copied_text){var i=e=>{e=e||(null==t?void 0:t.event),this._captureEvent(e,v)};oe(a,"copy",i,{capture:!0}),oe(a,"cut",i,{capture:!0})}}}else Ct.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 r=null==a?void 0:a.querySelectorAll(t);null==r||r.forEach((r=>{e===r&&i.push(t)}))})),i}get isEnabled(){var e,t,i=null===(e=this.instance.persistence)||void 0===e?void 0:e.props[ce],r=this._isDisabledServerSide;if($(r)&&!A(i)&&!this.instance.config.advanced_disable_decide)return!1;var n=null!==(t=this._isDisabledServerSide)&&void 0!==t?t:!!i;return!!this.instance.config.autocapture&&!n}_captureEvent(e){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"$autocapture";if(this.isEnabled){var r,n=it(e);if(Ye(n)&&(n=n.parentNode||null),"$autocapture"===i&&"click"===e.type&&e instanceof MouseEvent)this.instance.config.rageclick&&null!==(r=this.rageclicks)&&void 0!==r&&r.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._captureEvent(e,"$rageclick");var s=i===v;if(n&&st(n,e,this._config,s,s?["copy","cut"]:void 0)){var{props:o,explicitNoCapture:a}=Rt(n,{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(n);if(l&&l.length>0&&(o.$element_selectors=l),i===v){var u,c=et(null==t||null===(u=t.getSelection())||void 0===u?void 0:u.toString()),d=e.type||"clipboard";if(!c)return!1;o.$selected_content=c,o.$copy_type=d}return this.instance.capture(i,o),!0}}}isBrowserSupported(){return I(null==a?void 0:a.querySelectorAll)}}Math.trunc||(Math.trunc=function(e){return e<0?Math.ceil(e):Math.floor(e)}),Number.isInteger||(Number.isInteger=function(e){return M(e)&&isFinite(e)&&Math.floor(e)===e});var Ot="0123456789abcdef";class Mt{constructor(e){if(this.bytes=e,16!==e.length)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||e<0||t<0||i<0||r<0||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new Mt(n)}toString(){for(var e="",t=0;t>>4)+Ot.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 Mt(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(){W(this,"_timestamp",0),W(this,"_counter",0),W(this,"_random",new qt)}generate(){var e=this.generateOrAbort();if(F(e)){this._timestamp=0;var t=this.generateOrAbort();if(F(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 Mt.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 Lt,Dt=e=>{if("undefined"!=typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var t=0;tcrypto.getRandomValues(e));class qt{constructor(){W(this,"_buffer",new Uint32Array(8)),W(this,"_cursor",1/0)}nextUint32(){return this._cursor>=this._buffer.length&&(Dt(this._buffer),this._cursor=0),this._buffer[this._cursor++]}}var Nt=()=>Bt().toString(),Bt=()=>(Lt||(Lt=new At)).generate(),Ht="Thu, 01 Jan 1970 00:00:00 GMT",jt="";var Ut=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function zt(e,t){if(t){var i=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:a;if(jt)return jt;if(!t)return"";if(["localhost","127.0.0.1"].includes(e))return"";for(var i=e.split("."),r=Math.min(i.length,8),n="dmn_chk_"+Nt(),s=new RegExp("(^|;)\\s*"+n+"=1");!jt&&r--;){var o=i.slice(r).join("."),l=n+"=1;domain=."+o;t.cookie=l,s.test(t.cookie)&&(t.cookie=l+";expires="+Ht,jt=o)}return jt}(e);if(!i){var r=(e=>{var t=e.match(Ut);return t?t[0]:""})(e);r!==i&&N.info("Warning: cookie subdomain discovery mismatch",r,i),i=r}return i?"; domain=."+i:""}return""}var Wt,Gt={is_supported:()=>!!a,error:function(e){N.error("cookieStore error: "+e)},get:function(e){if(a){try{for(var t=e+"=",i=a.cookie.split(";").filter((e=>e.length)),r=0;r3686.4&&N.warn("cookieStore warning: large cookie, len="+c.length),a.cookie=c,c}catch(e){return}},remove:function(e,t){try{Gt.set(e,"",-1,t)}catch(e){return}}},Vt=null,Jt={is_supported:function(){if(!$(Vt))return Vt;var e=!0;if(F(t))e=!1;else try{var i="__mplssupport__";Jt.set(i,"xyz"),'"xyz"'!==Jt.get(i)&&(e=!1),Jt.remove(i)}catch(t){e=!1}return e||N.error("localStorage unsupported; falling back to cookie store"),Vt=e,e},error:function(e){N.error("localStorage error: "+e)},get:function(e){try{return null==t?void 0:t.localStorage.getItem(e)}catch(e){Jt.error(e)}return null},parse:function(e){try{return JSON.parse(Jt.get(e))||{}}catch(e){}return null},set:function(e,i){try{null==t||t.localStorage.setItem(e,JSON.stringify(i))}catch(e){Jt.error(e)}},remove:function(e){try{null==t||t.localStorage.removeItem(e)}catch(e){Jt.error(e)}}},Yt=["distinct_id",Ee,xe,je,He],Kt=z(z({},Jt),{},{parse:function(e){try{var t={};try{t=Gt.parse(e)||{}}catch(e){}var i=K(t,JSON.parse(Jt.get(e)||"{}"));return Jt.set(e,i),i}catch(e){}return null},set:function(e,t,i,r,n,s){try{Jt.set(e,t,void 0,void 0,s);var o={};Yt.forEach((e=>{t[e]&&(o[e]=t[e])})),Object.keys(o).length&&Gt.set(e,o,i,r,n,s)}catch(e){Jt.error(e)}},remove:function(e,i){try{null==t||t.localStorage.removeItem(e),Gt.remove(e,i)}catch(e){Jt.error(e)}}}),Xt={},Qt={is_supported:function(){return!0},error:function(e){N.error("memoryStorage error: "+e)},get:function(e){return Xt[e]||null},parse:function(e){return Xt[e]||null},set:function(e,t){Xt[e]=t},remove:function(e){delete Xt[e]}},Zt=null,ei={is_supported:function(){if(!$(Zt))return Zt;if(Zt=!0,F(t))Zt=!1;else try{var e="__support__";ei.set(e,"xyz"),'"xyz"'!==ei.get(e)&&(Zt=!1),ei.remove(e)}catch(e){Zt=!1}return Zt},error:function(e){N.error("sessionStorage error: ",e)},get:function(e){try{return null==t?void 0:t.sessionStorage.getItem(e)}catch(e){ei.error(e)}return null},parse:function(e){try{return JSON.parse(ei.get(e))||null}catch(e){}return null},set:function(e,i){try{null==t||t.sessionStorage.setItem(e,JSON.stringify(i))}catch(e){ei.error(e)}},remove:function(e){try{null==t||t.sessionStorage.removeItem(e)}catch(e){ei.error(e)}}};!function(e){e[e.PENDING=-1]="PENDING",e[e.DENIED=0]="DENIED",e[e.GRANTED=1]="GRANTED"}(Wt||(Wt={}));class ti{constructor(e){this._instance=e}get _config(){return this._instance.config}get consent(){return this._getDnt()?Wt.DENIED:this._storedConsent}isOptedOut(){return this.consent===Wt.DENIED||this.consent===Wt.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?Wt.GRANTED:"0"===e?Wt.DENIED:Wt.PENDING}get _storage(){if(!this._persistentStore){var e=this._config.opt_out_capturing_persistence_type;this._persistentStore="localStorage"===e?Jt:Gt;var t="localStorage"===e?Gt:Jt;t.get(this._storageKey)&&(this._persistentStore.get(this._storageKey)||this.optInOut("1"===t.get(this._storageKey)),t.remove(this._storageKey,this._config.cross_subdomain_cookie))}return this._persistentStore}_getDnt(){return!!this._config.respect_dnt&&!!se([null==o?void 0:o.doNotTrack,null==o?void 0:o.msDoNotTrack,h.doNotTrack],(e=>m([!0,1,"1","yes"],e)))}}var ii=B("[Dead Clicks]"),ri=()=>!0,ni=e=>{var t,i=!(null===(t=e.instance.persistence)||void 0===t||!t.get_property(pe)),r=e.instance.config.capture_dead_clicks;return A(r)?r: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({[pe]:null==e?void 0:e.captureDeadClicks}),this.startIfEnabled()}startIfEnabled(){this.isEnabled(this)&&this._loadScript((()=>{this._start()}))}_loadScript(e){var t,i,r;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.initDeadClicksAutocapture&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(r=i.loadExternalDependency)||void 0===r||r.call(i,this.instance,"dead-clicks-autocapture",(t=>{t?ii.error("failed to load script",t):e()}))}_start(){var e;if(a){if(!this._lazyLoadedDeadClicksAutocapture&&null!==(e=h.__PosthogExtensions__)&&void 0!==e&&e.initDeadClicksAutocapture){var t=C(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this._lazyLoadedDeadClicksAutocapture=h.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this._lazyLoadedDeadClicksAutocapture.start(a),ii.info("starting...")}}else ii.error("`document` not found. Cannot start.")}stop(){this._lazyLoadedDeadClicksAutocapture&&(this._lazyLoadedDeadClicksAutocapture.stop(),this._lazyLoadedDeadClicksAutocapture=void 0,ii.info("stopping..."))}}var oi=B("[ExceptionAutocapture]");class ai{constructor(e){var i;W(this,"_startCapturing",(()=>{var e;if(t&&this.isEnabled&&null!==(e=h.__PosthogExtensions__)&&void 0!==e&&e.errorWrappingFunctions){var i=h.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=h.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=h.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this._unwrapOnError&&this.config.capture_unhandled_errors&&(this._unwrapOnError=i(this.captureException.bind(this))),!this._unwrapUnhandledRejection&&this.config.capture_unhandled_rejections&&(this._unwrapUnhandledRejection=r(this.captureException.bind(this))),!this._unwrapConsoleError&&this.config.capture_console_errors&&(this._unwrapConsoleError=n(this.captureException.bind(this)))}catch(e){oi.error("failed to start",e),this._stopCapturing()}}})),this.instance=e,this.remoteEnabled=!(null===(i=this.instance.persistence)||void 0===i||!i.props[_e]),this.config=this._requiredConfig(),this.startIfEnabled()}_requiredConfig(){var e=this.instance.config.capture_exceptions,t={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return C(e)?t=z(z({},t),e):(F(e)?this.remoteEnabled:e)&&(t=z(z({},t),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),t}get isEnabled(){return this.config.capture_console_errors||this.config.capture_unhandled_errors||this.config.capture_unhandled_rejections}startIfEnabled(){this.isEnabled&&(oi.info("enabled"),this._loadScript(this._startCapturing))}_loadScript(e){var t,i,r;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.errorWrappingFunctions&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(r=i.loadExternalDependency)||void 0===r||r.call(i,this.instance,"exception-autocapture",(t=>{if(t)return oi.error("failed to load script",t);e()}))}_stopCapturing(){var e,t,i;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,null===(i=this._unwrapConsoleError)||void 0===i||i.call(this),this._unwrapConsoleError=void 0}onRemoteConfig(e){var t=e.autocaptureExceptions;this.remoteEnabled=!!t||!1,this.config=this._requiredConfig(),this.instance.persistence&&this.instance.persistence.register({[_e]: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 li(e){return!F(Event)&&ui(e,Event)}function ui(e,t){try{return e instanceof t}catch(e){return!1}}function ci(e,t){return Object.prototype.toString.call(e)==="[object ".concat(t,"]")}function di(e){return ci(e,"DOMError")}var _i=/\(error: (.*)\)/,hi=50,pi="?";function vi(e,t,i,r){var n={platform:"web:javascript",filename:e,function:""===t?pi:t,in_app:!0};return F(i)||(n.lineno=i),F(r)||(n.colno=r),n}var gi=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,fi=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,mi=/\((\S*)(?::(\d+))(?::(\d+))\)/,yi=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,bi=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,wi=function(){for(var e=arguments.length,t=new Array(e),i=0;ie[0]-t[0])).map((e=>e[1]));return function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=[],n=e.split("\n"),s=t;s1024)){var a=_i.test(o)?o.replace(_i,"$1"):o;if(!a.match(/\S*Error: /)){for(var l of r){var u=l(a);if(u){i.push(u);break}}if(i.length>=hi)break}}}return function(e){if(!e.length)return[];var t=Array.from(e);return t.reverse(),t.slice(0,hi).map((e=>z(z({},e),{},{filename:e.filename||Si(t).filename,function:e.function||pi})))}(i)}}(...[[30,e=>{var t=gi.exec(e);if(t){var[,i,r,n]=t;return vi(i,pi,+r,+n)}var s=fi.exec(e);if(s){if(s[2]&&0===s[2].indexOf("eval")){var o=mi.exec(s[2]);o&&(s[2]=o[1],s[3]=o[2],s[4]=o[3])}var[a,l]=Ii(s[1]||pi,s[2]);return vi(l,a,s[3]?+s[3]:void 0,s[4]?+s[4]:void 0)}}],[50,e=>{var t=yi.exec(e);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=bi.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var r=t[3],n=t[1]||pi;return[n,r]=Ii(n,r),vi(r,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}}]]);function Si(e){return e[e.length-1]||{}}var ki,Ei,xi,Ii=(e,t)=>{var i=-1!==e.indexOf("safari-extension"),r=-1!==e.indexOf("safari-web-extension");return i||r?[-1!==e.indexOf("@")?e.split("@")[0]:pi,i?"safari-extension:".concat(t):"safari-web-extension:".concat(t)]:[e,t]};var Ci=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i;function Pi(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,i=e.stacktrace||e.stack||"",r=function(e){if(e&&Fi.test(e.message))return 1;return 0}(e);try{var n=wi,s=function(e,t){var i=function(e){var t=globalThis._posthogChunkIds;if(!t)return{};var i=Object.keys(t);return xi&&i.length===Ei||(Ei=i.length,xi=i.reduce(((i,r)=>{ki||(ki={});var n=ki[r];if(n)i[n[0]]=n[1];else for(var s=e(r),o=s.length-1;o>=0;o--){var a=s[o],l=null==a?void 0:a.filename,u=t[r];if(l&&u){i[l]=u,ki[r]=[l,u];break}}return i}),{})),xi}(t);return e.forEach((e=>{e.filename&&(e.chunk_id=i[e.filename])})),e}(n(i,r),n);return s.slice(0,s.length-t)}catch(e){}return[]}var Fi=/Minified React error #\d+;/i;function Ti(e,t){var i,r,n=Pi(e),s=null===(i=null==t?void 0:t.handled)||void 0===i||i,o=null!==(r=null==t?void 0:t.synthetic)&&void 0!==r&&r;return{$exception_list:[{type:null!=t&&t.overrideExceptionType?t.overrideExceptionType:e.name,value:function(e){var t=e.message;if(t.error&&"string"==typeof t.error.message)return String(t.error.message);return String(t)}(e),stacktrace:{frames:n,type:"raw"},mechanism:{handled:s,synthetic:o}}],$exception_level:"error"}}function Ri(e,t){var i,r,n,s=null===(i=null==t?void 0:t.handled)||void 0===i||i,o=null===(r=null==t?void 0:t.synthetic)||void 0===r||r,a={type:null!=t&&t.overrideExceptionType?t.overrideExceptionType:null!==(n=null==t?void 0:t.defaultExceptionType)&&void 0!==n?n:"Error",value:e||(null==t?void 0:t.defaultExceptionMessage),mechanism:{handled:s,synthetic:o}};if(null!=t&&t.syntheticException){var l=Pi(t.syntheticException,1);l.length&&(a.stacktrace={frames:l,type:"raw"})}return{$exception_list:[a],$exception_level:"error"}}function $i(e){return T(e)&&!R(e)&&f.indexOf(e)>=0}function Oi(e,t){var i,r,n=null===(i=null==t?void 0:t.handled)||void 0===i||i,s=null===(r=null==t?void 0:t.synthetic)||void 0===r||r,o=null!=t&&t.overrideExceptionType?t.overrideExceptionType:li(e)?e.constructor.name:"Error",a="Non-Error 'exception' captured with keys: ".concat(function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:40,i=Object.keys(e);if(i.sort(),!i.length)return"[object has no keys]";for(var r=i.length;r>0;r--){var n=i.slice(0,r).join(", ");if(!(n.length>t))return r===i.length||n.length<=t?n:"".concat(n.slice(0,t),"...")}return""}(e)),l={type:o,value:a,mechanism:{handled:n,synthetic:s}};if(null!=t&&t.syntheticException){var u=Pi(null==t?void 0:t.syntheticException,1);u.length&&(l.stacktrace={frames:u,type:"raw"})}return{$exception_list:[l],$exception_level:$i(e.level)?e.level:"error"}}function Mi(e,t){var{error:i,event:r}=e,n={$exception_list:[]},s=i||r;if(di(s)||function(e){return ci(e,"DOMException")}(s)){var o=s;if(function(e){return"stack"in e}(s))n=Ti(s,t);else{var a=o.name||(di(o)?"DOMError":"DOMException"),l=o.message?"".concat(a,": ").concat(o.message):a,u=di(o)?"DOMError":"DOMException";n=Ri(l,z(z({},t),{},{overrideExceptionType:u,defaultExceptionMessage:l}))}return"code"in o&&(n.$exception_DOMException_code="".concat(o.code)),n}if(function(e){return ci(e,"ErrorEvent")}(s)&&s.error)return Ti(s.error,t);if(function(e){switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":return!0;default:return ui(e,Error)}}(s))return Ti(s,t);if(function(e){return ci(e,"Object")}(s)||li(s))return Oi(s,t);if(F(i)&&T(r)){var c="Error",d=r,_=r.match(Ci);return _&&(c=_[1],d=_[2]),Ri(d,z(z({},t),{},{overrideExceptionType:c,defaultExceptionMessage:d}))}return Ri(s,t)}function Ai(e){var t,i;return(null===(t=JSON.stringify(e,(i=[],function(e,t){if(C(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 Li(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),r=e.data.slice(0,i),n=e.data.slice(i);return[Li({size:Ai(r),data:r,sessionId:e.sessionId,windowId:e.windowId}),Li({size:Ai(n),data:n,sessionId:e.sessionId,windowId:e.windowId})].flatMap((e=>e))}return[e]}var Di=(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))(Di||{}),qi=(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))(qi||{}),Ni="[SessionRecording]",Bi="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"]},ji=["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"],Ui=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],zi=["/s/","/e/","/i/"];function Wi(e,t,i,r){if(O(e))return e;var n=(null==t?void 0:t["content-length"])||function(e){return new Blob([e]).size}(e);return T(n)&&(n=parseInt(n)),n>i?Ni+" ".concat(r," body too large to record (").concat(n," bytes)"):e}function Gi(e,t){if(O(e))return e;var i=e;return pt(i,!1)||(i=Ni+" "+t+" body "+Bi),Y(Ui,(e=>{var r,n;null!==(r=i)&&void 0!==r&&r.length&&-1!==(null===(n=i)||void 0===n?void 0:n.indexOf(e))&&(i=Ni+" "+t+" body "+Bi+" as might contain: "+e)})),i}var Vi=(e,t)=>{var i,r,n,s={payloadSizeLimitBytes:Hi.payloadSizeLimitBytes,performanceEntryTypeToObserve:[...Hi.performanceEntryTypeToObserve],payloadHostDenyList:[...t.payloadHostDenyList||[],...Hi.payloadHostDenyList]},o=!1!==e.session_recording.recordHeaders&&t.recordHeaders,a=!1!==e.session_recording.recordBody&&t.recordBody,l=!1!==e.capture_performance&&t.recordPerformance,u=(i=s,n=Math.min(1e6,null!==(r=i.payloadSizeLimitBytes)&&void 0!==r?r:1e6),e=>(null!=e&&e.requestBody&&(e.requestBody=Wi(e.requestBody,e.requestHeaders,n,"Request")),null!=e&&e.responseBody&&(e.responseBody=Wi(e.responseBody,e.responseHeaders,n,"Response")),e)),c=t=>{return u(((e,t)=>{var i,r=St(e.name),n=0===t.indexOf("http")?null===(i=St(t))||void 0===i?void 0:i.pathname:t;"/"===n&&(n="");var s=null==r?void 0:r.pathname.replace(n||"","");if(!(r&&s&&zi.some((e=>0===s.indexOf(e)))))return e})((r=(i=t).requestHeaders,O(r)||Y(Object.keys(null!=r?r:{}),(e=>{ji.includes(e.toLowerCase())&&(r[e]=Bi)})),i),e.api_host));var i,r},d=I(e.session_recording.maskNetworkRequestFn);return d&&I(e.session_recording.maskCapturedNetworkRequestFn)&&N.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),d&&(e.session_recording.maskCapturedNetworkRequestFn=t=>{var i=e.session_recording.maskNetworkRequestFn({url:t.name});return z(z({},t),{},{name:null==i?void 0:i.url})}),s.maskRequestFn=I(e.session_recording.maskCapturedNetworkRequestFn)?t=>{var i,r,n,s=c(t);return s&&null!==(i=null===(r=(n=e.session_recording).maskCapturedNetworkRequestFn)||void 0===r?void 0:r.call(n,s))&&void 0!==i?i:void 0}:e=>function(e){if(!F(e))return e.requestBody=Gi(e.requestBody,"Request"),e.responseBody=Gi(e.responseBody,"Response"),e}(c(e)),z(z(z({},Hi),s),{},{recordHeaders:o,recordBody:a,recordPerformance:l,recordInitialRequests:l})};function Ji(e,t,i,r,n){return t>i&&(N.warn("min cannot be greater than max."),t=i),M(e)?e>i?(r&&N.warn(r+" cannot be greater than max: "+i+". Using max value instead."),i):e1&&void 0!==arguments[1]?arguments[1]:{};W(this,"_bucketSize",100),W(this,"_refillRate",10),W(this,"_mutationBuckets",{}),W(this,"_loggedTracker",{}),W(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]}))})),W(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]})),W(this,"_numberOfChanges",(e=>{var t,i,r,n,s,o,a,l;return(null!==(t=null===(i=e.removes)||void 0===i?void 0:i.length)&&void 0!==t?t:0)+(null!==(r=null===(n=e.attributes)||void 0===n?void 0:n.length)&&void 0!==r?r:0)+(null!==(s=null===(o=e.texts)||void 0===o?void 0:o.length)&&void 0!==s?s:0)+(null!==(a=null===(l=e.adds)||void 0===l?void 0:l.length)&&void 0!==a?a:0)})),W(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,r,[n,s]=this._getNodeOrRelevantParent(e.id);if(0===this._mutationBuckets[n])return!1;(this._mutationBuckets[n]=null!==(t=this._mutationBuckets[n])&&void 0!==t?t:this._bucketSize,this._mutationBuckets[n]=Math.max(this._mutationBuckets[n]-1,0),0===this._mutationBuckets[n])&&(this._loggedTracker[n]||(this._loggedTracker[n]=!0,null===(i=(r=this._options).onBlockedNode)||void 0===i||i.call(r,n,s)));return e})));var r=this._numberOfChanges(t);return 0!==r||i===r?e:void 0})),this._rrweb=e,this._options=r,this._refillRate=Ji(null!==(t=this._options.refillRate)&&void 0!==t?t:this._refillRate,0,100,"mutation throttling refill rate"),this._bucketSize=Ji(null!==(i=this._options.bucketSize)&&void 0!==i?i:this._bucketSize,0,100,"mutation throttling bucket size"),setInterval((()=>{this._refillBuckets()}),1e3)}}var Ki=Uint8Array,Xi=Uint16Array,Qi=Uint32Array,Zi=new Ki([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]),er=new Ki([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]),tr=new Ki([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),ir=function(e,t){for(var i=new Xi(31),r=0;r<31;++r)i[r]=t+=1<>>1|(21845&lr)<<1;ur=(61680&(ur=(52428&ur)>>>2|(13107&ur)<<2))>>>4|(3855&ur)<<4,ar[lr]=((65280&ur)>>>8|(255&ur)<<8)>>>1}var cr=function(e,t,i){for(var r=e.length,n=0,s=new Xi(t);n>>l]=u}else for(o=new Xi(r),n=0;n>>15-e[n];return o},dr=new Ki(288);for(lr=0;lr<144;++lr)dr[lr]=8;for(lr=144;lr<256;++lr)dr[lr]=9;for(lr=256;lr<280;++lr)dr[lr]=7;for(lr=280;lr<288;++lr)dr[lr]=8;var _r=new Ki(32);for(lr=0;lr<32;++lr)_r[lr]=5;var hr=cr(dr,9,0),pr=cr(_r,5,0),vr=function(e){return(e/8>>0)+(7&e&&1)},gr=function(e,t,i){(null==i||i>e.length)&&(i=e.length);var r=new(e instanceof Xi?Xi:e instanceof Qi?Qi:Ki)(i-t);return r.set(e.subarray(t,i)),r},fr=function(e,t,i){i<<=7&t;var r=t/8>>0;e[r]|=i,e[r+1]|=i>>>8},mr=function(e,t,i){i<<=7&t;var r=t/8>>0;e[r]|=i,e[r+1]|=i>>>8,e[r+2]|=i>>>16},yr=function(e,t){for(var i=[],r=0;r_&&(_=s[r].s);var h=new Xi(_+1),p=br(i[c-1],h,0);if(p>t){r=0;var v=0,g=p-t,f=1<t))break;v+=f-(1<>>=g;v>0;){var y=s[r].s;h[y]=0&&v;--r){var b=s[r].s;h[b]==t&&(--h[b],++v)}p=t}return[new Ki(h),p]},br=function(e,t,i){return-1==e.s?Math.max(br(e.l,t,i+1),br(e.r,t,i+1)):t[e.s]=i},wr=function(e){for(var t=e.length;t&&!e[--t];);for(var i=new Xi(++t),r=0,n=e[0],s=1,o=function(e){i[r++]=e},a=1;a<=t;++a)if(e[a]==n&&a!=t)++s;else{if(!n&&s>2){for(;s>138;s-=138)o(32754);s>2&&(o(s>10?s-11<<5|28690:s-3<<5|12305),s=0)}else if(s>3){for(o(n),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(n);s=1,n=e[a]}return[i.subarray(0,r),t]},Sr=function(e,t){for(var i=0,r=0;r>>8,e[n+2]=255^e[n],e[n+3]=255^e[n+1];for(var s=0;s4&&!I[tr[P-1]];--P);var F,T,R,$,O=u+5<<3,M=Sr(n,dr)+Sr(s,_r)+o,A=Sr(n,_)+Sr(s,v)+o+14+3*P+Sr(k,I)+(2*k[16]+3*k[17]+7*k[18]);if(O<=M&&O<=A)return kr(t,c,e.subarray(l,l+u));if(fr(t,c,1+(A15&&(fr(t,c,N[E]>>>5&127),c+=N[E]>>>12)}}}else F=hr,T=dr,R=pr,$=_r;for(E=0;E255){B=r[E]>>>18&31;mr(t,c,F[B+257]),c+=T[B+257],B>7&&(fr(t,c,r[E]>>>23&31),c+=Zi[B]);var H=31&r[E];mr(t,c,R[H]),c+=$[H],H>3&&(mr(t,c,r[E]>>>5&8191),c+=er[H])}else mr(t,c,F[r[E]]),c+=T[r[E]];return mr(t,c,F[256]),c+T[256]},xr=new Qi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ir=function(){for(var e=new Qi(256),t=0;t<256;++t){for(var i=t,r=9;--r;)i=(1&i&&3988292384)^i>>>1;e[t]=i}return e}(),Cr=function(){var e=4294967295;return{p:function(t){for(var i=e,r=0;r>>8;e=i},d:function(){return 4294967295^e}}},Pr=function(e,t,i,r,n){return function(e,t,i,r,n,s){var o=e.length,a=new Ki(r+o+5*(1+Math.floor(o/7e3))+n),l=a.subarray(r,a.length-n),u=0;if(!t||o<8)for(var c=0;c<=o;c+=65535){var d=c+65535;d>>13,p=8191&_,v=(1<7e3||I>24576)&&$>423){u=Er(e,l,0,w,S,k,x,I,P,c-P,u),I=E=x=0,P=c;for(var O=0;O<286;++O)S[O]=0;for(O=0;O<30;++O)k[O]=0}var M=2,A=0,L=p,D=T-R&32767;if($>2&&F==b(c-D))for(var q=Math.min(h,$)-1,N=Math.min(32767,c),B=Math.min(258,$);D<=N&&--L&&T!=R;){if(e[c+M]==e[c+M-D]){for(var H=0;HM){if(M=H,A=D,H>q)break;var j=Math.min(D,H-2),U=0;for(O=0;OU&&(U=W,R=z)}}}D+=(T=R)-(R=g[T])+32768&32767}if(A){w[I++]=268435456|sr[M]<<18|or[A];var G=31&sr[M],V=31&or[A];x+=Zi[G]+er[V],++S[257+G],++k[V],C=c+M,++E}else w[I++]=e[c],++S[e[c]]}}u=Er(e,l,s,w,S,k,x,I,P,c-P,u)}return gr(a,0,r+vr(u)+n)}(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,r,!n)},Fr=function(e,t,i){for(;i;++t)e[t]=i,i>>>=8},Tr=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&&Fr(e,4,Math.floor(new Date(t.mtime||Date.now())/1e3)),i){e[3]=8;for(var r=0;r<=i.length;++r)e[r+10]=i.charCodeAt(r)}},Rr=function(e){return 10+(e.filename&&e.filename.length+1||0)};function $r(e,t){void 0===t&&(t={});var i=Cr(),r=e.length;i.p(e);var n=Pr(e,t,Rr(t),8),s=n.length;return Tr(n,t),Fr(n,s-8,i.d()),Fr(n,s-4,r),n}function Or(e,t){var i=e.length;if("undefined"!=typeof TextEncoder)return(new TextEncoder).encode(e);for(var r=new Ki(e.length+(e.length>>>1)),n=0,s=function(e){r[n++]=e},o=0;or.length){var a=new Ki(n+8+(i-o<<1));a.set(r),r=a}var l=e.charCodeAt(o);l<128||t?s(l):l<2048?(s(192|l>>>6),s(128|63&l)):l>55295&&l<57344?(s(240|(l=65536+(1047552&l)|1023&e.charCodeAt(++o))>>>18),s(128|l>>>12&63),s(128|l>>>6&63),s(128|63&l)):(s(224|l>>>12),s(128|l>>>6&63),s(128|63&l))}return gr(r,0,n)}function Mr(e,t){return function(e){for(var t=0,i=0;i({rrwebMethod:e,enqueuedAt:Date.now(),attempt:1});function Hr(e){return function(e,t){for(var i="",r=0;r>10,56320|1023&n))}return i}($r(Or(JSON.stringify(e))),!0)}function jr(e){return e.type===Di.Custom&&"sessionIdle"===e.data.tag}function Ur(e,t){return t.some((t=>"regex"===t.matching&&new RegExp(t.url).test(e)))}class zr{get _sessionIdleThresholdMilliseconds(){return this._instance.config.session_recording.session_idle_threshold_ms||3e5}get started(){return this._captureStarted}get _sessionManager(){if(!this._instance.sessionManager)throw new Error(Ar+" 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:qr}get _isSampled(){var e=this._instance.get_property(xe);return A(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:r}=this._sessionManager.checkAndGetSessionAndWindowId(!0);return i?i.timestamp-r:null}get _isRecordingEnabled(){var e=!!this._instance.get_property(ge),i=!this._instance.config.disable_session_recording;return t&&e&&i}get _isConsoleLogCaptureEnabled(){var e=!!this._instance.get_property(fe),t=this._instance.config.enable_recording_console_log;return null!=t?t:e}get _canvasRecording(){var e,t,i,r,n,s,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,u=null!==(i=null!==(r=null==o?void 0:o.canvasFps)&&void 0!==r?r:null==a?void 0:a.fps)&&void 0!==i?i:4,c=null!==(n=null!==(s=null==o?void 0:o.canvasQuality)&&void 0!==s?s:null==a?void 0:a.quality)&&void 0!==n?n:.4;if("string"==typeof c){var d=parseFloat(c);c=isNaN(d)?.4:d}return{enabled:l,fps:Ji(u,0,12,"canvas recording fps",4),quality:Ji(c,0,1,"canvas recording quality",.4)}}get _networkPayloadCapture(){var e,t,i=this._instance.get_property(me),r={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},n=(null==r?void 0:r.recordHeaders)||(null==i?void 0:i.recordHeaders),s=(null==r?void 0:r.recordBody)||(null==i?void 0:i.recordBody),o=C(this._instance.config.capture_performance)?this._instance.config.capture_performance.network_timing:this._instance.config.capture_performance,a=!!(A(o)?o:null==i?void 0:i.capturePerformance);return n||s||a?{recordHeaders:n,recordBody:s,recordPerformance:a}:void 0}get _masking(){var e,t,i,r,n,s,o=this._instance.get_property(ye),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!==(r=null==a?void 0:a.maskAllInputs)&&void 0!==r?r:null==o?void 0:o.maskAllInputs,u=null!==(n=null==a?void 0:a.maskTextSelector)&&void 0!==n?n:null==o?void 0:o.maskTextSelector,c=null!==(s=null==a?void 0:a.blockSelector)&&void 0!==s?s:null==o?void 0:o.blockSelector;return F(l)&&F(u)&&F(c)?void 0:{maskAllInputs:null==l||l,maskTextSelector:u,blockSelector:c}}get _sampleRate(){var e=this._instance.get_property(we);return M(e)?e:null}get _minimumDuration(){var e=this._instance.get_property(Se);return M(e)?e:null}get status(){return this._receivedDecide?this._isRecordingEnabled?!1===this._isSampled?"disabled":this._urlBlocked?"paused":O(this._linkedFlag)||this._linkedFlagSeen?"trigger_pending"===this._triggerStatus?"buffering":A(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(Ie))===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(Ce))===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(W(this,"_queuedRRWebEvents",[]),W(this,"_isIdle","unknown"),W(this,"_linkedFlagSeen",!1),W(this,"_lastActivityTimestamp",Date.now()),W(this,"_linkedFlag",null),W(this,"_removePageViewCaptureHook",void 0),W(this,"_onSessionIdListener",void 0),W(this,"_persistDecideOnSessionListener",void 0),W(this,"_samplingSessionListener",void 0),W(this,"_urlTriggers",[]),W(this,"_urlBlocklist",[]),W(this,"_urlBlocked",!1),W(this,"_eventTriggers",[]),W(this,"_removeEventTriggerCaptureHook",void 0),W(this,"_forceAllowLocalhostNetworkCapture",!1),W(this,"_onBeforeUnload",(()=>{this._flushBuffer()})),W(this,"_onOffline",(()=>{this._tryAddCustomEvent("browser offline",{})})),W(this,"_onOnline",(()=>{this._tryAddCustomEvent("browser online",{})})),W(this,"_onVisibilityChange",(()=>{if(null!=a&&a.visibilityState){var e="window "+a.visibilityState;this._tryAddCustomEvent(e,{})}})),this._instance=e,this._captureStarted=!1,this._endpoint="/s/",this._stopRrweb=void 0,this._receivedDecide=!1,!this._instance.sessionManager)throw Lr.error("started without valid sessionManager"),new Error(Ar+" started without valid sessionManager. This is a bug.");if(this._instance.config.__preview_experimental_cookieless_mode)throw new Error(Ar+" cannot be used with __preview_experimental_cookieless_mode.");var{sessionId:t,windowId:i}=this._sessionManager.checkAndGetSessionAndWindowId();this._sessionId=t,this._windowId=i,this._buffer=this._clearBuffer(),this._sessionIdleThresholdMilliseconds>=this._sessionManager.sessionTimeoutMs&&Lr.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),oe(t,"beforeunload",this._onBeforeUnload),oe(t,"offline",this._onOffline),oe(t,"online",this._onOnline),oe(t,"visibilitychange",this._onVisibilityChange),this._setupSampling(),this._addEventTriggerListener(),O(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){Lr.error("Could not add $pageview to rrweb session",e)}}))),this._onSessionIdListener||(this._onSessionIdListener=this._sessionManager.onSessionId(((e,t,i)=>{var r,n,s,o;i&&(this._tryAddCustomEvent("$session_id_change",{sessionId:e,windowId:t,changeReason:i}),null===(r=this._instance)||void 0===r||null===(n=r.persistence)||void 0===n||n.unregister(Ce),null===(s=this._instance)||void 0===s||null===(o=s.persistence)||void 0===o||o.unregister(Ie))})))):this.stopRecording()}stopRecording(){var e,i,r,n;this._captureStarted&&this._stopRrweb&&(this._stopRrweb(),this._stopRrweb=void 0,this._captureStarted=!1,null==t||t.removeEventListener("beforeunload",this._onBeforeUnload),null==t||t.removeEventListener("offline",this._onOffline),null==t||t.removeEventListener("online",this._onOnline),null==t||t.removeEventListener("visibilitychange",this._onVisibilityChange),this._clearBuffer(),clearInterval(this._fullSnapshotTimer),null===(e=this._removePageViewCaptureHook)||void 0===e||e.call(this),this._removePageViewCaptureHook=void 0,null===(i=this._removeEventTriggerCaptureHook)||void 0===i||i.call(this),this._removeEventTriggerCaptureHook=void 0,null===(r=this._onSessionIdListener)||void 0===r||r.call(this),this._onSessionIdListener=void 0,null===(n=this._samplingSessionListener)||void 0===n||n.call(this),this._samplingSessionListener=void 0,Lr.info("stopped"))}_resetSampling(){var e;null===(e=this._instance.persistence)||void 0===e||e.unregister(xe)}_makeSamplingDecision(e){var t,i=this._sessionId!==e,r=this._sampleRate;if(M(r)){var n=this._isSampled,s=i||!A(n),o=s?Mr(e,r):n;s&&(o?this._reportStarted("sampled"):Lr.warn("Sample rate (".concat(r,") has determined that this sessionId (").concat(e,") will not be sent to the server.")),this._tryAddCustomEvent("samplingDecisionMade",{sampleRate:r,isSampled:o})),null===(t=this._instance.persistence)||void 0===t||t.register({[xe]:o})}else this._resetSampling()}onRemoteConfig(e){var t,i,r,n,s,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(),!O(this._linkedFlag)&&!this._linkedFlagSeen){var a=T(this._linkedFlag)?this._linkedFlag:this._linkedFlag.flag,l=T(this._linkedFlag)?null:this._linkedFlag.variant;this._instance.onFeatureFlags(((e,t)=>{var i=C(t)&&a in t,r=l?t[a]===l:i;r&&this._reportStarted("linked_flag_matched",{linkedFlag:a,linkedVariant:l}),this._linkedFlagSeen=r}))}null!==(r=e.sessionRecording)&&void 0!==r&&r.urlTriggers&&(this._urlTriggers=e.sessionRecording.urlTriggers),null!==(n=e.sessionRecording)&&void 0!==n&&n.urlBlocklist&&(this._urlBlocklist=e.sessionRecording.urlBlocklist),null!==(s=e.sessionRecording)&&void 0!==s&&s.eventTriggers&&(this._eventTriggers=e.sessionRecording.eventTriggers),this._receivedDecide=!0,this.startIfEnabledOrStop()}_setupSampling(){M(this._sampleRate)&&O(this._samplingSessionListener)&&(this._samplingSessionListener=this._sessionManager.onSessionId((e=>{this._makeSamplingDecision(e)})))}_persistRemoteConfig(e){if(this._instance.persistence){var t,i=this._instance.persistence,r=()=>{var t,r,n,s,o,a,l,u,c,d=null===(t=e.sessionRecording)||void 0===t?void 0:t.sampleRate,_=O(d)?null:parseFloat(d);O(_)&&this._resetSampling();var h=null===(r=e.sessionRecording)||void 0===r?void 0:r.minimumDurationMilliseconds;i.register({[ge]:!!e.sessionRecording,[fe]:null===(n=e.sessionRecording)||void 0===n?void 0:n.consoleLogRecordingEnabled,[me]:z({capturePerformance:e.capturePerformance},null===(s=e.sessionRecording)||void 0===s?void 0:s.networkPayloadCapture),[ye]:null===(o=e.sessionRecording)||void 0===o?void 0:o.masking,[be]:{enabled:null===(a=e.sessionRecording)||void 0===a?void 0:a.recordCanvas,fps:null===(l=e.sessionRecording)||void 0===l?void 0:l.canvasFps,quality:null===(u=e.sessionRecording)||void 0===u?void 0:u.canvasQuality},[we]:_,[Se]:F(h)?null:h,[ke]:null===(c=e.sessionRecording)||void 0===c?void 0:c.scriptConfig})};r(),null===(t=this._persistDecideOnSessionListener)||void 0===t||t.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(!F(Object.assign)&&!F(Array.from)&&!(this._captureStarted||this._instance.config.disable_session_recording||this._instance.consent.isOptedOut())){var t,i;if(this._captureStarted=!0,this._sessionManager.checkAndGetSessionAndWindowId(),Dr())this._onScriptLoaded();else null===(t=h.__PosthogExtensions__)||void 0===t||null===(i=t.loadExternalDependency)||void 0===i||i.call(t,this._instance,this._scriptName,(e=>{if(e)return Lr.error("could not load recorder",e);this._onScriptLoaded()}));Lr.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(ke))||void 0===i?void 0:i.script)||"recorder"}_isInteractiveEvent(e){var t;return 3===e.type&&-1!==Nr.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)){var r="unknown"===this._isIdle;this._isIdle=!1,r||(this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)}if(!this._isIdle){var{windowId:n,sessionId:s}=this._sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),o=this._sessionId!==s,a=this._windowId!==n;this._windowId=n,this._sessionId=s,o||a?(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}):Lr.warn("could not emit queued rrweb event.",t,e),!1}}_tryAddCustomEvent(e,t){return this._tryRRWebMethod(Br((()=>Dr().addCustomEvent(e,t))))}_tryTakeFullSnapshot(){return this._tryRRWebMethod(Br((()=>Dr().takeFullSnapshot())))}_onScriptLoaded(){var e,t,i,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},s=this._instance.config.session_recording;for(var[o,a]of Object.entries(s||{}))o in n&&("maskInputOptions"===o?n.maskInputOptions=z({password:!0},a):n[o]=a);(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===(t=this._masking.maskAllInputs)||void 0===t||t,n.maskTextSelector=null!==(i=this._masking.maskTextSelector)&&void 0!==i?i:void 0,n.blockSelector=null!==(r=this._masking.blockSelector)&&void 0!==r?r:void 0);var l=Dr();if(l){this._mutationRateLimiter=null!==(e=this._mutationRateLimiter)&&void 0!==e?e:new Yi(l,{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");Lr.info(i,{node:t}),this.log(Ar+" "+i,"warn")}});var u=this._gatherRRWebPlugins();this._stopRrweb=l(z({emit:e=>{this.onRRwebEmit(e)},plugins:u},n)),this._lastActivityTimestamp=Date.now(),this._isIdle=A(this._isIdle)?this._isIdle:"unknown",this._tryAddCustomEvent("$session_options",{sessionRecordingOptions:n,activePlugins:u.map((e=>null==e?void 0:e.name))}),this._tryAddCustomEvent("$posthog_config",{config:this._instance.config})}else Lr.error("onScriptLoaded was called but rrwebRecord is not available. This indicates something has gone wrong.")}_scheduleFullSnapshot(){if(this._fullSnapshotTimer&&clearInterval(this._fullSnapshotTimer),!0!==this._isIdle){var e=this._fullSnapshotIntervalMillis;e&&(this._fullSnapshotTimer=setInterval((()=>{this._tryTakeFullSnapshot()}),e))}}_gatherRRWebPlugins(){var e,t,i,r,n=[],s=null===(e=h.__PosthogExtensions__)||void 0===e||null===(t=e.rrwebPlugins)||void 0===t?void 0:t.getRecordConsolePlugin;s&&this._isConsoleLogCaptureEnabled&&n.push(s());var o=null===(i=h.__PosthogExtensions__)||void 0===i||null===(r=i.rrwebPlugins)||void 0===r?void 0:r.getRecordNetworkPlugin;this._networkPayloadCapture&&I(o)&&(!wt.includes(location.hostname)||this._forceAllowLocalhostNetworkCapture?n.push(o(Vi(this._instance.config,this._networkPayloadCapture))):Lr.info("NetworkCapture not started because we are on localhost."));return n}onRRwebEmit(e){var t;if(this._processQueuedEvents(),e&&C(e)){if(e.type===Di.Meta){var i=this._maskUrl(e.data.href);if(this._lastHref=i,!i)return;e.data.href=i}else this._pageViewFallBack();if(this._checkUrlTriggerConditions(),!this._urlBlocked||function(e){return e.type===Di.Custom&&"recording paused"===e.data.tag}(e)){e.type===Di.FullSnapshot&&this._scheduleFullSnapshot(),e.type===Di.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&&C(t)&&6===t.type&&C(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=[],r=0;r2e3?i.push(t.data.payload.payload[r].slice(0,2e3)+"...[truncated]"):i.push(t.data.payload.payload[r]);return t.data.payload.payload=i,e}return e}(r);if(this._updateWindowAndSessionIds(n),!0!==this._isIdle||jr(n)){if(jr(n)){var s=n.data.payload;if(s){var o=s.lastActivityTimestamp,a=s.threshold;n.timestamp=o+a}}var l=null===(t=this._instance.config.session_recording.compress_events)||void 0===t||t?function(e){if(Ai(e)<1024)return e;try{if(e.type===Di.FullSnapshot)return z(z({},e),{},{data:Hr(e.data),cv:"2024-10"});if(e.type===Di.IncrementalSnapshot&&e.data.source===qi.Mutation)return z(z({},e),{},{cv:"2024-10",data:z(z({},e.data),{},{texts:Hr(e.data.texts),attributes:Hr(e.data.attributes),removes:Hr(e.data.removes),adds:Hr(e.data.adds)})});if(e.type===Di.IncrementalSnapshot&&e.data.source===qi.StyleSheetRule)return z(z({},e),{},{cv:"2024-10",data:z(z({},e.data),{},{adds:e.data.adds?Hr(e.data.adds):void 0,removes:e.data.removes?Hr(e.data.removes):void 0})})}catch(e){Lr.error("could not compress event - will use uncompressed event",e)}return e}(n):n,u={$snapshot_bytes:Ai(l),$snapshot_data:l,$session_id:this._sessionId,$window_id:this._windowId};"disabled"!==this.status?this._captureSnapshotBuffered(u):this._clearBuffer()}}}}}_pageViewFallBack(){if(!this._instance.config.capture_pageview&&t){var e=this._maskUrl(t.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,r={url:e};return null===(i=r=t.maskNetworkRequestFn(r))||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=M(t)&&t>=0,r=M(e)&&i&&t{this._flushBuffer()}),2e3),this._buffer;this._buffer.data.length>0&&Li(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:p.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!==t&&t.location.href){var e=t.location.href,i=this._urlBlocked,r=Ur(e,this._urlBlocklist);r&&!i?this._pauseRecording():!r&&i&&this._resumeRecording(),Ur(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?Ie:Ce]:this._sessionId}),this._flushBuffer(),this._reportStarted(e+"_trigger_matched"))}_pauseRecording(){this._urlBlocked||(this._urlBlocked=!0,clearInterval(this._fullSnapshotTimer),Lr.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"}),Lr.info("recording resumed"))}_addEventTriggerListener(){0!==this._eventTriggers.length&&O(this._removeEventTriggerCaptureHook)&&(this._removeEventTriggerCaptureHook=this._instance.on("eventCaptured",(e=>{try{this._eventTriggers.includes(e.event)&&this._activateTrigger("event")}catch(e){Lr.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({[xe]:!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}),Lr.info(e.replace("_"," "),t),m(["recording_initialized","session_id_changed"],e)||this._tryAddCustomEvent(e,t)}get sdkDebugProperties(){var{sessionStartTimestamp:e}=this._sessionManager.checkAndGetSessionAndWindowId(!0);return{$recording_status:this.status,$sdk_debug_replay_internal_buffer_length:this._buffer.data.length,$sdk_debug_replay_internal_buffer_size:this._buffer.size,$sdk_debug_current_session_duration:this._sessionDuration,$sdk_debug_session_start:e}}}var Wr=B("[SegmentIntegration]");function Gr(e,t){var i=e.config.segment;if(!i)return t();!function(e,t){var i=e.config.segment;if(!i)return t();var r=i=>{var r=()=>i.anonymousId()||Nt();e.config.get_device_id=r,i.id()&&(e.register({distinct_id:i.id(),$device_id:r()}),e.persistence.set_property(Le,"identified")),t()},n=i.user();"then"in n&&I(n.then)?n.then((e=>r(e))):r(n)}(e,(()=>{i.register((e=>{Promise&&Promise.resolve||Wr.warn("This browser does not have Promise support, and can not use the segment integration");var t=(t,i)=>{var r;if(!i)return t;t.event.userId||t.event.anonymousId===e.get_distinct_id()||(Wr.info("No userId set, resetting PostHog"),e.reset()),t.event.userId&&t.event.userId!==e.get_distinct_id()&&(Wr.info("UserId set, identifying with PostHog"),e.identify(t.event.userId));var n=e._calculate_event_properties(i,null!==(r=t.event.properties)&&void 0!==r?r:{},new Date);return t.event.properties=Object.assign({},n,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 Vr="posthog-js";function Jr(e){var{organization:t,projectId:i,prefix:r,severityAllowList:n=["error"]}=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return s=>{var o,a,l,u,c;if(!("*"===n||n.includes(s.level))||!e.__loaded)return s;s.tags||(s.tags={});var d=e.requestRouter.endpointFor("ui","/project/".concat(e.config.token,"/person/").concat(e.get_distinct_id()));s.tags["PostHog Person URL"]=d,e.sessionRecordingStarted()&&(s.tags["PostHog Recording URL"]=e.get_session_replay_url({withTimestamp:!0}));var _=(null===(o=s.exception)||void 0===o?void 0:o.values)||[],h=_.map((e=>z(z({},e),{},{stacktrace:e.stacktrace?z(z({},e.stacktrace),{},{type:"raw",frames:(e.stacktrace.frames||[]).map((e=>z(z({},e),{},{platform:"web:javascript"})))}):void 0}))),p={$exception_message:(null===(a=_[0])||void 0===a?void 0:a.value)||s.message,$exception_type:null===(l=_[0])||void 0===l?void 0:l.type,$exception_personURL:d,$exception_level:s.level,$exception_list:h,$sentry_event_id:s.event_id,$sentry_exception:s.exception,$sentry_exception_message:(null===(u=_[0])||void 0===u?void 0:u.value)||s.message,$sentry_exception_type:null===(c=_[0])||void 0===c?void 0:c.type,$sentry_tags:s.tags};return t&&i&&(p.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+s.event_id),e.exceptions.sendExceptionEvent(p),s}}class Yr{constructor(e,t,i,r,n){this.name=Vr,this.setupOnce=function(s){s(Jr(e,{organization:t,projectId:i,prefix:r,severityAllowList:n}))}}}var Kr,Xr=null!=t&&t.location?It(t.location.hash,"__posthog")||It(location.hash,"state"):null,Qr="_postHogToolbarParams",Zr=B("[Toolbar]");!function(e){e[e.UNINITIALIZED=0]="UNINITIALIZED",e[e.LOADING=1]="LOADING",e[e.LOADED=2]="LOADED"}(Kr||(Kr={}));class en{constructor(e){this.instance=e}_setToolbarState(e){h.ph_toolbar_state=e}_getToolbarState(){var e;return null!==(e=h.ph_toolbar_state)&&void 0!==e?e:Kr.UNINITIALIZED}maybeLoadToolbar(){var e,i,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:void 0,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:void 0,s=arguments.length>2&&void 0!==arguments[2]?arguments[2]:void 0;if(!t||!a)return!1;r=null!==(e=r)&&void 0!==e?e:t.location,s=null!==(i=s)&&void 0!==i?i:t.history;try{if(!n){try{t.localStorage.setItem("test","test"),t.localStorage.removeItem("test")}catch(e){return!1}n=null==t?void 0:t.localStorage}var o,l=Xr||It(r.hash,"__posthog")||It(r.hash,"state"),u=l?Z((()=>JSON.parse(atob(decodeURIComponent(l)))))||Z((()=>JSON.parse(decodeURIComponent(l)))):null;return u&&"ph_authorize"===u.action?((o=u).source="url",o&&Object.keys(o).length>0&&(u.desiredHash?r.hash=u.desiredHash:s?s.replaceState(s.state,"",r.pathname+r.search):r.hash="")):((o=JSON.parse(n.getItem(Qr)||"{}")).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=h.ph_load_toolbar||h.ph_load_editor;!O(t)&&I(t)?t(e,this.instance):Zr.warn("No toolbar load function found")}loadToolbar(e){var i=!(null==a||!a.getElementById(Ue));if(!t||i)return!1;var r="custom"===this.instance.requestRouter.region&&this.instance.config.advanced_disable_toolbar_metrics,n=z(z({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(t.localStorage.setItem(Qr,JSON.stringify(z(z({},n),{},{source:void 0}))),this._getToolbarState()===Kr.LOADED)this._callLoadToolbar(n);else if(this._getToolbarState()===Kr.UNINITIALIZED){var s,o;this._setToolbarState(Kr.LOADING),null===(s=h.__PosthogExtensions__)||void 0===s||null===(o=s.loadExternalDependency)||void 0===o||o.call(s,this.instance,"toolbar",(e=>{if(e)return Zr.error("[Toolbar] Failed to load",e),void this._setToolbarState(Kr.UNINITIALIZED);this._setToolbarState(Kr.LOADED),this._callLoadToolbar(n)})),oe(t,"turbolinks:load",(()=>{this._setToolbarState(Kr.UNINITIALIZED),this.loadToolbar(n)}))}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 tn=B("[TracingHeaders]");class rn{constructor(e){W(this,"_restoreXHRPatch",void 0),W(this,"_restoreFetchPatch",void 0),W(this,"_startCapturing",(()=>{var e,t,i,r;F(this._restoreXHRPatch)&&(null===(e=h.__PosthogExtensions__)||void 0===e||null===(t=e.tracingHeadersPatchFns)||void 0===t||t._patchXHR(this._instance.sessionManager));F(this._restoreFetchPatch)&&(null===(i=h.__PosthogExtensions__)||void 0===i||null===(r=i.tracingHeadersPatchFns)||void 0===r||r._patchFetch(this._instance.sessionManager))})),this._instance=e}_loadScript(e){var t,i,r;null!==(t=h.__PosthogExtensions__)&&void 0!==t&&t.tracingHeadersPatchFns&&e(),null===(i=h.__PosthogExtensions__)||void 0===i||null===(r=i.loadExternalDependency)||void 0===r||r.call(i,this._instance,"tracing-headers",(t=>{if(t)return tn.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 nn=B("[Web Vitals]"),sn=9e5;class on{constructor(e){var t;W(this,"_enabledServerSide",!1),W(this,"_initialized",!1),W(this,"_buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),W(this,"_flushToCapture",(()=>{clearTimeout(this._delayedFlushTimer),0!==this._buffer.metrics.length&&(this._instance.capture("$web_vitals",this._buffer.metrics.reduce(((e,t)=>z(z({},e),{},{["$web_vitals_".concat(t.name,"_event")]:z({},t),["$web_vitals_".concat(t.name,"_value")]:t.value})),{})),this._buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})})),W(this,"_addToBuffer",(e=>{var t,i=null===(t=this._instance.sessionManager)||void 0===t?void 0:t.checkAndGetSessionAndWindowId(!0);if(F(i))nn.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(!F(r))if(O(null==e?void 0:e.name)||O(null==e?void 0:e.value))nn.error("Invalid metric received",e);else if(this._maxAllowedValue&&e.value>=this._maxAllowedValue)nn.error("Ignoring metric with value >= "+this._maxAllowedValue,e);else this._buffer.url!==r&&(this._flushToCapture(),this._delayedFlushTimer=setTimeout(this._flushToCapture,this.flushToCaptureTimeoutMs)),F(this._buffer.url)&&(this._buffer.url=r),this._buffer.firstMetricTimestamp=F(this._buffer.firstMetricTimestamp)?Date.now():this._buffer.firstMetricTimestamp,e.attribution&&e.attribution.interactionTargetElement&&(e.attribution.interactionTargetElement=void 0),this._buffer.metrics.push(z(z({},e),{},{$current_url:r,$session_id:i.sessionId,$window_id:i.windowId,timestamp:Date.now()})),this._buffer.metrics.length===this.allowedMetrics.length&&this._flushToCapture()}})),W(this,"_startCapturing",(()=>{var e,t,i,r,n=h.__PosthogExtensions__;F(n)||F(n.postHogWebVitalsCallbacks)||({onLCP:e,onCLS:t,onFCP:i,onINP:r}=n.postHogWebVitalsCallbacks),e&&t&&i&&r?(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&&r(this._addToBuffer.bind(this)),this._initialized=!0):nn.error("web vitals callbacks not loaded - not starting")})),this._instance=e,this._enabledServerSide=!(null===(t=this._instance.persistence)||void 0===t||!t.props[he]),this.startIfEnabled()}get allowedMetrics(){var e,t,i=C(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 F(i)?(null===(t=this._instance.persistence)||void 0===t?void 0:t.props[ve])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(C(this._instance.config.capture_performance)?this._instance.config.capture_performance.web_vitals_delayed_flush_ms:void 0)||5e3}get _maxAllowedValue(){var e=C(this._instance.config.capture_performance)&&M(this._instance.config.capture_performance.__web_vitals_max_value)?this._instance.config.capture_performance.__web_vitals_max_value:sn;return 0{t?nn.error("failed to load script",t):e()}))}_currentURL(){var e=t?t.location.href:void 0;return e||nn.error("Could not determine current URL"),e}}var an=B("[Heatmaps]");function ln(e){return C(e)&&"clientX"in e&&"clientY"in e&&M(e.clientX)&&M(e.clientY)}class un{constructor(e){var t;W(this,"rageclicks",new bt),W(this,"_enabledServerSide",!1),W(this,"_initialized",!1),W(this,"_flushInterval",null),this.instance=e,this._enabledServerSide=!(null===(t=this.instance.persistence)||void 0===t||!t.props[de])}get flushIntervalMilliseconds(){var e=5e3;return C(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 F(this.instance.config.capture_heatmaps)?F(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;an.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({[de]: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(){t&&a&&(oe(t,"beforeunload",this._flush.bind(this)),oe(a,"click",(e=>this._onClick(e||(null==t?void 0:t.event))),{capture:!0}),oe(a,"mousemove",(e=>this._onMouseMove(e||(null==t?void 0:t.event))),{capture:!0}),this._deadClicksCapture=new si(this.instance,ri,this._onDeadClick.bind(this)),this._deadClicksCapture.startIfEnabled(),this._initialized=!0)}_getProperties(e,i){var r=this.instance.scrollManager.scrollY(),n=this.instance.scrollManager.scrollX(),s=this.instance.scrollManager.scrollElement(),o=function(e,i,r){for(var n=e;n&&Ve(n)&&!Je(n,"body");){if(n===r)return!1;if(m(i,null==t?void 0:t.getComputedStyle(n).position))return!0;n=nt(n)}return!1}(it(e),["fixed","sticky"],s);return{x:e.clientX+(o?0:n),y:e.clientY+(o?0:r),target_fixed:o,type:i}}_onClick(e){var t,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"click";if(!Ge(e.target)&&ln(e)){var r=this._getProperties(e,i);null!==(t=this.rageclicks)&&void 0!==t&&t.isRageClick(e.clientX,e.clientY,(new Date).getTime())&&this._capture(z(z({},r),{},{type:"rageclick"})),this._capture(r)}}_onMouseMove(e){!Ge(e.target)&&ln(e)&&(clearTimeout(this._mouseMoveTimeout),this._mouseMoveTimeout=setTimeout((()=>{this._capture(this._getProperties(e,"mousemove"))}),500))}_capture(e){if(t){var i=t.location.href;this._buffer=this._buffer||{},this._buffer[i]||(this._buffer[i]=[]),this._buffer[i].push(e)}}_flush(){this._buffer&&!P(this._buffer)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}}class cn{constructor(e){this._instance=e}doPageView(e,i){var r,n=this._previousPageViewProperties(e,i);return this._currentPageview={pathname:null!==(r=null==t?void 0:t.location.pathname)&&void 0!==r?r:"",pageViewId:i,timestamp:e},this._instance.scrollManager.resetContext(),n}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 r={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:s,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:u,maxContentY:c}=n;if(!(F(s)||F(o)||F(a)||F(l)||F(u)||F(c))){s=Math.ceil(s),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var d=s<=1?1:Ji(o/s,0,1),_=s<=1?1:Ji(a/s,0,1),h=l<=1?1:Ji(u/l,0,1),p=l<=1?1:Ji(c/l,0,1);r=K(r,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:d,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:_,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:h,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}}class dn{constructor(e){this._instance=e}sendExceptionEvent(e){this._instance.capture("$exception",e,{_noTruncate:!0,_batchKey:"exceptionEvent"})}}var _n="Mobile",hn="iOS",pn="Android",vn="Tablet",gn=pn+" "+vn,fn="iPad",mn="Apple",yn=mn+" Watch",bn="Safari",wn="BlackBerry",Sn="Samsung",kn=Sn+"Browser",En=Sn+" Internet",xn="Chrome",In=xn+" OS",Cn=xn+" "+hn,Pn="Internet Explorer",Fn=Pn+" "+_n,Tn="Opera",Rn=Tn+" Mini",$n="Edge",On="Microsoft "+$n,Mn="Firefox",An=Mn+" "+hn,Ln="Nintendo",Dn="PlayStation",qn="Xbox",Nn=pn+" "+_n,Bn=_n+" "+bn,Hn="Windows",jn=Hn+" Phone",Un="Nokia",zn="Ouya",Wn="Generic",Gn=Wn+" "+_n.toLowerCase(),Vn=Wn+" "+vn.toLowerCase(),Jn="Konqueror",Yn="(\\d+(\\.\\d+)?)",Kn=new RegExp("Version/"+Yn),Xn=new RegExp(qn,"i"),Qn=new RegExp(Dn+" \\w+","i"),Zn=new RegExp(Ln+" \\w+","i"),es=new RegExp(wn+"|PlayBook|BB10","i"),ts={"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 is=(e,t)=>t&&m(t,mn)||function(e){return m(e,bn)&&!m(e,xn)&&!m(e,pn)}(e),rs=function(e,t){return t=t||"",m(e," OPR/")&&m(e,"Mini")?Rn:m(e," OPR/")?Tn:es.test(e)?wn:m(e,"IE"+_n)||m(e,"WPDesktop")?Fn:m(e,kn)?En:m(e,$n)||m(e,"Edg/")?On:m(e,"FBIOS")?"Facebook "+_n:m(e,"UCWEB")||m(e,"UCBrowser")?"UC Browser":m(e,"CriOS")?Cn:m(e,"CrMo")||m(e,xn)?xn:m(e,pn)&&m(e,bn)?Nn:m(e,"FxiOS")?An:m(e.toLowerCase(),Jn.toLowerCase())?Jn:is(e,t)?m(e,_n)?Bn:bn:m(e,Mn)?Mn:m(e,"MSIE")||m(e,"Trident/")?Pn:m(e,"Gecko")?Mn:""},ns={[Fn]:[new RegExp("rv:"+Yn)],[On]:[new RegExp($n+"?\\/"+Yn)],[xn]:[new RegExp("("+xn+"|CrMo)\\/"+Yn)],[Cn]:[new RegExp("CriOS\\/"+Yn)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Yn)],[bn]:[Kn],[Bn]:[Kn],[Tn]:[new RegExp("(Opera|OPR)\\/"+Yn)],[Mn]:[new RegExp(Mn+"\\/"+Yn)],[An]:[new RegExp("FxiOS\\/"+Yn)],[Jn]:[new RegExp("Konqueror[:/]?"+Yn,"i")],[wn]:[new RegExp(wn+" "+Yn),Kn],[Nn]:[new RegExp("android\\s"+Yn,"i")],[En]:[new RegExp(kn+"\\/"+Yn)],[Pn]:[new RegExp("(rv:|MSIE )"+Yn)],Mozilla:[new RegExp("rv:"+Yn)]},ss=function(e,t){var i=rs(e,t),r=ns[i];if(F(r))return null;for(var n=0;n[qn,e&&e[1]||""]],[new RegExp(Ln,"i"),[Ln,""]],[new RegExp(Dn,"i"),[Dn,""]],[es,[wn,""]],[new RegExp(Hn,"i"),(e,t)=>{if(/Phone/.test(t)||/WPDesktop/.test(t))return[jn,""];if(new RegExp(_n).test(t)&&!/IEMobile\b/.test(t))return[Hn+" "+_n,""];var i=/Windows NT ([0-9.]+)/i.exec(t);if(i&&i[1]){var r=i[1],n=ts[r]||"";return/arm/i.test(t)&&(n="RT"),[Hn,n]}return[Hn,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,e=>{if(e&&e[3]){var t=[e[3],e[4],e[5]||"0"];return[hn,t.join(".")]}return[hn,""]}],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,e=>{var t="";return e&&e.length>=3&&(t=F(e[2])?e[3]:e[2]),["watchOS",t]}],[new RegExp("("+pn+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+pn+")","i"),e=>{if(e&&e[2]){var t=[e[2],e[3],e[4]||"0"];return[pn,t.join(".")]}return[pn,""]}],[/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/,[In,""]],[/Linux|debian/i,["Linux",""]]],as=function(e){return Zn.test(e)?Ln:Qn.test(e)?Dn:Xn.test(e)?qn:new RegExp(zn,"i").test(e)?zn:new RegExp("("+jn+"|WPDesktop)","i").test(e)?jn:/iPad/.test(e)?fn:/iPod/.test(e)?"iPod Touch":/iPhone/.test(e)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(e)?yn:es.test(e)?wn:/(kobo)\s(ereader|touch)/i.test(e)?"Kobo":new RegExp(Un,"i").test(e)?Un:/(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(_n).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)?pn:gn:pn:new RegExp("(pda|"+_n+")","i").test(e)?Gn:new RegExp(vn,"i").test(e)&&!new RegExp(vn+" pc","i").test(e)?Vn:""},ls=function(e){var t=as(e);return t===fn||t===gn||"Kobo"===t||"Kindle Fire"===t||t===Vn?vn:t===Ln||t===qn||t===Dn||t===zn?"Console":t===yn?"Wearable":t?_n:"Desktop"},us="https?://(.*)",cs=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],ds=X(["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid"],cs),_s="";function hs(e,t,i){if(!a)return{};var r=t?X([],cs,i||[]):[];return ps(xt(a.URL,r,_s),e)}function ps(e,t){var i=ds.concat(t||[]),r={};return Y(i,(function(t){var i=Et(e,t);r[t]=i||null})),r}function vs(e){var t=function(e){return e?0===e.search(us+"google.([^/?]*)")?"google":0===e.search(us+"bing.com")?"bing":0===e.search(us+"yahoo.com")?"yahoo":0===e.search(us+"duckduckgo.com")?"duckduckgo":null:null}(e),i="yahoo"!=t?"q":"p",r={};if(!$(t)){r.$search_engine=t;var n=a?Et(a.referrer,i):"";n.length&&(r.ph_keyword=n)}return r}function gs(){return navigator.language||navigator.userLanguage}function fs(){return(null==a?void 0:a.referrer)||"$direct"}function ms(e,t){var i=e?X([],cs,t||[]):[],r=null==l?void 0:l.href.substring(0,1e3);return{r:fs().substring(0,1e3),u:r?xt(r,i,_s):void 0}}function ys(e){var t,{r:i,u:r}=e,n={$referrer:i,$referring_domain:null==i?void 0:"$direct"==i?"$direct":null===(t=St(i))||void 0===t?void 0:t.host};if(r){n.$current_url=r;var s=St(r);n.$host=null==s?void 0:s.host,n.$pathname=null==s?void 0:s.pathname;var o=ps(r);K(n,o)}if(i){var a=vs(i);K(n,a)}return n}function bs(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch(e){return}}function ws(){try{return(new Date).getTimezoneOffset()}catch(e){return}}function Ss(e,i){if(!_)return{};var r,n=e?X([],cs,i||[]):[],[s,o]=function(e){for(var t=0;t1e3?_.substring(0,997)+"...":_,$browser_version:ss(_,navigator.vendor),$browser_language:gs(),$browser_language_prefix:(r=gs(),"string"==typeof r?r.split("-")[0]:void 0),$screen_height:null==t?void 0:t.screen.height,$screen_width:null==t?void 0:t.screen.width,$viewport_height:null==t?void 0:t.innerHeight,$viewport_width:null==t?void 0:t.innerWidth,$lib:"web",$lib_version:p.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})}var ks,Es=B("[FeatureFlags]"),xs="$active_feature_flags",Is="$override_feature_flags",Cs="$feature_flag_payloads",Ps="$override_feature_flag_payloads",Fs="$feature_flag_request_id",Ts=e=>{var t={};for(var[i,r]of Q(e||{}))r&&(t[i]=r);return t},Rs=e=>{var t=e.flags;return t?(e.featureFlags=Object.fromEntries(Object.keys(t).map((e=>{var i;return[e,null!==(i=t[e].variant)&&void 0!==i?i:t[e].enabled]}))),e.featureFlagPayloads=Object.fromEntries(Object.keys(t).filter((e=>t[e].enabled)).filter((e=>{var i;return null===(i=t[e].metadata)||void 0===i?void 0:i.payload})).map((e=>{var i;return[e,null===(i=t[e].metadata)||void 0===i?void 0:i.payload]})))):Es.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),e};!function(e){e.FeatureFlags="feature_flags",e.Recordings="recordings"}(ks||(ks={}));class $s{constructor(e){W(this,"_override_warning",!1),W(this,"_hasLoadedFlags",!1),W(this,"_requestInFlight",!1),W(this,"_reloadingDisabled",!1),W(this,"_additionalReloadRequested",!1),W(this,"_decideCalled",!1),W(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())}getFlagsWithDetails(){var e=this._instance.get_property(Te),t=this._instance.get_property(Is),i=this._instance.get_property(Ps);if(!i&&!t)return e||{};var r=K({},e||{}),n=[...new Set([...Object.keys(i||{}),...Object.keys(t||{})])];for(var s of n){var o,a,l=r[s],u=null==t?void 0:t[s],c=F(u)?null!==(o=null==l?void 0:l.enabled)&&void 0!==o&&o:!!u,d=F(u)?l.variant:"string"==typeof u?u:void 0,_=null==i?void 0:i[s],h=z(z({},l),{},{enabled:c,variant:c?null!=d?d:null==l?void 0:l.variant:void 0});if(c!==(null==l?void 0:l.enabled)&&(h.original_enabled=null==l?void 0:l.enabled),d!==(null==l?void 0:l.variant)&&(h.original_variant=null==l?void 0:l.variant),_)h.metadata=z(z({},null==l?void 0:l.metadata),{},{payload:_,original_payload:null==l||null===(a=l.metadata)||void 0===a?void 0:a.payload});r[s]=h}return this._override_warning||(Es.warn(" Overriding feature flag details!",{flagDetails:e,overriddenPayloads:i,finalDetails:r}),this._override_warning=!0),r}getFlagVariants(){var e=this._instance.get_property(Pe),t=this._instance.get_property(Is);if(!t)return e||{};for(var i=K({},e),r=Object.keys(t),n=0;n{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(t){var i;if(this._clearDebouncer(),!this._instance.config.advanced_disable_decide)if(this._requestInFlight)this._additionalReloadRequested=!0;else{var r={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:z(z({},(null===(i=this._instance.persistence)||void 0===i?void 0:i.get_initial_props())||{}),this._instance.get_property(Re)||{}),group_properties:this._instance.get_property($e)};(null!=t&&t.disableFlags||this._instance.config.advanced_disable_feature_flags)&&(r.disable_flags=!0);var n=this._instance.config.__preview_flags_v2&&this._instance.config.__preview_remote_config;n&&(r.timezone=bs()),this._requestInFlight=!0,this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("api",n?"/flags/?v=2":"/decide/?v=4"),data:r,compression:this._instance.config.disable_compression?void 0:e.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var t,i,n,s=!0;(200===e.statusCode&&(this._additionalReloadRequested||(this.$anon_distinct_id=void 0),s=!1),this._requestInFlight=!1,this._decideCalled)||(this._decideCalled=!0,this._instance._onRemoteConfig(null!==(n=e.json)&&void 0!==n?n:{}));r.disable_flags&&!this._additionalReloadRequested||(this._flagsLoadedFromRemote=!s,e.json&&null!==(t=e.json.quotaLimited)&&void 0!==t&&t.includes(ks.FeatureFlags)?Es.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:{},s),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=this.getFlagVariants()[e],r="".concat(i),n=this._instance.get_property(Fs)||void 0,s=this._instance.get_property(Ae)||{};if((t.send_event||!("send_event"in t))&&(!(e in s)||!s[e].includes(r))){var o,a,l,u,c,d,_,h,p,v,g;x(s[e])?s[e].push(r):s[e]=[r],null===(o=this._instance.persistence)||void 0===o||o.register({[Ae]:s});var f=this.getFeatureFlagDetails(e),m={$feature_flag:e,$feature_flag_response:i,$feature_flag_payload:this.getFeatureFlagPayload(e)||null,$feature_flag_request_id:n,$feature_flag_bootstrapped_response:(null===(a=this._instance.config.bootstrap)||void 0===a||null===(l=a.featureFlags)||void 0===l?void 0:l[e])||null,$feature_flag_bootstrapped_payload:(null===(u=this._instance.config.bootstrap)||void 0===u||null===(c=u.featureFlagPayloads)||void 0===c?void 0:c[e])||null,$used_bootstrap_value:!this._flagsLoadedFromRemote};F(null==f||null===(d=f.metadata)||void 0===d?void 0:d.version)||(m.$feature_flag_version=f.metadata.version);var y,b=null!==(_=null==f||null===(h=f.reason)||void 0===h?void 0:h.description)&&void 0!==_?_:null==f||null===(p=f.reason)||void 0===p?void 0:p.code;if(b&&(m.$feature_flag_reason=b),null!=f&&null!==(v=f.metadata)&&void 0!==v&&v.id&&(m.$feature_flag_id=f.metadata.id),F(null==f?void 0:f.original_variant)&&F(null==f?void 0:f.original_enabled)||(m.$feature_flag_original_response=F(f.original_variant)?f.original_enabled:f.original_variant),null!=f&&null!==(g=f.metadata)&&void 0!==g&&g.original_payload)m.$feature_flag_original_payload=null==f||null===(y=f.metadata)||void 0===y?void 0:y.original_payload;this._instance.capture("$feature_flag_called",m)}return i}Es.warn('getFeatureFlag for key "'+e+"\" failed. Feature flags didn't load in time.")}getFeatureFlagDetails(e){return this.getFlagsWithDetails()[e]}getFeatureFlagPayload(e){return this.getFlagPayloads()[e]}getRemoteConfigPayload(t,i){var r=this._instance.config.token;this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("api","/decide/?v=4"),data:{distinct_id:this._instance.get_distinct_id(),token:r},compression:this._instance.config.disable_compression?void 0:e.Base64,timeout:this._instance.config.feature_flag_request_timeout_ms,callback:e=>{var r,n=null===(r=e.json)||void 0===r?void 0:r.featureFlagPayloads;i((null==n?void 0:n[t])||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);Es.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,t){if(this._instance.persistence){this._hasLoadedFlags=!0;var i=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();!function(e,t){var i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},n=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},s=Rs(e),o=s.flags,a=s.featureFlags,l=s.featureFlagPayloads;if(a){var u=e.requestId;if(x(a)){Es.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var c={};if(a)for(var d=0;d1&&void 0!==arguments[1]&&arguments[1];Es.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:e,suppressWarning:t})}overrideFeatureFlags(e){if(!this._instance.__loaded||!this._instance.persistence)return Es.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(!1===e)return this._instance.persistence.unregister(Is),this._instance.persistence.unregister(Ps),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(Is);else if(i.flags)if(x(i.flags)){for(var r={},n=0;nthis.removeFeatureFlagsHandler(e)}updateEarlyAccessFeatureEnrollment(e,t){var i,r=(this._instance.get_property(Fe)||[]).find((t=>t.flagKey===e)),n={["$feature_enrollment/".concat(e)]:t},s={$feature_flag:e,$feature_enrollment:t,$set:n};r&&(s.$early_access_feature_name=r.name),this._instance.capture("$feature_enrollment_update",s),this.setPersonPropertiesForFlags(n,!1);var o=z(z({},this.getFlagVariants()),{},{[e]:t});null===(i=this._instance.persistence)||void 0===i||i.register({[xs]:Object.keys(Ts(o)),[Pe]:o}),this._fireFeatureFlagsCallbacks()}getEarlyAccessFeatures(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],i=arguments.length>2?arguments[2]:void 0,r=this._instance.get_property(Fe),n=i?"&".concat(i.map((e=>"stage=".concat(e))).join("&")):"";if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this._instance.config.token).concat(n)),method:"GET",callback:t=>{var i;if(t.json){var r=t.json.earlyAccessFeatures;return null===(i=this._instance.persistence)||void 0===i||i.register({[Fe]:r}),e(r)}}})}_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((r=>r(t,i,{errorsLoading:e})))}setPersonPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this._instance.get_property(Re)||{};this._instance.register({[Re]:z(z({},i),e)}),t&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Re)}setGroupPropertiesForFlags(e){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],i=this._instance.get_property($e)||{};0!==Object.keys(i).length&&Object.keys(i).forEach((t=>{i[t]=z(z({},i[t]),e[t]),delete e[t]})),this._instance.register({[$e]:z(z({},i),e)}),t&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(e){if(e){var t=this._instance.get_property($e)||{};this._instance.register({[$e]:z(z({},t),{},{[e]:{}})})}else this._instance.unregister($e)}}var Os=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"];class Ms{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&&N.info("Persistence loaded",e.persistence,z({},this.props)),this.update_config(e,e),this.save()}_buildStorage(e){-1===Os.indexOf(e.persistence.toLowerCase())&&(N.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return"localstorage"===t&&Jt.is_supported()?Jt:"localstorage+cookie"===t&&Kt.is_supported()?Kt:"sessionstorage"===t&&ei.is_supported()?ei:"memory"===t?Qt:"cookie"===t?Gt:Kt.is_supported()?Kt:Gt}properties(){var e={};return Y(this.props,(function(t,i){if(i===Pe&&C(t))for(var r=Object.keys(t),n=0;n{this.props.hasOwnProperty(i)&&this.props[i]!==t||(this.props[i]=e,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(C(e)){this.expire_days=F(t)?this.default_expiry:t;var i=!1;if(Y(e,((t,r)=>{e.hasOwnProperty(r)&&this.props[r]!==t&&(this.props[r]=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=hs(this._config.custom_campaign_params,this._config.mask_personal_data_properties,this._config.custom_personal_data_properties);P(te(e))||this.register(e),this.campaign_params_saved=!0}}update_search_keyword(){var e;this.register((e=null==a?void 0:a.referrer)?vs(e):{})}update_referrer_info(){var e;this.register_once({$referrer:fs(),$referring_domain:null!=a&&a.referrer&&(null===(e=St(a.referrer))||void 0===e?void 0:e.host)||"$direct"},void 0)}set_initial_person_info(){this.props[Ne]||this.props[Be]||this.register_once({[He]:ms(this._config.mask_personal_data_properties,this._config.custom_personal_data_properties)},void 0)}get_referrer_info(){return te({$referrer:this.props.$referrer,$referring_domain:this.props.$referring_domain})}get_initial_props(){var e={};Y([Be,Ne],(t=>{var i=this.props[t];i&&Y(i,(function(t,i){e["$initial_"+b(i)]=t}))}));var t,i,r=this.props[He];if(r){var n=(t=ys(r),i={},Y(t,(function(e,t){i["$initial_".concat(b(t))]=e})),i);K(e,n)}return e}safe_merge(e){return Y(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),r=this.props;this.clear(),this.storage=i,this.props=r,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[ue]||{};i[e]=t,this.props[ue]=i,this.save()}remove_event_timer(e){var t=(this.props[ue]||{})[e];return F(t)||(delete this.props[ue][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}}var As,Ls,Ds,qs,Ns,Bs,Hs,js,Us,zs,Ws,Gs,Vs,Js,Ys={},Ks=[],Xs=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i,Qs=Array.isArray;function Zs(e,t){for(var i in t)e[i]=t[i];return e}function eo(e){var t=e.parentNode;t&&t.removeChild(e)}function to(e,t,i,r,n){var s={type:e,props:t,key:i,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:null==n?++Ds:n,__i:-1,__u:0};return null==n&&null!=Ls.vnode&&Ls.vnode(s),s}function io(e){return e.children}function ro(e,t){this.props=e,this.context=t}function no(e,t){if(null==t)return e.__?no(e.__,e.__i+1):null;for(var i;tt&&qs.sort(Hs));ao.__r=0}function lo(e,t,i,r,n,s,o,a,l,u,c){var d,_,h,p,v,g=r&&r.__k||Ks,f=t.length;for(i.__d=l,uo(i,t,g),l=i.__d,d=0;d0?to(n.type,n.props,n.key,n.ref?n.ref:null,n.__v):n)?(n.__=e,n.__b=e.__b+1,a=_o(n,i,o=r+d,c),n.__i=a,s=null,-1!==a&&(c--,(s=i[a])&&(s.__u|=131072)),null==s||null===s.__v?(-1==a&&d--,"function"!=typeof n.type&&(n.__u|=65536)):a!==o&&(a===o+1?d++:a>o?c>l-o?d+=a-o:d--:d=a(null!=l&&0==(131072&l.__u)?1:0))for(;o>=0||a=0){if((l=t[o])&&0==(131072&l.__u)&&n==l.key&&s===l.type)return o;o--}if(ae.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=>ko(t,e))),not_regex:(e,t)=>e.every((e=>!ko(t,e))),exact:(e,t)=>e.some((e=>t===e)),is_not:(e,t)=>e.every((e=>t!==e))};function Io(e){return null!=e?e:"icontains"}zs.Right;!function(e,t){var i={__c:t="__cC"+js++,__:e,Consumer:function(e,t){return e.children(t)},Provider:function(e){var i,r;return this.getChildContext||(i=[],(r={})[t]=this,this.getChildContext=function(){return r},this.shouldComponentUpdate=function(e){this.props.value!==e.value&&i.some((function(e){e.__e=!0,oo(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:()=>{}});class Co{constructor(){W(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 r of this._events["*"]||[])r(e,t)}}class Po{constructor(e){W(this,"_debugEventEmitter",new Co),W(this,"_checkStep",((e,t)=>this._checkStepEvent(e,t)&&this._checkStepUrl(e,t)&&this._checkStepElement(e,t))),W(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(!F(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(!F(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 r,n=new Set;e.forEach((e=>{var t;null===(t=e.steps)||void 0===t||t.forEach((e=>{null!=e&&e.selector&&n.add(null==e?void 0:e.selector)}))})),null===(r=this._instance)||void 0===r||r.autocapture.setElementSelectors(n)}}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,r=null==e||null===(i=e.properties)||void 0===i?void 0:i.$current_url;if(!r||"string"!=typeof r)return!1;if(!Po._matchString(r,null==t?void 0:t.url,(null==t?void 0:t.url_matching)||"contains"))return!1}return!0}static _matchString(e,i,r){switch(r){case"regex":return!!t&&ko(e,i);case"exact":return i===e;case"contains":var n=Po._escapeStringRegexp(i).replace(/_/g,".").replace(/%/g,".*");return ko(e,n);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&&!Po._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&&!Po._matchString(e.text||"",null==t?void 0:t.text,(null==t?void 0:t.text_matching)||"exact")&&!Po._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,r=null==e||null===(i=e.properties)||void 0===i?void 0:i.$element_selectors;if(!r)return!1;if(!r.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 Fo{constructor(e){this._instance=e,this._eventToSurveys=new Map,this._actionToSurveys=new Map}register(e){var t;F(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,r,n;return(null===(t=e.conditions)||void 0===t?void 0:t.actions)&&(null===(i=e.conditions)||void 0===i||null===(r=i.actions)||void 0===r||null===(n=r.values)||void 0===n?void 0:n.length)>0}));if(0!==t.length){if(null==this._actionMatcher){this._actionMatcher=new Po(this._instance),this._actionMatcher.init();this._actionMatcher._addActionHook((e=>{this.onAction(e)}))}t.forEach((e=>{var t,i,r,n,s,o,a,l,u,c;e.conditions&&null!==(t=e.conditions)&&void 0!==t&&t.actions&&null!==(i=e.conditions)&&void 0!==i&&null!==(r=i.actions)&&void 0!==r&&r.values&&(null===(n=e.conditions)||void 0===n||null===(s=n.actions)||void 0===s||null===(o=s.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===(u=l.actions)||void 0===u||null===(c=u.values)||void 0===c||c.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,r,n;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(r=i.events)||void 0===r||null===(n=r.values)||void 0===n?void 0:n.length)>0})).length){null===(t=this._instance)||void 0===t||t._addCaptureHook(((e,t)=>{this.onEvent(e,t)})),e.forEach((e=>{var t,i,r;null===(t=e.conditions)||void 0===t||null===(i=t.events)||void 0===i||null===(r=i.values)||void 0===r||r.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,r,n=(null===(i=this._instance)||void 0===i||null===(r=i.persistence)||void 0===r?void 0:r.props[Me])||[];if("survey shown"===e&&t&&n.length>0){var s,o=null==t||null===(s=t.properties)||void 0===s?void 0:s.$survey_id;if(o){var a=n.indexOf(o);a>=0&&(n.splice(a,1),this._updateActivatedSurveys(n))}}else this._eventToSurveys.has(e)&&this._updateActivatedSurveys(n.concat(this._eventToSurveys.get(e)||[]))}onAction(e){var t,i,r=(null===(t=this._instance)||void 0===t||null===(i=t.persistence)||void 0===i?void 0:i.props[Me])||[];this._actionToSurveys.has(e)&&this._updateActivatedSurveys(r.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({[Me]:[...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[Me];return i||[]}getEventToSurveys(){return this._eventToSurveys}_getActionMatcher(){return this._actionMatcher}}class To{constructor(e){W(this,"_isFetchingSurveys",!1),W(this,"_isInitializingSurveys",!1),W(this,"_surveyCallbacks",[]),this._instance=e,this._surveyEventReceiver=null}onRemoteConfig(e){var t=e.surveys;if(O(t))return Eo.warn("Decide not loaded yet. Not loading surveys.");var i=x(t);this._hasSurveys=i?t.length>0:t,Eo.info("decide response received, hasSurveys: ".concat(this._hasSurveys)),this._hasSurveys&&this.loadIfEnabled()}reset(){localStorage.removeItem("lastSeenSurveyDate");var e=(()=>{for(var e=[],t=0;tlocalStorage.removeItem(e)))}loadIfEnabled(){if(!this._surveyManager)if(this._isInitializingSurveys)Eo.info("Already initializing surveys, skipping...");else if(this._instance.config.disable_surveys)Eo.info("Disabled. Not loading surveys.");else if(this._hasSurveys){var e=null==h?void 0:h.__PosthogExtensions__;if(e){this._isInitializingSurveys=!0;try{var t=e.generateSurveys;if(t)return void this._completeSurveyInitialization(t);var i=e.loadExternalDependency;if(!i)return void this._handleSurveyLoadError("PostHog loadExternalDependency extension not found.");i(this._instance,"surveys",(t=>{t||!e.generateSurveys?this._handleSurveyLoadError("Could not load surveys script",t):this._completeSurveyInitialization(e.generateSurveys)}))}catch(e){throw this._handleSurveyLoadError("Error initializing surveys",e),e}finally{this._isInitializingSurveys=!1}}else Eo.error("PostHog Extensions not found.")}else Eo.info("No surveys to load.")}_completeSurveyInitialization(e){this._surveyManager=e(this._instance),this._surveyEventReceiver=new Fo(this._instance),Eo.info("Surveys loaded successfully"),this._notifySurveyCallbacks({isLoaded:!0})}_handleSurveyLoadError(e,t){Eo.error(e,t),this._notifySurveyCallbacks({isLoaded:!1,error:e})}onSurveysLoaded(e){return this._surveyCallbacks.push(e),this._surveyManager&&this._notifySurveyCallbacks({isLoaded:!0}),()=>{this._surveyCallbacks=this._surveyCallbacks.filter((t=>t!==e))}}getSurveys(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(this._instance.config.disable_surveys)return Eo.info("Disabled. Not loading surveys."),e([]);var i=this._instance.get_property(Oe);if(i&&!t)return e(i,{isLoaded:!0});if(this._isFetchingSurveys)return e([],{isLoaded:!1,error:"Surveys are already being loaded"});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 r=t.statusCode;if(200!==r||!t.json){var n="Surveys API could not be loaded, status: ".concat(r);return Eo.error(n),e([],{isLoaded:!1,error:n})}var s,o=t.json.surveys||[],a=o.filter((e=>{var t,i,r,n,s,o,a,l,u,c,d,_;return(null===(t=e.conditions)||void 0===t?void 0:t.events)&&(null===(i=e.conditions)||void 0===i||null===(r=i.events)||void 0===r?void 0:r.values)&&(null===(n=e.conditions)||void 0===n||null===(s=n.events)||void 0===s||null===(o=s.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===(u=l.actions)||void 0===u?void 0:u.values)&&(null===(c=e.conditions)||void 0===c||null===(d=c.actions)||void 0===d||null===(_=d.values)||void 0===_?void 0:_.length)>0}));a.length>0&&(null===(s=this._surveyEventReceiver)||void 0===s||s.register(a));return null===(i=this._instance.persistence)||void 0===i||i.register({[Oe]:o}),e(o,{isLoaded:!0})}})}catch(e){throw this._isFetchingSurveys=!1,e}}_notifySurveyCallbacks(e){for(var t of this._surveyCallbacks)try{e.isLoaded?this.getSurveys(t):t([],e)}catch(e){Eo.error("Error in survey callback",e)}}_isSurveyFeatureFlagEnabled(e){return!e||this._instance.featureFlags.isFeatureEnabled(e)}getActiveMatchingSurveys(e){var i=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.getSurveys((i=>{var r,n=i.filter((e=>!(!e.start_date||e.end_date))).filter((e=>{var i;if(!e.conditions)return!0;var r=function(e){var i,r,n;if(null===(i=e.conditions)||void 0===i||!i.url)return!0;var s=null==t||null===(r=t.location)||void 0===r?void 0:r.href;if(!s)return!1;var o=[e.conditions.url];return xo[Io(null===(n=e.conditions)||void 0===n?void 0:n.urlMatchType)](o,s)}(e),n=null===(i=e.conditions)||void 0===i||!i.selector||(null==a?void 0:a.querySelector(e.conditions.selector)),s=function(e){var t,i,r;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(!_)return!1;var n=ls(_);return xo[Io(null===(r=e.conditions)||void 0===r?void 0:r.deviceTypesMatchType)](e.conditions.deviceTypes,n)}(e);return r&&n&&s})),s=null===(r=this._surveyEventReceiver)||void 0===r?void 0:r.getSurveys(),o=n.filter((e=>{var t,i,r,n,o,a,l,u,c;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),_=this._isSurveyFeatureFlagEnabled(e.targeting_flag_key),h=(null!==(i=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)&&void 0!==i?i:0)>0,p=(null!==(a=null===(l=e.conditions)||void 0===l||null===(u=l.actions)||void 0===u||null===(c=u.values)||void 0===c?void 0:c.length)&&void 0!==a?a:0)>0,v=!h&&!p||(null==s?void 0:s.includes(e.id)),g=this._canActivateRepeatedly(e)||this._isSurveyFeatureFlagEnabled(e.internal_targeting_flag_key),f=this.checkFlags(e);return d&&_&&g&&v&&f}));return e(o)}),i)}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 O(null===(t=h.__PosthogExtensions__)||void 0===t?void 0:t.canActivateRepeatedly)?(Eo.warn("init was not called"),!1):h.__PosthogExtensions__.canActivateRepeatedly(e)}canRenderSurvey(e){if(O(this._surveyManager))return Eo.warn("init was not called"),{visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"};var t=null;return this.getSurveys((i=>{var r=i.filter((t=>t.id===e))[0];t=r?z({},this._surveyManager.canRenderSurvey(r)):{visible:!1,disabledReason:"Survey not found"}})),t}canRenderSurveyAsync(e,t){return O(this._surveyManager)?(Eo.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:"SDK is not enabled or survey functionality is not yet loaded"})):new Promise((i=>{this.getSurveys((t=>{var r=t.filter((t=>t.id===e))[0];i(r?z({},this._surveyManager.canRenderSurvey(r)):{visible:!1,disabledReason:"Survey not found"})}),t)}))}renderSurvey(e,t){O(this._surveyManager)?Eo.warn("init was not called"):this.getSurveys((i=>{var r=i.filter((t=>t.id===e))[0];this._surveyManager.renderSurvey(r,null==a?void 0:a.querySelector(t))}))}}var Ro=B("[RateLimiter]");class $o{constructor(e){var t,i;W(this,"serverLimits",{}),W(this,"lastEventRateLimited",!1),W(this,"checkForLimiting",(e=>{var t=e.text;if(t&&t.length)try{(JSON.parse(t).quota_limited||[]).forEach((e=>{Ro.info("".concat(e||"events"," is quota limited.")),this.serverLimits[e]=(new Date).getTime()+6e4}))}catch(e){return void Ro.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===(i=e.config.rate_limiting)||void 0===i?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}clientRateLimitContext(){var e,t,i,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=(new Date).getTime(),s=null!==(e=null===(t=this.instance.persistence)||void 0===t?void 0:t.get_property(qe))&&void 0!==e?e:{tokens:this.captureEventsBurstLimit,last:n};s.tokens+=(n-s.last)/1e3*this.captureEventsPerSecond,s.last=n,s.tokens>this.captureEventsBurstLimit&&(s.tokens=this.captureEventsBurstLimit);var o=s.tokens<1;return o||r||(s.tokens=Math.max(0,s.tokens-1)),!o||this.lastEventRateLimited||r||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(qe,s),{isRateLimited:o,remainingTokens:s.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return!1!==t&&(new Date).getTime()e(this.remoteConfig))):(Oo.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 Oo.info("Using preloaded remote config",this.remoteConfig),void this._onRemoteConfig(this.remoteConfig);if(this._instance.config.advanced_disable_decide)return void Oo.warn("Remote config is disabled. Falling back to local config.");this._loadRemoteConfigJs((e=>{if(!e)return Oo.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){Oo.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()):Oo.info("__preview_remote_config is disabled. Logging config instead",e):Oo.error("Failed to fetch remote config from PostHog.")}}var Ao=function(e){var t,i,r,n,s="";for(t=i=0,r=(e=(e+"").replace(/\r\n/g,"\n").replace(/\r/g,"\n")).length,n=0;n127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),$(a)||(i>t&&(s+=e.substring(t,i)),s+=a,t=i=n+1)}return i>t&&(s+=e.substring(t,e.length)),s},Lo=!!c||!!u,Do="text/plain",qo=(e,t)=>{var[i,r]=e.split("?"),n=z({},t);null==r||r.split("&").forEach((e=>{var[t]=e.split("=");delete n[t]}));var s=kt(n);return s=s?(r?r+"&":"")+s:r,"".concat(i,"?").concat(s)},No=(e,t)=>JSON.stringify(e,((e,t)=>"bigint"==typeof t?t.toString():t),t),Bo=t=>{var{data:i,compression:r}=t;if(i){if(r===e.GZipJS){var n=$r(Or(No(i)),{mtime:0}),s=new Blob([n],{type:Do});return{contentType:Do,body:s,estimatedSize:s.size}}if(r===e.Base64){var o=function(e){var t,i,r,n,s,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",a=0,l=0,u="",c=[];if(!e)return e;e=Ao(e);do{t=(s=e.charCodeAt(a++)<<16|e.charCodeAt(a++)<<8|e.charCodeAt(a++))>>18&63,i=s>>12&63,r=s>>6&63,n=63&s,c[l++]=o.charAt(t)+o.charAt(i)+o.charAt(r)+o.charAt(n)}while(a"data="+encodeURIComponent("string"==typeof e?e:No(e)))(o);return{contentType:"application/x-www-form-urlencoded",body:a,estimatedSize:new Blob([a]).size}}var l=No(i);return{contentType:"application/json",body:l,estimatedSize:new Blob([l]).size}}},Ho=[];u&&Ho.push({transport:"fetch",method:e=>{var t,i,{contentType:r,body:n,estimatedSize:s}=null!==(t=Bo(e))&&void 0!==t?t:{},o=new Headers;Y(e.headers,(function(e,t){o.append(t,e)})),r&&o.append("Content-Type",r);var a=e.url,l=null;if(d){var c=new d;l={signal:c.signal,timeout:setTimeout((()=>c.abort()),e.timeout)}}u(a,z({method:(null==e?void 0:e.method)||"GET",headers:o,keepalive:"POST"===e.method&&(s||0)<52428.8,body:n,signal:null===(i=l)||void 0===i?void 0:i.signal},e.fetchOptions)).then((t=>t.text().then((i=>{var r,n={statusCode:t.status,text:i};if(200===t.status)try{n.json=JSON.parse(i)}catch(e){N.error(e)}null===(r=e.callback)||void 0===r||r.call(e,n)})))).catch((t=>{var i;N.error(t),null===(i=e.callback)||void 0===i||i.call(e,{statusCode:0,text:t})})).finally((()=>l?clearTimeout(l.timeout):null))}}),c&&Ho.push({transport:"XHR",method:e=>{var t,i=new c;i.open(e.method||"GET",e.url,!0);var{contentType:r,body:n}=null!==(t=Bo(e))&&void 0!==t?t:{};Y(e.headers,(function(e,t){i.setRequestHeader(t,e)})),r&&i.setRequestHeader("Content-Type",r),e.timeout&&(i.timeout=e.timeout),i.withCredentials=!0,i.onreadystatechange=()=>{if(4===i.readyState){var t,r={statusCode:i.status,text:i.responseText};if(200===i.status)try{r.json=JSON.parse(i.responseText)}catch(e){}null===(t=e.callback)||void 0===t||t.call(e,r)}},i.send(n)}}),null!=o&&o.sendBeacon&&Ho.push({transport:"sendBeacon",method:e=>{var t=qo(e.url,{beacon:"1"});try{var i,{contentType:r,body:n}=null!==(i=Bo(e))&&void 0!==i?i:{},s="string"==typeof n?new Blob([n],{type:r}):n;o.sendBeacon(t,s)}catch(e){}}});var jo=3e3;class Uo{constructor(e,t){W(this,"_isPaused",!0),W(this,"_queue",[]),this._flushTimeoutMs=Ji((null==t?void 0:t.flush_interval_ms)||jo,250,5e3,"flush interval",jo),this._sendRequest=e}enqueue(e){this._queue.push(e),this._flushTimeout||this._setFlushTimeout()}unload(){this._clearFlushTimeout();var e=this._queue.length>0?this._formatQueue():{},t=Object.values(e),i=[...t.filter((e=>0===e.url.indexOf("/e"))),...t.filter((e=>0!==e.url.indexOf("/e")))];i.map((e=>{this._sendRequest(z(z({},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 r=t[i],n=(new Date).getTime();r.data&&x(r.data)&&Y(r.data,(e=>{e.offset=Math.abs(e.timestamp-n),delete e.timestamp})),e._sendRequest(r)};for(var r in t)i(r)}}),this._flushTimeoutMs))}_clearFlushTimeout(){clearTimeout(this._flushTimeout),this._flushTimeout=void 0}_formatQueue(){var e={};return Y(this._queue,(t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;F(e[n])&&(e[n]=z(z({},r),{},{data:[]})),null===(i=e[n].data)||void 0===i||i.push(r.data)})),this._queue=[],e}}var zo=["retriesPerformedSoFar"];class Wo{constructor(e){W(this,"_isPolling",!1),W(this,"_pollIntervalMs",3e3),W(this,"_queue",[]),this._instance=e,this._queue=[],this._areWeOnline=!0,!F(t)&&"onLine"in t.navigator&&(this._areWeOnline=t.navigator.onLine,oe(t,"online",(()=>{this._areWeOnline=!0,this._flush()})),oe(t,"offline",(()=>{this._areWeOnline=!1})))}get length(){return this._queue.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=G(e,zo);M(t)&&t>0&&(i.url=qo(i.url,{retry_count:t})),this._instance._send_request(z(z({},i),{},{callback:e=>{var r;200!==e.statusCode&&(e.statusCode<400||e.statusCode>=500)&&(null!=t?t:0)<10?this._enqueue(z({retriesPerformedSoFar:t},i)):null===(r=i.callback)||void 0===r||r.call(i,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,r=Math.min(18e5,t),n=(Math.random()-.5)*(r-i);return Math.ceil(r+n)}(t),r=Date.now()+i;this._queue.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in ".concat(i);navigator.onLine||(n+=" (Browser is offline)"),N.warn(n),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.retryAt0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this._poller&&(clearTimeout(this._poller),this._poller=void 0),this._queue))try{this._instance._send_request(z(z({},e),{},{transport:"sendBeacon"}))}catch(e){N.error(e)}this._queue=[]}}class Go{constructor(e){W(this,"_updateScrollData",(()=>{var e,t,i,r;this._context||(this._context={});var n=this.scrollElement(),s=this.scrollY(),o=n?Math.max(0,n.scrollHeight-n.clientHeight):0,a=s+((null==n?void 0:n.clientHeight)||0),l=(null==n?void 0:n.scrollHeight)||0;this._context.lastScrollY=Math.ceil(s),this._context.maxScrollY=Math.max(s,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!==(r=this._context.maxContentHeight)&&void 0!==r?r:0)})),this._instance=e}getContext(){return this._context}resetContext(){var e=this._context;return setTimeout(this._updateScrollData,0),e}startMeasuringScrollPosition(){oe(t,"scroll",this._updateScrollData,{capture:!0}),oe(t,"scrollend",this._updateScrollData,{capture:!0}),oe(t,"resize",this._updateScrollData)}scrollElement(){if(!this._instance.config.scroll_root_selector)return null==t?void 0:t.document.documentElement;var e=x(this._instance.config.scroll_root_selector)?this._instance.config.scroll_root_selector:[this._instance.config.scroll_root_selector];for(var i of e){var r=null==t?void 0:t.document.querySelector(i);if(r)return r}}scrollY(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollTop||0}return t&&(t.scrollY||t.pageYOffset||t.document.documentElement.scrollTop)||0}scrollX(){if(this._instance.config.scroll_root_selector){var e=this.scrollElement();return e&&e.scrollLeft||0}return t&&(t.scrollX||t.pageXOffset||t.document.documentElement.scrollLeft)||0}}var Vo=e=>ms(null==e?void 0:e.config.mask_personal_data_properties,null==e?void 0:e.config.custom_personal_data_properties);class Jo{constructor(e,t,i,r){W(this,"_onSessionIdCallback",(e=>{var t=this._getStored();if(!t||t.sessionId!==e){var i={sessionId:e,props:this._sessionSourceParamGenerator(this._instance)};this._persistence.register({[De]:i})}})),this._instance=e,this._sessionIdManager=t,this._persistence=i,this._sessionSourceParamGenerator=r||Vo,this._sessionIdManager.onSessionId(this._onSessionIdCallback)}_getStored(){return this._persistence.props[De]}getSetOnceProps(){var e,t=null===(e=this._getStored())||void 0===e?void 0:e.props;return t?"r"in t?ys(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 Y(te(this.getSetOnceProps()),((t,i)=>{"$current_url"===i&&(i="url"),e["$session_entry_".concat(b(i))]=t})),e}}var Yo=B("[SessionId]");class Ko{constructor(e,t,i){var r;if(W(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||Nt,this._windowIdGenerator=i||Nt;var n=this._config.persistence_name||this._config.token,s=this._config.session_idle_timeout_seconds||1800;if(this._sessionTimeoutMs=1e3*Ji(s,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 o=ei.parse(this._window_id_storage_key),a=ei.parse(this._primary_window_exists_storage_key);o&&!a?this._windowId=o:ei.remove(this._window_id_storage_key),ei.set(this._primary_window_exists_storage_key,!0)}if(null!==(r=this._config.bootstrap)&&void 0!==r&&r.sessionID)try{var l=(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(),l)}catch(e){Yo.error("Invalid sessionID in bootstrap",e)}this._listenToReloadWindow()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return F(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&&ei.is_supported()}_setWindowId(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&ei.set(this._window_id_storage_key,e))}_getWindowId(){return this._windowId?this._windowId:this._canUseSessionStorage()?ei.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({[Ee]:[t,e,i]}))}_getSessionId(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this._persistence.props[Ee];return x(e)&&2===e.length&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this._setSessionId(null,null,null)}_listenToReloadWindow(){oe(t,"beforeunload",(()=>{this._canUseSessionStorage()&&ei.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(),[r,n,s]=this._getSessionId(),o=this._getWindowId(),a=M(s)&&s>0&&Math.abs(i-s)>864e5,l=!1,u=!n,c=!e&&Math.abs(i-r)>this.sessionTimeoutMs;u||c||a?(n=this._sessionIdGenerator(),o=this._windowIdGenerator(),Yo.info("new session ID generated",{sessionId:n,windowId:o,changeReason:{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}}),s=i,l=!0):o||(o=this._windowIdGenerator(),l=!0);var d=0===r||!e||a?i:r,_=0===s?(new Date).getTime():s;return this._setWindowId(o),this._setSessionId(n,d,_),e||this._resetIdleTimer(),l&&this._sessionIdChangedHandlers.forEach((e=>e(n,o,l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0))),{sessionId:n,windowId:o,sessionStartTimestamp:_,changeReason:l?{noSessionId:u,activityTimeout:c,sessionPastMaximumLength:a}:void 0,lastActivityTimestamp:r}}_resetIdleTimer(){clearTimeout(this._enforceIdleTimeout),this._enforceIdleTimeout=setTimeout((()=>{this.resetSessionId()}),1.1*this.sessionTimeoutMs)}}var Xo=["$set_once","$set"],Qo=B("[SiteApps]");class Zo{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=h._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 t,i,r,n,s,o,a;if(!e)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var[d,_]of Object.entries(c))l[d]={id:u[d],type:d,properties:_};var{$set_once:h,$set:p}=e;return{event:z(z({},G(e,Xo)),{},{properties:z(z(z({},e.properties),p?{$set:z(z({},null!==(t=null===(i=e.properties)||void 0===i?void 0:i.$set)&&void 0!==t?t:{}),p)}:{}),h?{$set_once:z(z({},null!==(r=null===(n=e.properties)||void 0===n?void 0:n.$set_once)&&void 0!==r?r:{}),h)}:{}),elements_chain:null!==(s=null===(o=e.properties)||void 0===o?void 0:o.$elements_chain)&&void 0!==s?s:"",distinct_id:null===(a=e.properties)||void 0===a?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(e){var t=this.apps[e.id],i=()=>{var i;(!t.errored&&this._bufferedInvocations.length&&(Qo.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))},r=!1,n=n=>{t.errored=!n,t.loaded=!0,Qo.info("Site app with id ".concat(e.id," ").concat(n?"loaded":"errored")),r&&i()};try{var{processEvent:s}=e.init({posthog:this._instance,callback:e=>{n(e)}});s&&(t.processEvent=s),r=!0}catch(t){Qo.error("Error while initializing PostHog app with config id ".concat(e.id),t),n(!1)}if(r&&t.loaded)try{i()}catch(i){Qo.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 r;null===(r=i.processEvent)||void 0===r||r.call(i,t)}catch(t){Qo.error("Error while processing event ".concat(e.event," for site app ").concat(i.id),t)}}}onRemoteConfig(e){var t,i,r,n=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 Qo.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!==(r=e.siteApps)&&void 0!==r&&r.length)if(this.isEnabled){var s=function(e,t){var i,r;h["__$$ph_site_app_".concat(e)]=n._instance,null===(i=h.__PosthogExtensions__)||void 0===i||null===(r=i.loadSiteApp)||void 0===r||r.call(i,n._instance,t,(t=>{if(t)return Qo.error("Error while initializing PostHog app with config id ".concat(e),t)}))};for(var{id:o,url:a}of e.siteApps)s(o,a)}else Qo.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}var ea,ta=["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"],ia=function(e,t){if(!e)return!1;var i=e.toLowerCase();return ta.concat(t||[]).some((e=>{var t=e.toLowerCase();return-1!==i.indexOf(t)}))},ra=function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&ia(i,t))return!0;try{var r=null==e?void 0:e.userAgentData;if(null!=r&&r.brands&&r.brands.some((e=>ia(null==e?void 0:e.brand,t))))return!0}catch(e){}return!!e.webdriver};function na(e,t,i){return No({distinct_id:e,userPropertiesToSet:t,userPropertiesToSetOnce:i})}!function(e){e.US="us",e.EU="eu",e.CUSTOM="custom"}(ea||(ea={}));var sa="i.posthog.com";class oa{constructor(e){W(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(sa),".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]=ea.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=ea.EU:this._regionCache[this.apiHost]=ea.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===ea.CUSTOM)return this.apiHost+t;var i=sa+t;switch(e){case"assets":return"https://".concat(this.region,"-assets.").concat(i);case"api":return"https://".concat(this.region,".").concat(i)}}}var aa={icontains:(e,i)=>!!t&&i.href.toLowerCase().indexOf(e.toLowerCase())>-1,not_icontains:(e,i)=>!!t&&-1===i.href.toLowerCase().indexOf(e.toLowerCase()),regex:(e,i)=>!!t&&ko(i.href,e),not_regex:(e,i)=>!!t&&!ko(i.href,e),exact:(e,t)=>t.href===e,is_not:(e,t)=>t.href!==e};class la{constructor(e){var t=this;W(this,"getWebExperimentsAndEvaluateDisplayLogic",(function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0];t.getWebExperiments((e=>{la._logInfo("retrieved web experiments from the server"),t._flagToExperiments=new Map,e.forEach((e=>{if(e.feature_flag_key){var i;if(t._flagToExperiments)la._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 r=t._instance.getFeatureFlag(e.feature_flag_key);T(r)&&e.variants[r]&&t._applyTransforms(e.name,r,e.variants[r].transforms)}else if(e.variants)for(var n in e.variants){var s=e.variants[n];la._matchesTestVariant(s)&&t._applyTransforms(e.name,n,s.transforms)}}))}),e)})),this._instance=e,this._instance.onFeatureFlags((e=>{this.onFeatureFlags(e)}))}onFeatureFlags(e){if(this._is_bot())la._logInfo("Refusing to render web experiment since the viewer is a likely bot");else if(!this._instance.config.disable_web_experiments){if(O(this._flagToExperiments))return this._flagToExperiments=new Map,this.loadIfEnabled(),void this.previewWebExperiment();la._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,r=this._instance.getFeatureFlag(e),n=null===(i=this._flagToExperiments)||void 0===i?void 0:i.get(e);r&&null!=n&&n.variants[r]&&this._applyTransforms(n.name,r,n.variants[r].transforms)}}))}}previewWebExperiment(){var e=la.getWindowLocation();if(null!=e&&e.search){var t=Et(null==e?void 0:e.search,"__experiment_id"),i=Et(null==e?void 0:e.search,"__experiment_variant");t&&i&&(la._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 r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);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 r=i.filter((t=>t.id===e));r&&r.length>0&&(la._logInfo("Previewing web experiment [".concat(r[0].name,"] with variant [").concat(t,"]")),this._applyTransforms(r[0].name,t,r[0].variants[t].transforms))}static _matchesTestVariant(e){return!O(e.conditions)&&(la._matchUrlConditions(e)&&la._matchUTMConditions(e))}static _matchUrlConditions(e){var t;if(O(e.conditions)||O(null===(t=e.conditions)||void 0===t?void 0:t.url))return!0;var i,r,n,s=la.getWindowLocation();return!!s&&(null===(i=e.conditions)||void 0===i||!i.url||aa[null!==(r=null===(n=e.conditions)||void 0===n?void 0:n.urlMatchType)&&void 0!==r?r:"icontains"](e.conditions.url,s))}static getWindowLocation(){return null==t?void 0:t.location}static _matchUTMConditions(e){var t;if(O(e.conditions)||O(null===(t=e.conditions)||void 0===t?void 0:t.utm))return!0;var i=hs();if(i.utm_source){var r,n,s,o,a,l,u,c,d,_,h,p,v,g,f,m,y=null===(r=e.conditions)||void 0===r||null===(n=r.utm)||void 0===n||!n.utm_campaign||(null===(s=e.conditions)||void 0===s||null===(o=s.utm)||void 0===o?void 0:o.utm_campaign)==i.utm_campaign,b=null===(a=e.conditions)||void 0===a||null===(l=a.utm)||void 0===l||!l.utm_source||(null===(u=e.conditions)||void 0===u||null===(c=u.utm)||void 0===c?void 0:c.utm_source)==i.utm_source,w=null===(d=e.conditions)||void 0===d||null===(_=d.utm)||void 0===_||!_.utm_medium||(null===(h=e.conditions)||void 0===h||null===(p=h.utm)||void 0===p?void 0:p.utm_medium)==i.utm_medium,S=null===(v=e.conditions)||void 0===v||null===(g=v.utm)||void 0===g||!g.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 y&&w&&S&&b}return!1}static _logInfo(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;r{if(i.selector){var r;la._logInfo("applying transform of variant ".concat(t," for experiment ").concat(e," "),i);var n=null===(r=document)||void 0===r?void 0:r.querySelectorAll(i.selector);null==n||n.forEach((e=>{var t=e;i.html&&(t.innerHTML=i.html),i.css&&t.setAttribute("style",i.css)}))}})):la._logInfo("Control variants leave the page unmodified.")}_is_bot(){return o&&this._instance?ra(o,this._instance.config.custom_blocked_useragents):void 0}}function ua(e,t,i){try{if(!(t in e))return()=>{};var r=e[t],n=i(r);return I(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0}})),e[t]=n,()=>{e[t]=r}}catch(e){return()=>{}}}class ca{constructor(e){var i;this._instance=e,this._lastPathname=(null==t||null===(i=t.location)||void 0===i?void 0:i.pathname)||""}get isEnabled(){return"history_change"===this._instance.config.capture_pageview}startIfEnabled(){this.isEnabled&&(N.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this._popstateListener&&this._popstateListener(),this._popstateListener=void 0,N.info("History API monitoring stopped")}monitorHistoryChanges(){var e,i;if(t&&t.history){var r=this;null!==(e=t.history.pushState)&&void 0!==e&&e.__posthog_wrapped__||ua(t.history,"pushState",(e=>function(t,i,n){e.call(this,t,i,n),r._capturePageview("pushState")})),null!==(i=t.history.replaceState)&&void 0!==i&&i.__posthog_wrapped__||ua(t.history,"replaceState",(e=>function(t,i,n){e.call(this,t,i,n),r._capturePageview("replaceState")})),this._setupPopstateListener()}}_capturePageview(e){try{var i,r=null==t||null===(i=t.location)||void 0===i?void 0:i.pathname;if(!r)return;r!==this._lastPathname&&this.isEnabled&&this._instance.capture("$pageview",{navigation_type:e}),this._lastPathname=r}catch(t){N.error("Error capturing ".concat(e," pageview"),t)}}_setupPopstateListener(){if(!this._popstateListener){var e=()=>{this._capturePageview("popstate")};oe(t,"popstate",e),this._popstateListener=()=>{t&&t.removeEventListener("popstate",e)}}}}var da={},_a=()=>{},ha="posthog",pa=!Lo&&-1===(null==_?void 0:_.indexOf("MSIE"))&&-1===(null==_?void 0:_.indexOf("Mozilla")),va=()=>{var e;return{api_host:"https://us.i.posthog.com",ui_host:null,token:"",autocapture:!0,rageclick:!0,cross_subdomain_cookie:ne(null==a?void 0:a.location),persistence:"localStorage+cookie",persistence_name:"",loaded:_a,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageview:!0,capture_pageleave:"if_capture_pageview",debug:l&&T(null==l?void 0:l.search)&&-1!==l.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==t||null===(e=t.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;N.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:jo},_onCapture:_a}},ga=e=>{var t={};F(e.process_person)||(t.person_profiles=e.process_person),F(e.xhr_headers)||(t.request_headers=e.xhr_headers),F(e.cookie_name)||(t.persistence_name=e.cookie_name),F(e.disable_cookie)||(t.disable_persistence=e.disable_cookie),F(e.store_google)||(t.save_campaign_params=e.store_google),F(e.verbose)||(t.debug=e.verbose);var i=K({},t,e);return x(e.property_blacklist)&&(F(e.property_denylist)?i.property_denylist=e.property_blacklist:x(e.property_denylist)?i.property_denylist=[...e.property_blacklist,...e.property_denylist]:N.error("Invalid value for property_denylist config: "+e.property_denylist)),i};class fa{constructor(){W(this,"__forceAllowLocalhost",!1)}get _forceAllowLocalhost(){return this.__forceAllowLocalhost}set _forceAllowLocalhost(e){N.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}}class ma{get decideEndpointWasHit(){var e,t;return null!==(e=null===(t=this.featureFlags)||void 0===t?void 0:t.hasLoadedFlags)&&void 0!==e&&e}constructor(){W(this,"webPerformance",new fa),W(this,"_personProcessingSetOncePropertiesSent",!1),W(this,"version",p.LIB_VERSION),W(this,"_internalEventEmitter",new Co),this.config=va(),this.SentryIntegration=Yr,this.sentryIntegration=e=>function(e,t){var i=Jr(e,t);return{name:Vr,processEvent:e=>i(e)}}(this,e),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this._initialPageviewCaptured=!1,this._initialPersonProfilesConfig=null,this._cachedPersonProperties=null,this.featureFlags=new $s(this),this.toolbar=new en(this),this.scrollManager=new Go(this),this.pageViewManager=new cn(this),this.surveys=new To(this),this.experiments=new la(this),this.exceptions=new dn(this),this.rateLimiter=new $o(this),this.requestRouter=new oa(this),this.consent=new ti(this),this.people={set:(e,t,i)=>{var r=T(e)?{[e]:t}:e;this.setPersonProperties(r),null==i||i({})},set_once:(e,t,i)=>{var r=T(e)?{[e]:t}:e;this.setPersonProperties(void 0,r),null==i||i({})}},this.on("eventCaptured",(e=>N.info('send "'.concat(null==e?void 0:e.event,'"'),e)))}init(e,t,i){if(i&&i!==ha){var r,n=null!==(r=da[i])&&void 0!==r?r:new ma;return n._init(e,t,i),da[i]=n,da[ha][i]=n,n}return this._init(e,t,i)}_init(i){var r,n,s=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(F(i)||R(i))return N.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 N.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],s.person_profiles&&(this._initialPersonProfilesConfig=s.person_profiles),this.set_config(K({},va(),ga(s),{name:o,token:i})),this.config.on_xhr_error&&N.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:e.GZipJS,this.persistence=new Ms(this.config),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ms(z(z({},this.config),{},{persistence:"sessionStorage"}));var a=z({},this.persistence.props),l=z({},this.sessionPersistence.props);if(this._requestQueue=new Uo((e=>this._send_retriable_request(e)),this.config.request_queue_config),this._retryQueue=new Wo(this),this.__request_queue=[],this.config.__preview_experimental_cookieless_mode||(this.sessionManager=new Ko(this),this.sessionPropsManager=new Jo(this,this.sessionManager,this.persistence)),new rn(this).startIfEnabledOrStop(),this.siteApps=new Zo(this),null===(r=this.siteApps)||void 0===r||r.init(),this.config.__preview_experimental_cookieless_mode||(this.sessionRecording=new zr(this),this.sessionRecording.startIfEnabledOrStop()),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new $t(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new un(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new on(this),this.exceptionObserver=new ai(this),this.exceptionObserver.startIfEnabled(),this.deadClicksAutocapture=new si(this,ni),this.deadClicksAutocapture.startIfEnabled(),this.historyAutocapture=new ca(this),this.historyAutocapture.startIfEnabled(),p.DEBUG=p.DEBUG||this.config.debug,p.DEBUG&&N.info("Starting in debug mode",{this:this,config:s,thisC:z({},this.config),p:a,s:l}),this._sync_opt_out_with_persistence(),void 0!==(null===(n=s.bootstrap)||void 0===n?void 0:n.distinctID)){var u,c,d=this.config.get_device_id(Nt()),_=null!==(u=s.bootstrap)&&void 0!==u&&u.isIdentifiedID?d:s.bootstrap.distinctID;this.persistence.set_property(Le,null!==(c=s.bootstrap)&&void 0!==c&&c.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:s.bootstrap.distinctID,$device_id:_})}if(this._hasBootstrappedFeatureFlags()){var h,v,g=Object.keys((null===(h=s.bootstrap)||void 0===h?void 0:h.featureFlags)||{}).filter((e=>{var t,i;return!(null===(t=s.bootstrap)||void 0===t||null===(i=t.featureFlags)||void 0===i||!i[e])})).reduce(((e,t)=>{var i,r;return e[t]=(null===(i=s.bootstrap)||void 0===i||null===(r=i.featureFlags)||void 0===r?void 0:r[t])||!1,e}),{}),f=Object.keys((null===(v=s.bootstrap)||void 0===v?void 0:v.featureFlagPayloads)||{}).filter((e=>g[e])).reduce(((e,t)=>{var i,r,n,o;null!==(i=s.bootstrap)&&void 0!==i&&null!==(r=i.featureFlagPayloads)&&void 0!==r&&r[t]&&(e[t]=null===(n=s.bootstrap)||void 0===n||null===(o=n.featureFlagPayloads)||void 0===o?void 0:o[t]);return e}),{});this.featureFlags.receivedFeatureFlags({featureFlags:g,featureFlagPayloads:f})}if(this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:ze,$device_id:null},"");else if(!this.get_distinct_id()){var m=this.config.get_device_id(Nt());this.register_once({distinct_id:m,$device_id:m},""),this.persistence.set_property(Le,"anonymous")}return oe(t,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),this.toolbar.maybeLoadToolbar(),s.segment?Gr(this,(()=>this._loaded())):this._loaded(),I(this.config._onCapture)&&this.config._onCapture!==_a&&(N.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(e=>this.config._onCapture(e.event,e)))),this}_onRemoteConfig(t){var i,r,n,s,o,l,u,c;if(!a||!a.body)return N.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this._onRemoteConfig(t)}),500);this.compression=void 0,t.supportedCompression&&!this.config.disable_compression&&(this.compression=m(t.supportedCompression,e.GZipJS)?e.GZipJS:m(t.supportedCompression,e.Base64)?e.Base64:void 0),null!==(i=t.analytics)&&void 0!==i&&i.endpoint&&(this.analyticsDefaultEndpoint=t.analytics.endpoint),this.set_config({person_profiles:this._initialPersonProfilesConfig?this._initialPersonProfilesConfig:"identified_only"}),null===(r=this.siteApps)||void 0===r||r.onRemoteConfig(t),null===(n=this.sessionRecording)||void 0===n||n.onRemoteConfig(t),null===(s=this.autocapture)||void 0===s||s.onRemoteConfig(t),null===(o=this.heatmaps)||void 0===o||o.onRemoteConfig(t),this.surveys.onRemoteConfig(t),null===(l=this.webVitalsAutocapture)||void 0===l||l.onRemoteConfig(t),null===(u=this.exceptionObserver)||void 0===u||u.onRemoteConfig(t),null===(c=this.deadClicksAutocapture)||void 0===c||c.onRemoteConfig(t)}_loaded(){try{this.config.loaded(this)}catch(e){N.critical("`loaded` function failed",e)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout((()=>{this.consent.isOptedIn()&&this._captureInitialPageview()}),1),new Mo(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()||J(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&&(pa?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=qo(e.url,{ip:this.config.ip?1:0}),e.headers=z({},this.config.request_headers),e.compression="best-available"===e.compression?this.compression:e.compression,e.fetchOptions=e.fetchOptions||this.config.fetch_options,(e=>{var t,i,r,n=z({},e);n.timeout=n.timeout||6e4,n.url=qo(n.url,{_:(new Date).getTime().toString(),ver:p.LIB_VERSION,compression:n.compression});var s=null!==(t=n.transport)&&void 0!==t?t:"fetch",o=null!==(i=null===(r=se(Ho,(e=>e.transport===s)))||void 0===r?void 0:r.method)&&void 0!==i?i:Ho[0].method;if(!o)throw new Error("No available transport method");o(n)})(z(z({},e),{},{callback:t=>{var i,r,n;(this.rateLimiter.checkForLimiting(t),t.statusCode>=400)&&(null===(r=(n=this.config).on_request_error)||void 0===r||r.call(n,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=[],r=[],n=[];J(e,(e=>{e&&(t=e[0],x(t)?n.push(e):I(e)?e.call(this):x(e)&&"alias"===t?i.push(e):x(e)&&-1!==t.indexOf("capture")&&I(this[t])?n.push(e):r.push(e))}));var s=function(e,t){J(e,(function(e){if(x(e[0])){var i=t;Y(e,(function(e){i=i[e[0]].apply(i,e.slice(1))}))}else this[e[0]].apply(this,e.slice(1))}),t)};s(i,this),s(r,this),s(n,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,t,i){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!F(e)&&T(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var n=null!=i&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(null==n||!n.isRateLimited){null!=t&&t.$current_url&&!T(null==t?void 0:t.$current_url)&&(N.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),null==t||delete t.$current_url),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 s=new Date,o=(null==i?void 0:i.timestamp)||s,a=Nt(),l={uuid:a,event:e,properties:this._calculate_event_properties(e,t||{},o,a)};n&&(l.properties.$lib_rate_limit_remaining_tokens=n.remainingTokens),(null==i?void 0:i.$set)&&(l.$set=null==i?void 0:i.$set);var u=this._calculate_set_once_properties(null==i?void 0:i.$set_once);u&&(l.$set_once=u),(l=ie(l,null!=i&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=o,F(null==i?void 0:i.timestamp)||(l.properties.$event_time_override_provided=!0,l.properties.$event_time_override_system_time=s);var c=z(z({},l.properties.$set),l.$set);if(P(c)||this.setPersonPropertiesForFlags(c),!O(this.config.before_send)){var d=this._runBeforeSend(l);if(!d)return;l=d}this._internalEventEmitter.emit("eventCaptured",l);var _={method:"POST",url:null!==(r=null==i?void 0:i._url)&&void 0!==r?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:l,compression:"best-available",batchKey:null==i?void 0:i._batchKey};return!this.config.request_batching||i&&(null==i||!i._batchKey)||null!=i&&i.send_instantly?this._send_retriable_request(_):this._requestQueue.enqueue(_),l}N.critical("This capture call is ignored due to client rate limiting.")}}else N.error("No event name provided to posthog.capture")}else N.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}_calculate_event_properties(e,t,i,r){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var n=this.persistence.remove_event_timer(e),s=z({},t);if(s.token=this.config.token,this.config.__preview_experimental_cookieless_mode&&(s.$cookieless_mode=!0),"$snapshot"===e){var o=z(z({},this.persistence.properties()),this.sessionPersistence.properties());return s.distinct_id=o.distinct_id,(!T(s.distinct_id)&&!M(s.distinct_id)||R(s.distinct_id))&&N.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),s}var l,u=Ss(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:c,windowId:d}=this.sessionManager.checkAndGetSessionAndWindowId();s.$session_id=c,s.$window_id=d}this.sessionPropsManager&&K(s,this.sessionPropsManager.getSessionProps());try{var h;this.sessionRecording&&K(s,this.sessionRecording.sdkDebugProperties),s.$sdk_debug_retry_queue_size=null===(h=this._retryQueue)||void 0===h?void 0:h.length}catch(e){s.$sdk_debug_error_capturing_properties=String(e)}if(this.requestRouter.region===ea.CUSTOM&&(s.$lib_custom_api_host=this.config.api_host),l="$pageview"===e?this.pageViewManager.doPageView(i,r):"$pageleave"===e?this.pageViewManager.doPageLeave(i):this.pageViewManager.doEvent(),s=K(s,l),"$pageview"===e&&a&&(s.title=a.title),!F(n)){var p=i.getTime()-n;s.$duration=parseFloat((p/1e3).toFixed(3))}_&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?"bot":"browser"),(s=K({},u,this.persistence.properties(),this.sessionPersistence.properties(),s)).$is_identified=this._isIdentified(),x(this.config.property_denylist)?Y(this.config.property_denylist,(function(e){delete s[e]})):N.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(N.error("sanitize_properties is deprecated. Use before_send instead"),s=v(s,e));var g=this._hasPersonProcessing();return s.$process_person_profile=g,g&&this._requirePersonProcessing("_calculate_event_properties"),s}_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(),r=null===(t=this.sessionPropsManager)||void 0===t?void 0:t.getSetOnceProps(),n=K({},i,r||{},e||{}),s=this.config.sanitize_properties;return s&&(N.error("sanitize_properties is deprecated. Use before_send instead"),n=s(n,"$set_once")),this._personProcessingSetOncePropertiesSent=!0,P(n)?void 0:n}register(e,t){var i;null===(i=this.persistence)||void 0===i||i.register(e,t)}register_once(e,t,i){var r;null===(r=this.persistence)||void 0===r||r.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)}onSurveysLoaded(e){return this.surveys.onSurveysLoaded(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){return this.surveys.canRenderSurvey(e)}canRenderSurveyAsync(e){var t=arguments.length>1&&void 0!==arguments[1]&&arguments[1];return this.surveys.canRenderSurveyAsync(e,t)}identify(e,t,i){if(!this.__loaded||!this.persistence)return N.uninitializedWarning("posthog.identify");if(M(e)&&(e=e.toString(),N.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()))N.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(le)&&(this.unregister(le),this.register({distinct_id:e}));var s="anonymous"===(this.persistence.get_property(Le)||"anonymous");e!==r&&s?(this.persistence.set_property(Le,"identified"),this.setPersonPropertiesForFlags(z(z({},i||{}),t||{}),!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this._cachedPersonProperties=na(e,t,i),this.featureFlags.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(Ae))}}else N.error("Unique user id has not been set in posthog.identify")}setPersonProperties(e,t){if((e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")){var i=na(this.get_distinct_id(),e,t);this._cachedPersonProperties!==i?(this.setPersonPropertiesForFlags(z(z({},t||{}),e||{})),this.capture("$set",{$set:e||{},$set_once:t||{}}),this._cachedPersonProperties=i):N.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){if(this._requirePersonProcessing("posthog.group")){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:z(z({},r),{},{[e]:t})}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags({[e]:i})),r[e]===t||i||this.reloadFeatureFlags()}}else N.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,r,n;if(N.info("reset"),!this.__loaded)return N.uninitializedWarning("posthog.reset");var s=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===(r=this.persistence)||void 0===r||r.set_property(Le,"anonymous"),null===(n=this.sessionManager)||void 0===n||n.resetSessionId(),this._cachedPersonProperties=null,this.config.__preview_experimental_cookieless_mode)this.register_once({distinct_id:ze,$device_id:null},"");else{var o=this.config.get_device_id(Nt());this.register_once({distinct_id:o,$device_id:e?o:s},"")}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),r=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(t));if(null!=e&&e.withTimestamp&&i){var n,s=null!==(n=e.timestampLookBack)&&void 0!==n?n:10;if(!i)return r;var o=Math.max(Math.floor(((new Date).getTime()-i)/1e3)-s,0);r+="?t=".concat(o)}return r}alias(e,t){return e===this.get_property(ae)?(N.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(F(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(le,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(N.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t,i,r,n,s=z({},this.config);C(e)&&(K(this.config,ga(e)),null===(t=this.persistence)||void 0===t||t.update_config(this.config,s),this.sessionPersistence="sessionStorage"===this.config.persistence||"memory"===this.config.persistence?this.persistence:new Ms(z(z({},this.config),{},{persistence:"sessionStorage"})),Jt.is_supported()&&"true"===Jt.get("ph_debug")&&(this.config.debug=!0),this.config.debug&&(p.DEBUG=!0,N.info("set_config",JSON.stringify({config:e,oldConfig:s,newConfig:z({},this.config)},null,2))),null===(i=this.sessionRecording)||void 0===i||i.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 r,n,s,o,a;if(null===(r=this.sessionManager)||void 0===r||r.checkAndGetSessionAndWindowId(),i.sampling)null===(n=this.sessionRecording)||void 0===n||n.overrideSampling();if(i.linked_flag)null===(s=this.sessionRecording)||void 0===s||s.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,t){var i=new Error("PostHog syntheticException");this.exceptions.sendExceptionEvent(z(z({},Mi((e=>e instanceof Error)(e)?{error:e,event:e.message}:{event:e},{syntheticException:i})),t))}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:ha;return t!==ha&&(t=ha+"."+t),t}_isIdentified(){var e,t;return"identified"===(null===(e=this.persistence)||void 0===e?void 0:e.get_property(Le))||"identified"===(null===(t=this.sessionPersistence)||void 0===t?void 0:t.get_property(Le))}_hasPersonProcessing(){var e,t,i,r;return!("never"===this.config.person_profiles||"identified_only"===this.config.person_profiles&&!this._isIdentified()&&P(this.getGroups())&&(null===(e=this.persistence)||void 0===e||null===(t=e.props)||void 0===t||!t[le])&&(null===(i=this.persistence)||void 0===i||null===(r=i.props)||void 0===r||!r[je]))}_shouldCapturePageleave(){return!0===this.config.capture_pageleave||"if_capture_pageview"===this.config.capture_pageleave&&(!0===this.config.capture_pageview||"history_change"===this.config.capture_pageview)}createPersonProfile(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}_requirePersonProcessing(e){return"never"===this.config.person_profiles?(N.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(je,!0),!0)}_sync_opt_out_with_persistence(){var e,t,i,r,n=this.consent.isOptedOut(),s=this.config.opt_out_persistence_by_default,o=this.config.disable_persistence||n&&!!s;(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===(r=this.sessionPersistence)||void 0===r||r.set_disabled(o))}opt_in_capturing(e){var t;(this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),F(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 o?ra(o,this.config.custom_blocked_useragents):void 0}_captureInitialPageview(){a&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:a.title},{send_instantly:!0}))}debug(e){!1===e?(null==t||t.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(null==t||t.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(O(this.config.before_send))return e;var t=x(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),O(i)){var n="Event '".concat(e.event,"' was rejected in beforeSend function");return D(e.event)?N.warn("".concat(n,". This can cause unexpected behavior.")):N.info(n),null}i.properties&&!P(i.properties)||N.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