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