@deriv-com/analytics 1.42.0 → 1.43.0
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/README.md +144 -61
- package/dist/browser/analytics.bundle.global.js +7 -6
- 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/chunk-2R54Y2IU.mjs +4 -0
- package/dist/chunk-2R54Y2IU.mjs.map +1 -0
- package/dist/chunk-34EEFBSP.mjs +5 -0
- package/dist/chunk-34EEFBSP.mjs.map +1 -0
- package/dist/chunk-MHY63WMT.mjs +9 -0
- package/dist/chunk-MHY63WMT.mjs.map +1 -0
- package/dist/chunk-TWWU2RKG.js +3 -0
- package/dist/chunk-TWWU2RKG.js.map +1 -0
- package/dist/chunk-XZPWAV3F.mjs +3 -0
- package/dist/chunk-XZPWAV3F.mjs.map +1 -0
- package/dist/{chunk-T4BXL6JM.js → chunk-ZAFMAIS7.js} +3 -3
- package/dist/chunk-ZAFMAIS7.js.map +1 -0
- package/dist/{growthbook-TBZXPHJZ.mjs → growthbook-SXLFY3KI.mjs} +2 -2
- package/dist/index.d.mts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- 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-ctBaPjWr.d.ts → posthog-BlpiD6V1.d.mts} +17 -0
- package/dist/{posthog-ctBaPjWr.d.mts → posthog-BlpiD6V1.d.ts} +17 -0
- package/dist/posthog-LBWKPBQW.mjs +5 -0
- package/dist/posthog-LBWKPBQW.mjs.map +1 -0
- package/dist/providers/growthbook/index.js +2 -2
- package/dist/providers/growthbook/index.mjs +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 +2 -2
- package/dist/providers/posthog/index.js.map +1 -1
- package/dist/providers/posthog/index.mjs +2 -2
- package/dist/providers/posthog/index.mjs.map +1 -1
- package/dist/providers/rudderstack/index.d.mts +4 -2
- package/dist/providers/rudderstack/index.d.ts +4 -2
- package/dist/providers/rudderstack/index.js +1 -1
- package/dist/providers/rudderstack/index.mjs +1 -1
- package/package.json +16 -15
- package/dist/chunk-4V72P52P.mjs +0 -3
- package/dist/chunk-4V72P52P.mjs.map +0 -1
- package/dist/chunk-6BHMKTVG.js +0 -3
- package/dist/chunk-6BHMKTVG.js.map +0 -1
- package/dist/chunk-F3U33XPR.mjs +0 -9
- package/dist/chunk-F3U33XPR.mjs.map +0 -1
- package/dist/chunk-MWNJTXSL.mjs +0 -5
- package/dist/chunk-MWNJTXSL.mjs.map +0 -1
- package/dist/chunk-T4BXL6JM.js.map +0 -1
- package/dist/chunk-TE3DYZVQ.mjs +0 -4
- package/dist/chunk-TE3DYZVQ.mjs.map +0 -1
- package/dist/posthog-54CQ2T32.mjs +0 -4
- package/dist/posthog-54CQ2T32.mjs.map +0 -1
- /package/dist/{growthbook-TBZXPHJZ.mjs.map → growthbook-SXLFY3KI.mjs.map} +0 -0
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
/* @deriv-com/analytics - Browser IIFE Bundle (RudderStack + PostHog) - Built with tsup */
|
|
2
|
-
"use strict";var DerivAnalytics=(()=>{var
|
|
3
|
-
`);return e.some(i=>zu.test(i))?e.map($v).filter(i=>i!==null):e.map(Fv).filter(i=>i!==null)}function tu(t,e,i,s){return{errorClass:eu(t),message:`${i}${eu(e)}`,type:"browserjs",stacktrace:s.reduce((r,n)=>{let o=Bv(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function ic(t,e){let i=Object.assign(t,e);for(let s of Object.keys(i))typeof i[s]=="object"&&typeof e[s]=="object"&&(i[s]=ic(i[s],e[s]));return i}async function w_(t){let e=S_[t];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((i,s)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=k_();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}i(e.lib)}).catch(s)})})}function Me(t,e){if(!t?.default&&e){let i=Object.create(null);return i.default=t,i.__esModule=!0,i}return t}function Ue(t,e){return w_(t).then(i=>i.get(e).then(s=>s()))}function em(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function im(){return lu||(lu=1,(function(t,e){(function(i,s){t.exports=s()})(tm,function(){function i(g){return g=JSON.stringify(g),!!/^\{[\s\S]*\}$/.test(g)}function s(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,R){return m._data[w]=String(R)},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&&!i(p))l.setItem(p,s(v));else if(i(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(b,x){return v[b]=x}),v}if(p.charAt(0)==="?")return this.has(p.substr(1));var m=arguments;if(m.length>1){for(var y={},w=0,R=m.length;w<R;w++){var N=r(l.getItem(m[w]));this.has(m[w])&&(y[m[w]]=N)}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 c=null;function h(g,p){var v=arguments,m=null;if(c||(c=u()),v.length===0)return c.get();if(v.length===1){if(typeof g=="string")return c.get(g);if(i(g))return c.set(g)}if(v.length===2&&typeof g=="string"){if(!p)return c.remove(g);if(p&&typeof p=="string")return c.set(g,p);p&&n(p)&&(m=null,m=p(g,c.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],c.get(g[y])),h.set(g[y],m);return h}for(var f in u.prototype)h[f]=u.prototype[f];return h})})(Hs)),Hs.exports}var zg,Kg,Jg,W,Zg,ef,tf,sf,bu,D,re,Ve,Ie,st,rf,te,hi,nf,lo,of,xn,af,lf,uf,ne,cf,we,bt,Hi,Ks,pt,ot,uo,df,Ul,Ws,hf,gf,Ys,co,Eu,Su,ku,kn,ho,Nn,Ye,wu,qi,Gt,zi,li,ff,wn,pf,vf,_f,Ms,Bl,Vs,Nt,An,Ht,Gs,Us,Ef,ir,Sf,kf,wf,Au,Af,V,If,Vl,Tf,Rf,Pf,Of,Cf,xf,Nf,Iu,Df,it,Lf,Tu,X,Ru,sr,go,fe,Gl,Xi,$f,Pu,Ff,ql,Mf,Uf,Wi,Bf,Vf,Gf,jl,qf,Hl,jf,Hf,zl,Dn,Kl,zf,Kf,Ou,Ji,Cu,Wl,Yf,Xf,Jf,Qf,Zf,ep,tp,ip,sp,rp,Xs,np,J,Yi,yt,Js,op,Ln,Qs,Zs,$n,Bs,Yl,Mu,lp,up,cp,Fn,Et,vt,Uu,Mn,Xl,dp,hp,gp,fp,pp,vp,_p,mp,Jl,yp,bp,Ep,Sp,kp,wp,Ap,Ql,Ip,Tp,Bu,Rp,Pp,Op,Cp,xp,Np,Dp,Zl,Lp,$p,Fp,Mp,Up,Bp,Vp,Gp,qp,jp,Hp,zp,Kp,Wp,Yp,Xp,Jp,Qp,Zp,ev,tv,iv,sv,rv,nv,ov,av,Vu,nr,Gu,lv,Qi,or,po,qu,ju,Hu,qt,uv,Un,qs,cv,dv,hv,gv,fv,pv,Q,In,vv,_v,mv,yv,bv,Ev,Sv,kv,wv,Av,Iv,Tv,Rv,Pv,Ov,Cv,xv,Nv,d,zu,Dv,Lv,Wu,Uv,Bv,eu,Yu,Vv,iu,js,Gv,qv,jv,Hv,zv,Kv,Wv,Yv,su,ru,Bn,Xu,Xv,Jv,Qv,Zv,e_,t_,i_,Ju,s_,r_,n_,o_,a_,l_,u_,c_,d_,h_,Qu,Zu,g_,f_,p_,v_,Vn,ec,Gn,__,m_,y_,nu,b_,tc,E_,S_,k_,A_,I_,sc,T_,R_,Tn,P_,qn,Be,je,We,at,zt,O_,C_,x_,N_,D_,L_,$_,F_,M_,U_,B_,V_,ui,G_,rc,nc,q_,oc,ac,ci,ou,au,j_,H_,jn,z_,_t,K_,W_,Y_,X_,J_,Q_,Z_,Hn,er,Hs,tm,lu,sm,Vt,lc,di,zn,vo,Kn,_o,Wn,mo,tt,rm,nm,om,am,lm,Yn,um,Xn,cm,dm,uc,hm,gm,fm,gi,Jn,cc,pm,vm,_m,fi,Rn,Pn,mm,ym,bm,uu,Em,dc,Sm,km,wm,Am,Im,Tm,Rm,Pm,Om,hc,Cm,xm,Qn,Nm,gc,Dm,Lm,$m,fc,Fm,Mm,Zn,Um,Bm,Vm,Gm,cu,qm,du,jm,hu,eo,Hm,zm,gu,On,pc,Km,tr,fu,vc,pu,Wm,Ym,Xm,Jm,Qm,Ki,to,Zm,ey,ty,Cn,iy,sy,ry,ny,oy,ji,io,so,ro,ay,ly,uy,vu,_u,cy,dy,hy,gy,zs,no,mu,fy,py,oo,jt,pi,yo=Fe(()=>{"use strict";zg=mt(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Kg=Number.isInteger||function(e){return e<<0===e};Jg=(function(){function t(){this.map={},this.length=0}return t.prototype.set=function(e,i){var s=this.hash(e),r=this.map[s];r||(this.map[s]=r=[]),r.push([e,i]),this.length+=1},t.prototype.hash=function(e){var i=[];for(var s in e)i.push(Object.prototype.toString.call(e[s]));return i.join()},t.prototype.get=function(e){if(this.length<=180){for(var i in this.map)for(var o=this.map[i],s=0;s<o.length;s+=1){var r=o[s];if(r[0]===e)return r[1]}return}var n=this.hash(e),o=this.map[n];if(o)for(var s=0;s<o.length;s+=1){var r=o[s];if(r[0]===e)return r[1]}},t})(),W=mt(function(e){return e!=null&&typeof e.clone=="function"?e.clone():yu(e)});Zg=ao(function(e,i,s){var r={},n;i=i||{},s=s||{};for(n in i)Fs(n,i)&&(r[n]=Fs(n,s)?e(n,i[n],s[n]):i[n]);for(n in s)Fs(n,s)&&!Fs(n,r)&&(r[n]=s[n]);return r}),ef=ao(function t(e,i,s){return Zg(function(r,n,o){return Ml(n)&&Ml(o)?t(e,n,o):e(r,n,o)},i,s)}),tf=ao(function(e,i,s){return ef(function(r,n,o){return e(n,o)},i,s)}),sf=xt(Qg),bu=xt(function(e,i){var s={};for(var r in i)e(i[r],r,i)&&(s[r]=i[r]);return s}),D=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),re=t=>typeof t=="string",Ve=t=>t===null,Ie=t=>typeof t>"u",st=t=>Ve(t)||Ie(t),rf=t=>typeof t=="bigint",te=t=>!Ie(t),hi=t=>!st(t),nf=t=>hi(t)&&t!=="",lo=t=>{switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return t instanceof Error}},of=t=>typeof t=="boolean",xn=(t,e)=>{let i=e.split(".");return sf(i,t)},af=(t,e)=>!!xn(t,e),lf=t=>typeof t=="object",uf=t=>!Ve(t)&&lf(t)&&!Array.isArray(t),ne=t=>!Ve(t)&&Object.prototype.toString.call(t)==="[object Object]",cf=(t,e)=>{if(!Array.isArray(t)||!Array.isArray(e))return W(e);let i=W(t);return e.forEach((s,r)=>{i[r]=Array.isArray(s)||uf(s)?we(i[r],s):s}),i},we=(t,e)=>tf(cf,t,e),bt=t=>ne(t)&&Object.keys(t).length>0,Hi=t=>{let e=bu(te,t);return Object.keys(e).forEach(i=>{let s=e[i];ne(s)&&(e[i]=Hi(s))}),e},Ks=t=>{let e=bu(hi,t);return Object.keys(e).forEach(i=>{let s=e[i];ne(s)&&(e[i]=Ks(s))}),e},pt=t=>{if(bt(t))return Ks(t)},ot=(t,e)=>typeof t=="boolean"?t:e,uo=t=>(Object.getOwnPropertyNames(t).forEach(function(e){t[e]&&typeof t[e]=="object"&&uo(t[e])}),Object.freeze(t)),df=t=>t.replace(/^\s+|\s+$/gm,""),Ul=t=>t.replace(/^\.+/,""),Ws=t=>{let e=t;if(!re(t)&&!st(t))try{e=JSON.stringify(t)}catch{e=null}return e},hf=t=>{let e=Array.from(t,i=>String.fromCodePoint(i)).join("");return globalThis.btoa(e)},gf=t=>hf(new TextEncoder().encode(t)),Ys=(t,e,i,s,r)=>{let n={category:t,name:e,properties:i,options:s,callback:void 0};D(r)&&(n.callback=r),D(s)&&(n.category=t,n.name=e,n.properties=i,n.options=void 0,n.callback=s),D(i)&&(n.category=t,n.name=e,n.properties=void 0,n.options=void 0,n.callback=i),D(e)&&(n.category=t,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),D(t)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=t),ne(t)?(n.name=void 0,n.category=void 0,n.properties=t,D(e)?n.options=void 0:n.options=e):ne(e)&&(n.name=void 0,n.properties=e,D(i)?n.options=void 0:n.options=i),re(t)&&!re(e)&&(n.category=void 0,n.name=t),te(n.category)||(n.category=void 0),te(n.name)||(n.name=void 0),n.properties=n.properties?W(n.properties):{},te(n.options)?n.options=W(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},co=(t,e,i,s)=>{let r={name:t,properties:e,options:i,callback:void 0};return D(s)&&(r.callback=s),D(i)&&(r.properties=e,r.options=void 0,r.callback=i),D(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=hi(r.properties)?W(r.properties):{},te(r.options)?r.options=W(r.options):r.options=void 0,r},Eu=(t,e,i,s)=>{let r={userId:t,traits:e,options:i,callback:void 0};return D(s)&&(r.callback=s),D(i)&&(r.userId=t,r.traits=e,r.options=void 0,r.callback=i),D(e)&&(r.userId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ne(t)||Ve(t))&&(r.userId=null,r.traits=t,D(e)?r.options=void 0:r.options=e),r.userId=Ws(r.userId),ne(r.traits)?r.traits=W(r.traits):r.traits=void 0,te(r.options)?r.options=W(r.options):r.options=void 0,r},Su=(t,e,i,s)=>{let r={to:t,from:e,options:i,callback:void 0};return D(s)&&(r.callback=s),D(i)&&(r.to=t,r.from=e,r.options=void 0,r.callback=i),D(e)?(r.to=t,r.from=void 0,r.options=void 0,r.callback=e):(ne(e)||Ve(e))&&(r.to=t,r.from=void 0,r.options=e),te(r.to)&&(r.to=Ws(r.to)),te(r.from)?r.from=Ws(r.from):r.from=void 0,te(r.options)?r.options=W(r.options):r.options=void 0,r},ku=(t,e,i,s)=>{let r={groupId:t,traits:e,options:i,callback:void 0};return D(s)&&(r.callback=s),D(i)&&(r.groupId=t,r.traits=e,r.options=void 0,r.callback=i),D(e)&&(r.groupId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ne(t)||Ve(t))&&(r.groupId=null,r.traits=t,D(e)?r.options=void 0:r.options=e),r.groupId=Ws(r.groupId),ne(r.traits)?r.traits=W(r.traits):r.traits=void 0,te(r.options)?r.options=W(r.options):r.options=void 0,r},kn=(function(t){return t.UNLOADED="Page Unloaded",t})({}),ho="API",Nn="CapabilitiesManager",Ye="ConfigManager",wu="EventManager",qi="PluginsManager",Gt="UserSessionManager",zi="ErrorHandler",li="PluginEngine",ff="StoreManager",wn=`Ready${ho}`,pf=`Load${ho}`,vf="HttpClient",_f="RudderStackAnalytics",Ms="AnalyticsCore";Bl=4096,Vs=[],Nt=0;for(;Nt<256;Nt++)Vs[Nt]=(Nt+256).toString(16).substring(1);Ht=256,Gs=[];for(;Ht--;)Gs[Ht]=(Ht+256).toString(16).substring(1);Ef=()=>!st(globalThis.crypto)&&D(globalThis.crypto.getRandomValues),ir=()=>Ef()?yf():bf(),Sf=()=>!!window.chrome?.runtime?.id,kf=()=>re(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),wf=(t,e=!1)=>{let i=!1,s=!1;function r(){i||(i=!0,t(s),setTimeout(()=>{i=!1},0))}(e||kf())&&globalThis.addEventListener("beforeunload",()=>{s=!1,r()}),globalThis.addEventListener("blur",()=>{s=!0,r()}),globalThis.addEventListener("focus",()=>{i=!1}),document.addEventListener("pagehide",()=>{s=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{s=!0,document.visibilityState==="hidden"?r():i=!1})},Au=t=>t.toISOString(),Af=()=>Au(new Date),V=":: ",If=t=>`A script with the id "${t}" is already loaded. Skipping the loading of this script to prevent conflicts`,Vl=(t,e,i)=>`Unable to load (${re(i)?i:i.type}) the script with the id "${t}" from URL "${e}"`,Tf=(t,e,i)=>`A timeout of ${i} ms occurred while trying to load the script with id "${t}" from URL "${e}"`,Rf=(t,e)=>`${t}${V}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,Pf="Failed to convert the value to a JSON string.",Of="Failed to encode the cookie data.",Cf=(t,e)=>`${t}${V}The "${e}" storage type is `,xf="JSONStringify",Nf="[BigInt]",Iu="[Circular Reference]",Df=(t,e,i)=>{let s=[];return function(r,n){if(!e?.includes(r)&&!(t&&st(n))){if(typeof n!="object"||Ve(n))return n;for(;s.length>0&&s[s.length-1]!==this;)s.pop();return s.includes(n)?(i?.warn(Rf(xf,r)),Iu):(s.push(n),n)}}},it=(t,e,i,s)=>{try{return JSON.stringify(t,Df(e,i,s))}catch(r){return s?.warn(Pf,r),null}},Lf=t=>{let e=[];return function(s,r){if(rf(r))return Nf;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?Iu:(e.push(r),r)}},Tu=(t,e)=>{let i=Array.isArray(t)?[]:{};for(let s in t)if(Object.hasOwnProperty.call(t,s)){let r=t[s],n=e.call(t,s,r);ne(n)||Array.isArray(n)?i[s]=Tu(n,e):i[s]=n}return i},X=(t,e)=>{let i=Lf(),s=i.call(t,"",t);return ne(t)||Array.isArray(t)?Tu(t,i):s},Ru="[SDK DISPATCHED ERROR]",sr=t=>{let{stack:e}=t;if(typeof e=="string"&&e)return e},go=(t,e)=>{if(!lo(t))return new Error(`${e}: ${it(t)}`);try{let i=t.constructor,s=new i(`${e}: ${t.message}`),r=sr(t);return r&&(s.stack=r),Object.getOwnPropertyNames(t).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{s[n]=t[n]}catch{}}),s}catch{return new Error(`${e}: ${it(t)}`)}},fe=t=>{if(lo(t)){let e=sr(t);e&&(t.stack=`${e}
|
|
4
|
-
${Ru}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:t,bubbles:!0,cancelable:!0,composed:!0}))},Gl="RudderLabs JavaScript SDK",Xi="3.31.1",$f="com.rudderlabs.javascript",Pu="npm",Ff="modern",ql="RudderJS-Initiated",Mf="ad-block page request",Uf="/ad-blocked",Wi="preloadedEventsBuffer",Bf="Consent Management Interaction",Vf="ajs_trait_",Gf="ajs_prop_",jl="ajs_aid",qf="ajs_uid",Hl="ajs_event",jf=10*1e3,Hf=31536e3*1e3,zl=720*60*1e3,Dn=1800*1e3,Kl=10*1e3,zf=10*1e3,Kf=250,Ou=(t="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[t]||(globalThis.RudderStackGlobals[t]={})},Ji=(t,e,i="app")=>{Ou(i),globalThis.RudderStackGlobals[i][t]=e},Cu=(t,e="app")=>(Ou(e),globalThis.RudderStackGlobals[e][t]);Wl=(t,e)=>{let i={};return t.forEach((s,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);i[n]=t.get(r)}}),i},Yf=(t=[])=>{let e={trait:Vf,properties:Gf},i=new URLSearchParams(globalThis.location.search);i.get(Hl)&&t.unshift(["track",i.get(Hl),Wl(i,e.properties)]);let s=i.get(qf),r=Wl(i,e.trait);if(s||bt(r)){let n=[...s?[s]:[],r];t.unshift(["identify",...n])}i.get(jl)&&t.unshift(["setAnonymousId",i.get(jl)])},Xf=t=>{let e="load",i=[],s=0;for(;s<t.length;){if(t[s]&&t[s][0]===e){i=W(t[s]),t.splice(s,1);break}s+=1}return i},Jf=t=>{let e="consent",i=t.filter(r=>r[0]===e),s=t.filter(r=>r[0]!==e);t.splice(0,t.length,...i,...s)},Qf=t=>{let e=Cu(Wi)||[];Yf(e),e.length>0&&(t.enqueuePreloadBufferEvents(e),Ji(Wi,[]))},Zf=(t,e)=>{let i=t.shift(),s;if(D(e[i])){switch(i){case"page":s=Ys(...t);break;case"track":s=co(...t);break;case"identify":s=Eu(...t);break;case"alias":s=Su(...t);break;case"group":s=ku(...t);break;default:e[i](...t);break}s&&e[i](s)}},ep=10*1e3,tp="RS_JS_SDK",ip=(t,e,i=!0,s=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=s,o.onerror=r,o.src=t,o.id=e,o.async=i,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",tp),o},sp=t=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(t,e[0]?.firstChild);return}let i=document.getElementsByTagName("script");if(i.length>0&&i[0]?.parentNode){i[0]?.parentNode.insertBefore(t,i[0]);return}let s=document.createElement("head");s.appendChild(t);let r=document.getElementsByTagName("html")[0];r?.insertBefore(s,r.firstChild)},rp=(t,e,i,s=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(If(e)));try{let l;sp(ip(t,e,s,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(Vl(e,t,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(Tf(e,t,i)))},i)}catch(l){o(go(l,Vl(e,t,"unknown")))}}),Xs=class{constructor(e,i=ep){this.logger=e,this.timeout=i}loadJSFile(e){let{url:i,id:s,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!D(o);rp(i,s,r||this.timeout,n,a).then(u=>{l||o(u)}).catch(u=>{l||o(s,u)})}},np=Symbol.for("preact-signals");J=void 0;Yi=void 0,yt=0,Js=0,op=0,Ln=0,Qs=void 0,Zs=0;Ce.prototype.brand=np;Ce.prototype.h=function(){return!0};Ce.prototype.S=function(t){var e=this,i=this.t;i!==t&&t.e===void 0&&(t.x=i,this.t=t,i!==void 0?i.e=t:xu(function(){var s;(s=e.W)==null||s.call(e)}))};Ce.prototype.U=function(t){var e=this;if(this.t!==void 0){var i=t.e,s=t.x;i!==void 0&&(i.x=s,t.e=void 0),s!==void 0&&(s.e=i,t.x=void 0),t===this.t&&(this.t=s,s===void 0&&xu(function(){var r;(r=e.Z)==null||r.call(e)}))}};Ce.prototype.subscribe=function(t){var e=this;return lt(function(){var i=e.value,s=J;J=void 0;try{t(i)}finally{J=s}},{name:"sub"})};Ce.prototype.valueOf=function(){return this.value};Ce.prototype.toString=function(){return this.value+""};Ce.prototype.toJSON=function(){return this.value};Ce.prototype.peek=function(){var t=J;J=void 0;try{return this.value}finally{J=t}};Object.defineProperty(Ce.prototype,"value",{get:function(){var t=Nu(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Js>100)throw new Error("Cycle detected");(function(i){yt!==0&&Js===0&&i.l!==Ln&&(i.l=Ln,Qs={S:i,v:i.v,i:i.i,o:Qs})})(this),this.v=t,this.i++,Zs++,yt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{rr()}}}});vi.prototype=new Ce;vi.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Zs))return!0;if(this.g=Zs,this.f|=1,this.i>0&&!Du(this))return this.f&=-2,!0;var t=J;try{Lu(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(i){this.v=i,this.f|=16,this.i++}return J=t,$u(this),this.f&=-2,!0};vi.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}Ce.prototype.S.call(this,t)};vi.prototype.U=function(t){if(this.t!==void 0&&(Ce.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};vi.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(vi.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Nu(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});_i.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};_i.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Fu(this),Lu(this),yt++;var t=J;return J=this,ap.bind(this,t)};_i.prototype.N=function(){2&this.f||(this.f|=2,this.u=Yi,Yi=this)};_i.prototype.d=function(){this.f|=8,1&this.f||fo(this)};_i.prototype.dispose=function(){this.d()};$n=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=[]}},Bs={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Yl="LOG",Mu="ERROR",lp="RS SDK",up="font-weight: bold; background: black; color: white;",cp="font-weight: normal;",Fn=class{constructor(e=Yl,i="",s=console){this.minLogLevel=Bs[e],this.scope=i,this.logProvider=s}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,i){this.minLogLevel<=Bs[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(i))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=Bs[e],Ie(this.minLogLevel)&&(this.minLogLevel=Bs[Yl])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let i=`%c ${lp}`;this.scope&&(i=`${i} - ${this.scope}`);let s=re(e[0])?e[0].trim():"";i=`${i} %c ${s}`;let r=[i,up,cp];return re(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},Et=new Fn,vt=(function(t){return t.HANDLEDEXCEPTION="handledException",t.UNHANDLEDEXCEPTION="unhandledException",t.UNHANDLEDREJECTION="unhandledPromiseRejection",t})({}),Uu=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Mn="cookieStorage",Xl="Unable to process/parse source configuration response",dp="The source is disabled. Please enable the source in the dashboard to send events.",hp="Failed to prepare data for the request.",gp="Failed to invoke plugin because the extension point name is missing.",fp="Failed to invoke plugin because the extension point name is invalid.",pp=t=>`${t}${V}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,vp=(t,e,i)=>`${t}${V}The base URL "${i}" for ${e} is not valid.`,_p=(t,e,i)=>`${t}${V}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(i)}".`,mp=(t,e)=>`${t}${V}Ignoring a non-error: ${e}.`,Jl="Failed to log breadcrumb",yp=t=>`${t}${V}Failed to handle the error.`,bp=t=>`${t}${V}Plugin name is missing.`,Ep=(t,e)=>`${t}${V}Plugin "${e}" already exists.`,Sp=(t,e)=>`${t}${V}Plugin "${e}" not found.`,kp=(t,e)=>`${t}${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.`,wp=(t,e,i)=>`${t}${V}Plugin "${e}" could not be loaded because some of its dependencies "${i}" do not exist.`,Ap=(t,e,i)=>`${t}${V}Failed to invoke the "${e}" extension point of plugin "${i}".`,Ql="Failed to fetch the source config",Ip=(t,e)=>`${t}${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.`,Tp=(t,e)=>`${t}${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.`,Bu=t=>`${t}${V}The provided callback parameter is not a function.`,Rp=(t,e,i,s,r)=>`${t} with status ${e} (${i}) for URL: ${s}. Response: ${r.trim()}`,Pp=(t,e,i)=>`${t} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${i}`,Op=(t,e)=>`${t} for URL: ${e}`,Cp=t=>`Failed to save the value for "${t}" to storage`,xp=t=>`Failed to retrieve or parse data for "${t}" from storage`,Np=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,Dp=t=>`The server failed to set the ${t} cookie. As a fallback, the cookies will be set client side.`,Zl="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",Lp=(t,e,i)=>`${t}${V}The storage type "${e}" is not supported. Please choose one of the following supported types: "${Uu}". The default type "${i}" will be used instead.`,$p=(t,e,i,s)=>`${t}${V}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(i)}". The default version "${s}" will be used instead.`,Fp=(t,e,i)=>`${t}${V}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${i}). To enable storage data migration, please update the storage encryption version to the latest version.`,Mp=(t,e,i)=>`${t}${V}The provided cookie domain (${e}) does not match the current webpage's domain (${i}). Hence, the cookies will be set client-side.`,Up=(t,e,i,s)=>`${t}${V}The "${e}" property defined under "${i}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${s}).`,Bp=t=>`${t}${V}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,Vp=t=>`${t}${V}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,Gp=(t,e,i)=>`${t}${V}The session timeout value "${e}" is not a number. The default timeout of ${i} ms will be used instead.`,qp=(t,e,i)=>`${t}${V}The session cut off duration value "${e}" is not a number. The default cut off duration of ${i} ms will be used instead.`,jp=(t,e,i)=>`${t}${V}The session cut off duration value "${e}" ms is less than the session timeout value "${i}" ms. The cut off functionality will be disabled.`,Hp=t=>`${t}${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.`,zp=(t,e,i)=>`${t}${V}The session timeout value ${e} ms is less than the recommended minimum of ${i} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,Kp=(t,e,i)=>`${t}${V}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${i}" digits long. A new session ID will be auto-generated instead.`,Wp=t=>`${t}${V}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,Yp=(t,e,i,s)=>`${t}${V}The storage type "${i}" is not available for entry "${e}". The SDK will initialize the entry with "${s}" storage type instead.`,Xp=t=>`${t}${V}The callback threw an exception`,Jp=(t,e)=>`${t}${V}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,Qp=(t,e)=>`Failed to load the polyfill script with ID "${t}" from URL ${e}.`,Zp=(t,e,i)=>`${t}${V}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${i}" will be used instead.`,ev=(t,e,i)=>`${t}${V}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${i}" will be used instead.`,tv=(t,e)=>`${t}${V}${e} plugin is deprecated. Please exclude it from the load API options.`,iv=(t,e,i,s)=>{let r=i.length===1,n=r?` '${i[0]}' plugin was`:` ['${i.join("', '")}'] plugins were`,o=`${t}${V}${e}, but${n} not configured to load.`;return s?`${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.`},sv=(t,e)=>`${t}${V}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,rv=t=>`${t}${V}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,nv=(t,e)=>`${t}${V}Ignoring unknown plugins: ${e.join(", ")}.`,ov=(t,e)=>`${t}${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.`,av=(t,e)=>`${t}${V}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,Vu={All:!0},nr="js-integrations",Gu="plugins",lv=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_]*)?$"),Qi="modern",or="https://cdn.rudderlabs.com",po="v3",qu=`${or}/${po}/${Qi}/${nr}`,ju=`${or}/${po}/${Qi}/${Gu}`,Hu="https://api.rudderstack.com",qt="v3",uv="xhr",Un={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},qs={[qt]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},cv={[uv]:"XhrQueue",beacon:"BeaconQueue"},dv="rsaRequest",hv="rsaMetrics",gv="Custom Device Mode",fv={configUrl:Hu,loadIntegration:!0,sessions:{autoTrack:!0,timeout:Dn,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:Vu,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:zf,storage:{encryption:{version:qt},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},pv=E(W(fv)),Q=uo({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),In=uo({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),vv=10,_v={userId:E(Q.userId),userTraits:E(Q.userTraits),anonymousId:E(Q.anonymousId),groupId:E(Q.groupId),groupTraits:E(Q.groupTraits),initialReferrer:E(Q.initialReferrer),initialReferringDomain:E(Q.initialReferringDomain),sessionInfo:E(Q.sessionInfo),authToken:E(Q.authToken)},mv={isOnline:E(!0),storage:{isLocalStorageAvailable:E(!1),isCookieStorageAvailable:E(!1),isSessionStorageAvailable:E(!1)},isBeaconAvailable:E(!1),isLegacyDOM:E(!1),isUaCHAvailable:E(!1),isCryptoAvailable:E(!1),isAdBlockerDetectionInProgress:E(!1),isAdBlocked:E(void 0),cspBlockedURLs:E([])},yv={isErrorReportingEnabled:E(!1),isMetricsReportingEnabled:E(!1),breadcrumbs:E([])},bv=E(void 0),Ev={activeDataplaneUrl:E(void 0),integrationsCDNPath:E(qu),pluginsCDNPath:E(ju),sourceConfigUrl:E(void 0),status:E(void 0),initialized:E(!1),logLevel:E(Mu),loaded:E(!1),readyCallbacks:E([]),writeKey:E(void 0),dataPlaneUrl:E(void 0),safeAnalyticsInstance:E(void 0)},Sv={enabled:E(!1),initialized:E(!1),data:E({}),activeConsentManagerPluginName:E(void 0),preConsent:E({enabled:!1}),postConsent:E({}),resolutionStrategy:E("and"),provider:E(void 0),metadata:E(void 0)},kv={retries:E(0),dropped:E(0),sent:E(0),queued:E(0),triggered:E(0),metricsServiceUrl:E(void 0)},wv=()=>Ff,Av={app:E({name:Gl,namespace:$f,version:Xi,installType:Pu}),traits:E(null),library:E({name:Gl,version:Xi,snippetVersion:globalThis.RudderSnippetVersion,variant:wv()}),userAgent:E(null),device:E(null),network:E(null),os:E({name:"",version:""}),locale:E(null),screen:E({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":E(void 0),timezone:E(void 0)},Iv={configuredDestinations:E([]),activeDestinations:E([]),loadOnlyIntegrations:E({}),failedDestinations:E([]),loadIntegration:E(!0),initializedDestinations:E([]),clientDestinationsReady:E(!1),integrationsConfig:E({})},Tv={toBeProcessedArray:E([]),readyCallbacksArray:E([])},Rv={ready:E(!1),loadedPlugins:E([]),failedPlugins:E([]),pluginsToLoadFromConfig:E([]),activePlugins:E([]),totalPluginsToLoad:E(0)},Pv={encryptionPluginName:E(void 0),migrate:E(!1),type:E(void 0),cookie:E(void 0),entries:E({}),trulyAnonymousTracking:E(!1)},Ov={isEnabledServerSideCookies:E(!1),dataServiceUrl:E(void 0)},Cv={eventsQueuePluginName:E(void 0),deliveryEnabled:E(!0)},xv={enabled:E(!1),pageLifecycle:{enabled:E(!1),pageViewId:E(void 0),pageLoadedTimestamp:E(void 0)}},Nv={capabilities:mv,consents:Sv,context:Av,eventBuffer:Tv,lifecycle:Ev,loadOptions:pv,metrics:kv,nativeDestinations:Iv,plugins:Rv,reporting:yv,session:_v,source:bv,storage:Pv,serverCookies:Ov,dataPlaneEvents:Cv,autoTrack:xv},d={...W(Nv)},zu=/^\s*at /,Dv=/^(eval@)?(\[native code])?$/,Lv=/(.+?)(?::(\d+))?(?::(\d+))?$/;Wu="global code",Uv=t=>te(t)&&/^global code$/i.test(t)?Wu:t,Bv=t=>{let e={file:t.fileName,method:Uv(t.functionName),lineNumber:t.lineNumber,columnNumber:t.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Wu),e},eu=t=>re(t)?t:"";Yu=(t,e)=>{let i;return lo(t)&&re(sr(t))?i=t:(e.warn(mp(zi,it(t))),i=void 0),i},Vv=(t,e)=>{try{let i=Mv(t);return tu(t.name,t.message,e,i)}catch{return tu(t.name,t.message,e,[])}},iu=(t,e)=>{try{return JSON.parse(t||"")}catch(i){let s=go(i,"Failed to parse response data");e(s)}},js="The request failed",Gv=[/Failed to fetch dynamically imported module: .*/],qv=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],jv=[new RegExp(`${js}.*`),/A script with the id .* is already loaded\./],Hv=[...Gv,...qv],zv="integrations",Kv="sdk",Wv=Kv,Yv={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},su=(t,e,i)=>{let s=we(Yv,e||{});return i&&(s.headers=we(s.headers,{Authorization:i})),s.url=t,s},ru=(t,e=jf,i)=>new Promise((s,r)=>{let n;if(t.sendRawData===!0)n=t.data;else if(n=it(t.data,!1,[],i),Ve(n)){r({error:new Error(hp),undefined:void 0,options:t});return}let o=new XMLHttpRequest,a=u=>{r({error:new Error(Rp(js,o.status,o.statusText,t.url,o.responseText)),xhr:o,options:t})},l=u=>{r({error:new Error(Pp(js,u,t.url)),xhr:o,options:t,...u?.type==="timeout"?{timedOut:!0}:{}})};o.ontimeout=l,o.onerror=l,o.onload=()=>{o.status>=200&&o.status<400?s({response:o.responseText,xhr:o,options:t}):a()},o.open(t.method,t.url,!0),t.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(t.headers).forEach(u=>{t.headers[u]&&o.setRequestHeader(u,t.headers[u])});try{o.send(n)}catch(u){r({error:go(u,Op(js,t.url)),xhr:o,options:t})}}),Bn=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:i,options:s,timeout:r,isRawResponse:n}=e;try{let o=await ru(su(i,s,this.basicAuthHeader),r,this.logger);return{data:n?o.response:iu(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:i,url:s,options:r,timeout:n,isRawResponse:o}=e,a=!D(i);ru(su(s,r,this.basicAuthHeader),n,this.logger).then(l=>{a||i(o?l.response:iu(l.response,this.onError),l)}).catch(l=>{a||i(void 0,l)})}onError(e,i){this.errorHandler?.onError({error:e,context:vf,groupingHash:i})}setAuthHeader(e,i=!1){let s=i?e:gf(`${e}:`);this.basicAuthHeader=`Basic ${s}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Xu=new Bn(Et),Xv="1",Jv=()=>["rsa"],Qv=["www.test-host.com","localhost","127.0.0.1","[::1]"],Zv=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],e_="RudderStack JavaScript SDK",t_="git+https://github.com/rudderlabs/rudder-sdk-js.git",i_="js",Ju=t=>{d.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(d.lifecycle.sourceConfigUrl.value),i=`${e.origin}${e.pathname}?view=ad`;t.getAsyncData({url:i,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(s,r)=>{d.capabilities.isAdBlockerDetectionInProgress.value=!1,d.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==i}})}catch(e){throw d.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},s_=(t,e)=>{switch(e){case vt.UNHANDLEDEXCEPTION:{let{error:i}=t;return i||t}case vt.UNHANDLEDREJECTION:return t.reason;case vt.HANDLEDEXCEPTION:default:return t}},r_=t=>({type:"manual",name:t,timestamp:new Date,metaData:{}}),n_=(t=()=>window.location.hostname)=>{let e=t();return!e||e&&Qv.includes(e)?"development":"production"},o_=t=>{let e=it(t,!1,Zv);return e!==null?JSON.parse(e):{}},a_=()=>globalThis.location.href.split("?")[0],l_=(t,e,i,s)=>({id:`${t.value?.id??i.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${s.pageLifecycle.pageViewId.value??"NA"}`,name:t.value?.name??"NA"}),u_=(t,e)=>({locale:t.value??"NA",userAgent:e.value??"NA",time:new Date}),c_=(t,e,i,s)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:u}=i,{app:c,locale:h,userAgent:f,timezone:g,screen:p,library:v}=r;return{payloadVersion:"5",notifier:{name:e_,version:c.value.version,url:t_},events:[{exceptions:[W(t)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:c.value.version,releaseStage:n_(),type:c.value.installType},device:u_(h,f),request:{url:a_(),clientIp:"[NOT COLLECTED]"},breadcrumbs:W(l.breadcrumbs.value),context:t.message,groupingHash:s,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...p.value,timezone:g.value},...o_(i)},user:l_(a,o,n,u)}]}},d_=(t,e,i)=>{if(Ie(t.capabilities.isAdBlocked.value)){t.capabilities.isAdBlockerDetectionInProgress.value===!1&&Ju(e);let s=lt(()=>{te(t.capabilities.isAdBlocked.value)&&(i(t.capabilities.isAdBlocked.value===!1),s())})}else i(t.capabilities.isAdBlocked.value===!1)},h_=(t,e,i)=>{let s=t.message;return new Promise(r=>{if(Hv.some(n=>n.test(s))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(s)?.[0];re(n)?n.startsWith(or)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):d_(e,i,r):r(!1):r(!0)}else r(!jv.some(n=>n.test(s)))})},Qu=t=>t?t.split("/").at(-2):void 0,Zu=t=>{let e=t.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},g_=t=>{let e=Zu(t);if(!e)return!1;let i=e.substring(e.lastIndexOf("/")+1);return Qu(e)===nr||Jv().some(r=>i.startsWith(r)&&i.endsWith(".js"))},f_=(t,e)=>{if(e)return e;let i=Zu(t);return Qu(i)===nr?zv:Wv},p_=(t,e,i)=>{let s={version:Xv,message_id:ir(),source:{name:i_,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:i},errors:t};return it(s)},v_=(t,e,i)=>{let s;if(!te(t))s=e;else if(re(t))s=t;else{let r=Yu(t,i);te(r)?s=r.message:s=e}return s},Vn=class{constructor(e,i){ae(this,"initialized",!1);this.httpClient=e,this.logger=i}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:zi,errorType:vt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:zi,errorType:vt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let i=re(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&i.startsWith(or)&&!d.capabilities.cspBlockedURLs.value.includes(i)&&(d.capabilities.cspBlockedURLs.value=[...d.capabilities.cspBlockedURLs.value,i])})}async onError(e){try{let{error:i,context:s,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??vt.HANDLEDEXCEPTION,l=s_(i,a),u=Yu(l,this.logger);if(Ie(u))return;let c=r?`${r} - `:"",h=`${s}${V}${c}`,f=Vv(u,h),p=sr(u).includes(Ru);if(!p&&!g_(f)&&a!==vt.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await h_(f,d,this.httpClient)){let m={severity:"error",unhandled:a!==vt.HANDLEDEXCEPTION,severityReason:{type:a}},y=v_(n,f.message,this.logger),w=c_(f,m,d,y),R=f_(f,o);this.httpClient.getAsyncData({url:d.metrics.metricsServiceUrl.value,options:{method:"POST",data:p_(w,d,R),sendRawData:!0},isRawResponse:!0})}(a===vt.HANDLEDEXCEPTION||p)&&this.logger.error(f.message)}catch(i){this.logger.error(yp(zi),i)}}leaveBreadcrumb(e){try{d.reporting.breadcrumbs.value=[...d.reporting.breadcrumbs.value,r_(e)]}catch(i){this.onError({error:i,context:zi,customMessage:Jl,groupingHash:Jl})}}},ec=new Vn(Xu,Et),Gn=class{constructor(e,i={}){ae(this,"plugins",[]);ae(this,"byName",{});ae(this,"cache",{});ae(this,"config",{throws:!0});this.config={throws:!0,...i},this.logger=e}register(e,i){if(!e.name){let r=bp(li);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=Ep(li,e.name);if(this.config.throws)throw new Error(r);this.logger.error(r);return}this.cache={},this.plugins=this.plugins.slice();let s=this.plugins.length;this.plugins.forEach((r,n)=>{r.deps?.includes(e.name)&&(s=Math.min(s,n))}),this.plugins.splice(s,0,e),this.byName[e.name]=e,D(e.initialize)&&e.initialize(i)}unregister(e){let i=this.byName[e];if(!i){let r=Sp(li,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let s=this.plugins.indexOf(i);if(s===-1){let r=kp(li,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(s,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let i=e??".";return this.cache[i]||(this.cache[i]=this.plugins.filter(s=>{if(s.deps?.some(r=>!this.byName[r])){let r=s.deps.filter(n=>!this.byName[n]);return this.logger.error(wp(li,s.name,r)),!1}return i==="."?!0:af(s,i)})),this.cache[i]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,i=!0,...s){let r=e;if(!r)throw new Error(gp);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(fp);let a=r.split(".");a.pop();let l=a.join(".");return(i?this.getPlugins(r):[this.getPlugins(r)[0]]).map(c=>{let h=xn(c,r);if(!D(h)||n)return h;try{return h.apply(xn(c,l),s)}catch(f){if(o)throw f;this.logger.error(Ap(li,r,c.name),f)}return null})}invokeSingle(e,...i){return this.invoke(e,!1,...i)[0]}invokeMultiple(e,...i){return this.invoke(e,!0,...i)}},__=new Gn(Et,{throws:!0}),m_=t=>t.config.connectionMode!=="cloud"||t.config.useNativeSDKToSend===!0||t.config.useNativeSDK===!0,y_=t=>t.config.connectionMode==="hybrid"||t.config.useNativeSDKToSend===!0,nu=t=>t.filter(m_),b_=(t,e)=>`${t.replaceAll(" ","-")}___${e}`,tc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],E_=["Bugsnag","ErrorReporting"],S_={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"}};k_=t=>ic({},(globalThis.__federation_shared__||{}).default||{});A_=t=>{switch(t){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}},I_=t=>{let e={};return t.forEach(i=>{if(tc.includes(i)){let s=A_(i);s&&(e[i]=s)}}),e},sc=()=>({}),T_=()=>({}),R_=t=>I_?.(t)||{},Tn={...sc(),...T_()},P_=t=>({...R_(t)}),qn=class{constructor(e,i,s){this.engine=e,this.errorHandler=i,this.logger=s,this.onError=this.onError.bind(this)}init(){d.lifecycle.status.value="pluginsLoading",Ji("pluginsCDNPath",d.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){lt(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&Ae(()=>{d.plugins.ready.value=!0,d.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=d.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>E_.includes(r)?(this.logger.warn(tv(qi,r)),!1):!0);let i=[{configurationStatus:()=>te(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(cv),shouldAddMissingPlugins:!0},{configurationStatus:()=>nu(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>nu(d.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>te(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Un)},{configurationStatus:()=>te(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(qs)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],s=!1;return i.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>te(n)),this.addMissingPlugins(r,s,e)):e=e.filter(r.basePlugins!==void 0?n=>!(r.basePlugins.includes(n)||r.supportedPlugins.includes(n)):n=>!r.supportedPlugins.includes(n))}),[...Object.keys(sc()),...e]}addMissingPlugins(e,i,s){let r=e.shouldAddMissingPlugins||i,n;e.activePluginName?n=[...e.basePlugins||[],e.activePluginName]:n=[...e.supportedPlugins];let o=n.filter(a=>!s.includes(a));o.length>0&&(r&&s.push(...o),this.logger.warn(iv(qi,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),i=[...Object.keys(Tn),...tc],s=[],r=[];e.forEach(n=>{i.includes(n)?s.push(n):r.push(n)}),r.length>0&&this.logger.warn(nv(qi,r)),Ae(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=s,d.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(Tn).forEach(([i,s])=>{d.plugins.activePlugins.value.includes(i)&&(D(s)?this.register([s()]):e.push(i))}),e.length>0&&(d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,...e],this.logger.error(ov(qi,e)))}registerRemotePlugins(){let e=P_(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async i=>{await e[i]().then(s=>this.register([s.default()])).catch(s=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,i],this.onError(s,`Failed to load plugin "${i}"`,s)})})).catch(i=>{this.onError(i)})}invokeMultiple(e,...i){try{return this.engine.invokeMultiple(e,...i)}catch(s){return this.onError(s,e),[]}}invokeSingle(e,...i){try{return this.engine.invokeSingle(e,...i)}catch(s){return this.onError(s,e),null}}register(e){e.forEach(i=>{try{this.engine.register(i,d)}catch(s){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,i.name],this.onError(s,`Failed to register plugin "${i.name}"`)}})}unregisterLocalPlugins(){Object.keys(Tn).forEach(e=>{try{this.engine.unregister(e)}catch(i){this.onError(i,`Failed to unregister plugin "${e}"`)}})}onError(e,i,s){this.errorHandler.onError({error:e,context:qi,customMessage:i,groupingHash:s})}},Be="cookieStorage",je="localStorage",We="sessionStorage",at="memoryStorage",zt="none",O_="test_rudder_cookie",C_="test_rudder_ls",x_="test_rudder_ss",N_="rl_user_id",D_="rl_trait",L_="rl_anonymous_id",$_="rl_group_id",F_="rl_group_trait",M_="rl_page_init_referrer",U_="rl_page_init_referring_domain",B_="rl_session",V_="rl_auth_token",ui={userId:N_,userTraits:D_,anonymousId:L_,groupId:$_,groupTraits:F_,initialReferrer:M_,initialReferringDomain:U_,sessionInfo:B_,authToken:V_},G_="__tld__",rc="clientDataInCookie",nc="clientDataInLocalStorage",q_="clientDataInMemory",oc="clientDataInSessionStorage",ac=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ci={[Be]:rc,[je]:nc,[at]:q_,[We]:oc},ou=(t,e)=>{try{return encodeURIComponent(t)}catch(i){e?.error(Of,i);return}},au=t=>{try{return decodeURIComponent(t)}catch{return}},j_=t=>{let e={},i=t.split(/\s*;\s*/),s;return i[0]&&i.forEach(r=>{s=r.split("=");let n=s[0]?au(s[0]):void 0;n&&(e[n]=s[1]?au(s[1]):void 0)}),e},H_=(t,e,i,s)=>{let r={...i||{}},n=`${ou(t,s)}=${ou(e,s)}`;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},jn=()=>{let t=globalThis.document.cookie;return j_(t)},z_=t=>jn()[t],_t=function(t,e,i,s){switch(arguments.length){case 4:case 3:case 2:return H_(t,e,i,s);case 1:return t?z_(t):jn();default:return jn()}},K_=t=>{let e=document.createElement("a");return e.href=t,e.hostname},W_=t=>{let i=(typeof globalThis.URL!="function"?K_(t):new URL(t).hostname)?.split(".")??[],s=i[i.length-1],r=[];if(i.length===4&&s&&s===parseInt(s,10).toString())return r;if(i.length<=1)return i[0]&&i[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=i.length-2;n>=0;n-=1)r.push(i.slice(n).join("."));return r},Y_=t=>{let e=W_(t);for(let i=0;i<e.length;i+=1){let s=e[i],r=G_,n={domain:`${s.indexOf("localhost")!==-1?"":"."}${s}`};try{if(_t(r,1,n),_t(r))return _t(r,null,n),s}catch{try{_t(r,null,n)}catch{}}}return""},X_=()=>{let t=`.${Y_(globalThis.location.href)}`;return{maxage:Hf,path:"/",domain:!t||t==="."?void 0:t,samesite:"Lax",enabled:!0}},J_=()=>({enabled:!0}),Q_=()=>({enabled:!0}),Z_=()=>({enabled:!0}),Hn=class{constructor(e){ae(this,"isEnabled",!0);ae(this,"length",0);ae(this,"data",{});this.options=Z_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,i){return this.data[e]=i,this.length=Object.keys(this.data).length,i}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)}},er=new Hn(Et);Hs={exports:{}},tm=Hs.exports;sm=im(),Vt=em(sm),lc=t=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],i=[22,1014];return t instanceof DOMException?e.includes(t.name)||i.includes(t.code):!1},di=(t=je,e,i)=>{let s,r,n=Cf(Nn,t),o="unavailable",a=!0,l;try{switch(t){case at:return!0;case Be:s=e,r=O_;break;case je:s=e??globalThis.localStorage,r=C_;break;case We:s=e??globalThis.sessionStorage,r=x_;break;default:return!1}if(s&&(s.setItem(r,"true"),s.getItem(r)))return s.removeItem(r),!0;a=!1}catch(u){a=!1,l=u,lc(u)&&(o="full")}return a||i?.warn(`${n}${o}.`,l),!1},zn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.options=J_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isSupportAvailable=di(je),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){Vt.set(e,i),this.length=Vt.len()}getItem(e){let i=Vt.get(e);return Ie(i)?null:i}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()}},vo=new zn(Et),Kn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.options=Q_(),this.logger=e}configure(e){return this.options=we(this.options,e??{}),this.isSupportAvailable=di(We),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){this.store&&(this.store.setItem(e,i),this.length=this.store.length)}getItem(e){if(!this.store)return null;let i=this.store.getItem(e);return Ie(i)?null:i}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 i=0;i<this.store.length;i+=1){let s=this.store.key(i);s!==null&&e.push(s)}return e}},_o=new Kn(Et),Wn=class{constructor(e){ae(this,"isSupportAvailable",!0);ae(this,"isEnabled",!0);ae(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=X_()),this.options=we(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=di(Be,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){return _t(e,i,this.options,this.logger),this.length=Object.keys(_t()).length,!0}getItem(e){let i=_t(e);return Ie(i)?null:i}removeItem(e){let i=this.setItem(e,null);return this.length=Object.keys(_t()).length,i}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(_t())}},mo=new Wn(Et),tt=t=>{switch(t){case je:return vo;case We:return _o;case at:return er;case Be:return mo;default:return er}},rm=t=>{let e=mo.configure(t);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},nm=t=>{vo.configure(t)},om=t=>{er.configure(t)},am=t=>{_o.configure(t)},lm=(t={},e={},i={},s={})=>{rm(t),nm(e),om(i),am(s)},Yn=class{constructor(e,i,s){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=i,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=s}createValidKey(e){let{name:i,id:s,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[i,s,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[i,s,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:i,validKeys:s,noCompoundKey:r}=this,n=tt(at);Object.keys(s).forEach(o=>{let a=this.get(s[o]),l=r?o:[e,i,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,i){let s=this.createValidKey(e);if(s)try{this.engine.setItem(s,this.encrypt(it(i,!1,[],this.logger)))}catch(r){if(lc(r))this.logger.warn(Wp(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,i);else{let n=Cp(e);this.onError(r,n,n)}}}get(e){let i=this.createValidKey(e),s;try{return!i||(s=this.decrypt(this.engine.getItem(i)),st(s)||s==="")?null:JSON.parse(s)}catch(r){let n=d.storage.encryptionPluginName.value;if(!n||!d.plugins.failedPlugins.value.includes(n)){let a=xp(e);this.onError(r,a,a)}return null}}remove(e){let i=this.createValidKey(e);i&&this.engine.removeItem(i)}getOriginalEngine(){return this.originalEngine}decrypt(e){return st(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,i){if(!this.isEncrypted||!e||typeof e!="string"||df(e)==="")return e;let r=`storage.${i}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,i,s){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:i,groupingHash:s})}},um=(t,e)=>{let i;if(t.consents.preConsent.value.enabled)switch(t.consents.preConsent.value.storage?.strategy){case"none":i=zt;break;case"session":e!=="sessionInfo"&&(i=zt);break;case"anonymousId":e!=="anonymousId"&&(i=zt);break}return i},Xn=class{constructor(e,i,s){ae(this,"stores",{});ae(this,"isInitialized",!1);this.errorHandler=i,this.logger=s,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=d.loadOptions.value,i={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};lm(Hi(we(i.cookieStorageOptions??{},d.storage.cookie?.value??{})),Hi(i.localStorageOptions),Hi(i.inMemoryStorageOptions),Hi(i.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[at,je,Be,We].forEach(i=>{tt(i)?.isEnabled&&this.setStore({id:ci[i],name:ci[i],isEncrypted:!0,noCompoundKey:!0,type:i,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=d.storage.type.value,i=d.loadOptions.value.storage?.entries,s=d.consents.postConsent.value.storage;(te(s?.type)||te(s?.entries))&&(e=s?.type,i=s?.entries);let r=!0,n={};ac.forEach(o=>{let a=o,l=o,u=i?.[a]?.type,h=um(d,o)??u??e??Mn,f=this.getResolvedStorageTypeForEntry(h,o);f!==zt&&(r=!1),n={...n,[o]:{type:f,key:ui[l]}}}),Ae(()=>{d.storage.type.value=e,d.storage.entries.value=n,d.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,i){let s=e;switch(e){case je:tt(je)?.isEnabled||(s=at);break;case We:tt(We)?.isEnabled||(s=at);break;case at:case zt:break;case Be:default:tt(Be)?.isEnabled?s=Be:tt(je)?.isEnabled?s=je:tt(We)?.isEnabled?s=We:s=at;break}return s!==e&&this.logger.warn(Yp(ff,i,e,s)),s}setStore(e){let i=tt(e.type);return this.stores[e.id]=new Yn(e,i,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},cm=t=>ne(t)&&ne(t.source)&&!st(t.source.id)&&ne(t.source.config)&&Array.isArray(t.source.destinations),dm=t=>typeof t=="string"&&Uu.includes(t),uc=t=>{let e=new URL(t),{host:i,protocol:s}=e,r=i.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=i,{topDomain:n,protocol:s}},hm=t=>{let{topDomain:e,protocol:i}=uc(t);return`${i}//${e}`},gm=(t,e)=>{let i=e?window.location.origin:hm(window.location.href),s=t.startsWith("/")?t.substring(1):t;return`${i}/${s}`},fm=t=>{let{topDomain:e}=uc(window.location.href);return e===t},gi=t=>t?.endsWith("/")?gi(t.substring(0,t.length-1)):t,Jn=t=>{try{return new URL(t).host}catch{return null}},cc=t=>Jn(t)??"",pm=t=>{let e={};try{let i=new URL(t),s="utm_";i.searchParams.forEach((r,n)=>{if(n.startsWith(s)){let o=n.substring(s.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},vm=t=>{let e=t;try{let i=new URL(t);e=i.origin+i.pathname+i.search}catch{}return e},_m=t=>t.replace(/\/{2,}/g,"/"),fi=t=>{if(!re(t))return!1;try{return D(globalThis.URL)&&new URL(t),lv.test(t)}catch{return!1}},Rn="none",Pn="immediate",mm=t=>t?.statsCollection?.errors?.enabled===!0,ym=t=>t?.statsCollection?.metrics?.enabled===!0,bm=t=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ne(t)){let i=W(t);e.storage=i.storage,bt(i.integrations)&&(e.integrations=i.integrations),e.discardPreConsentEvents=i.discardPreConsentEvents===!0,e.sendPageEvent=i.sendPageEvent===!0,e.trackConsent=i.trackConsent===!0,bt(i.consentManagement)&&(e.consentManagement=we(i.consentManagement,{enabled:d.consents.enabled.value}))}return e},uu=t=>bt(t)||Array.isArray(t),Em=(t,e)=>{let{provider:i}=t,s=i?Un[i]:void 0;return i&&!s&&(e.error(_p(Ye,i,Un)),i=void 0),{provider:i,consentManagerPluginName:s}},dc=(t,e)=>{let i,s=[],r=[],n=!1,o,a=t?.enabled===!0;bt(t)&&a&&({provider:o,consentManagerPluginName:i}=Em(t,e),uu(t.allowedConsentIds)&&(s=t.allowedConsentIds,n=!0),uu(t.deniedConsentIds)&&(r=t.deniedConsentIds,n=!0));let l={allowedConsentIds:s,deniedConsentIds:r};return a=a&&!!i,{provider:o,consentManagerPluginName:i,initialized:n,enabled:a,consentsData:l}},Sm=()=>{let t=document.querySelector("script[data-rsa-write-key]");if(t&&t.dataset.rsaWriteKey===d.lifecycle.writeKey.value)return t.src;let e=document.getElementsByTagName("script"),i=/(?:^|\/)rsa(\.min)?\.js$/;for(let s of e){let r=s.getAttribute("src");if(r&&i.test(r))return r}},km=t=>{d.reporting.isErrorReportingEnabled.value=mm(t.source.config)&&!Sf(),d.reporting.isMetricsReportingEnabled.value=ym(t.source.config)},wm=t=>{let{useServerSideCookies:e,dataServiceEndpoint:i,storage:s,setCookieDomain:r,sameDomainCookiesOnly:n}=d.loadOptions.value,o=s?.cookie,a=!1,l;if(e){a=e;let u=o.domain??r,c=te(u)&&!fm(Ul(u))||n,h=gm(i??dv,c);if(fi(h)){l=gi(h);let f=Jn(window.location.href),g=Jn(h);f!==g&&(o={...o,samesite:"None",secure:!0}),!n&&c&&g!==Ul(u)&&(a=!1,t.warn(Mp(Ye,u,g)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},Am=t=>{let{storage:e}=d.loadOptions.value,i=e?.type;te(i)&&!dm(i)&&(t.warn(Lp(Ye,i,Mn)),i=Mn);let s=e?.encryption?.version,r=s&&qs[s];!Ie(s)&&Ie(r)?(t.warn($p(Ye,s,qs,qt)),s=qt):Ie(s)&&(s=qt);let n=e?.migrate,o=n&&s===qt;n===!0&&o!==n&&t.warn(Fp(Ye,s,qt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=wm(t);Ae(()=>{d.storage.type.value=i,d.storage.cookie.value=u,d.serverCookies.isEnabledServerSideCookies.value=a,d.serverCookies.dataServiceUrl.value=l,d.storage.encryptionPluginName.value=qs[s],d.storage.migrate.value=o})},Im=t=>{let{provider:e,consentManagerPluginName:i,initialized:s,enabled:r,consentsData:n}=dc(d.loadOptions.value.consentManagement,t),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??Rn,l=["none","session","anonymousId"];te(a)&&!l.includes(a)&&(a=Rn,t.warn(Zp(Ye,o?.storage?.strategy,Rn)));let u=o?.events?.delivery??Pn,c=["immediate","buffer"];te(u)&&!c.includes(u)&&(u=Pn,t.warn(ev(Ye,o?.events?.delivery,Pn))),Ae(()=>{d.consents.activeConsentManagerPluginName.value=i,d.consents.initialized.value=s,d.consents.enabled.value=r,d.consents.data.value=n,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&s===!1&&r===!0,storage:{strategy:a},events:{delivery:u}}})},Tm=t=>{let e=d.consents.resolutionStrategy.value,i;ne(t.consentManagementMetadata)&&(d.consents.provider.value&&(e=t.consentManagementMetadata.providers.find(s=>s.provider===d.consents.provider.value)?.resolutionStrategy??d.consents.resolutionStrategy.value),i=t.consentManagementMetadata),d.consents.provider.value==="custom"&&(e=void 0),Ae(()=>{d.consents.metadata.value=W(i),d.consents.resolutionStrategy.value=e})},Rm=t=>{if(d.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",i=e;d.loadOptions.value.useBeacon&&(d.capabilities.isBeaconAvailable.value?i="BeaconQueue":(i=e,t.warn(Vp(Ye)))),Ae(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=i})}},Pm=(t,e,i,s,r)=>{let n=new URLSearchParams({p:Pu,v:Xi,build:Qi,writeKey:e,lockIntegrationsVersion:i.toString(),lockPluginsVersion:s.toString()}),o=Hu,a=n,l="/sourceConfig/",u="";if(fi(t)){let c=new URL(t);gi(c.pathname).endsWith("/sourceConfig")||(c.pathname=`${gi(c.pathname)}/sourceConfig/`),c.pathname=_m(c.pathname),n.forEach((h,f)=>{c.searchParams.get(f)===null&&c.searchParams.set(f,h)}),o=c.origin,l=c.pathname,a=c.searchParams,u=c.hash}else r.warn(Jp(Ye,t));return`${o}${l}?${a}${u}`},Om=t=>t.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:b_(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===gv})),hc=(t,e,i,s,r,n,o)=>{let a;if(n){if(!fi(n))return o.error(vp(Ye,t,n)),null;a=gi(n)}else if(a=i,d.context.app.value.installType==="cdn"){let l=Sm();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${po}/${Qi}/${e}$`),`/${s}/${Qi}/${e}`)),a},Cm=(t,e,i,s)=>hc("integrations",nr,qu,t,e,i,s),xm=(t,e,i,s)=>hc("plugins",Gu,ju,t,e,i,s),Qn=class{constructor(e,i,s){this.errorHandler=i,this.logger=s,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){lt(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:i,lockIntegrationsVersion:s,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=Cm(Xi,s,n,this.logger);if(Ve(l))return;let u;u=xm(Xi,r,o,this.logger),u!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=gi(d.lifecycle.dataPlaneUrl.value),Am(this.logger),Im(this.logger),Rm(this.logger),Ae(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=u,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=Pm(i,d.lifecycle.writeKey.value,s,r,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${hv}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,i,s){this.errorHandler.onError({error:e,context:Ye,customMessage:i,groupingHash:s})}processConfig(e,i){if(!te(e)){te(i)?this.onError(i.error,Ql):this.onError(new Error(Ql));return}let s;try{re(e)?s=JSON.parse(e):s=e}catch(n){this.onError(n,Xl);return}if(!cm(s)){this.onError(new Error(Xl));return}if(s.source.enabled===!1){this.logger.error(dp);return}km(s);let r=s.source.destinations.length>0?Om(s.source.destinations):[];Ae(()=>{d.source.value={config:s.source.config,name:s.source.name,id:s.source.id,workspaceId:s.source.workspaceId},d.nativeDestinations.configuredDestinations.value=r,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],Tm(s),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!D(e)){this.logger.error(pp(Ye));return}let i=e();i instanceof Promise?i.then(s=>this.processConfig(s)).catch(s=>{this.onError(s,"SourceConfig")}):this.processConfig(i)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},Nm=()=>{let t=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return t?.[1]?t[1]:"NA"},gc=(t=()=>document)=>t()?.referrer||"$direct",Dm=(t=()=>document)=>{let i=t().getElementsByTagName("link"),s="";for(let r=0;i[r];r+=1){let n=i[r];if(n.getAttribute("rel")==="canonical"&&!s){s=n.getAttribute("href")??"";break}}return s},Lm=(t=()=>globalThis.navigator)=>{let e=t();if(Ie(e))return null;let{userAgent:i}=e,{brave:s}=e;if(s&&Object.getPrototypeOf(s).isBrave){let r=i.match(/(chrome)\/([\w.]+)/i);r&&(i=`${i} Brave/${r[2]}`)}return i},$m=(t=()=>globalThis.navigator)=>{let e=t();return Ie(e)?null:e.language??e.browserLanguage},fc=(t=()=>globalThis.location,e=()=>document)=>{let i=t(),s=Dm(e),r=i.pathname,{href:n}=i,o=n,{search:a}=i;if(s)try{let h=new URL(s);h.search===""?o=s+a:o=s,r=h.pathname}catch{}let l=vm(o),{title:u}=e(),c=gc(e);return{path:r,referrer:c,referring_domain:cc(c),search:a,title:u,url:l,tab_url:n}},Fm=(t,e="none")=>{e==="none"&&t(void 0),e==="default"&&t(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(i=>{t(i)}).catch(()=>{t()})},Mm=()=>{let t=globalThis.document.createElement("div");return t.setAttribute("data-a-b","c"),t.dataset?t.dataset.aB==="c":!1},Zn={URL:()=>!D(globalThis.URL)||!D(globalThis.URLSearchParams),Promise:()=>!D(globalThis.Promise),"Number.isNaN":()=>!D(globalThis.Number.isNaN),"Number.isInteger":()=>!D(globalThis.Number.isInteger),"Array.from":()=>!D(globalThis.Array.from),"Array.prototype.find":()=>!D(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!D(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!D(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!D(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!D(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!D(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!D(globalThis.String.fromCodePoint),"Object.entries":()=>!D(globalThis.Object.entries),"Object.values":()=>!D(globalThis.Object.values),"Object.assign":()=>!D(globalThis.Object.assign),"Object.fromEntries":()=>!D(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!Mm(),TextEncoder:()=>!D(globalThis.TextEncoder)||!D(globalThis.TextDecoder),requestAnimationFrame:()=>!D(globalThis.requestAnimationFrame)||!D(globalThis.cancelAnimationFrame),CustomEvent:()=>!D(globalThis.CustomEvent),"navigator.sendBeacon":()=>!D(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!D(globalThis.Uint8Array),Set:()=>!D(globalThis.Set),atob:()=>!D(globalThis.atob)},Um=()=>{let t=Object.keys(Zn),e=!1;for(let i=0;i<t.length;i++){let s=Zn[t[i]];if(D(s)&&s()){e=!0;break}}return e},Bm="https://polyfill-fastly.io/v3/polyfill.min.js",Vm=`${Bm}?version=3.111.0&features=${Object.keys(Zn).join("%2C")}`,Gm=10*1e3,cu="rudderstackPolyfill",qm=()=>!st(globalThis.crypto)&&D(globalThis.crypto.getRandomValues),du=()=>!st(globalThis.navigator.userAgentData),jm=()=>!st(globalThis.navigator.sendBeacon)&&D(globalThis.navigator.sendBeacon),hu=()=>{let t={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return t={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},t},eo=class{constructor(e,i,s){this.httpClient=e,this.errorHandler=i,this.logger=s,this.externalSrcLoader=new Xs(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ae(()=>{d.capabilities.storage.isCookieStorageAvailable.value=di(Be,tt(Be),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=di(je,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=di(We,void 0,this.logger),d.capabilities.isBeaconAvailable.value=jm(),d.capabilities.isUaCHAvailable.value=du(),d.capabilities.isCryptoAvailable.value=qm(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=Lm(),d.context.locale.value=$m(),d.context.screen.value=hu(),d.context.timezone.value=Nm(),du()&&Fm(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),lt(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&Ju(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=Um();let e=d.loadOptions.value.polyfillURL,i=Vm;if(hi(e)&&(fi(e)?i=e:this.logger.warn(sv(Nn,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&fi(i)){let r=i!==d.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,i=`${i}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:i,id:cu,async:!0,timeout:Gm,callback:n=>{n?r||this.onReady():this.onError(new Error(Qp(cu,i)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Wf(()=>{d.context.screen.value=hu()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,i){this.errorHandler.onError({error:e,context:Nn,groupingHash:i})}},Hm="web",zm=["integrations","anonymousId","originalTimestamp"],gu=["library","consentManagement","userAgent","ua-ch","screen"],On=["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"],pc=t=>typeof t=="number"&&!Number.isNaN(t),Km=(t,e)=>e.toString().length>=t,tr=t=>pc(t)&&t>=0&&Number.isInteger(t),fu=10,vc=t=>{let{cutOff:e}=t,i=Date.now();return!!(e?.enabled&&e.expiresAt&&i>e.expiresAt)},pu=t=>!t.expiresAt||Date.now()>t.expiresAt||vc(t),Wm=()=>Date.now(),Ym=(t,e)=>!t||!tr(t)||!Km(fu,t)?(e.warn(Kp(Gt,t,fu)),!1):!0,Xm=t=>{if(t?.enabled)return t.expiresAt??(tr(t.duration)?Date.now()+t.duration:void 0)},Jm=t=>{let{timeout:e,cutOff:i}=t,s=Date.now();return{id:s,expiresAt:s+e,timeout:e,autoTrack:!0,...i&&{cutOff:i}}},Qm=(t,e)=>({id:Ym(t,e)?t:Wm(),sessionStart:void 0,manualTrack:!0}),Ki=t=>t===Be||t===je||t===We||t===at,to=()=>ir(),Zm=t=>{if(of(t)){let{entries:e,...i}=In;return{...i,entries:{...e,anonymousId:t}}}return ne(t)&&ne(t.entries)?we(In,t):{...In}},ey=t=>{let e=fc(),i={};return Object.keys(e).forEach(s=>{i[s]=t?.[s]||e[s]}),i.initial_referrer=t?.initial_referrer||d.session.initialReferrer.value,i.initial_referring_domain=t?.initial_referring_domain||d.session.initialReferringDomain.value,i},ty=(t,e)=>{let i=e?.page||{},s=t,r=fc();return Object.keys(r).forEach(n=>{Ie(s[n])&&(s[n]=i[n]||r[n])}),Ie(s.initial_referrer)&&(s.initial_referrer=i.initial_referrer||d.session.initialReferrer.value),Ie(s.initial_referring_domain)&&(s.initial_referring_domain=i.initial_referring_domain||d.session.initialReferringDomain.value),s},Cn=(t,e,i)=>{ne(t)&&Object.keys(t).forEach(s=>{(On.includes(s)||On.includes(s.toLowerCase()))&&i.warn(Up(wu,s,e,On))})},iy=(t,e)=>{let{properties:i,traits:s,context:r}=t,{traits:n}=r;Cn(i,"properties",e),Cn(s,"traits",e),Cn(n,"context.traits",e)},sy=(t,e)=>{e.anonymousId&&re(e.anonymousId)&&(t.anonymousId=e.anonymousId),bt(e.integrations)&&(t.integrations=e.integrations),e.originalTimestamp&&re(e.originalTimestamp)&&(t.originalTimestamp=e.originalTimestamp)},ry=(t,e,i)=>{let s=t;return Object.keys(e).forEach(r=>{if(!zm.includes(r)&&!gu.includes(r))if(r!=="context")s=we(s,{[r]:e[r]});else if(!Ie(e[r])&&ne(e[r])){let n={};Object.keys(e[r]).forEach(o=>{gu.includes(o)||(n[o]=e[r][o])}),s=we(s,{...n})}else i.warn(Bp(wu))}),s},ny=(t,e,i)=>{ne(e)&&(sy(t,e),t.context=ry(t.context,e,i))},oy=t=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:t?e=t:e=Vu,W(e)},ji=(t,e,i,s)=>{let r={channel:Hm,context:{traits:W(d.session.userTraits.value),sessionId:d.session.sessionInfo.value.id||void 0,sessionStart:d.session.sessionInfo.value.sessionStart||void 0,...d.consents.enabled.value&&{consentManagement:{deniedConsentIds:W(d.consents.data.value.deniedConsentIds),allowedConsentIds:W(d.consents.data.value.allowedConsentIds),provider:d.consents.provider.value,resolutionStrategy:d.consents.resolutionStrategy.value}},"ua-ch":d.context["ua-ch"].value,app:d.context.app.value,library:d.context.library.value,userAgent:d.context.userAgent.value,os:d.context.os.value,locale:d.context.locale.value,screen:d.context.screen.value,campaign:pm(globalThis.location.href),page:ey(i),timezone:d.context.timezone.value,...d.autoTrack.enabled.value&&{autoTrack:{...d.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:d.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:Af(),messageId:ir(),userId:t.userId||d.session.userId.value};Ki(d.storage.entries.value.anonymousId?.type)?r.anonymousId=d.session.anonymousId.value:r.anonymousId=to(),d.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),t.type==="identify"&&(r.context.traits=d.storage.entries.value.userTraits?.type!==zt?W(d.session.userTraits.value):t.context.traits),t.type==="group"&&((t.groupId||d.session.groupId.value)&&(r.groupId=t.groupId||d.session.groupId.value),(t.traits||d.session.groupTraits.value)&&(r.traits=d.storage.entries.value.groupTraits?.type!==zt?W(d.session.groupTraits.value):t.traits));let n=we(t,r);return n.event===void 0&&(n.event=null),n.properties===void 0&&(n.properties=null),ny(n,e,s),iy(n,s),n.integrations=oy(n.integrations),n},io=class{constructor(e){this.logger=e}generatePageEvent(e,i,s,r){let n=s??{};return n=ty(n,r),ji({properties:n,name:i,category:e,type:"page"},r,n,this.logger)}generateTrackEvent(e,i,s){return ji({properties:i,event:e,type:"track"},s,void 0,this.logger)}generateIdentifyEvent(e,i,s){return ji({userId:e,type:"identify",context:{traits:i}},s,void 0,this.logger)}generateAliasEvent(e,i,s){let n=ji({previousId:i,type:"alias"},s,void 0,this.logger);return n.userId=e??n.userId,n}generateGroupEvent(e,i,s){let r={type:"group"};return e&&(r.groupId=e),i&&(r.traits=i),ji(r,s,void 0,this.logger)}create(e){let i;switch(e.type){case"page":i=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":i=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":i=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":i=this.generateAliasEvent(e.to,e.from,e.options);break;default:i=this.generateGroupEvent(e.groupId,e.traits,e.options);break}return i}},so=class{constructor(e,i,s,r){this.eventRepository=e,this.userSessionManager=i,this.errorHandler=s,this.logger=r,this.eventFactory=new io(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let i=this.eventFactory.create(e);this.eventRepository.enqueue(i,e.callback)}},ro=class{constructor(e,i,s,r,n){this.storeManager=i,this.pluginsManager=e,this.logger=n,this.errorHandler=r,this.httpClient=s,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:i}=d.loadOptions.value,s;hi(e)&&typeof e=="string"&&(s=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(s??this.getAnonymousId(i)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let i=this.getConfiguredSessionTrackingInfo(),s=this.getSessionInfo()??Q.sessionInfo;e={autoTrack:i.autoTrack&&s.manualTrack!==!0,timeout:i.timeout,manualTrack:s.manualTrack,expiresAt:s.expiresAt,id:s.id,sessionStart:s.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=Q.sessionInfo:i.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:i.cutOff.duration,expiresAt:s.cutOff?.expiresAt})}else e=Q.sessionInfo;d.session.sessionInfo.value=e,d.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(d.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),i=this.getInitialReferringDomain();if(e&&i)this.setInitialReferrer(e),this.setInitialReferringDomain(i);else{let s=e||gc();this.setInitialReferrer(s),this.setInitialReferringDomain(cc(s))}}isPersistenceEnabledForStorageEntry(e){return Ki(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,i=[Be,je,We];Object.keys(e).forEach(s=>{let r=s,n=e[r]?.type,o=this.storeManager?.getStore(ci[n]);o&&i.forEach(a=>{let l=this.storeManager?.getStore(ci[a]);if(l&&a!==n){let u=l.get(ui[r]);nf(u)&&o.set(ui[r],u),l.remove(ui[r])}})})}migrateStorageIfNeeded(e,i){if(!d.storage.migrate.value)return;let s=e??[];s.length===0&&[rc,nc,oc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&s.push(a)}),(i??Object.keys(ui)).forEach(n=>{let o=ui[n];s.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);st(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=d.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let i,s=d.loadOptions.value.sessions?.timeout;tr(s)?i=s:(this.logger.warn(Gp(Gt,s,Dn)),i=Dn),i===0&&(this.logger.warn(Hp(Gt)),e=!1),i>0&&i<Kl&&this.logger.warn(zp(Gt,i,Kl));let r=this.getCutOffInfo(i);return{timeout:i,autoTrack:e,cutOff:r}}getCutOffInfo(e){let i=d.loadOptions.value.sessions.cutOff,s,r=!1;return i.enabled===!0&&(s=i.duration,r=!0,tr(s)?s<e&&(this.logger.warn(jp(Gt,s,e)),r=!1):(this.logger.warn(qp(Gt,s,zl)),s=zl)),{enabled:r,duration:s}}onError(e,i,s){this.errorHandler.onError({error:e,context:Gt,customMessage:i,groupingHash:s})}getEncryptedCookieData(e,i){let s=[];return e.forEach(r=>{let n=i?.encrypt(it(r.value,!1,[],this.logger));hi(n)&&s.push({name:r.name,value:n})}),s}makeRequestToSetCookie(e,i){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:it({reqType:"setCookies",workspaceId:d.source.value?.workspaceId,data:{options:{maxAge:d.storage.cookie.value?.maxage,path:d.storage.cookie.value?.path,domain:d.storage.cookie.value?.domain,sameSite:d.storage.cookie.value?.samesite,secure:d.storage.cookie.value?.secure,expires:d.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:i})}setServerSideCookies(e,i,s){let r=Object.keys(e),n=()=>r.map(u=>({name:e[u].name,value:d.session[u].value})),o={};r.forEach(u=>{o[e[u].name]=s?.get(e[u].name)});let a=()=>{r.forEach(u=>{this.serverSideCookiesRequestInProgress[u]=!1})},l=()=>{n().forEach(u=>{i&&i(u.name,u.value)})};try{let u={};r.forEach(h=>{u[e[h].name]=d.session[h].value});let c=this.getEncryptedCookieData(n(),s);c.length>0?this.makeRequestToSetCookie(c,(h,f)=>{a(),f?.xhr?.status===200?n().forEach(g=>{let p=o[g.name],v=s?.get(g.name);it(u[g.name],!1,[])!==it(v,!1,[])&&(Ve(p)&&Ve(v)&&this.logger.error(Dp(g.name)),i&&i(g.name,g.value))}):(this.logger.error(Np(f?.xhr?.status)),l())}):(l(),a())}catch(u){this.onError(u,Zl,Zl),l(),a()}}syncValueToStorage(e){let i=d.storage.entries.value,s=i[e]?.type;if(Ki(s)){let r=this.storeManager.getStore(ci[s]),n=i[e]?.key,o=d.session[e].value;o&&(re(o)||bt(o))?d.serverCookies.isEnabledServerSideCookies.value&&s===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)},vv)):r?.set(n,o):r?.remove(n)}}registerEffects(){ac.forEach(e=>{lt(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,i){let s=e;(!re(e)||!s)&&(s=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!s&&i&&(s=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",i)),s=s||to()):s=Q.anonymousId,d.session.anonymousId.value=s}getAnonymousId(e){let i=d.storage.entries.value.anonymousId?.type;if(Ki(i)){let s=d.session.anonymousId.value;(!s||s===Q.anonymousId)&&(s=this.getEntryValue("anonymousId")),!s&&e&&(s=this.pluginsManager?.invokeSingle("storage.getAnonymousId",tt,e)),d.session.anonymousId.value=s||to()}return d.session.anonymousId.value}getEntryValue(e){let i=d.storage.entries.value,s=i[e]?.type;if(Ki(s)){let r=this.storeManager?.getStore(ci[s]);this.migrateStorageIfNeeded([r],[e]);let n=i[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let i=tt(Be);return i?.isEnabled?i.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?d.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&&!pu(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??Q.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=d.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),d.session.sessionInfo.value=e,d.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=d.session,{manualTrack:i,autoTrack:s,timeout:r,cutOff:n}=e.sessionInfo.value;if(s){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 i&&this.startManualTrackingInternal()}reset(e){let{session:i}=d,s=Zm(e);Ae(()=>{Object.keys(Q).forEach(r=>{let n=r;if(s.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:i[n].value=Q[n];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:Q.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ne(e)?we(d.session.userTraits.value??Q.userTraits,e):Q.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:Q.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ne(e)?we(d.session.groupTraits.value??Q.groupTraits,e):Q.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:Q.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:Q.initialReferringDomain}startOrRenewAutoTracking(e){let i=e;if(pu(e))i=Jm(e);else{let s=Date.now(),r=e.timeout;i.expiresAt=s+r}if(vc(i)&&(i.cutOff.expiresAt=void 0),i.cutOff){let s=Xm(i.cutOff);i.cutOff.expiresAt=s}d.session.sessionInfo.value=i}start(e){d.session.sessionInfo.value=Qm(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=Q.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:Q.authToken}},ay=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],ly=ay,uy=(t,e)=>{let i=W(e);return re(i.setCookieDomain)||(i.setCookieDomain=void 0),["Strict","Lax","None"].includes(i.sameSiteCookie)||(i.sameSiteCookie=void 0),i.secureCookie=ot(i.secureCookie,t.secureCookie),i.sameDomainCookiesOnly=ot(i.sameDomainCookiesOnly,t.sameDomainCookiesOnly),["none","default","full"].includes(i.uaChTrackLevel)||(i.uaChTrackLevel=void 0),i.integrations=pt(i.integrations),Array.isArray(i.plugins)||(i.plugins=ly),i.useGlobalIntegrationsConfigInEvents=ot(i.useGlobalIntegrationsConfigInEvents,t.useGlobalIntegrationsConfigInEvents),i.bufferDataPlaneEventsUntilReady=ot(i.bufferDataPlaneEventsUntilReady,t.bufferDataPlaneEventsUntilReady),i.sendAdblockPage=ot(i.sendAdblockPage,t.sendAdblockPage),i.useServerSideCookies=ot(i.useServerSideCookies,t.useServerSideCookies),re(i.dataServiceEndpoint)||(i.dataServiceEndpoint=void 0),i.sendAdblockPageOptions=pt(i.sendAdblockPageOptions),i.loadIntegration=ot(i.loadIntegration,t.loadIntegration),bt(i.storage)?(i.storage.migrate=ot(i.storage.migrate,t.storage?.migrate),i.storage.cookie=pt(i.storage.cookie),i.storage.encryption=pt(i.storage.encryption),i.storage=Ks(i.storage)):i.storage=void 0,i.destinationsQueueOptions=pt(i.destinationsQueueOptions),i.queueOptions=pt(i.queueOptions),i.lockIntegrationsVersion=ot(i.lockIntegrationsVersion,t.lockIntegrationsVersion),i.lockPluginsVersion=ot(i.lockPluginsVersion,t.lockPluginsVersion),pc(i.dataPlaneEventsBufferTimeout)||(i.dataPlaneEventsBufferTimeout=void 0),i.beaconQueueOptions=pt(i.beaconQueueOptions),i.preConsent=pt(i.preConsent),i.sourceConfigurationOverride=pt(i.sourceConfigurationOverride),we(t,Ks(i))},vu="dataplaneEventsQueue",_u="destinationsEventsQueue",cy="transformEvent",dy=(t,e)=>Object.keys(t).filter(i=>t[i]!==!0||!e[i]).reduce((i,s)=>{let r=W(i);return r[s]=t[s],r},{}),hy=(t,e)=>{let i=W(t),s=e.nativeDestinations.integrationsConfig.value,r=dy(t.integrations,s);return i.integrations=we(s,r),i},gy=t=>t.consents.preConsent.value.enabled&&t.consents.preConsent.value.events?.delivery==="buffer",zs=(t,e,i,s)=>{if(te(t))if(D(t))try{t(...e)}catch(r){s.error(Xp(i),r)}else s.error(Bu(i))},no=class{constructor(e,i,s,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=s,this.logger=n,this.storeManager=i}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${vu}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${cy}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${_u}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),lt(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=gy(d),i;lt(()=>{let s=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(n=>y_(n))===!1||s===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(i),this.dataplaneEventsQueue?.start())}),d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(i=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},d.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(d.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,i){let s=hy(e,d);this.pluginsManager.invokeSingle(`${vu}.enqueue`,d,this.dataplaneEventsQueue,s,this.errorHandler,this.logger);let r=W(e);this.pluginsManager.invokeSingle(`${_u}.enqueue`,d,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${ho}`;zs(i,[s],n,this.logger)}},mu=t=>{let e=new CustomEvent(t,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},fy=t=>re(t)&&t.trim().length>0,py=t=>fi(t),oo=class{constructor(){this.preloadBuffer=new $n,this.initialized=!1,this.errorHandler=ec,this.logger=Et,this.externalSrcLoader=new Xs(this.logger),this.httpClient=Xu,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new eo(this.httpClient,this.errorHandler,this.logger)}load(e,i,s={}){if(!d.lifecycle.status.value){if(!fy(e)){this.logger.error(Ip(Ms,e));return}if(!py(i)){this.logger.error(Tp(Ms,i));return}Ae(()=>{d.lifecycle.writeKey.value=W(e),d.lifecycle.dataPlaneUrl.value=W(i),d.loadOptions.value=uy(d.loadOptions.value,s),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??Mu),Ji("state",d,e),this.startLifecycle()}}startLifecycle(){lt(()=>{try{switch(d.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 i="Failed to load the SDK";this.errorHandler.onError({error:e,context:Ms,customMessage:i,groupingHash:i})}})}onBrowserCapabilitiesReady(){Qf(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),d.consents.preConsent.value.enabled===!0?d.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(i=>this.preloadBuffer.enqueue(W(i)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Zf([...e],this)}}prepareInternalServices(){this.pluginsManager=new qn(__,this.errorHandler,this.logger),this.storeManager=new Xn(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Qn(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new ro(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new no(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new so(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){d.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(d.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),d.consents.enabled.value&&!d.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",d,this.logger),d.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger)),this.eventManager?.init(),d.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Ae(()=>{d.lifecycle.loaded.value=!0,d.lifecycle.status.value="loaded"}),this.initialized=!0;let e=d.loadOptions.value.onLoaded;zs(e,[globalThis.rudderanalytics],pf,this.logger),mu("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{zs(e,[],wn,this.logger)}),mu("RSA_Ready")}processBufferedEvents(){let e=d.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let i=e.shift();if(d.eventBuffer.toBeProcessedArray.value=e,i){let s=i[0];D(this[s])&&this[s](...i.slice(1),!0)}e=d.eventBuffer.toBeProcessedArray.value}}loadDestinations(){if(d.lifecycle.status.value==="destinationsLoading"||d.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",d,this.pluginsManager,this.errorHandler,this.logger);let e=d.nativeDestinations.activeDestinations.value.length;if(e===0){Ae(()=>{d.nativeDestinations.clientDestinationsReady.value=!0,d.lifecycle.status.value="destinationsReady"});return}d.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",d,this.externalSrcLoader,this.errorHandler,this.logger),lt(()=>{d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e&&Ae(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&Ae(()=>{d.lifecycle.status.value="ready"})}ready(e,i=!1){let s="ready";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),!D(e)){this.logger.error(Bu(wn));return}d.lifecycle.status.value==="readyExecuted"?zs(e,[],wn,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,i=!1){let s="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),d.capabilities.isAdBlocked.value===!0&&e.category!==ql&&this.page(Ys(ql,Mf,{path:Uf},d.loadOptions.value.sendAdblockPageOptions))}track(e,i=!1){let s="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event - ${e.name}`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:s,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e,i=!1){let s="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,e.userId&&d.session.userId.value&&e.userId!==d.session.userId.value&&this.reset(),Ve(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:s,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e,i=!1){let s="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1;let r=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:s,to:e.to,from:r,options:e.options,callback:e.callback})}group(e,i=!1){let s="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} event`),d.metrics.triggered.value+=1,Ve(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:s,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e,i=!1){let s="reset";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.reset(e)}getAnonymousId(e){return this.userSessionManager?.getAnonymousId(e)}setAnonymousId(e,i,s=!1){let r="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,i]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,i)}getUserId(){return d.session.userId.value}getUserTraits(){return d.session.userTraits.value}getGroupId(){return d.session.groupId.value}getGroupTraits(){return d.session.groupTraits.value}startSession(e,i=!1){let s="startSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let i="endSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,i=!1){let s="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ae(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=bm(e);let{initialized:r,consentsData:n}=dc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=r,d.consents.data.value=n}),d.consents.enabled.value&&!d.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(i)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let i=co(Bf);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",i]]:this.track(i)}if(d.consents.postConsent.value.sendPageEvent){let i=Ys();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",i]]:this.page(i)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,i,s=!1){let r="addCustomIntegration";if(s)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,i,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(av(Ms,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,i]]}}},jt=class jt{constructor(){ae(this,"analyticsInstances",{});ae(this,"defaultAnalyticsKey","");ae(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,d.autoTrack.pageLifecycle.pageViewId.value=ir(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){fe(e)}}createSafeAnalyticsInstance(){d.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(){ec.init(),mo.configure(),vo.configure(),_o.configure(),er.configure()}setDefaultInstanceKey(e){re(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let i=e;return(!re(i)||!i)&&(i=this.defaultAnalyticsKey),this.analyticsInstances[i]||(this.analyticsInstances[i]=new oo),this.analyticsInstances[i]}catch(i){fe(i);return}}load(e,i,s){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(s);let r=Cu(Wi);Jf(r),Ji(Wi,W(r)),this.getAnalyticsInstance(e)?.load(e,i,X(s))}catch(r){fe(r)}}trackPageLifecycleEvents(e){let{autoTrack:i,useBeacon:s}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=i??{},{events:a=[kn.UNLOADED],enabled:l=r,options:u=n}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,s,u)}setupPageUnloadTracking(e,i,s){(e.length===0||e.includes(kn.UNLOADED))&&(i===!0?wf(r=>{if(r===!1&&d.lifecycle.loaded.value){let n=Date.now(),o=n-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(kn.UNLOADED,{timeOnPage:o},{...s,originalTimestamp:Au(new Date(n))})}},!0):this.logger.warn(rv(_f)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],i=Xf(e);Ji(Wi,W([...e])),i.length>0&&(i.shift(),this.load.apply(null,i))}ready(e){try{this.getAnalyticsInstance()?.ready(X(e))}catch(i){fe(i)}}page(e,i,s,r,n){try{this.getAnalyticsInstance()?.page(Ys(X(e),X(i),X(s),X(r),X(n)))}catch(o){fe(o)}}track(e,i,s,r){try{this.getAnalyticsInstance()?.track(co(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}identify(e,i,s,r){try{this.getAnalyticsInstance()?.identify(Eu(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}alias(e,i,s,r){try{this.getAnalyticsInstance()?.alias(Su(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}group(e,i,s,r){try{this.getAnalyticsInstance()?.group(ku(X(e),X(i),X(s),X(r)))}catch(n){fe(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(X(e))}catch(i){fe(i)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(X(e))}catch(i){fe(i);return}}setAnonymousId(e,i){try{this.getAnalyticsInstance()?.setAnonymousId(X(e),X(i))}catch(s){fe(s)}}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(X(e))}catch(i){fe(i)}}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(X(e))}catch(i){fe(i)}}consent(e){try{this.getAnalyticsInstance()?.consent(X(e))}catch(i){fe(i)}}addCustomIntegration(e,i){try{this.getAnalyticsInstance()?.addCustomIntegration(X(e),X(i))}catch(s){fe(s)}}};ae(jt,"globalSingleton",null);pi=jt});var mc,yc,bo,_c,bc,Ec,Sc,kc,Zi=Fe(()=>{"use strict";mc="https://deriv.com/cdn-cgi/trace",yc="https://cdn.growthbook.io",bo="https://deriv-dataplane.rudderstack.com",_c="https://ph.deriv.com",bc="https://us.posthog.com",Ec=()=>{if(typeof window>"u")return _c;let t=window.location.hostname;return t.includes(".deriv.me")?"https://ph.deriv.me":t.includes(".deriv.be")?"https://ph.deriv.be":t.includes(".deriv.ae")?"https://ph.deriv.ae":_c},Sc=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae"],kc=["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 ar(t){for(var e=1;e<arguments.length;e++){var i=arguments[e];for(var s in i)t[s]=i[s]}return t}function Eo(t,e){function i(r,n,o){if(!(typeof document>"u")){o=ar({},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+"="+t.write(n,r)+a}}function s(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 c=decodeURIComponent(l[0]);if(o[c]=t.read(u,c),r===c)break}catch{}}return r?o[r]:o}}return Object.create({set:i,get:s,remove:function(r,n){i(r,"",ar({},n,{expires:-1}))},withAttributes:function(r){return Eo(this.converter,ar({},this.attributes,r))},withConverter:function(r){return Eo(ar({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var vy,wc,Ac=Fe(()=>{"use strict";vy={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};wc=Eo(vy,{path:"/"})});var Dt,ur,es,lr,Ic,Kt,Tc,Rc,ts=Fe(()=>{"use strict";Ac();Zi();Dt=(t,e)=>(...i)=>{e()&&console.log(`[ANALYTIC]${t}`,...i)},ur=t=>{let e=t.split("@")[1]?.toLowerCase();return e?kc.includes(e):!1},es=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),lr=null,Ic=async()=>{if(lr)return lr;let t=JSON.parse(wc.get("website_status")||"{}")?.clients_country;return lr=(async()=>{try{let e=await fetch(mc).catch(()=>null);if(!e)return t||"";let i=await e.text().catch(()=>"");return i?Object.fromEntries(i.split(`
|
|
5
|
-
`).map(r=>r.split("=",2))).loc?.toLowerCase()||t||"":t||""}catch{return t||""}})(),lr},Kt=t=>{if(t==null||typeof t!="object")return t;if(Array.isArray(t)){let s=[];for(let r=0;r<t.length;r++){let n=Kt(t[r]);n!=null&&s.push(n)}return s.length?s:void 0}let e={},i=!1;for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let r=Kt(t[s]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[s]=r,i=!0)}return i?e:void 0},Tc=(t,e)=>{for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let s=t[i];s&&typeof s=="object"&&!Array.isArray(s)?Tc(s,e):e[i]=s}},Rc=t=>{if(t==null||typeof t!="object"||Array.isArray(t))return t;let e={};return Tc(t,e),e}});function Fc(){return $c}function So(t){let e=2166136261,i=t.length;for(let s=0;s<i;s++)e^=t.charCodeAt(s),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function is(t,e,i){return i===2?So(So(t+e)+"")%1e4/1e4:i===1?So(e+t)%1e3/1e3:null}function my(t){return t<=0?[]:new Array(t).fill(1/t)}function gr(t,e){return t>=e[0]&&t<e[1]}function Mc(t,e){let i=is("__"+e[0],t,1);return i===null?!1:i>=e[1]&&i<e[2]}function Uc(t,e){for(let i=0;i<e.length;i++)if(gr(t,e[i]))return i;return-1}function wo(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function fr(t,e){if(!e.length)return!1;let i=!1,s=!1;for(let r=0;r<e.length;r++){let n=Ey(t,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else i=!0,n&&(s=!0)}return s||!i}function yy(t,e,i){try{let s=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return i&&(s="\\/?"+s.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+s+"$","i").test(t)}catch{return!1}}function by(t,e){try{let i=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),s=[[t.host,i.host,!1],[t.pathname,i.pathname,!0]];return i.hash&&s.push([t.hash,i.hash,!1]),i.searchParams.forEach((r,n)=>{s.push([t.searchParams.get(n)||"",r,!1])}),!s.some(r=>!yy(r[0],r[1],r[2]))}catch{return!1}}function Ey(t,e,i){try{let s=new URL(t,"https://_");if(e==="regex"){let r=wo(i);return r?r.test(s.href)||r.test(s.href.substring(s.origin.length)):!1}else if(e==="simple")return by(s,i);return!1}catch{return!1}}function Bc(t,e,i){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let s=my(t);i=i||s,i.length!==t&&(i=s);let r=i.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(i=s);let n=0;return i.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Vc(t,e,i){if(!e)return null;let s=e.split("?")[1];if(!s)return null;let r=s.replace(/#.*/,"").split("&").map(n=>n.split("=",2)).filter(([n])=>n===t).map(([,n])=>parseInt(n));return r.length>0&&r[0]>=0&&r[0]<i?r[0]:null}function Gc(t){try{return t()}catch(e){return console.error(e),!1}}async function Yt(t,e,i){if(e=e||"",i=i||globalThis.crypto&&globalThis.crypto.subtle||$c.SubtleCrypto,!i)throw new Error("No SubtleCrypto implementation found");try{let s=await i.importKey("raw",ko(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=t.split("."),o=await i.decrypt({name:"AES-CBC",iv:ko(r)},s,ko(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function ss(t){return typeof t=="string"?t:JSON.stringify(t)}function He(t){typeof t=="number"&&(t=t+""),(!t||typeof t!="string")&&(t="0");let e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(i=>i.match(/^[0-9]+$/)?i.padStart(5," "):i).join("-")}function qc(){let t;try{t="1.6.5"}catch{t=""}return t}function jc(t,e){let i,s;try{i=new URL(t),s=new URL(e)}catch(r){return console.error(`Unable to merge query strings: ${r}`),e}return i.searchParams.forEach((r,n)=>{s.searchParams.has(n)||s.searchParams.set(n,r)}),s.toString()}function Lc(t){return typeof t=="object"&&t!==null}function pr(t){return t.urlPatterns&&t.variations.some(e=>Lc(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>Lc(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function vr(t,e){return new Promise(i=>{let s=!1,r,n=o=>{s||(s=!0,r&&clearTimeout(r),i(o||null))};e&&(r=setTimeout(()=>n(),e)),t.then(o=>n(o)).catch(()=>n())})}var $c,ko,rs=Fe(()=>{"use strict";$c={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};ko=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0))});function Kc(t){Object.assign(Oe,t),Oe.backgroundSync||Oo()}async function Wc({instance:t,timeout:e,skipCache:i,allowStale:s,backgroundSync:r}){return r||(Oe.backgroundSync=!1),Ay({instance:t,allowStale:s,timeout:e,skipCache:i})}function Sy(t){let e=ns(t),i=yi.get(e)||new Set;i.add(t),yi.set(e,i)}function Yc(t){yi.forEach(e=>e.delete(t))}function ky(){bi.forEach(t=>{t&&(t.state="idle",Ro(t))})}function wy(){bi.forEach(t=>{t&&t.state==="idle"&&Po(t)})}async function zc(){try{if(!ut.localStorage)return;await ut.localStorage.setItem(Oe.cacheKey,JSON.stringify(Array.from(St.entries())))}catch{}}async function Ay({instance:t,allowStale:e,timeout:i,skipCache:s}){let r=ns(t),n=Io(t),o=new Date,a=new Date(o.getTime()-Oe.maxAge+Oe.staleTTL);await Iy();let l=!Oe.disableCache&&!s?St.get(n):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&Ei.add(r),l.staleAt<o?Ao(t):To(t),{data:l.data,success:!0,source:"cache"}):await vr(Ao(t),i)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ns(t){let[e,i]=t.getApiInfo();return`${e}||${i}`}function Io(t){let e=ns(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let i=t.getAttributes(),s=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};s.forEach(a=>{r[a]=i[a]});let n=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:r,fv:n,url:o})}`}async function Iy(){if(!Hc){Hc=!0;try{if(ut.localStorage){let t=await ut.localStorage.getItem(Oe.cacheKey);if(!Oe.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(([i,s])=>{St.set(i,{...s,staleAt:new Date(s.staleAt)})}),Xc()}}}catch{}if(!Oe.disableIdleStreams){let t=mi.startIdleListener();t&&(mi.stopIdleListener=t)}}}function Xc(){let t=Array.from(St.entries()).map(([i,s])=>({key:i,staleAt:s.staleAt.getTime()})).sort((i,s)=>i.staleAt-s.staleAt),e=Math.min(Math.max(0,St.size-Oe.maxEntries),St.size);for(let i=0;i<e;i++)St.delete(t[i].key)}function Jc(t,e,i){let s=i.dateUpdated||"",r=new Date(Date.now()+Oe.staleTTL),n=Oe.disableCache?void 0:St.get(e);if(n&&s&&n.version===s){n.staleAt=r,zc();return}Oe.disableCache||(St.set(e,{data:i,version:s,staleAt:r,sse:Ei.has(t)}),Xc()),zc();let o=yi.get(t);o&&o.forEach(a=>Ty(a,i))}async function Ty(t,e){await t.setPayload(e||t.getPayload())}async function Ao(t){let{apiHost:e,apiRequestHeaders:i}=t.getApiHosts(),s=t.getClientKey(),r="isRemoteEval"in t&&t.isRemoteEval(),n=ns(t),o=Io(t),a=_r.get(o);return a||(a=(r?mi.fetchRemoteEvalCall({host:e,clientKey:s,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:i}):mi.fetchFeaturesCall({host:e,clientKey:s,headers:i})).then(u=>{if(!u.ok)throw new Error(`HTTP error: ${u.status}`);return u.headers.get("x-sse-support")==="enabled"&&Ei.add(n),u.json()}).then(u=>(Jc(n,o,u),To(t),_r.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(_r.delete(o),{data:null,source:"error",success:!1,error:u})),_r.set(o,a)),a}function To(t,e=!1){let i=ns(t),s=Io(t),{streamingHost:r,streamingHostRequestHeaders:n}=t.getApiHosts(),o=t.getClientKey();if(e&&Ei.add(i),Oe.backgroundSync&&Ei.has(i)&&ut.EventSource){if(bi.has(i))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let u=yi.get(i);u&&u.forEach(c=>{Ao(c)})}else if(l.type==="features"){let u=JSON.parse(l.data);Jc(i,s,u)}a.errors=0}catch{Qc(a)}},errors:0,state:"active"};bi.set(i,a),Po(a)}}function Qc(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Math.pow(3,t.errors-3)*(1e3+Math.random()*1e3);Ro(t),setTimeout(()=>{["idle","active"].includes(t.state)||Po(t)},Math.min(e,3e5))}}function Ro(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function Po(t){t.src=mi.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>Qc(t),t.src.onopen=()=>{t.errors=0}}function Ry(t,e){Ro(t),bi.delete(e)}function Oo(){Ei.clear(),bi.forEach(Ry),yi.clear(),mi.stopIdleListener()}function mr(t,e){if(e.streaming){if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&To(t,!0),Sy(t)}}var Oe,ut,mi,yi,Hc,St,_r,bi,Ei,Zc=Fe(()=>{"use strict";rs();Oe={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},ut=Fc(),mi={fetchFeaturesCall:({host:t,clientKey:e,headers:i})=>ut.fetch(`${t}/api/features/${e}`,{headers:i}),fetchRemoteEvalCall:({host:t,clientKey:e,payload:i,headers:s})=>{let r={method:"POST",headers:{"Content-Type":"application/json",...s},body:JSON.stringify(i)};return ut.fetch(`${t}/api/eval/${e}`,r)},eventSourceCall:({host:t,clientKey:e,headers:i})=>i?new ut.EventSource(`${t}/sub/${e}`,{headers:i}):new ut.EventSource(`${t}/sub/${e}`),startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let i=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),wy()):document.visibilityState==="hidden"&&(t=window.setTimeout(ky,Oe.idleStreamInterval))};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(ut.localStorage=globalThis.localStorage)}catch{}yi=new Map,Hc=!1,St=new Map,_r=new Map,bi=new Map,Ei=new Set});function Oy(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function kr(t){var e=Sr.get(t);return e||(e={element:t,attributes:{}},Sr.set(t,e)),e}function wr(t,e,i,s,r){var n=i(t),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:t,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=i(t);e==="position"&&a.parentNode===o.virtualValue.parentNode&&a.insertBeforeNode===o.virtualValue.insertBeforeNode||a!==o.virtualValue&&(o.originalValue=a,r(o))}}),mutationRunner:r,setValue:s,getCurrentValue:i};return e==="position"&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,Oy(e)),o}function Ar(t,e){var i=e.getCurrentValue(e.el);e.virtualValue=t,t&&typeof t!="string"?(!i||t.parentNode!==i.parentNode||t.insertBeforeNode!==i.insertBeforeNode)&&(e.isDirty=!0,ed()):t!==i&&(e.isDirty=!0,ed())}function Cy(t){var e=t.originalValue;t.mutations.forEach(function(i){return e=i.mutate(e)}),Ar(Hy(e),t)}function xy(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(i){return i.mutate(e)}),Ar(Array.from(e).filter(Boolean).join(" "),t)}function Ny(t){var e=t.originalValue;t.mutations.forEach(function(i){return e=i.mutate(e)}),Ar(e,t)}function Dy(t){var e=t.parentSelector,i=t.insertBeforeSelector,s=document.querySelector(e);if(!s)return null;var r=i?document.querySelector(i):null;return i&&!r?null:{parentNode:s,insertBeforeNode:r}}function Ly(t){var e=t.originalValue;t.mutations.forEach(function(i){var s=i.mutate(),r=Dy(s);e=r||e}),Ar(e,t)}function id(t){var e=kr(t);return e.html||(e.html=wr(t,"html",$y,Fy,Cy)),e.html}function sd(t){var e=kr(t);return e.position||(e.position=wr(t,"position",My,Uy,Ly)),e.position}function rd(t){var e=kr(t);return e.classes||(e.classes=wr(t,"class",Vy,By,xy)),e.classes}function nd(t,e){var i=kr(t);return i.attributes[e]||(i.attributes[e]=wr(t,e,Gy(e),qy(e),Ny)),i.attributes[e]}function jy(t,e){var i=Sr.get(t);if(i)if(e==="html"){var s,r;(s=i.html)==null||(r=s.observer)==null||r.disconnect(),delete i.html}else if(e==="class"){var n,o;(n=i.classes)==null||(o=n.observer)==null||o.disconnect(),delete i.classes}else if(e==="position"){var a,l;(a=i.position)==null||(l=a.observer)==null||l.disconnect(),delete i.position}else{var u,c,h;(u=i.attributes)==null||(c=u[e])==null||(h=c.observer)==null||h.disconnect(),delete i.attributes[e]}}function Hy(t){return yr||(yr=document.createElement("div")),yr.innerHTML=t,yr.innerHTML}function br(t,e,i){if(i.isDirty){i.isDirty=!1;var s=i.virtualValue;i.mutations.length||jy(t,e),i.setValue(t,s)}}function zy(t,e){t.html&&br(e,"html",t.html),t.classes&&br(e,"class",t.classes),t.position&&br(e,"position",t.position),Object.keys(t.attributes).forEach(function(i){br(e,i,t.attributes[i])})}function ed(){Sr.forEach(zy)}function Ky(t,e){var i=null;t.kind==="html"?i=id(e):t.kind==="class"?i=rd(e):t.kind==="attribute"?i=nd(e,t.attribute):t.kind==="position"&&(i=sd(e)),i&&(i.mutations.push(t),i.mutationRunner(i))}function Wy(t,e){var i=null;if(t.kind==="html"?i=id(e):t.kind==="class"?i=rd(e):t.kind==="attribute"?i=nd(e,t.attribute):t.kind==="position"&&(i=sd(e)),!!i){var s=i.mutations.indexOf(t);s!==-1&&i.mutations.splice(s,1),i.mutationRunner(i)}}function od(t){if(!(t.kind==="position"&&t.elements.size===1)){var e=new Set(t.elements),i=document.querySelectorAll(t.selector);i.forEach(function(s){e.has(s)||(t.elements.add(s),Ky(t,s))})}}function Yy(t){t.elements.forEach(function(e){return Wy(t,e)}),t.elements.clear(),Do.delete(t)}function td(){Do.forEach(od)}function Xy(){typeof document>"u"||(Co||(Co=new MutationObserver(function(){td()})),td(),Co.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Ir(t){return typeof document>"u"?No:(Do.add(t),od(t),{revert:function(){Yy(t)}})}function xo(t,e){return Ir({kind:"html",elements:new Set,mutate:e,selector:t})}function ad(t,e){return Ir({kind:"position",elements:new Set,mutate:e,selector:t})}function os(t,e){return Ir({kind:"class",elements:new Set,mutate:e,selector:t})}function Er(t,e,i){return Py.test(e)?e==="class"||e==="className"?os(t,function(s){var r=i(Array.from(s).join(" "));s.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return s.add(n)})}):Ir({kind:"attribute",attribute:e,elements:new Set,mutate:i,selector:t}):No}function Jy(t){var e=t.selector,i=t.action,s=t.value,r=t.attribute,n=t.parentSelector,o=t.insertBeforeSelector;if(r==="html"){if(i==="append")return xo(e,function(a){return a+(s??"")});if(i==="set")return xo(e,function(){return s??""})}else if(r==="class"){if(i==="append")return os(e,function(a){s&&a.add(s)});if(i==="remove")return os(e,function(a){s&&a.delete(s)});if(i==="set")return os(e,function(a){a.clear(),s&&a.add(s)})}else if(r==="position"){if(i==="set"&&n)return ad(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(i==="append")return Er(e,r,function(a){return a!==null?a+(s??""):s??""});if(i==="set")return Er(e,r,function(){return s??""});if(i==="remove")return Er(e,r,function(){return null})}return No}var Py,No,Sr,Do,$y,Fy,My,Uy,By,Vy,Gy,qy,yr,Co,Qy,ld,ud=Fe(()=>{"use strict";Py=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,No={revert:function(){}},Sr=new Map,Do=new Set;$y=function(e){return e.innerHTML},Fy=function(e,i){return e.innerHTML=i};My=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},Uy=function(e,i){i.insertBeforeNode&&!i.parentNode.contains(i.insertBeforeNode)||i.parentNode.insertBefore(e,i.insertBeforeNode)};By=function(e,i){return i?e.className=i:e.removeAttribute("class")},Vy=function(e){return e.className};Gy=function(e){return function(i){var s;return(s=i.getAttribute(e))!=null?s:null}},qy=function(e){return function(i,s){return s!==null?i.setAttribute(e,s):i.removeAttribute(e)}};Xy();Qy={html:xo,classes:os,attribute:Er,position:ad,declarative:Jy},ld=Qy});function Lt(t,e,i){i=i||{};for(let[s,r]of Object.entries(e))switch(s){case"$or":if(!hd(t,r,i))return!1;break;case"$nor":if(hd(t,r,i))return!1;break;case"$and":if(!sb(t,r,i))return!1;break;case"$not":if(Lt(t,r,i))return!1;break;default:if(!as(r,Zy(t,s),i))return!1}return!0}function Zy(t,e){let i=e.split("."),s=t;for(let r=0;r<i.length;r++)if(s&&typeof s=="object"&&i[r]in s)s=s[i[r]];else return null;return s}function cd(t,e=!1){let i=`${t}${e?"/i":""}`;return Lo[i]||(Lo[i]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Lo[i]}function as(t,e,i,s=!1){if(typeof t=="string")return s?String(e).toLowerCase()===t.toLowerCase():e+""===t;if(typeof t=="number")return e*1===t;if(typeof t=="boolean")return e!==null&&!!e===t;if(t===null)return e===null;if(Array.isArray(t)||!gd(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!ib(r,e,t[r],i))return!1;return!0}function gd(t){let e=Object.keys(t);return e.length>0&&e.filter(i=>i[0]==="$").length===e.length}function eb(t){if(t===null)return"null";if(Array.isArray(t))return"array";let e=typeof t;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function tb(t,e,i){if(!Array.isArray(t))return!1;let s=gd(e)?r=>as(e,r,i):r=>Lt(r,e,i);for(let r=0;r<t.length;r++)if(t[r]&&s(t[r]))return!0;return!1}function Si(t,e,i=!1){if(i){let s=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(t)?t.some(r=>e.some(n=>s(r)===s(n))):e.some(r=>s(t)===s(r))}return Array.isArray(t)?t.some(s=>e.includes(s)):e.includes(t)}function dd(t,e,i,s=!1){if(!Array.isArray(t))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<t.length;o++)if(as(e[r],t[o],i,s)){n=!0;break}if(!n)return!1}return!0}function ib(t,e,i,s){switch(t){case"$veq":return He(e)===He(i);case"$vne":return He(e)!==He(i);case"$vgt":return He(e)>He(i);case"$vgte":return He(e)>=He(i);case"$vlt":return He(e)<He(i);case"$vlte":return He(e)<=He(i);case"$eq":return e===i;case"$ne":return e!==i;case"$lt":return e<i;case"$lte":return e<=i;case"$gt":return e>i;case"$gte":return e>=i;case"$exists":return i?e!=null:e==null;case"$in":return Array.isArray(i)?Si(e,i):!1;case"$ini":return Array.isArray(i)?Si(e,i,!0):!1;case"$inGroup":return Si(e,s[i]||[]);case"$notInGroup":return!Si(e,s[i]||[]);case"$nin":return Array.isArray(i)?!Si(e,i):!1;case"$nini":return Array.isArray(i)?!Si(e,i,!0):!1;case"$not":return!as(i,e,s);case"$size":return Array.isArray(e)?as(i,e.length,s):!1;case"$elemMatch":return tb(e,i,s);case"$all":return Array.isArray(i)?dd(e,i,s):!1;case"$alli":return Array.isArray(i)?dd(e,i,s,!0):!1;case"$regex":try{return cd(i).test(e)}catch{return!1}case"$regexi":try{return cd(i,!0).test(e)}catch{return!1}case"$type":return eb(e)===i;default:return console.error("Unknown operator: "+t),!1}}function hd(t,e,i){if(!e.length)return!0;for(let s=0;s<e.length;s++)if(Lt(t,e[s],i))return!0;return!1}function sb(t,e,i){for(let s=0;s<e.length;s++)if(!Lt(t,e[s],i))return!1;return!0}var Lo,fd=Fe(()=>{"use strict";rs();Lo={}});function ob(t){let e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach((i,s)=>e.set(s,i)),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach((i,s)=>e.set(s,i)),e}function ab(t){return t.global.forcedVariations&&t.user.forcedVariations?{...t.global.forcedVariations,...t.user.forcedVariations}:t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}async function ki(t){try{await t()}catch{}}function pd(t,e,i){if(t.user.trackedExperiments){let r=Pr(e,i);if(t.user.trackedExperiments.has(r))return[];t.user.trackedExperiments.add(r)}t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({experiment:e,result:i,timestamp:Date.now().toString(),logType:"experiment"});let s=[];if(t.global.trackingCallback){let r=t.global.trackingCallback;s.push(ki(()=>r(e,i,t.user)))}if(t.user.trackingCallback){let r=t.user.trackingCallback;s.push(ki(()=>r(e,i)))}if(t.global.eventLogger){let r=t.global.eventLogger;s.push(ki(()=>r(nb,{experimentId:e.key,variationId:i.key,hashAttribute:i.hashAttribute,hashValue:i.hashValue},t.user)))}return s}function lb(t,e,i){if(t.user.trackedFeatureUsage){let s=JSON.stringify(i.value);if(t.user.trackedFeatureUsage[e]===s)return;t.user.trackedFeatureUsage[e]=s,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:i,timestamp:Date.now().toString(),logType:"feature"})}if(t.global.onFeatureUsage){let s=t.global.onFeatureUsage;ki(()=>s(e,i,t.user))}if(t.user.onFeatureUsage){let s=t.user.onFeatureUsage;ki(()=>s(e,i))}if(t.global.eventLogger){let s=t.global.eventLogger;ki(()=>s(rb,{feature:e,source:i.source,value:i.value,ruleId:i.source==="defaultValue"?"$default":i.ruleId||"",variationId:i.experimentResult?i.experimentResult.key:""},t.user))}}function Tr(t,e){if(e.stack.evaluatedFeatures.has(t))return $t(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let i=ob(e);if(i.has(t))return $t(e,t,i.get(t),"override");if(!e.global.features||!e.global.features[t])return $t(e,t,null,"unknownFeature");let s=e.global.features[t];if(s.rules){let r=new Set(e.stack.evaluatedFeatures);e:for(let n of s.rules){if(n.parentConditions)for(let l of n.parentConditions){e.stack.evaluatedFeatures=new Set(r);let u=Tr(l.id,e);if(u.source==="cyclicPrerequisite")return $t(e,t,null,"cyclicPrerequisite");let c={value:u.value};if(!Lt(c,l.condition||{})){if(l.gate)return $t(e,t,null,"prerequisite");continue e}}if(n.filters&&md(n.filters,e))continue;if("force"in n){if(n.condition&&!_d(n.condition,e)||!ub(e,n.seed||t,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=>{!pd(e,l.experiment,l.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:l.experiment,result:l.result})}),$t(e,t,n.force,"force",n.id)}if(!n.variations)continue;let o={variations:n.variations,key:n.key||t};"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}=Rr(o,t,e);if(e.global.onExperimentEval&&e.global.onExperimentEval(o,a),a.inExperiment&&!a.passthrough)return $t(e,t,a.value,"experiment",n.id,o,a)}}return $t(e,t,s.defaultValue===void 0?null:s.defaultValue,"defaultValue")}function Rr(t,e,i){let s=t.key,r=t.variations.length;if(r<2)return{result:le(i,t,-1,!1,e)};if(i.global.enabled===!1||i.user.enabled===!1)return{result:le(i,t,-1,!1,e)};if(t=cb(t,i),t.urlPatterns&&!fr(i.user.url||"",t.urlPatterns))return{result:le(i,t,-1,!1,e)};let n=Vc(s,i.user.url||"",r);if(n!==null)return{result:le(i,t,n,!1,e)};let o=ab(i);if(s in o){let m=o[s];return{result:le(i,t,m,!1,e)}}if(t.status==="draft"||t.active===!1)return{result:le(i,t,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Xt(i,t.hashAttribute,i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:le(i,t,-1,!1,e)};let u=-1,c=!1,h=!1;if(i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:m,versionIsBlocked:y}=gb({ctx:i,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});c=m>=0,u=m,h=!!y}if(!c){if(t.filters){if(md(t.filters,i))return{result:le(i,t,-1,!1,e)}}else if(t.namespace&&!Mc(l,t.namespace))return{result:le(i,t,-1,!1,e)};if(t.include&&!Gc(t.include))return{result:le(i,t,-1,!1,e)};if(t.condition&&!_d(t.condition,i))return{result:le(i,t,-1,!1,e)};if(t.parentConditions){let m=new Set(i.stack.evaluatedFeatures);for(let y of t.parentConditions){i.stack.evaluatedFeatures=new Set(m);let w=Tr(y.id,i);if(w.source==="cyclicPrerequisite")return{result:le(i,t,-1,!1,e)};let R={value:w.value};if(!Lt(R,y.condition||{}))return{result:le(i,t,-1,!1,e)}}}if(t.groups&&!hb(t.groups,i))return{result:le(i,t,-1,!1,e)}}if(t.url&&!db(t.url,i))return{result:le(i,t,-1,!1,e)};let f=is(t.seed||s,l,t.hashVersion||1);if(f===null)return{result:le(i,t,-1,!1,e)};if(!c){let m=t.ranges||Bc(r,t.coverage===void 0?1:t.coverage,t.weights);u=Uc(f,m)}if(h)return{result:le(i,t,-1,!1,e,void 0,!0)};if(u<0)return{result:le(i,t,-1,!1,e)};if("force"in t)return{result:le(i,t,t.force===void 0?-1:t.force,!1,e)};if(i.global.qaMode||i.user.qaMode)return{result:le(i,t,-1,!1,e)};if(t.status==="stopped")return{result:le(i,t,-1,!1,e)};let g=le(i,t,u,!0,e,f,c);if(i.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:m,key:y,doc:w}=pb(i,a,ss(l),{[$o(t.key,t.bucketVersion)]:g.key});m&&(i.user.stickyBucketAssignmentDocs=i.user.stickyBucketAssignmentDocs||{},i.user.stickyBucketAssignmentDocs[y]=w,i.user.saveStickyBucketAssignmentDoc(w))}let p=pd(i,t,g);p.length===0&&i.global.saveDeferredTrack&&i.global.saveDeferredTrack({experiment:t,result:g});let v=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in t&&t.changeId&&i.global.recordChangeId&&i.global.recordChangeId(t.changeId),{result:g,trackingCall:v}}function $t(t,e,i,s,r,n,o){let a={value:i,on:!!i,off:!i,source:s,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),s!=="override"&&lb(t,e,a),a}function vd(t){return{...t.user.attributes,...t.user.attributeOverrides}}function _d(t,e){return Lt(vd(e),t,e.global.savedGroups||{})}function md(t,e){return t.some(i=>{let{hashValue:s}=Xt(e,i.attribute);if(!s)return!0;let r=is(i.seed,s,i.hashVersion||2);return r===null?!0:!i.ranges.some(n=>gr(r,n))})}function ub(t,e,i,s,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Xt(t,i,s);if(!a)return!1;let l=is(e,a,o||1);return l===null?!1:r?gr(l,r):n!==void 0?l<=n:!0}function le(t,e,i,s,r,n,o){let a=!0;(i<0||i>=e.variations.length)&&(i=0,a=!1);let{hashAttribute:l,hashValue:u}=Xt(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),c=e.meta?e.meta[i]:{},h={key:c.key||""+i,featureId:r,inExperiment:a,hashUsed:s,variationId:i,value:e.variations[i],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};return c.name&&(h.name=c.name),n!==void 0&&(h.bucket=n),c.passthrough&&(h.passthrough=c.passthrough),h}function cb(t,e){let i=t.key,s=e.global.overrides;return s&&s[i]&&(t=Object.assign({},t,s[i]),typeof t.url=="string"&&(t.url=wo(t.url))),t}function Xt(t,e,i){let s=e||"id",r="",n=vd(t);return n[s]&&(r=n[s]),!r&&i&&(n[i]&&(r=n[i]),r&&(s=i)),{hashAttribute:s,hashValue:r}}function db(t,e){let i=e.user.url;if(!i)return!1;let s=i.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(t.test(i)||t.test(s))}function hb(t,e){let i=e.global.groups||{};for(let s=0;s<t.length;s++)if(i[t[s]])return!0;return!1}function gb({ctx:t,expKey:e,expBucketVersion:i,expHashAttribute:s,expFallbackAttribute:r,expMinBucketVersion:n,expMeta:o}){i=i||0,n=n||0,s=s||"id",o=o||[];let a=$o(e,i),l=fb(t,s,r);if(n>0)for(let h=0;h<n;h++){let f=$o(e,h);if(l[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let u=l[a];if(u===void 0)return{variation:-1};let c=o.findIndex(h=>h.key===u);return c<0?{variation:-1}:{variation:c}}function $o(t,e){return e=e||0,`${t}__${e}`}function Fo(t,e){return`${t}||${e}`}function fb(t,e,i){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:s,hashValue:r}=Xt(t,e),n=Fo(s,ss(r)),{hashAttribute:o,hashValue:a}=Xt(t,i),l=a?Fo(o,ss(a)):null,u={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[n]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[n].assignments||{}),u}function pb(t,e,i,s){let r=Fo(e,i),n=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[r]?t.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o={...n,...s},a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:i,assignments:o},changed:a}}function vb(t,e){let i=new Set,s=e&&e.features?e.features:t.global.features||{},r=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(s).forEach(n=>{let o=s[n];if(o.rules)for(let a of o.rules)a.variations&&(i.add(a.hashAttribute||"id"),a.fallbackAttribute&&i.add(a.fallbackAttribute))}),r.map(n=>{i.add(n.hashAttribute||"id"),n.fallbackAttribute&&i.add(n.fallbackAttribute)}),Array.from(i)}async function yd(t,e,i){let s=Mo(t,i);return e.getAllAssignments(s)}function Mo(t,e){let i={};return vb(t,e).forEach(r=>{let{hashValue:n}=Xt(t,r);i[r]=ss(n)}),i}async function bd(t,e,i){if(t={...t},t.encryptedFeatures){try{t.features=JSON.parse(await Yt(t.encryptedFeatures,e,i))}catch(s){console.error(s)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await Yt(t.encryptedExperiments,e,i))}catch(s){console.error(s)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await Yt(t.encryptedSavedGroups,e,i))}catch(s){console.error(s)}delete t.encryptedSavedGroups}return t}function Ed(t){let e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}function Pr(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var rb,nb,Sd=Fe(()=>{"use strict";fd();rs();rb="Feature Evaluated",nb="Experiment Viewed"});var wi,_b,ls,kd=Fe(()=>{"use strict";ud();rs();Zc();Sd();wi=typeof window<"u"&&typeof document<"u",_b=qc(),ls=class{constructor(e){if(e=e||{},this.version=_b,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 i=!1;try{i=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(i)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 i=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=s=>i.saveAssignments(s)}if(e.plugins)for(let i of e.plugins)i(this);if(e.features&&(this.ready=!0),wi&&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 i in this._options.stickyBucketAssignmentDocs){let s=this._options.stickyBucketAssignmentDocs[i];s&&this._options.stickyBucketService.saveAssignments(s).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let i=await bd(e,this._options.decryptionKey);this._decryptedPayload=i,await this.refreshStickyBuckets(i),i.features&&(this._options.features=i.features),i.savedGroups&&(this._options.savedGroups=i.savedGroups),i.experiments&&(this._options.experiments=i.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let i=e.payload;if(i.encryptedExperiments||i.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,i)),this._payload=i,this._decryptedPayload=i,i.features&&(this._options.features=i.features),i.experiments&&(this._options.experiments=i.experiments,this._updateAllAutoExperiments()),this.ready=!0,mr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Kc(e.cacheSettings),e.payload)return await this.setPayload(e.payload),mr(this,e),{success:!0,source:"init"};{let{data:i,...s}=await this._refresh({...e,allowStale:!0});return mr(this,e),await this.setPayload(i||{}),s}}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 i=await this._refresh({...e||{},allowStale:!1});i.data&&await this.setPayload(i.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return Ed(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:i,allowStale:s,streaming:r}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Wc({instance:this,timeout:e,skipCache:i||this._options.disableCache,allowStale:s,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,i,s){let r=await Yt(e,i||this._options.decryptionKey,s);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,i,s){let r=await Yt(e,i||this._options.decryptionKey,s);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(i=>{try{i()}catch(s){console.error(s)}}),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,Yc(this),e.destroyAllStreams&&Oo(),this.logs=[],wi&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(i=>{i.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,i){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=i,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:i}=Rr(e,null,this._getEvalContext());return this._onExperimentEval(e,i),i}triggerExperiment(e){return this._triggeredExpKeys.add(e),this._options.experiments?this._options.experiments.filter(s=>s.key===e).map(s=>this._runAutoExperiment(s)).filter(s=>s!==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,i){let s=this._activeAutoExperiments.get(e);if(e.manual&&!this._triggeredExpKeys.has(e.key)&&!s)return null;let r=this._isAutoExperimentBlockedByContext(e),n,o;r?n=le(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=Rr(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!i&&n.inExperiment&&s&&s.valueHash===a)return n;if(s&&this._undoActiveAutoExperiment(e),n.inExperiment){let l=pr(e);if(l==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let u=e.persistQueryString?jc(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(fr(u,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=u;let{navigate:c,delay:h}=this._getNavigateFunction();if(c)if(wi)Promise.all([...o?[vr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(f=>window.setTimeout(f,this._options.navigateDelay??h))]).then(()=>{try{c(u)}catch(f){console.error(f)}});else try{c(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 i=this._activeAutoExperiments.get(e);i&&(i.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let i=this._options.experiments||[],s=new Set(i);this._activeAutoExperiments.forEach((r,n)=>{s.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of i){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&pr(r)==="redirect")break}}_onExperimentEval(e,i){let s=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:i}),this._subscriptions.size>0&&this._fireSubscriptions(e,i,s)}_fireSubscriptions(e,i,s){(!s||s.result.inExperiment!==i.inExperiment||s.result.variationId!==i.variationId)&&this._subscriptions.forEach(r=>{try{r(e,i)}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,i){let s=this.evalFeature(e).value;return s===null?i:s}feature(e){return this.evalFeature(e)}evalFeature(e){return Tr(e,this._getEvalContext())}log(e,i){this.debug&&(this._options.log?this._options.log(e,i):console.log(e,i))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(i=>i&&i.experiment&&i.result).map(i=>[Pr(i.experiment,i.result),i]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(i=>{!i||!i.experiment||!i.result?console.error("Invalid deferred tracking call",{call:i}):e.push(this._options.trackingCallback(i.experiment,i.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,i){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:i,timestamp:Date.now().toString(),logType:"event"}),this._options.eventLogger)try{await this._options.eventLogger(e,i||{},this._getUserContext())}catch(s){console.error(s)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(Pr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(wi?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let i=pr(e);if(i==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(s=>s.js))return!0}else if(i==="redirect"){if(this._options.disableUrlRedirectExperiments)return!0;try{let s=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!==s.protocol||n.host!==s.host))return!0}}catch(s){return this.log("Error parsing current or redirect URL",{id:e.key,error:s}),!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}:wi?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!wi)return;let i=[];if(e.css){let s=document.createElement("style");s.innerHTML=e.css,document.head.appendChild(s),i.push(()=>s.remove())}if(e.js){let s=document.createElement("script");s.innerHTML=e.js,this._options.jsInjectionNonce&&(s.nonce=this._options.jsInjectionNonce),document.head.appendChild(s),i.push(()=>s.remove())}return e.domMutations&&e.domMutations.forEach(s=>{i.push(ld.declarative(s).revert)}),()=>{i.forEach(s=>s())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let i=this._getEvalContext(),s=await yd(i,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=s}}generateStickyBucketAssignmentDocsSync(e,i){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let s=this._getEvalContext(),r=Mo(s,i);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var wd=Fe(()=>{"use strict";kd()});var Ad={};Sn(Ad,{Growthbook:()=>Uo});var Xe,Uo,Id=Fe(()=>{"use strict";wd();yo();Zi();ts();Xe=class Xe{constructor(e,i,s={},r=!1){this.analytics=new pi;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Dt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:i,user_language:s,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:u,url:c,domain:h,utm_content:f,residence_country:g,loggedIn:p,network_type:v,network_downlink:m,user_id:y,anonymous_id:w,account_mode:R})=>{let b={...this.GrowthBook.getAttributes(),id:e,...y!==void 0&&{user_id:y},...w!==void 0&&{anonymous_id:w},...i!==void 0&&{country:i},...g!==void 0&&{residence_country:g},...s!==void 0&&{user_language:s},...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},...c!==void 0&&{url:c},...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},...R!==void 0&&{account_mode:R}};this.log("setAttributes | updating GrowthBook attributes",b),this.GrowthBook.setAttributes(b)};this.getFeatureValue=(e,i)=>{let s=this.GrowthBook.getFeatureValue(e,i);return this.log("getFeatureValue",{key:e,value:s,defaultValue:i}),s};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let i=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:i}),i};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let i=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:i}),i};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 ls({apiHost:yc,clientKey:e,decryptionKey:i,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})},...s}),this.init()}reapplyExperiment(e){let i=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(i)}waitForIsLoaded(e=1e4){return new Promise((i,s)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),i()):Date.now()-r>=e&&(clearInterval(n),s(new Error("GrowthBook initialization timeout")))},100)})}};Xe.getGrowthBookInstance=(e,i,s,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,i??"",s,r),Xe._instance),Xe.resetInstance=()=>{Xe._instance&&(Xe._instance.destroy(),Xe._instance=void 0)};Uo=Xe});function Pd(t,e,i,s,r,n,o){try{var a=t[n](o),l=a.value}catch(u){return void i(u)}a.done?e(l):Promise.resolve(l).then(s,r)}function Qe(t){return function(){var e=this,i=arguments;return new Promise((function(s,r){var n=t.apply(e,i);function o(l){Pd(n,s,r,o,a,"next",l)}function a(l){Pd(n,s,r,o,a,"throw",l)}o(void 0)}))}}function S(){return S=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var i=arguments[e];for(var s in i)({}).hasOwnProperty.call(i,s)&&(t[s]=i[s])}return t},S.apply(null,arguments)}function Sh(t,e){if(t==null)return{};var i={};for(var s in t)if({}.hasOwnProperty.call(t,s)){if(e.indexOf(s)!==-1)continue;i[s]=t[s]}return i}function ua(){return ua=Qe((function*(t,e,i){e===void 0&&(e=!0);try{var s=new CompressionStream("gzip"),r=s.writable.getWriter(),n=r.write(new TextEncoder().encode(t)).then((()=>r.close())).catch((function(){var l=Qe((function*(u){try{yield r.abort(u)}catch{}throw u}));return function(u){return l.apply(this,arguments)}})()),o=new Response(s.readable).blob(),[a]=yield Promise.all([o,n]);return a}catch(l){if(i!=null&&i.rethrow)throw l;return e&&console.error("Failed to gzip compress data",l),null}})),ua.apply(this,arguments)}function z(t,e){return t.indexOf(e)!==-1}function Ah(t){return t===null||typeof t!="object"}function qr(t,e){return{}.toString.call(t)==="[object "+e+"]"}function bl(t){return typeof Event<"u"&&(function(e,i){try{return e instanceof i}catch{return!1}})(t,Event)}function gt(t,e,i,s,r){return e>i&&(s.warn("min cannot be greater than max."),e=i),et(t)?t>i?(s.warn(" cannot be greater than max: "+i+". Using max value instead."),i):e>t?(s.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(s.warn(" must be a number. using max or fallback. max: "+i+", fallback: "+r),gt(r||i,e,i,s))}function qh(t){if(ht(t))return{boolValue:t};if(typeof t=="number")return Number.isFinite(t)?Number.isInteger(t)?{intValue:t}:{doubleValue:t}:{stringValue:String(t)};if(typeof t=="string")return{stringValue:t};if(Y(t))return{arrayValue:{values:t.map((e=>qh(e)))}};try{return{stringValue:JSON.stringify(t)}}catch{return{stringValue:String(t)}}}function Ld(t){var e=[];for(var i in t){var s=t[i];Pt(s)||P(s)||e.push({key:i,value:qh(s)})}return e}function $b(t){var e=globalThis._posthogChunkIds;if(e){var i=Object.keys(e);return Vo&&i.length===Cd||(Cd=i.length,Vo=i.reduce(((s,r)=>{Or||(Or={});var n=Or[r];if(n)s[n[0]]=n[1];else for(var o=t(r),a=o.length-1;a>=0;a--){var l=o[a],u=l?.filename,c=e[r];if(u&&c){s[u]=c,Or[r]=[u,c];break}}return s}),{})),Vo}}function va(t,e,i,s,r){var n={platform:t,filename:e,function:i==="<anonymous>"?Bi:i,in_app:!0};return P(s)||(n.lineno=s),P(r)||(n.colno=r),n}function Hh(t,e){e===void 0&&(e=40);var i=Object.keys(t);if(i.sort(),!i.length)return"[object has no keys]";for(var s=i.length;s>0;s--){var r=i.slice(0,s).join(", ");if(e>=r.length)return s===i.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function Kr(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:qo.enabled,max_bytes:Kb(t.max_bytes,qo.max_bytes)}:S({},qo)}function Kb(t,e){if(!et(t)||t===1/0||t===-1/0)return e;var i=Math.floor(t);return 0>i?e:i}function xr(t,e){Y(t)&&t.forEach(e)}function oe(t,e){if(!K(t))if(Y(t))t.forEach(e);else if(Eb(t))t.forEach(((s,r)=>e(s,r)));else for(var i in t)wh.call(t,i)&&e(t[i],i)}function Vr(t){for(var e=Object.keys(t),i=e.length,s=new Array(i);i--;)s[i]=[e[i],t[e[i]]];return s}function Jb(t){var e=t?.hostname;if(!ge(e))return!1;var i=e.split(".").slice(-2).join(".");for(var s of Xb)if(i===s)return!1;return!0}function ye(t,e,i,s){var{capture:r=!1,passive:n=!0}=s??{};t?.addEventListener(e,i,{capture:r,passive:n})}function ig(t){return t.name==="ph_toolbar_internal"}function ng(t,e){var{organization:i,projectId:s,prefix:r,severityAllowList:n=["error"],sendExceptionsToPostHog:o=!0}=e===void 0?{}:e;return a=>{var l,u,c,h,f;if(n!=="*"&&!n.includes(a.level)||!t.__loaded)return a;a.tags||(a.tags={});var g=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());a.tags["PostHog Person URL"]=g,t.sessionRecordingStarted()&&(a.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var p,v=((l=a.exception)==null?void 0:l.values)||[],m=v.map((w=>S({},w,{stacktrace:w.stacktrace?S({},w.stacktrace,{type:"raw",frames:(w.stacktrace.frames||[]).map((R=>S({},R,{platform:"web:javascript"})))}):void 0}))),y={$exception_message:((u=v[0])==null?void 0:u.value)||a.message,$exception_type:(c=v[0])==null?void 0:c.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 i&&s&&(y.$sentry_url=(r||"https://sentry.io/organizations/")+i+"/issues/?project="+s+"&query="+a.event_id),o&&((p=t.exceptions)==null||p.sendExceptionEvent(y)),a}}function og(t,e,i){if(!I)return{};var s,r=e?[...Vi,...i||[]]:[],n=ag(xs(I.URL,r,Ns),t),o=(s={},oe(aE,(function(a){var l=dt.A(a);s[a]=l||null})),s);return pe(o,n)}function ag(t,e){var i=oE.concat(e||[]),s={};return oe(i,(function(r){var n=nn(t,r);s[r]=n||null})),s}function lg(t){var e=(function(n){return n?n.search(Lr+"google.([^/?]*)")===0?"google":n.search(Lr+"bing.com")===0?"bing":n.search(Lr+"yahoo.com")===0?"yahoo":n.search(Lr+"duckduckgo.com")===0?"duckduckgo":null:null})(t),i=e!="yahoo"?"q":"p",s={};if(!Pt(e)){s.$search_engine=e;var r=I?nn(I.referrer,i):"";r.length&&(s.ph_keyword=r)}return s}function Bd(){return navigator.language||navigator.userLanguage}function ug(){return I?.referrer||an}function cg(t,e){var i=t?[...Vi,...e||[]]:[],s=Te?.href.substring(0,1e3);return{r:ug().substring(0,1e3),u:s?xs(s,i,Ns):void 0}}function dg(t){var e,{r:i,u:s}=t,r={$referrer:i,$referring_domain:i==null?void 0:i==an?an:(e=rn(i))==null?void 0:e.host};if(s){r.$current_url=s;var n=rn(s);r.$host=n?.host,r.$pathname=n?.pathname;var o=ag(s);pe(r,o)}if(i){var a=lg(i);pe(r,a)}return r}function hg(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function lE(){try{return new Date().getTimezoneOffset()}catch{return}}function pE(t,e){e===void 0&&(e={});var i=(function(){var h=4294967295;return{p(f){for(var g=h,p=0;f.length>p;++p)g=fE[255&g^f[p]]^g>>>8;h=g},d(){return 4294967295^h}}})(),s=t.length;i.p(t);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 Ze(p+y+5*(1+Math.floor(y/7e3))+v),R=w.subarray(p,w.length-v),N=0;if(!f||8>y)for(var b=0;y>=b;b+=65535){var x=b+65535;y>x?N=il(R,N,h.subarray(b,x)):(R[b]=!0,N=il(R,N,h.subarray(b,y)))}else{for(var C=gE[f-1],O=C>>>13,A=8191&C,$=(1<<g)-1,U=new Le(32768),H=new Le($+1),G=Math.ceil(g/3),q=2*G,_e=function(En){return(h[En]^h[En+1]<<G^h[En+2]<<q)&$},Ee=new Gi(25e3),$e=new Le(288),Se=new Le(32),k=0,M=0,F=(b=0,0),B=0,Z=0;y>b;++b){var ce=_e(b),se=32767&b,me=H[ce];if(U[se]=me,H[ce]=se,b>=B){var Pe=y-b;if((k>7e3||F>24576)&&Pe>423){N=Hd(h,R,0,Ee,$e,Se,M,F,Z,b-Z,N),F=k=M=0,Z=b;for(var ke=0;286>ke;++ke)$e[ke]=0;for(ke=0;30>ke;++ke)Se[ke]=0}var j=2,ft=0,Lg=A,Ot=se-me&32767;if(Pe>2&&ce==_e(b-Ot))for(var $g=Math.min(O,Pe)-1,Fg=Math.min(32767,b),Mg=Math.min(258,Pe);Fg>=Ot&&--Lg&&se!=me;){if(h[b+j]==h[b+j-Ot]){for(var Ct=0;Mg>Ct&&h[b+Ct]==h[b+Ct-Ot];++Ct);if(Ct>j){if(j=Ct,ft=Ot,Ct>$g)break;var Ug=Math.min(Ot,Ct-2),Dl=0;for(ke=0;Ug>ke;++ke){var bn=b-Ot+ke+32768&32767,Ll=bn-U[bn]+32768&32767;Ll>Dl&&(Dl=Ll,me=bn)}}}Ot+=(se=me)-(me=U[se])+32768&32767}if(ft){Ee[F++]=268435456|Za[j]<<18|el[ft];var $l=31&Za[j],Fl=31&el[ft];M+=Pl[$l]+Ol[Fl],++$e[257+$l],++Se[Fl],B=b+j,++k}else Ee[F++]=h[b],++$e[h[b]]}}N=Hd(h,R,!0,Ee,$e,Se,M,F,Z,b-Z,N)}return vg(w,0,p+pg(N)+v)})(n=t,(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)),c=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&&Qo(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),Qo(u,c-8,i.d()),Qo(u,c-4,s),u}function Wd(t,e,i){return Li({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:i})}function bg(t,e){return!t||Object.entries(t).every((i=>{var[s,r]=i,n=e?.[s];if(P(n)||Pt(n))return!1;var o=[String(n)],a=yg[r.operator];return!!a&&a(r.values,o)}))}function eh(t){return t instanceof Element&&(t.id===Qh||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function oi(t){return!!t&&t.nodeType===IE}function nt(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function kg(t){return!!t&&t.nodeType===TE}function wg(t){return!!t&&t.nodeType===RE&&oi(t.host)}function Cl(t){return t?vn(t).split(/\s+/):[]}function th(t){var e=_?.location.href;return!!(e&&t&&t.some((i=>e.match(i))))}function fn(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return Cl(e)}function Ag(t){return K(t)?null:vn(t).split(/(\s+)/).filter((e=>Ps(e))).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function Ls(t){var e="";return fl(t)&&!Tg(t)&&t.childNodes&&t.childNodes.length&&oe(t.childNodes,(function(i){var s;kg(i)&&i.textContent&&(e+=(s=Ag(i.textContent))!==null&&s!==void 0?s:"")})),vn(e)}function ih(t){return P(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null;var e}function sh(t,e){if(P(e))return!0;var i,s=function(n){if(e.some((o=>n.matches(o))))return{v:!0}};for(var r of t)if(i=s(r))return i.v;return!1}function Ig(t){var e=t.parentNode;return!(!e||!oi(e))&&e}function fl(t){for(var e=t;e.parentNode&&!nt(e,"body");e=e.parentNode){var i=fn(e);if(z(i,"ph-sensitive")||z(i,"ph-no-capture"))return!1}if(z(fn(t),"ph-include"))return!0;var s=t.type||"";if(ge(s))switch(s.toLowerCase()){case"hidden":case"password":return!1}var r=t.name||t.id||"";return!ge(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 Tg(t){return!!(nt(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||nt(t,"select")||nt(t,"textarea")||t.getAttribute("contenteditable")==="true")}function Ps(t,e){return e===void 0&&(e=!0),!(K(t)||ge(t)&&(t=vn(t),(e?OE:CE).test((t||"").replace(/[- ]/g,""))||(e?xE:NE).test(t)))}function oh(t){var e=Ls(t);return Ps(e=(e+" "+Og(t)).trim())?e:""}function Og(t){var e="";return t&&t.childNodes&&t.childNodes.length&&oe(t.childNodes,(function(i){var s;if(i&&((s=i.tagName)==null?void 0:s.toLowerCase())==="span")try{var r=Ls(i);e=(e+" "+r).trim(),i.childNodes&&i.childNodes.length&&(e=(e+" "+Og(i)).trim())}catch(n){T.error("[AutoCapture]",n)}})),e}function ah(t){return t.replace(/"|\\"/g,'\\"')}function DE(t){var e=t.attr__class;return e?Y(e)?e:Cl(e):void 0}function ra(t,e){return e.length>t?e.slice(0,t)+"...":e}function LE(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!oi(e));return e}function $E(t,e){var i,s,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e;if(!oi(t))return{props:{}};for(var u=[t],c=t;c.parentNode&&!nt(c,"body");)if(wg(c.parentNode))u.push(c.parentNode.host),c=c.parentNode.host;else{if(!oi(c.parentNode))break;u.push(c.parentNode),c=c.parentNode}var h,f,g=[],p={},v=!1,m=!1;if(oe(u,(b=>{var x=fl(b);if(nt(b,"a")){var C=b.getAttribute("href");v=x&&!!C&&Ps(C)&&C}z(fn(b),"ph-no-capture")&&(m=!0),g.push((function(A,$,U,H){var G=A.tagName.toLowerCase(),q={tag_name:G};xl.indexOf(G)>-1&&!U&&(q.$el_text=G.toLowerCase()==="a"||G.toLowerCase()==="button"?ra(1024,oh(A)):ra(1024,Ls(A)));var _e=fn(A);_e.length>0&&(q.classes=_e.filter((function(k){return k!==""}))),oe(A.attributes,(function(k){var M;if((!Tg(A)||["name","id","class","aria-label"].indexOf(k.name)!==-1)&&(H==null||!H.includes(k.name))&&!$&&Ps(k.value)&&(!ge(M=k.name)||M.substring(0,10)!=="_ngcontent"&&M.substring(0,7)!=="_nghost")){var F=k.value;k.name==="class"&&(F=Cl(F).join(" ")),q["attr__"+k.name]=ra(1024,F)}}));for(var Ee=1,$e=1,Se=A;Se=LE(Se);)Ee++,Se.tagName===A.tagName&&$e++;return q.nth_child=Ee,q.nth_of_type=$e,q})(b,n,o,a));var O=(function(A){if(!fl(A))return{};var $={};return oe(A.attributes,(function(U){if(U.name&&U.name.indexOf("data-ph-capture-attribute")===0){var H=U.name.replace("data-ph-capture-attribute-",""),G=U.value;H&&G&&Ps(G)&&($[H]=G)}})),$})(b);pe(p,O)})),m)return{props:{},explicitNoCapture:m};if(o||(g[0].$el_text=nt(t,"a")||nt(t,"button")?oh(t):Ls(t)),v){var y,w;g[0].attr__href=v;var R=(y=rn(v))==null?void 0:y.host,N=_==null||(w=_.location)==null?void 0:w.host;R&&N&&R!==N&&(h=v)}return{props:pe({$event_type:r.type,$ce_version:1},l?{}:{$elements:g},{$elements_chain:(f=g,(function(b){return b.map((x=>{var C,O,A="";if(x.tag_name&&(A+=x.tag_name),x.attr_class)for(var $ of(x.attr_class.sort(),x.attr_class))A+="."+$.replace(/"/g,"");var U=S({},x.text?{text:x.text}:{},{"nth-child":(C=x.nth_child)!==null&&C!==void 0?C:0,"nth-of-type":(O=x.nth_of_type)!==null&&O!==void 0?O:0},x.href?{href:x.href}:{},x.attr_id?{attr_id:x.attr_id}:{},x.attributes),H={};return Vr(U).sort(((G,q)=>{var[_e]=G,[Ee]=q;return _e.localeCompare(Ee)})).forEach((G=>{var[q,_e]=G;return H[ah(q.toString())]=ah(_e.toString())})),(A+=":")+Vr(H).map((G=>{var[q,_e]=G;return q+'="'+_e+'"'})).join("")})).join(";")})((function(b){return b.map((x=>{var C,O,A={text:(C=x.$el_text)==null?void 0:C.slice(0,400),tag_name:x.tag_name,href:(O=x.attr__href)==null?void 0:O.slice(0,2048),attr_class:DE(x),attr_id:x.attr__id,nth_child:x.nth_child,nth_of_type:x.nth_of_type,attributes:{}};return Vr(x).filter(($=>{var[U]=$;return U.indexOf("attr__")===0})).forEach(($=>{var[U,H]=$;return A.attributes[U]=H})),A}))})(f)))},(i=g[0])!=null&&i.$el_text?{$el_text:(s=g[0])==null?void 0:s.$el_text}:{},h&&r.type==="click"?{$external_click_url:h}:{},p)}}function lh(t,e,i){try{if(!(e in t))return()=>{};var s=t[e],r=i(s);return It(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0}})),t[e]=r,()=>{t[e]=s}}catch{return()=>{}}}function hh(t){return ve(t)&&"clientX"in t&&"clientY"in t&&et(t.clientX)&&et(t.clientY)}function Ri(t,e,i){if(K(t))return!1;switch(i){case"exact":return t===e;case"contains":var s=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(s,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}var _,be,ze,I,Te,aa,la,Td,mb,Ge,L,Rd,De,yb,Od,bb,vn,ca,kh,wh,_n,Y,It,ve,Ni,P,ge,Mr,Pt,K,et,Pi,ht,Eb,Sb,kb,Bo,wb,da,Or,Cd,Vo,Ke,jr,Rt,Mi,Ih,Th,Rh,Ph,ws,Ui,Oh,Ch,xh,si,Ab,Nh,El,Dh,Sl,Ib,kl,Lh,$i,$h,Os,Cs,Fi,Fh,Mh,_s,ha,xd,ga,Uh,Tb,Bh,fa,Ne,Go,Rb,Pb,Ob,wl,Cb,Vh,xb,Nb,Nd,Dd,Db,Gh,Lb,pa,Bi,jh,Fb,Mb,Ub,Bb,Vb,Gb,qb,$d,_a,ma,ya,jb,ba,Hb,Ea,Sa,ka,wa,Hr,zr,zb,qo,Aa,zh,T,ue,Wb,jo,Kh,Wr,ms,ys,Ia,Ta,Ra,Pa,Oa,Ca,Al,xa,Na,bs,Wh,Yh,Xh,Jh,Yr,Il,Di,Ur,Es,Da,La,$a,At,Oi,Ss,ti,Fa,Ma,Br,As,Ua,Ba,Xr,rt,Va,Ga,qa,ja,Jr,Qr,Qh,Cr,Zh,eg,tg,Tl,ii,Tt,Ai,Ii,Ha,Zr,en,Ci,Ho,zo,Fd,pe,Md,Yb,Rl,Xb,za,Ka,Ud,sg,Wa,Bt,Qb,us,Zb,dt,Ko,he,eE,Nr,tE,Jt,Re,Ya,Dr,iE,sE,tn,Wo,rg,Xa,sn,rE,nE,rn,nn,xs,on,Lr,Vi,oE,Ns,aE,an,uE,Is,cs,Yo,ks,Xo,Ja,cE,Vd,Gd,Qa,ds,ln,ct,Ze,Le,Gi,Pl,Ol,qd,gg,fg,Za,Qt,el,un,ie,Ts,ni,cn,dE,hE,pg,vg,kt,hs,Jo,tl,jd,gs,il,Hd,gE,fE,Qo,vE,_g,zd,mn,Li,Zo,_E,Kd,Gr,sl,rl,mE,nl,ol,yE,dn,Ds,ea,hn,mg,gn,yg,$r,al,Yd,bE,ll,ee,ul,EE,SE,kE,wE,cl,Ti,Rs,ta,dl,Xd,fs,Jd,Eg,xi,Sg,Qd,AE,Zd,hl,ri,IE,TE,RE,xl,PE,rh,gl,nh,Rg,OE,CE,Pg,xE,NE,pn,ia,sa,ps,FE,Ft,uh,ch,dh,vs,Fr,pl,Mt,ME,gh,UE,Ut,fh,vl,_l,ml,na,ph,BE,vh,_h,xe,Zt,oa,mh,yh,wt,bh,VE,yl,Je,ei,yn,GE,qE,jE,HE,zE,KE,WE,YE,XE,JE,QE,ZE,Eh,qe,Cg=Fe(()=>{"use strict";_=typeof window<"u"?window:void 0,be=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(be.self=be),typeof File>"u"&&(be.File=function(){});ze=be?.navigator,I=be?.document,Te=be?.location,aa=be?.fetch,la=be!=null&&be.XMLHttpRequest&&"withCredentials"in new be.XMLHttpRequest?be.XMLHttpRequest:void 0,Td=be?.AbortController,mb=be?.CompressionStream,Ge=ze?.userAgent,L=_??{},Rd="1.372.9",De={DEBUG:!1,LIB_VERSION:Rd,LIB_NAME:"web",JS_SDK_VERSION:Rd};yb=["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"],Od=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var i=t.toLowerCase();return yb.concat(e).some((s=>{var r=s.toLowerCase();return i.indexOf(r)!==-1}))},bb=["$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"];vn=function(t){return t.trim()},ca=function(t){return t.replace(/^\$/,"")},kh=Object.prototype,wh=kh.hasOwnProperty,_n=kh.toString,Y=Array.isArray||function(t){return _n.call(t)==="[object Array]"},It=t=>typeof t=="function",ve=t=>t===Object(t)&&!Y(t),Ni=t=>{if(ve(t)){for(var e in t)if(wh.call(t,e))return!1;return!0}return!1},P=t=>t===void 0,ge=t=>_n.call(t)=="[object String]",Mr=t=>ge(t)&&t.trim().length===0,Pt=t=>t===null,K=t=>P(t)||Pt(t),et=t=>_n.call(t)=="[object Number]"&&t==t,Pi=t=>et(t)&&t>0,ht=t=>_n.call(t)==="[object Boolean]",Eb=t=>t instanceof FormData,Sb=t=>z(bb,t);kb=[!0,"true",1,"1","yes"],Bo=t=>z(kb,t),wb=[!1,"false",0,"0","no"];da=class{constructor(e){this.$t={},this.zt=e.zt,this.Zt=gt(e.bucketSize,0,100,e.Gt),this.Qt=gt(e.refillRate,0,this.Zt,e.Gt),this.Jt=gt(e.refillInterval,0,864e5,e.Gt)}Kt(e,i){var s=Math.floor((i-e.lastAccess)/this.Jt);s>0&&(e.tokens=Math.min(e.tokens+s*this.Qt,this.Zt),e.lastAccess=e.lastAccess+s*this.Jt)}consumeRateLimit(e){var i,s=Date.now(),r=String(e),n=this.$t[r];return n?this.Kt(n,s):this.$t[r]=n={tokens:this.Zt,lastAccess:s},n.tokens===0||(n.tokens--,n.tokens===0&&((i=this.zt)==null||i.call(this,e)),n.tokens===0)}stop(){this.$t={}}},Ke="Mobile",jr="iOS",Rt="Android",Mi="Tablet",Ih=Rt+" "+Mi,Th="iPad",Rh="Apple",Ph=Rh+" Watch",ws="Safari",Ui="BlackBerry",Oh="Samsung",Ch=Oh+"Browser",xh=Oh+" Internet",si="Chrome",Ab=si+" OS",Nh=si+" "+jr,El="Internet Explorer",Dh=El+" "+Ke,Sl="Opera",Ib=Sl+" Mini",kl="Edge",Lh="Microsoft "+kl,$i="Firefox",$h=$i+" "+jr,Os="Nintendo",Cs="PlayStation",Fi="Xbox",Fh=Rt+" "+Ke,Mh=Ke+" "+ws,_s="Windows",ha=_s+" Phone",xd="Nokia",ga="Ouya",Uh="Generic",Tb=Uh+" "+Ke.toLowerCase(),Bh=Uh+" "+Mi.toLowerCase(),fa="Konqueror",Ne="(\\d+(\\.\\d+)?)",Go=new RegExp("Version/"+Ne),Rb=new RegExp(Fi,"i"),Pb=new RegExp(Cs+" \\w+","i"),Ob=new RegExp(Os+" \\w+","i"),wl=new RegExp(Ui+"|PlayBook|BB10","i"),Cb={"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"},Vh=function(t,e){return e=e||"",z(t," OPR/")&&z(t,"Mini")?Ib:z(t," OPR/")?Sl:wl.test(t)?Ui:z(t,"IE"+Ke)||z(t,"WPDesktop")?Dh:z(t,Ch)?xh:z(t,kl)||z(t,"Edg/")?Lh:z(t,"FBIOS")?"Facebook "+Ke:z(t,"UCWEB")||z(t,"UCBrowser")?"UC Browser":z(t,"CriOS")?Nh:z(t,"CrMo")||z(t,si)?si:z(t,Rt)&&z(t,ws)?Fh:z(t,"FxiOS")?$h:z(t.toLowerCase(),fa.toLowerCase())?fa:((i,s)=>s&&z(s,Rh)||(function(r){return z(r,ws)&&!z(r,si)&&!z(r,Rt)})(i))(t,e)?z(t,Ke)?Mh:ws:z(t,$i)?$i:z(t,"MSIE")||z(t,"Trident/")?El:z(t,"Gecko")?$i:""},xb={[Dh]:[new RegExp("rv:"+Ne)],[Lh]:[new RegExp(kl+"?\\/"+Ne)],[si]:[new RegExp("("+si+"|CrMo)\\/"+Ne)],[Nh]:[new RegExp("CriOS\\/"+Ne)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Ne)],[ws]:[Go],[Mh]:[Go],[Sl]:[new RegExp("(Opera|OPR)\\/"+Ne)],[$i]:[new RegExp($i+"\\/"+Ne)],[$h]:[new RegExp("FxiOS\\/"+Ne)],[fa]:[new RegExp("Konqueror[:/]?"+Ne,"i")],[Ui]:[new RegExp(Ui+" "+Ne),Go],[Fh]:[new RegExp("android\\s"+Ne,"i")],[xh]:[new RegExp(Ch+"\\/"+Ne)],[El]:[new RegExp("(rv:|MSIE )"+Ne)],Mozilla:[new RegExp("rv:"+Ne)]},Nb=function(t,e){var i=Vh(t,e),s=xb[i];if(P(s))return null;for(var r=0;s.length>r;r++){var n=t.match(s[r]);if(n)return parseFloat(n[n.length-2])}return null},Nd=[[new RegExp(Fi+"; "+Fi+" (.*?)[);]","i"),t=>[Fi,t&&t[1]||""]],[new RegExp(Os,"i"),[Os,""]],[new RegExp(Cs,"i"),[Cs,""]],[wl,[Ui,""]],[new RegExp(_s,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[ha,""];if(new RegExp(Ke).test(e)&&!/IEMobile\b/.test(e))return[_s+" "+Ke,""];var i=/Windows NT ([0-9.]+)/i.exec(e);if(i&&i[1]){var s=Cb[i[1]]||"";return/arm/i.test(e)&&(s="RT"),[_s,s]}return[_s,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?[jr,[t[3],t[4],t[5]||"0"].join(".")]:[jr,""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=P(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("("+Rt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Rt+")","i"),t=>t&&t[2]?[Rt,[t[2],t[3],t[4]||"0"].join(".")]:[Rt,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,[Ab,""]],[/Linux|debian/i,["Linux",""]]],Dd=function(t){return Ob.test(t)?Os:Pb.test(t)?Cs:Rb.test(t)?Fi:new RegExp(ga,"i").test(t)?ga:new RegExp("("+ha+"|WPDesktop)","i").test(t)?ha:/iPad/.test(t)?Th:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Ph:wl.test(t)?Ui:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(xd,"i").test(t)?xd:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(Ke).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?Rt:Ih:new RegExp("(pda|"+Ke+")","i").test(t)?Tb:new RegExp(Mi,"i").test(t)&&!new RegExp(Mi+" pc","i").test(t)?Bh:""},Db=t=>t instanceof Error,Gh={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}},Lb=Gh.info;pa=class{constructor(e,i,s){s===void 0&&(s=[]),this.coercers=e,this.stackParser=i,this.modifiers=s}buildFromUnknown(e,i){i===void 0&&(i={});var s=i&&i.mechanism||{handled:!0,type:"generic"},r=this.buildCoercingContext(s,i,0).apply(e),n=this.buildParsingContext(i),o=this.parseStacktrace(r,n);return{$exception_list:this.convertToExceptionList(o,s),$exception_level:"error"}}modifyFrames(e){var i=this;return Qe((function*(){for(var s of e)s.stacktrace&&s.stacktrace.frames&&Y(s.stacktrace.frames)&&(s.stacktrace.frames=yield i.applyModifiers(s.stacktrace.frames));return e}))()}coerceFallback(e){var i;return{type:"Error",value:"Unknown error",stack:(i=e.syntheticException)==null?void 0:i.stack,synthetic:!0}}parseStacktrace(e,i){var s,r;return e.cause!=null&&(s=this.parseStacktrace(e.cause,i)),e.stack!=""&&e.stack!=null&&(r=this.applyChunkIds(this.stackParser(e.stack,e.synthetic?i.skipFirstLines:0),i.chunkIdMap)),S({},e,{cause:s,stack:r})}applyChunkIds(e,i){return e.map((s=>(s.filename&&i&&(s.chunk_id=i[s.filename]),s)))}applyCoercers(e,i){for(var s of this.coercers)if(s.match(e))return s.coerce(e,i);return this.coerceFallback(i)}applyModifiers(e){var i=this;return Qe((function*(){var s=e;for(var r of i.modifiers)s=yield r(s);return s}))()}convertToExceptionList(e,i){var s,r,n,o={type:e.type,value:e.value,mechanism:{type:(s=i.type)!==null&&s!==void 0?s:"generic",handled:(r=i.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,S({},i,{handled:!0}))),a}buildParsingContext(e){var i;return{chunkIdMap:$b(this.stackParser),skipFirstLines:(i=e.skipFirstLines)!==null&&i!==void 0?i:1}}buildCoercingContext(e,i,s){s===void 0&&(s=0);var r=(n,o)=>{if(4>=o){var a=this.buildCoercingContext(e,i,o);return this.applyCoercers(n,a)}};return S({},i,{syntheticException:s==0?i.syntheticException:void 0,mechanism:e,apply:n=>r(n,s),next:n=>r(n,s+1)})}},Bi="?";jh=(t,e)=>{var i=t.indexOf("safari-extension")!==-1,s=t.indexOf("safari-web-extension")!==-1;return i||s?[t.indexOf("@")!==-1?t.split("@")[0]:Bi,i?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},Fb=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,Mb=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,Ub=/\((\S*)(?::(\d+))(?::(\d+))\)/,Bb=(t,e)=>{var i=Fb.exec(t);if(i){var[,s,r,n]=i;return va(e,s,Bi,+r,+n)}var o=Mb.exec(t);if(o){if(o[2]&&o[2].indexOf("eval")===0){var a=Ub.exec(o[2]);a&&(o[2]=a[1],o[3]=a[2],o[4]=a[3])}var[l,u]=jh(o[1]||Bi,o[2]);return va(e,u,l,o[3]?+o[3]:void 0,o[4]?+o[4]:void 0)}},Vb=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,Gb=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,qb=(t,e)=>{var i=Vb.exec(t);if(i){if(i[3]&&i[3].indexOf(" > eval")>-1){var s=Gb.exec(i[3]);s&&(i[1]=i[1]||"eval",i[3]=s[1],i[4]=s[2],i[5]="")}var r=i[3],n=i[1]||Bi;return[n,r]=jh(n,r),va(e,r,n,i[4]?+i[4]:void 0,i[5]?+i[5]:void 0)}},$d=/\(error: (.*)\)/,_a=class{match(e){return this.isDOMException(e)||this.isDOMError(e)}coerce(e,i){var s=ge(e.stack);return{type:this.getType(e),value:this.getValue(e),stack:s?e.stack:void 0,cause:e.cause?i.next(e.cause):void 0,synthetic:!1}}getType(e){return this.isDOMError(e)?"DOMError":"DOMException"}getValue(e){var i=e.name||(this.isDOMError(e)?"DOMError":"DOMException");return e.message?i+": "+e.message:i}isDOMException(e){return qr(e,"DOMException")}isDOMError(e){return qr(e,"DOMError")}},ma=class{match(e){return(i=>i instanceof Error)(e)}coerce(e,i){return{type:this.getType(e),value:this.getMessage(e,i),stack:this.getStack(e),cause:e.cause?i.next(e.cause):void 0,synthetic:!1}}getType(e){return e.name||e.constructor.name}getMessage(e,i){var s=e.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(e){return e.stacktrace||e.stack||void 0}},ya=class{constructor(){}match(e){return qr(e,"ErrorEvent")&&e.error!=null}coerce(e,i){var s;return i.apply(e.error)||{type:"ErrorEvent",value:e.message,stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},jb=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,ba=class{match(e){return typeof e=="string"}coerce(e,i){var s,[r,n]=this.getInfos(e);return{type:r??"Error",value:n??e,stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(e){var i="Error",s=e,r=e.match(jb);return r&&(i=r[1],s=r[2]),[i,s]}},Hb=["fatal","error","warning","log","info","debug"];Ea=class{match(e){return typeof e=="object"&&e!==null}coerce(e,i){var s,r=this.getErrorPropertyFromObject(e);return r?i.apply(r):{type:this.getType(e),value:this.getValue(e),stack:(s=i.syntheticException)==null?void 0:s.stack,level:this.isSeverityLevel(e.level)?e.level:"error",synthetic:!0}}getType(e){return bl(e)?e.constructor.name:"Error"}getValue(e){if("name"in e&&typeof e.name=="string"){var i="'"+e.name+"' captured as exception";return"message"in e&&typeof e.message=="string"&&(i+=" with message: '"+e.message+"'"),i}if("message"in e&&typeof e.message=="string")return e.message;var s=this.getObjectClassName(e);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+Hh(e)}isSeverityLevel(e){return ge(e)&&!Mr(e)&&Hb.indexOf(e)>=0}getErrorPropertyFromObject(e){for(var i in e)if({}.hasOwnProperty.call(e,i)){var s=e[i];if(Db(s))return s}}getObjectClassName(e){try{var i=Object.getPrototypeOf(e);return i?i.constructor.name:void 0}catch{return}}},Sa=class{match(e){return bl(e)}coerce(e,i){var s,r=e.constructor.name;return{type:r,value:r+" captured as exception with keys: "+Hh(e),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},ka=class{match(e){return Ah(e)}coerce(e,i){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(e),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}}},wa=class{match(e){return qr(e,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(e)}isCustomEventWrappingRejection(e){if(!bl(e))return!1;try{var i=e.detail;return i!=null&&typeof i=="object"&&"reason"in i}catch{return!1}}coerce(e,i){var s,r=this.getUnhandledRejectionReason(e);return Ah(r)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(r),stack:(s=i.syntheticException)==null?void 0:s.stack,synthetic:!0}:i.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}},Hr="$message",zr="$timestamp",zb=new Set([Hr,zr]),qo={enabled:!0,max_bytes:32768};Aa=class{constructor(e){this.Yt=[],this.Xt=0,this.qt=Kr(e)}setConfig(e){this.qt=Kr(e),this.er()}add(e){var i=(function(r){var n=(function(c){var h=new WeakSet;try{return JSON.stringify(c,((f,g)=>{if(typeof g=="bigint")return g.toString();if(typeof g!="function"&&typeof g!="symbol"){if(g instanceof Date)return g.toISOString();if(g instanceof Error)return{name:g.name,message:g.message,stack:g.stack};if(g&&typeof g=="object"){if(h.has(g))return"[Circular]";h.add(g)}return g}}))}catch{return}})(r);if(n)try{var o=JSON.parse(n);if(!ve(o))return;var a=o,l=a[Hr],u=a[zr];return!ge(l)||l.trim().length===0||!ge(u)&&!et(u)?void 0:{step:a,json:n}}catch{return}})(e);if(i){var s=(function(r){if(typeof TextEncoder<"u")return new TextEncoder().encode(r).length;for(var n=encodeURIComponent(r),o=0,a=0;n.length>a;a++)n[a]==="%"?(o+=1,a+=2):o+=1;return o})(i.json);s>this.qt.max_bytes||(this.Yt.push({step:i.step,bytes:s}),this.Xt+=s,this.er())}}getAttachable(){return this.Yt.map((e=>e.step))}clear(){this.Yt=[],this.Xt=0}size(){return this.Yt.length}er(){for(;this.Xt>this.qt.max_bytes&&this.Yt.length>0;){var e=this.Yt.shift();e&&(this.Xt-=e.bytes)}}};zh=function(t,e){var{debugEnabled:i}=e===void 0?{}:e,s={k(r){if(_&&(De.DEBUG||L.POSTHOG_DEBUG||i)&&!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(t,...a)}},debug(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("debug",...n)},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];s.k("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(t,...n)},uninitializedWarning(r){s.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>zh(t+" "+r,n)};return s},T=zh("[PostHog.js]"),ue=T.createLogger,Wb=ue("[ExternalScriptsLoader]"),jo=(t,e,i)=>{if(t.config.disable_external_dependency_loading)return Wb.warn(e+" was requested but loading of external scripts is disabled."),i("Loading of external scripts is disabled");var s=I?.querySelectorAll("script");if(s){for(var r,n=function(){if(s[o].src===e){var l=s[o];return l.__posthog_loading_callback_fired?{v:i()}:(l.addEventListener("load",(u=>{l.__posthog_loading_callback_fired=!0,i(void 0,u)})),l.onerror=u=>i(u),{v:void 0})}},o=0;s.length>o;o++)if(r=n())return r.v}var a=()=>{if(!I)return i("document not found");var l=I.createElement("script");if(l.type="text/javascript",l.crossOrigin="anonymous",l.src=e,l.onload=h=>{l.__posthog_loading_callback_fired=!0,i(void 0,h)},l.onerror=h=>i(h),t.config.prepare_external_dependency_script&&(l=t.config.prepare_external_dependency_script(l)),!l)return i("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")I.head.appendChild(l);else{var u,c=I.querySelectorAll("body > script");c.length>0?(u=c[0].parentNode)==null||u.insertBefore(l,c[0]):I.body.appendChild(l)}};I!=null&&I.body?a():I?.addEventListener("DOMContentLoaded",a)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(t,e,i)=>{if(e!=="remote-config"){var s;if(t.config.__preview_external_dependency_versioned_paths)s=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js");else{var r="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var n=3e5;r=r+"&t="+Math.floor(Date.now()/n)*n}s=t.requestRouter.endpointFor("assets",r)}jo(t,s,i)}else{var o=t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js");jo(t,o,i)}},L.__PosthogExtensions__.loadSiteApp=(t,e,i)=>{var s=t.requestRouter.endpointFor("api",e);jo(t,s,i)};Kh="$people_distinct_id",Wr="$device_id",ms="__alias",ys="__timers",Ia="$autocapture_disabled_server_side",Ta="$heatmaps_enabled_server_side",Ra="$exception_capture_enabled_server_side",Pa="$error_tracking_suppression_rules",Oa="$error_tracking_capture_extension_exceptions",Ca="$web_vitals_enabled_server_side",Al="$dead_clicks_enabled_server_side",xa="$product_tours_enabled_server_side",Na="$web_vitals_allowed_metrics",bs="$session_recording_remote_config",Wh="$replay_override_sampling",Yh="$replay_override_linked_flag",Xh="$replay_override_url_trigger",Jh="$replay_override_event_trigger",Yr="$sesid",Il="$session_is_sampled",Di="$enabled_feature_flags",Ur="$active_feature_flags",Es="$early_access_features",Da="$feature_flag_details",La="$feature_flag_payloads",$a="$feature_flag_request_id",At="$override_feature_flags",Oi="$override_feature_flag_payloads",Ss="$stored_person_properties",ti="$stored_group_properties",Fa="$surveys",Ma="$surveys_activated",Br="ph_product_tours",As="$flag_call_reported",Ua="$flag_call_reported_session_id",Ba="$feature_flag_errors",Xr="$feature_flag_evaluated_at",rt="$user_state",Va="$client_session_props",Ga="$capture_rate_limit",qa="$initial_campaign_params",ja="$initial_referrer_info",Jr="$initial_person_info",Qr="$epp",Qh="__POSTHOG_TOOLBAR__",Cr="$posthog_cookieless",Zh="$sdk_debug_extensions_init_method",eg="$sdk_debug_extensions_init_time_ms",tg="$sdk_debug_recording_script_not_loaded",Tl="PostHog loadExternalDependency extension not found.",ii="on_reject",Tt="always",Ai="anonymous",Ii="identified",Ha="identified_only",Zr="visibilitychange",en="beforeunload",Ci="$pageview",Ho="$pageleave",zo="$identify",Fd="$groupidentify";pe=function(t){for(var e=arguments.length,i=new Array(e>1?e-1:0),s=1;e>s;s++)i[s-1]=arguments[s];for(var r of i)for(var n in r)r[n]!==void 0&&(t[n]=r[n]);return t};Md=function(t){try{return t()}catch{return}},Yb=function(t){return function(){try{for(var e=arguments.length,i=new Array(e),s=0;e>s;s++)i[s]=arguments[s];return t.apply(this,i)}catch(r){T.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),T.critical(r)}}},Rl=function(t){var e={};return oe(t,(function(i,s){(ge(i)&&i.length>0||et(i))&&(e[s]=i)})),e},Xb=["herokuapp.com","vercel.app","netlify.app"];Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return et(t)&&isFinite(t)&&Math.floor(t)===t});za=class t{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,i,s,r){if(!Number.isInteger(e)||!Number.isInteger(i)||!Number.isInteger(s)||!Number.isInteger(r)||0>e||0>i||0>s||0>r||e>0xffffffffffff||i>4095||s>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|i>>>8,n[7]=i,n[8]=128|s>>>24,n[9]=s>>>16,n[10]=s>>>8,n[11]=s,n[12]=r>>>24,n[13]=r>>>16,n[14]=r>>>8,n[15]=r,new t(n)}toString(){for(var e="",i=0;this.bytes.length>i;i++)e=e+(this.bytes[i]>>>4).toString(16)+(15&this.bytes[i]).toString(16),i!==3&&i!==5&&i!==7&&i!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new t(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var i=0;16>i;i++){var s=this.bytes[i]-e.bytes[i];if(s!==0)return Math.sign(s)}return 0}},Ka=class{constructor(){this.S=0,this.C=0,this.I=new Wa}generate(){var e=this.generateOrAbort();if(P(e)){this.S=0;var i=this.generateOrAbort();if(P(i))throw new Error("Could not generate UUID after timestamp reset");return i}return e}generateOrAbort(){var e=Date.now();if(e>this.S)this.S=e,this.T();else{if(this.S>=e+1e4)return;this.C++,this.C>4398046511103&&(this.S++,this.T())}return za.fromFieldsV7(this.S,Math.trunc(this.C/Math.pow(2,30)),this.C&Math.pow(2,30)-1,this.I.nextUint32())}T(){this.C=1024*this.I.nextUint32()+(1023&this.I.nextUint32())}},sg=t=>{if(typeof UUIDV7_DENY_WEAK_RNG<"u"&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};_&&!P(_.crypto)&&crypto.getRandomValues&&(sg=t=>crypto.getRandomValues(t));Wa=class{constructor(){this.M=new Uint32Array(8),this.O=1/0}nextUint32(){return this.M.length>this.O||(sg(this.M),this.O=0),this.M[this.O++]}},Bt=()=>Qb().toString(),Qb=()=>(Ud||(Ud=new Ka)).generate(),us="",Zb=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,dt={R:()=>!!I,D(t){T.error("cookieStore error: "+t)},A(t){if(I){try{for(var e=t+"=",i=I.cookie.split(";").filter((n=>n.length)),s=0;i.length>s;s++){for(var r=i[s];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}},F(t){var e;try{e=JSON.parse(dt.A(t))||{}}catch{}return e},N(t,e,i,s,r){if(I)try{var n="",o="",a=(function(c,h){if(h){var f=(function(p,v){if(v===void 0&&(v=I),us)return us;if(!v||["localhost","127.0.0.1"].includes(p))return"";for(var m=p.split("."),y=Math.min(m.length,8),w="dmn_chk_"+Bt();!us&&y--;){var R=m.slice(y).join("."),N=w+"=1;domain=."+R+";path=/";v.cookie=N+";max-age=3",v.cookie.includes(w)&&(v.cookie=N+";max-age=0",us=R)}return us})(c);if(!f){var g=(p=>{var v=p.match(Zb);return v?v[0]:""})(c);g!==f&&T.info("Warning: cookie subdomain discovery mismatch",g,f),f=g}return f?"; domain=."+f:""}return""})(I.location.hostname,s);if(i){var l=new Date;l.setTime(l.getTime()+864e5*i),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&T.warn("cookieStore warning: large cookie, len="+u.length),I.cookie=u,u}catch{return}},q(t,e){if(I!=null&&I.cookie)try{dt.N(t,"",-1,e)}catch{return}}},Ko=null,he={R(){if(!Pt(Ko))return Ko;var t=!0;if(P(_))t=!1;else try{var e="__mplssupport__";he.N(e,"xyz"),he.A(e)!=='"xyz"'&&(t=!1),he.q(e)}catch{t=!1}return t||T.error("localStorage unsupported; falling back to cookie store"),Ko=t,t},D(t){T.error("localStorage error: "+t)},A(t){try{return _?.localStorage.getItem(t)}catch(e){he.D(e)}return null},F(t){try{return JSON.parse(he.A(t))||{}}catch{}return null},N(t,e){try{_?.localStorage.setItem(t,JSON.stringify(e))}catch(i){he.D(i)}},q(t){try{_?.localStorage.removeItem(t)}catch(e){he.D(e)}}},eE=[Wr,"distinct_id",Yr,Il,Qr,Jr,rt],Nr={},tE={R:()=>!0,D(t){T.error("memoryStorage error: "+t)},A:t=>Nr[t]||null,F:t=>Nr[t]||null,N(t,e){Nr[t]=e},q(t){delete Nr[t]}},Jt=null,Re={R(){if(!Pt(Jt))return Jt;if(Jt=!0,P(_))Jt=!1;else try{var t="__support__";Re.N(t,"xyz"),Re.A(t)!=='"xyz"'&&(Jt=!1),Re.q(t)}catch{Jt=!1}return Jt},D(t){T.error("sessionStorage error: ",t)},A(t){try{return _?.sessionStorage.getItem(t)}catch(e){Re.D(e)}return null},F(t){try{return JSON.parse(Re.A(t))||null}catch{}return null},N(t,e){try{_?.sessionStorage.setItem(t,JSON.stringify(e))}catch(i){Re.D(i)}},q(t){try{_?.sessionStorage.removeItem(t)}catch(e){Re.D(e)}}},Ya=class{constructor(e){this._instance=e}get qt(){return this._instance.config}get consent(){return this.rr()?0:this.ir}isOptedOut(){return this.qt.cookieless_mode===Tt||this.isRejected()||this.consent===-1&&this.qt.cookieless_mode===ii}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.qt.opt_out_capturing_by_default}optInOut(e){this.nr.N(this.sr,e?1:0,this.qt.cookie_expiration,this.qt.cross_subdomain_cookie,this.qt.secure_cookie)}reset(){this.nr.q(this.sr,this.qt.cross_subdomain_cookie)}get sr(){var{token:e,opt_out_capturing_cookie_prefix:i,consent_persistence_name:s}=this._instance.config;return s||(i?i+e:"__ph_opt_in_out_"+e)}get ir(){var e=this.nr.A(this.sr);return Bo(e)?1:z(wb,e)?0:-1}get nr(){var e=this.qt.opt_out_capturing_persistence_type,i=e==="localStorage"?he:dt;if(!this.ar||this.ar!==i){this.ar=i;var s=e==="localStorage"?dt:he;s.A(this.sr)&&(this.ar.A(this.sr)||this.optInOut(Bo(s.A(this.sr))),s.q(this.sr,this.qt.cross_subdomain_cookie))}return this.ar}rr(){return!!this.qt.respect_dnt&&[ze?.doNotTrack,ze?.msDoNotTrack,L.doNotTrack].some((e=>Bo(e)))}},Dr=ue("[Dead Clicks]"),iE=()=>!0,sE=t=>{var e,i=!((e=t.instance.persistence)==null||!e.get_property(Al)),s=t.instance.config.capture_dead_clicks;return ht(s)?s:!!ve(s)||i},tn=class{get lazyLoadedDeadClicksAutocapture(){return this.ur}constructor(e,i,s){this.instance=e,this.isEnabled=i,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(e){"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[Al]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.lr((()=>{this.hr()})):this.stop()}lr(e){var i,s;(i=L.__PosthogExtensions__)!=null&&i.initDeadClicksAutocapture&&e(),(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",(r=>{r?Dr.error("failed to load script",r):e()}))}hr(){var e;if(I){if(!this.ur&&(e=L.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture){var i=ve(this.instance.config.capture_dead_clicks)?this.instance.config.capture_dead_clicks:{};i.__onCapture=this.onCapture,this.ur=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,i),this.ur.start(I),Dr.info("starting...")}}else Dr.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,Dr.info("stopping..."))}},Wo=ue("[SegmentIntegration]"),rg="posthog-js";Xa=class{constructor(e,i,s,r,n,o){this.name=rg,this.setupOnce=function(a){a(ng(e,{organization:i,projectId:s,prefix:r,severityAllowList:n,sendExceptionsToPostHog:o==null||o}))}}},sn=class{constructor(e){this.cr=(i,s,r)=>{r&&(r.noSessionId||r.activityTimeout||r.sessionPastMaximumLength)&&(T.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:i,changeReason:r}),this.dr=void 0,this._instance.scrollManager.resetContext())},this._instance=e,this.vr()}vr(){var e;this.pr=(e=this._instance.sessionManager)==null?void 0:e.onSessionId(this.cr)}destroy(){var e;(e=this.pr)==null||e.call(this),this.pr=void 0}doPageView(e,i){var s,r=this.gr(e,i);return this.dr={pathname:(s=_?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:i,timestamp:e},this._instance.scrollManager.resetContext(),r}doPageLeave(e){var i;return this.gr(e,(i=this.dr)==null?void 0:i.pageViewId)}doEvent(){var e;return{$pageview_id:(e=this.dr)==null?void 0:e.pageViewId}}gr(e,i){var s=this.dr;if(!s)return{$pageview_id:i};var r={$pageview_id:i,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){var{maxScrollHeight:o,lastScrollY:a,maxScrollY:l,maxContentHeight:u,lastContentY:c,maxContentY:h}=n;if(!(P(o)||P(a)||P(l)||P(u)||P(c)||P(h))){o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c),h=Math.ceil(h);var f=o>1?gt(a/o,0,1,T):1,g=o>1?gt(l/o,0,1,T):1,p=u>1?gt(c/u,0,1,T):1,v=u>1?gt(h/u,0,1,T):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:c,$prev_pageview_last_content_percentage:p,$prev_pageview_max_content:h,$prev_pageview_max_content_percentage:v})}}return s.pathname&&(r.$prev_pageview_pathname=s.pathname),s.timestamp&&(r.$prev_pageview_duration=(e.getTime()-s.timestamp.getTime())/1e3),r}},rE={[Kh]:{exposure:"hidden"},[ms]:{exposure:"hidden"},__cmpns:{exposure:"hidden"},[ys]:{exposure:"hidden"},[Ia]:{exposure:"event"},[Ta]:{exposure:"hidden"},[Ra]:{exposure:"event"},[Pa]:{exposure:"hidden"},[Oa]:{exposure:"event"},[Ca]:{exposure:"event"},[Al]:{exposure:"event"},[xa]:{exposure:"hidden"},[Na]:{exposure:"event"},[bs]:{exposure:"hidden"},$session_recording_enabled_server_side:{exposure:"hidden"},[Yr]:{exposure:"hidden"},[Il]:{exposure:"event"},$session_past_minimum_duration:{exposure:"event"},$session_recording_url_trigger_activated_session:{exposure:"event"},$session_recording_event_trigger_activated_session:{exposure:"event"},$debug_first_full_snapshot_timestamp:{exposure:"event"},[Di]:{exposure:"derived",shouldSkipFromEventProperties:(t,e)=>e(),transformToEventProperties(t){if(!ve(t))return{};for(var e={},i=Object.keys(t),s=0;i.length>s;s++)e["$feature/"+i[s]]=t[i[s]];return e}},[Ur]:{exposure:"event"},[Es]:{exposure:"hidden"},[Da]:{exposure:"hidden"},[La]:{exposure:"event"},[$a]:{exposure:"event"},[At]:{exposure:"event"},[Oi]:{exposure:"hidden"},[Ss]:{exposure:"hidden"},[ti]:{exposure:"hidden"},[Fa]:{exposure:"hidden"},[Ma]:{exposure:"event"},[Br]:{exposure:"hidden"},$product_tours_activated:{exposure:"hidden"},$conversations_widget_session_id:{exposure:"event"},$conversations_ticket_id:{exposure:"event"},$conversations_widget_state:{exposure:"event"},$conversations_user_traits:{exposure:"event"},[As]:{exposure:"hidden"},[Ua]:{exposure:"hidden"},[Ba]:{exposure:"hidden"},[Xr]:{exposure:"hidden"},[rt]:{exposure:"hidden"},[Va]:{exposure:"hidden"},[Ga]:{exposure:"hidden"},[qa]:{exposure:"hidden"},[ja]:{exposure:"hidden"},[Jr]:{exposure:"hidden"},[Qr]:{exposure:"hidden"},[Wh]:{exposure:"event"},[Yh]:{exposure:"event"},[Xh]:{exposure:"event"},[Jh]:{exposure:"event"},[Zh]:{exposure:"event"},[eg]:{exposure:"event"},[tg]:{exposure:"event"},$sdk_debug_replay_event_trigger_status:{exposure:"event"},$sdk_debug_replay_linked_flag_trigger_status:{exposure:"event"},$sdk_debug_replay_matched_recording_trigger_groups:{exposure:"event"},$sdk_debug_replay_remote_trigger_matching_config:{exposure:"event"},$sdk_debug_replay_trigger_groups_count:{exposure:"event"},$sdk_debug_replay_url_trigger_status:{exposure:"event"},$session_recording_start_reason:{exposure:"event"}},nE=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],rn=t=>{var e=I?.createElement("a");return P(e)?null:(e.href=t,e)},nn=function(t,e){for(var i,s=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;s.length>r;r++){var n=s[r].split("=");if(n[0]===e){i=n;break}}if(!Y(i)||2>i.length)return"";var o=i[1];try{o=decodeURIComponent(o)}catch{T.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},xs=function(t,e,i){if(!t||!e||!e.length)return t;for(var s=t.split("#"),r=s[1],n=(s[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var h=l[c].split("=");Y(h)&&(e.includes(h[0])?u.push(h[0]+"="+i):u.push(l[c]))}var f=a;return o!=null&&(f+="?"+u.join("&")),r!=null&&(f+="#"+r),f},on=function(t,e){var i=t.match(new RegExp(e+"=([^&]*)"));return i?i[1]:null},Lr="https?://(.*)",Vi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],oE=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...Vi],Ns="<masked>",aE=["li_fat_id"];an="$direct";uE=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Is=class{constructor(e,i){this.qt=e,this.props={},this.mr=!1,this.yr=(s=>{var r="";return s.token&&(r=s.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),s.persistence_name?"ph_"+s.persistence_name:"ph_"+r+"_posthog"})(e),this.nr=this.br(e),this.load(),e.debug&&T.info("Persistence loaded",e.persistence,S({},this.props)),this.update_config(e,e,i),this.save()}isDisabled(){return!!this._r}br(e){uE.indexOf(e.persistence.toLowerCase())===-1&&(T.critical("Unknown persistence type "+e.persistence+"; falling back to localStorage+cookie"),e.persistence="localStorage+cookie");var i=(function(r){r===void 0&&(r=[]);var n=[...eE,...r];return S({},he,{F(o){try{var a={};try{a=dt.F(o)||{}}catch{}var l=pe(a,JSON.parse(he.A(o)||"{}"));return he.N(o,l),l}catch{}return null},N(o,a,l,u,c,h){try{he.N(o,a,void 0,void 0,h);var f={};n.forEach((g=>{a[g]&&(f[g]=a[g])})),Object.keys(f).length&&dt.N(o,f,l,u,c,h)}catch(g){he.D(g)}},q(o,a){try{_?.localStorage.removeItem(o),dt.q(o,a)}catch(l){he.D(l)}}})})(e.cookie_persisted_properties||[]),s=e.persistence.toLowerCase();return s==="localstorage"&&he.R()?he:s==="localstorage+cookie"&&i.R()?i:s==="sessionstorage"&&Re.R()?Re:s==="memory"?tE:s==="cookie"?dt:i.R()?i:dt}wr(e){var i=e??this.qt.feature_flag_cache_ttl_ms;if(!i||0>=i)return!1;var s=this.props[Xr];return!s||typeof s!="number"||Date.now()-s>i}properties(){var e={};return oe(this.props,((i,s)=>{var r=(n=>{var o=rE[n];if(o)return o;for(var[a,l]of nE)if(n.indexOf(a)===0)return l})(s);if(r?.exposure==="derived"){if(r.shouldSkipFromEventProperties!=null&&r.shouldSkipFromEventProperties(i,s===Di?()=>this.wr():()=>!1))return;r.transformToEventProperties&&pe(e,r.transformToEventProperties(i))}else r&&r.exposure!=="event"||(e[s]=i)})),e}load(){if(!this._r){var e=this.nr.F(this.yr);e&&(this.props=pe({},e))}}save(){this._r||this.nr.N(this.yr,this.props,this.Sr,this.kr,this.Cr,this.qt.debug)}remove(){this.nr.q(this.yr,!1),this.nr.q(this.yr,!0)}clear(){this.remove(),this.props={}}register_once(e,i,s){if(ve(e)){P(i)&&(i="None"),this.Sr=P(s)?this.Ir:s;var r=!1;if(oe(e,((n,o)=>{this.props.hasOwnProperty(o)&&this.props[o]!==i||(this.Tr(o,n),r=!0)})),r)return this.save(),!0}return!1}register(e,i){if(ve(e)){this.Sr=P(i)?this.Ir:i;var s=!1;if(oe(e,((r,n)=>{e.hasOwnProperty(n)&&this.props[n]!==r&&(this.Tr(n,r),s=!0)})),s)return this.save(),!0}return!1}unregister(e){e in this.props&&(this.Er(e),this.save())}update_campaign_params(){if(!this.mr){var e=og(this.qt.custom_campaign_params,this.qt.mask_personal_data_properties,this.qt.custom_personal_data_properties);Ni(Rl(e))||this.register(e),this.mr=!0}}update_search_keyword(){var e;this.register((e=I?.referrer)?lg(e):{})}update_referrer_info(){var e;this.register_once({$referrer:ug(),$referring_domain:I!=null&&I.referrer&&((e=rn(I.referrer))==null?void 0:e.host)||an},void 0)}set_initial_person_info(){this.props[qa]||this.props[ja]||this.register_once({[Jr]:cg(this.qt.mask_personal_data_properties,this.qt.custom_personal_data_properties)},void 0)}get_initial_props(){var e={};oe([ja,qa],(o=>{var a=this.props[o];a&&oe(a,(function(l,u){e["$initial_"+ca(u)]=l}))}));var i,s,r=this.props[Jr];if(r){var n=(i=dg(r),s={},oe(i,(function(o,a){s["$initial_"+ca(a)]=o})),s);pe(e,n)}return e}safe_merge(e){return oe(this.props,(function(i,s){s in e||(e[s]=i)})),e}update_config(e,i,s){if(this.Ir=this.Sr=e.cookie_expiration,this.set_disabled(e.disable_persistence||!!s),this.set_cross_subdomain(e.cross_subdomain_cookie),this.set_secure(e.secure_cookie),e.persistence!==i.persistence||!((o,a)=>{if(o.length!==a.length)return!1;var l=[...o].sort(),u=[...a].sort();return l.every(((c,h)=>c===u[h]))})(e.cookie_persisted_properties||[],i.cookie_persisted_properties||[])){var r=this.br(e),n=this.props;this.clear(),this.nr=r,this.props=n,this.save()}}set_disabled(e){this._r=e,this._r?this.remove():this.save()}set_cross_subdomain(e){e!==this.kr&&(this.kr=e,this.remove(),this.save())}set_secure(e){e!==this.Cr&&(this.Cr=e,this.remove(),this.save())}set_event_timer(e,i){var s=this.props[ys]||{};s[e]=i,this.Tr(ys,s),this.save()}remove_event_timer(e){var i=this.props[ys]||{},s=i[e];return P(s)||(delete i[e],this.Tr(ys,i),this.save()),s}get_property(e){return this.props[e]}set_property(e,i){this.Tr(e,i),this.save()}Tr(e,i){this.props[e]=i}Er(e){delete this.props[e]}},cs={Activation:"events",Cancellation:"cancelEvents"},Yo={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},ks={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},Xo={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",SURVEY_LANGUAGE:"$survey_language"},Ja={Popover:"popover",Inline:"inline"},cE={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"},Vd={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"},Gd=ue("[RateLimiter]"),Qa=class{constructor(e){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=i=>{var s=i.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach((r=>{Gd.info((r||"events")+" is quota limited."),this.serverLimits[r]=new Date().getTime()+6e4}))}catch(r){return void Gd.warn('could not rate limit - continuing. Error: "'+r?.message+'"',{text:s})}},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 i,s,r;e===void 0&&(e=!1);var{captureEventsBurstLimit:n,captureEventsPerSecond:o}=this,a=new Date().getTime(),l=(i=(s=this.instance.persistence)==null?void 0:s.get_property(Ga))!==null&&i!==void 0?i:{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(Ga,l),{isRateLimited:u,remainingTokens:l.tokens}}isServerRateLimited(e){var i=this.serverLimits[e||"events"]||!1;return i!==!1&&new Date().getTime()<i}},ds=ue("[RemoteConfig]"),ln=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}Mr(e){var i,s;(i=L.__PosthogExtensions__)!=null&&i.loadExternalDependency?(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",(()=>e(this.remoteConfig))):e()}Pr(e){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback(i){e(i.json)}})}load(){try{if(this.remoteConfig)return ds.info("Using preloaded remote config",this.remoteConfig),this.Rr(this.remoteConfig),void this.Or();if(this._instance.Lr())return void ds.warn("Remote config is disabled. Falling back to local config.");this.Mr((e=>{if(!e)return ds.info("No config found after loading remote JS config. Falling back to JSON."),void this.Pr((i=>{this.Rr(i),this.Or()}));this.Rr(e),this.Or()}))}catch(e){ds.error("Error loading remote config",e)}}stop(){this.Fr&&(clearInterval(this.Fr),this.Fr=void 0)}refresh(){this._instance.Lr()||I?.visibilityState==="hidden"||this._instance.reloadFeatureFlags()}Or(){var e;if(!this.Fr){var i=(e=this._instance.config.remote_config_refresh_interval_ms)!==null&&e!==void 0?e:3e5;i!==0&&(this.Fr=setInterval((()=>{this.refresh()}),i))}}Rr(e){var i;e||ds.error("Failed to fetch remote config from PostHog."),this._instance.Rr(e??{}),e?.hasFeatureFlags!==!1&&(this._instance.config.advanced_disable_feature_flags_on_first_load||(i=this._instance.featureFlags)==null||i.ensureFlagsLoaded())}},ct={GZipJS:"gzip-js",Base64:"base64"},Ze=Uint8Array,Le=Uint16Array,Gi=Uint32Array,Pl=new Ze([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]),Ol=new Ze([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]),qd=new Ze([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),gg=function(t,e){for(var i=new Le(31),s=0;31>s;++s)i[s]=e+=1<<t[s-1];var r=new Gi(i[30]);for(s=1;30>s;++s)for(var n=i[s];i[s+1]>n;++n)r[n]=n-i[s]<<5|s;return[i,r]},fg=gg(Pl,2),Za=fg[1];fg[0][28]=258,Za[258]=28;for(el=gg(Ol,0)[1],un=new Le(32768),ie=0;32768>ie;++ie)Qt=(43690&ie)>>>1|(21845&ie)<<1,un[ie]=((65280&(Qt=(61680&(Qt=(52428&Qt)>>>2|(13107&Qt)<<2))>>>4|(3855&Qt)<<4))>>>8|(255&Qt)<<8)>>>1;Ts=function(t,e,i){for(var s=t.length,r=0,n=new Le(e);s>r;++r)++n[t[r]-1];var o,a=new Le(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Le(1<<e);var l=15-e;for(r=0;s>r;++r)if(t[r])for(var u=r<<4|t[r],c=e-t[r],h=a[t[r]-1]++<<c,f=h|(1<<c)-1;f>=h;++h)o[un[h]>>>l]=u}else for(o=new Le(s),r=0;s>r;++r)o[r]=un[a[t[r]-1]++]>>>15-t[r];return o},ni=new Ze(288);for(ie=0;144>ie;++ie)ni[ie]=8;for(ie=144;256>ie;++ie)ni[ie]=9;for(ie=256;280>ie;++ie)ni[ie]=7;for(ie=280;288>ie;++ie)ni[ie]=8;cn=new Ze(32);for(ie=0;32>ie;++ie)cn[ie]=5;dE=Ts(ni,9,0),hE=Ts(cn,5,0),pg=function(t){return(t/8>>0)+(7&t&&1)},vg=function(t,e,i){(i==null||i>t.length)&&(i=t.length);var s=new(t instanceof Le?Le:t instanceof Gi?Gi:Ze)(i-e);return s.set(t.subarray(e,i)),s},kt=function(t,e,i){var s=e/8>>0;t[s]|=i<<=7&e,t[s+1]|=i>>>8},hs=function(t,e,i){var s=e/8>>0;t[s]|=i<<=7&e,t[s+1]|=i>>>8,t[s+2]|=i>>>16},Jo=function(t,e){for(var i=[],s=0;t.length>s;++s)t[s]&&i.push({s,f:t[s]});var r=i.length,n=i.slice();if(!r)return[new Ze(0),0];if(r==1){var o=new Ze(i[0].s+1);return o[i[0].s]=1,[o,1]}i.sort((function(b,x){return b.f-x.f})),i.push({s:-1,f:25001});var a=i[0],l=i[1],u=0,c=1,h=2;for(i[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=i[i[h].f>i[u].f?u++:h++],l=i[u!=c&&i[h].f>i[u].f?u++:h++],i[c++]={s:-1,f:a.f+l.f,l:a,r:l};var f=n[0].s;for(s=1;r>s;++s)n[s].s>f&&(f=n[s].s);var g=new Le(f+1),p=tl(i[c-1],g,0);if(p>e){s=0;var v=0,m=p-e,y=1<<m;for(n.sort((function(b,x){return g[x.s]-g[b.s]||b.f-x.f}));r>s;++s){var w=n[s].s;if(e>=g[w])break;v+=y-(1<<p-g[w]),g[w]=e}for(v>>>=m;v>0;){var R=n[s].s;e>g[R]?v-=1<<e-g[R]++-1:++s}for(;s>=0&&v;--s){var N=n[s].s;g[N]==e&&(--g[N],++v)}p=e}return[new Ze(g),p]},tl=function(t,e,i){return t.s==-1?Math.max(tl(t.l,e,i+1),tl(t.r,e,i+1)):e[t.s]=i},jd=function(t){for(var e=t.length;e&&!t[--e];);for(var i=new Le(++e),s=0,r=t[0],n=1,o=function(l){i[s++]=l},a=1;e>=a;++a)if(t[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=t[a]}return[i.subarray(0,s),e]},gs=function(t,e){for(var i=0,s=0;e.length>s;++s)i+=t[s]*e[s];return i},il=function(t,e,i){var s=i.length,r=pg(e+2);t[r]=255&s,t[r+1]=s>>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var n=0;s>n;++n)t[r+n+4]=i[n];return 8*(r+4+s)},Hd=function(t,e,i,s,r,n,o,a,l,u,c){kt(e,c++,i),++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=jd(f),w=y[0],R=y[1],N=jd(v),b=N[0],x=N[1],C=new Le(19),O=0;w.length>O;++O)C[31&w[O]]++;for(O=0;b.length>O;++O)C[31&b[O]]++;for(var A=Jo(C,7),$=A[0],U=A[1],H=19;H>4&&!$[qd[H-1]];--H);var G,q,_e,Ee,$e=u+5<<3,Se=gs(r,ni)+gs(n,cn)+o,k=gs(r,f)+gs(n,v)+o+14+3*H+gs(C,$)+(2*C[16]+3*C[17]+7*C[18]);if(Se>=$e&&k>=$e)return il(e,c,t.subarray(l,l+u));if(kt(e,c,1+(Se>k)),c+=2,Se>k){G=Ts(f,g,0),q=f,_e=Ts(v,m,0),Ee=v;var M=Ts($,U,0);for(kt(e,c,R-257),kt(e,c+5,x-1),kt(e,c+10,H-4),c+=14,O=0;H>O;++O)kt(e,c+3*O,$[qd[O]]);c+=3*H;for(var F=[w,b],B=0;2>B;++B){var Z=F[B];for(O=0;Z.length>O;++O)kt(e,c,M[ce=31&Z[O]]),c+=$[ce],ce>15&&(kt(e,c,Z[O]>>>5&127),c+=Z[O]>>>12)}}else G=dE,q=ni,_e=hE,Ee=cn;for(O=0;a>O;++O)if(s[O]>255){var ce;hs(e,c,G[257+(ce=s[O]>>>18&31)]),c+=q[ce+257],ce>7&&(kt(e,c,s[O]>>>23&31),c+=Pl[ce]);var se=31&s[O];hs(e,c,_e[se]),c+=Ee[se],se>3&&(hs(e,c,s[O]>>>5&8191),c+=Ol[se])}else hs(e,c,G[s[O]]),c+=q[s[O]];return hs(e,c,G[256]),c+q[256]},gE=new Gi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),fE=(function(){for(var t=new Gi(256),e=0;256>e;++e){for(var i=e,s=9;--s;)i=(1&i&&3988292384)^i>>>1;t[e]=i}return t})(),Qo=function(t,e,i){for(;i;++e)t[e]=i,i>>>=8};vE=!!la||!!aa,_g="text/plain",zd=!1,mn=function(t,e,i){var s;i===void 0&&(i=!0);var[r,n]=t.split("?"),o=S({},e),a=(s=n?.split("&").map((u=>{var c,[h,f]=u.split("="),g=i&&(c=o[h])!==null&&c!==void 0?c:f;return delete o[h],h+"="+g})))!==null&&s!==void 0?s:[],l=(function(u,c){var h,f;c===void 0&&(c="&");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(c)})(o);return l&&a.push(l),r+"?"+a.join("&")},Li=(t,e)=>JSON.stringify(t,((i,s)=>typeof s=="bigint"?s.toString():s),e),Zo=t=>{if(t.tr)return t.tr;var{data:e,compression:i}=t;if(e){if(i===ct.GZipJS){var s=pE((function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var c=new Ze(a.length+(a.length>>>1)),h=0,f=function(m){c[h++]=m},g=0;u>g;++g){if(h+5>c.length){var p=new Ze(h+8+(u-g<<1));p.set(c),c=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 vg(c,0,h)})(Li(e)),{mtime:0});return{contentType:_g,body:s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength),estimatedSize:s.byteLength}}if(i===ct.Base64){var r=(function(a){return a&&btoa(encodeURIComponent(a).replace(/%([0-9A-F]{2})/g,((l,u)=>String.fromCharCode(parseInt(u,16)))))})(Li(e)),n=(a=>"data="+encodeURIComponent(typeof a=="string"?a:Li(a)))(r);return{contentType:"application/x-www-form-urlencoded",body:n,estimatedSize:new Blob([n]).size}}var o=Li(e);return{contentType:"application/json",body:o,estimatedSize:new Blob([o]).size}}},_E=(function(){var t=Qe((function*(e){var i=Li(e.data),s=yield(function(n,o,a){return ua.apply(this,arguments)})(i,De.DEBUG,{rethrow:!0});if(!s)return e;var r=yield s.arrayBuffer();return S({},e,{tr:{contentType:_g,body:r,estimatedSize:r.byteLength}})}));return function(e){return t.apply(this,arguments)}})(),Kd=(t,e)=>mn(t,{_:new Date().getTime().toString(),ver:De.JS_SDK_VERSION,compression:e}),Gr=[];aa&&Gr.push({transport:"fetch",method(t){var e,i,{contentType:s,body:r,estimatedSize:n}=(e=Zo(t))!==null&&e!==void 0?e:{},o=new Headers;oe(t.headers,(function(c,h){o.append(h,c)})),s&&o.append("Content-Type",s);var a=t.url,l=null;if(Td){var u=new Td;l={signal:u.signal,timeout:setTimeout((()=>u.abort()),t.timeout)}}aa(a,S({method:t?.method||"GET",headers:o,keepalive:t.method==="POST"&&52428.8>(n||0),body:r,signal:(i=l)==null?void 0:i.signal},t.fetchOptions)).then((c=>c.text().then((h=>{var f={statusCode:c.status,text:h};if(c.status===200)try{f.json=JSON.parse(h)}catch(g){T.error(g)}t.callback==null||t.callback(f)})))).catch((c=>{T.error(c),t.callback==null||t.callback({statusCode:0,error:c})})).finally((()=>l?clearTimeout(l.timeout):null))}}),la&&Gr.push({transport:"XHR",method(t){var e,i=new la;i.open(t.method||"GET",t.url,!0);var{contentType:s,body:r}=(e=Zo(t))!==null&&e!==void 0?e:{};oe(t.headers,(function(n,o){i.setRequestHeader(o,n)})),s&&i.setRequestHeader("Content-Type",s),t.timeout&&(i.timeout=t.timeout),t.disableXHRCredentials||(i.withCredentials=!0),i.onreadystatechange=()=>{if(i.readyState===4){var n={statusCode:i.status,text:i.responseText};if(i.status===200)try{n.json=JSON.parse(i.responseText)}catch{}t.callback==null||t.callback(n)}},i.send(r)}}),ze!=null&&ze.sendBeacon&&Gr.push({transport:"sendBeacon",method(t){var e=mn(t.url,{beacon:"1"});try{var i,{contentType:s,body:r}=(i=Zo(t))!==null&&i!==void 0?i:{};if(!r)return;var n=r instanceof Blob?r:new Blob([r],{type:s});ze.sendBeacon(e,n)}catch{}}});sl=3e3,rl=class{constructor(e,i){this.Ar=!0,this.Nr=[],this.$r=gt(i?.flush_interval_ms||sl,250,5e3,T.createLogger("flush interval"),sl),this.Dr=e}enqueue(e){this.Nr.push(e),this.qr||this.jr()}unload(){this.Hr();var e=this.Nr.length>0?this.Ur():{},i=Object.values(e);[...i.filter((s=>s.url.indexOf("/e")===0)),...i.filter((s=>s.url.indexOf("/e")!==0))].map((s=>{this.Dr(S({},s,{transport:"sendBeacon"}))}))}enable(){this.Ar=!1,this.jr()}jr(){var e=this;this.Ar||(this.qr=setTimeout((()=>{if(this.Hr(),this.Nr.length>0){var i=this.Ur(),s=function(){var n=i[r],o=new Date().getTime();n.data&&Y(n.data)&&oe(n.data,(a=>{a.offset=Math.abs(a.timestamp-o),delete a.timestamp})),e.Dr(n)};for(var r in i)s()}}),this.$r))}Hr(){clearTimeout(this.qr),this.qr=void 0}Ur(){var e={};return oe(this.Nr,(i=>{var s,r=i,n=(r?r.batchKey:null)||r.url;P(e[n])&&(e[n]=S({},r,{data:[]})),(s=e[n].data)==null||s.push(r.data)})),this.Nr=[],e}},mE=["retriesPerformedSoFar"],nl=class{constructor(e){this.Br=!1,this.zr=3e3,this.Nr=[],this._instance=e,this.Nr=[],this.Vr=!0,!P(_)&&"onLine"in _.navigator&&(this.Vr=_.navigator.onLine,this.Wr=()=>{this.Vr=!0,this.Zr()},this.Gr=()=>{this.Vr=!1},ye(_,"online",this.Wr),ye(_,"offline",this.Gr))}get length(){return this.Nr.length}retriableRequest(e){var{retriesPerformedSoFar:i}=e,s=Sh(e,mE);Pi(i)&&(s.url=mn(s.url,{retry_count:i})),this._instance._send_request(S({},s,{callback:r=>{r.statusCode===200||r.statusCode>=400&&500>r.statusCode||(i??0)>=10?s.callback==null||s.callback(r):this.Qr(S({retriesPerformedSoFar:i},s))}}))}Qr(e){var i=e.retriesPerformedSoFar||0;e.retriesPerformedSoFar=i+1;var s=(function(o){var a=3e3*Math.pow(2,o),l=a/2,u=Math.min(18e5,a),c=Math.random()-.5;return Math.ceil(u+c*(u-l))})(i),r=Date.now()+s;this.Nr.push({retryAt:r,requestOptions:e});var n="Enqueued failed request for retry in "+s;navigator.onLine||(n+=" (Browser is offline)"),T.warn(n),this.Br||(this.Br=!0,this.Jr())}Jr(){if(this.Kr&&clearTimeout(this.Kr),this.Nr.length===0)return this.Br=!1,void(this.Kr=void 0);this.Kr=setTimeout((()=>{this.Vr&&this.Nr.length>0&&this.Zr(),this.Jr()}),this.zr)}Zr(){var e=Date.now(),i=[],s=this.Nr.filter((n=>e>n.retryAt||(i.push(n),!1)));if(this.Nr=i,s.length>0)for(var{requestOptions:r}of s)this.retriableRequest(r)}unload(){for(var{requestOptions:e}of(this.Kr&&(clearTimeout(this.Kr),this.Kr=void 0),this.Br=!1,P(_)||(this.Wr&&(_.removeEventListener("online",this.Wr),this.Wr=void 0),this.Gr&&(_.removeEventListener("offline",this.Gr),this.Gr=void 0)),this.Nr))try{this._instance._send_request(S({},e,{transport:"sendBeacon"}))}catch(i){T.error(i)}this.Nr=[]}},ol=class{constructor(e){this.Yr=()=>{var i,s,r,n;this.Xr||(this.Xr={});var o=this.scrollElement(),a=this.scrollY(),l=o?Math.max(0,o.scrollHeight-o.clientHeight):0,u=a+(o?.clientHeight||0),c=o?.scrollHeight||0;this.Xr.lastScrollY=Math.ceil(a),this.Xr.maxScrollY=Math.max(a,(i=this.Xr.maxScrollY)!==null&&i!==void 0?i:0),this.Xr.maxScrollHeight=Math.max(l,(s=this.Xr.maxScrollHeight)!==null&&s!==void 0?s:0),this.Xr.lastContentY=u,this.Xr.maxContentY=Math.max(u,(r=this.Xr.maxContentY)!==null&&r!==void 0?r:0),this.Xr.maxContentHeight=Math.max(c,(n=this.Xr.maxContentHeight)!==null&&n!==void 0?n:0)},this._instance=e}get ei(){return this._instance.config.scroll_root_selector}getContext(){return this.Xr}resetContext(){var e=this.Xr;return setTimeout(this.Yr,0),e}startMeasuringScrollPosition(){ye(_,"scroll",this.Yr,{capture:!0}),ye(_,"scrollend",this.Yr,{capture:!0}),ye(_,"resize",this.Yr)}scrollElement(){if(!this.ei)return _?.document.documentElement;var e=Y(this.ei)?this.ei:[this.ei];for(var i of e){var s=_?.document.querySelector(i);if(s)return s}}scrollY(){if(this.ei){var e=this.scrollElement();return e&&e.scrollTop||0}return _&&(_.scrollY||_.pageYOffset||_.document.documentElement.scrollTop)||0}scrollX(){if(this.ei){var e=this.scrollElement();return e&&e.scrollLeft||0}return _&&(_.scrollX||_.pageXOffset||_.document.documentElement.scrollLeft)||0}},yE=t=>cg(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties),dn=class{constructor(e,i,s,r){this.ti=n=>{var o=this.ri();if(!o||o.sessionId!==n){var a={sessionId:n,props:this.ii(this._instance)};this.ni.register({[Va]:a})}},this._instance=e,this.si=i,this.ni=s,this.ii=r||yE,this.si.onSessionId(this.ti)}ri(){return this.ni.props[Va]}getSetOnceProps(){var e,i=(e=this.ri())==null?void 0:e.props;return i?"r"in i?dg(i):{$referring_domain:i.referringDomain,$pathname:i.initialPathName,utm_source:i.utm_source,utm_campaign:i.utm_campaign,utm_medium:i.utm_medium,utm_content:i.utm_content,utm_term:i.utm_term}:{}}getSessionProps(){var e={};return oe(Rl(this.getSetOnceProps()),((i,s)=>{s==="$current_url"&&(s="url"),e["$session_entry_"+ca(s)]=i})),e}},Ds=class{constructor(){this.oi={}}on(e,i){return this.oi[e]||(this.oi[e]=[]),this.oi[e].push(i),()=>{this.oi[e]=this.oi[e].filter((s=>s!==i))}}emit(e,i){for(var s of this.oi[e]||[])s(i);for(var r of this.oi["*"]||[])r(e,i)}},ea=ue("[SessionId]"),hn=class{on(e,i){return this.ai.on(e,i)}constructor(e,i,s){var r;if(this.ui=[],this.li=void 0,this.ai=new Ds,this.hi=(u,c)=>!(!Pi(u)||!Pi(c))&&Math.abs(u-c)>this.sessionTimeoutMs,!e.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(e.config.cookieless_mode===Tt)throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.qt=e.config,this.ni=e.persistence,this.ci=void 0,this.di=void 0,this._sessionStartTimestamp=null,this._sessionActivityTimestamp=null,this.vi=i||Bt,this.fi=s||Bt;var n=this.qt.persistence_name||this.qt.token;if(this._sessionTimeoutMs=1e3*gt(this.qt.session_idle_timeout_seconds||1800,60,36e3,ea.createLogger("session_idle_timeout_seconds"),1800),e.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.pi(),this.gi="ph_"+n+"_window_id",this.mi="ph_"+n+"_primary_window_exists",this.yi()){var o=Re.F(this.gi),a=Re.F(this.mi);o&&!a?this.ci=o:Re.q(this.gi),Re.N(this.mi,!0)}if((r=this.qt.bootstrap)!=null&&r.sessionID)try{var l=(u=>{var c=this.qt.bootstrap.sessionID.replace(/-/g,"");if(c.length!==32)throw new Error("Not a valid UUID");if(c[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(c.substring(0,12),16)})();this.bi(this.qt.bootstrap.sessionID,new Date().getTime(),l)}catch(u){ea.error("Invalid sessionID in bootstrap",u)}this.wi()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(e){return P(this.ui)&&(this.ui=[]),this.ui.push(e),this.di&&e(this.di,this.ci),()=>{this.ui=this.ui.filter((i=>i!==e))}}yi(){return this.qt.persistence!=="memory"&&!this.ni._r&&Re.R()}xi(e){e!==this.ci&&(this.ci=e,this.yi()&&Re.N(this.gi,e))}Si(){return this.ci?this.ci:this.yi()?Re.F(this.gi):null}bi(e,i,s){e===this.di&&i===this._sessionActivityTimestamp&&s===this._sessionStartTimestamp||(this._sessionStartTimestamp=s,this._sessionActivityTimestamp=i,this.di=e,this.ni.register({[Yr]:[i,e,s]}))}ki(){var e=this.ni.props[Yr];return Y(e)&&e.length===2&&e.push(e[0]),e||[0,null,0]}resetSessionId(){this.bi(null,null,null)}destroy(){clearTimeout(this.Ci),this.Ci=void 0,this.li&&_&&(_.removeEventListener(en,this.li,{capture:!1}),this.li=void 0),this.ui=[]}wi(){this.li=()=>{this.yi()&&Re.q(this.mi)},ye(_,en,this.li,{capture:!1})}checkAndGetSessionAndWindowId(e,i){if(e===void 0&&(e=!1),i===void 0&&(i=null),this.qt.cookieless_mode===Tt)throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var s=i||new Date().getTime(),[r,n,o]=this.ki(),a=this.Si(),l=Pi(o)&&Math.abs(s-o)>864e5,u=!1,c=!n,h=!c&&!e&&this.hi(s,r);c||h||l?(n=this.vi(),a=this.fi(),ea.info("new session ID generated",{sessionId:n,windowId:a,changeReason:{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}}),o=s,u=!0):a||(a=this.fi(),u=!0);var f=Pi(r)&&e&&!l?r:s,g=Pi(o)?o:new Date().getTime();return this.xi(a),this.bi(n,f,g),e||this.pi(),u&&this.ui.forEach((p=>p(n,a,u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0))),{sessionId:n,windowId:a,sessionStartTimestamp:g,changeReason:u?{noSessionId:c,activityTimeout:h,sessionPastMaximumLength:l}:void 0,lastActivityTimestamp:r}}pi(){clearTimeout(this.Ci),this.Ci=setTimeout((()=>{var[e]=this.ki();if(this.hi(new Date().getTime(),e)){var i=this.di;this.resetSessionId(),this.ai.emit("forcedIdleReset",{idleSessionId:i})}}),1.1*this.sessionTimeoutMs)}},mg=function(t,e){if(!t)return!1;var i=t.userAgent;if(i&&Od(i,e))return!0;try{var s=t?.userAgentData;if(s!=null&&s.brands&&s.brands.some((r=>Od(r?.brand,e))))return!0}catch{}return!!t.webdriver},gn=function(t,e){if(!(function(i){try{new RegExp(i)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}};yg={exact:(t,e)=>e.some((i=>t.some((s=>i===s)))),is_not:(t,e)=>e.every((i=>t.every((s=>i!==s)))),regex:(t,e)=>e.some((i=>t.some((s=>gn(i,s))))),not_regex:(t,e)=>e.every((i=>t.every((s=>!gn(i,s))))),icontains:(t,e)=>e.map($r).some((i=>t.map($r).some((s=>i.includes(s))))),not_icontains:(t,e)=>e.map($r).every((i=>t.map($r).every((s=>!i.includes(s))))),gt:(t,e)=>e.some((i=>{var s=parseFloat(i);return!isNaN(s)&&t.some((r=>s>parseFloat(r)))})),lt:(t,e)=>e.some((i=>{var s=parseFloat(i);return!isNaN(s)&&t.some((r=>s<parseFloat(r)))}))},$r=t=>t.toLowerCase();al="custom",Yd="i.posthog.com",bE=/^\/static\//,ll=class{constructor(e){this.Ii={},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,i=(e=this.instance.config.ui_host)==null?void 0:e.replace(/\/$/,"");return i||(i=this.apiHost.replace("."+Yd,".posthog.com")),i==="https://app.posthog.com"?"https://us.posthog.com":i}get region(){return this.Ii[this.apiHost]||(this.Ii[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":al),this.Ii[this.apiHost]}Ti(e){var i=this.instance.config.__preview_external_dependency_versioned_paths;if(typeof i=="string"&&bE.test(e))return i.trim().replace(/\/$/,"")||void 0}endpointFor(e,i){if(i===void 0&&(i=""),i&&(i=i[0]==="/"?i:"/"+i),e==="ui")return this.uiHost+i;if(e==="flags")return this.flagsApiHost+i;if(e==="assets"){var s=this.Ti(i);if(s)return""+s+i}if(this.region===al)return this.apiHost+i;var r=Yd+i;switch(e){case"assets":return"https://"+this.region+"-assets."+r;case"api":return"https://"+this.region+"."+r}}},ee=ue("[Surveys]"),ul="seenSurvey_",EE=[Yo.Popover,Yo.Widget,Yo.API],SE={ignoreConditions:!1,ignoreDelay:!1,displayType:Ja.Popover},kE=ue("[PostHog ExternalIntegrations]"),wE={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},cl=class{constructor(e){this._instance=e}lr(e,i){var s;(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,e,(r=>{if(r)return kE.error("failed to load script",r);i()}))}startIfEnabledOrStop(){var e=this,i=function(o){var a,l,u;!r||(a=L.__PosthogExtensions__)!=null&&(a=a.integrations)!=null&&a[o]||e.lr(wE[o],(()=>{var c;(c=L.__PosthogExtensions__)==null||(c=c.integrations)==null||(c=c[o])==null||c.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[s,r]of Object.entries((n=this._instance.config.integrations)!==null&&n!==void 0?n:{})){var n;i(s)}}},Rs={},ta=0,dl=()=>{},Xd='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',fs="Surveys module not available",Jd="sanitize_properties is deprecated. Use before_send instead",Eg="Invalid value for property_denylist config: ",xi="posthog",Sg=!vE&&Ge?.indexOf("MSIE")===-1&&Ge?.indexOf("Mozilla")===-1,Qd=t=>{var e;return S({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,token:"",autocapture:!0,cross_subdomain_cookie:Jb(I?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:dl,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,debug:Te&&ge(Te?.search)&&Te.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(i){T.error("Bad HTTP status: "+i.statusCode+" "+i.text)},get_device_id:i=>i,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Ha,before_send:void 0,request_queue_config:{flush_interval_ms:sl},error_tracking:{},_onCapture:dl,__preview_eager_load_replay:!1},(i=>({rageclick:!i||"2025-11-30">i||{content_ignorelist:!0},capture_pageview:!i||"2025-05-24">i||"history_change",session_recording:i&&i>="2025-11-30"?{strictMinimumDuration:!0}:{},external_scripts_inject_target:i&&i>="2026-01-30"?"head":"body",internal_or_test_user_hostname:i&&i>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0}))(t))},AE=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["store_google","save_campaign_params"],["verbose","debug"]],Zd=t=>{var e={};for(var[i,s]of AE)P(t[i])||(e[s]=t[i]);var r=pe({},e,t);return Y(t.property_blacklist)&&(P(t.property_denylist)?r.property_denylist=t.property_blacklist:Y(t.property_denylist)?r.property_denylist=[...t.property_blacklist,...t.property_denylist]:T.error(Eg+t.property_denylist)),r},hl=class{constructor(){this.__forceAllowLocalhost=!1}get Ei(){return this.__forceAllowLocalhost}set Ei(e){T.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=e}},ri=class t{Mi(e,i){if(e){var s=this.Pi.indexOf(e);s!==-1&&this.Pi.splice(s,1)}return this.Pi.push(i),i.initialize==null||i.initialize(),i}Ri(){return this.config.cookieless_mode===Tt||this.config.cookieless_mode===ii&&this.consent.isRejected()}get decideEndpointWasHit(){var e,i;return(e=(i=this.featureFlags)==null?void 0:i.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,i;return(e=(i=this.featureFlags)==null?void 0:i.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.webPerformance=new hl,this.Oi=!1,this.version=De.LIB_VERSION,this.Li=new Ds,this.Pi=[],this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=Qd(),this.SentryIntegration=Xa,this.sentryIntegration=s=>(function(r,n){var o=ng(r,n);return{name:rg,processEvent:a=>o(a)}})(this,s),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Fi=!1,this.Ai=null,this.Ni=null,this.$i=null,this.scrollManager=new ol(this),this.pageViewManager=new sn(this),this.rateLimiter=new Qa(this),this.requestRouter=new ll(this),this.consent=new Ya(this),this.externalIntegrations=new cl(this);var i=(e=t.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=i.featureFlags&&new i.featureFlags(this),this.toolbar=i.toolbar&&new i.toolbar(this),this.surveys=i.surveys&&new i.surveys(this),this.conversations=i.conversations&&new i.conversations(this),this.logs=i.logs&&new i.logs(this),this.experiments=i.experiments&&new i.experiments(this),this.exceptions=i.exceptions&&new i.exceptions(this),this.people={set:(s,r,n)=>{var o=ge(s)?{[s]:r}:s;this.setPersonProperties(o),n?.({})},set_once:(s,r,n)=>{var o=ge(s)?{[s]:r}:s;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",(s=>T.info('send "'+s?.event+'"',s)))}init(e,i,s){if(s&&s!==xi){var r,n=(r=Rs[s])!==null&&r!==void 0?r:new t;return n._init(e,i,s),Rs[s]=n,Rs[xi][s]=n,n}return this._init(e,i,s)}_init(e,i,s){var r,n;if(i===void 0&&(i={}),P(e)||Mr(e))return T.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={},i.debug=this.Di(i.debug),this.qi=i,this.ji=[],i.person_profiles?this.Ni=i.person_profiles:i.process_person&&(this.Ni=i.process_person),this.set_config(pe({},Qd(i.defaults),Zd(i),{name:s,token:e})),this.config.on_xhr_error&&T.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=i.disable_compression?void 0:ct.GZipJS;var o=this.Hi();this.persistence=new Is(this.config,o),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Is(S({},this.config,{persistence:"sessionStorage"}),o);var a=S({},this.persistence.props),l=S({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Ui=new rl((m=>this.Bi(m)),this.config.request_queue_config),this.zi=new nl(this),this.__request_queue=[];var u=this.Ri();if(u||(this.sessionManager=new hn(this),this.sessionPropsManager=new dn(this,this.sessionManager,this.persistence)),this.config.__preview_deferred_init_extensions?(T.info("Deferring extension initialization to improve startup performance"),setTimeout((()=>{this.Vi(u)}),0)):(T.info("Initializing extensions synchronously"),this.Vi(u)),De.DEBUG=De.DEBUG||this.config.debug,De.DEBUG&&T.info("Starting in debug mode",{this:this,config:i,thisC:S({},this.config),p:a,s:l}),!this.config.identity_distinct_id||(r=i.bootstrap)!=null&&r.distinctID||(i.bootstrap=S({},i.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0})),((n=i.bootstrap)==null?void 0:n.distinctID)!==void 0){var c=i.bootstrap.distinctID,h=this.get_distinct_id(),f=this.persistence.get_property(rt);if(i.bootstrap.isIdentifiedID&&h!=null&&h!==c&&f===Ai)this.identify(c);else if(i.bootstrap.isIdentifiedID&&h!=null&&h!==c&&f===Ii)T.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 g=this.config.get_device_id(Bt()),p=i.bootstrap.isIdentifiedID?g:c;this.persistence.set_property(rt,i.bootstrap.isIdentifiedID?Ii:Ai),this.register({distinct_id:c,$device_id:p})}}if(u)this.register_once({distinct_id:Cr,$device_id:null},"");else if(!this.get_distinct_id()){var v=this.config.get_device_id(Bt());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(rt,Ai)}return ye(_,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),i.segment?(function(m,y){var w=m.config.segment;if(!w)return y();(function(R,N){var b=R.config.segment;if(!b)return N();var x=O=>{var A=()=>O.anonymousId()||Bt();R.config.get_device_id=A,O.id()&&(R.register({distinct_id:O.id(),$device_id:A()}),R.persistence.set_property(rt,Ii)),N()},C=b.user();"then"in C&&It(C.then)?C.then(x):x(C)})(m,(()=>{w.register((R=>{Promise&&Promise.resolve||Wo.warn("This browser does not have Promise support, and can not use the segment integration");var N=(b,x)=>{if(!x)return b;b.event.userId||b.event.anonymousId===R.get_distinct_id()||(Wo.info("No userId set, resetting PostHog"),R.reset()),b.event.userId&&b.event.userId!==R.get_distinct_id()&&(Wo.info("UserId set, identifying with PostHog"),R.identify(b.event.userId));var C=R.calculateEventProperties(x,b.event.properties);return b.event.properties=Object.assign({},C,b.event.properties),b};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded:()=>!0,load:()=>Promise.resolve(),track:b=>N(b,b.event.event),page:b=>N(b,Ci),identify:b=>N(b,zo),screen:b=>N(b,"$screen")}})(m)).then((()=>{y()}))}))})(this,(()=>this.Wi())):this.Wi(),It(this.config._onCapture)&&this.config._onCapture!==dl&&(T.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",(m=>this.config._onCapture(m.event,m)))),this.config.ip&&T.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}Vi(e){var i,s,r,n,o,a,l,u=performance.now(),c=S({},t.__defaultExtensionClasses,this.config.__extensionClasses),h=[];c.featureFlags&&this.Pi.push(this.featureFlags=(i=this.featureFlags)!==null&&i!==void 0?i:new c.featureFlags(this)),c.exceptions&&this.Pi.push(this.exceptions=(s=this.exceptions)!==null&&s!==void 0?s:new c.exceptions(this)),c.historyAutocapture&&this.Pi.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.Pi.push(new c.tracingHeaders(this)),c.siteApps&&this.Pi.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this.Pi.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||h.push((()=>{this.scrollManager.startMeasuringScrollPosition()})),c.autocapture&&this.Pi.push(this.autocapture=new c.autocapture(this)),c.surveys&&this.Pi.push(this.surveys=(r=this.surveys)!==null&&r!==void 0?r:new c.surveys(this)),c.logs&&this.Pi.push(this.logs=(n=this.logs)!==null&&n!==void 0?n:new c.logs(this)),c.conversations&&this.Pi.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new c.conversations(this)),c.productTours&&this.Pi.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.Pi.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.Pi.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.Pi.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.Pi.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,sE)),c.toolbar&&this.Pi.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new c.toolbar(this)),c.experiments&&this.Pi.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new c.experiments(this)),this.Pi.forEach((f=>{f.initialize&&h.push((()=>{f.initialize==null||f.initialize()}))})),h.push((()=>{if(this.Zi){var f=this.Zi;this.Zi=void 0,this.Rr(f)}})),this.Gi(h,u)}Gi(e,i){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-i>=30&&e.length>0)return void setTimeout((()=>{this.Gi(e,i)}),0);var s=e.shift();if(s)try{s()}catch(n){T.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-i);this.register_for_session({[Zh]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[eg]:r}),this.config.__preview_deferred_init_extensions&&T.info("PostHog extensions initialized ("+r+"ms)")}Rr(e){var i;if(!I||!I.body)return T.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout((()=>{this.Rr(e)}),500);this.config.__preview_deferred_init_extensions&&(this.Zi=e),this.Qi=e,this.compression=void 0,e.supportedCompression&&!this.config.disable_compression&&(this.compression=z(e.supportedCompression,ct.GZipJS)?ct.GZipJS:z(e.supportedCompression,ct.Base64)?ct.Base64:void 0),(i=e.analytics)!=null&&i.endpoint&&(this.analyticsDefaultEndpoint=e.analytics.endpoint),this.set_config({person_profiles:this.Ni?this.Ni:Ha}),this.Pi.forEach((s=>s.onRemoteConfig==null?void 0:s.onRemoteConfig(e)))}Wi(){try{this.config.loaded(this)}catch(s){T.critical("`loaded` function failed",s)}if(this.Ji(),this.config.internal_or_test_user_hostname&&Te!=null&&Te.hostname){var e=Te.hostname,i=this.config.internal_or_test_user_hostname;(typeof i=="string"?e===i:i.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout((()=>{(this.consent.isOptedIn()||this.Ri())&&this.Ki()}),1),this.Yi=new ln(this),this.Yi.load()}Ji(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Ui)==null||e.enable())}_dom_loaded(){this.is_capturing()&&xr(this.__request_queue,(e=>this.Bi(e))),this.__request_queue=[],this.Ji()}_handle_unload(){var e,i,s,r;(e=this.surveys)==null||e.handlePageUnload(),this.config.request_batching?(this.Xi()&&this.capture(Ho),(i=this.logs)==null||i.flushLogs("sendBeacon"),(s=this.Ui)==null||s.unload(),(r=this.zi)==null||r.unload()):this.Xi()&&this.capture(Ho,null,{transport:"sendBeacon"})}_send_request(e){this.__loaded&&(Sg?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)||(e.transport=e.transport||this.config.api_transport,e.url=mn(e.url,{ip:this.config.ip?1:0}),e.headers=S({},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,(i=>{var s,r,n,o=S({},i);o.timeout=o.timeout||6e4,o.url=Kd(o.url,o.compression);var a=(s=o.transport)!==null&&s!==void 0?s:"fetch",l=Gr.filter((c=>!o.disableTransport||!c.transport||!o.disableTransport.includes(c.transport))),u=(r=(n=(function(c,h){for(var f=0;c.length>f;f++)if(c[f].transport===a)return c[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&&mb&&!zd?_E(o).then((c=>{u(c)})).catch((c=>{if((h=>!(!h||typeof h!="object")&&("name"in h?String(h.name):"")==="NotReadableError")(c))return zd=!0,void u(S({},o,{compression:void 0,url:Kd(i.url,void 0)}));u(o)})):u(o)})(S({},e,{callback:i=>{var s,r;this.rateLimiter.checkForLimiting(i),400>i.statusCode||(s=(r=this.config).on_request_error)==null||s.call(r,i),e.callback==null||e.callback(i)}}))))}Bi(e){this.zi?this.zi.retriableRequest(e):this._send_request(e)}_execute_array(e){ta++;try{var i,s=[],r=[],n=[];xr(e,(a=>{a&&(Y(i=a[0])?n.push(a):It(a)?a.call(this):Y(a)&&i==="alias"?s.push(a):Y(a)&&i.indexOf("capture")!==-1&&It(this[i])?n.push(a):r.push(a))}));var o=function(a,l){xr(a,(function(u){if(Y(u[0])){var c=l;oe(u,(function(h){c=c[h[0]].apply(c,h.slice(1))}))}else l[u[0]].apply(l,u.slice(1))}))};o(s,this),o(r,this),o(n,this)}finally{ta--}}push(e){if(ta>0&&Y(e)&&ge(e[0])){var i=t.prototype[e[0]];It(i)&&i.apply(this,e.slice(1))}else this._execute_array([e])}capture(e,i,s){var r,n,o,a,l;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Ui){if(this.is_capturing())if(!P(e)&&ge(e)){var u=!this.config.opt_out_useragent_filter&&this._is_bot();if(!u||this.config.__preview_capture_bot_pageviews){var c=s!=null&&s.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(c==null||!c.isRateLimited){i!=null&&i.$current_url&&!ge(i?.$current_url)&&(T.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),i==null||delete i.$current_url),e!=="$exception"||s!=null&&s.en||T.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=s?.timestamp||h,g=Bt(),p={uuid:g,event:e,properties:this.calculateEventProperties(e,i||{},f,g)};e===Ci&&this.config.__preview_capture_bot_pageviews&&u&&(p.event="$bot_pageview",p.properties.$browser_type="bot"),c&&(p.properties.$lib_rate_limit_remaining_tokens=c.remainingTokens),s?.$set&&(p.$set=s?.$set);var v,m,y,w=this.tn(s?.$set_once,e!==Fd,e===zo);if(w&&(p.$set_once=w),s!=null&&s._noTruncate||(n=this.config.properties_string_max_length,o=p,a=A=>ge(A)?A.slice(0,n):A,l=new Set,p=(function A($,U){return $!==Object($)?a?a($):$:l.has($)?void 0:(l.add($),Y($)?(H=[],xr($,(G=>{H.push(A(G))}))):(H={},oe($,((G,q)=>{l.has(G)||(H[q]=A(G,q))}))),H);var H})(o)),p.timestamp=f,P(s?.timestamp)||(p.properties.$event_time_override_provided=!0,p.properties.$event_time_override_system_time=h),e===ks.DISMISSED||e===ks.SENT){var R=i?.[Xo.SURVEY_ID],N=i?.[Xo.SURVEY_ITERATION];(A=>{try{var $=(U=>((H,G)=>{var q=""+ul+G.id;return G.current_iteration&&G.current_iteration>0&&(q=""+ul+G.id+"_"+G.current_iteration),q})(0,U))(A);if(localStorage.getItem($))return;localStorage.setItem($,"true")}catch(U){ee.error("Failed to persist survey seen state",U)}})({id:R,current_iteration:N}),p.$set=S({},p.$set,{[(v={id:R,current_iteration:N},m=e===ks.SENT?"responded":"dismissed",y="$survey_"+m+"/"+v.id,v.current_iteration&&v.current_iteration>0&&(y="$survey_"+m+"/"+v.id+"/"+v.current_iteration),y)]:!0})}else e===ks.SHOWN&&(p.$set=S({},p.$set,{[Xo.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===cE.SHOWN){var b=i?.[Vd.TOUR_TYPE];b&&(p.$set=S({},p.$set,{[Vd.TOUR_LAST_SEEN_DATE+"/"+b]:new Date().toISOString()}))}var x=S({},p.properties.$set,p.$set);if(Ni(x)||this.setPersonPropertiesForFlags(x),!K(this.config.before_send)){var C=this.rn(p);if(!C)return;p=C}this.Li.emit("eventCaptured",p);var O={method:"POST",url:(r=s?._url)!==null&&r!==void 0?r:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),data:p,compression:"best-available",batchKey:s?._batchKey};return!this.config.request_batching||s&&(s==null||!s._batchKey)||s!=null&&s.send_instantly?this.Bi(O):this.Ui.enqueue(O),p}T.critical("This capture call is ignored due to client rate limiting.")}}else T.error("No event name provided to posthog.capture")}else T.uninitializedWarning("posthog.capture")}_addCaptureHook(e){return this.on("eventCaptured",(i=>e(i.event,i)))}calculateEventProperties(e,i,s,r,n){if(s=s||new Date,!this.persistence||!this.sessionPersistence)return i;var o=n?void 0:this.persistence.remove_event_timer(e),a=S({},i);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.Ri()&&(a.$cookieless_mode=!0),e==="$snapshot"){var l=S({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!ge(a.distinct_id)&&!et(a.distinct_id)||Mr(a.distinct_id))&&T.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=(function(y,w){var R,N,b,x;if(!Ge)return{};var C,O,A,$,U,H,G,q,_e=y?[...Vi,...w||[]]:[],[Ee,$e]=(function(Se){for(var k=0;Nd.length>k;k++){var[M,F]=Nd[k],B=M.exec(Se),Z=B&&(It(F)?F(B,Se):F);if(Z)return Z}return["",""]})(Ge);return pe(Rl({$os:Ee,$os_version:$e,$browser:Vh(Ge,navigator.vendor),$device:Dd(Ge),$device_type:(O=Ge,A={userAgentDataPlatform:(R=navigator)==null||(R=R.userAgentData)==null?void 0:R.platform,maxTouchPoints:(N=navigator)==null?void 0:N.maxTouchPoints,screenWidth:_==null||(b=_.screen)==null?void 0:b.width,screenHeight:_==null||(x=_.screen)==null?void 0:x.height,devicePixelRatio:_?.devicePixelRatio},q=Dd(O),q===Th||q===Ih||q==="Kobo"||q==="Kindle Fire"||q===Bh?Mi:q===Os||q===Fi||q===Cs||q===ga?"Console":q===Ph?"Wearable":q?Ke:A?.userAgentDataPlatform==="Android"&&(($=A?.maxTouchPoints)!==null&&$!==void 0?$:0)>0?600>Math.min((U=A?.screenWidth)!==null&&U!==void 0?U:0,(H=A?.screenHeight)!==null&&H!==void 0?H:0)/((G=A?.devicePixelRatio)!==null&&G!==void 0?G:1)?Ke:Mi:"Desktop"),$timezone:hg(),$timezone_offset:lE()}),{$current_url:xs(Te?.href,_e,Ns),$host:Te?.host,$pathname:Te?.pathname,$raw_user_agent:Ge.length>1e3?Ge.substring(0,997)+"...":Ge,$browser_version:Nb(Ge,navigator.vendor),$browser_language:Bd(),$browser_language_prefix:(C=Bd(),typeof C=="string"?C.split("-")[0]:void 0),$screen_height:_?.screen.height,$screen_width:_?.screen.width,$viewport_height:_?.innerHeight,$viewport_width:_?.innerWidth,$lib:De.LIB_NAME,$lib_version:De.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,s.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.zi)==null?void 0:g.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}if(this.requestRouter.region===al&&(a.$lib_custom_api_host=this.config.api_host),u=e!==Ci||n?e!==Ho||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(s):this.pageViewManager.doPageView(s,r),a=pe(a,u),e===Ci&&I&&(a.title=I.title),!P(o)){var p=s.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({},c,this.persistence.properties(),this.sessionPersistence.properties(),a)).$is_identified=this._isIdentified(),Y(this.config.property_denylist)?oe(this.config.property_denylist,(function(y){delete a[y]})):T.error(Eg+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var v=this.config.sanitize_properties;v&&(T.error(Jd),a=v(a,e));var m=this.nn();return a.$process_person_profile=m,m&&!n&&this.sn("_calculate_event_properties"),a}tn(e,i,s){var r;if(i===void 0&&(i=!0),s===void 0&&(s=!1),!this.persistence||!this.nn()||this.Oi&&!s)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&&(T.error(Jd),a=l(a,"$set_once")),i&&(this.Oi=!0),Ni(a)?void 0:a}register(e,i){var s;(s=this.persistence)==null||s.register(e,i)}register_once(e,i,s){var r;(r=this.persistence)==null||r.register_once(e,i,s)}register_for_session(e){var i;(i=this.sessionPersistence)==null||i.register(e)}unregister(e){var i;(i=this.persistence)==null||i.unregister(e)}unregister_for_session(e){var i;(i=this.sessionPersistence)==null||i.unregister(e)}an(e,i){this.register({[e]:i})}getFeatureFlag(e,i){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlag(e,i)}getFeatureFlagPayload(e){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagPayload(e)}getFeatureFlagResult(e,i){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagResult(e,i)}isFeatureEnabled(e,i){var s;return(s=this.featureFlags)==null?void 0:s.isFeatureEnabled(e,i)}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,i,s){var r;(r=this.featureFlags)==null||r.updateFlags(e,i,s)}updateEarlyAccessFeatureEnrollment(e,i,s){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,i,s)}getEarlyAccessFeatures(e,i,s){var r;return i===void 0&&(i=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,i,s)}on(e,i){return this.Li.on(e,i)}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:fs}),()=>{})}onSessionId(e){var i,s;return(i=(s=this.sessionManager)==null?void 0:s.onSessionId(e))!==null&&i!==void 0?i:()=>{}}getSurveys(e,i){i===void 0&&(i=!1),this.surveys?this.surveys.getSurveys(e,i):e([],{isLoaded:!1,error:fs})}getActiveMatchingSurveys(e,i){i===void 0&&(i=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,i):e([],{isLoaded:!1,error:fs})}renderSurvey(e,i){var s;(s=this.surveys)==null||s.renderSurvey(e,i)}displaySurvey(e,i){var s;i===void 0&&(i=SE),(s=this.surveys)==null||s.displaySurvey(e,i)}cancelPendingSurvey(e){var i;(i=this.surveys)==null||i.cancelPendingSurvey(e)}canRenderSurvey(e){var i,s;return(i=(s=this.surveys)==null?void 0:s.canRenderSurvey(e))!==null&&i!==void 0?i:{visible:!1,disabledReason:fs}}canRenderSurveyAsync(e,i){var s,r;return i===void 0&&(i=!1),(s=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,i))!==null&&s!==void 0?s:Promise.resolve({visible:!1,disabledReason:fs})}un(e){return!e||Mr(e)?(T.critical("Unique user id has not been set in posthog.identify"),!1):e===Cr?(T.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())||(T.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,i,s){if(!this.__loaded||!this.persistence)return T.uninitializedWarning("posthog.identify");if(et(e)&&(e=e.toString(),T.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),this.un(e)&&this.sn("posthog.identify")){var r=this.get_distinct_id();this.register({$user_id:e}),this.get_property(Wr)||this.register_once({$had_persisted_distinct_id:!0,$device_id:r},""),e!==r&&e!==this.get_property(ms)&&(this.unregister(ms),this.register({distinct_id:e}));var n,o=(this.persistence.get_property(rt)||Ai)===Ai;e!==r&&o?(this.persistence.set_property(rt,Ii),this.setPersonPropertiesForFlags({$set:i||{},$set_once:s||{}},!1),this.capture(zo,{distinct_id:e,$anon_distinct_id:r},{$set:i||{},$set_once:s||{}}),this.$i=Wd(e,i,s),(n=this.featureFlags)==null||n.setAnonymousDistinctId(r)):(i||s)&&this.setPersonProperties(i,s),e!==r&&(this.reloadFeatureFlags(),this.unregister(As))}}setPersonProperties(e,i){if((e||i)&&this.sn("posthog.setPersonProperties")){var s=Wd(this.get_distinct_id(),e,i);this.$i!==s?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:i||{}},!0),this.capture("$set",{$set:e||{},$set_once:i||{}}),this.$i=s):T.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}group(e,i,s){if(e&&i){var r=this.getGroups(),n=r[e]!==i;if(n&&this.resetGroupPropertiesForFlags(e),this.register({$groups:S({},r,{[e]:i})}),n||s){var o={$group_type:e,$group_key:i};s&&(o.$group_set=s),this.capture(Fd,o)}s&&this.setGroupPropertiesForFlags({[e]:s}),n&&!s&&this.reloadFeatureFlags()}else T.error("posthog.group requires a group type and group key")}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,i){var s;i===void 0&&(i=!0),(s=this.featureFlags)==null||s.setPersonPropertiesForFlags(e,i)}resetPersonPropertiesForFlags(){var e;(e=this.featureFlags)==null||e.resetPersonPropertiesForFlags()}setGroupPropertiesForFlags(e,i){var s;i===void 0&&(i=!0),this.sn("posthog.setGroupPropertiesForFlags")&&((s=this.featureFlags)==null||s.setGroupPropertiesForFlags(e,i))}resetGroupPropertiesForFlags(e){var i;(i=this.featureFlags)==null||i.resetGroupPropertiesForFlags(e)}reset(e){var i,s,r,n,o,a,l,u;if(T.info("reset"),!this.__loaded)return T.uninitializedWarning("posthog.reset");var c=this.get_property(Wr);if(this.consent.reset(),(i=this.persistence)==null||i.clear(),(s=this.sessionPersistence)==null||s.clear(),(r=this.surveys)==null||r.reset(),(n=this.Yi)==null||n.stop(),(o=this.featureFlags)==null||o.reset(),(a=this.conversations)==null||a.reset(),(l=this.persistence)==null||l.set_property(rt,Ai),(u=this.sessionManager)==null||u.resetSessionId(),this.$i=null,this.config.cookieless_mode===Tt)this.register_once({distinct_id:Cr,$device_id:null},"");else{var h=this.config.get_device_id(Bt());this.register_once({distinct_id:h,$device_id:e?h:c},"")}this.register({$last_posthog_reset:new Date().toISOString()},1),delete this.config.identity_distinct_id,delete this.config.identity_hash,this.reloadFeatureFlags()}setIdentity(e,i){var s;this.config.identity_distinct_id=e,this.config.identity_hash=i,this.alias(e),(s=this.conversations)==null||s.ln()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,(e=this.conversations)==null||e.hn()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,i;return(e=(i=this.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var{sessionId:i,sessionStartTimestamp:s}=this.sessionManager.checkAndGetSessionAndWindowId(!0),r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+i);if(e!=null&&e.withTimestamp&&s){var n,o=(n=e.timestampLookBack)!==null&&n!==void 0?n:10;if(!s)return r;r+="?t="+Math.max(Math.floor((new Date().getTime()-s)/1e3)-o,0)}return r}alias(e,i){return e===this.get_property(Kh)?(T.critical("Attempting to create alias for existing People user - aborting."),-2):this.sn("posthog.alias")?(P(i)&&(i=this.get_distinct_id()),e!==i?(this.an(ms,e),this.capture("$create_alias",{alias:e,distinct_id:i})):(T.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var i=S({},this.config);if(ve(e)){var s,r,n,o,a,l,u,c,h,f;pe(this.config,Zd(e));var g=this.Hi();(s=this.persistence)==null||s.update_config(this.config,i,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new Is(S({},this.config,{persistence:"sessionStorage"}),g);var p=this.Di(this.config.debug);ht(p)&&(this.config.debug=p),ht(this.config.debug)&&(this.config.debug?(De.DEBUG=!0,he.R()&&he.N("ph_debug",!0),T.info("set_config",{config:e,oldConfig:i,newConfig:S({},this.config)})):(De.DEBUG=!1,he.R()&&he.q("ph_debug"))),(r=this.exceptionObserver)==null||r.onConfigChange(),(n=this.exceptions)==null||n.onConfigChange(),(o=this.sessionRecording)==null||o.startIfEnabledOrStop(),(a=this.autocapture)==null||a.startIfEnabled(),(l=this.heatmaps)==null||l.startIfEnabled(),(u=this.exceptionObserver)==null||u.startIfEnabledOrStop(),(c=this.deadClicksAutocapture)==null||c.startIfEnabledOrStop(),(h=this.surveys)==null||h.loadIfEnabled(),this.cn(),(f=this.externalIntegrations)==null||f.startIfEnabledOrStop()}}_overrideSDKInfo(e,i){De.LIB_NAME=e,De.LIB_VERSION=i}startSessionRecording(e){var i,s,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)&&((i=this.sessionManager)==null||i.checkAndGetSessionAndWindowId(),l.sampling&&((s=this.sessionRecording)==null||s.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,i){if(this.exceptions){var s=new Error("PostHog syntheticException"),r=this.exceptions.buildProperties(e,{handled:!0,syntheticException:s});return this.exceptions.sendExceptionEvent(S({},r,i))}}addExceptionStep(e,i){var s;(s=this.exceptions)==null||s.addExceptionStep(e,i)}captureLog(e){var i;(i=this.logs)==null||i.captureLog(e)}get logger(){var e,i;return(e=(i=this.logs)==null?void 0:i.logger)!==null&&e!==void 0?e:t.dn}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var i,s;return(i=(s=this.toolbar)==null?void 0:s.loadToolbar(e))!==null&&i!==void 0&&i}get_property(e){var i;return(i=this.persistence)==null?void 0:i.props[e]}getSessionProperty(e){var i;return(i=this.sessionPersistence)==null?void 0:i.props[e]}toString(){var e,i=(e=this.config.name)!==null&&e!==void 0?e:xi;return i!==xi&&(i=xi+"."+i),i}_isIdentified(){var e,i;return((e=this.persistence)==null?void 0:e.get_property(rt))===Ii||((i=this.sessionPersistence)==null?void 0:i.get_property(rt))===Ii}nn(){var e,i;return!(this.config.person_profiles==="never"||this.config.person_profiles===Ha&&!this._isIdentified()&&Ni(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e[ms])&&((i=this.persistence)==null||(i=i.props)==null||!i[Qr]))}Xi(){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.nn()||this.sn("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.sn("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}sn(e){return this.config.person_profiles==="never"?(T.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.an(Qr,!0),!0)}Hi(){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!==ii)}cn(){var e,i,s,r,n=this.Hi();return((e=this.persistence)==null?void 0:e._r)!==n&&((s=this.persistence)==null||s.set_disabled(n)),((i=this.sessionPersistence)==null?void 0:i._r)!==n&&((r=this.sessionPersistence)==null||r.set_disabled(n)),n}opt_in_capturing(e){var i;if(this.config.cookieless_mode!==Tt){if(this.Ri()){var s,r,n,o,a;this.reset(!0),(s=this.sessionManager)==null||s.destroy(),(r=this.pageViewManager)==null||r.destroy(),this.sessionManager=new hn(this),this.pageViewManager=new sn(this),this.persistence&&(this.sessionPropsManager=new dn(this,this.sessionManager,this.persistence));var l,u=(n=(o=this.config.__extensionClasses)==null?void 0:o.sessionRecording)!==null&&n!==void 0?n:(a=t.__defaultExtensionClasses)==null?void 0:a.sessionRecording;u&&(this.sessionRecording=this.Mi(this.sessionRecording,new u(this)),this.Qi&&((l=this.sessionRecording)==null||l.onRemoteConfig==null||l.onRemoteConfig(this.Qi)))}var c,h;this.consent.optInOut(!0),this.cn(),this.Ji(),(i=this.sessionRecording)==null||i.startIfEnabledOrStop(),this.config.cookieless_mode==ii&&((c=this.surveys)==null||c.loadIfEnabled()),(P(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((h=e?.captureEventName)!==null&&h!==void 0?h:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ki()}else T.warn(Xd)}opt_out_capturing(){var e,i,s;this.config.cookieless_mode!==Tt?(this.config.cookieless_mode===ii&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.cn(),this.config.cookieless_mode===ii&&(this.register({distinct_id:Cr,$device_id:null}),(e=this.sessionManager)==null||e.destroy(),(i=this.pageViewManager)==null||i.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,(s=this.sessionRecording)==null||s.stopRecording(),this.sessionRecording=void 0,this.Ki())):T.warn(Xd)}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===Tt||(this.config.cookieless_mode===ii?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.cn()}_is_bot(){return ze?mg(ze,this.config.custom_blocked_useragents):void 0}Ki(){I&&(I.visibilityState==="visible"?this.Fi||(this.Fi=!0,this.capture(Ci,{title:I.title},{send_instantly:!0}),this.Ai&&(I.removeEventListener(Zr,this.Ai),this.Ai=null)):this.Ai||(this.Ai=this.Ki.bind(this),ye(I,Zr,this.Ai)))}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}))}Lr(){var e,i,s,r,n,o,a=this.qi||{};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?(T.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):(s="advanced_disable_decide",r=T,n=(i="advanced_disable_flags")in(e=a)&&!K(e[i]),o=s in e&&!K(e[s]),n?e[i]:!!o&&(r&&r.warn("Config field '"+s+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),e[s]))}rn(e){if(K(this.config.before_send))return e;var i=Y(this.config.before_send)?this.config.before_send:[this.config.before_send],s=e;for(var r of i){if(s=r(s),K(s)){var n="Event '"+e.event+"' was rejected in beforeSend function";return Sb(e.event)?T.warn(n+". This can cause unexpected behavior."):T.info(n),null}s.properties&&!Ni(s.properties)||T.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}return s}getPageViewId(){var e;return(e=this.pageViewManager.dr)==null?void 0:e.pageViewId}captureTraceFeedback(e,i){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:i})}captureTraceMetric(e,i,s){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:i,$ai_metric_value:String(s)})}Di(e){var i=ht(e)&&!e,s=he.R()&&he.A("ph_debug")==="true";return!i&&(!!s||e)}};ri.__defaultExtensionClasses={},ri.dn={trace:Ti=()=>{},debug:Ti,info:Ti,warn:Ti,error:Ti,fatal:Ti},(function(t,e){for(var i=0;e.length>i;i++)t.prototype[e[i]]=Yb(t.prototype[e[i]])})(ri,["identify"]);IE=1,TE=3,RE=11;xl=["a","button","form","input","select","textarea","label"];PE=["next","previous","prev",">","<"],rh=[".ph-no-rageclick",".ph-no-capture"],gl=t=>!t||nt(t,"html")||!oi(t),nh=(t,e)=>{if(!_||gl(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[t],r=t;r.parentNode&&!nt(r,"body");)if(wg(r.parentNode))s.push(r.parentNode.host),r=r.parentNode.host;else{var n=Ig(r);if(!n)break;if(e||xl.indexOf(n.tagName.toLowerCase())>-1)i=!0;else{var o=_.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(i=!0)}s.push(n),r=n}return{parentIsUsefulElement:i,targetElementList:s}};Rg="(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("^(?:"+Rg+")$"),CE=new RegExp(Rg),Pg="\\d{3}-?\\d{2}-?\\d{4}",xE=new RegExp("^("+Pg+")$"),NE=new RegExp("("+Pg+")");pn=class{constructor(e){this.disabled=e===!1;var i=ve(e)?e:{};this.thresholdPx=i.threshold_px||30,this.timeoutMs=i.timeout_ms||1e3,this.clickCount=i.click_count||3,this.clicks=[]}isRageClick(e,i,s){if(this.disabled)return!1;var r=this.clicks[this.clicks.length-1];if(r&&Math.abs(e-r.x)+Math.abs(i-r.y)<this.thresholdPx&&this.timeoutMs>s-r.timestamp){if(this.clicks.push({x:e,y:i,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:e,y:i,timestamp:s}];return!1}},ia="$copy_autocapture",sa=ue("[AutoCapture]");ps=ue("[ExceptionAutocapture]");FE=ue("[TracingHeaders]"),Ft=ue("[Web Vitals]"),uh=9e5,ch="disabled",dh="lazy_loading",vs="awaiting_config",Fr="missing_config";ue("[SessionRecording]"),ue("[SessionRecording]");pl="[SessionRecording]",Mt=ue(pl),ME=ue("[Heatmaps]");gh=ue("[Product Tours]"),UE=["$set_once","$set"],Ut=ue("[SiteApps]"),fh="Error while initializing PostHog app with config id ";vl=class{constructor(e){this.vn=new Ds,this.fn=(i,s)=>this.pn(i,s)&&this.gn(i,s)&&this.mn(i,s)&&this.yn(i,s),this.pn=(i,s)=>s==null||!s.event||i?.event===s?.event,this._instance=e,this.bn=new Set,this._n=new Set}init(){var e,i;P((e=this._instance)==null?void 0:e._addCaptureHook)||(i=this._instance)==null||i._addCaptureHook(((s,r)=>{this.on(s,r)}))}register(e){var i,s;if(!P((i=this._instance)==null?void 0:i._addCaptureHook)&&(e.forEach((o=>{var a,l;(a=this._n)==null||a.add(o),(l=o.steps)==null||l.forEach((u=>{var c;(c=this.bn)==null||c.add(u?.event||"")}))})),(s=this._instance)!=null&&s.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,i){var s;i!=null&&e.length!=0&&(this.bn.has(e)||this.bn.has(i?.event))&&this._n&&((s=this._n)==null?void 0:s.size)>0&&this._n.forEach((r=>{this.wn(i,r)&&this.vn.emit("actionCaptured",r.name)}))}xn(e){this.onAction("actionCaptured",(i=>e(i)))}wn(e,i){if(i?.steps==null)return!1;for(var s of i.steps)if(this.fn(e,s))return!0;return!1}onAction(e,i){return this.vn.on(e,i)}gn(e,i){if(i!=null&&i.url){var s,r=e==null||(s=e.properties)==null?void 0:s.$current_url;if(!r||typeof r!="string"||!Ri(r,i.url,i.url_matching||"contains"))return!1}return!0}mn(e,i){return!!this.Sn(e,i)&&!!this.kn(e,i)&&!!this.Cn(e,i)}Sn(e,i){var s;if(i==null||!i.href)return!0;var r=this.In(e);if(r.length>0)return r.some((a=>Ri(a.href,i.href,i.href_matching||"exact")));var n,o=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!o&&Ri((n=o.match(/(?::|")href="(.*?)"/))?n[1]:"",i.href,i.href_matching||"exact")}kn(e,i){var s;if(i==null||!i.text)return!0;var r=this.In(e);if(r.length>0)return r.some((u=>Ri(u.text,i.text,i.text_matching||"exact")||Ri(u.$el_text,i.text,i.text_matching||"exact")));var n,o,a,l=(e==null||(s=e.properties)==null?void 0:s.$elements_chain)||"";return!!l&&(n=(function(u){for(var c,h=[],f=/(?::|")text="(.*?)"/g;!K(c=f.exec(u));)h.includes(c[1])||h.push(c[1]);return h})(l),o=i.text,a=i.text_matching||"exact",n.some((u=>Ri(u,o,a))))}Cn(e,i){var s,r;if(i==null||!i.selector)return!0;var n=e==null||(s=e.properties)==null?void 0:s.$element_selectors;if(n!=null&&n.includes(i.selector))return!0;var o=(e==null||(r=e.properties)==null?void 0:r.$elements_chain)||"";if(i.selector_regex&&o)try{return new RegExp(i.selector_regex).test(o)}catch{return!1}return!1}In(e){var i;return(e==null||(i=e.properties)==null?void 0:i.$elements)==null?[]:e?.properties.$elements}yn(e,i){return i==null||!i.properties||i.properties.length===0||bg(i.properties.reduce(((s,r)=>{var n=Y(r.value)?r.value.map(String):r.value!=null?[String(r.value)]:[];return s[r.key]={values:n,operator:r.operator||"exact"},s}),{}),e?.properties)}},_l=class{constructor(e){this._instance=e,this.Tn=new Map,this.En=new Map,this.Mn=new Map}Pn(e,i){return!!e&&bg(e.propertyFilters,i?.properties)}Rn(e,i){var s=new Map;return e.forEach((r=>{var n;(n=r.conditions)==null||(n=n[i])==null||(n=n.values)==null||n.forEach((o=>{if(o!=null&&o.name){var a=s.get(o.name)||[];a.push(r.id),s.set(o.name,a)}}))})),s}On(e,i,s){var r=(s===cs.Activation?this.Tn:this.En).get(e),n=[];return this.Ln((o=>{n=o.filter((a=>r?.includes(a.id)))})),n.filter((o=>{var a,l=(a=o.conditions)==null||(a=a[s])==null||(a=a.values)==null?void 0:a.find((u=>u.name===e));return this.Pn(l,i)}))}register(e){var i;P((i=this._instance)==null?void 0:i._addCaptureHook)||(this.Fn(e),this.An(e))}An(e){var i=e.filter((s=>{var r,n;return((r=s.conditions)==null?void 0:r.actions)&&((n=s.conditions)==null||(n=n.actions)==null||(n=n.values)==null?void 0:n.length)>0}));i.length!==0&&(this.Nn==null&&(this.Nn=new vl(this._instance),this.Nn.init(),this.Nn.xn((s=>{this.onAction(s)}))),i.forEach((s=>{var r,n,o,a,l;s.conditions&&(r=s.conditions)!=null&&r.actions&&(n=s.conditions)!=null&&(n=n.actions)!=null&&n.values&&((o=s.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length)>0&&((a=this.Nn)==null||a.register(s.conditions.actions.values),(l=s.conditions)==null||(l=l.actions)==null||(l=l.values)==null||l.forEach((u=>{if(u&&u.name){var c=this.Mn.get(u.name);c&&c.push(s.id),this.Mn.set(u.name,c||[s.id])}})))})))}Fn(e){var i,s=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}));s.length===0&&r.length===0||((i=this._instance)==null||i._addCaptureHook(((n,o)=>{this.onEvent(n,o)})),this.Tn=this.Rn(e,cs.Activation),this.En=this.Rn(e,cs.Cancellation))}onEvent(e,i){var s,r=this.le(),n=this.$n(),o=this.Dn(),a=((s=this._instance)==null||(s=s.persistence)==null?void 0:s.props[n])||[];if(o===e&&i&&a.length>0){var l,u;r.info("event matched, removing item from activated items",{event:e,eventPayload:i,existingActivatedItems:a});var c=(i==null||(l=i.properties)==null?void 0:l.$survey_id)||(i==null||(u=i.properties)==null?void 0:u.$product_tour_id);if(c){var h=a.indexOf(c);0>h||(a.splice(h,1),this.qn(a))}}else{if(this.En.has(e)){var f=this.On(e,i,cs.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.jn(p.id)})),this.qn(a))}if(this.Tn.has(e)){r.info("event name matched",{event:e,eventPayload:i,items:this.Tn.get(e)});var g=this.On(e,i,cs.Activation);this.qn(a.concat(g.map((p=>p.id))||[]))}}}onAction(e){var i,s=this.$n(),r=((i=this._instance)==null||(i=i.persistence)==null?void 0:i.props[s])||[];this.Mn.has(e)&&this.qn(r.concat(this.Mn.get(e)||[]))}qn(e){var i=this.le(),s=[...new Set(e)].filter((r=>!this.Hn(r)));i.info("updating activated items",{activatedItems:s}),this.Un(s)}getActivatedIds(){var e,i=this.$n();return((e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[i])||[]}getEventToItemsMap(){return this.Tn}Bn(){return this.Nn}},ml=class extends _l{constructor(e){super(e)}$n(){return Ma}Dn(){return ks.SHOWN}Ln(e){var i;(i=this._instance)==null||i.getSurveys(e)}jn(e){var i;(i=this._instance)==null||i.cancelPendingSurvey(e)}le(){return ee}Un(e){var i;(i=this._instance)==null||(i=i.persistence)==null||i.register({[Ma]:e})}Hn(){return!1}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},na="SDK is not enabled or survey functionality is not yet loaded",ph="Disabled. Not loading surveys.",BE=_!=null&&_.location?on(_.location.hash,"__posthog")||on(location.hash,"state"):null,vh="_postHogToolbarParams",_h=ue("[Toolbar]"),xe=ue("[FeatureFlags]"),Zt=ue("[FeatureFlags]",{debugEnabled:!0}),oa=`" failed. Feature flags didn't load in time.`,mh=t=>{for(var e={},i=0;t.length>i;i++)e[t[i]]=!0;return e},yh=t=>{var e={};for(var[i,s]of Vr(t||{}))s&&(e[i]=s);return e},wt=ue("[Error tracking]"),bh="Refusing to render web experiment since the viewer is a likely bot",VE={icontains:(t,e)=>!!_&&e.href.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>!!_&&e.href.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>!!_&&gn(e.href,t),not_regex:(t,e)=>!!_&&!gn(e.href,t),exact:(t,e)=>e.href===t,is_not:(t,e)=>e.href!==t},yl=class t{get qt(){return this._instance.config}constructor(e){var i=this;this.getWebExperimentsAndEvaluateDisplayLogic=function(s){s===void 0&&(s=!1),i.getWebExperiments((r=>{t.zn("retrieved web experiments from the server"),i.Vn=new Map,r.forEach((n=>{if(n.feature_flag_key){var o;i.Vn&&(t.zn("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=i.Vn)==null||o.set(n.feature_flag_key,n));var a=i._instance.getFeatureFlag(n.feature_flag_key);ge(a)&&n.variants[a]&&i.Wn(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];t.Zn(u)&&i.Wn(n.name,l,u.transforms)}}))}),s)},this._instance=e,this._instance.onFeatureFlags((s=>{this.onFeatureFlags(s)}))}initialize(){}onFeatureFlags(e){if(this._is_bot())t.zn(bh);else if(!this.qt.disable_web_experiments){if(K(this.Vn))return this.Vn=new Map,this.loadIfEnabled(),void this.previewWebExperiment();t.zn("applying feature flags",e),e.forEach((i=>{var s;if(this.Vn&&(s=this.Vn)!=null&&s.has(i)){var r,n=this._instance.getFeatureFlag(i),o=(r=this.Vn)==null?void 0:r.get(i);n&&o!=null&&o.variants[n]&&this.Wn(o.name,n,o.variants[n].transforms)}}))}}previewWebExperiment(){var e=t.getWindowLocation();if(e!=null&&e.search){var i=nn(e?.search,"__experiment_id"),s=nn(e?.search,"__experiment_variant");i&&s&&(t.zn("previewing web experiments "+i+" && "+s),this.getWebExperiments((r=>{this.Gn(parseInt(i),s,r)}),!1,!0))}}loadIfEnabled(){this.qt.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,i,s){if(this.qt.disable_web_experiments&&!s)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!i)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.qt.token),method:"GET",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}Gn(e,i,s){var r=s.filter((n=>n.id===e));r&&r.length>0&&(t.zn("Previewing web experiment ["+r[0].name+"] with variant ["+i+"]"),this.Wn(r[0].name,i,r[0].variants[i].transforms))}static Zn(e){return!K(e.conditions)&&t.Qn(e)&&t.Jn(e)}static Qn(e){var i;if(K(e.conditions)||K((i=e.conditions)==null?void 0:i.url))return!0;var s,r,n,o=t.getWindowLocation();return!!o&&((s=e.conditions)==null||!s.url||VE[(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 i;if(K(e.conditions)||K((i=e.conditions)==null?void 0:i.utm))return!0;var s=og();if(s.utm_source){var r,n,o,a,l,u,c,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)==s.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)==s.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)==s.utm_medium,v=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==s.utm_term;return f&&p&&v&&g}return!1}static zn(e){for(var i=arguments.length,s=new Array(i>1?i-1:0),r=1;i>r;r++)s[r-1]=arguments[r];T.info("[WebExperiments] "+e,s)}Wn(e,i,s){this._is_bot()?t.zn(bh):i!=="control"?s.forEach((r=>{if(r.selector){var n;t.zn("applying transform of variant "+i+" 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)}))}})):t.zn("Control variants leave the page unmodified.")}_is_bot(){return ze&&this._instance?mg(ze,this.qt.custom_blocked_useragents):void 0}},Je=ue("[Conversations]"),ei="Conversations not available yet.",yn={featureFlags:class{constructor(t){this.Kn=!1,this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.ns=!1,this.ss=!1,this._instance=t,this.featureFlagEventHandlers=[]}get qt(){return this._instance.config}get ni(){return this._instance.persistence}os(t){return this._instance.get_property(t)}us(){var t,e;return(t=(e=this.ni)==null?void 0:e.wr(this.qt.feature_flag_cache_ttl_ms))!==null&&t!==void 0&&t}ls(){return!!this.us()&&(this.ss||this.Xn||(this.ss=!0,xe.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}hs(){var t,e=(t=this.qt.evaluation_contexts)!==null&&t!==void 0?t:this.qt.evaluation_environments;return!this.qt.evaluation_environments||this.qt.evaluation_contexts||this.ns||(xe.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.ns=!0),e!=null&&e.length?e.filter((i=>{var s=i&&typeof i=="string"&&i.trim().length>0;return s||xe.error("Invalid evaluation context found:",i,"Expected non-empty string"),s})):[]}cs(){return this.hs().length>0}initialize(){var t,e,{config:i}=this._instance,s=(t=(e=i.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(s).length){var r,n,o=(r=(n=i.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(s).filter((u=>!!s[u])).reduce(((u,c)=>(u[c]=s[c]||!1,u)),{}),l=Object.keys(o).filter((u=>a[u])).reduce(((u,c)=>(o[c]&&(u[c]=o[c]),u)),{});this.receivedFeatureFlags({featureFlags:a,featureFlagPayloads:l})}}updateFlags(t,e,i){var s=i!=null&&i.merge?this.getFlagVariants():{},r=i!=null&&i.merge?this.getFlagPayloads():{},n=S({},s,t),o=S({},r,e),a={};for(var[l,u]of Object.entries(n)){var c=typeof u=="string";a[l]={key:l,enabled:!!c||!!u,variant:c?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.Yn}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.os(Da),e=this.os(At),i=this.os(Oi);if(!i&&!e)return t||{};var s=pe({},t||{}),r=[...new Set([...Object.keys(i||{}),...Object.keys(e||{})])];for(var n of r){var o,a,l=s[n],u=e?.[n],c=P(u)?(o=l?.enabled)!==null&&o!==void 0&&o:!!u,h=P(u)?l.variant:typeof u=="string"?u:void 0,f=i?.[n],g=S({},l,{enabled:c,variant:c?h??l?.variant:void 0});c!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),f&&(g.metadata=S({},l?.metadata,{payload:f,original_payload:l==null||(a=l.metadata)==null?void 0:a.payload})),s[n]=g}return this.Kn||(xe.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:s}),this.Kn=!0),s}getFlagVariants(){var t=this.os(Di),e=this.os(At);if(!e)return t||{};for(var i=pe({},t),s=Object.keys(e),r=0;s.length>r;r++)i[s[r]]=e[s[r]];return this.Kn||(xe.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:i}),this.Kn=!0),i}getFlagPayloads(){var t=this.os(La),e=this.os(Oi);if(!e)return t||{};for(var i=pe({},t||{}),s=Object.keys(e),r=0;s.length>r;r++)i[s[r]]=e[s[r]];return this.Kn||(xe.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:i}),this.Kn=!0),i}reloadFeatureFlags(){this.es||this.qt.advanced_disable_feature_flags||this.ds||(this._instance.Li.emit("featureFlagsReloading",!0),this.ds=setTimeout((()=>{this.vs()}),5))}fs(){clearTimeout(this.ds),this.ds=void 0}ensureFlagsLoaded(){this.Yn||this.Xn||this.ds||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.es=t}vs(t){var e;if(this.fs(),!this._instance.Lr())if(this.Xn)this.ts=!0;else{var i=this.qt.token,s=this.os(Wr),r={token:i,distinct_id:this._instance.get_distinct_id(),groups:this._instance.getGroups(),$anon_distinct_id:this.$anon_distinct_id,person_properties:S({},((e=this.ni)==null?void 0:e.get_initial_props())||{},this.os(Ss)||{}),group_properties:this.os(ti),timezone:hg()};Pt(s)||P(s)||(r.$device_id=s),(t!=null&&t.disableFlags||this.qt.advanced_disable_feature_flags)&&(r.disable_flags=!0),this.cs()&&(r.evaluation_contexts=this.hs());var n=this._instance.requestRouter.endpointFor("flags","/flags/?v=2"+(this.qt.advanced_only_evaluate_survey_feature_flags?"&only_evaluate_survey_feature_flags=true":""));this.Xn=!0,this._instance._send_request({method:"POST",url:n,data:r,compression:this.qt.disable_compression?void 0:ct.Base64,timeout:this.qt.feature_flag_request_timeout_ms,callback:o=>{var a,l,u,c=!0;if(o.statusCode===200&&(this.ts||(this.$anon_distinct_id=void 0),c=!1),this.Xn=!1,!r.disable_flags||this.ts){this.rs=!c;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.ni)==null||u.register({[Ba]:h}),g?xe.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:{},c,{partialResponse:!!this.qt.advanced_only_evaluate_survey_feature_flags}),this.ts&&(this.ts=!1,this.vs()))}}})}}getFeatureFlag(t,e){var i;if(e===void 0&&(e={}),!e.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var s=this.getFeatureFlagResult(t,e);return(i=s?.variant)!==null&&i!==void 0?i:s?.enabled}}else xe.warn('getFeatureFlag for key "'+t+oa)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.rs)if(this.Yn||this.getFlags()&&this.getFlags().length>0){if(!this.ls()){var i=this.getFlagVariants(),s=t in i,r=i[t],n=this.getFlagPayloads()[t],o=String(r),a=this.os($a)||void 0,l=this.os(Xr)||void 0,u=this.os(As)||{};if(this.qt.advanced_feature_flags_dedup_per_session){var c,h=this._instance.get_session_id(),f=this.os(Ua);h&&h!==f&&(u={},(c=this.ni)==null||c.register({[As]:u,[Ua]:h}))}if((e.send_event||!("send_event"in e))&&(!(t in u)||!u[t].includes(o))){var g,p,v,m,y,w,R,N,b,x;Y(u[t])?u[t].push(o):u[t]=[o],(g=this.ni)==null||g.register({[As]:u});var C=this.getFeatureFlagDetails(t),O=[...(p=this.os(Ba))!==null&&p!==void 0?p:[]];P(r)&&O.push("flag_missing");var A={$feature_flag:t,$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.qt.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[t])||null,$feature_flag_bootstrapped_payload:((m=this.qt.bootstrap)==null||(m=m.featureFlagPayloads)==null?void 0:m[t])||null,$used_bootstrap_value:!this.rs};P(C==null||(y=C.metadata)==null?void 0:y.version)||(A.$feature_flag_version=C.metadata.version);var $,U=(w=C==null||(R=C.reason)==null?void 0:R.description)!==null&&w!==void 0?w:C==null||(N=C.reason)==null?void 0:N.code;U&&(A.$feature_flag_reason=U),C!=null&&(b=C.metadata)!=null&&b.id&&(A.$feature_flag_id=C.metadata.id),P(C?.original_variant)&&P(C?.original_enabled)||(A.$feature_flag_original_response=P(C.original_variant)?C.original_enabled:C.original_variant),C!=null&&(x=C.metadata)!=null&&x.original_payload&&(A.$feature_flag_original_payload=C==null||($=C.metadata)==null?void 0:$.original_payload),O.length&&(A.$feature_flag_error=O.join(",")),this._instance.capture("$feature_flag_called",A)}if(s){var H=n;if(!P(n))try{H=JSON.parse(n)}catch{}return{key:t,enabled:!!r,variant:typeof r=="string"?r:void 0,payload:H}}}}else xe.warn('getFeatureFlagResult for key "'+t+oa)}getRemoteConfigPayload(t,e){var i=this.qt.token,s={distinct_id:this._instance.get_distinct_id(),token:i};this.cs()&&(s.evaluation_contexts=this.hs()),this._instance._send_request({method:"POST",url:this._instance.requestRouter.endpointFor("flags","/flags/?v=2"),data:s,compression:this.qt.disable_compression?void 0:ct.Base64,timeout:this.qt.feature_flag_request_timeout_ms,callback(r){var n,o=(n=r.json)==null?void 0:n.featureFlagPayloads;e(o?.[t]||void 0)}})}isFeatureEnabled(t,e){if(e===void 0&&(e={}),!e.fresh||this.rs){if(this.Yn||this.getFlags()&&this.getFlags().length>0){var i=this.getFeatureFlag(t,e);return P(i)?void 0:!!i}xe.warn('isFeatureEnabled for key "'+t+oa)}}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter((e=>e!==t))}receivedFeatureFlags(t,e,i){if(this.ni){this.Yn=!0;var s=this.getFlagVariants(),r=this.getFlagPayloads(),n=this.getFlagsWithDetails();(function(o,a,l,u,c,h){l===void 0&&(l={}),u===void 0&&(u={}),c===void 0&&(c={});var f=(O=>{var A=O.flags;return A?(O.featureFlags=Object.fromEntries(Object.keys(A).map(($=>{var U;return[$,(U=A[$].variant)!==null&&U!==void 0?U:A[$].enabled]}))),O.featureFlagPayloads=Object.fromEntries(Object.keys(A).filter(($=>A[$].enabled)).filter(($=>{var U;return(U=A[$].metadata)==null?void 0:U.payload})).map(($=>{var U;return[$,(U=A[$].metadata)==null?void 0:U.payload]})))):xe.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),O})(o),g=f.flags,p=f.featureFlags,v=f.featureFlagPayloads;if(p){var m=o.requestId,y=o.evaluatedAt;if(Y(p)){xe.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var w={};if(p)for(var R=0;p.length>R;R++)w[p[R]]=!0;a&&a.register({[Ur]:p,[Di]:w})}else{var N=p,b=v,x=g;if(h!=null&&h.partialResponse)N=S({},l,N),b=S({},u,b),x=S({},c,x);else if(o.errorsWhileComputingFlags)if(g){var C=new Set(Object.keys(g).filter((O=>{var A;return!((A=g[O])!=null&&A.failed)})));N=S({},l,Object.fromEntries(Object.entries(N).filter((O=>{var[A]=O;return C.has(A)})))),b=S({},u,Object.fromEntries(Object.entries(b||{}).filter((O=>{var[A]=O;return C.has(A)})))),x=S({},c,Object.fromEntries(Object.entries(x||{}).filter((O=>{var[A]=O;return C.has(A)}))))}else N=S({},l,N),b=S({},u,b),x=S({},c,x);a&&a.register(S({[Ur]:Object.keys(yh(N)),[Di]:N||{},[La]:b||{},[Da]:x||{}},m?{[$a]:m}:{},y?{[Xr]:y}:{}))}}})(t,this.ni,s,r,n,i),e||(this.ss=!1),this.ps(e)}}override(t,e){e===void 0&&(e=!1),xe.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.ni)return xe.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.ni.unregister(At),this.ni.unregister(Oi),this.ps(),Zt.info("All overrides cleared");if(Y(t)){var e=mh(t);return this.ni.register({[At]:e}),this.ps(),Zt.info("Flag overrides set",{flags:t})}if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var i,s=t;if(this.Kn=!!((i=s.suppressWarning)!==null&&i!==void 0&&i),"flags"in s){if(s.flags===!1)this.ni.unregister(At),Zt.info("Flag overrides cleared");else if(s.flags){if(Y(s.flags)){var r=mh(s.flags);this.ni.register({[At]:r})}else this.ni.register({[At]:s.flags});Zt.info("Flag overrides set",{flags:s.flags})}}return"payloads"in s&&(s.payloads===!1?(this.ni.unregister(Oi),Zt.info("Payload overrides cleared")):s.payloads&&(this.ni.register({[Oi]:s.payloads}),Zt.info("Payload overrides set",{payloads:s.payloads}))),void this.ps()}if(t&&typeof t=="object")return this.ni.register({[At]:t}),this.ps(),Zt.info("Flag overrides set",{flags:t});xe.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Yn){var{flags:e,flagVariants:i}=this.gs();t(e,i)}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,i){var s,r=(this.os(Es)||[]).find((l=>l.flagKey===t)),n={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),i&&(o.$feature_enrollment_stage=i),this._instance.capture("$feature_enrollment_update",o),this.setPersonPropertiesForFlags(n,!1);var a=S({},this.getFlagVariants(),{[t]:e});(s=this.ni)==null||s.register({[Ur]:Object.keys(yh(a)),[Di]:a}),this.ps()}getEarlyAccessFeatures(t,e,i){e===void 0&&(e=!1);var s=this.os(Es),r=i?"&"+i.map((n=>"stage="+n)).join("&"):"";if(s&&!e)return t(s);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/early_access_features/?token="+this.qt.token+r),method:"GET",callback:n=>{var o,a;if(n.json){var l=n.json.earlyAccessFeatures;return(o=this.ni)==null||o.unregister(Es),(a=this.ni)==null||a.register({[Es]:l}),t(l)}}})}gs(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter((i=>e[i])),flagVariants:Object.keys(e).filter((i=>e[i])).reduce(((i,s)=>(i[s]=e[s],i)),{})}}ps(t){var{flags:e,flagVariants:i}=this.gs();this.featureFlagEventHandlers.forEach((s=>s(e,i,{errorsLoading:t})))}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var i=this.os(Ss)||{},s=t?.$set||(t!=null&&t.$set_once?{}:t),r=t?.$set_once,n={};if(r)for(var o in r)({}).hasOwnProperty.call(r,o)&&(o in i||(n[o]=r[o]));this._instance.register({[Ss]:S({},i,n,s)}),e&&this._instance.reloadFeatureFlags()}resetPersonPropertiesForFlags(){this._instance.unregister(Ss)}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var i=this.os(ti)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((s=>{i[s]=S({},i[s],t[s]),delete t[s]})),this._instance.register({[ti]:S({},i,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.os(ti)||{};this._instance.register({[ti]:S({},e,{[t]:{}})})}else this._instance.unregister(ti)}reset(){this.Yn=!1,this.Xn=!1,this.es=!1,this.ts=!1,this.rs=!1,this.$anon_distinct_id=void 0,this.fs(),this.Kn=!1}}},GE={sessionRecording:class{get qt(){return this._instance.config}get ni(){return this._instance.persistence}get started(){var t;return!((t=this.ys)==null||!t.isStarted)}get status(){var t,e;return this.bs===vs||this.bs===Fr?this.bs:(t=(e=this.ys)==null?void 0:e.status)!==null&&t!==void 0?t:this.bs}constructor(t){if(this._forceAllowLocalhostNetworkCapture=!1,this.bs=ch,this._s=void 0,this._instance=t,!this._instance.sessionManager)throw Mt.error("started without valid sessionManager"),new Error(pl+" started without valid sessionManager. This is a bug.");if(this.qt.cookieless_mode===Tt)throw new Error(pl+' cannot be used with cookieless_mode="always"')}initialize(){this.startIfEnabledOrStop()}get ws(){var t,e=!((t=this._instance.get_property(bs))==null||!t.enabled),i=!this.qt.disable_session_recording,s=this.qt.disable_session_recording||this._instance.consent.isOptedOut();return _&&e&&i&&!s}startIfEnabledOrStop(t){var e;if(!this.ws||(e=this.ys)==null||!e.isStarted){var i=!P(Object.assign)&&!P(Array.from);this.ws&&i?(this.xs(t),Mt.info("starting")):(this.bs=ch,this.stopRecording())}}xs(t){var e,i,s;this.ws&&(this.bs!==vs&&this.bs!==Fr&&(this.bs=dh),L!=null&&(e=L.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(i=L.__PosthogExtensions__)!=null&&i.initSessionRecording?this.Ss(t):(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,this.ks,(r=>{if(r)return Mt.error("could not load recorder",r);this.Ss(t)})))}stopRecording(){var t,e;(t=this._s)==null||t.call(this),this._s=void 0,(e=this.ys)==null||e.stop()}Cs(){var t,e;(t=this._s)==null||t.call(this),this._s=void 0,(e=this.ys)==null||e.discard()}Is(){var t;(t=this.ni)==null||t.unregister(Il)}Ts(t,e){if(K(t))return null;var i,s=et(t)?t:parseFloat(t);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(Mt.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):s}Es(t){if(this.ni){var e,i,s=this.ni,r=()=>{var n,o=t.sessionRecording===!1?void 0:t.sessionRecording,a=this.Ts((n=this.qt.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Ts(o?.sampleRate,"remote config sampleRate"),u=a??l;K(u)&&this.Is();var c=o?.minimumDurationMilliseconds;s.register({[bs]:S({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:S({capturePerformance:t.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:P(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(e=this._s)==null||e.call(this),this._s=(i=this._instance.sessionManager)==null?void 0:i.onSessionId(r)}}onRemoteConfig(t){return"sessionRecording"in t?t.sessionRecording===!1?(this.Es(t),void this.Cs()):(this.Es(t),void this.startIfEnabledOrStop()):(this.bs===vs&&(this.bs=Fr,Mt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var i;e===void 0&&(e="log"),(i=this.ys)!=null&&i.log?this.ys.log(t,e):Mt.warn("log called before recorder was ready")}get ks(){var t,e,i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.get_property(bs);return(i==null||(e=i.scriptConfig)==null?void 0:e.script)||"lazy-recorder"}Ms(){var t,e=this._instance.get_property(bs);if(!e)return!1;var i=(t=(typeof e=="object"?e:JSON.parse(e)).cache_timestamp)!==null&&t!==void 0?t:Date.now();return 36e5>=Date.now()-i}Ss(t){var e,i;if((e=L.__PosthogExtensions__)==null||!e.initSessionRecording)return Mt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[tg]:!0});if(this.ys||(this.ys=(i=L.__PosthogExtensions__)==null?void 0:i.initSessionRecording(this._instance),this.ys._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Ms())return this.bs===Fr||this.bs===vs?void 0:(this.bs=vs,Mt.info("persisted remote config is stale, requesting fresh config before starting"),void new ln(this._instance).load());this.bs=dh,this.ys.start(t)}onRRwebEmit(t){var e;(e=this.ys)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.ys||(e=this.ni)==null||e.register({[Yh]:!0}),(t=this.ys)==null||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.ys||(e=this.ni)==null||e.register({[Wh]:!0}),(t=this.ys)==null||t.overrideSampling()}overrideTrigger(t){var e,i;this.ys||(i=this.ni)==null||i.register({[t==="url"?Xh:Jh]:!0}),(e=this.ys)==null||e.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.ys)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var i;return!((i=this.ys)==null||!i.tryAddCustomEvent(t,e))}}},qE={autocapture:class{constructor(t){this.Ps=!1,this.Rs=null,this.Os=!1,this.instance=t,this.rageclicks=new pn(t.config.rageclick),this.Ls=null}initialize(){this.startIfEnabled()}get qt(){var t,e,i=ve(this.instance.config.autocapture)?this.instance.config.autocapture:{};return i.url_allowlist=(t=i.url_allowlist)==null?void 0:t.map((s=>new RegExp(s))),i.url_ignorelist=(e=i.url_ignorelist)==null?void 0:e.map((s=>new RegExp(s))),i}Fs(){if(this.isBrowserSupported()){if(_&&I){var t=i=>{i=i||_?.event;try{this.As(i)}catch(s){sa.error("Failed to capture event",s)}};if(ye(I,"submit",t,{capture:!0}),ye(I,"change",t,{capture:!0}),ye(I,"click",t,{capture:!0}),this.qt.capture_copied_text){var e=i=>{i=i||_?.event;try{this.As(i,ia)}catch(s){sa.error("Failed to capture copy/cut event",s)}};ye(I,"copy",e,{capture:!0}),ye(I,"cut",e,{capture:!0})}}}else sa.info("Disabling Automatic Event Collection because this browser is not supported")}startIfEnabled(){this.isEnabled&&!this.Ps&&(this.Fs(),this.Ps=!0)}onRemoteConfig(t){t.elementsChainAsString&&(this.Os=t.elementsChainAsString),this.instance.persistence&&this.instance.persistence.register({[Ia]:!!t.autocapture_opt_out}),this.Rs=!!t.autocapture_opt_out,this.startIfEnabled()}setElementSelectors(t){this.Ls=t}getElementSelectors(t){var e,i=[];return(e=this.Ls)==null||e.forEach((s=>{var r=I?.querySelectorAll(s);r?.forEach((n=>{t===n&&i.push(s)}))})),i}get isEnabled(){var t,e,i=(t=this.instance.persistence)==null?void 0:t.props[Ia];if(Pt(this.Rs)&&!ht(i)&&!this.instance.Lr())return!1;var s=(e=this.Rs)!==null&&e!==void 0?e:!!i;return!!this.instance.config.autocapture&&!s}As(t,e){if(e===void 0&&(e="$autocapture"),this.isEnabled){var i,s=ih(t);kg(s)&&(s=s.parentNode||null),e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&this.instance.config.rageclick&&(i=this.rageclicks)!=null&&i.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&(function(h,f){if(!_||gl(h))return!1;var g,p,v;if(ht(f)?(g=!!f&&rh,p=void 0):(g=(v=f?.css_selector_ignorelist)!==null&&v!==void 0?v:rh,p=f?.content_ignorelist),g===!1)return!1;var{targetElementList:m}=nh(h,!1);return!(function(y,w){if(y===!1||P(y))return!1;var R;if(y===!0)R=PE;else{if(!Y(y))return!1;if(y.length>10)return T.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;R=y.map((N=>N.toLowerCase()))}return w.some((N=>{var{safeText:b,ariaLabel:x}=N;return R.some((C=>b.includes(C)||x.includes(C)))}))})(p,m.map((y=>{var w;return{safeText:Ls(y).toLowerCase(),ariaLabel:((w=y.getAttribute("aria-label"))==null?void 0:w.toLowerCase().trim())||""}})))&&!sh(m,g)})(s,this.instance.config.rageclick)&&this.As(t,"$rageclick");var r=e===ia;if(s&&(function(h,f,g,p,v){var m,y,w,R;if(g===void 0&&(g=void 0),!_||gl(h)||(m=g)!=null&&m.url_allowlist&&!th(g.url_allowlist)||(y=g)!=null&&y.url_ignorelist&&th(g.url_ignorelist))return!1;if((w=g)!=null&&w.dom_event_allowlist){var N=g.dom_event_allowlist;if(N&&!N.some((A=>f.type===A)))return!1}var{parentIsUsefulElement:b,targetElementList:x}=nh(h,p);if(!(function(A,$){var U=$?.element_allowlist;if(P(U))return!0;var H,G=function(_e){if(U.some((Ee=>_e.tagName.toLowerCase()===Ee)))return{v:!0}};for(var q of A)if(H=G(q))return H.v;return!1})(x,g)||!sh(x,(R=g)==null?void 0:R.css_selector_allowlist))return!1;var C=_.getComputedStyle(h);if(C&&C.getPropertyValue("cursor")==="pointer"&&f.type==="click")return!0;var O=h.tagName.toLowerCase();switch(O){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 b?(v||["click"]).indexOf(f.type)>=0:(v||["click"]).indexOf(f.type)>=0&&(xl.indexOf(O)>-1||h.getAttribute("contenteditable")==="true")}})(s,t,this.qt,r,r?["copy","cut"]:void 0)){var{props:n,explicitNoCapture:o}=$E(s,{e:t,maskAllElementAttributes:this.instance.config.mask_all_element_attributes,maskAllText:this.instance.config.mask_all_text,elementAttributeIgnoreList:this.qt.element_attribute_ignorelist,elementsChainAsString:this.Os});if(o)return!1;var a=this.getElementSelectors(s);if(a&&a.length>0&&(n.$element_selectors=a),e===ia){var l,u=Ag(_==null||(l=_.getSelection())==null?void 0:l.toString()),c=t.type||"clipboard";if(!u)return!1;n.$selected_content=u,n.$copy_type=c}return this.instance.capture(e,n),!0}}}isBrowserSupported(){return It(I?.querySelectorAll)}},historyAutocapture:class{constructor(t){var e;this._instance=t,this.Ns=(_==null||(e=_.location)==null?void 0:e.pathname)||""}initialize(){this.startIfEnabled()}get isEnabled(){return this._instance.config.capture_pageview==="history_change"}startIfEnabled(){this.isEnabled&&(T.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}stop(){this.$s&&this.$s(),this.$s=void 0,T.info("History API monitoring stopped")}monitorHistoryChanges(){var t,e;if(_&&_.history){var i=this;(t=_.history.pushState)!=null&&t.__posthog_wrapped__||lh(_.history,"pushState",(s=>function(r,n,o){s.call(this,r,n,o),i.Ds("pushState")})),(e=_.history.replaceState)!=null&&e.__posthog_wrapped__||lh(_.history,"replaceState",(s=>function(r,n,o){s.call(this,r,n,o),i.Ds("replaceState")})),this.qs()}}Ds(t){try{var e,i=_==null||(e=_.location)==null?void 0:e.pathname;if(!i)return;i!==this.Ns&&this.isEnabled&&this._instance.capture(Ci,{navigation_type:t}),this.Ns=i}catch(s){T.error("Error capturing "+t+" pageview",s)}}qs(){if(!this.$s){var t=()=>{this.Ds("popstate")};ye(_,"popstate",t),this.$s=()=>{_&&_.removeEventListener("popstate",t)}}}},heatmaps:class{get qt(){return this.instance.config}constructor(t){var e;this.js=!1,this.Ps=!1,this.Hs=null,this.instance=t,this.js=!((e=this.instance.persistence)==null||!e.props[Ta]),this.rageclicks=new pn(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return ve(this.qt.capture_heatmaps)&&this.qt.capture_heatmaps.flush_interval_milliseconds&&(t=this.qt.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return K(this.qt.capture_heatmaps)?K(this.qt.enable_heatmaps)?this.js:this.qt.enable_heatmaps:this.qt.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Ps)return;ME.info("starting..."),this.Us(),this.At()}else{var t;clearInterval((t=this.Hs)!==null&&t!==void 0?t:void 0),this.Bs(),this.getAndClearBuffer()}}onRemoteConfig(t){if("heatmaps"in t){var e=!!t.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Ta]:e}),this.js=e,this.startIfEnabled()}}getAndClearBuffer(){var t=this.M;return this.M=void 0,t}zs(t){this.Mt(t.originalEvent,"deadclick")}At(){this.Hs&&clearInterval(this.Hs),this.Hs=I?.visibilityState==="visible"?setInterval(this.Zr.bind(this),this.flushIntervalMilliseconds):null}Us(){_&&I&&(this.Vs=this.Zr.bind(this),ye(_,en,this.Vs),this.Ws=t=>this.Mt(t||_?.event),ye(I,"click",this.Ws,{capture:!0}),this.Zs=t=>this.Gs(t||_?.event),ye(I,"mousemove",this.Zs,{capture:!0}),this.Qs=new tn(this.instance,iE,this.zs.bind(this)),this.Qs.startIfEnabledOrStop(),this.Js=this.At.bind(this),ye(I,Zr,this.Js),this.Ps=!0)}Bs(){var t;_&&I&&(this.Vs&&_.removeEventListener(en,this.Vs),this.Ws&&I.removeEventListener("click",this.Ws,{capture:!0}),this.Zs&&I.removeEventListener("mousemove",this.Zs,{capture:!0}),this.Js&&I.removeEventListener(Zr,this.Js),clearTimeout(this.Ks),(t=this.Qs)==null||t.stop(),this.Ps=!1)}Ys(t,e){var i=this.instance.scrollManager.scrollY(),s=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&oi(u)&&!nt(u,"body");){if(u===l)return!1;if(z(a,_?.getComputedStyle(u).position))return!0;u=Ig(u)}return!1})(ih(t),["fixed","sticky"],r);return{x:t.clientX+(n?0:s),y:t.clientY+(n?0:i),target_fixed:n,type:e}}Mt(t,e){var i;if(e===void 0&&(e="click"),!eh(t.target)&&hh(t)){var s=this.Ys(t,e);(i=this.rageclicks)!=null&&i.isRageClick(t.clientX,t.clientY,new Date().getTime())&&this.Xs(S({},s,{type:"rageclick"})),this.Xs(s)}}Gs(t){!eh(t.target)&&hh(t)&&(clearTimeout(this.Ks),this.Ks=setTimeout((()=>{this.Xs(this.Ys(t,"mousemove"))}),500))}Xs(t){if(_){var e=_.location.href,i=this.qt.custom_personal_data_properties,s=this.qt.mask_personal_data_properties?[...Vi,...i||[]]:[],r=xs(e,s,Ns);this.M=this.M||{},this.M[r]||(this.M[r]=[]),this.M[r].push(t)}}Zr(){this.M&&!Ni(this.M)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:tn,webVitalsAutocapture:class{constructor(t){var e;this.js=!1,this.Ps=!1,this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0},this.eo=()=>{clearTimeout(this.ro),this.M.metrics.length!==0&&(this._instance.capture("$web_vitals",this.M.metrics.reduce(((i,s)=>S({},i,{["$web_vitals_"+s.name+"_event"]:S({},s),["$web_vitals_"+s.name+"_value"]:s.value})),{})),this.M={url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.ht=i=>{var s,r=(s=this._instance.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0);if(P(r))Ft.error("Could not read session ID. Dropping metrics!");else{this.M=this.M||{url:void 0,metrics:[],firstMetricTimestamp:void 0};var n=this.io();P(n)||(K(i?.name)||K(i?.value)?Ft.error("Invalid metric received",i):!this.no||this.no>i.value?(this.M.url!==n&&(this.eo(),this.ro=setTimeout(this.eo,this.flushToCaptureTimeoutMs)),P(this.M.url)&&(this.M.url=n),this.M.firstMetricTimestamp=P(this.M.firstMetricTimestamp)?Date.now():this.M.firstMetricTimestamp,i.attribution&&i.attribution.interactionTargetElement&&(i.attribution.interactionTargetElement=void 0),this.M.metrics.push(S({},i,{$current_url:n,$session_id:r.sessionId,$window_id:r.windowId,timestamp:Date.now()})),this.M.metrics.length===this.allowedMetrics.length&&this.eo()):Ft.error("Ignoring metric with value >= "+this.no,i))}},this.so=()=>{if(!this.Ps){var i,s,r,n,o=L.__PosthogExtensions__;P(o)||P(o.postHogWebVitalsCallbacks)||({onLCP:i,onCLS:s,onFCP:r,onINP:n}=o.postHogWebVitalsCallbacks),i&&s&&r&&n?(this.allowedMetrics.indexOf("LCP")>-1&&i(this.ht.bind(this)),this.allowedMetrics.indexOf("CLS")>-1&&s(this.ht.bind(this)),this.allowedMetrics.indexOf("FCP")>-1&&r(this.ht.bind(this)),this.allowedMetrics.indexOf("INP")>-1&&n(this.ht.bind(this)),this.Ps=!0):Ft.error("web vitals callbacks not loaded - not starting")}},this._instance=t,this.js=!((e=this._instance.persistence)==null||!e.props[Ca]),this.startIfEnabled()}get oo(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,i=ve(this.oo)?(t=this.oo)==null?void 0:t.web_vitals_allowed_metrics:void 0;return K(i)?((e=this._instance.persistence)==null?void 0:e.props[Na])||["CLS","FCP","INP","LCP"]:i}get flushToCaptureTimeoutMs(){return(ve(this.oo)?this.oo.web_vitals_delayed_flush_ms:void 0)||5e3}get useAttribution(){var t=ve(this.oo)?this.oo.web_vitals_attribution:void 0;return t!=null&&t}get no(){var t=ve(this.oo)&&et(this.oo.__web_vitals_max_value)?this.oo.__web_vitals_max_value:uh;return t>0&&6e4>=t?uh:t}get isEnabled(){var t=Te?.protocol;if(t!=="http:"&&t!=="https:")return Ft.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=ve(this.oo)?this.oo.web_vitals:ht(this.oo)?this.oo:void 0;return ht(e)?e:this.js}startIfEnabled(){this.isEnabled&&!this.Ps&&(Ft.info("enabled, starting..."),this.lr(this.so))}onRemoteConfig(t){if("capturePerformance"in t){var e=ve(t.capturePerformance)&&!!t.capturePerformance.web_vitals,i=ve(t.capturePerformance)?t.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ca]:e}),this._instance.persistence.register({[Na]:i})),this.js=e,this.startIfEnabled()}}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.postHogWebVitalsCallbacks?t():(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.useAttribution?"web-vitals-with-attribution":"web-vitals",(s=>{s?Ft.error("failed to load script",s):t()}))}io(){var t=_?_.location.href:void 0;if(t){var e=this._instance.config.custom_personal_data_properties,i=this._instance.config.mask_personal_data_properties?[...Vi,...e||[]]:[];return xs(t,i,Ns)}Ft.error("Could not determine current URL")}}},jE={exceptionObserver:class{constructor(t){var e,i,s;this.so=()=>{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.ao&&this.qt.capture_unhandled_errors&&(this.ao=n(this.captureException.bind(this))),!this.uo&&this.qt.capture_unhandled_rejections&&(this.uo=o(this.captureException.bind(this))),!this.lo&&this.qt.capture_console_errors&&(this.lo=a(this.captureException.bind(this)))}catch(l){ps.error("failed to start",l),this.ho()}}},this._instance=t,this.co=!((e=this._instance.persistence)==null||!e.props[Ra]),this.do=new da({refillRate:(i=this._instance.config.error_tracking.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(s=this._instance.config.error_tracking.__exceptionRateLimiterBucketSize)!==null&&s!==void 0?s:10,refillInterval:1e4,Gt:ps}),this.qt=this.vo(),this.startIfEnabledOrStop()}vo(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return ve(t)?e=S({},e,t):(P(t)?this.co:t)&&(e=S({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.qt.capture_console_errors||this.qt.capture_unhandled_errors||this.qt.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(ps.info("enabled"),this.ho(),this.lr(this.so)):this.ho()}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.errorWrappingFunctions&&t(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"exception-autocapture",(s=>{if(s)return ps.error("failed to load script",s);t()}))}ho(){var t,e,i;(t=this.ao)==null||t.call(this),this.ao=void 0,(e=this.uo)==null||e.call(this),this.uo=void 0,(i=this.lo)==null||i.call(this),this.lo=void 0}onRemoteConfig(t){"autocaptureExceptions"in t&&(this.co=!!t.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ra]:this.co}),this.qt=this.vo(),this.startIfEnabledOrStop())}onConfigChange(){this.qt=this.vo()}captureException(t){var e,i,s,r=(e=t==null||(i=t.$exception_list)==null||(i=i[0])==null?void 0:i.type)!==null&&e!==void 0?e:"Exception";this.do.consumeRateLimit(r)?ps.info("Skipping exception capture because of client rate limiting.",{exception:r}):(s=this._instance.exceptions)==null||s.sendExceptionEvent(t)}},exceptions:class{constructor(t){var e,i;this.fo=[],this.po=new pa([new _a,new wa,new ya,new ma,new Sa,new Ea,new ba,new ka],(function(s){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=[],c=a.split(`
|
|
6
|
-
`),h=l;c.length>h;h++){var f=c[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,s);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 S({},w,{filename:w.filename||(R=y,R[R.length-1]||{}).filename,function:w.function||Bi});var R}))})(u)}})("web:javascript",Bb,qb)),this._instance=t,this.fo=(e=(i=this._instance.persistence)==null?void 0:i.get_property(Pa))!==null&&e!==void 0?e:[],this.mo=Kr(this.yo()),this.bo=new Aa(this.mo)}onConfigChange(){this.mo=Kr(this.yo()),this.bo.setConfig(this.mo)}onRemoteConfig(t){var e,i,s;if("errorTracking"in t){var r=(e=(i=t.errorTracking)==null?void 0:i.suppressionRules)!==null&&e!==void 0?e:[],n=(s=t.errorTracking)==null?void 0:s.captureExtensionExceptions;this.fo=r,this._instance.persistence&&this._instance.persistence.register({[Pa]:this.fo,[Oa]:n})}}get _o(){var t,e=!!this._instance.get_property(Oa),i=this._instance.config.error_tracking.captureExtensionExceptions;return(t=i??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.po.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this.mo.enabled)try{if(!ge(t)||t.trim().length===0)return void wt.warn("Ignoring exception step because message must be a non-empty string");var i=this.wo(e),{sanitizedProperties:s,droppedKeys:r}=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};var o=[];return{sanitizedProperties:Object.keys(n).reduce(((a,l)=>zb.has(l)?(o.push(l),a):(a[l]=n[l],a)),{}),droppedKeys:o}})(i);r.length>0&&wt.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.bo.add(S({[Hr]:t,[zr]:new Date().toISOString()},s))}catch(n){wt.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.xo(e)){if(this.So(e))return this.ko("Exception dropped: matched a suppression rule"),void wt.info("Skipping exception capture because a suppression rule matched");if(!this._o&&this.Co(e))return this.ko("Exception dropped: thrown by a browser extension"),void wt.info("Skipping exception capture because it was thrown by an extension");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Io(e))return this.ko("Exception dropped: thrown by the PostHog SDK"),void wt.info("Skipping exception capture because it was thrown by the PostHog SDK")}var i=this.mo.enabled&&K(t.$exception_steps)?this.To(t):t;try{var s=this._instance.capture("$exception",i,{_noTruncate:!0,_batchKey:"exceptionEvent",en:!0});return s&&this.bo.clear(),s}catch(r){return wt.error("Failed to capture exception event. Dropping this exception.",r),void this.bo.clear()}}catch(r){return void wt.error("Failed to process exception event. Ignoring this exception.",r)}}To(t){try{var e=this.bo.getAttachable();return e.length===0?t:S({},t,{$exception_steps:e})}catch(i){return wt.error("Failed to read buffered exception steps. Capturing exception without steps.",i),t}}ko(t){this.mo.enabled&&this.bo.add({[Hr]:t,[zr]:new Date().toISOString()})}wo(t){return ve(t)?S({},t):{}}yo(){var t,e;return(t=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}So(t){if(t.length===0)return!1;var e=t.reduce(((i,s)=>{var{type:r,value:n}=s;return ge(r)&&r.length>0&&i.$exception_types.push(r),ge(n)&&n.length>0&&i.$exception_values.push(n),i}),{$exception_types:[],$exception_values:[]});return this.fo.some((i=>{var s=i.values.map((r=>{var n,o=yg[r.operator],a=Y(r.value)?r.value:[r.value],l=(n=e[r.key])!==null&&n!==void 0?n:[];return a.length>0&&o(a,l)}));return i.type==="OR"?s.some(Boolean):s.every(Boolean)}))}Co(t){return t.flatMap((e=>{var i,s;return(i=(s=e.stacktrace)==null?void 0:s.frames)!==null&&i!==void 0?i:[]})).some((e=>e.filename&&e.filename.startsWith("chrome-extension://")))}Io(t){if(t.length>0){var e,i,s,r,n=(e=(i=t[0].stacktrace)==null?void 0:i.frames)!==null&&e!==void 0?e:[],o=n[n.length-1];return(s=o==null||(r=o.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&s!==void 0&&s}return!1}xo(t){return!K(t)&&Y(t)}}},HE=S({productTours:class{get ni(){return this._instance.persistence}constructor(t){this.Eo=null,this.Mo=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){"productTours"in t&&(this.ni&&this.ni.register({[xa]:!!t.productTours}),this.loadIfEnabled())}loadIfEnabled(){var t,e;this.Eo||(t=this._instance).config.disable_product_tours||(e=t.persistence)==null||!e.get_property(xa)||this.lr((()=>this.Po()))}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.generateProductTours?t():(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"product-tours",(s=>{s?gh.error("Could not load product tours script",s):t()}))}Po(){var t;!this.Eo&&(t=L.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.Eo=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!Y(this.Mo)||e){var i=this.ni;if(i){var s=i.props[Br];if(Y(s)&&!e)return this.Mo=s,void t(s,{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 gh.error(o),void t([],{isLoaded:!1,error:o})}var a=Y(r.json.product_tours)?r.json.product_tours:[];this.Mo=a,i&&i.register({[Br]:a}),t(a,{isLoaded:!0})}})}else t(this.Mo,{isLoaded:!0})}getActiveProductTours(t){K(this.Eo)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Eo.getActiveProductTours(t)}showProductTour(t){var e;(e=this.Eo)==null||e.showTourById(t)}previewTour(t){this.Eo?this.Eo.previewTour(t):this.lr((()=>{var e;this.Po(),(e=this.Eo)==null||e.previewTour(t)}))}dismissProductTour(){var t;(t=this.Eo)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Eo)==null||t.nextStep()}previousStep(){var t;(t=this.Eo)==null||t.previousStep()}clearCache(){var t;this.Mo=null,(t=this.ni)==null||t.unregister(Br)}resetTour(t){var e;(e=this.Eo)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.Eo)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.Eo)==null||e.cancelPendingTour(t)}}},yn),zE={siteApps:class{constructor(t){this._instance=t,this.Ro=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Oo(t,e){if(e){var i=this.globalsForEvent(e);this.Ro.push(i),this.Ro.length>1e3&&(this.Ro=this.Ro.slice(10))}}get siteAppLoaders(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Oo.bind(this));this.Lo=()=>{t(),this.Ro=[],this.Lo=void 0}}}globalsForEvent(t){var e,i,s,r,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var[h,f]of Object.entries(c))l[h]={id:u[h],type:h,properties:f};var{$set_once:g,$set:p}=t;return{event:S({},Sh(t,UE),{properties:S({},t.properties,p?{$set:S({},(e=(i=t.properties)==null?void 0:i.$set)!==null&&e!==void 0?e:{},p)}:{},g?{$set_once:S({},(s=(r=t.properties)==null?void 0:r.$set_once)!==null&&s!==void 0?s:{},g)}:{}),elements_chain:(n=(o=t.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=t.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}setupSiteApp(t){var e=this.apps[t.id],i=()=>{var o;!e.errored&&this.Ro.length&&(Ut.info("Processing "+this.Ro.length+" events for site app with id "+t.id),this.Ro.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.Lo)==null||o.call(this))},s=!1,r=o=>{e.errored=!o,e.loaded=!0,Ut.info("Site app with id "+t.id+" "+(o?"loaded":"errored")),s&&i()};try{var{processEvent:n}=t.init({posthog:this._instance,callback(o){r(o)}});n&&(e.processEvent=n),s=!0}catch(o){Ut.error(fh+t.id,o),r(!1)}if(s&&e.loaded)try{i()}catch(o){Ut.error("Error while processing buffered events PostHog app with config id "+t.id,o),e.errored=!0}}Fo(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var i of t)this.setupSiteApp(i)}Ao(t){if(Object.keys(this.apps).length!==0){var e=this.globalsForEvent(t);for(var i of Object.values(this.apps))try{i.processEvent==null||i.processEvent(e)}catch(s){Ut.error("Error while processing event "+t.event+" for site app "+i.id,s)}}}onRemoteConfig(t){var e,i,s,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.Fo(),void this._instance.on("eventCaptured",(l=>this.Ao(l)))):void Ut.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((i=this.Lo)==null||i.call(this),(s=t.siteApps)!=null&&s.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,(c=>{if(c)return Ut.error(fh+l,c)}))};for(var{id:o,url:a}of t.siteApps)n(o)}else Ut.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},KE={tracingHeaders:class{constructor(t){this.No=void 0,this.$o=void 0,this.so=()=>{var e,i,s=this.Do()||[];P(this.No)&&((e=L.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null||e._patchXHR(s,this._instance.get_distinct_id(),this._instance.sessionManager)),P(this.$o)&&((i=L.__PosthogExtensions__)==null||(i=i.tracingHeadersPatchFns)==null||i._patchFetch(s,this._instance.get_distinct_id(),this._instance.sessionManager))},this._instance=t}initialize(){this.startIfEnabledOrStop()}lr(t){var e,i;(e=L.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns&&t(),(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,"tracing-headers",(s=>{if(s)return FE.error("failed to load script",s);t()}))}Do(){var t;return(t=this._instance.config.addTracingHeaders)!==null&&t!==void 0?t:this._instance.config.__add_tracing_headers}startIfEnabledOrStop(){var t,e;this.Do()?this.lr(this.so):((t=this.No)==null||t.call(this),(e=this.$o)==null||e.call(this),this.No=void 0,this.$o=void 0)}}},WE=S({surveys:class{get qt(){return this._instance.config}constructor(t){this.qo=void 0,this._surveyManager=null,this.jo=!1,this.Ho=[],this.Uo=null,this._instance=t,this._surveyEventReceiver=null}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this.qt.disable_surveys){var e=t.surveys;if(K(e))return ee.warn("Flags not loaded yet. Not loading surveys.");var i=Y(e);this.qo=i?e.length>0:e,ee.info("flags response received, isSurveysEnabled: "+this.qo),this.loadIfEnabled()}}reset(){localStorage.removeItem("lastSeenSurveyDate");for(var t=[],e=0;e<localStorage.length;e++){var i=localStorage.key(e);(i!=null&&i.startsWith(ul)||i!=null&&i.startsWith("inProgressSurvey_"))&&t.push(i)}t.forEach((s=>localStorage.removeItem(s)))}loadIfEnabled(){if(!this._surveyManager)if(this.jo)ee.info("Already initializing surveys, skipping...");else if(this.qt.disable_surveys)ee.info(ph);else if(this.qt.cookieless_mode&&this._instance.consent.isOptedOut())ee.info("Not loading surveys in cookieless mode without consent.");else{var t=L?.__PosthogExtensions__;if(t){if(!P(this.qo)||this.qt.advanced_enable_surveys){var e=this.qo||this.qt.advanced_enable_surveys;this.jo=!0;try{var i=t.generateSurveys;if(i)return void this.Bo(i,e);var s=t.loadExternalDependency;if(!s)return void this.zo(Tl);s(this._instance,"surveys",(r=>{r||!t.generateSurveys?this.zo("Could not load surveys script",r):this.Bo(t.generateSurveys,e)}))}catch(r){throw this.zo("Error initializing surveys",r),r}finally{this.jo=!1}}}else ee.error("PostHog Extensions not found.")}}Bo(t,e){this._surveyManager=t(this._instance,e),this._surveyEventReceiver=new ml(this._instance),ee.info("Surveys loaded successfully"),this.Vo({isLoaded:!0})}zo(t,e){ee.error(t,e),this.Vo({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ho.push(t),this._surveyManager&&this.Vo({isLoaded:!0}),()=>{this.Ho=this.Ho.filter((e=>e!==t))}}getSurveys(t,e){if(e===void 0&&(e=!1),this.qt.disable_surveys)return ee.info(ph),t([]);var i,s=this._instance.get_property(Fa);if(s&&!e)return t(s,{isLoaded:!0});typeof Promise<"u"&&this.Uo?this.Uo.then((r=>{var{surveys:n,context:o}=r;return t(n,o)})):(typeof Promise<"u"&&(this.Uo=new Promise((r=>{i=r}))),this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/surveys/?token="+this.qt.token),method:"GET",timeout:this.qt.surveys_request_timeout_ms,callback:r=>{var n;this.Uo=null;var o=r.statusCode;if(o!==200||!r.json){var a="Surveys API could not be loaded, status: "+o;ee.error(a);var l={isLoaded:!1,error:a};return t([],l),void(i==null||i({surveys:[],context:l}))}var u,c=r.json.surveys||[],h=c.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({[Fa]:c});var f={isLoaded:!0};t(c,f),i?.({surveys:c,context:f})}}))}Vo(t){for(var e of this.Ho)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(i){ee.error("Error in survey callback",i)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!K(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ee.warn("init was not called")}Wo(t){var e=null;return this.getSurveys((i=>{var s;e=(s=i.find((r=>r.id===t)))!==null&&s!==void 0?s:null})),e}Zo(t){if(K(this._surveyManager))return{eligible:!1,reason:na};var e=typeof t=="string"?this.Wo(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(K(this._surveyManager))return ee.warn("init was not called"),{visible:!1,disabledReason:na};var e=this.Zo(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return K(this._surveyManager)?(ee.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:na})):new Promise((i=>{this.getSurveys((s=>{var r,n=(r=s.find((a=>a.id===t)))!==null&&r!==void 0?r:null;if(n){var o=this.Zo(n);i({visible:o.eligible,disabledReason:o.reason})}else i({visible:!1,disabledReason:"Survey not found"})}),e)}))}renderSurvey(t,e,i){var s;if(K(this._surveyManager))ee.warn("init was not called");else{var r=typeof t=="string"?this.Wo(t):t;if(r!=null&&r.id)if(EE.includes(r.type)){var n=I?.querySelector(e);if(n)return(s=r.appearance)!=null&&s.surveyPopupDelaySeconds?(ee.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds"),void setTimeout((()=>{var o,a;ee.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,i),ee.info("Survey "+r.id+" rendered")}),1e3*r.appearance.surveyPopupDelaySeconds)):void this._surveyManager.renderSurvey(r,n,i);ee.warn("Survey element not found")}else ee.warn("Surveys of type "+r.type+" cannot be rendered in the app");else ee.warn("Survey not found")}}displaySurvey(t,e){var i;if(K(this._surveyManager))ee.warn("init was not called");else{var s=this.Wo(t);if(s){var r=s;if((i=s.appearance)!=null&&i.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=S({},s,{appearance:S({},s.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==Ja.Popover&&e.initialResponses&&ee.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.canRenderSurvey(s);if(!n.visible)return void ee.warn("Survey is not eligible to be displayed: ",n.disabledReason)}e.displayType!==Ja.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else ee.warn("Survey not found")}}cancelPendingSurvey(t){K(this._surveyManager)?ee.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload()}}},yn),YE={toolbar:class{constructor(t){this.instance=t}Go(t){L.ph_toolbar_state=t}Qo(){var t;return(t=L.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,i){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),i===void 0&&(i=void 0),ig(this.instance.config)||!_||!I)return!1;t=t??_.location,i=i??_.history;try{if(!e){try{_.localStorage.setItem("test","test"),_.localStorage.removeItem("test")}catch{return!1}e=_?.localStorage}var s,r=BE||on(t.hash,"__posthog")||on(t.hash,"state"),n=r?Md((()=>JSON.parse(atob(decodeURIComponent(r)))))||Md((()=>JSON.parse(decodeURIComponent(r)))):null;return n&&n.action==="ph_authorize"?((s=n).source="url",s&&Object.keys(s).length>0&&(n.desiredHash?t.hash=n.desiredHash:i?i.replaceState(i.state,"",t.pathname+t.search):t.hash="")):((s=JSON.parse(e.getItem(vh)||"{}")).source="localstorage",delete s.userIntent),!(!s.token||this.instance.config.token!==s.token||(this.loadToolbar(s),0))}catch{return!1}}Jo(t){var e=L.ph_load_toolbar||L.ph_load_editor;!K(e)&&It(e)?e(t,this.instance):_h.warn("No toolbar load function found")}loadToolbar(t){var e=!(I==null||!I.getElementById(Qh));if(!_||e)return!1;var i=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,s=S({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},i?{instrument:!1}:{});if(_.localStorage.setItem(vh,JSON.stringify(S({},s,{source:void 0}))),this.Qo()===2)this.Jo(s);else if(this.Qo()===0){var r;this.Go(1),(r=L.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",(n=>{if(n)return _h.error("[Toolbar] Failed to load",n),void this.Go(0);this.Go(2),this.Jo(s)})),ye(_,"turbolinks:load",(()=>{this.Go(0),this.loadToolbar(s)}))}return!0}Ko(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,i){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),i===void 0&&(i=void 0),this.maybeLoadToolbar(t,e,i)}}},XE=S({experiments:yl},yn),JE={conversations:class{constructor(t){this.Yo=void 0,this._conversationsManager=null,this.Xo=!1,this.ea=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations){var e=t.conversations;K(e)||(ht(e)?this.Yo=e:(this.Yo=e.enabled,this.ea=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.Yo=void 0,this.ea=null}loadIfEnabled(){if(!(this._conversationsManager||this.Xo||this._instance.config.disable_conversations||ig(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=L?.__PosthogExtensions__;if(t&&!P(this.Yo)&&this.Yo)if(this.ea&&this.ea.token){this.Xo=!0;try{var e=t.initConversations;if(e)return this.ta(e),void(this.Xo=!1);var i=t.loadExternalDependency;if(!i)return void this.ra(Tl);i(this._instance,"conversations",(s=>{s||!t.initConversations?this.ra("Could not load conversations script",s):this.ta(t.initConversations),this.Xo=!1}))}catch(s){this.ra("Error initializing conversations",s),this.Xo=!1}}else Je.error("Conversations enabled but missing token in remote config.")}}ta(t){if(this.ea)try{this._conversationsManager=t(this.ea,this._instance),Je.info("Conversations loaded successfully")}catch(e){this.ra("Error completing conversations initialization",e)}else Je.error("Cannot complete initialization: remote config is null")}ra(t,e){Je.error(t,e),this._conversationsManager=null,this.Xo=!1}show(){this._conversationsManager?this._conversationsManager.show():Je.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Yo===!0&&!Pt(this._conversationsManager)}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,i){var s=this;return Qe((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,e,i):(Je.warn(ei),null)}))()}getMessages(t,e){var i=this;return Qe((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Je.warn(ei),null)}))()}markAsRead(t){var e=this;return Qe((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Je.warn(ei),null)}))()}getTickets(t){var e=this;return Qe((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Je.warn(ei),null)}))()}requestRestoreLink(t){var e=this;return Qe((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Je.warn(ei),null)}))()}restoreFromToken(t){var e=this;return Qe((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Je.warn(ei),null)}))()}restoreFromUrlToken(){var t=this;return Qe((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Je.warn(ei),null)}))()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}ln(){var t;(t=this._conversationsManager)==null||t.setIdentity()}hn(){var t;(t=this._conversationsManager)==null||t.clearIdentity()}}},QE={logs:class{constructor(t){var e;this.ia=!1,this.na=!1,this.Gt=ue("[logs]"),this.sa=[],this.oa=0,this.aa=0,this.ua=!1,this._instance=t,this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.ia=!0)}initialize(){this.loadIfEnabled()}onRemoteConfig(t){var e,i=(e=t.logs)==null?void 0:e.captureConsoleLogs;!K(i)&&i&&(this.ia=!0,this.loadIfEnabled())}reset(){this.sa=[],this.qr&&(clearTimeout(this.qr),this.qr=void 0),this.oa=0,this.aa=0,this.ua=!1}loadIfEnabled(){if(this.ia&&!this.na){var t=L?.__PosthogExtensions__;if(t){var e=t.loadExternalDependency;e?e(this._instance,"logs",(i=>{var s;i||(s=t.logs)==null||!s.initializeLogs?this.Gt.error("Could not load logs script",i):(t.logs.initializeLogs(this._instance),this.na=!0)})):this.Gt.error(Tl)}else this.Gt.error("PostHog Extensions not found.")}}captureLog(t){var e,i,s,r,n,o;if(this._instance.is_capturing())if(t&&t.body){var a=(e=(i=this._instance.config.logs)==null?void 0:i.flushIntervalMs)!==null&&e!==void 0?e:3e3,l=(s=(r=this._instance.config.logs)==null?void 0:r.maxLogsPerInterval)!==null&&s!==void 0?s:1e3,u=Date.now();if(a>u-this.aa||(this.aa=u,this.oa=0,this.ua=!1),l>this.oa){this.oa++;var c=(function(h,f){var g=h.level||"info",{text:p,number:v}=Gh[g]||Lb,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.screenName&&(y["screen.name"]=f.screenName),f.appState&&(y["app.state"]=f.appState),f.activeFeatureFlags&&f.activeFeatureFlags.length>0&&(y.feature_flags=f.activeFeatureFlags);var w=S({},y,h.attributes||{}),R={timeUnixNano:m,observedTimeUnixNano:m,severityNumber:v,severityText:p,body:{stringValue:h.body},attributes:Ld(w)};return h.trace_id&&(R.traceId=h.trace_id),h.span_id&&(R.spanId=h.span_id),P(h.trace_flags)||(R.flags=h.trace_flags),R})(t,this.la());this.sa.push({record:c}),((n=(o=this._instance.config.logs)==null?void 0:o.maxBufferSize)!==null&&n!==void 0?n:100)>this.sa.length?this.ha():this.flushLogs()}else this.ua||(this.Gt.warn("captureLog dropping logs: exceeded "+l+" logs per "+a+"ms"),this.ua=!0)}else this.Gt.warn("captureLog requires a body")}get logger(){return this.ca||(this.ca={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.ca}flushLogs(t){if(this.qr&&(clearTimeout(this.qr),this.qr=void 0),this.sa.length!==0){var e=this.sa;this.sa=[];var i=this._instance.config.logs,s=S({"service.name":i?.serviceName||"unknown_service"},i?.environment&&{"deployment.environment":i.environment},i?.serviceVersion&&{"service.version":i.serviceVersion},i?.resourceAttributes),r=(function(o,a,l,u){return{resourceLogs:[{resource:{attributes:Ld(a)},scopeLogs:[{scope:{name:l,version:u},logRecords:o}]}]}})(e.map((o=>o.record)),s,De.LIB_NAME,De.LIB_VERSION),n=this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token);this._instance.Bi({method:"POST",url:n,data:r,compression:"best-available",batchKey:"logs",transport:t})}}ha(){var t,e;this.qr||(this.qr=setTimeout((()=>{this.qr=void 0,this.flushLogs()}),(t=(e=this._instance.config.logs)==null?void 0:e.flushIntervalMs)!==null&&t!==void 0?t:3e3))}la(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var{sessionId:i}=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0);e.sessionId=i}if(L!=null&&(t=L.location)!=null&&t.href&&(e.currentUrl=L.location.href),this._instance.featureFlags){var s=this._instance.featureFlags.getFlags();s&&s.length>0&&(e.activeFeatureFlags=s)}return e}}},ZE=S({},yn,GE,qE,jE,HE,zE,WE,KE,YE,XE,JE,QE);ri.__defaultExtensionClasses=S({},ZE);qe=(Eh=Rs[xi]=new ri,(function(){function t(){t.done||(t.done=!0,Sg=!1,oe(Rs,(function(e){e._dom_loaded()})))}I!=null&&I.addEventListener?I.readyState==="complete"?t():ye(I,"DOMContentLoaded",t,{capture:!1}):_&&T.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),Eh)});var xg={};Sn(xg,{Posthog:()=>Nl});var ai,Nl,Ng=Fe(()=>{"use strict";Cg();Zi();ts();ai=class ai{constructor(e,i=!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 i=`ph_${e}_posthog`,s=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==i);if(s.length===0)return;let r=window.location.hostname,n=r.split("."),o=n.length>=2?`.${n.slice(-2).join(".")}`:r;s.forEach(a=>{[o,r,""].forEach(u=>{let c=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${c}; 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:i,config:s={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}this.cleanupStalePosthogCookies(e);let r=i||Ec();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:bc,autocapture:!0,capture_pageview:"history_change",session_recording:{recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,maskAllInputs:!0,...s.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=Sc.some(u=>a.endsWith(`.${u}`)||a===u);return l||this.log("init | before_send blocked event from disallowed host",{currentHost:a}),l?o:null},...s};qe.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,i={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{let s=this.has_identified&&qe.get_distinct_id()===e;e&&!s?(this.log("identifyEvent | identifying user",{user_id:e,traits:i}),qe.identify(e,{...i,client_id:e}),this.has_identified=!0):this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e})}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),qe.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:i,language:s,country_of_residence:r})=>{if(!(!this.has_initialized||!e))try{let n=qe.get_property("$stored_person_properties")??{},o={};n.client_id||(o.client_id=e),i&&n.is_internal===void 0&&(o.is_internal=ur(i)),s&&!n.language&&(o.language=s),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}),qe.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,i)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:i}),qe.capture(e,i)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let i=qe.isFeatureEnabled(e);return this.log("isFeatureEnabled",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to check feature flag",i);return}};this.getFeatureFlag=e=>{if(this.has_initialized)try{let i=qe.getFeatureFlag(e);return this.log("getFeatureFlag",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag",i);return}};this.getFeatureFlagPayload=e=>{if(this.has_initialized)try{let i=qe.getFeatureFlagResult(e)?.payload;return this.log("getFeatureFlagPayload",{key:e,result:i}),i}catch(i){console.error("Posthog: Failed to get feature flag payload",i);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let e=qe.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 i=qe.onFeatureFlags(e);return typeof i=="function"?i:()=>{}}catch(i){return console.error("Posthog: Failed to subscribe to feature flags",i),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),qe.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=i,this.init()}};ai.getPosthogInstance=(e,i=!1)=>(ai._instance||(ai._instance=new ai(e,i)),ai._instance);Nl=ai});var t0={};Sn(t0,{Analytics:()=>Dg});yo();Zi();ts();var _y=4320*60*60,Wt=class Wt{constructor(e,i,s=!1){this.analytics=new pi;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 i=window.location.hostname,n=["webflow.io"].some(u=>i.endsWith(u))?i:i.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 c=Array.from(u,h=>h.toString(16).padStart(2,"0")).join("");o=`${c.slice(0,8)}-${c.slice(8,12)}-${c.slice(12,16)}-${c.slice(16,20)}-${c.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=${_y}; SameSite=Lax${l}`}catch(i){console.warn("RudderStack: Failed to set anonymous ID cookie",i)}};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:bo});try{this.setCookieIfNotExists(),this.analytics.load(e,bo,{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(i){console.error("RudderStack: Failed to initialize",i)}};this.identifyEvent=(e,i)=>{if(!this.has_initialized){console.warn("RudderStack: Cannot identify - not initialized");return}let s=this.getUserId();if(!s||s!==e)try{this.log("identifyEvent | identifying user",{user_id:e,traits:i}),this.analytics.identify(e,i||{}),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,i="Deriv App",s,r)=>{if(!(!this.has_initialized||e===this.current_page))try{let n={...s&&{user_id:s},...r};this.log("pageView | tracking page view",{platform:i,current_page:e,properties:n}),this.analytics.page(i,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,i)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:i}),this.analytics.track(e,i)}catch(s){console.warn("RudderStack: Failed to track event",s)}};this.onLoadedCallback=i,this.debug=s,this.init(e)}};Wt.getRudderStackInstance=(e,i,s=!1)=>(Wt._instance||(Wt._instance=new Wt(e,i,s)),Wt._instance);var cr=Wt;var dr="cached_analytics_events",hr="cached_analytics_page_views",Pc=(t,e)=>{try{let i=localStorage.getItem(dr),s=i?JSON.parse(i):[];s.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(dr,JSON.stringify(s))}catch(i){console.warn("Analytics: Failed to cache event",i)}},Oc=(t,e)=>{try{let i=localStorage.getItem(hr),s=i?JSON.parse(i):[];s.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(hr,JSON.stringify(s))}catch(i){console.warn("Analytics: Failed to cache page view",i)}},Cc=()=>{try{let t=localStorage.getItem(dr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached events",t)}return[]},xc=()=>{try{let t=localStorage.getItem(hr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached pages",t)}return[]},Nc=()=>{try{localStorage.removeItem(dr)}catch(t){console.warn("Analytics: Failed to clear cached events",t)}},Dc=()=>{try{localStorage.removeItem(hr)}catch(t){console.warn("Analytics: Failed to clear cached page views",t)}};ts();function e0(t){let e=t?.debug??!1,i=Dt("",()=>e),s,r,n,o={},a={},l=[],u=[],c=!1,h=()=>{if(!c&&r?.has_initialized){c=!0;try{let k=Cc();k.length>0&&(i(`processStorageCache | replaying ${k.length} cached event(s)`,k),k.forEach(F=>{let B=Kt(F.properties);r?.track(F.name,B)}),Nc());let M=xc();M.length>0&&(i(`processStorageCache | replaying ${M.length} cached page view(s)`,M),M.forEach(F=>{r?.pageView(F.name,"Deriv App",N(),F.properties)}),Dc())}catch(k){console.warn("Analytics: Failed to process storage cache",k)}}},f=()=>{i("onSdkLoaded | RudderStack SDK loaded"),h(),u.length>0&&i(`onSdkLoaded | flushing ${u.length} pending identify call(s)`),u.forEach(({userId:k,traits:M})=>{k&&r?.identifyEvent(k,M)}),u=[]},g=async({growthbookKey:k,growthbookDecryptionKey:M,rudderstackKey:F,growthbookOptions:B,posthogOptions:Z,debug:ce})=>{var se,me;ce!==void 0&&(e=ce),i("initialise | starting analytics initialization",{rudderstack:!!F,growthbook:!!k,posthog:!!Z});try{let Pe=B?.attributes?.country||(k?await Ic():void 0);if(F&&(i("initialise | initializing RudderStack"),r=cr.getRudderStackInstance(F,f,e)),B?.attributes&&Object.keys(B.attributes).length>0){let j=B.attributes,ft=r?.getAnonymousId();o={...o,country:Pe,...j.user_language&&{user_language:j.user_language},...j.account_type&&{account_type:j.account_type},...j.app_id&&{app_id:j.app_id},...j.residence_country&&{residence_country:j.residence_country},...j.device_type&&{device_type:j.device_type},...j.url&&{url:j.url},...j.email_hash&&{email_hash:j.email_hash},...j.network_type&&{network_type:j.network_type},...j.network_rtt&&{network_rtt:j.network_rtt},...j.network_downlink&&{network_downlink:j.network_downlink},...j.account_currency&&{account_currency:j.account_currency},...j.account_mode&&{account_mode:j.account_mode},loggedIn:!!j.loggedIn,...j.user_id&&!es(j.user_id)&&{user_id:j.user_id},...ft&&{anonymous_id:ft}}}B??(B={}),B.attributes??(B.attributes={});let ke=r?.getAnonymousId();if((se=B.attributes).id??(se.id=ke),(me=B.attributes).country??(me.country=Pe),k){i("initialise | initializing GrowthBook");let{Growthbook:j}=await Promise.resolve().then(()=>(Id(),Ad));s=j.getGrowthBookInstance(k,M,B,e),i("initialise | GrowthBook initialized");let ft=setInterval(()=>{Object.keys(a).length>0?clearInterval(ft):a=m("tracking-buttons-config",{})},1e3)}if(Z){i("initialise | initializing PostHog");let{Posthog:j}=await Promise.resolve().then(()=>(Ng(),xg));n=j.getPosthogInstance(Z,e),i("initialise | PostHog initialized")}i("initialise | analytics initialization complete")}catch(Pe){console.warn("Analytics: Failed to initialize",Pe)}},p=k=>{i("setAttributes | received attributes",k);let{user_id:M,...F}=k,B=M??N();if(s){let Z={...F};M&&!es(M)&&(Z.user_id=M),B&&(Z.id=B,Z.user_id=B),i("setAttributes | called GrowthBook setAttributes",Z),s.setAttributes(Z)}o={...o,...Object.fromEntries(Object.entries(F).filter(([,Z])=>Z!==void 0)),...M!==void 0&&!es(M)&&{user_id:M}},i("setAttributes | updated core_data",o)},v=k=>s?.getFeatureState(k)?.experimentResult?.name,m=(k,M)=>s?.getFeatureValue(k,M),y=async()=>await s?.getStatus(),w=k=>s?.isOn(k),R=k=>s?.setUrl(k),N=()=>{let k=r?.getUserId()||"";return k&&!es(k)?k:""},Se={initialise:g,setAttributes:p,identifyEvent:(k,M)=>{let F=k||N();if(!F){i("identifyEvent | skipped \u2014 no user_id available");return}i("identifyEvent | called",{user_id:F,traits:M});let B=me=>{if(!me)return me;let{email:Pe,...ke}=me;return{...ke,...Pe&&{is_internal:ur(Pe)}}},Z=M?.rudderstack!==void 0||M?.posthog!==void 0,ce,se;if(Z){let{rudderstack:me,posthog:Pe,...ke}=M;ce=B({...ke,...me}),se=B({...ke,...Pe})}else ce=B(M),se=B(M);r&&(r.has_initialized?(i("identifyEvent | calling RudderStack identify",{user_id:F,traits:ce}),r.identifyEvent(F,ce)):u.some(me=>me.userId===F)||(i("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:F}),u.push({userId:F,traits:ce}))),n?.has_initialized&&(i("identifyEvent | calling PostHog identify",{user_id:F,traits:se}),n.identifyEvent(F,se))},backfillPersonProperties:({user_id:k,email:M,language:F,country_of_residence:B})=>{i("backfillPersonProperties | called",{user_id:k}),n?.has_initialized?(i("backfillPersonProperties | backfilling person properties in PostHog",{user_id:k}),n.backfillPersonProperties({user_id:k,email:M,language:F,country_of_residence:B})):i("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:v,getFeatureValue:m,getGrowthbookStatus:y,isFeatureOn:w,setUrl:R,getId:N,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(k,M)=>{let F=N();i("trackEvent | called",{event:k,analytics_data:M,userId:F,core_data:o});let B={...o,...M,...F&&!o.user_id&&{user_id:F}};if(i("trackEvent | built payload",{event:k,final_payload:B}),!(!(k in a)||a[k])){i("trackEvent | skipped \u2014 event disabled by tracking_config",{event:k});return}let ce=r?.has_initialized;if(!navigator.onLine||!ce)ce?(i("trackEvent | offline \u2014 caching event to memory",{event:k}),l.push({event:k,payload:B})):(i("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:k}),Pc(k,B));else{l.length>0&&(i(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(me=>{let Pe=Kt(me.payload);r?.track(me.event,Pe)}),l=[]);let se=Kt(B);i("trackEvent | sending event to RudderStack",{event:k,payload:se}),r?.track(k,se)}if(n?.has_initialized){let se=Kt(Rc(B));i("trackEvent | sending event to PostHog",{event:k,payload:se}),n.capture(k,se)}},getInstances:()=>({ab:s,tracking:r,posthog:n}),pageView:(k,M="Deriv App",F)=>{let B=N();i("pageView | called",{current_page:k,platform:M,properties:F,userId:B}),r?.has_initialized?(i("pageView | sending page view to RudderStack",{current_page:k,platform:M}),r.pageView(k,M,B,F)):(i("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:k}),Oc(k,{platform:M,...F}))},reset:()=>{i("reset | resetting all providers"),r?.has_initialized&&(i("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(i("reset | resetting PostHog"),n.reset())},isPosthogFeatureEnabled:k=>n?.isFeatureEnabled(k),getPosthogFeatureFlag:k=>n?.getFeatureFlag(k),getPosthogFeatureFlagPayload:k=>n?.getFeatureFlagPayload(k),getPosthogAllFlags:()=>n?.getAllFlags()??{},onPosthogFeatureFlags:k=>n?.onFeatureFlags(k)??(()=>{}),reloadPosthogFeatureFlags:()=>n?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=Se),Se}var Dg=e0();return Hg(t0);})();
|
|
2
|
+
"use strict";var DerivAnalytics=(()=>{var br=Object.defineProperty;var $p=Object.getOwnPropertyDescriptor;var Fp=Object.getOwnPropertyNames;var Mp=Object.prototype.hasOwnProperty;var Bp=(t,e,s)=>e in t?br(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var et=(t,e,s)=>()=>{if(s)throw s[0];try{return t&&(e=t(t=0)),e}catch(i){throw s=[i],i}};var ho=(t,e)=>{for(var s in e)br(t,s,{get:e[s],enumerable:!0})},Up=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of Fp(e))!Mp.call(t,r)&&r!==s&&br(t,r,{get:()=>e[r],enumerable:!(i=$p(e,r))||i.enumerable});return t};var Vp=t=>Up(br({},"__esModule",{value:!0}),t);var we=(t,e,s)=>Bp(t,typeof e!="symbol"?e+"":e,s);function Pe(t){return t!=null&&typeof t=="object"&&t["@@functional/placeholder"]===!0}function Ft(t){return function e(s){return arguments.length===0||Pe(s)?e:t.apply(this,arguments)}}function Xt(t){return function e(s,i){switch(arguments.length){case 0:return e;case 1:return Pe(s)?e:Ft(function(r){return t(s,r)});default:return Pe(s)&&Pe(i)?e:Pe(s)?Ft(function(r){return t(r,i)}):Pe(i)?Ft(function(r){return t(s,r)}):t(s,i)}}}function Zo(t){return function e(s,i,r){switch(arguments.length){case 0:return e;case 1:return Pe(s)?e:Xt(function(n,o){return t(s,n,o)});case 2:return Pe(s)&&Pe(i)?e:Pe(s)?Xt(function(n,o){return t(n,i,o)}):Pe(i)?Xt(function(n,o){return t(s,n,o)}):Ft(function(n){return t(s,i,n)});default:return Pe(s)&&Pe(i)&&Pe(r)?e:Pe(s)&&Pe(i)?Xt(function(n,o){return t(n,o,r)}):Pe(s)&&Pe(r)?Xt(function(n,o){return t(n,i,o)}):Pe(i)&&Pe(r)?Xt(function(n,o){return t(s,n,o)}):Pe(s)?Ft(function(n){return t(n,i,r)}):Pe(i)?Ft(function(n){return t(s,n,r)}):Pe(r)?Ft(function(n){return t(s,i,n)}):t(s,i,r)}}}function Er(t,e){return Object.prototype.hasOwnProperty.call(e,t)}function Eu(t){return Object.prototype.toString.call(t)==="[object Object]"}function Hp(t,e){var s=t<0?e.length+t:t;return e[s]}function qp(t){return new RegExp(t.source,t.flags?t.flags:(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":"")+(t.dotAll?"s":""))}function ic(t,e,s){if(s||(s=new Kp),zp(t))return t;var i=function(n){var o=s.get(t);if(o)return o;s.set(t,n);for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(n[a]=ic(t[a],!0,s));return n};switch(jp(t)){case"Object":return i(Object.create(Object.getPrototypeOf(t)));case"Array":return i(Array(t.length));case"Date":return new Date(t.valueOf());case"RegExp":return qp(t);case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"BigInt64Array":case"BigUint64Array":return t.slice();default:return t}}function zp(t){var e=typeof t;return t==null||e!="object"&&e!="function"}function Wp(t,e){for(var s=e,i=0;i<t.length;i+=1){if(s==null)return;var r=t[i];Gp(r)?s=Hp(r,s):s=s[r]}return s}function fv(t){return crypto.getRandomValues(new Uint8Array(t))}function gv(){(!po||Qt+16>wu)&&(po=fv(wu),Qt=0);for(var t=0,e,s="";t<16;t++)e=po[Qt+t],t==6?s+=Ar[e&15|64]:t==8?s+=Ar[e&63|128]:s+=Ar[e],t&1&&t>1&&t<11&&(s+="-");return Qt+=16,s}function pv(){var t=0,e,s="";if(!wr||_s+16>256){for(wr=Array(t=256);t--;)wr[t]=256*Math.random()|0;t=_s=0}for(;t<16;t++)e=wr[_s+t],t==6?s+=Ir[e&15|64]:t==8?s+=Ir[e&63|128]:s+=Ir[e],t&1&&t>1&&t<11&&(s+="-");return _s++,s}function Gv(t,e,s=jv){let i;return(...r)=>{globalThis.clearTimeout(i),i=globalThis.setTimeout(()=>{t.apply(e,r)},s)}}function Gr(){if(Mt>1)Mt--;else{var t,e=!1;for((function(){var r=Fr;for(Fr=void 0;r!==void 0;){var n=r.S;if(n.v===r.v)for(var o=n.t;o!==void 0;o=o.x)o.i===r.i&&(o.i=n.i);r=r.o}})();Ci!==void 0;){var s=Ci;for(Ci=void 0,$r++;s!==void 0;){var i=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&vc(s))try{s.c()}catch(r){e||(t=r,e=!0)}s=i}}if($r=0,Mt--,e)throw t}}function Ue(t){if(Mt>0)return t();Io=++t_,Mt++;try{return t()}finally{Gr()}}function Hr(t){var e=ke,s=Pi;ke=void 0,Pi=void 0;try{return t()}finally{ke=e,Pi=s}}function pc(t){if(ke!==void 0){var e=t.n;if(e===void 0||e.t!==ke)return e={i:0,S:t,p:ke.s,n:void 0,t:ke,e:void 0,x:void 0,r:e},ke.s!==void 0&&(ke.s.n=e),ke.s=e,t.n=e,32&ke.f&&t.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=ke.s,e.n=void 0,ke.s.n=e,ke.s=e),e}}function We(t,e){this.v=t,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 R(t,e){return new We(t,e)}function vc(t){for(var e=t.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 _c(t){for(var e=t.s;e!==void 0;e=e.n){var s=e.S.n;if(s!==void 0&&(e.r=s),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function mc(t){for(var e=t.s,s=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)):s=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=i}t.s=s}function Hs(t,e){We.call(this,void 0,e),this.x=t,this.s=void 0,this.g=Mr-1,this.f=4}function yc(t){var e=t.m;if(t.m=void 0,typeof e=="function"){Mt++;var s=ke;ke=void 0;try{e()}catch(i){throw t.f&=-2,t.f|=8,na(t),i}finally{ke=s,Gr()}}}function na(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,yc(t)}function s_(t){if(ke!==this)throw new Error("Out-of-order effect");mc(this),ke=t,this.f&=-2,8&this.f&&na(this),Gr()}function qs(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,Pi&&Pi.push(this)}function At(t,e){var s=new qs(t,e);try{s.c()}catch(r){throw s.d(),r}var i=s.d.bind(s);return i[Symbol.dispose]=i,i}function Oc(t){if(!t?.includes(":"))return[t||void 0,void 0,void 0];let e=t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1):t,s=xm.exec(e);return s?[s[1]||void 0,s[2]===void 0?void 0:Number(s[2]),s[3]===void 0?void 0:Number(s[3])]:[void 0,void 0,void 0]}function Dm(t){if(!Tc.test(t))return null;t.includes("(eval ")&&(t=t.replaceAll("eval code","eval").replaceAll(/(\(eval at [^()]*)|(,.*$)/g,""));let e=t.replace(/^\s+/,"").replaceAll("(eval code","(").replace(/^.*?\s+/,""),s=/ (\(.+\)$)/.exec(e),i=s?e.replace(s[0],""):e,[r,n,o]=Oc(s?s[1]:e);return{functionName:s&&i||void 0,fileName:r==="eval"||r==="<anonymous>"?void 0:r,lineNumber:n,columnNumber:o}}function Nm(t){if(Cm.test(t))return null;if(t.includes(" > eval")&&(t=t.replaceAll(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),!t.includes("@")&&!t.includes(":"))return{functionName:t,fileName:void 0,lineNumber:void 0,columnNumber:void 0};let e=t.lastIndexOf("@"),s=e>0?t.slice(0,e):void 0,[i,r,n]=Oc(t.slice(e+1));return{functionName:s,fileName:i,lineNumber:r,columnNumber:n}}function Lm(t){if(!t.stack)throw new Error("Cannot parse given Error object");let e=t.stack.split(`
|
|
3
|
+
`);return e.some(s=>Tc.test(s))?e.map(Dm).filter(s=>s!==null):e.map(Nm).filter(s=>s!==null)}function Uu(t,e,s,i){return{errorClass:Bu(t),message:`${s}${Bu(e)}`,type:"browserjs",stacktrace:i.reduce((r,n)=>{let o=Fm(n);try{return JSON.stringify(o)==="{}"?r:r.concat(o)}catch{return r}},[])}}function Mc(t,e){let s=Object.assign(t,e);for(let i of Object.keys(s))typeof s[i]=="object"&&typeof e[i]=="object"&&(s[i]=Mc(s[i],e[i]));return s}async function Ey(t){let e=yy[t];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((s,i)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(n=>{import(n).then(o=>{if(!e.inited){let a=by();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}s(e.lib)}).catch(i)})})}function tt(t,e){if(!t?.default&&e){let s=Object.create(null);return s.default=t,s.__esModule=!0,s}return t}function st(t,e){return Ey(t).then(s=>s.get(e).then(i=>i()))}function Xy(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function Zy(){return Ku||(Ku=1,(function(t,e){(function(s,i){t.exports=i()})(Qy,function(){function s(f){return f=JSON.stringify(f),!!/^\{[\s\S]*\}$/.test(f)}function i(f){return f===void 0||typeof f=="function"?f+"":JSON.stringify(f)}function r(f){if(typeof f=="string")try{return JSON.parse(f)}catch{return f}}function n(f){return{}.toString.call(f)==="[object Function]"}function o(f){return Object.prototype.toString.call(f)==="[object Array]"}function a(f){var p="_Is_Incognit",_="yes";try{f||(f=window.localStorage),f.setItem(p,_),f.removeItem(p)}catch{var v={};v._data={},v.setItem=function(y,w){return v._data[y]=String(w)},v.getItem=function(y){return v._data.hasOwnProperty(y)?v._data[y]:void 0},v.removeItem=function(y){return delete v._data[y]},v.clear=function(){return v._data={}},f=v}finally{f.getItem(p)===_&&f.removeItem(p)}return f}var l=a();function u(){if(!(this instanceof u))return new u}u.prototype={set:function(p,_){if(p&&!s(p))l.setItem(p,i(_));else if(s(p))for(var v in p)this.set(v,p[v]);return this},get:function(p){if(p===void 0){var _={};return this.forEach(function(T,C){return _[T]=C}),_}if(p.charAt(0)==="?")return this.has(p.substr(1));var v=arguments;if(v.length>1){for(var m={},y=0,w=v.length;y<w;y++){var E=r(l.getItem(v[y]));this.has(v[y])&&(m[v[y]]=E)}return m}return r(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var _=this.get(p);return l.removeItem(p),_},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(_){p.push(_)}),p},forEach:function(p){for(var _=0,v=l.length;_<v;_++){var m=l.key(_);p(m,this.get(m))}return this},search:function(p){for(var _=this.keys(),v={},m=0,y=_.length;m<y;m++)_[m].indexOf(p)>-1&&(v[_[m]]=this.get(_[m]));return v},len:function(){return l.length}};var c=null;function h(f,p){var _=arguments,v=null;if(c||(c=u()),_.length===0)return c.get();if(_.length===1){if(typeof f=="string")return c.get(f);if(s(f))return c.set(f)}if(_.length===2&&typeof f=="string"){if(!p)return c.remove(f);if(p&&typeof p=="string")return c.set(f,p);p&&n(p)&&(v=null,v=p(f,c.get(f)),h.set(f,v))}if(_.length===2&&o(f)&&n(p))for(var m=0,y=f.length;m<y;m++)v=p(f[m],c.get(f[m])),h.set(f[m],v);return h}for(var g in u.prototype)h[g]=u.prototype[g];return h})})(Pr)),Pr.exports}var jp,Gp,Kp,te,Jp,Yp,Xp,Qp,rc,$,ye,rt,Ve,mt,Zp,pe,Us,ev,ea,tv,So,sv,iv,rv,ve,nv,$e,Bt,Ii,xi,Nt,wt,ta,ov,Su,Dr,av,lv,Nr,sa,nc,oc,ac,fo,ia,wo,ht,ko,ki,gs,Ri,$s,uv,go,cv,dv,hv,Sr,wu,Ar,Qt,po,_s,Ir,wr,vv,Vr,_v,mv,yv,lc,bv,z,Ev,ku,Sv,wv,kv,Au,Av,Iv,Rv,Iu,Tv,uc,Ov,_t,Pv,cc,re,dc,jr,ra,me,Ru,Di,Cv,hc,xv,Tu,Dv,Nv,Oi,Lv,$v,Fv,Ou,Mv,Pu,Bv,Uv,Cu,Ao,xu,Vv,jv,fc,Ni,gc,Du,Hv,qv,zv,Kv,Wv,Jv,Yv,Xv,Qv,Zv,Lr,e_,Pi,ke,Ci,Mt,$r,t_,Io,Fr,Mr,Ro,kr,Nu,bc,i_,r_,n_,To,Ut,Lt,Ec,Oo,Lu,o_,a_,l_,u_,c_,d_,h_,f_,$u,g_,p_,v_,__,m_,y_,b_,Fu,E_,S_,Sc,w_,k_,A_,I_,R_,T_,O_,Mu,P_,C_,x_,D_,N_,L_,$_,Rr,F_,M_,B_,U_,V_,j_,G_,H_,q_,z_,K_,W_,J_,Y_,X_,Q_,Z_,em,tm,sm,im,wc,qr,kc,rm,Li,zr,oa,Ac,Ic,Rc,ps,nm,Po,Tr,om,am,lm,um,cm,dm,ce,vo,hm,fm,gm,pm,vm,_m,mm,ym,bm,Em,Sm,wm,km,Am,Im,Rm,Tm,Om,Pm,d,Tc,Cm,xm,Pc,$m,Fm,Bu,Cc,Mm,Vu,Or,Bm,Um,Vm,jm,Gm,Hm,qm,zm,ju,Gu,Co,xc,Km,Wm,Jm,Ym,Xm,Qm,Zm,Dc,ey,ty,sy,iy,ry,ny,oy,ay,ly,uy,Nc,Lc,cy,dy,hy,fy,xo,$c,Do,gy,py,vy,Hu,_y,Fc,my,yy,by,Sy,wy,Bc,ky,Ay,_o,Iy,No,it,ot,dt,kt,ms,Ry,Ty,Oy,Py,Cy,xy,Dy,Ny,Ly,$y,Fy,My,Fs,By,Uc,Vc,Uy,jc,Gc,Ms,qu,zu,Vy,jy,Lo,Gy,$t,Hy,qy,zy,Ky,Wy,Jy,Yy,$o,Br,Pr,Qy,Ku,eb,fs,Hc,Bs,Fo,aa,Mo,la,Bo,ua,vt,tb,sb,ib,rb,nb,Uo,ob,Vo,ab,lb,qc,ub,cb,db,Vs,jo,zc,hb,fb,gb,js,mo,yo,pb,vb,_b,Wu,mb,Kc,yb,bb,Eb,Sb,wb,kb,Ab,Ib,Rb,Wc,Tb,Ob,Go,Pb,Jc,Cb,xb,Db,Yc,Nb,Lb,Ho,$b,Fb,Mb,Bb,Ju,Ub,Yu,Vb,Xu,qo,jb,Gb,Hb,bo,Cr,qb,zb,Kb,ca,Xc,Qc,zo,Zc,Wb,Ur,Qu,ed,Zu,Jb,Yb,Xb,Qb,Zb,Ti,Ko,e0,t0,s0,Eo,i0,r0,n0,o0,a0,Ai,Wo,Jo,Yo,l0,u0,c0,ec,tc,d0,h0,f0,g0,xr,Xo,sc,p0,v0,Qo,vs,Gs,da=et(()=>{"use strict";jp=Ft(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Gp=Number.isInteger||function(e){return e<<0===e};Kp=(function(){function t(){this.map={},this.length=0}return t.prototype.set=function(e,s){var i=this.hash(e),r=this.map[i];r||(this.map[i]=r=[]),r.push([e,s]),this.length+=1},t.prototype.hash=function(e){var s=[];for(var i in e)s.push(Object.prototype.toString.call(e[i]));return s.join()},t.prototype.get=function(e){if(this.length<=180){for(var s in this.map)for(var o=this.map[s],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]}},t})(),te=Ft(function(e){return e!=null&&typeof e.clone=="function"?e.clone():ic(e)});Jp=Zo(function(e,s,i){var r={},n;s=s||{},i=i||{};for(n in s)Er(n,s)&&(r[n]=Er(n,i)?e(n,s[n],i[n]):s[n]);for(n in i)Er(n,i)&&!Er(n,r)&&(r[n]=i[n]);return r}),Yp=Zo(function t(e,s,i){return Jp(function(r,n,o){return Eu(n)&&Eu(o)?t(e,n,o):e(r,n,o)},s,i)}),Xp=Zo(function(e,s,i){return Yp(function(r,n,o){return e(n,o)},s,i)}),Qp=Xt(Wp),rc=Xt(function(e,s){var i={};for(var r in s)e(s[r],r,s)&&(i[r]=s[r]);return i}),$=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),ye=t=>typeof t=="string",rt=t=>t===null,Ve=t=>typeof t>"u",mt=t=>rt(t)||Ve(t),Zp=t=>typeof t=="bigint",pe=t=>!Ve(t),Us=t=>!mt(t),ev=t=>Us(t)&&t!=="",ea=t=>{switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return t instanceof Error}},tv=t=>typeof t=="boolean",So=(t,e)=>{let s=e.split(".");return Qp(s,t)},sv=(t,e)=>!!So(t,e),iv=t=>typeof t=="object",rv=t=>!rt(t)&&iv(t)&&!Array.isArray(t),ve=t=>!rt(t)&&Object.prototype.toString.call(t)==="[object Object]",nv=(t,e)=>{if(!Array.isArray(t)||!Array.isArray(e))return te(e);let s=te(t);return e.forEach((i,r)=>{s[r]=Array.isArray(i)||rv(i)?$e(s[r],i):i}),s},$e=(t,e)=>Xp(nv,t,e),Bt=t=>ve(t)&&Object.keys(t).length>0,Ii=t=>{let e=rc(pe,t);return Object.keys(e).forEach(s=>{let i=e[s];ve(i)&&(e[s]=Ii(i))}),e},xi=t=>{let e=rc(Us,t);return Object.keys(e).forEach(s=>{let i=e[s];ve(i)&&(e[s]=xi(i))}),e},Nt=t=>{if(Bt(t))return xi(t)},wt=(t,e)=>typeof t=="boolean"?t:e,ta=t=>(Object.getOwnPropertyNames(t).forEach(function(e){t[e]&&typeof t[e]=="object"&&ta(t[e])}),Object.freeze(t)),ov=t=>t.replace(/^\s+|\s+$/gm,""),Su=t=>t.replace(/^\.+/,""),Dr=t=>{let e=t;if(!ye(t)&&!mt(t))try{e=JSON.stringify(t)}catch{e=null}return e},av=t=>{let e=Array.from(t,s=>String.fromCodePoint(s)).join("");return globalThis.btoa(e)},lv=t=>av(new TextEncoder().encode(t)),Nr=(t,e,s,i,r)=>{let n={category:t,name:e,properties:s,options:i,callback:void 0};$(r)&&(n.callback=r),$(i)&&(n.category=t,n.name=e,n.properties=s,n.options=void 0,n.callback=i),$(s)&&(n.category=t,n.name=e,n.properties=void 0,n.options=void 0,n.callback=s),$(e)&&(n.category=t,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),$(t)&&(n.category=void 0,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=t),ve(t)?(n.name=void 0,n.category=void 0,n.properties=t,$(e)?n.options=void 0:n.options=e):ve(e)&&(n.name=void 0,n.properties=e,$(s)?n.options=void 0:n.options=s),ye(t)&&!ye(e)&&(n.category=void 0,n.name=t),pe(n.category)||(n.category=void 0),pe(n.name)||(n.name=void 0),n.properties=n.properties?te(n.properties):{},pe(n.options)?n.options=te(n.options):n.options=void 0;let o=ye(n.name)?n.name:n.properties.name,a=ye(n.category)?n.category:n.properties.category;return n.properties=$e(ve(n.properties)?n.properties:{},{...o&&{name:o},...a&&{category:a}}),n},sa=(t,e,s,i)=>{let r={name:t,properties:e,options:s,callback:void 0};return $(i)&&(r.callback=i),$(s)&&(r.properties=e,r.options=void 0,r.callback=s),$(e)&&(r.properties=void 0,r.options=void 0,r.callback=e),r.properties=Us(r.properties)?te(r.properties):{},pe(r.options)?r.options=te(r.options):r.options=void 0,r},nc=(t,e,s,i)=>{let r={userId:t,traits:e,options:s,callback:void 0};return $(i)&&(r.callback=i),$(s)&&(r.userId=t,r.traits=e,r.options=void 0,r.callback=s),$(e)&&(r.userId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ve(t)||rt(t))&&(r.userId=null,r.traits=t,$(e)?r.options=void 0:r.options=e),r.userId=Dr(r.userId),ve(r.traits)?r.traits=te(r.traits):r.traits=void 0,pe(r.options)?r.options=te(r.options):r.options=void 0,r},oc=(t,e,s,i)=>{let r={to:t,from:e,options:s,callback:void 0};return $(i)&&(r.callback=i),$(s)&&(r.to=t,r.from=e,r.options=void 0,r.callback=s),$(e)?(r.to=t,r.from=void 0,r.options=void 0,r.callback=e):(ve(e)||rt(e))&&(r.to=t,r.from=void 0,r.options=e),pe(r.to)&&(r.to=Dr(r.to)),pe(r.from)?r.from=Dr(r.from):r.from=void 0,pe(r.options)?r.options=te(r.options):r.options=void 0,r},ac=(t,e,s,i)=>{let r={groupId:t,traits:e,options:s,callback:void 0};return $(i)&&(r.callback=i),$(s)&&(r.groupId=t,r.traits=e,r.options=void 0,r.callback=s),$(e)&&(r.groupId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ve(t)||rt(t))&&(r.groupId=null,r.traits=t,$(e)?r.options=void 0:r.options=e),r.groupId=Dr(r.groupId),ve(r.traits)?r.traits=te(r.traits):r.traits=void 0,pe(r.options)?r.options=te(r.options):r.options=void 0,r},fo=(function(t){return t.UNLOADED="Page Unloaded",t})({}),ia="API",wo="CapabilitiesManager",ht="ConfigManager",ko="EventManager",ki="PluginsManager",gs="UserSessionManager",Ri="ErrorHandler",$s="PluginEngine",uv="StoreManager",go=`Ready${ia}`,cv=`Load${ia}`,dv="HttpClient",hv="RudderStackAnalytics",Sr="AnalyticsCore";wu=4096,Ar=[],Qt=0;for(;Qt<256;Qt++)Ar[Qt]=(Qt+256).toString(16).substring(1);_s=256,Ir=[];for(;_s--;)Ir[_s]=(_s+256).toString(16).substring(1);vv=()=>!mt(globalThis.crypto)&&$(globalThis.crypto.getRandomValues),Vr=()=>vv()?gv():pv(),_v=()=>!!window.chrome?.runtime?.id,mv=()=>ye(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),yv=(t,e=!1)=>{let s=!1,i=!1;function r(){s||(s=!0,t(i),setTimeout(()=>{s=!1},0))}(e||mv())&&globalThis.addEventListener("beforeunload",()=>{i=!1,r()}),globalThis.addEventListener("blur",()=>{i=!0,r()}),globalThis.addEventListener("focus",()=>{s=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",r()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?r():s=!1})},lc=t=>t.toISOString(),bv=()=>lc(new Date),z=":: ",Ev=t=>`A script with the id "${t}" is already loaded. Skipping the loading of this script to prevent conflicts`,ku=(t,e,s)=>`Unable to load (${ye(s)?s:s.type}) the script with the id "${t}" from URL "${e}"`,Sv=(t,e,s)=>`A timeout of ${s} ms occurred while trying to load the script with id "${t}" from URL "${e}"`,wv=(t,e)=>`${t}${z}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,kv="Failed to convert the value to a JSON string.",Au=(t,e)=>`${t}${z}A bad data (like circular reference, BigInt) has been detected in the object and the property "${e}" has been dropped from the output.`,Av="Failed to encode the cookie data.",Iv=(t,e)=>`${t}${z}The "${e}" storage type is `,Rv="JSONStringify",Iu="JSON",Tv="[BigInt]",uc="[Circular Reference]",Ov=(t,e,s)=>{let i=[];return function(r,n){if(!e?.includes(r)&&!(t&&mt(n))){if(typeof n!="object"||rt(n))return n;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(n)?(s?.warn(wv(Rv,r)),uc):(i.push(n),n)}}},_t=(t,e,s,i)=>{try{return JSON.stringify(t,Ov(e,s,i))}catch(r){return i?.warn(kv,r),null}},Pv=t=>{let e=[];return function(i,r){if(Zp(r))return t?.warn(Au(Iu,i)),Tv;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(r)?(t?.warn(Au(Iu,i)),uc):(e.push(r),r)}},cc=(t,e)=>{let s=Array.isArray(t)?[]:{};for(let i in t)if(Object.hasOwnProperty.call(t,i)){let r=t[i],n=e.call(t,i,r);ve(n)||Array.isArray(n)?s[i]=cc(n,e):s[i]=n}return s},re=(t,e)=>{let s=Pv(e),i=s.call(t,"",t);return ve(t)||Array.isArray(t)?cc(t,s):i},dc="[SDK DISPATCHED ERROR]",jr=t=>{let{stack:e}=t;if(typeof e=="string"&&e)return e},ra=(t,e)=>{if(!ea(t))return new Error(`${e}: ${_t(t)}`);try{let s=t.constructor,i=new s(`${e}: ${t.message}`),r=jr(t);return r&&(i.stack=r),Object.getOwnPropertyNames(t).forEach(n=>{if(n!=="message"&&n!=="stack"&&n!=="name")try{i[n]=t[n]}catch{}}),i}catch{return new Error(`${e}: ${_t(t)}`)}},me=t=>{if(ea(t)){let e=jr(t);e&&(t.stack=`${e}
|
|
4
|
+
${dc}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:t,bubbles:!0,cancelable:!0,composed:!0}))},Ru="RudderLabs JavaScript SDK",Di="3.32.0",Cv="com.rudderlabs.javascript",hc="npm",xv="modern",Tu="RudderJS-Initiated",Dv="ad-block page request",Nv="/ad-blocked",Oi="preloadedEventsBuffer",Lv="Consent Management Interaction",$v="ajs_trait_",Fv="ajs_prop_",Ou="ajs_aid",Mv="ajs_uid",Pu="ajs_event",Bv=10*1e3,Uv=31536e3*1e3,Cu=720*60*1e3,Ao=1800*1e3,xu=10*1e3,Vv=10*1e3,jv=250,fc=(t="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[t]||(globalThis.RudderStackGlobals[t]={})},Ni=(t,e,s="app")=>{fc(s),globalThis.RudderStackGlobals[s][t]=e},gc=(t,e="app")=>(fc(e),globalThis.RudderStackGlobals[e][t]);Du=(t,e)=>{let s={};return t.forEach((i,r)=>{if(r.startsWith(e)){let n=r.substring(e.length);s[n]=t.get(r)}}),s},Hv=(t=[])=>{let e={trait:$v,properties:Fv},s=new URLSearchParams(globalThis.location.search);s.get(Pu)&&t.unshift(["track",s.get(Pu),Du(s,e.properties)]);let i=s.get(Mv),r=Du(s,e.trait);if(i||Bt(r)){let n=[...i?[i]:[],r];t.unshift(["identify",...n])}s.get(Ou)&&t.unshift(["setAnonymousId",s.get(Ou)])},qv=t=>{let e="load",s=[],i=0;for(;i<t.length;){if(t[i]&&t[i][0]===e){s=te(t[i]),t.splice(i,1);break}i+=1}return s},zv=t=>{let e="consent",s=t.filter(r=>r[0]===e),i=t.filter(r=>r[0]!==e);t.splice(0,t.length,...s,...i)},Kv=t=>{let e=gc(Oi)||[];Hv(e),e.length>0&&(t.enqueuePreloadBufferEvents(e),Ni(Oi,[]))},Wv=(t,e)=>{let s=t.shift(),i;if($(e[s])){switch(s){case"page":i=Nr(...t);break;case"track":i=sa(...t);break;case"identify":i=nc(...t);break;case"alias":i=oc(...t);break;case"group":i=ac(...t);break;default:e[s](...t);break}i&&e[s](i)}},Jv=10*1e3,Yv="RS_JS_SDK",Xv=(t,e,s=!0,i=null,r=null,n={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=r,o.src=t,o.id=e,o.async=s,Object.keys(n).forEach(a=>{o.setAttribute(a,n[a])}),o.setAttribute("data-loader",Yv),o},Qv=t=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(t,e[0]?.firstChild);return}let s=document.getElementsByTagName("script");if(s.length>0&&s[0]?.parentNode){s[0]?.parentNode.insertBefore(t,s[0]);return}let i=document.createElement("head");i.appendChild(t);let r=document.getElementsByTagName("html")[0];r?.insertBefore(i,r.firstChild)},Zv=(t,e,s,i=!0,r)=>new Promise((n,o)=>{document.getElementById(e)&&o(new Error(Ev(e)));try{let l;Qv(Xv(t,e,i,()=>{globalThis.clearTimeout(l),n(e)},h=>{globalThis.clearTimeout(l),o(new Error(ku(e,t,h)))},r)),l=globalThis.setTimeout(()=>{o(new Error(Sv(e,t,s)))},s)}catch(l){o(ra(l,ku(e,t,"unknown")))}}),Lr=class{constructor(e,s=Jv){this.logger=e,this.timeout=s}loadJSFile(e){let{url:s,id:i,timeout:r,async:n,callback:o,extraAttributes:a}=e,l=!$(o);Zv(s,i,r||this.timeout,n,a).then(u=>{l||o(u)}).catch(u=>{l||o(i,u)})}},e_=Symbol.for("preact-signals");ke=void 0;Ci=void 0,Mt=0,$r=0,t_=0,Io=0,Fr=void 0,Mr=0;We.prototype.brand=e_;We.prototype.h=function(){return!0};We.prototype.S=function(t){var e=this,s=this.t;s!==t&&t.e===void 0&&(t.x=s,this.t=t,s!==void 0?s.e=t:Hr(function(){var i;(i=e.W)==null||i.call(e)}))};We.prototype.U=function(t){var e=this;if(this.t!==void 0){var s=t.e,i=t.x;s!==void 0&&(s.x=i,t.e=void 0),i!==void 0&&(i.e=s,t.x=void 0),t===this.t&&(this.t=i,i===void 0&&Hr(function(){var r;(r=e.Z)==null||r.call(e)}))}};We.prototype.subscribe=function(t){var e=this;return At(function(){var s=e.value;Hr(function(){return t(s)})},{name:"sub"})};We.prototype.valueOf=function(){return this.value};We.prototype.toString=function(){return this.value+""};We.prototype.toJSON=function(){return this.value};We.prototype.peek=function(){var t=this;return Hr(function(){return t.value})};Object.defineProperty(We.prototype,"value",{get:function(){var t=pc(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if($r>100)throw new Error("Cycle detected");(function(s){Mt!==0&&$r===0&&s.l!==Io&&(s.l=Io,Fr={S:s,v:s.v,i:s.i,o:Fr})})(this),this.v=t,this.i++,Mr++,Mt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Gr()}}}});Hs.prototype=new We;Hs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Mr))return!0;if(this.g=Mr,this.f|=1,this.i>0&&!vc(this))return this.f&=-2,!0;var t=ke;try{_c(this),ke=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(s){this.v=s,this.f|=16,this.i++}return ke=t,mc(this),this.f&=-2,!0};Hs.prototype.S=function(t){if(this.t===void 0){this.f|=36;for(var e=this.s;e!==void 0;e=e.n)e.S.S(e)}We.prototype.S.call(this,t)};Hs.prototype.U=function(t){if(this.t!==void 0&&(We.prototype.U.call(this,t),this.t===void 0)){this.f&=-33;for(var e=this.s;e!==void 0;e=e.n)e.S.U(e)}};Hs.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var t=this.t;t!==void 0;t=t.x)t.t.N()}};Object.defineProperty(Hs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=pc(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});qs.prototype.c=function(){var t=this.S();try{if(8&this.f||this.x===void 0)return;var e=this.x();typeof e=="function"&&(this.m=e)}finally{t()}};qs.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,yc(this),_c(this),Mt++;var t=ke;return ke=this,s_.bind(this,t)};qs.prototype.N=function(){2&this.f||(this.f|=2,this.u=Ci,Ci=this)};qs.prototype.d=function(){this.f|=8,1&this.f||na(this)};qs.prototype.dispose=function(){this.d()};Ro=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=[]}},kr={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Nu="LOG",bc="ERROR",i_="RS SDK",r_="font-weight: bold; background: black; color: white;",n_="font-weight: normal;",To=class{constructor(e=Nu,s="",i=console){this.minLogLevel=kr[e],this.scope=s,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,s){this.minLogLevel<=kr[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(s))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=kr[e],Ve(this.minLogLevel)&&(this.minLogLevel=kr[Nu])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let s=`%c ${i_}`;this.scope&&(s=`${s} - ${this.scope}`);let i=ye(e[0])?e[0].trim():"";s=`${s} %c ${i}`;let r=[s,r_,n_];return ye(e[0])||r.push(e[0]),r.push(...e.slice(1)),r}return e}},Ut=new To,Lt=(function(t){return t.HANDLEDEXCEPTION="handledException",t.UNHANDLEDEXCEPTION="unhandledException",t.UNHANDLEDREJECTION="unhandledPromiseRejection",t})({}),Ec=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],Oo="cookieStorage",Lu="Unable to process/parse source configuration response",o_="The source is disabled. Please enable the source in the dashboard to send events.",a_="Failed to prepare data for the request.",l_="Failed to invoke plugin because the extension point name is missing.",u_="Failed to invoke plugin because the extension point name is invalid.",c_=t=>`${t}${z}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,d_=(t,e,s)=>`${t}${z}The base URL "${s}" for ${e} is not valid.`,h_=(t,e,s)=>`${t}${z}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(s)}".`,f_=(t,e)=>`${t}${z}Ignoring a non-error: ${e}.`,$u="Failed to log breadcrumb",g_=t=>`${t}${z}Failed to handle the error.`,p_=t=>`${t}${z}Plugin name is missing.`,v_=(t,e)=>`${t}${z}Plugin "${e}" already exists.`,__=(t,e)=>`${t}${z}Plugin "${e}" not found.`,m_=(t,e)=>`${t}${z}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.`,y_=(t,e,s)=>`${t}${z}Plugin "${e}" could not be loaded because some of its dependencies "${s}" do not exist.`,b_=(t,e,s)=>`${t}${z}Failed to invoke the "${e}" extension point of plugin "${s}".`,Fu="Failed to fetch the source config",E_=(t,e)=>`${t}${z}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,S_=(t,e)=>`${t}${z}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.`,Sc=t=>`${t}${z}The provided callback parameter is not a function.`,w_=(t,e,s,i,r)=>`${t} with status ${e} (${s}) for URL: ${i}. Response: ${r.trim()}`,k_=(t,e,s)=>`${t} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${s}`,A_=(t,e)=>`${t} for URL: ${e}`,I_=t=>`Failed to save the value for "${t}" to storage`,R_=t=>`Failed to retrieve or parse data for "${t}" from storage`,T_=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,O_=t=>`The server failed to set the ${t} cookie. As a fallback, the cookies will be set client side.`,Mu="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",P_=(t,e,s)=>`${t}${z}The storage type "${e}" is not supported. Please choose one of the following supported types: "${Ec}". The default type "${s}" will be used instead.`,C_=(t,e,s,i)=>`${t}${z}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(s)}". The default version "${i}" will be used instead.`,x_=(t,e,s)=>`${t}${z}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${s}). To enable storage data migration, please update the storage encryption version to the latest version.`,D_=(t,e,s)=>`${t}${z}The provided cookie domain (${e}) does not match the current webpage's domain (${s}). Hence, the cookies will be set client-side.`,N_=(t,e,s,i)=>`${t}${z}The "${e}" property defined under "${s}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,L_=(t,e)=>`${t}${z}The top-level custom context property "${e}" is reserved and was ignored.`,$_=t=>`${t}${z}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,Rr=t=>`${t}${z}Invalid custom context. Use a plain object without prototype pollution keys.`,F_=t=>`${t}${z}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,M_=(t,e,s)=>`${t}${z}The session timeout value "${e}" is not a number. The default timeout of ${s} ms will be used instead.`,B_=(t,e,s)=>`${t}${z}The session cut off duration value "${e}" is not a number. The default cut off duration of ${s} ms will be used instead.`,U_=(t,e,s)=>`${t}${z}The session cut off duration value "${e}" ms is less than the session timeout value "${s}" ms. The cut off functionality will be disabled.`,V_=t=>`${t}${z}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.`,j_=(t,e,s)=>`${t}${z}The session timeout value ${e} ms is less than the recommended minimum of ${s} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,G_=(t,e,s)=>`${t}${z}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${s}" digits long. A new session ID will be auto-generated instead.`,H_=t=>`${t}${z}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,q_=(t,e,s,i)=>`${t}${z}The storage type "${s}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,z_=t=>`${t}${z}The callback threw an exception`,K_=(t,e)=>`${t}${z}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,W_=(t,e)=>`Failed to load the polyfill script with ID "${t}" from URL ${e}.`,J_=(t,e,s)=>`${t}${z}The pre-consent storage strategy "${e}" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "${s}" will be used instead.`,Y_=(t,e,s)=>`${t}${z}The pre-consent events delivery type "${e}" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "${s}" will be used instead.`,X_=(t,e)=>`${t}${z}${e} plugin is deprecated. Please exclude it from the load API options.`,Q_=(t,e,s,i)=>{let r=s.length===1,n=r?` '${s[0]}' plugin was`:` ['${s.join("', '")}'] plugins were`,o=`${t}${z}${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.`},Z_=(t,e)=>`${t}${z}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,em=t=>`${t}${z}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,tm=(t,e)=>`${t}${z}Ignoring unknown plugins: ${e.join(", ")}.`,sm=(t,e)=>`${t}${z}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.`,im=(t,e)=>`${t}${z}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,wc={All:!0},qr="js-integrations",kc="plugins",rm=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_]*)?$"),Li="modern",zr="https://cdn.rudderlabs.com",oa="v3",Ac=`${zr}/${oa}/${Li}/${qr}`,Ic=`${zr}/${oa}/${Li}/${kc}`,Rc="https://api.rudderstack.com",ps="v3",nm="xhr",Po={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},Tr={[ps]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},om={[nm]:"XhrQueue",beacon:"BeaconQueue"},am="rsaRequest",lm="rsaMetrics",um="Custom Device Mode",cm={configUrl:Rc,loadIntegration:!0,sessions:{autoTrack:!0,timeout:Ao,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:wc,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:Vv,storage:{encryption:{version:ps},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},dm=R(te(cm)),ce=ta({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),vo=ta({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),hm=10,fm={userId:R(ce.userId),userTraits:R(ce.userTraits),anonymousId:R(ce.anonymousId),groupId:R(ce.groupId),groupTraits:R(ce.groupTraits),initialReferrer:R(ce.initialReferrer),initialReferringDomain:R(ce.initialReferringDomain),sessionInfo:R(ce.sessionInfo),authToken:R(ce.authToken)},gm={isOnline:R(!0),storage:{isLocalStorageAvailable:R(!1),isCookieStorageAvailable:R(!1),isSessionStorageAvailable:R(!1)},isBeaconAvailable:R(!1),isLegacyDOM:R(!1),isUaCHAvailable:R(!1),isCryptoAvailable:R(!1),isAdBlockerDetectionInProgress:R(!1),isAdBlocked:R(void 0),cspBlockedURLs:R([])},pm={isErrorReportingEnabled:R(!1),isMetricsReportingEnabled:R(!1),breadcrumbs:R([])},vm=R(void 0),_m={activeDataplaneUrl:R(void 0),integrationsCDNPath:R(Ac),pluginsCDNPath:R(Ic),sourceConfigUrl:R(void 0),status:R(void 0),initialized:R(!1),logLevel:R(bc),loaded:R(!1),readyCallbacks:R([]),writeKey:R(void 0),dataPlaneUrl:R(void 0),safeAnalyticsInstance:R(void 0)},mm={enabled:R(!1),initialized:R(!1),data:R({}),activeConsentManagerPluginName:R(void 0),preConsent:R({enabled:!1}),postConsent:R({}),resolutionStrategy:R("and"),provider:R(void 0),metadata:R(void 0)},ym={retries:R(0),dropped:R(0),sent:R(0),queued:R(0),triggered:R(0),metricsServiceUrl:R(void 0)},bm=()=>xv,Em={app:R({name:Ru,namespace:Cv,version:Di,installType:hc}),traits:R(null),library:R({name:Ru,version:Di,snippetVersion:globalThis.RudderSnippetVersion,variant:bm()}),userAgent:R(null),device:R(null),network:R(null),os:R({name:"",version:""}),locale:R(null),screen:R({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":R(void 0),timezone:R(void 0)},Sm=R({}),wm={configuredDestinations:R([]),activeDestinations:R([]),loadOnlyIntegrations:R({}),failedDestinations:R([]),loadIntegration:R(!0),initializedDestinations:R([]),clientDestinationsReady:R(!1),integrationsConfig:R({})},km={toBeProcessedArray:R([]),readyCallbacksArray:R([])},Am={ready:R(!1),loadedPlugins:R([]),failedPlugins:R([]),pluginsToLoadFromConfig:R([]),activePlugins:R([]),totalPluginsToLoad:R(0)},Im={encryptionPluginName:R(void 0),migrate:R(!1),type:R(void 0),cookie:R(void 0),entries:R({}),trulyAnonymousTracking:R(!1)},Rm={isEnabledServerSideCookies:R(!1),dataServiceUrl:R(void 0)},Tm={eventsQueuePluginName:R(void 0),deliveryEnabled:R(!0)},Om={enabled:R(!1),pageLifecycle:{enabled:R(!1),pageViewId:R(void 0),pageLoadedTimestamp:R(void 0)}},Pm={capabilities:gm,consents:mm,context:Em,customContext:Sm,eventBuffer:km,lifecycle:_m,loadOptions:dm,metrics:ym,nativeDestinations:wm,plugins:Am,reporting:pm,session:fm,source:vm,storage:Im,serverCookies:Rm,dataPlaneEvents:Tm,autoTrack:Om},d={...te(Pm)},Tc=/^\s*at /,Cm=/^(eval@)?(\[native code])?$/,xm=/(.+?)(?::(\d+))?(?::(\d+))?$/;Pc="global code",$m=t=>pe(t)&&/^global code$/i.test(t)?Pc:t,Fm=t=>{let e={file:t.fileName,method:$m(t.functionName),lineNumber:t.lineNumber,columnNumber:t.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Pc),e},Bu=t=>ye(t)?t:"";Cc=(t,e)=>{let s;return ea(t)&&ye(jr(t))?s=t:(e.warn(f_(Ri,_t(t))),s=void 0),s},Mm=(t,e)=>{try{let s=Lm(t);return Uu(t.name,t.message,e,s)}catch{return Uu(t.name,t.message,e,[])}},Vu=(t,e)=>{try{return JSON.parse(t||"")}catch(s){let i=ra(s,"Failed to parse response data");e(i)}},Or="The request failed",Bm=[/Failed to fetch dynamically imported module: .*/],Um=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],Vm=[new RegExp(`${Or}.*`),/A script with the id .* is already loaded\./],jm=[...Bm,...Um],Gm="integrations",Hm="sdk",qm=Hm,zm={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},ju=(t,e,s)=>{let i=$e(zm,e||{});return s&&(i.headers=$e(i.headers,{Authorization:s})),i.url=t,i},Gu=(t,e=Bv,s)=>new Promise((i,r)=>{let n;if(t.sendRawData===!0)n=t.data;else if(n=_t(t.data,!1,[],s),rt(n)){r({error:new Error(a_),undefined:void 0,options:t});return}let o=new XMLHttpRequest,a=u=>{r({error:new Error(w_(Or,o.status,o.statusText,t.url,o.responseText)),xhr:o,options:t})},l=u=>{r({error:new Error(k_(Or,u,t.url)),xhr:o,options:t,...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:t}):a()},o.open(t.method,t.url,!0),t.withCredentials===!0&&(o.withCredentials=!0),o.timeout=e,Object.keys(t.headers).forEach(u=>{t.headers[u]&&o.setRequestHeader(u,t.headers[u])});try{o.send(n)}catch(u){r({error:ra(u,A_(Or,t.url)),xhr:o,options:t})}}),Co=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:s,options:i,timeout:r,isRawResponse:n}=e;try{let o=await Gu(ju(s,i,this.basicAuthHeader),r,this.logger);return{data:n?o.response:Vu(o.response,this.onError),details:o}}catch(o){return{data:void 0,details:o}}}getAsyncData(e){let{callback:s,url:i,options:r,timeout:n,isRawResponse:o}=e,a=!$(s);Gu(ju(i,r,this.basicAuthHeader),n,this.logger).then(l=>{a||s(o?l.response:Vu(l.response,this.onError),l)}).catch(l=>{a||s(void 0,l)})}onError(e,s){this.errorHandler?.onError({error:e,context:dv,groupingHash:s})}setAuthHeader(e,s=!1){let i=s?e:lv(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},xc=new Co(Ut),Km="1",Wm=()=>["rsa"],Jm=["www.test-host.com","localhost","127.0.0.1","[::1]"],Ym=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","customContext","traits","authToken"],Xm="RudderStack JavaScript SDK",Qm="git+https://github.com/rudderlabs/rudder-sdk-js.git",Zm="js",Dc=t=>{d.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(d.lifecycle.sourceConfigUrl.value),s=`${e.origin}${e.pathname}?view=ad`;t.getAsyncData({url:s,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(i,r)=>{d.capabilities.isAdBlockerDetectionInProgress.value=!1,d.capabilities.isAdBlocked.value=r?.error!==void 0||r?.xhr?.responseURL!==s}})}catch(e){throw d.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},ey=(t,e)=>{switch(e){case Lt.UNHANDLEDEXCEPTION:{let{error:s}=t;return s||t}case Lt.UNHANDLEDREJECTION:return t.reason;case Lt.HANDLEDEXCEPTION:default:return t}},ty=t=>({type:"manual",name:t,timestamp:new Date,metaData:{}}),sy=(t=()=>window.location.hostname)=>{let e=t();return!e||e&&Jm.includes(e)?"development":"production"},iy=t=>{let e=_t(t,!1,Ym);return e!==null?JSON.parse(e):{}},ry=()=>globalThis.location.href.split("?")[0],ny=(t,e,s,i)=>({id:`${t.value?.id??s.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${i.pageLifecycle.pageViewId.value??"NA"}`,name:t.value?.name??"NA"}),oy=(t,e)=>({locale:t.value??"NA",userAgent:e.value??"NA",time:new Date}),ay=(t,e,s,i)=>{let{context:r,lifecycle:n,session:o,source:a,reporting:l,autoTrack:u}=s,{app:c,locale:h,userAgent:g,timezone:f,screen:p,library:_}=r;return{payloadVersion:"5",notifier:{name:Xm,version:c.value.version,url:Qm},events:[{exceptions:[te(t)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:c.value.version,releaseStage:sy(),type:c.value.installType},device:oy(h,g),request:{url:ry(),clientIp:"[NOT COLLECTED]"},breadcrumbs:te(l.breadcrumbs.value),context:t.message,groupingHash:i,metaData:{app:{snippetVersion:_.value.snippetVersion},device:{...p.value,timezone:f.value},...iy(s)},user:ny(a,o,n,u)}]}},ly=(t,e,s)=>{if(Ve(t.capabilities.isAdBlocked.value)){t.capabilities.isAdBlockerDetectionInProgress.value===!1&&Dc(e);let i=At(()=>{pe(t.capabilities.isAdBlocked.value)&&(s(t.capabilities.isAdBlocked.value===!1),i())})}else s(t.capabilities.isAdBlocked.value===!1)},uy=(t,e,s)=>{let i=t.message;return new Promise(r=>{if(jm.some(n=>n.test(i))){let n=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];ye(n)?n.startsWith(zr)?e.capabilities.cspBlockedURLs.value.includes(n)?r(!1):ly(e,s,r):r(!1):r(!0)}else r(!Vm.some(n=>n.test(i)))})},Nc=t=>t?t.split("/").at(-2):void 0,Lc=t=>{let e=t.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},cy=t=>{let e=Lc(t);if(!e)return!1;let s=e.substring(e.lastIndexOf("/")+1);return Nc(e)===qr||Wm().some(r=>s.startsWith(r)&&s.endsWith(".js"))},dy=(t,e)=>{if(e)return e;let s=Lc(t);return Nc(s)===qr?Gm:qm},hy=(t,e,s)=>{let i={version:Km,message_id:Vr(),source:{name:Zm,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:s},errors:t};return _t(i)},fy=(t,e,s)=>{let i;if(!pe(t))i=e;else if(ye(t))i=t;else{let r=Cc(t,s);pe(r)?i=r.message:i=e}return i},xo=class{constructor(e,s){we(this,"initialized",!1);this.httpClient=e,this.logger=s}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Ri,errorType:Lt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Ri,errorType:Lt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let s=ye(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&s.startsWith(zr)&&!d.capabilities.cspBlockedURLs.value.includes(s)&&(d.capabilities.cspBlockedURLs.value=[...d.capabilities.cspBlockedURLs.value,s])})}async onError(e){try{let{error:s,context:i,customMessage:r,groupingHash:n,category:o}=e,a=e.errorType??Lt.HANDLEDEXCEPTION,l=ey(s,a),u=Cc(l,this.logger);if(Ve(u))return;let c=r?`${r} - `:"",h=`${i}${z}${c}`,g=Mm(u,h),p=jr(u).includes(dc);if(!p&&!cy(g)&&a!==Lt.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await uy(g,d,this.httpClient)){let v={severity:"error",unhandled:a!==Lt.HANDLEDEXCEPTION,severityReason:{type:a}},m=fy(n,g.message,this.logger),y=ay(g,v,d,m),w=dy(g,o);this.httpClient.getAsyncData({url:d.metrics.metricsServiceUrl.value,options:{method:"POST",data:hy(y,d,w),sendRawData:!0},isRawResponse:!0})}(a===Lt.HANDLEDEXCEPTION||p)&&this.logger.error(g.message)}catch(s){this.logger.error(g_(Ri),s)}}leaveBreadcrumb(e){try{d.reporting.breadcrumbs.value=[...d.reporting.breadcrumbs.value,ty(e)]}catch(s){this.onError({error:s,context:Ri,customMessage:$u,groupingHash:$u})}}},$c=new xo(xc,Ut),Do=class{constructor(e,s={}){we(this,"plugins",[]);we(this,"byName",{});we(this,"cache",{});we(this,"config",{throws:!0});this.config={throws:!0,...s},this.logger=e}register(e,s){if(!e.name){let r=p_($s);if(this.config.throws)throw new Error(r);this.logger.error(r,e);return}if(this.byName[e.name]){let r=v_($s,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,$(e.initialize)&&e.initialize(s)}unregister(e){let s=this.byName[e];if(!s){let r=__($s,e);if(this.config.throws)throw new Error(r);this.logger.error(r);return}let i=this.plugins.indexOf(s);if(i===-1){let r=m_($s,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 s=e??".";return this.cache[s]||(this.cache[s]=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(y_($s,i.name,r)),!1}return s==="."?!0:sv(i,s)})),this.cache[s]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,s=!0,...i){let r=e;if(!r)throw new Error(l_);let n=r.startsWith("!"),o=this.config.throws??r.endsWith("!");if(r=r.replace(/(^!|!$)/g,""),!r)throw new Error(u_);let a=r.split(".");a.pop();let l=a.join(".");return(s?this.getPlugins(r):[this.getPlugins(r)[0]]).map(c=>{let h=So(c,r);if(!$(h)||n)return h;try{return h.apply(So(c,l),i)}catch(g){if(o)throw g;this.logger.error(b_($s,r,c.name),g)}return null})}invokeSingle(e,...s){return this.invoke(e,!1,...s)[0]}invokeMultiple(e,...s){return this.invoke(e,!0,...s)}},gy=new Do(Ut,{throws:!0}),py=t=>t.config.connectionMode!=="cloud"||t.config.useNativeSDKToSend===!0||t.config.useNativeSDK===!0,vy=t=>t.config.connectionMode==="hybrid"||t.config.useNativeSDKToSend===!0,Hu=t=>t.filter(py),_y=(t,e)=>`${t.replaceAll(" ","-")}___${e}`,Fc=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],my=["Bugsnag","ErrorReporting"],yy={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"}};by=t=>Mc({},(globalThis.__federation_shared__||{}).default||{});Sy=t=>{switch(t){case"BeaconQueue":return()=>st("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>tt(e,!0));case"CustomConsentManager":return()=>st("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>tt(e,!0));case"DeviceModeDestinations":return()=>st("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>tt(e,!0));case"DeviceModeTransformation":return()=>st("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>tt(e,!0));case"ExternalAnonymousId":return()=>st("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>tt(e,!0));case"GoogleLinker":return()=>st("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>tt(e,!0));case"KetchConsentManager":return()=>st("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>tt(e,!0));case"IubendaConsentManager":return()=>st("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>tt(e,!0));case"NativeDestinationQueue":return()=>st("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>tt(e,!0));case"OneTrustConsentManager":return()=>st("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>tt(e,!0));case"StorageEncryption":return()=>st("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>tt(e,!0));case"StorageEncryptionLegacy":return()=>st("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>tt(e,!0));case"StorageMigrator":return()=>st("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>tt(e,!0));case"XhrQueue":return()=>st("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>tt(e,!0));default:return}},wy=t=>{let e={};return t.forEach(s=>{if(Fc.includes(s)){let i=Sy(s);i&&(e[s]=i)}}),e},Bc=()=>({}),ky=()=>({}),Ay=t=>wy?.(t)||{},_o={...Bc(),...ky()},Iy=t=>({...Ay(t)}),No=class{constructor(e,s,i){this.engine=e,this.errorHandler=s,this.logger=i,this.onError=this.onError.bind(this)}init(){d.lifecycle.status.value="pluginsLoading",Ni("pluginsCDNPath",d.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){At(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&Ue(()=>{d.plugins.ready.value=!0,d.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=d.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(r=>my.includes(r)?(this.logger.warn(X_(ki,r)),!1):!0);let s=[{configurationStatus:()=>pe(d.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:d.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(om),shouldAddMissingPlugins:!0},{configurationStatus:()=>Hu(d.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Hu(d.nativeDestinations.configuredDestinations.value).some(r=>r.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>pe(d.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:d.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Po)},{configurationStatus:()=>pe(d.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:d.storage.encryptionPluginName.value,supportedPlugins:Object.values(Tr)},{configurationStatus:()=>d.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return s.forEach(r=>{r.configurationStatus()?(e=e.filter(r.activePluginName?n=>!(n!==r.activePluginName&&r.supportedPlugins.includes(n)):n=>pe(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(Bc()),...e]}addMissingPlugins(e,s,i){let r=e.shouldAddMissingPlugins||s,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(Q_(ki,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),s=[...Object.keys(_o),...Fc],i=[],r=[];e.forEach(n=>{s.includes(n)?i.push(n):r.push(n)}),r.length>0&&this.logger.warn(tm(ki,r)),Ue(()=>{d.plugins.totalPluginsToLoad.value=e.length,d.plugins.activePlugins.value=i,d.plugins.failedPlugins.value=r})}registerLocalPlugins(){let e=[];Object.entries(_o).forEach(([s,i])=>{d.plugins.activePlugins.value.includes(s)&&($(i)?this.register([i()]):e.push(s))}),e.length>0&&(d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,...e],this.logger.error(sm(ki,e)))}registerRemotePlugins(){let e=Iy(d.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async s=>{await e[s]().then(i=>this.register([i.default()])).catch(i=>{d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,s],this.onError(i,`Failed to load plugin "${s}"`,i)})})).catch(s=>{this.onError(s)})}invokeMultiple(e,...s){try{return this.engine.invokeMultiple(e,...s)}catch(i){return this.onError(i,e),[]}}invokeSingle(e,...s){try{return this.engine.invokeSingle(e,...s)}catch(i){return this.onError(i,e),null}}register(e){e.forEach(s=>{try{this.engine.register(s,d)}catch(i){d.plugins.failedPlugins.value=[...d.plugins.failedPlugins.value,s.name],this.onError(i,`Failed to register plugin "${s.name}"`)}})}unregisterLocalPlugins(){Object.keys(_o).forEach(e=>{try{this.engine.unregister(e)}catch(s){this.onError(s,`Failed to unregister plugin "${e}"`)}})}onError(e,s,i){this.errorHandler.onError({error:e,context:ki,customMessage:s,groupingHash:i})}},it="cookieStorage",ot="localStorage",dt="sessionStorage",kt="memoryStorage",ms="none",Ry="test_rudder_cookie",Ty="test_rudder_ls",Oy="test_rudder_ss",Py="rl_user_id",Cy="rl_trait",xy="rl_anonymous_id",Dy="rl_group_id",Ny="rl_group_trait",Ly="rl_page_init_referrer",$y="rl_page_init_referring_domain",Fy="rl_session",My="rl_auth_token",Fs={userId:Py,userTraits:Cy,anonymousId:xy,groupId:Dy,groupTraits:Ny,initialReferrer:Ly,initialReferringDomain:$y,sessionInfo:Fy,authToken:My},By="__tld__",Uc="clientDataInCookie",Vc="clientDataInLocalStorage",Uy="clientDataInMemory",jc="clientDataInSessionStorage",Gc=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],Ms={[it]:Uc,[ot]:Vc,[kt]:Uy,[dt]:jc},qu=(t,e)=>{try{return encodeURIComponent(t)}catch(s){e?.error(Av,s);return}},zu=t=>{try{return decodeURIComponent(t)}catch{return}},Vy=t=>{let e={},s=t.split(/\s*;\s*/),i;return s[0]&&s.forEach(r=>{i=r.split("=");let n=i[0]?zu(i[0]):void 0;n&&(e[n]=i[1]?zu(i[1]):void 0)}),e},jy=(t,e,s,i)=>{let r={...s||{}},n=`${qu(t,i)}=${qu(e,i)}`;rt(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},Lo=()=>{let t=globalThis.document.cookie;return Vy(t)},Gy=t=>Lo()[t],$t=function(t,e,s,i){switch(arguments.length){case 4:case 3:case 2:return jy(t,e,s,i);case 1:return t?Gy(t):Lo();default:return Lo()}},Hy=t=>{let e=document.createElement("a");return e.href=t,e.hostname},qy=t=>{let s=(typeof globalThis.URL!="function"?Hy(t):new URL(t).hostname)?.split(".")??[],i=s[s.length-1],r=[];if(s.length===4&&i&&i===parseInt(i,10).toString())return r;if(s.length<=1)return s[0]&&s[0].indexOf("localhost")!==-1?["localhost"]:r;for(let n=s.length-2;n>=0;n-=1)r.push(s.slice(n).join("."));return r},zy=t=>{let e=qy(t);for(let s=0;s<e.length;s+=1){let i=e[s],r=By,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""},Ky=()=>{let t=`.${zy(globalThis.location.href)}`;return{maxage:Uv,path:"/",domain:!t||t==="."?void 0:t,samesite:"Lax",enabled:!0}},Wy=()=>({enabled:!0}),Jy=()=>({enabled:!0}),Yy=()=>({enabled:!0}),$o=class{constructor(e){we(this,"isEnabled",!0);we(this,"length",0);we(this,"data",{});this.options=Yy(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,s){return this.data[e]=s,this.length=Object.keys(this.data).length,s}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)}},Br=new $o(Ut);Pr={exports:{}},Qy=Pr.exports;eb=Zy(),fs=Xy(eb),Hc=t=>{let e=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"],s=[22,1014];return t instanceof DOMException?e.includes(t.name)||s.includes(t.code):!1},Bs=(t=ot,e,s)=>{let i,r,n=Iv(wo,t),o="unavailable",a=!0,l;try{switch(t){case kt:return!0;case it:i=e,r=Ry;break;case ot:i=e??globalThis.localStorage,r=Ty;break;case dt:i=e??globalThis.sessionStorage,r=Oy;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,Hc(u)&&(o="full")}return a||s?.warn(`${n}${o}.`,l),!1},Fo=class{constructor(e){we(this,"isSupportAvailable",!0);we(this,"isEnabled",!0);we(this,"length",0);this.options=Wy(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isSupportAvailable=Bs(ot),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){fs.set(e,s),this.length=fs.len()}getItem(e){let s=fs.get(e);return Ve(s)?null:s}removeItem(e){fs.remove(e),this.length=fs.len()}clear(){fs.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return fs.keys()}},aa=new Fo(Ut),Mo=class{constructor(e){we(this,"isSupportAvailable",!0);we(this,"isEnabled",!0);we(this,"length",0);this.options=Jy(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isSupportAvailable=Bs(dt),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){this.store&&(this.store.setItem(e,s),this.length=this.store.length)}getItem(e){if(!this.store)return null;let s=this.store.getItem(e);return Ve(s)?null:s}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 s=0;s<this.store.length;s+=1){let i=this.store.key(s);i!==null&&e.push(i)}return e}},la=new Mo(Ut),Bo=class{constructor(e){we(this,"isSupportAvailable",!0);we(this,"isEnabled",!0);we(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=Ky()),this.options=$e(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=Bs(it,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){return $t(e,s,this.options,this.logger),this.length=Object.keys($t()).length,!0}getItem(e){let s=$t(e);return Ve(s)?null:s}removeItem(e){let s=this.setItem(e,null);return this.length=Object.keys($t()).length,s}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys($t())}},ua=new Bo(Ut),vt=t=>{switch(t){case ot:return aa;case dt:return la;case kt:return Br;case it:return ua;default:return Br}},tb=t=>{let e=ua.configure(t);d.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},sb=t=>{aa.configure(t)},ib=t=>{Br.configure(t)},rb=t=>{la.configure(t)},nb=(t={},e={},s={},i={})=>{tb(t),sb(e),ib(s),rb(i)},Uo=class{constructor(e,s,i){this.id=e.id,this.name=e.name,this.isEncrypted=e.isEncrypted??!1,this.validKeys=e.validKeys??{},this.engine=s,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:s,id:i,validKeys:r,noKeyValidation:n,noCompoundKey:o}=this;if(n)return o?e:[s,i,e].join(".");let a;return Object.values(r).forEach(l=>{l===e&&(a=o?e:[s,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{name:e,id:s,validKeys:i,noCompoundKey:r}=this,n=vt(kt);Object.keys(i).forEach(o=>{let a=this.get(i[o]),l=r?o:[e,s,o].join(".");n.setItem(l,a),this.remove(o)}),this.engine=n}set(e,s){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(_t(s,!1,[],this.logger)))}catch(r){if(Hc(r))this.logger.warn(H_(`Store ${this.id}`)),this.swapQueueStoreToInMemoryEngine(),this.set(e,s);else{let n=I_(e);this.onError(r,n,n)}}}get(e){let s=this.createValidKey(e),i;try{return!s||(i=this.decrypt(this.engine.getItem(s)),mt(i)||i==="")?null:JSON.parse(i)}catch(r){let n=d.storage.encryptionPluginName.value;if(!n||!d.plugins.failedPlugins.value.includes(n)){let a=R_(e);this.onError(r,a,a)}return null}}remove(e){let s=this.createValidKey(e);s&&this.engine.removeItem(s)}getOriginalEngine(){return this.originalEngine}decrypt(e){return mt(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,s){if(!this.isEncrypted||!e||typeof e!="string"||ov(e)==="")return e;let r=`storage.${s}`,n=this.pluginsManager?this.pluginsManager.invokeSingle(r,e):e;return typeof n>"u"?e:n??""}onError(e,s,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:s,groupingHash:i})}},ob=(t,e)=>{let s;if(t.consents.preConsent.value.enabled)switch(t.consents.preConsent.value.storage?.strategy){case"none":s=ms;break;case"session":e!=="sessionInfo"&&(s=ms);break;case"anonymousId":e!=="anonymousId"&&(s=ms);break}return s},Vo=class{constructor(e,s,i){we(this,"stores",{});we(this,"isInitialized",!1);this.errorHandler=s,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=d.loadOptions.value,s={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};nb(Ii($e(s.cookieStorageOptions??{},d.storage.cookie?.value??{})),Ii(s.localStorageOptions),Ii(s.inMemoryStorageOptions),Ii(s.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[kt,ot,it,dt].forEach(s=>{vt(s)?.isEnabled&&this.setStore({id:Ms[s],name:Ms[s],isEncrypted:!0,noCompoundKey:!0,type:s,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=d.storage.type.value,s=d.loadOptions.value.storage?.entries,i=d.consents.postConsent.value.storage;(pe(i?.type)||pe(i?.entries))&&(e=i?.type,s=i?.entries);let r=!0,n={};Gc.forEach(o=>{let a=o,l=o,u=s?.[a]?.type,h=ob(d,o)??u??e??Oo,g=this.getResolvedStorageTypeForEntry(h,o);g!==ms&&(r=!1),n={...n,[o]:{type:g,key:Fs[l]}}}),Ue(()=>{d.storage.type.value=e,d.storage.entries.value=n,d.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,s){let i=e;switch(e){case ot:vt(ot)?.isEnabled||(i=kt);break;case dt:vt(dt)?.isEnabled||(i=kt);break;case kt:case ms:break;case it:default:vt(it)?.isEnabled?i=it:vt(ot)?.isEnabled?i=ot:vt(dt)?.isEnabled?i=dt:i=kt;break}return i!==e&&this.logger.warn(q_(uv,s,e,i)),i}setStore(e){let s=vt(e.type);return this.stores[e.id]=new Uo(e,s,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},ab=t=>ve(t)&&ve(t.source)&&!mt(t.source.id)&&ve(t.source.config)&&Array.isArray(t.source.destinations),lb=t=>typeof t=="string"&&Ec.includes(t),qc=t=>{let e=new URL(t),{host:s,protocol:i}=e,r=s.split("."),n;return r.length>2?n=`${r[r.length-2]}.${r[r.length-1]}`:n=s,{topDomain:n,protocol:i}},ub=t=>{let{topDomain:e,protocol:s}=qc(t);return`${s}//${e}`},cb=(t,e)=>{let s=e?window.location.origin:ub(window.location.href),i=t.startsWith("/")?t.substring(1):t;return`${s}/${i}`},db=t=>{let{topDomain:e}=qc(window.location.href);return e===t},Vs=t=>t?.endsWith("/")?Vs(t.substring(0,t.length-1)):t,jo=t=>{try{return new URL(t).host}catch{return null}},zc=t=>jo(t)??"",hb=t=>{let e={};try{let s=new URL(t),i="utm_";s.searchParams.forEach((r,n)=>{if(n.startsWith(i)){let o=n.substring(i.length);o==="campaign"&&(o="name"),e[o]=r}})}catch{}return e},fb=t=>{let e=t;try{let s=new URL(t);e=s.origin+s.pathname+s.search}catch{}return e},gb=t=>t.replace(/\/{2,}/g,"/"),js=t=>{if(!ye(t))return!1;try{return $(globalThis.URL)&&new URL(t),rm.test(t)}catch{return!1}},mo="none",yo="immediate",pb=t=>t?.statsCollection?.errors?.enabled===!0,vb=t=>t?.statsCollection?.metrics?.enabled===!0,_b=t=>{let e={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(ve(t)){let s=te(t);e.storage=s.storage,Bt(s.integrations)&&(e.integrations=s.integrations),e.discardPreConsentEvents=s.discardPreConsentEvents===!0,e.sendPageEvent=s.sendPageEvent===!0,e.trackConsent=s.trackConsent===!0,Bt(s.consentManagement)&&(e.consentManagement=$e(s.consentManagement,{enabled:d.consents.enabled.value}))}return e},Wu=t=>Bt(t)||Array.isArray(t),mb=(t,e)=>{let{provider:s}=t,i=s?Po[s]:void 0;return s&&!i&&(e.error(h_(ht,s,Po)),s=void 0),{provider:s,consentManagerPluginName:i}},Kc=(t,e)=>{let s,i=[],r=[],n=!1,o,a=t?.enabled===!0;Bt(t)&&a&&({provider:o,consentManagerPluginName:s}=mb(t,e),Wu(t.allowedConsentIds)&&(i=t.allowedConsentIds,n=!0),Wu(t.deniedConsentIds)&&(r=t.deniedConsentIds,n=!0));let l={allowedConsentIds:i,deniedConsentIds:r};return a=a&&!!s,{provider:o,consentManagerPluginName:s,initialized:n,enabled:a,consentsData:l}},yb=()=>{let t=document.querySelector("script[data-rsa-write-key]");if(t&&t.dataset.rsaWriteKey===d.lifecycle.writeKey.value)return t.src;let e=document.getElementsByTagName("script"),s=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let r=i.getAttribute("src");if(r&&s.test(r))return r}},bb=t=>{d.reporting.isErrorReportingEnabled.value=pb(t.source.config)&&!_v(),d.reporting.isMetricsReportingEnabled.value=vb(t.source.config)},Eb=t=>{let{useServerSideCookies:e,dataServiceEndpoint:s,storage:i,setCookieDomain:r,sameDomainCookiesOnly:n}=d.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let u=o.domain??r,c=pe(u)&&!db(Su(u))||n,h=cb(s??am,c);if(js(h)){l=Vs(h);let g=jo(window.location.href),f=jo(h);g!==f&&(o={...o,samesite:"None",secure:!0}),!n&&c&&f!==Su(u)&&(a=!1,t.warn(D_(ht,u,f)))}else a=!1}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},Sb=t=>{let{storage:e}=d.loadOptions.value,s=e?.type;pe(s)&&!lb(s)&&(t.warn(P_(ht,s,Oo)),s=Oo);let i=e?.encryption?.version,r=i&&Tr[i];!Ve(i)&&Ve(r)?(t.warn(C_(ht,i,Tr,ps)),i=ps):Ve(i)&&(i=ps);let n=e?.migrate,o=n&&i===ps;n===!0&&o!==n&&t.warn(x_(ht,i,ps));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=Eb(t);Ue(()=>{d.storage.type.value=s,d.storage.cookie.value=u,d.serverCookies.isEnabledServerSideCookies.value=a,d.serverCookies.dataServiceUrl.value=l,d.storage.encryptionPluginName.value=Tr[i],d.storage.migrate.value=o})},wb=t=>{let{provider:e,consentManagerPluginName:s,initialized:i,enabled:r,consentsData:n}=Kc(d.loadOptions.value.consentManagement,t),o=d.loadOptions.value.preConsent,a=o?.storage?.strategy??mo,l=["none","session","anonymousId"];pe(a)&&!l.includes(a)&&(a=mo,t.warn(J_(ht,o?.storage?.strategy,mo)));let u=o?.events?.delivery??yo,c=["immediate","buffer"];pe(u)&&!c.includes(u)&&(u=yo,t.warn(Y_(ht,o?.events?.delivery,yo))),Ue(()=>{d.consents.activeConsentManagerPluginName.value=s,d.consents.initialized.value=i,d.consents.enabled.value=r,d.consents.data.value=n,d.consents.provider.value=e,d.consents.preConsent.value={enabled:d.loadOptions.value.preConsent?.enabled===!0&&i===!1&&r===!0,storage:{strategy:a},events:{delivery:u}}})},kb=t=>{let e=d.consents.resolutionStrategy.value,s;ve(t.consentManagementMetadata)&&(d.consents.provider.value&&(e=t.consentManagementMetadata.providers.find(i=>i.provider===d.consents.provider.value)?.resolutionStrategy??d.consents.resolutionStrategy.value),s=t.consentManagementMetadata),d.consents.provider.value==="custom"&&(e=void 0),Ue(()=>{d.consents.metadata.value=te(s),d.consents.resolutionStrategy.value=e})},Ab=t=>{if(d.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",s=e;d.loadOptions.value.useBeacon&&(d.capabilities.isBeaconAvailable.value?s="BeaconQueue":(s=e,t.warn(F_(ht)))),Ue(()=>{d.dataPlaneEvents.eventsQueuePluginName.value=s})}},Ib=(t,e,s,i,r)=>{let n=new URLSearchParams({p:hc,v:Di,build:Li,writeKey:e,lockIntegrationsVersion:s.toString(),lockPluginsVersion:i.toString()}),o=Rc,a=n,l="/sourceConfig/",u="";if(js(t)){let c=new URL(t);Vs(c.pathname).endsWith("/sourceConfig")||(c.pathname=`${Vs(c.pathname)}/sourceConfig/`),c.pathname=gb(c.pathname),n.forEach((h,g)=>{c.searchParams.get(g)===null&&c.searchParams.set(g,h)}),o=c.origin,l=c.pathname,a=c.searchParams,u=c.hash}else r.warn(K_(ht,t));return`${o}${l}?${a}${u}`},Rb=t=>t.map(e=>({id:e.id,displayName:e.destinationDefinition.displayName,enabled:e.enabled,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation??!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError??!1,userFriendlyId:_y(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===um})),Wc=(t,e,s,i,r,n,o)=>{let a;if(n){if(!js(n))return o.error(d_(ht,t,n)),null;a=Vs(n)}else if(a=s,d.context.app.value.installType==="cdn"){let l=yb();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return r&&(a=a.replace(new RegExp(`/${oa}/${Li}/${e}$`),`/${i}/${Li}/${e}`)),a},Tb=(t,e,s,i)=>Wc("integrations",qr,Ac,t,e,s,i),Ob=(t,e,s,i)=>Wc("plugins",kc,Ic,t,e,s,i),Go=class{constructor(e,s,i){this.errorHandler=s,this.logger=i,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}attachEffects(){At(()=>{this.logger.setMinLogLevel(d.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:s,lockIntegrationsVersion:i,lockPluginsVersion:r,destSDKBaseURL:n,pluginsSDKBaseURL:o,integrations:a}=d.loadOptions.value,l=Tb(Di,i,n,this.logger);if(rt(l))return;let u;u=Ob(Di,r,o,this.logger),u!==null&&(this.attachEffects(),d.lifecycle.activeDataplaneUrl.value=Vs(d.lifecycle.dataPlaneUrl.value),Sb(this.logger),wb(this.logger),Ab(this.logger),Ue(()=>{d.lifecycle.integrationsCDNPath.value=l,d.lifecycle.pluginsCDNPath.value=u,e&&(d.lifecycle.logLevel.value=e),d.lifecycle.sourceConfigUrl.value=Ib(s,d.lifecycle.writeKey.value,i,r,this.logger),d.metrics.metricsServiceUrl.value=`${d.lifecycle.activeDataplaneUrl.value}/${lm}`,d.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,s,i){this.errorHandler.onError({error:e,context:ht,customMessage:s,groupingHash:i})}processConfig(e,s){if(!pe(e)){pe(s)?this.onError(s.error,Fu):this.onError(new Error(Fu));return}let i;try{ye(e)?i=JSON.parse(e):i=e}catch(n){this.onError(n,Lu);return}if(!ab(i)){this.onError(new Error(Lu));return}if(i.source.enabled===!1){this.logger.error(o_);return}bb(i);let r=i.source.destinations.length>0?Rb(i.source.destinations):[];Ue(()=>{d.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},d.nativeDestinations.configuredDestinations.value=r,d.plugins.pluginsToLoadFromConfig.value=d.loadOptions.value.plugins??[],kb(i),d.lifecycle.status.value="configured"})}getConfig(){let e=d.loadOptions.value.getSourceConfig;if(e){if(!$(e)){this.logger.error(c_(ht));return}let s=e();s instanceof Promise?s.then(i=>this.processConfig(i)).catch(i=>{this.onError(i,"SourceConfig")}):this.processConfig(s)}else this.httpClient.getAsyncData({url:d.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},Pb=()=>{let t=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return t?.[1]?t[1]:"NA"},Jc=(t=()=>document)=>t()?.referrer||"$direct",Cb=(t=()=>document)=>{let s=t().getElementsByTagName("link"),i="";for(let r=0;s[r];r+=1){let n=s[r];if(n.getAttribute("rel")==="canonical"&&!i){i=n.getAttribute("href")??"";break}}return i},xb=(t=()=>globalThis.navigator)=>{let e=t();if(Ve(e))return null;let{userAgent:s}=e,{brave:i}=e;if(i&&Object.getPrototypeOf(i).isBrave){let r=s.match(/(chrome)\/([\w.]+)/i);r&&(s=`${s} Brave/${r[2]}`)}return s},Db=(t=()=>globalThis.navigator)=>{let e=t();return Ve(e)?null:e.language??e.browserLanguage},Yc=(t=()=>globalThis.location,e=()=>document)=>{let s=t(),i=Cb(e),r=s.pathname,{href:n}=s,o=n,{search:a}=s;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,r=h.pathname}catch{}let l=fb(o),{title:u}=e(),c=Jc(e);return{path:r,referrer:c,referring_domain:zc(c),search:a,title:u,url:l,tab_url:n}},Nb=(t,e="none")=>{e==="none"&&t(void 0),e==="default"&&t(navigator.userAgentData),e==="full"&&navigator.userAgentData?.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(s=>{t(s)}).catch(()=>{t()})},Lb=()=>{let t=globalThis.document.createElement("div");return t.setAttribute("data-a-b","c"),t.dataset?t.dataset.aB==="c":!1},Ho={URL:()=>!$(globalThis.URL)||!$(globalThis.URLSearchParams),Promise:()=>!$(globalThis.Promise),"Number.isNaN":()=>!$(globalThis.Number.isNaN),"Number.isInteger":()=>!$(globalThis.Number.isInteger),"Array.from":()=>!$(globalThis.Array.from),"Array.prototype.find":()=>!$(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!$(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!$(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!$(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!$(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!$(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!$(globalThis.String.fromCodePoint),"Object.entries":()=>!$(globalThis.Object.entries),"Object.values":()=>!$(globalThis.Object.values),"Object.assign":()=>!$(globalThis.Object.assign),"Object.fromEntries":()=>!$(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!Lb(),TextEncoder:()=>!$(globalThis.TextEncoder)||!$(globalThis.TextDecoder),requestAnimationFrame:()=>!$(globalThis.requestAnimationFrame)||!$(globalThis.cancelAnimationFrame),CustomEvent:()=>!$(globalThis.CustomEvent),"navigator.sendBeacon":()=>!$(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!$(globalThis.Uint8Array),Set:()=>!$(globalThis.Set),atob:()=>!$(globalThis.atob)},$b=()=>{let t=Object.keys(Ho),e=!1;for(let s=0;s<t.length;s++){let i=Ho[t[s]];if($(i)&&i()){e=!0;break}}return e},Fb="https://polyfill-fastly.io/v3/polyfill.min.js",Mb=`${Fb}?version=3.111.0&features=${Object.keys(Ho).join("%2C")}`,Bb=10*1e3,Ju="rudderstackPolyfill",Ub=()=>!mt(globalThis.crypto)&&$(globalThis.crypto.getRandomValues),Yu=()=>!mt(globalThis.navigator.userAgentData),Vb=()=>!mt(globalThis.navigator.sendBeacon)&&$(globalThis.navigator.sendBeacon),Xu=()=>{let t={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return t={width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight},t},qo=class{constructor(e,s,i){this.httpClient=e,this.errorHandler=s,this.logger=i,this.externalSrcLoader=new Lr(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Ue(()=>{d.capabilities.storage.isCookieStorageAvailable.value=Bs(it,vt(it),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=Bs(ot,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=Bs(dt,void 0,this.logger),d.capabilities.isBeaconAvailable.value=Vb(),d.capabilities.isUaCHAvailable.value=Yu(),d.capabilities.isCryptoAvailable.value=Ub(),d.capabilities.isOnline.value=globalThis.navigator.onLine,d.context.userAgent.value=xb(),d.context.locale.value=Db(),d.context.screen.value=Xu(),d.context.timezone.value=Pb(),Yu()&&Nb(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),At(()=>{d.loadOptions.value.sendAdblockPage===!0&&d.lifecycle.sourceConfigUrl.value!==void 0&&Dc(this.httpClient)})}prepareBrowserCapabilities(){d.capabilities.isLegacyDOM.value=$b();let e=d.loadOptions.value.polyfillURL,s=Mb;if(Us(e)&&(js(e)?s=e:this.logger.warn(Z_(wo,e))),d.loadOptions.value.polyfillIfRequired&&d.capabilities.isLegacyDOM.value&&js(s)){let r=s!==d.loadOptions.value.polyfillURL;if(r){let n=`RS_polyfillCallback_${d.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[n]};globalThis[n]=o,s=`${s}&callback=${n}`}this.externalSrcLoader.loadJSFile({url:s,id:Ju,async:!0,timeout:Bb,callback:n=>{n?r||this.onReady():this.onError(new Error(W_(Ju,s)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{d.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{d.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Gv(()=>{d.context.screen.value=Xu()},this))}onReady(){this.detectBrowserCapabilities(),d.lifecycle.status.value="browserCapabilitiesReady"}onError(e,s){this.errorHandler.onError({error:e,context:wo,groupingHash:s})}},jb="web",Gb=["integrations","anonymousId","originalTimestamp"],Hb=["library","consentManagement","userAgent","ua-ch","screen"],bo=["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"],Cr="CustomContext",qb=new Set(["__proto__","constructor","prototype"]),zb=Function.prototype.toString.call(Object),Kb=t=>{if(!ve(t))return!1;let e=Object.getPrototypeOf(t);if(e===null)return!0;let s=Object.prototype.hasOwnProperty.call(e,"constructor")?e.constructor:void 0;return typeof s=="function"&&s.prototype===e&&Function.prototype.toString.call(s)===zb},ca=(t,e=new Set)=>{if(!ve(t)&&!Array.isArray(t))return!1;let s=t;return e.has(s)?!1:(e.add(s),Object.keys(s).some(i=>qb.has(i)||ca(s[i],e)))},Xc=(t,e)=>{let s={};return Object.keys(t).forEach(i=>{if(Hb.includes(i)){e.warn(L_(Cr,i));return}Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:t[i]===t?s:t[i],writable:!0})}),s},Qc=(t,e)=>{try{if(!Kb(t)){e.warn(Rr(Cr));return}let s=Xc(t,e);if(ca(s)){e.warn(Rr(Cr));return}let i=re(s,e);return te(i)}catch{e.warn(Rr(Cr));return}},zo=class{constructor(e,s){this.state=e,this.logger=s}set(e){let s=Qc(e,this.logger);if(!s)return;let i=$e(te(this.state.value),s);this.state.value=xi(i)}get(){return te(this.state.value)}clear(){this.state.value={}}},Zc=t=>typeof t=="number"&&!Number.isNaN(t),Wb=(t,e)=>e.toString().length>=t,Ur=t=>Zc(t)&&t>=0&&Number.isInteger(t),Qu=10,ed=t=>{let{cutOff:e}=t,s=Date.now();return!!(e?.enabled&&e.expiresAt&&s>e.expiresAt)},Zu=t=>!t.expiresAt||Date.now()>t.expiresAt||ed(t),Jb=()=>Date.now(),Yb=(t,e)=>!t||!Ur(t)||!Wb(Qu,t)?(e.warn(G_(gs,t,Qu)),!1):!0,Xb=t=>{if(t?.enabled)return t.expiresAt??(Ur(t.duration)?Date.now()+t.duration:void 0)},Qb=t=>{let{timeout:e,cutOff:s}=t,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...s&&{cutOff:s}}},Zb=(t,e)=>({id:Yb(t,e)?t:Jb(),sessionStart:void 0,manualTrack:!0}),Ti=t=>t===it||t===ot||t===dt||t===kt,Ko=()=>Vr(),e0=t=>{if(tv(t)){let{entries:e,...s}=vo;return{...s,entries:{...e,anonymousId:t}}}return ve(t)&&ve(t.entries)?$e(vo,t):{...vo}},t0=t=>{let e=Yc(),s={};return Object.keys(e).forEach(i=>{s[i]=t?.[i]||e[i]}),s.initial_referrer=t?.initial_referrer||d.session.initialReferrer.value,s.initial_referring_domain=t?.initial_referring_domain||d.session.initialReferringDomain.value,s},s0=(t,e)=>{let s=e?.page||{},i=t,r=Yc();return Object.keys(r).forEach(n=>{Ve(i[n])&&(i[n]=s[n]||r[n])}),Ve(i.initial_referrer)&&(i.initial_referrer=s.initial_referrer||d.session.initialReferrer.value),Ve(i.initial_referring_domain)&&(i.initial_referring_domain=s.initial_referring_domain||d.session.initialReferringDomain.value),i},Eo=(t,e,s)=>{ve(t)&&Object.keys(t).forEach(i=>{(bo.includes(i)||bo.includes(i.toLowerCase()))&&s.warn(N_(ko,i,e,bo))})},i0=(t,e)=>{let{properties:s,traits:i,context:r}=t,{traits:n}=r;Eo(s,"properties",e),Eo(i,"traits",e),Eo(n,"context.traits",e)},r0=(t,e)=>{e.anonymousId&&ye(e.anonymousId)&&(t.anonymousId=e.anonymousId),Bt(e.integrations)&&(t.integrations=e.integrations),e.originalTimestamp&&ye(e.originalTimestamp)&&(t.originalTimestamp=e.originalTimestamp)},n0=(t,e,s)=>{let i=t,r=n=>{let o=Xc(n,s);if(ca(o)){s.warn(Rr(ko));return}i=$e(i,o)};return Object.keys(e).forEach(n=>{Gb.includes(n)||(n!=="context"?r({[n]:e[n]}):!Ve(e[n])&&ve(e[n])?r(e[n]):s.warn($_(ko)))}),i},o0=(t,e,s)=>{ve(e)&&(r0(t,e),t.context=n0(t.context,e,s))},a0=t=>{let e;return d.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=d.consents.postConsent.value.integrations??d.nativeDestinations.loadOnlyIntegrations.value:t?e=t:e=wc,te(e)},Ai=(t,e,s,i,r={})=>{let n={channel:jb,context:{traits:te(d.session.userTraits.value),sessionId:d.session.sessionInfo.value.id||void 0,sessionStart:d.session.sessionInfo.value.sessionStart||void 0,...d.consents.enabled.value&&{consentManagement:{deniedConsentIds:te(d.consents.data.value.deniedConsentIds),allowedConsentIds:te(d.consents.data.value.allowedConsentIds),provider:d.consents.provider.value,resolutionStrategy:d.consents.resolutionStrategy.value}},"ua-ch":d.context["ua-ch"].value,app:d.context.app.value,library:d.context.library.value,userAgent:d.context.userAgent.value,os:d.context.os.value,locale:d.context.locale.value,screen:d.context.screen.value,campaign:hb(globalThis.location.href),page:t0(s),timezone:d.context.timezone.value,...d.autoTrack.enabled.value&&{autoTrack:{...d.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:d.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:bv(),messageId:Vr(),userId:t.userId||d.session.userId.value};Ti(d.storage.entries.value.anonymousId?.type)?n.anonymousId=d.session.anonymousId.value:n.anonymousId=Ko(),d.storage.trulyAnonymousTracking.value&&(n.context.trulyAnonymousTracking=!0),t.type==="identify"&&(n.context.traits=d.storage.entries.value.userTraits?.type!==ms?te(d.session.userTraits.value):t.context.traits),t.type==="group"&&((t.groupId||d.session.groupId.value)&&(n.groupId=t.groupId||d.session.groupId.value),(t.traits||d.session.groupTraits.value)&&(n.traits=d.storage.entries.value.groupTraits?.type!==ms?te(d.session.groupTraits.value):t.traits));let o=$e(t,n),a=$e(o,{context:r});return a.event===void 0&&(a.event=null),a.properties===void 0&&(a.properties=null),o0(a,e,i),i0(a,i),a.integrations=a0(a.integrations),a},Wo=class{constructor(e){this.logger=e}generatePageEvent(e,s,i,r,n={}){let o=i??{};return o=s0(o,r),Ai({properties:o,name:s,category:e,type:"page"},r,o,this.logger,n)}generateTrackEvent(e,s,i,r={}){return Ai({properties:s,event:e,type:"track"},i,void 0,this.logger,r)}generateIdentifyEvent(e,s,i,r={}){return Ai({userId:e,type:"identify",context:{traits:s}},i,void 0,this.logger,r)}generateAliasEvent(e,s,i,r={}){let o=Ai({previousId:s,type:"alias"},i,void 0,this.logger,r);return o.userId=e??o.userId,o}generateGroupEvent(e,s,i,r={}){let n={type:"group"};return e&&(n.groupId=e),s&&(n.traits=s),Ai(n,i,void 0,this.logger,r)}create(e,s={}){let i,{type:r,name:n,properties:o,options:a,category:l,userId:u,traits:c,to:h,from:g,groupId:f}=e;switch(r){case"page":i=this.generatePageEvent(l,n,o,a,s);break;case"track":i=this.generateTrackEvent(n,o,a,s);break;case"identify":i=this.generateIdentifyEvent(u,c,a,s);break;case"alias":i=this.generateAliasEvent(h,g,a,s);break;default:i=this.generateGroupEvent(f,c,a,s);break}return i}},Jo=class{constructor(e,s,i,r){this.eventRepository=e,this.userSessionManager=s,this.errorHandler=i,this.logger=r,this.eventFactory=new Wo(this.logger)}init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e,s){this.userSessionManager.refreshSession();let i=this.eventFactory.create(e,s);this.eventRepository.enqueue(i,e.callback)}},Yo=class{constructor(e,s,i,r,n){this.storeManager=s,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:s}=d.loadOptions.value,i;Us(e)&&typeof e=="string"&&(i=this.getExternalAnonymousIdByCookieName(e)),this.setAnonymousId(i??this.getAnonymousId(s)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e;if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let s=this.getConfiguredSessionTrackingInfo(),i=this.getSessionInfo()??ce.sessionInfo;e={autoTrack:s.autoTrack&&i.manualTrack!==!0,timeout:s.timeout,manualTrack:i.manualTrack,expiresAt:i.expiresAt,id:i.id,sessionStart:i.sessionStart},!e.autoTrack&&e.manualTrack!==!0?e=ce.sessionInfo:s.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:s.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=ce.sessionInfo;d.session.sessionInfo.value=e,d.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(d.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),s=this.getInitialReferringDomain();if(e&&s)this.setInitialReferrer(e),this.setInitialReferringDomain(s);else{let i=e||Jc();this.setInitialReferrer(i),this.setInitialReferringDomain(zc(i))}}isPersistenceEnabledForStorageEntry(e){return Ti(d.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=d.storage.entries.value,s=[it,ot,dt];Object.keys(e).forEach(i=>{let r=i,n=e[r]?.type,o=this.storeManager?.getStore(Ms[n]);o&&s.forEach(a=>{let l=this.storeManager?.getStore(Ms[a]);if(l&&a!==n){let u=l.get(Fs[r]);ev(u)&&o.set(Fs[r],u),l.remove(Fs[r])}})})}migrateStorageIfNeeded(e,s){if(!d.storage.migrate.value)return;let i=e??[];i.length===0&&[Uc,Vc,jc].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(s??Object.keys(Fs)).forEach(n=>{let o=Fs[n];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);mt(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=d.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let s,i=d.loadOptions.value.sessions?.timeout;Ur(i)?s=i:(this.logger.warn(M_(gs,i,Ao)),s=Ao),s===0&&(this.logger.warn(V_(gs)),e=!1),s>0&&s<xu&&this.logger.warn(j_(gs,s,xu));let r=this.getCutOffInfo(s);return{timeout:s,autoTrack:e,cutOff:r}}getCutOffInfo(e){let s=d.loadOptions.value.sessions.cutOff,i,r=!1;return s.enabled===!0&&(i=s.duration,r=!0,Ur(i)?i<e&&(this.logger.warn(U_(gs,i,e)),r=!1):(this.logger.warn(B_(gs,i,Cu)),i=Cu)),{enabled:r,duration:i}}onError(e,s,i){this.errorHandler.onError({error:e,context:gs,customMessage:s,groupingHash:i})}getEncryptedCookieData(e,s){let i=[];return e.forEach(r=>{let n=s?.encrypt(_t(r.value,!1,[],this.logger));Us(n)&&i.push({name:r.name,value:n})}),i}makeRequestToSetCookie(e,s){this.httpClient?.getAsyncData({url:d.serverCookies.dataServiceUrl.value,options:{method:"POST",data:_t({reqType:"setCookies",workspaceId:d.source.value?.workspaceId,data:{options:{maxAge:d.storage.cookie.value?.maxage,path:d.storage.cookie.value?.path,domain:d.storage.cookie.value?.domain,sameSite:d.storage.cookie.value?.samesite,secure:d.storage.cookie.value?.secure,expires:d.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:s})}setServerSideCookies(e,s,i){let r=Object.keys(e),n=()=>r.map(u=>({name:e[u].name,value:d.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=>{s&&s(u.name,u.value)})};try{let u={};r.forEach(h=>{u[e[h].name]=d.session[h].value});let c=this.getEncryptedCookieData(n(),i);c.length>0?this.makeRequestToSetCookie(c,(h,g)=>{a(),g?.xhr?.status===200?n().forEach(f=>{let p=o[f.name],_=i?.get(f.name);_t(u[f.name],!1,[])!==_t(_,!1,[])&&(rt(p)&&rt(_)&&this.logger.error(O_(f.name)),s&&s(f.name,f.value))}):(this.logger.error(T_(g?.xhr?.status)),l())}):(l(),a())}catch(u){this.onError(u,Mu,Mu),l(),a()}}syncValueToStorage(e){let s=d.storage.entries.value,i=s[e]?.type;if(Ti(i)){let r=this.storeManager.getStore(Ms[i]),n=s[e]?.key,o=d.session[e].value;o&&(ye(o)||Bt(o))?d.serverCookies.isEnabledServerSideCookies.value&&i===it?(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)},hm)):r?.set(n,o):r?.remove(n)}}registerEffects(){Gc.forEach(e=>{At(()=>{this.syncValueToStorage(e)})})}setAnonymousId(e,s){let i=e;(!ye(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&s&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",s)),i=i||Ko()):i=ce.anonymousId,d.session.anonymousId.value=i}getAnonymousId(e){let s=d.storage.entries.value.anonymousId?.type;if(Ti(s)){let i=d.session.anonymousId.value;(!i||i===ce.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",vt,e)),d.session.anonymousId.value=i||Ko()}return d.session.anonymousId.value}getEntryValue(e){let s=d.storage.entries.value,i=s[e]?.type;if(Ti(i)){let r=this.storeManager?.getStore(Ms[i]);this.migrateStorageIfNeeded([r],[e]);let n=s[e]?.key;return r?.get(n)??null}return null}getExternalAnonymousIdByCookieName(e){let s=vt(it);return s?.isEnabled?s.getItem(e)??null:null}getUserSessionValue(e){return this.serverSideCookiesRequestInProgress[e]?d.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()??ce.sessionInfo;return e.autoTrack&&!Zu(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??ce.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=d.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),d.session.sessionInfo.value=e,d.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=d.session,{manualTrack:s,autoTrack:i,timeout:r,cutOff:n}=e.sessionInfo.value;if(i){let o={...ce.sessionInfo,timeout:r};n&&(o.cutOff={enabled:n.enabled,duration:n.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else s&&this.startManualTrackingInternal()}reset(e){let{session:s}=d,i=e0(e);Ue(()=>{Object.keys(ce).forEach(r=>{let n=r;if(i.entries[n]===!0)switch(r){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:s[n].value=ce[n];break}})})}setUserId(e){d.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:ce.userId}setUserTraits(e){d.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&ve(e)?$e(d.session.userTraits.value??ce.userTraits,e):ce.userTraits}setGroupId(e){d.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:ce.groupId}setGroupTraits(e){d.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&ve(e)?$e(d.session.groupTraits.value??ce.groupTraits,e):ce.groupTraits}setInitialReferrer(e){d.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:ce.initialReferrer}setInitialReferringDomain(e){d.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:ce.initialReferringDomain}startOrRenewAutoTracking(e){let s=e;if(Zu(e))s=Qb(e);else{let i=Date.now(),r=e.timeout;s.expiresAt=i+r}if(ed(s)&&(s.cutOff.expiresAt=void 0),s.cutOff){let i=Xb(s.cutOff);s.cutOff.expiresAt=i}d.session.sessionInfo.value=s}start(e){d.session.sessionInfo.value=Zb(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){d.session.sessionInfo.value=ce.sessionInfo}setAuthToken(e){d.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:ce.authToken}},l0=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],u0=l0,c0=(t,e)=>{let s=te(e);return ye(s.setCookieDomain)||(s.setCookieDomain=void 0),["Strict","Lax","None"].includes(s.sameSiteCookie)||(s.sameSiteCookie=void 0),s.secureCookie=wt(s.secureCookie,t.secureCookie),s.sameDomainCookiesOnly=wt(s.sameDomainCookiesOnly,t.sameDomainCookiesOnly),["none","default","full"].includes(s.uaChTrackLevel)||(s.uaChTrackLevel=void 0),s.integrations=Nt(s.integrations),Array.isArray(s.plugins)||(s.plugins=u0),s.useGlobalIntegrationsConfigInEvents=wt(s.useGlobalIntegrationsConfigInEvents,t.useGlobalIntegrationsConfigInEvents),s.bufferDataPlaneEventsUntilReady=wt(s.bufferDataPlaneEventsUntilReady,t.bufferDataPlaneEventsUntilReady),s.sendAdblockPage=wt(s.sendAdblockPage,t.sendAdblockPage),s.useServerSideCookies=wt(s.useServerSideCookies,t.useServerSideCookies),ye(s.dataServiceEndpoint)||(s.dataServiceEndpoint=void 0),s.sendAdblockPageOptions=Nt(s.sendAdblockPageOptions),s.loadIntegration=wt(s.loadIntegration,t.loadIntegration),Bt(s.storage)?(s.storage.migrate=wt(s.storage.migrate,t.storage?.migrate),s.storage.cookie=Nt(s.storage.cookie),s.storage.encryption=Nt(s.storage.encryption),s.storage=xi(s.storage)):s.storage=void 0,s.destinationsQueueOptions=Nt(s.destinationsQueueOptions),s.queueOptions=Nt(s.queueOptions),s.lockIntegrationsVersion=wt(s.lockIntegrationsVersion,t.lockIntegrationsVersion),s.lockPluginsVersion=wt(s.lockPluginsVersion,t.lockPluginsVersion),Zc(s.dataPlaneEventsBufferTimeout)||(s.dataPlaneEventsBufferTimeout=void 0),s.beaconQueueOptions=Nt(s.beaconQueueOptions),s.preConsent=Nt(s.preConsent),s.sourceConfigurationOverride=Nt(s.sourceConfigurationOverride),$e(t,xi(s))},ec="dataplaneEventsQueue",tc="destinationsEventsQueue",d0="transformEvent",h0=(t,e)=>Object.keys(t).filter(s=>t[s]!==!0||!e[s]).reduce((s,i)=>{let r=te(s);return r[i]=t[i],r},{}),f0=(t,e)=>{let s=te(t),i=e.nativeDestinations.integrationsConfig.value,r=h0(t.integrations,i);return s.integrations=$e(i,r),s},g0=t=>t.consents.preConsent.value.enabled&&t.consents.preConsent.value.events?.delivery==="buffer",xr=(t,e,s,i)=>{if(pe(t))if($(t))try{t(...e)}catch(r){i.error(z_(s),r)}else i.error(Sc(s))},Xo=class{constructor(e,s,i,r,n){this.pluginsManager=e,this.errorHandler=r,this.httpClient=i,this.logger=n,this.storeManager=s}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${ec}.init`,d,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${d0}.init`,d,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${tc}.init`,d,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),At(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=g0(d),s;At(()=>{let i=d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&d.nativeDestinations.clientDestinationsReady.value===!1;(d.nativeDestinations.activeDestinations.value.some(n=>vy(n))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(s),this.dataplaneEventsQueue?.start())}),d.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(s=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},d.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(d.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,s){let i=f0(e,d);this.pluginsManager.invokeSingle(`${ec}.enqueue`,d,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let r=te(e);this.pluginsManager.invokeSingle(`${tc}.enqueue`,d,this.destinationsEventsQueue,r,this.errorHandler,this.logger);let n=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${ia}`;xr(s,[i],n,this.logger)}},sc=t=>{let e=new CustomEvent(t,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},p0=t=>ye(t)&&t.trim().length>0,v0=t=>js(t),Qo=class{constructor(){this.preloadBuffer=new Ro,this.initialized=!1,this.errorHandler=$c,this.logger=Ut,this.customContextStore=new zo(d.customContext,this.logger),this.externalSrcLoader=new Lr(this.logger),this.httpClient=xc,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new qo(this.httpClient,this.errorHandler,this.logger)}load(e,s,i={}){if(d.lifecycle.status.value)return;if(!p0(e)){this.logger.error(E_(Sr,e));return}if(!v0(s)){this.logger.error(S_(Sr,s));return}let{context:r,...n}=i,o=re(n);r!==void 0&&this.customContextStore.set(r),Ue(()=>{d.lifecycle.writeKey.value=te(e),d.lifecycle.dataPlaneUrl.value=te(s),d.loadOptions.value=c0(d.loadOptions.value,o),d.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(d.loadOptions.value.logLevel??bc),Ni("state",d,e),this.startLifecycle()}setCustomContext(e){if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["setCustomContext",e]];return}this.customContextStore.set(e)}getCustomContext(){return this.customContextStore.get()}clearCustomContext(){if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["clearCustomContext"]];return}this.customContextStore.clear()}startLifecycle(){At(()=>{try{switch(d.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 s="Failed to load the SDK";this.errorHandler.onError({error:e,context:Sr,customMessage:s,groupingHash:s})}})}onBrowserCapabilitiesReady(){Kv(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),d.consents.preConsent.value.enabled===!0?d.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(s=>this.preloadBuffer.enqueue(te(s)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&Wv([...e],this)}}prepareInternalServices(){this.pluginsManager=new No(gy,this.errorHandler,this.logger),this.storeManager=new Vo(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new Go(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Yo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Xo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Jo(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){d.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(d.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),d.consents.enabled.value&&!d.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",d,this.logger),d.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger)),this.eventManager?.init(),d.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Ue(()=>{d.lifecycle.loaded.value=!0,d.lifecycle.status.value="loaded"}),this.initialized=!0;let e=d.loadOptions.value.onLoaded;xr(e,[globalThis.rudderanalytics],cv,this.logger),sc("RSA_Initialised")}onReady(){d.lifecycle.status.value="readyExecuted",d.eventBuffer.readyCallbacksArray.value.forEach(e=>{xr(e,[],go,this.logger)}),sc("RSA_Ready")}processBufferedEvents(){let e=d.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let s=e.shift();d.eventBuffer.toBeProcessedArray.value=e,s&&this.processBufferedEvent(s),e=d.eventBuffer.toBeProcessedArray.value}}processBufferedEvent(e){switch(e[0]){case"setCustomContext":this.setCustomContext(e[1]);break;case"clearCustomContext":this.clearCustomContext();break;case"ready":this.ready(e[1],!0);break;case"page":this.page(e[1],!0,e[2]);break;case"track":this.track(e[1],!0,e[2]);break;case"identify":this.identify(e[1],!0,e[2]);break;case"alias":this.alias(e[1],!0,e[2]);break;case"group":this.group(e[1],!0,e[2]);break;case"reset":this.reset(e[1],!0);break;case"setAnonymousId":this.setAnonymousId(e[1],e[2],!0);break;case"startSession":this.startSession(e[1],!0);break;case"endSession":this.endSession(!0);break;case"consent":this.consent(e[1],!0);break;case"addCustomIntegration":this.addCustomIntegration(e[1],e[2],!0);break;default:return e}}getInvocationContext(e){return e===void 0?this.customContextStore.get():Qc(e,this.logger)??{}}loadDestinations(){if(d.lifecycle.status.value==="destinationsLoading"||d.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",d,this.pluginsManager,this.errorHandler,this.logger);let e=d.nativeDestinations.activeDestinations.value.length;if(e===0){Ue(()=>{d.nativeDestinations.clientDestinationsReady.value=!0,d.lifecycle.status.value="destinationsReady"});return}d.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",d,this.externalSrcLoader,this.errorHandler,this.logger),At(()=>{d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e&&Ue(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&Ue(()=>{d.lifecycle.status.value="ready"})}ready(e,s=!1){let i="ready";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!$(e)){this.logger.error(Sc(go));return}d.lifecycle.status.value==="readyExecuted"?xr(e,[],go,this.logger):d.eventBuffer.readyCallbacksArray.value=[...d.eventBuffer.readyCallbacksArray.value,e]}page(e,s=!1,i){let r="page";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback},n),d.capabilities.isAdBlocked.value===!0&&e.category!==Tu&&this.page(Nr(Tu,Dv,{path:Nv},d.loadOptions.value.sendAdblockPageOptions),s,n)}track(e,s=!1,i){let r="track";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event - ${e.name}`),d.metrics.triggered.value+=1,this.eventManager?.addEvent({type:r,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback},n)}identify(e,s=!1,i){let r="identify";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1,e.userId&&d.session.userId.value&&e.userId!==d.session.userId.value&&this.reset(),rt(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:r,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback},n)}alias(e,s=!1,i){let r="alias";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1;let o=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:r,to:e.to,from:o,options:e.options,callback:e.callback},n)}group(e,s=!1,i){let r="group";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e]];return}let n=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${r} event`),d.metrics.triggered.value+=1,rt(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:r,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback},n)}reset(e,s=!1){let i="reset";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.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,s,i=!1){let r="setAnonymousId";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,s]];return}this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.userSessionManager?.setAnonymousId(e,s)}getUserId(){return d.session.userId.value}getUserTraits(){return d.session.userTraits.value}getGroupId(){return d.session.groupId.value}getGroupTraits(){return d.session.groupTraits.value}startSession(e,s=!1){let i="startSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let s="endSession";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[s]];return}this.errorHandler.leaveBreadcrumb(`New ${s} invocation`),this.userSessionManager?.end()}getSessionId(){return this.userSessionManager?.getSessionId()??null}consent(e,s=!1){let i="consent";if(!d.lifecycle.loaded.value){d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Ue(()=>{d.consents.preConsent.value={...d.consents.preConsent.value,enabled:!1},d.consents.postConsent.value=_b(e);let{initialized:r,consentsData:n}=Kc(d.consents.postConsent.value.consentManagement,this.logger);d.consents.initialized.value=r,d.consents.data.value=n}),d.consents.enabled.value&&!d.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",d,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(s)}sendTrackingEvents(e){if(d.consents.postConsent.value.trackConsent){let s=sa(Lv);e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["track",s,this.customContextStore.get()]]:this.track(s)}if(d.consents.postConsent.value.sendPageEvent){let s=Nr();e?d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,["page",s,this.customContextStore.get()]]:this.page(s)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,s,i=!1){let r="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${r} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,s,d,this.logger);else{if(d.lifecycle.loaded.value){this.logger.error(im(Sr,e));return}d.eventBuffer.toBeProcessedArray.value=[...d.eventBuffer.toBeProcessedArray.value,[r,e,s]]}}},vs=class vs{constructor(){we(this,"analyticsInstances",{});we(this,"defaultAnalyticsKey","");we(this,"logger",Ut);try{if(vs.globalSingleton)return vs.globalSingleton;vs.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.setCustomContext=this.setCustomContext.bind(this),this.getCustomContext=this.getCustomContext.bind(this),this.clearCustomContext=this.clearCustomContext.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(),vs.globalSingleton=this,d.autoTrack.pageLifecycle.pageViewId.value=Vr(),d.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){me(e)}}createSafeAnalyticsInstance(){d.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(){$c.init(),ua.configure(),aa.configure(),la.configure(),Br.configure()}setDefaultInstanceKey(e){ye(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let s=e;return(!ye(s)||!s)&&(s=this.defaultAnalyticsKey),this.analyticsInstances[s]||(this.analyticsInstances[s]=new Qo),this.analyticsInstances[s]}catch(s){me(s);return}}load(e,s,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let r=gc(Oi);zv(r),Ni(Oi,te(r)),this.getAnalyticsInstance(e)?.load(e,s,i)}catch(r){me(r)}}trackPageLifecycleEvents(e){let{autoTrack:s,useBeacon:i}=e??{},{enabled:r=!1,options:n={},pageLifecycle:o}=s??{},{events:a=[fo.UNLOADED],enabled:l=r,options:u=n}=o??{};d.autoTrack.pageLifecycle.enabled.value=l,d.autoTrack.enabled.value=r||l,l&&this.setupPageUnloadTracking(a,i,u)}setupPageUnloadTracking(e,s,i){(e.length===0||e.includes(fo.UNLOADED))&&(s===!0?yv(r=>{if(r===!1&&d.lifecycle.loaded.value){let n=Date.now(),o=n-d.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(fo.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:lc(new Date(n))})}},!0):this.logger.warn(em(hv)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],s=qv(e);Ni(Oi,te([...e])),s.length>0&&(s.shift(),this.load.apply(null,s))}ready(e){try{this.getAnalyticsInstance()?.ready(re(e))}catch(s){me(s)}}page(e,s,i,r,n){try{this.getAnalyticsInstance()?.page(Nr(re(e),re(s),re(i),re(r),re(n)))}catch(o){me(o)}}track(e,s,i,r){try{this.getAnalyticsInstance()?.track(sa(re(e),re(s),re(i),re(r)))}catch(n){me(n)}}identify(e,s,i,r){try{this.getAnalyticsInstance()?.identify(nc(re(e),re(s),re(i),re(r)))}catch(n){me(n)}}alias(e,s,i,r){try{this.getAnalyticsInstance()?.alias(oc(re(e),re(s),re(i),re(r)))}catch(n){me(n)}}group(e,s,i,r){try{this.getAnalyticsInstance()?.group(ac(re(e),re(s),re(i),re(r)))}catch(n){me(n)}}reset(e){try{this.getAnalyticsInstance()?.reset(re(e))}catch(s){me(s)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(re(e))}catch(s){me(s);return}}setAnonymousId(e,s){try{this.getAnalyticsInstance()?.setAnonymousId(re(e),re(s))}catch(i){me(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){me(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){me(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){me(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){me(e);return}}setCustomContext(e){try{this.getAnalyticsInstance()?.setCustomContext(e)}catch(s){me(s)}}getCustomContext(){try{return this.getAnalyticsInstance()?.getCustomContext()??{}}catch(e){return me(e),{}}}clearCustomContext(){try{this.getAnalyticsInstance()?.clearCustomContext()}catch(e){me(e)}}startSession(e){try{this.getAnalyticsInstance()?.startSession(re(e))}catch(s){me(s)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){me(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){me(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(re(e))}catch(s){me(s)}}consent(e){try{this.getAnalyticsInstance()?.consent(re(e))}catch(s){me(s)}}addCustomIntegration(e,s){try{this.getAnalyticsInstance()?.addCustomIntegration(re(e),re(s))}catch(i){me(i)}}};we(vs,"globalSingleton",null);Gs=vs});var sd,id,ha,td,rd,nd,od,ad,$i=et(()=>{"use strict";sd="https://deriv.com/cdn-cgi/trace",id="https://cdn.growthbook.io",ha="https://deriv-dataplane.rudderstack.com",td="https://ph.deriv.com",rd="https://us.posthog.com",nd=()=>{if(typeof window>"u")return td;let t=window.location.hostname;return t.includes(".deriv.me")?"https://ph.deriv.me":t.includes(".deriv.be")?"https://ph.deriv.be":t.includes(".deriv.ae")?"https://ph.deriv.ae":td},od=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae","trading.game"],ad=["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 Kr(t){for(var e=1;e<arguments.length;e++){var s=arguments[e];for(var i in s)i!=="__proto__"&&(t[i]=s[i])}return t}function fa(t,e){function s(r,n,o){if(!(typeof document>"u")){o=Kr({},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+"="+t.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 c=decodeURIComponent(l[0]);if(c in o||(o[c]=t.read(u,c)),r===c)break}catch{}}return r?o[r]:o}}return Object.create({set:s,get:i,remove:function(r,n){s(r,"",Kr({},n,{expires:-1}))},withAttributes:function(r){return fa(this.converter,Kr({},this.attributes,r))},withConverter:function(r){return fa(Kr({},this.converter,r),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var _0,ld,ud=et(()=>{"use strict";_0={read:function(t){return t[0]==='"'&&(t=t.slice(1,-1)),t.replace(/(%[\dA-F]{2})+/gi,decodeURIComponent)},write:function(t){return encodeURIComponent(t).replace(/%(2[346BF]|3[AC-F]|40|5[BDE]|60|7[BCD])/g,decodeURIComponent)}};ld=fa(_0,{path:"/"})});var Zt,Jr,Fi,Wr,cd,ys,dd,hd,Mi=et(()=>{"use strict";ud();$i();Zt=(t,e)=>(...s)=>{e()&&console.log(`[ANALYTIC]${t}`,...s)},Jr=t=>{let e=t.split("@")[1]?.toLowerCase();return e?ad.includes(e):!1},Fi=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),Wr=null,cd=async()=>{if(Wr)return Wr;let t=JSON.parse(ld.get("website_status")||"{}")?.clients_country;return Wr=(async()=>{try{let e=await fetch(sd).catch(()=>null);if(!e)return t||"";let s=await e.text().catch(()=>"");return s?Object.fromEntries(s.split(`
|
|
5
|
+
`).map(r=>r.split("=",2))).loc?.toLowerCase()||t||"":t||""}catch{return t||""}})(),Wr},ys=t=>{if(t==null||typeof t!="object")return t;if(Array.isArray(t)){let i=[];for(let r=0;r<t.length;r++){let n=ys(t[r]);n!=null&&i.push(n)}return i.length?i:void 0}let e={},s=!1;for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let r=ys(t[i]);r==null||r===""||typeof r=="object"&&!Array.isArray(r)&&Object.keys(r).length===0||Array.isArray(r)&&r.length===0||(e[i]=r,s=!0)}return s?e:void 0},dd=(t,e)=>{for(let s in t){if(!Object.prototype.hasOwnProperty.call(t,s))continue;let i=t[s];i&&typeof i=="object"&&!Array.isArray(i)?dd(i,e):e[s]=i}},hd=t=>{if(t==null||typeof t!="object"||Array.isArray(t))return t;let e={};return dd(t,e),e}});function Ed(){return bd}function ga(t){let e=2166136261,s=t.length;for(let i=0;i<s;i++)e^=t.charCodeAt(i),e+=(e<<1)+(e<<4)+(e<<7)+(e<<8)+(e<<24);return e>>>0}function Bi(t,e,s){return s===2?ga(ga(t+e)+"")%1e4/1e4:s===1?ga(e+t)%1e3/1e3:null}function va(t){return t<=0?[]:new Array(t).fill(1/t)}function Zr(t,e){return t>=e[0]&&t<e[1]}function Sd(t,e){let s=Bi("__"+e[0],t,1);return s===null?!1:s>=e[1]&&s<e[2]}function wd(t,e){for(let s=0;s<e.length;s++)if(Zr(t,e[s]))return s;return-1}function _a(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function en(t,e){if(!e.length)return!1;let s=!1,i=!1;for(let r=0;r<e.length;r++){let n=E0(t,e[r].type,e[r].pattern);if(e[r].include===!1){if(n)return!1}else s=!0,n&&(i=!0)}return i||!s}function y0(t,e,s){try{let i=e.replace(/[*.+?^${}()|[\]\\]/g,"\\$&").replace(/_____/g,".*");return s&&(i="\\/?"+i.replace(/(^\/|\/$)/g,"")+"\\/?"),new RegExp("^"+i+"$","i").test(t)}catch{return!1}}function b0(t,e){try{let s=new URL(e.replace(/^([^:/?]*)\./i,"https://$1.").replace(/\*/g,"_____"),"https://_____"),i=[[t.host,s.host,!1],[t.pathname,s.pathname,!0]];return s.hash&&i.push([t.hash,s.hash,!1]),s.searchParams.forEach((r,n)=>{i.push([t.searchParams.get(n)||"",r,!1])}),!i.some(r=>!y0(r[0],r[1],r[2]))}catch{return!1}}function E0(t,e,s){try{let i=new URL(t,"https://_");if(e==="regex"){let r=_a(s);return r?r.test(i.href)||r.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return b0(i,s);return!1}catch{return!1}}function kd(t,e,s){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=va(t);s=s||i,s.length!==t&&(s=i);let r=s.reduce((o,a)=>a+o,0);(r<.99||r>1.01)&&(s=i);let n=0;return s.map(o=>{let a=n;return n+=o,[a,a+e*o]})}function Ad(t,e,s){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=>{let[o]=n;return o===t}).map(n=>{let[,o]=n;return parseInt(o)});return r.length>0&&r[0]>=0&&r[0]<s?r[0]:null}function Id(t){try{return t()}catch(e){return console.error(e),!1}}async function es(t,e,s){if(e=e||"",s=s||globalThis.crypto&&globalThis.crypto.subtle||bd.SubtleCrypto,!s)throw new Error("No SubtleCrypto implementation found");try{let i=await s.importKey("raw",pa(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[r,n]=t.split("."),o=await s.decrypt({name:"AES-CBC",iv:pa(r)},i,pa(n));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Ui(t){return typeof t=="string"?t:JSON.stringify(t)}function at(t){typeof t=="number"&&(t=t+""),(!t||typeof t!="string")&&(t="0");let e=t.replace(/(^v|\+.*$)/g,"").split(/[-.]/);return e.length===3&&e.push("~"),e.map(s=>s.match(/^[0-9]+$/)?s.padStart(5," "):s).join("-")}function Rd(){let t;try{t="1.7.0"}catch{t=""}return t}function Td(t,e){let s,i;try{s=new URL(t),i=new URL(e)}catch(r){return console.error("Unable to merge query strings: ".concat(r)),e}return s.searchParams.forEach((r,n)=>{i.searchParams.has(n)||i.searchParams.set(n,r)}),i.toString()}function yd(t){return typeof t=="object"&&t!==null}function tn(t){return t.urlPatterns&&t.variations.some(e=>yd(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>yd(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function sn(t,e){return new Promise(s=>{let i=!1,r,n=o=>{i||(i=!0,r&&clearTimeout(r),s(o||null))};e&&(r=setTimeout(()=>n(),e)),t.then(o=>n(o)).catch(()=>n())})}var bd,pa,Vi=et(()=>{"use strict";bd={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};pa=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0))});function Od(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),s.push.apply(s,i)}return s}function ma(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?Od(Object(s),!0).forEach(function(i){S0(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):Od(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function S0(t,e,s){return(e=w0(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function w0(t){var e=k0(t,"string");return typeof e=="symbol"?e:e+""}function k0(t,e){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function xd(t){Object.assign(He,t),He.backgroundSync||ka()}async function Dd(t){let{instance:e,timeout:s,skipCache:i,allowStale:r,backgroundSync:n}=t;return n||(He.backgroundSync=!1),T0({instance:e,allowStale:r,timeout:s,skipCache:i})}function A0(t){let e=ji(t),s=Ks.get(e)||new Set;s.add(t),Ks.set(e,s)}function Nd(t){Ks.forEach(e=>e.delete(t))}function I0(){Ws.forEach(t=>{t&&(t.state="idle",Sa(t))})}function R0(){Ws.forEach(t=>{t&&t.state==="idle"&&wa(t)})}async function Cd(){try{if(!It.localStorage)return;await It.localStorage.setItem(He.cacheKey,JSON.stringify(Array.from(Vt.entries())))}catch{}}async function T0(t){let{instance:e,allowStale:s,timeout:i,skipCache:r}=t,n=ji(e),o=ba(e),a=new Date,l=new Date(a.getTime()-He.maxAge+He.staleTTL);await O0();let u=!He.disableCache&&!r?Vt.get(o):void 0;return u&&(s||u.staleAt>a)&&u.staleAt>l?(u.sse&&Js.add(n),u.staleAt<a?ya(e):Ea(e),{data:u.data,success:!0,source:"cache"}):await sn(ya(e),i)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function ji(t){let[e,s]=t.getApiInfo();return"".concat(e,"||").concat(s)}function ba(t){let e=ji(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let s=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),r={};i.forEach(a=>{r[a]=s[a]});let n=t.getForcedVariations(),o=t.getUrl();return"".concat(e,"||").concat(JSON.stringify({ca:r,fv:n,url:o}))}async function O0(){if(!Pd){Pd=!0;try{if(It.localStorage){let t=await It.localStorage.getItem(He.cacheKey);if(!He.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(s=>{let[i,r]=s;Vt.set(i,ma(ma({},r),{},{staleAt:new Date(r.staleAt)}))}),Ld()}}}catch{}if(!He.disableIdleStreams){let t=zs.startIdleListener();t&&(zs.stopIdleListener=t)}}}function Ld(){let t=Array.from(Vt.entries()).map(s=>{let[i,r]=s;return{key:i,staleAt:r.staleAt.getTime()}}).sort((s,i)=>s.staleAt-i.staleAt),e=Math.min(Math.max(0,Vt.size-He.maxEntries),Vt.size);for(let s=0;s<e;s++)Vt.delete(t[s].key)}function $d(t,e,s){let i=s.dateUpdated||"",r=new Date(Date.now()+He.staleTTL),n=He.disableCache?void 0:Vt.get(e);if(n&&i&&n.version===i){n.staleAt=r,Cd();return}He.disableCache||(Vt.set(e,{data:s,version:i,staleAt:r,sse:Js.has(t)}),Ld()),Cd();let o=Ks.get(t);o&&o.forEach(a=>P0(a,s))}async function P0(t,e){await t.setPayload(e||t.getPayload())}async function ya(t){let{apiHost:e,apiRequestHeaders:s}=t.getApiHosts(),i=t.getClientKey(),r="isRemoteEval"in t&&t.isRemoteEval(),n=ji(t),o=ba(t),a=rn.get(o);return a||(a=(r?zs.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:s}):zs.fetchFeaturesCall({host:e,clientKey:i,headers:s})).then(u=>{if(!u.ok)throw new Error("HTTP error: ".concat(u.status));return u.headers.get("x-sse-support")==="enabled"&&Js.add(n),u.json()}).then(u=>($d(n,o,u),Ea(t),rn.delete(o),{data:u,success:!0,source:"network"})).catch(u=>(rn.delete(o),{data:null,source:"error",success:!1,error:u})),rn.set(o,a)),a}function Ea(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s=ji(t),i=ba(t),{streamingHost:r,streamingHostRequestHeaders:n}=t.getApiHosts(),o=t.getClientKey();if(e&&Js.add(s),He.backgroundSync&&Js.has(s)&&It.EventSource){if(Ws.has(s))return;let a={src:null,host:r,clientKey:o,headers:n,cb:l=>{try{if(l.type==="features-updated"){let u=Ks.get(s);u&&u.forEach(c=>{ya(c)})}else if(l.type==="features"){let u=JSON.parse(l.data);$d(s,i,u)}a.errors=0}catch{Fd(a)}},errors:0,state:"active"};Ws.set(s,a),wa(a)}}function Fd(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Math.pow(3,t.errors-3)*(1e3+Math.random()*1e3);Sa(t),setTimeout(()=>{["idle","active"].includes(t.state)||wa(t)},Math.min(e,3e5))}}function Sa(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function wa(t){t.src=zs.eventSourceCall({host:t.host,clientKey:t.clientKey,headers:t.headers}),t.state="active",t.src.addEventListener("features",t.cb),t.src.addEventListener("features-updated",t.cb),t.src.onerror=()=>Fd(t),t.src.onopen=()=>{t.errors=0}}function C0(t,e){Sa(t),Ws.delete(e)}function ka(){Js.clear(),Ws.forEach(C0),Ks.clear(),zs.stopIdleListener()}function nn(t,e){if(e.streaming){if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming");e.payload&&Ea(t,!0),A0(t)}}var He,It,zs,Ks,Pd,Vt,rn,Ws,Js,Md=et(()=>{"use strict";Vi();He={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},It=Ed(),zs={fetchFeaturesCall:t=>{let{host:e,clientKey:s,headers:i}=t;return It.fetch("".concat(e,"/api/features/").concat(s),{headers:i})},fetchRemoteEvalCall:t=>{let{host:e,clientKey:s,payload:i,headers:r}=t,n={method:"POST",headers:ma({"Content-Type":"application/json"},r),body:JSON.stringify(i)};return It.fetch("".concat(e,"/api/eval/").concat(s),n)},eventSourceCall:t=>{let{host:e,clientKey:s,headers:i}=t;return i?new It.EventSource("".concat(e,"/sub/").concat(s),{headers:i}):new It.EventSource("".concat(e,"/sub/").concat(s))},startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let s=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),R0()):document.visibilityState==="hidden"&&(t=window.setTimeout(I0,He.idleStreamInterval))};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(It.localStorage=globalThis.localStorage)}catch{}Ks=new Map,Pd=!1,Vt=new Map,rn=new Map,Ws=new Map,Js=new Set});function D0(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function cn(t){var e=un.get(t);return e||(e={element:t,attributes:{}},un.set(t,e)),e}function dn(t,e,s,i,r){var n=s(t),o={isDirty:!1,originalValue:n,virtualValue:n,mutations:[],el:t,_positionTimeout:null,observer:new MutationObserver(function(){if(!(e==="position"&&o._positionTimeout)){e==="position"&&(o._positionTimeout=setTimeout(function(){o._positionTimeout=null},1e3));var a=s(t);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:s};return e==="position"&&t.parentNode?o.observer.observe(t.parentNode,{childList:!0,subtree:!0,attributes:!1,characterData:!1}):o.observer.observe(t,D0(e)),o}function hn(t,e){var s=e.getCurrentValue(e.el);e.virtualValue=t,t&&typeof t!="string"?(!s||t.parentNode!==s.parentNode||t.insertBeforeNode!==s.insertBeforeNode)&&(e.isDirty=!0,Bd()):t!==s&&(e.isDirty=!0,Bd())}function N0(t){var e=t.originalValue;t.mutations.forEach(function(s){return e=s.mutate(e)}),hn(W0(e),t)}function L0(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(s){return s.mutate(e)}),hn(Array.from(e).filter(Boolean).join(" "),t)}function $0(t){var e=t.originalValue;t.mutations.forEach(function(s){return e=s.mutate(e)}),hn(e,t)}function F0(t){var e=t.parentSelector,s=t.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var r=s?document.querySelector(s):null;return s&&!r?null:{parentNode:i,insertBeforeNode:r}}function M0(t){var e=t.originalValue;t.mutations.forEach(function(s){var i=s.mutate(),r=F0(i);e=r||e}),hn(e,t)}function Vd(t){var e=cn(t);return e.html||(e.html=dn(t,"html",B0,U0,N0)),e.html}function jd(t){var e=cn(t);return e.position||(e.position=dn(t,"position",V0,j0,M0)),e.position}function Gd(t){var e=cn(t);return e.classes||(e.classes=dn(t,"class",H0,G0,L0)),e.classes}function Hd(t,e){var s=cn(t);return s.attributes[e]||(s.attributes[e]=dn(t,e,q0(e),z0(e),$0)),s.attributes[e]}function K0(t,e){var s=un.get(t);if(s)if(e==="html"){var i,r;(i=s.html)==null||(r=i.observer)==null||r.disconnect(),delete s.html}else if(e==="class"){var n,o;(n=s.classes)==null||(o=n.observer)==null||o.disconnect(),delete s.classes}else if(e==="position"){var a,l;(a=s.position)==null||(l=a.observer)==null||l.disconnect(),delete s.position}else{var u,c,h;(u=s.attributes)==null||(c=u[e])==null||(h=c.observer)==null||h.disconnect(),delete s.attributes[e]}}function W0(t){return on||(on=document.createElement("div")),on.innerHTML=t,on.innerHTML}function an(t,e,s){if(s.isDirty){s.isDirty=!1;var i=s.virtualValue;s.mutations.length||K0(t,e),s.setValue(t,i)}}function J0(t,e){t.html&&an(e,"html",t.html),t.classes&&an(e,"class",t.classes),t.position&&an(e,"position",t.position),Object.keys(t.attributes).forEach(function(s){an(e,s,t.attributes[s])})}function Bd(){un.forEach(J0)}function Y0(t,e){var s=null;t.kind==="html"?s=Vd(e):t.kind==="class"?s=Gd(e):t.kind==="attribute"?s=Hd(e,t.attribute):t.kind==="position"&&(s=jd(e)),s&&(s.mutations.push(t),s.mutationRunner(s))}function X0(t,e){var s=null;if(t.kind==="html"?s=Vd(e):t.kind==="class"?s=Gd(e):t.kind==="attribute"?s=Hd(e,t.attribute):t.kind==="position"&&(s=jd(e)),!!s){var i=s.mutations.indexOf(t);i!==-1&&s.mutations.splice(i,1),s.mutationRunner(s)}}function qd(t){if(!(t.kind==="position"&&t.elements.size===1)){var e=new Set(t.elements),s=document.querySelectorAll(t.selector);s.forEach(function(i){e.has(i)||(t.elements.add(i),Y0(t,i))})}}function Q0(t){t.elements.forEach(function(e){return X0(t,e)}),t.elements.clear(),Ta.delete(t)}function Ud(){Ta.forEach(qd)}function Z0(){typeof document>"u"||(Aa||(Aa=new MutationObserver(function(){Ud()})),Ud(),Aa.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function fn(t){return typeof document>"u"?Ra:(Ta.add(t),qd(t),{revert:function(){Q0(t)}})}function Ia(t,e){return fn({kind:"html",elements:new Set,mutate:e,selector:t})}function zd(t,e){return fn({kind:"position",elements:new Set,mutate:e,selector:t})}function Gi(t,e){return fn({kind:"class",elements:new Set,mutate:e,selector:t})}function ln(t,e,s){return x0.test(e)?e==="class"||e==="className"?Gi(t,function(i){var r=s(Array.from(i).join(" "));i.clear(),r&&r.split(/\s+/g).filter(Boolean).forEach(function(n){return i.add(n)})}):fn({kind:"attribute",attribute:e,elements:new Set,mutate:s,selector:t}):Ra}function eE(t){var e=t.selector,s=t.action,i=t.value,r=t.attribute,n=t.parentSelector,o=t.insertBeforeSelector;if(r==="html"){if(s==="append")return Ia(e,function(a){return a+(i??"")});if(s==="set")return Ia(e,function(){return i??""})}else if(r==="class"){if(s==="append")return Gi(e,function(a){i&&a.add(i)});if(s==="remove")return Gi(e,function(a){i&&a.delete(i)});if(s==="set")return Gi(e,function(a){a.clear(),i&&a.add(i)})}else if(r==="position"){if(s==="set"&&n)return zd(e,function(){return{insertBeforeSelector:o,parentSelector:n}})}else{if(s==="append")return ln(e,r,function(a){return a!==null?a+(i??""):i??""});if(s==="set")return ln(e,r,function(){return i??""});if(s==="remove")return ln(e,r,function(){return null})}return Ra}var x0,Ra,un,Ta,B0,U0,V0,j0,G0,H0,q0,z0,on,Aa,tE,Kd,Wd=et(()=>{"use strict";x0=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Ra={revert:function(){}},un=new Map,Ta=new Set;B0=function(e){return e.innerHTML},U0=function(e,s){return e.innerHTML=s};V0=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},j0=function(e,s){s.insertBeforeNode&&!s.parentNode.contains(s.insertBeforeNode)||s.parentNode.insertBefore(e,s.insertBeforeNode)};G0=function(e,s){return s?e.className=s:e.removeAttribute("class")},H0=function(e){return e.className};q0=function(e){return function(s){var i;return(i=s.getAttribute(e))!=null?i:null}},z0=function(e){return function(s,i){return i!==null?s.setAttribute(e,i):s.removeAttribute(e)}};Z0();tE={html:Ia,classes:Gi,attribute:ln,position:zd,declarative:eE},Kd=tE});function ts(t,e,s){s=s||{};for(let[i,r]of Object.entries(e))switch(i){case"$or":if(!Xd(t,r,s))return!1;break;case"$nor":if(Xd(t,r,s))return!1;break;case"$and":if(!oE(t,r,s))return!1;break;case"$not":if(ts(t,r,s))return!1;break;default:if(!Hi(r,sE(t,i),s))return!1}return!0}function sE(t,e){let s=e.split("."),i=t;for(let r=0;r<s.length;r++)if(i&&typeof i=="object"&&s[r]in i)i=i[s[r]];else return null;return i}function Jd(t){let e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,s="".concat(t).concat(e?"/i":"");return Oa[s]||(Oa[s]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Oa[s]}function Hi(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(typeof t=="string")return i?String(e).toLowerCase()===t.toLowerCase():e+""===t;if(typeof t=="number")return e*1===t;if(typeof t=="boolean")return e!==null&&!!e===t;if(t===null)return e===null;if(Array.isArray(t)||!Qd(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!nE(r,e,t[r],s))return!1;return!0}function Qd(t){let e=Object.keys(t);return e.length>0&&e.filter(s=>s[0]==="$").length===e.length}function iE(t){if(t===null)return"null";if(Array.isArray(t))return"array";let e=typeof t;return["string","number","boolean","object","undefined"].includes(e)?e:"unknown"}function rE(t,e,s){if(!Array.isArray(t))return!1;let i=Qd(e)?r=>Hi(e,r,s):r=>ts(r,e,s);for(let r=0;r<t.length;r++)if(t[r]&&i(t[r]))return!0;return!1}function Ys(t,e){if(arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1){let i=r=>typeof r=="string"?r.toLowerCase():r;return Array.isArray(t)?t.some(r=>e.some(n=>i(r)===i(n))):e.some(r=>i(t)===i(r))}return Array.isArray(t)?t.some(i=>e.includes(i)):e.includes(t)}function Yd(t,e,s){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:!1;if(!Array.isArray(t))return!1;for(let r=0;r<e.length;r++){let n=!1;for(let o=0;o<t.length;o++)if(Hi(e[r],t[o],s,i)){n=!0;break}if(!n)return!1}return!0}function nE(t,e,s,i){switch(t){case"$veq":return at(e)===at(s);case"$vne":return at(e)!==at(s);case"$vgt":return at(e)>at(s);case"$vgte":return at(e)>=at(s);case"$vlt":return at(e)<at(s);case"$vlte":return at(e)<=at(s);case"$eq":return e===s;case"$ne":return e!==s;case"$lt":return e<s;case"$lte":return e<=s;case"$gt":return e>s;case"$gte":return e>=s;case"$exists":return s?e!=null:e==null;case"$in":return Array.isArray(s)?Ys(e,s):!1;case"$ini":return Array.isArray(s)?Ys(e,s,!0):!1;case"$inGroup":return Ys(e,i[s]||[]);case"$notInGroup":return!Ys(e,i[s]||[]);case"$nin":return Array.isArray(s)?!Ys(e,s):!1;case"$nini":return Array.isArray(s)?!Ys(e,s,!0):!1;case"$not":return!Hi(s,e,i);case"$size":return Array.isArray(e)?Hi(s,e.length,i):!1;case"$elemMatch":return rE(e,s,i);case"$all":return Array.isArray(s)?Yd(e,s,i):!1;case"$alli":return Array.isArray(s)?Yd(e,s,i,!0):!1;case"$regex":try{return Jd(s).test(e)}catch{return!1}case"$regexi":try{return Jd(s,!0).test(e)}catch{return!1}case"$type":return iE(e)===s;default:return console.error("Unknown operator: "+t),!1}}function Xd(t,e,s){if(!e.length)return!0;for(let i=0;i<e.length;i++)if(ts(t,e[i],s))return!0;return!1}function oE(t,e,s){for(let i=0;i<e.length;i++)if(!ts(t,e[i],s))return!1;return!0}var Oa,Zd=et(()=>{"use strict";Vi();Oa={}});function eh(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),s.push.apply(s,i)}return s}function Gt(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?eh(Object(s),!0).forEach(function(i){aE(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):eh(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function aE(t,e,s){return(e=lE(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function lE(t){var e=uE(t,"string");return typeof e=="symbol"?e:e+""}function uE(t,e){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function hE(t){let e=new Map;return t.global.forcedFeatureValues&&t.global.forcedFeatureValues.forEach((s,i)=>e.set(i,s)),t.user.forcedFeatureValues&&t.user.forcedFeatureValues.forEach((s,i)=>e.set(i,s)),e}function fE(t){return t.global.forcedVariations&&t.user.forcedVariations?Gt(Gt({},t.global.forcedVariations),t.user.forcedVariations):t.global.forcedVariations?t.global.forcedVariations:t.user.forcedVariations?t.user.forcedVariations:{}}async function Xs(t){try{await t()}catch{}}function th(t,e,s){if(t.user.trackedExperiments){let r=vn(e,s);if(t.user.trackedExperiments.has(r))return[];t.user.trackedExperiments.add(r)}t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({experiment:e,result:s,timestamp:Date.now().toString(),logType:"experiment"});let i=[];if(t.global.trackingCallback){let r=t.global.trackingCallback;i.push(Xs(()=>r(e,s,jt(t.user))))}if(t.user.trackingCallback){let r=t.user.trackingCallback;i.push(Xs(()=>r(e,s,jt(t.user))))}if(t.global.eventLogger){let r=t.global.eventLogger;i.push(Xs(()=>r(dE,{experimentId:e.key,variationId:s.key,hashAttribute:s.hashAttribute,hashValue:s.hashValue},jt(t.user))))}return i}function gE(t,e,s){if(t.user.trackedFeatureUsage){var i;let r=JSON.stringify(s.value);if(t.user.trackedFeatureUsage[e]===r)return;t.user.trackedFeatureUsage[e]=r,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:s,timestamp:Date.now().toString(),logType:"feature"}),(i=t.user.featureUsageSubs)!==null&&i!==void 0&&i.size&&t.user.featureUsageSubs.forEach(n=>{try{n(e,s)}catch(o){console.error(o)}})}if(t.global.onFeatureUsage){let r=t.global.onFeatureUsage;Xs(()=>r(e,s,jt(t.user)))}if(t.user.onFeatureUsage){let r=t.user.onFeatureUsage;Xs(()=>r(e,s))}if(t.global.eventLogger){let r=t.global.eventLogger;Xs(()=>r(cE,{feature:e,source:s.source,value:s.value,ruleId:s.source==="defaultValue"?"$default":s.ruleId||"",variationId:s.experimentResult?s.experimentResult.key:""},jt(t.user)))}}function gn(t,e){if(e.stack.evaluatedFeatures.has(t))return ss(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let s=hE(e);if(s.has(t))return ss(e,t,s.get(t),"override");if(!e.global.features||!e.global.features[t])return ss(e,t,null,"unknownFeature");let i=e.global.features[t];if(i.rules){let n=new Set(e.stack.evaluatedFeatures);e:for(let o of i.rules){var r;if(o.parentConditions)for(let c of o.parentConditions){e.stack.evaluatedFeatures=new Set(n);let h=gn(c.id,e);if(h.source==="cyclicPrerequisite")return ss(e,t,null,"cyclicPrerequisite");let g={value:h.value};if(!ts(g,c.condition||{})){if(c.gate)return ss(e,t,null,"prerequisite");continue e}}if(o.filters&&sh(o.filters,e))continue;if("force"in o){if(o.condition&&!Da(o.condition,e)||!mE(e,o.seed||t,o.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!o.disableStickyBucketing?o.fallbackAttribute:void 0,o.range,o.coverage,o.hashVersion))continue;return o.tracks&&o.tracks.forEach(c=>{!th(e,c.experiment,c.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:c.experiment,result:c.result,user:jt(e.user)})}),ss(e,t,o.force,"force",o.id)}let a=(r=o.contextualVariations)!==null&&r!==void 0?r:o.variations;if(!a)continue;let l={variations:a,key:o.key||t};"coverage"in o&&(l.coverage=o.coverage),o.weights&&(l.weights=o.weights),o.hashAttribute&&(l.hashAttribute=o.hashAttribute),o.fallbackAttribute&&(l.fallbackAttribute=o.fallbackAttribute),o.disableStickyBucketing&&(l.disableStickyBucketing=o.disableStickyBucketing),o.bucketVersion!==void 0&&(l.bucketVersion=o.bucketVersion),o.minBucketVersion!==void 0&&(l.minBucketVersion=o.minBucketVersion),o.namespace&&(l.namespace=o.namespace),o.meta&&(l.meta=o.meta),o.ranges&&(l.ranges=o.ranges),o.name&&(l.name=o.name),o.phase&&(l.phase=o.phase),o.seed&&(l.seed=o.seed),o.hashVersion&&(l.hashVersion=o.hashVersion),o.filters&&(l.filters=o.filters),o.condition&&(l.condition=o.condition),o.contextualBanditRef&&_E(l,o.contextualBanditRef,t,e);let{result:u}=pn(l,t,e);if(l.contextualBandit&&!(u.hashUsed&&u.inExperiment)&&delete l.contextualBandit,e.global.onExperimentEval&&e.global.onExperimentEval(l,u),u.inExperiment&&!u.passthrough)return ss(e,t,u.value,"experiment",o.id,l,u)}}return ss(e,t,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function pn(t,e,s){let i=t.key,r=t.variations.length;if(r<2)return{result:Ae(s,t,-1,!1,e)};if(s.global.enabled===!1||s.user.enabled===!1)return{result:Ae(s,t,-1,!1,e)};if(t=yE(t,s),t.contextualBandit&&t.weights&&(t.contextualBandit=Gt(Gt({},t.contextualBandit),{},{variationWeights:t.weights})),t.urlPatterns&&!en(s.user.url||"",t.urlPatterns))return{result:Ae(s,t,-1,!1,e)};let n=Ad(i,s.user.url||"",r);if(n!==null)return{result:Ae(s,t,n,!1,e)};let o=fE(s);if(i in o){let v=o[i];return{result:Ae(s,t,v,!1,e)}}if(t.status==="draft"||t.active===!1)return{result:Ae(s,t,-1,!1,e)};let{hashAttribute:a,hashValue:l}=Es(s,t.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:Ae(s,t,-1,!1,e)};let u=-1,c=!1,h=!1;if(s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:v,versionIsBlocked:m}=SE({ctx:s,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});c=v>=0,u=v,h=!!m}if(!c){if(t.filters){if(sh(t.filters,s))return{result:Ae(s,t,-1,!1,e)}}else if(t.namespace&&!Sd(l,t.namespace))return{result:Ae(s,t,-1,!1,e)};if(t.include&&!Id(t.include))return{result:Ae(s,t,-1,!1,e)};if(t.condition&&!Da(t.condition,s))return{result:Ae(s,t,-1,!1,e)};if(t.parentConditions){let v=new Set(s.stack.evaluatedFeatures);for(let m of t.parentConditions){s.stack.evaluatedFeatures=new Set(v);let y=gn(m.id,s);if(y.source==="cyclicPrerequisite")return{result:Ae(s,t,-1,!1,e)};let w={value:y.value};if(!ts(w,m.condition||{}))return{result:Ae(s,t,-1,!1,e)}}}if(t.groups&&!EE(t.groups,s))return{result:Ae(s,t,-1,!1,e)}}if(t.url&&!bE(t.url,s))return{result:Ae(s,t,-1,!1,e)};let g=Bi(t.seed||i,l,t.hashVersion||1);if(g===null)return{result:Ae(s,t,-1,!1,e)};if(!c){let v=t.ranges||kd(r,t.coverage===void 0?1:t.coverage,t.weights);u=wd(g,v)}if(h)return{result:Ae(s,t,-1,!1,e,void 0,!0)};if(u<0)return{result:Ae(s,t,-1,!1,e)};if("force"in t)return{result:Ae(s,t,t.force===void 0?-1:t.force,!1,e)};if(s.global.qaMode||s.user.qaMode)return{result:Ae(s,t,-1,!1,e)};if(t.status==="stopped")return{result:Ae(s,t,-1,!1,e)};let f=Ae(s,t,u,!0,e,g,c);if(s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:v,key:m,doc:y}=kE(s,a,Ui(l),{[Pa(t.key,t.bucketVersion)]:f.key});v&&(s.user.stickyBucketAssignmentDocs=s.user.stickyBucketAssignmentDocs||{},s.user.stickyBucketAssignmentDocs[m]=y,s.user.saveStickyBucketAssignmentDoc(y))}let p=th(s,t,f);p.length===0&&s.global.saveDeferredTrack&&s.global.saveDeferredTrack({experiment:t,result:f,user:jt(s.user)});let _=p.length?p.length===1?p[0]:Promise.all(p).then(()=>{}):void 0;return"changeId"in t&&t.changeId&&s.global.recordChangeId&&s.global.recordChangeId(t.changeId),{result:f,trackingCall:_}}function ss(t,e,s,i,r,n,o){let a={value:s,on:!!s,off:!s,source:i,ruleId:r||""};return n&&(a.experiment=n),o&&(a.experimentResult=o),i!=="override"&&gE(t,e,a),a}function xa(t){return Gt(Gt({},t.attributes),t.attributeOverrides)}function jt(t){return{attributes:xa(t),url:t.url}}function pE(t,e){for(let s of t.contexts||[])if(Da(s.condition||{},e))return{leafId:s.leafId,weights:s.weights};return null}function _E(t,e,s,i){var r,n;let o=(r=i.global.contextualBandits)===null||r===void 0?void 0:r[e];if(!o)return;let a=null;if(o.contexts&&o.contexts.length)try{a=pE(o,i)}catch{}if(a){t.weights=a.weights,t.contextualBandit={leafId:a.leafId,variationWeights:a.weights,banditVersion:o.banditVersion};return}t.contextualBandit={leafId:vE,variationWeights:(n=t.weights)!==null&&n!==void 0?n:va(t.variations.length),banditVersion:o.banditVersion}}function Da(t,e){return ts(xa(e.user),t,e.global.savedGroups||{})}function sh(t,e){return t.some(s=>{let{hashValue:i}=Es(e,s.attribute);if(!i)return!0;let r=Bi(s.seed,i,s.hashVersion||2);return r===null?!0:!s.ranges.some(n=>Zr(r,n))})}function mE(t,e,s,i,r,n,o){if(!r&&n===void 0)return!0;if(!r&&n===0)return!1;let{hashValue:a}=Es(t,s,i);if(!a)return!1;let l=Bi(e,a,o||1);return l===null?!1:r?Zr(l,r):n!==void 0?l<=n:!0}function Ae(t,e,s,i,r,n,o){let a=!0;(s<0||s>=e.variations.length)&&(s=0,a=!1);let{hashAttribute:l,hashValue:u}=Es(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),c=e.meta?e.meta[s]:{},h={key:c.key||""+s,featureId:r,inExperiment:a,hashUsed:i,variationId:s,value:e.variations[s],hashAttribute:l,hashValue:u,stickyBucketUsed:!!o};c.name&&(h.name=c.name),n!==void 0&&(h.bucket=n),c.passthrough&&(h.passthrough=c.passthrough);let g=e.contextualBandit;return g&&i&&a&&(h.leafId=g.leafId,h.variationWeights=g.variationWeights,g.banditVersion!==void 0&&(h.banditVersion=g.banditVersion)),h}function yE(t,e){let s=t.key,i=e.global.overrides;return i&&i[s]&&(t=Object.assign({},t,i[s]),typeof t.url=="string"&&(t.url=_a(t.url))),t}function Es(t,e,s){let i=e||"id",r="",n=xa(t.user);return n[i]&&(r=n[i]),!r&&s&&(n[s]&&(r=n[s]),r&&(i=s)),{hashAttribute:i,hashValue:r}}function bE(t,e){let s=e.user.url;if(!s)return!1;let i=s.replace(/^https?:\/\//,"").replace(/^[^/]*\//,"/");return!!(t.test(s)||t.test(i))}function EE(t,e){let s=e.global.groups||{};for(let i=0;i<t.length;i++)if(s[t[i]])return!0;return!1}function SE(t){let{ctx:e,expKey:s,expBucketVersion:i,expHashAttribute:r,expFallbackAttribute:n,expMinBucketVersion:o,expMeta:a}=t;i=i||0,o=o||0,r=r||"id",a=a||[];let l=Pa(s,i),u=wE(e,r,n);if(o>0)for(let g=0;g<o;g++){let f=Pa(s,g);if(u[f]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=u[l];if(c===void 0)return{variation:-1};let h=a.findIndex(g=>g.key===c);return h<0?{variation:-1}:{variation:h}}function Pa(t,e){return e=e||0,"".concat(t,"__").concat(e)}function Ca(t,e){return"".concat(t,"||").concat(e)}function wE(t,e,s){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:r}=Es(t,e),n=Ca(i,Ui(r)),{hashAttribute:o,hashValue:a}=Es(t,s),l=a?Ca(o,Ui(a)):null,u={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[n]&&Object.assign(u,t.user.stickyBucketAssignmentDocs[n].assignments||{}),u}function kE(t,e,s,i){let r=Ca(e,s),n=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[r]?t.user.stickyBucketAssignmentDocs[r].assignments||{}:{},o=Gt(Gt({},n),i),a=JSON.stringify(n)!==JSON.stringify(o);return{key:r,doc:{attributeName:e,attributeValue:s,assignments:o},changed:a}}function AE(t,e){let s=new Set,i=e&&e.features?e.features:t.global.features||{},r=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(i).forEach(n=>{let o=i[n];if(o.rules)for(let a of o.rules)(a.variations||a.contextualVariations)&&(s.add(a.hashAttribute||"id"),a.fallbackAttribute&&s.add(a.fallbackAttribute))}),r.map(n=>{s.add(n.hashAttribute||"id"),n.fallbackAttribute&&s.add(n.fallbackAttribute)}),Array.from(s)}async function ih(t,e,s){let i=Na(t,s);return e.getAllAssignments(i)}function Na(t,e){let s={};return AE(t,e).forEach(r=>{let{hashValue:n}=Es(t,r);s[r]=Ui(n)}),s}async function rh(t,e,s){if(t=Gt({},t),t.encryptedFeatures){try{t.features=JSON.parse(await es(t.encryptedFeatures,e,s))}catch(i){console.error(i)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await es(t.encryptedExperiments,e,s))}catch(i){console.error(i)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await es(t.encryptedSavedGroups,e,s))}catch(i){console.error(i)}delete t.encryptedSavedGroups}if(t.encryptedContextualBandits){try{t.contextualBandits=JSON.parse(await es(t.encryptedContextualBandits,e,s))}catch(i){console.error(i)}delete t.encryptedContextualBandits}return t}function nh(t){let e=t.apiHost||"https://cdn.growthbook.io";return{apiHost:e.replace(/\/*$/,""),streamingHost:(t.streamingHost||e).replace(/\/*$/,""),apiRequestHeaders:t.apiHostRequestHeaders,streamingHostRequestHeaders:t.streamingHostRequestHeaders}}function vn(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var cE,dE,vE,oh=et(()=>{"use strict";Zd();Vi();cE="Feature Evaluated",dE="Experiment Viewed";vE=-1});function ah(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(t,r).enumerable})),s.push.apply(s,i)}return s}function Rt(t){for(var e=1;e<arguments.length;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?ah(Object(s),!0).forEach(function(i){RE(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):ah(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function RE(t,e,s){return(e=TE(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function TE(t){var e=OE(t,"string");return typeof e=="symbol"?e:e+""}function OE(t,e){if(typeof t!="object"||!t)return t;var s=t[Symbol.toPrimitive];if(s!==void 0){var i=s.call(t,e||"default");if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function PE(t,e){if(t==null)return{};var s,i,r=CE(t,e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);for(i=0;i<n.length;i++)s=n[i],e.indexOf(s)===-1&&{}.propertyIsEnumerable.call(t,s)&&(r[s]=t[s])}return r}function CE(t,e){if(t==null)return{};var s={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;s[i]=t[i]}return s}var IE,Qs,xE,qi,lh=et(()=>{"use strict";Wd();Vi();Md();oh();IE=["data"];Qs=typeof window<"u"&&typeof document<"u",xE=Rd(),qi=class{constructor(e){if(e=e||{},this.version=xE,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._featureUsageSubs=new Set,this._customEventSubs=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 s=!1;try{s=!!new URL(e.apiHost||"").hostname.match(/growthbook\.io$/i)}catch{}if(s)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 s=e.stickyBucketService;this._saveStickyBucketAssignmentDoc=i=>s.saveAssignments(i)}if(e.plugins)for(let s of e.plugins)s(this);if(e.features&&(this.ready=!0),Qs&&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 s in this._options.stickyBucketAssignmentDocs){let i=this._options.stickyBucketAssignmentDocs[s];i&&this._options.stickyBucketService.saveAssignments(i).catch(()=>{})}this.ready&&this.refreshStickyBuckets(this.getPayload())}async setPayload(e){this._payload=e;let s=await rh(e,this._options.decryptionKey);this._decryptedPayload=s,await this.refreshStickyBuckets(s),s.features&&(this._options.features=s.features),s.savedGroups&&(this._options.savedGroups=s.savedGroups),s.contextualBandits&&(this._options.contextualBandits=s.contextualBandits),s.experiments&&(this._options.experiments=s.experiments,this._updateAllAutoExperiments()),this.ready=!0,this._render()}initSync(e){this._initialized=!0;let s=e.payload;if(s.encryptedExperiments||s.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,s)),this._payload=s,this._decryptedPayload=s,s.features&&(this._options.features=s.features),s.savedGroups&&(this._options.savedGroups=s.savedGroups),s.contextualBandits&&(this._options.contextualBandits=s.contextualBandits),s.experiments&&(this._options.experiments=s.experiments,this._updateAllAutoExperiments()),this.ready=!0,nn(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&xd(e.cacheSettings),e.payload)return await this.setPayload(e.payload),nn(this,e),{success:!0,source:"init"};{let s=await this._refresh(Rt(Rt({},e),{},{allowStale:!0})),{data:i}=s,r=PE(s,IE);return nn(this,e),await this.setPayload(i||{}),r}}async loadFeatures(e){var s;e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:((s=this._options.backgroundSync)!==null&&s!==void 0?s:!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let s=await this._refresh(Rt(Rt({},e||{}),{},{allowStale:!1}));s.data&&await this.setPayload(s.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return nh(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(e){var s;let{timeout:i,skipCache:r,allowStale:n,streaming:o}=e;if(!this._options.clientKey)throw new Error("Missing clientKey");return Dd({instance:this,timeout:i,skipCache:r||this._options.disableCache,allowStale:n,backgroundSync:(s=o??this._options.backgroundSync)!==null&&s!==void 0?s:!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,s,i){let r=await es(e,s||this._options.decryptionKey,i);this.setFeatures(JSON.parse(r))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,s,i){let r=await es(e,s||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(Rt(Rt({},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 Rt(Rt({},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)}}_subscribeFeatureUsage(e){return this._featureUsageSubs.add(e),()=>this._featureUsageSubs.delete(e)}_subscribeCustomEvents(e){return this._customEventSubs.add(e),()=>this._customEventSubs.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(s=>{try{s()}catch(i){console.error(i)}}),this._subscriptions.clear(),this._featureUsageSubs.clear(),this._customEventSubs.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,Nd(this),e.destroyAllStreams&&ka(),this.logs=[],Qs&&window._growthbook===this&&delete window._growthbook,this._activeAutoExperiments.forEach(s=>{s.undo()}),this._activeAutoExperiments.clear(),this._triggeredExpKeys.clear()}setRenderer(e){this._renderer=e}forceVariation(e,s){if(this._options.forcedVariations=this._options.forcedVariations||{},this._options.forcedVariations[e]=s,this._options.remoteEval){this._refreshForRemoteEval();return}this._updateAllAutoExperiments(),this._render()}run(e){let{result:s}=pn(e,null,this._getEvalContext());return this._onExperimentEval(e,s),s}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?Rt(Rt({},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,featureUsageSubs:this._featureUsageSubs,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,contextualBandits:this._options.contextualBandits,groups:this._options.groups,overrides:this._options.overrides,onExperimentEval:this._onExperimentEval,recordChangeId:this._recordChangedId,saveDeferredTrack:this._saveDeferredTrack,eventLogger:this._options.eventLogger}}_runAutoExperiment(e,s){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=Ae(this._getEvalContext(),e,-1,!1,""):({result:n,trackingCall:o}=pn(e,null,this._getEvalContext()),this._onExperimentEval(e,n));let a=JSON.stringify(n.value);if(!s&&n.inExperiment&&i&&i.valueHash===a)return n;if(i&&this._undoActiveAutoExperiment(e),n.inExperiment){let u=tn(e);if(u==="redirect"&&n.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?Td(this._getContextUrl(),n.value.urlRedirect):n.value.urlRedirect;if(en(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),n;this._redirectedUrl=c;let{navigate:h,delay:g}=this._getNavigateFunction();if(h)if(Qs){var l;Promise.all([...o?[sn(o,(l=this._options.maxNavigateDelay)!==null&&l!==void 0?l:1e3)]:[],new Promise(f=>{var p;return window.setTimeout(f,(p=this._options.navigateDelay)!==null&&p!==void 0?p:g)})]).then(()=>{try{h(c)}catch(f){console.error(f)}})}else try{h(c)}catch(f){console.error(f)}}else if(u==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(n.value):this._applyDOMChanges(n.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return n}_undoActiveAutoExperiment(e){let s=this._activeAutoExperiments.get(e);s&&(s.undo(),this._activeAutoExperiments.delete(e))}_updateAllAutoExperiments(e){if(!this._autoExperimentsAllowed)return;let s=this._options.experiments||[],i=new Set(s);this._activeAutoExperiments.forEach((r,n)=>{i.has(n)||(r.undo(),this._activeAutoExperiments.delete(n))});for(let r of s){let n=this._runAutoExperiment(r,e);if(n&&n.inExperiment&&tn(r)==="redirect")break}}_onExperimentEval(e,s){let i=this._assigned.get(e.key);this._assigned.set(e.key,{experiment:e,result:s}),this._subscriptions.size>0&&this._fireSubscriptions(e,s,i)}_fireSubscriptions(e,s,i){(!i||i.result.inExperiment!==s.inExperiment||i.result.variationId!==s.variationId)&&this._subscriptions.forEach(r=>{try{r(e,s)}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,s){let i=this.evalFeature(e).value;return i===null?s:i}feature(e){return this.evalFeature(e)}evalFeature(e){return gn(e,this._getEvalContext())}log(e,s){this.debug&&(this._options.log?this._options.log(e,s):console.log(e,s))}getDeferredTrackingCalls(){return Array.from(this._deferredTrackingCalls.values())}setDeferredTrackingCalls(e){this._deferredTrackingCalls=new Map(e.filter(s=>s&&s.experiment&&s.result).map(s=>[vn(s.experiment,s.result),s]))}async fireDeferredTrackingCalls(){if(!this._options.trackingCallback)return;let e=[];this._deferredTrackingCalls.forEach(s=>{!s||!s.experiment||!s.result?console.error("Invalid deferred tracking call",{call:s}):e.push(this._options.trackingCallback(s.experiment,s.result,s.user))}),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,s){if(this._destroyed){console.error("Cannot log event to destroyed GrowthBook instance");return}if(this._options.enableDevMode&&this.logs.push({eventName:e,properties:s,timestamp:Date.now().toString(),logType:"event"}),this._customEventSubs.size&&this._customEventSubs.forEach(i=>{try{i(e,s||{})}catch(r){console.error(r)}}),this._options.eventLogger)try{await this._options.eventLogger(e,s||{},jt(this._getUserContext()))}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(vn(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Qs?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let s=tn(e);if(s==="visual"){if(this._options.disableVisualExperiments||this._options.disableJsInjection&&e.variations.some(i=>i.js))return!0}else if(s==="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}:Qs?{navigate:e=>{window.location.replace(e)},delay:100}:{navigate:null,delay:0}}_applyDOMChanges(e){if(!Qs)return;let s=[];if(e.css){let i=document.createElement("style");i.innerHTML=e.css,document.head.appendChild(i),s.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),s.push(()=>i.remove())}return e.domMutations&&e.domMutations.forEach(i=>{s.push(Kd.declarative(i).revert)}),()=>{s.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let s=this._getEvalContext(),i=await ih(s,this._options.stickyBucketService,e);this._options.stickyBucketAssignmentDocs=i}}generateStickyBucketAssignmentDocsSync(e,s){if(!("getAllAssignmentsSync"in e)){console.error("generating StickyBucketAssignmentDocs docs requires StickyBucketServiceSync");return}let i=this._getEvalContext(),r=Na(i,s);return e.getAllAssignmentsSync(r)}inDevMode(){return!!this._options.enableDevMode}}});var uh=et(()=>{"use strict";lh()});var ch={};ho(ch,{Growthbook:()=>La});var ft,La,dh=et(()=>{"use strict";uh();da();$i();Mi();ft=class ft{constructor(e,s,i={},r=!1){this.analytics=new Gs;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Zt("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:s,user_language:i,device_language:r,device_type:n,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:u,url:c,domain:h,utm_content:g,residence_country:f,loggedIn:p,network_type:_,network_downlink:v,user_id:m,anonymous_id:y,account_mode:w})=>{let T={...this.GrowthBook.getAttributes(),id:e,...m!==void 0&&{user_id:m},...y!==void 0&&{anonymous_id:y},...s!==void 0&&{country:s},...f!==void 0&&{residence_country:f},...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},...c!==void 0&&{url:c},...h!==void 0&&{domain:h},...g!==void 0&&{utm_content:g},...p!==void 0&&{loggedIn:p},..._!==void 0&&{network_type:_},...v!==void 0&&{network_downlink:v},...w!==void 0&&{account_mode:w}};this.log("setAttributes | updating GrowthBook attributes",T),this.GrowthBook.setAttributes(T)};this.getFeatureValue=(e,s)=>{let i=this.GrowthBook.getFeatureValue(e,s);return this.log("getFeatureValue",{key:e,value:i,defaultValue:s}),i};this.getStatus=async()=>(await this.waitForIsLoaded(),{isLoaded:this.isLoaded,status:this.status});this.getFeatureState=e=>{let s=this.GrowthBook.evalFeature(e);return this.log("getFeatureState",{id:e,result:s}),s};this.setUrl=e=>{this.log("setUrl",{href:e}),this.GrowthBook.setURL(e)};this.isOn=e=>{let s=this.GrowthBook.isOn(e);return this.log("isOn",{key:e,result:s}),s};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 qi({apiHost:id,clientKey:e,decryptionKey:s,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 s=e??(typeof window<"u"?window.location.href:"");this.GrowthBook.setURL(s)}waitForIsLoaded(e=1e4){return new Promise((s,i)=>{let r=Date.now(),n=setInterval(()=>{this.isLoaded?(clearInterval(n),s()):Date.now()-r>=e&&(clearInterval(n),i(new Error("GrowthBook initialization timeout")))},100)})}};ft.getGrowthBookInstance=(e,s,i,r=!1)=>ft._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),ft._instance):(ft._instance=new ft(e,s??"",i,r),ft._instance),ft.resetInstance=()=>{ft._instance&&(ft._instance.destroy(),ft._instance=void 0)};La=ft});function Nf(t,e){if(t==null)return{};var s={};for(var i in t)if({}.hasOwnProperty.call(t,i)){if(e.indexOf(i)!==-1)continue;s[i]=t[i]}return s}function k(){return k=Object.assign?Object.assign.bind():function(t){for(var e=1;arguments.length>e;e++){var s=arguments[e];for(var i in s)({}).hasOwnProperty.call(s,i)&&(t[i]=s[i])}return t},k.apply(null,arguments)}function hh(t,e,s,i,r,n,o){try{var a=t[n](o),l=a.value}catch(u){return void s(u)}a.done?e(l):Promise.resolve(l).then(i,r)}function ge(t){return function(){var e=this,s=arguments;return new Promise(function(i,r){var n=t.apply(e,s);function o(l){hh(n,i,r,o,a,"next",l)}function a(l){hh(n,i,r,o,a,"throw",l)}o(void 0)})}}function Lf(){return!(!b||b.navigator.onLine===!1)}function M(t,e){return t.indexOf(e)!==-1}function $f(t){var e,s=[];return(e=JSON.stringify(t,function(i,r){if(typeof r=="bigint")return r.toString();if(typeof r!="function"&&typeof r!="symbol"){if(r instanceof Error)return{name:r.name,message:r.message,stack:r.stack};if(r&&typeof r=="object"){for(;s.length>0&&s[s.length-1]!==this;)s.pop();if(s.includes(r))return"[Circular]";s.push(r)}return r}}))!==null&&e!==void 0?e:"null"}function Bf(t){return t===null||typeof t!="object"}function Un(t,e){return{}.toString.call(t)==="[object "+e+"]"}function mr(t){switch({}.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":case"[object DOMError]":case"[object WebAssembly.Exception]":return!0;default:return Uf(t,Error)}}function eu(t){return"u">typeof Event&&Uf(t,Event)}function Uf(t,e){try{return t instanceof e}catch{return!1}}function xt(t,e,s,i,r){return e>s&&(i.warn("min cannot be greater than max."),e=s),Re(t)?t>s?(i.warn(" cannot be greater than max: "+s+". Using max value instead."),s):e>t?(i.warn(" cannot be less than min: "+e+". Using min value instead."),e):t:(i.warn(" must be a number. using max or fallback. max: "+s+", fallback: "+r),xt(r??s,e,s,i))}function li(t){for(var e="",s=0;t.length>s;s++){var i=t.charCodeAt(s);if(55296>i||i>56319)e+=56320>i||i>57343?t[s]:"\uFFFD";else{var r=t.charCodeAt(s+1);56320>r||r>57343?e+="\uFFFD":(e+=t[s]+t[s+1],s++)}}return e}function Eh(t,e){return typeof(s=t)=="string"&&XE.test(s)?t:e();var s}function gg(t,e){var s=new Error(e);try{Object.defineProperty(s,"name",{value:t,writable:!0,enumerable:!0,configurable:!0})}catch{}return s}function ds(t){return t&&t.split("#")[0]}function su(t,e){var s=setTimeout(t,e);return s!=null&&s.unref&&s?.unref(),s}function Sh(t,e,s){return pg.apply(this,arguments)}function pg(){return(pg=ge(function*(t,e,s){var i;try{return yield Promise.race([t,new Promise((r,n)=>{i=su(()=>{try{s?.(),r()}catch(o){n(o)}},e)})])}finally{clearTimeout(i)}})).apply(this,arguments)}function QE(t){var e=globalThis._posthogChunkIds;if(e){var s=Object.keys(e);return Va&&s.length===bh?Va:(bh=s.length,Va=s.reduce((i,r)=>{mn||(mn={});var n=mn[r];if(n)i[n[0]]=n[1];else for(var o=t(r),a=o.length-1;a>=0;a--){var l,u=(l=o[a])==null?void 0:l.filename,c=e[r];if(u&&c){i[u]=c,mn[r]=[u,c];break}}return i},{}))}}function wl(t,e,s,i,r){var n={platform:t,filename:e,function:s==="<anonymous>"?"?":s,in_app:!!e&&!e.startsWith("webkit-masked-url://")&&e!=="<anonymous>"};return S(i)||(n.lineno=i),S(r)||(n.colno=r),n}function _g(t,e){e===void 0&&(e=40);var s=Object.keys(t);if(s.sort(),!s.length)return"[object has no keys]";for(var i=s.length;i>0;i--){var r=s.slice(0,i).join(", ");if(e>=r.length)return i===s.length?r:r.length>e?r.slice(0,e)+"...":r}return""}function zn(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:ja.enabled,max_bytes:yS(t.max_bytes,ja.max_bytes)}:k({},ja)}function yS(t,e){if(!Re(t)||t===1/0||t===-1/0)return e;var s=Math.floor(t);return 0>s?e:s}function Ah(t){return typeof t=="string"||t}function Ih(t){return typeof t=="string"?t:void 0}function Al(){return Al=ge(function*(t,e,s){e===void 0&&(e=!0);try{var i=new TextEncoder().encode(t),r=new globalThis.CompressionStream("gzip"),n=r.writable.getWriter(),o=n.write(i).then(()=>n.close()).catch((function(){var u=ge(function*(c){try{yield n.abort(c)}catch{}throw c});return function(c){return u.apply(this,arguments)}})()),a=new Response(r.readable).blob(),l=(yield Promise.all([a,o]))[0];return yield ES(l,i),l}catch(u){if(s!=null&&s.rethrow)throw u;return e&&console.error("Failed to gzip compress data",u),null}}),Al.apply(this,arguments)}function Kn(t,e){try{return yg(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function iu(t,e,s,i){if(0>=s.remainingNodes)return{stringValue:Sl};if(s.remainingNodes--,Xe(t))return{boolValue:t};if(typeof t=="bigint")return(function(l,u){var c=l.toString(),h=BigInt("9223372036854775808");return l>=h||-h>l?(u?.debug("Attribute "+c+" is outside the int64 range; encoding it as a string"),{stringValue:c}):{intValue:c}})(t,e);if(typeof t=="number"){if(!Number.isFinite(t))return{stringValue:String(t)};if(Number.isInteger(t)){if(Number.isSafeInteger(t))return{intValue:String(t)};if(typeof BigInt>"u")return{stringValue:String(t)};var r=BigInt(t).toString();return t>=9223372036854776e3||-9223372036854776e3>t?(e?.debug("Attribute "+r+" is outside the int64 range; encoding it as a string"),{stringValue:r}):{intValue:r}}return{doubleValue:t}}if(typeof t=="string")return{stringValue:li(t)};if(typeof t=="function")return{stringValue:"[Function]"};if(typeof t=="symbol")return{stringValue:String(t)};if(typeof t=="object"&&t!==null){if(s.ancestors.has(t))return{stringValue:"[Circular]"};if(i>=20)return{stringValue:Sl};if(t instanceof Date){var n=t.getTime(),o=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:typeof o=="string"?li(o):String(o)}}s.ancestors.add(t);try{try{var a=t.toJSON;if(typeof a=="function")return iu(a.call(t),e,s,i+1)}catch{}return F(t)?{arrayValue:{values:wS(t,e,s,i+1)}}:{kvlistValue:{values:yg(t,e,s,i+1)}}}finally{s.ancestors.delete(t)}}return{stringValue:li(String(t))}}function wS(t,e,s,i){for(var r=[],n=Math.min(t.length,1e3),o=0;n>o&&s.remainingNodes>0;o++)try{var a=o in t?t[o]:void 0;if(H(a))continue;r.push(iu(a,e,s,i))}catch{r.push({stringValue:uo})}return t.length>o&&r.push({stringValue:Sl}),r}function yg(t,e,s,i){var r=[];for(var n in t)if(SS.call(t,n)){if(!n){e?.debug("Dropping an attribute with an empty key");continue}if(r.length>=1e3||0>=s.remainingNodes){e?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{var o=t[n];if(Ie(o)||S(o))continue;r.push({key:li(n),value:iu(o,e,s,i)})}catch{r.push({key:li(n),value:{stringValue:uo}})}}return r}function bg(t,e,s){return k({},t.resourceAttributes,{"service.name":t.serviceName||"unknown_service"},t.environment&&{"deployment.environment":t.environment},t.serviceVersion&&{"service.version":t.serviceVersion},{"telemetry.sdk.name":e,"telemetry.sdk.version":s})}function AS(t){try{return li(String(t))}catch{return uo}}function IS(t,e,s,i){var r,n=Eg[t.level||"info"]||kS,o=n.text,a=n.number,l=((r=Re(i)?i:void 0)===void 0&&(r=Date.now()),String(r)+"000000"),u={};e.distinctId&&(u.posthogDistinctId=e.distinctId),e.sessionId&&(u.sessionId=e.sessionId),e.windowId&&(u["window.id"]=e.windowId),H(e.sessionStartTimestamp)||(u.sessionStartTimestamp=String(e.sessionStartTimestamp)),H(e.lastActivityTimestamp)||(u.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(u["url.full"]=e.currentUrl),e.screenName&&(u["screen.name"]=e.screenName),e.appState&&(u["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(u.feature_flags=e.activeFeatureFlags);var c=k({},u),h=t.attributes;if(h){var g=[];try{g=Object.keys(h)}catch{g=[]}for(var f of g){var p=void 0;try{p=h[f]}catch{p=uo}Object.defineProperty(c,f,{value:p,enumerable:!0,writable:!0,configurable:!0})}}var _={timeUnixNano:l,observedTimeUnixNano:l,severityNumber:a,severityText:o,body:{stringValue:AS(t.body)},attributes:Kn(c,s)};return t.trace_id&&(_.traceId=t.trace_id),t.span_id&&(_.spanId=t.span_id),S(t.trace_flags)||(_.flags=t.trace_flags),_}function Sg(t,e,s){return bg(t,e,s)}function wg(t,e,s,i){return{resourceLogs:[{resource:{attributes:Kn(e)},scopeLogs:[{scope:{name:s,version:i},logRecords:t}]}]}}function Ph(t){return String(t)+"000000"}function Ch(t,e,s,i){var r="";return i&&(r=Object.keys(i).sort().map(n=>JSON.stringify(n)+":"+JSON.stringify(i[n])).join(",")),t+"\0"+e+"\0"+(s??"")+"\0"+r}function bn(t,e){F(t)&&t.forEach(e)}function ie(t,e){if(!H(t))if(F(t))t.forEach(e);else if((i=>i instanceof FormData)(t))t.forEach((i,r)=>e(i,r));else for(var s in t)Mf.call(t,s)&&e(t[s],s)}function $n(t){for(var e=Object.keys(t),s=e.length,i=new Array(s);s--;)i[s]=[e[s],t[e[s]]];return i}function Ug(t){var e=k({},t);for(var s of["name","message","stack","cause","errors"])try{s in t&&(e[s]=t[s])}catch{}return e}function ew(t){var e=t?.hostname;if(!Q(e))return!1;var s=e.split(".").slice(-2).join(".");for(var i of ZS)if(s===i)return!1;return!0}function ae(t,e,s,i){var r=i??{},n=r.capture,o=r.passive;t?.addEventListener(e,s,{capture:n!==void 0&&n,passive:o===void 0||o})}function Ul(t){return t.name==="ph_toolbar_internal"}function Gg(t,e){var s,i=t==null||(s=t.config)==null?void 0:s.get_current_url;if(!qe(i))return e;try{var r=i(e);return Q(r)&&r?r:e}catch(n){return I.error("Error in get_current_url, falling back to window.location.href",n),e}}function Bh(t){return t instanceof Element&&(t.id==="__POSTHOG_TOOLBAR__"||!(t.closest==null||!t.closest(".toolbar-global-fade-container")))}function Dt(t){return!!t&&t.nodeType===1}function Ge(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Hg(t){return!!t&&t.nodeType===3}function du(t){return!!t&&t.nodeType===11&&Dt(t.host)}function hu(t){return t?no(t).split(/\s+/):[]}function Uh(t,e){var s=(function(i){var r,n=b==null||(r=b.location)==null?void 0:r.href;return S(n)?void 0:Gg(i,n)})(e);return!!(s&&t&&t.some(i=>s.match(i)))}function fi(t){var e="";switch(typeof t.className){case"string":e=t.className;break;case"object":e=(t.className&&"baseVal"in t.className?t.className.baseVal:null)||t.getAttribute("class")||"";break;default:e=""}return hu(e)}function qg(t){return H(t)?null:no(t).split(/(\s+)/).filter(e=>ar(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function gr(t){var e="";return ci(t)&&!pr(t)&&t.childNodes&&t.childNodes.length&&ie(t.childNodes,function(s){var i;Hg(s)&&s.textContent&&(e+=(i=qg(s.textContent))!==null&&i!==void 0?i:"")}),no(e)}function or(t){var e;return S(t.target)?t.srcElement||null:(e=t.target)!=null&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}function Hl(t,e){var s=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!s&&s.call(t,e)}catch{return!1}}function ql(t,e){if(S(e))return!0;var s,i=function(n){if(e.some(o=>Hl(n,o)))return{v:!0}};for(var r of t)if(s=i(r))return s.v;return!1}function zg(t){var e=t.parentNode;return!(!e||!Dt(e))&&e}function Wg(t,e){if(!b||gu(t))return!1;var s,i,r,n,o;if(Xe(e)?(s=!!e&&jh,i=void 0,r=!1):(s=(n=e?.css_selector_ignorelist)!==null&&n!==void 0?n:jh,i=e?.content_ignorelist,r=(o=e?.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||r&&(function(l){return!(!l||!Dt(l))&&(!!Ge(l,"textarea")||(Ge(l,"input")?M(uw,(l.getAttribute("type")||"").toLowerCase()):(function(u){if(u.isContentEditable)return!0;var c=u.getAttribute==null?void 0:u.getAttribute("contenteditable");return c==="true"||c===""})(l)))})(t))return!1;var a=Jg(t,!1).targetElementList;return!(function(l,u){if(l===!1||S(l))return!1;var c;if(l===!0)c=Kg;else{if(!F(l))return!1;if(l.length>10)return I.error("[PostHog] content_ignorelist array cannot exceed 10 items. Use css_selector_ignorelist for more complex matching."),!1;c=l.map(h=>h.toLowerCase())}return u.some(h=>{var g=h.safeText,f=h.ariaLabel;return c.some(p=>Vh(g,p)||Vh(f,p))})})(i,a.map(l=>{var u;return{safeText:gr(l).toLowerCase(),ariaLabel:((u=l.getAttribute("aria-label"))==null?void 0:u.toLowerCase().trim())||""}}))&&!ql(a,s)}function ci(t){for(var e=new Set,s=0,i=t;i.parentNode&&!Ge(i,"body");i=i.parentNode){if(s++>=1e3||e.has(i))return!1;e.add(i);var r=fi(i);if(M(r,"ph-sensitive")||M(r,"ph-no-capture"))return!1}if(M(fi(t),"ph-include"))return!0;var n=t.type||"";if(Q(n))switch(n.toLowerCase()){case"hidden":case"password":return!1}var o=t.name||t.id||"";return!Q(o)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(o.replace(/[^a-zA-Z0-9]/g,""))}function pr(t){return!!(Ge(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ge(t,"select")||Ge(t,"textarea")||t.getAttribute("contenteditable")==="true")}function hw(t){for(var e=0,s=!1,i=t.length-1;i>=0;i--){var r=t.charCodeAt(i)-48;s&&(r*=2)>9&&(r-=9),e+=r,s=!s}return e%10==0}function ar(t,e){return e===void 0&&(e=!0),!(H(t)||Q(t)&&(t=no(t),(e?Gh.test((t||"").replace(/[- ]/g,"")):(function(s){var i;for(Hh.lastIndex=0;i=Hh.exec(s);){var r=i[2];if(r)for(var n=r.replace(/[- ]/g,""),o=0;n.length>o;o++)for(var a of cw){var l=o+a;if(n.length>=l){var u=n.slice(o,l);if(Gh.test(u)&&hw(u))return!0}}}return!1})(t))||(e?dw.test(t):(function(s){var i;for(qh.lastIndex=0;i=qh.exec(s);){var r=i[1],n=i[3];if(!(r&&n&&zh.test(r)&&zh.test(n)))return!0}return!1})(t))))}function Kh(t){var e=gr(t);return ar(e=(e+" "+Yg(t)).trim())?e:""}function Yg(t){var e="";return t&&t.childNodes&&t.childNodes.length&&ie(t.childNodes,function(s){var i;if(s&&((i=s.tagName)==null?void 0:i.toLowerCase())==="span")try{var r=gr(s);e=(e+" "+r).trim(),s.childNodes&&s.childNodes.length&&(e=(e+" "+Yg(s)).trim())}catch(n){I.error("[AutoCapture]",n)}}),e}function Wh(t){return t.replace(/"|\\"/g,'\\"')}function fw(t){var e=t.attr__class;if(e)return F(e)?e:hu(e)}function Yh(t,e,s){s===void 0&&(s=!0);var i=t.config.segment;if(!i)return e();(function(r,n,o){var a=r.config.segment;if(!a)return n();var l=c=>{var h=()=>c.anonymousId()||St();r.config.get_device_id=h,o&&c.id()&&(r.register({distinct_id:c.id(),$device_id:h()}),r.persistence.set_property(je,sr)),n(o?void 0:c.anonymousId()||void 0)},u=a.user();"then"in u&&qe(u.then)?u.then(l):l(u)})(t,r=>{i.register(((n,o)=>{typeof Promise<"u"&&Promise.resolve||Sn.warn("This browser does not have Promise support, and can not use the segment integration");var a=(l,u)=>{if(!u)return l;var c=!!o&&l.event.anonymousId===o&&!l.event.userId;c||l.event.userId||l.event.anonymousId===n.get_distinct_id()||(Sn.info("No userId set, resetting PostHog"),n.reset()),c||(o=void 0),l.event.userId&&l.event.userId!==n.get_distinct_id()&&(Sn.info("UserId set, identifying with PostHog"),n.identify(l.event.userId));var h=n.calculateEventProperties(u,l.event.properties);return l.event.properties=Object.assign({},h,l.event.properties),l};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(l){return a(l,l.event.event)},page(l){return a(l,uu)},identify(l){return a(l,Bl)},screen(l){return a(l,"$screen")}}})(t,r)).then(()=>{e()},n=>{Sn.error("Failed to register the Segment integration",n),e()})},s)}function Qg(t,e){var s=e===void 0?{}:e,i=s.organization,r=s.projectId,n=s.prefix,o=s.severityAllowList,a=o===void 0?["error"]:o,l=s.sendExceptionsToPostHog,u=l===void 0||l;return c=>{var h,g,f,p,_,v;if(a!=="*"&&!a.includes(c.level)||!t.__loaded)return c;c.tags||(c.tags={});var m=t.requestRouter.endpointFor("ui","/project/"+t.config.token+"/person/"+t.get_distinct_id());c.tags["PostHog Person URL"]=m,t.sessionRecordingStarted()&&(c.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));var y=((h=c.exception)==null?void 0:h.values)||[],w=y.map(T=>k({},T,{stacktrace:T.stacktrace?k({},T.stacktrace,{type:"raw",frames:(T.stacktrace.frames||[]).map(C=>k({},C,{platform:"web:javascript"}))}):void 0})),E={$exception_message:((g=y[0])==null?void 0:g.value)||c.message,$exception_type:(f=y[0])==null?void 0:f.type,$exception_level:c.level,$exception_list:w,$sentry_event_id:c.event_id,$sentry_exception:c.exception,$sentry_exception_message:((p=y[0])==null?void 0:p.value)||c.message,$sentry_exception_type:(_=y[0])==null?void 0:_.type,$sentry_tags:c.tags};return i&&r&&(E.$sentry_url=(n||"https://sentry.io/organizations/")+i+"/issues/?project="+r+"&query="+c.event_id),u&&((v=t.exceptions)==null||v.sendExceptionEvent(E)),c}}function tp(t,e,s){if(!A)return{};var i,r=e?[...vi,...s||[]]:[],n=sp(vr(A.URL,r,_r),t);return fe((i={},ie(bw,function(o){var a=Vl(o);i[o]=a||null}),i),n)}function sp(t,e){var s=yw.concat(e||[]),i={};return ie(s,function(r){var n=pi(t,r);i[r]=n||null}),i}function ip(t){var e=(function(n){return n?n.search("https?://(.*)google.([^/?]*)")===0?"google":n.search("https?://(.*)bing.com")===0?"bing":n.search("https?://(.*)yahoo.com")===0?"yahoo":n.search("https?://(.*)duckduckgo.com")===0?"duckduckgo":null:null})(t),s=e!="yahoo"?"q":"p",i={};if(!Ie(e)){i.$search_engine=e;var r=A?pi(A.referrer,s):"";r.length&&(i.ph_keyword=r)}return i}function Qh(){return navigator.language||navigator.userLanguage}function rp(){return A?.referrer||eo}function np(t,e,s){var i;s===void 0&&(s=!1);var r=t?[...vi,...e||[]]:[],n=(i=s?ds(Ee?.href):Ee?.href)==null?void 0:i.substring(0,1e3);return{r:rp().substring(0,1e3),u:n?vr(n,r,_r):void 0}}function op(t,e){var s;e===void 0&&(e=!1);var i=t.r,r=t.u,n=e?ds(r):r,o={$referrer:i,$referring_domain:i==null?void 0:i==eo?eo:(s=gi(i))==null?void 0:s.host};if(n){o.$current_url=n;var a=gi(n);o.$host=a?.host,o.$pathname=a?.pathname,fe(o,sp(n))}return i&&fe(o,ip(i)),o}function ap(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Ew(){try{return new Date().getTimezoneOffset()}catch{return}}function An(t){var e=!0;return{dispose(){if(e){e=!1;var s=t();s&&qe(s.then)&&s.then(void 0,()=>{})}}}}function Cw(t,e){e===void 0&&(e={});var s=(function(){var g=4294967295;return{p(f){for(var p=g,_=0;f.length>_;++_)p=Pw[255&p^f[_]]^p>>>8;g=p},d(){return 4294967295^g}}})(),i=t.length;s.p(t);var r,n,o,a,l,u,c=(a=10+((r=e).filename&&r.filename.length+1||0),l=8,(function(g,f,p,_,v,m){var y=g.length,w=new ut(_+y+5*(1+Math.floor(y/7e3))+v),E=w.subarray(_,w.length-v),T=0;if(!f||8>y)for(var C=0;y>=C;C+=65535){var q=C+65535;y>q?T=Fn(E,T,g.subarray(C,q)):(E[C]=m,T=Fn(E,T,g.subarray(C,y)))}else{for(var x=Tw[f-1],le=x>>>13,D=8191&x,P=(1<<p)-1,G=new Qe(32768),N=new Qe(P+1),U=Math.ceil(p/3),ue=2*U,Oe=function(wi){return(g[wi]^g[wi+1]<<U^g[wi+2]<<ue)&P},he=new _i(25e3),oe=new Qe(288),O=new Qe(32),B=0,V=0,K=(C=0,0),J=0,W=0;y>C;++C){var Z=Oe(C),X=32767&C,se=N[Z];if(G[X]=se,N[Z]=X,C>=J){var xe=y-C;if((B>7e3||K>24576)&&xe>423){T=nf(g,E,0,he,oe,O,V,K,W,C-W,T),K=B=V=0,W=C;for(var Se=0;286>Se;++Se)oe[Se]=0;for(Se=0;30>Se;++Se)O[Se]=0}var j=2,Me=0,hs=D,De=X-se&32767;if(xe>2&&Z==Oe(C-De))for(var mi=Math.min(le,xe)-1,yi=Math.min(32767,C),bi=Math.min(258,xe);yi>=De&&--hs&&X!=se;){if(g[C+j]==g[C+j-De]){for(var ct=0;bi>ct&&g[C+ct]==g[C+ct-De];++ct);if(ct>j){if(j=ct,Me=De,ct>mi)break;var Ze=Math.min(De,ct-2),Ei=0;for(Se=0;Ze>Se;++Se){var Ds=C-De+Se+32768&32767,Ns=Ds-G[Ds]+32768&32767;Ns>Ei&&(Ei=Ns,se=Ds)}}}De+=(X=se)-(se=G[X])+32768&32767}if(Me){he[K++]=268435456|Kl[j]<<18|Wl[Me];var Si=31&Kl[j],Ls=31&Wl[Me];V+=pu[Si]+vu[Ls],++oe[257+Si],++O[Ls],J=C+j,++B}else he[K++]=g[C],++oe[g[C]]}}T=nf(g,E,m,he,oe,O,V,K,W,C-W,T),m||(T=Fn(E,T,Ow))}return hp(w,0,_+dp(T)+v)})(n=t,(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,!u)),h=c.length;return(function(g,f){var p=f.filename;if(g[0]=31,g[1]=139,g[2]=8,g[8]=2>f.level?4:f.level==9?2:0,g[9]=3,f.mtime!=0&&nl(g,4,Math.floor(new Date(f.mtime||Date.now())/1e3)),p){g[3]=8;for(var _=0;p.length>=_;++_)g[_+10]=p.charCodeAt(_)}})(c,e),nl(c,h-8,s.d()),nl(c,h-4,i),c}function Ep(){return(Ep=ge(function*(){var t=Fe?.userAgentData;if(t!=null&&t.getHighEntropyValues)try{var e,s=(e=yield t.getHighEntropyValues(["model"]))==null?void 0:e.model;return Q(s)&&s.length>0?s:void 0}catch(i){return void I.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",i)}})).apply(this,arguments)}function Bw(t,e){var s="$survey_"+e+"/"+t.id;return t.current_iteration&&t.current_iteration>0&&(s="$survey_"+e+"/"+t.id+"/"+t.current_iteration),s}function Sp(t){var e;return!((e=t.conditions)==null||(e=e.events)==null||(e=e.values)==null||!e.length)}function kp(t,e){return!t||Object.entries(t).every(s=>{var i=s[1],r=e?.[s[0]];if(r==null)return!1;var n=wp[i.operator];return!!n&&n(i.values,[String(r)])})}function al(t,e,s){return ai({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:s})}function hl(t,e){return e.length>t?e.slice(0,t)+"...":e}function sk(t){if(t.previousElementSibling)return t.previousElementSibling;var e=t;do e=e.previousSibling;while(e&&!Dt(e));return e}function ik(t,e){var s,i,r=e.e,n=e.maskAllElementAttributes,o=e.maskAllText,a=e.elementAttributeIgnoreList,l=e.elementsChainAsString,u=e.disableCaptureUrlHashes;if(!Dt(t))return{props:{}};for(var c=[t],h=new Set([t]),g=t;g.parentNode&&!Ge(g,"body")&&1e3>c.length;)if(du(g.parentNode)){var f=g.parentNode.host;if(h.has(f))break;h.add(f),c.push(f),g=f}else{if(!Dt(g.parentNode)||h.has(g.parentNode))break;h.add(g.parentNode),c.push(g.parentNode),g=g.parentNode}var p=r.type==="click"&&t.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(D=>Ge(D,"button")||Ge(D,"a")):-1;p>0&&(o=o||c.slice(0,p+1).some(D=>!ci(D)||pr(D)));var _,v,m,y=[],w={},E=!1,T=!1;if(ie(c,D=>{var P=ci(D);if(Ge(D,"a")){var G=D.getAttribute("href");E=!!(P&&G&&ar(G))&&(u?ds(G):G)}M(fi(D),"ph-no-capture")&&(T=!0),y.push((function(N,U,ue,Oe,he){he===void 0&&(he=!1);var oe=N.tagName.toLowerCase(),O={tag_name:oe};fu.indexOf(oe)>-1&&!ue&&(O.$el_text=oe.toLowerCase()==="a"||oe.toLowerCase()==="button"?hl(1024,Kh(N)):hl(1024,gr(N)));var B=fi(N);B.length>0&&(O.classes=B.filter(function(W){return W!==""})),ie(N.attributes,function(W){var Z;if((!pr(N)||["name","id","class","aria-label"].indexOf(W.name)!==-1)&&(Oe==null||!Oe.includes(W.name))&&!U&&ar(W.value)&&(!Q(Z=W.name)||Z.substring(0,10)!=="_ngcontent"&&Z.substring(0,7)!=="_nghost")){var X=W.value;W.name==="class"&&(X=hu(X).join(" ")),O["attr__"+W.name]=hl(1024,W.name==="href"&&he?ds(X):X)}});for(var V=1,K=1,J=N;J=sk(J);)V++,J.tagName===N.tagName&&K++;return O.nth_child=V,O.nth_of_type=K,O})(D,n,o,a,u)),ie((function(N){if(!ci(N))return{};var U={};return ie(N.attributes,function(ue){if(ue.name&&ue.name.indexOf("data-ph-capture-attribute")===0){var Oe=ue.name.replace("data-ph-capture-attribute-",""),he=ue.value;Oe&&he&&ar(he)&&(U[Oe]=he)}}),U})(D),(N,U)=>{({}).hasOwnProperty.call(w,U)||(w[U]=N)})}),T)return{props:{},explicitNoCapture:T};if(p>0&&(t=c[p],y.splice(0,p)),o||(y[0].$el_text=Ge(t,"a")||Ge(t,"button")?Kh(t):gr(t)),E){var C,q;y[0].attr__href=E;var x=(C=gi(E))==null?void 0:C.host,le=b==null||(q=b.location)==null?void 0:q.host;x&&le&&x!==le&&(_=E)}return{props:fe((v=r.type,{$event_type:v,$ce_version:1}),l?{}:{$elements:y},{$elements_chain:(m=y,F(m)?(function(D){return D.map(P=>{var G,N,U="";if(P.tag_name&&(U+=P.tag_name),P.attr_class)for(var ue of(P.attr_class.sort(),P.attr_class))U+="."+ue.replace(/"/g,"");var Oe=k({},P.text?{text:P.text}:{},{"nth-child":(G=P.nth_child)!==null&&G!==void 0?G:0,"nth-of-type":(N=P.nth_of_type)!==null&&N!==void 0?N:0},P.href?{href:P.href}:{},P.attr_id?{attr_id:P.attr_id}:{},P.attributes),he={};return $n(Oe).sort((oe,O)=>{return(V=O[0])>(B=oe[0])?-1:B>V?1:0;var B,V}).forEach(oe=>{var O=oe[1];return he[Wh(oe[0].toString())]=Wh(O.toString())}),(U+=":")+$n(he).map(oe=>oe[0]+'="'+oe[1]+'"').join("")}).join(";")})((function(D){return D.map(P=>{var G,N,U={text:(G=P.$el_text)==null?void 0:G.slice(0,400),tag_name:P.tag_name,href:(N=P.attr__href)==null?void 0:N.slice(0,2048),attr_class:fw(P),attr_id:P.attr__id,nth_child:P.nth_child,nth_of_type:P.nth_of_type,attributes:{}};return $n(P).filter(ue=>ue[0].indexOf("attr__")===0).forEach(ue=>U.attributes[ue[0]]=ue[1]),U})})(m)):"")},(s=y[0])!=null&&s.$el_text?{$el_text:(i=y[0])==null?void 0:i.$el_text}:{},_&&r.type==="click"?{$external_click_url:_}:{},w),target:t}}function Op(t,e,s){try{if(!(e in t))return pf;var i={next:t[e]},r=s(function(){for(var n=arguments.length,o=new Array(n),a=0;n>a;a++)o[a]=arguments[a];return i.next.apply(this,o)});return qe(r)&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:i}})),t[e]=r,()=>{if(t[e]!==r)for(var n=t[e],o=vf(n);o;){if(o.next===r)return void(o.next=i.next);o=vf(n=o.next)}else t[e]=i.next}}catch{return pf}}function fl(t){return Y(t)&&"clientX"in t&&"clientY"in t&&Re(t.clientX)&&Re(t.clientY)}function ri(t,e,s){if(H(t))return!1;switch(s){case"exact":return t===e;case"contains":var i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/_/g,".").replace(/%/g,".*");return new RegExp(i,"i").test(t);case"regex":try{return new RegExp(e).test(t)}catch{return!1}default:return!1}}function Cf(t,e){var s,i,r,n,o,a,l,u=(s=t?.flushIntervalMs)!==null&&s!==void 0?s:3e3,c=(i=t?.maxBufferSize)!==null&&i!==void 0?i:100,h=e!=null&&e.consoleCapture?void 0:(r=t?.maxLogsPerInterval)!==null&&r!==void 0?r:1e3,g=S(h)?Math.max(c,2048):Math.max(c,h),f=k({},(function(){var p="",_="";try{var v=Fe?.userAgent;if(v){var m=fg(v);p=m[0],_=m[1]}}catch{}return(function(y,w){var E=(function(T){if(T)return{}.hasOwnProperty.call(Oh,T)?Oh[T]:T})(y);return k({},E?{"os.name":E}:{},w?{"os.version":w}:{})})(p,_)})(),t?.resourceAttributes);return{serviceName:(n=(o=f?.["service.name"])!==null&&o!==void 0?o:t?.serviceName)!==null&&n!==void 0?n:e?.serviceNameDefault,serviceVersion:(a=f?.["service.version"])!==null&&a!==void 0?a:t?.serviceVersion,environment:(l=f?.["deployment.environment"])!==null&&l!==void 0?l:t?.environment,resourceAttributes:f,beforeSend:t?.beforeSend,flushIntervalMs:u,maxBufferSize:c,maxQueueSize:g,maxBatchRecordsPerPost:100,rateCapWindowMs:u,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}var _n,DE,NE,b,ze,Fe,A,Ee,dr,Zl,fh,LE,Ye,zi,L,gh,Yt,$E,ph,no,_l,Pt,ml,FE,ME,Ff,Mf,oo,F,qe,Y,nt,S,Q,rr,Ie,H,Re,zt,Xe,BE,UE,VE,$a,jE,GE,di,hr,Vn,Vf,jf,Gf,Pn,ao,Hf,Cn,qf,zf,Kf,Wf,Jf,xn,Yf,jn,Gn,lo,Xf,Qf,Fa,Zf,vh,yl,HE,eg,bl,tg,sg,ig,rg,ng,og,ag,El,lg,ug,cg,dg,Ma,Ba,qE,zE,KE,tu,WE,hg,JE,YE,_h,fg,mh,Ua,yh,Sl,uo,mn,bh,Va,XE,ZE,vg,eS,tS,sS,iS,rS,nS,oS,wh,aS,lS,uS,cS,dS,hS,fS,gS,pS,vS,Hn,qn,_S,ja,mS,kh,Ki,bS,mg,kl,Rh,Th,yn,ES,SS,Oh,Eg,kS,RS,Ga,TS,kg,I,Te,OS,Wn,Rs,Ha,xh,Le,PS,bt,ru,qa,Jn,CS,za,Et,Il,Rl,Tl,Ol,Ag,Pl,Cl,nu,ou,xl,Ig,ui,xS,Rg,Tg,Og,Pg,Cg,ni,au,DS,NS,LS,$S,FS,pt,Ct,Dl,Ps,as,Cs,nr,Ot,Ts,Wt,ls,xg,Nl,Yn,Ll,Dn,Nn,Ln,MS,BS,US,VS,jS,GS,us,tr,fr,cs,je,$l,Dg,Ng,Lg,oi,lu,Ka,$g,Fg,Mg,Fl,HS,qS,zS,KS,WS,JS,YS,XS,Ml,os,sr,Bg,hi,Xn,uu,Dh,Bl,Nh,fe,Lh,QS,cu,ZS,Vl,tw,sw,Vg,$h,iw,St,rw,Wi,nw,Zs,be,Wa,ee,Ja,Os,Qn,ow,Ya,Xa,jg,Fh,Mh,Qa,ei,Gl,Ss,de,aw,fu,Za,Kg,lw,Vh,jh,uw,gu,Jg,Gh,Hh,cw,dw,qh,zh,En,gw,pw,Jh,Sn,Xg,vw,Xh,Ji,_w,mw,Be,ai,gi,pi,vr,Zn,Zg,ep,vi,yw,_r,bw,eo,Sw,ww,wn,kn,Ne,Kt,el,is,ti,Zh,tl,lt,Yi,sl,Jt,il,zl,kw,ef,tf,Aw,rs,lp,ut,Qe,_i,pu,vu,sf,up,cp,Kl,ws,Wl,to,_e,lr,xs,so,Iw,Rw,dp,hp,Ht,Xi,rl,Jl,rf,Qi,Fn,nf,Tw,Ow,Pw,nl,xw,fp,Mn,gp,yr,ol,pp,vp,Dw,Nw,_p,mp,yp,Yl,of,Bn,Lw,$w,Fw,Mw,af,io,si,lf,uf,bp,ro,In,wp,Xl,cf,Uw,Vw,jw,ne,Ap,Gw,Hw,qw,zw,Kw,Ww,Jw,df,Yw,ur,ll,cr,hf,Zi,ff,Ip,Xw,ul,Qw,ir,Rp,Zw,cl,ek,gf,tk,_u,Tp,dl,Rn,rk,nk,er,pf,vf,ok,ks,_f,mf,ak,lk,Tn,yf,qt,uk,On,gl,Tt,bf,Pp,ii,Ef,ck,dk,hk,fk,gk,pk,vk,Sf,wf,kf,_k,Af,As,pl,If,Rf,Tf,Of,yt,Ql,mk,yk,bk,Pf,Ek,gt,Is,Sk,xf,Cp,vl,Df,co,wk,kk,Ak,Ik,Rk,Tk,Ok,Pk,Ck,xk,Dk,Ce,xp=et(()=>{"use strict";DE=["retriesPerformedSoFar"],NE=["$set_once","$set"];b="u">typeof window?window:void 0,ze="u">typeof globalThis?globalThis:b,Fe=ze?.navigator,A=ze?.document,Ee=ze?.location,dr=ze?.fetch,Zl=ze!=null&&ze.XMLHttpRequest&&"withCredentials"in new ze.XMLHttpRequest?ze.XMLHttpRequest:void 0,fh=ze?.AbortController,LE=ze?.CompressionStream,Ye=Fe?.userAgent;zi=typeof globalThis<"u"?globalThis:b;zi&&typeof self>"u"&&(zi.self=zi),zi&&typeof File>"u"&&(zi.File=function(){});L=b??{},gh="0.8.2",Yt={DEBUG:!1,LIB_VERSION:gh,LIB_NAME:"browser-common",JS_SDK_VERSION:gh},$E=["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","pinterestbot","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"],ph=function(t,e){if(e===void 0&&(e=[]),!t)return!1;var s=t.toLowerCase();return $E.concat(e).some(i=>{var r=i.toLowerCase();return s.indexOf(r)!==-1})};no=function(t){return t.trim()},_l=function(t){return t.replace(/^\$/,"")};Pt=(function(t){return t.AnonymousId="anonymous_id",t.DistinctId="distinct_id",t.Props="props",t.EnablePersonProcessing="enable_person_processing",t.PersonMode="person_mode",t.FeatureFlagDetails="feature_flag_details",t.FeatureFlags="feature_flags",t.FeatureFlagPayloads="feature_flag_payloads",t.BootstrapFeatureFlagDetails="bootstrap_feature_flag_details",t.BootstrapFeatureFlags="bootstrap_feature_flags",t.BootstrapFeatureFlagPayloads="bootstrap_feature_flag_payloads",t.OverrideFeatureFlags="override_feature_flags",t.Queue="queue",t.AiQueue="ai_queue",t.AiCaptureQueue="ai_capture_queue",t.LogsQueue="logs_queue",t.OptedOut="opted_out",t.SessionId="session_id",t.SessionStartTimestamp="session_start_timestamp",t.SessionLastTimestamp="session_timestamp",t.PersonProperties="person_properties",t.GroupProperties="group_properties",t.InstalledAppBuild="installed_app_build",t.InstalledAppVersion="installed_app_version",t.SessionReplay="session_replay",t.PushRegistered="push_registered",t.SessionReplayEventTriggerActivatedSession="session_replay_event_trigger_activated_session",t.SurveyLastSeenDate="survey_last_seen_date",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),ml=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),FE=["$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"],ME=["token"],Ff=Object.prototype,Mf=Ff.hasOwnProperty,oo=Ff.toString,F=Array.isArray||function(t){return oo.call(t)==="[object Array]"},qe=t=>typeof t=="function",Y=t=>t===Object(t)&&!F(t),nt=t=>{if(Y(t)){for(var e in t)if(Mf.call(t,e))return!1;return!0}return!1},S=t=>t===void 0,Q=t=>oo.call(t)=="[object String]",rr=t=>Q(t)&&t.trim().length===0,Ie=t=>t===null,H=t=>S(t)||Ie(t),Re=t=>oo.call(t)=="[object Number]"&&t==t,zt=t=>Re(t)&&t>0,Xe=t=>oo.call(t)==="[object Boolean]",BE=t=>M(FE,t),UE=t=>M(ME,t);VE=[!0,"true",1,"1","yes"],$a=t=>M(VE,t),jE=[!1,"false",0,"0","no"];GE=class{constructor(t){this.C={},this.I=t.I,this.R=xt(t.bucketSize,0,100,t.A),this.O=xt(t.refillRate,0,this.R,t.A),this.N=xt(t.refillInterval,0,864e5,t.A)}F(t,e){var s=Math.floor((e-t.lastAccess)/this.N);s>0&&(t.tokens=Math.min(t.tokens+s*this.O,this.R),t.lastAccess=t.lastAccess+s*this.N)}consumeRateLimit(t){var e,s=Date.now(),i=String(t),r=this.C[i];return r?this.F(r,s):this.C[i]=r={tokens:this.R,lastAccess:s},r.tokens===0||(r.tokens--,r.tokens===0&&((e=this.I)==null||e.call(this,t)),r.tokens===0)}stop(){this.C={}}},di="Mobile",hr="Android",Vn="Tablet",Vf="Android Tablet",jf="iPad",Gf="Apple Watch",Pn="Safari",ao="BlackBerry",Hf="Samsung Internet",Cn="Chrome",qf="Chrome iOS",zf="Internet Explorer",Kf="Internet Explorer Mobile",Wf="Opera",Jf="Microsoft Edge",xn="Firefox",Yf="Firefox iOS",jn="Nintendo",Gn="PlayStation",lo="Xbox",Xf="Android Mobile",Qf="Mobile Safari",Fa="Windows",Zf="Windows Phone",vh="Nokia",yl="Ouya",HE="Generic "+di.toLowerCase(),eg="Generic "+Vn.toLowerCase(),bl="Konqueror",tg="Oculus Browser",sg="Vivaldi",ig="Yandex",rg="Whale",ng="DuckDuckGo",og="Pale Moon",ag="Waterfox",El="Brave",lg="Claude",ug="Codex",cg="ChatGPT",dg="Google Search App",Ma=new RegExp("Version/(\\d+(\\.\\d+)?)"),Ba=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),qE=new RegExp(lo,"i"),zE=new RegExp("PlayStation \\w+","i"),KE=new RegExp("Nintendo \\w+","i"),tu=new RegExp("BlackBerry|PlayBook|BB10","i"),WE={"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"},hg=function(t,e,s,i){e=e||"";var r=(function(n){return n!=null&&n.brave?El:null})(s);return r||(i!=null&&i.detectGoogleSearchApp&&M(t,"GSA/")?dg:M(t," OPR/")&&M(t,"Mini")?"Opera Mini":M(t," OPR/")?Wf:tu.test(t)?ao:M(t,"IEMobile")||M(t,"WPDesktop")?Kf:M(t,"OculusBrowser")?tg:M(t,"SamsungBrowser")?Hf:M(t,"Edge")||M(t,"Edg/")?Jf:M(t,"Vivaldi/")?sg:M(t,"YaBrowser/")?ig:M(t,"Whale/")?rg:M(t,"DuckDuckGo/")||M(t,"Ddg/")?ng:M(t,"Claude/")?lg:M(t,"Codex/")?ug:M(t,"ChatGPT/")?cg:M(t,"FBIOS")?"Facebook Mobile":M(t,"UCWEB")||M(t,"UCBrowser")?"UC Browser":M(t,"CriOS")?qf:M(t,"CrMo")||M(t,Cn)?Cn:M(t,hr)&&M(t,Pn)?Xf:M(t,"FxiOS")?Yf:M(t.toLowerCase(),bl.toLowerCase())?bl:M(t,"Brave/")?El:((n,o)=>o&&M(o,"Apple")||(function(a){return M(a,Pn)&&!M(a,Cn)&&!M(a,hr)})(n))(t,e)?M(t,di)?Qf:Pn:M(t,"PaleMoon/")?og:M(t,"Waterfox/")?ag:M(t,xn)?xn:M(t,"MSIE")||M(t,"Trident/")?zf:M(t,"Gecko")?xn:"")},JE={[Kf]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[Jf]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[Cn]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[qf]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[Pn]:[Ma],[Qf]:[Ma],[Wf]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[xn]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[Yf]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[bl]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[ao]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ma],[Xf]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[Hf]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[tg]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[sg]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[ig]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[rg]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[El]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[lg]:[Ba],[ug]:[Ba],[cg]:[Ba],[ng]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[og]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[ag]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[dg]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[zf]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},YE=function(t,e,s,i){var r=JE[hg(t,e,s,i)];if(S(r))return null;for(var n=0;r.length>n;n++){var o=t.match(r[n]);if(o)return parseFloat(o[o.length-2])}return null},_h=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[lo,t&&t[1]||""]],[new RegExp(jn,"i"),[jn,""]],[new RegExp(Gn,"i"),[Gn,""]],[tu,[ao,""]],[new RegExp(Fa,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[Zf,""];if(new RegExp(di).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];var s=/Windows NT ([0-9.]+)/i.exec(e);if(s&&s[1]){var i=WE[s[1]]||"";return/arm/i.test(e)&&(i="RT"),[Fa,i]}return[Fa,""]}],[/((iPhone|iPad|iPod).*?OS (\d+)_(\d+)_?(\d+)?|iPhone)/,t=>t&&t[3]?["iOS",[t[3],t[4],t[5]||"0"].join(".")]:["iOS",""]],[/(watch.*\/(\d+\.\d+\.\d+)|watch os,(\d+\.\d+),)/i,t=>{var e="";return t&&t.length>=3&&(e=S(t[2])?t[3]:t[2]),["watchOS",e]}],[new RegExp("(Android (\\d+)\\.(\\d+)\\.?(\\d+)?|Android)","i"),t=>t&&t[2]?[hr,[t[2],t[3],t[4]||"0"].join(".")]:[hr,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{var e=["Mac OS X",""];return t&&t[1]&&(e[1]=[t[1],t[2],t[3]||"0"].join(".")),e}],[/Mac/i,["Mac OS X",""]],[/CrOS/,["Chrome OS",""]],[/Linux|debian/i,["Linux",""]]],fg=function(t){for(var e=0;_h.length>e;e++){var s=_h[e],i=s[1],r=s[0].exec(t),n=r&&(qe(i)?i(r,t):i);if(n)return n}return["",""]},mh=function(t){return KE.test(t)?jn:zE.test(t)?Gn:qE.test(t)?lo:new RegExp(yl,"i").test(t)?yl:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?Zf:/iPad/.test(t)?jf:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?Gf:tu.test(t)?ao:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(vh,"i").test(t)?vh:/(kf[a-z]{2}wi|aeo[c-r]{2})( bui|\))/i.test(t)||/(kf[a-z]+)( bui|\)).+silk\//i.test(t)?"Kindle Fire":/(Android|ZTE)/i.test(t)?new RegExp(di).test(t)&&!/(9138B|TB782B|Nexus [97]|pixel c|HUAWEISHT|BTV|noble nook|smart ultra 6)/i.test(t)||/pixel[\daxl ]{1,6}/i.test(t)&&!/pixel c/i.test(t)||/(huaweimed-al00|tah-|APA|SM-G92|i980|zte|U304AA)/i.test(t)||/lmy47v/i.test(t)&&!/QTAQZ3/i.test(t)?hr:Vf:new RegExp("(pda|Mobile)","i").test(t)?HE:new RegExp(Vn,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?eg:""},Ua=/\bFBAV\/(\d+(?:\.\d+)*)/i,yh=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",Ua],[/\bFBAN\/EMA\b/i,"Facebook Lite",Ua],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",Ua],[/\bLinkedInApp(?:\]?\/(\d+(?:\.\d+)*))?\b/i,"LinkedIn"],[/\bTwitter(?:Android| for (?:iPhone|iPad|Android))(?:\/(\d+(?:\.\d+)*))?\b/i,"Twitter"],[/\b(?:musical_ly|trill)(?:[_/](\d+\.\d+(?:\.\d+)*))?(?=\b|_)/i,"TikTok",/\bapp_version\/(\d+(?:\.\d+)*)/i],[/\b(?:MicroMessenger|WeChat)\/(\d+(?:\.\d+)*)?/i,"WeChat"],[/\bLine\/(\d+(?:\.\d+)*)?/i,"Line"],[/\bGSA\/(\d+(?:\.\d+)*)?/i,"Google"],[/\[Pinterest\/(?:iOS|Android)\b|\bPinterest(?: for (?:Android(?: Tablet)?|iOS))?\/(\d+(?:\.\d+)*)/i,"Pinterest"],[/\b(?:WA4A|WAiOS)\/(\d+(?:\.\d+)*)?/i,"WhatsApp"],[/\bSnapchat[ /](\d+(?:\.\d+)*)?/i,"Snapchat"],[/\bBing(?:Web|Sapphire)\/(\d+(?:\.\d+)*)?/i,"Bing"],[/\bNAVER\(inapp; search;/i,"Naver",/\bNAVER\(inapp; search;[^;)]*; (\d+(?:\.\d+)*)/i],[/\bKAKAOTALK[ /](\d+\.\d+(?:\.\d+)*)?/i,"KakaoTalk"]],Sl="[Truncated]",uo="[Unserializable]";XE=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;ZE=class{constructor(t,e,s){s===void 0&&(s=[]),this.coercers=t,this.stackParser=e,this.modifiers=s}buildFromUnknown(t,e){e===void 0&&(e={});var s=e&&e.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(s,e,0).apply(t),r=this.buildParsingContext(e),n=this.parseStacktrace(i,r);return{$exception_list:this.convertToExceptionList(n,s),$exception_level:"error"}}modifyFrames(t){var e=this;return ge(function*(){for(var s of t)s.stacktrace&&s.stacktrace.frames&&F(s.stacktrace.frames)&&(s.stacktrace.frames=yield e.applyModifiers(s.stacktrace.frames));return t})()}coerceFallback(t){var e;return{type:"Error",value:"Unknown error",stack:(e=t.syntheticException)==null?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var s,i;return t.cause!=null&&(s=this.parseStacktrace(t.cause,e)),t.stack!=""&&t.stack!=null&&(i=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)),k({},t,{cause:s,stack:i})}applyChunkIds(t,e){return t.map(s=>(s.filename&&e&&(s.chunk_id=e[s.filename]),s))}applyCoercers(t,e){for(var s of this.coercers)if(s.match(t))return s.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return ge(function*(){var s=t;for(var i of e.modifiers)s=yield i(s);return s})()}convertToExceptionList(t,e){var s,i,r,n={type:t.type,value:t.value,mechanism:{type:(s=e.type)!==null&&s!==void 0?s:"generic",handled:(i=e.handled)===null||i===void 0||i,synthetic:(r=t.synthetic)!==null&&r!==void 0&&r}};t.stack&&(n.stacktrace={type:"raw",frames:t.stack});var o=[n];return t.cause!=null&&o.push(...this.convertToExceptionList(t.cause,k({},e,{handled:!0}))),o}buildParsingContext(t){var e;return{chunkIdMap:QE(this.stackParser),skipFirstLines:(e=t.skipFirstLines)!==null&&e!==void 0?e:1}}buildCoercingContext(t,e,s){s===void 0&&(s=0);var i=(r,n)=>{if(4>=n){var o=this.buildCoercingContext(t,e,n);return this.applyCoercers(r,o)}};return k({},e,{syntheticException:s==0?e.syntheticException:void 0,mechanism:t,apply:r=>i(r,s),next:r=>i(r,s+1)})}};vg=(t,e)=>{var s=t.indexOf("safari-extension")!==-1,i=t.indexOf("safari-web-extension")!==-1;return s||i?[t.indexOf("@")!==-1?t.split("@")[0]:"?",s?"safari-extension:"+e:"safari-web-extension:"+e]:[t,e]},eS=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,tS=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,sS=/\((\S*)(?::(\d+))(?::(\d+))\)/,iS=(t,e)=>{var s=eS.exec(t);if(s)return wl(e,s[1],"?",+s[2],+s[3]);var i=tS.exec(t);if(i){if(i[2]&&i[2].indexOf("eval")===0){var r=sS.exec(i[2]);r&&(i[2]=r[1],i[3]=r[2],i[4]=r[3])}var n=vg(i[1]||"?",i[2]);return wl(e,n[1],n[0],i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},rS=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,nS=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,oS=(t,e)=>{var s=rS.exec(t);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){var i=nS.exec(s[3]);i&&(s[1]=s[1]||"eval",s[3]=i[1],s[4]=i[2],s[5]="")}var r=s[3],n=s[1]||"?",o=vg(n,r);return wl(e,r=o[1],n=o[0],s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},wh=/\(error: (.*)\)/,aS=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){var s=Q(t.stack);return{type:this.getType(t),value:this.getValue(t),stack:s?t.stack:void 0,cause:t.cause?e.next(t.cause):void 0,synthetic:!1}}getType(t){return this.isDOMError(t)?"DOMError":"DOMException"}getValue(t){var e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?e+": "+t.message:e}isDOMException(t){return Un(t,"DOMException")}isDOMError(t){return Un(t,"DOMError")}},lS=class{match(t){return mr(t)}coerce(t,e){var s,i=this.getStack(t),r=i===void 0;return{type:this.getType(t),value:this.getMessage(t,e),stack:i??((s=e.syntheticException)==null?void 0:s.stack),cause:t.cause?e.next(t.cause):void 0,synthetic:r}}getType(t){return t.name||t.constructor.name}getMessage(t,e){var s=t.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(t){return t.stacktrace||t.stack||void 0}},uS=class{match(t){return!!Un(t,"ErrorEvent")&&(t.error!=null||this.an(t))}coerce(t,e){var s;if(t.error!=null)return e.apply(t.error);var i=e.apply(t.message);return k({},i,{stack:(s=this.sn(t))!==null&&s!==void 0?s:i.stack,synthetic:!0})}an(t){return Q(t.message)&&t.message.length>0}sn(t){var e,s,i=t,r=(e=i.lineno)!==null&&e!==void 0?e:0,n=(s=i.colno)!==null&&s!==void 0?s:0;if(Q(i.filename)&&i.filename.length!==0&&r!==0)return`Error
|
|
6
|
+
at `+i.filename+":"+r+":"+n}},cS=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,dS=class{match(t){return typeof t=="string"}coerce(t,e){var s,i=this.getInfos(t),r=i[0],n=i[1];return{type:r??"Error",value:n??t,stack:(s=e.syntheticException)==null?void 0:s.stack,synthetic:!0}}getInfos(t){var e="Error",s=t,i=t.match(cS);return i&&(e=i[1],s=i[2]),[e,s]}},hS=["fatal","error","warning","log","info","debug"];fS=class{match(t){return typeof t=="object"&&t!==null}coerce(t,e){var s,i,r=this.getErrorPropertyFromObject(t);return r?e.apply(r):{type:this.getType(t),value:this.getValue(t),stack:(s=this.getStack(t))!==null&&s!==void 0?s:(i=e.syntheticException)==null?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(eu(t))return t.constructor.name;var e="name"in t?t.name:void 0;return Q(e)&&!rr(e)?e:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){var e="'"+t.name+"' captured as exception";return"message"in t&&typeof t.message=="string"&&(e+=" with message: '"+t.message+"'"),e}if("message"in t&&typeof t.message=="string")return t.message;var s=this.getObjectClassName(t);return(s&&s!=="Object"?"'"+s+"'":"Object")+" captured as exception with keys: "+_g(t)}isSeverityLevel(t){return Q(t)&&!rr(t)&&hS.indexOf(t)>=0}getStack(t){try{return Q(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:Q(t.stack)&&t.stack.length>0?t.stack:void 0}catch{return}}getErrorPropertyFromObject(t){for(var e in t)if({}.hasOwnProperty.call(t,e)){var s=t[e];if(mr(s))return s}}getObjectClassName(t){try{var e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{return}}},gS=class{match(t){return eu(t)}coerce(t,e){var s,i=t.constructor.name;return{type:i,value:i+" captured as exception with keys: "+_g(t),stack:(s=e.syntheticException)==null?void 0:s.stack,synthetic:!0}}},pS=class{match(t){return Bf(t)}coerce(t,e){var s;return{type:"Error",value:"Primitive value captured as exception: "+String(t),stack:(s=e.syntheticException)==null?void 0:s.stack,synthetic:!0}}},vS=class{match(t){return Un(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!eu(t))return!1;try{var e=t.detail;return e!=null&&typeof e=="object"&&"reason"in e}catch{return!1}}coerce(t,e){var s,i=this.getUnhandledRejectionReason(t);return Bf(i)?{type:"UnhandledRejection",value:"Non-Error promise rejection captured with value: "+String(i),stack:(s=e.syntheticException)==null?void 0:s.stack,synthetic:!0}:e.apply(i)}getUnhandledRejectionReason(t){try{if("reason"in t)return t.reason;if("detail"in t&&t.detail!=null&&typeof t.detail=="object"&&"reason"in t.detail)return t.detail.reason}catch{}return t}},Hn="$message",qn="$timestamp",_S=new Set([Hn,qn]),ja={enabled:!0,max_bytes:32768};mS=class{constructor(t){this.Gn=[],this.Zn=0,this.Rn=zn(t)}setConfig(t){this.Rn=zn(t),this.Jn()}add(t){var e=(function(i){var r;try{r=$f(i)}catch{return}try{var n=JSON.parse(r);if(!Y(n))return;var o=n,a=o[Hn],l=o[qn];return!Q(a)||a.trim().length===0||!Q(l)&&!Re(l)?void 0:{step:o,json:r}}catch{return}})(t);if(e){var s=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;for(var r=encodeURIComponent(i),n=0,o=0;r.length>o;o++)r[o]==="%"?(n+=1,o+=2):n+=1;return n})(e.json);s>this.Rn.max_bytes||(this.Gn.push({step:e.step,bytes:s}),this.Zn+=s,this.Jn())}}getAttachable(){return this.Gn.map(t=>t.step)}clear(){this.Gn=[],this.Zn=0}size(){return this.Gn.length}Jn(){for(;this.Zn>this.Rn.max_bytes&&this.Gn.length>0;){var t=this.Gn.shift();t&&(this.Zn-=t.bytes)}}};kh=t=>{if(typeof t!="string")return t;try{return JSON.parse(t)}catch{return t}};bS=["$feature_flag","$feature_flag_response","$feature_flag_has_experiment","$feature_flag_id","$feature_flag_version","$feature_flag_reason","$feature_flag_request_id","$feature_flag_evaluated_at","$feature_flag_error","locally_evaluated","$groups","$process_person_profile","$geoip_disable","$current_url","$pathname","$referring_domain","utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid","gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],mg="NativeGzipValidationError",kl=t=>t.length>=2&&t[0]===31&&t[1]===139,Rh=(t,e)=>t===ml.GZipJS||e===ml.GZipJS||e==="gzip",Th=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError",yn=t=>{throw gg(mg,"Native gzip produced invalid output: "+t)},ES=(function(){var t=ge(function*(e,s){18>e.size&&yn("too-short");var i=new Uint8Array(yield e.slice(0,10).arrayBuffer());kl(i)&&i[2]===8||yn("invalid-header");var r=new DataView(yield e.slice(e.size-8).arrayBuffer());r.getUint32(0,!0)!==(o=>{for(var a=(()=>{if(Ki)return Ki;Ki=[];for(var c=0;256>c;c++){for(var h=c,g=0;8>g;g++)h=1&h?3988292384^h>>>1:h>>>1;Ki[c]=h>>>0}return Ki})(),l=4294967295,u=0;o.length>u;u++)l=a[255&(l^o[u])]^l>>>8;return(4294967295^l)>>>0})(s)&&yn("invalid-crc");var n=s.length>>>0;r.getUint32(4,!0)!==n&&yn("invalid-size")});return function(e,s){return t.apply(this,arguments)}})();SS={}.propertyIsEnumerable;Oh={darwin:"macOS",win32:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",sunos:"SunOS",aix:"AIX","Mac OS X":"macOS"},Eg={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}},kS=Eg.info;RS=class{constructor(t,e,s,i,r,n,o){var a;n===void 0&&(n=()=>Promise.resolve()),this._instance=t,this.Rn=e,this.A=s,this.Qn=i,this.Kn=r,this.Xn=n,this.Yn=o,this.ts=null,this.es=0,this.rs=0,this.ns=0,this.ss=0,this.ls=0,this.us=!1,this.hs=e.maxBufferSize,this.ds=Math.max((a=e.maxQueueSize)!==null&&a!==void 0?a:e.maxBufferSize,e.maxBufferSize),this.vs=e.flushIntervalMs,this.cs=e.maxBatchRecordsPerPost,this.fs=e.rateCapWindowMs,this.ps=e.maxLogsPerInterval}clearQueue(){this.rs++,this._instance.setPersistedProperty(Pt.LogsQueue,[])}reset(){this.gs(),this.ss=0,this.ls=0,this.us=!1,this.ns=0,this.cs=this.Rn.maxBatchRecordsPerPost}onReconnect(){this.ns=0,this.ys()}captureLog(t,e){var s;if(!this._instance.isDisabled&&!this._instance.optedOut&&t!=null&&t.body){var i=this.bs(t);if(i!==null)if(i.body){if(this._s()){var r={record:IS(i,(s=e?.context)!==null&&s!==void 0?s:this.Qn(),this.A,e?.occurredAtMs)};this.Kn(()=>this.ws(r))}}else this.A.info("Log was rejected in beforeSend function")}}bs(t){var e=this.Rn.beforeSend;if(!e)return t;var s=F(e)?e:[e],i=t;for(var r of s)try{var n=r(i);if(!n)return this.A.info("Log was rejected in beforeSend function"),null;i=n}catch(o){return this.A.error("Error in beforeSend function for log:",o),null}return i}_s(){if(this.ps===void 0)return!0;var t=Date.now(),e=t-this.ss;return this.fs>e&&e>=0||(this.ss=t,this.ls=0,this.us=!1),this.ps>this.ls?(this.ls++,!0):(this.us||(this.A.warn("captureLog dropping logs: exceeded "+this.ps+" logs per "+this.fs+"ms"),this.us=!0),!1)}flush(){var t=this;return ge(function*(){if(!t._instance.isDisabled)return t.ts||(t.ts=t.ks().finally(()=>{t.ts=null})),t.ts})()}ks(){var t=this;return ge(function*(){var e;t.gs();var s=(e=t._instance.getPersistedProperty(Pt.LogsQueue))!==null&&e!==void 0?e:[];if(s.length!==0)for(var i=s.length,r=0;s.length>0&&i>r;){var n,o,a=t.rs;t.es=0;var l=Math.min(s.length,t.cs),u=s.slice(0,l),c=wg(u.map(g=>g.record),t.Ss(),(n=t.Yn)!==null&&n!==void 0?n:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.xs(c);if(t.rs!==a)return;if(h.kind==="too-large"&&u.length>1)t.cs=Math.max(1,Math.floor(u.length/2)),t.A.warn("Received 413 when sending logs batch of size "+u.length+", reducing batch size to "+t.cs);else if(h.kind==="retry-later"||(h.kind==="too-large"?t.A.warn("Dropping a single log record after 413 with batch size 1 \u2014 the record is larger than the server cap and cannot be split further."):h.kind==="ok"&&t.Rn.maxBatchRecordsPerPost>t.cs&&(t.cs=Math.min(t.Rn.maxBatchRecordsPerPost,t.cs+1)),yield t.Cs(u.length),s=(o=t._instance.getPersistedProperty(Pt.LogsQueue))!==null&&o!==void 0?o:[],r+=u.length,h.kind==="fatal"))throw h.error}})()}Cs(t){var e=this;return ge(function*(){var s,i=Math.max(0,t-e.es),r=(s=e._instance.getPersistedProperty(Pt.LogsQueue))!==null&&s!==void 0?s:[];e._instance.setPersistedProperty(Pt.LogsQueue,r.slice(i)),yield e.Xn()})()}Ss(){return Sg(this.Rn,this._instance.getLibraryId(),this._instance.getLibraryVersion())}ws(t){var e;if(!this._instance.optedOut){var s=(e=this._instance.getPersistedProperty(Pt.LogsQueue))!==null&&e!==void 0?e:[];this.ds>s.length||(s.shift(),this.es++,this.A.info("Logs queue is full, dropping oldest record.")),s.push(t),this._instance.setPersistedProperty(Pt.LogsQueue,s),this.hs>s.length?this.Ts():this.ys()}}Ts(t){t===void 0&&(t=this.vs),this.Ms||(this.Ms=su(()=>{this.Ms=void 0,this.ys()},t))}Is(){var t=Math.min(Math.max(0,this.ns-1),6);return this.vs*Math.pow(2,t)}Es(){var t=this._instance.getPersistedProperty(Pt.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return ge(function*(){e.gs();var s=e.flush().catch(()=>{});t!==void 0?yield Sh(s,t):yield s})()}flushWithTimeout(t){var e=this;return ge(function*(){var s=e.flush();yield Sh(s,t,()=>{s.catch(()=>{})})})()}ys(){this.flush().then(()=>{this.ns=0},t=>{this.ns++,this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.Es()&&this.Ts(this.Is())})}gs(){this.Ms&&(clearTimeout(this.Ms),this.Ms=void 0)}},Ga=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];TS=class{constructor(t,e,s){this._instance=t,this.Rn=e,this.A=s,this.Rs=new Map,this.ts=null,this.As=!1,this.Ps=new Map,this.Fs=new Set,this.Os=0}count(t,e,s){e===void 0&&(e=1),this.$s({name:t,type:"count",value:e,unit:s?.unit,attributes:s?.attributes})}gauge(t,e,s){this.$s({name:t,type:"gauge",value:e,unit:s?.unit,attributes:s?.attributes})}histogram(t,e,s){this.$s({name:t,type:"histogram",value:e,unit:s?.unit,attributes:s?.attributes})}flush(){var t=this,e=this.ts,s=(function(){var i=ge(function*(){e&&(yield e.catch(()=>{})),yield t.Ds()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ts===s&&(this.ts=null)});return this.ts=s,s}drainWindow(){if(this.Rs.size===0)return null;var t=this.Rs;return this.Rs=new Map,this.As=!1,this.Ps=new Map,this.Fs=new Set,this.Ls(t)}reset(){this.Os++,this.gs(),this.Rs=new Map,this.ts=null,this.As=!1,this.Ps=new Map,this.Fs=new Set}$s(t){if(!this._instance.isDisabled&&!this._instance.optedOut){var e=this.bs(t);if(e!==null)if(e.name&&typeof e.name=="string")if(typeof e.value=="number"&&Number.isFinite(e.value))if(e.type==="count"&&0>e.value)this.A.warn("Dropping count '"+e.name+"': counters are monotonic, value must be >= 0");else{var s,i;try{s=e.attributes?k({},e.attributes):void 0,i=Ch(e.type,e.name,e.unit,s)}catch(o){return void this.A.warn("Dropping metric '"+e.name+"': attributes could not be serialized",o)}var r=this.Rs.get(i);if(!r){if(!this.Ns())return;r={name:e.name,type:e.type,unit:e.unit,attributes:s,windowStartMs:Date.now()},this.Rs.set(i,r)}var n=this.Ps.get(e.name);n===void 0?this.Ps.set(e.name,e.type):n===e.type||this.Fs.has(e.name)||(this.Fs.add(e.name),this.A.warn("Metric name '"+e.name+"' is already used as a "+n+"; recording it as a "+e.type+" too will blend both series in charts. Use a distinct name.")),this.qs(r,e.value),this.Ts()}else this.A.warn("Dropping metric '"+e.name+"': value must be a finite number");else this.A.warn("Dropping metric with empty name")}}Ns(){return this.Rn.maxSeriesPerFlush>this.Rs.size||(this.As||(this.As=!0,this.A.warn("Metric series cap reached ("+this.Rn.maxSeriesPerFlush+" per flush window); dropping new series until the next flush. Reduce attribute cardinality.")),!1)}qs(t,e){var s;switch(t.type){case"count":t.total=((s=t.total)!==null&&s!==void 0?s:0)+e;break;case"gauge":t.last=e;break;case"histogram":t.hist||(t.hist={count:0,sum:0,min:e,max:e,bucketCounts:new Array(Ga.length+1).fill(0)});var i=t.hist;i.count+=1,i.sum+=e,i.min=Math.min(i.min,e),i.max=Math.max(i.max,e),i.bucketCounts[(function(r,n){for(var o=0;n.length>o;o++)if(n[o]>=r)return o;return n.length})(e,Ga)]+=1}}bs(t){var e=this.Rn.beforeSend;if(!e)return t;var s=F(e)?e:[e],i=t;for(var r of s)try{var n=r(i);if(!n)return this.A.info("Metric was rejected in beforeSend function"),null;i=n}catch(o){return this.A.error("Error in beforeSend function for metric:",o),null}return i}Ts(){this.Ms||(this.Ms=su(()=>{this.Ms=void 0,this.flush().catch(t=>{this.A.error("Metrics flush failed:",t)})},this.Rn.flushIntervalMs))}gs(){this.Ms&&(clearTimeout(this.Ms),this.Ms=void 0)}Ds(){var t=this;return ge(function*(){if(t.Rs.size!==0){var e=t.Rs;t.Rs=new Map,t.As=!1,t.Ps=new Map,t.Fs=new Set;var s=t.Os,i=yield t._instance.js(t.Ls(e));if(s===t.Os)switch(i.kind){case"ok":return;case"retry-later":return t.Bs(e),void t.Ts();case"too-large":return void t.A.warn("Metrics batch exceeded the server size limit and was dropped");case"fatal":return void t.A.error("Failed to send metrics batch:",i.error)}}})()}Ls(t){return e=this.Hs(t),s=(function(n,o,a){return bg(n,o,a)})(this.Rn,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),r=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:Kn(s)},scopeMetrics:[{scope:{name:i,version:r},metrics:e}]}]};var e,s,i,r}Hs(t){var e=Ph(Date.now()),s=new Map;for(var i of t.values()){var r,n=Ch(i.type,i.name,i.unit,void 0),o=s.get(n);o||(o=k({name:i.name},i.unit&&{unit:i.unit}),i.type==="count"?o.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:i.type==="gauge"?o.gauge={dataPoints:[]}:o.histogram={aggregationTemporality:1,dataPoints:[]},s.set(n,o));var a=Kn((r=i.attributes)!==null&&r!==void 0?r:{},this.A),l=Ph(i.windowStartMs);if(i.type==="count"){var u,c={attributes:a,startTimeUnixNano:l,timeUnixNano:e,asDouble:(u=i.total)!==null&&u!==void 0?u:0};o.sum.dataPoints.push(c)}else if(i.type==="gauge"){var h,g={attributes:a,timeUnixNano:e,asDouble:(h=i.last)!==null&&h!==void 0?h:0};o.gauge.dataPoints.push(g)}else i.hist&&o.histogram.dataPoints.push({attributes:a,startTimeUnixNano:l,timeUnixNano:e,count:i.hist.count,sum:i.hist.sum,min:i.hist.min,max:i.hist.max,bucketCounts:i.hist.bucketCounts,explicitBounds:Ga})}return Array.from(s.values())}Bs(t){var e,s;for(var i of t){var r=i[0],n=i[1],o=this.Rs.get(r);if(o)switch(o.windowStartMs=Math.min(o.windowStartMs,n.windowStartMs),o.type){case"count":o.total=((e=o.total)!==null&&e!==void 0?e:0)+((s=n.total)!==null&&s!==void 0?s:0);break;case"gauge":break;case"histogram":if(n.hist)if(o.hist){o.hist.count+=n.hist.count,o.hist.sum+=n.hist.sum,o.hist.min=Math.min(o.hist.min,n.hist.min),o.hist.max=Math.max(o.hist.max,n.hist.max);for(var a=0;o.hist.bucketCounts.length>a;a++)o.hist.bucketCounts[a]+=n.hist.bucketCounts[a]}else o.hist=n.hist}else this.Ns()&&this.Rs.set(r,n)}}},kg=function(t,e){var s=(e===void 0?{}:e).debugEnabled,i={q(r){for(var n=arguments.length,o=new Array(n>1?n-1:0),a=1;n>a;a++)o[a-1]=arguments[a];b&&(Yt.DEBUG||b.POSTHOG_DEBUG||s)&&!S(b.console)&&b.console&&("__rrweb_original__"in b.console[r]?b.console[r].__rrweb_original__:b.console[r])(t,...o)},debug(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.q("debug",...n)},info(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.q("log",...n)},warn(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.q("warn",...n)},error(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];i.q("error",...n)},critical(){for(var r=arguments.length,n=new Array(r),o=0;r>o;o++)n[o]=arguments[o];console.error(t,...n)},uninitializedWarning(r){i.error("You must initialize PostHog before calling "+r)},createLogger:(r,n)=>kg(t+" "+r,n)};return i},I=kg("[PostHog.js]"),Te=I.createLogger,OS=Te("[ExternalScriptsLoader]"),Wn=t=>{var e=A?.querySelectorAll("script");if(e){for(var s=0;e.length>s;s++)if(e[s].src===t||e[s].getAttribute("src")===t)return e[s]}},Rs=(t,e,s)=>{if(t.config.disable_external_dependency_loading)return OS.warn(e+" was requested but loading of external scripts is disabled."),s("Loading of external scripts is disabled");var i=Wn(e);if(i){if(i.__posthog_loading_callback_fired)return s();var r=i.__posthog_loading_error;return r?s(r):(i.addEventListener("load",o=>{i.__posthog_loading_callback_fired=!0,s(void 0,o)}),void i.addEventListener("error",o=>{i.__posthog_loading_error=o,s(o)}))}var n=()=>{if(!A)return s("document not found");if(Wn(e))return Rs(t,e,s);var o=A.createElement("script");if(o.type="text/javascript",o.crossOrigin="anonymous",o.src=e,o.onload=u=>{o.__posthog_loading_callback_fired=!0,s(void 0,u)},o.onerror=u=>{o.__posthog_loading_error=u,s(u)},t.config.prepare_external_dependency_script&&(o=t.config.prepare_external_dependency_script(o)),!o)return s("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")A.head.appendChild(o);else{var a,l=A.querySelectorAll("body > script");l.length>0?(a=l[0].parentNode)==null||a.insertBefore(o,l[0]):A.body.appendChild(o)}};A!=null&&A.body?n():A?.addEventListener("DOMContentLoaded",n)},Ha={},xh=(t,e)=>{var s="/static/"+e+".js?v="+t.version;if(e==="toolbar"){var i=3e5;s=s+"&t="+Math.floor(Date.now()/i)*i}return t.requestRouter.endpointFor("assets",s)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(t,e,s)=>{if(e!=="remote-config"){var i=t.config.strict_script_versioning;if(i){var r=t.requestRouter.endpointFor("assets","/static/"+t.version+"/"+e+".js"),n=Ha[r];if(i==="fallback"&&n){if(Wn(n))return void Rs(t,n,s);delete Ha[r]}Rs(t,r,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l,u=xh(t,e);Ha[r]=u;var c=Wn(r);c==null||(l=c.parentNode)==null||l.removeChild(c),Rs(t,u,s)}else s(void 0,a)}:s)}else Rs(t,xh(t,e),s)}else Rs(t,t.requestRouter.endpointFor("assets","/array/"+t.config.token+"/config.js"),s)},L.__PosthogExtensions__.loadSiteApp=(t,e,s)=>{Rs(t,t.requestRouter.endpointFor("api",e),s)},Yt.DEBUG=!1,Yt.LIB_VERSION="1.428.7",Yt.LIB_NAME="web";Le=Yt,PS="$people_distinct_id",bt="distinct_id",ru="$device_id",qa="$device_model",Jn="__alias",CS="__cmpns",za="$fbc",Et="$fbc_persistence",Il="__timers",Rl="$autocapture_disabled_server_side",Tl="$heatmaps_enabled_server_side",Ol="$exception_capture_enabled_server_side",Ag="$error_tracking_suppression_rules",Pl="$error_tracking_capture_extension_exceptions",Cl="$web_vitals_enabled_server_side",nu="$dead_clicks_enabled_server_side",ou="$product_tours_enabled_server_side",xl="$logs_capture_enabled_server_side",Ig="$web_vitals_allowed_metrics",ui="$session_recording_remote_config",xS="$session_recording_enabled_server_side",Rg="$replay_sample_rate",Tg="$replay_override_sampling",Og="$replay_override_linked_flag",Pg="$replay_override_url_trigger",Cg="$replay_override_event_trigger",ni="$sesid",au="$session_is_sampled",DS="$session_past_minimum_duration",NS="$session_recording_url_trigger_activated_session",LS="$session_recording_event_trigger_activated_session",$S="$debug_first_full_snapshot_timestamp",FS="$sess_rec_flush_size",pt="$enabled_feature_flags",Ct="$active_feature_flags",Dl="$early_access_features",Ps="$feature_flag_details",as="$feature_flag_payloads",Cs="$feature_flag_request_id",nr="$minimal_flag_called_events",Ot="$override_feature_flags",Ts="$override_feature_flag_payloads",Wt="$stored_person_properties",ls="$stored_group_properties",xg="$groups",Nl="$surveys",Yn="$surveys_loaded_at",Ll="$surveys_activated",Dn="$surveys_activated_session",Nn="$surveys_activated_timestamps",Ln="ph_product_tours",MS="$product_tours_activated",BS="$product_tours_activated_session",US="$conversations_widget_session_id",VS="$conversations_ticket_id",jS="$conversations_widget_state",GS="$conversations_user_traits",us="$flag_call_reported",tr="$flag_call_reported_session_id",fr="$feature_flag_errors",cs="$feature_flag_evaluated_at",je="$user_state",$l="$client_session_props",Dg="$capture_rate_limit",Ng="$initial_campaign_params",Lg="$initial_referrer_info",oi="$initial_person_info",lu="$epp",Ka="$posthog_cookieless",$g="$cookieless_mode",Fg="$sdk_debug_extensions_init_method",Mg="$sdk_debug_extensions_init_time_ms",Fl="$sdk_debug_recording_script_not_loaded",HS="$sdk_debug_replay_event_trigger_status",qS="$sdk_debug_replay_linked_flag_trigger_status",zS="$sdk_debug_replay_matched_recording_trigger_groups",KS="$sdk_debug_replay_pending_trigger_conditions",WS="$sdk_debug_replay_remote_trigger_matching_config",JS="$sdk_debug_replay_trigger_groups_count",YS="$sdk_debug_replay_url_trigger_status",XS="$session_recording_start_reason",Ml="PostHog loadExternalDependency extension not found.",os="anonymous",sr="identified",Bg="identified_only",hi="visibilitychange",Xn="beforeunload",uu="$pageview",Dh="$pageleave",Bl="$identify",Nh="$groupidentify";fe=function(t){for(var e=arguments.length,s=new Array(e>1?e-1:0),i=1;e>i;i++)s[i-1]=arguments[i];for(var r of s)for(var n in r)r[n]!==void 0&&(t[n]=r[n]);return t};Lh=function(t){try{return t()}catch{return}},QS=function(t){return function(){try{for(var e=arguments.length,s=new Array(e),i=0;e>i;i++)s[i]=arguments[i];return t.apply(this,s)}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)}}},cu=function(t){var e={};return ie(t,function(s,i){(Q(s)&&s.length>0||Re(s))&&(e[i]=s)}),e};ZS=["herokuapp.com","vercel.app","netlify.app"];Vl=t=>{if(A){try{for(var e=t+"=",s=A.cookie.split(";").filter(n=>n.length),i=0;s.length>i;i++){for(var r=s[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}};Math.trunc||(Math.trunc=function(t){return 0>t?Math.ceil(t):Math.floor(t)}),Number.isInteger||(Number.isInteger=function(t){return Re(t)&&isFinite(t)&&Math.floor(t)===t});tw=class jl{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,s,i,r){if(!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(i)||!Number.isInteger(r)||0>e||0>s||0>i||0>r||e>0xffffffffffff||s>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/256,n[5]=e,n[6]=112|s>>>8,n[7]=s,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 jl(n)}toString(){for(var e="",s=0;this.bytes.length>s;s++)e=e+(this.bytes[s]>>>4).toString(16)+(15&this.bytes[s]).toString(16),s!==3&&s!==5&&s!==7&&s!==9||(e+="-");if(e.length!==36)throw new Error("Invalid UUIDv7 was generated");return e}clone(){return new jl(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(var s=0;16>s;s++){var i=this.bytes[s]-e.bytes[s];if(i!==0)return Math.sign(i)}return 0}},sw=class{generate(){var t=this.generateOrAbort();if(!S(t))return t;this.Ct=0;var e=this.generateOrAbort();if(S(e))throw new Error("Could not generate UUID after timestamp reset");return e}generateOrAbort(){var t,e=(t=Date.now(),Re(t)&&isFinite(t)?Math.min(Math.max(Math.floor(t),0),0xffffffffffff):0);if(e>this.Ct)this.Ct=e,this.Mt();else{if(this.Ct>=e+1e4)return;this.Tt++,this.Tt>4398046511103&&(this.Ct++,this.Mt())}return tw.fromFieldsV7(this.Ct,Math.trunc(this.Tt/Math.pow(2,30)),this.Tt&Math.pow(2,30)-1,this.It.nextUint32())}Mt(){this.Tt=1024*this.It.nextUint32()+(1023&this.It.nextUint32())}constructor(){this.Ct=0,this.Tt=0,this.It=new iw}},Vg=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(var e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};b&&!S(b.crypto)&&crypto.getRandomValues&&(Vg=t=>crypto.getRandomValues(t));iw=class{nextUint32(){return this.Rt.length>this.At||(Vg(this.Rt),this.At=0),this.Rt[this.At++]}constructor(){this.Rt=new Uint32Array(8),this.At=1/0}},St=()=>rw().toString(),rw=()=>($h||($h=new sw)).generate(),Wi="",nw=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Zs=null,be={Et(){if(!Ie(Zs))return Zs;if(Zs=!1,A)try{var t="__ph_cookie_support_"+St();be.Ot(t,"xyz"),Zs=Vl(t)==='"xyz"',be.Dt(t)}catch{Zs=!1}return Zs},Pt(t){I.error("cookieStore error: "+t)},Lt:Vl,Nt(t){var e;try{e=JSON.parse(be.Lt(t))||{}}catch{}return e},Ot(t,e,s,i,r){if(!A)return!1;try{var n="",o="",a=(function(c,h){if(h){var g=(function(p,_){if(_===void 0&&(_=A),Wi)return Wi;if(!_||["localhost","127.0.0.1"].includes(p))return"";for(var v=p.split("."),m=Math.min(v.length,8),y="dmn_chk_"+St();!Wi&&m--;){var w=v.slice(m).join("."),E=y+"=1;domain=."+w+";path=/";_.cookie=E+";max-age=3",_.cookie.includes(y)&&(_.cookie=E+";max-age=0",Wi=w)}return Wi})(c);if(!g){var f=(p=>{var _=p.match(nw);return _?_[0]:""})(c);f!==g&&I.info("Warning: cookie subdomain discovery mismatch",f,g),g=f}return g?"; domain=."+g:""}return""})(A.location.hostname,i);if(s){var l=new Date;l.setTime(l.getTime()+864e5*s),n="; expires="+l.toUTCString()}r&&(o="; secure");var u=t+"="+encodeURIComponent(JSON.stringify(e))+n+"; SameSite=Lax; path=/"+a+o;return u.length>3686.4&&I.warn("cookieStore warning: large cookie, len="+u.length),A.cookie=u,!0}catch{return!1}},Dt(t,e){if(A!=null&&A.cookie)try{be.Ot(t,"",-1,e)}catch{return}}},Wa=null,ee={Et(){if(!Ie(Wa))return Wa;var t=!0;if(S(b))t=!1;else try{var e="__mplssupport__";ee.Ot(e,"xyz"),ee.Lt(e)!=='"xyz"'&&(t=!1),ee.Dt(e)}catch{t=!1}return t||I.error("localStorage unsupported; falling back to cookie store"),Wa=t,t},Pt(t){I.error("localStorage error: "+t)},Lt(t){try{return b?.localStorage.getItem(t)}catch(e){ee.Pt(e)}return null},Nt(t){try{return JSON.parse(ee.Lt(t))||{}}catch{}return null},Ot(t,e){try{return b?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(s){ee.Pt(s)}return!1},Dt(t){try{b?.localStorage.removeItem(t)}catch(e){ee.Pt(e)}}},Ja=[Wt,Ct,pt,Ps,as,Cs,cs,fr,us],Os=[ru,bt,ni,au,lu,oi,Et,je],Qn=t=>t+"_cpm",ow=["__proto__","constructor","prototype"],Ya=t=>{if(!Y(t))return{};var e={};return Object.keys(t).forEach(s=>{ow.indexOf(s)===-1&&(e[s]=t[s])}),e},Xa=function(t,e){e===void 0&&(e=[]);var s={};return[...Os,...e].forEach(i=>{var r=t[i];S(r)||Ie(r)||r===""||(s[i]=r)}),s},jg=t=>{for(var e=5381,s=2166136261,i=0;t.length>i;i++){var r=t.charCodeAt(i);e=33*e^r,s=Math.imul(s^r,16777619)}return t.length.toString(36)+"."+(e>>>0).toString(36)+"."+(s>>>0).toString(36)},Fh=(t,e)=>({p:e,f:jg(JSON.stringify(t))}),Mh=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{var s=be.Nt(Qn(t)),i=s?.f===jg(e)&&F(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},Qa=(t,e)=>e+"|"+(be.Lt(Qn(t))||""),ei={},Gl={Et:()=>!0,Pt(t){I.error("memoryStorage error: "+t)},Lt:t=>t in ei?ei[t]:null,Nt:t=>t in ei?ei[t]:null,Ot:(t,e)=>(ei[t]=e,!0),Dt(t){delete ei[t]}},Ss=null,de={Et(){if(!Ie(Ss))return Ss;if(Ss=!0,S(b))Ss=!1;else try{var t="__support__";de.Ot(t,"xyz"),de.Lt(t)!=='"xyz"'&&(Ss=!1),de.Dt(t)}catch{Ss=!1}return Ss},Pt(t){I.error("sessionStorage error: ",t)},Lt(t){try{return b?.sessionStorage.getItem(t)}catch(e){de.Pt(e)}return null},Nt(t){try{return JSON.parse(de.Lt(t))||null}catch{}return null},Ot(t,e){try{return b?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(s){de.Pt(s)}return!1},Dt(t){try{b?.sessionStorage.removeItem(t)}catch(e){de.Pt(e)}}},aw=class{constructor(t){this._instance=t}get Rn(){return this._instance.config}get consent(){return this.vo()?0:this.co}isOptedOut(){return this.Rn.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Rn.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Rn.opt_out_capturing_by_default}optInOut(t){this.fo.Ot(this.po,t?1:0,this.Rn.cookie_expiration,this.Rn.cross_subdomain_cookie,this.Rn.secure_cookie)}reset(){this.fo.Dt(this.po,this.Rn.cross_subdomain_cookie)}get po(){var t=this._instance.config,e=t.token,s=t.opt_out_capturing_cookie_prefix;return t.consent_persistence_name||(s?s+e:"__ph_opt_in_out_"+e)}get co(){var t=this.fo.Lt(this.po);return $a(t)?1:M(jE,t)?0:-1}get fo(){var t=this.Rn.opt_out_capturing_persistence_type,e=t==="localStorage"?ee:be,s=e.Et()?e:Gl;if(!this.mo||this.mo!==s){this.mo=s;var i=t==="localStorage"?be:ee;i.Lt(this.po)&&(this.mo.Lt(this.po)||this.optInOut($a(i.Lt(this.po))),i.Dt(this.po,this.Rn.cross_subdomain_cookie))}return this.mo}vo(){return!!this.Rn.respect_dnt&&[Fe?.doNotTrack,Fe?.msDoNotTrack,L.doNotTrack,Fe?.globalPrivacyControl].some(t=>$a(t))}};fu=["a","button","form","input","select","textarea","label"];Za=[".ph-no-autocapture","[data-ph-no-autocapture]"],Kg=["next","previous","prev",">","<"],lw=[...Kg,"+","-","\u2212","\u2013"],Vh=(t,e)=>/[a-z0-9]/i.test(e)?t.includes(e):t===e,jh=[".ph-no-rageclick",".ph-no-capture"],uw=["","text","search","email","password","url","tel","number"];gu=t=>!t||Ge(t,"html")||!Dt(t),Jg=(t,e)=>{if(!b||gu(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var s=!1,i=[t],r=t;r.parentNode&&!Ge(r,"body");)if(du(r.parentNode))i.push(r.parentNode.host),r=r.parentNode.host;else{var n=zg(r);if(!n)break;if(e||fu.indexOf(n.tagName.toLowerCase())>-1)s=!0;else try{var o=b.getComputedStyle(n);o&&o.getPropertyValue("cursor")==="pointer"&&(s=!0)}catch{}i.push(n),r=n}return{parentIsUsefulElement:s,targetElementList:i}};Gh=new RegExp("^(?:(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}))$"),Hh=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,cw=[16,15,14,13],dw=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),qh=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),zh=/[0-9A-Za-z_]/;En=Te("[Dead Clicks]"),gw=()=>!0,pw=t=>{var e,s=!((e=t.instance.persistence)==null||!e.get_property(nu)),i=t.instance.config.capture_dead_clicks;return Xe(i)?i:!!Y(i)||s},Jh=class{get lazyLoadedDeadClicksAutocapture(){return this.yo}constructor(t,e,s){this.instance=t,this.isEnabled=e,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(t){if(t.ok){var e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[nu]:e.captureDeadClicks}),this.startIfEnabledOrStop())}}startIfEnabledOrStop(){this.isEnabled(this)?this.bo(()=>{this._o()}):this.stop()}bo(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.initDeadClicksAutocapture?t():(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this.instance,"dead-clicks-autocapture",i=>{i?En.error("failed to load script",i):t()})}_o(){var t;if(A){if(!this.yo&&(t=L.__PosthogExtensions__)!=null&&t.initDeadClicksAutocapture){var e=Y(this.instance.config.capture_dead_clicks)?k({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.yo=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.yo.start(A),En.info("starting...")}}else En.error("`document` not found. Cannot start.")}stop(){this.yo&&(this.yo.stop(),this.yo=void 0,En.info("stopping..."))}},Sn=Te("[SegmentIntegration]");Xg="posthog-js";vw=class{constructor(t,e,s,i,r,n){this.name=Xg,this.setupOnce=function(o){o(Qg(t,{organization:e,projectId:s,prefix:i,severityAllowList:r,sendExceptionsToPostHog:n==null||n}))}}},Xh=class{constructor(t){this.wo=(e,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(I.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.ko=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.So()}So(){var t;this.xo=(t=this._instance.sessionManager)==null?void 0:t.onSessionId(this.wo)}destroy(){var t;(t=this.xo)==null||t.call(this),this.xo=void 0}doPageView(t,e){var s,i=this.Co(t,e);return this.ko={pathname:(s=b?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:e,timestamp:t},this._instance.scrollManager.resetContext(),i}doPageLeave(t){var e;return this.Co(t,(e=this.ko)==null?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.ko)==null?void 0:t.pageViewId}}Co(t,e){var s=this.ko;if(!s)return{$pageview_id:e};var i={$pageview_id:e,$prev_pageview_id:s.pageViewId},r=this._instance.scrollManager.getContext();if(r&&!this._instance.config.disable_scroll_properties){var n=r.maxScrollHeight,o=r.lastScrollY,a=r.maxScrollY,l=r.maxContentHeight,u=r.lastContentY,c=r.maxContentY;if(!(S(n)||S(o)||S(a)||S(l)||S(u)||S(c))){n=Math.ceil(n),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),u=Math.ceil(u),c=Math.ceil(c);var h=n>1?xt(o/n,0,1,I):1,g=n>1?xt(a/n,0,1,I):1,f=l>1?xt(u/l,0,1,I):1,p=l>1?xt(c/l,0,1,I):1;i=fe(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:g,$prev_pageview_last_content:u,$prev_pageview_last_content_percentage:f,$prev_pageview_max_content:c,$prev_pageview_max_content_percentage:p})}}return s.pathname&&(i.$prev_pageview_pathname=s.pathname),s.timestamp&&(i.$prev_pageview_duration=(t.getTime()-s.timestamp.getTime())/1e3),i}},Ji=["flags","surveys"],_w={[PS]:{exposure:"hidden"},[Jn]:{exposure:"hidden"},[CS]:{exposure:"hidden"},[Il]:{exposure:"hidden"},[Et]:{exposure:"hidden"},[Rl]:{exposure:"event"},[Tl]:{exposure:"hidden"},[xl]:{exposure:"hidden"},[Ol]:{exposure:"event"},[Ag]:{exposure:"hidden"},[Pl]:{exposure:"event"},[Cl]:{exposure:"event"},[nu]:{exposure:"event"},[ou]:{exposure:"hidden"},[Ig]:{exposure:"event"},[ui]:{exposure:"hidden"},[xS]:{exposure:"hidden"},[ni]:{exposure:"hidden"},[au]:{exposure:"event"},[Rg]:{exposure:"event",shouldSkipFromEventProperties:t=>Ie(t)},[DS]:{exposure:"event"},[NS]:{exposure:"event"},[LS]:{exposure:"event"},[$S]:{exposure:"event"},[FS]:{exposure:"hidden"},[pt]:{exposure:"hidden",storageGroup:"flags"},[Ct]:{exposure:"hidden",storageGroup:"flags"},[Dl]:{exposure:"hidden"},[Ps]:{exposure:"hidden",storageGroup:"flags"},[as]:{exposure:"hidden",storageGroup:"flags"},[Cs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[nr]:{exposure:"hidden",storageGroup:"flags"},[Ot]:{exposure:"hidden"},[Ts]:{exposure:"hidden"},[Wt]:{exposure:"hidden"},[ls]:{exposure:"hidden"},[Nl]:{exposure:"hidden",storageGroup:"surveys"},[Yn]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[Ll]:{exposure:"event"},[Dn]:{exposure:"hidden"},[Nn]:{exposure:"hidden"},[Ln]:{exposure:"hidden"},[MS]:{exposure:"hidden"},[BS]:{exposure:"hidden"},[US]:{exposure:"event"},[VS]:{exposure:"event"},[jS]:{exposure:"event"},[GS]:{exposure:"event"},[us]:{exposure:"hidden"},[tr]:{exposure:"hidden"},[xg]:{exposure:"event"},[fr]:{exposure:"hidden"},[cs]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[je]:{exposure:"hidden"},[$l]:{exposure:"hidden"},[Dg]:{exposure:"hidden"},[Ng]:{exposure:"hidden"},[Lg]:{exposure:"hidden"},[oi]:{exposure:"hidden"},[lu]:{exposure:"hidden"},[Tg]:{exposure:"event"},[Og]:{exposure:"event"},[Pg]:{exposure:"event"},[Cg]:{exposure:"event"},[Fg]:{exposure:"event"},[Mg]:{exposure:"event"},[Fl]:{exposure:"event"},[HS]:{exposure:"event"},[qS]:{exposure:"event"},[zS]:{exposure:"event"},[KS]:{exposure:"event"},[WS]:{exposure:"event"},[JS]:{exposure:"event"},[YS]:{exposure:"event"},[XS]:{exposure:"event"}},mw=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Be=t=>{var e=_w[t];if(e)return e;for(var s of mw){var i=s[1];if(t.indexOf(s[0])===0)return i}},ai=(t,e)=>{try{var s;return JSON.stringify(t,(i,r)=>mr(r)?(s!=null||(s=new WeakMap),s.has(r)||s.set(r,Ug(r)),s.get(r)):typeof r=="bigint"?r.toString():r,e)}catch{return $f(t)}},gi=t=>{var e=A?.createElement("a");return S(e)?null:(e.href=t,e)},pi=function(t,e){for(var s,i=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),r=0;i.length>r;r++){var n=i[r].split("=");if(n[0]===e){s=n;break}}if(!F(s)||2>s.length)return"";var o=s[1];try{o=decodeURIComponent(o)}catch{I.error("Skipping decoding for malformed query param: "+o)}return o.replace(/\+/g," ")},vr=function(t,e,s){if(!t||!e||!e.length)return t;for(var i=t.split("#"),r=i[1],n=(i[0]||"").split("?"),o=n[1],a=n[0],l=(o||"").split("&"),u=[],c=0;l.length>c;c++){var h=l[c].split("=");F(h)&&(e.includes(h[0])?u.push(h[0]+"="+s):u.push(l[c]))}var g=a;return o!=null&&(g+="?"+u.join("&")),r!=null&&(g+="#"+r),g},Zn=function(t,e){var s=t.match(new RegExp(e+"=([^&]*)"));return s?s[1]:null},Zg=(t,e)=>t>=e&&Lf(),ep=(t,e,s,i)=>{if(t===0){if(Lf()){var r=e+1;return r===s&&i(),r}return e}return 0},vi=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","irclid","_kx"],yw=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",...vi],_r="<masked>",bw=["li_fat_id"];eo="$direct";Sw={flags:cs,surveys:Yn},ww=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],wn=t=>t+"_cookie_identity_change_pending",kn=t=>{var e="",s=0;for(var i of t){var r=encodeURIComponent(JSON.stringify(i).slice(1,-1)).length;if(s+r>1e3)break;e+=i,s+=r}return e},Ne="main",Kt=[pt,Ct,Ps,as,Cs,cs,nr,Wt],el=t=>Kt.indexOf(t)!==-1,is=(t,e)=>{try{return JSON.stringify(t)===JSON.stringify(e)}catch{return t===e}},ti=t=>{if(!t)return{};var e=JSON.parse(t);return Y(e)?e:{}},Zh=(t,e)=>{ie(t,(s,i)=>{var r=Be(i);r&&r.exposure!=="event"||{}.hasOwnProperty.call(e,i)||delete t[i]})},tl=class{constructor(t,e,s){if(s===void 0&&(s=!0),this.To={},this.Mo=!1,this.Io=!1,this.Eo=!1,this.Ro=!1,this.Ao=!1,this.Po=new Map,this.Fo=!1,this.Oo=!1,this.$o=!1,this.Do=!1,this.Lo=new Set,this.Rn=t,this.No=s,this.props={},this.qo=void 0,this.jo=(r=>{var n="";return r.token&&(n=r.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),r.persistence_name?"ph_"+r.persistence_name:"ph_"+n+"_posthog"})(t),this.fo=this.Bo(t),this.Eo=this.Ho(t),this.load(),this.zo(),t.debug&&I.info("Persistence loaded",t.persistence,k({},this.props)),this.update_config(t,t,e),this.save(),b){var i=()=>this.flush();ae(b,"beforeunload",i,{capture:!1}),ae(b,"pagehide",i,{capture:!1}),this.Uo=r=>{if(this.Mo&&(!r.storageArea||r.storageArea===b?.localStorage)&&r.key)if(r.key!==this.jo){if(this.Eo){var n=Ji.find(o=>r.key===this.Wo(o));n&&this.Vo(r.key,n)}}else this.Vo(r.key,Ne)},ae(b,"storage",this.Uo)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(e=>{var s=e[0],i=e[1],r=this.Po.get(s);if(el(s)&&r!==!0)if(i!==!0){var n=new Set(r||[]);i.forEach(o=>n.add(o)),n.size&&this.Go(s,n)}else this.Go(s,!0)})}onCrossTabFeatureFlagChange(t){return this.Lo.add(t),()=>this.Lo.delete(t)}destroy(){this.Uo&&b&&(b.removeEventListener("storage",this.Uo),this.Uo=void 0),this.Lo.clear()}Vo(t,e,s){if(s===void 0&&(s=!0),this.gi)return!1;var i,r;try{if(r=ee.Lt(t),Ie(r)){var n=this.Zo(e);return n.storageValue=null,e!==Ne&&(n.persisted=!1),!1}i=ti(r)}catch{return!1}var o=e===Ne?i:ee.Nt(this.jo);if(o&&this.Jo(o))return!1;var a=this.Qo(i,e,s);return e===Ne&&this.Eo&&!is(this.Ko().main,i)||this.Xo(i,e,!0,r),a}Jo(t){var e=this.props[bt],s=t[bt];return!S(e)&&!S(s)&&e!==s}Xo(t,e,s,i){var r=this.Zo(e);r.storageValue=i,e!==Ne&&(r.persisted=s);try{r.fingerprint=this.Yo(t,e)}catch{r.fingerprint=void 0}}Qo(t,e,s){var i=!1;return Kt.forEach(r=>{var n,o=(n=Be(r))==null?void 0:n.storageGroup;if(!(e===Ne&&this.Eo&&o||e!==Ne&&o!==e)){var a=r in t,l=this.ta(r,a?t[r]:void 0),u=this.Po.has(r)?r in this.props:a;u===r in this.props&&is(l,this.props[r])||(u?this.ea(r,l,!1):this.ia(r,!1),i=!0)}}),i&&s&&this.Lo.forEach(r=>r()),i}ra(){if(!this.Mo)return!1;try{this.$o=!1;var t,e=ee.Lt(this.jo),s=this.Zo(Ne),i=!1,r=!1;if(e!==s.storageValue)if(Ie(e))s.storageValue=null;else{if(t=ti(e),this.$o=!this.Oo&&this.Jo(t),this.$o)return!1;r=this.Qo(t,Ne,!1),!this.Eo||is(this.Ko().main,t)?this.Xo(t,Ne,!0,e):s.storageValue=e,i=!0}return this.Eo&&Ji.forEach(n=>{var o=ee.Lt(this.Wo(n)),a=this.Zo(n),l=t||{},u=i&&Kt.some(h=>{var g;return((g=Be(h))==null?void 0:g.storageGroup)===n&&h in l});if(o!==a.storageValue||u){if(Ie(o))return a.storageValue=null,a.persisted=!1,void(u&&(r=this.Qo(l,n,!1)||r));var c=ti(o);r=this.Qo(c,n,!1)||r,this.Xo(c,n,!0,o)}}),r}catch{return!1}}Go(t,e){this.Po.set(t,e);var s=Be(t);s!=null&&s.volatile||(this.Zo((this.Eo?s?.storageGroup:void 0)||Ne).fingerprint=void 0,this.na(t))}sa(){Kt.forEach(t=>this.Po.set(t,!0))}zo(){if(this.Mo)try{var t=ee.Lt(this.jo),e=ti(t);this.Zo(Ne).storageValue=t,Kt.forEach(s=>{var i,r=this.Eo?(i=Be(s))==null?void 0:i.storageGroup:void 0,n=r?ee.Lt(this.Wo(r)):null;if(r){var o=this.Zo(r);o.storageValue=n,o.persisted=!Ie(n)}var a=r&&!Ie(n)?ti(n):e;s in this.props?this.oa(s,a[s],this.props[s]):s in a&&this.Go(s,!0)})}catch{}}ta(t,e){var s=this.Po.get(t);if(!s)return e;if(s===!0)return this.props[t];if(t==="$active_feature_flags"){var i=new Set(F(e)?e:[]),r=new Set(F(this.props[t])?this.props[t]:[]);return s.forEach(a=>r.has(a)?i.add(a):i.delete(a)),Array.from(i)}var n=Y(e)?k({},e):{},o=Y(this.props[t])?this.props[t]:{};return s.forEach(a=>{a in o?n[a]=o[a]:delete n[a]}),n}oa(t,e,s){if(el(t)){var i=this.Po.get(t);if(i!==!0){var r=e;if(this.Mo)try{var n,o=this.Eo?(n=Be(t))==null?void 0:n.storageGroup:void 0,a=o?this.Wo(o):this.jo;r=ti(ee.Lt(a))[t]}catch{}var l=new Set(i||[]);if(t==="$active_feature_flags"){if(!S(e)&&!F(e)||!S(r)&&!F(r)||!F(s))return void this.Go(t,!0);var u=new Set(e||[]),c=new Set(r||[]),h=new Set(s);new Set([...u,...h]).forEach(p=>{u.has(p)!==h.has(p)&&l.add(p)}),l.forEach(p=>{c.has(p)===h.has(p)&&l.delete(p)})}else{if(!Y(s))return void(is(r,s)?this.Po.delete(t):this.Go(t,!0));if(!S(e)&&!Y(e)||S(e)&&nt(s)&&S(r))return void this.Go(t,!0);var g=Y(e)?e:{},f=Y(r)?r:{};new Set([...Object.keys(g),...Object.keys(s)]).forEach(p=>{p in g==p in s&&is(g[p],s[p])||l.add(p)}),l.forEach(p=>{p in f==p in s&&is(f[p],s[p])&&l.delete(p)})}l.size?this.Go(t,l):this.Po.delete(t)}}}aa(){var t,e=(t=this.Rn)==null?void 0:t.persistence_save_debounce_ms;return Re(e)&&e>0?e:0}la(t){if(this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie")if(t)try{var e=Xa(t,this.Rn.cookie_persisted_properties||[]),s=Fh(e,this.Rn.cookie_persisted_properties||[]),i=JSON.stringify(e)+"|"+JSON.stringify(s),r=be.Lt(this.jo)||void 0;r&&Qa(this.jo,r)===i&&(this.ua=i,this.ha=r)}catch{}else try{var n=be.Lt(this.jo)||void 0;this.ua=n?Qa(this.jo,n):void 0,this.ha=n}catch{}}syncCookieProperties(){return this.da(this.Rn)}da(t,e){if(e===void 0&&(e=!1),this.gi&&!e||this.Ao||!t.cookieWinsOnConflict||t.persistence.toLowerCase()!=="localstorage+cookie")return!1;var s;try{s=be.Lt(this.jo)||void 0}catch{}if(!s||s===this.ha)return!1;var i,r=Qa(this.jo,s);try{i=Ya(JSON.parse(s))}catch{return!1}if((be.Lt(this.jo)||void 0)!==s)return!1;this.ua=r,this.ha=s;var n=Mh(this.jo,s),o=[...Os,...n.properties],a={};if(Object.keys(i).forEach(_=>{var v=i[_];(S(v)||Ie(v)||v===""||_==="$user_state"&&v!=="anonymous"&&v!=="identified")&&(a[_]=!0,delete i[_])}),nt(i))return!1;var l="distinct_id"in i||i.$user_state==="anonymous"||i.$user_state==="identified",u=this.props,c=u[bt],h=u[je],g=fe({},u);[...Os,...t.cookie_persisted_properties||[]].forEach(_=>{if(o.indexOf(_)!==-1&&!(_ in i)&&!a[_]&&(l||_!=="distinct_id"&&_!=="$user_state")){var v=g[_];(n.isValid||Os.indexOf(_)===-1||v!==!1&&v!==0)&&delete g[_]}}),this.props=fe(g,i),Kt.forEach(_=>{var v=_ in this.props;_ in u===v&&is(u[_],this.props[_])||(v?this.oa(_,u[_],this.props[_]):this.Go(_,!0))}),!l||"$user_state"in i||"$user_state"in this.props||this.ea(je,os);var f=this.props[bt],p=this.props[je];return!l||f===c&&p===h||(this.Oo=!0,this.Ro=!0,de.Ot(wn(this.jo),!0),this.ia(Wt),this.ia(Ct),this.ia(pt),this.ia(Ps),this.ia(as),this.ia(Cs),this.ia(cs),this.ia(fr),this.ia(us),p!=="anonymous"||h!=="identified"&&i.$user_state!=="anonymous"&&(S(c)||f===c)||(Zh(this.props,i),this.ia(ls)),p==="identified"?this.props.$user_id=f:delete this.props.$user_id,this.ia(Jn)),!0}consumeCookieIdentityChange(){var t=wn(this.jo),e=this.Ro||!!de.Lt(t);return this.Ro=!1,e&&de.Dt(t),e}va(t){return t===void 0&&(t=!1),!(this.Ao||this.gi&&!t||!this.Rn.cookieWinsOnConflict||this.Rn.persistence.toLowerCase()!=="localstorage+cookie"||(this.Ao=!0,0))}ca(){this.Ao&&(S(this.fa)||(clearTimeout(this.fa),this.fa=void 0),delete this.To[Ne],this.pa(!0))}ga(t){if(t===void 0&&(t=!0),this.Ao)try{t?this.ca():S(this.fa)||(clearTimeout(this.fa),this.fa=void 0)}finally{this.Ao=!1}}isDisabled(){return!!this.gi}Bo(t){ww.indexOf(t.persistence.toLowerCase())===-1&&(I.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");var e,s=(function(o,a){o===void 0&&(o=[]),a===void 0&&(a=!1);var l=[...Os,...o];return k({},ee,{Nt(u){try{var c,h={};try{c=be.Lt(u)||void 0,h=c?Ya(JSON.parse(c)):{}}catch{}var g,f=JSON.parse(ee.Lt(u)||"{}");if(a){var p=Mh(u,c),_=[...Os,...p.properties],v={};Object.keys(h).forEach(T=>{var C=h[T];Ie(C)||C===""||T==="$user_state"&&C!=="anonymous"&&C!=="identified"||(v[T]=C)});var m="distinct_id"in v||v.$user_state==="anonymous"||v.$user_state==="identified";if(Object.keys(v).length>0){var y,w=f[bt],E=(y=f.$user_state)!==null&&y!==void 0?y:"anonymous";l.forEach(T=>{if(_.indexOf(T)!==-1&&!(T in h)&&(m||T!=="distinct_id"&&T!=="$user_state")){var C=f[T];(p.isValid||Os.indexOf(T)===-1||C!==!1&&C!==0)&&delete f[T]}}),!m||"$user_state"in h||"$user_state"in f||(f[je]=os),!m||("distinct_id"in v?v[bt]:f[bt])===w&&("$user_state"in v?v[je]:f[je])===E||(Ja.forEach(T=>delete f[T]),v.$user_state==="identified"&&"distinct_id"in v?f.$user_id=v[bt]:delete f.$user_id,v.$user_state!=="identified"&&(delete f[xg],delete f[ls]),delete f.__alias)}g=fe(f,v)}else g=fe(h,f);return ee.Ot(u,g),g}catch{}return null},Ot(u,c,h,g,f,p){var _=ee.Ot(u,c,void 0,void 0,p);try{var v=Xa(c,o);if(Object.keys(v).length){if(a){var m=Qn(u),y=Fh(v,o);if(be.Ot(m,y,h,g,f,p),be.Lt(m)!==JSON.stringify(y)){be.Dt(m,g);var w=Xa(c);return be.Ot(u,w,h,g,f,p),_}}be.Ot(u,v,h,g,f,p)}}catch(E){ee.Pt(E)}return _},Dt(u,c){try{b?.localStorage.removeItem(u),be.Dt(u,c),be.Dt(Qn(u),c)}catch(h){ee.Pt(h)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict),i=!1,r=!1,n=t.persistence.toLowerCase();return n==="localstorage"&&ee.Et()?(e=ee,r=!0):n==="localstorage+cookie"&&s.Et()?(e=s,r=!0,i=!0):n==="sessionstorage"&&de.Et()?e=de:n==="memory"?e=Gl:n==="cookie"&&be.Et()?(e=be,i=!0):s.Et()?(e=s,r=!0,i=!0):be.Et()?(e=be,i=!0):e=Gl,this.Mo=r,this.Io=i,e}Wo(t){return this.jo+"__"+t}Ho(t){return this.Mo&&!!t.split_storage}properties(){var t={};return ie(this.props,(e,s)=>{var i=Be(s);if(!i||i.exposure==="event"){if(i!=null&&i.shouldSkipFromEventProperties!=null&&i.shouldSkipFromEventProperties(e))return;t[s]=e}}),t}load(t){if(t===void 0&&(t=!1),!this.gi||t){var e=this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie",s=e?ee.Nt(this.jo):null,i={};if(e)try{ie(i=Ya(be.Nt(this.jo)),(f,p)=>{(S(f)||Ie(f)||f==="")&&delete i[p]})}catch{}var r=this.fo.Nt(this.jo);if(r&&(this.props=fe({},r)),this.Eo&&this.ma(),e&&r){var n,o,a=s?.[bt],l=(n=s?.$user_state)!==null&&n!==void 0?n:"anonymous",u=r[bt],c=(o=r.$user_state)!==null&&o!==void 0?o:"anonymous";if(u!==a||c!==l){this.Ro=!0,de.Ot(wn(this.jo),!0);var h=fe({},this.props);Ja.forEach(f=>delete h[f]),c!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(S(a)||u===a)||(Zh(h,i),delete h[ls]),this.props=h;var g=new Set;Ja.forEach(f=>{var p,_=(p=Be(f))==null?void 0:p.storageGroup;_&&g.add(_)}),g.forEach(f=>{var p={};ie(this.props,(_,v)=>{var m;((m=Be(v))==null?void 0:m.storageGroup)===f&&(p[v]=_)}),nt(p)?(ee.Dt(this.Wo(f)),this.To[f]={}):ee.Ot(this.Wo(f),p)&&(this.To[f]={persisted:!0,fingerprint:this.Yo(p,f)})})}}de.Lt(wn(this.jo))&&(this.Ro=!0)}}ma(){for(var t of Ji){var e=ee.Nt(this.Wo(t));if(e&&!nt(e)){var s=this.Zo(t);s.persisted=!0,this.ya(t)||(s.fingerprint=this.Yo(e,t)),this.ba(t,e)||fe(this.props,e)}}}ya(t){return Object.keys(this.props).some(e=>{var s;return((s=Be(e))==null?void 0:s.storageGroup)===t})}ba(t,e){var s=Sw[t];if(!s)return!1;var i=e[s],r=this.props[s];return Re(i)&&Re(r)&&r>i}refreshKey(t){var e;if(!(this.gi||t==="$fbc_persistence"&&this.Do)){var s=this.Eo?(e=Be(t))==null?void 0:e.storageGroup:void 0,i=s?ee.Nt(this.Wo(s)):this.fo.Nt(this.jo);if(i&&t in i)this.ea(t,i[t],!1);else{if(s){var r=this.fo.Nt(this.jo);if(r&&t in r)return void this.ea(t,r[t],!1)}this.ia(t,!1)}}}save(){if(!this.gi){var t=this.aa();t>0?S(this.fa)&&(this.fa=setTimeout(()=>{this.fa=void 0,this.pa()},t)):this.pa()}}flush(){S(this.fa)||(clearTimeout(this.fa),this.fa=void 0,this.pa())}pa(t){if(t===void 0&&(t=!1),!(this.gi||this.Ao&&!t)){t||(this.syncCookieProperties(),this.Do||this.Rn.cookieWinsOnConflict&&this.Rn.persistence.toLowerCase()==="localstorage+cookie"||this.refreshKey(Et));var e=!t&&!this.Fo;e||(this.$o=!1);var s=!!e&&this.ra();if(this.$o)this.Rn.debug&&I.warn("skipping persistence write because storage belongs to a different distinct ID");else{if(this.Eo)return this._a(),void(s&&this.Lo.forEach(r=>r()));var i=this.wa(this.fo,this.jo,this.props,Ne);i==="written"&&this.la(this.props),i!=="failed"&&(this.Po.clear(),this.Oo=!1,this.Do=!1),s&&this.Lo.forEach(r=>r())}}}_a(){var t=this,e=this.Ko(),s=e.main,i=e.groups,r=this.wa(this.fo,this.jo,s,Ne);r==="written"&&this.la(s),r!=="failed"&&(this.Oo=!1,this.Do=!1,Kt.forEach(a=>{var l;(l=Be(a))!=null&&l.storageGroup||this.Po.delete(a)}));var n=function(a){var l,u=i[a];if(nt(u)&&((l=t.To[a])==null||!l.persisted))return Kt.forEach(h=>{var g;((g=Be(h))==null?void 0:g.storageGroup)===a&&t.Po.delete(h)}),1;var c=t.wa(ee,t.Wo(a),u,a);c!=="failed"&&Kt.forEach(h=>{var g=Be(h);g?.storageGroup!==a||c!=="written"&&g.volatile||t.Po.delete(h)})};for(var o of Ji)n(o)}Ko(){var t={},e={flags:{},surveys:{}};return ie(this.props,(s,i)=>{var r,n=(r=Be(i))==null?void 0:r.storageGroup;n?e[n][i]=s:t[i]=s}),{main:t,groups:e}}Yo(t,e){if(e===Ne)return JSON.stringify(t)+"|"+this.ka+"|"+this.Sa+"|"+this.xa;var s={};return ie(t,(i,r)=>{var n;s[r]=(n=Be(r))!=null&&n.volatile?"__volatile__":i}),JSON.stringify(s)}wa(t,e,s,i){var r,n=this.Zo(i);if(i!==Ne&&!n.dirty&&!S(n.fingerprint))return"skipped";try{if((r=this.Yo(s,i))===n.fingerprint)return n.dirty=!1,"skipped"}catch{r=void 0}return t.Ot(e,s,this.ka,this.Sa,this.xa,this.Rn.debug)?(n.dirty=!1,i!==Ne&&(n.persisted=!0),S(r)||(n.fingerprint=r),this.Mo&&(n.storageValue=ee.Lt(e)),"written"):(this.Rn.debug&&I.warn('failed to persist storage entry "'+e+'"; will retry on next save'),"failed")}remove(t){var e=(t===void 0?{}:t).keepGroupEntries,s=e!==void 0&&e;if(this.sa(),S(this.fa)||(clearTimeout(this.fa),this.fa=void 0),this.fo.Dt(this.jo,!1),this.fo.Dt(this.jo,!0),!s&&this.No)for(var i of Ji)ee.Dt(this.Wo(i));s?delete this.To[Ne]:this.To={},this.ua=void 0,this.ha=void 0}clear(){this.remove(),this.props={}}register_once(t,e,s){if(Y(t)){this.syncCookieProperties(),S(e)&&(e="None"),this.ka=S(s)?this.Ca:s;var i=!1;if(ie(t,(r,n)=>{this.props.hasOwnProperty(n)&&this.props[n]!==e||(this.ea(n,r),i=!0)}),i)return this.save(),!0}return!1}register(t,e){if(Y(t)){this.syncCookieProperties(),this.ka=S(e)?this.Ca:e;var s=!1;if(ie(t,(i,r)=>{t.hasOwnProperty(r)&&(this.props[r]!==i||Y(i)||F(i))&&(this.ea(r,i),s=!0)}),s)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();var e=typeof t=="string"?[t]:t,s=!1;for(var i of e)i in this.props&&(this.ia(i),s=!0);s&&this.save()}update_campaign_params(){var t=A?.URL;if(t!==this.qo){var e=tp(this.Rn.custom_campaign_params,this.Rn.mask_personal_data_properties,this.Rn.custom_personal_data_properties),s=!nt(cu(e));return s&&this.register(e),this.qo=t,s?e:void 0}}update_search_keyword(){var t;this.register((t=A?.referrer)?ip(t):{})}update_referrer_info(){var t;this.register_once({$referrer:rp(),$referring_domain:A!=null&&A.referrer&&((t=gi(A.referrer))==null?void 0:t.host)||eo},void 0)}set_initial_person_info(){if(!this.props.$initial_campaign_params&&!this.props.$initial_referrer_info){var t=np(this.Rn.mask_personal_data_properties,this.Rn.custom_personal_data_properties,this.Rn.disable_capture_url_hashes);this.register_once({[oi]:this.Io?{r:kn(t.r),u:t.u?kn(t.u):void 0}:t},void 0)}}get_initial_props(){var t={};ie([Lg,Ng],s=>{var i=this.props[s];i&&ie(i,function(r,n){t["$initial_"+_l(n)]=r})});var e=this.props[oi];return e&&fe(t,(function(s,i){i===void 0&&(i=!1);var r=op(s,i),n={};return ie(r,function(o,a){n["$initial_"+_l(a)]=o}),n})(e,this.Rn.disable_capture_url_hashes)),t}safe_merge(t){return ie(this.props,function(e,s){s in t||(t[s]=e)}),t}update_config(t,e,s){var i=t.persistence!==e.persistence,r=!((p,_)=>{if(p.length!==_.length)return!1;var v=[...p].sort(),m=[..._].sort();return v.every((y,w)=>y===m[w])})(t.cookie_persisted_properties||[],e.cookie_persisted_properties||[]),n=i||r,o=t.cookieWinsOnConflict!==e.cookieWinsOnConflict,a=t.disable_persistence||!!s,l=!!this.gi&&!a;a||this.da(e,l),this.Rn=t,!a&&(i||r||o)&&(this.ua=void 0,this.ha=void 0,this.da(k({},t,{cookie_persisted_properties:e.cookie_persisted_properties}),l));var u=n||o?this.Bo(t):this.fo;this.Ta();var c=this.Ho(t),h=n||c!==this.Eo,g=!a&&(h||t.cross_subdomain_cookie!==this.Sa||t.secure_cookie!==this.xa)&&this.va(l);this.Fo=h;try{if(this.Ca=this.ka=t.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),h){var f=this.props;this.clear(),this.fo=u,this.Eo=c,this.props=f,this.save()}else o&&(this.fo=u,a||(delete this.To[Ne],this.pa()))}finally{this.Fo=!1,g&&this.ga()}}Ta(){var t=this.props[oi];if(this.Io&&Y(t)&&typeof t.r=="string"){var e=kn(t.r),s=typeof t.u=="string"?kn(t.u):t.u;e===t.r&&s===t.u||this.ea(oi,k({},t,{r:e,u:s}))}}set_disabled(t){this.gi=t,this.gi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Sa&&(this.Sa=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.xa&&(this.xa=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){var s=this.props.__timers||{};s[t]=e,this.ea(Il,s),this.save()}remove_event_timer(t){var e=this.props.__timers||{},s=e[t];return S(s)||(delete e[t],this.ea(Il,e),this.save()),s}get_property(t){return this.props[t]}set_property(t,e){this.ea(t,e),this.save()}ea(t,e,s){var i;s===void 0&&(s=!0);var r=this.props[t];this.props[t]=e,s&&(t!=="distinct_id"&&t!=="$user_state"||r===e||(this.Oo=!0),t!=="$fbc_persistence"||is(r,e)||(this.Do=!0),this.oa(t,r,e),(i=Be(t))!=null&&i.volatile||this.na(t))}ia(t,e){e===void 0&&(e=!0),delete this.props[t],e&&(el(t)&&this.Go(t,!0),t==="$fbc_persistence"&&(this.Do=!0),this.na(t))}na(t){var e,s=(e=Be(t))==null?void 0:e.storageGroup;s&&(this.Zo(s).dirty=!0)}Zo(t){return this.To[t]||(this.To[t]={})}},lt={GZipJS:"gzip-js",Base64:"base64"},Yi={Activation:"events",Cancellation:"cancelEvents"},sl={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},Jt={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},il={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",SURVEY_LANGUAGE:"$survey_language"},zl={Popover:"popover",Inline:"inline"};kw={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"},ef={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"},tf=Te("[RateLimiter]"),Aw=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{var s=e.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(i=>{tf.info((i||"events")+" is quota limited."),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void tf.warn('could not rate limit - continuing. Error: "'+i?.message+'"',{text:s})}},this.instance=t,this.lastEventRateLimited=this.clientRateLimitContext(!0).isRateLimited}get captureEventsPerSecond(){var t;return((t=this.instance.config.rate_limiting)==null?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)==null?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t){var e,s,i;t===void 0&&(t=!1);var r=this.captureEventsBurstLimit,n=this.captureEventsPerSecond,o=new Date().getTime(),a=(e=(s=this.instance.persistence)==null?void 0:s.get_property("$capture_rate_limit"))!==null&&e!==void 0?e:{tokens:r,last:o};a.tokens+=(o-a.last)/1e3*n,a.last=o,a.tokens>r&&(a.tokens=r);var l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){var u=(Re(a.dropped)?a.dropped:0)+1;a.dropped=u,!this.lastEventRateLimited&&this.Ma(u)&&(a.dropped=0)}return this.lastEventRateLimited=l,(i=this.instance.persistence)==null||i.set_property(Dg,a),{isRateLimited:l,remainingTokens:a.tokens}}Ia(t){var e=this.instance.config.property_denylist;return!F(e)||!e.includes(t)}Ea(){var t;if(this.Ia("$current_url")&&this.Ia("$pathname")&&Ee!=null&&Ee.pathname)return""+((t=Ee.origin)!==null&&t!==void 0?t:"")+Ee.pathname}Ma(t){var e,s,i=this.captureEventsBurstLimit,r=this.captureEventsPerSecond,n=this.Ea(),o=this.Ia("$session_id")?(e=(s=this.instance).get_session_id)==null?void 0:e.call(s):void 0,a=[t+" event(s) dropped since the last warning",n?"triggered on "+n:void 0,o?"session "+o:void 0].filter(Boolean).join(", ");return!!this.instance.capture("$$client_ingestion_warning",{$$client_ingestion_warning_message:"posthog-js client rate limited: "+a+". Config is set to "+r+" events per second and "+i+" events burst limit."},{skip_client_rate_limiting:!0})}isServerRateLimited(t){var e=this.serverLimits[t||"events"]||!1;return e!==!1&&new Date().getTime()<e}},rs=Te("[RemoteConfig]"),lp=class{constructor(t){this._instance=t}get remoteConfig(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.config}Ra(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.loadExternalDependency?(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"remote-config",()=>t(this.remoteConfig)):t()}Aa(t){this._instance._send_request({method:"GET",url:this._instance.requestRouter.endpointFor("assets","/array/"+this._instance.config.token+"/config"),callback:t})}load(){try{if(this.remoteConfig)return rs.info("Using preloaded remote config",this.remoteConfig),void this.Pa(this.remoteConfig);if(this._instance.Fa())return void rs.warn("Remote config is disabled. Falling back to local config.");this.Ra(t=>{if(!t)return rs.info("No config found after loading remote JS config. Falling back to JSON."),void this.Aa(e=>{this.Pa(e.json,e)});this.Pa(t)})}catch(t){rs.error("Error loading remote config",t),this.Pa()}}Pa(t,e){!t&&e&&(e.statusCode===0?e.error||rs.warn("Failed to fetch remote config from PostHog."):rs.error("Failed to fetch remote config from PostHog."));try{this._instance.Pa(t?{ok:!0,config:t}:{ok:!1})}catch(i){rs.error("Error applying remote config",i)}if(t?.hasFeatureFlags!==!1&&!this._instance.config.advanced_disable_feature_flags_on_first_load)try{var s;(s=this._instance.featureFlags)==null||s.ensureFlagsLoaded()}catch(i){rs.error("Error loading feature flags",i)}}},ut=Uint8Array,Qe=Uint16Array,_i=Uint32Array,pu=new ut([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]),vu=new ut([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]),sf=new ut([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),up=function(t,e){for(var s=new Qe(31),i=0;31>i;++i)s[i]=e+=1<<t[i-1];var r=new _i(s[30]);for(i=1;30>i;++i)for(var n=s[i];s[i+1]>n;++n)r[n]=n-s[i]<<5|i;return[s,r]},cp=up(pu,2),Kl=cp[1];cp[0][28]=258,Kl[258]=28;for(Wl=up(vu,0)[1],to=new Qe(32768),_e=0;32768>_e;++_e)ws=(43690&_e)>>>1|(21845&_e)<<1,to[_e]=((65280&(ws=(61680&(ws=(52428&ws)>>>2|(13107&ws)<<2))>>>4|(3855&ws)<<4))>>>8|(255&ws)<<8)>>>1;lr=function(t,e,s){for(var i=t.length,r=0,n=new Qe(e);i>r;++r)++n[t[r]-1];var o,a=new Qe(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(s){o=new Qe(1<<e);var l=15-e;for(r=0;i>r;++r)if(t[r])for(var u=r<<4|t[r],c=e-t[r],h=a[t[r]-1]++<<c,g=h|(1<<c)-1;g>=h;++h)o[to[h]>>>l]=u}else for(o=new Qe(i),r=0;i>r;++r)o[r]=to[a[t[r]-1]++]>>>15-t[r];return o},xs=new ut(288);for(_e=0;144>_e;++_e)xs[_e]=8;for(_e=144;256>_e;++_e)xs[_e]=9;for(_e=256;280>_e;++_e)xs[_e]=7;for(_e=280;288>_e;++_e)xs[_e]=8;so=new ut(32);for(_e=0;32>_e;++_e)so[_e]=5;Iw=lr(xs,9,0),Rw=lr(so,5,0),dp=function(t){return(t/8|0)+(7&t&&1)},hp=function(t,e,s){(e==null||0>e)&&(e=0),(s==null||s>t.length)&&(s=t.length);var i=new(t instanceof Qe?Qe:t instanceof _i?_i:ut)(s-e);return i.set(t.subarray(e,s)),i},Ht=function(t,e,s){var i=e/8|0;t[i]|=s<<=7&e,t[i+1]|=s>>>8},Xi=function(t,e,s){var i=e/8|0;t[i]|=s<<=7&e,t[i+1]|=s>>>8,t[i+2]|=s>>>16},rl=function(t,e){for(var s=[],i=0;t.length>i;++i)t[i]&&s.push({s:i,f:t[i]});var r=s.length,n=s.slice();if(!r)return[new ut(0),0];if(r==1){var o=new ut(s[0].s+1);return o[s[0].s]=1,[o,1]}s.sort(function(T,C){return T.f-C.f}),s.push({s:-1,f:25001});var a=s[0],l=s[1],u=0,c=1,h=2;for(s[0]={s:-1,f:a.f+l.f,l:a,r:l};c!=r-1;)a=s[s[h].f>s[u].f?u++:h++],l=s[u!=c&&s[h].f>s[u].f?u++:h++],s[c++]={s:-1,f:a.f+l.f,l:a,r:l};var g=n[0].s;for(i=1;r>i;++i)n[i].s>g&&(g=n[i].s);var f=new Qe(g+1),p=Jl(s[c-1],f,0);if(p>e){i=0;var _=0,v=p-e,m=1<<v;for(n.sort(function(T,C){return f[C.s]-f[T.s]||T.f-C.f});r>i;++i){var y=n[i].s;if(e>=f[y])break;_+=m-(1<<p-f[y]),f[y]=e}for(_>>>=v;_>0;){var w=n[i].s;e>f[w]?_-=1<<e-f[w]++-1:++i}for(;i>=0&&_;--i){var E=n[i].s;f[E]==e&&(--f[E],++_)}p=e}return[new ut(f),p]},Jl=function(t,e,s){return t.s==-1?Math.max(Jl(t.l,e,s+1),Jl(t.r,e,s+1)):e[t.s]=s},rf=function(t){for(var e=t.length;e&&!t[--e];);for(var s=new Qe(++e),i=0,r=t[0],n=1,o=function(l){s[i++]=l},a=1;e>=a;++a)if(t[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=t[a]}return[s.subarray(0,i),e]},Qi=function(t,e){for(var s=0,i=0;e.length>i;++i)s+=t[i]*e[i];return s},Fn=function(t,e,s){var i=s.length,r=dp(e+2);t[r]=255&i,t[r+1]=i>>>8,t[r+2]=255^t[r],t[r+3]=255^t[r+1];for(var n=0;i>n;++n)t[r+n+4]=s[n];return 8*(r+4+i)},nf=function(t,e,s,i,r,n,o,a,l,u,c){Ht(e,c++,s),++r[256];for(var h=rl(r,15),g=h[0],f=h[1],p=rl(n,15),_=p[0],v=p[1],m=rf(g),y=m[0],w=m[1],E=rf(_),T=E[0],C=E[1],q=new Qe(19),x=0;y.length>x;++x)q[31&y[x]]++;for(x=0;T.length>x;++x)q[31&T[x]]++;for(var le=rl(q,7),D=le[0],P=le[1],G=19;G>4&&!D[sf[G-1]];--G);var N,U,ue,Oe,he=u+5<<3,oe=Qi(r,xs)+Qi(n,so)+o,O=Qi(r,g)+Qi(n,_)+o+14+3*G+Qi(q,D)+(2*q[16]+3*q[17]+7*q[18]);if(oe>=he&&O>=he)return Fn(e,c,t.subarray(l,l+u));if(Ht(e,c,1+(oe>O)),c+=2,oe>O){N=lr(g,f,0),U=g,ue=lr(_,v,0),Oe=_;var B=lr(D,P,0);for(Ht(e,c,w-257),Ht(e,c+5,C-1),Ht(e,c+10,G-4),c+=14,x=0;G>x;++x)Ht(e,c+3*x,D[sf[x]]);c+=3*G;for(var V=[y,T],K=0;2>K;++K){var J=V[K];for(x=0;J.length>x;++x)Ht(e,c,B[W=31&J[x]]),c+=D[W],W>15&&(Ht(e,c,J[x]>>>5&127),c+=J[x]>>>12)}}else N=Iw,U=xs,ue=Rw,Oe=so;for(x=0;a>x;++x)if(i[x]>255){var W;Xi(e,c,N[257+(W=i[x]>>>18&31)]),c+=U[W+257],W>7&&(Ht(e,c,i[x]>>>23&31),c+=pu[W]);var Z=31&i[x];Xi(e,c,ue[Z]),c+=Oe[Z],Z>3&&(Xi(e,c,i[x]>>>5&8191),c+=vu[Z])}else Xi(e,c,N[i[x]]),c+=U[i[x]];return Xi(e,c,N[256]),c+U[256]},Tw=new _i([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),Ow=new ut(0),Pw=(function(){for(var t=new _i(256),e=0;256>e;++e){for(var s=e,i=9;--i;)s=(1&s&&3988292384)^s>>>1;t[e]=s}return t})(),nl=function(t,e,s){for(;s;++e)t[e]=s,s>>>=8};xw=!!Zl||!!dr,fp="text/plain",Mn=!1,gp=(t,e)=>{var s=t.split("#"),i=s[1],r=s[0].split("?"),n=r[0],o=r[1];if(!o)return t;var a=o.split("&").filter(l=>l.split("=")[0]!==e).join("&");return n+(a?"?"+a:"")+(i?"#"+i:"")},yr=function(t,e,s){var i;s===void 0&&(s=!0);var r=t.split("?"),n=r[0],o=r[1],a=k({},e),l=(i=o?.split("&").map(c=>{var h,g=c.split("="),f=g[0],p=s&&(h=a[f])!==null&&h!==void 0?h:g[1];return delete a[f],f+"="+p}))!==null&&i!==void 0?i:[],u=(function(c,h){var g,f;h===void 0&&(h="&");var p=[];return ie(c,function(_,v){S(_)||S(v)||v==="undefined"||(g=encodeURIComponent((m=>m instanceof File)(_)?_.name:_.toString()),f=encodeURIComponent(v),p[p.length]=f+"="+g)}),p.join(h)})(a);return u&&l.push(u),l.length>0?n+"?"+l.join("&"):n},ol=t=>{if(t.Oa)return t.Oa;var e=t.data,s=t.compression;if(e){if(s===lt.GZipJS){var i=Cw((function(o){var a=o.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(o);for(var l=new ut(o.length+(o.length>>>1)),u=0,c=function(p){l[u++]=p},h=0;a>h;++h){if(u+5>l.length){var g=new ut(u+8+(a-h<<1));g.set(l),l=g}var f=o.charCodeAt(h);128>f?c(f):2048>f?(c(192|f>>>6),c(128|63&f)):f>55295&&57344>f?(c(240|(f=65536+(1047552&f)|1023&o.charCodeAt(++h))>>>18),c(128|f>>>12&63),c(128|f>>>6&63),c(128|63&f)):(c(224|f>>>12),c(128|f>>>6&63),c(128|63&f))}return hp(l,0,u)})(ai(e)),{mtime:0});return{contentType:fp,body:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength),estimatedSize:i.byteLength}}if(s===lt.Base64){var r=(o=>"data="+encodeURIComponent(typeof o=="string"?o:ai(o)))((function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(ai(e)));return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}var n=ai(e);return{contentType:"application/json",body:n,estimatedSize:new Blob([n]).size}}},pp=t=>{var e,s,i=()=>t.transport==="sendBeacon"?{url:yr(t.url,{compression:lt.Base64}),encodedBody:ol(k({},t,{compression:lt.Base64,Oa:void 0}))}:{url:gp(t.url,"compression"),encodedBody:ol(k({},t,{compression:void 0,Oa:void 0}))};try{e=ol(t)}catch(r){if(Rh(t.compression,pi(t.url,"compression")))return I.error("Failed to gzip request body, sending uncompressed payload",r),i();throw r}return e&&Rh(t.compression,pi(t.url,"compression"))&&!((s=e.body)instanceof ArrayBuffer?kl(new Uint8Array(s)):ArrayBuffer.isView(s)&&kl(new Uint8Array(s.buffer,s.byteOffset,s.byteLength)))?(Mn=!0,i()):{url:t.url,encodedBody:e}},vp=t=>{try{return pp(t)}catch(e){return I.error(e),void(t.callback==null||t.callback({statusCode:0,error:e}))}},Dw=(function(){var t=ge(function*(e){var s=yield(function(r,n,o){return Al.apply(this,arguments)})(ai(e.data),Le.DEBUG,{rethrow:!0});if(!s)return e;var i=yield s.arrayBuffer();return k({},e,{Oa:{contentType:fp,body:i,estimatedSize:i.byteLength}})});return function(e){return t.apply(this,arguments)}})(),Nw=/Failed to fetch|NetworkError|Load failed/i,_p=t=>t?.name==="TypeError"&&Nw.test(t?.message||""),mp=t=>{var e=vp(t);if(e){var s=new Zl,i=e.encodedBody;s.open(t.method||"GET",e.url,!0);var r=i??{},n=r.contentType,o=r.body;ie(t.headers,function(a,l){s.setRequestHeader(l,a)}),n&&s.setRequestHeader("Content-Type",n),t.timeout&&(s.timeout=t.timeout),s.onreadystatechange=()=>{if(s.readyState===4){var a={statusCode:s.status,text:s.responseText};if(s.status===200)try{a.json=JSON.parse(s.responseText)}catch{}t.callback==null||t.callback(a)}},s.send(o)}},yp=t=>{var e=vp(t);if(e){var s=e.url,i=e.encodedBody,r=i??{},n=r.contentType,o=r.body,a=r.estimatedSize,l=new Headers;ie(t.headers,function(p,_){l.append(_,p)}),n&&l.append("Content-Type",n);var u=null,c=!1;if(fh){var h=new fh;u={signal:h.signal,timeout:setTimeout(()=>{var p;c=!0,h.abort(gg("AbortError","PostHog request timed out"+((p=t.timeout)?" after "+p+"ms":"")))},t.timeout)}}var g=p=>{c&&p?.name==="AbortError"||_p(p)?I.warn(p):I.error(p),t.callback==null||t.callback({statusCode:0,error:p})};try{var f;dr(s,k({method:t?.method||"GET",headers:l,keepalive:t.method==="POST"&&!t.$a&&52428.8>(a||0),body:o,signal:(f=u)==null?void 0:f.signal},t.fetchOptions)).then(p=>p.text().then(_=>{var v={statusCode:p.status,text:_};if(p.status===200)try{v.json=JSON.parse(_)}catch(m){I.error(m)}t.callback==null||t.callback(v)})).catch(g).finally(()=>u?clearTimeout(u.timeout):null)}catch(p){u&&clearTimeout(u.timeout),g(p)}}},Yl=t=>{try{var e,s=pp(t),i=s.url,r=s.encodedBody,n=r??{},o=n.body,a=n.estimatedSize;if(!o)return;var l=o instanceof Blob?o:new Blob([o],{type:n.contentType});if(Fe.sendBeacon(i,l))return;var u=F(t.data)?t.data:(e=t.data)==null?void 0:e.batch;if(F(u)&&u.length>1&&(a??0)>16384){var c=Math.ceil(u.length/2),h=g=>F(t.data)?g:k({},t.data,{batch:g});return Yl(k({},t,{data:h(u.slice(0,c))})),void Yl(k({},t,{data:h(u.slice(c))}))}I.warn("Beacon of ~"+(a??0)+" bytes was rejected by the browser, falling back to "+(dr?"fetch":"XHR")),dr?yp(k({},t,{$a:!0})):mp(t)}catch(g){I.warn("Beacon send failed",g)}},of=(t,e,s,i)=>{var r=i==="query"?e==="POST"?"sent_at":"_":void 0;return yr(s===lt.GZipJS?gp(t,"compression"):t,k({},r?{[r]:Date.now().toString()}:{},s===lt.GZipJS?{}:{compression:s}))},Bn=[];dr&&Bn.push({transport:"fetch",method:yp}),Zl&&Bn.push({transport:"XHR",method:mp}),Fe!=null&&Fe.sendBeacon&&Bn.push({transport:"sendBeacon",method:Yl});Lw=class{constructor(t,e){this.Da=!0,this.La=[],this.Na=xt(e?.flush_interval_ms||3e3,250,5e3,I.createLogger("flush interval"),3e3),this.qa=t}enqueue(t){this.La.push(t),this.ja||this.Ba()}unload(){this.Ha();var t=this.La.length>0?this.za():{},e=Object.values(t);[...e.filter(s=>s.url.indexOf("/e")===0),...e.filter(s=>s.url.indexOf("/e")!==0)].map(s=>{this.Ua(k({},s,{transport:"sendBeacon"}))})}enable(){this.Da=!1,this.Ba()}Ba(){var t=this;this.Da||(this.ja=setTimeout(()=>{if(this.Ha(),this.La.length>0){var e=this.za(),s=function(){var r=e[i],n=new Date().getTime();r.data&&F(r.data)&&ie(r.data,o=>{o.offset=Math.abs(o.timestamp-n),delete o.timestamp}),t.Ua(r)};for(var i in e)s()}},this.Na))}Ua(t){try{this.qa(t)}catch(e){I.error(e)}}Ha(){clearTimeout(this.ja),this.ja=void 0}za(){var t={};return ie(this.La,e=>{var s,i=e,r=(i?i.batchKey:null)||i.url;S(t[r])&&(t[r]=k({},i,{data:[]})),(s=t[r].data)==null||s.push(i.data)}),this.La=[],t}},$w=class{constructor(t){this._instance=t,this.Wa=!1,this.Va=3e3,this.La=[],this.La=[],this.Ga=!0,this.resume()}resume(){if(!S(b)&&"onLine"in b.navigator){if(this.Ga=b.navigator.onLine,this.Za)return;this.Za=()=>{this.Ga=!0,this.Ja()},this.Qa=()=>{this.Ga=!1},ae(b,"online",this.Za),ae(b,"offline",this.Qa)}}get length(){return this.La.length}retriableRequest(t){var e=t.retriesPerformedSoFar,s=Nf(t,DE);zt(e)&&(s.url=yr(s.url,{retry_count:e})),this._instance._send_request(k({},s,{callback:i=>{if(i.statusCode!==200&&(400>i.statusCode||i.statusCode>=500)){if((i.statusCode===0?3:10)>(e??0))return void this.ws(k({retriesPerformedSoFar:e},s));i.statusCode===0&&I.warn("Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after "+(e??0)+" retries.")}s.callback==null||s.callback(i)}}))}ws(t){var e=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=e+1;var s=(function(n){var o=3e3*Math.pow(2,n),a=o/2,l=Math.min(18e5,o),u=(Math.random()-.5)*(l-a);return Math.ceil(l+u)})(e),i=Date.now()+s;this.La.push({retryAt:i,requestOptions:t});var r="Enqueued failed request for retry in "+s;navigator.onLine||(r+=" (Browser is offline)"),I.warn(r),this.Wa||(this.Wa=!0,this.Ka())}Ka(){if(this.Xa&&clearTimeout(this.Xa),this.La.length===0)return this.Wa=!1,void(this.Xa=void 0);this.Xa=setTimeout(()=>{this.Ga&&this.La.length>0&&this.Ja(),this.Ka()},this.Va)}Ja(){var t=Date.now(),e=[],s=this.La.filter(r=>t>r.retryAt||(e.push(r),!1));if(this.La=e,s.length>0)for(var i of s)this.retriableRequest(i.requestOptions)}unload(){for(var t of(this.Xa&&(clearTimeout(this.Xa),this.Xa=void 0),this.Wa=!1,S(b)||(this.Za&&(b.removeEventListener("online",this.Za),this.Za=void 0),this.Qa&&(b.removeEventListener("offline",this.Qa),this.Qa=void 0)),this.La)){var e=t.requestOptions;try{this._instance._send_request(k({},e,{transport:"sendBeacon"}))}catch(s){I.error(s)}}this.La=[]}},Fw=class{constructor(t){this._instance=t,this.Ya=()=>{var e,s,i,r;this.tl||(this.tl={});var n=this.scrollElement(),o=this.scrollY(),a=n?Math.max(0,n.scrollHeight-n.clientHeight):0,l=o+(n?.clientHeight||0),u=n?.scrollHeight||0;this.tl.lastScrollY=Math.ceil(o),this.tl.maxScrollY=Math.max(o,(e=this.tl.maxScrollY)!==null&&e!==void 0?e:0),this.tl.maxScrollHeight=Math.max(a,(s=this.tl.maxScrollHeight)!==null&&s!==void 0?s:0),this.tl.lastContentY=l,this.tl.maxContentY=Math.max(l,(i=this.tl.maxContentY)!==null&&i!==void 0?i:0),this.tl.maxContentHeight=Math.max(u,(r=this.tl.maxContentHeight)!==null&&r!==void 0?r:0)}}get el(){return this._instance.config.scroll_root_selector}getContext(){return this.tl}resetContext(){var t=this.tl;return setTimeout(this.Ya,0),t}startMeasuringScrollPosition(){ae(b,"scroll",this.Ya,{capture:!0}),ae(b,"scrollend",this.Ya,{capture:!0}),ae(b,"resize",this.Ya)}scrollElement(){var t;if(!this.el)return b==null||(t=b.document)==null?void 0:t.documentElement;for(var e of F(this.el)?this.el:[this.el]){var s,i=b==null||(s=b.document)==null?void 0:s.querySelector(e);if(i)return i}}il(t){var e,s,i=t==="y"?"scrollTop":"scrollLeft";if(this.el){var r=this.scrollElement();return r&&r[i]||0}return b?t==="y"?b.scrollY||b.pageYOffset||((e=b.document)==null||(e=e.documentElement)==null?void 0:e.scrollTop)||0:b.scrollX||b.pageXOffset||((s=b.document)==null||(s=s.documentElement)==null?void 0:s.scrollLeft)||0:0}scrollY(){return this.il("y")}scrollX(){return this.il("x")}},Mw=t=>np(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes),af=class{constructor(t,e,s,i){this.Be=r=>{var n=this.rl();if(!n||n.sessionId!==r){var o={sessionId:r,props:this.nl(this._instance)};this.sl.register({[$l]:o})}},this._instance=t,this.ol=e,this.sl=s,this.nl=i||Mw,this.ol.onSessionId(this.Be)}rl(){return this.sl.props[$l]}getSetOnceProps(){var t,e=(t=this.rl())==null?void 0:t.props;return e?"r"in e?op(e,this._instance.config.disable_capture_url_hashes):{$referring_domain:e.referringDomain,$pathname:e.initialPathName,utm_source:e.utm_source,utm_campaign:e.utm_campaign,utm_medium:e.utm_medium,utm_content:e.utm_content,utm_term:e.utm_term}:{}}getSessionProps(){var t={};return ie(cu(this.getSetOnceProps()),(e,s)=>{s==="$current_url"&&(s="url"),t["$session_entry_"+_l(s)]=e}),t}},io=class{on(t,e){return this.al[t]||(this.al[t]=[]),this.al[t].push(e),()=>{this.al[t]=this.al[t].filter(s=>s!==e)}}emit(t,e){for(var s of this.al[t]||[])s(e);for(var i of this.al["*"]||[])i(t,e)}constructor(){this.al={}}},si=Te("[SessionId]"),lf=864e5,uf=class{on(t,e){return this.ll.on(t,e)}constructor(t,e,s){var i;if(this.ul=null,this.hl=null,this.dl=[],this.vl=void 0,this.cl=!1,this.ll=new io,this.fl=(a,l)=>!(!zt(a)||!zt(l))&&Math.abs(a-l)>this.sessionTimeoutMs,!t.persistence)throw new Error("SessionIdManager requires a PostHogPersistence instance");if(t.config.cookieless_mode==="always")throw new Error('SessionIdManager cannot be used with cookieless_mode="always"');this.Rn=t.config,this.sl=t.persistence,this.He=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.pl=void 0,this._sessionActivityTimestamp=null,this.gl=e||St,this.ml=s||St;var r=this.Rn.persistence_name||this.Rn.token;if(this._sessionTimeoutMs=1e3*xt(this.Rn.session_idle_timeout_seconds||1800,60,36e3,si.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.yl(),this.bl="ph_"+r+"_window_id",this._l="ph_"+r+"_primary_window_exists",this.wl()){var n=de.Nt(this.bl),o=de.Nt(this._l);n&&!o?this.He=n:de.Dt(this.bl),de.Ot(this._l,!0)}(i=this.Rn.bootstrap)!=null&&i.sessionID&&this.setBootstrapSessionId(this.Rn.bootstrap.sessionID),this.kl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return S(this.dl)&&(this.dl=[]),this.dl.push(t),this.Xt&&t(this.Xt,this.He),()=>{this.dl=this.dl.filter(e=>e!==t)}}wl(){return this.Rn.persistence!=="memory"&&!this.sl.gi&&de.Et()}Sl(t){t!==this.He&&(this.He=t,this.wl()&&de.Ot(this.bl,t))}xl(){return this.He?this.He:this.wl()?de.Nt(this.bl):null}Cl(t){var e=this.ul;return!Ie(e)&&!Ie(t)&&5e3>Math.abs(t-e)}Tl(t,e,s){var i=e!==this._sessionActivityTimestamp,r=!(t!==this.Xt||s!==this._sessionStartTimestamp);this._sessionStartTimestamp=s,this._sessionActivityTimestamp=e,this.Xt=t,r&&!i||r&&this.Cl(e)||(this.ul=e,this.sl.register({[ni]:[e,t,s]}))}Ml(){var t,e=(t=this.Rn)==null?void 0:t.persistence_save_debounce_ms;return zt(e)&&e>0}Il(){this.Ml()?this.sl.refreshKey(ni):(this.sl.flush(),this.sl.load())}El(){var t;if(!Ie(this._sessionActivityTimestamp)&&this._sessionActivityTimestamp!==this.ul){this.Il();var e=this.Rl();e[1]===this.Xt&&e[2]===this._sessionStartTimestamp&&(this.ul=this._sessionActivityTimestamp,this.sl.register({[ni]:[this._sessionActivityTimestamp,(t=this.Xt)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.sl.flush())}}Al(){var t=this.Rl()[0],e=zt(t)?t:0,s=zt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,s)}Pl(t){return this.Il(),this.fl(t,this.Al())}Rl(){var t=this.sl.props[ni];return F(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.ul=null,this.pl=void 0,clearTimeout(this.Fl),this.Fl=void 0,this.Tl(null,null,null)}setBootstrapSessionId(t,e){e===void 0&&(e=!1);var s=(function(i,r){r===void 0&&(r=new Date().getTime());try{var n=(o=>{var a=o.replace(/-/g,"");if(a.length!==32)throw new Error("Not a valid UUID");if(a[12]!=="7")throw new Error("Not a UUIDv7");return parseInt(a.substring(0,12),16)})(i);return n>r+6e4?void si.error("Bootstrap sessionID cannot be in the future"):n}catch(o){return void si.error("Invalid sessionID in bootstrap",o)}})(t);return!S(s)&&(e?this.pl={sessionId:t,sessionStartTimestamp:s}:this.Tl(t,new Date().getTime(),s),!0)}destroy(){this.cl=!0,this.El(),clearTimeout(this.Fl),this.Fl=void 0,this.vl&&b&&(b.removeEventListener(Xn,this.vl,{capture:!1}),this.vl=void 0),this.dl=[]}kl(){this.vl=()=>{this.El(),this.wl()&&de.Dt(this._l)},ae(b,Xn,this.vl,{capture:!1})}checkAndGetSessionAndWindowId(t,e,s){if(t===void 0&&(t=!1),e===void 0&&(e=null),s===void 0&&(s=!1),this.Rn.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');var i=e||new Date().getTime(),r=this.Xt;if(s)this.hl=i;else if(Ie(this.hl)||this.hl>i||i-this.hl>=1e3){var n,o;(n=(o=this.sl).syncCookieProperties)==null||n.call(o),this.hl=i}var a=this.Rl(),l=a[1],u=a[2],c=!S(r)&&l!==r,h=this.Al(),g=this.xl(),f=this.pl,p=!!f&&(f.sessionStartTimestamp>i+6e4||i-f.sessionStartTimestamp>lf),_=f?p:zt(u)&&Math.abs(i-u)>lf,v=!1,m=c,y=!l||!!f,w=l,E=!y&&!t&&this.fl(i,h);if(E){(E=this.Pl(i))||si.info("cross-tab refresh kept the session alive",{sessionId:l});var T=this.Rl();l=T[1],u=T[2]}if(y||E||_){m=!1;var C=f&&!p;l=C?f.sessionId:this.gl(),g=this.ml(),si.info("new session ID assigned",{sessionId:l,windowId:g,bootstrapped:!!C,changeReason:{noSessionId:y,activityTimeout:E,sessionPastMaximumLength:_}}),u=C?f.sessionStartTimestamp:i,this.pl=void 0,v=!0}else g||(g=this.ml(),v=!0),(m=m||l!==w)&&(si.info("adopted cross-tab session id",{sessionId:l,windowId:g}),v=!0);var q=zt(h)&&t&&!_?h:i,x=zt(u)?u:new Date().getTime();this.Sl(g),this.Tl(l,q,x),t||this.yl();var le={noSessionId:y,activityTimeout:E,sessionPastMaximumLength:_,crossTabAdoption:m};return v&&this.dl.forEach(D=>D(l,g,le)),{sessionId:l,windowId:g,sessionStartTimestamp:x,changeReason:v?le:void 0,lastActivityTimestamp:h}}yl(){this.cl||(clearTimeout(this.Fl),this.Fl=setTimeout(()=>{if(!this.cl)if(this.Pl(new Date().getTime())){var t=this.Xt;this.resetSessionId(),this.ll.emit("forcedIdleReset",{idleSessionId:t})}else this.yl()},1.1*this.sessionTimeoutMs))}},bp=function(t,e){if(!t)return!1;var s=t.userAgent;if(s&&ph(s,e))return!0;try{var i=t?.userAgentData;if(i!=null&&i.brands&&i.brands.some(r=>ph(r?.brand,e)))return!0}catch{}return!!t.webdriver};ro=(t,e)=>{if(!(s=>{try{new RegExp(s)}catch{return!1}return!0})(e))return!1;try{return new RegExp(e).test(t)}catch{return!1}},In=t=>t.toLowerCase(),wp={exact:(t,e)=>e.some(s=>t.some(i=>s===i)),is_not:(t,e)=>e.every(s=>t.every(i=>s!==i)),regex:(t,e)=>e.some(s=>t.some(i=>ro(s,i))),not_regex:(t,e)=>e.every(s=>t.every(i=>!ro(s,i))),icontains:(t,e)=>e.map(In).some(s=>t.map(In).some(i=>s.includes(i))),not_icontains:(t,e)=>e.map(In).every(s=>t.map(In).every(i=>!s.includes(i))),gt:(t,e)=>e.some(s=>{var i=parseFloat(s);return!isNaN(i)&&t.some(r=>i>parseFloat(r))}),lt:(t,e)=>e.some(s=>{var i=parseFloat(s);return!isNaN(i)&&t.some(r=>i<parseFloat(r))})};Xl="custom",cf="i.posthog.com",Uw=/^\/static\//,Vw=["/s/","/e/","/i/"],jw=class{constructor(t){this.Ol={},this.instance=t}get apiHost(){var t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){var t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t,e=(t=this.instance.config.ui_host)==null?void 0:t.replace(/\/$/,"");return e||(e=this.apiHost.replace("."+cf,".posthog.com")),e==="https://app.posthog.com"?"https://us.posthog.com":e}get region(){return this.Ol[this.apiHost]||(this.Ol[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":Xl),this.Ol[this.apiHost]}$l(t){if(Uw.test(t)){var e=this.instance.config.asset_host;if(typeof e=="string")return e.trim().replace(/\/$/,"")||void 0}}Dl(t){var e=gi(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}Ll(t,e,s){if(t==="ui")return s;var i=s,r=this.instance.config.rewriteRequestPath;if(r){var n,o=((n=gi(s))==null?void 0:n.href)||s;i=r(new URL(o)).toString()}if(r&&t==="api"&&Vw.some(h=>e.indexOf(h)===0)){var a=this.Dl(i);if(a){var l,u=this.apiHost,c=this.Nl;((l=c)==null?void 0:l.apiHost)===u&&c.rewriteRequestPath===r||(this.Nl=c={apiHost:u,rewriteRequestPath:r,urls:new Set}),c.urls.add(a)}}return i}isIngestionEndpoint(t){var e=this.Nl,s=this.Dl(t);return e?.apiHost===this.apiHost&&e.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!s&&e.urls.has(s)}endpointFor(t,e){if(e===void 0&&(e=""),e&&(e=e[0]==="/"?e:"/"+e),t==="ui")return this.Ll(t,e,this.uiHost+e);if(t==="flags")return this.Ll(t,e,this.flagsApiHost+e);if(t==="assets"){var s=this.$l(e);if(s)return this.Ll(t,e,""+s+e)}if(this.region===Xl)return this.Ll(t,e,this.apiHost+e);var i=cf+e;switch(t){case"assets":return this.Ll(t,e,"https://"+this.region+"-assets."+i);case"api":return this.Ll(t,e,"https://"+this.region+"."+i)}}},ne=Te("[Surveys]"),Ap=t=>{try{var e=(s=>((i,r)=>"seenSurvey_"+(function(n){return n.current_iteration&&n.current_iteration>0?n.id+"_"+n.current_iteration:n.id})(r))(0,s))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(s){ne.error("Failed to persist survey seen state",s)}},Gw=[sl.Popover,sl.Widget,sl.API],Hw={ignoreConditions:!1,ignoreDelay:!1,displayType:zl.Popover},qw=Te("[PostHog ExternalIntegrations]"),zw={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},Kw=class{constructor(t){this._instance=t}bo(t,e){var s;(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,t,i=>{if(i)return qw.error("failed to load script",i);e()})}startIfEnabledOrStop(){var t=this,e=function(){var r,n,o,a=s[0],l=s[1];!l||(r=L.__PosthogExtensions__)!=null&&(r=r.integrations)!=null&&r[a]||t.bo(zw[a],()=>{var u;(u=L.__PosthogExtensions__)==null||(u=u.integrations)==null||(u=u[a])==null||u.start(t._instance)}),!l&&(n=L.__PosthogExtensions__)!=null&&(n=n.integrations)!=null&&n[a]&&((o=L.__PosthogExtensions__)==null||(o=o.integrations)==null||(o=o[a])==null||o.stop())};for(var s of Object.entries((i=this._instance.config.integrations)!==null&&i!==void 0?i:{})){var i;e()}}},Ww=class{constructor(t,e){this.A=t,this.Js=e,this.ql=new Map,this.ro=!1}add(t){var e=this;return ge(function*(){if(e.ro)throw new Error("Cannot add an extension to a disposed ExtensionRuntime");if(e.ql.has(t.name))throw new Error('Browser extension "'+t.name+'" is already registered');e.ql.set(t.name,t);try{var s=t.setup(e.Js);s&&(yield s)}catch(r){var i=e.ql.get(t.name)===t;i&&e.ql.delete(t.name),e.A.error('Failed to set up browser extension "'+t.name+'"',r),i&&e.jl(t)}})()}getExtension(t){return this.ql.get(t)}dispose(){if(!this.ro){this.ro=!0;var t=Array.from(this.ql.values()).reverse();for(var e of(this.ql.clear(),t))this.jl(e)}}jl(t){try{var e=t.dispose==null?void 0:t.dispose();e&&qe(e.then)&&e.then(void 0,s=>{this.A.error('Failed to dispose browser extension "'+t.name+'"',s)})}catch(s){this.A.error('Failed to dispose browser extension "'+t.name+'"',s)}}},Jw=class{constructor(t){this._instance=t}initialize(){}get(t){var e=this._instance.persistence;if(typeof t=="string")return e?.get_property(t);var s={};for(var i of t){var r=e?.get_property(i);S(r)||(s[i]=r)}return s}set(t,e){var s;(s=this._instance.persistence)==null||s.register(typeof t=="string"?{[t]:e}:t)}remove(t){var e;(e=this._instance.persistence)==null||e.unregister(t)}},df="extensionsRemoteConfig",Yw=class{constructor(t){this.instance=t,this.ro=!1,this.A=I,this.Bl=t.Hl,this.kv=new Jw(t),this.onEvent=e=>An(this.instance.on("eventCaptured",s=>{try{e({event:s.event,properties:s.properties})}catch(i){this.A.error("Browser extension event listener failed",i)}})),this.onRemoteConfig=e=>{if(this.ro)return An(()=>{});var s=r=>{try{e(r)}catch(n){this.A.error("Browser extension remote config listener failed",n)}},i=this.instance.zl.on(df,s);return this.Bl&&s(this.Bl),An(i)},this.Ul=new Ww(I.createLogger("[BrowserExtensions]"),this)}get logger(){return this.A}get distinctId(){return this.instance.get_distinct_id()}get anonymousId(){var t;return(t=this.instance.get_property("$device_id"))!==null&&t!==void 0?t:this.distinctId}get deviceId(){var t=this.instance.get_property(ru);return typeof t=="string"?t:void 0}get library(){return{name:Le.LIB_NAME,version:Le.LIB_VERSION}}get initialPersonProperties(){var t,e;return(t=(e=this.instance.persistence)==null?void 0:e.get_initial_props())!==null&&t!==void 0?t:{}}get groups(){return this.instance.getGroups()}get session(){try{var t,e,s,i,r=(t=this.instance.sessionManager)==null?void 0:t.checkAndGetSessionAndWindowId(!0);return{sessionId:(e=r?.sessionId)!==null&&e!==void 0?e:"",windowId:(s=r?.windowId)!==null&&s!==void 0?s:"",sessionStartTimestamp:(i=r?.sessionStartTimestamp)!==null&&i!==void 0?i:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0}}}get canCapture(){return this.instance.is_capturing()}get projectToken(){return this.instance.config.token}add(t){return this.Ul.add(t)}getExtension(t){return this.Ul.getExtension(t)}capture(t,e,s){var i=this;return ge(function*(){s?i.instance.capture(t,e,{timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce}):i.instance.capture(t,e)})()}registerDynamicEventProperties(t){return An(this.instance.Wl(t))}handleRemoteConfig(t){this.ro||(this.Bl=t,this.instance.zl.emit(df,t))}sendRequest(t,e){var s=this;return ge(function*(){var i;e===void 0&&(e={});var r=s.instance.requestRouter.endpointFor((i=e.target)!==null&&i!==void 0?i:"api",t),n={method:e.method,url:e.query?yr(r,e.query):r,data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,compressionFallback:e.target==="flags"&&e.compression==="best-available"?ml.Base64:void 0,timestampMode:e.sentAt};return e.transport==="sendBeacon"?(s.instance._send_request(n),{statusCode:202}):new Promise(o=>{n.callback=o,s.instance._send_request(n)})})()}dispose(){this.ro||(this.ro=!0,this.Ul.dispose())}},ur={},ll=0,cr=()=>{},hf='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',Zi="Surveys module not available",ff="sanitize_properties is deprecated. Use before_send instead",Ip="Invalid value for property_denylist config: ",Xw=/^[A-Za-z0-9_-]{1,400}$/,ul=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Qw=["token","distinct_id",$g],ir="posthog",Rp=!xw&&Ye?.indexOf("MSIE")===-1&&Ye?.indexOf("Mozilla")===-1,Zw=t=>{var e={};return t&&t!=="unset"&&("2025-11-30">t||(e.strictMinimumDuration=!0),"2026-05-30">t||(e.canvasCapture={resolutionScale:.6}),"2026-06-25">t||(e.streamNetworkBody=!0),"2026-08-30">t||(e.captureJsonLd=!0)),e},cl=t=>{var e;return k({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:ew(A?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:cr,save_campaign_params:!0,custom_campaign_params:[],custom_blocked_useragents:[],save_referrer:!0,capture_pageleave:"if_capture_pageview",defaults:t??"unset",__preview_deferred_init_extensions:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:Ee&&Q(Ee?.search)&&Ee.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,disableDeviceModel:!1,reuseAnonymousId:!1,disable_external_dependency_loading:!1,strict_script_versioning:"fallback",enable_recording_console_log:void 0,secure_cookie:(b==null||(e=b.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(s){I.error("Bad HTTP status: "+s.statusCode+" "+s.text)},get_device_id:s=>s,capture_performance:void 0,name:"posthog",bootstrap:{},disable_compression:!1,session_idle_timeout_seconds:1800,person_profiles:Bg,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:cr},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:lw,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:Zw(s),external_scripts_inject_target:s&&s>="2026-01-30"?"head":"body",internal_or_test_user_hostname:s&&s>="2026-01-30"?/^(localhost|127\.0\.0\.1)$/:void 0,persistence_save_debounce_ms:s&&s>="2026-05-30"?250:0,split_storage:!(!s||"2026-05-30">s),detect_google_search_app:!(!s||"2026-05-30">s),disable_capture_url_hashes:!(!s||"2026-06-25">s),cookieWinsOnConflict:!(!s||s==="unset"||"2026-08-29">s)}))(t))},ek=[["process_person","person_profiles"],["xhr_headers","request_headers"],["cookie_name","persistence_name"],["disable_cookie","disable_persistence"],["__preview_disable_beacon","disable_beacon"],["store_google","save_campaign_params"],["verbose","debug"],["__preview_cookie_wins_on_conflict","cookieWinsOnConflict"]],gf=t=>{var e={};for(var s of ek){var i=s[0],r=s[1];S(t[i])||(e[r]=t[i])}var n=fe({},e,t),o=t.__preview_external_dependency_versioned_paths;return S(o)||(S(t.strict_script_versioning)&&(n.strict_script_versioning=!!o),Q(o)&&S(t.asset_host)&&(n.asset_host=o)),F(t.property_blacklist)&&(S(t.property_denylist)?n.property_denylist=t.property_blacklist:F(t.property_denylist)?n.property_denylist=[...t.property_blacklist,...t.property_denylist]:I.error(Ip+t.property_denylist)),n},tk=class{constructor(){this.__forceAllowLocalhost=!1}get Vl(){return this.__forceAllowLocalhost}set Vl(t){I.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},_u=(_n=class ns{Gl(e){if(e){var s=this.ql.indexOf(e);s!==-1&&this.ql.splice(s,1)}}Zl(e,s){return this.Gl(e),this.ql.push(s),s.initialize==null||s.initialize(),s}Jl(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}Ql(){if(!(this.Kl||this.config.reuseAnonymousId||this.config.segment||this.Jl())){var e,s,i,r=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";(r||this.config.disable_persistence)&&(this.Xl||(r?(e="persistence is set to '"+this.config.persistence+"'",s=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",i="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(e="persistence is disabled (disable_persistence is true)",s="on every page load",i="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.Kl=!0,console.warn("[PostHog.js]",e+" but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID "+s+", so calling identify() merges a new ID onto the person each time. A person can then pass the distinct-ID limit and its events stop appearing on person pages and the session tab. "+i)))}}Yl(){if(!this.Jl()&&this.get_distinct_id()==="$posthog_cookieless"){var e=this.persistence;if(e){this.tu()||e.load(!0);var s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){var i=this.config.get_device_id(St());this.register({distinct_id:i,$device_id:i}),e.set_property(je,os)}this.eu()}}}get decideEndpointWasHit(){var e,s;return(e=(s=this.featureFlags)==null?void 0:s.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,s;return(e=(s=this.featureFlags)==null?void 0:s.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.iu=!1,this.ru=!1,this.webPerformance=new tk,this.nu=!1,this.version=Le.LIB_VERSION,this.su=new Set,this.ou="",this.zl=new io,this.ql=[],this.au=[],this.Xl=!1,this.Kl=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=cl(),this.SentryIntegration=vw,this.sentryIntegration=i=>(function(r,n){var o=Qg(r,n);return{name:Xg,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.lu=!1,this.uu=null,this.hu=null,this.du=null,this.scrollManager=new Fw(this),this.pageViewManager=new Xh(this),this.rateLimiter=new Aw(this),this.requestRouter=new jw(this),this.consent=new aw(this),this.externalIntegrations=new Kw(this);var s=(e=ns.__defaultExtensionClasses)!==null&&e!==void 0?e:{};this.featureFlags=s.featureFlags&&new s.featureFlags(this),this.toolbar=s.toolbar&&new s.toolbar(this),this.surveys=s.surveys&&new s.surveys(this),this.conversations=s.conversations&&new s.conversations(this),this.logs=s.logs&&new s.logs(this),this.metrics=s.metrics&&new s.metrics(this),this.experiments=s.experiments&&new s.experiments(this),this.exceptions=s.exceptions&&new s.exceptions(this),this.people={set:(i,r,n)=>{var o=Q(i)?{[i]:r}:i;this.setPersonProperties(o),n?.({})},set_once:(i,r,n)=>{var o=Q(i)?{[i]:r}:i;this.setPersonProperties(void 0,o),n?.({})}},this.on("eventCaptured",i=>I.info('send "'+i?.event+'"',i))}init(e,s,i){if(i&&i!==ir){var r,n=(r=ur[i])!==null&&r!==void 0?r:new ns;return n._init(e,s,i),ur[i]=n,ur[ir][i]=n,n}return this._init(e,s,i)}_init(e,s,i){var r,n,o;s===void 0&&(s={});var a,l=Q(e)?e.trim():"";if(!l)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 l!==((a=this.config)==null?void 0:a.token)?console.warn("[PostHog.js]","You have already initialized PostHog with a different project token! Re-initializing is a no-op, so events will keep going to the project this instance was initialized with. To capture into a second project, load PostHog once, then initialize a named instance after the SDK has loaded, e.g. posthog.init('"+l+"', { ... }, 'project2')"):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=cl(s.defaults),s.debug=this.vu(s.debug),this.cu=s,this.fu=[],s.person_profiles?this.hu=s.person_profiles:s.process_person&&(this.hu=s.process_person);var u=cl(s.defaults),c=gf(s),h=fe({},u,c,{name:i,token:l});Y(u.rageclick)&&Y(c.rageclick)&&(h.rageclick=fe({},u.rageclick,c.rageclick)),Y(u.session_recording)&&Y(c.session_recording)&&(h.session_recording=fe({},u.session_recording,c.session_recording)),this.set_config(h),this.config.on_xhr_error&&I.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:lt.GZipJS;var g=this.tu();if(this.persistence=new tl(this.config,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tl(k({},this.config,{persistence:"sessionStorage"}),g,!1),this.ou="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!g&&de.Et()){var f=de.Nt(this.ou);F(f)&&f.forEach(x=>{Q(x)&&this.su.add(x)})}else de.Dt(this.ou);var p=k({},this.persistence.props),_=k({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.pu=new Lw(x=>this.gu(x),this.config.request_queue_config),this.mu=new $w(this),this.__request_queue=[];var v=this.Jl();v||(this.sessionManager=new uf(this),this.sessionPropsManager=new af(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((x,le,D)=>{(D!=null&&D.activityTimeout||D!=null&&D.sessionPastMaximumLength||D!=null&&D.crossTabAdoption)&&this.yu()})),this.bu(),this.config.__preview_deferred_init_extensions?(I.info("Deferring extension initialization to improve startup performance"),setTimeout(()=>{this._u(v)},0)):(I.info("Initializing extensions synchronously"),this._u(v)),Le.DEBUG=Le.DEBUG||this.config.debug,Le.DEBUG&&I.info("Starting in debug mode",{this:this,config:s,thisC:k({},this.config),p,s:_}),!this.config.identity_distinct_id||(r=s.bootstrap)!=null&&r.distinctID||(s.bootstrap=k({},s.bootstrap,{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));var m=(n=s.bootstrap)==null?void 0:n.distinctID;if(this.Xl=!!m&&!rr(m),((o=s.bootstrap)==null?void 0:o.distinctID)!==void 0){var y=s.bootstrap.distinctID,w=this.get_distinct_id(),E=this.persistence.get_property(je);if(s.bootstrap.isIdentifiedID&&w!=null&&w!==y&&E==="anonymous")this.identify(y);else if(s.bootstrap.isIdentifiedID&&w!=null&&w!==y&&E==="identified")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 T=this.config.get_device_id(St()),C=s.bootstrap.isIdentifiedID?T:y;this.persistence.set_property(je,s.bootstrap.isIdentifiedID?sr:os),this.register({distinct_id:y,$device_id:C})}}if(v)this.register_once({distinct_id:Ka,$device_id:null},"");else if(!this.get_distinct_id()){var q=this.config.get_device_id(St());this.register_once({distinct_id:q,$device_id:q},""),this.persistence.set_property(je,os)}return ae(b,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),ae(b,"pageshow",()=>{var x;this.iu=!1,this.ru||(x=this.mu)==null||x.resume()}),s.segment?Yh(this,()=>this.wu()):this.wu(),qe(this.config._onCapture)&&this.config._onCapture!==cr&&(I.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",x=>this.config._onCapture(x.event,x))),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.config.disableDeviceModel||(function(){return Ep.apply(this,arguments)})().then(x=>{x&&this.register({[qa]:x})}).catch(cr),this}ku(e){var s=e;return Q(s.name)&&qe(s.setup)}Su(e,s){this.ku(e)?s.push(()=>{this.xu().add(e).catch(()=>e.dispose==null?void 0:e.dispose()).catch(i=>{I.error('Failed to dispose browser extension "'+e.name+'"',i)})}):this.ql.push(e)}bu(){var e,s,i,r,n,o,a=(e=(s=this.config.__extensionClasses)==null?void 0:s.featureFlags)!==null&&e!==void 0?e:(i=ns.__defaultExtensionClasses)==null?void 0:i.featureFlags;a&&(this.featureFlags&&this.featureFlags instanceof a||((o=this.Cu)==null||o.call(this),this.Cu=void 0,this.featureFlags=new a(this)),qe(this.featureFlags.onReloading)&&qe(this.featureFlags.setup)?this.Cu||(this.Cu=this.featureFlags.onReloading(()=>{this.zl.emit("featureFlagsReloading",!0)}),this.xu().add(this.featureFlags)):(r=(n=this.featureFlags).initialize)==null||r.call(n))}_u(e){var s,i,r,n,o,a,l,u=performance.now(),c=k({},ns.__defaultExtensionClasses,this.config.__extensionClasses),h=[];c.exceptions&&this.ql.push(this.exceptions=(s=this.exceptions)!==null&&s!==void 0?s:new c.exceptions(this)),c.historyAutocapture&&this.ql.push(this.historyAutocapture=new c.historyAutocapture(this)),c.tracingHeaders&&this.ql.push(this.tracingHeaders=new c.tracingHeaders(this)),c.siteApps&&this.ql.push(this.siteApps=new c.siteApps(this)),c.sessionRecording&&!e&&this.ql.push(this.sessionRecording=new c.sessionRecording(this)),this.config.disable_scroll_properties||h.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),c.autocapture&&this.Su(this.autocapture=new c.autocapture(this),h),c.surveys&&this.Su(this.surveys=(i=this.surveys)!==null&&i!==void 0?i:new c.surveys(this),h),c.logs&&this.Su(this.logs=(r=this.logs)!==null&&r!==void 0?r:new c.logs(this),h),c.metrics&&this.ql.push(this.metrics=(n=this.metrics)!==null&&n!==void 0?n:new c.metrics(this)),c.conversations&&this.ql.push(this.conversations=(o=this.conversations)!==null&&o!==void 0?o:new c.conversations(this)),c.productTours&&this.ql.push(this.productTours=new c.productTours(this)),c.heatmaps&&this.ql.push(this.heatmaps=new c.heatmaps(this)),c.webVitalsAutocapture&&this.ql.push(this.webVitalsAutocapture=new c.webVitalsAutocapture(this)),c.exceptionObserver&&this.ql.push(this.exceptionObserver=new c.exceptionObserver(this)),c.deadClicksAutocapture&&this.ql.push(this.deadClicksAutocapture=new c.deadClicksAutocapture(this,pw)),c.toolbar&&this.ql.push(this.toolbar=(a=this.toolbar)!==null&&a!==void 0?a:new c.toolbar(this)),c.experiments&&this.ql.push(this.experiments=(l=this.experiments)!==null&&l!==void 0?l:new c.experiments(this)),this.ql.forEach(g=>{g.initialize&&h.push(()=>{g.initialize==null||g.initialize()})}),h.push(()=>{if(this.Tu){var g=this.Tu;this.Tu=void 0,this.ql.forEach(f=>f.onRemoteConfig==null?void 0:f.onRemoteConfig(g))}}),this.Mu(h,u)}Mu(e,s){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&e.length>0)return void setTimeout(()=>{this.Mu(e,s)},0);var i=e.shift();if(i)try{i()}catch(n){I.error("Error initializing extension:",n)}}var r=Math.round(performance.now()-s);this.register_for_session({[Fg]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[Mg]:r}),this.config.__preview_deferred_init_extensions&&I.info("PostHog extensions initialized ("+r+"ms)")}Pa(e){var s;if(!A||!A.body)return I.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.Pa(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Tu=e),this.Hl=e,this.compression=void 0,e.ok){var i,r=e.config;r.supportedCompression&&!this.config.disable_compression&&(this.compression=M(r.supportedCompression,lt.GZipJS)?lt.GZipJS:M(r.supportedCompression,lt.Base64)?lt.Base64:void 0),(i=r.analytics)!=null&&i.endpoint&&(this.analyticsDefaultEndpoint=r.analytics.endpoint)}this.set_config({person_profiles:this.hu?this.hu:Bg}),(s=this.Iu)==null||s.handleRemoteConfig(e),this.ql.forEach(n=>n.onRemoteConfig==null?void 0:n.onRemoteConfig(e))}wu(){try{this.config.loaded(this)}catch(i){I.critical("`loaded` function failed",i)}if(this.Eu(),this.config.internal_or_test_user_hostname&&Ee!=null&&Ee.hostname){var e=Ee.hostname,s=this.config.internal_or_test_user_hostname;(typeof s=="string"?e===s:s.test(e))&&this.setInternalOrTestUser()}this.config.capture_pageview&&setTimeout(()=>{(this.consent.isOptedIn()||this.Jl())&&this.Ru()},1),this.Au=new lp(this),this.Au.load()}Eu(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.pu)==null||e.enable())}_dom_loaded(){this.is_capturing()&&bn(this.__request_queue,e=>this.gu(e)),this.__request_queue=[],this.Eu()}_handle_unload(){var e,s,i,r,n;this.iu=!0,(e=this.surveys)==null||e.handlePageUnload==null||e.handlePageUnload(),(s=this.metrics)==null||s.flush("sendBeacon"),this.config.request_batching?(this.Pu()&&this.capture(Dh),(i=this.logs)==null||i.flushLogs("sendBeacon"),(r=this.pu)==null||r.unload(),(n=this.mu)==null||n.unload()):this.Pu()&&this.capture(Dh,null,{transport:"sendBeacon"})}_send_request(e){var s;this.__loaded?Rp?this.__request_queue.push(e):this.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:429})):(e.transport=e.transport||this.config.api_transport,e.headers=k({},this.config.request_headers,e.headers),e.compression=e.compression==="best-available"?(s=this.compression)!==null&&s!==void 0?s:e.compressionFallback:e.compression,(S(this.config.disable_beacon)?this.config.__preview_disable_beacon:this.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||this.config.fetch_options,(i=>{var r,n,o,a=k({},i);a.timeout=a.timeout||6e4;var l,u,c,h,g,f=(r=a.transport)!==null&&r!==void 0?r:"fetch";f==="sendBeacon"&&S(a.compression)&&a.data&&(a.compression=lt.Base64),a.method==="POST"&&a.data&&(a.timestampMode==="capture-body"?a.data={api_key:(u=(g=(h=(F(l=a.data)?l:[l]).map(m=>k({},m,m.timestamp instanceof Date&&!isNaN(m.timestamp.getTime())?{timestamp:m.timestamp.toISOString()}:{})))[0])==null||(c=g.properties)==null?void 0:c.token)!==null&&u!==void 0?u:g?.token,batch:h,sent_at:new Date().toISOString()}:a.timestampMode==="body"&&(a.data=(function(m,y){return y===void 0&&(y=new Date().toISOString()),F(m)?m.map(w=>k({},w,{sent_at:y})):k({},m,{sent_at:y})})(a.data))),a.url=of(a.url,a.method,a.compression,a.timestampMode);var p=Bn.filter(m=>!a.disableTransport||!m.transport||!a.disableTransport.includes(m.transport)),_=(n=(o=(function(m,y){for(var w=0;m.length>w;w++)if(y(m[w]))return m[w]})(p,m=>m.transport===f))==null?void 0:o.method)!==null&&n!==void 0?n:p[0].method;if(!_)throw new Error("No available transport method");var v=m=>{try{_(m)}catch(y){_p(y)?I.warn(y):I.error(y),a.callback==null||a.callback({statusCode:0,error:y})}};f!=="sendBeacon"&&a.data&&a.compression===lt.GZipJS&&LE&&typeof Promise<"u"&&!Mn?Dw(a).then(m=>{v(m)}).catch(m=>{if(Th(m))return Mn=!0,void v(k({},a,{compression:void 0,url:of(i.url,i.method,void 0,i.timestampMode)}));(y=>{if(!y||typeof y!="object")return!1;var w="name"in y?String(y.name):"";return Th(y)||w===mg})(m)&&(Mn=!0),v(a)}):_(a)})(k({},e,{callback:i=>{var r,n;this.rateLimiter.checkForLimiting(i),400>i.statusCode||(r=(n=this.config).on_request_error)==null||r.call(n,i),e.callback==null||e.callback(i)}}))):e.fireCallbackOnDrop&&(e.callback==null||e.callback({statusCode:0}))}gu(e){this.mu?this.mu.retriableRequest(e):this._send_request(e)}_execute_array(e){ll++;try{var s,i=[],r=[],n=[];bn(e,a=>{if(a)if(F(s=a[0]))n.push(a);else if(qe(a))try{a.call(this)}catch(l){I.error("Error executing queued PostHog call",a,l)}else F(a)&&s==="alias"?i.push(a):F(a)&&s.indexOf("capture")!==-1&&qe(this[s])?n.push(a):r.push(a)});var o=function(a,l){bn(a,function(u){try{if(F(u[0])){var c=l;ie(u,function(h){c=c[h[0]].apply(c,h.slice(1))})}else l[u[0]].apply(l,u.slice(1))}catch(h){I.error("Error executing queued PostHog call",u,h)}})};o(i,this),o(r,this),o(n,this)}finally{ll--}}push(e){if(ll>0&&F(e)&&Q(e[0])){var s=ns.prototype[e[0]];qe(s)&&s.apply(this,e.slice(1))}else this._execute_array([e])}Fu(){var e,s=(e=this.persistence)==null?void 0:e.get_property(Et);return Q(s)&&ul.test(s)?{value:s,delivered:!1}:Y(s)&&Q(s.value)&&ul.test(s.value)?{value:s.value,delivered:s.delivered===!0}:void 0}Ou(e,s,i,r){if(this.persistence){this.persistence.refreshKey(Et);var n=this.Fu();if(!r){if(i)return Q(s)&&ul.test(s)?(s!==n?.value&&this.persistence.register({[Et]:{value:s,delivered:!1}}),{value:s,pending:s!==n?.value||!n.delivered}):void this.persistence.unregister(Et);if(Q(e)&&Xw.test(e)){if(n?.value.split(".")[3]===e)return{value:n.value,pending:!n.delivered};var o="fb.1."+Date.now()+"."+e;return this.persistence.register({[Et]:{value:o,delivered:!1}}),{value:o,pending:!0}}return n?{value:n.value,pending:!n.delivered}:void 0}this.persistence.unregister(Et)}}$u(e){if(this.persistence){this.persistence.refreshKey(Et);var s=this.Fu();s?.value!==e||s.delivered||this.persistence.register({[Et]:{value:e,delivered:!0}})}}capture(e,s,i){var r,n,o,a,l,u,c,h,g,f;if(this.__loaded&&this.persistence&&this.sessionPersistence&&this.pu){if(this.is_capturing())if(!S(e)&&Q(e)){this.Yl();var p=!this.config.opt_out_useragent_filter&&this._is_bot();if(!p||this.config.__preview_capture_bot_pageviews){var _=i!=null&&i.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(_==null||!_.isRateLimited){var v;s!=null&&s.$current_url&&!Q(s?.$current_url)&&(I.error("Invalid `$current_url` property provided to `posthog.capture`. Input must be a string. Ignoring provided value."),s==null||delete s.$current_url),e!=="$exception"||i!=null&&i.Du||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&&(v=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 m=new Date,y=i?.timestamp||m,w=Eh(i?.uuid,St),E={uuid:w,event:e,properties:this.calculateEventProperties(e,s||{},y,w)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&p&&(E.event="$bot_pageview",E.properties.$browser_type="bot"),_&&(E.properties.$lib_rate_limit_remaining_tokens=_.remainingTokens);var T=e==="$feature_flag_called"&&E.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;i!=null&&i.$set&&!T&&(E.$set=i?.$set);var C=Y(s?.$set)?s.$set:void 0,q=!(i==null||!i.$set)&&"$fbc"in i.$set,x=q||!!C&&"$fbc"in C,le=q?i==null||(r=i.$set)==null?void 0:r[za]:C?.[za],D=F(s?.$unset)?s.$unset:[],P=i?.$unset||[],G=D.indexOf("$fbc")!==-1||P.indexOf("$fbc")!==-1,N=this.Ou((n=v)==null?void 0:n.fbclid,le,x,G);N&&E.properties.$process_person_profile===!0&&N.pending&&!x&&!T&&(E.$set=k({[za]:N.value},E.$set));var U=i?.$unset;U&&(E.$unset=U);var ue=T?void 0:this.Lu(i?.$set_once,e!==Nh,e===Bl);if(ue&&(E.$set_once=ue),i!=null&&i._noTruncate||(c=this.config.properties_string_max_length,h=E,g=X=>Q(X)?X.slice(0,c):X,f=new Set,E=(function X(se,xe){if(se!==Object(se))return g?g(se):se;if(!f.has(se)){var Se;if(f.add(se),F(se))Se=[],bn(se,Me=>{Se.push(X(Me))});else{var j={};ie(mr(se)?Ug(se):se,(Me,hs)=>{f.has(Me)||(j[hs]=X(Me,hs))}),Se=j}return Se}})(h)),E.timestamp=y,S(i?.timestamp)||(E.properties.$event_time_override_provided=!0,E.properties.$event_time_override_system_time=m),T&&(E.properties=(function(X,se){se===void 0&&(se=[]);var xe={},Se=j=>{X[j]!==void 0&&(xe[j]=X[j])};return bS.forEach(Se),se.forEach(Se),xe})(E.properties,Qw)),e===Jt.DISMISSED||e===Jt.SENT){var Oe=s?.[il.SURVEY_ID],he=s?.[il.SURVEY_ITERATION];Ap({id:Oe,current_iteration:he}),E.$set=k({},E.$set,{[Bw({id:Oe,current_iteration:he},e===Jt.SENT?"responded":"dismissed")]:!0})}else e===Jt.SHOWN&&(E.$set=k({},E.$set,{[il.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));if(e===kw.SHOWN){var oe=s?.[ef.TOUR_TYPE];oe&&(E.$set=k({},E.$set,{[ef.TOUR_LAST_SEEN_DATE+"/"+oe]:new Date().toISOString()}))}var O=k({},E.properties.$set,E.$set);if(nt(O)||this.setPersonPropertiesForFlags(O),!H(this.config.before_send)){var B=this.bs(E);if(!B)return;(E=B).uuid=Eh(E.uuid,St)}var V=(o=(a=E.$set)==null?void 0:a.$fbc)!==null&&o!==void 0?o:Y((l=E.properties)==null?void 0:l.$set)?E.properties.$set.$fbc:void 0,K=N!=null&&N.pending&&V===N.value?N.value:void 0;this.zl.emit("eventCaptured",E);var J,W=(u=i?._url)!==null&&u!==void 0?u:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),Z=k({method:"POST",url:W,data:E,compression:"best-available",timestampMode:i?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(W)?"body":"capture-body",batchKey:i?._batchKey},i!=null&&i.transport?{transport:i.transport}:{},K?{fireCallbackOnDrop:!0,callback:X=>{X.statusCode>=200&&300>X.statusCode&&this.$u(K)}}:{});return!this.config.request_batching||i&&(i==null||!i._batchKey)||i!=null&&i.send_instantly||K?(!Z.transport&&!Z.callback&&nt((J=this.config.request_headers)!==null&&J!==void 0?J:{})&&this.iu&&(Z.transport="sendBeacon"),this.gu(Z)):this.pu.enqueue(Z),E}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",s=>e(s.event,s))}getExtension(e){var s;return(s=this.Iu)==null?void 0:s.getExtension(e)}xu(){var e;return(e=this.Iu)!==null&&e!==void 0?e:this.Iu=new Yw(this)}Wl(e){this.au.push(e);var s=!0;return()=>{if(s){s=!1;var i=this.au.indexOf(e);i!==-1&&this.au.splice(i,1)}}}Nu(e){var s,i,r;return e===void 0&&(e=!0),!((s=this.persistence)==null||!s.consumeCookieIdentityChange())&&(this.du=null,this.persistence.get_property("$user_state")==="anonymous"&&((r=this.sessionPersistence)==null||r.clear(),this.su.clear(),this.qu()),(i=this.featureFlags)==null||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,s,i,r,n){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return s;this.persistence.syncCookieProperties(),this.Nu();var o=n?void 0:this.persistence.remove_event_timer(e),a=k({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.Jl()&&(a[$g]=!0),e==="$snapshot"){var l=k({},this.persistence.properties(),this.sessionPersistence.properties());return a.distinct_id=l.distinct_id,(!Q(a.distinct_id)&&!Re(a.distinct_id)||rr(a.distinct_id))&&I.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}var u,c=(function(q,x,le,D){var P,G,N,U;if(D===void 0&&(D=!1),!Ye)return{};var ue,Oe=q?[...vi,...x||[]]:[],he=fg(Ye),oe=he[0],O=he[1],B=(function(Ds){for(var Ns=0;yh.length>Ns;Ns++){var Si,Ls=yh[Ns],wi=Ls[1],yu=Ls[2],bu=Ds.match(Ls[0]);if(bu)return[wi,((Si=yu&&Ds.match(yu)||bu)==null?void 0:Si[1])||""]}return["",""]})(Ye),V=B[0],K=B[1],J=(ue="u">typeof navigator?navigator:void 0)!=null&&ue.brave?{brave:!0}:{},W={};S(le)||(W.detectGoogleSearchApp=le);var Z={},X=(P=navigator)==null||(P=P.userAgentData)==null?void 0:P.platform,se=(G=navigator)==null?void 0:G.maxTouchPoints,xe=b==null||(N=b.screen)==null?void 0:N.width,Se=b==null||(U=b.screen)==null?void 0:U.height,j=b?.devicePixelRatio;S(X)||(Z.userAgentDataPlatform=X),S(se)||(Z.maxTouchPoints=se),S(xe)||(Z.screenWidth=xe),S(Se)||(Z.screenHeight=Se),S(j)||(Z.devicePixelRatio=j);var Me,hs,De,mi,yi,bi,ct,Ze,Ei=fe(cu({$os:oe,$os_version:O,$browser:hg(Ye,navigator.vendor,J,W),$webview_app:V,$webview_app_version:K,$device:mh(Ye),$device_type:(hs=Ye,De=Z,Ze=mh(hs),Ze===jf||Ze===Vf||Ze==="Kobo"||Ze==="Kindle Fire"||Ze===eg?Vn:Ze===jn||Ze===lo||Ze===Gn||Ze===yl?"Console":Ze===Gf?"Wearable":Ze?di:De?.userAgentDataPlatform==="Android"&&((mi=De?.maxTouchPoints)!==null&&mi!==void 0?mi:0)>0?600>Math.min((yi=De?.screenWidth)!==null&&yi!==void 0?yi:0,(bi=De?.screenHeight)!==null&&bi!==void 0?bi:0)/((ct=De?.devicePixelRatio)!==null&&ct!==void 0?ct:1)?di:Vn:"Desktop"),$timezone:ap(),$timezone_offset:Ew()}),{$current_url:vr(D?ds(Ee?.href):Ee?.href,Oe,_r),$host:Ee?.host,$pathname:Ee?.pathname,$raw_user_agent:Ye.length>1e3?Ye.substring(0,997)+"...":Ye,$browser_version:YE(Ye,navigator.vendor,J,W),$browser_language:Qh(),$browser_language_prefix:(Me=Qh(),typeof Me=="string"?Me.split("-")[0]:void 0),$screen_height:b?.screen.height,$screen_width:b?.screen.width,$viewport_height:b?.innerHeight,$viewport_width:b?.innerWidth,$lib:Yt.LIB_NAME,$lib_version:Yt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Yt.SDK_DIST_CHANNEL&&(Ei.$sdk_dist_channel=Yt.SDK_DIST_CHANNEL),Ei})(this.config.mask_personal_data_properties,this.config.custom_personal_data_properties,this.config.detect_google_search_app,this.config.disable_capture_url_hashes);if(this.sessionManager){var h=this.sessionManager.checkAndGetSessionAndWindowId(n,i.getTime(),!0),g=h.windowId;a.$session_id=h.sessionId,a.$window_id=g}this.sessionPropsManager&&fe(a,this.sessionPropsManager.getSessionProps());try{var f;this.sessionRecording&&fe(a,this.sessionRecording.sdkDebugProperties),a.$sdk_debug_retry_queue_size=(f=this.mu)==null?void 0:f.length}catch(q){a.$sdk_debug_error_capturing_properties=String(q)}if(this.requestRouter.region===Xl&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||n?e!=="$pageleave"||n?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,r),a=fe(a,u),e==="$pageview"&&A&&(a.title=A.title),!S(o)){var p=i.getTime()-o;a.$duration=parseFloat((p/1e3).toFixed(3))}Ye&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");var _=this.persistence.properties(),v=this.sessionPersistence.properties(),m=a.$groups,y=_.$groups;Y(m)&&!nt(m)&&(a.$groups=k({},Y(y)?y:{},m)),ie(["$referrer","$referring_domain"],q=>{q in _&&delete v[q]});var w={};if(this.au.length>0)for(var E of this.au.slice())try{fe(w,E())}catch(q){I.error("Failed to produce browser extension event properties",q)}(a=fe({},c,_,v,k({},w,a))).$is_identified=this._isIdentified(),F(this.config.property_denylist)?ie(this.config.property_denylist,function(q){delete a[q]}):I.error(Ip+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);var T=this.config.sanitize_properties;T&&(I.error(ff),a=T(a,e));var C=this.ju();return a.$process_person_profile=C,C&&!n&&this.Bu("_calculate_event_properties"),a}Lu(e,s,i){var r;if(s===void 0&&(s=!0),i===void 0&&(i=!1),!this.persistence||!this.ju()||this.nu&&!i)return e;var n=fe({},this.persistence.get_initial_props(),((r=this.sessionPropsManager)==null?void 0:r.getSetOnceProps())||{},e||{}),o=this.config.sanitize_properties;return o&&(I.error(ff),n=o(n,"$set_once")),s&&(this.nu=!0),nt(n)?void 0:n}register(e,s){var i;(i=this.persistence)==null||i.register(e,s)}register_once(e,s,i){var r;(r=this.persistence)==null||r.register_once(e,s,i)}register_for_session(e){var s,i;(s=this.persistence)==null||s.syncCookieProperties(),this.Nu(),(i=this.sessionPersistence)==null||i.register(e),Object.keys(e).forEach(r=>this.su.add(r)),this.qu()}unregister(e){var s;(s=this.persistence)==null||s.unregister(e)}unregister_for_session(e){var s;(s=this.sessionPersistence)==null||s.unregister(e),this.su.delete(e),this.qu()}Hu(e,s){this.register({[e]:s})}yu(){this.su.forEach(e=>{var s;(s=this.sessionPersistence)==null||s.unregister(e)}),this.su.clear(),this.qu()}qu(){var e;if(this.ou)if(this.config.persistence==="memory"||(e=this.sessionPersistence)!=null&&e.gi||!de.Et())de.Dt(this.ou);else{var s=[];this.su.forEach(i=>s.push(i)),s.length>0?de.Ot(this.ou,s):de.Dt(this.ou)}}getFeatureFlag(e,s){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlag(e,s)}getFeatureFlagPayload(e){var s;return(s=this.featureFlags)==null?void 0:s.getFeatureFlagPayload(e)}getFeatureFlagResult(e,s){var i;return(i=this.featureFlags)==null?void 0:i.getFeatureFlagResult(e,s)}getAllFeatureFlags(){var e,s;return(e=(s=this.featureFlags)==null?void 0:s.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,s){var i,r;return(i=(r=this.featureFlags)==null?void 0:r.isFeatureEnabled(e,s))!==null&&i!==void 0?i:s?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)==null||e.reloadFeatureFlags()}updateFlags(e,s,i){var r;(r=this.featureFlags)==null||r.updateFlags(e,s,i)}updateEarlyAccessFeatureEnrollment(e,s,i){var r;(r=this.featureFlags)==null||r.updateEarlyAccessFeatureEnrollment(e,s,i)}getEarlyAccessFeatures(e,s,i){var r;return s===void 0&&(s=!1),(r=this.featureFlags)==null?void 0:r.getEarlyAccessFeatures(e,s,i)}on(e,s){return this.zl.on(e,s)}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:Zi}),()=>{})}onSessionId(e){var s,i;return(s=(i=this.sessionManager)==null?void 0:i.onSessionId(e))!==null&&s!==void 0?s:()=>{}}getSurveys(e,s){s===void 0&&(s=!1),this.surveys?this.surveys.getSurveys(e,s):e([],{isLoaded:!1,error:Zi})}getActiveMatchingSurveys(e,s){s===void 0&&(s=!1),this.surveys?this.surveys.getActiveMatchingSurveys(e,s):e([],{isLoaded:!1,error:Zi})}renderSurvey(e,s){var i;(i=this.surveys)==null||i.renderSurvey(e,s)}displaySurvey(e,s){var i;s===void 0&&(s=Hw),(i=this.surveys)==null||i.displaySurvey(e,s)}cancelPendingSurvey(e){var s;(s=this.surveys)==null||s.cancelPendingSurvey(e)}canRenderSurvey(e){var s,i;return(s=(i=this.surveys)==null?void 0:i.canRenderSurvey(e))!==null&&s!==void 0?s:{visible:!1,disabledReason:Zi}}canRenderSurveyAsync(e,s){var i,r;return s===void 0&&(s=!1),(i=(r=this.surveys)==null?void 0:r.canRenderSurveyAsync(e,s))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:Zi})}zu(e){return!e||rr(e)?(I.critical("Unique user id has not been set in posthog.identify"),!1):e==="$posthog_cookieless"?(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,s,i){if(!this.__loaded||!this.persistence)return I.uninitializedWarning("posthog.identify");if(Re(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.zu(e)&&this.Bu("posthog.identify")){this.Yl();var r=this.get_distinct_id(),n=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==r,o=this.Nu(!1),a=this.persistence.va(),l=!1;try{var u=this.get_distinct_id();this.register({$user_id:e}),this.get_property("$device_id")||this.register_once({$had_persisted_distinct_id:!0,$device_id:u},""),e!==u&&e!==this.get_property("__alias")&&(this.unregister(Jn),this.register({distinct_id:e}));var c=(this.persistence.get_property("$user_state")||"anonymous")===os,h=e!==u,g=!h&&c;if(h&&c){var f,p=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:u};this.persistence.set_property(je,sr),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.ca(),this.capture(Bl,p,{$set:s||{},$set_once:i||{}}),this.du=al(e,s,i),(f=this.featureFlags)==null||f.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:u)}else if(g){this.persistence.set_property(je,sr);var _=s||{},v=i||{};this.setPersonPropertiesForFlags({$set:_,$set_once:v},!1),this.config.cookieWinsOnConflict&&this.persistence.ca(),this.capture("$set",{$set:_,$set_once:v}),this.du=al(e,s,i)}else(s||i)&&this.setPersonProperties(s,i);h||n||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(us)):g&&(s||i)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.ga(l)}}}setPersonProperties(e,s){if((e||s)&&this.Bu("posthog.setPersonProperties")){var i=al(this.get_distinct_id(),e,s);this.du!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:s||{}},!0),this.capture("$set",{$set:e||{},$set_once:s||{}}),this.du=i):I.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}}unsetPersonProperties(e){var s,i=(F(e)?e:[e]).filter(r=>Q(r)&&r.length>0);i.length!==0&&this.Bu("posthog.unsetPersonProperties")&&((s=this.featureFlags)==null||s.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.du=null)}group(e,s,i){var r;if(e&&s){(r=this.persistence)==null||r.syncCookieProperties(),this.Nu();var n=this.getGroups(),o=n[e]!==s;if(o&&this.resetGroupPropertiesForFlags(e),this.register({$groups:k({},n,{[e]:s})}),(o||i)&&this.ju()){var a={$group_type:e,$group_key:s};i&&(a.$group_set=i),this.capture(Nh,a)}i&&this.setGroupPropertiesForFlags({[e]:i}),o&&!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,s){var i;s===void 0&&(s=!0),(i=this.featureFlags)==null||i.setPersonPropertiesForFlags(e,s)}resetPersonPropertiesForFlags(e){var s;e===void 0&&(e=!0),(s=this.featureFlags)==null||s.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,s){var i;s===void 0&&(s=!0),this.Bu("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)==null||i.setGroupPropertiesForFlags(e,s))}resetGroupPropertiesForFlags(e){var s;(s=this.featureFlags)==null||s.resetGroupPropertiesForFlags(e)}reset(e){var s=Xe(e)?e:e?.resetDeviceID,i=Xe(e)||e==null?void 0:e.bootstrap;this.Uu(s,!1,i)}Uu(e,s,i){var r,n,o,a;if(s===void 0&&(s=!1),I.info("reset"),!this.__loaded)return I.uninitializedWarning("posthog.reset");var l=i?.sessionID;this.config.bootstrap=i||((r=this.cu)==null?void 0:r.bootstrap)||{},(n=this.featureFlags)==null||n.updateConfig==null||n.updateConfig(this.config,this.Fa());var u=this.get_property(ru),c=this.get_property(qa),h=this.get_property(ui);(o=this.sessionRecording)==null||o.flushBeforeIdentityReset();var g=this.is_capturing();this.consent.reset(),s||!g||this.is_capturing()||console.warn("[PostHog.js]","reset() cleared the stored consent, and capturing is now off because of `opt_out_capturing_by_default`. Call opt_in_capturing() again, and prefer calling reset() before opting in rather than after.");var f=(a=this.persistence)==null||a.va==null?void 0:a.va(),p=!1;try{var _,v,m,y,w,E,T,C,q,x,le,D,P;if((_=this.persistence)==null||_.clear(),(v=this.sessionPersistence)==null||v.clear(),this.su.clear(),this.qu(),S(h)||(m=this.persistence)==null||m.register({[ui]:h}),(y=this.surveys)==null||y.reset(),(w=this.featureFlags)==null||w.reset(),(E=this.conversations)==null||E.reset(),(T=this.logs)==null||T.reset(),(C=this.metrics)==null||C.reset(),(q=this.persistence)==null||q.set_property(je,os),(x=this.sessionManager)==null||x.resetSessionId(),this.du=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:Ka,$device_id:null},"");else{var G=this.config.get_device_id(St());this.register_once({distinct_id:G,$device_id:e?G:u},""),e||S(c)||this.register({[qa]:c})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID===void 0||this.Jl()||((P=this.persistence)==null||P.set_property(je,i.isIdentifiedID?sr:os),this.register({distinct_id:i.distinctID})),(le=this.featureFlags)==null||le.initialize(),!(S(l)||(D=this.sessionManager)!=null&&D.setBootstrapSessionId(l,!0)))){var N=k({},i);delete N.sessionID,this.config.bootstrap=N}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,p=!0}finally{var U;f&&((U=this.persistence)==null||U.ga==null||U.ga(p))}this.reloadFeatureFlags()}shutdown(e){var s=this;return ge(function*(){var i,r,n,o,a,l,u;if(s.__loaded){s.ru=!0,s.xu().dispose(),(i=s.sessionRecording)==null||i.dispose(),(r=s.logs)==null||r.flushLogs("sendBeacon"),(n=s.metrics)==null||n.flush("sendBeacon"),(o=s.pu)==null||o.unload(),(a=s.mu)==null||a.unload();try{var c;(c=s.featureFlags)==null||c.destroy()}catch(h){I.error("Error while destroying feature flags",h)}(l=s.persistence)==null||l.destroy(),(u=s.sessionPersistence)==null||u.destroy()}else I.uninitializedWarning("posthog.shutdown")})()}setIdentity(e,s){var i;delete this.config.identity_claims,this.config.identity_distinct_id=e,this.config.identity_hash=s,this.alias(e),(i=this.conversations)==null||i.Wu()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)==null||e.Vu()}get_distinct_id(){return this.get_property("distinct_id")}getGroups(){return this.get_property("$groups")||{}}get_session_id(){var e,s;return(e=(s=this.sessionManager)==null?void 0:s.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";var s=this.sessionManager.checkAndGetSessionAndWindowId(!0),i=s.sessionStartTimestamp,r=this.requestRouter.endpointFor("ui","/project/"+this.config.token+"/replay/"+s.sessionId);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,s){return e===this.get_property("$people_distinct_id")?(I.critical("Attempting to create alias for existing People user - aborting."),-2):this.Bu("posthog.alias")?(S(s)&&(s=this.get_distinct_id()),e!==s?(this.Hu(Jn,e),this.capture("$create_alias",{alias:e,distinct_id:s})):(I.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){var s=k({},this.config);if(Y(e)){var i,r,n,o,a,l,u,c,h,g,f,p,_;fe(this.config,gf(e));var v=this.tu();(i=this.persistence)==null||i.update_config(this.config,s,v),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new tl(k({},this.config,{persistence:"sessionStorage"}),v,!1);var m=this.vu(this.config.debug);Xe(m)&&(this.config.debug=m),Xe(this.config.debug)&&(this.config.debug?(Le.DEBUG=!0,ee.Et()&&ee.Ot("ph_debug",!0),I.info("set_config",{config:e,oldConfig:s,newConfig:k({},this.config)})):(Le.DEBUG=!1,ee.Et()&&ee.Dt("ph_debug"))),(r=this.featureFlags)==null||r.updateConfig==null||r.updateConfig(this.config,this.Fa()),(n=this.exceptionObserver)==null||n.onConfigChange(),(o=this.exceptions)==null||o.onConfigChange(),(a=this.sessionRecording)==null||a.startIfEnabledOrStop(),(l=this.tracingHeaders)==null||l.startIfEnabledOrStop(),(u=this.autocapture)==null||u.startIfEnabled(),(c=this.heatmaps)==null||c.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((h=this.historyAutocapture)==null||h.startIfEnabledOrStop()),(g=this.exceptionObserver)==null||g.startIfEnabledOrStop(),(f=this.deadClicksAutocapture)==null||f.startIfEnabledOrStop(),(p=this.surveys)==null||p.loadIfEnabled(),this.eu(),(_=this.externalIntegrations)==null||_.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&Yh(this,cr,!1)}}_overrideSDKInfo(e,s){Le.LIB_NAME=e,Le.LIB_VERSION=s}startSessionRecording(e){var s,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)&&((s=this.sessionManager)==null||s.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,s){try{if(!this.exceptions)return;var i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(k({},i,s))}catch{return}}addExceptionStep(e,s){var i;(i=this.exceptions)==null||i.addExceptionStep(e,s)}captureLog(e){var s;(s=this.logs)==null||s.captureLog(e)}get logger(){var e,s;return(e=(s=this.logs)==null?void 0:s.logger)!==null&&e!==void 0?e:ns.Gu}startExceptionAutocapture(e){this.set_config({capture_exceptions:e==null||e})}stopExceptionAutocapture(){this.set_config({capture_exceptions:!1})}loadToolbar(e){var s,i;return(s=(i=this.toolbar)==null?void 0:i.loadToolbar(e))!==null&&s!==void 0&&s}get_property(e){var s;return(s=this.persistence)==null?void 0:s.props[e]}getSessionProperty(e){var s;return(s=this.sessionPersistence)==null?void 0:s.props[e]}toString(){var e,s=(e=this.config.name)!==null&&e!==void 0?e:ir;return s!==ir&&(s="posthog."+s),s}_isIdentified(){var e,s;return((e=this.persistence)==null?void 0:e.get_property("$user_state"))==="identified"||((s=this.sessionPersistence)==null?void 0:s.get_property("$user_state"))==="identified"}ju(){var e,s;return!(this.config.person_profiles==="never"||this.config.person_profiles==="identified_only"&&!this._isIdentified()&&nt(this.getGroups())&&((e=this.persistence)==null||(e=e.props)==null||!e.__alias)&&((s=this.persistence)==null||(s=s.props)==null||!s.$epp))}Pu(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.ju()||this.Bu("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.Bu("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}Bu(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.Ql(),this.Hu(lu,!0),!0)}tu(){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!=="on_reject")}eu(){var e,s,i,r,n,o=this.tu();return this.is_capturing()||(e=this.logs)==null||e.Zu(),((s=this.persistence)==null?void 0:s.gi)!==o&&((i=this.persistence)==null||i.set_disabled(o)),((r=this.sessionPersistence)==null?void 0:r.gi)!==o&&((n=this.sessionPersistence)==null||n.set_disabled(o)),o&&(this.su.clear(),this.qu()),o}opt_in_capturing(e){var s,i,r;if(this.config.cookieless_mode!=="always"){if(this.Jl()){var n,o,a,l,u,c;(n=this.sessionRecording)==null||n.dispose({discardBufferedEvents:!0}),this.Uu(!0,!0),(o=this.sessionManager)==null||o.destroy(),(a=this.pageViewManager)==null||a.destroy(),this.sessionManager=new uf(this),this.pageViewManager=new Xh(this),this.persistence&&(this.sessionPropsManager=new af(this,this.sessionManager,this.persistence));var h,g=(l=(u=this.config.__extensionClasses)==null?void 0:u.sessionRecording)!==null&&l!==void 0?l:(c=ns.__defaultExtensionClasses)==null?void 0:c.sessionRecording;g&&(this.sessionRecording=this.Zl(this.sessionRecording,new g(this)),this.Hl&&((h=this.sessionRecording)==null||h.onRemoteConfig==null||h.onRemoteConfig(this.Hl)))}this.consent.optInOut(!0),this.eu(),this.Eu(),(s=this.sessionRecording)==null||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((i=this.surveys)==null||i.loadIfEnabled()),(S(e?.captureEventName)||e!=null&&e.captureEventName)&&this.capture((r=e?.captureEventName)!==null&&r!==void 0?r:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Ru()}else I.warn(hf)}opt_out_capturing(){if(this.config.cookieless_mode!=="always"){var e,s,i=this.config.cookieless_mode==="on_reject"?this.sessionRecording:void 0;i?.dispose({discardBufferedEvents:!0}),this.config.cookieless_mode==="on_reject"&&this.consent.isOptedIn()&&this.Uu(!0,!0),this.consent.optInOut(!1),this.eu(),this.config.cookieless_mode==="on_reject"&&(this.register({distinct_id:Ka,$device_id:null}),this.Gl(i),this.sessionRecording=void 0,(e=this.sessionManager)==null||e.destroy(),(s=this.pageViewManager)==null||s.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Ru(),this.Eu())}else I.warn(hf)}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==="always"||(this.config.cookieless_mode==="on_reject"?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.eu()}_is_bot(){return Fe?bp(Fe,this.config.custom_blocked_useragents):void 0}Ru(){A&&(A.visibilityState==="visible"?this.lu||(this.lu=!0,this.capture(uu,{title:A.title},{send_instantly:!0}),this.uu&&(A.removeEventListener(hi,this.uu),this.uu=null)):this.uu||(this.uu=this.Ru.bind(this),ae(A,hi,this.uu)))}debug(e){e===!1?(b?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(b?.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}))}Fa(){var e=this.cu||{};return"advanced_disable_flags"in e?!!e.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):(function(s,i,r,n,o){var a=i in s&&!H(s[i]),l=r in s&&!H(s[r]);return a?s[i]:!!l&&(o&&o.warn("Config field '"+r+"' is deprecated. Please use '"+i+"' instead. The old field will be removed in a future major version."),s[r])})(e,"advanced_disable_flags","advanced_disable_decide",0,I)}bs(e){var s;if(H(this.config.before_send))return e;var i=Object.keys((s=e.properties)!==null&&s!==void 0?s:{}).filter(UE),r=F(this.config.before_send)?this.config.before_send:[this.config.before_send],n=e;for(var o of r)try{if(n=o(n),H(n)){var a="Event '"+e.event+"' was rejected in beforeSend function";return BE(e.event)?I.warn(a+". This can cause unexpected behavior."):I.info(a),null}n.properties&&!nt(n.properties)||I.warn("Event '"+e.event+"' has no properties after beforeSend function, this is likely an error.")}catch(u){return I.error("Error in beforeSend function for event '"+e.event+"':",u),null}for(var l of i)if(n.properties&&H(n.properties[l]))return I.warn("Event '"+e.event+"' had its '"+l+"' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped."),null;return n}getPageViewId(){var e;return(e=this.pageViewManager.ko)==null?void 0:e.pageViewId}captureTraceFeedback(e,s){this.capture("$ai_feedback",{$ai_trace_id:String(e),$ai_feedback_text:s})}captureTraceMetric(e,s,i){this.capture("$ai_metric",{$ai_trace_id:String(e),$ai_metric_name:s,$ai_metric_value:String(i)})}vu(e){var s=Xe(e)&&!e,i=ee.Et()&&ee.Lt("ph_debug")==="true";return!s&&(!!i||e)}},_n.__defaultExtensionClasses={},_n.Gu=(()=>{var t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),_n);(function(t,e){for(var s=0;e.length>s;s++)t.prototype[e[s]]=QS(t.prototype[e[s]])})(_u,["identify"]);Tp=class{constructor(t){this.disabled=t===!1;var e=Y(t)?t:{};this.thresholdPx=e.threshold_px||30,this.timeoutMs=e.timeout_ms||1e3,this.clickCount=e.click_count||3,this.clicks=[]}isRageClick(t,e,s){if(this.disabled)return!1;var i=this.clicks[this.clicks.length-1];if(i&&Math.abs(t-i.x)+Math.abs(e-i.y)<this.thresholdPx&&this.timeoutMs>s-i.timestamp){if(this.clicks.push({x:t,y:e,timestamp:s}),this.clicks.length===this.clickCount)return!0}else this.clicks=[{x:t,y:e,timestamp:s}];return!1}},dl="$copy_autocapture",Rn=Te("[AutoCapture]");rk=class{zs(){this.Us=void 0,clearTimeout(this.Ws),this.Ws=void 0}Vs(t){var e;if(!ci(t))return!0;for(var s,i=(e=this.Gs().css_selector_ignorelist)!==null&&e!==void 0?e:Za,r=new Set,n=t,o=function(){if(r.size>=1e3||r.has(n))return{v:!0};r.add(n);var a=n,l=fi(a);if(M(l,"ph-no-capture")||M(l,"ph-sensitive")||pr(a)||i.some(c=>Hl(a,c)))return{v:!0};var u=n.parentNode;n=du(u)?u.host:u&&Dt(u)?u:null};n;)if(s=o())return s.v;return!1}Zs(t){if(this.isEnabled&&t.type!=="pointercancel")if(t.type!=="pointerdown"){var e=this.Us;e&&(t.pointerId!==e.id||Math.abs(t.clientX-e.x)>5||Math.abs(t.clientY-e.y)>5?this.zs():t.type==="pointerup"&&(e.released=!0,this.Ws=setTimeout(()=>this.zs(),0)))}else{var s;this.zs();var i=or(t);t.isPrimary&&t.button===0&&!t.ctrlKey&&i&&Dt(i)&&(this.Us={target:i,excluded:this.Vs(i),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:(s=this.Js)==null?void 0:s.distinctId})}else this.zs()}Qs(t){var e,s=this.Us;this.zs();var i=or(t);if(s!=null&&s.released&&s.target.isConnected&&s.distinctId===((e=this.Js)==null?void 0:e.distinctId)&&t.pointerId===s.id&&(t.detail>0||t.pointerType==="touch"||t.pointerType==="pen")&&t.button===0&&5>=Math.abs(t.clientX-s.x)&&5>=Math.abs(t.clientY-s.y)&&i&&(Ge(i,"html")||Ge(i,"body"))){var r;if(s.excluded)return null;var n=(r=this.Gs().css_selector_ignorelist)!==null&&r!==void 0?r:Za;return[i,A?.documentElement,A?.body].some(o=>{if(!o)return!1;var a=fi(o);return M(a,"ph-no-capture")||M(a,"ph-sensitive")||!ci(o)||pr(o)||n.some(l=>Hl(o,l))})?null:s.target}}constructor(t){this.Ks=t,this.name="autocapture",this.Xs=!1,this.Ys=null,this.eo=!1,this.io=!1,this.Rn={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.ro=!1,this.Ks.refresh(this.Rn),this.rageclicks=new Tp(this.Rn.rageclick),this.no=null}setup(t){this.so(),this.Js=t;var e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.ro?e.dispose():(this.oo=e,this.startIfEnabled())}dispose(){var t;this.ro||(this.ro=!0,this.Js=void 0,(t=this.oo)==null||t.dispose(),this.oo=void 0,this.ao())}Gs(){return this.Ks.refresh(this.Rn),this.Rn}so(){var t,e;return this.Gs(),this.Rn.url_allowlist=(t=this.Rn.url_allowlist)==null?void 0:t.map(s=>new RegExp(s)),this.Rn.url_ignorelist=(e=this.Rn.url_ignorelist)==null?void 0:e.map(s=>new RegExp(s)),this.Rn}lo(){if(this.isBrowserSupported()){if(b&&A){var t=this.uo=s=>{s=s||b?.event;try{if(s.type==="blur")return void this.zs();if(s.type.indexOf("pointer")===0)return void this.Zs(s);var i=s.type==="click"?this.Qs(s):void 0;if(Ie(i))return;this.ho(s,"$autocapture",i)}catch(r){Rn.error("Failed to capture event",r)}};if(ae(b,"blur",t),ae(A,"submit",t,{capture:!0}),ae(A,"change",t,{capture:!0}),ae(A,"click",t,{capture:!0}),ie(["pointerdown","pointermove","pointerup","pointercancel"],s=>{ae(A,s,t,{capture:!0})}),this.Gs().capture_copied_text){var e=this.do=s=>{s=s||b?.event;try{this.ho(s,dl)}catch(i){Rn.error("Failed to capture clipboard event",i)}};ae(A,"copy",e,{capture:!0}),ae(A,"cut",e,{capture:!0}),ae(A,"paste",e,{capture:!0})}}}else Rn.info("Disabling Automatic Event Collection because this browser is not supported")}ao(){this.zs(),this.uo&&(b?.removeEventListener("blur",this.uo),ie(["pointerdown","pointermove","pointerup","pointercancel"],t=>{A?.removeEventListener(t,this.uo,!0)}),A?.removeEventListener("submit",this.uo,!0),A?.removeEventListener("change",this.uo,!0),A?.removeEventListener("click",this.uo,!0),this.uo=void 0),this.do&&(A?.removeEventListener("copy",this.do,!0),A?.removeEventListener("cut",this.do,!0),A?.removeEventListener("paste",this.do,!0),this.do=void 0),this.Xs=!1}startIfEnabled(){this.isEnabled||this.zs(),!this.ro&&this.Js&&this.isEnabled&&!this.Xs&&(this.lo(),this.Xs=!0)}onRemoteConfig(t){if(!this.ro)if(this.eo=!0,t.ok){var e=t.config;e.elementsChainAsString&&(this.io=e.elementsChainAsString);var s,i=e.autocapture_opt_out;Xe(i)&&((s=this.Js)==null||s.kv.set(Rl,i),this.Ys=i),this.startIfEnabled()}else this.startIfEnabled()}setElementSelectors(t){this.no=t}getElementSelectors(t,e){var s,i=[];return(s=this.no)==null||s.forEach(r=>{var n;A==null||(n=A.querySelectorAll(r))==null||n.forEach(o=>{t!==o&&e!==o||M(i,r)||i.push(r)})}),i}get isEnabled(){var t,e;if(this.ro)return!1;var s=(t=this.Js)==null?void 0:t.kv.get(Rl),i=this.Ys,r=this.Gs();if(!r.remoteRequestsDisabled&&!this.eo)return!1;var n=r.remoteRequestsDisabled&&!this.eo;if(Ie(i)&&!Xe(s)&&!n)return!1;var o=(e=this.Ys)!==null&&e!==void 0?e:!!s;return!!r.enabled&&!o}ho(t,e,s){if(e===void 0&&(e="$autocapture"),this.isEnabled){var i=s||or(t);Hg(i)&&(i=i.parentNode||null);var r,n=this.so();e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&n.rageclick&&(r=this.rageclicks)!=null&&r.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime())&&Wg(i,n.rageclick)&&this.ho(t,"$rageclick",s);var o=e===dl,a=o?k({},n,{dom_event_allowlist:void 0}):n;if(i&&(function(m,y,w,E,T,C){var q;if(!b||gu(m)||w!=null&&w.url_allowlist&&!Uh(w.url_allowlist,C)||w!=null&&w.url_ignorelist&&Uh(w.url_ignorelist,C))return!1;if(w!=null&&w.dom_event_allowlist){var x=w.dom_event_allowlist;if(x&&!x.some(U=>y.type===U))return!1}var le=Jg(m,E),D=le.parentIsUsefulElement,P=le.targetElementList;if(!(function(U,ue){var Oe=ue?.element_allowlist;if(S(Oe))return!0;var he,oe=function(B){if(Oe.some(V=>B.tagName.toLowerCase()===V))return{v:!0}};for(var O of U)if(he=oe(O))return he.v;return!1})(P,w)||!ql(P,w?.css_selector_allowlist)||ql(P,(q=w?.css_selector_ignorelist)!==null&&q!==void 0?q:Za))return!1;try{var G=b.getComputedStyle(m);if(G&&G.getPropertyValue("cursor")==="pointer"&&y.type==="click")return!0}catch{}var N=m.tagName.toLowerCase();switch(N){case"html":return!1;case"form":return(T||["submit"]).indexOf(y.type)>=0;case"input":case"select":case"textarea":return(T||["change","click"]).indexOf(y.type)>=0;default:return D?(T||["click"]).indexOf(y.type)>=0:(T||["click"]).indexOf(y.type)>=0&&(fu.indexOf(N)>-1||m.getAttribute("contenteditable")==="true")}})(i,t,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l,u=ik(i,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.io,disableCaptureUrlHashes:n.disableCaptureUrlHashes}),c=u.props;if(u.explicitNoCapture)return!1;var h=this.getElementSelectors(i,u.target);if(h&&h.length>0&&(c.$element_selectors=h),e===dl){var g=t.type||"clipboard";if(g!=="paste"){var f,p,_=b==null||(f=b.getSelection())==null?void 0:f.toString(),v=qg(_);if(!v)return!1;c.$selected_content=v,c.$clipboard_text_length=(p=_?.length)!==null&&p!==void 0?p:0}c.$copy_type=g}return(l=this.Js)==null||l.capture(e,c).catch(m=>Rn.error("Failed to capture event",m)),!0}}else this.zs()}isBrowserSupported(){return qe(A?.querySelectorAll)}},nk=class{constructor(t){this._instance=t}refresh(t){var e=this._instance.config,s=Y(e.autocapture)?e.autocapture:void 0;t.enabled=!!e.autocapture,t.rageclick=e.rageclick,t.maskAllElementAttributes=e.mask_all_element_attributes,t.maskAllText=e.mask_all_text,t.disableCaptureUrlHashes=e.disable_capture_url_hashes,t.getCurrentUrl=e.get_current_url,t.remoteRequestsDisabled=this._instance.Fa(),t.url_allowlist=s?.url_allowlist,t.url_ignorelist=s?.url_ignorelist,t.dom_event_allowlist=s?.dom_event_allowlist,t.element_allowlist=s?.element_allowlist,t.css_selector_allowlist=s?.css_selector_allowlist,t.css_selector_ignorelist=s?.css_selector_ignorelist,t.element_attribute_ignorelist=s?.element_attribute_ignorelist,t.capture_copied_text=s?.capture_copied_text}},er=Te("[ExceptionAutocapture]"),pf=()=>{},vf=t=>{var e;if(qe(t))return(e=t.__posthog_layer__)!==null&&e!==void 0?e:t.__rrweb_layer__};ok=Te("[TracingHeaders]"),ks=Te("[Web Vitals]"),_f=9e5,mf=["CLS","FCP","INP","LCP"],ak=["INP","LCP"],lk=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],Tn="disabled",yf="lazy_loading",qt=Te("[SessionRecording]"),uk=Te("[Heatmaps]");On=Te("[Product Tours]"),gl=t=>{var e;return!t.config.disable_product_tours&&!((e=t.persistence)==null||!e.get_property(ou))},Tt=Te("[SiteApps]"),bf="Error while initializing PostHog app with config id ",Pp=(t,e)=>t!=null&&t.then?t.then(e):e(t),ii="SDK is not enabled or survey functionality is not yet loaded",Ef="Disabled. Not loading surveys.",ck=class{constructor(t,e){this.Ks=t,this.Ju=e,this.name="surveys",this._surveyEventReceiver=null,this._surveyManager=null,this.Qu=!1,this.Ku=[],this.Xu=null,this.Yu=null,this.ro=!1,this.th=new Set,this.onRemoteConfig=s=>{if(!this.ro&&!this.Rn.disableSurveys){if(!s.ok)return ne.warn("Remote config unavailable. Not loading surveys.");var i=s.config.surveys;if(H(i))return ne.warn("Flags not loaded yet. Not loading surveys.");this.eh=Xe(i)?i:i.length>0,ne.info("flags response received, isSurveysEnabled: "+this.eh),this.loadIfEnabled()}}}setup(t){if(!this.ro)return this.ih=t,Pp(t.kv.initialize(),()=>{if(this.ih===t&&!this.ro){this.ih=void 0,this.Js=t;var e=t.onRemoteConfig(this.onRemoteConfig);this.ro?e.dispose():(this.oo=e,this.loadIfEnabled())}})}dispose(){var t,e,s;this.ro||(this.ro=!0,this.ih=void 0,this.Js=void 0,(t=this.oo)==null||t.dispose(),this.oo=void 0,(e=this._surveyEventReceiver)==null||e.dispose(),this._surveyEventReceiver=null,(s=this._surveyManager)==null||s.dispose==null||s.dispose(),this._surveyManager=null,this.Ku=[],this.Xu=null,this.th.forEach(i=>clearTimeout(i)),this.th.clear())}get Rn(){return this.Ks.get()}initialize(){this.loadIfEnabled()}reset(){try{var t;(t=this._surveyEventReceiver)==null||t.reset(),localStorage.removeItem("lastSeenSurveyDate");for(var e=[],s=0;s<localStorage.length;s++){var i=localStorage.key(s);(i!=null&&i.startsWith("seenSurvey_")||i!=null&&i.startsWith("inProgressSurvey_"))&&e.push(i)}e.forEach(r=>localStorage.removeItem(r))}catch{}}loadIfEnabled(){if(!this.ro&&this.Js){var t=this.Rn;if(!this._surveyManager)if(this.Qu)ne.info("Already initializing surveys, skipping...");else if(t.disableSurveys)ne.info(Ef);else if(t.cookielessMode&&this.Ks.isOptedOut())ne.info("Not loading surveys in cookieless mode without consent.");else{var e=this.Ks.getExtensions();if(e){if(!S(this.eh)||t.advancedEnableSurveys){var s=this.eh||t.advancedEnableSurveys;this.Qu=!0;try{var i=e.generateSurveys;if(i)return this.rh(i,s),void(this.Qu=!1);var r=e.loadExternalDependency;if(!r)return this.nh(Ml),void(this.Qu=!1);r(n=>{try{if(this.ro)return;var o=this.Ks.getExtensions();n||o==null||!o.generateSurveys?this.nh("Could not load surveys script",n):this.rh(o.generateSurveys,s)}finally{this.Qu=!1}})}catch(n){throw this.Qu=!1,this.nh("Error initializing surveys",n),n}}}else ne.error("PostHog Extensions not found.")}}}rh(t,e){this.ro||(this._surveyManager=t(e),this._surveyEventReceiver=this.Ks.createEventReceiver(),ne.info("Surveys loaded successfully"),this.sh({isLoaded:!0}))}nh(t,e){ne.error(t,e),this.sh({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Ku.push(t),this._surveyManager&&this.sh({isLoaded:!0}),()=>{this.Ku=this.Ku.filter(e=>e!==t)}}getSurveys(t,e){var s;e===void 0&&(e=!1);var i=(s=this.Js)!==null&&s!==void 0?s:this.Ju;if(i&&!this.ro){if(this.Rn.disableSurveys)return ne.info(Ef),t([]);var r=i.kv.get(Nl);if(r&&!e)return t(r,{isLoaded:!0}),void(this.oh()&&this.getSurveys(()=>{},!0));if(this.Xu)this.Xu.then(a=>{this.ro||t(a.surveys,a.context)}).catch(a=>ne.error("Error in survey callback",a));else{var n=this.ah("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Rn.requestTimeoutMs}).then(a=>{try{return this.uh(i,a)}catch(l){return ne.error("Error processing surveys response",l),this.uh(i,{statusCode:0,error:l})}},a=>this.uh(i,{statusCode:0,error:a}));this.Xu=n;var o=()=>{this.Xu===n&&(this.Xu=null)};n.then(a=>{o(),this.ro||t(a.surveys,a.context)},o).catch(a=>ne.error("Error in survey callback",a))}}}ah(t,e){var s=this.Js;return s?s.sendRequest(t,e):new Promise(i=>i({statusCode:0,error:new Error(ii)}))}uh(t,e){var s;if(this.ro)return{surveys:[],context:{isLoaded:!1,error:ii}};var i=e.statusCode;if(i!==200||!e.json){var r="Surveys API could not be loaded, status: "+i;return i!==0?ne.error(r):e.error||ne.warn(r),this.Yu=Date.now(),{surveys:[],context:{isLoaded:!1,error:r}}}this.Yu=null;var n=e.json.surveys||[],o=n.filter(a=>(function(l){return!(!l.start_date||l.end_date)})(a)&&(Sp(a)||(function(l){var u;return!((u=l.conditions)==null||(u=u.actions)==null||(u=u.values)==null||!u.length)})(a)));return o.length>0&&((s=this._surveyEventReceiver)==null||s.register(o)),t.kv.set({[Nl]:n,[Yn]:Date.now()}),{surveys:n,context:{isLoaded:!0}}}oh(){return this.hh()&&!this.Xu&&!this.dh()}hh(){var t,e,s=(t=(e=this.Js)!==null&&e!==void 0?e:this.Ju)==null?void 0:t.kv.get(Yn);return Re(s)&&Date.now()-s>3e5}dh(){return Re(this.Yu)&&3e5>Date.now()-this.Yu}markSurveyAsSeen(t,e){var s;Ap({id:t,current_iteration:(s=e?.iteration)!==null&&s!==void 0?s:null});try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}}sh(t){for(var e of this.Ku)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(s){ne.error("Error in survey callback",s)}}getActiveMatchingSurveys(t,e){if(e===void 0&&(e=!1),!H(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ne.warn("init was not called")}fh(t){var e=null;return this.getSurveys(s=>{var i;e=(i=s.find(r=>r.id===t))!==null&&i!==void 0?i:null}),e}ph(t){if(H(this._surveyManager))return{eligible:!1,reason:ii};var e=typeof t=="string"?this.fh(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}gh(t){if(H(this._surveyManager))return{eligible:!1,reason:ii};var e=typeof t=="string"?this.fh(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(H(this._surveyManager))return ne.warn("init was not called"),{visible:!1,disabledReason:ii};var e=this.gh(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return H(this._surveyManager)?(ne.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ii})):new Promise(s=>{this.getSurveys(i=>{var r,n=(r=i.find(a=>a.id===t))!==null&&r!==void 0?r:null;if(n){var o=this.gh(n);s({visible:o.eligible,disabledReason:o.reason})}else s({visible:!1,disabledReason:"Survey not found"})},e)})}renderSurvey(t,e,s){var i;if(H(this._surveyManager))ne.warn("init was not called");else{var r=typeof t=="string"?this.fh(t):t;if(r!=null&&r.id)if(Gw.includes(r.type)){var n=A?.querySelector(e);if(n)if((i=r.appearance)!=null&&i.surveyPopupDelaySeconds){ne.info("Rendering survey "+r.id+" with delay of "+r.appearance.surveyPopupDelaySeconds+" seconds");var o=setTimeout(()=>{var a,l;this.th.delete(o),this.ro||(ne.info("Rendering survey "+r.id+" with delay of "+((a=r.appearance)==null?void 0:a.surveyPopupDelaySeconds)+" seconds"),(l=this._surveyManager)==null||l.renderSurvey(r,n,s),ne.info("Survey "+r.id+" rendered"))},1e3*r.appearance.surveyPopupDelaySeconds);this.th.add(o)}else this._surveyManager.renderSurvey(r,n,s);else ne.warn("Survey element not found")}else ne.warn("Surveys of type "+r.type+" cannot be rendered in the app");else ne.warn("Survey not found")}}displaySurvey(t,e){var s;if(H(this._surveyManager))ne.warn("init was not called");else{var i=this.fh(t);if(i){var r=i;if((s=i.appearance)!=null&&s.surveyPopupDelaySeconds&&e.ignoreDelay&&(r=k({},i,{appearance:k({},i.appearance,{surveyPopupDelaySeconds:0})})),e.displayType!==zl.Popover&&e.initialResponses&&ne.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){var n=this.ph(i);if(!n.eligible)return void ne.warn("Survey is not eligible to be displayed: ",n.reason)}e.displayType!==zl.Inline?this._surveyManager.handlePopoverSurvey(r,e):this.renderSurvey(r,e.selector,e.properties)}else ne.warn("Survey not found")}}cancelPendingSurvey(t){H(this._surveyManager)?ne.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t;(t=this._surveyManager)==null||t.handlePageUnload==null||t.handlePageUnload()}};dk=class{constructor(t){this._instance=t,this.mh=new Set,this.yh=new Set,this.bh=new io,this._h=(e,s)=>this.wh(e,s)&&this.kh(e,s)&&this.Sh(e,s)&&this.xh(e,s),this.wh=(e,s)=>s==null||!s.event||e?.event===s?.event}init(){var t,e;S((t=this._instance)==null?void 0:t._addCaptureHook)||(this.Ch=(e=this._instance)==null?void 0:e._addCaptureHook((s,i)=>{this.on(s,i)}))}dispose(){var t;(t=this.Ch)==null||t.call(this),this.Ch=void 0,this.bh=new io}register(t){var e,s;if(!S((e=this._instance)==null?void 0:e._addCaptureHook)&&(t.forEach(r=>{var n;this.mh.add(r),(n=r.steps)==null||n.forEach(o=>{this.yh.add(o?.event||"")})}),(s=this._instance)!=null&&s.autocapture)){var i=new Set;this.mh.forEach(r=>{var n;(n=r.steps)==null||n.forEach(o=>{o!=null&&o.selector&&i.add(o.selector)})}),this._instance.autocapture.setElementSelectors(i)}}replace(t){this.mh.clear(),this.yh.clear(),this.register(t)}on(t,e){e!=null&&t.length!=0&&(this.yh.has(t)||this.yh.has(e.event))&&this.mh.forEach(s=>{this.Th(e,s)&&this.bh.emit("actionCaptured",s.name)})}Mh(t){this.onAction("actionCaptured",e=>t(e))}Th(t,e){if(e?.steps==null)return!1;for(var s of e.steps)if(this._h(t,s))return!0;return!1}onAction(t,e){return this.bh.on(t,e)}kh(t,e){if(e!=null&&e.url){var s,i=t==null||(s=t.properties)==null?void 0:s.$current_url;if(!i||typeof i!="string"||!ri(i,e.url,e.url_matching||"contains"))return!1}return!0}Sh(t,e){return!!this.Ih(t,e)&&!!this.Eh(t,e)&&!!this.Rh(t,e)}Ih(t,e){var s;if(e==null||!e.href)return!0;var i=this.Ah(t);if(i.length>0)return i.some(o=>ri(o.href,e.href,e.href_matching||"exact"));var r,n=(t==null||(s=t.properties)==null?void 0:s.$elements_chain)||"";return!!n&&ri((r=n.match(/(?::|")href="(.*?)"/))?r[1]:"",e.href,e.href_matching||"exact")}Eh(t,e){var s;if(e==null||!e.text)return!0;var i=this.Ah(t);if(i.length>0)return i.some(l=>ri(l.text,e.text,e.text_matching||"exact")||ri(l.$el_text,e.text,e.text_matching||"exact"));var r,n,o,a=(t==null||(s=t.properties)==null?void 0:s.$elements_chain)||"";return!!a&&(r=(function(l){for(var u,c=[],h=/(?::|")text="(.*?)"/g;!H(u=h.exec(l));)c.includes(u[1])||c.push(u[1]);return c})(a),n=e.text,o=e.text_matching||"exact",r.some(l=>ri(l,n,o)))}Rh(t,e){var s,i;if(e==null||!e.selector||t!=null&&(s=t.properties)!=null&&(s=s.$element_selectors)!=null&&s.includes(e.selector))return!0;var r=(t==null||(i=t.properties)==null?void 0:i.$elements_chain)||"";if(e.selector_regex&&r)try{return new RegExp(e.selector_regex).test(r)}catch{return!1}return!1}Ah(t){var e;return(t==null||(e=t.properties)==null?void 0:e.$elements)==null?[]:t?.properties.$elements}xh(t,e){return e==null||!e.properties||e.properties.length===0||kp(e.properties.reduce((s,i)=>{var r=F(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return s[i.key]={values:r,operator:i.operator||"exact"},s},{}),t?.properties)}},hk=class{constructor(t){var e;this.Ph=[],this._instance=t,this.Fh=new Map,this.Oh=new Map,this.$h=new Map,this.Dh=(e=this._instance)==null||e.onSessionId==null?void 0:e.onSessionId(s=>this.Lh(s))}Nh(t){return!1}qh(){return null}jh(t){}Bh(){}Hh(t,e){return!!t&&kp(t.propertyFilters,e?.properties)}zh(t,e){var s=new Map;return t.forEach(i=>{var r;(r=i.conditions)==null||(r=r[e])==null||(r=r.values)==null||r.forEach(n=>{if(n!=null&&n.name){var o=s.get(n.name)||[];o.push(i.id),s.set(n.name,o)}})}),s}Uh(t,e,s){var i=(s===Yi.Activation?this.Fh:this.Oh).get(t),r=[];return this.Wh(n=>{r=n.filter(o=>i?.includes(o.id))}),r.filter(n=>{var o,a=(o=n.conditions)==null||(o=o[s])==null||(o=o.values)==null?void 0:o.find(l=>l.name===t);return this.Hh(a,e)})}register(t){this.Vh(t,!1)}replace(t){this.Vh(t,!0)}Vh(t,e){var s;S((s=this._instance)==null?void 0:s._addCaptureHook)||(this.Gh(t,e),this.Zh(t,e))}Zh(t,e){var s=t.filter(n=>{var o;return(o=n.conditions)==null||(o=o.actions)==null||(o=o.values)==null?void 0:o.length});if(e&&this.$h.clear(),s.length!==0){this.Jh||(this.Jh=new dk(this._instance),this.Jh.init(),this.Jh.Mh(n=>this.onAction(n)));var i=[];s.forEach(n=>{var o;(o=n.conditions)==null||(o=o.actions)==null||o.values.forEach(a=>{if(i.push(a),a.name){var l,u=(l=this.$h.get(a.name))!==null&&l!==void 0?l:[];u.includes(n.id)||u.push(n.id),this.$h.set(a.name,u)}})}),e?this.Jh.replace(i):this.Jh.register(i)}else{var r;e&&((r=this.Jh)==null||r.replace([]))}}Qh(t,e){e.forEach((s,i)=>{var r,n=(r=t.get(i))!==null&&r!==void 0?r:[];s.forEach(o=>{n.includes(o)||n.push(o)}),t.set(i,n)})}Gh(t,e){var s,i,r=t.filter(l=>{var u,c;return((u=l.conditions)==null?void 0:u.events)&&((c=l.conditions)==null||(c=c.events)==null||(c=c.values)==null?void 0:c.length)>0}),n=t.filter(l=>{var u,c;return((u=l.conditions)==null?void 0:u.cancelEvents)&&((c=l.conditions)==null||(c=c.cancelEvents)==null||(c=c.values)==null?void 0:c.length)>0}),o=this.zh(t,Yi.Activation),a=this.zh(t,Yi.Cancellation);e?(this.Fh=o,this.Oh=a):(this.Qh(this.Fh,o),this.Qh(this.Oh,a)),(r.length!==0||n.length!==0)&&((s=this.Ch)!==null&&s!==void 0||(this.Ch=(i=this._instance)==null?void 0:i._addCaptureHook((l,u)=>{this.onEvent(l,u)})))}onEvent(t,e){var s,i,r=this.Kh(),n=(e==null||(s=e.properties)==null?void 0:s.$survey_id)||(e==null||(i=e.properties)==null?void 0:i.$product_tour_id);if(n&&this.getActivatedIds().includes(n)){var o=this.Xh(t,n);if(o==="consume")return r.info("event consumed activated item, removing it",{event:t,itemId:n}),void this.Yh([n]);if(o==="persist")return r.info("shown item promoted to persisted activation",{event:t,itemId:n}),this.td(n),void this.ed([n])}if(this.Oh.has(t)){var a=this.Uh(t,e,Yi.Cancellation);a.length>0&&(r.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map(u=>u.id)}),this.Yh(a.map(u=>u.id)),a.forEach(u=>this.rd(u.id)))}if(this.Fh.has(t)){r.info("event name matched",{event:t,eventPayload:e,items:this.Fh.get(t)});var l=this.Uh(t,e,Yi.Activation);this.nd(l.map(u=>u.id))}}onAction(t){this.$h.has(t)&&this.nd(this.$h.get(t)||[])}nd(t){var e;if(t.length!==0){var s=!((e=this._instance)==null||e.get_session_id==null||!e.get_session_id()),i=[];for(var r of t)s&&this.Nh(r)?this.td(r)&&this.sd(r):i.push(r);i.length>0&&(this.Ph=[...new Set([...this.Ph,...i])]),this.Kh().info("updating activated items",{activatedItems:this.getActivatedIds()})}}td(t){this.Ph=this.Ph.filter(s=>s!==t);var e=this.od();return!e.includes(t)&&(this.ad([...e,t]),this.ld(),!0)}Yh(t){var e=new Set(t);this.Ph=this.Ph.filter(r=>!e.has(r));var s=this.ud(),i=s.filter(r=>!e.has(r));i.length!==s.length&&(this.ad(i),i.length===0&&this.hd()),this.ed(t)}dd(){var t,e=this.qh();if(!e)return{};var s=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[e];return s&&typeof s=="object"?s:{}}sd(t){if(this.qh()){var e=this.dd();this.jh(k({},e,{[t]:Date.now()}))}}ed(t){if(this.qh()){var e=this.dd(),s={},i=!1;for(var r of Object.entries(e)){var n=r[0],o=r[1];t.includes(n)?i=!0:s[n]=o}i&&(nt(s)?this.Bh():this.jh(s))}}vd(){this.qh()&&this.Bh()}getActivationTimestamp(t){if(this.od().includes(t)){var e=this.dd()[t];return Re(e)?e:void 0}}ud(){var t,e=this.fd();return((t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[e])||[]}od(){var t,e,s=this.ud();if(s.length===0)return[];var i=(t=this._instance)==null||(t=t.persistence)==null?void 0:t.props[this.pd()],r=(e=this._instance)==null||e.get_session_id==null?void 0:e.get_session_id();return r&&i===r?s:[]}ld(){var t,e=(t=this._instance)==null||t.get_session_id==null?void 0:t.get_session_id();e&&this.gd(e)}hd(){this.md()}Lh(t){var e,s=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.props[this.pd()];if(s&&s!==t){var i=this.ud(),r=this.dd();i.length>0&&(this.ad([]),i.filter(n=>Re(r[n])).forEach(n=>this.rd(n))),this.hd(),this.vd()}}getActivatedIds(){return[...new Set([...this.od(),...this.Ph])].filter(t=>!this.yd(t))}dispose(){var t,e,s;(t=this.Dh)==null||t.call(this),this.Dh=void 0,(e=this.Ch)==null||e.call(this),this.Ch=void 0,(s=this.Jh)==null||s.dispose(),this.Jh=void 0}reset(){this.Ph=[],this.ud().length>0&&this.ad([]),this.hd(),this.vd()}getEventToItemsMap(){return this.Fh}bd(){return this.Jh}},fk=class extends hk{constructor(t){super(t)}fd(){return Ll}pd(){return Dn}qh(){return Nn}jh(t){var e;(e=this._instance)==null||(e=e.persistence)==null||e.register({[Nn]:t})}Bh(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Nn)}Nh(t){var e,s;this.Wh(r=>{s=r.find(n=>n.id===t)});var i=(e=s)==null||(e=e.appearance)==null?void 0:e.surveyPopupDelaySeconds;return Re(i)&&i>0}_d(){return Jt.SHOWN}Wh(t){var e;(e=this._instance)==null||e.getSurveys(t)}rd(t){var e;(e=this._instance)==null||e.cancelPendingSurvey(t)}Kh(){return ne}ad(t){var e;(e=this._instance)==null||(e=e.persistence)==null||e.register({[Ll]:t})}gd(t){var e;(e=this._instance)==null||(e=e.persistence)==null||e.register({[Dn]:t})}md(){var t;(t=this._instance)==null||(t=t.persistence)==null||t.unregister(Dn)}yd(){return!1}Xh(t,e){var s;return this.Wh(i=>{s=i.find(r=>r.id===e)}),!s||(function(i){var r;return Sp(i)&&!((r=i.conditions)==null||(r=r.events)==null||!r.repeatedActivation)||i.schedule==="always"})(s)?t===Jt.SHOWN?"consume":"ignore":t===Jt.SHOWN?"persist":t===Jt.DISMISSED||t===Jt.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},gk=class{constructor(t){this._instance=t}initialize(){}get(t){if(typeof t=="string")return this._instance.get_property(t);var e={};for(var s of t){var i=this._instance.get_property(s);S(i)||(e[s]=i)}return e}set(t,e){this._instance.register(typeof t=="string"?{[t]:e}:t)}remove(t){typeof t!="string"?t.forEach(e=>this._instance.unregister(e)):this._instance.unregister(t)}},pk=class{constructor(t){this._instance=t}get(){var t=this._instance.config;return{disableSurveys:t.disable_surveys,cookielessMode:!!t.cookieless_mode,advancedEnableSurveys:t.advanced_enable_surveys,requestTimeoutMs:t.surveys_request_timeout_ms}}isOptedOut(){return this._instance.consent.isOptedOut()}getExtensions(){var t=L?.__PosthogExtensions__;if(t){var e=t.generateSurveys,s=t.loadExternalDependency;return{generateSurveys:e?i=>e(this._instance,i):void 0,loadExternalDependency:s?i=>s(this._instance,"surveys",i):void 0}}}createEventReceiver(){return new fk(this._instance)}},vk=b!=null&&b.location?Zn(b.location.hash,"__posthog")||Zn(location.hash,"state"):null,Sf="_postHogToolbarParams",wf=Te("[Toolbar]"),kf=Te("[FeatureFlags]"),_k=class{constructor(t,e){e===void 0&&(e=!1),this.wd=!1,this.update(t,e)}update(t,e){this.kd=((s,i)=>{var r,n,o,a,l;return{bootstrap:{featureFlags:(r=s.bootstrap)==null?void 0:r.featureFlags,featureFlagPayloads:(n=s.bootstrap)==null?void 0:n.featureFlagPayloads},remoteRequestsDisabled:i,featureFlagsDisabled:!!s.advanced_disable_feature_flags,onlyEvaluateSurveyFeatureFlags:!!s.advanced_only_evaluate_survey_feature_flags,deduplicateCallsPerSession:!!s.advanced_feature_flags_dedup_per_session,cacheTtlMs:s.feature_flag_cache_ttl_ms,refreshIntervalMs:(o=s.remote_config_refresh_interval_ms)!==null&&o!==void 0?o:3e5,requestTimeoutMs:s.feature_flag_request_timeout_ms,compression:s.disable_compression?void 0:"best-available",evaluationContexts:(a=(l=s.evaluation_contexts)!==null&&l!==void 0?l:s.evaluation_environments)!==null&&a!==void 0?a:[],flagKeys:F(s.flag_keys)?s.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.wd||(kf.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.wd=!0),S(t.flag_keys)||F(t.flag_keys)||kf.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.kd}},Af=Te("[FeatureFlags]"),As=Te("[FeatureFlags]",{debugEnabled:!0}),pl=`" failed. Feature flags didn't load in time.`,If="connection_error",Rf=t=>{for(var e={},s=0;t.length>s;s++)e[t[s]]=!0;return e},Tf=t=>{var e={};for(var s of $n(t||{})){var i=s[1];i&&(e[s[0]]=i)}return e},Of=t=>mr(t)&&(t.name==="RangeError"&&t.message.indexOf("Maximum call stack size exceeded")===0||t.name==="InternalError"&&t.message==="too much recursion"),yt=Te("[Error tracking]"),Ql="webkit-masked-url:",mk=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],yk=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Ql],bk=["__firefox__","__gCrWeb"],Pf="Refusing to render web experiment since the viewer is a likely bot",Ek={icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())>-1,not_icontains:(t,e)=>e.toLowerCase().indexOf(t.toLowerCase())===-1,regex:(t,e)=>ro(e,t),not_regex:(t,e)=>!ro(e,t),exact:(t,e)=>e===t,is_not:(t,e)=>e!==t},gt=Te("[Conversations]"),Is="Conversations not available yet.";Sk=["debug","log","warn","error","info"],xf="console",Cp="__posthogHandledLogsRequestError",vl=(t,e)=>{var s=t instanceof Error?t:new Error(e);return s[Cp]=!0,s},Df=t=>!!t&&typeof t=="object"&&t[Cp]===!0,co={featureFlags:class{constructor(t){this.name="featureFlags",this.Sd=!1,this.featureFlagEventHandlers=[],this.A=Af,this.xd={},this.Cd={},this.Td=[],this.Md=!1,this.Id=!1,this.Ed=0,this.Rd=!1,this.Ad=!1,this.Pd=!1,this.Fd=!1,this.Od=0,this.nr=()=>{var e=this.$d();this.Od=0,e&&this.reloadFeatureFlags()},this.Dd=()=>{var e,s=this.Ld;S(s)||this.Rn.remoteRequestsDisabled||!A||A.visibilityState==="hidden"||Date.now()-((e=this.Nd)!==null&&e!==void 0?e:0)<s||(this.reloadFeatureFlags(),this.qd())},this.ar=()=>{A?.visibilityState==="visible"&&this.Dd()},"get"in t?this.Ks=t:(this._instance=t,this.jd=new _k(t.config,t.Fa()),this.Ks=this.jd)}updateConfig(t,e){var s;(s=this.jd)==null||s.update(t,e),this.Js&&this.Bd()}setup(t){return this.ih=t,this.A=t.logger.createLogger("[FeatureFlags]"),Pp(t.kv.initialize(),()=>{this.ih===t&&(this.ih=void 0,this.Js=t,this.Hd(t))})}Hd(t){var e;if(this.Js===t)return b&&ae(b,"online",this.nr),this.Bd(),this.zd=t.registerDynamicEventProperties(()=>this.Ud()?this.xd:this.Cd),this.Wd=(e=this._instance)==null||(e=e.persistence)==null?void 0:e.onCrossTabFeatureFlagChange(()=>{this.Vd(),this.Gd(),this.Zd()}),this.Gd(),this.initialize()}Bd(){var t=this.Rn.refreshIntervalMs,e=!this.Rn.remoteRequestsDisabled&&A&&!S(t)&&t>0?t:void 0;e!==this.Ld&&(this.Jd(),S(e)||(this.Ld=e,this.qd(),A!=null&&A.addEventListener&&ae(A,hi,this.ar)))}qd(){S(this.Ld)||(S(this.Qd)||clearInterval(this.Qd),this.Nd=Date.now(),this.Qd=setInterval(this.Dd,this.Ld))}Jd(){S(this.Qd)||(clearInterval(this.Qd),this.Qd=void 0,A==null||A.removeEventListener==null||A.removeEventListener(hi,this.ar)),this.Ld=void 0,this.Nd=void 0}destroy(){this.Kd()}dispose(){this.Kd()}Kd(){var t,e;this.Jd(),this.Ed++,this.Ad=!1,this.ih=void 0,this.Js&&(this.Xd(),(t=this.zd)==null||t.dispose(),this.zd=void 0,(e=this.Wd)==null||e.call(this),this.Wd=void 0,this.Td=[],b?.removeEventListener("online",this.nr),this.Js=void 0)}get Rn(){return this.Ks.get()}Yd(t){var e;return this.tv&&t in this.tv?this.tv[t]:(e=this.Js)==null?void 0:e.kv.get(t)}Vd(){return!!this.tv&&(this.tv=void 0,!0)}ev(){var t;return!S((t=this.Js)==null?void 0:t.kv.get("$enabled_feature_flags"))&&this.Vd()}Ot(t){this.iv(()=>{var e;return(e=this.Js)==null?void 0:e.kv.set(t)})}rv(t,e,s){var i;if((i=this._instance)!=null&&i.persistence&&t.$enabled_feature_flags){var r=this.Yd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},o=e.flags||e.featureFlags,a=e.flags?Object.entries(e.flags).filter(y=>{var w=y[1];return!(w!=null&&w.failed)}).map(y=>y[0]):[],l=!!e.errorsWhileComputingFlags&&!!e.flags,u=l?a:s&&!F(o)?Object.keys(o||{}):Array.from(new Set([...Object.keys(r),...Object.keys(n)])),c=this.Yd("$feature_flag_payloads")||{},h=t.$feature_flag_payloads||{},g=l||s?u:Array.from(new Set([...Object.keys(c),...Object.keys(h)])),f=!l&&!s,p=!!f||u,_=!!f||g,v={[Ct]:p,[pt]:p,[as]:_};for(var m of(t.$feature_flag_details&&(v[Ps]=p),[Cs,cs,nr]))S(t[m])||(v[m]=!0);this._instance.persistence.markCrossTabFeatureFlagChanges(v)}}Dt(t){this.iv(()=>{var e;return(e=this.Js)==null?void 0:e.kv.remove(t)})}iv(t){try{t()}catch(e){this.A.error("Failed to update feature flag persistence",e)}}Gd(){var t={};for(var e of[Ct,as,Cs,Ot]){var s=this.Yd(e);S(s)||(t[e]=s)}this.xd=t;var i=k({},t),r=this.Yd(pt);if(r)for(var n of Object.entries(r))i["$feature/"+n[0]]=n[1];this.Cd=i}Ud(){var t=this.Rn.cacheTtlMs;if(!t||0>=t)return!1;var e=this.Yd(cs);return typeof e!="number"||Date.now()-e>t}nv(){return!!this.Ud()&&(this.Fd||this.Id||(this.Fd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}sv(){var t=this.Rn.evaluationContexts;return t!=null&&t.length?t.filter(e=>{var s=e&&typeof e=="string"&&e.trim().length>0;return s||this.A.error("Invalid evaluation context found:",e,"Expected non-empty string"),s}):[]}ov(){var t=this.Rn.flagKeys;if(!S(t))return t.filter(e=>{var s=e&&typeof e=="string"&&e.trim().length>0;return s||this.A.error("Invalid flag key found:",e,"Expected non-empty string"),s})}initialize(){var t,e,s=this.Rn,i=(t=(e=s.bootstrap)==null?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(i).length){var r,n,o=(r=(n=s.bootstrap)==null?void 0:n.featureFlagPayloads)!==null&&r!==void 0?r:{},a=Object.keys(i).filter(u=>!S(i[u])).reduce((u,c)=>(u[c]=i[c],u),{}),l=Object.keys(o).filter(u=>a[u]).reduce((u,c)=>(u[c]=o[c],u),{});return this.av({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,e,s){var i,r,n=s!=null&&s.merge&&(i=this.Yd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s!=null&&s.merge&&(r=this.Yd("$feature_flag_payloads"))!==null&&r!==void 0?r:{},a=k({},n,t),l=k({},o,e),u={};for(var c of Object.entries(a)){var h=c[0],g=c[1];u[h]={key:h,enabled:Ah(g),variant:Ih(g),reason:void 0,metadata:S(l?.[h])?void 0:{id:0,version:void 0,description:void 0,payload:l[h]}}}this.av({flags:u})}get hasLoadedFlags(){return this.Md}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){var t=this.Yd(Ps),e=this.Yd(Ot),s=this.Yd(Ts);if(!s&&!e)return t||{};var i=fe({},t||{});for(var r of[...new Set([...Object.keys(s||{}),...Object.keys(e||{})])]){var n,o,a=i[r],l=e?.[r],u=S(l)?(n=a?.enabled)!==null&&n!==void 0&&n:!!l,c=S(l)?a?.variant:typeof l=="string"?l:void 0,h=s?.[r],g=k({},a,{enabled:u,variant:u?c??a?.variant:void 0});u!==a?.enabled&&(g.original_enabled=a?.enabled),c!==a?.variant&&(g.original_variant=a?.variant),h&&(g.metadata=k({},a?.metadata,{payload:h,original_payload:a==null||(o=a.metadata)==null?void 0:o.payload})),i[r]=g}return this.Sd||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:s,finalDetails:i}),this.Sd=!0),i}getAllFeatureFlags(){var t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(s=>{var i=t[s];return{key:s,enabled:Ah(i),variant:Ih(i),payload:kh(e[s])}})}getFlagVariants(){var t=this.Yd(pt),e=this.Yd(Ot);if(!e)return t||{};for(var s=fe({},t||{}),i=Object.keys(e),r=0;i.length>r;r++)s[i[r]]=e[i[r]];return this.Sd||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:s}),this.Sd=!0),s}getFlagPayloads(){var t=this.Yd(as),e=this.Yd(Ts);if(!e)return t||{};for(var s=fe({},t||{}),i=Object.keys(e),r=0;i.length>r;r++)s[i[r]]=e[i[r]];return this.Sd||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:s}),this.Sd=!0),s}reloadFeatureFlags(){this.Rd||this.Rn.featureFlagsDisabled||this.$d()||(this.Id&&(this.Ad=!0),this.lv||(this.Td.slice().forEach(t=>{try{t()}catch(e){this.A.error("Error while running feature flags reloading callback",e)}}),this.lv=setTimeout(()=>{this.uv()},5)))}Xd(){clearTimeout(this.lv),this.lv=void 0}onReloading(t){return this.Td.push(t),()=>{this.Td=this.Td.filter(e=>e!==t)}}ensureFlagsLoaded(){this.Md||this.Id||this.lv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.Rd=t}resetFlagCallReported(){this.Dt(us)}uv(t){this.Xd();var e=this.Js;if(e&&!this.Rn.remoteRequestsDisabled&&!this.$d())if(this.Id)this.Ad=!0;else{var s={token:e.projectToken,distinct_id:e.distinctId,groups:e.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:k({},e.initialPersonProperties,this.Yd("$stored_person_properties")||{},{$lib:e.library.name,$lib_version:e.library.version}),group_properties:this.Yd(ls),timezone:ap()};S(e.deviceId)||(s.$device_id=e.deviceId),(t!=null&&t.disableFlags||this.Rn.featureFlagsDisabled)&&(s.disable_flags=!0);var i=this.sv();i.length&&(s.evaluation_contexts=i);var r=this.ov();S(r)||(s.flag_keys=r);var n=this.Rn.onlyEvaluateSurveyFeatureFlags,o="/flags/?v=2"+(n?"&only_evaluate_survey_feature_flags=true":""),a=this.Ed;this.Id=!0;var l=()=>{this.Ad&&(this.Ad=!1,this.uv())},u=c=>{this.Id=!1,a===this.Ed&&(this.Ot({[fr]:[If]}),this.A.error("Feature flag request failed",c),this.ev()&&this.Zd(!0)),l()};try{e.sendRequest(o,{target:"flags",method:"POST",body:s,compression:this.Rn.compression,sentAt:"body",timeoutMs:this.Rn.requestTimeoutMs}).then(c=>{var h,g,f=(h=c.json)!==null&&h!==void 0?h:{},p=c.statusCode!==200;if(this.Id=!1,a===this.Ed){if(this.hv(c.statusCode),p||this.Ad||(this.$anon_distinct_id=void 0),!s.disable_flags||this.Ad){this.Pd=!p;var _=[];c.error?_.push(c.error instanceof Error&&c.error.name==="AbortError"?"timeout":c.error instanceof Error?If:"unknown_error"):c.statusCode!==200&&_.push("api_error_"+c.statusCode),f.errorsWhileComputingFlags&&_.push("errors_while_computing_flags");var v=!((g=f.quotaLimited)==null||!g.includes("feature_flags"));v&&_.push("quota_limited"),this.Ot({[fr]:_}),v?this.A.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."):s.disable_flags||this.av(f,p,{partialResponse:n}),l()}}else l()}).catch(u)}catch(c){u(c)}}}$d(){return Zg(this.Od,3)}hv(t){this.Od=ep(t,this.Od,3,()=>this.A.warn("Feature flag requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped refreshing feature flags; will try again when connectivity changes."))}getFeatureFlag(t,e){var s;if(e===void 0&&(e={}),!e.fresh||this.Pd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.nv()){var i=this.getFeatureFlagResult(t,e);return(s=i?.variant)!==null&&s!==void 0?s:i?.enabled}}else this.A.warn('getFeatureFlag for key "'+t+pl)}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){var e;return(e=this.getFeatureFlagResult(t,{send_event:!1}))==null?void 0:e.payload}getFeatureFlagResult(t,e){if(e===void 0&&(e={}),!e.fresh||this.Pd)if(this.Md||this.getFlags()&&this.getFlags().length>0){if(!this.nv()){var s,i=this.getFlagVariants(),r=t in i,n=i[t],o=this.getFlagPayloads()[t],a=String(n),l=this.Yd("$feature_flag_request_id")||void 0,u=this.Yd("$feature_flag_evaluated_at")||void 0,c=this.Yd("$flag_call_reported")||{};if(this.Rn.deduplicateCallsPerSession){var h,g=(h=this.Js)==null?void 0:h.session.sessionId,f=this.Yd(tr);g&&g!==f&&(c={},s=g)}if(e.send_event||!("send_event"in e))if(t in c&&c[t].includes(a))s&&this.Ot({[us]:c,[tr]:s});else{var p,_,v,m,y,w,E,T,C,q,x,le,D;F(c[t])?c[t].push(a):c[t]=[a],this.Ot(k({[us]:c},s?{[tr]:s}:{}));var P=this.getFeatureFlagDetails(t),G=[...(p=this.Yd("$feature_flag_errors"))!==null&&p!==void 0?p:[]];S(n)&&G.push("flag_missing");var N={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:o??null,$feature_flag_request_id:l,$feature_flag_evaluated_at:u,$feature_flag_bootstrapped_response:(_=(v=this.Rn.bootstrap)==null||(v=v.featureFlags)==null?void 0:v[t])!==null&&_!==void 0?_:null,$feature_flag_bootstrapped_payload:(m=(y=this.Rn.bootstrap)==null||(y=y.featureFlagPayloads)==null?void 0:y[t])!==null&&m!==void 0?m:null,$used_bootstrap_value:!this.Pd};S(P==null||(w=P.metadata)==null?void 0:w.has_experiment)||(N.$feature_flag_has_experiment=P.metadata.has_experiment),S(P==null||(E=P.metadata)==null?void 0:E.version)||(N.$feature_flag_version=P.metadata.version);var U=(T=P==null||(C=P.reason)==null?void 0:C.description)!==null&&T!==void 0?T:P==null||(q=P.reason)==null?void 0:q.code;U&&(N.$feature_flag_reason=U),P!=null&&(x=P.metadata)!=null&&x.id&&(N.$feature_flag_id=P.metadata.id),S(P?.original_variant)&&S(P?.original_enabled)||(N.$feature_flag_original_response=S(P.original_variant)?P.original_enabled:P.original_variant),P!=null&&(le=P.metadata)!=null&&le.original_payload&&(N.$feature_flag_original_payload=P==null||(D=P.metadata)==null?void 0:D.original_payload),G.length&&(N.$feature_flag_error=G.join(",")),this.dv(N)}else s&&this.Ot({[us]:c,[tr]:s});if(r)return{key:t,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:kh(o)}}}else this.A.warn('getFeatureFlagResult for key "'+t+pl)}dv(t){try{var e;(e=this.Js)==null||e.capture("$feature_flag_called",t).catch(s=>{this.A.error("Failed to capture feature flag call",s)})}catch(s){this.A.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(t,e){this.vv(t,e)}vv(t,e){var s=this;return ge(function*(){var i=s.Js;if(i){var r={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},n=s.sv();n.length&&(r.evaluation_contexts=n);var o,a=s.ov();S(a)||(r.flag_keys=a);try{var l;o=((l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:r,compression:s.Rn.compression,sentAt:"body",timeoutMs:s.Rn.requestTimeoutMs})).json)==null||(l=l.featureFlagPayloads)==null?void 0:l[t])||void 0}catch(u){return void s.A.error("Remote config feature flag request failed",u)}try{e(o)}catch(u){s.A.error("Remote config feature flag callback failed",u)}}})()}isFeatureEnabled(t,e){if(e===void 0&&(e={}),e.fresh&&!this.Pd)return e.defaultValue;if(!(this.Md||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+pl),e.defaultValue;var s=this.getFeatureFlag(t,e);return S(s)?e.defaultValue:!!s}addFeatureFlagsHandler(t){this.featureFlagEventHandlers.push(t)}removeFeatureFlagsHandler(t){this.featureFlagEventHandlers=this.featureFlagEventHandlers.filter(e=>e!==t)}receivedFeatureFlags(t,e,s){this.av(t,e,s)}av(t,e,s){if(this.Js){this.Md=!0;var i=(function(n,o,a,l,u,c){o===void 0&&(o={}),a===void 0&&(a={}),l===void 0&&(l={}),c===void 0&&(c=Af);var h=((D,P)=>{var G=D.flags;return G?k({},D,{featureFlags:Object.fromEntries(Object.keys(G).map(N=>{var U;return[N,(U=G[N].variant)!==null&&U!==void 0?U:G[N].enabled]})),featureFlagPayloads:Object.fromEntries(Object.keys(G).filter(N=>G[N].enabled).filter(N=>{var U;return!S((U=G[N].metadata)==null?void 0:U.payload)}).map(N=>{var U;return[N,(U=G[N].metadata)==null?void 0:U.payload]}))}):(D.featureFlags&&P.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),D)})(n,c),g=h.flags,f=h.featureFlags,p=h.featureFlagPayloads;if(f){var _=n.requestId,v=n.evaluatedAt;if(F(f)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");var m={};if(f)for(var y=0;f.length>y;y++)m[f[y]]=!0;return{[Ct]:f,[pt]:m,[nr]:!1}}var w=f,E=p,T=g;if(u!=null&&u.partialResponse){var C=Object.keys(w),q=E||{};w=k({},o,w),E=k({},a,q),C.forEach(D=>{var P;D in q||(P=E)==null||delete P[D]}),T=k({},l,T)}else if(n.errorsWhileComputingFlags)if(g){var x=new Set(Object.keys(g).filter(D=>{var P;return!((P=g[D])!=null&&P.failed)}));w=k({},o,Object.fromEntries(Object.entries(w).filter(D=>x.has(D[0]))));var le=Object.fromEntries(Object.entries(E||{}).filter(D=>x.has(D[0])));E=k({},a,le),x.forEach(D=>{var P;D in le||(P=E)==null||delete P[D]}),T=k({},l,Object.fromEntries(Object.entries(T||{}).filter(D=>x.has(D[0]))))}else w=k({},o,w),E=k({},a,E),T=k({},l,T);return k({[Ct]:Object.keys(Tf(w)),[pt]:w||{},[as]:E||{},[Ps]:T||{},[nr]:n.minimalFlagCalledEvents===!0},_?{[Cs]:_}:{},v?{[cs]:v}:{})}})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.A);if(i)if(s?.persist===!1){var r=!S(this.Js.kv.get(pt));this.tv=i,r||this.Ot(i)}else this.Vd(),this.rv(i,t,!(s==null||!s.partialResponse)),this.Ot(i);else e&&this.ev();e||(this.Fd=!1),this.Zd(e)}}override(t,e){e===void 0&&(e=!1),this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.fv(t)}fv(t){if(this.Js){if(t===!1)return this.Dt([Ot,Ts]),this.Zd(),void As.info("All overrides cleared");if(F(t))return this.Ot({[Ot]:Rf(t)}),this.Zd(),void As.info("Flag overrides set",{flags:t});if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var e,s=t;this.Sd=!!((e=s.suppressWarning)!==null&&e!==void 0&&e);var i={},r=s.flags,n=s.payloads;return r&&(i[Ot]=F(r)?Rf(r):r),n&&(i[Ts]=n),Object.keys(i).length&&this.Ot(i),r===!1&&n===!1?this.Dt([Ot,Ts]):r===!1?this.Dt(Ot):n===!1&&this.Dt(Ts),this.Zd(),r===!1?As.info("Flag overrides cleared"):r&&As.info("Flag overrides set",{flags:r}),void(n===!1?As.info("Payload overrides cleared"):n&&As.info("Payload overrides set",{payloads:n}))}if(t&&typeof t=="object")return this.Ot({[Ot]:t}),this.Zd(),void As.info("Flag overrides set",{flags:t});this.A.warn("Invalid overrideOptions provided to overrideFeatureFlags",{overrideOptions:t})}else this.A.warn("posthog.featureFlags.overrideFeatureFlags called before feature flags were ready")}onFeatureFlags(t){if(this.addFeatureFlagsHandler(t),this.Md){var e=this.pv(),s=e.flags,i=e.flagVariants;try{t(s,i)}catch(r){this.A.error("Error while running feature flags callback",r)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,s){var i,r=(this.Yd("$early_access_features")||[]).find(u=>u.flagKey===t),n={["$feature_enrollment/"+t]:e},o={$feature_flag:t,$feature_enrollment:e,$set:n};r&&(o.$early_access_feature_name=r.name),s&&(o.$feature_enrollment_stage=s);var a=k({},this.getFlagVariants(),{[t]:e});(i=this._instance)==null||(i=i.persistence)==null||i.markCrossTabFeatureFlagChanges({[Ct]:[t],[pt]:[t],[Wt]:Object.keys(n)}),this.Ot({[Ct]:Object.keys(Tf(a)),[pt]:a,[Wt]:k({},this.Yd("$stored_person_properties")||{},n)}),this.Zd();try{var l;(l=this.Js)==null||l.capture("$feature_enrollment_update",o).catch(u=>{this.A.error("Failed to capture early access feature enrollment",u)})}catch(u){this.A.error("Failed to capture early access feature enrollment",u)}}getEarlyAccessFeatures(t,e,s){e===void 0&&(e=!1);var i=this.Yd(Dl);!i||e?this.gv(t,s):t(i)}gv(t,e){var s=this;return ge(function*(){var i=s.Js;if(i){var r,n=e?"&"+e.map(a=>"stage="+a).join("&"):"";try{var o=yield i.sendRequest("/api/early_access_features/?token="+i.projectToken+n,{target:"api",method:"GET",sentAt:"query"});if(!o.json)return;r=o.json.earlyAccessFeatures,s.Ot({[Dl]:r})}catch(a){return void s.A.error("Early access feature request failed",a)}try{t(r)}catch(a){s.A.error("Early access feature callback failed",a)}}})()}pv(){var t=this.getFlags(),e=this.getFlagVariants();return{flags:t.filter(s=>e[s]),flagVariants:Object.keys(e).filter(s=>e[s]).reduce((s,i)=>(s[i]=e[i],s),{})}}Zd(t){this.Gd();var e=this.pv(),s=e.flags,i=e.flagVariants;this.featureFlagEventHandlers.forEach(r=>{try{r(s,i,{errorsLoading:t})}catch(n){this.A.error("Error while running feature flags callback",n)}})}setPersonPropertiesForFlags(t,e){e===void 0&&(e=!0),this.mv(t,e)}mv(t,e){e===void 0&&(e=!0);var s=this.Yd("$stored_person_properties")||{},i=t?.$set||(t!=null&&t.$set_once?{}:t),r=t?.$set_once,n={};if(r)for(var o in r)({}).hasOwnProperty.call(r,o)&&(o in s||(n[o]=r[o]));this.Ot({[Wt]:k({},s,n,i)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e){e===void 0&&(e=!0);var s=k({},this.Yd("$stored_person_properties")||{});t.forEach(i=>{delete s[i]}),this.Ot({[Wt]:s}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t){t===void 0&&(t=!0),this.Dt(Wt),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e){e===void 0&&(e=!0);var s=this.Yd("$stored_group_properties")||{},i=k({},s);for(var r of Object.keys(t))i[r]=k({},s[r],t[r]);this.Ot({[ls]:i}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.Yd("$stored_group_properties")||{};this.Ot({[ls]:k({},e,{[t]:{}})})}else this.Dt(ls)}reset(){this.Ed++,this.Ad=!1,this.xd={},this.Cd={},this.tv=void 0,this.Md=!1,this.Rd=!1,this.Pd=!1,this.$anon_distinct_id=void 0,this.Xd(),this.Sd=!1,this.Od=0}}},wk={sessionRecording:class{get Rn(){return this._instance.config}get sl(){return this._instance.persistence}get started(){var t;return!((t=this.yv)==null||!t.isStarted)}get status(){var t,e;return this.bv==="awaiting_config"||this.bv==="missing_config"?this.bv:(t=(e=this.yv)==null?void 0:e.status)!==null&&t!==void 0?t:this.bv}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.bv=Tn,this._v=void 0,this.wv=!1,this.Ke=(()=>{var e;if(A==null||!A.visibilityState||A.visibilityState==="visible")return!0;var s=b==null||(e=b.performance)==null||e.getEntriesByType==null?void 0:e.getEntriesByType("visibility-state");return!(s!=null&&s.length)||s.some(i=>i.name==="visible")})(),this.ar=()=>{var e;A?.visibilityState==="visible"&&(this.Ke=!0,(e=this.yv)==null||e.setDocumentWasEverVisible==null||e.setDocumentWasEverVisible(!0))},!this._instance.sessionManager)throw qt.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Rn.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');A!=null&&A.addEventListener&&ae(A,"visibilitychange",this.ar)}initialize(){this.startIfEnabledOrStop()}dispose(t){var e=(t===void 0?{}:t).discardBufferedEvents,s=e!==void 0&&e;this.wv=!0,A==null||A.removeEventListener==null||A.removeEventListener("visibilitychange",this.ar),s?this.Sv(!0):this.stopRecording()}get xv(){var t,e=!((t=this._instance.get_property(ui))==null||!t.enabled),s=!this.Rn.disable_session_recording,i=this.Rn.disable_session_recording||this._instance.consent.isOptedOut();return b&&e&&s&&!i}startIfEnabledOrStop(t){var e;if(!(this.wv||this.xv&&(e=this.yv)!=null&&e.isStarted)){var s=!S(Object.assign)&&!S(Array.from);this.xv&&s?(this.Cv(t),qt.info("starting")):(this.bv=Tn,this.stopRecording())}}Cv(t){var e,s;if(this.xv)if(this.bv!=="awaiting_config"&&this.bv!=="missing_config"&&(this.bv=yf),L!=null&&(e=L.__PosthogExtensions__)!=null&&(e=e.rrweb)!=null&&e.record&&(s=L.__PosthogExtensions__)!=null&&s.initSessionRecording)this.Tv(t);else{var i,r=this._instance.sessionManager;(i=L.__PosthogExtensions__)==null||i.loadExternalDependency==null||i.loadExternalDependency(this._instance,this.Mv,n=>{if(!this.wv&&this.xv&&this._instance.sessionManager===r)return n?(this._instance.register_for_session({[Fl]:!0}),qt.error("could not load recorder",n)):void this.Tv(t);this.bv=Tn})}}stopRecording(){var t,e;(t=this._v)==null||t.call(this),this._v=void 0,(e=this.yv)==null||e.stop()}Sv(t){var e,s;t===void 0&&(t=!1),(e=this._v)==null||e.call(this),this._v=void 0,(s=this.yv)==null||s.discard({discardProducerEvents:t})}Iv(){var t,e;(t=this.sl)==null||t.unregister(au),(e=this.sl)==null||e.unregister(Rg)}Ev(t,e){if(H(t))return null;var s,i=Re(t)?t:parseFloat(t);return typeof(s=i)!="number"||!Number.isFinite(s)||0>s||s>1?(qt.warn(e+" must be between 0 and 1. Ignoring invalid value:",t),null):i}Rv(t){if(this.sl){var e,s,i=this.sl,r=()=>{var n,o=t.sessionRecording===!1?void 0:t.sessionRecording,a=this.Ev((n=this.Rn.session_recording)==null?void 0:n.sampleRate,"session_recording.sampleRate"),l=this.Ev(o?.sampleRate,"remote config sampleRate"),u=a??l;H(u)&&this.Iv();var c=o?.minimumDurationMilliseconds;i.register({[ui]:k({cache_timestamp:Date.now(),enabled:!!o},o,{networkPayloadCapture:k({capturePerformance:t.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:u,minimumDurationMilliseconds:S(c)?null:c,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};r(),(e=this._v)==null||e.call(this),this._v=(s=this._instance.sessionManager)==null?void 0:s.onSessionId(r)}}onRemoteConfig(t){var e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.Rv(e),void this.Sv()):(this.Rv(e),void this.startIfEnabledOrStop()):(this.bv==="awaiting_config"&&(this.bv="missing_config",qt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e){var s;e===void 0&&(e="log"),(s=this.yv)!=null&&s.log?this.yv.log(t,e):qt.warn("log called before recorder was ready")}get Mv(){var t;return((t=this._instance)==null||(t=t.persistence)==null||(t=t.get_property("$session_recording_remote_config"))==null||(t=t.scriptConfig)==null?void 0:t.script)||"lazy-recorder"}Av(){var t,e=this._instance.get_property(ui);if(!e)return!1;try{t=typeof e=="object"?e:JSON.parse(e)}catch(s){return qt.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!H(t.cache_timestamp)&&36e5>=Date.now()-t.cache_timestamp}Tv(t){var e,s,i;if(!this.wv&&this.xv&&this._instance.sessionManager){if((e=L.__PosthogExtensions__)==null||!e.initSessionRecording)return qt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[Fl]:!0});var r;if(this.yv||(this.yv=(r=L.__PosthogExtensions__)==null?void 0:r.initSessionRecording(this._instance,this.Ke),this.yv._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.Av())return this.bv==="missing_config"||this.bv==="awaiting_config"?void 0:(this.bv="awaiting_config",qt.info("persisted remote config is stale, requesting fresh config before starting"),void new lp(this._instance).load());this.bv=yf,(s=(i=this.yv).setDocumentWasEverVisible)==null||s.call(i,this.Ke),this.yv.start(t)}else this.bv=Tn}onRRwebEmit(t){var e;(e=this.yv)==null||e.onRRwebEmit==null||e.onRRwebEmit(t)}overrideLinkedFlag(){var t,e;this.yv||(t=this.sl)==null||t.register({[Og]:!0}),(e=this.yv)==null||e.overrideLinkedFlag()}overrideSampling(){var t,e;this.yv||(t=this.sl)==null||t.register({[Tg]:!0}),(e=this.yv)==null||e.overrideSampling()}overrideTrigger(t){var e,s;this.yv||(e=this.sl)==null||e.register({[t==="url"?Pg:Cg]:!0}),(s=this.yv)==null||s.overrideTrigger(t)}get sdkDebugProperties(){var t;return((t=this.yv)==null?void 0:t.sdkDebugProperties)||{$recording_status:this.status}}tryAddCustomEvent(t,e){var s;return!((s=this.yv)==null||!s.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t;(t=this.yv)==null||t.flushBeforeIdentityReset==null||t.flushBeforeIdentityReset()}}},kk={autocapture:class extends rk{constructor(t){super(new nk(t)),this.instance=t}},historyAutocapture:class{constructor(t){this._instance=t,this.Pv=this.Fv()}initialize(){this.startIfEnabled()}get isEnabled(){var t=this.Ov();return!!(t.path||t.search||this.$v(t))}startIfEnabled(){this.isEnabled&&(I.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.Pv=this.Fv(),this.startIfEnabled()}stop(){this.Dv&&this.Dv(),this.Dv=void 0,this.Lv&&this.Lv(),this.Lv=void 0,I.info("History API monitoring stopped")}monitorHistoryChanges(){b&&b.history&&(this.Nv("pushState"),this.Nv("replaceState"),this.qv(),this.$v()&&this.jv())}Nv(t){var e;if(b&&((e=b.history[t])==null||!e.__posthog_wrapped__)){var s=this;Op(b.history,t,i=>function(r,n,o){i.call(this,r,n,o),s.Bv(t)})}}Fv(){var t=b?.location;if(t!=null&&t.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}Ov(){var t=this._instance.config.capture_pageview;return t==="history_change"?{path:!0}:Y(t)?t:{}}$v(t){return t===void 0&&(t=this.Ov()),!!t.hash&&!this._instance.config.disable_capture_url_hashes}Hv(t){var e=this.Ov(),s=this.Pv;return!(!s||!(e.path&&t.pathname!==s.pathname||e.search&&t.search!==s.search||this.$v(e)&&t.hash!==s.hash))}Bv(t){try{var e=this.Fv();if(!e)return;this.Hv(e)&&this._instance.capture(uu,{navigation_type:t}),this.Pv=e}catch(s){I.error("Error capturing "+t+" pageview",s)}}qv(){if(!this.Dv){var t=()=>{this.Bv("popstate")};ae(b,"popstate",t),this.Dv=()=>{b&&b.removeEventListener("popstate",t)}}}jv(){if(!this.Lv){var t=()=>{this.Bv("hashchange")};ae(b,"hashchange",t),this.Lv=()=>{b&&b.removeEventListener("hashchange",t)}}}},heatmaps:class{get Rn(){return this.instance.config}constructor(t){var e;this.zv=!1,this.Xs=!1,this.Uv=null,this.instance=t,this.zv=!((e=this.instance.persistence)==null||!e.props[Tl]),this.rageclicks=new Tp(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){var t=5e3;return Y(this.Rn.capture_heatmaps)&&this.Rn.capture_heatmaps.flush_interval_milliseconds&&(t=this.Rn.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return H(this.Rn.capture_heatmaps)?H(this.Rn.enable_heatmaps)?this.zv:this.Rn.enable_heatmaps:this.Rn.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.Xs)return;uk.info("starting..."),this.Wv(),this.ar()}else{var t;clearInterval((t=this.Uv)!==null&&t!==void 0?t:void 0),this.Vv(),this.getAndClearBuffer()}}onRemoteConfig(t){if(t.ok){var e=t.config;if("heatmaps"in e){var s=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[Tl]:s}),this.zv=s,this.startIfEnabled()}}}getAndClearBuffer(){var t=this.Rt;return this.Rt=void 0,t}Gv(t){fl(t.originalEvent)&&this.vn(t.originalEvent,"deadclick")}ar(){this.Uv&&clearInterval(this.Uv),this.Uv=A?.visibilityState==="visible"?setInterval(this.Ja.bind(this),this.flushIntervalMilliseconds):null}Wv(){b&&A&&(this.Zv=this.Ja.bind(this),ae(b,Xn,this.Zv),this.Jv=t=>this.vn(t||b?.event),ae(A,"click",this.Jv,{capture:!0}),this.Qv=t=>this.Kv(t||b?.event),ae(A,"mousemove",this.Qv,{capture:!0}),this.Xv=new Jh(this.instance,gw,this.Gv.bind(this)),this.Xv.startIfEnabledOrStop(),this.Yv=this.ar.bind(this),ae(A,hi,this.Yv),this.Xs=!0)}Vv(){var t;b&&A&&(this.Zv&&b.removeEventListener(Xn,this.Zv),this.Jv&&A.removeEventListener("click",this.Jv,{capture:!0}),this.Qv&&A.removeEventListener("mousemove",this.Qv,{capture:!0}),this.Yv&&A.removeEventListener(hi,this.Yv),clearTimeout(this.tc),(t=this.Xv)==null||t.stop(),this.Xs=!1)}ec(t,e){var s=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),r=this.instance.scrollManager.scrollElement(),n=(function(o,a,l){for(var u=o;u&&Dt(u)&&!Ge(u,"body");){if(u===l)return!1;var c=void 0;try{var h,g,f;c=(h=(g=(f=u.ownerDocument)==null?void 0:f.defaultView)!==null&&g!==void 0?g:b)==null?void 0:h.getComputedStyle(u).position}catch{return!1}if(M(a,c))return!0;u=zg(u)}return!1})(or(t),["fixed","sticky"],r);return{x:t.clientX+(n?0:i),y:t.clientY+(n?0:s),target_fixed:n,type:e}}vn(t,e){var s;if(e===void 0&&(e="click"),!Bh(t.target)&&fl(t)){var i=this.ec(t,e);(s=this.rageclicks)!=null&&s.isRageClick(t.clientX,t.clientY,new Date().getTime())&&Wg(or(t),this.instance.config.rageclick)&&this.$s(k({},i,{type:"rageclick"})),this.$s(i)}}Kv(t){!Bh(t.target)&&fl(t)&&(clearTimeout(this.tc),this.tc=setTimeout(()=>{this.$s(this.ec(t,"mousemove"))},500))}$s(t){if(b){var e=this.Rn.disable_capture_url_hashes?ds(b.location.href):b.location.href,s=this.Rn.custom_personal_data_properties,i=vr(e,this.Rn.mask_personal_data_properties?[...vi,...s||[]]:[],_r);this.Rt=this.Rt||{},this.Rt[i]||(this.Rt[i]=[]),this.Rt[i].push(t)}}Ja(){this.Rt&&!nt(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:Jh,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.zv=!1,this.Xs=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.rc=()=>{clearTimeout(this.nc),this.nc=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",k({$current_url:this.Rt.url},this.Rt.metrics.reduce((s,i)=>k({},s,{["$web_vitals_"+i.name+"_event"]:k({},i),["$web_vitals_"+i.name+"_value"]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.sc=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},H(s?.name)||H(s?.value))ks.error("Invalid metric received",s);else{var r=typeof s.navigationURL=="string"?s.navigationURL:void 0,n=this.oc(r);if(!S(n)){var o=Re(s.navigationId)||typeof s.navigationId=="string"?"navigation:"+s.navigationId:"url:"+n;if(!this.ac||this.ac>s.value){this.Rt.navigationKey!==o&&(this.rc(),this.nc=setTimeout(this.rc,this.flushToCaptureTimeoutMs)),S(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=n),this.Rt.firstMetricTimestamp=S(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;var a=(i=this._instance.sessionManager)==null?void 0:i.checkAndGetSessionAndWindowId(!0),l=k({},s,r?{navigationURL:n}:{},{$current_url:n,timestamp:Date.now()});if(delete l.entries,Y(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){var u={};for(var c of lk){var h=c==="url"&&typeof s.attribution[c]=="string"?this.oc(s.attribution[c]):s.attribution[c];S(h)||(u[c]=h)}l.attribution=u}else delete l.attribution;S(a)||(l.$session_id=a.sessionId,l.$window_id=a.windowId),this.Rt.metrics.push(l),this.Rt.metrics.length===this.allowedMetrics.length&&this.rc()}else ks.error("Ignoring metric with value >= "+this.ac,s)}}},this.lc=()=>{if(!this.Xs){var s,i,r,n,o=!1,a=L.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,u=l?.[this.uc]||(this.uc==="web-vitals"&&S(l)?a?.postHogWebVitalsCallbacks:void 0);if(!S(u)){var c=u.withoutAttribution,h=this.attributionMetrics;o=!S(c),s=h.indexOf("LCP")>-1?u.onLCP:c?.onLCP||u.onLCP,i=h.indexOf("CLS")>-1?u.onCLS:c?.onCLS||u.onCLS,r=h.indexOf("FCP")>-1?u.onFCP:c?.onFCP||u.onFCP,n=h.indexOf("INP")>-1?u.onINP:c?.onINP||u.onINP}if(s&&i&&r&&n){var g={reportSoftNavs:this.useSoftNavs},f=o&&this.attributionMetrics.indexOf("INP")>-1?k({},g,{includeProcessedEventEntries:!1}):g;this.allowedMetrics.indexOf("LCP")>-1&&s(this.sc.bind(this),g),this.allowedMetrics.indexOf("CLS")>-1&&i(this.sc.bind(this),g),this.allowedMetrics.indexOf("FCP")>-1&&r(this.sc.bind(this),g),this.allowedMetrics.indexOf("INP")>-1&&n(this.sc.bind(this),f),this.Xs=!0}else ks.error("web vitals callbacks not loaded - not starting")}},this.zv=!((e=this._instance.persistence)==null||!e.props[Cl]),this.startIfEnabled()}get hc(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e,s=Y(this.hc)?(t=this.hc)==null?void 0:t.web_vitals_allowed_metrics:void 0;return H(s)?((e=this._instance.persistence)==null?void 0:e.props.$web_vitals_allowed_metrics)||mf:s}get flushToCaptureTimeoutMs(){return(Y(this.hc)?this.hc.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){var t=Y(this.hc)?this.hc.web_vitals_attribution:void 0;return Xe(t)?t?mf:[]:F(t)?t:ak}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){var t;return(t=Y(this.hc)?this.hc.__preview_web_vitals_soft_navs:void 0)!==null&&t!==void 0&&t}get ac(){var t=Y(this.hc)&&Re(this.hc.__web_vitals_max_value)?this.hc.__web_vitals_max_value:_f;return t>0&&6e4>=t?_f:t}get isEnabled(){var t=Ee?.protocol;if(t!=="http:"&&t!=="https:")return ks.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=Y(this.hc)?this.hc.web_vitals:Xe(this.hc)?this.hc:void 0;return Xe(e)?e:this.zv}startIfEnabled(){this.isEnabled&&!this.Xs&&(ks.info("enabled, starting..."),this.bo(this.lc))}onRemoteConfig(t){if(t.ok){var e=t.config;if("capturePerformance"in e){var s=Y(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=Y(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Cl]:s}),this._instance.persistence.register({[Ig]:i})),this.zv=s,this.startIfEnabled()}}}get uc(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}bo(t){var e=L.__PosthogExtensions__,s=this.uc,i=e?.postHogWebVitalsCallbacksByFlavor;i!=null&&i[s]||s==="web-vitals"&&S(i)&&e!=null&&e.postHogWebVitalsCallbacks?t():e==null||e.loadExternalDependency==null||e.loadExternalDependency(this._instance,s,r=>{r?ks.error("failed to load script",r):t()})}oc(t){var e=t||b?.location.href;if(e){var s=this._instance.config.disable_capture_url_hashes?ds(e):e,i=this._instance.config.custom_personal_data_properties;return vr(s,this._instance.config.mask_personal_data_properties?[...vi,...i||[]]:[],_r)}ks.error("Could not determine current URL")}}},Ak={exceptionObserver:class{constructor(t){var e;this.lc=()=>{var s;if(b&&this.isEnabled&&(s=L.__PosthogExtensions__)!=null&&s.errorWrappingFunctions){var i=L.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,r=L.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,n=L.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.dc&&this.Rn.capture_unhandled_errors&&(this.dc=i(this.captureException.bind(this))),!this.vc&&this.Rn.capture_unhandled_rejections&&(this.vc=r(this.captureException.bind(this))),!this.cc&&this.Rn.capture_console_errors&&(this.cc=n(this.captureException.bind(this)))}catch(o){er.error("failed to start",o),this.fc()}}},this._instance=t,this.gc=!((e=this._instance.persistence)==null||!e.props[Ol]),this.wt=new GE(k({},(function(s){var i,r,n,o;return s===void 0&&(s={}),{refillRate:(i=(r=s.exceptionRateLimiterRefillRate)!==null&&r!==void 0?r:s.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(n=(o=s.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:s.__exceptionRateLimiterBucketSize)!==null&&n!==void 0?n:10}})(this._instance.config.error_tracking),{refillInterval:1e4,A:er})),this.Rn=this.mc(),this.startIfEnabledOrStop()}mc(){var t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return Y(t)?e=k({},e,t):(S(t)?this.gc:t)&&(e=k({},e,{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Rn.capture_console_errors||this.Rn.capture_unhandled_errors||this.Rn.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(er.info("enabled"),this.fc(),this.bo(this.lc)):this.fc()}bo(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.errorWrappingFunctions?t():(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"exception-autocapture",i=>{if(i)return er.error("failed to load script",i);t()})}fc(){var t,e,s;(t=this.dc)==null||t.call(this),this.dc=void 0,(e=this.vc)==null||e.call(this),this.vc=void 0,(s=this.cc)==null||s.call(this),this.cc=void 0}onRemoteConfig(t){if(t.ok){var e=t.config;"autocaptureExceptions"in e&&(this.gc=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Ol]:this.gc}),this.Rn=this.mc(),this.startIfEnabledOrStop())}}onConfigChange(){this.Rn=this.mc()}captureException(t){try{var e,s,i,r=(e=t==null||(s=t.$exception_list)==null||(s=s[0])==null?void 0:s.type)!==null&&e!==void 0?e:"Exception";if(this.wt.consumeRateLimit(r))return void er.info("Skipping exception capture because of client rate limiting.",{exception:r});(i=this._instance.exceptions)==null||i.sendExceptionEvent(t)}catch{}}},exceptions:class{constructor(t){var e,s;this.yc=[],this.bc=new ZE([new aS,new vS,new uS,new lS,new gS,new fS,new dS,new pS],(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=[],c=a.split(`
|
|
7
|
+
`),h=l;c.length>h;h++){var g=c[h];if(1024>=g.length){var f=wh.test(g)?g.replace(wh,"$1"):g;if(!f.match(/\S*Error: /)){for(var p of n){var _=p(f,i);if(_){u.push(_);break}}if(u.length>=50)break}}}return(function(v){if(!v.length)return[];var m=Array.from(v);return m.reverse(),m.slice(0,50).map(y=>{return k({},y,{filename:y.filename||(w=m,w[w.length-1]||{}).filename,function:y.function||"?"});var w})})(u)}})("web:javascript",iS,oS)),this._instance=t,this.yc=(e=(s=this._instance.persistence)==null?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&e!==void 0?e:[],this._c=zn(this.wc()),this.kc=new mS(this._c)}onConfigChange(){this._c=zn(this.wc()),this.kc.setConfig(this._c)}onRemoteConfig(t){var e,s,i;if(t.ok){var r=t.config;if("errorTracking"in r){var n=(e=(s=r.errorTracking)==null?void 0:s.suppressionRules)!==null&&e!==void 0?e:[],o=(i=r.errorTracking)==null?void 0:i.captureExtensionExceptions;this.yc=n,this._instance.persistence&&this._instance.persistence.register({[Ag]:this.yc,[Pl]:o})}}}get Sc(){var t,e,s=!!this._instance.get_property(Pl);return(t=(e=this._instance.config.error_tracking.captureExtensionExceptions)!==null&&e!==void 0?e:s)!==null&&t!==void 0&&t}buildProperties(t,e){return this.bc.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this._c.enabled)try{if(!Q(t)||t.trim().length===0)return void yt.warn("Ignoring exception step because message must be a non-empty string");var s=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};var o=[];return{sanitizedProperties:Object.keys(n).reduce((a,l)=>_S.has(l)?(o.push(l),a):(a[l]=n[l],a),{}),droppedKeys:o}})(this.xc(e)),i=s.sanitizedProperties,r=s.droppedKeys;r.length>0&&yt.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.kc.add(k({[Hn]:t,[qn]:new Date().toISOString()},i))}catch(n){yt.error("Failed to add exception step. Ignoring breadcrumb.",n)}}sendExceptionEvent(t){try{var e=t.$exception_list;if(this.Cc(e)){if(this.Tc(e))return this.Mc("Exception dropped: matched a suppression rule"),void yt.info("Skipping exception capture because a suppression rule matched");if(!this.Sc&&this.Ic(e))return this.Mc("Exception dropped: thrown by a browser extension"),void yt.info("Skipping exception capture because it was thrown by an extension");if(!this.Sc&&this.Ec(e))return this.Mc("Exception dropped: thrown by an injected browser script"),void yt.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.Rc(e))return this.Mc("Exception dropped: thrown by the PostHog SDK"),void yt.info("Skipping exception capture because it was thrown by the PostHog SDK")}var s=this._c.enabled&&H(t.$exception_steps)?this.Ac(t):t,i=typeof(n=globalThis._posthogReleaseId)=="string"&&n.length>0?n:void 0;i&&(s.$release_id=i);try{var r=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",Du:!0});return r&&this.kc.clear(),r}catch(o){return Of(o)||yt.error("Failed to capture exception event. Dropping this exception.",o),void this.kc.clear()}}catch(o){return void(Of(o)||yt.error("Failed to process exception event. Ignoring this exception.",o))}var n}Ac(t){try{var e=this.kc.getAttachable();return e.length===0?t:k({},t,{$exception_steps:e})}catch(s){return yt.error("Failed to read buffered exception steps. Capturing exception without steps.",s),t}}Mc(t){this._c.enabled&&this.kc.add({[Hn]:t,[qn]:new Date().toISOString()})}xc(t){return Y(t)?k({},t):{}}wc(){var t,e;return(t=(e=this._instance.config.error_tracking)==null?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}Tc(t){if(t.length===0)return!1;try{var e=t.reduce((s,i)=>{var r=i.type,n=i.value;return Q(r)&&r.length>0&&s.$exception_types.push(r),Q(n)&&n.length>0&&s.$exception_values.push(n),s},{$exception_types:[],$exception_values:[]});return this.yc.some(s=>{var i=s.values.map(r=>{var n=wp[r.operator],o=e[r.key];if(!n||!o)return!1;var a=F(r.value)?r.value:[r.value];return a.length>0&&n(a,o)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}catch(s){return yt.warn("Failed to evaluate suppression rules. Capturing the exception.",s),!1}}Ic(t){var e=t.flatMap(i=>{var r,n;return(r=(n=i.stacktrace)==null?void 0:n.frames)!==null&&r!==void 0?r:[]}),s=e.filter(i=>{var r=i.filename;return!!r&&yk.some(n=>r.startsWith(n))});return s.length!==0&&(!s.every(i=>{var r=i.filename;return!!r&&r.startsWith(Ql)})||t.some(i=>{var r=i.value;return i.type==="NoResponse"||Q(r)&&mk.some(n=>{var o=n.value;return n.exact?r===o:r.includes(o)})})&&!e.some(i=>{var r=i.filename;return i.in_app&&!(r!=null&&r.startsWith(Ql))}))}Ec(t){return t.some(e=>{var s=e.value;return Q(s)&&bk.some(i=>s.includes(i))})}Rc(t){if(t.length>0){var e,s,i,r,n=(e=(s=t[0].stacktrace)==null?void 0:s.frames)!==null&&e!==void 0?e:[];return(i=(r=n[n.length-1])==null||(r=r.filename)==null?void 0:r.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}Cc(t){return!H(t)&&F(t)}}},Ik=k({productTours:class{get sl(){return this._instance.persistence}constructor(t){this.Pc=null,this.Fc=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(t.ok){var e=t.config;if("productTours"in e){var s,i;if(this.sl&&this.sl.register({[ou]:!!e.productTours}),!gl(this._instance))return!this.Pc&&H((s=this.sl)==null?void 0:s.props.ph_product_tours)||On.info("product tours disabled; stopping and clearing cached tours"),(i=this.Pc)==null||i.stop(),this.Pc=null,void this.clearCache();this.loadIfEnabled()}}}loadIfEnabled(){!this.Pc&&gl(this._instance)&&this.bo(()=>this.Oc())}bo(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.generateProductTours?t():(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"product-tours",i=>{i?On.error("Could not load product tours script",i):t()})}Oc(){var t;!this.Pc&&(t=L.__PosthogExtensions__)!=null&&t.generateProductTours&&(this.Pc=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e){if(e===void 0&&(e=!1),!F(this.Fc)||e){var s=this.sl;if(s){var i=s.props[Ln];if(F(i)&&!e)return this.Fc=i,void t(i,{isLoaded:!0})}this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/product_tours/?token="+this._instance.config.token),method:"GET",timestampMode:"query",callback:r=>{if(gl(this._instance)){var n=r.statusCode;if(n!==200||!r.json){var o="Product Tours API could not be loaded, status: "+n;return n===0?r.error||On.warn(o):On.error(o),void t([],{isLoaded:!1,error:o})}var a=F(r.json.product_tours)?r.json.product_tours:[];this.Fc=a,s&&s.register({[Ln]:a}),t(a,{isLoaded:!0})}else t([],{isLoaded:!0})}})}else t(this.Fc,{isLoaded:!0})}getActiveProductTours(t){H(this.Pc)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.Pc.getActiveProductTours(t)}showProductTour(t){var e;(e=this.Pc)==null||e.showTourById(t)}previewTour(t){this.Pc?this.Pc.previewTour(t):this.bo(()=>{var e;this.Oc(),(e=this.Pc)==null||e.previewTour(t)})}dismissProductTour(){var t;(t=this.Pc)==null||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.Pc)==null||t.nextStep()}previousStep(){var t;(t=this.Pc)==null||t.previousStep()}clearCache(){var t;this.Fc=null,(t=this.sl)==null||t.unregister(Ln)}resetTour(t){var e;(e=this.Pc)==null||e.resetTour(t)}resetAllTours(){var t;(t=this.Pc)==null||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.Pc)==null||e.cancelPendingTour(t)}}},co),Rk={siteApps:class{constructor(t){this._instance=t,this.$c=0,this.Dc=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}Lc(t,e){if(e){var s=this.globalsForEvent(e);this.Dc.push(s),this.Dc.length>1e3&&(this.Dc=this.Dc.slice(10))}}get siteAppLoaders(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)==null||(t=t[this._instance.config.token])==null?void 0:t.siteApps}initialize(){if(this.isEnabled){var t=this._instance._addCaptureHook(this.Lc.bind(this));this.Nc=()=>{t(),this.Dc=[],this.Nc=void 0}}}globalsForEvent(t){var e,s,i,r,n,o,a;if(!t)throw new Error("Event payload is required");var l={},u=this._instance.get_property("$groups")||[],c=this._instance.get_property("$stored_group_properties")||{};for(var h of Object.entries(c)){var g=h[0];l[g]={id:u[g],type:g,properties:h[1]}}var f=t.$set_once,p=t.$set;return{event:k({},Nf(t,NE),{properties:k({},t.properties,p?{$set:k({},(e=(s=t.properties)==null?void 0:s.$set)!==null&&e!==void 0?e:{},p)}:{},f?{$set_once:k({},(i=(r=t.properties)==null?void 0:r.$set_once)!==null&&i!==void 0?i:{},f)}:{}),elements_chain:(n=(o=t.properties)==null?void 0:o.$elements_chain)!==null&&n!==void 0?n:"",distinct_id:(a=t.properties)==null?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}qc(t){var e,s=(e=t.tagName)==null?void 0:e.toLowerCase();return s==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(Tt.error("prepare_external_dependency_stylesheet returned null"),null):s==="script"&&this._instance.config.prepare_external_dependency_script?this._instance.config.prepare_external_dependency_script(t)||(Tt.error("prepare_external_dependency_script returned null"),null):t}jc(){var t,e,s,i,r,n,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};var l=A?.defaultView,u=l==null||(t=l.Node)==null?void 0:t.prototype;if(!l||!u)return()=>{};if(this.$c++,this.Bc)return this.Hc();var c=[],h=this,g=new WeakSet,f=(v,m,y)=>{if(v!=null&&v[m]){var w=v[m];v[m]=y(w),c.push(()=>{v[m]=w})}},p=v=>{if(g.has(v))return v;var m=h.qc(v);return m&&g.add(m),m},_=v=>v.map(m=>typeof m=="string"?m:p(m)).filter(m=>!Ie(m));return f(u,"appendChild",v=>function(m){var y=p(m);return y?v.call(this,y):m}),f(u,"insertBefore",v=>function(m,y){var w=p(m);return w?v.call(this,w,y):m}),f(u,"replaceChild",v=>function(m,y){var w=p(m);return w?v.call(this,w,y):y}),[(e=l.Element)==null?void 0:e.prototype,(s=l.Document)==null?void 0:s.prototype,(i=l.DocumentFragment)==null?void 0:i.prototype].forEach(v=>{f(v,"append",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];return m.apply(this,_(w))}),f(v,"prepend",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];return m.apply(this,_(w))})}),[(r=l.Element)==null?void 0:r.prototype,(n=l.CharacterData)==null?void 0:n.prototype,(o=l.DocumentType)==null?void 0:o.prototype].forEach(v=>{f(v,"before",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];return m.apply(this,_(w))}),f(v,"after",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];return m.apply(this,_(w))}),f(v,"replaceWith",m=>function(){for(var y=arguments.length,w=new Array(y),E=0;y>E;E++)w[E]=arguments[E];var T=_(w);return w.length&&!T.length?void 0:m.apply(this,T)})}),f((a=l.Element)==null?void 0:a.prototype,"insertAdjacentElement",v=>function(m,y){var w=p(y);return w?v.call(this,m,w):null}),this.Bc=()=>{c.forEach(v=>v()),this.Bc=void 0},this.Hc()}Hc(){var t=!1;return()=>{var e;t||(t=!0,this.$c--,this.$c===0&&((e=this.Bc)==null||e.call(this)))}}zc(t,e){e===void 0&&(e=!0);var s=this.jc();try{var i=t(s);return e&&s(),i}catch(r){throw s(),r}}setupSiteApp(t){var e=this.apps[t.id],s=()=>{var o;!e.errored&&this.Dc.length&&(Tt.info("Processing "+this.Dc.length+" events for site app with id "+t.id),this.Dc.forEach(a=>this.zc(()=>e.processEvent==null?void 0:e.processEvent(a))),e.processedBuffer=!0),Object.values(this.apps).every(a=>a.processedBuffer||a.errored)&&((o=this.Nc)==null||o.call(this))},i=!1,r=o=>{e.errored=!o,e.loaded=!0,Tt.info("Site app with id "+t.id+" "+(o?"loaded":"errored")),i&&s()};try{var n=this.zc(o=>t.init({posthog:this._instance,callback(a){o(),r(a)}}),!1).processEvent;n&&(e.processEvent=n),i=!0}catch(o){Tt.error(bf+t.id,o),r(!1)}if(i&&e.loaded)try{s()}catch(o){Tt.error("Error while processing buffered events PostHog app with config id "+t.id,o),e.errored=!0}}Uc(){var t=this.siteAppLoaders||[];for(var e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(var s of t)this.setupSiteApp(s)}Wc(t){var e=this;if(Object.keys(this.apps).length!==0){var s=this.globalsForEvent(t),i=function(n){try{e.zc(()=>n.processEvent==null?void 0:n.processEvent(s))}catch(o){Tt.error("Error while processing event "+t.event+" for site app "+n.id,o)}};for(var r of Object.values(this.apps))i(r)}}onRemoteConfig(t){var e,s,i,r=this;if((e=this.siteAppLoaders)!=null&&e.length)return this.isEnabled?(this.Uc(),void this._instance.on("eventCaptured",l=>this.Wc(l))):void Tt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.Nc)==null||s.call(this),t.ok){var n=t.config;if((i=n.siteApps)!=null&&i.length)if(this.isEnabled){var o=function(){var l,u=a.id,c=a.url;L["__$$ph_site_app_"+u]=r._instance,(l=L.__PosthogExtensions__)==null||l.loadSiteApp==null||l.loadSiteApp(r._instance,c,h=>{if(h)return Tt.error(bf+u,h)})};for(var a of n.siteApps)o()}else Tt.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}}},Tk={tracingHeaders:class{constructor(t){this._instance=t,this.Vc=void 0,this.Gc=void 0,this.Zc=void 0,this.lc=()=>{var e,s,i=this.Jc();i?(S(this.Vc)&&(this.Vc=(e=L.__PosthogExtensions__)==null||(e=e.tracingHeadersPatchFns)==null?void 0:e._patchXHR(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),S(this.Gc)&&(this.Gc=(s=L.__PosthogExtensions__)==null||(s=s.tracingHeadersPatchFns)==null?void 0:s._patchFetch(i,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.fc()}}initialize(){this.startIfEnabledOrStop()}bo(t){var e,s;(e=L.__PosthogExtensions__)!=null&&e.tracingHeadersPatchFns?t():(s=L.__PosthogExtensions__)==null||s.loadExternalDependency==null||s.loadExternalDependency(this._instance,"tracing-headers",i=>{if(i)return ok.error("failed to load script",i);t()})}Qc(){var t,e;return(t=(e=this._instance.config.tracing_headers)!==null&&e!==void 0?e:this._instance.config.addTracingHeaders)!==null&&t!==void 0?t:this._instance.config.__add_tracing_headers}Jc(){var t=this.Qc();return F(t)?(F(this.Zc)?this.Zc.splice(0,this.Zc.length,...t):this.Zc=[...t],t.length>0?this.Zc:void 0):(F(this.Zc)&&this.Zc.splice(0),this.Zc=t||void 0,this.Zc)}fc(){var t,e;(t=this.Vc)==null||t.call(this),(e=this.Gc)==null||e.call(this),this.Vc=void 0,this.Gc=void 0}startIfEnabledOrStop(){this.Jc()?this.bo(this.lc):this.fc()}}},Ok=k({surveys:class extends ck{constructor(t){var e;super(new pk(t),(e=t,{get projectToken(){return e.config.token},kv:new gk(e)})),this._instance=t}ah(t,e){var s=e.query?yr(t,e.query):t;return new Promise(i=>{var r;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor((r=e.target)!==null&&r!==void 0?r:"api",s),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:i})})}}},co),Pk={toolbar:class{constructor(t){this.instance=t}Kc(t){L.ph_toolbar_state=t}Xc(){var t;return(t=L.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t,e,s){if(t===void 0&&(t=void 0),e===void 0&&(e=void 0),s===void 0&&(s=void 0),Ul(this.instance.config)||!b||!A)return!1;t=t??b.location,s=s??b.history;try{if(!e){try{b.localStorage.setItem("test","test"),b.localStorage.removeItem("test")}catch{return!1}e=b?.localStorage}var i,r=vk||Zn(t.hash,"__posthog")||Zn(t.hash,"state"),n=r?Lh(()=>JSON.parse(atob(decodeURIComponent(r))))||Lh(()=>JSON.parse(decodeURIComponent(r))):null;return n&&n.action==="ph_authorize"?((i=n).source="url",i&&Object.keys(i).length>0&&(n.desiredHash?t.hash=n.desiredHash:s?s.replaceState(s.state,"",t.pathname+t.search):t.hash="")):((i=JSON.parse(e.getItem(Sf)||"{}")).source="localstorage",delete i.userIntent),!(!i.token||this.instance.config.token!==i.token||(this.loadToolbar(i),0))}catch{return!1}}Yc(t){var e=L.ph_load_toolbar||L.ph_load_editor;!H(e)&&qe(e)?e(t,this.instance):wf.warn("No toolbar load function found")}loadToolbar(t){var e=!(A==null||!A.getElementById("__POSTHOG_TOOLBAR__"));if(!b||e)return!1;var s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=k({token:this.instance.config.token},t,{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(b.localStorage.setItem(Sf,JSON.stringify(k({},i,{source:void 0}))),this.Xc()===2)this.Yc(i);else if(this.Xc()===0){var r;this.Kc(1),(r=L.__PosthogExtensions__)==null||r.loadExternalDependency==null||r.loadExternalDependency(this.instance,"toolbar",n=>{if(n)return wf.error("[Toolbar] Failed to load",n),void this.Kc(0);this.Kc(2),this.Yc(i)}),ae(b,"turbolinks:load",()=>{this.Kc(0),this.loadToolbar(i)})}return!0}tf(t){return this.loadToolbar(t)}maybeLoadEditor(t,e,s){return t===void 0&&(t=void 0),e===void 0&&(e=void 0),s===void 0&&(s=void 0),this.maybeLoadToolbar(t,e,s)}}},Ck=k({experiments:class Je{get Rn(){return this._instance.config}constructor(e){var s=this;this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=function(i){i===void 0&&(i=!1),s.getWebExperiments(r=>{Je.ef("retrieved web experiments from the server"),s.if=new Map,r.forEach(n=>{if(n.feature_flag_key){var o;s.if&&(Je.ef("setting flag key ",n.feature_flag_key," to web experiment ",n),(o=s.if)==null||o.set(n.feature_flag_key,n));var a=s._instance.getFeatureFlag(n.feature_flag_key);Q(a)&&n.variants[a]&&s.rf(n.name,a,n.variants[a].transforms)}else if(n.variants)for(var l in n.variants){var u=n.variants[l];Je.nf(u,s._instance)&&s.rf(n.name,l,u.transforms)}})},i)},this._instance.onFeatureFlags(i=>{this.onFeatureFlags(i)})}initialize(){}onFeatureFlags(e){if(this._is_bot())Je.ef(Pf);else if(!this.Rn.disable_web_experiments){if(H(this.if))return this.if=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Je.ef("applying feature flags",e),e.forEach(s=>{var i;if(this.if&&(i=this.if)!=null&&i.has(s)){var r,n=this._instance.getFeatureFlag(s),o=(r=this.if)==null?void 0:r.get(s);n&&o!=null&&o.variants[n]&&this.rf(o.name,n,o.variants[n].transforms)}})}}previewWebExperiment(){var e=Je.getWindowLocation();if(e!=null&&e.search){var s=pi(e?.search,"__experiment_id"),i=pi(e?.search,"__experiment_variant");s&&i&&(Je.ef("previewing web experiments "+s+" && "+i),this.getWebExperiments(r=>{this.sf(parseInt(s),i,r)},!1,!0))}}loadIfEnabled(){this.Rn.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,s,i){if(this.Rn.disable_web_experiments&&!i)return e([]);var r=this._instance.get_property("$web_experiments");if(r&&!s)return e(r);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api","/api/web_experiments/?token="+this.Rn.token),method:"GET",timestampMode:"query",callback:n=>e(n.statusCode===200&&n.json&&n.json.experiments||[])})}sf(e,s,i){var r=i.filter(n=>n.id===e);r&&r.length>0&&(Je.ef("Previewing web experiment ["+r[0].name+"] with variant ["+s+"]"),this.rf(r[0].name,s,r[0].variants[s].transforms))}static nf(e,s){return!H(e.conditions)&&Je.af(e,s)&&Je.lf(e)}static af(e,s){var i;if(H(e.conditions)||H((i=e.conditions)==null?void 0:i.url))return!0;var r=Je.getWindowLocation();if(r){var n,o,a,l=Gg(s,r.href);return(n=e.conditions)==null||!n.url||Ek[(o=(a=e.conditions)==null?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return b?.location}static lf(e){var s;if(H(e.conditions)||H((s=e.conditions)==null?void 0:s.utm))return!0;var i=tp();if(i.utm_source){var r,n,o,a,l,u,c,h,g=(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,f=(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,_=(c=e.conditions)==null||(c=c.utm)==null||!c.utm_term||((h=e.conditions)==null||(h=h.utm)==null?void 0:h.utm_term)==i.utm_term;return g&&p&&_&&f}return!1}static ef(e){for(var s=arguments.length,i=new Array(s>1?s-1:0),r=1;s>r;r++)i[r-1]=arguments[r];I.info("[WebExperiments] "+e,i)}rf(e,s,i){this._is_bot()?Je.ef(Pf):s!=="control"?i.forEach(r=>{var n;r.selector&&(Je.ef("applying transform of variant "+s+" for experiment "+e+" ",r),(n=document)==null||(n=n.querySelectorAll(r.selector))==null||n.forEach(o=>{var a=o;r.html&&(a.innerHTML=r.html),r.css&&a.setAttribute("style",r.css)}))}):Je.ef("Control variants leave the page unmodified.")}_is_bot(){return Fe&&this._instance?bp(Fe,this.Rn.custom_blocked_useragents):void 0}}},co),xk=k({},co,wk,kk,Ak,Ik,Rk,Ok,Tk,Pk,Ck,{conversations:class{constructor(t){this._instance=t,this.uf=void 0,this._conversationsManager=null,this.hf=!1,this.re=null,this.df=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!this._instance.config.disable_conversations&&(this.vf=t.ok,t.ok)){var e=t.config.conversations;H(e)||(Xe(e)?this.uf=e:(this.uf=e.enabled,this.re=e),this.loadIfEnabled())}}reset(){var t;(t=this._conversationsManager)==null||t.reset(),this._conversationsManager=null,this.uf=void 0,this.re=null,this.vf=void 0,this.df=!1}loadIfEnabled(){if(!(this._conversationsManager||this.hf||this._instance.config.disable_conversations||Ul(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())){var t=L?.__PosthogExtensions__;if(t&&!S(this.uf)&&this.uf)if(this.re&&this.re.token){this.hf=!0;try{var e=t.initConversations;if(e)return this.cf(e),void(this.hf=!1);var s=t.loadExternalDependency;if(!s)return void this.ff(Ml);s(this._instance,"conversations",i=>{i||!t.initConversations?this.ff("Could not load conversations script",i):this.cf(t.initConversations),this.hf=!1})}catch(i){this.ff("Error initializing conversations",i),this.hf=!1}}else gt.error("Conversations enabled but missing token in remote config.")}}cf(t){if(this.re)try{this._conversationsManager=t(this.re,this._instance),this.df=!1,gt.info("Conversations loaded successfully")}catch(e){this.ff("Error completing conversations initialization",e)}else gt.error("Cannot complete initialization: remote config is null")}ff(t,e){gt.error(t,e),this._conversationsManager=null,this.hf=!1,this.df=!0}show(){this._conversationsManager?this._conversationsManager.show():gt.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.uf===!0&&!Ie(this._conversationsManager)}getUnavailableReason(){return this.isAvailable()?null:this._instance.config.disable_conversations?"disabled_by_config":Ul(this._instance.config)?"disabled_for_toolbar":this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut()?"consent_opted_out":this.vf===!1?"remote_config_failed":S(this.uf)?this.vf?"disabled_in_project":"remote_config_pending":this.uf?H(this.re)||!this.re.token?"missing_token":L!=null&&L.__PosthogExtensions__?this.hf?"initializing":this.df?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,s){var i=this;return ge(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(t,e,s):(gt.warn(Is),null)})()}getMessages(t,e){var s=this;return ge(function*(){return s._conversationsManager?s._conversationsManager.getMessages(t,e):(gt.warn(Is),null)})()}markAsRead(t){var e=this;return ge(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(gt.warn(Is),null)})()}getTickets(t){var e=this;return ge(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(gt.warn(Is),null)})()}requestRestoreLink(t){var e=this;return ge(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(gt.warn(Is),null)})()}restoreFromToken(t){var e=this;return ge(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(gt.warn(Is),null)})()}restoreFromUrlToken(){var t=this;return ge(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(gt.warn(Is),null)})()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)==null?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}Wu(){var t;(t=this._conversationsManager)==null||t.setIdentity()}Vu(){var t;(t=this._conversationsManager)==null||t.clearIdentity()}}},{logs:class{constructor(t){var e,s=this;this._instance=t,this.name="logs",this.pf=!1,this.gf=!1,this.mf=!1,this.A=Te("[logs]"),this.yf=k({},this.A,{error(){for(var i=arguments.length,r=new Array(i),n=0;i>n;n++)r[n]=arguments[n];r.some(Df)||s.A.error(...r)}}),this.La=[],this.bf=[],this.Od=0,this.ro=!1,this._f=[],this.wf=[],this.kf=!1,this.Sf=!1,this.xf=()=>{var i,r;this.ro||(this.Od=0,(i=this.Cf)==null||i.onReconnect(),(r=this.Tf)==null||r.onReconnect())},this._instance&&(e=this._instance.config.logs)!=null&&e.captureConsoleLogs&&(this.pf=!0),b&&ae(b,"online",this.xf)}Mf(t,e,s,i){var r,n=Cf((r=this._instance)==null||(r=r.config)==null?void 0:r.logs,s);return[new RS(this.If(t,e),n,this.yf,()=>this.Ef(),o=>o(),void 0,i),n]}Rf(){var t,e=(t=this._instance)==null||(t=t.config)==null?void 0:t.logs;if(!this.Cf||this.Af!==e){var s;(s=this.Cf)==null||s.reset(),this.Af=e;var i=this.Mf(()=>this.La,r=>{this.La=r});this.Cf=i[0],this.Pf=i[1]}return this.Cf}Ff(){var t,e=(t=this._instance)==null||(t=t.config)==null?void 0:t.logs;if(!this.Tf||this.Of!==e){var s;(s=this.Tf)==null||s.reset(),this.Of=e;var i=this.Mf(()=>this.bf,r=>{this.bf=r},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},xf);this.Tf=i[0],this.$f=i[1]}return this.Tf}setup(t){var e;if(!this.ro){this.Js=t,(e=this._instance)!=null&&(e=e.config)!=null&&(e=e.logs)!=null&&e.captureConsoleLogs&&(this.pf=!0),(this.pf||this.Df()&&this.Lf())&&this.Nf();var s=!1,i=t.onRemoteConfig(r=>{var n;s=r.ok&&((n=r.config.logs)==null?void 0:n.captureConsoleLogs)===!0,this.onRemoteConfig(r)});this.ro?i.dispose():(this.oo=i,s||this.loadIfEnabled())}}dispose(){var t,e,s,i;this.ro||(this.ro=!0,this.qf(),(t=this.oo)==null||t.dispose(),this.oo=void 0,this.Js=void 0,this.mf=!1,b?.removeEventListener("online",this.xf),(e=this.jf)==null||e.call(this),this.jf=void 0,(s=this.Cf)==null||s.reset(),(i=this.Tf)==null||i.reset())}onRemoteConfig(t){var e,s;if(!this.ro){var i=t.ok?(e=t.config.logs)==null?void 0:e.captureConsoleLogs:void 0;H(i)?this.Bf():((s=this._instance)==null||(s=s.persistence)==null||s.register({[xl]:!!i}),i?(this.pf=!0,this.gf||this.Nf(),this.loadIfEnabled()):this.Bf())}}reset(){var t,e,s,i;this.qf(),(t=this.Cf)==null||t.clearQueue(),this.La=[],(e=this.Cf)==null||e.reset(),(s=this.Tf)==null||s.clearQueue(),this.bf=[],(i=this.Tf)==null||i.reset(),this.Od=0}captureLog(t){this.ro||this.Rf().captureLog(t)}captureConsoleLog(t){this.ro||this.Ff().captureLog(t)}captureBufferedConsoleLog(t,e,s){this.ro||this.Ff().captureLog(t,{context:e,occurredAtMs:s})}Lf(){var t;return!((t=this._instance)==null||(t=t.persistence)==null||(t=t.props)==null||!t[xl])}Df(){var t,e;return(t=this._instance)==null||t.Fa==null||!t.Fa()||!((e=L._POSTHOG_REMOTE_CONFIG)==null||(e=e[this._instance.config.token])==null||!e.config)}Zu(){var t;this.qf(),(t=this.Tf)==null||t.clearQueue(),this.bf=[]}Bf(){this.pf||this.qf()}Nf(){var t,e=this;if(!this.kf&&L!=null&&L.console){var s=Cf((t=this._instance)==null||(t=t.config)==null?void 0:t.logs).maxBufferSize,i=function(n){var o;try{o=(a=>{for(;(l=a)!=null&&l.__rrweb_original__;){var l;a=a.__rrweb_original__}return a})(L.console[n])}catch{return 0}if(!o)return 0;e.wf.push(Op(L.console,n,a=>{var l=function(){for(var u=arguments.length,c=new Array(u),h=0;u>h;h++)c[h]=arguments[h];try{e.Hf(n,c,s)}catch{}return a.apply(L.console,c)};return l.__rrweb_original__=o,l}))};for(var r of Sk)i(r);this.kf=!0,this.zf=setTimeout(()=>{this.qf()},3e4)}}Hf(t,e,s){var i;if(this.kf&&!this.Sf&&e.length!==0)if((i=this._instance)!=null&&i.is_capturing()){if(s>this._f.length){this.Sf=!0;try{this._f.push({level:t,args:e,occurredAtMs:Date.now(),context:this.Ef()})}finally{this.Sf=!1}}}else this.qf()}qf(){if(this._f=[],this.kf){for(var t of(this.kf=!1,this.zf&&(clearTimeout(this.zf),this.zf=void 0),this.wf))t();this.wf=[]}}Uf(){var t=this._f;return this.qf(),t}get logger(){return this.Wf||(this.Wf={trace:(t,e)=>this.captureLog({body:t,level:"trace",attributes:e}),debug:(t,e)=>this.captureLog({body:t,level:"debug",attributes:e}),info:(t,e)=>this.captureLog({body:t,level:"info",attributes:e}),warn:(t,e)=>this.captureLog({body:t,level:"warn",attributes:e}),error:(t,e)=>this.captureLog({body:t,level:"error",attributes:e}),fatal:(t,e)=>this.captureLog({body:t,level:"fatal",attributes:e})}),this.Wf}flushLogs(t){t?this.Vf(t):(this.Cf&&this.Cf.flush().catch(e=>this.Gf(e)),this.Tf&&this.Tf.flush().catch(e=>this.Gf(e)))}Gf(t){Df(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(!this.ro&&this.pf&&!this.gf&&!this.mf){var t=L?.__PosthogExtensions__;if(!t)return this.A.error("PostHog Extensions not found."),void this.qf();var e=t.loadExternalDependency;if(!e)return this.A.error(Ml),void this.qf();this.mf=!0;try{e(this._instance,"logs",s=>{if(this.mf=!1,!this.ro&&this.pf){var i=t.logs;if(s||i==null||!i.initializeLogs)this.A.error("Could not load logs script",s),this.qf();else{var r,n,o=this.Uf();this.jf=i.initializeLogs((r=this.Js)!==null&&r!==void 0?r:this._instance),this.gf=!0,o.length>0&&(i.replayConsoleBuffer==null||i.replayConsoleBuffer((n=this.Js)!==null&&n!==void 0?n:this._instance,o))}}})}catch(s){throw this.mf=!1,s}}}If(t,e){var s=this._instance;return{get isDisabled(){return!1},get optedOut(){return!s.is_capturing()},getPersistedProperty:i=>i===Pt.LogsQueue?t():void 0,setPersistedProperty(i,r){i===Pt.LogsQueue&&e(r??[])},xs:i=>this.xs(i),getLibraryId:()=>Le.LIB_NAME,getLibraryVersion:()=>Le.LIB_VERSION}}xs(t){return new Promise(e=>{if(Zg(this.Od,3))e({kind:"fatal",error:vl(void 0,"logs endpoint is unreachable, dropping batch")});else{var s=!1,i=n=>{s||(s=!0,clearTimeout(r),e(n))},r=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:vl(void 0,"logs request timed out")})},9e4);this._instance._send_request({method:"POST",url:this.Zf(),data:t,compression:"best-available",batchKey:"logs",fireCallbackOnDrop:!0,callback:n=>{var o=n.statusCode;if(this.Jf(o),o>=200&&300>o)i({kind:"ok"});else if(o===413)i({kind:"too-large"});else if(o!==0&&o!==408&&o!==429&&500>o)i({kind:"fatal",error:new Error("logs request failed with status "+o)});else{var a;o===0?(n.error||this.A.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:vl(n.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=n.error)!==null&&a!==void 0?a:new Error("logs request failed with status "+o)})}}})}})}Jf(t){(t!==0||this._instance.__loaded)&&(this.Od=ep(t,this.Od,3,()=>this.A.warn("Log requests are failing before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped sending logs; will try again when connectivity changes.")))}Vf(t){this.La.length>0&&this.Qf(t,this.La,this.Pf,Le.LIB_NAME,e=>{this.La=e}),this.bf.length>0&&this.Qf(t,this.bf,this.$f,xf,e=>{this.bf=e})}Qf(t,e,s,i,r){if(e.length!==0){var n=e.map(a=>a.record);r([]);var o=wg(n,Sg(s,Le.LIB_NAME,Le.LIB_VERSION),i,Le.LIB_VERSION);this._instance._send_request({method:"POST",url:this.Zf(),data:o,compression:"best-available",batchKey:"logs",transport:t})}}Zf(){return this._instance.requestRouter.endpointFor("api","/i/v1/logs")+"?token="+encodeURIComponent(this._instance.config.token)}Ef(){var t,e={};if(e.distinctId=this._instance.get_distinct_id(),this._instance.sessionManager){var s=this._instance.sessionManager.checkAndGetSessionAndWindowId(!0),i=s.windowId,r=s.sessionStartTimestamp,n=s.lastActivityTimestamp;e.sessionId=s.sessionId,e.windowId=i,H(r)||(e.sessionStartTimestamp=r),H(n)||(e.lastActivityTimestamp=n)}if(L!=null&&(t=L.location)!=null&&t.href&&(e.currentUrl=this._instance.config.disable_capture_url_hashes?ds(L.location.href):L.location.href),this._instance.featureFlags){var o=this._instance.featureFlags.getFlags();o&&o.length>0&&(e.activeFeatureFlags=o)}return e}}},{metrics:class{constructor(t){this._instance=t,this.A=Te("[metrics]")}initialize(){}Rf(){var t,e,s=(t=this._instance)==null||(t=t.config)==null?void 0:t.metrics;return this.Cf&&this.Af===s||((e=this.Cf)==null||e.reset(),this.Af=s,this.Cf=new TS(this.If(),(function(i){var r,n,o,a,l,u=i?.resourceAttributes;return{serviceName:(r=u?.["service.name"])!==null&&r!==void 0?r:i?.serviceName,serviceVersion:(n=u?.["service.version"])!==null&&n!==void 0?n:i?.serviceVersion,environment:(o=u?.["deployment.environment"])!==null&&o!==void 0?o:i?.environment,resourceAttributes:u,beforeSend:i?.beforeSend,flushIntervalMs:(a=i?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=i?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(s),this.A)),this.Cf}count(t,e,s){e===void 0&&(e=1),this.Rf().count(t,e,s)}gauge(t,e,s){this.Rf().gauge(t,e,s)}histogram(t,e,s){this.Rf().histogram(t,e,s)}flush(t){if(!this.Cf)return Promise.resolve();if(t){var e=this.Cf.drainWindow();return e&&this.js(e,t),Promise.resolve()}return this.Cf.flush().catch(s=>this.A.error("PostHog metrics flush failed:",s))}reset(){var t;(t=this.Cf)==null||t.reset()}If(){var t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},js:s=>e.js(s),getLibraryId:()=>Le.LIB_NAME,getLibraryVersion:()=>Le.LIB_VERSION}}js(t,e){return new Promise(s=>{var i=!1,r=o=>{i||(i=!0,clearTimeout(n),s(o))},n=setTimeout(()=>r({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(k({method:"POST",url:this.Kf(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e},{fireCallbackOnDrop:!0,callback(o){var a,l=o.statusCode;r(l>=200&&300>l?{kind:"ok"}:l===413?{kind:"too-large"}:l!==0&&l!==408&&l!==429&&500>l?{kind:"fatal",error:new Error("metrics request failed with status "+l)}:{kind:"retry-later",error:(a=o.error)!==null&&a!==void 0?a:new Error("metrics request failed with status "+l)})}}))})}Kf(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}});_u.__defaultExtensionClasses=k({},xk);Dk=(function(){Le.SDK_DIST_CHANNEL="npm";var t=ur[ir]=new _u;return(function(){function e(){e.done||(e.done=!0,Rp=!1,ie(ur,function(s){s._dom_loaded()}))}A!=null&&A.addEventListener?A.readyState==="complete"?e():ae(A,"DOMContentLoaded",e,{capture:!1}):b&&I.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),t})(),Ce=Dk});var Dp={};ho(Dp,{Posthog:()=>mu});var Ke,mu,Np=et(()=>{"use strict";xp();$i();Mi();Ke=class Ke{constructor(e,s=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Zt("[PostHog]",()=>this.debug);this.cleanupStalePosthogCookies=e=>{if(typeof document>"u"||typeof window>"u")return;let s=`ph_${e}_posthog`,i=document.cookie.split(";").map(a=>a.trim().split("=")[0]??"").filter(a=>/^ph_.+_posthog$/.test(a)&&a!==s);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 c=u?`; Domain=${u}`:"";document.cookie=`${a}=; path=/${c}; 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:s,config:i={}}=this.options;if(!e){console.warn("Posthog: No API key provided");return}if(Ke._hasLoaded||Ce.__loaded){this.log("init | PostHog already initialized, skipping re-init"),this.has_initialized=!0;return}this.cleanupStalePosthogCookies(e);let r=s||nd();this.log("init | loading PostHog SDK",{api_host:r});let n={api_host:r,ui_host:rd,autocapture:{dom_event_allowlist:["click"]},rate_limiting:{events_per_second:10,events_burst_limit:100},...i,person_profiles:"identified_only",capture_pageview:"history_change",capture_pageleave:!0,session_recording:{...i.session_recording,recordCrossOriginIframes:!0,minimumDurationMilliseconds:3e4,maskAllInputs:!0},before_send:o=>{if(typeof window>"u"||!o)return null;if(o.timestamp){let u=o.timestamp.getTime(),c=Date.now();if(u<c-6048e5||u>c+6048e5)return this.log("init | before_send dropped event with bad timestamp",{event:o.event,timestamp:o.timestamp.toISOString()}),null}let a=window.location.hostname;if(a!=="localhost"&&a!=="127.0.0.1"&&!od.some(u=>a.endsWith(`.${u}`)||a===u))return this.log("init | before_send blocked event from disallowed host",{currentHost:a}),null;if(i.before_send){let l=Array.isArray(i.before_send)?i.before_send:[i.before_send],u=o;for(let c of l)u=u?c(u):null;return u}return o}};Ce.init(e,n),this.options.app_version&&Ce.register({app_version:this.options.app_version}),Ke._hasLoaded=!0,this.has_initialized=!0,this.log("init | PostHog SDK loaded successfully")}catch(e){console.error("Posthog: Failed to initialize",e)}};this.resetIfStaleId=(e,s,i)=>{Ke.isAnonymousId(e)||(this.log(`${i} | stale identified user, resetting`,{previous:e,next:s}),Ce.reset())};this.identifyEvent=(e,s={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{if(!e||!e.trim()||Ke.ILLEGAL_IDS.has(e.toLowerCase())){this.log("identifyEvent | skipped \u2014 invalid user_id",{user_id:e});return}let i=Ce.get_distinct_id();if(i===e){this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e});return}this.resetIfStaleId(i,e,"identifyEvent"),this.log("identifyEvent | identifying user",{user_id:e,traits:s}),Ce.identify(e,{...s,client_id:e}),this.has_identified=!0}catch(i){console.error("Posthog: Failed to identify user",i)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),Ce.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:s,language:i,country_of_residence:r})=>{if(!(!this.has_initialized||!e)){if(!e.trim()||Ke.ILLEGAL_IDS.has(e.toLowerCase())){this.log("backfillPersonProperties | skipped \u2014 invalid user_id",{user_id:e});return}try{let n=Ce.get_distinct_id(),o=n===e;o||this.resetIfStaleId(n,e,"backfillPersonProperties");let a={};if(Ce.get_property("client_id")||(a.client_id=e),s&&Ce.get_property("is_internal")==null&&(a.is_internal=Jr(s)),i&&!Ce.get_property("language")&&(a.language=i),r&&!Ce.get_property("country_of_residence")&&(a.country_of_residence=r),o){if(Object.keys(a).length===0){this.log("backfillPersonProperties | skipped \u2014 all properties already present",{user_id:e});return}this.log("backfillPersonProperties | backfilling person properties",{user_id:e,updates:a}),Ce.setPersonProperties(a)}else a.client_id||(a.client_id=e),this.log("backfillPersonProperties | user not identified, identifying now",{user_id:e,updates:a}),Ce.identify(e,a),this.has_identified=!0}catch(n){console.error("Posthog: Failed to backfill person properties",n)}}};this.capture=(e,s)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:s}),Ce.capture(e,s)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let s=Ce.isFeatureEnabled(e);return this.log("isFeatureEnabled",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to check feature flag",s);return}};this.getFeatureFlag=e=>{if(this.has_initialized)try{let s=Ce.getFeatureFlag(e);return this.log("getFeatureFlag",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to get feature flag",s);return}};this.getFeatureFlagPayload=e=>{if(this.has_initialized)try{let s=Ce.getFeatureFlagResult(e)?.payload;return this.log("getFeatureFlagPayload",{key:e,result:s}),s}catch(s){console.error("Posthog: Failed to get feature flag payload",s);return}};this.getAllFlags=()=>{if(!this.has_initialized)return{};try{let e=Ce.featureFlags?.getFlagVariants()??{},s=Object.fromEntries(Object.entries(e).filter(i=>i[1]!=null));return this.log("getAllFlags",{result:s}),s}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 s=Ce.onFeatureFlags(e);return typeof s=="function"?s:()=>{}}catch(s){return console.error("Posthog: Failed to subscribe to feature flags",s),()=>{}}};this.reloadFeatureFlags=()=>{if(this.has_initialized)try{this.log("reloadFeatureFlags | reloading feature flags"),Ce.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=s,this.init()}};Ke._hasLoaded=!1,Ke.ILLEGAL_IDS=new Set(["restored","null","undefined","anonymous","guest","distinctid","distinct_id","id","not_authenticated","email","true","false","0","none","nan"]),Ke.getPosthogInstance=(e,s=!1)=>(Ke._instance?e.apiKey&&e.apiKey!==Ke._instance.options.apiKey&&console.warn("Posthog: getPosthogInstance called with a different API key \u2014 returning existing instance"):Ke._instance=new Ke(e,s),Ke._instance),Ke.isAnonymousId=e=>e?/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(e):!0;mu=Ke});var Lk={};ho(Lk,{Analytics:()=>Lp});da();$i();Mi();var m0=4320*60*60,bs=class bs{constructor(e,s,i=!1,r){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=Zt("[RudderStack]",()=>this.debug);this.getAnonymousId=()=>document.cookie.match("(^|;)\\s*"+this.rudderstack_anonymous_cookie_key+"\\s*=\\s*([^;]+)")?.pop();this.setCookieIfNotExists=()=>{if(!this.getAnonymousId())try{let s=window.location.hostname,n=["webflow.io"].some(u=>s.endsWith(u))?s:s.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 c=Array.from(u,h=>h.toString(16).padStart(2,"0")).join("");o=`${c.slice(0,8)}-${c.slice(8,12)}-${c.slice(12,16)}-${c.slice(16,20)}-${c.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=${m0}; SameSite=Lax${l}`}catch(s){console.warn("RudderStack: Failed to set anonymous ID cookie",s)}};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:ha});try{this.setCookieIfNotExists(),this.analytics.load(e,ha,{...this.app_version&&{context:{app_version:this.app_version}},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(s){console.error("RudderStack: Failed to initialize",s)}};this.identifyEvent=(e,s)=>{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:s}),this.analytics.identify(e,s||{}),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,s="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:s,current_page:e,properties:n}),this.analytics.page(s,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,s)=>{if(this.has_initialized)try{this.log("track | sending event to RudderStack",{event:e,payload:s}),this.analytics.track(e,s)}catch(i){console.warn("RudderStack: Failed to track event",i)}};this.onLoadedCallback=s,this.debug=i,this.app_version=r,this.init(e)}};bs.getRudderStackInstance=(e,s,i=!1,r)=>(bs._instance||(bs._instance=new bs(e,s,i,r)),bs._instance);var Yr=bs;var Xr="cached_analytics_events",Qr="cached_analytics_page_views",fd=(t,e)=>{try{let s=localStorage.getItem(Xr),i=s?JSON.parse(s):[];i.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(Xr,JSON.stringify(i))}catch(s){console.warn("Analytics: Failed to cache event",s)}},gd=(t,e)=>{try{let s=localStorage.getItem(Qr),i=s?JSON.parse(s):[];i.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(Qr,JSON.stringify(i))}catch(s){console.warn("Analytics: Failed to cache page view",s)}},pd=()=>{try{let t=localStorage.getItem(Xr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached events",t)}return[]},vd=()=>{try{let t=localStorage.getItem(Qr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached pages",t)}return[]},_d=()=>{try{localStorage.removeItem(Xr)}catch(t){console.warn("Analytics: Failed to clear cached events",t)}},md=()=>{try{localStorage.removeItem(Qr)}catch(t){console.warn("Analytics: Failed to clear cached page views",t)}};Mi();function Nk(t){let e=t?.debug??!1,s=Zt("",()=>e),i,r,n,o={},a={},l=[],u=[],c=!1,h=()=>{if(!c&&r?.has_initialized){c=!0;try{let O=pd();O.length>0&&(s(`processStorageCache | replaying ${O.length} cached event(s)`,O),O.forEach(V=>{let K=ys(V.properties);r?.track(V.name,K)}),_d());let B=vd();B.length>0&&(s(`processStorageCache | replaying ${B.length} cached page view(s)`,B),B.forEach(V=>{r?.pageView(V.name,"Deriv App",E(),V.properties)}),md())}catch(O){console.warn("Analytics: Failed to process storage cache",O)}}},g=()=>{s("onSdkLoaded | RudderStack SDK loaded"),h(),u.length>0&&s(`onSdkLoaded | flushing ${u.length} pending identify call(s)`),u.forEach(({userId:O,traits:B})=>{O&&r?.identifyEvent(O,B)}),u=[]},f=async({growthbookKey:O,growthbookDecryptionKey:B,rudderstackKey:V,app_version:K,growthbookOptions:J,posthogOptions:W,debug:Z})=>{var X,se;Z!==void 0&&(e=Z),s("initialise | starting analytics initialization",{rudderstack:!!V,growthbook:!!O,posthog:!!W});try{let xe=J?.attributes?.country||(O?await cd():void 0);if(V&&(s("initialise | initializing RudderStack"),r=Yr.getRudderStackInstance(V,g,e,K)),J?.attributes&&Object.keys(J.attributes).length>0){let j=J.attributes,Me=r?.getAnonymousId();o={...o,country:xe,...j.user_language&&{user_language:j.user_language},...j.account_type&&{account_type:j.account_type},...j.app_id&&{app_id:j.app_id},...j.residence_country&&{residence_country:j.residence_country},...j.device_type&&{device_type:j.device_type},...j.url&&{url:j.url},...j.email_hash&&{email_hash:j.email_hash},...j.network_type&&{network_type:j.network_type},...j.network_rtt&&{network_rtt:j.network_rtt},...j.network_downlink&&{network_downlink:j.network_downlink},...j.account_currency&&{account_currency:j.account_currency},...j.account_mode&&{account_mode:j.account_mode},loggedIn:!!j.loggedIn,...j.user_id&&!Fi(j.user_id)&&{user_id:j.user_id},...Me&&{anonymous_id:Me}}}J??(J={}),J.attributes??(J.attributes={});let Se=r?.getAnonymousId();if((X=J.attributes).id??(X.id=Se),(se=J.attributes).country??(se.country=xe),O){s("initialise | initializing GrowthBook");let{Growthbook:j}=await Promise.resolve().then(()=>(dh(),ch));i=j.getGrowthBookInstance(O,B,J,e),s("initialise | GrowthBook initialized");let Me=setInterval(()=>{Object.keys(a).length>0?clearInterval(Me):a=v("tracking-buttons-config",{})},1e3)}if(W){s("initialise | initializing PostHog");let{Posthog:j}=await Promise.resolve().then(()=>(Np(),Dp));n=j.getPosthogInstance({app_version:K,...W},e),s("initialise | PostHog initialized")}s("initialise | analytics initialization complete")}catch(xe){console.warn("Analytics: Failed to initialize",xe)}},p=O=>{s("setAttributes | received attributes",O);let{user_id:B,...V}=O,K=B??E();if(i){let J={...V};B&&!Fi(B)&&(J.user_id=B),K&&(J.id=K,J.user_id=K),s("setAttributes | called GrowthBook setAttributes",J),i.setAttributes(J)}o={...o,...Object.fromEntries(Object.entries(V).filter(([,J])=>J!==void 0)),...B!==void 0&&!Fi(B)&&{user_id:B}},s("setAttributes | updated core_data",o)},_=O=>i?.getFeatureState(O)?.experimentResult?.name,v=(O,B)=>i?.getFeatureValue(O,B),m=async()=>await i?.getStatus(),y=O=>i?.isOn(O),w=O=>i?.setUrl(O),E=()=>{let O=r?.getUserId()||"";return O&&!Fi(O)?O:""},oe={initialise:f,setAttributes:p,identifyEvent:(O,B)=>{let V=O||E();if(!V){s("identifyEvent | skipped \u2014 no user_id available");return}s("identifyEvent | called",{user_id:V,traits:B});let K=X=>{if(!X)return X;let{email:se,...xe}=X;return{...xe,...se&&{is_internal:Jr(se)}}},J=B?.rudderstack!==void 0||B?.posthog!==void 0,W,Z;if(J){let{rudderstack:X,posthog:se,...xe}=B;W=K({...xe,...X}),Z=K({...xe,...se})}else W=K(B),Z=K(B);r&&(r.has_initialized?(s("identifyEvent | calling RudderStack identify",{user_id:V,traits:W}),r.identifyEvent(V,W)):u.some(X=>X.userId===V)||(s("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:V}),u.push({userId:V,traits:W}))),n?.has_initialized&&(s("identifyEvent | calling PostHog identify",{user_id:V,traits:Z}),n.identifyEvent(V,Z))},backfillPersonProperties:({user_id:O,email:B,language:V,country_of_residence:K})=>{s("backfillPersonProperties | called",{user_id:O}),n?.has_initialized?(s("backfillPersonProperties | backfilling person properties in PostHog",{user_id:O}),n.backfillPersonProperties({user_id:O,email:B,language:V,country_of_residence:K})):s("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:_,getFeatureValue:v,getGrowthbookStatus:m,isFeatureOn:y,setUrl:w,getId:E,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(O,B)=>{let V=E();s("trackEvent | called",{event:O,analytics_data:B,userId:V,core_data:o});let K={...o,...B,...V&&!o.user_id&&{user_id:V}};if(s("trackEvent | built payload",{event:O,final_payload:K}),!(!(O in a)||a[O])){s("trackEvent | skipped \u2014 event disabled by tracking_config",{event:O});return}let W=r?.has_initialized;if(!navigator.onLine||!W)W?(s("trackEvent | offline \u2014 caching event to memory",{event:O}),l.push({event:O,payload:K})):(s("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:O}),fd(O,K));else{l.length>0&&(s(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(X=>{let se=ys(X.payload);r?.track(X.event,se)}),l=[]);let Z=ys(K);s("trackEvent | sending event to RudderStack",{event:O,payload:Z}),r?.track(O,Z)}if(n?.has_initialized){let Z=ys(hd(K));s("trackEvent | sending event to PostHog",{event:O,payload:Z}),n.capture(O,Z)}},getInstances:()=>({ab:i,tracking:r,posthog:n}),pageView:(O,B="Deriv App",V)=>{let K=E();s("pageView | called",{current_page:O,platform:B,properties:V,userId:K}),r?.has_initialized?(s("pageView | sending page view to RudderStack",{current_page:O,platform:B}),r.pageView(O,B,K,V)):(s("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:O}),gd(O,{platform:B,...V}))},reset:()=>{s("reset | resetting all providers"),r?.has_initialized&&(s("reset | resetting RudderStack"),r.reset()),n?.has_initialized&&(s("reset | resetting PostHog"),n.reset())},isPosthogFeatureEnabled:O=>n?.isFeatureEnabled(O),getPosthogFeatureFlag:O=>n?.getFeatureFlag(O),getPosthogFeatureFlagPayload:O=>n?.getFeatureFlagPayload(O),getPosthogAllFlags:()=>n?.getAllFlags()??{},onPosthogFeatureFlags:O=>n?.onFeatureFlags(O)??(()=>{}),reloadPosthogFeatureFlags:()=>n?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=oe),oe}var Lp=Nk();return Vp(Lk);})();
|
|
7
8
|
/*! Bundled license information:
|
|
8
9
|
|
|
9
10
|
js-cookie/dist/js.cookie.mjs:
|
|
10
|
-
(*! js-cookie v3.0.
|
|
11
|
+
(*! js-cookie v3.0.8 | MIT *)
|
|
11
12
|
*/
|
|
12
13
|
//# sourceMappingURL=analytics.bundle.global.js.map
|