UNPKG

@deriv-com/analytics

Version:

Comprehensive analytics package for Deriv applications. Provides unified event tracking, A/B testing, and user analytics through RudderStack, PostHog and GrowthBook integrations with built-in caching and offline support.

4 lines 109 kB
/* @deriv-com/analytics - Browser ESM Bundle (RudderStack + PostHog) - Built with tsup */ import{a as N}from"./chunk-F3U33XPR.mjs";function P(t){return t!=null&&typeof t=="object"&&t["@@functional/placeholder"]===!0}function Z(t){return function e(n){return arguments.length===0||P(n)?e:t.apply(this,arguments)}}function se(t){return function e(n,s){switch(arguments.length){case 0:return e;case 1:return P(n)?e:Z(function(i){return t(n,i)});default:return P(n)&&P(s)?e:P(n)?Z(function(i){return t(i,s)}):P(s)?Z(function(i){return t(n,i)}):t(n,s)}}}function xt(t){return function e(n,s,i){switch(arguments.length){case 0:return e;case 1:return P(n)?e:se(function(r,a){return t(n,r,a)});case 2:return P(n)&&P(s)?e:P(n)?se(function(r,a){return t(r,s,a)}):P(s)?se(function(r,a){return t(n,r,a)}):Z(function(r){return t(n,s,r)});default:return P(n)&&P(s)&&P(i)?e:P(n)&&P(s)?se(function(r,a){return t(r,a,i)}):P(n)&&P(i)?se(function(r,a){return t(r,s,a)}):P(s)&&P(i)?se(function(r,a){return t(n,r,a)}):P(n)?Z(function(r){return t(r,s,i)}):P(s)?Z(function(r){return t(n,r,i)}):P(i)?Z(function(r){return t(n,s,r)}):t(n,s,i)}}}function De(t,e){return Object.prototype.hasOwnProperty.call(e,t)}var ws=Z(function(e){return e===null?"Null":e===void 0?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function Yt(t){return Object.prototype.toString.call(t)==="[object Object]"}var Us=Number.isInteger||function(e){return e<<0===e};function Ms(t,e){var n=t<0?e.length+t:t;return e[n]}function $s(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 Ln(t,e,n){if(n||(n=new xs),Bs(t))return t;var s=function(r){var a=n.get(t);if(a)return a;n.set(t,r);for(var l in t)Object.prototype.hasOwnProperty.call(t,l)&&(r[l]=Ln(t[l],!0,n));return r};switch(ws(t)){case"Object":return s(Object.create(Object.getPrototypeOf(t)));case"Array":return s(Array(t.length));case"Date":return new Date(t.valueOf());case"RegExp":return $s(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 Bs(t){var e=typeof t;return t==null||e!="object"&&e!="function"}var xs=(function(){function t(){this.map={},this.length=0}return t.prototype.set=function(e,n){var s=this.hash(e),i=this.map[s];i||(this.map[s]=i=[]),i.push([e,n]),this.length+=1},t.prototype.hash=function(e){var n=[];for(var s in e)n.push(Object.prototype.toString.call(e[s]));return n.join()},t.prototype.get=function(e){if(this.length<=180){for(var n in this.map)for(var a=this.map[n],s=0;s<a.length;s+=1){var i=a[s];if(i[0]===e)return i[1]}return}var r=this.hash(e),a=this.map[r];if(a)for(var s=0;s<a.length;s+=1){var i=a[s];if(i[0]===e)return i[1]}},t})(),E=Z(function(e){return e!=null&&typeof e.clone=="function"?e.clone():Ln(e)});function Gs(t,e){for(var n=e,s=0;s<t.length;s+=1){if(n==null)return;var i=t[s];Us(i)?n=Ms(i,n):n=n[i]}return n}var Fs=xt(function(e,n,s){var i={},r;n=n||{},s=s||{};for(r in n)De(r,n)&&(i[r]=De(r,s)?e(r,n[r],s[r]):n[r]);for(r in s)De(r,s)&&!De(r,i)&&(i[r]=s[r]);return i}),Vs=xt(function t(e,n,s){return Fs(function(i,r,a){return Yt(r)&&Yt(a)?t(e,r,a):e(i,r,a)},n,s)}),js=xt(function(e,n,s){return Vs(function(i,r,a){return e(r,a)},n,s)}),Hs=se(Gs),wn=se(function(e,n){var s={};for(var i in n)e(n[i],i,n)&&(s[i]=n[i]);return s}),f=t=>typeof t=="function"&&!!(t.constructor&&t.call&&t.apply),_=t=>typeof t=="string",G=t=>t===null,U=t=>typeof t>"u",W=t=>G(t)||U(t),Ks=t=>typeof t=="bigint",A=t=>!U(t),pe=t=>!W(t),Ws=t=>pe(t)&&t!=="",Gt=t=>{switch(Object.prototype.toString.call(t)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return t instanceof Error}},Qs=t=>typeof t=="boolean",ut=(t,e)=>{let n=e.split(".");return Hs(n,t)},zs=(t,e)=>!!ut(t,e),Xs=t=>typeof t=="object",Ys=t=>!G(t)&&Xs(t)&&!Array.isArray(t),O=t=>!G(t)&&Object.prototype.toString.call(t)==="[object Object]",qs=(t,e)=>{if(!Array.isArray(t)||!Array.isArray(e))return E(e);let n=E(t);return e.forEach((s,i)=>{n[i]=Array.isArray(s)||Ys(s)?L(n[i],s):s}),n},L=(t,e)=>js(qs,t,e),te=t=>O(t)&&Object.keys(t).length>0,Te=t=>{let e=wn(A,t);return Object.keys(e).forEach(n=>{let s=e[n];O(s)&&(e[n]=Te(s))}),e},Fe=t=>{let e=wn(pe,t);return Object.keys(e).forEach(n=>{let s=e[n];O(s)&&(e[n]=Fe(s))}),e},Y=t=>{if(te(t))return Fe(t)},Q=(t,e)=>typeof t=="boolean"?t:e,Ft=t=>(Object.getOwnPropertyNames(t).forEach(function(e){t[e]&&typeof t[e]=="object"&&Ft(t[e])}),Object.freeze(t)),Js=t=>t.replace(/^\s+|\s+$/gm,""),qt=t=>t.replace(/^\.+/,""),Ve=t=>{let e=t;if(!_(t)&&!W(t))try{e=JSON.stringify(t)}catch{e=null}return e},Zs=t=>{let e=Array.from(t,n=>String.fromCodePoint(n)).join("");return globalThis.btoa(e)},ei=t=>Zs(new TextEncoder().encode(t)),je=(t,e,n,s,i)=>{let r={category:t,name:e,properties:n,options:s,callback:void 0};f(i)&&(r.callback=i),f(s)&&(r.category=t,r.name=e,r.properties=n,r.options=void 0,r.callback=s),f(n)&&(r.category=t,r.name=e,r.properties=void 0,r.options=void 0,r.callback=n),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),O(t)?(r.name=void 0,r.category=void 0,r.properties=t,f(e)?r.options=void 0:r.options=e):O(e)&&(r.name=void 0,r.properties=e,f(n)?r.options=void 0:r.options=n),_(t)&&!_(e)&&(r.category=void 0,r.name=t),A(r.category)||(r.category=void 0),A(r.name)||(r.name=void 0),r.properties=r.properties?E(r.properties):{},A(r.options)?r.options=E(r.options):r.options=void 0;let a=_(r.name)?r.name:r.properties.name,l=_(r.category)?r.category:r.properties.category;return r.properties=L(O(r.properties)?r.properties:{},{...a&&{name:a},...l&&{category:l}}),r},Vt=(t,e,n,s)=>{let i={name:t,properties:e,options:n,callback:void 0};return f(s)&&(i.callback=s),f(n)&&(i.properties=e,i.options=void 0,i.callback=n),f(e)&&(i.properties=void 0,i.options=void 0,i.callback=e),i.properties=pe(i.properties)?E(i.properties):{},A(i.options)?i.options=E(i.options):i.options=void 0,i},Un=(t,e,n,s)=>{let i={userId:t,traits:e,options:n,callback:void 0};return f(s)&&(i.callback=s),f(n)&&(i.userId=t,i.traits=e,i.options=void 0,i.callback=n),f(e)&&(i.userId=t,i.traits=void 0,i.options=void 0,i.callback=e),(O(t)||G(t))&&(i.userId=null,i.traits=t,f(e)?i.options=void 0:i.options=e),i.userId=Ve(i.userId),O(i.traits)?i.traits=E(i.traits):i.traits=void 0,A(i.options)?i.options=E(i.options):i.options=void 0,i},Mn=(t,e,n,s)=>{let i={to:t,from:e,options:n,callback:void 0};return f(s)&&(i.callback=s),f(n)&&(i.to=t,i.from=e,i.options=void 0,i.callback=n),f(e)?(i.to=t,i.from=void 0,i.options=void 0,i.callback=e):(O(e)||G(e))&&(i.to=t,i.from=void 0,i.options=e),A(i.to)&&(i.to=Ve(i.to)),A(i.from)?i.from=Ve(i.from):i.from=void 0,A(i.options)?i.options=E(i.options):i.options=void 0,i},$n=(t,e,n,s)=>{let i={groupId:t,traits:e,options:n,callback:void 0};return f(s)&&(i.callback=s),f(n)&&(i.groupId=t,i.traits=e,i.options=void 0,i.callback=n),f(e)&&(i.groupId=t,i.traits=void 0,i.options=void 0,i.callback=e),(O(t)||G(t))&&(i.groupId=null,i.traits=t,f(e)?i.options=void 0:i.options=e),i.groupId=Ve(i.groupId),O(i.traits)?i.traits=E(i.traits):i.traits=void 0,A(i.options)?i.options=E(i.options):i.options=void 0,i},tt=(function(t){return t.UNLOADED="Page Unloaded",t})({}),jt="API",dt="CapabilitiesManager",j="ConfigManager",Bn="EventManager",Ie="PluginsManager",oe="UserSessionManager",Ae="ErrorHandler",de="PluginEngine",ti="StoreManager",nt=`Ready${jt}`,ni=`Load${jt}`,si="HttpClient",ii="RudderStackAnalytics",ke="AnalyticsCore";function ri(t){return crypto.getRandomValues(new Uint8Array(t))}var Jt=4096,Ue=[],ie=0,st;for(;ie<256;ie++)Ue[ie]=(ie+256).toString(16).substring(1);function oi(){(!st||ie+16>Jt)&&(st=ri(Jt),ie=0);for(var t=0,e,n="";t<16;t++)e=st[ie+t],t==6?n+=Ue[e&15|64]:t==8?n+=Ue[e&63|128]:n+=Ue[e],t&1&&t>1&&t<11&&(n+="-");return ie+=16,n}var ce=256,Me=[],Le;for(;ce--;)Me[ce]=(ce+256).toString(16).substring(1);function ai(){var t=0,e,n="";if(!Le||ce+16>256){for(Le=Array(t=256);t--;)Le[t]=256*Math.random()|0;t=ce=0}for(;t<16;t++)e=Le[ce+t],t==6?n+=Me[e&15|64]:t==8?n+=Me[e&63|128]:n+=Me[e],t&1&&t>1&&t<11&&(n+="-");return ce++,n}var li=()=>!W(globalThis.crypto)&&f(globalThis.crypto.getRandomValues),Ye=()=>li()?oi():ai(),ci=()=>!!window.chrome?.runtime?.id,ui=()=>_(globalThis.navigator.userAgent)&&/Trident.*rv:11\./.test(globalThis.navigator.userAgent),di=(t,e=!1)=>{let n=!1,s=!1;function i(){n||(n=!0,t(s),setTimeout(()=>{n=!1},0))}(e||ui())&&globalThis.addEventListener("beforeunload",()=>{s=!1,i()}),globalThis.addEventListener("blur",()=>{s=!0,i()}),globalThis.addEventListener("focus",()=>{n=!1}),document.addEventListener("pagehide",()=>{s=document.visibilityState==="hidden",i()}),document.addEventListener("visibilitychange",()=>{s=!0,document.visibilityState==="hidden"?i():n=!1})},xn=t=>t.toISOString(),gi=()=>xn(new Date),v=":: ",fi=t=>`A script with the id "${t}" is already loaded. Skipping the loading of this script to prevent conflicts`,Zt=(t,e,n)=>`Unable to load (${_(n)?n:n.type}) the script with the id "${t}" from URL "${e}"`,hi=(t,e,n)=>`A timeout of ${n} ms occurred while trying to load the script with id "${t}" from URL "${e}"`,pi=(t,e)=>`${t}${v}A circular reference has been detected in the object and the property "${e}" has been dropped from the output.`,vi="Failed to convert the value to a JSON string.",mi="Failed to encode the cookie data.",Ei=(t,e)=>`${t}${v}The "${e}" storage type is `,yi="JSONStringify",Si="[BigInt]",Gn="[Circular Reference]",Ii=(t,e,n)=>{let s=[];return function(i,r){if(!e?.includes(i)&&!(t&&W(r))){if(typeof r!="object"||G(r))return r;for(;s.length>0&&s[s.length-1]!==this;)s.pop();return s.includes(r)?(n?.warn(pi(yi,i)),Gn):(s.push(r),r)}}},K=(t,e,n,s)=>{try{return JSON.stringify(t,Ii(e,n,s))}catch(i){return s?.warn(vi,i),null}},bi=t=>{let e=[];return function(s,i){if(Ks(i))return Si;for(;e.length>0&&e[e.length-1]!==this;)e.pop();return e.includes(i)?Gn:(e.push(i),i)}},Fn=(t,e)=>{let n=Array.isArray(t)?[]:{};for(let s in t)if(Object.hasOwnProperty.call(t,s)){let i=t[s],r=e.call(t,s,i);O(r)||Array.isArray(r)?n[s]=Fn(r,e):n[s]=r}return n},y=(t,e)=>{let n=bi(),s=n.call(t,"",t);return O(t)||Array.isArray(t)?Fn(t,n):s},Vn="[SDK DISPATCHED ERROR]",qe=t=>{let{stack:e}=t;if(typeof e=="string"&&e)return e},Ht=(t,e)=>{if(!Gt(t))return new Error(`${e}: ${K(t)}`);try{let n=t.constructor,s=new n(`${e}: ${t.message}`),i=qe(t);return i&&(s.stack=i),Object.getOwnPropertyNames(t).forEach(r=>{if(r!=="message"&&r!=="stack"&&r!=="name")try{s[r]=t[r]}catch{}}),s}catch{return new Error(`${e}: ${K(t)}`)}},C=t=>{if(Gt(t)){let e=qe(t);e&&(t.stack=`${e} ${Vn}`)}globalThis.dispatchEvent(new ErrorEvent("error",{error:t,bubbles:!0,cancelable:!0,composed:!0}))},en="RudderLabs JavaScript SDK",Ne="3.31.1",Ti="com.rudderlabs.javascript",jn="npm",Ai="modern",tn="RudderJS-Initiated",Ri="ad-block page request",_i="/ad-blocked",_e="preloadedEventsBuffer",Oi="Consent Management Interaction",Ni="ajs_trait_",Pi="ajs_prop_",nn="ajs_aid",Ci="ajs_uid",sn="ajs_event",Di=10*1e3,ki=31536e3*1e3,rn=720*60*1e3,gt=1800*1e3,on=10*1e3,Li=10*1e3,wi=250,Hn=(t="app")=>{globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[t]||(globalThis.RudderStackGlobals[t]={})},Pe=(t,e,n="app")=>{Hn(n),globalThis.RudderStackGlobals[n][t]=e},Kn=(t,e="app")=>(Hn(e),globalThis.RudderStackGlobals[e][t]);function Ui(t,e,n=wi){let s;return(...i)=>{globalThis.clearTimeout(s),s=globalThis.setTimeout(()=>{t.apply(e,i)},n)}}var an=(t,e)=>{let n={};return t.forEach((s,i)=>{if(i.startsWith(e)){let r=i.substring(e.length);n[r]=t.get(i)}}),n},Mi=(t=[])=>{let e={trait:Ni,properties:Pi},n=new URLSearchParams(globalThis.location.search);n.get(sn)&&t.unshift(["track",n.get(sn),an(n,e.properties)]);let s=n.get(Ci),i=an(n,e.trait);if(s||te(i)){let r=[...s?[s]:[],i];t.unshift(["identify",...r])}n.get(nn)&&t.unshift(["setAnonymousId",n.get(nn)])},$i=t=>{let e="load",n=[],s=0;for(;s<t.length;){if(t[s]&&t[s][0]===e){n=E(t[s]),t.splice(s,1);break}s+=1}return n},Bi=t=>{let e="consent",n=t.filter(i=>i[0]===e),s=t.filter(i=>i[0]!==e);t.splice(0,t.length,...n,...s)},xi=t=>{let e=Kn(_e)||[];Mi(e),e.length>0&&(t.enqueuePreloadBufferEvents(e),Pe(_e,[]))},Gi=(t,e)=>{let n=t.shift(),s;if(f(e[n])){switch(n){case"page":s=je(...t);break;case"track":s=Vt(...t);break;case"identify":s=Un(...t);break;case"alias":s=Mn(...t);break;case"group":s=$n(...t);break;default:e[n](...t);break}s&&e[n](s)}},Fi=10*1e3,Vi="RS_JS_SDK",ji=(t,e,n=!0,s=null,i=null,r={})=>{let a=document.createElement("script");return a.type="text/javascript",a.onload=s,a.onerror=i,a.src=t,a.id=e,a.async=n,Object.keys(r).forEach(l=>{a.setAttribute(l,r[l])}),a.setAttribute("data-loader",Vi),a},Hi=t=>{let e=document.getElementsByTagName("head");if(e.length>0){e[0]?.insertBefore(t,e[0]?.firstChild);return}let n=document.getElementsByTagName("script");if(n.length>0&&n[0]?.parentNode){n[0]?.parentNode.insertBefore(t,n[0]);return}let s=document.createElement("head");s.appendChild(t);let i=document.getElementsByTagName("html")[0];i?.insertBefore(s,i.firstChild)},Ki=(t,e,n,s=!0,i)=>new Promise((r,a)=>{document.getElementById(e)&&a(new Error(fi(e)));try{let u;Hi(ji(t,e,s,()=>{globalThis.clearTimeout(u),r(e)},S=>{globalThis.clearTimeout(u),a(new Error(Zt(e,t,S)))},i)),u=globalThis.setTimeout(()=>{a(new Error(hi(e,t,n)))},n)}catch(u){a(Ht(u,Zt(e,t,"unknown")))}}),He=class{constructor(e,n=Fi){this.logger=e,this.timeout=n}loadJSFile(e){let{url:n,id:s,timeout:i,async:r,callback:a,extraAttributes:l}=e,u=!f(a);Ki(n,s,i||this.timeout,r,l).then(d=>{u||a(d)}).catch(d=>{u||a(s,d)})}},Wi=Symbol.for("preact-signals");function Je(){if(ee>1)ee--;else{var t,e=!1;for((function(){var i=We;for(We=void 0;i!==void 0;)i.S.v===i.v&&(i.S.i=i.i),i=i.o})();Oe!==void 0;){var n=Oe;for(Oe=void 0,Ke++;n!==void 0;){var s=n.u;if(n.u=void 0,n.f&=-3,!(8&n.f)&&zn(n))try{n.c()}catch(i){e||(t=i,e=!0)}n=s}}if(Ke=0,ee--,e)throw t}}function w(t){if(ee>0)return t();ft=++Qi,ee++;try{return t()}finally{Je()}}var b=void 0;function Wn(t){var e=b;b=void 0;try{return t()}finally{b=e}}var Oe=void 0,ee=0,Ke=0,Qi=0,ft=0,We=void 0,Qe=0;function Qn(t){if(b!==void 0){var e=t.n;if(e===void 0||e.t!==b)return e={i:0,S:t,p:b.s,n:void 0,t:b,e:void 0,x:void 0,r:e},b.s!==void 0&&(b.s.n=e),b.s=e,t.n=e,32&b.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=b.s,e.n=void 0,b.s.n=e,b.s=e),e}}function M(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}M.prototype.brand=Wi;M.prototype.h=function(){return!0};M.prototype.S=function(t){var e=this,n=this.t;n!==t&&t.e===void 0&&(t.x=n,this.t=t,n!==void 0?n.e=t:Wn(function(){var s;(s=e.W)==null||s.call(e)}))};M.prototype.U=function(t){var e=this;if(this.t!==void 0){var n=t.e,s=t.x;n!==void 0&&(n.x=s,t.e=void 0),s!==void 0&&(s.e=n,t.x=void 0),t===this.t&&(this.t=s,s===void 0&&Wn(function(){var i;(i=e.Z)==null||i.call(e)}))}};M.prototype.subscribe=function(t){var e=this;return X(function(){var n=e.value,s=b;b=void 0;try{t(n)}finally{b=s}},{name:"sub"})};M.prototype.valueOf=function(){return this.value};M.prototype.toString=function(){return this.value+""};M.prototype.toJSON=function(){return this.value};M.prototype.peek=function(){var t=b;b=void 0;try{return this.value}finally{b=t}};Object.defineProperty(M.prototype,"value",{get:function(){var t=Qn(this);return t!==void 0&&(t.i=this.i),this.v},set:function(t){if(t!==this.v){if(Ke>100)throw new Error("Cycle detected");(function(n){ee!==0&&Ke===0&&n.l!==ft&&(n.l=ft,We={S:n,v:n.v,i:n.i,o:We})})(this),this.v=t,this.i++,Qe++,ee++;try{for(var e=this.t;e!==void 0;e=e.x)e.t.N()}finally{Je()}}}});function c(t,e){return new M(t,e)}function zn(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 Xn(t){for(var e=t.s;e!==void 0;e=e.n){var n=e.S.n;if(n!==void 0&&(e.r=n),e.S.n=e,e.i=-1,e.n===void 0){t.s=e;break}}}function Yn(t){for(var e=t.s,n=void 0;e!==void 0;){var s=e.p;e.i===-1?(e.S.U(e),s!==void 0&&(s.n=e.n),e.n!==void 0&&(e.n.p=s)):n=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=s}t.s=n}function Ee(t,e){M.call(this,void 0),this.x=t,this.s=void 0,this.g=Qe-1,this.f=4,this.W=e?.watched,this.Z=e?.unwatched,this.name=e?.name}Ee.prototype=new M;Ee.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Qe))return!0;if(this.g=Qe,this.f|=1,this.i>0&&!zn(this))return this.f&=-2,!0;var t=b;try{Xn(this),b=this;var e=this.x();(16&this.f||this.v!==e||this.i===0)&&(this.v=e,this.f&=-17,this.i++)}catch(n){this.v=n,this.f|=16,this.i++}return b=t,Yn(this),this.f&=-2,!0};Ee.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)}M.prototype.S.call(this,t)};Ee.prototype.U=function(t){if(this.t!==void 0&&(M.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)}};Ee.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(Ee.prototype,"value",{get:function(){if(1&this.f)throw new Error("Cycle detected");var t=Qn(this);if(this.h(),t!==void 0&&(t.i=this.i),16&this.f)throw this.v;return this.v}});function qn(t){var e=t.m;if(t.m=void 0,typeof e=="function"){ee++;var n=b;b=void 0;try{e()}catch(s){throw t.f&=-2,t.f|=8,Kt(t),s}finally{b=n,Je()}}}function Kt(t){for(var e=t.s;e!==void 0;e=e.n)e.S.U(e);t.x=void 0,t.s=void 0,qn(t)}function zi(t){if(b!==this)throw new Error("Out-of-order effect");Yn(this),b=t,this.f&=-2,8&this.f&&Kt(this),Je()}function ye(t,e){this.x=t,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=e?.name}ye.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()}};ye.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,qn(this),Xn(this),ee++;var t=b;return b=this,zi.bind(this,t)};ye.prototype.N=function(){2&this.f||(this.f|=2,this.u=Oe,Oe=this)};ye.prototype.d=function(){this.f|=8,1&this.f||Kt(this)};ye.prototype.dispose=function(){this.d()};function X(t,e){var n=new ye(t,e);try{n.c()}catch(i){throw n.d(),i}var s=n.d.bind(n);return s[Symbol.dispose]=s,s}var ht=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=[]}},we={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},ln="LOG",Jn="ERROR",Xi="RS SDK",Yi="font-weight: bold; background: black; color: white;",qi="font-weight: normal;",pt=class{constructor(e=ln,n="",s=console){this.minLogLevel=we[e],this.scope=n,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,n){this.minLogLevel<=we[e]&&this.logProvider[e.toLowerCase()]?.(...this.formatLogData(n))}setScope(e){this.scope=e||this.scope}setMinLogLevel(e){this.minLogLevel=we[e],U(this.minLogLevel)&&(this.minLogLevel=we[ln])}formatLogData(e){if(Array.isArray(e)&&e.length>0){let n=`%c ${Xi}`;this.scope&&(n=`${n} - ${this.scope}`);let s=_(e[0])?e[0].trim():"";n=`${n} %c ${s}`;let i=[n,Yi,qi];return _(e[0])||i.push(e[0]),i.push(...e.slice(1)),i}return e}},ne=new pt,q=(function(t){return t.HANDLEDEXCEPTION="handledException",t.UNHANDLEDEXCEPTION="unhandledException",t.UNHANDLEDREJECTION="unhandledPromiseRejection",t})({}),Zn=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],vt="cookieStorage",cn="Unable to process/parse source configuration response",Ji="The source is disabled. Please enable the source in the dashboard to send events.",Zi="Failed to prepare data for the request.",er="Failed to invoke plugin because the extension point name is missing.",tr="Failed to invoke plugin because the extension point name is invalid.",nr=t=>`${t}${v}The "getSourceConfig" load API option must be a function that returns valid source configuration data.`,sr=(t,e,n)=>`${t}${v}The base URL "${n}" for ${e} is not valid.`,ir=(t,e,n)=>`${t}${v}The consent manager "${e}" is not supported. Please choose one of the following supported consent managers: "${Object.keys(n)}".`,rr=(t,e)=>`${t}${v}Ignoring a non-error: ${e}.`,un="Failed to log breadcrumb",or=t=>`${t}${v}Failed to handle the error.`,ar=t=>`${t}${v}Plugin name is missing.`,lr=(t,e)=>`${t}${v}Plugin "${e}" already exists.`,cr=(t,e)=>`${t}${v}Plugin "${e}" not found.`,ur=(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.`,dr=(t,e,n)=>`${t}${v}Plugin "${e}" could not be loaded because some of its dependencies "${n}" do not exist.`,gr=(t,e,n)=>`${t}${v}Failed to invoke the "${e}" extension point of plugin "${n}".`,dn="Failed to fetch the source config",fr=(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.`,hr=(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.`,es=t=>`${t}${v}The provided callback parameter is not a function.`,pr=(t,e,n,s,i)=>`${t} with status ${e} (${n}) for URL: ${s}. Response: ${i.trim()}`,vr=(t,e,n)=>`${t} due to timeout or no connection (${e?e.type:""}) at the client side for URL: ${n}`,mr=(t,e)=>`${t} for URL: ${e}`,Er=t=>`Failed to save the value for "${t}" to storage`,yr=t=>`Failed to retrieve or parse data for "${t}" from storage`,Sr=t=>`The server responded with status ${t} while setting the cookies. As a fallback, the cookies will be set client side.`,Ir=t=>`The server failed to set the ${t} cookie. As a fallback, the cookies will be set client side.`,gn="Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side.",br=(t,e,n)=>`${t}${v}The storage type "${e}" is not supported. Please choose one of the following supported types: "${Zn}". The default type "${n}" will be used instead.`,Tr=(t,e,n,s)=>`${t}${v}The storage encryption version "${e}" is not supported. Please choose one of the following supported versions: "${Object.keys(n)}". The default version "${s}" will be used instead.`,Ar=(t,e,n)=>`${t}${v}The storage data migration has been disabled because the configured storage encryption version (${e}) is not the latest (${n}). To enable storage data migration, please update the storage encryption version to the latest version.`,Rr=(t,e,n)=>`${t}${v}The provided cookie domain (${e}) does not match the current webpage's domain (${n}). Hence, the cookies will be set client-side.`,_r=(t,e,n,s)=>`${t}${v}The "${e}" property defined under "${n}" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (${s}).`,Or=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.`,Nr=t=>`${t}${v}The Beacon API is not supported by your browser. The events will be sent using XHR instead.`,Pr=(t,e,n)=>`${t}${v}The session timeout value "${e}" is not a number. The default timeout of ${n} ms will be used instead.`,Cr=(t,e,n)=>`${t}${v}The session cut off duration value "${e}" is not a number. The default cut off duration of ${n} ms will be used instead.`,Dr=(t,e,n)=>`${t}${v}The session cut off duration value "${e}" ms is less than the session timeout value "${n}" ms. The cut off functionality will be disabled.`,kr=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.`,Lr=(t,e,n)=>`${t}${v}The session timeout value ${e} ms is less than the recommended minimum of ${n} ms. Please consider increasing the timeout value to ensure optimal performance and reliability.`,wr=(t,e,n)=>`${t}${v}The provided session ID (${e}) is either invalid, not a positive integer, or not at least "${n}" digits long. A new session ID will be auto-generated instead.`,Ur=t=>`${t}${v}The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage.`,Mr=(t,e,n,s)=>`${t}${v}The storage type "${n}" is not available for entry "${e}". The SDK will initialize the entry with "${s}" storage type instead.`,$r=t=>`${t}${v}The callback threw an exception`,Br=(t,e)=>`${t}${v}The provided source config URL "${e}" is invalid. Using the default source config URL instead.`,xr=(t,e)=>`Failed to load the polyfill script with ID "${t}" from URL ${e}.`,Gr=(t,e,n)=>`${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 "${n}" will be used instead.`,Fr=(t,e,n)=>`${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 "${n}" will be used instead.`,Vr=(t,e)=>`${t}${v}${e} plugin is deprecated. Please exclude it from the load API options.`,jr=(t,e,n,s)=>{let i=n.length===1,r=i?` '${n[0]}' plugin was`:` ['${n.join("', '")}'] plugins were`,a=`${t}${v}${e}, but${r} not configured to load.`;return s?`${a} So, ${i?"the plugin":"those plugins"} will be loaded automatically.`:`${a} Ignore if this was intentional. Otherwise, consider adding ${i?"it":"them"} to the 'plugins' load API option.`},Hr=(t,e)=>`${t}${v}The provided polyfill URL "${e}" is invalid. The default polyfill URL will be used instead.`,Kr=t=>`${t}${v}Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.`,Wr=(t,e)=>`${t}${v}Ignoring unknown plugins: ${e.join(", ")}.`,Qr=(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.`,zr=(t,e)=>`${t}${v}Cannot add custom integration for destination ID "${e}" after the SDK is loaded.`,ts={All:!0},Ze="js-integrations",ns="plugins",Xr=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_]*)?$"),Ce="modern",et="https://cdn.rudderlabs.com",Wt="v3",ss=`${et}/${Wt}/${Ce}/${Ze}`,is=`${et}/${Wt}/${Ce}/${ns}`,rs="https://api.rudderstack.com",ae="v3",Yr="xhr",mt={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},$e={[ae]:"StorageEncryption",legacy:"StorageEncryptionLegacy"},qr={[Yr]:"XhrQueue",beacon:"BeaconQueue"},Jr="rsaRequest",Zr="rsaMetrics",eo="Custom Device Mode",to={configUrl:rs,loadIntegration:!0,sessions:{autoTrack:!0,timeout:gt,cutOff:{enabled:!1}},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:ts,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:Li,storage:{encryption:{version:ae},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1},no=c(E(to)),T=Ft({userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null}),it=Ft({entries:{userId:!0,userTraits:!0,groupId:!0,groupTraits:!0,sessionInfo:!0,authToken:!0,anonymousId:!1,initialReferrer:!1,initialReferringDomain:!1}}),so=10,io={userId:c(T.userId),userTraits:c(T.userTraits),anonymousId:c(T.anonymousId),groupId:c(T.groupId),groupTraits:c(T.groupTraits),initialReferrer:c(T.initialReferrer),initialReferringDomain:c(T.initialReferringDomain),sessionInfo:c(T.sessionInfo),authToken:c(T.authToken)},ro={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),cspBlockedURLs:c([])},oo={isErrorReportingEnabled:c(!1),isMetricsReportingEnabled:c(!1),breadcrumbs:c([])},ao=c(void 0),lo={activeDataplaneUrl:c(void 0),integrationsCDNPath:c(ss),pluginsCDNPath:c(is),sourceConfigUrl:c(void 0),status:c(void 0),initialized:c(!1),logLevel:c(Jn),loaded:c(!1),readyCallbacks:c([]),writeKey:c(void 0),dataPlaneUrl:c(void 0),safeAnalyticsInstance:c(void 0)},co={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)},uo={retries:c(0),dropped:c(0),sent:c(0),queued:c(0),triggered:c(0),metricsServiceUrl:c(void 0)},go=()=>Ai,fo={app:c({name:en,namespace:Ti,version:Ne,installType:jn}),traits:c(null),library:c({name:en,version:Ne,snippetVersion:globalThis.RudderSnippetVersion,variant:go()}),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)},ho={configuredDestinations:c([]),activeDestinations:c([]),loadOnlyIntegrations:c({}),failedDestinations:c([]),loadIntegration:c(!0),initializedDestinations:c([]),clientDestinationsReady:c(!1),integrationsConfig:c({})},po={toBeProcessedArray:c([]),readyCallbacksArray:c([])},vo={ready:c(!1),loadedPlugins:c([]),failedPlugins:c([]),pluginsToLoadFromConfig:c([]),activePlugins:c([]),totalPluginsToLoad:c(0)},mo={encryptionPluginName:c(void 0),migrate:c(!1),type:c(void 0),cookie:c(void 0),entries:c({}),trulyAnonymousTracking:c(!1)},Eo={isEnabledServerSideCookies:c(!1),dataServiceUrl:c(void 0)},yo={eventsQueuePluginName:c(void 0),deliveryEnabled:c(!0)},So={enabled:c(!1),pageLifecycle:{enabled:c(!1),pageViewId:c(void 0),pageLoadedTimestamp:c(void 0)}},Io={capabilities:ro,consents:co,context:fo,eventBuffer:po,lifecycle:lo,loadOptions:no,metrics:uo,nativeDestinations:ho,plugins:vo,reporting:oo,session:io,source:ao,storage:mo,serverCookies:Eo,dataPlaneEvents:yo,autoTrack:So},o={...E(Io)},os=/^\s*at /,bo=/^(eval@)?(\[native code])?$/,To=/(.+?)(?::(\d+))?(?::(\d+))?$/;function as(t){if(!t?.includes(":"))return[t||void 0,void 0,void 0];let e=t.startsWith("(")&&t.endsWith(")")?t.slice(1,-1):t,n=To.exec(e);return n?[n[1]||void 0,n[2]===void 0?void 0:Number(n[2]),n[3]===void 0?void 0:Number(n[3])]:[void 0,void 0,void 0]}function Ao(t){if(!os.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+/,""),n=/ (\(.+\)$)/.exec(e),s=n?e.replace(n[0],""):e,[i,r,a]=as(n?n[1]:e);return{functionName:n&&s||void 0,fileName:i==="eval"||i==="<anonymous>"?void 0:i,lineNumber:r,columnNumber:a}}function Ro(t){if(bo.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("@"),n=e>0?t.slice(0,e):void 0,[s,i,r]=as(t.slice(e+1));return{functionName:n,fileName:s,lineNumber:i,columnNumber:r}}function _o(t){if(!t.stack)throw new Error("Cannot parse given Error object");let e=t.stack.split(` `);return e.some(n=>os.test(n))?e.map(Ao).filter(n=>n!==null):e.map(Ro).filter(n=>n!==null)}var ls="global code",Oo=t=>A(t)&&/^global code$/i.test(t)?ls:t,No=t=>{let e={file:t.fileName,method:Oo(t.functionName),lineNumber:t.lineNumber,columnNumber:t.columnNumber};return e.lineNumber&&e.lineNumber>-1&&!e.file&&!e.method&&(e.file=ls),e},fn=t=>_(t)?t:"";function hn(t,e,n,s){return{errorClass:fn(t),message:`${n}${fn(e)}`,type:"browserjs",stacktrace:s.reduce((i,r)=>{let a=No(r);try{return JSON.stringify(a)==="{}"?i:i.concat(a)}catch{return i}},[])}}var cs=(t,e)=>{let n;return Gt(t)&&_(qe(t))?n=t:(e.warn(rr(Ae,K(t))),n=void 0),n},Po=(t,e)=>{try{let n=_o(t);return hn(t.name,t.message,e,n)}catch{return hn(t.name,t.message,e,[])}},pn=(t,e)=>{try{return JSON.parse(t||"")}catch(n){let s=Ht(n,"Failed to parse response data");e(s)}},Be="The request failed",Co=[/Failed to fetch dynamically imported module: .*/],Do=[/Unable to load \(.*\) the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],ko=[new RegExp(`${Be}.*`),/A script with the id .* is already loaded\./],Lo=[...Co,...Do],wo="integrations",Uo="sdk",Mo=Uo,$o={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},vn=(t,e,n)=>{let s=L($o,e||{});return n&&(s.headers=L(s.headers,{Authorization:n})),s.url=t,s},mn=(t,e=Di,n)=>new Promise((s,i)=>{let r;if(t.sendRawData===!0)r=t.data;else if(r=K(t.data,!1,[],n),G(r)){i({error:new Error(Zi),undefined:void 0,options:t});return}let a=new XMLHttpRequest,l=d=>{i({error:new Error(pr(Be,a.status,a.statusText,t.url,a.responseText)),xhr:a,options:t})},u=d=>{i({error:new Error(vr(Be,d,t.url)),xhr:a,options:t,...d?.type==="timeout"?{timedOut:!0}:{}})};a.ontimeout=u,a.onerror=u,a.onload=()=>{a.status>=200&&a.status<400?s({response:a.responseText,xhr:a,options:t}):l()},a.open(t.method,t.url,!0),t.withCredentials===!0&&(a.withCredentials=!0),a.timeout=e,Object.keys(t.headers).forEach(d=>{t.headers[d]&&a.setRequestHeader(d,t.headers[d])});try{a.send(r)}catch(d){i({error:Ht(d,mr(Be,t.url)),xhr:a,options:t})}}),Et=class{constructor(e){this.logger=e,this.onError=this.onError.bind(this)}init(e){this.errorHandler=e}async getData(e){let{url:n,options:s,timeout:i,isRawResponse:r}=e;try{let a=await mn(vn(n,s,this.basicAuthHeader),i,this.logger);return{data:r?a.response:pn(a.response,this.onError),details:a}}catch(a){return{data:void 0,details:a}}}getAsyncData(e){let{callback:n,url:s,options:i,timeout:r,isRawResponse:a}=e,l=!f(n);mn(vn(s,i,this.basicAuthHeader),r,this.logger).then(u=>{l||n(a?u.response:pn(u.response,this.onError),u)}).catch(u=>{l||n(void 0,u)})}onError(e,n){this.errorHandler?.onError({error:e,context:si,groupingHash:n})}setAuthHeader(e,n=!1){let s=n?e:ei(`${e}:`);this.basicAuthHeader=`Basic ${s}`}resetAuthHeader(){this.basicAuthHeader=void 0}},us=new Et(ne),Bo="1",xo=()=>["rsa"],Go=["www.test-host.com","localhost","127.0.0.1","[::1]"],Fo=["userId","userTraits","groupId","groupTraits","anonymousId","config","integration","eventBuffer","traits","authToken"],Vo="RudderStack JavaScript SDK",jo="git+https://github.com/rudderlabs/rudder-sdk-js.git",Ho="js",ds=t=>{o.capabilities.isAdBlockerDetectionInProgress.value=!0;try{let e=new URL(o.lifecycle.sourceConfigUrl.value),n=`${e.origin}${e.pathname}?view=ad`;t.getAsyncData({url:n,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(s,i)=>{o.capabilities.isAdBlockerDetectionInProgress.value=!1,o.capabilities.isAdBlocked.value=i?.error!==void 0||i?.xhr?.responseURL!==n}})}catch(e){throw o.capabilities.isAdBlockerDetectionInProgress.value=!1,e}},Ko=(t,e)=>{switch(e){case q.UNHANDLEDEXCEPTION:{let{error:n}=t;return n||t}case q.UNHANDLEDREJECTION:return t.reason;case q.HANDLEDEXCEPTION:default:return t}},Wo=t=>({type:"manual",name:t,timestamp:new Date,metaData:{}}),Qo=(t=()=>window.location.hostname)=>{let e=t();return!e||e&&Go.includes(e)?"development":"production"},zo=t=>{let e=K(t,!1,Fo);return e!==null?JSON.parse(e):{}},Xo=()=>globalThis.location.href.split("?")[0],Yo=(t,e,n,s)=>({id:`${t.value?.id??n.writeKey.value}..${e.sessionInfo.value.id??"NA"}..${s.pageLifecycle.pageViewId.value??"NA"}`,name:t.value?.name??"NA"}),qo=(t,e)=>({locale:t.value??"NA",userAgent:e.value??"NA",time:new Date}),Jo=(t,e,n,s)=>{let{context:i,lifecycle:r,session:a,source:l,reporting:u,autoTrack:d}=n,{app:p,locale:S,userAgent:R,timezone:g,screen:h,library:I}=i;return{payloadVersion:"5",notifier:{name:Vo,version:p.value.version,url:jo},events:[{exceptions:[E(t)],severity:e.severity,unhandled:e.unhandled,severityReason:e.severityReason,app:{version:p.value.version,releaseStage:Qo(),type:p.value.installType},device:qo(S,R),request:{url:Xo(),clientIp:"[NOT COLLECTED]"},breadcrumbs:E(u.breadcrumbs.value),context:t.message,groupingHash:s,metaData:{app:{snippetVersion:I.value.snippetVersion},device:{...h.value,timezone:g.value},...zo(n)},user:Yo(l,a,r,d)}]}},Zo=(t,e,n)=>{if(U(t.capabilities.isAdBlocked.value)){t.capabilities.isAdBlockerDetectionInProgress.value===!1&&ds(e);let s=X(()=>{A(t.capabilities.isAdBlocked.value)&&(n(t.capabilities.isAdBlocked.value===!1),s())})}else n(t.capabilities.isAdBlocked.value===!1)},ea=(t,e,n)=>{let s=t.message;return new Promise(i=>{if(Lo.some(r=>r.test(s))){let r=/https?:\/\/[^\s"'(),;<>[\]{}]+/.exec(s)?.[0];_(r)?r.startsWith(et)?e.capabilities.cspBlockedURLs.value.includes(r)?i(!1):Zo(e,n,i):i(!1):i(!0)}else i(!ko.some(r=>r.test(s)))})},gs=t=>t?t.split("/").at(-2):void 0,fs=t=>{let e=t.stacktrace[0]?.file;if(!(!e||typeof e!="string"))return e},ta=t=>{let e=fs(t);if(!e)return!1;let n=e.substring(e.lastIndexOf("/")+1);return gs(e)===Ze||xo().some(i=>n.startsWith(i)&&n.endsWith(".js"))},na=(t,e)=>{if(e)return e;let n=fs(t);return gs(n)===Ze?wo:Mo},sa=(t,e,n)=>{let s={version:Bo,message_id:Ye(),source:{name:Ho,sdk_version:e.context.app.value.version,write_key:e.lifecycle.writeKey.value,install_type:e.context.app.value.installType,category:n},errors:t};return K(s)},ia=(t,e,n)=>{let s;if(!A(t))s=e;else if(_(t))s=t;else{let i=cs(t,n);A(i)?s=i.message:s=e}return s},yt=class{constructor(e,n){N(this,"initialized",!1);this.httpClient=e,this.logger=n}init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError({error:e,context:Ae,errorType:q.UNHANDLEDEXCEPTION})}),globalThis.addEventListener("unhandledrejection",e=>{this.onError({error:e,context:Ae,errorType:q.UNHANDLEDREJECTION})}),document.addEventListener("securitypolicyviolation",e=>{let n=_(e.blockedURI)?e.blockedURI:"";e.disposition==="enforce"&&n.startsWith(et)&&!o.capabilities.cspBlockedURLs.value.includes(n)&&(o.capabilities.cspBlockedURLs.value=[...o.capabilities.cspBlockedURLs.value,n])})}async onError(e){try{let{error:n,context:s,customMessage:i,groupingHash:r,category:a}=e,l=e.errorType??q.HANDLEDEXCEPTION,u=Ko(n,l),d=cs(u,this.logger);if(U(d))return;let p=i?`${i} - `:"",S=`${s}${v}${p}`,R=Po(d,S),h=qe(d).includes(Vn);if(!h&&!ta(R)&&l!==q.HANDLEDEXCEPTION)return;if(o.reporting.isErrorReportingEnabled.value&&await ea(R,o,this.httpClient)){let m={severity:"error",unhandled:l!==q.HANDLEDEXCEPTION,severityReason:{type:l}},D=ia(r,R.message,this.logger),k=Jo(R,m,o,D),Se=na(R,a);this.httpClient.getAsyncData({url:o.metrics.metricsServiceUrl.value,options:{method:"POST",data:sa(k,o,Se),sendRawData:!0},isRawResponse:!0})}(l===q.HANDLEDEXCEPTION||h)&&this.logger.error(R.message)}catch(n){this.logger.error(or(Ae),n)}}leaveBreadcrumb(e){try{o.reporting.breadcrumbs.value=[...o.reporting.breadcrumbs.value,Wo(e)]}catch(n){this.onError({error:n,context:Ae,customMessage:un,groupingHash:un})}}},hs=new yt(us,ne),St=class{constructor(e,n={}){N(this,"plugins",[]);N(this,"byName",{});N(this,"cache",{});N(this,"config",{throws:!0});this.config={throws:!0,...n},this.logger=e}register(e,n){if(!e.name){let i=ar(de);if(this.config.throws)throw new Error(i);this.logger.error(i,e);return}if(this.byName[e.name]){let i=lr(de,e.name);if(this.config.throws)throw new Error(i);this.logger.error(i);return}this.cache={},this.plugins=this.plugins.slice();let s=this.plugins.length;this.plugins.forEach((i,r)=>{i.deps?.includes(e.name)&&(s=Math.min(s,r))}),this.plugins.splice(s,0,e),this.byName[e.name]=e,f(e.initialize)&&e.initialize(n)}unregister(e){let n=this.byName[e];if(!n){let i=cr(de,e);if(this.config.throws)throw new Error(i);this.logger.error(i);return}let s=this.plugins.indexOf(n);if(s===-1){let i=ur(de,e);if(this.config.throws)throw new Error(i);this.logger.error(i);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 n=e??".";return this.cache[n]||(this.cache[n]=this.plugins.filter(s=>{if(s.deps?.some(i=>!this.byName[i])){let i=s.deps.filter(r=>!this.byName[r]);return this.logger.error(dr(de,s.name,i)),!1}return n==="."?!0:zs(s,n)})),this.cache[n]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e,n=!0,...s){let i=e;if(!i)throw new Error(er);let r=i.startsWith("!"),a=this.config.throws??i.endsWith("!");if(i=i.replace(/(^!|!$)/g,""),!i)throw new Error(tr);let l=i.split(".");l.pop();let u=l.join(".");return(n?this.getPlugins(i):[this.getPlugins(i)[0]]).map(p=>{let S=ut(p,i);if(!f(S)||r)return S;try{return S.apply(ut(p,u),s)}catch(R){if(a)throw R;this.logger.error(gr(de,i,p.name),R)}return null})}invokeSingle(e,...n){return this.invoke(e,!1,...n)[0]}invokeMultiple(e,...n){return this.invoke(e,!0,...n)}},ra=new St(ne,{throws:!0}),oa=t=>t.config.connectionMode!=="cloud"||t.config.useNativeSDKToSend===!0||t.config.useNativeSDK===!0,aa=t=>t.config.connectionMode==="hybrid"||t.config.useNativeSDKToSend===!0,En=t=>t.filter(oa),la=(t,e)=>`${t.replaceAll(" ","-")}___${e}`,ps=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],ca=["Bugsnag","ErrorReporting"],ua={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"}};function vs(t,e){let n=Object.assign(t,e);for(let s of Object.keys(n))typeof n[s]=="object"&&typeof e[s]=="object"&&(n[s]=vs(n[s],e[s]));return n}var da=t=>vs({},(globalThis.__federation_shared__||{}).default||{});async function ga(t){let e=ua[t];if(e.inited)return e.lib;if(["esm","systemjs"].includes(e.format))return new Promise((n,s)=>{(typeof e.url=="function"?e.url:()=>Promise.resolve(e.url))().then(r=>{import(r).then(a=>{if(!e.inited){let l=da();a.init(l),e.lib=a,e.lib.init(l),e.inited=!0}n(e.lib)}).catch(s)})})}function $(t,e){if(!t?.default&&e){let n=Object.create(null);return n.default=t,n.__esModule=!0,n}return t}function B(t,e){return ga(t).then(n=>n.get(e).then(s=>s()))}var fa=t=>{switch(t){case"BeaconQueue":return()=>B("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>$(e,!0));case"CustomConsentManager":return()=>B("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>$(e,!0));case"DeviceModeDestinations":return()=>B("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>$(e,!0));case"DeviceModeTransformation":return()=>B("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>$(e,!0));case"ExternalAnonymousId":return()=>B("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>$(e,!0));case"GoogleLinker":return()=>B("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>$(e,!0));case"KetchConsentManager":return()=>B("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>$(e,!0));case"IubendaConsentManager":return()=>B("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>$(e,!0));case"NativeDestinationQueue":return()=>B("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>$(e,!0));case"OneTrustConsentManager":return()=>B("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>$(e,!0));case"StorageEncryption":return()=>B("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>$(e,!0));case"StorageEncryptionLegacy":return()=>B("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>$(e,!0));case"StorageMigrator":return()=>B("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>$(e,!0));case"XhrQueue":return()=>B("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>$(e,!0));default:return}},ha=t=>{let e={};return t.forEach(n=>{if(ps.includes(n)){let s=fa(n);s&&(e[n]=s)}}),e},ms=()=>({}),pa=()=>({}),va=t=>ha?.(t)||{},rt={...ms(),...pa()},ma=t=>({...va(t)}),It=class{constructor(e,n,s){this.engine=e,this.errorHandler=n,this.logger=s,this.onError=this.onError.bind(this)}init(){o.lifecycle.status.value="pluginsLoading",Pe("pluginsCDNPath",o.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){X(()=>{(o.plugins.activePlugins.value.length===0||o.plugins.loadedPlugins.value.length+o.plugins.failedPlugins.value.length===o.plugins.totalPluginsToLoad.value)&&w(()=>{o.plugins.ready.value=!0,o.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=o.plugins.pluginsToLoadFromConfig.value;if(!e)return[];e=e.filter(i=>ca.includes(i)?(this.logger.warn(Vr(Ie,i)),!1):!0);let n=[{configurationStatus:()=>A(o.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:o.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(qr),shouldAddMissingPlugins:!0},{configurationStatus:()=>En(o.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>En(o.nativeDestinations.configuredDestinations.value).some(i=>i.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>A(o.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:o.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(mt)},{configurationStatus:()=>A(o.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:o.storage.encryptionPluginName.value,supportedPlugins:Object.values($e)},{configurationStatus:()=>o.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}],s=!1;return n.forEach(i=>{i.configurationStatus()?(e=e.filter(i.activePluginName?r=>!(r!==i.activePluginName&&i.supportedPlugins.includes(r)):r=>A(r)),this.addMissingPlugins(i,s,e)):e=e.filter(i.basePlugins!==void 0?r=>!(i.basePlugins.includes(r)||i.supportedPlugins.includes(r)):r=>!i.supportedPlugins.includes(r))}),[...Object.keys(ms()),...e]}addMissingPlugins(e,n,s){let i=e.shouldAddMissingPlugins||n,r;e.activePluginName?r=[...e.basePlugins||[],e.activePluginName]:r=[...e.supportedPlugins];let a=r.filter(l=>!s.includes(l));a.length>0&&(i&&s.push(...a),this.logger.warn(jr(Ie,e.configurationStatusStr,a,i)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),n=[...Object.keys(rt),...ps],s=[],i=[];e.forEach(r=>{n.includes(r)?s.push(r):i.push(r)}),i.length>0&&this.logger.warn(Wr(Ie,i)),w(()=>{o.plugins.totalPluginsToLoad.value=e.length,o.plugins.activePlugins.value=s,o.plugins.failedPlugins.value=i})}registerLocalPlugins(){let e=[];Object.entries(rt).forEach(([n,s])=>{o.plugins.activePlugins.value.includes(n)&&(f(s)?this.register([s()]):e.push(n))}),e.length>0&&(o.plugins.failedPlugins.value=[...o.plugins.failedPlugins.value,...e],this.logger.error(Qr(Ie,e)))}registerRemotePlugins(){let e=ma(o.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async n=>{await e[n]().then(s=>this.register([s.default()])).catch(s=>{o.plugins.failedPlugins.value=[...o.plugins.failedPlugins.value,n],this.onError(s,`Failed to load plugin "${n}"`,s)})})).catch(n=>{this.onError(n)})}invokeMultiple(e,...n){try{return this.engine.invokeMultiple(e,...n)}catch(s){return this.onError(s,e),[]}}invokeSingle(e,...n){try{return this.engine.invokeSingle(e,...n)}catch(s){return this.onError(s,e),null}}register(e){e.forEach(n=>{try{this.engine.register(n,o)}catch(s){o.plugins.failedPlugins.value=[...o.plugins.failedPlugins.value,n.name],this.onError(s,`Failed to register plugin "${n.name}"`)}})}unregisterLocalPlugins(){Object.keys(rt).forEach(e=>{try{this.engine.unregister(e)}catch(n){this.onError(n,`Failed to unregister plugin "${e}"`)}})}onError(e,n,s){this.errorHandler.onError({error:e,context:Ie,customMessage:n,groupingHash:s})}},x="cookieStorage",F="localStorage",V="sessionStorage",z="memoryStorage",ue="none",Ea="test_rudder_cookie",ya="test_rudder_ls",Sa="test_rudder_ss",Ia="rl_user_id",ba="rl_trait",Ta="rl_anonymous_id",Aa="rl_group_id",Ra="rl_group_trait",_a="rl_page_init_referrer",Oa="rl_page_init_referring_domain",Na="rl_session",Pa="rl_auth_token",ge={userId:Ia,userTraits:ba,anonymousId:Ta,groupId:Aa,groupTraits:Ra,initialReferrer:_a,initialReferringDomain:Oa,sessionInfo:Na,authToken:Pa},Ca="__tld__",Es="clientDataInCookie",ys="clientDataInLocalStorage",Da="clientDataInMemory",Ss="clientDataInSessionStorage",Is=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],fe={[x]:Es,[F]:ys,[z]:Da,[V]:Ss},yn=(t,e)=>{try{return encodeURIComponent(t)}catch(n){e?.error(mi,n);return}},Sn=t=>{try{return decodeURIComponent(t)}catch{return}},ka=t=>{let e={},n=t.split