@deriv-com/analytics 1.42.1 → 1.44.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 +8 -6
- 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-L5T5UBUR.mjs +5 -0
- package/dist/chunk-L5T5UBUR.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-K2X2PYJR.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-DmVmqDsn.d.ts → posthog-BlpiD6V1.d.mts} +4 -0
- package/dist/{posthog-DmVmqDsn.d.mts → posthog-BlpiD6V1.d.ts} +4 -0
- package/dist/posthog-NG27XP3H.mjs +5 -0
- package/dist/posthog-NG27XP3H.mjs.map +1 -0
- package/dist/providers/growthbook/index.d.mts +1 -1
- package/dist/providers/growthbook/index.d.ts +1 -1
- 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 +18 -17
- 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-QH4OCJ4V.mjs +0 -4
- package/dist/posthog-QH4OCJ4V.mjs.map +0 -1
- /package/dist/{growthbook-TBZXPHJZ.mjs.map → growthbook-K2X2PYJR.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 Be(t,e){if(!t?.default&&e){let i=Object.create(null);return i.default=t,i.__esModule=!0,i}return t}function Ve(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 D=r(l.getItem(m[w]));this.has(m[w])&&(y[m[w]]=D)}return y}return r(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var v=this.get(p);return l.removeItem(p),v},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(v){p.push(v)}),p},forEach:function(p){for(var v=0,m=l.length;v<m;v++){var y=l.key(v);p(y,this.get(y))}return this},search:function(p){for(var v=this.keys(),m={},y=0,w=v.length;y<w;y++)v[y].indexOf(p)>-1&&(m[v[y]]=this.get(v[y]));return m},len:function(){return l.length}};var 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,N,re,qe,Te,rt,rf,te,hi,nf,lo,of,xn,af,lf,uf,ne,cf,Ae,Et,Hi,Ks,vt,at,uo,df,Ul,Ws,hf,gf,Ys,co,Eu,Su,ku,kn,ho,Dn,Xe,wu,qi,qt,zi,li,ff,wn,pf,vf,_f,Ms,Bl,Vs,Nt,An,zt,Gs,Us,Ef,ir,Sf,kf,wf,Au,Af,V,If,Vl,Tf,Rf,Pf,Of,Cf,xf,Df,Iu,Nf,st,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,Nn,Kl,zf,Kf,Ou,Ji,Cu,Wl,Yf,Xf,Jf,Qf,Zf,ep,tp,ip,sp,rp,Xs,np,J,Yi,bt,Js,op,Ln,Qs,Zs,$n,Bs,Yl,Mu,lp,up,cp,Fn,St,_t,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,Dp,Np,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,jt,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,Dv,d,zu,Nv,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,Ge,He,Ye,lt,Kt,O_,C_,x_,D_,N_,L_,$_,F_,M_,U_,B_,V_,ui,G_,rc,nc,q_,oc,ac,ci,ou,au,j_,H_,jn,z_,mt,K_,W_,Y_,X_,J_,Q_,Z_,Hn,er,Hs,tm,lu,sm,Gt,lc,di,zn,vo,Kn,_o,Wn,mo,it,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,Dm,gc,Nm,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,Ht,pi,yo=Ue(()=>{"use strict";zg=yt(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=yt(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=Dt(Qg),bu=Dt(function(e,i){var s={};for(var r in i)e(i[r],r,i)&&(s[r]=i[r]);return s}),N=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),re=t=>typeof t=="string",qe=t=>t===null,Te=t=>typeof t>"u",rt=t=>qe(t)||Te(t),rf=t=>typeof t=="bigint",te=t=>!Te(t),hi=t=>!rt(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=>!qe(t)&&lf(t)&&!Array.isArray(t),ne=t=>!qe(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)?Ae(i[r],s):s}),i},Ae=(t,e)=>tf(cf,t,e),Et=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},vt=t=>{if(Et(t))return Ks(t)},at=(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)&&!rt(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};N(r)&&(n.callback=r),N(s)&&(n.category=t,n.name=e,n.properties=i,n.options=void 0,n.callback=s),N(i)&&(n.category=t,n.name=e,n.properties=void 0,n.options=void 0,n.callback=i),N(e)&&(n.category=t,n.name=void 0,n.properties=void 0,n.options=void 0,n.callback=e),N(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,N(e)?n.options=void 0:n.options=e):ne(e)&&(n.name=void 0,n.properties=e,N(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=Ae(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 N(s)&&(r.callback=s),N(i)&&(r.properties=e,r.options=void 0,r.callback=i),N(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 N(s)&&(r.callback=s),N(i)&&(r.userId=t,r.traits=e,r.options=void 0,r.callback=i),N(e)&&(r.userId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ne(t)||qe(t))&&(r.userId=null,r.traits=t,N(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 N(s)&&(r.callback=s),N(i)&&(r.to=t,r.from=e,r.options=void 0,r.callback=i),N(e)?(r.to=t,r.from=void 0,r.options=void 0,r.callback=e):(ne(e)||qe(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 N(s)&&(r.callback=s),N(i)&&(r.groupId=t,r.traits=e,r.options=void 0,r.callback=i),N(e)&&(r.groupId=t,r.traits=void 0,r.options=void 0,r.callback=e),(ne(t)||qe(t))&&(r.groupId=null,r.traits=t,N(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",Dn="CapabilitiesManager",Xe="ConfigManager",wu="EventManager",qi="PluginsManager",qt="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);zt=256,Gs=[];for(;zt--;)Gs[zt]=(zt+256).toString(16).substring(1);Ef=()=>!rt(globalThis.crypto)&&N(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",Df="[BigInt]",Iu="[Circular Reference]",Nf=(t,e,i)=>{let s=[];return function(r,n){if(!e?.includes(r)&&!(t&&rt(n))){if(typeof n!="object"||qe(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)}}},st=(t,e,i,s)=>{try{return JSON.stringify(t,Nf(e,i,s))}catch(r){return s?.warn(Pf,r),null}},Lf=t=>{let e=[];return function(s,r){if(rf(r))return Df;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}: ${st(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}: ${st(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,Nn=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||Et(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(N(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=!N(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,bt=0,Js=0,op=0,Ln=0,Qs=void 0,Zs=0;De.prototype.brand=np;De.prototype.h=function(){return!0};De.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)}))};De.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)}))}};De.prototype.subscribe=function(t){var e=this;return ut(function(){var i=e.value,s=J;J=void 0;try{t(i)}finally{J=s}},{name:"sub"})};De.prototype.valueOf=function(){return this.value};De.prototype.toString=function(){return this.value+""};De.prototype.toJSON=function(){return this.value};De.prototype.peek=function(){var t=J;J=void 0;try{return this.value}finally{J=t}};Object.defineProperty(De.prototype,"value",{get:function(){var t=Du(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){bt!==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++,bt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{rr()}}}});vi.prototype=new De;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&&!Nu(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)}De.prototype.S.call(this,t)};vi.prototype.U=function(t){if(this.t!==void 0&&(De.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=Du(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),bt++;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],Te(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}},St=new Fn,_t=(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`,Dp=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,Np=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",jt="v3",uv="xhr",Un={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},qs={[jt]:"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:Nn,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:jt},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)}},Dv={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(Dv)},zu=/^\s*at /,Nv=/^(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,st(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=Ae(Yv,e||{});return i&&(s.headers=Ae(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=st(t.data,!1,[],i),qe(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=!N(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(St),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 _t.UNHANDLEDEXCEPTION:{let{error:i}=t;return i||t}case _t.UNHANDLEDREJECTION:return t.reason;case _t.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=st(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(Te(t.capabilities.isAdBlocked.value)){t.capabilities.isAdBlockerDetectionInProgress.value===!1&&Ju(e);let s=ut(()=>{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 st(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:_t.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:zi,errorType:_t.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??_t.HANDLEDEXCEPTION,l=s_(i,a),u=Yu(l,this.logger);if(Te(u))return;let c=r?`${r} - `:"",h=`${s}${V}${c}`,f=Vv(u,h),p=sr(u).includes(Ru);if(!p&&!g_(f)&&a!==_t.HANDLEDEXCEPTION)return;if(d.reporting.isErrorReportingEnabled.value&&await h_(f,d,this.httpClient)){let m={severity:"error",unhandled:a!==_t.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===_t.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,St),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,N(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(!N(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(St,{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()=>Ve("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>Be(e,!0));case"CustomConsentManager":return()=>Ve("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>Be(e,!0));case"DeviceModeDestinations":return()=>Ve("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>Be(e,!0));case"DeviceModeTransformation":return()=>Ve("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>Be(e,!0));case"ExternalAnonymousId":return()=>Ve("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>Be(e,!0));case"GoogleLinker":return()=>Ve("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>Be(e,!0));case"KetchConsentManager":return()=>Ve("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>Be(e,!0));case"IubendaConsentManager":return()=>Ve("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>Be(e,!0));case"NativeDestinationQueue":return()=>Ve("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>Be(e,!0));case"OneTrustConsentManager":return()=>Ve("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>Be(e,!0));case"StorageEncryption":return()=>Ve("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>Be(e,!0));case"StorageEncryptionLegacy":return()=>Ve("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>Be(e,!0));case"StorageMigrator":return()=>Ve("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>Be(e,!0));case"XhrQueue":return()=>Ve("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>Be(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(){ut(()=>{(d.plugins.activePlugins.value.length===0||d.plugins.loadedPlugins.value.length+d.plugins.failedPlugins.value.length===d.plugins.totalPluginsToLoad.value)&&Ie(()=>{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)),Ie(()=>{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)&&(N(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})}},Ge="cookieStorage",He="localStorage",Ye="sessionStorage",lt="memoryStorage",Kt="none",O_="test_rudder_cookie",C_="test_rudder_ls",x_="test_rudder_ss",D_="rl_user_id",N_="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:D_,userTraits:N_,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={[Ge]:rc,[He]:nc,[lt]:q_,[Ye]: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)}`;qe(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],mt=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(mt(r,1,n),mt(r))return mt(r,null,n),s}catch{try{mt(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=Ae(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(St);Hs={exports:{}},tm=Hs.exports;sm=im(),Gt=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=He,e,i)=>{let s,r,n=Cf(Dn,t),o="unavailable",a=!0,l;try{switch(t){case lt:return!0;case Ge:s=e,r=O_;break;case He:s=e??globalThis.localStorage,r=C_;break;case Ye: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=Ae(this.options,e??{}),this.isSupportAvailable=di(He),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){Gt.set(e,i),this.length=Gt.len()}getItem(e){let i=Gt.get(e);return Te(i)?null:i}removeItem(e){Gt.remove(e),this.length=Gt.len()}clear(){Gt.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return Gt.keys()}},vo=new zn(St),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=Ae(this.options,e??{}),this.isSupportAvailable=di(Ye),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 Te(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(St),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=Ae(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=di(Ge,this),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,i){return mt(e,i,this.options,this.logger),this.length=Object.keys(mt()).length,!0}getItem(e){let i=mt(e);return Te(i)?null:i}removeItem(e){let i=this.setItem(e,null);return this.length=Object.keys(mt()).length,i}clear(){}key(e){return this.keys()[e]??null}keys(){return Object.keys(mt())}},mo=new Wn(St),it=t=>{switch(t){case He:return vo;case Ye:return _o;case lt:return er;case Ge: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=it(lt);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(st(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)),rt(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 rt(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=Kt;break;case"session":e!=="sessionInfo"&&(i=Kt);break;case"anonymousId":e!=="anonymousId"&&(i=Kt);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(Ae(i.cookieStorageOptions??{},d.storage.cookie?.value??{})),Hi(i.localStorageOptions),Hi(i.inMemoryStorageOptions),Hi(i.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[lt,He,Ge,Ye].forEach(i=>{it(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!==Kt&&(r=!1),n={...n,[o]:{type:f,key:ui[l]}}}),Ie(()=>{d.storage.type.value=e,d.storage.entries.value=n,d.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,i){let s=e;switch(e){case He:it(He)?.isEnabled||(s=lt);break;case Ye:it(Ye)?.isEnabled||(s=lt);break;case lt:case Kt:break;case Ge:default:it(Ge)?.isEnabled?s=Ge:it(He)?.isEnabled?s=He:it(Ye)?.isEnabled?s=Ye:s=lt;break}return s!==e&&this.logger.warn(Yp(ff,i,e,s)),s}setStore(e){let i=it(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)&&!rt(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 N(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,Et(i.integrations)&&(e.integrations=i.integrations),e.discardPreConsentEvents=i.discardPreConsentEvents===!0,e.sendPageEvent=i.sendPageEvent===!0,e.trackConsent=i.trackConsent===!0,Et(i.consentManagement)&&(e.consentManagement=Ae(i.consentManagement,{enabled:d.consents.enabled.value}))}return e},uu=t=>Et(t)||Array.isArray(t),Em=(t,e)=>{let{provider:i}=t,s=i?Un[i]:void 0;return i&&!s&&(e.error(_p(Xe,i,Un)),i=void 0),{provider:i,consentManagerPluginName:s}},dc=(t,e)=>{let i,s=[],r=[],n=!1,o,a=t?.enabled===!0;Et(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(Xe,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(Xe,i,Mn)),i=Mn);let s=e?.encryption?.version,r=s&&qs[s];!Te(s)&&Te(r)?(t.warn($p(Xe,s,qs,jt)),s=jt):Te(s)&&(s=jt);let n=e?.migrate,o=n&&s===jt;n===!0&&o!==n&&t.warn(Fp(Xe,s,jt));let{sscEnabled:a,finalDataServiceUrl:l,cookieOptions:u}=wm(t);Ie(()=>{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(Xe,o?.storage?.strategy,Rn)));let u=o?.events?.delivery??Pn,c=["immediate","buffer"];te(u)&&!c.includes(u)&&(u=Pn,t.warn(ev(Xe,o?.events?.delivery,Pn))),Ie(()=>{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),Ie(()=>{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(Xe)))),Ie(()=>{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(Xe,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(Xe,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(){ut(()=>{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(qe(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),Ie(()=>{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:Xe,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):[];Ie(()=>{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(!N(e)){this.logger.error(pp(Xe));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})}},Dm=()=>{let t=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return t?.[1]?t[1]:"NA"},gc=(t=()=>document)=>t()?.referrer||"$direct",Nm=(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(Te(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 Te(e)?null:e.language??e.browserLanguage},fc=(t=()=>globalThis.location,e=()=>document)=>{let i=t(),s=Nm(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:()=>!N(globalThis.URL)||!N(globalThis.URLSearchParams),Promise:()=>!N(globalThis.Promise),"Number.isNaN":()=>!N(globalThis.Number.isNaN),"Number.isInteger":()=>!N(globalThis.Number.isInteger),"Array.from":()=>!N(globalThis.Array.from),"Array.prototype.find":()=>!N(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!N(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!N(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!N(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!N(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!N(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!N(globalThis.String.fromCodePoint),"Object.entries":()=>!N(globalThis.Object.entries),"Object.values":()=>!N(globalThis.Object.values),"Object.assign":()=>!N(globalThis.Object.assign),"Object.fromEntries":()=>!N(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!Mm(),TextEncoder:()=>!N(globalThis.TextEncoder)||!N(globalThis.TextDecoder),requestAnimationFrame:()=>!N(globalThis.requestAnimationFrame)||!N(globalThis.cancelAnimationFrame),CustomEvent:()=>!N(globalThis.CustomEvent),"navigator.sendBeacon":()=>!N(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!N(globalThis.Uint8Array),Set:()=>!N(globalThis.Set),atob:()=>!N(globalThis.atob)},Um=()=>{let t=Object.keys(Zn),e=!1;for(let i=0;i<t.length;i++){let s=Zn[t[i]];if(N(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=()=>!rt(globalThis.crypto)&&N(globalThis.crypto.getRandomValues),du=()=>!rt(globalThis.navigator.userAgentData),jm=()=>!rt(globalThis.navigator.sendBeacon)&&N(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(){Ie(()=>{d.capabilities.storage.isCookieStorageAvailable.value=di(Ge,it(Ge),this.logger),d.capabilities.storage.isLocalStorageAvailable.value=di(He,void 0,this.logger),d.capabilities.storage.isSessionStorageAvailable.value=di(Ye,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=Dm(),du()&&Fm(e=>{d.context["ua-ch"].value=e},d.loadOptions.value.uaChTrackLevel)}),ut(()=>{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(Dn,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:Dn,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(qt,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===Ge||t===He||t===Ye||t===lt,to=()=>ir(),Zm=t=>{if(of(t)){let{entries:e,...i}=In;return{...i,entries:{...e,anonymousId:t}}}return ne(t)&&ne(t.entries)?Ae(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=>{Te(s[n])&&(s[n]=i[n]||r[n])}),Te(s.initial_referrer)&&(s.initial_referrer=i.initial_referrer||d.session.initialReferrer.value),Te(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),Et(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=Ae(s,{[r]:e[r]});else if(!Te(e[r])&&ne(e[r])){let n={};Object.keys(e[r]).forEach(o=>{gu.includes(o)||(n[o]=e[r][o])}),s=Ae(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!==Kt?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!==Kt?W(d.session.groupTraits.value):t.traits));let n=Ae(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=[Ge,He,Ye];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);rt(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(qt,s,Nn)),i=Nn),i===0&&(this.logger.warn(Hp(qt)),e=!1),i>0&&i<Kl&&this.logger.warn(zp(qt,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(qt,s,e)),r=!1):(this.logger.warn(qp(qt,s,zl)),s=zl)),{enabled:r,duration:s}}onError(e,i,s){this.errorHandler.onError({error:e,context:qt,customMessage:i,groupingHash:s})}getEncryptedCookieData(e,i){let s=[];return e.forEach(r=>{let n=i?.encrypt(st(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:st({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);st(u[g.name],!1,[])!==st(v,!1,[])&&(qe(p)&&qe(v)&&this.logger.error(Np(g.name)),i&&i(g.name,g.value))}):(this.logger.error(Dp(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)||Et(o))?d.serverCookies.isEnabledServerSideCookies.value&&s===Ge?(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=>{ut(()=>{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",it,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=it(Ge);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);Ie(()=>{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)?Ae(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)?Ae(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=at(i.secureCookie,t.secureCookie),i.sameDomainCookiesOnly=at(i.sameDomainCookiesOnly,t.sameDomainCookiesOnly),["none","default","full"].includes(i.uaChTrackLevel)||(i.uaChTrackLevel=void 0),i.integrations=vt(i.integrations),Array.isArray(i.plugins)||(i.plugins=ly),i.useGlobalIntegrationsConfigInEvents=at(i.useGlobalIntegrationsConfigInEvents,t.useGlobalIntegrationsConfigInEvents),i.bufferDataPlaneEventsUntilReady=at(i.bufferDataPlaneEventsUntilReady,t.bufferDataPlaneEventsUntilReady),i.sendAdblockPage=at(i.sendAdblockPage,t.sendAdblockPage),i.useServerSideCookies=at(i.useServerSideCookies,t.useServerSideCookies),re(i.dataServiceEndpoint)||(i.dataServiceEndpoint=void 0),i.sendAdblockPageOptions=vt(i.sendAdblockPageOptions),i.loadIntegration=at(i.loadIntegration,t.loadIntegration),Et(i.storage)?(i.storage.migrate=at(i.storage.migrate,t.storage?.migrate),i.storage.cookie=vt(i.storage.cookie),i.storage.encryption=vt(i.storage.encryption),i.storage=Ks(i.storage)):i.storage=void 0,i.destinationsQueueOptions=vt(i.destinationsQueueOptions),i.queueOptions=vt(i.queueOptions),i.lockIntegrationsVersion=at(i.lockIntegrationsVersion,t.lockIntegrationsVersion),i.lockPluginsVersion=at(i.lockPluginsVersion,t.lockPluginsVersion),pc(i.dataPlaneEventsBufferTimeout)||(i.dataPlaneEventsBufferTimeout=void 0),i.beaconQueueOptions=vt(i.beaconQueueOptions),i.preConsent=vt(i.preConsent),i.sourceConfigurationOverride=vt(i.sourceConfigurationOverride),Ae(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=Ae(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(N(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),ut(()=>{d.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=gy(d),i;ut(()=>{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=St,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}Ie(()=>{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(){ut(()=>{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(),Ie(()=>{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];N(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){Ie(()=>{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),ut(()=>{d.nativeDestinations.initializedDestinations.value.length+d.nativeDestinations.failedDestinations.value.length===e&&Ie(()=>{d.lifecycle.status.value="destinationsReady",d.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){d.lifecycle.status.value!=="ready"&&Ie(()=>{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`),!N(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(),qe(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,qe(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"),Ie(()=>{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]]}}},Ht=class Ht{constructor(){ae(this,"analyticsInstances",{});ae(this,"defaultAnalyticsKey","");ae(this,"logger",St);try{if(Ht.globalSingleton)return Ht.globalSingleton;Ht.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(),Ht.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(Ht,"globalSingleton",null);pi=Ht});var mc,yc,bo,_c,bc,Ec,Sc,kc,Zi=Ue(()=>{"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=Ue(()=>{"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 Lt,ur,es,lr,Ic,Wt,Tc,Rc,ts=Ue(()=>{"use strict";Ac();Zi();Lt=(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},Wt=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=Wt(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=Wt(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 Xt(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 ze(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=Ue(()=>{"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(Ce,t),Ce.backgroundSync||Oo()}async function Wc({instance:t,timeout:e,skipCache:i,allowStale:s,backgroundSync:r}){return r||(Ce.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(!ct.localStorage)return;await ct.localStorage.setItem(Ce.cacheKey,JSON.stringify(Array.from(kt.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()-Ce.maxAge+Ce.staleTTL);await Iy();let l=!Ce.disableCache&&!s?kt.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(ct.localStorage){let t=await ct.localStorage.getItem(Ce.cacheKey);if(!Ce.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(([i,s])=>{kt.set(i,{...s,staleAt:new Date(s.staleAt)})}),Xc()}}}catch{}if(!Ce.disableIdleStreams){let t=mi.startIdleListener();t&&(mi.stopIdleListener=t)}}}function Xc(){let t=Array.from(kt.entries()).map(([i,s])=>({key:i,staleAt:s.staleAt.getTime()})).sort((i,s)=>i.staleAt-s.staleAt),e=Math.min(Math.max(0,kt.size-Ce.maxEntries),kt.size);for(let i=0;i<e;i++)kt.delete(t[i].key)}function Jc(t,e,i){let s=i.dateUpdated||"",r=new Date(Date.now()+Ce.staleTTL),n=Ce.disableCache?void 0:kt.get(e);if(n&&s&&n.version===s){n.staleAt=r,zc();return}Ce.disableCache||(kt.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),Ce.backgroundSync&&Ei.has(i)&&ct.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 Ce,ct,mi,yi,Hc,kt,_r,bi,Ei,Zc=Ue(()=>{"use strict";rs();Ce={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},ct=Fc(),mi={fetchFeaturesCall:({host:t,clientKey:e,headers:i})=>ct.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 ct.fetch(`${t}/api/eval/${e}`,r)},eventSourceCall:({host:t,clientKey:e,headers:i})=>i?new ct.EventSource(`${t}/sub/${e}`,{headers:i}):new ct.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,Ce.idleStreamInterval))};return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(ct.localStorage=globalThis.localStorage)}catch{}yi=new Map,Hc=!1,kt=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 Dy(t){var e=t.originalValue;t.mutations.forEach(function(i){return e=i.mutate(e)}),Ar(e,t)}function Ny(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=Ny(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),Dy)),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(),No.delete(t)}function td(){No.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"?Do:(No.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}):Do}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 Do}var Py,Do,Sr,No,$y,Fy,My,Uy,By,Vy,Gy,qy,yr,Co,Qy,ld,ud=Ue(()=>{"use strict";Py=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Do={revert:function(){}},Sr=new Map,No=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 $t(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($t(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=>$t(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 ze(e)===ze(i);case"$vne":return ze(e)!==ze(i);case"$vgt":return ze(e)>ze(i);case"$vgte":return ze(e)>=ze(i);case"$vlt":return ze(e)<ze(i);case"$vlte":return ze(e)<=ze(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($t(t,e[s],i))return!0;return!1}function sb(t,e,i){for(let s=0;s<e.length;s++)if(!$t(t,e[s],i))return!1;return!0}var Lo,fd=Ue(()=>{"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 Ft(e,t,null,"cyclicPrerequisite");e.stack.evaluatedFeatures.add(t),e.stack.id=t;let i=ob(e);if(i.has(t))return Ft(e,t,i.get(t),"override");if(!e.global.features||!e.global.features[t])return Ft(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 Ft(e,t,null,"cyclicPrerequisite");let c={value:u.value};if(!$t(c,l.condition||{})){if(l.gate)return Ft(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})}),Ft(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 Ft(e,t,a.value,"experiment",n.id,o,a)}}return Ft(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}=Jt(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(!$t(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 Ft(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 $t(vd(e),t,e.global.savedGroups||{})}function md(t,e){return t.some(i=>{let{hashValue:s}=Jt(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}=Jt(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}=Jt(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 Jt(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}=Jt(t,e),n=Fo(s,ss(r)),{hashAttribute:o,hashValue:a}=Jt(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}=Jt(t,r);i[r]=ss(n)}),i}async function bd(t,e,i){if(t={...t},t.encryptedFeatures){try{t.features=JSON.parse(await Xt(t.encryptedFeatures,e,i))}catch(s){console.error(s)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await Xt(t.encryptedExperiments,e,i))}catch(s){console.error(s)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await Xt(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=Ue(()=>{"use strict";fd();rs();rb="Feature Evaluated",nb="Experiment Viewed"});var wi,_b,ls,kd=Ue(()=>{"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 Xt(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 Xt(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=Ue(()=>{"use strict";kd()});var Ad={};Sn(Ad,{Growthbook:()=>Uo});var Je,Uo,Id=Ue(()=>{"use strict";wd();yo();Zi();ts();Je=class Je{constructor(e,i,s={},r=!1){this.analytics=new pi;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=Lt("[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)})}};Je.getGrowthBookInstance=(e,i,s,r=!1)=>Je._instance?(typeof window<"u"&&console.warn&&console.warn("GrowthBook instance already exists. Ignoring new initialization parameters."),Je._instance):(Je._instance=new Je(e,i??"",s,r),Je._instance),Je.resetInstance=()=>{Je._instance&&(Je._instance.destroy(),Je._instance=void 0)};Uo=Je});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 Ze(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=Ze((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=Ze((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 ft(t,e,i,s,r){return e>i&&(s.warn("min cannot be greater than max."),e=i),tt(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),ft(r||i,e,i,s))}function qh(t){if(gt(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];Ot(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(!tt(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 be(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,Ds),t),o=(s={},oe(aE,(function(a){var l=ht.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(!Ot(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=Re?.href.substring(0,1e3);return{r:ug().substring(0,1e3),u:s?xs(s,i,Ds):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 et(p+y+5*(1+Math.floor(y/7e3))+v),R=w.subarray(p,w.length-v),D=0;if(!f||8>y)for(var b=0;y>=b;b+=65535){var x=b+65535;y>x?D=il(R,D,h.subarray(b,x)):(R[b]=!0,D=il(R,D,h.subarray(b,y)))}else{for(var C=gE[f-1],O=C>>>13,A=8191&C,$=(1<<g)-1,U=new Fe(32768),H=new Fe($+1),G=Math.ceil(g/3),q=2*G,me=function(En){return(h[En]^h[En+1]<<G^h[En+2]<<q)&$},Se=new Gi(25e3),Me=new Fe(288),ke=new Fe(32),k=0,M=0,F=(b=0,0),B=0,Z=0;y>b;++b){var ce=me(b),se=32767&b,ye=H[ce];if(U[se]=ye,H[ce]=se,b>=B){var Oe=y-b;if((k>7e3||F>24576)&&Oe>423){D=Hd(h,R,0,Se,Me,ke,M,F,Z,b-Z,D),F=k=M=0,Z=b;for(var we=0;286>we;++we)Me[we]=0;for(we=0;30>we;++we)ke[we]=0}var j=2,pt=0,Lg=A,Ct=se-ye&32767;if(Oe>2&&ce==me(b-Ct))for(var $g=Math.min(O,Oe)-1,Fg=Math.min(32767,b),Mg=Math.min(258,Oe);Fg>=Ct&&--Lg&&se!=ye;){if(h[b+j]==h[b+j-Ct]){for(var xt=0;Mg>xt&&h[b+xt]==h[b+xt-Ct];++xt);if(xt>j){if(j=xt,pt=Ct,xt>$g)break;var Ug=Math.min(Ct,xt-2),Nl=0;for(we=0;Ug>we;++we){var bn=b-Ct+we+32768&32767,Ll=bn-U[bn]+32768&32767;Ll>Nl&&(Nl=Ll,ye=bn)}}}Ct+=(se=ye)-(ye=U[se])+32768&32767}if(pt){Se[F++]=268435456|Za[j]<<18|el[pt];var $l=31&Za[j],Fl=31&el[pt];M+=Pl[$l]+Ol[Fl],++Me[257+$l],++ke[Fl],B=b+j,++k}else Se[F++]=h[b],++Me[h[b]]}}D=Hd(h,R,!0,Se,Me,ke,M,F,Z,b-Z,D)}return vg(w,0,p+pg(D)+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)||Ot(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 ai(t){return!!t&&t.nodeType===IE}function ot(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&&ai(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||!ai(e))&&e}function fl(t){for(var e=t;e.parentNode&&!ot(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!!(ot(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||ot(t,"select")||ot(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:DE).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 NE(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&&!ai(e));return e}function $E(t,e){var i,s,{e:r,maskAllElementAttributes:n,maskAllText:o,elementAttributeIgnoreList:a,elementsChainAsString:l}=e;if(!ai(t))return{props:{}};for(var u=[t],c=t;c.parentNode&&!ot(c,"body");)if(wg(c.parentNode))u.push(c.parentNode.host),c=c.parentNode.host;else{if(!ai(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(ot(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 me=fn(A);me.length>0&&(q.classes=me.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 Se=1,Me=1,ke=A;ke=LE(ke);)Se++,ke.tagName===A.tagName&&Me++;return q.nth_child=Se,q.nth_of_type=Me,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=ot(t,"a")||ot(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,D=_==null||(w=_.location)==null?void 0:w.host;R&&D&&R!==D&&(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[me]=G,[Se]=q;return me.localeCompare(Se)})).forEach((G=>{var[q,me]=G;return H[ah(q.toString())]=ah(me.toString())})),(A+=":")+Vr(H).map((G=>{var[q,me]=G;return q+'="'+me+'"'})).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:NE(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 Tt(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&&tt(t.clientX)&&tt(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 _,Ee,Ke,I,Re,aa,la,Td,mb,je,L,Rd,$e,yb,Od,bb,vn,ca,kh,wh,_n,Y,Tt,ve,Di,P,ge,Mr,Ot,K,tt,Pi,gt,Eb,Sb,kb,Bo,wb,da,Or,Cd,Vo,We,jr,Pt,Mi,Ih,Th,Rh,Ph,ws,Ui,Oh,Ch,xh,ri,Ab,Dh,El,Nh,Sl,Ib,kl,Lh,$i,$h,Os,Cs,Fi,Fh,Mh,_s,ha,xd,ga,Uh,Tb,Bh,fa,Le,Go,Rb,Pb,Ob,wl,Cb,Vh,xb,Db,Dd,Nd,Nb,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,Da,bs,Wh,Yh,Xh,Jh,Yr,Il,Ni,Ur,Es,Na,La,$a,It,Oi,Ss,ii,Fa,Ma,Br,As,Ua,Ba,Xr,nt,Va,Ga,qa,ja,Jr,Qr,Qh,Cr,Zh,eg,tg,Tl,si,Rt,Ai,Ii,Ha,Zr,en,Ci,Ho,zo,Fd,pe,Md,Yb,Rl,Xb,za,Ka,Ud,sg,Wa,Vt,Qb,us,Zb,ht,Ko,he,eE,Dr,tE,Qt,Pe,Ya,Nr,iE,sE,tn,Wo,rg,Xa,sn,rE,nE,rn,nn,xs,on,Lr,Vi,oE,Ds,aE,an,uE,Is,cs,Yo,ks,Xo,Ja,cE,Vd,Gd,Qa,ds,ln,dt,et,Fe,Gi,Pl,Ol,qd,gg,fg,Za,Zt,el,un,ie,Ts,oi,cn,dE,hE,pg,vg,wt,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,Ns,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,ni,IE,TE,RE,xl,PE,rh,gl,nh,Rg,OE,CE,Pg,xE,DE,pn,ia,sa,ps,FE,Mt,uh,ch,dh,vs,Fr,pl,Ut,ME,gh,UE,Bt,fh,vl,_l,ml,na,ph,BE,vh,_h,Ne,ei,oa,mh,yh,At,bh,VE,yl,Qe,ti,yn,GE,qE,jE,HE,zE,KE,WE,YE,XE,JE,QE,ZE,Eh,_e,Cg=Ue(()=>{"use strict";_=typeof window<"u"?window:void 0,Ee=typeof globalThis<"u"?globalThis:_;typeof self>"u"&&(Ee.self=Ee),typeof File>"u"&&(Ee.File=function(){});Ke=Ee?.navigator,I=Ee?.document,Re=Ee?.location,aa=Ee?.fetch,la=Ee!=null&&Ee.XMLHttpRequest&&"withCredentials"in new Ee.XMLHttpRequest?Ee.XMLHttpRequest:void 0,Td=Ee?.AbortController,mb=Ee?.CompressionStream,je=Ke?.userAgent,L=_??{},Rd="1.372.9",$e={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]"},Tt=t=>typeof t=="function",ve=t=>t===Object(t)&&!Y(t),Di=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,Ot=t=>t===null,K=t=>P(t)||Ot(t),tt=t=>_n.call(t)=="[object Number]"&&t==t,Pi=t=>tt(t)&&t>0,gt=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=ft(e.bucketSize,0,100,e.Gt),this.Qt=ft(e.refillRate,0,this.Zt,e.Gt),this.Jt=ft(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={}}},We="Mobile",jr="iOS",Pt="Android",Mi="Tablet",Ih=Pt+" "+Mi,Th="iPad",Rh="Apple",Ph=Rh+" Watch",ws="Safari",Ui="BlackBerry",Oh="Samsung",Ch=Oh+"Browser",xh=Oh+" Internet",ri="Chrome",Ab=ri+" OS",Dh=ri+" "+jr,El="Internet Explorer",Nh=El+" "+We,Sl="Opera",Ib=Sl+" Mini",kl="Edge",Lh="Microsoft "+kl,$i="Firefox",$h=$i+" "+jr,Os="Nintendo",Cs="PlayStation",Fi="Xbox",Fh=Pt+" "+We,Mh=We+" "+ws,_s="Windows",ha=_s+" Phone",xd="Nokia",ga="Ouya",Uh="Generic",Tb=Uh+" "+We.toLowerCase(),Bh=Uh+" "+Mi.toLowerCase(),fa="Konqueror",Le="(\\d+(\\.\\d+)?)",Go=new RegExp("Version/"+Le),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"+We)||z(t,"WPDesktop")?Nh:z(t,Ch)?xh:z(t,kl)||z(t,"Edg/")?Lh:z(t,"FBIOS")?"Facebook "+We:z(t,"UCWEB")||z(t,"UCBrowser")?"UC Browser":z(t,"CriOS")?Dh:z(t,"CrMo")||z(t,ri)?ri:z(t,Pt)&&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,ri)&&!z(r,Pt)})(i))(t,e)?z(t,We)?Mh:ws:z(t,$i)?$i:z(t,"MSIE")||z(t,"Trident/")?El:z(t,"Gecko")?$i:""},xb={[Nh]:[new RegExp("rv:"+Le)],[Lh]:[new RegExp(kl+"?\\/"+Le)],[ri]:[new RegExp("("+ri+"|CrMo)\\/"+Le)],[Dh]:[new RegExp("CriOS\\/"+Le)],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/"+Le)],[ws]:[Go],[Mh]:[Go],[Sl]:[new RegExp("(Opera|OPR)\\/"+Le)],[$i]:[new RegExp($i+"\\/"+Le)],[$h]:[new RegExp("FxiOS\\/"+Le)],[fa]:[new RegExp("Konqueror[:/]?"+Le,"i")],[Ui]:[new RegExp(Ui+" "+Le),Go],[Fh]:[new RegExp("android\\s"+Le,"i")],[xh]:[new RegExp(Ch+"\\/"+Le)],[El]:[new RegExp("(rv:|MSIE )"+Le)],Mozilla:[new RegExp("rv:"+Le)]},Db=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},Dd=[[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(We).test(e)&&!/IEMobile\b/.test(e))return[_s+" "+We,""];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("("+Pt+" (\\d+)\\.(\\d+)\\.?(\\d+)?|"+Pt+")","i"),t=>t&&t[2]?[Pt,[t[2],t[3],t[4]||"0"].join(".")]:[Pt,""]],[/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",""]]],Nd=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(We).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)?Pt:Ih:new RegExp("(pda|"+We+")","i").test(t)?Tb:new RegExp(Mi,"i").test(t)&&!new RegExp(Mi+" pc","i").test(t)?Bh:""},Nb=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 Ze((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 Ze((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(Nb(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)&&!tt(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(_&&($e.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",Da="$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",Ni="$enabled_feature_flags",Ur="$active_feature_flags",Es="$early_access_features",Na="$feature_flag_details",La="$feature_flag_payloads",$a="$feature_flag_request_id",It="$override_feature_flags",Oi="$override_feature_flag_payloads",Ss="$stored_person_properties",ii="$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",nt="$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.",si="on_reject",Rt="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||tt(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 tt(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++]}},Vt=()=>Qb().toString(),Qb=()=>(Ud||(Ud=new Ka)).generate(),us="",Zb=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,ht={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(ht.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_"+Vt();!us&&y--;){var R=m.slice(y).join("."),D=w+"=1;domain=."+R+";path=/";v.cookie=D+";max-age=3",v.cookie.includes(w)&&(v.cookie=D+";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{ht.N(t,"",-1,e)}catch{return}}},Ko=null,he={R(){if(!Ot(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,nt],Dr={},tE={R:()=>!0,D(t){T.error("memoryStorage error: "+t)},A:t=>Dr[t]||null,F:t=>Dr[t]||null,N(t,e){Dr[t]=e},q(t){delete Dr[t]}},Qt=null,Pe={R(){if(!Ot(Qt))return Qt;if(Qt=!0,P(_))Qt=!1;else try{var t="__support__";Pe.N(t,"xyz"),Pe.A(t)!=='"xyz"'&&(Qt=!1),Pe.q(t)}catch{Qt=!1}return Qt},D(t){T.error("sessionStorage error: ",t)},A(t){try{return _?.sessionStorage.getItem(t)}catch(e){Pe.D(e)}return null},F(t){try{return JSON.parse(Pe.A(t))||null}catch{}return null},N(t,e){try{_?.sessionStorage.setItem(t,JSON.stringify(e))}catch(i){Pe.D(i)}},q(t){try{_?.sessionStorage.removeItem(t)}catch(e){Pe.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===Rt||this.isRejected()||this.consent===-1&&this.qt.cookieless_mode===si}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:ht;if(!this.ar||this.ar!==i){this.ar=i;var s=e==="localStorage"?ht: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&&[Ke?.doNotTrack,Ke?.msDoNotTrack,L.doNotTrack].some((e=>Bo(e)))}},Nr=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 gt(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?Nr.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),Nr.info("starting...")}}else Nr.error("`document` not found. Cannot start.")}stop(){this.ur&&(this.ur.stop(),this.ur=void 0,Nr.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?ft(a/o,0,1,T):1,g=o>1?ft(l/o,0,1,T):1,p=u>1?ft(c/u,0,1,T):1,v=u>1?ft(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"},[Da]:{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"},[Ni]:{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"},[Na]:{exposure:"hidden"},[La]:{exposure:"event"},[$a]:{exposure:"event"},[It]:{exposure:"event"},[Oi]:{exposure:"hidden"},[Ss]:{exposure:"hidden"},[ii]:{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"},[nt]:{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],Ds="<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=ht.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&&ht.N(o,f,l,u,c,h)}catch(g){he.D(g)}},q(o,a){try{_?.localStorage.removeItem(o),ht.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"&&Pe.R()?Pe:s==="memory"?tE:s==="cookie"?ht:i.R()?i:ht}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===Ni?()=>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);Di(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())}},dt={GZipJS:"gzip-js",Base64:"base64"},et=Uint8Array,Fe=Uint16Array,Gi=Uint32Array,Pl=new et([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 et([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 et([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 Fe(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 Fe(32768),ie=0;32768>ie;++ie)Zt=(43690&ie)>>>1|(21845&ie)<<1,un[ie]=((65280&(Zt=(61680&(Zt=(52428&Zt)>>>2|(13107&Zt)<<2))>>>4|(3855&Zt)<<4))>>>8|(255&Zt)<<8)>>>1;Ts=function(t,e,i){for(var s=t.length,r=0,n=new Fe(e);s>r;++r)++n[t[r]-1];var o,a=new Fe(e);for(r=0;e>r;++r)a[r]=a[r-1]+n[r-1]<<1;if(i){o=new Fe(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 Fe(s),r=0;s>r;++r)o[r]=un[a[t[r]-1]++]>>>15-t[r];return o},oi=new et(288);for(ie=0;144>ie;++ie)oi[ie]=8;for(ie=144;256>ie;++ie)oi[ie]=9;for(ie=256;280>ie;++ie)oi[ie]=7;for(ie=280;288>ie;++ie)oi[ie]=8;cn=new et(32);for(ie=0;32>ie;++ie)cn[ie]=5;dE=Ts(oi,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 Fe?Fe:t instanceof Gi?Gi:et)(i-e);return s.set(t.subarray(e,i)),s},wt=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 et(0),0];if(r==1){var o=new et(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 Fe(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 D=n[s].s;g[D]==e&&(--g[D],++v)}p=e}return[new et(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 Fe(++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){wt(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],D=jd(v),b=D[0],x=D[1],C=new Fe(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,me,Se,Me=u+5<<3,ke=gs(r,oi)+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(ke>=Me&&k>=Me)return il(e,c,t.subarray(l,l+u));if(wt(e,c,1+(ke>k)),c+=2,ke>k){G=Ts(f,g,0),q=f,me=Ts(v,m,0),Se=v;var M=Ts($,U,0);for(wt(e,c,R-257),wt(e,c+5,x-1),wt(e,c+10,H-4),c+=14,O=0;H>O;++O)wt(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)wt(e,c,M[ce=31&Z[O]]),c+=$[ce],ce>15&&(wt(e,c,Z[O]>>>5&127),c+=Z[O]>>>12)}}else G=dE,q=oi,me=hE,Se=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&&(wt(e,c,s[O]>>>23&31),c+=Pl[ce]);var se=31&s[O];hs(e,c,me[se]),c+=Se[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===dt.GZipJS){var s=pE((function(a,l){var u=a.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(a);for(var c=new et(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 et(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===dt.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=Ze((function*(e){var i=Li(e.data),s=yield(function(n,o,a){return ua.apply(this,arguments)})(i,$e.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:$e.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)}}),Ke!=null&&Ke.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});Ke.sendBeacon(e,n)}catch{}}});sl=3e3,rl=class{constructor(e,i){this.Ar=!0,this.Nr=[],this.$r=ft(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},be(_,"online",this.Wr),be(_,"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(){be(_,"scroll",this.Yr,{capture:!0}),be(_,"scrollend",this.Yr,{capture:!0}),be(_,"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}},Ns=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 Ns,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===Rt)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||Vt,this.fi=s||Vt;var n=this.qt.persistence_name||this.qt.token;if(this._sessionTimeoutMs=1e3*ft(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=Pe.F(this.gi),a=Pe.F(this.mi);o&&!a?this.ci=o:Pe.q(this.gi),Pe.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&&Pe.R()}xi(e){e!==this.ci&&(this.ci=e,this.yi()&&Pe.N(this.gi,e))}Si(){return this.ci?this.ci:this.yi()?Pe.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()&&Pe.q(this.mi)},be(_,en,this.li,{capture:!1})}checkAndGetSessionAndWindowId(e,i){if(e===void 0&&(e=!1),i===void 0&&(i=null),this.qt.cookieless_mode===Rt)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&&je?.indexOf("MSIE")===-1&&je?.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:Re&&ge(Re?.search)&&Re.search.indexOf("__posthog_debug=true")!==-1||!1,cookie_expiration:365,upgrade:!1,disable_session_recording:!1,disable_persistence:!1,disable_web_experiments:!0,disable_surveys:!1,disable_surveys_automatic_display:!1,disable_conversations:!1,disable_product_tours:!1,disable_external_dependency_loading:!1,enable_recording_console_log:void 0,secure_cookie:(_==null||(e=_.location)==null?void 0:e.protocol)==="https:",ip:!1,opt_out_capturing_by_default:!1,opt_out_persistence_by_default:!1,opt_out_useragent_filter:!1,opt_out_capturing_persistence_type:"localStorage",consent_persistence_name:null,opt_out_capturing_cookie_prefix:null,opt_in_site_apps:!1,property_denylist:[],respect_dnt:!1,sanitize_properties:null,request_headers:{},request_batching:!0,properties_string_max_length:65535,mask_all_element_attributes:!1,mask_all_text:!1,mask_personal_data_properties:!1,custom_personal_data_properties:[],advanced_disable_flags:!1,advanced_disable_decide:!1,advanced_disable_feature_flags:!1,advanced_disable_feature_flags_on_first_load:!1,advanced_only_evaluate_survey_feature_flags:!1,advanced_feature_flags_dedup_per_session:!1,advanced_enable_surveys:!1,advanced_disable_toolbar_metrics:!1,feature_flag_request_timeout_ms:3e3,surveys_request_timeout_ms:1e4,on_request_error(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}},ni=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===Rt||this.config.cookieless_mode===si&&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=$e.LIB_VERSION,this.Li=new Ns,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:dt.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)),$e.DEBUG=$e.DEBUG||this.config.debug,$e.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(nt);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(Vt()),p=i.bootstrap.isIdentifiedID?g:c;this.persistence.set_property(nt,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(Vt());this.register_once({distinct_id:v,$device_id:v},""),this.persistence.set_property(nt,Ai)}return be(_,"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,D){var b=R.config.segment;if(!b)return D();var x=O=>{var A=()=>O.anonymousId()||Vt();R.config.get_device_id=A,O.id()&&(R.register({distinct_id:O.id(),$device_id:A()}),R.persistence.set_property(nt,Ii)),D()},C=b.user();"then"in C&&Tt(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 D=(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=>D(b,b.event.event),page:b=>D(b,Ci),identify:b=>D(b,zo),screen:b=>D(b,"$screen")}})(m)).then((()=>{y()}))}))})(this,(()=>this.Wi())):this.Wi(),Tt(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,dt.GZipJS)?dt.GZipJS:z(e.supportedCompression,dt.Base64)?dt.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&&Re!=null&&Re.hostname){var e=Re.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===dt.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):Tt(a)?a.call(this):Y(a)&&i==="alias"?s.push(a):Y(a)&&i.indexOf("capture")!==-1&&Tt(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]];Tt(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=Vt(),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],D=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:D}),p.$set=S({},p.$set,{[(v={id:R,current_iteration:D},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(Di(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)&&!tt(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,D,b,x;if(!je)return{};var C,O,A,$,U,H,G,q,me=y?[...Vi,...w||[]]:[],[Se,Me]=(function(ke){for(var k=0;Dd.length>k;k++){var[M,F]=Dd[k],B=M.exec(ke),Z=B&&(Tt(F)?F(B,ke):F);if(Z)return Z}return["",""]})(je);return pe(Rl({$os:Se,$os_version:Me,$browser:Vh(je,navigator.vendor),$device:Nd(je),$device_type:(O=je,A={userAgentDataPlatform:(R=navigator)==null||(R=R.userAgentData)==null?void 0:R.platform,maxTouchPoints:(D=navigator)==null?void 0:D.maxTouchPoints,screenWidth:_==null||(b=_.screen)==null?void 0:b.width,screenHeight:_==null||(x=_.screen)==null?void 0:x.height,devicePixelRatio:_?.devicePixelRatio},q=Nd(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?We: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)?We:Mi:"Desktop"),$timezone:hg(),$timezone_offset:lE()}),{$current_url:xs(Re?.href,me,Ds),$host:Re?.host,$pathname:Re?.pathname,$raw_user_agent:je.length>1e3?je.substring(0,997)+"...":je,$browser_version:Db(je,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:$e.LIB_NAME,$lib_version:$e.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))}je&&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),Di(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(tt(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(nt)||Ai)===Ai;e!==r&&o?(this.persistence.set_property(nt,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(nt,Ai),(u=this.sessionManager)==null||u.resetSessionId(),this.$i=null,this.config.cookieless_mode===Rt)this.register_once({distinct_id:Cr,$device_id:null},"");else{var h=this.config.get_device_id(Vt());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);gt(p)&&(this.config.debug=p),gt(this.config.debug)&&(this.config.debug?($e.DEBUG=!0,he.R()&&he.N("ph_debug",!0),T.info("set_config",{config:e,oldConfig:i,newConfig:S({},this.config)})):($e.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){$e.LIB_NAME=e,$e.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(nt))===Ii||((i=this.sessionPersistence)==null?void 0:i.get_property(nt))===Ii}nn(){var e,i;return!(this.config.person_profiles==="never"||this.config.person_profiles===Ha&&!this._isIdentified()&&Di(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!==si)}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!==Rt){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==si&&((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!==Rt?(this.config.cookieless_mode===si&&this.consent.isOptedIn()&&this.reset(!0),this.consent.optInOut(!1),this.cn(),this.config.cookieless_mode===si&&(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===Rt||(this.config.cookieless_mode===si?this.consent.isRejected()||this.consent.isOptedIn():!this.has_opted_out_capturing())}clear_opt_in_out_capturing(){this.consent.reset(),this.cn()}_is_bot(){return Ke?mg(Ke,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),be(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&&!Di(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=gt(e)&&!e,s=he.R()&&he.A("ph_debug")==="true";return!i&&(!!s||e)}};ni.__defaultExtensionClasses={},ni.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]])})(ni,["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||ot(t,"html")||!ai(t),nh=(t,e)=>{if(!_||gl(t))return{parentIsUsefulElement:!1,targetElementList:[]};for(var i=!1,s=[t],r=t;r.parentNode&&!ot(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+")$"),DE=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]"),Mt=ue("[Web Vitals]"),uh=9e5,ch="disabled",dh="lazy_loading",vs="awaiting_config",Fr="missing_config";ue("[SessionRecording]"),ue("[SessionRecording]");pl="[SessionRecording]",Ut=ue(pl),ME=ue("[Heatmaps]");gh=ue("[Product Tours]"),UE=["$set_once","$set"],Bt=ue("[SiteApps]"),fh="Error while initializing PostHog app with config id ";vl=class{constructor(e){this.vn=new Ns,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]"),Ne=ue("[FeatureFlags]"),ei=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},At=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 Ke&&this._instance?mg(Ke,this.qt.custom_blocked_useragents):void 0}},Qe=ue("[Conversations]"),ti="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,Ne.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||(Ne.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||Ne.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(Na),e=this.os(It),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||(Ne.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:i,finalDetails:s}),this.Kn=!0),s}getFlagVariants(){var t=this.os(Ni),e=this.os(It);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||(Ne.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||(Ne.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(ii),timezone:hg()};Ot(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:dt.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?Ne.warn("You have hit your feature flags quota limit, and will not be able to load feature flags until the quota is reset. Please visit https://posthog.com/docs/billing/limits-alerts to learn more."):(r.disable_flags||this.receivedFeatureFlags((f=o.json)!==null&&f!==void 0?f:{},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 Ne.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,D,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||(D=C.reason)==null?void 0:D.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 Ne.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:dt.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}Ne.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]})))):Ne.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)){Ne.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,[Ni]:w})}else{var D=p,b=v,x=g;if(h!=null&&h.partialResponse)D=S({},l,D),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)})));D=S({},l,Object.fromEntries(Object.entries(D).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 D=S({},l,D),b=S({},u,b),x=S({},c,x);a&&a.register(S({[Ur]:Object.keys(yh(D)),[Ni]:D||{},[La]:b||{},[Na]: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),Ne.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){if(!this._instance.__loaded||!this.ni)return Ne.uninitializedWarning("posthog.featureFlags.overrideFeatureFlags");if(t===!1)return this.ni.unregister(It),this.ni.unregister(Oi),this.ps(),ei.info("All overrides cleared");if(Y(t)){var e=mh(t);return this.ni.register({[It]:e}),this.ps(),ei.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(It),ei.info("Flag overrides cleared");else if(s.flags){if(Y(s.flags)){var r=mh(s.flags);this.ni.register({[It]:r})}else this.ni.register({[It]:s.flags});ei.info("Flag overrides set",{flags:s.flags})}}return"payloads"in s&&(s.payloads===!1?(this.ni.unregister(Oi),ei.info("Payload overrides cleared")):s.payloads&&(this.ni.register({[Oi]:s.payloads}),ei.info("Payload overrides set",{payloads:s.payloads}))),void this.ps()}if(t&&typeof t=="object")return this.ni.register({[It]:t}),this.ps(),ei.info("Flag overrides set",{flags:t});Ne.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)),[Ni]: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(ii)||{};Object.keys(i).length!==0&&Object.keys(i).forEach((s=>{i[s]=S({},i[s],t[s]),delete t[s]})),this._instance.register({[ii]:S({},i,t)}),e&&this._instance.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){var e=this.os(ii)||{};this._instance.register({[ii]:S({},e,{[t]:{}})})}else this._instance.unregister(ii)}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 Ut.error("started without valid sessionManager"),new Error(pl+" started without valid sessionManager. This is a bug.");if(this.qt.cookieless_mode===Rt)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),Ut.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 Ut.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=tt(t)?t:parseFloat(t);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(Ut.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,Ut.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):Ut.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 Ut.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,Ut.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(be(I,"submit",t,{capture:!0}),be(I,"change",t,{capture:!0}),be(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)}};be(I,"copy",e,{capture:!0}),be(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(Ot(this.Rs)&&!gt(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(gt(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((D=>D.toLowerCase()))}return w.some((D=>{var{safeText:b,ariaLabel:x}=D;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 D=g.dom_event_allowlist;if(D&&!D.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(me){if(U.some((Se=>me.tagName.toLowerCase()===Se)))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 Tt(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")};be(_,"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),be(_,en,this.Vs),this.Ws=t=>this.Mt(t||_?.event),be(I,"click",this.Ws,{capture:!0}),this.Zs=t=>this.Gs(t||_?.event),be(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),be(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&&ai(u)&&!ot(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,Ds);this.M=this.M||{},this.M[r]||(this.M[r]=[]),this.M[r].push(t)}}Zr(){this.M&&!Di(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))Mt.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)?Mt.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()):Mt.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):Mt.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[Da])||["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)&&tt(this.oo.__web_vitals_max_value)?this.oo.__web_vitals_max_value:uh;return t>0&&6e4>=t?uh:t}get isEnabled(){var t=Re?.protocol;if(t!=="http:"&&t!=="https:")return Mt.info("Web Vitals are disabled on non-http/https protocols"),!1;var e=ve(this.oo)?this.oo.web_vitals:gt(this.oo)?this.oo:void 0;return gt(e)?e:this.js}startIfEnabled(){this.isEnabled&&!this.Ps&&(Mt.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({[Da]: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?Mt.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,Ds)}Mt.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 At.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&&At.warn("Ignoring reserved exception step fields",{droppedKeys:r}),this.bo.add(S({[Hr]:t,[zr]:new Date().toISOString()},s))}catch(n){At.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 At.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 At.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 At.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 At.error("Failed to capture exception event. Dropping this exception.",r),void this.bo.clear()}}catch(r){return void At.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 At.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&&(Bt.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,Bt.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){Bt.error(fh+t.id,o),r(!1)}if(s&&e.loaded)try{i()}catch(o){Bt.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){Bt.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 Bt.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 Bt.error(fh+l,c)}))};for(var{id:o,url:a}of t.siteApps)n(o)}else Bt.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)&&Tt(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)})),be(_,"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)||(gt(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 Qe.error("Conversations enabled but missing token in remote config.")}}ta(t){if(this.ea)try{this._conversationsManager=t(this.ea,this._instance),Qe.info("Conversations loaded successfully")}catch(e){this.ra("Error completing conversations initialization",e)}else Qe.error("Cannot complete initialization: remote config is null")}ra(t,e){Qe.error(t,e),this._conversationsManager=null,this.Xo=!1}show(){this._conversationsManager?this._conversationsManager.show():Qe.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Yo===!0&&!Ot(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 Ze((function*(){return s._conversationsManager?s._conversationsManager.sendMessage(t,e,i):(Qe.warn(ti),null)}))()}getMessages(t,e){var i=this;return Ze((function*(){return i._conversationsManager?i._conversationsManager.getMessages(t,e):(Qe.warn(ti),null)}))()}markAsRead(t){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(Qe.warn(ti),null)}))()}getTickets(t){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(Qe.warn(ti),null)}))()}requestRestoreLink(t){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(Qe.warn(ti),null)}))()}restoreFromToken(t){var e=this;return Ze((function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(Qe.warn(ti),null)}))()}restoreFromUrlToken(){var t=this;return Ze((function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(Qe.warn(ti),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,$e.LIB_NAME,$e.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);ni.__defaultExtensionClasses=S({},ZE);_e=(Eh=Rs[xi]=new ni,(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():be(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:()=>Dl});var xe,Dl,Dg=Ue(()=>{"use strict";Cg();Zi();ts();xe=class xe{constructor(e,i=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=Lt("[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}if(xe._hasLoaded||_e.__loaded){this.log("init | PostHog already initialized, skipping re-init"),this.has_initialized=!0;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:{dom_event_allowlist:["click"]},rate_limiting:{events_per_second:10,events_burst_limit:100},...s,person_profiles:"identified_only",capture_pageview:"history_change",capture_pageleave:!0,session_recording:{...s.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"&&!Sc.some(u=>a.endsWith(`.${u}`)||a===u))return this.log("init | before_send blocked event from disallowed host",{currentHost:a}),null;if(s.before_send){let l=Array.isArray(s.before_send)?s.before_send:[s.before_send],u=o;for(let c of l)u=u?c(u):null;return u}return o}};_e.init(e,n),xe._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,i,s)=>{xe.isAnonymousId(e)||(this.log(`${s} | stale identified user, resetting`,{previous:e,next:i}),_e.reset())};this.identifyEvent=(e,i={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{if(!e||!e.trim()||xe.ILLEGAL_IDS.has(e.toLowerCase())){this.log("identifyEvent | skipped \u2014 invalid user_id",{user_id:e});return}let s=_e.get_distinct_id();if(s===e){this.log("identifyEvent | skipped \u2014 user already identified",{user_id:e});return}this.resetIfStaleId(s,e,"identifyEvent"),this.log("identifyEvent | identifying user",{user_id:e,traits:i}),_e.identify(e,{...i,client_id:e}),this.has_identified=!0}catch(s){console.error("Posthog: Failed to identify user",s)}};this.reset=()=>{if(this.has_initialized)try{this.log("reset | resetting PostHog session"),_e.reset(),this.has_identified=!1}catch(e){console.error("Posthog: Failed to reset",e)}};this.backfillPersonProperties=({user_id:e,email:i,language:s,country_of_residence:r})=>{if(!(!this.has_initialized||!e)){if(!e.trim()||xe.ILLEGAL_IDS.has(e.toLowerCase())){this.log("backfillPersonProperties | skipped \u2014 invalid user_id",{user_id:e});return}try{let n=_e.get_distinct_id(),o=n===e;o||this.resetIfStaleId(n,e,"backfillPersonProperties");let a={};if(_e.get_property("client_id")||(a.client_id=e),i&&_e.get_property("is_internal")==null&&(a.is_internal=ur(i)),s&&!_e.get_property("language")&&(a.language=s),r&&!_e.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}),_e.setPersonProperties(a)}else a.client_id||(a.client_id=e),this.log("backfillPersonProperties | user not identified, identifying now",{user_id:e,updates:a}),_e.identify(e,a),this.has_identified=!0}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}),_e.capture(e,i)}catch(s){console.error("Posthog: Failed to capture event",s)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let i=_e.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=_e.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=_e.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=_e.featureFlags?.getFlagVariants()??{},i=Object.fromEntries(Object.entries(e).filter(s=>s[1]!=null));return this.log("getAllFlags",{result:i}),i}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=_e.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"),_e.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=i,this.init()}};xe._hasLoaded=!1,xe.ILLEGAL_IDS=new Set(["restored","null","undefined","anonymous","guest","distinctid","distinct_id","id","not_authenticated","email","true","false","0","none","nan"]),xe.getPosthogInstance=(e,i=!1)=>(xe._instance?e.apiKey&&e.apiKey!==xe._instance.options.apiKey&&console.warn("Posthog: getPosthogInstance called with a different API key \u2014 returning existing instance"):xe._instance=new xe(e,i),xe._instance),xe.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;Dl=xe});var t0={};Sn(t0,{Analytics:()=>Ng});yo();Zi();ts();var _y=4320*60*60,Yt=class Yt{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=Lt("[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)}};Yt.getRudderStackInstance=(e,i,s=!1)=>(Yt._instance||(Yt._instance=new Yt(e,i,s)),Yt._instance);var cr=Yt;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[]},Dc=()=>{try{localStorage.removeItem(dr)}catch(t){console.warn("Analytics: Failed to clear cached events",t)}},Nc=()=>{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=Lt("",()=>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=Wt(F.properties);r?.track(F.name,B)}),Dc());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",D(),F.properties)}),Nc())}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,ye;ce!==void 0&&(e=ce),i("initialise | starting analytics initialization",{rudderstack:!!F,growthbook:!!k,posthog:!!Z});try{let Oe=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,pt=r?.getAnonymousId();o={...o,country:Oe,...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},...pt&&{anonymous_id:pt}}}B??(B={}),B.attributes??(B.attributes={});let we=r?.getAnonymousId();if((se=B.attributes).id??(se.id=we),(ye=B.attributes).country??(ye.country=Oe),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 pt=setInterval(()=>{Object.keys(a).length>0?clearInterval(pt):a=m("tracking-buttons-config",{})},1e3)}if(Z){i("initialise | initializing PostHog");let{Posthog:j}=await Promise.resolve().then(()=>(Dg(),xg));n=j.getPosthogInstance(Z,e),i("initialise | PostHog initialized")}i("initialise | analytics initialization complete")}catch(Oe){console.warn("Analytics: Failed to initialize",Oe)}},p=k=>{i("setAttributes | received attributes",k);let{user_id:M,...F}=k,B=M??D();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),D=()=>{let k=r?.getUserId()||"";return k&&!es(k)?k:""},ke={initialise:g,setAttributes:p,identifyEvent:(k,M)=>{let F=k||D();if(!F){i("identifyEvent | skipped \u2014 no user_id available");return}i("identifyEvent | called",{user_id:F,traits:M});let B=ye=>{if(!ye)return ye;let{email:Oe,...we}=ye;return{...we,...Oe&&{is_internal:ur(Oe)}}},Z=M?.rudderstack!==void 0||M?.posthog!==void 0,ce,se;if(Z){let{rudderstack:ye,posthog:Oe,...we}=M;ce=B({...we,...ye}),se=B({...we,...Oe})}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(ye=>ye.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:D,getAnonymousId:()=>r?.getAnonymousId()||"",trackEvent:(k,M)=>{let F=D();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(ye=>{let Oe=Wt(ye.payload);r?.track(ye.event,Oe)}),l=[]);let se=Wt(B);i("trackEvent | sending event to RudderStack",{event:k,payload:se}),r?.track(k,se)}if(n?.has_initialized){let se=Wt(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=D();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=ke),ke}var Ng=e0();return Hg(t0);})();
|
|
2
|
+
"use strict";var DerivAnalytics=(()=>{var Sn=Object.defineProperty;var Gv=Object.getOwnPropertyDescriptor;var Hv=Object.getOwnPropertyNames;var zv=Object.prototype.hasOwnProperty;var qv=(t,e,s)=>e in t?Sn(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s;var Ze=(t,e,s)=>()=>{if(s)throw s[0];try{return t&&(e=t(t=0)),e}catch(i){throw s=[i],i}};var go=(t,e)=>{for(var s in e)Sn(t,s,{get:e[s],enumerable:!0})},Wv=(t,e,s,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of Hv(e))!zv.call(t,n)&&n!==s&&Sn(t,n,{get:()=>e[n],enumerable:!(i=Gv(e,n))||i.enumerable});return t};var Kv=t=>Wv(Sn({},"__esModule",{value:!0}),t);var Se=(t,e,s)=>qv(t,typeof e!="symbol"?e+"":e,s);function Ie(t){return t!=null&&typeof t=="object"&&t["@@functional/placeholder"]===!0}function xt(t){return function e(s){return arguments.length===0||Ie(s)?e:t.apply(this,arguments)}}function Jt(t){return function e(s,i){switch(arguments.length){case 0:return e;case 1:return Ie(s)?e:xt(function(n){return t(s,n)});default:return Ie(s)&&Ie(i)?e:Ie(s)?xt(function(n){return t(n,i)}):Ie(i)?xt(function(n){return t(s,n)}):t(s,i)}}}function Xo(t){return function e(s,i,n){switch(arguments.length){case 0:return e;case 1:return Ie(s)?e:Jt(function(r,o){return t(s,r,o)});case 2:return Ie(s)&&Ie(i)?e:Ie(s)?Jt(function(r,o){return t(r,i,o)}):Ie(i)?Jt(function(r,o){return t(s,r,o)}):xt(function(r){return t(s,i,r)});default:return Ie(s)&&Ie(i)&&Ie(n)?e:Ie(s)&&Ie(i)?Jt(function(r,o){return t(r,o,n)}):Ie(s)&&Ie(n)?Jt(function(r,o){return t(r,i,o)}):Ie(i)&&Ie(n)?Jt(function(r,o){return t(s,r,o)}):Ie(s)?xt(function(r){return t(r,i,n)}):Ie(i)?xt(function(r){return t(s,r,n)}):Ie(n)?xt(function(r){return t(s,i,r)}):t(s,i,n)}}}function kn(t,e){return Object.prototype.hasOwnProperty.call(e,t)}function Rc(t){return Object.prototype.toString.call(t)==="[object Object]"}function Jv(t,e){var s=t<0?e.length+t:t;return e[s]}function Xv(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 hu(t,e,s){if(s||(s=new e_),Zv(t))return t;var i=function(r){var o=s.get(t);if(o)return o;s.set(t,r);for(var a in t)Object.prototype.hasOwnProperty.call(t,a)&&(r[a]=hu(t[a],!0,s));return r};switch(Yv(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 Xv(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 Zv(t){var e=typeof t;return t==null||e!="object"&&e!="function"}function t_(t,e){for(var s=e,i=0;i<t.length;i+=1){if(s==null)return;var n=t[i];Qv(n)?s=Jv(n,s):s=s[n]}return s}function b_(t){return crypto.getRandomValues(new Uint8Array(t))}function E_(){(!_o||Xt+16>Oc)&&(_o=b_(Oc),Xt=0);for(var t=0,e,s="";t<16;t++)e=_o[Xt+t],t==6?s+=Cn[e&15|64]:t==8?s+=Cn[e&63|128]:s+=Cn[e],t&1&&t>1&&t<11&&(s+="-");return Xt+=16,s}function w_(){var t=0,e,s="";if(!Tn||_s+16>256){for(Tn=Array(t=256);t--;)Tn[t]=256*Math.random()|0;t=_s=0}for(;t<16;t++)e=Tn[_s+t],t==6?s+=On[e&15|64]:t==8?s+=On[e&63|128]:s+=On[e],t&1&&t>1&&t<11&&(s+="-");return _s++,s}function Q_(t,e,s=Y_){let i;return(...n)=>{globalThis.clearTimeout(i),i=globalThis.setTimeout(()=>{t.apply(e,n)},s)}}function Qn(){if(Dt>1)Dt--;else{var t,e=!1;for((function(){var n=Gn;for(Gn=void 0;n!==void 0;){var r=n.S;if(r.v===n.v)for(var o=r.t;o!==void 0;o=o.x)o.i===n.i&&(o.i=r.i);n=n.o}})();Ii!==void 0;){var s=Ii;for(Ii=void 0,jn++;s!==void 0;){var i=s.u;if(s.u=void 0,s.f&=-3,!(8&s.f)&&Tu(s))try{s.c()}catch(n){e||(t=n,e=!0)}s=i}}if(jn=0,Dt--,e)throw t}}function Fe(t){if(Dt>0)return t();Io=++lm,Dt++;try{return t()}finally{Qn()}}function Jn(t){var e=ke,s=Ti;ke=void 0,Ti=void 0;try{return t()}finally{ke=e,Ti=s}}function Au(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 C(t,e){return new We(t,e)}function Tu(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 Iu(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 Ru(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 qs(t,e){We.call(this,void 0,e),this.x=t,this.s=void 0,this.g=Hn-1,this.f=4}function Cu(t){var e=t.m;if(t.m=void 0,typeof e=="function"){Dt++;var s=ke;ke=void 0;try{e()}catch(i){throw t.f&=-2,t.f|=8,ia(t),i}finally{ke=s,Qn()}}}function ia(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,Cu(t)}function cm(t){if(ke!==this)throw new Error("Out-of-order effect");Ru(this),ke=t,this.f&=-2,8&this.f&&ia(this),Qn()}function Ws(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name,Ti&&Ti.push(this)}function Mt(t,e){var s=new Ws(t,e);try{s.c()}catch(n){throw s.d(),n}var i=s.d.bind(s);return i[Symbol.dispose]=i,i}function Lu(t){if(!t?.includes(":"))return[t||void 0,void 0,void 0];let e=t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1):t,s=qy.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 Wy(t){if(!Fu.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,[n,r,o]=Lu(s?s[1]:e);return{functionName:s&&i||void 0,fileName:n==="eval"||n==="<anonymous>"?void 0:n,lineNumber:r,columnNumber:o}}function Ky(t){if(zy.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,n,r]=Lu(t.slice(e+1));return{functionName:s,fileName:i,lineNumber:n,columnNumber:r}}function Yy(t){if(!t.stack)throw new Error("Cannot parse given Error object");let e=t.stack.split(`
|
|
3
|
+
`);return e.some(s=>Fu.test(s))?e.map(Wy).filter(s=>s!==null):e.map(Ky).filter(s=>s!==null)}function Wc(t,e,s,i){return{errorClass:qc(t),message:`${s}${qc(e)}`,type:"browserjs",stacktrace:i.reduce((n,r)=>{let o=Jy(r);try{return JSON.stringify(o)==="{}"?n:n.concat(o)}catch{return n}},[])}}function qu(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]=qu(s[i],e[i]));return s}async function F0(t){let e=N0[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(r=>{import(r).then(o=>{if(!e.inited){let a=M0();o.init(a),e.lib=o,e.lib.init(a),e.inited=!0}s(e.lib)}).catch(i)})})}function et(t,e){if(!t?.default&&e){let s=Object.create(null);return s.default=t,s.__esModule=!0,s}return t}function tt(t,e){return F0(t).then(s=>s.get(e).then(i=>i()))}function hb(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}function gb(){return tu||(tu=1,(function(t,e){(function(s,i){t.exports=i()})(fb,function(){function s(g){return g=JSON.stringify(g),!!/^\{[\s\S]*\}$/.test(g)}function i(g){return g===void 0||typeof g=="function"?g+"":JSON.stringify(g)}function n(g){if(typeof g=="string")try{return JSON.parse(g)}catch{return g}}function r(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",m="yes";try{g||(g=window.localStorage),g.setItem(p,m),g.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={}},g=v}finally{g.getItem(p)===m&&g.removeItem(p)}return g}var l=a();function c(){if(!(this instanceof c))return new c}c.prototype={set:function(p,m){if(p&&!s(p))l.setItem(p,i(m));else if(s(p))for(var v in p)this.set(v,p[v]);return this},get:function(p){if(p===void 0){var m={};return this.forEach(function(I,k){return m[I]=k}),m}if(p.charAt(0)==="?")return this.has(p.substr(1));var v=arguments;if(v.length>1){for(var b={},y=0,w=v.length;y<w;y++){var A=n(l.getItem(v[y]));this.has(v[y])&&(b[v[y]]=A)}return b}return n(l.getItem(p))},clear:function(){return l.clear(),this},remove:function(p){var m=this.get(p);return l.removeItem(p),m},has:function(p){return{}.hasOwnProperty.call(this.get(),p)},keys:function(){var p=[];return this.forEach(function(m){p.push(m)}),p},forEach:function(p){for(var m=0,v=l.length;m<v;m++){var b=l.key(m);p(b,this.get(b))}return this},search:function(p){for(var m=this.keys(),v={},b=0,y=m.length;b<y;b++)m[b].indexOf(p)>-1&&(v[m[b]]=this.get(m[b]));return v},len:function(){return l.length}};var u=null;function h(g,p){var m=arguments,v=null;if(u||(u=c()),m.length===0)return u.get();if(m.length===1){if(typeof g=="string")return u.get(g);if(s(g))return u.set(g)}if(m.length===2&&typeof g=="string"){if(!p)return u.remove(g);if(p&&typeof p=="string")return u.set(g,p);p&&r(p)&&(v=null,v=p(g,u.get(g)),h.set(g,v))}if(m.length===2&&o(g)&&r(p))for(var b=0,y=g.length;b<y;b++)v=p(g[b],u.get(g[b])),h.set(g[b],v);return h}for(var d in c.prototype)h[d]=c.prototype[d];return h})})(Nn)),Nn.exports}var Yv,Qv,e_,te,s_,i_,n_,r_,fu,F,ge,st,Ve,at,o_,ce,js,a_,Zo,Cc,So,l_,c_,u_,fe,d_,$e,Nt,wi,Ri,Ot,wt,ea,h_,gu,Un,f_,g_,Bn,ta,pu,vu,_u,po,Wn,ko,qe,Ao,Ls,fs,Si,Us,p_,vo,v_,__,m_,y_,An,Oc,Cn,Xt,_o,_s,On,Tn,S_,Kn,k_,A_,T_,mu,I_,j,R_,Pc,C_,O_,P_,$c,$_,x_,D_,xc,N_,yu,M_,rt,F_,bu,oe,Eu,Yn,sa,be,Dc,Ci,L_,wu,U_,Nc,B_,V_,Ai,j_,G_,H_,Mc,z_,Fc,q_,W_,Lc,To,Uc,K_,Y_,Su,Oi,ku,Bc,J_,X_,Z_,em,tm,sm,im,nm,rm,om,Vn,am,Ti,ke,Ii,Dt,jn,lm,Io,Gn,Hn,Ro,In,Vc,Ou,um,dm,hm,Co,Ft,Pt,Pi,fm,jc,gm,pm,vm,_m,mm,ym,bm,Em,Gc,wm,Sm,km,Am,Tm,Im,Rm,Hc,Cm,Om,Pu,Pm,$m,xm,Dm,Nm,Mm,Fm,Lm,zc,Um,Bm,Vm,jm,Gm,Hm,zm,qm,Wm,Km,Pn,Ym,Qm,Jm,Xm,Zm,ey,ty,sy,iy,ny,ry,oy,ay,ly,cy,uy,dy,hy,fy,gy,py,vy,_y,$u,Xn,xu,my,$i,xi,na,Du,Nu,Mu,gs,yy,Oo,$n,by,Ey,wy,Sy,ky,Ay,ue,xn,Ty,Iy,Ry,Cy,Oy,Py,$y,xy,Dy,Ny,My,Fy,Ly,Uy,By,Vy,jy,Gy,Hy,f,Fu,zy,qy,Uu,Qy,Jy,qc,Bu,Xy,Kc,Dn,Zy,e0,t0,s0,i0,n0,r0,o0,Yc,Qc,Po,Vu,a0,l0,c0,u0,d0,h0,f0,g0,p0,v0,_0,m0,y0,b0,E0,w0,S0,Jc,Zn,Rn,k0,A0,ju,Gu,T0,I0,R0,C0,$o,Hu,xo,O0,P0,$0,Xc,x0,zu,D0,N0,M0,L0,U0,Wu,B0,V0,mo,j0,Do,ze,ot,ht,St,Zt,G0,H0,z0,q0,W0,K0,Y0,Q0,J0,X0,Z0,eb,Bs,tb,Ku,Yu,sb,Qu,Ju,ps,Zc,eu,ib,nb,No,rb,$t,ob,ab,Xu,lb,cb,ub,db,Mo,zn,Nn,fb,tu,pb,hs,Zu,Vs,Fo,ra,Lo,oa,Uo,aa,pt,vb,_b,mb,yb,bb,Bo,Eb,Vo,wb,su,ed,Sb,kb,Ab,Tb,Mn,Ib,Rb,Gs,Cb,Ob,td,Pb,$b,xb,Hs,yo,bo,Db,Nb,Mb,iu,Fb,sd,Lb,Ub,Bb,Vb,jb,Gb,Hb,zb,qb,Wb,Kb,id,Yb,Qb,jo,Jb,nd,Xb,Zb,eE,rd,tE,sE,Go,iE,nE,rE,oE,nu,aE,lE,ru,cE,ou,Ho,uE,dE,hE,Eo,Fn,fE,gE,pE,la,od,ad,zo,ld,vE,qn,au,cd,lu,_E,mE,yE,bE,EE,ki,qo,wE,SE,kE,AE,wo,TE,IE,RE,CE,OE,Ei,Wo,Ko,Yo,PE,$E,xE,cu,uu,DE,NE,ME,FE,Ln,Qo,du,LE,UE,Jo,vs,zs,ca=Ze(()=>{"use strict";Yv=xt(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});Qv=Number.isInteger||function(e){return e<<0===e};e_=(function(){function t(){this.map={},this.length=0}return t.prototype.set=function(e,s){var i=this.hash(e),n=this.map[i];n||(this.map[i]=n=[]),n.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 n=o[i];if(n[0]===e)return n[1]}return}var r=this.hash(e),o=this.map[r];if(o)for(var i=0;i<o.length;i+=1){var n=o[i];if(n[0]===e)return n[1]}},t})(),te=xt(function(e){return e!=null&&typeof e.clone=="function"?e.clone():hu(e)});s_=Xo(function(e,s,i){var n={},r;s=s||{},i=i||{};for(r in s)kn(r,s)&&(n[r]=kn(r,i)?e(r,s[r],i[r]):s[r]);for(r in i)kn(r,i)&&!kn(r,n)&&(n[r]=i[r]);return n}),i_=Xo(function t(e,s,i){return s_(function(n,r,o){return Rc(r)&&Rc(o)?t(e,r,o):e(n,r,o)},s,i)}),n_=Xo(function(e,s,i){return i_(function(n,r,o){return e(r,o)},s,i)}),r_=Jt(t_),fu=Jt(function(e,s){var i={};for(var n in s)e(s[n],n,s)&&(i[n]=s[n]);return i}),F=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),ge=t=>typeof t=="string",st=t=>t===null,Ve=t=>typeof t>"u",at=t=>st(t)||Ve(t),o_=t=>typeof t=="bigint",ce=t=>!Ve(t),js=t=>!at(t),a_=t=>js(t)&&t!=="",Zo=t=>{switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return t instanceof Error}},Cc=t=>typeof t=="boolean",So=(t,e)=>{let s=e.split(".");return r_(s,t)},l_=(t,e)=>!!So(t,e),c_=t=>typeof t=="object",u_=t=>!st(t)&&c_(t)&&!Array.isArray(t),fe=t=>!st(t)&&Object.prototype.toString.call(t)==="[object Object]",d_=(t,e)=>{if(!Array.isArray(t)||!Array.isArray(e))return te(e);let s=te(t);return e.forEach((i,n)=>{s[n]=Array.isArray(i)||u_(i)?$e(s[n],i):i}),s},$e=(t,e)=>n_(d_,t,e),Nt=t=>fe(t)&&Object.keys(t).length>0,wi=t=>{let e=fu(ce,t);return Object.keys(e).forEach(s=>{let i=e[s];fe(i)&&(e[s]=wi(i))}),e},Ri=t=>{let e=fu(js,t);return Object.keys(e).forEach(s=>{let i=e[s];fe(i)&&(e[s]=Ri(i))}),e},Ot=t=>{if(Nt(t))return Ri(t)},wt=(t,e)=>typeof t=="boolean"?t:e,ea=t=>(Object.getOwnPropertyNames(t).forEach(function(e){t[e]&&typeof t[e]=="object"&&ea(t[e])}),Object.freeze(t)),h_=t=>t.replace(/^\s+|\s+$/gm,""),gu=t=>t.replace(/^\.+/,""),Un=t=>{let e=t;if(!ge(t)&&!at(t))try{e=JSON.stringify(t)}catch{e=null}return e},f_=t=>{let e=Array.from(t,s=>String.fromCodePoint(s)).join("");return globalThis.btoa(e)},g_=t=>f_(new TextEncoder().encode(t)),Bn=(t,e,s,i,n)=>{let r={category:t,name:e,properties:s,options:i,callback:void 0};F(n)&&(r.callback=n),F(i)&&(r.category=t,r.name=e,r.properties=s,r.options=void 0,r.callback=i),F(s)&&(r.category=t,r.name=e,r.properties=void 0,r.options=void 0,r.callback=s),F(e)&&(r.category=t,r.name=void 0,r.properties=void 0,r.options=void 0,r.callback=e),F(t)&&(r.category=void 0,r.name=void 0,r.properties=void 0,r.options=void 0,r.callback=t),fe(t)?(r.name=void 0,r.category=void 0,r.properties=t,F(e)?r.options=void 0:r.options=e):fe(e)&&(r.name=void 0,r.properties=e,F(s)?r.options=void 0:r.options=s),ge(t)&&!ge(e)&&(r.category=void 0,r.name=t),ce(r.category)||(r.category=void 0),ce(r.name)||(r.name=void 0),r.properties=r.properties?te(r.properties):{},ce(r.options)?r.options=te(r.options):r.options=void 0;let o=ge(r.name)?r.name:r.properties.name,a=ge(r.category)?r.category:r.properties.category;return r.properties=$e(fe(r.properties)?r.properties:{},{...o&&{name:o},...a&&{category:a}}),r},ta=(t,e,s,i)=>{let n={name:t,properties:e,options:s,callback:void 0};return F(i)&&(n.callback=i),F(s)&&(n.properties=e,n.options=void 0,n.callback=s),F(e)&&(n.properties=void 0,n.options=void 0,n.callback=e),n.properties=js(n.properties)?te(n.properties):{},ce(n.options)?n.options=te(n.options):n.options=void 0,n},pu=(t,e,s,i)=>{let n={userId:t,traits:e,options:s,callback:void 0};return F(i)&&(n.callback=i),F(s)&&(n.userId=t,n.traits=e,n.options=void 0,n.callback=s),F(e)&&(n.userId=t,n.traits=void 0,n.options=void 0,n.callback=e),(fe(t)||st(t))&&(n.userId=null,n.traits=t,F(e)?n.options=void 0:n.options=e),n.userId=Un(n.userId),fe(n.traits)?n.traits=te(n.traits):n.traits=void 0,ce(n.options)?n.options=te(n.options):n.options=void 0,n},vu=(t,e,s,i)=>{let n={to:t,from:e,options:s,callback:void 0};return F(i)&&(n.callback=i),F(s)&&(n.to=t,n.from=e,n.options=void 0,n.callback=s),F(e)?(n.to=t,n.from=void 0,n.options=void 0,n.callback=e):(fe(e)||st(e))&&(n.to=t,n.from=void 0,n.options=e),ce(n.to)&&(n.to=Un(n.to)),ce(n.from)?n.from=Un(n.from):n.from=void 0,ce(n.options)?n.options=te(n.options):n.options=void 0,n},_u=(t,e,s,i)=>{let n={groupId:t,traits:e,options:s,callback:void 0};return F(i)&&(n.callback=i),F(s)&&(n.groupId=t,n.traits=e,n.options=void 0,n.callback=s),F(e)&&(n.groupId=t,n.traits=void 0,n.options=void 0,n.callback=e),(fe(t)||st(t))&&(n.groupId=null,n.traits=t,F(e)?n.options=void 0:n.options=e),n.groupId=Un(n.groupId),fe(n.traits)?n.traits=te(n.traits):n.traits=void 0,ce(n.options)?n.options=te(n.options):n.options=void 0,n},po=(function(t){return t.UNLOADED="Page Unloaded",t})({}),Wn="API",ko="CapabilitiesManager",qe="ConfigManager",Ao="EventManager",Ls="PluginsManager",fs="UserSessionManager",Si="ErrorHandler",Us="PluginEngine",p_="StoreManager",vo=`Ready${Wn}`,v_=`Load${Wn}`,__=`Consent${Wn}`,m_="HttpClient",y_="RudderStackAnalytics",An="AnalyticsCore";Oc=4096,Cn=[],Xt=0;for(;Xt<256;Xt++)Cn[Xt]=(Xt+256).toString(16).substring(1);_s=256,On=[];for(;_s--;)On[_s]=(_s+256).toString(16).substring(1);S_=()=>!at(globalThis.crypto)&&F(globalThis.crypto.getRandomValues),Kn=()=>S_()?E_():w_(),k_=()=>!!window.chrome?.runtime?.id,A_=()=>ge(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),T_=(t,e=!1)=>{let s=!1,i=!1;function n(){s||(s=!0,t(i),setTimeout(()=>{s=!1},0))}(e||A_())&&globalThis.addEventListener("beforeunload",()=>{i=!1,n()}),globalThis.addEventListener("blur",()=>{i=!0,n()}),globalThis.addEventListener("focus",()=>{s=!1}),document.addEventListener("pagehide",()=>{i=document.visibilityState==="hidden",n()}),document.addEventListener("visibilitychange",()=>{i=!0,document.visibilityState==="hidden"?n():s=!1})},mu=t=>t.toISOString(),I_=()=>mu(new Date),j=":: ",R_=t=>`A script with the id "${t}" is already loaded. Skipping the loading of this script to prevent conflicts`,Pc=(t,e,s)=>`Unable to load (${ge(s)?s:s.type}) the script with the id "${t}" from URL "${e}"`,C_=(t,e,s)=>`A timeout of ${s} ms occurred while trying to load the script with id "${t}" from URL "${e}"`,O_=(t,e)=>`${t}${j}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,P_="Failed to convert the value to a JSON string.",$c=(t,e)=>`${t}${j}A bad data (like circular reference, BigInt) has been detected in the object and the property "${e}" has been dropped from the output.`,$_="Failed to encode the cookie data.",x_=(t,e)=>`${t}${j}The "${e}" storage type is `,D_="JSONStringify",xc="JSON",N_="[BigInt]",yu="[Circular Reference]",M_=(t,e,s)=>{let i=[];return function(n,r){if(!e?.includes(n)&&!(t&&at(r))){if(typeof r!="object"||st(r))return r;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(r)?(s?.warn(O_(D_,n)),yu):(i.push(r),r)}}},rt=(t,e,s,i)=>{try{return JSON.stringify(t,M_(e,s,i))}catch(n){return i?.warn(P_,n),null}},F_=t=>{let e=[];return function(i,n){if(o_(n))return t?.warn($c(xc,i)),N_;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(n)?(t?.warn($c(xc,i)),yu):(e.push(n),n)}},bu=(t,e)=>{let s=Array.isArray(t)?[]:{};for(let i in t)if(Object.hasOwnProperty.call(t,i)){let n=t[i],r=e.call(t,i,n);fe(r)||Array.isArray(r)?s[i]=bu(r,e):s[i]=r}return s},oe=(t,e)=>{let s=F_(e),i=s.call(t,"",t);return fe(t)||Array.isArray(t)?bu(t,s):i},Eu="[SDK DISPATCHED ERROR]",Yn=t=>{let{stack:e}=t;if(typeof e=="string"&&e)return e},sa=(t,e)=>{if(!Zo(t))return new Error(`${e}: ${rt(t)}`);try{let s=t.constructor,i=new s(`${e}: ${t.message}`),n=Yn(t);return n&&(i.stack=n),Object.getOwnPropertyNames(t).forEach(r=>{if(r!=="message"&&r!=="stack"&&r!=="name")try{i[r]=t[r]}catch{}}),i}catch{return new Error(`${e}: ${rt(t)}`)}},be=t=>{if(Zo(t)){let e=Yn(t);e&&(t.stack=`${e}
|
|
4
|
+
${Eu}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:t,bubbles:!0,cancelable:!0,composed:!0}))},Dc="RudderLabs JavaScript SDK",Ci="3.34.3",L_="com.rudderlabs.javascript",wu="npm",U_="modern",Nc="RudderJS-Initiated",B_="ad-block page request",V_="/ad-blocked",Ai="preloadedEventsBuffer",j_="Consent Management Interaction",G_="ajs_trait_",H_="ajs_prop_",Mc="ajs_aid",z_="ajs_uid",Fc="ajs_event",q_=10*1e3,W_=31536e3*1e3,Lc=720*60*1e3,To=1800*1e3,Uc=10*1e3,K_=10*1e3,Y_=250,Su=(t="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[t]||(globalThis.RudderStackGlobals[t]={})},Oi=(t,e,s="app")=>{Su(s),globalThis.RudderStackGlobals[s][t]=e},ku=(t,e="app")=>(Su(e),globalThis.RudderStackGlobals[e][t]);Bc=(t,e)=>{let s={};return t.forEach((i,n)=>{if(n.startsWith(e)){let r=n.substring(e.length);s[r]=t.get(n)}}),s},J_=(t=[])=>{let e={trait:G_,properties:H_},s=new URLSearchParams(globalThis.location.search);s.get(Fc)&&t.unshift(["track",s.get(Fc),Bc(s,e.properties)]);let i=s.get(z_),n=Bc(s,e.trait);if(i||Nt(n)){let r=[...i?[i]:[],n];t.unshift(["identify",...r])}s.get(Mc)&&t.unshift(["setAnonymousId",s.get(Mc)])},X_=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},Z_=t=>{let e="consent",s=t.filter(n=>n[0]===e),i=t.filter(n=>n[0]!==e);t.splice(0,t.length,...s,...i)},em=t=>{let e=ku(Ai)||[];J_(e),e.length>0&&(t.enqueuePreloadBufferEvents(e),Oi(Ai,[]))},tm=(t,e)=>{let s=t.shift(),i;if(F(e[s])){switch(s){case"page":i=Bn(...t);break;case"track":i=ta(...t);break;case"identify":i=pu(...t);break;case"alias":i=vu(...t);break;case"group":i=_u(...t);break;default:e[s](...t);break}i&&e[s](i)}},sm=10*1e3,im="RS_JS_SDK",nm=(t,e,s=!0,i=null,n=null,r={})=>{let o=document.createElement("script");return o.type="text/javascript",o.onload=i,o.onerror=n,o.src=t,o.id=e,o.async=s,Object.keys(r).forEach(a=>{o.setAttribute(a,r[a])}),o.setAttribute("data-loader",im),o},rm=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 n=document.getElementsByTagName("html")[0];n?.insertBefore(i,n.firstChild)},om=(t,e,s,i=!0,n)=>new Promise((r,o)=>{document.getElementById(e)&&o(new Error(R_(e)));try{let l;rm(nm(t,e,i,()=>{globalThis.clearTimeout(l),r(e)},h=>{globalThis.clearTimeout(l),o(new Error(Pc(e,t,h)))},n)),l=globalThis.setTimeout(()=>{o(new Error(C_(e,t,s)))},s)}catch(l){o(sa(l,Pc(e,t,"unknown")))}}),Vn=class{constructor(e,s=sm){this.logger=e,this.timeout=s}loadJSFile(e){let{url:s,id:i,timeout:n,async:r,callback:o,extraAttributes:a}=e,l=!F(o);om(s,i,n||this.timeout,r,a).then(c=>{l||o(c)}).catch(c=>{l||o(i,c)})}},am=Symbol.for("preact-signals");ke=void 0;Ii=void 0,Dt=0,jn=0,lm=0,Io=0,Gn=void 0,Hn=0;We.prototype.brand=am;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:Jn(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&&Jn(function(){var n;(n=e.Z)==null||n.call(e)}))}};We.prototype.subscribe=function(t){var e=this;return Mt(function(){var s=e.value;Jn(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 Jn(function(){return t.value})};Object.defineProperty(We.prototype,"value",{get:function(){var t=Au(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(jn>100)throw new Error("Cycle detected");(function(s){Dt!==0&&jn===0&&s.l!==Io&&(s.l=Io,Gn={S:s,v:s.v,i:s.i,o:Gn})})(this),this.v=t,this.i++,Hn++,Dt++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Qn()}}}});qs.prototype=new We;qs.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Hn))return!0;if(this.g=Hn,this.f|=1,this.i>0&&!Tu(this))return this.f&=-2,!0;var t=ke;try{Iu(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,Ru(this),this.f&=-2,!0};qs.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)};qs.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)}};qs.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(qs.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Au(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});Ws.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()}};Ws.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Cu(this),Iu(this),Dt++;var t=ke;return ke=this,cm.bind(this,t)};Ws.prototype.N=function(){2&this.f||(this.f|=2,this.u=Ii,Ii=this)};Ws.prototype.d=function(){this.f|=8,1&this.f||ia(this)};Ws.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=[]}},In={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},Vc="LOG",Ou="ERROR",um="RS SDK",dm="font-weight: bold; background: black; color: white;",hm="font-weight: normal;",Co=class{constructor(e=Vc,s="",i=console){this.minLogLevel=In[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<=In[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(s))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=In[e],Ve(this.minLogLevel)&&(this.minLogLevel=In[Vc])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let s=`%c ${um}`;this.scope&&(s=`${s} - ${this.scope}`);let i=ge(e[0])?e[0].trim():"";s=`${s} %c ${i}`;let n=[s,dm,hm];return ge(e[0])||n.push(e[0]),n.push(...e.slice(1)),n}return e}},Ft=new Co,Pt=(function(t){return t.HANDLEDEXCEPTION="handledException",t.UNHANDLEDEXCEPTION="unhandledException",t.UNHANDLEDREJECTION="unhandledPromiseRejection",t})({}),Pi=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],fm="cookieStorage",jc="Unable to process/parse source configuration response",gm="The source is disabled. Please enable the source in the dashboard to send events.",pm="Failed to prepare data for the request.",vm="Failed to invoke plugin because the extension point name is missing.",_m="Failed to invoke plugin because the extension point name is invalid.",mm=t=>`${t}${j}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,ym=(t,e,s)=>`${t}${j}The base URL "${s}" for ${e} is not valid.`,bm=(t,e,s)=>`${t}${j}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(s)}".`,Em=(t,e)=>`${t}${j}Ignoring a non-error: ${e}.`,Gc="Failed to log breadcrumb",wm=t=>`${t}${j}Failed to handle the error.`,Sm=t=>`${t}${j}Plugin name is missing.`,km=(t,e)=>`${t}${j}Plugin "${e}" already exists.`,Am=(t,e)=>`${t}${j}Plugin "${e}" not found.`,Tm=(t,e)=>`${t}${j}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.`,Im=(t,e,s)=>`${t}${j}Plugin "${e}" could not be loaded because some of its dependencies "${s}" do not exist.`,Rm=(t,e,s)=>`${t}${j}Failed to invoke the "${e}" extension point of plugin "${s}".`,Hc="Failed to fetch the source config",Cm=(t,e)=>`${t}${j}The write key "${e}" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.`,Om=(t,e)=>`${t}${j}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.`,Pu=t=>`${t}${j}The provided callback parameter is not a function.`,Pm=(t,e,s,i,n)=>`${t} with status ${e} (${s}) for URL: ${i}. Response: ${n.trim()}`,$m=(t,e,s)=>`${t} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${s}`,xm=(t,e)=>`${t} for URL: ${e}`,Dm=t=>`Failed to save the value for "${t}" to storage`,Nm=t=>`Failed to retrieve or parse data for "${t}" from storage`,Mm=(t,e)=>`${t}${j}The server side cookies functionality is disabled as the provided data server URL, "${e}" is invalid.`,Fm=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,Lm=t=>`The server failed to set the ${t} cookie. As a fallback, the cookies will be set client side.`,zc="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",Um=(t,e)=>`The server did not set ${t.length} of the ${e} cookies sent in one request: ${t.join(", ")}. A fallback to set them client side was attempted. Check that the data service and any proxy preserve every "Set-Cookie" header, and that the cookie domain and SameSite/Secure attributes are valid.`,Bm=(t,e)=>`${t}${j}The storage type "${e}" is not supported. Please choose one of the following supported types: "${Pi}". The default storage type will be used instead.`,Vm=(t,e,s)=>`${t}${j}The storage type "${s}" configured for the entry "${e}" is not supported. Please choose one of the following supported types: "${Pi}". The default storage type will be used instead.`,jm=(t,e,s,i)=>`${t}${j}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.`,Gm=(t,e,s)=>`${t}${j}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.`,Hm=(t,e,s)=>`${t}${j}The provided cookie domain (${e}) does not match the current webpage's domain (${s}). Hence, the cookies will be set client-side.`,zm=(t,e,s)=>`${t}${j}The data service host (${e}) cannot set cookies for the current webpage (${s}). Hence, the cookies will be set client-side instead of server-side.`,qm=(t,e,s,i)=>`${t}${j}The "${e}" property defined under "${s}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${i}).`,Wm=(t,e)=>`${t}${j}The top-level custom context property "${e}" is reserved and was ignored.`,Km=t=>`${t}${j}Please make sure that the "context" property in the event API's "options" argument is a valid object literal with key-value pairs.`,Pn=t=>`${t}${j}Invalid custom context. Use a plain object without prototype pollution keys.`,Ym=t=>`${t}${j}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,Qm=(t,e,s)=>`${t}${j}The session timeout value "${e}" is not a number. The default timeout of ${s} ms will be used instead.`,Jm=(t,e,s)=>`${t}${j}The session cut off duration value "${e}" is not a number. The default cut off duration of ${s} ms will be used instead.`,Xm=(t,e,s)=>`${t}${j}The session cut off duration value "${e}" ms is less than the session timeout value "${s}" ms. The cut off functionality will be disabled.`,Zm=t=>`${t}${j}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.`,ey=(t,e,s)=>`${t}${j}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.`,ty=(t,e,s)=>`${t}${j}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.`,sy=t=>`${t}${j}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,iy=(t,e,s,i)=>`${t}${j}The storage type "${s}" is not available for entry "${e}". The SDK will initialize the entry with "${i}" storage type instead.`,ny=t=>`${t}${j}The callback threw an exception`,ry=(t,e)=>`${t}${j}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,oy=(t,e)=>`Failed to load the polyfill script with ID "${t}" from URL ${e}.`,ay=(t,e,s)=>`${t}${j}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.`,ly=t=>`${t}${j}The pre-consent storage strategy option is deprecated. Please enable "storage" in the pre-consent options and use the "storage" load API option instead.`,cy=(t,e,s)=>`${t}${j}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.`,uy=(t,e)=>`${t}${j}${e} plugin is deprecated. Please exclude it from the load API options.`,dy=(t,e,s,i)=>{let n=s.length===1,r=n?` '${s[0]}' plugin was`:` ['${s.join("', '")}'] plugins were`,o=`${t}${j}${e}, but${r} not configured to load.`;return i?`${o} So, ${n?"the plugin":"those plugins"} will be loaded automatically.`:`${o} Ignore if this was intentional. Otherwise, consider adding ${n?"it":"them"} to the 'plugins' load API option.`},hy=(t,e)=>`${t}${j}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,fy=t=>`${t}${j}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,gy=(t,e)=>`${t}${j}Ignoring unknown plugins: ${e.join(", ")}.`,py=(t,e,s)=>`${t}${j}Failed to load plugin "${e}" - ${s}`,vy=(t,e)=>`${t}${j}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.`,_y=(t,e)=>`${t}${j}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,$u={All:!0},Xn="js-integrations",xu="plugins",my=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_]*)?$"),$i="modern",xi="https://cdn.rudderlabs.com",na="v3",Du=`${xi}/${na}/${$i}/${Xn}`,Nu=`${xi}/${na}/${$i}/${xu}`,Mu="https://api.rudderstack.com",gs="v3",yy="xhr",Oo={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},$n={[gs]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},by={[yy]:"XhrQueue",beacon:"BeaconQueue"},Ey="rsaRequest",wy="rsaMetrics",Sy="Custom Device Mode",ky={configUrl:Mu,loadIntegration:!0,sessions:{autoTrack:!0,timeout:To,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:$u,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:K_,storage:{encryption:{version:gs},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},Ay=C(te(ky)),ue=ea({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),xn=ea({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),Ty=10,Iy={userId:C(ue.userId),userTraits:C(ue.userTraits),anonymousId:C(ue.anonymousId),groupId:C(ue.groupId),groupTraits:C(ue.groupTraits),initialReferrer:C(ue.initialReferrer),initialReferringDomain:C(ue.initialReferringDomain),sessionInfo:C(ue.sessionInfo),authToken:C(ue.authToken)},Ry={isOnline:C(!0),storage:{isLocalStorageAvailable:C(!1),isCookieStorageAvailable:C(!1),isSessionStorageAvailable:C(!1)},isBeaconAvailable:C(!1),isLegacyDOM:C(!1),isUaCHAvailable:C(!1),isCryptoAvailable:C(!1),isAdBlockerDetectionInProgress:C(!1),isAdBlocked:C(void 0),cspViolations:C([]),sdkCdnProbe:C({})},Cy={isErrorReportingEnabled:C(!1),isMetricsReportingEnabled:C(!1),breadcrumbs:C([])},Oy=C(void 0),Py={activeDataplaneUrl:C(void 0),integrationsCDNPath:C(Du),pluginsCDNPath:C(Nu),sourceConfigUrl:C(void 0),status:C(void 0),initialized:C(!1),logLevel:C(Ou),loaded:C(!1),readyCallbacks:C([]),writeKey:C(void 0),dataPlaneUrl:C(void 0),safeAnalyticsInstance:C(void 0)},$y={enabled:C(!1),initialized:C(!1),data:C({}),activeConsentManagerPluginName:C(void 0),preConsent:C({enabled:!1}),postConsent:C({}),resolutionStrategy:C("and"),provider:C(void 0),metadata:C(void 0)},xy={retries:C(0),dropped:C(0),sent:C(0),queued:C(0),triggered:C(0),metricsServiceUrl:C(void 0)},Dy=()=>U_,Ny={app:C({name:Dc,namespace:L_,version:Ci,installType:wu}),traits:C(null),library:C({name:Dc,version:Ci,snippetVersion:globalThis.RudderSnippetVersion,variant:Dy()}),userAgent:C(null),device:C(null),network:C(null),os:C({name:"",version:""}),locale:C(null),screen:C({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":C(void 0),timezone:C(void 0)},My=C({}),Fy={configuredDestinations:C([]),activeDestinations:C([]),loadOnlyIntegrations:C({}),failedDestinations:C([]),loadIntegration:C(!0),initializedDestinations:C([]),clientDestinationsReady:C(!1),integrationsConfig:C({})},Ly={toBeProcessedArray:C([]),readyCallbacksArray:C([])},Uy={ready:C(!1),loadedPlugins:C([]),failedPlugins:C([]),pluginsToLoadFromConfig:C([]),activePlugins:C([]),totalPluginsToLoad:C(0)},By={encryptionPluginName:C(void 0),migrate:C(!1),cookie:C(void 0),entries:C({}),trulyAnonymousTracking:C(!1)},Vy={isEnabledServerSideCookies:C(!1),dataServiceUrl:C(void 0),isCollapsedBatchErrorLogged:C(!1)},jy={eventsQueuePluginName:C(void 0),deliveryEnabled:C(!0)},Gy={enabled:C(!1),pageLifecycle:{enabled:C(!1),pageViewId:C(void 0),pageLoadedTimestamp:C(void 0)}},Hy={capabilities:Ry,consents:$y,context:Ny,customContext:My,eventBuffer:Ly,lifecycle:Py,loadOptions:Ay,metrics:xy,nativeDestinations:Fy,plugins:Uy,reporting:Cy,session:Iy,source:Oy,storage:By,serverCookies:Vy,dataPlaneEvents:jy,autoTrack:Gy},f={...te(Hy)},Fu=/^\s*at /,zy=/^(eval@)?(\[native code])?$/,qy=/(.+?)(?::(\d+))?(?::(\d+))?$/;Uu="global code",Qy=t=>ce(t)&&/^global code$/i.test(t)?Uu:t,Jy=t=>{let e={file:t.fileName,method:Qy(t.functionName),lineNumber:t.lineNumber,columnNumber:t.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=Uu),e},qc=t=>ge(t)?t:"";Bu=(t,e)=>{let s;return Zo(t)&&ge(Yn(t))?s=t:(e.warn(Em(Si,rt(t))),s=void 0),s},Xy=(t,e)=>{try{let s=Yy(t);return Wc(t.name,t.message,e,s)}catch{return Wc(t.name,t.message,e,[])}},Kc=(t,e)=>{try{return JSON.parse(t||"")}catch(s){let i=sa(s,"Failed to parse response data");e(i)}},Dn="The request failed",Zy=[/Failed to fetch dynamically imported module: .*/,/error loading dynamically imported module: .*/],e0=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],t0=[new RegExp(`${Dn}.*`),/A script with the id .* is already loaded\./],s0=[...Zy,...e0],i0="integrations",n0="sdk",r0=n0,o0={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},Yc=(t,e,s)=>{let i=$e(o0,e||{});return s&&(i.headers=$e(i.headers,{Authorization:s})),i.url=t,i},Qc=(t,e=q_,s)=>new Promise((i,n)=>{let r;if(t.sendRawData===!0)r=t.data;else if(r=rt(t.data,!1,[],s),st(r)){n({error:new Error(pm),undefined:void 0,options:t});return}let o=new XMLHttpRequest,a=c=>{n({error:new Error(Pm(Dn,o.status,o.statusText,t.url,o.responseText)),xhr:o,options:t})},l=c=>{n({error:new Error($m(Dn,c,t.url)),xhr:o,options:t,...c?.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(c=>{t.headers[c]&&o.setRequestHeader(c,t.headers[c])});try{o.send(r)}catch(c){n({error:sa(c,xm(Dn,t.url)),xhr:o,options:t})}}),Po=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:n,isRawResponse:r,skipAuthHeader:o}=e;try{let a=await Qc(Yc(s,i,this.getAuthHeader(o)),n,this.logger);return{data:r?a.response:Kc(a.response,this.onError),details:a}}catch(a){return{data:void 0,details:a}}}getAsyncData(e){let{callback:s,url:i,options:n,timeout:r,isRawResponse:o,skipAuthHeader:a}=e,l=!F(s);Qc(Yc(i,n,this.getAuthHeader(a)),r,this.logger).then(c=>{l||s(o?c.response:Kc(c.response,this.onError),c)},c=>{l||s(void 0,c)}).catch(this.onError)}onError(e,s){this.errorHandler?.onError({error:e,context:m_,groupingHash:s})}getAuthHeader(e){return e===!0?void 0:this.basicAuthHeader}setAuthHeader(e,s=!1){let i=s?e:g_(`${e}:`);this.basicAuthHeader=`Basic ${i}`}resetAuthHeader(){this.basicAuthHeader=void 0}},Vu=new Po(Ft),a0="1",l0=()=>["rsa"],c0=["www.test-host.com","localhost","127.0.0.1","[::1]"],u0=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","customContext","traits","authToken"],d0="RudderStack JavaScript SDK",h0="git+https://github.com/rudderlabs/rudder-sdk-js.git",f0="js",g0=(t,e)=>{switch(e){case Pt.UNHANDLEDEXCEPTION:{let{error:s}=t;return s||t}case Pt.UNHANDLEDREJECTION:return t.reason;case Pt.HANDLEDEXCEPTION:default:return t}},p0=t=>({type:"manual",name:t,timestamp:new Date,metaData:{}}),v0=(t=()=>window.location.hostname)=>{let e=t();return!e||e&&c0.includes(e)?"development":"production"},_0=t=>{let e=rt(t,!1,u0);return e!==null?JSON.parse(e):{}},m0=()=>globalThis.location.href.split("?")[0],y0=(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"}),b0=(t,e)=>({locale:t.value??"NA",userAgent:e.value??"NA",time:new Date}),E0=(t,e,s,i)=>{let{context:n,lifecycle:r,session:o,source:a,reporting:l,autoTrack:c}=s,{app:u,locale:h,userAgent:d,timezone:g,screen:p,library:m}=n;return{payloadVersion:"5",notifier:{name:d0,version:u.value.version,url:h0},events:[{exceptions:[te(t)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:u.value.version,releaseStage:v0(),type:u.value.installType},device:b0(h,d),request:{url:m0(),clientIp:"[NOT COLLECTED]"},breadcrumbs:te(l.breadcrumbs.value),context:t.message,groupingHash:i,metaData:{app:{snippetVersion:m.value.snippetVersion},device:{...p.value,timezone:g.value},..._0(s)},user:y0(a,o,r,c)}]}},w0=["script-src-elem","script-src","default-src"],S0=["connect-src","default-src"],Jc=(t,e,s)=>t.capabilities.cspViolations.value.some(i=>s.includes(i.directive)&&Zn(e,i.blockedURL)),Zn=(t,e)=>{if(t===e)return!0;if(!t.startsWith(e))return!1;let s=t.charAt(e.length);return s==="/"||s==="?"||s==="#"},Rn=new Map,k0=(t,e,s,i)=>{if(ce(t.capabilities.sdkCdnProbe.value[s])){i();return}let n=Rn.get(s);if(n){n.push(i);return}Rn.set(s,[i]),e.getAsyncData({url:s,skipAuthHeader:!0,options:{method:"HEAD",headers:{"Content-Type":void 0,Accept:void 0}},isRawResponse:!0,callback:(r,o)=>{let a=o?.xhr?.status??0,l=o?.xhr?.responseURL;t.capabilities.sdkCdnProbe.value={...t.capabilities.sdkCdnProbe.value,[s]:{status:a,timedOut:o?.timedOut===!0,redirectedOffCdn:a!==0&&ge(l)&&l!==s&&!Zn(l,xi)}};let c=Rn.get(s)??[];Rn.delete(s),c.forEach(u=>u())}})},A0=(t,e,s)=>{let i=t.message;return new Promise(n=>{if(s0.some(r=>r.test(i))){let r=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(i)?.[0];ge(r)?Zn(r,xi)?k0(e,s,r,()=>{let o=Jc(e,r,w0),a=e.capabilities.sdkCdnProbe.value[r],l=Jc(e,r,S0),c=a!==void 0&&!a.timedOut&&!l&&(a.status===0||a.redirectedOffCdn);n(!o&&!c)}):n(!1):n(!0)}else n(!t0.some(r=>r.test(i)))})},ju=t=>t?t.split("/").at(-2):void 0,Gu=t=>{let e=t.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},T0=t=>{let e=Gu(t);if(!e)return!1;let s=e.substring(e.lastIndexOf("/")+1);return ju(e)===Xn||l0().some(n=>s.startsWith(n)&&s.endsWith(".js"))},I0=(t,e)=>{if(e)return e;let s=Gu(t);return ju(s)===Xn?i0:r0},R0=(t,e,s)=>{let i={version:a0,message_id:Kn(),source:{name:f0,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 rt(i)},C0=(t,e,s)=>{let i;if(!ce(t))i=e;else if(ge(t))i=t;else{let n=Bu(t,s);ce(n)?i=n.message:i=e}return i},$o=class{constructor(e,s){Se(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:Si,errorType:Pt.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Si,errorType:Pt.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let s=ge(e.blockedURI)?e.blockedURI:"",i=ge(e.effectiveDirective)?e.effectiveDirective:"";if(e.disposition!=="enforce"||!Zn(s,xi))return;f.capabilities.cspViolations.value.some(r=>r.blockedURL===s&&r.directive===i)||(f.capabilities.cspViolations.value=[...f.capabilities.cspViolations.value,{blockedURL:s,directive:i}])})}async onError(e){try{let{error:s,context:i,customMessage:n,groupingHash:r,category:o}=e,a=e.errorType??Pt.HANDLEDEXCEPTION,l=g0(s,a),c=Bu(l,this.logger);if(Ve(c))return;let u=n?`${n} - `:"",h=`${i}${j}${u}`,d=Xy(c,h),p=Yn(c).includes(Eu);if(!p&&!T0(d)&&a!==Pt.HANDLEDEXCEPTION)return;if(f.reporting.isErrorReportingEnabled.value&&await A0(d,f,this.httpClient)){let v={severity:"error",unhandled:a!==Pt.HANDLEDEXCEPTION,severityReason:{type:a}},b=C0(r,d.message,this.logger),y=E0(d,v,f,b),w=I0(d,o);this.httpClient.getAsyncData({url:f.metrics.metricsServiceUrl.value,options:{method:"POST",data:R0(y,f,w),sendRawData:!0},isRawResponse:!0})}(a===Pt.HANDLEDEXCEPTION||p)&&this.logger.error(d.message)}catch(s){this.logger.error(wm(Si),s)}}leaveBreadcrumb(e){try{f.reporting.breadcrumbs.value=[...f.reporting.breadcrumbs.value,p0(e)]}catch(s){this.onError({error:s,context:Si,customMessage:Gc,groupingHash:Gc})}}},Hu=new $o(Vu,Ft),xo=class{constructor(e,s={}){Se(this,"plugins",[]);Se(this,"byName",{});Se(this,"cache",{});Se(this,"config",{throws:!0});this.config={throws:!0,...s},this.logger=e}register(e,s){if(!e.name){let n=Sm(Us);if(this.config.throws)throw new Error(n);this.logger.error(n,e);return}if(this.byName[e.name]){let n=km(Us,e.name);if(this.config.throws)throw new Error(n);this.logger.error(n);return}this.cache={},this.plugins=this.plugins.slice();let i=this.plugins.length;this.plugins.forEach((n,r)=>{n.deps?.includes(e.name)&&(i=Math.min(i,r))}),this.plugins.splice(i,0,e),this.byName[e.name]=e,F(e.initialize)&&e.initialize(s)}unregister(e){let s=this.byName[e];if(!s){let n=Am(Us,e);if(this.config.throws)throw new Error(n);this.logger.error(n);return}let i=this.plugins.indexOf(s);if(i===-1){let n=Tm(Us,e);if(this.config.throws)throw new Error(n);this.logger.error(n);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(n=>!this.byName[n])){let n=i.deps.filter(r=>!this.byName[r]);return this.logger.error(Im(Us,i.name,n)),!1}return s==="."?!0:l_(i,s)})),this.cache[s]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,s=!0,...i){let n=e;if(!n)throw new Error(vm);let r=n.startsWith("!"),o=this.config.throws??n.endsWith("!");if(n=n.replace(/(^!|!$)/g,""),!n)throw new Error(_m);let a=n.split(".");a.pop();let l=a.join(".");return(s?this.getPlugins(n):[this.getPlugins(n)[0]]).map(u=>{let h=So(u,n);if(!F(h)||r)return h;try{return h.apply(So(u,l),i)}catch(d){if(o)throw d;this.logger.error(Rm(Us,n,u.name),d)}return null})}invokeSingle(e,...s){return this.invoke(e,!1,...s)[0]}invokeMultiple(e,...s){return this.invoke(e,!0,...s)}},O0=new xo(Ft,{throws:!0}),P0=t=>t.config.connectionMode!=="cloud"||t.config.useNativeSDKToSend===!0||t.config.useNativeSDK===!0,$0=t=>t.config.connectionMode==="hybrid"||t.config.useNativeSDKToSend===!0,Xc=t=>t.filter(P0),x0=(t,e)=>`${t.replaceAll(" ","-")}___${e}`,zu=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],D0=["Bugsnag","ErrorReporting"],N0={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//rsa-plugins.js"),format:"esm",from:"vite"}};M0=t=>qu({},(globalThis.__federation_shared__||{}).default||{});L0=t=>{switch(t){case"BeaconQueue":return()=>tt("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>et(e,!0));case"CustomConsentManager":return()=>tt("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>et(e,!0));case"DeviceModeDestinations":return()=>tt("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>et(e,!0));case"DeviceModeTransformation":return()=>tt("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>et(e,!0));case"ExternalAnonymousId":return()=>tt("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>et(e,!0));case"GoogleLinker":return()=>tt("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>et(e,!0));case"KetchConsentManager":return()=>tt("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>et(e,!0));case"IubendaConsentManager":return()=>tt("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>et(e,!0));case"NativeDestinationQueue":return()=>tt("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>et(e,!0));case"OneTrustConsentManager":return()=>tt("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>et(e,!0));case"StorageEncryption":return()=>tt("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>et(e,!0));case"StorageEncryptionLegacy":return()=>tt("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>et(e,!0));case"StorageMigrator":return()=>tt("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>et(e,!0));case"XhrQueue":return()=>tt("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>et(e,!0));default:return}},U0=t=>{let e={};return t.forEach(s=>{if(zu.includes(s)){let i=L0(s);i&&(e[s]=i)}}),e},Wu=()=>({}),B0=()=>({}),V0=t=>U0?.(t)||{},mo={...Wu(),...B0()},j0=t=>({...V0(t)}),Do=class{constructor(e,s,i){this.engine=e,this.errorHandler=s,this.logger=i,this.onError=this.onError.bind(this)}init(){f.lifecycle.status.value="pluginsLoading",Oi("pluginsCDNPath",f.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){Mt(()=>{(f.plugins.activePlugins.value.length===0||f.plugins.loadedPlugins.value.length+f.plugins.failedPlugins.value.length===f.plugins.totalPluginsToLoad.value)&&Fe(()=>{f.plugins.ready.value=!0,f.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=f.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(n=>D0.includes(n)?(this.logger.warn(uy(Ls,n)),!1):!0);let s=[{configurationStatus:()=>ce(f.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:f.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(by),shouldAddMissingPlugins:!0},{configurationStatus:()=>Xc(f.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>Xc(f.nativeDestinations.configuredDestinations.value).some(n=>n.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>ce(f.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:f.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(Oo)},{configurationStatus:()=>ce(f.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:f.storage.encryptionPluginName.value,supportedPlugins:Object.values($n)},{configurationStatus:()=>f.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],i=!1;return s.forEach(n=>{n.configurationStatus()?(e=e.filter(n.activePluginName?r=>!(r!==n.activePluginName&&n.supportedPlugins.includes(r)):r=>ce(r)),this.addMissingPlugins(n,i,e)):e=e.filter(n.basePlugins!==void 0?r=>!(n.basePlugins.includes(r)||n.supportedPlugins.includes(r)):r=>!n.supportedPlugins.includes(r))}),[...Object.keys(Wu()),...e]}addMissingPlugins(e,s,i){let n=e.shouldAddMissingPlugins||s,r;e.activePluginName?r=[...e.basePlugins||[],e.activePluginName]:r=[...e.supportedPlugins];let o=r.filter(a=>!i.includes(a));o.length>0&&(n&&i.push(...o),this.logger.warn(dy(Ls,e.configurationStatusStr,o,n)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),s=[...Object.keys(mo),...zu],i=[],n=[];e.forEach(r=>{s.includes(r)?i.push(r):n.push(r)}),n.length>0&&this.logger.warn(gy(Ls,n)),Fe(()=>{f.plugins.totalPluginsToLoad.value=e.length,f.plugins.activePlugins.value=i,f.plugins.failedPlugins.value=n})}registerLocalPlugins(){let e=[];Object.entries(mo).forEach(([s,i])=>{f.plugins.activePlugins.value.includes(s)&&(F(i)?this.register([i()]):e.push(s))}),e.length>0&&(f.plugins.failedPlugins.value=[...f.plugins.failedPlugins.value,...e],this.logger.error(vy(Ls,e)))}registerRemotePlugins(){let e=j0(f.plugins.activePlugins.value),s=[],i=[];return Promise.all(Object.keys(e).map(async n=>{await e[n]().then(r=>this.register([r.default()])).catch(r=>{i.push(n),f.plugins.failedPlugins.value=[...f.plugins.failedPlugins.value,n],this.logger.error(py(Ls,n,r?.message??String(r))),s.push(r)})})).then(()=>{if(i.length===0)return;let n=s[0];this.onError(n,`Failed to load plugins: ${i.join(", ")}`,n)}).catch(n=>{this.onError(n)})}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,f)}catch(i){f.plugins.failedPlugins.value=[...f.plugins.failedPlugins.value,s.name],this.onError(i,`Failed to register plugin "${s.name}"`)}})}unregisterLocalPlugins(){Object.keys(mo).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:Ls,customMessage:s,groupingHash:i})}},ze="cookieStorage",ot="localStorage",ht="sessionStorage",St="memoryStorage",Zt="none",G0="test_rudder_cookie",H0="test_rudder_ls",z0="test_rudder_ss",q0="rl_user_id",W0="rl_trait",K0="rl_anonymous_id",Y0="rl_group_id",Q0="rl_group_trait",J0="rl_page_init_referrer",X0="rl_page_init_referring_domain",Z0="rl_session",eb="rl_auth_token",Bs={userId:q0,userTraits:W0,anonymousId:K0,groupId:Y0,groupTraits:Q0,initialReferrer:J0,initialReferringDomain:X0,sessionInfo:Z0,authToken:eb},tb="__tld__",Ku="clientDataInCookie",Yu="clientDataInLocalStorage",sb="clientDataInMemory",Qu="clientDataInSessionStorage",Ju=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ps={[ze]:Ku,[ot]:Yu,[St]:sb,[ht]:Qu},Zc=(t,e)=>{try{return encodeURIComponent(t)}catch(s){e?.error($_,s);return}},eu=t=>{try{return decodeURIComponent(t)}catch{return}},ib=t=>{let e={},s=t.split(/\s*;\s*/),i;return s[0]&&s.forEach(n=>{i=n.split("=");let r=i[0]?eu(i[0]):void 0;r&&(e[r]=i[1]?eu(i[1]):void 0)}),e},nb=(t,e,s,i)=>{let n={...s||{}},r=`${Zc(t,i)}=${Zc(e,i)}`;st(e)&&(n.maxage=-1),n.maxage&&(n.expires=new Date(+new Date+n.maxage)),n.path&&(r+=`; path=${n.path}`),n.domain&&(r+=`; domain=${n.domain}`),n.expires&&(r+=`; expires=${n.expires.toUTCString()}`),n.samesite&&(r+=`; samesite=${n.samesite}`),n.secure&&(r+="; secure"),globalThis.document.cookie=r},No=()=>{let t=globalThis.document.cookie;return ib(t)},rb=t=>No()[t],$t=function(t,e,s,i){switch(arguments.length){case 4:case 3:case 2:return nb(t,e,s,i);case 1:return t?rb(t):No();default:return No()}},ob=t=>{let e=document.createElement("a");return e.href=t,e.hostname},ab=t=>{let s=(typeof globalThis.URL!="function"?ob(t):new URL(t).hostname)?.split(".")??[],i=s[s.length-1],n=[];if(s.length===4&&i&&i===parseInt(i,10).toString())return n;if(s.length<=1)return s[0]&&s[0].indexOf("localhost")!==-1?["localhost"]:n;for(let r=s.length-2;r>=0;r-=1)n.push(s.slice(r).join("."));return n},Xu=t=>{let e=ab(t);for(let s=0;s<e.length;s+=1){let i=e[s],n=tb,r={domain:`${i.indexOf("localhost")!==-1?"":"."}${i}`};try{if($t(n,1,r),$t(n))return $t(n,null,r),i}catch{try{$t(n,null,r)}catch{}}}return""},lb=()=>{let t=`.${Xu(globalThis.location.href)}`;return{maxage:W_,path:"/",domain:!t||t==="."?void 0:t,samesite:"Lax",enabled:!0}},cb=()=>({enabled:!0}),ub=()=>({enabled:!0}),db=()=>({enabled:!0}),Mo=class{constructor(e){Se(this,"isEnabled",!0);Se(this,"length",0);Se(this,"data",{});this.options=db(),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)}},zn=new Mo(Ft);Nn={exports:{}},fb=Nn.exports;pb=gb(),hs=hb(pb),Zu=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},Vs=(t=ot,e,s)=>{let i,n,r=x_(ko,t),o="unavailable",a=!0,l;try{switch(t){case St:return!0;case ze:i=e,n=G0;break;case ot:i=e??globalThis.localStorage,n=H0;break;case ht:i=e??globalThis.sessionStorage,n=z0;break;default:return!1}if(i&&(i.setItem(n,"true"),i.getItem(n)))return i.removeItem(n),!0;a=!1}catch(c){a=!1,l=c,Zu(c)&&(o="full")}return a||s?.warn(`${r}${o}.`,l),!1},Fo=class{constructor(e){Se(this,"isSupportAvailable",!0);Se(this,"isEnabled",!0);Se(this,"length",0);this.options=cb(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isSupportAvailable=Vs(ot),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,s){hs.set(e,s),this.length=hs.len()}getItem(e){let s=hs.get(e);return Ve(s)?null:s}removeItem(e){hs.remove(e),this.length=hs.len()}clear(){hs.clear(),this.length=0}key(e){return this.keys()[e]??null}keys(){return hs.keys()}},ra=new Fo(Ft),Lo=class{constructor(e){Se(this,"isSupportAvailable",!0);Se(this,"isEnabled",!0);Se(this,"length",0);this.options=ub(),this.logger=e}configure(e){return this.options=$e(this.options,e??{}),this.isSupportAvailable=Vs(ht),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}},oa=new Lo(Ft),Uo=class{constructor(e){Se(this,"isSupportAvailable",!0);Se(this,"isEnabled",!0);Se(this,"length",0);this.logger=e}configure(e){return this.options||(this.options=lb()),this.options=$e(this.options,e??{}),this.options.sameDomainCookiesOnly&&delete this.options.domain,this.isSupportAvailable=Vs(ze,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())}},aa=new Uo(Ft),pt=t=>{switch(t){case ot:return ra;case ht:return oa;case St:return zn;case ze:return aa;default:return zn}},vb=t=>{let e=aa.configure(t);f.storage.cookie.value={maxage:e.maxage,path:e.path,domain:e.domain,samesite:e.samesite,expires:e.expires,secure:e.secure}},_b=t=>{ra.configure(t)},mb=t=>{zn.configure(t)},yb=t=>{oa.configure(t)},bb=(t={},e={},s={},i={})=>{vb(t),_b(e),mb(s),yb(i)},Bo=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.noSwapOnQuota=e.noSwapOnQuota,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=i}createValidKey(e){let{name:s,id:i,validKeys:n,noKeyValidation:r,noCompoundKey:o}=this;if(r)return o?e:[s,i,e].join(".");let a;return Object.values(n).forEach(l=>{l===e&&(a=o?e:[s,i,e].join("."))}),a}swapQueueStoreToInMemoryEngine(){let{validKeys:e,noCompoundKey:s}=this,i=pt(St),n=this.engine,r=Object.values(e).map(a=>[a,this.get(a)]),o=!s&&n!==i;this.engine=i,r.forEach(([a,l])=>{if(at(l))return;this.set(a,l);let c=this.createValidKey(a);if(o&&c&&!at(this.get(a)))try{n.removeItem(c)}catch{}})}set(e,s){let i=this.createValidKey(e);if(i)try{this.engine.setItem(i,this.encrypt(rt(s,!1,[],this.logger)))}catch(n){if(Zu(n)){if(this.logger.warn(sy(`Store ${this.id}`)),this.noSwapOnQuota)return;this.swapQueueStoreToInMemoryEngine(),this.set(e,s)}else{let r=Dm(e);this.onError(n,r,r)}}}get(e){let s=this.createValidKey(e),i;try{return!s||(i=this.decrypt(this.engine.getItem(s)),at(i)||i==="")?null:JSON.parse(i)}catch(n){let r=f.storage.encryptionPluginName.value;if(!r||!f.plugins.failedPlugins.value.includes(r)){let a=Nm(e);this.onError(n,a,a)}return null}}remove(e){let s=this.createValidKey(e);s&&this.engine.removeItem(s)}getOriginalEngine(){return this.originalEngine}decrypt(e){return at(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,s){if(!this.isEncrypted||!e||typeof e!="string"||h_(e)==="")return e;let n=`storage.${s}`,r=this.pluginsManager?this.pluginsManager.invokeSingle(n,e):e;return typeof r>"u"?e:r??""}onError(e,s,i){this.errorHandler.onError({error:e,context:`Store ${this.id}`,customMessage:s,groupingHash:i})}},Eb=(t,e)=>{let s;if(t.consents.preConsent.value.enabled)switch(t.consents.preConsent.value.storage?.strategy){case"none":s=Zt;break;case"session":e!=="sessionInfo"&&(s=Zt);break;case"anonymousId":e!=="anonymousId"&&(s=Zt);break}return s},Vo=class{constructor(e,s,i){Se(this,"stores",{});Se(this,"isInitialized",!1);this.errorHandler=s,this.logger=i,this.pluginsManager=e}init(){if(this.isInitialized)return;let e=f.loadOptions.value,s={cookieStorageOptions:{samesite:e.sameSiteCookie,secure:e.secureCookie,domain:e.setCookieDomain,sameDomainCookiesOnly:e.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};bb(wi($e(s.cookieStorageOptions??{},f.storage.cookie?.value??{})),wi(s.localStorageOptions),wi(s.inMemoryStorageOptions),wi(s.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[St,ot,ze,ht].forEach(s=>{pt(s)?.isEnabled&&this.setStore({id:ps[s],name:ps[s],isEncrypted:!0,noCompoundKey:!0,type:s,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){let e=f.loadOptions.value.storage?.type,s=f.loadOptions.value.storage?.entries,i=f.consents.postConsent.value.storage;(ce(i?.type)||ce(i?.entries))&&(e=i?.type,s=i?.entries);let n=f.consents.preConsent.value,o=n.enabled===!0&&!n.storage?.strategy?Zt:fm;e!==void 0&&!Pi.includes(e)&&(e=void 0);let a=!0,l={};Ju.forEach(c=>{let u=c,h=c,d=s?.[u]?.type,p=Eb(f,c)??d??e??o;Pi.includes(p)||(p=o);let m=this.getResolvedStorageTypeForEntry(p,c);m!==Zt&&(a=!1),l={...l,[c]:{type:m,key:Bs[h]}}}),Fe(()=>{f.storage.entries.value=l,f.storage.trulyAnonymousTracking.value=a})}getResolvedStorageTypeForEntry(e,s){let i=e;switch(e){case ot:pt(ot)?.isEnabled||(i=St);break;case ht:pt(ht)?.isEnabled||(i=St);break;case St:case Zt:break;case ze:default:pt(ze)?.isEnabled?i=ze:pt(ot)?.isEnabled?i=ot:pt(ht)?.isEnabled?i=ht:i=St;break}return i!==e&&this.logger.warn(iy(p_,s,e,i)),i}setStore(e){let s=pt(e.type);return this.stores[e.id]=new Bo(e,s,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}},wb=t=>fe(t)&&fe(t.source)&&!at(t.source.id)&&fe(t.source.config)&&Array.isArray(t.source.destinations),su=t=>typeof t=="string"&&Pi.includes(t),ed=(t,e,s)=>{if(!fe(t))return;let{type:i,entries:n}=t;ce(i)&&!su(i)&&s?.warn(Bm(e,i)),n&&Object.entries(n).forEach(([r,o])=>{let a=o?.type;ce(a)&&!su(a)&&s?.warn(Vm(e,r,a))})},Sb=t=>{let e=document.createElement("a");return e.href=t,{host:e.host,protocol:e.protocol}},kb=t=>{let{host:e,protocol:s}=typeof globalThis.URL!="function"?Sb(t):new URL(t),i=e.split("."),n;return i.length>2?n=i.slice(-2).join("."):n=e,{topDomain:n,protocol:s}},Ab=/^https?:\/\//i,Tb=(t,e,s)=>{if(Ab.test(t))return t;let i=e||!s?window.location.origin:`${window.location.protocol}//${s}`,n=t.startsWith("/")?t.substring(1):t;return`${i}/${n}`},Mn=(t,e)=>t===e||t.endsWith(`.${e}`),Ib=(t,e,s)=>s||!e?t===globalThis.location.hostname:Mn(t,e),Rb=t=>{let{topDomain:e}=kb(window.location.href);return e===t},Gs=t=>t?.endsWith("/")?Gs(t.substring(0,t.length-1)):t,Cb=t=>{try{return new URL(t).host}catch{return null}},Ob=t=>{try{return new URL(t).hostname}catch{return null}},td=t=>Cb(t)??"",Pb=t=>{let e={};try{let s=new URL(t),i="utm_";s.searchParams.forEach((n,r)=>{if(r.startsWith(i)){let o=r.substring(i.length);o==="campaign"&&(o="name"),e[o]=n}})}catch{}return e},$b=t=>{let e=t;try{let s=new URL(t);e=s.origin+s.pathname+s.search}catch{}return e},xb=t=>t.replace(/\/{2,}/g,"/"),Hs=t=>{if(!ge(t))return!1;try{return F(globalThis.URL)&&new URL(t),my.test(t)}catch{return!1}},yo="none",bo="immediate",Db=t=>t?.statsCollection?.errors?.enabled===!0,Nb=t=>t?.statsCollection?.metrics?.enabled===!0,Mb=(t,e)=>{let s={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(s.storage=f.consents.postConsent.value.storage,fe(t)){let i=te(t);ce(i.storage)&&(ed(i.storage,__,e),s.storage=i.storage),Nt(i.integrations)&&(s.integrations=i.integrations),s.discardPreConsentEvents=i.discardPreConsentEvents===!0,s.sendPageEvent=i.sendPageEvent===!0,s.trackConsent=i.trackConsent===!0,Nt(i.consentManagement)&&(s.consentManagement=$e(i.consentManagement,{enabled:f.consents.enabled.value}))}return s},iu=t=>Nt(t)||Array.isArray(t),Fb=(t,e)=>{let{provider:s}=t,i=s?Oo[s]:void 0;return s&&!i&&(e.error(bm(qe,s,Oo)),s=void 0),{provider:s,consentManagerPluginName:i}},sd=(t,e)=>{let s,i=[],n=[],r=!1,o,a=t?.enabled===!0;Nt(t)&&a&&({provider:o,consentManagerPluginName:s}=Fb(t,e),iu(t.allowedConsentIds)&&(i=t.allowedConsentIds,r=!0),iu(t.deniedConsentIds)&&(n=t.deniedConsentIds,r=!0));let l={allowedConsentIds:i,deniedConsentIds:n};return a=a&&!!s,{provider:o,consentManagerPluginName:s,initialized:r,enabled:a,consentsData:l}},Lb=()=>{let t=document.querySelector("script[data-rsa-write-key]");if(t&&t.dataset.rsaWriteKey===f.lifecycle.writeKey.value)return t.src;let e=document.getElementsByTagName("script"),s=/(?:^|\/)rsa(\.min)?\.js$/;for(let i of e){let n=i.getAttribute("src");if(n&&s.test(n))return n}},Ub=t=>{f.reporting.isErrorReportingEnabled.value=Db(t.source.config)&&!k_(),f.reporting.isMetricsReportingEnabled.value=Nb(t.source.config)},Bb=()=>{let t=Xu(globalThis.location.href),{port:e}=globalThis.location;return{topDomain:t,topHost:t&&e?`${t}:${e}`:t}},Vb=(t,e,s,i,n)=>{if(!Ib(t,s.topDomain,i))return n.error(zm(qe,t,s.hostname)),!1;if(i||!ce(e))return!0;let r=gu(e).toLowerCase();return!Mn(t,r)||!Mn(s.hostname,r)||s.topDomain&&!Mn(r,s.topDomain)?(n.error(Hm(qe,e,s.hostname)),!1):!0},jb=t=>{let{useServerSideCookies:e,dataServiceEndpoint:s,storage:i,setCookieDomain:n,sameDomainCookiesOnly:r}=f.loadOptions.value,o=i?.cookie,a=!1,l;if(e){a=e;let c=o.domain??n,u=ce(c)&&!Rb(gu(c))||r,{hostname:h}=globalThis.location,{topDomain:d,topHost:g}=Bb(),p=Tb(s??Ey,u,g),m=Ob(p);Hs(p)&&m?(l=Gs(p),a=Vb(m,c,{hostname:h,topDomain:d},r,t),a&&h!==m&&(o={...o,samesite:"None",secure:!0})):(t.error(Mm(qe,p)),a=!1)}return{sscEnabled:a,cookieOptions:o,finalDataServiceUrl:l}},Gb=t=>{let{storage:e}=f.loadOptions.value;ed(e,qe,t);let s=e?.encryption?.version,i=s&&$n[s];!Ve(s)&&Ve(i)?(t.warn(jm(qe,s,$n,gs)),s=gs):Ve(s)&&(s=gs);let n=e?.migrate,r=n&&s===gs;n===!0&&r!==n&&t.warn(Gm(qe,s,gs));let{sscEnabled:o,finalDataServiceUrl:a,cookieOptions:l}=jb(t);Fe(()=>{f.storage.cookie.value=l,f.serverCookies.isEnabledServerSideCookies.value=o,f.serverCookies.dataServiceUrl.value=a,f.storage.encryptionPluginName.value=$n[s],f.storage.migrate.value=r})},Hb=t=>{let{provider:e,consentManagerPluginName:s,initialized:i,enabled:n,consentsData:r}=sd(f.loadOptions.value.consentManagement,t),o=f.loadOptions.value.preConsent,a=o?.storage?.strategy;ce(a)&&t.warn(ly(qe));let l;o?.storage?.enabled!==!0&&(l=a??yo,["none","session","anonymousId"].includes(l)||(l=yo,t.warn(ay(qe,a,yo))));let c=o?.events?.delivery??bo,u=["immediate","buffer"];ce(c)&&!u.includes(c)&&(c=bo,t.warn(cy(qe,o?.events?.delivery,bo))),Fe(()=>{f.consents.activeConsentManagerPluginName.value=s,f.consents.initialized.value=i,f.consents.enabled.value=n,f.consents.data.value=r,f.consents.provider.value=e,f.consents.preConsent.value={enabled:f.loadOptions.value.preConsent?.enabled===!0&&i===!1&&n===!0,storage:{strategy:l},events:{delivery:c}}})},zb=t=>{let e=f.consents.resolutionStrategy.value,s;fe(t.consentManagementMetadata)&&(f.consents.provider.value&&(e=t.consentManagementMetadata.providers.find(i=>i.provider===f.consents.provider.value)?.resolutionStrategy??f.consents.resolutionStrategy.value),s=t.consentManagementMetadata),f.consents.provider.value==="custom"&&(e=void 0),Fe(()=>{f.consents.metadata.value=te(s),f.consents.resolutionStrategy.value=e})},qb=t=>{if(f.dataPlaneEvents.deliveryEnabled.value){let e="XhrQueue",s=e;f.loadOptions.value.useBeacon&&(f.capabilities.isBeaconAvailable.value?s="BeaconQueue":(s=e,t.warn(Ym(qe)))),Fe(()=>{f.dataPlaneEvents.eventsQueuePluginName.value=s})}},Wb=(t,e,s,i,n)=>{let r=new URLSearchParams({p:wu,v:Ci,build:$i,writeKey:e,lockIntegrationsVersion:s.toString(),lockPluginsVersion:i.toString()}),o=Mu,a=r,l="/sourceConfig/",c="";if(Hs(t)){let u=new URL(t);Gs(u.pathname).endsWith("/sourceConfig")||(u.pathname=`${Gs(u.pathname)}/sourceConfig/`),u.pathname=xb(u.pathname),r.forEach((h,d)=>{u.searchParams.get(d)===null&&u.searchParams.set(d,h)}),o=u.origin,l=u.pathname,a=u.searchParams,c=u.hash}else n.warn(ry(qe,t));return`${o}${l}?${a}${c}`},Kb=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:x0(e.destinationDefinition.displayName,e.id),isCustomIntegration:e.destinationDefinition.displayName===Sy})),id=(t,e,s,i,n,r,o)=>{let a;if(r){if(!Hs(r))return o.error(ym(qe,t,r)),null;a=Gs(r)}else if(a=s,f.context.app.value.installType==="cdn"){let l=Lb();l&&(a=l.split("/").slice(0,-1).concat(e).join("/"))}return n&&(a=a.replace(new RegExp(`/${na}/${$i}/${e}$`),`/${i}/${$i}/${e}`)),a},Yb=(t,e,s,i)=>id("integrations",Xn,Du,t,e,s,i),Qb=(t,e,s,i)=>id("plugins",xu,Nu,t,e,s,i),jo=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(){Mt(()=>{this.logger.setMinLogLevel(f.lifecycle.logLevel.value)})}init(){let{logLevel:e,configUrl:s,lockIntegrationsVersion:i,lockPluginsVersion:n,destSDKBaseURL:r,pluginsSDKBaseURL:o,integrations:a}=f.loadOptions.value,l=Yb(Ci,i,r,this.logger);if(st(l))return;let c;c=Qb(Ci,n,o,this.logger),c!==null&&(e&&(f.lifecycle.logLevel.value=e),this.attachEffects(),f.lifecycle.activeDataplaneUrl.value=Gs(f.lifecycle.dataPlaneUrl.value),Gb(this.logger),Hb(this.logger),qb(this.logger),Fe(()=>{f.lifecycle.integrationsCDNPath.value=l,f.lifecycle.pluginsCDNPath.value=c,f.lifecycle.sourceConfigUrl.value=Wb(s,f.lifecycle.writeKey.value,i,n,this.logger),f.metrics.metricsServiceUrl.value=`${f.lifecycle.activeDataplaneUrl.value}/${wy}`,f.nativeDestinations.loadOnlyIntegrations.value=a}),this.getConfig())}onError(e,s,i){this.errorHandler.onError({error:e,context:qe,customMessage:s,groupingHash:i})}processConfig(e,s){if(!ce(e)){ce(s)?this.onError(s.error,Hc):this.onError(new Error(Hc));return}let i;try{ge(e)?i=JSON.parse(e):i=e}catch(r){this.onError(r,jc);return}if(!wb(i)){this.onError(new Error(jc));return}if(i.source.enabled===!1){this.logger.error(gm);return}Ub(i);let n=i.source.destinations.length>0?Kb(i.source.destinations):[];Fe(()=>{f.source.value={config:i.source.config,name:i.source.name,id:i.source.id,workspaceId:i.source.workspaceId},f.nativeDestinations.configuredDestinations.value=n,f.plugins.pluginsToLoadFromConfig.value=f.loadOptions.value.plugins??[],zb(i),f.lifecycle.status.value="configured"})}getConfig(){let e=f.loadOptions.value.getSourceConfig;if(e){if(!F(e)){this.logger.error(mm(qe));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:f.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}},Jb=()=>{let t=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return t?.[1]?t[1]:"NA"},nd=(t=()=>document)=>t()?.referrer||"$direct",Xb=(t=()=>document)=>{let s=t().getElementsByTagName("link"),i="";for(let n=0;s[n];n+=1){let r=s[n];if(r.getAttribute("rel")==="canonical"&&!i){i=r.getAttribute("href")??"";break}}return i},Zb=(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 n=s.match(/(chrome)\/([\w.]+)/i);n&&(s=`${s} Brave/${n[2]}`)}return s},eE=(t=()=>globalThis.navigator)=>{let e=t();return Ve(e)?null:e.language??e.browserLanguage},rd=(t=()=>globalThis.location,e=()=>document)=>{let s=t(),i=Xb(e),n=s.pathname,{href:r}=s,o=r,{search:a}=s;if(i)try{let h=new URL(i);h.search===""?o=i+a:o=i,n=h.pathname}catch{}let l=$b(o),{title:c}=e(),u=nd(e);return{path:n,referrer:u,referring_domain:td(u),search:a,title:c,url:l,tab_url:r}},tE=(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()})},sE=()=>{let t=globalThis.document.createElement("div");return t.setAttribute("data-a-b","c"),t.dataset?t.dataset.aB==="c":!1},Go={URL:()=>!F(globalThis.URL)||!F(globalThis.URLSearchParams),Promise:()=>!F(globalThis.Promise),"Number.isNaN":()=>!F(globalThis.Number.isNaN),"Number.isInteger":()=>!F(globalThis.Number.isInteger),"Array.from":()=>!F(globalThis.Array.from),"Array.prototype.find":()=>!F(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!F(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!F(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!F(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!F(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!F(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!F(globalThis.String.fromCodePoint),"Object.entries":()=>!F(globalThis.Object.entries),"Object.values":()=>!F(globalThis.Object.values),"Object.assign":()=>!F(globalThis.Object.assign),"Object.fromEntries":()=>!F(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!sE(),TextEncoder:()=>!F(globalThis.TextEncoder)||!F(globalThis.TextDecoder),requestAnimationFrame:()=>!F(globalThis.requestAnimationFrame)||!F(globalThis.cancelAnimationFrame),CustomEvent:()=>!F(globalThis.CustomEvent),"navigator.sendBeacon":()=>!F(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!F(globalThis.Uint8Array),Set:()=>!F(globalThis.Set),atob:()=>!F(globalThis.atob)},iE=()=>{let t=Object.keys(Go),e=!1;for(let s=0;s<t.length;s++){let i=Go[t[s]];if(F(i)&&i()){e=!0;break}}return e},nE="https://polyfill-fastly.io/v3/polyfill.min.js",rE=`${nE}?version=3.111.0&features=${Object.keys(Go).join("%2C")}`,oE=10*1e3,nu="rudderstackPolyfill",aE=t=>{f.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(f.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,n)=>{f.capabilities.isAdBlockerDetectionInProgress.value=!1,f.capabilities.isAdBlocked.value=n?.error!==void 0||n?.xhr?.responseURL!==s}})}catch(e){throw f.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},lE=()=>!at(globalThis.crypto)&&F(globalThis.crypto.getRandomValues),ru=()=>!at(globalThis.navigator.userAgentData),cE=()=>!at(globalThis.navigator.sendBeacon)&&F(globalThis.navigator.sendBeacon),ou=()=>{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},Ho=class{constructor(e,s,i){this.httpClient=e,this.errorHandler=s,this.logger=i,this.externalSrcLoader=new Vn(this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){Fe(()=>{f.capabilities.storage.isCookieStorageAvailable.value=Vs(ze,pt(ze),this.logger),f.capabilities.storage.isLocalStorageAvailable.value=Vs(ot,void 0,this.logger),f.capabilities.storage.isSessionStorageAvailable.value=Vs(ht,void 0,this.logger),f.capabilities.isBeaconAvailable.value=cE(),f.capabilities.isUaCHAvailable.value=ru(),f.capabilities.isCryptoAvailable.value=lE(),f.capabilities.isOnline.value=globalThis.navigator.onLine,f.context.userAgent.value=Zb(),f.context.locale.value=eE(),f.context.screen.value=ou(),f.context.timezone.value=Jb(),ru()&&tE(e=>{f.context["ua-ch"].value=e},f.loadOptions.value.uaChTrackLevel)}),Mt(()=>{f.loadOptions.value.sendAdblockPage===!0&&f.lifecycle.sourceConfigUrl.value!==void 0&&aE(this.httpClient)})}prepareBrowserCapabilities(){f.capabilities.isLegacyDOM.value=iE();let e=f.loadOptions.value.polyfillURL,s=rE;if(js(e)&&(Hs(e)?s=e:this.logger.warn(hy(ko,e))),f.loadOptions.value.polyfillIfRequired&&f.capabilities.isLegacyDOM.value&&Hs(s)){let n=s!==f.loadOptions.value.polyfillURL;if(n){let r=`RS_polyfillCallback_${f.lifecycle.writeKey.value}`,o=()=>{this.onReady(),delete globalThis[r]};globalThis[r]=o,s=`${s}&callback=${r}`}this.externalSrcLoader.loadJSFile({url:s,id:nu,async:!0,timeout:oE,callback:r=>{r?n||this.onReady():this.onError(new Error(oy(nu,s)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{f.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{f.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",Q_(()=>{f.context.screen.value=ou()},this))}onReady(){this.detectBrowserCapabilities(),f.lifecycle.status.value="browserCapabilitiesReady"}onError(e,s){this.errorHandler.onError({error:e,context:ko,groupingHash:s})}},uE="web",dE=["integrations","anonymousId","originalTimestamp"],hE=["library","consentManagement","userAgent","ua-ch","screen"],Eo=["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"],Fn="CustomContext",fE=new Set(["__proto__","constructor","prototype"]),gE=Function.prototype.toString.call(Object),pE=t=>{if(!fe(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)===gE},la=(t,e=new Set)=>{if(!fe(t)&&!Array.isArray(t))return!1;let s=t;return e.has(s)?!1:(e.add(s),Object.keys(s).some(i=>fE.has(i)||la(s[i],e)))},od=(t,e)=>{let s={};return Object.keys(t).forEach(i=>{if(hE.includes(i)){e.warn(Wm(Fn,i));return}Object.defineProperty(s,i,{configurable:!0,enumerable:!0,value:t[i]===t?s:t[i],writable:!0})}),s},ad=(t,e)=>{try{if(!pE(t)){e.warn(Pn(Fn));return}let s=od(t,e);if(la(s)){e.warn(Pn(Fn));return}let i=oe(s,e);return te(i)}catch{e.warn(Pn(Fn));return}},zo=class{constructor(e,s){this.state=e,this.logger=s}set(e){let s=ad(e,this.logger);if(!s)return;let i=$e(te(this.state.value),s);this.state.value=Ri(i)}get(){return te(this.state.value)}clear(){this.state.value={}}},ld=t=>typeof t=="number"&&!Number.isNaN(t),vE=(t,e)=>e.toString().length>=t,qn=t=>ld(t)&&t>=0&&Number.isInteger(t),au=10,cd=t=>{let{cutOff:e}=t,s=Date.now();return!!(e?.enabled&&e.expiresAt&&s>e.expiresAt)},lu=t=>!t.expiresAt||Date.now()>t.expiresAt||cd(t),_E=()=>Date.now(),mE=(t,e)=>!t||!qn(t)||!vE(au,t)?(e.warn(ty(fs,t,au)),!1):!0,yE=t=>{if(t?.enabled)return t.expiresAt??(qn(t.duration)?Date.now()+t.duration:void 0)},bE=t=>{let{timeout:e,cutOff:s}=t,i=Date.now();return{id:i,expiresAt:i+e,timeout:e,autoTrack:!0,...s&&{cutOff:s}}},EE=(t,e)=>({id:mE(t,e)?t:_E(),sessionStart:void 0,manualTrack:!0}),ki=t=>t===ze||t===ot||t===ht||t===St,qo=()=>Kn(),wE=t=>Object.prototype.hasOwnProperty.call(xn.entries,t),SE=t=>{if(Cc(t)){let{entries:e,...s}=xn;return{...s,entries:{...e,anonymousId:t}}}if(fe(t)&&fe(t.entries)){let e=t.entries,s=Object.keys(e).reduce((i,n)=>{if(wE(n)){let r=e[n];Cc(r)&&(i[n]=r)}return i},{});return $e(xn,{entries:s})}return{...xn}},kE=t=>{let e=rd(),s={};return Object.keys(e).forEach(i=>{s[i]=t?.[i]||e[i]}),s.initial_referrer=t?.initial_referrer||f.session.initialReferrer.value,s.initial_referring_domain=t?.initial_referring_domain||f.session.initialReferringDomain.value,s},AE=(t,e)=>{let s=e?.page||{},i=t,n=rd();return Object.keys(n).forEach(r=>{Ve(i[r])&&(i[r]=s[r]||n[r])}),Ve(i.initial_referrer)&&(i.initial_referrer=s.initial_referrer||f.session.initialReferrer.value),Ve(i.initial_referring_domain)&&(i.initial_referring_domain=s.initial_referring_domain||f.session.initialReferringDomain.value),i},wo=(t,e,s)=>{fe(t)&&Object.keys(t).forEach(i=>{(Eo.includes(i)||Eo.includes(i.toLowerCase()))&&s.warn(qm(Ao,i,e,Eo))})},TE=(t,e)=>{let{properties:s,traits:i,context:n}=t,{traits:r}=n;wo(s,"properties",e),wo(i,"traits",e),wo(r,"context.traits",e)},IE=(t,e)=>{e.anonymousId&&ge(e.anonymousId)&&(t.anonymousId=e.anonymousId),Nt(e.integrations)&&(t.integrations=e.integrations),e.originalTimestamp&&ge(e.originalTimestamp)&&(t.originalTimestamp=e.originalTimestamp)},RE=(t,e,s)=>{let i=t,n=r=>{let o=od(r,s);if(la(o)){s.warn(Pn(Ao));return}i=$e(i,o)};return Object.keys(e).forEach(r=>{dE.includes(r)||(r!=="context"?n({[r]:e[r]}):!Ve(e[r])&&fe(e[r])?n(e[r]):s.warn(Km(Ao)))}),i},CE=(t,e,s)=>{fe(e)&&(IE(t,e),t.context=RE(t.context,e,s))},OE=t=>{let e;return f.loadOptions.value.useGlobalIntegrationsConfigInEvents?e=f.consents.postConsent.value.integrations??f.nativeDestinations.loadOnlyIntegrations.value:t?e=t:e=$u,te(e)},Ei=(t,e,s,i,n={})=>{let r={channel:uE,context:{traits:te(f.session.userTraits.value),sessionId:f.session.sessionInfo.value.id||void 0,sessionStart:f.session.sessionInfo.value.sessionStart||void 0,...f.consents.enabled.value&&{consentManagement:{deniedConsentIds:te(f.consents.data.value.deniedConsentIds),allowedConsentIds:te(f.consents.data.value.allowedConsentIds),provider:f.consents.provider.value,resolutionStrategy:f.consents.resolutionStrategy.value}},"ua-ch":f.context["ua-ch"].value,app:f.context.app.value,library:f.context.library.value,userAgent:f.context.userAgent.value,os:f.context.os.value,locale:f.context.locale.value,screen:f.context.screen.value,campaign:Pb(globalThis.location.href),page:kE(s),timezone:f.context.timezone.value,...f.autoTrack.enabled.value&&{autoTrack:{...f.autoTrack.pageLifecycle.enabled.value&&{page:{pageViewId:f.autoTrack.pageLifecycle.pageViewId.value}}}}},originalTimestamp:I_(),messageId:Kn(),userId:t.userId||f.session.userId.value};ki(f.storage.entries.value.anonymousId?.type)?r.anonymousId=f.session.anonymousId.value:r.anonymousId=qo(),f.storage.trulyAnonymousTracking.value&&(r.context.trulyAnonymousTracking=!0),t.type==="identify"&&(r.context.traits=f.storage.entries.value.userTraits?.type!==Zt?te(f.session.userTraits.value):t.context.traits),t.type==="group"&&((t.groupId||f.session.groupId.value)&&(r.groupId=t.groupId||f.session.groupId.value),(t.traits||f.session.groupTraits.value)&&(r.traits=f.storage.entries.value.groupTraits?.type!==Zt?te(f.session.groupTraits.value):t.traits));let o=$e(t,r),a=$e(o,{context:n});return a.event===void 0&&(a.event=null),a.properties===void 0&&(a.properties=null),CE(a,e,i),TE(a,i),a.integrations=OE(a.integrations),a},Wo=class{constructor(e){this.logger=e}generatePageEvent(e,s,i,n,r={}){let o=i??{};return o=AE(o,n),Ei({properties:o,name:s,category:e,type:"page"},n,o,this.logger,r)}generateTrackEvent(e,s,i,n={}){return Ei({properties:s,event:e,type:"track"},i,void 0,this.logger,n)}generateIdentifyEvent(e,s,i,n={}){return Ei({userId:e,type:"identify",context:{traits:s}},i,void 0,this.logger,n)}generateAliasEvent(e,s,i,n={}){let o=Ei({previousId:s,type:"alias"},i,void 0,this.logger,n);return o.userId=e??o.userId,o}generateGroupEvent(e,s,i,n={}){let r={type:"group"};return e&&(r.groupId=e),s&&(r.traits=s),Ei(r,i,void 0,this.logger,n)}create(e,s={}){let i,{type:n,name:r,properties:o,options:a,category:l,userId:c,traits:u,to:h,from:d,groupId:g}=e;switch(n){case"page":i=this.generatePageEvent(l,r,o,a,s);break;case"track":i=this.generateTrackEvent(r,o,a,s);break;case"identify":i=this.generateIdentifyEvent(c,u,a,s);break;case"alias":i=this.generateAliasEvent(h,d,a,s);break;default:i=this.generateGroupEvent(g,u,a,s);break}return i}},Ko=class{constructor(e,s,i,n){this.eventRepository=e,this.userSessionManager=s,this.errorHandler=i,this.logger=n,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,n,r){this.storeManager=s,this.pluginsManager=e,this.logger=r,this.errorHandler=n,this.httpClient=i,this.onError=this.onError.bind(this),this.serverSideCookiesDebounceTimer=0,this.serverSideCookiesPending={},this.serverSideCookiesRequestInProgress={},this.lastSyncedValues={}}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}=f.loadOptions.value,i;js(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()??ue.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=ue.sessionInfo:s.cutOff?.enabled===!0&&(e.cutOff={enabled:!0,duration:s.cutOff.duration,expiresAt:i.cutOff?.expiresAt})}else e=ue.sessionInfo;f.session.sessionInfo.value=e,f.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(f.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),s=this.getInitialReferringDomain();if(e&&s)this.setInitialReferrer(e),this.setInitialReferringDomain(s);else{let i=e||nd();this.setInitialReferrer(i),this.setInitialReferringDomain(td(i))}}isPersistenceEnabledForStorageEntry(e){return ki(f.storage.entries.value[e]?.type)}migrateDataFromPreviousStorage(){let e=f.storage.entries.value,s=[ze,ot,ht];Object.keys(e).forEach(i=>{let n=i,r=e[n]?.type,o=this.storeManager?.getStore(ps[r]);o&&s.forEach(a=>{let l=this.storeManager?.getStore(ps[a]);if(l&&a!==r){let c=l.get(Bs[n]);a_(c)&&o.set(Bs[n],c),l.remove(Bs[n])}})})}migrateStorageIfNeeded(e,s){if(!f.storage.migrate.value)return;let i=e??[];i.length===0&&[Ku,Yu,Qu].forEach(o=>{let a=this.storeManager?.getStore(o);a&&i.push(a)}),(s??Object.keys(Bs)).forEach(r=>{let o=Bs[r];i.forEach(a=>{let l=this.pluginsManager?.invokeSingle("storage.migrate",o,a.engine,this.errorHandler,this.logger);at(l)||a.set(o,l)})})}getConfiguredSessionTrackingInfo(){let e=f.loadOptions.value.sessions.autoTrack!==!1;if(!e)return{autoTrack:e};let s,i=f.loadOptions.value.sessions?.timeout;qn(i)?s=i:(this.logger.warn(Qm(fs,i,To)),s=To),s===0&&(this.logger.warn(Zm(fs)),e=!1),s>0&&s<Uc&&this.logger.warn(ey(fs,s,Uc));let n=this.getCutOffInfo(s);return{timeout:s,autoTrack:e,cutOff:n}}getCutOffInfo(e){let s=f.loadOptions.value.sessions.cutOff,i,n=!1;return s.enabled===!0&&(i=s.duration,n=!0,qn(i)?i<e&&(this.logger.warn(Xm(fs,i,e)),n=!1):(this.logger.warn(Jm(fs,i,Lc)),i=Lc)),{enabled:n,duration:i}}onError(e,s,i){this.errorHandler.onError({error:e,context:fs,customMessage:s,groupingHash:i})}getEncryptedCookieData(e,s){let i=[];return e.forEach(n=>{let r=s?.encrypt(rt(n.value,!1,[],this.logger));js(r)&&i.push({name:n.name,value:r})}),i}makeRequestToSetCookie(e,s){this.httpClient?.getAsyncData({url:f.serverCookies.dataServiceUrl.value,options:{method:"POST",data:rt({reqType:"setCookies",workspaceId:f.source.value?.workspaceId,data:{options:{maxAge:f.storage.cookie.value?.maxage,path:f.storage.cookie.value?.path,domain:f.storage.cookie.value?.domain,sameSite:f.storage.cookie.value?.samesite,secure:f.storage.cookie.value?.secure,expires:f.storage.cookie.value?.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:s})}setServerSideCookies(e,s,i){let n=Object.keys(e),r=()=>n.map(c=>({name:e[c].name,value:f.session[c].value})),o={};n.forEach(c=>{o[e[c].name]=i?.get(e[c].name)});let a=()=>{n.forEach(c=>{this.serverSideCookiesRequestInProgress[c]=!1})},l=()=>{r().forEach(c=>{s&&s(c.name,c.value)})};try{let c={};n.forEach(h=>{c[e[h].name]=f.session[h].value});let u=this.getEncryptedCookieData(r(),i);u.length>0?this.makeRequestToSetCookie(u,(h,d)=>{if(a(),d?.xhr?.status===200){let g=new Set(u.map(m=>m.name)),p=[];r().forEach(m=>{let v=o[m.name],b=i?.get(m.name);rt(c[m.name],!1,[])!==rt(b,!1,[])&&(g.has(m.name)&&rt(v,!1,[])===rt(b,!1,[])&&p.push(m.name),st(v)&&st(b)&&this.logger.error(Lm(m.name)),s&&s(m.name,m.value))}),u.length>1&&p.length>0&&!f.serverCookies.isCollapsedBatchErrorLogged.value&&(f.serverCookies.isCollapsedBatchErrorLogged.value=!0,this.logger.error(Um(p,u.length)))}else this.logger.error(Fm(d?.xhr?.status)),l()}):(l(),a())}catch(c){this.onError(c,zc,zc),l(),a()}}flushServerSideCookies(){this.serverSideCookiesDebounceTimer=0;let e=Object.entries(this.serverSideCookiesPending).reduce((i,[n,r])=>(i[n]={name:r},i),{});if(this.serverSideCookiesPending={},Object.keys(e).length===0)return;let s=this.storeManager.getStore(ps[ze]);this.setServerSideCookies(e,(i,n)=>{s?.set(i,n)},s)}syncValueToStorage(e){let s=f.storage.entries.value,i=s[e]?.type;if(ki(i)){let n=this.storeManager.getStore(ps[i]),r=s[e]?.key,o=f.session[e].value;o&&(ge(o)||Nt(o))?f.serverCookies.isEnabledServerSideCookies.value&&i===ze?(this.serverSideCookiesRequestInProgress[e]=!0,this.serverSideCookiesPending[e]=r,this.serverSideCookiesDebounceTimer&&globalThis.clearTimeout(this.serverSideCookiesDebounceTimer),this.serverSideCookiesDebounceTimer=globalThis.setTimeout(()=>{this.flushServerSideCookies()},Ty)):n?.set(r,o):n?.remove(r)}}registerEffects(){Ju.forEach(e=>{Mt(()=>{let s=f.session[e].value;this.syncValueToStorage(e),this.lastSyncedValues[e]=s})})}setAnonymousId(e,s){let i=e;(!ge(e)||!i)&&(i=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")?(!i&&s&&(i=this.pluginsManager?.invokeSingle("userSession.anonymousIdGoogleLinker",s)),i=i||qo()):i=ue.anonymousId,f.session.anonymousId.value=i}getAnonymousId(e){let s=f.storage.entries.value.anonymousId?.type;if(ki(s)){let i=f.session.anonymousId.value;(!i||i===ue.anonymousId)&&(i=this.getEntryValue("anonymousId")),!i&&e&&(i=this.pluginsManager?.invokeSingle("storage.getAnonymousId",pt,e)),f.session.anonymousId.value=i||qo()}return f.session.anonymousId.value}getEntryValue(e){let s=f.storage.entries.value,i=s[e]?.type;if(ki(i)){let n=this.storeManager?.getStore(ps[i]);this.migrateStorageIfNeeded([n],[e]);let r=s[e]?.key;return n?.get(r)??null}return null}getExternalAnonymousIdByCookieName(e){let s=pt(ze);return s?.isEnabled?s.getItem(e)??null:null}getUserSessionValue(e){let s=f.session[e].peek();return this.isPersistenceEnabledForStorageEntry(e)&&e in this.lastSyncedValues&&s!==this.lastSyncedValues[e]||this.serverSideCookiesRequestInProgress[e]?s: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()??ue.sessionInfo;return e.autoTrack&&!lu(e)||e.manualTrack?e.id??null:null}refreshSession(){let e=this.getSessionInfo()??ue.sessionInfo;(e.autoTrack||e.manualTrack)&&(e.autoTrack&&(this.startOrRenewAutoTracking(e),e=f.session.sessionInfo.value),e.sessionStart===void 0?e={...e,sessionStart:!0}:e.sessionStart&&(e={...e,sessionStart:!1})),f.session.sessionInfo.value=e,f.lifecycle.status.value!=="readyExecuted"&&this.syncValueToStorage("sessionInfo")}resetAndStartNewSession(){let e=f.session,{manualTrack:s,autoTrack:i,timeout:n,cutOff:r}=e.sessionInfo.value;if(i){let o={...ue.sessionInfo,timeout:n};r&&(o.cutOff={enabled:r.enabled,duration:r.duration}),e.sessionInfo.value=o,this.startOrRenewAutoTracking(e.sessionInfo.value)}else s&&this.startManualTrackingInternal()}reset(e){let{session:s}=f,i=SE(e);Fe(()=>{Object.keys(ue).forEach(n=>{let r=n;if(i.entries[r]===!0)switch(n){case"anonymousId":this.setAnonymousId();break;case"sessionInfo":this.resetAndStartNewSession();break;default:s[r].value=ue[r];break}})})}setUserId(e){f.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:ue.userId}setUserTraits(e){f.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&fe(e)?$e(f.session.userTraits.value??ue.userTraits,e):ue.userTraits}setGroupId(e){f.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:ue.groupId}setGroupTraits(e){f.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&fe(e)?$e(f.session.groupTraits.value??ue.groupTraits,e):ue.groupTraits}setInitialReferrer(e){f.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:ue.initialReferrer}setInitialReferringDomain(e){f.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:ue.initialReferringDomain}startOrRenewAutoTracking(e){let s=e;if(lu(e))s=bE(e);else{let i=Date.now(),n=e.timeout;s.expiresAt=i+n}if(cd(s)&&(s.cutOff.expiresAt=void 0),s.cutOff){let i=yE(s.cutOff);s.cutOff.expiresAt=i}f.session.sessionInfo.value=s}start(e){f.session.sessionInfo.value=EE(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){f.session.sessionInfo.value=ue.sessionInfo}setAuthToken(e){f.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:ue.authToken}},PE=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],$E=PE,xE=(t,e)=>{let s=te(e);return ge(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=Ot(s.integrations),Array.isArray(s.plugins)||(s.plugins=$E),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),ge(s.dataServiceEndpoint)||(s.dataServiceEndpoint=void 0),s.sendAdblockPageOptions=Ot(s.sendAdblockPageOptions),s.loadIntegration=wt(s.loadIntegration,t.loadIntegration),Nt(s.storage)?(s.storage.migrate=wt(s.storage.migrate,t.storage?.migrate),s.storage.cookie=Ot(s.storage.cookie),s.storage.encryption=Ot(s.storage.encryption),s.storage=Ri(s.storage)):s.storage=void 0,s.destinationsQueueOptions=Ot(s.destinationsQueueOptions),s.queueOptions=Ot(s.queueOptions),s.lockIntegrationsVersion=wt(s.lockIntegrationsVersion,t.lockIntegrationsVersion),s.lockPluginsVersion=wt(s.lockPluginsVersion,t.lockPluginsVersion),ld(s.dataPlaneEventsBufferTimeout)||(s.dataPlaneEventsBufferTimeout=void 0),s.beaconQueueOptions=Ot(s.beaconQueueOptions),s.preConsent=Ot(s.preConsent),s.sourceConfigurationOverride=Ot(s.sourceConfigurationOverride),$e(t,Ri(s))},cu="dataplaneEventsQueue",uu="destinationsEventsQueue",DE="transformEvent",NE=(t,e)=>Object.keys(t).filter(s=>t[s]!==!0||!e[s]).reduce((s,i)=>{let n=te(s);return n[i]=t[i],n},{}),ME=(t,e)=>{let s=te(t),i=e.nativeDestinations.integrationsConfig.value,n=NE(t.integrations,i);return s.integrations=$e(i,n),s},FE=t=>t.consents.preConsent.value.enabled&&t.consents.preConsent.value.events?.delivery==="buffer",Ln=(t,e,s,i)=>{if(ce(t))if(F(t))try{t(...e)}catch(n){i.error(ny(s),n)}else i.error(Pu(s))},Qo=class{constructor(e,s,i,n,r){this.pluginsManager=e,this.errorHandler=n,this.httpClient=i,this.logger=r,this.storeManager=s}init(){this.dataplaneEventsQueue=this.pluginsManager.invokeSingle(`${cu}.init`,f,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle(`${DE}.init`,f,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle(`${uu}.init`,f,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),Mt(()=>{f.nativeDestinations.clientDestinationsReady.value===!0&&(this.destinationsEventsQueue?.start(),this.dmtEventsQueue?.start())});let e=FE(f),s;Mt(()=>{let i=f.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&f.nativeDestinations.clientDestinationsReady.value===!1;(f.nativeDestinations.activeDestinations.value.some(r=>$0(r))===!1||i===!1)&&!e&&this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(globalThis.clearTimeout(s),this.dataplaneEventsQueue?.start())}),f.loadOptions.value.bufferDataPlaneEventsUntilReady===!0&&(s=globalThis.setTimeout(()=>{this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&this.dataplaneEventsQueue?.start()},f.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){this.dataplaneEventsQueue?.scheduleTimeoutActive!==!0&&(f.consents.postConsent.value.discardPreConsentEvents&&(this.dataplaneEventsQueue?.clear(),this.destinationsEventsQueue?.clear()),this.dataplaneEventsQueue?.start())}enqueue(e,s){let i=ME(e,f);this.pluginsManager.invokeSingle(`${cu}.enqueue`,f,this.dataplaneEventsQueue,i,this.errorHandler,this.logger);let n=te(e);this.pluginsManager.invokeSingle(`${uu}.enqueue`,f,this.destinationsEventsQueue,n,this.errorHandler,this.logger);let r=`${e.type.charAt(0).toUpperCase()}${e.type.slice(1)}${Wn}`;Ln(s,[i],r,this.logger)}},du=t=>{let e=new CustomEvent(t,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(e)},LE=t=>ge(t)&&t.trim().length>0,UE=t=>Hs(t),Jo=class{constructor(){this.preloadBuffer=new Ro,this.initialized=!1,this.errorHandler=Hu,this.logger=Ft,this.customContextStore=new zo(f.customContext,this.logger),this.externalSrcLoader=new Vn(this.logger),this.httpClient=Vu,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new Ho(this.httpClient,this.errorHandler,this.logger)}load(e,s,i={}){if(f.lifecycle.status.value)return;if(!LE(e)){this.logger.error(Cm(An,e));return}if(!UE(s)){this.logger.error(Om(An,s));return}let{context:n,...r}=i,o=oe(r);n!==void 0&&this.customContextStore.set(n),Fe(()=>{f.lifecycle.writeKey.value=te(e),f.lifecycle.dataPlaneUrl.value=te(s),f.loadOptions.value=xE(f.loadOptions.value,o),f.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(f.loadOptions.value.logLevel??Ou),Oi("state",f,e),this.startLifecycle()}setCustomContext(e){if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,["setCustomContext",e]];return}this.customContextStore.set(e)}getCustomContext(){return this.customContextStore.get()}clearCustomContext(){if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,["clearCustomContext"]];return}this.customContextStore.clear()}startLifecycle(){Mt(()=>{try{switch(f.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:An,customMessage:s,groupingHash:s})}})}onBrowserCapabilitiesReady(){em(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),f.consents.preConsent.value.enabled===!0?f.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&&tm([...e],this)}}prepareInternalServices(){this.pluginsManager=new Do(O0,this.errorHandler,this.logger),this.storeManager=new Vo(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new jo(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new Yo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new Qo(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new Ko(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){f.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(f.lifecycle.writeKey.value),this.configManager?.init()}onPluginsReady(){this.storeManager?.init(),this.userSessionManager?.init(),f.consents.enabled.value&&!f.consents.initialized.value&&(this.pluginsManager?.invokeSingle("consentManager.init",f,this.logger),f.consents.preConsent.value.enabled===!1&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",f,this.storeManager,this.logger)),this.eventManager?.init(),f.lifecycle.status.value="initialized"}onConfigured(){this.pluginsManager?.init()}onInitialized(){this.processDataInPreloadBuffer(),Fe(()=>{f.lifecycle.loaded.value=!0,f.lifecycle.status.value="loaded"}),this.initialized=!0;let e=f.loadOptions.value.onLoaded;Ln(e,[globalThis.rudderanalytics],v_,this.logger),du("RSA_Initialised")}onReady(){f.lifecycle.status.value="readyExecuted",f.eventBuffer.readyCallbacksArray.value.forEach(e=>{Ln(e,[],vo,this.logger)}),du("RSA_Ready")}processBufferedEvents(){let e=f.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let s=e.shift();f.eventBuffer.toBeProcessedArray.value=e,s&&this.processBufferedEvent(s),e=f.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():ad(e,this.logger)??{}}loadDestinations(){if(f.lifecycle.status.value==="destinationsLoading"||f.nativeDestinations.clientDestinationsReady.value===!0)return;this.pluginsManager?.invokeSingle("nativeDestinations.setActiveDestinations",f,this.pluginsManager,this.errorHandler,this.logger);let e=f.nativeDestinations.activeDestinations.value.length;if(e===0){Fe(()=>{f.nativeDestinations.clientDestinationsReady.value=!0,f.lifecycle.status.value="destinationsReady"});return}f.lifecycle.status.value="destinationsLoading",this.pluginsManager?.invokeSingle("nativeDestinations.load",f,this.externalSrcLoader,this.errorHandler,this.logger),Mt(()=>{f.nativeDestinations.initializedDestinations.value.length+f.nativeDestinations.failedDestinations.value.length===e&&Fe(()=>{f.lifecycle.status.value="destinationsReady",f.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){f.lifecycle.status.value!=="ready"&&Fe(()=>{f.lifecycle.status.value="ready"})}ready(e,s=!1){let i="ready";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[i,e]];return}if(this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),!F(e)){this.logger.error(Pu(vo));return}f.lifecycle.status.value==="readyExecuted"?Ln(e,[],vo,this.logger):f.eventBuffer.readyCallbacksArray.value=[...f.eventBuffer.readyCallbacksArray.value,e]}page(e,s=!1,i){let n="page";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event`),f.metrics.triggered.value+=1,this.eventManager?.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback},r),f.capabilities.isAdBlocked.value===!0&&e.category!==Nc&&this.page(Bn(Nc,B_,{path:V_},f.loadOptions.value.sendAdblockPageOptions),s,r)}track(e,s=!1,i){let n="track";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event - ${e.name}`),f.metrics.triggered.value+=1,this.eventManager?.addEvent({type:n,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback},r)}identify(e,s=!1,i){let n="identify";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event`),f.metrics.triggered.value+=1,e.userId&&f.session.userId.value&&e.userId!==f.session.userId.value&&this.reset(),st(e.userId)||this.userSessionManager?.setUserId(e.userId),this.userSessionManager?.setUserTraits(e.traits),this.eventManager?.addEvent({type:n,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback},r)}alias(e,s=!1,i){let n="alias";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event`),f.metrics.triggered.value+=1;let o=e.from??(this.getUserId()||this.userSessionManager?.getAnonymousId());this.eventManager?.addEvent({type:n,to:e.to,from:o,options:e.options,callback:e.callback},r)}group(e,s=!1,i){let n="group";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e]];return}let r=this.getInvocationContext(i);this.errorHandler.leaveBreadcrumb(`New ${n} event`),f.metrics.triggered.value+=1,st(e.groupId)||this.userSessionManager?.setGroupId(e.groupId),this.userSessionManager?.setGroupTraits(e.traits),this.eventManager?.addEvent({type:n,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback},r)}reset(e,s=!1){let i="reset";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.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 n="setAnonymousId";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e,s]];return}this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),this.userSessionManager?.setAnonymousId(e,s)}getUserId(){return f.session.userId.value}getUserTraits(){return f.session.userTraits.value}getGroupId(){return f.session.groupId.value}getGroupTraits(){return f.session.groupTraits.value}startSession(e,s=!1){let i="startSession";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb(`New ${i} invocation`),this.userSessionManager?.start(e)}endSession(e=!1){let s="endSession";if(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.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(!f.lifecycle.loaded.value){f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[i,e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),Fe(()=>{f.consents.preConsent.value={...f.consents.preConsent.value,enabled:!1},f.consents.postConsent.value=Mb(e,this.logger);let{initialized:n,consentsData:r}=sd(f.consents.postConsent.value.consentManagement,this.logger);f.consents.initialized.value=n,f.consents.data.value=r}),f.consents.enabled.value&&!f.consents.initialized.value&&this.pluginsManager?.invokeSingle("consentManager.updateConsentsInfo",f,this.storeManager,this.logger),this.storeManager?.initializeStorageState(),this.userSessionManager?.syncStorageDataToState(),this.eventManager?.resume(),this.loadDestinations(),this.sendTrackingEvents(s)}sendTrackingEvents(e){if(f.consents.postConsent.value.trackConsent){let s=ta(j_);e?f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,["track",s,this.customContextStore.get()]]:this.track(s)}if(f.consents.postConsent.value.sendPageEvent){let s=Bn();e?f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,["page",s,this.customContextStore.get()]]:this.page(s)}}setAuthToken(e){this.userSessionManager?.setAuthToken(e)}addCustomIntegration(e,s,i=!1){let n="addCustomIntegration";if(i)this.errorHandler.leaveBreadcrumb(`New ${n} invocation`),this.pluginsManager?.invokeSingle("nativeDestinations.addCustomIntegration",e,s,f,this.logger);else{if(f.lifecycle.loaded.value){this.logger.error(_y(An,e));return}f.eventBuffer.toBeProcessedArray.value=[...f.eventBuffer.toBeProcessedArray.value,[n,e,s]]}}},vs=class vs{constructor(){Se(this,"analyticsInstances",{});Se(this,"defaultAnalyticsKey","");Se(this,"logger",Ft);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,f.autoTrack.pageLifecycle.pageViewId.value=Kn(),f.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){be(e)}}createSafeAnalyticsInstance(){f.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(){Hu.init(),aa.configure(),ra.configure(),oa.configure(),zn.configure()}setDefaultInstanceKey(e){ge(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let s=e;return(!ge(s)||!s)&&(s=this.defaultAnalyticsKey),this.analyticsInstances[s]||(this.analyticsInstances[s]=new Jo),this.analyticsInstances[s]}catch(s){be(s);return}}load(e,s,i){try{if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e),this.trackPageLifecycleEvents(i);let n=ku(Ai);Z_(n),Oi(Ai,te(n)),this.getAnalyticsInstance(e)?.load(e,s,i)}catch(n){be(n)}}trackPageLifecycleEvents(e){let{autoTrack:s,useBeacon:i}=e??{},{enabled:n=!1,options:r={},pageLifecycle:o}=s??{},{events:a=[po.UNLOADED],enabled:l=n,options:c=r}=o??{};f.autoTrack.pageLifecycle.enabled.value=l,f.autoTrack.enabled.value=n||l,l&&this.setupPageUnloadTracking(a,i,c)}setupPageUnloadTracking(e,s,i){(e.length===0||e.includes(po.UNLOADED))&&(s===!0?T_(n=>{if(n===!1&&f.lifecycle.loaded.value){let r=Date.now(),o=r-f.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(po.UNLOADED,{timeOnPage:o},{...i,originalTimestamp:mu(new Date(r))})}},!0):this.logger.warn(fy(y_)))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],s=X_(e);Oi(Ai,te([...e])),s.length>0&&(s.shift(),this.load.apply(null,s))}ready(e){try{this.getAnalyticsInstance()?.ready(oe(e))}catch(s){be(s)}}page(e,s,i,n,r){try{this.getAnalyticsInstance()?.page(Bn(oe(e),oe(s),oe(i),oe(n),oe(r)))}catch(o){be(o)}}track(e,s,i,n){try{this.getAnalyticsInstance()?.track(ta(oe(e),oe(s),oe(i),oe(n)))}catch(r){be(r)}}identify(e,s,i,n){try{this.getAnalyticsInstance()?.identify(pu(oe(e),oe(s),oe(i),oe(n)))}catch(r){be(r)}}alias(e,s,i,n){try{this.getAnalyticsInstance()?.alias(vu(oe(e),oe(s),oe(i),oe(n)))}catch(r){be(r)}}group(e,s,i,n){try{this.getAnalyticsInstance()?.group(_u(oe(e),oe(s),oe(i),oe(n)))}catch(r){be(r)}}reset(e){try{this.getAnalyticsInstance()?.reset(oe(e))}catch(s){be(s)}}getAnonymousId(e){try{return this.getAnalyticsInstance()?.getAnonymousId(oe(e))}catch(s){be(s);return}}setAnonymousId(e,s){try{this.getAnalyticsInstance()?.setAnonymousId(oe(e),oe(s))}catch(i){be(i)}}getUserId(){try{return this.getAnalyticsInstance()?.getUserId()}catch(e){be(e);return}}getUserTraits(){try{return this.getAnalyticsInstance()?.getUserTraits()}catch(e){be(e);return}}getGroupId(){try{return this.getAnalyticsInstance()?.getGroupId()}catch(e){be(e);return}}getGroupTraits(){try{return this.getAnalyticsInstance()?.getGroupTraits()}catch(e){be(e);return}}setCustomContext(e){try{this.getAnalyticsInstance()?.setCustomContext(e)}catch(s){be(s)}}getCustomContext(){try{return this.getAnalyticsInstance()?.getCustomContext()??{}}catch(e){return be(e),{}}}clearCustomContext(){try{this.getAnalyticsInstance()?.clearCustomContext()}catch(e){be(e)}}startSession(e){try{this.getAnalyticsInstance()?.startSession(oe(e))}catch(s){be(s)}}endSession(){try{this.getAnalyticsInstance()?.endSession()}catch(e){be(e)}}getSessionId(){try{return this.getAnalyticsInstance()?.getSessionId()}catch(e){be(e);return}}setAuthToken(e){try{this.getAnalyticsInstance()?.setAuthToken(oe(e))}catch(s){be(s)}}consent(e){try{this.getAnalyticsInstance()?.consent(oe(e))}catch(s){be(s)}}addCustomIntegration(e,s){try{this.getAnalyticsInstance()?.addCustomIntegration(oe(e),oe(s))}catch(i){be(i)}}};Se(vs,"globalSingleton",null);zs=vs});var dd,hd,ua,ud,fd,gd,pd,vd,Di=Ze(()=>{"use strict";dd="https://deriv.com/cdn-cgi/trace",hd="https://cdn.growthbook.io",ua="https://deriv-dataplane.rudderstack.com",ud="https://ph.deriv.com",fd="https://us.posthog.com",gd=()=>{if(typeof window>"u")return ud;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":ud},pd=["deriv.com","deriv.be","deriv.me","deriv.team","deriv.ae","trading.game"],vd=["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 er(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 da(t,e){function s(n,r,o){if(!(typeof document>"u")){o=er({},e,o),typeof o.expires=="number"&&(o.expires=new Date(Date.now()+o.expires*864e5)),o.expires&&(o.expires=o.expires.toUTCString()),n=encodeURIComponent(n).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=n+"="+t.write(r,n)+a}}function i(n){if(!(typeof document>"u"||arguments.length&&!n)){for(var r=document.cookie?document.cookie.split("; "):[],o={},a=0;a<r.length;a++){var l=r[a].split("="),c=l.slice(1).join("=");try{var u=decodeURIComponent(l[0]);if(u in o||(o[u]=t.read(c,u)),n===u)break}catch{}}return n?o[n]:o}}return Object.create({set:s,get:i,remove:function(n,r){s(n,"",er({},r,{expires:-1}))},withAttributes:function(n){return da(this.converter,er({},this.attributes,n))},withConverter:function(n){return da(er({},this.converter,n),this.attributes)}},{attributes:{value:Object.freeze(e)},converter:{value:Object.freeze(t)}})}var BE,_d,md=Ze(()=>{"use strict";BE={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)}};_d=da(BE,{path:"/"})});var es,sr,Ni,tr,yd,ms,bd,Ed,Mi=Ze(()=>{"use strict";md();Di();es=(t,e)=>(...s)=>{e()&&console.log(`[ANALYTIC]${t}`,...s)},sr=t=>{let e=t.split("@")[1]?.toLowerCase();return e?vd.includes(e):!1},Ni=t=>/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(t),tr=null,yd=async()=>{if(tr)return tr;let t=JSON.parse(_d.get("website_status")||"{}")?.clients_country;return tr=(async()=>{try{let e=await fetch(dd).catch(()=>null);if(!e)return t||"";let s=await e.text().catch(()=>"");return s?Object.fromEntries(s.split(`
|
|
5
|
+
`).map(n=>n.split("=",2))).loc?.toLowerCase()||t||"":t||""}catch{return t||""}})(),tr},ms=t=>{if(t==null||typeof t!="object")return t;if(Array.isArray(t)){let i=[];for(let n=0;n<t.length;n++){let r=ms(t[n]);r!=null&&i.push(r)}return i.length?i:void 0}let e={},s=!1;for(let i in t){if(!Object.prototype.hasOwnProperty.call(t,i))continue;let n=ms(t[i]);n==null||n===""||typeof n=="object"&&!Array.isArray(n)&&Object.keys(n).length===0||Array.isArray(n)&&n.length===0||(e[i]=n,s=!0)}return s?e:void 0},bd=(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)?bd(i,e):e[s]=i}},Ed=t=>{if(t==null||typeof t!="object"||Array.isArray(t))return t;let e={};return bd(t,e),e}});function Od(){return Cd}function ha(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 Fi(t,e,s){return s===2?ha(ha(t+e)+"")%1e4/1e4:s===1?ha(e+t)%1e3/1e3:null}function ga(t){return t<=0?[]:new Array(t).fill(1/t)}function or(t,e){return t>=e[0]&&t<e[1]}function Pd(t,e){let s=Fi("__"+e[0],t,1);return s===null?!1:s>=e[1]&&s<e[2]}function $d(t,e){for(let s=0;s<e.length;s++)if(or(t,e[s]))return s;return-1}function pa(t){try{let e=t.replace(/([^\\])\//g,"$1\\/");return new RegExp(e)}catch(e){console.error(e);return}}function ar(t,e){if(!e.length)return!1;let s=!1,i=!1;for(let n=0;n<e.length;n++){let r=HE(t,e[n].type,e[n].pattern);if(e[n].include===!1){if(r)return!1}else s=!0,r&&(i=!0)}return i||!s}function jE(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 GE(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((n,r)=>{i.push([t.searchParams.get(r)||"",n,!1])}),!i.some(n=>!jE(n[0],n[1],n[2]))}catch{return!1}}function HE(t,e,s){try{let i=new URL(t,"https://_");if(e==="regex"){let n=pa(s);return n?n.test(i.href)||n.test(i.href.substring(i.origin.length)):!1}else if(e==="simple")return GE(i,s);return!1}catch{return!1}}function xd(t,e,s){e=e===void 0?1:e,e<0?e=0:e>1&&(e=1);let i=ga(t);s=s||i,s.length!==t&&(s=i);let n=s.reduce((o,a)=>a+o,0);(n<.99||n>1.01)&&(s=i);let r=0;return s.map(o=>{let a=r;return r+=o,[a,a+e*o]})}function Dd(t,e,s){if(!e)return null;let i=e.split("?")[1];if(!i)return null;let n=i.replace(/#.*/,"").split("&").map(r=>r.split("=",2)).filter(([r])=>r===t).map(([,r])=>parseInt(r));return n.length>0&&n[0]>=0&&n[0]<s?n[0]:null}function Nd(t){try{return t()}catch(e){return console.error(e),!1}}async function ts(t,e,s){if(e=e||"",s=s||globalThis.crypto&&globalThis.crypto.subtle||Cd.SubtleCrypto,!s)throw new Error("No SubtleCrypto implementation found");try{let i=await s.importKey("raw",fa(e),{name:"AES-CBC",length:128},!0,["encrypt","decrypt"]),[n,r]=t.split("."),o=await s.decrypt({name:"AES-CBC",iv:fa(n)},i,fa(r));return new TextDecoder().decode(o)}catch{throw new Error("Failed to decrypt")}}function Li(t){return typeof t=="string"?t:JSON.stringify(t)}function lt(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 Md(){let t;try{t="1.8.0"}catch{t=""}return t}function Fd(t,e){let s,i;try{s=new URL(t),i=new URL(e)}catch(n){return console.error(`Unable to merge query strings: ${n}`),e}return s.searchParams.forEach((n,r)=>{i.searchParams.has(r)||i.searchParams.set(r,n)}),i.toString()}function Rd(t){return typeof t=="object"&&t!==null}function lr(t){return t.urlPatterns&&t.variations.some(e=>Rd(e)&&"urlRedirect"in e)?"redirect":t.variations.some(e=>Rd(e)&&(e.domMutations||"js"in e||"css"in e))?"visual":"unknown"}async function cr(t,e){return new Promise(s=>{let i=!1,n,r=o=>{i||(i=!0,n&&clearTimeout(n),s(o||null))};e&&(n=setTimeout(()=>r(),e)),t.then(o=>r(o)).catch(()=>r())})}var Cd,fa,Ui=Ze(()=>{"use strict";Cd={fetch:globalThis.fetch?globalThis.fetch.bind(globalThis):void 0,SubtleCrypto:globalThis.crypto?globalThis.crypto.subtle:void 0,EventSource:globalThis.EventSource};fa=t=>Uint8Array.from(atob(t),e=>e.charCodeAt(0))});function Bd(t){Object.assign(De,t),De.backgroundSync||wa()}async function Vd({instance:t,timeout:e,skipCache:s,allowStale:i,backgroundSync:n}){return n||(De.backgroundSync=!1),YE({instance:t,allowStale:i,timeout:e,skipCache:s})}function zE(t){let e=Ss(t),s=bs.get(e)||new Set;s.add(t),bs.set(e,s)}function jd(t){bs.forEach((e,s)=>{e.delete(t);let i=e.size?void 0:Es.get(s);i&&hr(i,s)})}function qE(){Ut.forEach(t=>{t&&(t.state="idle",ba(t))})}function WE(){Ut.forEach(t=>{t&&t.state==="idle"&&Ea(t)})}function Gd(t,e,s){return Math.min(t*Math.pow(e,s)*(1+Math.random()),KE)}function Hd(t){console.warn(`[GrowthBook] ${t}`)}function _a(t){va.has(t)||(va.add(t),Hd(`Streaming is enabled, but not active: ${t}. Features will not be updated in the background. Set \`pollingInterval\` to refresh on a timer instead, or see https://docs.growthbook.io/lib/node#refreshing-features`))}async function Ud(){try{if(!vt.localStorage)return;await vt.localStorage.setItem(De.cacheKey,JSON.stringify(Array.from(Lt.entries())))}catch{}}async function YE({instance:t,allowStale:e,timeout:s,skipCache:i}){let n=Ss(t),r=ma(t),o=new Date,a=new Date(o.getTime()-De.maxAge+De.staleTTL);await QE();let l=!De.disableCache&&!i?Lt.get(r):void 0;return l&&(e||l.staleAt>o)&&l.staleAt>a?(l.sse&&ws.add(n),l.staleAt<o?dr(t):ya(t),{data:l.data,success:!0,source:"cache"}):await cr(dr(t),s)||{data:null,success:!1,source:"timeout",error:new Error("Timeout")}}function Ss(t){let[e,s]=t.getApiInfo();return`${e}||${s}`}function ma(t){let e=Ss(t);if(!("isRemoteEval"in t)||!t.isRemoteEval())return e;let s=t.getAttributes(),i=t.getCacheKeyAttributes()||Object.keys(t.getAttributes()),n={};i.forEach(a=>{n[a]=s[a]});let r=t.getForcedVariations(),o=t.getUrl();return`${e}||${JSON.stringify({ca:n,fv:r,url:o})}`}async function QE(){if(!Ld){Ld=!0;try{if(vt.localStorage){let t=await vt.localStorage.getItem(De.cacheKey);if(!De.disableCache&&t){let e=JSON.parse(t);e&&Array.isArray(e)&&e.forEach(([s,i])=>{Lt.set(s,{...i,staleAt:new Date(i.staleAt)})}),zd()}}}catch{}if(!De.disableIdleStreams){let t=Ks.startIdleListener();t&&(Ks.stopIdleListener=t)}}}function zd(){let t=Array.from(Lt.entries()).map(([s,i])=>({key:s,staleAt:i.staleAt.getTime()})).sort((s,i)=>s.staleAt-i.staleAt),e=Math.min(Math.max(0,Lt.size-De.maxEntries),Lt.size);for(let s=0;s<e;s++)Lt.delete(t[s].key)}function qd(t,e,s){let i=s.dateUpdated||"",n=new Date(Date.now()+De.staleTTL),r=De.disableCache?void 0:Lt.get(e);if(r&&i&&r.version===i){r.staleAt=n,Ud();return}De.disableCache||(Lt.set(e,{data:s,version:i,staleAt:n,sse:ws.has(t)}),zd()),Ud();let o=bs.get(t);o&&o.forEach(a=>JE(a,s))}async function JE(t,e){await t.setPayload(e||t.getPayload())}async function dr(t){let{apiHost:e,apiRequestHeaders:s}=t.getApiHosts(),i=t.getClientKey(),n="isRemoteEval"in t&&t.isRemoteEval(),r=Ss(t),o=ma(t),a=ur.get(o);return a||(a=(n?Ks.fetchRemoteEvalCall({host:e,clientKey:i,payload:{attributes:t.getAttributes(),forcedVariations:t.getForcedVariations(),forcedFeatures:Array.from(t.getForcedFeatures().entries()),url:t.getUrl()},headers:s}):Ks.fetchFeaturesCall({host:e,clientKey:i,headers:s})).then(c=>{if(!c.ok)throw new Error(`HTTP error: ${c.status}`);return c.headers.get("x-sse-support")==="enabled"&&ws.add(r),c.json()}).then(c=>(qd(r,o,c),ya(t),ur.delete(o),{data:c,success:!0,source:"network"})).catch(c=>(ur.delete(o),{data:null,source:"error",success:!1,error:c})),ur.set(o,a)),a}function ya(t,e=!1){let s=Ss(t),i=ma(t),{streamingHost:n,streamingHostRequestHeaders:r}=t.getApiHosts(),o=t.getClientKey();if(e&&ws.add(s),De.backgroundSync&&ws.has(s)&&vt.EventSource){if(Ut.has(s))return;let a={src:null,key:s,host:n,clientKey:o,headers:r,cb:l=>{try{if(l.type==="features-updated"){let c=bs.get(s);c&&c.forEach(u=>{dr(u)})}else if(l.type==="features"){let c=JSON.parse(l.data);qd(s,i,c)}a.errors=0}catch{Wd(a)}},errors:0,state:"active"};Ut.set(s,a),Ea(a)}}function Wd(t){if(t.state!=="idle"&&(t.errors++,t.errors>3||t.src&&t.src.readyState===2)){let e=Gd(1e3,3,t.errors-3);ba(t),setTimeout(()=>{["idle","active"].includes(t.state)||Ut.get(t.key)===t&&Ea(t)},e)}}function ba(t){t.src&&(t.src.onopen=null,t.src.onerror=null,t.src.close(),t.src=null,t.state==="active"&&(t.state="disabled"))}function Ea(t){try{t.src=Ks.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=()=>Wd(t),t.src.onopen=()=>{t.errors=0;let e=Es.get(t.key);e&&hr(e,t.key)}}catch(e){try{t.src&&(t.src.close(),t.src.onerror=null,t.src.onopen=null)}catch{}t.src=null,t.state="disabled",Ut.get(t.key)===t&&Ut.delete(t.key),_a(`the EventSource implementation threw an error (${e?e.message:"unknown error"})`)}}function XE(t,e){ba(t),Ut.delete(e)}function ZE(t,e){if(!Number.isFinite(e)||e<1||e>2147483647){Hd(`Ignoring invalid pollingInterval (${e}). Expected a finite number of milliseconds between 1 and 2147483647.`);return}if(Es.has(t))return;let s={timer:null,interval:e,errors:0};Es.set(t,s),Kd(t,s)}function Kd(t,e){let s=e.errors>0?Gd(e.interval,2,e.errors-1):e.interval,i=setTimeout(()=>{let n=bs.get(t),r=n&&n.values().next().value;if(!r){hr(e,t);return}dr(r).then(o=>{e.errors=o.success?0:e.errors+1,Es.get(t)===e&&Kd(t,e)})},s);i.unref&&i.unref(),e.timer=i}function hr(t,e){t.timer&&clearTimeout(t.timer),Es.delete(e)}function wa(){ws.clear(),va.clear(),Ut.forEach(XE),Es.forEach(hr),bs.clear(),Ks.stopIdleListener()}function fr(t,e){if(!e.streaming&&e.pollingInterval===void 0)return;if(!t.getClientKey())throw new Error("Must specify clientKey to enable streaming or polling");e.streaming&&(e.payload&&ya(t,!0),vt.EventSource?De.backgroundSync&&!ws.has(Ss(t))&&_a("the API host did not report SSE support (missing `x-sse-support` response header). This is also expected when the initial payload fetch fails"):_a("no EventSource implementation is available. In Node.js, install the `eventsource` package and pass it to setPolyfills({ EventSource })")),zE(t);let s=Ss(t);e.pollingInterval!==void 0&&De.backgroundSync&&ZE(s,e.pollingInterval)}var De,vt,Ks,bs,Ld,Lt,ur,Ut,Es,ws,va,KE,Yd=Ze(()=>{"use strict";Ui();De={staleTTL:1e3*60,maxAge:1e3*60*60*4,cacheKey:"gbFeaturesCache",backgroundSync:!0,maxEntries:10,disableIdleStreams:!1,idleStreamInterval:2e4,disableCache:!1},vt=Od(),Ks={fetchFeaturesCall:({host:t,clientKey:e,headers:s})=>vt.fetch(`${t}/api/features/${e}`,{headers:s}),fetchRemoteEvalCall:({host:t,clientKey:e,payload:s,headers:i})=>{let n={method:"POST",headers:{"Content-Type":"application/json",...i},body:JSON.stringify(s)};return vt.fetch(`${t}/api/eval/${e}`,n)},eventSourceCall:({host:t,clientKey:e,headers:s})=>s?new vt.EventSource(`${t}/sub/${e}`,{headers:s}):new vt.EventSource(`${t}/sub/${e}`),startIdleListener:()=>{let t;if(!(typeof window<"u"&&typeof document<"u"))return;let s=()=>{document.visibilityState==="visible"?(window.clearTimeout(t),WE()):document.visibilityState==="hidden"&&(t=window.setTimeout(qE,De.idleStreamInterval))};return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},stopIdleListener:()=>{}};try{globalThis.localStorage&&(vt.localStorage=globalThis.localStorage)}catch{}bs=new Map,Ld=!1,Lt=new Map,ur=new Map,Ut=new Map,Es=new Map,ws=new Set,va=new Set;KE=1e3*60*5});function tw(t){return t==="html"?{childList:!0,subtree:!0,attributes:!0,characterData:!0}:{childList:!1,subtree:!1,attributes:!0,attributeFilter:[t]}}function mr(t){var e=_r.get(t);return e||(e={element:t,attributes:{}},_r.set(t,e)),e}function yr(t,e,s,i,n){var r=s(t),o={isDirty:!1,originalValue:r,virtualValue:r,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,n(o))}}),mutationRunner:n,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,tw(e)),o}function br(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,Qd()):t!==s&&(e.isDirty=!0,Qd())}function sw(t){var e=t.originalValue;t.mutations.forEach(function(s){return e=s.mutate(e)}),br(vw(e),t)}function iw(t){var e=new Set(t.originalValue.split(/\s+/).filter(Boolean));t.mutations.forEach(function(s){return s.mutate(e)}),br(Array.from(e).filter(Boolean).join(" "),t)}function nw(t){var e=t.originalValue;t.mutations.forEach(function(s){return e=s.mutate(e)}),br(e,t)}function rw(t){var e=t.parentSelector,s=t.insertBeforeSelector,i=document.querySelector(e);if(!i)return null;var n=s?document.querySelector(s):null;return s&&!n?null:{parentNode:i,insertBeforeNode:n}}function ow(t){var e=t.originalValue;t.mutations.forEach(function(s){var i=s.mutate(),n=rw(i);e=n||e}),br(e,t)}function Xd(t){var e=mr(t);return e.html||(e.html=yr(t,"html",aw,lw,sw)),e.html}function Zd(t){var e=mr(t);return e.position||(e.position=yr(t,"position",cw,uw,ow)),e.position}function eh(t){var e=mr(t);return e.classes||(e.classes=yr(t,"class",hw,dw,iw)),e.classes}function th(t,e){var s=mr(t);return s.attributes[e]||(s.attributes[e]=yr(t,e,fw(e),gw(e),nw)),s.attributes[e]}function pw(t,e){var s=_r.get(t);if(s)if(e==="html"){var i,n;(i=s.html)==null||(n=i.observer)==null||n.disconnect(),delete s.html}else if(e==="class"){var r,o;(r=s.classes)==null||(o=r.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 c,u,h;(c=s.attributes)==null||(u=c[e])==null||(h=u.observer)==null||h.disconnect(),delete s.attributes[e]}}function vw(t){return gr||(gr=document.createElement("div")),gr.innerHTML=t,gr.innerHTML}function pr(t,e,s){if(s.isDirty){s.isDirty=!1;var i=s.virtualValue;s.mutations.length||pw(t,e),s.setValue(t,i)}}function _w(t,e){t.html&&pr(e,"html",t.html),t.classes&&pr(e,"class",t.classes),t.position&&pr(e,"position",t.position),Object.keys(t.attributes).forEach(function(s){pr(e,s,t.attributes[s])})}function Qd(){_r.forEach(_w)}function mw(t,e){var s=null;t.kind==="html"?s=Xd(e):t.kind==="class"?s=eh(e):t.kind==="attribute"?s=th(e,t.attribute):t.kind==="position"&&(s=Zd(e)),s&&(s.mutations.push(t),s.mutationRunner(s))}function yw(t,e){var s=null;if(t.kind==="html"?s=Xd(e):t.kind==="class"?s=eh(e):t.kind==="attribute"?s=th(e,t.attribute):t.kind==="position"&&(s=Zd(e)),!!s){var i=s.mutations.indexOf(t);i!==-1&&s.mutations.splice(i,1),s.mutationRunner(s)}}function sh(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),mw(t,i))})}}function bw(t){t.elements.forEach(function(e){return yw(t,e)}),t.elements.clear(),Ta.delete(t)}function Jd(){Ta.forEach(sh)}function Ew(){typeof document>"u"||(Sa||(Sa=new MutationObserver(function(){Jd()})),Jd(),Sa.observe(document.documentElement,{childList:!0,subtree:!0,attributes:!1,characterData:!1}))}function Er(t){return typeof document>"u"?Aa:(Ta.add(t),sh(t),{revert:function(){bw(t)}})}function ka(t,e){return Er({kind:"html",elements:new Set,mutate:e,selector:t})}function ih(t,e){return Er({kind:"position",elements:new Set,mutate:e,selector:t})}function Bi(t,e){return Er({kind:"class",elements:new Set,mutate:e,selector:t})}function vr(t,e,s){return ew.test(e)?e==="class"||e==="className"?Bi(t,function(i){var n=s(Array.from(i).join(" "));i.clear(),n&&n.split(/\s+/g).filter(Boolean).forEach(function(r){return i.add(r)})}):Er({kind:"attribute",attribute:e,elements:new Set,mutate:s,selector:t}):Aa}function ww(t){var e=t.selector,s=t.action,i=t.value,n=t.attribute,r=t.parentSelector,o=t.insertBeforeSelector;if(n==="html"){if(s==="append")return ka(e,function(a){return a+(i??"")});if(s==="set")return ka(e,function(){return i??""})}else if(n==="class"){if(s==="append")return Bi(e,function(a){i&&a.add(i)});if(s==="remove")return Bi(e,function(a){i&&a.delete(i)});if(s==="set")return Bi(e,function(a){a.clear(),i&&a.add(i)})}else if(n==="position"){if(s==="set"&&r)return ih(e,function(){return{insertBeforeSelector:o,parentSelector:r}})}else{if(s==="append")return vr(e,n,function(a){return a!==null?a+(i??""):i??""});if(s==="set")return vr(e,n,function(){return i??""});if(s==="remove")return vr(e,n,function(){return null})}return Aa}var ew,Aa,_r,Ta,aw,lw,cw,uw,dw,hw,fw,gw,gr,Sa,Sw,nh,rh=Ze(()=>{"use strict";ew=/^[a-zA-Z:_][a-zA-Z0-9:_.-]*$/,Aa={revert:function(){}},_r=new Map,Ta=new Set;aw=function(e){return e.innerHTML},lw=function(e,s){return e.innerHTML=s};cw=function(e){return{parentNode:e.parentElement,insertBeforeNode:e.nextElementSibling}},uw=function(e,s){s.insertBeforeNode&&!s.parentNode.contains(s.insertBeforeNode)||s.parentNode.insertBefore(e,s.insertBeforeNode)};dw=function(e,s){return s?e.className=s:e.removeAttribute("class")},hw=function(e){return e.className};fw=function(e){return function(s){var i;return(i=s.getAttribute(e))!=null?i:null}},gw=function(e){return function(s,i){return i!==null?s.setAttribute(e,i):s.removeAttribute(e)}};Ew();Sw={html:ka,classes:Bi,attribute:vr,position:ih,declarative:ww},nh=Sw});function Bt(t,e,s,i){s=s||{},i=i||new Set;for(let[n,r]of Object.entries(e))switch(n){case"$or":if(!ch(t,r,s,i))return!1;break;case"$nor":if(ch(t,r,s,i))return!1;break;case"$and":if(!Rw(t,r,s,i))return!1;break;case"$not":if(Bt(t,r,s,i))return!1;break;case"$savedGroup":if(!kw(t,r,s,i))return!1;break;default:if(!Vi(r,uh(t,n),s,!1,i))return!1}return!0}function kw(t,e,s,i){if(!e||typeof e!="object"||Array.isArray(e))return!1;let{id:n,attributeKey:r}=e;if(typeof n!="string"||i.has(n)||r!==void 0&&typeof r!="string")return!1;let o=s[n];if(!o||Array.isArray(o)||typeof o!="object")return!1;let a=new Set(i).add(n);if(o.type==="list"){let l=r??o.attributeKey;return typeof l!="string"||!Array.isArray(o.values)?!1:ks(uh(t,l),o.values)}return o.type==="condition"?!o.condition||typeof o.condition!="object"?!1:Bt(t,o.condition,s,a):!1}function uh(t,e){let s=e.split("."),i=t;for(let n=0;n<s.length;n++)if(i&&typeof i=="object"&&s[n]in i)i=i[s[n]];else return null;return i}function oh(t,e=!1){let s=`${t}${e?"/i":""}`;return Ia[s]||(Ia[s]=new RegExp(t.replace(/([^\\])\//g,"$1\\/"),e?"i":void 0)),Ia[s]}function Vi(t,e,s,i=!1,n=new Set){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)||!dh(t))return JSON.stringify(e)===JSON.stringify(t);for(let r in t)if(!Iw(r,e,t[r],s,n))return!1;return!0}function dh(t){let e=Object.keys(t);return e.length>0&&e.filter(s=>s[0]==="$").length===e.length}function Aw(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 Tw(t,e,s,i){if(!Array.isArray(t))return!1;let n=dh(e)?r=>Vi(e,r,s,!1,i):r=>Bt(r,e,s,i);for(let r=0;r<t.length;r++)if((t[r]??null)!==null&&n(t[r]))return!0;return!1}function ks(t,e,s=!1){if(s){let i=n=>typeof n=="string"?n.toLowerCase():n;return Array.isArray(t)?t.some(n=>e.some(r=>i(n)===i(r))):e.some(n=>i(t)===i(n))}return Array.isArray(t)?t.some(i=>e.includes(i)):e.includes(t)}function ah(t){return t===void 0?[]:Array.isArray(t)?t:t&&typeof t=="object"&&t.type==="list"&&Array.isArray(t.values)?t.values:null}function lh(t,e,s,i=!1,n=new Set){if(!Array.isArray(t))return!1;for(let r=0;r<e.length;r++){let o=!1;for(let a=0;a<t.length;a++)if(Vi(e[r],t[a],s,i,n)){o=!0;break}if(!o)return!1}return!0}function Iw(t,e,s,i,n=new Set){switch(t){case"$veq":return lt(e)===lt(s);case"$vne":return lt(e)!==lt(s);case"$vgt":return lt(e)>lt(s);case"$vgte":return lt(e)>=lt(s);case"$vlt":return lt(e)<lt(s);case"$vlte":return lt(e)<=lt(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)?ks(e,s):!1;case"$ini":return Array.isArray(s)?ks(e,s,!0):!1;case"$inGroup":{let r=ah(i[s]);return r===null?!1:ks(e,r)}case"$notInGroup":{let r=ah(i[s]);return r===null?!1:!ks(e,r)}case"$nin":return Array.isArray(s)?!ks(e,s):!1;case"$nini":return Array.isArray(s)?!ks(e,s,!0):!1;case"$not":return!Vi(s,e,i,!1,n);case"$size":return Array.isArray(e)?Vi(s,e.length,i,!1,n):!1;case"$elemMatch":return Tw(e,s,i,n);case"$all":return Array.isArray(s)?lh(e,s,i,!1,n):!1;case"$alli":return Array.isArray(s)?lh(e,s,i,!0,n):!1;case"$regex":try{return oh(s).test(e)}catch{return!1}case"$regexi":try{return oh(s,!0).test(e)}catch{return!1}case"$type":return Aw(e)===s;default:return console.error("Unknown operator: "+t),!1}}function ch(t,e,s,i){if(!e.length)return!0;for(let n=0;n<e.length;n++)if(Bt(t,e[n],s,i))return!0;return!1}function Rw(t,e,s,i){for(let n=0;n<e.length;n++)if(!Bt(t,e[n],s,i))return!1;return!0}var Ia,hh=Ze(()=>{"use strict";Ui();Ia={}});function Pw(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 $w(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 Ys(t){try{await t()}catch{}}function fh(t,e,s){if(t.user.trackedExperiments){let n=kr(e,s);if(t.user.trackedExperiments.has(n))return[];t.user.trackedExperiments.add(n)}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 n=t.global.trackingCallback;i.push(Ys(()=>n(e,s,kt(t.user))))}if(t.user.trackingCallback){let n=t.user.trackingCallback;i.push(Ys(()=>n(e,s,kt(t.user))))}if(t.global.eventLogger){let n=t.global.eventLogger;i.push(Ys(()=>n(Ow,{experimentId:e.key,variationId:s.key,hashAttribute:s.hashAttribute,hashValue:s.hashValue},kt(t.user))))}if(t.user.experimentViewedSubs?.size){let n=kt(t.user);t.user.experimentViewedSubs.forEach(r=>{try{r(e,s,n)}catch(o){console.error(o)}})}return i}function xw(t,e,s){if(t.user.trackedFeatureUsage){let i=JSON.stringify(s.value);if(t.user.trackedFeatureUsage[e]===i)return;t.user.trackedFeatureUsage[e]=i,t.user.enableDevMode&&t.user.devLogs&&t.user.devLogs.push({featureKey:e,result:s,timestamp:Date.now().toString(),logType:"feature"}),t.user.featureUsageSubs?.size&&t.user.featureUsageSubs.forEach(n=>{try{n(e,s)}catch(r){console.error(r)}})}if(t.global.onFeatureUsage){let i=t.global.onFeatureUsage;Ys(()=>i(e,s,kt(t.user)))}if(t.user.onFeatureUsage){let i=t.user.onFeatureUsage;Ys(()=>i(e,s))}if(t.global.eventLogger){let i=t.global.eventLogger;Ys(()=>i(Cw,{feature:e,source:s.source,value:s.value,ruleId:s.source==="defaultValue"?"$default":s.ruleId||"",variationId:s.experimentResult?s.experimentResult.key:""},kt(t.user)))}}function wr(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=Pw(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 r of i.rules){if(r.parentConditions)for(let c of r.parentConditions){e.stack.evaluatedFeatures=new Set(n);let u=wr(c.id,e);if(u.source==="cyclicPrerequisite")return ss(e,t,null,"cyclicPrerequisite");let h={value:u.value};if(!Bt(h,c.condition||{},e.global.savedGroups||{})){if(c.gate)return ss(e,t,null,"prerequisite");continue e}}if(r.filters&&gh(r.filters,e))continue;if("force"in r){if(r.condition&&!Pa(r.condition,e)||!Fw(e,r.seed||t,r.hashAttribute,e.user.saveStickyBucketAssignmentDoc&&!r.disableStickyBucketing?r.fallbackAttribute:void 0,r.range,r.coverage,r.hashVersion))continue;return r.tracks&&r.tracks.forEach(c=>{!fh(e,c.experiment,c.result).length&&e.global.saveDeferredTrack&&e.global.saveDeferredTrack({experiment:c.experiment,result:c.result,user:kt(e.user)})}),ss(e,t,r.force,"force",r.id)}let o=r.contextualVariations??r.variations;if(!o)continue;let a={variations:o,key:r.key||t};"coverage"in r&&(a.coverage=r.coverage),r.weights&&(a.weights=r.weights),r.hashAttribute&&(a.hashAttribute=r.hashAttribute),r.fallbackAttribute&&(a.fallbackAttribute=r.fallbackAttribute),r.disableStickyBucketing&&(a.disableStickyBucketing=r.disableStickyBucketing),r.bucketVersion!==void 0&&(a.bucketVersion=r.bucketVersion),r.minBucketVersion!==void 0&&(a.minBucketVersion=r.minBucketVersion),r.namespace&&(a.namespace=r.namespace),r.meta&&(a.meta=r.meta),r.ranges&&(a.ranges=r.ranges),r.name&&(a.name=r.name),r.phase&&(a.phase=r.phase),r.seed&&(a.seed=r.seed),r.hashVersion&&(a.hashVersion=r.hashVersion),r.filters&&(a.filters=r.filters),r.condition&&(a.condition=r.condition),r.contextualBanditRef&&Mw(a,r.contextualBanditRef,t,e);let{result:l}=Sr(a,t,e);if(a.contextualBandit&&!(l.hashUsed&&l.inExperiment)&&delete a.contextualBandit,e.global.onExperimentEval&&e.global.onExperimentEval(a,l),l.inExperiment&&!l.passthrough)return ss(e,t,l.value,"experiment",r.id,a,l)}}return ss(e,t,i.defaultValue===void 0?null:i.defaultValue,"defaultValue")}function Sr(t,e,s){let i=t.key,n=t.variations.length;if(n<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=Lw(t,s),t.contextualBandit&&t.weights&&(t.contextualBandit={...t.contextualBandit,variationWeights:t.weights}),t.urlPatterns&&!ar(s.user.url||"",t.urlPatterns))return{result:Ae(s,t,-1,!1,e)};let r=Dd(i,s.user.url||"",n);if(r!==null)return{result:Ae(s,t,r,!1,e)};let o=$w(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}=As(s,t.hashAttribute,s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing?t.fallbackAttribute:void 0);if(!l)return{result:Ae(s,t,-1,!1,e)};let c=-1,u=!1,h=!1;if(s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{variation:v,versionIsBlocked:b}=Vw({ctx:s,expKey:t.key,expBucketVersion:t.bucketVersion,expHashAttribute:t.hashAttribute,expFallbackAttribute:t.fallbackAttribute,expMinBucketVersion:t.minBucketVersion,expMeta:t.meta});u=v>=0,c=v,h=!!b}if(!u){if(t.filters){if(gh(t.filters,s))return{result:Ae(s,t,-1,!1,e)}}else if(t.namespace&&!Pd(l,t.namespace))return{result:Ae(s,t,-1,!1,e)};if(t.include&&!Nd(t.include))return{result:Ae(s,t,-1,!1,e)};if(t.condition&&!Pa(t.condition,s))return{result:Ae(s,t,-1,!1,e)};if(t.parentConditions){let v=new Set(s.stack.evaluatedFeatures);for(let b of t.parentConditions){s.stack.evaluatedFeatures=new Set(v);let y=wr(b.id,s);if(y.source==="cyclicPrerequisite")return{result:Ae(s,t,-1,!1,e)};let w={value:y.value};if(!Bt(w,b.condition||{},s.global.savedGroups||{}))return{result:Ae(s,t,-1,!1,e)}}}if(t.groups&&!Bw(t.groups,s))return{result:Ae(s,t,-1,!1,e)}}if(t.url&&!Uw(t.url,s))return{result:Ae(s,t,-1,!1,e)};let d=Fi(t.seed||i,l,t.hashVersion||1);if(d===null)return{result:Ae(s,t,-1,!1,e)};if(!u){let v=t.ranges||xd(n,t.coverage===void 0?1:t.coverage,t.weights);c=$d(d,v)}if(h)return{result:Ae(s,t,-1,!1,e,void 0,!0)};if(c<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 g=Ae(s,t,c,!0,e,d,u);if(s.user.saveStickyBucketAssignmentDoc&&!t.disableStickyBucketing){let{changed:v,key:b,doc:y}=Gw(s,a,Li(l),{[Ra(t.key,t.bucketVersion)]:g.key});v&&(s.user.stickyBucketAssignmentDocs=s.user.stickyBucketAssignmentDocs||{},s.user.stickyBucketAssignmentDocs[b]=y,s.user.saveStickyBucketAssignmentDoc(y))}let p=fh(s,t,g);p.length===0&&s.global.saveDeferredTrack&&s.global.saveDeferredTrack({experiment:t,result:g,user:kt(s.user)});let m=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:g,trackingCall:m}}function ss(t,e,s,i,n,r,o){let a={value:s,on:!!s,off:!s,source:i,ruleId:n||""};return r&&(a.experiment=r),o&&(a.experimentResult=o),i!=="override"&&xw(t,e,a),a}function Oa(t){return{...t.attributes,...t.attributeOverrides}}function kt(t){return{attributes:Oa(t),url:t.url}}function Dw(t,e){for(let s of t.contexts||[])if(Pa(s.condition||{},e))return{leafId:s.leafId,weights:s.weights};return null}function Mw(t,e,s,i){let n=i.global.contextualBandits?.[e];if(!n)return;let r=null;if(n.contexts&&n.contexts.length)try{r=Dw(n,i)}catch{}if(r){t.weights=r.weights,t.contextualBandit={leafId:r.leafId,variationWeights:r.weights,banditVersion:n.banditVersion};return}t.contextualBandit={leafId:Nw,variationWeights:t.weights??ga(t.variations.length),banditVersion:n.banditVersion}}function Pa(t,e){return Bt(Oa(e.user),t,e.global.savedGroups||{})}function gh(t,e){return t.some(s=>{let{hashValue:i}=As(e,s.attribute);if(!i)return!0;let n=Fi(s.seed,i,s.hashVersion||2);return n===null?!0:!s.ranges.some(r=>or(n,r))})}function Fw(t,e,s,i,n,r,o){if(!n&&r===void 0)return!0;if(!n&&r===0)return!1;let{hashValue:a}=As(t,s,i);if(!a)return!1;let l=Fi(e,a,o||1);return l===null?!1:n?or(l,n):r!==void 0?l<=r:!0}function Ae(t,e,s,i,n,r,o){let a=!0;(s<0||s>=e.variations.length)&&(s=0,a=!1);let{hashAttribute:l,hashValue:c}=As(t,e.hashAttribute,t.user.saveStickyBucketAssignmentDoc&&!e.disableStickyBucketing?e.fallbackAttribute:void 0),u=e.meta?e.meta[s]:{},h={key:u.key||""+s,featureId:n,inExperiment:a,hashUsed:i,variationId:s,value:e.variations[s],hashAttribute:l,hashValue:c,stickyBucketUsed:!!o};u.name&&(h.name=u.name),r!==void 0&&(h.bucket=r),u.passthrough&&(h.passthrough=u.passthrough);let d=e.contextualBandit;return d&&i&&a&&(h.leafId=d.leafId,h.variationWeights=d.variationWeights,d.banditVersion!==void 0&&(h.banditVersion=d.banditVersion)),h}function Lw(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=pa(t.url))),t}function As(t,e,s){let i=e||"id",n="",r=Oa(t.user);return r[i]&&(n=r[i]),!n&&s&&(r[s]&&(n=r[s]),n&&(i=s)),{hashAttribute:i,hashValue:n}}function Uw(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 Bw(t,e){let s=e.global.groups||{};for(let i=0;i<t.length;i++)if(s[t[i]])return!0;return!1}function Vw({ctx:t,expKey:e,expBucketVersion:s,expHashAttribute:i,expFallbackAttribute:n,expMinBucketVersion:r,expMeta:o}){s=s||0,r=r||0,i=i||"id",o=o||[];let a=Ra(e,s),l=jw(t,i,n);if(r>0)for(let h=0;h<r;h++){let d=Ra(e,h);if(l[d]!==void 0)return{variation:-1,versionIsBlocked:!0}}let c=l[a];if(c===void 0)return{variation:-1};let u=o.findIndex(h=>h.key===c);return u<0?{variation:-1}:{variation:u}}function Ra(t,e){return e=e||0,`${t}__${e}`}function Ca(t,e){return`${t}||${e}`}function jw(t,e,s){if(!t.user.stickyBucketAssignmentDocs)return{};let{hashAttribute:i,hashValue:n}=As(t,e),r=Ca(i,Li(n)),{hashAttribute:o,hashValue:a}=As(t,s),l=a?Ca(o,Li(a)):null,c={};return l&&t.user.stickyBucketAssignmentDocs[l]&&Object.assign(c,t.user.stickyBucketAssignmentDocs[l].assignments||{}),t.user.stickyBucketAssignmentDocs[r]&&Object.assign(c,t.user.stickyBucketAssignmentDocs[r].assignments||{}),c}function Gw(t,e,s,i){let n=Ca(e,s),r=t.user.stickyBucketAssignmentDocs&&t.user.stickyBucketAssignmentDocs[n]?t.user.stickyBucketAssignmentDocs[n].assignments||{}:{},o={...r,...i},a=JSON.stringify(r)!==JSON.stringify(o);return{key:n,doc:{attributeName:e,attributeValue:s,assignments:o},changed:a}}function Hw(t,e){let s=new Set,i=e&&e.features?e.features:t.global.features||{},n=e&&e.experiments?e.experiments:t.global.experiments||[];return Object.keys(i).forEach(r=>{let o=i[r];if(o.rules)for(let a of o.rules)(a.variations||a.contextualVariations)&&(s.add(a.hashAttribute||"id"),a.fallbackAttribute&&s.add(a.fallbackAttribute))}),n.map(r=>{s.add(r.hashAttribute||"id"),r.fallbackAttribute&&s.add(r.fallbackAttribute)}),Array.from(s)}async function ph(t,e,s){let i=$a(t,s);return e.getAllAssignments(i)}function $a(t,e){let s={};return Hw(t,e).forEach(n=>{let{hashValue:r}=As(t,n);s[n]=Li(r)}),s}async function vh(t,e,s){if(t={...t},t.encryptedFeatures){try{t.features=JSON.parse(await ts(t.encryptedFeatures,e,s))}catch(i){console.error(i)}delete t.encryptedFeatures}if(t.encryptedExperiments){try{t.experiments=JSON.parse(await ts(t.encryptedExperiments,e,s))}catch(i){console.error(i)}delete t.encryptedExperiments}if(t.encryptedSavedGroups){try{t.savedGroups=JSON.parse(await ts(t.encryptedSavedGroups,e,s))}catch(i){console.error(i)}delete t.encryptedSavedGroups}if(t.encryptedContextualBandits){try{t.contextualBandits=JSON.parse(await ts(t.encryptedContextualBandits,e,s))}catch(i){console.error(i)}delete t.encryptedContextualBandits}return t}function _h(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 kr(t,e){return e.hashAttribute+e.hashValue+t.key+e.variationId}var Cw,Ow,Nw,mh=Ze(()=>{"use strict";hh();Ui();Cw="Feature Evaluated",Ow="Experiment Viewed";Nw=-1});var Qs,zw,ji,yh=Ze(()=>{"use strict";rh();Ui();Yd();mh();Qs=typeof window<"u"&&typeof document<"u",zw=Md(),ji=class{constructor(e){if(e=e||{},this.version=zw,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._experimentViewedSubs=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 vh(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,fr(this,e),this}async init(e){if(this._initialized=!0,e=e||{},e.cacheSettings&&Bd(e.cacheSettings),e.payload)return await this.setPayload(e.payload),fr(this,e),{success:!0,source:"init"};{let{data:s,...i}=await this._refresh({...e,allowStale:!0});return fr(this,e),await this.setPayload(s||{}),i}}async loadFeatures(e){e=e||{},await this.init({skipCache:e.skipCache,timeout:e.timeout,streaming:(this._options.backgroundSync??!0)&&(e.autoRefresh||this._options.subscribeToChanges)})}async refreshFeatures(e){let s=await this._refresh({...e||{},allowStale:!1});s.data&&await this.setPayload(s.data)}getApiInfo(){return[this.getApiHosts().apiHost,this.getClientKey()]}getApiHosts(){return _h(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:s,allowStale:i,streaming:n}){if(!this._options.clientKey)throw new Error("Missing clientKey");return Vd({instance:this,timeout:e,skipCache:s||this._options.disableCache,allowStale:i,backgroundSync:n??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,s,i){let n=await ts(e,s||this._options.decryptionKey,i);this.setFeatures(JSON.parse(n))}setExperiments(e){this._options.experiments=e,this.ready=!0,this._updateAllAutoExperiments()}async setEncryptedExperiments(e,s,i){let n=await ts(e,s||this._options.decryptionKey,i);this.setExperiments(JSON.parse(n))}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)}}_subscribeFeatureUsage(e){return this._featureUsageSubs.add(e),()=>this._featureUsageSubs.delete(e)}_subscribeExperimentViewed(e){return this._experimentViewedSubs.add(e),()=>this._experimentViewedSubs.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._experimentViewedSubs.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,jd(this),e.destroyAllStreams&&wa(),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}=Sr(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?{...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,experimentViewedSubs:this._experimentViewedSubs,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 n=this._isAutoExperimentBlockedByContext(e),r,o;n?r=Ae(this._getEvalContext(),e,-1,!1,""):({result:r,trackingCall:o}=Sr(e,null,this._getEvalContext()),this._onExperimentEval(e,r));let a=JSON.stringify(r.value);if(!s&&r.inExperiment&&i&&i.valueHash===a)return r;if(i&&this._undoActiveAutoExperiment(e),r.inExperiment){let l=lr(e);if(l==="redirect"&&r.value.urlRedirect&&e.urlPatterns){let c=e.persistQueryString?Fd(this._getContextUrl(),r.value.urlRedirect):r.value.urlRedirect;if(ar(c,e.urlPatterns))return this.log("Skipping redirect because original URL matches redirect URL",{id:e.key}),r;this._redirectedUrl=c;let{navigate:u,delay:h}=this._getNavigateFunction();if(u)if(Qs)Promise.all([...o?[cr(o,this._options.maxNavigateDelay??1e3)]:[],new Promise(d=>window.setTimeout(d,this._options.navigateDelay??h))]).then(()=>{try{u(c)}catch(d){console.error(d)}});else try{u(c)}catch(d){console.error(d)}}else if(l==="visual"){let c=this._options.applyDomChangesCallback?this._options.applyDomChangesCallback(r.value):this._applyDOMChanges(r.value);c&&this._activeAutoExperiments.set(e,{undo:c,valueHash:a})}}return r}_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((n,r)=>{i.has(r)||(n.undo(),this._activeAutoExperiments.delete(r))});for(let n of s){let r=this._runAutoExperiment(n,e);if(r&&r.inExperiment&&lr(n)==="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(n=>{try{n(e,s)}catch(r){console.error(r)}})}_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 wr(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=>[kr(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(n){console.error(n)}}),this._options.eventLogger)try{await this._options.eventLogger(e,s||{},kt(this._getUserContext()))}catch(i){console.error(i)}else console.error("No event logger configured")}_saveDeferredTrack(e){this._deferredTrackingCalls.set(kr(e.experiment,e.result),e)}_getContextUrl(){return this._options.url||(Qs?window.location.href:"")}_isAutoExperimentBlockedByContext(e){let s=lr(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 n of e.variations){if(!n||!n.urlRedirect)continue;let r=new URL(n.urlRedirect);if(this._options.disableCrossOriginUrlRedirectExperiments&&(r.protocol!==i.protocol||r.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(nh.declarative(i).revert)}),()=>{s.forEach(i=>i())}}async refreshStickyBuckets(e){if(this._options.stickyBucketService){let s=this._getEvalContext(),i=await ph(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(),n=$a(i,s);return e.getAllAssignmentsSync(n)}inDevMode(){return!!this._options.enableDevMode}}});var bh=Ze(()=>{"use strict";yh()});var Eh={};go(Eh,{Growthbook:()=>xa});var ft,xa,wh=Ze(()=>{"use strict";bh();ca();Di();Mi();ft=class ft{constructor(e,s,i={},n=!1){this.analytics=new zs;this.isLoaded=!1;this.status=void 0;this.debug=!1;this.log=es("[GrowthBook]",()=>this.debug);this.setAttributes=({id:e,country:s,user_language:i,device_language:n,device_type:r,utm_source:o,utm_medium:a,utm_campaign:l,is_authorised:c,url:u,domain:h,utm_content:d,residence_country:g,loggedIn:p,network_type:m,network_downlink:v,user_id:b,anonymous_id:y,account_mode:w})=>{let I={...this.GrowthBook.getAttributes(),id:e,...b!==void 0&&{user_id:b},...y!==void 0&&{anonymous_id:y},...s!==void 0&&{country:s},...g!==void 0&&{residence_country:g},...i!==void 0&&{user_language:i},...n!==void 0&&{device_language:n},...r!==void 0&&{device_type:r},...o!==void 0&&{utm_source:o},...a!==void 0&&{utm_medium:a},...l!==void 0&&{utm_campaign:l},...c!==void 0&&{is_authorised:c},...u!==void 0&&{url:u},...h!==void 0&&{domain:h},...d!==void 0&&{utm_content:d},...p!==void 0&&{loggedIn:p},...m!==void 0&&{network_type:m},...v!==void 0&&{network_downlink:v},...w!==void 0&&{account_mode:w}};this.log("setAttributes | updating GrowthBook attributes",I),this.GrowthBook.setAttributes(I)};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=n;let r=typeof window<"u"?window.location.hostname.includes("localhost"):!1;this.GrowthBook=new ji({apiHost:hd,clientKey:e,decryptionKey:s,antiFlicker:!1,navigateDelay:0,antiFlickerTimeout:3500,subscribeToChanges:!0,enableDevMode:r,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 n=Date.now(),r=setInterval(()=>{this.isLoaded?(clearInterval(r),s()):Date.now()-n>=e&&(clearInterval(r),i(new Error("GrowthBook initialization timeout")))},100)})}};ft.getGrowthBookInstance=(e,s,i,n=!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,n),ft._instance),ft.resetInstance=()=>{ft._instance&&(ft._instance.destroy(),ft._instance=void 0)};xa=ft});function M(t,e){return t.indexOf(e)!==-1}function og(t){var e;let s=[];return(e=JSON.stringify(t,function(i,n){if(typeof n=="bigint")return n.toString();if(typeof n!="function"&&typeof n!="symbol"){if(n instanceof Error)return{name:n.name,message:n.message,stack:n.stack};if(n&&typeof n=="object"){for(;s.length>0&&s[s.length-1]!==this;)s.pop();if(s.includes(n))return"[Circular]";s.push(n)}return n}}))!==null&&e!==void 0?e:"null"}function lg(t){return t===null||typeof t!="object"}function Br(t,e){return{}.toString.call(t)===`[object ${e}]`}function bi(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 cg(t,Error)}}function ec(t){return"u">typeof Event&&cg(t,Event)}function cg(t,e){try{return t instanceof e}catch{return!1}}function Ah(t,e,s,i,n,r,o){try{var a=t[r](o),l=a.value}catch(c){return void s(c)}a.done?e(l):Promise.resolve(l).then(i,n)}function he(t){return function(){var e=this,s=arguments;return new Promise(function(i,n){var r=t.apply(e,s);function o(l){Ah(r,i,n,o,a,"next",l)}function a(l){Ah(r,i,n,o,a,"throw",l)}o(void 0)})}}function Rt(t,e,s,i,n){return e>s&&(i.warn("min cannot be greater than max."),e=s),Te(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: "+n),Rt(n??s,e,s,i))}function ci(t){let e="";for(let s=0;t.length>s;s++){let i=t.charCodeAt(s);if(55296>i||i>56319)e+=56320>i||i>57343?t[s]:"\uFFFD";else{let n=t.charCodeAt(s+1);56320>n||n>57343?e+="\uFFFD":(e+=t[s]+t[s+1],s++)}}return e}function Lg(t,e){if(!e)return t;let s=[];try{s=Object.keys(e)}catch{s=[]}for(let i of s){let n;try{n=e[i]}catch{n=En}Object.defineProperty(t,i,{value:n,enumerable:!0,writable:!0,configurable:!0})}return t}function Oh(t,e){return typeof(s=t)=="string"&&cS.test(s)?t:e();var s}function Bg(t,e){let 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 Ph(t){try{return t()}catch{return}}function Vg(t,e){let s=setTimeout(t,e);return s!=null&&s.unref&&s?.unref(),s}function $h(t,e,s){return jg.apply(this,arguments)}function jg(){return(jg=he(function*(t,e,s){let i;try{return yield Promise.race([t,new Promise((n,r)=>{i=Vg(()=>{try{s?.(),n()}catch(o){r(o)}},e)})])}finally{clearTimeout(i)}})).apply(this,arguments)}function nn(t){return nn=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},nn(t)}function uS(t,e,s){return(e=(function(i){var n=(function(r){if(nn(r)!="object"||!r)return r;var o=r[Symbol.toPrimitive];if(o!==void 0){var a=o.call(r,"string");if(nn(a)!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)})(i);return nn(n)=="symbol"?n:n+""})(e))in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function xh(t,e){var s=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(n){return Object.getOwnPropertyDescriptor(t,n).enumerable})),s.push.apply(s,i)}return s}function _(t){for(var e=1;arguments.length>e;e++){var s=arguments[e]!=null?arguments[e]:{};e%2?xh(Object(s),!0).forEach(function(i){uS(t,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(s)):xh(Object(s)).forEach(function(i){Object.defineProperty(t,i,Object.getOwnPropertyDescriptor(s,i))})}return t}function dS(t){var e;let s=globalThis._posthogChunkIds,i=globalThis._debugIds;if(!s&&!i)return;let n=s?Object.keys(s):[],r=i?Object.keys(i):[];if(Js&&Mh(s,n,Dh)&&Mh(i,r,Nh))return Js;Dh=s?_({},s):void 0,Nh=i?_({},i):void 0,Js={},(e=Hi)!==null&&e!==void 0||(Hi={});let o=(a,l)=>{for(let u of a){let h=l[u];if(!h)continue;let d=Hi?.[u];if(d){Js[d]=h;continue}let g=t(u);for(let p=g.length-1;p>=0;p--){var c;let m=(c=g[p])===null||c===void 0?void 0:c.filename;if(m){Js[m]=h,Hi[u]=m;break}}}};return i&&o(r,i),s&&o(n,s),Js}function Mh(t,e,s){return t&&s?e.length===Object.keys(s).length&&e.every(i=>t[i]===s[i]):t===s}function pS(t){if(!t||t==="<anonymous>")return!1;let e=fS.exec(t);return!e||gS.includes(e[1].toLowerCase())}function Il(t,e,s,i,n){let r={platform:t,filename:e,function:s==="<anonymous>"?"?":s,in_app:pS(e)};return S(i)||(r.lineno=i),S(n)||(r.colno=n),r}function sc(t,e){return t.filename===e.filename&&t.function===e.function&&t.module===e.module&&t.lineno===e.lineno&&t.colno===e.colno}function SS(t){for(let e=1;10>=e;e++){let s=t.length-2*e;if(0>s)break;let i=!0;for(let n=0;e>n;n++)if(!sc(t[s+n],t[s+e+n])){i=!1;break}if(i){for(let n=0;e>n;n++)t[s+n]=t[s+e+n];return t.length=s+e,{start:s,length:e}}}}function kS(t,e){let s=e.start+e.length,i=zg(t,e);i&&t.splice(s+i===t.length?s:e.start,i)}function Hg(t,e){let s=e.start;for(;s>0&&sc(t[s-1],t[s-1+e.length]);)s--;return e.start-s}function zg(t,e){let s=e.start+e.length,i=s;for(;t.length>i&&sc(t[i],t[i-e.length]);)i++;return i-s}function AS(t,e){let s=e[0],i=t.length-(s?Hg(t,s):0);for(let n of e)i-=zg(t,n);return i}function TS(t,e,s){for(let i=0;t.length>i;i++){let n=t[(e+i)%t.length],r=t[(s+i)%t.length];if(n!==r)return r>n}return!1}function qg(t,e=40){let s=Object.keys(t);if(s.sort(),!s.length)return"[object has no keys]";for(let i=s.length;i>0;i--){let n=s.slice(0,i).join(", ");if(e>=n.length)return i===s.length?n:n.length>e?`${n.slice(0,e)}...`:n}return""}function qr(t){var e;return t?{enabled:(e=t.enabled)!==null&&e!==void 0?e:Ua.enabled,max_bytes:US(t.max_bytes,Ua.max_bytes)}:_({},Ua)}function US(t,e){if(!Te(t)||t===1/0||t===-1/0)return e;let s=Math.floor(t);return 0>s?e:s}function Uh(t){return typeof t=="string"||t}function Bh(t){return typeof t=="string"?t:void 0}function Cl(){return Cl=he(function*(t,e=!0,s){try{let n=new TextEncoder().encode(t),r=new globalThis.CompressionStream("gzip"),o=r.writable.getWriter(),a=o.write(n).then(()=>o.close()).catch((i=he(function*(u){try{yield o.abort(u)}catch{}throw u}),function(u){return i.apply(this,arguments)})),l=new Response(r.readable).blob(),[c]=yield Promise.all([l,a]);return yield VS(c,n),c}catch(n){if(s?.rethrow)throw n;return e&&console.error("Failed to gzip compress data",n),null}var i}),Cl.apply(this,arguments)}function Kg(t,e){if(t==null)return{};var s,i,n=(function(o,a){if(o==null)return{};var l={};for(var c in o)if({}.hasOwnProperty.call(o,c)){if(a.includes(c))continue;l[c]=o[c]}return l})(t,e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);for(i=0;r.length>i;i++)e.includes(s=r[i])||{}.propertyIsEnumerable.call(t,s)&&(n[s]=t[s])}return n}function Ol(t){return(function(e){return KS.test(e)})(t)||XS.test(t)||ZS.test(t)}function Ba(t){return t.split("&",129).length>128}function lk(t,e,s){return Ol(t)||e.includes(";")&&(function(i){return i.split(";").some(n=>Ol(n.split("=",1)[0]))})(e)?je:Qg.test(e)?s?ic(e,{allowNestedUrls:!1,stripPunctuation:!0}):je:e}function Xg(t,e){let s=new URLSearchParams,i=!1,n=!1;for(let[r,o]of new URLSearchParams(t)){let a=Wr(r),l=Wr(o);i||(i=a!==r||l!==o);let c=lk(a,l,e);i||(i=c!==l),n=Ol(a)||c!==l,s.append(a,c)}return{changed:i,lastFieldSensitive:n,serialized:s.toString()}}function zh(t,e){if(!t.includes("="))return{value:ck(t,e),lastFieldSensitive:!1};let s=Xg(t,e);return{value:s.changed?s.serialized:t,lastFieldSensitive:s.lastFieldSensitive}}function ck(t,e){return e?ic(t,{allowNestedUrls:!1,stripPunctuation:!0}):Qg.test(t)?je:t}function uk(t,e,s){return t==="#"?!e.fragment&&(e.fragment=!0):t==="?"&&(e.fragment?s!=="="&&!e.fragmentQuery&&(e.fragmentQuery=!0):!e.query&&(e.query=!0))}function Va(t,e){var s;if(t.length>8192&&QS.test(t))return je;let{address:i,suffix:n}=e.stripPunctuation?(function(v){let b=v.length;for(;b>0&&".,;:!?)]}'".includes(v[b-1]);)b--;return{address:v.slice(0,b),suffix:v.slice(b)}})(t):{address:t,suffix:""},r;try{r=new URL(i)}catch{return je+n}let o=r.search.slice(1),a=r.hash!=="",l=(function(v){let b=v.slice(1),y=b.indexOf("?");return 0>y?{head:b,tail:null}:{head:b.slice(0,y),tail:b.slice(y+1)}})(r.hash);if(Ba(o)||Ba(l.head)||Ba((s=l.tail)!==null&&s!==void 0?s:""))return je+n;let c=!1;(r.username||r.password)&&(r.username=je,r.password="",c=!0);let u=Xg(o,e.allowNestedUrls);u.changed&&(r.search=u.serialized,c=!0);let h=zh(l.head,e.allowNestedUrls),d=l.tail===null?null:(g=l.tail,h.lastFieldSensitive?{value:g===""?"":je,lastFieldSensitive:!0}:zh(g,e.allowNestedUrls));var g;let p=d===null?h.value:`${h.value}?${d.value}`;p!==r.hash.slice(1)&&(r.hash=p,c=!0);let m=a?d??h:u;return(c?Wr(r.toString()):i)+(m.lastFieldSensitive?"":n)}function ic(t,e){return t.replace(Yg,s=>(function(i,n){let r=(function(l){if(!l.includes("://"))return[];let c=[...l.matchAll(JS)].map(m=>m.index),u=[],h={query:!1,fragment:!1,fragmentQuery:!1},d=0,g=!1,p="";for(let m=0;l.length>m&&c.length>d;m++){c[d]===m&&(m>0&&p!=="="&&u.push(m),d++);let v=l[m];uk(v,h,p)?(p=v,g=!0):g&&"=&".includes(v)&&(p=v)}return u})(i);if(r.length===0)return Va(i,n);let o="",a=0;for(let l of r)o+=Va(i.slice(a,l),_(_({},n),{},{stripPunctuation:!1})),a=l;return o+Va(i.slice(a),n)})(s,_(_({},e),{},{stripPunctuation:e.stripPunctuation&&s.length!==t.length})))}function Wr(t){return t.replace(WS,je)}function dk(t,e){return(function(s){return s.length>=10240&&(jS.test(s)||(function(i){let n=zS.exec(i);if(!n)return!1;let r;try{r=decodeURIComponent(i.slice(n[0].length))}catch{return!1}return qS.test(r.replace(/[\r\n]/g,""))})(s)||HS.test(s)&&GS.test(s))})(t)?"[binary data redacted - not supported by PostHog MCP analytics]":(function(s,i,n){let r=4*n.maxStringLength;if(s.length>r){let o=i(s.slice(0,(function(a,l){let c=l;for(;c>0&&!YS.test(a[c-1]);)c--;return c})(s,r)));if(o.length>=2*n.maxStringLength)return o+n.truncationSuffix}return i(s)})(t,s=>(function(i){return ic(i,{allowNestedUrls:!0,stripPunctuation:!0})})((function(i){let n=i.replace(ek," ");return n=n.replace(tk,je),n=n.replace(sk,je),n=n.replace(ik,`$1${je}`),n=n.replace(rk,fk),n=n.replace(nk,je),n=n.replace(ok,`$1${je}`),n=n.replace(ak,`$1${je}`),n})(Wr(s))),e)}function hk(t){let e=0,s=!1;for(let i=t.length-1;i>=0;i--){let n=t.charCodeAt(i)-48;if(0>n||n>9)return!1;s&&(n*=2,n>9&&(n-=9)),e+=n,s=!s}return e%10==0}function fk(t){let e=[];for(let r=Hh.exec(t);r!==null;r=Hh.exec(t))e.push({digits:r[0],start:r.index,end:r.index+r[0].length});let s="",i=0,n=0;for(;e.length>n;){let r="",o=-1;for(let a=n;e.length>a&&(r+=e[a].digits,19>=r.length);a++)r.length>=13&&hk(r)&&(o=a);0>o?n++:(s+=t.slice(i,e[n].start)+je,i=e[o].end,n=o+1)}return s+t.slice(i)}function Kr(t,e){try{return Zg(t,e,{ancestors:new WeakSet,remainingNodes:1e4},0)}catch{return[]}}function nc(t,e,s,i){if(0>=s.remainingNodes)return{stringValue:Tl};if(s.remainingNodes--,Je(t))return{boolValue:t};if(typeof t=="bigint")return(function(n,r){let o=n.toString(),a=BigInt("9223372036854775808");return n>=a||-a>n?(r?.debug(`Attribute ${o} is outside the int64 range; encoding it as a string`),{stringValue:o}):{intValue:o}})(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)};let n=BigInt(t).toString();return t>=9223372036854776e3||-9223372036854776e3>t?(e?.debug(`Attribute ${n} is outside the int64 range; encoding it as a string`),{stringValue:n}):{intValue:n}}return{doubleValue:t}}if(typeof t=="string")return{stringValue:ci(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:Tl};if(t instanceof Date){let n=t.getTime(),r=Number.isFinite(n)?t.toISOString():String(t);return{stringValue:typeof r=="string"?ci(r):String(r)}}s.ancestors.add(t);try{try{let n=t.toJSON;if(typeof n=="function")return nc(n.call(t),e,s,i+1)}catch{}return N(t)?{arrayValue:{values:pk(t,e,s,i+1)}}:{kvlistValue:{values:Zg(t,e,s,i+1)}}}finally{s.ancestors.delete(t)}}return{stringValue:ci(String(t))}}function pk(t,e,s,i){let n=[],r=Math.min(t.length,1e3),o=0;for(;r>o&&s.remainingNodes>0;o++)try{let a=o in t?t[o]:void 0;if(B(a))continue;n.push(nc(a,e,s,i))}catch{n.push({stringValue:En})}return t.length>o&&n.push({stringValue:Tl}),n}function Zg(t,e,s,i){let n=[];for(let r in t)if(gk.call(t,r)){if(!r){e?.debug("Dropping an attribute with an empty key");continue}if(n.length>=1e3||0>=s.remainingNodes){e?.debug("Attributes truncated: the value exceeds the OTLP encoder budget");break}try{let o=t[r];if(we(o)||S(o))continue;n.push({key:ci(r),value:nc(o,e,s,i)})}catch{n.push({key:ci(r),value:{stringValue:En}})}}return n}function ep(t,e,s){return _(_(_(_({},Lg({},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 tp(t,e){let s=Lg({},t),i={};for(let n of vk)({}).hasOwnProperty.call(s,n)&&(i[n]=s[n],delete s[n]);return[...Kr(s,e),...Kr(i,e)]}function mk(t){try{return ci(String(t))}catch{return En}}function yk(t,e,s,i){let n=t.level||"info",{text:r,number:o}=sp[n]||_k,a=(function(d=Date.now()){return String(d)+"000000"})(Te(i)?i:void 0),l={};e.distinctId&&(l.posthogDistinctId=e.distinctId),e.sessionId&&(l.sessionId=e.sessionId),e.windowId&&(l["window.id"]=e.windowId),B(e.sessionStartTimestamp)||(l.sessionStartTimestamp=String(e.sessionStartTimestamp)),B(e.lastActivityTimestamp)||(l.lastActivityTimestamp=String(e.lastActivityTimestamp)),e.currentUrl&&(l["url.full"]=e.currentUrl),e.screenName&&(l["screen.name"]=e.screenName),e.appState&&(l["app.state"]=e.appState),e.activeFeatureFlags&&e.activeFeatureFlags.length>0&&(l.feature_flags=e.activeFeatureFlags);let c=_({},l),u=t.attributes;if(u){let d=[];try{d=Object.keys(u)}catch{d=[]}for(let g of d){let p;try{p=u[g]}catch{p=En}Object.defineProperty(c,g,{value:p,enumerable:!0,writable:!0,configurable:!0})}}let h={timeUnixNano:a,observedTimeUnixNano:a,severityNumber:o,severityText:r,body:{stringValue:mk(t.body)},attributes:Kr(c,s)};return t.trace_id&&(h.traceId=t.trace_id),t.span_id&&(h.spanId=t.span_id),S(t.trace_flags)||(h.flags=t.trace_flags),h}function ip(t,e,s){return ep(t,e,s)}function np(t,e,s,i){return{resourceLogs:[{resource:{attributes:tp(e)},scopeLogs:[{scope:{name:s,version:i},logRecords:t}]}]}}function op(){return .75+.5*Math.random()}function ap(t,e,s,i){let n=Math.min(Math.max(0,e-1),6),r=t*Math.pow(2,n);return Math.round((i===void 0?r:Math.min(r,Math.max(i,t)))*s)}function Wh(t){return String(t)+"000000"}function Kh(t,e,s,i){let n="";return i&&(n=Object.keys(i).sort().map(r=>`${JSON.stringify(r)}:${JSON.stringify(i[r])}`).join(",")),`${t}\0${e}\0${s??""}\0${n}`}function ai(t,e){N(t)&&t.forEach(e)}function re(t,e){if(!B(t))if(N(t))t.forEach(e);else if((s=>s instanceof FormData)(t))t.forEach((s,i)=>e(s,i));else for(let s in t)Zl.call(t,s)&&e(t[s],s)}function Fr(t){let e=Object.keys(t),s=e.length,i=new Array(s);for(;s--;)i[s]=[e[s],t[e[s]]];return i}function $p(t){let e=_({},t);for(let s of["name","message","stack","cause","errors"])try{s in t&&(e[s]=t[s])}catch{}return e}function qk(t){let e=t?.hostname;if(!H(e))return!1;let s=e.split(".").slice(-2).join(".");for(let i of zk)if(s===i)return!1;return!0}function se(t,e,s,i){let{capture:n=!1,passive:r=!0}=i??{};t?.addEventListener(e,s,{capture:n,passive:r})}function Ul(t){return t.name==="ph_toolbar_internal"}function Np(t,e){var s;let i=t==null||(s=t.config)===null||s===void 0?void 0:s.get_current_url;if(!Ce(i))return e;try{let n=i(e);return H(n)&&n?n:e}catch(n){return R.error("Error in get_current_url, falling back to window.location.href",n),e}}function nf(t){var e;return t instanceof Element&&(t.id==="__POSTHOG_TOOLBAR__"||!!(!((e=t.closest)===null||e===void 0)&&e.call(t,".toolbar-global-fade-container")))}function Et(t){return!!t&&t.nodeType===1}function Ue(t,e){return!!t&&!!t.tagName&&t.tagName.toLowerCase()===e.toLowerCase()}function Mp(t){return!!t&&t.nodeType===3}function gc(t){return!!t&&t.nodeType===11&&Et(t.host)}function pc(t){return t?hi(t).split(/\s+/):[]}function rf(t,e){let s=(function(i){var n;let r=E==null||(n=E.location)===null||n===void 0?void 0:n.href;return S(r)?void 0:Np(i,r)})(e);return!!(s&&t&&t.some(i=>s.match(i)))}function gi(t){let 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 pc(e)}function Fp(t){return B(t)?null:hi(t).split(/(\s+)/).filter(e=>di(e)).join("").replace(/[\r\n]/g," ").replace(/[ ]+/g," ").substring(0,255)}function mn(t){let e="";return Ms(t)&&!pi(t)&&t.childNodes&&t.childNodes.length&&re(t.childNodes,function(s){var i;Mp(s)&&s.textContent&&(e+=(i=Fp(s.textContent))!==null&&i!==void 0?i:"")}),hi(e)}function cn(t){var e;return S(t.target)?t.srcElement||null:!((e=t.target)===null||e===void 0)&&e.shadowRoot?t.composedPath()[0]||null:t.target||null}function jl(t,e){let s=t.matches||t.matchesSelector||t.msMatchesSelector||t.mozMatchesSelector||t.webkitMatchesSelector||t.oMatchesSelector;try{return!!s&&s.call(t,e)}catch{return!1}}function Gl(t,e){if(S(e))return!0;for(let s of t)if(e.some(i=>jl(s,i)))return!0;return!1}function Lp(t){let e=t.parentNode;return!(!e||!Et(e))&&e}function Xa(t){let e="",s="",i=o=>{Et(o)&&Ms(o)&&!pi(o)&&(e+=` ${mn(o)}`,s=s||o.getAttribute("aria-label")||"",re(o.childNodes,i))};i(t),e=hi(e.replace(/\s+/g," "));let n=(di(e)?e:"").toLowerCase(),r=t.getAttribute("aria-label")||(n?"":s);return{safeText:n,ariaLabel:hi(r).toLowerCase()}}function Bp(t,e){if(!E||mc(t))return!1;let s,i,n;var r,o;if(Je(e)?(s=!!e&&lf,i=void 0,n=!1):(s=(r=e?.css_selector_ignorelist)!==null&&r!==void 0?r:lf,i=e?.content_ignorelist,n=(o=e?.ignore_text_selection)!==null&&o!==void 0&&o),s===!1||n&&(function(l){return!(!l||!Et(l))&&(!!Ue(l,"textarea")||(Ue(l,"input")?M(iA,(l.getAttribute("type")||"").toLowerCase()):(function(c){var u;if(c.isContentEditable)return!0;let h=(u=c.getAttribute)===null||u===void 0?void 0:u.call(c,"contenteditable");return h==="true"||h===""})(l)))})(t))return!1;let{targetElementList:a}=Vp(t,!1);return!(i&&(function(l,{safeText:c,ariaLabel:u}){let h;if(l===!0)h=Up;else{if(!N(l))return!1;if(l.length>of)return R.error(`[PostHog] content_ignorelist array cannot exceed ${of} items. Use css_selector_ignorelist for more complex matching.`),!1;h=l.map(d=>d.toLowerCase())}return h.some(d=>af(c,d)||af(u,d))})(i,(function(l,c){for(let u of c)if(sA(u))return Xa(u);for(let u of c){try{if(E?.getComputedStyle(u).getPropertyValue("cursor")!=="pointer")break}catch{break}let h=Xa(u);if(h.safeText||h.ariaLabel)return h}return Xa(l)})(t,a))||Gl(a,s))}function Ms(t){let e=new Set,s=0;for(let r=t;r.parentNode&&!Ue(r,"body");r=r.parentNode){if(s++>=1e3||e.has(r))return!1;e.add(r);let o=gi(r);if(M(o,"ph-sensitive")||M(o,"ph-no-capture"))return!1}if(M(gi(t),"ph-include"))return!0;let i=t.type||"";if(H(i))switch(i.toLowerCase()){case"hidden":case"password":return!1}let n=t.name||t.id||"";return!H(n)||!/^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g,""))}function pi(t){return!!(Ue(t,"input")&&!["button","checkbox","submit","reset"].includes(t.type)||Ue(t,"select")||Ue(t,"textarea")||t.getAttribute("contenteditable")==="true")}function oA(t){let e=0,s=!1;for(let i=t.length-1;i>=0;i--){let n=t.charCodeAt(i)-48;s&&(n*=2,n>9&&(n-=9)),e+=n,s=!s}return e%10==0}function di(t,e=!0){return!(B(t)||H(t)&&(t=hi(t),(e?cf.test((t||"").replace(/[- ]/g,"")):(function(s){let i;for(uf.lastIndex=0;i=uf.exec(s);){let n=i[2];if(!n)continue;let r=n.replace(/[- ]/g,"");for(let o=0;r.length>o;o++)for(let a of nA){let l=o+a;if(r.length>=l){let c=r.slice(o,l);if(cf.test(c)&&oA(c))return!0}}}return!1})(t))||(e?rA.test(t):(function(s){let i;for(df.lastIndex=0;i=df.exec(s);){let n=i[1],r=i[3];if(!(n&&r&&hf.test(n)&&hf.test(r)))return!0}return!1})(t))))}function ff(t){let e=mn(t);return e=`${e} ${jp(t)}`.trim(),di(e)?e:""}function jp(t){let e="";return t&&t.childNodes&&t.childNodes.length&&re(t.childNodes,function(s){var i;if(s&&((i=s.tagName)===null||i===void 0?void 0:i.toLowerCase())==="span")try{let n=mn(s);e=`${e} ${n}`.trim(),s.childNodes&&s.childNodes.length&&(e=`${e} ${jp(s)}`.trim())}catch(n){R.error("[AutoCapture]",n)}}),e}function gf(t){return t.replace(/"|\\"/g,'\\"')}function aA(t){let e=t.attr__class;if(e)return N(e)?e:pc(e)}function vf(t,e,s=!0){let i=t.config.segment;if(!i)return e();let{analytics:n,filterProperties:r}=(a=>Ce(a.register))(o=i)?{analytics:o}:o;var o;(function(a,l,c,u){let h=g=>{let p=()=>g.anonymousId()||bt();a.config.get_device_id=p,u&&g.id()&&(a.register({distinct_id:g.id(),$device_id:p()}),a.persistence.set_property(Qe,Mr)),c(u?void 0:g.anonymousId()||void 0)},d=l.user();"then"in d&&Ce(d.then)?d.then(h):h(d)})(t,n,a=>{n.register(((l,c,{filterProperties:u}={})=>{typeof Promise<"u"&&Promise.resolve||Wi.warn("This browser does not have Promise support, and can not use the segment integration");let h=(d,g)=>{if(!g)return d;let p=!!c&&d.event.anonymousId===c&&!d.event.userId;p||d.event.userId||d.event.anonymousId===l.get_distinct_id()||(Wi.info("No userId set, resetting PostHog"),l.reset()),p||(c=void 0),d.event.userId&&d.event.userId!==l.get_distinct_id()&&(Wi.info("UserId set, identifying with PostHog"),l.identify(d.event.userId));let m=l.calculateEventProperties(g,d.event.properties);if(!B(u)){let v=d.event.properties||{},b={};for(let w of Object.keys(m))Zl.call(v,w)||(b[w]=m[w]);let y=((w,A)=>{let I=N(w)?w:[w],k=_({},A);for(let $ of I)try{if(k=$(k),B(k))return null}catch(O){return Wi.error("Error in Segment filterProperties:",O),null}return k})(u,b);if(B(y))return d;m=y}return d.event.properties=Object.assign({},m,d.event.properties),d};return{name:"PostHog JS",type:"enrichment",version:"1.0.0",isLoaded(){return!0},load(){return Promise.resolve()},track(d){return h(d,d.event.event)},page(d){return h(d,hc)},identify(d){return h(d,Pp)},screen(d){return h(d,"$screen")}}})(t,a,{filterProperties:r})).then(()=>{e()},l=>{Wi.error("Failed to register the Segment integration",l),e()})},s)}function Hp(t,{organization:e,projectId:s,prefix:i,severityAllowList:n=["error"],sendExceptionsToPostHog:r=!0}={}){return o=>{var a,l,c,u,h;if(n!=="*"&&!n.includes(o.level)||!t.__loaded)return o;o.tags||(o.tags={});let d=t.requestRouter.endpointFor("ui",`/project/${t.config.token}/person/${t.get_distinct_id()}`);o.tags["PostHog Person URL"]=d,t.sessionRecordingStarted()&&(o.tags["PostHog Recording URL"]=t.get_session_replay_url({withTimestamp:!0}));let g=((a=o.exception)===null||a===void 0?void 0:a.values)||[],p=g.map(b=>_(_({},b),{},{stacktrace:b.stacktrace?_(_({},b.stacktrace),{},{type:"raw",frames:(b.stacktrace.frames||[]).map(y=>_(_({},y),{},{platform:"web:javascript"}))}):void 0})),m={$exception_message:((l=g[0])===null||l===void 0?void 0:l.value)||o.message,$exception_type:(c=g[0])===null||c===void 0?void 0:c.type,$exception_level:o.level,$exception_list:p,$sentry_event_id:o.event_id,$sentry_exception:o.exception,$sentry_exception_message:((u=g[0])===null||u===void 0?void 0:u.value)||o.message,$sentry_exception_type:(h=g[0])===null||h===void 0?void 0:h.type,$sentry_tags:o.tags};var v;return e&&s&&(m.$sentry_url=(i||"https://sentry.io/organizations/")+e+"/issues/?project="+s+"&query="+o.event_id),r&&((v=t.exceptions)===null||v===void 0||v.sendExceptionEvent(m)),o}}function zp(){try{return Intl.DateTimeFormat().resolvedOptions().timeZone}catch{return}}function Yp(t,e,s){if(!T)return{};let i=e?[..._i,...s||[]]:[],n=Qp(yn(T.URL,i,bn),t),r=(function(){let o={};return re(gA,function(a){let l=ln(a);o[a]=l||null}),o})();return ve(r,n)}function Qp(t,e){let s=fA.concat(e||[]),i={};return re(s,function(n){let r=vi(t,n);i[n]=r||null}),i}function Jp(t){let 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(!we(e)){i.$search_engine=e;let n=T?vi(T.referrer,s):"";n.length&&(i.ph_keyword=n)}return i}function Xp(){return navigator.language||navigator.userLanguage}function pA(){let t=Xp();return typeof t=="string"?t.split("-")[0]:void 0}function Zp(){return T?.referrer||to}function ev(t,e,s=!1){let i=t?[..._i,...e||[]]:[],n=s?ds(pe?.href):pe?.href,r=n?.substring(0,1e3);return{r:Zp().substring(0,1e3),u:r?yn(r,i,bn):void 0}}function tv(t,e=!1){var s;let{r:i,u:n}=t,r=e?ds(n):n,o={$referrer:i,$referring_domain:i==null?void 0:i==to?to:(s=Kt(i))===null||s===void 0?void 0:s.host};if(r){o.$current_url=r;let a=Kt(r);o.$host=a?.host,o.$pathname=a?.pathname;let l=Qp(r);ve(o,l)}if(i){let a=Jp(i);ve(o,a)}return o}function vA(){try{return new Date().getTimezoneOffset()}catch{return}}function il(t){let e=!0;return{dispose(){if(e){e=!1;let s=t();s&&Ce(s.then)&&s.then(void 0,()=>{})}}}}function TA(t,e){e===void 0&&(e={});var s=(function(){var d=4294967295;return{p(g){for(var p=d,m=0;g.length>m;++m)p=AA[255&p^g[m]]^p>>>8;d=p},d(){return 4294967295^d}}})(),i=t.length;s.p(t);var n,r,o,a,l,c,u=(a=10+((n=e).filename&&n.filename.length+1||0),l=8,(function(d,g,p,m,v,b){var y=d.length,w=new dt(m+y+5*(1+Math.floor(y/7e3))+v),A=w.subarray(m,w.length-v),I=0;if(!g||8>y)for(var k=0;y>=k;k+=65535){var $=k+65535;y>$?I=Lr(A,I,d.subarray(k,$)):(A[k]=b,I=Lr(A,I,d.subarray(k,y)))}else{for(var O=SA[g-1],x=O>>>13,Y=8191&O,X=(1<<p)-1,Z=new Xe(32768),ae=new Xe(X+1),D=Math.ceil(p/3),K=2*D,q=function(fo){return(d[fo]^d[fo+1]<<D^d[fo+2]<<K)&X},ie=new mi(25e3),Q=new Xe(288),P=new Xe(32),U=0,V=0,W=(k=0,0),ee=0,le=0;y>k;++k){var _e=q(k),Re=32767&k,xe=ae[_e];if(Z[Re]=xe,ae[_e]=Re,k>=ee){var Me=y-k;if((U>7e3||W>24576)&&Me>423){I=kf(d,A,0,ie,Q,P,V,W,le,k-le,I),W=U=V=0,le=k;for(var Be=0;286>Be;++Be)Q[Be]=0;for(Be=0;30>Be;++Be)P[Be]=0}var z=2,Ct=0,Lv=Y,Yt=Re-xe&32767;if(Me>2&&_e==q(k-Yt))for(var Uv=Math.min(x,Me)-1,Bv=Math.min(32767,k),Vv=Math.min(258,Me);Bv>=Yt&&--Lv&&Re!=xe;){if(d[k+z]==d[k+z-Yt]){for(var Qt=0;Vv>Qt&&d[k+Qt]==d[k+Qt-Yt];++Qt);if(Qt>z){if(z=Qt,Ct=Yt,Qt>Uv)break;var jv=Math.min(Yt,Qt-2),kc=0;for(Be=0;jv>Be;++Be){var ho=k-Yt+Be+32768&32767,Ac=ho-Z[ho]+32768&32767;Ac>kc&&(kc=Ac,xe=ho)}}}Yt+=(Re=xe)-(xe=Z[Re])+32768&32767}if(Ct){ie[W++]=268435456|zl[z]<<18|ql[Ct];var Tc=31&zl[z],Ic=31&ql[Ct];V+=yc[Tc]+bc[Ic],++Q[257+Tc],++P[Ic],ee=k+z,++U}else ie[W++]=d[k],++Q[d[k]]}}I=kf(d,A,b,ie,Q,P,V,W,le,k-le,I),b||(I=Lr(A,I,kA))}return av(w,0,m+ov(I)+v)})(r=t,(o=e).level==null?6:o.level,o.mem==null?Math.ceil(1.5*Math.max(8,Math.min(13,Math.log(r.length)))):12+o.mem,a,l,!c)),h=u.length;return(function(d,g){var p=g.filename;if(d[0]=31,d[1]=139,d[2]=8,d[8]=2>g.level?4:g.level==9?2:0,d[9]=3,g.mtime!=0&&rl(d,4,Math.floor(new Date(g.mtime||Date.now())/1e3)),p){d[3]=8;for(var m=0;p.length>=m;++m)d[m+10]=p.charCodeAt(m)}})(u,e),rl(u,h-8,s.d()),rl(u,h-4,i),u}function mv(t,e,s){var i,n,r;s&&(e=_(_({},e),{},{callback:o=>s(o)})),t.__loaded?_v?t.__request_queue.push(e):t.rateLimiter.isServerRateLimited(e.batchKey)?e.fireCallbackOnDrop&&((n=e.callback)===null||n===void 0||n.call(e,{statusCode:429})):(e.transport=e.transport||t.config.api_transport,e.headers=_(_({},t.config.request_headers),e.headers),e.compression=e.compression==="best-available"?(i=t.compression)!==null&&i!==void 0?i:e.compressionFallback:e.compression,(S(t.config.disable_beacon)?t.config.__preview_disable_beacon:t.config.disable_beacon)&&(e.disableTransport=["sendBeacon"]),e.fetchOptions=e.fetchOptions||t.config.fetch_options,((o,a)=>{var l,c,u;let h=_(_({},o),{},{callback:a??(v=>{var b;return(b=o.callback)===null||b===void 0?void 0:b.call(o,v)})});h.timeout=h.timeout||6e4;let d=(l=h.transport)!==null&&l!==void 0?l:"fetch";d==="sendBeacon"&&S(h.compression)&&h.data&&(h.compression=ut.Base64),h.method==="POST"&&h.data&&(h.timestampMode==="capture-body"?h.data=(v=>{var b,y;let w=(N(v)?v:[v]).map(I=>_(_({},I),I.timestamp instanceof Date&&!isNaN(I.timestamp.getTime())?{timestamp:I.timestamp.toISOString()}:{})),A=w[0];return{api_key:(b=A==null||(y=A.properties)===null||y===void 0?void 0:y.token)!==null&&b!==void 0?b:A?.token,batch:w,sent_at:new Date().toISOString()}})(h.data):h.timestampMode==="body"&&(h.data=((v,b=new Date().toISOString())=>N(v)?v.map(y=>_(_({},y),{},{sent_at:b})):_(_({},v),{},{sent_at:b}))(h.data))),h.url=Af(h.url,h.method,h.compression,h.timestampMode);let g=OA.filter(v=>!h.disableTransport||!v.transport||!h.disableTransport.includes(v.transport)),p=(c=(u=(function(v,b){for(let y=0;v.length>y;y++)if(b(v[y]))return v[y]})(g,v=>v.transport===d))===null||u===void 0?void 0:u.method)!==null&&c!==void 0?c:g[0].method;if(!p)throw new Error("No available transport method");let m=v=>{try{p(v)}catch(y){var b;fv(y)?R.warn(y):R.error(y),(b=h.callback)===null||b===void 0||b.call(h,{statusCode:0,error:y})}};d!=="sendBeacon"&&!h.preferSyncCompression&&h.data&&h.compression===ut.GZipJS&&qw&&typeof Promise<"u"&&!Ur?RA(h).then(v=>{m(v)}).catch(v=>{if(jh(v))return Ur=!0,void m(_(_({},h),{},{compression:void 0,url:Af(o.url,o.method,void 0,o.timestampMode)}));(b=>{if(!b||typeof b!="object")return!1;let y="name"in b?String(b.name):"";return jh(b)||y===Wg})(v)&&(Ur=!0),m(h)}):m(h)})(e,(o,a)=>{var l,c,u;t.rateLimiter.checkForLimiting(o),400>o.statusCode||(l=(c=t.config).on_request_error)===null||l===void 0||l.call(c,o),s?s(o,a):(u=e.callback)===null||u===void 0||u.call(e,o)})):e.fireCallbackOnDrop&&((r=e.callback)===null||r===void 0||r.call(e,{statusCode:0}))}function bv(){return(bv=he(function*(){let t=Le?.userAgentData;if(t?.getHighEntropyValues)try{let e=yield t.getHighEntropyValues(["model"]),s=e?.model;return H(s)&&s.length>0?s:void 0}catch(e){return void R.info("Unable to resolve $device_model from userAgentData.getHighEntropyValues",e)}})).apply(this,arguments)}function MA(t,e){let s=`$survey_${e}/${t.id}`;return t.current_iteration&&t.current_iteration>0&&(s=`$survey_${e}/${t.id}/${t.current_iteration}`),s}function Ev(t){var e;return!!(!((e=t.conditions)===null||e===void 0||(e=e.events)===null||e===void 0||(e=e.values)===null||e===void 0)&&e.length)}function Sv(t,e){return!t||Object.entries(t).every(([s,i])=>{let n=e?.[s];if(n==null)return!1;let r=wv[i.operator];return!!r&&r(i.values.map(String),[String(n)])})}function ll(t,e,s){return li({distinct_id:t,userPropertiesToSet:e,userPropertiesToSetOnce:s})}function fl(t,e){return e.length>t?e.slice(0,t)+"...":e}function eT(t){if(t.previousElementSibling)return t.previousElementSibling;let e=t;do e=e.previousSibling;while(e&&!Et(e));return e}function tT(t,{e,maskAllElementAttributes:s,maskAllText:i,elementAttributeIgnoreList:n,elementsChainAsString:r,disableCaptureUrlHashes:o}){var a,l;if(!Et(t))return{props:{}};let c=[t],u=new Set([t]),h=t;for(;h.parentNode&&!Ue(h,"body")&&1e3>c.length;){if(gc(h.parentNode)){let k=h.parentNode.host;if(u.has(k))break;u.add(k),c.push(k),h=k;continue}if(!Et(h.parentNode)||u.has(h.parentNode))break;u.add(h.parentNode),c.push(h.parentNode),h=h.parentNode}let d=e.type==="click"&&t.namespaceURI==="http://www.w3.org/2000/svg"?c.findIndex(k=>Ue(k,"button")||Ue(k,"a")):-1;d>0&&(i=i||c.slice(0,d+1).some(k=>!Ms(k)||pi(k)));let g=[],p={},m,v=!1,b=!1;if(re(c,k=>{let $=Ms(k);if(Ue(k,"a")&&!s&&!n?.includes("href")){let O=k.getAttribute("href");v=!!($&&O&&di(O))&&(o?ds(O):O)}M(gi(k),"ph-no-capture")&&(b=!0),g.push((function(O,x,Y,X,Z=!1){let ae=O.tagName.toLowerCase(),D={tag_name:ae};vc.indexOf(ae)>-1&&!Y&&(D.$el_text=ae.toLowerCase()==="a"||ae.toLowerCase()==="button"?fl(1024,ff(O)):fl(1024,mn(O)));let K=gi(O);x||X?.includes("class")||0>=K.length||(D.classes=K.filter(function(P){return P!==""})),re(O.attributes,function(P){var U;if((!pi(O)||["name","id","class","aria-label"].indexOf(P.name)!==-1)&&!X?.includes(P.name)&&!x&&di(P.value)&&(!H(U=P.name)||U.substring(0,10)!=="_ngcontent"&&U.substring(0,7)!=="_nghost")){let V=P.value;P.name==="class"&&(V=pc(V).join(" ")),D["attr__"+P.name]=fl(1024,P.name==="href"&&Z?ds(V):V)}});let q=1,ie=1,Q=O;for(;Q=eT(Q);)q++,Q.tagName===O.tagName&&ie++;return D.nth_child=q,D.nth_of_type=ie,D})(k,s,i,n,o)),re((function(O){if(!Ms(O))return{};let x={};return re(O.attributes,function(Y){if(Y.name&&Y.name.indexOf("data-ph-capture-attribute")===0){let X=Y.name.replace("data-ph-capture-attribute-",""),Z=Y.value;X&&Z&&di(Z)&&(x[X]=Z)}}),x})(k),(O,x)=>{({}).hasOwnProperty.call(p,x)||(p[x]=O)})}),b)return{props:{},explicitNoCapture:b};if(d>0&&(t=c[d],g.splice(0,d)),i||(g[0].$el_text=Ue(t,"a")||Ue(t,"button")?ff(t):mn(t)),v){var y,w;g[0].attr__href=v;let k=(y=Kt(v))===null||y===void 0?void 0:y.host,$=E==null||(w=E.location)===null||w===void 0?void 0:w.host;k&&$&&k!==$&&(m=v)}return{props:ve((I=e.type,{$event_type:I,$ce_version:1}),r?{}:{$elements:g},{$elements_chain:(A=g,N(A)?(function(k){return k.map($=>{var O,x;let Y="";if($.tag_name&&(Y+=$.tag_name),$.attr_class){$.attr_class.sort();for(let ae of $.attr_class)Y+=`.${ae.replace(/"/g,"")}`}let X=_(_(_(_({},$.text?{text:$.text}:{}),{},{"nth-child":(O=$.nth_child)!==null&&O!==void 0?O:0,"nth-of-type":(x=$.nth_of_type)!==null&&x!==void 0?x:0},$.href?{href:$.href}:{}),$.attr_id?{attr_id:$.attr_id}:{}),$.attributes),Z={};return Fr(X).sort(([ae],[D])=>(function(K,q){return q>K?-1:K>q?1:0})(ae,D)).forEach(([ae,D])=>Z[gf(ae.toString())]=gf(D.toString())),Y+=":",Y+=Fr(Z).map(([ae,D])=>`${ae}="${D}"`).join(""),Y}).join(";")})((function(k){return k.map($=>{var O,x;let Y={text:(O=$.$el_text)===null||O===void 0?void 0:O.slice(0,400),tag_name:$.tag_name,href:(x=$.attr__href)===null||x===void 0?void 0:x.slice(0,2048),attr_class:aA($),attr_id:$.attr__id,nth_child:$.nth_child,nth_of_type:$.nth_of_type,attributes:{}};return Fr($).filter(([X])=>X.indexOf("attr__")===0).forEach(([X,Z])=>Y.attributes[X]=Z),Y})})(A)):"")},!((a=g[0])===null||a===void 0)&&a.$el_text?{$el_text:(l=g[0])===null||l===void 0?void 0:l.$el_text}:{},m&&e.type==="click"?{$external_click_url:m}:{},p),target:t};var A,I}function yi(t,e,s){try{if(!(e in t))return Mf;let i={next:t[e]},n=s(function(...r){return i.next.apply(this,r)});return Ce(n)&&(n.prototype=n.prototype||{},Object.defineProperties(n,{__posthog_wrapped__:{enumerable:!1,value:!0},__posthog_layer__:{enumerable:!1,value:i}})),t[e]=n,()=>{if(t[e]===n)return void(t[e]=i.next);let r=t[e],o=Ff(r);for(;o;){if(o.next===n)return void(o.next=i.next);r=o.next,o=Ff(r)}}}catch{return Mf}}function pl(t){return G(t)&&"clientX"in t&&"clientY"in t&&Te(t.clientX)&&Te(t.clientY)}function ni(t,e,s){if(B(t))return!1;switch(s){case"exact":return t===e;case"contains":{let 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 Zf(t,e){var s,i,n,r,o,a,l;let c=(s=t?.flushIntervalMs)!==null&&s!==void 0?s:3e3,u=(i=t?.maxBufferSize)!==null&&i!==void 0?i:100,h=e?.consoleCapture?void 0:(n=t?.maxLogsPerInterval)!==null&&n!==void 0?n:1e3,d=S(h)?Math.max(u,2048):Math.max(u,h),g=_(_({},(function(){let p="",m="";try{var v;let b="u">typeof globalThis?globalThis:"u">typeof window?window:void 0,y=b==null||(v=b.navigator)===null||v===void 0?void 0:v.userAgent;y&&([p,m]=Mg(y))}catch{}return(function(b,y){let w=(function(A){if(A)return{}.hasOwnProperty.call(qh,A)?qh[A]:A})(b);return _(_({},w?{"os.name":w}:{}),y?{"os.version":y}:{})})(p,m)})()),t?.resourceAttributes);return{serviceName:(r=(o=g?.["service.name"])!==null&&o!==void 0?o:t?.serviceName)!==null&&r!==void 0?r:e?.serviceNameDefault,serviceVersion:(a=g?.["service.version"])!==null&&a!==void 0?a:t?.serviceVersion,environment:(l=g?.["deployment.environment"])!==null&&l!==void 0?l:t?.environment,resourceAttributes:g,beforeSend:t?.beforeSend,flushIntervalMs:c,maxBufferSize:u,maxQueueSize:d,maxBatchRecordsPerPost:100,rateCapWindowMs:c,maxLogsPerInterval:h,backgroundFlushBudgetMs:0,terminationFlushBudgetMs:0}}function ig(t){if(t)return t===!0?{intent:!0,model:!0}:{intent:t.intent!==!1,model:t.model!==!1}}function yl(t,e){return{}.hasOwnProperty.call(t,e)}function bl(t,e){let s=Object.create(t);return e&&Object.defineProperty(s,"inputSchema",{configurable:!0,enumerable:!0,writable:!0,value:e}),s}function ng(t,e,s=!1){if(!H(t))return;let i=t.trim();return i?(s?dk(i,$T):i).slice(0,e):void 0}function rg(t){try{return G(t)&&t.isError===!0}catch{return!1}}var E,Ge,Le,T,pe,gn,Xl,Sh,qw,Ye,Gi,L,kh,Wt,It,El,Ww,Kw,hi,wl,ag,Zl,ao,N,Ce,G,nt,S,H,sn,we,B,Te,Gt,Je,Yw,Qw,Jw,Da,Xw,Zw,Ar,Th,eS,fi,pn,Vr,ug,dg,hg,$r,lo,fg,xr,gg,pg,vg,_g,mg,Dr,yg,jr,Gr,co,bg,Eg,Na,wg,Ih,Sl,tS,Sg,kl,kg,Ag,Tg,Ig,Rg,Cg,Og,Al,Pg,$g,xg,Dg,Ma,Fa,sS,iS,nS,tc,rS,Ng,oS,aS,Rh,Mg,Fg,lS,La,Ch,Tl,En,Nr,Ug,cS,Hi,Dh,Nh,Js,hS,fS,gS,Gg,vS,_S,mS,yS,bS,ES,wS,Fh,IS,RS,CS,OS,PS,$S,xS,DS,NS,MS,Hr,zr,FS,Ua,LS,Lh,BS,Wg,Rl,Vh,jh,zi,Tr,VS,Gh,je,jS,GS,HS,zS,qS,WS,KS,Yg,YS,Qg,Jg,QS,JS,XS,ZS,ek,tk,sk,ik,nk,rk,Hh,ok,ak,gk,vk,qh,sp,_k,rp,bk,ja,Ek,lp,R,ye,wk,Yr,Ps,Ga,Yh,it,Pl,zt,Ds,vn,us,Ns,rn,yt,os,as,ls,Zi,cs,Tt,$s,_n,Sk,mt,rc,Ha,Qr,kk,Qh,ui,Jh,on,$l,cp,xl,Dl,up,Nl,Ml,oc,ac,dp,hp,an,Ak,Tk,Ik,Rk,Ck,Ok,ri,fp,Pk,$k,xk,Dk,Nk,gp,en,Jr,pp,vp,_p,Fl,Mk,Fk,Lk,Uk,Bk,Vk,Qe,Ll,jk,mp,yp,oi,lc,za,bp,Ep,wp,cc,uc,Sp,kp,Ap,Tp,Ip,Rp,Cp,Gk,dc,qt,Mr,Op,Xr,hc,Xh,Pp,Zh,ve,Hk,fc,zk,ln,Wk,Kk,xp,Yk,ef,bt,Qk,qi,Jk,Xs,Ee,qa,J,Wa,xs,Zr,Xk,Ka,Ya,Dp,tf,sf,Qa,Zs,Vl,Ts,de,Zk,vc,Ja,Up,_c,of,eA,tA,af,sA,lf,iA,mc,Vp,cf,uf,nA,rA,df,hf,Ir,lA,cA,pf,Wi,Gp,uA,_f,Ki,dA,hA,Ne,qp,Wp,Kp,li,Kt,vi,yn,eo,_i,fA,bn,gA,to,_A,mA,Rr,Cr,Pe,Ht,Za,sv,mf,is,ei,yf,el,ut,Yi,tl,ct,sl,Hl,yA,bf,Ef,bA,ns,iv,dt,Xe,mi,yc,bc,wf,nv,rv,zl,Is,ql,so,me,un,Fs,io,EA,wA,ov,av,Vt,Qi,nl,Wl,Sf,Ji,Lr,kf,SA,kA,AA,rl,IA,lv,cv,ol,Ur,uv,wn,al,dv,hv,RA,CA,fv,gv,pv,vv,Kl,Af,OA,_v,PA,$A,xA,DA,NA,Tf,no,ti,If,Rf,yv,ro,Or,wv,Yl,Cf,FA,LA,UA,ne,kv,BA,VA,jA,GA,HA,Av,Tv,Iv,Rv,zA,qA,dn,cl,hn,Of,si,Pf,Cv,WA,KA,$f,YA,xf,Df,QA,tn,JA,ul,XA,Nf,ZA,fn,Ov,dl,hl,sT,iT,Xi,Mf,Ff,nT,Rs,Lf,Uf,rT,oT,gl,Bf,jt,aT,lT,Pr,vl,cT,At,Vf,Ec,ii,jf,uT,dT,hT,fT,gT,pT,vT,Gf,Hf,zf,Cs,_l,_T,qf,Wf,Kf,Yf,mT,Qf,yT,Jf,_t,Ql,bT,ET,wT,Xf,ST,gt,Os,kT,AT,eg,Pv,ml,tg,TT,oo,wc,IT,RT,$v,Jl,xv,CT,OT,sg,PT,$T,uo,xT,DT,NT,MT,FT,LT,UT,BT,VT,jT,GT,HT,zT,qT,Oe,Dv=Ze(()=>{"use strict";E="u">typeof window?window:void 0,Ge="u">typeof globalThis?globalThis:E,Le=Ge?.navigator,T=Ge?.document,pe=Ge?.location,gn=Ge?.fetch,Xl=Ge?.XMLHttpRequest&&"withCredentials"in new Ge.XMLHttpRequest?Ge.XMLHttpRequest:void 0,Sh=Ge?.AbortController,qw=Ge?.CompressionStream,Ye=Le?.userAgent,Gi=typeof globalThis<"u"?globalThis:E;Gi&&typeof self>"u"&&(Gi.self=Gi),Gi&&typeof File>"u"&&(Gi.File=function(){});L=E??{},kh="0.9.4",Wt={DEBUG:!1,LIB_VERSION:kh,LIB_NAME:"browser-common",JS_SDK_VERSION:kh},It=(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.SurveysInProgress="surveys_in_progress",t.SurveysSeen="surveys_seen",t.Surveys="surveys",t.RemoteConfig="remote_config",t.FlagsEndpointWasHit="flags_endpoint_was_hit",t.DeviceId="device_id",t})({}),El=(function(t){return t.GZipJS="gzip-js",t.Base64="base64",t})({}),Ww=["$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"],Kw=["token"];hi=function(t){return t.trim()},wl=function(t){return t.replace(/^\$/,"")};ag=Object.prototype,Zl=ag.hasOwnProperty,ao=ag.toString,N=Array.isArray||function(t){return ao.call(t)==="[object Array]"},Ce=t=>typeof t=="function",G=t=>t===Object(t)&&!N(t),nt=t=>{if(G(t)){for(let e in t)if(Zl.call(t,e))return!1;return!0}return!1},S=t=>t===void 0,H=t=>ao.call(t)=="[object String]",sn=t=>H(t)&&t.trim().length===0,we=t=>t===null,B=t=>S(t)||we(t),Te=t=>ao.call(t)=="[object Number]"&&t==t,Gt=t=>Te(t)&&t>0,Je=t=>ao.call(t)==="[object Boolean]",Yw=t=>M(Ww,t),Qw=t=>M(Kw,t);Jw=[!0,"true",1,"1","yes"],Da=t=>M(Jw,t),Xw=[!1,"false",0,"0","no"];Zw=["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"],Ar=new Map,Th=function(t,e=[]){if(!t)return!1;let s=(function(o,a){let l="";for(let c=0;a.length>c;c++){let u=a[c];l+=u.length+":"+u}return o.length+":"+o+"|"+a.length+":"+l})(t,e),i=Ar.get(s);if(i!==void 0)return i;let n=t.toLowerCase(),r=Zw.concat(e).some(o=>n.indexOf(o.toLowerCase())!==-1);return 256>Ar.size||Ar.clear(),Ar.set(s,r),r};eS=class{constructor(t){this.C={},this.I=t.I,this.R=Rt(t.bucketSize,0,100,t.A),this.$=Rt(t.refillRate,0,this.R,t.A),this.O=Rt(t.refillInterval,0,864e5,t.A)}F(t,e){let s=Math.floor((e-t.lastAccess)/this.O);s>0&&(t.tokens=Math.min(t.tokens+s*this.$,this.R),t.lastAccess=t.lastAccess+s*this.O)}consumeRateLimit(t){var e;let s=Date.now(),i=String(t),n=this.C[i];return n?this.F(n,s):(n={tokens:this.R,lastAccess:s},this.C[i]=n),n.tokens===0||(n.tokens--,n.tokens===0&&((e=this.I)===null||e===void 0||e.call(this,t)),n.tokens===0)}stop(){this.C={}}},fi="Mobile",pn="Android",Vr="Tablet",ug="Android Tablet",dg="iPad",hg="Apple Watch",$r="Safari",lo="BlackBerry",fg="Samsung Internet",xr="Chrome",gg="Chrome iOS",pg="Internet Explorer",vg="Internet Explorer Mobile",_g="Opera",mg="Microsoft Edge",Dr="Firefox",yg="Firefox iOS",jr="Nintendo",Gr="PlayStation",co="Xbox",bg="Android Mobile",Eg="Mobile Safari",Na="Windows",wg="Windows Phone",Ih="Nokia",Sl="Ouya",tS="Generic "+fi.toLowerCase(),Sg="Generic "+Vr.toLowerCase(),kl="Konqueror",kg="Oculus Browser",Ag="Vivaldi",Tg="Yandex",Ig="Whale",Rg="DuckDuckGo",Cg="Pale Moon",Og="Waterfox",Al="Brave",Pg="Claude",$g="Codex",xg="ChatGPT",Dg="Google Search App",Ma=new RegExp("Version/(\\d+(\\.\\d+)?)"),Fa=new RegExp("(Claude|Codex|ChatGPT)\\/(\\d+(\\.\\d+)?)"),sS=new RegExp(co,"i"),iS=new RegExp("PlayStation \\w+","i"),nS=new RegExp("Nintendo \\w+","i"),tc=new RegExp("BlackBerry|PlayBook|BB10","i"),rS={"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"},Ng=function(t,e,s,i){return e=e||"",(function(r){return r?.brave?Al:null})(s)||(i?.detectGoogleSearchApp&&M(t,"GSA/")?Dg:M(t," OPR/")&&M(t,"Mini")?"Opera Mini":M(t," OPR/")?_g:tc.test(t)?lo:M(t,"IEMobile")||M(t,"WPDesktop")?vg:M(t,"OculusBrowser")?kg:M(t,"SamsungBrowser")?fg:M(t,"Edge")||M(t,"Edg/")?mg:M(t,"Vivaldi/")?Ag:M(t,"YaBrowser/")?Tg:M(t,"Whale/")?Ig:M(t,"DuckDuckGo/")||M(t,"Ddg/")?Rg:M(t,"Claude/")?Pg:M(t,"Codex/")?$g:M(t,"ChatGPT/")?xg:M(t,"FBIOS")?"Facebook Mobile":M(t,"UCWEB")||M(t,"UCBrowser")?"UC Browser":M(t,"CriOS")?gg:M(t,"CrMo")||M(t,xr)?xr:M(t,pn)&&M(t,$r)?bg:M(t,"FxiOS")?yg:M(t.toLowerCase(),kl.toLowerCase())?kl:M(t,"Brave/")?Al:((r,o)=>o&&M(o,"Apple")||(function(a){return M(a,$r)&&!M(a,xr)&&!M(a,pn)})(r))(t,e)?M(t,fi)?Eg:$r:M(t,"PaleMoon/")?Cg:M(t,"Waterfox/")?Og:M(t,Dr)?Dr:M(t,"MSIE")||M(t,"Trident/")?pg:M(t,"Gecko")?Dr:"")},oS={[vg]:[new RegExp("rv:(\\d+(\\.\\d+)?)")],[mg]:[new RegExp("Edge?\\/(\\d+(\\.\\d+)?)")],[xr]:[new RegExp("(Chrome|CrMo)\\/(\\d+(\\.\\d+)?)")],[gg]:[new RegExp("CriOS\\/(\\d+(\\.\\d+)?)")],"UC Browser":[new RegExp("(UCBrowser|UCWEB)\\/(\\d+(\\.\\d+)?)")],[$r]:[Ma],[Eg]:[Ma],[_g]:[new RegExp("(Opera|OPR)\\/(\\d+(\\.\\d+)?)")],[Dr]:[new RegExp("Firefox\\/(\\d+(\\.\\d+)?)")],[yg]:[new RegExp("FxiOS\\/(\\d+(\\.\\d+)?)")],[kl]:[new RegExp("Konqueror[:/]?(\\d+(\\.\\d+)?)","i")],[lo]:[new RegExp("BlackBerry (\\d+(\\.\\d+)?)"),Ma],[bg]:[new RegExp("android\\s(\\d+(\\.\\d+)?)","i")],[fg]:[new RegExp("SamsungBrowser\\/(\\d+(\\.\\d+)?)")],[kg]:[new RegExp("OculusBrowser\\/(\\d+(\\.\\d+)?)")],[Ag]:[new RegExp("Vivaldi\\/(\\d+(\\.\\d+)?)")],[Tg]:[new RegExp("YaBrowser\\/(\\d+(\\.\\d+)?)")],[Ig]:[new RegExp("Whale\\/(\\d+(\\.\\d+)?)")],[Al]:[new RegExp("Brave\\/(\\d+(\\.\\d+)?)")],[Pg]:[Fa],[$g]:[Fa],[xg]:[Fa],[Rg]:[new RegExp("(DuckDuckGo|Ddg)\\/(\\d+(\\.\\d+)?)")],[Cg]:[new RegExp("PaleMoon\\/(\\d+(\\.\\d+)?)")],[Og]:[new RegExp("Waterfox\\/(\\d+(\\.\\d+)?)")],[Dg]:[new RegExp("GSA\\/(\\d+(\\.\\d+)?)")],[pg]:[new RegExp("(rv:|MSIE )(\\d+(\\.\\d+)?)")],Mozilla:[new RegExp("rv:(\\d+(\\.\\d+)?)")]},aS=function(t,e,s,i){let n=Ng(t,e,s,i),r=oS[n];if(S(r))return null;for(let o=0;r.length>o;o++){let a=t.match(r[o]);if(a)return parseFloat(a[a.length-2])}return null},Rh=[[new RegExp("Xbox; Xbox (.*?)[);]","i"),t=>[co,t&&t[1]||""]],[new RegExp(jr,"i"),[jr,""]],[new RegExp(Gr,"i"),[Gr,""]],[tc,[lo,""]],[new RegExp(Na,"i"),(t,e)=>{if(/Phone/.test(e)||/WPDesktop/.test(e))return[wg,""];if(new RegExp(fi).test(e)&&!/IEMobile\b/.test(e))return["Windows Mobile",""];let s=/Windows NT ([0-9.]+)/i.exec(e);if(s&&s[1]){let i=rS[s[1]]||"";return/arm/i.test(e)&&(i="RT"),[Na,i]}return[Na,""]}],[/((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=>{let 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]?[pn,[t[2],t[3],t[4]||"0"].join(".")]:[pn,""]],[/Mac OS X (\d+)[_.](\d+)[_.]?(\d+)?/i,t=>{let 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",""]]],Mg=function(t){for(let e=0;Rh.length>e;e++){let[s,i]=Rh[e],n=s.exec(t),r=n&&(Ce(i)?i(n,t):i);if(r)return r}return["",""]},Fg=function(t){return nS.test(t)?jr:iS.test(t)?Gr:sS.test(t)?co:new RegExp(Sl,"i").test(t)?Sl:new RegExp("(Windows Phone|WPDesktop)","i").test(t)?wg:/iPad/.test(t)?dg:/iPod/.test(t)?"iPod Touch":/iPhone/.test(t)?"iPhone":/(watch)(?: ?os[,/]|\d,\d\/)[\d.]+/i.test(t)?hg:tc.test(t)?lo:/(kobo)\s(ereader|touch)/i.test(t)?"Kobo":new RegExp(Ih,"i").test(t)?Ih:/(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(fi).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)?pn:ug:new RegExp("(pda|Mobile)","i").test(t)?tS:new RegExp(Vr,"i").test(t)&&!new RegExp("Tablet pc","i").test(t)?Sg:""},lS=function(t,e){var s;let i=Fg(t);return i===dg||i===ug||i==="Kobo"||i==="Kindle Fire"||i===Sg?Vr:i===jr||i===co||i===Gr||i===Sl?"Console":i===hg?"Wearable":i?fi:e?.userAgentDataPlatform==="Android"&&((s=e?.maxTouchPoints)!==null&&s!==void 0?s:0)>0?600>Math.min((n=e?.screenWidth)!==null&&n!==void 0?n:0,(r=e?.screenHeight)!==null&&r!==void 0?r:0)/((o=e?.devicePixelRatio)!==null&&o!==void 0?o:1)?fi:Vr:"Desktop";var n,r,o},La=/\bFBAV\/(\d+(?:\.\d+)*)/i,Ch=[[/\bInstagram(?:[ /](\d+(?:\.\d+)*))?\b/i,"Instagram"],[/\bBarcelona[ /](\d+(?:\.\d+)*)?/i,"Threads"],[/\b(?:MessengerForiOS|(?:FBAN|FB_IAB)\/Orca-Android)\b/i,"Messenger",La],[/\bFBAN\/EMA\b/i,"Facebook Lite",La],[/\b(?:FBIOS|(?:FBAN|FB_IAB)\/(?:FB4A|FBIOS))\b/i,"Facebook",La],[/\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"]],Tl="[Truncated]",En="[Unserializable]";Nr=3e5,Ug=class{record(t){if(t.kind==="too-large")return;if(t.kind!=="retry-later")return void this.reset();if(!t.retryAfterMs)return;let e=this.isOpen(),s=Date.now(),i=Math.min(t.retryAfterMs,Nr);if(!e)return this.ts=s,void(this.es=s+i);this.es=Math.max(this.es,Math.min(s+i,this.ts+Nr))}remainingMs(){let t=Date.now();if(this.ts-5e3>t)return this.reset(),0;let e=Math.min(Nr,Math.max(0,this.es-t));return e===0&&this.reset(),e}isOpen(){return this.remainingMs()>0}reset(){this.es=0,this.ts=0}constructor(){this.es=0,this.ts=0}},cS=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;hS=class{constructor(t,e,s=[]){this.coercers=t,this.stackParser=e,this.modifiers=s}buildFromUnknown(t,e={}){let s=e&&e.mechanism||{handled:!0,type:"generic"},i=this.buildCoercingContext(s,e,0).apply(t),n=this.buildParsingContext(e),r=this.parseStacktrace(i,n);return{$exception_list:this.convertToExceptionList(r,s),$exception_level:"error"}}modifyFrames(t){var e=this;return he(function*(){for(let s of t)s.stacktrace&&s.stacktrace.frames&&N(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||e===void 0?void 0:e.stack,synthetic:!0}}parseStacktrace(t,e){var s;let i,n;if(t.cause!=null&&(i=this.parseStacktrace(t.cause,e)),t.stack!=""&&t.stack!=null)try{n=this.applyChunkIds(this.stackParser(t.stack,t.synthetic?e.skipFirstLines:0),e.chunkIdMap)}catch{}return _(_({},t),{},{cause:i,stack:n,errors:(s=t.errors)===null||s===void 0?void 0:s.map(r=>this.parseStacktrace(r,e))})}applyChunkIds(t,e){return t.map(s=>(s.filename&&e&&(s.chunk_id=e[s.filename]),s))}applyCoercers(t,e){for(let s of this.coercers)if(s.match(t))return s.coerce(t,e);return this.coerceFallback(e)}applyModifiers(t){var e=this;return he(function*(){let s=t;for(let i of e.modifiers)s=yield i(s);return s})()}convertToExceptionList(t,e){let s=[],i=(n,r,o)=>{var a;let l=s.length,c=r===void 0?_(_({type:typeof e.type=="string"&&e.type.length>0?e.type:"generic"},typeof e.handled=="boolean"?{handled:e.handled}:e.handled===void 0?{handled:!0}:{}),{},{synthetic:typeof e.synthetic=="boolean"?e.synthetic:n.synthetic,exception_id:l}):{type:"chained",source:o,synthetic:n.synthetic,exception_id:l,parent_id:r},u={type:n.type,value:n.value,mechanism:c};n.stack&&(u.stacktrace={type:"raw",frames:n.stack}),s.push(u),n.cause&&i(n.cause,l,"cause");for(let h of(a=n.errors)!==null&&a!==void 0?a:[])i(h,l,"member")};return i(t),s}buildParsingContext(t){var e;return{chunkIdMap:dS(this.stackParser),skipFirstLines:(e=t.skipFirstLines)!==null&&e!==void 0?e:1}}getAggregateErrors(t){try{if(bi(t)){let s=Object.getPrototypeOf(t);for(let i=0;s&&100>i;i++){var e;let n=(e=Object.getOwnPropertyDescriptor(s,"constructor"))===null||e===void 0?void 0:e.value;if(typeof n=="function"&&n.name==="AggregateError"){let r=t.errors;return N(r)?r:void 0}s=Object.getPrototypeOf(s)}}}catch{}}buildCoercingContext(t,e,s=0){let i=0,n=0,r=!1,o=new Set,a=[],l={},c=(d,g,p=0)=>{let m=u(g,p),v=m.apply;if(m.apply=k=>{a.push(d);try{return v(k)}finally{a.pop()}},p>4||p>0&&a.indexOf(d)!==-1)return this.coerceFallback(m);let b=typeof d=="object"&&d!==null||typeof d=="function";if(p===0&&i>=50||b&&o.has(d))return;b&&o.add(d),p===0&&i++;let y=this.getAggregateErrors(d),w,A;r||(r=!!y);try{if(w=this.applyCoercers(d,m),!w)throw l}catch(k){if(k===l)return void(p===0&&i--);if(!r)throw k;w=this.coerceFallback(m)}if(!y||i>=50)return w;try{A=y.length}catch{return w}if(!Number.isInteger(A)||0>A||A>4294967295)return w;let I=[];for(let k=0;50>i&&1e3>n&&A>k;k++){let $;n++;try{$=m.next(y[k])}catch{i++,$=this.coerceFallback(u(g+1))}$&&I.push($)}return _(_({},w),{},{errors:I})},u=(d,g=0)=>_(_({},e),{},{syntheticException:d==0?e.syntheticException:void 0,mechanism:d==0?t:{},apply(p){let m=c(p,d,g+1);if(!m)throw l;return m},next:p=>c(p,d+1)}),h=u(s);return _(_({},h),{},{apply:d=>{var g;return(g=c(d,s))!==null&&g!==void 0?g:this.coerceFallback(h)}})}},fS=/^([a-z][a-z0-9.+-]+):/i,gS=["http","https","file","blob","app","capacitor","ionic","webpack","webpack-internal","ng"];Gg=(t,e)=>{let 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]},vS=/^\s*at (\S+?)(?::(\d+))(?::(\d+))\s*$/i,_S=/^\s*at (?:(.+?\)(?: \[.+\])?|.*?) ?\((?:address at )?)?(?:async )?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,mS=/\((\S*)(?::(\d+))(?::(\d+))\)/,yS=(t,e)=>{let s=vS.exec(t);if(s){let[,n,r,o]=s;return Il(e,n,"?",+r,+o)}let i=_S.exec(t);if(i){if(i[2]&&i[2].indexOf("eval")===0){let o=mS.exec(i[2]);o&&(i[2]=o[1],i[3]=o[2],i[4]=o[3])}let[n,r]=Gg(i[1]||"?",i[2]);return Il(e,r,n,i[3]?+i[3]:void 0,i[4]?+i[4]:void 0)}},bS=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. /=]+)(?::(\d+))?(?::(\d+))?\s*$/i,ES=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,wS=(t,e)=>{let s=bS.exec(t);if(s){if(s[3]&&s[3].indexOf(" > eval")>-1){let r=ES.exec(s[3]);r&&(s[1]=s[1]||"eval",s[3]=r[1],s[4]=r[2],s[5]="")}let i=s[3],n=s[1]||"?";return[n,i]=Gg(n,i),Il(e,i,n,s[4]?+s[4]:void 0,s[5]?+s[5]:void 0)}},Fh=/\(error: (.*)\)/;IS=class{match(t){return this.isDOMException(t)||this.isDOMError(t)}coerce(t,e){let s=H(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){let e=t.name||(this.isDOMError(t)?"DOMError":"DOMException");return t.message?`${e}: ${t.message}`:e}isDOMException(t){return Br(t,"DOMException")}isDOMError(t){return Br(t,"DOMError")}},RS=class{match(t){return bi(t)}coerce(t,e){var s;let i=this.getStack(t),n=i===void 0?(s=e.syntheticException)===null||s===void 0?void 0:s.stack:void 0,r=!!n;return{type:this.getType(t),value:this.getMessage(t,e),stack:i??n,cause:t.cause?e.next(t.cause):void 0,synthetic:r}}getType(t){return t.name||t.constructor.name}getMessage(t,e){let s=t.message;return String(s.error&&typeof s.error.message=="string"?s.error.message:s)}getStack(t){try{let e=t.stacktrace;if(typeof e=="string"&&e.length>0)return e;let s=t.stack;return typeof s=="string"&&s.length>0?s:void 0}catch{return}}},CS=class{match(t){return!!Br(t,"ErrorEvent")&&(t.error!=null||this.ar(t))}coerce(t,e){var s;if(t.error!=null)return e.apply(t.error);let i=e.apply(t.message);return _(_({},i),{},{stack:(s=this.lr(t))!==null&&s!==void 0?s:i.stack,synthetic:!0})}ar(t){return H(t.message)&&t.message.length>0}lr(t){var e,s;let i=t,n=(e=i.lineno)!==null&&e!==void 0?e:0,r=(s=i.colno)!==null&&s!==void 0?s:0;if(H(i.filename)&&i.filename.length!==0&&n!==0)return`Error
|
|
6
|
+
at ${i.filename}:${n}:${r}`}},OS=/^(?:[Uu]ncaught (?:exception: )?)?(?:((?:Eval|Internal|Range|Reference|Syntax|Type|URI|)Error): )?(.*)$/i,PS=class{match(t){return typeof t=="string"}coerce(t,e){var s;let[i,n]=this.getInfos(t);return{type:i??"Error",value:n??t,stack:(s=e.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}getInfos(t){let e="Error",s=t,i=t.match(OS);return i&&(e=i[1],s=i[2]),[e,s]}},$S=["fatal","error","warning","log","info","debug"];xS=class{match(t){return typeof t=="object"&&t!==null}coerce(t,e){var s,i;let n=this.getErrorPropertyFromObject(t);return n?e.apply(n):{type:this.getType(t),value:this.getValue(t),stack:(s=this.getStack(t))!==null&&s!==void 0?s:(i=e.syntheticException)===null||i===void 0?void 0:i.stack,level:this.isSeverityLevel(t.level)?t.level:"error",synthetic:!0}}getType(t){if(ec(t))return t.constructor.name;let e="name"in t?t.name:void 0;return H(e)&&!sn(e)?e:"Error"}getValue(t){if("name"in t&&typeof t.name=="string"){let s=`'${t.name}' captured as exception`;return"message"in t&&typeof t.message=="string"&&(s+=` with message: '${t.message}'`),s}if("message"in t&&typeof t.message=="string")return t.message;let e=this.getObjectClassName(t);return`${e&&e!=="Object"?`'${e}'`:"Object"} captured as exception with keys: ${qg(t)}`}isSeverityLevel(t){return H(t)&&!sn(t)&&$S.indexOf(t)>=0}getStack(t){try{return H(t.stacktrace)&&t.stacktrace.length>0?t.stacktrace:H(t.stack)&&t.stack.length>0?t.stack:void 0}catch{return}}getErrorPropertyFromObject(t){for(let e in t)if({}.hasOwnProperty.call(t,e)){let s=t[e];if(bi(s))return s}}getObjectClassName(t){try{let e=Object.getPrototypeOf(t);return e?e.constructor.name:void 0}catch{return}}},DS=class{match(t){return ec(t)}coerce(t,e){var s;let i=t.constructor.name;return{type:i,value:`${i} captured as exception with keys: ${qg(t)}`,stack:(s=e.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},NS=class{match(t){return lg(t)}coerce(t,e){var s;return{type:"Error",value:`Primitive value captured as exception: ${String(t)}`,stack:(s=e.syntheticException)===null||s===void 0?void 0:s.stack,synthetic:!0}}},MS=class{match(t){return Br(t,"PromiseRejectionEvent")||this.isCustomEventWrappingRejection(t)}isCustomEventWrappingRejection(t){if(!ec(t))return!1;try{let e=t.detail;return e!=null&&typeof e=="object"&&"reason"in e}catch{return!1}}coerce(t,e){var s;let i=this.getUnhandledRejectionReason(t);return lg(i)?{type:"UnhandledRejection",value:`Non-Error promise rejection captured with value: ${String(i)}`,stack:(s=e.syntheticException)===null||s===void 0?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}},Hr="$message",zr="$timestamp",FS=new Set([Hr,zr]),Ua={enabled:!0,max_bytes:32768};LS=class{constructor(t){this.ns=[],this.ss=0,this.Mr=qr(t)}setConfig(t){this.Mr=qr(t),this.rs()}add(t){let e=(function(i){let n;try{n=og(i)}catch{return}try{let r=JSON.parse(n);if(!G(r))return;let o=r,a=o[Hr],l=o[zr];return!H(a)||a.trim().length===0||!H(l)&&!Te(l)?void 0:{step:o,json:n}}catch{return}})(t);if(!e)return;let s=(function(i){if("u">typeof TextEncoder)return new TextEncoder().encode(i).length;let n=encodeURIComponent(i),r=0;for(let o=0;n.length>o;o++)n[o]==="%"?(r+=1,o+=2):r+=1;return r})(e.json);s>this.Mr.max_bytes||(this.ns.push({step:e.step,bytes:s}),this.ss+=s,this.rs())}getAttachable(){return this.ns.map(t=>t.step)}clear(){this.ns=[],this.ss=0}size(){return this.ns.length}rs(){for(;this.ss>this.Mr.max_bytes&&this.ns.length>0;){let t=this.ns.shift();t&&(this.ss-=t.bytes)}}};Lh=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","oppref","irclid","_kx","$session_id","$window_id","$lib","$lib_version","$device_id","$is_server"],Wg="NativeGzipValidationError",Rl=t=>t.length>=2&&t[0]===31&&t[1]===139,Vh=(t,e)=>t===El.GZipJS||e===El.GZipJS||e==="gzip",jh=t=>!(!t||typeof t!="object")&&("name"in t?String(t.name):"")==="NotReadableError",Tr=t=>{throw Bg(Wg,`Native gzip produced invalid output: ${t}`)},VS=(Gh=he(function*(t,e){18>t.size&&Tr("too-short");let s=new Uint8Array(yield t.slice(0,10).arrayBuffer());Rl(s)&&s[2]===8||Tr("invalid-header");let i=new DataView(yield t.slice(t.size-8).arrayBuffer());i.getUint32(0,!0)!==(r=>{let o=(()=>{if(zi)return zi;zi=[];for(let l=0;256>l;l++){let c=l;for(let u=0;8>u;u++)c=1&c?3988292384^c>>>1:c>>>1;zi[l]=c>>>0}return zi})(),a=4294967295;for(let l=0;r.length>l;l++)a=o[255&(a^r[l])]^a>>>8;return(4294967295^a)>>>0})(e)&&Tr("invalid-crc");let n=e.length>>>0;i.getUint32(4,!0)!==n&&Tr("invalid-size")}),function(t,e){return Gh.apply(this,arguments)});je="[redacted]",jS=/^[A-Za-z0-9+/\n\r]+=*$/,GS=/^[A-Za-z0-9_-]+={0,2}$/,HS=/[-_]/,zS=/^data:[^,\s]*;base64,/i,qS=/^[A-Za-z0-9+/_-]+={0,2}$/,WS=/\bph[a-z]_[A-Za-z0-9_-]{20,}\b/g,KS=/^(authorization|cookie|set-cookie|x-api-key|api[-_]?key|api[-_]?token|access[-_]?token|refresh[-_]?token|token|password|secret|client[-_]?secret|private[-_]?key)$/i,Yg=/[a-z][a-z0-9+.-]{0,63}:[^\s<>"]+/gi,YS=/[\s<>"]/,Qg=new RegExp(Yg.source,"i"),Jg=/[a-z][a-z0-9+.-]{0,63}:\/\//i,QS=new RegExp(`^${Jg.source}`,"i"),JS=new RegExp(Jg.source,"gi"),XS=/(^|[-_./;])(auth|token|secret|password|passwd|pwd|credential|signature|sig|key|hmac|sas|bearer|jwt|session|sessionid)([-_./;]|$)/i,ZS=/^(code|AWSAccessKeyId|GoogleAccessId|Policy)$/i,ek=/[\u00A0\u1680\u2000-\u200A\u202F\u205F\u3000]/g,tk=/[A-Za-z0-9._%+-]{1,64}@[A-Za-z0-9.-]{1,255}\.[A-Za-z]{2,24}/g,sk=/\b(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\b/g,ik=/(^|[^\w:])((?:(?:[0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4}|(?:[0-9A-Fa-f]{1,4}:){1,7}:|(?:[0-9A-Fa-f]{1,4}:){1,6}:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,5}|::(?:[0-9A-Fa-f]{1,4}(?::[0-9A-Fa-f]{1,4}){0,6})))(?=$|[^\w:])/g,nk=/\b\d{3}[ .-]\d{2}[ .-]\d{4}\b/g,rk=/\b\d(?:[ ./-]?\d){12,}\b/g,Hh=/\d+/g,ok=/(^|[^\w+])((?:\+?1[ ./-]?)?(?:\(\d{3}\)[ ./-]?|\d{3}[ ./-])\d{3}[ ./-]\d{4})(?![\w])/g,ak=/(^|[^\w])(\+\d{1,3}(?:[ ./()-]{0,2}\d){7,13})(?![\w])/g;gk={}.propertyIsEnumerable;vk=["service.name","deployment.environment","service.version","telemetry.sdk.name","telemetry.sdk.version"];qh={darwin:"macOS",win32:"Windows",cygwin:"Windows",linux:"Linux",android:"Android",freebsd:"FreeBSD",openbsd:"OpenBSD",netbsd:"NetBSD",sunos:"SunOS",aix:"AIX",haiku:"Haiku","Mac OS X":"macOS"},sp={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}},_k=sp.info;rp=class{constructor(t){this.ls=t,this.us=0}get pending(){return!!this.cs}arm(t){this.clear(),this.us=Date.now()+t,this.cs=Vg(()=>{this.cs=void 0,this.ls()},t)}armNoEarlierThan(t){this.cs&&Date.now()+t<=this.us||this.arm(t)}clear(){this.cs&&(clearTimeout(this.cs),this.cs=void 0)}};bk=class{constructor(t,e,s,i,n,r=()=>Promise.resolve(),o){var a;this._instance=t,this.Mr=e,this.A=s,this.hs=i,this.ds=n,this.vs=r,this.fs=o,this.ps=new rp(()=>this.gs()),this.ys=null,this.bs=0,this._s=0,this.ws=new Ug,this.ks=0,this.Ss=1,this.xs=0,this.$s=0,this.Cs=!1,this.Ts=e.maxBufferSize,this.Is=Math.max((a=e.maxQueueSize)!==null&&a!==void 0?a:e.maxBufferSize,e.maxBufferSize),this.Ms=e.flushIntervalMs,this.Es=e.maxBatchRecordsPerPost,this.Ps=e.rateCapWindowMs,this.Rs=e.maxLogsPerInterval}clearQueue(){this._s++,this._instance.setPersistedProperty(It.LogsQueue,[])}reset(){this.ps.clear(),this.xs=0,this.$s=0,this.Cs=!1,this.ks=0,this.Ss=1,this.ws.reset(),this.Es=this.Mr.maxBatchRecordsPerPost}onReconnect(){this.ks=0,this.Ss=1,this.ws.isOpen()?this.As()&&this.Fs():this.gs()}captureLog(t,e){var s;if(this._instance.isDisabled||this._instance.optedOut||!t?.body)return;let i=this.Os(t);if(i===null)return;if(!i.body)return void this.A.info("Log was rejected in beforeSend function");if(!this.Ds())return;let n={record:yk(i,(s=e?.context)!==null&&s!==void 0?s:this.hs(),this.A,e?.occurredAtMs)};this.ds(()=>this.Ls(n))}Os(t){let e=this.Mr.beforeSend;if(!e)return t;let s=N(e)?e:[e],i=t;for(let n of s)try{let r=n(i);if(!r)return this.A.info("Log was rejected in beforeSend function"),null;i=r}catch(r){return this.A.error("Error in beforeSend function for log:",r),null}return i}Ds(){if(this.Rs===void 0)return!0;let t=Date.now(),e=t-this.xs;return this.Ps>e&&e>=0||(this.xs=t,this.$s=0,this.Cs=!1),this.Rs>this.$s?(this.$s++,!0):(this.Cs||(this.A.warn(`captureLog dropping logs: exceeded ${this.Rs} logs per ${this.Ps}ms`),this.Cs=!0),!1)}flush(){var t=this;return he(function*(){if(!t._instance.isDisabled)return t.ys||(t.ys=t.Ns().finally(()=>{t.ys=null})),t.ys})()}Ns(){var t=this;return he(function*(){var e;t.ps.clear();let s=(e=t._instance.getPersistedProperty(It.LogsQueue))!==null&&e!==void 0?e:[];if(s.length===0)return;let i=s.length,n=0;for(;s.length>0&&i>n;){var r,o;let a=t._s;t.bs=0;let l=Math.min(s.length,t.Es),c=s.slice(0,l),u=np(c.map(d=>d.record),t.qs(),(r=t.fs)!==null&&r!==void 0?r:t._instance.getLibraryId(),t._instance.getLibraryVersion()),h=yield t._instance.js(u);if(t._s!==a)return;if(h.kind==="too-large"&&c.length>1)t.Es=Math.max(1,Math.floor(c.length/2)),t.A.warn(`Logs batch of size ${c.length} was too large for the ingestion endpoint, reducing batch size to ${t.Es}`);else if(t.ws.record(h),t.ps.pending&&t.ps.arm(Math.max(t.Ms,t.ws.remainingMs())),h.kind==="retry-later"||(h.kind==="too-large"?t.A.warn("Dropping a single log record with batch size 1 \u2014 the record is larger than the server cap and cannot be split further."):h.kind==="ok"&&t.Mr.maxBatchRecordsPerPost>t.Es&&(t.Es=Math.min(t.Mr.maxBatchRecordsPerPost,t.Es+1)),yield t.Bs(c.length),s=(o=t._instance.getPersistedProperty(It.LogsQueue))!==null&&o!==void 0?o:[],n+=c.length,h.kind==="fatal"))throw h.error}})()}Bs(t){var e=this;return he(function*(){var s;let i=Math.max(0,t-e.bs),n=(s=e._instance.getPersistedProperty(It.LogsQueue))!==null&&s!==void 0?s:[];e._instance.setPersistedProperty(It.LogsQueue,n.slice(i)),yield e.vs()})()}qs(){return ip(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion())}Ls(t){var e;if(this._instance.optedOut)return;let s=(e=this._instance.getPersistedProperty(It.LogsQueue))!==null&&e!==void 0?e:[];this.Is>s.length||(s.shift(),this.bs++,this.A.info("Logs queue is full, dropping oldest record.")),s.push(t),this._instance.setPersistedProperty(It.LogsQueue,s),this.Ts>s.length||this.ws.isOpen()?this.Fs():this.gs()}Fs(){this.ps.pending||this.ps.arm(Math.max(this.Ms,this.ws.remainingMs()))}zs(){return Math.max(ap(this.Ms,this.ks,this.Ss,3e4),this.ws.remainingMs())}As(){let t=this._instance.getPersistedProperty(It.LogsQueue);return!!t&&t.length>0}shutdown(t){var e=this;return he(function*(){e.ps.clear();let s=e.flush().catch(()=>{});t!==void 0?yield $h(s,t):yield s})()}flushWithTimeout(t){var e=this;return he(function*(){let s=e.flush();yield $h(s,t,()=>{s.catch(()=>{})})})()}gs(){this.flush().then(()=>{this.ks=0,this.Ss=1},t=>{this.ks++,this.Ss=op(),this.A.error("PostHog logs flush failed:",t)}).finally(()=>{!this._instance.isDisabled&&this.As()&&this.ps.armNoEarlierThan(this.zs())})}},ja=[0,5,10,25,50,75,100,250,500,750,1e3,2500,5e3,7500,1e4];Ek=class{constructor(t,e,s){this._instance=t,this.Mr=e,this.A=s,this.Hs=new Map,this.ps=new rp(()=>this.flush().catch(i=>{this.A.error("Metrics flush failed:",i)})),this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.ws=new Ug,this.ks=0,this.Ss=1,this.Gs=0}count(t,e=1,s){this.Qs({name:t,type:"count",value:e,unit:s?.unit,attributes:s?.attributes})}gauge(t,e,s){this.Qs({name:t,type:"gauge",value:e,unit:s?.unit,attributes:s?.attributes})}histogram(t,e,s){this.Qs({name:t,type:"histogram",value:e,unit:s?.unit,attributes:s?.attributes})}flush(){var t=this;let e=this.ys,s=(function(){var i=he(function*(){e&&(yield e.catch(()=>{})),yield t.Zs()});return function(){return i.apply(this,arguments)}})()().finally(()=>{this.ys===s&&(this.ys=null)});return this.ys=s,s}drainWindow(){if(this.Hs.size===0)return null;let t=this.Hs;return this.Hs=new Map,this.Us=!1,this.Ws=new Map,this.Vs=new Set,this.Js(t)}reset(){this.Gs++,this.ws.reset(),this.ks=0,this.Ss=1,this.ps.clear(),this.Hs=new Map,this.ys=null,this.Us=!1,this.Ws=new Map,this.Vs=new Set}Qs(t){if(this._instance.isDisabled||this._instance.optedOut)return;let e=this.Os(t);if(e===null)return;if(!e.name||typeof e.name!="string")return void this.A.warn("Dropping metric with empty name");if(typeof e.value!="number"||!Number.isFinite(e.value))return void this.A.warn(`Dropping metric '${e.name}': value must be a finite number`);if(e.type==="count"&&0>e.value)return void this.A.warn(`Dropping count '${e.name}': counters are monotonic, value must be >= 0`);let s,i;try{s=e.attributes?_({},e.attributes):void 0,i=Kh(e.type,e.name,e.unit,s)}catch(o){return void this.A.warn(`Dropping metric '${e.name}': attributes could not be serialized`,o)}let n=this.Hs.get(i);if(!n){if(!this.Ks())return;n={name:e.name,type:e.type,unit:e.unit,attributes:s,windowStartMs:Date.now()},this.Hs.set(i,n)}let r=this.Ws.get(e.name);r===void 0?this.Ws.set(e.name,e.type):r===e.type||this.Vs.has(e.name)||(this.Vs.add(e.name),this.A.warn(`Metric name '${e.name}' is already used as a ${r}; recording it as a ${e.type} too will blend both series in charts. Use a distinct name.`)),this.Xs(n,e.value),this.Fs()}Ks(){return this.Mr.maxSeriesPerFlush>this.Hs.size||(this.Us||(this.Us=!0,this.A.warn(`Metric series cap reached (${this.Mr.maxSeriesPerFlush} per flush window); dropping new series until the next flush. Reduce attribute cardinality.`)),!1)}Xs(t,e){switch(t.type){case"count":var s;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(ja.length+1).fill(0)});let 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(n,r){for(let o=0;r.length>o;o++)if(r[o]>=n)return o;return r.length})(e,ja)]+=1;break}}}Os(t){let e=this.Mr.beforeSend;if(!e)return t;let s=N(e)?e:[e],i=t;for(let n of s)try{let r=n(i);if(!r)return this.A.info("Metric was rejected in beforeSend function"),null;i=r}catch(r){return this.A.error("Error in beforeSend function for metric:",r),null}return i}Fs(){this.ps.pending||this.ps.arm(this.zs())}zs(){return Math.max(ap(this.Mr.flushIntervalMs,this.ks,this.Ss,3e4),this.ws.remainingMs())}Zs(){var t=this;return he(function*(){if(t.ps.clear(),t.Hs.size===0)return;let e=t.Hs;t.Hs=new Map,t.Us=!1,t.Ws=new Map,t.Vs=new Set;let s=t.Gs,i=yield t._instance.Ys(t.Js(e));if(s===t.Gs)switch(t.ws.record(i),i.kind==="retry-later"?(t.ks++,t.Ss=op()):(t.ks=0,t.Ss=1),t.ps.pending&&t.ps.arm(t.zs()),i.kind){case"ok":return;case"retry-later":return t.co(e),void t.ps.armNoEarlierThan(t.zs());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)}})()}Js(t){return e=this.ho(t),s=(function(r,o,a){return ep(r,o,a)})(this.Mr,this._instance.getLibraryId(),this._instance.getLibraryVersion()),i=this._instance.getLibraryId(),n=this._instance.getLibraryVersion(),{resourceMetrics:[{resource:{attributes:tp(s)},scopeMetrics:[{scope:{name:i,version:n},metrics:e}]}]};var e,s,i,n}ho(t){let e=Wh(Date.now()),s=new Map;for(let o of t.values()){var i;let a=Kh(o.type,o.name,o.unit,void 0),l=s.get(a);l||(l=_({name:o.name},o.unit&&{unit:o.unit}),o.type==="count"?l.sum={aggregationTemporality:1,isMonotonic:!0,dataPoints:[]}:o.type==="gauge"?l.gauge={dataPoints:[]}:l.histogram={aggregationTemporality:1,dataPoints:[]},s.set(a,l));let c=Kr((i=o.attributes)!==null&&i!==void 0?i:{},this.A),u=Wh(o.windowStartMs);if(o.type==="count"){var n;let h={attributes:c,startTimeUnixNano:u,timeUnixNano:e,asDouble:(n=o.total)!==null&&n!==void 0?n:0};l.sum.dataPoints.push(h)}else if(o.type==="gauge"){var r;let h={attributes:c,timeUnixNano:e,asDouble:(r=o.last)!==null&&r!==void 0?r:0};l.gauge.dataPoints.push(h)}else o.hist&&l.histogram.dataPoints.push({attributes:c,startTimeUnixNano:u,timeUnixNano:e,count:o.hist.count,sum:o.hist.sum,min:o.hist.min,max:o.hist.max,bucketCounts:o.hist.bucketCounts,explicitBounds:ja})}return Array.from(s.values())}co(t){for(let[i,n]of t){let r=this.Hs.get(i);if(r)switch(r.windowStartMs=Math.min(r.windowStartMs,n.windowStartMs),r.type){case"count":var e,s;r.total=((e=r.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(r.hist){r.hist.count+=n.hist.count,r.hist.sum+=n.hist.sum,r.hist.min=Math.min(r.hist.min,n.hist.min),r.hist.max=Math.max(r.hist.max,n.hist.max);for(let o=0;r.hist.bucketCounts.length>o;o++)r.hist.bucketCounts[o]+=n.hist.bucketCounts[o]}else r.hist=n.hist}else this.Ks()&&this.Hs.set(i,n)}}},lp=(t,{debugEnabled:e}={})=>{let s={N(i,...n){let r;try{r=typeof window>"u"?void 0:window}catch{return}r&&(Wt.DEBUG||r.POSTHOG_DEBUG||e)&&!S(r.console)&&r.console&&("__rrweb_original__"in r.console[i]?r.console[i].__rrweb_original__:r.console[i])(t,...n)},debug(...i){s.N("debug",...i)},info(...i){s.N("log",...i)},warn(...i){s.N("warn",...i)},error(...i){s.N("error",...i)},critical(...i){console.error(t,...i)},uninitializedWarning(i){s.error(`You must initialize PostHog before calling ${i}`)},createLogger:(i,n)=>lp(`${t} ${i}`,n)};return s},R=lp("[PostHog.js]"),ye=R.createLogger,wk=ye("[ExternalScriptsLoader]"),Yr=t=>{let e=T?.querySelectorAll("script");if(e){for(let s=0;e.length>s;s++)if(e[s].src===t||e[s].getAttribute("src")===t)return e[s]}},Ps=(t,e,s)=>{if(t.config.disable_external_dependency_loading)return wk.warn(`${e} was requested but loading of external scripts is disabled.`),s("Loading of external scripts is disabled");let i=Yr(e);if(i){if(i.__posthog_loading_callback_fired)return s();let 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)}))}let n=()=>{if(!T)return s("document not found");if(Yr(e))return Ps(t,e,s);let r=T.createElement("script");if(r.type="text/javascript",r.crossOrigin="anonymous",r.src=e,r.onload=a=>{r.__posthog_loading_callback_fired=!0,s(void 0,a)},r.onerror=a=>{r.__posthog_loading_error=a,s(a)},t.config.prepare_external_dependency_script&&(r=t.config.prepare_external_dependency_script(r)),!r)return s("prepare_external_dependency_script returned null");if(t.config.external_scripts_inject_target==="head")T.head.appendChild(r);else{let a=T.querySelectorAll("body > script");var o;a.length>0?(o=a[0].parentNode)===null||o===void 0||o.insertBefore(r,a[0]):T.body.appendChild(r)}};T?.body?n():T?.addEventListener("DOMContentLoaded",n)},Ga={},Yh=(t,e)=>{let s=`/static/${e}.js?v=${t.version}`;return e==="toolbar"&&(s=`${s}&t=${Math.floor(Date.now()/3e5)*3e5}`),t.requestRouter.endpointFor("assets",s)};L.__PosthogExtensions__=L.__PosthogExtensions__||{},L.__PosthogExtensions__.loadExternalDependency=(t,e,s)=>{if(e==="remote-config"){let n=t.requestRouter.endpointFor("assets",`/array/${t.config.token}/config.js`);return void Ps(t,n,s)}let i=t.config.strict_script_versioning;if(i){let n=t.requestRouter.endpointFor("assets",`/static/${t.version}/${e}.js`),r=Ga[n];if(i==="fallback"&&r){if(Yr(r))return void Ps(t,r,s);delete Ga[n]}return void Ps(t,n,i==="fallback"?(o,a)=>{if(o)if(typeof o=="string")s(o);else{var l;let c=Yh(t,e);Ga[n]=c;let u=Yr(n);u==null||(l=u.parentNode)===null||l===void 0||l.removeChild(u),Ps(t,c,s)}else s(void 0,a)}:s)}Ps(t,Yh(t,e),s)},L.__PosthogExtensions__.loadSiteApp=(t,e,s)=>{let i=t.requestRouter.endpointFor("api",e);Ps(t,i,s)},Wt.DEBUG=!1,Wt.LIB_VERSION="1.438.7",Wt.LIB_NAME="web";it=Wt,Pl="$early_access_features",zt="$active_feature_flags",Ds="$feature_flag_details",vn="$feature_flag_errors",us="$feature_flag_evaluated_at",Ns="$feature_flag_request_id",rn="$minimal_flag_called_events",yt="$enabled_feature_flags",os="$stored_group_properties",as="$stored_person_properties",ls="$flag_call_reported",Zi="$flag_call_reported_session_id",cs="$feature_flag_payloads",Tt="$override_feature_flags",$s="$override_feature_flag_payloads",_n="visibilitychange",Sk="$people_distinct_id",mt="distinct_id",rc="$device_id",Ha="$device_model",Qr="__alias",kk="__cmpns",Qh="$fbc",ui="$fbc_persistence",Jh="$fbp",on="$fbp_persistence",$l="__timers",cp="$autocapture_disabled_server_side",xl="$heatmaps_enabled_server_side",Dl="$exception_capture_enabled_server_side",up="$error_tracking_suppression_rules",Nl="$error_tracking_capture_extension_exceptions",Ml="$web_vitals_enabled_server_side",oc="$dead_clicks_enabled_server_side",ac="$product_tours_enabled_server_side",dp="$logs_capture_enabled_server_side",hp="$web_vitals_allowed_metrics",an="$session_recording_remote_config",Ak="$session_recording_enabled_server_side",Tk="$replay_sample_rate",Ik="$replay_override_sampling",Rk="$replay_override_linked_flag",Ck="$replay_override_url_trigger",Ok="$replay_override_event_trigger",ri="$sesid",fp="$session_is_sampled",Pk="$session_past_minimum_duration",$k="$session_recording_url_trigger_activated_session",xk="$session_recording_event_trigger_activated_session",Dk="$debug_first_full_snapshot_timestamp",Nk="$sess_rec_flush_size",gp="$groups",en="$surveys",Jr="$surveys_loaded_at",pp="$surveys_activated",vp="$surveys_activated_session",_p="$surveys_activated_timestamps",Fl="ph_product_tours",Mk="$product_tours_activated",Fk="$product_tours_activated_session",Lk="$conversations_widget_session_id",Uk="$conversations_ticket_id",Bk="$conversations_widget_state",Vk="$conversations_user_traits",Qe="$user_state",Ll="$client_session_props",jk="$capture_rate_limit",mp="$initial_campaign_params",yp="$initial_referrer_info",oi="$initial_person_info",lc="$epp",za="$posthog_cookieless",bp="$cookieless_mode",Ep="$sdk_debug_extensions_init_method",wp="$sdk_debug_extensions_init_time_ms",cc="$sdk_debug_recording_script_not_loaded",uc="$sdk_debug_replay_stale_config",Sp="$sdk_debug_replay_event_trigger_status",kp="$sdk_debug_replay_linked_flag_trigger_status",Ap="$sdk_debug_replay_matched_recording_trigger_groups",Tp="$sdk_debug_replay_pending_trigger_conditions",Ip="$sdk_debug_replay_remote_trigger_matching_config",Rp="$sdk_debug_replay_trigger_groups_count",Cp="$sdk_debug_replay_url_trigger_status",Gk="$session_recording_start_reason",dc="PostHog loadExternalDependency extension not found.",qt="anonymous",Mr="identified",Op="identified_only",Xr="beforeunload",hc="$pageview",Xh="$pageleave",Pp="$identify",Zh="$groupidentify";ve=function(t,...e){for(let s of e)for(let i in s)s[i]!==void 0&&(t[i]=s[i]);return t};Hk=function(t){return function(...e){try{return t.apply(this,e)}catch(s){R.critical("Implementation error. Please turn on debug mode and open a ticket on https://app.posthog.com/home#panel=support%3Asupport%3A."),R.critical(s)}}},fc=function(t){let e={};return re(t,function(s,i){(H(s)&&s.length>0||Te(s))&&(e[i]=s)}),e};zk=["herokuapp.com","vercel.app","netlify.app"];ln=t=>{if(T){try{let e=t+"=",s=T.cookie.split(";").filter(i=>i.length);for(let i=0;s.length>i;i++){let n=s[i];for(;n.charAt(0)==" ";)n=n.substring(1,n.length);if(n.indexOf(e)===0)return decodeURIComponent(n.substring(e.length,n.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 Te(t)&&isFinite(t)&&Math.floor(t)===t});Wk=class Bl{constructor(e){if(this.bytes=e,e.length!==16)throw new TypeError("not 128-bit length")}static fromFieldsV7(e,s,i,n){if(!Number.isInteger(e)||!Number.isInteger(s)||!Number.isInteger(i)||!Number.isInteger(n)||0>e||0>s||0>i||0>n||e>0xffffffffffff||s>4095||i>1073741823||n>4294967295)throw new RangeError("invalid field value");let r=new Uint8Array(16);return r[0]=e/Math.pow(2,40),r[1]=e/Math.pow(2,32),r[2]=e/Math.pow(2,24),r[3]=e/Math.pow(2,16),r[4]=e/256,r[5]=e,r[6]=112|s>>>8,r[7]=s,r[8]=128|i>>>24,r[9]=i>>>16,r[10]=i>>>8,r[11]=i,r[12]=n>>>24,r[13]=n>>>16,r[14]=n>>>8,r[15]=n,new Bl(r)}toString(){let e="";for(let 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 Bl(this.bytes.slice(0))}equals(e){return this.compareTo(e)===0}compareTo(e){for(let s=0;16>s;s++){let i=this.bytes[s]-e.bytes[s];if(i!==0)return Math.sign(i)}return 0}},Kk=class{generate(){let t=this.generateOrAbort();if(!S(t))return t;{this.Ct=0;let e=this.generateOrAbort();if(S(e))throw new Error("Could not generate UUID after timestamp reset");return e}}generateOrAbort(){let t=(()=>{let e=Date.now();return Te(e)&&isFinite(e)?Math.min(Math.max(Math.floor(e),0),0xffffffffffff):0})();if(t>this.Ct)this.Ct=t,this.It();else{if(this.Ct>=t+1e4)return;this.Mt++,this.Mt>4398046511103&&(this.Ct++,this.It())}return Wk.fromFieldsV7(this.Ct,Math.trunc(this.Mt/Math.pow(2,30)),this.Mt&Math.pow(2,30)-1,this.Tt.nextUint32())}It(){this.Mt=1024*this.Tt.nextUint32()+(1023&this.Tt.nextUint32())}constructor(){this.Ct=0,this.Mt=0,this.Tt=new Yk}},xp=t=>{if("u">typeof UUIDV7_DENY_WEAK_RNG&&UUIDV7_DENY_WEAK_RNG)throw new Error("no cryptographically strong RNG available");for(let e=0;t.length>e;e++)t[e]=65536*Math.trunc(65536*Math.random())+Math.trunc(65536*Math.random());return t};E&&!S(E.crypto)&&crypto.getRandomValues&&(xp=t=>crypto.getRandomValues(t));Yk=class{nextUint32(){return this.Rt.length>this.Et||(xp(this.Rt),this.Et=0),this.Rt[this.Et++]}constructor(){this.Rt=new Uint32Array(8),this.Et=1/0}},bt=()=>Qk().toString(),Qk=()=>(ef||(ef=new Kk)).generate(),qi="",Jk=/[a-z0-9][a-z0-9-]+\.[a-z]{2,}$/i,Xs=null,Ee={At(){if(!we(Xs))return Xs;if(Xs=!1,T)try{let t=`__ph_cookie_support_${bt()}`;Ee.$t(t,"xyz"),Xs=ln(t)==='"xyz"',Ee.Pt(t)}catch{Xs=!1}return Xs},Lt(t){R.error("cookieStore error: "+t)},Ot:ln,Dt(t){let e;try{e=JSON.parse(Ee.Ot(t))||{}}catch{}return e},$t(t,e,s,i,n){if(!T)return!1;try{let r="",o="",a=(function(c,u){if(u){let h=(function(d,g=T){if(qi)return qi;if(!g||["localhost","127.0.0.1"].includes(d))return"";let p=d.split("."),m=Math.min(p.length,8),v="dmn_chk_"+bt();for(;!qi&&m--;){let b=p.slice(m).join("."),y=v+"=1;domain=."+b+";path=/";g.cookie=y+";max-age=3",g.cookie.includes(v)&&(g.cookie=y+";max-age=0",qi=b)}return qi})(c);if(!h){let d=(g=>{let p=g.match(Jk);return p?p[0]:""})(c);d!==h&&R.info("Warning: cookie subdomain discovery mismatch",d,h),h=d}return h?"; domain=."+h:""}return""})(T.location.hostname,i);if(s){let c=new Date;c.setTime(c.getTime()+864e5*s),r="; expires="+c.toUTCString()}n&&(o="; secure");let l=t+"="+encodeURIComponent(JSON.stringify(e))+r+"; SameSite=Lax; path=/"+a+o;return l.length>3686.4&&R.warn("cookieStore warning: large cookie, len="+l.length),T.cookie=l,!0}catch{return!1}},Pt(t,e){if(T?.cookie&&(!e||!we(ln(t))))try{Ee.$t(t,"",-1,e)}catch{return}}},qa=null,J={At(){if(!we(qa))return qa;let t=!0;if(S(E))t=!1;else try{let e="__mplssupport__";J.$t(e,"xyz"),J.Ot(e)!=='"xyz"'&&(t=!1),J.Pt(e)}catch{t=!1}return t||R.error("localStorage unsupported; falling back to cookie store"),qa=t,t},Lt(t){R.error("localStorage error: "+t)},Ot(t){try{return E?.localStorage.getItem(t)}catch(e){J.Lt(e)}return null},Dt(t){try{return JSON.parse(J.Ot(t))||{}}catch{}return null},$t(t,e){try{return E?.localStorage.setItem(t,JSON.stringify(e)),!0}catch(s){J.Lt(s)}return!1},Pt(t){try{E?.localStorage.removeItem(t)}catch(e){J.Lt(e)}}},Wa=[as,zt,yt,Ds,cs,Ns,us,vn,ls],xs=[rc,mt,ri,fp,lc,oi,ui,Qe],Zr=t=>t+"_cpm",Xk=["__proto__","constructor","prototype"],Ka=t=>{if(!G(t))return{};let e={};return Object.keys(t).forEach(s=>{Xk.indexOf(s)===-1&&(e[s]=t[s])}),e},Ya=(t,e=[])=>{let s={};return[...xs,...e].forEach(i=>{let n=t[i];S(n)||we(n)||n===""||(s[i]=n)}),s},Dp=t=>{let e=5381,s=2166136261;for(let i=0;t.length>i;i++){let n=t.charCodeAt(i);e=33*e^n,s=Math.imul(s^n,16777619)}return t.length.toString(36)+"."+(e>>>0).toString(36)+"."+(s>>>0).toString(36)},tf=(t,e)=>({p:e,f:Dp(JSON.stringify(t))}),sf=(t,e)=>{if(!e)return{properties:[],isValid:!1};try{let s=Ee.Dt(Zr(t)),i=s?.f===Dp(e)&&N(s.p);return{properties:i?s.p:[],isValid:i}}catch{return{properties:[],isValid:!1}}},Qa=(t,e)=>e+"|"+(Ee.Ot(Zr(t))||""),Zs={},Vl={At:()=>!0,Lt(t){R.error("memoryStorage error: "+t)},Ot:t=>t in Zs?Zs[t]:null,Dt:t=>t in Zs?Zs[t]:null,$t:(t,e)=>(Zs[t]=e,!0),Pt(t){delete Zs[t]}},Ts=null,de={At(){if(!we(Ts))return Ts;if(Ts=!0,S(E))Ts=!1;else try{let t="__support__";de.$t(t,"xyz"),de.Ot(t)!=='"xyz"'&&(Ts=!1),de.Pt(t)}catch{Ts=!1}return Ts},Lt(t){R.error("sessionStorage error: ",t)},Ot(t){try{return E?.sessionStorage.getItem(t)}catch(e){de.Lt(e)}return null},Dt(t){try{return JSON.parse(de.Ot(t))||null}catch{}return null},$t(t,e){try{return E?.sessionStorage.setItem(t,JSON.stringify(e)),!0}catch(s){de.Lt(s)}return!1},Pt(t){try{E?.sessionStorage.removeItem(t)}catch(e){de.Lt(e)}}},Zk=class{constructor(t){this._instance=t}get Mr(){return this._instance.config}get consent(){return this.Do()?0:this.Lo}isOptedOut(){return this.Mr.cookieless_mode==="always"||this.isRejected()||this.consent===-1&&this.Mr.cookieless_mode==="on_reject"}isOptedIn(){return!this.isOptedOut()}isExplicitlyOptedOut(){return this.consent===0}isRejected(){return this.consent===0||this.consent===-1&&this.Mr.opt_out_capturing_by_default}optInOut(t){this.No.$t(this.qo,t?1:0,this.Mr.cookie_expiration,this.Mr.cross_subdomain_cookie,this.Mr.secure_cookie)}reset(){this.No.Pt(this.qo,this.Mr.cross_subdomain_cookie)}get qo(){let{token:t,opt_out_capturing_cookie_prefix:e,consent_persistence_name:s}=this._instance.config;return s||(e?e+t:"__ph_opt_in_out_"+t)}get Lo(){let t=this.No.Ot(this.qo);return Da(t)?1:M(Xw,t)?0:-1}get No(){let t=this.Mr.opt_out_capturing_persistence_type,e=t==="localStorage"?J:Ee,s=e.At()?e:Vl;if(!this.jo||this.jo!==s){this.jo=s;let i=t==="localStorage"?Ee:J;i.Ot(this.qo)&&(this.jo.Ot(this.qo)||this.optInOut(Da(i.Ot(this.qo))),i.Pt(this.qo,this.Mr.cross_subdomain_cookie))}return this.jo}Do(){return!!this.Mr.respect_dnt&&[Le?.doNotTrack,Le?.msDoNotTrack,L.doNotTrack,Le?.globalPrivacyControl].some(t=>Da(t))}};vc=["a","button","form","input","select","textarea","label"];Ja=[".ph-no-autocapture","[data-ph-no-autocapture]"],Up=["next","previous","prev",">","<","\u2192","\u2190","\u203A","\u2039","\xBB","\xAB","\u25B6","\u25C0","\u276F","\u276E"],_c=[...Up,"+","-","\u2212","\u2013"],of=_c.length+10,eA=["button","a","input","select","textarea","label"],tA=["button","link","tab","menuitem","option"],af=(t,e)=>/[a-z0-9]/i.test(e)?M(_c,e)?new RegExp(`\\b${e}\\b`).test(t):t.includes(e):t===e,sA=t=>M(eA,t.tagName.toLowerCase())||M(tA,(t.getAttribute("role")||"").toLowerCase());lf=[".ph-no-rageclick",".ph-no-capture"],iA=["","text","search","email","password","url","tel","number"];mc=t=>!t||Ue(t,"html")||!Et(t),Vp=(t,e)=>{if(!E||mc(t))return{parentIsUsefulElement:!1,targetElementList:[]};let s=!1,i=[t],n=t;for(;n.parentNode&&!Ue(n,"body");){if(gc(n.parentNode)){i.push(n.parentNode.host),n=n.parentNode.host;continue}let r=Lp(n);if(!r)break;if(e||vc.indexOf(r.tagName.toLowerCase())>-1)s=!0;else try{let o=E.getComputedStyle(r);o&&o.getPropertyValue("cursor")==="pointer"&&(s=!0)}catch{}i.push(r),n=r}return{parentIsUsefulElement:s,targetElementList:i}};cf=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}))$"),uf=/(^|[^0-9A-Za-z_])([0-9][0-9 -]*[0-9])(?=$|[^0-9A-Za-z_])/g,nA=[16,15,14,13],rA=new RegExp("^(\\d{3}-?\\d{2}-?\\d{4})$"),df=new RegExp("(^|[^0-9])((?!000|666)[0-9]{3}-?(?!00)[0-9]{2}-?(?!0000)[0-9]{4})(?=$|([^0-9]))","g"),hf=/[0-9A-Za-z_]/;Ir=ye("[Dead Clicks]"),lA=()=>!0,cA=t=>{var e;let s=!!(!((e=t.instance.persistence)===null||e===void 0)&&e.get_property(oc)),i=t.instance.config.capture_dead_clicks;return Je(i)?i:!!G(i)||s},pf=class{get lazyLoadedDeadClicksAutocapture(){return this.Bo}constructor(t,e,s){this.instance=t,this.isEnabled=e,this.onCapture=s,this.startIfEnabledOrStop()}onRemoteConfig(t){if(!t.ok)return;let e=t.config;"captureDeadClicks"in e&&(this.instance.persistence&&this.instance.persistence.register({[oc]:e.captureDeadClicks}),this.startIfEnabledOrStop())}startIfEnabledOrStop(){this.isEnabled(this)?this.zo(()=>{this.Ho()}):this.stop()}zo(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.initDeadClicksAutocapture?t():(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this.instance,"dead-clicks-autocapture",n=>{n?Ir.error("failed to load script",n):t()})}Ho(){var t;if(T){if(!this.Bo&&(!((t=L.__PosthogExtensions__)===null||t===void 0)&&t.initDeadClicksAutocapture)){let e=G(this.instance.config.capture_dead_clicks)?_({},this.instance.config.capture_dead_clicks):{};e.__onCapture=this.onCapture,this.onCapture&&(e.capture_dead_swipes=!1),this.Bo=L.__PosthogExtensions__.initDeadClicksAutocapture(this.instance,e),this.Bo.start(T),Ir.info("starting...")}}else Ir.error("`document` not found. Cannot start.")}stop(){this.Bo&&(this.Bo.stop(),this.Bo=void 0,Ir.info("stopping..."))}},Wi=ye("[SegmentIntegration]");Gp="posthog-js";uA=class{constructor(t,e,s,i,n,r){this.name=Gp,this.setupOnce=function(o){o(Hp(t,{organization:e,projectId:s,prefix:i,severityAllowList:n,sendExceptionsToPostHog:r==null||r}))}}},_f=class{constructor(t){this.Uo=(e,s,i)=>{i&&(i.noSessionId||i.activityTimeout||i.sessionPastMaximumLength||i.crossTabAdoption)&&(R.info("[PageViewManager] Session rotated, clearing pageview state",{sessionId:e,changeReason:i}),this.Wo=void 0,this._instance.scrollManager.resetContext())},this._instance=t,this.Vo()}Vo(){var t;this.Go=(t=this._instance.sessionManager)===null||t===void 0?void 0:t.onSessionId(this.Uo)}destroy(){var t;(t=this.Go)===null||t===void 0||t.call(this),this.Go=void 0}doPageView(t,e){var s;let i=this.Qo(t,e);return this.Wo={pathname:(s=E?.location.pathname)!==null&&s!==void 0?s:"",pageViewId:e,timestamp:t},this._instance.scrollManager.resetContext(),i}doPageLeave(t){var e;return this.Qo(t,(e=this.Wo)===null||e===void 0?void 0:e.pageViewId)}doEvent(){var t;return{$pageview_id:(t=this.Wo)===null||t===void 0?void 0:t.pageViewId}}Qo(t,e){let s=this.Wo;if(!s)return{$pageview_id:e};let i={$pageview_id:e,$prev_pageview_id:s.pageViewId},n=this._instance.scrollManager.getContext();if(n&&!this._instance.config.disable_scroll_properties){let{maxScrollHeight:r,lastScrollY:o,maxScrollY:a,maxContentHeight:l,lastContentY:c,maxContentY:u}=n;if(!(S(r)||S(o)||S(a)||S(l)||S(c)||S(u))){r=Math.ceil(r),o=Math.ceil(o),a=Math.ceil(a),l=Math.ceil(l),c=Math.ceil(c),u=Math.ceil(u);let h=r>1?Rt(o/r,0,1,R):1,d=r>1?Rt(a/r,0,1,R):1,g=l>1?Rt(c/l,0,1,R):1,p=l>1?Rt(u/l,0,1,R):1;i=ve(i,{$prev_pageview_last_scroll:o,$prev_pageview_last_scroll_percentage:h,$prev_pageview_max_scroll:a,$prev_pageview_max_scroll_percentage:d,$prev_pageview_last_content:c,$prev_pageview_last_content_percentage:g,$prev_pageview_max_content:u,$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}},Ki=["flags","surveys"],dA={[Sk]:{exposure:"hidden"},[Qr]:{exposure:"hidden"},[kk]:{exposure:"hidden"},[$l]:{exposure:"hidden"},[ui]:{exposure:"hidden"},[on]:{exposure:"hidden"},[cp]:{exposure:"event"},[xl]:{exposure:"hidden"},[dp]:{exposure:"hidden"},[Dl]:{exposure:"event"},[up]:{exposure:"hidden"},[Nl]:{exposure:"event"},[Ml]:{exposure:"event"},[oc]:{exposure:"event"},[ac]:{exposure:"hidden"},[hp]:{exposure:"event"},[an]:{exposure:"hidden"},[Ak]:{exposure:"hidden"},[ri]:{exposure:"hidden"},[fp]:{exposure:"event"},[Tk]:{exposure:"event",shouldSkipFromEventProperties:t=>we(t)},[Pk]:{exposure:"event"},[$k]:{exposure:"event"},[xk]:{exposure:"event"},[Dk]:{exposure:"event"},[Nk]:{exposure:"hidden"},[yt]:{exposure:"hidden",storageGroup:"flags"},[zt]:{exposure:"hidden",storageGroup:"flags"},[Pl]:{exposure:"hidden"},[Ds]:{exposure:"hidden",storageGroup:"flags"},[cs]:{exposure:"hidden",storageGroup:"flags"},[Ns]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[rn]:{exposure:"hidden",storageGroup:"flags"},[Tt]:{exposure:"hidden"},[$s]:{exposure:"hidden"},[as]:{exposure:"hidden"},[os]:{exposure:"hidden"},[en]:{exposure:"hidden",storageGroup:"surveys"},[Jr]:{exposure:"hidden",storageGroup:"surveys",volatile:!0},[pp]:{exposure:"event"},[vp]:{exposure:"hidden"},[_p]:{exposure:"hidden"},[Fl]:{exposure:"hidden"},[Mk]:{exposure:"hidden"},[Fk]:{exposure:"hidden"},[Lk]:{exposure:"event"},[Uk]:{exposure:"event"},[Bk]:{exposure:"event"},[Vk]:{exposure:"event"},[ls]:{exposure:"hidden"},[Zi]:{exposure:"hidden"},[gp]:{exposure:"event"},[vn]:{exposure:"hidden"},[us]:{exposure:"hidden",storageGroup:"flags",volatile:!0},[Qe]:{exposure:"hidden"},[Ll]:{exposure:"hidden"},[jk]:{exposure:"hidden"},[mp]:{exposure:"hidden"},[yp]:{exposure:"hidden"},[oi]:{exposure:"hidden"},[lc]:{exposure:"hidden"},[Ik]:{exposure:"event"},[Rk]:{exposure:"event"},[Ck]:{exposure:"event"},[Ok]:{exposure:"event"},[Ep]:{exposure:"event"},[wp]:{exposure:"event"},[cc]:{exposure:"hidden"},[uc]:{exposure:"hidden"},[Sp]:{exposure:"hidden"},[kp]:{exposure:"hidden"},[Ap]:{exposure:"hidden"},[Tp]:{exposure:"hidden"},[Ip]:{exposure:"hidden"},[Rp]:{exposure:"hidden"},[Cp]:{exposure:"hidden"},[Gk]:{exposure:"event"}},hA=[["$posthog_sr_group_event_trigger_",{exposure:"hidden"}],["$posthog_sr_group_url_trigger_",{exposure:"hidden"}],["$posthog_sr_group_sampling_",{exposure:"hidden"}]],Ne=t=>{let e=dA[t];if(e)return e;for(let[s,i]of hA)if(t.indexOf(s)===0)return i};qp=()=>{try{return"u">typeof window&&window.navigator.onLine!==!1}catch{return!1}},Wp=(t,e)=>t>=e&&qp(),Kp=(t,e,s,i)=>{if(t===0){if(qp()){let n=e+1;return n===s&&i(),n}return e}return 0},li=(t,e)=>{try{let s;return JSON.stringify(t,(i,n)=>{var r;return bi(n)?((r=s)!==null&&r!==void 0||(s=new WeakMap),s.has(n)||s.set(n,$p(n)),s.get(n)):typeof n=="bigint"?n.toString():n},e)}catch{return og(t)}},Kt=t=>{let e=T?.createElement("a");return S(e)?null:(e.href=t,e)},vi=function(t,e){let s=((t.split("#")[0]||"").split(/\?(.*)/)[1]||"").replace(/^\?+/g,"").split("&"),i;for(let n=0;s.length>n;n++){let r=s[n].split("=");if(r[0]===e){i=r;break}}if(!N(i)||2>i.length)return"";{let n=i[1];try{n=decodeURIComponent(n)}catch{R.error("Skipping decoding for malformed query param: "+n)}return n.replace(/\+/g," ")}},yn=function(t,e,s){if(!t||!e||!e.length)return t;let i=t.split("#"),n=i[1],r=(i[0]||"").split("?"),o=r[1],a=r[0],l=(o||"").split("&"),c=[];for(let h=0;l.length>h;h++){let d=l[h].split("=");N(d)&&(e.includes(d[0])?c.push(d[0]+"="+s):c.push(l[h]))}let u=a;return o!=null&&(u+="?"+c.join("&")),n!=null&&(u+="#"+n),u},eo=function(t,e){let s=t.match(new RegExp(e+"=([^&]*)"));return s?s[1]:null},_i=["gclid","gclsrc","dclid","gbraid","wbraid","fbclid","msclkid","twclid","li_fat_id","igshid","ttclid","rdt_cid","epik","qclid","sccid","oppref","irclid","_kx"],fA=["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gad_source","mc_cid",..._i],bn="<masked>",gA=["li_fat_id"];to="$direct";_A={flags:us,surveys:Jr},mA=["cookie","localstorage","localstorage+cookie","sessionstorage","memory"],Rr=t=>`${t}_cookie_identity_change_pending`,Cr=t=>{let e="",s=0;for(let i of t){let n=encodeURIComponent(JSON.stringify(i).slice(1,-1)).length;if(s+n>1e3)break;e+=i,s+=n}return e},Pe="main",Ht=[yt,zt,Ds,cs,Ns,us,rn,as],Za=t=>Ht.indexOf(t)!==-1,sv=[ui,on],mf=t=>sv.indexOf(t)!==-1,is=(t,e)=>{try{return JSON.stringify(t)===JSON.stringify(e)}catch{return t===e}},ei=t=>{if(!t)return{};let e=JSON.parse(t);return G(e)?e:{}},yf=(t,e)=>{re(t,(s,i)=>{let n=Ne(i);n&&n.exposure!=="event"||{}.hasOwnProperty.call(e,i)||delete t[i]})},el=class{constructor(t,e,s=!0,i=!t.cookieless_mode){if(this.Zo={},this.Jo=!1,this.Ko=!1,this.Xo=!1,this.Yo=!1,this.ta=!1,this.ea=new Map,this.ia=!1,this.na=!1,this.sa=!1,this.ra=new Set,this.oa=new Set,this.Mr=t,this.aa=s,this.props={},this.la=void 0,this.ua=(n=>{let r="";return n.token&&(r=n.token.replace(/\+/g,"PL").replace(/\//g,"SL").replace(/=/g,"EQ")),n.persistence_name?"ph_"+n.persistence_name:"ph_"+r+"_posthog"})(t),this.hi=t.disable_persistence||!!e,this.No=this.ca(t),this.Xo=this.ha(t),this.load(i),this.da(),t.debug&&R.info("Persistence loaded",t.persistence,_({},this.props)),this.update_config(t,t,e),this.save(),E){let n=()=>this.flush();se(E,"beforeunload",n,{capture:!1}),se(E,"pagehide",n,{capture:!1}),this.va=r=>{if(this.Jo&&(!r.storageArea||r.storageArea===E?.localStorage)&&r.key)if(r.key!==this.ua){if(this.Xo){let o=Ki.find(a=>r.key===this.fa(a));o&&this.pa(r.key,o)}}else this.pa(r.key,Pe)},se(E,"storage",this.va)}}markCrossTabFeatureFlagChanges(t){Object.entries(t).forEach(([e,s])=>{let i=this.ea.get(e);if(!Za(e)||i===!0)return;if(s===!0)return void this.ga(e,!0);let n=new Set(i||[]);s.forEach(r=>n.add(r)),n.size&&this.ga(e,n)})}onCrossTabFeatureFlagChange(t){return this.oa.add(t),()=>this.oa.delete(t)}destroy(){this.va&&E&&(E.removeEventListener("storage",this.va),this.va=void 0),this.oa.clear()}pa(t,e,s=!0){if(this.hi)return!1;let i,n;try{if(n=J.Ot(t),we(n)){let a=this.ma(e);return a.storageValue=null,e!==Pe&&(a.persisted=!1),!1}i=ei(n)}catch{return!1}let r=e===Pe?i:J.Dt(this.ua);if(r&&this.ya(r))return!1;let o=this.ba(i,e,s);return e===Pe&&this.Xo&&!is(this._a().main,i)||this.wa(i,e,!0,n),o}ya(t){let e=this.props[mt],s=t[mt];return!S(e)&&!S(s)&&e!==s}wa(t,e,s,i){let n=this.ma(e);n.storageValue=i,e!==Pe&&(n.persisted=s);try{n.fingerprint=this.ka(t,e)}catch{n.fingerprint=void 0}}ba(t,e,s){let i=!1;return Ht.forEach(n=>{var r;let o=(r=Ne(n))===null||r===void 0?void 0:r.storageGroup;if(e===Pe&&this.Xo&&o||e!==Pe&&o!==e)return;let a=n in t,l=this.Sa(n,a?t[n]:void 0),c=this.ea.has(n)?n in this.props:a;c===n in this.props&&is(l,this.props[n])||(c?this.xa(n,l,!1):this.$a(n,!1),i=!0)}),i&&s&&this.oa.forEach(n=>n()),i}Ca(){if(!this.Jo)return!1;try{this.sa=!1;let t=J.Ot(this.ua),e=this.ma(Pe),s,i=!1,n=!1;if(t!==e.storageValue)if(we(t))e.storageValue=null;else{if(s=ei(t),this.sa=!this.na&&this.ya(s),this.sa)return!1;n=this.ba(s,Pe,!1),!this.Xo||is(this._a().main,s)?this.wa(s,Pe,!0,t):e.storageValue=t,i=!0}return this.Xo&&Ki.forEach(r=>{let o=J.Ot(this.fa(r)),a=this.ma(r),l=s||{},c=i&&Ht.some(h=>{var d;return((d=Ne(h))===null||d===void 0?void 0:d.storageGroup)===r&&h in l});if(o===a.storageValue&&!c)return;if(we(o))return a.storageValue=null,a.persisted=!1,void(c&&(n=this.ba(l,r,!1)||n));let u=ei(o);n=this.ba(u,r,!1)||n,this.wa(u,r,!0,o)}),n}catch{return!1}}ga(t,e){this.ea.set(t,e);let s=Ne(t);s?.volatile||(this.ma((this.Xo?s?.storageGroup:void 0)||Pe).fingerprint=void 0,this.Ta(t))}Ia(){Ht.forEach(t=>this.ea.set(t,!0))}da(){if(this.Jo)try{let t=J.Ot(this.ua),e=ei(t);this.ma(Pe).storageValue=t,Ht.forEach(s=>{var i;let n=this.Xo?(i=Ne(s))===null||i===void 0?void 0:i.storageGroup:void 0,r=n?J.Ot(this.fa(n)):null;if(n){let a=this.ma(n);a.storageValue=r,a.persisted=!we(r)}let o=n&&!we(r)?ei(r):e;s in this.props?this.Ma(s,o[s],this.props[s]):s in o&&this.ga(s,!0)})}catch{}}Sa(t,e){let s=this.ea.get(t);if(!s)return e;if(s===!0)return this.props[t];if(t==="$active_feature_flags"){let r=new Set(N(e)?e:[]),o=new Set(N(this.props[t])?this.props[t]:[]);return s.forEach(a=>o.has(a)?r.add(a):r.delete(a)),Array.from(r)}let i=G(e)?_({},e):{},n=G(this.props[t])?this.props[t]:{};return s.forEach(r=>{r in n?i[r]=n[r]:delete i[r]}),i}Ma(t,e,s){if(!Za(t))return;let i=this.ea.get(t);if(i===!0)return;let n=e;if(this.Jo)try{var r;let a=this.Xo?(r=Ne(t))===null||r===void 0?void 0:r.storageGroup:void 0,l=a?this.fa(a):this.ua;n=ei(J.Ot(l))[t]}catch{}let o=new Set(i||[]);if(t==="$active_feature_flags"){if(!S(e)&&!N(e)||!S(n)&&!N(n)||!N(s))return void this.ga(t,!0);let a=new Set(e||[]),l=new Set(n||[]),c=new Set(s);new Set([...a,...c]).forEach(u=>{a.has(u)!==c.has(u)&&o.add(u)}),o.forEach(u=>{l.has(u)===c.has(u)&&o.delete(u)})}else{if(!G(s))return void(is(n,s)?this.ea.delete(t):this.ga(t,!0));{if(!S(e)&&!G(e)||S(e)&&nt(s)&&S(n))return void this.ga(t,!0);let a=G(e)?e:{},l=G(n)?n:{};new Set([...Object.keys(a),...Object.keys(s)]).forEach(c=>{c in a==c in s&&is(a[c],s[c])||o.add(c)}),o.forEach(c=>{c in l==c in s&&is(l[c],s[c])&&o.delete(c)})}}o.size?this.ga(t,o):this.ea.delete(t)}Ea(){var t;let e=(t=this.Mr)===null||t===void 0?void 0:t.persistence_save_debounce_ms;return Te(e)&&e>0?e:0}Pa(t){if(this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie")if(t)try{let e=Ya(t,this.Mr.cookie_persisted_properties||[]),s=tf(e,this.Mr.cookie_persisted_properties||[]),i=JSON.stringify(e)+"|"+JSON.stringify(s),n=Ee.Ot(this.ua)||void 0;n&&Qa(this.ua,n)===i&&(this.Ra=i,this.Aa=n)}catch{}else try{let e=Ee.Ot(this.ua)||void 0;this.Ra=e?Qa(this.ua,e):void 0,this.Aa=e}catch{}}syncCookieProperties(){return this.Fa(this.Mr)}Fa(t,e=!1){if(this.hi&&!e||this.ta||!t.cookieWinsOnConflict||t.persistence.toLowerCase()!=="localstorage+cookie")return!1;let s;try{s=Ee.Ot(this.ua)||void 0}catch{}if(!s||s===this.Aa)return!1;let i=Qa(this.ua,s),n;try{n=Ka(JSON.parse(s))}catch{return!1}if((Ee.Ot(this.ua)||void 0)!==s)return!1;this.Ra=i,this.Aa=s;let r=sf(this.ua,s),o=[...xs,...r.properties],a={};if(Object.keys(n).forEach(m=>{let v=n[m];(S(v)||we(v)||v===""||m==="$user_state"&&v!=="anonymous"&&v!=="identified")&&(a[m]=!0,delete n[m])}),nt(n))return!1;let l="distinct_id"in n||n.$user_state==="anonymous"||n.$user_state==="identified",c=this.props,u=c[mt],h=c[Qe],d=ve({},c);[...xs,...t.cookie_persisted_properties||[]].forEach(m=>{if(o.indexOf(m)!==-1&&!(m in n)&&!a[m]&&(l||m!=="distinct_id"&&m!=="$user_state")){let v=d[m];(r.isValid||xs.indexOf(m)===-1||v!==!1&&v!==0)&&delete d[m]}}),this.props=ve(d,n),Ht.forEach(m=>{let v=m in this.props;m in c===v&&is(c[m],this.props[m])||(v?this.Ma(m,c[m],this.props[m]):this.ga(m,!0))}),!l||"$user_state"in n||"$user_state"in this.props||this.xa(Qe,qt);let g=this.props[mt],p=this.props[Qe];return!l||g===u&&p===h||(this.na=!0,this.Yo=!0,de.$t(Rr(this.ua),!0),this.$a(as),this.$a(zt),this.$a(yt),this.$a(Ds),this.$a(cs),this.$a(Ns),this.$a(us),this.$a(vn),this.$a(ls),p!=="anonymous"||h!=="identified"&&n.$user_state!=="anonymous"&&(S(u)||g===u)||(yf(this.props,n),this.$a(os)),p==="identified"?this.props.$user_id=g:delete this.props.$user_id,this.$a(Qr)),!0}consumeCookieIdentityChange(){let t=Rr(this.ua),e=this.Yo||!!de.Ot(t);return this.Yo=!1,e&&de.Pt(t),e}Oa(t=!1){return!(this.ta||this.hi&&!t||!this.Mr.cookieWinsOnConflict||this.Mr.persistence.toLowerCase()!=="localstorage+cookie"||(this.ta=!0,0))}Da(){this.ta&&(S(this.La)||(clearTimeout(this.La),this.La=void 0),delete this.Zo[Pe],this.Na(!0))}qa(t=!0){if(this.ta)try{t?this.Da():S(this.La)||(clearTimeout(this.La),this.La=void 0)}finally{this.ta=!1}}isDisabled(){return!!this.hi}ca(t){mA.indexOf(t.persistence.toLowerCase())===-1&&(R.critical("Unknown persistence type "+t.persistence+"; falling back to localStorage+cookie"),t.persistence="localStorage+cookie");let e=((o=[],a=!1,l=()=>!1)=>{let c=[...xs,...o];return _(_({},J),{},{Dt(u){try{let d,g={};try{d=Ee.Ot(u)||void 0,g=d?Ka(JSON.parse(d)):{}}catch{}let p=JSON.parse(J.Ot(u)||"{}"),m;if(a){let v=sf(u,d),b=[...xs,...v.properties],y={};Object.keys(g).forEach(A=>{let I=g[A];we(I)||I===""||A==="$user_state"&&I!=="anonymous"&&I!=="identified"||(y[A]=I)});let w="distinct_id"in y||y.$user_state==="anonymous"||y.$user_state==="identified";if(Object.keys(y).length>0){var h;let A=p[mt],I=(h=p.$user_state)!==null&&h!==void 0?h:qt;c.forEach(k=>{if(b.indexOf(k)!==-1&&!(k in g)&&(w||k!=="distinct_id"&&k!=="$user_state")){let $=p[k];(v.isValid||xs.indexOf(k)===-1||$!==!1&&$!==0)&&delete p[k]}}),!w||"$user_state"in g||"$user_state"in p||(p[Qe]=qt),!w||("distinct_id"in y?y[mt]:p[mt])===A&&("$user_state"in y?y[Qe]:p[Qe])===I||(Wa.forEach(k=>delete p[k]),y.$user_state==="identified"&&"distinct_id"in y?p.$user_id=y[mt]:delete p.$user_id,y.$user_state!=="identified"&&(delete p[gp],delete p[os]),delete p.__alias)}m=ve(p,y)}else m=ve(g,p);return l()||J.$t(u,m),m}catch{}return null},$t(u,h,d,g,p,m){let v=J.$t(u,h,void 0,void 0,m);try{let b=Ya(h,o);if(Object.keys(b).length){if(a){let y=Zr(u),w=tf(b,o);if(Ee.$t(y,w,d,g,p,m),Ee.Ot(y)!==JSON.stringify(w)){Ee.Pt(y,g);let A=Ya(h);return Ee.$t(u,A,d,g,p,m),v}}Ee.$t(u,b,d,g,p,m)}}catch(b){J.Lt(b)}return v},Pt(u,h){try{E?.localStorage.removeItem(u),Ee.Pt(u,h),Ee.Pt(Zr(u),h)}catch(d){J.Lt(d)}}})})(t.cookie_persisted_properties||[],t.cookieWinsOnConflict,()=>!!this.hi),s,i=!1,n=!1,r=t.persistence.toLowerCase();return r==="localstorage"&&J.At()?(s=J,n=!0):r==="localstorage+cookie"&&e.At()?(s=e,n=!0,i=!0):r==="sessionstorage"&&de.At()?s=de:r==="memory"?s=Vl:r==="cookie"&&Ee.At()?(s=Ee,i=!0):e.At()?(s=e,n=!0,i=!0):Ee.At()?(s=Ee,i=!0):s=Vl,this.Jo=n,this.Ko=i,s}fa(t){return`${this.ua}__${t}`}ha(t){return this.Jo&&!!t.split_storage}properties(){let t={};return re(this.props,(e,s)=>{let i=Ne(s);if(!i||i.exposure==="event"){var n;if(!(i==null||(n=i.shouldSkipFromEventProperties)===null||n===void 0)&&n.call(i,e))return;t[s]=e}}),t}load(t=!1){if(this.hi&&!t)return;let e=this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie",s=e?J.Dt(this.ua):null,i={};if(e)try{i=Ka(Ee.Dt(this.ua)),re(i,(a,l)=>{(S(a)||we(a)||a==="")&&delete i[l]})}catch{}let n=this.No.Dt(this.ua);if(n&&(this.props=ve({},n)),this.Xo&&this.ja(),e&&n){var r,o;let a=s?.[mt],l=(r=s?.$user_state)!==null&&r!==void 0?r:qt,c=n[mt],u=(o=n.$user_state)!==null&&o!==void 0?o:qt;if(c!==a||u!==l){this.Yo=!0,this.hi||de.$t(Rr(this.ua),!0);let h=ve({},this.props);Wa.forEach(g=>delete h[g]),u!=="anonymous"||l!=="identified"&&i.$user_state!=="anonymous"&&(S(a)||c===a)||(yf(h,i),delete h[os]),this.props=h;let d=new Set;Wa.forEach(g=>{var p;let m=(p=Ne(g))===null||p===void 0?void 0:p.storageGroup;m&&d.add(m)}),d.forEach(g=>{if(this.hi)return;let p={};re(this.props,(m,v)=>{var b;((b=Ne(v))===null||b===void 0?void 0:b.storageGroup)===g&&(p[v]=m)}),nt(p)?(J.Pt(this.fa(g)),this.Zo[g]={}):J.$t(this.fa(g),p)&&(this.Zo[g]={persisted:!0,fingerprint:this.ka(p,g)})})}}de.Ot(Rr(this.ua))&&(this.Yo=!0)}ja(){for(let t of Ki){let e=J.Dt(this.fa(t));if(e&&!nt(e)){let s=this.ma(t);s.persisted=!0,this.Ba(t)||(s.fingerprint=this.ka(e,t)),this.za(t,e)||ve(this.props,e)}}}Ba(t){return Object.keys(this.props).some(e=>{var s;return((s=Ne(e))===null||s===void 0?void 0:s.storageGroup)===t})}za(t,e){let s=_A[t];if(!s)return!1;let i=e[s],n=this.props[s];return Te(i)&&Te(n)&&n>i}refreshKey(t){var e;if(this.hi||this.ra.has(t))return;let s=this.Xo?(e=Ne(t))===null||e===void 0?void 0:e.storageGroup:void 0,i=s?J.Dt(this.fa(s)):this.No.Dt(this.ua);if(i&&t in i)this.xa(t,i[t],!1);else{if(s){let n=this.No.Dt(this.ua);if(n&&t in n)return void this.xa(t,n[t],!1)}this.$a(t,!1)}}save(){if(this.hi)return;let t=this.Ea();t>0?S(this.La)&&(this.La=setTimeout(()=>{this.La=void 0,this.Na()},t)):this.Na()}flush(){S(this.La)||(clearTimeout(this.La),this.La=void 0,this.Na())}Na(t=!1){if(this.hi||this.ta&&!t)return;t||(this.syncCookieProperties(),this.Mr.cookieWinsOnConflict&&this.Mr.persistence.toLowerCase()==="localstorage+cookie"||sv.forEach(n=>this.refreshKey(n)));let e=!t&&!this.ia;e||(this.sa=!1);let s=!!e&&this.Ca();if(this.sa)return void(this.Mr.debug&&R.warn("skipping persistence write because storage belongs to a different distinct ID"));if(this.Xo)return this.Ha(),void(s&&this.oa.forEach(n=>n()));let i=this.Ua(this.No,this.ua,this.props,Pe);i==="written"&&this.Pa(this.props),i!=="failed"&&(this.ea.clear(),this.na=!1,this.ra.clear()),s&&this.oa.forEach(n=>n())}Ha(){let{main:t,groups:e}=this._a(),s=this.Ua(this.No,this.ua,t,Pe);s==="written"&&this.Pa(t),s!=="failed"&&(this.na=!1,this.ra.clear(),Ht.forEach(n=>{var r;!((r=Ne(n))===null||r===void 0)&&r.storageGroup||this.ea.delete(n)}));for(let n of Ki){var i;let r=e[n];if(nt(r)&&!(!((i=this.Zo[n])===null||i===void 0)&&i.persisted)){Ht.forEach(a=>{var l;((l=Ne(a))===null||l===void 0?void 0:l.storageGroup)===n&&this.ea.delete(a)});continue}let o=this.Ua(J,this.fa(n),r,n);o!=="failed"&&Ht.forEach(a=>{let l=Ne(a);l?.storageGroup!==n||o!=="written"&&l.volatile||this.ea.delete(a)})}}_a(){let t={},e={flags:{},surveys:{}};return re(this.props,(s,i)=>{var n;let r=(n=Ne(i))===null||n===void 0?void 0:n.storageGroup;r?e[r][i]=s:t[i]=s}),{main:t,groups:e}}ka(t,e){if(e===Pe)return JSON.stringify(t)+"|"+this.Wa+"|"+this.Va+"|"+this.Ga;let s={};return re(t,(i,n)=>{var r;s[n]=!((r=Ne(n))===null||r===void 0)&&r.volatile?"__volatile__":i}),JSON.stringify(s)}Ua(t,e,s,i){let n=this.ma(i);if(i!==Pe&&!n.dirty&&!S(n.fingerprint))return"skipped";let r;try{if(r=this.ka(s,i),r===n.fingerprint)return n.dirty=!1,"skipped"}catch{r=void 0}return t.$t(e,s,this.Wa,this.Va,this.Ga,this.Mr.debug)?(n.dirty=!1,i!==Pe&&(n.persisted=!0),S(r)||(n.fingerprint=r),this.Jo&&(n.storageValue=J.Ot(e)),"written"):(this.Mr.debug&&R.warn(`failed to persist storage entry "${e}"; will retry on next save`),"failed")}remove({keepGroupEntries:t=!1}={}){if(this.Ia(),S(this.La)||(clearTimeout(this.La),this.La=void 0),this.No.Pt(this.ua,!1),this.No.Pt(this.ua,!0),!t&&this.aa)for(let e of Ki)J.Pt(this.fa(e));t?delete this.Zo[Pe]:this.Zo={},this.Ra=void 0,this.Aa=void 0}clear(){this.remove(),this.props={}}register_once(t,e,s){if(G(t)){this.syncCookieProperties(),S(e)&&(e="None"),this.Wa=S(s)?this.Qa:s;let i=!1;if(re(t,(n,r)=>{this.props.hasOwnProperty(r)&&this.props[r]!==e||(this.xa(r,n),i=!0)}),i)return this.save(),!0}return!1}register(t,e){if(G(t)){this.syncCookieProperties(),this.Wa=S(e)?this.Qa:e;let s=!1;if(re(t,(i,n)=>{t.hasOwnProperty(n)&&(this.props[n]!==i||G(i)||N(i))&&(this.xa(n,i),s=!0)}),s)return this.save(),!0}return!1}unregister(t){this.syncCookieProperties();let e=typeof t=="string"?[t]:t,s=!1;for(let i of e)i in this.props&&(this.$a(i),s=!0);s&&this.save()}update_campaign_params(){let t=T?.URL;if(t===this.la)return;let e=Yp(this.Mr.custom_campaign_params,this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties),s=!nt(fc(e));return s&&this.register(e),this.la=t,s?e:void 0}update_search_keyword(){this.register((function(){let t=T?.referrer;return t?Jp(t):{}})())}update_referrer_info(){var t;this.register_once({$referrer:Zp(),$referring_domain:T?.referrer&&((t=Kt(T.referrer))===null||t===void 0?void 0:t.host)||to},void 0)}set_initial_person_info(){if(this.props.$initial_campaign_params||this.props.$initial_referrer_info)return;let t=ev(this.Mr.mask_personal_data_properties,this.Mr.custom_personal_data_properties,this.Mr.disable_capture_url_hashes);this.register_once({[oi]:this.Ko?{r:Cr(t.r),u:t.u?Cr(t.u):void 0}:t},void 0)}get_initial_props(){let t={};re([yp,mp],s=>{let i=this.props[s];i&&re(i,function(n,r){t["$initial_"+wl(r)]=n})});let e=this.props[oi];if(e){let s=(function(i,n=!1){let r=tv(i,n),o={};return re(r,function(a,l){o[`$initial_${wl(l)}`]=a}),o})(e,this.Mr.disable_capture_url_hashes);ve(t,s)}return t}safe_merge(t){return re(this.props,function(e,s){s in t||(t[s]=e)}),t}update_config(t,e,s){let i=t.persistence!==e.persistence,n=!((g,p)=>{if(g.length!==p.length)return!1;let m=[...g].sort(),v=[...p].sort();return m.every((b,y)=>b===v[y])})(t.cookie_persisted_properties||[],e.cookie_persisted_properties||[]),r=i||n,o=t.cookieWinsOnConflict!==e.cookieWinsOnConflict,a=t.disable_persistence||!!s,l=!!this.hi&&!a;a||this.Fa(e,l),this.Mr=t,!a&&(i||n||o)&&(this.Ra=void 0,this.Aa=void 0,this.Fa(_(_({},t),{},{cookie_persisted_properties:e.cookie_persisted_properties}),l));let c=r||o?this.ca(t):this.No;this.Za();let u=this.ha(t),h=r||u!==this.Xo,d=!a&&(h||t.cross_subdomain_cookie!==this.Va||t.secure_cookie!==this.Ga)&&this.Oa(l);this.ia=h;try{if(this.Qa=this.Wa=t.cookie_expiration,this.set_disabled(a),this.set_cross_subdomain(t.cross_subdomain_cookie),this.set_secure(t.secure_cookie),h){let g=this.props;this.clear(),this.No=c,this.Xo=u,this.props=g,this.save()}else o&&(this.No=c,a||(delete this.Zo[Pe],this.Na()))}finally{this.ia=!1,d&&this.qa()}}Za(){let t=this.props[oi];if(!this.Ko||!G(t)||typeof t.r!="string")return;let e=Cr(t.r),s=typeof t.u=="string"?Cr(t.u):t.u;e===t.r&&s===t.u||this.xa(oi,_(_({},t),{},{r:e,u:s}))}set_disabled(t){this.hi=t,this.hi?this.remove():this.save()}set_cross_subdomain(t){t!==this.Va&&(this.Va=t,this.remove({keepGroupEntries:!0}),this.save())}set_secure(t){t!==this.Ga&&(this.Ga=t,this.remove({keepGroupEntries:!0}),this.save())}set_event_timer(t,e){let s=this.props.__timers||{};s[t]=e,this.xa($l,s),this.save()}remove_event_timer(t){let e=this.props.__timers||{},s=e[t];return S(s)||(delete e[t],this.xa($l,e),this.save()),s}get_property(t){return this.props[t]}set_property(t,e){this.xa(t,e),this.save()}xa(t,e,s=!0){var i;let n=this.props[t];this.props[t]=e,s&&(t!=="distinct_id"&&t!=="$user_state"||n===e||(this.na=!0),mf(t)&&!is(n,e)&&this.ra.add(t),this.Ma(t,n,e),!((i=Ne(t))===null||i===void 0)&&i.volatile||this.Ta(t))}$a(t,e=!0){delete this.props[t],e&&(Za(t)&&this.ga(t,!0),mf(t)&&this.ra.add(t),this.Ta(t))}Ta(t){var e;let s=(e=Ne(t))===null||e===void 0?void 0:e.storageGroup;s&&(this.ma(s).dirty=!0)}ma(t){return this.Zo[t]||(this.Zo[t]={})}},ut={GZipJS:"gzip-js",Base64:"base64"},Yi={Activation:"events",Cancellation:"cancelEvents"},tl={Popover:"popover",API:"api",Widget:"widget",ExternalSurvey:"external_survey"},ct={SHOWN:"survey shown",DISMISSED:"survey dismissed",SENT:"survey sent",ABANDONED:"survey abandoned"},sl={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"},Hl={Popover:"popover",Inline:"inline"};yA={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"},bf={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"},Ef=ye("[RateLimiter]"),bA=class{constructor(t){this.serverLimits={},this.lastEventRateLimited=!1,this.checkForLimiting=e=>{let s=e.text;if(s&&s.length)try{(JSON.parse(s).quota_limited||[]).forEach(i=>{Ef.info(`${i||"events"} is quota limited.`),this.serverLimits[i]=new Date().getTime()+6e4})}catch(i){return void Ef.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||t===void 0?void 0:t.events_per_second)||10}get captureEventsBurstLimit(){var t;return Math.max(((t=this.instance.config.rate_limiting)===null||t===void 0?void 0:t.events_burst_limit)||10*this.captureEventsPerSecond,this.captureEventsPerSecond)}clientRateLimitContext(t=!1){var e,s,i;let{captureEventsBurstLimit:n,captureEventsPerSecond:r}=this,o=new Date().getTime(),a=(e=(s=this.instance.persistence)===null||s===void 0?void 0:s.get_property("$capture_rate_limit"))!==null&&e!==void 0?e:{tokens:n,last:o};a.tokens+=(o-a.last)/1e3*r,a.last=o,a.tokens>n&&(a.tokens=n);let l=1>a.tokens;if(l||t||(a.tokens=Math.max(0,a.tokens-1)),l&&!t){let c=(Te(a.dropped)?a.dropped:0)+1;a.dropped=c,!this.lastEventRateLimited&&this.Ja(c)&&(a.dropped=0)}return this.lastEventRateLimited=l,(i=this.instance.persistence)===null||i===void 0||i.set_property("$capture_rate_limit",a),{isRateLimited:l,remainingTokens:a.tokens}}Ka(t){let e=this.instance.config.property_denylist;return!N(e)||!e.includes(t)}Xa(){var t;if(this.Ka("$current_url")&&this.Ka("$pathname")&&pe?.pathname)return`${(t=pe.origin)!==null&&t!==void 0?t:""}${pe.pathname}`}Ja(t){var e,s;let{captureEventsBurstLimit:i,captureEventsPerSecond:n}=this,r=this.Xa(),o=this.Ka("$session_id")?(e=(s=this.instance).get_session_id)===null||e===void 0?void 0:e.call(s):void 0,a=[`${t} event(s) dropped since the last warning`,r?`triggered on ${r}`: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 ${n} events per second and ${i} events burst limit.`},{skip_client_rate_limiting:!0})}isServerRateLimited(t){let e=this.serverLimits[t||"events"]||!1;return e!==!1&&new Date().getTime()<e}},ns=ye("[RemoteConfig]"),iv=class{constructor(t){this._instance=t}get remoteConfig(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(t=t[this._instance.config.token])===null||t===void 0?void 0:t.config}Ya(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.loadExternalDependency?(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"remote-config",()=>t(this.remoteConfig)):t()}tl(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 ns.info("Using preloaded remote config",this.remoteConfig),void this.el(this.remoteConfig);if(this._instance.il())return void ns.warn("Remote config is disabled. Falling back to local config.");this.Ya(t=>{if(!t)return ns.info("No config found after loading remote JS config. Falling back to JSON."),void this.tl(e=>{this.el(e.json,e)});this.el(t)})}catch(t){ns.error("Error loading remote config",t),this.el()}}el(t,e){!t&&e&&(e.statusCode===0?e.error||ns.warn("Failed to fetch remote config from PostHog."):ns.error("Failed to fetch remote config from PostHog."));try{this._instance.el(t?{ok:!0,config:t}:{ok:!1})}catch(i){ns.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===void 0||s.ensureFlagsLoaded()}catch(i){ns.error("Error loading feature flags",i)}}},dt=Uint8Array,Xe=Uint16Array,mi=Uint32Array,yc=new dt([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]),bc=new dt([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]),wf=new dt([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),nv=function(t,e){for(var s=new Xe(31),i=0;31>i;++i)s[i]=e+=1<<t[i-1];var n=new mi(s[30]);for(i=1;30>i;++i)for(var r=s[i];s[i+1]>r;++r)n[r]=r-s[i]<<5|i;return[s,n]},rv=nv(yc,2),zl=rv[1];rv[0][28]=258,zl[258]=28;for(ql=nv(bc,0)[1],so=new Xe(32768),me=0;32768>me;++me)Is=(43690&me)>>>1|(21845&me)<<1,so[me]=((65280&(Is=(61680&(Is=(52428&Is)>>>2|(13107&Is)<<2))>>>4|(3855&Is)<<4))>>>8|(255&Is)<<8)>>>1;un=function(t,e,s){for(var i=t.length,n=0,r=new Xe(e);i>n;++n)++r[t[n]-1];var o,a=new Xe(e);for(n=0;e>n;++n)a[n]=a[n-1]+r[n-1]<<1;if(s){o=new Xe(1<<e);var l=15-e;for(n=0;i>n;++n)if(t[n])for(var c=n<<4|t[n],u=e-t[n],h=a[t[n]-1]++<<u,d=h|(1<<u)-1;d>=h;++h)o[so[h]>>>l]=c}else for(o=new Xe(i),n=0;i>n;++n)o[n]=so[a[t[n]-1]++]>>>15-t[n];return o},Fs=new dt(288);for(me=0;144>me;++me)Fs[me]=8;for(me=144;256>me;++me)Fs[me]=9;for(me=256;280>me;++me)Fs[me]=7;for(me=280;288>me;++me)Fs[me]=8;io=new dt(32);for(me=0;32>me;++me)io[me]=5;EA=un(Fs,9,0),wA=un(io,5,0),ov=function(t){return(t/8|0)+(7&t&&1)},av=function(t,e,s){(e==null||0>e)&&(e=0),(s==null||s>t.length)&&(s=t.length);var i=new(t instanceof Xe?Xe:t instanceof mi?mi:dt)(s-e);return i.set(t.subarray(e,s)),i},Vt=function(t,e,s){var i=e/8|0;t[i]|=s<<=7&e,t[i+1]|=s>>>8},Qi=function(t,e,s){var i=e/8|0;t[i]|=s<<=7&e,t[i+1]|=s>>>8,t[i+2]|=s>>>16},nl=function(t,e){for(var s=[],i=0;t.length>i;++i)t[i]&&s.push({s:i,f:t[i]});var n=s.length,r=s.slice();if(!n)return[new dt(0),0];if(n==1){var o=new dt(s[0].s+1);return o[s[0].s]=1,[o,1]}s.sort(function(I,k){return I.f-k.f}),s.push({s:-1,f:25001});var a=s[0],l=s[1],c=0,u=1,h=2;for(s[0]={s:-1,f:a.f+l.f,l:a,r:l};u!=n-1;)a=s[s[h].f>s[c].f?c++:h++],l=s[c!=u&&s[h].f>s[c].f?c++:h++],s[u++]={s:-1,f:a.f+l.f,l:a,r:l};var d=r[0].s;for(i=1;n>i;++i)r[i].s>d&&(d=r[i].s);var g=new Xe(d+1),p=Wl(s[u-1],g,0);if(p>e){i=0;var m=0,v=p-e,b=1<<v;for(r.sort(function(I,k){return g[k.s]-g[I.s]||I.f-k.f});n>i;++i){var y=r[i].s;if(e>=g[y])break;m+=b-(1<<p-g[y]),g[y]=e}for(m>>>=v;m>0;){var w=r[i].s;e>g[w]?m-=1<<e-g[w]++-1:++i}for(;i>=0&&m;--i){var A=r[i].s;g[A]==e&&(--g[A],++m)}p=e}return[new dt(g),p]},Wl=function(t,e,s){return t.s==-1?Math.max(Wl(t.l,e,s+1),Wl(t.r,e,s+1)):e[t.s]=s},Sf=function(t){for(var e=t.length;e&&!t[--e];);for(var s=new Xe(++e),i=0,n=t[0],r=1,o=function(l){s[i++]=l},a=1;e>=a;++a)if(t[a]==n&&a!=e)++r;else{if(!n&&r>2){for(;r>138;r-=138)o(32754);r>2&&(o(r>10?r-11<<5|28690:r-3<<5|12305),r=0)}else if(r>3){for(o(n),--r;r>6;r-=6)o(8304);r>2&&(o(r-3<<5|8208),r=0)}for(;r--;)o(n);r=1,n=t[a]}return[s.subarray(0,i),e]},Ji=function(t,e){for(var s=0,i=0;e.length>i;++i)s+=t[i]*e[i];return s},Lr=function(t,e,s){var i=s.length,n=ov(e+2);t[n]=255&i,t[n+1]=i>>>8,t[n+2]=255^t[n],t[n+3]=255^t[n+1];for(var r=0;i>r;++r)t[n+r+4]=s[r];return 8*(n+4+i)},kf=function(t,e,s,i,n,r,o,a,l,c,u){Vt(e,u++,s),++n[256];for(var h=nl(n,15),d=h[0],g=h[1],p=nl(r,15),m=p[0],v=p[1],b=Sf(d),y=b[0],w=b[1],A=Sf(m),I=A[0],k=A[1],$=new Xe(19),O=0;y.length>O;++O)$[31&y[O]]++;for(O=0;I.length>O;++O)$[31&I[O]]++;for(var x=nl($,7),Y=x[0],X=x[1],Z=19;Z>4&&!Y[wf[Z-1]];--Z);var ae,D,K,q,ie=c+5<<3,Q=Ji(n,Fs)+Ji(r,io)+o,P=Ji(n,d)+Ji(r,m)+o+14+3*Z+Ji($,Y)+(2*$[16]+3*$[17]+7*$[18]);if(Q>=ie&&P>=ie)return Lr(e,u,t.subarray(l,l+c));if(Vt(e,u,1+(Q>P)),u+=2,Q>P){ae=un(d,g,0),D=d,K=un(m,v,0),q=m;var U=un(Y,X,0);for(Vt(e,u,w-257),Vt(e,u+5,k-1),Vt(e,u+10,Z-4),u+=14,O=0;Z>O;++O)Vt(e,u+3*O,Y[wf[O]]);u+=3*Z;for(var V=[y,I],W=0;2>W;++W){var ee=V[W];for(O=0;ee.length>O;++O)Vt(e,u,U[le=31&ee[O]]),u+=Y[le],le>15&&(Vt(e,u,ee[O]>>>5&127),u+=ee[O]>>>12)}}else ae=EA,D=Fs,K=wA,q=io;for(O=0;a>O;++O)if(i[O]>255){var le;Qi(e,u,ae[257+(le=i[O]>>>18&31)]),u+=D[le+257],le>7&&(Vt(e,u,i[O]>>>23&31),u+=yc[le]);var _e=31&i[O];Qi(e,u,K[_e]),u+=q[_e],_e>3&&(Qi(e,u,i[O]>>>5&8191),u+=bc[_e])}else Qi(e,u,ae[i[O]]),u+=D[i[O]];return Qi(e,u,ae[256]),u+D[256]},SA=new mi([65540,131080,131088,131104,262176,1048704,1048832,2114560,2117632]),kA=new dt(0),AA=(function(){for(var t=new mi(256),e=0;256>e;++e){for(var s=e,i=9;--i;)s=(1&s&&3988292384)^s>>>1;t[e]=s}return t})(),rl=function(t,e,s){for(;s;++e)t[e]=s,s>>>=8};IA=!!Xl||!!gn,lv=new WeakMap,cv="text/plain",ol=0,Ur=!1,uv=(t,e)=>{let[s,i]=t.split("#"),[n,r]=s.split("?");if(!r)return t;let o=r.split("&").filter(a=>a.split("=")[0]!==e).join("&");return`${n}${o?`?${o}`:""}${i?`#${i}`:""}`},wn=(t,e,s=!0)=>{var i;let[n,r]=t.split("?"),o=_({},e),a=(i=r?.split("&").map(c=>{var u;let[h,d]=c.split("="),g=s&&(u=o[h])!==null&&u!==void 0?u:d;return delete o[h],`${h}=${g}`}))!==null&&i!==void 0?i:[],l=(function(c,u="&"){let h,d,g=[];return re(c,function(p,m){S(p)||S(m)||m==="undefined"||(h=encodeURIComponent((v=>v instanceof File)(p)?p.name:p.toString()),d=encodeURIComponent(m),g[g.length]=d+"="+h)}),g.join(u)})(o);return l&&a.push(l),a.length>0?`${n}?${a.join("&")}`:n},al=t=>{if(t.nl)return t.nl;let{data:e,compression:s}=t;if(!e)return;if(s===ut.GZipJS){let n=TA((function(r){var o=r.length;if(typeof TextEncoder<"u")return new TextEncoder().encode(r);for(var a=new dt(r.length+(r.length>>>1)),l=0,c=function(g){a[l++]=g},u=0;o>u;++u){if(l+5>a.length){var h=new dt(l+8+(o-u<<1));h.set(a),a=h}var d=r.charCodeAt(u);128>d?c(d):2048>d?(c(192|d>>>6),c(128|63&d)):d>55295&&57344>d?(c(240|(d=65536+(1047552&d)|1023&r.charCodeAt(++u))>>>18),c(128|d>>>12&63),c(128|d>>>6&63),c(128|63&d)):(c(224|d>>>12),c(128|d>>>6&63),c(128|63&d))}return av(a,0,l)})(li(e)),{mtime:0});return{contentType:cv,body:n.buffer.slice(n.byteOffset,n.byteOffset+n.byteLength),estimatedSize:n.byteLength}}if(s===ut.Base64){let n=(function(o){return o&&btoa(encodeURIComponent(o).replace(/%([0-9A-F]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16))))})(li(e)),r=(o=>"data="+encodeURIComponent(typeof o=="string"?o:li(o)))(n);return{contentType:"application/x-www-form-urlencoded",body:r,estimatedSize:new Blob([r]).size}}let i=li(e);return{contentType:"application/json",body:i,estimatedSize:new Blob([i]).size}},dv=t=>{let e=()=>t.transport==="sendBeacon"?{url:wn(t.url,{compression:ut.Base64}),encodedBody:al(_(_({},t),{},{compression:ut.Base64,nl:void 0}))}:{url:uv(t.url,"compression"),encodedBody:al(_(_({},t),{},{compression:void 0,nl:void 0}))},s;try{s=al(t)}catch(n){if(Vh(t.compression,vi(t.url,"compression")))return R.error("Failed to gzip request body, sending uncompressed payload",n),e();throw n}return s&&Vh(t.compression,vi(t.url,"compression"))&&!((i=s.body)instanceof ArrayBuffer?Rl(new Uint8Array(i)):ArrayBuffer.isView(i)&&Rl(new Uint8Array(i.buffer,i.byteOffset,i.byteLength)))?(Ur=!0,e()):{url:t.url,encodedBody:s};var i},hv=t=>{try{return dv(t)}catch(s){var e;return R.error(s),void((e=t.callback)===null||e===void 0||e.call(t,{statusCode:0,error:s}))}},RA=(function(){var t=he(function*(e){let s=yield(function(n){return Cl.apply(this,arguments)})(li(e.data),it.DEBUG,{rethrow:!0});if(!s)return e;let i=yield s.arrayBuffer();return _(_({},e),{},{nl:{contentType:cv,body:i,estimatedSize:i.byteLength}})});return function(e){return t.apply(this,arguments)}})(),CA=/Failed to fetch|NetworkError|Load failed/i,fv=t=>t?.name==="TypeError"&&CA.test(t?.message||""),gv=t=>{try{let e=(function(s,i=Date.now()){if(typeof s!="string"||!s)return;let n=s.trim(),r=/^\d+\s*,/.test(n)?n.slice(0,n.indexOf(",")).trim():n;if(/^\d+$/.test(r)){let l=1e3*Math.min(Number(r),300);return l>0?l:void 0}if(!/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)[a-z]*[ ,]/.test(r))return;let o=/^\w{3} \w{3} /.test(r)?r+" GMT":r,a=Date.parse(o)-i;return Number.isFinite(a)&&a>0?Math.min(a,Nr):void 0})(t());return S(e)?void 0:Math.min(e,3e4)}catch{return}},pv=t=>{let e=hv(t);if(!e)return;let s=new Xl;lv.set(s,!0);let{url:i,encodedBody:n}=e;s.open(t.method||"GET",i,!0);let{contentType:r,body:o}=n??{};re(t.headers,function(a,l){s.setRequestHeader(l,a)}),r&&s.setRequestHeader("Content-Type",r),t.timeout&&(s.timeout=t.timeout),s.onreadystatechange=()=>{if(s.readyState===4){var a;let l={statusCode:s.status,text:s.responseText};if(s.status===200)try{l.json=JSON.parse(s.responseText)}catch{}(a=t.callback)===null||a===void 0||a.call(t,l,gv(()=>s.getResponseHeader("Retry-After")))}},s.send(o)},vv=t=>{let e=hv(t);if(!e)return;let{url:s,encodedBody:i}=e,{contentType:n,body:r,estimatedSize:o}=i??{},a=new Headers;re(t.headers,function(p,m){a.append(m,p)}),n&&a.append("Content-Type",n);let l=null,c=!1;if(Sh){let p=new Sh;l={signal:p.signal,timeout:setTimeout(()=>{c=!0;try{p.abort(Bg("AbortError","PostHog request timed out"+((m=t.timeout)?` after ${m}ms`:"")))}catch(v){h(v)}var m},t.timeout)}}let u=!1,h=p=>{var m;u||(u=!0,c&&p?.name==="AbortError"||fv(p)?R.warn(p):R.error(p),(m=t.callback)===null||m===void 0||m.call(t,{statusCode:0,error:p}))},d=0,g=()=>{ol-=d,d=0,l&&clearTimeout(l.timeout)};try{let p=_({method:t?.method||"GET",headers:a,referrerPolicy:"strict-origin",body:r,signal:l?.signal},t.fetchOptions),m=o??(S(r)?0:void 0);p.keepalive=p.method==="POST"&&!t.sl&&p.keepalive!==!1&&p.body===r&&!S(m)&&m>=0&&52428.8>ol+m,p.keepalive&&(d=m,ol+=d),gn(s,p).then(v=>v.text().then(b=>{var y;if(u)return;let w={statusCode:v.status,text:b};if(v.status===200)try{w.json=JSON.parse(b)}catch(A){R.error(A)}u=!0,g(),(y=t.callback)===null||y===void 0||y.call(t,w,gv(()=>v.headers.get("Retry-After")))})).catch(v=>{g(),h(v)}).finally(g)}catch(p){g(),h(p)}},Kl=t=>{try{var e;let{url:s,encodedBody:i}=dv(t),{contentType:n,body:r,estimatedSize:o}=i??{};if(!r)return;let a=r instanceof Blob?r:new Blob([r],{type:n});if(Le.sendBeacon(s,a))return;let l=N(t.data)?t.data:(e=t.data)===null||e===void 0?void 0:e.batch;if(N(l)&&l.length>1&&(o??0)>16384){let c=Math.ceil(l.length/2),u=h=>N(t.data)?h:_(_({},t.data),{},{batch:h});return Kl(_(_({},t),{},{data:u(l.slice(0,c))})),void Kl(_(_({},t),{},{data:u(l.slice(c))}))}R.warn(`Beacon of ~${o??0} bytes was rejected by the browser, falling back to ${gn?"fetch":"XHR"}`),gn?vv(_(_({},t),{},{sl:!0})):pv(t)}catch(s){R.warn("Beacon send failed",s)}},Af=(t,e,s,i)=>{let n=i==="query"?e==="POST"?"sent_at":"_":void 0;return wn(s===ut.GZipJS?uv(t,"compression"):t,_(_({},n?{[n]:Date.now().toString()}:{}),s===ut.GZipJS?{}:{compression:s}))},OA=(()=>{let t=[];return gn&&t.push({transport:"fetch",method:vv}),Xl&&t.push({transport:"XHR",method:pv}),Le?.sendBeacon&&t.push({transport:"sendBeacon",method:Kl}),t})(),_v=!IA&&Ye?.indexOf("MSIE")===-1&&Ye?.indexOf("Mozilla")===-1;PA=class{constructor(t,e){this.rl=!0,this.ol=[],this.al=Rt(e?.flush_interval_ms||3e3,250,5e3,R.createLogger("flush interval"),3e3),this.ll=t}enqueue(t){this.ol.push(t),this.ul||this.cl()}unload(){this.hl();let t=this.ol.length>0?this.dl():{},e=Object.values(t);[...e.filter(s=>s.url.indexOf("/e")===0),...e.filter(s=>s.url.indexOf("/e")!==0)].map(s=>{this.vl(_(_({},s),{},{callback:void 0}),"sendBeacon")})}enable(){this.rl=!1,this.cl()}cl(){this.rl||(this.ul=setTimeout(()=>{this.hl(),this.fl()},this.al))}fl(){if(this.ol.length>0){let t=this.dl();for(let e in t)this.vl(t[e])}}vl(t,e){try{this.ll(t,e)}catch(s){R.error(s)}}hl(){clearTimeout(this.ul),this.ul=void 0}dl(){let t={},e={};re(this.ol,s=>{var i;let n=s,r=((n?n.batchKey:null)||n.url)+(n.batchGroup?`:${n.batchGroup}`:"");S(t[r])&&(t[r]=_(_({},n),{},{data:[],callback:void 0,fireCallbackOnDrop:void 0}),e[r]=[]),(i=t[r].data)===null||i===void 0||i.push(n.data),n.callback&&e[r].push(n.callback)});for(let s in e){let i=e[s];i.length&&(t[s].callback=n=>{for(let r of i)r(n)})}return this.ol=[],t}},$A=["retriesPerformedSoFar"],xA=class{constructor(t){this._instance=t,this.pl=!1,this.gl=3e3,this.ol=[],this.ol=[],this.ml=!0,this.resume()}resume(){if(!S(E)&&"onLine"in E.navigator){if(this.ml=E.navigator.onLine,this.yl)return;this.yl=()=>{this.ml=!0,this.fl()},this.bl=()=>{this.ml=!1},se(E,"online",this.yl),se(E,"offline",this.bl)}}get length(){return this.ol.length}retriableRequest(t,e){let{retriesPerformedSoFar:s}=t,i=Kg(t,$A);Gt(s)&&(i.url=wn(i.url,{retry_count:s})),mv(this._instance,e?_(_({},i),{},{transport:e}):i,(n,r)=>{var o;if(n.statusCode!==200&&(400>n.statusCode||n.statusCode>=500)){if((n.statusCode===0?3:10)>(s??0))return void this.Ls(_({retriesPerformedSoFar:s},i),r);n.statusCode===0&&R.warn(`Request failed before receiving an HTTP response; this can happen due to network issues, CORS, browser blocking, or ad blockers. Stopped retrying after ${s??0} retries.`)}(o=i.callback)===null||o===void 0||o.call(i,n)})}Ls(t,e){let s=t.retriesPerformedSoFar||0;t.retriesPerformedSoFar=s+1;let i=Math.max((function(o){let a=3e3*Math.pow(2,o),l=a/2,c=Math.min(18e5,a),u=(Math.random()-.5)*(c-l);return Math.ceil(c+u)})(s),e??0),n=Date.now()+i;this.ol.push({retryAt:n,requestOptions:t});let r=`Enqueued failed request for retry in ${i}`;navigator.onLine||(r+=" (Browser is offline)"),R.warn(r),this.pl||(this.pl=!0,this._l())}_l(){if(this.wl&&clearTimeout(this.wl),this.ol.length===0)return this.pl=!1,void(this.wl=void 0);this.wl=setTimeout(()=>{this.ml&&this.ol.length>0&&this.fl(),this._l()},this.gl)}fl(){let t=Date.now(),e=[],s=this.ol.filter(i=>t>i.retryAt||(e.push(i),!1));if(this.ol=e,s.length>0)for(let{requestOptions:i}of s)this.retriableRequest(i)}unload(){this.wl&&(clearTimeout(this.wl),this.wl=void 0),this.pl=!1,S(E)||(this.yl&&(E.removeEventListener("online",this.yl),this.yl=void 0),this.bl&&(E.removeEventListener("offline",this.bl),this.bl=void 0));for(let{requestOptions:t}of this.ol)try{this._instance._send_request(_(_({},t),{},{callback:N(t.data)?void 0:t.callback,transport:"sendBeacon"}))}catch(e){R.error(e)}this.ol=[]}},DA=class{constructor(t){this._instance=t,this.kl=()=>{var e,s,i,n;this.Sl||(this.Sl={});let r=this.scrollElement(),o=this.scrollY(),a=r?Math.max(0,r.scrollHeight-r.clientHeight):0,l=o+(r?.clientHeight||0),c=r?.scrollHeight||0;this.Sl.lastScrollY=Math.ceil(o),this.Sl.maxScrollY=Math.max(o,(e=this.Sl.maxScrollY)!==null&&e!==void 0?e:0),this.Sl.maxScrollHeight=Math.max(a,(s=this.Sl.maxScrollHeight)!==null&&s!==void 0?s:0),this.Sl.lastContentY=l,this.Sl.maxContentY=Math.max(l,(i=this.Sl.maxContentY)!==null&&i!==void 0?i:0),this.Sl.maxContentHeight=Math.max(c,(n=this.Sl.maxContentHeight)!==null&&n!==void 0?n:0)}}get xl(){return this._instance.config.scroll_root_selector}getContext(){return this.Sl}resetContext(){let t=this.Sl;return this.Sl=void 0,setTimeout(this.kl,0),t}startMeasuringScrollPosition(){se(E,"scroll",this.kl,{capture:!0}),se(E,"scrollend",this.kl,{capture:!0}),se(E,"resize",this.kl)}scrollElement(){if(this.xl){let s=N(this.xl)?this.xl:[this.xl];for(let i of s){var t;let n=E==null||(t=E.document)===null||t===void 0?void 0:t.querySelector(i);if(n)return n}return}var e;return E==null||(e=E.document)===null||e===void 0?void 0:e.documentElement}$l(t){var e,s;let i=t==="y"?"scrollTop":"scrollLeft";if(this.xl){let n=this.scrollElement();return n&&n[i]||0}return E?t==="y"?E.scrollY||E.pageYOffset||((e=E.document)===null||e===void 0||(e=e.documentElement)===null||e===void 0?void 0:e.scrollTop)||0:E.scrollX||E.pageXOffset||((s=E.document)===null||s===void 0||(s=s.documentElement)===null||s===void 0?void 0:s.scrollLeft)||0:0}scrollY(){return this.$l("y")}scrollX(){return this.$l("x")}},NA=t=>ev(t?.config.mask_personal_data_properties,t?.config.custom_personal_data_properties,t?.config.disable_capture_url_hashes),Tf=class{constructor(t,e,s,i){this.qe=n=>{let r=this.Cl();if(r&&r.sessionId===n)return;let o={sessionId:n,props:this.Tl(this._instance)};this.Il.register({[Ll]:o})},this._instance=t,this.Ml=e,this.Il=s,this.Tl=i||NA,this.Ml.onSessionId(this.qe)}Cl(){return this.Il.props[Ll]}getSetOnceProps(){var t;let e=(t=this.Cl())===null||t===void 0?void 0:t.props;return e?"r"in e?tv(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(){let t={};return re(fc(this.getSetOnceProps()),(e,s)=>{s==="$current_url"&&(s="url"),t[`$session_entry_${wl(s)}`]=e}),t}},no=class{on(t,e){return this.El[t]||(this.El[t]=[]),this.El[t].push(e),()=>{this.El[t]=this.El[t].filter(s=>s!==e)}}emit(t,e){for(let s of this.El[t]||[])s(e);for(let s of this.El["*"]||[])s(t,e)}constructor(){this.El={}}},ti=ye("[SessionId]"),If=864e5,Rf=class{on(t,e){return this.Pl.on(t,e)}constructor(t,e,s){var i;if(this.Rl=null,this.Al=null,this.Fl=[],this.Ol=void 0,this.Dl=!1,this.Pl=new no,this.Ll=(r,o)=>!(!Gt(r)||!Gt(o))&&Math.abs(r-o)>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.Mr=t.config,this.Il=t.persistence,this.je=void 0,this.Xt=void 0,this._sessionStartTimestamp=null,this.Nl=void 0,this._sessionActivityTimestamp=null,this.ql=e||bt,this.jl=s||bt;let n=this.Mr.persistence_name||this.Mr.token;if(this._sessionTimeoutMs=1e3*Rt(this.Mr.session_idle_timeout_seconds||1800,60,36e3,ti.createLogger("session_idle_timeout_seconds"),1800),t.register({$configured_session_timeout_ms:this._sessionTimeoutMs}),this.Bl(),this.zl="ph_"+n+"_window_id",this.Hl="ph_"+n+"_primary_window_exists",this.Ul()){let r=de.Dt(this.zl),o=de.Dt(this.Hl);r&&!o?this.je=r:de.Pt(this.zl),de.$t(this.Hl,!0)}!((i=this.Mr.bootstrap)===null||i===void 0)&&i.sessionID&&this.setBootstrapSessionId(this.Mr.bootstrap.sessionID),this.Wl()}get sessionTimeoutMs(){return this._sessionTimeoutMs}onSessionId(t){return S(this.Fl)&&(this.Fl=[]),this.Fl.push(t),this.Xt&&t(this.Xt,this.je),()=>{this.Fl=this.Fl.filter(e=>e!==t)}}Ul(){return this.Mr.persistence!=="memory"&&!this.Il.hi&&de.At()}Vl(t){t!==this.je&&(this.je=t,this.Ul()&&de.$t(this.zl,t))}Gl(){return this.je?this.je:this.Ul()?de.Dt(this.zl):null}Ql(t){let e=this.Rl;return!we(e)&&!we(t)&&5e3>Math.abs(t-e)}Zl(t,e,s){let i=e!==this._sessionActivityTimestamp,n=!(t!==this.Xt||s!==this._sessionStartTimestamp);this._sessionStartTimestamp=s,this._sessionActivityTimestamp=e,this.Xt=t,n&&!i||n&&this.Ql(e)||(this.Rl=e,this.Il.register({[ri]:[e,t,s]}))}Jl(){var t;let e=(t=this.Mr)===null||t===void 0?void 0:t.persistence_save_debounce_ms;return Gt(e)&&e>0}Kl(){this.Jl()?this.Il.refreshKey(ri):(this.Il.flush(),this.Il.load())}Xl(){var t;if(we(this._sessionActivityTimestamp)||this._sessionActivityTimestamp===this.Rl)return;this.Kl();let[,e,s]=this.Yl();e===this.Xt&&s===this._sessionStartTimestamp&&(this.Rl=this._sessionActivityTimestamp,this.Il.register({[ri]:[this._sessionActivityTimestamp,(t=this.Xt)!==null&&t!==void 0?t:null,this._sessionStartTimestamp]}),this.Il.flush())}tu(){let[t]=this.Yl(),e=Gt(t)?t:0,s=Gt(this._sessionActivityTimestamp)?this._sessionActivityTimestamp:0;return Math.max(e,s)}eu(t){return this.Kl(),this.Ll(t,this.tu())}Yl(){let t=this.Il.props[ri];return N(t)&&t.length===2&&t.push(t[0]),t||[0,null,0]}resetSessionId(){this.Rl=null,this.Nl=void 0,clearTimeout(this.iu),this.iu=void 0,this.Zl(null,null,null)}setBootstrapSessionId(t,e=!1){let s=((i,n=new Date().getTime())=>{try{let r=(o=>{let 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 r>n+6e4?void ti.error("Bootstrap sessionID cannot be in the future"):r}catch(r){return void ti.error("Invalid sessionID in bootstrap",r)}})(t);return!S(s)&&(e?this.Nl={sessionId:t,sessionStartTimestamp:s}:this.Zl(t,new Date().getTime(),s),!0)}destroy(){this.Dl=!0,this.Xl(),clearTimeout(this.iu),this.iu=void 0,this.Ol&&E&&(E.removeEventListener(Xr,this.Ol,{capture:!1}),this.Ol=void 0),this.Fl=[]}Wl(){this.Ol=()=>{this.Xl(),this.Ul()&&de.Pt(this.Hl)},se(E,Xr,this.Ol,{capture:!1})}checkAndGetSessionAndWindowId(t=!1,e=null,s=!1){if(this.Mr.cookieless_mode==="always")throw new Error('checkAndGetSessionAndWindowId should not be called with cookieless_mode="always"');let i=e||new Date().getTime(),n=this.Xt;if(s)this.Al=i;else if(we(this.Al)||this.Al>i||i-this.Al>=1e3){var r,o;(r=(o=this.Il).syncCookieProperties)===null||r===void 0||r.call(o),this.Al=i}let[,a,l]=this.Yl(),c=!S(n)&&a!==n,u=this.tu(),h=this.Gl(),d=this.Nl,g=!!d&&(d.sessionStartTimestamp>i+6e4||i-d.sessionStartTimestamp>If),p=d?g:Gt(l)&&Math.abs(i-l)>If,m=!1,v=c,b=!a||!!d,y=a,w=!b&&!t&&this.Ll(i,u);if(w&&(w=this.eu(i),w||ti.info("cross-tab refresh kept the session alive",{sessionId:a}),[,a,l]=this.Yl(),w||(b=!a||!!d)),b||w||p){v=!1;let $=d&&!g;a=$?d.sessionId:this.ql(),h=this.jl(),ti.info("new session ID assigned",{sessionId:a,windowId:h,bootstrapped:!!$,changeReason:{noSessionId:b,activityTimeout:w,sessionPastMaximumLength:p}}),l=$?d.sessionStartTimestamp:i,this.Nl=void 0,m=!0}else h||(h=this.jl(),m=!0),v=v||a!==y,v&&(ti.info("adopted cross-tab session id",{sessionId:a,windowId:h}),m=!0);let A=Gt(u)&&t&&!p?u:i,I=Gt(l)?l:new Date().getTime();this.Vl(h),this.Zl(a,A,I),t||this.Bl();let k={noSessionId:b,activityTimeout:w,sessionPastMaximumLength:p,crossTabAdoption:v};return m&&this.Fl.forEach($=>$(a,h,k)),{sessionId:a,windowId:h,sessionStartTimestamp:I,changeReason:m?k:void 0,lastActivityTimestamp:u}}Bl(){this.Dl||(clearTimeout(this.iu),this.iu=setTimeout(()=>{if(!this.Dl)if(this.eu(new Date().getTime())){let t=this.Xt;this.resetSessionId(),this.Pl.emit("forcedIdleReset",{idleSessionId:t})}else this.Bl()},1.1*this.sessionTimeoutMs))}},yv=function(t,e){if(!t)return!1;let s=t.userAgent;if(s&&Th(s,e))return!0;try{let i=t?.userAgentData;if(i?.brands&&i.brands.some(n=>Th(n?.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}},Or=t=>t.toLowerCase(),wv={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(Or).some(s=>t.map(Or).some(i=>s.includes(i))),not_icontains:(t,e)=>e.map(Or).every(s=>t.map(Or).every(i=>!s.includes(i))),gt:(t,e)=>e.some(s=>{let i=parseFloat(s);return!isNaN(i)&&t.some(n=>i>parseFloat(n))}),lt:(t,e)=>e.some(s=>{let i=parseFloat(s);return!isNaN(i)&&t.some(n=>i<parseFloat(n))})};Yl="custom",Cf="i.posthog.com",FA=/^\/static\//,LA=["/s/","/e/","/i/"],UA=class{constructor(t){this.nu={},this.instance=t}get apiHost(){let t=this.instance.config.api_host.trim().replace(/\/$/,"");return t==="https://app.posthog.com"?"https://us.i.posthog.com":t}get flagsApiHost(){let t=this.instance.config.flags_api_host;return t?t.trim().replace(/\/$/,""):this.apiHost}get uiHost(){var t;let e=(t=this.instance.config.ui_host)===null||t===void 0?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.nu[this.apiHost]||(this.nu[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":Yl),this.nu[this.apiHost]}su(t){if(!FA.test(t))return;let e=this.instance.config.asset_host;return typeof e=="string"&&e.trim().replace(/\/$/,"")||void 0}ru(t){let e=Kt(t);return e?e.protocol+"//"+e.host+e.pathname:void 0}ou(t,e,s){if(t==="ui")return s;let i=s,n=this.instance.config.rewriteRequestPath;if(n){var r;let o=((r=Kt(s))===null||r===void 0?void 0:r.href)||s;i=n(new URL(o)).toString()}if(n&&t==="api"&&LA.some(o=>e.indexOf(o)===0)){let o=this.ru(i);if(o){let a=this.apiHost,l=this.au;l?.apiHost===a&&l.rewriteRequestPath===n||(l={apiHost:a,rewriteRequestPath:n,urls:new Set},this.au=l),l.urls.add(o)}}return i}isIngestionEndpoint(t){let e=this.au,s=this.ru(t);return e?.apiHost===this.apiHost&&e.rewriteRequestPath===this.instance.config.rewriteRequestPath&&!!s&&e.urls.has(s)}endpointFor(t,e=""){if(e&&(e=e[0]==="/"?e:`/${e}`),t==="ui")return this.ou(t,e,this.uiHost+e);if(t==="flags")return this.ou(t,e,this.flagsApiHost+e);if(t==="assets"){let i=this.su(e);if(i)return this.ou(t,e,`${i}${e}`)}if(this.region===Yl)return this.ou(t,e,this.apiHost+e);let s=Cf+e;switch(t){case"assets":return this.ou(t,e,`https://${this.region}-assets.${s}`);case"api":return this.ou(t,e,`https://${this.region}.${s}`)}}},ne=ye("[Surveys]"),kv=t=>{try{let e=(s=>((i,n)=>`seenSurvey_${(function(r){return r.current_iteration&&r.current_iteration>0?`${r.id}_${r.current_iteration}`:r.id})(n)}`)(0,s))(t);if(localStorage.getItem(e))return;localStorage.setItem(e,"true")}catch(e){ne.error("Failed to persist survey seen state",e)}},BA=[tl.Popover,tl.Widget,tl.API],VA={ignoreConditions:!1,ignoreDelay:!1,displayType:Hl.Popover},jA=ye("[PostHog ExternalIntegrations]"),GA={intercom:"intercom-integration",crispChat:"crisp-chat-integration"},HA=class{constructor(t){this._instance=t}zo(t,e){var s,i;(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,t,n=>{if(n)return jA.error("failed to load script",n);e()})}startIfEnabledOrStop(){var t;for(let[n,r]of Object.entries((t=this._instance.config.integrations)!==null&&t!==void 0?t:{})){var e,s,i;r&&!(!((e=L.__PosthogExtensions__)===null||e===void 0||(e=e.integrations)===null||e===void 0)&&e[n])&&this.zo(GA[n],()=>{var o;(o=L.__PosthogExtensions__)===null||o===void 0||(o=o.integrations)===null||o===void 0||(o=o[n])===null||o===void 0||o.start(this._instance)}),!r&&(!((s=L.__PosthogExtensions__)===null||s===void 0||(s=s.integrations)===null||s===void 0)&&s[n])&&((i=L.__PosthogExtensions__)===null||i===void 0||(i=i.integrations)===null||i===void 0||(i=i[n])===null||i===void 0||i.stop())}}},Av="autocapture",Tv="featureFlags",Iv="logs",Rv="surveys",zA=class{constructor(t){this._instance=t}initialize(){}get(t){let e=this._instance.persistence;if(typeof t=="string")return e?.get_property(t);let s={};for(let i of t){let n=e?.get_property(i);S(n)||(s[i]=n)}return s}set(t,e){var s;(s=this._instance.persistence)===null||s===void 0||s.register(typeof t=="string"?{[t]:e}:t)}remove(t){var e;(e=this._instance.persistence)===null||e===void 0||e.unregister(t)}},qA=class{constructor(t){this.instance=t,this.A=R,this.kv=new zA(t),this.onEvent=e=>il(this.instance._addCaptureHook((s,i)=>{if(i)try{e({event:s,properties:i.properties})}catch(n){this.A.error("Browser extension event listener failed",n)}})),this.onRemoteConfig=e=>{let s=n=>{try{e(n)}catch(r){this.A.error("Browser extension remote config listener failed",r)}},i=this.instance.lu.on("extensionsRemoteConfig",s);return this.instance.uu&&s(this.instance.uu),il(i)}}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(){let t=this.instance.get_property(rc);return typeof t=="string"?t:void 0}get library(){return{name:it.LIB_NAME,version:it.LIB_VERSION}}get initialPersonProperties(){var t,e;return(t=(e=this.instance.persistence)===null||e===void 0?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,n;let r=(t=this.instance.sessionManager)===null||t===void 0?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,lastActivityTimestamp:(n=r?.lastActivityTimestamp)!==null&&n!==void 0?n:0}}catch{return{sessionId:"",windowId:"",sessionStartTimestamp:0,lastActivityTimestamp:0}}}get isOptedOut(){return this.instance.has_opted_out_capturing()}get canCapture(){return Ce(this.instance.is_capturing)?this.instance.is_capturing():!this.isOptedOut}get projectToken(){return this.instance.config.token}getExtension(t){let e;switch(t){case Tv:case"featureFlagsCommon":e=this.instance.featureFlags;break;case Iv:e=this.instance.logs;break;case Rv:e=this.instance.surveys;break;case Av:e=this.instance.autocapture}return e}capture(t,e,s){s?this.instance.capture(t,e,{timestamp:s.timestamp,uuid:s.uuid,$set:s.set,$set_once:s.setOnce}):this.instance.capture(t,e)}registerDynamicEventProperties(t){return il(this.instance.cu(t))}sendRequest(t){var e=this;return he(function*(s,i={}){var n;let r=(n=i.target)!==null&&n!==void 0?n:"api",o=e.instance.requestRouter.endpointFor(r,s),a=r==="api"&&s==="/i/v1/logs",l={method:i.method,url:i.query?wn(o,i.query):o,data:i.body,headers:i.headers,timeout:i.timeoutMs,fireCallbackOnDrop:!0,transport:i.transport,compression:i.compression,compressionFallback:i.target==="flags"&&i.compression==="best-available"?El.Base64:void 0,timestampMode:i.sentAt};return a&&(l.batchKey="logs"),i.transport==="sendBeacon"?(e.instance._send_request(l),{statusCode:202}):new Promise(c=>{l.callback=c,e.instance._send_request(l)})}).apply(this,arguments)}},dn={},cl=0,hn=()=>{},Of='Consent opt in/out is not valid with cookieless_mode="always" and will be ignored',si="Surveys module not available",Pf="sanitize_properties is deprecated. Use before_send instead",Cv="Invalid value for property_denylist config: ",WA=["$recording_status","$sdk_debug_recording_script_not_loaded","$sdk_debug_replay_url_trigger_status","$sdk_debug_replay_event_trigger_status","$sdk_debug_replay_linked_flag_trigger_status","$sdk_debug_replay_rrweb_error","$sdk_debug_replay_internal_buffer_length","$sdk_debug_replay_flushed_size"],KA=["$feature_flag_called","$$heatmap","$snapshot"],$f=t=>t.charAt(0)==="$"&&!M(KA,t),YA=/^[A-Za-z0-9_-]{1,400}$/,xf=/^fb\.[0-9]+\.[0-9]+\.[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)?$/,Df=/^fb\.[0-9]+\.[0-9]+\.[0-9]+$/,QA=["token","distinct_id",bp],tn="posthog",JA=t=>{let 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},ul=t=>{var e;return _({api_host:"https://us.i.posthog.com",flags_api_host:null,ui_host:null,asset_host:null,token:"",autocapture:!0,cross_subdomain_cookie:qk(T?.location),persistence:"localStorage+cookie",persistence_name:"",cookie_persisted_properties:[],loaded:hn,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_replay_sync_fetch:!1,__preview_external_dependency_versioned_paths:!1,__preview_cookie_wins_on_conflict:!1,debug:pe&&H(pe?.search)&&pe.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:(E==null||(e=E.location)===null||e===void 0?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,feature_flag_request_max_retries:1,surveys_request_timeout_ms:1e4,on_request_error(s){R.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:Op,before_send:void 0,get_current_url:void 0,request_queue_config:{flush_interval_ms:3e3},error_tracking:{},_onCapture:hn},(s=>({rageclick:s&&s>="2026-05-30"?{content_ignorelist:_c,ignore_text_selection:!0}:!s||"2025-11-30">s||{content_ignorelist:!0},capture_pageview:!s||"2025-05-24">s||"history_change",session_recording:JA(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))},XA=[["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"]],Nf=t=>{let e={};for(let[n,r]of XA)S(t[n])||(e[r]=t[n]);let s=ve({},e,t),i=t.__preview_external_dependency_versioned_paths;return S(i)||(S(t.strict_script_versioning)&&(s.strict_script_versioning=!!i),H(i)&&S(t.asset_host)&&(s.asset_host=i)),N(t.property_blacklist)&&(S(t.property_denylist)?s.property_denylist=t.property_blacklist:N(t.property_denylist)?s.property_denylist=[...t.property_blacklist,...t.property_denylist]:R.error(Cv+t.property_denylist)),s},ZA=class{constructor(){this.__forceAllowLocalhost=!1}get hu(){return this.__forceAllowLocalhost}set hu(t){R.error("WebPerformanceObserver is deprecated and has no impact on network capture. Use `_forceAllowLocalhostNetworkCapture` on `posthog.sessionRecording`"),this.__forceAllowLocalhost=t}},fn=class rs{du(e){if(!e)return;let s=this.vu.indexOf(e);s!==-1&&this.vu.splice(s,1)}fu(e,s){var i;return this.du(e),this.vu.push(s),(i=s.initialize)===null||i===void 0||i.call(s),s}pu(){return this.config.cookieless_mode==="always"||this.config.cookieless_mode==="on_reject"&&this.consent.isRejected()}gu(){if(this.mu||this.config.reuseAnonymousId||this.config.segment||this.pu())return;let e=this.config.persistence==="memory"||this.config.persistence==="sessionStorage";if(!e&&!this.config.disable_persistence||this.yu)return;let s,i,n;e?(s=`persistence is set to '${this.config.persistence}'`,i=this.config.persistence==="memory"?"on every page load":"for every new browser tab or window",n="Either set persistence to 'localStorage+cookie', keep this persistence and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."):(s="persistence is disabled (disable_persistence is true)",i="on every page load",n="Either set disable_persistence to false, keep persistence disabled and pass a stable ID through bootstrap.distinctID, or enable reuseAnonymousId."),this.mu=!0,console.warn("[PostHog.js]",`${s} but no bootstrap.distinctID was provided. PostHog will mint a new distinct ID ${i}, 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. ${n}`)}bu(){let e=this.persistence;if(!e||this._u)return;if(this.pu())return void(this.config.cookieless_mode==="on_reject"&&this.get_distinct_id()!=="$posthog_cookieless"&&(this.wu(),this.ku()));if(this.get_distinct_id()!=="$posthog_cookieless")return;this.Su()||e.load(!0);let s=this.get_distinct_id();if(!s||s==="$posthog_cookieless"){let i=this.config.get_device_id(bt());this.register({distinct_id:i,$device_id:i}),e.set_property(Qe,qt)}this.wu()}get decideEndpointWasHit(){var e,s;return(e=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&e!==void 0&&e}get flagsEndpointWasHit(){var e,s;return(e=(s=this.featureFlags)===null||s===void 0?void 0:s.hasLoadedFlags)!==null&&e!==void 0&&e}constructor(){var e;this.xu=!1,this.$u=!1,this.webPerformance=new ZA,this.Cu=!1,this.version=it.LIB_VERSION,this.Tu=new Set,this.Iu="",this.lu=new no,this.vu=[],this.Mu=[],this.Eu=!1,this.yu=!1,this.mu=!1,this._u=!1,this._calculate_event_properties=this.calculateEventProperties.bind(this),this.config=ul(),this.SentryIntegration=uA,this.sentryIntegration=i=>(function(n,r){let o=Hp(n,r);return{name:Gp,processEvent:a=>o(a)}})(this,i),this.__request_queue=[],this.__loaded=!1,this.analyticsDefaultEndpoint="/e/",this.Pu=!1,this.Ru=null,this.Au=null,this.Fu=null,this.scrollManager=new DA(this),this.pageViewManager=new _f(this),this.rateLimiter=new bA(this),this.requestRouter=new UA(this),this.consent=new Zk(this),this.externalIntegrations=new HA(this);let s=(e=rs.__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,n,r)=>{let o=H(i)?{[i]:n}:i;this.setPersonProperties(o),r?.({})},set_once:(i,n,r)=>{let o=H(i)?{[i]:n}:i;this.setPersonProperties(void 0,o),r?.({})}},this.on("eventCaptured",i=>R.info(`send "${i?.event}"`,i))}init(e,s,i){if(i&&i!==tn){var n;let r=(n=dn[i])!==null&&n!==void 0?n:new rs;return r._init(e,s,i),dn[i]=r,dn[tn][i]=r,r}return this._init(e,s,i)}_init(e,s={},i){var n,r,o;let a=H(e)?e.trim():"";if(!a)return R.critical("PostHog was initialized without a token. This likely indicates a misconfiguration. Please check the first argument passed to posthog.init()"),this;var l;if(this.__loaded)return a!==((l=this.config)===null||l===void 0?void 0:l.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('${a}', { ... }, 'project2')`):console.warn("[PostHog.js]","You have already initialized PostHog! Re-initializing is a no-op"),this;this.__loaded=!0,this.config=ul(s.defaults),s.debug=this.Ou(s.debug),this.Du=s,this.Lu=[],s.person_profiles?this.Au=s.person_profiles:s.process_person&&(this.Au=s.process_person);let c=ul(s.defaults),u=Nf(s),h=ve({},c,u,{name:i,token:a});G(c.rageclick)&&G(u.rageclick)&&(h.rageclick=ve({},c.rageclick,u.rageclick)),G(c.session_recording)&&G(u.session_recording)&&(h.session_recording=ve({},c.session_recording,u.session_recording)),this.set_config(h),this.config.on_xhr_error&&R.error("on_xhr_error is deprecated. Use on_request_error instead"),this.compression=s.disable_compression?void 0:ut.GZipJS;let d=this.Su(),g=!this.pu();if(this.persistence=new el(this.config,d,!0,g),this.sessionPersistence=this.config.persistence==="sessionStorage"||this.config.persistence==="memory"?this.persistence:new el(_(_({},this.config),{},{persistence:"sessionStorage"}),d,!1,g),this.Iu="ph_"+(this.config.persistence_name||this.config.token)+"_session_registered_properties",this.config.persistence!=="memory"&&!d&&de.At()){let y=de.Dt(this.Iu);N(y)&&y.forEach(w=>{H(w)&&this.Tu.add(w)})}else de.Pt(this.Iu);let p=_({},this.persistence.props),m=_({},this.sessionPersistence.props);this.register({$initialization_time:new Date().toISOString()}),this.Nu=new PA((y,w)=>this.qu(y,w),this.config.request_queue_config),this.ju=new xA(this),this.__request_queue=[];let v=this.pu();v||(this.sessionManager=new Rf(this),this.sessionPropsManager=new Tf(this,this.sessionManager,this.persistence),this.sessionManager.onSessionId((y,w,A)=>{(A?.activityTimeout||A?.sessionPastMaximumLength||A?.crossTabAdoption)&&this.Bu()})),this.zu(),this.config.__preview_deferred_init_extensions?(R.info("Deferring extension initialization to improve startup performance"),this.Hu=setTimeout(()=>{this.Hu=void 0,this.Uu(v)},0)):(R.info("Initializing extensions synchronously"),this.Uu(v)),it.DEBUG=it.DEBUG||this.config.debug,it.DEBUG&&R.info("Starting in debug mode",{this:this,config:s,thisC:_({},this.config),p,s:m}),this.config.identity_distinct_id&&!(!((n=s.bootstrap)===null||n===void 0)&&n.distinctID)&&(s.bootstrap=_(_({},s.bootstrap),{},{distinctID:this.config.identity_distinct_id,isIdentifiedID:!0}));let b=(r=s.bootstrap)===null||r===void 0?void 0:r.distinctID;if(this.yu=!!b&&!sn(b),(o=s.bootstrap)===null||o===void 0?void 0:o.distinctID){let y=s.bootstrap.distinctID,w=this.get_distinct_id(),A=this.persistence.get_property(Qe);if(s.bootstrap.isIdentifiedID&&w!=null&&w!==y&&A==="anonymous")this.identify(y);else if(s.bootstrap.isIdentifiedID&&w!=null&&w!==y&&A==="identified")R.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{let I=this.config.get_device_id(bt()),k=s.bootstrap.isIdentifiedID?I:y;this.persistence.set_property(Qe,s.bootstrap.isIdentifiedID?Mr:qt),this.register({distinct_id:y,$device_id:k})}}if(v)this.register_once({distinct_id:za,$device_id:null},"");else if(!this.get_distinct_id()){let y=this.config.get_device_id(bt());this.register_once({distinct_id:y,$device_id:y},""),this.persistence.set_property(Qe,qt)}return se(E,"onpagehide"in self?"pagehide":"unload",this._handle_unload.bind(this),{passive:!1}),se(E,"pageshow",()=>{var y;this.xu=!1,this.$u||(y=this.ju)===null||y===void 0||y.resume()}),s.segment?vf(this,()=>this.Wu()):this.Wu(),Ce(this.config._onCapture)&&this.config._onCapture!==hn&&(R.warn("onCapture is deprecated. Please use `before_send` instead"),this.on("eventCaptured",y=>this.config._onCapture(y.event,y))),this.config.ip&&R.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 bv.apply(this,arguments)})().then(y=>{y&&this.register({[Ha]:y})}).catch(hn),this}Vu(e){let s=e;return H(s.name)&&Ce(s.setup)}Gu(e,s){var i=this;this.Vu(e)?s.push(he(function*(){try{yield e.setup(i.Qu())}catch(r){R.error(`Failed to set up extension "${e.name}"`,r);try{var n;yield(n=e.dispose)===null||n===void 0?void 0:n.call(e)}catch(o){R.error(`Failed to dispose extension "${e.name}"`,o)}}})):this.vu.push(e)}zu(){var e,s,i,n=this;let r=(e=(s=this.config.__extensionClasses)===null||s===void 0?void 0:s.featureFlags)!==null&&e!==void 0?e:(i=rs.__defaultExtensionClasses)===null||i===void 0?void 0:i.featureFlags;var o,a,l;if(r)if(this.featureFlags&&this.featureFlags instanceof r||((o=this.Zu)===null||o===void 0||o.call(this),this.Zu=void 0,this.featureFlags=new r(this)),Ce(this.featureFlags.onReloading)&&Ce(this.featureFlags.setup)){if(!this.Zu){this.Zu=this.featureFlags.onReloading(()=>{this.lu.emit("featureFlagsReloading",!0)});let c=this.featureFlags;he(function*(){try{yield c.setup(n.Qu())}catch(u){R.error("Failed to set up feature flags",u);let h=n.Zu;n.Zu=void 0;try{h?.()}catch(d){R.error("Failed to unsubscribe feature flag reloading",d)}try{yield c.dispose()}catch(d){R.error("Failed to dispose feature flags",d)}}})()}}else(a=(l=this.featureFlags).initialize)===null||a===void 0||a.call(l)}Uu(e){let s=performance.now(),i=_(_({},rs.__defaultExtensionClasses),this.config.__extensionClasses),n=[];var r,o,a,l,c,u,h,d;i.exceptions&&this.vu.push(this.exceptions=(r=this.exceptions)!==null&&r!==void 0?r:new i.exceptions(this)),i.historyAutocapture&&this.vu.push(this.historyAutocapture=new i.historyAutocapture(this)),i.tracingHeaders&&this.vu.push(this.tracingHeaders=new i.tracingHeaders(this)),i.siteApps&&this.vu.push(this.siteApps=new i.siteApps(this)),i.sessionRecording&&!e&&this.vu.push(this.sessionRecording=new i.sessionRecording(this)),this.config.disable_scroll_properties||n.push(()=>{this.scrollManager.startMeasuringScrollPosition()}),i.autocapture&&this.Gu(this.autocapture=new i.autocapture(this),n),i.surveys&&this.Gu(this.surveys=(o=this.surveys)!==null&&o!==void 0?o:new i.surveys(this),n),i.logs&&this.Gu(this.logs=(a=this.logs)!==null&&a!==void 0?a:new i.logs(this),n),i.metrics&&this.vu.push(this.metrics=(l=this.metrics)!==null&&l!==void 0?l:new i.metrics(this)),i.conversations&&this.vu.push(this.conversations=(c=this.conversations)!==null&&c!==void 0?c:new i.conversations(this)),i.productTours&&this.vu.push(this.productTours=new i.productTours(this)),i.heatmaps&&this.vu.push(this.heatmaps=new i.heatmaps(this)),i.webVitalsAutocapture&&this.vu.push(this.webVitalsAutocapture=new i.webVitalsAutocapture(this)),i.exceptionObserver&&this.vu.push(this.exceptionObserver=new i.exceptionObserver(this)),i.deadClicksAutocapture&&this.vu.push(this.deadClicksAutocapture=new i.deadClicksAutocapture(this,cA)),i.toolbar&&this.vu.push(this.toolbar=(u=this.toolbar)!==null&&u!==void 0?u:new i.toolbar(this)),i.experiments&&this.vu.push(this.experiments=(h=this.experiments)!==null&&h!==void 0?h:new i.experiments(this)),i.webMCP&&this.vu.push(this.webMCP=(d=this.webMCP)!==null&&d!==void 0?d:new i.webMCP(this)),this.vu.forEach(g=>{g.initialize&&n.push(()=>{var p;(p=g.initialize)===null||p===void 0||p.call(g)})}),n.push(()=>{if(this.Ju){let g=this.Ju;this.Ju=void 0,this.vu.forEach(p=>{var m;return(m=p.onRemoteConfig)===null||m===void 0?void 0:m.call(p,g)})}}),this.Ku(n,s)}Ku(e,s){for(;e.length>0;){if(this.config.__preview_deferred_init_extensions&&performance.now()-s>=30&&e.length>0)return void(this.Hu=setTimeout(()=>{this.Hu=void 0,this.Ku(e,s)},0));let n=e.shift();if(n)try{n()}catch(r){R.error("Error initializing extension:",r)}}let i=Math.round(performance.now()-s);this.register_for_session({[Ep]:this.config.__preview_deferred_init_extensions?"deferred":"synchronous",[wp]:i}),this.config.__preview_deferred_init_extensions&&R.info(`PostHog extensions initialized (${i}ms)`)}el(e){if(!T||!T.body)return R.info("document not ready yet, trying again in 500 milliseconds..."),void setTimeout(()=>{this.el(e)},500);if(this.config.__preview_deferred_init_extensions&&(this.Ju=e),this.uu=e,this.compression=void 0,e.ok){var s;let i=e.config;i.supportedCompression&&!this.config.disable_compression&&(this.compression=M(i.supportedCompression,ut.GZipJS)?ut.GZipJS:M(i.supportedCompression,ut.Base64)?ut.Base64:void 0),!((s=i.analytics)===null||s===void 0)&&s.endpoint&&(this.analyticsDefaultEndpoint=i.analytics.endpoint)}this.set_config({person_profiles:this.Au?this.Au:Op}),this.lu.emit("extensionsRemoteConfig",e),this.vu.forEach(i=>{var n;return(n=i.onRemoteConfig)===null||n===void 0?void 0:n.call(i,e)})}Wu(){try{this.config.loaded(this)}catch(e){R.critical("`loaded` function failed",e)}if(this.Xu(),this.config.internal_or_test_user_hostname&&pe?.hostname){let e=pe.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.pu())&&this.Yu()},1),this.tc=new iv(this),this.tc.load()}Xu(){var e;this.is_capturing()&&this.config.request_batching&&((e=this.Nu)===null||e===void 0||e.enable())}_dom_loaded(){this.is_capturing()&&ai(this.__request_queue,e=>this.qu(e)),this.__request_queue=[],this.Xu()}_handle_unload(){var e,s,i,n,r,o;this.xu=!0,(e=this.surveys)===null||e===void 0||(s=e.handlePageUnload)===null||s===void 0||s.call(e),(i=this.metrics)===null||i===void 0||i.flush("sendBeacon"),this.config.request_batching?(this.ec()&&this.capture(Xh),(n=this.logs)===null||n===void 0||n.flushLogs("sendBeacon"),(r=this.Nu)===null||r===void 0||r.unload(),(o=this.ju)===null||o===void 0||o.unload()):this.ec()&&this.capture(Xh,null,{transport:"sendBeacon"})}_send_request(e){mv(this,e)}qu(e,s){this.ju?this.ju.retriableRequest(e,s):this._send_request(s?_(_({},e),{},{transport:s}):e)}_execute_array(e){cl++;try{let s,i=[],n=[],r=[];ai(e,a=>{if(a)if(s=a[0],N(s))r.push(a);else if(Ce(a))try{a.call(this)}catch(l){R.error("Error executing queued PostHog call",a,l)}else N(a)&&s==="alias"?i.push(a):N(a)&&s.indexOf("capture")!==-1&&Ce(this[s])?r.push(a):n.push(a)});let o=function(a,l){ai(a,function(c){try{if(N(c[0])){let u=l;re(c,function(h){u=u[h[0]].apply(u,h.slice(1))})}else l[c[0]].apply(l,c.slice(1))}catch(u){R.error("Error executing queued PostHog call",c,u)}})};o(i,this),o(n,this),o(r,this)}finally{cl--}}push(e){if(cl>0&&N(e)&&H(e[0])){let s=rs.prototype[e[0]];return void(Ce(s)&&s.apply(this,e.slice(1)))}this._execute_array([e])}get nc(){return{property:Qh,persistenceKey:ui,cookieName:"_fbc",pattern:xf,register:(e,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[ui]:{value:e,delivered:s}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(ui)}}}get sc(){return{property:Jh,persistenceKey:on,cookieName:"_fbp",pattern:Df,register:(e,s)=>{var i;return(i=this.persistence)===null||i===void 0?void 0:i.register({[on]:{value:e,delivered:s}})},unregister:()=>{var e;return(e=this.persistence)===null||e===void 0?void 0:e.unregister(on)}}}rc(e){var s;let i=(s=this.persistence)===null||s===void 0?void 0:s.get_property(e.persistenceKey);return H(i)&&e.pattern.test(i)?{value:i,delivered:!1}:G(i)&&H(i.value)&&e.pattern.test(i.value)?{value:i.value,delivered:i.delivered===!0}:void 0}oc(e,s,i){return s===i?.value?{value:s,pending:!i.delivered}:(e.register(s,!1),{value:s,pending:!0})}ac(e){if(!this.config.save_campaign_params||this.pu())return;let s=ln(e.cookieName);return H(s)&&e.pattern.test(s)?s:void 0}lc(e,s,i,n){if(!this.persistence)return;let r=this.nc;this.persistence.refreshKey(r.persistenceKey);let o=this.rc(r);if(n)return void r.unregister();if(i)return H(s)&&xf.test(s)?this.oc(r,s,o):void r.unregister();let a=H(e)&&YA.test(e)?e:void 0,l=this.ac(r);return l&&((c,u,h)=>{let d=c.split(".");if(u)return d[3]===u;if(!h)return!0;let g=h.value.split(".");return d[3]===g[3]||Number(d[2])>Number(g[2])})(l,a,o)?this.oc(r,l,o):a?o?.value.split(".")[3]===a?{value:o.value,pending:!o.delivered}:this.oc(r,`fb.1.${Date.now()}.${a}`,o):o?{value:o.value,pending:!o.delivered}:void 0}uc(e,s,i){if(!this.persistence)return;let n=this.sc;this.persistence.refreshKey(n.persistenceKey);let r=this.rc(n);if(i)return void n.unregister();if(s)return H(e)&&Df.test(e)?this.oc(n,e,r):void n.unregister();let o=this.ac(n);return o?this.oc(n,o,r):r?{value:r.value,pending:!r.delivered}:void 0}cc(e,s){if(!this.persistence)return;this.persistence.refreshKey(e.persistenceKey);let i=this.rc(e);i?.value!==s||i.delivered||e.register(s,!0)}capture(e,s,i){var n,r;if(!(this.__loaded&&this.persistence&&this.sessionPersistence&&this.Nu))return void R.uninitializedWarning("posthog.capture");if(!this.is_capturing())return;if(S(e)||!H(e))return void R.error("No event name provided to posthog.capture");if(this.bu(),e==="$snapshot"&&this.pu())return;let o=!this.config.opt_out_useragent_filter&&this._is_bot();if(o&&!this.config.__preview_capture_bot_pageviews)return;let a=i?.skip_client_rate_limiting?void 0:this.rateLimiter.clientRateLimitContext();if(a?.isRateLimited)return void R.critical("This capture call is ignored due to client rate limiting.");let l;s?.$current_url&&!H(s?.$current_url)&&(R.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?.hc||R.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&&(l=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();let c=new Date,u=i?.timestamp||c,h=Oh(i?.uuid,bt),d={uuid:h,event:e,properties:this.calculateEventProperties(e,s||{},u,h)};e==="$pageview"&&this.config.__preview_capture_bot_pageviews&&o&&(d.event="$bot_pageview",d.properties.$browser_type="bot"),a&&(d.properties.$lib_rate_limit_remaining_tokens=a.remainingTokens);let g=e==="$feature_flag_called"&&d.properties.$feature_flag_has_experiment===!1&&this.get_property("$minimal_flag_called_events")===!0;i?.$set&&!g&&(d.$set=i?.$set);let p=G(s?.$set)?s.$set:void 0,m=N(s?.$unset)?s.$unset:[],v=i?.$unset||[],b=D=>{var K;let q=!!i?.$set&&D in i.$set;return{hasProvided:q||!!p&&D in p,provided:q?i==null||(K=i.$set)===null||K===void 0?void 0:K[D]:p?.[D],unset:m.indexOf(D)!==-1||v.indexOf(D)!==-1}},y=b(Qh),w=b(Jh),A=[{channel:this.nc,hasProvided:y.hasProvided,update:this.lc(l?.fbclid,y.provided,y.hasProvided,y.unset)},{channel:this.sc,hasProvided:w.hasProvided,update:this.uc(w.provided,w.hasProvided,w.unset)}];for(let{channel:D,hasProvided:K,update:q}of A)q&&d.properties.$process_person_profile===!0&&q.pending&&!K&&!g&&(d.$set=_({[D.property]:q.value},d.$set));let I=i?.$unset;I&&(d.$unset=I);let k=g?void 0:this.dc(i?.$set_once,e!==Zh,e===Pp);if(k&&(d.$set_once=k),i?._noTruncate||($=this.config.properties_string_max_length,d=(function(D,K){let q=new Set;return(function ie(Q,P){if(Q!==Object(Q))return K?K(Q):Q;if(q.has(Q))return;let U;if(q.add(Q),N(Q))U=[],ai(Q,V=>{U.push(ie(V))});else{let V={};re(bi(Q)?$p(Q):Q,(W,ee)=>{q.has(W)||(V[ee]=ie(W,ee))}),U=V}return U})(D)})(d,D=>H(D)?D.slice(0,$):D)),d.timestamp=u,S(i?.timestamp)||(d.properties.$event_time_override_provided=!0,d.properties.$event_time_override_system_time=c),g&&(d.properties=((D,K=[])=>{let q={},ie=Q=>{D[Q]!==void 0&&(q[Q]=D[Q])};return BS.forEach(ie),K.forEach(ie),q})(d.properties,QA)),e===ct.DISMISSED||e===ct.SENT){let D=s?.[sl.SURVEY_ID],K=s?.[sl.SURVEY_ITERATION];kv({id:D,current_iteration:K}),d.$set=_(_({},d.$set),{},{[MA({id:D,current_iteration:K},e===ct.SENT?"responded":"dismissed")]:!0})}else e===ct.SHOWN&&(d.$set=_(_({},d.$set),{},{[sl.SURVEY_LAST_SEEN_DATE]:new Date().toISOString()}));var $;if(e===yA.SHOWN){let D=s?.[bf.TOUR_TYPE];D&&(d.$set=_(_({},d.$set),{},{[`${bf.TOUR_LAST_SEEN_DATE}/${D}`]:new Date().toISOString()}))}let O=_(_({},d.properties.$set),d.$set);if(nt(O)||this.setPersonPropertiesForFlags(O),!B(this.config.before_send)){let D=this.Os(d);if(!D)return;d=D,d.uuid=Oh(d.uuid,bt)}this.sessionRecording&&!this.Eu&&$f(e)&&(this.Eu=!0,setTimeout(()=>this.Eu=!1,3e4));let x=A.filter(({channel:D,update:K})=>{var q,ie,Q;let P=(q=(ie=d.$set)===null||ie===void 0?void 0:ie[D.property])!==null&&q!==void 0?q:G((Q=d.properties)===null||Q===void 0?void 0:Q.$set)?d.properties.$set[D.property]:void 0;return K?.pending&&P===K.value});this.lu.emit("eventCaptured",d);let Y=(n=i?._url)!==null&&n!==void 0?n:this.requestRouter.endpointFor("api",this.analyticsDefaultEndpoint),X=i?._batchKey==="recordings"||/\/s\/(?:\?|$)/.test(Y),Z=_(_(_({method:"POST",url:Y,data:d,compression:"best-available",preferSyncCompression:i?.send_instantly,timestampMode:X?"body":"capture-body",batchKey:i?._batchKey},X&&(!((r=d.properties)===null||r===void 0)&&r.$session_id)?{batchGroup:d.properties.$session_id+(d.properties.$window_id?`-${d.properties.$window_id}`:"")}:{}),i?.transport?{transport:i.transport}:{}),x.length?{fireCallbackOnDrop:!0,callback:D=>{if(D.statusCode>=200&&300>D.statusCode)for(let{channel:K,update:q}of x)this.cc(K,q.value)}}:{});if(!this.config.request_batching||i&&!i?._batchKey||i?.send_instantly){var ae;let D;!Z.transport&&!Z.callback&&nt((ae=this.config.request_headers)!==null&&ae!==void 0?ae:{})&&this.xu&&(D="sendBeacon"),this.qu(Z,D)}else this.Nu.enqueue(Z);return d}_addCaptureHook(e){return this.on("eventCaptured",s=>e(s.event,s))}getExtension(e){var s;return(s=this.vc)===null||s===void 0?void 0:s.getExtension(e)}Qu(){var e;return(e=this.vc)!==null&&e!==void 0?e:this.vc=new qA(this)}cu(e){this.Mu.push(e);let s=!0;return()=>{if(!s)return;s=!1;let i=this.Mu.indexOf(e);i!==-1&&this.Mu.splice(i,1)}}fc(e=!0){var s,i,n;return!!(!((s=this.persistence)===null||s===void 0)&&s.consumeCookieIdentityChange())&&(this.Fu=null,this.persistence.get_property("$user_state")==="anonymous"&&((n=this.sessionPersistence)===null||n===void 0||n.clear(),this.Tu.clear(),this.gc()),(i=this.featureFlags)===null||i===void 0||i.reset(),e&&this.reloadFeatureFlags(),!0)}calculateEventProperties(e,s,i,n,r){if(i=i||new Date,!this.persistence||!this.sessionPersistence)return s;this.bu(),this.persistence.syncCookieProperties(),this.fc();let o=r?void 0:this.persistence.remove_event_timer(e),a=_({},s);if(a.token=this.config.token,a.$config_defaults=this.config.defaults,this.pu()&&(a[bp]=!0),e==="$snapshot"){let y=_(_({},this.persistence.properties()),this.sessionPersistence.properties());return a.distinct_id=y.distinct_id,(!H(a.distinct_id)&&!Te(a.distinct_id)||sn(a.distinct_id))&&R.error("Invalid distinct_id for replay event. This indicates a bug in your implementation"),a}let l=(function(y,w,A,I=!1){var k,$,O,x;if(!Ye)return{};let Y=y?[..._i,...w||[]]:[],[X,Z]=Mg(Ye),[ae,D]=(function(le){for(let _e=0;Ch.length>_e;_e++){let[Re,xe,Me]=Ch[_e],Be=le.match(Re);if(Be){let z=Me&&le.match(Me)||Be;return[xe,z?.[1]||""]}}return["",""]})(Ye),K=(function(){let le="u">typeof navigator?navigator:void 0;return le?.brave?{brave:!0}:{}})(),q={};S(A)||(q.detectGoogleSearchApp=A);let ie={},Q=(k=navigator)===null||k===void 0||(k=k.userAgentData)===null||k===void 0?void 0:k.platform,P=($=navigator)===null||$===void 0?void 0:$.maxTouchPoints,U=E==null||(O=E.screen)===null||O===void 0?void 0:O.width,V=E==null||(x=E.screen)===null||x===void 0?void 0:x.height,W=E?.devicePixelRatio;S(Q)||(ie.userAgentDataPlatform=Q),S(P)||(ie.maxTouchPoints=P),S(U)||(ie.screenWidth=U),S(V)||(ie.screenHeight=V),S(W)||(ie.devicePixelRatio=W);let ee=ve(fc({$os:X,$os_version:Z,$browser:Ng(Ye,navigator.vendor,K,q),$webview_app:ae,$webview_app_version:D,$device:Fg(Ye),$device_type:lS(Ye,ie),$timezone:zp(),$timezone_offset:vA()}),{$current_url:yn(I?ds(pe?.href):pe?.href,Y,bn),$host:pe?.host,$pathname:pe?.pathname,$raw_user_agent:Ye.length>1e3?Ye.substring(0,997)+"...":Ye,$browser_version:aS(Ye,navigator.vendor,K,q),$browser_language:Xp(),$browser_language_prefix:pA(),$screen_height:E?.screen.height,$screen_width:E?.screen.width,$viewport_height:E?.innerHeight,$viewport_width:E?.innerWidth,$lib:Wt.LIB_NAME,$lib_version:Wt.LIB_VERSION,$insert_id:Math.random().toString(36).substring(2,10)+Math.random().toString(36).substring(2,10),$time:Date.now()/1e3});return Wt.SDK_DIST_CHANNEL&&(ee.$sdk_dist_channel=Wt.SDK_DIST_CHANNEL),ee})(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){let{sessionId:y,windowId:w}=this.sessionManager.checkAndGetSessionAndWindowId(r,i.getTime(),!0);a.$session_id=y,a.$window_id=w}this.sessionPropsManager&&ve(a,this.sessionPropsManager.getSessionProps());try{var c;if(this.sessionRecording){let y=this.sessionRecording.sdkDebugProperties,w=!this.Eu&&$f(e);for(let A in y)(w||M(WA,A))&&(a[A]=y[A])}a.$sdk_debug_retry_queue_size=(c=this.ju)===null||c===void 0?void 0:c.length}catch(y){a.$sdk_debug_error_capturing_properties=String(y)}let u;if(this.requestRouter.region===Yl&&(a.$lib_custom_api_host=this.config.api_host),u=e!=="$pageview"||r?e!=="$pageleave"||r?this.pageViewManager.doEvent():this.pageViewManager.doPageLeave(i):this.pageViewManager.doPageView(i,n),a=ve(a,u),e==="$pageview"&&T&&(a.title=T.title),!S(o)){let y=i.getTime()-o;a.$duration=parseFloat((y/1e3).toFixed(3))}Ye&&this.config.opt_out_useragent_filter&&(a.$browser_type=this._is_bot()?"bot":"browser");let h=this.persistence.properties(),d=this.sessionPersistence.properties(),g=a.$groups,p=h.$groups;G(g)&&!nt(g)&&(a.$groups=_(_({},G(p)?p:{}),g)),re(["$referrer","$referring_domain"],y=>{y in h&&delete d[y]});let m={};if(this.Mu.length>0)for(let y of this.Mu.slice())try{ve(m,y())}catch(w){R.error("Failed to produce browser extension event properties",w)}a=ve({},l,h,d,_(_({},m),a)),a.$is_identified=this._isIdentified(),N(this.config.property_denylist)?re(this.config.property_denylist,function(y){delete a[y]}):R.error(Cv+this.config.property_denylist+" or property_blacklist config: "+this.config.property_blacklist);let v=this.config.sanitize_properties;v&&(R.error(Pf),a=v(a,e));let b=this.mc();return a.$process_person_profile=b,b&&!r&&this.yc("_calculate_event_properties"),a}dc(e,s=!0,i=!1){var n;if(!this.persistence||!this.mc()||this.Cu&&!i)return e;let r=this.persistence.get_initial_props(),o=(n=this.sessionPropsManager)===null||n===void 0?void 0:n.getSetOnceProps(),a=ve({},r,o||{},e||{}),l=this.config.sanitize_properties;return l&&(R.error(Pf),a=l(a,"$set_once")),s&&(this.Cu=!0),nt(a)?void 0:a}register(e,s){var i;(i=this.persistence)===null||i===void 0||i.register(e,s)}register_once(e,s,i){var n;(n=this.persistence)===null||n===void 0||n.register_once(e,s,i)}register_for_session(e){var s,i;(s=this.persistence)===null||s===void 0||s.syncCookieProperties(),this.fc(),(i=this.sessionPersistence)===null||i===void 0||i.register(e),Object.keys(e).forEach(n=>this.Tu.add(n)),this.gc()}unregister(e){var s;(s=this.persistence)===null||s===void 0||s.unregister(e)}unregister_for_session(e){var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(e),this.Tu.delete(e),this.gc()}bc(e,s){this.register({[e]:s})}Bu(){this.Tu.forEach(e=>{var s;(s=this.sessionPersistence)===null||s===void 0||s.unregister(e)}),this.Tu.clear(),this.gc()}gc(){var e;if(!this.Iu)return;if(this.config.persistence==="memory"||!((e=this.sessionPersistence)===null||e===void 0)&&e.hi||!de.At())return void de.Pt(this.Iu);let s=[];this.Tu.forEach(i=>s.push(i)),s.length>0?de.$t(this.Iu,s):de.Pt(this.Iu)}getFeatureFlag(e,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlag(e,s)}getFeatureFlagPayload(e){var s;return(s=this.featureFlags)===null||s===void 0?void 0:s.getFeatureFlagPayload(e)}getFeatureFlagResult(e,s){var i;return(i=this.featureFlags)===null||i===void 0?void 0:i.getFeatureFlagResult(e,s)}getAllFeatureFlags(){var e,s;return(e=(s=this.featureFlags)===null||s===void 0?void 0:s.getAllFeatureFlags())!==null&&e!==void 0?e:[]}isFeatureEnabled(e,s){var i,n;return(i=(n=this.featureFlags)===null||n===void 0?void 0:n.isFeatureEnabled(e,s))!==null&&i!==void 0?i:s?.defaultValue}reloadFeatureFlags(){var e;(e=this.featureFlags)===null||e===void 0||e.reloadFeatureFlags()}updateFlags(e,s,i){var n;(n=this.featureFlags)===null||n===void 0||n.updateFlags(e,s,i)}updateEarlyAccessFeatureEnrollment(e,s,i){var n;(n=this.featureFlags)===null||n===void 0||n.updateEarlyAccessFeatureEnrollment(e,s,i)}getEarlyAccessFeatures(e,s=!1,i){var n;return(n=this.featureFlags)===null||n===void 0?void 0:n.getEarlyAccessFeatures(e,s,i)}on(e,s){return this.lu.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:si}),()=>{})}onSessionId(e){var s,i;return(s=(i=this.sessionManager)===null||i===void 0?void 0:i.onSessionId(e))!==null&&s!==void 0?s:()=>{}}getSurveys(e,s=!1){this.surveys?this.surveys.getSurveys(e,s):e([],{isLoaded:!1,error:si})}getActiveMatchingSurveys(e,s=!1){this.surveys?this.surveys.getActiveMatchingSurveys(e,s):e([],{isLoaded:!1,error:si})}onActiveMatchingSurveysChanged(e){return this.surveys?this.surveys.onActiveMatchingSurveysChanged(e):(e([],{isLoaded:!1,error:si}),()=>{})}renderSurvey(e,s){var i;(i=this.surveys)===null||i===void 0||i.renderSurvey(e,s)}displaySurvey(e,s=VA){var i;(i=this.surveys)===null||i===void 0||i.displaySurvey(e,s)}cancelPendingSurvey(e){var s;(s=this.surveys)===null||s===void 0||s.cancelPendingSurvey(e)}canRenderSurvey(e){var s,i;return(s=(i=this.surveys)===null||i===void 0?void 0:i.canRenderSurvey(e))!==null&&s!==void 0?s:{visible:!1,disabledReason:si}}canRenderSurveyAsync(e,s=!1){var i,n;return(i=(n=this.surveys)===null||n===void 0?void 0:n.canRenderSurveyAsync(e,s))!==null&&i!==void 0?i:Promise.resolve({visible:!1,disabledReason:si})}_c(e){return!e||sn(e)?(R.critical("Unique user id has not been set in posthog.identify"),!1):e==="$posthog_cookieless"?(R.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())||(R.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 R.uninitializedWarning("posthog.identify");if(Te(e)&&(e=e.toString(),R.warn("The first argument to posthog.identify was a number, but it should be a string. It has been converted to a string.")),!this._c(e)||!this.yc("posthog.identify"))return;this.bu();let n=this.get_distinct_id(),r=this.persistence.syncCookieProperties()&&this.get_distinct_id()!==n,o=this.fc(!1),a=this.persistence.Oa(),l=!1;try{let 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(Qr),this.register({distinct_id:e}));let h=(this.persistence.get_property("$user_state")||"anonymous")===qt,d=e!==u,g=!d&&h;if(d&&h){var c;let p=this.config.reuseAnonymousId?{distinct_id:e}:{distinct_id:e,$anon_distinct_id:u};this.persistence.set_property(Qe,Mr),this.setPersonPropertiesForFlags({$set:s||{},$set_once:i||{}},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$identify",p,{$set:s||{},$set_once:i||{}})&&(this.Fu=ll(e,s,i)),(c=this.featureFlags)===null||c===void 0||c.setAnonymousDistinctId(this.config.reuseAnonymousId?void 0:u)}else if(g){this.persistence.set_property(Qe,Mr);let p=s||{},m=i||{};this.setPersonPropertiesForFlags({$set:p,$set_once:m},!1),this.config.cookieWinsOnConflict&&this.persistence.Da(),this.capture("$set",{$set:p,$set_once:m})&&(this.Fu=ll(e,s,i))}else(s||i)&&this.setPersonProperties(s,i);d||r||o?(this.reloadFeatureFlags(),this.featureFlags?this.featureFlags.resetFlagCallReported():this.unregister(ls)):g&&(s||i)&&this.reloadFeatureFlags(),l=!0}finally{a&&this.persistence.qa(l)}}setPersonProperties(e,s){if(!e&&!s||!this.yc("posthog.setPersonProperties"))return;let i=ll(this.get_distinct_id(),e,s);this.Fu!==i?(this.setPersonPropertiesForFlags({$set:e||{},$set_once:s||{}},!0),this.capture("$set",{$set:e||{},$set_once:s||{}})&&(this.Fu=i)):R.info("A duplicate setPersonProperties call was made with the same properties. It has been ignored.")}unsetPersonProperties(e){var s;let i=(N(e)?e:[e]).filter(n=>H(n)&&n.length>0);i.length!==0&&this.yc("posthog.unsetPersonProperties")&&((s=this.featureFlags)===null||s===void 0||s.unsetPersonPropertiesForFlags(i,!0),this.capture("$set",{$unset:i}),this.Fu=null)}group(e,s,i){var n;if(!e||!s)return void R.error("posthog.group requires a group type and group key");(n=this.persistence)===null||n===void 0||n.syncCookieProperties(),this.fc();let r=this.getGroups(),o=r[e]!==s;if(o&&this.resetGroupPropertiesForFlags(e),this.register({$groups:_(_({},r),{},{[e]:s})}),(o||i)&&this.mc()){let a={$group_type:e,$group_key:s};i&&(a.$group_set=i),this.capture(Zh,a)}i&&this.setGroupPropertiesForFlags({[e]:i}),o&&!i&&this.reloadFeatureFlags()}resetGroups(){this.register({$groups:{}}),this.resetGroupPropertiesForFlags(),this.reloadFeatureFlags()}setPersonPropertiesForFlags(e,s=!0){var i;(i=this.featureFlags)===null||i===void 0||i.setPersonPropertiesForFlags(e,s)}resetPersonPropertiesForFlags(e=!0){var s;(s=this.featureFlags)===null||s===void 0||s.resetPersonPropertiesForFlags(e)}setGroupPropertiesForFlags(e,s=!0){var i;this.yc("posthog.setGroupPropertiesForFlags")&&((i=this.featureFlags)===null||i===void 0||i.setGroupPropertiesForFlags(e,s))}resetGroupPropertiesForFlags(e){var s;(s=this.featureFlags)===null||s===void 0||s.resetGroupPropertiesForFlags(e)}reset(e){let s=Je(e)?e:e?.resetDeviceID,i=Je(e)||e==null?void 0:e.bootstrap;this.wc(s,!1,i)}wc(e,s=!1,i){var n,r,o,a,l,c;if(R.info("reset"),!this.__loaded)return R.uninitializedWarning("posthog.reset");let u=i?.sessionID;this.config.bootstrap=i||((n=this.Du)===null||n===void 0?void 0:n.bootstrap)||{},(r=this.featureFlags)===null||r===void 0||(o=r.updateConfig)===null||o===void 0||o.call(r,this.config,this.il());let h=this.get_property(rc),d=this.get_property(Ha),g=this.get_property(an);(a=this.sessionRecording)===null||a===void 0||a.flushBeforeIdentityReset();let p=this.is_capturing();s||this.consent.reset(),s||!p||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.");let m=(l=this.persistence)===null||l===void 0||(c=l.Oa)===null||c===void 0?void 0:c.call(l),v=this._u;this._u=v||s;let b=!1;try{var y,w,A,I,k,$,O,x,Y,X,Z,ae,D;if((y=this.persistence)===null||y===void 0||y.clear(),(w=this.sessionPersistence)===null||w===void 0||w.clear(),this.Tu.clear(),this.gc(),S(g)||(X=this.persistence)===null||X===void 0||X.register({$session_recording_remote_config:g}),(A=this.surveys)===null||A===void 0||A.reset(),(I=this.featureFlags)===null||I===void 0||I.reset(),(k=this.conversations)===null||k===void 0||k.reset(),($=this.logs)===null||$===void 0||$.reset(),(O=this.metrics)===null||O===void 0||O.reset(),(x=this.persistence)===null||x===void 0||x.set_property("$user_state","anonymous"),(Y=this.sessionManager)===null||Y===void 0||Y.resetSessionId(),this.Fu=null,this.config.cookieless_mode==="always")this.register_once({distinct_id:za,$device_id:null},"");else{let ie=this.config.get_device_id(bt());this.register_once({distinct_id:ie,$device_id:e?ie:h},""),e||S(d)||this.register({[Ha]:d})}if(this.register({$last_posthog_reset:new Date().toISOString()},1),i&&(i.distinctID&&!this.pu()&&((D=this.persistence)===null||D===void 0||D.set_property("$user_state",i.isIdentifiedID?"identified":"anonymous"),this.register({distinct_id:i.distinctID})),(Z=this.featureFlags)===null||Z===void 0||Z.initialize(),!B(u)&&!(!((ae=this.sessionManager)===null||ae===void 0)&&ae.setBootstrapSessionId(u,!0)))){let ie=_({},i);delete ie.sessionID,this.config.bootstrap=ie}delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,b=!0}finally{var K,q;this._u=v,m&&((K=this.persistence)===null||K===void 0||(q=K.qa)===null||q===void 0||q.call(K,b))}this.reloadFeatureFlags()}shutdown(e){var s=this;return he(function*(){if(!s.__loaded)return void R.uninitializedWarning("posthog.shutdown");s.$u=!0,clearTimeout(s.Hu),s.Hu=void 0;let i=s.Zu;s.Zu=void 0;for(let n of[()=>{var r;return(r=s.sessionRecording)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=s.logs)===null||r===void 0?void 0:r.flushLogs("sendBeacon")},()=>{var r;return(r=s.metrics)===null||r===void 0?void 0:r.flush("sendBeacon")},()=>{var r;return(r=s.metrics)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=s.logs)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=s.surveys)===null||r===void 0?void 0:r.dispose()},()=>{var r;return(r=s.autocapture)===null||r===void 0?void 0:r.dispose()},()=>i?.(),()=>{var r;return(r=s.Nu)===null||r===void 0?void 0:r.unload()},()=>{var r;return(r=s.ju)===null||r===void 0?void 0:r.unload()},()=>{var r;return(r=s.featureFlags)===null||r===void 0?void 0:r.destroy()},()=>{var r;return(r=s.persistence)===null||r===void 0?void 0:r.destroy()},()=>{var r;return(r=s.sessionPersistence)===null||r===void 0?void 0:r.destroy()}])try{let r=n();r&&Ce(r.then)&&r.then(void 0,o=>{R.error("Error during shutdown",o)})}catch(r){R.error("Error during shutdown",r)}})()}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===void 0||i.kc()}clearIdentity(){var e;delete this.config.identity_distinct_id,delete this.config.identity_hash,delete this.config.identity_claims,(e=this.conversations)===null||e===void 0||e.Sc()}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||s===void 0?void 0:s.checkAndGetSessionAndWindowId(!0).sessionId)!==null&&e!==void 0?e:""}get_session_replay_url(e){if(!this.sessionManager)return"";let{sessionId:s,sessionStartTimestamp:i}=this.sessionManager.checkAndGetSessionAndWindowId(!0),n=this.requestRouter.endpointFor("ui",`/project/${this.config.token}/replay/${s}`);if(e?.withTimestamp&&i){var r;let o=(r=e.timestampLookBack)!==null&&r!==void 0?r:10;if(!i)return n;n+=`?t=${Math.max(Math.floor((new Date().getTime()-i)/1e3)-o,0)}`}return n}alias(e,s){return e===this.get_property("$people_distinct_id")?(R.critical("Attempting to create alias for existing People user - aborting."),-2):this.yc("posthog.alias")?(S(s)&&(s=this.get_distinct_id()),e!==s?(this.bc(Qr,e),this.capture("$create_alias",{alias:e,distinct_id:s})):(R.warn("alias matches current distinct_id - skipping api call."),this.identify(e),-1)):void 0}set_config(e){let s=_({},this.config);if(G(e)){var i,n,r,o,a,l,c,u,h,d,g,p,m,v;ve(this.config,Nf(e));let I=this.Su();if(this.persistence){let $=this.config.persistence==="sessionStorage"||this.config.persistence==="memory";var b,y;if($&&this.sessionPersistence!==this.persistence&&((b=this.sessionPersistence)===null||b===void 0||b.remove(),(y=this.sessionPersistence)===null||y===void 0||y.destroy()),this.persistence.update_config(this.config,s,I),$)this.sessionPersistence=this.persistence;else if(this.sessionPersistence===this.persistence)this.sessionPersistence=new el(_(_({},this.config),{},{persistence:"sessionStorage"}),I,!1);else{var w;(w=this.sessionPersistence)===null||w===void 0||w.update_config(_(_({},this.config),{},{persistence:"sessionStorage"}),_(_({},s),{},{persistence:"sessionStorage"}),I)}}let k=this.Ou(this.config.debug);var A;Je(k)&&(this.config.debug=k),Je(this.config.debug)&&(this.config.debug?(it.DEBUG=!0,J.At()&&J.$t("ph_debug",!0),R.info("set_config",{config:e,oldConfig:s,newConfig:_({},this.config)})):(it.DEBUG=!1,J.At()&&J.Pt("ph_debug"))),(i=this.featureFlags)===null||i===void 0||(n=i.updateConfig)===null||n===void 0||n.call(i,this.config,this.il()),(r=this.exceptionObserver)===null||r===void 0||r.onConfigChange(),(o=this.exceptions)===null||o===void 0||o.onConfigChange(),(a=this.metrics)===null||a===void 0||a.onConfigChange(),(l=this.webMCP)===null||l===void 0||l.startIfEnabled(),(c=this.sessionRecording)===null||c===void 0||c.startIfEnabledOrStop(),(u=this.tracingHeaders)===null||u===void 0||u.startIfEnabledOrStop(),(h=this.autocapture)===null||h===void 0||h.startIfEnabled(),(d=this.heatmaps)===null||d===void 0||d.startIfEnabled(),("capture_pageview"in e||"disable_capture_url_hashes"in e)&&((A=this.historyAutocapture)===null||A===void 0||A.startIfEnabledOrStop()),(g=this.exceptionObserver)===null||g===void 0||g.startIfEnabledOrStop(),(p=this.deadClicksAutocapture)===null||p===void 0||p.startIfEnabledOrStop(),(m=this.surveys)===null||m===void 0||m.loadIfEnabled(),this.wu(),(v=this.externalIntegrations)===null||v===void 0||v.startIfEnabledOrStop(),!s.segment&&this.config.segment&&this.persistence&&vf(this,hn,!1)}}_overrideSDKInfo(e,s){it.LIB_NAME=e,it.LIB_VERSION=s}startSessionRecording(e){let s=e===!0,i={sampling:s||!!e?.sampling,linked_flag:s||!!e?.linked_flag,url_trigger:s||!!e?.url_trigger,event_trigger:s||!!e?.event_trigger};var n,r,o,a,l;Object.values(i).some(Boolean)&&((n=this.sessionManager)===null||n===void 0||n.checkAndGetSessionAndWindowId(),i.sampling&&((r=this.sessionRecording)===null||r===void 0||r.overrideSampling()),i.linked_flag&&((o=this.sessionRecording)===null||o===void 0||o.overrideLinkedFlag()),i.url_trigger&&((a=this.sessionRecording)===null||a===void 0||a.overrideTrigger("url")),i.event_trigger&&((l=this.sessionRecording)===null||l===void 0||l.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===void 0)&&e.started)}captureException(e,s){try{if(!this.exceptions)return;let i=this.exceptions.buildProperties(e,{handled:!0,syntheticException:new Error("PostHog syntheticException")});return this.exceptions.sendExceptionEvent(_(_({},i),s))}catch{return}}addExceptionStep(e,s){var i;(i=this.exceptions)===null||i===void 0||i.addExceptionStep(e,s)}captureLog(e){var s;(s=this.logs)===null||s===void 0||s.captureLog(e)}get logger(){var e,s;return(e=(s=this.logs)===null||s===void 0?void 0:s.logger)!==null&&e!==void 0?e:rs.xc}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||i===void 0?void 0:i.loadToolbar(e))!==null&&s!==void 0&&s}get_property(e){var s;return(s=this.persistence)===null||s===void 0?void 0:s.props[e]}getSessionProperty(e){var s;return(s=this.sessionPersistence)===null||s===void 0?void 0:s.props[e]}toString(){var e;let s=(e=this.config.name)!==null&&e!==void 0?e:tn;return s!==tn&&(s="posthog."+s),s}_isIdentified(){var e,s;return((e=this.persistence)===null||e===void 0?void 0:e.get_property("$user_state"))==="identified"||((s=this.sessionPersistence)===null||s===void 0?void 0:s.get_property("$user_state"))==="identified"}mc(){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===void 0||(e=e.props)===null||e===void 0)&&e.__alias)&&!(!((s=this.persistence)===null||s===void 0||(s=s.props)===null||s===void 0)&&s.$epp))}ec(){return this.config.capture_pageleave===!0||this.config.capture_pageleave==="if_capture_pageview"&&!!this.config.capture_pageview}createPersonProfile(){this.mc()||this.yc("posthog.createPersonProfile")&&this.setPersonProperties({},{})}setInternalOrTestUser(){this.yc("posthog.setInternalOrTestUser")&&this.setPersonProperties({$internal_or_test_user:!0})}yc(e){return this.config.person_profiles==="never"?(R.error(e+' was called, but process_person is set to "never". This call will be ignored.'),!1):(this.gu(),this.bc(lc,!0),!0)}Su(){if(this.config.cookieless_mode==="always")return!0;let e=this.consent.isOptedOut();return this.config.disable_persistence||e&&!(!this.config.opt_out_persistence_by_default&&this.config.cookieless_mode!=="on_reject")}wu(){var e,s;let i=this.Su();var n,r,o;return this.is_capturing()||(n=this.logs)===null||n===void 0||n.$c(),((e=this.persistence)===null||e===void 0?void 0:e.hi)!==i&&((r=this.persistence)===null||r===void 0||r.set_disabled(i)),((s=this.sessionPersistence)===null||s===void 0?void 0:s.hi)!==i&&((o=this.sessionPersistence)===null||o===void 0||o.set_disabled(i)),this.gc(),i}opt_in_capturing(e){var s;if(this.config.cookieless_mode!=="always"){if(this.pu()){var i,n,r,o,a,l;(i=this.sessionRecording)===null||i===void 0||i.dispose({discardBufferedEvents:!0}),this.wc(!0,!0),(n=this.sessionManager)===null||n===void 0||n.destroy(),(r=this.pageViewManager)===null||r===void 0||r.destroy(),this.sessionManager=new Rf(this),this.pageViewManager=new _f(this),this.persistence&&(this.sessionPropsManager=new Tf(this,this.sessionManager,this.persistence));let g=(o=(a=this.config.__extensionClasses)===null||a===void 0?void 0:a.sessionRecording)!==null&&o!==void 0?o:(l=rs.__defaultExtensionClasses)===null||l===void 0?void 0:l.sessionRecording;var c,u;g&&(this.sessionRecording=this.fu(this.sessionRecording,new g(this)),this.uu&&((c=this.sessionRecording)===null||c===void 0||(u=c.onRemoteConfig)===null||u===void 0||u.call(c,this.uu)))}var h,d;this.consent.optInOut(!0),this.wu(),this.Xu(),(s=this.sessionRecording)===null||s===void 0||s.startIfEnabledOrStop(),this.config.cookieless_mode=="on_reject"&&((h=this.surveys)===null||h===void 0||h.loadIfEnabled()),(S(e?.captureEventName)||e?.captureEventName)&&this.capture((d=e?.captureEventName)!==null&&d!==void 0?d:"$opt_in",e?.captureProperties,{send_instantly:!0}),this.config.capture_pageview&&this.Yu()}else R.warn(Of)}opt_out_capturing(){this.config.cookieless_mode!=="always"?(this.consent.optInOut(!1),this.wu(),this.config.cookieless_mode==="on_reject"&&this.ku()):R.warn(Of)}ku(){var e,s;let i=this.sessionRecording;i?.dispose({discardBufferedEvents:!0}),this.get_distinct_id()!=="$posthog_cookieless"&&this.wc(!0,!0),this.register({distinct_id:za,$device_id:null}),this.du(i),this.sessionRecording=void 0,(e=this.sessionManager)===null||e===void 0||e.destroy(),(s=this.pageViewManager)===null||s===void 0||s.destroy(),this.sessionManager=void 0,this.sessionPropsManager=void 0,this.config.capture_pageview&&this.Yu(),this.Xu()}has_opted_in_capturing(){return this.consent.isOptedIn()}has_opted_out_capturing(){return this.consent.isOptedOut()}get_explicit_consent_status(){let e=this.consent.consent;return e===1?"granted":e===0?"denied":"pending"}is_capturing(){return!this._u&&(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.wu()}_is_bot(){return Le?yv(Le,this.config.custom_blocked_useragents):void 0}Yu(){T&&(T.visibilityState==="visible"?this.Pu||(this.Pu=!0,this.capture(hc,{title:T.title},{send_instantly:!0}),this.Ru&&(T.removeEventListener(_n,this.Ru),this.Ru=null)):this.Ru||(this.Ru=this.Yu.bind(this),se(T,_n,this.Ru)))}debug(e){e===!1?(E?.console.log("You've disabled debug mode."),this.set_config({debug:!1})):(E?.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}))}il(){let e=this.Du||{};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?(R.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,n,r,o){let a=i in s&&!B(s[i]),l=n in s&&!B(s[n]);return a?s[i]:!!l&&(o&&o.warn(`Config field '${n}' is deprecated. Please use '${i}' instead. The old field will be removed in a future major version.`),s[n])})(e,"advanced_disable_flags","advanced_disable_decide",0,R)}Os(e){var s;if(B(this.config.before_send))return e;let i=Object.keys((s=e.properties)!==null&&s!==void 0?s:{}).filter(Qw),n=N(this.config.before_send)?this.config.before_send:[this.config.before_send],r=e;for(let o of n)try{if(r=o(r),B(r)){let a=`Event '${e.event}' was rejected in beforeSend function`;return Yw(e.event)?R.warn(`${a}. This can cause unexpected behavior.`):R.info(a),null}r.properties&&!nt(r.properties)||R.warn(`Event '${e.event}' has no properties after beforeSend function, this is likely an error.`)}catch(a){return R.error(`Error in beforeSend function for event '${e.event}':`,a),null}for(let o of i)if(r.properties&&B(r.properties[o]))return R.warn(`Event '${e.event}' had its '${o}' property removed in a beforeSend function. This property is required for ingestion, so the event will be dropped.`),null;return r}getPageViewId(){var e;return(e=this.pageViewManager.Wo)===null||e===void 0?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)})}Ou(e){let s=Je(e)&&!e,i=J.At()&&J.Ot("ph_debug")==="true";return!s&&(!!i||e)}};fn.__defaultExtensionClasses={},fn.xc=(()=>{let t=()=>{};return{trace:t,debug:t,info:t,warn:t,error:t,fatal:t}})(),(function(t,e){for(let s=0;e.length>s;s++)t.prototype[e[s]]=Hk(t.prototype[e[s]])})(fn,["identify"]);Ov=class{constructor(t){this.disabled=t===!1;let e=G(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;let 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",hl=ye("[AutoCapture]");sT=class{do(){this.vo=void 0,clearTimeout(this.fo),this.fo=void 0}po(t){var e;if(!Ms(t))return!0;let s=(e=this.mo().css_selector_ignorelist)!==null&&e!==void 0?e:Ja,i=new Set,n=t;for(;n;){if(i.size>=1e3||i.has(n))return!0;i.add(n);let r=n,o=gi(r);if(M(o,"ph-no-capture")||M(o,"ph-sensitive")||pi(r)||s.some(l=>jl(r,l)))return!0;let a=n.parentNode;n=gc(a)?a.host:a&&Et(a)?a:null}return!1}yo(t){if(!this.isEnabled||t.type==="pointercancel")return void this.do();if(t.type==="pointerdown"){this.do();let i=cn(t);var e;return void(t.isPrimary&&t.button===0&&!t.ctrlKey&&i&&Et(i)&&(this.vo={target:i,excluded:this.po(i),id:t.pointerId,x:t.clientX,y:t.clientY,released:!1,distinctId:(e=this.bo)===null||e===void 0?void 0:e.distinctId}))}let s=this.vo;s&&(t.pointerId!==s.id||Math.abs(t.clientX-s.x)>5||Math.abs(t.clientY-s.y)>5?this.do():t.type==="pointerup"&&(s.released=!0,this.fo=setTimeout(()=>this.do(),0)))}_o(t){var e;let s=this.vo;this.do();let i=cn(t);if(s?.released&&s.target.isConnected&&s.distinctId===((e=this.bo)===null||e===void 0?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&&(Ue(i,"html")||Ue(i,"body"))){var n;if(s.excluded)return null;let r=(n=this.mo().css_selector_ignorelist)!==null&&n!==void 0?n:Ja;return[i,T?.documentElement,T?.body].some(o=>{if(!o)return!1;let a=gi(o);return M(a,"ph-no-capture")||M(a,"ph-sensitive")||!Ms(o)||pi(o)||r.some(l=>jl(o,l))})?null:s.target}}constructor(t){this.wo=t,this.name=Av,this.ko=!1,this.So=null,this.xo=!1,this.$o=new Map,this.Co=!1,this.Mr={enabled:!1,rageclick:!1,maskAllElementAttributes:!1,maskAllText:!1,disableCaptureUrlHashes:!1,remoteRequestsDisabled:!1},this.To=!1,this.wo.refresh(this.Mr),this.rageclicks=new Ov(this.Mr.rageclick),this.Io=null}setup(t){this.Mo(),this.bo=t;let e=t.onRemoteConfig(this.onRemoteConfig.bind(this));this.To?e.dispose():(this.Eo=e,this.startIfEnabled())}dispose(){var t;this.To||(this.To=!0,this.bo=void 0,(t=this.Eo)===null||t===void 0||t.dispose(),this.Eo=void 0,this.$o.clear(),this.Io=null,this.Po())}mo(){return this.wo.refresh(this.Mr),this.Mr}Mo(){var t,e;return this.mo(),this.Mr.url_allowlist=(t=this.Mr.url_allowlist)===null||t===void 0?void 0:t.map(s=>new RegExp(s)),this.Mr.url_ignorelist=(e=this.Mr.url_ignorelist)===null||e===void 0?void 0:e.map(s=>new RegExp(s)),this.Mr}Ro(){if(!this.isBrowserSupported())return void hl.info("Disabling Automatic Event Collection because this browser is not supported");if(!E||!T)return;let t=this.Ao=e=>{e=e||E?.event;try{if(e.type==="blur")return void this.do();if(e.type.indexOf("pointer")===0)return void this.yo(e);let s=e.type==="click"?this._o(e):void 0;if(we(s))return;this.Fo(e,"$autocapture",s)}catch(s){hl.error("Failed to capture event",s)}};if(se(E,"blur",t),se(T,"submit",t,{capture:!0}),se(T,"change",t,{capture:!0}),se(T,"click",t,{capture:!0}),re(["pointerdown","pointermove","pointerup","pointercancel"],e=>{se(T,e,t,{capture:!0})}),this.mo().capture_copied_text){let e=this.Oo=s=>{s=s||E?.event;try{this.Fo(s,dl)}catch(i){hl.error("Failed to capture clipboard event",i)}};se(T,"copy",e,{capture:!0}),se(T,"cut",e,{capture:!0}),se(T,"paste",e,{capture:!0})}}Po(){this.do(),this.Ao&&(E?.removeEventListener("blur",this.Ao),re(["pointerdown","pointermove","pointerup","pointercancel"],t=>{T?.removeEventListener(t,this.Ao,!0)}),T?.removeEventListener("submit",this.Ao,!0),T?.removeEventListener("change",this.Ao,!0),T?.removeEventListener("click",this.Ao,!0),this.Ao=void 0),this.Oo&&(T?.removeEventListener("copy",this.Oo,!0),T?.removeEventListener("cut",this.Oo,!0),T?.removeEventListener("paste",this.Oo,!0),this.Oo=void 0),this.ko=!1}startIfEnabled(){this.isEnabled||this.do(),!this.To&&this.bo&&this.isEnabled&&!this.ko&&(this.Ro(),this.ko=!0)}onRemoteConfig(t){if(this.To)return;if(this.xo=!0,!t.ok)return void this.startIfEnabled();let e=t.config;e.elementsChainAsString&&(this.Co=e.elementsChainAsString);let s=e.autocapture_opt_out;var i;Je(s)&&((i=this.bo)===null||i===void 0||i.kv.set("$autocapture_disabled_server_side",s),this.So=s),this.startIfEnabled()}setElementSelectors(t,e=this){if(this.To)return;t.size?this.$o.set(e,new Set(t)):this.$o.delete(e);let s=new Set;this.$o.forEach(i=>{i.forEach(n=>s.add(n))}),this.Io=s}getElementSelectors(t,e){var s;let i=[];return(s=this.Io)===null||s===void 0||s.forEach(n=>{let r=T?.querySelectorAll(n);r?.forEach(o=>{t!==o&&e!==o||M(i,n)||i.push(n)})}),i}get isEnabled(){var t,e;if(this.To)return!1;let s=(t=this.bo)===null||t===void 0?void 0:t.kv.get(cp),i=this.So,n=this.mo();if(!n.remoteRequestsDisabled&&!this.xo)return!1;let r=n.remoteRequestsDisabled&&!this.xo;if(we(i)&&!Je(s)&&!r)return!1;let o=(e=this.So)!==null&&e!==void 0?e:!!s;return!!n.enabled&&!o}Fo(t,e="$autocapture",s){if(!this.isEnabled)return void this.do();let i=s||cn(t);Mp(i)&&(i=i.parentNode||null);let n=this.Mo();var r;e==="$autocapture"&&t.type==="click"&&t instanceof MouseEvent&&n.rageclick&&(!((r=this.rageclicks)===null||r===void 0)&&r.isRageClick(t.clientX,t.clientY,t.timeStamp||new Date().getTime()))&&Bp(i,n.rageclick)&&this.Fo(t,"$rageclick",s);let o=e===dl,a=o?_(_({},n),{},{dom_event_allowlist:void 0}):n;if(i&&(function(h,d,g,p,m,v){var b;if(!E||mc(h)||g?.url_allowlist&&!rf(g.url_allowlist,v)||g?.url_ignorelist&&rf(g.url_ignorelist,v))return!1;if(g?.dom_event_allowlist){let I=g.dom_event_allowlist;if(I&&!I.some(k=>d.type===k))return!1}let{parentIsUsefulElement:y,targetElementList:w}=Vp(h,p);if(!(function(I,k){let $=k?.element_allowlist;if(S($))return!0;for(let O of I)if($.some(x=>O.tagName.toLowerCase()===x))return!0;return!1})(w,g)||!Gl(w,g?.css_selector_allowlist)||Gl(w,(b=g?.css_selector_ignorelist)!==null&&b!==void 0?b:Ja))return!1;try{let I=E.getComputedStyle(h);if(I&&I.getPropertyValue("cursor")==="pointer"&&d.type==="click")return!0}catch{}let A=h.tagName.toLowerCase();switch(A){case"html":return!1;case"form":return(m||["submit"]).indexOf(d.type)>=0;case"input":case"select":case"textarea":return(m||["change","click"]).indexOf(d.type)>=0;default:return y?(m||["click"]).indexOf(d.type)>=0:(m||["click"]).indexOf(d.type)>=0&&(vc.indexOf(A)>-1||h.getAttribute("contenteditable")==="true")}})(i,t,a,o,o?["copy","cut","paste"]:void 0,{config:{get_current_url:n.getCurrentUrl}})){var l;let{props:h,explicitNoCapture:d,target:g}=tT(i,{e:t,maskAllElementAttributes:n.maskAllElementAttributes,maskAllText:n.maskAllText,elementAttributeIgnoreList:n.element_attribute_ignorelist,elementsChainAsString:this.Co,disableCaptureUrlHashes:n.disableCaptureUrlHashes});if(d)return!1;let p=this.getElementSelectors(i,g);if(p&&p.length>0&&(h.$element_selectors=p),e===dl){let m=t.type||"clipboard";if(m!=="paste"){var c,u;let v=E==null||(c=E.getSelection())===null||c===void 0?void 0:c.toString(),b=Fp(v);if(!b)return!1;h.$selected_content=b,h.$clipboard_text_length=(u=v?.length)!==null&&u!==void 0?u:0}h.$copy_type=m}return(l=this.bo)===null||l===void 0||l.capture(e,h),!0}}isBrowserSupported(){return Ce(T?.querySelectorAll)}},iT=class{constructor(t){this._instance=t}refresh(t){let e=this._instance.config,s=G(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.il(),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}},Xi=ye("[ExceptionAutocapture]"),Mf=()=>{},Ff=t=>{var e;if(Ce(t))return(e=t.__posthog_layer__)!==null&&e!==void 0?e:t.__rrweb_layer__};nT=ye("[TracingHeaders]"),Rs=ye("[Web Vitals]"),Lf=9e5,Uf=["CLS","FCP","INP","LCP"],rT=["INP","LCP"],oT=["interactionTarget","interactionType","inputDelay","processingDuration","presentationDelay","loadState","target","url","timeToFirstByte","resourceLoadDelay","resourceLoadDuration","elementRenderDelay","largestShiftTarget","largestShiftTime","largestShiftValue","firstByteToFCP"],gl="disabled",Bf="lazy_loading",jt=ye("[SessionRecording]"),aT=[cc,uc,Sp,kp,Ap,Tp,Ip,Rp,Cp],lT=ye("[Heatmaps]");Pr=ye("[Product Tours]"),vl=t=>{var e;return!t.config.disable_product_tours&&!!(!((e=t.persistence)===null||e===void 0)&&e.get_property(ac))},cT=["$set_once","$set"],At=ye("[SiteApps]"),Vf="Error while initializing PostHog app with config id ",Ec=(t,e)=>t?.then?t.then(e):e(t),ii="SDK is not enabled or survey functionality is not yet loaded",jf="Disabled. Not loading surveys.",uT=class{constructor(t,e){this.wo=t,this.Cc=e,this.name=Rv,this._surveyEventReceiver=null,this._surveyManager=null,this.Tc=!1,this.Ic=!1,this.Mc=[],this.Ec=[],this.Pc=null,this.Rc=null,this.To=!1,this.Ac=new Set,this.onRemoteConfig=s=>{if(this.To||this.Mr.disableSurveys)return;if(!s.ok)return this.Ic=!0,this.Fc({isLoaded:!1,error:"Remote config unavailable. Not loading surveys."}),ne.warn("Remote config unavailable. Not loading surveys.");let i=s.config.surveys;if(B(i))return ne.warn("Flags not loaded yet. Not loading surveys.");this.Oc=Je(i)?i:i.length>0,ne.info(`flags response received, isSurveysEnabled: ${this.Oc}`),this.loadIfEnabled()},this.Fc=s=>{this.Ec.slice().forEach(i=>this.Dc(i,s))}}setup(t){if(!this.To)return this.Lc=t,Ec(t.kv.initialize(),()=>{if(this.Lc!==t||this.To)return;this.Lc=void 0,this.bo=t;let e=t.onRemoteConfig(this.onRemoteConfig);this.To?e.dispose():(this.Eo=e,this.loadIfEnabled())})}dispose(){var t,e,s,i,n;this.To||(this.To=!0,this.Lc=void 0,this.bo=void 0,(t=this.Eo)===null||t===void 0||t.dispose(),this.Eo=void 0,(e=this._surveyEventReceiver)===null||e===void 0||e.dispose(),this._surveyEventReceiver=null,(s=this._surveyManager)===null||s===void 0||(i=s.dispose)===null||i===void 0||i.call(s),this._surveyManager=null,this.Mc=[],this.Ec.forEach(r=>{r.active=!1}),this.Ec=[],(n=this.Nc)===null||n===void 0||n.call(this),this.Nc=void 0,this.Pc=null,this.Ac.forEach(r=>clearTimeout(r)),this.Ac.clear())}get Mr(){return this.wo.get()}initialize(){this.loadIfEnabled()}reset(){var t,e;(t=this._surveyManager)===null||t===void 0||(e=t.clearInMemoryInProgressSurveyState)===null||e===void 0||e.call(t);try{var s;(s=this._surveyEventReceiver)===null||s===void 0||s.reset(),localStorage.removeItem("lastSeenSurveyDate");let i=[];for(let n=0;n<localStorage.length;n++){let r=localStorage.key(n);(r?.startsWith("seenSurvey_")||r?.startsWith("inProgressSurvey_"))&&i.push(r)}i.forEach(n=>localStorage.removeItem(n))}catch{}this.Fc()}loadIfEnabled(){if(this.To||!this.bo)return;let t=this.Mr;if(this._surveyManager)return;if(this.Tc)return void ne.info("Already initializing surveys, skipping...");if(t.disableSurveys)return void ne.info(jf);if(t.cookielessMode&&this.wo.isOptedOut())return void ne.info("Not loading surveys in cookieless mode without consent.");let e=this.wo.getExtensions();if(!e)return void this.qc("PostHog Extensions not found.");if(S(this.Oc)&&!t.advancedEnableSurveys)return;let s=this.Oc||t.advancedEnableSurveys;this.Tc=!0,this.Ic=!1;try{let i=e.generateSurveys;if(i)return this.jc(i,s),void(this.Tc=!1);let n=e.loadExternalDependency;if(!n)return this.qc(dc),void(this.Tc=!1);n(r=>{try{if(this.To)return;let o=this.wo.getExtensions();r||!o?.generateSurveys?this.qc("Could not load surveys script",r):this.jc(o.generateSurveys,s)}finally{this.Tc=!1}})}catch(i){throw this.Tc=!1,this.qc("Error initializing surveys",i),i}}jc(t,e){var s,i;if(this.To)return;this._surveyManager=t(e),this._surveyEventReceiver=this.wo.createEventReceiver(this.Fc);let n=(s=(i=this.bo)!==null&&i!==void 0?i:this.Cc)===null||s===void 0?void 0:s.kv.get(en);n&&this.Bc(n),ne.info("Surveys loaded successfully"),this.zc(),this.Fc(),this.Hc({isLoaded:!0})}qc(t,e){this.Ic=!0,ne.error(t,e),this.Fc({isLoaded:!1,error:t}),this.Hc({isLoaded:!1,error:t})}onSurveysLoaded(t){return this.Mc.push(t),this._surveyManager&&this.Hc({isLoaded:!0}),()=>{this.Mc=this.Mc.filter(e=>e!==t)}}getSurveys(t,e=!1){var s;let i=(s=this.bo)!==null&&s!==void 0?s:this.Cc;if(!i||this.To)return;if(this.Mr.disableSurveys)return ne.info(jf),t([]);let n=i.kv.get(en);if(n&&!e)return t(n,{isLoaded:!0}),void(this.Uc()&&this.getSurveys(()=>{},!0));if(this.Pc)return void this.Pc.then(({surveys:a,context:l})=>{this.To||t(a,l)}).catch(a=>ne.error("Error in survey callback",a));let r=this.Wc("/api/surveys/",{method:"GET",query:{token:i.projectToken},sentAt:"query",timeoutMs:this.Mr.requestTimeoutMs}).then(a=>{try{return this.Vc(i,a)}catch(l){return ne.error("Error processing surveys response",l),this.Vc(i,{statusCode:0,error:l})}},a=>this.Vc(i,{statusCode:0,error:a}));this.Pc=r;let o=()=>{this.Pc===r&&(this.Pc=null)};r.then(a=>{o(),this.To||(this.Fc(a.context),t(a.surveys,a.context))},o).catch(a=>ne.error("Error in survey callback",a))}Wc(t,e){let s=this.bo;return s?s.sendRequest(t,e):new Promise(i=>i({statusCode:0,error:new Error(ii)}))}Vc(t,e){if(this.To)return{surveys:[],context:{isLoaded:!1,error:ii}};let s=e.statusCode;if(s!==200||!e.json){let n=`Surveys API could not be loaded, status: ${s}`;return s!==0?ne.error(n):e.error||ne.warn(n),this.Rc=Date.now(),{surveys:[],context:{isLoaded:!1,error:n}}}this.Rc=null;let i=e.json.surveys||[];return t.kv.set({[en]:i,[Jr]:Date.now()}),this.Bc(i),{surveys:i,context:{isLoaded:!0}}}Bc(t){var e;let s=t.filter(i=>(function(n){return!(!n.start_date||n.end_date)})(i)&&(Ev(i)||(function(n){var r;return!!(!((r=n.conditions)===null||r===void 0||(r=r.actions)===null||r===void 0||(r=r.values)===null||r===void 0)&&r.length)})(i)));(e=this._surveyEventReceiver)===null||e===void 0||e.replace(s)}Uc(){return this.Gc()&&!this.Pc&&!this.Qc()}Gc(){var t,e;let s=(t=(e=this.bo)!==null&&e!==void 0?e:this.Cc)===null||t===void 0?void 0:t.kv.get(Jr);return Te(s)&&Date.now()-s>3e5}Qc(){return Te(this.Rc)&&3e5>Date.now()-this.Rc}markSurveyAsSeen(t,e){var s;let i={id:t,current_iteration:(s=e?.iteration)!==null&&s!==void 0?s:null};kv(i);try{localStorage.setItem("lastSeenSurveyDate",new Date().toISOString())}catch{}this.Fc()}Hc(t){for(let e of this.Mc)try{if(!t.isLoaded)return e([],t);this.getSurveys(e)}catch(s){ne.error("Error in survey callback",s)}}getActiveMatchingSurveys(t,e=!1){if(!B(this._surveyManager))return this._surveyManager.getActiveMatchingSurveys(t,e);ne.warn("init was not called")}onActiveMatchingSurveysChanged(t){var e,s;if(this.To)return()=>{};let i={callback:t,active:!0,revision:0};this.Ec.push(i),this.zc();let n=(e=(s=this.bo)!==null&&s!==void 0?s:this.Cc)===null||e===void 0?void 0:e.kv.get(en);return this.Mr.disableSurveys||!this._surveyManager&&this.Ic&&!this.Tc||!n&&!B(this.Rc)&&!this.Pc?this.Dc(i,{isLoaded:!1}):this._surveyManager&&this.Dc(i),()=>{var r;i.active=!1,this.Ec=this.Ec.filter(o=>o!==i),this.Ec.length===0&&((r=this.Nc)===null||r===void 0||r.call(this),this.Nc=void 0)}}zc(){var t,e,s;this._surveyManager&&this.Ec.length>0&&((t=this.Nc)!==null&&t!==void 0||(this.Nc=(e=(s=this.wo).onMatchingConditionsChanged)===null||e===void 0?void 0:e.call(s,this.Fc)))}Dc(t,e){if(this.To||!t.active)return;let s=++t.revision,i=n=>{if(!this.To&&t.active&&s===t.revision)try{let r=e??{isLoaded:!0},o=JSON.stringify([n,r]);if(o===t.lastResult)return;t.lastResult=o,t.callback(n,r)}catch(r){ne.error("Error in active matching surveys callback",r)}};try{e&&!e.isLoaded?i([]):this.getActiveMatchingSurveys(i)}catch(n){ne.error("Error in active matching surveys callback",n)}}Zc(t){let e=null;return this.getSurveys(s=>{var i;e=(i=s.find(n=>n.id===t))!==null&&i!==void 0?i:null}),e}Jc(t){if(B(this._surveyManager))return{eligible:!1,reason:ii};let e=typeof t=="string"?this.Zc(t):t;return e?this._surveyManager.checkSurveyEligibility(e):{eligible:!1,reason:"Survey not found"}}Kc(t){if(!this.wo.isCapturing())return{eligible:!1,reason:"PostHog is not capturing, so a survey response cannot be recorded"};if(B(this._surveyManager))return{eligible:!1,reason:ii};let e=typeof t=="string"?this.Zc(t):t;return e?this._surveyManager.checkSurveyRenderability(e):{eligible:!1,reason:"Survey not found"}}canRenderSurvey(t){if(B(this._surveyManager))return ne.warn("init was not called"),{visible:!1,disabledReason:ii};let e=this.Kc(t);return{visible:e.eligible,disabledReason:e.reason}}canRenderSurveyAsync(t,e){return B(this._surveyManager)?(ne.warn("init was not called"),Promise.resolve({visible:!1,disabledReason:ii})):new Promise(s=>{this.getSurveys(i=>{var n;let r=(n=i.find(o=>o.id===t))!==null&&n!==void 0?n:null;if(r){let o=this.Kc(r);s({visible:o.eligible,disabledReason:o.reason})}else s({visible:!1,disabledReason:"Survey not found"})},e)})}renderSurvey(t,e,s){var i;if(!this.wo.isCapturing())return;if(B(this._surveyManager))return void ne.warn("init was not called");let n=typeof t=="string"?this.Zc(t):t;if(!n?.id)return void ne.warn("Survey not found");if(!BA.includes(n.type))return void ne.warn(`Surveys of type ${n.type} cannot be rendered in the app`);let r=T?.querySelector(e);if(r){if(!((i=n.appearance)===null||i===void 0)&&i.surveyPopupDelaySeconds){ne.info(`Rendering survey ${n.id} with delay of ${n.appearance.surveyPopupDelaySeconds} seconds`);let o=setTimeout(()=>{var a,l;this.Ac.delete(o),!this.To&&this.wo.isCapturing()&&(ne.info(`Rendering survey ${n.id} with delay of ${(a=n.appearance)===null||a===void 0?void 0:a.surveyPopupDelaySeconds} seconds`),(l=this._surveyManager)===null||l===void 0||l.renderSurvey(n,r,s),ne.info(`Survey ${n.id} rendered`))},1e3*n.appearance.surveyPopupDelaySeconds);return void this.Ac.add(o)}this._surveyManager.renderSurvey(n,r,s)}else ne.warn("Survey element not found")}displaySurvey(t,e){var s;if(!this.wo.isCapturing())return;if(B(this._surveyManager))return void ne.warn("init was not called");let i=this.Zc(t);if(!i)return void ne.warn("Survey not found");let n=i;if(!((s=i.appearance)===null||s===void 0)&&s.surveyPopupDelaySeconds&&e.ignoreDelay&&(n=_(_({},i),{},{appearance:_(_({},i.appearance),{},{surveyPopupDelaySeconds:0})})),e.displayType!==Hl.Popover&&e.initialResponses&&ne.warn("initialResponses is only supported for popover surveys. prefill will not be applied."),e.ignoreConditions===!1){let r=this.Jc(i);if(!r.eligible)return void ne.warn("Survey is not eligible to be displayed: ",r.reason)}e.displayType!==Hl.Inline?this._surveyManager.handlePopoverSurvey(n,e):this.renderSurvey(n,e.selector,e.properties)}cancelPendingSurvey(t){B(this._surveyManager)?ne.warn("init was not called"):this._surveyManager.cancelSurvey(t)}handlePageUnload(){var t,e;(t=this._surveyManager)===null||t===void 0||(e=t.handlePageUnload)===null||e===void 0||e.call(t)}};dT=class{constructor(t){this._instance=t,this.Xc=new Set,this.Yc=new Set,this.th=new no,this.eh=(e,s)=>this.ih(e,s)&&this.nh(e,s)&&this.sh(e,s)&&this.rh(e,s),this.ih=(e,s)=>!s?.event||e?.event===s?.event}init(){var t,e;S((t=this._instance)===null||t===void 0?void 0:t._addCaptureHook)||(this.oh=(e=this._instance)===null||e===void 0?void 0:e._addCaptureHook((s,i)=>{this.on(s,i)}))}dispose(){var t,e;(t=this.oh)===null||t===void 0||t.call(this),this.oh=void 0,(e=this._instance)===null||e===void 0||(e=e.autocapture)===null||e===void 0||e.setElementSelectors(new Set,this),this.th=new no}register(t){var e,s;if(!S((e=this._instance)===null||e===void 0?void 0:e._addCaptureHook)&&(t.forEach(i=>{var n;this.Xc.add(i),(n=i.steps)===null||n===void 0||n.forEach(r=>{this.Yc.add(r?.event||"")})}),(s=this._instance)===null||s===void 0?void 0:s.autocapture)){let i=new Set;this.Xc.forEach(n=>{var r;(r=n.steps)===null||r===void 0||r.forEach(o=>{o?.selector&&i.add(o.selector)})}),this._instance.autocapture.setElementSelectors(i,this)}}replace(t){this.Xc.clear(),this.Yc.clear(),this.register(t)}on(t,e){e!=null&&t.length!=0&&(this.Yc.has(t)||this.Yc.has(e.event))&&this.Xc.forEach(s=>{this.ah(e,s)&&this.th.emit("actionCaptured",s.name)})}uh(t){this.onAction("actionCaptured",e=>t(e))}ah(t,e){if(e?.steps==null)return!1;for(let s of e.steps)if(this.eh(t,s))return!0;return!1}onAction(t,e){return this.th.on(t,e)}nh(t,e){if(e?.url){var s;let i=t==null||(s=t.properties)===null||s===void 0?void 0:s.$current_url;if(!i||typeof i!="string"||!ni(i,e.url,e.url_matching||"contains"))return!1}return!0}sh(t,e){return!!this.hh(t,e)&&!!this.dh(t,e)&&!!this.fh(t,e)}hh(t,e){var s;if(!e?.href)return!0;let i=this.ph(t);if(i.length>0)return i.some(r=>ni(r.href,e.href,e.href_matching||"exact"));let n=(t==null||(s=t.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!n&&ni((function(r){let o=r.match(/(?::|")href="(.*?)"/);return o?o[1]:""})(n),e.href,e.href_matching||"exact")}dh(t,e){var s;if(!e?.text)return!0;let i=this.ph(t);if(i.length>0)return i.some(l=>ni(l.text,e.text,e.text_matching||"exact")||ni(l.$el_text,e.text,e.text_matching||"exact"));let n=(t==null||(s=t.properties)===null||s===void 0?void 0:s.$elements_chain)||"";return!!n&&(r=(function(l){let c=[],u=/(?::|")text="(.*?)"/g,h;for(;!B(h=u.exec(l));)c.includes(h[1])||c.push(h[1]);return c})(n),o=e.text,a=e.text_matching||"exact",r.some(l=>ni(l,o,a)));var r,o,a}fh(t,e){var s,i;if(!e?.selector)return!0;let n=t==null||(s=t.properties)===null||s===void 0?void 0:s.$element_selectors;if(n?.includes(e.selector))return!0;let r=(t==null||(i=t.properties)===null||i===void 0?void 0:i.$elements_chain)||"";if(e.selector_regex&&r)try{return new RegExp(e.selector_regex).test(r)}catch{return!1}return!1}ph(t){var e;return(t==null||(e=t.properties)===null||e===void 0?void 0:e.$elements)==null?[]:t?.properties.$elements}rh(t,e){return!e?.properties||e.properties.length===0||Sv(e.properties.reduce((s,i)=>{let n=N(i.value)?i.value.map(String):i.value!=null?[String(i.value)]:[];return s[i.key]={values:n,operator:i.operator||"exact"},s},{}),t?.properties)}},hT=class{constructor(t,e){var s,i;this.gh=[],this._instance=t,this.mh=e,this.yh=new Map,this.bh=new Map,this._h=new Map,this.wh=(s=this._instance)===null||s===void 0||(i=s.onSessionId)===null||i===void 0?void 0:i.call(s,n=>this.kh(n))}Sh(t){return!1}xh(){return null}$h(t){}Ch(){}Th(t,e){return!!t&&Sv(t.propertyFilters,e?.properties)}Ih(t,e){let s=new Map;return t.forEach(i=>{var n;(n=i.conditions)===null||n===void 0||(n=n[e])===null||n===void 0||(n=n.values)===null||n===void 0||n.forEach(r=>{if(r?.name){let o=s.get(r.name)||[];o.push(i.id),s.set(r.name,o)}})}),s}Mh(t,e,s){let i=(s===Yi.Activation?this.yh:this.bh).get(t),n=[];return this.Eh(r=>{n=r.filter(o=>i?.includes(o.id))}),n.filter(r=>{var o;let a=(o=r.conditions)===null||o===void 0||(o=o[s])===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.find(l=>l.name===t);return this.Th(a,e)})}register(t){this.Ph(t,!1)}replace(t){this.Ph(t,!0)}Ph(t,e){var s;S((s=this._instance)===null||s===void 0?void 0:s._addCaptureHook)||(this.Rh(t,e),this.Ah(t,e))}Ah(t,e){let s=t.filter(r=>{var o;return(o=r.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||(o=o.values)===null||o===void 0?void 0:o.length});var i;if(e&&this._h.clear(),s.length===0)return void(e&&((i=this.Fh)===null||i===void 0||i.replace([])));this.Fh||(this.Fh=new dT(this._instance),this.Fh.init(),this.Fh.uh(r=>this.onAction(r)));let n=[];s.forEach(r=>{var o;(o=r.conditions)===null||o===void 0||(o=o.actions)===null||o===void 0||o.values.forEach(a=>{if(n.push(a),a.name){var l;let c=(l=this._h.get(a.name))!==null&&l!==void 0?l:[];c.includes(r.id)||c.push(r.id),this._h.set(a.name,c)}})}),e?this.Fh.replace(n):this.Fh.register(n)}Oh(t,e){e.forEach((s,i)=>{var n;let r=(n=t.get(i))!==null&&n!==void 0?n:[];s.forEach(o=>{r.includes(o)||r.push(o)}),t.set(i,r)})}Rh(t,e){var s,i;let n=t.filter(l=>{var c,u;return((c=l.conditions)===null||c===void 0?void 0:c.events)&&((u=l.conditions)===null||u===void 0||(u=u.events)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),r=t.filter(l=>{var c,u;return((c=l.conditions)===null||c===void 0?void 0:c.cancelEvents)&&((u=l.conditions)===null||u===void 0||(u=u.cancelEvents)===null||u===void 0||(u=u.values)===null||u===void 0?void 0:u.length)>0}),o=this.Ih(t,Yi.Activation),a=this.Ih(t,Yi.Cancellation);e?(this.yh=o,this.bh=a):(this.Oh(this.yh,o),this.Oh(this.bh,a)),(n.length!==0||r.length!==0||t.some(l=>{var c;return(c=l.conditions)===null||c===void 0||(c=c.actions)===null||c===void 0||(c=c.values)===null||c===void 0?void 0:c.length}))&&((s=this.oh)!==null&&s!==void 0||(this.oh=(i=this._instance)===null||i===void 0?void 0:i._addCaptureHook((l,c)=>{this.onEvent(l,c)})))}onEvent(t,e){var s,i;let n=this.Dh(),r=(e==null||(s=e.properties)===null||s===void 0?void 0:s.$survey_id)||(e==null||(i=e.properties)===null||i===void 0?void 0:i.$product_tour_id);if(r&&this.getActivatedIds().includes(r)){let a=this.Lh(t,r,e);if(a==="consume")return n.info("event consumed activated item, removing it",{event:t,itemId:r}),void this.Nh([r]);if(a==="persist")return n.info("shown item promoted to persisted activation",{event:t,itemId:r}),this.qh(r),void this.jh([r])}if(this.bh.has(t)){let a=this.Mh(t,e,Yi.Cancellation);a.length>0&&(n.info("cancel event matched, cancelling items",{event:t,itemsToCancel:a.map(l=>l.id)}),this.Nh(a.map(l=>l.id)),a.forEach(l=>this.Bh(l.id)))}if(!this.yh.has(t))return;n.info("event name matched",{event:t,eventPayload:e,items:this.yh.get(t)});let o=this.Mh(t,e,Yi.Activation);this.zh(o.map(a=>a.id))}onAction(t){this._h.has(t)&&this.zh(this._h.get(t)||[])}zh(t){var e,s;if(t.length===0)return;let i=!!(!((e=this._instance)===null||e===void 0||(s=e.get_session_id)===null||s===void 0)&&s.call(e)),n=[];for(let r of t)i&&this.Sh(r)?this.qh(r)&&this.Hh(r):n.push(r);n.length>0&&(this.gh=[...new Set([...this.gh,...n])]),this.Dh().info("updating activated items",{activatedItems:this.getActivatedIds()}),this.Uh()}qh(t){this.gh=this.gh.filter(s=>s!==t);let e=this.Wh();return!e.includes(t)&&(this.Vh([...e,t]),this.Gh(),!0)}Nh(t){let e=new Set(t);this.gh=this.gh.filter(n=>!e.has(n));let s=this.Qh(),i=s.filter(n=>!e.has(n));i.length!==s.length&&(this.Vh(i),i.length===0&&this.Zh()),this.jh(t),this.Uh()}Uh(){try{var t;(t=this.mh)===null||t===void 0||t.call(this)}catch(e){this.Dh().error("Error while handling activated items change",e)}}Jh(){var t;let e=this.xh();if(!e)return{};let s=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[e];return s&&typeof s=="object"?s:{}}Hh(t){if(!this.xh())return;let e=this.Jh();this.$h(_(_({},e),{},{[t]:Date.now()}))}jh(t){if(!this.xh())return;let e=this.Jh(),s={},i=!1;for(let[n,r]of Object.entries(e))t.includes(n)?i=!0:s[n]=r;i&&(nt(s)?this.Ch():this.$h(s))}Kh(){this.xh()&&this.Ch()}getActivationTimestamp(t){if(!this.Wh().includes(t))return;let e=this.Jh()[t];return Te(e)?e:void 0}Qh(){var t;let e=this.Xh();return((t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[e])||[]}Wh(){var t,e,s;let i=this.Qh();if(i.length===0)return[];let n=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.props[this.Yh()],r=(e=this._instance)===null||e===void 0||(s=e.get_session_id)===null||s===void 0?void 0:s.call(e);return r&&n===r?i:[]}Gh(){var t,e;let s=(t=this._instance)===null||t===void 0||(e=t.get_session_id)===null||e===void 0?void 0:e.call(t);s&&this.td(s)}Zh(){this.ed()}kh(t){var e;let s=(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0?void 0:e.props[this.Yh()];if(s&&s!==t){let i=this.Qh(),n=this.Jh();i.length>0&&(this.Vh([]),i.filter(r=>Te(n[r])).forEach(r=>this.Bh(r))),this.Zh(),this.Kh(),i.length>0&&this.Uh()}}getActivatedIds(){return[...new Set([...this.Wh(),...this.gh])].filter(t=>!this.nd(t))}dispose(){var t,e,s;(t=this.wh)===null||t===void 0||t.call(this),this.wh=void 0,(e=this.oh)===null||e===void 0||e.call(this),this.oh=void 0,(s=this.Fh)===null||s===void 0||s.dispose(),this.Fh=void 0}reset(){this.gh=[],this.Qh().length>0&&this.Vh([]),this.Zh(),this.Kh(),this.Uh()}getEventToItemsMap(){return this.yh}sd(){return this.Fh}},fT=class extends hT{constructor(t,e){super(t,e)}Xh(){return pp}Yh(){return vp}xh(){return _p}$h(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated_timestamps:t})}Ch(){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.unregister("$surveys_activated_timestamps")}Sh(t){var e;let s;this.Eh(n=>{s=n.find(r=>r.id===t)});let i=s==null||(e=s.appearance)===null||e===void 0?void 0:e.surveyPopupDelaySeconds;return Te(i)&&i>0}rd(){return ct.SHOWN}Eh(t){var e;(e=this._instance)===null||e===void 0||e.getSurveys(t)}Bh(t){var e;(e=this._instance)===null||e===void 0||e.cancelPendingSurvey(t)}Dh(){return ne}Vh(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated:t})}td(t){var e;(e=this._instance)===null||e===void 0||(e=e.persistence)===null||e===void 0||e.register({$surveys_activated_session:t})}ed(){var t;(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0||t.unregister("$surveys_activated_session")}nd(){return!1}Lh(t,e,s){var i;if(t===ct.SENT&&(s==null||(i=s.properties)===null||i===void 0?void 0:i.$survey_completed)===!1)return"ignore";let n;return this.Eh(r=>{n=r.find(o=>o.id===e)}),!n||(function(r){var o;return Ev(r)&&!!(!((o=r.conditions)===null||o===void 0||(o=o.events)===null||o===void 0)&&o.repeatedActivation)||r.schedule==="always"})(n)?t===ct.SHOWN?"consume":"ignore":t===ct.SHOWN?"persist":t===ct.DISMISSED||t===ct.SENT?"consume":"ignore"}getSurveys(){return this.getActivatedIds()}getEventToSurveys(){return this.getEventToItemsMap()}},gT=class{constructor(t){this._instance=t}initialize(){}get(t){if(typeof t=="string")return this._instance.get_property(t);let e={};for(let s of t){let 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)}},pT=class{constructor(t){this._instance=t}get(){let 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()}isCapturing(){return this._instance.is_capturing()}getExtensions(){let t=L?.__PosthogExtensions__;if(!t)return;let{generateSurveys:e,loadExternalDependency:s}=t;return{generateSurveys:e?i=>e(this._instance,i):void 0,loadExternalDependency:s?i=>s(this._instance,"surveys",i):void 0}}createEventReceiver(t){return new fT(this._instance,t)}onMatchingConditionsChanged(t){let e=this._instance._addCaptureHook(r=>{r!=="$pageview"&&r!==ct.SHOWN&&r!==ct.DISMISSED&&r!==ct.SENT||t()}),s=()=>t();se(E,"PHSurveyShown",s);let i=!1,n=this._instance.onFeatureFlags(()=>{i&&t()});return i=!0,()=>{i=!1,e(),n(),E?.removeEventListener("PHSurveyShown",s)}}},vT=E?.location?eo(E.location.hash,"__posthog")||eo(location.hash,"state"):null,Gf="_postHogToolbarParams",Hf=ye("[Toolbar]"),zf=ye("[FeatureFlags]"),Cs=ye("[FeatureFlags]",{debugEnabled:!0}),_l=`" failed. Feature flags didn't load in time.`,_T=[502,504],qf=["click","keydown","wheel","touchstart","pointerdown"],Wf="connection_error",Kf=t=>{let e={};for(let s=0;t.length>s;s++)e[t[s]]=!0;return e},Yf=t=>{let e={};for(let[s,i]of Fr(t||{}))i&&(e[s]=i);return e},mT=class{constructor(t){this.name="featureFlags",this.od=!1,this.featureFlagEventHandlers=[],this.A=zf,this.ad={},this.ld={},this.ud=[],this.hd=new Set,this.dd=new Set,this.vd=!1,this.fd=!1,this.pd=0,this.gd=!1,this.md=!1,this.yd=!1,this.bd=!1,this._d=0,this.wd=!1,this.rn=()=>{let e=this.kd();this._d=0,e&&this.reloadFeatureFlags()},this.Sd=()=>{var e,s;let i=this.xd,n=(e=this.$d)!==null&&e!==void 0?e:i;S(i)||S(n)||this.Mr.remoteRequestsDisabled||!this.Cd||this.Cd.visibilityState==="hidden"||Date.now()-((s=this.Td)!==null&&s!==void 0?s:0)<n||(this.$d=this.wd||!this.Mr.idleRefreshBackoff?i:Math.min(2*n,36e5),this.wd=!1,this.reloadFeatureFlags(),this.Id())},this.Md=()=>{this.wd&&this.$d===this.xd||this.Ed()},this.sn=()=>{var e;((e=this.Cd)===null||e===void 0?void 0:e.visibilityState)==="visible"&&this.Ed()},this.wo=t}get Pd(){}Rd(){this.bo&&this.Ad()}setup(t){try{this.Fd=typeof window>"u"?void 0:window,this.Cd=typeof document>"u"?void 0:document}catch{this.Fd=void 0,this.Cd=void 0}return this.Lc=t,this.A=t.logger.createLogger("[FeatureFlags]"),Ec(t.kv.initialize(),()=>{this.Lc===t&&(this.Lc=void 0,this.bo=t,this.Od(t))})}Od(t){var e;if(this.bo===t)return this.Fd&&se(this.Fd,"online",this.rn),this.Ad(),this.Dd=t.registerDynamicEventProperties(()=>this.Ld()?this.ad:this.ld),this.Nd=(e=this.Pd)===null||e===void 0?void 0:e.onCrossTabFeatureFlagChange(()=>{this.qd(),this.jd(),this.Bd()}),this.jd(),this.initialize()}Ed(){this.wd=!0,this.$d=this.xd,this.Sd()}Ad(){var t;let e=this.Mr.refreshIntervalMs,s=!this.Mr.remoteRequestsDisabled&&this.Cd&&!S(e)&&e>0?e:void 0;this.Mr.idleRefreshBackoff||(this.$d=s),s!==this.xd&&(this.zd(),S(s)||(this.xd=s,this.$d=s,this.Id(),!((t=this.Cd)===null||t===void 0)&&t.addEventListener&&(se(this.Cd,_n,this.sn),ai(qf,i=>{se(this.Cd,i,this.Md,{capture:!0})}))))}Id(){S(this.xd)||(S(this.Hd)||clearInterval(this.Hd),this.Td=Date.now(),this.Hd=setInterval(this.Sd,this.xd))}zd(){var t,e;S(this.Hd)||(clearInterval(this.Hd),this.Hd=void 0,(t=this.Cd)===null||t===void 0||(e=t.removeEventListener)===null||e===void 0||e.call(t,"visibilitychange",this.sn),ai(qf,s=>{var i,n;(i=this.Cd)===null||i===void 0||(n=i.removeEventListener)===null||n===void 0||n.call(i,s,this.Md,{capture:!0})})),this.xd=void 0,this.$d=void 0,this.wd=!1,this.Td=void 0}destroy(){this.Ud()}dispose(){this.Ud()}Ud(){var t,e,s;this.zd(),this.pd++,this.md=!1,this.Lc=void 0,this.Wd(this.hd,"cancelled"),this.Wd(this.dd,"cancelled"),this.bo&&(this.Vd(),(t=this.Dd)===null||t===void 0||t.dispose(),this.Dd=void 0,(e=this.Nd)===null||e===void 0||e.call(this),this.Nd=void 0,this.ud=[],(s=this.Fd)===null||s===void 0||s.removeEventListener("online",this.rn),this.bo=void 0)}get Mr(){return this.wo.get()}Gd(t){var e;return this.Qd&&t in this.Qd?this.Qd[t]:(e=this.bo)===null||e===void 0?void 0:e.kv.get(t)}qd(){return!!this.Qd&&(this.Qd=void 0,!0)}Zd(){var t;return!S((t=this.bo)===null||t===void 0?void 0:t.kv.get("$enabled_feature_flags"))&&this.qd()}$t(t){this.Jd(()=>{var e;return(e=this.bo)===null||e===void 0?void 0:e.kv.set(t)})}Kd(t,e,s){if(!this.Pd||!t.$enabled_feature_flags)return;let i=this.Gd("$enabled_feature_flags")||{},n=t.$enabled_feature_flags||{},r=e.flags||e.featureFlags,o=e.flags?Object.entries(e.flags).filter(([,v])=>!v?.failed).map(([v])=>v):[],a=!!e.errorsWhileComputingFlags&&!!e.flags,l=a?o:s&&!N(r)?Object.keys(r||{}):Array.from(new Set([...Object.keys(i),...Object.keys(n)])),c=this.Gd("$feature_flag_payloads")||{},u=t.$feature_flag_payloads||{},h=a||s?l:Array.from(new Set([...Object.keys(c),...Object.keys(u)])),d=!a&&!s,g=!!d||l,p=!!d||h,m={[zt]:g,[yt]:g,[cs]:p};t.$feature_flag_details&&(m[Ds]=g);for(let v of[Ns,us,rn])S(t[v])||(m[v]=!0);this.Pd.markCrossTabFeatureFlagChanges(m)}Pt(t){this.Jd(()=>{var e;return(e=this.bo)===null||e===void 0?void 0:e.kv.remove(t)})}Jd(t){try{t()}catch(e){this.A.error("Failed to update feature flag persistence",e)}}jd(){let t={};for(let i of[zt,cs,Ns,Tt]){let n=this.Gd(i);S(n)||(t[i]=n)}this.ad=t;let e=_({},t),s=this.Gd(yt);if(s)for(let[i,n]of Object.entries(s))e[`$feature/${i}`]=n;this.ld=e}Ld(){let t=this.Mr.cacheTtlMs;if(!t||0>=t)return!1;let e=this.Gd(us);return typeof e!="number"||Date.now()-e>t}Xd(){return!!this.Ld()&&(this.bd||this.fd||(this.bd=!0,this.A.warn("Feature flag cache is stale, triggering refresh..."),this.reloadFeatureFlags()),!0)}Yd(){let t=this.Mr.evaluationContexts;return t?.length?t.filter(e=>{let s=e&&typeof e=="string"&&e.trim().length>0;return s||this.A.error("Invalid evaluation context found:",e,"Expected non-empty string"),s}):[]}tv(){let t=this.Mr.flagKeys;if(!S(t))return t.filter(e=>{let 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;let s=this.Mr,i=(t=(e=s.bootstrap)===null||e===void 0?void 0:e.featureFlags)!==null&&t!==void 0?t:{};if(Object.keys(i).length){var n,r;let o=(n=(r=s.bootstrap)===null||r===void 0?void 0:r.featureFlagPayloads)!==null&&n!==void 0?n:{},a=Object.keys(i).filter(c=>!S(i[c])).reduce((c,u)=>(c[u]=i[u],c),{}),l=Object.keys(o).filter(c=>a[c]).reduce((c,u)=>(c[u]=o[u],c),{});return this.ev({featureFlags:a,featureFlagPayloads:l},void 0,{persist:!1})}}updateFlags(t,e,s){var i,n;let r=s?.merge&&(i=this.Gd("$enabled_feature_flags"))!==null&&i!==void 0?i:{},o=s?.merge&&(n=this.Gd("$feature_flag_payloads"))!==null&&n!==void 0?n:{},a=_(_({},r),t),l=_(_({},o),e),c={};for(let[u,h]of Object.entries(a))c[u]={key:u,enabled:Uh(h),variant:Bh(h),reason:void 0,metadata:S(l?.[u])?void 0:{id:0,version:void 0,description:void 0,payload:l[u]}};this.ev({flags:c})}get hasLoadedFlags(){return this.vd}getFlags(){return Object.keys(this.getFlagVariants())}getFlagsWithDetails(){let t=this.Gd(Ds),e=this.Gd(Tt),s=this.Gd($s);if(!s&&!e)return t||{};let i=ve({},t||{}),n=[...new Set([...Object.keys(s||{}),...Object.keys(e||{})])];for(let a of n){var r,o;let l=i[a],c=e?.[a],u=S(c)?(r=l?.enabled)!==null&&r!==void 0&&r:!!c,h=S(c)?l?.variant:typeof c=="string"?c:void 0,d=s?.[a],g=_(_({},l),{},{enabled:u,variant:u?h??l?.variant:void 0});u!==l?.enabled&&(g.original_enabled=l?.enabled),h!==l?.variant&&(g.original_variant=l?.variant),d&&(g.metadata=_(_({},l?.metadata),{},{payload:d,original_payload:l==null||(o=l.metadata)===null||o===void 0?void 0:o.payload})),i[a]=g}return this.od||(this.A.warn(" Overriding feature flag details!",{flagDetails:t,overriddenPayloads:s,finalDetails:i}),this.od=!0),i}getAllFeatureFlags(){let t=this.getFlagVariants(),e=this.getFlagPayloads();return Object.keys(t).map(s=>{let i=t[s];return{key:s,enabled:Uh(i),variant:Bh(i),payload:Lh(e[s])}})}getFlagVariants(){let t=this.Gd(yt),e=this.Gd(Tt);if(!e)return t||{};let s=ve({},t||{}),i=Object.keys(e);for(let n=0;i.length>n;n++)s[i[n]]=e[i[n]];return this.od||(this.A.warn(" Overriding feature flags!",{enabledFlags:t,overriddenFlags:e,finalFlags:s}),this.od=!0),s}getFlagPayloads(){let t=this.Gd(cs),e=this.Gd($s);if(!e)return t||{};let s=ve({},t||{}),i=Object.keys(e);for(let n=0;i.length>n;n++)s[i[n]]=e[i[n]];return this.od||(this.A.warn(" Overriding feature flag payloads!",{flagPayloads:t,overriddenPayloads:e,finalPayloads:s}),this.od=!0),s}reloadFeatureFlags(){this.gd||this.Mr.featureFlagsDisabled||this.kd()||(this.fd&&(this.md=!0),this.iv||(this.ud.slice().forEach(t=>{try{t()}catch(e){this.A.error("Error while running feature flags reloading callback",e)}}),this.iv=setTimeout(()=>{this.nv()},5)))}reloadFeatureFlagsAsync(){return!this.bo||this.gd||this.Mr.featureFlagsDisabled||this.Mr.remoteRequestsDisabled||this.kd()?Promise.resolve({status:"skipped"}):new Promise(t=>{this.hd.add(t),this.reloadFeatureFlags()})}Wd(t,e){t.forEach(s=>s({status:e})),t.clear()}Vd(){clearTimeout(this.iv),this.iv=void 0}onReloading(t){return this.ud.push(t),()=>{this.ud=this.ud.filter(e=>e!==t)}}ensureFlagsLoaded(){this.vd||this.fd||this.iv||this.reloadFeatureFlags()}setAnonymousDistinctId(t){this.$anon_distinct_id=t}setReloadingPaused(t){this.gd=t}resetFlagCallReported(){this.Pt(ls)}nv(t){var e;this.Vd();let s=this.bo;if(!s||this.Mr.remoteRequestsDisabled||this.kd())return void this.Wd(this.hd,"skipped");if(this.fd)return void(this.md=!0);let i={token:s.projectToken,distinct_id:s.distinctId,groups:s.groups,$anon_distinct_id:this.$anon_distinct_id,person_properties:_(_(_({},s.initialPersonProperties),this.Gd("$stored_person_properties")||{}),{},{$lib:s.library.name,$lib_version:s.library.version}),group_properties:this.Gd(os),timezone:zp()};S(s.deviceId)||(i.$device_id=s.deviceId),(t?.disableFlags||this.Mr.featureFlagsDisabled)&&(i.disable_flags=!0);let n=this.Yd();n.length&&(i.evaluation_contexts=n);let r=this.tv();S(r)||(i.flag_keys=r);let o=this.Mr.onlyEvaluateSurveyFeatureFlags,a="/flags/?v=2"+(o?"&only_evaluate_survey_feature_flags=true":""),l=this.pd,c=this.hd;this.hd=new Set,this.dd=c,this.fd=!0;let u=()=>{this.md&&(this.md=!1,this.nv())},h=v=>{var b,y;let w=(b=v.json)!==null&&b!==void 0?b:{},A=v.statusCode!==200;if(this.fd=!1,l!==this.pd)return void u();if(this.sv(v.statusCode),A||this.md||(this.$anon_distinct_id=void 0),i.disable_flags&&!this.md)return void this.Wd(c,"skipped");this.yd=!A;let I=[];v.error?I.push(v.error instanceof Error&&v.error.name==="AbortError"?"timeout":v.error instanceof Error?Wf:"unknown_error"):v.statusCode!==200&&I.push(`api_error_${v.statusCode}`),w.errorsWhileComputingFlags&&I.push("errors_while_computing_flags");let k=!!(!((y=w.quotaLimited)===null||y===void 0)&&y.includes("feature_flags"));k&&I.push("quota_limited"),this.$t({[vn]:I}),k?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."):i.disable_flags||this.ev(w,A,{partialResponse:o}),this.Wd(c,i.disable_flags?"skipped":I.length||!w.flags&&!w.featureFlags?"error":"loaded"),u()},d=v=>{this.fd=!1,l===this.pd&&(this.$t({[vn]:[Wf]}),this.A.error("Feature flag request failed",v),this.Zd()&&this.Bd(!0),this.Wd(c,"error")),u()},g=(e=this.Mr.requestMaxRetries)!==null&&e!==void 0?e:1,p=()=>g>0&&l===this.pd,m=()=>{if(l!==this.pd||!this.bo||this.Mr.remoteRequestsDisabled)return this.fd=!1,this.Wd(c,"skipped"),void u();try{s.sendRequest(a,{target:"flags",method:"POST",body:i,compression:this.Mr.compression,sentAt:"body",timeoutMs:this.Mr.requestTimeoutMs}).then(v=>{if((b=>_T.includes(b.statusCode)||(y=>y.statusCode===0&&y.error instanceof Error&&y.error.name==="AbortError")(b))(v)&&p())return g--,void setTimeout(m,500);h(v)}).catch(d)}catch(v){d(v)}};m()}kd(){return Wp(this._d,3)}sv(t){this._d=Kp(t,this._d,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.fresh&&!this.yd)return;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlag for key "'+t+_l);if(this.Xd())return;let i=this.getFeatureFlagResult(t,e);return(s=i?.variant)!==null&&s!==void 0?s:i?.enabled}getFeatureFlagDetails(t){return this.getFlagsWithDetails()[t]}getFeatureFlagPayload(t){let e=this.getFeatureFlagResult(t,{send_event:!1});return e?.payload}getFeatureFlagResult(t,e={}){if(e.fresh&&!this.yd)return;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return void this.A.warn('getFeatureFlagResult for key "'+t+_l);if(this.Xd())return;let s=this.getFlagVariants(),i=t in s,n=s[t],r=this.getFlagPayloads()[t],o=String(n),a=this.Gd("$feature_flag_request_id")||void 0,l=this.Gd("$feature_flag_evaluated_at")||void 0,c,u=this.Gd("$flag_call_reported")||{};if(this.Mr.deduplicateCallsPerSession){var h;let x=(h=this.bo)===null||h===void 0||(h=h.session)===null||h===void 0?void 0:h.sessionId,Y=this.Gd(Zi);x&&x!==Y&&(u={},c=x)}if(!e.send_event&&"send_event"in e)c&&this.$t({[ls]:u,[Zi]:c});else if(t in u&&u[t].includes(o))c&&this.$t({[ls]:u,[Zi]:c});else{var d,g,p,m,v,b,y,w,A,I,k,$,O;N(u[t])?u[t].push(o):u[t]=[o],this.$t(_({[ls]:u},c?{[Zi]:c}:{}));let x=this.getFeatureFlagDetails(t),Y=[...(d=this.Gd("$feature_flag_errors"))!==null&&d!==void 0?d:[]];S(n)&&Y.push("flag_missing");let X={$feature_flag:t,$feature_flag_response:n,$feature_flag_payload:r??null,$feature_flag_request_id:a,$feature_flag_evaluated_at:l,$feature_flag_bootstrapped_response:(g=(p=this.Mr.bootstrap)===null||p===void 0||(p=p.featureFlags)===null||p===void 0?void 0:p[t])!==null&&g!==void 0?g:null,$feature_flag_bootstrapped_payload:(m=(v=this.Mr.bootstrap)===null||v===void 0||(v=v.featureFlagPayloads)===null||v===void 0?void 0:v[t])!==null&&m!==void 0?m:null,$used_bootstrap_value:!this.yd};S(x==null||(b=x.metadata)===null||b===void 0?void 0:b.has_experiment)||(X.$feature_flag_has_experiment=x.metadata.has_experiment),S(x==null||(y=x.metadata)===null||y===void 0?void 0:y.version)||(X.$feature_flag_version=x.metadata.version);let Z=(w=x==null||(A=x.reason)===null||A===void 0?void 0:A.description)!==null&&w!==void 0?w:x==null||(I=x.reason)===null||I===void 0?void 0:I.code;Z&&(X.$feature_flag_reason=Z),!(x==null||(k=x.metadata)===null||k===void 0)&&k.id&&(X.$feature_flag_id=x.metadata.id),S(x?.original_variant)&&S(x?.original_enabled)||(X.$feature_flag_original_response=S(x.original_variant)?x.original_enabled:x.original_variant),!(x==null||($=x.metadata)===null||$===void 0)&&$.original_payload&&(X.$feature_flag_original_payload=x==null||(O=x.metadata)===null||O===void 0?void 0:O.original_payload),Y.length&&(X.$feature_flag_error=Y.join(",")),this.rv(X)}return i?{key:t,enabled:!!n,variant:typeof n=="string"?n:void 0,payload:Lh(r)}:void 0}rv(t){try{var e;(e=this.bo)===null||e===void 0||e.capture("$feature_flag_called",t)}catch(s){this.A.error("Failed to capture feature flag call",s)}}getRemoteConfigPayload(t,e){this.ov(t,e)}ov(t,e){var s=this;return he(function*(){let i=s.bo;if(!i)return;let n={distinct_id:i.distinctId,token:i.projectToken,person_properties:{$lib:i.library.name,$lib_version:i.library.version}},r=s.Yd();r.length&&(n.evaluation_contexts=r);let o=s.tv(),a;S(o)||(n.flag_keys=o);try{var l;let c=(l=(yield i.sendRequest("/flags/?v=2",{target:"flags",method:"POST",body:n,compression:s.Mr.compression,sentAt:"body",timeoutMs:s.Mr.requestTimeoutMs})).json)===null||l===void 0?void 0:l.featureFlagPayloads;a=c?.[t]||void 0}catch(c){return void s.A.error("Remote config feature flag request failed",c)}try{e(a)}catch(c){s.A.error("Remote config feature flag callback failed",c)}})()}isFeatureEnabled(t,e={}){if(e.fresh&&!this.yd)return e.defaultValue;if(!(this.vd||this.getFlags()&&this.getFlags().length>0))return this.A.warn('isFeatureEnabled for key "'+t+_l),e.defaultValue;let 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.ev(t,e,s)}ev(t,e,s){if(!this.bo)return;this.vd=!0;let i=((n,r={},o={},a={},l,c=zf)=>{let u=((w,A)=>{let I=w.flags;if(I){let k=Object.fromEntries(Object.keys(I).map(O=>{var x;return[O,(x=I[O].variant)!==null&&x!==void 0?x:I[O].enabled]})),$=Object.fromEntries(Object.keys(I).filter(O=>I[O].enabled).filter(O=>{var x;return!S((x=I[O].metadata)===null||x===void 0?void 0:x.payload)}).map(O=>{var x;return[O,(x=I[O].metadata)===null||x===void 0?void 0:x.payload]}));return _(_({},w),{},{featureFlags:k,featureFlagPayloads:$})}return w.featureFlags&&A.warn("Using an older version of the feature flags endpoint. Please upgrade your PostHog server to the latest version"),w})(n,c),h=u.flags,d=u.featureFlags,g=u.featureFlagPayloads;if(!d)return;let p=n.requestId,m=n.evaluatedAt;if(N(d)){c.warn("v1 of the feature flags endpoint is deprecated. Please use the latest version.");let w={};if(d)for(let A=0;d.length>A;A++)w[d[A]]=!0;return{[zt]:d,[yt]:w,[rn]:!1}}let v=d,b=g,y=h;if(l?.partialResponse){let w=Object.keys(v),A=b||{};v=_(_({},r),v),b=_(_({},o),A),w.forEach(I=>{I in A||b==null||delete b[I]}),y=_(_({},a),y)}else if(n.errorsWhileComputingFlags)if(h){let w=new Set(Object.keys(h).filter(I=>{var k;return!(!((k=h[I])===null||k===void 0)&&k.failed)}));v=_(_({},r),Object.fromEntries(Object.entries(v).filter(([I])=>w.has(I))));let A=Object.fromEntries(Object.entries(b||{}).filter(([I])=>w.has(I)));b=_(_({},o),A),w.forEach(I=>{I in A||b==null||delete b[I]}),y=_(_({},a),Object.fromEntries(Object.entries(y||{}).filter(([I])=>w.has(I))))}else v=_(_({},r),v),b=_(_({},o),b),y=_(_({},a),y);return _(_({[zt]:Object.keys(Yf(v)),[yt]:v||{},[cs]:b||{},[Ds]:y||{},[rn]:n.minimalFlagCalledEvents===!0},p?{[Ns]:p}:{}),m?{[us]:m}:{})})(t,this.getFlagVariants(),this.getFlagPayloads(),this.getFlagsWithDetails(),s,this.A);if(i)if(s?.persist===!1){let n=!S(this.bo.kv.get(yt));this.Qd=i,n||this.$t(i)}else this.qd(),this.Kd(i,t,!!s?.partialResponse),this.$t(i);else e&&this.Zd();e||(this.bd=!1),this.Bd(e)}override(t,e=!1){this.A.warn("override is deprecated. Please use overrideFeatureFlags instead."),this.overrideFeatureFlags({flags:t,suppressWarning:e})}overrideFeatureFlags(t){this.av(t)}av(t){if(this.bo){if(t===!1)return this.Pt([Tt,$s]),this.Bd(),void Cs.info("All overrides cleared");if(N(t))return this.$t({[Tt]:Kf(t)}),this.Bd(),void Cs.info("Flag overrides set",{flags:t});if(t&&typeof t=="object"&&("flags"in t||"payloads"in t)){var e;let s=t;this.od=!!((e=s.suppressWarning)!==null&&e!==void 0&&e);let i={},n=s.flags,r=s.payloads;return n&&(i[Tt]=N(n)?Kf(n):n),r&&(i[$s]=r),Object.keys(i).length&&this.$t(i),n===!1&&r===!1?this.Pt([Tt,$s]):n===!1?this.Pt(Tt):r===!1&&this.Pt($s),this.Bd(),n===!1?Cs.info("Flag overrides cleared"):n&&Cs.info("Flag overrides set",{flags:n}),void(r===!1?Cs.info("Payload overrides cleared"):r&&Cs.info("Payload overrides set",{payloads:r}))}if(t&&typeof t=="object")return this.$t({[Tt]:t}),this.Bd(),void Cs.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.vd){let{flags:e,flagVariants:s}=this.lv();try{t(e,s)}catch(i){this.A.error("Error while running feature flags callback",i)}}return()=>this.removeFeatureFlagsHandler(t)}updateEarlyAccessFeatureEnrollment(t,e,s){var i;let n=(this.Gd("$early_access_features")||[]).find(c=>c.flagKey===t),r={[`$feature_enrollment/${t}`]:e},o={$feature_flag:t,$feature_enrollment:e,$set:r};n&&(o.$early_access_feature_name=n.name),s&&(o.$feature_enrollment_stage=s);let a=_(_({},this.getFlagVariants()),{},{[t]:e});(i=this.Pd)===null||i===void 0||i.markCrossTabFeatureFlagChanges({$active_feature_flags:[t],$enabled_feature_flags:[t],$stored_person_properties:Object.keys(r)}),this.$t({[zt]:Object.keys(Yf(a)),[yt]:a,[as]:_(_({},this.Gd("$stored_person_properties")||{}),r)}),this.Bd();try{var l;(l=this.bo)===null||l===void 0||l.capture("$feature_enrollment_update",o)}catch(c){this.A.error("Failed to capture early access feature enrollment",c)}}getEarlyAccessFeatures(t,e=!1,s){let i=this.Gd(Pl);!i||e?this.uv(t,s):t(i)}uv(t,e){var s=this;return he(function*(){let i=s.bo;if(!i)return;let n=e?`&${e.map(o=>`stage=${o}`).join("&")}`:"",r;try{let 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.$t({[Pl]:r})}catch(o){return void s.A.error("Early access feature request failed",o)}try{t(r)}catch(o){s.A.error("Early access feature callback failed",o)}})()}lv(){let 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),{})}}Bd(t){this.jd();let{flags:e,flagVariants:s}=this.lv();this.featureFlagEventHandlers.forEach(i=>{try{i(e,s,{errorsLoading:t})}catch(n){this.A.error("Error while running feature flags callback",n)}})}setPersonPropertiesForFlags(t,e=!0){this.hv(t,e)}hv(t,e=!0){let s=this.Gd("$stored_person_properties")||{},i=t?.$set||(t?.$set_once?{}:t),n=t?.$set_once,r={};if(n)for(let o in n)({}).hasOwnProperty.call(n,o)&&(o in s||(r[o]=n[o]));this.$t({[as]:_(_(_({},s),r),i)}),e&&this.reloadFeatureFlags()}unsetPersonPropertiesForFlags(t,e=!0){let s=_({},this.Gd("$stored_person_properties")||{});t.forEach(i=>{delete s[i]}),this.$t({[as]:s}),e&&this.reloadFeatureFlags()}resetPersonPropertiesForFlags(t=!0){this.Pt(as),t&&this.reloadFeatureFlags()}setGroupPropertiesForFlags(t,e=!0){let s=this.Gd("$stored_group_properties")||{},i=_({},s);for(let n of Object.keys(t))i[n]=_(_({},s[n]),t[n]);this.$t({[os]:i}),e&&this.reloadFeatureFlags()}resetGroupPropertiesForFlags(t){if(t){let e=this.Gd("$stored_group_properties")||{};this.$t({[os]:_(_({},e),{},{[t]:{}})})}else this.Pt(os)}reset(){this.pd++,this.Wd(this.hd,"cancelled"),this.Wd(this.dd,"cancelled"),this.md=!1,this.ad={},this.ld={},this.Qd=void 0,this.vd=!1,this.gd=!1,this.yd=!1,this.$anon_distinct_id=void 0,this.Vd(),this.od=!1,this._d=0}},Qf=ye("[FeatureFlags]"),yT=class{constructor(t,e=!1){this.dv=!1,this.update(t,e)}update(t,e){this.vv=((s,i)=>{var n,r,o,a,l,c,u,h;return{bootstrap:{featureFlags:(n=(r=s.bootstrap)===null||r===void 0?void 0:r.featureFlags)!==null&&n!==void 0?n:void 0,featureFlagPayloads:(o=(a=s.bootstrap)===null||a===void 0?void 0:a.featureFlagPayloads)!==null&&o!==void 0?o:void 0},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:(l=s.remote_config_refresh_interval_ms)!==null&&l!==void 0?l:3e5,idleRefreshBackoff:S(s.remote_config_refresh_interval_ms),requestTimeoutMs:s.feature_flag_request_timeout_ms,requestMaxRetries:Math.max(0,(c=s.feature_flag_request_max_retries)!==null&&c!==void 0?c:1),compression:s.disable_compression?void 0:"best-available",evaluationContexts:(u=(h=s.evaluation_contexts)!==null&&h!==void 0?h:s.evaluation_environments)!==null&&u!==void 0?u:[],flagKeys:N(s.flag_keys)?s.flag_keys:void 0}})(t,e),!t.evaluation_environments||t.evaluation_contexts||this.dv||(Qf.warn("evaluation_environments is deprecated. Use evaluation_contexts instead. evaluation_environments will be removed in a future version."),this.dv=!0),S(t.flag_keys)||N(t.flag_keys)||Qf.error("Invalid flag_keys found:",t.flag_keys,"Expected array of non-empty strings")}get(){return this.vv}},Jf=t=>bi(t)&&(t.name==="RangeError"&&t.message.indexOf("Maximum call stack size exceeded")===0||t.name==="InternalError"&&t.message==="too much recursion"),_t=ye("[Error tracking]"),Ql="webkit-masked-url:",bT=[{value:"isolatedAPI.contexts.topHostname",exact:!1},{value:"No response from target",exact:!0}],ET=["chrome-extension://","moz-extension://","safari-extension:","safari-web-extension:",Ql],wT=["__firefox__","__gCrWeb"],Xf="Refusing to render web experiment since the viewer is a likely bot",ST={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=ye("[Conversations]"),Os="Conversations not available yet.";kT=["debug","log","warn","error","info"],AT=t=>{for(;t?.__rrweb_original__;)t=t.__rrweb_original__;return t},eg="console",Pv="__posthogHandledLogsRequestError",ml=(t,e)=>{let s=t instanceof Error?t:new Error(e);return s[Pv]=!0,s},tg=t=>!!t&&typeof t=="object"&&t[Pv]===!0,TT=class{get fv(){return _(_({},this.A),{},{error:(...t)=>{t.some(tg)||this.A.error(...t)}})}constructor(t,e){var s;this.wo=t,this.pv=e,this.name="logs",this.gv=!1,this.mv=!1,this.yv=!1,this.A=ye("[logs]"),this.ol=[],this.bv=[],this._d=0,this._v=!1,this.To=!1,this.wv=[],this.Sv=[],this.xv=!1,this.$v=!1,this.Cv=!1,this.Tv=()=>{var i,n;this.To||(this._d=0,(i=this.Iv)===null||i===void 0||i.onReconnect(),(n=this.Mv)===null||n===void 0||n.onReconnect())},this.gv=!!(!((s=t.get())===null||s===void 0)&&s.captureConsoleLogs)}get Ev(){return!0}Pv(){}Rv(){if(!this.Cv){try{this.Fd=typeof window>"u"?void 0:window}catch{this.Fd=void 0}this.Fd&&(se(this.Fd,"online",this.Tv),this.Cv=!0)}}Av(t,e,s,i){this.Rv();let n=Zf(this.wo.get(),s);return[new bk(this.Fv(t,e),n,this.fv,()=>this.pv(),r=>r(),void 0,i),n]}Ov(){let t=this.wo.get();var e;return this.Iv&&this.Dv===t||((e=this.Iv)===null||e===void 0||e.reset(),this.Dv=t,[this.Iv,this.Lv]=this.Av(()=>this.ol,s=>{this.ol=s})),this.Iv}Nv(){let t=this.wo.get();var e;return this.Mv&&this.qv===t||((e=this.Mv)===null||e===void 0||e.reset(),this.qv=t,[this.Mv,this.jv]=this.Av(()=>this.bv,s=>{this.bv=s},{serviceNameDefault:"posthog-browser-logs",consoleCapture:!0},eg)),this.Mv}setup(t){if(!this.To&&!this._v)return this._v=!0,this.bo=t,this.A=t.logger.createLogger("[logs]"),Ec(t.kv.initialize(),()=>{this.To||this.Od(t)})}Od(t){var e;this.Rv(),!((e=this.wo.get())===null||e===void 0)&&e.captureConsoleLogs&&(this.gv=!0),(this.gv||this.wo.remoteConfigWillArrive&&t.kv.get(this.wo.captureHintKey))&&this.Bv();let s=!1,i=t.onRemoteConfig(n=>{var r;s=n.ok&&((r=n.config.logs)===null||r===void 0?void 0:r.captureConsoleLogs)===!0,this.onRemoteConfig(n)});this.To?i.dispose():(this.Eo=i,s||this.loadIfEnabled())}dispose(){var t,e,s,i,n,r,o;this.To||(this.To=!0,this.zv(),(t=this.Eo)===null||t===void 0||t.dispose(),this.Eo=void 0,this.bo=void 0,this.yv=!1,(e=this.Fd)===null||e===void 0||e.removeEventListener("online",this.Tv),(s=this.Hv)===null||s===void 0||s.call(this),this.Hv=void 0,(i=this.Iv)===null||i===void 0||i.clearQueue(),(n=this.Mv)===null||n===void 0||n.clearQueue(),(r=this.Iv)===null||r===void 0||r.reset(),(o=this.Mv)===null||o===void 0||o.reset())}onRemoteConfig(t){var e,s;if(this.To)return;let i=t.ok?(e=t.config.logs)===null||e===void 0?void 0:e.captureConsoleLogs:void 0;B(i)?this.Uv():((s=this.bo)===null||s===void 0||s.kv.set(this.wo.captureHintKey,!!i),i?(this.gv=!0,this.mv||this.Bv(),this.loadIfEnabled()):this.Uv())}reset(){var t,e,s,i;this.zv(),(t=this.Iv)===null||t===void 0||t.clearQueue(),this.ol=[],(e=this.Iv)===null||e===void 0||e.reset(),(s=this.Mv)===null||s===void 0||s.clearQueue(),this.bv=[],(i=this.Mv)===null||i===void 0||i.reset(),this._d=0}captureLog(t){!this.To&&this.bo&&this.Ov().captureLog(t)}captureConsoleLog(t){!this.To&&this.bo&&this.Nv().captureLog(t)}captureBufferedConsoleLog(t,e,s){!this.To&&this.bo&&this.Nv().captureLog(t,{context:e,occurredAtMs:s})}$c(){var t;this.zv(),(t=this.Mv)===null||t===void 0||t.clearQueue(),this.bv=[]}Uv(){this.gv||this.zv()}Bv(){var t;if(this.xv||!(!((t=this.Fd)===null||t===void 0)&&t.console))return;let e=Zf(this.wo.get()).maxBufferSize,s=!0;this.Sv.push(()=>{s=!1});for(let i of kT){let n;try{n=AT(this.Fd.console[i])}catch{continue}n&&this.Sv.push(yi(this.Fd.console,i,r=>{let o=(...a)=>{try{s&&this.Wv(i,a,e)}catch{}return r.apply(this.Fd.console,a)};return o.__rrweb_original__=n,o}))}this.xv=!0,this.Vv=setTimeout(()=>{this.zv()},3e4)}Wv(t,e,s){var i;if(this.xv&&!this.$v&&e.length!==0)if(!((i=this.bo)===null||i===void 0)&&i.canCapture){if(s>this.wv.length){this.$v=!0;try{this.wv.push({level:t,args:e,occurredAtMs:Date.now(),context:this.pv()})}finally{this.$v=!1}}}else this.zv()}zv(){if(this.wv=[],this.xv){this.xv=!1,this.Vv&&(clearTimeout(this.Vv),this.Vv=void 0);for(let t of this.Sv)t();this.Sv=[]}}Gv(){let t=this.wv;return this.zv(),t}get logger(){return this.Qv||(this.Qv={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.Qv}flushLogs(t){this.bo&&(t?this.Zv(t):(this.Iv&&this.Iv.flush().catch(e=>this.Jv(e)),this.Mv&&this.Mv.flush().catch(e=>this.Jv(e))))}flush(){var t=this;return he(function*(){var e,s;let i=(e=t.Iv)===null||e===void 0?void 0:e.flush().catch(r=>t.Jv(r)),n=(s=t.Mv)===null||s===void 0?void 0:s.flush().catch(r=>t.Jv(r));yield i,yield n})()}Jv(t){tg(t)||this.A.error("PostHog logs flush failed:",t)}loadIfEnabled(){if(this.To||!this.gv||this.mv||this.yv)return;let t=this.Pv();if(t){this.yv=!0;try{t((e,s)=>{if(this.yv=!1,!this.To&&this.gv)if(e||!s)this.A.error("Could not load logs script",e),this.zv();else{let i=this.Gv();this.Hv=s.initialize(this.bo),this.mv=!0,i.length>0&&s.replay(this.bo,i)}})}catch(e){throw this.yv=!1,e}}else this.zv()}Fv(t,e){let s=this.bo;return{get isDisabled(){return!1},get optedOut(){return!s.canCapture},getPersistedProperty:i=>i===It.LogsQueue?t():void 0,setPersistedProperty(i,n){i===It.LogsQueue&&e(n??[])},js:i=>this.js(i),getLibraryId:()=>s.library.name,getLibraryVersion:()=>s.library.version}}js(t){return new Promise(e=>{if(Wp(this._d,3))return void e({kind:"fatal",error:ml(void 0,"logs endpoint is unreachable, dropping batch")});let s=!1,i=o=>{s||(s=!0,clearTimeout(n),e(o))},n=setTimeout(()=>{this.A.warn("Logs request timed out before receiving a response"),i({kind:"retry-later",error:ml(void 0,"logs request timed out")})},9e4),r=this.Ev;this.bo.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.bo.projectToken},body:t,compression:"best-available",timeoutMs:6e4}).then(o=>{var a;let l=o.statusCode;this.Kv(l,r),l>=200&&300>l?i({kind:"ok"}):l===413?i({kind:"too-large"}):l!==0&&l!==408&&l!==429&&500>l?i({kind:"fatal",error:new Error(`logs request failed with status ${l}`)}):l===0?(o.error||this.A.warn("Logs request failed before receiving an HTTP response"),i({kind:"retry-later",error:ml(o.error,"logs request failed before receiving an HTTP response")})):i({kind:"retry-later",error:(a=o.error)!==null&&a!==void 0?a:new Error(`logs request failed with status ${l}`)})},o=>{i({kind:"retry-later",error:o})})})}Kv(t,e){(t!==0||e)&&(this._d=Kp(t,this._d,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.")))}Zv(t){this.ol.length>0&&this.Xv(t,this.ol,this.Lv,this.bo.library.name,e=>{this.ol=e}),this.bv.length>0&&this.Xv(t,this.bv,this.jv,eg,e=>{this.bv=e})}Xv(t,e,s,i,n){if(e.length===0)return;let r=e.map(a=>a.record);n([]);let o=np(r,ip(s,this.bo.library.name,this.bo.library.version),i,this.bo.library.version);this.bo.sendRequest("/i/v1/logs",{method:"POST",query:{token:this.bo.projectToken},body:o,compression:"best-available",transport:t,timeoutMs:6e4}).catch(a=>this.Jv(a))}},oo=ye("[NetworkMetrics]"),wc=()=>{var t;return!(E==null||(t=E.performance)===null||t===void 0)&&t.now?E.performance.now():Date.now()},IT={"http:":80,"https:":443},RT=new Set(["CONNECT","DELETE","GET","HEAD","OPTIONS","PATCH","POST","PUT","TRACE"]),$v=(t,e)=>{var s;let i=String(e);return{method:String(t).toUpperCase(),url:((s=Kt(i))===null||s===void 0?void 0:s.href)||i}},Jl=(t,e,s,i,n,r,o=!1)=>{try{var a,l;let c=n();if(!c)return;let u=s||void 0,h=wc()-i,d=Kt(e.url);if(d&&d.protocol!=="http:"&&d.protocol!=="https:")return;let g={url:d?.href||e.url,method:e.method},p=Ce(c.name)?c.name(g):H(c.name)?c.name:"http.client.request.duration";if(!p)return;let m=o&&!u?void 0:((b,y)=>b?400>b?void 0:String(b):y?.name||"_OTHER")(u,r),v=_(_(_(_(_({},(b=>{let y=RT.has(b)?b:"_OTHER";return _({"http.request.method":y},y==="_OTHER"&&b!==y?{"http.request.method_original":b}:{})})(g.method)),d?(b=>{return{"server.address":b.hostname.startsWith("[")&&b.hostname.endsWith("]")?b.hostname.slice(1,-1):b.hostname,"server.port":Number(b.port)||IT[b.protocol],"url.scheme":b.protocol.slice(0,-1),"url.template":(y=b.pathname,y.split("/").map(w=>(A=>/^\d+$/.test(A)||A.length>=8&&/^[0-9a-f-]*\d[0-9a-f-]*$/i.test(A))(w)?":id":w).join("/"))};var y})(d):{}),u?{"http.response.status_code":u}:{}),m?{"error.type":m}:{}),(a=c.attributes)===null||a===void 0?void 0:a.call(c,g,{status:u,durationMs:h}));(l=t.metrics)===null||l===void 0||l.histogram(p,h,{unit:"ms",attributes:v})}catch(c){oo.error("Failed to record network metric",c)}},xv=()=>{},CT=(t,e)=>Ce(E?.fetch)?yi(E,"fetch",s=>function(...i){let n=wc(),r=s.apply(this,i);if(!e())return r;try{var o,a,l;let[c,u]=i,h=$v((o=(a=u?.method)!==null&&a!==void 0?a:c?.method)!==null&&o!==void 0?o:"GET",(l=c?.url)!==null&&l!==void 0?l:c);return r.then(d=>(Jl(t,h,d?.status,n,e,void 0,!0),d),d=>{throw Jl(t,h,void 0,n,e,d),d})}catch(c){return oo.error("Failed to observe fetch",c),r}}):xv,OT=(t,e)=>{var s;let i=E==null||(s=E.XMLHttpRequest)===null||s===void 0?void 0:s.prototype;if(!i)return xv;let n=new WeakMap,r=yi(i,"open",a=>function(...l){try{lv.has(this)||n.set(this,$v(l[0],l[1]))}catch(c){oo.error("Failed to observe XHR open",c)}return a.apply(this,l)}),o=yi(i,"send",a=>function(...l){let c;try{let u=n.get(this);if(u&&e()){let h=wc();c=()=>{this.removeEventListener("loadend",c),Jl(t,u,this.status,h,e)},se(this,"loadend",c)}}catch(u){oo.error("Failed to observe XHR send",u)}try{return a.apply(this,l)}catch(u){throw c&&this.removeEventListener("loadend",c),u}});return()=>{r(),o()}},sg=new WeakMap,PT=new Set(["$comment","$defs","$id","$schema","additionalProperties","default","definitions","deprecated","description","examples","minProperties","properties","readOnly","required","title","type","writeOnly"]),$T={maxStringLength:2048,truncationSuffix:"..."};uo={featureFlags:class extends mT{constructor(t){let e=new yT(t.config,t.il());super(e),this.name=Tv,this._instance=t,this.Yv=e}get Pd(){return this._instance.persistence}updateConfig(t,e){this.Yv.update(t,e),this.Rd()}}},xT={sessionRecording:class{get Mr(){return this._instance.config}get Il(){return this._instance.persistence}get started(){var t;return!!(!((t=this.tf)===null||t===void 0)&&t.isStarted)}get status(){var t,e;return this.ef==="awaiting_config"||this.ef==="missing_config"?this.ef:(t=(e=this.tf)===null||e===void 0?void 0:e.status)!==null&&t!==void 0?t:this.ef}constructor(t){if(this._instance=t,this._forceAllowLocalhostNetworkCapture=!1,this.ef=gl,this.if=void 0,this.nf=!1,this.Je=(()=>{var e,s;if(!T?.visibilityState||T.visibilityState==="visible")return!0;let i=E==null||(e=E.performance)===null||e===void 0||(s=e.getEntriesByType)===null||s===void 0?void 0:s.call(e,"visibility-state");return!i?.length||i.some(n=>n.name==="visible")})(),this.sn=()=>{var e,s;T?.visibilityState==="visible"&&(this.Je=!0,(e=this.tf)===null||e===void 0||(s=e.setDocumentWasEverVisible)===null||s===void 0||s.call(e,!0))},!this._instance.sessionManager)throw jt.error("started without valid sessionManager"),new Error("[SessionRecording] started without valid sessionManager. This is a bug.");if(this.Mr.cookieless_mode==="always")throw new Error('[SessionRecording] cannot be used with cookieless_mode="always"');T?.addEventListener&&se(T,"visibilitychange",this.sn)}initialize(){this.startIfEnabledOrStop()}dispose({discardBufferedEvents:t=!1}={}){var e;this.nf=!0,T==null||(e=T.removeEventListener)===null||e===void 0||e.call(T,"visibilitychange",this.sn),t?this.sf(!0):this.stopRecording()}get rf(){var t;let e=!!(!((t=this._instance.get_property("$session_recording_remote_config"))===null||t===void 0)&&t.enabled),s=!this.Mr.disable_session_recording,i=this.Mr.disable_session_recording||this._instance.consent.isOptedOut();return E&&e&&s&&!i}startIfEnabledOrStop(t){var e;if(this.nf||this.rf&&(!((e=this.tf)===null||e===void 0)&&e.isStarted))return;let s=!S(Object.assign)&&!S(Array.from);this.rf&&s?(this.af(t),jt.info("starting")):(this.ef=gl,this.stopRecording())}af(t){var e,s;if(this.rf)if(this.ef!=="awaiting_config"&&this.ef!=="missing_config"&&(this.ef=Bf),(L==null||(e=L.__PosthogExtensions__)===null||e===void 0||(e=e.rrweb)===null||e===void 0?void 0:e.record)&&((s=L.__PosthogExtensions__)===null||s===void 0?void 0:s.initSessionRecording))this.lf(t);else{var i,n;let r=this._instance.sessionManager;(i=L.__PosthogExtensions__)===null||i===void 0||(n=i.loadExternalDependency)===null||n===void 0||n.call(i,this._instance,this.uf,o=>{if(!this.nf&&this.rf&&this._instance.sessionManager===r)return o?(this._instance.register_for_session({$sdk_debug_recording_script_not_loaded:!0}),jt.error("could not load recorder",o)):void this.lf(t);this.ef="disabled"})}}stopRecording(){var t,e;(t=this.if)===null||t===void 0||t.call(this),this.if=void 0,(e=this.tf)===null||e===void 0||e.stop()}sf(t=!1){var e,s;(e=this.if)===null||e===void 0||e.call(this),this.if=void 0,(s=this.tf)===null||s===void 0||s.discard({discardProducerEvents:t})}cf(){var t,e;(t=this.Il)===null||t===void 0||t.unregister("$session_is_sampled"),(e=this.Il)===null||e===void 0||e.unregister("$replay_sample_rate")}hf(t,e){if(B(t))return null;let s=Te(t)?t:parseFloat(t);return typeof(i=s)!="number"||!Number.isFinite(i)||0>i||i>1?(jt.warn(`${e} must be between 0 and 1. Ignoring invalid value:`,t),null):s;var i}df(t){if(this.Il){var e,s;let i=this.Il,n=()=>{var r;let o=t.sessionRecording===!1?void 0:t.sessionRecording,a=this.hf((r=this.Mr.session_recording)===null||r===void 0?void 0:r.sampleRate,"session_recording.sampleRate"),l=this.hf(o?.sampleRate,"remote config sampleRate"),c=a??l;B(c)&&this.cf();let u=o?.minimumDurationMilliseconds;i.register({[an]:_(_({cache_timestamp:Date.now(),enabled:!!o},o),{},{networkPayloadCapture:_({capturePerformance:t.capturePerformance},o?.networkPayloadCapture),canvasRecording:{enabled:o?.recordCanvas,fps:o?.canvasFps,quality:o?.canvasQuality},sampleRate:c,minimumDurationMilliseconds:S(u)?null:u,endpoint:o?.endpoint,triggerMatchType:o?.triggerMatchType,masking:o?.masking,urlTriggers:o?.urlTriggers,version:o?.version,triggerGroups:o?.triggerGroups})})};n(),(e=this.if)===null||e===void 0||e.call(this),this.if=(s=this._instance.sessionManager)===null||s===void 0?void 0:s.onSessionId(n)}}onRemoteConfig(t){let e=t.ok?t.config:void 0;return e&&"sessionRecording"in e?e.sessionRecording===!1?(this.df(e),void this.sf()):(this.df(e),void this.startIfEnabledOrStop()):(this.ef==="awaiting_config"&&(this.ef="missing_config",this._instance.register_for_session({[uc]:!0}),jt.warn("config refresh failed, recording will not start until page reload")),void this.startIfEnabledOrStop())}log(t,e="log"){var s;!((s=this.tf)===null||s===void 0)&&s.log?this.tf.log(t,e):jt.warn("log called before recorder was ready")}get uf(){var t,e;let s=(t=this._instance)===null||t===void 0||(t=t.persistence)===null||t===void 0?void 0:t.get_property(an);return(s==null||(e=s.scriptConfig)===null||e===void 0?void 0:e.script)||"lazy-recorder"}vf(){let t=this._instance.get_property(an);if(!t)return!1;let e;try{e=typeof t=="object"?t:JSON.parse(t)}catch(s){return jt.warn("persisted remote config for session recording is invalid and will be ignored",s),!1}return!B(e.cache_timestamp)&&36e5>=Date.now()-e.cache_timestamp}lf(t){var e,s,i;if(!this.nf&&this.rf&&this._instance.sessionManager){if(!(!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.initSessionRecording))return jt.warn("Called on script loaded before session recording is available. This can be caused by adblockers."),void this._instance.register_for_session({[cc]:!0});var n;if(this.tf||(this.tf=(n=L.__PosthogExtensions__)===null||n===void 0?void 0:n.initSessionRecording(this._instance,this.Je),this.tf._forceAllowLocalhostNetworkCapture=this._forceAllowLocalhostNetworkCapture),!this.vf())return this.ef==="missing_config"||this.ef==="awaiting_config"?void 0:(this.ef="awaiting_config",jt.info("persisted remote config is stale, requesting fresh config before starting"),void new iv(this._instance).load());this.ef=Bf,(s=(i=this.tf).setDocumentWasEverVisible)===null||s===void 0||s.call(i,this.Je),this.tf.start(t)}else this.ef=gl}onRRwebEmit(t){var e,s;(e=this.tf)===null||e===void 0||(s=e.onRRwebEmit)===null||s===void 0||s.call(e,t)}overrideLinkedFlag(){var t,e;this.tf||(e=this.Il)===null||e===void 0||e.register({$replay_override_linked_flag:!0}),(t=this.tf)===null||t===void 0||t.overrideLinkedFlag()}overrideSampling(){var t,e;this.tf||(e=this.Il)===null||e===void 0||e.register({$replay_override_sampling:!0}),(t=this.tf)===null||t===void 0||t.overrideSampling()}overrideTrigger(t){var e,s;this.tf||(s=this.Il)===null||s===void 0||s.register({[t==="url"?"$replay_override_url_trigger":"$replay_override_event_trigger"]:!0}),(e=this.tf)===null||e===void 0||e.overrideTrigger(t)}get sdkDebugProperties(){var t;let e={};for(let i of aT){var s;let n=(s=this._instance.sessionPersistence)===null||s===void 0?void 0:s.get_property(i);S(n)||(e[i]=n)}return _(_({},e),((t=this.tf)===null||t===void 0?void 0:t.sdkDebugProperties)||{$recording_status:this.status})}tryAddCustomEvent(t,e){var s;return!!(!((s=this.tf)===null||s===void 0)&&s.tryAddCustomEvent(t,e))}flushBeforeIdentityReset(){var t,e;(t=this.tf)===null||t===void 0||(e=t.flushBeforeIdentityReset)===null||e===void 0||e.call(t)}}},DT={autocapture:class extends sT{constructor(t){super(new iT(t)),this.instance=t}},historyAutocapture:class{constructor(t){this.ff=!1,this._instance=t,this.pf=this.gf()}initialize(){this.startIfEnabled()}get isEnabled(){let t=this.mf();return!!(t.path||t.search||this.yf(t))}startIfEnabled(){this.isEnabled&&(R.info("History API monitoring enabled, starting..."),this.monitorHistoryChanges())}startIfEnabledOrStop(){this.stop(),this.pf=this.gf(),this.startIfEnabled()}stop(){this.bf&&this.bf(),this.bf=void 0,this._f&&this._f(),this._f=void 0,R.info("History API monitoring stopped")}monitorHistoryChanges(){E&&E.history&&(this.wf("pushState"),this.wf("replaceState"),this.kf(),this.yf()&&this.Sf())}wf(t){var e;if(!E||!((e=E.history[t])===null||e===void 0)&&e.__posthog_wrapped__)return;let s=this;yi(E.history,t,i=>function(n,r,o){var a;s.xf(o)&&s.$f(),i.call(this,n,r,o),s.Cf(t,!s.ff&&(E==null||(a=E.event)===null||a===void 0?void 0:a.type)!=="popstate")})}gf(){let t=E?.location;if(t?.pathname)return{pathname:t.pathname,search:t.search,hash:t.hash}}mf(){let t=this._instance.config.capture_pageview;return t==="history_change"?{path:!0}:G(t)?t:{}}yf(t=this.mf()){return!!t.hash&&!this._instance.config.disable_capture_url_hashes}Tf(t){let e=this.mf(),s=this.pf;return!(!s||!(e.path&&t.pathname!==s.pathname||e.search&&t.search!==s.search||this.yf(e)&&t.hash!==s.hash))}Cf(t,e=!1){try{e||this.$f();let s=this.gf();if(!s)return;if(this.Tf(s)){let i=()=>this._instance.capture(hc,{navigation_type:t});e?(this.If=i,Promise.resolve().then(()=>this.$f())):i()}this.pf=s}catch(s){R.error(`Error capturing ${t} pageview`,s)}}xf(t){var e,s;return!(B(t)||!E)&&((e=Kt(String(t)))===null||e===void 0?void 0:e.href)!==((s=E.location)===null||s===void 0?void 0:s.href)}$f(){let t=this.If;if(t){this.If=void 0,this.ff=!0;try{t()}catch(e){R.error("Error capturing deferred pageview",e)}finally{this.ff=!1}this.pf=this.gf()}}kf(){if(this.bf)return;let t=()=>{this.Cf("popstate")};se(E,"popstate",t),this.bf=()=>{E&&E.removeEventListener("popstate",t)}}Sf(){if(this._f)return;let t=()=>{this.Cf("hashchange")};se(E,"hashchange",t),this._f=()=>{E&&E.removeEventListener("hashchange",t)}}},heatmaps:class{get Mr(){return this.instance.config}constructor(t){var e;this.Mf=!1,this.ko=!1,this.Ef=null,this.instance=t,this.Mf=!!(!((e=this.instance.persistence)===null||e===void 0)&&e.props[xl]),this.rageclicks=new Ov(t.config.rageclick)}initialize(){this.startIfEnabled()}get flushIntervalMilliseconds(){let t=5e3;return G(this.Mr.capture_heatmaps)&&this.Mr.capture_heatmaps.flush_interval_milliseconds&&(t=this.Mr.capture_heatmaps.flush_interval_milliseconds),t}get isEnabled(){return B(this.Mr.capture_heatmaps)?B(this.Mr.enable_heatmaps)?this.Mf:this.Mr.enable_heatmaps:this.Mr.capture_heatmaps!==!1}startIfEnabled(){if(this.isEnabled){if(this.ko)return;lT.info("starting..."),this.Pf(),this.sn()}else{var t;clearInterval((t=this.Ef)!==null&&t!==void 0?t:void 0),this.Rf(),this.getAndClearBuffer()}}onRemoteConfig(t){if(!t.ok)return;let e=t.config;if(!("heatmaps"in e))return;let s=!!e.heatmaps;this.instance.persistence&&this.instance.persistence.register({[xl]:s}),this.Mf=s,this.startIfEnabled()}getAndClearBuffer(){let t=this.Rt;return this.Rt=void 0,t}Af(t){pl(t.originalEvent)&&this.Ir(t.originalEvent,"deadclick")}sn(){this.Ef&&clearInterval(this.Ef),this.Ef=T?.visibilityState==="visible"?setInterval(this.fl.bind(this),this.flushIntervalMilliseconds):null}Pf(){E&&T&&(this.Ff=this.fl.bind(this),se(E,Xr,this.Ff),this.Of=t=>this.Ir(t||E?.event),se(T,"click",this.Of,{capture:!0}),this.Df=t=>this.Lf(t||E?.event),se(T,"mousemove",this.Df,{capture:!0}),this.Nf=new pf(this.instance,lA,this.Af.bind(this)),this.Nf.startIfEnabledOrStop(),this.qf=this.sn.bind(this),se(T,_n,this.qf),this.ko=!0)}Rf(){var t;E&&T&&(this.Ff&&E.removeEventListener(Xr,this.Ff),this.Of&&T.removeEventListener("click",this.Of,{capture:!0}),this.Df&&T.removeEventListener("mousemove",this.Df,{capture:!0}),this.qf&&T.removeEventListener(_n,this.qf),clearTimeout(this.jf),(t=this.Nf)===null||t===void 0||t.stop(),this.ko=!1)}Bf(t,e){let s=this.instance.scrollManager.scrollY(),i=this.instance.scrollManager.scrollX(),n=this.instance.scrollManager.scrollElement(),r=(function(o,a,l){let c=o;for(;c&&Et(c)&&!Ue(c,"body");){if(c===l)return!1;let g;try{var u,h,d;g=(u=(h=(d=c.ownerDocument)===null||d===void 0?void 0:d.defaultView)!==null&&h!==void 0?h:E)===null||u===void 0?void 0:u.getComputedStyle(c).position}catch{return!1}if(M(a,g))return!0;c=Lp(c)}return!1})(cn(t),["fixed","sticky"],n);return{x:t.clientX+(r?0:i),y:t.clientY+(r?0:s),target_fixed:r,type:e}}Ir(t,e="click"){var s;if(nf(t.target)||!pl(t))return;let i=this.Bf(t,e);!((s=this.rageclicks)===null||s===void 0)&&s.isRageClick(t.clientX,t.clientY,new Date().getTime())&&Bp(cn(t),this.instance.config.rageclick)&&this.Qs(_(_({},i),{},{type:"rageclick"})),this.Qs(i)}Lf(t){!nf(t.target)&&pl(t)&&(clearTimeout(this.jf),this.jf=setTimeout(()=>{this.Qs(this.Bf(t,"mousemove"))},500))}Qs(t){if(!E)return;let e=this.Mr.disable_capture_url_hashes?ds(E.location.href):E.location.href,s=this.Mr.custom_personal_data_properties,i=this.Mr.mask_personal_data_properties?[..._i,...s||[]]:[],n=yn(e,i,bn);this.Rt=this.Rt||{},this.Rt[n]||(this.Rt[n]=[]),this.Rt[n].push(t)}fl(){this.Rt&&!nt(this.Rt)&&this.instance.capture("$$heatmap",{$heatmap_data:this.getAndClearBuffer()})}},deadClicksAutocapture:pf,webVitalsAutocapture:class{constructor(t){var e;this._instance=t,this.Mf=!1,this.ko=!1,this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},this.zf=()=>{clearTimeout(this.Hf),this.Hf=void 0,this.Rt.metrics.length!==0&&(this._instance.capture("$web_vitals",_({$current_url:this.Rt.url},this.Rt.metrics.reduce((s,i)=>_(_({},s),{},{[`$web_vitals_${i.name}_event`]:_({},i),[`$web_vitals_${i.name}_value`]:i.value}),{}))),this.Rt={navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0})},this.Uf=s=>{var i;if(this.Rt=this.Rt||{navigationKey:void 0,url:void 0,metrics:[],firstMetricTimestamp:void 0},B(s?.name)||B(s?.value))return void Rs.error("Invalid metric received",s);let n=typeof s.navigationURL=="string"?s.navigationURL:void 0,r=this.Wf(n);if(S(r))return;let o=Te(s.navigationId)||typeof s.navigationId=="string"?`navigation:${s.navigationId}`:`url:${r}`;if(this.Vf&&s.value>=this.Vf)return void Rs.error("Ignoring metric with value >= "+this.Vf,s);this.Rt.navigationKey!==o&&(this.zf(),this.Hf=setTimeout(this.zf,this.flushToCaptureTimeoutMs)),S(this.Rt.navigationKey)&&(this.Rt.navigationKey=o,this.Rt.url=r),this.Rt.firstMetricTimestamp=S(this.Rt.firstMetricTimestamp)?Date.now():this.Rt.firstMetricTimestamp;let a=(i=this._instance.sessionManager)===null||i===void 0?void 0:i.checkAndGetSessionAndWindowId(!0),l=_(_(_({},s),n?{navigationURL:r}:{}),{},{$current_url:r,timestamp:Date.now()});if(delete l.entries,G(s.attribution)&&this.attributionMetrics.indexOf(s.name)>-1){let c={};for(let u of oT){let h=u==="url"&&typeof s.attribution[u]=="string"?this.Wf(s.attribution[u]):s.attribution[u];S(h)||(c[u]=h)}l.attribution=c}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.zf()},this.Gf=()=>{if(this.ko)return;let s,i,n,r,o=!1,a=L.__PosthogExtensions__,l=a?.postHogWebVitalsCallbacksByFlavor,c=l?.[this.Qf]||(this.Qf==="web-vitals"&&S(l)?a?.postHogWebVitalsCallbacks:void 0);if(!S(c)){let d=c.withoutAttribution,g=this.attributionMetrics;o=!S(d),s=g.indexOf("LCP")>-1?c.onLCP:d?.onLCP||c.onLCP,i=g.indexOf("CLS")>-1?c.onCLS:d?.onCLS||c.onCLS,n=g.indexOf("FCP")>-1?c.onFCP:d?.onFCP||c.onFCP,r=g.indexOf("INP")>-1?c.onINP:d?.onINP||c.onINP}if(!(s&&i&&n&&r))return void Rs.error("web vitals callbacks not loaded - not starting");let u={reportSoftNavs:this.useSoftNavs},h=o&&this.attributionMetrics.indexOf("INP")>-1?_(_({},u),{},{includeProcessedEventEntries:!1}):u;this.allowedMetrics.indexOf("LCP")>-1&&s(this.Uf.bind(this),u),this.allowedMetrics.indexOf("CLS")>-1&&i(this.Uf.bind(this),u),this.allowedMetrics.indexOf("FCP")>-1&&n(this.Uf.bind(this),u),this.allowedMetrics.indexOf("INP")>-1&&r(this.Uf.bind(this),h),this.ko=!0},this.Mf=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[Ml]),this.startIfEnabled()}get Zf(){return this._instance.config.capture_performance}get allowedMetrics(){var t,e;let s=G(this.Zf)?(t=this.Zf)===null||t===void 0?void 0:t.web_vitals_allowed_metrics:void 0;return B(s)?((e=this._instance.persistence)===null||e===void 0?void 0:e.props.$web_vitals_allowed_metrics)||Uf:s}get flushToCaptureTimeoutMs(){return(G(this.Zf)?this.Zf.web_vitals_delayed_flush_ms:void 0)||5e3}get attributionMetrics(){let t=G(this.Zf)?this.Zf.web_vitals_attribution:void 0;return Je(t)?t?Uf:[]:N(t)?t:rT}get useAttribution(){return this.attributionMetrics.length>0}get useSoftNavs(){let t=G(this.Zf)?this.Zf.__preview_web_vitals_soft_navs:void 0;return t!=null&&t}get Vf(){let t=G(this.Zf)&&Te(this.Zf.__web_vitals_max_value)?this.Zf.__web_vitals_max_value:Lf;return t>0&&6e4>=t?Lf:t}get isEnabled(){let t=pe?.protocol;if(t!=="http:"&&t!=="https:")return Rs.info("Web Vitals are disabled on non-http/https protocols"),!1;let e=G(this.Zf)?this.Zf.web_vitals:Je(this.Zf)?this.Zf:void 0;return Je(e)?e:this.Mf}startIfEnabled(){this.isEnabled&&!this.ko&&(Rs.info("enabled, starting..."),this.zo(this.Gf))}onRemoteConfig(t){if(!t.ok)return;let e=t.config;if(!("capturePerformance"in e))return;let s=G(e.capturePerformance)&&!!e.capturePerformance.web_vitals,i=G(e.capturePerformance)?e.capturePerformance.web_vitals_allowed_metrics:void 0;this._instance.persistence&&(this._instance.persistence.register({[Ml]:s}),this._instance.persistence.register({[hp]:i})),this.Mf=s,this.startIfEnabled()}get Qf(){return this.useSoftNavs?this.useAttribution?"web-vitals-with-attribution-soft-navs":"web-vitals-soft-navs":this.useAttribution?"web-vitals-with-attribution":"web-vitals"}zo(t){var e;let s=L.__PosthogExtensions__,i=this.Qf,n=s?.postHogWebVitalsCallbacksByFlavor;n?.[i]||i==="web-vitals"&&S(n)&&s?.postHogWebVitalsCallbacks?t():s==null||(e=s.loadExternalDependency)===null||e===void 0||e.call(s,this._instance,i,r=>{r?Rs.error("failed to load script",r):t()})}Wf(t){let e=t||E?.location.href;if(!e)return void Rs.error("Could not determine current URL");let s=this._instance.config.disable_capture_url_hashes?ds(e):e,i=this._instance.config.custom_personal_data_properties,n=this._instance.config.mask_personal_data_properties?[..._i,...i||[]]:[];return yn(s,n,bn)}}},NT={exceptionObserver:class{constructor(t){var e;this.Gf=()=>{var s;if(!E||!this.isEnabled||!(!((s=L.__PosthogExtensions__)===null||s===void 0)&&s.errorWrappingFunctions))return;let i=L.__PosthogExtensions__.errorWrappingFunctions.wrapOnError,n=L.__PosthogExtensions__.errorWrappingFunctions.wrapUnhandledRejection,r=L.__PosthogExtensions__.errorWrappingFunctions.wrapConsoleError;try{!this.Jf&&this.Mr.capture_unhandled_errors&&(this.Jf=i(this.captureException.bind(this))),!this.Kf&&this.Mr.capture_unhandled_rejections&&(this.Kf=n(this.captureException.bind(this))),!this.Xf&&this.Mr.capture_console_errors&&(this.Xf=r(this.captureException.bind(this)))}catch(o){Xi.error("failed to start",o),this.Yf()}},this._instance=t,this.tp=!!(!((e=this._instance.persistence)===null||e===void 0)&&e.props[Dl]),this.wt=new eS(_(_({},(function(s={}){var i,n,r,o;return{refillRate:(i=(n=s.exceptionRateLimiterRefillRate)!==null&&n!==void 0?n:s.__exceptionRateLimiterRefillRate)!==null&&i!==void 0?i:1,bucketSize:(r=(o=s.exceptionRateLimiterBucketSize)!==null&&o!==void 0?o:s.__exceptionRateLimiterBucketSize)!==null&&r!==void 0?r:10}})(this._instance.config.error_tracking)),{},{refillInterval:1e4,A:Xi})),this.Mr=this.ep(),this.startIfEnabledOrStop()}ep(){let t=this._instance.config.capture_exceptions,e={capture_unhandled_errors:!1,capture_unhandled_rejections:!1,capture_console_errors:!1};return G(t)?e=_(_({},e),t):(S(t)?this.tp:t)&&(e=_(_({},e),{},{capture_unhandled_errors:!0,capture_unhandled_rejections:!0})),e}get isEnabled(){return this.Mr.capture_console_errors||this.Mr.capture_unhandled_errors||this.Mr.capture_unhandled_rejections}startIfEnabledOrStop(){this.isEnabled?(Xi.info("enabled"),this.Yf(),this.zo(this.Gf)):this.Yf()}zo(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.errorWrappingFunctions?t():(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"exception-autocapture",n=>{if(n)return Xi.error("failed to load script",n);t()})}Yf(){var t,e,s;(t=this.Jf)===null||t===void 0||t.call(this),this.Jf=void 0,(e=this.Kf)===null||e===void 0||e.call(this),this.Kf=void 0,(s=this.Xf)===null||s===void 0||s.call(this),this.Xf=void 0}onRemoteConfig(t){if(!t.ok)return;let e=t.config;"autocaptureExceptions"in e&&(this.tp=!!e.autocaptureExceptions||!1,this._instance.persistence&&this._instance.persistence.register({[Dl]:this.tp}),this.Mr=this.ep(),this.startIfEnabledOrStop())}onConfigChange(){this.Mr=this.ep()}captureException(t){try{var e,s,i;let n=(e=t==null||(s=t.$exception_list)===null||s===void 0||(s=s[0])===null||s===void 0?void 0:s.type)!==null&&e!==void 0?e:"Exception";if(this.wt.consumeRateLimit(n))return void Xi.info("Skipping exception capture because of client rate limiting.",{exception:n});(i=this._instance.exceptions)===null||i===void 0||i.sendExceptionEvent(t)}catch{}}},exceptions:class{constructor(t){var e,s;this.np=[],this.sp=new hS([new IS,new MS,new CS,new RS,new DS,new xS,new PS,new NS],(function(i,...n){return(r,o=0)=>{let a=[],l=r.split(`
|
|
7
|
+
`),c=Math.min(l.length,o+1e3),u=[];for(let g=o;c>g;g++){let p=l[g];if(p.length>1024)continue;let m=Fh.test(p)?p.replace(Fh,"$1"):p;if(!m.match(/\S*Error: /)){for(let v of n){let b=v(m,i);if(b){a.push(b);let y=SS(a);if(y){for(let w=u.length-1;w>=0;w--){let A=u[w];if(y.start>=A.start+A.length)break;u.pop()}u.push(y)}break}}if(AS(a,u)>=50)break}}let h=[...u].sort((g,p)=>p.start-g.start),d=h[h.length-1];if(d){let g=Hg(a,d);a.splice(d.start-g,g);for(let p of h)p.start-=g}for(let g of h)kS(a,g);return u.some(g=>g.start===0&&a.length===g.length)&&(function(g){let p=g.map(v=>`${v.function}|${v.filename}|${v.lineno}|${v.colno}|${v.module}`),m=0;for(let v=1;p.length>v;v++)TS(p,v,m)&&(m=v);g.push(...g.splice(0,m))})(a),(function(g){if(!g.length)return[];let p=Array.from(g);return p.reverse(),p.slice(0,50).map(m=>{return _(_({},m),{},{filename:m.filename||(v=p,v[v.length-1]||{}).filename,function:m.function||"?"});var v})})(a)}})("web:javascript",yS,wS)),this._instance=t,this.np=(e=(s=this._instance.persistence)===null||s===void 0?void 0:s.get_property("$error_tracking_suppression_rules"))!==null&&e!==void 0?e:[],this.rp=qr(this.op()),this.ap=new LS(this.rp)}onConfigChange(){this.rp=qr(this.op()),this.ap.setConfig(this.rp)}onRemoteConfig(t){var e,s,i;if(!t.ok)return;let n=t.config;if(!("errorTracking"in n))return;let r=(e=(s=n.errorTracking)===null||s===void 0?void 0:s.suppressionRules)!==null&&e!==void 0?e:[],o=(i=n.errorTracking)===null||i===void 0?void 0:i.captureExtensionExceptions;this.np=r,this._instance.persistence&&this._instance.persistence.register({[up]:this.np,[Nl]:o})}get lp(){var t;let e=!!this._instance.get_property(Nl),s=this._instance.config.error_tracking.captureExtensionExceptions;return(t=s??e)!==null&&t!==void 0&&t}buildProperties(t,e){return this.sp.buildFromUnknown(t,{syntheticException:e?.syntheticException,mechanism:{handled:e?.handled}})}addExceptionStep(t,e){if(this.rp.enabled)try{if(!H(t)||t.trim().length===0)return void _t.warn("Ignoring exception step because message must be a non-empty string");let{sanitizedProperties:s,droppedKeys:i}=(function(n){if(!n)return{sanitizedProperties:{},droppedKeys:[]};let r=[];return{sanitizedProperties:Object.keys(n).reduce((o,a)=>FS.has(a)?(r.push(a),o):(o[a]=n[a],o),{}),droppedKeys:r}})(this.up(e));i.length>0&&_t.warn("Ignoring reserved exception step fields",{droppedKeys:i}),this.ap.add(_({[Hr]:t,[zr]:new Date().toISOString()},s))}catch(s){_t.error("Failed to add exception step. Ignoring breadcrumb.",s)}}sendExceptionEvent(t){try{let e=t.$exception_list;if(this.cp(e)){if(this.hp(e))return this.dp("Exception dropped: matched a suppression rule"),void _t.info("Skipping exception capture because a suppression rule matched");if(!this.lp&&this.vp(e))return this.dp("Exception dropped: thrown by a browser extension"),void _t.info("Skipping exception capture because it was thrown by an extension");if(!this.lp&&this.fp(e))return this.dp("Exception dropped: thrown by an injected browser script"),void _t.info("Skipping exception capture because it was thrown by an injected browser script");if(!this._instance.config.error_tracking.__capturePostHogExceptions&&this.pp(e))return this.dp("Exception dropped: thrown by the PostHog SDK"),void _t.info("Skipping exception capture because it was thrown by the PostHog SDK")}let s=this.rp.enabled&&B(t.$exception_steps)?this.gp(t):t,i=(function(){if("u">typeof process){var n;let o=(n=process.env.POSTHOG_RELEASE_ID)===null||n===void 0?void 0:n.trim();if(o)return o}let r=globalThis._posthogReleaseId;return typeof r=="string"&&r.length>0?r:void 0})();i&&(s.$release_id=i);try{let n=this._instance.capture("$exception",s,{_noTruncate:!0,_batchKey:"exceptionEvent",hc:!0});return n&&this.ap.clear(),n}catch(n){return Jf(n)||_t.error("Failed to capture exception event. Dropping this exception.",n),void this.ap.clear()}}catch(e){return void(Jf(e)||_t.error("Failed to process exception event. Ignoring this exception.",e))}}gp(t){try{let e=this.ap.getAttachable();return e.length===0?t:_(_({},t),{},{$exception_steps:e})}catch(e){return _t.error("Failed to read buffered exception steps. Capturing exception without steps.",e),t}}dp(t){this.rp.enabled&&this.ap.add({[Hr]:t,[zr]:new Date().toISOString()})}up(t){return G(t)?_({},t):{}}op(){var t,e;return(t=(e=this._instance.config.error_tracking)===null||e===void 0?void 0:e.exception_steps)!==null&&t!==void 0?t:{}}hp(t){if(t.length===0)return!1;try{let e=t.reduce((s,{type:i,value:n})=>(H(i)&&i.length>0&&s.$exception_types.push(i),H(n)&&n.length>0&&s.$exception_values.push(n),s),{$exception_types:[],$exception_values:[]});return this.np.some(s=>{let i=s.values.map(n=>{let r=wv[n.operator],o=e[n.key];if(!r||!o)return!1;let a=N(n.value)?n.value:[n.value];return a.length>0&&r(a,o)});return s.type==="OR"?i.some(Boolean):i.every(Boolean)})}catch(e){return _t.warn("Failed to evaluate suppression rules. Capturing the exception.",e),!1}}vp(t){let e=t.flatMap(i=>{var n,r;return(n=(r=i.stacktrace)===null||r===void 0?void 0:r.frames)!==null&&n!==void 0?n:[]}),s=e.filter(({filename:i})=>!!i&&ET.some(n=>i.startsWith(n)));return s.length!==0&&(!s.every(({filename:i})=>!!i&&i.startsWith(Ql))||t.some(({type:i,value:n})=>i==="NoResponse"||H(n)&&bT.some(({value:r,exact:o})=>o?n===r:n.includes(r)))&&!e.some(({in_app:i,filename:n})=>i&&!n?.startsWith(Ql)))}fp(t){return t.some(({value:e})=>H(e)&&wT.some(s=>e.includes(s)))}pp(t){if(t.length>0){var e,s,i,n;let r=(e=(s=t[0].stacktrace)===null||s===void 0?void 0:s.frames)!==null&&e!==void 0?e:[],o=r[r.length-1];return(i=o==null||(n=o.filename)===null||n===void 0?void 0:n.includes("posthog.com/static"))!==null&&i!==void 0&&i}return!1}cp(t){return!B(t)&&N(t)}}},MT=_({productTours:class{get Il(){return this._instance.persistence}constructor(t){this.mp=null,this.yp=null,this._instance=t}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(!t.ok)return;let e=t.config;if("productTours"in e){var s,i;if(this.Il&&this.Il.register({[ac]:!!e.productTours}),!vl(this._instance))return!this.mp&&B((s=this.Il)===null||s===void 0?void 0:s.props.ph_product_tours)||Pr.info("product tours disabled; stopping and clearing cached tours"),(i=this.mp)===null||i===void 0||i.stop(),this.mp=null,void this.clearCache();this.loadIfEnabled()}}loadIfEnabled(){!this.mp&&vl(this._instance)&&this.zo(()=>this.bp())}zo(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.generateProductTours?t():(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"product-tours",n=>{n?Pr.error("Could not load product tours script",n):t()})}bp(){var t;!this.mp&&(!((t=L.__PosthogExtensions__)===null||t===void 0)&&t.generateProductTours)&&(this.mp=L.__PosthogExtensions__.generateProductTours(this._instance,!0))}getProductTours(t,e=!1){if(N(this.yp)&&!e)return void t(this.yp,{isLoaded:!0});let s=this.Il;if(s){let i=s.props[Fl];if(N(i)&&!e)return this.yp=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:i=>{if(!vl(this._instance))return void t([],{isLoaded:!0});let n=i.statusCode;if(n!==200||!i.json){let o=`Product Tours API could not be loaded, status: ${n}`;return n===0?i.error||Pr.warn(o):Pr.error(o),void t([],{isLoaded:!1,error:o})}let r=N(i.json.product_tours)?i.json.product_tours:[];this.yp=r,s&&s.register({[Fl]:r}),t(r,{isLoaded:!0})}})}getActiveProductTours(t){B(this.mp)?t([],{isLoaded:!1,error:"Product tours not loaded"}):this.mp.getActiveProductTours(t)}showProductTour(t){var e;(e=this.mp)===null||e===void 0||e.showTourById(t)}previewTour(t){this.mp?this.mp.previewTour(t):this.zo(()=>{var e;this.bp(),(e=this.mp)===null||e===void 0||e.previewTour(t)})}dismissProductTour(){var t;(t=this.mp)===null||t===void 0||t.dismissTour("user_clicked_skip")}nextStep(){var t;(t=this.mp)===null||t===void 0||t.nextStep()}previousStep(){var t;(t=this.mp)===null||t===void 0||t.previousStep()}clearCache(){var t;this.yp=null,(t=this.Il)===null||t===void 0||t.unregister("ph_product_tours")}resetTour(t){var e;(e=this.mp)===null||e===void 0||e.resetTour(t)}resetAllTours(){var t;(t=this.mp)===null||t===void 0||t.resetAllTours()}cancelPendingTour(t){var e;(e=this.mp)===null||e===void 0||e.cancelPendingTour(t)}}},uo),FT={siteApps:class{constructor(t){this._instance=t,this._p=0,this.wp=[],this.apps={}}get isEnabled(){return!!this._instance.config.opt_in_site_apps}kp(t,e){if(!e)return;let s=this.globalsForEvent(e);this.wp.push(s),this.wp.length>1e3&&(this.wp=this.wp.slice(10))}get siteAppLoaders(){var t;return(t=L._POSTHOG_REMOTE_CONFIG)===null||t===void 0||(t=t[this._instance.config.token])===null||t===void 0?void 0:t.siteApps}initialize(){if(this.isEnabled){let t=this._instance._addCaptureHook(this.kp.bind(this));this.Sp=()=>{t(),this.wp=[],this.Sp=void 0}}}globalsForEvent(t){var e,s,i,n,r,o,a;if(!t)throw new Error("Event payload is required");let l={},c=this._instance.get_property("$groups")||[],u=this._instance.get_property("$stored_group_properties")||{};for(let[g,p]of Object.entries(u))l[g]={id:c[g],type:g,properties:p};let{$set_once:h,$set:d}=t;return{event:_(_({},Kg(t,cT)),{},{properties:_(_(_({},t.properties),d?{$set:_(_({},(e=(s=t.properties)===null||s===void 0?void 0:s.$set)!==null&&e!==void 0?e:{}),d)}:{}),h?{$set_once:_(_({},(i=(n=t.properties)===null||n===void 0?void 0:n.$set_once)!==null&&i!==void 0?i:{}),h)}:{}),elements_chain:(r=(o=t.properties)===null||o===void 0?void 0:o.$elements_chain)!==null&&r!==void 0?r:"",distinct_id:(a=t.properties)===null||a===void 0?void 0:a.distinct_id}),person:{properties:this._instance.get_property("$stored_person_properties")},groups:l}}xp(t){var e;let s=(e=t.tagName)===null||e===void 0?void 0:e.toLowerCase();return s==="style"&&this._instance.config.prepare_external_dependency_stylesheet?this._instance.config.prepare_external_dependency_stylesheet(t)||(At.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)||(At.error("prepare_external_dependency_script returned null"),null):t}$p(){var t,e,s,i,n,r,o,a;if(!this._instance.config.prepare_external_dependency_stylesheet&&!this._instance.config.prepare_external_dependency_script)return()=>{};let l=T?.defaultView,c=l==null||(t=l.Node)===null||t===void 0?void 0:t.prototype;if(!l||!c)return()=>{};if(this._p++,this.Cp)return this.Tp();let u=[],h=this,d=new WeakSet,g=(v,b,y)=>{if(!v?.[b])return;let w=v[b];v[b]=y(w),u.push(()=>{v[b]=w})},p=v=>{if(d.has(v))return v;let b=h.xp(v);return b&&d.add(b),b},m=v=>v.map(b=>typeof b=="string"?b:p(b)).filter(b=>!we(b));return g(c,"appendChild",v=>function(b){let y=p(b);return y?v.call(this,y):b}),g(c,"insertBefore",v=>function(b,y){let w=p(b);return w?v.call(this,w,y):b}),g(c,"replaceChild",v=>function(b,y){let w=p(b);return w?v.call(this,w,y):y}),[(e=l.Element)===null||e===void 0?void 0:e.prototype,(s=l.Document)===null||s===void 0?void 0:s.prototype,(i=l.DocumentFragment)===null||i===void 0?void 0:i.prototype].forEach(v=>{g(v,"append",b=>function(...y){return b.apply(this,m(y))}),g(v,"prepend",b=>function(...y){return b.apply(this,m(y))})}),[(n=l.Element)===null||n===void 0?void 0:n.prototype,(r=l.CharacterData)===null||r===void 0?void 0:r.prototype,(o=l.DocumentType)===null||o===void 0?void 0:o.prototype].forEach(v=>{g(v,"before",b=>function(...y){return b.apply(this,m(y))}),g(v,"after",b=>function(...y){return b.apply(this,m(y))}),g(v,"replaceWith",b=>function(...y){let w=m(y);return y.length&&!w.length?void 0:b.apply(this,w)})}),g((a=l.Element)===null||a===void 0?void 0:a.prototype,"insertAdjacentElement",v=>function(b,y){let w=p(y);return w?v.call(this,b,w):null}),this.Cp=()=>{u.forEach(v=>v()),this.Cp=void 0},this.Tp()}Tp(){let t=!1;return()=>{var e;t||(t=!0,this._p--,this._p===0&&((e=this.Cp)===null||e===void 0||e.call(this)))}}Ip(t,e=!0){let s=this.$p();try{let i=t(s);return e&&s(),i}catch(i){throw s(),i}}setupSiteApp(t){let e=this.apps[t.id],s=()=>{var r;!e.errored&&this.wp.length&&(At.info(`Processing ${this.wp.length} events for site app with id ${t.id}`),this.wp.forEach(o=>this.Ip(()=>{var a;return(a=e.processEvent)===null||a===void 0?void 0:a.call(e,o)})),e.processedBuffer=!0),Object.values(this.apps).every(o=>o.processedBuffer||o.errored)&&((r=this.Sp)===null||r===void 0||r.call(this))},i=!1,n=r=>{e.errored=!r,e.loaded=!0,At.info(`Site app with id ${t.id} ${r?"loaded":"errored"}`),i&&s()};try{let{processEvent:r}=this.Ip(o=>t.init({posthog:this._instance,callback(a){o(),n(a)}}),!1);r&&(e.processEvent=r),i=!0}catch(r){At.error(Vf+t.id,r),n(!1)}if(i&&e.loaded)try{s()}catch(r){At.error(`Error while processing buffered events PostHog app with config id ${t.id}`,r),e.errored=!0}}Mp(){let t=this.siteAppLoaders||[];for(let e of t)this.apps[e.id]={id:e.id,loaded:!1,errored:!1,processedBuffer:!1};for(let e of t)this.setupSiteApp(e)}Ep(t){if(Object.keys(this.apps).length===0)return;let e=this.globalsForEvent(t);for(let s of Object.values(this.apps))try{this.Ip(()=>{var i;return(i=s.processEvent)===null||i===void 0?void 0:i.call(s,e)})}catch(i){At.error(`Error while processing event ${t.event} for site app ${s.id}`,i)}}onRemoteConfig(t){var e,s,i;if(!((e=this.siteAppLoaders)===null||e===void 0)&&e.length)return this.isEnabled?(this.Mp(),void this._instance.on("eventCaptured",a=>this.Ep(a))):void At.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.');if((s=this.Sp)===null||s===void 0||s.call(this),!t.ok)return;let n=t.config;if(!((i=n.siteApps)===null||i===void 0)&&i.length)if(this.isEnabled)for(let{id:a,url:l}of n.siteApps){var r,o;L[`__$$ph_site_app_${a}`]=this._instance,(r=L.__PosthogExtensions__)===null||r===void 0||(o=r.loadSiteApp)===null||o===void 0||o.call(r,this._instance,l,c=>{if(c)return At.error(Vf+a,c)})}else At.error('PostHog site apps are disabled. Enable the "opt_in_site_apps" config to proceed.')}}},LT={tracingHeaders:class{constructor(t){this._instance=t,this.Pp=void 0,this.Rp=void 0,this.Ap=void 0,this.Gf=()=>{let e=this.Fp();var s,i;e?(S(this.Pp)&&(this.Pp=(s=L.__PosthogExtensions__)===null||s===void 0||(s=s.tracingHeadersPatchFns)===null||s===void 0?void 0:s._patchXHR(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager)),S(this.Rp)&&(this.Rp=(i=L.__PosthogExtensions__)===null||i===void 0||(i=i.tracingHeadersPatchFns)===null||i===void 0?void 0:i._patchFetch(e,()=>this._instance.get_distinct_id(),this._instance.sessionManager))):this.Yf()}}initialize(){this.startIfEnabledOrStop()}zo(t){var e,s,i;!((e=L.__PosthogExtensions__)===null||e===void 0)&&e.tracingHeadersPatchFns?t():(s=L.__PosthogExtensions__)===null||s===void 0||(i=s.loadExternalDependency)===null||i===void 0||i.call(s,this._instance,"tracing-headers",n=>{if(n)return nT.error("failed to load script",n);t()})}Op(){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}Fp(){let t=this.Op();return N(t)?(N(this.Ap)?this.Ap.splice(0,this.Ap.length,...t):this.Ap=[...t],t.length>0?this.Ap:void 0):(N(this.Ap)&&this.Ap.splice(0),this.Ap=t||void 0,this.Ap)}Yf(){var t,e;(t=this.Pp)===null||t===void 0||t.call(this),(e=this.Rp)===null||e===void 0||e.call(this),this.Pp=void 0,this.Rp=void 0}startIfEnabledOrStop(){this.Fp()?this.zo(this.Gf):this.Yf()}}},UT=_({surveys:class extends uT{constructor(t){var e;super(new pT(t),(e=t,{get projectToken(){return e.config.token},kv:new gT(e)})),this._instance=t}Wc(t,e){let s=e.query?wn(t,e.query):t;return new Promise(i=>{var n;this._instance._send_request({method:e.method,url:this._instance.requestRouter.endpointFor((n=e.target)!==null&&n!==void 0?n:"api",s),data:e.body,headers:e.headers,timeout:e.timeoutMs,fireCallbackOnDrop:!0,transport:e.transport,compression:e.compression,timestampMode:e.sentAt,callback:i})})}}},uo),BT={toolbar:class{constructor(t){this.instance=t}Dp(t){L.ph_toolbar_state=t}Lp(){var t;return(t=L.ph_toolbar_state)!==null&&t!==void 0?t:0}initialize(){return this.maybeLoadToolbar()}maybeLoadToolbar(t=void 0,e=void 0,s=void 0){var i,n;if(Ul(this.instance.config)||!E||!T)return!1;t=(i=t)!==null&&i!==void 0?i:E.location,s=(n=s)!==null&&n!==void 0?n:E.history;try{if(!e){try{E.localStorage.setItem("test","test"),E.localStorage.removeItem("test")}catch{return!1}e=E?.localStorage}let r=vT||eo(t.hash,"__posthog")||eo(t.hash,"state"),o,a=r?Ph(()=>JSON.parse(atob(decodeURIComponent(r))))||Ph(()=>JSON.parse(decodeURIComponent(r))):null;return a&&a.action==="ph_authorize"?(o=a,o.source="url",o&&Object.keys(o).length>0&&(a.desiredHash?t.hash=a.desiredHash:s?s.replaceState(s.state,"",t.pathname+t.search):t.hash="")):(o=JSON.parse(e.getItem(Gf)||"{}"),o.source="localstorage",delete o.userIntent),!(!o.token||this.instance.config.token!==o.token||(this.loadToolbar(o),0))}catch{return!1}}Np(t){let e=L.ph_load_toolbar||L.ph_load_editor;!B(e)&&Ce(e)?e(t,this.instance):Hf.warn("No toolbar load function found")}loadToolbar(t){let e=!!T?.getElementById("__POSTHOG_TOOLBAR__");if(!E||e)return!1;let s=this.instance.requestRouter.region==="custom"&&this.instance.config.advanced_disable_toolbar_metrics,i=_(_({token:this.instance.config.token},t),{},{apiURL:this.instance.requestRouter.endpointFor("ui")},s?{instrument:!1}:{});if(E.localStorage.setItem(Gf,JSON.stringify(_(_({},i),{},{source:void 0}))),this.Lp()===2)this.Np(i);else if(this.Lp()===0){var n,r;this.Dp(1),(n=L.__PosthogExtensions__)===null||n===void 0||(r=n.loadExternalDependency)===null||r===void 0||r.call(n,this.instance,"toolbar",o=>{if(o)return Hf.error("[Toolbar] Failed to load",o),void this.Dp(0);this.Dp(2),this.Np(i)}),se(E,"turbolinks:load",()=>{this.Dp(0),this.loadToolbar(i)})}return!0}qp(t){return this.loadToolbar(t)}maybeLoadEditor(t=void 0,e=void 0,s=void 0){return this.maybeLoadToolbar(t,e,s)}}},VT=_({experiments:class Ke{get Mr(){return this._instance.config}constructor(e){this._instance=e,this.getWebExperimentsAndEvaluateDisplayLogic=(s=!1)=>{this.getWebExperiments(i=>{Ke.jp("retrieved web experiments from the server"),this.Bp=new Map,i.forEach(n=>{if(n.feature_flag_key){var r;this.Bp&&(Ke.jp("setting flag key ",n.feature_flag_key," to web experiment ",n),(r=this.Bp)===null||r===void 0||r.set(n.feature_flag_key,n));let o=this._instance.getFeatureFlag(n.feature_flag_key);H(o)&&n.variants[o]&&this.zp(n.name,o,n.variants[o].transforms)}else if(n.variants)for(let o in n.variants){let a=n.variants[o];Ke.Hp(a,this._instance)&&this.zp(n.name,o,a.transforms)}})},s)},this._instance.onFeatureFlags(s=>{this.onFeatureFlags(s)})}initialize(){}onFeatureFlags(e){if(this._is_bot())Ke.jp(Xf);else if(!this.Mr.disable_web_experiments){if(B(this.Bp))return this.Bp=new Map,this.loadIfEnabled(),void this.previewWebExperiment();Ke.jp("applying feature flags",e),e.forEach(s=>{var i;if(this.Bp&&(!((i=this.Bp)===null||i===void 0)&&i.has(s))){var n;let r=this._instance.getFeatureFlag(s),o=(n=this.Bp)===null||n===void 0?void 0:n.get(s);r&&o?.variants[r]&&this.zp(o.name,r,o.variants[r].transforms)}})}}previewWebExperiment(){let e=Ke.getWindowLocation();if(e?.search){let s=vi(e?.search,"__experiment_id"),i=vi(e?.search,"__experiment_variant");s&&i&&(Ke.jp(`previewing web experiments ${s} && ${i}`),this.getWebExperiments(n=>{this.Up(parseInt(s),i,n)},!1,!0))}}loadIfEnabled(){this.Mr.disable_web_experiments||this.getWebExperimentsAndEvaluateDisplayLogic()}getWebExperiments(e,s,i){if(this.Mr.disable_web_experiments&&!i)return e([]);let n=this._instance.get_property("$web_experiments");if(n&&!s)return e(n);this._instance._send_request({url:this._instance.requestRouter.endpointFor("api",`/api/web_experiments/?token=${this.Mr.token}`),method:"GET",timestampMode:"query",callback:r=>e(r.statusCode===200&&r.json&&r.json.experiments||[])})}Up(e,s,i){let n=i.filter(r=>r.id===e);n&&n.length>0&&(Ke.jp(`Previewing web experiment [${n[0].name}] with variant [${s}]`),this.zp(n[0].name,s,n[0].variants[s].transforms))}static Hp(e,s){return!B(e.conditions)&&Ke.Wp(e,s)&&Ke.Vp(e)}static Wp(e,s){var i;if(B(e.conditions)||B((i=e.conditions)===null||i===void 0?void 0:i.url))return!0;let n=Ke.getWindowLocation();if(n){var r,o,a;let l=Np(s,n.href);return!(!((r=e.conditions)===null||r===void 0)&&r.url)||ST[(o=(a=e.conditions)===null||a===void 0?void 0:a.urlMatchType)!==null&&o!==void 0?o:"icontains"](e.conditions.url,l)}return!1}static getWindowLocation(){return E?.location}static Vp(e){var s;if(B(e.conditions)||B((s=e.conditions)===null||s===void 0?void 0:s.utm))return!0;let i=Yp();if(i.utm_source){var n,r,o,a,l,c,u,h;let d=!(!((n=e.conditions)===null||n===void 0||(n=n.utm)===null||n===void 0)&&n.utm_campaign)||((r=e.conditions)===null||r===void 0||(r=r.utm)===null||r===void 0?void 0:r.utm_campaign)==i.utm_campaign,g=!(!((o=e.conditions)===null||o===void 0||(o=o.utm)===null||o===void 0)&&o.utm_source)||((a=e.conditions)===null||a===void 0||(a=a.utm)===null||a===void 0?void 0:a.utm_source)==i.utm_source,p=!(!((l=e.conditions)===null||l===void 0||(l=l.utm)===null||l===void 0)&&l.utm_medium)||((c=e.conditions)===null||c===void 0||(c=c.utm)===null||c===void 0?void 0:c.utm_medium)==i.utm_medium,m=!(!((u=e.conditions)===null||u===void 0||(u=u.utm)===null||u===void 0)&&u.utm_term)||((h=e.conditions)===null||h===void 0||(h=h.utm)===null||h===void 0?void 0:h.utm_term)==i.utm_term;return d&&p&&m&&g}return!1}static jp(e,...s){R.info(`[WebExperiments] ${e}`,s)}zp(e,s,i){this._is_bot()?Ke.jp(Xf):s!=="control"?i.forEach(n=>{if(n.selector){var r;Ke.jp(`applying transform of variant ${s} for experiment ${e} `,n);let o=(r=document)===null||r===void 0?void 0:r.querySelectorAll(n.selector);o?.forEach(a=>{let l=a;n.html&&(l.innerHTML=n.html),n.css&&l.setAttribute("style",n.css)})}}):Ke.jp("Control variants leave the page unmodified.")}_is_bot(){return Le&&this._instance?yv(Le,this.Mr.custom_blocked_useragents):void 0}}},uo),jT={conversations:class{constructor(t){this._instance=t,this.Gp=void 0,this._conversationsManager=null,this.Qp=!1,this.ne=null,this.Zp=!1}initialize(){this.loadIfEnabled()}onRemoteConfig(t){if(this._instance.config.disable_conversations||(this.Jp=t.ok,!t.ok))return;let e=t.config.conversations;B(e)||(Je(e)?this.Gp=e:(this.Gp=e.enabled,this.ne=e),this.loadIfEnabled())}reset(){var t;(t=this._conversationsManager)===null||t===void 0||t.reset(),this._conversationsManager=null,this.Gp=void 0,this.ne=null,this.Jp=void 0,this.Zp=!1}loadIfEnabled(){if(this._conversationsManager||this.Qp||this._instance.config.disable_conversations||Ul(this._instance.config)||this._instance.config.cookieless_mode&&this._instance.consent.isOptedOut())return;let t=L?.__PosthogExtensions__;if(t&&!S(this.Gp)&&this.Gp)if(this.ne&&this.ne.token){this.Qp=!0;try{let e=t.initConversations;if(e)return this.Kp(e),void(this.Qp=!1);let s=t.loadExternalDependency;if(!s)return void this.Xp(dc);s(this._instance,"conversations",i=>{i||!t.initConversations?this.Xp("Could not load conversations script",i):this.Kp(t.initConversations),this.Qp=!1})}catch(e){this.Xp("Error initializing conversations",e),this.Qp=!1}}else gt.error("Conversations enabled but missing token in remote config.")}Kp(t){if(this.ne)try{this._conversationsManager=t(this.ne,this._instance),this.Zp=!1,gt.info("Conversations loaded successfully")}catch(e){this.Xp("Error completing conversations initialization",e)}else gt.error("Cannot complete initialization: remote config is null")}Xp(t,e){gt.error(t,e),this._conversationsManager=null,this.Qp=!1,this.Zp=!0}show(){this._conversationsManager?this._conversationsManager.show():gt.warn("Conversations not loaded yet.")}hide(){this._conversationsManager&&this._conversationsManager.hide()}isAvailable(){return this.Gp===!0&&!we(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.Jp===!1?"remote_config_failed":S(this.Gp)?this.Jp?"disabled_in_project":"remote_config_pending":this.Gp?B(this.ne)||!this.ne.token?"missing_token":L?.__PosthogExtensions__?this.Qp?"initializing":this.Zp?"load_failed":"not_loaded":"extensions_unavailable":"disabled_in_project"}isVisible(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.isVisible())!==null&&t!==void 0&&t}sendMessage(t,e,s){var i=this;return he(function*(){return i._conversationsManager?i._conversationsManager.sendMessage(t,e,s):(gt.warn(Os),null)})()}getMessages(t,e){var s=this;return he(function*(){return s._conversationsManager?s._conversationsManager.getMessages(t,e):(gt.warn(Os),null)})()}markAsRead(t){var e=this;return he(function*(){return e._conversationsManager?e._conversationsManager.markAsRead(t):(gt.warn(Os),null)})()}getTickets(t){var e=this;return he(function*(){return e._conversationsManager?e._conversationsManager.getTickets(t):(gt.warn(Os),null)})()}requestRestoreLink(t){var e=this;return he(function*(){return e._conversationsManager?e._conversationsManager.requestRestoreLink(t):(gt.warn(Os),null)})()}restoreFromToken(t){var e=this;return he(function*(){return e._conversationsManager?e._conversationsManager.restoreFromToken(t):(gt.warn(Os),null)})()}restoreFromUrlToken(){var t=this;return he(function*(){return t._conversationsManager?t._conversationsManager.restoreFromUrlToken():(gt.warn(Os),null)})()}getCurrentTicketId(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.getCurrentTicketId())!==null&&t!==void 0?t:null}getWidgetSessionId(){var t,e;return(t=(e=this._conversationsManager)===null||e===void 0?void 0:e.getWidgetSessionId())!==null&&t!==void 0?t:null}kc(){var t;(t=this._conversationsManager)===null||t===void 0||t.setIdentity()}Sc(){var t;(t=this._conversationsManager)===null||t===void 0||t.clearIdentity()}}},GT={logs:class extends TT{constructor(t){super({get(){var e;return t==null||(e=t.config)===null||e===void 0?void 0:e.logs},captureHintKey:dp,get remoteConfigWillArrive(){var e,s;return!(!((e=t.il)===null||e===void 0)&&e.call(t))||!!(!((s=L._POSTHOG_REMOTE_CONFIG)===null||s===void 0||(s=s[t.config.token])===null||s===void 0)&&s.config)}},()=>(function(e){var s;let i={};if(i.distinctId=e.get_distinct_id(),e.sessionManager){let{sessionId:n,windowId:r,sessionStartTimestamp:o,lastActivityTimestamp:a}=e.sessionManager.checkAndGetSessionAndWindowId(!0);i.sessionId=n,i.windowId=r,B(o)||(i.sessionStartTimestamp=o),B(a)||(i.lastActivityTimestamp=a)}if(!(L==null||(s=L.location)===null||s===void 0)&&s.href&&(i.currentUrl=e.config.disable_capture_url_hashes?ds(L.location.href):L.location.href),e.featureFlags){let n=e.featureFlags.getFlags();n&&n.length>0&&(i.activeFeatureFlags=n)}return i})(t)),this._instance=t,this.name=Iv,this.Rv()}get Ev(){return this._instance.__loaded}Pv(){let t=ye("[logs]"),e=L?.__PosthogExtensions__;if(!e)return void t.error("PostHog Extensions not found.");let s=e.loadExternalDependency;if(s)return i=>{s(this._instance,"logs",n=>{let r=e.logs;i(n,r?.initializeLogs?{initialize:o=>r.initializeLogs(o),replay(o,a){var l;return(l=r.replayConsoleBuffer)===null||l===void 0?void 0:l.call(r,o,a)}}:void 0)})};t.error(dc)}}},HT={metrics:class{constructor(t){this._instance=t,this.A=ye("[metrics]"),this.To=!1}initialize(){this.onConfigChange()}onConfigChange(){var t;if(this.To)return;let e=!!(!((t=this._instance.config.metrics)===null||t===void 0)&&t.network);e&&!this.Yp?this.Yp=(s=>{let i=!0,n=()=>i?(a=>{var l;let c=(l=a.config.metrics)===null||l===void 0?void 0:l.network;return c===!0?{}:c||void 0})(s):void 0,r=CT(s,n),o=OT(s,n);return()=>{i=!1,r(),o()}})(this._instance):!e&&this.Yp&&(this.Yp(),this.Yp=void 0)}Ov(){var t;let e=(t=this._instance)===null||t===void 0||(t=t.config)===null||t===void 0?void 0:t.metrics;var s;return this.Iv&&this.Dv===e||((s=this.Iv)===null||s===void 0||s.reset(),this.Dv=e,this.Iv=new Ek(this.Fv(),(function(i){var n,r,o,a,l;let c=i?.resourceAttributes;return{serviceName:(n=c?.["service.name"])!==null&&n!==void 0?n:i?.serviceName,serviceVersion:(r=c?.["service.version"])!==null&&r!==void 0?r:i?.serviceVersion,environment:(o=c?.["deployment.environment"])!==null&&o!==void 0?o:i?.environment,resourceAttributes:c,beforeSend:i?.beforeSend,flushIntervalMs:(a=i?.flushIntervalMs)!==null&&a!==void 0?a:1e4,maxSeriesPerFlush:(l=i?.maxSeriesPerFlush)!==null&&l!==void 0?l:1e3}})(e),this.A)),this.Iv}count(t,e=1,s){this.Ov().count(t,e,s)}gauge(t,e,s){this.Ov().gauge(t,e,s)}histogram(t,e,s){this.Ov().histogram(t,e,s)}flush(t){if(!this.Iv)return Promise.resolve();if(t){let e=this.Iv.drainWindow();return e&&this.Ys(e,t),Promise.resolve()}return this.Iv.flush().catch(e=>this.A.error("PostHog metrics flush failed:",e))}reset(){var t;(t=this.Iv)===null||t===void 0||t.reset()}dispose(){var t,e;this.To=!0,(t=this.Yp)===null||t===void 0||t.call(this),this.Yp=void 0,(e=this.Iv)===null||e===void 0||e.reset()}Fv(){let t=this._instance,e=this;return{get isDisabled(){return!1},get optedOut(){return!t.is_capturing()},Ys:s=>e.Ys(s),getLibraryId:()=>it.LIB_NAME,getLibraryVersion:()=>it.LIB_VERSION}}Ys(t,e){return new Promise(s=>{let i=!1,n=o=>{i||(i=!0,clearTimeout(r),s(o))},r=setTimeout(()=>n({kind:"retry-later",error:new Error("metrics request timed out")}),9e4);this._instance._send_request(_(_({method:"POST",url:this.tg(),data:t,compression:"best-available",batchKey:"metrics"},e&&{transport:e}),{},{fireCallbackOnDrop:!0,callback(o){let a=o.statusCode;if(a>=200&&300>a)n({kind:"ok"});else if(a===413)n({kind:"too-large"});else if(a!==0&&a!==408&&a!==429&&500>a)n({kind:"fatal",error:new Error(`metrics request failed with status ${a}`)});else{var l;n({kind:"retry-later",error:(l=o.error)!==null&&l!==void 0?l:new Error(`metrics request failed with status ${a}`)})}}}))})}tg(){return this._instance.requestRouter.endpointFor("api","/i/v1/metrics")+"?token="+encodeURIComponent(this._instance.config.token)}}},zT={webMCP:class{constructor(t){this._instance=t,this.eg=!1}initialize(){this.startIfEnabled()}startIfEnabled(){if(!this._instance.config.capture_webmcp||this.eg)return;let t=T?.modelContext;if(!t||!Ce(t.registerTool))return;let e=sg.get(t);if(e)return e.instances.add(this._instance),void(this.eg=!0);let s={instances:new Set([this._instance])},i=t.registerTool,n=this;yi(t,"registerTool",r=>{let o=r;return function(a,...l){let c=a;try{c=n.ig(a,s)}catch{return o.call(this,a,...l)}return o.call(this,c,...l)}}),t.registerTool!==i&&(sg.set(t,s),this.eg=!0)}ig(t,e){if(!t||!Ce(t.execute))return t;let s=t.execute,i=this,{tool:n,injected:r}=(function(o,a){let l={intent:!1,model:!1},c=o.inputSchema;if(!(function(p){return!!S(p)||G(p)&&Object.keys(p).every(m=>PT.has(m)||m.startsWith("x-"))&&p.additionalProperties!==!0&&!G(p.additionalProperties)&&(!p.type||p.type==="object")&&(!p.properties||G(p.properties))&&(!p.required||N(p.required))})(c))return{tool:bl(o),injected:l};let u=c?.properties||{},h=p=>yl(u,p)||N(c?.required)&&c.required.includes(p);if(l.intent=a.intent&&!h("context"),l.model=a.model&&!h("llm_model"),!l.intent&&!l.model)return{tool:bl(o),injected:l};let d=_({},u),g=N(c?.required)?[...c.required]:[];return l.intent&&(d.context={type:"string",description:`Explain why this tool is called and how it supports the user's goal. Describe the abstract purpose only. Do not include personal or identifying information. Generalize specific entities as roles such as "a customer".`},g.includes("context")||g.push("context")),l.model&&(d.llm_model={type:"string",description:'The exact model identifier you are running as, taken from your system prompt or environment. Pass "unknown" if you do not know it. Never guess.'},g.includes("llm_model")||g.push("llm_model")),{tool:bl(o,_(_({},c),{},{type:c?.type||"object",properties:d,required:g})),injected:l}})(t,(function(o){let a={intent:!1,model:!1};for(let l of o.instances){let c=ig(l.config.capture_webmcp);a.intent||(a.intent=c?.intent===!0),a.model||(a.model=c?.model===!0)}return a})(e));return Object.defineProperty(n,"execute",{configurable:!0,enumerable:!0,writable:!0,value(...o){let a=new Date,l=(function(d,g){if(!G(d))return{};try{let p=g.intent?ng(d.context,2048,!0):void 0,m=g.model?ng(d.llm_model,256):void 0;return _(_({},p&&p!=="{}"?{intent:p}:{}),m&&m.toLowerCase()!=="unknown"?{model:m}:{})}catch{return{}}})(o[0],r),c=(function(d,g){let p=d[0];if(!G(p))return d;try{let m=g.intent&&yl(p,"context"),v=g.model&&yl(p,"llm_model");if(!m&&!v)return d;let b=_({},p);return m&&delete b.context,v&&delete b.llm_model,[b,...d.slice(1)]}catch{return d}})(o,r),u;try{u=s.apply(this===n?t:this,c)}catch(d){throw i.ng(e,n,a,!0,l),d}return(h=u)&&typeof h.then=="function"?Promise.resolve(u).then(d=>(i.ng(e,n,a,rg(d),l),d),d=>{throw i.ng(e,n,a,!0,l),d}):(i.ng(e,n,a,rg(u),l),u);var h}}),n}ng(t,e,s,i,n){let r=Date.now()-s.getTime();for(let o of t.instances){let a=ig(o.config.capture_webmcp);if(a)try{o.capture("$mcp_tool_call",_(_({$mcp_source:"posthog_mcp_analytics",$mcp_interface:"webmcp",$mcp_tool_name:e.name,$mcp_resource_name:e.name,$mcp_tool_description:e.description,$mcp_server_name:pe?.hostname,$mcp_duration_ms:r,$mcp_is_error:i},a.intent&&n.intent?{$mcp_intent:n.intent,$mcp_intent_source:"context_parameter"}:{}),a.model&&n.model?{$mcp_llm_model:n.model,$mcp_llm_model_source:"self_reported"}:{}),{timestamp:s})}catch{continue}}}}};fn.__defaultExtensionClasses=_({},_(_(_(_(_(_(_(_(_(_(_(_(_(_({},uo),xT),DT),NT),MT),FT),UT),LT),BT),VT),jT),GT),HT),zT));qT=(function(){it.SDK_DIST_CHANNEL="npm";let t=dn[tn]=new fn;return(function(){function e(){e.done||(e.done=!0,_v=!1,re(dn,function(s){s._dom_loaded()}))}T?.addEventListener?T.readyState==="complete"?e():se(T,"DOMContentLoaded",e,{capture:!1}):E&&R.error("Browser doesn't support `document.addEventListener` so PostHog couldn't be initialized")})(),t})(),Oe=qT});var Nv={};go(Nv,{Posthog:()=>Sc});var He,Sc,Mv=Ze(()=>{"use strict";Dv();Di();Mi();He=class He{constructor(e,s=!1){this.has_initialized=!1;this.has_identified=!1;this.debug=!1;this.log=es("[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 n=window.location.hostname,r=n.split("."),o=r.length>=2?`.${r.slice(-2).join(".")}`:n;i.forEach(a=>{[o,n,""].forEach(c=>{let u=c?`; Domain=${c}`:"";document.cookie=`${a}=; path=/${u}; max-age=0; SameSite=Lax`});let l=!document.cookie.split(";").some(c=>c.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(He._hasLoaded||Oe.__loaded){this.log("init | PostHog already initialized, skipping re-init"),this.has_initialized=!0;return}this.cleanupStalePosthogCookies(e);let n=s||gd();this.log("init | loading PostHog SDK",{api_host:n});let r={api_host:n,ui_host:fd,autocapture:{dom_event_allowlist:["click"],element_allowlist:["button","a"]},rageclick:!0,capture_dead_clicks:!0,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 c=o.timestamp.getTime(),u=Date.now();if(c<u-6048e5||c>u+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"&&!pd.some(c=>a.endsWith(`.${c}`)||a===c))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],c=o;for(let u of l)c=c?u(c):null;return c}return o}};Oe.init(e,r),this.options.app_version&&Oe.register({app_version:this.options.app_version}),He._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)=>{He.isAnonymousId(e)||(this.log(`${i} | stale identified user, resetting`,{previous:e,next:s}),Oe.reset())};this.identifyEvent=(e,s={})=>{if(!this.has_initialized){console.warn("Posthog: Cannot identify - not initialized");return}try{if(!e||!e.trim()||He.ILLEGAL_IDS.has(e.toLowerCase())){this.log("identifyEvent | skipped \u2014 invalid user_id",{user_id:e});return}let i=Oe.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}),Oe.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"),Oe.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:n})=>{if(!(!this.has_initialized||!e)){if(!e.trim()||He.ILLEGAL_IDS.has(e.toLowerCase())){this.log("backfillPersonProperties | skipped \u2014 invalid user_id",{user_id:e});return}try{let r=Oe.get_distinct_id(),o=r===e;o||this.resetIfStaleId(r,e,"backfillPersonProperties");let a={};if(Oe.get_property("client_id")||(a.client_id=e),s&&Oe.get_property("is_internal")==null&&(a.is_internal=sr(s)),i&&!Oe.get_property("language")&&(a.language=i),n&&!Oe.get_property("country_of_residence")&&(a.country_of_residence=n),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}),Oe.setPersonProperties(a)}else a.client_id||(a.client_id=e),this.log("backfillPersonProperties | user not identified, identifying now",{user_id:e,updates:a}),Oe.identify(e,a),this.has_identified=!0}catch(r){console.error("Posthog: Failed to backfill person properties",r)}}};this.capture=(e,s)=>{if(this.has_initialized)try{this.log("capture | sending event to PostHog",{event_name:e,properties:s}),Oe.capture(e,s)}catch(i){console.error("Posthog: Failed to capture event",i)}};this.isFeatureEnabled=e=>{if(this.has_initialized)try{let s=Oe.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=Oe.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=Oe.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=Oe.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=Oe.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"),Oe.reloadFeatureFlags()}catch(e){console.error("Posthog: Failed to reload feature flags",e)}};this.options=e,this.debug=s,this.init()}};He._hasLoaded=!1,He.ILLEGAL_IDS=new Set(["restored","null","undefined","anonymous","guest","distinctid","distinct_id","id","not_authenticated","email","true","false","0","none","nan"]),He.getPosthogInstance=(e,s=!1)=>(He._instance?e.apiKey&&e.apiKey!==He._instance.options.apiKey&&console.warn("Posthog: getPosthogInstance called with a different API key \u2014 returning existing instance"):He._instance=new He(e,s),He._instance),He.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;Sc=He});var KT={};go(KT,{Analytics:()=>Fv});ca();Di();Mi();var VE=4320*60*60,ys=class ys{constructor(e,s,i=!1,n){this.analytics=new zs;this.has_identified=!1;this.has_initialized=!1;this.current_page="";this.rudderstack_anonymous_cookie_key="rudder_anonymous_id";this.debug=!1;this.log=es("[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,r=["webflow.io"].some(c=>s.endsWith(c))?s:s.split(".").slice(-2).join("."),o;if(crypto?.randomUUID)o=crypto.randomUUID();else if(crypto?.getRandomValues){let c=new Uint8Array(16);crypto.getRandomValues(c),c[6]=c[6]&15|64,c[8]=c[8]&63|128;let u=Array.from(c,h=>h.toString(16).padStart(2,"0")).join("");o=`${u.slice(0,8)}-${u.slice(8,12)}-${u.slice(12,16)}-${u.slice(16,20)}-${u.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=${r}; max-age=${VE}; 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:ua});try{this.setCookieIfNotExists(),this.analytics.load(e,ua,{...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(n){console.error("RudderStack: Failed to identify user",n)}else this.log("identifyEvent | user already identified",{user_id:e}),this.has_identified=!0};this.pageView=(e,s="Deriv App",i,n)=>{if(!(!this.has_initialized||e===this.current_page))try{let r={...i&&{user_id:i},...n};this.log("pageView | tracking page view",{platform:s,current_page:e,properties:r}),this.analytics.page(s,e,r),this.current_page=e}catch(r){console.error("RudderStack: Failed to track page view",r)}};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=n,this.init(e)}};ys.getRudderStackInstance=(e,s,i=!1,n)=>(ys._instance||(ys._instance=new ys(e,s,i,n)),ys._instance);var ir=ys;var nr="cached_analytics_events",rr="cached_analytics_page_views",wd=(t,e)=>{try{let s=localStorage.getItem(nr),i=s?JSON.parse(s):[];i.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(nr,JSON.stringify(i))}catch(s){console.warn("Analytics: Failed to cache event",s)}},Sd=(t,e)=>{try{let s=localStorage.getItem(rr),i=s?JSON.parse(s):[];i.push({name:t,properties:e,timestamp:Date.now()}),localStorage.setItem(rr,JSON.stringify(i))}catch(s){console.warn("Analytics: Failed to cache page view",s)}},kd=()=>{try{let t=localStorage.getItem(nr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached events",t)}return[]},Ad=()=>{try{let t=localStorage.getItem(rr);if(t){let e=JSON.parse(t);return Array.isArray(e)?e:[]}}catch(t){console.warn("Analytics: Failed to get cached pages",t)}return[]},Td=()=>{try{localStorage.removeItem(nr)}catch(t){console.warn("Analytics: Failed to clear cached events",t)}},Id=()=>{try{localStorage.removeItem(rr)}catch(t){console.warn("Analytics: Failed to clear cached page views",t)}};Mi();function WT(t){let e=t?.debug??!1,s=es("",()=>e),i,n,r,o={},a={},l=[],c=[],u=!1,h=()=>{if(!u&&n?.has_initialized){u=!0;try{let P=kd();P.length>0&&(s(`processStorageCache | replaying ${P.length} cached event(s)`,P),P.forEach(V=>{let W=ms(V.properties);n?.track(V.name,W)}),Td());let U=Ad();U.length>0&&(s(`processStorageCache | replaying ${U.length} cached page view(s)`,U),U.forEach(V=>{n?.pageView(V.name,"Deriv App",A(),V.properties)}),Id())}catch(P){console.warn("Analytics: Failed to process storage cache",P)}}},d=()=>{s("onSdkLoaded | RudderStack SDK loaded"),h(),c.length>0&&s(`onSdkLoaded | flushing ${c.length} pending identify call(s)`),c.forEach(({userId:P,traits:U})=>{P&&n?.identifyEvent(P,U)}),c=[]},g=async({growthbookKey:P,growthbookDecryptionKey:U,rudderstackKey:V,app_version:W,growthbookOptions:ee,posthogOptions:le,debug:_e})=>{var Re,xe;_e!==void 0&&(e=_e),s("initialise | starting analytics initialization",{rudderstack:!!V,growthbook:!!P,posthog:!!le});try{let Me=ee?.attributes?.country||(P?await yd():void 0);if(V&&(s("initialise | initializing RudderStack"),n=ir.getRudderStackInstance(V,d,e,W)),ee?.attributes&&Object.keys(ee.attributes).length>0){let z=ee.attributes,Ct=n?.getAnonymousId();o={...o,country:Me,...z.user_language&&{user_language:z.user_language},...z.account_type&&{account_type:z.account_type},...z.app_id&&{app_id:z.app_id},...z.residence_country&&{residence_country:z.residence_country},...z.device_type&&{device_type:z.device_type},...z.url&&{url:z.url},...z.email_hash&&{email_hash:z.email_hash},...z.network_type&&{network_type:z.network_type},...z.network_rtt&&{network_rtt:z.network_rtt},...z.network_downlink&&{network_downlink:z.network_downlink},...z.account_currency&&{account_currency:z.account_currency},...z.account_mode&&{account_mode:z.account_mode},loggedIn:!!z.loggedIn,...z.user_id&&!Ni(z.user_id)&&{user_id:z.user_id},...Ct&&{anonymous_id:Ct}}}ee??(ee={}),ee.attributes??(ee.attributes={});let Be=n?.getAnonymousId();if((Re=ee.attributes).id??(Re.id=Be),(xe=ee.attributes).country??(xe.country=Me),P){s("initialise | initializing GrowthBook");let{Growthbook:z}=await Promise.resolve().then(()=>(wh(),Eh));i=z.getGrowthBookInstance(P,U,ee,e),s("initialise | GrowthBook initialized");let Ct=setInterval(()=>{Object.keys(a).length>0?clearInterval(Ct):a=v("tracking-buttons-config",{})},1e3)}if(le){s("initialise | initializing PostHog");let{Posthog:z}=await Promise.resolve().then(()=>(Mv(),Nv));r=z.getPosthogInstance({app_version:W,...le},e),s("initialise | PostHog initialized")}s("initialise | analytics initialization complete")}catch(Me){console.warn("Analytics: Failed to initialize",Me)}},p=P=>{s("setAttributes | received attributes",P);let{user_id:U,...V}=P,W=U??A();if(i){let ee={...V};U&&!Ni(U)&&(ee.user_id=U),W&&(ee.id=W,ee.user_id=W),s("setAttributes | called GrowthBook setAttributes",ee),i.setAttributes(ee)}o={...o,...Object.fromEntries(Object.entries(V).filter(([,ee])=>ee!==void 0)),...U!==void 0&&!Ni(U)&&{user_id:U}},s("setAttributes | updated core_data",o)},m=P=>i?.getFeatureState(P)?.experimentResult?.name,v=(P,U)=>i?.getFeatureValue(P,U),b=async()=>await i?.getStatus(),y=P=>i?.isOn(P),w=P=>i?.setUrl(P),A=()=>{let P=n?.getUserId()||"";return P&&!Ni(P)?P:""},Q={initialise:g,setAttributes:p,identifyEvent:(P,U)=>{let V=P||A();if(!V){s("identifyEvent | skipped \u2014 no user_id available");return}s("identifyEvent | called",{user_id:V,traits:U});let W=Re=>{if(!Re)return Re;let{email:xe,...Me}=Re;return{...Me,...xe&&{is_internal:sr(xe)}}},ee=U?.rudderstack!==void 0||U?.posthog!==void 0,le,_e;if(ee){let{rudderstack:Re,posthog:xe,...Me}=U;le=W({...Me,...Re}),_e=W({...Me,...xe})}else le=W(U),_e=W(U);n&&(n.has_initialized?(s("identifyEvent | calling RudderStack identify",{user_id:V,traits:le}),n.identifyEvent(V,le)):c.some(Re=>Re.userId===V)||(s("identifyEvent | RudderStack not initialized \u2014 queuing identify call",{user_id:V}),c.push({userId:V,traits:le}))),r?.has_initialized&&(s("identifyEvent | calling PostHog identify",{user_id:V,traits:_e}),r.identifyEvent(V,_e))},backfillPersonProperties:({user_id:P,email:U,language:V,country_of_residence:W})=>{s("backfillPersonProperties | called",{user_id:P}),r?.has_initialized?(s("backfillPersonProperties | backfilling person properties in PostHog",{user_id:P}),r.backfillPersonProperties({user_id:P,email:U,language:V,country_of_residence:W})):s("backfillPersonProperties | skipped \u2014 PostHog not initialized")},getFeatureState:m,getFeatureValue:v,getGrowthbookStatus:b,isFeatureOn:y,setUrl:w,getId:A,getAnonymousId:()=>n?.getAnonymousId()||"",trackEvent:(P,U)=>{let V=A();s("trackEvent | called",{event:P,analytics_data:U,userId:V,core_data:o});let W={...o,...U,...V&&!o.user_id&&{user_id:V}};if(s("trackEvent | built payload",{event:P,final_payload:W}),!(!(P in a)||a[P])){s("trackEvent | skipped \u2014 event disabled by tracking_config",{event:P});return}let le=n?.has_initialized;if(!navigator.onLine||!le)le?(s("trackEvent | offline \u2014 caching event to memory",{event:P}),l.push({event:P,payload:W})):(s("trackEvent | RudderStack not initialized \u2014 caching event to localStorage",{event:P}),wd(P,W));else{l.length>0&&(s(`trackEvent | flushing ${l.length} offline cached event(s) to RudderStack`),l.forEach(Re=>{let xe=ms(Re.payload);n?.track(Re.event,xe)}),l=[]);let _e=ms(W);s("trackEvent | sending event to RudderStack",{event:P,payload:_e}),n?.track(P,_e)}if(r?.has_initialized){let _e=ms(Ed(W));s("trackEvent | sending event to PostHog",{event:P,payload:_e}),r.capture(P,_e)}},getInstances:()=>({ab:i,tracking:n,posthog:r}),pageView:(P,U="Deriv App",V)=>{let W=A();s("pageView | called",{current_page:P,platform:U,properties:V,userId:W}),n?.has_initialized?(s("pageView | sending page view to RudderStack",{current_page:P,platform:U}),n.pageView(P,U,W,V)):(s("pageView | RudderStack not initialized \u2014 caching page view to localStorage",{current_page:P}),Sd(P,{platform:U,...V}))},reset:()=>{s("reset | resetting all providers"),n?.has_initialized&&(s("reset | resetting RudderStack"),n.reset()),r?.has_initialized&&(s("reset | resetting PostHog"),r.reset())},isPosthogFeatureEnabled:P=>r?.isFeatureEnabled(P),getPosthogFeatureFlag:P=>r?.getFeatureFlag(P),getPosthogFeatureFlagPayload:P=>r?.getFeatureFlagPayload(P),getPosthogAllFlags:()=>r?.getAllFlags()??{},onPosthogFeatureFlags:P=>r?.onFeatureFlags(P)??(()=>{}),reloadPosthogFeatureFlags:()=>r?.reloadFeatureFlags()};return typeof window<"u"&&(window.AnalyticsInstance=Q),Q}var Fv=WT();return Kv(KT);})();
|
|
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
|