"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[39440],{85508:(e,t,n)=>{function i(e){return null!=e&&"object"==typeof e&&!0===e["@@functional/placeholder"]}function r(e){return function t(n){return 0==arguments.length||i(n)?t:e.apply(this,arguments)}}function o(e){return function t(n,o){switch(arguments.length){case 0:return t;case 1:return i(n)?t:r(function(t){return e(n,t)});default:return i(n)&&i(o)?t:i(n)?r(function(t){return e(t,o)}):i(o)?r(function(t){return e(n,t)}):e(n,o)}}}function a(e){return function t(n,a,s){switch(arguments.length){case 0:return t;case 1:return i(n)?t:o(function(t,i){return e(n,t,i)});case 2:return i(n)&&i(a)?t:i(n)?o(function(t,n){return e(t,a,n)}):i(a)?o(function(t,i){return e(n,t,i)}):r(function(t){return e(n,a,t)});default:return i(n)&&i(a)&&i(s)?t:i(n)&&i(a)?o(function(t,n){return e(t,n,s)}):i(n)&&i(s)?o(function(t,n){return e(t,a,n)}):i(a)&&i(s)?o(function(t,i){return e(n,t,i)}):i(n)?r(function(t){return e(t,a,s)}):i(a)?r(function(t){return e(n,t,s)}):i(s)?r(function(t){return e(n,a,t)}):e(n,a,s)}}}function s(e,t){return Object.prototype.hasOwnProperty.call(t,e)}n.d(t,{RudderAnalytics:()=>oj});var l,u,c,d=r(function(e){return null===e?"Null":void 0===e?"Undefined":Object.prototype.toString.call(e).slice(8,-1)});function g(e){return"[object Object]"===Object.prototype.toString.call(e)}let h=Number.isInteger||function(e){return e<<0===e};var v=function(){function e(){this.map={},this.length=0}return e.prototype.set=function(e,t){var n=this.hash(e),i=this.map[n];i||(this.map[n]=i=[]),i.push([e,t]),this.length+=1},e.prototype.hash=function(e){var t=[];for(var n in e)t.push(Object.prototype.toString.call(e[n]));return t.join()},e.prototype.get=function(e){if(this.length<=180){for(var t in this.map)for(var n=this.map[t],i=0;i"function"==typeof e&&!!(e.constructor&&e.call&&e.apply),I=e=>"string"==typeof e,S=e=>null===e,T=e=>void 0===e,A=e=>S(e)||T(e),w=e=>"bigint"==typeof e,C=e=>!T(e),P=e=>!A(e),O=e=>P(e)&&""!==e,D=e=>{switch(Object.prototype.toString.call(e)){case"[object Error]":case"[object Exception]":case"[object DOMException]":return!0;default:return e instanceof Error}},R=(e,t)=>b(t.split("."),e),N=(e,t)=>!!R(e,t),L=e=>"object"==typeof e,M=e=>!S(e)&&L(e)&&!Array.isArray(e),x=e=>!S(e)&&"[object Object]"===Object.prototype.toString.call(e),B=(e,t)=>{if(!Array.isArray(e)||!Array.isArray(t))return p(t);let n=p(e);return t.forEach((e,t)=>{n[t]=Array.isArray(e)||M(e)?U(n[t],e):e}),n},U=(e,t)=>m(B,e,t),j=e=>x(e)&&Object.keys(e).length>0,_=e=>{let t=E(C,e);return Object.keys(t).forEach(e=>{let n=t[e];x(n)&&(t[e]=_(n))}),t},H=e=>{let t=E(P,e);return Object.keys(t).forEach(e=>{let n=t[e];x(n)&&(t[e]=H(n))}),t},F=e=>{if(j(e))return H(e)},G=(e,t)=>C(t)?C(e)?!0===e:t:!0===e,Q=e=>e.replace(/^\s+|\s+$/gm,""),K=e=>e.replace(/^\.+/,""),z=e=>{let t=e;if(!I(e)&&!A(e))try{t=JSON.stringify(e)}catch(e){t=null}return t},V=e=>globalThis.btoa(Array.from(e,e=>String.fromCodePoint(e)).join("")),q=e=>V(new TextEncoder().encode(e)),W=(e,t,n,i,r)=>{let o={category:e,name:t,properties:n,options:i,callback:void 0};k(r)&&(o.callback=r),k(i)&&(o.category=e,o.name=t,o.properties=n,o.options=void 0,o.callback=i),k(n)&&(o.category=e,o.name=t,o.properties=void 0,o.options=void 0,o.callback=n),k(t)&&(o.category=e,o.name=void 0,o.properties=void 0,o.options=void 0,o.callback=t),k(e)&&(o.category=void 0,o.name=void 0,o.properties=void 0,o.options=void 0,o.callback=e),x(e)?(o.name=void 0,o.category=void 0,o.properties=e,k(t)?o.options=void 0:o.options=t):x(t)&&(o.name=void 0,o.properties=t,k(n)?o.options=void 0:o.options=n),I(e)&&!I(t)&&(o.category=void 0,o.name=e),C(o.category)||(o.category=void 0),C(o.name)||(o.name=void 0),o.properties=o.properties?p(o.properties):{},C(o.options)?o.options=p(o.options):o.options=void 0;let a=I(o.name)?o.name:o.properties.name,s=I(o.category)?o.category:o.properties.category;return o.properties=U(x(o.properties)?o.properties:{},{...a&&{name:a},...s&&{category:s}}),o},J=(e,t,n,i)=>{let r={name:e,properties:t,options:n,callback:void 0};return k(i)&&(r.callback=i),k(n)&&(r.properties=t,r.options=void 0,r.callback=n),k(t)&&(r.properties=void 0,r.options=void 0,r.callback=t),r.properties=P(r.properties)?p(r.properties):{},C(r.options)?r.options=p(r.options):r.options=void 0,r},$=(e,t,n,i)=>{let r={userId:e,traits:t,options:n,callback:void 0};return k(i)&&(r.callback=i),k(n)&&(r.userId=e,r.traits=t,r.options=void 0,r.callback=n),k(t)&&(r.userId=e,r.traits=void 0,r.options=void 0,r.callback=t),(x(e)||S(e))&&(r.userId=null,r.traits=e,k(t)?r.options=void 0:r.options=t),r.userId=z(r.userId),x(r.traits)?r.traits=p(r.traits):r.traits=void 0,C(r.options)?r.options=p(r.options):r.options=void 0,r},X=(e,t,n,i)=>{let r={to:e,from:t,options:n,callback:void 0};return k(i)&&(r.callback=i),k(n)&&(r.to=e,r.from=t,r.options=void 0,r.callback=n),k(t)?(r.to=e,r.from=void 0,r.options=void 0,r.callback=t):(x(t)||S(t))&&(r.to=e,r.from=void 0,r.options=t),C(r.to)&&(r.to=z(r.to)),C(r.from)?r.from=z(r.from):r.from=void 0,C(r.options)?r.options=p(r.options):r.options=void 0,r},Z=(e,t,n,i)=>{let r={groupId:e,traits:t,options:n,callback:void 0};return k(i)&&(r.callback=i),k(n)&&(r.groupId=e,r.traits=t,r.options=void 0,r.callback=n),k(t)&&(r.groupId=e,r.traits=void 0,r.options=void 0,r.callback=t),(x(e)||S(e))&&(r.groupId=null,r.traits=e,k(t)?r.options=void 0:r.options=t),r.groupId=z(r.groupId),x(r.traits)?r.traits=p(r.traits):r.traits=void 0,C(r.options)?r.options=p(r.options):r.options=void 0,r},Y=function(e){return e.LOADED="Page Loaded",e.UNLOADED="Page Unloaded",e}({}),ee="CapabilitiesManager",et="ConfigManager",en="EventManager",ei="PluginsManager",er="UserSessionManager",eo="ErrorHandler",ea="PluginEngine",es="Ready".concat("API"),el="Load".concat("API"),eu="AnalyticsCore";for(var ec,ed=[],eg=0;eg<256;eg++)ed[eg]=(eg+256).toString(16).substring(1);for(var eh,ev=256,ep=[];ev--;)ep[ev]=(ev+256).toString(16).substring(1);let ef=()=>!A(globalThis.crypto)&&k(globalThis.crypto.getRandomValues),ey=()=>ef()?function(){if(!ec||eg+16>4096)ec=crypto.getRandomValues(new Uint8Array(4096)),eg=0;for(var e,t=0,n="";t<16;t++)e=ec[eg+t],6==t?n+=ed[15&e|64]:8==t?n+=ed[63&e|128]:n+=ed[e],1&t&&t>1&&t<11&&(n+="-");return eg+=16,n}():function(){var e,t=0,n="";if(!eh||ev+16>256){for(eh=Array(t=256);t--;)eh[t]=256*Math.random()|0;t=ev=0}for(;t<16;t++)e=eh[ev+t],6==t?n+=ep[15&e|64]:8==t?n+=ep[63&e|128]:n+=ep[e],1&t&&t>1&&t<11&&(n+="-");return ev++,n}(),em=e=>{let t=!1,n=!1;function i(){t||(t=!0,e(n),setTimeout(()=>{t=!1},0))}globalThis.addEventListener("beforeunload",()=>{n=!1,i()}),globalThis.addEventListener("blur",()=>{n=!0,i()}),globalThis.addEventListener("focus",()=>{t=!1}),document.addEventListener("pagehide",()=>{n="hidden"===document.visibilityState,i()}),document.addEventListener("visibilitychange",()=>{n=!0,"hidden"===document.visibilityState?i():t=!1})},eb=e=>e.toISOString(),eE=()=>eb(new Date),ek=e=>'A script with the id "'.concat(e,'" is already loaded. Skipping the loading of this script to prevent conflicts.'),eI=(e,t)=>'Failed to load the script with the id "'.concat(e,'" from URL "').concat(t,'".'),eS=(e,t,n)=>"A timeout of ".concat(n,' ms occurred while trying to load the script with id "').concat(e,'" from URL "').concat(t,'".'),eT=(e,t)=>"".concat(e).concat(":: ",'A circular reference has been detected in the object and the property "').concat(t,'" has been dropped from the output.'),eA="[Circular Reference]",ew=(e,t,n)=>{let i=[];return function(r,o){if((null==t||!t.includes(r))&&!(e&&A(o))){if("object"!=typeof o||S(o))return o;for(;i.length>0&&i[i.length-1]!==this;)i.pop();return i.includes(o)?(null==n||n.warn(eT("JSONStringify",r)),eA):(i.push(o),o)}}},eC=(e,t,n,i)=>{try{return JSON.stringify(e,ew(t,n,i))}catch(e){return null==i||i.warn("Failed to convert the value to a JSON string.",e),null}},eP=e=>{let t=[];return function(e,n){if(w(n))return"[BigInt]";for(;t.length>0&&t[t.length-1]!==this;)t.pop();return t.includes(n)?eA:(t.push(n),n)}},eO=(e,t)=>{let n=Array.isArray(e)?[]:{};for(let i in e)if(Object.hasOwnProperty.call(e,i)){let r=e[i],o=t.call(e,i,r);x(o)||Array.isArray(o)?n[i]=eO(o,t):n[i]=o}return n},eD=(e,t)=>{let n=eP(),i=n.call(e,"",e);return x(e)||Array.isArray(e)?eO(e,n):i},eR="[SDK DISPATCHED ERROR]",eN=e=>{var t;let{stack:n,stacktrace:i}=e,r=e["opera#sourceloc"],o=null!==(t=null!=n?n:i)&&void 0!==t?t:r;if(o&&"string"==typeof o)return o},eL=(e,t)=>{let n=e;return D(e)?n.message="".concat(t,": ").concat(e.message):n=Error("".concat(t,": ").concat(eC(e))),n},eM=e=>{if(D(e)){let t=eN(e);if(t){let{stack:n,stacktrace:i}=e,r=e["opera#sourceloc"];switch(t){case n:e.stack="".concat(n,"\n").concat(eR);break;case i:e.stacktrace="".concat(i,"\n").concat(eR);break;default:e["opera#sourceloc"]="".concat(r,"\n").concat(eR)}}}globalThis.dispatchEvent(new ErrorEvent("error",{error:e,bubbles:!0,cancelable:!0,composed:!0}))},ex="RudderLabs JavaScript SDK",eB="3.16.1",eU="RudderJS-Initiated",ej="preloadedEventsBuffer",e_="ajs_aid",eH="ajs_uid",eF="ajs_event",eG=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"app";globalThis.RudderStackGlobals||(globalThis.RudderStackGlobals={}),globalThis.RudderStackGlobals[e]||(globalThis.RudderStackGlobals[e]={})},eQ=function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"app";eG(n),globalThis.RudderStackGlobals[n][e]=t},eK=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"app";return eG(t),globalThis.RudderStackGlobals[t][e]},ez=(e,t)=>{let n={};return e.forEach((i,r)=>{r.startsWith(t)&&(n[r.substring(t.length)]=e.get(r))}),n},eV=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t={trait:"ajs_trait_",properties:"ajs_prop_"},n=new URLSearchParams(globalThis.location.search);n.get(eF)&&e.unshift(["track",n.get(eF),ez(n,t.properties)]),n.get(eH)&&e.unshift(["identify",n.get(eH),ez(n,t.trait)]),n.get(e_)&&e.unshift(["setAnonymousId",n.get(e_)])},eq=e=>{let t=[],n=0;for(;n{let t="consent",n=e.filter(e=>e[0]===t),i=e.filter(e=>e[0]!==t);e.splice(0,e.length,...n,...i)},eJ=e=>{let t=eK(ej)||[];eV(t),t.length>0&&(e.enqueuePreloadBufferEvents(t),eQ(ej,[]))},e$=(e,t)=>{let n,i=e.shift();if(k(t[i])){switch(i){case"page":n=W(...e);break;case"track":n=J(...e);break;case"identify":n=$(...e);break;case"alias":n=X(...e);break;case"group":n=Z(...e);break;default:t[i](...e)}n&&t[i](n)}},eX=function(e,t){let n=!(arguments.length>2)||void 0===arguments[2]||arguments[2],i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:null,r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,o=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},a=document.createElement("script");return a.type="text/javascript",a.onload=i,a.onerror=r,a.src=e,a.id=t,a.async=n,Object.keys(o).forEach(e=>{a.setAttribute(e,o[e])}),a.setAttribute("data-loader","RS_JS_SDK"),a},eZ=e=>{var t,n,i,r;let o=document.getElementsByTagName("head");if(o.length>0){null===(i=o[0])||void 0===i||i.insertBefore(e,null===(n=o[0])||void 0===n?void 0:n.firstChild);return}let a=document.getElementsByTagName("script");if(a.length>0&&(null===(t=a[0])||void 0===t?void 0:t.parentNode)){null===(r=a[0])||void 0===r||r.parentNode.insertBefore(e,a[0]);return}let s=document.createElement("head");s.appendChild(e);let l=document.getElementsByTagName("html")[0];null==l||l.insertBefore(s,l.firstChild)},eY=function(e,t,n){let i=!(arguments.length>3)||void 0===arguments[3]||arguments[3],r=arguments.length>4?arguments[4]:void 0;return new Promise((o,a)=>{document.getElementById(t)&&a(Error(ek(t)));try{let s;eZ(eX(e,t,i,()=>{globalThis.clearTimeout(s),o(t)},()=>{globalThis.clearTimeout(s),a(Error(eI(t,e)))},r)),s=globalThis.setTimeout(()=>{a(Error(eS(t,e,n)))},n)}catch(n){a(eL(n,eI(t,e)))}})};class e0{loadJSFile(e){let{url:t,id:n,timeout:i,async:r,callback:o,extraAttributes:a}=e,s=!k(o);eY(t,n,i||this.timeout,r,a).then(e=>{s||o(e)}).catch(e=>{this.onError(e),s||o()})}onError(e){this.errorHandler.onError(e,"ExternalSrcLoader")}constructor(e,t,n=1e4){this.errorHandler=e,this.logger=t,this.timeout=n,this.onError=this.onError.bind(this)}}var e1=Symbol.for("preact-signals");function e2(){if(e5>1)e5--;else{for(var e,t=!1;void 0!==e4;){var n=e4;for(e4=void 0,e8++;void 0!==n;){var i=n.o;if(n.o=void 0,n.f&=-3,!(8&n.f)&&tn(n))try{n.c()}catch(n){t||(e=n,t=!0)}n=i}}if(e8=0,e5--,t)throw e}}function e3(e){if(e5>0)return e();e5++;try{return e()}finally{e2()}}var e6=void 0,e4=void 0,e5=0,e8=0,e9=0;function e7(e){if(void 0!==e6){var t=e.n;if(void 0===t||t.t!==e6)return t={i:0,S:e,p:e6.s,n:void 0,t:e6,e:void 0,x:void 0,r:t},void 0!==e6.s&&(e6.s.n=t),e6.s=t,e.n=t,32&e6.f&&e.S(t),t;if(-1===t.i)return t.i=0,void 0!==t.n&&(t.n.p=t.p,void 0!==t.p&&(t.p.n=t.n),t.p=e6.s,t.n=void 0,e6.s.n=t,e6.s=t),t}}function te(e){this.v=e,this.i=0,this.n=void 0,this.t=void 0}function tt(e){return new te(e)}function tn(e){for(var t=e.s;void 0!==t;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function ti(e){for(var t=e.s;void 0!==t;t=t.n){var n=t.S.n;if(void 0!==n&&(t.r=n),t.S.n=t,t.i=-1,void 0===t.n){e.s=t;break}}}function tr(e){for(var t=e.s,n=void 0;void 0!==t;){var i=t.p;-1===t.i?(t.S.U(t),void 0!==i&&(i.n=t.n),void 0!==t.n&&(t.n.p=i)):n=t,t.S.n=t.r,void 0!==t.r&&(t.r=void 0),t=i}e.s=n}function to(e){te.call(this,void 0),this.x=e,this.s=void 0,this.g=e9-1,this.f=4}function ta(e){var t=e.u;if(e.u=void 0,"function"==typeof t){e5++;var n=e6;e6=void 0;try{t()}catch(t){throw e.f&=-2,e.f|=8,ts(e),t}finally{e6=n,e2()}}}function ts(e){for(var t=e.s;void 0!==t;t=t.n)t.S.U(t);e.x=void 0,e.s=void 0,ta(e)}function tl(e){if(e6!==this)throw Error("Out-of-order effect");tr(this),e6=e,this.f&=-2,8&this.f&&ts(this),e2()}function tu(e){this.x=e,this.u=void 0,this.s=void 0,this.o=void 0,this.f=32}function tc(e){var t=new tu(e);try{t.c()}catch(e){throw t.d(),e}return t.d.bind(t)}te.prototype.brand=e1,te.prototype.h=function(){return!0},te.prototype.S=function(e){this.t!==e&&void 0===e.e&&(e.x=this.t,void 0!==this.t&&(this.t.e=e),this.t=e)},te.prototype.U=function(e){if(void 0!==this.t){var t=e.e,n=e.x;void 0!==t&&(t.x=n,e.e=void 0),void 0!==n&&(n.e=t,e.x=void 0),e===this.t&&(this.t=n)}},te.prototype.subscribe=function(e){var t=this;return tc(function(){var n=t.value,i=e6;e6=void 0;try{e(n)}finally{e6=i}})},te.prototype.valueOf=function(){return this.value},te.prototype.toString=function(){return this.value+""},te.prototype.toJSON=function(){return this.value},te.prototype.peek=function(){var e=e6;e6=void 0;try{return this.value}finally{e6=e}},Object.defineProperty(te.prototype,"value",{get:function(){var e=e7(this);return void 0!==e&&(e.i=this.i),this.v},set:function(e){if(e!==this.v){if(e8>100)throw Error("Cycle detected");this.v=e,this.i++,e9++,e5++;try{for(var t=this.t;void 0!==t;t=t.x)t.t.N()}finally{e2()}}}}),(to.prototype=new te).h=function(){if(this.f&=-3,1&this.f)return!1;if(32==(36&this.f)||(this.f&=-5,this.g===e9))return!0;if(this.g=e9,this.f|=1,this.i>0&&!tn(this))return this.f&=-2,!0;var e=e6;try{ti(this),e6=this;var t=this.x();(16&this.f||this.v!==t||0===this.i)&&(this.v=t,this.f&=-17,this.i++)}catch(e){this.v=e,this.f|=16,this.i++}return e6=e,tr(this),this.f&=-2,!0},to.prototype.S=function(e){if(void 0===this.t){this.f|=36;for(var t=this.s;void 0!==t;t=t.n)t.S.S(t)}te.prototype.S.call(this,e)},to.prototype.U=function(e){if(void 0!==this.t&&(te.prototype.U.call(this,e),void 0===this.t)){this.f&=-33;for(var t=this.s;void 0!==t;t=t.n)t.S.U(t)}},to.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(var e=this.t;void 0!==e;e=e.x)e.t.N()}},Object.defineProperty(to.prototype,"value",{get:function(){if(1&this.f)throw Error("Cycle detected");var e=e7(this);if(this.h(),void 0!==e&&(e.i=this.i),16&this.f)throw this.v;return this.v}}),tu.prototype.c=function(){var e=this.S();try{if(8&this.f||void 0===this.x)return;var t=this.x();"function"==typeof t&&(this.u=t)}finally{e()}},tu.prototype.S=function(){if(1&this.f)throw Error("Cycle detected");this.f|=1,this.f&=-9,ta(this),ti(this),e5++;var e=e6;return e6=this,tl.bind(this,e)},tu.prototype.N=function(){2&this.f||(this.f|=2,this.o=e4,e4=this)},tu.prototype.d=function(){this.f|=8,1&this.f||ts(this)};class td{enqueue(e){this.items.push(e)}dequeue(){return 0===this.items.length?null:this.items.shift()}isEmpty(){return 0===this.items.length}size(){return this.items.length}clear(){this.items=[]}constructor(){this.items=[]}}let tg={LOG:0,INFO:1,DEBUG:2,WARN:3,ERROR:4,NONE:5},th="ERROR";class tv{log(){for(var e=arguments.length,t=Array(e),n=0;n0){let t="%c ".concat("RS SDK");this.scope&&(t="".concat(t," - ").concat(this.scope));let n=I(e[0])?e[0].trim():"",i=[t="".concat(t," %c ").concat(n),"font-weight: bold; background: black; color: white;","font-weight: normal;"];return I(e[0])||i.push(e[0]),i.push(...e.slice(1)),i}return e}constructor(e="LOG",t="",n=console){this.minLogLevel=tg[e],this.scope=t,this.logProvider=n}}let tp=new tv,tf=function(e){return e.HANDLEDEXCEPTION="handledException",e.UNHANDLEDEXCEPTION="unhandledException",e.UNHANDLEDREJECTION="unhandledPromiseRejection",e}({}),ty=["localStorage","memoryStorage","cookieStorage","sessionStorage","none"],tm="cookieStorage",tb="Unable to process/parse source configuration response",tE=e=>"".concat(e).concat(":: ",'The "getSourceConfig" load API option must be a function that returns valid source configuration data.'),tk=(e,t,n)=>"".concat(e).concat(":: ",'The base URL "').concat(n,'" for ').concat(t," is not valid."),tI=(e,t,n)=>"".concat(e).concat(":: ",'The consent manager "').concat(t,'" is not supported. Please choose one of the following supported consent managers: "').concat(Object.keys(n),'".'),tS=(e,t)=>"".concat(e).concat(":: ","Ignoring a non-error: ").concat(t,"."),tT=e=>"".concat(e).concat(":: ","Failed to log breadcrumb."),tA=e=>"".concat(e).concat(":: ","Failed to handle the error."),tw=e=>"".concat(e).concat(":: ","Plugin name is missing."),tC=(e,t)=>"".concat(e).concat(":: ",'Plugin "').concat(t,'" already exists.'),tP=(e,t)=>"".concat(e).concat(":: ",'Plugin "').concat(t,'" not found.'),tO=(e,t)=>"".concat(e).concat(":: ",'Plugin "').concat(t,'" not found in plugins but found in byName. This indicates a bug in the plugin engine. Please report this issue to the development team.'),tD=(e,t,n)=>"".concat(e).concat(":: ",'Plugin "').concat(t,'" could not be loaded because some of its dependencies "').concat(n,'" do not exist.'),tR=(e,t,n)=>"".concat(e).concat(":: ",'Failed to invoke the "').concat(t,'" extension point of plugin "').concat(n,'".'),tN=(e,t)=>"".concat(e).concat(":: ",'The "').concat(t,'" storage type is '),tL="Failed to fetch the source config",tM=(e,t)=>"".concat(e).concat(":: ",'The write key "').concat(t,'" is invalid. It must be a non-empty string. Please check that the write key is correct and try again.'),tx=(e,t)=>"".concat(e).concat(":: ",'The data plane URL "').concat(t,'" is invalid. It must be a valid URL string. Please check that the data plane URL is correct and try again.'),tB=e=>"".concat(e).concat(":: ","The provided callback parameter is not a function."),tU=(e,t,n,i,r)=>"".concat(e," with status ").concat(t," (").concat(n,") for URL: ").concat(i,". Response: ").concat(r.trim()),tj=(e,t,n)=>"".concat(e," due to timeout or no connection (").concat(t?t.type:"",") at the client side for URL: ").concat(n),t_=(e,t)=>"".concat(e," for URL: ").concat(t),tH=e=>'Failed to save the value for "'.concat(e,'" to storage'),tF=e=>'Failed to retrieve or parse data for "'.concat(e,'" from storage'),tG=e=>"The server responded with status ".concat(e," while setting the cookies. As a fallback, the cookies will be set client side."),tQ=e=>"The server failed to set the ".concat(e," cookie. As a fallback, the cookies will be set client side."),tK=(e,t,n)=>"".concat(e).concat(":: ",'The storage type "').concat(t,'" is not supported. Please choose one of the following supported types: "').concat(ty,'". The default type "').concat(n,'" will be used instead.'),tz=(e,t,n,i)=>"".concat(e).concat(":: ",'The storage encryption version "').concat(t,'" is not supported. Please choose one of the following supported versions: "').concat(Object.keys(n),'". The default version "').concat(i,'" will be used instead.'),tV=(e,t,n)=>"".concat(e).concat(":: ","The storage data migration has been disabled because the configured storage encryption version (").concat(t,") is not the latest (").concat(n,"). To enable storage data migration, please update the storage encryption version to the latest version."),tq=(e,t,n)=>"".concat(e).concat(":: ","The provided cookie domain (").concat(t,") does not match the current webpage's domain (").concat(n,"). Hence, the cookies will be set client-side."),tW=(e,t,n,i)=>"".concat(e).concat(":: ",'The "').concat(t,'" property defined under "').concat(n,'" is a reserved keyword. Please choose a different property name to avoid conflicts with reserved keywords (').concat(i,")."),tJ=e=>"".concat(e).concat(":: ",'Please make sure that the "context" property in the event API\'s "options" argument is a valid object literal with key-value pairs.'),t$=e=>"".concat(e).concat(":: ","The Beacon API is not supported by your browser. The events will be sent using XHR instead."),tX=(e,t,n)=>"".concat(e).concat(":: ",'The session timeout value "').concat(t,'" is not a number. The default timeout of ').concat(n," ms will be used instead."),tZ=e=>"".concat(e).concat(":: ","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."),tY=(e,t,n)=>"".concat(e).concat(":: ","The session timeout value ").concat(t," ms is less than the recommended minimum of ").concat(n," ms. Please consider increasing the timeout value to ensure optimal performance and reliability."),t0=(e,t,n)=>"".concat(e).concat(":: ","The provided session ID (").concat(t,') is either invalid, not a positive integer, or not at least "').concat(n,'" digits long. A new session ID will be auto-generated instead.'),t1=e=>"".concat(e).concat(":: ","The storage is either full or unavailable, so the data will not be persisted. Switching to in-memory storage."),t2=(e,t,n,i)=>"".concat(e).concat(":: ",'The storage type "').concat(n,'" is not available for entry "').concat(t,'". The SDK will initialize the entry with "').concat(i,'" storage type instead.'),t3=e=>"".concat(e).concat(":: ","The callback threw an exception"),t6=(e,t)=>"".concat(e).concat(":: ",'The provided source config URL "').concat(t,'" is invalid. Using the default source config URL instead.'),t4=(e,t)=>'Failed to load the polyfill script with ID "'.concat(e,'" from URL ').concat(t,"."),t5=(e,t,n)=>"".concat(e).concat(":: ",'The pre-consent storage strategy "').concat(t,'" is not supported. Please choose one of the following supported strategies: "none, session, anonymousId". The default strategy "').concat(n,'" will be used instead.'),t8=(e,t,n)=>"".concat(e).concat(":: ",'The pre-consent events delivery type "').concat(t,'" is not supported. Please choose one of the following supported types: "immediate, buffer". The default type "').concat(n,'" will be used instead.'),t9=(e,t)=>"".concat(e).concat(":: ").concat(t," plugin is deprecated. Please exclude it from the load API options."),t7=(e,t,n,i)=>{let r=1===n.length,o=r?" '".concat(n[0],"' plugin was"):" ['".concat(n.join("', '"),"'] plugins were"),a="".concat(e).concat(":: ").concat(t,", but").concat(o," not configured to load.");return i?"".concat(a," So, ").concat(r?"the plugin":"those plugins"," will be loaded automatically."):"".concat(a," Ignore if this was intentional. Otherwise, consider adding ").concat(r?"it":"them"," to the 'plugins' load API option.")},ne=(e,t)=>"".concat(e).concat(":: ",'The provided polyfill URL "').concat(t,'" is invalid. The default polyfill URL will be used instead.'),nt=e=>"The cookie data for ".concat(e," seems to be encrypted using SDK versions < v3. The data is dropped. This can potentially stem from using SDK versions < v3 on other sites or web pages that can share cookies with this webpage. We recommend using the same SDK (v3) version everywhere or avoid disabling the storage data migration."),nn=e=>"".concat(e).concat(":: ",'Page Unloaded event can only be tracked when the Beacon transport is active. Please enable "useBeacon" load API option.'),ni=(e,t)=>"".concat(e).concat(":: ","Ignoring unknown plugins: ").concat(t.join(", "),"."),nr={All:!0},no="js-integrations",na="plugins",ns=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_]*)?$"),nl="modern",nu="https://cdn.rudderlabs.com",nc="".concat(nu,"/").concat("v3","/").concat(nl,"/").concat(no),nd="".concat(nu,"/").concat("v3","/").concat(nl,"/").concat(na),ng="https://api.rudderstack.com",nh={iubenda:"IubendaConsentManager",oneTrust:"OneTrustConsentManager",ketch:"KetchConsentManager",custom:"CustomConsentManager"},nv={v3:"StorageEncryption",legacy:"StorageEncryptionLegacy"},np={xhr:"XhrQueue",beacon:"BeaconQueue"},nf=tt(p({configUrl:ng,loadIntegration:!0,sessions:{autoTrack:!0,timeout:18e5},sameSiteCookie:"Lax",polyfillIfRequired:!0,integrations:nr,useBeacon:!1,beaconQueueOptions:{},destinationsQueueOptions:{},queueOptions:{},lockIntegrationsVersion:!0,lockPluginsVersion:!0,uaChTrackLevel:"none",plugins:[],useGlobalIntegrationsConfigInEvents:!1,bufferDataPlaneEventsUntilReady:!1,dataPlaneEventsBufferTimeout:1e4,storage:{encryption:{version:"v3"},migrate:!0,cookie:{}},sendAdblockPage:!1,sameDomainCookiesOnly:!1,secureCookie:!1,sendAdblockPageOptions:{},useServerSideCookies:!1})),ny={userId:"",userTraits:{},anonymousId:"",groupId:"",groupTraits:{},initialReferrer:"",initialReferringDomain:"",sessionInfo:{},authToken:null},nm={autoTrack:!0,timeout:18e5},nb={userId:tt(ny.userId),userTraits:tt(ny.userTraits),anonymousId:tt(ny.anonymousId),groupId:tt(ny.groupId),groupTraits:tt(ny.groupTraits),initialReferrer:tt(ny.initialReferrer),initialReferringDomain:tt(ny.initialReferringDomain),sessionInfo:tt(ny.sessionInfo),authToken:tt(ny.authToken)},nE={isOnline:tt(!0),storage:{isLocalStorageAvailable:tt(!1),isCookieStorageAvailable:tt(!1),isSessionStorageAvailable:tt(!1)},isBeaconAvailable:tt(!1),isLegacyDOM:tt(!1),isUaCHAvailable:tt(!1),isCryptoAvailable:tt(!1),isIE11:tt(!1),isAdBlocked:tt(!1)},nk={isErrorReportingEnabled:tt(!1),isMetricsReportingEnabled:tt(!1),breadcrumbs:tt([])},nI=tt(void 0),nS={activeDataplaneUrl:tt(void 0),integrationsCDNPath:tt(nc),pluginsCDNPath:tt(nd),sourceConfigUrl:tt(void 0),status:tt(void 0),initialized:tt(!1),logLevel:tt(th),loaded:tt(!1),readyCallbacks:tt([]),writeKey:tt(void 0),dataPlaneUrl:tt(void 0)},nT={enabled:tt(!1),initialized:tt(!1),data:tt({}),activeConsentManagerPluginName:tt(void 0),preConsent:tt({enabled:!1}),postConsent:tt({}),resolutionStrategy:tt("and"),provider:tt(void 0),metadata:tt(void 0)},nA={retries:tt(0),dropped:tt(0),sent:tt(0),queued:tt(0),triggered:tt(0),metricsServiceUrl:tt(void 0)},nw={app:tt({name:ex,namespace:"com.rudderlabs.javascript",version:eB,installType:"npm"}),traits:tt(null),library:tt({name:ex,version:eB,snippetVersion:globalThis.RudderSnippetVersion}),userAgent:tt(null),device:tt(null),network:tt(null),os:tt({name:"",version:""}),locale:tt(null),screen:tt({density:0,width:0,height:0,innerWidth:0,innerHeight:0}),"ua-ch":tt(void 0),timezone:tt(void 0)},nC={configuredDestinations:tt([]),activeDestinations:tt([]),loadOnlyIntegrations:tt({}),failedDestinations:tt([]),loadIntegration:tt(!0),initializedDestinations:tt([]),clientDestinationsReady:tt(!1),integrationsConfig:tt({})},nP={toBeProcessedArray:tt([]),readyCallbacksArray:tt([])},nO={ready:tt(!1),loadedPlugins:tt([]),failedPlugins:tt([]),pluginsToLoadFromConfig:tt([]),activePlugins:tt([]),totalPluginsToLoad:tt(0)},nD={encryptionPluginName:tt(void 0),migrate:tt(!1),type:tt(void 0),cookie:tt(void 0),entries:tt({}),trulyAnonymousTracking:tt(!1)},nR={isEnabledServerSideCookies:tt(!1),dataServiceUrl:tt(void 0)},nN={eventsQueuePluginName:tt(void 0),deliveryEnabled:tt(!0)},nL={...p({capabilities:nE,consents:nT,context:nw,eventBuffer:nP,lifecycle:nS,loadOptions:nf,metrics:nA,nativeDestinations:nC,plugins:nO,reporting:nk,session:nb,source:nI,storage:nD,serverCookies:nR,dataPlaneEvents:nN,autoTrack:{enabled:tt(!1),pageLifecycle:{enabled:tt(!1),visitId:tt(void 0),pageLoadedTimestamp:tt(void 0)}}})};function nM(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var nx={exports:{}},nB={exports:{}};nB.exports,nx.exports;let nU=nM(function(){var e,t,n,i;if(u)return nx.exports;return u=1,e=function(){return l?nB.exports:(l=1,nB.exports=function(){function e(e){return e.charAt(0).toUpperCase()+e.substring(1)}function t(e){return function(){return this[e]}}var n=["isConstructor","isEval","isNative","isToplevel"],i=["columnNumber","lineNumber"],r=["fileName","functionName","source"],o=n.concat(i,r,["args"],["evalOrigin"]);function a(t){if(t)for(var n=0;n-1&&(t=t.replace(/eval code/g,"eval").replace(/(\(eval at [^()]*)|(,.*$)/g,""));var n=t.replace(/^\s+/,"").replace(/\(eval code/g,"(").replace(/^.*?\s+/,""),i=n.match(/ (\(.+\)$)/);n=i?n.replace(i[0],""):n;var r=this.extractLocation(i?i[1]:n);return new e({functionName:i&&n||void 0,fileName:["eval",""].indexOf(r[0])>-1?void 0:r[0],lineNumber:r[1],columnNumber:r[2],source:t})},this)},parseFFOrSafari:function(t){return t.stack.split("\n").filter(function(e){return!e.match(i)},this).map(function(t){if(t.indexOf(" > eval")>-1&&(t=t.replace(/ line (\d+)(?: > eval line \d+)* > eval:\d+:\d+/g,":$1")),-1===t.indexOf("@")&&-1===t.indexOf(":"))return new e({functionName:t});var n=/((.*".+"[^@]*)?[^@]*)(?:@)/,i=t.match(n),r=i&&i[1]?i[1]:void 0,o=this.extractLocation(t.replace(n,""));return new e({functionName:r,fileName:o[0],lineNumber:o[1],columnNumber:o[2],source:t})},this)},parseOpera:function(e){return!e.stacktrace||e.message.indexOf("\n")>-1&&e.message.split("\n").length>e.stacktrace.split("\n").length?this.parseOpera9(e):e.stack?this.parseOpera11(e):this.parseOpera10(e)},parseOpera9:function(t){for(var n=/Line (\d+).*script (?:in )?(\S+)/i,i=t.message.split("\n"),r=[],o=2,a=i.length;o/,"$2").replace(/\([^)]*\)/g,"")||void 0;return o.match(/\(([^)]*)\)/)&&(n=o.replace(/^[^(]+\(([^)]*)\)$/,"$1")),new e({functionName:a,args:void 0===n||"[arguments not available]"===n?void 0:n.split(","),fileName:r[0],lineNumber:r[1],columnNumber:r[2],source:t})},this)}},nx.exports}()),nj="global code",n_=e=>C(e)&&/^global code$/i.test(e)?nj:e,nH=e=>{let t={file:e.fileName,method:n_(e.functionName),lineNumber:e.lineNumber,columnNumber:e.columnNumber};return t.lineNumber&&t.lineNumber>-1&&!t.file&&!t.method&&(t.file=nj),t},nF=e=>I(e)?e:"";function nG(e,t,n,i){return{errorClass:nF(e),message:"".concat(n).concat(nF(t)),type:"browserjs",stacktrace:i.reduce((e,t)=>{let n=nH(t);try{if("{}"===JSON.stringify(n))return e;return e.concat(n)}catch(t){return e}},[])}}let nQ=(e,t)=>{let n;return D(e)&&I(eN(e))?n=e:(t.warn(tS(eo,eC(e))),n=void 0),n},nK=(e,t)=>{try{let n=nU.parse(e);return nG(e.name,e.message,t,n)}catch(n){return nG(e.name,e.message,t,[])}},nz=(e,t)=>{try{return JSON.parse(e||"")}catch(e){t(eL(e,"Failed to parse response data"))}},nV="The request failed",nq=[/Failed to fetch dynamically imported module: .*/],nW=[/Failed to load the script with the id .*/,/A timeout of \d+ ms occurred while trying to load the script with id .*/],nJ=[new RegExp("".concat(nV,".*")),/A script with the id .* is already loaded\./],n$={headers:{Accept:"application/json","Content-Type":"application/json;charset=UTF-8"},method:"GET"},nX=(e,t,n)=>{let i=U(n$,t||{});return n&&(i.headers=U(i.headers,{Authorization:n})),i.url=e,i},nZ=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:1e4,n=arguments.length>2?arguments[2]:void 0;return new Promise((i,r)=>{let o;if(!0===e.sendRawData)o=e.data;else if(S(o=eC(e.data,!1,[],n))){r({error:Error("Failed to prepare data for the request."),undefined,options:e});return}let a=new XMLHttpRequest,s=t=>{r({error:Error(tU(nV,a.status,a.statusText,e.url,a.responseText)),xhr:a,options:e})},l=t=>{r({error:Error(tj(nV,t,e.url)),xhr:a,options:e})};a.ontimeout=l,a.onerror=l,a.onload=()=>{a.status>=200&&a.status<400?i({response:a.responseText,xhr:a,options:e}):s()},a.open(e.method,e.url,!0),!0===e.withCredentials&&(a.withCredentials=!0),a.timeout=t,Object.keys(e.headers).forEach(t=>{e.headers[t]&&a.setRequestHeader(t,e.headers[t])});try{a.send(o)}catch(t){r({error:eL(t,t_(nV,e.url)),xhr:a,options:e})}})};class nY{init(e){this.errorHandler=e}async getData(e){let{url:t,options:n,timeout:i,isRawResponse:r}=e;try{let e=await nZ(nX(t,n,this.basicAuthHeader),i,this.logger);return{data:r?e.response:nz(e.response,this.onError),details:e}}catch(e){return{data:void 0,details:e}}}getAsyncData(e){let{callback:t,url:n,options:i,timeout:r,isRawResponse:o}=e,a=!k(t);nZ(nX(n,i,this.basicAuthHeader),r,this.logger).then(e=>{a||t(o?e.response:nz(e.response,this.onError),e)}).catch(e=>{a||t(void 0,e)})}onError(e){var t;null===(t=this.errorHandler)||void 0===t||t.onError(e,"HttpClient")}setAuthHeader(e){let t=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=t?e:q("".concat(e,":"));this.basicAuthHeader="Basic ".concat(n)}resetAuthHeader(){this.basicAuthHeader=void 0}constructor(e){this.logger=e,this.onError=this.onError.bind(this)}}let n0=new nY(tp),n1=()=>["rsa"],n2=["www.test-host.com","localhost","127.0.0.1","[::1]"],n3=["userId","userTraits","groupId","groupTraits","anonymousId","config","instance","eventBuffer","traits","authToken"],n6=(e,t)=>{switch(t){case tf.UNHANDLEDEXCEPTION:{let{error:t}=e;return t||e}case tf.UNHANDLEDREJECTION:return e.reason;case tf.HANDLEDEXCEPTION:default:return e}},n4=e=>({type:"manual",name:e,timestamp:new Date,metaData:{}}),n5=()=>{let e=globalThis.location.hostname;return e&&n2.includes(e)?"development":"production"},n8=e=>{let t=eC(e,!1,n3);return null!==t?JSON.parse(t):{}},n9=()=>globalThis.location.href.split("?")[0],n7=(e,t,n,i)=>{var r,o,a,s,l,u;return{id:"".concat(null!==(a=null===(r=e.value)||void 0===r?void 0:r.id)&&void 0!==a?a:n.writeKey.value,"..").concat(null!==(s=t.sessionInfo.value.id)&&void 0!==s?s:"NA","..").concat(null!==(l=i.pageLifecycle.visitId.value)&&void 0!==l?l:"NA"),name:null!==(u=null===(o=e.value)||void 0===o?void 0:o.name)&&void 0!==u?u:"NA"}},ie=(e,t)=>{var n,i;return{locale:null!==(n=e.value)&&void 0!==n?n:"NA",userAgent:null!==(i=t.value)&&void 0!==i?i:"NA",time:new Date}},it=(e,t,n)=>{let{context:i,lifecycle:r,session:o,source:a,reporting:s,autoTrack:l}=n,{app:u,locale:c,userAgent:d,timezone:g,screen:h,library:v}=i;return{payloadVersion:"5",notifier:{name:"RudderStack JavaScript SDK",version:u.value.version,url:"__REPOSITORY_URL__"},events:[{exceptions:[p(e)],severity:t.severity,unhandled:t.unhandled,severityReason:t.severityReason,app:{version:u.value.version,releaseStage:n5(),type:u.value.installType},device:ie(c,d),request:{url:n9(),clientIp:"[NOT COLLECTED]"},breadcrumbs:p(s.breadcrumbs.value),context:e.message,metaData:{app:{snippetVersion:v.value.snippetVersion},device:{...h.value,timezone:g.value},...n8(n)},user:n7(a,o,r,l)}]}},ii=e=>{let t=e.message;return nq.some(e=>e.test(t))||nW.some(e=>e.test(t))?t.includes(nu):!nJ.some(e=>e.test(t))},ir=e=>{var t;let n=null===(t=e.stacktrace[0])||void 0===t?void 0:t.file;if(!n||"string"!=typeof n)return!1;let i=n.substring(n.lastIndexOf("/")+1),r=n.split("/");return r[r.length-2]===no||n1().some(e=>i.startsWith(e)&&i.endsWith(".js"))},io=(e,t)=>eC({version:"1",message_id:ey(),source:{name:"js",sdk_version:t.context.app.value.version,write_key:t.lifecycle.writeKey.value,install_type:t.context.app.value.installType},errors:e});class ia{init(){this.initialized||(this.attachErrorListeners(),this.initialized=!0)}attachErrorListeners(){globalThis.addEventListener("error",e=>{this.onError(e,eo,void 0,tf.UNHANDLEDEXCEPTION)}),globalThis.addEventListener("unhandledrejection",e=>{this.onError(e,eo,void 0,tf.UNHANDLEDREJECTION)})}onError(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:tf.HANDLEDEXCEPTION;try{let r=n6(e,i),o=nQ(r,this.logger);if(T(o))return;let a="".concat(t).concat(":: ").concat(n?"".concat(n," - "):""),s=nK(o,a),l=eN(o).includes(eR);if(!l&&!ir(s)&&i!==tf.HANDLEDEXCEPTION)return;if(nL.reporting.isErrorReportingEnabled.value&&ii(s)){let e={severity:"error",unhandled:i!==tf.HANDLEDEXCEPTION,severityReason:{type:i}},t=it(s,e,nL);this.httpClient.getAsyncData({url:nL.metrics.metricsServiceUrl.value,options:{method:"POST",data:io(t,nL),sendRawData:!0},isRawResponse:!0})}(i===tf.HANDLEDEXCEPTION||l)&&this.logger.error(s.message)}catch(e){this.logger.error(tA(eo),e)}}leaveBreadcrumb(e){try{nL.reporting.breadcrumbs.value=[...nL.reporting.breadcrumbs.value,n4(e)]}catch(e){this.onError(e,tT(eo))}}constructor(e,t){this.initialized=!1,this.httpClient=e,this.logger=t}}let is=new ia(n0,tp);class il{register(e,t){if(!e.name){let t=tw(ea);if(this.config.throws)throw Error(t);this.logger.error(t,e);return}if(this.byName[e.name]){let t=tC(ea,e.name);if(this.config.throws)throw Error(t);this.logger.error(t);return}this.cache={},this.plugins=this.plugins.slice();let n=this.plugins.length;this.plugins.forEach((t,i)=>{var r;(null===(r=t.deps)||void 0===r?void 0:r.includes(e.name))&&(n=Math.min(n,i))}),this.plugins.splice(n,0,e),this.byName[e.name]=e,k(e.initialize)&&e.initialize(t)}unregister(e){let t=this.byName[e];if(!t){let t=tP(ea,e);if(this.config.throws)throw Error(t);this.logger.error(t);return}let n=this.plugins.indexOf(t);if(-1===n){let t=tO(ea,e);if(this.config.throws)throw Error(t);this.logger.error(t);return}this.cache={},delete this.byName[e],this.plugins=this.plugins.slice(),this.plugins.splice(n,1)}getPlugin(e){return this.byName[e]}getPlugins(e){let t=null!=e?e:".";return this.cache[t]||(this.cache[t]=this.plugins.filter(e=>{var n;if(null===(n=e.deps)||void 0===n?void 0:n.some(e=>!this.byName[e])){let t=e.deps.filter(e=>!this.byName[e]);return this.logger.error(tD(ea,e.name,t)),!1}return"."===t||N(e,t)})),this.cache[t]}processRawPlugins(e){e(this.plugins),this.cache={}}invoke(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1];for(var n,i=arguments.length,r=Array(i>2?i-2:0),o=2;o{let t=R(e,a);if(!k(t)||s)return t;try{return t.apply(R(e,c),r)}catch(t){if(l)throw t;this.logger.error(tR(ea,a,e.name),t)}return null})}invokeSingle(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i1?t-1:0),i=1;i"cloud"!==e.config.connectionMode||!0===e.config.useNativeSDKToSend||!0===e.config.useNativeSDK,id=e=>"hybrid"===e.config.connectionMode||!0===e.config.useNativeSDKToSend,ig=e=>e.filter(ic),ih=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],iv=["Bugsnag","ErrorReporting"],ip={rudderAnalyticsRemotePlugins:{url:()=>Promise.resolve(window.RudderStackGlobals&&window.RudderStackGlobals.app&&window.RudderStackGlobals.app.pluginsCDNPath?"".concat(window.RudderStackGlobals.app.pluginsCDNPath,"/rsa-plugins.js"):"https://cdn.rudderlabs.com/v3/modern/plugins//rsa-plugins.js"),format:"esm",from:"vite"}},iy=e=>(function e(t,n){let i=Object.assign(t,n);for(let t of Object.keys(i))"object"==typeof i[t]&&"object"==typeof n[t]&&(i[t]=e(i[t],n[t]));return i})({},(globalThis.__federation_shared__||{}).default||{});async function im(e){let t=ip[e];return t.inited?t.lib:["esm","systemjs"].includes(t.format)?new Promise((e,n)=>{("function"==typeof t.url?t.url:()=>Promise.resolve(t.url))().then(i=>{import(i).then(n=>{if(!t.inited){let e=iy();n.init(e),t.lib=n,t.lib.init(e),t.inited=!0}e(t.lib)}).catch(n)})}):void 0}function ib(e,t){if(!(null==e?void 0:e.default)&&t){let t=Object.create(null);return t.default=e,t.__esModule=!0,t}return e}function iE(e,t){return im(e).then(e=>e.get(t).then(e=>e()))}let ik=e=>{switch(e){case"BeaconQueue":return()=>iE("rudderAnalyticsRemotePlugins","./BeaconQueue").then(e=>ib(e,!0));case"CustomConsentManager":return()=>iE("rudderAnalyticsRemotePlugins","./CustomConsentManager").then(e=>ib(e,!0));case"DeviceModeDestinations":return()=>iE("rudderAnalyticsRemotePlugins","./DeviceModeDestinations").then(e=>ib(e,!0));case"DeviceModeTransformation":return()=>iE("rudderAnalyticsRemotePlugins","./DeviceModeTransformation").then(e=>ib(e,!0));case"ExternalAnonymousId":return()=>iE("rudderAnalyticsRemotePlugins","./ExternalAnonymousId").then(e=>ib(e,!0));case"GoogleLinker":return()=>iE("rudderAnalyticsRemotePlugins","./GoogleLinker").then(e=>ib(e,!0));case"KetchConsentManager":return()=>iE("rudderAnalyticsRemotePlugins","./KetchConsentManager").then(e=>ib(e,!0));case"IubendaConsentManager":return()=>iE("rudderAnalyticsRemotePlugins","./IubendaConsentManager").then(e=>ib(e,!0));case"NativeDestinationQueue":return()=>iE("rudderAnalyticsRemotePlugins","./NativeDestinationQueue").then(e=>ib(e,!0));case"OneTrustConsentManager":return()=>iE("rudderAnalyticsRemotePlugins","./OneTrustConsentManager").then(e=>ib(e,!0));case"StorageEncryption":return()=>iE("rudderAnalyticsRemotePlugins","./StorageEncryption").then(e=>ib(e,!0));case"StorageEncryptionLegacy":return()=>iE("rudderAnalyticsRemotePlugins","./StorageEncryptionLegacy").then(e=>ib(e,!0));case"StorageMigrator":return()=>iE("rudderAnalyticsRemotePlugins","./StorageMigrator").then(e=>ib(e,!0));case"XhrQueue":return()=>iE("rudderAnalyticsRemotePlugins","./XhrQueue").then(e=>ib(e,!0));default:return}},iI=e=>{let t={};return e.forEach(e=>{if(ih.includes(e)){let n=ik(e);n&&(t[e]=n)}}),t},iS=()=>({}),iT=e=>(null==iI?void 0:iI(e))||{},iA={...iS()},iw=e=>({...iT(e)});class iC{init(){nL.lifecycle.status.value="pluginsLoading",eQ("pluginsCDNPath",nL.lifecycle.pluginsCDNPath.value),this.setActivePlugins(),this.registerLocalPlugins(),this.registerRemotePlugins(),this.attachEffects()}attachEffects(){tc(()=>{(0===nL.plugins.activePlugins.value.length||nL.plugins.loadedPlugins.value.length+nL.plugins.failedPlugins.value.length===nL.plugins.totalPluginsToLoad.value)&&e3(()=>{nL.plugins.ready.value=!0,nL.lifecycle.status.value="pluginsReady"})})}getPluginsToLoadBasedOnConfig(){let e=nL.plugins.pluginsToLoadFromConfig.value;return e?(e=e.filter(e=>!iv.includes(e)||(this.logger.warn(t9(ei,e)),!1)),[{configurationStatus:()=>C(nL.dataPlaneEvents.eventsQueuePluginName.value),configurationStatusStr:"Data plane events delivery is enabled",activePluginName:nL.dataPlaneEvents.eventsQueuePluginName.value,supportedPlugins:Object.values(np),shouldAddMissingPlugins:!0},{configurationStatus:()=>ig(nL.nativeDestinations.configuredDestinations.value).length>0,configurationStatusStr:"Device mode destinations are connected to the source",supportedPlugins:["DeviceModeDestinations","NativeDestinationQueue"]},{configurationStatus:()=>ig(nL.nativeDestinations.configuredDestinations.value).some(e=>e.shouldApplyDeviceModeTransformation),configurationStatusStr:"Device mode transformations are enabled for at least one destination",supportedPlugins:["DeviceModeTransformation"]},{configurationStatus:()=>C(nL.consents.activeConsentManagerPluginName.value),configurationStatusStr:"Consent management is enabled",activePluginName:nL.consents.activeConsentManagerPluginName.value,supportedPlugins:Object.values(nh)},{configurationStatus:()=>C(nL.storage.encryptionPluginName.value),configurationStatusStr:"Storage encryption is enabled",activePluginName:nL.storage.encryptionPluginName.value,supportedPlugins:Object.values(nv)},{configurationStatus:()=>nL.storage.migrate.value,configurationStatusStr:"Storage migration is enabled",supportedPlugins:["StorageMigrator"]}].forEach(t=>{t.configurationStatus()?(e=e.filter(t.activePluginName?e=>!(e!==t.activePluginName&&t.supportedPlugins.includes(e)):e=>C(e)),this.addMissingPlugins(t,!1,e)):e=e.filter(void 0!==t.basePlugins?e=>!(t.basePlugins.includes(e)||t.supportedPlugins.includes(e)):e=>!t.supportedPlugins.includes(e))}),[...Object.keys(iS()),...e]):[]}addMissingPlugins(e,t,n){let i,r=e.shouldAddMissingPlugins||t,o=(e.activePluginName?[...e.basePlugins||[],e.activePluginName]:[...e.supportedPlugins]).filter(e=>!n.includes(e));o.length>0&&(r&&n.push(...o),this.logger.warn(t7(ei,e.configurationStatusStr,o,r)))}setActivePlugins(){let e=this.getPluginsToLoadBasedOnConfig(),t=[...Object.keys(iA),...ih],n=[],i=[];e.forEach(e=>{t.includes(e)?n.push(e):i.push(e)}),i.length>0&&this.logger.warn(ni(ei,i)),e3(()=>{nL.plugins.totalPluginsToLoad.value=e.length,nL.plugins.activePlugins.value=n,nL.plugins.failedPlugins.value=i})}registerLocalPlugins(){Object.values(iA).forEach(e=>{k(e)&&nL.plugins.activePlugins.value.includes(e().name)&&this.register([e()])})}registerRemotePlugins(){let e=iw(nL.plugins.activePlugins.value);Promise.all(Object.keys(e).map(async t=>{await e[t]().then(e=>this.register([e.default()])).catch(e=>{nL.plugins.failedPlugins.value=[...nL.plugins.failedPlugins.value,t],this.onError(e,t)})})).catch(e=>{this.onError(e)})}invokeMultiple(e){for(var t=arguments.length,n=Array(t>1?t-1:0),i=1;i1?t-1:0),i=1;i{try{this.engine.register(e,nL)}catch(t){nL.plugins.failedPlugins.value=[...nL.plugins.failedPlugins.value,e.name],this.onError(t)}})}unregisterLocalPlugins(){Object.values(iA).forEach(e=>{try{this.engine.unregister(e().name)}catch(e){this.onError(e)}})}onError(e,t){this.errorHandler.onError(e,ei,t)}constructor(e,t,n){this.engine=e,this.errorHandler=t,this.logger=n,this.onError=this.onError.bind(this)}}let iP="cookieStorage",iO="localStorage",iD="sessionStorage",iR="memoryStorage",iN="none",iL={userId:"rl_user_id",userTraits:"rl_trait",anonymousId:"rl_anonymous_id",groupId:"rl_group_id",groupTraits:"rl_group_trait",initialReferrer:"rl_page_init_referrer",initialReferringDomain:"rl_page_init_referring_domain",sessionInfo:"rl_session",authToken:"rl_auth_token"},iM="clientDataInCookie",ix="clientDataInLocalStorage",iB="clientDataInSessionStorage",iU=["userId","userTraits","anonymousId","groupId","groupTraits","initialReferrer","initialReferringDomain","sessionInfo","authToken"],ij={[iP]:iM,[iO]:ix,[iR]:"clientDataInMemory",[iD]:iB},i_=(e,t)=>{try{return encodeURIComponent(e)}catch(e){null==t||t.error("Failed to encode the cookie data.",e);return}},iH=e=>{try{return decodeURIComponent(e)}catch(e){return}},iF=e=>{let t,n={},i=e.split(/\s*;\s*/);return i[0]&&i.forEach(e=>{let i=(t=e.split("="))[0]?iH(t[0]):void 0;i&&(n[i]=t[1]?iH(t[1]):void 0)}),n},iG=(e,t,n,i)=>{let r={...n||{}},o="".concat(i_(e,i),"=").concat(i_(t,i));S(t)&&(r.maxage=-1),r.maxage&&(r.expires=new Date(+new Date+r.maxage)),r.path&&(o+="; path=".concat(r.path)),r.domain&&(o+="; domain=".concat(r.domain)),r.expires&&(o+="; expires=".concat(r.expires.toUTCString())),r.samesite&&(o+="; samesite=".concat(r.samesite)),r.secure&&(o+="; secure"),globalThis.document.cookie=o},iQ=()=>iF(globalThis.document.cookie),iK=e=>iQ()[e],iz=function(e,t,n,i){switch(arguments.length){case 4:case 3:case 2:return iG(e,t,n,i);case 1:if(e)return iK(e);return iQ();default:return iQ()}},iV=e=>{let t=document.createElement("a");return t.href=e,t.hostname},iq=e=>{var t;let n="function"!=typeof globalThis.URL?iV(e):new URL(e).hostname,i=null!==(t=null==n?void 0:n.split("."))&&void 0!==t?t:[],r=i[i.length-1],o=[];if(4===i.length&&r&&r===parseInt(r,10).toString())return o;if(i.length<=1)return i[0]&&-1!==i[0].indexOf("localhost")?["localhost"]:o;for(let e=i.length-2;e>=0;e-=1)o.push(i.slice(e).join("."));return o},iW=e=>{let t=iq(e);for(let e=0;e{let e=".".concat(iW(globalThis.location.href));return{maxage:31536e6,path:"/",domain:e&&"."!==e?e:void 0,samesite:"Lax",enabled:!0}},i$=()=>({enabled:!0}),iX=()=>({enabled:!0}),iZ=()=>({enabled:!0});class iY{configure(e){return this.options=U(this.options,null!=e?e:{}),this.isEnabled=!!this.options.enabled,this.options}setItem(e,t){return this.data[e]=t,this.length=Object.keys(this.data).length,t}getItem(e){return e in this.data?this.data[e]:null}removeItem(e){return e in this.data&&delete this.data[e],this.length=Object.keys(this.data).length,null}clear(){this.data={},this.length=0}key(e){var t;return null!==(t=this.keys()[e])&&void 0!==t?t:null}keys(){return Object.keys(this.data)}constructor(e){this.isEnabled=!0,this.length=0,this.data={},this.options=iZ(),this.logger=e}}let i0=new iY(tp);var i1={exports:{}};i1.exports;let i2=nM(function(){return c?i1.exports:(c=1,i1.exports=function(){function e(e){return e=JSON.stringify(e),!!/^\{[\s\S]*\}$/.test(e)}function t(e){if("string"==typeof e)try{return JSON.parse(e)}catch(t){return e}}function n(e){return"[object Function]"===({}).toString.call(e)}var i=function(e){var t="_Is_Incognit";try{e||(e=window.localStorage),e.setItem(t,"yes"),e.removeItem(t)}catch(t){var n={};n._data={},n.setItem=function(e,t){return n._data[e]=String(t)},n.getItem=function(e){return n._data.hasOwnProperty(e)?n._data[e]:void 0},n.removeItem=function(e){return delete n._data[e]},n.clear=function(){return n._data={}},e=n}finally{"yes"===e.getItem(t)&&e.removeItem(t)}return e}();function r(){if(!(this instanceof r))return new r}r.prototype={set:function(t,n){if(t&&!e(t))i.setItem(t,void 0===n||"function"==typeof n?n+"":JSON.stringify(n));else if(e(t))for(var r in t)this.set(r,t[r]);return this},get:function(e){if(void 0===e){var n={};return this.forEach(function(e,t){return n[e]=t}),n}if("?"===e.charAt(0))return this.has(e.substr(1));var r=arguments;if(r.length>1){for(var o={},a=0,s=r.length;a-1&&(n[t[i]]=this.get(t[i]));return n},len:function(){return i.length}};var o=null;function a(t,i){var s=arguments,l=null;if(o||(o=r()),0===s.length)return o.get();if(1===s.length){if("string"==typeof t)return o.get(t);if(e(t))return o.set(t)}if(2===s.length&&"string"==typeof t){if(!i)return o.remove(t);if(i&&"string"==typeof i)return o.set(t,i);i&&n(i)&&(l=null,l=i(t,o.get(t)),a.set(t,l))}if(2===s.length&&"[object Array]"===Object.prototype.toString.call(t)&&n(i))for(var u=0,c=t.length;u{let t=new URL(nL.lifecycle.sourceConfigUrl.value),n="".concat(t.origin).concat(t.pathname,"?view=ad");e.getAsyncData({url:n,options:{method:"HEAD",headers:{"Content-Type":void 0}},isRawResponse:!0,callback:(e,t)=>{var i;nL.capabilities.isAdBlocked.value=(null==t?void 0:t.error)!==void 0||(null==t?void 0:null===(i=t.xhr)||void 0===i?void 0:i.responseURL)!==n}})},i6=()=>!A(globalThis.crypto)&&k(globalThis.crypto.getRandomValues),i4=()=>!A(globalThis.navigator.userAgentData),i5=()=>!A(globalThis.navigator.sendBeacon)&&k(globalThis.navigator.sendBeacon),i8=()=>!!globalThis.navigator.userAgent.match(/Trident.*rv:11\./),i9=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"none";if("none"===t&&e(void 0),"default"===t&&e(navigator.userAgentData),"full"===t){var n;null===(n=navigator.userAgentData)||void 0===n||n.getHighEntropyValues(["architecture","bitness","brands","mobile","model","platform","platformVersion","uaFullVersion","fullVersionList","wow64"]).then(t=>{e(t)}).catch(()=>{e()})}},i7=()=>{let e=globalThis.document.createElement("div");return e.setAttribute("data-a-b","c"),!!e.dataset&&"c"===e.dataset.aB},re={URL:()=>!k(globalThis.URL)||!k(globalThis.URLSearchParams),Promise:()=>!k(globalThis.Promise),"Number.isNaN":()=>!k(globalThis.Number.isNaN),"Number.isInteger":()=>!k(globalThis.Number.isInteger),"Array.from":()=>!k(globalThis.Array.from),"Array.prototype.find":()=>!k(globalThis.Array.prototype.find),"Array.prototype.includes":()=>!k(globalThis.Array.prototype.includes),"String.prototype.endsWith":()=>!k(globalThis.String.prototype.endsWith),"String.prototype.startsWith":()=>!k(globalThis.String.prototype.startsWith),"String.prototype.includes":()=>!k(globalThis.String.prototype.includes),"String.prototype.replaceAll":()=>!k(globalThis.String.prototype.replaceAll),"String.fromCodePoint":()=>!k(globalThis.String.fromCodePoint),"Object.entries":()=>!k(globalThis.Object.entries),"Object.values":()=>!k(globalThis.Object.values),"Object.assign":()=>!k(globalThis.Object.assign),"Object.fromEntries":()=>!k(globalThis.Object.fromEntries),"Element.prototype.dataset":()=>!i7(),TextEncoder:()=>!k(globalThis.TextEncoder)||!k(globalThis.TextDecoder),requestAnimationFrame:()=>!k(globalThis.requestAnimationFrame)||!k(globalThis.cancelAnimationFrame),CustomEvent:()=>!k(globalThis.CustomEvent),"navigator.sendBeacon":()=>!k(globalThis.navigator.sendBeacon),ArrayBuffer:()=>!k(globalThis.Uint8Array),Set:()=>!k(globalThis.Set),atob:()=>!k(globalThis.atob)},rt=()=>{let e=Object.keys(re),t=!1;for(let n=0;n{let e={density:0,width:0,height:0,innerWidth:0,innerHeight:0};return{width:globalThis.screen.width,height:globalThis.screen.height,density:globalThis.devicePixelRatio,innerWidth:globalThis.innerWidth,innerHeight:globalThis.innerHeight}},ri=e=>{let t=["QuotaExceededError","NS_ERROR_DOM_QUOTA_REACHED"].includes(e.name)||[22,1014].includes(e.code);return e instanceof DOMException&&t},rr=function(){let e,t,n,i=arguments.length>0&&void 0!==arguments[0]?arguments[0]:iO,r=arguments.length>1?arguments[1]:void 0,o=arguments.length>2?arguments[2]:void 0,a=tN(ee,i),s="unavailable",l=!0;try{switch(i){case iR:return!0;case iP:e=r,t="test_rudder_cookie";break;case iO:e=null!=r?r:globalThis.localStorage,t="test_rudder_ls";break;case iD:e=null!=r?r:globalThis.sessionStorage,t="test_rudder_ss";break;default:return!1}if(e&&(e.setItem(t,"true"),e.getItem(t)))return e.removeItem(t),!0;l=!1}catch(e){l=!1,n=e,ri(e)&&(s="full")}return l||null==o||o.warn("".concat(a).concat(s,"."),n),!1};class ro{configure(e){return this.options=U(this.options,null!=e?e:{}),this.isSupportAvailable=rr(iO),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){i2.set(e,t),this.length=i2.len()}getItem(e){let t=i2.get(e);return T(t)?null:t}removeItem(e){i2.remove(e),this.length=i2.len()}clear(){i2.clear(),this.length=0}key(e){var t;return null!==(t=this.keys()[e])&&void 0!==t?t:null}keys(){return i2.keys()}constructor(e){this.isSupportAvailable=!0,this.isEnabled=!0,this.length=0,this.options=i$(),this.logger=e}}let ra=new ro(tp);class rs{configure(e){return this.options=U(this.options,null!=e?e:{}),this.isSupportAvailable=rr(iD),this.isSupportAvailable&&(this.store=globalThis.sessionStorage),this.isEnabled=!!(this.options.enabled&&this.isSupportAvailable),this.options}setItem(e,t){this.store&&(this.store.setItem(e,t),this.length=this.store.length)}getItem(e){if(!this.store)return null;let t=this.store.getItem(e);return T(t)?null:t}removeItem(e){this.store&&(this.store.removeItem(e),this.length=this.store.length)}clear(){var e;null===(e=this.store)||void 0===e||e.clear(),this.length=0}key(e){var t,n;return null!==(n=null===(t=this.store)||void 0===t?void 0:t.key(e))&&void 0!==n?n:null}keys(){let e=[];if(!this.store)return e;for(let t=0;t{switch(e){case iO:return ra;case iD:return rl;case iR:return i0;case iP:return rc;default:return i0}},rg=e=>{let t=rc.configure(e);nL.storage.cookie.value={maxage:t.maxage,path:t.path,domain:t.domain,samesite:t.samesite,expires:t.expires,secure:t.secure}},rh=e=>{ra.configure(e)},rv=e=>{i0.configure(e)},rp=e=>{rl.configure(e)},rf=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{};rg(e),rh(t),rv(n),rp(i)};class ry{createValidKey(e){let t,{name:n,id:i,validKeys:r,noKeyValidation:o,noCompoundKey:a}=this;return o?a?e:[n,i,e].join("."):(Object.values(r).forEach(r=>{r===e&&(t=a?e:[n,i,e].join("."))}),t)}swapQueueStoreToInMemoryEngine(){let{name:e,id:t,validKeys:n,noCompoundKey:i}=this,r=rd(iR);Object.keys(n).forEach(o=>{let a=this.get(n[o]),s=i?o:[e,t,o].join(".");r.setItem(s,a),this.remove(o)}),this.engine=r}set(e,t){let n=this.createValidKey(e);if(n)try{this.engine.setItem(n,this.encrypt(eC(t,!1,[],this.logger)))}catch(n){ri(n)?(this.logger.warn(t1("Store ".concat(this.id))),this.swapQueueStoreToInMemoryEngine(),this.set(e,t)):this.onError(eL(n,tH(e)))}}get(e){let t,n=this.createValidKey(e);try{if(!n||(t=this.decrypt(this.engine.getItem(n)),A(t)))return null;return JSON.parse(t)}catch(n){return this.onError(Error("".concat(tF(e),": ").concat(n.message))),I(t)&&t.startsWith("RudderEncrypt:")&&this.logger.warn(nt(e)),null}}remove(e){let t=this.createValidKey(e);t&&this.engine.removeItem(t)}getOriginalEngine(){return this.originalEngine}decrypt(e){return A(e)?null:this.crypto(e,"decrypt")}encrypt(e){return this.crypto(e,"encrypt")}crypto(e,t){if(!this.isEncrypted||!e||"string"!=typeof e||""===Q(e))return e;let n=this.pluginsManager?this.pluginsManager.invokeSingle("storage.".concat(t),e):e;return void 0===n?e:null!=n?n:""}onError(e){this.errorHandler.onError(e,"Store ".concat(this.id))}constructor(e,t,n){var i,r;this.id=e.id,this.name=e.name,this.isEncrypted=null!==(i=e.isEncrypted)&&void 0!==i&&i,this.validKeys=null!==(r=e.validKeys)&&void 0!==r?r:{},this.engine=t,this.noKeyValidation=0===Object.keys(this.validKeys).length,this.noCompoundKey=e.noCompoundKey,this.originalEngine=this.engine,this.errorHandler=e.errorHandler,this.logger=e.logger,this.pluginsManager=n}}let rm=(e,t)=>{let n;if(e.consents.preConsent.value.enabled){var i;switch(null===(i=e.consents.preConsent.value.storage)||void 0===i?void 0:i.strategy){case"none":n=iN;break;case"session":"sessionInfo"!==t&&(n=iN);break;case"anonymousId":"anonymousId"!==t&&(n=iN)}}return n};class rb{init(){var e,t,n;if(this.isInitialized)return;let i=nL.loadOptions.value,r={cookieStorageOptions:{samesite:i.sameSiteCookie,secure:i.secureCookie,domain:i.setCookieDomain,sameDomainCookiesOnly:i.sameDomainCookiesOnly},localStorageOptions:{},inMemoryStorageOptions:{},sessionStorageOptions:{}};rf(_(U(null!==(t=r.cookieStorageOptions)&&void 0!==t?t:{},null!==(n=null===(e=nL.storage.cookie)||void 0===e?void 0:e.value)&&void 0!==n?n:{})),_(r.localStorageOptions),_(r.inMemoryStorageOptions),_(r.sessionStorageOptions)),this.initClientDataStores(),this.isInitialized=!0}initClientDataStores(){this.initializeStorageState(),[iR,iO,iP,iD].forEach(e=>{var t;(null===(t=rd(e))||void 0===t?void 0:t.isEnabled)&&this.setStore({id:ij[e],name:ij[e],isEncrypted:!0,noCompoundKey:!0,type:e,errorHandler:this.errorHandler,logger:this.logger})})}initializeStorageState(){var e;let t=nL.storage.type.value,n=null===(e=nL.loadOptions.value.storage)||void 0===e?void 0:e.entries,i=nL.consents.postConsent.value.storage;(C(null==i?void 0:i.type)||C(null==i?void 0:i.entries))&&(t=null==i?void 0:i.type,n=null==i?void 0:i.entries);let r=!0,o={};iU.forEach(e=>{var i,a,s;let l=null==n?void 0:null===(i=n[e])||void 0===i?void 0:i.type,u=rm(nL,e),c=null!==(s=null!==(a=null!=u?u:l)&&void 0!==a?a:t)&&void 0!==s?s:tm,d=this.getResolvedStorageTypeForEntry(c,e);d!==iN&&(r=!1),o={...o,[e]:{type:d,key:iL[e]}}}),e3(()=>{nL.storage.type.value=t,nL.storage.entries.value=o,nL.storage.trulyAnonymousTracking.value=r})}getResolvedStorageTypeForEntry(e,t){var n,i,r,o,a;let s=e;switch(e){case iO:(null===(n=rd(iO))||void 0===n?void 0:n.isEnabled)||(s=iR);break;case iD:(null===(i=rd(iD))||void 0===i?void 0:i.isEnabled)||(s=iR);break;case iR:case iN:break;default:s=(null===(r=rd(iP))||void 0===r?void 0:r.isEnabled)?iP:(null===(o=rd(iO))||void 0===o?void 0:o.isEnabled)?iO:(null===(a=rd(iD))||void 0===a?void 0:a.isEnabled)?iD:iR}return s!==e&&this.logger.warn(t2("StoreManager",t,e,s)),s}setStore(e){let t=rd(e.type);return this.stores[e.id]=new ry(e,t,this.pluginsManager),this.stores[e.id]}getStore(e){return this.stores[e]}constructor(e,t,n){this.stores={},this.isInitialized=!1,this.errorHandler=t,this.logger=n,this.pluginsManager=e}}let rE=e=>x(e)&&x(e.source)&&!A(e.source.id)&&x(e.source.config)&&Array.isArray(e.source.destinations),rk=e=>"string"==typeof e&&ty.includes(e),rI=e=>{let t,{host:n,protocol:i}=new URL(e),r=n.split(".");return{topDomain:r.length>2?"".concat(r[r.length-2],".").concat(r[r.length-1]):n,protocol:i}},rS=e=>{let{topDomain:t,protocol:n}=rI(e);return"".concat(n,"//").concat(t)},rT=(e,t)=>{let n=t?window.location.origin:rS(window.location.href),i=e.startsWith("/")?e.substring(1):e;return"".concat(n,"/").concat(i)},rA=e=>{let{topDomain:t}=rI(window.location.href);return t===e},rw=e=>{let t=[];return e.forEach(e=>{e.enabled&&!e.deleted&&t.push({id:e.id,displayName:e.destinationDefinition.displayName,config:e.config,shouldApplyDeviceModeTransformation:e.shouldApplyDeviceModeTransformation||!1,propagateEventsUntransformedOnError:e.propagateEventsUntransformedOnError||!1,userFriendlyId:"".concat(e.destinationDefinition.displayName.replaceAll(" ","-"),"___").concat(e.id)})}),t},rC=e=>(null==e?void 0:e.endsWith("/"))?rC(e.substring(0,e.length-1)):e,rP=e=>{try{return new URL(e).host}catch(e){return null}},rO=e=>{var t;return null!==(t=rP(e))&&void 0!==t?t:""},rD=e=>{let t={};try{let n=new URL(e),i="utm_";n.searchParams.forEach((e,n)=>{if(n.startsWith(i)){let r=n.substring(i.length);"campaign"===r&&(r="name"),t[r]=e}})}catch(e){}return t},rR=e=>{let t=e;try{let n=new URL(e);t=n.origin+n.pathname+n.search}catch(e){}return t},rN=e=>e.replace(/\/{2,}/g,"/"),rL=e=>{if(!I(e))return!1;try{return k(globalThis.URL)&&new URL(e),ns.test(e)}catch(e){return!1}},rM=()=>{var e,t;return!!(null===(t=window.chrome)||void 0===t?void 0:null===(e=t.runtime)||void 0===e?void 0:e.id)},rx="none",rB="immediate",rU=e=>{var t,n;return(null==e?void 0:null===(n=e.statsCollection)||void 0===n?void 0:null===(t=n.errors)||void 0===t?void 0:t.enabled)===!0},rj=e=>{var t,n;return(null==e?void 0:null===(n=e.statsCollection)||void 0===n?void 0:null===(t=n.metrics)||void 0===t?void 0:t.enabled)===!0},r_=e=>{let t={sendPageEvent:!1,trackConsent:!1,discardPreConsentEvents:!1};if(x(e)){let n=p(e);t.storage=n.storage,j(n.integrations)&&(t.integrations=n.integrations),t.discardPreConsentEvents=!0===n.discardPreConsentEvents,t.sendPageEvent=!0===n.sendPageEvent,t.trackConsent=!0===n.trackConsent,j(n.consentManagement)&&(t.consentManagement=U(n.consentManagement,{enabled:nL.consents.enabled.value}))}return t},rH=e=>j(e)||Array.isArray(e),rF=(e,t)=>{let{provider:n}=e,i=n?nh[n]:void 0;return n&&!i&&(t.error(tI(et,n,nh)),n=void 0),{provider:n,consentManagerPluginName:i}},rG=(e,t)=>{let n,i,r=[],o=[],a=!1,s=(null==e?void 0:e.enabled)===!0;j(e)&&s&&({provider:i,consentManagerPluginName:n}=rF(e,t),rH(e.allowedConsentIds)&&(r=e.allowedConsentIds,a=!0),rH(e.deniedConsentIds)&&(o=e.deniedConsentIds,a=!0));let l={allowedConsentIds:r,deniedConsentIds:o};return s=s&&!!n,{provider:i,consentManagerPluginName:n,initialized:a,enabled:s,consentsData:l}},rQ=()=>{let e=document.querySelector("script[data-rsa-write-key]");if(e&&e.dataset.rsaWriteKey===nL.lifecycle.writeKey.value)return e.src;let t=document.getElementsByTagName("script"),n=/(?:^|\/)rsa(\.min)?\.js$/;for(let e of t){let t=e.getAttribute("src");if(t&&n.test(t))return t}},rK=e=>{nL.reporting.isErrorReportingEnabled.value=rU(e.source.config)&&!rM(),nL.reporting.isMetricsReportingEnabled.value=rj(e.source.config)},rz=e=>{let t,{useServerSideCookies:n,dataServiceEndpoint:i,storage:r,setCookieDomain:o,sameDomainCookiesOnly:a}=nL.loadOptions.value,s=null==r?void 0:r.cookie,l=!1;if(n){var u;l=n;let r=null!==(u=s.domain)&&void 0!==u?u:o,c=C(r)&&!rA(K(r))||a,d=rT(null!=i?i:"rsaRequest",c);if(rL(d)){t=rC(d);let n=rP(window.location.href),i=rP(d);n!==i&&(s={...s,samesite:"None",secure:!0}),!a&&c&&i!==K(r)&&(l=!1,e.warn(tq(et,r,i)))}else l=!1}return{sscEnabled:l,cookieOptions:s,finalDataServiceUrl:t}},rV=e=>{var t;let{storage:n}=nL.loadOptions.value,i=null==n?void 0:n.type;C(i)&&!rk(i)&&(e.warn(tK(et,i,tm)),i=tm);let r=null==n?void 0:null===(t=n.encryption)||void 0===t?void 0:t.version,o=r&&nv[r];!T(r)&&T(o)?(e.warn(tz(et,r,nv,"v3")),r="v3"):T(r)&&(r="v3");let a=null==n?void 0:n.migrate,s=a&&"v3"===r;!0===a&&s!==a&&e.warn(tV(et,r,"v3"));let{sscEnabled:l,finalDataServiceUrl:u,cookieOptions:c}=rz(e);e3(()=>{nL.storage.type.value=i,nL.storage.cookie.value=c,nL.serverCookies.isEnabledServerSideCookies.value=l,nL.serverCookies.dataServiceUrl.value=u,nL.storage.encryptionPluginName.value=nv[r],nL.storage.migrate.value=s})},rq=e=>{var t,n,i,r,o,a;let{provider:s,consentManagerPluginName:l,initialized:u,enabled:c,consentsData:d}=rG(nL.loadOptions.value.consentManagement,e),g=nL.loadOptions.value.preConsent,h=null!==(i=null==g?void 0:null===(t=g.storage)||void 0===t?void 0:t.strategy)&&void 0!==i?i:rx;C(h)&&!["none","session","anonymousId"].includes(h)&&(h=rx,e.warn(t5(et,null==g?void 0:null===(r=g.storage)||void 0===r?void 0:r.strategy,rx)));let v=null!==(o=null==g?void 0:null===(n=g.events)||void 0===n?void 0:n.delivery)&&void 0!==o?o:rB;C(v)&&!["immediate","buffer"].includes(v)&&(v=rB,e.warn(t8(et,null==g?void 0:null===(a=g.events)||void 0===a?void 0:a.delivery,rB))),e3(()=>{var e;nL.consents.activeConsentManagerPluginName.value=l,nL.consents.initialized.value=u,nL.consents.enabled.value=c,nL.consents.data.value=d,nL.consents.provider.value=s,nL.consents.preConsent.value={enabled:(null===(e=nL.loadOptions.value.preConsent)||void 0===e?void 0:e.enabled)===!0&&!1===u&&!0===c,storage:{strategy:h},events:{delivery:v}}})},rW=e=>{let t,n=nL.consents.resolutionStrategy.value;if(x(e.consentManagementMetadata)){if(nL.consents.provider.value){var i,r;n=null!==(r=null===(i=e.consentManagementMetadata.providers.find(e=>e.provider===nL.consents.provider.value))||void 0===i?void 0:i.resolutionStrategy)&&void 0!==r?r:nL.consents.resolutionStrategy.value}t=e.consentManagementMetadata}"custom"===nL.consents.provider.value&&(n=void 0),e3(()=>{nL.consents.metadata.value=p(t),nL.consents.resolutionStrategy.value=n})},rJ=e=>{if(nL.dataPlaneEvents.deliveryEnabled.value){let t="XhrQueue",n=t;nL.loadOptions.value.useBeacon&&(nL.capabilities.isBeaconAvailable.value?n="BeaconQueue":(n=t,e.warn(t$(et)))),e3(()=>{nL.dataPlaneEvents.eventsQueuePluginName.value=n})}},r$=(e,t,n,i,r)=>{let o=new URLSearchParams({p:"npm",v:eB,build:nl,writeKey:t,lockIntegrationsVersion:n.toString(),lockPluginsVersion:i.toString()}),a=ng,s=o,l="/sourceConfig/",u="";if(rL(e)){let t=new URL(e);rC(t.pathname).endsWith("/sourceConfig")||(t.pathname="".concat(rC(t.pathname),"/sourceConfig/")),t.pathname=rN(t.pathname),o.forEach((e,n)=>{null===t.searchParams.get(n)&&t.searchParams.set(n,e)}),a=t.origin,l=t.pathname,s=t.searchParams,u=t.hash}else r.warn(t6(et,e));return"".concat(a).concat(l,"?").concat(s).concat(u)},rX=(e,t,n,i,r,o,a)=>{let s;if(o){if(!rL(o))return a.error(tk(et,e,o)),null;s=rC(o)}else if(s=n,"cdn"===nL.context.app.value.installType){let e=rQ();e&&(s=e.split("/").slice(0,-1).concat(t).join("/"))}return r&&(s=s.replace(new RegExp("/".concat("v3","/").concat(nl,"/").concat(t,"$")),"/".concat(i,"/").concat(nl,"/").concat(t))),s},rZ=(e,t,n,i)=>rX("integrations",no,nc,e,t,n,i),rY=(e,t,n,i)=>rX("plugins",na,nd,e,t,n,i);class r0{attachEffects(){tc(()=>{this.logger.setMinLogLevel(nL.lifecycle.logLevel.value)})}init(){let e,{logLevel:t,configUrl:n,lockIntegrationsVersion:i,lockPluginsVersion:r,destSDKBaseURL:o,pluginsSDKBaseURL:a,integrations:s}=nL.loadOptions.value,l=rZ(eB,i,o,this.logger);!S(l)&&null!==(e=rY(eB,r,a,this.logger))&&(this.attachEffects(),nL.lifecycle.activeDataplaneUrl.value=rC(nL.lifecycle.dataPlaneUrl.value),rV(this.logger),rq(this.logger),rJ(this.logger),e3(()=>{nL.lifecycle.integrationsCDNPath.value=l,nL.lifecycle.pluginsCDNPath.value=e,t&&(nL.lifecycle.logLevel.value=t),nL.lifecycle.sourceConfigUrl.value=r$(n,nL.lifecycle.writeKey.value,i,r,this.logger),nL.metrics.metricsServiceUrl.value="".concat(nL.lifecycle.activeDataplaneUrl.value,"/").concat("rsaMetrics"),nL.nativeDestinations.loadOnlyIntegrations.value=s}),this.getConfig())}onError(e,t){this.errorHandler.onError(e,et,t)}processConfig(e,t){let n;if(!C(e)){C(t)?this.onError(t.error,tL):this.onError(Error(tL));return}try{n=I(e)?JSON.parse(e):e}catch(e){this.onError(e,tb);return}if(!rE(n)){this.onError(Error(tb));return}if(!1===n.source.enabled){this.logger.error("The source is disabled. Please enable the source in the dashboard to send events.");return}rK(n);let i=n.source.destinations.length>0?rw(n.source.destinations):[];e3(()=>{var e;nL.source.value={config:n.source.config,name:n.source.name,id:n.source.id,workspaceId:n.source.workspaceId},nL.nativeDestinations.configuredDestinations.value=i,nL.plugins.pluginsToLoadFromConfig.value=null!==(e=nL.loadOptions.value.plugins)&&void 0!==e?e:[],rW(n),nL.lifecycle.status.value="configured"})}getConfig(){let e=nL.loadOptions.value.getSourceConfig;if(e){if(!k(e)){this.logger.error(tE(et));return}let t=e();t instanceof Promise?t.then(e=>this.processConfig(e)).catch(e=>{this.onError(e,"SourceConfig")}):this.processConfig(t)}else this.httpClient.getAsyncData({url:nL.lifecycle.sourceConfigUrl.value,options:{headers:{"Content-Type":void 0}},callback:this.processConfig})}constructor(e,t,n){this.errorHandler=t,this.logger=n,this.httpClient=e,this.onError=this.onError.bind(this),this.processConfig=this.processConfig.bind(this)}}let r1=()=>{let e=/([A-Z]+[+-]\d+)/.exec(new Date().toString());return(null==e?void 0:e[1])?e[1]:"NA"},r2=()=>{var e;return(null===(e=document)||void 0===e?void 0:e.referrer)||"$direct"},r3=()=>{let e=document.getElementsByTagName("link"),t="";for(let i=0;e[i];i+=1){let r=e[i];if("canonical"===r.getAttribute("rel")&&!t){var n;t=null!==(n=r.getAttribute("href"))&&void 0!==n?n:"";break}}return t},r6=()=>{if(T(globalThis.navigator))return null;let{userAgent:e}=globalThis.navigator,{brave:t}=globalThis.navigator;if(t&&Object.getPrototypeOf(t).isBrave){let t=e.match(/(chrome)\/([\w.]+)/i);t&&(e="".concat(e," Brave/").concat(t[2]))}return e},r4=()=>{var e;return T(globalThis.navigator)?null:null!==(e=globalThis.navigator.language)&&void 0!==e?e:globalThis.navigator.browserLanguage},r5=()=>{let e=r3(),t=globalThis.location.pathname,{href:n}=globalThis.location,i=n,{search:r}=globalThis.location;if(e)try{let n=new URL(e);i=""===n.search?e+r:e,t=n.pathname}catch(e){}let o=rR(i),{title:a}=document,s=r2();return{path:t,referrer:s,referring_domain:rO(s),search:r,title:a,url:o,tab_url:n}},r8="https://polyfill-fastly.io/v3/polyfill.min.js?version=3.111.0&features=".concat(Object.keys(re).join("%2C")),r9="rudderstackPolyfill";class r7{init(){this.prepareBrowserCapabilities(),this.attachWindowListeners()}detectBrowserCapabilities(){e3(()=>{nL.capabilities.storage.isCookieStorageAvailable.value=rr(iP,rd(iP),this.logger),nL.capabilities.storage.isLocalStorageAvailable.value=rr(iO,void 0,this.logger),nL.capabilities.storage.isSessionStorageAvailable.value=rr(iD,void 0,this.logger),nL.capabilities.isBeaconAvailable.value=i5(),nL.capabilities.isUaCHAvailable.value=i4(),nL.capabilities.isCryptoAvailable.value=i6(),nL.capabilities.isIE11.value=i8(),nL.capabilities.isOnline.value=globalThis.navigator.onLine,nL.context.userAgent.value=r6(),nL.context.locale.value=r4(),nL.context.screen.value=rn(),nL.context.timezone.value=r1(),i4()&&i9(e=>{nL.context["ua-ch"].value=e},nL.loadOptions.value.uaChTrackLevel)}),tc(()=>{!0===nL.loadOptions.value.sendAdblockPage&&void 0!==nL.lifecycle.sourceConfigUrl.value&&i3(this.httpClient)})}prepareBrowserCapabilities(){nL.capabilities.isLegacyDOM.value=rt();let e=nL.loadOptions.value.polyfillURL,t=r8;if(P(e)&&(rL(e)?t=e:this.logger.warn(ne(ee,e))),nL.loadOptions.value.polyfillIfRequired&&nL.capabilities.isLegacyDOM.value&&rL(t)){let e=t!==nL.loadOptions.value.polyfillURL;if(e){let e="RS_polyfillCallback_".concat(nL.lifecycle.writeKey.value);globalThis[e]=()=>{this.onReady(),delete globalThis[e]},t="".concat(t,"&callback=").concat(e)}this.externalSrcLoader.loadJSFile({url:t,id:r9,async:!0,timeout:1e4,callback:n=>{n?e||this.onReady():this.onError(Error(t4(r9,t)))}})}else this.onReady()}attachWindowListeners(){globalThis.addEventListener("offline",()=>{nL.capabilities.isOnline.value=!1}),globalThis.addEventListener("online",()=>{nL.capabilities.isOnline.value=!0}),globalThis.addEventListener("resize",function(e,t){let n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:250;return function(){for(var r=arguments.length,o=Array(r),a=0;a{e.apply(t,o)},i)}}(()=>{nL.context.screen.value=rn()},this))}onReady(){this.detectBrowserCapabilities(),nL.lifecycle.status.value="browserCapabilitiesReady"}onError(e){this.errorHandler.onError(e,ee)}constructor(e,t,n){this.httpClient=e,this.errorHandler=t,this.logger=n,this.externalSrcLoader=new e0(this.errorHandler,this.logger),this.onError=this.onError.bind(this),this.onReady=this.onReady.bind(this)}}let oe=["integrations","anonymousId","originalTimestamp"],ot=["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"],oi=e=>"number"==typeof e&&!Number.isNaN(e),or=(e,t)=>t.toString().length>=e,oo=e=>oi(e)&&e>=0&&Number.isInteger(e),oa=e=>{let t=Date.now();return!!(!e||t>e)},os=()=>Date.now(),ol=(e,t)=>!!(e&&oo(e)&&or(10,e))||(t.warn(t0(er,e,10)),!1),ou=e=>{let t=Date.now(),n=e||18e5;return{id:t,expiresAt:t+n,timeout:n,sessionStart:void 0,autoTrack:!0}},oc=(e,t)=>({id:ol(e,t)?e:os(),sessionStart:void 0,manualTrack:!0}),od=e=>e===iP||e===iO||e===iD||e===iR,og=()=>ey(),oh=e=>{let t=r5(),n={};return Object.keys(t).forEach(i=>{n[i]=(null==e?void 0:e[i])||t[i]}),n.initial_referrer=(null==e?void 0:e.initial_referrer)||nL.session.initialReferrer.value,n.initial_referring_domain=(null==e?void 0:e.initial_referring_domain)||nL.session.initialReferringDomain.value,n},ov=(e,t)=>{let n=(null==t?void 0:t.page)||{},i=r5();return Object.keys(i).forEach(t=>{T(e[t])&&(e[t]=n[t]||i[t])}),T(e.initial_referrer)&&(e.initial_referrer=n.initial_referrer||nL.session.initialReferrer.value),T(e.initial_referring_domain)&&(e.initial_referring_domain=n.initial_referring_domain||nL.session.initialReferringDomain.value),e},op=(e,t,n)=>{x(e)&&Object.keys(e).forEach(e=>{(on.includes(e)||on.includes(e.toLowerCase()))&&n.warn(tW(en,e,t,on))})},of=(e,t)=>{let{properties:n,traits:i,context:r}=e,{traits:o}=r;op(n,"properties",t),op(i,"traits",t),op(o,"context.traits",t)},oy=(e,t)=>{t.anonymousId&&I(t.anonymousId)&&(e.anonymousId=t.anonymousId),j(t.integrations)&&(e.integrations=t.integrations),t.originalTimestamp&&I(t.originalTimestamp)&&(e.originalTimestamp=t.originalTimestamp)},om=(e,t,n)=>{let i=e;return Object.keys(t).forEach(e=>{if(!oe.includes(e)&&!ot.includes(e))if("context"!==e)i=U(i,{[e]:t[e]});else if(!T(t[e])&&x(t[e])){let n={};Object.keys(t[e]).forEach(i=>{ot.includes(i)||(n[i]=t[e][i])}),i=U(i,{...n})}else n.warn(tJ(en))}),i},ob=(e,t,n)=>{x(t)&&(oy(e,t),e.context=om(e.context,t,n))},oE=e=>{let t;if(nL.loadOptions.value.useGlobalIntegrationsConfigInEvents){var n;t=null!==(n=nL.consents.postConsent.value.integrations)&&void 0!==n?n:nL.nativeDestinations.loadOnlyIntegrations.value}else t=e||nr;return p(t)},ok=(e,t,n,i)=>{var r,o,a;let s={channel:"web",context:{traits:p(nL.session.userTraits.value),sessionId:nL.session.sessionInfo.value.id||void 0,sessionStart:nL.session.sessionInfo.value.sessionStart||void 0,...nL.consents.enabled.value&&{consentManagement:{deniedConsentIds:p(nL.consents.data.value.deniedConsentIds),allowedConsentIds:p(nL.consents.data.value.allowedConsentIds),provider:nL.consents.provider.value,resolutionStrategy:nL.consents.resolutionStrategy.value}},"ua-ch":nL.context["ua-ch"].value,app:nL.context.app.value,library:nL.context.library.value,userAgent:nL.context.userAgent.value,os:nL.context.os.value,locale:nL.context.locale.value,screen:nL.context.screen.value,campaign:rD(globalThis.location.href),page:oh(n),timezone:nL.context.timezone.value,...nL.autoTrack.enabled.value&&{autoTrack:{...nL.autoTrack.pageLifecycle.enabled.value&&{page:{visitId:nL.autoTrack.pageLifecycle.visitId.value}}}}},originalTimestamp:eE(),messageId:ey(),userId:e.userId||nL.session.userId.value};od(null===(r=nL.storage.entries.value.anonymousId)||void 0===r?void 0:r.type)?s.anonymousId=nL.session.anonymousId.value:s.anonymousId=og(),nL.storage.trulyAnonymousTracking.value&&(s.context.trulyAnonymousTracking=!0),"identify"===e.type&&(s.context.traits=(null===(o=nL.storage.entries.value.userTraits)||void 0===o?void 0:o.type)!==iN?p(nL.session.userTraits.value):e.context.traits),"group"===e.type&&((e.groupId||nL.session.groupId.value)&&(s.groupId=e.groupId||nL.session.groupId.value),(e.traits||nL.session.groupTraits.value)&&(s.traits=(null===(a=nL.storage.entries.value.groupTraits)||void 0===a?void 0:a.type)!==iN?p(nL.session.groupTraits.value):e.traits));let l=U(e,s);return void 0===l.event&&(l.event=null),void 0===l.properties&&(l.properties=null),ob(l,t,i),of(l,i),l.integrations=oE(l.integrations),l};class oI{generatePageEvent(e,t,n,i){let r=null!=n?n:{};return ok({properties:r=ov(r,i),name:t,category:e,type:"page"},i,r,this.logger)}generateTrackEvent(e,t,n){return ok({properties:t,event:e,type:"track"},n,void 0,this.logger)}generateIdentifyEvent(e,t,n){return ok({userId:e,type:"identify",context:{traits:t}},n,void 0,this.logger)}generateAliasEvent(e,t,n){let i=ok({previousId:t,type:"alias"},n,void 0,this.logger);return i.userId=null!=e?e:i.userId,i}generateGroupEvent(e,t,n){let i={type:"group"};return e&&(i.groupId=e),t&&(i.traits=t),ok(i,n,void 0,this.logger)}create(e){let t;switch(e.type){case"page":t=this.generatePageEvent(e.category,e.name,e.properties,e.options);break;case"track":t=this.generateTrackEvent(e.name,e.properties,e.options);break;case"identify":t=this.generateIdentifyEvent(e.userId,e.traits,e.options);break;case"alias":t=this.generateAliasEvent(e.to,e.from,e.options);break;default:t=this.generateGroupEvent(e.groupId,e.traits,e.options)}return t}constructor(e){this.logger=e}}class oS{init(){this.eventRepository.init()}resume(){this.eventRepository.resume()}addEvent(e){this.userSessionManager.refreshSession();let t=this.eventFactory.create(e);this.eventRepository.enqueue(t,e.callback)}constructor(e,t,n,i){this.eventRepository=e,this.userSessionManager=t,this.errorHandler=n,this.logger=i,this.eventFactory=new oI(this.logger)}}class oT{init(){this.syncStorageDataToState(),this.registerEffects()}syncStorageDataToState(){let e;this.migrateStorageIfNeeded(),this.migrateDataFromPreviousStorage(),this.setUserId(this.getUserId()),this.setUserTraits(this.getUserTraits()),this.setGroupId(this.getGroupId()),this.setGroupTraits(this.getGroupTraits());let{externalAnonymousIdCookieName:t,anonymousIdOptions:n}=nL.loadOptions.value;P(t)&&"string"==typeof t&&(e=this.getExternalAnonymousIdByCookieName(t)),this.setAnonymousId(null!=e?e:this.getAnonymousId(n)),this.setAuthToken(this.getAuthToken()),this.setInitialReferrerInfo(),this.configureSessionTracking()}configureSessionTracking(){let e=this.getSessionInfo();if(this.isPersistenceEnabledForStorageEntry("sessionInfo")){let t=this.getConfiguredSessionTrackingInfo(),n=null!=e?e:nm;(e={...n,...t,autoTrack:t.autoTrack&&!0!==n.manualTrack}).autoTrack||!0===e.manualTrack||(e=ny.sessionInfo)}else e=ny.sessionInfo;nL.session.sessionInfo.value=e,nL.session.sessionInfo.value.autoTrack&&this.startOrRenewAutoTracking(nL.session.sessionInfo.value)}setInitialReferrerInfo(){let e=this.getInitialReferrer(),t=this.getInitialReferringDomain();if(e&&t)this.setInitialReferrer(e),this.setInitialReferringDomain(t);else{let t=e||r2();this.setInitialReferrer(t),this.setInitialReferringDomain(rO(t))}}isPersistenceEnabledForStorageEntry(e){var t;return od(null===(t=nL.storage.entries.value[e])||void 0===t?void 0:t.type)}migrateDataFromPreviousStorage(){let e=nL.storage.entries.value,t=[iP,iO,iD];Object.keys(e).forEach(n=>{var i,r;let o=null===(i=e[n])||void 0===i?void 0:i.type,a=null===(r=this.storeManager)||void 0===r?void 0:r.getStore(ij[o]);a&&t.forEach(e=>{var t;let i=null===(t=this.storeManager)||void 0===t?void 0:t.getStore(ij[e]);if(i&&e!==o){let e=i.get(iL[n]);O(e)&&a.set(iL[n],e),i.remove(iL[n])}})})}migrateStorageIfNeeded(){if(!nL.storage.migrate.value)return;let e=[];[iM,ix,iB].forEach(t=>{var n;let i=null===(n=this.storeManager)||void 0===n?void 0:n.getStore(t);i&&e.push(i)}),Object.keys(iL).forEach(t=>{let n=iL[t];e.forEach(e=>{var t;let i=null===(t=this.pluginsManager)||void 0===t?void 0:t.invokeSingle("storage.migrate",n,e.engine,this.errorHandler,this.logger);A(i)||e.set(n,i)})})}getConfiguredSessionTrackingInfo(){var e,t;let n,i=(null===(e=nL.loadOptions.value.sessions)||void 0===e?void 0:e.autoTrack)!==!1;if(!i)return{autoTrack:i};let r=null===(t=nL.loadOptions.value.sessions)||void 0===t?void 0:t.timeout;return oo(r)?n=r:(this.logger.warn(tX(er,r,18e5)),n=18e5),0===n&&(this.logger.warn(tZ(er)),i=!1),n>0&&n<1e4&&this.logger.warn(tY(er,n,1e4)),{timeout:n,autoTrack:i}}onError(e,t){this.errorHandler.onError(e,er,t)}getEncryptedCookieData(e,t){let n=[];return e.forEach(e=>{let i=null==t?void 0:t.encrypt(eC(e.value,!1,[],this.logger));P(i)&&n.push({name:e.name,value:i})}),n}makeRequestToSetCookie(e,t){var n,i,r,o,a,s,l,u;null===(u=this.httpClient)||void 0===u||u.getAsyncData({url:nL.serverCookies.dataServiceUrl.value,options:{method:"POST",data:eC({reqType:"setCookies",workspaceId:null===(n=nL.source.value)||void 0===n?void 0:n.workspaceId,data:{options:{maxAge:null===(i=nL.storage.cookie.value)||void 0===i?void 0:i.maxage,path:null===(r=nL.storage.cookie.value)||void 0===r?void 0:r.path,domain:null===(o=nL.storage.cookie.value)||void 0===o?void 0:o.domain,sameSite:null===(a=nL.storage.cookie.value)||void 0===a?void 0:a.samesite,secure:null===(s=nL.storage.cookie.value)||void 0===s?void 0:s.secure,expires:null===(l=nL.storage.cookie.value)||void 0===l?void 0:l.expires},cookies:e}}),sendRawData:!0,withCredentials:!0},isRawResponse:!0,callback:t})}setServerSideCookies(e,t,n){try{let i=this.getEncryptedCookieData(e,n);i.length>0&&this.makeRequestToSetCookie(i,(i,r)=>{var o,a;(null==r?void 0:null===(o=r.xhr)||void 0===o?void 0:o.status)===200?e.forEach(e=>{let i=null==n?void 0:n.get(e.name),r=eC(e.value,!1,[]);eC(i,!1,[])!==r&&(this.logger.error(tQ(e.name)),t&&t(e.name,e.value))}):(this.logger.error(tG(null==r?void 0:null===(a=r.xhr)||void 0===a?void 0:a.status)),e.forEach(e=>{t&&t(e.name,e.value)}))})}catch(n){this.onError(n,"Failed to set/remove cookies via server. As a fallback, the cookies will be managed client side."),e.forEach(e=>{t&&t(e.name,e.value)})}}syncValueToStorage(e,t){var n,i,r;let o=nL.storage.entries.value,a=null===(n=o[e])||void 0===n?void 0:n.type;if(od(a)){let n=null===(i=this.storeManager)||void 0===i?void 0:i.getStore(ij[a]),s=null===(r=o[e])||void 0===r?void 0:r.key;t&&(I(t)||j(t))?nL.serverCookies.isEnabledServerSideCookies.value&&a===iP?(this.serverSideCookieDebounceFuncs[e]&&globalThis.clearTimeout(this.serverSideCookieDebounceFuncs[e]),this.serverSideCookieDebounceFuncs[e]=globalThis.setTimeout(()=>{this.setServerSideCookies([{name:s,value:t}],(e,t)=>{null==n||n.set(e,t)},n)},10)):null==n||n.set(s,t):null==n||n.remove(s)}}registerEffects(){iU.forEach(e=>{tc(()=>{this.syncValueToStorage(e,nL.session[e].value)})})}setAnonymousId(e,t){let n=e;if(I(e)&&n||(n=void 0),this.isPersistenceEnabledForStorageEntry("anonymousId")){if(!n&&t){var i;n=null===(i=this.pluginsManager)||void 0===i?void 0:i.invokeSingle("userSession.anonymousIdGoogleLinker",t)}n=n||og()}else n=ny.anonymousId;nL.session.anonymousId.value=n}getAnonymousId(e){var t,n;if(od(null===(t=nL.storage.entries.value.anonymousId)||void 0===t?void 0:t.type)){let t=this.getEntryValue("anonymousId");!t&&e&&(t=null===(n=this.pluginsManager)||void 0===n?void 0:n.invokeSingle("storage.getAnonymousId",rd,e)),nL.session.anonymousId.value=t||og()}return nL.session.anonymousId.value}getEntryValue(e){var t,n,i,r;let o=nL.storage.entries.value,a=null===(t=o[e])||void 0===t?void 0:t.type;if(od(a)){let t=null===(n=this.storeManager)||void 0===n?void 0:n.getStore(ij[a]),s=null===(i=o[e])||void 0===i?void 0:i.key;return null!==(r=null==t?void 0:t.get(s))&&void 0!==r?r:null}return null}getExternalAnonymousIdByCookieName(e){let t=rd(iP);if(null==t?void 0:t.isEnabled){var n;return null!==(n=t.getItem(e))&&void 0!==n?n:null}return null}getUserId(){return this.getEntryValue("userId")}getUserTraits(){return this.getEntryValue("userTraits")}getGroupId(){return this.getEntryValue("groupId")}getGroupTraits(){return this.getEntryValue("groupTraits")}getInitialReferrer(){return this.getEntryValue("initialReferrer")}getInitialReferringDomain(){return this.getEntryValue("initialReferringDomain")}getSessionInfo(){return this.getEntryValue("sessionInfo")}getAuthToken(){return this.getEntryValue("authToken")}getSessionId(){var e,t;let n=null!==(e=this.getSessionInfo())&&void 0!==e?e:ny.sessionInfo;return(n.autoTrack&&!oa(n.expiresAt)||n.manualTrack)&&null!==(t=n.id)&&void 0!==t?t:null}refreshSession(){var e;let t=null!==(e=this.getSessionInfo())&&void 0!==e?e:ny.sessionInfo;(t.autoTrack||t.manualTrack)&&(t.autoTrack&&(this.startOrRenewAutoTracking(t),t=nL.session.sessionInfo.value),void 0===t.sessionStart?t={...t,sessionStart:!0}:t.sessionStart&&(t={...t,sessionStart:!1})),nL.session.sessionInfo.value=t,"readyExecuted"!==nL.lifecycle.status.value&&this.syncValueToStorage("sessionInfo",t)}reset(e,t){let{session:n}=nL,{manualTrack:i,autoTrack:r}=n.sessionInfo.value;e3(()=>{n.userId.value=ny.userId,n.userTraits.value=ny.userTraits,n.groupId.value=ny.groupId,n.groupTraits.value=ny.groupTraits,n.authToken.value=ny.authToken,!0===e&&this.setAnonymousId(),!t&&(r?(n.sessionInfo.value=ny.sessionInfo,this.startOrRenewAutoTracking(n.sessionInfo.value)):i&&this.startManualTrackingInternal())})}setUserId(e){nL.session.userId.value=this.isPersistenceEnabledForStorageEntry("userId")&&e?e:ny.userId}setUserTraits(e){var t;nL.session.userTraits.value=this.isPersistenceEnabledForStorageEntry("userTraits")&&x(e)?U(null!==(t=nL.session.userTraits.value)&&void 0!==t?t:ny.userTraits,e):ny.userTraits}setGroupId(e){nL.session.groupId.value=this.isPersistenceEnabledForStorageEntry("groupId")&&e?e:ny.groupId}setGroupTraits(e){var t;nL.session.groupTraits.value=this.isPersistenceEnabledForStorageEntry("groupTraits")&&x(e)?U(null!==(t=nL.session.groupTraits.value)&&void 0!==t?t:ny.groupTraits,e):ny.groupTraits}setInitialReferrer(e){nL.session.initialReferrer.value=this.isPersistenceEnabledForStorageEntry("initialReferrer")&&e?e:ny.initialReferrer}setInitialReferringDomain(e){nL.session.initialReferringDomain.value=this.isPersistenceEnabledForStorageEntry("initialReferringDomain")&&e?e:ny.initialReferringDomain}startOrRenewAutoTracking(e){if(oa(e.expiresAt))nL.session.sessionInfo.value=ou(e.timeout);else{let t=Date.now(),n=e.timeout;nL.session.sessionInfo.value=U(e,{expiresAt:t+n})}}start(e){nL.session.sessionInfo.value=oc(e,this.logger)}startManualTrackingInternal(){this.start(Date.now())}end(){nL.session.sessionInfo.value=ny.sessionInfo}setAuthToken(e){nL.session.authToken.value=this.isPersistenceEnabledForStorageEntry("authToken")&&e?e:ny.authToken}constructor(e,t,n,i,r){this.storeManager=t,this.pluginsManager=e,this.logger=r,this.errorHandler=i,this.httpClient=n,this.onError=this.onError.bind(this),this.serverSideCookieDebounceFuncs={}}}let oA=["BeaconQueue","CustomConsentManager","DeviceModeDestinations","DeviceModeTransformation","ExternalAnonymousId","GoogleLinker","IubendaConsentManager","KetchConsentManager","NativeDestinationQueue","OneTrustConsentManager","StorageEncryption","StorageEncryptionLegacy","StorageMigrator","XhrQueue"],ow=(e,t)=>{let n=p(t);if(I(n.setCookieDomain)||(n.setCookieDomain=void 0),["Strict","Lax","None"].includes(n.sameSiteCookie)||(n.sameSiteCookie=void 0),n.secureCookie=G(n.secureCookie,e.secureCookie),n.sameDomainCookiesOnly=G(n.sameDomainCookiesOnly,e.sameDomainCookiesOnly),["none","default","full"].includes(n.uaChTrackLevel)||(n.uaChTrackLevel=void 0),n.integrations=F(n.integrations),Array.isArray(n.plugins)||(n.plugins=oA),n.useGlobalIntegrationsConfigInEvents=G(n.useGlobalIntegrationsConfigInEvents,e.useGlobalIntegrationsConfigInEvents),n.bufferDataPlaneEventsUntilReady=G(n.bufferDataPlaneEventsUntilReady,e.bufferDataPlaneEventsUntilReady),n.sendAdblockPage=G(n.sendAdblockPage,e.sendAdblockPage),n.useServerSideCookies=G(n.useServerSideCookies,e.useServerSideCookies),I(n.dataServiceEndpoint)||(n.dataServiceEndpoint=void 0),n.sendAdblockPageOptions=F(n.sendAdblockPageOptions),n.loadIntegration=G(n.loadIntegration,e.loadIntegration),j(n.storage)){var i;n.storage.migrate=G(n.storage.migrate,null===(i=e.storage)||void 0===i?void 0:i.migrate),n.storage.cookie=F(n.storage.cookie),n.storage.encryption=F(n.storage.encryption),n.storage=H(n.storage)}else n.storage=void 0;return n.destinationsQueueOptions=F(n.destinationsQueueOptions),n.queueOptions=F(n.queueOptions),n.lockIntegrationsVersion=G(n.lockIntegrationsVersion,e.lockIntegrationsVersion),n.lockPluginsVersion=G(n.lockPluginsVersion,e.lockPluginsVersion),oi(n.dataPlaneEventsBufferTimeout)||(n.dataPlaneEventsBufferTimeout=void 0),n.beaconQueueOptions=F(n.beaconQueueOptions),n.preConsent=F(n.preConsent),U(e,H(n))},oC="dataplaneEventsQueue",oP="destinationsEventsQueue",oO=(e,t)=>Object.keys(e).filter(n=>!0!==e[n]||!t[n]).reduce((t,n)=>{let i=p(t);return i[n]=e[n],i},{}),oD=(e,t)=>{let n=p(e),i=t.nativeDestinations.integrationsConfig.value,r=oO(e.integrations,i);return n.integrations=U(i,r),n},oR=e=>{var t,n,i;return e.consents.preConsent.value.enabled&&(null===(t=e.consents.preConsent.value.events)||void 0===t?void 0:t.delivery)==="buffer"&&((null===(n=e.consents.preConsent.value.storage)||void 0===n?void 0:n.strategy)==="session"||(null===(i=e.consents.preConsent.value.storage)||void 0===i?void 0:i.strategy)==="none")},oN=(e,t,n,i)=>{if(C(e))if(k(e))try{e(...t)}catch(e){i.error(t3(n),e)}else i.error(tB(n))};class oL{init(){let e;this.dataplaneEventsQueue=this.pluginsManager.invokeSingle("".concat(oC,".init"),nL,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.dmtEventsQueue=this.pluginsManager.invokeSingle("".concat("transformEvent",".init"),nL,this.pluginsManager,this.httpClient,this.storeManager,this.errorHandler,this.logger),this.destinationsEventsQueue=this.pluginsManager.invokeSingle("".concat(oP,".init"),nL,this.pluginsManager,this.storeManager,this.dmtEventsQueue,this.errorHandler,this.logger),tc(()=>{if(!0===nL.nativeDestinations.clientDestinationsReady.value){var e,t;null===(e=this.destinationsEventsQueue)||void 0===e||e.start(),null===(t=this.dmtEventsQueue)||void 0===t||t.start()}});let t=oR(nL);tc(()=>{var n,i;let r=!0===nL.loadOptions.value.bufferDataPlaneEventsUntilReady&&!1===nL.nativeDestinations.clientDestinationsReady.value;!1!==nL.nativeDestinations.activeDestinations.value.some(e=>id(e))&&!1!==r||t||(null===(n=this.dataplaneEventsQueue)||void 0===n?void 0:n.scheduleTimeoutActive)===!0||(globalThis.clearTimeout(e),null===(i=this.dataplaneEventsQueue)||void 0===i||i.start())}),!0===nL.loadOptions.value.bufferDataPlaneEventsUntilReady&&(e=globalThis.setTimeout(()=>{var e,t;(null===(e=this.dataplaneEventsQueue)||void 0===e?void 0:e.scheduleTimeoutActive)!==!0&&(null===(t=this.dataplaneEventsQueue)||void 0===t||t.start())},nL.loadOptions.value.dataPlaneEventsBufferTimeout))}resume(){var e,t,n,i;(null===(e=this.dataplaneEventsQueue)||void 0===e?void 0:e.scheduleTimeoutActive)!==!0&&(nL.consents.postConsent.value.discardPreConsentEvents&&(null===(n=this.dataplaneEventsQueue)||void 0===n||n.clear(),null===(i=this.destinationsEventsQueue)||void 0===i||i.clear()),null===(t=this.dataplaneEventsQueue)||void 0===t||t.start())}enqueue(e,t){let n=oD(e,nL);this.pluginsManager.invokeSingle("".concat(oC,".enqueue"),nL,this.dataplaneEventsQueue,n,this.errorHandler,this.logger);let i=p(e);this.pluginsManager.invokeSingle("".concat(oP,".enqueue"),nL,this.destinationsEventsQueue,i,this.errorHandler,this.logger),oN(t,[n],"".concat(e.type.charAt(0).toUpperCase()).concat(e.type.slice(1)).concat("API"),this.logger)}constructor(e,t,n,i,r){this.pluginsManager=e,this.errorHandler=i,this.httpClient=n,this.logger=r,this.storeManager=t}}let oM=e=>{let t=new CustomEvent(e,{detail:{analyticsInstance:globalThis.rudderanalytics},bubbles:!0,cancelable:!0,composed:!0});globalThis.document.dispatchEvent(t)},ox=e=>I(e)&&e.trim().length>0,oB=e=>rL(e);class oU{load(e,t){var n;let i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!nL.lifecycle.status.value){if(!ox(e)){this.logger.error(tM(eu,e));return}if(!oB(t)){this.logger.error(tx(eu,t));return}e3(()=>{nL.lifecycle.writeKey.value=p(e),nL.lifecycle.dataPlaneUrl.value=p(t),nL.loadOptions.value=ow(nL.loadOptions.value,i),nL.lifecycle.status.value="mounted"}),this.logger.setMinLogLevel(null!==(n=nL.loadOptions.value.logLevel)&&void 0!==n?n:th),eQ("state",nL,e),this.startLifecycle()}}startLifecycle(){tc(()=>{try{switch(nL.lifecycle.status.value){case"mounted":this.onMounted();break;case"browserCapabilitiesReady":this.onBrowserCapabilitiesReady();break;case"configured":this.onConfigured();break;case"pluginsLoading":case"destinationsLoading":break;case"pluginsReady":this.onPluginsReady();break;case"initialized":this.onInitialized();break;case"loaded":this.onLoaded();break;case"destinationsReady":this.onDestinationsReady();break;case"ready":this.onReady()}}catch(e){this.errorHandler.onError(eL(e,"Failed to load the SDK"),eu)}})}onBrowserCapabilitiesReady(){eJ(this),this.prepareInternalServices(),this.loadConfig()}onLoaded(){this.processBufferedEvents(),!0===nL.consents.preConsent.value.enabled?nL.lifecycle.status.value="ready":this.loadDestinations()}onMounted(){this.capabilitiesManager.init()}enqueuePreloadBufferEvents(e){Array.isArray(e)&&e.forEach(e=>this.preloadBuffer.enqueue(p(e)))}processDataInPreloadBuffer(){for(;this.preloadBuffer.size()>0;){let e=this.preloadBuffer.dequeue();e&&e$([...e],this)}}prepareInternalServices(){this.pluginsManager=new iC(iu,this.errorHandler,this.logger),this.storeManager=new rb(this.pluginsManager,this.errorHandler,this.logger),this.configManager=new r0(this.httpClient,this.errorHandler,this.logger),this.userSessionManager=new oT(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventRepository=new oL(this.pluginsManager,this.storeManager,this.httpClient,this.errorHandler,this.logger),this.eventManager=new oS(this.eventRepository,this.userSessionManager,this.errorHandler,this.logger)}loadConfig(){var e;nL.lifecycle.writeKey.value&&this.httpClient.setAuthHeader(nL.lifecycle.writeKey.value),null===(e=this.configManager)||void 0===e||e.init()}onPluginsReady(){var e,t,n,i,r;null===(e=this.storeManager)||void 0===e||e.init(),null===(t=this.userSessionManager)||void 0===t||t.init(),nL.consents.enabled.value&&!nL.consents.initialized.value&&(null===(i=this.pluginsManager)||void 0===i||i.invokeSingle("consentManager.init",nL,this.logger),!1===nL.consents.preConsent.value.enabled&&(null===(r=this.pluginsManager)||void 0===r||r.invokeSingle("consentManager.updateConsentsInfo",nL,this.storeManager,this.logger))),null===(n=this.eventManager)||void 0===n||n.init(),nL.lifecycle.status.value="initialized"}onConfigured(){var e;null===(e=this.pluginsManager)||void 0===e||e.init()}onInitialized(){this.processDataInPreloadBuffer(),oN(nL.loadOptions.value.onLoaded,[globalThis.rudderanalytics],el,this.logger),e3(()=>{nL.lifecycle.loaded.value=!0,nL.lifecycle.status.value="loaded"}),this.initialized=!0,oM("RSA_Initialised")}onReady(){nL.lifecycle.status.value="readyExecuted",nL.eventBuffer.readyCallbacksArray.value.forEach(e=>{oN(e,[],es,this.logger)}),oM("RSA_Ready")}processBufferedEvents(){let e=nL.eventBuffer.toBeProcessedArray.value;for(;e.length>0;){let t=e.shift();if(nL.eventBuffer.toBeProcessedArray.value=e,t){let e=t[0];k(this[e])&&this[e](...t.slice(1),!0)}e=nL.eventBuffer.toBeProcessedArray.value}}loadDestinations(){var e,t;if(nL.nativeDestinations.clientDestinationsReady.value)return;null===(e=this.pluginsManager)||void 0===e||e.invokeSingle("nativeDestinations.setActiveDestinations",nL,this.pluginsManager,this.errorHandler,this.logger);let n=nL.nativeDestinations.activeDestinations.value.length;if(0===n){nL.lifecycle.status.value="destinationsReady";return}nL.lifecycle.status.value="destinationsLoading",null===(t=this.pluginsManager)||void 0===t||t.invokeSingle("nativeDestinations.load",nL,this.externalSrcLoader,this.errorHandler,this.logger),tc(()=>{(0===n||nL.nativeDestinations.initializedDestinations.value.length+nL.nativeDestinations.failedDestinations.value.length===n)&&e3(()=>{nL.lifecycle.status.value="destinationsReady",nL.nativeDestinations.clientDestinationsReady.value=!0})})}onDestinationsReady(){"ready"!==nL.lifecycle.status.value&&(nL.lifecycle.status.value="ready")}ready(e){arguments.length>1&&void 0!==arguments[1]&&arguments[1];let t="ready";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[t,e]];return}if(this.errorHandler.leaveBreadcrumb("New ".concat(t," invocation")),!k(e)){this.logger.error(tB(es));return}"readyExecuted"===nL.lifecycle.status.value?oN(e,[],es,this.logger):nL.eventBuffer.readyCallbacksArray.value=[...nL.eventBuffer.readyCallbacksArray.value,e]}page(e){var t;arguments.length>1&&void 0!==arguments[1]&&arguments[1];let n="page";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[n,e]];return}this.errorHandler.leaveBreadcrumb("New ".concat(n," event")),nL.metrics.triggered.value+=1,null===(t=this.eventManager)||void 0===t||t.addEvent({type:"page",category:e.category,name:e.name,properties:e.properties,options:e.options,callback:e.callback}),!0===nL.capabilities.isAdBlocked.value&&e.category!==eU&&this.page(W(eU,"ad-block page request",{path:"/ad-blocked"},nL.loadOptions.value.sendAdblockPageOptions))}track(e){var t;arguments.length>1&&void 0!==arguments[1]&&arguments[1];let n="track";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[n,e]];return}this.errorHandler.leaveBreadcrumb("New ".concat(n," event - ").concat(e.name)),nL.metrics.triggered.value+=1,null===(t=this.eventManager)||void 0===t||t.addEvent({type:n,name:e.name||void 0,properties:e.properties,options:e.options,callback:e.callback})}identify(e){var t,n,i;arguments.length>1&&void 0!==arguments[1]&&arguments[1];let r="identify";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[r,e]];return}this.errorHandler.leaveBreadcrumb("New ".concat(r," event")),nL.metrics.triggered.value+=1,e.userId&&nL.session.userId.value&&e.userId!==nL.session.userId.value&&this.reset(),S(e.userId)||null===(i=this.userSessionManager)||void 0===i||i.setUserId(e.userId),null===(t=this.userSessionManager)||void 0===t||t.setUserTraits(e.traits),null===(n=this.eventManager)||void 0===n||n.addEvent({type:r,userId:e.userId,traits:e.traits,options:e.options,callback:e.callback})}alias(e){var t,n,i,r,o;arguments.length>1&&void 0!==arguments[1]&&arguments[1];let a="alias";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[a,e]];return}this.errorHandler.leaveBreadcrumb("New ".concat(a," event")),nL.metrics.triggered.value+=1;let s=null!==(o=null!==(r=e.from)&&void 0!==r?r:null===(t=this.userSessionManager)||void 0===t?void 0:t.getUserId())&&void 0!==o?o:null===(n=this.userSessionManager)||void 0===n?void 0:n.getAnonymousId();null===(i=this.eventManager)||void 0===i||i.addEvent({type:a,to:e.to,from:s,options:e.options,callback:e.callback})}group(e){var t,n,i;arguments.length>1&&void 0!==arguments[1]&&arguments[1];let r="group";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[r,e]];return}this.errorHandler.leaveBreadcrumb("New ".concat(r," event")),nL.metrics.triggered.value+=1,S(e.groupId)||null===(i=this.userSessionManager)||void 0===i||i.setGroupId(e.groupId),null===(t=this.userSessionManager)||void 0===t||t.setGroupTraits(e.traits),null===(n=this.eventManager)||void 0===n||n.addEvent({type:r,groupId:e.groupId,traits:e.traits,options:e.options,callback:e.callback})}reset(e){var t;arguments.length>1&&void 0!==arguments[1]&&arguments[1];let n="reset";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[n,e]];return}this.errorHandler.leaveBreadcrumb("New ".concat(n," invocation, resetAnonymousId: ").concat(e)),null===(t=this.userSessionManager)||void 0===t||t.reset(e)}getAnonymousId(e){var t;return null===(t=this.userSessionManager)||void 0===t?void 0:t.getAnonymousId(e)}setAnonymousId(e,t){var n;arguments.length>2&&void 0!==arguments[2]&&arguments[2];let i="setAnonymousId";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[i,e,t]];return}this.errorHandler.leaveBreadcrumb("New ".concat(i," invocation")),null===(n=this.userSessionManager)||void 0===n||n.setAnonymousId(e,t)}getUserId(){return nL.session.userId.value}getUserTraits(){return nL.session.userTraits.value}getGroupId(){return nL.session.groupId.value}getGroupTraits(){return nL.session.groupTraits.value}startSession(e){var t;arguments.length>1&&void 0!==arguments[1]&&arguments[1];let n="startSession";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[n,e]];return}this.errorHandler.leaveBreadcrumb("New ".concat(n," invocation")),null===(t=this.userSessionManager)||void 0===t||t.start(e)}endSession(){var e;arguments.length>0&&void 0!==arguments[0]&&arguments[0];let t="endSession";if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,[t]];return}this.errorHandler.leaveBreadcrumb("New ".concat(t," invocation")),null===(e=this.userSessionManager)||void 0===e||e.end()}getSessionId(){var e;let t=null===(e=this.userSessionManager)||void 0===e?void 0:e.getSessionId();return null!=t?t:null}consent(e){var t,n,i,r;let o=arguments.length>1&&void 0!==arguments[1]&&arguments[1];if(!nL.lifecycle.loaded.value){nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,["consent",e]];return}this.errorHandler.leaveBreadcrumb("New consent invocation"),e3(()=>{nL.consents.preConsent.value={...nL.consents.preConsent.value,enabled:!1},nL.consents.postConsent.value=r_(e);let{initialized:t,consentsData:n}=rG(nL.consents.postConsent.value.consentManagement,this.logger);nL.consents.initialized.value=t,nL.consents.data.value=n}),nL.consents.enabled.value&&!nL.consents.initialized.value&&(null===(r=this.pluginsManager)||void 0===r||r.invokeSingle("consentManager.updateConsentsInfo",nL,this.storeManager,this.logger)),null===(t=this.storeManager)||void 0===t||t.initializeStorageState(),null===(n=this.userSessionManager)||void 0===n||n.syncStorageDataToState(),null===(i=this.eventManager)||void 0===i||i.resume(),this.loadDestinations(),this.sendTrackingEvents(o)}sendTrackingEvents(e){if(nL.consents.postConsent.value.trackConsent){let t=J("Consent Management Interaction");e?nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,["track",t]]:this.track(t)}if(nL.consents.postConsent.value.sendPageEvent){let t=W();e?nL.eventBuffer.toBeProcessedArray.value=[...nL.eventBuffer.toBeProcessedArray.value,["page",t]]:this.page(t)}}setAuthToken(e){var t;null===(t=this.userSessionManager)||void 0===t||t.setAuthToken(e)}constructor(){this.preloadBuffer=new td,this.initialized=!1,this.errorHandler=is,this.logger=tp,this.externalSrcLoader=new e0(this.errorHandler,this.logger),this.httpClient=n0,this.httpClient.init(this.errorHandler),this.capabilitiesManager=new r7(this.httpClient,this.errorHandler,this.logger)}}class oj{static initializeGlobalResources(){is.init(),rc.configure(),ra.configure(),rl.configure(),i0.configure()}setDefaultInstanceKey(e){I(e)&&e&&(this.defaultAnalyticsKey=e)}getAnalyticsInstance(e){try{let t=e;return I(t)&&t||(t=this.defaultAnalyticsKey),this.analyticsInstances[t]||(this.analyticsInstances[t]=new oU),this.analyticsInstances[t]}catch(e){eM(e);return}}load(e,t,n){try{var i;if(this.analyticsInstances[e])return;this.setDefaultInstanceKey(e);let r=eK(ej);this.trackPageLifecycleEvents(r,n),eW(r),eQ(ej,p(r)),null===(i=this.getAnalyticsInstance(e))||void 0===i||i.load(e,t,eD(n))}catch(e){eM(e)}}trackPageLifecycleEvents(e,t){let{autoTrack:n,useBeacon:i}=null!=t?t:{},{enabled:r=!1,options:o={},pageLifecycle:a}=null!=n?n:{},{events:s=[Y.LOADED,Y.UNLOADED],enabled:l=r,options:u=o}=null!=a?a:{};nL.autoTrack.pageLifecycle.enabled.value=l,nL.autoTrack.enabled.value=r||l,l&&(this.trackPageLoadedEvent(s,u,e),this.setupPageUnloadTracking(s,i,u))}trackPageLoadedEvent(e,t,n){(0===e.length||e.includes(Y.LOADED))&&n.unshift(["track",Y.LOADED,{},{...t,originalTimestamp:eb(new Date(nL.autoTrack.pageLifecycle.pageLoadedTimestamp.value))}])}setupPageUnloadTracking(e,t,n){(0===e.length||e.includes(Y.UNLOADED))&&(!0===t?em(e=>{if(!1===e&&nL.lifecycle.loaded.value){let e=Date.now(),t=e-nL.autoTrack.pageLifecycle.pageLoadedTimestamp.value;this.track(Y.UNLOADED,{visitDuration:t},{...n,originalTimestamp:eb(new Date(e))})}}):this.logger.warn(nn("RudderStackAnalytics")))}triggerBufferedLoadEvent(){let e=Array.isArray(globalThis.rudderanalytics)?globalThis.rudderanalytics:[],t=eq(e);eQ(ej,p([...e])),t.length>0&&(t.shift(),this.load.apply(null,t))}ready(e){try{var t;null===(t=this.getAnalyticsInstance())||void 0===t||t.ready(eD(e))}catch(e){eM(e)}}page(e,t,n,i,r){try{var o;null===(o=this.getAnalyticsInstance())||void 0===o||o.page(W(eD(e),eD(t),eD(n),eD(i),eD(r)))}catch(e){eM(e)}}track(e,t,n,i){try{var r;null===(r=this.getAnalyticsInstance())||void 0===r||r.track(J(eD(e),eD(t),eD(n),eD(i)))}catch(e){eM(e)}}identify(e,t,n,i){try{var r;null===(r=this.getAnalyticsInstance())||void 0===r||r.identify($(eD(e),eD(t),eD(n),eD(i)))}catch(e){eM(e)}}alias(e,t,n,i){try{var r;null===(r=this.getAnalyticsInstance())||void 0===r||r.alias(X(eD(e),eD(t),eD(n),eD(i)))}catch(e){eM(e)}}group(e,t,n,i){try{var r;null===(r=this.getAnalyticsInstance())||void 0===r||r.group(Z(eD(e),eD(t),eD(n),eD(i)))}catch(e){eM(e)}}reset(e){try{var t;null===(t=this.getAnalyticsInstance())||void 0===t||t.reset(eD(e))}catch(e){eM(e)}}getAnonymousId(e){try{var t;return null===(t=this.getAnalyticsInstance())||void 0===t?void 0:t.getAnonymousId(eD(e))}catch(e){eM(e);return}}setAnonymousId(e,t){try{var n;null===(n=this.getAnalyticsInstance())||void 0===n||n.setAnonymousId(eD(e),eD(t))}catch(e){eM(e)}}getUserId(){try{var e;return null===(e=this.getAnalyticsInstance())||void 0===e?void 0:e.getUserId()}catch(e){eM(e);return}}getUserTraits(){try{var e;return null===(e=this.getAnalyticsInstance())||void 0===e?void 0:e.getUserTraits()}catch(e){eM(e);return}}getGroupId(){try{var e;return null===(e=this.getAnalyticsInstance())||void 0===e?void 0:e.getGroupId()}catch(e){eM(e);return}}getGroupTraits(){try{var e;return null===(e=this.getAnalyticsInstance())||void 0===e?void 0:e.getGroupTraits()}catch(e){eM(e);return}}startSession(e){try{var t;null===(t=this.getAnalyticsInstance())||void 0===t||t.startSession(eD(e))}catch(e){eM(e)}}endSession(){try{var e;null===(e=this.getAnalyticsInstance())||void 0===e||e.endSession()}catch(e){eM(e)}}getSessionId(){try{var e;return null===(e=this.getAnalyticsInstance())||void 0===e?void 0:e.getSessionId()}catch(e){eM(e);return}}setAuthToken(e){try{var t;null===(t=this.getAnalyticsInstance())||void 0===t||t.setAuthToken(eD(e))}catch(e){eM(e)}}consent(e){try{var t;null===(t=this.getAnalyticsInstance())||void 0===t||t.consent(eD(e))}catch(e){eM(e)}}constructor(){this.analyticsInstances={},this.defaultAnalyticsKey="",this.logger=tp;try{if(oj.globalSingleton)return oj.globalSingleton;oj.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),oj.globalSingleton=this,nL.autoTrack.pageLifecycle.visitId.value=ey(),nL.autoTrack.pageLifecycle.pageLoadedTimestamp.value=Date.now(),this.triggerBufferedLoadEvent(),globalThis.rudderanalytics=this}catch(e){eM(e)}}}oj.globalSingleton=null}}]);