@mparticle/web-rokt-kit 1.28.1 → 1.28.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const q=["billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],B=new Set(q);function z(n){return B.has(n.toLowerCase())}function S(n){const e={},t=n||{},i=Object.keys(t);for(let r=0;r<i.length;r++){const s=i[r];z(s)||(e[s]=t[s])}return e}const d="Rokt",b=181,J="selectPlacements",Q="apps.roktecommerce.com",X=.1,$="ThankYouPageJourney",Z="rokt-launcher",ee="rokt-thank-you-element",te="userIdentifiedInWorkspace",ie=500,O={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},L={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},ne="apps.rokt-api.com/v1/log",re="apps.rokt-api.com/v1/errors",se=10;function a(){return window.mParticle}function C(n,e){const i=[W(n),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?i:i+"?extensions="+e.join(",")}function U(n){return[W(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function W(n){return["https://",typeof n<"u"?n:"apps.rokt-api.com"].join("")}function K(n,e,t){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),i.appendChild(r)}function T(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function w(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function M(n){const e=n?w(n):[],t=[],i=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,i.push($)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:i,loadThankYouElement:r}}async function oe(n,e){const t=[];if(e)for(const i of n)t.push(e.use(i));return Promise.all(t)}function x(n){if(!n)return{};const e={};for(let t=0;t<n.length;t++){const i=n[t];e[i.jsmap]=i.value}return e}function D(n){const e={};if(!Array.isArray(n))return e;for(let t=0;t<n.length;t++){const i=n[t];if(!i||!f(i.value)||!f(i.map))continue;const r=i.value,s=i.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return e}function j(n,e,t){return a().generateHash([n,e,t].join(""))}function k(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function f(n){return typeof n=="string"}function ae(n){let i="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.28.1";return n&&(i+="_"+n),i}function G(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t),e=e&e;return e}function N(n){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=n,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function Y(n,e){const t=G(window.location.origin);if(m._allowedOriginHashes.indexOf(t)===-1||Math.random()>=X)return;const r=window.__rokt_li_guid__;if(!r)return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s);N("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),N("https://"+Q+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function ce(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function le(){return typeof window<"u"?window.location?.href:void 0}function ue(){return typeof window<"u"?window.navigator?.userAgent:void 0}class V{constructor(){this._logCount={}}incrementAndCheck(e){const i=(this._logCount[e]||0)+1;return this._logCount[e]=i,i>se}}class P{constructor(e,t,i,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=s||new V,this._isEnabled=ce()||o}send(e,t,i,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:t,code:r||O.UNKNOWN_ERROR,url:le(),deviceInfo:ue(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class F{constructor(e,t,i,r,s){this._transport=new P(e,t,i,r,s),this._errorUrl="https://"+(e?.errorUrl||re)}report(e){if(!e)return;const t=e.severity||L.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class H{constructor(e,t,i,r,s,o){this._transport=new P(e,i,r,s,o),this._loggingUrl="https://"+(e?.loggingUrl||ne),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,L.INFO,e.message,e.code,void 0,t=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:O.UNKNOWN_ERROR,severity:L.ERROR})})}}const h=class h{constructor(){this.name=d,this.id=b,this.moduleId=b,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const i=e&&e.EventAttributes;return!i||typeof i[t]>"u"?null:i[t]}doesEventAttributeConditionMatch(e,t){if(!e||!f(e.operator))return!1;const i=e.operator.toLowerCase(),r=e.attributeValue;return i==="exists"?t!==null:t==null?!1:i==="equals"?String(t)===String(r):i==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!f(t.eventAttributeKey))return!1;const i=t.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(i.length===0)return r!==null;for(let s=0;s<i.length;s++)if(!this.doesEventAttributeConditionMatch(i[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<t.length;i++){const r=t[i],s=this.placementEventAttributeMappingLookup[r];if(k(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:k(this.placementEventMappingLookup)&&k(this.placementEventAttributeMappingLookup)?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},i=this._mappedEmailSha256Key;return i&&e[i]&&(t[h.EMAIL_SHA256_KEY]=e[i]),i&&delete t[i],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!T(e))return;const t=a().EventType.Other;a().logEvent(J,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(b,{roktSessionId:e})}catch{}}attachLauncher(e,t,i=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await oe(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,Y(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,i,r,s){const o=e,c=o.accountId;this.userAttributes=S(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=w(o.placementEventMapping);this.placementEventMappingLookup=x(u);const l=w(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=D(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=f(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const E=a().Rokt?.domain,{roktExtensionsQueryParams:v,legacyRoktExtensions:I,loadThankYouElement:R}=M(o.roktExtensions),p={...a().Rokt?.launcherOptions||{}};this.integrationName=ae(p.integrationName),p.integrationName=this.integrationName,this.domain=E;const _={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,isLoggingEnabled:a().config?.isLoggingEnabled===!0},y=new F(_,this.integrationName,window.__rokt_li_guid__,o.accountId),A=new H(_,y,this.integrationName,window.__rokt_li_guid__,o.accountId);return this.errorReportingService=y,this.loggingService=A,a()._registerErrorReportingService&&a()._registerErrorReportingService(y),a()._registerLoggingService&&a()._registerLoggingService(A),i?(this.testHelpers={generateLauncherScript:C,generateThankYouElementScript:U,extractRoktExtensionConfig:M,hashEventMessage:j,parseSettingsString:w,generateMappedEventLookup:x,generateMappedEventAttributeLookup:D,sendAdBlockMeasurementSignals:Y,createAutoRemovedIframe:N,djb2:G,setAllowedOriginHashes:g=>{h._allowedOriginHashes=g},ReportingTransport:P,ErrorReportingService:F,LoggingService:H,RateLimiter:V,ErrorCodes:O,WSDKErrorSeverity:L},this.attachLauncher(c,p),"Successfully initialized: "+d):(R&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),K(ee,U(E),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:g=>{console.error("Error loading Rokt Thank You Element script:",g)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,p,I):(K(Z,C(E,v),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,p,I):console.error("Rokt object is not available after script load.")},onError:g=>{console.error("Error loading Rokt launcher script:",g)}}),this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(k(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!k(this.placementEventMappingLookup))){const t=j(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return z(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=S(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const i=a().Identity?.search;if(typeof i!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];f(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{i(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(i=>setTimeout(i,ie))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...S(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=S(l);const E=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},v=this.returnUserIdentities(c),I=this.returnLocalSessionAttributes(),R={...v,...l,...E,...I,...this.userIdentifiedInWorkspace?{[te]:!0}:{},mpid:u},p={...e,attributes:R},_=this.launcher.selectPlacements(p),y=()=>this.logSelectPlacementsEvent(R);return Promise.resolve(_).then(A=>A?.context?.sessionId?.then(g=>this.setRoktSessionId(g))).catch(()=>{}).finally(y),_}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!f(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};h._allowedOriginHashes=[-553112570,549508659],h.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},h.EMAIL_SHA256_KEY="emailsha256";let m=h;function de(){return b}function he(n){if(!n){window.console.log("You must pass a config object to register the kit "+d);return}if(!T(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}T(n.kits)?n.kits[d]={constructor:m}:(n.kits={},n.kits[d]={constructor:m}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:m,getId:de});exports.register=he;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const B=["billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],J=new Set(B);function G(n){return J.has(n.toLowerCase())}function w(n){const t={},e=n||{},i=Object.keys(e);for(let r=0;r<i.length;r++){const s=i[r];G(s)||(t[s]=e[s])}return t}const d="Rokt",b=181,Q="selectPlacements",X="apps.roktecommerce.com",$=.1,Z="ThankYouPageJourney",tt="rokt-launcher",et="rokt-thank-you-element",it="userIdentifiedInWorkspace",nt=500,N={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},I={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},rt="apps.rokt-api.com",st="/v1/log",ot="/v1/errors",at=10;function a(){return window.mParticle}function U(n,t){const i=[P(n),"/wsdk/integrations/launcher.js"].join("");return!t||t.length===0?i:i+"?extensions="+t.join(",")}function K(n){return[P(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function P(n){return["https://",typeof n<"u"?n:rt].join("")}function z(n,t,e){return n?n.startsWith("http://")||n.startsWith("https://")?n:"https://"+n:P(t)+e}function M(n,t,e){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,r.type="text/javascript",r.src=t,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",e?.onLoad&&(r.onload=e.onLoad),e?.onError&&(r.onerror=e.onError),i.appendChild(r)}function T(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function L(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function D(n){const t=n?L(n):[],e=[],i=[];let r=!1;for(let s=0;s<t.length;s++){const o=t[s].value;o==="thank-you-journey"?(r=!0,i.push(Z)):e.push(o)}return{roktExtensionsQueryParams:e,legacyRoktExtensions:i,loadThankYouElement:r}}async function ct(n,t){const e=[];if(t)for(const i of n)e.push(t.use(i));return Promise.all(e)}function x(n){if(!n)return{};const t={};for(let e=0;e<n.length;e++){const i=n[e];t[i.jsmap]=i.value}return t}function Y(n){const t={};if(!Array.isArray(n))return t;for(let e=0;e<n.length;e++){const i=n[e];if(!i||!m(i.value)||!m(i.map))continue;const r=i.value,s=i.map;t[r]||(t[r]=[]),t[r].push({eventAttributeKey:s,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return t}function j(n,t,e){return a().generateHash([n,t,e].join(""))}function k(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function m(n){return typeof n=="string"}function lt(n){let i="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.28.3";return n&&(i+="_"+n),i}function V(n){let t=5381;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e),t=t&t;return t}function O(n){const t=document.createElement("iframe");t.style.display="none",t.setAttribute("sandbox","allow-scripts allow-same-origin"),t.src=n,t.onload=function(){t.onload=null,t.parentNode&&t.parentNode.removeChild(t)};const e=document.body||document.head;e&&e.appendChild(t)}function F(n,t){const e=V(window.location.origin);if(E._allowedOriginHashes.indexOf(e)===-1||Math.random()>=$)return;const r=window.__rokt_li_guid__;if(!r)return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(t??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s);O("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),O("https://"+X+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function ut(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function dt(){return typeof window<"u"?window.location?.href:void 0}function ht(){return typeof window<"u"?window.navigator?.userAgent:void 0}class q{constructor(){this._logCount={}}incrementAndCheck(t){const i=(this._logCount[t]||0)+1;return this._logCount[t]=i,i>at}}class C{constructor(t,e,i,r,s){this._reporter="mp-wsdk";const o=t.isLoggingEnabled;this._integrationName=e||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=s||new q,this._isEnabled=ut()||o}send(t,e,i,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(e)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:e,code:r||N.UNKNOWN_ERROR,url:dt(),deviceInfo:ht(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(t,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const h=new Error("HTTP "+l.status+" from log endpoint");throw h.statusCode=l.status,h}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class H{constructor(t,e,i,r,s){this._transport=new C(t,e,i,r,s),this._errorUrl=z(t?.errorUrl,t?.integrationDomain,ot)}report(t){if(!t)return;const e=t.severity||I.ERROR;this._transport.send(this._errorUrl,e,t.message,t.code,t.stackTrace)}}class W{constructor(t,e,i,r,s,o){this._transport=new C(t,i,r,s,o),this._loggingUrl=z(t?.loggingUrl,t?.integrationDomain,st),this._errorReportingService=e}log(t){t&&this._transport.send(this._loggingUrl,I.INFO,t.message,t.code,void 0,e=>{if(this._errorReportingService){const i=typeof e.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+e.message,code:N.LOG_DELIVERY_FAILURE,severity:i?I.ERROR:I.WARNING})}})}}const p=class p{constructor(){this.name=d,this.id=b,this.moduleId=b,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(t,e){const i=t&&t.EventAttributes;return!i||typeof i[e]>"u"?null:i[e]}doesEventAttributeConditionMatch(t,e){if(!t||!m(t.operator))return!1;const i=t.operator.toLowerCase(),r=t.attributeValue;return i==="exists"?e!==null:e==null?!1:i==="equals"?String(e)===String(r):i==="contains"?String(e).indexOf(String(r))!==-1:!1}doesEventMatchRule(t,e){if(!e||!m(e.eventAttributeKey))return!1;const i=e.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(t,e.eventAttributeKey);if(i.length===0)return r!==null;for(let s=0;s<i.length;s++)if(!this.doesEventAttributeConditionMatch(i[s],r))return!1;return!0}applyPlacementEventAttributeMapping(t){const e=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<e.length;i++){const r=e[i],s=this.placementEventAttributeMappingLookup[r];if(k(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(t,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}returnUserIdentities(t){if(!t||!t.getUserIdentities)return{};const e=t.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(e)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:k(this.placementEventMappingLookup)&&k(this.placementEventAttributeMappingLookup)?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(t){const e={...t||{}},i=this._mappedEmailSha256Key;return i&&t[i]&&(e[p.EMAIL_SHA256_KEY]=t[i]),i&&delete e[i],e}logSelectPlacementsEvent(t){if(!window.mParticle||typeof a().logEvent!="function"||!T(t))return;const e=a().EventType.Other;a().logEvent(Q,e,t)}setRoktSessionId(t){if(!(!t||typeof t!="string"))try{const e=a().getInstance();e&&typeof e.setIntegrationAttribute=="function"&&e.setIntegrationAttribute(b,{roktSessionId:t})}catch{}}attachLauncher(t,e,i=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:t,...e||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await ct(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(t){window.Rokt&&(window.Rokt.currentLauncher=t),this.launcher=t;const e=a().Rokt?.filters;e?(this.filters=e,e.filteredUser?this._workspaceSearchInFlightPromise=this.search(e.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,F(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const t=a()._getActiveForwarders().filter(e=>e.name==="Optimizely");try{if(t.length>0&&window.optimizely){const e=window.optimizely.get("state");return!e||!e.getActiveExperimentIds?{}:e.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=e.getVariationMap()[o].id,s),{})}}catch(e){console.error("Error fetching Optimizely attributes:",e)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(t){window&&a()&&a().captureTiming&&t&&a().captureTiming(t)}init(t,e,i,r,s){const o=t,c=o.accountId;this.userAttributes=w(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=L(o.placementEventMapping);this.placementEventMappingLookup=x(u);const l=L(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Y(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const h=a().Rokt?.domain,{roktExtensionsQueryParams:v,legacyRoktExtensions:R,loadThankYouElement:A}=D(o.roktExtensions),g={...a().Rokt?.launcherOptions||{}};this.integrationName=lt(g.integrationName),g.integrationName=this.integrationName,this.domain=h;const _={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:h,isLoggingEnabled:a().config?.isLoggingEnabled===!0},y=new H(_,this.integrationName,window.__rokt_li_guid__,o.accountId),S=new W(_,y,this.integrationName,window.__rokt_li_guid__,o.accountId);return this.errorReportingService=y,this.loggingService=S,a()._registerErrorReportingService&&a()._registerErrorReportingService(y),a()._registerLoggingService&&a()._registerLoggingService(S),i?(this.testHelpers={generateLauncherScript:U,generateThankYouElementScript:K,extractRoktExtensionConfig:D,hashEventMessage:j,parseSettingsString:L,generateMappedEventLookup:x,generateMappedEventAttributeLookup:Y,sendAdBlockMeasurementSignals:F,createAutoRemovedIframe:O,djb2:V,setAllowedOriginHashes:f=>{p._allowedOriginHashes=f},ReportingTransport:C,ErrorReportingService:H,LoggingService:W,RateLimiter:q,ErrorCodes:N,WSDKErrorSeverity:I},this.attachLauncher(c,g),"Successfully initialized: "+d):(A&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),M(et,K(h),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:f=>{console.error("Error loading Rokt Thank You Element script:",f)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,g,R):(M(tt,U(h,v),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,g,R):console.error("Rokt object is not available after script load.")},onError:f=>{console.error("Error loading Rokt launcher script:",f)}}),this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(t){if(!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(k(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(t),!k(this.placementEventMappingLookup))){const e=j(t.EventDataType,t.EventCategory,t.EventName??"");this.placementEventMappingLookup[String(e)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(e)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(t){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(t)}setUserAttribute(t,e){return G(t)||(this.userAttributes[t]=e),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(t){return delete this.userAttributes[t],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(t,e){return this.userAttributes=w(t.getAllUserAttributes()),"Successfully called "+e+" for forwarder: "+d}onUserIdentified(t){const e=t;return this.filters.filteredUser=e,this._workspaceSearchInFlightPromise=this.search(e),this.handleIdentityComplete(t,"onUserIdentified")}search(t){const e=this._workspaceIdSyncApiKey;if(!e)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const i=a().Identity?.search;if(typeof i!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=t.getUserIdentities?t.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];m(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{i(e,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(t,e){return this.handleIdentityComplete(t,"onLoginComplete")}onLogoutComplete(t,e){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(t,"onLogoutComplete")}onModifyComplete(t,e){return this.handleIdentityComplete(t,"onModifyComplete")}selectPlacements(t){if(this._workspaceSearchInFlightPromise){const e=this._workspaceSearchInFlightPromise;return Promise.race([e,new Promise(i=>setTimeout(i,nt))]).then(()=>this._dispatchPlacements(t))}return this._dispatchPlacements(t)}_dispatchPlacements(t){const e=t&&t.attributes||{},r={...w(this.userAttributes),...e},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=w(l);const h=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},v=this.returnUserIdentities(c),R=this.returnLocalSessionAttributes(),A={...v,...l,...h,...R,...this.userIdentifiedInWorkspace?{[it]:!0}:{},mpid:u},g={...t,attributes:A},_=this.launcher.selectPlacements(g),y=()=>this.logSelectPlacementsEvent(A);return Promise.resolve(_).then(S=>S?.context?.sessionId?.then(f=>this.setRoktSessionId(f))).catch(()=>{}).finally(y),_}hashAttributes(t){return this.isKitReady()?this.launcher.hashAttributes(t):(console.error("Rokt Kit: Not initialized"),null)}use(t){return this.isKitReady()?!t||!m(t)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(t):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(t){this._isThankYouElementLoaded?t():this._thankYouElementOnLoadCallback=t}};p._allowedOriginHashes=[-553112570,549508659],p.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},p.EMAIL_SHA256_KEY="emailsha256";let E=p;function pt(){return b}function gt(n){if(!n){window.console.log("You must pass a config object to register the kit "+d);return}if(!T(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}T(n.kits)?n.kits[d]={constructor:E}:(n.kits={},n.kits[d]={constructor:E}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:E,getId:pt});exports.register=gt;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -1,4 +1,4 @@
1
- const q = [
1
+ const B = [
2
2
  "billingaddress1",
3
3
  "billingaddress2",
4
4
  "billingcity",
@@ -22,49 +22,53 @@ const q = [
22
22
  "shippingstate",
23
23
  "shippingzipcode",
24
24
  "totalprice"
25
- ], B = new Set(q);
26
- function z(n) {
27
- return B.has(n.toLowerCase());
25
+ ], J = new Set(B);
26
+ function G(n) {
27
+ return J.has(n.toLowerCase());
28
28
  }
29
- function S(n) {
30
- const e = {}, t = n || {}, i = Object.keys(t);
29
+ function w(n) {
30
+ const t = {}, e = n || {}, i = Object.keys(e);
31
31
  for (let r = 0; r < i.length; r++) {
32
32
  const s = i[r];
33
- z(s) || (e[s] = t[s]);
33
+ G(s) || (t[s] = e[s]);
34
34
  }
35
- return e;
35
+ return t;
36
36
  }
37
- const d = "Rokt", w = 181, J = "selectPlacements", Q = "apps.roktecommerce.com", X = 0.1, $ = "ThankYouPageJourney", Z = "rokt-launcher", ee = "rokt-thank-you-element", te = "userIdentifiedInWorkspace", ie = 500, O = {
37
+ const d = "Rokt", b = 181, Q = "selectPlacements", X = "apps.roktecommerce.com", $ = 0.1, Z = "ThankYouPageJourney", tt = "rokt-launcher", et = "rokt-thank-you-element", it = "userIdentifiedInWorkspace", nt = 500, O = {
38
38
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
39
39
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
40
- IDENTITY_REQUEST: "IDENTITY_REQUEST"
41
- }, L = {
40
+ IDENTITY_REQUEST: "IDENTITY_REQUEST",
41
+ LOG_DELIVERY_FAILURE: "LOG_DELIVERY_FAILURE"
42
+ }, I = {
42
43
  ERROR: "ERROR",
43
44
  INFO: "INFO",
44
45
  WARNING: "WARNING"
45
- }, ne = "apps.rokt-api.com/v1/log", re = "apps.rokt-api.com/v1/errors", se = 10;
46
+ }, rt = "apps.rokt-api.com", st = "/v1/log", ot = "/v1/errors", at = 10;
46
47
  function a() {
47
48
  return window.mParticle;
48
49
  }
49
- function C(n, e) {
50
- const i = [W(n), "/wsdk/integrations/launcher.js"].join("");
51
- return !e || e.length === 0 ? i : i + "?extensions=" + e.join(",");
50
+ function U(n, t) {
51
+ const i = [P(n), "/wsdk/integrations/launcher.js"].join("");
52
+ return !t || t.length === 0 ? i : i + "?extensions=" + t.join(",");
53
+ }
54
+ function K(n) {
55
+ return [P(n), "/rokt-elements/rokt-element-thank-you.js"].join("");
52
56
  }
53
- function U(n) {
54
- return [W(n), "/rokt-elements/rokt-element-thank-you.js"].join("");
57
+ function P(n) {
58
+ return ["https://", typeof n < "u" ? n : rt].join("");
55
59
  }
56
- function W(n) {
57
- return ["https://", typeof n < "u" ? n : "apps.rokt-api.com"].join("");
60
+ function z(n, t, e) {
61
+ return n ? n.startsWith("http://") || n.startsWith("https://") ? n : "https://" + n : P(t) + e;
58
62
  }
59
- function K(n, e, t) {
63
+ function M(n, t, e) {
60
64
  if (document.getElementById(n)) return;
61
65
  const i = document.head || document.body, r = document.createElement("script");
62
- r.id = n, r.type = "text/javascript", r.src = e, r.async = !0, r.crossOrigin = "anonymous", r.fetchPriority = "high", t?.onLoad && (r.onload = t.onLoad), t?.onError && (r.onerror = t.onError), i.appendChild(r);
66
+ r.id = n, r.type = "text/javascript", r.src = t, r.async = !0, r.crossOrigin = "anonymous", r.fetchPriority = "high", e?.onLoad && (r.onload = e.onLoad), e?.onError && (r.onerror = e.onError), i.appendChild(r);
63
67
  }
64
68
  function T(n) {
65
69
  return n != null && typeof n == "object" && Array.isArray(n) === !1;
66
70
  }
67
- function b(n) {
71
+ function L(n) {
68
72
  if (!n)
69
73
  return [];
70
74
  try {
@@ -74,127 +78,127 @@ function b(n) {
74
78
  }
75
79
  return [];
76
80
  }
77
- function M(n) {
78
- const e = n ? b(n) : [], t = [], i = [];
81
+ function D(n) {
82
+ const t = n ? L(n) : [], e = [], i = [];
79
83
  let r = !1;
80
- for (let s = 0; s < e.length; s++) {
81
- const o = e[s].value;
82
- o === "thank-you-journey" ? (r = !0, i.push($)) : t.push(o);
84
+ for (let s = 0; s < t.length; s++) {
85
+ const o = t[s].value;
86
+ o === "thank-you-journey" ? (r = !0, i.push(Z)) : e.push(o);
83
87
  }
84
88
  return {
85
- roktExtensionsQueryParams: t,
89
+ roktExtensionsQueryParams: e,
86
90
  legacyRoktExtensions: i,
87
91
  loadThankYouElement: r
88
92
  };
89
93
  }
90
- async function oe(n, e) {
91
- const t = [];
92
- if (e)
94
+ async function ct(n, t) {
95
+ const e = [];
96
+ if (t)
93
97
  for (const i of n)
94
- t.push(e.use(i));
95
- return Promise.all(t);
98
+ e.push(t.use(i));
99
+ return Promise.all(e);
96
100
  }
97
101
  function x(n) {
98
102
  if (!n)
99
103
  return {};
100
- const e = {};
101
- for (let t = 0; t < n.length; t++) {
102
- const i = n[t];
103
- e[i.jsmap] = i.value;
104
+ const t = {};
105
+ for (let e = 0; e < n.length; e++) {
106
+ const i = n[e];
107
+ t[i.jsmap] = i.value;
104
108
  }
105
- return e;
109
+ return t;
106
110
  }
107
- function D(n) {
108
- const e = {};
111
+ function Y(n) {
112
+ const t = {};
109
113
  if (!Array.isArray(n))
110
- return e;
111
- for (let t = 0; t < n.length; t++) {
112
- const i = n[t];
113
- if (!i || !f(i.value) || !f(i.map))
114
+ return t;
115
+ for (let e = 0; e < n.length; e++) {
116
+ const i = n[e];
117
+ if (!i || !m(i.value) || !m(i.map))
114
118
  continue;
115
119
  const r = i.value, s = i.map;
116
- e[r] || (e[r] = []), e[r].push({
120
+ t[r] || (t[r] = []), t[r].push({
117
121
  eventAttributeKey: s,
118
122
  conditions: Array.isArray(i.conditions) ? i.conditions : []
119
123
  });
120
124
  }
121
- return e;
125
+ return t;
122
126
  }
123
- function j(n, e, t) {
124
- return a().generateHash([n, e, t].join(""));
127
+ function F(n, t, e) {
128
+ return a().generateHash([n, t, e].join(""));
125
129
  }
126
130
  function k(n) {
127
131
  return n == null ? !0 : typeof n == "object" ? Object.keys(n).length === 0 : Array.isArray(n) ? n.length === 0 : !1;
128
132
  }
129
- function f(n) {
133
+ function m(n) {
130
134
  return typeof n == "string";
131
135
  }
132
- function ae(n) {
133
- let i = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.28.1";
136
+ function lt(n) {
137
+ let i = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.28.3";
134
138
  return n && (i += "_" + n), i;
135
139
  }
136
- function G(n) {
137
- let e = 5381;
138
- for (let t = 0; t < n.length; t++)
139
- e = (e << 5) + e + n.charCodeAt(t), e = e & e;
140
- return e;
140
+ function V(n) {
141
+ let t = 5381;
142
+ for (let e = 0; e < n.length; e++)
143
+ t = (t << 5) + t + n.charCodeAt(e), t = t & t;
144
+ return t;
141
145
  }
142
146
  function N(n) {
143
- const e = document.createElement("iframe");
144
- e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = n, e.onload = function() {
145
- e.onload = null, e.parentNode && e.parentNode.removeChild(e);
147
+ const t = document.createElement("iframe");
148
+ t.style.display = "none", t.setAttribute("sandbox", "allow-scripts allow-same-origin"), t.src = n, t.onload = function() {
149
+ t.onload = null, t.parentNode && t.parentNode.removeChild(t);
146
150
  };
147
- const t = document.body || document.head;
148
- t && t.appendChild(e);
151
+ const e = document.body || document.head;
152
+ e && e.appendChild(t);
149
153
  }
150
- function Y(n, e) {
151
- const t = G(window.location.origin);
152
- if (m._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= X)
154
+ function j(n, t) {
155
+ const e = V(window.location.origin);
156
+ if (E._allowedOriginHashes.indexOf(e) === -1 || Math.random() >= $)
153
157
  return;
154
158
  const r = window.__rokt_li_guid__;
155
159
  if (!r)
156
160
  return;
157
- const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s);
161
+ const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(t ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s);
158
162
  N("https://" + (n || "apps.rokt.com") + "/v1/wsdk-init/index.html?" + o), N(
159
- "https://" + Q + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
163
+ "https://" + X + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
160
164
  );
161
165
  }
162
- function ce() {
166
+ function ut() {
163
167
  return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
164
168
  }
165
- function le() {
169
+ function dt() {
166
170
  return typeof window < "u" ? window.location?.href : void 0;
167
171
  }
168
- function ue() {
172
+ function ht() {
169
173
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
170
174
  }
171
- class V {
175
+ class q {
172
176
  constructor() {
173
177
  this._logCount = {};
174
178
  }
175
- incrementAndCheck(e) {
176
- const i = (this._logCount[e] || 0) + 1;
177
- return this._logCount[e] = i, i > se;
179
+ incrementAndCheck(t) {
180
+ const i = (this._logCount[t] || 0) + 1;
181
+ return this._logCount[t] = i, i > at;
178
182
  }
179
183
  }
180
- class P {
181
- constructor(e, t, i, r, s) {
184
+ class C {
185
+ constructor(t, e, i, r, s) {
182
186
  this._reporter = "mp-wsdk";
183
- const o = e.isLoggingEnabled;
184
- this._integrationName = t || "", this._launcherInstanceGuid = i, this._accountId = r || null, this._rateLimiter = s || new V(), this._isEnabled = ce() || o;
187
+ const o = t.isLoggingEnabled;
188
+ this._integrationName = e || "", this._launcherInstanceGuid = i, this._accountId = r || null, this._rateLimiter = s || new q(), this._isEnabled = ut() || o;
185
189
  }
186
- send(e, t, i, r, s, o) {
187
- if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
190
+ send(t, e, i, r, s, o) {
191
+ if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(e)))
188
192
  try {
189
193
  const c = {
190
194
  additionalInformation: {
191
195
  message: i,
192
196
  version: this._integrationName
193
197
  },
194
- severity: t,
198
+ severity: e,
195
199
  code: r || O.UNKNOWN_ERROR,
196
- url: le(),
197
- deviceInfo: ue(),
200
+ url: dt(),
201
+ deviceInfo: ht(),
198
202
  stackTrace: s,
199
203
  reporter: this._reporter,
200
204
  integration: this._integrationName
@@ -204,10 +208,15 @@ class P {
204
208
  "rokt-launcher-version": this._integrationName,
205
209
  "rokt-wsdk-version": "joint"
206
210
  };
207
- this._launcherInstanceGuid && (u["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (u["rokt-account-id"] = this._accountId), fetch(e, {
211
+ this._launcherInstanceGuid && (u["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (u["rokt-account-id"] = this._accountId), fetch(t, {
208
212
  method: "POST",
209
213
  headers: u,
210
214
  body: JSON.stringify(c)
215
+ }).then((l) => {
216
+ if (!l.ok) {
217
+ const h = new Error("HTTP " + l.status + " from log endpoint");
218
+ throw h.statusCode = l.status, h;
219
+ }
211
220
  }).catch((l) => {
212
221
  console.error("ReportingTransport: Failed to send log", l), o && o(l);
213
222
  });
@@ -216,59 +225,62 @@ class P {
216
225
  }
217
226
  }
218
227
  }
219
- class F {
220
- constructor(e, t, i, r, s) {
221
- this._transport = new P(e, t, i, r, s), this._errorUrl = "https://" + (e?.errorUrl || re);
228
+ class H {
229
+ constructor(t, e, i, r, s) {
230
+ this._transport = new C(t, e, i, r, s), this._errorUrl = z(t?.errorUrl, t?.integrationDomain, ot);
222
231
  }
223
- report(e) {
224
- if (!e) return;
225
- const t = e.severity || L.ERROR;
226
- this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
232
+ report(t) {
233
+ if (!t) return;
234
+ const e = t.severity || I.ERROR;
235
+ this._transport.send(this._errorUrl, e, t.message, t.code, t.stackTrace);
227
236
  }
228
237
  }
229
- class H {
230
- constructor(e, t, i, r, s, o) {
231
- this._transport = new P(e, i, r, s, o), this._loggingUrl = "https://" + (e?.loggingUrl || ne), this._errorReportingService = t;
238
+ class W {
239
+ constructor(t, e, i, r, s, o) {
240
+ this._transport = new C(t, i, r, s, o), this._loggingUrl = z(t?.loggingUrl, t?.integrationDomain, st), this._errorReportingService = e;
232
241
  }
233
- log(e) {
234
- e && this._transport.send(
242
+ log(t) {
243
+ t && this._transport.send(
235
244
  this._loggingUrl,
236
- L.INFO,
237
- e.message,
238
- e.code,
245
+ I.INFO,
246
+ t.message,
247
+ t.code,
239
248
  void 0,
240
- (t) => {
241
- this._errorReportingService && this._errorReportingService.report({
242
- message: "LoggingService: Failed to send log: " + t.message,
243
- code: O.UNKNOWN_ERROR,
244
- severity: L.ERROR
245
- });
249
+ (e) => {
250
+ if (this._errorReportingService) {
251
+ const i = typeof e.statusCode == "number";
252
+ this._errorReportingService.report({
253
+ message: "LoggingService: Failed to send log: " + e.message,
254
+ code: O.LOG_DELIVERY_FAILURE,
255
+ severity: i ? I.ERROR : I.WARNING
256
+ });
257
+ }
246
258
  }
247
259
  );
248
260
  }
249
261
  }
250
- const h = class h {
262
+ const p = class p {
251
263
  constructor() {
252
- this.name = d, this.id = w, this.moduleId = w, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null;
264
+ this.name = d, this.id = b, this.moduleId = b, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null;
253
265
  }
254
266
  // ---- Private helpers ----
255
- getEventAttributeValue(e, t) {
256
- const i = e && e.EventAttributes;
257
- return !i || typeof i[t] > "u" ? null : i[t];
267
+ getEventAttributeValue(t, e) {
268
+ const i = t && t.EventAttributes;
269
+ return !i || typeof i[e] > "u" ? null : i[e];
258
270
  }
259
- doesEventAttributeConditionMatch(e, t) {
260
- if (!e || !f(e.operator))
271
+ doesEventAttributeConditionMatch(t, e) {
272
+ if (!t || !m(t.operator))
261
273
  return !1;
262
- const i = e.operator.toLowerCase(), r = e.attributeValue;
263
- return i === "exists" ? t !== null : t == null ? !1 : i === "equals" ? String(t) === String(r) : i === "contains" ? String(t).indexOf(String(r)) !== -1 : !1;
274
+ const i = t.operator.toLowerCase(), r = t.attributeValue;
275
+ return i === "exists" ? e !== null : e == null ? !1 : i === "equals" ? String(e) === String(r) : i === "contains" ? String(e).indexOf(String(r)) !== -1 : !1;
264
276
  }
265
- doesEventMatchRule(e, t) {
266
- if (!t || !f(t.eventAttributeKey))
277
+ doesEventMatchRule(t, e) {
278
+ if (!e || !m(e.eventAttributeKey))
267
279
  return !1;
268
- const i = t.conditions;
280
+ const i = e.conditions;
269
281
  if (!Array.isArray(i))
270
282
  return !1;
271
- const r = this.getEventAttributeValue(e, t.eventAttributeKey);
283
+ const r = this.getEventAttributeValue(t, e.eventAttributeKey);
272
284
  if (i.length === 0)
273
285
  return r !== null;
274
286
  for (let s = 0; s < i.length; s++)
@@ -276,15 +288,15 @@ const h = class h {
276
288
  return !1;
277
289
  return !0;
278
290
  }
279
- applyPlacementEventAttributeMapping(e) {
280
- const t = Object.keys(this.placementEventAttributeMappingLookup);
281
- for (let i = 0; i < t.length; i++) {
282
- const r = t[i], s = this.placementEventAttributeMappingLookup[r];
291
+ applyPlacementEventAttributeMapping(t) {
292
+ const e = Object.keys(this.placementEventAttributeMappingLookup);
293
+ for (let i = 0; i < e.length; i++) {
294
+ const r = e[i], s = this.placementEventAttributeMappingLookup[r];
283
295
  if (k(s))
284
296
  continue;
285
297
  let o = !0;
286
298
  for (let c = 0; c < s.length; c++)
287
- if (!this.doesEventMatchRule(e, s[c])) {
299
+ if (!this.doesEventMatchRule(t, s[c])) {
288
300
  o = !1;
289
301
  break;
290
302
  }
@@ -297,62 +309,62 @@ const h = class h {
297
309
  /**
298
310
  * Returns the user identities from the filtered user, if any.
299
311
  */
300
- returnUserIdentities(e) {
301
- if (!e || !e.getUserIdentities)
312
+ returnUserIdentities(t) {
313
+ if (!t || !t.getUserIdentities)
302
314
  return {};
303
- const t = e.getUserIdentities().userIdentities;
304
- return this.replaceOtherIdentityWithEmailsha256(t);
315
+ const e = t.getUserIdentities().userIdentities;
316
+ return this.replaceOtherIdentityWithEmailsha256(e);
305
317
  }
306
318
  returnLocalSessionAttributes() {
307
319
  return !a().Rokt || typeof a().Rokt.getLocalSessionAttributes != "function" ? {} : k(this.placementEventMappingLookup) && k(this.placementEventAttributeMappingLookup) ? {} : a().Rokt.getLocalSessionAttributes();
308
320
  }
309
- replaceOtherIdentityWithEmailsha256(e) {
310
- const t = { ...e || {} }, i = this._mappedEmailSha256Key;
311
- return i && e[i] && (t[h.EMAIL_SHA256_KEY] = e[i]), i && delete t[i], t;
321
+ replaceOtherIdentityWithEmailsha256(t) {
322
+ const e = { ...t || {} }, i = this._mappedEmailSha256Key;
323
+ return i && t[i] && (e[p.EMAIL_SHA256_KEY] = t[i]), i && delete e[i], e;
312
324
  }
313
- logSelectPlacementsEvent(e) {
314
- if (!window.mParticle || typeof a().logEvent != "function" || !T(e))
325
+ logSelectPlacementsEvent(t) {
326
+ if (!window.mParticle || typeof a().logEvent != "function" || !T(t))
315
327
  return;
316
- const t = a().EventType.Other;
317
- a().logEvent(J, t, e);
328
+ const e = a().EventType.Other;
329
+ a().logEvent(Q, e, t);
318
330
  }
319
- setRoktSessionId(e) {
320
- if (!(!e || typeof e != "string"))
331
+ setRoktSessionId(t) {
332
+ if (!(!t || typeof t != "string"))
321
333
  try {
322
- const t = a().getInstance();
323
- t && typeof t.setIntegrationAttribute == "function" && t.setIntegrationAttribute(w, {
324
- roktSessionId: e
334
+ const e = a().getInstance();
335
+ e && typeof e.setIntegrationAttribute == "function" && e.setIntegrationAttribute(b, {
336
+ roktSessionId: t
325
337
  });
326
338
  } catch {
327
339
  }
328
340
  }
329
- attachLauncher(e, t, i = []) {
341
+ attachLauncher(t, e, i = []) {
330
342
  const r = a() && a().sessionManager && typeof a().sessionManager.getSession == "function" ? a().sessionManager.getSession() : void 0, s = {
331
- accountId: e,
332
- ...t || {},
343
+ accountId: t,
344
+ ...e || {},
333
345
  ...r ? { mpSessionId: r } : {}
334
346
  };
335
347
  let o;
336
348
  this.isPartnerInLocalLauncherTestGroup() ? o = Promise.resolve(window.Rokt.createLocalLauncher(s)) : o = window.Rokt.createLauncher(s), o.then(async (c) => {
337
- await oe(i, c), this.initRoktLauncher(c);
349
+ await ct(i, c), this.initRoktLauncher(c);
338
350
  }).catch((c) => {
339
351
  console.error("Error creating Rokt launcher:", c);
340
352
  });
341
353
  }
342
- initRoktLauncher(e) {
343
- window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e;
344
- const t = a().Rokt?.filters;
345
- t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, Y(this.domain, this.integrationName), a().Rokt.attachKit(this);
354
+ initRoktLauncher(t) {
355
+ window.Rokt && (window.Rokt.currentLauncher = t), this.launcher = t;
356
+ const e = a().Rokt?.filters;
357
+ e ? (this.filters = e, e.filteredUser ? this._workspaceSearchInFlightPromise = this.search(e.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, j(this.domain, this.integrationName), a().Rokt.attachKit(this);
346
358
  }
347
359
  fetchOptimizely() {
348
- const e = a()._getActiveForwarders().filter((t) => t.name === "Optimizely");
360
+ const t = a()._getActiveForwarders().filter((e) => e.name === "Optimizely");
349
361
  try {
350
- if (e.length > 0 && window.optimizely) {
351
- const t = window.optimizely.get("state");
352
- return !t || !t.getActiveExperimentIds ? {} : t.getActiveExperimentIds().reduce((s, o) => (s["rokt.custom.optimizely.experiment." + o + ".variationId"] = t.getVariationMap()[o].id, s), {});
362
+ if (t.length > 0 && window.optimizely) {
363
+ const e = window.optimizely.get("state");
364
+ return !e || !e.getActiveExperimentIds ? {} : e.getActiveExperimentIds().reduce((s, o) => (s["rokt.custom.optimizely.experiment." + o + ".variationId"] = e.getVariationMap()[o].id, s), {});
353
365
  }
354
- } catch (t) {
355
- console.error("Error fetching Optimizely attributes:", t);
366
+ } catch (e) {
367
+ console.error("Error fetching Optimizely attributes:", e);
356
368
  }
357
369
  return {};
358
370
  }
@@ -365,121 +377,122 @@ const h = class h {
365
377
  isAssignedToSampleGroup() {
366
378
  return Math.random() > 0.5;
367
379
  }
368
- captureTiming(e) {
369
- window && a() && a().captureTiming && e && a().captureTiming(e);
380
+ captureTiming(t) {
381
+ window && a() && a().captureTiming && t && a().captureTiming(t);
370
382
  }
371
383
  // ---- Public methods (mParticle Kit Callbacks) ----
372
384
  /**
373
385
  * Initializes the Rokt forwarder with settings from the mParticle server.
374
386
  */
375
- init(e, t, i, r, s) {
376
- const o = e, c = o.accountId;
377
- this.userAttributes = S(s), this._onboardingExpProvider = o.onboardingExpProvider;
378
- const u = b(o.placementEventMapping);
387
+ init(t, e, i, r, s) {
388
+ const o = t, c = o.accountId;
389
+ this.userAttributes = w(s), this._onboardingExpProvider = o.onboardingExpProvider;
390
+ const u = L(o.placementEventMapping);
379
391
  this.placementEventMappingLookup = x(u);
380
- const l = b(
392
+ const l = L(
381
393
  o.placementEventAttributeMapping
382
394
  );
383
- this.placementEventAttributeMappingLookup = D(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = f(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
384
- const E = a().Rokt?.domain, { roktExtensionsQueryParams: v, legacyRoktExtensions: I, loadThankYouElement: R } = M(
395
+ this.placementEventAttributeMappingLookup = Y(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
396
+ const h = a().Rokt?.domain, { roktExtensionsQueryParams: v, legacyRoktExtensions: R, loadThankYouElement: A } = D(
385
397
  o.roktExtensions
386
- ), p = {
398
+ ), g = {
387
399
  ...a().Rokt?.launcherOptions || {}
388
400
  };
389
- this.integrationName = ae(p.integrationName), p.integrationName = this.integrationName, this.domain = E;
401
+ this.integrationName = lt(g.integrationName), g.integrationName = this.integrationName, this.domain = h;
390
402
  const _ = {
391
403
  loggingUrl: o.loggingUrl,
392
404
  errorUrl: o.errorUrl,
405
+ integrationDomain: h,
393
406
  isLoggingEnabled: a().config?.isLoggingEnabled === !0
394
- }, y = new F(
407
+ }, y = new H(
395
408
  _,
396
409
  this.integrationName,
397
410
  window.__rokt_li_guid__,
398
411
  o.accountId
399
- ), A = new H(
412
+ ), S = new W(
400
413
  _,
401
414
  y,
402
415
  this.integrationName,
403
416
  window.__rokt_li_guid__,
404
417
  o.accountId
405
418
  );
406
- return this.errorReportingService = y, this.loggingService = A, a()._registerErrorReportingService && a()._registerErrorReportingService(y), a()._registerLoggingService && a()._registerLoggingService(A), i ? (this.testHelpers = {
407
- generateLauncherScript: C,
408
- generateThankYouElementScript: U,
409
- extractRoktExtensionConfig: M,
410
- hashEventMessage: j,
411
- parseSettingsString: b,
419
+ return this.errorReportingService = y, this.loggingService = S, a()._registerErrorReportingService && a()._registerErrorReportingService(y), a()._registerLoggingService && a()._registerLoggingService(S), i ? (this.testHelpers = {
420
+ generateLauncherScript: U,
421
+ generateThankYouElementScript: K,
422
+ extractRoktExtensionConfig: D,
423
+ hashEventMessage: F,
424
+ parseSettingsString: L,
412
425
  generateMappedEventLookup: x,
413
- generateMappedEventAttributeLookup: D,
414
- sendAdBlockMeasurementSignals: Y,
426
+ generateMappedEventAttributeLookup: Y,
427
+ sendAdBlockMeasurementSignals: j,
415
428
  createAutoRemovedIframe: N,
416
- djb2: G,
417
- setAllowedOriginHashes: (g) => {
418
- h._allowedOriginHashes = g;
429
+ djb2: V,
430
+ setAllowedOriginHashes: (f) => {
431
+ p._allowedOriginHashes = f;
419
432
  },
420
- ReportingTransport: P,
421
- ErrorReportingService: F,
422
- LoggingService: H,
423
- RateLimiter: V,
433
+ ReportingTransport: C,
434
+ ErrorReportingService: H,
435
+ LoggingService: W,
436
+ RateLimiter: q,
424
437
  ErrorCodes: O,
425
- WSDKErrorSeverity: L
426
- }, this.attachLauncher(c, p), "Successfully initialized: " + d) : (R && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), K(ee, U(E), {
438
+ WSDKErrorSeverity: I
439
+ }, this.attachLauncher(c, g), "Successfully initialized: " + d) : (A && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), M(et, K(h), {
427
440
  onLoad: () => {
428
441
  this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
429
442
  },
430
- onError: (g) => {
431
- console.error("Error loading Rokt Thank You Element script:", g);
443
+ onError: (f) => {
444
+ console.error("Error loading Rokt Thank You Element script:", f);
432
445
  }
433
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, I) : (K(Z, C(E, v), {
446
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, g, R) : (M(tt, U(h, v), {
434
447
  onLoad: () => {
435
- this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, I) : console.error("Rokt object is not available after script load.");
448
+ this.isLauncherReadyToAttach() ? this.attachLauncher(c, g, R) : console.error("Rokt object is not available after script load.");
436
449
  },
437
- onError: (g) => {
438
- console.error("Error loading Rokt launcher script:", g);
450
+ onError: (f) => {
451
+ console.error("Error loading Rokt launcher script:", f);
439
452
  }
440
- }), this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
453
+ }), this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
441
454
  }
442
- process(e) {
455
+ process(t) {
443
456
  if (!this.isKitReady())
444
457
  return "Kit not ready for forwarder: " + d;
445
- if (typeof a().Rokt?.setLocalSessionAttribute == "function" && (k(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !k(this.placementEventMappingLookup))) {
446
- const t = j(e.EventDataType, e.EventCategory, e.EventName ?? "");
447
- this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
458
+ if (typeof a().Rokt?.setLocalSessionAttribute == "function" && (k(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(t), !k(this.placementEventMappingLookup))) {
459
+ const e = F(t.EventDataType, t.EventCategory, t.EventName ?? "");
460
+ this.placementEventMappingLookup[String(e)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(e)], !0);
448
461
  }
449
462
  return "Successfully sent to forwarder: " + d;
450
463
  }
451
- setExtensionData(e) {
464
+ setExtensionData(t) {
452
465
  if (!this.isKitReady()) {
453
466
  console.error("Rokt Kit: Not initialized");
454
467
  return;
455
468
  }
456
- window.Rokt.setExtensionData(e);
469
+ window.Rokt.setExtensionData(t);
457
470
  }
458
- setUserAttribute(e, t) {
459
- return z(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
471
+ setUserAttribute(t, e) {
472
+ return G(t) || (this.userAttributes[t] = e), "Successfully set user attribute for forwarder: " + d;
460
473
  }
461
- removeUserAttribute(e) {
462
- return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
474
+ removeUserAttribute(t) {
475
+ return delete this.userAttributes[t], "Successfully removed user attribute for forwarder: " + d;
463
476
  }
464
- handleIdentityComplete(e, t) {
465
- return this.userAttributes = S(e.getAllUserAttributes()), "Successfully called " + t + " for forwarder: " + d;
477
+ handleIdentityComplete(t, e) {
478
+ return this.userAttributes = w(t.getAllUserAttributes()), "Successfully called " + e + " for forwarder: " + d;
466
479
  }
467
- onUserIdentified(e) {
468
- const t = e;
469
- return this.filters.filteredUser = t, this._workspaceSearchInFlightPromise = this.search(t), this.handleIdentityComplete(e, "onUserIdentified");
480
+ onUserIdentified(t) {
481
+ const e = t;
482
+ return this.filters.filteredUser = e, this._workspaceSearchInFlightPromise = this.search(e), this.handleIdentityComplete(t, "onUserIdentified");
470
483
  }
471
- search(e) {
472
- const t = this._workspaceIdSyncApiKey;
473
- if (!t)
484
+ search(t) {
485
+ const e = this._workspaceIdSyncApiKey;
486
+ if (!e)
474
487
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
475
488
  const i = a().Identity?.search;
476
489
  if (typeof i != "function")
477
490
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
478
- const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
491
+ const r = t.getUserIdentities ? t.getUserIdentities().userIdentities : null, s = {};
479
492
  if (r)
480
493
  for (const u of Object.keys(r)) {
481
494
  const l = r[u];
482
- f(l) && l.length > 0 && (s[u] = l);
495
+ m(l) && l.length > 0 && (s[u] = l);
483
496
  }
484
497
  const o = Object.keys(s);
485
498
  if (o.length === 0)
@@ -487,7 +500,7 @@ const h = class h {
487
500
  const c = o.sort().map((u) => `${u}=${s[u]}`).join("&");
488
501
  return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
489
502
  try {
490
- i(t, s, (l) => {
503
+ i(e, s, (l) => {
491
504
  l?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
492
505
  });
493
506
  } catch (l) {
@@ -495,14 +508,14 @@ const h = class h {
495
508
  }
496
509
  }));
497
510
  }
498
- onLoginComplete(e, t) {
499
- return this.handleIdentityComplete(e, "onLoginComplete");
511
+ onLoginComplete(t, e) {
512
+ return this.handleIdentityComplete(t, "onLoginComplete");
500
513
  }
501
- onLogoutComplete(e, t) {
502
- return this.userIdentifiedInWorkspace = !1, this._workspaceSearchInFlightPromise = null, this._workspaceLastSearchedIdentitiesKey = void 0, this.handleIdentityComplete(e, "onLogoutComplete");
514
+ onLogoutComplete(t, e) {
515
+ return this.userIdentifiedInWorkspace = !1, this._workspaceSearchInFlightPromise = null, this._workspaceLastSearchedIdentitiesKey = void 0, this.handleIdentityComplete(t, "onLogoutComplete");
503
516
  }
504
- onModifyComplete(e, t) {
505
- return this.handleIdentityComplete(e, "onModifyComplete");
517
+ onModifyComplete(t, e) {
518
+ return this.handleIdentityComplete(t, "onModifyComplete");
506
519
  }
507
520
  /**
508
521
  * Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options.
@@ -527,60 +540,60 @@ const h = class h {
527
540
  * `Promise.resolve(...)`. The inner work runs in `_dispatchPlacements`;
528
541
  * this wrapper just gates it on the in-flight search via `Promise.race`.
529
542
  */
530
- selectPlacements(e) {
543
+ selectPlacements(t) {
531
544
  if (this._workspaceSearchInFlightPromise) {
532
- const t = this._workspaceSearchInFlightPromise;
545
+ const e = this._workspaceSearchInFlightPromise;
533
546
  return Promise.race([
534
- t,
535
- new Promise((i) => setTimeout(i, ie))
536
- ]).then(() => this._dispatchPlacements(e));
547
+ e,
548
+ new Promise((i) => setTimeout(i, nt))
549
+ ]).then(() => this._dispatchPlacements(t));
537
550
  }
538
- return this._dispatchPlacements(e);
551
+ return this._dispatchPlacements(t);
539
552
  }
540
- _dispatchPlacements(e) {
541
- const t = e && e.attributes || {}, r = { ...S(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
553
+ _dispatchPlacements(t) {
554
+ const e = t && t.attributes || {}, r = { ...w(this.userAttributes), ...e }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
542
555
  let l;
543
- s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = S(l);
544
- const E = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, v = this.returnUserIdentities(c), I = this.returnLocalSessionAttributes(), R = {
556
+ s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = w(l);
557
+ const h = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, v = this.returnUserIdentities(c), R = this.returnLocalSessionAttributes(), A = {
545
558
  ...v,
546
559
  ...l,
547
- ...E,
548
- ...I,
549
- ...this.userIdentifiedInWorkspace ? { [te]: !0 } : {},
560
+ ...h,
561
+ ...R,
562
+ ...this.userIdentifiedInWorkspace ? { [it]: !0 } : {},
550
563
  mpid: u
551
- }, p = { ...e, attributes: R }, _ = this.launcher.selectPlacements(p), y = () => this.logSelectPlacementsEvent(R);
552
- return Promise.resolve(_).then((A) => A?.context?.sessionId?.then((g) => this.setRoktSessionId(g))).catch(() => {
564
+ }, g = { ...t, attributes: A }, _ = this.launcher.selectPlacements(g), y = () => this.logSelectPlacementsEvent(A);
565
+ return Promise.resolve(_).then((S) => S?.context?.sessionId?.then((f) => this.setRoktSessionId(f))).catch(() => {
553
566
  }).finally(y), _;
554
567
  }
555
568
  /**
556
569
  * Passes attributes to the Rokt Web SDK for client-side hashing.
557
570
  */
558
- hashAttributes(e) {
559
- return this.isKitReady() ? this.launcher.hashAttributes(e) : (console.error("Rokt Kit: Not initialized"), null);
571
+ hashAttributes(t) {
572
+ return this.isKitReady() ? this.launcher.hashAttributes(t) : (console.error("Rokt Kit: Not initialized"), null);
560
573
  }
561
574
  /**
562
575
  * Enables optional Integration Launcher extensions before selecting placements.
563
576
  *
564
577
  * @deprecated This functionality has been internalized and will be removed in a future release.
565
578
  */
566
- use(e) {
567
- return this.isKitReady() ? !e || !f(e) ? Promise.reject(new Error("Rokt Kit: Invalid extension name")) : this.launcher.use(e) : (console.error("Rokt Kit: Not initialized"), Promise.reject(new Error("Rokt Kit: Not initialized")));
579
+ use(t) {
580
+ return this.isKitReady() ? !t || !m(t) ? Promise.reject(new Error("Rokt Kit: Invalid extension name")) : this.launcher.use(t) : (console.error("Rokt Kit: Not initialized"), Promise.reject(new Error("Rokt Kit: Not initialized")));
568
581
  }
569
582
  /**
570
583
  * Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
571
584
  */
572
- onShoppableAdsReady(e) {
573
- this._isThankYouElementLoaded ? e() : this._thankYouElementOnLoadCallback = e;
585
+ onShoppableAdsReady(t) {
586
+ this._isThankYouElementLoaded ? t() : this._thankYouElementOnLoadCallback = t;
574
587
  }
575
588
  };
576
- h._allowedOriginHashes = [-553112570, 549508659], h.PERFORMANCE_MARKS = {
589
+ p._allowedOriginHashes = [-553112570, 549508659], p.PERFORMANCE_MARKS = {
577
590
  RoktScriptAppended: "mp:RoktScriptAppended"
578
- }, h.EMAIL_SHA256_KEY = "emailsha256";
579
- let m = h;
580
- function de() {
581
- return w;
591
+ }, p.EMAIL_SHA256_KEY = "emailsha256";
592
+ let E = p;
593
+ function pt() {
594
+ return b;
582
595
  }
583
- function he(n) {
596
+ function gt(n) {
584
597
  if (!n) {
585
598
  window.console.log("You must pass a config object to register the kit " + d);
586
599
  return;
@@ -590,17 +603,17 @@ function he(n) {
590
603
  return;
591
604
  }
592
605
  T(n.kits) ? n.kits[d] = {
593
- constructor: m
606
+ constructor: E
594
607
  } : (n.kits = {}, n.kits[d] = {
595
- constructor: m
608
+ constructor: E
596
609
  }), window.console.log("Successfully registered " + d + " to your mParticle configuration");
597
610
  }
598
611
  typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
599
612
  name: d,
600
- constructor: m,
601
- getId: de
613
+ constructor: E,
614
+ getId: pt
602
615
  });
603
616
  export {
604
- he as register
617
+ gt as register
605
618
  };
606
619
  //# sourceMappingURL=Rokt-Kit.esm.js.map
@@ -1,2 +1,2 @@
1
- var RoktKit=(function(v){"use strict";const B=["billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],J=new Set(B);function U(n){return J.has(n.toLowerCase())}function I(n){const e={},t=n||{},i=Object.keys(t);for(let r=0;r<i.length;r++){const o=i[r];U(o)||(e[o]=t[o])}return e}const d="Rokt",R=181,Q="selectPlacements",X="apps.roktecommerce.com",$=.1,Z="ThankYouPageJourney",ee="rokt-launcher",te="rokt-thank-you-element",ie="userIdentifiedInWorkspace",ne=500,T={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},A={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},re="apps.rokt-api.com/v1/log",oe="apps.rokt-api.com/v1/errors",se=10;function a(){return window.mParticle}function K(n,e){const i=[D(n),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?i:i+"?extensions="+e.join(",")}function M(n){return[D(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function D(n){return["https://",typeof n<"u"?n:"apps.rokt-api.com"].join("")}function x(n,e,t){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),i.appendChild(r)}function N(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function S(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function j(n){const e=n?S(n):[],t=[],i=[];let r=!1;for(let o=0;o<e.length;o++){const s=e[o].value;s==="thank-you-journey"?(r=!0,i.push(Z)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:i,loadThankYouElement:r}}async function ae(n,e){const t=[];if(e)for(const i of n)t.push(e.use(i));return Promise.all(t)}function Y(n){if(!n)return{};const e={};for(let t=0;t<n.length;t++){const i=n[t];e[i.jsmap]=i.value}return e}function F(n){const e={};if(!Array.isArray(n))return e;for(let t=0;t<n.length;t++){const i=n[t];if(!i||!p(i.value)||!p(i.map))continue;const r=i.value,o=i.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:o,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return e}function H(n,e,t){return a().generateHash([n,e,t].join(""))}function E(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function p(n){return typeof n=="string"}function ce(n){let i="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.28.1";return n&&(i+="_"+n),i}function z(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t),e=e&e;return e}function O(n){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=n,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function W(n,e){const t=z(window.location.origin);if(m._allowedOriginHashes.indexOf(t)===-1||Math.random()>=$)return;const r=window.__rokt_li_guid__;if(!r)return;const o=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(o);O("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+s),O("https://"+X+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function le(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function ue(){return typeof window<"u"?window.location?.href:void 0}function de(){return typeof window<"u"?window.navigator?.userAgent:void 0}class G{constructor(){this._logCount={}}incrementAndCheck(e){const i=(this._logCount[e]||0)+1;return this._logCount[e]=i,i>se}}class P{constructor(e,t,i,r,o){this._reporter="mp-wsdk";const s=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=o||new G,this._isEnabled=le()||s}send(e,t,i,r,o,s){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:t,code:r||T.UNKNOWN_ERROR,url:ue(),deviceInfo:de(),stackTrace:o,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),s&&s(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),s&&s(c)}}}class V{constructor(e,t,i,r,o){this._transport=new P(e,t,i,r,o),this._errorUrl="https://"+(e?.errorUrl||oe)}report(e){if(!e)return;const t=e.severity||A.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class q{constructor(e,t,i,r,o,s){this._transport=new P(e,i,r,o,s),this._loggingUrl="https://"+(e?.loggingUrl||re),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,A.INFO,e.message,e.code,void 0,t=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:T.UNKNOWN_ERROR,severity:A.ERROR})})}}const h=class h{constructor(){this.name=d,this.id=R,this.moduleId=R,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const i=e&&e.EventAttributes;return!i||typeof i[t]>"u"?null:i[t]}doesEventAttributeConditionMatch(e,t){if(!e||!p(e.operator))return!1;const i=e.operator.toLowerCase(),r=e.attributeValue;return i==="exists"?t!==null:t==null?!1:i==="equals"?String(t)===String(r):i==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!p(t.eventAttributeKey))return!1;const i=t.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(i.length===0)return r!==null;for(let o=0;o<i.length;o++)if(!this.doesEventAttributeConditionMatch(i[o],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<t.length;i++){const r=t[i],o=this.placementEventAttributeMappingLookup[r];if(E(o))continue;let s=!0;for(let c=0;c<o.length;c++)if(!this.doesEventMatchRule(e,o[c])){s=!1;break}s&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:E(this.placementEventMappingLookup)&&E(this.placementEventAttributeMappingLookup)?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},i=this._mappedEmailSha256Key;return i&&e[i]&&(t[h.EMAIL_SHA256_KEY]=e[i]),i&&delete t[i],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!N(e))return;const t=a().EventType.Other;a().logEvent(Q,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(R,{roktSessionId:e})}catch{}}attachLauncher(e,t,i=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,o={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(o)):s=window.Rokt.createLauncher(o),s.then(async c=>{await ae(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,W(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((o,s)=>(o["rokt.custom.optimizely.experiment."+s+".variationId"]=t.getVariationMap()[s].id,o),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,i,r,o){const s=e,c=s.accountId;this.userAttributes=I(o),this._onboardingExpProvider=s.onboardingExpProvider;const u=S(s.placementEventMapping);this.placementEventMappingLookup=Y(u);const l=S(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=F(l),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=p(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const _=a().Rokt?.domain,{roktExtensionsQueryParams:C,legacyRoktExtensions:b,loadThankYouElement:w}=j(s.roktExtensions),g={...a().Rokt?.launcherOptions||{}};this.integrationName=ce(g.integrationName),g.integrationName=this.integrationName,this.domain=_;const y={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,isLoggingEnabled:a().config?.isLoggingEnabled===!0},k=new V(y,this.integrationName,window.__rokt_li_guid__,s.accountId),L=new q(y,k,this.integrationName,window.__rokt_li_guid__,s.accountId);return this.errorReportingService=k,this.loggingService=L,a()._registerErrorReportingService&&a()._registerErrorReportingService(k),a()._registerLoggingService&&a()._registerLoggingService(L),i?(this.testHelpers={generateLauncherScript:K,generateThankYouElementScript:M,extractRoktExtensionConfig:j,hashEventMessage:H,parseSettingsString:S,generateMappedEventLookup:Y,generateMappedEventAttributeLookup:F,sendAdBlockMeasurementSignals:W,createAutoRemovedIframe:O,djb2:z,setAllowedOriginHashes:f=>{h._allowedOriginHashes=f},ReportingTransport:P,ErrorReportingService:V,LoggingService:q,RateLimiter:G,ErrorCodes:T,WSDKErrorSeverity:A},this.attachLauncher(c,g),"Successfully initialized: "+d):(w&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),x(te,M(_),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:f=>{console.error("Error loading Rokt Thank You Element script:",f)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,g,b):(x(ee,K(_,C),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,g,b):console.error("Rokt object is not available after script load.")},onError:f=>{console.error("Error loading Rokt launcher script:",f)}}),this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(E(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!E(this.placementEventMappingLookup))){const t=H(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return U(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=I(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const i=a().Identity?.search;if(typeof i!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,o={};if(r)for(const u of Object.keys(r)){const l=r[u];p(l)&&l.length>0&&(o[u]=l)}const s=Object.keys(o);if(s.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=s.sort().map(u=>`${u}=${o[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{i(t,o,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(i=>setTimeout(i,ne))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...I(this.userAttributes),...t},o=this.filters||{},s=o.userAttributeFilters||[],c=o.filteredUser||null,u=c?c.getMPID():null;let l;o?o.filterUserAttributes?l=o.filterUserAttributes(r,s):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=I(l);const _=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},C=this.returnUserIdentities(c),b=this.returnLocalSessionAttributes(),w={...C,...l,..._,...b,...this.userIdentifiedInWorkspace?{[ie]:!0}:{},mpid:u},g={...e,attributes:w},y=this.launcher.selectPlacements(g),k=()=>this.logSelectPlacementsEvent(w);return Promise.resolve(y).then(L=>L?.context?.sessionId?.then(f=>this.setRoktSessionId(f))).catch(()=>{}).finally(k),y}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!p(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};h._allowedOriginHashes=[-553112570,549508659],h.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},h.EMAIL_SHA256_KEY="emailsha256";let m=h;function he(){return R}function pe(n){if(!n){window.console.log("You must pass a config object to register the kit "+d);return}if(!N(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}N(n.kits)?n.kits[d]={constructor:m}:(n.kits={},n.kits[d]={constructor:m}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:m,getId:he}),v.register=pe,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),v})({});
1
+ var RoktKit=(function(v){"use strict";const J=["billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Q=new Set(J);function K(n){return Q.has(n.toLowerCase())}function R(n){const t={},e=n||{},i=Object.keys(e);for(let r=0;r<i.length;r++){const s=i[r];K(s)||(t[s]=e[s])}return t}const d="Rokt",A=181,X="selectPlacements",$="apps.roktecommerce.com",Z=.1,tt="ThankYouPageJourney",et="rokt-launcher",it="rokt-thank-you-element",nt="userIdentifiedInWorkspace",rt=500,T={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},_={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},st="apps.rokt-api.com",ot="/v1/log",at="/v1/errors",ct=10;function a(){return window.mParticle}function M(n,t){const i=[O(n),"/wsdk/integrations/launcher.js"].join("");return!t||t.length===0?i:i+"?extensions="+t.join(",")}function D(n){return[O(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function O(n){return["https://",typeof n<"u"?n:st].join("")}function Y(n,t,e){return n?n.startsWith("http://")||n.startsWith("https://")?n:"https://"+n:O(t)+e}function x(n,t,e){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,r.type="text/javascript",r.src=t,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",e?.onLoad&&(r.onload=e.onLoad),e?.onError&&(r.onerror=e.onError),i.appendChild(r)}function N(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function S(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function j(n){const t=n?S(n):[],e=[],i=[];let r=!1;for(let s=0;s<t.length;s++){const o=t[s].value;o==="thank-you-journey"?(r=!0,i.push(tt)):e.push(o)}return{roktExtensionsQueryParams:e,legacyRoktExtensions:i,loadThankYouElement:r}}async function lt(n,t){const e=[];if(t)for(const i of n)e.push(t.use(i));return Promise.all(e)}function F(n){if(!n)return{};const t={};for(let e=0;e<n.length;e++){const i=n[e];t[i.jsmap]=i.value}return t}function H(n){const t={};if(!Array.isArray(n))return t;for(let e=0;e<n.length;e++){const i=n[e];if(!i||!g(i.value)||!g(i.map))continue;const r=i.value,s=i.map;t[r]||(t[r]=[]),t[r].push({eventAttributeKey:s,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return t}function W(n,t,e){return a().generateHash([n,t,e].join(""))}function y(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function g(n){return typeof n=="string"}function ut(n){let i="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.28.3";return n&&(i+="_"+n),i}function G(n){let t=5381;for(let e=0;e<n.length;e++)t=(t<<5)+t+n.charCodeAt(e),t=t&t;return t}function P(n){const t=document.createElement("iframe");t.style.display="none",t.setAttribute("sandbox","allow-scripts allow-same-origin"),t.src=n,t.onload=function(){t.onload=null,t.parentNode&&t.parentNode.removeChild(t)};const e=document.body||document.head;e&&e.appendChild(t)}function z(n,t){const e=G(window.location.origin);if(E._allowedOriginHashes.indexOf(e)===-1||Math.random()>=Z)return;const r=window.__rokt_li_guid__;if(!r)return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(t??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s);P("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),P("https://"+$+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function dt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function ht(){return typeof window<"u"?window.location?.href:void 0}function pt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class V{constructor(){this._logCount={}}incrementAndCheck(t){const i=(this._logCount[t]||0)+1;return this._logCount[t]=i,i>ct}}class C{constructor(t,e,i,r,s){this._reporter="mp-wsdk";const o=t.isLoggingEnabled;this._integrationName=e||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=s||new V,this._isEnabled=dt()||o}send(t,e,i,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(e)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:e,code:r||T.UNKNOWN_ERROR,url:ht(),deviceInfo:pt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(t,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const h=new Error("HTTP "+l.status+" from log endpoint");throw h.statusCode=l.status,h}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class q{constructor(t,e,i,r,s){this._transport=new C(t,e,i,r,s),this._errorUrl=Y(t?.errorUrl,t?.integrationDomain,at)}report(t){if(!t)return;const e=t.severity||_.ERROR;this._transport.send(this._errorUrl,e,t.message,t.code,t.stackTrace)}}class B{constructor(t,e,i,r,s,o){this._transport=new C(t,i,r,s,o),this._loggingUrl=Y(t?.loggingUrl,t?.integrationDomain,ot),this._errorReportingService=e}log(t){t&&this._transport.send(this._loggingUrl,_.INFO,t.message,t.code,void 0,e=>{if(this._errorReportingService){const i=typeof e.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+e.message,code:T.LOG_DELIVERY_FAILURE,severity:i?_.ERROR:_.WARNING})}})}}const p=class p{constructor(){this.name=d,this.id=A,this.moduleId=A,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(t,e){const i=t&&t.EventAttributes;return!i||typeof i[e]>"u"?null:i[e]}doesEventAttributeConditionMatch(t,e){if(!t||!g(t.operator))return!1;const i=t.operator.toLowerCase(),r=t.attributeValue;return i==="exists"?e!==null:e==null?!1:i==="equals"?String(e)===String(r):i==="contains"?String(e).indexOf(String(r))!==-1:!1}doesEventMatchRule(t,e){if(!e||!g(e.eventAttributeKey))return!1;const i=e.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(t,e.eventAttributeKey);if(i.length===0)return r!==null;for(let s=0;s<i.length;s++)if(!this.doesEventAttributeConditionMatch(i[s],r))return!1;return!0}applyPlacementEventAttributeMapping(t){const e=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<e.length;i++){const r=e[i],s=this.placementEventAttributeMappingLookup[r];if(y(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(t,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}returnUserIdentities(t){if(!t||!t.getUserIdentities)return{};const e=t.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(e)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:y(this.placementEventMappingLookup)&&y(this.placementEventAttributeMappingLookup)?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(t){const e={...t||{}},i=this._mappedEmailSha256Key;return i&&t[i]&&(e[p.EMAIL_SHA256_KEY]=t[i]),i&&delete e[i],e}logSelectPlacementsEvent(t){if(!window.mParticle||typeof a().logEvent!="function"||!N(t))return;const e=a().EventType.Other;a().logEvent(X,e,t)}setRoktSessionId(t){if(!(!t||typeof t!="string"))try{const e=a().getInstance();e&&typeof e.setIntegrationAttribute=="function"&&e.setIntegrationAttribute(A,{roktSessionId:t})}catch{}}attachLauncher(t,e,i=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:t,...e||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await lt(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(t){window.Rokt&&(window.Rokt.currentLauncher=t),this.launcher=t;const e=a().Rokt?.filters;e?(this.filters=e,e.filteredUser?this._workspaceSearchInFlightPromise=this.search(e.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,z(this.domain,this.integrationName),a().Rokt.attachKit(this)}fetchOptimizely(){const t=a()._getActiveForwarders().filter(e=>e.name==="Optimizely");try{if(t.length>0&&window.optimizely){const e=window.optimizely.get("state");return!e||!e.getActiveExperimentIds?{}:e.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=e.getVariationMap()[o].id,s),{})}}catch(e){console.error("Error fetching Optimizely attributes:",e)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(t){window&&a()&&a().captureTiming&&t&&a().captureTiming(t)}init(t,e,i,r,s){const o=t,c=o.accountId;this.userAttributes=R(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=S(o.placementEventMapping);this.placementEventMappingLookup=F(u);const l=S(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=H(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const h=a().Rokt?.domain,{roktExtensionsQueryParams:U,legacyRoktExtensions:w,loadThankYouElement:b}=j(o.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=ut(f.integrationName),f.integrationName=this.integrationName,this.domain=h;const k={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:h,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new q(k,this.integrationName,window.__rokt_li_guid__,o.accountId),L=new B(k,I,this.integrationName,window.__rokt_li_guid__,o.accountId);return this.errorReportingService=I,this.loggingService=L,a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(L),i?(this.testHelpers={generateLauncherScript:M,generateThankYouElementScript:D,extractRoktExtensionConfig:j,hashEventMessage:W,parseSettingsString:S,generateMappedEventLookup:F,generateMappedEventAttributeLookup:H,sendAdBlockMeasurementSignals:z,createAutoRemovedIframe:P,djb2:G,setAllowedOriginHashes:m=>{p._allowedOriginHashes=m},ReportingTransport:C,ErrorReportingService:q,LoggingService:B,RateLimiter:V,ErrorCodes:T,WSDKErrorSeverity:_},this.attachLauncher(c,f),"Successfully initialized: "+d):(b&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),x(it,D(h),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:m=>{console.error("Error loading Rokt Thank You Element script:",m)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,f,w):(x(et,M(h,U),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,w):console.error("Rokt object is not available after script load.")},onError:m=>{console.error("Error loading Rokt launcher script:",m)}}),this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(t){if(!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(y(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(t),!y(this.placementEventMappingLookup))){const e=W(t.EventDataType,t.EventCategory,t.EventName??"");this.placementEventMappingLookup[String(e)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(e)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(t){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(t)}setUserAttribute(t,e){return K(t)||(this.userAttributes[t]=e),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(t){return delete this.userAttributes[t],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(t,e){return this.userAttributes=R(t.getAllUserAttributes()),"Successfully called "+e+" for forwarder: "+d}onUserIdentified(t){const e=t;return this.filters.filteredUser=e,this._workspaceSearchInFlightPromise=this.search(e),this.handleIdentityComplete(t,"onUserIdentified")}search(t){const e=this._workspaceIdSyncApiKey;if(!e)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const i=a().Identity?.search;if(typeof i!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=t.getUserIdentities?t.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{i(e,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(t,e){return this.handleIdentityComplete(t,"onLoginComplete")}onLogoutComplete(t,e){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(t,"onLogoutComplete")}onModifyComplete(t,e){return this.handleIdentityComplete(t,"onModifyComplete")}selectPlacements(t){if(this._workspaceSearchInFlightPromise){const e=this._workspaceSearchInFlightPromise;return Promise.race([e,new Promise(i=>setTimeout(i,rt))]).then(()=>this._dispatchPlacements(t))}return this._dispatchPlacements(t)}_dispatchPlacements(t){const e=t&&t.attributes||{},r={...R(this.userAttributes),...e},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=R(l);const h=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},U=this.returnUserIdentities(c),w=this.returnLocalSessionAttributes(),b={...U,...l,...h,...w,...this.userIdentifiedInWorkspace?{[nt]:!0}:{},mpid:u},f={...t,attributes:b},k=this.launcher.selectPlacements(f),I=()=>this.logSelectPlacementsEvent(b);return Promise.resolve(k).then(L=>L?.context?.sessionId?.then(m=>this.setRoktSessionId(m))).catch(()=>{}).finally(I),k}hashAttributes(t){return this.isKitReady()?this.launcher.hashAttributes(t):(console.error("Rokt Kit: Not initialized"),null)}use(t){return this.isKitReady()?!t||!g(t)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(t):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(t){this._isThankYouElementLoaded?t():this._thankYouElementOnLoadCallback=t}};p._allowedOriginHashes=[-553112570,549508659],p.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},p.EMAIL_SHA256_KEY="emailsha256";let E=p;function gt(){return A}function ft(n){if(!n){window.console.log("You must pass a config object to register the kit "+d);return}if(!N(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}N(n.kits)?n.kits[d]={constructor:E}:(n.kits={},n.kits[d]={constructor:E}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:E,getId:gt}),v.register=ft,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),v})({});
2
2
  //# sourceMappingURL=Rokt-Kit.iife.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.28.1",
3
+ "version": "1.28.3",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "module": "dist/Rokt-Kit.esm.js",