(function(Y,J){typeof exports=="object"&&typeof module<"u"?module.exports=J():typeof define=="function"&&define.amd?define(J):(Y=typeof globalThis<"u"?globalThis:Y||self,Y.$insights=J())})(this,function(){"use strict";var bl=Object.defineProperty;var wl=(Y,J,oe)=>J in Y?bl(Y,J,{enumerable:!0,configurable:!0,writable:!0,value:oe}):Y[J]=oe;var ri=(Y,J,oe)=>(wl(Y,typeof J!="symbol"?J+"":J,oe),oe),Lo=(Y,J,oe)=>{if(!J.has(Y))throw TypeError("Cannot "+oe)};var fn=(Y,J,oe)=>(Lo(Y,J,"read from private field"),oe?oe.call(Y):J.get(Y)),si=(Y,J,oe)=>{if(J.has(Y))throw TypeError("Cannot add the same private member more than once");J instanceof WeakSet?J.add(Y):J.set(Y,oe)},hr=(Y,J,oe,Lt)=>(Lo(Y,J,"write to private field"),Lt?Lt.call(Y,oe):J.set(Y,oe),oe);var ti,ni,Nt;function Y(n,e,t,i,r){for(e=e.split?e.split("."):e,i=0;i1&&(Ko(i,u.map(function(l){return l.replace(/[?[\]\\ ]/g,"")}),i[a]),delete i[a])}return i}(function(e){if(e){var t=e.match(/\?(.*)/);return t&&t[1]?t[1].split("#")[0]:""}return Ae&&window.location.search.substring(1)}(n))}function Ko(n,e,t){for(var i=e.length-1,r=0;r>4}return n}var jt="global",mt=rt+"global"+rt,yt=typeof self===oe&&self.self===self&&self||typeof global===oe&&global.global===global&&global||void 0;function st(n){return yt[mt][n]}function ot(n,e){return yt[mt][n]=e}function bt(n){delete yt[mt][n]}function wt(n,e,t){var i;try{if(oi(n)){var r=window[n];i=r[e].bind(r)}}catch{}return i||t}yt[mt]||(yt[mt]={});var mn={};function oi(n){if(typeof mn[n]!==J)return mn[n];try{var e=window[n];e.setItem(J,J),e.removeItem(J)}catch{return mn[n]=!1}return mn[n]=!0}function N(){return N=Object.assign||function(n){for(var e=1;e1;return ut===!1&&(o?ot(n,e):st(n)),o?document.cookie=n+"="+encodeURIComponent(e)+(t?"; expires="+new Date(+new Date+1e3*t).toUTCString()+(i?"; path="+i:"")+(r?"; domain="+r:"")+(s?"; secure":""):""):decodeURIComponent((("; "+document.cookie).split("; "+n+"=")[1]||"").split(";")[0])}}var Vt="localStorage",Ia=oi.bind(null,"localStorage");wt("localStorage","getItem",st),wt("localStorage","setItem",ot),wt("localStorage","removeItem",bt);var Gt="sessionStorage",Ea=oi.bind(null,"sessionStorage");wt("sessionStorage","getItem",st),wt("sessionStorage","setItem",ot),wt("sessionStorage","removeItem",bt);function Pt(n){var e=n;try{if((e=JSON.parse(n))==="true")return!0;if(e==="false")return!1;if(be(e))return e;parseFloat(e)===e&&(e=parseFloat(e))}catch{}if(e!==null&&e!=="")return e}var Pa=Ia(),xa=Ea(),$a=zt();function Xr(n,e){if(n){var t=pi(e),i=!mi(t),r=vi(t)?Pt(localStorage.getItem(n)):void 0;if(i&&!_t(r))return r;var s=gi(t)?Pt(Jr(n)):void 0;if(i&&s)return s;var o=_i(t)?Pt(sessionStorage.getItem(n)):void 0;if(i&&o)return o;var a=st(n);return i?a:{localStorage:r,sessionStorage:o,cookie:s,global:a}}}function Ra(n,e,t){if(n&&!_t(e)){var i={},r=pi(t),s=JSON.stringify(e),o=!mi(r);return vi(r)&&(i[Vt]=En(Vt,e,Pt(localStorage.getItem(n))),localStorage.setItem(n,s),o)?i[Vt]:gi(r)&&(i[Ht]=En(Ht,e,Pt(Jr(n))),hi(n,s),o)?i[Ht]:_i(r)&&(i[Gt]=En(Gt,e,Pt(sessionStorage.getItem(n))),sessionStorage.setItem(n,s),o)?i[Gt]:(i[jt]=En(jt,e,st(n)),ot(n,e),o?i[jt]:i)}}function Fa(n,e){if(n){var t=pi(e),i=Xr(n,pr),r={};return!_t(i.localStorage)&&vi(t)&&(localStorage.removeItem(n),r[Vt]=i.localStorage),!_t(i.cookie)&&gi(t)&&(Qr(n),r[Ht]=i.cookie),!_t(i.sessionStorage)&&_i(t)&&(sessionStorage.removeItem(n),r[Gt]=i.sessionStorage),!_t(i.global)&&In(t,jt)&&(bt(n),r[jt]=i.global),r}}function pi(n){return n?gt(n)?n:n.storage:Lt}function vi(n){return Pa&&In(n,Vt)}function gi(n){return $a&&In(n,Ht)}function _i(n){return xa&&In(n,Gt)}function mi(n){return n===pr||n==="all"}function In(n,e){return n===Lt||n===e||mi(n)}function En(n,e,t){return{location:n,current:e,previous:t}}var Oa={setItem:Ra,getItem:Xr,removeItem:Fa};function Ta(n,e,t){return e in n?Object.defineProperty(n,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):n[e]=t,n}function Yr(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function Kr(n){for(var e=1;e0&&arguments[0]!==void 0?arguments[0]:{},e={storage:Oa};return Sa(Kr(Kr({},e),n))}const yi={ping:"__INSIGHT_PING___",anonId:"__anon_id",anonIdCookie:"$$A_U_ID"};function Pn(n){return["projectworks.com","projectworks.io","projectworksapp.com"].find(t=>n.toLowerCase().includes(t))}const dr=class dr{constructor(){si(this,ti,yi.ping);si(this,ni,void 0);si(this,Nt,[]);ri(this,"$analytics");ri(this,"isInitialised",!1);ri(this,"isReady",!1)}async init(e={}){return this.isReady=!1,this.isInitialised=!1,fn(this,ni)??hr(this,ni,e),this.$analytics=Ca({app:e.app,version:e.version,debug:e.debug,plugins:await this.initPlugins(e.plugins)}),this.isInitialised=!0,this.once("ready",async()=>{this.isReady=!0;for await(const{method:t,args:i}of fn(this,Nt))try{await this[t].apply(this,i)}catch(r){console.error(r)}hr(this,Nt,[])}),this}plugins(){return this.$analytics.plugins}async track(e,t={},i={}){this.isReady?await new Promise(r=>{this.$analytics.track(e,t,i,()=>r())}):this.deferActionOnReady("track",arguments)}async identify(e,t={},i={}){if(this.isReady){if(!i.force&&this.isIdentified().user)return;await new Promise(r=>{this.$analytics.identify(e,t,i,()=>r())})}else this.deferActionOnReady("identify",arguments)}async page(e={},t={}){this.isReady?await new Promise(i=>{this.$analytics.page(e,t,()=>i())}):this.deferActionOnReady("page",arguments)}async reset(e={}){if(this.isReady){if(!e.force&&!this.isIdentified().user)return;if(e.clearCookies)for(const[t]of this.getCookies())this.removeCookie(t),this.removeCookie(t,`.${location.hostname}`),this.removeCookie(t,`.${Pn(location.hostname)}`);await new Promise(t=>{this.$analytics.reset(()=>t())})}else this.deferActionOnReady("reset",arguments)}async abTest(e){return new Promise((t,i)=>{const r=Date.now(),s=setInterval(()=>{if(this.isReady&&this.$analytics.plugins.posthog){clearInterval(s);const o=this.$analytics.plugins.posthog.abtest(e);t(o)}else Date.now()-r>2500&&(clearInterval(s),i("Timeout: Plugin not ready"))},10)})}ready(e){if(this.isInitialised)return this.$analytics.ready(e)}on(e,t){if(this.isInitialised)return this.$analytics.on(e,t)}once(e,t){if(this.isInitialised)return this.$analytics.once(e,t)}getState(){return this.$analytics.getState()}getCookies(){return document.cookie.split("; ").map(e=>e.split("="))}setCookie(e,t,i,r,s){zt()&&e&&(hi(e,t,i,s,r),this.pingStorageEventListeners())}removeCookie(e,t,i){zt()&&e&&(hi(e,"",-1,i,t),this.pingStorageEventListeners())}removeFromStorage(e,t="*"){this.$analytics.storage.removeItem(e,{storage:t})}getFromStorage(e,t="*"){return this.$analytics.storage.getItem(e,{storage:t})||void 0}setToStorage(e,t,i="*"){this.$analytics.storage.setItem(e,t,{storage:i})}newInstance(){return new dr}async initPlugins(e){const t=[];for await(const[i,r]of Object.entries(e))if(r)switch(i){case"anonIdfromCookie":{const s=(await Promise.resolve().then(()=>ja)).default;t.push(s());break}case"posthog":{const s=(await Promise.resolve().then(()=>yl)).default,o="https://web-ins-ph.projectworks.com";typeof r=="string"?t.push(s({token:r,proxyDomain:o})):t.push(s({token:r.token,proxyDomain:o,autocaptureEvents:r.autocaptureEvents}));break}}return t}pingStorageEventListeners(){this.$analytics.storage.setItem(fn(this,ti),Date.now(),{storage:"global"})}isIdentified(){const{user:e}=this.getState();return{user:!!(e!=null&&e.userId),anonymous:!!(e!=null&&e.anonymousId)}}deferActionOnReady(e,t){fn(this,Nt).push({method:e,args:t})}};ti=new WeakMap,ni=new WeakMap,Nt=new WeakMap;let bi=dr;const Aa=new bi;let xn;const Ma=new Uint8Array(16);function Na(){if(!xn&&(xn=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!xn))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return xn(Ma)}const de=[];for(let n=0;n<256;++n)de.push((n+256).toString(16).slice(1));function Da(n,e=0){return de[n[e+0]]+de[n[e+1]]+de[n[e+2]]+de[n[e+3]]+"-"+de[n[e+4]]+de[n[e+5]]+"-"+de[n[e+6]]+de[n[e+7]]+"-"+de[n[e+8]]+de[n[e+9]]+"-"+de[n[e+10]]+de[n[e+11]]+de[n[e+12]]+de[n[e+13]]+de[n[e+14]]+de[n[e+15]]}const Zr={randomUUID:typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto)};function La(n,e,t){if(Zr.randomUUID&&!e&&!n)return Zr.randomUUID();n=n||{};const i=n.random||(n.rng||Na)();if(i[6]=i[6]&15|64,i[8]=i[8]&63|128,e){t=t||0;for(let r=0;r<16;++r)e[t+r]=i[r];return e}return Da(i)}function qa(n={}){const e=yi.anonIdCookie,t=yi.anonId,i=r=>{const s=Pn(location.hostname);window.$insights.setCookie(e,r,365*24*60*60,s?`.${s}`:location.hostname)};return{name:"anon-id-from-cookie",config:Object.assign({},n),initializeStart:r=>{if(!zt())return r.abort("Browser has disabled cookies, or user has specified do-not-track");const s=r.instance.storage.getItem(e,{storage:"cookie"});if(s)r.instance.storage.setItem(t,s,{storage:"localStorage"});else{const o=r.instance.storage.getItem(t,{storage:"localStorage"});o&&i(o)}},setItemStart:r=>{if(r.payload.key===t){Pn(location.hostname)&&window.$insights.removeCookie(e,location.hostname);const o=r.instance.storage.getItem(e,{storage:"cookie"});if(o)return{...r.payload,value:o};i(r.payload.value)}},resetEnd:r=>{window.$insights.removeCookie(e,`.${Pn(location.hostname)}`),window.$insights.removeCookie(e,location.hostname),r.instance.storage.setItem(t,La(),{storage:"localStorage"})}}}const ja=Object.freeze(Object.defineProperty({__proto__:null,default:qa},Symbol.toStringTag,{value:"Module"}));function es(n,e){var t=Object.keys(n);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(n);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(n,r).enumerable})),t.push.apply(t,i)}return t}function I(n){for(var e=1;e=0||(c[u]=o[u]);return c}(n,e);if(Object.getOwnPropertySymbols){var s=Object.getOwnPropertySymbols(n);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(n,t)&&(r[t]=n[t])}return r}function ge(n,e){return function(t){if(Array.isArray(t))return t}(n)||function(t,i){var r=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(r!=null){var s,o,a=[],u=!0,l=!1;try{for(r=r.call(t);!(u=(s=r.next()).done)&&(a.push(s.value),!i||a.length!==i);u=!0);}catch(c){l=!0,o=c}finally{try{u||r.return==null||r.return()}finally{if(l)throw o}}return a}}(n,e)||wi(n,e)||function(){throw new TypeError(`Invalid attempt to destructure non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function Be(n){return function(e){if(Array.isArray(e))return ki(e)}(n)||function(e){if(typeof Symbol<"u"&&e[Symbol.iterator]!=null||e["@@iterator"]!=null)return Array.from(e)}(n)||wi(n)||function(){throw new TypeError(`Invalid attempt to spread non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}()}function wi(n,e){if(n){if(typeof n=="string")return ki(n,e);var t=Object.prototype.toString.call(n).slice(8,-1);return t==="Object"&&n.constructor&&(t=n.constructor.name),t==="Map"||t==="Set"?Array.from(n):t==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?ki(n,e):void 0}}function ki(n,e){(e==null||e>n.length)&&(e=n.length);for(var t=0,i=new Array(e);t=n.length?{done:!0}:{done:!1,value:n[i++]}},e:function(u){throw u},f:r}}throw new TypeError(`Invalid attempt to iterate non-iterable instance. In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}var s,o=!0,a=!1;return{s:function(){t=t.call(n)},n:function(){var u=t.next();return o=u.done,u},e:function(u){a=!0,s=u},f:function(){try{o||t.return==null||t.return()}finally{if(a)throw s}}}}var $e={DEBUG:!1,LIB_VERSION:"1.160.3"},Ua=Array.isArray,ns=Object.prototype,is=ns.hasOwnProperty,$n=ns.toString,ae=Ua||function(n){return $n.call(n)==="[object Array]"},Re=function(n){return typeof n=="function"},fe=function(n){return n===Object(n)&&!ae(n)},Rn=function(n){if(fe(n)){for(var e in n)if(is.call(n,e))return!1;return!0}return!1},O=function(n){return n===void 0},ve=function(n){return $n.call(n)=="[object String]"},rs=function(n){return ve(n)&&n.trim().length===0},Ue=function(n){return n===null},we=function(n){return O(n)||Ue(n)},Fe=function(n){return $n.call(n)=="[object Number]"},lt=function(n){return $n.call(n)==="[object Boolean]"},Ha=function(n){return n instanceof FormData},p=typeof window<"u"?window:void 0,ke=typeof globalThis<"u"?globalThis:p,ss=Array.prototype,os=ss.forEach,as=ss.indexOf,Me=ke==null?void 0:ke.navigator,$=ke==null?void 0:ke.document,Se=ke==null?void 0:ke.location,Si=ke==null?void 0:ke.fetch,Ii=ke!=null&&ke.XMLHttpRequest&&"withCredentials"in new ke.XMLHttpRequest?ke.XMLHttpRequest:void 0,us=ke==null?void 0:ke.AbortController,le=Me==null?void 0:Me.userAgent,Z=p??{},ls="[PostHog.js]",b={_log:function(n){if(p&&($e.DEBUG||Z.POSTHOG_DEBUG)&&!O(p.console)&&p.console){for(var e=("__rrweb_original__"in p.console[n])?p.console[n].__rrweb_original__:p.console[n],t=arguments.length,i=new Array(t>1?t-1:0),r=1;r1?e-1:0),i=1;i0&&(e[i]=t)}),e},Pi=function(n){return n.replace(/^\$/,"")};function Va(n,e){return t=n,i=function(s){return ve(s)&&!Ue(e)?s.slice(0,e):s},r=new Set,function s(o,a){return o!==Object(o)?i?i(o,a):o:r.has(o)?void 0:(r.add(o),ae(o)?(u=[],xt(o,function(l){u.push(s(l))})):(u={},X(o,function(l,c){r.has(l)||(u[c]=s(l,c))})),u);var u}(t);var t,i,r}var Ne,Ga=function(n){var e,t,i,r,s="";for(e=t=0,i=(n=(n+"").replace(/\r\n/g,` `).replace(/\r/g,` `)).length,r=0;r127&&o<2048?String.fromCharCode(o>>6|192,63&o|128):String.fromCharCode(o>>12|224,o>>6&63|128,63&o|128),Ue(a)||(t>e&&(s+=n.substring(e,t)),s+=a,e=t=r+1)}return t>e&&(s+=n.substring(e,n.length)),s},He=function(){function n(e){return e&&(e.preventDefault=n.preventDefault,e.stopPropagation=n.stopPropagation),e}return n.preventDefault=function(){this.returnValue=!1},n.stopPropagation=function(){this.cancelBubble=!0},function(e,t,i,r,s){if(e)if(e.addEventListener&&!r)e.addEventListener(t,i,!!s);else{var o="on"+t,a=e[o];e[o]=function(u,l,c){return function(d){if(d=d||n(p==null?void 0:p.event)){var h,f=!0;Re(c)&&(h=c(d));var _=l.call(u,d);return h!==!1&&_!==!1||(f=!1),f}}}(e,i,a)}else b.error("No valid element provided to register_event")}}();function fs(n,e){for(var t=0;t1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0){var i,r=this.getFlagVariants()[e],s="".concat(r),o=this.instance.get_property(Mn)||{};return(t.send_event||!("send_event"in t))&&(!(e in o)||!o[e].includes(s))&&(ae(o[e])?o[e].push(s):o[e]=[s],(i=this.instance.persistence)===null||i===void 0||i.register(m({},Mn,o)),this.instance.capture("$feature_flag_called",{$feature_flag:e,$feature_flag_response:r})),r}b.warn('getFeatureFlag for key "'+e+`" failed. Feature flags didn't load in time.`)}},{key:"getFeatureFlagPayload",value:function(e){return this.getFlagPayloads()[e]}},{key:"isFeatureEnabled",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(this.instance.decideEndpointWasHit||this.getFlags()&&this.getFlags().length>0)return!!this.getFeatureFlag(e,t);b.warn('isFeatureEnabled for key "'+e+`" failed. Feature flags didn't load in time.`)}},{key:"addFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers.push(e)}},{key:"removeFeatureFlagsHandler",value:function(e){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(function(t){return t!==e})}},{key:"receivedFeatureFlags",value:function(e,t){if(this.instance.persistence){this.instance.decideEndpointWasHit=!0;var i=this.getFlagVariants(),r=this.getFlagPayloads();(function(s,o){var a,u=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},l=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{},c=s.featureFlags,d=s.featureFlagPayloads;if(c)if(ae(c)){var h,f={};if(c)for(var _=0;_1&&arguments[1]!==void 0&&arguments[1];if(!this.instance.__loaded||!this.instance.persistence)return b.uninitializedWarning("posthog.feature_flags.override");if(this._override_warning=t,e===!1)this.instance.persistence.unregister(Dn);else if(ae(e)){for(var i={},r=0;r1&&arguments[1]!==void 0&&arguments[1],r=this.instance.get_property(Ri);if(r&&!i)return e(r);this.instance._send_request({transport:"XHR",url:this.instance.requestRouter.endpointFor("api","/api/early_access_features/?token=".concat(this.instance.config.token)),method:"GET",callback:function(s){var o;if(s.json){var a=s.json.earlyAccessFeatures;return(o=t.instance.persistence)===null||o===void 0||o.register(m({},Ri,a)),e(a)}}})}},{key:"_prepareFeatureFlagsForCallbacks",value:function(){var e=this.getFlags(),t=this.getFlagVariants();return{flags:e.filter(function(i){return t[i]}),flagVariants:Object.keys(t).filter(function(i){return t[i]}).reduce(function(i,r){return i[r]=t[r],i},{})}}},{key:"_fireFeatureFlagsCallbacks",value:function(e){var t=this._prepareFeatureFlagsForCallbacks(),i=t.flags,r=t.flagVariants;this.featureFlagEventHandlers.forEach(function(s){return s(i,r,{errorsLoading:e})})}},{key:"setPersonPropertiesForFlags",value:function(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],i=this.instance.get_property(Rt)||{};this.instance.register(m({},Rt,I(I({},i),e))),t&&this.instance.reloadFeatureFlags()}},{key:"resetPersonPropertiesForFlags",value:function(){this.instance.unregister(Rt)}},{key:"setGroupPropertiesForFlags",value:function(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1],i=this.instance.get_property(Ke)||{};Object.keys(i).length!==0&&Object.keys(i).forEach(function(r){i[r]=I(I({},i[r]),e[r]),delete e[r]}),this.instance.register(m({},Ke,I(I({},i),e))),t&&this.instance.reloadFeatureFlags()}},{key:"resetGroupPropertiesForFlags",value:function(e){if(e){var t=this.instance.get_property(Ke)||{};this.instance.register(m({},Ke,I(I({},t),{},m({},e,{}))))}else this.instance.unregister(Ke)}}]),n}();Math.trunc||(Math.trunc=function(n){return n<0?Math.ceil(n):Math.floor(n)}),Number.isInteger||(Number.isInteger=function(n){return Fe(n)&&isFinite(n)&&Math.floor(n)===n});var Ps="0123456789abcdef",Qa=function(){function n(e){if(V(this,n),this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}return G(n,[{key:"toString",value:function(){for(var e="",t=0;t>>4)+Ps.charAt(15&this.bytes[t]),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}},{key:"clone",value:function(){return new n(this.bytes.slice(0))}},{key:"equals",value:function(e){return this.compareTo(e)===0}},{key:"compareTo",value:function(e){for(var t=0;t<16;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}}],[{key:"fromFieldsV7",value:function(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 s=new Uint8Array(16);return s[0]=e/Math.pow(2,40),s[1]=e/Math.pow(2,32),s[2]=e/Math.pow(2,24),s[3]=e/Math.pow(2,16),s[4]=e/Math.pow(2,8),s[5]=e,s[6]=112|t>>>8,s[7]=t,s[8]=128|i>>>24,s[9]=i>>>16,s[10]=i>>>8,s[11]=i,s[12]=r>>>24,s[13]=r>>>16,s[14]=r>>>8,s[15]=r,new n(s)}}]),n}(),Xa=function(){function n(){V(this,n),m(this,"timestamp",0),m(this,"counter",0),m(this,"random",new Ya)}return G(n,[{key:"generate",value:function(){var e=this.generateOrAbort();if(O(e)){this.timestamp=0;var t=this.generateOrAbort();if(O(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}},{key:"generateOrAbort",value:function(){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 Qa.fromFieldsV7(this.timestamp,Math.trunc(this.counter/Math.pow(2,30)),this.counter&Math.pow(2,30)-1,this.random.nextUint32())}},{key:"resetCounter",value:function(){this.counter=1024*this.random.nextUint32()+(1023&this.random.nextUint32())}}]),n}(),xs=function(n){if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;e=this.buffer.length&&(xs(this.buffer),this.cursor=0),this.buffer[this.cursor++]}}]),n}(),Ze=function(){return Ka().toString()},Ka=function(){return($s||($s=new Xa)).generate()},Za="Thu, 01 Jan 1970 00:00:00 GMT",Yt="",eu=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i;function tu(n,e){if(e){var t=function(r){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:$;if(Yt)return Yt;if(!s||["localhost","127.0.0.1"].includes(r))return"";for(var o=r.split("."),a=Math.min(o.length,8),u="dmn_chk_"+Ze(),l=new RegExp("(^|;)\\s*"+u+"=1");!Yt&&a--;){var c=o.slice(a).join("."),d=u+"=1;domain=."+c;s.cookie=d,l.test(s.cookie)&&(s.cookie=d+";expires="+Za,Yt=c)}return Yt}(n);if(!t){var i=function(r){var s=r.match(eu);return s?s[0]:""}(n);i!==t&&b.info("Warning: cookie subdomain discovery mismatch",i,t),t=i}return t?"; domain=."+t:""}return""}var he,Ve={is_supported:function(){return!!$},error:function(n){b.error("cookieStore error: "+n)},get:function(n){if($){try{for(var e=n+"=",t=$.cookie.split(";").filter(function(s){return s.length}),i=0;i3686.4&&b.warn("cookieStore warning: large cookie, len="+l.length),$.cookie=l,l}catch{return}},remove:function(n,e){try{Ve.set(n,"",-1,e)}catch{return}}},Di=null,ue={is_supported:function(){if(!Ue(Di))return Di;var n=!0;if(O(p))n=!1;else try{var e="__mplssupport__";ue.set(e,"xyz"),ue.get(e)!=='"xyz"'&&(n=!1),ue.remove(e)}catch{n=!1}return n||b.error("localStorage unsupported; falling back to cookie store"),Di=n,n},error:function(n){b.error("localStorage error: "+n)},get:function(n){try{return p==null?void 0:p.localStorage.getItem(n)}catch(e){ue.error(e)}return null},parse:function(n){try{return JSON.parse(ue.get(n))||{}}catch{}return null},set:function(n,e){try{p==null||p.localStorage.setItem(n,JSON.stringify(e))}catch(t){ue.error(t)}},remove:function(n){try{p==null||p.localStorage.removeItem(n)}catch(e){ue.error(e)}}},nu=["distinct_id",Cn,Xt,Nn],Ln=I(I({},ue),{},{parse:function(n){try{var e={};try{e=Ve.parse(n)||{}}catch{}var t=_e(e,JSON.parse(ue.get(n)||"{}"));return ue.set(n,t),t}catch{}return null},set:function(n,e,t,i,r,s){try{ue.set(n,e,void 0,void 0,s);var o={};nu.forEach(function(a){e[a]&&(o[a]=e[a])}),Object.keys(o).length&&Ve.set(n,o,t,i,r,s)}catch(a){ue.error(a)}},remove:function(n,e){try{p==null||p.localStorage.removeItem(n),Ve.remove(n,e)}catch(t){ue.error(t)}}}),qn={},iu={is_supported:function(){return!0},error:function(n){b.error("memoryStorage error: "+n)},get:function(n){return qn[n]||null},parse:function(n){return qn[n]||null},set:function(n,e){qn[n]=e},remove:function(n){delete qn[n]}},ct=null,pe={is_supported:function(){if(!Ue(ct))return ct;if(ct=!0,O(p))ct=!1;else try{var n="__support__";pe.set(n,"xyz"),pe.get(n)!=='"xyz"'&&(ct=!1),pe.remove(n)}catch{ct=!1}return ct},error:function(n){b.error("sessionStorage error: ",n)},get:function(n){try{return p==null?void 0:p.sessionStorage.getItem(n)}catch(e){pe.error(e)}return null},parse:function(n){try{return JSON.parse(pe.get(n))||null}catch{}return null},set:function(n,e){try{p==null||p.sessionStorage.setItem(n,JSON.stringify(e))}catch(t){pe.error(t)}},remove:function(n){try{p==null||p.sessionStorage.removeItem(n)}catch(e){pe.error(e)}}},ru=["localhost","127.0.0.1"],Kt=function(n){var e=$==null?void 0:$.createElement("a");return O(e)?null:(e.href=n,e)},jn=function(n,e){return!!function(t){try{new RegExp(t)}catch{return!1}return!0}(e)&&new RegExp(e).test(n)},su=function(n){var e,t,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"&",r=[];return X(n,function(s,o){O(s)||O(o)||o==="undefined"||(e=encodeURIComponent(function(a){return a instanceof File}(s)?s.name:s.toString()),t=encodeURIComponent(o),r[r.length]=t+"="+e)}),r.join(i)},Rs=function(n,e){for(var t,i=((n.split("#")[0]||"").split("?")[1]||"").split("&"),r=0;r=3&&(e=O(n[2])?n[3]:n[2]),["watchOS",e]}],[new RegExp("("+qe+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+qe+")","i"),function(n){if(n&&n[2]){var e=[n[2],n[3],n[4]||"0"];return[qe,e.join(".")]}return[qe,""]}],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,function(n){var e=["Mac OS X",""];if(n&&n[1]){var t=[n[1],n[2],n[3]||"0"];e[1]=t.join(".")}return e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ou,""]],[/Linux|debian/i,["Linux",""]]],Js=function(n){return du.test(n)?tn:cu.test(n)?nn:lu.test(n)?Tt:new RegExp(Ui,"i").test(n)?Ui:new RegExp("("+Bi+"|WPDesktop)","i").test(n)?Bi:/iPad/.test(n)?Os:/iPod/.test(n)?"iPod Touch":/iPhone/.test(n)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(n)?Cs:Vi.test(n)?Ft:/(kobo)\s(ereader|touch)/i.test(n)?"Kobo":new RegExp(Hs,"i").test(n)?Hs:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(n)||/(kf[a-z]+)( bui|\)).+silk\//i.test(n)?"Kindle Fire":/(Android|ZTE)/i.test(n)?!new RegExp(Oe).test(n)||/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(n)?/pixel[\daxl ]{1,6}/i.test(n)&&!/pixel c/i.test(n)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(n)||/lmy47v/i.test(n)&&!/QTAQZ3/i.test(n)?qe:Fs:qe:new RegExp("(pda|"+Oe+")","i").test(n)?uu:new RegExp(Zt,"i").test(n)&&!new RegExp(Zt+" pc","i").test(n)?Vs:""},Hn="https?://(.*)",vu=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","gad_source","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","mc_cid","igshid","ttclid","rdt_cid"],ce={campaignParams:function(n){return $?this._campaignParamsFromUrl($.URL,n):{}},_campaignParamsFromUrl:function(n,e){var t=vu.concat(e||[]),i={};return X(t,function(r){var s=Rs(n,r);s&&(i[r]=s)}),i},_searchEngine:function(n){return n?n.search(Hn+"google.([^/?]*)")===0?"google":n.search(Hn+"bing.com")===0?"bing":n.search(Hn+"yahoo.com")===0?"yahoo":n.search(Hn+"duckduckgo.com")===0?"duckduckgo":null:null},_searchInfoFromReferrer:function(n){var e=ce._searchEngine(n),t=e!="yahoo"?"q":"p",i={};if(!Ue(e)){i.$search_engine=e;var r=$?Rs($.referrer,t):"";r.length&&(i.ph_keyword=r)}return i},searchInfo:function(){var n=$==null?void 0:$.referrer;return n?this._searchInfoFromReferrer(n):{}},browser:Gs,browserVersion:function(n,e){var t=Gs(n,e),i=pu[t];if(O(i))return null;for(var r=0;r1e3?le.substring(0,997)+"...":le,$browser_version:ce.browserVersion(le,navigator.vendor),$browser_language:ce.browserLanguage(),$screen_height:p==null?void 0:p.screen.height,$screen_width:p==null?void 0:p.screen.width,$viewport_height:p==null?void 0:p.innerHeight,$viewport_width:p==null?void 0:p.innerWidth,$lib:"web",$lib_version:$e.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:cs()/1e3})},people_properties:function(){if(!le)return{};var n=ge(ce.os(le),2),e=n[0],t=n[1];return _e(Ei({$os:e,$os_version:t,$browser:ce.browser(le,navigator.vendor)}),{$browser_version:ce.browserVersion(le,navigator.vendor)})}},gu=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Gi=function(){function n(e){V(this,n),this.config=e,this.props={},this.campaign_params_saved=!1,this.name=function(t){var i="";return t.token&&(i=t.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),t.persistence_name?"ph_"+t.persistence_name:"ph_"+i+"_posthog"}(e),this.storage=this.buildStorage(e),this.load(),e.debug&&b.info("Persistence loaded",e.persistence,I({},this.props)),this.update_config(e,e),this.save()}return G(n,[{key:"buildStorage",value:function(e){gu.indexOf(e.persistence.toLowerCase())===-1&&(b.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=e.persistence.toLowerCase();return t==="localstorage"&&ue.is_supported()?ue:t==="localstorage+cookie"&&Ln.is_supported()?Ln:t==="sessionstorage"&&pe.is_supported()?pe:t==="memory"?iu:t==="cookie"?Ve:Ln.is_supported()?Ln:Ve}},{key:"properties",value:function(){var e={};return X(this.props,function(t,i){if(i===$t&&fe(t))for(var r=Object.keys(t),s=0;s0&&e.at(-1)!==this;)e.pop();return e.includes(i)?"[Circular]":(e.push(i),i)}return i})).length;var e}var _u=2,mu=4;function Ji(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:66060288e-1;if(n.size>=e&&n.data.length>1){var t=Math.floor(n.data.length/2),i=n.data.slice(0,t),r=n.data.slice(t);return[Ji({size:Wi(i),data:i,sessionId:n.sessionId,windowId:n.windowId}),Ji({size:Wi(r),data:r,sessionId:n.sessionId,windowId:n.windowId})].flatMap(function(s){return s})}return[n]}var zn=function(n){return n[n.DomContentLoaded=0]="DomContentLoaded",n[n.Load=1]="Load",n[n.FullSnapshot=2]="FullSnapshot",n[n.IncrementalSnapshot=3]="IncrementalSnapshot",n[n.Meta=4]="Meta",n[n.Custom=5]="Custom",n[n.Plugin=6]="Plugin",n}(zn||{}),Ge=function(n){return n[n.Mutation=0]="Mutation",n[n.MouseMove=1]="MouseMove",n[n.MouseInteraction=2]="MouseInteraction",n[n.Scroll=3]="Scroll",n[n.ViewportResize=4]="ViewportResize",n[n.Input=5]="Input",n[n.TouchMove=6]="TouchMove",n[n.MediaInteraction=7]="MediaInteraction",n[n.StyleSheetRule=8]="StyleSheetRule",n[n.CanvasMutation=9]="CanvasMutation",n[n.Font=10]="Font",n[n.Log=11]="Log",n[n.Drag=12]="Drag",n[n.StyleDeclaration=13]="StyleDeclaration",n[n.Selection=14]="Selection",n[n.AdoptedStyleSheet=15]="AdoptedStyleSheet",n[n.CustomElement=16]="CustomElement",n}(Ge||{});function Qi(n){return n?On(n).split(/\s+/):[]}function Qs(n){var e=p==null?void 0:p.location.href;return!!(e&&n&&n.some(function(t){return e.match(t)}))}function Vn(n){var e="";switch(Wt(n.className)){case"string":e=n.className;break;case"object":e=(n.className&&"baseVal"in n.className?n.className.baseVal:null)||n.getAttribute("class")||"";break;default:e=""}return Qi(e)}function Xs(n){return we(n)?null:On(n).split(/(\s+)/).filter(function(e){return Ct(e)}).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Gn(n){var e="";return Ki(n)&&!eo(n)&&n.childNodes&&n.childNodes.length&&X(n.childNodes,function(t){var i;Ys(t)&&t.textContent&&(e+=(i=Xs(t.textContent))!==null&&i!==void 0?i:"")}),On(e)}function Xi(n){return!!n&&n.nodeType===1}function tt(n,e){return!!n&&!!n.tagName&&n.tagName.toLowerCase()===e.toLowerCase()}function Ys(n){return!!n&&n.nodeType===3}function Ks(n){return!!n&&n.nodeType===11}var Yi=["a","button","form","input","select","textarea","label"];function Zs(n){var e=n.parentNode;return!(!e||!Xi(e))&&e}function yu(n,e){var t=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0,i=arguments.length>3?arguments[3]:void 0,r=arguments.length>4?arguments[4]:void 0;if(!p||!n||tt(n,"html")||!Xi(n)||t!=null&&t.url_allowlist&&!Qs(t.url_allowlist)||t!=null&&t.url_ignorelist&&Qs(t.url_ignorelist))return!1;if(t!=null&&t.dom_event_allowlist){var s=t.dom_event_allowlist;if(s&&!s.some(function(f){return e.type===f}))return!1}for(var o=!1,a=[n],u=!0,l=n;l.parentNode&&!tt(l,"body");)if(Ks(l.parentNode))a.push(l.parentNode.host),l=l.parentNode.host;else{if(!(u=Zs(l)))break;if(i||Yi.indexOf(u.tagName.toLowerCase())>-1)o=!0;else{var c=p.getComputedStyle(u);c&&c.getPropertyValue("cursor")==="pointer"&&(o=!0)}a.push(u),l=u}if(!function(f,_){var v=_==null?void 0:_.element_allowlist;if(O(v))return!0;var S,P=xe(f);try{var E=function(){var k=S.value;if(v.some(function(w){return k.tagName.toLowerCase()===w}))return{v:!0}};for(P.s();!(S=P.n()).done;){var F=E();if(Wt(F)==="object")return F.v}}catch(k){P.e(k)}finally{P.f()}return!1}(a,t)||!function(f,_){var v=_==null?void 0:_.css_selector_allowlist;if(O(v))return!0;var S,P=xe(f);try{var E=function(){var k=S.value;if(v.some(function(w){return k.matches(w)}))return{v:!0}};for(P.s();!(S=P.n()).done;){var F=E();if(Wt(F)==="object")return F.v}}catch(k){P.e(k)}finally{P.f()}return!1}(a,t))return!1;var d=p.getComputedStyle(n);if(d&&d.getPropertyValue("cursor")==="pointer"&&e.type==="click")return!0;var h=n.tagName.toLowerCase();switch(h){case"html":return!1;case"form":return(r||["submit"]).indexOf(e.type)>=0;case"input":case"select":case"textarea":return(r||["change","click"]).indexOf(e.type)>=0;default:return o?(r||["click"]).indexOf(e.type)>=0:(r||["click"]).indexOf(e.type)>=0&&(Yi.indexOf(h)>-1||n.getAttribute("contenteditable")==="true")}}function Ki(n){for(var e=n;e.parentNode&&!tt(e,"body");e=e.parentNode){var t=Vn(e);if(U(t,"ph-sensitive")||U(t,"ph-no-capture"))return!1}if(U(Vn(n),"ph-include"))return!0;var i=n.type||"";if(ve(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var r=n.name||n.id||"";return!(ve(r)&&/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(r.replace(/[^a-zA-Z0-9]/g,"")))}function eo(n){return!!(tt(n,"input")&&!["button","checkbox","submit","reset"].includes(n.type)||tt(n,"select")||tt(n,"textarea")||n.getAttribute("contenteditable")==="true")}var to="(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})",bu=new RegExp("^(?:".concat(to,")$")),wu=new RegExp(to),no="\\d{3}-?\\d{2}-?\\d{4}",ku=new RegExp("^(".concat(no,")$")),Su=new RegExp("(".concat(no,")"));function Ct(n){var e=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];return!(we(n)||ve(n)&&(n=On(n),(e?bu:wu).test((n||"").replace(/[- ]/g,""))||(e?ku:Su).test(n)))}function io(n){var e=Gn(n);return Ct(e="".concat(e," ").concat(ro(n)).trim())?e:""}function ro(n){var e="";return n&&n.childNodes&&n.childNodes.length&&X(n.childNodes,function(t){var i;if(t&&((i=t.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{var r=Gn(t);e="".concat(e," ").concat(r).trim(),t.childNodes&&t.childNodes.length&&(e="".concat(e," ").concat(ro(t)).trim())}catch(s){b.error(s)}}),e}function Iu(n){return function(e){var t=e.map(function(i){var r,s,o="";if(i.tag_name&&(o+=i.tag_name),i.attr_class){i.attr_class.sort();var a,u=xe(i.attr_class);try{for(u.s();!(a=u.n()).done;){var l=a.value;o+=".".concat(l.replace(/"/g,""))}}catch(h){u.e(h)}finally{u.f()}}var c=I(I(I(I({},i.text?{text:i.text}:{}),{},{"nth-child":(r=i.nth_child)!==null&&r!==void 0?r:0,"nth-of-type":(s=i.nth_of_type)!==null&&s!==void 0?s:0},i.href?{href:i.href}:{}),i.attr_id?{attr_id:i.attr_id}:{}),i.attributes),d={};return Tn(c).sort(function(h,f){var _=ge(h,1)[0],v=ge(f,1)[0];return _.localeCompare(v)}).forEach(function(h){var f=ge(h,2),_=f[0],v=f[1];return d[so(_.toString())]=so(v.toString())}),o+=":",o+=Tn(c).map(function(h){var f=ge(h,2),_=f[0],v=f[1];return"".concat(_,'="').concat(v,'"')}).join("")});return t.join(";")}(function(e){return e.map(function(t){var i,r,s={text:(i=t.$el_text)===null||i===void 0?void 0:i.slice(0,400),tag_name:t.tag_name,href:(r=t.attr__href)===null||r===void 0?void 0:r.slice(0,2048),attr_class:Eu(t),attr_id:t.attr__id,nth_child:t.nth_child,nth_of_type:t.nth_of_type,attributes:{}};return Tn(t).filter(function(o){return ge(o,1)[0].indexOf("attr__")===0}).forEach(function(o){var a=ge(o,2),u=a[0],l=a[1];return s.attributes[u]=l}),s})}(n))}function so(n){return n.replace(/"|\\"/g,'\\"')}function Eu(n){var e=n.attr__class;return e?ae(e)?e:Qi(e):void 0}var Zi="[SessionRecording]",er="redacted",Wn={initiatorTypes:["audio","beacon","body","css","early-hint","embed","fetch","frame","iframe","icon","image","img","input","link","navigation","object","ping","script","track","video","xmlhttprequest"],maskRequestFn:function(n){return n},recordHeaders:!1,recordBody:!1,recordInitialRequests:!1,recordPerformance:!1,performanceEntryTypeToObserve:["first-input","navigation","paint","resource"],payloadSizeLimitBytes:1e6,payloadHostDenyList:[".lr-ingest.io",".ingest.sentry.io"]},Pu=["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"],xu=["password","secret","passwd","api_key","apikey","auth","credentials","mysql_pwd","privatekey","private_key","token"],$u=["/s/","/e/","/i/"];function oo(n,e,t,i){if(we(n))return n;var r=(e==null?void 0:e["content-length"])||function(s){return new Blob([s]).size}(n);return ve(r)&&(r=parseInt(r)),r>t?Zi+" ".concat(i," body too large to record (").concat(r," bytes)"):n}function ao(n,e){if(we(n))return n;var t=n;return Ct(t,!1)||(t=Zi+" "+e+" body "+er),X(xu,function(i){var r,s;(r=t)!==null&&r!==void 0&&r.length&&((s=t)===null||s===void 0?void 0:s.indexOf(i))!==-1&&(t=Zi+" "+e+" body "+er+" as might contain: "+i)}),t}var We,Ru=function(n,e){var t,i,r,s={payloadSizeLimitBytes:Wn.payloadSizeLimitBytes,performanceEntryTypeToObserve:Be(Wn.performanceEntryTypeToObserve),payloadHostDenyList:[].concat(Be(e.payloadHostDenyList||[]),Be(Wn.payloadHostDenyList))},o=n.session_recording.recordHeaders!==!1&&e.recordHeaders,a=n.session_recording.recordBody!==!1&&e.recordBody,u=n.capture_performance!==!1&&e.recordPerformance,l=(t=s,r=Math.min(1e6,(i=t.payloadSizeLimitBytes)!==null&&i!==void 0?i:1e6),function(h){return h!=null&&h.requestBody&&(h.requestBody=oo(h.requestBody,h.requestHeaders,r,"Request")),h!=null&&h.responseBody&&(h.responseBody=oo(h.responseBody,h.responseHeaders,r,"Response")),h}),c=function(h){return l(function(v){var S=Kt(v.name);if(!(S&&S.pathname&&$u.some(function(P){return S.pathname.indexOf(P)===0})))return v}((_=(f=h).requestHeaders,we(_)||X(Object.keys(_??{}),function(v){Pu.includes(v.toLowerCase())&&(_[v]=er)}),f)));var f,_},d=Re(n.session_recording.maskNetworkRequestFn);return d&&Re(n.session_recording.maskCapturedNetworkRequestFn)&&b.warn("Both `maskNetworkRequestFn` and `maskCapturedNetworkRequestFn` are defined. `maskNetworkRequestFn` will be ignored."),d&&(n.session_recording.maskCapturedNetworkRequestFn=function(h){var f=n.session_recording.maskNetworkRequestFn({url:h.name});return I(I({},h),{},{name:f==null?void 0:f.url})}),s.maskRequestFn=Re(n.session_recording.maskCapturedNetworkRequestFn)?function(h){var f,_,v,S=c(h);return S&&(f=(_=(v=n.session_recording).maskCapturedNetworkRequestFn)===null||_===void 0?void 0:_.call(v,S))!==null&&f!==void 0?f:void 0}:function(h){return function(f){if(!O(f))return f.requestBody=ao(f.requestBody,"Request"),f.responseBody=ao(f.responseBody,"Response"),f}(c(h))},I(I(I({},Wn),s),{},{recordHeaders:o,recordBody:a,recordPerformance:u,recordInitialRequests:u})},Fu=G(function n(e){var t,i,r=this,s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};V(this,n),m(this,"bucketSize",100),m(this,"refillRate",10),m(this,"mutationBuckets",{}),m(this,"loggedTracker",{}),m(this,"refillBuckets",function(){Object.keys(r.mutationBuckets).forEach(function(o){r.mutationBuckets[o]=r.mutationBuckets[o]+r.refillRate,r.mutationBuckets[o]>=r.bucketSize&&delete r.mutationBuckets[o]})}),m(this,"getNodeOrRelevantParent",function(o){var a=r.rrweb.mirror.getNode(o);if((a==null?void 0:a.nodeName)!=="svg"&&a instanceof Element){var u=a.closest("svg");if(u)return[r.rrweb.mirror.getId(u),u]}return[o,a]}),m(this,"numberOfChanges",function(o){var a,u,l,c,d,h,f,_;return((a=(u=o.removes)===null||u===void 0?void 0:u.length)!==null&&a!==void 0?a:0)+((l=(c=o.attributes)===null||c===void 0?void 0:c.length)!==null&&l!==void 0?l:0)+((d=(h=o.texts)===null||h===void 0?void 0:h.length)!==null&&d!==void 0?d:0)+((f=(_=o.adds)===null||_===void 0?void 0:_.length)!==null&&f!==void 0?f:0)}),m(this,"throttleMutations",function(o){if(o.type!==3||o.data.source!==0)return o;var a=o.data,u=r.numberOfChanges(a);a.attributes&&(a.attributes=a.attributes.filter(function(c){var d,h,f,_=ge(r.getNodeOrRelevantParent(c.id),2),v=_[0],S=_[1];return r.mutationBuckets[v]===0?!1:(r.mutationBuckets[v]=(d=r.mutationBuckets[v])!==null&&d!==void 0?d:r.bucketSize,r.mutationBuckets[v]=Math.max(r.mutationBuckets[v]-1,0),r.mutationBuckets[v]===0&&(r.loggedTracker[v]||(r.loggedTracker[v]=!0,(h=(f=r.options).onBlockedNode)===null||h===void 0||h.call(f,v,S))),c)}));var l=r.numberOfChanges(a);return l!==0||u===l?o:void 0}),this.rrweb=e,this.options=s,this.refillRate=(t=this.options.refillRate)!==null&&t!==void 0?t:this.refillRate,this.bucketSize=(i=this.options.bucketSize)!==null&&i!==void 0?i:this.bucketSize,setInterval(function(){r.refillBuckets()},1e3)}),Ou=3e5,Tu=[Ge.MouseMove,Ge.MouseInteraction,Ge.Scroll,Ge.ViewportResize,Ge.Input,Ge.TouchMove,Ge.MediaInteraction,Ge.Drag],uo=function(n){return{rrwebMethod:n,enqueuedAt:Date.now(),attempt:1}},Te="[SessionRecording]",Cu=function(){function n(e){var t=this;if(V(this,n),m(this,"queuedRRWebEvents",[]),m(this,"isIdle",!1),m(this,"_linkedFlagSeen",!1),m(this,"_lastActivityTimestamp",Date.now()),m(this,"_linkedFlag",null),m(this,"_forceAllowLocalhostNetworkCapture",!1),m(this,"_onBeforeUnload",function(){t._flushBuffer()}),m(this,"_onOffline",function(){t._tryAddCustomEvent("browser offline",{})}),m(this,"_onOnline",function(){t._tryAddCustomEvent("browser online",{})}),m(this,"_onVisibilityChange",function(){if($!=null&&$.visibilityState){var o="window "+$.visibilityState;t._tryAddCustomEvent(o,{})}}),m(this,"_samplingSessionListener",null),this.instance=e,this._captureStarted=!1,this._endpoint="/s/",this.stopRrweb=void 0,this.receivedDecide=!1,!this.instance.sessionManager)throw b.error(Te+" started without valid sessionManager"),new Error(Te+" started without valid sessionManager. This is a bug.");var i=this.sessionManager.checkAndGetSessionAndWindowId(),r=i.sessionId,s=i.windowId;this.sessionId=r,this.windowId=s,this.buffer=this.clearBuffer(),this._setupSampling()}return G(n,[{key:"rrwebRecord",get:function(){var e;return Z==null||(e=Z.rrweb)===null||e===void 0?void 0:e.record}},{key:"started",get:function(){return this._captureStarted}},{key:"sessionManager",get:function(){if(!this.instance.sessionManager)throw new Error(Te+" must be started with a valid sessionManager.");return this.instance.sessionManager}},{key:"fullSnapshotIntervalMillis",get:function(){var e;return((e=this.instance.config.session_recording)===null||e===void 0?void 0:e.full_snapshot_interval_millis)||Ou}},{key:"isSampled",get:function(){var e=this.instance.get_property(Xt);return lt(e)?e:null}},{key:"sessionDuration",get:function(){var e,t,i=(e=this.buffer)===null||e===void 0?void 0:e.data[((t=this.buffer)===null||t===void 0?void 0:t.data.length)-1],r=this.sessionManager.checkAndGetSessionAndWindowId(!0).sessionStartTimestamp;return i?i.timestamp-r:null}},{key:"isRecordingEnabled",get:function(){var e=!!this.instance.get_property($i),t=!this.instance.config.disable_session_recording;return p&&e&&t}},{key:"isConsoleLogCaptureEnabled",get:function(){var e=!!this.instance.get_property(ms),t=this.instance.config.enable_recording_console_log;return t??e}},{key:"canvasRecording",get:function(){var e=this.instance.get_property(bs);return e&&e.fps&&e.quality?{enabled:e.enabled,fps:e.fps,quality:e.quality}:void 0}},{key:"networkPayloadCapture",get:function(){var e,t,i=this.instance.get_property(ys),r={recordHeaders:(e=this.instance.config.session_recording)===null||e===void 0?void 0:e.recordHeaders,recordBody:(t=this.instance.config.session_recording)===null||t===void 0?void 0:t.recordBody},s=(r==null?void 0:r.recordHeaders)||(i==null?void 0:i.recordHeaders),o=(r==null?void 0:r.recordBody)||(i==null?void 0:i.recordBody),a=fe(this.instance.config.capture_performance)?this.instance.config.capture_performance.network_timing:this.instance.config.capture_performance,u=!!(lt(a)?a:i!=null&&i.capturePerformance);return s||o||u?{recordHeaders:s,recordBody:o,recordPerformance:u}:void 0}},{key:"sampleRate",get:function(){var e=this.instance.get_property(ws);return Fe(e)?e:null}},{key:"minimumDuration",get:function(){var e=this.instance.get_property(ks);return Fe(e)?e:null}},{key:"status",get:function(){return this.receivedDecide?this.isRecordingEnabled?we(this._linkedFlag)||this._linkedFlagSeen?lt(this.isSampled)?this.isSampled?"sampled":"disabled":"active":"buffering":"disabled":"buffering"}},{key:"startIfEnabledOrStop",value:function(){this.isRecordingEnabled?(this._startCapture(),p==null||p.addEventListener("beforeunload",this._onBeforeUnload),p==null||p.addEventListener("offline",this._onOffline),p==null||p.addEventListener("online",this._onOnline),p==null||p.addEventListener("visibilitychange",this._onVisibilityChange),b.info(Te+" started")):(this.stopRecording(),this.clearBuffer(),clearInterval(this._fullSnapshotTimer))}},{key:"stopRecording",value:function(){this._captureStarted&&this.stopRrweb&&(this.stopRrweb(),this.stopRrweb=void 0,this._captureStarted=!1,p==null||p.removeEventListener("beforeunload",this._onBeforeUnload),p==null||p.removeEventListener("offline",this._onOffline),p==null||p.removeEventListener("online",this._onOnline),p==null||p.removeEventListener("visibilitychange",this._onVisibilityChange),b.info(Te+" stopped"))}},{key:"makeSamplingDecision",value:function(e){var t,i=this.sessionId!==e,r=this.sampleRate;if(Fe(r)){var s,o=this.isSampled,a=i||!lt(o);a?s=Math.random()1&&arguments[1]!==void 0?arguments[1]:"log";(t=this.instance.sessionRecording)===null||t===void 0||t.onRRwebEmit({type:6,data:{plugin:"rrweb/console@1",payload:{level:i,trace:[],payload:[JSON.stringify(e)]}},timestamp:cs()})}},{key:"_startCapture",value:function(){var e=this;O(Object.assign)||this._captureStarted||this.instance.config.disable_session_recording||this.instance.consent.isOptedOut()||(this._captureStarted=!0,this.sessionManager.checkAndGetSessionAndWindowId(),this.rrwebRecord?this._onScriptLoaded():this.instance.requestRouter.loadScript("/static/recorder.js?v=".concat($e.LIB_VERSION),function(t){if(t)return b.error(Te+" could not load recorder.js",t);e._onScriptLoaded()}))}},{key:"isInteractiveEvent",value:function(e){var t;return e.type===3&&Tu.indexOf((t=e.data)===null||t===void 0?void 0:t.source)!==-1}},{key:"_updateWindowAndSessionIds",value:function(e){var t=this.isInteractiveEvent(e);t||this.isIdle||e.timestamp-this._lastActivityTimestamp>3e5&&(this.isIdle=!0,clearInterval(this._fullSnapshotTimer),this._flushBuffer());var i=!1;if(t&&(this._lastActivityTimestamp=e.timestamp,this.isIdle&&(this.isIdle=!1,this._tryAddCustomEvent("sessionNoLongerIdle",{reason:"user activity",type:e.type}),i=!0)),!this.isIdle){var r=this.sessionManager.checkAndGetSessionAndWindowId(!t,e.timestamp),s=r.windowId,o=r.sessionId,a=this.sessionId!==o,u=this.windowId!==s;this.windowId=s,this.sessionId=o,(i||[_u,mu].indexOf(e.type)===-1&&(u||a||O(this._fullSnapshotTimer)))&&this._tryTakeFullSnapshot()}}},{key:"_tryRRWebMethod",value:function(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}):b.warn(Te+" could not emit queued rrweb event.",t,e),!1}}},{key:"_tryAddCustomEvent",value:function(e,t){var i=this;return this._tryRRWebMethod(uo(function(){return i.rrwebRecord.addCustomEvent(e,t)}))}},{key:"_tryTakeFullSnapshot",value:function(){var e=this;return this._tryRRWebMethod(uo(function(){return e.rrwebRecord.takeFullSnapshot()}))}},{key:"_onScriptLoaded",value:function(){for(var e,t=this,i={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},r=this.instance.config.session_recording,s=0,o=Object.entries(r||{});s10&&(u.data.payload.payload=u.data.payload.payload.slice(0,10),u.data.payload.payload.push("...[truncated]"));for(var l=[],c=0;c2e3?l.push(u.data.payload.payload[c].slice(0,2e3)+"...[truncated]"):l.push(u.data.payload.payload[c]);return u.data.payload.payload=l,a}return a}(i),s=Wi(r);if(this._updateWindowAndSessionIds(r),!this.isIdle||r.type===zn.Custom){var o={$snapshot_bytes:s,$snapshot_data:r,$session_id:this.sessionId,$window_id:this.windowId};this.status!=="disabled"?this._captureSnapshotBuffered(o):this.clearBuffer()}}}}},{key:"_pageViewFallBack",value:function(){if(!this.instance.config.capture_pageview&&p){var e=this._maskUrl(p.location.href);this._lastHref!==e&&(this._tryAddCustomEvent("$url_changed",{href:e}),this._lastHref=e)}}},{key:"_processQueuedEvents",value:function(){var e=this;if(this.queuedRRWebEvents.length){var t=Be(this.queuedRRWebEvents);this.queuedRRWebEvents=[],t.forEach(function(i){Date.now()-i.enqueuedAt<=2e3&&e._tryRRWebMethod(i)})}}},{key:"_maskUrl",value:function(e){var t=this.instance.config.session_recording;if(t.maskNetworkRequestFn){var i,r={url:e};return(i=r=t.maskNetworkRequestFn(r))===null||i===void 0?void 0:i.url}return e}},{key:"clearBuffer",value:function(){return this.buffer={size:0,data:[],sessionId:this.sessionId,windowId:this.windowId},this.buffer}},{key:"_flushBuffer",value:function(){var e=this;this.flushBufferTimer&&(clearTimeout(this.flushBufferTimer),this.flushBufferTimer=void 0);var t=this.minimumDuration,i=this.sessionDuration,r=Fe(i)&&i>=0,s=Fe(t)&&r&&i0&&Ji(this.buffer).forEach(function(o){e._captureSnapshot({$snapshot_bytes:o.size,$snapshot_data:o.data,$session_id:o.sessionId,$window_id:o.windowId})}),this.clearBuffer())}},{key:"_captureSnapshotBuffered",value:function(e){var t,i=this,r=2+(((t=this.buffer)===null||t===void 0?void 0:t.data.length)||0);!this.isIdle&&(this.buffer.size+e.$snapshot_bytes+r>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(function(){i._flushBuffer()},2e3))}},{key:"_captureSnapshot",value:function(e){this.instance.capture("$snapshot",e,{_url:this.instance.requestRouter.endpointFor("api",this._endpoint),_noTruncate:!0,_batchKey:"recordings",skip_client_rate_limiting:!0})}},{key:"overrideLinkedFlag",value:function(){this._linkedFlagSeen=!0}}]),n}(),Au=function(){function n(e){V(this,n),this.instance=e,this.instance.decideEndpointWasHit=this.instance._hasBootstrappedFeatureFlags()}return G(n,[{key:"call",value:function(){var e=this,t={token:this.instance.config.token,distinct_id:this.instance.get_distinct_id(),groups:this.instance.getGroups(),person_properties:this.instance.get_property(Rt),group_properties:this.instance.get_property(Ke),disable_flags:this.instance.config.advanced_disable_feature_flags||this.instance.config.advanced_disable_feature_flags_on_first_load||void 0};this.instance._send_request({method:"POST",url:this.instance.requestRouter.endpointFor("api","/decide/?v=3"),data:t,compression:this.instance.config.disable_compression?void 0:Ne.Base64,timeout:this.instance.config.feature_flag_request_timeout_ms,callback:function(i){return e.parseDecideResponse(i.json)}})}},{key:"parseDecideResponse",value:function(e){var t=this;this.instance.featureFlags.setReloadingPaused(!1),this.instance.featureFlags._startReloadTimer();var i=!e;if(this.instance.config.advanced_disable_feature_flags_on_first_load||this.instance.config.advanced_disable_feature_flags||this.instance.featureFlags.receivedFeatureFlags(e??{},i),i)b.error("Failed to fetch feature flags from PostHog.");else{if(!$||!$.body)return b.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(function(){t.parseDecideResponse(e)},500);if(this.instance._afterDecideResponse(e),e.siteApps)if(this.instance.config.opt_in_site_apps){var r,s=xe(e.siteApps);try{var o=function(){var a=r.value,u=a.id,l=a.url,c=t.instance.requestRouter.endpointFor("api",l);Z["__$$ph_site_app_".concat(u)]=t.instance,t.instance.requestRouter.loadScript(c,function(d){if(d)return b.error("Error while initializing PostHog app with config id ".concat(u),d)})};for(s.s();!(r=s.n()).done;)o()}catch(a){s.e(a)}finally{s.f()}}else e.siteApps.length>0&&b.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}]),n}(),Mu=p!=null&&p.location?Bn(p.location.hash,"__posthog")||Bn(location.hash,"state"):null,lo="_postHogToolbarParams";(function(n){n[n.UNINITIALIZED=0]="UNINITIALIZED",n[n.LOADING=1]="LOADING",n[n.LOADED=2]="LOADED"})(We||(We={}));var Nu=function(){function n(e){V(this,n),this.instance=e}return G(n,[{key:"setToolbarState",value:function(e){Z.ph_toolbar_state=e}},{key:"getToolbarState",value:function(){var e;return(e=Z.ph_toolbar_state)!==null&&e!==void 0?e:We.UNINITIALIZED}},{key:"maybeLoadToolbar",value:function(){var e,t,i=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,s=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;if(!p||!$)return!1;i=(e=i)!==null&&e!==void 0?e:p.location,s=(t=s)!==null&&t!==void 0?t:p.history;try{if(!r){try{p.localStorage.setItem("test","test"),p.localStorage.removeItem("test")}catch{return!1}r=p==null?void 0:p.localStorage}var o,a=Mu||Bn(i.hash,"__posthog")||Bn(i.hash,"state"),u=a?ds(function(){return JSON.parse(atob(decodeURIComponent(a)))})||ds(function(){return JSON.parse(decodeURIComponent(a))}):null;return u&&u.action==="ph_authorize"?((o=u).source="url",o&&Object.keys(o).length>0&&(u.desiredHash?i.hash=u.desiredHash:s?s.replaceState(s.state,"",i.pathname+i.search):i.hash="")):((o=JSON.parse(r.getItem(lo)||"{}")).source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token)&&(this.loadToolbar(o),!0)}catch{return!1}}},{key:"_callLoadToolbar",value:function(e){(Z.ph_load_toolbar||Z.ph_load_editor)(e,this.instance)}},{key:"loadToolbar",value:function(e){var t=this,i=!($==null||!$.getElementById(Mi));if(!p||i)return!1;var r=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=I(I({token:this.instance.config.token},e),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},r?{instrument:!1}:{});if(p.localStorage.setItem(lo,JSON.stringify(I(I({},s),{},{source:void 0}))),this.getToolbarState()===We.LOADED)this._callLoadToolbar(s);else if(this.getToolbarState()===We.UNINITIALIZED){this.setToolbarState(We.LOADING);var o=3e5,a=Math.floor(Date.now()/o)*o;this.instance.requestRouter.loadScript("/static/toolbar.js?t=".concat(a),function(u){if(u)return b.error("Failed to load toolbar",u),void t.setToolbarState(We.UNINITIALIZED);t.setToolbarState(We.LOADED),t._callLoadToolbar(s)}),He(p,"turbolinks:load",function(){t.setToolbarState(We.UNINITIALIZED),t.loadToolbar(s)})}return!0}},{key:"_loadEditor",value:function(e){return this.loadToolbar(e)}},{key:"maybeLoadEditor",value:function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:void 0,t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:void 0,i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:void 0;return this.maybeLoadToolbar(e,t,i)}}]),n}(),Du=function(){function n(e){V(this,n),m(this,"isPaused",!0),m(this,"queue",[]),m(this,"flushTimeoutMs",3e3),this.sendRequest=e}return G(n,[{key:"enqueue",value:function(e){this.queue.push(e),this.flushTimeout||this.setFlushTimeout()}},{key:"unload",value:function(){var e=this;this.clearFlushTimeout();var t=this.queue.length>0?this.formatQueue():{},i=Object.values(t);[].concat(Be(i.filter(function(r){return r.url.indexOf("/e")===0})),Be(i.filter(function(r){return r.url.indexOf("/e")!==0}))).map(function(r){e.sendRequest(I(I({},r),{},{transport:"sendBeacon"}))})}},{key:"enable",value:function(){this.isPaused=!1,this.setFlushTimeout()}},{key:"setFlushTimeout",value:function(){var e=this;this.isPaused||(this.flushTimeout=setTimeout(function(){if(e.clearFlushTimeout(),e.queue.length>0){var t=e.formatQueue(),i=function(s){var o=t[s],a=new Date().getTime();o.data&&ae(o.data)&&X(o.data,function(u){u.offset=Math.abs(u.timestamp-a),delete u.timestamp}),e.sendRequest(o)};for(var r in t)i(r)}},this.flushTimeoutMs))}},{key:"clearFlushTimeout",value:function(){clearTimeout(this.flushTimeout),this.flushTimeout=void 0}},{key:"formatQueue",value:function(){var e={};return X(this.queue,function(t){var i,r=t,s=(r?r.batchKey:null)||r.url;O(e[s])&&(e[s]=I(I({},r),{},{data:[]})),(i=e[s].data)===null||i===void 0||i.push(r.data)}),this.queue=[],e}}]),n}(),Ee=Uint8Array,ye=Uint16Array,At=Uint32Array,tr=new Ee([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]),nr=new Ee([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]),co=new Ee([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),fo=function(n,e){for(var t=new ye(31),i=0;i<31;++i)t[i]=e+=1<>>1|(21845&K)<<1;dt=(61680&(dt=(52428&dt)>>>2|(13107&dt)<<2))>>>4|(3855&dt)<<4,rr[K]=((65280&dt)>>>8|(255&dt)<<8)>>>1}var sn=function(n,e,t){for(var i=n.length,r=0,s=new ye(e);r>>u]=l}else for(o=new ye(i),r=0;r>>15-n[r];return o},ft=new Ee(288);for(K=0;K<144;++K)ft[K]=8;for(K=144;K<256;++K)ft[K]=9;for(K=256;K<280;++K)ft[K]=7;for(K=280;K<288;++K)ft[K]=8;var Jn=new Ee(32);for(K=0;K<32;++K)Jn[K]=5;var qu=sn(ft,9,0),ju=sn(Jn,5,0),vo=function(n){return(n/8>>0)+(7&n&&1)},go=function(n,e,t){(e==null||e<0)&&(e=0),(t==null||t>n.length)&&(t=n.length);var i=new(n instanceof ye?ye:n instanceof At?At:Ee)(t-e);return i.set(n.subarray(e,t)),i},Je=function(n,e,t){t<<=7&e;var i=e/8>>0;n[i]|=t,n[i+1]|=t>>>8},on=function(n,e,t){t<<=7&e;var i=e/8>>0;n[i]|=t,n[i+1]|=t>>>8,n[i+2]|=t>>>16},sr=function(n,e){for(var t=[],i=0;ih&&(h=s[i].s);var f=new ye(h+1),_=Bu(t[c-1],f,0);if(_>e){i=0;var v=0,S=_-e,P=1<e))break;v+=P-(1<<_-f[E]),f[E]=e}for(v>>>=S;v>0;){var F=s[i].s;f[F]=0&&v;--i){var k=s[i].s;f[k]==e&&(--f[k],++v)}_=e}return[new Ee(f),_]},Bu=function n(e,t,i){return e.s==-1?Math.max(n(e.l,t,i+1),n(e.r,t,i+1)):t[e.s]=i},_o=function(n){for(var e=n.length;e&&!n[--e];);for(var t=new ye(++e),i=0,r=n[0],s=1,o=function(u){t[i++]=u},a=1;a<=e;++a)if(n[a]==r&&a!=e)++s;else{if(!r&&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(r),--s;s>6;s-=6)o(8304);s>2&&(o(s-3<<5|8208),s=0)}for(;s--;)o(r);s=1,r=n[a]}return[t.subarray(0,i),e]},an=function(n,e){for(var t=0,i=0;i>>8,n[r+2]=255^n[r],n[r+3]=255^n[r+1];for(var s=0;s4&&!j[co[z-1]];--z);var ne,Q,T,re,ie=l+5<<3,Pe=an(r,ft)+an(s,Jn)+o,g=an(r,h)+an(s,v)+o+14+3*z+an(A,j)+(2*A[16]+3*A[17]+7*A[18]);if(ie<=Pe&&ie<=g)return Qn(e,c,n.subarray(u,u+l));if(Je(e,c,1+(g15&&(Je(e,c,M[x]>>>5&127),c+=M[x]>>>12)}}}else ne=qu,Q=ft,T=ju,re=Jn;for(x=0;x255){q=i[x]>>>18&31,on(e,c,ne[q+257]),c+=Q[q+257],q>7&&(Je(e,c,i[x]>>>23&31),c+=tr[q]);var ee=31&i[x];on(e,c,T[ee]),c+=re[ee],ee>3&&(on(e,c,i[x]>>>5&8191),c+=nr[ee])}else on(e,c,ne[i[x]]),c+=Q[i[x]];return on(e,c,ne[256]),c+Q[256]},Uu=new At([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Hu=new Ee(0),zu=function(){for(var n=new At(256),e=0;e<256;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;n[e]=t}return n}(),Vu=function(n,e,t,i,r){return function(s,o,a,u,l,c){var d=s.length,h=new Ee(u+d+5*(1+Math.floor(d/7e3))+l),f=h.subarray(u,h.length-l),_=0;if(!o||d<8)for(var v=0;v<=d;v+=65535){var S=v+65535;S>>13,F=8191&P,k=(1<7e3||T>24576)&&R>423){_=mo(s,f,0,j,te,z,Q,T,ie,v-ie,_),T=ne=Q=0,ie=v;for(var C=0;C<286;++C)te[C]=0;for(C=0;C<30;++C)z[C]=0}var M=2,q=0,ee=F,B=g-y&32767;if(R>2&&Pe==H(v-B))for(var se=Math.min(E,R)-1,W=Math.min(32767,v),Ce=Math.min(258,R);B<=W&&--ee&&g!=y;){if(s[v+M]==s[v+M-B]){for(var Ie=0;IeM){if(M=Ie,q=B,Ie>se)break;var Dt=Math.min(B,Ie-2),dn=0;for(C=0;Cdn&&(dn=ii,y=vt)}}}B+=(g=y)-(y=w[g])+32768&32767}if(q){j[T++]=268435456|ir[M]<<18|po[q];var No=31&ir[M],Do=31&po[q];Q+=tr[No]+nr[Do],++te[257+No],++z[Do],re=v+M,++ne}else j[T++]=s[v],++te[s[v]]}}_=mo(s,f,c,j,te,z,Q,T,ie,v-ie,_),c||(_=Qn(f,_,Hu))}return go(h,0,u+vo(_)+l)}(n,e.level==null?6:e.level,e.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+e.mem,t,i,!r)},or=function(n,e,t){for(;t;++e)n[e]=t,t>>>=8};function Gu(n,e){e===void 0&&(e={});var t=function(){var a=4294967295;return{p:function(u){for(var l=a,c=0;c>>8;a=l},d:function(){return 4294967295^a}}}(),i=n.length;t.p(n);var r,s=Vu(n,e,10+((r=e).filename&&r.filename.length+1||0),8),o=s.length;return function(a,u){var l=u.filename;if(a[0]=31,a[1]=139,a[2]=8,a[8]=u.level<2?4:u.level==9?2:0,a[9]=3,u.mtime!=0&&or(a,4,Math.floor(new Date(u.mtime||Date.now())/1e3)),l){a[3]=8;for(var c=0;c<=l.length;++c)a[c+10]=l.charCodeAt(c)}}(s,e),or(s,o-8,t.d()),or(s,o-4,i),s}var Wu=!!Ii||!!Si,yo="text/plain",Xn=function(n,e){var t=ge(n.split("?"),2),i=t[0],r=t[1],s=I({},e);r==null||r.split("&").forEach(function(a){var u=ge(a.split("="),1)[0];delete s[u]});var o=su(s);return o=o?(r?r+"&":"")+o:r,"".concat(i,"?").concat(o)},Ju=function(n){return"data="+encodeURIComponent(typeof n=="string"?n:JSON.stringify(n))},ar=function(n){var e=n.data,t=n.compression;if(e){if(t===Ne.GZipJS){var i=Gu(function(s,o){var a=s.length;if(!o&&typeof TextEncoder<"u")return new TextEncoder().encode(s);for(var u=new Ee(s.length+(s.length>>>1)),l=0,c=function(_){u[l++]=_},d=0;du.length){var h=new Ee(l+8+(a-d<<1));h.set(u),u=h}var f=s.charCodeAt(d);f<128||o?c(f):f<2048?(c(192|f>>>6),c(128|63&f)):f>55295&&f<57344?(c(240|(f=65536+(1047552&f)|1023&s.charCodeAt(++d))>>>18),c(128|f>>>12&63),c(128|f>>>6&63),c(128|63&f)):(c(224|f>>>12),c(128|f>>>6&63),c(128|63&f))}return go(u,0,l)}(JSON.stringify(e)),{mtime:0});return{contentType:yo,body:new Blob([i],{type:yo})}}if(t===Ne.Base64){var r=function(s){var o,a,u,l,c,d="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",h=0,f=0,_="",v=[];if(!s)return s;s=Ga(s);do o=(c=s.charCodeAt(h++)<<16|s.charCodeAt(h++)<<8|s.charCodeAt(h++))>>18&63,a=c>>12&63,u=c>>6&63,l=63&c,v[f++]=d.charAt(o)+d.charAt(a)+d.charAt(u)+d.charAt(l);while(h0&&(r.url=Xn(r.url,{retry_count:i})),this.instance._send_request(I(I({},r),{},{callback:function(s){var o;s.statusCode!==200&&(s.statusCode<400||s.statusCode>=500)&&(i??0)<10?t.enqueue(I({retriesPerformedSoFar:i},r)):(o=r.callback)===null||o===void 0||o.call(r,s)}}))}},{key:"enqueue",value:function(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=function(o){var a=3e3*Math.pow(2,o),u=a/2,l=Math.min(18e5,a),c=(Math.random()-.5)*(l-u);return Math.ceil(l+c)}(t),r=Date.now()+i;this.queue.push({retryAt:r,requestOptions:e});var s="Enqueued failed request for retry in ".concat(i);navigator.onLine||(s+=" (Browser is offline)"),b.warn(s),this.isPolling||(this.isPolling=!0,this.poll())}},{key:"poll",value:function(){var e=this;this.poller&&clearTimeout(this.poller),this.poller=setTimeout(function(){e.areWeOnline&&e.queue.length>0&&e.flush(),e.poll()},this.pollIntervalMs)}},{key:"flush",value:function(){var e=Date.now(),t=[],i=this.queue.filter(function(a){return a.retryAt0){var r,s=xe(i);try{for(s.s();!(r=s.n()).done;){var o=r.value.requestOptions;this.retriableRequest(o)}}catch(a){s.e(a)}finally{s.f()}}}},{key:"unload",value:function(){this.poller&&(clearTimeout(this.poller),this.poller=void 0);var e,t=xe(this.queue);try{for(t.s();!(e=t.n()).done;){var i=e.value.requestOptions;try{this.instance._send_request(I(I({},i),{},{transport:"sendBeacon"}))}catch(r){b.error(r)}}}catch(r){t.e(r)}finally{t.f()}this.queue=[]}}]),n}(),Yn=1800,Yu=function(){function n(e,t,i,r){var s;V(this,n),m(this,"_sessionIdChangedHandlers",[]),this.config=e,this.persistence=t,this._windowId=void 0,this._sessionId=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this._sessionIdGenerator=i||Ze,this._windowIdGenerator=r||Ze;var o=e.persistence_name||e.token,a=e.session_idle_timeout_seconds||Yn;if(Fe(a)?a>Yn?b.warn("session_idle_timeout_seconds cannot be greater than 30 minutes. Using 30 minutes instead."):a<60&&b.warn("session_idle_timeout_seconds cannot be less than 60 seconds. Using 60 seconds instead."):(b.warn("session_idle_timeout_seconds must be a number. Defaulting to 30 minutes."),a=Yn),this._sessionTimeoutMs=1e3*Math.min(Math.max(a,60),Yn),this._window_id_storage_key="ph_"+o+"_window_id",this._primary_window_exists_storage_key="ph_"+o+"_primary_window_exists",this._canUseSessionStorage()){var u=pe.parse(this._window_id_storage_key),l=pe.parse(this._primary_window_exists_storage_key);u&&!l?this._windowId=u:pe.remove(this._window_id_storage_key),pe.set(this._primary_window_exists_storage_key,!0)}if((s=this.config.bootstrap)!==null&&s!==void 0&&s.sessionID)try{var c=function(d){var h=d.replace(/-/g,"");if(h.length!==32)throw new Error("Not a valid UUID");if(h[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(h.substring(0,12),16)}(this.config.bootstrap.sessionID);this._setSessionId(this.config.bootstrap.sessionID,new Date().getTime(),c)}catch(d){b.error("Invalid sessionID in bootstrap",d)}this._listenToReloadWindow()}return G(n,[{key:"onSessionId",value:function(e){var t=this;return O(this._sessionIdChangedHandlers)&&(this._sessionIdChangedHandlers=[]),this._sessionIdChangedHandlers.push(e),this._sessionId&&e(this._sessionId,this._windowId),function(){t._sessionIdChangedHandlers=t._sessionIdChangedHandlers.filter(function(i){return i!==e})}}},{key:"_canUseSessionStorage",value:function(){return this.config.persistence!=="memory"&&!this.persistence.disabled&&pe.is_supported()}},{key:"_setWindowId",value:function(e){e!==this._windowId&&(this._windowId=e,this._canUseSessionStorage()&&pe.set(this._window_id_storage_key,e))}},{key:"_getWindowId",value:function(){return this._windowId?this._windowId:this._canUseSessionStorage()?pe.parse(this._window_id_storage_key):null}},{key:"_setSessionId",value:function(e,t,i){e===this._sessionId&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this._sessionId=e,this.persistence.register(m({},Cn,[t,e,i])))}},{key:"_getSessionId",value:function(){if(this._sessionId&&this._sessionActivityTimestamp&&this._sessionStartTimestamp)return[this._sessionActivityTimestamp,this._sessionId,this._sessionStartTimestamp];var e=this.persistence.props[Cn];return ae(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}},{key:"resetSessionId",value:function(){this._setSessionId(null,null,null)}},{key:"_listenToReloadWindow",value:function(){var e=this;p==null||p.addEventListener("beforeunload",function(){e._canUseSessionStorage()&&pe.remove(e._primary_window_exists_storage_key)})}},{key:"checkAndGetSessionAndWindowId",value:function(){var e=arguments.length>0&&arguments[0]!==void 0&&arguments[0],t=(arguments.length>1&&arguments[1]!==void 0?arguments[1]:null)||new Date().getTime(),i=ge(this._getSessionId(),3),r=i[0],s=i[1],o=i[2],a=this._getWindowId(),u=o&&o>0&&Math.abs(t-o)>864e5,l=!1,c=!s,d=!e&&Math.abs(t-r)>this._sessionTimeoutMs;c||d||u?(s=this._sessionIdGenerator(),a=this._windowIdGenerator(),b.info("[SessionId] new session ID generated",{sessionId:s,windowId:a,changeReason:{noSessionId:c,activityTimeout:d,sessionPastMaximumLength:u}}),o=t,l=!0):a||(a=this._windowIdGenerator(),l=!0);var h=r===0||!e||u?t:r,f=o===0?new Date().getTime():o;return this._setWindowId(a),this._setSessionId(s,h,f),l&&this._sessionIdChangedHandlers.forEach(function(_){return _(s,a)}),{sessionId:s,windowId:a,sessionStartTimestamp:f}}}]),n}();(function(n){n.US="us",n.EU="eu",n.CUSTOM="custom"})(ht||(ht={}));var bo="i.posthog.com",Ku=function(){function n(e){V(this,n),m(this,"_regionCache",{}),this.instance=e}return G(n,[{key:"apiHost",get:function(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}},{key:"uiHost",get:function(){var e,t=(e=this.instance.config.ui_host)===null||e===void 0?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace(".".concat(bo),".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}},{key:"region",get:function(){return this._regionCache[this.apiHost]||(/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=ht.US:/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?this._regionCache[this.apiHost]=ht.EU:this._regionCache[this.apiHost]=ht.CUSTOM),this._regionCache[this.apiHost]}},{key:"endpointFor",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";if(t&&(t=t[0]==="/"?t:"/".concat(t)),e==="ui")return this.uiHost+t;if(this.region===ht.CUSTOM)return this.apiHost+t;var i=bo+t;switch(e){case"assets":return"https://".concat(this.region,"-assets.").concat(i);case"api":return"https://".concat(this.region,".").concat(i)}}},{key:"loadScript",value:function(e,t){if(this.instance.config.disable_external_dependency_loading)return b.warn("".concat(e," was requested but loading of external scripts is disabled.")),t("Loading of external scripts is disabled");var i=e[0]==="/"?this.endpointFor("assets",e):e,r=function(){if(!$)return t("document not found");var s=$.createElement("script");s.type="text/javascript",s.src=i,s.onload=function(u){return t(void 0,u)},s.onerror=function(u){return t(u)};var o,a=$.querySelectorAll("body > script");a.length>0?(o=a[0].parentNode)===null||o===void 0||o.insertBefore(s,a[0]):$.body.appendChild(s)};$!=null&&$.body?r():$==null||$.addEventListener("DOMContentLoaded",r)}}]),n}(),wo="posthog-js";function ko(n){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},t=e.organization,i=e.projectId,r=e.prefix,s=e.severityAllowList,o=s===void 0?["error"]:s;return function(a){var u,l,c,d,h;if(!(o==="*"||o.includes(a.level))||!n.__loaded)return a;a.tags||(a.tags={});var f=n.requestRouter.endpointFor("ui","/project/".concat(n.config.token,"/person/").concat(n.get_distinct_id()));a.tags["PostHog Person URL"]=f,n.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=n.get_session_replay_url({withTimestamp:!0}));var _=((u=a.exception)===null||u===void 0?void 0:u.values)||[],v={$exception_message:((l=_[0])===null||l===void 0?void 0:l.value)||a.message,$exception_type:(c=_[0])===null||c===void 0?void 0:c.type,$exception_personURL:f,$exception_level:a.level,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((d=_[0])===null||d===void 0?void 0:d.value)||a.message,$sentry_exception_type:(h=_[0])===null||h===void 0?void 0:h.type,$sentry_tags:a.tags,$level:a.level};return t&&i&&(v.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+a.event_id),n.exceptions.sendExceptionEvent(v),a}}var Zu=G(function n(e,t,i,r,s){V(this,n),this.name=wo,this.setupOnce=function(o){o(ko(e,{organization:t,projectId:i,prefix:r,severityAllowList:s}))}});function el(n,e){var t=n.config.segment;if(!t)return e();(function(i,r){var s=i.config.segment;if(!s)return r();var o=function(u){var l=function(){return u.anonymousId()||Ze()};i.config.get_device_id=l,u.id()&&(i.register({distinct_id:u.id(),$device_id:l()}),i.persistence.set_property(ze,"identified")),r()},a=s.user();"then"in a&&Re(a.then)?a.then(function(u){return o(u)}):o(a)})(n,function(){t.register(function(i){Promise&&Promise.resolve||b.warn("This browser does not have Promise support, and can not use the segment integration");var r=function(s,o){var a;if(!o)return s;s.event.userId||s.event.anonymousId===i.get_distinct_id()||(b.info("Segment integration does not have a userId set, resetting PostHog"),i.reset()),s.event.userId&&s.event.userId!==i.get_distinct_id()&&(b.info("Segment integration has a userId set, identifying with PostHog"),i.identify(s.event.userId));var u=i._calculate_event_properties(o,(a=s.event.properties)!==null&&a!==void 0?a:{},new Date);return s.event.properties=Object.assign({},u,s.event.properties),s};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:function(){return!0},load:function(){return Promise.resolve()},track:function(s){return r(s,s.event.event)},page:function(s){return r(s,"$pageview")},identify:function(s){return r(s,"$identify")},screen:function(s){return r(s,"$screen")}}}(n)).then(function(){e()})})}var So,Kn,De,tl=function(){function n(e){V(this,n),this._instance=e}return G(n,[{key:"doPageView",value:function(e){var t,i=this._previousPageViewProperties(e);return this._currentPath=(t=p==null?void 0:p.location.pathname)!==null&&t!==void 0?t:"",this._instance.scrollManager.resetContext(),this._prevPageviewTimestamp=e,i}},{key:"doPageLeave",value:function(e){return this._previousPageViewProperties(e)}},{key:"_previousPageViewProperties",value:function(e){var t=this._currentPath,i=this._prevPageviewTimestamp,r=this._instance.scrollManager.getContext();if(!i)return{};var s={};if(r){var o=r.maxScrollHeight,a=r.lastScrollY,u=r.maxScrollY,l=r.maxContentHeight,c=r.lastContentY,d=r.maxContentY;O(o)||O(a)||O(u)||O(l)||O(c)||O(d)||(o=Math.ceil(o),a=Math.ceil(a),u=Math.ceil(u),l=Math.ceil(l),c=Math.ceil(c),d=Math.ceil(d),s={$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:o<=1?1:Zn(a/o,0,1),$prev_pageview_max_scroll:u,$prev_pageview_max_scroll_percentage:o<=1?1:Zn(u/o,0,1),$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:l<=1?1:Zn(c/l,0,1),$prev_pageview_max_content:d,$prev_pageview_max_content_percentage:l<=1?1:Zn(d/l,0,1)})}return t&&(s.$prev_pageview_pathname=t),i&&(s.$prev_pageview_duration=(e.getTime()-i.getTime())/1e3),s}}]),n}();function Zn(n,e,t){return Math.max(e,Math.min(n,t))}(function(n){n.Popover="popover",n.API="api",n.Widget="widget"})(So||(So={})),function(n){n.Open="open",n.MultipleChoice="multiple_choice",n.SingleChoice="single_choice",n.Rating="rating",n.Link="link"}(Kn||(Kn={})),function(n){n.NextQuestion="next_question",n.End="end",n.ResponseBased="response_based",n.SpecificQuestion="specific_question"}(De||(De={}));var Io=function(){function n(){V(this,n),m(this,"events",{}),this.events={}}return G(n,[{key:"on",value:function(e,t){var i=this;return this.events[e]||(this.events[e]=[]),this.events[e].push(t),function(){i.events[e]=i.events[e].filter(function(r){return r!==t})}}},{key:"emit",value:function(e,t){var i,r=xe(this.events[e]||[]);try{for(r.s();!(i=r.n()).done;)(0,i.value)(t)}catch(a){r.e(a)}finally{r.f()}var s,o=xe(this.events["*"]||[]);try{for(o.s();!(s=o.n()).done;)(0,s.value)(e,t)}catch(a){o.e(a)}finally{o.f()}}}]),n}(),nl=function(){function n(e){var t=this;V(this,n),m(this,"_debugEventEmitter",new Io),m(this,"checkStep",function(i,r){return t.checkStepEvent(i,r)&&t.checkStepUrl(i,r)&&t.checkStepElement(i,r)}),m(this,"checkStepEvent",function(i,r){return r==null||!r.event||(i==null?void 0:i.event)===(r==null?void 0:r.event)}),this.instance=e,this.actionEvents=new Set,this.actionRegistry=new Set}return G(n,[{key:"init",value:function(){var e,t=this;if(!O((e=this.instance)===null||e===void 0?void 0:e._addCaptureHook)){var i;(i=this.instance)===null||i===void 0||i._addCaptureHook(function(r,s){t.on(r,s)})}}},{key:"register",value:function(e){var t,i,r=this;if(!O((t=this.instance)===null||t===void 0?void 0:t._addCaptureHook)&&(e.forEach(function(a){var u,l;(u=r.actionRegistry)===null||u===void 0||u.add(a),(l=a.steps)===null||l===void 0||l.forEach(function(c){var d;(d=r.actionEvents)===null||d===void 0||d.add((c==null?void 0:c.event)||"")})}),(i=this.instance)!==null&&i!==void 0&&i.autocapture)){var s,o=new Set;e.forEach(function(a){var u;(u=a.steps)===null||u===void 0||u.forEach(function(l){l!=null&&l.selector&&o.add(l==null?void 0:l.selector)})}),(s=this.instance)===null||s===void 0||s.autocapture.setElementSelectors(o)}}},{key:"on",value:function(e,t){var i,r=this;t!=null&&e.length!=0&&(this.actionEvents.has(e)||this.actionEvents.has(t==null?void 0:t.event))&&this.actionRegistry&&((i=this.actionRegistry)===null||i===void 0?void 0:i.size)>0&&this.actionRegistry.forEach(function(s){r.checkAction(t,s)&&r._debugEventEmitter.emit("actionCaptured",s.name)})}},{key:"_addActionHook",value:function(e){this.onAction("actionCaptured",function(t){return e(t)})}},{key:"checkAction",value:function(e,t){if((t==null?void 0:t.steps)==null)return!1;var i,r=xe(t.steps);try{for(r.s();!(i=r.n()).done;){var s=i.value;if(this.checkStep(e,s))return!0}}catch(o){r.e(o)}finally{r.f()}return!1}},{key:"onAction",value:function(e,t){return this._debugEventEmitter.on(e,t)}},{key:"checkStepUrl",value:function(e,t){if(t!=null&&t.url){var i,r=e==null||(i=e.properties)===null||i===void 0?void 0:i.$current_url;if(!r||typeof r!="string"||!n.matchString(r,t==null?void 0:t.url,(t==null?void 0:t.url_matching)||"contains"))return!1}return!0}},{key:"checkStepElement",value:function(e,t){if((t!=null&&t.href||t!=null&&t.tag_name||t!=null&&t.text)&&!this.getElementsList(e).some(function(s){return!(t!=null&&t.href&&!n.matchString(s.href||"",t==null?void 0:t.href,(t==null?void 0:t.href_matching)||"exact"))&&(t==null||!t.tag_name||s.tag_name===(t==null?void 0:t.tag_name))&&!(t!=null&&t.text&&!n.matchString(s.text||"",t==null?void 0:t.text,(t==null?void 0:t.text_matching)||"exact")&&!n.matchString(s.$el_text||"",t==null?void 0:t.text,(t==null?void 0:t.text_matching)||"exact"))}))return!1;if(t!=null&&t.selector){var i,r=e==null||(i=e.properties)===null||i===void 0?void 0:i.$element_selectors;if(!r||!r.includes(t==null?void 0:t.selector))return!1}return!0}},{key:"getElementsList",value:function(e){return(e==null?void 0:e.properties.$elements)==null?[]:e==null?void 0:e.properties.$elements}}],[{key:"matchString",value:function(e,t,i){switch(i){case"regex":return!!p&&jn(e,t);case"exact":return t===e;case"contains":var r=n.escapeStringRegexp(t).replace(/_/g,".").replace(/%/g,".*");return jn(e,r);default:return!1}}},{key:"escapeStringRegexp",value:function(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}}]),n}(),ur=function(){function n(e){V(this,n),this.instance=e,this.eventToSurveys=new Map,this.actionToSurveys=new Map}return G(n,[{key:"register",value:function(e){var t;O((t=this.instance)===null||t===void 0?void 0:t._addCaptureHook)||(this.setupEventBasedSurveys(e),this.setupActionBasedSurveys(e))}},{key:"setupActionBasedSurveys",value:function(e){var t=this,i=e.filter(function(r){var s,o,a,u;return((s=r.conditions)===null||s===void 0?void 0:s.actions)&&((o=r.conditions)===null||o===void 0||(a=o.actions)===null||a===void 0||(u=a.values)===null||u===void 0?void 0:u.length)>0});i.length!==0&&(this.actionMatcher==null&&(this.actionMatcher=new nl(this.instance),this.actionMatcher.init(),this.actionMatcher._addActionHook(function(r){t.onAction(r)})),i.forEach(function(r){var s,o,a,u,l,c,d,h,f,_;r.conditions&&(s=r.conditions)!==null&&s!==void 0&&s.actions&&(o=r.conditions)!==null&&o!==void 0&&(a=o.actions)!==null&&a!==void 0&&a.values&&((u=r.conditions)===null||u===void 0||(l=u.actions)===null||l===void 0||(c=l.values)===null||c===void 0?void 0:c.length)>0&&((d=t.actionMatcher)===null||d===void 0||d.register(r.conditions.actions.values),(h=r.conditions)===null||h===void 0||(f=h.actions)===null||f===void 0||(_=f.values)===null||_===void 0||_.forEach(function(v){if(v&&v.name){var S=t.actionToSurveys.get(v.name);S&&S.push(r.id),t.actionToSurveys.set(v.name,S||[r.id])}}))}))}},{key:"setupEventBasedSurveys",value:function(e){var t,i=this;e.filter(function(r){var s,o,a,u;return((s=r.conditions)===null||s===void 0?void 0:s.events)&&((o=r.conditions)===null||o===void 0||(a=o.events)===null||a===void 0||(u=a.values)===null||u===void 0?void 0:u.length)>0}).length!==0&&((t=this.instance)===null||t===void 0||t._addCaptureHook(function(r,s){i.onEvent(r,s)}),e.forEach(function(r){var s,o,a;(s=r.conditions)===null||s===void 0||(o=s.events)===null||o===void 0||(a=o.values)===null||a===void 0||a.forEach(function(u){if(u&&u.name){var l=i.eventToSurveys.get(u.name);l&&l.push(r.id),i.eventToSurveys.set(u.name,l||[r.id])}})}))}},{key:"onEvent",value:function(e,t){var i,r,s=((i=this.instance)===null||i===void 0||(r=i.persistence)===null||r===void 0?void 0:r.props[An])||[];if(n.SURVEY_SHOWN_EVENT_NAME==e&&t&&s.length>0){var o,a=t==null||(o=t.properties)===null||o===void 0?void 0:o.$survey_id;if(a){var u=s.indexOf(a);u>=0&&(s.splice(u,1),this._updateActivatedSurveys(s))}}else this.eventToSurveys.has(e)&&this._updateActivatedSurveys(s.concat(this.eventToSurveys.get(e)||[]))}},{key:"onAction",value:function(e){var t,i,r=((t=this.instance)===null||t===void 0||(i=t.persistence)===null||i===void 0?void 0:i.props[An])||[];this.actionToSurveys.has(e)&&this._updateActivatedSurveys(r.concat(this.actionToSurveys.get(e)||[]))}},{key:"_updateActivatedSurveys",value:function(e){var t,i;(t=this.instance)===null||t===void 0||(i=t.persistence)===null||i===void 0||i.register(m({},An,Be(new Set(e))))}},{key:"getSurveys",value:function(){var e,t,i=(e=this.instance)===null||e===void 0||(t=e.persistence)===null||t===void 0?void 0:t.props[An];return i||[]}},{key:"getEventToSurveys",value:function(){return this.eventToSurveys}},{key:"_getActionMatcher",value:function(){return this.actionMatcher}}]),n}();m(ur,"SURVEY_SHOWN_EVENT_NAME","survey shown");var ln="[Surveys]",il={icontains:function(n){return!!p&&p.location.href.toLowerCase().indexOf(n.toLowerCase())>-1},not_icontains:function(n){return!!p&&p.location.href.toLowerCase().indexOf(n.toLowerCase())===-1},regex:function(n){return!!p&&jn(p.location.href,n)},not_regex:function(n){return!!p&&!jn(p.location.href,n)},exact:function(n){return(p==null?void 0:p.location.href)===n},is_not:function(n){return(p==null?void 0:p.location.href)!==n}},rl=function(){function n(e){V(this,n),this.instance=e,this._surveyEventReceiver=null}return G(n,[{key:"afterDecideResponse",value:function(e){this._decideServerResponse=!!e.surveys,this.loadIfEnabled()}},{key:"loadIfEnabled",value:function(){var e=this,t=Z==null?void 0:Z.extendPostHogWithSurveys;this.instance.config.disable_surveys||!this._decideServerResponse||t||(this._surveyEventReceiver==null&&(this._surveyEventReceiver=new ur(this.instance)),this.instance.requestRouter.loadScript("/static/surveys.js",function(i){if(i)return b.error(ln,"Could not load surveys script",i);e._surveyManager=Z.extendPostHogWithSurveys(e.instance)}))}},{key:"getSurveys",value:function(e){var t=this,i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];if(this.instance.config.disable_surveys)return e([]);this._surveyEventReceiver==null&&(this._surveyEventReceiver=new ur(this.instance));var r=this.instance.get_property(Fi);if(r&&!i)return e(r);this.instance._send_request({url:this.instance.requestRouter.endpointFor("api","/api/surveys/?token=".concat(this.instance.config.token)),method:"GET",transport:"XHR",callback:function(s){var o;if(s.statusCode!==200||!s.json)return e([]);var a,u=s.json.surveys||[],l=u.filter(function(c){var d,h,f,_,v,S,P,E,F,k,w,L;return((d=c.conditions)===null||d===void 0?void 0:d.events)&&((h=c.conditions)===null||h===void 0||(f=h.events)===null||f===void 0?void 0:f.values)&&((_=c.conditions)===null||_===void 0||(v=_.events)===null||v===void 0||(S=v.values)===null||S===void 0?void 0:S.length)>0||((P=c.conditions)===null||P===void 0?void 0:P.actions)&&((E=c.conditions)===null||E===void 0||(F=E.actions)===null||F===void 0?void 0:F.values)&&((k=c.conditions)===null||k===void 0||(w=k.actions)===null||w===void 0||(L=w.values)===null||L===void 0?void 0:L.length)>0});return l.length>0&&((a=t._surveyEventReceiver)===null||a===void 0||a.register(l)),(o=t.instance.persistence)===null||o===void 0||o.register(m({},Fi,u)),e(u)}})}},{key:"getActiveMatchingSurveys",value:function(e){var t=this,i=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.getSurveys(function(r){var s,o=r.filter(function(l){return!(!l.start_date||l.end_date)}).filter(function(l){var c,d,h,f;if(!l.conditions)return!0;var _=(c=l.conditions)===null||c===void 0||!c.url||il[(d=(h=l.conditions)===null||h===void 0?void 0:h.urlMatchType)!==null&&d!==void 0?d:"icontains"](l.conditions.url),v=(f=l.conditions)===null||f===void 0||!f.selector||($==null?void 0:$.querySelector(l.conditions.selector));return _&&v}),a=(s=t._surveyEventReceiver)===null||s===void 0?void 0:s.getSurveys(),u=o.filter(function(l){var c,d,h,f,_,v,S,P,E,F;if(!l.linked_flag_key&&!l.targeting_flag_key&&!l.internal_targeting_flag_key)return!0;var k=!l.linked_flag_key||t.instance.featureFlags.isFeatureEnabled(l.linked_flag_key),w=!l.targeting_flag_key||t.instance.featureFlags.isFeatureEnabled(l.targeting_flag_key),L=((c=l.conditions)===null||c===void 0?void 0:c.events)&&((d=l.conditions)===null||d===void 0||(h=d.events)===null||h===void 0?void 0:h.values)&&((f=l.conditions)===null||f===void 0||(_=f.events)===null||_===void 0?void 0:_.values.length)>0,A=((v=l.conditions)===null||v===void 0?void 0:v.actions)&&((S=l.conditions)===null||S===void 0||(P=S.actions)===null||P===void 0?void 0:P.values)&&((E=l.conditions)===null||E===void 0||(F=E.actions)===null||F===void 0?void 0:F.values.length)>0,x=!L&&!A||(a==null?void 0:a.includes(l.id)),H=t._canActivateRepeatedly(l),j=!(l.internal_targeting_flag_key&&!H)||t.instance.featureFlags.isFeatureEnabled(l.internal_targeting_flag_key);return k&&w&&j&&x});return e(u)},i)}},{key:"getNextSurveyStep",value:function(e,t,i){var r,s=e.questions[t],o=t+1;if((r=s.branching)===null||r===void 0||!r.type)return t===e.questions.length-1?De.End:o;if(s.branching.type===De.End)return De.End;if(s.branching.type===De.SpecificQuestion){if(Number.isInteger(s.branching.index))return s.branching.index}else if(s.branching.type===De.ResponseBased){if(s.type===Kn.SingleChoice){var a,u,l=s.choices.indexOf("".concat(i));if((a=s.branching)!==null&&a!==void 0&&(u=a.responseValues)!==null&&u!==void 0&&u.hasOwnProperty(l)){var c=s.branching.responseValues[l];return Number.isInteger(c)?c:c===De.End?De.End:o}}else if(s.type===Kn.Rating){var d,h;if(typeof i!="number"||!Number.isInteger(i))throw new Error("The response type must be an integer");var f=function(v,S){if(S===3){if(v<1||v>3)throw new Error("The response must be in range 1-3");return v===1?"negative":v===2?"neutral":"positive"}if(S===5){if(v<1||v>5)throw new Error("The response must be in range 1-5");return v<=2?"negative":v===3?"neutral":"positive"}if(S===10){if(v<0||v>10)throw new Error("The response must be in range 0-10");return v<=6?"detractors":v<=8?"passives":"promoters"}throw new Error("The scale must be one of: 3, 5, 10")}(i,s.scale);if((d=s.branching)!==null&&d!==void 0&&(h=d.responseValues)!==null&&h!==void 0&&h.hasOwnProperty(f)){var _=s.branching.responseValues[f];return Number.isInteger(_)?_:_===De.End?De.End:o}}return o}return b.warn(ln,"Falling back to next question index due to unexpected branching type"),o}},{key:"_canActivateRepeatedly",value:function(e){return we(Z.__PosthogExtensions__.canActivateRepeatedly)&&b.warn(ln,"canActivateRepeatedly is not defined, must init before calling"),Z.__PosthogExtensions__.canActivateRepeatedly(e)}},{key:"canRenderSurvey",value:function(e){var t=this;we(this._surveyManager)?b.warn(ln,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys(function(i){var r=i.filter(function(s){return s.id===e})[0];t._surveyManager.canRenderSurvey(r)})}},{key:"renderSurvey",value:function(e,t){var i=this;we(this._surveyManager)?b.warn(ln,"canActivateRepeatedly is not defined, must init before calling"):this.getSurveys(function(r){var s=r.filter(function(o){return o.id===e})[0];i._surveyManager.renderSurvey(s,$==null?void 0:$.querySelector(t))})}}]),n}(),sl=function(){function n(e){var t,i,r=this;V(this,n),m(this,"serverLimits",{}),m(this,"lastEventRateLimited",!1),m(this,"checkForLimiting",function(s){var o=s.text;if(o&&o.length)try{(JSON.parse(o).quota_limited||[]).forEach(function(a){b.info("[RateLimiter] ".concat(a||"events"," is quota limited.")),r.serverLimits[a]=new Date().getTime()+6e4})}catch(a){return void b.warn('[RateLimiter] could not rate limit - continuing. Error: "'.concat(a==null?void 0:a.message,'"'),{text:o})}}),this.instance=e,this.captureEventsPerSecond=((t=e.config.rate_limiting)===null||t===void 0?void 0:t.events_per_second)||10,this.captureEventsBurstLimit=Math.max(((i=e.config.rate_limiting)===null||i===void 0?void 0:i.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond),this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}return G(n,[{key:"clientRateLimitContext",value:function(){var e,t,i,r=arguments.length>0&&arguments[0]!==void 0&&arguments[0],s=new Date().getTime(),o=(e=(t=this.instance.persistence)===null||t===void 0?void 0:t.get_property(Ti))!==null&&e!==void 0?e:{tokens:this.captureEventsBurstLimit,last:s};o.tokens+=(s-o.last)/1e3*this.captureEventsPerSecond,o.last=s,o.tokens>this.captureEventsBurstLimit&&(o.tokens=this.captureEventsBurstLimit);var a=o.tokens<1;return a||r||(o.tokens=Math.max(0,o.tokens-1)),!a||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=a,(i=this.instance.persistence)===null||i===void 0||i.set_property(Ti,o),{isRateLimited:a,remainingTokens:o.tokens}}},{key:"isServerRateLimited",value:function(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()n?e.slice(0,n)+"...":e}var nt,dl=function(){function n(e){V(this,n),m(this,"_initialized",!1),m(this,"_isDisabledServerSide",null),m(this,"rageclicks",new Po),m(this,"_elementsChainAsString",!1),this.instance=e,this._elementSelectors=null}return G(n,[{key:"config",get:function(){var e,t,i=fe(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=(e=i.url_allowlist)===null||e===void 0?void 0:e.map(function(r){return new RegExp(r)}),i.url_ignorelist=(t=i.url_ignorelist)===null||t===void 0?void 0:t.map(function(r){return new RegExp(r)}),i}},{key:"_addDomEventHandlers",value:function(){var e=this;if(this.isBrowserSupported()){if(p&&$){var t=function(r){r=r||(p==null?void 0:p.event);try{e._captureEvent(r)}catch(s){b.error("Failed to capture event",s)}},i=function(r){r=r||(p==null?void 0:p.event),e._captureEvent(r,lr)};He($,"submit",t,!1,!0),He($,"change",t,!1,!0),He($,"click",t,!1,!0),this.config.capture_copied_text&&(He($,"copy",i,!1,!0),He($,"cut",i,!1,!0))}}else b.info("Disabling Automatic Event Collection because this browser is not supported")}},{key:"startIfEnabled",value:function(){this.isEnabled&&!this._initialized&&(this._addDomEventHandlers(),this._initialized=!0)}},{key:"afterDecideResponse",value:function(e){e.elementsChainAsString&&(this._elementsChainAsString=e.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register(m({},ps,!!e.autocapture_opt_out)),this._isDisabledServerSide=!!e.autocapture_opt_out,this.startIfEnabled()}},{key:"setElementSelectors",value:function(e){this._elementSelectors=e}},{key:"getElementSelectors",value:function(e){var t,i=[];return(t=this._elementSelectors)===null||t===void 0||t.forEach(function(r){var s=$==null?void 0:$.querySelectorAll(r);s==null||s.forEach(function(o){e===o&&i.push(r)})}),i}},{key:"isEnabled",get:function(){var e,t,i=(e=this.instance.persistence)===null||e===void 0?void 0:e.props[ps],r=this._isDisabledServerSide;if(Ue(r)&&!lt(i)&&!this.instance.config.advanced_disable_decide)return!1;var s=(t=this._isDisabledServerSide)!==null&&t!==void 0?t:!!i;return!!this.instance.config.autocapture&&!s}},{key:"_previousElementSibling",value:function(e){if(e.previousElementSibling)return e.previousElementSibling;var t=e;do t=t.previousSibling;while(t&&!Xi(t));return t}},{key:"_getAugmentPropertiesFromElement",value:function(e){if(!Ki(e))return{};var t={};return X(e.attributes,function(i){if(i.name&&i.name.indexOf("data-ph-capture-attribute")===0){var r=i.name.replace("data-ph-capture-attribute-",""),s=i.value;r&&s&&Ct(s)&&(t[r]=s)}}),t}},{key:"_getPropertiesFromElement",value:function(e,t,i){var r,s=e.tagName.toLowerCase(),o={tag_name:s};Yi.indexOf(s)>-1&&!i&&(s.toLowerCase()==="a"||s.toLowerCase()==="button"?o.$el_text=cr(1024,io(e)):o.$el_text=cr(1024,Gn(e)));var a=Vn(e);a.length>0&&(o.classes=a.filter(function(h){return h!==""}));var u=(r=this.config)===null||r===void 0?void 0:r.element_attribute_ignorelist;X(e.attributes,function(h){var f;if((!eo(e)||["name","id","class","aria-label"].indexOf(h.name)!==-1)&&(u==null||!u.includes(h.name))&&!t&&Ct(h.value)&&(f=h.name,!ve(f)||f.substring(0,10)!=="_ngcontent"&&f.substring(0,7)!=="_nghost")){var _=h.value;h.name==="class"&&(_=Qi(_).join(" ")),o["attr__"+h.name]=cr(1024,_)}});for(var l=1,c=1,d=e;d=this._previousElementSibling(d);)l++,d.tagName===e.tagName&&c++;return o.nth_child=l,o.nth_of_type=c,o}},{key:"_getDefaultProperties",value:function(e){return{$event_type:e,$ce_version:1}}},{key:"_getEventTarget",value:function(e){return O(e.target)?e.srcElement||null:(t=e.target)!==null&&t!==void 0&&t.shadowRoot?e.composedPath()[0]||null:e.target||null;var t}},{key:"_captureEvent",value:function(e){var t=this,i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"$autocapture";if(this.isEnabled){var r,s=this._getEventTarget(e);Ys(s)&&(s=s.parentNode||null),i==="$autocapture"&&e.type==="click"&&e instanceof MouseEvent&&this.instance.config.rageclick&&(r=this.rageclicks)!==null&&r!==void 0&&r.isRageClick(e.clientX,e.clientY,new Date().getTime())&&this._captureEvent(e,"$rageclick");var o=i===lr;if(s&&yu(s,e,this.config,o,o?["copy","cut"]:void 0)){for(var a,u,l=[s],c=s;c.parentNode&&!tt(c,"body");)Ks(c.parentNode)?(l.push(c.parentNode.host),c=c.parentNode.host):(l.push(c.parentNode),c=c.parentNode);var d,h,f=[],_={},v=!1;if(X(l,function(H){var j=Ki(H);H.tagName.toLowerCase()==="a"&&(d=H.getAttribute("href"),d=j&&Ct(d)&&d),U(Vn(H),"ph-no-capture")&&(v=!0),f.push(t._getPropertiesFromElement(H,t.instance.config.mask_all_element_attributes,t.instance.config.mask_all_text));var te=t._getAugmentPropertiesFromElement(H);_e(_,te)}),this.instance.config.mask_all_text||(s.tagName.toLowerCase()==="a"||s.tagName.toLowerCase()==="button"?f[0].$el_text=io(s):f[0].$el_text=Gn(s)),d){var S,P;f[0].attr__href=d;var E=(S=Kt(d))===null||S===void 0?void 0:S.host,F=p==null||(P=p.location)===null||P===void 0?void 0:P.host;E&&F&&E!==F&&(h=d)}if(v)return!1;var k=_e(this._getDefaultProperties(e.type),this._elementsChainAsString?{$elements_chain:Iu(f)}:{$elements:f},(a=f[0])!==null&&a!==void 0&&a.$el_text?{$el_text:(u=f[0])===null||u===void 0?void 0:u.$el_text}:{},h&&e.type==="click"?{$external_click_url:h}:{},_),w=this.getElementSelectors(s);if(w&&w.length>0&&(k.$element_selectors=w),i===lr){var L,A=Xs(p==null||(L=p.getSelection())===null||L===void 0?void 0:L.toString()),x=e.type||"clipboard";if(!A)return!1;k.$selected_content=A,k.$copy_type=x}return this.instance.capture(i,k),!0}}}},{key:"isBrowserSupported",value:function(){return Re($==null?void 0:$.querySelectorAll)}}]),n}(),fl=function(){function n(e){var t=this;V(this,n),m(this,"_restoreXHRPatch",void 0),m(this,"_restoreFetchPatch",void 0),m(this,"_startCapturing",function(){O(t._restoreXHRPatch)&&Z.postHogTracingHeadersPatchFns._patchXHR(t.instance.sessionManager),O(t._restoreFetchPatch)&&Z.postHogTracingHeadersPatchFns._patchFetch(t.instance.sessionManager)}),this.instance=e}return G(n,[{key:"_loadScript",value:function(e){Z.postHogTracingHeadersPatchFns&&e(),this.instance.requestRouter.loadScript("/static/tracing-headers.js?v=".concat($e.LIB_VERSION),function(t){if(t)return b.error("[TRACING-HEADERS] failed to load script",t);e()})}},{key:"startIfEnabledOrStop",value:function(){var e,t;this.instance.config.__add_tracing_headers?this._loadScript(this._startCapturing):((e=this._restoreXHRPatch)===null||e===void 0||e.call(this),(t=this._restoreFetchPatch)===null||t===void 0||t.call(this),this._restoreXHRPatch=void 0,this._restoreFetchPatch=void 0)}}]),n}();(function(n){n[n.PENDING=-1]="PENDING",n[n.DENIED=0]="DENIED",n[n.GRANTED=1]="GRANTED"})(nt||(nt={}));var hl=function(){function n(e){V(this,n),this.instance=e}return G(n,[{key:"config",get:function(){return this.instance.config}},{key:"consent",get:function(){return this.getDnt()?nt.DENIED:this.storedConsent}},{key:"isOptedOut",value:function(){return this.consent===nt.DENIED||this.consent===nt.PENDING&&this.config.opt_out_capturing_by_default}},{key:"isOptedIn",value:function(){return!this.isOptedOut()}},{key:"optInOut",value:function(e){this.storage.set(this.storageKey,e?1:0,this.config.cookie_expiration,this.config.cross_subdomain_cookie,this.config.secure_cookie)}},{key:"reset",value:function(){this.storage.remove(this.storageKey,this.config.cross_subdomain_cookie)}},{key:"storageKey",get:function(){var e=this.instance.config,t=e.token;return(e.opt_out_capturing_cookie_prefix||"__ph_opt_in_out_")+t}},{key:"storedConsent",get:function(){var e=this.storage.get(this.storageKey);return e==="1"?nt.GRANTED:e==="0"?nt.DENIED:nt.PENDING}},{key:"storage",get:function(){if(!this._storage){var e=this.config.opt_out_capturing_persistence_type;this._storage=e==="localStorage"?ue:Ve;var t=e==="localStorage"?Ve:ue;t.get(this.storageKey)&&(this._storage.get(this.storageKey)||this.optInOut(t.get(this.storageKey)==="1"),t.remove(this.storageKey,this.config.cross_subdomain_cookie))}return this._storage}},{key:"getDnt",value:function(){return!!this.config.respect_dnt&&!!fs([Me==null?void 0:Me.doNotTrack,Me==null?void 0:Me.msDoNotTrack,Z.doNotTrack],function(e){return U([!0,1,"1","yes"],e)})}}]),n}(),ei="[Exception Autocapture]",pl=function(){function n(e){var t,i=this;V(this,n),m(this,"originalOnUnhandledRejectionHandler",void 0),m(this,"startCapturing",function(){if(p&&i.isEnabled&&!i.hasHandlers&&!i.isCapturing){var r=p.posthogErrorWrappingFunctions.wrapOnError,s=p.posthogErrorWrappingFunctions.wrapUnhandledRejection;if(r&&s)try{i.unwrapOnError=r(i.captureException.bind(i)),i.unwrapUnhandledRejection=s(i.captureException.bind(i))}catch(o){b.error(ei+" failed to start",o),i.stopCapturing()}else b.error(ei+" failed to load error wrapping functions - cannot start")}}),this.instance=e,this.remoteEnabled=!((t=this.instance.persistence)===null||t===void 0||!t.props[vs]),this.startIfEnabled()}return G(n,[{key:"isEnabled",get:function(){var e;return(e=this.remoteEnabled)!==null&&e!==void 0&&e}},{key:"isCapturing",get:function(){var e;return!(p==null||(e=p.onerror)===null||e===void 0||!e.__POSTHOG_INSTRUMENTED__)}},{key:"hasHandlers",get:function(){return this.originalOnUnhandledRejectionHandler||this.unwrapOnError}},{key:"startIfEnabled",value:function(){this.isEnabled&&!this.isCapturing&&(b.info(ei+" enabled, starting..."),this.loadScript(this.startCapturing))}},{key:"loadScript",value:function(e){this.hasHandlers&&e(),this.instance.requestRouter.loadScript("/static/exception-autocapture.js?v=".concat($e.LIB_VERSION),function(t){if(t)return b.error(ei+" failed to load script",t);e()})}},{key:"stopCapturing",value:function(){var e,t;(e=this.unwrapOnError)===null||e===void 0||e.call(this),(t=this.unwrapUnhandledRejection)===null||t===void 0||t.call(this)}},{key:"afterDecideResponse",value:function(e){var t=e.autocaptureExceptions;this.remoteEnabled=!!t||!1,this.instance.persistence&&this.instance.persistence.register(m({},vs,this.remoteEnabled)),this.startIfEnabled()}},{key:"captureException",value:function(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)}}]),n}(),$o=9e5,pt="[Web Vitals]",vl=function(){function n(e){var t,i=this;V(this,n),m(this,"_enabledServerSide",!1),m(this,"_initialized",!1),m(this,"buffer",{url:void 0,metrics:[],firstMetricTimestamp:void 0}),m(this,"_flushToCapture",function(){clearTimeout(i._delayedFlushTimer),i.buffer.metrics.length!==0&&(i.instance.capture("$web_vitals",i.buffer.metrics.reduce(function(r,s){var o;return I(I({},r),{},(m(o={},"$web_vitals_".concat(s.name,"_event"),I({},s)),m(o,"$web_vitals_".concat(s.name,"_value"),s.value),o))},{})),i.buffer={url:void 0,metrics:[],firstMetricTimestamp:void 0})}),m(this,"_addToBuffer",function(r){var s,o=(s=i.instance.sessionManager)===null||s===void 0?void 0:s.checkAndGetSessionAndWindowId(!0);if(O(o))b.error(pt+"Could not read session ID. Dropping metrics!");else{i.buffer=i.buffer||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var a=i._currentURL();O(a)||(we(r==null?void 0:r.name)||we(r==null?void 0:r.value)?b.error(pt+"Invalid metric received",r):i._maxAllowedValue&&r.value>=i._maxAllowedValue?b.error(pt+"Ignoring metric with value >= "+i._maxAllowedValue,r):(i.buffer.url!==a&&(i._flushToCapture(),i._delayedFlushTimer=setTimeout(i._flushToCapture,8e3)),O(i.buffer.url)&&(i.buffer.url=a),i.buffer.firstMetricTimestamp=O(i.buffer.firstMetricTimestamp)?Date.now():i.buffer.firstMetricTimestamp,i.buffer.metrics.push(I(I({},r),{},{$current_url:a,$session_id:o.sessionId,$window_id:o.windowId,timestamp:Date.now()})),i.buffer.metrics.length===4&&i._flushToCapture()))}}),m(this,"_startCapturing",function(){var r=Z.postHogWebVitalsCallbacks,s=r.onLCP,o=r.onCLS,a=r.onFCP,u=r.onINP;s&&o&&a&&u?(s(i._addToBuffer),o(i._addToBuffer),a(i._addToBuffer),u(i._addToBuffer),i._initialized=!0):b.error(pt+"web vitals callbacks not loaded - not starting")}),this.instance=e,this._enabledServerSide=!((t=this.instance.persistence)===null||t===void 0||!t.props[_s]),this.startIfEnabled()}return G(n,[{key:"_maxAllowedValue",get:function(){var e=fe(this.instance.config.capture_performance)&&Fe(this.instance.config.capture_performance.__web_vitals_max_value)?this.instance.config.capture_performance.__web_vitals_max_value:$o;return 01&&arguments[1]!==void 0?arguments[1]:{},o=arguments.length>2?arguments[2]:void 0;if(O(e)||rs(e))return b.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 b.warn("You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},this._triggered_notifs=[],this.set_config(_e({},To(),Co(s),{name:o,token:e})),this.config.on_xhr_error&&b.error("[posthog] on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:Ne.GZipJS,this.persistence=new Gi(this.config),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new Gi(I(I({},this.config),{},{persistence:"sessionStorage"}));var a=I({},this.persistence.props),u=I({},this.sessionPersistence.props);if(this._requestQueue=new Du(function(E){return r._send_retriable_request(E)}),this._retryQueue=new Xu(this),this.__request_queue=[],this.sessionManager=new Yu(this.config,this.persistence),this.sessionPropsManager=new al(this.sessionManager,this.persistence),new fl(this).startIfEnabledOrStop(),this.sessionRecording=new Cu(this),this.sessionRecording.startIfEnabledOrStop(),this.config.disable_scroll_properties||this.scrollManager.startMeasuringScrollPosition(),this.autocapture=new dl(this),this.autocapture.startIfEnabled(),this.surveys.loadIfEnabled(),this.heatmaps=new ll(this),this.heatmaps.startIfEnabled(),this.webVitalsAutocapture=new vl(this),this.exceptionObserver=new pl(this),this.exceptionObserver.startIfEnabled(),$e.DEBUG=$e.DEBUG||this.config.debug,$e.DEBUG&&b.info("Starting in debug mode",{this:this,config:s,thisC:I({},this.config),p:a,s:u}),this._sync_opt_out_with_persistence(),((t=s.bootstrap)===null||t===void 0?void 0:t.distinctID)!==void 0){var l,c,d=this.config.get_device_id(Ze()),h=(l=s.bootstrap)!==null&&l!==void 0&&l.isIdentifiedID?d:s.bootstrap.distinctID;this.persistence.set_property(ze,(c=s.bootstrap)!==null&&c!==void 0&&c.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:s.bootstrap.distinctID,$device_id:h})}if(this._hasBootstrappedFeatureFlags()){var f,_,v=Object.keys(((f=s.bootstrap)===null||f===void 0?void 0:f.featureFlags)||{}).filter(function(E){var F,k;return!((F=s.bootstrap)===null||F===void 0||(k=F.featureFlags)===null||k===void 0||!k[E])}).reduce(function(E,F){var k,w;return E[F]=((k=s.bootstrap)===null||k===void 0||(w=k.featureFlags)===null||w===void 0?void 0:w[F])||!1,E},{}),S=Object.keys(((_=s.bootstrap)===null||_===void 0?void 0:_.featureFlagPayloads)||{}).filter(function(E){return v[E]}).reduce(function(E,F){var k,w,L,A;return(k=s.bootstrap)!==null&&k!==void 0&&(w=k.featureFlagPayloads)!==null&&w!==void 0&&w[F]&&(E[F]=(L=s.bootstrap)===null||L===void 0||(A=L.featureFlagPayloads)===null||A===void 0?void 0:A[F]),E},{});this.featureFlags.receivedFeatureFlags({featureFlags:v,featureFlagPayloads:S})}if(!this.get_distinct_id()){var P=this.config.get_device_id(Ze());this.register_once({distinct_id:P,$device_id:P},""),this.persistence.set_property(ze,"anonymous")}return p==null||(i=p.addEventListener)===null||i===void 0||i.call(p,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this)),this.toolbar.maybeLoadToolbar(),s.segment?el(this,function(){return r._loaded()}):this._loaded(),Re(this.config._onCapture)&&this.on("eventCaptured",function(E){return r.config._onCapture(E.event,E)}),this}},{key:"_afterDecideResponse",value:function(e){var t,i,r,s,o,a,u,l;this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=U(e.supportedCompression,Ne.GZipJS)?Ne.GZipJS:U(e.supportedCompression,Ne.Base64)?Ne.Base64:void 0),(t=e.analytics)!==null&&t!==void 0&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),(i=this.sessionRecording)===null||i===void 0||i.afterDecideResponse(e),(r=this.autocapture)===null||r===void 0||r.afterDecideResponse(e),(s=this.heatmaps)===null||s===void 0||s.afterDecideResponse(e),(o=this.surveys)===null||o===void 0||o.afterDecideResponse(e),(a=this.webVitalsAutocapture)===null||a===void 0||a.afterDecideResponse(e),(u=this.exceptions)===null||u===void 0||u.afterDecideResponse(e),(l=this.exceptionObserver)===null||l===void 0||l.afterDecideResponse(e)}},{key:"_loaded",value:function(){var e=this,t=this.config.advanced_disable_decide;t||this.featureFlags.setReloadingPaused(!0);try{this.config.loaded(this)}catch(i){b.critical("`loaded` function failed",i)}this._start_queue_if_opted_in(),this.config.capture_pageview&&setTimeout(function(){e.consent.isOptedIn()&&e._captureInitialPageview()},1),t||(new Au(this).call(),this.featureFlags.resetRequestQueue())}},{key:"_start_queue_if_opted_in",value:function(){var e;this.has_opted_out_capturing()||this.config.request_batching&&((e=this._requestQueue)===null||e===void 0||e.enable())}},{key:"_dom_loaded",value:function(){var e=this;this.has_opted_out_capturing()||xt(this.__request_queue,function(t){return e._send_retriable_request(t)}),this.__request_queue=[],this._start_queue_if_opted_in()}},{key:"_handle_unload",value:function(){var e,t;this.config.request_batching?(this._shouldCapturePageleave()&&this.capture("$pageleave"),(e=this._requestQueue)===null||e===void 0||e.unload(),(t=this._retryQueue)===null||t===void 0||t.unload()):this._shouldCapturePageleave()&&this.capture("$pageleave",null,{transport:"sendBeacon"})}},{key:"_send_request",value:function(e){var t=this;this.__loaded&&(Oo?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=Xn(e.url,{ip:this.config.ip?1:0}),e.headers=I({},this.config.request_headers),e.compression=e.compression==="best-available"?this.compression:e.compression,function(i){var r,s,o,a=I({},i);a.timeout=a.timeout||6e4,a.url=Xn(a.url,{_:new Date().getTime().toString(),ver:$e.LIB_VERSION,compression:a.compression});var u=(r=a.transport)!==null&&r!==void 0?r:"XHR",l=(s=(o=fs(un,function(c){return c.transport===u}))===null||o===void 0?void 0:o.method)!==null&&s!==void 0?s:un[0].method;if(!l)throw new Error("No available transport method");l(a)}(I(I({},e),{},{callback:function(i){var r,s,o;t.rateLimiter.checkForLimiting(i),i.statusCode>=400&&((s=(o=t.config).on_request_error)===null||s===void 0||s.call(o,i)),(r=e.callback)===null||r===void 0||r.call(e,i)}}))))}},{key:"_send_retriable_request",value:function(e){this._retryQueue?this._retryQueue.retriableRequest(e):this._send_request(e)}},{key:"_execute_array",value:function(e){var t,i=this,r=[],s=[],o=[];xt(e,function(u){u&&(t=u[0],ae(t)?o.push(u):Re(u)?u.call(i):ae(u)&&t==="alias"?r.push(u):ae(u)&&t.indexOf("capture")!==-1&&Re(i[t])?o.push(u):s.push(u))});var a=function(u,l){xt(u,function(c){if(ae(c[0])){var d=l;X(c,function(h){d=d[h[0]].apply(d,h.slice(1))})}else this[c[0]].apply(this,c.slice(1))},l)};a(r,this),a(s,this),a(o,this)}},{key:"_hasBootstrappedFeatureFlags",value:function(){var e,t;return((e=this.config.bootstrap)===null||e===void 0?void 0:e.featureFlags)&&Object.keys((t=this.config.bootstrap)===null||t===void 0?void 0:t.featureFlags).length>0||!1}},{key:"push",value:function(e){this._execute_array([e])}},{key:"capture",value:function(e,t,i){var r;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this._requestQueue){if(!this.consent.isOptedOut())if(!O(e)&&ve(e)){if(this.config.opt_out_useragent_filter||!this._is_bot()){var s=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(s==null||!s.isRateLimited){this.sessionPersistence.update_search_keyword(),this.config.store_google&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.store_google||this.config.save_referrer)&&this.persistence.set_initial_person_info();var o=new Date,a=(i==null?void 0:i.timestamp)||o,u={uuid:Ze(),event:e,properties:this._calculate_event_properties(e,t||{},a)};s&&(u.properties.$lib_rate_limit_remaining_tokens=s.remainingTokens),i!=null&&i.$set&&(u.$set=i==null?void 0:i.$set);var l=this._calculate_set_once_properties(i==null?void 0:i.$set_once);l&&(u.$set_once=l),(u=Va(u,i!=null&&i._noTruncate?null:this.config.properties_string_max_length)).timestamp=a,O(i==null?void 0:i.timestamp)||(u.properties.$event_time_override_provided=!0,u.properties.$event_time_override_system_time=o);var c=I(I({},u.properties.$set),u.$set);Rn(c)||this.setPersonPropertiesForFlags(c),this._internalEventEmitter.emit("eventCaptured",u);var d={method:"POST",url:(r=i==null?void 0:i._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:u,compression:"best-available",batchKey:i==null?void 0:i._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this._send_retriable_request(d):this._requestQueue.enqueue(d),u}b.critical("This capture call is ignored due to client rate limiting.")}}else b.error("No event name provided to posthog.capture")}else b.uninitializedWarning("posthog.capture")}},{key:"_addCaptureHook",value:function(e){this.on("eventCaptured",function(t){return e(t.event,t)})}},{key:"_calculate_event_properties",value:function(e,t,i){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var r=this.persistence.remove_event_timer(e),s=I({},t);if(s.token=this.config.token,e==="$snapshot"){var o=I(I({},this.persistence.properties()),this.sessionPersistence.properties());return s.distinct_id=o.distinct_id,(!ve(s.distinct_id)&&!Fe(s.distinct_id)||rs(s.distinct_id))&&b.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),s}var a=ce.properties();if(this.sessionManager){var u=this.sessionManager.checkAndGetSessionAndWindowId(),l=u.sessionId,c=u.windowId;s.$session_id=l,s.$window_id=c}if(this.requestRouter.region===ht.CUSTOM&&(s.$lib_custom_api_host=this.config.api_host),this.sessionPropsManager&&this.config.__preview_send_client_session_params&&(e==="$pageview"||e==="$pageleave"||e==="$autocapture")){var d=this.sessionPropsManager.getSessionProps();s=_e(s,d)}if(!this.config.disable_scroll_properties){var h={};e==="$pageview"?h=this.pageViewManager.doPageView(i):e==="$pageleave"&&(h=this.pageViewManager.doPageLeave(i)),s=_e(s,h)}if(e==="$pageview"&&$&&(s.title=$.title),!O(r)){var f=i.getTime()-r;s.$duration=parseFloat((f/1e3).toFixed(3))}le&&this.config.opt_out_useragent_filter&&(s.$browser_type=this._is_bot()?"bot":"browser"),(s=_e({},a,this.persistence.properties(),this.sessionPersistence.properties(),s)).$is_identified=this._isIdentified(),ae(this.config.property_denylist)?X(this.config.property_denylist,function(v){delete s[v]}):b.error("Invalid value for property_denylist config: "+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var _=this.config.sanitize_properties;return _&&(s=_(s,e)),s.$process_person_profile=this._hasPersonProcessing(),s}},{key:"_calculate_set_once_properties",value:function(e){if(!this.persistence||!this._hasPersonProcessing())return e;var t=_e({},this.persistence.get_initial_props(),e||{});return Rn(t)?void 0:t}},{key:"register",value:function(e,t){var i;(i=this.persistence)===null||i===void 0||i.register(e,t)}},{key:"register_once",value:function(e,t,i){var r;(r=this.persistence)===null||r===void 0||r.register_once(e,t,i)}},{key:"register_for_session",value:function(e){var t;(t=this.sessionPersistence)===null||t===void 0||t.register(e)}},{key:"unregister",value:function(e){var t;(t=this.persistence)===null||t===void 0||t.unregister(e)}},{key:"unregister_for_session",value:function(e){var t;(t=this.sessionPersistence)===null||t===void 0||t.unregister(e)}},{key:"_register_single",value:function(e,t){this.register(m({},e,t))}},{key:"getFeatureFlag",value:function(e,t){return this.featureFlags.getFeatureFlag(e,t)}},{key:"getFeatureFlagPayload",value:function(e){var t=this.featureFlags.getFeatureFlagPayload(e);try{return JSON.parse(t)}catch{return t}}},{key:"isFeatureEnabled",value:function(e,t){return this.featureFlags.isFeatureEnabled(e,t)}},{key:"reloadFeatureFlags",value:function(){this.featureFlags.reloadFeatureFlags()}},{key:"updateEarlyAccessFeatureEnrollment",value:function(e,t){this.featureFlags.updateEarlyAccessFeatureEnrollment(e,t)}},{key:"getEarlyAccessFeatures",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];return this.featureFlags.getEarlyAccessFeatures(e,t)}},{key:"on",value:function(e,t){return this._internalEventEmitter.on(e,t)}},{key:"onFeatureFlags",value:function(e){return this.featureFlags.onFeatureFlags(e)}},{key:"onSessionId",value:function(e){var t,i;return(t=(i=this.sessionManager)===null||i===void 0?void 0:i.onSessionId(e))!==null&&t!==void 0?t:function(){}}},{key:"getSurveys",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getSurveys(e,t)}},{key:"getActiveMatchingSurveys",value:function(e){var t=arguments.length>1&&arguments[1]!==void 0&&arguments[1];this.surveys.getActiveMatchingSurveys(e,t)}},{key:"renderSurvey",value:function(e,t){this.surveys.renderSurvey(e,t)}},{key:"canRenderSurvey",value:function(e){this.surveys.canRenderSurvey(e)}},{key:"getNextSurveyStep",value:function(e,t,i){return this.surveys.getNextSurveyStep(e,t,i)}},{key:"identify",value:function(e,t,i){if(!this.__loaded||!this.persistence)return b.uninitializedWarning("posthog.identify");if(Fe(e)&&(e=e.toString(),b.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()))b.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 s=r;this.register_once({$had_persisted_distinct_id:!0,$device_id:s},"")}e!==r&&e!==this.get_property(Jt)&&(this.unregister(Jt),this.register({distinct_id:e}));var o=(this.persistence.get_property(ze)||"anonymous")==="anonymous";e!==r&&o?(this.persistence.set_property(ze,"identified"),this.setPersonPropertiesForFlags(t||{},!1),this.capture("$identify",{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.featureFlags.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(Mn))}}else b.error("Unique user id has not been set in posthog.identify")}},{key:"setPersonProperties",value:function(e,t){(e||t)&&this._requirePersonProcessing("posthog.setPersonProperties")&&(this.setPersonPropertiesForFlags(e||{}),this.capture("$set",{$set:e||{},$set_once:t||{}}))}},{key:"group",value:function(e,t,i){if(e&&t){if(this._requirePersonProcessing("posthog.group")){var r=this.getGroups();r[e]!==t&&this.resetGroupPropertiesForFlags(e),this.register({$groups:I(I({},r),{},m({},e,t))}),i&&(this.capture("$groupidentify",{$group_type:e,$group_key:t,$group_set:i}),this.setGroupPropertiesForFlags(m({},e,i))),r[e]===t||i||this.reloadFeatureFlags()}}else b.error("posthog.group requires a group type and group key")}},{key:"resetGroups",value:function(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}},{key:"setPersonPropertiesForFlags",value:function(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setPersonPropertiesForFlags")&&this.featureFlags.setPersonPropertiesForFlags(e,t)}},{key:"resetPersonPropertiesForFlags",value:function(){this.featureFlags.resetPersonPropertiesForFlags()}},{key:"setGroupPropertiesForFlags",value:function(e){var t=!(arguments.length>1&&arguments[1]!==void 0)||arguments[1];this._requirePersonProcessing("posthog.setGroupPropertiesForFlags")&&this.featureFlags.setGroupPropertiesForFlags(e,t)}},{key:"resetGroupPropertiesForFlags",value:function(e){this.featureFlags.resetGroupPropertiesForFlags(e)}},{key:"reset",value:function(e){var t,i,r,s;if(b.info("reset"),!this.__loaded)return b.uninitializedWarning("posthog.reset");var o=this.get_property("$device_id");this.consent.reset(),(t=this.persistence)===null||t===void 0||t.clear(),(i=this.sessionPersistence)===null||i===void 0||i.clear(),(r=this.persistence)===null||r===void 0||r.set_property(ze,"anonymous"),(s=this.sessionManager)===null||s===void 0||s.resetSessionId();var a=this.config.get_device_id(Ze());this.register_once({distinct_id:a,$device_id:e?a:o},"")}},{key:"get_distinct_id",value:function(){return this.get_property("distinct_id")}},{key:"getGroups",value:function(){return this.get_property("$groups")||{}}},{key:"get_session_id",value:function(){var e,t;return(e=(t=this.sessionManager)===null||t===void 0?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}},{key:"get_session_replay_url",value:function(e){if(!this.sessionManager)return"";var t=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=t.sessionId,r=t.sessionStartTimestamp,s=this.requestRouter.endpointFor("ui","/project/".concat(this.config.token,"/replay/").concat(i));if(e!=null&&e.withTimestamp&&r){var o,a=(o=e.timestampLookBack)!==null&&o!==void 0?o:10;if(!r)return s;var u=Math.max(Math.floor((new Date().getTime()-r)/1e3)-a,0);s+="?t=".concat(u)}return s}},{key:"alias",value:function(e,t){return e===this.get_property(hs)?(b.critical("Attempting to create alias for existing People user - aborting."),-2):this._requirePersonProcessing("posthog.alias")?(O(t)&&(t=this.get_distinct_id()),e!==t?(this._register_single(Jt,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(b.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}},{key:"set_config",value:function(e){var t,i,r,s,o=I({},this.config);fe(e)&&(_e(this.config,Co(e)),(t=this.persistence)===null||t===void 0||t.update_config(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"?this.persistence:new Gi(I(I({},this.config),{},{persistence:"sessionStorage"})),ue.is_supported()&&ue.get("ph_debug")==="true"&&(this.config.debug=!0),this.config.debug&&($e.DEBUG=!0,b.info("set_config",{config:e,oldConfig:o,newConfig:I({},this.config)})),(i=this.sessionRecording)===null||i===void 0||i.startIfEnabledOrStop(),(r=this.autocapture)===null||r===void 0||r.startIfEnabled(),(s=this.heatmaps)===null||s===void 0||s.startIfEnabled(),this.surveys.loadIfEnabled(),this._sync_opt_out_with_persistence())}},{key:"startSessionRecording",value:function(e){var t,i=lt(e)&&e;if(i||e!=null&&e.sampling){var r,s,o=(r=this.sessionManager)===null||r===void 0?void 0:r.checkAndGetSessionAndWindowId();(s=this.persistence)===null||s===void 0||s.register(m({},Xt,!0)),b.info("Session recording started with sampling override for session: ",o==null?void 0:o.sessionId)}(i||e!=null&&e.linked_flag)&&((t=this.sessionRecording)===null||t===void 0||t.overrideLinkedFlag(),b.info("Session recording started with linked_flags override")),this.set_config({disable_session_recording:!1})}},{key:"stopSessionRecording",value:function(){this.set_config({disable_session_recording:!0})}},{key:"sessionRecordingStarted",value:function(){var e;return!((e=this.sessionRecording)===null||e===void 0||!e.started)}},{key:"captureException",value:function(e,t){var i=Re(Z.parseErrorAsProperties)?Z.parseErrorAsProperties([e.message,void 0,void 0,void 0,e]):I({$exception_type:e.name,$exception_message:e.message,$exception_level:"error"},t);this.exceptions.sendExceptionEvent(i)}},{key:"loadToolbar",value:function(e){return this.toolbar.loadToolbar(e)}},{key:"get_property",value:function(e){var t;return(t=this.persistence)===null||t===void 0?void 0:t.props[e]}},{key:"getSessionProperty",value:function(e){var t;return(t=this.sessionPersistence)===null||t===void 0?void 0:t.props[e]}},{key:"toString",value:function(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Mt;return t!==Mt&&(t=Mt+"."+t),t}},{key:"_isIdentified",value:function(){var e,t;return((e=this.persistence)===null||e===void 0?void 0:e.get_property(ze))==="identified"||((t=this.sessionPersistence)===null||t===void 0?void 0:t.get_property(ze))==="identified"}},{key:"_hasPersonProcessing",value:function(){var e,t,i,r;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&Rn(this.getGroups())&&((e=this.persistence)===null||e===void 0||(t=e.props)===null||t===void 0||!t[Jt])&&((i=this.persistence)===null||i===void 0||(r=i.props)===null||r===void 0||!r[Nn]))}},{key:"_shouldCapturePageleave",value:function(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&this.config.capture_pageview}},{key:"createPersonProfile",value:function(){this._hasPersonProcessing()||this._requirePersonProcessing("posthog.createPersonProfile")&&this.setPersonProperties({},{})}},{key:"_requirePersonProcessing",value:function(e){return this.config.person_profiles==="never"?(b.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this._register_single(Nn,!0),!0)}},{key:"_sync_opt_out_with_persistence",value:function(){var e,t,i,r,s=this.consent.isOptedOut(),o=this.config.opt_out_persistence_by_default,a=this.config.disable_persistence||s&&!!o;((e=this.persistence)===null||e===void 0?void 0:e.disabled)!==a&&((i=this.persistence)===null||i===void 0||i.set_disabled(a)),((t=this.sessionPersistence)===null||t===void 0?void 0:t.disabled)!==a&&((r=this.sessionPersistence)===null||r===void 0||r.set_disabled(a))}},{key:"opt_in_capturing",value:function(e){var t;this.consent.optInOut(!0),this._sync_opt_out_with_persistence(),(O(e==null?void 0:e.captureEventName)||e!=null&&e.captureEventName)&&this.capture((t=e==null?void 0:e.captureEventName)!==null&&t!==void 0?t:"$opt_in",e==null?void 0:e.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this._captureInitialPageview()}},{key:"opt_out_capturing",value:function(){this.consent.optInOut(!1),this._sync_opt_out_with_persistence()}},{key:"has_opted_in_capturing",value:function(){return this.consent.isOptedIn()}},{key:"has_opted_out_capturing",value:function(){return this.consent.isOptedOut()}},{key:"clear_opt_in_out_capturing",value:function(){this.consent.reset(),this._sync_opt_out_with_persistence()}},{key:"_is_bot",value:function(){return Me?function(e,t){if(!e)return!1;var i=e.userAgent;if(i&&Eo(i,t))return!0;try{var r=e==null?void 0:e.userAgentData;if(r!=null&&r.brands&&r.brands.some(function(s){return Eo(s==null?void 0:s.brand,t)}))return!0}catch{}return!!e.webdriver}(Me,this.config.custom_blocked_useragents):void 0}},{key:"_captureInitialPageview",value:function(){$&&!this._initialPageviewCaptured&&(this._initialPageviewCaptured=!0,this.capture("$pageview",{title:$.title},{send_instantly:!0}))}},{key:"debug",value:function(e){e===!1?(p==null||p.console.log("You've disabled debug mode."),localStorage&&localStorage.removeItem("ph_debug"),this.set_config({debug:!1})):(p==null||p.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}))}}]),n}();(function(n,e){for(var t=0;t{it.init(n.token,e)},reset:()=>{it.reset()},track:({payload:t})=>{t.properties?it.capture(t.event,t.properties):it.capture(t.event)},identify:({payload:t})=>{t.userId&&(it.identify(t.userId,t.traits),it.alias(t.anonymousId,t.userId))},page:()=>{},methods:{abtest:t=>it.getFeatureFlag(t),abtestOverride:t=>it.featureFlags.override(t)}}}const yl=Object.freeze(Object.defineProperty({__proto__:null,default:ml},Symbol.toStringTag,{value:"Module"}));return Aa});