@deriv-com/analytics 1.41.0 → 1.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser/analytics.bundle.global.js +5 -5
- package/dist/browser/analytics.bundle.global.js.map +1 -1
- package/dist/browser/analytics.esm.mjs +1 -1
- package/dist/browser/analytics.esm.mjs.map +1 -1
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/metafile-iife.json +1 -1
- package/dist/posthog-AGNFJC2G.mjs +4 -0
- package/dist/posthog-AGNFJC2G.mjs.map +1 -0
- package/dist/{posthog-DYLYirAm.d.mts → posthog-ctBaPjWr.d.mts} +1 -1
- package/dist/{posthog-DYLYirAm.d.ts → posthog-ctBaPjWr.d.ts} +1 -1
- package/dist/providers/posthog/index.d.mts +1 -1
- package/dist/providers/posthog/index.d.ts +1 -1
- package/dist/providers/posthog/index.js +1 -1
- package/dist/providers/posthog/index.js.map +1 -1
- package/dist/providers/posthog/index.mjs +1 -1
- package/dist/providers/posthog/index.mjs.map +1 -1
- package/package.json +5 -5
- package/dist/posthog-4QHY3J66.mjs +0 -4
- package/dist/posthog-4QHY3J66.mjs.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/* @deriv-com/analytics - Browser IIFE Bundle (RudderStack + PostHog) - Built with tsup */
|
|
2
|
-
"use strict";var DerivAnalytics=(()=>{var
|
|
3
|
-
`);return e.some(t=>Au.test(t))?e.map(mv).filter(t=>t!==null):e.map(yv).filter(t=>t!==null)}function $l(s,e,t,i){return{errorClass:Ll(s),message:`${t}${Ll(e)}`,type:"browserjs",stacktrace:i.reduce((r,n)=>{let o=Sv(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function Fu(s,e){let t=Object.assign(s,e);for(let i of Object.keys(t))typeof t[i]=="object"&&typeof e[i]=="object"&&(t[i]=Fu(t[i],e[i]));return t}async function o_(s){let e=r_[s];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((t,i)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=n_();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}t(e.lib)}).catch(i)})})}function Me(s,e){if(!s?.default&&e){let t=Object.create(null);return t.default=s,t.__esModule=!0,t}return s}function Ue(s,e){return o_(s).then(t=>t.get(e).then(i=>i()))}function $_(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function M_(){return Hl||(Hl=1,(function(s,e){(function(t,i){s.exports=i()})(F_,function(){function t(g){return g=JSON.stringify(g),!!/^\{[\s\S]*\}$/.test(g)}function i(g){return g===void 0||typeof g=="function"?g+"":JSON.stringify(g)}function r(g){if(typeof g=="string")try{return JSON.parse(g)}catch{return g}}function n(g){return{}.toString.call(g)==="[object Function]"}function o(g){return Object.prototype.toString.call(g)==="[object Array]"}function a(g){var p="_Is_Incognit",v="yes";try{g||(g=window.localStorage),g.setItem(p,v),g.removeItem(p)}catch{var m={};m._data={},m.setItem=function(k,D){return m._data[k]=String(D)},m.getItem=function(k){return m._data.hasOwnProperty(k)?m._data[k]:void 0},m.removeItem=function(k){return delete m._data[k]},m.clear=function(){return m._data={}},g=m}finally{g.getItem(p)===v&&g.removeItem(p)}return g}var l=a();function u(){if(!(this instanceof u))return new u}u.prototype={set:function(p,v){if(p&&!t(p))l.setItem(p,i(v));else if(t(p))for(var m in p)this.set(m,p[m]);return this},get:function(p){if(p===void 0){var v={};return this.forEach(function(O,C){return v[O]=C}),v}if(p.charAt(0)==="?")return this.has(p.substr(1));var m=arguments;if(m.length>1){for(var b={},k=0,D=m.length;k<D;k++){var N=r(l.getItem(m[k]));this.has(m[k])&&(b[m[k]]=N)}return b}return r(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var v=this.get(p);return l.removeItem(p),v},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(v){p.push(v)}),p},forEach:function(p){for(var v=0,m=l.length;v<m;v++){var b=l.key(v);p(b,this.get(b))}return this},search:function(p){for(var v=this.keys(),m={},b=0,k=v.length;b<k;b++)v[b].indexOf(p)>-1&&(m[v[b]]=this.get(v[b]));return m},len:function(){return l.length}};var d=null;function h(g,p){var v=arguments,m=null;if(d||(d=u()),v.length===0)return d.get();if(v.length===1){if(typeof g=="string")return d.get(g);if(t(g))return d.set(g)}if(v.length===2&&typeof g=="string"){if(!p)return d.remove(g);if(p&&typeof p=="string")return d.set(g,p);p&&n(p)&&(m=null,m=p(g,d.get(g)),h.set(g,m))}if(v.length===2&&o(g)&&n(p))for(var b=0,k=g.length;b<k;b++)m=p(g[b],d.get(g[b])),h.set(g[b],m);return h}for(var f in u.prototype)h[f]=u.prototype[f];return h})})(Vi)),Vi.exports}var Ig,Og,Ng,K,Lg,$g,Fg,Mg,tu,x,re,Ve,Re,tt,Ug,ee,us,Bg,so,Vg,Rn,Gg,Hg,jg,ne,zg,we,yt,Vs,Hi,ft,nt,io,Kg,bl,ji,qg,Wg,zi,ro,su,iu,ru,_n,no,An,Ye,nu,Us,Gt,Gs,ns,Yg,mn,Xg,Jg,Qg,xi,El,Fi,Pt,yn,zt,Mi,Li,sf,Qi,rf,nf,of,ou,af,B,lf,Sl,uf,cf,df,hf,gf,ff,pf,au,vf,et,_f,lu,Y,uu,Zi,oo,fe,kl,Ks,mf,cu,yf,wl,bf,Ef,js,Sf,kf,wf,Tl,Tf,Rl,Rf,Af,Al,In,Il,If,Of,du,qs,hu,Ol,Cf,Df,Nf,xf,Lf,$f,Ff,Mf,Uf,Bf,Ki,Vf,J,zs,mt,qi,Gf,On,Wi,Yi,Pn,$i,Pl,yu,jf,zf,Kf,Cn,bt,pt,bu,Dn,Cl,qf,Wf,Yf,Xf,Jf,Qf,Zf,ep,Dl,tp,sp,ip,rp,np,op,ap,Nl,lp,up,Eu,cp,dp,hp,gp,fp,pp,vp,xl,_p,mp,yp,bp,Ep,Sp,kp,wp,Tp,Rp,Ap,Ip,Op,Pp,Cp,Dp,Np,xp,Lp,$p,Fp,Mp,Up,Bp,Vp,Gp,Hp,Su,tr,ku,jp,Ws,sr,lo,wu,Tu,Ru,Ht,zp,Nn,Ui,Kp,qp,Wp,Yp,Xp,Jp,Q,bn,Qp,Zp,ev,tv,sv,iv,rv,nv,ov,av,lv,uv,cv,dv,hv,gv,fv,pv,c,Au,vv,_v,Ou,Ev,Sv,Ll,Pu,kv,Fl,Bi,wv,Tv,Rv,Av,Iv,Ov,Pv,Cv,Ml,Ul,xn,Cu,Dv,Nv,xv,Lv,$v,Fv,Mv,Du,Uv,Bv,Vv,Gv,Hv,jv,zv,Kv,qv,Wv,Nu,xu,Yv,Xv,Jv,Qv,Ln,Lu,$n,Zv,e_,t_,Bl,s_,$u,i_,r_,n_,a_,l_,Mu,u_,c_,En,d_,Fn,Be,He,We,ot,Kt,h_,g_,f_,p_,v_,__,m_,y_,b_,E_,S_,k_,os,w_,Uu,Bu,T_,Vu,Gu,as,Vl,Gl,R_,A_,Mn,I_,vt,O_,P_,C_,D_,N_,x_,L_,Un,Xi,Vi,F_,Hl,U_,Vt,Hu,ls,Bn,uo,Vn,co,Gn,ho,Ze,B_,V_,G_,H_,j_,Hn,z_,jn,K_,q_,ju,W_,Y_,X_,cs,zn,zu,J_,Q_,Z_,ds,Sn,kn,em,tm,sm,jl,im,Ku,rm,nm,om,am,lm,um,cm,dm,hm,qu,gm,fm,Kn,pm,Wu,vm,_m,mm,Yu,ym,bm,qn,Em,Sm,km,wm,zl,Tm,Kl,Rm,ql,Wn,Am,Im,Wl,wn,Xu,Om,Ji,Yl,Ju,Xl,Pm,Cm,Dm,Nm,xm,Hs,Yn,Lm,$m,Fm,Tn,Mm,Um,Bm,Vm,Gm,Bs,Xn,Jn,Qn,Hm,jm,zm,Jl,Ql,Km,qm,Wm,Ym,Gi,Zn,Zl,Xm,Jm,eo,jt,hs,go=Fe(()=>{"use strict";Ig=_t(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Og=Number.isInteger||function(e){return e<<0===e};Ng=(function(){function s(){this.map={},this.length=0}return s.prototype.set=function(e,t){var i=this.hash(e),r=this.map[i];r||(this.map[i]=r=[]),r.push([e,t]),this.length+=1},s.prototype.hash=function(e){var t=[];for(var i in e)t.push(Object.prototype.toString.call(e[i]));return t.join()},s.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var o=this.map[t],i=0;i<o.length;i+=1){var r=o[i];if(r[0]===e)return r[1]}return}var n=this.hash(e),o=this.map[n];if(o)for(var i=0;i<o.length;i+=1){var r=o[i];if(r[0]===e)return r[1]}},s})(),K=_t(function(e){return e!=null&&typeof e.clone=="function"?e.clone():eu(e)});Lg=to(function(e,t,i){var r={},n;t=t||{},i=i||{};for(n in t)Ni(n,t)&&(r[n]=Ni(n,i)?e(n,t[n],i[n]):t[n]);for(n in i)Ni(n,i)&&!Ni(n,r)&&(r[n]=i[n]);return r}),$g=to(function s(e,t,i){return Lg(function(r,n,o){return yl(n)&&yl(o)?s(e,n,o):e(r,n,o)},t,i)}),Fg=to(function(e,t,i){return $g(function(r,n,o){return e(n,o)},t,i)}),Mg=Ot(xg),tu=Ot(function(e,t){var i={};for(var r in t)e(t[r],r,t)&&(i[r]=t[r]);return i}),x=s=>typeof s=="function"&&!!(s.constructor&&s.call&&s.apply),re=s=>typeof s=="string",Ve=s=>s===null,Re=s=>typeof s>"u",tt=s=>Ve(s)||Re(s),Ug=s=>typeof s=="bigint",ee=s=>!Re(s),us=s=>!tt(s),Bg=s=>us(s)&&s!=="",so=s=>{switch(Object.prototype.toString.call(s)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return s instanceof Error}},Vg=s=>typeof s=="boolean",Rn=(s,e)=>{let t=e.split(".");return Mg(t,s)},Gg=(s,e)=>!!Rn(s,e),Hg=s=>typeof s=="object",jg=s=>!Ve(s)&&Hg(s)&&!Array.isArray(s),ne=s=>!Ve(s)&&Object.prototype.toString.call(s)==="[object Object]",zg=(s,e)=>{if(!Array.isArray(s)||!Array.isArray(e))return K(e);let t=K(s);return e.forEach((i,r)=>{t[r]=Array.isArray(i)||jg(i)?we(t[r],i):i}),t},we=(s,e)=>Fg(zg,s,e),yt=s=>ne(s)&&Object.keys(s).length>0,Vs=s=>{let e=tu(ee,s);return Object.keys(e).forEach(t=>{let i=e[t];ne(i)&&(e[t]=Vs(i))}),e},Hi=s=>{let e=tu(us,s);return Object.keys(e).forEach(t=>{let i=e[t];ne(i)&&(e[t]=Hi(i))}),e},ft=s=>{if(yt(s))return Hi(s)},nt=(s,e)=>typeof s=="boolean"?s:e,io=s=>(Object.getOwnPropertyNames(s).forEach(function(e){s[e]&&typeof s[e]=="object"&&io(s[e])}),Object.freeze(s)),Kg=s=>s.replace(/^\s+|\s+$/gm,""),bl=s=>s.replace(/^\.+/,""),ji=s=>{let e=s;if(!re(s)&&!tt(s))try{e=JSON.stringify(s)}catch{e=null}return e},qg=s=>{let e=Array.from(s,t=>String.fromCodePoint(t)).join("");return globalThis.btoa(e)},Wg=s=>qg(new TextEncoder().encode(s)),zi=(s,e,t,i,r)=>{let n={category:s,name:e,properties:t,options:i,callback:void 0};x(r)&&(n.callback=r),x(i)&&(n.category=s,n.name=e,n.properties=t,n.options=void 0,n.callback=i),x(t)&&(n.category=s,n.name=e,n.properties=void 0,n.options=void 0,n.callback=t),x(e)&&(n.category=s,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),x(s)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=s),ne(s)?(n.name=void 0,n.category=void 0,n.properties=s,x(e)?n.options=void 0:n.options=e):ne(e)&&(n.name=void 0,n.properties=e,x(t)?n.options=void 0:n.options=t),re(s)&&!re(e)&&(n.category=void 0,n.name=s),ee(n.category)||(n.category=void 0),ee(n.name)||(n.name=void 0),n.properties=n.properties?K(n.properties):{},ee(n.options)?n.options=K(n.options):n.options=void 0;let o=re(n.name)?n.name:n.properties.name,a=re(n.category)?n.category:n.properties.category;return n.properties=we(ne(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},ro=(s,e,t,i)=>{let r={name:s,properties:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.properties=e,r.options=void 0,r.callback=t),x(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=us(r.properties)?K(r.properties):{},ee(r.options)?r.options=K(r.options):r.options=void 0,r},su=(s,e,t,i)=>{let r={userId:s,traits:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.userId=s,r.traits=e,r.options=void 0,r.callback=t),x(e)&&(r.userId=s,r.traits=void 0,r.options=void 0,r.callback=e),(ne(s)||Ve(s))&&(r.userId=null,r.traits=s,x(e)?r.options=void 0:r.options=e),r.userId=ji(r.userId),ne(r.traits)?r.traits=K(r.traits):r.traits=void 0,ee(r.options)?r.options=K(r.options):r.options=void 0,r},iu=(s,e,t,i)=>{let r={to:s,from:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.to=s,r.from=e,r.options=void 0,r.callback=t),x(e)?(r.to=s,r.from=void 0,r.options=void 0,r.callback=e):(ne(e)||Ve(e))&&(r.to=s,r.from=void 0,r.options=e),ee(r.to)&&(r.to=ji(r.to)),ee(r.from)?r.from=ji(r.from):r.from=void 0,ee(r.options)?r.options=K(r.options):r.options=void 0,r},ru=(s,e,t,i)=>{let r={groupId:s,traits:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.groupId=s,r.traits=e,r.options=void 0,r.callback=t),x(e)&&(r.groupId=s,r.traits=void 0,r.options=void 0,r.callback=e),(ne(s)||Ve(s))&&(r.groupId=null,r.traits=s,x(e)?r.options=void 0:r.options=e),r.groupId=ji(r.groupId),ne(r.traits)?r.traits=K(r.traits):r.traits=void 0,ee(r.options)?r.options=K(r.options):r.options=void 0,r},_n=(function(s){return s.UNLOADED="Page Unloaded",s})({}),no="API",An="CapabilitiesManager",Ye="ConfigManager",nu="EventManager",Us="PluginsManager",Gt="UserSessionManager",Gs="ErrorHandler",ns="PluginEngine",Yg="StoreManager",mn=`Ready${no}`,Xg=`Load${no}`,Jg="HttpClient",Qg="RudderStackAnalytics",xi="AnalyticsCore";El=4096,Fi=[],Pt=0;for(;Pt<256;Pt++)Fi[Pt]=(Pt+256).toString(16).substring(1);zt=256,Mi=[];for(;zt--;)Mi[zt]=(zt+256).toString(16).substring(1);sf=()=>!tt(globalThis.crypto)&&x(globalThis.crypto.getRandomValues),Qi=()=>sf()?ef():tf(),rf=()=>!!window.chrome?.runtime?.id,nf=()=>re(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),of=(s,e=!1)=>{let t=!1,i=!1;function r(){t||(t=!0,s(i),setTimeout(()=>{t=!1},0))}(e||nf())&&globalThis.addEventListener("beforeunload",()=>{i=!1,r()}),globalThis.addEventListener("blur",()=>{i=!0,r()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?r():t=!1})},ou=s=>s.toISOString(),af=()=>ou(new Date),B=":: ",lf=s=>`A script with the id "${s}" is already loaded. Skipping the loading of this script to prevent conflicts`,Sl=(s,e,t)=>`Unable to load (${re(t)?t:t.type}) the script with the id "${s}" from URL "${e}"`,uf=(s,e,t)=>`A timeout of ${t} ms occurred while trying to load the script with id "${s}" from URL "${e}"`,cf=(s,e)=>`${s}${B}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,df="Failed to convert the value to a JSON string.",hf="Failed to encode the cookie data.",gf=(s,e)=>`${s}${B}The "${e}" storage type is `,ff="JSONStringify",pf="[BigInt]",au="[Circular Reference]",vf=(s,e,t)=>{let i=[];return function(r,n){if(!e?.includes(r)&&!(s&&tt(n))){if(typeof n!="object"||Ve(n))return n;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(n)?(t?.warn(cf(ff,r)),au):(i.push(n),n)}}},et=(s,e,t,i)=>{try{return JSON.stringify(s,vf(e,t,i))}catch(r){return i?.warn(df,r),null}},_f=s=>{let e=[];return function(i,r){if(Ug(r))return pf;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?au:(e.push(r),r)}},lu=(s,e)=>{let t=Array.isArray(s)?[]:{};for(let i in s)if(Object.hasOwnProperty.call(s,i)){let r=s[i],n=e.call(s,i,r);ne(n)||Array.isArray(n)?t[i]=lu(n,e):t[i]=n}return t},Y=(s,e)=>{let t=_f(),i=t.call(s,"",s);return ne(s)||Array.isArray(s)?lu(s,t):i},uu="[SDK DISPATCHED ERROR]",Zi=s=>{let{stack:e}=s;if(typeof e=="string"&&e)return e},oo=(s,e)=>{if(!so(s))return new Error(`${e}: ${et(s)}`);try{let t=s.constructor,i=new t(`${e}: ${s.message}`),r=Zi(s);return r&&(i.stack=r),Object.getOwnPropertyNames(s).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{i[n]=s[n]}catch{}}),i}catch{return new Error(`${e}: ${et(s)}`)}},fe=s=>{if(so(s)){let e=Zi(s);e&&(s.stack=`${e}
|
|
4
|
-
${uu}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:s,bubbles:!0,cancelable:!0,composed:!0}))},kl="RudderLabs JavaScript SDK",Ks="3.31.0",mf="com.rudderlabs.javascript",cu="npm",yf="modern",wl="RudderJS-Initiated",bf="ad-block page request",Ef="/ad-blocked",js="preloadedEventsBuffer",Sf="Consent Management Interaction",kf="ajs_trait_",wf="ajs_prop_",Tl="ajs_aid",Tf="ajs_uid",Rl="ajs_event",Rf=10*1e3,Af=31536e3*1e3,Al=720*60*1e3,In=1800*1e3,Il=10*1e3,If=10*1e3,Of=250,du=(s="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[s]||(globalThis.RudderStackGlobals[s]={})},qs=(s,e,t="app")=>{du(t),globalThis.RudderStackGlobals[t][s]=e},hu=(s,e="app")=>(du(e),globalThis.RudderStackGlobals[e][s]);Ol=(s,e)=>{let t={};return s.forEach((i,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);t[n]=s.get(r)}}),t},Cf=(s=[])=>{let e={trait:kf,properties:wf},t=new URLSearchParams(globalThis.location.search);t.get(Rl)&&s.unshift(["track",t.get(Rl),Ol(t,e.properties)]);let i=t.get(Tf),r=Ol(t,e.trait);if(i||yt(r)){let n=[...i?[i]:[],r];s.unshift(["identify",...n])}t.get(Tl)&&s.unshift(["setAnonymousId",t.get(Tl)])},Df=s=>{let e="load",t=[],i=0;for(;i<s.length;){if(s[i]&&s[i][0]===e){t=K(s[i]),s.splice(i,1);break}i+=1}return t},Nf=s=>{let e="consent",t=s.filter(r=>r[0]===e),i=s.filter(r=>r[0]!==e);s.splice(0,s.length,...t,...i)},xf=s=>{let e=hu(js)||[];Cf(e),e.length>0&&(s.enqueuePreloadBufferEvents(e),qs(js,[]))},Lf=(s,e)=>{let t=s.shift(),i;if(x(e[t])){switch(t){case"page":i=zi(...s);break;case"track":i=ro(...s);break;case"identify":i=su(...s);break;case"alias":i=iu(...s);break;case"group":i=ru(...s);break;default:e[t](...s);break}i&&e[t](i)}},$f=10*1e3,Ff="RS_JS_SDK",Mf=(s,e,t=!0,i=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=r,o.src=s,o.id=e,o.async=t,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",Ff),o},Uf=s=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(s,e[0]?.firstChild);return}let t=document.getElementsByTagName("script");if(t.length>0&&t[0]?.parentNode){t[0]?.parentNode.insertBefore(s,t[0]);return}let i=document.createElement("head");i.appendChild(s);let r=document.getElementsByTagName("html")[0];r?.insertBefore(i,r.firstChild)},Bf=(s,e,t,i=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(lf(e)));try{let l;Uf(Mf(s,e,i,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(Sl(e,s,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(uf(e,s,t)))},t)}catch(l){o(oo(l,Sl(e,s,"unknown")))}}),Ki=class{constructor(e,t=$f){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:i,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!x(o);Bf(t,i,r||this.timeout,n,a).then(u=>{l||o(u)}).catch(u=>{l||o(i,u)})}},Vf=Symbol.for("preact-signals");J=void 0;zs=void 0,mt=0,qi=0,Gf=0,On=0,Wi=void 0,Yi=0;De.prototype.brand=Vf;De.prototype.h=function(){return!0};De.prototype.S=function(s){var e=this,t=this.t;t!==s&&s.e===void 0&&(s.x=t,this.t=s,t!==void 0?t.e=s:gu(function(){var i;(i=e.W)==null||i.call(e)}))};De.prototype.U=function(s){var e=this;if(this.t!==void 0){var t=s.e,i=s.x;t!==void 0&&(t.x=i,s.e=void 0),i!==void 0&&(i.e=t,s.x=void 0),s===this.t&&(this.t=i,i===void 0&&gu(function(){var r;(r=e.Z)==null||r.call(e)}))}};De.prototype.subscribe=function(s){var e=this;return at(function(){var t=e.value,i=J;J=void 0;try{s(t)}finally{J=i}},{name:"sub"})};De.prototype.valueOf=function(){return this.value};De.prototype.toString=function(){return this.value+""};De.prototype.toJSON=function(){return this.value};De.prototype.peek=function(){var s=J;J=void 0;try{return this.value}finally{J=s}};Object.defineProperty(De.prototype,"value",{get:function(){var s=fu(this);return s!==void 0&&(s.i=this.i),this.v},set:function(s){if(s!==this.v){if(qi>100)throw new Error("Cycle detected");(function(t){mt!==0&&qi===0&&t.l!==On&&(t.l=On,Wi={S:t,v:t.v,i:t.i,o:Wi})})(this),this.v=s,this.i++,Yi++,mt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{er()}}}});gs.prototype=new De;gs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Yi))return!0;if(this.g=Yi,this.f|=1,this.i>0&&!pu(this))return this.f&=-2,!0;var s=J;try{vu(this),J=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return J=s,_u(this),this.f&=-2,!0};gs.prototype.S=function(s){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}De.prototype.S.call(this,s)};gs.prototype.U=function(s){if(this.t!==void 0&&(De.prototype.U.call(this,s),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};gs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var s=this.t;s!==void 0;s=s.x)s.t.N()}};Object.defineProperty(gs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var s=fu(this);if(this.h(),s!==void 0&&(s.i=this.i),16&this.f)throw this.v;return this.v}});fs.prototype.c=function(){var s=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{s()}};fs.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,mu(this),vu(this),mt++;var s=J;return J=this,Hf.bind(this,s)};fs.prototype.N=function(){2&this.f||(this.f|=2,this.u=zs,zs=this)};fs.prototype.d=function(){this.f|=8,1&this.f||ao(this)};fs.prototype.dispose=function(){this.d()};Pn=class{constructor(){this.items=[]}enqueue(e){this.items.push(e)}dequeue(){return this.items.length===0?null:this.items.shift()}isEmpty(){return this.items.length===0}size(){return this.items.length}clear(){this.items=[]}},$i={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Pl="LOG",yu="ERROR",jf="RS SDK",zf="font-weight: bold; background: black; color: white;",Kf="font-weight: normal;",Cn=class{constructor(e=Pl,t="",i=console){this.minLogLevel=$i[e],this.scope=t,this.logProvider=i}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=$i[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=$i[e],Re(this.minLogLevel)&&(this.minLogLevel=$i[Pl])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t=`%c ${jf}`;this.scope&&(t=`${t} - ${this.scope}`);let i=re(e[0])?e[0].trim():"";t=`${t} %c ${i}`;let r=[t,zf,Kf];return re(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},bt=new Cn,pt=(function(s){return s.HANDLEDEXCEPTION="handledException",s.UNHANDLEDEXCEPTION="unhandledException",s.UNHANDLEDREJECTION="unhandledPromiseRejection",s})({}),bu=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Dn="cookieStorage",Cl="Unable to process/parse source configuration response",qf="The source is disabled. Please enable the source in the dashboard to send events.",Wf="Failed to prepare data for the request.",Yf="Failed to invoke plugin because the extension point name is missing.",Xf="Failed to invoke plugin because the extension point name is invalid.",Jf=s=>`${s}${B}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,Qf=(s,e,t)=>`${s}${B}The base URL "${t}" for ${e} is not valid.`,Zf=(s,e,t)=>`${s}${B}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(t)}".`,ep=(s,e)=>`${s}${B}Ignoring a non-error: ${e}.`,Dl="Failed to log breadcrumb",tp=s=>`${s}${B}Failed to handle the error.`,sp=s=>`${s}${B}Plugin name is missing.`,ip=(s,e)=>`${s}${B}Plugin "${e}" already exists.`,rp=(s,e)=>`${s}${B}Plugin "${e}" not found.`,np=(s,e)=>`${s}${B}Plugin "${e}" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.`,op=(s,e,t)=>`${s}${B}Plugin "${e}" could not be loaded because some of its dependencies "${t}" do not exist.`,ap=(s,e,t)=>`${s}${B}Failed to invoke the "${e}" extension point of plugin "${t}".`,Nl="Failed to fetch the source config",lp=(s,e)=>`${s}${B}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,up=(s,e)=>`${s}${B}The data plane URL "${e}" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.`,Eu=s=>`${s}${B}The provided callback parameter is not a function.`,cp=(s,e,t,i,r)=>`${s} with status ${e} (${t}) for URL: ${i}. Response: ${r.trim()}`,dp=(s,e,t)=>`${s} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${t}`,hp=(s,e)=>`${s} for URL: ${e}`,gp=s=>`Failed to save the value for "${s}" to storage`,fp=s=>`Failed to retrieve or parse data for "${s}" from storage`,pp=s=>`The server responded with status ${s} while setting the cookies. As a fallback, the cookies will be set client side.`,vp=s=>`The server failed to set the ${s} cookie. As a fallback, the cookies will be set client side.`,xl="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",_p=(s,e,t)=>`${s}${B}The storage type "${e}" is not supported. Please choose one of the following supported types: "${bu}". The default type "${t}" will be used instead.`,mp=(s,e,t,i)=>`${s}${B}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(t)}". The default version "${i}" will be used instead.`,yp=(s,e,t)=>`${s}${B}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${t}). To enable storage data migration, please update the storage encryption version to the latest version.`,bp=(s,e,t)=>`${s}${B}The provided cookie domain (${e}) does not match the current webpage's domain (${t}). Hence, the cookies will be set client-side.`,Ep=(s,e,t,i)=>`${s}${B}The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,Sp=s=>`${s}${B}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,kp=s=>`${s}${B}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,wp=(s,e,t)=>`${s}${B}The session timeout value "${e}" is not a number. The default timeout of ${t} ms will be used instead.`,Tp=(s,e,t)=>`${s}${B}The session cut off duration value "${e}" is not a number. The default cut off duration of ${t} ms will be used instead.`,Rp=(s,e,t)=>`${s}${B}The session cut off duration value "${e}" ms is less than the session timeout value "${t}" ms. The cut off functionality will be disabled.`,Ap=s=>`${s}${B}The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.`,Ip=(s,e,t)=>`${s}${B}The session timeout value ${e} ms is less than the recommended minimum of ${t} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,Op=(s,e,t)=>`${s}${B}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${t}" digits long. A new session ID will be auto-generated instead.`,Pp=s=>`${s}${B}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,Cp=(s,e,t,i)=>`${s}${B}The storage type "${t}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,Dp=s=>`${s}${B}The callback threw an exception`,Np=(s,e)=>`${s}${B}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,xp=(s,e)=>`Failed to load the polyfill script with ID "${s}" from URL ${e}.`,Lp=(s,e,t)=>`${s}${B}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${t}" will be used instead.`,$p=(s,e,t)=>`${s}${B}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${t}" will be used instead.`,Fp=(s,e)=>`${s}${B}${e} plugin is deprecated. Please exclude it from the load API options.`,Mp=(s,e,t,i)=>{let r=t.length===1,n=r?` '${t[0]}' plugin was`:` ['${t.join("', '")}'] plugins were`,o=`${s}${B}${e}, but${n} not configured to load.`;return i?`${o} So, ${r?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${r?"it":"them"} to the 'plugins' load API option.`},Up=(s,e)=>`${s}${B}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,Bp=s=>`${s}${B}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,Vp=(s,e)=>`${s}${B}Ignoring unknown plugins: ${e.join(", ")}.`,Gp=(s,e)=>`${s}${B}Failed to load the following unavailable local plugins: ${e.join(", ")}. Some features of the SDK may not work as expected. Make sure you are using the correct SDK bundle variant.`,Hp=(s,e)=>`${s}${B}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,Su={All:!0},tr="js-integrations",ku="plugins",jp=new RegExp("^(https?:\\/\\/)(((([a-zA-Z\\d]([a-zA-Z\\d-]*[a-zA-Z\\d])*)\\.)+[a-zA-Z]{2,}|localhost|((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]?)))(\\:\\d+)?(\\/[-a-zA-Z\\d%_.~+]*)*(\\?[;&a-zA-Z\\d%_.~+=-]*)?(\\#[-a-zA-Z\\d_]*)?$"),Ws="modern",sr="https://cdn.rudderlabs.com",lo="v3",wu=`${sr}/${lo}/${Ws}/${tr}`,Tu=`${sr}/${lo}/${Ws}/${ku}`,Ru="https://api.rudderstack.com",Ht="v3",zp="xhr",Nn={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Ui={[Ht]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},Kp={[zp]:"XhrQueue",beacon:"BeaconQueue"},qp="rsaRequest",Wp="rsaMetrics",Yp="Custom Device Mode",Xp={configUrl:Ru,loadIntegration:!0,sessions:{autoTrack:!0,timeout:In,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:Su,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:If,storage:{encryption:{version:Ht},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Jp=y(K(Xp)),Q=io({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),bn=io({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Qp=10,Zp={userId:y(Q.userId),userTraits:y(Q.userTraits),anonymousId:y(Q.anonymousId),groupId:y(Q.groupId),groupTraits:y(Q.groupTraits),initialReferrer:y(Q.initialReferrer),initialReferringDomain:y(Q.initialReferringDomain),sessionInfo:y(Q.sessionInfo),authToken:y(Q.authToken)},ev={isOnline:y(!0),storage:{isLocalStorageAvailable:y(!1),isCookieStorageAvailable:y(!1),isSessionStorageAvailable:y(!1)},isBeaconAvailable:y(!1),isLegacyDOM:y(!1),isUaCHAvailable:y(!1),isCryptoAvailable:y(!1),isAdBlockerDetectionInProgress:y(!1),isAdBlocked:y(void 0),cspBlockedURLs:y([])},tv={isErrorReportingEnabled:y(!1),isMetricsReportingEnabled:y(!1),breadcrumbs:y([])},sv=y(void 0),iv={activeDataplaneUrl:y(void 0),integrationsCDNPath:y(wu),pluginsCDNPath:y(Tu),sourceConfigUrl:y(void 0),status:y(void 0),initialized:y(!1),logLevel:y(yu),loaded:y(!1),readyCallbacks:y([]),writeKey:y(void 0),dataPlaneUrl:y(void 0),safeAnalyticsInstance:y(void 0)},rv={enabled:y(!1),initialized:y(!1),data:y({}),activeConsentManagerPluginName:y(void 0),preConsent:y({enabled:!1}),postConsent:y({}),resolutionStrategy:y("and"),provider:y(void 0),metadata:y(void 0)},nv={retries:y(0),dropped:y(0),sent:y(0),queued:y(0),triggered:y(0),metricsServiceUrl:y(void 0)},ov=()=>yf,av={app:y({name:kl,namespace:mf,version:Ks,installType:cu}),traits:y(null),library:y({name:kl,version:Ks,snippetVersion:globalThis.RudderSnippetVersion,variant:ov()}),userAgent:y(null),device:y(null),network:y(null),os:y({name:"",version:""}),locale:y(null),screen:y({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":y(void 0),timezone:y(void 0)},lv={configuredDestinations:y([]),activeDestinations:y([]),loadOnlyIntegrations:y({}),failedDestinations:y([]),loadIntegration:y(!0),initializedDestinations:y([]),clientDestinationsReady:y(!1),integrationsConfig:y({})},uv={toBeProcessedArray:y([]),readyCallbacksArray:y([])},cv={ready:y(!1),loadedPlugins:y([]),failedPlugins:y([]),pluginsToLoadFromConfig:y([]),activePlugins:y([]),totalPluginsToLoad:y(0)},dv={encryptionPluginName:y(void 0),migrate:y(!1),type:y(void 0),cookie:y(void 0),entries:y({}),trulyAnonymousTracking:y(!1)},hv={isEnabledServerSideCookies:y(!1),dataServiceUrl:y(void 0)},gv={eventsQueuePluginName:y(void 0),deliveryEnabled:y(!0)},fv={enabled:y(!1),pageLifecycle:{enabled:y(!1),pageViewId:y(void 0),pageLoadedTimestamp:y(void 0)}},pv={capabilities:ev,consents:rv,context:av,eventBuffer:uv,lifecycle:iv,loadOptions:Jp,metrics:nv,nativeDestinations:lv,plugins:cv,reporting:tv,session:Zp,source:sv,storage:dv,serverCookies:hv,dataPlaneEvents:gv,autoTrack:fv},c={...K(pv)},Au=/^\s*at /,vv=/^(eval@)?(\[native code])?$/,_v=/(.+?)(?::(\d+))?(?::(\d+))?$/;Ou="global code",Ev=s=>ee(s)&&/^global code$/i.test(s)?Ou:s,Sv=s=>{let e={file:s.fileName,method:Ev(s.functionName),lineNumber:s.lineNumber,columnNumber:s.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Ou),e},Ll=s=>re(s)?s:"";Pu=(s,e)=>{let t;return so(s)&&re(Zi(s))?t=s:(e.warn(ep(Gs,et(s))),t=void 0),t},kv=(s,e)=>{try{let t=bv(s);return $l(s.name,s.message,e,t)}catch{return $l(s.name,s.message,e,[])}},Fl=(s,e)=>{try{return JSON.parse(s||"")}catch(t){let i=oo(t,"Failed to parse response data");e(i)}},Bi="The request failed",wv=[/Failed to fetch dynamically imported module: .*/],Tv=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],Rv=[new RegExp(`${Bi}.*`),/A script with the id .* is already loaded\./],Av=[...wv,...Tv],Iv="integrations",Ov="sdk",Pv=Ov,Cv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Ml=(s,e,t)=>{let i=we(Cv,e||{});return t&&(i.headers=we(i.headers,{Authorization:t})),i.url=s,i},Ul=(s,e=Rf,t)=>new Promise((i,r)=>{let n;if(s.sendRawData===!0)n=s.data;else if(n=et(s.data,!1,[],t),Ve(n)){r({error:new Error(Wf),undefined:void 0,options:s});return}let o=new XMLHttpRequest,a=u=>{r({error:new Error(cp(Bi,o.status,o.statusText,s.url,o.responseText)),xhr:o,options:s})},l=u=>{r({error:new Error(dp(Bi,u,s.url)),xhr:o,options:s,...u?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?i({response:o.responseText,xhr:o,options:s}):a()},o.open(s.method,s.url,!0),s.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(s.headers).forEach(u=>{s.headers[u]&&o.setRequestHeader(u,s.headers[u])});try{o.send(n)}catch(u){r({error:oo(u,hp(Bi,s.url)),xhr:o,options:s})}}),xn=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:i,timeout:r,isRawResponse:n}=e;try{let o=await Ul(Ml(t,i,this.basicAuthHeader),r,this.logger);return{data:n?o.response:Fl(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:t,url:i,options:r,timeout:n,isRawResponse:o}=e,a=!x(t);Ul(Ml(i,r,this.basicAuthHeader),n,this.logger).then(l=>{a||t(o?l.response:Fl(l.response,this.onError),l)}).catch(l=>{a||t(void 0,l)})}onError(e,t){this.errorHandler?.onError({error:e,context:Jg,groupingHash:t})}setAuthHeader(e,t=!1){let i=t?e:Wg(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Cu=new xn(bt),Dv="1",Nv=()=>["rsa"],xv=["www.test-host.com","localhost","127.0.0.1","[::1]"],Lv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],$v="RudderStack JavaScript SDK",Fv="git+https://github.com/rudderlabs/rudder-sdk-js.git",Mv="js",Du=s=>{c.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(c.lifecycle.sourceConfigUrl.value),t=`${e.origin}${e.pathname}?view=ad`;s.getAsyncData({url:t,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(i,r)=>{c.capabilities.isAdBlockerDetectionInProgress.value=!1,c.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==t}})}catch(e){throw c.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},Uv=(s,e)=>{switch(e){case pt.UNHANDLEDEXCEPTION:{let{error:t}=s;return t||s}case pt.UNHANDLEDREJECTION:return s.reason;case pt.HANDLEDEXCEPTION:default:return s}},Bv=s=>({type:"manual",name:s,timestamp:new Date,metaData:{}}),Vv=(s=()=>window.location.hostname)=>{let e=s();return!e||e&&xv.includes(e)?"development":"production"},Gv=s=>{let e=et(s,!1,Lv);return e!==null?JSON.parse(e):{}},Hv=()=>globalThis.location.href.split("?")[0],jv=(s,e,t,i)=>({id:`${s.value?.id??t.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${i.pageLifecycle.pageViewId.value??"NA"}`,name:s.value?.name??"NA"}),zv=(s,e)=>({locale:s.value??"NA",userAgent:e.value??"NA",time:new Date}),Kv=(s,e,t,i)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:u}=t,{app:d,locale:h,userAgent:f,timezone:g,screen:p,library:v}=r;return{payloadVersion:"5",notifier:{name:$v,version:d.value.version,url:Fv},events:[{exceptions:[K(s)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:d.value.version,releaseStage:Vv(),type:d.value.installType},device:zv(h,f),request:{url:Hv(),clientIp:"[NOT COLLECTED]"},breadcrumbs:K(l.breadcrumbs.value),context:s.message,groupingHash:i,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...p.value,timezone:g.value},...Gv(t)},user:jv(a,o,n,u)}]}},qv=(s,e,t)=>{if(Re(s.capabilities.isAdBlocked.value)){s.capabilities.isAdBlockerDetectionInProgress.value===!1&&Du(e);let i=at(()=>{ee(s.capabilities.isAdBlocked.value)&&(t(s.capabilities.isAdBlocked.value===!1),i())})}else t(s.capabilities.isAdBlocked.value===!1)},Wv=(s,e,t)=>{let i=s.message;return new Promise(r=>{if(Av.some(n=>n.test(i))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];re(n)?n.startsWith(sr)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):qv(e,t,r):r(!1):r(!0)}else r(!Rv.some(n=>n.test(i)))})},Nu=s=>s?s.split("/").at(-2):void 0,xu=s=>{let e=s.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},Yv=s=>{let e=xu(s);if(!e)return!1;let t=e.substring(e.lastIndexOf("/")+1);return Nu(e)===tr||Nv().some(r=>t.startsWith(r)&&t.endsWith(".js"))},Xv=(s,e)=>{if(e)return e;let t=xu(s);return Nu(t)===tr?Iv:Pv},Jv=(s,e,t)=>{let i={version:Dv,message_id:Qi(),source:{name:Mv,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:t},errors:s};return et(i)},Qv=(s,e,t)=>{let i;if(!ee(s))i=e;else if(re(s))i=s;else{let r=Pu(s,t);ee(r)?i=r.message:i=e}return i},Ln=class{constructor(e,t){le(this,"initialized",!1);this.httpClient=e,this.logger=t}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Gs,errorType:pt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Gs,errorType:pt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let t=re(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&t.startsWith(sr)&&!c.capabilities.cspBlockedURLs.value.includes(t)&&(c.capabilities.cspBlockedURLs.value=[...c.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:i,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??pt.HANDLEDEXCEPTION,l=Uv(t,a),u=Pu(l,this.logger);if(Re(u))return;let d=r?`${r} - `:"",h=`${i}${B}${d}`,f=kv(u,h),p=Zi(u).includes(uu);if(!p&&!Yv(f)&&a!==pt.HANDLEDEXCEPTION)return;if(c.reporting.isErrorReportingEnabled.value&&await Wv(f,c,this.httpClient)){let m={severity:"error",unhandled:a!==pt.HANDLEDEXCEPTION,severityReason:{type:a}},b=Qv(n,f.message,this.logger),k=Kv(f,m,c,b),D=Xv(f,o);this.httpClient.getAsyncData({url:c.metrics.metricsServiceUrl.value,options:{method:"POST",data:Jv(k,c,D),sendRawData:!0},isRawResponse:!0})}(a===pt.HANDLEDEXCEPTION||p)&&this.logger.error(f.message)}catch(t){this.logger.error(tp(Gs),t)}}leaveBreadcrumb(e){try{c.reporting.breadcrumbs.value=[...c.reporting.breadcrumbs.value,Bv(e)]}catch(t){this.onError({error:t,context:Gs,customMessage:Dl,groupingHash:Dl})}}},Lu=new Ln(Cu,bt),$n=class{constructor(e,t={}){le(this,"plugins",[]);le(this,"byName",{});le(this,"cache",{});le(this,"config",{throws:!0});this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let r=sp(ns);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=ip(ns,e.name);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},this.plugins=this.plugins.slice();let i=this.plugins.length;this.plugins.forEach((r,n)=>{r.deps?.includes(e.name)&&(i=Math.min(i,n))}),this.plugins.splice(i,0,e),this.byName[e.name]=e,x(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let r=rp(ns,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let i=this.plugins.indexOf(t);if(i===-1){let r=np(ns,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(i,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(i=>{if(i.deps?.some(r=>!this.byName[r])){let r=i.deps.filter(n=>!this.byName[n]);return this.logger.error(op(ns,i.name,r)),!1}return t==="."?!0:Gg(i,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...i){let r=e;if(!r)throw new Error(Yf);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(Xf);let a=r.split(".");a.pop();let l=a.join(".");return(t?this.getPlugins(r):[this.getPlugins(r)[0]]).map(d=>{let h=Rn(d,r);if(!x(h)||n)return h;try{return h.apply(Rn(d,l),i)}catch(f){if(o)throw f;this.logger.error(ap(ns,r,d.name),f)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}},Zv=new $n(bt,{throws:!0}),e_=s=>s.config.connectionMode!=="cloud"||s.config.useNativeSDKToSend===!0||s.config.useNativeSDK===!0,t_=s=>s.config.connectionMode==="hybrid"||s.config.useNativeSDKToSend===!0,Bl=s=>s.filter(e_),s_=(s,e)=>`${s.replaceAll(" ","-")}___${e}`,$u=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],i_=["Bugsnag","ErrorReporting"],r_={rudderAnalyticsRemotePlugins:{url:()=>Promise.resolve(window.RudderStackGlobals&&window.RudderStackGlobals.app&&window.RudderStackGlobals.app.pluginsCDNPath?`${window.RudderStackGlobals.app.pluginsCDNPath}/rsa-plugins.js`:"https://cdn.rudderlabs.com/v3/modern/plugins//rsa-plugins.js"),format:"esm",from:"vite"}};n_=s=>Fu({},(globalThis.__federation_shared__||{}).default||{});a_=s=>{switch(s){case"BeaconQueue":return()=>Ue("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Me(e,!0));case"CustomConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Me(e,!0));case"DeviceModeDestinations":return()=>Ue("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Me(e,!0));case"DeviceModeTransformation":return()=>Ue("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Me(e,!0));case"ExternalAnonymousId":return()=>Ue("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Me(e,!0));case"GoogleLinker":return()=>Ue("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Me(e,!0));case"KetchConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Me(e,!0));case"IubendaConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Me(e,!0));case"NativeDestinationQueue":return()=>Ue("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Me(e,!0));case"OneTrustConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Me(e,!0));case"StorageEncryption":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Me(e,!0));case"StorageEncryptionLegacy":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Me(e,!0));case"StorageMigrator":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Me(e,!0));case"XhrQueue":return()=>Ue("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Me(e,!0));default:return}},l_=s=>{let e={};return s.forEach(t=>{if($u.includes(t)){let i=a_(t);i&&(e[t]=i)}}),e},Mu=()=>({}),u_=()=>({}),c_=s=>l_?.(s)||{},En={...Mu(),...u_()},d_=s=>({...c_(s)}),Fn=class{constructor(e,t,i){this.engine=e,this.errorHandler=t,this.logger=i,this.onError=this.onError.bind(this)}init(){c.lifecycle.status.value="pluginsLoading",qs("pluginsCDNPath",c.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){at(()=>{(c.plugins.activePlugins.value.length===0||c.plugins.loadedPlugins.value.length+c.plugins.failedPlugins.value.length===c.plugins.totalPluginsToLoad.value)&&Te(()=>{c.plugins.ready.value=!0,c.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=c.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>i_.includes(r)?(this.logger.warn(Fp(Us,r)),!1):!0);let t=[{configurationStatus:()=>ee(c.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:c.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(Kp),shouldAddMissingPlugins:!0},{configurationStatus:()=>Bl(c.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Bl(c.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>ee(c.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:c.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Nn)},{configurationStatus:()=>ee(c.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:c.storage.encryptionPluginName.value,supportedPlugins:Object.values(Ui)},{configurationStatus:()=>c.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return t.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>ee(n)),this.addMissingPlugins(r,i,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(Mu()),...e]}addMissingPlugins(e,t,i){let r=e.shouldAddMissingPlugins||t,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!i.includes(a));o.length>0&&(r&&i.push(...o),this.logger.warn(Mp(Us,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(En),...$u],i=[],r=[];e.forEach(n=>{t.includes(n)?i.push(n):r.push(n)}),r.length>0&&this.logger.warn(Vp(Us,r)),Te(()=>{c.plugins.totalPluginsToLoad.value=e.length,c.plugins.activePlugins.value=i,c.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(En).forEach(([t,i])=>{c.plugins.activePlugins.value.includes(t)&&(x(i)?this.register([i()]):e.push(t))}),e.length>0&&(c.plugins.failedPlugins.value=[...c.plugins.failedPlugins.value,...e],this.logger.error(Gp(Us,e)))}registerRemotePlugins(){let e=d_(c.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(i=>this.register([i.default()])).catch(i=>{c.plugins.failedPlugins.value=[...c.plugins.failedPlugins.value,t],this.onError(i,`Failed to load plugin "${t}"`,i)})})).catch(t=>{this.onError(t)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(i){return this.onError(i,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(i){return this.onError(i,e),null}}register(e){e.forEach(t=>{try{this.engine.register(t,c)}catch(i){c.plugins.failedPlugins.value=[...c.plugins.failedPlugins.value,t.name],this.onError(i,`Failed to register plugin "${t.name}"`)}})}unregisterLocalPlugins(){Object.keys(En).forEach(e=>{try{this.engine.unregister(e)}catch(t){this.onError(t,`Failed to unregister plugin "${e}"`)}})}onError(e,t,i){this.errorHandler.onError({error:e,context:Us,customMessage:t,groupingHash:i})}},Be="cookieStorage",He="localStorage",We="sessionStorage",ot="memoryStorage",Kt="none",h_="test_rudder_cookie",g_="test_rudder_ls",f_="test_rudder_ss",p_="rl_user_id",v_="rl_trait",__="rl_anonymous_id",m_="rl_group_id",y_="rl_group_trait",b_="rl_page_init_referrer",E_="rl_page_init_referring_domain",S_="rl_session",k_="rl_auth_token",os={userId:p_,userTraits:v_,anonymousId:__,groupId:m_,groupTraits:y_,initialReferrer:b_,initialReferringDomain:E_,sessionInfo:S_,authToken:k_},w_="__tld__",Uu="clientDataInCookie",Bu="clientDataInLocalStorage",T_="clientDataInMemory",Vu="clientDataInSessionStorage",Gu=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],as={[Be]:Uu,[He]:Bu,[ot]:T_,[We]:Vu},Vl=(s,e)=>{try{return encodeURIComponent(s)}catch(t){e?.error(hf,t);return}},Gl=s=>{try{return decodeURIComponent(s)}catch{return}},R_=s=>{let e={},t=s.split(/\s*;\s*/),i;return t[0]&&t.forEach(r=>{i=r.split("=");let n=i[0]?Gl(i[0]):void 0;n&&(e[n]=i[1]?Gl(i[1]):void 0)}),e},A_=(s,e,t,i)=>{let r={...t||{}},n=`${Vl(s,i)}=${Vl(e,i)}`;Ve(e)&&(r.maxage=-1),r.maxage&&(r.expires=new Date(+new Date+r.maxage)),r.path&&(n+=`; path=${r.path}`),r.domain&&(n+=`; domain=${r.domain}`),r.expires&&(n+=`; expires=${r.expires.toUTCString()}`),r.samesite&&(n+=`; samesite=${r.samesite}`),r.secure&&(n+="; secure"),globalThis.document.cookie=n},Mn=()=>{let s=globalThis.document.cookie;return R_(s)},I_=s=>Mn()[s],vt=function(s,e,t,i){switch(arguments.length){case 4:case 3:case 2:return A_(s,e,t,i);case 1:return s?I_(s):Mn();default:return Mn()}},O_=s=>{let e=document.createElement("a");return e.href=s,e.hostname},P_=s=>{let t=(typeof globalThis.URL!="function"?O_(s):new URL(s).hostname)?.split(".")??[],i=t[t.length-1],r=[];if(t.length===4&&i&&i===parseInt(i,10).toString())return r;if(t.length<=1)return t[0]&&t[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=t.length-2;n>=0;n-=1)r.push(t.slice(n).join("."));return r},C_=s=>{let e=P_(s);for(let t=0;t<e.length;t+=1){let i=e[t],r=w_,n={domain:`${i.indexOf("localhost")!==-1?"":"."}${i}`};try{if(vt(r,1,n),vt(r))return vt(r,null,n),i}catch{try{vt(r,null,n)}catch{}}}return""},D_=()=>{let s=`.${C_(globalThis.location.href)}`;return{maxage:Af,path:"/",domain:!s||s==="."?void 0:s,samesite:"Lax",enabled:!0}},N_=()=>({enabled:!0}),x_=()=>({enabled:!0}),L_=()=>({enabled:!0}),Un=class{constructor(e){le(this,"isEnabled",!0);le(this,"length",0);le(this,"data",{});this.options=L_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,t){return this.data[e]=t,this.length=Object.keys(this.data).length,t}getItem(e){return e in this.data?this.data[e]:null}removeItem(e){return e in this.data&&delete this.data[e],this.length=Object.keys(this.data).length,null}clear(){this.data={},this.length=0}key(e){return this.keys()[e]??null}keys(){return Object.keys(this.data)}},Xi=new Un(bt);Vi={exports:{}},F_=Vi.exports;U_=M_(),Vt=$_(U_),Hu=s=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],t=[22,1014];return s instanceof DOMException?e.includes(s.name)||t.includes(s.code):!1},ls=(s=He,e,t)=>{let i,r,n=gf(An,s),o="unavailable",a=!0,l;try{switch(s){case ot:return!0;case Be:i=e,r=h_;break;case He:i=e??globalThis.localStorage,r=g_;break;case We:i=e??globalThis.sessionStorage,r=f_;break;default:return!1}if(i&&(i.setItem(r,"true"),i.getItem(r)))return i.removeItem(r),!0;a=!1}catch(u){a=!1,l=u,Hu(u)&&(o="full")}return a||t?.warn(`${n}${o}.`,l),!1},Bn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.options=N_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isSupportAvailable=ls(He),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){Vt.set(e,t),this.length=Vt.len()}getItem(e){let t=Vt.get(e);return Re(t)?null:t}removeItem(e){Vt.remove(e),this.length=Vt.len()}clear(){Vt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Vt.keys()}},uo=new Bn(bt),Vn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.options=x_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isSupportAvailable=ls(We),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){this.store&&(this.store.setItem(e,t),this.length=this.store.length)}getItem(e){if(!this.store)return null;let t=this.store.getItem(e);return Re(t)?null:t}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];if(!this.store)return e;for(let t=0;t<this.store.length;t+=1){let i=this.store.key(t);i!==null&&e.push(i)}return e}},co=new Vn(bt),Gn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=D_()),this.options=we(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=ls(Be,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){return vt(e,t,this.options,this.logger),this.length=Object.keys(vt()).length,!0}getItem(e){let t=vt(e);return Re(t)?null:t}removeItem(e){let t=this.setItem(e,null);return this.length=Object.keys(vt()).length,t}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(vt())}},ho=new Gn(bt),Ze=s=>{switch(s){case He:return uo;case We:return co;case ot:return Xi;case Be:return ho;default:return Xi}},B_=s=>{let e=ho.configure(s);c.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},V_=s=>{uo.configure(s)},G_=s=>{Xi.configure(s)},H_=s=>{co.configure(s)},j_=(s={},e={},t={},i={})=>{B_(s),V_(e),G_(t),H_(i)},Hn=class{constructor(e,t,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=t,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=i}createValidKey(e){let{name:t,id:i,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[t,i,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[t,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:i,noCompoundKey:r}=this,n=Ze(ot);Object.keys(i).forEach(o=>{let a=this.get(i[o]),l=r?o:[e,t,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,t){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(et(t,!1,[],this.logger)))}catch(r){if(Hu(r))this.logger.warn(Pp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t);else{let n=gp(e);this.onError(r,n,n)}}}get(e){let t=this.createValidKey(e),i;try{return!t||(i=this.decrypt(this.engine.getItem(t)),tt(i)||i==="")?null:JSON.parse(i)}catch(r){let n=c.storage.encryptionPluginName.value;if(!n||!c.plugins.failedPlugins.value.includes(n)){let a=fp(e);this.onError(r,a,a)}return null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return tt(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||typeof e!="string"||Kg(e)==="")return e;let r=`storage.${t}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,t,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:i})}},z_=(s,e)=>{let t;if(s.consents.preConsent.value.enabled)switch(s.consents.preConsent.value.storage?.strategy){case"none":t=Kt;break;case"session":e!=="sessionInfo"&&(t=Kt);break;case"anonymousId":e!=="anonymousId"&&(t=Kt);break}return t},jn=class{constructor(e,t,i){le(this,"stores",{});le(this,"isInitialized",!1);this.errorHandler=t,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=c.loadOptions.value,t={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};j_(Vs(we(t.cookieStorageOptions??{},c.storage.cookie?.value??{})),Vs(t.localStorageOptions),Vs(t.inMemoryStorageOptions),Vs(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[ot,He,Be,We].forEach(t=>{Ze(t)?.isEnabled&&this.setStore({id:as[t],name:as[t],isEncrypted:!0,noCompoundKey:!0,type:t,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=c.storage.type.value,t=c.loadOptions.value.storage?.entries,i=c.consents.postConsent.value.storage;(ee(i?.type)||ee(i?.entries))&&(e=i?.type,t=i?.entries);let r=!0,n={};Gu.forEach(o=>{let a=o,l=o,u=t?.[a]?.type,h=z_(c,o)??u??e??Dn,f=this.getResolvedStorageTypeForEntry(h,o);f!==Kt&&(r=!1),n={...n,[o]:{type:f,key:os[l]}}}),Te(()=>{c.storage.type.value=e,c.storage.entries.value=n,c.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){let i=e;switch(e){case He:Ze(He)?.isEnabled||(i=ot);break;case We:Ze(We)?.isEnabled||(i=ot);break;case ot:case Kt:break;case Be:default:Ze(Be)?.isEnabled?i=Be:Ze(He)?.isEnabled?i=He:Ze(We)?.isEnabled?i=We:i=ot;break}return i!==e&&this.logger.warn(Cp(Yg,t,e,i)),i}setStore(e){let t=Ze(e.type);return this.stores[e.id]=new Hn(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},K_=s=>ne(s)&&ne(s.source)&&!tt(s.source.id)&&ne(s.source.config)&&Array.isArray(s.source.destinations),q_=s=>typeof s=="string"&&bu.includes(s),ju=s=>{let e=new URL(s),{host:t,protocol:i}=e,r=t.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=t,{topDomain:n,protocol:i}},W_=s=>{let{topDomain:e,protocol:t}=ju(s);return`${t}//${e}`},Y_=(s,e)=>{let t=e?window.location.origin:W_(window.location.href),i=s.startsWith("/")?s.substring(1):s;return`${t}/${i}`},X_=s=>{let{topDomain:e}=ju(window.location.href);return e===s},cs=s=>s?.endsWith("/")?cs(s.substring(0,s.length-1)):s,zn=s=>{try{return new URL(s).host}catch{return null}},zu=s=>zn(s)??"",J_=s=>{let e={};try{let t=new URL(s),i="utm_";t.searchParams.forEach((r,n)=>{if(n.startsWith(i)){let o=n.substring(i.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},Q_=s=>{let e=s;try{let t=new URL(s);e=t.origin+t.pathname+t.search}catch{}return e},Z_=s=>s.replace(/\/{2,}/g,"/"),ds=s=>{if(!re(s))return!1;try{return x(globalThis.URL)&&new URL(s),jp.test(s)}catch{return!1}},Sn="none",kn="immediate",em=s=>s?.statsCollection?.errors?.enabled===!0,tm=s=>s?.statsCollection?.metrics?.enabled===!0,sm=s=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ne(s)){let t=K(s);e.storage=t.storage,yt(t.integrations)&&(e.integrations=t.integrations),e.discardPreConsentEvents=t.discardPreConsentEvents===!0,e.sendPageEvent=t.sendPageEvent===!0,e.trackConsent=t.trackConsent===!0,yt(t.consentManagement)&&(e.consentManagement=we(t.consentManagement,{enabled:c.consents.enabled.value}))}return e},jl=s=>yt(s)||Array.isArray(s),im=(s,e)=>{let{provider:t}=s,i=t?Nn[t]:void 0;return t&&!i&&(e.error(Zf(Ye,t,Nn)),t=void 0),{provider:t,consentManagerPluginName:i}},Ku=(s,e)=>{let t,i=[],r=[],n=!1,o,a=s?.enabled===!0;yt(s)&&a&&({provider:o,consentManagerPluginName:t}=im(s,e),jl(s.allowedConsentIds)&&(i=s.allowedConsentIds,n=!0),jl(s.deniedConsentIds)&&(r=s.deniedConsentIds,n=!0));let l={allowedConsentIds:i,deniedConsentIds:r};return a=a&&!!t,{provider:o,consentManagerPluginName:t,initialized:n,enabled:a,consentsData:l}},rm=()=>{let s=document.querySelector("script[data-rsa-write-key]");if(s&&s.dataset.rsaWriteKey===c.lifecycle.writeKey.value)return s.src;let e=document.getElementsByTagName("script"),t=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let r=i.getAttribute("src");if(r&&t.test(r))return r}},nm=s=>{c.reporting.isErrorReportingEnabled.value=em(s.source.config)&&!rf(),c.reporting.isMetricsReportingEnabled.value=tm(s.source.config)},om=s=>{let{useServerSideCookies:e,dataServiceEndpoint:t,storage:i,setCookieDomain:r,sameDomainCookiesOnly:n}=c.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let u=o.domain??r,d=ee(u)&&!X_(bl(u))||n,h=Y_(t??qp,d);if(ds(h)){l=cs(h);let f=zn(window.location.href),g=zn(h);f!==g&&(o={...o,samesite:"None",secure:!0}),!n&&d&&g!==bl(u)&&(a=!1,s.warn(bp(Ye,u,g)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},am=s=>{let{storage:e}=c.loadOptions.value,t=e?.type;ee(t)&&!q_(t)&&(s.warn(_p(Ye,t,Dn)),t=Dn);let i=e?.encryption?.version,r=i&&Ui[i];!Re(i)&&Re(r)?(s.warn(mp(Ye,i,Ui,Ht)),i=Ht):Re(i)&&(i=Ht);let n=e?.migrate,o=n&&i===Ht;n===!0&&o!==n&&s.warn(yp(Ye,i,Ht));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=om(s);Te(()=>{c.storage.type.value=t,c.storage.cookie.value=u,c.serverCookies.isEnabledServerSideCookies.value=a,c.serverCookies.dataServiceUrl.value=l,c.storage.encryptionPluginName.value=Ui[i],c.storage.migrate.value=o})},lm=s=>{let{provider:e,consentManagerPluginName:t,initialized:i,enabled:r,consentsData:n}=Ku(c.loadOptions.value.consentManagement,s),o=c.loadOptions.value.preConsent,a=o?.storage?.strategy??Sn,l=["none","session","anonymousId"];ee(a)&&!l.includes(a)&&(a=Sn,s.warn(Lp(Ye,o?.storage?.strategy,Sn)));let u=o?.events?.delivery??kn,d=["immediate","buffer"];ee(u)&&!d.includes(u)&&(u=kn,s.warn($p(Ye,o?.events?.delivery,kn))),Te(()=>{c.consents.activeConsentManagerPluginName.value=t,c.consents.initialized.value=i,c.consents.enabled.value=r,c.consents.data.value=n,c.consents.provider.value=e,c.consents.preConsent.value={enabled:c.loadOptions.value.preConsent?.enabled===!0&&i===!1&&r===!0,storage:{strategy:a},events:{delivery:u}}})},um=s=>{let e=c.consents.resolutionStrategy.value,t;ne(s.consentManagementMetadata)&&(c.consents.provider.value&&(e=s.consentManagementMetadata.providers.find(i=>i.provider===c.consents.provider.value)?.resolutionStrategy??c.consents.resolutionStrategy.value),t=s.consentManagementMetadata),c.consents.provider.value==="custom"&&(e=void 0),Te(()=>{c.consents.metadata.value=K(t),c.consents.resolutionStrategy.value=e})},cm=s=>{if(c.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",t=e;c.loadOptions.value.useBeacon&&(c.capabilities.isBeaconAvailable.value?t="BeaconQueue":(t=e,s.warn(kp(Ye)))),Te(()=>{c.dataPlaneEvents.eventsQueuePluginName.value=t})}},dm=(s,e,t,i,r)=>{let n=new URLSearchParams({p:cu,v:Ks,build:Ws,writeKey:e,lockIntegrationsVersion:t.toString(),lockPluginsVersion:i.toString()}),o=Ru,a=n,l="/sourceConfig/",u="";if(ds(s)){let d=new URL(s);cs(d.pathname).endsWith("/sourceConfig")||(d.pathname=`${cs(d.pathname)}/sourceConfig/`),d.pathname=Z_(d.pathname),n.forEach((h,f)=>{d.searchParams.get(f)===null&&d.searchParams.set(f,h)}),o=d.origin,l=d.pathname,a=d.searchParams,u=d.hash}else r.warn(Np(Ye,s));return`${o}${l}?${a}${u}`},hm=s=>s.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:s_(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Yp})),qu=(s,e,t,i,r,n,o)=>{let a;if(n){if(!ds(n))return o.error(Qf(Ye,s,n)),null;a=cs(n)}else if(a=t,c.context.app.value.installType==="cdn"){let l=rm();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${lo}/${Ws}/${e}$`),`/${i}/${Ws}/${e}`)),a},gm=(s,e,t,i)=>qu("integrations",tr,wu,s,e,t,i),fm=(s,e,t,i)=>qu("plugins",ku,Tu,s,e,t,i),Kn=class{constructor(e,t,i){this.errorHandler=t,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){at(()=>{this.logger.setMinLogLevel(c.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:t,lockIntegrationsVersion:i,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=c.loadOptions.value,l=gm(Ks,i,n,this.logger);if(Ve(l))return;let u;u=fm(Ks,r,o,this.logger),u!==null&&(this.attachEffects(),c.lifecycle.activeDataplaneUrl.value=cs(c.lifecycle.dataPlaneUrl.value),am(this.logger),lm(this.logger),cm(this.logger),Te(()=>{c.lifecycle.integrationsCDNPath.value=l,c.lifecycle.pluginsCDNPath.value=u,e&&(c.lifecycle.logLevel.value=e),c.lifecycle.sourceConfigUrl.value=dm(t,c.lifecycle.writeKey.value,i,r,this.logger),c.metrics.metricsServiceUrl.value=`${c.lifecycle.activeDataplaneUrl.value}/${Wp}`,c.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,t,i){this.errorHandler.onError({error:e,context:Ye,customMessage:t,groupingHash:i})}processConfig(e,t){if(!ee(e)){ee(t)?this.onError(t.error,Nl):this.onError(new Error(Nl));return}let i;try{re(e)?i=JSON.parse(e):i=e}catch(n){this.onError(n,Cl);return}if(!K_(i)){this.onError(new Error(Cl));return}if(i.source.enabled===!1){this.logger.error(qf);return}nm(i);let r=i.source.destinations.length>0?hm(i.source.destinations):[];Te(()=>{c.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},c.nativeDestinations.configuredDestinations.value=r,c.plugins.pluginsToLoadFromConfig.value=c.loadOptions.value.plugins??[],um(i),c.lifecycle.status.value="configured"})}getConfig(){let e=c.loadOptions.value.getSourceConfig;if(e){if(!x(e)){this.logger.error(Jf(Ye));return}let t=e();t instanceof Promise?t.then(i=>this.processConfig(i)).catch(i=>{this.onError(i,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:c.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},pm=()=>{let s=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return s?.[1]?s[1]:"NA"},Wu=(s=()=>document)=>s()?.referrer||"$direct",vm=(s=()=>document)=>{let t=s().getElementsByTagName("link"),i="";for(let r=0;t[r];r+=1){let n=t[r];if(n.getAttribute("rel")==="canonical"&&!i){i=n.getAttribute("href")??"";break}}return i},_m=(s=()=>globalThis.navigator)=>{let e=s();if(Re(e))return null;let{userAgent:t}=e,{brave:i}=e;if(i&&Object.getPrototypeOf(i).isBrave){let r=t.match(/(chrome)\/([\w.]+)/i);r&&(t=`${t} Brave/${r[2]}`)}return t},mm=(s=()=>globalThis.navigator)=>{let e=s();return Re(e)?null:e.language??e.browserLanguage},Yu=(s=()=>globalThis.location,e=()=>document)=>{let t=s(),i=vm(e),r=t.pathname,{href:n}=t,o=n,{search:a}=t;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,r=h.pathname}catch{}let l=Q_(o),{title:u}=e(),d=Wu(e);return{path:r,referrer:d,referring_domain:zu(d),search:a,title:u,url:l,tab_url:n}},ym=(s,e="none")=>{e==="none"&&s(void 0),e==="default"&&s(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(t=>{s(t)}).catch(()=>{s()})},bm=()=>{let s=globalThis.document.createElement("div");return s.setAttribute("data-a-b","c"),s.dataset?s.dataset.aB==="c":!1},qn={URL:()=>!x(globalThis.URL)||!x(globalThis.URLSearchParams),Promise:()=>!x(globalThis.Promise),"Number.isNaN":()=>!x(globalThis.Number.isNaN),"Number.isInteger":()=>!x(globalThis.Number.isInteger),"Array.from":()=>!x(globalThis.Array.from),"Array.prototype.find":()=>!x(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!x(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!x(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!x(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!x(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!x(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!x(globalThis.String.fromCodePoint),"Object.entries":()=>!x(globalThis.Object.entries),"Object.values":()=>!x(globalThis.Object.values),"Object.assign":()=>!x(globalThis.Object.assign),"Object.fromEntries":()=>!x(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!bm(),TextEncoder:()=>!x(globalThis.TextEncoder)||!x(globalThis.TextDecoder),requestAnimationFrame:()=>!x(globalThis.requestAnimationFrame)||!x(globalThis.cancelAnimationFrame),CustomEvent:()=>!x(globalThis.CustomEvent),"navigator.sendBeacon":()=>!x(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!x(globalThis.Uint8Array),Set:()=>!x(globalThis.Set),atob:()=>!x(globalThis.atob)},Em=()=>{let s=Object.keys(qn),e=!1;for(let t=0;t<s.length;t++){let i=qn[s[t]];if(x(i)&&i()){e=!0;break}}return e},Sm="https://polyfill-fastly.io/v3/polyfill.min.js",km=`${Sm}?version=3.111.0&features=${Object.keys(qn).join("%2C")}`,wm=10*1e3,zl="rudderstackPolyfill",Tm=()=>!tt(globalThis.crypto)&&x(globalThis.crypto.getRandomValues),Kl=()=>!tt(globalThis.navigator.userAgentData),Rm=()=>!tt(globalThis.navigator.sendBeacon)&&x(globalThis.navigator.sendBeacon),ql=()=>{let s={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return s={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},s},Wn=class{constructor(e,t,i){this.httpClient=e,this.errorHandler=t,this.logger=i,this.externalSrcLoader=new Ki(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Te(()=>{c.capabilities.storage.isCookieStorageAvailable.value=ls(Be,Ze(Be),this.logger),c.capabilities.storage.isLocalStorageAvailable.value=ls(He,void 0,this.logger),c.capabilities.storage.isSessionStorageAvailable.value=ls(We,void 0,this.logger),c.capabilities.isBeaconAvailable.value=Rm(),c.capabilities.isUaCHAvailable.value=Kl(),c.capabilities.isCryptoAvailable.value=Tm(),c.capabilities.isOnline.value=globalThis.navigator.onLine,c.context.userAgent.value=_m(),c.context.locale.value=mm(),c.context.screen.value=ql(),c.context.timezone.value=pm(),Kl()&&ym(e=>{c.context["ua-ch"].value=e},c.loadOptions.value.uaChTrackLevel)}),at(()=>{c.loadOptions.value.sendAdblockPage===!0&&c.lifecycle.sourceConfigUrl.value!==void 0&&Du(this.httpClient)})}prepareBrowserCapabilities(){c.capabilities.isLegacyDOM.value=Em();let e=c.loadOptions.value.polyfillURL,t=km;if(us(e)&&(ds(e)?t=e:this.logger.warn(Up(An,e))),c.loadOptions.value.polyfillIfRequired&&c.capabilities.isLegacyDOM.value&&ds(t)){let r=t!==c.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${c.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,t=`${t}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:t,id:zl,async:!0,timeout:wm,callback:n=>{n?r||this.onReady():this.onError(new Error(xp(zl,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{c.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{c.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Pf(()=>{c.context.screen.value=ql()},this))}onReady(){this.detectBrowserCapabilities(),c.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:An,groupingHash:t})}},Am="web",Im=["integrations","anonymousId","originalTimestamp"],Wl=["library","consentManagement","userAgent","ua-ch","screen"],wn=["id","anonymous_id","user_id","sent_at","timestamp","received_at","original_timestamp","event","event_text","channel","context_ip","context_request_ip","context_passed_ip","group_id","previous_id"],Xu=s=>typeof s=="number"&&!Number.isNaN(s),Om=(s,e)=>e.toString().length>=s,Ji=s=>Xu(s)&&s>=0&&Number.isInteger(s),Yl=10,Ju=s=>{let{cutOff:e}=s,t=Date.now();return!!(e?.enabled&&e.expiresAt&&t>e.expiresAt)},Xl=s=>!s.expiresAt||Date.now()>s.expiresAt||Ju(s),Pm=()=>Date.now(),Cm=(s,e)=>!s||!Ji(s)||!Om(Yl,s)?(e.warn(Op(Gt,s,Yl)),!1):!0,Dm=s=>{if(s?.enabled)return s.expiresAt??(Ji(s.duration)?Date.now()+s.duration:void 0)},Nm=s=>{let{timeout:e,cutOff:t}=s,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...t&&{cutOff:t}}},xm=(s,e)=>({id:Cm(s,e)?s:Pm(),sessionStart:void 0,manualTrack:!0}),Hs=s=>s===Be||s===He||s===We||s===ot,Yn=()=>Qi(),Lm=s=>{if(Vg(s)){let{entries:e,...t}=bn;return{...t,entries:{...e,anonymousId:s}}}return ne(s)&&ne(s.entries)?we(bn,s):{...bn}},$m=s=>{let e=Yu(),t={};return Object.keys(e).forEach(i=>{t[i]=s?.[i]||e[i]}),t.initial_referrer=s?.initial_referrer||c.session.initialReferrer.value,t.initial_referring_domain=s?.initial_referring_domain||c.session.initialReferringDomain.value,t},Fm=(s,e)=>{let t=e?.page||{},i=s,r=Yu();return Object.keys(r).forEach(n=>{Re(i[n])&&(i[n]=t[n]||r[n])}),Re(i.initial_referrer)&&(i.initial_referrer=t.initial_referrer||c.session.initialReferrer.value),Re(i.initial_referring_domain)&&(i.initial_referring_domain=t.initial_referring_domain||c.session.initialReferringDomain.value),i},Tn=(s,e,t)=>{ne(s)&&Object.keys(s).forEach(i=>{(wn.includes(i)||wn.includes(i.toLowerCase()))&&t.warn(Ep(nu,i,e,wn))})},Mm=(s,e)=>{let{properties:t,traits:i,context:r}=s,{traits:n}=r;Tn(t,"properties",e),Tn(i,"traits",e),Tn(n,"context.traits",e)},Um=(s,e)=>{e.anonymousId&&re(e.anonymousId)&&(s.anonymousId=e.anonymousId),yt(e.integrations)&&(s.integrations=e.integrations),e.originalTimestamp&&re(e.originalTimestamp)&&(s.originalTimestamp=e.originalTimestamp)},Bm=(s,e,t)=>{let i=s;return Object.keys(e).forEach(r=>{if(!Im.includes(r)&&!Wl.includes(r))if(r!=="context")i=we(i,{[r]:e[r]});else if(!Re(e[r])&&ne(e[r])){let n={};Object.keys(e[r]).forEach(o=>{Wl.includes(o)||(n[o]=e[r][o])}),i=we(i,{...n})}else t.warn(Sp(nu))}),i},Vm=(s,e,t)=>{ne(e)&&(Um(s,e),s.context=Bm(s.context,e,t))},Gm=s=>{let e;return c.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=c.consents.postConsent.value.integrations??c.nativeDestinations.loadOnlyIntegrations.value:s?e=s:e=Su,K(e)},Bs=(s,e,t,i)=>{let r={channel:Am,context:{traits:K(c.session.userTraits.value),sessionId:c.session.sessionInfo.value.id||void 0,sessionStart:c.session.sessionInfo.value.sessionStart||void 0,...c.consents.enabled.value&&{consentManagement:{deniedConsentIds:K(c.consents.data.value.deniedConsentIds),allowedConsentIds:K(c.consents.data.value.allowedConsentIds),provider:c.consents.provider.value,resolutionStrategy:c.consents.resolutionStrategy.value}},"ua-ch":c.context["ua-ch"].value,app:c.context.app.value,library:c.context.library.value,userAgent:c.context.userAgent.value,os:c.context.os.value,locale:c.context.locale.value,screen:c.context.screen.value,campaign:J_(globalThis.location.href),page:$m(t),timezone:c.context.timezone.value,...c.autoTrack.enabled.value&&{autoTrack:{...c.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:c.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:af(),messageId:Qi(),userId:s.userId||c.session.userId.value};Hs(c.storage.entries.value.anonymousId?.type)?r.anonymousId=c.session.anonymousId.value:r.anonymousId=Yn(),c.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),s.type==="identify"&&(r.context.traits=c.storage.entries.value.userTraits?.type!==Kt?K(c.session.userTraits.value):s.context.traits),s.type==="group"&&((s.groupId||c.session.groupId.value)&&(r.groupId=s.groupId||c.session.groupId.value),(s.traits||c.session.groupTraits.value)&&(r.traits=c.storage.entries.value.groupTraits?.type!==Kt?K(c.session.groupTraits.value):s.traits));let n=we(s,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),Vm(n,e,i),Mm(n,i),n.integrations=Gm(n.integrations),n},Xn=class{constructor(e){this.logger=e}generatePageEvent(e,t,i,r){let n=i??{};return n=Fm(n,r),Bs({properties:n,name:t,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,t,i){return Bs({properties:t,event:e,type:"track"},i,void 0,this.logger)}generateIdentifyEvent(e,t,i){return Bs({userId:e,type:"identify",context:{traits:t}},i,void 0,this.logger)}generateAliasEvent(e,t,i){let n=Bs({previousId:t,type:"alias"},i,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,t,i){let r={type:"group"};return e&&(r.groupId=e),t&&(r.traits=t),Bs(r,i,void 0,this.logger)}create(e){let t;switch(e.type){case"page":t=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":t=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":t=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":t=this.generateAliasEvent(e.to,e.from,e.options);break;default:t=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return t}},Jn=class{constructor(e,t,i,r){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=i,this.logger=r,this.eventFactory=new Xn(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let t=this.eventFactory.create(e);this.eventRepository.enqueue(t,e.callback)}},Qn=class{constructor(e,t,i,r,n){this.storeManager=t,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=i,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=c.loadOptions.value,i;us(e)&&typeof e=="string"&&(i=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(i??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??Q.sessionInfo;e={autoTrack:t.autoTrack&&i.manualTrack!==!0,timeout:t.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=Q.sessionInfo:t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=Q.sessionInfo;c.session.sessionInfo.value=e,c.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(c.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{let i=e||Wu();this.setInitialReferrer(i),this.setInitialReferringDomain(zu(i))}}isPersistenceEnabledForStorageEntry(e){return Hs(c.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=c.storage.entries.value,t=[Be,He,We];Object.keys(e).forEach(i=>{let r=i,n=e[r]?.type,o=this.storeManager?.getStore(as[n]);o&&t.forEach(a=>{let l=this.storeManager?.getStore(as[a]);if(l&&a!==n){let u=l.get(os[r]);Bg(u)&&o.set(os[r],u),l.remove(os[r])}})})}migrateStorageIfNeeded(e,t){if(!c.storage.migrate.value)return;let i=e??[];i.length===0&&[Uu,Bu,Vu].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(t??Object.keys(os)).forEach(n=>{let o=os[n];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);tt(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=c.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let t,i=c.loadOptions.value.sessions?.timeout;Ji(i)?t=i:(this.logger.warn(wp(Gt,i,In)),t=In),t===0&&(this.logger.warn(Ap(Gt)),e=!1),t>0&&t<Il&&this.logger.warn(Ip(Gt,t,Il));let r=this.getCutOffInfo(t);return{timeout:t,autoTrack:e,cutOff:r}}getCutOffInfo(e){let t=c.loadOptions.value.sessions.cutOff,i,r=!1;return t.enabled===!0&&(i=t.duration,r=!0,Ji(i)?i<e&&(this.logger.warn(Rp(Gt,i,e)),r=!1):(this.logger.warn(Tp(Gt,i,Al)),i=Al)),{enabled:r,duration:i}}onError(e,t,i){this.errorHandler.onError({error:e,context:Gt,customMessage:t,groupingHash:i})}getEncryptedCookieData(e,t){let i=[];return e.forEach(r=>{let n=t?.encrypt(et(r.value,!1,[],this.logger));us(n)&&i.push({name:r.name,value:n})}),i}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:c.serverCookies.dataServiceUrl.value,options:{method:"POST",data:et({reqType:"setCookies",workspaceId:c.source.value?.workspaceId,data:{options:{maxAge:c.storage.cookie.value?.maxage,path:c.storage.cookie.value?.path,domain:c.storage.cookie.value?.domain,sameSite:c.storage.cookie.value?.samesite,secure:c.storage.cookie.value?.secure,expires:c.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:t})}setServerSideCookies(e,t,i){let r=Object.keys(e),n=()=>r.map(u=>({name:e[u].name,value:c.session[u].value})),o={};r.forEach(u=>{o[e[u].name]=i?.get(e[u].name)});let a=()=>{r.forEach(u=>{this.serverSideCookiesRequestInProgress[u]=!1})},l=()=>{n().forEach(u=>{t&&t(u.name,u.value)})};try{let u={};r.forEach(h=>{u[e[h].name]=c.session[h].value});let d=this.getEncryptedCookieData(n(),i);d.length>0?this.makeRequestToSetCookie(d,(h,f)=>{a(),f?.xhr?.status===200?n().forEach(g=>{let p=o[g.name],v=i?.get(g.name);et(u[g.name],!1,[])!==et(v,!1,[])&&(Ve(p)&&Ve(v)&&this.logger.error(vp(g.name)),t&&t(g.name,g.value))}):(this.logger.error(pp(f?.xhr?.status)),l())}):(l(),a())}catch(u){this.onError(u,xl,xl),l(),a()}}syncValueToStorage(e){let t=c.storage.entries.value,i=t[e]?.type;if(Hs(i)){let r=this.storeManager.getStore(as[i]),n=t[e]?.key,o=c.session[e].value;o&&(re(o)||yt(o))?c.serverCookies.isEnabledServerSideCookies.value&&i===Be?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:n}};this.setServerSideCookies(a,(l,u)=>{r?.set(l,u)},r)},Qp)):r?.set(n,o):r?.remove(n)}}registerEffects(){Gu.forEach(e=>{at(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let i=e;(!re(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&t&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),i=i||Yn()):i=Q.anonymousId,c.session.anonymousId.value=i}getAnonymousId(e){let t=c.storage.entries.value.anonymousId?.type;if(Hs(t)){let i=c.session.anonymousId.value;(!i||i===Q.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",Ze,e)),c.session.anonymousId.value=i||Yn()}return c.session.anonymousId.value}getEntryValue(e){let t=c.storage.entries.value,i=t[e]?.type;if(Hs(i)){let r=this.storeManager?.getStore(as[i]);this.migrateStorageIfNeeded([r],[e]);let n=t[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let t=Ze(Be);return t?.isEnabled?t.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?c.session[e].value:this.getEntryValue(e)}getUserId(){return this.getUserSessionValue("userId")}getUserTraits(){return this.getUserSessionValue("userTraits")}getGroupId(){return this.getUserSessionValue("groupId")}getGroupTraits(){return this.getUserSessionValue("groupTraits")}getInitialReferrer(){return this.getUserSessionValue("initialReferrer")}getInitialReferringDomain(){return this.getUserSessionValue("initialReferringDomain")}getSessionInfo(){return this.getUserSessionValue("sessionInfo")}getAuthToken(){return this.getUserSessionValue("authToken")}getSessionId(){let e=this.getSessionInfo()??Q.sessionInfo;return e.autoTrack&&!Xl(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??Q.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=c.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),c.session.sessionInfo.value=e,c.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=c.session,{manualTrack:t,autoTrack:i,timeout:r,cutOff:n}=e.sessionInfo.value;if(i){let o={...Q.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=c,i=Lm(e);Te(()=>{Object.keys(Q).forEach(r=>{let n=r;if(i.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[n].value=Q[n];break}})})}setUserId(e){c.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:Q.userId}setUserTraits(e){c.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ne(e)?we(c.session.userTraits.value??Q.userTraits,e):Q.userTraits}setGroupId(e){c.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:Q.groupId}setGroupTraits(e){c.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ne(e)?we(c.session.groupTraits.value??Q.groupTraits,e):Q.groupTraits}setInitialReferrer(e){c.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:Q.initialReferrer}setInitialReferringDomain(e){c.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:Q.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(Xl(e))t=Nm(e);else{let i=Date.now(),r=e.timeout;t.expiresAt=i+r}if(Ju(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let i=Dm(t.cutOff);t.cutOff.expiresAt=i}c.session.sessionInfo.value=t}start(e){c.session.sessionInfo.value=xm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){c.session.sessionInfo.value=Q.sessionInfo}setAuthToken(e){c.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:Q.authToken}},Hm=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],jm=Hm,zm=(s,e)=>{let t=K(e);return re(t.setCookieDomain)||(t.setCookieDomain=void 0),["Strict","Lax","None"].includes(t.sameSiteCookie)||(t.sameSiteCookie=void 0),t.secureCookie=nt(t.secureCookie,s.secureCookie),t.sameDomainCookiesOnly=nt(t.sameDomainCookiesOnly,s.sameDomainCookiesOnly),["none","default","full"].includes(t.uaChTrackLevel)||(t.uaChTrackLevel=void 0),t.integrations=ft(t.integrations),Array.isArray(t.plugins)||(t.plugins=jm),t.useGlobalIntegrationsConfigInEvents=nt(t.useGlobalIntegrationsConfigInEvents,s.useGlobalIntegrationsConfigInEvents),t.bufferDataPlaneEventsUntilReady=nt(t.bufferDataPlaneEventsUntilReady,s.bufferDataPlaneEventsUntilReady),t.sendAdblockPage=nt(t.sendAdblockPage,s.sendAdblockPage),t.useServerSideCookies=nt(t.useServerSideCookies,s.useServerSideCookies),re(t.dataServiceEndpoint)||(t.dataServiceEndpoint=void 0),t.sendAdblockPageOptions=ft(t.sendAdblockPageOptions),t.loadIntegration=nt(t.loadIntegration,s.loadIntegration),yt(t.storage)?(t.storage.migrate=nt(t.storage.migrate,s.storage?.migrate),t.storage.cookie=ft(t.storage.cookie),t.storage.encryption=ft(t.storage.encryption),t.storage=Hi(t.storage)):t.storage=void 0,t.destinationsQueueOptions=ft(t.destinationsQueueOptions),t.queueOptions=ft(t.queueOptions),t.lockIntegrationsVersion=nt(t.lockIntegrationsVersion,s.lockIntegrationsVersion),t.lockPluginsVersion=nt(t.lockPluginsVersion,s.lockPluginsVersion),Xu(t.dataPlaneEventsBufferTimeout)||(t.dataPlaneEventsBufferTimeout=void 0),t.beaconQueueOptions=ft(t.beaconQueueOptions),t.preConsent=ft(t.preConsent),t.sourceConfigurationOverride=ft(t.sourceConfigurationOverride),we(s,Hi(t))},Jl="dataplaneEventsQueue",Ql="destinationsEventsQueue",Km="transformEvent",qm=(s,e)=>Object.keys(s).filter(t=>s[t]!==!0||!e[t]).reduce((t,i)=>{let r=K(t);return r[i]=s[i],r},{}),Wm=(s,e)=>{let t=K(s),i=e.nativeDestinations.integrationsConfig.value,r=qm(s.integrations,i);return t.integrations=we(i,r),t},Ym=s=>s.consents.preConsent.value.enabled&&s.consents.preConsent.value.events?.delivery==="buffer",Gi=(s,e,t,i)=>{if(ee(s))if(x(s))try{s(...e)}catch(r){i.error(Dp(t),r)}else i.error(Eu(t))},Zn=class{constructor(e,t,i,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=i,this.logger=n,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${Jl}.init`,c,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${Km}.init`,c,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${Ql}.init`,c,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),at(()=>{c.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=Ym(c),t;at(()=>{let i=c.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&c.nativeDestinations.clientDestinationsReady.value===!1;(c.nativeDestinations.activeDestinations.value.some(n=>t_(n))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(t),this.dataplaneEventsQueue?.start())}),c.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(t=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},c.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(c.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,t){let i=Wm(e,c);this.pluginsManager.invokeSingle(`${Jl}.enqueue`,c,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let r=K(e);this.pluginsManager.invokeSingle(`${Ql}.enqueue`,c,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${no}`;Gi(t,[i],n,this.logger)}},Zl=s=>{let e=new CustomEvent(s,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},Xm=s=>re(s)&&s.trim().length>0,Jm=s=>ds(s),eo=class{constructor(){this.preloadBuffer=new Pn,this.initialized=!1,this.errorHandler=Lu,this.logger=bt,this.externalSrcLoader=new Ki(this.logger),this.httpClient=Cu,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new Wn(this.httpClient,this.errorHandler,this.logger)}load(e,t,i={}){if(!c.lifecycle.status.value){if(!Xm(e)){this.logger.error(lp(xi,e));return}if(!Jm(t)){this.logger.error(up(xi,t));return}Te(()=>{c.lifecycle.writeKey.value=K(e),c.lifecycle.dataPlaneUrl.value=K(t),c.loadOptions.value=zm(c.loadOptions.value,i),c.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(c.loadOptions.value.logLevel??yu),qs("state",c,e),this.startLifecycle()}}startLifecycle(){at(()=>{try{switch(c.lifecycle.status.value){case"mounted":this.onMounted();break;case"browserCapabilitiesReady":this.onBrowserCapabilitiesReady();break;case"configured":this.onConfigured();break;case"pluginsLoading":break;case"pluginsReady":this.onPluginsReady();break;case"initialized":this.onInitialized();break;case"loaded":this.onLoaded();break;case"destinationsLoading":break;case"destinationsReady":this.onDestinationsReady();break;case"ready":this.onReady();break;default:break}}catch(e){let t="Failed to load the SDK";this.errorHandler.onError({error:e,context:xi,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){xf(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),c.consents.preConsent.value.enabled===!0?c.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(t=>this.preloadBuffer.enqueue(K(t)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Lf([...e],this)}}prepareInternalServices(){this.pluginsManager=new Fn(Zv,this.errorHandler,this.logger),this.storeManager=new jn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Kn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Qn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Zn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Jn(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){c.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(c.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),c.consents.enabled.value&&!c.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",c,this.logger),c.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",c,this.storeManager,this.logger)),this.eventManager?.init(),c.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Te(()=>{c.lifecycle.loaded.value=!0,c.lifecycle.status.value="loaded"}),this.initialized=!0;let e=c.loadOptions.value.onLoaded;Gi(e,[globalThis.rudderanalytics],Xg,this.logger),Zl("RSA_Initialised")}onReady(){c.lifecycle.status.value="readyExecuted",c.eventBuffer.readyCallbacksArray.value.forEach(e=>{Gi(e,[],mn,this.logger)}),Zl("RSA_Ready")}processBufferedEvents(){let e=c.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let t=e.shift();if(c.eventBuffer.toBeProcessedArray.value=e,t){let i=t[0];x(this[i])&&this[i](...t.slice(1),!0)}e=c.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(c.lifecycle.status.value==="destinationsLoading"||c.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",c,this.pluginsManager,this.errorHandler,this.logger);let e=c.nativeDestinations.activeDestinations.value.length;if(e===0){Te(()=>{c.nativeDestinations.clientDestinationsReady.value=!0,c.lifecycle.status.value="destinationsReady"});return}c.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",c,this.externalSrcLoader,this.errorHandler,this.logger),at(()=>{c.nativeDestinations.initializedDestinations.value.length+c.nativeDestinations.failedDestinations.value.length===e&&Te(()=>{c.lifecycle.status.value="destinationsReady",c.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){c.lifecycle.status.value!=="ready"&&Te(()=>{c.lifecycle.status.value="ready"})}ready(e,t=!1){let i="ready";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!x(e)){this.logger.error(Eu(mn));return}c.lifecycle.status.value==="readyExecuted"?Gi(e,[],mn,this.logger):c.eventBuffer.readyCallbacksArray.value=[...c.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let i="page";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),c.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),c.capabilities.isAdBlocked.value===!0&&e.category!==wl&&this.page(zi(wl,bf,{path:Ef},c.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let i="track";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event - ${e.name}`),c.metrics.triggered.value+=1,this.eventManager?.addEvent({type:i,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,t=!1){let i="identify";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),c.metrics.triggered.value+=1,e.userId&&c.session.userId.value&&e.userId!==c.session.userId.value&&this.reset(),Ve(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:i,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,t=!1){let i="alias";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),c.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:i,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,t=!1){let i="group";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),c.metrics.triggered.value+=1,Ve(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:i,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,t=!1){let i="reset";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,i=!1){let r="setAnonymousId";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[r,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,t)}getUserId(){return c.session.userId.value}getUserTraits(){return c.session.userTraits.value}getGroupId(){return c.session.groupId.value}getGroupTraits(){return c.session.groupTraits.value}startSession(e,t=!1){let i="startSession";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let t="endSession";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[t]];return}this.errorHandler.leaveBreadcrumb(`New ${t} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,t=!1){let i="consent";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Te(()=>{c.consents.preConsent.value={...c.consents.preConsent.value,enabled:!1},c.consents.postConsent.value=sm(e);let{initialized:r,consentsData:n}=Ku(c.consents.postConsent.value.consentManagement,this.logger);c.consents.initialized.value=r,c.consents.data.value=n}),c.consents.enabled.value&&!c.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",c,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(t)}sendTrackingEvents(e){if(c.consents.postConsent.value.trackConsent){let t=ro(Sf);e?c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(c.consents.postConsent.value.sendPageEvent){let t=zi();e?c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,i=!1){let r="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,c,this.logger);else{if(c.lifecycle.loaded.value){this.logger.error(Hp(xi,e));return}c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[r,e,t]]}}},jt=class jt{constructor(){le(this,"analyticsInstances",{});le(this,"defaultAnalyticsKey","");le(this,"logger",bt);try{if(jt.globalSingleton)return jt.globalSingleton;jt.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.getSessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),jt.globalSingleton=this,c.autoTrack.pageLifecycle.pageViewId.value=Qi(),c.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){fe(e)}}createSafeAnalyticsInstance(){c.lifecycle.safeAnalyticsInstance.value={page:this.page.bind(this),track:this.track.bind(this),identify:this.identify.bind(this),alias:this.alias.bind(this),group:this.group.bind(this),getAnonymousId:this.getAnonymousId.bind(this),getUserId:this.getUserId.bind(this),getUserTraits:this.getUserTraits.bind(this),getGroupId:this.getGroupId.bind(this),getGroupTraits:this.getGroupTraits.bind(this),getSessionId:this.getSessionId.bind(this)}}static initializeGlobalResources(){Lu.init(),ho.configure(),uo.configure(),co.configure(),Xi.configure()}setDefaultInstanceKey(e){re(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return(!re(t)||!t)&&(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new eo),this.analyticsInstances[t]}catch(t){fe(t);return}}load(e,t,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let r=hu(js);Nf(r),qs(js,K(r)),this.getAnalyticsInstance(e)?.load(e,t,Y(i))}catch(r){fe(r)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:i}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=t??{},{events:a=[_n.UNLOADED],enabled:l=r,options:u=n}=o??{};c.autoTrack.pageLifecycle.enabled.value=l,c.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,i,u)}setupPageUnloadTracking(e,t,i){(e.length===0||e.includes(_n.UNLOADED))&&(t===!0?of(r=>{if(r===!1&&c.lifecycle.loaded.value){let n=Date.now(),o=n-c.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(_n.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:ou(new Date(n))})}},!0):this.logger.warn(Bp(Qg)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=Df(e);qs(js,K([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(Y(e))}catch(t){fe(t)}}page(e,t,i,r,n){try{this.getAnalyticsInstance()?.page(zi(Y(e),Y(t),Y(i),Y(r),Y(n)))}catch(o){fe(o)}}track(e,t,i,r){try{this.getAnalyticsInstance()?.track(ro(Y(e),Y(t),Y(i),Y(r)))}catch(n){fe(n)}}identify(e,t,i,r){try{this.getAnalyticsInstance()?.identify(su(Y(e),Y(t),Y(i),Y(r)))}catch(n){fe(n)}}alias(e,t,i,r){try{this.getAnalyticsInstance()?.alias(iu(Y(e),Y(t),Y(i),Y(r)))}catch(n){fe(n)}}group(e,t,i,r){try{this.getAnalyticsInstance()?.group(ru(Y(e),Y(t),Y(i),Y(r)))}catch(n){fe(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(Y(e))}catch(t){fe(t)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(Y(e))}catch(t){fe(t);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(Y(e),Y(t))}catch(i){fe(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){fe(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){fe(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){fe(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){fe(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(Y(e))}catch(t){fe(t)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){fe(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){fe(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(Y(e))}catch(t){fe(t)}}consent(e){try{this.getAnalyticsInstance()?.consent(Y(e))}catch(t){fe(t)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(Y(e),Y(t))}catch(i){fe(i)}}};le(jt,"globalSingleton",null);hs=jt});var Zu,ec,fo,Qu,tc,sc,ic,rc,Ys=Fe(()=>{"use strict";Zu="https://deriv.com/cdn-cgi/trace",ec="https://cdn.growthbook.io",fo="https://deriv-dataplane.rudderstack.com",Qu="https://ph.deriv.com",tc="https://us.posthog.com",sc=()=>{if(typeof window>"u")return Qu;let s=window.location.hostname;return s.includes(".deriv.me")?"https://ph.deriv.me":s.includes(".deriv.be")?"https://ph.deriv.be":s.includes(".deriv.ae")?"https://ph.deriv.ae":Qu},ic=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],rc=["deriv.com","derivcrypto.com","besquare.my","besquare.com.my","ewallet.exchange","champion-fx.com","opalstraits.com","binary.com","binary.marketing","championgbs.com","4x.my","re-work.dev","regentmarkets.com","4x.com","binary.me","deriv.team","firstsource.io","firstsource.tech","deriv.hr","vmgbpo.net","mailisk.net","mailosaur.net","mobileapps.mailisk.net","w3e180zd.mailosaur.net"]});function ir(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)s[i]=t[i]}return s}function po(s,e){function t(r,n,o){if(!(typeof document>"u")){o=ir({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=r+"="+s.write(n,r)+a}}function i(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var n=document.cookie?document.cookie.split("; "):[],o={},a=0;a<n.length;a++){var l=n[a].split("="),u=l.slice(1).join("=");try{var d=decodeURIComponent(l[0]);if(o[d]=s.read(u,d),r===d)break}catch{}}return r?o[r]:o}}return Object.create({set:t,get:i,remove:function(r,n){t(r,"",ir({},n,{expires:-1}))},withAttributes:function(r){return po(this.converter,ir({},this.attributes,r))},withConverter:function(r){return po(ir({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(s)}})}var Qm,nc,oc=Fe(()=>{"use strict";Qm={read:function(s){return s[0]==='"'&&(s=s.slice(1,-1)),s.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(s){return encodeURIComponent(s).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};nc=po(Qm,{path:"/"})});var Ct,nr,Xs,rr,ac,qt,lc,uc,Js=Fe(()=>{"use strict";oc();Ys();Ct=(s,e)=>(...t)=>{e()&&console.log(`[ANALYTIC]${s}`,...t)},nr=s=>{let e=s.split("@")[1]?.toLowerCase();return e?rc.includes(e):!1},Xs=s=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s),rr=null,ac=async()=>{if(rr)return rr;let s=JSON.parse(nc.get("website_status")||"{}")?.clients_country;return rr=(async()=>{try{let e=await fetch(Zu).catch(()=>null);if(!e)return s||"";let t=await e.text().catch(()=>"");return t?Object.fromEntries(t.split(`
|
|
5
|
-
`).map(r=>r.split("=",2))).loc?.toLowerCase()||s||"":s||""}catch{return s||""}})(),rr},qt=s=>{if(s==null||typeof s!="object")return s;if(Array.isArray(s)){let i=[];for(let r=0;r<s.length;r++){let n=qt(s[r]);n!=null&&i.push(n)}return i.length?i:void 0}let e={},t=!1;for(let i in s){if(!Object.prototype.hasOwnProperty.call(s,i))continue;let r=qt(s[i]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[i]=r,t=!0)}return t?e:void 0},lc=(s,e)=>{for(let t in s){if(!Object.prototype.hasOwnProperty.call(s,t))continue;let i=s[t];i&&typeof i=="object"&&!Array.isArray(i)?lc(i,e):e[t]=i}},uc=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return s;let e={};return lc(s,e),e}});function mc(){return _c}function vo(s){let e=2166136261,t=s.length;for(let i=0;i<t;i++)e^=s.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Qs(s,e,t){return t===2?vo(vo(s+e)+"")%1e4/1e4:t===1?vo(e+s)%1e3/1e3:null}function ey(s){return s<=0?[]:new Array(s).fill(1/s)}function ur(s,e){return s>=e[0]&&s<e[1]}function yc(s,e){let t=Qs("__"+e[0],s,1);return t===null?!1:t>=e[1]&&t<e[2]}function bc(s,e){for(let t=0;t<e.length;t++)if(ur(s,e[t]))return t;return-1}function mo(s){try{let e=s.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function cr(s,e){if(!e.length)return!1;let t=!1,i=!1;for(let r=0;r<e.length;r++){let n=iy(s,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else t=!0,n&&(i=!0)}return i||!t}function ty(s,e,t){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(s)}catch{return!1}}function sy(s,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[s.host,t.host,!1],[s.pathname,t.pathname,!0]];return t.hash&&i.push([s.hash,t.hash,!1]),t.searchParams.forEach((r,n)=>{i.push([s.searchParams.get(n)||"",r,!1])}),!i.some(r=>!ty(r[0],r[1],r[2]))}catch{return!1}}function iy(s,e,t){try{let i=new URL(s,"https://_");if(e==="regex"){let r=mo(t);return r?r.test(i.href)||r.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return sy(i,t);return!1}catch{return!1}}function Ec(s,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=ey(s);t=t||i,t.length!==s&&(t=i);let r=t.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(t=i);let n=0;return t.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Sc(s,e,t){if(!e)return null;let i=e.split("?")[1];if(!i)return null;let r=i.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===s).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<t?r[0]:null}function kc(s){try{return s()}catch(e){return console.error(e),!1}}async function Yt(s,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||_c.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let i=await t.importKey("raw",_o(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=s.split("."),o=await t.decrypt({name:"AES-CBC",iv:_o(r)},i,_o(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Zs(s){return typeof s=="string"?s:JSON.stringify(s)}function je(s){typeof s=="number"&&(s=s+""),(!s||typeof s!="string")&&(s="0");let e=s.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function wc(){let s;try{s="1.6.5"}catch{s=""}return s}function Tc(s,e){let t,i;try{t=new URL(s),i=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return t.searchParams.forEach((r,n)=>{i.searchParams.has(n)||i.searchParams.set(n,r)}),i.toString()}function vc(s){return typeof s=="object"&&s!==null}function dr(s){return s.urlPatterns&&s.variations.some(e=>vc(e)&&"urlRedirect"in e)?"redirect":s.variations.some(e=>vc(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function hr(s,e){return new Promise(t=>{let i=!1,r,n=o=>{i||(i=!0,r&&clearTimeout(r),t(o||null))};e&&(r=setTimeout(()=>n(),e)),s.then(o=>n(o)).catch(()=>n())})}var _c,_o,ei=Fe(()=>{"use strict";_c={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};_o=s=>Uint8Array.from(atob(s),e=>e.charCodeAt(0))});function Ic(s){Object.assign(Pe,s),Pe.backgroundSync||wo()}async function Oc({instance:s,timeout:e,skipCache:t,allowStale:i,backgroundSync:r}){return r||(Pe.backgroundSync=!1),ay({instance:s,allowStale:i,timeout:e,skipCache:t})}function ry(s){let e=ti(s),t=vs.get(e)||new Set;t.add(s),vs.set(e,t)}function Pc(s){vs.forEach(e=>e.delete(s))}function ny(){_s.forEach(s=>{s&&(s.state="idle",So(s))})}function oy(){_s.forEach(s=>{s&&s.state==="idle"&&ko(s)})}async function Ac(){try{if(!lt.localStorage)return;await lt.localStorage.setItem(Pe.cacheKey,JSON.stringify(Array.from(Et.entries())))}catch{}}async function ay({instance:s,allowStale:e,timeout:t,skipCache:i}){let r=ti(s),n=bo(s),o=new Date,a=new Date(o.getTime()-Pe.maxAge+Pe.staleTTL);await ly();let l=!Pe.disableCache&&!i?Et.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&ms.add(r),l.staleAt<o?yo(s):Eo(s),{data:l.data,success:!0,source:"cache"}):await hr(yo(s),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ti(s){let[e,t]=s.getApiInfo();return`${e}||${t}`}function bo(s){let e=ti(s);if(!("isRemoteEval"in s)||!s.isRemoteEval())return e;let t=s.getAttributes(),i=s.getCacheKeyAttributes()||Object.keys(s.getAttributes()),r={};i.forEach(a=>{r[a]=t[a]});let n=s.getForcedVariations(),o=s.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function ly(){if(!Rc){Rc=!0;try{if(lt.localStorage){let s=await lt.localStorage.getItem(Pe.cacheKey);if(!Pe.disableCache&&s){let e=JSON.parse(s);e&&Array.isArray(e)&&e.forEach(([t,i])=>{Et.set(t,{...i,staleAt:new Date(i.staleAt)})}),Cc()}}}catch{}if(!Pe.disableIdleStreams){let s=ps.startIdleListener();s&&(ps.stopIdleListener=s)}}}function Cc(){let s=Array.from(Et.entries()).map(([t,i])=>({key:t,staleAt:i.staleAt.getTime()})).sort((t,i)=>t.staleAt-i.staleAt),e=Math.min(Math.max(0,Et.size-Pe.maxEntries),Et.size);for(let t=0;t<e;t++)Et.delete(s[t].key)}function Dc(s,e,t){let i=t.dateUpdated||"",r=new Date(Date.now()+Pe.staleTTL),n=Pe.disableCache?void 0:Et.get(e);if(n&&i&&n.version===i){n.staleAt=r,Ac();return}Pe.disableCache||(Et.set(e,{data:t,version:i,staleAt:r,sse:ms.has(s)}),Cc()),Ac();let o=vs.get(s);o&&o.forEach(a=>uy(a,t))}async function uy(s,e){await s.setPayload(e||s.getPayload())}async function yo(s){let{apiHost:e,apiRequestHeaders:t}=s.getApiHosts(),i=s.getClientKey(),r="isRemoteEval"in s&&s.isRemoteEval(),n=ti(s),o=bo(s),a=gr.get(o);return a||(a=(r?ps.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:s.getAttributes(),forcedVariations:s.getForcedVariations(),forcedFeatures:Array.from(s.getForcedFeatures().entries()),url:s.getUrl()},headers:t}):ps.fetchFeaturesCall({host:e,clientKey:i,headers:t})).then(u=>{if(!u.ok)throw new Error(`HTTP error: ${u.status}`);return u.headers.get("x-sse-support")==="enabled"&&ms.add(n),u.json()}).then(u=>(Dc(n,o,u),Eo(s),gr.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(gr.delete(o),{data:null,source:"error",success:!1,error:u})),gr.set(o,a)),a}function Eo(s,e=!1){let t=ti(s),i=bo(s),{streamingHost:r,streamingHostRequestHeaders:n}=s.getApiHosts(),o=s.getClientKey();if(e&&ms.add(t),Pe.backgroundSync&&ms.has(t)&<.EventSource){if(_s.has(t))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let u=vs.get(t);u&&u.forEach(d=>{yo(d)})}else if(l.type==="features"){let u=JSON.parse(l.data);Dc(t,i,u)}a.errors=0}catch{Nc(a)}},errors:0,state:"active"};_s.set(t,a),ko(a)}}function Nc(s){if(s.state!=="idle"&&(s.errors++,s.errors>3||s.src&&s.src.readyState===2)){let e=Math.pow(3,s.errors-3)*(1e3+Math.random()*1e3);So(s),setTimeout(()=>{["idle","active"].includes(s.state)||ko(s)},Math.min(e,3e5))}}function So(s){s.src&&(s.src.onopen=null,s.src.onerror=null,s.src.close(),s.src=null,s.state==="active"&&(s.state="disabled"))}function ko(s){s.src=ps.eventSourceCall({host:s.host,clientKey:s.clientKey,headers:s.headers}),s.state="active",s.src.addEventListener("features",s.cb),s.src.addEventListener("features-updated",s.cb),s.src.onerror=()=>Nc(s),s.src.onopen=()=>{s.errors=0}}function cy(s,e){So(s),_s.delete(e)}function wo(){ms.clear(),_s.forEach(cy),vs.clear(),ps.stopIdleListener()}function fr(s,e){if(e.streaming){if(!s.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&Eo(s,!0),ry(s)}}var Pe,lt,ps,vs,Rc,Et,gr,_s,ms,xc=Fe(()=>{"use strict";ei();Pe={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},lt=mc(),ps={fetchFeaturesCall:({host:s,clientKey:e,headers:t})=>lt.fetch(`${s}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:s,clientKey:e,payload:t,headers:i})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(t)};return lt.fetch(`${s}/api/eval/${e}`,r)},eventSourceCall:({host:s,clientKey:e,headers:t})=>t?new lt.EventSource(`${s}/sub/${e}`,{headers:t}):new lt.EventSource(`${s}/sub/${e}`),startIdleListener:()=>{let s;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(s),oy()):document.visibilityState==="hidden"&&(s=window.setTimeout(ny,Pe.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(lt.localStorage=globalThis.localStorage)}catch{}vs=new Map,Rc=!1,Et=new Map,gr=new Map,_s=new Map,ms=new Set});function hy(s){return s==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[s]}}function yr(s){var e=mr.get(s);return e||(e={element:s,attributes:{}},mr.set(s,e)),e}function br(s,e,t,i,r){var n=t(s),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:s,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(s);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,r(o))}}),mutationRunner:r,setValue:i,getCurrentValue:t};return e==="position"&&s.parentNode?o.observer.observe(s.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(s,hy(e)),o}function Er(s,e){var t=e.getCurrentValue(e.el);e.virtualValue=s,s&&typeof s!="string"?(!t||s.parentNode!==t.parentNode||s.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,Lc()):s!==t&&(e.isDirty=!0,Lc())}function gy(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),Er(Ay(e),s)}function fy(s){var e=new Set(s.originalValue.split(/\s+/).filter(Boolean));s.mutations.forEach(function(t){return t.mutate(e)}),Er(Array.from(e).filter(Boolean).join(" "),s)}function py(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),Er(e,s)}function vy(s){var e=s.parentSelector,t=s.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var r=t?document.querySelector(t):null;return t&&!r?null:{parentNode:i,insertBeforeNode:r}}function _y(s){var e=s.originalValue;s.mutations.forEach(function(t){var i=t.mutate(),r=vy(i);e=r||e}),Er(e,s)}function Fc(s){var e=yr(s);return e.html||(e.html=br(s,"html",my,yy,gy)),e.html}function Mc(s){var e=yr(s);return e.position||(e.position=br(s,"position",by,Ey,_y)),e.position}function Uc(s){var e=yr(s);return e.classes||(e.classes=br(s,"class",ky,Sy,fy)),e.classes}function Bc(s,e){var t=yr(s);return t.attributes[e]||(t.attributes[e]=br(s,e,wy(e),Ty(e),py)),t.attributes[e]}function Ry(s,e){var t=mr.get(s);if(t)if(e==="html"){var i,r;(i=t.html)==null||(r=i.observer)==null||r.disconnect(),delete t.html}else if(e==="class"){var n,o;(n=t.classes)==null||(o=n.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var u,d,h;(u=t.attributes)==null||(d=u[e])==null||(h=d.observer)==null||h.disconnect(),delete t.attributes[e]}}function Ay(s){return pr||(pr=document.createElement("div")),pr.innerHTML=s,pr.innerHTML}function vr(s,e,t){if(t.isDirty){t.isDirty=!1;var i=t.virtualValue;t.mutations.length||Ry(s,e),t.setValue(s,i)}}function Iy(s,e){s.html&&vr(e,"html",s.html),s.classes&&vr(e,"class",s.classes),s.position&&vr(e,"position",s.position),Object.keys(s.attributes).forEach(function(t){vr(e,t,s.attributes[t])})}function Lc(){mr.forEach(Iy)}function Oy(s,e){var t=null;s.kind==="html"?t=Fc(e):s.kind==="class"?t=Uc(e):s.kind==="attribute"?t=Bc(e,s.attribute):s.kind==="position"&&(t=Mc(e)),t&&(t.mutations.push(s),t.mutationRunner(t))}function Py(s,e){var t=null;if(s.kind==="html"?t=Fc(e):s.kind==="class"?t=Uc(e):s.kind==="attribute"?t=Bc(e,s.attribute):s.kind==="position"&&(t=Mc(e)),!!t){var i=t.mutations.indexOf(s);i!==-1&&t.mutations.splice(i,1),t.mutationRunner(t)}}function Vc(s){if(!(s.kind==="position"&&s.elements.size===1)){var e=new Set(s.elements),t=document.querySelectorAll(s.selector);t.forEach(function(i){e.has(i)||(s.elements.add(i),Oy(s,i))})}}function Cy(s){s.elements.forEach(function(e){return Py(s,e)}),s.elements.clear(),Io.delete(s)}function $c(){Io.forEach(Vc)}function Dy(){typeof document>"u"||(To||(To=new MutationObserver(function(){$c()})),$c(),To.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Sr(s){return typeof document>"u"?Ao:(Io.add(s),Vc(s),{revert:function(){Cy(s)}})}function Ro(s,e){return Sr({kind:"html",elements:new Set,mutate:e,selector:s})}function Gc(s,e){return Sr({kind:"position",elements:new Set,mutate:e,selector:s})}function si(s,e){return Sr({kind:"class",elements:new Set,mutate:e,selector:s})}function _r(s,e,t){return dy.test(e)?e==="class"||e==="className"?si(s,function(i){var r=t(Array.from(i).join(" "));i.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return i.add(n)})}):Sr({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:s}):Ao}function Ny(s){var e=s.selector,t=s.action,i=s.value,r=s.attribute,n=s.parentSelector,o=s.insertBeforeSelector;if(r==="html"){if(t==="append")return Ro(e,function(a){return a+(i??"")});if(t==="set")return Ro(e,function(){return i??""})}else if(r==="class"){if(t==="append")return si(e,function(a){i&&a.add(i)});if(t==="remove")return si(e,function(a){i&&a.delete(i)});if(t==="set")return si(e,function(a){a.clear(),i&&a.add(i)})}else if(r==="position"){if(t==="set"&&n)return Gc(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(t==="append")return _r(e,r,function(a){return a!==null?a+(i??""):i??""});if(t==="set")return _r(e,r,function(){return i??""});if(t==="remove")return _r(e,r,function(){return null})}return Ao}var dy,Ao,mr,Io,my,yy,by,Ey,Sy,ky,wy,Ty,pr,To,xy,Hc,jc=Fe(()=>{"use strict";dy=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Ao={revert:function(){}},mr=new Map,Io=new Set;my=function(e){return e.innerHTML},yy=function(e,t){return e.innerHTML=t};by=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Ey=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};Sy=function(e,t){return t?e.className=t:e.removeAttribute("class")},ky=function(e){return e.className};wy=function(e){return function(t){var i;return(i=t.getAttribute(e))!=null?i:null}},Ty=function(e){return function(t,i){return i!==null?t.setAttribute(e,i):t.removeAttribute(e)}};Dy();xy={html:Ro,classes:si,attribute:_r,position:Gc,declarative:Ny},Hc=xy});function Dt(s,e,t){t=t||{};for(let[i,r]of Object.entries(e))switch(i){case"$or":if(!qc(s,r,t))return!1;break;case"$nor":if(qc(s,r,t))return!1;break;case"$and":if(!Uy(s,r,t))return!1;break;case"$not":if(Dt(s,r,t))return!1;break;default:if(!ii(r,Ly(s,i),t))return!1}return!0}function Ly(s,e){let t=e.split("."),i=s;for(let r=0;r<t.length;r++)if(i&&typeof i=="object"&&t[r]in i)i=i[t[r]];else return null;return i}function zc(s,e=!1){let t=`${s}${e?"/i":""}`;return Oo[t]||(Oo[t]=new RegExp(s.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Oo[t]}function ii(s,e,t,i=!1){if(typeof s=="string")return i?String(e).toLowerCase()===s.toLowerCase():e+""===s;if(typeof s=="number")return e*1===s;if(typeof s=="boolean")return e!==null&&!!e===s;if(s===null)return e===null;if(Array.isArray(s)||!Wc(s))return JSON.stringify(e)===JSON.stringify(s);for(let r in s)if(!My(r,e,s[r],t))return!1;return!0}function Wc(s){let e=Object.keys(s);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function $y(s){if(s===null)return"null";if(Array.isArray(s))return"array";let e=typeof s;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function Fy(s,e,t){if(!Array.isArray(s))return!1;let i=Wc(e)?r=>ii(e,r,t):r=>Dt(r,e,t);for(let r=0;r<s.length;r++)if(s[r]&&i(s[r]))return!0;return!1}function ys(s,e,t=!1){if(t){let i=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(s)?s.some(r=>e.some(n=>i(r)===i(n))):e.some(r=>i(s)===i(r))}return Array.isArray(s)?s.some(i=>e.includes(i)):e.includes(s)}function Kc(s,e,t,i=!1){if(!Array.isArray(s))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<s.length;o++)if(ii(e[r],s[o],t,i)){n=!0;break}if(!n)return!1}return!0}function My(s,e,t,i){switch(s){case"$veq":return je(e)===je(t);case"$vne":return je(e)!==je(t);case"$vgt":return je(e)>je(t);case"$vgte":return je(e)>=je(t);case"$vlt":return je(e)<je(t);case"$vlte":return je(e)<=je(t);case"$eq":return e===t;case"$ne":return e!==t;case"$lt":return e<t;case"$lte":return e<=t;case"$gt":return e>t;case"$gte":return e>=t;case"$exists":return t?e!=null:e==null;case"$in":return Array.isArray(t)?ys(e,t):!1;case"$ini":return Array.isArray(t)?ys(e,t,!0):!1;case"$inGroup":return ys(e,i[t]||[]);case"$notInGroup":return!ys(e,i[t]||[]);case"$nin":return Array.isArray(t)?!ys(e,t):!1;case"$nini":return Array.isArray(t)?!ys(e,t,!0):!1;case"$not":return!ii(t,e,i);case"$size":return Array.isArray(e)?ii(t,e.length,i):!1;case"$elemMatch":return Fy(e,t,i);case"$all":return Array.isArray(t)?Kc(e,t,i):!1;case"$alli":return Array.isArray(t)?Kc(e,t,i,!0):!1;case"$regex":try{return zc(t).test(e)}catch{return!1}case"$regexi":try{return zc(t,!0).test(e)}catch{return!1}case"$type":return $y(e)===t;default:return console.error("Unknown operator: "+s),!1}}function qc(s,e,t){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(Dt(s,e[i],t))return!0;return!1}function Uy(s,e,t){for(let i=0;i<e.length;i++)if(!Dt(s,e[i],t))return!1;return!0}var Oo,Yc=Fe(()=>{"use strict";ei();Oo={}});function Gy(s){let e=new Map;return s.global.forcedFeatureValues&&s.global.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),s.user.forcedFeatureValues&&s.user.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),e}function Hy(s){return s.global.forcedVariations&&s.user.forcedVariations?{...s.global.forcedVariations,...s.user.forcedVariations}:s.global.forcedVariations?s.global.forcedVariations:s.user.forcedVariations?s.user.forcedVariations:{}}async function bs(s){try{await s()}catch{}}function Xc(s,e,t){if(s.user.trackedExperiments){let r=Tr(e,t);if(s.user.trackedExperiments.has(r))return[];s.user.trackedExperiments.add(r)}s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(s.global.trackingCallback){let r=s.global.trackingCallback;i.push(bs(()=>r(e,t,s.user)))}if(s.user.trackingCallback){let r=s.user.trackingCallback;i.push(bs(()=>r(e,t)))}if(s.global.eventLogger){let r=s.global.eventLogger;i.push(bs(()=>r(Vy,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},s.user)))}return i}function jy(s,e,t){if(s.user.trackedFeatureUsage){let i=JSON.stringify(t.value);if(s.user.trackedFeatureUsage[e]===i)return;s.user.trackedFeatureUsage[e]=i,s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(s.global.onFeatureUsage){let i=s.global.onFeatureUsage;bs(()=>i(e,t,s.user))}if(s.user.onFeatureUsage){let i=s.user.onFeatureUsage;bs(()=>i(e,t))}if(s.global.eventLogger){let i=s.global.eventLogger;bs(()=>i(By,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},s.user))}}function kr(s,e){if(e.stack.evaluatedFeatures.has(s))return Nt(e,s,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(s),e.stack.id=s;let t=Gy(e);if(t.has(s))return Nt(e,s,t.get(s),"override");if(!e.global.features||!e.global.features[s])return Nt(e,s,null,"unknownFeature");let i=e.global.features[s];if(i.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of i.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let u=kr(l.id,e);if(u.source==="cyclicPrerequisite")return Nt(e,s,null,"cyclicPrerequisite");let d={value:u.value};if(!Dt(d,l.condition||{})){if(l.gate)return Nt(e,s,null,"prerequisite");continue e}}if(n.filters&&Zc(n.filters,e))continue;if("force"in n){if(n.condition&&!Qc(n.condition,e)||!zy(e,n.seed||s,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach(l=>{!Xc(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),Nt(e,s,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||s};"coverage"in n&&(o.coverage=n.coverage),n.weights&&(o.weights=n.weights),n.hashAttribute&&(o.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(o.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(o.disableStickyBucketing=n.disableStickyBucketing),n.bucketVersion!==void 0&&(o.bucketVersion=n.bucketVersion),n.minBucketVersion!==void 0&&(o.minBucketVersion=n.minBucketVersion),n.namespace&&(o.namespace=n.namespace),n.meta&&(o.meta=n.meta),n.ranges&&(o.ranges=n.ranges),n.name&&(o.name=n.name),n.phase&&(o.phase=n.phase),n.seed&&(o.seed=n.seed),n.hashVersion&&(o.hashVersion=n.hashVersion),n.filters&&(o.filters=n.filters),n.condition&&(o.condition=n.condition);let{result:a}=wr(o,s,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return Nt(e,s,a.value,"experiment",n.id,o,a)}}return Nt(e,s,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function wr(s,e,t){let i=s.key,r=s.variations.length;if(r<2)return{result:ue(t,s,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:ue(t,s,-1,!1,e)};if(s=Ky(s,t),s.urlPatterns&&!cr(t.user.url||"",s.urlPatterns))return{result:ue(t,s,-1,!1,e)};let n=Sc(i,t.user.url||"",r);if(n!==null)return{result:ue(t,s,n,!1,e)};let o=Hy(t);if(i in o){let m=o[i];return{result:ue(t,s,m,!1,e)}}if(s.status==="draft"||s.active===!1)return{result:ue(t,s,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Xt(t,s.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0);if(!l)return{result:ue(t,s,-1,!1,e)};let u=-1,d=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{variation:m,versionIsBlocked:b}=Yy({ctx:t,expKey:s.key,expBucketVersion:s.bucketVersion,expHashAttribute:s.hashAttribute,expFallbackAttribute:s.fallbackAttribute,expMinBucketVersion:s.minBucketVersion,expMeta:s.meta});d=m>=0,u=m,h=!!b}if(!d){if(s.filters){if(Zc(s.filters,t))return{result:ue(t,s,-1,!1,e)}}else if(s.namespace&&!yc(l,s.namespace))return{result:ue(t,s,-1,!1,e)};if(s.include&&!kc(s.include))return{result:ue(t,s,-1,!1,e)};if(s.condition&&!Qc(s.condition,t))return{result:ue(t,s,-1,!1,e)};if(s.parentConditions){let m=new Set(t.stack.evaluatedFeatures);for(let b of s.parentConditions){t.stack.evaluatedFeatures=new Set(m);let k=kr(b.id,t);if(k.source==="cyclicPrerequisite")return{result:ue(t,s,-1,!1,e)};let D={value:k.value};if(!Dt(D,b.condition||{}))return{result:ue(t,s,-1,!1,e)}}}if(s.groups&&!Wy(s.groups,t))return{result:ue(t,s,-1,!1,e)}}if(s.url&&!qy(s.url,t))return{result:ue(t,s,-1,!1,e)};let f=Qs(s.seed||i,l,s.hashVersion||1);if(f===null)return{result:ue(t,s,-1,!1,e)};if(!d){let m=s.ranges||Ec(r,s.coverage===void 0?1:s.coverage,s.weights);u=bc(f,m)}if(h)return{result:ue(t,s,-1,!1,e,void 0,!0)};if(u<0)return{result:ue(t,s,-1,!1,e)};if("force"in s)return{result:ue(t,s,s.force===void 0?-1:s.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:ue(t,s,-1,!1,e)};if(s.status==="stopped")return{result:ue(t,s,-1,!1,e)};let g=ue(t,s,u,!0,e,f,d);if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{changed:m,key:b,doc:k}=Jy(t,a,Zs(l),{[Po(s.key,s.bucketVersion)]:g.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[b]=k,t.user.saveStickyBucketAssignmentDoc(k))}let p=Xc(t,s,g);p.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:s,result:g});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in s&&s.changeId&&t.global.recordChangeId&&t.global.recordChangeId(s.changeId),{result:g,trackingCall:v}}function Nt(s,e,t,i,r,n,o){let a={value:t,on:!!t,off:!t,source:i,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),i!=="override"&&jy(s,e,a),a}function Jc(s){return{...s.user.attributes,...s.user.attributeOverrides}}function Qc(s,e){return Dt(Jc(e),s,e.global.savedGroups||{})}function Zc(s,e){return s.some(t=>{let{hashValue:i}=Xt(e,t.attribute);if(!i)return!0;let r=Qs(t.seed,i,t.hashVersion||2);return r===null?!0:!t.ranges.some(n=>ur(r,n))})}function zy(s,e,t,i,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Xt(s,t,i);if(!a)return!1;let l=Qs(e,a,o||1);return l===null?!1:r?ur(l,r):n!==void 0?l<=n:!0}function ue(s,e,t,i,r,n,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:u}=Xt(s,e.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),d=e.meta?e.meta[t]:{},h={key:d.key||""+t,featureId:r,inExperiment:a,hashUsed:i,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};return d.name&&(h.name=d.name),n!==void 0&&(h.bucket=n),d.passthrough&&(h.passthrough=d.passthrough),h}function Ky(s,e){let t=s.key,i=e.global.overrides;return i&&i[t]&&(s=Object.assign({},s,i[t]),typeof s.url=="string"&&(s.url=mo(s.url))),s}function Xt(s,e,t){let i=e||"id",r="",n=Jc(s);return n[i]&&(r=n[i]),!r&&t&&(n[t]&&(r=n[t]),r&&(i=t)),{hashAttribute:i,hashValue:r}}function qy(s,e){let t=e.user.url;if(!t)return!1;let i=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(s.test(t)||s.test(i))}function Wy(s,e){let t=e.global.groups||{};for(let i=0;i<s.length;i++)if(t[s[i]])return!0;return!1}function Yy({ctx:s,expKey:e,expBucketVersion:t,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){t=t||0,n=n||0,i=i||"id",o=o||[];let a=Po(e,t),l=Xy(s,i,r);if(n>0)for(let h=0;h<n;h++){let f=Po(e,h);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let u=l[a];if(u===void 0)return{variation:-1};let d=o.findIndex(h=>h.key===u);return d<0?{variation:-1}:{variation:d}}function Po(s,e){return e=e||0,`${s}__${e}`}function Co(s,e){return`${s}||${e}`}function Xy(s,e,t){if(!s.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:r}=Xt(s,e),n=Co(i,Zs(r)),{hashAttribute:o,hashValue:a}=Xt(s,t),l=a?Co(o,Zs(a)):null,u={};return l&&s.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,s.user.stickyBucketAssignmentDocs[l].assignments||{}),s.user.stickyBucketAssignmentDocs[n]&&Object.assign(u,s.user.stickyBucketAssignmentDocs[n].assignments||{}),u}function Jy(s,e,t,i){let r=Co(e,t),n=s.user.stickyBucketAssignmentDocs&&s.user.stickyBucketAssignmentDocs[r]?s.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...i},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function Qy(s,e){let t=new Set,i=e&&e.features?e.features:s.global.features||{},r=e&&e.experiments?e.experiments:s.global.experiments||[];return Object.keys(i).forEach(n=>{let o=i[n];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),r.map(n=>{t.add(n.hashAttribute||"id"),n.fallbackAttribute&&t.add(n.fallbackAttribute)}),Array.from(t)}async function ed(s,e,t){let i=Do(s,t);return e.getAllAssignments(i)}function Do(s,e){let t={};return Qy(s,e).forEach(r=>{let{hashValue:n}=Xt(s,r);t[r]=Zs(n)}),t}async function td(s,e,t){if(s={...s},s.encryptedFeatures){try{s.features=JSON.parse(await Yt(s.encryptedFeatures,e,t))}catch(i){console.error(i)}delete s.encryptedFeatures}if(s.encryptedExperiments){try{s.experiments=JSON.parse(await Yt(s.encryptedExperiments,e,t))}catch(i){console.error(i)}delete s.encryptedExperiments}if(s.encryptedSavedGroups){try{s.savedGroups=JSON.parse(await Yt(s.encryptedSavedGroups,e,t))}catch(i){console.error(i)}delete s.encryptedSavedGroups}return s}function sd(s){let e=s.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(s.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:s.apiHostRequestHeaders,streamingHostRequestHeaders:s.streamingHostRequestHeaders}}function Tr(s,e){return e.hashAttribute+e.hashValue+s.key+e.variationId}var By,Vy,id=Fe(()=>{"use strict";Yc();ei();By="Feature Evaluated",Vy="Experiment Viewed"});var Es,Zy,ri,rd=Fe(()=>{"use strict";jc();ei();xc();id();Es=typeof window<"u"&&typeof document<"u",Zy=wc(),ri=class{constructor(e){if(e=e||{},this.version=Zy,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>t.saveAssignments(i)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),Es&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let t in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[t];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await td(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,fr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Ic(e.cacheSettings),e.payload)return await this.setPayload(e.payload),fr(this,e),{success:!0,source:"init"};{let{data:t,...i}=await this._refresh({...e,allowStale:!0});return fr(this,e),await this.setPayload(t||{}),i}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return sd(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:t,allowStale:i,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Oc({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:i,backgroundSync:r??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,t,i){let r=await Yt(e,t||this._options.decryptionKey,i);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,i){let r=await Yt(e,t||this._options.decryptionKey,i);this.setExperiments(JSON.parse(r))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(i){console.error(i)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,Pc(this),e.destroyAllStreams&&wo(),this.logs=[],Es&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(t=>{t.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,t){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=t,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:t}=wr(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(i=>i.key===e).map(i=>this._runAutoExperiment(i)).filter(i=>i!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let i=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!i)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=ue(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=wr(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!t&&n.inExperiment&&i&&i.valueHash===a)return n;if(i&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=dr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let u=e.persistQueryString?Tc(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(cr(u,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=u;let{navigate:d,delay:h}=this._getNavigateFunction();if(d)if(Es)Promise.all([...o?[hr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??h))]).then(()=>{try{d(u)}catch(f){console.error(f)}});else try{d(u)}catch(f){console.error(f)}}else if(l==="visual"){let u=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(n.value):this._applyDOMChanges(n.value);u&&this._activeAutoExperiments.set(e,{undo:u,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],i=new Set(t);this._activeAutoExperiments.forEach((r,n)=>{i.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of t){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&dr(r)==="redirect")break}}_onExperimentEval(e,t){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,i)}_fireSubscriptions(e,t,i){(!i||i.result.inExperiment!==t.inExperiment||i.result.variationId!==t.variationId)&&this._subscriptions.forEach(r=>{try{r(e,t)}catch(n){console.error(n)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,t){let i=this.evalFeature(e).value;return i===null?t:i}feature(e){return this.evalFeature(e)}evalFeature(e){return kr(e,this._getEvalContext())}log(e,t){this.debug&&(this._options.log?this._options.log(e,t):console.log(e,t))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(t=>t&&t.experiment&&t.result).map(t=>[Tr(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setFeatureUsageCallback(e){this._options.onFeatureUsage=e}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Tr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Es?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=dr(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let i=new URL(this._getContextUrl());for(let r of e.variations){if(!r||!r.urlRedirect)continue;let n=new URL(r.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(n.protocol!==i.protocol||n.host!==i.host))return!0}}catch(i){return this.log("Error parsing current or redirect URL",{id:e.key,error:i}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:Es?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!Es)return;let t=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),t.push(()=>i.remove())}if(e.js){let i=document.createElement("script");i.innerHTML=e.js,this._options.jsInjectionNonce&&(i.nonce=this._options.jsInjectionNonce),document.head.appendChild(i),t.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{t.push(Hc.declarative(i).revert)}),()=>{t.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),i=await ed(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),r=Do(i,t);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var nd=Fe(()=>{"use strict";rd()});var od={};vn(od,{Growthbook:()=>No});var Xe,No,ad=Fe(()=>{"use strict";nd();go();Ys();Js();Xe=class Xe{constructor(e,t,i={},r=!1){this.analytics=new hs;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Ct("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:t,user_language:i,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:u,url:d,domain:h,utm_content:f,residence_country:g,loggedIn:p,network_type:v,network_downlink:m,user_id:b,anonymous_id:k,account_mode:D})=>{let O={...this.GrowthBook.getAttributes(),id:e,...b!==void 0&&{user_id:b},...k!==void 0&&{anonymous_id:k},...t!==void 0&&{country:t},...g!==void 0&&{residence_country:g},...i!==void 0&&{user_language:i},...r!==void 0&&{device_language:r},...n!==void 0&&{device_type:n},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...u!==void 0&&{is_authorised:u},...d!==void 0&&{url:d},...h!==void 0&&{domain:h},...f!==void 0&&{utm_content:f},...p!==void 0&&{loggedIn:p},...v!==void 0&&{network_type:v},...m!==void 0&&{network_downlink:m},...D!==void 0&&{account_mode:D}};this.log("setAttributes | updating GrowthBook attributes",O),this.GrowthBook.setAttributes(O)};this.getFeatureValue=(e,t)=>{let i=this.GrowthBook.getFeatureValue(e,t);return this.log("getFeatureValue",{key:e,value:i,defaultValue:t}),i};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let t=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:t}),t};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let t=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:t}),t};this.init=async()=>{this.log("init | initializing GrowthBook SDK");let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0,this.log("init | GrowthBook SDK loaded",{status:e})};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};this.debug=r;let n=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new ri({apiHost:ec,clientKey:e,decryptionKey:t,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:n,trackingCallback:(o,a)=>{this.log("trackingCallback | experiment viewed",{experiment_id:o.key,variation_id:a.variationId}),typeof window<"u"&&window.dataLayer&&window.dataLayer.push({event:"experiment_viewed",event_category:"experiment",rudder_anonymous_id:this.analytics.getAnonymousId(),experiment_id:o.key,variation_id:a.variationId}),this.analytics.track("experiment_viewed",{experimentId:o.key,variationId:a.variationId})},...i}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,i)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),t()):Date.now()-r>=e&&(clearInterval(n),i(new Error("GrowthBook initialization timeout")))},100)})}};Xe.getGrowthBookInstance=(e,t,i,r=!1)=>Xe._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),Xe._instance):(Xe._instance=new Xe(e,t??"",i,r),Xe._instance),Xe.resetInstance=()=>{Xe._instance&&(Xe._instance.destroy(),Xe._instance=void 0)};No=Xe});function cd(s,e,t,i,r,n,o){try{var a=s[n](o),l=a.value}catch(u){return void t(u)}a.done?e(l):Promise.resolve(l).then(i,r)}function it(s){return function(){var e=this,t=arguments;return new Promise((function(i,r){var n=s.apply(e,t);function o(l){cd(n,i,r,o,a,"next",l)}function a(l){cd(n,i,r,o,a,"throw",l)}o(void 0)}))}}function T(){return T=Object.assign?Object.assign.bind():function(s){for(var e=1;arguments.length>e;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},T.apply(null,arguments)}function ch(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}function dh(){return(dh=it((function*(s,e){e===void 0&&(e=!0);try{var t=new Blob([s],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return yield new Response(t).blob()}catch(i){return e&&console.error("Failed to gzip compress data",i),null}}))).apply(this,arguments)}function j(s,e){return s.indexOf(e)!==-1}function fh(s){return s===null||typeof s!="object"}function Ur(s,e){return{}.toString.call(s)==="[object "+e+"]"}function il(s){return typeof Event<"u"&&(function(e,t){try{return e instanceof t}catch{return!1}})(s,Event)}function dt(s,e,t,i,r){return e>t&&(i.warn("min cannot be greater than max."),e=t),ht(s)?s>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e>s?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):s:(i.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),dt(r||t,e,t,i))}function _b(s){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return Lo&&t.length===hd||(hd=t.length,Lo=t.reduce(((i,r)=>{Rr||(Rr={});var n=Rr[r];if(n)i[n[0]]=n[1];else for(var o=s(r),a=o.length-1;a>=0;a--){var l=o[a],u=l?.filename,d=e[r];if(u&&d){i[u]=d,Rr[r]=[u,d];break}}return i}),{})),Lo}}function ua(s,e,t,i,r){var n={platform:s,filename:e,function:t==="<anonymous>"?Ls:t,in_app:!0};return P(i)||(n.lineno=i),P(r)||(n.colno=r),n}function Dh(s,e){e===void 0&&(e=40);var t=Object.keys(s);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var r=t.slice(0,i).join(", ");if(e>=r.length)return i===t.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function Pr(s,e){X(s)&&s.forEach(e)}function oe(s,e){if(!z(s))if(X(s))s.forEach(e);else if(ib(s))s.forEach(((i,r)=>e(i,r)));else for(var t in s)gh.call(s,t)&&e(s[t],t)}function Fr(s){for(var e=Object.keys(s),t=e.length,i=new Array(t);t--;)i[t]=[e[t],s[e[t]]];return i}function Cb(s){var e=s?.hostname;if(!ye(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of Pb)if(t===i)return!1;return!0}function me(s,e,t,i){var{capture:r=!1,passive:n=!0}=i??{};s?.addEventListener(e,t,{capture:r,passive:n})}function Mh(s){return s.name==="ph_toolbar_internal"}function Vh(s,e){var{organization:t,projectId:i,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,u,d,h,f;if(n!=="*"&&!n.includes(a.level)||!s.__loaded)return a;a.tags||(a.tags={});var g=s.requestRouter.endpointFor("ui","/project/"+s.config.token+"/person/"+s.get_distinct_id());a.tags["PostHog Person URL"]=g,s.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=s.get_session_replay_url({withTimestamp:!0}));var p,v=((l=a.exception)==null?void 0:l.values)||[],m=v.map((k=>T({},k,{stacktrace:k.stacktrace?T({},k.stacktrace,{type:"raw",frames:(k.stacktrace.frames||[]).map((D=>T({},D,{platform:"web:javascript"})))}):void 0}))),b={$exception_message:((u=v[0])==null?void 0:u.value)||a.message,$exception_type:(d=v[0])==null?void 0:d.type,$exception_level:a.level,$exception_list:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=v[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(f=v[0])==null?void 0:f.type,$sentry_tags:a.tags};return t&&i&&(b.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+a.event_id),o&&((p=s.exceptions)==null||p.sendExceptionEvent(b)),a}}function Gh(s,e,t){if(!R)return{};var i,r=e?[...$s,...t||[]]:[],n=Hh(Ii(R.URL,r,Oi),s),o=(i={},oe(Ub,(function(a){var l=ct.Wt(a);i[a]=l||null})),i);return pe(o,n)}function Hh(s,e){var t=Mb.concat(e||[]),i={};return oe(t,(function(r){var n=Jr(s,r);i[r]=n||null})),i}function jh(s){var e=(function(n){return n?n.search(Nr+"google.([^/?]*)")===0?"google":n.search(Nr+"bing.com")===0?"bing":n.search(Nr+"yahoo.com")===0?"yahoo":n.search(Nr+"duckduckgo.com")===0?"duckduckgo":null:null})(s),t=e!="yahoo"?"q":"p",i={};if(!Bt(e)){i.$search_engine=e;var r=R?Jr(R.referrer,t):"";r.length&&(i.ph_keyword=r)}return i}function Rd(){return navigator.language||navigator.userLanguage}function zh(){return R?.referrer||Zr}function Kh(s,e){var t=s?[...$s,...e||[]]:[],i=Ae?.href.substring(0,1e3);return{r:zh().substring(0,1e3),u:i?Ii(i,t,Oi):void 0}}function qh(s){var e,{r:t,u:i}=s,r={$referrer:t,$referring_domain:t==null?void 0:t==Zr?Zr:(e=Xr(t))==null?void 0:e.host};if(i){r.$current_url=i;var n=Xr(i);r.$host=n?.host,r.$pathname=n?.pathname;var o=Hh(i);pe(r,o)}if(t){var a=jh(t);pe(r,a)}return r}function Wh(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Bb(){try{return new Date().getTimezoneOffset()}catch{return}}function qb(s,e){e===void 0&&(e={});var t=(function(){var h=4294967295;return{p(f){for(var g=h,p=0;f.length>p;++p)g=Kb[255&g^f[p]]^g>>>8;h=g},d(){return 4294967295^h}}})(),i=s.length;t.p(s);var r,n,o,a,l,u=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(h,f,g,p,v,m){var b=h.length,k=new Qe(p+b+5*(1+Math.floor(b/7e3))+v),D=k.subarray(p,k.length-v),N=0;if(!f||8>b)for(var O=0;b>=O;O+=65535){var C=O+65535;b>C?N=Ua(D,N,h.subarray(O,C)):(D[O]=!0,N=Ua(D,N,h.subarray(O,b)))}else{for(var S=zb[f-1],E=S>>>13,I=8191&S,M=(1<<g)-1,G=new Le(32768),V=new Le(M+1),q=Math.ceil(g/3),W=2*q,ve=function(pn){return(h[pn]^h[pn+1]<<q^h[pn+2]<<W)&M},Se=new Fs(25e3),Ce=new Le(288),ae=new Le(32),w=0,$=0,F=(O=0,0),U=0,Z=0;b>O;++O){var ce=ve(O),ie=32767&O,_e=V[ce];if(G[ie]=_e,V[ce]=ie,O>=U){var Oe=b-O;if((w>7e3||F>24576)&&Oe>423){N=Cd(h,D,0,Se,Ce,ae,$,F,Z,O-Z,N),F=w=$=0,Z=O;for(var ke=0;286>ke;++ke)Ce[ke]=0;for(ke=0;30>ke;++ke)ae[ke]=0}var H=2,gt=0,_g=I,At=ie-_e&32767;if(Oe>2&&ce==ve(O-At))for(var mg=Math.min(E,Oe)-1,yg=Math.min(32767,O),bg=Math.min(258,Oe);yg>=At&&--_g&&ie!=_e;){if(h[O+H]==h[O+H-At]){for(var It=0;bg>It&&h[O+It]==h[O+It-At];++It);if(It>H){if(H=It,gt=At,It>mg)break;var Eg=Math.min(At,It-2),pl=0;for(ke=0;Eg>ke;++ke){var fn=O-At+ke+32768&32767,vl=fn-G[fn]+32768&32767;vl>pl&&(pl=vl,_e=fn)}}}At+=(ie=_e)-(_e=G[ie])+32768&32767}if(gt){Se[F++]=268435456|$a[H]<<18|Fa[gt];var _l=31&$a[H],ml=31&Fa[gt];$+=cl[_l]+dl[ml],++Ce[257+_l],++ae[ml],U=O+H,++w}else Se[F++]=h[O],++Ce[h[O]]}}N=Cd(h,D,!0,Se,Ce,ae,$,F,Z,O-Z,N)}return Qh(k,0,p+Jh(N)+v)})(n=s,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),d=u.length;return(function(h,f){var g=f.filename;if(h[0]=31,h[1]=139,h[2]=8,h[8]=2>f.level?4:f.level==9?2:0,h[9]=3,f.mtime!=0&&jo(h,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),g){h[3]=8;for(var p=0;g.length>=p;++p)h[p+10]=g.charCodeAt(p)}})(u,e),jo(u,d-8,t.d()),jo(u,d-4,i),u}function Dd(s,e,t){return Ps({distinct_id:s,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function sg(s,e){return!s||Object.entries(s).every((t=>{var[i,r]=t,n=e?.[i];if(P(n)||Bt(n))return!1;var o=[String(n)],a=tg[r.operator];return!!a&&a(r.values,o)}))}function Ud(s){return s instanceof Element&&(s.id===Fh||!(s.closest==null||!s.closest(".toolbar-global-fade-container")))}function hn(s){return!!s&&s.nodeType===1}function Ut(s,e){return!!s&&!!s.tagName&&s.tagName.toLowerCase()===e.toLowerCase()}function ng(s){return!!s&&s.nodeType===3}function og(s){return!!s&&s.nodeType===11}function hl(s){return s?cn(s).split(/\s+/):[]}function Bd(s){var e=_?.location.href;return!!(e&&s&&s.some((t=>e.match(t))))}function ln(s){var e="";switch(typeof s.className){case"string":e=s.className;break;case"object":e=(s.className&&"baseVal"in s.className?s.className.baseVal:null)||s.getAttribute("class")||"";break;default:e=""}return hl(e)}function ag(s){return z(s)?null:cn(s).split(/(\s+)/).filter((e=>Ti(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ci(s){var e="";return Ja(s)&&!ug(s)&&s.childNodes&&s.childNodes.length&&oe(s.childNodes,(function(t){var i;ng(t)&&t.textContent&&(e+=(i=ag(t.textContent))!==null&&i!==void 0?i:"")})),cn(e)}function Vd(s){return P(s.target)?s.srcElement||null:(e=s.target)!=null&&e.shadowRoot?s.composedPath()[0]||null:s.target||null;var e}function Gd(s,e){if(P(e))return!0;var t,i=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of s)if(t=i(r))return t.v;return!1}function lg(s){var e=s.parentNode;return!(!e||!hn(e))&&e}function Ja(s){for(var e=s;e.parentNode&&!Ut(e,"body");e=e.parentNode){var t=ln(e);if(j(t,"ph-sensitive")||j(t,"ph-no-capture"))return!1}if(j(ln(s),"ph-include"))return!0;var i=s.type||"";if(ye(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var r=s.name||s.id||"";return!ye(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 ug(s){return!!(Ut(s,"input")&&!["button","checkbox","submit","reset"].includes(s.type)||Ut(s,"select")||Ut(s,"textarea")||s.getAttribute("contenteditable")==="true")}function Ti(s,e){return e===void 0&&(e=!0),!(z(s)||ye(s)&&(s=cn(s),(e?oE:aE).test((s||"").replace(/[- ]/g,""))||(e?lE:uE).test(s)))}function zd(s){var e=Ci(s);return Ti(e=(e+" "+hg(s)).trim())?e:""}function hg(s){var e="";return s&&s.childNodes&&s.childNodes.length&&oe(s.childNodes,(function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var r=Ci(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+hg(t)).trim())}catch(n){A.error("[AutoCapture]",n)}})),e}function Kd(s){return s.replace(/"|\\"/g,'\\"')}function cE(s){var e=s.attr__class;return e?X(e)?e:hl(e):void 0}function Yo(s,e){return e.length>s?e.slice(0,s)+"...":e}function dE(s){if(s.previousElementSibling)return s.previousElementSibling;var e=s;do e=e.previousSibling;while(e&&!hn(e));return e}function hE(s,e){for(var t,i,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,u=[s],d=s;d.parentNode&&!Ut(d,"body");)og(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,f,g=[],p={},v=!1,m=!1;if(oe(u,(O=>{var C=Ja(O);O.tagName.toLowerCase()==="a"&&(v=O.getAttribute("href"),v=C&&v&&Ti(v)&&v),j(ln(O),"ph-no-capture")&&(m=!0),g.push((function(E,I,M,G){var V=E.tagName.toLowerCase(),q={tag_name:V};gl.indexOf(V)>-1&&!M&&(q.$el_text=V.toLowerCase()==="a"||V.toLowerCase()==="button"?Yo(1024,zd(E)):Yo(1024,Ci(E)));var W=ln(E);W.length>0&&(q.classes=W.filter((function(ae){return ae!==""}))),oe(E.attributes,(function(ae){var w;if((!ug(E)||["name","id","class","aria-label"].indexOf(ae.name)!==-1)&&(G==null||!G.includes(ae.name))&&!I&&Ti(ae.value)&&(!ye(w=ae.name)||w.substring(0,10)!=="_ngcontent"&&w.substring(0,7)!=="_nghost")){var $=ae.value;ae.name==="class"&&($=hl($).join(" ")),q["attr__"+ae.name]=Yo(1024,$)}}));for(var ve=1,Se=1,Ce=E;Ce=dE(Ce);)ve++,Ce.tagName===E.tagName&&Se++;return q.nth_child=ve,q.nth_of_type=Se,q})(O,n,o,a));var S=(function(E){if(!Ja(E))return{};var I={};return oe(E.attributes,(function(M){if(M.name&&M.name.indexOf("data-ph-capture-attribute")===0){var G=M.name.replace("data-ph-capture-attribute-",""),V=M.value;G&&V&&Ti(V)&&(I[G]=V)}})),I})(O);pe(p,S)})),m)return{props:{},explicitNoCapture:m};if(o||(g[0].$el_text=s.tagName.toLowerCase()==="a"||s.tagName.toLowerCase()==="button"?zd(s):Ci(s)),v){var b,k;g[0].attr__href=v;var D=(b=Xr(v))==null?void 0:b.host,N=_==null||(k=_.location)==null?void 0:k.host;D&&N&&D!==N&&(h=v)}return{props:pe({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(f=g,(function(O){return O.map((C=>{var S,E,I="";if(C.tag_name&&(I+=C.tag_name),C.attr_class)for(var M of(C.attr_class.sort(),C.attr_class))I+="."+M.replace(/"/g,"");var G=T({},C.text?{text:C.text}:{},{"nth-child":(S=C.nth_child)!==null&&S!==void 0?S:0,"nth-of-type":(E=C.nth_of_type)!==null&&E!==void 0?E:0},C.href?{href:C.href}:{},C.attr_id?{attr_id:C.attr_id}:{},C.attributes),V={};return Fr(G).sort(((q,W)=>{var[ve]=q,[Se]=W;return ve.localeCompare(Se)})).forEach((q=>{var[W,ve]=q;return V[Kd(W.toString())]=Kd(ve.toString())})),(I+=":")+Fr(V).map((q=>{var[W,ve]=q;return W+'="'+ve+'"'})).join("")})).join(";")})((function(O){return O.map((C=>{var S,E,I={text:(S=C.$el_text)==null?void 0:S.slice(0,400),tag_name:C.tag_name,href:(E=C.attr__href)==null?void 0:E.slice(0,2048),attr_class:cE(C),attr_id:C.attr__id,nth_child:C.nth_child,nth_of_type:C.nth_of_type,attributes:{}};return Fr(C).filter((M=>{var[G]=M;return G.indexOf("attr__")===0})).forEach((M=>{var[G,V]=M;return I.attributes[G]=V})),I}))})(f)))},(t=g[0])!=null&&t.$el_text?{$el_text:(i=g[0])==null?void 0:i.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},p)}}function Wd(s,e,t){try{if(!(e in s))return()=>{};var i=s[e],r=t(i);return wt(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),s[e]=r,()=>{s[e]=i}}catch{return()=>{}}}function Qd(s){return be(s)&&"clientX"in s&&"clientY"in s&&ht(s.clientX)&&ht(s.clientY)}function ws(s,e,t){if(z(s))return!1;switch(t){case"exact":return s===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(s);case"regex":try{return new RegExp(e).test(s)}catch{return!1}default:return!1}}var _,Ee,Ke,R,Ae,ta,sa,ld,eb,Ge,L,ud,ze,tb,sb,dd,cn,ia,hh,gh,dn,X,wt,be,Is,P,ye,$r,Bt,z,ht,Ts,Tt,ib,rb,nb,xo,ob,ra,Rr,hd,Lo,qe,Br,Rt,Ns,ph,vh,_h,mh,bi,xs,yh,bh,Eh,ss,ab,Sh,rl,kh,nl,lb,ol,wh,Cs,Th,Ri,Ai,Ds,Rh,Ah,fi,na,gd,oa,Ih,ub,Oh,aa,xe,$o,cb,db,hb,al,gb,Ph,fb,pb,fd,pd,vb,la,Ls,Ch,mb,yb,bb,Eb,Sb,kb,wb,vd,ca,da,ha,Tb,ga,Rb,fa,pa,va,_a,Nh,A,ge,Ab,Ar,xh,Vr,pi,vi,_d,ma,md,ya,yd,bd,Lh,Ed,Sd,Ir,Gr,$h,Os,_i,ba,mi,ts,Ea,Ei,Sa,ka,Hr,st,wa,Ta,Ra,Aa,jr,zr,Fh,Or,Ib,ll,kt,rt,Ss,ks,Ia,Kr,qr,Rs,Fo,Mo,kd,pe,wd,Ob,ul,Pb,Oa,Pa,Td,Uh,Ca,Mt,Db,ni,Nb,ct,Uo,he,xb,Cr,Lb,Jt,Ie,Da,Dr,$b,Fb,Wr,Bo,Bh,Na,Yr,Xr,Jr,Ii,Qr,Nr,$s,Mb,Oi,Ub,Zr,Vb,Si,oi,Vo,yi,Go,xa,Gb,Ad,Id,La,ai,en,ut,Qe,Le,Fs,cl,dl,Od,Yh,Xh,$a,Qt,Fa,tn,se,ki,is,sn,Hb,jb,Jh,Qh,St,li,Ho,Ma,Pd,ui,Ua,Cd,zb,Kb,jo,Wb,Zh,rn,Ps,zo,Yb,Mr,Ba,Va,Xb,Ga,Ha,Jb,nn,Pi,Ko,on,eg,an,tg,xr,ja,Nd,za,te,Ka,Qb,xd,Zb,eE,tE,sE,qa,wi,qo,Wa,Ld,ci,$d,ig,iE,As,rg,Fd,rE,Md,Ya,Ms,gl,nE,Hd,Xa,jd,cg,oE,aE,dg,lE,uE,un,Wo,qd,di,gE,xt,Yd,Xd,Jd,hi,Lr,Qa,Lt,fE,Zd,Xo,pE,$t,eh,Za,el,tl,Jo,th,vE,sh,ih,Ne,Zt,Qo,Zo,Ft,rh,gi,nh,oh,ah,ea,lh,_E,sl,Je,es,gn,mE,yE,bE,EE,SE,kE,wE,TE,RE,AE,IE,OE,uh,$e,gg=Fe(()=>{"use strict";_=typeof window<"u"?window:void 0,Ee=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(Ee.self=Ee),typeof File>"u"&&(Ee.File=function(){});Ke=Ee?.navigator,R=Ee?.document,Ae=Ee?.location,ta=Ee?.fetch,sa=Ee!=null&&Ee.XMLHttpRequest&&"withCredentials"in new Ee.XMLHttpRequest?Ee.XMLHttpRequest:void 0,ld=Ee?.AbortController,eb=Ee?.CompressionStream,Ge=Ke?.userAgent,L=_??{},ud="1.367.0",ze={DEBUG:!1,LIB_VERSION:ud,LIB_NAME:"web",JS_SDK_VERSION:ud};tb=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],sb=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],dd=function(s,e){if(e===void 0&&(e=[]),!s)return!1;var t=s.toLowerCase();return sb.concat(e).some((i=>{var r=i.toLowerCase();return t.indexOf(r)!==-1}))};cn=function(s){return s.trim()},ia=function(s){return s.replace(/^\$/,"")},hh=Object.prototype,gh=hh.hasOwnProperty,dn=hh.toString,X=Array.isArray||function(s){return dn.call(s)==="[object Array]"},wt=s=>typeof s=="function",be=s=>s===Object(s)&&!X(s),Is=s=>{if(be(s)){for(var e in s)if(gh.call(s,e))return!1;return!0}return!1},P=s=>s===void 0,ye=s=>dn.call(s)=="[object String]",$r=s=>ye(s)&&s.trim().length===0,Bt=s=>s===null,z=s=>P(s)||Bt(s),ht=s=>dn.call(s)=="[object Number]"&&s==s,Ts=s=>ht(s)&&s>0,Tt=s=>dn.call(s)==="[object Boolean]",ib=s=>s instanceof FormData,rb=s=>j(tb,s);nb=[!0,"true",1,"1","yes"],xo=s=>j(nb,s),ob=[!1,"false",0,"0","no"];ra=class{constructor(e){this.Pt={},this.Dt=e.Dt,this.jt=dt(e.bucketSize,0,100,e.qt),this.$t=dt(e.refillRate,0,this.jt,e.qt),this.Ht=dt(e.refillInterval,0,864e5,e.qt)}Vt(e,t){var i=Math.floor((t-e.lastAccess)/this.Ht);i>0&&(e.tokens=Math.min(e.tokens+i*this.$t,this.jt),e.lastAccess=e.lastAccess+i*this.Ht)}consumeRateLimit(e){var t,i=Date.now(),r=String(e),n=this.Pt[r];return n?this.Vt(n,i):this.Pt[r]=n={tokens:this.jt,lastAccess:i},n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.Dt)==null||t.call(this,e)),n.tokens===0)}stop(){this.Pt={}}},qe="Mobile",Br="iOS",Rt="Android",Ns="Tablet",ph=Rt+" "+Ns,vh="iPad",_h="Apple",mh=_h+" Watch",bi="Safari",xs="BlackBerry",yh="Samsung",bh=yh+"Browser",Eh=yh+" Internet",ss="Chrome",ab=ss+" OS",Sh=ss+" "+Br,rl="Internet Explorer",kh=rl+" "+qe,nl="Opera",lb=nl+" Mini",ol="Edge",wh="Microsoft "+ol,Cs="Firefox",Th=Cs+" "+Br,Ri="Nintendo",Ai="PlayStation",Ds="Xbox",Rh=Rt+" "+qe,Ah=qe+" "+bi,fi="Windows",na=fi+" Phone",gd="Nokia",oa="Ouya",Ih="Generic",ub=Ih+" "+qe.toLowerCase(),Oh=Ih+" "+Ns.toLowerCase(),aa="Konqueror",xe="(\\d+(\\.\\d+)?)",$o=new RegExp("Version/"+xe),cb=new RegExp(Ds,"i"),db=new RegExp(Ai+" \\w+","i"),hb=new RegExp(Ri+" \\w+","i"),al=new RegExp(xs+"|PlayBook|BB10","i"),gb={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},Ph=function(s,e){return e=e||"",j(s," OPR/")&&j(s,"Mini")?lb:j(s," OPR/")?nl:al.test(s)?xs:j(s,"IE"+qe)||j(s,"WPDesktop")?kh:j(s,bh)?Eh:j(s,ol)||j(s,"Edg/")?wh:j(s,"FBIOS")?"Facebook "+qe:j(s,"UCWEB")||j(s,"UCBrowser")?"UC Browser":j(s,"CriOS")?Sh:j(s,"CrMo")||j(s,ss)?ss:j(s,Rt)&&j(s,bi)?Rh:j(s,"FxiOS")?Th:j(s.toLowerCase(),aa.toLowerCase())?aa:((t,i)=>i&&j(i,_h)||(function(r){return j(r,bi)&&!j(r,ss)&&!j(r,Rt)})(t))(s,e)?j(s,qe)?Ah:bi:j(s,Cs)?Cs:j(s,"MSIE")||j(s,"Trident/")?rl:j(s,"Gecko")?Cs:""},fb={[kh]:[new RegExp("rv:"+xe)],[wh]:[new RegExp(ol+"?\\/"+xe)],[ss]:[new RegExp("("+ss+"|CrMo)\\/"+xe)],[Sh]:[new RegExp("CriOS\\/"+xe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+xe)],[bi]:[$o],[Ah]:[$o],[nl]:[new RegExp("(Opera|OPR)\\/"+xe)],[Cs]:[new RegExp(Cs+"\\/"+xe)],[Th]:[new RegExp("FxiOS\\/"+xe)],[aa]:[new RegExp("Konqueror[:/]?"+xe,"i")],[xs]:[new RegExp(xs+" "+xe),$o],[Rh]:[new RegExp("android\\s"+xe,"i")],[Eh]:[new RegExp(bh+"\\/"+xe)],[rl]:[new RegExp("(rv:|MSIE )"+xe)],Mozilla:[new RegExp("rv:"+xe)]},pb=function(s,e){var t=Ph(s,e),i=fb[t];if(P(i))return null;for(var r=0;i.length>r;r++){var n=s.match(i[r]);if(n)return parseFloat(n[n.length-2])}return null},fd=[[new RegExp(Ds+"; "+Ds+" (.*?)[);]","i"),s=>[Ds,s&&s[1]||""]],[new RegExp(Ri,"i"),[Ri,""]],[new RegExp(Ai,"i"),[Ai,""]],[al,[xs,""]],[new RegExp(fi,"i"),(s,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[na,""];if(new RegExp(qe).test(e)&&!/IEMobile\b/.test(e))return[fi+" "+qe,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=gb[t[1]]||"";return/arm/i.test(e)&&(i="RT"),[fi,i]}return[fi,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,s=>s&&s[3]?[Br,[s[3],s[4],s[5]||"0"].join(".")]:[Br,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,s=>{var e="";return s&&s.length>=3&&(e=P(s[2])?s[3]:s[2]),["watchOS",e]}],[new RegExp("("+Rt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Rt+")","i"),s=>s&&s[2]?[Rt,[s[2],s[3],s[4]||"0"].join(".")]:[Rt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,s=>{var e=["Mac OS X",""];return s&&s[1]&&(e[1]=[s[1],s[2],s[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[ab,""]],[/Linux|debian/i,["Linux",""]]],pd=function(s){return hb.test(s)?Ri:db.test(s)?Ai:cb.test(s)?Ds:new RegExp(oa,"i").test(s)?oa:new RegExp("("+na+"|WPDesktop)","i").test(s)?na:/iPad/.test(s)?vh:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?mh:al.test(s)?xs:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(gd,"i").test(s)?gd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":/(Android|ZTE)/i.test(s)?new RegExp(qe).test(s)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)||/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?Rt:ph:new RegExp("(pda|"+qe+")","i").test(s)?ub:new RegExp(Ns,"i").test(s)&&!new RegExp(Ns+" pc","i").test(s)?Oh:""},vb=s=>s instanceof Error;la=class{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,i),$exception_level:"error"}}modifyFrames(e){var t=this;return it((function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&X(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),T({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map((i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return it((function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i}))()}convertToExceptionList(e,t){var i,r,n,o={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(r=t.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,T({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:_b(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var r=(n,o)=>{if(4>=o){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(n,a)}};return T({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,i),next:n=>r(n,i+1)})}},Ls="?";Ch=(s,e)=>{var t=s.indexOf("safari-extension")!==-1,i=s.indexOf("safari-web-extension")!==-1;return t||i?[s.indexOf("@")!==-1?s.split("@")[0]:Ls,t?"safari-extension:"+e:"safari-web-extension:"+e]:[s,e]},mb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,yb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,bb=/\((\S*)(?::(\d+))(?::(\d+))\)/,Eb=(s,e)=>{var t=mb.exec(s);if(t){var[,i,r,n]=t;return ua(e,i,Ls,+r,+n)}var o=yb.exec(s);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=bb.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=Ch(o[1]||Ls,o[2]);return ua(e,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Sb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,kb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,wb=(s,e)=>{var t=Sb.exec(s);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=kb.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var r=t[3],n=t[1]||Ls;return[n,r]=Ch(n,r),ua(e,r,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},vd=/\(error: (.*)\)/,ca=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=ye(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Ur(e,"DOMException")}isDOMError(e){return Ur(e,"DOMError")}},da=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&typeof i.error.message=="string"?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}},ha=class{constructor(){}match(e){return Ur(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},Tb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ga=class{match(e){return typeof e=="string"}coerce(e,t){var i,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Tb);return r&&(t=r[1],i=r[2]),[t,i]}},Rb=["fatal","error","warning","log","info","debug"];fa=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(i=t.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return il(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+Dh(e)}isSeverityLevel(e){return ye(e)&&!$r(e)&&Rb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(vb(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},pa=class{match(e){return il(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Dh(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},va=class{match(e){return fh(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},_a=class{match(e){return Ur(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!il(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return fh(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}},Nh=function(s,e){var{debugEnabled:t}=e===void 0?{}:e,i={C(r){if(_&&(ze.DEBUG||L.POSTHOG_DEBUG||t)&&!P(_.console)&&_.console){for(var n=("__rrweb_original__"in _.console[r])?_.console[r].__rrweb_original__:_.console[r],o=arguments.length,a=new Array(o>1?o-1:0),l=1;o>l;l++)a[l-1]=arguments[l];n(s,...a)}},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(s,...n)},uninitializedWarning(r){i.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Nh(s+" "+r,n)};return i},A=Nh("[PostHog.js]"),ge=A.createLogger,Ab=ge("[ExternalScriptsLoader]"),Ar=(s,e,t)=>{if(s.config.disable_external_dependency_loading)return Ab.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=R?.querySelectorAll("script");if(i){for(var r,n=function(){if(i[o].src===e){var l=i[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(u=>{l.__posthog_loading_callback_fired=!0,t(void 0,u)})),l.onerror=u=>t(u),{v:void 0})}},o=0;i.length>o;o++)if(r=n())return r.v}var a=()=>{if(!R)return t("document not found");var l=R.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,t(void 0,h)},l.onerror=h=>t(h),s.config.prepare_external_dependency_script&&(l=s.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(s.config.external_scripts_inject_target==="head")R.head.appendChild(l);else{var u,d=R.querySelectorAll("body > script");d.length>0?(u=d[0].parentNode)==null||u.insertBefore(l,d[0]):R.body.appendChild(l)}};R!=null&&R.body?a():R?.addEventListener("DOMContentLoaded",a)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(s,e,t)=>{if(e!=="remote-config")if(s._resolvedSdkVersion){var i=s.requestRouter.endpointFor("assets","/static/"+s._resolvedSdkVersion+"/"+e+".js");Ar(s,i,t)}else{var r="/static/"+e+".js?v="+s.version;if(e==="toolbar"){var n=3e5;r=r+"&t="+Math.floor(Date.now()/n)*n}var o=s.requestRouter.endpointFor("assets",r);Ar(s,o,t)}else{var a=s.requestRouter.endpointFor("assets","/array/"+s.config.token+"/config.js");Ar(s,a,t)}},L.__PosthogExtensions__.loadSiteApp=(s,e,t)=>{var i=s.requestRouter.endpointFor("api",e);Ar(s,i,t)};xh="$people_distinct_id",Vr="$device_id",pi="__alias",vi="__timers",_d="$autocapture_disabled_server_side",ma="$heatmaps_enabled_server_side",md="$exception_capture_enabled_server_side",ya="$error_tracking_suppression_rules",yd="$error_tracking_capture_extension_exceptions",bd="$web_vitals_enabled_server_side",Lh="$dead_clicks_enabled_server_side",Ed="$product_tours_enabled_server_side",Sd="$web_vitals_allowed_metrics",Ir="$session_recording_remote_config",Gr="$sesid",$h="$session_is_sampled",Os="$enabled_feature_flags",_i="$early_access_features",ba="$feature_flag_details",mi="$stored_person_properties",ts="$stored_group_properties",Ea="$surveys",Ei="$flag_call_reported",Sa="$flag_call_reported_session_id",ka="$feature_flag_errors",Hr="$feature_flag_evaluated_at",st="$user_state",wa="$client_session_props",Ta="$capture_rate_limit",Ra="$initial_campaign_params",Aa="$initial_referrer_info",jr="$initial_person_info",zr="$epp",Fh="__POSTHOG_TOOLBAR__",Or="$posthog_cookieless",Ib=[xh,pi,"__cmpns",vi,"$session_recording_enabled_server_side",ma,Gr,Os,ya,st,_i,ba,ts,mi,Ea,Ei,Sa,ka,Hr,wa,Ta,Ra,Aa,zr,jr],ll="PostHog loadExternalDependency extension not found.",kt="on_reject",rt="always",Ss="anonymous",ks="identified",Ia="identified_only",Kr="visibilitychange",qr="beforeunload",Rs="$pageview",Fo="$pageleave",Mo="$identify",kd="$groupidentify";pe=function(s){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;e>i;i++)t[i-1]=arguments[i];for(var r of t)for(var n in r)r[n]!==void 0&&(s[n]=r[n]);return s};wd=function(s){try{return s()}catch{return}},Ob=function(s){return function(){try{for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return s.apply(this,t)}catch(r){A.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),A.critical(r)}}},ul=function(s){var e={};return oe(s,(function(t,i){(ye(t)&&t.length>0||ht(t))&&(e[i]=t)})),e},Pb=["herokuapp.com","vercel.app","netlify.app"];Math.trunc||(Math.trunc=function(s){return 0>s?Math.ceil(s):Math.floor(s)}),Number.isInteger||(Number.isInteger=function(s){return ht(s)&&isFinite(s)&&Math.floor(s)===s});Oa=class s{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new s(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new s(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}},Pa=class{constructor(){this.I=0,this.S=0,this.k=new Ca}generate(){var e=this.generateOrAbort();if(P(e)){this.I=0;var t=this.generateOrAbort();if(P(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.I)this.I=e,this.A();else{if(this.I>=e+1e4)return;this.S++,this.S>4398046511103&&(this.I++,this.A())}return Oa.fromFieldsV7(this.I,Math.trunc(this.S/Math.pow(2,30)),this.S&Math.pow(2,30)-1,this.k.nextUint32())}A(){this.S=1024*this.k.nextUint32()+(1023&this.k.nextUint32())}},Uh=s=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;s.length>e;e++)s[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return s};_&&!P(_.crypto)&&crypto.getRandomValues&&(Uh=s=>crypto.getRandomValues(s));Ca=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(Uh(this.T),this.N=0),this.T[this.N++]}},Mt=()=>Db().toString(),Db=()=>(Td||(Td=new Pa)).generate(),ni="",Nb=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ct={Yt:()=>!!R,Ut(s){A.error("cookieStore error: "+s)},Wt(s){if(R){try{for(var e=s+"=",t=R.cookie.split(";").filter((n=>n.length)),i=0;t.length>i;i++){for(var r=t[i];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}},Gt(s){var e;try{e=JSON.parse(ct.Wt(s))||{}}catch{}return e},Xt(s,e,t,i,r){if(R)try{var n="",o="",a=(function(d,h){if(h){var f=(function(p,v){if(v===void 0&&(v=R),ni)return ni;if(!v||["localhost","127.0.0.1"].includes(p))return"";for(var m=p.split("."),b=Math.min(m.length,8),k="dmn_chk_"+Mt();!ni&&b--;){var D=m.slice(b).join("."),N=k+"=1;domain=."+D+";path=/";v.cookie=N+";max-age=3",v.cookie.includes(k)&&(v.cookie=N+";max-age=0",ni=D)}return ni})(d);if(!f){var g=(p=>{var v=p.match(Nb);return v?v[0]:""})(d);g!==f&&A.info("Warning: cookie subdomain discovery mismatch",g,f),f=g}return f?"; domain=."+f:""}return""})(R.location.hostname,i);if(t){var l=new Date;l.setTime(l.getTime()+864e5*t),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=s+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&A.warn("cookieStore warning: large cookie, len="+u.length),R.cookie=u,u}catch{return}},Jt(s,e){if(R!=null&&R.cookie)try{ct.Xt(s,"",-1,e)}catch{return}}},Uo=null,he={Yt(){if(!Bt(Uo))return Uo;var s=!0;if(P(_))s=!1;else try{var e="__mplssupport__";he.Xt(e,"xyz"),he.Wt(e)!=='"xyz"'&&(s=!1),he.Jt(e)}catch{s=!1}return s||A.error("localStorage unsupported; falling back to cookie store"),Uo=s,s},Ut(s){A.error("localStorage error: "+s)},Wt(s){try{return _?.localStorage.getItem(s)}catch(e){he.Ut(e)}return null},Gt(s){try{return JSON.parse(he.Wt(s))||{}}catch{}return null},Xt(s,e){try{_?.localStorage.setItem(s,JSON.stringify(e))}catch(t){he.Ut(t)}},Jt(s){try{_?.localStorage.removeItem(s)}catch(e){he.Ut(e)}}},xb=[Vr,"distinct_id",Gr,$h,zr,jr,st],Cr={},Lb={Yt:()=>!0,Ut(s){A.error("memoryStorage error: "+s)},Wt:s=>Cr[s]||null,Gt:s=>Cr[s]||null,Xt(s,e){Cr[s]=e},Jt(s){delete Cr[s]}},Jt=null,Ie={Yt(){if(!Bt(Jt))return Jt;if(Jt=!0,P(_))Jt=!1;else try{var s="__support__";Ie.Xt(s,"xyz"),Ie.Wt(s)!=='"xyz"'&&(Jt=!1),Ie.Jt(s)}catch{Jt=!1}return Jt},Ut(s){A.error("sessionStorage error: ",s)},Wt(s){try{return _?.sessionStorage.getItem(s)}catch(e){Ie.Ut(e)}return null},Gt(s){try{return JSON.parse(Ie.Wt(s))||null}catch{}return null},Xt(s,e){try{_?.sessionStorage.setItem(s,JSON.stringify(e))}catch(t){Ie.Ut(t)}},Jt(s){try{_?.sessionStorage.removeItem(s)}catch(e){Ie.Ut(e)}}},Da=class{constructor(e){this._instance=e}get Rt(){return this._instance.config}get consent(){return this.Kt()?0:this.Qt}isOptedOut(){return this.Rt.cookieless_mode===rt||this.consent===0||this.consent===-1&&(this.Rt.opt_out_capturing_by_default||this.Rt.cookieless_mode===kt)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}optInOut(e){this.tr.Xt(this.er,e?1:0,this.Rt.cookie_expiration,this.Rt.cross_subdomain_cookie,this.Rt.secure_cookie)}reset(){this.tr.Jt(this.er,this.Rt.cross_subdomain_cookie)}get er(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get Qt(){var e=this.tr.Wt(this.er);return xo(e)?1:j(ob,e)?0:-1}get tr(){var e=this.Rt.opt_out_capturing_persistence_type,t=e==="localStorage"?he:ct;if(!this.rr||this.rr!==t){this.rr=t;var i=e==="localStorage"?ct:he;i.Wt(this.er)&&(this.rr.Wt(this.er)||this.optInOut(xo(i.Wt(this.er))),i.Jt(this.er,this.Rt.cross_subdomain_cookie))}return this.rr}Kt(){return!!this.Rt.respect_dnt&&[Ke?.doNotTrack,Ke?.msDoNotTrack,L.doNotTrack].some((e=>xo(e)))}},Dr=ge("[Dead Clicks]"),$b=()=>!0,Fb=s=>{var e,t=!((e=s.instance.persistence)==null||!e.get_property(Lh)),i=s.instance.config.capture_dead_clicks;return Tt(i)?i:!!be(i)||t},Wr=class{get lazyLoadedDeadClicksAutocapture(){return this.ir}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Lh]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.nr((()=>{this.sr()})):this.stop()}nr(e){var t,i;(t=L.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Dr.error("failed to load script",r):e()}))}sr(){var e;if(R){if(!this.ir&&(e=L.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=be(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.ir=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.ir.start(R),Dr.info("starting...")}}else Dr.error("`document` not found. Cannot start.")}stop(){this.ir&&(this.ir.stop(),this.ir=void 0,Dr.info("stopping..."))}},Bo=ge("[SegmentIntegration]"),Bh="posthog-js";Na=class{constructor(e,t,i,r,n,o){this.name=Bh,this.setupOnce=function(a){a(Vh(e,{organization:t,projectId:i,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},Yr=class{constructor(e){this.ar=(t,i,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(A.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.lr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.ur()}ur(){var e;this.hr=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.ar)}destroy(){var e;(e=this.hr)==null||e.call(this),this.hr=void 0}doPageView(e,t){var i,r=this.cr(e,t);return this.lr={pathname:(i=_?.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.cr(e,(t=this.lr)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.lr)==null?void 0:e.pageViewId}}cr(e,t){var i=this.lr;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:u,lastContentY:d,maxContentY:h}=n;if(!(P(o)||P(a)||P(l)||P(u)||P(d)||P(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),d=Math.ceil(d),h=Math.ceil(h);var f=o>1?dt(a/o,0,1,A):1,g=o>1?dt(l/o,0,1,A):1,p=u>1?dt(d/u,0,1,A):1,v=u>1?dt(h/u,0,1,A):1;r=pe(r,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:d,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}},Xr=s=>{var e=R?.createElement("a");return P(e)?null:(e.href=s,e)},Jr=function(s,e){for(var t,i=((s.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;i.length>r;r++){var n=i[r].split("=");if(n[0]===e){t=n;break}}if(!X(t)||2>t.length)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{A.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Ii=function(s,e,t){if(!s||!e||!e.length)return s;for(var i=s.split("#"),r=i[1],n=(i[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],d=0;l.length>d;d++){var h=l[d].split("=");X(h)&&(e.includes(h[0])?u.push(h[0]+"="+t):u.push(l[d]))}var f=a;return o!=null&&(f+="?"+u.join("&")),r!=null&&(f+="#"+r),f},Qr=function(s,e){var t=s.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},Nr="https?://(.*)",$s=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],Mb=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...$s],Oi="<masked>",Ub=["li_fat_id"];Zr="$direct";Vb=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Si=class{constructor(e,t){this.Rt=e,this.props={},this.dr=!1,this.vr=(i=>{var r="";return i.token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"})(e),this.tr=this.pr(e),this.load(),e.debug&&A.info("Persistence loaded",e.persistence,T({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.gr}pr(e){Vb.indexOf(e.persistence.toLowerCase())===-1&&(A.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(r){r===void 0&&(r=[]);var n=[...xb,...r];return T({},he,{Gt(o){try{var a={};try{a=ct.Gt(o)||{}}catch{}var l=pe(a,JSON.parse(he.Wt(o)||"{}"));return he.Xt(o,l),l}catch{}return null},Xt(o,a,l,u,d,h){try{he.Xt(o,a,void 0,void 0,h);var f={};n.forEach((g=>{a[g]&&(f[g]=a[g])})),Object.keys(f).length&&ct.Xt(o,f,l,u,d,h)}catch(g){he.Ut(g)}},Jt(o,a){try{_?.localStorage.removeItem(o),ct.Jt(o,a)}catch(l){he.Ut(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&he.Yt()?he:i==="localstorage+cookie"&&t.Yt()?t:i==="sessionstorage"&&Ie.Yt()?Ie:i==="memory"?Lb:i==="cookie"?ct:t.Yt()?t:ct}mr(e){var t=e??this.Rt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[Hr];return!i||typeof i!="number"||Date.now()-i>t}properties(){var e={};return oe(this.props,((t,i)=>{if(i===Os&&be(t)){if(!this.mr())for(var r=Object.keys(t),n=0;r.length>n;n++)e["$feature/"+r[n]]=t[r[n]]}else Ib.indexOf(i)===-1&&(e[i]=t)})),e}load(){if(!this.gr){var e=this.tr.Gt(this.vr);e&&(this.props=pe({},e))}}save(){this.gr||this.tr.Xt(this.vr,this.props,this.yr,this.br,this.wr,this.Rt.debug)}remove(){this.tr.Jt(this.vr,!1),this.tr.Jt(this.vr,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(be(e)){P(t)&&(t="None"),this.yr=P(i)?this._r:i;var r=!1;if(oe(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=n,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(be(e)){this.yr=P(t)?this._r:t;var i=!1;if(oe(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.props[n]=r,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.dr){var e=Gh(this.Rt.custom_campaign_params,this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties);Is(ul(e))||this.register(e),this.dr=!0}}update_search_keyword(){var e;this.register((e=R?.referrer)?jh(e):{})}update_referrer_info(){var e;this.register_once({$referrer:zh(),$referring_domain:R!=null&&R.referrer&&((e=Xr(R.referrer))==null?void 0:e.host)||Zr},void 0)}set_initial_person_info(){this.props[Ra]||this.props[Aa]||this.register_once({[jr]:Kh(this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};oe([Aa,Ra],(o=>{var a=this.props[o];a&&oe(a,(function(l,u){e["$initial_"+ia(u)]=l}))}));var t,i,r=this.props[jr];if(r){var n=(t=qh(r),i={},oe(t,(function(o,a){i["$initial_"+ia(a)]=o})),i);pe(e,n)}return e}safe_merge(e){return oe(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this._r=this.yr=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),u=[...a].sort();return l.every(((d,h)=>d===u[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.pr(e),n=this.props;this.clear(),this.tr=r,this.props=n,this.save()}}set_disabled(e){this.gr=e,this.gr?this.remove():this.save()}set_cross_subdomain(e){e!==this.br&&(this.br=e,this.remove(),this.save())}set_secure(e){e!==this.wr&&(this.wr=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[vi]||{};i[e]=t,this.props[vi]=i,this.save()}remove_event_timer(e){var t=(this.props[vi]||{})[e];return P(t)||(delete this.props[vi][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},oi={Activation:"events",Cancellation:"cancelEvents"},Vo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},yi={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Go={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},xa={Popover:"popover",Inline:"inline"},Gb={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Ad={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Id=ge("[RateLimiter]"),La=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((r=>{Id.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void Id.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(Ta))!==null&&t!==void 0?t:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var u=1>l.tokens;return u||e||(l.tokens=Math.max(0,l.tokens-1)),!u||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=u,(r=this.instance.persistence)==null||r.set_property(Ta,l),{isRateLimited:u,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},ai=ge("[RemoteConfig]"),en=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=L._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}Ir(e){var t,i;(t=L.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Cr(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return ai.info("Using preloaded remote config",this.remoteConfig),this.Sr(this.remoteConfig),void this.kr();if(this._instance.Tr())return void ai.warn("Remote config is disabled. Falling back to local config.");this.Ir((e=>{if(!e)return ai.info("No config found after loading remote JS config. Falling back to JSON."),void this.Cr((t=>{this.Sr(t),this.kr()}));this.Sr(e),this.kr()}))}catch(e){ai.error("Error loading remote config",e)}}stop(){this.Ar&&(clearInterval(this.Ar),this.Ar=void 0)}refresh(){this._instance.Tr()||R?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}kr(){var e;if(!this.Ar){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.Ar=setInterval((()=>{this.refresh()}),t))}}Sr(e){var t;e||ai.error("Failed to fetch remote config from PostHog."),this._instance.Sr(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},ut={GZipJS:"gzip-js",Base64:"base64"},Qe=Uint8Array,Le=Uint16Array,Fs=Uint32Array,cl=new Qe([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]),dl=new Qe([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]),Od=new Qe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Yh=function(s,e){for(var t=new Le(31),i=0;31>i;++i)t[i]=e+=1<<s[i-1];var r=new Fs(t[30]);for(i=1;30>i;++i)for(var n=t[i];t[i+1]>n;++n)r[n]=n-t[i]<<5|i;return[t,r]},Xh=Yh(cl,2),$a=Xh[1];Xh[0][28]=258,$a[258]=28;for(Fa=Yh(dl,0)[1],tn=new Le(32768),se=0;32768>se;++se)Qt=(43690&se)>>>1|(21845&se)<<1,tn[se]=((65280&(Qt=(61680&(Qt=(52428&Qt)>>>2|(13107&Qt)<<2))>>>4|(3855&Qt)<<4))>>>8|(255&Qt)<<8)>>>1;ki=function(s,e,t){for(var i=s.length,r=0,n=new Le(e);i>r;++r)++n[s[r]-1];var o,a=new Le(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(t){o=new Le(1<<e);var l=15-e;for(r=0;i>r;++r)if(s[r])for(var u=r<<4|s[r],d=e-s[r],h=a[s[r]-1]++<<d,f=h|(1<<d)-1;f>=h;++h)o[tn[h]>>>l]=u}else for(o=new Le(i),r=0;i>r;++r)o[r]=tn[a[s[r]-1]++]>>>15-s[r];return o},is=new Qe(288);for(se=0;144>se;++se)is[se]=8;for(se=144;256>se;++se)is[se]=9;for(se=256;280>se;++se)is[se]=7;for(se=280;288>se;++se)is[se]=8;sn=new Qe(32);for(se=0;32>se;++se)sn[se]=5;Hb=ki(is,9,0),jb=ki(sn,5,0),Jh=function(s){return(s/8>>0)+(7&s&&1)},Qh=function(s,e,t){(t==null||t>s.length)&&(t=s.length);var i=new(s instanceof Le?Le:s instanceof Fs?Fs:Qe)(t-e);return i.set(s.subarray(e,t)),i},St=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8},li=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8,s[i+2]|=t>>>16},Ho=function(s,e){for(var t=[],i=0;s.length>i;++i)s[i]&&t.push({s:i,f:s[i]});var r=t.length,n=t.slice();if(!r)return[new Qe(0),0];if(r==1){var o=new Qe(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(O,C){return O.f-C.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],u=0,d=1,h=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};d!=r-1;)a=t[t[h].f>t[u].f?u++:h++],l=t[u!=d&&t[h].f>t[u].f?u++:h++],t[d++]={s:-1,f:a.f+l.f,l:a,r:l};var f=n[0].s;for(i=1;r>i;++i)n[i].s>f&&(f=n[i].s);var g=new Le(f+1),p=Ma(t[d-1],g,0);if(p>e){i=0;var v=0,m=p-e,b=1<<m;for(n.sort((function(O,C){return g[C.s]-g[O.s]||O.f-C.f}));r>i;++i){var k=n[i].s;if(e>=g[k])break;v+=b-(1<<p-g[k]),g[k]=e}for(v>>>=m;v>0;){var D=n[i].s;e>g[D]?v-=1<<e-g[D]++-1:++i}for(;i>=0&&v;--i){var N=n[i].s;g[N]==e&&(--g[N],++v)}p=e}return[new Qe(g),p]},Ma=function(s,e,t){return s.s==-1?Math.max(Ma(s.l,e,t+1),Ma(s.r,e,t+1)):e[s.s]=t},Pd=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new Le(++e),i=0,r=s[0],n=1,o=function(l){t[i++]=l},a=1;e>=a;++a)if(s[a]==r&&a!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=s[a]}return[t.subarray(0,i),e]},ui=function(s,e){for(var t=0,i=0;e.length>i;++i)t+=s[i]*e[i];return t},Ua=function(s,e,t){var i=t.length,r=Jh(e+2);s[r]=255&i,s[r+1]=i>>>8,s[r+2]=255^s[r],s[r+3]=255^s[r+1];for(var n=0;i>n;++n)s[r+n+4]=t[n];return 8*(r+4+i)},Cd=function(s,e,t,i,r,n,o,a,l,u,d){St(e,d++,t),++r[256];for(var h=Ho(r,15),f=h[0],g=h[1],p=Ho(n,15),v=p[0],m=p[1],b=Pd(f),k=b[0],D=b[1],N=Pd(v),O=N[0],C=N[1],S=new Le(19),E=0;k.length>E;++E)S[31&k[E]]++;for(E=0;O.length>E;++E)S[31&O[E]]++;for(var I=Ho(S,7),M=I[0],G=I[1],V=19;V>4&&!M[Od[V-1]];--V);var q,W,ve,Se,Ce=u+5<<3,ae=ui(r,is)+ui(n,sn)+o,w=ui(r,f)+ui(n,v)+o+14+3*V+ui(S,M)+(2*S[16]+3*S[17]+7*S[18]);if(ae>=Ce&&w>=Ce)return Ua(e,d,s.subarray(l,l+u));if(St(e,d,1+(ae>w)),d+=2,ae>w){q=ki(f,g,0),W=f,ve=ki(v,m,0),Se=v;var $=ki(M,G,0);for(St(e,d,D-257),St(e,d+5,C-1),St(e,d+10,V-4),d+=14,E=0;V>E;++E)St(e,d+3*E,M[Od[E]]);d+=3*V;for(var F=[k,O],U=0;2>U;++U){var Z=F[U];for(E=0;Z.length>E;++E)St(e,d,$[ce=31&Z[E]]),d+=M[ce],ce>15&&(St(e,d,Z[E]>>>5&127),d+=Z[E]>>>12)}}else q=Hb,W=is,ve=jb,Se=sn;for(E=0;a>E;++E)if(i[E]>255){var ce;li(e,d,q[257+(ce=i[E]>>>18&31)]),d+=W[ce+257],ce>7&&(St(e,d,i[E]>>>23&31),d+=cl[ce]);var ie=31&i[E];li(e,d,ve[ie]),d+=Se[ie],ie>3&&(li(e,d,i[E]>>>5&8191),d+=dl[ie])}else li(e,d,q[i[E]]),d+=W[i[E]];return li(e,d,q[256]),d+W[256]},zb=new Fs([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Kb=(function(){for(var s=new Fs(256),e=0;256>e;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;s[e]=t}return s})(),jo=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8};Wb=!!sa||!!ta,Zh="text/plain",rn=function(s,e,t){var i;t===void 0&&(t=!0);var[r,n]=s.split("?"),o=T({},e),a=(i=n?.split("&").map((u=>{var d,[h,f]=u.split("="),g=t&&(d=o[h])!==null&&d!==void 0?d:f;return delete o[h],h+"="+g})))!==null&&i!==void 0?i:[],l=(function(u,d){var h,f;d===void 0&&(d="&");var g=[];return oe(u,(function(p,v){P(p)||P(v)||v==="undefined"||(h=encodeURIComponent((m=>m instanceof File)(p)?p.name:p.toString()),f=encodeURIComponent(v),g[g.length]=f+"="+h)})),g.join(d)})(o);return l&&a.push(l),r+"?"+a.join("&")},Ps=(s,e)=>JSON.stringify(s,((t,i)=>typeof i=="bigint"?i.toString():i),e),zo=s=>{if(s.zt)return s.zt;var{data:e,compression:t}=s;if(e){if(t===ut.GZipJS){var i=qb((function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var d=new Qe(a.length+(a.length>>>1)),h=0,f=function(m){d[h++]=m},g=0;u>g;++g){if(h+5>d.length){var p=new Qe(h+8+(u-g<<1));p.set(d),d=p}var v=a.charCodeAt(g);128>v?f(v):2048>v?(f(192|v>>>6),f(128|63&v)):v>55295&&57344>v?(f(240|(v=65536+(1047552&v)|1023&a.charCodeAt(++g))>>>18),f(128|v>>>12&63),f(128|v>>>6&63),f(128|63&v)):(f(224|v>>>12),f(128|v>>>6&63),f(128|63&v))}return Qh(d,0,h)})(Ps(e)),{mtime:0});return{contentType:Zh,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(t===ut.Base64){var r=(function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,((l,u)=>String.fromCharCode(parseInt(u,16)))))})(Ps(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Ps(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Ps(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},Yb=(function(){var s=it((function*(e){var t=Ps(e.data),i=yield(function(n,o){return dh.apply(this,arguments)})(t,ze.DEBUG);if(!i)return e;var r=yield i.arrayBuffer();return T({},e,{zt:{contentType:Zh,body:r,estimatedSize:r.byteLength}})}));return function(e){return s.apply(this,arguments)}})(),Mr=[];ta&&Mr.push({transport:"fetch",method(s){var e,t,{contentType:i,body:r,estimatedSize:n}=(e=zo(s))!==null&&e!==void 0?e:{},o=new Headers;oe(s.headers,(function(d,h){o.append(h,d)})),i&&o.append("Content-Type",i);var a=s.url,l=null;if(ld){var u=new ld;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),s.timeout)}}ta(a,T({method:s?.method||"GET",headers:o,keepalive:s.method==="POST"&&52428.8>(n||0),body:r,signal:(t=l)==null?void 0:t.signal},s.fetchOptions)).then((d=>d.text().then((h=>{var f={statusCode:d.status,text:h};if(d.status===200)try{f.json=JSON.parse(h)}catch(g){A.error(g)}s.callback==null||s.callback(f)})))).catch((d=>{A.error(d),s.callback==null||s.callback({statusCode:0,error:d})})).finally((()=>l?clearTimeout(l.timeout):null))}}),sa&&Mr.push({transport:"XHR",method(s){var e,t=new sa;t.open(s.method||"GET",s.url,!0);var{contentType:i,body:r}=(e=zo(s))!==null&&e!==void 0?e:{};oe(s.headers,(function(n,o){t.setRequestHeader(o,n)})),i&&t.setRequestHeader("Content-Type",i),s.timeout&&(t.timeout=s.timeout),s.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}s.callback==null||s.callback(n)}},t.send(r)}}),Ke!=null&&Ke.sendBeacon&&Mr.push({transport:"sendBeacon",method(s){var e=rn(s.url,{beacon:"1"});try{var t,{contentType:i,body:r}=(t=zo(s))!==null&&t!==void 0?t:{};if(!r)return;var n=r instanceof Blob?r:new Blob([r],{type:i});Ke.sendBeacon(e,n)}catch{}}});Ba=3e3,Va=class{constructor(e,t){this.Er=!0,this.Rr=[],this.Nr=dt(t?.flush_interval_ms||Ba,250,5e3,A.createLogger("flush interval"),Ba),this.Mr=e}enqueue(e){this.Rr.push(e),this.Fr||this.Or()}unload(){this.Pr();var e=this.Rr.length>0?this.Lr():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Mr(T({},i,{transport:"sendBeacon"}))}))}enable(){this.Er=!1,this.Or()}Or(){var e=this;this.Er||(this.Fr=setTimeout((()=>{if(this.Pr(),this.Rr.length>0){var t=this.Lr(),i=function(){var n=t[r],o=new Date().getTime();n.data&&X(n.data)&&oe(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Mr(n)};for(var r in t)i()}}),this.Nr))}Pr(){clearTimeout(this.Fr),this.Fr=void 0}Lr(){var e={};return oe(this.Rr,(t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;P(e[n])&&(e[n]=T({},r,{data:[]})),(i=e[n].data)==null||i.push(r.data)})),this.Rr=[],e}},Xb=["retriesPerformedSoFar"],Ga=class{constructor(e){this.Dr=!1,this.Br=3e3,this.Rr=[],this._instance=e,this.Rr=[],this.jr=!0,!P(_)&&"onLine"in _.navigator&&(this.jr=_.navigator.onLine,this.qr=()=>{this.jr=!0,this.Zr()},this.$r=()=>{this.jr=!1},me(_,"online",this.qr),me(_,"offline",this.$r))}get length(){return this.Rr.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=ch(e,Xb);Ts(t)&&(i.url=rn(i.url,{retry_count:t})),this._instance._send_request(T({},i,{callback:r=>{r.statusCode===200||r.statusCode>=400&&500>r.statusCode||(t??0)>=10?i.callback==null||i.callback(r):this.Hr(T({retriesPerformedSoFar:t},i))}}))}Hr(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),d=Math.random()-.5;return Math.ceil(u+d*(u-l))})(t),r=Date.now()+i;this.Rr.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+i;navigator.onLine||(n+=" (Browser is offline)"),A.warn(n),this.Dr||(this.Dr=!0,this.Vr())}Vr(){if(this.zr&&clearTimeout(this.zr),this.Rr.length===0)return this.Dr=!1,void(this.zr=void 0);this.zr=setTimeout((()=>{this.jr&&this.Rr.length>0&&this.Zr(),this.Vr()}),this.Br)}Zr(){var e=Date.now(),t=[],i=this.Rr.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Rr=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.zr&&(clearTimeout(this.zr),this.zr=void 0),this.Dr=!1,P(_)||(this.qr&&(_.removeEventListener("online",this.qr),this.qr=void 0),this.$r&&(_.removeEventListener("offline",this.$r),this.$r=void 0)),this.Rr))try{this._instance._send_request(T({},e,{transport:"sendBeacon"}))}catch(t){A.error(t)}this.Rr=[]}},Ha=class{constructor(e){this.Yr=()=>{var t,i,r,n;this.Ur||(this.Ur={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+(o?.clientHeight||0),d=o?.scrollHeight||0;this.Ur.lastScrollY=Math.ceil(a),this.Ur.maxScrollY=Math.max(a,(t=this.Ur.maxScrollY)!==null&&t!==void 0?t:0),this.Ur.maxScrollHeight=Math.max(l,(i=this.Ur.maxScrollHeight)!==null&&i!==void 0?i:0),this.Ur.lastContentY=u,this.Ur.maxContentY=Math.max(u,(r=this.Ur.maxContentY)!==null&&r!==void 0?r:0),this.Ur.maxContentHeight=Math.max(d,(n=this.Ur.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get Wr(){return this._instance.config.scroll_root_selector}getContext(){return this.Ur}resetContext(){var e=this.Ur;return setTimeout(this.Yr,0),e}startMeasuringScrollPosition(){me(_,"scroll",this.Yr,{capture:!0}),me(_,"scrollend",this.Yr,{capture:!0}),me(_,"resize",this.Yr)}scrollElement(){if(!this.Wr)return _?.document.documentElement;var e=X(this.Wr)?this.Wr:[this.Wr];for(var t of e){var i=_?.document.querySelector(t);if(i)return i}}scrollY(){if(this.Wr){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this.Wr){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},Jb=s=>Kh(s?.config.mask_personal_data_properties,s?.config.custom_personal_data_properties),nn=class{constructor(e,t,i,r){this.Gr=n=>{var o=this.Xr();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.Jr(this._instance)};this.Kr.register({[wa]:a})}},this._instance=e,this.Qr=t,this.Kr=i,this.Jr=r||Jb,this.Qr.onSessionId(this.Gr)}Xr(){return this.Kr.props[wa]}getSetOnceProps(){var e,t=(e=this.Xr())==null?void 0:e.props;return t?"r"in t?qh(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return oe(ul(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+ia(i)]=t})),e}},Pi=class{constructor(){this.ti={}}on(e,t){return this.ti[e]||(this.ti[e]=[]),this.ti[e].push(t),()=>{this.ti[e]=this.ti[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.ti[e]||[])i(t);for(var r of this.ti["*"]||[])r(e,t)}},Ko=ge("[SessionId]"),on=class{on(e,t){return this.ei.on(e,t)}constructor(e,t,i){var r;if(this.ri=[],this.ii=void 0,this.ei=new Pi,this.ni=(u,d)=>!(!Ts(u)||!Ts(d))&&Math.abs(u-d)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===rt)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Rt=e.config,this.Kr=e.persistence,this.si=void 0,this.oi=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.ai=t||Mt,this.li=i||Mt;var n=this.Rt.persistence_name||this.Rt.token;if(this._sessionTimeoutMs=1e3*dt(this.Rt.session_idle_timeout_seconds||1800,60,36e3,Ko.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.ui(),this.hi="ph_"+n+"_window_id",this.ci="ph_"+n+"_primary_window_exists",this.di()){var o=Ie.Gt(this.hi),a=Ie.Gt(this.ci);o&&!a?this.si=o:Ie.Jt(this.hi),Ie.Xt(this.ci,!0)}if((r=this.Rt.bootstrap)!=null&&r.sessionID)try{var l=(u=>{var d=this.Rt.bootstrap.sessionID.replace(/-/g,"");if(d.length!==32)throw new Error("Not a valid UUID");if(d[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(d.substring(0,12),16)})();this.vi(this.Rt.bootstrap.sessionID,new Date().getTime(),l)}catch(u){Ko.error("Invalid sessionID in bootstrap",u)}this.fi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this.ri)&&(this.ri=[]),this.ri.push(e),this.oi&&e(this.oi,this.si),()=>{this.ri=this.ri.filter((t=>t!==e))}}di(){return this.Rt.persistence!=="memory"&&!this.Kr.gr&&Ie.Yt()}pi(e){e!==this.si&&(this.si=e,this.di()&&Ie.Xt(this.hi,e))}gi(){return this.si?this.si:this.di()?Ie.Gt(this.hi):null}vi(e,t,i){e===this.oi&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.oi=e,this.Kr.register({[Gr]:[t,e,i]}))}mi(){var e=this.Kr.props[Gr];return X(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.vi(null,null,null)}destroy(){clearTimeout(this.yi),this.yi=void 0,this.ii&&_&&(_.removeEventListener(qr,this.ii,{capture:!1}),this.ii=void 0),this.ri=[]}fi(){this.ii=()=>{this.di()&&Ie.Jt(this.ci)},me(_,qr,this.ii,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Rt.cookieless_mode===rt)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||new Date().getTime(),[r,n,o]=this.mi(),a=this.gi(),l=Ts(o)&&Math.abs(i-o)>864e5,u=!1,d=!n,h=!d&&!e&&this.ni(i,r);d||h||l?(n=this.ai(),a=this.li(),Ko.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}}),o=i,u=!0):a||(a=this.li(),u=!0);var f=Ts(r)&&e&&!l?r:i,g=Ts(o)?o:new Date().getTime();return this.pi(a),this.vi(n,f,g),e||this.ui(),u&&this.ri.forEach((p=>p(n,a,u?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:g,changeReason:u?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}ui(){clearTimeout(this.yi),this.yi=setTimeout((()=>{var[e]=this.mi();if(this.ni(new Date().getTime(),e)){var t=this.oi;this.resetSessionId(),this.ei.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},eg=function(s,e){if(!s)return!1;var t=s.userAgent;if(t&&dd(t,e))return!0;try{var i=s?.userAgentData;if(i!=null&&i.brands&&i.brands.some((r=>dd(r?.brand,e))))return!0}catch{}return!!s.webdriver},an=function(s,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(s)}catch{return!1}};tg={exact:(s,e)=>e.some((t=>s.some((i=>t===i)))),is_not:(s,e)=>e.every((t=>s.every((i=>t!==i)))),regex:(s,e)=>e.some((t=>s.some((i=>an(t,i))))),not_regex:(s,e)=>e.every((t=>s.every((i=>!an(t,i))))),icontains:(s,e)=>e.map(xr).some((t=>s.map(xr).some((i=>t.includes(i))))),not_icontains:(s,e)=>e.map(xr).every((t=>s.map(xr).every((i=>!t.includes(i))))),gt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((r=>i>parseFloat(r)))})),lt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((r=>i<parseFloat(r)))}))},xr=s=>s.toLowerCase();ja="custom",Nd="i.posthog.com",za=class{constructor(e){this.bi={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+Nd,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.bi[this.apiHost]||(this.bi[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":ja),this.bi[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===ja)return this.apiHost+t;var i=Nd+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}},te=ge("[Surveys]"),Ka="seenSurvey_",Qb=(s,e)=>{var t="$survey_"+e+"/"+s.id;return s.current_iteration&&s.current_iteration>0&&(t="$survey_"+e+"/"+s.id+"/"+s.current_iteration),t},xd=s=>((e,t)=>{var i=""+Ka+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+Ka+t.id+"_"+t.current_iteration),i})(0,s),Zb=[Vo.Popover,Vo.Widget,Vo.API],eE={ignoreConditions:!1,ignoreDelay:!1,displayType:xa.Popover},tE=ge("[PostHog ExternalIntegrations]"),sE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},qa=class{constructor(e){this._instance=e}nr(e,t){var i;(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(r=>{if(r)return tE.error("failed to load script",r);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,u;!r||(a=L.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.nr(sE[o],(()=>{var d;(d=L.__PosthogExtensions__)==null||(d=d.integrations)==null||(d=d[o])==null||d.start(e._instance)})),!r&&(l=L.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=L.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[i,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(i)}}},wi={},qo=0,Wa=()=>{},Ld='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',ci="Surveys module not available",$d="sanitize_properties is deprecated. Use before_send instead",ig="Invalid value for property_denylist config: ",iE=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,As="posthog",rg=!Wb&&Ge?.indexOf("MSIE")===-1&&Ge?.indexOf("Mozilla")===-1,Fd=s=>{var e;return T({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Cb(R?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Wa,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:s??"unset",__preview_deferred_init_extensions:!1,debug:Ae&&ye(Ae?.search)&&Ae.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(t){A.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ia,before_send:void 0,request_queue_config:{flush_interval_ms:Ba},error_tracking:{},_onCapture:Wa,__preview_eager_load_replay:!1},(t=>({rageclick:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(s))},rE=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Md=s=>{var e={};for(var[t,i]of rE)P(s[t])||(e[i]=s[t]);var r=pe({},e,s);return X(s.property_blacklist)&&(P(s.property_denylist)?r.property_denylist=s.property_blacklist:X(s.property_denylist)?r.property_denylist=[...s.property_blacklist,...s.property_denylist]:A.error(ig+s.property_denylist)),r},Ya=class{constructor(){this.__forceAllowLocalhost=!1}get wi(){return this.__forceAllowLocalhost}set wi(e){A.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},Ms=class s{Ii(e,t){if(e){var i=this.Ci.indexOf(e);i!==-1&&this.Ci.splice(i,1)}return this.Ci.push(t),t.initialize==null||t.initialize(),t}get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new Ya,this.Si=!1,this.version=ze.LIB_VERSION,this.ki=new Pi,this.Ci=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Fd(),this.SentryIntegration=Na,this.sentryIntegration=i=>(function(r,n){var o=Vh(r,n);return{name:Bh,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.xi=!1,this.Ti=null,this.Ai=null,this.Ei=null,this.scrollManager=new Ha(this),this.pageViewManager=new Yr(this),this.rateLimiter=new La(this),this.requestRouter=new za(this),this.consent=new Da(this),this.externalIntegrations=new qa(this);var t=(e=s.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(i,r,n)=>{var o=ye(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{var o=ye(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(i=>A.info('send "'+i?.event+'"',i)))}init(e,t,i){if(i&&i!==As){var r,n=(r=wi[i])!==null&&r!==void 0?r:new s;return n._init(e,t,i),wi[i]=n,wi[As][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var r,n,o,a;if(t===void 0&&(t={}),P(e)||$r(e))return A.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 console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Ri(t.debug),this.Ni=t,this.Mi=[],t.person_profiles?this.Ai=t.person_profiles:t.process_person&&(this.Ai=t.process_person),this.set_config(pe({},Fd(t.defaults),Md(t),{name:i,token:e})),this.config.on_xhr_error&&A.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ut.GZipJS;var l=this.Fi();this.persistence=new Si(this.config,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Si(T({},this.config,{persistence:"sessionStorage"}),l);var u=T({},this.persistence.props),d=T({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Oi=new Va((N=>this.Pi(N)),this.config.request_queue_config),this.Li=new Ga(this),this.__request_queue=[];var h=this.config.cookieless_mode===rt||this.config.cookieless_mode===kt&&this.consent.isExplicitlyOptedOut();h||(this.sessionManager=new on(this),this.sessionPropsManager=new nn(this,this.sessionManager,this.persistence));var f=(r=L._POSTHOG_REMOTE_CONFIG)==null||(r=r[this.config.token])==null?void 0:r.config,g=f==null||(n=f.sdkVersion)==null?void 0:n.resolved;if(g&&(iE.test(g)?this._resolvedSdkVersion=g:A.warn("Ignoring invalid preloaded sdkVersion.resolved from remote config: "+g)),this.config.__preview_deferred_init_extensions?(A.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Di(h)}),0)):(A.info("Initializing extensions synchronously"),this.Di(h)),ze.DEBUG=ze.DEBUG||this.config.debug,ze.DEBUG&&A.info("Starting in debug mode",{this:this,config:t,thisC:T({},this.config),p:u,s:d}),!this.config.identity_distinct_id||(o=t.bootstrap)!=null&&o.distinctID||(t.bootstrap=T({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((a=t.bootstrap)==null?void 0:a.distinctID)!==void 0){var p=t.bootstrap.distinctID,v=this.get_distinct_id(),m=this.persistence.get_property(st);if(t.bootstrap.isIdentifiedID&&v!=null&&v!==p&&m===Ss)this.identify(p);else if(t.bootstrap.isIdentifiedID&&v!=null&&v!==p&&m===ks)A.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var b=this.config.get_device_id(Mt()),k=t.bootstrap.isIdentifiedID?b:p;this.persistence.set_property(st,t.bootstrap.isIdentifiedID?ks:Ss),this.register({distinct_id:p,$device_id:k})}}if(h)this.register_once({distinct_id:Or,$device_id:null},"");else if(!this.get_distinct_id()){var D=this.config.get_device_id(Mt());this.register_once({distinct_id:D,$device_id:D},""),this.persistence.set_property(st,Ss)}return me(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?(function(N,O){var C=N.config.segment;if(!C)return O();(function(S,E){var I=S.config.segment;if(!I)return E();var M=V=>{var q=()=>V.anonymousId()||Mt();S.config.get_device_id=q,V.id()&&(S.register({distinct_id:V.id(),$device_id:q()}),S.persistence.set_property(st,ks)),E()},G=I.user();"then"in G&&wt(G.then)?G.then(M):M(G)})(N,(()=>{C.register((S=>{Promise&&Promise.resolve||Bo.warn("This browser does not have Promise support, and can not use the segment integration");var E=(I,M)=>{if(!M)return I;I.event.userId||I.event.anonymousId===S.get_distinct_id()||(Bo.info("No userId set, resetting PostHog"),S.reset()),I.event.userId&&I.event.userId!==S.get_distinct_id()&&(Bo.info("UserId set, identifying with PostHog"),S.identify(I.event.userId));var G=S.calculateEventProperties(M,I.event.properties);return I.event.properties=Object.assign({},G,I.event.properties),I};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:I=>E(I,I.event.event),page:I=>E(I,Rs),identify:I=>E(I,Mo),screen:I=>E(I,"$screen")}})(N)).then((()=>{O()}))}))})(this,(()=>this.Bi())):this.Bi(),wt(this.config._onCapture)&&this.config._onCapture!==Wa&&(A.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(N=>this.config._onCapture(N.event,N)))),this.config.ip&&A.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Di(e){var t,i,r,n,o,a,l,u=performance.now(),d=T({},s.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.featureFlags&&this.Ci.push(this.featureFlags=(t=this.featureFlags)!==null&&t!==void 0?t:new d.featureFlags(this)),d.exceptions&&this.Ci.push(this.exceptions=(i=this.exceptions)!==null&&i!==void 0?i:new d.exceptions(this)),d.historyAutocapture&&this.Ci.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this.Ci.push(new d.tracingHeaders(this)),d.siteApps&&this.Ci.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!e&&this.Ci.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),d.autocapture&&this.Ci.push(this.autocapture=new d.autocapture(this)),d.surveys&&this.Ci.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new d.surveys(this)),d.logs&&this.Ci.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new d.logs(this)),d.conversations&&this.Ci.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new d.conversations(this)),d.productTours&&this.Ci.push(this.productTours=new d.productTours(this)),d.heatmaps&&this.Ci.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this.Ci.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this.Ci.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this.Ci.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,Fb)),d.toolbar&&this.Ci.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new d.toolbar(this)),d.experiments&&this.Ci.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new d.experiments(this)),this.Ci.forEach((f=>{f.initialize&&h.push((()=>{f.initialize==null||f.initialize()}))})),h.push((()=>{if(this.ji){var f=this.ji;this.ji=void 0,this.Sr(f)}})),this.qi(h,u)}qi(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.qi(e,t)}),0);var i=e.shift();if(i)try{i()}catch(n){A.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&A.info("PostHog extensions initialized ("+r+"ms)")}Sr(e){var t;if(!R||!R.body)return A.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Sr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.ji=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=j(e.supportedCompression,ut.GZipJS)?ut.GZipJS:j(e.supportedCompression,ut.Base64)?ut.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ai?this.Ai:Ia}),this.Ci.forEach((i=>i.onRemoteConfig==null?void 0:i.onRemoteConfig(e)))}Bi(){try{this.config.loaded(this)}catch(i){A.critical("`loaded` function failed",i)}if(this.Zi(),this.config.internal_or_test_user_hostname&&Ae!=null&&Ae.hostname){var e=Ae.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode===rt)&&this.$i()}),1),this.Hi=new en(this),this.Hi.load()}Zi(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Oi)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Pr(this.__request_queue,(e=>this.Pi(e))),this.__request_queue=[],this.Zi()}_handle_unload(){var e,t,i;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Vi()&&this.capture(Fo),(t=this.Oi)==null||t.unload(),(i=this.Li)==null||i.unload()):this.Vi()&&this.capture(Fo,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(rg?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=rn(e.url,{ip:this.config.ip?1:0}),e.headers=T({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var i,r,n,o=T({},t);o.timeout=o.timeout||6e4,o.url=rn(o.url,{_:new Date().getTime().toString(),ver:ze.JS_SDK_VERSION,compression:o.compression});var a=(i=o.transport)!==null&&i!==void 0?i:"fetch",l=Mr.filter((d=>!o.disableTransport||!d.transport||!o.disableTransport.includes(d.transport))),u=(r=(n=(function(d,h){for(var f=0;d.length>f;f++)if(d[f].transport===a)return d[f]})(l))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!u)throw new Error("No available transport method");a!=="sendBeacon"&&o.data&&o.compression===ut.GZipJS&&eb?Yb(o).then((d=>{u(d)})).catch((()=>{u(o)})):u(o)})(T({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(i=(r=this.config).on_request_error)==null||i.call(r,t),e.callback==null||e.callback(t)}}))))}Pi(e){this.Li?this.Li.retriableRequest(e):this._send_request(e)}_execute_array(e){qo++;try{var t,i=[],r=[],n=[];Pr(e,(a=>{a&&(X(t=a[0])?n.push(a):wt(a)?a.call(this):X(a)&&t==="alias"?i.push(a):X(a)&&t.indexOf("capture")!==-1&&wt(this[t])?n.push(a):r.push(a))}));var o=function(a,l){Pr(a,(function(u){if(X(u[0])){var d=l;oe(u,(function(h){d=d[h[0]].apply(d,h.slice(1))}))}else l[u[0]].apply(l,u.slice(1))}))};o(i,this),o(r,this),o(n,this)}finally{qo--}}push(e){if(qo>0&&X(e)&&ye(e[0])){var t=s.prototype[e[0]];wt(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,i){var r,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Oi){if(this.is_capturing())if(!P(e)&&ye(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var d=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(d==null||!d.isRateLimited){t!=null&&t.$current_url&&!ye(t?.$current_url)&&(A.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!=="$exception"||i!=null&&i.zi||A.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var h=new Date,f=i?.timestamp||h,g=Mt(),p={uuid:g,event:e,properties:this.calculateEventProperties(e,t||{},f,g)};e===Rs&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),d&&(p.properties.$lib_rate_limit_remaining_tokens=d.remainingTokens),i?.$set&&(p.$set=i?.$set);var v,m=this.Yi(i?.$set_once,e!==kd,e===Mo);if(m&&(p.$set_once=m),i!=null&&i._noTruncate||(n=this.config.properties_string_max_length,o=p,a=S=>ye(S)?S.slice(0,n):S,l=new Set,p=(function S(E,I){return E!==Object(E)?a?a(E):E:l.has(E)?void 0:(l.add(E),X(E)?(M=[],Pr(E,(G=>{M.push(S(G))}))):(M={},oe(E,((G,V)=>{l.has(G)||(M[V]=S(G,V))}))),M);var M})(o)),p.timestamp=f,P(i?.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=h),e===yi.DISMISSED||e===yi.SENT){var b=t?.[Go.SURVEY_ID],k=t?.[Go.SURVEY_ITERATION];v={id:b,current_iteration:k},localStorage.getItem(xd(v))||localStorage.setItem(xd(v),"true"),p.$set=T({},p.$set,{[Qb({id:b,current_iteration:k},e===yi.SENT?"responded":"dismissed")]:!0})}else e===yi.SHOWN&&(p.$set=T({},p.$set,{[Go.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Gb.SHOWN){var D=t?.[Ad.TOUR_TYPE];D&&(p.$set=T({},p.$set,{[Ad.TOUR_LAST_SEEN_DATE+"/"+D]:new Date().toISOString()}))}var N=T({},p.properties.$set,p.$set);if(Is(N)||this.setPersonPropertiesForFlags(N),!z(this.config.before_send)){var O=this.Ui(p);if(!O)return;p=O}this.ki.emit("eventCaptured",p);var C={method:"POST",url:(r=i?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:i?._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Pi(C):this.Oi.enqueue(C),p}A.critical("This capture call is ignored due to client rate limiting.")}}else A.error("No event name provided to posthog.capture")}else A.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=T({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode==rt||this.config.cookieless_mode==kt&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=T({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ye(a.distinct_id)&&!ht(a.distinct_id)||$r(a.distinct_id))&&A.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,d=(function(b,k){var D,N,O,C;if(!Ge)return{};var S,E,I,M,G,V,q,W,ve=b?[...$s,...k||[]]:[],[Se,Ce]=(function(ae){for(var w=0;fd.length>w;w++){var[$,F]=fd[w],U=$.exec(ae),Z=U&&(wt(F)?F(U,ae):F);if(Z)return Z}return["",""]})(Ge);return pe(ul({$os:Se,$os_version:Ce,$browser:Ph(Ge,navigator.vendor),$device:pd(Ge),$device_type:(E=Ge,I={userAgentDataPlatform:(D=navigator)==null||(D=D.userAgentData)==null?void 0:D.platform,maxTouchPoints:(N=navigator)==null?void 0:N.maxTouchPoints,screenWidth:_==null||(O=_.screen)==null?void 0:O.width,screenHeight:_==null||(C=_.screen)==null?void 0:C.height,devicePixelRatio:_?.devicePixelRatio},W=pd(E),W===vh||W===ph||W==="Kobo"||W==="Kindle Fire"||W===Oh?Ns:W===Ri||W===Ds||W===Ai||W===oa?"Console":W===mh?"Wearable":W?qe:I?.userAgentDataPlatform==="Android"&&((M=I?.maxTouchPoints)!==null&&M!==void 0?M:0)>0?600>Math.min((G=I?.screenWidth)!==null&&G!==void 0?G:0,(V=I?.screenHeight)!==null&&V!==void 0?V:0)/((q=I?.devicePixelRatio)!==null&&q!==void 0?q:1)?qe:Ns:"Desktop"),$timezone:Wh(),$timezone_offset:Bb()}),{$current_url:Ii(Ae?.href,ve,Oi),$host:Ae?.host,$pathname:Ae?.pathname,$raw_user_agent:Ge.length>1e3?Ge.substring(0,997)+"...":Ge,$browser_version:pb(Ge,navigator.vendor),$browser_language:Rd(),$browser_language_prefix:(S=Rd(),typeof S=="string"?S.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.innerWidth,$lib:ze.LIB_NAME,$lib_version:ze.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime());a.$session_id=h,a.$window_id=f}this.sessionPropsManager&&pe(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&pe(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Li)==null?void 0:g.length}catch(b){a.$sdk_debug_error_capturing_properties=String(b)}if(this.requestRouter.region===ja&&(a.$lib_custom_api_host=this.config.api_host),u=e!==Rs||n?e!==Fo||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=pe(a,u),e===Rs&&R&&(a.title=R.title),!P(o)){var p=i.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}Ge&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=pe({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),X(this.config.property_denylist)?oe(this.config.property_denylist,(function(b){delete a[b]})):A.error(ig+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(A.error($d),a=v(a,e));var m=this.Wi();return a.$process_person_profile=m,m&&!n&&this.Gi("_calculate_event_properties"),a}Yi(e,t,i){var r;if(t===void 0&&(t=!0),i===void 0&&(i=!1),!this.persistence||!this.Wi()||this.Si&&!i)return e;var n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),a=pe({},n,o||{},e||{}),l=this.config.sanitize_properties;return l&&(A.error($d),a=l(a,"$set_once")),t&&(this.Si=!0),Is(a)?void 0:a}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var r;(r=this.persistence)==null||r.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}Xi(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return(t=this.featureFlags)==null?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var i;return(i=this.featureFlags)==null?void 0:i.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return t===void 0&&(t=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.ki.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:ci}),()=>{})}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:ci})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:ci})}renderSurvey(e,t){var i;(i=this.surveys)==null||i.renderSurvey(e,t)}displaySurvey(e,t){var i;t===void 0&&(t=eE),(i=this.surveys)==null||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return(t=(i=this.surveys)==null?void 0:i.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:ci}}canRenderSurveyAsync(e,t){var i,r;return t===void 0&&(t=!1),(i=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:ci})}Ji(e){return!e||$r(e)?(A.critical("Unique user id has not been set in posthog.identify"),!1):e===Or?(A.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(A.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return A.uninitializedWarning("posthog.identify");if(ht(e)&&(e=e.toString(),A.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Ji(e)&&this.Gi("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Vr)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(pi)&&(this.unregister(pi),this.register({distinct_id:e}));var n,o=(this.persistence.get_property(st)||Ss)===Ss;e!==r&&o?(this.persistence.set_property(st,ks),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(Mo,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.Ei=Dd(e,t,i),(n=this.featureFlags)==null||n.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(Ei))}}setPersonProperties(e,t){if((e||t)&&this.Gi("posthog.setPersonProperties")){var i=Dd(this.get_distinct_id(),e,t);this.Ei!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Ei=i):A.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var r=this.getGroups(),n=r[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:T({},r,{[e]:t})}),n||i){var o={$group_type:e,$group_key:t};i&&(o.$group_set=i),this.capture(kd,o)}i&&this.setGroupPropertiesForFlags({[e]:i}),n&&!i&&this.reloadFeatureFlags()}else A.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),this.Gi("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,n,o,a,l,u;if(A.info("reset"),!this.__loaded)return A.uninitializedWarning("posthog.reset");var d=this.get_property(Vr);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(i=this.sessionPersistence)==null||i.clear(),(r=this.surveys)==null||r.reset(),(n=this.Hi)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.conversations)==null||a.reset(),(l=this.persistence)==null||l.set_property(st,Ss),(u=this.sessionManager)==null||u.resetSessionId(),this.Ei=null,this.config.cookieless_mode===rt)this.register_once({distinct_id:Or,$device_id:null},"");else{var h=this.config.get_device_id(Mt());this.register_once({distinct_id:h,$device_id:e?h:d},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(i=this.conversations)==null||i.Ki()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.Qi()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}return r}alias(e,t){return e===this.get_property(xh)?(A.critical("Attempting to create alias for existing People user - aborting."),-2):this.Gi("posthog.alias")?(P(t)&&(t=this.get_distinct_id()),e!==t?(this.Xi(pi,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(A.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=T({},this.config);if(be(e)){var i,r,n,o,a,l,u,d,h;pe(this.config,Md(e));var f=this.Fi();(i=this.persistence)==null||i.update_config(this.config,t,f),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Si(T({},this.config,{persistence:"sessionStorage"}),f);var g=this.Ri(this.config.debug);Tt(g)&&(this.config.debug=g),Tt(this.config.debug)&&(this.config.debug?(ze.DEBUG=!0,he.Yt()&&he.Xt("ph_debug",!0),A.info("set_config",{config:e,oldConfig:t,newConfig:T({},this.config)})):(ze.DEBUG=!1,he.Yt()&&he.Jt("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(u=this.deadClicksAutocapture)==null||u.startIfEnabledOrStop(),(d=this.surveys)==null||d.loadIfEnabled(),this.tn(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){ze.LIB_NAME=e,ze.LIB_VERSION=t}startSessionRecording(e){var t,i,r,n,o,a=e===!0,l={sampling:a||!(e==null||!e.sampling),linked_flag:a||!(e==null||!e.linked_flag),url_trigger:a||!(e==null||!e.url_trigger),event_trigger:a||!(e==null||!e.event_trigger)};Object.values(l).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),l.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),l.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),l.url_trigger&&((n=this.sessionRecording)==null||n.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(T({},r,t))}}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return(t=(i=this.toolbar)==null?void 0:i.loadToolbar(e))!==null&&t!==void 0&&t}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:As;return t!==As&&(t=As+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(st))===ks||((t=this.sessionPersistence)==null?void 0:t.get_property(st))===ks}Wi(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles===Ia&&!this._isIdentified()&&Is(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[pi])&&((t=this.persistence)==null||(t=t.props)==null||!t[zr]))}Vi(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.Wi()||this.Gi("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Gi("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Gi(e){return this.config.person_profiles==="never"?(A.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Xi(zr,!0),!0)}Fi(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==kt)}tn(){var e,t,i,r,n=this.Fi();return((e=this.persistence)==null?void 0:e.gr)!==n&&((i=this.persistence)==null||i.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.gr)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==rt){if(this.config.cookieless_mode===kt&&this.consent.isExplicitlyOptedOut()){var i,r,n,o,a;this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new on(this),this.pageViewManager=new Yr(this),this.persistence&&(this.sessionPropsManager=new nn(this,this.sessionManager,this.persistence));var l=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=s.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=this.Ii(this.sessionRecording,new l(this)))}var u,d;this.consent.optInOut(!0),this.tn(),this.Zi(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode==kt&&((u=this.surveys)==null||u.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((d=e?.captureEventName)!==null&&d!==void 0?d:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.$i()}else A.warn(Ld)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==rt?(this.config.cookieless_mode===kt&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.tn(),this.config.cookieless_mode===kt&&(this.register({distinct_id:Or,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(i=this.sessionRecording)==null||i.stopRecording(),this.sessionRecording=void 0,this.$i())):A.warn(Ld)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===rt||(this.config.cookieless_mode===kt?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.tn()}_is_bot(){return Ke?eg(Ke,this.config.custom_blocked_useragents):void 0}$i(){R&&(R.visibilityState==="visible"?this.xi||(this.xi=!0,this.capture(Rs,{title:R.title},{send_instantly:!0}),this.Ti&&(R.removeEventListener(Kr,this.Ti),this.Ti=null)):this.Ti||(this.Ti=this.$i.bind(this),me(R,Kr,this.Ti)))}debug(e){e===!1?(_?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(_?.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)`."),this.set_config({debug:!0}))}Tr(){var e,t,i,r,n,o,a=this.Ni||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(A.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",r=A,n=(t="advanced_disable_flags")in(e=a)&&!z(e[t]),o=i in e&&!z(e[i]),n?e[t]:!!o&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}Ui(e){if(z(this.config.before_send))return e;var t=X(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),z(i)){var n="Event '"+e.event+"' was rejected in beforeSend function";return rb(e.event)?A.warn(n+". This can cause unexpected behavior."):A.info(n),null}i.properties&&!Is(i.properties)||A.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.lr)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Ri(e){var t=Tt(e)&&!e,i=he.Yt()&&he.Wt("ph_debug")==="true";return!t&&(!!i||e)}};Ms.__defaultExtensionClasses={},(function(s,e){for(var t=0;e.length>t;t++)s.prototype[e[t]]=Ob(s.prototype[e[t]])})(Ms,["identify"]);gl=["a","button","form","input","select","textarea","label"];nE=["next","previous","prev",">","<"],Hd=[".ph-no-rageclick",".ph-no-capture"],Xa=s=>!s||Ut(s,"html")||!hn(s),jd=(s,e)=>{if(!_||Xa(s))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[s],r=s;r.parentNode&&!Ut(r,"body");)if(og(r.parentNode))i.push(r.parentNode.host),r=r.parentNode.host;else{var n=lg(r);if(!n)break;if(e||gl.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:i}};cg="(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})",oE=new RegExp("^(?:"+cg+")$"),aE=new RegExp(cg),dg="\\d{3}-?\\d{2}-?\\d{4}",lE=new RegExp("^("+dg+")$"),uE=new RegExp("("+dg+")");un=class{constructor(e){this.disabled=e===!1;var t=be(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Wo="$copy_autocapture",qd=ge("[AutoCapture]");di=ge("[ExceptionAutocapture]");gE=ge("[TracingHeaders]"),xt=ge("[Web Vitals]"),Yd=9e5,Xd="disabled",Jd="lazy_loading",hi="awaiting_config",Lr="missing_config";ge("[SessionRecording]");Qa="[SessionRecording]",Lt=ge(Qa),fE=ge("[Heatmaps]");Zd=ge("[Product Tours]"),Xo="ph_product_tours",pE=["$set_once","$set"],$t=ge("[SiteApps]"),eh="Error while initializing PostHog app with config id ";Za=class{constructor(e){this.en=new Pi,this.rn=(t,i)=>this.nn(t,i)&&this.sn(t,i)&&this.an(t,i)&&this.ln(t,i),this.nn=(t,i)=>i==null||!i.event||t?.event===i?.event,this._instance=e,this.un=new Set,this.hn=new Set}init(){var e,t;P((e=this._instance)==null?void 0:e._addCaptureHook)||(t=this._instance)==null||t._addCaptureHook(((i,r)=>{this.on(i,r)}))}register(e){var t,i;if(!P((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.hn)==null||a.add(o),(l=o.steps)==null||l.forEach((u=>{var d;(d=this.un)==null||d.add(u?.event||"")}))})),(i=this._instance)!=null&&i.autocapture)){var r,n=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&n.add(l?.selector)}))})),(r=this._instance)==null||r.autocapture.setElementSelectors(n)}}on(e,t){var i;t!=null&&e.length!=0&&(this.un.has(e)||this.un.has(t?.event))&&this.hn&&((i=this.hn)==null?void 0:i.size)>0&&this.hn.forEach((r=>{this.cn(t,r)&&this.en.emit("actionCaptured",r.name)}))}dn(e){this.onAction("actionCaptured",(t=>e(t)))}cn(e,t){if(t?.steps==null)return!1;for(var i of t.steps)if(this.rn(e,i))return!0;return!1}onAction(e,t){return this.en.on(e,t)}sn(e,t){if(t!=null&&t.url){var i,r=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!r||typeof r!="string"||!ws(r,t.url,t.url_matching||"contains"))return!1}return!0}an(e,t){return!!this.vn(e,t)&&!!this.fn(e,t)&&!!this.pn(e,t)}vn(e,t){var i;if(t==null||!t.href)return!0;var r=this.gn(e);if(r.length>0)return r.some((a=>ws(a.href,t.href,t.href_matching||"exact")));var n,o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!o&&ws((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}fn(e,t){var i;if(t==null||!t.text)return!0;var r=this.gn(e);if(r.length>0)return r.some((u=>ws(u.text,t.text,t.text_matching||"exact")||ws(u.$el_text,t.text,t.text_matching||"exact")));var n,o,a,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(n=(function(u){for(var d,h=[],f=/(?::|")text="(.*?)"/g;!z(d=f.exec(u));)h.includes(d[1])||h.push(d[1]);return h})(l),o=t.text,a=t.text_matching||"exact",n.some((u=>ws(u,o,a))))}pn(e,t){var i,r;if(t==null||!t.selector)return!0;var n=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}gn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}ln(e,t){return t==null||!t.properties||t.properties.length===0||sg(t.properties.reduce(((i,r)=>{var n=X(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return i[r.key]={values:n,operator:r.operator||"exact"},i}),{}),e?.properties)}},el=class{constructor(e){this._instance=e,this.mn=new Map,this.yn=new Map,this.bn=new Map}wn(e,t){return!!e&&sg(e.propertyFilters,t?.properties)}_n(e,t){var i=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=i.get(o.name)||[];a.push(r.id),i.set(o.name,a)}}))})),i}In(e,t,i){var r=(i===oi.Activation?this.mn:this.yn).get(e),n=[];return this.Cn((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[i])==null||(a=a.values)==null?void 0:a.find((u=>u.name===e));return this.wn(l,t)}))}register(e){var t;P((t=this._instance)==null?void 0:t._addCaptureHook)||(this.Sn(e),this.kn(e))}kn(e){var t=e.filter((i=>{var r,n;return((r=i.conditions)==null?void 0:r.actions)&&((n=i.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.xn==null&&(this.xn=new Za(this._instance),this.xn.init(),this.xn.dn((i=>{this.onAction(i)}))),t.forEach((i=>{var r,n,o,a,l;i.conditions&&(r=i.conditions)!=null&&r.actions&&(n=i.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.xn)==null||a.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var d=this.bn.get(u.name);d&&d.push(i.id),this.bn.set(u.name,d||[i.id])}})))})))}Sn(e){var t,i=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.events)&&((a=n.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),r=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.cancelEvents)&&((a=n.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));i.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.mn=this._n(e,oi.Activation),this.yn=this._n(e,oi.Cancellation))}onEvent(e,t){var i,r=this.re(),n=this.Tn(),o=this.An(),a=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[n])||[];if(o===e&&t&&a.length>0){var l,u;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var d=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(u=t.properties)==null?void 0:u.$product_tour_id);if(d){var h=a.indexOf(d);0>h||(a.splice(h,1),this.En(a))}}else{if(this.yn.has(e)){var f=this.In(e,t,oi.Cancellation);f.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((p=>p.id))}),f.forEach((p=>{var v=a.indexOf(p.id);0>v||a.splice(v,1),this.Rn(p.id)})),this.En(a))}if(this.mn.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.mn.get(e)});var g=this.In(e,t,oi.Activation);this.En(a.concat(g.map((p=>p.id))||[]))}}}onAction(e){var t,i=this.Tn(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.bn.has(e)&&this.En(r.concat(this.bn.get(e)||[]))}En(e){var t,i=this.re(),r=this.Tn(),n=[...new Set(e)].filter((o=>!this.Nn(o)));i.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:n})}getActivatedIds(){var e,t=this.Tn();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.mn}Mn(){return this.xn}},tl=class extends el{constructor(e){super(e)}Tn(){return"$surveys_activated"}An(){return yi.SHOWN}Cn(e){var t;(t=this._instance)==null||t.getSurveys(e)}Rn(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}re(){return te}Nn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Jo="SDK is not enabled or survey functionality is not yet loaded",th="Disabled. Not loading surveys.",vE=_!=null&&_.location?Qr(_.location.hash,"__posthog")||Qr(location.hash,"state"):null,sh="_postHogToolbarParams",ih=ge("[Toolbar]"),Ne=ge("[FeatureFlags]"),Zt=ge("[FeatureFlags]",{debugEnabled:!0}),Qo=`" failed. Feature flags didn't load in time.`,Zo="$active_feature_flags",Ft="$override_feature_flags",rh="$feature_flag_payloads",gi="$override_feature_flag_payloads",nh="$feature_flag_request_id",oh=s=>{for(var e={},t=0;s.length>t;t++)e[s[t]]=!0;return e},ah=s=>{var e={};for(var[t,i]of Fr(s||{}))i&&(e[t]=i);return e},ea=ge("[Error tracking]"),lh="Refusing to render web experiment since the viewer is a likely bot",_E={icontains:(s,e)=>!!_&&e.href.toLowerCase().indexOf(s.toLowerCase())>-1,not_icontains:(s,e)=>!!_&&e.href.toLowerCase().indexOf(s.toLowerCase())===-1,regex:(s,e)=>!!_&&an(e.href,s),not_regex:(s,e)=>!!_&&!an(e.href,s),exact:(s,e)=>e.href===s,is_not:(s,e)=>e.href!==s},sl=class s{get Rt(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((r=>{s.Fn("retrieved web experiments from the server"),t.On=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;t.On&&(s.Fn("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=t.On)==null||o.set(n.feature_flag_key,n));var a=t._instance.getFeatureFlag(n.feature_flag_key);ye(a)&&n.variants[a]&&t.Pn(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];s.Ln(u)&&t.Pn(n.name,l,u.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())s.Fn(lh);else if(!this.Rt.disable_web_experiments){if(z(this.On))return this.On=new Map,this.loadIfEnabled(),void this.previewWebExperiment();s.Fn("applying feature flags",e),e.forEach((t=>{var i;if(this.On&&(i=this.On)!=null&&i.has(t)){var r,n=this._instance.getFeatureFlag(t),o=(r=this.On)==null?void 0:r.get(t);n&&o!=null&&o.variants[n]&&this.Pn(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=s.getWindowLocation();if(e!=null&&e.search){var t=Jr(e?.search,"__experiment_id"),i=Jr(e?.search,"__experiment_variant");t&&i&&(s.Fn("previewing web experiments "+t+" && "+i),this.getWebExperiments((r=>{this.Dn(parseInt(t),i,r)}),!1,!0))}}loadIfEnabled(){this.Rt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.Rt.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Rt.token),method:"GET",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}Dn(e,t,i){var r=i.filter((n=>n.id===e));r&&r.length>0&&(s.Fn("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Pn(r[0].name,t,r[0].variants[t].transforms))}static Ln(e){return!z(e.conditions)&&s.Bn(e)&&s.jn(e)}static Bn(e){var t;if(z(e.conditions)||z((t=e.conditions)==null?void 0:t.url))return!0;var i,r,n,o=s.getWindowLocation();return!!o&&((i=e.conditions)==null||!i.url||_E[(r=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&r!==void 0?r:"icontains"](e.conditions.url,o))}static getWindowLocation(){return _?.location}static jn(e){var t;if(z(e.conditions)||z((t=e.conditions)==null?void 0:t.utm))return!0;var i=Gh();if(i.utm_source){var r,n,o,a,l,u,d,h,f=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==i.utm_campaign,g=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==i.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==i.utm_medium,v=(d=e.conditions)==null||(d=d.utm)==null||!d.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return f&&p&&v&&g}return!1}static Fn(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];A.info("[WebExperiments] "+e,i)}Pn(e,t,i){this._is_bot()?s.Fn(lh):t!=="control"?i.forEach((r=>{if(r.selector){var n;s.Fn("applying transform of variant "+t+" for experiment "+e+" ",r);var o=(n=document)==null?void 0:n.querySelectorAll(r.selector);o?.forEach((a=>{var l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)}))}})):s.Fn("Control variants leave the page unmodified.")}_is_bot(){return Ke&&this._instance?eg(Ke,this.Rt.custom_blocked_useragents):void 0}},Je=ge("[Conversations]"),es="Conversations not available yet.",gn={featureFlags:class{constructor(s){this.qn=!1,this.Zn=!1,this.$n=!1,this.Hn=!1,this.Vn=!1,this.zn=!1,this.Yn=!1,this.Un=!1,this._instance=s,this.featureFlagEventHandlers=[]}get Rt(){return this._instance.config}get Kr(){return this._instance.persistence}Wn(s){return this._instance.get_property(s)}Gn(){var s,e;return(s=(e=this.Kr)==null?void 0:e.mr(this.Rt.feature_flag_cache_ttl_ms))!==null&&s!==void 0&&s}Xn(){return!!this.Gn()&&(this.Un||this.$n||(this.Un=!0,Ne.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Jn(){var s,e=(s=this.Rt.evaluation_contexts)!==null&&s!==void 0?s:this.Rt.evaluation_environments;return!this.Rt.evaluation_environments||this.Rt.evaluation_contexts||this.Yn||(Ne.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Yn=!0),e!=null&&e.length?e.filter((t=>{var i=t&&typeof t=="string"&&t.trim().length>0;return i||Ne.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}Kn(){return this.Jn().length>0}initialize(){var s,e,{config:t}=this._instance,i=(s=(e=t.bootstrap)==null?void 0:e.featureFlags)!==null&&s!==void 0?s:{};if(Object.keys(i).length){var r,n,o=(r=(n=t.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(i).filter((u=>!!i[u])).reduce(((u,d)=>(u[d]=i[d]||!1,u)),{}),l=Object.keys(o).filter((u=>a[u])).reduce(((u,d)=>(o[d]&&(u[d]=o[d]),u)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(s,e,t){var i=t!=null&&t.merge?this.getFlagVariants():{},r=t!=null&&t.merge?this.getFlagPayloads():{},n=T({},i,s),o=T({},r,e),a={};for(var[l,u]of Object.entries(n)){var d=typeof u=="string";a[l]={key:l,enabled:!!d||!!u,variant:d?u:void 0,reason:void 0,metadata:P(o?.[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.receivedFeatureFlags({flags:a})}get hasLoadedFlags(){return this.Zn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var s=this.Wn(ba),e=this.Wn(Ft),t=this.Wn(gi);if(!t&&!e)return s||{};var i=pe({},s||{}),r=[...new Set([...Object.keys(t||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=i[n],u=e?.[n],d=P(u)?(o=l?.enabled)!==null&&o!==void 0&&o:!!u,h=P(u)?l.variant:typeof u=="string"?u:void 0,f=t?.[n],g=T({},l,{enabled:d,variant:d?h??l?.variant:void 0});d!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),f&&(g.metadata=T({},l?.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),i[n]=g}return this.qn||(Ne.warn(" Overriding feature flag details!",{flagDetails:s,overriddenPayloads:t,finalDetails:i}),this.qn=!0),i}getFlagVariants(){var s=this.Wn(Os),e=this.Wn(Ft);if(!e)return s||{};for(var t=pe({},s),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.qn||(Ne.warn(" Overriding feature flags!",{enabledFlags:s,overriddenFlags:e,finalFlags:t}),this.qn=!0),t}getFlagPayloads(){var s=this.Wn(rh),e=this.Wn(gi);if(!e)return s||{};for(var t=pe({},s||{}),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.qn||(Ne.warn(" Overriding feature flag payloads!",{flagPayloads:s,overriddenPayloads:e,finalPayloads:t}),this.qn=!0),t}reloadFeatureFlags(){this.Hn||this.Rt.advanced_disable_feature_flags||this.Qn||(this._instance.ki.emit("featureFlagsReloading",!0),this.Qn=setTimeout((()=>{this.ts()}),5))}es(){clearTimeout(this.Qn),this.Qn=void 0}ensureFlagsLoaded(){this.Zn||this.$n||this.Qn||this.reloadFeatureFlags()}setAnonymousDistinctId(s){this.$anon_distinct_id=s}setReloadingPaused(s){this.Hn=s}ts(s){var e;if(this.es(),!this._instance.Tr())if(this.$n)this.Vn=!0;else{var t=this.Rt.token,i=this.Wn(Vr),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:T({},((e=this.Kr)==null?void 0:e.get_initial_props())||{},this.Wn(mi)||{}),group_properties:this.Wn(ts),timezone:Wh()};Bt(i)||P(i)||(r.$device_id=i),(s!=null&&s.disableFlags||this.Rt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Kn()&&(r.evaluation_contexts=this.Jn());var n=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Rt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.$n=!0,this._instance._send_request({method:"POST",url:n,data:r,compression:this.Rt.disable_compression?void 0:ut.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback:o=>{var a,l,u,d=!0;if(o.statusCode===200&&(this.Vn||(this.$anon_distinct_id=void 0),d=!1),this.$n=!1,!r.disable_flags||this.Vn){this.zn=!d;var h=[];o.error?o.error instanceof Error?h.push(o.error.name==="AbortError"?"timeout":"connection_error"):h.push("unknown_error"):o.statusCode!==200&&h.push("api_error_"+o.statusCode),(a=o.json)!=null&&a.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");var f,g=!((l=o.json)==null||(l=l.quotaLimited)==null||!l.includes("feature_flags"));g&&h.push("quota_limited"),(u=this.Kr)==null||u.register({[ka]:h}),g?Ne.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(r.disable_flags||this.receivedFeatureFlags((f=o.json)!==null&&f!==void 0?f:{},d),this.Vn&&(this.Vn=!1,this.ts()))}}})}}getFeatureFlag(s,e){var t;if(e===void 0&&(e={}),!e.fresh||this.zn)if(this.Zn||this.getFlags()&&this.getFlags().length>0){if(!this.Xn()){var i=this.getFeatureFlagResult(s,e);return(t=i?.variant)!==null&&t!==void 0?t:i?.enabled}}else Ne.warn('getFeatureFlag for key "'+s+Qo)}getFeatureFlagDetails(s){return this.getFlagsWithDetails()[s]}getFeatureFlagPayload(s){var e=this.getFeatureFlagResult(s,{send_event:!1});return e?.payload}getFeatureFlagResult(s,e){if(e===void 0&&(e={}),!e.fresh||this.zn)if(this.Zn||this.getFlags()&&this.getFlags().length>0){if(!this.Xn()){var t=this.getFlagVariants(),i=s in t,r=t[s],n=this.getFlagPayloads()[s],o=String(r),a=this.Wn(nh)||void 0,l=this.Wn(Hr)||void 0,u=this.Wn(Ei)||{};if(this.Rt.advanced_feature_flags_dedup_per_session){var d,h=this._instance.get_session_id(),f=this.Wn(Sa);h&&h!==f&&(u={},(d=this.Kr)==null||d.register({[Ei]:u,[Sa]:h}))}if((e.send_event||!("send_event"in e))&&(!(s in u)||!u[s].includes(o))){var g,p,v,m,b,k,D,N,O,C;X(u[s])?u[s].push(o):u[s]=[o],(g=this.Kr)==null||g.register({[Ei]:u});var S=this.getFeatureFlagDetails(s),E=[...(p=this.Wn(ka))!==null&&p!==void 0?p:[]];P(r)&&E.push("flag_missing");var I={$feature_flag:s,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((v=this.Rt.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[s])||null,$feature_flag_bootstrapped_payload:((m=this.Rt.bootstrap)==null||(m=m.featureFlagPayloads)==null?void 0:m[s])||null,$used_bootstrap_value:!this.zn};P(S==null||(b=S.metadata)==null?void 0:b.version)||(I.$feature_flag_version=S.metadata.version);var M,G=(k=S==null||(D=S.reason)==null?void 0:D.description)!==null&&k!==void 0?k:S==null||(N=S.reason)==null?void 0:N.code;G&&(I.$feature_flag_reason=G),S!=null&&(O=S.metadata)!=null&&O.id&&(I.$feature_flag_id=S.metadata.id),P(S?.original_variant)&&P(S?.original_enabled)||(I.$feature_flag_original_response=P(S.original_variant)?S.original_enabled:S.original_variant),S!=null&&(C=S.metadata)!=null&&C.original_payload&&(I.$feature_flag_original_payload=S==null||(M=S.metadata)==null?void 0:M.original_payload),E.length&&(I.$feature_flag_error=E.join(",")),this._instance.capture("$feature_flag_called",I)}if(i){var V=n;if(!P(n))try{V=JSON.parse(n)}catch{}return{key:s,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:V}}}}else Ne.warn('getFeatureFlagResult for key "'+s+Qo)}getRemoteConfigPayload(s,e){var t=this.Rt.token,i={distinct_id:this._instance.get_distinct_id(),token:t};this.Kn()&&(i.evaluation_contexts=this.Jn()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:i,compression:this.Rt.disable_compression?void 0:ut.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback(r){var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[s]||void 0)}})}isFeatureEnabled(s,e){if(e===void 0&&(e={}),!e.fresh||this.zn){if(this.Zn||this.getFlags()&&this.getFlags().length>0){var t=this.getFeatureFlag(s,e);return P(t)?void 0:!!t}Ne.warn('isFeatureEnabled for key "'+s+Qo)}}addFeatureFlagsHandler(s){this.featureFlagEventHandlers.push(s)}removeFeatureFlagsHandler(s){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==s))}receivedFeatureFlags(s,e){if(this.Kr){this.Zn=!0;var t=this.getFlagVariants(),i=this.getFlagPayloads(),r=this.getFlagsWithDetails();(function(n,o,a,l,u){a===void 0&&(a={}),l===void 0&&(l={}),u===void 0&&(u={});var d=(C=>{var S=C.flags;return S?(C.featureFlags=Object.fromEntries(Object.keys(S).map((E=>{var I;return[E,(I=S[E].variant)!==null&&I!==void 0?I:S[E].enabled]}))),C.featureFlagPayloads=Object.fromEntries(Object.keys(S).filter((E=>S[E].enabled)).filter((E=>{var I;return(I=S[E].metadata)==null?void 0:I.payload})).map((E=>{var I;return[E,(I=S[E].metadata)==null?void 0:I.payload]})))):Ne.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),C})(n),h=d.flags,f=d.featureFlags,g=d.featureFlagPayloads;if(f){var p=n.requestId,v=n.evaluatedAt;if(X(f)){Ne.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(f)for(var b=0;f.length>b;b++)m[f[b]]=!0;o&&o.register({[Zo]:f,[Os]:m})}else{var k=f,D=g,N=h;if(n.errorsWhileComputingFlags)if(h){var O=new Set(Object.keys(h).filter((C=>{var S;return!((S=h[C])!=null&&S.failed)})));k=T({},a,Object.fromEntries(Object.entries(k).filter((C=>{var[S]=C;return O.has(S)})))),D=T({},l,Object.fromEntries(Object.entries(D||{}).filter((C=>{var[S]=C;return O.has(S)})))),N=T({},u,Object.fromEntries(Object.entries(N||{}).filter((C=>{var[S]=C;return O.has(S)}))))}else k=T({},a,k),D=T({},l,D),N=T({},u,N);o&&o.register(T({[Zo]:Object.keys(ah(k)),[Os]:k||{},[rh]:D||{},[ba]:N||{}},p?{[nh]:p}:{},v?{[Hr]:v}:{}))}}})(s,this.Kr,t,i,r),e||(this.Un=!1),this.rs(e)}}override(s,e){e===void 0&&(e=!1),Ne.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:s,suppressWarning:e})}overrideFeatureFlags(s){if(!this._instance.__loaded||!this.Kr)return Ne.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(s===!1)return this.Kr.unregister(Ft),this.Kr.unregister(gi),this.rs(),Zt.info("All overrides cleared");if(X(s)){var e=oh(s);return this.Kr.register({[Ft]:e}),this.rs(),Zt.info("Flag overrides set",{flags:s})}if(s&&typeof s=="object"&&("flags"in s||"payloads"in s)){var t,i=s;if(this.qn=!!((t=i.suppressWarning)!==null&&t!==void 0&&t),"flags"in i){if(i.flags===!1)this.Kr.unregister(Ft),Zt.info("Flag overrides cleared");else if(i.flags){if(X(i.flags)){var r=oh(i.flags);this.Kr.register({[Ft]:r})}else this.Kr.register({[Ft]:i.flags});Zt.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this.Kr.unregister(gi),Zt.info("Payload overrides cleared")):i.payloads&&(this.Kr.register({[gi]:i.payloads}),Zt.info("Payload overrides set",{payloads:i.payloads}))),void this.rs()}if(s&&typeof s=="object")return this.Kr.register({[Ft]:s}),this.rs(),Zt.info("Flag overrides set",{flags:s});Ne.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:s})}onFeatureFlags(s){if(this.addFeatureFlagsHandler(s),this.Zn){var{flags:e,flagVariants:t}=this.ns();s(e,t)}return()=>this.removeFeatureFlagsHandler(s)}updateEarlyAccessFeatureEnrollment(s,e,t){var i,r=(this.Wn(_i)||[]).find((l=>l.flagKey===s)),n={["$feature_enrollment/"+s]:e},o={$feature_flag:s,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),t&&(o.$feature_enrollment_stage=t),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=T({},this.getFlagVariants(),{[s]:e});(i=this.Kr)==null||i.register({[Zo]:Object.keys(ah(a)),[Os]:a}),this.rs()}getEarlyAccessFeatures(s,e,t){e===void 0&&(e=!1);var i=this.Wn(_i),r=t?"&"+t.map((n=>"stage="+n)).join("&"):"";if(i&&!e)return s(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Rt.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this.Kr)==null||o.unregister(_i),(a=this.Kr)==null||a.register({[_i]:l}),s(l)}}})}ns(){var s=this.getFlags(),e=this.getFlagVariants();return{flags:s.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}rs(s){var{flags:e,flagVariants:t}=this.ns();this.featureFlagEventHandlers.forEach((i=>i(e,t,{errorsLoading:s})))}setPersonPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Wn(mi)||{},i=s?.$set||(s!=null&&s.$set_once?{}:s),r=s?.$set_once,n={};if(r)for(var o in r)({}).hasOwnProperty.call(r,o)&&(o in t||(n[o]=r[o]));this._instance.register({[mi]:T({},t,n,i)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(mi)}setGroupPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Wn(ts)||{};Object.keys(t).length!==0&&Object.keys(t).forEach((i=>{t[i]=T({},t[i],s[i]),delete s[i]})),this._instance.register({[ts]:T({},t,s)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(s){if(s){var e=this.Wn(ts)||{};this._instance.register({[ts]:T({},e,{[s]:{}})})}else this._instance.unregister(ts)}reset(){this.Zn=!1,this.$n=!1,this.Hn=!1,this.Vn=!1,this.zn=!1,this.$anon_distinct_id=void 0,this.es(),this.qn=!1}}},mE={sessionRecording:class{get Rt(){return this._instance.config}get Kr(){return this._instance.persistence}get started(){var s;return!((s=this.ss)==null||!s.isStarted)}get status(){var s,e;return this.os===hi||this.os===Lr?this.os:(s=(e=this.ss)==null?void 0:e.status)!==null&&s!==void 0?s:this.os}constructor(s){if(this._forceAllowLocalhostNetworkCapture=!1,this.os=Xd,this.ls=void 0,this._instance=s,!this._instance.sessionManager)throw Lt.error("started without valid sessionManager"),new Error(Qa+" started without valid sessionManager. This is a bug.");if(this.Rt.cookieless_mode===rt)throw new Error(Qa+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get us(){var s,e=!((s=this._instance.get_property(Ir))==null||!s.enabled),t=!this.Rt.disable_session_recording,i=this.Rt.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&t&&!i}startIfEnabledOrStop(s){var e;if(!this.us||(e=this.ss)==null||!e.isStarted){var t=!P(Object.assign)&&!P(Array.from);this.us&&t?(this.hs(s),Lt.info("starting")):(this.os=Xd,this.stopRecording())}}hs(s){var e,t,i;this.us&&(this.os!==hi&&this.os!==Lr&&(this.os=Jd),L!=null&&(e=L.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=L.__PosthogExtensions__)!=null&&t.initSessionRecording?this.cs(s):(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.ds,(r=>{if(r)return Lt.error("could not load recorder",r);this.cs(s)})))}stopRecording(){var s,e;(s=this.ls)==null||s.call(this),this.ls=void 0,(e=this.ss)==null||e.stop()}vs(){var s,e;(s=this.ls)==null||s.call(this),this.ls=void 0,(e=this.ss)==null||e.discard()}fs(){var s;(s=this.Kr)==null||s.unregister($h)}ps(s,e){if(z(s))return null;var t,i=ht(s)?s:parseFloat(s);return typeof(t=i)!="number"||!Number.isFinite(t)||0>t||t>1?(Lt.warn(e+" must be between 0 and 1. Ignoring invalid value:",s),null):i}gs(s){if(this.Kr){var e,t,i=this.Kr,r=()=>{var n,o=s.sessionRecording===!1?void 0:s.sessionRecording,a=this.ps((n=this.Rt.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.ps(o?.sampleRate,"remote config sampleRate"),u=a??l;z(u)&&this.fs();var d=o?.minimumDurationMilliseconds;i.register({[Ir]:T({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:T({capturePerformance:s.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:P(d)?null:d,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers})})};r(),(e=this.ls)==null||e.call(this),this.ls=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(s){return"sessionRecording"in s?s.sessionRecording===!1?(this.gs(s),void this.vs()):(this.gs(s),void this.startIfEnabledOrStop()):(this.os===hi&&(this.os=Lr,Lt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(s,e){var t;e===void 0&&(e="log"),(t=this.ss)!=null&&t.log?this.ss.log(s,e):Lt.warn("log called before recorder was ready")}get ds(){var s,e,t=(s=this._instance)==null||(s=s.persistence)==null?void 0:s.get_property(Ir);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}ys(){var s,e=this._instance.get_property(Ir);if(!e)return!1;var t=(s=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&s!==void 0?s:Date.now();return 36e5>=Date.now()-t}cs(s){var e,t;if((e=L.__PosthogExtensions__)==null||!e.initSessionRecording)return Lt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.ss||(this.ss=(t=L.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.ss._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.ys())return this.os===Lr||this.os===hi?void 0:(this.os=hi,Lt.info("persisted remote config is stale, requesting fresh config before starting"),void new en(this._instance).load());this.os=Jd,this.ss.start(s)}onRRwebEmit(s){var e;(e=this.ss)==null||e.onRRwebEmit==null||e.onRRwebEmit(s)}overrideLinkedFlag(){var s,e;this.ss||(e=this.Kr)==null||e.register({$replay_override_linked_flag:!0}),(s=this.ss)==null||s.overrideLinkedFlag()}overrideSampling(){var s,e;this.ss||(e=this.Kr)==null||e.register({$replay_override_sampling:!0}),(s=this.ss)==null||s.overrideSampling()}overrideTrigger(s){var e,t;this.ss||(t=this.Kr)==null||t.register({[s==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.ss)==null||e.overrideTrigger(s)}get sdkDebugProperties(){var s;return((s=this.ss)==null?void 0:s.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(s,e){var t;return!((t=this.ss)==null||!t.tryAddCustomEvent(s,e))}}},yE={autocapture:class{constructor(s){this.bs=!1,this.ws=null,this._s=!1,this.instance=s,this.rageclicks=new un(s.config.rageclick),this.Is=null}initialize(){this.startIfEnabled()}get Rt(){var s,e,t=be(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(s=t.url_allowlist)==null?void 0:s.map((i=>new RegExp(i))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((i=>new RegExp(i))),t}Cs(){if(this.isBrowserSupported()){if(_&&R){var s=t=>{t=t||_?.event;try{this.Ss(t)}catch(i){qd.error("Failed to capture event",i)}};if(me(R,"submit",s,{capture:!0}),me(R,"change",s,{capture:!0}),me(R,"click",s,{capture:!0}),this.Rt.capture_copied_text){var e=t=>{this.Ss(t=t||_?.event,Wo)};me(R,"copy",e,{capture:!0}),me(R,"cut",e,{capture:!0})}}}else qd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.bs&&(this.Cs(),this.bs=!0)}onRemoteConfig(s){s.elementsChainAsString&&(this._s=s.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[_d]:!!s.autocapture_opt_out}),this.ws=!!s.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(s){this.Is=s}getElementSelectors(s){var e,t=[];return(e=this.Is)==null||e.forEach((i=>{var r=R?.querySelectorAll(i);r?.forEach((n=>{s===n&&t.push(i)}))})),t}get isEnabled(){var s,e,t=(s=this.instance.persistence)==null?void 0:s.props[_d];if(Bt(this.ws)&&!Tt(t)&&!this.instance.Tr())return!1;var i=(e=this.ws)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!i}Ss(s,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,i=Vd(s);ng(i)&&(i=i.parentNode||null),e==="$autocapture"&&s.type==="click"&&s instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,s.timeStamp||new Date().getTime())&&(function(h,f){if(!_||Xa(h))return!1;var g,p,v;if(Tt(f)?(g=!!f&&Hd,p=void 0):(g=(v=f?.css_selector_ignorelist)!==null&&v!==void 0?v:Hd,p=f?.content_ignorelist),g===!1)return!1;var{targetElementList:m}=jd(h,!1);return!(function(b,k){if(b===!1||P(b))return!1;var D;if(b===!0)D=nE;else{if(!X(b))return!1;if(b.length>10)return A.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;D=b.map((N=>N.toLowerCase()))}return k.some((N=>{var{safeText:O,ariaLabel:C}=N;return D.some((S=>O.includes(S)||C.includes(S)))}))})(p,m.map((b=>{var k;return{safeText:Ci(b).toLowerCase(),ariaLabel:((k=b.getAttribute("aria-label"))==null?void 0:k.toLowerCase().trim())||""}})))&&!Gd(m,g)})(i,this.instance.config.rageclick)&&this.Ss(s,"$rageclick");var r=e===Wo;if(i&&(function(h,f,g,p,v){var m,b,k,D;if(g===void 0&&(g=void 0),!_||Xa(h)||(m=g)!=null&&m.url_allowlist&&!Bd(g.url_allowlist)||(b=g)!=null&&b.url_ignorelist&&Bd(g.url_ignorelist))return!1;if((k=g)!=null&&k.dom_event_allowlist){var N=g.dom_event_allowlist;if(N&&!N.some((I=>f.type===I)))return!1}var{parentIsUsefulElement:O,targetElementList:C}=jd(h,p);if(!(function(I,M){var G=M?.element_allowlist;if(P(G))return!0;var V,q=function(ve){if(G.some((Se=>ve.tagName.toLowerCase()===Se)))return{v:!0}};for(var W of I)if(V=q(W))return V.v;return!1})(C,g)||!Gd(C,(D=g)==null?void 0:D.css_selector_allowlist))return!1;var S=_.getComputedStyle(h);if(S&&S.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0;var E=h.tagName.toLowerCase();switch(E){case"html":return!1;case"form":return(v||["submit"]).indexOf(f.type)>=0;case"input":case"select":case"textarea":return(v||["change","click"]).indexOf(f.type)>=0;default:return O?(v||["click"]).indexOf(f.type)>=0:(v||["click"]).indexOf(f.type)>=0&&(gl.indexOf(E)>-1||h.getAttribute("contenteditable")==="true")}})(i,s,this.Rt,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=hE(i,{e:s,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Rt.element_attribute_ignorelist,elementsChainAsString:this._s});if(o)return!1;var a=this.getElementSelectors(i);if(a&&a.length>0&&(n.$element_selectors=a),e===Wo){var l,u=ag(_==null||(l=_.getSelection())==null?void 0:l.toString()),d=s.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=d}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return wt(R?.querySelectorAll)}},historyAutocapture:class{constructor(s){var e;this._instance=s,this.ks=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(A.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.xs&&this.xs(),this.xs=void 0,A.info("History API monitoring stopped")}monitorHistoryChanges(){var s,e;if(_&&_.history){var t=this;(s=_.history.pushState)!=null&&s.__posthog_wrapped__||Wd(_.history,"pushState",(i=>function(r,n,o){i.call(this,r,n,o),t.Ts("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||Wd(_.history,"replaceState",(i=>function(r,n,o){i.call(this,r,n,o),t.Ts("replaceState")})),this.As()}}Ts(s){try{var e,t=_==null||(e=_.location)==null?void 0:e.pathname;if(!t)return;t!==this.ks&&this.isEnabled&&this._instance.capture(Rs,{navigation_type:s}),this.ks=t}catch(i){A.error("Error capturing "+s+" pageview",i)}}As(){if(!this.xs){var s=()=>{this.Ts("popstate")};me(_,"popstate",s),this.xs=()=>{_&&_.removeEventListener("popstate",s)}}}},heatmaps:class{get Rt(){return this.instance.config}constructor(s){var e;this.Es=!1,this.bs=!1,this.Rs=null,this.instance=s,this.Es=!((e=this.instance.persistence)==null||!e.props[ma]),this.rageclicks=new un(s.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var s=5e3;return be(this.Rt.capture_heatmaps)&&this.Rt.capture_heatmaps.flush_interval_milliseconds&&(s=this.Rt.capture_heatmaps.flush_interval_milliseconds),s}get isEnabled(){return z(this.Rt.capture_heatmaps)?z(this.Rt.enable_heatmaps)?this.Es:this.Rt.enable_heatmaps:this.Rt.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.bs)return;fE.info("starting..."),this.Ns(),this.Tt()}else{var s;clearInterval((s=this.Rs)!==null&&s!==void 0?s:void 0),this.Ms(),this.getAndClearBuffer()}}onRemoteConfig(s){if("heatmaps"in s){var e=!!s.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ma]:e}),this.Es=e,this.startIfEnabled()}}getAndClearBuffer(){var s=this.T;return this.T=void 0,s}Fs(s){this.wt(s.originalEvent,"deadclick")}Tt(){this.Rs&&clearInterval(this.Rs),this.Rs=R?.visibilityState==="visible"?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Ns(){_&&R&&(this.Os=this.Zr.bind(this),me(_,qr,this.Os),this.Ps=s=>this.wt(s||_?.event),me(R,"click",this.Ps,{capture:!0}),this.Ls=s=>this.Ds(s||_?.event),me(R,"mousemove",this.Ls,{capture:!0}),this.Bs=new Wr(this.instance,$b,this.Fs.bind(this)),this.Bs.startIfEnabledOrStop(),this.js=this.Tt.bind(this),me(R,Kr,this.js),this.bs=!0)}Ms(){var s;_&&R&&(this.Os&&_.removeEventListener(qr,this.Os),this.Ps&&R.removeEventListener("click",this.Ps,{capture:!0}),this.Ls&&R.removeEventListener("mousemove",this.Ls,{capture:!0}),this.js&&R.removeEventListener(Kr,this.js),clearTimeout(this.qs),(s=this.Bs)==null||s.stop(),this.bs=!1)}Zs(s,e){var t=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&hn(u)&&!Ut(u,"body");){if(u===l)return!1;if(j(a,_?.getComputedStyle(u).position))return!0;u=lg(u)}return!1})(Vd(s),["fixed","sticky"],r);return{x:s.clientX+(n?0:i),y:s.clientY+(n?0:t),target_fixed:n,type:e}}wt(s,e){var t;if(e===void 0&&(e="click"),!Ud(s.target)&&Qd(s)){var i=this.Zs(s,e);(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,new Date().getTime())&&this.$s(T({},i,{type:"rageclick"})),this.$s(i)}}Ds(s){!Ud(s.target)&&Qd(s)&&(clearTimeout(this.qs),this.qs=setTimeout((()=>{this.$s(this.Zs(s,"mousemove"))}),500))}$s(s){if(_){var e=_.location.href,t=this.Rt.custom_personal_data_properties,i=this.Rt.mask_personal_data_properties?[...$s,...t||[]]:[],r=Ii(e,i,Oi);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(s)}}Zr(){this.T&&!Is(this.T)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Wr,webVitalsAutocapture:class{constructor(s){var e;this.Es=!1,this.bs=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Hs=()=>{clearTimeout(this.Vs),this.T.metrics.length!==0&&(this._instance.capture("$web_vitals",this.T.metrics.reduce(((t,i)=>T({},t,{["$web_vitals_"+i.name+"_event"]:T({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.nt=t=>{var i,r=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(P(r))xt.error("Could not read session ID. Dropping metrics!");else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.zs();P(n)||(z(t?.name)||z(t?.value)?xt.error("Invalid metric received",t):!this.Ys||this.Ys>t.value?(this.T.url!==n&&(this.Hs(),this.Vs=setTimeout(this.Hs,this.flushToCaptureTimeoutMs)),P(this.T.url)&&(this.T.url=n),this.T.firstMetricTimestamp=P(this.T.firstMetricTimestamp)?Date.now():this.T.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.T.metrics.push(T({},t,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.T.metrics.length===this.allowedMetrics.length&&this.Hs()):xt.error("Ignoring metric with value >= "+this.Ys,t))}},this.Us=()=>{if(!this.bs){var t,i,r,n,o=L.__PosthogExtensions__;P(o)||P(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:i,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),t&&i&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.nt.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.nt.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.nt.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.nt.bind(this)),this.bs=!0):xt.error("web vitals callbacks not loaded - not starting")}},this._instance=s,this.Es=!((e=this._instance.persistence)==null||!e.props[bd]),this.startIfEnabled()}get Ws(){return this._instance.config.capture_performance}get allowedMetrics(){var s,e,t=be(this.Ws)?(s=this.Ws)==null?void 0:s.web_vitals_allowed_metrics:void 0;return z(t)?((e=this._instance.persistence)==null?void 0:e.props[Sd])||["CLS","FCP","INP","LCP"]:t}get flushToCaptureTimeoutMs(){return(be(this.Ws)?this.Ws.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var s=be(this.Ws)?this.Ws.web_vitals_attribution:void 0;return s!=null&&s}get Ys(){var s=be(this.Ws)&&ht(this.Ws.__web_vitals_max_value)?this.Ws.__web_vitals_max_value:Yd;return s>0&&6e4>=s?Yd:s}get isEnabled(){var s=Ae?.protocol;if(s!=="http:"&&s!=="https:")return xt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=be(this.Ws)?this.Ws.web_vitals:Tt(this.Ws)?this.Ws:void 0;return Tt(e)?e:this.Es}startIfEnabled(){this.isEnabled&&!this.bs&&(xt.info("enabled, starting..."),this.nr(this.Us))}onRemoteConfig(s){if("capturePerformance"in s){var e=be(s.capturePerformance)&&!!s.capturePerformance.web_vitals,t=be(s.capturePerformance)?s.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[bd]:e}),this._instance.persistence.register({[Sd]:t})),this.Es=e,this.startIfEnabled()}}nr(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?s():(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(i=>{i?xt.error("failed to load script",i):s()}))}zs(){var s=_?_.location.href:void 0;if(s){var e=this._instance.config.custom_personal_data_properties,t=this._instance.config.mask_personal_data_properties?[...$s,...e||[]]:[];return Ii(s,t,Oi)}xt.error("Could not determine current URL")}}},bE={exceptionObserver:class{constructor(s){var e,t,i;this.Us=()=>{var r;if(_&&this.isEnabled&&(r=L.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var n=L.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=L.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=L.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Gs&&this.Rt.capture_unhandled_errors&&(this.Gs=n(this.captureException.bind(this))),!this.Xs&&this.Rt.capture_unhandled_rejections&&(this.Xs=o(this.captureException.bind(this))),!this.Js&&this.Rt.capture_console_errors&&(this.Js=a(this.captureException.bind(this)))}catch(l){di.error("failed to start",l),this.Ks()}}},this._instance=s,this.Qs=!((e=this._instance.persistence)==null||!e.props[md]),this.eo=new ra({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,qt:di}),this.Rt=this.ro(),this.startIfEnabledOrStop()}ro(){var s=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return be(s)?e=T({},e,s):(P(s)?this.Qs:s)&&(e=T({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Rt.capture_console_errors||this.Rt.capture_unhandled_errors||this.Rt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(di.info("enabled"),this.Ks(),this.nr(this.Us)):this.Ks()}nr(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&s(),(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return di.error("failed to load script",i);s()}))}Ks(){var s,e,t;(s=this.Gs)==null||s.call(this),this.Gs=void 0,(e=this.Xs)==null||e.call(this),this.Xs=void 0,(t=this.Js)==null||t.call(this),this.Js=void 0}onRemoteConfig(s){"autocaptureExceptions"in s&&(this.Qs=!!s.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[md]:this.Qs}),this.Rt=this.ro(),this.startIfEnabledOrStop())}onConfigChange(){this.Rt=this.ro()}captureException(s){var e,t,i,r=(e=s==null||(t=s.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.eo.consumeRateLimit(r)?di.info("Skipping exception capture because of client rate limiting.",{exception:r}):(i=this._instance.exceptions)==null||i.sendExceptionEvent(s)}},exceptions:class{constructor(s){var e,t;this.io=[],this.no=new la([new ca,new _a,new ha,new da,new pa,new fa,new ga,new va],(function(i){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;r>o;o++)n[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var u=[],d=a.split(`
|
|
6
|
-
`),h=l;d.length>h;h++){var f=d[h];if(1024>=f.length){var g=vd.test(f)?f.replace(vd,"$1"):f;if(!g.match(/\S*Error: /)){for(var p of n){var v=p(g,i);if(v){u.push(v);break}}if(u.length>=50)break}}}return(function(m){if(!m.length)return[];var b=Array.from(m);return b.reverse(),b.slice(0,50).map((k=>{return T({},k,{filename:k.filename||(D=b,D[D.length-1]||{}).filename,function:k.function||Ls});var D}))})(u)}})("web:javascript",Eb,wb)),this._instance=s,this.io=(e=(t=this._instance.persistence)==null?void 0:t.get_property(ya))!==null&&e!==void 0?e:[]}onRemoteConfig(s){var e,t,i;if("errorTracking"in s){var r=(e=(t=s.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],n=(i=s.errorTracking)==null?void 0:i.captureExtensionExceptions;this.io=r,this._instance.persistence&&this._instance.persistence.register({[ya]:this.io,[yd]:n})}}get so(){var s,e=!!this._instance.get_property(yd),t=this._instance.config.error_tracking.captureExtensionExceptions;return(s=t??e)!==null&&s!==void 0&&s}buildProperties(s,e){return this.no.buildFromUnknown(s,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}sendExceptionEvent(s){var e=s.$exception_list;if(this.oo(e)){if(this.ao(e))return void ea.info("Skipping exception capture because a suppression rule matched");if(!this.so&&this.lo(e))return void ea.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.uo(e))return void ea.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",zi:!0})}ao(s){if(s.length===0)return!1;var e=s.reduce(((t,i)=>{var{type:r,value:n}=i;return ye(r)&&r.length>0&&t.$exception_types.push(r),ye(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.io.some((t=>{var i=t.values.map((r=>{var n,o=tg[r.operator],a=X(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return t.type==="OR"?i.some(Boolean):i.every(Boolean)}))}lo(s){return s.flatMap((e=>{var t,i;return(t=(i=e.stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}uo(s){if(s.length>0){var e,t,i,r,n=(e=(t=s[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(i=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}oo(s){return!z(s)&&X(s)}}},EE=T({productTours:class{get Kr(){return this._instance.persistence}constructor(s){this.ho=null,this.co=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){"productTours"in s&&(this.Kr&&this.Kr.register({[Ed]:!!s.productTours}),this.loadIfEnabled())}loadIfEnabled(){var s,e;this.ho||(s=this._instance).config.disable_product_tours||(e=s.persistence)==null||!e.get_property(Ed)||this.nr((()=>this.do()))}nr(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.generateProductTours?s():(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(i=>{i?Zd.error("Could not load product tours script",i):s()}))}do(){var s;!this.ho&&(s=L.__PosthogExtensions__)!=null&&s.generateProductTours&&(this.ho=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(s,e){if(e===void 0&&(e=!1),!X(this.co)||e){var t=this.Kr;if(t){var i=t.props[Xo];if(X(i)&&!e)return this.co=i,void s(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return Zd.error(o),void s([],{isLoaded:!1,error:o})}var a=X(r.json.product_tours)?r.json.product_tours:[];this.co=a,t&&t.register({[Xo]:a}),s(a,{isLoaded:!0})}})}else s(this.co,{isLoaded:!0})}getActiveProductTours(s){z(this.ho)?s([],{isLoaded:!1,error:"Product tours not loaded"}):this.ho.getActiveProductTours(s)}showProductTour(s){var e;(e=this.ho)==null||e.showTourById(s)}previewTour(s){this.ho?this.ho.previewTour(s):this.nr((()=>{var e;this.do(),(e=this.ho)==null||e.previewTour(s)}))}dismissProductTour(){var s;(s=this.ho)==null||s.dismissTour("user_clicked_skip")}nextStep(){var s;(s=this.ho)==null||s.nextStep()}previousStep(){var s;(s=this.ho)==null||s.previousStep()}clearCache(){var s;this.co=null,(s=this.Kr)==null||s.unregister(Xo)}resetTour(s){var e;(e=this.ho)==null||e.resetTour(s)}resetAllTours(){var s;(s=this.ho)==null||s.resetAllTours()}cancelPendingTour(s){var e;(e=this.ho)==null||e.cancelPendingTour(s)}}},gn),SE={siteApps:class{constructor(s){this._instance=s,this.vo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}fo(s,e){if(e){var t=this.globalsForEvent(e);this.vo.push(t),this.vo.length>1e3&&(this.vo=this.vo.slice(10))}}get siteAppLoaders(){var s;return(s=L._POSTHOG_REMOTE_CONFIG)==null||(s=s[this._instance.config.token])==null?void 0:s.siteApps}initialize(){if(this.isEnabled){var s=this._instance._addCaptureHook(this.fo.bind(this));this.po=()=>{s(),this.vo=[],this.po=void 0}}}globalsForEvent(s){var e,t,i,r,n,o,a;if(!s)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[h,f]of Object.entries(d))l[h]={id:u[h],type:h,properties:f};var{$set_once:g,$set:p}=s;return{event:T({},ch(s,pE),{properties:T({},s.properties,p?{$set:T({},(e=(t=s.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},p)}:{},g?{$set_once:T({},(i=(r=s.properties)==null?void 0:r.$set_once)!==null&&i!==void 0?i:{},g)}:{}),elements_chain:(n=(o=s.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=s.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(s){var e=this.apps[s.id],t=()=>{var o;!e.errored&&this.vo.length&&($t.info("Processing "+this.vo.length+" events for site app with id "+s.id),this.vo.forEach((a=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every((a=>a.processedBuffer||a.errored))&&((o=this.po)==null||o.call(this))},i=!1,r=o=>{e.errored=!o,e.loaded=!0,$t.info("Site app with id "+s.id+" "+(o?"loaded":"errored")),i&&t()};try{var{processEvent:n}=s.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),i=!0}catch(o){$t.error(eh+s.id,o),r(!1)}if(i&&e.loaded)try{t()}catch(o){$t.error("Error while processing buffered events PostHog app with config id "+s.id,o),e.errored=!0}}mo(){var s=this.siteAppLoaders||[];for(var e of s)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of s)this.setupSiteApp(t)}yo(s){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(s);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(i){$t.error("Error while processing event "+s.event+" for site app "+t.id,i)}}}onRemoteConfig(s){var e,t,i,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.mo(),void this._instance.on("eventCaptured",(l=>this.yo(l)))):void $t.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.po)==null||t.call(this),(i=s.siteApps)!=null&&i.length)if(this.isEnabled){var n=function(l){var u;L["__$$ph_site_app_"+l]=r._instance,(u=L.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(r._instance,a,(d=>{if(d)return $t.error(eh+l,d)}))};for(var{id:o,url:a}of s.siteApps)n(o)}else $t.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},kE={tracingHeaders:class{constructor(s){this.bo=void 0,this.wo=void 0,this.Us=()=>{var e,t;P(this.bo)&&((e=L.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),P(this.wo)&&((t=L.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=s}initialize(){this.startIfEnabledOrStop()}nr(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&s(),(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return gE.error("failed to load script",i);s()}))}startIfEnabledOrStop(){var s,e;this._instance.config.__add_tracing_headers?this.nr(this.Us):((s=this.bo)==null||s.call(this),(e=this.wo)==null||e.call(this),this.bo=void 0,this.wo=void 0)}}},wE=T({surveys:class{get Rt(){return this._instance.config}constructor(s){this._o=void 0,this._surveyManager=null,this.Io=!1,this.Co=[],this.So=null,this._instance=s,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this.Rt.disable_surveys){var e=s.surveys;if(z(e))return te.warn("Flags not loaded yet. Not loading surveys.");var t=X(e);this._o=t?e.length>0:e,te.info("flags response received, isSurveysEnabled: "+this._o),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var s=[],e=0;e<localStorage.length;e++){var t=localStorage.key(e);(t!=null&&t.startsWith(Ka)||t!=null&&t.startsWith("inProgressSurvey_"))&&s.push(t)}s.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.Io)te.info("Already initializing surveys, skipping...");else if(this.Rt.disable_surveys)te.info(th);else if(this.Rt.cookieless_mode&&this._instance.consent.isOptedOut())te.info("Not loading surveys in cookieless mode without consent.");else{var s=L?.__PosthogExtensions__;if(s){if(!P(this._o)||this.Rt.advanced_enable_surveys){var e=this._o||this.Rt.advanced_enable_surveys;this.Io=!0;try{var t=s.generateSurveys;if(t)return void this.ko(t,e);var i=s.loadExternalDependency;if(!i)return void this.xo(ll);i(this._instance,"surveys",(r=>{r||!s.generateSurveys?this.xo("Could not load surveys script",r):this.ko(s.generateSurveys,e)}))}catch(r){throw this.xo("Error initializing surveys",r),r}finally{this.Io=!1}}}else te.error("PostHog Extensions not found.")}}ko(s,e){this._surveyManager=s(this._instance,e),this._surveyEventReceiver=new tl(this._instance),te.info("Surveys loaded successfully"),this.To({isLoaded:!0})}xo(s,e){te.error(s,e),this.To({isLoaded:!1,error:s})}onSurveysLoaded(s){return this.Co.push(s),this._surveyManager&&this.To({isLoaded:!0}),()=>{this.Co=this.Co.filter((e=>e!==s))}}getSurveys(s,e){if(e===void 0&&(e=!1),this.Rt.disable_surveys)return te.info(th),s([]);var t,i=this._instance.get_property(Ea);if(i&&!e)return s(i,{isLoaded:!0});typeof Promise<"u"&&this.So?this.So.then((r=>{var{surveys:n,context:o}=r;return s(n,o)})):(typeof Promise<"u"&&(this.So=new Promise((r=>{t=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Rt.token),method:"GET",timeout:this.Rt.surveys_request_timeout_ms,callback:r=>{var n;this.So=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;te.error(a);var l={isLoaded:!1,error:a};return s([],l),void(t==null||t({surveys:[],context:l}))}var u,d=r.json.surveys||[],h=d.filter((g=>(function(p){return!(!p.start_date||p.end_date)})(g)&&((function(p){var v;return!((v=p.conditions)==null||(v=v.events)==null||(v=v.values)==null||!v.length)})(g)||(function(p){var v;return!((v=p.conditions)==null||(v=v.actions)==null||(v=v.values)==null||!v.length)})(g))));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(n=this._instance.persistence)==null||n.register({[Ea]:d});var f={isLoaded:!0};s(d,f),t?.({surveys:d,context:f})}}))}To(s){for(var e of this.Co)try{if(!s.isLoaded)return e([],s);this.getSurveys(e)}catch(t){te.error("Error in survey callback",t)}}getActiveMatchingSurveys(s,e){if(e===void 0&&(e=!1),!z(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(s,e);te.warn("init was not called")}Ao(s){var e=null;return this.getSurveys((t=>{var i;e=(i=t.find((r=>r.id===s)))!==null&&i!==void 0?i:null})),e}Eo(s){if(z(this._surveyManager))return{eligible:!1,reason:Jo};var e=typeof s=="string"?this.Ao(s):s;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(s){if(z(this._surveyManager))return te.warn("init was not called"),{visible:!1,disabledReason:Jo};var e=this.Eo(s);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(s,e){return z(this._surveyManager)?(te.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Jo})):new Promise((t=>{this.getSurveys((i=>{var r,n=(r=i.find((a=>a.id===s)))!==null&&r!==void 0?r:null;if(n){var o=this.Eo(n);t({visible:o.eligible,disabledReason:o.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(s,e,t){var i;if(z(this._surveyManager))te.warn("init was not called");else{var r=typeof s=="string"?this.Ao(s):s;if(r!=null&&r.id)if(Zb.includes(r.type)){var n=R?.querySelector(e);if(n)return(i=r.appearance)!=null&&i.surveyPopupDelaySeconds?(te.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;te.info("Rendering survey "+r.id+" with delay of "+((o=r.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(r,n,t),te.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);te.warn("Survey element not found")}else te.warn("Surveys of type "+r.type+" cannot be rendered in the app");else te.warn("Survey not found")}}displaySurvey(s,e){var t;if(z(this._surveyManager))te.warn("init was not called");else{var i=this.Ao(s);if(i){var r=i;if((t=i.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=T({},i,{appearance:T({},i.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==xa.Popover&&e.initialResponses&&te.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(i);if(!n.visible)return void te.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==xa.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else te.warn("Survey not found")}}cancelPendingSurvey(s){z(this._surveyManager)?te.warn("init was not called"):this._surveyManager.cancelSurvey(s)}handlePageUnload(){var s;(s=this._surveyManager)==null||s.handlePageUnload()}}},gn),TE={toolbar:class{constructor(s){this.instance=s}Ro(s){L.ph_toolbar_state=s}No(){var s;return(s=L.ph_toolbar_state)!==null&&s!==void 0?s:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(s,e,t){if(s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),Mh(this.instance.config)||!_||!R)return!1;s=s??_.location,t=t??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var i,r=vE||Qr(s.hash,"__posthog")||Qr(s.hash,"state"),n=r?wd((()=>JSON.parse(atob(decodeURIComponent(r)))))||wd((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((i=n).source="url",i&&Object.keys(i).length>0&&(n.desiredHash?s.hash=n.desiredHash:t?t.replaceState(t.state,"",s.pathname+s.search):s.hash="")):((i=JSON.parse(e.getItem(sh)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}Mo(s){var e=L.ph_load_toolbar||L.ph_load_editor;!z(e)&&wt(e)?e(s,this.instance):ih.warn("No toolbar load function found")}loadToolbar(s){var e=!(R==null||!R.getElementById(Fh));if(!_||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=T({token:this.instance.config.token},s,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(_.localStorage.setItem(sh,JSON.stringify(T({},i,{source:void 0}))),this.No()===2)this.Mo(i);else if(this.No()===0){var r;this.Ro(1),(r=L.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return ih.error("[Toolbar] Failed to load",n),void this.Ro(0);this.Ro(2),this.Mo(i)})),me(_,"turbolinks:load",(()=>{this.Ro(0),this.loadToolbar(i)}))}return!0}Fo(s){return this.loadToolbar(s)}maybeLoadEditor(s,e,t){return s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(s,e,t)}}},RE=T({experiments:sl},gn),AE={conversations:class{constructor(s){this.Oo=void 0,this._conversationsManager=null,this.Po=!1,this.Lo=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this._instance.config.disable_conversations){var e=s.conversations;z(e)||(Tt(e)?this.Oo=e:(this.Oo=e.enabled,this.Lo=e),this.loadIfEnabled())}}reset(){var s;(s=this._conversationsManager)==null||s.reset(),this._conversationsManager=null,this.Oo=void 0,this.Lo=null}loadIfEnabled(){if(!(this._conversationsManager||this.Po||this._instance.config.disable_conversations||Mh(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var s=L?.__PosthogExtensions__;if(s&&!P(this.Oo)&&this.Oo)if(this.Lo&&this.Lo.token){this.Po=!0;try{var e=s.initConversations;if(e)return this.Do(e),void(this.Po=!1);var t=s.loadExternalDependency;if(!t)return void this.Bo(ll);t(this._instance,"conversations",(i=>{i||!s.initConversations?this.Bo("Could not load conversations script",i):this.Do(s.initConversations),this.Po=!1}))}catch(i){this.Bo("Error initializing conversations",i),this.Po=!1}}else Je.error("Conversations enabled but missing token in remote config.")}}Do(s){if(this.Lo)try{this._conversationsManager=s(this.Lo,this._instance),Je.info("Conversations loaded successfully")}catch(e){this.Bo("Error completing conversations initialization",e)}else Je.error("Cannot complete initialization: remote config is null")}Bo(s,e){Je.error(s,e),this._conversationsManager=null,this.Po=!1}show(){this._conversationsManager?this._conversationsManager.show():Je.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Oo===!0&&!Bt(this._conversationsManager)}isVisible(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&s!==void 0&&s}sendMessage(s,e,t){var i=this;return it((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(s,e,t):(Je.warn(es),null)}))()}getMessages(s,e){var t=this;return it((function*(){return t._conversationsManager?t._conversationsManager.getMessages(s,e):(Je.warn(es),null)}))()}markAsRead(s){var e=this;return it((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(s):(Je.warn(es),null)}))()}getTickets(s){var e=this;return it((function*(){return e._conversationsManager?e._conversationsManager.getTickets(s):(Je.warn(es),null)}))()}requestRestoreLink(s){var e=this;return it((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(s):(Je.warn(es),null)}))()}restoreFromToken(s){var e=this;return it((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(s):(Je.warn(es),null)}))()}restoreFromUrlToken(){var s=this;return it((function*(){return s._conversationsManager?s._conversationsManager.restoreFromUrlToken():(Je.warn(es),null)}))()}getCurrentTicketId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&s!==void 0?s:null}getWidgetSessionId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&s!==void 0?s:null}Ki(){var s;(s=this._conversationsManager)==null||s.setIdentity()}Qi(){var s;(s=this._conversationsManager)==null||s.clearIdentity()}}},IE={logs:class{constructor(s){var e;this.jo=!1,this.qo=!1,this._instance=s,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.jo=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(s){var e,t=(e=s.logs)==null?void 0:e.captureConsoleLogs;!z(t)&&t&&(this.jo=!0,this.loadIfEnabled())}reset(){}loadIfEnabled(){if(this.jo&&!this.qo){var s=ge("[logs]"),e=L?.__PosthogExtensions__;if(e){var t=e.loadExternalDependency;t?t(this._instance,"logs",(i=>{var r;i||(r=e.logs)==null||!r.initializeLogs?s.error("Could not load logs script",i):(e.logs.initializeLogs(this._instance),this.qo=!0)})):s.error(ll)}else s.error("PostHog Extensions not found.")}}}},OE=T({},gn,mE,yE,bE,EE,SE,wE,kE,TE,RE,AE,IE);Ms.__defaultExtensionClasses=T({},OE);$e=(uh=wi[As]=new Ms,(function(){function s(){s.done||(s.done=!0,rg=!1,oe(wi,(function(e){e._dom_loaded()})))}R!=null&&R.addEventListener?R.readyState==="complete"?s():me(R,"DOMContentLoaded",s,{capture:!1}):_&&A.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),uh)});var fg={};vn(fg,{Posthog:()=>fl});var rs,fl,pg=Fe(()=>{"use strict";gg();Ys();Js();rs=class rs{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Ct("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let t=`ph_${e}_posthog`,i=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==t);if(i.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;i.forEach(a=>{[o,r,""].forEach(u=>{let d=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${d}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(u=>u.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:t,config:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=t||sc();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:tc,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=ic.some(u=>a.endsWith(`.${u}`)||a===u);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...i};$e.init(e,n),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=typeof $e._isIdentified=="function"?$e._isIdentified():this.has_identified;e&&!i?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),$e.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),$e.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,language:i,country_of_residence:r})=>{if(!(!this.has_initialized||!e))try{let n=$e.get_property("$stored_person_properties")??{},o={};n.client_id||(o.client_id=e),t&&n.is_internal===void 0&&(o.is_internal=nr(t)),i&&!n.language&&(o.language=i),r&&!n.country_of_residence&&(o.country_of_residence=r),Object.keys(o).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:o}),$e.setPersonProperties(o)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:r})}catch(n){console.error("Posthog: Failed to backfill person properties",n)}};this.capture=(e,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),$e.capture(e,t)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let t=$e.isFeatureEnabled(e);return this.log("isFeatureEnabled",{key:e,result:t}),t}catch(t){console.error("Posthog: Failed to check feature flag",t);return}};this.getFeatureFlag=e=>{if(this.has_initialized)try{let t=$e.getFeatureFlag(e);return this.log("getFeatureFlag",{key:e,result:t}),t}catch(t){console.error("Posthog: Failed to get feature flag",t);return}};this.getFeatureFlagPayload=e=>{if(this.has_initialized)try{let t=$e.featureFlags?.getFeatureFlagResult(e)?.payload;return this.log("getFeatureFlagPayload",{key:e,result:t}),t}catch(t){console.error("Posthog: Failed to get feature flag payload",t);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let e=$e.featureFlags?.getFlagVariants()??{};return this.log("getAllFlags",{result:e}),e}catch(e){return console.error("Posthog: Failed to get all feature flags",e),{}}};this.onFeatureFlags=e=>{if(!this.has_initialized)return()=>{};try{this.log("onFeatureFlags | subscribing to feature flag changes");let t=$e.onFeatureFlags(e);return typeof t=="function"?t:()=>{}}catch(t){return console.error("Posthog: Failed to subscribe to feature flags",t),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),$e.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=t,this.init()}};rs.getPosthogInstance=(e,t=!1)=>(rs._instance||(rs._instance=new rs(e,t)),rs._instance);fl=rs});var CE={};vn(CE,{Analytics:()=>vg});go();Ys();Js();var Zm=4320*60*60,Wt=class Wt{constructor(e,t,i=!1){this.analytics=new hs;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=Ct("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let t=window.location.hostname,n=["webflow.io"].some(u=>t.endsWith(u))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let u=new Uint8Array(16);crypto.getRandomValues(u),u[6]=u[6]&15|64,u[8]=u[8]&63|128;let d=Array.from(u,h=>h.toString(16).padStart(2,"0")).join("");o=`${d.slice(0,8)}-${d.slice(8,12)}-${d.slice(12,16)}-${d.slice(16,20)}-${d.slice(20)}`}else throw new Error("Crypto API not available for secure random UUID generation");let l=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${this.rudderstack_anonymous_cookie_key}=${o}; path=/; Domain=${n}; max-age=${Zm}; SameSite=Lax${l}`}catch(t){console.warn("RudderStack: Failed to set anonymous ID cookie",t)}};this.getUserId=()=>this.analytics.getUserId();this.init=e=>{if(!e){console.warn("RudderStack: Initialization skipped - no key provided");return}this.log("init | loading SDK",{dataplane:fo});try{this.setCookieIfNotExists(),this.analytics.load(e,fo,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,storage:{type:"localStorage"},lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let i=this.getUserId();if(!i||i!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),this.has_identified=!0}catch(r){console.error("RudderStack: Failed to identify user",r)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,t="Deriv App",i,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...i&&{user_id:i},...r};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:n}),this.analytics.page(t,e,n),this.current_page=e}catch(n){console.error("RudderStack: Failed to track page view",n)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=t,this.debug=i,this.init(e)}};Wt.getRudderStackInstance=(e,t,i=!1)=>(Wt._instance||(Wt._instance=new Wt(e,t,i)),Wt._instance);var or=Wt;var ar="cached_analytics_events",lr="cached_analytics_page_views",cc=(s,e)=>{try{let t=localStorage.getItem(ar),i=t?JSON.parse(t):[];i.push({name:s,properties:e,timestamp:Date.now()}),localStorage.setItem(ar,JSON.stringify(i))}catch(t){console.warn("Analytics: Failed to cache event",t)}},dc=(s,e)=>{try{let t=localStorage.getItem(lr),i=t?JSON.parse(t):[];i.push({name:s,properties:e,timestamp:Date.now()}),localStorage.setItem(lr,JSON.stringify(i))}catch(t){console.warn("Analytics: Failed to cache page view",t)}},hc=()=>{try{let s=localStorage.getItem(ar);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached events",s)}return[]},gc=()=>{try{let s=localStorage.getItem(lr);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached pages",s)}return[]},fc=()=>{try{localStorage.removeItem(ar)}catch(s){console.warn("Analytics: Failed to clear cached events",s)}},pc=()=>{try{localStorage.removeItem(lr)}catch(s){console.warn("Analytics: Failed to clear cached page views",s)}};Js();function PE(s){let e=s?.debug??!1,t=Ct("",()=>e),i,r,n,o={},a={},l=[],u=[],d=!1,h=()=>{if(!d&&r?.has_initialized){d=!0;try{let w=hc();w.length>0&&(t(`processStorageCache | replaying ${w.length} cached event(s)`,w),w.forEach(F=>{let U=qt(F.properties);r?.track(F.name,U)}),fc());let $=gc();$.length>0&&(t(`processStorageCache | replaying ${$.length} cached page view(s)`,$),$.forEach(F=>{r?.pageView(F.name,"Deriv App",N(),F.properties)}),pc())}catch(w){console.warn("Analytics: Failed to process storage cache",w)}}},f=()=>{t("onSdkLoaded | RudderStack SDK loaded"),h(),u.length>0&&t(`onSdkLoaded | flushing ${u.length} pending identify call(s)`),u.forEach(({userId:w,traits:$})=>{w&&r?.identifyEvent(w,$)}),u=[]},g=async({growthbookKey:w,growthbookDecryptionKey:$,rudderstackKey:F,growthbookOptions:U,posthogOptions:Z,debug:ce})=>{var ie,_e;ce!==void 0&&(e=ce),t("initialise | starting analytics initialization",{rudderstack:!!F,growthbook:!!w,posthog:!!Z});try{let Oe=U?.attributes?.country||(w?await ac():void 0);if(F&&(t("initialise | initializing RudderStack"),r=or.getRudderStackInstance(F,f,e)),U?.attributes&&Object.keys(U.attributes).length>0){let H=U.attributes,gt=r?.getAnonymousId();o={...o,country:Oe,...H.user_language&&{user_language:H.user_language},...H.account_type&&{account_type:H.account_type},...H.app_id&&{app_id:H.app_id},...H.residence_country&&{residence_country:H.residence_country},...H.device_type&&{device_type:H.device_type},...H.url&&{url:H.url},...H.email_hash&&{email_hash:H.email_hash},...H.network_type&&{network_type:H.network_type},...H.network_rtt&&{network_rtt:H.network_rtt},...H.network_downlink&&{network_downlink:H.network_downlink},...H.account_currency&&{account_currency:H.account_currency},...H.account_mode&&{account_mode:H.account_mode},loggedIn:!!H.loggedIn,...H.user_id&&!Xs(H.user_id)&&{user_id:H.user_id},...gt&&{anonymous_id:gt}}}U??(U={}),U.attributes??(U.attributes={});let ke=r?.getAnonymousId();if((ie=U.attributes).id??(ie.id=ke),(_e=U.attributes).country??(_e.country=Oe),w){t("initialise | initializing GrowthBook");let{Growthbook:H}=await Promise.resolve().then(()=>(ad(),od));i=H.getGrowthBookInstance(w,$,U,e),t("initialise | GrowthBook initialized");let gt=setInterval(()=>{Object.keys(a).length>0?clearInterval(gt):a=m("tracking-buttons-config",{})},1e3)}if(Z){t("initialise | initializing PostHog");let{Posthog:H}=await Promise.resolve().then(()=>(pg(),fg));n=H.getPosthogInstance(Z,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(Oe){console.warn("Analytics: Failed to initialize",Oe)}},p=w=>{t("setAttributes | received attributes",w);let{user_id:$,...F}=w,U=$??N();if(i){let Z={...F};$&&!Xs($)&&(Z.user_id=$),U&&(Z.id=U,Z.user_id=U),t("setAttributes | called GrowthBook setAttributes",Z),i.setAttributes(Z)}o={...o,...Object.fromEntries(Object.entries(F).filter(([,Z])=>Z!==void 0)),...$!==void 0&&!Xs($)&&{user_id:$}},t("setAttributes | updated core_data",o)},v=w=>i?.getFeatureState(w)?.experimentResult?.name,m=(w,$)=>i?.getFeatureValue(w,$),b=async()=>await i?.getStatus(),k=w=>i?.isOn(w),D=w=>i?.setUrl(w),N=()=>{let w=r?.getUserId()||"";return w&&!Xs(w)?w:""},ae={initialise:g,setAttributes:p,identifyEvent:(w,$)=>{let F=w||N();if(!F){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:F,traits:$});let U=_e=>{if(!_e)return _e;let{email:Oe,...ke}=_e;return{...ke,...Oe&&{is_internal:nr(Oe)}}},Z=$?.rudderstack!==void 0||$?.posthog!==void 0,ce,ie;if(Z){let{rudderstack:_e,posthog:Oe,...ke}=$;ce=U({...ke,..._e}),ie=U({...ke,...Oe})}else ce=U($),ie=U($);r&&(r.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:F,traits:ce}),r.identifyEvent(F,ce)):u.some(_e=>_e.userId===F)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:F}),u.push({userId:F,traits:ce}))),n?.has_initialized&&(t("identifyEvent | calling PostHog identify",{user_id:F,traits:ie}),n.identifyEvent(F,ie))},backfillPersonProperties:({user_id:w,email:$,language:F,country_of_residence:U})=>{t("backfillPersonProperties | called",{user_id:w}),n?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:w}),n.backfillPersonProperties({user_id:w,email:$,language:F,country_of_residence:U})):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:m,getGrowthbookStatus:b,isFeatureOn:k,setUrl:D,getId:N,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(w,$)=>{let F=N();t("trackEvent | called",{event:w,analytics_data:$,userId:F,core_data:o});let U={...o,...$,...F&&!o.user_id&&{user_id:F}};if(t("trackEvent | built payload",{event:w,final_payload:U}),!(!(w in a)||a[w])){t("trackEvent | skipped \u2014 event disabled by tracking_config",{event:w});return}let ce=r?.has_initialized;if(!navigator.onLine||!ce)ce?(t("trackEvent | offline \u2014 caching event to memory",{event:w}),l.push({event:w,payload:U})):(t("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:w}),cc(w,U));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(_e=>{let Oe=qt(_e.payload);r?.track(_e.event,Oe)}),l=[]);let ie=qt(U);t("trackEvent | sending event to RudderStack",{event:w,payload:ie}),r?.track(w,ie)}if(n?.has_initialized){let ie=qt(uc(U));t("trackEvent | sending event to PostHog",{event:w,payload:ie}),n.capture(w,ie)}},getInstances:()=>({ab:i,tracking:r,posthog:n}),pageView:(w,$="Deriv App",F)=>{let U=N();t("pageView | called",{current_page:w,platform:$,properties:F,userId:U}),r?.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:w,platform:$}),r.pageView(w,$,U,F)):(t("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:w}),dc(w,{platform:$,...F}))},reset:()=>{t("reset | resetting all providers"),r?.has_initialized&&(t("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(t("reset | resetting PostHog"),n.reset())},isPosthogFeatureEnabled:w=>n?.isFeatureEnabled(w),getPosthogFeatureFlag:w=>n?.getFeatureFlag(w),getPosthogFeatureFlagPayload:w=>n?.getFeatureFlagPayload(w),getPosthogAllFlags:()=>n?.getAllFlags()??{},onPosthogFeatureFlags:w=>n?.onFeatureFlags(w)??(()=>{}),reloadPosthogFeatureFlags:()=>n?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=ae),ae}var vg=PE();return Ag(CE);})();
|
|
2
|
+
"use strict";var DerivAnalytics=(()=>{var Ni=Object.defineProperty;var Ig=Object.getOwnPropertyDescriptor;var Og=Object.getOwnPropertyNames;var Pg=Object.prototype.hasOwnProperty;var Cg=(s,e,t)=>e in s?Ni(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var Fe=(s,e)=>()=>(s&&(e=s(s=0)),e);var _n=(s,e)=>{for(var t in e)Ni(s,t,{get:e[t],enumerable:!0})},Dg=(s,e,t,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Og(e))!Pg.call(s,r)&&r!==t&&Ni(s,r,{get:()=>e[r],enumerable:!(i=Ig(e,r))||i.enumerable});return s};var Ng=s=>Dg(Ni({},"__esModule",{value:!0}),s);var le=(s,e,t)=>Cg(s,typeof e!="symbol"?e+"":e,t);function he(s){return s!=null&&typeof s=="object"&&s["@@functional/placeholder"]===!0}function mt(s){return function e(t){return arguments.length===0||he(t)?e:s.apply(this,arguments)}}function Pt(s){return function e(t,i){switch(arguments.length){case 0:return e;case 1:return he(t)?e:mt(function(r){return s(t,r)});default:return he(t)&&he(i)?e:he(t)?mt(function(r){return s(r,i)}):he(i)?mt(function(r){return s(t,r)}):s(t,i)}}}function so(s){return function e(t,i,r){switch(arguments.length){case 0:return e;case 1:return he(t)?e:Pt(function(n,o){return s(t,n,o)});case 2:return he(t)&&he(i)?e:he(t)?Pt(function(n,o){return s(n,i,o)}):he(i)?Pt(function(n,o){return s(t,n,o)}):mt(function(n){return s(t,i,n)});default:return he(t)&&he(i)&&he(r)?e:he(t)&&he(i)?Pt(function(n,o){return s(n,o,r)}):he(t)&&he(r)?Pt(function(n,o){return s(n,i,o)}):he(i)&&he(r)?Pt(function(n,o){return s(t,n,o)}):he(t)?mt(function(n){return s(n,i,r)}):he(i)?mt(function(n){return s(t,n,r)}):he(r)?mt(function(n){return s(t,i,n)}):s(t,i,r)}}}function xi(s,e){return Object.prototype.hasOwnProperty.call(e,s)}function bl(s){return Object.prototype.toString.call(s)==="[object Object]"}function $g(s,e){var t=s<0?e.length+s:s;return e[t]}function Fg(s){return new RegExp(s.source,s.flags?s.flags:(s.global?"g":"")+(s.ignoreCase?"i":"")+(s.multiline?"m":"")+(s.sticky?"y":"")+(s.unicode?"u":"")+(s.dotAll?"s":""))}function tu(s,e,t){if(t||(t=new Ug),Mg(s))return s;var i=function(n){var o=t.get(s);if(o)return o;t.set(s,n);for(var a in s)Object.prototype.hasOwnProperty.call(s,a)&&(n[a]=tu(s[a],!0,t));return n};switch(xg(s)){case"Object":return i(Object.create(Object.getPrototypeOf(s)));case"Array":return i(Array(s.length));case"Date":return new Date(s.valueOf());case"RegExp":return Fg(s);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return s.slice();default:return s}}function Mg(s){var e=typeof s;return s==null||e!="object"&&e!="function"}function Bg(s,e){for(var t=e,i=0;i<s.length;i+=1){if(t==null)return;var r=s[i];Lg(r)?t=$g(r,t):t=t[r]}return t}function of(s){return crypto.getRandomValues(new Uint8Array(s))}function af(){(!bn||Ct+16>kl)&&(bn=of(kl),Ct=0);for(var s=0,e,t="";s<16;s++)e=bn[Ct+s],s==6?t+=Mi[e&15|64]:s==8?t+=Mi[e&63|128]:t+=Mi[e],s&1&&s>1&&s<11&&(t+="-");return Ct+=16,t}function lf(){var s=0,e,t="";if(!$i||zt+16>256){for($i=Array(s=256);s--;)$i[s]=256*Math.random()|0;s=zt=0}for(;s<16;s++)e=$i[zt+s],s==6?t+=Ui[e&15|64]:s==8?t+=Ui[e&63|128]:t+=Ui[e],s&1&&s>1&&s<11&&(t+="-");return zt++,t}function $f(s,e,t=Lf){let i;return(...r)=>{globalThis.clearTimeout(i),i=globalThis.setTimeout(()=>{s.apply(e,r)},t)}}function tr(){if(yt>1)yt--;else{var s,e=!1;for((function(){var r=Xi;for(Xi=void 0;r!==void 0;)r.S.v===r.v&&(r.S.i=r.i),r=r.o})();qs!==void 0;){var t=qs;for(qs=void 0,Ki++;t!==void 0;){var i=t.u;if(t.u=void 0,t.f&=-3,!(8&t.f)&&vu(t))try{t.c()}catch(r){e||(s=r,e=!0)}t=i}}if(Ki=0,yt--,e)throw s}}function Ae(s){if(yt>0)return s();Pn=++Kf,yt++;try{return s()}finally{tr()}}function fu(s){var e=J;J=void 0;try{return s()}finally{J=e}}function pu(s){if(J!==void 0){var e=s.n;if(e===void 0||e.t!==J)return e={i:0,S:s,p:J.s,n:void 0,t:J,e:void 0,x:void 0,r:e},J.s!==void 0&&(J.s.n=e),J.s=e,s.n=e,32&J.f&&s.S(e),e;if(e.i===-1)return e.i=0,e.n!==void 0&&(e.n.p=e.p,e.p!==void 0&&(e.p.n=e.n),e.p=J.s,e.n=void 0,J.s.n=e,J.s=e),e}}function De(s,e){this.v=s,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function b(s,e){return new De(s,e)}function vu(s){for(var e=s.s;e!==void 0;e=e.n)if(e.S.i!==e.i||!e.S.h()||e.S.i!==e.i)return!0;return!1}function _u(s){for(var e=s.s;e!==void 0;e=e.n){var t=e.S.n;if(t!==void 0&&(e.r=t),e.S.n=e,e.i=-1,e.n===void 0){s.s=e;break}}}function mu(s){for(var e=s.s,t=void 0;e!==void 0;){var i=e.p;e.i===-1?(e.S.U(e),i!==void 0&&(i.n=e.n),e.n!==void 0&&(e.n.p=i)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}s.s=t}function fs(s,e){De.call(this,void 0),this.x=s,this.s=void 0,this.g=Yi-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}function yu(s){var e=s.m;if(s.m=void 0,typeof e=="function"){yt++;var t=J;J=void 0;try{e()}catch(i){throw s.f&=-2,s.f|=8,lo(s),i}finally{J=t,tr()}}}function lo(s){for(var e=s.s;e!==void 0;e=e.n)e.S.U(e);s.x=void 0,s.s=void 0,yu(s)}function Xf(s){if(J!==this)throw new Error("Out-of-order effect");mu(this),J=s,this.f&=-2,8&this.f&&lo(this),tr()}function ps(s,e){this.x=s,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name}function lt(s,e){var t=new ps(s,e);try{t.c()}catch(r){throw t.d(),r}var i=t.d.bind(t);return i[Symbol.dispose]=i,i}function Ou(s){if(!s?.includes(":"))return[s||void 0,void 0,void 0];let e=s.startsWith("(")&&s.endsWith(")")?s.slice(1,-1):s,t=Sv.exec(e);return t?[t[1]||void 0,t[2]===void 0?void 0:Number(t[2]),t[3]===void 0?void 0:Number(t[3])]:[void 0,void 0,void 0]}function wv(s){if(!Iu.test(s))return null;s.includes("(eval ")&&(s=s.replaceAll("eval code","eval").replaceAll(/(\(eval at [^()]*)|(,.*$)/g,""));let e=s.replace(/^\s+/,"").replaceAll("(eval code","(").replace(/^.*?\s+/,""),t=/ (\(.+\)$)/.exec(e),i=t?e.replace(t[0],""):e,[r,n,o]=Ou(t?t[1]:e);return{functionName:t&&i||void 0,fileName:r==="eval"||r==="<anonymous>"?void 0:r,lineNumber:n,columnNumber:o}}function Av(s){if(kv.test(s))return null;if(s.includes(" > eval")&&(s=s.replaceAll(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!s.includes("@")&&!s.includes(":"))return{functionName:s,fileName:void 0,lineNumber:void 0,columnNumber:void 0};let e=s.lastIndexOf("@"),t=e>0?s.slice(0,e):void 0,[i,r,n]=Ou(s.slice(e+1));return{functionName:t,fileName:i,lineNumber:r,columnNumber:n}}function Tv(s){if(!s.stack)throw new Error("Cannot parse given Error object");let e=s.stack.split(`
|
|
3
|
+
`);return e.some(t=>Iu.test(t))?e.map(wv).filter(t=>t!==null):e.map(Av).filter(t=>t!==null)}function Fl(s,e,t,i){return{errorClass:$l(s),message:`${t}${$l(e)}`,type:"browserjs",stacktrace:i.reduce((r,n)=>{let o=Iv(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function Mu(s,e){let t=Object.assign(s,e);for(let i of Object.keys(t))typeof t[i]=="object"&&typeof e[i]=="object"&&(t[i]=Mu(t[i],e[i]));return t}async function h_(s){let e=c_[s];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((t,i)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=d_();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}t(e.lib)}).catch(i)})})}function Me(s,e){if(!s?.default&&e){let t=Object.create(null);return t.default=s,t.__esModule=!0,t}return s}function Ue(s,e){return h_(s).then(t=>t.get(e).then(i=>i()))}function G_(s){return s&&s.__esModule&&Object.prototype.hasOwnProperty.call(s,"default")?s.default:s}function j_(){return jl||(jl=1,(function(s,e){(function(t,i){s.exports=i()})(H_,function(){function t(g){return g=JSON.stringify(g),!!/^\{[\s\S]*\}$/.test(g)}function i(g){return g===void 0||typeof g=="function"?g+"":JSON.stringify(g)}function r(g){if(typeof g=="string")try{return JSON.parse(g)}catch{return g}}function n(g){return{}.toString.call(g)==="[object Function]"}function o(g){return Object.prototype.toString.call(g)==="[object Array]"}function a(g){var p="_Is_Incognit",v="yes";try{g||(g=window.localStorage),g.setItem(p,v),g.removeItem(p)}catch{var m={};m._data={},m.setItem=function(w,C){return m._data[w]=String(C)},m.getItem=function(w){return m._data.hasOwnProperty(w)?m._data[w]:void 0},m.removeItem=function(w){return delete m._data[w]},m.clear=function(){return m._data={}},g=m}finally{g.getItem(p)===v&&g.removeItem(p)}return g}var l=a();function u(){if(!(this instanceof u))return new u}u.prototype={set:function(p,v){if(p&&!t(p))l.setItem(p,i(v));else if(t(p))for(var m in p)this.set(m,p[m]);return this},get:function(p){if(p===void 0){var v={};return this.forEach(function(R,N){return v[R]=N}),v}if(p.charAt(0)==="?")return this.has(p.substr(1));var m=arguments;if(m.length>1){for(var y={},w=0,C=m.length;w<C;w++){var D=r(l.getItem(m[w]));this.has(m[w])&&(y[m[w]]=D)}return y}return r(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var v=this.get(p);return l.removeItem(p),v},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(v){p.push(v)}),p},forEach:function(p){for(var v=0,m=l.length;v<m;v++){var y=l.key(v);p(y,this.get(y))}return this},search:function(p){for(var v=this.keys(),m={},y=0,w=v.length;y<w;y++)v[y].indexOf(p)>-1&&(m[v[y]]=this.get(v[y]));return m},len:function(){return l.length}};var d=null;function h(g,p){var v=arguments,m=null;if(d||(d=u()),v.length===0)return d.get();if(v.length===1){if(typeof g=="string")return d.get(g);if(t(g))return d.set(g)}if(v.length===2&&typeof g=="string"){if(!p)return d.remove(g);if(p&&typeof p=="string")return d.set(g,p);p&&n(p)&&(m=null,m=p(g,d.get(g)),h.set(g,m))}if(v.length===2&&o(g)&&n(p))for(var y=0,w=g.length;y<w;y++)m=p(g[y],d.get(g[y])),h.set(g[y],m);return h}for(var f in u.prototype)h[f]=u.prototype[f];return h})})(Gi)),Gi.exports}var xg,Lg,Ug,q,Vg,Gg,Hg,jg,su,x,re,Ve,Te,tt,zg,ee,cs,qg,io,Wg,Rn,Kg,Xg,Yg,ne,Jg,we,bt,Gs,ji,pt,ot,ro,Qg,El,zi,Zg,ef,qi,no,iu,ru,nu,mn,oo,In,Xe,ou,Bs,Gt,Hs,os,tf,yn,sf,rf,nf,Li,kl,Mi,Ct,bn,zt,Ui,$i,uf,Zi,cf,df,hf,au,gf,V,ff,Sl,pf,vf,_f,mf,yf,bf,Ef,lu,kf,et,Sf,uu,Y,cu,er,ao,fe,wl,Ws,wf,du,Af,Al,Tf,Rf,zs,If,Of,Pf,Tl,Cf,Rl,Df,Nf,Il,On,Ol,xf,Lf,hu,Ks,gu,Pl,Ff,Mf,Uf,Bf,Vf,Gf,Hf,jf,zf,qf,Wi,Wf,J,qs,yt,Ki,Kf,Pn,Xi,Yi,Cn,Fi,Cl,bu,Yf,Jf,Qf,Dn,Et,vt,Eu,Nn,Dl,Zf,ep,tp,sp,ip,rp,np,op,Nl,ap,lp,up,cp,dp,hp,gp,xl,fp,pp,ku,vp,_p,mp,yp,bp,Ep,kp,Ll,Sp,wp,Ap,Tp,Rp,Ip,Op,Pp,Cp,Dp,Np,xp,Lp,$p,Fp,Mp,Up,Bp,Vp,Gp,Hp,jp,zp,qp,Wp,Kp,Xp,Su,sr,wu,Yp,Xs,ir,uo,Au,Tu,Ru,Ht,Jp,xn,Bi,Qp,Zp,ev,tv,sv,iv,Q,En,rv,nv,ov,av,lv,uv,cv,dv,hv,gv,fv,pv,vv,_v,mv,yv,bv,Ev,c,Iu,kv,Sv,Pu,Rv,Iv,$l,Cu,Ov,Ml,Vi,Pv,Cv,Dv,Nv,xv,Lv,$v,Fv,Ul,Bl,Ln,Du,Mv,Uv,Bv,Vv,Gv,Hv,jv,Nu,zv,qv,Wv,Kv,Xv,Yv,Jv,Qv,Zv,e_,xu,Lu,t_,s_,i_,r_,$n,$u,Fn,n_,o_,a_,Vl,l_,Fu,u_,c_,d_,g_,f_,Uu,p_,v_,kn,__,Mn,Be,je,Ke,at,qt,m_,y_,b_,E_,k_,S_,w_,A_,T_,R_,I_,O_,as,P_,Bu,Vu,C_,Gu,Hu,ls,Gl,Hl,D_,N_,Un,x_,_t,L_,$_,F_,M_,U_,B_,V_,Bn,Ji,Gi,H_,jl,z_,Vt,ju,us,Vn,co,Gn,ho,Hn,go,Ze,q_,W_,K_,X_,Y_,jn,J_,zn,Q_,Z_,zu,em,tm,sm,ds,qn,qu,im,rm,nm,hs,Sn,wn,om,am,lm,zl,um,Wu,cm,dm,hm,gm,fm,pm,vm,_m,mm,Ku,ym,bm,Wn,Em,Xu,km,Sm,wm,Yu,Am,Tm,Kn,Rm,Im,Om,Pm,ql,Cm,Wl,Dm,Kl,Xn,Nm,xm,Xl,An,Ju,Lm,Qi,Yl,Qu,Jl,$m,Fm,Mm,Um,Bm,js,Yn,Vm,Gm,Hm,Tn,jm,zm,qm,Wm,Km,Vs,Jn,Qn,Zn,Xm,Ym,Jm,Ql,Zl,Qm,Zm,ey,ty,Hi,eo,eu,sy,iy,to,jt,gs,fo=Fe(()=>{"use strict";xg=mt(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Lg=Number.isInteger||function(e){return e<<0===e};Ug=(function(){function s(){this.map={},this.length=0}return s.prototype.set=function(e,t){var i=this.hash(e),r=this.map[i];r||(this.map[i]=r=[]),r.push([e,t]),this.length+=1},s.prototype.hash=function(e){var t=[];for(var i in e)t.push(Object.prototype.toString.call(e[i]));return t.join()},s.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var o=this.map[t],i=0;i<o.length;i+=1){var r=o[i];if(r[0]===e)return r[1]}return}var n=this.hash(e),o=this.map[n];if(o)for(var i=0;i<o.length;i+=1){var r=o[i];if(r[0]===e)return r[1]}},s})(),q=mt(function(e){return e!=null&&typeof e.clone=="function"?e.clone():tu(e)});Vg=so(function(e,t,i){var r={},n;t=t||{},i=i||{};for(n in t)xi(n,t)&&(r[n]=xi(n,i)?e(n,t[n],i[n]):t[n]);for(n in i)xi(n,i)&&!xi(n,r)&&(r[n]=i[n]);return r}),Gg=so(function s(e,t,i){return Vg(function(r,n,o){return bl(n)&&bl(o)?s(e,n,o):e(r,n,o)},t,i)}),Hg=so(function(e,t,i){return Gg(function(r,n,o){return e(n,o)},t,i)}),jg=Pt(Bg),su=Pt(function(e,t){var i={};for(var r in t)e(t[r],r,t)&&(i[r]=t[r]);return i}),x=s=>typeof s=="function"&&!!(s.constructor&&s.call&&s.apply),re=s=>typeof s=="string",Ve=s=>s===null,Te=s=>typeof s>"u",tt=s=>Ve(s)||Te(s),zg=s=>typeof s=="bigint",ee=s=>!Te(s),cs=s=>!tt(s),qg=s=>cs(s)&&s!=="",io=s=>{switch(Object.prototype.toString.call(s)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return s instanceof Error}},Wg=s=>typeof s=="boolean",Rn=(s,e)=>{let t=e.split(".");return jg(t,s)},Kg=(s,e)=>!!Rn(s,e),Xg=s=>typeof s=="object",Yg=s=>!Ve(s)&&Xg(s)&&!Array.isArray(s),ne=s=>!Ve(s)&&Object.prototype.toString.call(s)==="[object Object]",Jg=(s,e)=>{if(!Array.isArray(s)||!Array.isArray(e))return q(e);let t=q(s);return e.forEach((i,r)=>{t[r]=Array.isArray(i)||Yg(i)?we(t[r],i):i}),t},we=(s,e)=>Hg(Jg,s,e),bt=s=>ne(s)&&Object.keys(s).length>0,Gs=s=>{let e=su(ee,s);return Object.keys(e).forEach(t=>{let i=e[t];ne(i)&&(e[t]=Gs(i))}),e},ji=s=>{let e=su(cs,s);return Object.keys(e).forEach(t=>{let i=e[t];ne(i)&&(e[t]=ji(i))}),e},pt=s=>{if(bt(s))return ji(s)},ot=(s,e)=>typeof s=="boolean"?s:e,ro=s=>(Object.getOwnPropertyNames(s).forEach(function(e){s[e]&&typeof s[e]=="object"&&ro(s[e])}),Object.freeze(s)),Qg=s=>s.replace(/^\s+|\s+$/gm,""),El=s=>s.replace(/^\.+/,""),zi=s=>{let e=s;if(!re(s)&&!tt(s))try{e=JSON.stringify(s)}catch{e=null}return e},Zg=s=>{let e=Array.from(s,t=>String.fromCodePoint(t)).join("");return globalThis.btoa(e)},ef=s=>Zg(new TextEncoder().encode(s)),qi=(s,e,t,i,r)=>{let n={category:s,name:e,properties:t,options:i,callback:void 0};x(r)&&(n.callback=r),x(i)&&(n.category=s,n.name=e,n.properties=t,n.options=void 0,n.callback=i),x(t)&&(n.category=s,n.name=e,n.properties=void 0,n.options=void 0,n.callback=t),x(e)&&(n.category=s,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),x(s)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=s),ne(s)?(n.name=void 0,n.category=void 0,n.properties=s,x(e)?n.options=void 0:n.options=e):ne(e)&&(n.name=void 0,n.properties=e,x(t)?n.options=void 0:n.options=t),re(s)&&!re(e)&&(n.category=void 0,n.name=s),ee(n.category)||(n.category=void 0),ee(n.name)||(n.name=void 0),n.properties=n.properties?q(n.properties):{},ee(n.options)?n.options=q(n.options):n.options=void 0;let o=re(n.name)?n.name:n.properties.name,a=re(n.category)?n.category:n.properties.category;return n.properties=we(ne(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},no=(s,e,t,i)=>{let r={name:s,properties:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.properties=e,r.options=void 0,r.callback=t),x(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=cs(r.properties)?q(r.properties):{},ee(r.options)?r.options=q(r.options):r.options=void 0,r},iu=(s,e,t,i)=>{let r={userId:s,traits:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.userId=s,r.traits=e,r.options=void 0,r.callback=t),x(e)&&(r.userId=s,r.traits=void 0,r.options=void 0,r.callback=e),(ne(s)||Ve(s))&&(r.userId=null,r.traits=s,x(e)?r.options=void 0:r.options=e),r.userId=zi(r.userId),ne(r.traits)?r.traits=q(r.traits):r.traits=void 0,ee(r.options)?r.options=q(r.options):r.options=void 0,r},ru=(s,e,t,i)=>{let r={to:s,from:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.to=s,r.from=e,r.options=void 0,r.callback=t),x(e)?(r.to=s,r.from=void 0,r.options=void 0,r.callback=e):(ne(e)||Ve(e))&&(r.to=s,r.from=void 0,r.options=e),ee(r.to)&&(r.to=zi(r.to)),ee(r.from)?r.from=zi(r.from):r.from=void 0,ee(r.options)?r.options=q(r.options):r.options=void 0,r},nu=(s,e,t,i)=>{let r={groupId:s,traits:e,options:t,callback:void 0};return x(i)&&(r.callback=i),x(t)&&(r.groupId=s,r.traits=e,r.options=void 0,r.callback=t),x(e)&&(r.groupId=s,r.traits=void 0,r.options=void 0,r.callback=e),(ne(s)||Ve(s))&&(r.groupId=null,r.traits=s,x(e)?r.options=void 0:r.options=e),r.groupId=zi(r.groupId),ne(r.traits)?r.traits=q(r.traits):r.traits=void 0,ee(r.options)?r.options=q(r.options):r.options=void 0,r},mn=(function(s){return s.UNLOADED="Page Unloaded",s})({}),oo="API",In="CapabilitiesManager",Xe="ConfigManager",ou="EventManager",Bs="PluginsManager",Gt="UserSessionManager",Hs="ErrorHandler",os="PluginEngine",tf="StoreManager",yn=`Ready${oo}`,sf=`Load${oo}`,rf="HttpClient",nf="RudderStackAnalytics",Li="AnalyticsCore";kl=4096,Mi=[],Ct=0;for(;Ct<256;Ct++)Mi[Ct]=(Ct+256).toString(16).substring(1);zt=256,Ui=[];for(;zt--;)Ui[zt]=(zt+256).toString(16).substring(1);uf=()=>!tt(globalThis.crypto)&&x(globalThis.crypto.getRandomValues),Zi=()=>uf()?af():lf(),cf=()=>!!window.chrome?.runtime?.id,df=()=>re(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),hf=(s,e=!1)=>{let t=!1,i=!1;function r(){t||(t=!0,s(i),setTimeout(()=>{t=!1},0))}(e||df())&&globalThis.addEventListener("beforeunload",()=>{i=!1,r()}),globalThis.addEventListener("blur",()=>{i=!0,r()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?r():t=!1})},au=s=>s.toISOString(),gf=()=>au(new Date),V=":: ",ff=s=>`A script with the id "${s}" is already loaded. Skipping the loading of this script to prevent conflicts`,Sl=(s,e,t)=>`Unable to load (${re(t)?t:t.type}) the script with the id "${s}" from URL "${e}"`,pf=(s,e,t)=>`A timeout of ${t} ms occurred while trying to load the script with id "${s}" from URL "${e}"`,vf=(s,e)=>`${s}${V}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,_f="Failed to convert the value to a JSON string.",mf="Failed to encode the cookie data.",yf=(s,e)=>`${s}${V}The "${e}" storage type is `,bf="JSONStringify",Ef="[BigInt]",lu="[Circular Reference]",kf=(s,e,t)=>{let i=[];return function(r,n){if(!e?.includes(r)&&!(s&&tt(n))){if(typeof n!="object"||Ve(n))return n;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(n)?(t?.warn(vf(bf,r)),lu):(i.push(n),n)}}},et=(s,e,t,i)=>{try{return JSON.stringify(s,kf(e,t,i))}catch(r){return i?.warn(_f,r),null}},Sf=s=>{let e=[];return function(i,r){if(zg(r))return Ef;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?lu:(e.push(r),r)}},uu=(s,e)=>{let t=Array.isArray(s)?[]:{};for(let i in s)if(Object.hasOwnProperty.call(s,i)){let r=s[i],n=e.call(s,i,r);ne(n)||Array.isArray(n)?t[i]=uu(n,e):t[i]=n}return t},Y=(s,e)=>{let t=Sf(),i=t.call(s,"",s);return ne(s)||Array.isArray(s)?uu(s,t):i},cu="[SDK DISPATCHED ERROR]",er=s=>{let{stack:e}=s;if(typeof e=="string"&&e)return e},ao=(s,e)=>{if(!io(s))return new Error(`${e}: ${et(s)}`);try{let t=s.constructor,i=new t(`${e}: ${s.message}`),r=er(s);return r&&(i.stack=r),Object.getOwnPropertyNames(s).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{i[n]=s[n]}catch{}}),i}catch{return new Error(`${e}: ${et(s)}`)}},fe=s=>{if(io(s)){let e=er(s);e&&(s.stack=`${e}
|
|
4
|
+
${cu}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:s,bubbles:!0,cancelable:!0,composed:!0}))},wl="RudderLabs JavaScript SDK",Ws="3.31.0",wf="com.rudderlabs.javascript",du="npm",Af="modern",Al="RudderJS-Initiated",Tf="ad-block page request",Rf="/ad-blocked",zs="preloadedEventsBuffer",If="Consent Management Interaction",Of="ajs_trait_",Pf="ajs_prop_",Tl="ajs_aid",Cf="ajs_uid",Rl="ajs_event",Df=10*1e3,Nf=31536e3*1e3,Il=720*60*1e3,On=1800*1e3,Ol=10*1e3,xf=10*1e3,Lf=250,hu=(s="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[s]||(globalThis.RudderStackGlobals[s]={})},Ks=(s,e,t="app")=>{hu(t),globalThis.RudderStackGlobals[t][s]=e},gu=(s,e="app")=>(hu(e),globalThis.RudderStackGlobals[e][s]);Pl=(s,e)=>{let t={};return s.forEach((i,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);t[n]=s.get(r)}}),t},Ff=(s=[])=>{let e={trait:Of,properties:Pf},t=new URLSearchParams(globalThis.location.search);t.get(Rl)&&s.unshift(["track",t.get(Rl),Pl(t,e.properties)]);let i=t.get(Cf),r=Pl(t,e.trait);if(i||bt(r)){let n=[...i?[i]:[],r];s.unshift(["identify",...n])}t.get(Tl)&&s.unshift(["setAnonymousId",t.get(Tl)])},Mf=s=>{let e="load",t=[],i=0;for(;i<s.length;){if(s[i]&&s[i][0]===e){t=q(s[i]),s.splice(i,1);break}i+=1}return t},Uf=s=>{let e="consent",t=s.filter(r=>r[0]===e),i=s.filter(r=>r[0]!==e);s.splice(0,s.length,...t,...i)},Bf=s=>{let e=gu(zs)||[];Ff(e),e.length>0&&(s.enqueuePreloadBufferEvents(e),Ks(zs,[]))},Vf=(s,e)=>{let t=s.shift(),i;if(x(e[t])){switch(t){case"page":i=qi(...s);break;case"track":i=no(...s);break;case"identify":i=iu(...s);break;case"alias":i=ru(...s);break;case"group":i=nu(...s);break;default:e[t](...s);break}i&&e[t](i)}},Gf=10*1e3,Hf="RS_JS_SDK",jf=(s,e,t=!0,i=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=r,o.src=s,o.id=e,o.async=t,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",Hf),o},zf=s=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(s,e[0]?.firstChild);return}let t=document.getElementsByTagName("script");if(t.length>0&&t[0]?.parentNode){t[0]?.parentNode.insertBefore(s,t[0]);return}let i=document.createElement("head");i.appendChild(s);let r=document.getElementsByTagName("html")[0];r?.insertBefore(i,r.firstChild)},qf=(s,e,t,i=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(ff(e)));try{let l;zf(jf(s,e,i,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(Sl(e,s,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(pf(e,s,t)))},t)}catch(l){o(ao(l,Sl(e,s,"unknown")))}}),Wi=class{constructor(e,t=Gf){this.logger=e,this.timeout=t}loadJSFile(e){let{url:t,id:i,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!x(o);qf(t,i,r||this.timeout,n,a).then(u=>{l||o(u)}).catch(u=>{l||o(i,u)})}},Wf=Symbol.for("preact-signals");J=void 0;qs=void 0,yt=0,Ki=0,Kf=0,Pn=0,Xi=void 0,Yi=0;De.prototype.brand=Wf;De.prototype.h=function(){return!0};De.prototype.S=function(s){var e=this,t=this.t;t!==s&&s.e===void 0&&(s.x=t,this.t=s,t!==void 0?t.e=s:fu(function(){var i;(i=e.W)==null||i.call(e)}))};De.prototype.U=function(s){var e=this;if(this.t!==void 0){var t=s.e,i=s.x;t!==void 0&&(t.x=i,s.e=void 0),i!==void 0&&(i.e=t,s.x=void 0),s===this.t&&(this.t=i,i===void 0&&fu(function(){var r;(r=e.Z)==null||r.call(e)}))}};De.prototype.subscribe=function(s){var e=this;return lt(function(){var t=e.value,i=J;J=void 0;try{s(t)}finally{J=i}},{name:"sub"})};De.prototype.valueOf=function(){return this.value};De.prototype.toString=function(){return this.value+""};De.prototype.toJSON=function(){return this.value};De.prototype.peek=function(){var s=J;J=void 0;try{return this.value}finally{J=s}};Object.defineProperty(De.prototype,"value",{get:function(){var s=pu(this);return s!==void 0&&(s.i=this.i),this.v},set:function(s){if(s!==this.v){if(Ki>100)throw new Error("Cycle detected");(function(t){yt!==0&&Ki===0&&t.l!==Pn&&(t.l=Pn,Xi={S:t,v:t.v,i:t.i,o:Xi})})(this),this.v=s,this.i++,Yi++,yt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{tr()}}}});fs.prototype=new De;fs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Yi))return!0;if(this.g=Yi,this.f|=1,this.i>0&&!vu(this))return this.f&=-2,!0;var s=J;try{_u(this),J=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return J=s,mu(this),this.f&=-2,!0};fs.prototype.S=function(s){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}De.prototype.S.call(this,s)};fs.prototype.U=function(s){if(this.t!==void 0&&(De.prototype.U.call(this,s),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};fs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var s=this.t;s!==void 0;s=s.x)s.t.N()}};Object.defineProperty(fs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var s=pu(this);if(this.h(),s!==void 0&&(s.i=this.i),16&this.f)throw this.v;return this.v}});ps.prototype.c=function(){var s=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{s()}};ps.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,yu(this),_u(this),yt++;var s=J;return J=this,Xf.bind(this,s)};ps.prototype.N=function(){2&this.f||(this.f|=2,this.u=qs,qs=this)};ps.prototype.d=function(){this.f|=8,1&this.f||lo(this)};ps.prototype.dispose=function(){this.d()};Cn=class{constructor(){this.items=[]}enqueue(e){this.items.push(e)}dequeue(){return this.items.length===0?null:this.items.shift()}isEmpty(){return this.items.length===0}size(){return this.items.length}clear(){this.items=[]}},Fi={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Cl="LOG",bu="ERROR",Yf="RS SDK",Jf="font-weight: bold; background: black; color: white;",Qf="font-weight: normal;",Dn=class{constructor(e=Cl,t="",i=console){this.minLogLevel=Fi[e],this.scope=t,this.logProvider=i}log(...e){this.outputLog("LOG",e)}info(...e){this.outputLog("INFO",e)}debug(...e){this.outputLog("DEBUG",e)}warn(...e){this.outputLog("WARN",e)}error(...e){this.outputLog("ERROR",e)}outputLog(e,t){this.minLogLevel<=Fi[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(t))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=Fi[e],Te(this.minLogLevel)&&(this.minLogLevel=Fi[Cl])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let t=`%c ${Yf}`;this.scope&&(t=`${t} - ${this.scope}`);let i=re(e[0])?e[0].trim():"";t=`${t} %c ${i}`;let r=[t,Jf,Qf];return re(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},Et=new Dn,vt=(function(s){return s.HANDLEDEXCEPTION="handledException",s.UNHANDLEDEXCEPTION="unhandledException",s.UNHANDLEDREJECTION="unhandledPromiseRejection",s})({}),Eu=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Nn="cookieStorage",Dl="Unable to process/parse source configuration response",Zf="The source is disabled. Please enable the source in the dashboard to send events.",ep="Failed to prepare data for the request.",tp="Failed to invoke plugin because the extension point name is missing.",sp="Failed to invoke plugin because the extension point name is invalid.",ip=s=>`${s}${V}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,rp=(s,e,t)=>`${s}${V}The base URL "${t}" for ${e} is not valid.`,np=(s,e,t)=>`${s}${V}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(t)}".`,op=(s,e)=>`${s}${V}Ignoring a non-error: ${e}.`,Nl="Failed to log breadcrumb",ap=s=>`${s}${V}Failed to handle the error.`,lp=s=>`${s}${V}Plugin name is missing.`,up=(s,e)=>`${s}${V}Plugin "${e}" already exists.`,cp=(s,e)=>`${s}${V}Plugin "${e}" not found.`,dp=(s,e)=>`${s}${V}Plugin "${e}" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.`,hp=(s,e,t)=>`${s}${V}Plugin "${e}" could not be loaded because some of its dependencies "${t}" do not exist.`,gp=(s,e,t)=>`${s}${V}Failed to invoke the "${e}" extension point of plugin "${t}".`,xl="Failed to fetch the source config",fp=(s,e)=>`${s}${V}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,pp=(s,e)=>`${s}${V}The data plane URL "${e}" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.`,ku=s=>`${s}${V}The provided callback parameter is not a function.`,vp=(s,e,t,i,r)=>`${s} with status ${e} (${t}) for URL: ${i}. Response: ${r.trim()}`,_p=(s,e,t)=>`${s} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${t}`,mp=(s,e)=>`${s} for URL: ${e}`,yp=s=>`Failed to save the value for "${s}" to storage`,bp=s=>`Failed to retrieve or parse data for "${s}" from storage`,Ep=s=>`The server responded with status ${s} while setting the cookies. As a fallback, the cookies will be set client side.`,kp=s=>`The server failed to set the ${s} cookie. As a fallback, the cookies will be set client side.`,Ll="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",Sp=(s,e,t)=>`${s}${V}The storage type "${e}" is not supported. Please choose one of the following supported types: "${Eu}". The default type "${t}" will be used instead.`,wp=(s,e,t,i)=>`${s}${V}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(t)}". The default version "${i}" will be used instead.`,Ap=(s,e,t)=>`${s}${V}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${t}). To enable storage data migration, please update the storage encryption version to the latest version.`,Tp=(s,e,t)=>`${s}${V}The provided cookie domain (${e}) does not match the current webpage's domain (${t}). Hence, the cookies will be set client-side.`,Rp=(s,e,t,i)=>`${s}${V}The "${e}" property defined under "${t}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,Ip=s=>`${s}${V}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,Op=s=>`${s}${V}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,Pp=(s,e,t)=>`${s}${V}The session timeout value "${e}" is not a number. The default timeout of ${t} ms will be used instead.`,Cp=(s,e,t)=>`${s}${V}The session cut off duration value "${e}" is not a number. The default cut off duration of ${t} ms will be used instead.`,Dp=(s,e,t)=>`${s}${V}The session cut off duration value "${e}" ms is less than the session timeout value "${t}" ms. The cut off functionality will be disabled.`,Np=s=>`${s}${V}The session timeout value is 0, which disables the automatic session tracking feature. If you want to enable session tracking, please provide a positive integer value for the timeout.`,xp=(s,e,t)=>`${s}${V}The session timeout value ${e} ms is less than the recommended minimum of ${t} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,Lp=(s,e,t)=>`${s}${V}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${t}" digits long. A new session ID will be auto-generated instead.`,$p=s=>`${s}${V}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,Fp=(s,e,t,i)=>`${s}${V}The storage type "${t}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,Mp=s=>`${s}${V}The callback threw an exception`,Up=(s,e)=>`${s}${V}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,Bp=(s,e)=>`Failed to load the polyfill script with ID "${s}" from URL ${e}.`,Vp=(s,e,t)=>`${s}${V}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${t}" will be used instead.`,Gp=(s,e,t)=>`${s}${V}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${t}" will be used instead.`,Hp=(s,e)=>`${s}${V}${e} plugin is deprecated. Please exclude it from the load API options.`,jp=(s,e,t,i)=>{let r=t.length===1,n=r?` '${t[0]}' plugin was`:` ['${t.join("', '")}'] plugins were`,o=`${s}${V}${e}, but${n} not configured to load.`;return i?`${o} So, ${r?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${r?"it":"them"} to the 'plugins' load API option.`},zp=(s,e)=>`${s}${V}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,qp=s=>`${s}${V}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,Wp=(s,e)=>`${s}${V}Ignoring unknown plugins: ${e.join(", ")}.`,Kp=(s,e)=>`${s}${V}Failed to load the following unavailable local plugins: ${e.join(", ")}. Some features of the SDK may not work as expected. Make sure you are using the correct SDK bundle variant.`,Xp=(s,e)=>`${s}${V}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,Su={All:!0},sr="js-integrations",wu="plugins",Yp=new RegExp("^(https?:\\/\\/)(((([a-zA-Z\\d]([a-zA-Z\\d-]*[a-zA-Z\\d])*)\\.)+[a-zA-Z]{2,}|localhost|((25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]?)\\.){3}(25[0-5]|2[0-4][0-9]|[0-1]?[0-9]?[0-9]?)))(\\:\\d+)?(\\/[-a-zA-Z\\d%_.~+]*)*(\\?[;&a-zA-Z\\d%_.~+=-]*)?(\\#[-a-zA-Z\\d_]*)?$"),Xs="modern",ir="https://cdn.rudderlabs.com",uo="v3",Au=`${ir}/${uo}/${Xs}/${sr}`,Tu=`${ir}/${uo}/${Xs}/${wu}`,Ru="https://api.rudderstack.com",Ht="v3",Jp="xhr",xn={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Bi={[Ht]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},Qp={[Jp]:"XhrQueue",beacon:"BeaconQueue"},Zp="rsaRequest",ev="rsaMetrics",tv="Custom Device Mode",sv={configUrl:Ru,loadIntegration:!0,sessions:{autoTrack:!0,timeout:On,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:Su,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:xf,storage:{encryption:{version:Ht},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},iv=b(q(sv)),Q=ro({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),En=ro({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),rv=10,nv={userId:b(Q.userId),userTraits:b(Q.userTraits),anonymousId:b(Q.anonymousId),groupId:b(Q.groupId),groupTraits:b(Q.groupTraits),initialReferrer:b(Q.initialReferrer),initialReferringDomain:b(Q.initialReferringDomain),sessionInfo:b(Q.sessionInfo),authToken:b(Q.authToken)},ov={isOnline:b(!0),storage:{isLocalStorageAvailable:b(!1),isCookieStorageAvailable:b(!1),isSessionStorageAvailable:b(!1)},isBeaconAvailable:b(!1),isLegacyDOM:b(!1),isUaCHAvailable:b(!1),isCryptoAvailable:b(!1),isAdBlockerDetectionInProgress:b(!1),isAdBlocked:b(void 0),cspBlockedURLs:b([])},av={isErrorReportingEnabled:b(!1),isMetricsReportingEnabled:b(!1),breadcrumbs:b([])},lv=b(void 0),uv={activeDataplaneUrl:b(void 0),integrationsCDNPath:b(Au),pluginsCDNPath:b(Tu),sourceConfigUrl:b(void 0),status:b(void 0),initialized:b(!1),logLevel:b(bu),loaded:b(!1),readyCallbacks:b([]),writeKey:b(void 0),dataPlaneUrl:b(void 0),safeAnalyticsInstance:b(void 0)},cv={enabled:b(!1),initialized:b(!1),data:b({}),activeConsentManagerPluginName:b(void 0),preConsent:b({enabled:!1}),postConsent:b({}),resolutionStrategy:b("and"),provider:b(void 0),metadata:b(void 0)},dv={retries:b(0),dropped:b(0),sent:b(0),queued:b(0),triggered:b(0),metricsServiceUrl:b(void 0)},hv=()=>Af,gv={app:b({name:wl,namespace:wf,version:Ws,installType:du}),traits:b(null),library:b({name:wl,version:Ws,snippetVersion:globalThis.RudderSnippetVersion,variant:hv()}),userAgent:b(null),device:b(null),network:b(null),os:b({name:"",version:""}),locale:b(null),screen:b({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":b(void 0),timezone:b(void 0)},fv={configuredDestinations:b([]),activeDestinations:b([]),loadOnlyIntegrations:b({}),failedDestinations:b([]),loadIntegration:b(!0),initializedDestinations:b([]),clientDestinationsReady:b(!1),integrationsConfig:b({})},pv={toBeProcessedArray:b([]),readyCallbacksArray:b([])},vv={ready:b(!1),loadedPlugins:b([]),failedPlugins:b([]),pluginsToLoadFromConfig:b([]),activePlugins:b([]),totalPluginsToLoad:b(0)},_v={encryptionPluginName:b(void 0),migrate:b(!1),type:b(void 0),cookie:b(void 0),entries:b({}),trulyAnonymousTracking:b(!1)},mv={isEnabledServerSideCookies:b(!1),dataServiceUrl:b(void 0)},yv={eventsQueuePluginName:b(void 0),deliveryEnabled:b(!0)},bv={enabled:b(!1),pageLifecycle:{enabled:b(!1),pageViewId:b(void 0),pageLoadedTimestamp:b(void 0)}},Ev={capabilities:ov,consents:cv,context:gv,eventBuffer:pv,lifecycle:uv,loadOptions:iv,metrics:dv,nativeDestinations:fv,plugins:vv,reporting:av,session:nv,source:lv,storage:_v,serverCookies:mv,dataPlaneEvents:yv,autoTrack:bv},c={...q(Ev)},Iu=/^\s*at /,kv=/^(eval@)?(\[native code])?$/,Sv=/(.+?)(?::(\d+))?(?::(\d+))?$/;Pu="global code",Rv=s=>ee(s)&&/^global code$/i.test(s)?Pu:s,Iv=s=>{let e={file:s.fileName,method:Rv(s.functionName),lineNumber:s.lineNumber,columnNumber:s.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Pu),e},$l=s=>re(s)?s:"";Cu=(s,e)=>{let t;return io(s)&&re(er(s))?t=s:(e.warn(op(Hs,et(s))),t=void 0),t},Ov=(s,e)=>{try{let t=Tv(s);return Fl(s.name,s.message,e,t)}catch{return Fl(s.name,s.message,e,[])}},Ml=(s,e)=>{try{return JSON.parse(s||"")}catch(t){let i=ao(t,"Failed to parse response data");e(i)}},Vi="The request failed",Pv=[/Failed to fetch dynamically imported module: .*/],Cv=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],Dv=[new RegExp(`${Vi}.*`),/A script with the id .* is already loaded\./],Nv=[...Pv,...Cv],xv="integrations",Lv="sdk",$v=Lv,Fv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Ul=(s,e,t)=>{let i=we(Fv,e||{});return t&&(i.headers=we(i.headers,{Authorization:t})),i.url=s,i},Bl=(s,e=Df,t)=>new Promise((i,r)=>{let n;if(s.sendRawData===!0)n=s.data;else if(n=et(s.data,!1,[],t),Ve(n)){r({error:new Error(ep),undefined:void 0,options:s});return}let o=new XMLHttpRequest,a=u=>{r({error:new Error(vp(Vi,o.status,o.statusText,s.url,o.responseText)),xhr:o,options:s})},l=u=>{r({error:new Error(_p(Vi,u,s.url)),xhr:o,options:s,...u?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?i({response:o.responseText,xhr:o,options:s}):a()},o.open(s.method,s.url,!0),s.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(s.headers).forEach(u=>{s.headers[u]&&o.setRequestHeader(u,s.headers[u])});try{o.send(n)}catch(u){r({error:ao(u,mp(Vi,s.url)),xhr:o,options:s})}}),Ln=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:t,options:i,timeout:r,isRawResponse:n}=e;try{let o=await Bl(Ul(t,i,this.basicAuthHeader),r,this.logger);return{data:n?o.response:Ml(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:t,url:i,options:r,timeout:n,isRawResponse:o}=e,a=!x(t);Bl(Ul(i,r,this.basicAuthHeader),n,this.logger).then(l=>{a||t(o?l.response:Ml(l.response,this.onError),l)}).catch(l=>{a||t(void 0,l)})}onError(e,t){this.errorHandler?.onError({error:e,context:rf,groupingHash:t})}setAuthHeader(e,t=!1){let i=t?e:ef(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Du=new Ln(Et),Mv="1",Uv=()=>["rsa"],Bv=["www.test-host.com","localhost","127.0.0.1","[::1]"],Vv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],Gv="RudderStack JavaScript SDK",Hv="git+https://github.com/rudderlabs/rudder-sdk-js.git",jv="js",Nu=s=>{c.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(c.lifecycle.sourceConfigUrl.value),t=`${e.origin}${e.pathname}?view=ad`;s.getAsyncData({url:t,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(i,r)=>{c.capabilities.isAdBlockerDetectionInProgress.value=!1,c.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==t}})}catch(e){throw c.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},zv=(s,e)=>{switch(e){case vt.UNHANDLEDEXCEPTION:{let{error:t}=s;return t||s}case vt.UNHANDLEDREJECTION:return s.reason;case vt.HANDLEDEXCEPTION:default:return s}},qv=s=>({type:"manual",name:s,timestamp:new Date,metaData:{}}),Wv=(s=()=>window.location.hostname)=>{let e=s();return!e||e&&Bv.includes(e)?"development":"production"},Kv=s=>{let e=et(s,!1,Vv);return e!==null?JSON.parse(e):{}},Xv=()=>globalThis.location.href.split("?")[0],Yv=(s,e,t,i)=>({id:`${s.value?.id??t.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${i.pageLifecycle.pageViewId.value??"NA"}`,name:s.value?.name??"NA"}),Jv=(s,e)=>({locale:s.value??"NA",userAgent:e.value??"NA",time:new Date}),Qv=(s,e,t,i)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:u}=t,{app:d,locale:h,userAgent:f,timezone:g,screen:p,library:v}=r;return{payloadVersion:"5",notifier:{name:Gv,version:d.value.version,url:Hv},events:[{exceptions:[q(s)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:d.value.version,releaseStage:Wv(),type:d.value.installType},device:Jv(h,f),request:{url:Xv(),clientIp:"[NOT COLLECTED]"},breadcrumbs:q(l.breadcrumbs.value),context:s.message,groupingHash:i,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...p.value,timezone:g.value},...Kv(t)},user:Yv(a,o,n,u)}]}},Zv=(s,e,t)=>{if(Te(s.capabilities.isAdBlocked.value)){s.capabilities.isAdBlockerDetectionInProgress.value===!1&&Nu(e);let i=lt(()=>{ee(s.capabilities.isAdBlocked.value)&&(t(s.capabilities.isAdBlocked.value===!1),i())})}else t(s.capabilities.isAdBlocked.value===!1)},e_=(s,e,t)=>{let i=s.message;return new Promise(r=>{if(Nv.some(n=>n.test(i))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];re(n)?n.startsWith(ir)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):Zv(e,t,r):r(!1):r(!0)}else r(!Dv.some(n=>n.test(i)))})},xu=s=>s?s.split("/").at(-2):void 0,Lu=s=>{let e=s.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},t_=s=>{let e=Lu(s);if(!e)return!1;let t=e.substring(e.lastIndexOf("/")+1);return xu(e)===sr||Uv().some(r=>t.startsWith(r)&&t.endsWith(".js"))},s_=(s,e)=>{if(e)return e;let t=Lu(s);return xu(t)===sr?xv:$v},i_=(s,e,t)=>{let i={version:Mv,message_id:Zi(),source:{name:jv,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:t},errors:s};return et(i)},r_=(s,e,t)=>{let i;if(!ee(s))i=e;else if(re(s))i=s;else{let r=Cu(s,t);ee(r)?i=r.message:i=e}return i},$n=class{constructor(e,t){le(this,"initialized",!1);this.httpClient=e,this.logger=t}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Hs,errorType:vt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Hs,errorType:vt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let t=re(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&t.startsWith(ir)&&!c.capabilities.cspBlockedURLs.value.includes(t)&&(c.capabilities.cspBlockedURLs.value=[...c.capabilities.cspBlockedURLs.value,t])})}async onError(e){try{let{error:t,context:i,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??vt.HANDLEDEXCEPTION,l=zv(t,a),u=Cu(l,this.logger);if(Te(u))return;let d=r?`${r} - `:"",h=`${i}${V}${d}`,f=Ov(u,h),p=er(u).includes(cu);if(!p&&!t_(f)&&a!==vt.HANDLEDEXCEPTION)return;if(c.reporting.isErrorReportingEnabled.value&&await e_(f,c,this.httpClient)){let m={severity:"error",unhandled:a!==vt.HANDLEDEXCEPTION,severityReason:{type:a}},y=r_(n,f.message,this.logger),w=Qv(f,m,c,y),C=s_(f,o);this.httpClient.getAsyncData({url:c.metrics.metricsServiceUrl.value,options:{method:"POST",data:i_(w,c,C),sendRawData:!0},isRawResponse:!0})}(a===vt.HANDLEDEXCEPTION||p)&&this.logger.error(f.message)}catch(t){this.logger.error(ap(Hs),t)}}leaveBreadcrumb(e){try{c.reporting.breadcrumbs.value=[...c.reporting.breadcrumbs.value,qv(e)]}catch(t){this.onError({error:t,context:Hs,customMessage:Nl,groupingHash:Nl})}}},$u=new $n(Du,Et),Fn=class{constructor(e,t={}){le(this,"plugins",[]);le(this,"byName",{});le(this,"cache",{});le(this,"config",{throws:!0});this.config={throws:!0,...t},this.logger=e}register(e,t){if(!e.name){let r=lp(os);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=up(os,e.name);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},this.plugins=this.plugins.slice();let i=this.plugins.length;this.plugins.forEach((r,n)=>{r.deps?.includes(e.name)&&(i=Math.min(i,n))}),this.plugins.splice(i,0,e),this.byName[e.name]=e,x(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let r=cp(os,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let i=this.plugins.indexOf(t);if(i===-1){let r=dp(os,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(i,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=e??".";return this.cache[t]||(this.cache[t]=this.plugins.filter(i=>{if(i.deps?.some(r=>!this.byName[r])){let r=i.deps.filter(n=>!this.byName[n]);return this.logger.error(hp(os,i.name,r)),!1}return t==="."?!0:Kg(i,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,t=!0,...i){let r=e;if(!r)throw new Error(tp);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(sp);let a=r.split(".");a.pop();let l=a.join(".");return(t?this.getPlugins(r):[this.getPlugins(r)[0]]).map(d=>{let h=Rn(d,r);if(!x(h)||n)return h;try{return h.apply(Rn(d,l),i)}catch(f){if(o)throw f;this.logger.error(gp(os,r,d.name),f)}return null})}invokeSingle(e,...t){return this.invoke(e,!1,...t)[0]}invokeMultiple(e,...t){return this.invoke(e,!0,...t)}},n_=new Fn(Et,{throws:!0}),o_=s=>s.config.connectionMode!=="cloud"||s.config.useNativeSDKToSend===!0||s.config.useNativeSDK===!0,a_=s=>s.config.connectionMode==="hybrid"||s.config.useNativeSDKToSend===!0,Vl=s=>s.filter(o_),l_=(s,e)=>`${s.replaceAll(" ","-")}___${e}`,Fu=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],u_=["Bugsnag","ErrorReporting"],c_={rudderAnalyticsRemotePlugins:{url:()=>Promise.resolve(window.RudderStackGlobals&&window.RudderStackGlobals.app&&window.RudderStackGlobals.app.pluginsCDNPath?`${window.RudderStackGlobals.app.pluginsCDNPath}/rsa-plugins.js`:"https://cdn.rudderlabs.com/v3/modern/plugins//rsa-plugins.js"),format:"esm",from:"vite"}};d_=s=>Mu({},(globalThis.__federation_shared__||{}).default||{});g_=s=>{switch(s){case"BeaconQueue":return()=>Ue("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Me(e,!0));case"CustomConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Me(e,!0));case"DeviceModeDestinations":return()=>Ue("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Me(e,!0));case"DeviceModeTransformation":return()=>Ue("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Me(e,!0));case"ExternalAnonymousId":return()=>Ue("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Me(e,!0));case"GoogleLinker":return()=>Ue("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Me(e,!0));case"KetchConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Me(e,!0));case"IubendaConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Me(e,!0));case"NativeDestinationQueue":return()=>Ue("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Me(e,!0));case"OneTrustConsentManager":return()=>Ue("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Me(e,!0));case"StorageEncryption":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Me(e,!0));case"StorageEncryptionLegacy":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Me(e,!0));case"StorageMigrator":return()=>Ue("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Me(e,!0));case"XhrQueue":return()=>Ue("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Me(e,!0));default:return}},f_=s=>{let e={};return s.forEach(t=>{if(Fu.includes(t)){let i=g_(t);i&&(e[t]=i)}}),e},Uu=()=>({}),p_=()=>({}),v_=s=>f_?.(s)||{},kn={...Uu(),...p_()},__=s=>({...v_(s)}),Mn=class{constructor(e,t,i){this.engine=e,this.errorHandler=t,this.logger=i,this.onError=this.onError.bind(this)}init(){c.lifecycle.status.value="pluginsLoading",Ks("pluginsCDNPath",c.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){lt(()=>{(c.plugins.activePlugins.value.length===0||c.plugins.loadedPlugins.value.length+c.plugins.failedPlugins.value.length===c.plugins.totalPluginsToLoad.value)&&Ae(()=>{c.plugins.ready.value=!0,c.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=c.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>u_.includes(r)?(this.logger.warn(Hp(Bs,r)),!1):!0);let t=[{configurationStatus:()=>ee(c.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:c.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(Qp),shouldAddMissingPlugins:!0},{configurationStatus:()=>Vl(c.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Vl(c.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>ee(c.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:c.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(xn)},{configurationStatus:()=>ee(c.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:c.storage.encryptionPluginName.value,supportedPlugins:Object.values(Bi)},{configurationStatus:()=>c.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return t.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>ee(n)),this.addMissingPlugins(r,i,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(Uu()),...e]}addMissingPlugins(e,t,i){let r=e.shouldAddMissingPlugins||t,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!i.includes(a));o.length>0&&(r&&i.push(...o),this.logger.warn(jp(Bs,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(kn),...Fu],i=[],r=[];e.forEach(n=>{t.includes(n)?i.push(n):r.push(n)}),r.length>0&&this.logger.warn(Wp(Bs,r)),Ae(()=>{c.plugins.totalPluginsToLoad.value=e.length,c.plugins.activePlugins.value=i,c.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(kn).forEach(([t,i])=>{c.plugins.activePlugins.value.includes(t)&&(x(i)?this.register([i()]):e.push(t))}),e.length>0&&(c.plugins.failedPlugins.value=[...c.plugins.failedPlugins.value,...e],this.logger.error(Kp(Bs,e)))}registerRemotePlugins(){let e=__(c.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(i=>this.register([i.default()])).catch(i=>{c.plugins.failedPlugins.value=[...c.plugins.failedPlugins.value,t],this.onError(i,`Failed to load plugin "${t}"`,i)})})).catch(t=>{this.onError(t)})}invokeMultiple(e,...t){try{return this.engine.invokeMultiple(e,...t)}catch(i){return this.onError(i,e),[]}}invokeSingle(e,...t){try{return this.engine.invokeSingle(e,...t)}catch(i){return this.onError(i,e),null}}register(e){e.forEach(t=>{try{this.engine.register(t,c)}catch(i){c.plugins.failedPlugins.value=[...c.plugins.failedPlugins.value,t.name],this.onError(i,`Failed to register plugin "${t.name}"`)}})}unregisterLocalPlugins(){Object.keys(kn).forEach(e=>{try{this.engine.unregister(e)}catch(t){this.onError(t,`Failed to unregister plugin "${e}"`)}})}onError(e,t,i){this.errorHandler.onError({error:e,context:Bs,customMessage:t,groupingHash:i})}},Be="cookieStorage",je="localStorage",Ke="sessionStorage",at="memoryStorage",qt="none",m_="test_rudder_cookie",y_="test_rudder_ls",b_="test_rudder_ss",E_="rl_user_id",k_="rl_trait",S_="rl_anonymous_id",w_="rl_group_id",A_="rl_group_trait",T_="rl_page_init_referrer",R_="rl_page_init_referring_domain",I_="rl_session",O_="rl_auth_token",as={userId:E_,userTraits:k_,anonymousId:S_,groupId:w_,groupTraits:A_,initialReferrer:T_,initialReferringDomain:R_,sessionInfo:I_,authToken:O_},P_="__tld__",Bu="clientDataInCookie",Vu="clientDataInLocalStorage",C_="clientDataInMemory",Gu="clientDataInSessionStorage",Hu=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ls={[Be]:Bu,[je]:Vu,[at]:C_,[Ke]:Gu},Gl=(s,e)=>{try{return encodeURIComponent(s)}catch(t){e?.error(mf,t);return}},Hl=s=>{try{return decodeURIComponent(s)}catch{return}},D_=s=>{let e={},t=s.split(/\s*;\s*/),i;return t[0]&&t.forEach(r=>{i=r.split("=");let n=i[0]?Hl(i[0]):void 0;n&&(e[n]=i[1]?Hl(i[1]):void 0)}),e},N_=(s,e,t,i)=>{let r={...t||{}},n=`${Gl(s,i)}=${Gl(e,i)}`;Ve(e)&&(r.maxage=-1),r.maxage&&(r.expires=new Date(+new Date+r.maxage)),r.path&&(n+=`; path=${r.path}`),r.domain&&(n+=`; domain=${r.domain}`),r.expires&&(n+=`; expires=${r.expires.toUTCString()}`),r.samesite&&(n+=`; samesite=${r.samesite}`),r.secure&&(n+="; secure"),globalThis.document.cookie=n},Un=()=>{let s=globalThis.document.cookie;return D_(s)},x_=s=>Un()[s],_t=function(s,e,t,i){switch(arguments.length){case 4:case 3:case 2:return N_(s,e,t,i);case 1:return s?x_(s):Un();default:return Un()}},L_=s=>{let e=document.createElement("a");return e.href=s,e.hostname},$_=s=>{let t=(typeof globalThis.URL!="function"?L_(s):new URL(s).hostname)?.split(".")??[],i=t[t.length-1],r=[];if(t.length===4&&i&&i===parseInt(i,10).toString())return r;if(t.length<=1)return t[0]&&t[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=t.length-2;n>=0;n-=1)r.push(t.slice(n).join("."));return r},F_=s=>{let e=$_(s);for(let t=0;t<e.length;t+=1){let i=e[t],r=P_,n={domain:`${i.indexOf("localhost")!==-1?"":"."}${i}`};try{if(_t(r,1,n),_t(r))return _t(r,null,n),i}catch{try{_t(r,null,n)}catch{}}}return""},M_=()=>{let s=`.${F_(globalThis.location.href)}`;return{maxage:Nf,path:"/",domain:!s||s==="."?void 0:s,samesite:"Lax",enabled:!0}},U_=()=>({enabled:!0}),B_=()=>({enabled:!0}),V_=()=>({enabled:!0}),Bn=class{constructor(e){le(this,"isEnabled",!0);le(this,"length",0);le(this,"data",{});this.options=V_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,t){return this.data[e]=t,this.length=Object.keys(this.data).length,t}getItem(e){return e in this.data?this.data[e]:null}removeItem(e){return e in this.data&&delete this.data[e],this.length=Object.keys(this.data).length,null}clear(){this.data={},this.length=0}key(e){return this.keys()[e]??null}keys(){return Object.keys(this.data)}},Ji=new Bn(Et);Gi={exports:{}},H_=Gi.exports;z_=j_(),Vt=G_(z_),ju=s=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],t=[22,1014];return s instanceof DOMException?e.includes(s.name)||t.includes(s.code):!1},us=(s=je,e,t)=>{let i,r,n=yf(In,s),o="unavailable",a=!0,l;try{switch(s){case at:return!0;case Be:i=e,r=m_;break;case je:i=e??globalThis.localStorage,r=y_;break;case Ke:i=e??globalThis.sessionStorage,r=b_;break;default:return!1}if(i&&(i.setItem(r,"true"),i.getItem(r)))return i.removeItem(r),!0;a=!1}catch(u){a=!1,l=u,ju(u)&&(o="full")}return a||t?.warn(`${n}${o}.`,l),!1},Vn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.options=U_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isSupportAvailable=us(je),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){Vt.set(e,t),this.length=Vt.len()}getItem(e){let t=Vt.get(e);return Te(t)?null:t}removeItem(e){Vt.remove(e),this.length=Vt.len()}clear(){Vt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Vt.keys()}},co=new Vn(Et),Gn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.options=B_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isSupportAvailable=us(Ke),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){this.store&&(this.store.setItem(e,t),this.length=this.store.length)}getItem(e){if(!this.store)return null;let t=this.store.getItem(e);return Te(t)?null:t}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){this.store?.clear(),this.length=0}key(e){return this.store?.key(e)??null}keys(){let e=[];if(!this.store)return e;for(let t=0;t<this.store.length;t+=1){let i=this.store.key(t);i!==null&&e.push(i)}return e}},ho=new Gn(Et),Hn=class{constructor(e){le(this,"isSupportAvailable",!0);le(this,"isEnabled",!0);le(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=M_()),this.options=we(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=us(Be,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){return _t(e,t,this.options,this.logger),this.length=Object.keys(_t()).length,!0}getItem(e){let t=_t(e);return Te(t)?null:t}removeItem(e){let t=this.setItem(e,null);return this.length=Object.keys(_t()).length,t}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(_t())}},go=new Hn(Et),Ze=s=>{switch(s){case je:return co;case Ke:return ho;case at:return Ji;case Be:return go;default:return Ji}},q_=s=>{let e=go.configure(s);c.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},W_=s=>{co.configure(s)},K_=s=>{Ji.configure(s)},X_=s=>{ho.configure(s)},Y_=(s={},e={},t={},i={})=>{q_(s),W_(e),K_(t),X_(i)},jn=class{constructor(e,t,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=t,this.noKeyValidation=Object.keys(this.validKeys).length===0,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=i}createValidKey(e){let{name:t,id:i,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[t,i,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[t,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:i,noCompoundKey:r}=this,n=Ze(at);Object.keys(i).forEach(o=>{let a=this.get(i[o]),l=r?o:[e,t,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,t){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(et(t,!1,[],this.logger)))}catch(r){if(ju(r))this.logger.warn($p(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,t);else{let n=yp(e);this.onError(r,n,n)}}}get(e){let t=this.createValidKey(e),i;try{return!t||(i=this.decrypt(this.engine.getItem(t)),tt(i)||i==="")?null:JSON.parse(i)}catch(r){let n=c.storage.encryptionPluginName.value;if(!n||!c.plugins.failedPlugins.value.includes(n)){let a=bp(e);this.onError(r,a,a)}return null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return tt(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||typeof e!="string"||Qg(e)==="")return e;let r=`storage.${t}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,t,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:t,groupingHash:i})}},J_=(s,e)=>{let t;if(s.consents.preConsent.value.enabled)switch(s.consents.preConsent.value.storage?.strategy){case"none":t=qt;break;case"session":e!=="sessionInfo"&&(t=qt);break;case"anonymousId":e!=="anonymousId"&&(t=qt);break}return t},zn=class{constructor(e,t,i){le(this,"stores",{});le(this,"isInitialized",!1);this.errorHandler=t,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=c.loadOptions.value,t={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};Y_(Gs(we(t.cookieStorageOptions??{},c.storage.cookie?.value??{})),Gs(t.localStorageOptions),Gs(t.inMemoryStorageOptions),Gs(t.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[at,je,Be,Ke].forEach(t=>{Ze(t)?.isEnabled&&this.setStore({id:ls[t],name:ls[t],isEncrypted:!0,noCompoundKey:!0,type:t,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=c.storage.type.value,t=c.loadOptions.value.storage?.entries,i=c.consents.postConsent.value.storage;(ee(i?.type)||ee(i?.entries))&&(e=i?.type,t=i?.entries);let r=!0,n={};Hu.forEach(o=>{let a=o,l=o,u=t?.[a]?.type,h=J_(c,o)??u??e??Nn,f=this.getResolvedStorageTypeForEntry(h,o);f!==qt&&(r=!1),n={...n,[o]:{type:f,key:as[l]}}}),Ae(()=>{c.storage.type.value=e,c.storage.entries.value=n,c.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){let i=e;switch(e){case je:Ze(je)?.isEnabled||(i=at);break;case Ke:Ze(Ke)?.isEnabled||(i=at);break;case at:case qt:break;case Be:default:Ze(Be)?.isEnabled?i=Be:Ze(je)?.isEnabled?i=je:Ze(Ke)?.isEnabled?i=Ke:i=at;break}return i!==e&&this.logger.warn(Fp(tf,t,e,i)),i}setStore(e){let t=Ze(e.type);return this.stores[e.id]=new jn(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},Q_=s=>ne(s)&&ne(s.source)&&!tt(s.source.id)&&ne(s.source.config)&&Array.isArray(s.source.destinations),Z_=s=>typeof s=="string"&&Eu.includes(s),zu=s=>{let e=new URL(s),{host:t,protocol:i}=e,r=t.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=t,{topDomain:n,protocol:i}},em=s=>{let{topDomain:e,protocol:t}=zu(s);return`${t}//${e}`},tm=(s,e)=>{let t=e?window.location.origin:em(window.location.href),i=s.startsWith("/")?s.substring(1):s;return`${t}/${i}`},sm=s=>{let{topDomain:e}=zu(window.location.href);return e===s},ds=s=>s?.endsWith("/")?ds(s.substring(0,s.length-1)):s,qn=s=>{try{return new URL(s).host}catch{return null}},qu=s=>qn(s)??"",im=s=>{let e={};try{let t=new URL(s),i="utm_";t.searchParams.forEach((r,n)=>{if(n.startsWith(i)){let o=n.substring(i.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},rm=s=>{let e=s;try{let t=new URL(s);e=t.origin+t.pathname+t.search}catch{}return e},nm=s=>s.replace(/\/{2,}/g,"/"),hs=s=>{if(!re(s))return!1;try{return x(globalThis.URL)&&new URL(s),Yp.test(s)}catch{return!1}},Sn="none",wn="immediate",om=s=>s?.statsCollection?.errors?.enabled===!0,am=s=>s?.statsCollection?.metrics?.enabled===!0,lm=s=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ne(s)){let t=q(s);e.storage=t.storage,bt(t.integrations)&&(e.integrations=t.integrations),e.discardPreConsentEvents=t.discardPreConsentEvents===!0,e.sendPageEvent=t.sendPageEvent===!0,e.trackConsent=t.trackConsent===!0,bt(t.consentManagement)&&(e.consentManagement=we(t.consentManagement,{enabled:c.consents.enabled.value}))}return e},zl=s=>bt(s)||Array.isArray(s),um=(s,e)=>{let{provider:t}=s,i=t?xn[t]:void 0;return t&&!i&&(e.error(np(Xe,t,xn)),t=void 0),{provider:t,consentManagerPluginName:i}},Wu=(s,e)=>{let t,i=[],r=[],n=!1,o,a=s?.enabled===!0;bt(s)&&a&&({provider:o,consentManagerPluginName:t}=um(s,e),zl(s.allowedConsentIds)&&(i=s.allowedConsentIds,n=!0),zl(s.deniedConsentIds)&&(r=s.deniedConsentIds,n=!0));let l={allowedConsentIds:i,deniedConsentIds:r};return a=a&&!!t,{provider:o,consentManagerPluginName:t,initialized:n,enabled:a,consentsData:l}},cm=()=>{let s=document.querySelector("script[data-rsa-write-key]");if(s&&s.dataset.rsaWriteKey===c.lifecycle.writeKey.value)return s.src;let e=document.getElementsByTagName("script"),t=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let r=i.getAttribute("src");if(r&&t.test(r))return r}},dm=s=>{c.reporting.isErrorReportingEnabled.value=om(s.source.config)&&!cf(),c.reporting.isMetricsReportingEnabled.value=am(s.source.config)},hm=s=>{let{useServerSideCookies:e,dataServiceEndpoint:t,storage:i,setCookieDomain:r,sameDomainCookiesOnly:n}=c.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let u=o.domain??r,d=ee(u)&&!sm(El(u))||n,h=tm(t??Zp,d);if(hs(h)){l=ds(h);let f=qn(window.location.href),g=qn(h);f!==g&&(o={...o,samesite:"None",secure:!0}),!n&&d&&g!==El(u)&&(a=!1,s.warn(Tp(Xe,u,g)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},gm=s=>{let{storage:e}=c.loadOptions.value,t=e?.type;ee(t)&&!Z_(t)&&(s.warn(Sp(Xe,t,Nn)),t=Nn);let i=e?.encryption?.version,r=i&&Bi[i];!Te(i)&&Te(r)?(s.warn(wp(Xe,i,Bi,Ht)),i=Ht):Te(i)&&(i=Ht);let n=e?.migrate,o=n&&i===Ht;n===!0&&o!==n&&s.warn(Ap(Xe,i,Ht));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=hm(s);Ae(()=>{c.storage.type.value=t,c.storage.cookie.value=u,c.serverCookies.isEnabledServerSideCookies.value=a,c.serverCookies.dataServiceUrl.value=l,c.storage.encryptionPluginName.value=Bi[i],c.storage.migrate.value=o})},fm=s=>{let{provider:e,consentManagerPluginName:t,initialized:i,enabled:r,consentsData:n}=Wu(c.loadOptions.value.consentManagement,s),o=c.loadOptions.value.preConsent,a=o?.storage?.strategy??Sn,l=["none","session","anonymousId"];ee(a)&&!l.includes(a)&&(a=Sn,s.warn(Vp(Xe,o?.storage?.strategy,Sn)));let u=o?.events?.delivery??wn,d=["immediate","buffer"];ee(u)&&!d.includes(u)&&(u=wn,s.warn(Gp(Xe,o?.events?.delivery,wn))),Ae(()=>{c.consents.activeConsentManagerPluginName.value=t,c.consents.initialized.value=i,c.consents.enabled.value=r,c.consents.data.value=n,c.consents.provider.value=e,c.consents.preConsent.value={enabled:c.loadOptions.value.preConsent?.enabled===!0&&i===!1&&r===!0,storage:{strategy:a},events:{delivery:u}}})},pm=s=>{let e=c.consents.resolutionStrategy.value,t;ne(s.consentManagementMetadata)&&(c.consents.provider.value&&(e=s.consentManagementMetadata.providers.find(i=>i.provider===c.consents.provider.value)?.resolutionStrategy??c.consents.resolutionStrategy.value),t=s.consentManagementMetadata),c.consents.provider.value==="custom"&&(e=void 0),Ae(()=>{c.consents.metadata.value=q(t),c.consents.resolutionStrategy.value=e})},vm=s=>{if(c.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",t=e;c.loadOptions.value.useBeacon&&(c.capabilities.isBeaconAvailable.value?t="BeaconQueue":(t=e,s.warn(Op(Xe)))),Ae(()=>{c.dataPlaneEvents.eventsQueuePluginName.value=t})}},_m=(s,e,t,i,r)=>{let n=new URLSearchParams({p:du,v:Ws,build:Xs,writeKey:e,lockIntegrationsVersion:t.toString(),lockPluginsVersion:i.toString()}),o=Ru,a=n,l="/sourceConfig/",u="";if(hs(s)){let d=new URL(s);ds(d.pathname).endsWith("/sourceConfig")||(d.pathname=`${ds(d.pathname)}/sourceConfig/`),d.pathname=nm(d.pathname),n.forEach((h,f)=>{d.searchParams.get(f)===null&&d.searchParams.set(f,h)}),o=d.origin,l=d.pathname,a=d.searchParams,u=d.hash}else r.warn(Up(Xe,s));return`${o}${l}?${a}${u}`},mm=s=>s.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:l_(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===tv})),Ku=(s,e,t,i,r,n,o)=>{let a;if(n){if(!hs(n))return o.error(rp(Xe,s,n)),null;a=ds(n)}else if(a=t,c.context.app.value.installType==="cdn"){let l=cm();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${uo}/${Xs}/${e}$`),`/${i}/${Xs}/${e}`)),a},ym=(s,e,t,i)=>Ku("integrations",sr,Au,s,e,t,i),bm=(s,e,t,i)=>Ku("plugins",wu,Tu,s,e,t,i),Wn=class{constructor(e,t,i){this.errorHandler=t,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){lt(()=>{this.logger.setMinLogLevel(c.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:t,lockIntegrationsVersion:i,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=c.loadOptions.value,l=ym(Ws,i,n,this.logger);if(Ve(l))return;let u;u=bm(Ws,r,o,this.logger),u!==null&&(this.attachEffects(),c.lifecycle.activeDataplaneUrl.value=ds(c.lifecycle.dataPlaneUrl.value),gm(this.logger),fm(this.logger),vm(this.logger),Ae(()=>{c.lifecycle.integrationsCDNPath.value=l,c.lifecycle.pluginsCDNPath.value=u,e&&(c.lifecycle.logLevel.value=e),c.lifecycle.sourceConfigUrl.value=_m(t,c.lifecycle.writeKey.value,i,r,this.logger),c.metrics.metricsServiceUrl.value=`${c.lifecycle.activeDataplaneUrl.value}/${ev}`,c.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,t,i){this.errorHandler.onError({error:e,context:Xe,customMessage:t,groupingHash:i})}processConfig(e,t){if(!ee(e)){ee(t)?this.onError(t.error,xl):this.onError(new Error(xl));return}let i;try{re(e)?i=JSON.parse(e):i=e}catch(n){this.onError(n,Dl);return}if(!Q_(i)){this.onError(new Error(Dl));return}if(i.source.enabled===!1){this.logger.error(Zf);return}dm(i);let r=i.source.destinations.length>0?mm(i.source.destinations):[];Ae(()=>{c.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},c.nativeDestinations.configuredDestinations.value=r,c.plugins.pluginsToLoadFromConfig.value=c.loadOptions.value.plugins??[],pm(i),c.lifecycle.status.value="configured"})}getConfig(){let e=c.loadOptions.value.getSourceConfig;if(e){if(!x(e)){this.logger.error(ip(Xe));return}let t=e();t instanceof Promise?t.then(i=>this.processConfig(i)).catch(i=>{this.onError(i,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:c.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},Em=()=>{let s=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return s?.[1]?s[1]:"NA"},Xu=(s=()=>document)=>s()?.referrer||"$direct",km=(s=()=>document)=>{let t=s().getElementsByTagName("link"),i="";for(let r=0;t[r];r+=1){let n=t[r];if(n.getAttribute("rel")==="canonical"&&!i){i=n.getAttribute("href")??"";break}}return i},Sm=(s=()=>globalThis.navigator)=>{let e=s();if(Te(e))return null;let{userAgent:t}=e,{brave:i}=e;if(i&&Object.getPrototypeOf(i).isBrave){let r=t.match(/(chrome)\/([\w.]+)/i);r&&(t=`${t} Brave/${r[2]}`)}return t},wm=(s=()=>globalThis.navigator)=>{let e=s();return Te(e)?null:e.language??e.browserLanguage},Yu=(s=()=>globalThis.location,e=()=>document)=>{let t=s(),i=km(e),r=t.pathname,{href:n}=t,o=n,{search:a}=t;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,r=h.pathname}catch{}let l=rm(o),{title:u}=e(),d=Xu(e);return{path:r,referrer:d,referring_domain:qu(d),search:a,title:u,url:l,tab_url:n}},Am=(s,e="none")=>{e==="none"&&s(void 0),e==="default"&&s(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(t=>{s(t)}).catch(()=>{s()})},Tm=()=>{let s=globalThis.document.createElement("div");return s.setAttribute("data-a-b","c"),s.dataset?s.dataset.aB==="c":!1},Kn={URL:()=>!x(globalThis.URL)||!x(globalThis.URLSearchParams),Promise:()=>!x(globalThis.Promise),"Number.isNaN":()=>!x(globalThis.Number.isNaN),"Number.isInteger":()=>!x(globalThis.Number.isInteger),"Array.from":()=>!x(globalThis.Array.from),"Array.prototype.find":()=>!x(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!x(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!x(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!x(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!x(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!x(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!x(globalThis.String.fromCodePoint),"Object.entries":()=>!x(globalThis.Object.entries),"Object.values":()=>!x(globalThis.Object.values),"Object.assign":()=>!x(globalThis.Object.assign),"Object.fromEntries":()=>!x(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!Tm(),TextEncoder:()=>!x(globalThis.TextEncoder)||!x(globalThis.TextDecoder),requestAnimationFrame:()=>!x(globalThis.requestAnimationFrame)||!x(globalThis.cancelAnimationFrame),CustomEvent:()=>!x(globalThis.CustomEvent),"navigator.sendBeacon":()=>!x(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!x(globalThis.Uint8Array),Set:()=>!x(globalThis.Set),atob:()=>!x(globalThis.atob)},Rm=()=>{let s=Object.keys(Kn),e=!1;for(let t=0;t<s.length;t++){let i=Kn[s[t]];if(x(i)&&i()){e=!0;break}}return e},Im="https://polyfill-fastly.io/v3/polyfill.min.js",Om=`${Im}?version=3.111.0&features=${Object.keys(Kn).join("%2C")}`,Pm=10*1e3,ql="rudderstackPolyfill",Cm=()=>!tt(globalThis.crypto)&&x(globalThis.crypto.getRandomValues),Wl=()=>!tt(globalThis.navigator.userAgentData),Dm=()=>!tt(globalThis.navigator.sendBeacon)&&x(globalThis.navigator.sendBeacon),Kl=()=>{let s={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return s={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},s},Xn=class{constructor(e,t,i){this.httpClient=e,this.errorHandler=t,this.logger=i,this.externalSrcLoader=new Wi(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ae(()=>{c.capabilities.storage.isCookieStorageAvailable.value=us(Be,Ze(Be),this.logger),c.capabilities.storage.isLocalStorageAvailable.value=us(je,void 0,this.logger),c.capabilities.storage.isSessionStorageAvailable.value=us(Ke,void 0,this.logger),c.capabilities.isBeaconAvailable.value=Dm(),c.capabilities.isUaCHAvailable.value=Wl(),c.capabilities.isCryptoAvailable.value=Cm(),c.capabilities.isOnline.value=globalThis.navigator.onLine,c.context.userAgent.value=Sm(),c.context.locale.value=wm(),c.context.screen.value=Kl(),c.context.timezone.value=Em(),Wl()&&Am(e=>{c.context["ua-ch"].value=e},c.loadOptions.value.uaChTrackLevel)}),lt(()=>{c.loadOptions.value.sendAdblockPage===!0&&c.lifecycle.sourceConfigUrl.value!==void 0&&Nu(this.httpClient)})}prepareBrowserCapabilities(){c.capabilities.isLegacyDOM.value=Rm();let e=c.loadOptions.value.polyfillURL,t=Om;if(cs(e)&&(hs(e)?t=e:this.logger.warn(zp(In,e))),c.loadOptions.value.polyfillIfRequired&&c.capabilities.isLegacyDOM.value&&hs(t)){let r=t!==c.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${c.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,t=`${t}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:t,id:ql,async:!0,timeout:Pm,callback:n=>{n?r||this.onReady():this.onError(new Error(Bp(ql,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{c.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{c.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",$f(()=>{c.context.screen.value=Kl()},this))}onReady(){this.detectBrowserCapabilities(),c.lifecycle.status.value="browserCapabilitiesReady"}onError(e,t){this.errorHandler.onError({error:e,context:In,groupingHash:t})}},Nm="web",xm=["integrations","anonymousId","originalTimestamp"],Xl=["library","consentManagement","userAgent","ua-ch","screen"],An=["id","anonymous_id","user_id","sent_at","timestamp","received_at","original_timestamp","event","event_text","channel","context_ip","context_request_ip","context_passed_ip","group_id","previous_id"],Ju=s=>typeof s=="number"&&!Number.isNaN(s),Lm=(s,e)=>e.toString().length>=s,Qi=s=>Ju(s)&&s>=0&&Number.isInteger(s),Yl=10,Qu=s=>{let{cutOff:e}=s,t=Date.now();return!!(e?.enabled&&e.expiresAt&&t>e.expiresAt)},Jl=s=>!s.expiresAt||Date.now()>s.expiresAt||Qu(s),$m=()=>Date.now(),Fm=(s,e)=>!s||!Qi(s)||!Lm(Yl,s)?(e.warn(Lp(Gt,s,Yl)),!1):!0,Mm=s=>{if(s?.enabled)return s.expiresAt??(Qi(s.duration)?Date.now()+s.duration:void 0)},Um=s=>{let{timeout:e,cutOff:t}=s,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...t&&{cutOff:t}}},Bm=(s,e)=>({id:Fm(s,e)?s:$m(),sessionStart:void 0,manualTrack:!0}),js=s=>s===Be||s===je||s===Ke||s===at,Yn=()=>Zi(),Vm=s=>{if(Wg(s)){let{entries:e,...t}=En;return{...t,entries:{...e,anonymousId:s}}}return ne(s)&&ne(s.entries)?we(En,s):{...En}},Gm=s=>{let e=Yu(),t={};return Object.keys(e).forEach(i=>{t[i]=s?.[i]||e[i]}),t.initial_referrer=s?.initial_referrer||c.session.initialReferrer.value,t.initial_referring_domain=s?.initial_referring_domain||c.session.initialReferringDomain.value,t},Hm=(s,e)=>{let t=e?.page||{},i=s,r=Yu();return Object.keys(r).forEach(n=>{Te(i[n])&&(i[n]=t[n]||r[n])}),Te(i.initial_referrer)&&(i.initial_referrer=t.initial_referrer||c.session.initialReferrer.value),Te(i.initial_referring_domain)&&(i.initial_referring_domain=t.initial_referring_domain||c.session.initialReferringDomain.value),i},Tn=(s,e,t)=>{ne(s)&&Object.keys(s).forEach(i=>{(An.includes(i)||An.includes(i.toLowerCase()))&&t.warn(Rp(ou,i,e,An))})},jm=(s,e)=>{let{properties:t,traits:i,context:r}=s,{traits:n}=r;Tn(t,"properties",e),Tn(i,"traits",e),Tn(n,"context.traits",e)},zm=(s,e)=>{e.anonymousId&&re(e.anonymousId)&&(s.anonymousId=e.anonymousId),bt(e.integrations)&&(s.integrations=e.integrations),e.originalTimestamp&&re(e.originalTimestamp)&&(s.originalTimestamp=e.originalTimestamp)},qm=(s,e,t)=>{let i=s;return Object.keys(e).forEach(r=>{if(!xm.includes(r)&&!Xl.includes(r))if(r!=="context")i=we(i,{[r]:e[r]});else if(!Te(e[r])&&ne(e[r])){let n={};Object.keys(e[r]).forEach(o=>{Xl.includes(o)||(n[o]=e[r][o])}),i=we(i,{...n})}else t.warn(Ip(ou))}),i},Wm=(s,e,t)=>{ne(e)&&(zm(s,e),s.context=qm(s.context,e,t))},Km=s=>{let e;return c.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=c.consents.postConsent.value.integrations??c.nativeDestinations.loadOnlyIntegrations.value:s?e=s:e=Su,q(e)},Vs=(s,e,t,i)=>{let r={channel:Nm,context:{traits:q(c.session.userTraits.value),sessionId:c.session.sessionInfo.value.id||void 0,sessionStart:c.session.sessionInfo.value.sessionStart||void 0,...c.consents.enabled.value&&{consentManagement:{deniedConsentIds:q(c.consents.data.value.deniedConsentIds),allowedConsentIds:q(c.consents.data.value.allowedConsentIds),provider:c.consents.provider.value,resolutionStrategy:c.consents.resolutionStrategy.value}},"ua-ch":c.context["ua-ch"].value,app:c.context.app.value,library:c.context.library.value,userAgent:c.context.userAgent.value,os:c.context.os.value,locale:c.context.locale.value,screen:c.context.screen.value,campaign:im(globalThis.location.href),page:Gm(t),timezone:c.context.timezone.value,...c.autoTrack.enabled.value&&{autoTrack:{...c.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:c.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:gf(),messageId:Zi(),userId:s.userId||c.session.userId.value};js(c.storage.entries.value.anonymousId?.type)?r.anonymousId=c.session.anonymousId.value:r.anonymousId=Yn(),c.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),s.type==="identify"&&(r.context.traits=c.storage.entries.value.userTraits?.type!==qt?q(c.session.userTraits.value):s.context.traits),s.type==="group"&&((s.groupId||c.session.groupId.value)&&(r.groupId=s.groupId||c.session.groupId.value),(s.traits||c.session.groupTraits.value)&&(r.traits=c.storage.entries.value.groupTraits?.type!==qt?q(c.session.groupTraits.value):s.traits));let n=we(s,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),Wm(n,e,i),jm(n,i),n.integrations=Km(n.integrations),n},Jn=class{constructor(e){this.logger=e}generatePageEvent(e,t,i,r){let n=i??{};return n=Hm(n,r),Vs({properties:n,name:t,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,t,i){return Vs({properties:t,event:e,type:"track"},i,void 0,this.logger)}generateIdentifyEvent(e,t,i){return Vs({userId:e,type:"identify",context:{traits:t}},i,void 0,this.logger)}generateAliasEvent(e,t,i){let n=Vs({previousId:t,type:"alias"},i,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,t,i){let r={type:"group"};return e&&(r.groupId=e),t&&(r.traits=t),Vs(r,i,void 0,this.logger)}create(e){let t;switch(e.type){case"page":t=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":t=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":t=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":t=this.generateAliasEvent(e.to,e.from,e.options);break;default:t=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return t}},Qn=class{constructor(e,t,i,r){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=i,this.logger=r,this.eventFactory=new Jn(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let t=this.eventFactory.create(e);this.eventRepository.enqueue(t,e.callback)}},Zn=class{constructor(e,t,i,r,n){this.storeManager=t,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=i,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={},this.serverSideCookiesRequestInProgress={}}init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:e,anonymousIdOptions:t}=c.loadOptions.value,i;cs(e)&&typeof e=="string"&&(i=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(i??this.getAnonymousId(t)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??Q.sessionInfo;e={autoTrack:t.autoTrack&&i.manualTrack!==!0,timeout:t.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=Q.sessionInfo:t.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:t.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=Q.sessionInfo;c.session.sessionInfo.value=e,c.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(c.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{let i=e||Xu();this.setInitialReferrer(i),this.setInitialReferringDomain(qu(i))}}isPersistenceEnabledForStorageEntry(e){return js(c.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=c.storage.entries.value,t=[Be,je,Ke];Object.keys(e).forEach(i=>{let r=i,n=e[r]?.type,o=this.storeManager?.getStore(ls[n]);o&&t.forEach(a=>{let l=this.storeManager?.getStore(ls[a]);if(l&&a!==n){let u=l.get(as[r]);qg(u)&&o.set(as[r],u),l.remove(as[r])}})})}migrateStorageIfNeeded(e,t){if(!c.storage.migrate.value)return;let i=e??[];i.length===0&&[Bu,Vu,Gu].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(t??Object.keys(as)).forEach(n=>{let o=as[n];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);tt(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=c.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let t,i=c.loadOptions.value.sessions?.timeout;Qi(i)?t=i:(this.logger.warn(Pp(Gt,i,On)),t=On),t===0&&(this.logger.warn(Np(Gt)),e=!1),t>0&&t<Ol&&this.logger.warn(xp(Gt,t,Ol));let r=this.getCutOffInfo(t);return{timeout:t,autoTrack:e,cutOff:r}}getCutOffInfo(e){let t=c.loadOptions.value.sessions.cutOff,i,r=!1;return t.enabled===!0&&(i=t.duration,r=!0,Qi(i)?i<e&&(this.logger.warn(Dp(Gt,i,e)),r=!1):(this.logger.warn(Cp(Gt,i,Il)),i=Il)),{enabled:r,duration:i}}onError(e,t,i){this.errorHandler.onError({error:e,context:Gt,customMessage:t,groupingHash:i})}getEncryptedCookieData(e,t){let i=[];return e.forEach(r=>{let n=t?.encrypt(et(r.value,!1,[],this.logger));cs(n)&&i.push({name:r.name,value:n})}),i}makeRequestToSetCookie(e,t){this.httpClient?.getAsyncData({url:c.serverCookies.dataServiceUrl.value,options:{method:"POST",data:et({reqType:"setCookies",workspaceId:c.source.value?.workspaceId,data:{options:{maxAge:c.storage.cookie.value?.maxage,path:c.storage.cookie.value?.path,domain:c.storage.cookie.value?.domain,sameSite:c.storage.cookie.value?.samesite,secure:c.storage.cookie.value?.secure,expires:c.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:t})}setServerSideCookies(e,t,i){let r=Object.keys(e),n=()=>r.map(u=>({name:e[u].name,value:c.session[u].value})),o={};r.forEach(u=>{o[e[u].name]=i?.get(e[u].name)});let a=()=>{r.forEach(u=>{this.serverSideCookiesRequestInProgress[u]=!1})},l=()=>{n().forEach(u=>{t&&t(u.name,u.value)})};try{let u={};r.forEach(h=>{u[e[h].name]=c.session[h].value});let d=this.getEncryptedCookieData(n(),i);d.length>0?this.makeRequestToSetCookie(d,(h,f)=>{a(),f?.xhr?.status===200?n().forEach(g=>{let p=o[g.name],v=i?.get(g.name);et(u[g.name],!1,[])!==et(v,!1,[])&&(Ve(p)&&Ve(v)&&this.logger.error(kp(g.name)),t&&t(g.name,g.value))}):(this.logger.error(Ep(f?.xhr?.status)),l())}):(l(),a())}catch(u){this.onError(u,Ll,Ll),l(),a()}}syncValueToStorage(e){let t=c.storage.entries.value,i=t[e]?.type;if(js(i)){let r=this.storeManager.getStore(ls[i]),n=t[e]?.key,o=c.session[e].value;o&&(re(o)||bt(o))?c.serverCookies.isEnabledServerSideCookies.value&&i===Be?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{let a={[e]:{name:n}};this.setServerSideCookies(a,(l,u)=>{r?.set(l,u)},r)},rv)):r?.set(n,o):r?.remove(n)}}registerEffects(){Hu.forEach(e=>{lt(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,t){let i=e;(!re(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&t&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",t)),i=i||Yn()):i=Q.anonymousId,c.session.anonymousId.value=i}getAnonymousId(e){let t=c.storage.entries.value.anonymousId?.type;if(js(t)){let i=c.session.anonymousId.value;(!i||i===Q.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",Ze,e)),c.session.anonymousId.value=i||Yn()}return c.session.anonymousId.value}getEntryValue(e){let t=c.storage.entries.value,i=t[e]?.type;if(js(i)){let r=this.storeManager?.getStore(ls[i]);this.migrateStorageIfNeeded([r],[e]);let n=t[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let t=Ze(Be);return t?.isEnabled?t.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?c.session[e].value:this.getEntryValue(e)}getUserId(){return this.getUserSessionValue("userId")}getUserTraits(){return this.getUserSessionValue("userTraits")}getGroupId(){return this.getUserSessionValue("groupId")}getGroupTraits(){return this.getUserSessionValue("groupTraits")}getInitialReferrer(){return this.getUserSessionValue("initialReferrer")}getInitialReferringDomain(){return this.getUserSessionValue("initialReferringDomain")}getSessionInfo(){return this.getUserSessionValue("sessionInfo")}getAuthToken(){return this.getUserSessionValue("authToken")}getSessionId(){let e=this.getSessionInfo()??Q.sessionInfo;return e.autoTrack&&!Jl(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??Q.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=c.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),c.session.sessionInfo.value=e,c.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=c.session,{manualTrack:t,autoTrack:i,timeout:r,cutOff:n}=e.sessionInfo.value;if(i){let o={...Q.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else t&&this.startManualTrackingInternal()}reset(e){let{session:t}=c,i=Vm(e);Ae(()=>{Object.keys(Q).forEach(r=>{let n=r;if(i.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:t[n].value=Q[n];break}})})}setUserId(e){c.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:Q.userId}setUserTraits(e){c.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ne(e)?we(c.session.userTraits.value??Q.userTraits,e):Q.userTraits}setGroupId(e){c.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:Q.groupId}setGroupTraits(e){c.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ne(e)?we(c.session.groupTraits.value??Q.groupTraits,e):Q.groupTraits}setInitialReferrer(e){c.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:Q.initialReferrer}setInitialReferringDomain(e){c.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:Q.initialReferringDomain}startOrRenewAutoTracking(e){let t=e;if(Jl(e))t=Um(e);else{let i=Date.now(),r=e.timeout;t.expiresAt=i+r}if(Qu(t)&&(t.cutOff.expiresAt=void 0),t.cutOff){let i=Mm(t.cutOff);t.cutOff.expiresAt=i}c.session.sessionInfo.value=t}start(e){c.session.sessionInfo.value=Bm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){c.session.sessionInfo.value=Q.sessionInfo}setAuthToken(e){c.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:Q.authToken}},Xm=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],Ym=Xm,Jm=(s,e)=>{let t=q(e);return re(t.setCookieDomain)||(t.setCookieDomain=void 0),["Strict","Lax","None"].includes(t.sameSiteCookie)||(t.sameSiteCookie=void 0),t.secureCookie=ot(t.secureCookie,s.secureCookie),t.sameDomainCookiesOnly=ot(t.sameDomainCookiesOnly,s.sameDomainCookiesOnly),["none","default","full"].includes(t.uaChTrackLevel)||(t.uaChTrackLevel=void 0),t.integrations=pt(t.integrations),Array.isArray(t.plugins)||(t.plugins=Ym),t.useGlobalIntegrationsConfigInEvents=ot(t.useGlobalIntegrationsConfigInEvents,s.useGlobalIntegrationsConfigInEvents),t.bufferDataPlaneEventsUntilReady=ot(t.bufferDataPlaneEventsUntilReady,s.bufferDataPlaneEventsUntilReady),t.sendAdblockPage=ot(t.sendAdblockPage,s.sendAdblockPage),t.useServerSideCookies=ot(t.useServerSideCookies,s.useServerSideCookies),re(t.dataServiceEndpoint)||(t.dataServiceEndpoint=void 0),t.sendAdblockPageOptions=pt(t.sendAdblockPageOptions),t.loadIntegration=ot(t.loadIntegration,s.loadIntegration),bt(t.storage)?(t.storage.migrate=ot(t.storage.migrate,s.storage?.migrate),t.storage.cookie=pt(t.storage.cookie),t.storage.encryption=pt(t.storage.encryption),t.storage=ji(t.storage)):t.storage=void 0,t.destinationsQueueOptions=pt(t.destinationsQueueOptions),t.queueOptions=pt(t.queueOptions),t.lockIntegrationsVersion=ot(t.lockIntegrationsVersion,s.lockIntegrationsVersion),t.lockPluginsVersion=ot(t.lockPluginsVersion,s.lockPluginsVersion),Ju(t.dataPlaneEventsBufferTimeout)||(t.dataPlaneEventsBufferTimeout=void 0),t.beaconQueueOptions=pt(t.beaconQueueOptions),t.preConsent=pt(t.preConsent),t.sourceConfigurationOverride=pt(t.sourceConfigurationOverride),we(s,ji(t))},Ql="dataplaneEventsQueue",Zl="destinationsEventsQueue",Qm="transformEvent",Zm=(s,e)=>Object.keys(s).filter(t=>s[t]!==!0||!e[t]).reduce((t,i)=>{let r=q(t);return r[i]=s[i],r},{}),ey=(s,e)=>{let t=q(s),i=e.nativeDestinations.integrationsConfig.value,r=Zm(s.integrations,i);return t.integrations=we(i,r),t},ty=s=>s.consents.preConsent.value.enabled&&s.consents.preConsent.value.events?.delivery==="buffer",Hi=(s,e,t,i)=>{if(ee(s))if(x(s))try{s(...e)}catch(r){i.error(Mp(t),r)}else i.error(ku(t))},eo=class{constructor(e,t,i,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=i,this.logger=n,this.storeManager=t}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${Ql}.init`,c,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${Qm}.init`,c,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${Zl}.init`,c,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),lt(()=>{c.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=ty(c),t;lt(()=>{let i=c.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&c.nativeDestinations.clientDestinationsReady.value===!1;(c.nativeDestinations.activeDestinations.value.some(n=>a_(n))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(t),this.dataplaneEventsQueue?.start())}),c.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(t=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},c.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(c.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,t){let i=ey(e,c);this.pluginsManager.invokeSingle(`${Ql}.enqueue`,c,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let r=q(e);this.pluginsManager.invokeSingle(`${Zl}.enqueue`,c,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${oo}`;Hi(t,[i],n,this.logger)}},eu=s=>{let e=new CustomEvent(s,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},sy=s=>re(s)&&s.trim().length>0,iy=s=>hs(s),to=class{constructor(){this.preloadBuffer=new Cn,this.initialized=!1,this.errorHandler=$u,this.logger=Et,this.externalSrcLoader=new Wi(this.logger),this.httpClient=Du,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new Xn(this.httpClient,this.errorHandler,this.logger)}load(e,t,i={}){if(!c.lifecycle.status.value){if(!sy(e)){this.logger.error(fp(Li,e));return}if(!iy(t)){this.logger.error(pp(Li,t));return}Ae(()=>{c.lifecycle.writeKey.value=q(e),c.lifecycle.dataPlaneUrl.value=q(t),c.loadOptions.value=Jm(c.loadOptions.value,i),c.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(c.loadOptions.value.logLevel??bu),Ks("state",c,e),this.startLifecycle()}}startLifecycle(){lt(()=>{try{switch(c.lifecycle.status.value){case"mounted":this.onMounted();break;case"browserCapabilitiesReady":this.onBrowserCapabilitiesReady();break;case"configured":this.onConfigured();break;case"pluginsLoading":break;case"pluginsReady":this.onPluginsReady();break;case"initialized":this.onInitialized();break;case"loaded":this.onLoaded();break;case"destinationsLoading":break;case"destinationsReady":this.onDestinationsReady();break;case"ready":this.onReady();break;default:break}}catch(e){let t="Failed to load the SDK";this.errorHandler.onError({error:e,context:Li,customMessage:t,groupingHash:t})}})}onBrowserCapabilitiesReady(){Bf(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),c.consents.preConsent.value.enabled===!0?c.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(t=>this.preloadBuffer.enqueue(q(t)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Vf([...e],this)}}prepareInternalServices(){this.pluginsManager=new Mn(n_,this.errorHandler,this.logger),this.storeManager=new zn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Wn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Zn(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new eo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Qn(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){c.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(c.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),c.consents.enabled.value&&!c.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",c,this.logger),c.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",c,this.storeManager,this.logger)),this.eventManager?.init(),c.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Ae(()=>{c.lifecycle.loaded.value=!0,c.lifecycle.status.value="loaded"}),this.initialized=!0;let e=c.loadOptions.value.onLoaded;Hi(e,[globalThis.rudderanalytics],sf,this.logger),eu("RSA_Initialised")}onReady(){c.lifecycle.status.value="readyExecuted",c.eventBuffer.readyCallbacksArray.value.forEach(e=>{Hi(e,[],yn,this.logger)}),eu("RSA_Ready")}processBufferedEvents(){let e=c.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let t=e.shift();if(c.eventBuffer.toBeProcessedArray.value=e,t){let i=t[0];x(this[i])&&this[i](...t.slice(1),!0)}e=c.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(c.lifecycle.status.value==="destinationsLoading"||c.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",c,this.pluginsManager,this.errorHandler,this.logger);let e=c.nativeDestinations.activeDestinations.value.length;if(e===0){Ae(()=>{c.nativeDestinations.clientDestinationsReady.value=!0,c.lifecycle.status.value="destinationsReady"});return}c.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",c,this.externalSrcLoader,this.errorHandler,this.logger),lt(()=>{c.nativeDestinations.initializedDestinations.value.length+c.nativeDestinations.failedDestinations.value.length===e&&Ae(()=>{c.lifecycle.status.value="destinationsReady",c.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){c.lifecycle.status.value!=="ready"&&Ae(()=>{c.lifecycle.status.value="ready"})}ready(e,t=!1){let i="ready";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!x(e)){this.logger.error(ku(yn));return}c.lifecycle.status.value==="readyExecuted"?Hi(e,[],yn,this.logger):c.eventBuffer.readyCallbacksArray.value=[...c.eventBuffer.readyCallbacksArray.value,e]}page(e,t=!1){let i="page";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),c.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),c.capabilities.isAdBlocked.value===!0&&e.category!==Al&&this.page(qi(Al,Tf,{path:Rf},c.loadOptions.value.sendAdblockPageOptions))}track(e,t=!1){let i="track";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event - ${e.name}`),c.metrics.triggered.value+=1,this.eventManager?.addEvent({type:i,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,t=!1){let i="identify";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),c.metrics.triggered.value+=1,e.userId&&c.session.userId.value&&e.userId!==c.session.userId.value&&this.reset(),Ve(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:i,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,t=!1){let i="alias";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),c.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:i,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,t=!1){let i="group";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} event`),c.metrics.triggered.value+=1,Ve(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:i,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,t=!1){let i="reset";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,t,i=!1){let r="setAnonymousId";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[r,e,t]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,t)}getUserId(){return c.session.userId.value}getUserTraits(){return c.session.userTraits.value}getGroupId(){return c.session.groupId.value}getGroupTraits(){return c.session.groupTraits.value}startSession(e,t=!1){let i="startSession";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let t="endSession";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[t]];return}this.errorHandler.leaveBreadcrumb(`New ${t} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,t=!1){let i="consent";if(!c.lifecycle.loaded.value){c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ae(()=>{c.consents.preConsent.value={...c.consents.preConsent.value,enabled:!1},c.consents.postConsent.value=lm(e);let{initialized:r,consentsData:n}=Wu(c.consents.postConsent.value.consentManagement,this.logger);c.consents.initialized.value=r,c.consents.data.value=n}),c.consents.enabled.value&&!c.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",c,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(t)}sendTrackingEvents(e){if(c.consents.postConsent.value.trackConsent){let t=no(If);e?c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(c.consents.postConsent.value.sendPageEvent){let t=qi();e?c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,t,i=!1){let r="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,t,c,this.logger);else{if(c.lifecycle.loaded.value){this.logger.error(Xp(Li,e));return}c.eventBuffer.toBeProcessedArray.value=[...c.eventBuffer.toBeProcessedArray.value,[r,e,t]]}}},jt=class jt{constructor(){le(this,"analyticsInstances",{});le(this,"defaultAnalyticsKey","");le(this,"logger",Et);try{if(jt.globalSingleton)return jt.globalSingleton;jt.initializeGlobalResources(),this.setDefaultInstanceKey=this.setDefaultInstanceKey.bind(this),this.getAnalyticsInstance=this.getAnalyticsInstance.bind(this),this.load=this.load.bind(this),this.ready=this.ready.bind(this),this.triggerBufferedLoadEvent=this.triggerBufferedLoadEvent.bind(this),this.page=this.page.bind(this),this.track=this.track.bind(this),this.identify=this.identify.bind(this),this.alias=this.alias.bind(this),this.group=this.group.bind(this),this.reset=this.reset.bind(this),this.getAnonymousId=this.getAnonymousId.bind(this),this.setAnonymousId=this.setAnonymousId.bind(this),this.getUserId=this.getUserId.bind(this),this.getUserTraits=this.getUserTraits.bind(this),this.getGroupId=this.getGroupId.bind(this),this.getGroupTraits=this.getGroupTraits.bind(this),this.startSession=this.startSession.bind(this),this.endSession=this.endSession.bind(this),this.getSessionId=this.getSessionId.bind(this),this.setAuthToken=this.setAuthToken.bind(this),this.consent=this.consent.bind(this),this.addCustomIntegration=this.addCustomIntegration.bind(this),this.createSafeAnalyticsInstance(),jt.globalSingleton=this,c.autoTrack.pageLifecycle.pageViewId.value=Zi(),c.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){fe(e)}}createSafeAnalyticsInstance(){c.lifecycle.safeAnalyticsInstance.value={page:this.page.bind(this),track:this.track.bind(this),identify:this.identify.bind(this),alias:this.alias.bind(this),group:this.group.bind(this),getAnonymousId:this.getAnonymousId.bind(this),getUserId:this.getUserId.bind(this),getUserTraits:this.getUserTraits.bind(this),getGroupId:this.getGroupId.bind(this),getGroupTraits:this.getGroupTraits.bind(this),getSessionId:this.getSessionId.bind(this)}}static initializeGlobalResources(){$u.init(),go.configure(),co.configure(),ho.configure(),Ji.configure()}setDefaultInstanceKey(e){re(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return(!re(t)||!t)&&(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new to),this.analyticsInstances[t]}catch(t){fe(t);return}}load(e,t,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let r=gu(zs);Uf(r),Ks(zs,q(r)),this.getAnalyticsInstance(e)?.load(e,t,Y(i))}catch(r){fe(r)}}trackPageLifecycleEvents(e){let{autoTrack:t,useBeacon:i}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=t??{},{events:a=[mn.UNLOADED],enabled:l=r,options:u=n}=o??{};c.autoTrack.pageLifecycle.enabled.value=l,c.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,i,u)}setupPageUnloadTracking(e,t,i){(e.length===0||e.includes(mn.UNLOADED))&&(t===!0?hf(r=>{if(r===!1&&c.lifecycle.loaded.value){let n=Date.now(),o=n-c.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(mn.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:au(new Date(n))})}},!0):this.logger.warn(qp(nf)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=Mf(e);Ks(zs,q([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{this.getAnalyticsInstance()?.ready(Y(e))}catch(t){fe(t)}}page(e,t,i,r,n){try{this.getAnalyticsInstance()?.page(qi(Y(e),Y(t),Y(i),Y(r),Y(n)))}catch(o){fe(o)}}track(e,t,i,r){try{this.getAnalyticsInstance()?.track(no(Y(e),Y(t),Y(i),Y(r)))}catch(n){fe(n)}}identify(e,t,i,r){try{this.getAnalyticsInstance()?.identify(iu(Y(e),Y(t),Y(i),Y(r)))}catch(n){fe(n)}}alias(e,t,i,r){try{this.getAnalyticsInstance()?.alias(ru(Y(e),Y(t),Y(i),Y(r)))}catch(n){fe(n)}}group(e,t,i,r){try{this.getAnalyticsInstance()?.group(nu(Y(e),Y(t),Y(i),Y(r)))}catch(n){fe(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(Y(e))}catch(t){fe(t)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(Y(e))}catch(t){fe(t);return}}setAnonymousId(e,t){try{this.getAnalyticsInstance()?.setAnonymousId(Y(e),Y(t))}catch(i){fe(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){fe(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){fe(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){fe(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){fe(e);return}}startSession(e){try{this.getAnalyticsInstance()?.startSession(Y(e))}catch(t){fe(t)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){fe(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){fe(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(Y(e))}catch(t){fe(t)}}consent(e){try{this.getAnalyticsInstance()?.consent(Y(e))}catch(t){fe(t)}}addCustomIntegration(e,t){try{this.getAnalyticsInstance()?.addCustomIntegration(Y(e),Y(t))}catch(i){fe(i)}}};le(jt,"globalSingleton",null);gs=jt});var ec,tc,po,Zu,sc,ic,rc,nc,Ys=Fe(()=>{"use strict";ec="https://deriv.com/cdn-cgi/trace",tc="https://cdn.growthbook.io",po="https://deriv-dataplane.rudderstack.com",Zu="https://ph.deriv.com",sc="https://us.posthog.com",ic=()=>{if(typeof window>"u")return Zu;let s=window.location.hostname;return s.includes(".deriv.me")?"https://ph.deriv.me":s.includes(".deriv.be")?"https://ph.deriv.be":s.includes(".deriv.ae")?"https://ph.deriv.ae":Zu},rc=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],nc=["deriv.com","derivcrypto.com","besquare.my","besquare.com.my","ewallet.exchange","champion-fx.com","opalstraits.com","binary.com","binary.marketing","championgbs.com","4x.my","re-work.dev","regentmarkets.com","4x.com","binary.me","deriv.team","firstsource.io","firstsource.tech","deriv.hr","vmgbpo.net","mailisk.net","mailosaur.net","mobileapps.mailisk.net","w3e180zd.mailosaur.net"]});function rr(s){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var i in t)s[i]=t[i]}return s}function vo(s,e){function t(r,n,o){if(!(typeof document>"u")){o=rr({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),r=encodeURIComponent(r).replace(/%(2[346B]|5E|60|7C)/g,decodeURIComponent).replace(/[()]/g,escape);var a="";for(var l in o)o[l]&&(a+="; "+l,o[l]!==!0&&(a+="="+o[l].split(";")[0]));return document.cookie=r+"="+s.write(n,r)+a}}function i(r){if(!(typeof document>"u"||arguments.length&&!r)){for(var n=document.cookie?document.cookie.split("; "):[],o={},a=0;a<n.length;a++){var l=n[a].split("="),u=l.slice(1).join("=");try{var d=decodeURIComponent(l[0]);if(o[d]=s.read(u,d),r===d)break}catch{}}return r?o[r]:o}}return Object.create({set:t,get:i,remove:function(r,n){t(r,"",rr({},n,{expires:-1}))},withAttributes:function(r){return vo(this.converter,rr({},this.attributes,r))},withConverter:function(r){return vo(rr({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(s)}})}var ry,oc,ac=Fe(()=>{"use strict";ry={read:function(s){return s[0]==='"'&&(s=s.slice(1,-1)),s.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(s){return encodeURIComponent(s).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};oc=vo(ry,{path:"/"})});var Dt,or,Js,nr,lc,Wt,uc,cc,Qs=Fe(()=>{"use strict";ac();Ys();Dt=(s,e)=>(...t)=>{e()&&console.log(`[ANALYTIC]${s}`,...t)},or=s=>{let e=s.split("@")[1]?.toLowerCase();return e?nc.includes(e):!1},Js=s=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(s),nr=null,lc=async()=>{if(nr)return nr;let s=JSON.parse(oc.get("website_status")||"{}")?.clients_country;return nr=(async()=>{try{let e=await fetch(ec).catch(()=>null);if(!e)return s||"";let t=await e.text().catch(()=>"");return t?Object.fromEntries(t.split(`
|
|
5
|
+
`).map(r=>r.split("=",2))).loc?.toLowerCase()||s||"":s||""}catch{return s||""}})(),nr},Wt=s=>{if(s==null||typeof s!="object")return s;if(Array.isArray(s)){let i=[];for(let r=0;r<s.length;r++){let n=Wt(s[r]);n!=null&&i.push(n)}return i.length?i:void 0}let e={},t=!1;for(let i in s){if(!Object.prototype.hasOwnProperty.call(s,i))continue;let r=Wt(s[i]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[i]=r,t=!0)}return t?e:void 0},uc=(s,e)=>{for(let t in s){if(!Object.prototype.hasOwnProperty.call(s,t))continue;let i=s[t];i&&typeof i=="object"&&!Array.isArray(i)?uc(i,e):e[t]=i}},cc=s=>{if(s==null||typeof s!="object"||Array.isArray(s))return s;let e={};return uc(s,e),e}});function yc(){return mc}function _o(s){let e=2166136261,t=s.length;for(let i=0;i<t;i++)e^=s.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Zs(s,e,t){return t===2?_o(_o(s+e)+"")%1e4/1e4:t===1?_o(e+s)%1e3/1e3:null}function oy(s){return s<=0?[]:new Array(s).fill(1/s)}function cr(s,e){return s>=e[0]&&s<e[1]}function bc(s,e){let t=Zs("__"+e[0],s,1);return t===null?!1:t>=e[1]&&t<e[2]}function Ec(s,e){for(let t=0;t<e.length;t++)if(cr(s,e[t]))return t;return-1}function yo(s){try{let e=s.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function dr(s,e){if(!e.length)return!1;let t=!1,i=!1;for(let r=0;r<e.length;r++){let n=uy(s,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else t=!0,n&&(i=!0)}return i||!t}function ay(s,e,t){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return t&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(s)}catch{return!1}}function ly(s,e){try{let t=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[s.host,t.host,!1],[s.pathname,t.pathname,!0]];return t.hash&&i.push([s.hash,t.hash,!1]),t.searchParams.forEach((r,n)=>{i.push([s.searchParams.get(n)||"",r,!1])}),!i.some(r=>!ay(r[0],r[1],r[2]))}catch{return!1}}function uy(s,e,t){try{let i=new URL(s,"https://_");if(e==="regex"){let r=yo(t);return r?r.test(i.href)||r.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return ly(i,t);return!1}catch{return!1}}function kc(s,e,t){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=oy(s);t=t||i,t.length!==s&&(t=i);let r=t.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(t=i);let n=0;return t.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Sc(s,e,t){if(!e)return null;let i=e.split("?")[1];if(!i)return null;let r=i.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===s).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<t?r[0]:null}function wc(s){try{return s()}catch(e){return console.error(e),!1}}async function Xt(s,e,t){if(e=e||"",t=t||globalThis.crypto&&globalThis.crypto.subtle||mc.SubtleCrypto,!t)throw new Error("No SubtleCrypto implementation found");try{let i=await t.importKey("raw",mo(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=s.split("."),o=await t.decrypt({name:"AES-CBC",iv:mo(r)},i,mo(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function ei(s){return typeof s=="string"?s:JSON.stringify(s)}function ze(s){typeof s=="number"&&(s=s+""),(!s||typeof s!="string")&&(s="0");let e=s.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(t=>t.match(/^[0-9]+$/)?t.padStart(5," "):t).join("-")}function Ac(){let s;try{s="1.6.5"}catch{s=""}return s}function Tc(s,e){let t,i;try{t=new URL(s),i=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return t.searchParams.forEach((r,n)=>{i.searchParams.has(n)||i.searchParams.set(n,r)}),i.toString()}function _c(s){return typeof s=="object"&&s!==null}function hr(s){return s.urlPatterns&&s.variations.some(e=>_c(e)&&"urlRedirect"in e)?"redirect":s.variations.some(e=>_c(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function gr(s,e){return new Promise(t=>{let i=!1,r,n=o=>{i||(i=!0,r&&clearTimeout(r),t(o||null))};e&&(r=setTimeout(()=>n(),e)),s.then(o=>n(o)).catch(()=>n())})}var mc,mo,ti=Fe(()=>{"use strict";mc={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};mo=s=>Uint8Array.from(atob(s),e=>e.charCodeAt(0))});function Oc(s){Object.assign(Pe,s),Pe.backgroundSync||Ao()}async function Pc({instance:s,timeout:e,skipCache:t,allowStale:i,backgroundSync:r}){return r||(Pe.backgroundSync=!1),gy({instance:s,allowStale:i,timeout:e,skipCache:t})}function cy(s){let e=si(s),t=_s.get(e)||new Set;t.add(s),_s.set(e,t)}function Cc(s){_s.forEach(e=>e.delete(s))}function dy(){ms.forEach(s=>{s&&(s.state="idle",So(s))})}function hy(){ms.forEach(s=>{s&&s.state==="idle"&&wo(s)})}async function Ic(){try{if(!ut.localStorage)return;await ut.localStorage.setItem(Pe.cacheKey,JSON.stringify(Array.from(kt.entries())))}catch{}}async function gy({instance:s,allowStale:e,timeout:t,skipCache:i}){let r=si(s),n=Eo(s),o=new Date,a=new Date(o.getTime()-Pe.maxAge+Pe.staleTTL);await fy();let l=!Pe.disableCache&&!i?kt.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&ys.add(r),l.staleAt<o?bo(s):ko(s),{data:l.data,success:!0,source:"cache"}):await gr(bo(s),t)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function si(s){let[e,t]=s.getApiInfo();return`${e}||${t}`}function Eo(s){let e=si(s);if(!("isRemoteEval"in s)||!s.isRemoteEval())return e;let t=s.getAttributes(),i=s.getCacheKeyAttributes()||Object.keys(s.getAttributes()),r={};i.forEach(a=>{r[a]=t[a]});let n=s.getForcedVariations(),o=s.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function fy(){if(!Rc){Rc=!0;try{if(ut.localStorage){let s=await ut.localStorage.getItem(Pe.cacheKey);if(!Pe.disableCache&&s){let e=JSON.parse(s);e&&Array.isArray(e)&&e.forEach(([t,i])=>{kt.set(t,{...i,staleAt:new Date(i.staleAt)})}),Dc()}}}catch{}if(!Pe.disableIdleStreams){let s=vs.startIdleListener();s&&(vs.stopIdleListener=s)}}}function Dc(){let s=Array.from(kt.entries()).map(([t,i])=>({key:t,staleAt:i.staleAt.getTime()})).sort((t,i)=>t.staleAt-i.staleAt),e=Math.min(Math.max(0,kt.size-Pe.maxEntries),kt.size);for(let t=0;t<e;t++)kt.delete(s[t].key)}function Nc(s,e,t){let i=t.dateUpdated||"",r=new Date(Date.now()+Pe.staleTTL),n=Pe.disableCache?void 0:kt.get(e);if(n&&i&&n.version===i){n.staleAt=r,Ic();return}Pe.disableCache||(kt.set(e,{data:t,version:i,staleAt:r,sse:ys.has(s)}),Dc()),Ic();let o=_s.get(s);o&&o.forEach(a=>py(a,t))}async function py(s,e){await s.setPayload(e||s.getPayload())}async function bo(s){let{apiHost:e,apiRequestHeaders:t}=s.getApiHosts(),i=s.getClientKey(),r="isRemoteEval"in s&&s.isRemoteEval(),n=si(s),o=Eo(s),a=fr.get(o);return a||(a=(r?vs.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:s.getAttributes(),forcedVariations:s.getForcedVariations(),forcedFeatures:Array.from(s.getForcedFeatures().entries()),url:s.getUrl()},headers:t}):vs.fetchFeaturesCall({host:e,clientKey:i,headers:t})).then(u=>{if(!u.ok)throw new Error(`HTTP error: ${u.status}`);return u.headers.get("x-sse-support")==="enabled"&&ys.add(n),u.json()}).then(u=>(Nc(n,o,u),ko(s),fr.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(fr.delete(o),{data:null,source:"error",success:!1,error:u})),fr.set(o,a)),a}function ko(s,e=!1){let t=si(s),i=Eo(s),{streamingHost:r,streamingHostRequestHeaders:n}=s.getApiHosts(),o=s.getClientKey();if(e&&ys.add(t),Pe.backgroundSync&&ys.has(t)&&ut.EventSource){if(ms.has(t))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let u=_s.get(t);u&&u.forEach(d=>{bo(d)})}else if(l.type==="features"){let u=JSON.parse(l.data);Nc(t,i,u)}a.errors=0}catch{xc(a)}},errors:0,state:"active"};ms.set(t,a),wo(a)}}function xc(s){if(s.state!=="idle"&&(s.errors++,s.errors>3||s.src&&s.src.readyState===2)){let e=Math.pow(3,s.errors-3)*(1e3+Math.random()*1e3);So(s),setTimeout(()=>{["idle","active"].includes(s.state)||wo(s)},Math.min(e,3e5))}}function So(s){s.src&&(s.src.onopen=null,s.src.onerror=null,s.src.close(),s.src=null,s.state==="active"&&(s.state="disabled"))}function wo(s){s.src=vs.eventSourceCall({host:s.host,clientKey:s.clientKey,headers:s.headers}),s.state="active",s.src.addEventListener("features",s.cb),s.src.addEventListener("features-updated",s.cb),s.src.onerror=()=>xc(s),s.src.onopen=()=>{s.errors=0}}function vy(s,e){So(s),ms.delete(e)}function Ao(){ys.clear(),ms.forEach(vy),_s.clear(),vs.stopIdleListener()}function pr(s,e){if(e.streaming){if(!s.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&ko(s,!0),cy(s)}}var Pe,ut,vs,_s,Rc,kt,fr,ms,ys,Lc=Fe(()=>{"use strict";ti();Pe={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},ut=yc(),vs={fetchFeaturesCall:({host:s,clientKey:e,headers:t})=>ut.fetch(`${s}/api/features/${e}`,{headers:t}),fetchRemoteEvalCall:({host:s,clientKey:e,payload:t,headers:i})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(t)};return ut.fetch(`${s}/api/eval/${e}`,r)},eventSourceCall:({host:s,clientKey:e,headers:t})=>t?new ut.EventSource(`${s}/sub/${e}`,{headers:t}):new ut.EventSource(`${s}/sub/${e}`),startIdleListener:()=>{let s;if(!(typeof window<"u"&&typeof document<"u"))return;let t=()=>{document.visibilityState==="visible"?(window.clearTimeout(s),hy()):document.visibilityState==="hidden"&&(s=window.setTimeout(dy,Pe.idleStreamInterval))};return document.addEventListener("visibilitychange",t),()=>document.removeEventListener("visibilitychange",t)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(ut.localStorage=globalThis.localStorage)}catch{}_s=new Map,Rc=!1,kt=new Map,fr=new Map,ms=new Map,ys=new Set});function my(s){return s==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[s]}}function br(s){var e=yr.get(s);return e||(e={element:s,attributes:{}},yr.set(s,e)),e}function Er(s,e,t,i,r){var n=t(s),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:s,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=t(s);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,r(o))}}),mutationRunner:r,setValue:i,getCurrentValue:t};return e==="position"&&s.parentNode?o.observer.observe(s.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(s,my(e)),o}function kr(s,e){var t=e.getCurrentValue(e.el);e.virtualValue=s,s&&typeof s!="string"?(!t||s.parentNode!==t.parentNode||s.insertBeforeNode!==t.insertBeforeNode)&&(e.isDirty=!0,$c()):s!==t&&(e.isDirty=!0,$c())}function yy(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),kr(Ny(e),s)}function by(s){var e=new Set(s.originalValue.split(/\s+/).filter(Boolean));s.mutations.forEach(function(t){return t.mutate(e)}),kr(Array.from(e).filter(Boolean).join(" "),s)}function Ey(s){var e=s.originalValue;s.mutations.forEach(function(t){return e=t.mutate(e)}),kr(e,s)}function ky(s){var e=s.parentSelector,t=s.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var r=t?document.querySelector(t):null;return t&&!r?null:{parentNode:i,insertBeforeNode:r}}function Sy(s){var e=s.originalValue;s.mutations.forEach(function(t){var i=t.mutate(),r=ky(i);e=r||e}),kr(e,s)}function Mc(s){var e=br(s);return e.html||(e.html=Er(s,"html",wy,Ay,yy)),e.html}function Uc(s){var e=br(s);return e.position||(e.position=Er(s,"position",Ty,Ry,Sy)),e.position}function Bc(s){var e=br(s);return e.classes||(e.classes=Er(s,"class",Oy,Iy,by)),e.classes}function Vc(s,e){var t=br(s);return t.attributes[e]||(t.attributes[e]=Er(s,e,Py(e),Cy(e),Ey)),t.attributes[e]}function Dy(s,e){var t=yr.get(s);if(t)if(e==="html"){var i,r;(i=t.html)==null||(r=i.observer)==null||r.disconnect(),delete t.html}else if(e==="class"){var n,o;(n=t.classes)==null||(o=n.observer)==null||o.disconnect(),delete t.classes}else if(e==="position"){var a,l;(a=t.position)==null||(l=a.observer)==null||l.disconnect(),delete t.position}else{var u,d,h;(u=t.attributes)==null||(d=u[e])==null||(h=d.observer)==null||h.disconnect(),delete t.attributes[e]}}function Ny(s){return vr||(vr=document.createElement("div")),vr.innerHTML=s,vr.innerHTML}function _r(s,e,t){if(t.isDirty){t.isDirty=!1;var i=t.virtualValue;t.mutations.length||Dy(s,e),t.setValue(s,i)}}function xy(s,e){s.html&&_r(e,"html",s.html),s.classes&&_r(e,"class",s.classes),s.position&&_r(e,"position",s.position),Object.keys(s.attributes).forEach(function(t){_r(e,t,s.attributes[t])})}function $c(){yr.forEach(xy)}function Ly(s,e){var t=null;s.kind==="html"?t=Mc(e):s.kind==="class"?t=Bc(e):s.kind==="attribute"?t=Vc(e,s.attribute):s.kind==="position"&&(t=Uc(e)),t&&(t.mutations.push(s),t.mutationRunner(t))}function $y(s,e){var t=null;if(s.kind==="html"?t=Mc(e):s.kind==="class"?t=Bc(e):s.kind==="attribute"?t=Vc(e,s.attribute):s.kind==="position"&&(t=Uc(e)),!!t){var i=t.mutations.indexOf(s);i!==-1&&t.mutations.splice(i,1),t.mutationRunner(t)}}function Gc(s){if(!(s.kind==="position"&&s.elements.size===1)){var e=new Set(s.elements),t=document.querySelectorAll(s.selector);t.forEach(function(i){e.has(i)||(s.elements.add(i),Ly(s,i))})}}function Fy(s){s.elements.forEach(function(e){return $y(s,e)}),s.elements.clear(),Oo.delete(s)}function Fc(){Oo.forEach(Gc)}function My(){typeof document>"u"||(To||(To=new MutationObserver(function(){Fc()})),Fc(),To.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Sr(s){return typeof document>"u"?Io:(Oo.add(s),Gc(s),{revert:function(){Fy(s)}})}function Ro(s,e){return Sr({kind:"html",elements:new Set,mutate:e,selector:s})}function Hc(s,e){return Sr({kind:"position",elements:new Set,mutate:e,selector:s})}function ii(s,e){return Sr({kind:"class",elements:new Set,mutate:e,selector:s})}function mr(s,e,t){return _y.test(e)?e==="class"||e==="className"?ii(s,function(i){var r=t(Array.from(i).join(" "));i.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return i.add(n)})}):Sr({kind:"attribute",attribute:e,elements:new Set,mutate:t,selector:s}):Io}function Uy(s){var e=s.selector,t=s.action,i=s.value,r=s.attribute,n=s.parentSelector,o=s.insertBeforeSelector;if(r==="html"){if(t==="append")return Ro(e,function(a){return a+(i??"")});if(t==="set")return Ro(e,function(){return i??""})}else if(r==="class"){if(t==="append")return ii(e,function(a){i&&a.add(i)});if(t==="remove")return ii(e,function(a){i&&a.delete(i)});if(t==="set")return ii(e,function(a){a.clear(),i&&a.add(i)})}else if(r==="position"){if(t==="set"&&n)return Hc(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(t==="append")return mr(e,r,function(a){return a!==null?a+(i??""):i??""});if(t==="set")return mr(e,r,function(){return i??""});if(t==="remove")return mr(e,r,function(){return null})}return Io}var _y,Io,yr,Oo,wy,Ay,Ty,Ry,Iy,Oy,Py,Cy,vr,To,By,jc,zc=Fe(()=>{"use strict";_y=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Io={revert:function(){}},yr=new Map,Oo=new Set;wy=function(e){return e.innerHTML},Ay=function(e,t){return e.innerHTML=t};Ty=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Ry=function(e,t){t.insertBeforeNode&&!t.parentNode.contains(t.insertBeforeNode)||t.parentNode.insertBefore(e,t.insertBeforeNode)};Iy=function(e,t){return t?e.className=t:e.removeAttribute("class")},Oy=function(e){return e.className};Py=function(e){return function(t){var i;return(i=t.getAttribute(e))!=null?i:null}},Cy=function(e){return function(t,i){return i!==null?t.setAttribute(e,i):t.removeAttribute(e)}};My();By={html:Ro,classes:ii,attribute:mr,position:Hc,declarative:Uy},jc=By});function Nt(s,e,t){t=t||{};for(let[i,r]of Object.entries(e))switch(i){case"$or":if(!Kc(s,r,t))return!1;break;case"$nor":if(Kc(s,r,t))return!1;break;case"$and":if(!zy(s,r,t))return!1;break;case"$not":if(Nt(s,r,t))return!1;break;default:if(!ri(r,Vy(s,i),t))return!1}return!0}function Vy(s,e){let t=e.split("."),i=s;for(let r=0;r<t.length;r++)if(i&&typeof i=="object"&&t[r]in i)i=i[t[r]];else return null;return i}function qc(s,e=!1){let t=`${s}${e?"/i":""}`;return Po[t]||(Po[t]=new RegExp(s.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Po[t]}function ri(s,e,t,i=!1){if(typeof s=="string")return i?String(e).toLowerCase()===s.toLowerCase():e+""===s;if(typeof s=="number")return e*1===s;if(typeof s=="boolean")return e!==null&&!!e===s;if(s===null)return e===null;if(Array.isArray(s)||!Xc(s))return JSON.stringify(e)===JSON.stringify(s);for(let r in s)if(!jy(r,e,s[r],t))return!1;return!0}function Xc(s){let e=Object.keys(s);return e.length>0&&e.filter(t=>t[0]==="$").length===e.length}function Gy(s){if(s===null)return"null";if(Array.isArray(s))return"array";let e=typeof s;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function Hy(s,e,t){if(!Array.isArray(s))return!1;let i=Xc(e)?r=>ri(e,r,t):r=>Nt(r,e,t);for(let r=0;r<s.length;r++)if(s[r]&&i(s[r]))return!0;return!1}function bs(s,e,t=!1){if(t){let i=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(s)?s.some(r=>e.some(n=>i(r)===i(n))):e.some(r=>i(s)===i(r))}return Array.isArray(s)?s.some(i=>e.includes(i)):e.includes(s)}function Wc(s,e,t,i=!1){if(!Array.isArray(s))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<s.length;o++)if(ri(e[r],s[o],t,i)){n=!0;break}if(!n)return!1}return!0}function jy(s,e,t,i){switch(s){case"$veq":return ze(e)===ze(t);case"$vne":return ze(e)!==ze(t);case"$vgt":return ze(e)>ze(t);case"$vgte":return ze(e)>=ze(t);case"$vlt":return ze(e)<ze(t);case"$vlte":return ze(e)<=ze(t);case"$eq":return e===t;case"$ne":return e!==t;case"$lt":return e<t;case"$lte":return e<=t;case"$gt":return e>t;case"$gte":return e>=t;case"$exists":return t?e!=null:e==null;case"$in":return Array.isArray(t)?bs(e,t):!1;case"$ini":return Array.isArray(t)?bs(e,t,!0):!1;case"$inGroup":return bs(e,i[t]||[]);case"$notInGroup":return!bs(e,i[t]||[]);case"$nin":return Array.isArray(t)?!bs(e,t):!1;case"$nini":return Array.isArray(t)?!bs(e,t,!0):!1;case"$not":return!ri(t,e,i);case"$size":return Array.isArray(e)?ri(t,e.length,i):!1;case"$elemMatch":return Hy(e,t,i);case"$all":return Array.isArray(t)?Wc(e,t,i):!1;case"$alli":return Array.isArray(t)?Wc(e,t,i,!0):!1;case"$regex":try{return qc(t).test(e)}catch{return!1}case"$regexi":try{return qc(t,!0).test(e)}catch{return!1}case"$type":return Gy(e)===t;default:return console.error("Unknown operator: "+s),!1}}function Kc(s,e,t){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(Nt(s,e[i],t))return!0;return!1}function zy(s,e,t){for(let i=0;i<e.length;i++)if(!Nt(s,e[i],t))return!1;return!0}var Po,Yc=Fe(()=>{"use strict";ti();Po={}});function Ky(s){let e=new Map;return s.global.forcedFeatureValues&&s.global.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),s.user.forcedFeatureValues&&s.user.forcedFeatureValues.forEach((t,i)=>e.set(i,t)),e}function Xy(s){return s.global.forcedVariations&&s.user.forcedVariations?{...s.global.forcedVariations,...s.user.forcedVariations}:s.global.forcedVariations?s.global.forcedVariations:s.user.forcedVariations?s.user.forcedVariations:{}}async function Es(s){try{await s()}catch{}}function Jc(s,e,t){if(s.user.trackedExperiments){let r=Tr(e,t);if(s.user.trackedExperiments.has(r))return[];s.user.trackedExperiments.add(r)}s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({experiment:e,result:t,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(s.global.trackingCallback){let r=s.global.trackingCallback;i.push(Es(()=>r(e,t,s.user)))}if(s.user.trackingCallback){let r=s.user.trackingCallback;i.push(Es(()=>r(e,t)))}if(s.global.eventLogger){let r=s.global.eventLogger;i.push(Es(()=>r(Wy,{experimentId:e.key,variationId:t.key,hashAttribute:t.hashAttribute,hashValue:t.hashValue},s.user)))}return i}function Yy(s,e,t){if(s.user.trackedFeatureUsage){let i=JSON.stringify(t.value);if(s.user.trackedFeatureUsage[e]===i)return;s.user.trackedFeatureUsage[e]=i,s.user.enableDevMode&&s.user.devLogs&&s.user.devLogs.push({featureKey:e,result:t,timestamp:Date.now().toString(),logType:"feature"})}if(s.global.onFeatureUsage){let i=s.global.onFeatureUsage;Es(()=>i(e,t,s.user))}if(s.user.onFeatureUsage){let i=s.user.onFeatureUsage;Es(()=>i(e,t))}if(s.global.eventLogger){let i=s.global.eventLogger;Es(()=>i(qy,{feature:e,source:t.source,value:t.value,ruleId:t.source==="defaultValue"?"$default":t.ruleId||"",variationId:t.experimentResult?t.experimentResult.key:""},s.user))}}function wr(s,e){if(e.stack.evaluatedFeatures.has(s))return xt(e,s,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(s),e.stack.id=s;let t=Ky(e);if(t.has(s))return xt(e,s,t.get(s),"override");if(!e.global.features||!e.global.features[s])return xt(e,s,null,"unknownFeature");let i=e.global.features[s];if(i.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of i.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let u=wr(l.id,e);if(u.source==="cyclicPrerequisite")return xt(e,s,null,"cyclicPrerequisite");let d={value:u.value};if(!Nt(d,l.condition||{})){if(l.gate)return xt(e,s,null,"prerequisite");continue e}}if(n.filters&&ed(n.filters,e))continue;if("force"in n){if(n.condition&&!Zc(n.condition,e)||!Jy(e,n.seed||s,n.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!n.disableStickyBucketing?n.fallbackAttribute:void 0,n.range,n.coverage,n.hashVersion))continue;return n.tracks&&n.tracks.forEach(l=>{!Jc(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),xt(e,s,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||s};"coverage"in n&&(o.coverage=n.coverage),n.weights&&(o.weights=n.weights),n.hashAttribute&&(o.hashAttribute=n.hashAttribute),n.fallbackAttribute&&(o.fallbackAttribute=n.fallbackAttribute),n.disableStickyBucketing&&(o.disableStickyBucketing=n.disableStickyBucketing),n.bucketVersion!==void 0&&(o.bucketVersion=n.bucketVersion),n.minBucketVersion!==void 0&&(o.minBucketVersion=n.minBucketVersion),n.namespace&&(o.namespace=n.namespace),n.meta&&(o.meta=n.meta),n.ranges&&(o.ranges=n.ranges),n.name&&(o.name=n.name),n.phase&&(o.phase=n.phase),n.seed&&(o.seed=n.seed),n.hashVersion&&(o.hashVersion=n.hashVersion),n.filters&&(o.filters=n.filters),n.condition&&(o.condition=n.condition);let{result:a}=Ar(o,s,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return xt(e,s,a.value,"experiment",n.id,o,a)}}return xt(e,s,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function Ar(s,e,t){let i=s.key,r=s.variations.length;if(r<2)return{result:ue(t,s,-1,!1,e)};if(t.global.enabled===!1||t.user.enabled===!1)return{result:ue(t,s,-1,!1,e)};if(s=Qy(s,t),s.urlPatterns&&!dr(t.user.url||"",s.urlPatterns))return{result:ue(t,s,-1,!1,e)};let n=Sc(i,t.user.url||"",r);if(n!==null)return{result:ue(t,s,n,!1,e)};let o=Xy(t);if(i in o){let m=o[i];return{result:ue(t,s,m,!1,e)}}if(s.status==="draft"||s.active===!1)return{result:ue(t,s,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Yt(t,s.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing?s.fallbackAttribute:void 0);if(!l)return{result:ue(t,s,-1,!1,e)};let u=-1,d=!1,h=!1;if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{variation:m,versionIsBlocked:y}=tb({ctx:t,expKey:s.key,expBucketVersion:s.bucketVersion,expHashAttribute:s.hashAttribute,expFallbackAttribute:s.fallbackAttribute,expMinBucketVersion:s.minBucketVersion,expMeta:s.meta});d=m>=0,u=m,h=!!y}if(!d){if(s.filters){if(ed(s.filters,t))return{result:ue(t,s,-1,!1,e)}}else if(s.namespace&&!bc(l,s.namespace))return{result:ue(t,s,-1,!1,e)};if(s.include&&!wc(s.include))return{result:ue(t,s,-1,!1,e)};if(s.condition&&!Zc(s.condition,t))return{result:ue(t,s,-1,!1,e)};if(s.parentConditions){let m=new Set(t.stack.evaluatedFeatures);for(let y of s.parentConditions){t.stack.evaluatedFeatures=new Set(m);let w=wr(y.id,t);if(w.source==="cyclicPrerequisite")return{result:ue(t,s,-1,!1,e)};let C={value:w.value};if(!Nt(C,y.condition||{}))return{result:ue(t,s,-1,!1,e)}}}if(s.groups&&!eb(s.groups,t))return{result:ue(t,s,-1,!1,e)}}if(s.url&&!Zy(s.url,t))return{result:ue(t,s,-1,!1,e)};let f=Zs(s.seed||i,l,s.hashVersion||1);if(f===null)return{result:ue(t,s,-1,!1,e)};if(!d){let m=s.ranges||kc(r,s.coverage===void 0?1:s.coverage,s.weights);u=Ec(f,m)}if(h)return{result:ue(t,s,-1,!1,e,void 0,!0)};if(u<0)return{result:ue(t,s,-1,!1,e)};if("force"in s)return{result:ue(t,s,s.force===void 0?-1:s.force,!1,e)};if(t.global.qaMode||t.user.qaMode)return{result:ue(t,s,-1,!1,e)};if(s.status==="stopped")return{result:ue(t,s,-1,!1,e)};let g=ue(t,s,u,!0,e,f,d);if(t.user.saveStickyBucketAssignmentDoc&&!s.disableStickyBucketing){let{changed:m,key:y,doc:w}=ib(t,a,ei(l),{[Co(s.key,s.bucketVersion)]:g.key});m&&(t.user.stickyBucketAssignmentDocs=t.user.stickyBucketAssignmentDocs||{},t.user.stickyBucketAssignmentDocs[y]=w,t.user.saveStickyBucketAssignmentDoc(w))}let p=Jc(t,s,g);p.length===0&&t.global.saveDeferredTrack&&t.global.saveDeferredTrack({experiment:s,result:g});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in s&&s.changeId&&t.global.recordChangeId&&t.global.recordChangeId(s.changeId),{result:g,trackingCall:v}}function xt(s,e,t,i,r,n,o){let a={value:t,on:!!t,off:!t,source:i,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),i!=="override"&&Yy(s,e,a),a}function Qc(s){return{...s.user.attributes,...s.user.attributeOverrides}}function Zc(s,e){return Nt(Qc(e),s,e.global.savedGroups||{})}function ed(s,e){return s.some(t=>{let{hashValue:i}=Yt(e,t.attribute);if(!i)return!0;let r=Zs(t.seed,i,t.hashVersion||2);return r===null?!0:!t.ranges.some(n=>cr(r,n))})}function Jy(s,e,t,i,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Yt(s,t,i);if(!a)return!1;let l=Zs(e,a,o||1);return l===null?!1:r?cr(l,r):n!==void 0?l<=n:!0}function ue(s,e,t,i,r,n,o){let a=!0;(t<0||t>=e.variations.length)&&(t=0,a=!1);let{hashAttribute:l,hashValue:u}=Yt(s,e.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),d=e.meta?e.meta[t]:{},h={key:d.key||""+t,featureId:r,inExperiment:a,hashUsed:i,variationId:t,value:e.variations[t],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};return d.name&&(h.name=d.name),n!==void 0&&(h.bucket=n),d.passthrough&&(h.passthrough=d.passthrough),h}function Qy(s,e){let t=s.key,i=e.global.overrides;return i&&i[t]&&(s=Object.assign({},s,i[t]),typeof s.url=="string"&&(s.url=yo(s.url))),s}function Yt(s,e,t){let i=e||"id",r="",n=Qc(s);return n[i]&&(r=n[i]),!r&&t&&(n[t]&&(r=n[t]),r&&(i=t)),{hashAttribute:i,hashValue:r}}function Zy(s,e){let t=e.user.url;if(!t)return!1;let i=t.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(s.test(t)||s.test(i))}function eb(s,e){let t=e.global.groups||{};for(let i=0;i<s.length;i++)if(t[s[i]])return!0;return!1}function tb({ctx:s,expKey:e,expBucketVersion:t,expHashAttribute:i,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){t=t||0,n=n||0,i=i||"id",o=o||[];let a=Co(e,t),l=sb(s,i,r);if(n>0)for(let h=0;h<n;h++){let f=Co(e,h);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let u=l[a];if(u===void 0)return{variation:-1};let d=o.findIndex(h=>h.key===u);return d<0?{variation:-1}:{variation:d}}function Co(s,e){return e=e||0,`${s}__${e}`}function Do(s,e){return`${s}||${e}`}function sb(s,e,t){if(!s.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:r}=Yt(s,e),n=Do(i,ei(r)),{hashAttribute:o,hashValue:a}=Yt(s,t),l=a?Do(o,ei(a)):null,u={};return l&&s.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,s.user.stickyBucketAssignmentDocs[l].assignments||{}),s.user.stickyBucketAssignmentDocs[n]&&Object.assign(u,s.user.stickyBucketAssignmentDocs[n].assignments||{}),u}function ib(s,e,t,i){let r=Do(e,t),n=s.user.stickyBucketAssignmentDocs&&s.user.stickyBucketAssignmentDocs[r]?s.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...i},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:t,assignments:o},changed:a}}function rb(s,e){let t=new Set,i=e&&e.features?e.features:s.global.features||{},r=e&&e.experiments?e.experiments:s.global.experiments||[];return Object.keys(i).forEach(n=>{let o=i[n];if(o.rules)for(let a of o.rules)a.variations&&(t.add(a.hashAttribute||"id"),a.fallbackAttribute&&t.add(a.fallbackAttribute))}),r.map(n=>{t.add(n.hashAttribute||"id"),n.fallbackAttribute&&t.add(n.fallbackAttribute)}),Array.from(t)}async function td(s,e,t){let i=No(s,t);return e.getAllAssignments(i)}function No(s,e){let t={};return rb(s,e).forEach(r=>{let{hashValue:n}=Yt(s,r);t[r]=ei(n)}),t}async function sd(s,e,t){if(s={...s},s.encryptedFeatures){try{s.features=JSON.parse(await Xt(s.encryptedFeatures,e,t))}catch(i){console.error(i)}delete s.encryptedFeatures}if(s.encryptedExperiments){try{s.experiments=JSON.parse(await Xt(s.encryptedExperiments,e,t))}catch(i){console.error(i)}delete s.encryptedExperiments}if(s.encryptedSavedGroups){try{s.savedGroups=JSON.parse(await Xt(s.encryptedSavedGroups,e,t))}catch(i){console.error(i)}delete s.encryptedSavedGroups}return s}function id(s){let e=s.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(s.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:s.apiHostRequestHeaders,streamingHostRequestHeaders:s.streamingHostRequestHeaders}}function Tr(s,e){return e.hashAttribute+e.hashValue+s.key+e.variationId}var qy,Wy,rd=Fe(()=>{"use strict";Yc();ti();qy="Feature Evaluated",Wy="Experiment Viewed"});var ks,nb,ni,nd=Fe(()=>{"use strict";zc();ti();Lc();rd();ks=typeof window<"u"&&typeof document<"u",nb=Ac(),ni=class{constructor(e){if(e=e||{},this.version=nb,this._options=this.context=e,this._renderer=e.renderer||null,this._trackedExperiments=new Set,this._completedChangeIds=new Set,this._trackedFeatures={},this.debug=!!e.debug,this._subscriptions=new Set,this.ready=!1,this._assigned=new Map,this._activeAutoExperiments=new Map,this._triggeredExpKeys=new Set,this._initialized=!1,this._redirectedUrl="",this._deferredTrackingCalls=new Map,this._autoExperimentsAllowed=!e.disableExperimentsOnLoad,this._destroyCallbacks=[],this.logs=[],this.log=this.log.bind(this),this._saveDeferredTrack=this._saveDeferredTrack.bind(this),this._onExperimentEval=this._onExperimentEval.bind(this),this._fireSubscriptions=this._fireSubscriptions.bind(this),this._recordChangedId=this._recordChangedId.bind(this),e.remoteEval){if(e.decryptionKey)throw new Error("Encryption is not available for remoteEval");if(!e.clientKey)throw new Error("Missing clientKey");let t=!1;try{t=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(t)throw new Error("Cannot use remoteEval on GrowthBook Cloud")}else if(e.cacheKeyAttributes)throw new Error("cacheKeyAttributes are only used for remoteEval");if(e.stickyBucketService){let t=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>t.saveAssignments(i)}if(e.plugins)for(let t of e.plugins)t(this);if(e.features&&(this.ready=!0),ks&&e.enableDevMode&&(window._growthbook=this,document.dispatchEvent(new Event("gbloaded"))),e.experiments&&(this.ready=!0,this._updateAllAutoExperiments()),this._options.stickyBucketService&&this._options.stickyBucketAssignmentDocs)for(let t in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[t];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let t=await sd(e,this._options.decryptionKey);this._decryptedPayload=t,await this.refreshStickyBuckets(t),t.features&&(this._options.features=t.features),t.savedGroups&&(this._options.savedGroups=t.savedGroups),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let t=e.payload;if(t.encryptedExperiments||t.encryptedFeatures)throw new Error("initSync does not support encrypted payloads");return this._options.stickyBucketService&&!this._options.stickyBucketAssignmentDocs&&(this._options.stickyBucketAssignmentDocs=this.generateStickyBucketAssignmentDocsSync(this._options.stickyBucketService,t)),this._payload=t,this._decryptedPayload=t,t.features&&(this._options.features=t.features),t.experiments&&(this._options.experiments=t.experiments,this._updateAllAutoExperiments()),this.ready=!0,pr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Oc(e.cacheSettings),e.payload)return await this.setPayload(e.payload),pr(this,e),{success:!0,source:"init"};{let{data:t,...i}=await this._refresh({...e,allowStale:!0});return pr(this,e),await this.setPayload(t||{}),i}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let t=await this._refresh({...e||{},allowStale:!1});t.data&&await this.setPayload(t.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return id(this._options)}getClientKey(){return this._options.clientKey||""}getPayload(){return this._payload||{features:this.getFeatures(),experiments:this.getExperiments()}}getDecryptedPayload(){return this._decryptedPayload||this.getPayload()}isRemoteEval(){return this._options.remoteEval||!1}getCacheKeyAttributes(){return this._options.cacheKeyAttributes}async _refresh({timeout:e,skipCache:t,allowStale:i,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Pc({instance:this,timeout:e,skipCache:t||this._options.disableCache,allowStale:i,backgroundSync:r??this._options.backgroundSync??!0})}_render(){if(this._renderer)try{this._renderer()}catch(e){console.error("Failed to render",e)}}setFeatures(e){this._options.features=e,this.ready=!0,this._render()}async setEncryptedFeatures(e,t,i){let r=await Xt(e,t||this._options.decryptionKey,i);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,t,i){let r=await Xt(e,t||this._options.decryptionKey,i);this.setExperiments(JSON.parse(r))}async setAttributes(e){if(this._options.attributes=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async updateAttributes(e){return this.setAttributes({...this._options.attributes,...e})}async setAttributeOverrides(e){if(this._options.attributeOverrides=e,this._options.stickyBucketService&&await this.refreshStickyBuckets(),this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}async setForcedVariations(e){if(this._options.forcedVariations=e||{},this._options.remoteEval){await this._refreshForRemoteEval();return}this._render(),this._updateAllAutoExperiments()}setForcedFeatures(e){this._options.forcedFeatureValues=e,this._render()}async setURL(e){if(e!==this._options.url){if(this._options.url=e,this._redirectedUrl="",this._options.remoteEval){await this._refreshForRemoteEval(),this._updateAllAutoExperiments(!0);return}this._updateAllAutoExperiments(!0)}}getAttributes(){return{...this._options.attributes,...this._options.attributeOverrides}}getForcedVariations(){return this._options.forcedVariations||{}}getForcedFeatures(){return this._options.forcedFeatureValues||new Map}getStickyBucketAssignmentDocs(){return this._options.stickyBucketAssignmentDocs||{}}getUrl(){return this._options.url||""}getFeatures(){return this._options.features||{}}getExperiments(){return this._options.experiments||[]}getCompletedChangeIds(){return Array.from(this._completedChangeIds)}subscribe(e){return this._subscriptions.add(e),()=>{this._subscriptions.delete(e)}}async _refreshForRemoteEval(){if(!this._options.remoteEval||!this._initialized)return;let e=await this._refresh({allowStale:!1});e.data&&await this.setPayload(e.data)}getAllResults(){return new Map(this._assigned)}onDestroy(e){this._destroyCallbacks.push(e)}isDestroyed(){return!!this._destroyed}destroy(e){e=e||{},this._destroyed=!0,this._destroyCallbacks.forEach(t=>{try{t()}catch(i){console.error(i)}}),this._subscriptions.clear(),this._assigned.clear(),this._trackedExperiments.clear(),this._completedChangeIds.clear(),this._deferredTrackingCalls.clear(),this._trackedFeatures={},this._destroyCallbacks=[],this._payload=void 0,this._saveStickyBucketAssignmentDoc=void 0,Cc(this),e.destroyAllStreams&&Ao(),this.logs=[],ks&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(t=>{t.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,t){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=t,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:t}=Ar(e,null,this._getEvalContext());return this._onExperimentEval(e,t),t}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(i=>i.key===e).map(i=>this._runAutoExperiment(i)).filter(i=>i!==null):null}triggerAutoExperiments(){this._autoExperimentsAllowed=!0,this._updateAllAutoExperiments(!0)}_getEvalContext(){return{user:this._getUserContext(),global:this._getGlobalContext(),stack:{evaluatedFeatures:new Set}}}_getUserContext(){return{attributes:this._options.user?{...this._options.user,...this._options.attributes}:this._options.attributes,enableDevMode:this._options.enableDevMode,blockedChangeIds:this._options.blockedChangeIds,stickyBucketAssignmentDocs:this._options.stickyBucketAssignmentDocs,url:this._getContextUrl(),forcedVariations:this._options.forcedVariations,forcedFeatureValues:this._options.forcedFeatureValues,attributeOverrides:this._options.attributeOverrides,saveStickyBucketAssignmentDoc:this._saveStickyBucketAssignmentDoc,trackingCallback:this._options.trackingCallback,onFeatureUsage:this._options.onFeatureUsage,devLogs:this.logs,trackedExperiments:this._trackedExperiments,trackedFeatureUsage:this._trackedFeatures}}_getGlobalContext(){return{features:this._options.features,experiments:this._options.experiments,log:this.log,enabled:this._options.enabled,qaMode:this._options.qaMode,savedGroups:this._options.savedGroups,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,t){let i=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!i)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=ue(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=Ar(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!t&&n.inExperiment&&i&&i.valueHash===a)return n;if(i&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=hr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let u=e.persistQueryString?Tc(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(dr(u,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=u;let{navigate:d,delay:h}=this._getNavigateFunction();if(d)if(ks)Promise.all([...o?[gr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??h))]).then(()=>{try{d(u)}catch(f){console.error(f)}});else try{d(u)}catch(f){console.error(f)}}else if(l==="visual"){let u=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(n.value):this._applyDOMChanges(n.value);u&&this._activeAutoExperiments.set(e,{undo:u,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let t=this._activeAutoExperiments.get(e);t&&(t.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let t=this._options.experiments||[],i=new Set(t);this._activeAutoExperiments.forEach((r,n)=>{i.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of t){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&hr(r)==="redirect")break}}_onExperimentEval(e,t){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:t}),this._subscriptions.size>0&&this._fireSubscriptions(e,t,i)}_fireSubscriptions(e,t,i){(!i||i.result.inExperiment!==t.inExperiment||i.result.variationId!==t.variationId)&&this._subscriptions.forEach(r=>{try{r(e,t)}catch(n){console.error(n)}})}_recordChangedId(e){this._completedChangeIds.add(e)}isOn(e){return this.evalFeature(e).on}isOff(e){return this.evalFeature(e).off}getFeatureValue(e,t){let i=this.evalFeature(e).value;return i===null?t:i}feature(e){return this.evalFeature(e)}evalFeature(e){return wr(e,this._getEvalContext())}log(e,t){this.debug&&(this._options.log?this._options.log(e,t):console.log(e,t))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(t=>t&&t.experiment&&t.result).map(t=>[Tr(t.experiment,t.result),t]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(t=>{!t||!t.experiment||!t.result?console.error("Invalid deferred tracking call",{call:t}):e.push(this._options.trackingCallback(t.experiment,t.result))}),this._deferredTrackingCalls.clear(),await Promise.all(e)}setTrackingCallback(e){this._options.trackingCallback=e,this.fireDeferredTrackingCalls()}setFeatureUsageCallback(e){this._options.onFeatureUsage=e}setEventLogger(e){this._options.eventLogger=e}async logEvent(e,t){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:t,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,t||{},this._getUserContext())}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Tr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(ks?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let t=hr(e);if(t==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(t==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let i=new URL(this._getContextUrl());for(let r of e.variations){if(!r||!r.urlRedirect)continue;let n=new URL(r.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(n.protocol!==i.protocol||n.host!==i.host))return!0}}catch(i){return this.log("Error parsing current or redirect URL",{id:e.key,error:i}),!0}}else return!0;return!!(e.changeId&&(this._options.blockedChangeIds||[]).includes(e.changeId))}getRedirectUrl(){return this._redirectedUrl}_getNavigateFunction(){return this._options.navigate?{navigate:this._options.navigate,delay:0}:ks?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!ks)return;let t=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),t.push(()=>i.remove())}if(e.js){let i=document.createElement("script");i.innerHTML=e.js,this._options.jsInjectionNonce&&(i.nonce=this._options.jsInjectionNonce),document.head.appendChild(i),t.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{t.push(jc.declarative(i).revert)}),()=>{t.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let t=this._getEvalContext(),i=await td(t,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,t){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),r=No(i,t);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var od=Fe(()=>{"use strict";nd()});var ad={};_n(ad,{Growthbook:()=>xo});var Ye,xo,ld=Fe(()=>{"use strict";od();fo();Ys();Qs();Ye=class Ye{constructor(e,t,i={},r=!1){this.analytics=new gs;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Dt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:t,user_language:i,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:u,url:d,domain:h,utm_content:f,residence_country:g,loggedIn:p,network_type:v,network_downlink:m,user_id:y,anonymous_id:w,account_mode:C})=>{let R={...this.GrowthBook.getAttributes(),id:e,...y!==void 0&&{user_id:y},...w!==void 0&&{anonymous_id:w},...t!==void 0&&{country:t},...g!==void 0&&{residence_country:g},...i!==void 0&&{user_language:i},...r!==void 0&&{device_language:r},...n!==void 0&&{device_type:n},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...u!==void 0&&{is_authorised:u},...d!==void 0&&{url:d},...h!==void 0&&{domain:h},...f!==void 0&&{utm_content:f},...p!==void 0&&{loggedIn:p},...v!==void 0&&{network_type:v},...m!==void 0&&{network_downlink:m},...C!==void 0&&{account_mode:C}};this.log("setAttributes | updating GrowthBook attributes",R),this.GrowthBook.setAttributes(R)};this.getFeatureValue=(e,t)=>{let i=this.GrowthBook.getFeatureValue(e,t);return this.log("getFeatureValue",{key:e,value:i,defaultValue:t}),i};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let t=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:t}),t};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let t=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:t}),t};this.init=async()=>{this.log("init | initializing GrowthBook SDK");let e=await this.GrowthBook.init({timeout:2e3,streaming:!0}).catch(()=>{});this.status=e,this.isLoaded=!0,this.log("init | GrowthBook SDK loaded",{status:e})};this.destroy=()=>{this.GrowthBook.destroy(),this.isLoaded=!1,this.status=void 0};this.debug=r;let n=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new ni({apiHost:tc,clientKey:e,decryptionKey:t,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:n,trackingCallback:(o,a)=>{this.log("trackingCallback | experiment viewed",{experiment_id:o.key,variation_id:a.variationId}),typeof window<"u"&&window.dataLayer&&window.dataLayer.push({event:"experiment_viewed",event_category:"experiment",rudder_anonymous_id:this.analytics.getAnonymousId(),experiment_id:o.key,variation_id:a.variationId}),this.analytics.track("experiment_viewed",{experimentId:o.key,variationId:a.variationId})},...i}),this.init()}reapplyExperiment(e){let t=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(t)}waitForIsLoaded(e=1e4){return new Promise((t,i)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),t()):Date.now()-r>=e&&(clearInterval(n),i(new Error("GrowthBook initialization timeout")))},100)})}};Ye.getGrowthBookInstance=(e,t,i,r=!1)=>Ye._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),Ye._instance):(Ye._instance=new Ye(e,t??"",i,r),Ye._instance),Ye.resetInstance=()=>{Ye._instance&&(Ye._instance.destroy(),Ye._instance=void 0)};xo=Ye});function dd(s,e,t,i,r,n,o){try{var a=s[n](o),l=a.value}catch(u){return void t(u)}a.done?e(l):Promise.resolve(l).then(i,r)}function it(s){return function(){var e=this,t=arguments;return new Promise((function(i,r){var n=s.apply(e,t);function o(l){dd(n,i,r,o,a,"next",l)}function a(l){dd(n,i,r,o,a,"throw",l)}o(void 0)}))}}function k(){return k=Object.assign?Object.assign.bind():function(s){for(var e=1;arguments.length>e;e++){var t=arguments[e];for(var i in t)({}).hasOwnProperty.call(t,i)&&(s[i]=t[i])}return s},k.apply(null,arguments)}function fh(s,e){if(s==null)return{};var t={};for(var i in s)if({}.hasOwnProperty.call(s,i)){if(e.indexOf(i)!==-1)continue;t[i]=s[i]}return t}function ph(){return(ph=it((function*(s,e,t){e===void 0&&(e=!0);try{var i=new Blob([s],{type:"text/plain"}).stream().pipeThrough(new CompressionStream("gzip"));return yield new Response(i).blob()}catch(r){if(t!=null&&t.rethrow)throw r;return e&&console.error("Failed to gzip compress data",r),null}}))).apply(this,arguments)}function j(s,e){return s.indexOf(e)!==-1}function mh(s){return s===null||typeof s!="object"}function Br(s,e){return{}.toString.call(s)==="[object "+e+"]"}function rl(s){return typeof Event<"u"&&(function(e,t){try{return e instanceof t}catch{return!1}})(s,Event)}function gt(s,e,t,i,r){return e>t&&(i.warn("min cannot be greater than max."),e=t),nt(s)?s>t?(i.warn(" cannot be greater than max: "+t+". Using max value instead."),t):e>s?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):s:(i.warn(" must be a number. using max or fallback. max: "+t+", fallback: "+r),gt(r||t,e,t,i))}function Sb(s){var e=globalThis._posthogChunkIds;if(e){var t=Object.keys(e);return $o&&t.length===gd||(gd=t.length,$o=t.reduce(((i,r)=>{Rr||(Rr={});var n=Rr[r];if(n)i[n[0]]=n[1];else for(var o=s(r),a=o.length-1;a>=0;a--){var l=o[a],u=l?.filename,d=e[r];if(u&&d){i[u]=d,Rr[r]=[u,d];break}}return i}),{})),$o}}function ca(s,e,t,i,r){var n={platform:s,filename:e,function:t==="<anonymous>"?Fs:t,in_app:!0};return P(i)||(n.lineno=i),P(r)||(n.colno=r),n}function $h(s,e){e===void 0&&(e=40);var t=Object.keys(s);if(t.sort(),!t.length)return"[object has no keys]";for(var i=t.length;i>0;i--){var r=t.slice(0,i).join(", ");if(e>=r.length)return i===t.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function Cr(s,e){W(s)&&s.forEach(e)}function oe(s,e){if(!z(s))if(W(s))s.forEach(e);else if(ub(s))s.forEach(((i,r)=>e(i,r)));else for(var t in s)_h.call(s,t)&&e(s[t],t)}function Mr(s){for(var e=Object.keys(s),t=e.length,i=new Array(t);t--;)i[t]=[e[t],s[e[t]]];return i}function Fb(s){var e=s?.hostname;if(!ye(e))return!1;var t=e.split(".").slice(-2).join(".");for(var i of $b)if(t===i)return!1;return!0}function me(s,e,t,i){var{capture:r=!1,passive:n=!0}=i??{};s?.addEventListener(e,t,{capture:r,passive:n})}function Gh(s){return s.name==="ph_toolbar_internal"}function zh(s,e){var{organization:t,projectId:i,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,u,d,h,f;if(n!=="*"&&!n.includes(a.level)||!s.__loaded)return a;a.tags||(a.tags={});var g=s.requestRouter.endpointFor("ui","/project/"+s.config.token+"/person/"+s.get_distinct_id());a.tags["PostHog Person URL"]=g,s.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=s.get_session_replay_url({withTimestamp:!0}));var p,v=((l=a.exception)==null?void 0:l.values)||[],m=v.map((w=>k({},w,{stacktrace:w.stacktrace?k({},w.stacktrace,{type:"raw",frames:(w.stacktrace.frames||[]).map((C=>k({},C,{platform:"web:javascript"})))}):void 0}))),y={$exception_message:((u=v[0])==null?void 0:u.value)||a.message,$exception_type:(d=v[0])==null?void 0:d.type,$exception_level:a.level,$exception_list:m,$sentry_event_id:a.event_id,$sentry_exception:a.exception,$sentry_exception_message:((h=v[0])==null?void 0:h.value)||a.message,$sentry_exception_type:(f=v[0])==null?void 0:f.type,$sentry_tags:a.tags};return t&&i&&(y.$sentry_url=(r||"https://sentry.io/organizations/")+t+"/issues/?project="+i+"&query="+a.event_id),o&&((p=s.exceptions)==null||p.sendExceptionEvent(y)),a}}function qh(s,e,t){if(!T)return{};var i,r=e?[...Ms,...t||[]]:[],n=Wh(Oi(T.URL,r,Pi),s),o=(i={},oe(zb,(function(a){var l=dt.Gt(a);i[a]=l||null})),i);return pe(o,n)}function Wh(s,e){var t=jb.concat(e||[]),i={};return oe(t,(function(r){var n=Qr(s,r);i[r]=n||null})),i}function Kh(s){var e=(function(n){return n?n.search(xr+"google.([^/?]*)")===0?"google":n.search(xr+"bing.com")===0?"bing":n.search(xr+"yahoo.com")===0?"yahoo":n.search(xr+"duckduckgo.com")===0?"duckduckgo":null:null})(s),t=e!="yahoo"?"q":"p",i={};if(!Rt(e)){i.$search_engine=e;var r=T?Qr(T.referrer,t):"";r.length&&(i.ph_keyword=r)}return i}function Rd(){return navigator.language||navigator.userLanguage}function Xh(){return T?.referrer||en}function Yh(s,e){var t=s?[...Ms,...e||[]]:[],i=Re?.href.substring(0,1e3);return{r:Xh().substring(0,1e3),u:i?Oi(i,t,Pi):void 0}}function Jh(s){var e,{r:t,u:i}=s,r={$referrer:t,$referring_domain:t==null?void 0:t==en?en:(e=Jr(t))==null?void 0:e.host};if(i){r.$current_url=i;var n=Jr(i);r.$host=n?.host,r.$pathname=n?.pathname;var o=Wh(i);pe(r,o)}if(t){var a=Kh(t);pe(r,a)}return r}function Qh(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function qb(){try{return new Date().getTimezoneOffset()}catch{return}}function Zb(s,e){e===void 0&&(e={});var t=(function(){var h=4294967295;return{p(f){for(var g=h,p=0;f.length>p;++p)g=Qb[255&g^f[p]]^g>>>8;h=g},d(){return 4294967295^h}}})(),i=s.length;t.p(s);var r,n,o,a,l,u=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(h,f,g,p,v,m){var y=h.length,w=new Qe(p+y+5*(1+Math.floor(y/7e3))+v),C=w.subarray(p,w.length-v),D=0;if(!f||8>y)for(var R=0;y>=R;R+=65535){var N=R+65535;y>N?D=Ba(C,D,h.subarray(R,N)):(C[R]=!0,D=Ba(C,D,h.subarray(R,y)))}else{for(var O=Jb[f-1],E=O>>>13,S=8191&O,$=(1<<g)-1,F=new $e(32768),G=new $e($+1),K=Math.ceil(g/3),X=2*K,ve=function(vn){return(h[vn]^h[vn+1]<<K^h[vn+2]<<X)&$},ke=new Us(25e3),Ce=new $e(288),ae=new $e(32),A=0,M=0,U=(R=0,0),B=0,Z=0;y>R;++R){var de=ve(R),ie=32767&R,_e=G[de];if(F[ie]=_e,G[de]=ie,R>=B){var Oe=y-R;if((A>7e3||U>24576)&&Oe>423){D=Dd(h,C,0,ke,Ce,ae,M,U,Z,R-Z,D),U=A=M=0,Z=R;for(var Se=0;286>Se;++Se)Ce[Se]=0;for(Se=0;30>Se;++Se)ae[Se]=0}var H=2,ft=0,Sg=S,It=ie-_e&32767;if(Oe>2&&de==ve(R-It))for(var wg=Math.min(E,Oe)-1,Ag=Math.min(32767,R),Tg=Math.min(258,Oe);Ag>=It&&--Sg&&ie!=_e;){if(h[R+H]==h[R+H-It]){for(var Ot=0;Tg>Ot&&h[R+Ot]==h[R+Ot-It];++Ot);if(Ot>H){if(H=Ot,ft=It,Ot>wg)break;var Rg=Math.min(It,Ot-2),vl=0;for(Se=0;Rg>Se;++Se){var pn=R-It+Se+32768&32767,_l=pn-F[pn]+32768&32767;_l>vl&&(vl=_l,_e=pn)}}}It+=(ie=_e)-(_e=F[ie])+32768&32767}if(ft){ke[U++]=268435456|Fa[H]<<18|Ma[ft];var ml=31&Fa[H],yl=31&Ma[ft];M+=dl[ml]+hl[yl],++Ce[257+ml],++ae[yl],B=R+H,++A}else ke[U++]=h[R],++Ce[h[R]]}}D=Dd(h,C,!0,ke,Ce,ae,M,U,Z,R-Z,D)}return sg(w,0,p+tg(D)+v)})(n=s,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(n.length)))):12+o.mem,a,l)),d=u.length;return(function(h,f){var g=f.filename;if(h[0]=31,h[1]=139,h[2]=8,h[8]=2>f.level?4:f.level==9?2:0,h[9]=3,f.mtime!=0&&zo(h,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),g){h[3]=8;for(var p=0;g.length>=p;++p)h[p+10]=g.charCodeAt(p)}})(u,e),zo(u,d-8,t.d()),zo(u,d-4,i),u}function Ld(s,e,t){return Ds({distinct_id:s,userPropertiesToSet:e,userPropertiesToSetOnce:t})}function og(s,e){return!s||Object.entries(s).every((t=>{var[i,r]=t,n=e?.[i];if(P(n)||Rt(n))return!1;var o=[String(n)],a=ng[r.operator];return!!a&&a(r.values,o)}))}function Gd(s){return s instanceof Element&&(s.id===Vh||!(s.closest==null||!s.closest(".toolbar-global-fade-container")))}function gn(s){return!!s&&s.nodeType===1}function Bt(s,e){return!!s&&!!s.tagName&&s.tagName.toLowerCase()===e.toLowerCase()}function ug(s){return!!s&&s.nodeType===3}function cg(s){return!!s&&s.nodeType===11}function gl(s){return s?cn(s).split(/\s+/):[]}function Hd(s){var e=_?.location.href;return!!(e&&s&&s.some((t=>e.match(t))))}function ln(s){var e="";switch(typeof s.className){case"string":e=s.className;break;case"object":e=(s.className&&"baseVal"in s.className?s.className.baseVal:null)||s.getAttribute("class")||"";break;default:e=""}return gl(e)}function dg(s){return z(s)?null:cn(s).split(/(\s+)/).filter((e=>Ti(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Di(s){var e="";return Qa(s)&&!gg(s)&&s.childNodes&&s.childNodes.length&&oe(s.childNodes,(function(t){var i;ug(t)&&t.textContent&&(e+=(i=dg(t.textContent))!==null&&i!==void 0?i:"")})),cn(e)}function jd(s){return P(s.target)?s.srcElement||null:(e=s.target)!=null&&e.shadowRoot?s.composedPath()[0]||null:s.target||null;var e}function zd(s,e){if(P(e))return!0;var t,i=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of s)if(t=i(r))return t.v;return!1}function hg(s){var e=s.parentNode;return!(!e||!gn(e))&&e}function Qa(s){for(var e=s;e.parentNode&&!Bt(e,"body");e=e.parentNode){var t=ln(e);if(j(t,"ph-sensitive")||j(t,"ph-no-capture"))return!1}if(j(ln(s),"ph-include"))return!0;var i=s.type||"";if(ye(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}var r=s.name||s.id||"";return!ye(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 gg(s){return!!(Bt(s,"input")&&!["button","checkbox","submit","reset"].includes(s.type)||Bt(s,"select")||Bt(s,"textarea")||s.getAttribute("contenteditable")==="true")}function Ti(s,e){return e===void 0&&(e=!0),!(z(s)||ye(s)&&(s=cn(s),(e?hE:gE).test((s||"").replace(/[- ]/g,""))||(e?fE:pE).test(s)))}function Kd(s){var e=Di(s);return Ti(e=(e+" "+vg(s)).trim())?e:""}function vg(s){var e="";return s&&s.childNodes&&s.childNodes.length&&oe(s.childNodes,(function(t){var i;if(t&&((i=t.tagName)==null?void 0:i.toLowerCase())==="span")try{var r=Di(t);e=(e+" "+r).trim(),t.childNodes&&t.childNodes.length&&(e=(e+" "+vg(t)).trim())}catch(n){I.error("[AutoCapture]",n)}})),e}function Xd(s){return s.replace(/"|\\"/g,'\\"')}function vE(s){var e=s.attr__class;return e?W(e)?e:gl(e):void 0}function Yo(s,e){return e.length>s?e.slice(0,s)+"...":e}function _E(s){if(s.previousElementSibling)return s.previousElementSibling;var e=s;do e=e.previousSibling;while(e&&!gn(e));return e}function mE(s,e){for(var t,i,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e,u=[s],d=s;d.parentNode&&!Bt(d,"body");)cg(d.parentNode)?(u.push(d.parentNode.host),d=d.parentNode.host):(u.push(d.parentNode),d=d.parentNode);var h,f,g=[],p={},v=!1,m=!1;if(oe(u,(R=>{var N=Qa(R);R.tagName.toLowerCase()==="a"&&(v=R.getAttribute("href"),v=N&&v&&Ti(v)&&v),j(ln(R),"ph-no-capture")&&(m=!0),g.push((function(E,S,$,F){var G=E.tagName.toLowerCase(),K={tag_name:G};fl.indexOf(G)>-1&&!$&&(K.$el_text=G.toLowerCase()==="a"||G.toLowerCase()==="button"?Yo(1024,Kd(E)):Yo(1024,Di(E)));var X=ln(E);X.length>0&&(K.classes=X.filter((function(ae){return ae!==""}))),oe(E.attributes,(function(ae){var A;if((!gg(E)||["name","id","class","aria-label"].indexOf(ae.name)!==-1)&&(F==null||!F.includes(ae.name))&&!S&&Ti(ae.value)&&(!ye(A=ae.name)||A.substring(0,10)!=="_ngcontent"&&A.substring(0,7)!=="_nghost")){var M=ae.value;ae.name==="class"&&(M=gl(M).join(" ")),K["attr__"+ae.name]=Yo(1024,M)}}));for(var ve=1,ke=1,Ce=E;Ce=_E(Ce);)ve++,Ce.tagName===E.tagName&&ke++;return K.nth_child=ve,K.nth_of_type=ke,K})(R,n,o,a));var O=(function(E){if(!Qa(E))return{};var S={};return oe(E.attributes,(function($){if($.name&&$.name.indexOf("data-ph-capture-attribute")===0){var F=$.name.replace("data-ph-capture-attribute-",""),G=$.value;F&&G&&Ti(G)&&(S[F]=G)}})),S})(R);pe(p,O)})),m)return{props:{},explicitNoCapture:m};if(o||(g[0].$el_text=s.tagName.toLowerCase()==="a"||s.tagName.toLowerCase()==="button"?Kd(s):Di(s)),v){var y,w;g[0].attr__href=v;var C=(y=Jr(v))==null?void 0:y.host,D=_==null||(w=_.location)==null?void 0:w.host;C&&D&&C!==D&&(h=v)}return{props:pe({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(f=g,(function(R){return R.map((N=>{var O,E,S="";if(N.tag_name&&(S+=N.tag_name),N.attr_class)for(var $ of(N.attr_class.sort(),N.attr_class))S+="."+$.replace(/"/g,"");var F=k({},N.text?{text:N.text}:{},{"nth-child":(O=N.nth_child)!==null&&O!==void 0?O:0,"nth-of-type":(E=N.nth_of_type)!==null&&E!==void 0?E:0},N.href?{href:N.href}:{},N.attr_id?{attr_id:N.attr_id}:{},N.attributes),G={};return Mr(F).sort(((K,X)=>{var[ve]=K,[ke]=X;return ve.localeCompare(ke)})).forEach((K=>{var[X,ve]=K;return G[Xd(X.toString())]=Xd(ve.toString())})),(S+=":")+Mr(G).map((K=>{var[X,ve]=K;return X+'="'+ve+'"'})).join("")})).join(";")})((function(R){return R.map((N=>{var O,E,S={text:(O=N.$el_text)==null?void 0:O.slice(0,400),tag_name:N.tag_name,href:(E=N.attr__href)==null?void 0:E.slice(0,2048),attr_class:vE(N),attr_id:N.attr__id,nth_child:N.nth_child,nth_of_type:N.nth_of_type,attributes:{}};return Mr(N).filter(($=>{var[F]=$;return F.indexOf("attr__")===0})).forEach(($=>{var[F,G]=$;return S.attributes[F]=G})),S}))})(f)))},(t=g[0])!=null&&t.$el_text?{$el_text:(i=g[0])==null?void 0:i.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},p)}}function Jd(s,e,t){try{if(!(e in s))return()=>{};var i=s[e],r=t(i);return At(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),s[e]=r,()=>{s[e]=i}}catch{return()=>{}}}function th(s){return be(s)&&"clientX"in s&&"clientY"in s&&nt(s.clientX)&&nt(s.clientY)}function Ts(s,e,t){if(z(s))return!1;switch(t){case"exact":return s===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(s);case"regex":try{return new RegExp(e).test(s)}catch{return!1}default:return!1}}function mg(s){if(ht(s))return{boolValue:s};if(nt(s))return Number.isInteger(s)?{intValue:s}:{doubleValue:s};if(typeof s=="string")return{stringValue:s};if(W(s))return{arrayValue:{values:s.map((e=>mg(e)))}};try{return{stringValue:JSON.stringify(s)}}catch{return{stringValue:String(s)}}}function hh(s){var e=[];for(var t in s){var i=s[t];Rt(i)||P(i)||e.push({key:t,value:mg(i)})}return e}var _,Ee,qe,T,Re,sa,ia,ud,ob,Ge,L,cd,Le,ab,lb,hd,cn,ra,vh,_h,dn,W,At,be,Ps,P,ye,Fr,Rt,z,nt,Rs,ht,ub,cb,db,Lo,hb,na,Rr,gd,$o,We,Vr,Tt,Ls,yh,bh,Eh,kh,Ei,$s,Sh,wh,Ah,ss,gb,Th,nl,Rh,ol,fb,al,Ih,Ns,Oh,Ri,Ii,xs,Ph,Ch,pi,oa,fd,aa,Dh,pb,Nh,la,xe,Fo,vb,_b,mb,ll,yb,xh,bb,Eb,pd,vd,kb,ua,Fs,Lh,wb,Ab,Tb,Rb,Ib,Ob,Pb,_d,da,ha,ga,Cb,fa,Db,pa,va,_a,ma,Fh,I,ce,Nb,Ir,Mh,Gr,vi,_i,md,ya,yd,ba,bd,Ed,Uh,kd,Sd,Or,Hr,Bh,Cs,mi,Ea,yi,ts,ka,ki,Sa,wa,jr,st,Aa,Ta,Ra,Ia,zr,qr,Vh,Pr,xb,ul,wt,rt,Ss,ws,Oa,Wr,Kr,Is,Mo,Uo,wd,pe,Ad,Lb,cl,$b,Pa,Ca,Td,Hh,Da,Ut,Mb,oi,Ub,dt,Bo,ge,Bb,Dr,Vb,Jt,Ie,Na,Nr,Gb,Hb,Xr,Vo,jh,xa,Yr,Jr,Qr,Oi,Zr,xr,Ms,jb,Pi,zb,en,Wb,Si,ai,Go,bi,Ho,La,Kb,Id,Od,$a,li,tn,ct,Qe,$e,Us,dl,hl,Pd,Zh,eg,Fa,Qt,Ma,sn,se,wi,rs,rn,Xb,Yb,tg,sg,St,ui,jo,Ua,Cd,ci,Ba,Dd,Jb,Qb,zo,eE,ig,Nd,hn,Ds,qo,tE,xd,Ur,Va,Ga,sE,Ha,ja,iE,nn,Ci,Wo,on,rg,an,ng,Lr,za,$d,qa,te,Wa,rE,Fd,nE,oE,aE,lE,Ka,As,Ai,Ko,Xa,Md,di,Ud,ag,uE,Os,lg,Bd,cE,Vd,Ya,is,fl,dE,qd,Ja,Wd,fg,hE,gE,pg,fE,pE,un,Xo,Yd,hi,yE,Lt,Qd,Zd,eh,gi,$r,Za,$t,bE,sh,Jo,EE,Ft,ih,el,tl,sl,Qo,rh,kE,nh,oh,Ne,Zt,Zo,ea,Mt,ah,fi,lh,uh,ch,ta,dh,SE,il,Je,es,_g,wE,fn,AE,TE,RE,IE,OE,PE,CE,DE,NE,xE,LE,$E,gh,He,yg=Fe(()=>{"use strict";_=typeof window<"u"?window:void 0,Ee=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(Ee.self=Ee),typeof File>"u"&&(Ee.File=function(){});qe=Ee?.navigator,T=Ee?.document,Re=Ee?.location,sa=Ee?.fetch,ia=Ee!=null&&Ee.XMLHttpRequest&&"withCredentials"in new Ee.XMLHttpRequest?Ee.XMLHttpRequest:void 0,ud=Ee?.AbortController,ob=Ee?.CompressionStream,Ge=qe?.userAgent,L=_??{},cd="1.369.0",Le={DEBUG:!1,LIB_VERSION:cd,LIB_NAME:"web",JS_SDK_VERSION:cd};ab=["$snapshot","$pageview","$pageleave","$set","survey dismissed","survey sent","survey shown","$identify","$groupidentify","$create_alias","$$client_ingestion_warning","$web_experiment_applied","$feature_enrollment_update","$feature_flag_called"],lb=["amazonbot","amazonproductbot","app.hypefactors.com","applebot","archive.org_bot","awariobot","backlinksextendedbot","baiduspider","bingbot","bingpreview","chrome-lighthouse","dataforseobot","deepscan","duckduckbot","facebookexternal","facebookcatalog","http://yandex.com/bots","hubspot","ia_archiver","leikibot","linkedinbot","meta-externalagent","mj12bot","msnbot","nessus","petalbot","pinterest","prerender","rogerbot","screaming frog","sebot-wa","sitebulb","slackbot","slurp","trendictionbot","turnitin","twitterbot","vercel-screenshot","vercelbot","yahoo! slurp","yandexbot","zoombot","bot.htm","bot.php","(bot;","bot/","crawler","ahrefsbot","ahrefssiteaudit","semrushbot","siteauditbot","splitsignalbot","gptbot","oai-searchbot","chatgpt-user","perplexitybot","better uptime bot","sentryuptimebot","uptimerobot","headlesschrome","cypress","google-hoteladsverifier","adsbot-google","apis-google","duplexweb-google","feedfetcher-google","google favicon","google web preview","google-read-aloud","googlebot","googleother","google-cloudvertexbot","googleweblight","mediapartners-google","storebot-google","google-inspectiontool","bytespider"],hd=function(s,e){if(e===void 0&&(e=[]),!s)return!1;var t=s.toLowerCase();return lb.concat(e).some((i=>{var r=i.toLowerCase();return t.indexOf(r)!==-1}))};cn=function(s){return s.trim()},ra=function(s){return s.replace(/^\$/,"")},vh=Object.prototype,_h=vh.hasOwnProperty,dn=vh.toString,W=Array.isArray||function(s){return dn.call(s)==="[object Array]"},At=s=>typeof s=="function",be=s=>s===Object(s)&&!W(s),Ps=s=>{if(be(s)){for(var e in s)if(_h.call(s,e))return!1;return!0}return!1},P=s=>s===void 0,ye=s=>dn.call(s)=="[object String]",Fr=s=>ye(s)&&s.trim().length===0,Rt=s=>s===null,z=s=>P(s)||Rt(s),nt=s=>dn.call(s)=="[object Number]"&&s==s,Rs=s=>nt(s)&&s>0,ht=s=>dn.call(s)==="[object Boolean]",ub=s=>s instanceof FormData,cb=s=>j(ab,s);db=[!0,"true",1,"1","yes"],Lo=s=>j(db,s),hb=[!1,"false",0,"0","no"];na=class{constructor(e){this.Pt={},this.Dt=e.Dt,this.jt=gt(e.bucketSize,0,100,e.qt),this.$t=gt(e.refillRate,0,this.jt,e.qt),this.Vt=gt(e.refillInterval,0,864e5,e.qt)}Ht(e,t){var i=Math.floor((t-e.lastAccess)/this.Vt);i>0&&(e.tokens=Math.min(e.tokens+i*this.$t,this.jt),e.lastAccess=e.lastAccess+i*this.Vt)}consumeRateLimit(e){var t,i=Date.now(),r=String(e),n=this.Pt[r];return n?this.Ht(n,i):this.Pt[r]=n={tokens:this.jt,lastAccess:i},n.tokens===0||(n.tokens--,n.tokens===0&&((t=this.Dt)==null||t.call(this,e)),n.tokens===0)}stop(){this.Pt={}}},We="Mobile",Vr="iOS",Tt="Android",Ls="Tablet",yh=Tt+" "+Ls,bh="iPad",Eh="Apple",kh=Eh+" Watch",Ei="Safari",$s="BlackBerry",Sh="Samsung",wh=Sh+"Browser",Ah=Sh+" Internet",ss="Chrome",gb=ss+" OS",Th=ss+" "+Vr,nl="Internet Explorer",Rh=nl+" "+We,ol="Opera",fb=ol+" Mini",al="Edge",Ih="Microsoft "+al,Ns="Firefox",Oh=Ns+" "+Vr,Ri="Nintendo",Ii="PlayStation",xs="Xbox",Ph=Tt+" "+We,Ch=We+" "+Ei,pi="Windows",oa=pi+" Phone",fd="Nokia",aa="Ouya",Dh="Generic",pb=Dh+" "+We.toLowerCase(),Nh=Dh+" "+Ls.toLowerCase(),la="Konqueror",xe="(\\d+(\\.\\d+)?)",Fo=new RegExp("Version/"+xe),vb=new RegExp(xs,"i"),_b=new RegExp(Ii+" \\w+","i"),mb=new RegExp(Ri+" \\w+","i"),ll=new RegExp($s+"|PlayBook|BB10","i"),yb={"NT3.51":"NT 3.11","NT4.0":"NT 4.0","5.0":"2000",5.1:"XP",5.2:"XP","6.0":"Vista",6.1:"7",6.2:"8",6.3:"8.1",6.4:"10","10.0":"10"},xh=function(s,e){return e=e||"",j(s," OPR/")&&j(s,"Mini")?fb:j(s," OPR/")?ol:ll.test(s)?$s:j(s,"IE"+We)||j(s,"WPDesktop")?Rh:j(s,wh)?Ah:j(s,al)||j(s,"Edg/")?Ih:j(s,"FBIOS")?"Facebook "+We:j(s,"UCWEB")||j(s,"UCBrowser")?"UC Browser":j(s,"CriOS")?Th:j(s,"CrMo")||j(s,ss)?ss:j(s,Tt)&&j(s,Ei)?Ph:j(s,"FxiOS")?Oh:j(s.toLowerCase(),la.toLowerCase())?la:((t,i)=>i&&j(i,Eh)||(function(r){return j(r,Ei)&&!j(r,ss)&&!j(r,Tt)})(t))(s,e)?j(s,We)?Ch:Ei:j(s,Ns)?Ns:j(s,"MSIE")||j(s,"Trident/")?nl:j(s,"Gecko")?Ns:""},bb={[Rh]:[new RegExp("rv:"+xe)],[Ih]:[new RegExp(al+"?\\/"+xe)],[ss]:[new RegExp("("+ss+"|CrMo)\\/"+xe)],[Th]:[new RegExp("CriOS\\/"+xe)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+xe)],[Ei]:[Fo],[Ch]:[Fo],[ol]:[new RegExp("(Opera|OPR)\\/"+xe)],[Ns]:[new RegExp(Ns+"\\/"+xe)],[Oh]:[new RegExp("FxiOS\\/"+xe)],[la]:[new RegExp("Konqueror[:/]?"+xe,"i")],[$s]:[new RegExp($s+" "+xe),Fo],[Ph]:[new RegExp("android\\s"+xe,"i")],[Ah]:[new RegExp(wh+"\\/"+xe)],[nl]:[new RegExp("(rv:|MSIE )"+xe)],Mozilla:[new RegExp("rv:"+xe)]},Eb=function(s,e){var t=xh(s,e),i=bb[t];if(P(i))return null;for(var r=0;i.length>r;r++){var n=s.match(i[r]);if(n)return parseFloat(n[n.length-2])}return null},pd=[[new RegExp(xs+"; "+xs+" (.*?)[);]","i"),s=>[xs,s&&s[1]||""]],[new RegExp(Ri,"i"),[Ri,""]],[new RegExp(Ii,"i"),[Ii,""]],[ll,[$s,""]],[new RegExp(pi,"i"),(s,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[oa,""];if(new RegExp(We).test(e)&&!/IEMobile\b/.test(e))return[pi+" "+We,""];var t=/Windows NT ([0-9.]+)/i.exec(e);if(t&&t[1]){var i=yb[t[1]]||"";return/arm/i.test(e)&&(i="RT"),[pi,i]}return[pi,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,s=>s&&s[3]?[Vr,[s[3],s[4],s[5]||"0"].join(".")]:[Vr,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,s=>{var e="";return s&&s.length>=3&&(e=P(s[2])?s[3]:s[2]),["watchOS",e]}],[new RegExp("("+Tt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Tt+")","i"),s=>s&&s[2]?[Tt,[s[2],s[3],s[4]||"0"].join(".")]:[Tt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,s=>{var e=["Mac OS X",""];return s&&s[1]&&(e[1]=[s[1],s[2],s[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[gb,""]],[/Linux|debian/i,["Linux",""]]],vd=function(s){return mb.test(s)?Ri:_b.test(s)?Ii:vb.test(s)?xs:new RegExp(aa,"i").test(s)?aa:new RegExp("("+oa+"|WPDesktop)","i").test(s)?oa:/iPad/.test(s)?bh:/iPod/.test(s)?"iPod Touch":/iPhone/.test(s)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(s)?kh:ll.test(s)?$s:/(kobo)\s(ereader|touch)/i.test(s)?"Kobo":new RegExp(fd,"i").test(s)?fd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(s)||/(kf[a-z]+)( bui|\)).+silk\//i.test(s)?"Kindle Fire":/(Android|ZTE)/i.test(s)?new RegExp(We).test(s)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(s)||/pixel[\daxl ]{1,6}/i.test(s)&&!/pixel c/i.test(s)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(s)||/lmy47v/i.test(s)&&!/QTAQZ3/i.test(s)?Tt:yh:new RegExp("(pda|"+We+")","i").test(s)?pb:new RegExp(Ls,"i").test(s)&&!new RegExp(Ls+" pc","i").test(s)?Nh:""},kb=s=>s instanceof Error;ua=class{constructor(e,t,i){i===void 0&&(i=[]),this.coercers=e,this.stackParser=t,this.modifiers=i}buildFromUnknown(e,t){t===void 0&&(t={});var i=t&&t.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(i,t,0).apply(e),n=this.buildParsingContext(t),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,i),$exception_level:"error"}}modifyFrames(e){var t=this;return it((function*(){for(var i of e)i.stacktrace&&i.stacktrace.frames&&W(i.stacktrace.frames)&&(i.stacktrace.frames=yield t.applyModifiers(i.stacktrace.frames));return e}))()}coerceFallback(e){var t;return{type:"Error",value:"Unknown error",stack:(t=e.syntheticException)==null?void 0:t.stack,synthetic:!0}}parseStacktrace(e,t){var i,r;return e.cause!=null&&(i=this.parseStacktrace(e.cause,t)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?t.skipFirstLines:0),t.chunkIdMap)),k({},e,{cause:i,stack:r})}applyChunkIds(e,t){return e.map((i=>(i.filename&&t&&(i.chunk_id=t[i.filename]),i)))}applyCoercers(e,t){for(var i of this.coercers)if(i.match(e))return i.coerce(e,t);return this.coerceFallback(t)}applyModifiers(e){var t=this;return it((function*(){var i=e;for(var r of t.modifiers)i=yield r(i);return i}))()}convertToExceptionList(e,t){var i,r,n,o={type:e.type,value:e.value,mechanism:{type:(i=t.type)!==null&&i!==void 0?i:"generic",handled:(r=t.handled)===null||r===void 0||r,synthetic:(n=e.synthetic)!==null&&n!==void 0&&n}};e.stack&&(o.stacktrace={type:"raw",frames:e.stack});var a=[o];return e.cause!=null&&a.push(...this.convertToExceptionList(e.cause,k({},t,{handled:!0}))),a}buildParsingContext(e){var t;return{chunkIdMap:Sb(this.stackParser),skipFirstLines:(t=e.skipFirstLines)!==null&&t!==void 0?t:1}}buildCoercingContext(e,t,i){i===void 0&&(i=0);var r=(n,o)=>{if(4>=o){var a=this.buildCoercingContext(e,t,o);return this.applyCoercers(n,a)}};return k({},t,{syntheticException:i==0?t.syntheticException:void 0,mechanism:e,apply:n=>r(n,i),next:n=>r(n,i+1)})}},Fs="?";Lh=(s,e)=>{var t=s.indexOf("safari-extension")!==-1,i=s.indexOf("safari-web-extension")!==-1;return t||i?[s.indexOf("@")!==-1?s.split("@")[0]:Fs,t?"safari-extension:"+e:"safari-web-extension:"+e]:[s,e]},wb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Ab=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Tb=/\((\S*)(?::(\d+))(?::(\d+))\)/,Rb=(s,e)=>{var t=wb.exec(s);if(t){var[,i,r,n]=t;return ca(e,i,Fs,+r,+n)}var o=Ab.exec(s);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Tb.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=Lh(o[1]||Fs,o[2]);return ca(e,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Ib=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Ob=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Pb=(s,e)=>{var t=Ib.exec(s);if(t){if(t[3]&&t[3].indexOf(" > eval")>-1){var i=Ob.exec(t[3]);i&&(t[1]=t[1]||"eval",t[3]=i[1],t[4]=i[2],t[5]="")}var r=t[3],n=t[1]||Fs;return[n,r]=Lh(n,r),ca(e,r,n,t[4]?+t[4]:void 0,t[5]?+t[5]:void 0)}},_d=/\(error: (.*)\)/,da=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,t){var i=ye(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:i?e.stack:void 0,cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var t=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?t+": "+e.message:t}isDOMException(e){return Br(e,"DOMException")}isDOMError(e){return Br(e,"DOMError")}},ha=class{match(e){return(t=>t instanceof Error)(e)}coerce(e,t){return{type:this.getType(e),value:this.getMessage(e,t),stack:this.getStack(e),cause:e.cause?t.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,t){var i=e.message;return String(i.error&&typeof i.error.message=="string"?i.error.message:i)}getStack(e){return e.stacktrace||e.stack||void 0}},ga=class{constructor(){}match(e){return Br(e,"ErrorEvent")&&e.error!=null}coerce(e,t){var i;return t.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},Cb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,fa=class{match(e){return typeof e=="string"}coerce(e,t){var i,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}getInfos(e){var t="Error",i=e,r=e.match(Cb);return r&&(t=r[1],i=r[2]),[t,i]}},Db=["fatal","error","warning","log","info","debug"];pa=class{match(e){return typeof e=="object"&&e!==null}coerce(e,t){var i,r=this.getErrorPropertyFromObject(e);return r?t.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(i=t.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return rl(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var t="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(t+=" with message: '"+e.message+"'"),t}if("message"in e&&typeof e.message=="string")return e.message;var i=this.getObjectClassName(e);return(i&&i!=="Object"?"'"+i+"'":"Object")+" captured as exception with keys: "+$h(e)}isSeverityLevel(e){return ye(e)&&!Fr(e)&&Db.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var t in e)if({}.hasOwnProperty.call(e,t)){var i=e[t];if(kb(i))return i}}getObjectClassName(e){try{var t=Object.getPrototypeOf(e);return t?t.constructor.name:void 0}catch{return}}},va=class{match(e){return rl(e)}coerce(e,t){var i,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+$h(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},_a=class{match(e){return mh(e)}coerce(e,t){var i;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}}},ma=class{match(e){return Br(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!rl(e))return!1;try{var t=e.detail;return t!=null&&typeof t=="object"&&"reason"in t}catch{return!1}}coerce(e,t){var i,r=this.getUnhandledRejectionReason(e);return mh(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(i=t.syntheticException)==null?void 0:i.stack,synthetic:!0}:t.apply(r)}getUnhandledRejectionReason(e){try{if("reason"in e)return e.reason;if("detail"in e&&e.detail!=null&&typeof e.detail=="object"&&"reason"in e.detail)return e.detail.reason}catch{}return e}},Fh=function(s,e){var{debugEnabled:t}=e===void 0?{}:e,i={C(r){if(_&&(Le.DEBUG||L.POSTHOG_DEBUG||t)&&!P(_.console)&&_.console){for(var n=("__rrweb_original__"in _.console[r])?_.console[r].__rrweb_original__:_.console[r],o=arguments.length,a=new Array(o>1?o-1:0),l=1;o>l;l++)a[l-1]=arguments[l];n(s,...a)}},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.C("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(s,...n)},uninitializedWarning(r){i.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>Fh(s+" "+r,n)};return i},I=Fh("[PostHog.js]"),ce=I.createLogger,Nb=ce("[ExternalScriptsLoader]"),Ir=(s,e,t)=>{if(s.config.disable_external_dependency_loading)return Nb.warn(e+" was requested but loading of external scripts is disabled."),t("Loading of external scripts is disabled");var i=T?.querySelectorAll("script");if(i){for(var r,n=function(){if(i[o].src===e){var l=i[o];return l.__posthog_loading_callback_fired?{v:t()}:(l.addEventListener("load",(u=>{l.__posthog_loading_callback_fired=!0,t(void 0,u)})),l.onerror=u=>t(u),{v:void 0})}},o=0;i.length>o;o++)if(r=n())return r.v}var a=()=>{if(!T)return t("document not found");var l=T.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,t(void 0,h)},l.onerror=h=>t(h),s.config.prepare_external_dependency_script&&(l=s.config.prepare_external_dependency_script(l)),!l)return t("prepare_external_dependency_script returned null");if(s.config.external_scripts_inject_target==="head")T.head.appendChild(l);else{var u,d=T.querySelectorAll("body > script");d.length>0?(u=d[0].parentNode)==null||u.insertBefore(l,d[0]):T.body.appendChild(l)}};T!=null&&T.body?a():T?.addEventListener("DOMContentLoaded",a)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(s,e,t)=>{if(e!=="remote-config")if(s._resolvedSdkVersion){var i=s.requestRouter.endpointFor("assets","/static/"+s._resolvedSdkVersion+"/"+e+".js");Ir(s,i,t)}else{var r="/static/"+e+".js?v="+s.version;if(e==="toolbar"){var n=3e5;r=r+"&t="+Math.floor(Date.now()/n)*n}var o=s.requestRouter.endpointFor("assets",r);Ir(s,o,t)}else{var a=s.requestRouter.endpointFor("assets","/array/"+s.config.token+"/config.js");Ir(s,a,t)}},L.__PosthogExtensions__.loadSiteApp=(s,e,t)=>{var i=s.requestRouter.endpointFor("api",e);Ir(s,i,t)};Mh="$people_distinct_id",Gr="$device_id",vi="__alias",_i="__timers",md="$autocapture_disabled_server_side",ya="$heatmaps_enabled_server_side",yd="$exception_capture_enabled_server_side",ba="$error_tracking_suppression_rules",bd="$error_tracking_capture_extension_exceptions",Ed="$web_vitals_enabled_server_side",Uh="$dead_clicks_enabled_server_side",kd="$product_tours_enabled_server_side",Sd="$web_vitals_allowed_metrics",Or="$session_recording_remote_config",Hr="$sesid",Bh="$session_is_sampled",Cs="$enabled_feature_flags",mi="$early_access_features",Ea="$feature_flag_details",yi="$stored_person_properties",ts="$stored_group_properties",ka="$surveys",ki="$flag_call_reported",Sa="$flag_call_reported_session_id",wa="$feature_flag_errors",jr="$feature_flag_evaluated_at",st="$user_state",Aa="$client_session_props",Ta="$capture_rate_limit",Ra="$initial_campaign_params",Ia="$initial_referrer_info",zr="$initial_person_info",qr="$epp",Vh="__POSTHOG_TOOLBAR__",Pr="$posthog_cookieless",xb=[Mh,vi,"__cmpns",_i,"$session_recording_enabled_server_side",ya,Hr,Cs,ba,st,mi,Ea,ts,yi,ka,ki,Sa,wa,jr,Aa,Ta,Ra,Ia,qr,zr],ul="PostHog loadExternalDependency extension not found.",wt="on_reject",rt="always",Ss="anonymous",ws="identified",Oa="identified_only",Wr="visibilitychange",Kr="beforeunload",Is="$pageview",Mo="$pageleave",Uo="$identify",wd="$groupidentify";pe=function(s){for(var e=arguments.length,t=new Array(e>1?e-1:0),i=1;e>i;i++)t[i-1]=arguments[i];for(var r of t)for(var n in r)r[n]!==void 0&&(s[n]=r[n]);return s};Ad=function(s){try{return s()}catch{return}},Lb=function(s){return function(){try{for(var e=arguments.length,t=new Array(e),i=0;e>i;i++)t[i]=arguments[i];return s.apply(this,t)}catch(r){I.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),I.critical(r)}}},cl=function(s){var e={};return oe(s,(function(t,i){(ye(t)&&t.length>0||nt(t))&&(e[i]=t)})),e},$b=["herokuapp.com","vercel.app","netlify.app"];Math.trunc||(Math.trunc=function(s){return 0>s?Math.ceil(s):Math.floor(s)}),Number.isInteger||(Number.isInteger=function(s){return nt(s)&&isFinite(s)&&Math.floor(s)===s});Pa=class s{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,t,i,r){if(!Number.isInteger(e)||!Number.isInteger(t)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>t||0>i||0>r||e>0xffffffffffff||t>4095||i>1073741823||r>4294967295)throw new RangeError("invalid field value");var n=new Uint8Array(16);return n[0]=e/Math.pow(2,40),n[1]=e/Math.pow(2,32),n[2]=e/Math.pow(2,24),n[3]=e/Math.pow(2,16),n[4]=e/Math.pow(2,8),n[5]=e,n[6]=112|t>>>8,n[7]=t,n[8]=128|i>>>24,n[9]=i>>>16,n[10]=i>>>8,n[11]=i,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new s(n)}toString(){for(var e="",t=0;this.bytes.length>t;t++)e=e+(this.bytes[t]>>>4).toString(16)+(15&this.bytes[t]).toString(16),t!==3&&t!==5&&t!==7&&t!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new s(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var t=0;16>t;t++){var i=this.bytes[t]-e.bytes[t];if(i!==0)return Math.sign(i)}return 0}},Ca=class{constructor(){this.I=0,this.S=0,this.k=new Da}generate(){var e=this.generateOrAbort();if(P(e)){this.I=0;var t=this.generateOrAbort();if(P(t))throw new Error("Could not generate UUID after timestamp reset");return t}return e}generateOrAbort(){var e=Date.now();if(e>this.I)this.I=e,this.A();else{if(this.I>=e+1e4)return;this.S++,this.S>4398046511103&&(this.I++,this.A())}return Pa.fromFieldsV7(this.I,Math.trunc(this.S/Math.pow(2,30)),this.S&Math.pow(2,30)-1,this.k.nextUint32())}A(){this.S=1024*this.k.nextUint32()+(1023&this.k.nextUint32())}},Hh=s=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;s.length>e;e++)s[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return s};_&&!P(_.crypto)&&crypto.getRandomValues&&(Hh=s=>crypto.getRandomValues(s));Da=class{constructor(){this.T=new Uint32Array(8),this.N=1/0}nextUint32(){return this.T.length>this.N||(Hh(this.T),this.N=0),this.T[this.N++]}},Ut=()=>Mb().toString(),Mb=()=>(Td||(Td=new Ca)).generate(),oi="",Ub=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,dt={Ut:()=>!!T,Yt(s){I.error("cookieStore error: "+s)},Gt(s){if(T){try{for(var e=s+"=",t=T.cookie.split(";").filter((n=>n.length)),i=0;t.length>i;i++){for(var r=t[i];r.charAt(0)==" ";)r=r.substring(1,r.length);if(r.indexOf(e)===0)return decodeURIComponent(r.substring(e.length,r.length))}}catch{}return null}},Wt(s){var e;try{e=JSON.parse(dt.Gt(s))||{}}catch{}return e},Xt(s,e,t,i,r){if(T)try{var n="",o="",a=(function(d,h){if(h){var f=(function(p,v){if(v===void 0&&(v=T),oi)return oi;if(!v||["localhost","127.0.0.1"].includes(p))return"";for(var m=p.split("."),y=Math.min(m.length,8),w="dmn_chk_"+Ut();!oi&&y--;){var C=m.slice(y).join("."),D=w+"=1;domain=."+C+";path=/";v.cookie=D+";max-age=3",v.cookie.includes(w)&&(v.cookie=D+";max-age=0",oi=C)}return oi})(d);if(!f){var g=(p=>{var v=p.match(Ub);return v?v[0]:""})(d);g!==f&&I.info("Warning: cookie subdomain discovery mismatch",g,f),f=g}return f?"; domain=."+f:""}return""})(T.location.hostname,i);if(t){var l=new Date;l.setTime(l.getTime()+864e5*t),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=s+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&I.warn("cookieStore warning: large cookie, len="+u.length),T.cookie=u,u}catch{return}},Jt(s,e){if(T!=null&&T.cookie)try{dt.Xt(s,"",-1,e)}catch{return}}},Bo=null,ge={Ut(){if(!Rt(Bo))return Bo;var s=!0;if(P(_))s=!1;else try{var e="__mplssupport__";ge.Xt(e,"xyz"),ge.Gt(e)!=='"xyz"'&&(s=!1),ge.Jt(e)}catch{s=!1}return s||I.error("localStorage unsupported; falling back to cookie store"),Bo=s,s},Yt(s){I.error("localStorage error: "+s)},Gt(s){try{return _?.localStorage.getItem(s)}catch(e){ge.Yt(e)}return null},Wt(s){try{return JSON.parse(ge.Gt(s))||{}}catch{}return null},Xt(s,e){try{_?.localStorage.setItem(s,JSON.stringify(e))}catch(t){ge.Yt(t)}},Jt(s){try{_?.localStorage.removeItem(s)}catch(e){ge.Yt(e)}}},Bb=[Gr,"distinct_id",Hr,Bh,qr,zr,st],Dr={},Vb={Ut:()=>!0,Yt(s){I.error("memoryStorage error: "+s)},Gt:s=>Dr[s]||null,Wt:s=>Dr[s]||null,Xt(s,e){Dr[s]=e},Jt(s){delete Dr[s]}},Jt=null,Ie={Ut(){if(!Rt(Jt))return Jt;if(Jt=!0,P(_))Jt=!1;else try{var s="__support__";Ie.Xt(s,"xyz"),Ie.Gt(s)!=='"xyz"'&&(Jt=!1),Ie.Jt(s)}catch{Jt=!1}return Jt},Yt(s){I.error("sessionStorage error: ",s)},Gt(s){try{return _?.sessionStorage.getItem(s)}catch(e){Ie.Yt(e)}return null},Wt(s){try{return JSON.parse(Ie.Gt(s))||null}catch{}return null},Xt(s,e){try{_?.sessionStorage.setItem(s,JSON.stringify(e))}catch(t){Ie.Yt(t)}},Jt(s){try{_?.sessionStorage.removeItem(s)}catch(e){Ie.Yt(e)}}},Na=class{constructor(e){this._instance=e}get Rt(){return this._instance.config}get consent(){return this.Kt()?0:this.Qt}isOptedOut(){return this.Rt.cookieless_mode===rt||this.consent===0||this.consent===-1&&(this.Rt.opt_out_capturing_by_default||this.Rt.cookieless_mode===wt)}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}optInOut(e){this.ti.Xt(this.ei,e?1:0,this.Rt.cookie_expiration,this.Rt.cross_subdomain_cookie,this.Rt.secure_cookie)}reset(){this.ti.Jt(this.ei,this.Rt.cross_subdomain_cookie)}get ei(){var{token:e,opt_out_capturing_cookie_prefix:t,consent_persistence_name:i}=this._instance.config;return i||(t?t+e:"__ph_opt_in_out_"+e)}get Qt(){var e=this.ti.Gt(this.ei);return Lo(e)?1:j(hb,e)?0:-1}get ti(){var e=this.Rt.opt_out_capturing_persistence_type,t=e==="localStorage"?ge:dt;if(!this.ii||this.ii!==t){this.ii=t;var i=e==="localStorage"?dt:ge;i.Gt(this.ei)&&(this.ii.Gt(this.ei)||this.optInOut(Lo(i.Gt(this.ei))),i.Jt(this.ei,this.Rt.cross_subdomain_cookie))}return this.ii}Kt(){return!!this.Rt.respect_dnt&&[qe?.doNotTrack,qe?.msDoNotTrack,L.doNotTrack].some((e=>Lo(e)))}},Nr=ce("[Dead Clicks]"),Gb=()=>!0,Hb=s=>{var e,t=!((e=s.instance.persistence)==null||!e.get_property(Uh)),i=s.instance.config.capture_dead_clicks;return ht(i)?i:!!be(i)||t},Xr=class{get lazyLoadedDeadClicksAutocapture(){return this.ri}constructor(e,t,i){this.instance=e,this.isEnabled=t,this.onCapture=i,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Uh]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.ni((()=>{this.si()})):this.stop()}ni(e){var t,i;(t=L.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture&&e(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Nr.error("failed to load script",r):e()}))}si(){var e;if(T){if(!this.ri&&(e=L.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var t=be(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};t.__onCapture=this.onCapture,this.ri=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,t),this.ri.start(T),Nr.info("starting...")}}else Nr.error("`document` not found. Cannot start.")}stop(){this.ri&&(this.ri.stop(),this.ri=void 0,Nr.info("stopping..."))}},Vo=ce("[SegmentIntegration]"),jh="posthog-js";xa=class{constructor(e,t,i,r,n,o){this.name=jh,this.setupOnce=function(a){a(zh(e,{organization:t,projectId:i,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},Yr=class{constructor(e){this.oi=(t,i,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(I.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:t,changeReason:r}),this.ai=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.li()}li(){var e;this.ui=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.oi)}destroy(){var e;(e=this.ui)==null||e.call(this),this.ui=void 0}doPageView(e,t){var i,r=this.hi(e,t);return this.ai={pathname:(i=_?.location.pathname)!==null&&i!==void 0?i:"",pageViewId:t,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var t;return this.hi(e,(t=this.ai)==null?void 0:t.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.ai)==null?void 0:e.pageViewId}}hi(e,t){var i=this.ai;if(!i)return{$pageview_id:t};var r={$pageview_id:t,$prev_pageview_id:i.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:u,lastContentY:d,maxContentY:h}=n;if(!(P(o)||P(a)||P(l)||P(u)||P(d)||P(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),d=Math.ceil(d),h=Math.ceil(h);var f=o>1?gt(a/o,0,1,I):1,g=o>1?gt(l/o,0,1,I):1,p=u>1?gt(d/u,0,1,I):1,v=u>1?gt(h/u,0,1,I):1;r=pe(r,{$prev_pageview_last_scroll:a,$prev_pageview_last_scroll_percentage:f,$prev_pageview_max_scroll:l,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:d,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return i.pathname&&(r.$prev_pageview_pathname=i.pathname),i.timestamp&&(r.$prev_pageview_duration=(e.getTime()-i.timestamp.getTime())/1e3),r}},Jr=s=>{var e=T?.createElement("a");return P(e)?null:(e.href=s,e)},Qr=function(s,e){for(var t,i=((s.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;i.length>r;r++){var n=i[r].split("=");if(n[0]===e){t=n;break}}if(!W(t)||2>t.length)return"";var o=t[1];try{o=decodeURIComponent(o)}catch{I.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},Oi=function(s,e,t){if(!s||!e||!e.length)return s;for(var i=s.split("#"),r=i[1],n=(i[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],d=0;l.length>d;d++){var h=l[d].split("=");W(h)&&(e.includes(h[0])?u.push(h[0]+"="+t):u.push(l[d]))}var f=a;return o!=null&&(f+="?"+u.join("&")),r!=null&&(f+="#"+r),f},Zr=function(s,e){var t=s.match(new RegExp(e+"=([^&]*)"));return t?t[1]:null},xr="https?://(.*)",Ms=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],jb=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Ms],Pi="<masked>",zb=["li_fat_id"];en="$direct";Wb=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Si=class{constructor(e,t){this.Rt=e,this.props={},this.ci=!1,this.di=(i=>{var r="";return i.token&&(r=i.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),i.persistence_name?"ph_"+i.persistence_name:"ph_"+r+"_posthog"})(e),this.ti=this.vi(e),this.load(),e.debug&&I.info("Persistence loaded",e.persistence,k({},this.props)),this.update_config(e,e,t),this.save()}isDisabled(){return!!this.fi}vi(e){Wb.indexOf(e.persistence.toLowerCase())===-1&&(I.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var t=(function(r){r===void 0&&(r=[]);var n=[...Bb,...r];return k({},ge,{Wt(o){try{var a={};try{a=dt.Wt(o)||{}}catch{}var l=pe(a,JSON.parse(ge.Gt(o)||"{}"));return ge.Xt(o,l),l}catch{}return null},Xt(o,a,l,u,d,h){try{ge.Xt(o,a,void 0,void 0,h);var f={};n.forEach((g=>{a[g]&&(f[g]=a[g])})),Object.keys(f).length&&dt.Xt(o,f,l,u,d,h)}catch(g){ge.Yt(g)}},Jt(o,a){try{_?.localStorage.removeItem(o),dt.Jt(o,a)}catch(l){ge.Yt(l)}}})})(e.cookie_persisted_properties||[]),i=e.persistence.toLowerCase();return i==="localstorage"&&ge.Ut()?ge:i==="localstorage+cookie"&&t.Ut()?t:i==="sessionstorage"&&Ie.Ut()?Ie:i==="memory"?Vb:i==="cookie"?dt:t.Ut()?t:dt}pi(e){var t=e??this.Rt.feature_flag_cache_ttl_ms;if(!t||0>=t)return!1;var i=this.props[jr];return!i||typeof i!="number"||Date.now()-i>t}properties(){var e={};return oe(this.props,((t,i)=>{if(i===Cs&&be(t)){if(!this.pi())for(var r=Object.keys(t),n=0;r.length>n;n++)e["$feature/"+r[n]]=t[r[n]]}else xb.indexOf(i)===-1&&(e[i]=t)})),e}load(){if(!this.fi){var e=this.ti.Wt(this.di);e&&(this.props=pe({},e))}}save(){this.fi||this.ti.Xt(this.di,this.props,this.gi,this.mi,this.yi,this.Rt.debug)}remove(){this.ti.Jt(this.di,!1),this.ti.Jt(this.di,!0)}clear(){this.remove(),this.props={}}register_once(e,t,i){if(be(e)){P(t)&&(t="None"),this.gi=P(i)?this.bi:i;var r=!1;if(oe(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==t||(this.props[o]=n,r=!0)})),r)return this.save(),!0}return!1}register(e,t){if(be(e)){this.gi=P(t)?this.bi:t;var i=!1;if(oe(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.props[n]=r,i=!0)})),i)return this.save(),!0}return!1}unregister(e){e in this.props&&(delete this.props[e],this.save())}update_campaign_params(){if(!this.ci){var e=qh(this.Rt.custom_campaign_params,this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties);Ps(cl(e))||this.register(e),this.ci=!0}}update_search_keyword(){var e;this.register((e=T?.referrer)?Kh(e):{})}update_referrer_info(){var e;this.register_once({$referrer:Xh(),$referring_domain:T!=null&&T.referrer&&((e=Jr(T.referrer))==null?void 0:e.host)||en},void 0)}set_initial_person_info(){this.props[Ra]||this.props[Ia]||this.register_once({[zr]:Yh(this.Rt.mask_personal_data_properties,this.Rt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};oe([Ia,Ra],(o=>{var a=this.props[o];a&&oe(a,(function(l,u){e["$initial_"+ra(u)]=l}))}));var t,i,r=this.props[zr];if(r){var n=(t=Jh(r),i={},oe(t,(function(o,a){i["$initial_"+ra(a)]=o})),i);pe(e,n)}return e}safe_merge(e){return oe(this.props,(function(t,i){i in e||(e[i]=t)})),e}update_config(e,t,i){if(this.bi=this.gi=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!i),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==t.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),u=[...a].sort();return l.every(((d,h)=>d===u[h]))})(e.cookie_persisted_properties||[],t.cookie_persisted_properties||[])){var r=this.vi(e),n=this.props;this.clear(),this.ti=r,this.props=n,this.save()}}set_disabled(e){this.fi=e,this.fi?this.remove():this.save()}set_cross_subdomain(e){e!==this.mi&&(this.mi=e,this.remove(),this.save())}set_secure(e){e!==this.yi&&(this.yi=e,this.remove(),this.save())}set_event_timer(e,t){var i=this.props[_i]||{};i[e]=t,this.props[_i]=i,this.save()}remove_event_timer(e){var t=(this.props[_i]||{})[e];return P(t)||(delete this.props[_i][e],this.save()),t}get_property(e){return this.props[e]}set_property(e,t){this.props[e]=t,this.save()}},ai={Activation:"events",Cancellation:"cancelEvents"},Go={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},bi={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Ho={SURVEY_ID:"$survey_id",SURVEY_NAME:"$survey_name",SURVEY_RESPONSE:"$survey_response",SURVEY_ITERATION:"$survey_iteration",SURVEY_ITERATION_START_DATE:"$survey_iteration_start_date",SURVEY_PARTIALLY_COMPLETED:"$survey_partially_completed",SURVEY_SUBMISSION_ID:"$survey_submission_id",SURVEY_QUESTIONS:"$survey_questions",SURVEY_COMPLETED:"$survey_completed",PRODUCT_TOUR_ID:"$product_tour_id",SURVEY_LAST_SEEN_DATE:"$survey_last_seen_date"},La={Popover:"popover",Inline:"inline"},Kb={SHOWN:"product tour shown",DISMISSED:"product tour dismissed",COMPLETED:"product tour completed",STEP_SHOWN:"product tour step shown",STEP_COMPLETED:"product tour step completed",BUTTON_CLICKED:"product tour button clicked",STEP_SELECTOR_FAILED:"product tour step selector failed",BANNER_CONTAINER_SELECTOR_FAILED:"product tour banner container selector failed",BANNER_ACTION_CLICKED:"product tour banner action clicked"},Id={TOUR_ID:"$product_tour_id",TOUR_NAME:"$product_tour_name",TOUR_ITERATION:"$product_tour_iteration",TOUR_RENDER_REASON:"$product_tour_render_reason",TOUR_STEP_ID:"$product_tour_step_id",TOUR_STEP_ORDER:"$product_tour_step_order",TOUR_STEP_TYPE:"$product_tour_step_type",TOUR_DISMISS_REASON:"$product_tour_dismiss_reason",TOUR_BUTTON_TEXT:"$product_tour_button_text",TOUR_BUTTON_ACTION:"$product_tour_button_action",TOUR_BUTTON_LINK:"$product_tour_button_link",TOUR_BUTTON_TOUR_ID:"$product_tour_button_tour_id",TOUR_STEPS_COUNT:"$product_tour_steps_count",TOUR_STEP_SELECTOR:"$product_tour_step_selector",TOUR_STEP_SELECTOR_FOUND:"$product_tour_step_selector_found",TOUR_STEP_ELEMENT_TAG:"$product_tour_step_element_tag",TOUR_STEP_ELEMENT_ID:"$product_tour_step_element_id",TOUR_STEP_ELEMENT_CLASSES:"$product_tour_step_element_classes",TOUR_STEP_ELEMENT_TEXT:"$product_tour_step_element_text",TOUR_ERROR:"$product_tour_error",TOUR_MATCHES_COUNT:"$product_tour_matches_count",TOUR_FAILURE_PHASE:"$product_tour_failure_phase",TOUR_WAITED_FOR_ELEMENT:"$product_tour_waited_for_element",TOUR_WAIT_DURATION_MS:"$product_tour_wait_duration_ms",TOUR_BANNER_SELECTOR:"$product_tour_banner_selector",TOUR_LINKED_SURVEY_ID:"$product_tour_linked_survey_id",USE_MANUAL_SELECTOR:"$use_manual_selector",INFERENCE_DATA_PRESENT:"$inference_data_present",TOUR_LAST_SEEN_DATE:"$product_tour_last_seen_date",TOUR_TYPE:"$product_tour_type"},Od=ce("[RateLimiter]"),$a=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=t=>{var i=t.text;if(i&&i.length)try{(JSON.parse(i).quota_limited||[]).forEach((r=>{Od.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void Od.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:i})}},this.instance=e,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var e;return((e=this.instance.config.rate_limiting)==null?void 0:e.events_per_second)||10}get captureEventsBurstLimit(){var e;return Math.max(((e=this.instance.config.rate_limiting)==null?void 0:e.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(e){var t,i,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(t=(i=this.instance.persistence)==null?void 0:i.get_property(Ta))!==null&&t!==void 0?t:{tokens:n,last:a};l.tokens+=(a-l.last)/1e3*o,l.last=a,l.tokens>n&&(l.tokens=n);var u=1>l.tokens;return u||e||(l.tokens=Math.max(0,l.tokens-1)),!u||this.lastEventRateLimited||e||this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited. Config is set to "+o+" events per second and "+n+" events burst limit."},{skip_client_rate_limiting:!0}),this.lastEventRateLimited=u,(r=this.instance.persistence)==null||r.set_property(Ta,l),{isRateLimited:u,remainingTokens:l.tokens}}isServerRateLimited(e){var t=this.serverLimits[e||"events"]||!1;return t!==!1&&new Date().getTime()<t}},li=ce("[RemoteConfig]"),tn=class{constructor(e){this._instance=e}get remoteConfig(){var e;return(e=L._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null?void 0:e.config}wi(e){var t,i;(t=L.__PosthogExtensions__)!=null&&t.loadExternalDependency?(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Ii(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(t){e(t.json)}})}load(){try{if(this.remoteConfig)return li.info("Using preloaded remote config",this.remoteConfig),this.Ci(this.remoteConfig),void this.Si();if(this._instance.ki())return void li.warn("Remote config is disabled. Falling back to local config.");this.wi((e=>{if(!e)return li.info("No config found after loading remote JS config. Falling back to JSON."),void this.Ii((t=>{this.Ci(t),this.Si()}));this.Ci(e),this.Si()}))}catch(e){li.error("Error loading remote config",e)}}stop(){this.xi&&(clearInterval(this.xi),this.xi=void 0)}refresh(){this._instance.ki()||T?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}Si(){var e;if(!this.xi){var t=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;t!==0&&(this.xi=setInterval((()=>{this.refresh()}),t))}}Ci(e){var t;e||li.error("Failed to fetch remote config from PostHog."),this._instance.Ci(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(t=this._instance.featureFlags)==null||t.ensureFlagsLoaded())}},ct={GZipJS:"gzip-js",Base64:"base64"},Qe=Uint8Array,$e=Uint16Array,Us=Uint32Array,dl=new Qe([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]),hl=new Qe([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]),Pd=new Qe([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Zh=function(s,e){for(var t=new $e(31),i=0;31>i;++i)t[i]=e+=1<<s[i-1];var r=new Us(t[30]);for(i=1;30>i;++i)for(var n=t[i];t[i+1]>n;++n)r[n]=n-t[i]<<5|i;return[t,r]},eg=Zh(dl,2),Fa=eg[1];eg[0][28]=258,Fa[258]=28;for(Ma=Zh(hl,0)[1],sn=new $e(32768),se=0;32768>se;++se)Qt=(43690&se)>>>1|(21845&se)<<1,sn[se]=((65280&(Qt=(61680&(Qt=(52428&Qt)>>>2|(13107&Qt)<<2))>>>4|(3855&Qt)<<4))>>>8|(255&Qt)<<8)>>>1;wi=function(s,e,t){for(var i=s.length,r=0,n=new $e(e);i>r;++r)++n[s[r]-1];var o,a=new $e(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(t){o=new $e(1<<e);var l=15-e;for(r=0;i>r;++r)if(s[r])for(var u=r<<4|s[r],d=e-s[r],h=a[s[r]-1]++<<d,f=h|(1<<d)-1;f>=h;++h)o[sn[h]>>>l]=u}else for(o=new $e(i),r=0;i>r;++r)o[r]=sn[a[s[r]-1]++]>>>15-s[r];return o},rs=new Qe(288);for(se=0;144>se;++se)rs[se]=8;for(se=144;256>se;++se)rs[se]=9;for(se=256;280>se;++se)rs[se]=7;for(se=280;288>se;++se)rs[se]=8;rn=new Qe(32);for(se=0;32>se;++se)rn[se]=5;Xb=wi(rs,9,0),Yb=wi(rn,5,0),tg=function(s){return(s/8>>0)+(7&s&&1)},sg=function(s,e,t){(t==null||t>s.length)&&(t=s.length);var i=new(s instanceof $e?$e:s instanceof Us?Us:Qe)(t-e);return i.set(s.subarray(e,t)),i},St=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8},ui=function(s,e,t){var i=e/8>>0;s[i]|=t<<=7&e,s[i+1]|=t>>>8,s[i+2]|=t>>>16},jo=function(s,e){for(var t=[],i=0;s.length>i;++i)s[i]&&t.push({s:i,f:s[i]});var r=t.length,n=t.slice();if(!r)return[new Qe(0),0];if(r==1){var o=new Qe(t[0].s+1);return o[t[0].s]=1,[o,1]}t.sort((function(R,N){return R.f-N.f})),t.push({s:-1,f:25001});var a=t[0],l=t[1],u=0,d=1,h=2;for(t[0]={s:-1,f:a.f+l.f,l:a,r:l};d!=r-1;)a=t[t[h].f>t[u].f?u++:h++],l=t[u!=d&&t[h].f>t[u].f?u++:h++],t[d++]={s:-1,f:a.f+l.f,l:a,r:l};var f=n[0].s;for(i=1;r>i;++i)n[i].s>f&&(f=n[i].s);var g=new $e(f+1),p=Ua(t[d-1],g,0);if(p>e){i=0;var v=0,m=p-e,y=1<<m;for(n.sort((function(R,N){return g[N.s]-g[R.s]||R.f-N.f}));r>i;++i){var w=n[i].s;if(e>=g[w])break;v+=y-(1<<p-g[w]),g[w]=e}for(v>>>=m;v>0;){var C=n[i].s;e>g[C]?v-=1<<e-g[C]++-1:++i}for(;i>=0&&v;--i){var D=n[i].s;g[D]==e&&(--g[D],++v)}p=e}return[new Qe(g),p]},Ua=function(s,e,t){return s.s==-1?Math.max(Ua(s.l,e,t+1),Ua(s.r,e,t+1)):e[s.s]=t},Cd=function(s){for(var e=s.length;e&&!s[--e];);for(var t=new $e(++e),i=0,r=s[0],n=1,o=function(l){t[i++]=l},a=1;e>=a;++a)if(s[a]==r&&a!=e)++n;else{if(!r&&n>2){for(;n>138;n-=138)o(32754);n>2&&(o(n>10?n-11<<5|28690:n-3<<5|12305),n=0)}else if(n>3){for(o(r),--n;n>6;n-=6)o(8304);n>2&&(o(n-3<<5|8208),n=0)}for(;n--;)o(r);n=1,r=s[a]}return[t.subarray(0,i),e]},ci=function(s,e){for(var t=0,i=0;e.length>i;++i)t+=s[i]*e[i];return t},Ba=function(s,e,t){var i=t.length,r=tg(e+2);s[r]=255&i,s[r+1]=i>>>8,s[r+2]=255^s[r],s[r+3]=255^s[r+1];for(var n=0;i>n;++n)s[r+n+4]=t[n];return 8*(r+4+i)},Dd=function(s,e,t,i,r,n,o,a,l,u,d){St(e,d++,t),++r[256];for(var h=jo(r,15),f=h[0],g=h[1],p=jo(n,15),v=p[0],m=p[1],y=Cd(f),w=y[0],C=y[1],D=Cd(v),R=D[0],N=D[1],O=new $e(19),E=0;w.length>E;++E)O[31&w[E]]++;for(E=0;R.length>E;++E)O[31&R[E]]++;for(var S=jo(O,7),$=S[0],F=S[1],G=19;G>4&&!$[Pd[G-1]];--G);var K,X,ve,ke,Ce=u+5<<3,ae=ci(r,rs)+ci(n,rn)+o,A=ci(r,f)+ci(n,v)+o+14+3*G+ci(O,$)+(2*O[16]+3*O[17]+7*O[18]);if(ae>=Ce&&A>=Ce)return Ba(e,d,s.subarray(l,l+u));if(St(e,d,1+(ae>A)),d+=2,ae>A){K=wi(f,g,0),X=f,ve=wi(v,m,0),ke=v;var M=wi($,F,0);for(St(e,d,C-257),St(e,d+5,N-1),St(e,d+10,G-4),d+=14,E=0;G>E;++E)St(e,d+3*E,$[Pd[E]]);d+=3*G;for(var U=[w,R],B=0;2>B;++B){var Z=U[B];for(E=0;Z.length>E;++E)St(e,d,M[de=31&Z[E]]),d+=$[de],de>15&&(St(e,d,Z[E]>>>5&127),d+=Z[E]>>>12)}}else K=Xb,X=rs,ve=Yb,ke=rn;for(E=0;a>E;++E)if(i[E]>255){var de;ui(e,d,K[257+(de=i[E]>>>18&31)]),d+=X[de+257],de>7&&(St(e,d,i[E]>>>23&31),d+=dl[de]);var ie=31&i[E];ui(e,d,ve[ie]),d+=ke[ie],ie>3&&(ui(e,d,i[E]>>>5&8191),d+=hl[ie])}else ui(e,d,K[i[E]]),d+=X[i[E]];return ui(e,d,K[256]),d+X[256]},Jb=new Us([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Qb=(function(){for(var s=new Us(256),e=0;256>e;++e){for(var t=e,i=9;--i;)t=(1&t&&3988292384)^t>>>1;s[e]=t}return s})(),zo=function(s,e,t){for(;t;++e)s[e]=t,t>>>=8};eE=!!ia||!!sa,ig="text/plain",Nd=!1,hn=function(s,e,t){var i;t===void 0&&(t=!0);var[r,n]=s.split("?"),o=k({},e),a=(i=n?.split("&").map((u=>{var d,[h,f]=u.split("="),g=t&&(d=o[h])!==null&&d!==void 0?d:f;return delete o[h],h+"="+g})))!==null&&i!==void 0?i:[],l=(function(u,d){var h,f;d===void 0&&(d="&");var g=[];return oe(u,(function(p,v){P(p)||P(v)||v==="undefined"||(h=encodeURIComponent((m=>m instanceof File)(p)?p.name:p.toString()),f=encodeURIComponent(v),g[g.length]=f+"="+h)})),g.join(d)})(o);return l&&a.push(l),r+"?"+a.join("&")},Ds=(s,e)=>JSON.stringify(s,((t,i)=>typeof i=="bigint"?i.toString():i),e),qo=s=>{if(s.zt)return s.zt;var{data:e,compression:t}=s;if(e){if(t===ct.GZipJS){var i=Zb((function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var d=new Qe(a.length+(a.length>>>1)),h=0,f=function(m){d[h++]=m},g=0;u>g;++g){if(h+5>d.length){var p=new Qe(h+8+(u-g<<1));p.set(d),d=p}var v=a.charCodeAt(g);128>v?f(v):2048>v?(f(192|v>>>6),f(128|63&v)):v>55295&&57344>v?(f(240|(v=65536+(1047552&v)|1023&a.charCodeAt(++g))>>>18),f(128|v>>>12&63),f(128|v>>>6&63),f(128|63&v)):(f(224|v>>>12),f(128|v>>>6&63),f(128|63&v))}return sg(d,0,h)})(Ds(e)),{mtime:0});return{contentType:ig,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(t===ct.Base64){var r=(function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,((l,u)=>String.fromCharCode(parseInt(u,16)))))})(Ds(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Ds(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Ds(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},tE=(function(){var s=it((function*(e){var t=Ds(e.data),i=yield(function(n,o,a){return ph.apply(this,arguments)})(t,Le.DEBUG,{rethrow:!0});if(!i)return e;var r=yield i.arrayBuffer();return k({},e,{zt:{contentType:ig,body:r,estimatedSize:r.byteLength}})}));return function(e){return s.apply(this,arguments)}})(),xd=(s,e)=>hn(s,{_:new Date().getTime().toString(),ver:Le.JS_SDK_VERSION,compression:e}),Ur=[];sa&&Ur.push({transport:"fetch",method(s){var e,t,{contentType:i,body:r,estimatedSize:n}=(e=qo(s))!==null&&e!==void 0?e:{},o=new Headers;oe(s.headers,(function(d,h){o.append(h,d)})),i&&o.append("Content-Type",i);var a=s.url,l=null;if(ud){var u=new ud;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),s.timeout)}}sa(a,k({method:s?.method||"GET",headers:o,keepalive:s.method==="POST"&&52428.8>(n||0),body:r,signal:(t=l)==null?void 0:t.signal},s.fetchOptions)).then((d=>d.text().then((h=>{var f={statusCode:d.status,text:h};if(d.status===200)try{f.json=JSON.parse(h)}catch(g){I.error(g)}s.callback==null||s.callback(f)})))).catch((d=>{I.error(d),s.callback==null||s.callback({statusCode:0,error:d})})).finally((()=>l?clearTimeout(l.timeout):null))}}),ia&&Ur.push({transport:"XHR",method(s){var e,t=new ia;t.open(s.method||"GET",s.url,!0);var{contentType:i,body:r}=(e=qo(s))!==null&&e!==void 0?e:{};oe(s.headers,(function(n,o){t.setRequestHeader(o,n)})),i&&t.setRequestHeader("Content-Type",i),s.timeout&&(t.timeout=s.timeout),s.disableXHRCredentials||(t.withCredentials=!0),t.onreadystatechange=()=>{if(t.readyState===4){var n={statusCode:t.status,text:t.responseText};if(t.status===200)try{n.json=JSON.parse(t.responseText)}catch{}s.callback==null||s.callback(n)}},t.send(r)}}),qe!=null&&qe.sendBeacon&&Ur.push({transport:"sendBeacon",method(s){var e=hn(s.url,{beacon:"1"});try{var t,{contentType:i,body:r}=(t=qo(s))!==null&&t!==void 0?t:{};if(!r)return;var n=r instanceof Blob?r:new Blob([r],{type:i});qe.sendBeacon(e,n)}catch{}}});Va=3e3,Ga=class{constructor(e,t){this.Ti=!0,this.Ai=[],this.Ei=gt(t?.flush_interval_ms||Va,250,5e3,I.createLogger("flush interval"),Va),this.Ri=e}enqueue(e){this.Ai.push(e),this.Ni||this.Mi()}unload(){this.Fi();var e=this.Ai.length>0?this.Oi():{},t=Object.values(e);[...t.filter((i=>i.url.indexOf("/e")===0)),...t.filter((i=>i.url.indexOf("/e")!==0))].map((i=>{this.Ri(k({},i,{transport:"sendBeacon"}))}))}enable(){this.Ti=!1,this.Mi()}Mi(){var e=this;this.Ti||(this.Ni=setTimeout((()=>{if(this.Fi(),this.Ai.length>0){var t=this.Oi(),i=function(){var n=t[r],o=new Date().getTime();n.data&&W(n.data)&&oe(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Ri(n)};for(var r in t)i()}}),this.Ei))}Fi(){clearTimeout(this.Ni),this.Ni=void 0}Oi(){var e={};return oe(this.Ai,(t=>{var i,r=t,n=(r?r.batchKey:null)||r.url;P(e[n])&&(e[n]=k({},r,{data:[]})),(i=e[n].data)==null||i.push(r.data)})),this.Ai=[],e}},sE=["retriesPerformedSoFar"],Ha=class{constructor(e){this.Pi=!1,this.Li=3e3,this.Ai=[],this._instance=e,this.Ai=[],this.Di=!0,!P(_)&&"onLine"in _.navigator&&(this.Di=_.navigator.onLine,this.Bi=()=>{this.Di=!0,this.ji()},this.qi=()=>{this.Di=!1},me(_,"online",this.Bi),me(_,"offline",this.qi))}get length(){return this.Ai.length}retriableRequest(e){var{retriesPerformedSoFar:t}=e,i=fh(e,sE);Rs(t)&&(i.url=hn(i.url,{retry_count:t})),this._instance._send_request(k({},i,{callback:r=>{r.statusCode===200||r.statusCode>=400&&500>r.statusCode||(t??0)>=10?i.callback==null||i.callback(r):this.Zi(k({retriesPerformedSoFar:t},i))}}))}Zi(e){var t=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=t+1;var i=(function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),d=Math.random()-.5;return Math.ceil(u+d*(u-l))})(t),r=Date.now()+i;this.Ai.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+i;navigator.onLine||(n+=" (Browser is offline)"),I.warn(n),this.Pi||(this.Pi=!0,this.$i())}$i(){if(this.Vi&&clearTimeout(this.Vi),this.Ai.length===0)return this.Pi=!1,void(this.Vi=void 0);this.Vi=setTimeout((()=>{this.Di&&this.Ai.length>0&&this.ji(),this.$i()}),this.Li)}ji(){var e=Date.now(),t=[],i=this.Ai.filter((n=>e>n.retryAt||(t.push(n),!1)));if(this.Ai=t,i.length>0)for(var{requestOptions:r}of i)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Vi&&(clearTimeout(this.Vi),this.Vi=void 0),this.Pi=!1,P(_)||(this.Bi&&(_.removeEventListener("online",this.Bi),this.Bi=void 0),this.qi&&(_.removeEventListener("offline",this.qi),this.qi=void 0)),this.Ai))try{this._instance._send_request(k({},e,{transport:"sendBeacon"}))}catch(t){I.error(t)}this.Ai=[]}},ja=class{constructor(e){this.Hi=()=>{var t,i,r,n;this.zi||(this.zi={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+(o?.clientHeight||0),d=o?.scrollHeight||0;this.zi.lastScrollY=Math.ceil(a),this.zi.maxScrollY=Math.max(a,(t=this.zi.maxScrollY)!==null&&t!==void 0?t:0),this.zi.maxScrollHeight=Math.max(l,(i=this.zi.maxScrollHeight)!==null&&i!==void 0?i:0),this.zi.lastContentY=u,this.zi.maxContentY=Math.max(u,(r=this.zi.maxContentY)!==null&&r!==void 0?r:0),this.zi.maxContentHeight=Math.max(d,(n=this.zi.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get Ui(){return this._instance.config.scroll_root_selector}getContext(){return this.zi}resetContext(){var e=this.zi;return setTimeout(this.Hi,0),e}startMeasuringScrollPosition(){me(_,"scroll",this.Hi,{capture:!0}),me(_,"scrollend",this.Hi,{capture:!0}),me(_,"resize",this.Hi)}scrollElement(){if(!this.Ui)return _?.document.documentElement;var e=W(this.Ui)?this.Ui:[this.Ui];for(var t of e){var i=_?.document.querySelector(t);if(i)return i}}scrollY(){if(this.Ui){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this.Ui){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},iE=s=>Yh(s?.config.mask_personal_data_properties,s?.config.custom_personal_data_properties),nn=class{constructor(e,t,i,r){this.Yi=n=>{var o=this.Gi();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.Wi(this._instance)};this.Xi.register({[Aa]:a})}},this._instance=e,this.Ji=t,this.Xi=i,this.Wi=r||iE,this.Ji.onSessionId(this.Yi)}Gi(){return this.Xi.props[Aa]}getSetOnceProps(){var e,t=(e=this.Gi())==null?void 0:e.props;return t?"r"in t?Jh(t):{$referring_domain:t.referringDomain,$pathname:t.initialPathName,utm_source:t.utm_source,utm_campaign:t.utm_campaign,utm_medium:t.utm_medium,utm_content:t.utm_content,utm_term:t.utm_term}:{}}getSessionProps(){var e={};return oe(cl(this.getSetOnceProps()),((t,i)=>{i==="$current_url"&&(i="url"),e["$session_entry_"+ra(i)]=t})),e}},Ci=class{constructor(){this.Ki={}}on(e,t){return this.Ki[e]||(this.Ki[e]=[]),this.Ki[e].push(t),()=>{this.Ki[e]=this.Ki[e].filter((i=>i!==t))}}emit(e,t){for(var i of this.Ki[e]||[])i(t);for(var r of this.Ki["*"]||[])r(e,t)}},Wo=ce("[SessionId]"),on=class{on(e,t){return this.Qi.on(e,t)}constructor(e,t,i){var r;if(this.tr=[],this.er=void 0,this.Qi=new Ci,this.ir=(u,d)=>!(!Rs(u)||!Rs(d))&&Math.abs(u-d)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===rt)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Rt=e.config,this.Xi=e.persistence,this.rr=void 0,this.nr=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.sr=t||Ut,this.ar=i||Ut;var n=this.Rt.persistence_name||this.Rt.token;if(this._sessionTimeoutMs=1e3*gt(this.Rt.session_idle_timeout_seconds||1800,60,36e3,Wo.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.lr(),this.ur="ph_"+n+"_window_id",this.hr="ph_"+n+"_primary_window_exists",this.cr()){var o=Ie.Wt(this.ur),a=Ie.Wt(this.hr);o&&!a?this.rr=o:Ie.Jt(this.ur),Ie.Xt(this.hr,!0)}if((r=this.Rt.bootstrap)!=null&&r.sessionID)try{var l=(u=>{var d=this.Rt.bootstrap.sessionID.replace(/-/g,"");if(d.length!==32)throw new Error("Not a valid UUID");if(d[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(d.substring(0,12),16)})();this.dr(this.Rt.bootstrap.sessionID,new Date().getTime(),l)}catch(u){Wo.error("Invalid sessionID in bootstrap",u)}this.vr()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this.tr)&&(this.tr=[]),this.tr.push(e),this.nr&&e(this.nr,this.rr),()=>{this.tr=this.tr.filter((t=>t!==e))}}cr(){return this.Rt.persistence!=="memory"&&!this.Xi.fi&&Ie.Ut()}pr(e){e!==this.rr&&(this.rr=e,this.cr()&&Ie.Xt(this.ur,e))}gr(){return this.rr?this.rr:this.cr()?Ie.Wt(this.ur):null}dr(e,t,i){e===this.nr&&t===this._sessionActivityTimestamp&&i===this._sessionStartTimestamp||(this._sessionStartTimestamp=i,this._sessionActivityTimestamp=t,this.nr=e,this.Xi.register({[Hr]:[t,e,i]}))}mr(){var e=this.Xi.props[Hr];return W(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.dr(null,null,null)}destroy(){clearTimeout(this.yr),this.yr=void 0,this.er&&_&&(_.removeEventListener(Kr,this.er,{capture:!1}),this.er=void 0),this.tr=[]}vr(){this.er=()=>{this.cr()&&Ie.Jt(this.hr)},me(_,Kr,this.er,{capture:!1})}checkAndGetSessionAndWindowId(e,t){if(e===void 0&&(e=!1),t===void 0&&(t=null),this.Rt.cookieless_mode===rt)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=t||new Date().getTime(),[r,n,o]=this.mr(),a=this.gr(),l=Rs(o)&&Math.abs(i-o)>864e5,u=!1,d=!n,h=!d&&!e&&this.ir(i,r);d||h||l?(n=this.sr(),a=this.ar(),Wo.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}}),o=i,u=!0):a||(a=this.ar(),u=!0);var f=Rs(r)&&e&&!l?r:i,g=Rs(o)?o:new Date().getTime();return this.pr(a),this.dr(n,f,g),e||this.lr(),u&&this.tr.forEach((p=>p(n,a,u?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:g,changeReason:u?{noSessionId:d,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}lr(){clearTimeout(this.yr),this.yr=setTimeout((()=>{var[e]=this.mr();if(this.ir(new Date().getTime(),e)){var t=this.nr;this.resetSessionId(),this.Qi.emit("forcedIdleReset",{idleSessionId:t})}}),1.1*this.sessionTimeoutMs)}},rg=function(s,e){if(!s)return!1;var t=s.userAgent;if(t&&hd(t,e))return!0;try{var i=s?.userAgentData;if(i!=null&&i.brands&&i.brands.some((r=>hd(r?.brand,e))))return!0}catch{}return!!s.webdriver},an=function(s,e){if(!(function(t){try{new RegExp(t)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(s)}catch{return!1}};ng={exact:(s,e)=>e.some((t=>s.some((i=>t===i)))),is_not:(s,e)=>e.every((t=>s.every((i=>t!==i)))),regex:(s,e)=>e.some((t=>s.some((i=>an(t,i))))),not_regex:(s,e)=>e.every((t=>s.every((i=>!an(t,i))))),icontains:(s,e)=>e.map(Lr).some((t=>s.map(Lr).some((i=>t.includes(i))))),not_icontains:(s,e)=>e.map(Lr).every((t=>s.map(Lr).every((i=>!t.includes(i))))),gt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((r=>i>parseFloat(r)))})),lt:(s,e)=>e.some((t=>{var i=parseFloat(t);return!isNaN(i)&&s.some((r=>i<parseFloat(r)))}))},Lr=s=>s.toLowerCase();za="custom",$d="i.posthog.com",qa=class{constructor(e){this.br={},this.instance=e}get apiHost(){var e=this.instance.config.api_host.trim().replace(/\/$/,"");return e==="https://app.posthog.com"?"https://us.i.posthog.com":e}get flagsApiHost(){var e=this.instance.config.flags_api_host;return e?e.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var e,t=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return t||(t=this.apiHost.replace("."+$d,".posthog.com")),t==="https://app.posthog.com"?"https://us.posthog.com":t}get region(){return this.br[this.apiHost]||(this.br[this.apiHost]=/https:\/\/(app|us|us-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"us":/https:\/\/(eu|eu-assets)(\.i)?\.posthog\.com/i.test(this.apiHost)?"eu":za),this.br[this.apiHost]}endpointFor(e,t){if(t===void 0&&(t=""),t&&(t=t[0]==="/"?t:"/"+t),e==="ui")return this.uiHost+t;if(e==="flags")return this.flagsApiHost+t;if(this.region===za)return this.apiHost+t;var i=$d+t;switch(e){case"assets":return"https://"+this.region+"-assets."+i;case"api":return"https://"+this.region+"."+i}}},te=ce("[Surveys]"),Wa="seenSurvey_",rE=(s,e)=>{var t="$survey_"+e+"/"+s.id;return s.current_iteration&&s.current_iteration>0&&(t="$survey_"+e+"/"+s.id+"/"+s.current_iteration),t},Fd=s=>((e,t)=>{var i=""+Wa+t.id;return t.current_iteration&&t.current_iteration>0&&(i=""+Wa+t.id+"_"+t.current_iteration),i})(0,s),nE=[Go.Popover,Go.Widget,Go.API],oE={ignoreConditions:!1,ignoreDelay:!1,displayType:La.Popover},aE=ce("[PostHog ExternalIntegrations]"),lE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Ka=class{constructor(e){this._instance=e}ni(e,t){var i;(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,e,(r=>{if(r)return aE.error("failed to load script",r);t()}))}startIfEnabledOrStop(){var e=this,t=function(o){var a,l,u;!r||(a=L.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.ni(lE[o],(()=>{var d;(d=L.__PosthogExtensions__)==null||(d=d.integrations)==null||(d=d[o])==null||d.start(e._instance)})),!r&&(l=L.__PosthogExtensions__)!=null&&(l=l.integrations)!=null&&l[o]&&((u=L.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[o])==null||u.stop())};for(var[i,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;t(i)}}},Ai={},Ko=0,Xa=()=>{},Md='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',di="Surveys module not available",Ud="sanitize_properties is deprecated. Use before_send instead",ag="Invalid value for property_denylist config: ",uE=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/,Os="posthog",lg=!eE&&Ge?.indexOf("MSIE")===-1&&Ge?.indexOf("Mozilla")===-1,Bd=s=>{var e;return k({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Fb(T?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:Xa,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:s??"unset",__preview_deferred_init_extensions:!1,debug:Re&&ye(Re?.search)&&Re.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(t){I.error("Bad HTTP status: "+t.statusCode+" "+t.text)},get_device_id:t=>t,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Oa,before_send:void 0,request_queue_config:{flush_interval_ms:Va},error_tracking:{},_onCapture:Xa,__preview_eager_load_replay:!1},(t=>({rageclick:!t||"2025-11-30">t||{content_ignorelist:!0},capture_pageview:!t||"2025-05-24">t||"history_change",session_recording:t&&t>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:t&&t>="2026-01-30"?"head":"body",internal_or_test_user_hostname:t&&t>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(s))},cE=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Vd=s=>{var e={};for(var[t,i]of cE)P(s[t])||(e[i]=s[t]);var r=pe({},e,s);return W(s.property_blacklist)&&(P(s.property_denylist)?r.property_denylist=s.property_blacklist:W(s.property_denylist)?r.property_denylist=[...s.property_blacklist,...s.property_denylist]:I.error(ag+s.property_denylist)),r},Ya=class{constructor(){this.__forceAllowLocalhost=!1}get wr(){return this.__forceAllowLocalhost}set wr(e){I.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},is=class s{_r(e,t){if(e){var i=this.Ir.indexOf(e);i!==-1&&this.Ir.splice(i,1)}return this.Ir.push(t),t.initialize==null||t.initialize(),t}get decideEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,t;return(e=(t=this.featureFlags)==null?void 0:t.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new Ya,this.Cr=!1,this.version=Le.LIB_VERSION,this.Sr=new Ci,this.Ir=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Bd(),this.SentryIntegration=xa,this.sentryIntegration=i=>(function(r,n){var o=zh(r,n);return{name:jh,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.kr=!1,this.Tr=null,this.Ar=null,this.Er=null,this.scrollManager=new ja(this),this.pageViewManager=new Yr(this),this.rateLimiter=new $a(this),this.requestRouter=new qa(this),this.consent=new Na(this),this.externalIntegrations=new Ka(this);var t=(e=s.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=t.featureFlags&&new t.featureFlags(this),this.toolbar=t.toolbar&&new t.toolbar(this),this.surveys=t.surveys&&new t.surveys(this),this.conversations=t.conversations&&new t.conversations(this),this.logs=t.logs&&new t.logs(this),this.experiments=t.experiments&&new t.experiments(this),this.exceptions=t.exceptions&&new t.exceptions(this),this.people={set:(i,r,n)=>{var o=ye(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{var o=ye(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(i=>I.info('send "'+i?.event+'"',i)))}init(e,t,i){if(i&&i!==Os){var r,n=(r=Ai[i])!==null&&r!==void 0?r:new s;return n._init(e,t,i),Ai[i]=n,Ai[Os][i]=n,n}return this._init(e,t,i)}_init(e,t,i){var r,n,o,a;if(t===void 0&&(t={}),P(e)||Fr(e))return I.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 console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config={},t.debug=this.Rr(t.debug),this.Nr=t,this.Mr=[],t.person_profiles?this.Ar=t.person_profiles:t.process_person&&(this.Ar=t.process_person),this.set_config(pe({},Bd(t.defaults),Vd(t),{name:i,token:e})),this.config.on_xhr_error&&I.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=t.disable_compression?void 0:ct.GZipJS;var l=this.Fr();this.persistence=new Si(this.config,l),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Si(k({},this.config,{persistence:"sessionStorage"}),l);var u=k({},this.persistence.props),d=k({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Or=new Ga((D=>this.Pr(D)),this.config.request_queue_config),this.Lr=new Ha(this),this.__request_queue=[];var h=this.config.cookieless_mode===rt||this.config.cookieless_mode===wt&&this.consent.isExplicitlyOptedOut();h||(this.sessionManager=new on(this),this.sessionPropsManager=new nn(this,this.sessionManager,this.persistence));var f=(r=L._POSTHOG_REMOTE_CONFIG)==null||(r=r[this.config.token])==null?void 0:r.config,g=f==null||(n=f.sdkVersion)==null?void 0:n.resolved;if(g&&(uE.test(g)?this._resolvedSdkVersion=g:I.warn("Ignoring invalid preloaded sdkVersion.resolved from remote config: "+g)),this.config.__preview_deferred_init_extensions?(I.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Dr(h)}),0)):(I.info("Initializing extensions synchronously"),this.Dr(h)),Le.DEBUG=Le.DEBUG||this.config.debug,Le.DEBUG&&I.info("Starting in debug mode",{this:this,config:t,thisC:k({},this.config),p:u,s:d}),!this.config.identity_distinct_id||(o=t.bootstrap)!=null&&o.distinctID||(t.bootstrap=k({},t.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((a=t.bootstrap)==null?void 0:a.distinctID)!==void 0){var p=t.bootstrap.distinctID,v=this.get_distinct_id(),m=this.persistence.get_property(st);if(t.bootstrap.isIdentifiedID&&v!=null&&v!==p&&m===Ss)this.identify(p);else if(t.bootstrap.isIdentifiedID&&v!=null&&v!==p&&m===ws)I.warn("Bootstrap distinctID differs from an already-identified user. The existing identity is preserved. Call reset() before reinitializing if you intend to switch users.");else{var y=this.config.get_device_id(Ut()),w=t.bootstrap.isIdentifiedID?y:p;this.persistence.set_property(st,t.bootstrap.isIdentifiedID?ws:Ss),this.register({distinct_id:p,$device_id:w})}}if(h)this.register_once({distinct_id:Pr,$device_id:null},"");else if(!this.get_distinct_id()){var C=this.config.get_device_id(Ut());this.register_once({distinct_id:C,$device_id:C},""),this.persistence.set_property(st,Ss)}return me(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),t.segment?(function(D,R){var N=D.config.segment;if(!N)return R();(function(O,E){var S=O.config.segment;if(!S)return E();var $=G=>{var K=()=>G.anonymousId()||Ut();O.config.get_device_id=K,G.id()&&(O.register({distinct_id:G.id(),$device_id:K()}),O.persistence.set_property(st,ws)),E()},F=S.user();"then"in F&&At(F.then)?F.then($):$(F)})(D,(()=>{N.register((O=>{Promise&&Promise.resolve||Vo.warn("This browser does not have Promise support, and can not use the segment integration");var E=(S,$)=>{if(!$)return S;S.event.userId||S.event.anonymousId===O.get_distinct_id()||(Vo.info("No userId set, resetting PostHog"),O.reset()),S.event.userId&&S.event.userId!==O.get_distinct_id()&&(Vo.info("UserId set, identifying with PostHog"),O.identify(S.event.userId));var F=O.calculateEventProperties($,S.event.properties);return S.event.properties=Object.assign({},F,S.event.properties),S};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:S=>E(S,S.event.event),page:S=>E(S,Is),identify:S=>E(S,Uo),screen:S=>E(S,"$screen")}})(D)).then((()=>{R()}))}))})(this,(()=>this.Br())):this.Br(),At(this.config._onCapture)&&this.config._onCapture!==Xa&&(I.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(D=>this.config._onCapture(D.event,D)))),this.config.ip&&I.warn('The `ip` config option has NO EFFECT AT ALL and has been deprecated. Use a custom transformation or "Discard IP data" project setting instead. See https://posthog.com/tutorials/web-redact-properties#hiding-customer-ip-address for more information.'),this}Dr(e){var t,i,r,n,o,a,l,u=performance.now(),d=k({},s.__defaultExtensionClasses,this.config.__extensionClasses),h=[];d.featureFlags&&this.Ir.push(this.featureFlags=(t=this.featureFlags)!==null&&t!==void 0?t:new d.featureFlags(this)),d.exceptions&&this.Ir.push(this.exceptions=(i=this.exceptions)!==null&&i!==void 0?i:new d.exceptions(this)),d.historyAutocapture&&this.Ir.push(this.historyAutocapture=new d.historyAutocapture(this)),d.tracingHeaders&&this.Ir.push(new d.tracingHeaders(this)),d.siteApps&&this.Ir.push(this.siteApps=new d.siteApps(this)),d.sessionRecording&&!e&&this.Ir.push(this.sessionRecording=new d.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),d.autocapture&&this.Ir.push(this.autocapture=new d.autocapture(this)),d.surveys&&this.Ir.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new d.surveys(this)),d.logs&&this.Ir.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new d.logs(this)),d.conversations&&this.Ir.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new d.conversations(this)),d.productTours&&this.Ir.push(this.productTours=new d.productTours(this)),d.heatmaps&&this.Ir.push(this.heatmaps=new d.heatmaps(this)),d.webVitalsAutocapture&&this.Ir.push(this.webVitalsAutocapture=new d.webVitalsAutocapture(this)),d.exceptionObserver&&this.Ir.push(this.exceptionObserver=new d.exceptionObserver(this)),d.deadClicksAutocapture&&this.Ir.push(this.deadClicksAutocapture=new d.deadClicksAutocapture(this,Hb)),d.toolbar&&this.Ir.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new d.toolbar(this)),d.experiments&&this.Ir.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new d.experiments(this)),this.Ir.forEach((f=>{f.initialize&&h.push((()=>{f.initialize==null||f.initialize()}))})),h.push((()=>{if(this.jr){var f=this.jr;this.jr=void 0,this.Ci(f)}})),this.qr(h,u)}qr(e,t){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-t>=30&&e.length>0)return void setTimeout((()=>{this.qr(e,t)}),0);var i=e.shift();if(i)try{i()}catch(n){I.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-t);this.register_for_session({$sdk_debug_extensions_init_method:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",$sdk_debug_extensions_init_time_ms:r}),this.config.__preview_deferred_init_extensions&&I.info("PostHog extensions initialized ("+r+"ms)")}Ci(e){var t;if(!T||!T.body)return I.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Ci(e)}),500);this.config.__preview_deferred_init_extensions&&(this.jr=e),this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=j(e.supportedCompression,ct.GZipJS)?ct.GZipJS:j(e.supportedCompression,ct.Base64)?ct.Base64:void 0),(t=e.analytics)!=null&&t.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ar?this.Ar:Oa}),this.Ir.forEach((i=>i.onRemoteConfig==null?void 0:i.onRemoteConfig(e)))}Br(){try{this.config.loaded(this)}catch(i){I.critical("`loaded` function failed",i)}if(this.Zr(),this.config.internal_or_test_user_hostname&&Re!=null&&Re.hostname){var e=Re.hostname,t=this.config.internal_or_test_user_hostname;(typeof t=="string"?e===t:t.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.config.cookieless_mode===rt)&&this.$r()}),1),this.Vr=new tn(this),this.Vr.load()}Zr(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Or)==null||e.enable())}_dom_loaded(){this.is_capturing()&&Cr(this.__request_queue,(e=>this.Pr(e))),this.__request_queue=[],this.Zr()}_handle_unload(){var e,t,i,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Hr()&&this.capture(Mo),(t=this.logs)==null||t.flushLogs("sendBeacon"),(i=this.Or)==null||i.unload(),(r=this.Lr)==null||r.unload()):this.Hr()&&this.capture(Mo,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(lg?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=hn(e.url,{ip:this.config.ip?1:0}),e.headers=k({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?this.compression:e.compression,e.disableXHRCredentials=this.config.__preview_disable_xhr_credentials,this.config.__preview_disable_beacon&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(t=>{var i,r,n,o=k({},t);o.timeout=o.timeout||6e4,o.url=xd(o.url,o.compression);var a=(i=o.transport)!==null&&i!==void 0?i:"fetch",l=Ur.filter((d=>!o.disableTransport||!d.transport||!o.disableTransport.includes(d.transport))),u=(r=(n=(function(d,h){for(var f=0;d.length>f;f++)if(d[f].transport===a)return d[f]})(l))==null?void 0:n.method)!==null&&r!==void 0?r:l[0].method;if(!u)throw new Error("No available transport method");a!=="sendBeacon"&&o.data&&o.compression===ct.GZipJS&&ob&&!Nd?tE(o).then((d=>{u(d)})).catch((d=>{if((h=>!(!h||typeof h!="object")&&("name"in h?String(h.name):"")==="NotReadableError")(d))return Nd=!0,void u(k({},o,{compression:void 0,url:xd(t.url,void 0)}));u(o)})):u(o)})(k({},e,{callback:t=>{var i,r;this.rateLimiter.checkForLimiting(t),400>t.statusCode||(i=(r=this.config).on_request_error)==null||i.call(r,t),e.callback==null||e.callback(t)}}))))}Pr(e){this.Lr?this.Lr.retriableRequest(e):this._send_request(e)}_execute_array(e){Ko++;try{var t,i=[],r=[],n=[];Cr(e,(a=>{a&&(W(t=a[0])?n.push(a):At(a)?a.call(this):W(a)&&t==="alias"?i.push(a):W(a)&&t.indexOf("capture")!==-1&&At(this[t])?n.push(a):r.push(a))}));var o=function(a,l){Cr(a,(function(u){if(W(u[0])){var d=l;oe(u,(function(h){d=d[h[0]].apply(d,h.slice(1))}))}else l[u[0]].apply(l,u.slice(1))}))};o(i,this),o(r,this),o(n,this)}finally{Ko--}}push(e){if(Ko>0&&W(e)&&ye(e[0])){var t=s.prototype[e[0]];At(t)&&t.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,t,i){var r,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Or){if(this.is_capturing())if(!P(e)&&ye(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var d=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(d==null||!d.isRateLimited){t!=null&&t.$current_url&&!ye(t?.$current_url)&&(I.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),t==null||delete t.$current_url),e!=="$exception"||i!=null&&i.zr||I.warn("Using `posthog.capture('$exception')` is unreliable because it does not attach required metadata. Use `posthog.captureException(error)` instead, which attaches required metadata automatically."),this.sessionPersistence.update_search_keyword(),this.config.save_campaign_params&&this.sessionPersistence.update_campaign_params(),this.config.save_referrer&&this.sessionPersistence.update_referrer_info(),(this.config.save_campaign_params||this.config.save_referrer)&&this.persistence.set_initial_person_info();var h=new Date,f=i?.timestamp||h,g=Ut(),p={uuid:g,event:e,properties:this.calculateEventProperties(e,t||{},f,g)};e===Is&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),d&&(p.properties.$lib_rate_limit_remaining_tokens=d.remainingTokens),i?.$set&&(p.$set=i?.$set);var v,m=this.Ur(i?.$set_once,e!==wd,e===Uo);if(m&&(p.$set_once=m),i!=null&&i._noTruncate||(n=this.config.properties_string_max_length,o=p,a=O=>ye(O)?O.slice(0,n):O,l=new Set,p=(function O(E,S){return E!==Object(E)?a?a(E):E:l.has(E)?void 0:(l.add(E),W(E)?($=[],Cr(E,(F=>{$.push(O(F))}))):($={},oe(E,((F,G)=>{l.has(F)||($[G]=O(F,G))}))),$);var $})(o)),p.timestamp=f,P(i?.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=h),e===bi.DISMISSED||e===bi.SENT){var y=t?.[Ho.SURVEY_ID],w=t?.[Ho.SURVEY_ITERATION];v={id:y,current_iteration:w},localStorage.getItem(Fd(v))||localStorage.setItem(Fd(v),"true"),p.$set=k({},p.$set,{[rE({id:y,current_iteration:w},e===bi.SENT?"responded":"dismissed")]:!0})}else e===bi.SHOWN&&(p.$set=k({},p.$set,{[Ho.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===Kb.SHOWN){var C=t?.[Id.TOUR_TYPE];C&&(p.$set=k({},p.$set,{[Id.TOUR_LAST_SEEN_DATE+"/"+C]:new Date().toISOString()}))}var D=k({},p.properties.$set,p.$set);if(Ps(D)||this.setPersonPropertiesForFlags(D),!z(this.config.before_send)){var R=this.Yr(p);if(!R)return;p=R}this.Sr.emit("eventCaptured",p);var N={method:"POST",url:(r=i?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:i?._batchKey};return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly?this.Pr(N):this.Or.enqueue(N),p}I.critical("This capture call is ignored due to client rate limiting.")}}else I.error("No event name provided to posthog.capture")}else I.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(t=>e(t.event,t)))}calculateEventProperties(e,t,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return t;var o=n?void 0:this.persistence.remove_event_timer(e),a=k({},t);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,(this.config.cookieless_mode==rt||this.config.cookieless_mode==wt&&this.consent.isExplicitlyOptedOut())&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=k({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ye(a.distinct_id)&&!nt(a.distinct_id)||Fr(a.distinct_id))&&I.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,d=(function(y,w){var C,D,R,N;if(!Ge)return{};var O,E,S,$,F,G,K,X,ve=y?[...Ms,...w||[]]:[],[ke,Ce]=(function(ae){for(var A=0;pd.length>A;A++){var[M,U]=pd[A],B=M.exec(ae),Z=B&&(At(U)?U(B,ae):U);if(Z)return Z}return["",""]})(Ge);return pe(cl({$os:ke,$os_version:Ce,$browser:xh(Ge,navigator.vendor),$device:vd(Ge),$device_type:(E=Ge,S={userAgentDataPlatform:(C=navigator)==null||(C=C.userAgentData)==null?void 0:C.platform,maxTouchPoints:(D=navigator)==null?void 0:D.maxTouchPoints,screenWidth:_==null||(R=_.screen)==null?void 0:R.width,screenHeight:_==null||(N=_.screen)==null?void 0:N.height,devicePixelRatio:_?.devicePixelRatio},X=vd(E),X===bh||X===yh||X==="Kobo"||X==="Kindle Fire"||X===Nh?Ls:X===Ri||X===xs||X===Ii||X===aa?"Console":X===kh?"Wearable":X?We:S?.userAgentDataPlatform==="Android"&&(($=S?.maxTouchPoints)!==null&&$!==void 0?$:0)>0?600>Math.min((F=S?.screenWidth)!==null&&F!==void 0?F:0,(G=S?.screenHeight)!==null&&G!==void 0?G:0)/((K=S?.devicePixelRatio)!==null&&K!==void 0?K:1)?We:Ls:"Desktop"),$timezone:Qh(),$timezone_offset:qb()}),{$current_url:Oi(Re?.href,ve,Pi),$host:Re?.host,$pathname:Re?.pathname,$raw_user_agent:Ge.length>1e3?Ge.substring(0,997)+"...":Ge,$browser_version:Eb(Ge,navigator.vendor),$browser_language:Rd(),$browser_language_prefix:(O=Rd(),typeof O=="string"?O.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.innerWidth,$lib:Le.LIB_NAME,$lib_version:Le.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3})})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties);if(this.sessionManager){var{sessionId:h,windowId:f}=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime());a.$session_id=h,a.$window_id=f}this.sessionPropsManager&&pe(a,this.sessionPropsManager.getSessionProps());try{var g;this.sessionRecording&&pe(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(g=this.Lr)==null?void 0:g.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===za&&(a.$lib_custom_api_host=this.config.api_host),u=e!==Is||n?e!==Mo||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=pe(a,u),e===Is&&T&&(a.title=T.title),!P(o)){var p=i.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}Ge&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser"),(a=pe({},d,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),W(this.config.property_denylist)?oe(this.config.property_denylist,(function(y){delete a[y]})):I.error(ag+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(I.error(Ud),a=v(a,e));var m=this.Gr();return a.$process_person_profile=m,m&&!n&&this.Wr("_calculate_event_properties"),a}Ur(e,t,i){var r;if(t===void 0&&(t=!0),i===void 0&&(i=!1),!this.persistence||!this.Gr()||this.Cr&&!i)return e;var n=this.persistence.get_initial_props(),o=(r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps(),a=pe({},n,o||{},e||{}),l=this.config.sanitize_properties;return l&&(I.error(Ud),a=l(a,"$set_once")),t&&(this.Cr=!0),Ps(a)?void 0:a}register(e,t){var i;(i=this.persistence)==null||i.register(e,t)}register_once(e,t,i){var r;(r=this.persistence)==null||r.register_once(e,t,i)}register_for_session(e){var t;(t=this.sessionPersistence)==null||t.register(e)}unregister(e){var t;(t=this.persistence)==null||t.unregister(e)}unregister_for_session(e){var t;(t=this.sessionPersistence)==null||t.unregister(e)}Xr(e,t){this.register({[e]:t})}getFeatureFlag(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(e,t)}getFeatureFlagPayload(e){var t;return(t=this.featureFlags)==null?void 0:t.getFeatureFlagPayload(e)}getFeatureFlagResult(e,t){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(e,t)}isFeatureEnabled(e,t){var i;return(i=this.featureFlags)==null?void 0:i.isFeatureEnabled(e,t)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,t,i){var r;(r=this.featureFlags)==null||r.updateFlags(e,t,i)}updateEarlyAccessFeatureEnrollment(e,t,i){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,t,i)}getEarlyAccessFeatures(e,t,i){var r;return t===void 0&&(t=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,t,i)}on(e,t){return this.Sr.on(e,t)}onFeatureFlags(e){return this.featureFlags?this.featureFlags.onFeatureFlags(e):(e([],{},{errorsLoading:!0}),()=>{})}onSurveysLoaded(e){return this.surveys?this.surveys.onSurveysLoaded(e):(e([],{isLoaded:!1,error:di}),()=>{})}onSessionId(e){var t,i;return(t=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&t!==void 0?t:()=>{}}getSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getSurveys(e,t):e([],{isLoaded:!1,error:di})}getActiveMatchingSurveys(e,t){t===void 0&&(t=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,t):e([],{isLoaded:!1,error:di})}renderSurvey(e,t){var i;(i=this.surveys)==null||i.renderSurvey(e,t)}displaySurvey(e,t){var i;t===void 0&&(t=oE),(i=this.surveys)==null||i.displaySurvey(e,t)}cancelPendingSurvey(e){var t;(t=this.surveys)==null||t.cancelPendingSurvey(e)}canRenderSurvey(e){var t,i;return(t=(i=this.surveys)==null?void 0:i.canRenderSurvey(e))!==null&&t!==void 0?t:{visible:!1,disabledReason:di}}canRenderSurveyAsync(e,t){var i,r;return t===void 0&&(t=!1),(i=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,t))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:di})}Jr(e){return!e||Fr(e)?(I.critical("Unique user id has not been set in posthog.identify"),!1):e===Pr?(I.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID is only used as a sentinel value.'),!1):!["distinct_id","distinctid"].includes(e.toLowerCase())&&!["undefined","null"].includes(e.toLowerCase())||(I.critical('The string "'+e+'" was set in posthog.identify which indicates an error. This ID should be unique to the user and not a hardcoded string.'),!1)}identify(e,t,i){if(!this.__loaded||!this.persistence)return I.uninitializedWarning("posthog.identify");if(nt(e)&&(e=e.toString(),I.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.Jr(e)&&this.Wr("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Gr)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(vi)&&(this.unregister(vi),this.register({distinct_id:e}));var n,o=(this.persistence.get_property(st)||Ss)===Ss;e!==r&&o?(this.persistence.set_property(st,ws),this.setPersonPropertiesForFlags({$set:t||{},$set_once:i||{}},!1),this.capture(Uo,{distinct_id:e,$anon_distinct_id:r},{$set:t||{},$set_once:i||{}}),this.Er=Ld(e,t,i),(n=this.featureFlags)==null||n.setAnonymousDistinctId(r)):(t||i)&&this.setPersonProperties(t,i),e!==r&&(this.reloadFeatureFlags(),this.unregister(ki))}}setPersonProperties(e,t){if((e||t)&&this.Wr("posthog.setPersonProperties")){var i=Ld(this.get_distinct_id(),e,t);this.Er!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:t||{}},!0),this.capture("$set",{$set:e||{},$set_once:t||{}}),this.Er=i):I.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,t,i){if(e&&t){var r=this.getGroups(),n=r[e]!==t;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:k({},r,{[e]:t})}),n||i){var o={$group_type:e,$group_key:t};i&&(o.$group_set=i),this.capture(wd,o)}i&&this.setGroupPropertiesForFlags({[e]:i}),n&&!i&&this.reloadFeatureFlags()}else I.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(e,t)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,t){var i;t===void 0&&(t=!0),this.Wr("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(e,t))}resetGroupPropertiesForFlags(e){var t;(t=this.featureFlags)==null||t.resetGroupPropertiesForFlags(e)}reset(e){var t,i,r,n,o,a,l,u;if(I.info("reset"),!this.__loaded)return I.uninitializedWarning("posthog.reset");var d=this.get_property(Gr);if(this.consent.reset(),(t=this.persistence)==null||t.clear(),(i=this.sessionPersistence)==null||i.clear(),(r=this.surveys)==null||r.reset(),(n=this.Vr)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.conversations)==null||a.reset(),(l=this.persistence)==null||l.set_property(st,Ss),(u=this.sessionManager)==null||u.resetSessionId(),this.Er=null,this.config.cookieless_mode===rt)this.register_once({distinct_id:Pr,$device_id:null},"");else{var h=this.config.get_device_id(Ut());this.register_once({distinct_id:h,$device_id:e?h:d},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,t){var i;this.config.identity_distinct_id=e,this.config.identity_hash=t,this.alias(e),(i=this.conversations)==null||i.Kr()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.Qr()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,t;return(e=(t=this.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:t,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+t);if(e!=null&&e.withTimestamp&&i){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!i)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}return r}alias(e,t){return e===this.get_property(Mh)?(I.critical("Attempting to create alias for existing People user - aborting."),-2):this.Wr("posthog.alias")?(P(t)&&(t=this.get_distinct_id()),e!==t?(this.Xr(vi,e),this.capture("$create_alias",{alias:e,distinct_id:t})):(I.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var t=k({},this.config);if(be(e)){var i,r,n,o,a,l,u,d,h;pe(this.config,Vd(e));var f=this.Fr();(i=this.persistence)==null||i.update_config(this.config,t,f),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Si(k({},this.config,{persistence:"sessionStorage"}),f);var g=this.Rr(this.config.debug);ht(g)&&(this.config.debug=g),ht(this.config.debug)&&(this.config.debug?(Le.DEBUG=!0,ge.Ut()&&ge.Xt("ph_debug",!0),I.info("set_config",{config:e,oldConfig:t,newConfig:k({},this.config)})):(Le.DEBUG=!1,ge.Ut()&&ge.Jt("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.sessionRecording)==null||n.startIfEnabledOrStop(),(o=this.autocapture)==null||o.startIfEnabled(),(a=this.heatmaps)==null||a.startIfEnabled(),(l=this.exceptionObserver)==null||l.startIfEnabledOrStop(),(u=this.deadClicksAutocapture)==null||u.startIfEnabledOrStop(),(d=this.surveys)==null||d.loadIfEnabled(),this.tn(),(h=this.externalIntegrations)==null||h.startIfEnabledOrStop()}}_overrideSDKInfo(e,t){Le.LIB_NAME=e,Le.LIB_VERSION=t}startSessionRecording(e){var t,i,r,n,o,a=e===!0,l={sampling:a||!(e==null||!e.sampling),linked_flag:a||!(e==null||!e.linked_flag),url_trigger:a||!(e==null||!e.url_trigger),event_trigger:a||!(e==null||!e.event_trigger)};Object.values(l).some(Boolean)&&((t=this.sessionManager)==null||t.checkAndGetSessionAndWindowId(),l.sampling&&((i=this.sessionRecording)==null||i.overrideSampling()),l.linked_flag&&((r=this.sessionRecording)==null||r.overrideLinkedFlag()),l.url_trigger&&((n=this.sessionRecording)==null||n.overrideTrigger("url")),l.event_trigger&&((o=this.sessionRecording)==null||o.overrideTrigger("event"))),this.set_config({disable_session_recording:!1})}stopSessionRecording(){this.set_config({disable_session_recording:!0})}sessionRecordingStarted(){var e;return!((e=this.sessionRecording)==null||!e.started)}captureException(e,t){if(this.exceptions){var i=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:i});return this.exceptions.sendExceptionEvent(k({},r,t))}}captureLog(e){var t;(t=this.logs)==null||t.captureLog(e)}get logger(){var e,t;return(e=(t=this.logs)==null?void 0:t.logger)!==null&&e!==void 0?e:s.en}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var t,i;return(t=(i=this.toolbar)==null?void 0:i.loadToolbar(e))!==null&&t!==void 0&&t}get_property(e){var t;return(t=this.persistence)==null?void 0:t.props[e]}getSessionProperty(e){var t;return(t=this.sessionPersistence)==null?void 0:t.props[e]}toString(){var e,t=(e=this.config.name)!==null&&e!==void 0?e:Os;return t!==Os&&(t=Os+"."+t),t}_isIdentified(){var e,t;return((e=this.persistence)==null?void 0:e.get_property(st))===ws||((t=this.sessionPersistence)==null?void 0:t.get_property(st))===ws}Gr(){var e,t;return!(this.config.person_profiles==="never"||this.config.person_profiles===Oa&&!this._isIdentified()&&Ps(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[vi])&&((t=this.persistence)==null||(t=t.props)==null||!t[qr]))}Hr(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&(this.config.capture_pageview===!0||this.config.capture_pageview==="history_change")}createPersonProfile(){this.Gr()||this.Wr("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Wr("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Wr(e){return this.config.person_profiles==="never"?(I.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.Xr(qr,!0),!0)}Fr(){if(this.config.cookieless_mode==="always")return!0;var e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!==wt)}tn(){var e,t,i,r,n=this.Fr();return((e=this.persistence)==null?void 0:e.fi)!==n&&((i=this.persistence)==null||i.set_disabled(n)),((t=this.sessionPersistence)==null?void 0:t.fi)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var t;if(this.config.cookieless_mode!==rt){if(this.config.cookieless_mode===wt&&this.consent.isExplicitlyOptedOut()){var i,r,n,o,a;this.reset(!0),(i=this.sessionManager)==null||i.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new on(this),this.pageViewManager=new Yr(this),this.persistence&&(this.sessionPropsManager=new nn(this,this.sessionManager,this.persistence));var l=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=s.__defaultExtensionClasses)==null?void 0:a.sessionRecording;l&&(this.sessionRecording=this._r(this.sessionRecording,new l(this)))}var u,d;this.consent.optInOut(!0),this.tn(),this.Zr(),(t=this.sessionRecording)==null||t.startIfEnabledOrStop(),this.config.cookieless_mode==wt&&((u=this.surveys)==null||u.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((d=e?.captureEventName)!==null&&d!==void 0?d:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.$r()}else I.warn(Md)}opt_out_capturing(){var e,t,i;this.config.cookieless_mode!==rt?(this.config.cookieless_mode===wt&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.tn(),this.config.cookieless_mode===wt&&(this.register({distinct_id:Pr,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(t=this.pageViewManager)==null||t.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(i=this.sessionRecording)==null||i.stopRecording(),this.sessionRecording=void 0,this.$r())):I.warn(Md)}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){var e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return this.config.cookieless_mode===rt||(this.config.cookieless_mode===wt?this.consent.isExplicitlyOptedOut()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.tn()}_is_bot(){return qe?rg(qe,this.config.custom_blocked_useragents):void 0}$r(){T&&(T.visibilityState==="visible"?this.kr||(this.kr=!0,this.capture(Is,{title:T.title},{send_instantly:!0}),this.Tr&&(T.removeEventListener(Wr,this.Tr),this.Tr=null)):this.Tr||(this.Tr=this.$r.bind(this),me(T,Wr,this.Tr)))}debug(e){e===!1?(_?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(_?.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)`."),this.set_config({debug:!0}))}ki(){var e,t,i,r,n,o,a=this.Nr||{};return"advanced_disable_flags"in a?!!a.advanced_disable_flags:this.config.advanced_disable_flags!==!1?!!this.config.advanced_disable_flags:this.config.advanced_disable_decide===!0?(I.warn("Config field 'advanced_disable_decide' is deprecated. Please use 'advanced_disable_flags' instead. The old field will be removed in a future major version."),!0):(i="advanced_disable_decide",r=I,n=(t="advanced_disable_flags")in(e=a)&&!z(e[t]),o=i in e&&!z(e[i]),n?e[t]:!!o&&(r&&r.warn("Config field '"+i+"' is deprecated. Please use '"+t+"' instead. The old field will be removed in a future major version."),e[i]))}Yr(e){if(z(this.config.before_send))return e;var t=W(this.config.before_send)?this.config.before_send:[this.config.before_send],i=e;for(var r of t){if(i=r(i),z(i)){var n="Event '"+e.event+"' was rejected in beforeSend function";return cb(e.event)?I.warn(n+". This can cause unexpected behavior."):I.info(n),null}i.properties&&!Ps(i.properties)||I.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return i}getPageViewId(){var e;return(e=this.pageViewManager.ai)==null?void 0:e.pageViewId}captureTraceFeedback(e,t){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:t})}captureTraceMetric(e,t,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:t,$ai_metric_value:String(i)})}Rr(e){var t=ht(e)&&!e,i=ge.Ut()&&ge.Gt("ph_debug")==="true";return!t&&(!!i||e)}};is.__defaultExtensionClasses={},is.en={trace:As=()=>{},debug:As,info:As,warn:As,error:As,fatal:As},(function(s,e){for(var t=0;e.length>t;t++)s.prototype[e[t]]=Lb(s.prototype[e[t]])})(is,["identify"]);fl=["a","button","form","input","select","textarea","label"];dE=["next","previous","prev",">","<"],qd=[".ph-no-rageclick",".ph-no-capture"],Ja=s=>!s||Bt(s,"html")||!gn(s),Wd=(s,e)=>{if(!_||Ja(s))return{parentIsUsefulElement:!1,targetElementList:[]};for(var t=!1,i=[s],r=s;r.parentNode&&!Bt(r,"body");)if(cg(r.parentNode))i.push(r.parentNode.host),r=r.parentNode.host;else{var n=hg(r);if(!n)break;if(e||fl.indexOf(n.tagName.toLowerCase())>-1)t=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(t=!0)}i.push(n),r=n}return{parentIsUsefulElement:t,targetElementList:i}};fg="(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})",hE=new RegExp("^(?:"+fg+")$"),gE=new RegExp(fg),pg="\\d{3}-?\\d{2}-?\\d{4}",fE=new RegExp("^("+pg+")$"),pE=new RegExp("("+pg+")");un=class{constructor(e){this.disabled=e===!1;var t=be(e)?e:{};this.thresholdPx=t.threshold_px||30,this.timeoutMs=t.timeout_ms||1e3,this.clickCount=t.click_count||3,this.clicks=[]}isRageClick(e,t,i){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(t-r.y)<this.thresholdPx&&this.timeoutMs>i-r.timestamp){if(this.clicks.push({x:e,y:t,timestamp:i}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:t,timestamp:i}];return!1}},Xo="$copy_autocapture",Yd=ce("[AutoCapture]");hi=ce("[ExceptionAutocapture]");yE=ce("[TracingHeaders]"),Lt=ce("[Web Vitals]"),Qd=9e5,Zd="disabled",eh="lazy_loading",gi="awaiting_config",$r="missing_config";ce("[SessionRecording]"),ce("[SessionRecording]");Za="[SessionRecording]",$t=ce(Za),bE=ce("[Heatmaps]");sh=ce("[Product Tours]"),Jo="ph_product_tours",EE=["$set_once","$set"],Ft=ce("[SiteApps]"),ih="Error while initializing PostHog app with config id ";el=class{constructor(e){this.rn=new Ci,this.nn=(t,i)=>this.sn(t,i)&&this.an(t,i)&&this.ln(t,i)&&this.un(t,i),this.sn=(t,i)=>i==null||!i.event||t?.event===i?.event,this._instance=e,this.hn=new Set,this.cn=new Set}init(){var e,t;P((e=this._instance)==null?void 0:e._addCaptureHook)||(t=this._instance)==null||t._addCaptureHook(((i,r)=>{this.on(i,r)}))}register(e){var t,i;if(!P((t=this._instance)==null?void 0:t._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this.cn)==null||a.add(o),(l=o.steps)==null||l.forEach((u=>{var d;(d=this.hn)==null||d.add(u?.event||"")}))})),(i=this._instance)!=null&&i.autocapture)){var r,n=new Set;e.forEach((o=>{var a;(a=o.steps)==null||a.forEach((l=>{l!=null&&l.selector&&n.add(l?.selector)}))})),(r=this._instance)==null||r.autocapture.setElementSelectors(n)}}on(e,t){var i;t!=null&&e.length!=0&&(this.hn.has(e)||this.hn.has(t?.event))&&this.cn&&((i=this.cn)==null?void 0:i.size)>0&&this.cn.forEach((r=>{this.dn(t,r)&&this.rn.emit("actionCaptured",r.name)}))}vn(e){this.onAction("actionCaptured",(t=>e(t)))}dn(e,t){if(t?.steps==null)return!1;for(var i of t.steps)if(this.nn(e,i))return!0;return!1}onAction(e,t){return this.rn.on(e,t)}an(e,t){if(t!=null&&t.url){var i,r=e==null||(i=e.properties)==null?void 0:i.$current_url;if(!r||typeof r!="string"||!Ts(r,t.url,t.url_matching||"contains"))return!1}return!0}ln(e,t){return!!this.fn(e,t)&&!!this.pn(e,t)&&!!this.gn(e,t)}fn(e,t){var i;if(t==null||!t.href)return!0;var r=this.mn(e);if(r.length>0)return r.some((a=>Ts(a.href,t.href,t.href_matching||"exact")));var n,o=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!o&&Ts((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",t.href,t.href_matching||"exact")}pn(e,t){var i;if(t==null||!t.text)return!0;var r=this.mn(e);if(r.length>0)return r.some((u=>Ts(u.text,t.text,t.text_matching||"exact")||Ts(u.$el_text,t.text,t.text_matching||"exact")));var n,o,a,l=(e==null||(i=e.properties)==null?void 0:i.$elements_chain)||"";return!!l&&(n=(function(u){for(var d,h=[],f=/(?::|")text="(.*?)"/g;!z(d=f.exec(u));)h.includes(d[1])||h.push(d[1]);return h})(l),o=t.text,a=t.text_matching||"exact",n.some((u=>Ts(u,o,a))))}gn(e,t){var i,r;if(t==null||!t.selector)return!0;var n=e==null||(i=e.properties)==null?void 0:i.$element_selectors;if(n!=null&&n.includes(t.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(t.selector_regex&&o)try{return new RegExp(t.selector_regex).test(o)}catch{return!1}return!1}mn(e){var t;return(e==null||(t=e.properties)==null?void 0:t.$elements)==null?[]:e?.properties.$elements}un(e,t){return t==null||!t.properties||t.properties.length===0||og(t.properties.reduce(((i,r)=>{var n=W(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return i[r.key]={values:n,operator:r.operator||"exact"},i}),{}),e?.properties)}},tl=class{constructor(e){this._instance=e,this.yn=new Map,this.bn=new Map,this.wn=new Map}_n(e,t){return!!e&&og(e.propertyFilters,t?.properties)}In(e,t){var i=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[t])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=i.get(o.name)||[];a.push(r.id),i.set(o.name,a)}}))})),i}Cn(e,t,i){var r=(i===ai.Activation?this.yn:this.bn).get(e),n=[];return this.Sn((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[i])==null||(a=a.values)==null?void 0:a.find((u=>u.name===e));return this._n(l,t)}))}register(e){var t;P((t=this._instance)==null?void 0:t._addCaptureHook)||(this.kn(e),this.xn(e))}xn(e){var t=e.filter((i=>{var r,n;return((r=i.conditions)==null?void 0:r.actions)&&((n=i.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));t.length!==0&&(this.Tn==null&&(this.Tn=new el(this._instance),this.Tn.init(),this.Tn.vn((i=>{this.onAction(i)}))),t.forEach((i=>{var r,n,o,a,l;i.conditions&&(r=i.conditions)!=null&&r.actions&&(n=i.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=i.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.Tn)==null||a.register(i.conditions.actions.values),(l=i.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var d=this.wn.get(u.name);d&&d.push(i.id),this.wn.set(u.name,d||[i.id])}})))})))}kn(e){var t,i=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.events)&&((a=n.conditions)==null||(a=a.events)==null||(a=a.values)==null?void 0:a.length)>0})),r=e.filter((n=>{var o,a;return((o=n.conditions)==null?void 0:o.cancelEvents)&&((a=n.conditions)==null||(a=a.cancelEvents)==null||(a=a.values)==null?void 0:a.length)>0}));i.length===0&&r.length===0||((t=this._instance)==null||t._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.yn=this.In(e,ai.Activation),this.bn=this.In(e,ai.Cancellation))}onEvent(e,t){var i,r=this.re(),n=this.An(),o=this.En(),a=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[n])||[];if(o===e&&t&&a.length>0){var l,u;r.info("event matched, removing item from activated items",{event:e,eventPayload:t,existingActivatedItems:a});var d=(t==null||(l=t.properties)==null?void 0:l.$survey_id)||(t==null||(u=t.properties)==null?void 0:u.$product_tour_id);if(d){var h=a.indexOf(d);0>h||(a.splice(h,1),this.Rn(a))}}else{if(this.bn.has(e)){var f=this.Cn(e,t,ai.Cancellation);f.length>0&&(r.info("cancel event matched, cancelling items",{event:e,itemsToCancel:f.map((p=>p.id))}),f.forEach((p=>{var v=a.indexOf(p.id);0>v||a.splice(v,1),this.Nn(p.id)})),this.Rn(a))}if(this.yn.has(e)){r.info("event name matched",{event:e,eventPayload:t,items:this.yn.get(e)});var g=this.Cn(e,t,ai.Activation);this.Rn(a.concat(g.map((p=>p.id))||[]))}}}onAction(e){var t,i=this.An(),r=((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[i])||[];this.wn.has(e)&&this.Rn(r.concat(this.wn.get(e)||[]))}Rn(e){var t,i=this.re(),r=this.An(),n=[...new Set(e)].filter((o=>!this.Mn(o)));i.info("updating activated items",{activatedItems:n}),(t=this._instance)==null||(t=t.persistence)==null||t.register({[r]:n})}getActivatedIds(){var e,t=this.An();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[t])||[]}getEventToItemsMap(){return this.yn}Fn(){return this.Tn}},sl=class extends tl{constructor(e){super(e)}An(){return"$surveys_activated"}En(){return bi.SHOWN}Sn(e){var t;(t=this._instance)==null||t.getSurveys(e)}Nn(e){var t;(t=this._instance)==null||t.cancelPendingSurvey(e)}re(){return te}Mn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},Qo="SDK is not enabled or survey functionality is not yet loaded",rh="Disabled. Not loading surveys.",kE=_!=null&&_.location?Zr(_.location.hash,"__posthog")||Zr(location.hash,"state"):null,nh="_postHogToolbarParams",oh=ce("[Toolbar]"),Ne=ce("[FeatureFlags]"),Zt=ce("[FeatureFlags]",{debugEnabled:!0}),Zo=`" failed. Feature flags didn't load in time.`,ea="$active_feature_flags",Mt="$override_feature_flags",ah="$feature_flag_payloads",fi="$override_feature_flag_payloads",lh="$feature_flag_request_id",uh=s=>{for(var e={},t=0;s.length>t;t++)e[s[t]]=!0;return e},ch=s=>{var e={};for(var[t,i]of Mr(s||{}))i&&(e[t]=i);return e},ta=ce("[Error tracking]"),dh="Refusing to render web experiment since the viewer is a likely bot",SE={icontains:(s,e)=>!!_&&e.href.toLowerCase().indexOf(s.toLowerCase())>-1,not_icontains:(s,e)=>!!_&&e.href.toLowerCase().indexOf(s.toLowerCase())===-1,regex:(s,e)=>!!_&&an(e.href,s),not_regex:(s,e)=>!!_&&!an(e.href,s),exact:(s,e)=>e.href===s,is_not:(s,e)=>e.href!==s},il=class s{get Rt(){return this._instance.config}constructor(e){var t=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),t.getWebExperiments((r=>{s.On("retrieved web experiments from the server"),t.Pn=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;t.Pn&&(s.On("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=t.Pn)==null||o.set(n.feature_flag_key,n));var a=t._instance.getFeatureFlag(n.feature_flag_key);ye(a)&&n.variants[a]&&t.Ln(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];s.Dn(u)&&t.Ln(n.name,l,u.transforms)}}))}),i)},this._instance=e,this._instance.onFeatureFlags((i=>{this.onFeatureFlags(i)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())s.On(dh);else if(!this.Rt.disable_web_experiments){if(z(this.Pn))return this.Pn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();s.On("applying feature flags",e),e.forEach((t=>{var i;if(this.Pn&&(i=this.Pn)!=null&&i.has(t)){var r,n=this._instance.getFeatureFlag(t),o=(r=this.Pn)==null?void 0:r.get(t);n&&o!=null&&o.variants[n]&&this.Ln(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=s.getWindowLocation();if(e!=null&&e.search){var t=Qr(e?.search,"__experiment_id"),i=Qr(e?.search,"__experiment_variant");t&&i&&(s.On("previewing web experiments "+t+" && "+i),this.getWebExperiments((r=>{this.Bn(parseInt(t),i,r)}),!1,!0))}}loadIfEnabled(){this.Rt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,t,i){if(this.Rt.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!t)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Rt.token),method:"GET",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}Bn(e,t,i){var r=i.filter((n=>n.id===e));r&&r.length>0&&(s.On("Previewing web experiment ["+r[0].name+"] with variant ["+t+"]"),this.Ln(r[0].name,t,r[0].variants[t].transforms))}static Dn(e){return!z(e.conditions)&&s.jn(e)&&s.qn(e)}static jn(e){var t;if(z(e.conditions)||z((t=e.conditions)==null?void 0:t.url))return!0;var i,r,n,o=s.getWindowLocation();return!!o&&((i=e.conditions)==null||!i.url||SE[(r=(n=e.conditions)==null?void 0:n.urlMatchType)!==null&&r!==void 0?r:"icontains"](e.conditions.url,o))}static getWindowLocation(){return _?.location}static qn(e){var t;if(z(e.conditions)||z((t=e.conditions)==null?void 0:t.utm))return!0;var i=qh();if(i.utm_source){var r,n,o,a,l,u,d,h,f=(r=e.conditions)==null||(r=r.utm)==null||!r.utm_campaign||((n=e.conditions)==null||(n=n.utm)==null?void 0:n.utm_campaign)==i.utm_campaign,g=(o=e.conditions)==null||(o=o.utm)==null||!o.utm_source||((a=e.conditions)==null||(a=a.utm)==null?void 0:a.utm_source)==i.utm_source,p=(l=e.conditions)==null||(l=l.utm)==null||!l.utm_medium||((u=e.conditions)==null||(u=u.utm)==null?void 0:u.utm_medium)==i.utm_medium,v=(d=e.conditions)==null||(d=d.utm)==null||!d.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return f&&p&&v&&g}return!1}static On(e){for(var t=arguments.length,i=new Array(t>1?t-1:0),r=1;t>r;r++)i[r-1]=arguments[r];I.info("[WebExperiments] "+e,i)}Ln(e,t,i){this._is_bot()?s.On(dh):t!=="control"?i.forEach((r=>{if(r.selector){var n;s.On("applying transform of variant "+t+" for experiment "+e+" ",r);var o=(n=document)==null?void 0:n.querySelectorAll(r.selector);o?.forEach((a=>{var l=a;r.html&&(l.innerHTML=r.html),r.css&&l.setAttribute("style",r.css)}))}})):s.On("Control variants leave the page unmodified.")}_is_bot(){return qe&&this._instance?rg(qe,this.Rt.custom_blocked_useragents):void 0}},Je=ce("[Conversations]"),es="Conversations not available yet.",_g={trace:{text:"TRACE",number:1},debug:{text:"DEBUG",number:5},info:{text:"INFO",number:9},warn:{text:"WARN",number:13},error:{text:"ERROR",number:17},fatal:{text:"FATAL",number:21}},wE=_g.info;fn={featureFlags:class{constructor(s){this.Zn=!1,this.$n=!1,this.Vn=!1,this.Hn=!1,this.zn=!1,this.Un=!1,this.Yn=!1,this.Gn=!1,this._instance=s,this.featureFlagEventHandlers=[]}get Rt(){return this._instance.config}get Xi(){return this._instance.persistence}Wn(s){return this._instance.get_property(s)}Xn(){var s,e;return(s=(e=this.Xi)==null?void 0:e.pi(this.Rt.feature_flag_cache_ttl_ms))!==null&&s!==void 0&&s}Jn(){return!!this.Xn()&&(this.Gn||this.Vn||(this.Gn=!0,Ne.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Kn(){var s,e=(s=this.Rt.evaluation_contexts)!==null&&s!==void 0?s:this.Rt.evaluation_environments;return!this.Rt.evaluation_environments||this.Rt.evaluation_contexts||this.Yn||(Ne.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.Yn=!0),e!=null&&e.length?e.filter((t=>{var i=t&&typeof t=="string"&&t.trim().length>0;return i||Ne.error("Invalid evaluation context found:",t,"Expected non-empty string"),i})):[]}Qn(){return this.Kn().length>0}initialize(){var s,e,{config:t}=this._instance,i=(s=(e=t.bootstrap)==null?void 0:e.featureFlags)!==null&&s!==void 0?s:{};if(Object.keys(i).length){var r,n,o=(r=(n=t.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(i).filter((u=>!!i[u])).reduce(((u,d)=>(u[d]=i[d]||!1,u)),{}),l=Object.keys(o).filter((u=>a[u])).reduce(((u,d)=>(o[d]&&(u[d]=o[d]),u)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(s,e,t){var i=t!=null&&t.merge?this.getFlagVariants():{},r=t!=null&&t.merge?this.getFlagPayloads():{},n=k({},i,s),o=k({},r,e),a={};for(var[l,u]of Object.entries(n)){var d=typeof u=="string";a[l]={key:l,enabled:!!d||!!u,variant:d?u:void 0,reason:void 0,metadata:P(o?.[l])?void 0:{id:0,version:void 0,description:void 0,payload:o[l]}}}this.receivedFeatureFlags({flags:a})}get hasLoadedFlags(){return this.$n}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var s=this.Wn(Ea),e=this.Wn(Mt),t=this.Wn(fi);if(!t&&!e)return s||{};var i=pe({},s||{}),r=[...new Set([...Object.keys(t||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=i[n],u=e?.[n],d=P(u)?(o=l?.enabled)!==null&&o!==void 0&&o:!!u,h=P(u)?l.variant:typeof u=="string"?u:void 0,f=t?.[n],g=k({},l,{enabled:d,variant:d?h??l?.variant:void 0});d!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),f&&(g.metadata=k({},l?.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),i[n]=g}return this.Zn||(Ne.warn(" Overriding feature flag details!",{flagDetails:s,overriddenPayloads:t,finalDetails:i}),this.Zn=!0),i}getFlagVariants(){var s=this.Wn(Cs),e=this.Wn(Mt);if(!e)return s||{};for(var t=pe({},s),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.Zn||(Ne.warn(" Overriding feature flags!",{enabledFlags:s,overriddenFlags:e,finalFlags:t}),this.Zn=!0),t}getFlagPayloads(){var s=this.Wn(ah),e=this.Wn(fi);if(!e)return s||{};for(var t=pe({},s||{}),i=Object.keys(e),r=0;i.length>r;r++)t[i[r]]=e[i[r]];return this.Zn||(Ne.warn(" Overriding feature flag payloads!",{flagPayloads:s,overriddenPayloads:e,finalPayloads:t}),this.Zn=!0),t}reloadFeatureFlags(){this.Hn||this.Rt.advanced_disable_feature_flags||this.ts||(this._instance.Sr.emit("featureFlagsReloading",!0),this.ts=setTimeout((()=>{this.es()}),5))}rs(){clearTimeout(this.ts),this.ts=void 0}ensureFlagsLoaded(){this.$n||this.Vn||this.ts||this.reloadFeatureFlags()}setAnonymousDistinctId(s){this.$anon_distinct_id=s}setReloadingPaused(s){this.Hn=s}es(s){var e;if(this.rs(),!this._instance.ki())if(this.Vn)this.zn=!0;else{var t=this.Rt.token,i=this.Wn(Gr),r={token:t,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:k({},((e=this.Xi)==null?void 0:e.get_initial_props())||{},this.Wn(yi)||{}),group_properties:this.Wn(ts),timezone:Qh()};Rt(i)||P(i)||(r.$device_id=i),(s!=null&&s.disableFlags||this.Rt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.Qn()&&(r.evaluation_contexts=this.Kn());var n=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.Rt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Vn=!0,this._instance._send_request({method:"POST",url:n,data:r,compression:this.Rt.disable_compression?void 0:ct.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback:o=>{var a,l,u,d=!0;if(o.statusCode===200&&(this.zn||(this.$anon_distinct_id=void 0),d=!1),this.Vn=!1,!r.disable_flags||this.zn){this.Un=!d;var h=[];o.error?o.error instanceof Error?h.push(o.error.name==="AbortError"?"timeout":"connection_error"):h.push("unknown_error"):o.statusCode!==200&&h.push("api_error_"+o.statusCode),(a=o.json)!=null&&a.errorsWhileComputingFlags&&h.push("errors_while_computing_flags");var f,g=!((l=o.json)==null||(l=l.quotaLimited)==null||!l.includes("feature_flags"));g&&h.push("quota_limited"),(u=this.Xi)==null||u.register({[wa]:h}),g?Ne.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(r.disable_flags||this.receivedFeatureFlags((f=o.json)!==null&&f!==void 0?f:{},d,{partialResponse:!!this.Rt.advanced_only_evaluate_survey_feature_flags}),this.zn&&(this.zn=!1,this.es()))}}})}}getFeatureFlag(s,e){var t;if(e===void 0&&(e={}),!e.fresh||this.Un)if(this.$n||this.getFlags()&&this.getFlags().length>0){if(!this.Jn()){var i=this.getFeatureFlagResult(s,e);return(t=i?.variant)!==null&&t!==void 0?t:i?.enabled}}else Ne.warn('getFeatureFlag for key "'+s+Zo)}getFeatureFlagDetails(s){return this.getFlagsWithDetails()[s]}getFeatureFlagPayload(s){var e=this.getFeatureFlagResult(s,{send_event:!1});return e?.payload}getFeatureFlagResult(s,e){if(e===void 0&&(e={}),!e.fresh||this.Un)if(this.$n||this.getFlags()&&this.getFlags().length>0){if(!this.Jn()){var t=this.getFlagVariants(),i=s in t,r=t[s],n=this.getFlagPayloads()[s],o=String(r),a=this.Wn(lh)||void 0,l=this.Wn(jr)||void 0,u=this.Wn(ki)||{};if(this.Rt.advanced_feature_flags_dedup_per_session){var d,h=this._instance.get_session_id(),f=this.Wn(Sa);h&&h!==f&&(u={},(d=this.Xi)==null||d.register({[ki]:u,[Sa]:h}))}if((e.send_event||!("send_event"in e))&&(!(s in u)||!u[s].includes(o))){var g,p,v,m,y,w,C,D,R,N;W(u[s])?u[s].push(o):u[s]=[o],(g=this.Xi)==null||g.register({[ki]:u});var O=this.getFeatureFlagDetails(s),E=[...(p=this.Wn(wa))!==null&&p!==void 0?p:[]];P(r)&&E.push("flag_missing");var S={$feature_flag:s,$feature_flag_response:r,$feature_flag_payload:n||null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:((v=this.Rt.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[s])||null,$feature_flag_bootstrapped_payload:((m=this.Rt.bootstrap)==null||(m=m.featureFlagPayloads)==null?void 0:m[s])||null,$used_bootstrap_value:!this.Un};P(O==null||(y=O.metadata)==null?void 0:y.version)||(S.$feature_flag_version=O.metadata.version);var $,F=(w=O==null||(C=O.reason)==null?void 0:C.description)!==null&&w!==void 0?w:O==null||(D=O.reason)==null?void 0:D.code;F&&(S.$feature_flag_reason=F),O!=null&&(R=O.metadata)!=null&&R.id&&(S.$feature_flag_id=O.metadata.id),P(O?.original_variant)&&P(O?.original_enabled)||(S.$feature_flag_original_response=P(O.original_variant)?O.original_enabled:O.original_variant),O!=null&&(N=O.metadata)!=null&&N.original_payload&&(S.$feature_flag_original_payload=O==null||($=O.metadata)==null?void 0:$.original_payload),E.length&&(S.$feature_flag_error=E.join(",")),this._instance.capture("$feature_flag_called",S)}if(i){var G=n;if(!P(n))try{G=JSON.parse(n)}catch{}return{key:s,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:G}}}}else Ne.warn('getFeatureFlagResult for key "'+s+Zo)}getRemoteConfigPayload(s,e){var t=this.Rt.token,i={distinct_id:this._instance.get_distinct_id(),token:t};this.Qn()&&(i.evaluation_contexts=this.Kn()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:i,compression:this.Rt.disable_compression?void 0:ct.Base64,timeout:this.Rt.feature_flag_request_timeout_ms,callback(r){var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[s]||void 0)}})}isFeatureEnabled(s,e){if(e===void 0&&(e={}),!e.fresh||this.Un){if(this.$n||this.getFlags()&&this.getFlags().length>0){var t=this.getFeatureFlag(s,e);return P(t)?void 0:!!t}Ne.warn('isFeatureEnabled for key "'+s+Zo)}}addFeatureFlagsHandler(s){this.featureFlagEventHandlers.push(s)}removeFeatureFlagsHandler(s){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==s))}receivedFeatureFlags(s,e,t){if(this.Xi){this.$n=!0;var i=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();(function(o,a,l,u,d,h){l===void 0&&(l={}),u===void 0&&(u={}),d===void 0&&(d={});var f=(E=>{var S=E.flags;return S?(E.featureFlags=Object.fromEntries(Object.keys(S).map(($=>{var F;return[$,(F=S[$].variant)!==null&&F!==void 0?F:S[$].enabled]}))),E.featureFlagPayloads=Object.fromEntries(Object.keys(S).filter(($=>S[$].enabled)).filter(($=>{var F;return(F=S[$].metadata)==null?void 0:F.payload})).map(($=>{var F;return[$,(F=S[$].metadata)==null?void 0:F.payload]})))):Ne.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),E})(o),g=f.flags,p=f.featureFlags,v=f.featureFlagPayloads;if(p){var m=o.requestId,y=o.evaluatedAt;if(W(p)){Ne.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var w={};if(p)for(var C=0;p.length>C;C++)w[p[C]]=!0;a&&a.register({[ea]:p,[Cs]:w})}else{var D=p,R=v,N=g;if(h!=null&&h.partialResponse)D=k({},l,D),R=k({},u,R),N=k({},d,N);else if(o.errorsWhileComputingFlags)if(g){var O=new Set(Object.keys(g).filter((E=>{var S;return!((S=g[E])!=null&&S.failed)})));D=k({},l,Object.fromEntries(Object.entries(D).filter((E=>{var[S]=E;return O.has(S)})))),R=k({},u,Object.fromEntries(Object.entries(R||{}).filter((E=>{var[S]=E;return O.has(S)})))),N=k({},d,Object.fromEntries(Object.entries(N||{}).filter((E=>{var[S]=E;return O.has(S)}))))}else D=k({},l,D),R=k({},u,R),N=k({},d,N);a&&a.register(k({[ea]:Object.keys(ch(D)),[Cs]:D||{},[ah]:R||{},[Ea]:N||{}},m?{[lh]:m}:{},y?{[jr]:y}:{}))}}})(s,this.Xi,i,r,n,t),e||(this.Gn=!1),this.ns(e)}}override(s,e){e===void 0&&(e=!1),Ne.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:s,suppressWarning:e})}overrideFeatureFlags(s){if(!this._instance.__loaded||!this.Xi)return Ne.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(s===!1)return this.Xi.unregister(Mt),this.Xi.unregister(fi),this.ns(),Zt.info("All overrides cleared");if(W(s)){var e=uh(s);return this.Xi.register({[Mt]:e}),this.ns(),Zt.info("Flag overrides set",{flags:s})}if(s&&typeof s=="object"&&("flags"in s||"payloads"in s)){var t,i=s;if(this.Zn=!!((t=i.suppressWarning)!==null&&t!==void 0&&t),"flags"in i){if(i.flags===!1)this.Xi.unregister(Mt),Zt.info("Flag overrides cleared");else if(i.flags){if(W(i.flags)){var r=uh(i.flags);this.Xi.register({[Mt]:r})}else this.Xi.register({[Mt]:i.flags});Zt.info("Flag overrides set",{flags:i.flags})}}return"payloads"in i&&(i.payloads===!1?(this.Xi.unregister(fi),Zt.info("Payload overrides cleared")):i.payloads&&(this.Xi.register({[fi]:i.payloads}),Zt.info("Payload overrides set",{payloads:i.payloads}))),void this.ns()}if(s&&typeof s=="object")return this.Xi.register({[Mt]:s}),this.ns(),Zt.info("Flag overrides set",{flags:s});Ne.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:s})}onFeatureFlags(s){if(this.addFeatureFlagsHandler(s),this.$n){var{flags:e,flagVariants:t}=this.ss();s(e,t)}return()=>this.removeFeatureFlagsHandler(s)}updateEarlyAccessFeatureEnrollment(s,e,t){var i,r=(this.Wn(mi)||[]).find((l=>l.flagKey===s)),n={["$feature_enrollment/"+s]:e},o={$feature_flag:s,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),t&&(o.$feature_enrollment_stage=t),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=k({},this.getFlagVariants(),{[s]:e});(i=this.Xi)==null||i.register({[ea]:Object.keys(ch(a)),[Cs]:a}),this.ns()}getEarlyAccessFeatures(s,e,t){e===void 0&&(e=!1);var i=this.Wn(mi),r=t?"&"+t.map((n=>"stage="+n)).join("&"):"";if(i&&!e)return s(i);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.Rt.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this.Xi)==null||o.unregister(mi),(a=this.Xi)==null||a.register({[mi]:l}),s(l)}}})}ss(){var s=this.getFlags(),e=this.getFlagVariants();return{flags:s.filter((t=>e[t])),flagVariants:Object.keys(e).filter((t=>e[t])).reduce(((t,i)=>(t[i]=e[i],t)),{})}}ns(s){var{flags:e,flagVariants:t}=this.ss();this.featureFlagEventHandlers.forEach((i=>i(e,t,{errorsLoading:s})))}setPersonPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Wn(yi)||{},i=s?.$set||(s!=null&&s.$set_once?{}:s),r=s?.$set_once,n={};if(r)for(var o in r)({}).hasOwnProperty.call(r,o)&&(o in t||(n[o]=r[o]));this._instance.register({[yi]:k({},t,n,i)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(yi)}setGroupPropertiesForFlags(s,e){e===void 0&&(e=!0);var t=this.Wn(ts)||{};Object.keys(t).length!==0&&Object.keys(t).forEach((i=>{t[i]=k({},t[i],s[i]),delete s[i]})),this._instance.register({[ts]:k({},t,s)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(s){if(s){var e=this.Wn(ts)||{};this._instance.register({[ts]:k({},e,{[s]:{}})})}else this._instance.unregister(ts)}reset(){this.$n=!1,this.Vn=!1,this.Hn=!1,this.zn=!1,this.Un=!1,this.$anon_distinct_id=void 0,this.rs(),this.Zn=!1}}},AE={sessionRecording:class{get Rt(){return this._instance.config}get Xi(){return this._instance.persistence}get started(){var s;return!((s=this.os)==null||!s.isStarted)}get status(){var s,e;return this.ls===gi||this.ls===$r?this.ls:(s=(e=this.os)==null?void 0:e.status)!==null&&s!==void 0?s:this.ls}constructor(s){if(this._forceAllowLocalhostNetworkCapture=!1,this.ls=Zd,this.us=void 0,this._instance=s,!this._instance.sessionManager)throw $t.error("started without valid sessionManager"),new Error(Za+" started without valid sessionManager. This is a bug.");if(this.Rt.cookieless_mode===rt)throw new Error(Za+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get hs(){var s,e=!((s=this._instance.get_property(Or))==null||!s.enabled),t=!this.Rt.disable_session_recording,i=this.Rt.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&t&&!i}startIfEnabledOrStop(s){var e;if(!this.hs||(e=this.os)==null||!e.isStarted){var t=!P(Object.assign)&&!P(Array.from);this.hs&&t?(this.cs(s),$t.info("starting")):(this.ls=Zd,this.stopRecording())}}cs(s){var e,t,i;this.hs&&(this.ls!==gi&&this.ls!==$r&&(this.ls=eh),L!=null&&(e=L.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(t=L.__PosthogExtensions__)!=null&&t.initSessionRecording?this.ds(s):(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.vs,(r=>{if(r)return $t.error("could not load recorder",r);this.ds(s)})))}stopRecording(){var s,e;(s=this.us)==null||s.call(this),this.us=void 0,(e=this.os)==null||e.stop()}fs(){var s,e;(s=this.us)==null||s.call(this),this.us=void 0,(e=this.os)==null||e.discard()}ps(){var s;(s=this.Xi)==null||s.unregister(Bh)}gs(s,e){if(z(s))return null;var t,i=nt(s)?s:parseFloat(s);return typeof(t=i)!="number"||!Number.isFinite(t)||0>t||t>1?($t.warn(e+" must be between 0 and 1. Ignoring invalid value:",s),null):i}ys(s){if(this.Xi){var e,t,i=this.Xi,r=()=>{var n,o=s.sessionRecording===!1?void 0:s.sessionRecording,a=this.gs((n=this.Rt.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.gs(o?.sampleRate,"remote config sampleRate"),u=a??l;z(u)&&this.ps();var d=o?.minimumDurationMilliseconds;i.register({[Or]:k({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:k({capturePerformance:s.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:P(d)?null:d,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(e=this.us)==null||e.call(this),this.us=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(r)}}onRemoteConfig(s){return"sessionRecording"in s?s.sessionRecording===!1?(this.ys(s),void this.fs()):(this.ys(s),void this.startIfEnabledOrStop()):(this.ls===gi&&(this.ls=$r,$t.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(s,e){var t;e===void 0&&(e="log"),(t=this.os)!=null&&t.log?this.os.log(s,e):$t.warn("log called before recorder was ready")}get vs(){var s,e,t=(s=this._instance)==null||(s=s.persistence)==null?void 0:s.get_property(Or);return(t==null||(e=t.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}bs(){var s,e=this._instance.get_property(Or);if(!e)return!1;var t=(s=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&s!==void 0?s:Date.now();return 36e5>=Date.now()-t}ds(s){var e,t;if((e=L.__PosthogExtensions__)==null||!e.initSessionRecording)return $t.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0});if(this.os||(this.os=(t=L.__PosthogExtensions__)==null?void 0:t.initSessionRecording(this._instance),this.os._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.bs())return this.ls===$r||this.ls===gi?void 0:(this.ls=gi,$t.info("persisted remote config is stale, requesting fresh config before starting"),void new tn(this._instance).load());this.ls=eh,this.os.start(s)}onRRwebEmit(s){var e;(e=this.os)==null||e.onRRwebEmit==null||e.onRRwebEmit(s)}overrideLinkedFlag(){var s,e;this.os||(e=this.Xi)==null||e.register({$replay_override_linked_flag:!0}),(s=this.os)==null||s.overrideLinkedFlag()}overrideSampling(){var s,e;this.os||(e=this.Xi)==null||e.register({$replay_override_sampling:!0}),(s=this.os)==null||s.overrideSampling()}overrideTrigger(s){var e,t;this.os||(t=this.Xi)==null||t.register({[s==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.os)==null||e.overrideTrigger(s)}get sdkDebugProperties(){var s;return((s=this.os)==null?void 0:s.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(s,e){var t;return!((t=this.os)==null||!t.tryAddCustomEvent(s,e))}}},TE={autocapture:class{constructor(s){this.ws=!1,this._s=null,this.Is=!1,this.instance=s,this.rageclicks=new un(s.config.rageclick),this.Cs=null}initialize(){this.startIfEnabled()}get Rt(){var s,e,t=be(this.instance.config.autocapture)?this.instance.config.autocapture:{};return t.url_allowlist=(s=t.url_allowlist)==null?void 0:s.map((i=>new RegExp(i))),t.url_ignorelist=(e=t.url_ignorelist)==null?void 0:e.map((i=>new RegExp(i))),t}Ss(){if(this.isBrowserSupported()){if(_&&T){var s=t=>{t=t||_?.event;try{this.ks(t)}catch(i){Yd.error("Failed to capture event",i)}};if(me(T,"submit",s,{capture:!0}),me(T,"change",s,{capture:!0}),me(T,"click",s,{capture:!0}),this.Rt.capture_copied_text){var e=t=>{this.ks(t=t||_?.event,Xo)};me(T,"copy",e,{capture:!0}),me(T,"cut",e,{capture:!0})}}}else Yd.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.ws&&(this.Ss(),this.ws=!0)}onRemoteConfig(s){s.elementsChainAsString&&(this.Is=s.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[md]:!!s.autocapture_opt_out}),this._s=!!s.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(s){this.Cs=s}getElementSelectors(s){var e,t=[];return(e=this.Cs)==null||e.forEach((i=>{var r=T?.querySelectorAll(i);r?.forEach((n=>{s===n&&t.push(i)}))})),t}get isEnabled(){var s,e,t=(s=this.instance.persistence)==null?void 0:s.props[md];if(Rt(this._s)&&!ht(t)&&!this.instance.ki())return!1;var i=(e=this._s)!==null&&e!==void 0?e:!!t;return!!this.instance.config.autocapture&&!i}ks(s,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var t,i=jd(s);ug(i)&&(i=i.parentNode||null),e==="$autocapture"&&s.type==="click"&&s instanceof MouseEvent&&this.instance.config.rageclick&&(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,s.timeStamp||new Date().getTime())&&(function(h,f){if(!_||Ja(h))return!1;var g,p,v;if(ht(f)?(g=!!f&&qd,p=void 0):(g=(v=f?.css_selector_ignorelist)!==null&&v!==void 0?v:qd,p=f?.content_ignorelist),g===!1)return!1;var{targetElementList:m}=Wd(h,!1);return!(function(y,w){if(y===!1||P(y))return!1;var C;if(y===!0)C=dE;else{if(!W(y))return!1;if(y.length>10)return I.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;C=y.map((D=>D.toLowerCase()))}return w.some((D=>{var{safeText:R,ariaLabel:N}=D;return C.some((O=>R.includes(O)||N.includes(O)))}))})(p,m.map((y=>{var w;return{safeText:Di(y).toLowerCase(),ariaLabel:((w=y.getAttribute("aria-label"))==null?void 0:w.toLowerCase().trim())||""}})))&&!zd(m,g)})(i,this.instance.config.rageclick)&&this.ks(s,"$rageclick");var r=e===Xo;if(i&&(function(h,f,g,p,v){var m,y,w,C;if(g===void 0&&(g=void 0),!_||Ja(h)||(m=g)!=null&&m.url_allowlist&&!Hd(g.url_allowlist)||(y=g)!=null&&y.url_ignorelist&&Hd(g.url_ignorelist))return!1;if((w=g)!=null&&w.dom_event_allowlist){var D=g.dom_event_allowlist;if(D&&!D.some((S=>f.type===S)))return!1}var{parentIsUsefulElement:R,targetElementList:N}=Wd(h,p);if(!(function(S,$){var F=$?.element_allowlist;if(P(F))return!0;var G,K=function(ve){if(F.some((ke=>ve.tagName.toLowerCase()===ke)))return{v:!0}};for(var X of S)if(G=K(X))return G.v;return!1})(N,g)||!zd(N,(C=g)==null?void 0:C.css_selector_allowlist))return!1;var O=_.getComputedStyle(h);if(O&&O.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0;var E=h.tagName.toLowerCase();switch(E){case"html":return!1;case"form":return(v||["submit"]).indexOf(f.type)>=0;case"input":case"select":case"textarea":return(v||["change","click"]).indexOf(f.type)>=0;default:return R?(v||["click"]).indexOf(f.type)>=0:(v||["click"]).indexOf(f.type)>=0&&(fl.indexOf(E)>-1||h.getAttribute("contenteditable")==="true")}})(i,s,this.Rt,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=mE(i,{e:s,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.Rt.element_attribute_ignorelist,elementsChainAsString:this.Is});if(o)return!1;var a=this.getElementSelectors(i);if(a&&a.length>0&&(n.$element_selectors=a),e===Xo){var l,u=dg(_==null||(l=_.getSelection())==null?void 0:l.toString()),d=s.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=d}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return At(T?.querySelectorAll)}},historyAutocapture:class{constructor(s){var e;this._instance=s,this.xs=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(I.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.Ts&&this.Ts(),this.Ts=void 0,I.info("History API monitoring stopped")}monitorHistoryChanges(){var s,e;if(_&&_.history){var t=this;(s=_.history.pushState)!=null&&s.__posthog_wrapped__||Jd(_.history,"pushState",(i=>function(r,n,o){i.call(this,r,n,o),t.As("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||Jd(_.history,"replaceState",(i=>function(r,n,o){i.call(this,r,n,o),t.As("replaceState")})),this.Es()}}As(s){try{var e,t=_==null||(e=_.location)==null?void 0:e.pathname;if(!t)return;t!==this.xs&&this.isEnabled&&this._instance.capture(Is,{navigation_type:s}),this.xs=t}catch(i){I.error("Error capturing "+s+" pageview",i)}}Es(){if(!this.Ts){var s=()=>{this.As("popstate")};me(_,"popstate",s),this.Ts=()=>{_&&_.removeEventListener("popstate",s)}}}},heatmaps:class{get Rt(){return this.instance.config}constructor(s){var e;this.Rs=!1,this.ws=!1,this.Ns=null,this.instance=s,this.Rs=!((e=this.instance.persistence)==null||!e.props[ya]),this.rageclicks=new un(s.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var s=5e3;return be(this.Rt.capture_heatmaps)&&this.Rt.capture_heatmaps.flush_interval_milliseconds&&(s=this.Rt.capture_heatmaps.flush_interval_milliseconds),s}get isEnabled(){return z(this.Rt.capture_heatmaps)?z(this.Rt.enable_heatmaps)?this.Rs:this.Rt.enable_heatmaps:this.Rt.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ws)return;bE.info("starting..."),this.Ms(),this.Tt()}else{var s;clearInterval((s=this.Ns)!==null&&s!==void 0?s:void 0),this.Fs(),this.getAndClearBuffer()}}onRemoteConfig(s){if("heatmaps"in s){var e=!!s.heatmaps;this.instance.persistence&&this.instance.persistence.register({[ya]:e}),this.Rs=e,this.startIfEnabled()}}getAndClearBuffer(){var s=this.T;return this.T=void 0,s}Os(s){this.wt(s.originalEvent,"deadclick")}Tt(){this.Ns&&clearInterval(this.Ns),this.Ns=T?.visibilityState==="visible"?setInterval(this.ji.bind(this),this.flushIntervalMilliseconds):null}Ms(){_&&T&&(this.Ps=this.ji.bind(this),me(_,Kr,this.Ps),this.Ls=s=>this.wt(s||_?.event),me(T,"click",this.Ls,{capture:!0}),this.Ds=s=>this.Bs(s||_?.event),me(T,"mousemove",this.Ds,{capture:!0}),this.js=new Xr(this.instance,Gb,this.Os.bind(this)),this.js.startIfEnabledOrStop(),this.qs=this.Tt.bind(this),me(T,Wr,this.qs),this.ws=!0)}Fs(){var s;_&&T&&(this.Ps&&_.removeEventListener(Kr,this.Ps),this.Ls&&T.removeEventListener("click",this.Ls,{capture:!0}),this.Ds&&T.removeEventListener("mousemove",this.Ds,{capture:!0}),this.qs&&T.removeEventListener(Wr,this.qs),clearTimeout(this.Zs),(s=this.js)==null||s.stop(),this.ws=!1)}$s(s,e){var t=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&gn(u)&&!Bt(u,"body");){if(u===l)return!1;if(j(a,_?.getComputedStyle(u).position))return!0;u=hg(u)}return!1})(jd(s),["fixed","sticky"],r);return{x:s.clientX+(n?0:i),y:s.clientY+(n?0:t),target_fixed:n,type:e}}wt(s,e){var t;if(e===void 0&&(e="click"),!Gd(s.target)&&th(s)){var i=this.$s(s,e);(t=this.rageclicks)!=null&&t.isRageClick(s.clientX,s.clientY,new Date().getTime())&&this.Vs(k({},i,{type:"rageclick"})),this.Vs(i)}}Bs(s){!Gd(s.target)&&th(s)&&(clearTimeout(this.Zs),this.Zs=setTimeout((()=>{this.Vs(this.$s(s,"mousemove"))}),500))}Vs(s){if(_){var e=_.location.href,t=this.Rt.custom_personal_data_properties,i=this.Rt.mask_personal_data_properties?[...Ms,...t||[]]:[],r=Oi(e,i,Pi);this.T=this.T||{},this.T[r]||(this.T[r]=[]),this.T[r].push(s)}}ji(){this.T&&!Ps(this.T)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Xr,webVitalsAutocapture:class{constructor(s){var e;this.Rs=!1,this.ws=!1,this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.Hs=()=>{clearTimeout(this.zs),this.T.metrics.length!==0&&(this._instance.capture("$web_vitals",this.T.metrics.reduce(((t,i)=>k({},t,{["$web_vitals_"+i.name+"_event"]:k({},i),["$web_vitals_"+i.name+"_value"]:i.value})),{})),this.T={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.nt=t=>{var i,r=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0);if(P(r))Lt.error("Could not read session ID. Dropping metrics!");else{this.T=this.T||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.Us();P(n)||(z(t?.name)||z(t?.value)?Lt.error("Invalid metric received",t):!this.Ys||this.Ys>t.value?(this.T.url!==n&&(this.Hs(),this.zs=setTimeout(this.Hs,this.flushToCaptureTimeoutMs)),P(this.T.url)&&(this.T.url=n),this.T.firstMetricTimestamp=P(this.T.firstMetricTimestamp)?Date.now():this.T.firstMetricTimestamp,t.attribution&&t.attribution.interactionTargetElement&&(t.attribution.interactionTargetElement=void 0),this.T.metrics.push(k({},t,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.T.metrics.length===this.allowedMetrics.length&&this.Hs()):Lt.error("Ignoring metric with value >= "+this.Ys,t))}},this.Gs=()=>{if(!this.ws){var t,i,r,n,o=L.__PosthogExtensions__;P(o)||P(o.postHogWebVitalsCallbacks)||({onLCP:t,onCLS:i,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),t&&i&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&t(this.nt.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&i(this.nt.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.nt.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.nt.bind(this)),this.ws=!0):Lt.error("web vitals callbacks not loaded - not starting")}},this._instance=s,this.Rs=!((e=this._instance.persistence)==null||!e.props[Ed]),this.startIfEnabled()}get Ws(){return this._instance.config.capture_performance}get allowedMetrics(){var s,e,t=be(this.Ws)?(s=this.Ws)==null?void 0:s.web_vitals_allowed_metrics:void 0;return z(t)?((e=this._instance.persistence)==null?void 0:e.props[Sd])||["CLS","FCP","INP","LCP"]:t}get flushToCaptureTimeoutMs(){return(be(this.Ws)?this.Ws.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var s=be(this.Ws)?this.Ws.web_vitals_attribution:void 0;return s!=null&&s}get Ys(){var s=be(this.Ws)&&nt(this.Ws.__web_vitals_max_value)?this.Ws.__web_vitals_max_value:Qd;return s>0&&6e4>=s?Qd:s}get isEnabled(){var s=Re?.protocol;if(s!=="http:"&&s!=="https:")return Lt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=be(this.Ws)?this.Ws.web_vitals:ht(this.Ws)?this.Ws:void 0;return ht(e)?e:this.Rs}startIfEnabled(){this.isEnabled&&!this.ws&&(Lt.info("enabled, starting..."),this.ni(this.Gs))}onRemoteConfig(s){if("capturePerformance"in s){var e=be(s.capturePerformance)&&!!s.capturePerformance.web_vitals,t=be(s.capturePerformance)?s.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ed]:e}),this._instance.persistence.register({[Sd]:t})),this.Rs=e,this.startIfEnabled()}}ni(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?s():(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(i=>{i?Lt.error("failed to load script",i):s()}))}Us(){var s=_?_.location.href:void 0;if(s){var e=this._instance.config.custom_personal_data_properties,t=this._instance.config.mask_personal_data_properties?[...Ms,...e||[]]:[];return Oi(s,t,Pi)}Lt.error("Could not determine current URL")}}},RE={exceptionObserver:class{constructor(s){var e,t,i;this.Gs=()=>{var r;if(_&&this.isEnabled&&(r=L.__PosthogExtensions__)!=null&&r.errorWrappingFunctions){var n=L.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,o=L.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,a=L.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Xs&&this.Rt.capture_unhandled_errors&&(this.Xs=n(this.captureException.bind(this))),!this.Js&&this.Rt.capture_unhandled_rejections&&(this.Js=o(this.captureException.bind(this))),!this.Ks&&this.Rt.capture_console_errors&&(this.Ks=a(this.captureException.bind(this)))}catch(l){hi.error("failed to start",l),this.Qs()}}},this._instance=s,this.eo=!((e=this._instance.persistence)==null||!e.props[yd]),this.io=new na({refillRate:(t=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&t!==void 0?t:1,bucketSize:(i=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&i!==void 0?i:10,refillInterval:1e4,qt:hi}),this.Rt=this.ro(),this.startIfEnabledOrStop()}ro(){var s=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return be(s)?e=k({},e,s):(P(s)?this.eo:s)&&(e=k({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Rt.capture_console_errors||this.Rt.capture_unhandled_errors||this.Rt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(hi.info("enabled"),this.Qs(),this.ni(this.Gs)):this.Qs()}ni(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&s(),(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"exception-autocapture",(i=>{if(i)return hi.error("failed to load script",i);s()}))}Qs(){var s,e,t;(s=this.Xs)==null||s.call(this),this.Xs=void 0,(e=this.Js)==null||e.call(this),this.Js=void 0,(t=this.Ks)==null||t.call(this),this.Ks=void 0}onRemoteConfig(s){"autocaptureExceptions"in s&&(this.eo=!!s.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[yd]:this.eo}),this.Rt=this.ro(),this.startIfEnabledOrStop())}onConfigChange(){this.Rt=this.ro()}captureException(s){var e,t,i,r=(e=s==null||(t=s.$exception_list)==null||(t=t[0])==null?void 0:t.type)!==null&&e!==void 0?e:"Exception";this.io.consumeRateLimit(r)?hi.info("Skipping exception capture because of client rate limiting.",{exception:r}):(i=this._instance.exceptions)==null||i.sendExceptionEvent(s)}},exceptions:class{constructor(s){var e,t;this.no=[],this.so=new ua([new da,new ma,new ga,new ha,new va,new pa,new fa,new _a],(function(i){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;r>o;o++)n[o-1]=arguments[o];return function(a,l){l===void 0&&(l=0);for(var u=[],d=a.split(`
|
|
6
|
+
`),h=l;d.length>h;h++){var f=d[h];if(1024>=f.length){var g=_d.test(f)?f.replace(_d,"$1"):f;if(!g.match(/\S*Error: /)){for(var p of n){var v=p(g,i);if(v){u.push(v);break}}if(u.length>=50)break}}}return(function(m){if(!m.length)return[];var y=Array.from(m);return y.reverse(),y.slice(0,50).map((w=>{return k({},w,{filename:w.filename||(C=y,C[C.length-1]||{}).filename,function:w.function||Fs});var C}))})(u)}})("web:javascript",Rb,Pb)),this._instance=s,this.no=(e=(t=this._instance.persistence)==null?void 0:t.get_property(ba))!==null&&e!==void 0?e:[]}onRemoteConfig(s){var e,t,i;if("errorTracking"in s){var r=(e=(t=s.errorTracking)==null?void 0:t.suppressionRules)!==null&&e!==void 0?e:[],n=(i=s.errorTracking)==null?void 0:i.captureExtensionExceptions;this.no=r,this._instance.persistence&&this._instance.persistence.register({[ba]:this.no,[bd]:n})}}get oo(){var s,e=!!this._instance.get_property(bd),t=this._instance.config.error_tracking.captureExtensionExceptions;return(s=t??e)!==null&&s!==void 0&&s}buildProperties(s,e){return this.so.buildFromUnknown(s,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}sendExceptionEvent(s){var e=s.$exception_list;if(this.ao(e)){if(this.lo(e))return void ta.info("Skipping exception capture because a suppression rule matched");if(!this.oo&&this.uo(e))return void ta.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.ho(e))return void ta.info("Skipping exception capture because it was thrown by the PostHog SDK")}return this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",zr:!0})}lo(s){if(s.length===0)return!1;var e=s.reduce(((t,i)=>{var{type:r,value:n}=i;return ye(r)&&r.length>0&&t.$exception_types.push(r),ye(n)&&n.length>0&&t.$exception_values.push(n),t}),{$exception_types:[],$exception_values:[]});return this.no.some((t=>{var i=t.values.map((r=>{var n,o=ng[r.operator],a=W(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return t.type==="OR"?i.some(Boolean):i.every(Boolean)}))}uo(s){return s.flatMap((e=>{var t,i;return(t=(i=e.stacktrace)==null?void 0:i.frames)!==null&&t!==void 0?t:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}ho(s){if(s.length>0){var e,t,i,r,n=(e=(t=s[0].stacktrace)==null?void 0:t.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(i=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}ao(s){return!z(s)&&W(s)}}},IE=k({productTours:class{get Xi(){return this._instance.persistence}constructor(s){this.co=null,this.do=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){"productTours"in s&&(this.Xi&&this.Xi.register({[kd]:!!s.productTours}),this.loadIfEnabled())}loadIfEnabled(){var s,e;this.co||(s=this._instance).config.disable_product_tours||(e=s.persistence)==null||!e.get_property(kd)||this.ni((()=>this.vo()))}ni(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.generateProductTours?s():(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"product-tours",(i=>{i?sh.error("Could not load product tours script",i):s()}))}vo(){var s;!this.co&&(s=L.__PosthogExtensions__)!=null&&s.generateProductTours&&(this.co=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(s,e){if(e===void 0&&(e=!1),!W(this.do)||e){var t=this.Xi;if(t){var i=t.props[Jo];if(W(i)&&!e)return this.do=i,void s(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",callback:r=>{var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return sh.error(o),void s([],{isLoaded:!1,error:o})}var a=W(r.json.product_tours)?r.json.product_tours:[];this.do=a,t&&t.register({[Jo]:a}),s(a,{isLoaded:!0})}})}else s(this.do,{isLoaded:!0})}getActiveProductTours(s){z(this.co)?s([],{isLoaded:!1,error:"Product tours not loaded"}):this.co.getActiveProductTours(s)}showProductTour(s){var e;(e=this.co)==null||e.showTourById(s)}previewTour(s){this.co?this.co.previewTour(s):this.ni((()=>{var e;this.vo(),(e=this.co)==null||e.previewTour(s)}))}dismissProductTour(){var s;(s=this.co)==null||s.dismissTour("user_clicked_skip")}nextStep(){var s;(s=this.co)==null||s.nextStep()}previousStep(){var s;(s=this.co)==null||s.previousStep()}clearCache(){var s;this.do=null,(s=this.Xi)==null||s.unregister(Jo)}resetTour(s){var e;(e=this.co)==null||e.resetTour(s)}resetAllTours(){var s;(s=this.co)==null||s.resetAllTours()}cancelPendingTour(s){var e;(e=this.co)==null||e.cancelPendingTour(s)}}},fn),OE={siteApps:class{constructor(s){this._instance=s,this.fo=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}po(s,e){if(e){var t=this.globalsForEvent(e);this.fo.push(t),this.fo.length>1e3&&(this.fo=this.fo.slice(10))}}get siteAppLoaders(){var s;return(s=L._POSTHOG_REMOTE_CONFIG)==null||(s=s[this._instance.config.token])==null?void 0:s.siteApps}initialize(){if(this.isEnabled){var s=this._instance._addCaptureHook(this.po.bind(this));this.mo=()=>{s(),this.fo=[],this.mo=void 0}}}globalsForEvent(s){var e,t,i,r,n,o,a;if(!s)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],d=this._instance.get_property("$stored_group_properties")||{};for(var[h,f]of Object.entries(d))l[h]={id:u[h],type:h,properties:f};var{$set_once:g,$set:p}=s;return{event:k({},fh(s,EE),{properties:k({},s.properties,p?{$set:k({},(e=(t=s.properties)==null?void 0:t.$set)!==null&&e!==void 0?e:{},p)}:{},g?{$set_once:k({},(i=(r=s.properties)==null?void 0:r.$set_once)!==null&&i!==void 0?i:{},g)}:{}),elements_chain:(n=(o=s.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=s.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(s){var e=this.apps[s.id],t=()=>{var o;!e.errored&&this.fo.length&&(Ft.info("Processing "+this.fo.length+" events for site app with id "+s.id),this.fo.forEach((a=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every((a=>a.processedBuffer||a.errored))&&((o=this.mo)==null||o.call(this))},i=!1,r=o=>{e.errored=!o,e.loaded=!0,Ft.info("Site app with id "+s.id+" "+(o?"loaded":"errored")),i&&t()};try{var{processEvent:n}=s.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),i=!0}catch(o){Ft.error(ih+s.id,o),r(!1)}if(i&&e.loaded)try{t()}catch(o){Ft.error("Error while processing buffered events PostHog app with config id "+s.id,o),e.errored=!0}}yo(){var s=this.siteAppLoaders||[];for(var e of s)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var t of s)this.setupSiteApp(t)}bo(s){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(s);for(var t of Object.values(this.apps))try{t.processEvent==null||t.processEvent(e)}catch(i){Ft.error("Error while processing event "+s.event+" for site app "+t.id,i)}}}onRemoteConfig(s){var e,t,i,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.yo(),void this._instance.on("eventCaptured",(l=>this.bo(l)))):void Ft.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((t=this.mo)==null||t.call(this),(i=s.siteApps)!=null&&i.length)if(this.isEnabled){var n=function(l){var u;L["__$$ph_site_app_"+l]=r._instance,(u=L.__PosthogExtensions__)==null||u.loadSiteApp==null||u.loadSiteApp(r._instance,a,(d=>{if(d)return Ft.error(ih+l,d)}))};for(var{id:o,url:a}of s.siteApps)n(o)}else Ft.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},PE={tracingHeaders:class{constructor(s){this.wo=void 0,this._o=void 0,this.Gs=()=>{var e,t;P(this.wo)&&((e=L.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager)),P(this._o)&&((t=L.__PosthogExtensions__)==null||(t=t.tracingHeadersPatchFns)==null||t._patchFetch(this._instance.config.__add_tracing_headers||[],this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=s}initialize(){this.startIfEnabledOrStop()}ni(s){var e,t;(e=L.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&s(),(t=L.__PosthogExtensions__)==null||t.loadExternalDependency==null||t.loadExternalDependency(this._instance,"tracing-headers",(i=>{if(i)return yE.error("failed to load script",i);s()}))}startIfEnabledOrStop(){var s,e;this._instance.config.__add_tracing_headers?this.ni(this.Gs):((s=this.wo)==null||s.call(this),(e=this._o)==null||e.call(this),this.wo=void 0,this._o=void 0)}}},CE=k({surveys:class{get Rt(){return this._instance.config}constructor(s){this.Io=void 0,this._surveyManager=null,this.Co=!1,this.So=[],this.ko=null,this._instance=s,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this.Rt.disable_surveys){var e=s.surveys;if(z(e))return te.warn("Flags not loaded yet. Not loading surveys.");var t=W(e);this.Io=t?e.length>0:e,te.info("flags response received, isSurveysEnabled: "+this.Io),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var s=[],e=0;e<localStorage.length;e++){var t=localStorage.key(e);(t!=null&&t.startsWith(Wa)||t!=null&&t.startsWith("inProgressSurvey_"))&&s.push(t)}s.forEach((i=>localStorage.removeItem(i)))}loadIfEnabled(){if(!this._surveyManager)if(this.Co)te.info("Already initializing surveys, skipping...");else if(this.Rt.disable_surveys)te.info(rh);else if(this.Rt.cookieless_mode&&this._instance.consent.isOptedOut())te.info("Not loading surveys in cookieless mode without consent.");else{var s=L?.__PosthogExtensions__;if(s){if(!P(this.Io)||this.Rt.advanced_enable_surveys){var e=this.Io||this.Rt.advanced_enable_surveys;this.Co=!0;try{var t=s.generateSurveys;if(t)return void this.xo(t,e);var i=s.loadExternalDependency;if(!i)return void this.To(ul);i(this._instance,"surveys",(r=>{r||!s.generateSurveys?this.To("Could not load surveys script",r):this.xo(s.generateSurveys,e)}))}catch(r){throw this.To("Error initializing surveys",r),r}finally{this.Co=!1}}}else te.error("PostHog Extensions not found.")}}xo(s,e){this._surveyManager=s(this._instance,e),this._surveyEventReceiver=new sl(this._instance),te.info("Surveys loaded successfully"),this.Ao({isLoaded:!0})}To(s,e){te.error(s,e),this.Ao({isLoaded:!1,error:s})}onSurveysLoaded(s){return this.So.push(s),this._surveyManager&&this.Ao({isLoaded:!0}),()=>{this.So=this.So.filter((e=>e!==s))}}getSurveys(s,e){if(e===void 0&&(e=!1),this.Rt.disable_surveys)return te.info(rh),s([]);var t,i=this._instance.get_property(ka);if(i&&!e)return s(i,{isLoaded:!0});typeof Promise<"u"&&this.ko?this.ko.then((r=>{var{surveys:n,context:o}=r;return s(n,o)})):(typeof Promise<"u"&&(this.ko=new Promise((r=>{t=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.Rt.token),method:"GET",timeout:this.Rt.surveys_request_timeout_ms,callback:r=>{var n;this.ko=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;te.error(a);var l={isLoaded:!1,error:a};return s([],l),void(t==null||t({surveys:[],context:l}))}var u,d=r.json.surveys||[],h=d.filter((g=>(function(p){return!(!p.start_date||p.end_date)})(g)&&((function(p){var v;return!((v=p.conditions)==null||(v=v.events)==null||(v=v.values)==null||!v.length)})(g)||(function(p){var v;return!((v=p.conditions)==null||(v=v.actions)==null||(v=v.values)==null||!v.length)})(g))));h.length>0&&((u=this._surveyEventReceiver)==null||u.register(h)),(n=this._instance.persistence)==null||n.register({[ka]:d});var f={isLoaded:!0};s(d,f),t?.({surveys:d,context:f})}}))}Ao(s){for(var e of this.So)try{if(!s.isLoaded)return e([],s);this.getSurveys(e)}catch(t){te.error("Error in survey callback",t)}}getActiveMatchingSurveys(s,e){if(e===void 0&&(e=!1),!z(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(s,e);te.warn("init was not called")}Eo(s){var e=null;return this.getSurveys((t=>{var i;e=(i=t.find((r=>r.id===s)))!==null&&i!==void 0?i:null})),e}Ro(s){if(z(this._surveyManager))return{eligible:!1,reason:Qo};var e=typeof s=="string"?this.Eo(s):s;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(s){if(z(this._surveyManager))return te.warn("init was not called"),{visible:!1,disabledReason:Qo};var e=this.Ro(s);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(s,e){return z(this._surveyManager)?(te.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:Qo})):new Promise((t=>{this.getSurveys((i=>{var r,n=(r=i.find((a=>a.id===s)))!==null&&r!==void 0?r:null;if(n){var o=this.Ro(n);t({visible:o.eligible,disabledReason:o.reason})}else t({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(s,e,t){var i;if(z(this._surveyManager))te.warn("init was not called");else{var r=typeof s=="string"?this.Eo(s):s;if(r!=null&&r.id)if(nE.includes(r.type)){var n=T?.querySelector(e);if(n)return(i=r.appearance)!=null&&i.surveyPopupDelaySeconds?(te.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;te.info("Rendering survey "+r.id+" with delay of "+((o=r.appearance)==null?void 0:o.surveyPopupDelaySeconds)+" seconds"),(a=this._surveyManager)==null||a.renderSurvey(r,n,t),te.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,t);te.warn("Survey element not found")}else te.warn("Surveys of type "+r.type+" cannot be rendered in the app");else te.warn("Survey not found")}}displaySurvey(s,e){var t;if(z(this._surveyManager))te.warn("init was not called");else{var i=this.Eo(s);if(i){var r=i;if((t=i.appearance)!=null&&t.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=k({},i,{appearance:k({},i.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==La.Popover&&e.initialResponses&&te.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(i);if(!n.visible)return void te.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==La.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else te.warn("Survey not found")}}cancelPendingSurvey(s){z(this._surveyManager)?te.warn("init was not called"):this._surveyManager.cancelSurvey(s)}handlePageUnload(){var s;(s=this._surveyManager)==null||s.handlePageUnload()}}},fn),DE={toolbar:class{constructor(s){this.instance=s}No(s){L.ph_toolbar_state=s}Mo(){var s;return(s=L.ph_toolbar_state)!==null&&s!==void 0?s:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(s,e,t){if(s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),Gh(this.instance.config)||!_||!T)return!1;s=s??_.location,t=t??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var i,r=kE||Zr(s.hash,"__posthog")||Zr(s.hash,"state"),n=r?Ad((()=>JSON.parse(atob(decodeURIComponent(r)))))||Ad((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((i=n).source="url",i&&Object.keys(i).length>0&&(n.desiredHash?s.hash=n.desiredHash:t?t.replaceState(t.state,"",s.pathname+s.search):s.hash="")):((i=JSON.parse(e.getItem(nh)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}Fo(s){var e=L.ph_load_toolbar||L.ph_load_editor;!z(e)&&At(e)?e(s,this.instance):oh.warn("No toolbar load function found")}loadToolbar(s){var e=!(T==null||!T.getElementById(Vh));if(!_||e)return!1;var t=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=k({token:this.instance.config.token},s,{apiURL:this.instance.requestRouter.endpointFor("ui")},t?{instrument:!1}:{});if(_.localStorage.setItem(nh,JSON.stringify(k({},i,{source:void 0}))),this.Mo()===2)this.Fo(i);else if(this.Mo()===0){var r;this.No(1),(r=L.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return oh.error("[Toolbar] Failed to load",n),void this.No(0);this.No(2),this.Fo(i)})),me(_,"turbolinks:load",(()=>{this.No(0),this.loadToolbar(i)}))}return!0}Oo(s){return this.loadToolbar(s)}maybeLoadEditor(s,e,t){return s===void 0&&(s=void 0),e===void 0&&(e=void 0),t===void 0&&(t=void 0),this.maybeLoadToolbar(s,e,t)}}},NE=k({experiments:il},fn),xE={conversations:class{constructor(s){this.Po=void 0,this._conversationsManager=null,this.Lo=!1,this.Do=null,this._instance=s}initialize(){this.loadIfEnabled()}onRemoteConfig(s){if(!this._instance.config.disable_conversations){var e=s.conversations;z(e)||(ht(e)?this.Po=e:(this.Po=e.enabled,this.Do=e),this.loadIfEnabled())}}reset(){var s;(s=this._conversationsManager)==null||s.reset(),this._conversationsManager=null,this.Po=void 0,this.Do=null}loadIfEnabled(){if(!(this._conversationsManager||this.Lo||this._instance.config.disable_conversations||Gh(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var s=L?.__PosthogExtensions__;if(s&&!P(this.Po)&&this.Po)if(this.Do&&this.Do.token){this.Lo=!0;try{var e=s.initConversations;if(e)return this.Bo(e),void(this.Lo=!1);var t=s.loadExternalDependency;if(!t)return void this.jo(ul);t(this._instance,"conversations",(i=>{i||!s.initConversations?this.jo("Could not load conversations script",i):this.Bo(s.initConversations),this.Lo=!1}))}catch(i){this.jo("Error initializing conversations",i),this.Lo=!1}}else Je.error("Conversations enabled but missing token in remote config.")}}Bo(s){if(this.Do)try{this._conversationsManager=s(this.Do,this._instance),Je.info("Conversations loaded successfully")}catch(e){this.jo("Error completing conversations initialization",e)}else Je.error("Cannot complete initialization: remote config is null")}jo(s,e){Je.error(s,e),this._conversationsManager=null,this.Lo=!1}show(){this._conversationsManager?this._conversationsManager.show():Je.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Po===!0&&!Rt(this._conversationsManager)}isVisible(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&s!==void 0&&s}sendMessage(s,e,t){var i=this;return it((function*(){return i._conversationsManager?i._conversationsManager.sendMessage(s,e,t):(Je.warn(es),null)}))()}getMessages(s,e){var t=this;return it((function*(){return t._conversationsManager?t._conversationsManager.getMessages(s,e):(Je.warn(es),null)}))()}markAsRead(s){var e=this;return it((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(s):(Je.warn(es),null)}))()}getTickets(s){var e=this;return it((function*(){return e._conversationsManager?e._conversationsManager.getTickets(s):(Je.warn(es),null)}))()}requestRestoreLink(s){var e=this;return it((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(s):(Je.warn(es),null)}))()}restoreFromToken(s){var e=this;return it((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(s):(Je.warn(es),null)}))()}restoreFromUrlToken(){var s=this;return it((function*(){return s._conversationsManager?s._conversationsManager.restoreFromUrlToken():(Je.warn(es),null)}))()}getCurrentTicketId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&s!==void 0?s:null}getWidgetSessionId(){var s,e;return(s=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&s!==void 0?s:null}Kr(){var s;(s=this._conversationsManager)==null||s.setIdentity()}Qr(){var s;(s=this._conversationsManager)==null||s.clearIdentity()}}},LE={logs:class{constructor(s){var e;this.qo=!1,this.Zo=!1,this.qt=ce("[logs]"),this.$o=[],this.Vo=0,this.Ho=0,this.zo=!1,this._instance=s,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.qo=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(s){var e,t=(e=s.logs)==null?void 0:e.captureConsoleLogs;!z(t)&&t&&(this.qo=!0,this.loadIfEnabled())}reset(){this.$o=[],this.Ni&&(clearTimeout(this.Ni),this.Ni=void 0),this.Vo=0,this.Ho=0,this.zo=!1}loadIfEnabled(){if(this.qo&&!this.Zo){var s=L?.__PosthogExtensions__;if(s){var e=s.loadExternalDependency;e?e(this._instance,"logs",(t=>{var i;t||(i=s.logs)==null||!i.initializeLogs?this.qt.error("Could not load logs script",t):(s.logs.initializeLogs(this._instance),this.Zo=!0)})):this.qt.error(ul)}else this.qt.error("PostHog Extensions not found.")}}captureLog(s){var e,t,i,r,n,o;if(this._instance.is_capturing())if(s&&s.body){var a=(e=(t=this._instance.config.logs)==null?void 0:t.flushIntervalMs)!==null&&e!==void 0?e:3e3,l=(i=(r=this._instance.config.logs)==null?void 0:r.maxLogsPerInterval)!==null&&i!==void 0?i:1e3,u=Date.now();if(a>u-this.Ho||(this.Ho=u,this.Vo=0,this.zo=!1),l>this.Vo){this.Vo++;var d=(function(h,f){var g=h.level||"info",{text:p,number:v}=_g[g]||wE,m=String(Date.now())+"000000",y={};f.distinctId&&(y.posthogDistinctId=f.distinctId),f.sessionId&&(y.sessionId=f.sessionId),f.currentUrl&&(y["url.full"]=f.currentUrl),f.activeFeatureFlags&&f.activeFeatureFlags.length>0&&(y.feature_flags=f.activeFeatureFlags);var w=k({},y,h.attributes||{}),C={timeUnixNano:m,observedTimeUnixNano:m,severityNumber:v,severityText:p,body:{stringValue:h.body},attributes:hh(w)};return h.trace_id&&(C.traceId=h.trace_id),h.span_id&&(C.spanId=h.span_id),P(h.trace_flags)||(C.flags=h.trace_flags),C})(s,this.Uo());this.$o.push({record:d}),((n=(o=this._instance.config.logs)==null?void 0:o.maxBufferSize)!==null&&n!==void 0?n:100)>this.$o.length?this.Yo():this.flushLogs()}else this.zo||(this.qt.warn("captureLog dropping logs: exceeded "+l+" logs per "+a+"ms"),this.zo=!0)}else this.qt.warn("captureLog requires a body")}get logger(){return this.Go||(this.Go={trace:(s,e)=>this.captureLog({body:s,level:"trace",attributes:e}),debug:(s,e)=>this.captureLog({body:s,level:"debug",attributes:e}),info:(s,e)=>this.captureLog({body:s,level:"info",attributes:e}),warn:(s,e)=>this.captureLog({body:s,level:"warn",attributes:e}),error:(s,e)=>this.captureLog({body:s,level:"error",attributes:e}),fatal:(s,e)=>this.captureLog({body:s,level:"fatal",attributes:e})}),this.Go}flushLogs(s){if(this.Ni&&(clearTimeout(this.Ni),this.Ni=void 0),this.$o.length!==0){var e=this.$o;this.$o=[];var t=this._instance.config.logs,i=k({"service.name":t?.serviceName||"unknown_service"},t?.environment&&{"deployment.environment":t.environment},t?.serviceVersion&&{"service.version":t.serviceVersion},t?.resourceAttributes),r=(function(o,a){return{resourceLogs:[{resource:{attributes:hh(a)},scopeLogs:[{scope:{name:Le.LIB_NAME},logRecords:o}]}]}})(e.map((o=>o.record)),i),n=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance.Pr({method:"POST",url:n,data:r,compression:"best-available",batchKey:"logs",transport:s})}}Yo(){var s,e;this.Ni||(this.Ni=setTimeout((()=>{this.Ni=void 0,this.flushLogs()}),(s=(e=this._instance.config.logs)==null?void 0:e.flushIntervalMs)!==null&&s!==void 0?s:3e3))}Uo(){var s,e={lib:Le.LIB_NAME};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:t}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=t}if(L!=null&&(s=L.location)!=null&&s.href&&(e.currentUrl=L.location.href),this._instance.featureFlags){var i=this._instance.featureFlags.getFlags();i&&i.length>0&&(e.activeFeatureFlags=i)}return e}}},$E=k({},fn,AE,TE,RE,IE,OE,CE,PE,DE,NE,xE,LE);is.__defaultExtensionClasses=k({},$E);He=(gh=Ai[Os]=new is,(function(){function s(){s.done||(s.done=!0,lg=!1,oe(Ai,(function(e){e._dom_loaded()})))}T!=null&&T.addEventListener?T.readyState==="complete"?s():me(T,"DOMContentLoaded",s,{capture:!1}):_&&I.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),gh)});var bg={};_n(bg,{Posthog:()=>pl});var ns,pl,Eg=Fe(()=>{"use strict";yg();Ys();Qs();ns=class ns{constructor(e,t=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Dt("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let t=`ph_${e}_posthog`,i=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==t);if(i.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;i.forEach(a=>{[o,r,""].forEach(u=>{let d=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${d}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(u=>u.trim().startsWith(`${a}=`));this.log(`cleanupStalePosthogCookies | ${l?"removed":"failed to remove"} stale cookie: ${a}`)})};this.init=()=>{try{let{apiKey:e,api_host:t,config:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=t||ic();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:sc,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,...i.session_recording},before_send:o=>{if(typeof window>"u")return null;let a=window.location.hostname;if(a==="localhost"||a==="127.0.0.1")return o;let l=rc.some(u=>a.endsWith(`.${u}`)||a===u);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...i};He.init(e,n),this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.identifyEvent=(e,t={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let i=this.has_identified&&He.get_distinct_id()===e;e&&!i?(this.log("identifyEvent | identifying user",{user_id:e,traits:t}),He.identify(e,{...t,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),He.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:t,language:i,country_of_residence:r})=>{if(!(!this.has_initialized||!e))try{let n=He.get_property("$stored_person_properties")??{},o={};n.client_id||(o.client_id=e),t&&n.is_internal===void 0&&(o.is_internal=or(t)),i&&!n.language&&(o.language=i),r&&!n.country_of_residence&&(o.country_of_residence=r),Object.keys(o).length>0?(this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:o}),He.setPersonProperties(o)):this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e,country_of_residence:r})}catch(n){console.error("Posthog: Failed to backfill person properties",n)}};this.capture=(e,t)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:t}),He.capture(e,t)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let t=He.isFeatureEnabled(e);return this.log("isFeatureEnabled",{key:e,result:t}),t}catch(t){console.error("Posthog: Failed to check feature flag",t);return}};this.getFeatureFlag=e=>{if(this.has_initialized)try{let t=He.getFeatureFlag(e);return this.log("getFeatureFlag",{key:e,result:t}),t}catch(t){console.error("Posthog: Failed to get feature flag",t);return}};this.getFeatureFlagPayload=e=>{if(this.has_initialized)try{let t=He.getFeatureFlagResult(e)?.payload;return this.log("getFeatureFlagPayload",{key:e,result:t}),t}catch(t){console.error("Posthog: Failed to get feature flag payload",t);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let e=He.featureFlags?.getFlagVariants()??{};return this.log("getAllFlags",{result:e}),e}catch(e){return console.error("Posthog: Failed to get all feature flags",e),{}}};this.onFeatureFlags=e=>{if(!this.has_initialized)return()=>{};try{this.log("onFeatureFlags | subscribing to feature flag changes");let t=He.onFeatureFlags(e);return typeof t=="function"?t:()=>{}}catch(t){return console.error("Posthog: Failed to subscribe to feature flags",t),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),He.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=t,this.init()}};ns.getPosthogInstance=(e,t=!1)=>(ns._instance||(ns._instance=new ns(e,t)),ns._instance);pl=ns});var ME={};_n(ME,{Analytics:()=>kg});fo();Ys();Qs();var ny=4320*60*60,Kt=class Kt{constructor(e,t,i=!1){this.analytics=new gs;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=Dt("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let t=window.location.hostname,n=["webflow.io"].some(u=>t.endsWith(u))?t:t.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let u=new Uint8Array(16);crypto.getRandomValues(u),u[6]=u[6]&15|64,u[8]=u[8]&63|128;let d=Array.from(u,h=>h.toString(16).padStart(2,"0")).join("");o=`${d.slice(0,8)}-${d.slice(8,12)}-${d.slice(12,16)}-${d.slice(16,20)}-${d.slice(20)}`}else throw new Error("Crypto API not available for secure random UUID generation");let l=window.location.protocol==="https:"?"; Secure":"";document.cookie=`${this.rudderstack_anonymous_cookie_key}=${o}; path=/; Domain=${n}; max-age=${ny}; SameSite=Lax${l}`}catch(t){console.warn("RudderStack: Failed to set anonymous ID cookie",t)}};this.getUserId=()=>this.analytics.getUserId();this.init=e=>{if(!e){console.warn("RudderStack: Initialization skipped - no key provided");return}this.log("init | loading SDK",{dataplane:po});try{this.setCookieIfNotExists(),this.analytics.load(e,po,{externalAnonymousIdCookieName:this.rudderstack_anonymous_cookie_key,storage:{type:"localStorage"},lockIntegrationsVersion:!0,onLoaded:()=>{this.has_initialized=!0,this.has_identified=!!this.getUserId(),this.log("init | SDK loaded successfully",{userId:this.getUserId(),anonymousId:this.getAnonymousId()}),this.onLoadedCallback?.()}})}catch(t){console.error("RudderStack: Failed to initialize",t)}};this.identifyEvent=(e,t)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let i=this.getUserId();if(!i||i!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:t}),this.analytics.identify(e,t||{}),this.has_identified=!0}catch(r){console.error("RudderStack: Failed to identify user",r)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,t="Deriv App",i,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...i&&{user_id:i},...r};this.log("pageView | tracking page view",{platform:t,current_page:e,properties:n}),this.analytics.page(t,e,n),this.current_page=e}catch(n){console.error("RudderStack: Failed to track page view",n)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting RudderStack session"),this.analytics.reset(),this.has_identified=!1}catch(e){console.error("RudderStack: Failed to reset",e)}};this.track=(e,t)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:t}),this.analytics.track(e,t)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=t,this.debug=i,this.init(e)}};Kt.getRudderStackInstance=(e,t,i=!1)=>(Kt._instance||(Kt._instance=new Kt(e,t,i)),Kt._instance);var ar=Kt;var lr="cached_analytics_events",ur="cached_analytics_page_views",dc=(s,e)=>{try{let t=localStorage.getItem(lr),i=t?JSON.parse(t):[];i.push({name:s,properties:e,timestamp:Date.now()}),localStorage.setItem(lr,JSON.stringify(i))}catch(t){console.warn("Analytics: Failed to cache event",t)}},hc=(s,e)=>{try{let t=localStorage.getItem(ur),i=t?JSON.parse(t):[];i.push({name:s,properties:e,timestamp:Date.now()}),localStorage.setItem(ur,JSON.stringify(i))}catch(t){console.warn("Analytics: Failed to cache page view",t)}},gc=()=>{try{let s=localStorage.getItem(lr);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached events",s)}return[]},fc=()=>{try{let s=localStorage.getItem(ur);if(s){let e=JSON.parse(s);return Array.isArray(e)?e:[]}}catch(s){console.warn("Analytics: Failed to get cached pages",s)}return[]},pc=()=>{try{localStorage.removeItem(lr)}catch(s){console.warn("Analytics: Failed to clear cached events",s)}},vc=()=>{try{localStorage.removeItem(ur)}catch(s){console.warn("Analytics: Failed to clear cached page views",s)}};Qs();function FE(s){let e=s?.debug??!1,t=Dt("",()=>e),i,r,n,o={},a={},l=[],u=[],d=!1,h=()=>{if(!d&&r?.has_initialized){d=!0;try{let A=gc();A.length>0&&(t(`processStorageCache | replaying ${A.length} cached event(s)`,A),A.forEach(U=>{let B=Wt(U.properties);r?.track(U.name,B)}),pc());let M=fc();M.length>0&&(t(`processStorageCache | replaying ${M.length} cached page view(s)`,M),M.forEach(U=>{r?.pageView(U.name,"Deriv App",D(),U.properties)}),vc())}catch(A){console.warn("Analytics: Failed to process storage cache",A)}}},f=()=>{t("onSdkLoaded | RudderStack SDK loaded"),h(),u.length>0&&t(`onSdkLoaded | flushing ${u.length} pending identify call(s)`),u.forEach(({userId:A,traits:M})=>{A&&r?.identifyEvent(A,M)}),u=[]},g=async({growthbookKey:A,growthbookDecryptionKey:M,rudderstackKey:U,growthbookOptions:B,posthogOptions:Z,debug:de})=>{var ie,_e;de!==void 0&&(e=de),t("initialise | starting analytics initialization",{rudderstack:!!U,growthbook:!!A,posthog:!!Z});try{let Oe=B?.attributes?.country||(A?await lc():void 0);if(U&&(t("initialise | initializing RudderStack"),r=ar.getRudderStackInstance(U,f,e)),B?.attributes&&Object.keys(B.attributes).length>0){let H=B.attributes,ft=r?.getAnonymousId();o={...o,country:Oe,...H.user_language&&{user_language:H.user_language},...H.account_type&&{account_type:H.account_type},...H.app_id&&{app_id:H.app_id},...H.residence_country&&{residence_country:H.residence_country},...H.device_type&&{device_type:H.device_type},...H.url&&{url:H.url},...H.email_hash&&{email_hash:H.email_hash},...H.network_type&&{network_type:H.network_type},...H.network_rtt&&{network_rtt:H.network_rtt},...H.network_downlink&&{network_downlink:H.network_downlink},...H.account_currency&&{account_currency:H.account_currency},...H.account_mode&&{account_mode:H.account_mode},loggedIn:!!H.loggedIn,...H.user_id&&!Js(H.user_id)&&{user_id:H.user_id},...ft&&{anonymous_id:ft}}}B??(B={}),B.attributes??(B.attributes={});let Se=r?.getAnonymousId();if((ie=B.attributes).id??(ie.id=Se),(_e=B.attributes).country??(_e.country=Oe),A){t("initialise | initializing GrowthBook");let{Growthbook:H}=await Promise.resolve().then(()=>(ld(),ad));i=H.getGrowthBookInstance(A,M,B,e),t("initialise | GrowthBook initialized");let ft=setInterval(()=>{Object.keys(a).length>0?clearInterval(ft):a=m("tracking-buttons-config",{})},1e3)}if(Z){t("initialise | initializing PostHog");let{Posthog:H}=await Promise.resolve().then(()=>(Eg(),bg));n=H.getPosthogInstance(Z,e),t("initialise | PostHog initialized")}t("initialise | analytics initialization complete")}catch(Oe){console.warn("Analytics: Failed to initialize",Oe)}},p=A=>{t("setAttributes | received attributes",A);let{user_id:M,...U}=A,B=M??D();if(i){let Z={...U};M&&!Js(M)&&(Z.user_id=M),B&&(Z.id=B,Z.user_id=B),t("setAttributes | called GrowthBook setAttributes",Z),i.setAttributes(Z)}o={...o,...Object.fromEntries(Object.entries(U).filter(([,Z])=>Z!==void 0)),...M!==void 0&&!Js(M)&&{user_id:M}},t("setAttributes | updated core_data",o)},v=A=>i?.getFeatureState(A)?.experimentResult?.name,m=(A,M)=>i?.getFeatureValue(A,M),y=async()=>await i?.getStatus(),w=A=>i?.isOn(A),C=A=>i?.setUrl(A),D=()=>{let A=r?.getUserId()||"";return A&&!Js(A)?A:""},ae={initialise:g,setAttributes:p,identifyEvent:(A,M)=>{let U=A||D();if(!U){t("identifyEvent | skipped \u2014 no user_id available");return}t("identifyEvent | called",{user_id:U,traits:M});let B=_e=>{if(!_e)return _e;let{email:Oe,...Se}=_e;return{...Se,...Oe&&{is_internal:or(Oe)}}},Z=M?.rudderstack!==void 0||M?.posthog!==void 0,de,ie;if(Z){let{rudderstack:_e,posthog:Oe,...Se}=M;de=B({...Se,..._e}),ie=B({...Se,...Oe})}else de=B(M),ie=B(M);r&&(r.has_initialized?(t("identifyEvent | calling RudderStack identify",{user_id:U,traits:de}),r.identifyEvent(U,de)):u.some(_e=>_e.userId===U)||(t("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:U}),u.push({userId:U,traits:de}))),n?.has_initialized&&(t("identifyEvent | calling PostHog identify",{user_id:U,traits:ie}),n.identifyEvent(U,ie))},backfillPersonProperties:({user_id:A,email:M,language:U,country_of_residence:B})=>{t("backfillPersonProperties | called",{user_id:A}),n?.has_initialized?(t("backfillPersonProperties | backfilling person properties in PostHog",{user_id:A}),n.backfillPersonProperties({user_id:A,email:M,language:U,country_of_residence:B})):t("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:m,getGrowthbookStatus:y,isFeatureOn:w,setUrl:C,getId:D,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(A,M)=>{let U=D();t("trackEvent | called",{event:A,analytics_data:M,userId:U,core_data:o});let B={...o,...M,...U&&!o.user_id&&{user_id:U}};if(t("trackEvent | built payload",{event:A,final_payload:B}),!(!(A in a)||a[A])){t("trackEvent | skipped \u2014 event disabled by tracking_config",{event:A});return}let de=r?.has_initialized;if(!navigator.onLine||!de)de?(t("trackEvent | offline \u2014 caching event to memory",{event:A}),l.push({event:A,payload:B})):(t("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:A}),dc(A,B));else{l.length>0&&(t(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(_e=>{let Oe=Wt(_e.payload);r?.track(_e.event,Oe)}),l=[]);let ie=Wt(B);t("trackEvent | sending event to RudderStack",{event:A,payload:ie}),r?.track(A,ie)}if(n?.has_initialized){let ie=Wt(cc(B));t("trackEvent | sending event to PostHog",{event:A,payload:ie}),n.capture(A,ie)}},getInstances:()=>({ab:i,tracking:r,posthog:n}),pageView:(A,M="Deriv App",U)=>{let B=D();t("pageView | called",{current_page:A,platform:M,properties:U,userId:B}),r?.has_initialized?(t("pageView | sending page view to RudderStack",{current_page:A,platform:M}),r.pageView(A,M,B,U)):(t("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:A}),hc(A,{platform:M,...U}))},reset:()=>{t("reset | resetting all providers"),r?.has_initialized&&(t("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(t("reset | resetting PostHog"),n.reset())},isPosthogFeatureEnabled:A=>n?.isFeatureEnabled(A),getPosthogFeatureFlag:A=>n?.getFeatureFlag(A),getPosthogFeatureFlagPayload:A=>n?.getFeatureFlagPayload(A),getPosthogAllFlags:()=>n?.getAllFlags()??{},onPosthogFeatureFlags:A=>n?.onFeatureFlags(A)??(()=>{}),reloadPosthogFeatureFlags:()=>n?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=ae),ae}var kg=FE();return Ng(ME);})();
|
|
7
7
|
/*! Bundled license information:
|
|
8
8
|
|
|
9
9
|
js-cookie/dist/js.cookie.mjs:
|