@mparticle/web-rokt-kit 3.3.3 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Le=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Oe=new Set(Le);function me(i){return Oe.has(i.toLowerCase())}function v(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];me(s)||(e[s]=t[s])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function U(i){return typeof i=="function"}function w(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function z(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function Ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const h="mp-rokt-kit",ee="__rokt_ls_probe__";function H(){try{return window.localStorage.setItem(ee,"1"),window.localStorage.removeItem(ee),!0}catch{return!1}}const A=()=>window.localStorage;function $(i,e=A){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function _e(i,e,t=A){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Ne(i,e=A){try{e().removeItem(i)}catch{}}function O(i,e,t=A){const n=$(i,t);return m(n)?n[e]:void 0}function x(i,e,t,n=A){const r=$(i,n),s=m(r)?{...r}:{};return s[e]=t,_e(i,s,n)}function Y(i,e,t=A){const n=$(i,t);if(!m(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Ne(i,t):_e(i,r,t)}const q="pageViews",D="utmParams",Ie=25,Ue=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function Se(i){return i.slice(-Ie)}function te(){const i=O(h,q);return Array.isArray(i)?i:[]}function Ce(i){const e=Se(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(x(h,q,n))return n.length}return 0}function ie(){Y(h,q)}function Ke(i){const e=Se(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,l=c!==void 0&&Number.isFinite(c),u=s&&l?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...u!==void 0&&u>=0?{activeTimeOnPage:u}:{}}})}function De(i){if(O(h,D)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ue){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!x(h,D,t)){const r=H()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function Me(){const i=O(h,D);return m(i)?i:null}function ne(){Y(h,D)}function Fe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return z(e)}const J=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","amount","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"]}],xe=6e4;function Ye(i){return m(i)&&typeof i.expiresAt=="number"&&m(i.attributes)}function Ge(i,e){return`activePreselect:${i}:${e}`}function je(i){const e=O(h,i);return Ye(e)?e:null}function He(i,e){x(h,i,{expiresAt:Date.now()+xe,attributes:e})}const Ve=5*6e4;function M(){return window.sessionStorage}function We(i){return m(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&m(i.attributes)&&g(i.mpid)}function B(i){return`pendingPreselect:${i}`}function ze(i){const e=B(i),t=O(h,e,M);return We(t)?t.expiresAt<=Date.now()?(Y(h,e,M),null):t:null}function $e(i,e,t,n,r){return x(h,B(i),{expiresAt:Date.now()+Ve,pathname:e,identifier:t,attributes:n,mpid:r},M)}function T(i){Y(h,B(i),M)}function L(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function qe(i,e){if(i)return J.find(t=>t.accountId===i&&t.pathname===e)}function Je(i,e){if(!(!i||!g(e)))return J.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function Be(i,e){return i?J.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Qe(){return{pending:[]}}function j(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function V(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function ye(i){const e=i?.getMPID?.();return e==null?null:String(e)}function re(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r={},s=[];for(const o of t.attributeKeys){const c=i.getEventAttributeValue(e,o),l=w(c)?i.userAttributes[o]??n[o]:c;if(w(l)){s.push(o);continue}r[o]=l}return{collected:r,missingKeys:s}}function Xe(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function Ae(i,e,t,n,r,s){const o=Ge(e,t),c=je(o),l=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&l){i.logPlacementDiagnostic(L("skipped","active_preselection"));return}He(o,r),i.logPlacementDiagnostic(L("fired",s)),Xe(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Ze(i,e){if(!e.accountId||!e.isKitReady())return;const t=ze(e.accountId);if(t){if(i.pending.some(n=>n.pathname===t.pathname)){T(e.accountId);return}if(!e.isPreselectionEnabled()){T(e.accountId);return}V(e.filteredUser)&&(T(e.accountId),ye(e.filteredUser)===t.mpid&&Ae(e,e.accountId,t.identifier,t.identifier,t.attributes,"recovered"))}}function Pe(i,e,t,n=window.location.pathname){const r=qe(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],l=ye(e.filteredUser);if(e.accountId&&l&&V(e.filteredUser)){const{collected:u,missingKeys:f}=re(e,t,r);if(f.length===0){const P=v(u);$e(e.accountId,n,r.targetPageIdentifier,P,l)||c.push(L("queued","persist_failed"))}}j(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!V(e.filteredUser)){e.logPlacementDiagnostic(L("missed","no_valid_identity")),j(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=re(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(L("missed",`missing_attribute:${c}`));j(i,{event:t,pathname:n});return}Ae(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function et(i,e,t=window.location.pathname){if(Ze(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),Pe(i,e,r,s))})}function tt(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function it(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function nt(i){i.lifecycle="attached"}function rt(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function st(i){i.lifecycle="terminated"}function ot(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function ct(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",C=181,at="selectPlacements",lt="apps.roktecommerce.com",ut=.1,dt="ThankYouPageJourney",ht="rokt-launcher",gt="rokt-thank-you-element",ft="userIdentifiedInWorkspace",pt=3,mt=2,Et="page_events",_t="page_view_attributes",It="mparticle_session_id",St="mparticle_device_id",se=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},S={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},yt="apps.rokt-api.com",At="/v1/log",Pt="/v1/errors",Rt=10;function a(){return window.mParticle}function oe(i,e){const n=[G(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function ce(i){return[G(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function G(i){const e=i!==void 0?i:yt;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function Re(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return G(r)+t}function ae(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,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),n.appendChild(r)}function K(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function le(i){const e=i?K(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(dt)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function bt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ue(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function de(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function he(i,e,t){return a().generateHash([i,e,t].join(""))}function kt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.3.3";return i&&(n+="_"+i),n}function W(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function ge(i,e){const t=Ee(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ut)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?G(i):"https://apps.rokt.com";W(c+"/v1/wsdk-init/index.html?"+o),W("https://"+lt+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function vt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function wt(){return typeof window<"u"?window.location?.href:void 0}function Tt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class be{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Rt}}class F{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new be,this._isEnabled=vt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:wt(),deviceInfo:Tt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},l={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(l["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(l["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:l,body:JSON.stringify(c)}).then(u=>{if(!u.ok){const f=new Error("HTTP "+u.status+" from log endpoint");throw f.statusCode=u.status,f}}).catch(u=>{console.error("ReportingTransport: Failed to send log",u),o&&o(u)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class fe{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=Re(e?.errorUrl,e?.integrationDomain,Pt)}report(e){if(!e)return;const t=e.severity||S.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class pe{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._placementDiagnosticTransport=new F(e,n,r,s),this._loggingUrl=Re(e?.loggingUrl,e?.integrationDomain,At),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,S.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?S.ERROR:S.WARNING})}})}}function Lt(i){const e=z(window.location.href),t=i.EventAttributes?.title||document.title,n=Fe(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const _=class _{constructor(){this.name=d,this.id=C,this.moduleId=C,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,this._launcherAttachState=tt(),this.accountId=null,this._preselectState=Qe()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(w(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)}}capturePageView(e){let t;try{t=z(window.location.href);const n=te(),r=Lt(e);n.push(r);const s=Math.min(n.length,Ie),o=Ce(n);if(o===0){const c=H()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=H()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=Je(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){et(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&U(window.Rokt.createLauncher)}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"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[_.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!m(e))return;const t=a().EventType.Other;a().logEvent(at,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&U(t.setIntegrationAttribute)&&t.setIntegrationAttribute(C,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(U(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){it(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await bt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(st(this._launcherAttachState),!c){const l=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${l}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return ct(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,nt(this._launcherAttachState);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,ge(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}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)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}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,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=v(s),this._onboardingExpProvider=o.onboardingExpProvider;const l=K(o.placementEventMapping);this.placementEventMappingLookup=ue(l);const u=K(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=de(u),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const f=a().Rokt?.domain,{roktExtensionsQueryParams:P,legacyRoktExtensions:R,loadThankYouElement:N}=le(o.roktExtensions),E={...a().Rokt?.launcherOptions||{}};this.integrationName=kt(E.integrationName),E.integrationName=this.integrationName,this.domain=f;const b={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:f,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new fe(b,this.integrationName,window.__rokt_li_guid__,o.accountId),k=new pe(b,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=k,this.isTargetingDisabled())try{ie(),ne()}catch(p){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:S.INFO,stackTrace:p instanceof Error?p.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(k),n?(this.testHelpers={generateLauncherScript:oe,generateThankYouElementScript:ce,extractRoktExtensionConfig:le,hashEventMessage:he,parseSettingsString:K,generateMappedEventLookup:ue,generateMappedEventAttributeLookup:de,sendAdBlockMeasurementSignals:ge,createAutoRemovedIframe:W,djb2:Ee,setAllowedOriginHashes:p=>{_._allowedOriginHashes=p},ReportingTransport:F,ErrorReportingService:fe,LoggingService:pe,RateLimiter:be,ErrorCodes:Q,WSDKErrorSeverity:S,resetLauncherAttachState:()=>ot(this._launcherAttachState)},this.attachLauncher(c,E),"Successfully initialized: "+d):(N&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ae(gt,ce(f),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:p=>{console.error("Error loading Rokt Thank You Element script:",p)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,E,R):(ae(ht,oe(f,P),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,E,R):console.error("Rokt object is not available after script load.")},onError:p=>{console.error("Error loading Rokt launcher script:",p)}}),this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===pt&&(De(this.loggingService),this.capturePageView(e),Pe(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===mt&&(ie(),ne(),this.accountId&&T(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(U(a().Rokt?.setLocalSessionAttribute)&&(w(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!w(this.placementEventMappingLookup))){const t=he(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 me(e)||(this.userAttributes[e]=t),Be(this.accountId,e)&&this.flushPendingPreselectDispatches(),"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=v(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const l of Object.keys(r)){const u=r[l];g(u)&&u.length>0&&(s[l]=u)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(l=>`${l}=${s[l]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(l=>{try{n(t,s,u=>{u?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),l()})}catch(u){console.error("Rokt Kit: Workspace IDSync search failed",u),this._workspaceLastSearchedIdentitiesKey=void 0,l()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&T(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,se))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,se))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...v(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,l=c?c.getMPID():null;let u;s?s.filterUserAttributes?u=s.filterUserAttributes(r,o):u=r:(console.warn("Rokt Kit: No filters available, using user attributes"),u=r),this.userAttributes=v(u);const f=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},P=this.returnUserIdentities(c),R=this.returnLocalSessionAttributes(),N=Ke(te()),E=Me(),b=this.readMpSessionId(),I=this.readMpDeviceId(),k={...P,...u,...f,...R,...N.length?{[Et]:JSON.stringify(N)}:{},...E?{[_t]:E}:{},...this.userIdentifiedInWorkspace?{[ft]:!0}:{},...b?{[It]:b}:{},...I?{[St]:I}:{},mpid:l},p=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),ke={...e,attributes:k,...p!==void 0?{cacheMatchKeys:p}:{}},X=this.launcher.selectPlacements(ke),Z=e.preselect===!0,ve=()=>{Z||this.logSelectPlacementsEvent(k)};return Promise.resolve(X).then(we=>{if(!Z)return we?.context?.sessionId?.then(Te=>this.setRoktSessionId(Te))}).catch(()=>{}).finally(ve),X}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(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")))}terminate(){return this.isKitReady()?(rt(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};_._allowedOriginHashes=[-553112570,549508659],_.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},_.EMAIL_SHA256_KEY="emailsha256";let y=_;function Ot(){return C}function Nt(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!m(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}m(i.kits)?i.kits[d]={constructor:y}:(i.kits={},i.kits[d]={constructor:y}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:Ot});exports.register=Nt;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Le=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Oe=new Set(Le);function me(i){return Oe.has(i.toLowerCase())}function v(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];me(s)||(e[s]=t[s])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function U(i){return typeof i=="function"}function w(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function z(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function Ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const h="mp-rokt-kit",ee="__rokt_ls_probe__";function H(){try{return window.localStorage.setItem(ee,"1"),window.localStorage.removeItem(ee),!0}catch{return!1}}const A=()=>window.localStorage;function $(i,e=A){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function _e(i,e,t=A){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Ne(i,e=A){try{e().removeItem(i)}catch{}}function O(i,e,t=A){const n=$(i,t);return m(n)?n[e]:void 0}function x(i,e,t,n=A){const r=$(i,n),s=m(r)?{...r}:{};return s[e]=t,_e(i,s,n)}function Y(i,e,t=A){const n=$(i,t);if(!m(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Ne(i,t):_e(i,r,t)}const q="pageViews",D="utmParams",Ie=25,Ue=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function ye(i){return i.slice(-Ie)}function te(){const i=O(h,q);return Array.isArray(i)?i:[]}function Ce(i){const e=ye(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(x(h,q,n))return n.length}return 0}function ie(){Y(h,q)}function Ke(i){const e=ye(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function De(i){if(O(h,D)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ue){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!x(h,D,t)){const r=H()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function Me(){const i=O(h,D);return m(i)?i:null}function ne(){Y(h,D)}function Fe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return z(e)}const J=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","amount","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","amount","firstname","lastname","cartItems","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]}],xe=6e4;function Ye(i){return m(i)&&typeof i.expiresAt=="number"&&m(i.attributes)}function Ge(i,e){return`activePreselect:${i}:${e}`}function je(i){const e=O(h,i);return Ye(e)?e:null}function He(i,e){x(h,i,{expiresAt:Date.now()+xe,attributes:e})}const Ve=5*6e4;function M(){return window.sessionStorage}function We(i){return m(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&m(i.attributes)&&g(i.mpid)}function B(i){return`pendingPreselect:${i}`}function ze(i){const e=B(i),t=O(h,e,M);return We(t)?t.expiresAt<=Date.now()?(Y(h,e,M),null):t:null}function $e(i,e,t,n,r){return x(h,B(i),{expiresAt:Date.now()+Ve,pathname:e,identifier:t,attributes:n,mpid:r},M)}function T(i){Y(h,B(i),M)}function L(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function qe(i,e){if(i)return J.find(t=>t.accountId===i&&t.pathname===e)}function Je(i,e){if(!(!i||!g(e)))return J.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function Be(i,e){return i?J.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Qe(){return{pending:[]}}function j(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function V(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function Se(i){const e=i?.getMPID?.();return e==null?null:String(e)}function re(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r=new Set((t.optionalAttributeKeys??[]).map(c=>c.toLowerCase())),s={},o=[];for(const c of t.attributeKeys){const u=i.getEventAttributeValue(e,c),l=w(u)?i.userAttributes[c]??n[c]:u;if(w(l)){r.has(c.toLowerCase())||o.push(c);continue}s[c]=l}return{collected:s,missingKeys:o}}function Xe(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function Ae(i,e,t,n,r,s){const o=Ge(e,t),c=je(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(L("skipped","active_preselection"));return}He(o,r),i.logPlacementDiagnostic(L("fired",s)),Xe(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Ze(i,e){if(!e.accountId||!e.isKitReady())return;const t=ze(e.accountId);if(t){if(i.pending.some(n=>n.pathname===t.pathname)){T(e.accountId);return}if(!e.isPreselectionEnabled()){T(e.accountId);return}V(e.filteredUser)&&(T(e.accountId),Se(e.filteredUser)===t.mpid&&Ae(e,e.accountId,t.identifier,t.identifier,t.attributes,"recovered"))}}function Pe(i,e,t,n=window.location.pathname){const r=qe(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=Se(e.filteredUser);if(e.accountId&&u&&V(e.filteredUser)){const{collected:l,missingKeys:f}=re(e,t,r);if(f.length===0){const P=v(l);$e(e.accountId,n,r.targetPageIdentifier,P,u)||c.push(L("queued","persist_failed"))}}j(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!V(e.filteredUser)){e.logPlacementDiagnostic(L("missed","no_valid_identity")),j(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=re(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(L("missed",`missing_attribute:${c}`));j(i,{event:t,pathname:n});return}Ae(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function et(i,e,t=window.location.pathname){if(Ze(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),Pe(i,e,r,s))})}function tt(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function it(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function nt(i){i.lifecycle="attached"}function rt(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function st(i){i.lifecycle="terminated"}function ot(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function ct(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",C=181,at="selectPlacements",lt="apps.roktecommerce.com",ut=.1,dt="ThankYouPageJourney",ht="rokt-launcher",gt="rokt-thank-you-element",ft="userIdentifiedInWorkspace",pt=3,mt=2,Et="page_events",_t="page_view_attributes",It="mparticle_session_id",yt="mparticle_device_id",se=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},y={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},St="apps.rokt-api.com",At="/v1/log",Pt="/v1/errors",bt=10;function a(){return window.mParticle}function oe(i,e){const n=[G(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function ce(i){return[G(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function G(i){const e=i!==void 0?i:St;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function be(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return G(r)+t}function ae(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,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),n.appendChild(r)}function K(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function le(i){const e=i?K(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(dt)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Rt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ue(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function de(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function he(i,e,t){return a().generateHash([i,e,t].join(""))}function kt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.5.0";return i&&(n+="_"+i),n}function W(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function ge(i,e){const t=Ee(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ut)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?G(i):"https://apps.rokt.com";W(c+"/v1/wsdk-init/index.html?"+o),W("https://"+lt+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function vt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function wt(){return typeof window<"u"?window.location?.href:void 0}function Tt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class Re{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>bt}}class F{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new Re,this._isEnabled=vt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:wt(),deviceInfo:Tt(),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)}).then(l=>{if(!l.ok){const f=new Error("HTTP "+l.status+" from log endpoint");throw f.statusCode=l.status,f}}).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 fe{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=be(e?.errorUrl,e?.integrationDomain,Pt)}report(e){if(!e)return;const t=e.severity||y.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class pe{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._placementDiagnosticTransport=new F(e,n,r,s),this._loggingUrl=be(e?.loggingUrl,e?.integrationDomain,At),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,y.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?y.ERROR:y.WARNING})}})}}function Lt(i){const e=z(window.location.href),t=i.EventAttributes?.title||document.title,n=Fe(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const _=class _{constructor(){this.name=d,this.id=C,this.moduleId=C,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,this._launcherAttachState=tt(),this.accountId=null,this._preselectState=Qe()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(w(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)}}capturePageView(e){let t;try{t=z(window.location.href);const n=te(),r=Lt(e);n.push(r);const s=Math.min(n.length,Ie),o=Ce(n);if(o===0){const c=H()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=H()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=Je(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){et(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&U(window.Rokt.createLauncher)}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"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[_.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!m(e))return;const t=a().EventType.Other;a().logEvent(at,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&U(t.setIntegrationAttribute)&&t.setIntegrationAttribute(C,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(U(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){it(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await Rt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(st(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return ct(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,nt(this._launcherAttachState);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,ge(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}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)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}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,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=v(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=K(o.placementEventMapping);this.placementEventMappingLookup=ue(u);const l=K(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=de(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const f=a().Rokt?.domain,{roktExtensionsQueryParams:P,legacyRoktExtensions:b,loadThankYouElement:N}=le(o.roktExtensions),E={...a().Rokt?.launcherOptions||{}};this.integrationName=kt(E.integrationName),E.integrationName=this.integrationName,this.domain=f;const R={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:f,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new fe(R,this.integrationName,window.__rokt_li_guid__,o.accountId),k=new pe(R,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=k,this.isTargetingDisabled())try{ie(),ne()}catch(p){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:y.INFO,stackTrace:p instanceof Error?p.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(k),n?(this.testHelpers={generateLauncherScript:oe,generateThankYouElementScript:ce,extractRoktExtensionConfig:le,hashEventMessage:he,parseSettingsString:K,generateMappedEventLookup:ue,generateMappedEventAttributeLookup:de,sendAdBlockMeasurementSignals:ge,createAutoRemovedIframe:W,djb2:Ee,setAllowedOriginHashes:p=>{_._allowedOriginHashes=p},ReportingTransport:F,ErrorReportingService:fe,LoggingService:pe,RateLimiter:Re,ErrorCodes:Q,WSDKErrorSeverity:y,resetLauncherAttachState:()=>ot(this._launcherAttachState)},this.attachLauncher(c,E),"Successfully initialized: "+d):(N&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ae(gt,ce(f),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:p=>{console.error("Error loading Rokt Thank You Element script:",p)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,E,b):(ae(ht,oe(f,P),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,E,b):console.error("Rokt object is not available after script load.")},onError:p=>{console.error("Error loading Rokt launcher script:",p)}}),this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===pt&&(De(this.loggingService),this.capturePageView(e),Pe(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===mt&&(ie(),ne(),this.accountId&&T(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(U(a().Rokt?.setLocalSessionAttribute)&&(w(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!w(this.placementEventMappingLookup))){const t=he(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 me(e)||(this.userAttributes[e]=t),Be(this.accountId,e)&&this.flushPendingPreselectDispatches(),"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=v(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="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];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{n(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.accountId&&T(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,se))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,se))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...v(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=v(l);const f=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},P=this.returnUserIdentities(c),b=this.returnLocalSessionAttributes(),N=Ke(te()),E=Me(),R=this.readMpSessionId(),I=this.readMpDeviceId(),k={...P,...l,...f,...b,...N.length?{[Et]:JSON.stringify(N)}:{},...E?{[_t]:E}:{},...this.userIdentifiedInWorkspace?{[ft]:!0}:{},...R?{[It]:R}:{},...I?{[yt]:I}:{},mpid:u},p=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),ke={...e,attributes:k,...p!==void 0?{cacheMatchKeys:p}:{}},X=this.launcher.selectPlacements(ke),Z=e.preselect===!0,ve=()=>{Z||this.logSelectPlacementsEvent(k)};return Promise.resolve(X).then(we=>{if(!Z)return we?.context?.sessionId?.then(Te=>this.setRoktSessionId(Te))}).catch(()=>{}).finally(ve),X}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(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")))}terminate(){return this.isKitReady()?(rt(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};_._allowedOriginHashes=[-553112570,549508659],_.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},_.EMAIL_SHA256_KEY="emailsha256";let S=_;function Ot(){return C}function Nt(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!m(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}m(i.kits)?i.kits[d]={constructor:S}:(i.kits={},i.kits[d]={constructor:S}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:S,getId:Ot});exports.register=Nt;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -107,7 +107,7 @@ function Y(i, e, t = A) {
107
107
  delete r[e], Object.keys(r).length === 0 ? Ne(i, t) : _e(i, r, t);
108
108
  }
109
109
  const q = "pageViews", D = "utmParams", Ie = 25, Ue = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
110
- function Se(i) {
110
+ function ye(i) {
111
111
  return i.slice(-Ie);
112
112
  }
113
113
  function te() {
@@ -115,7 +115,7 @@ function te() {
115
115
  return Array.isArray(i) ? i : [];
116
116
  }
117
117
  function Ce(i) {
118
- const e = Se(i);
118
+ const e = ye(i);
119
119
  for (let t = 0; t < e.length; t++) {
120
120
  const n = e.slice(t);
121
121
  if (x(h, q, n))
@@ -127,9 +127,9 @@ function ie() {
127
127
  Y(h, q);
128
128
  }
129
129
  function Ke(i) {
130
- const e = Se(i);
130
+ const e = ye(i);
131
131
  return e.map((t, n) => {
132
- const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r), c = e[n + 1]?.activeTimeOnSite, l = c !== void 0 && Number.isFinite(c), u = s && l ? c - r : void 0;
132
+ const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r), c = e[n + 1]?.activeTimeOnSite, u = c !== void 0 && Number.isFinite(c), l = s && u ? c - r : void 0;
133
133
  return {
134
134
  pageUrl: t.pageUrl,
135
135
  sourceMessageId: t.sourceMessageId,
@@ -137,7 +137,7 @@ function Ke(i) {
137
137
  ...t.pageTitle !== void 0 ? { pageTitle: t.pageTitle } : {},
138
138
  ...t.canonicalUrl !== void 0 ? { canonicalUrl: t.canonicalUrl } : {},
139
139
  ...s ? { activeTimeOnSite: r } : {},
140
- ...u !== void 0 && u >= 0 ? { activeTimeOnPage: u } : {}
140
+ ...l !== void 0 && l >= 0 ? { activeTimeOnPage: l } : {}
141
141
  };
142
142
  });
143
143
  }
@@ -192,7 +192,25 @@ const J = [
192
192
  "member_status",
193
193
  "billingzipcode",
194
194
  "currency"
195
- ]
195
+ ],
196
+ optionalAttributeKeys: ["firstname", "lastname"]
197
+ },
198
+ {
199
+ accountId: "2550745407543340151",
200
+ pathname: "/checkout",
201
+ targetPageIdentifier: "RoktExperience",
202
+ attributeKeys: [
203
+ "email",
204
+ "amount",
205
+ "firstname",
206
+ "lastname",
207
+ "cartItems",
208
+ "customertype",
209
+ "loyaltytier",
210
+ "paymenttype",
211
+ "ccbin"
212
+ ],
213
+ optionalAttributeKeys: ["loyaltytier", "paymenttype", "ccbin"]
196
214
  }
197
215
  ], xe = 6e4;
198
216
  function Ye(i) {
@@ -285,21 +303,21 @@ function V(i) {
285
303
  return g(n) && n.length > 0;
286
304
  }) : !1;
287
305
  }
288
- function ye(i) {
306
+ function Se(i) {
289
307
  const e = i?.getMPID?.();
290
308
  return e == null ? null : String(e);
291
309
  }
292
310
  function re(i, e, t) {
293
- const n = i.filteredUser?.getAllUserAttributes?.() || {}, r = {}, s = [];
294
- for (const o of t.attributeKeys) {
295
- const c = i.getEventAttributeValue(e, o), l = w(c) ? i.userAttributes[o] ?? n[o] : c;
311
+ const n = i.filteredUser?.getAllUserAttributes?.() || {}, r = new Set((t.optionalAttributeKeys ?? []).map((c) => c.toLowerCase())), s = {}, o = [];
312
+ for (const c of t.attributeKeys) {
313
+ const u = i.getEventAttributeValue(e, c), l = w(u) ? i.userAttributes[c] ?? n[c] : u;
296
314
  if (w(l)) {
297
- s.push(o);
315
+ r.has(c.toLowerCase()) || o.push(c);
298
316
  continue;
299
317
  }
300
- r[o] = l;
318
+ s[c] = l;
301
319
  }
302
- return { collected: r, missingKeys: s };
320
+ return { collected: s, missingKeys: o };
303
321
  }
304
322
  function Xe(i, e) {
305
323
  Promise.resolve(i.selectPlacements(e)).catch((t) => {
@@ -311,8 +329,8 @@ function Xe(i, e) {
311
329
  });
312
330
  }
313
331
  function Ae(i, e, t, n, r, s) {
314
- const o = Ge(e, t), c = je(o), l = !!c && JSON.stringify(c.attributes) === JSON.stringify(r);
315
- if (c && c.expiresAt > Date.now() && l) {
332
+ const o = Ge(e, t), c = je(o), u = !!c && JSON.stringify(c.attributes) === JSON.stringify(r);
333
+ if (c && c.expiresAt > Date.now() && u) {
316
334
  i.logPlacementDiagnostic(L("skipped", "active_preselection"));
317
335
  return;
318
336
  }
@@ -331,7 +349,7 @@ function Ze(i, e) {
331
349
  T(e.accountId);
332
350
  return;
333
351
  }
334
- V(e.filteredUser) && (T(e.accountId), ye(e.filteredUser) === t.mpid && Ae(e, e.accountId, t.identifier, t.identifier, t.attributes, "recovered"));
352
+ V(e.filteredUser) && (T(e.accountId), Se(e.filteredUser) === t.mpid && Ae(e, e.accountId, t.identifier, t.identifier, t.attributes, "recovered"));
335
353
  }
336
354
  }
337
355
  function Pe(i, e, t, n = window.location.pathname) {
@@ -339,17 +357,17 @@ function Pe(i, e, t, n = window.location.pathname) {
339
357
  if (!r)
340
358
  return;
341
359
  if (!e.isKitReady()) {
342
- const c = [], l = ye(e.filteredUser);
343
- if (e.accountId && l && V(e.filteredUser)) {
344
- const { collected: u, missingKeys: f } = re(e, t, r);
360
+ const c = [], u = Se(e.filteredUser);
361
+ if (e.accountId && u && V(e.filteredUser)) {
362
+ const { collected: l, missingKeys: f } = re(e, t, r);
345
363
  if (f.length === 0) {
346
- const P = v(u);
364
+ const P = v(l);
347
365
  $e(
348
366
  e.accountId,
349
367
  n,
350
368
  r.targetPageIdentifier,
351
369
  P,
352
- l
370
+ u
353
371
  ) || c.push(L("queued", "persist_failed"));
354
372
  }
355
373
  }
@@ -416,16 +434,16 @@ function ct(i, e, t) {
416
434
  i.recreateInFlight = null;
417
435
  }), i.recreateInFlight;
418
436
  }
419
- const d = "Rokt", C = 181, at = "selectPlacements", lt = "apps.roktecommerce.com", ut = 0.1, dt = "ThankYouPageJourney", ht = "rokt-launcher", gt = "rokt-thank-you-element", ft = "userIdentifiedInWorkspace", pt = 3, mt = 2, Et = "page_events", _t = "page_view_attributes", It = "mparticle_session_id", St = "mparticle_device_id", se = 500, Q = {
437
+ const d = "Rokt", C = 181, at = "selectPlacements", lt = "apps.roktecommerce.com", ut = 0.1, dt = "ThankYouPageJourney", ht = "rokt-launcher", gt = "rokt-thank-you-element", ft = "userIdentifiedInWorkspace", pt = 3, mt = 2, Et = "page_events", _t = "page_view_attributes", It = "mparticle_session_id", yt = "mparticle_device_id", se = 500, Q = {
420
438
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
421
439
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
422
440
  IDENTITY_REQUEST: "IDENTITY_REQUEST",
423
441
  LOG_DELIVERY_FAILURE: "LOG_DELIVERY_FAILURE"
424
- }, S = {
442
+ }, y = {
425
443
  ERROR: "ERROR",
426
444
  INFO: "INFO",
427
445
  WARNING: "WARNING"
428
- }, yt = "apps.rokt-api.com", At = "/v1/log", Pt = "/v1/errors", Rt = 10;
446
+ }, St = "apps.rokt-api.com", At = "/v1/log", Pt = "/v1/errors", bt = 10;
429
447
  function a() {
430
448
  return window.mParticle;
431
449
  }
@@ -437,10 +455,10 @@ function ce(i) {
437
455
  return [G(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
438
456
  }
439
457
  function G(i) {
440
- const e = i !== void 0 ? i : yt;
458
+ const e = i !== void 0 ? i : St;
441
459
  return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
442
460
  }
443
- function Re(i, e, t) {
461
+ function be(i, e, t) {
444
462
  if (i)
445
463
  return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
446
464
  const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
@@ -474,7 +492,7 @@ function le(i) {
474
492
  loadThankYouElement: r
475
493
  };
476
494
  }
477
- async function kt(i, e) {
495
+ async function Rt(i, e) {
478
496
  const t = [];
479
497
  if (e)
480
498
  for (const n of i)
@@ -510,8 +528,8 @@ function de(i) {
510
528
  function he(i, e, t) {
511
529
  return a().generateHash([i, e, t].join(""));
512
530
  }
513
- function bt(i) {
514
- let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.3.3";
531
+ function kt(i) {
532
+ let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.5.0";
515
533
  return i && (n += "_" + i), n;
516
534
  }
517
535
  function W(i) {
@@ -524,7 +542,7 @@ function W(i) {
524
542
  }
525
543
  function ge(i, e) {
526
544
  const t = Ee(window.location.origin);
527
- if (y._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= ut)
545
+ if (S._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= ut)
528
546
  return;
529
547
  const r = window.__rokt_li_guid__;
530
548
  if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
@@ -543,20 +561,20 @@ function wt() {
543
561
  function Tt() {
544
562
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
545
563
  }
546
- class ke {
564
+ class Re {
547
565
  constructor() {
548
566
  this._logCount = {};
549
567
  }
550
568
  incrementAndCheck(e) {
551
569
  const n = (this._logCount[e] || 0) + 1;
552
- return this._logCount[e] = n, n > Rt;
570
+ return this._logCount[e] = n, n > bt;
553
571
  }
554
572
  }
555
573
  class F {
556
574
  constructor(e, t, n, r, s) {
557
575
  this._reporter = "mp-wsdk";
558
576
  const o = e.isLoggingEnabled;
559
- this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new ke(), this._isEnabled = vt() || o;
577
+ this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new Re(), this._isEnabled = vt() || o;
560
578
  }
561
579
  send(e, t, n, r, s, o) {
562
580
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
@@ -573,23 +591,23 @@ class F {
573
591
  stackTrace: s,
574
592
  reporter: this._reporter,
575
593
  integration: this._integrationName
576
- }, l = {
594
+ }, u = {
577
595
  Accept: "text/plain;charset=UTF-8",
578
596
  "Content-Type": "application/json",
579
597
  "rokt-launcher-version": this._integrationName,
580
598
  "rokt-wsdk-version": "joint"
581
599
  };
582
- this._launcherInstanceGuid && (l["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (l["rokt-account-id"] = this._accountId), fetch(e, {
600
+ this._launcherInstanceGuid && (u["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (u["rokt-account-id"] = this._accountId), fetch(e, {
583
601
  method: "POST",
584
- headers: l,
602
+ headers: u,
585
603
  body: JSON.stringify(c)
586
- }).then((u) => {
587
- if (!u.ok) {
588
- const f = new Error("HTTP " + u.status + " from log endpoint");
589
- throw f.statusCode = u.status, f;
604
+ }).then((l) => {
605
+ if (!l.ok) {
606
+ const f = new Error("HTTP " + l.status + " from log endpoint");
607
+ throw f.statusCode = l.status, f;
590
608
  }
591
- }).catch((u) => {
592
- console.error("ReportingTransport: Failed to send log", u), o && o(u);
609
+ }).catch((l) => {
610
+ console.error("ReportingTransport: Failed to send log", l), o && o(l);
593
611
  });
594
612
  } catch (c) {
595
613
  console.error("ReportingTransport: Failed to send log", c), o && o(c);
@@ -598,11 +616,11 @@ class F {
598
616
  }
599
617
  class fe {
600
618
  constructor(e, t, n, r, s) {
601
- this._transport = new F(e, t, n, r, s), this._errorUrl = Re(e?.errorUrl, e?.integrationDomain, Pt);
619
+ this._transport = new F(e, t, n, r, s), this._errorUrl = be(e?.errorUrl, e?.integrationDomain, Pt);
602
620
  }
603
621
  report(e) {
604
622
  if (!e) return;
605
- const t = e.severity || S.ERROR;
623
+ const t = e.severity || y.ERROR;
606
624
  this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
607
625
  }
608
626
  }
@@ -613,7 +631,7 @@ class pe {
613
631
  n,
614
632
  r,
615
633
  s
616
- ), this._loggingUrl = Re(e?.loggingUrl, e?.integrationDomain, At), this._errorReportingService = t;
634
+ ), this._loggingUrl = be(e?.loggingUrl, e?.integrationDomain, At), this._errorReportingService = t;
617
635
  }
618
636
  log(e) {
619
637
  e && this._send(this._transport, e);
@@ -624,7 +642,7 @@ class pe {
624
642
  _send(e, t) {
625
643
  e.send(
626
644
  this._loggingUrl,
627
- S.INFO,
645
+ y.INFO,
628
646
  t.message,
629
647
  t.code,
630
648
  void 0,
@@ -634,7 +652,7 @@ class pe {
634
652
  this._errorReportingService.report({
635
653
  message: "LoggingService: Failed to send log: " + n.message,
636
654
  code: Q.LOG_DELIVERY_FAILURE,
637
- severity: r ? S.ERROR : S.WARNING
655
+ severity: r ? y.ERROR : y.WARNING
638
656
  });
639
657
  }
640
658
  }
@@ -802,13 +820,13 @@ const _ = class _ {
802
820
  };
803
821
  let s;
804
822
  return this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(r)) : s = window.Rokt.createLauncher(r), s.then(async (o) => {
805
- await kt([...n], o), this.initRoktLauncher(o);
823
+ await Rt([...n], o), this.initRoktLauncher(o);
806
824
  }).catch((o) => {
807
825
  const c = this._launcherAttachState.lifecycle === "attached";
808
826
  if (st(this._launcherAttachState), !c) {
809
- const l = o instanceof Error ? o.message : String(o);
827
+ const u = o instanceof Error ? o.message : String(o);
810
828
  this.loggingService?.log({
811
- message: `Rokt Kit: Failed to attach Rokt launcher: ${l}`,
829
+ message: `Rokt Kit: Failed to attach Rokt launcher: ${u}`,
812
830
  code: "LAUNCHER_ATTACH_FAILED"
813
831
  });
814
832
  }
@@ -863,47 +881,47 @@ const _ = class _ {
863
881
  init(e, t, n, r, s) {
864
882
  const o = e, c = o.accountId;
865
883
  this.accountId = c || null, this.userAttributes = v(s), this._onboardingExpProvider = o.onboardingExpProvider;
866
- const l = K(o.placementEventMapping);
867
- this.placementEventMappingLookup = ue(l);
868
- const u = K(
884
+ const u = K(o.placementEventMapping);
885
+ this.placementEventMappingLookup = ue(u);
886
+ const l = K(
869
887
  o.placementEventAttributeMapping
870
888
  );
871
- this.placementEventAttributeMappingLookup = de(u), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = g(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
872
- const f = a().Rokt?.domain, { roktExtensionsQueryParams: P, legacyRoktExtensions: R, loadThankYouElement: N } = le(
889
+ this.placementEventAttributeMappingLookup = de(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = g(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
890
+ const f = a().Rokt?.domain, { roktExtensionsQueryParams: P, legacyRoktExtensions: b, loadThankYouElement: N } = le(
873
891
  o.roktExtensions
874
892
  ), E = {
875
893
  ...a().Rokt?.launcherOptions || {}
876
894
  };
877
- this.integrationName = bt(E.integrationName), E.integrationName = this.integrationName, this.domain = f;
878
- const k = {
895
+ this.integrationName = kt(E.integrationName), E.integrationName = this.integrationName, this.domain = f;
896
+ const R = {
879
897
  loggingUrl: o.loggingUrl,
880
898
  errorUrl: o.errorUrl,
881
899
  integrationDomain: f,
882
900
  isLoggingEnabled: a().config?.isLoggingEnabled === !0
883
901
  }, I = new fe(
884
- k,
902
+ R,
885
903
  this.integrationName,
886
904
  window.__rokt_li_guid__,
887
905
  o.accountId
888
- ), b = new pe(
889
- k,
906
+ ), k = new pe(
907
+ R,
890
908
  I,
891
909
  this.integrationName,
892
910
  window.__rokt_li_guid__,
893
911
  o.accountId
894
912
  );
895
- if (this.errorReportingService = I, this.loggingService = b, this.isTargetingDisabled())
913
+ if (this.errorReportingService = I, this.loggingService = k, this.isTargetingDisabled())
896
914
  try {
897
915
  ie(), ne();
898
916
  } catch (p) {
899
917
  this.errorReportingService?.report({
900
918
  message: "Rokt Kit: Failed to clear page views when targeting is disabled",
901
919
  code: "PAGE_VIEW_CAPTURE_FAILED",
902
- severity: S.INFO,
920
+ severity: y.INFO,
903
921
  stackTrace: p instanceof Error ? p.stack : void 0
904
922
  });
905
923
  }
906
- return a()._registerErrorReportingService && a()._registerErrorReportingService(I), a()._registerLoggingService && a()._registerLoggingService(b), n ? (this.testHelpers = {
924
+ return a()._registerErrorReportingService && a()._registerErrorReportingService(I), a()._registerLoggingService && a()._registerLoggingService(k), n ? (this.testHelpers = {
907
925
  generateLauncherScript: oe,
908
926
  generateThankYouElementScript: ce,
909
927
  extractRoktExtensionConfig: le,
@@ -920,9 +938,9 @@ const _ = class _ {
920
938
  ReportingTransport: F,
921
939
  ErrorReportingService: fe,
922
940
  LoggingService: pe,
923
- RateLimiter: ke,
941
+ RateLimiter: Re,
924
942
  ErrorCodes: Q,
925
- WSDKErrorSeverity: S,
943
+ WSDKErrorSeverity: y,
926
944
  resetLauncherAttachState: () => ot(this._launcherAttachState)
927
945
  }, this.attachLauncher(c, E), "Successfully initialized: " + d) : (N && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), ae(gt, ce(f), {
928
946
  onLoad: () => {
@@ -931,9 +949,9 @@ const _ = class _ {
931
949
  onError: (p) => {
932
950
  console.error("Error loading Rokt Thank You Element script:", p);
933
951
  }
934
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, R) : (ae(ht, oe(f, P), {
952
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, b) : (ae(ht, oe(f, P), {
935
953
  onLoad: () => {
936
- this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, R) : console.error("Rokt object is not available after script load.");
954
+ this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, b) : console.error("Rokt object is not available after script load.");
937
955
  },
938
956
  onError: (p) => {
939
957
  console.error("Error loading Rokt launcher script:", p);
@@ -980,21 +998,21 @@ const _ = class _ {
980
998
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
981
999
  const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
982
1000
  if (r)
983
- for (const l of Object.keys(r)) {
984
- const u = r[l];
985
- g(u) && u.length > 0 && (s[l] = u);
1001
+ for (const u of Object.keys(r)) {
1002
+ const l = r[u];
1003
+ g(l) && l.length > 0 && (s[u] = l);
986
1004
  }
987
1005
  const o = Object.keys(s);
988
1006
  if (o.length === 0)
989
1007
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
990
- const c = o.sort().map((l) => `${l}=${s[l]}`).join("&");
991
- return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((l) => {
1008
+ const c = o.sort().map((u) => `${u}=${s[u]}`).join("&");
1009
+ return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
992
1010
  try {
993
- n(t, s, (u) => {
994
- u?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), l();
1011
+ n(t, s, (l) => {
1012
+ l?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
995
1013
  });
996
- } catch (u) {
997
- console.error("Rokt Kit: Workspace IDSync search failed", u), this._workspaceLastSearchedIdentitiesKey = void 0, l();
1014
+ } catch (l) {
1015
+ console.error("Rokt Kit: Workspace IDSync search failed", l), this._workspaceLastSearchedIdentitiesKey = void 0, u();
998
1016
  }
999
1017
  }));
1000
1018
  }
@@ -1052,26 +1070,26 @@ const _ = class _ {
1052
1070
  return this._dispatchPlacements(e);
1053
1071
  }
1054
1072
  _dispatchPlacements(e) {
1055
- const t = e && e.attributes || {}, r = { ...v(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, l = c ? c.getMPID() : null;
1056
- let u;
1057
- s ? s.filterUserAttributes ? u = s.filterUserAttributes(r, o) : u = r : (console.warn("Rokt Kit: No filters available, using user attributes"), u = r), this.userAttributes = v(u);
1058
- const f = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, P = this.returnUserIdentities(c), R = this.returnLocalSessionAttributes(), N = Ke(te()), E = Me(), k = this.readMpSessionId(), I = this.readMpDeviceId(), b = {
1073
+ const t = e && e.attributes || {}, r = { ...v(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
1074
+ let l;
1075
+ s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = v(l);
1076
+ const f = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, P = this.returnUserIdentities(c), b = this.returnLocalSessionAttributes(), N = Ke(te()), E = Me(), R = this.readMpSessionId(), I = this.readMpDeviceId(), k = {
1059
1077
  ...P,
1060
- ...u,
1078
+ ...l,
1061
1079
  ...f,
1062
- ...R,
1080
+ ...b,
1063
1081
  ...N.length ? { [Et]: JSON.stringify(N) } : {},
1064
1082
  ...E ? { [_t]: E } : {},
1065
1083
  ...this.userIdentifiedInWorkspace ? { [ft]: !0 } : {},
1066
- ...k ? { [It]: k } : {},
1067
- ...I ? { [St]: I } : {},
1068
- mpid: l
1069
- }, p = this.buildCacheMatchKeys(typeof e.identifier == "string" ? e.identifier : void 0), be = {
1084
+ ...R ? { [It]: R } : {},
1085
+ ...I ? { [yt]: I } : {},
1086
+ mpid: u
1087
+ }, p = this.buildCacheMatchKeys(typeof e.identifier == "string" ? e.identifier : void 0), ke = {
1070
1088
  ...e,
1071
- attributes: b,
1089
+ attributes: k,
1072
1090
  ...p !== void 0 ? { cacheMatchKeys: p } : {}
1073
- }, X = this.launcher.selectPlacements(be), Z = e.preselect === !0, ve = () => {
1074
- Z || this.logSelectPlacementsEvent(b);
1091
+ }, X = this.launcher.selectPlacements(ke), Z = e.preselect === !0, ve = () => {
1092
+ Z || this.logSelectPlacementsEvent(k);
1075
1093
  };
1076
1094
  return Promise.resolve(X).then((we) => {
1077
1095
  if (!Z)
@@ -1115,7 +1133,7 @@ const _ = class _ {
1115
1133
  _._allowedOriginHashes = [-553112570, 549508659], _.PERFORMANCE_MARKS = {
1116
1134
  RoktScriptAppended: "mp:RoktScriptAppended"
1117
1135
  }, _.EMAIL_SHA256_KEY = "emailsha256";
1118
- let y = _;
1136
+ let S = _;
1119
1137
  function Ot() {
1120
1138
  return C;
1121
1139
  }
@@ -1129,14 +1147,14 @@ function Nt(i) {
1129
1147
  return;
1130
1148
  }
1131
1149
  m(i.kits) ? i.kits[d] = {
1132
- constructor: y
1150
+ constructor: S
1133
1151
  } : (i.kits = {}, i.kits[d] = {
1134
- constructor: y
1152
+ constructor: S
1135
1153
  }), window.console.log("Successfully registered " + d + " to your mParticle configuration");
1136
1154
  }
1137
1155
  typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
1138
1156
  name: d,
1139
- constructor: y,
1157
+ constructor: S,
1140
1158
  getId: Ot
1141
1159
  });
1142
1160
  export {
@@ -1,2 +1,2 @@
1
- var RoktKit=(function(j){"use strict";const ve=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],we=new Set(ve);function Z(i){return we.has(i.toLowerCase())}function P(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];Z(s)||(e[s]=t[s])}return e}function f(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function N(i){return typeof i=="function"}function R(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function H(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const d="mp-rokt-kit",te="__rokt_ls_probe__";function V(){try{return window.localStorage.setItem(te,"1"),window.localStorage.removeItem(te),!0}catch{return!1}}const I=()=>window.localStorage;function W(i,e=I){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function ie(i,e,t=I){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Te(i,e=I){try{e().removeItem(i)}catch{}}function b(i,e,t=I){const n=W(i,t);return f(n)?n[e]:void 0}function U(i,e,t,n=I){const r=W(i,n),s=f(r)?{...r}:{};return s[e]=t,ie(i,s,n)}function C(i,e,t=I){const n=W(i,t);if(!f(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Te(i,t):ie(i,r,t)}const z="pageViews",K="utmParams",ne=25,Le=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function re(i){return i.slice(-ne)}function se(){const i=b(d,z);return Array.isArray(i)?i:[]}function Oe(i){const e=re(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(U(d,z,n))return n.length}return 0}function oe(){C(d,z)}function Ne(i){const e=re(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,l=c!==void 0&&Number.isFinite(c),u=s&&l?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...u!==void 0&&u>=0?{activeTimeOnPage:u}:{}}})}function Ue(i){if(b(d,K)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Le){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!U(d,K,t)){const r=V()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function Ce(){const i=b(d,K);return f(i)?i:null}function ce(){C(d,K)}function Ke(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return H(e)}const $=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","amount","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"]}],De=6e4;function Me(i){return f(i)&&typeof i.expiresAt=="number"&&f(i.attributes)}function Fe(i,e){return`activePreselect:${i}:${e}`}function xe(i){const e=b(d,i);return Me(e)?e:null}function Ye(i,e){U(d,i,{expiresAt:Date.now()+De,attributes:e})}const Ge=5*6e4;function D(){return window.sessionStorage}function je(i){return f(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&f(i.attributes)&&g(i.mpid)}function q(i){return`pendingPreselect:${i}`}function He(i){const e=q(i),t=b(d,e,D);return je(t)?t.expiresAt<=Date.now()?(C(d,e,D),null):t:null}function Ve(i,e,t,n,r){return U(d,q(i),{expiresAt:Date.now()+Ge,pathname:e,identifier:t,attributes:n,mpid:r},D)}function k(i){C(d,q(i),D)}function v(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function We(i,e){if(i)return $.find(t=>t.accountId===i&&t.pathname===e)}function ze(i,e){if(!(!i||!g(e)))return $.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function $e(i,e){return i?$.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function qe(){return{pending:[]}}function J(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function B(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function ae(i){const e=i?.getMPID?.();return e==null?null:String(e)}function le(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r={},s=[];for(const o of t.attributeKeys){const c=i.getEventAttributeValue(e,o),l=R(c)?i.userAttributes[o]??n[o]:c;if(R(l)){s.push(o);continue}r[o]=l}return{collected:r,missingKeys:s}}function Je(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function ue(i,e,t,n,r,s){const o=Fe(e,t),c=xe(o),l=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&l){i.logPlacementDiagnostic(v("skipped","active_preselection"));return}Ye(o,r),i.logPlacementDiagnostic(v("fired",s)),Je(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Be(i,e){if(!e.accountId||!e.isKitReady())return;const t=He(e.accountId);if(t){if(i.pending.some(n=>n.pathname===t.pathname)){k(e.accountId);return}if(!e.isPreselectionEnabled()){k(e.accountId);return}B(e.filteredUser)&&(k(e.accountId),ae(e.filteredUser)===t.mpid&&ue(e,e.accountId,t.identifier,t.identifier,t.attributes,"recovered"))}}function de(i,e,t,n=window.location.pathname){const r=We(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],l=ae(e.filteredUser);if(e.accountId&&l&&B(e.filteredUser)){const{collected:u,missingKeys:p}=le(e,t,r);if(p.length===0){const w=P(u);Ve(e.accountId,n,r.targetPageIdentifier,w,l)||c.push(v("queued","persist_failed"))}}J(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!B(e.filteredUser)){e.logPlacementDiagnostic(v("missed","no_valid_identity")),J(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=le(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(v("missed",`missing_attribute:${c}`));J(i,{event:t,pathname:n});return}ue(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function Qe(i,e,t=window.location.pathname){if(Be(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),de(i,e,r,s))})}function Xe(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function Ze(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function et(i){i.lifecycle="attached"}function tt(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function it(i){i.lifecycle="terminated"}function nt(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function rt(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const h="Rokt",M=181,st="selectPlacements",ot="apps.roktecommerce.com",ct=.1,at="ThankYouPageJourney",lt="rokt-launcher",ut="rokt-thank-you-element",dt="userIdentifiedInWorkspace",ht=3,gt=2,ft="page_events",pt="page_view_attributes",mt="mparticle_session_id",Et="mparticle_device_id",he=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},S={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},_t="apps.rokt-api.com",It="/v1/log",St="/v1/errors",yt=10;function a(){return window.mParticle}function ge(i,e){const n=[F(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function fe(i){return[F(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function F(i){const e=i!==void 0?i:_t;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function pe(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return F(r)+t}function me(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,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),n.appendChild(r)}function x(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Ee(i){const e=i?x(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(at)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function At(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function _e(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function Ie(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function Se(i,e,t){return a().generateHash([i,e,t].join(""))}function Pt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.3.3";return i&&(n+="_"+i),n}function X(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function ye(i,e){const t=ee(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ct)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?F(i):"https://apps.rokt.com";X(c+"/v1/wsdk-init/index.html?"+o),X("https://"+ot+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Rt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function bt(){return typeof window<"u"?window.location?.href:void 0}function kt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class Ae{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>yt}}class Y{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new Ae,this._isEnabled=Rt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:bt(),deviceInfo:kt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},l={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(l["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(l["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:l,body:JSON.stringify(c)}).then(u=>{if(!u.ok){const p=new Error("HTTP "+u.status+" from log endpoint");throw p.statusCode=u.status,p}}).catch(u=>{console.error("ReportingTransport: Failed to send log",u),o&&o(u)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class Pe{constructor(e,t,n,r,s){this._transport=new Y(e,t,n,r,s),this._errorUrl=pe(e?.errorUrl,e?.integrationDomain,St)}report(e){if(!e)return;const t=e.severity||S.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class Re{constructor(e,t,n,r,s,o){this._transport=new Y(e,n,r,s,o),this._placementDiagnosticTransport=new Y(e,n,r,s),this._loggingUrl=pe(e?.loggingUrl,e?.integrationDomain,It),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,S.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?S.ERROR:S.WARNING})}})}}function vt(i){const e=H(window.location.href),t=i.EventAttributes?.title||document.title,n=Ke(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const E=class E{constructor(){this.name=h,this.id=M,this.moduleId=M,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,this._launcherAttachState=Xe(),this.accountId=null,this._preselectState=qe()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(R(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)}}capturePageView(e){let t;try{t=H(window.location.href);const n=se(),r=vt(e);n.push(r);const s=Math.min(n.length,ne),o=Oe(n);if(o===0){const c=V()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=V()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=ze(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){Qe(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&N(window.Rokt.createLauncher)}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"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[E.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!f(e))return;const t=a().EventType.Other;a().logEvent(st,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&N(t.setIntegrationAttribute)&&t.setIntegrationAttribute(M,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(N(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){Ze(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await At([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(it(this._launcherAttachState),!c){const l=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${l}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return rt(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,et(this._launcherAttachState);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,ye(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}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)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}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,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=P(s),this._onboardingExpProvider=o.onboardingExpProvider;const l=x(o.placementEventMapping);this.placementEventMappingLookup=_e(l);const u=x(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Ie(u),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:w,legacyRoktExtensions:T,loadThankYouElement:G}=Ee(o.roktExtensions),_={...a().Rokt?.launcherOptions||{}};this.integrationName=Pt(_.integrationName),_.integrationName=this.integrationName,this.domain=p;const L={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},A=new Pe(L,this.integrationName,window.__rokt_li_guid__,o.accountId),O=new Re(L,A,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=A,this.loggingService=O,this.isTargetingDisabled())try{oe(),ce()}catch(m){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:S.INFO,stackTrace:m instanceof Error?m.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(A),a()._registerLoggingService&&a()._registerLoggingService(O),n?(this.testHelpers={generateLauncherScript:ge,generateThankYouElementScript:fe,extractRoktExtensionConfig:Ee,hashEventMessage:Se,parseSettingsString:x,generateMappedEventLookup:_e,generateMappedEventAttributeLookup:Ie,sendAdBlockMeasurementSignals:ye,createAutoRemovedIframe:X,djb2:ee,setAllowedOriginHashes:m=>{E._allowedOriginHashes=m},ReportingTransport:Y,ErrorReportingService:Pe,LoggingService:Re,RateLimiter:Ae,ErrorCodes:Q,WSDKErrorSeverity:S,resetLauncherAttachState:()=>nt(this._launcherAttachState)},this.attachLauncher(c,_),"Successfully initialized: "+h):(G&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),me(ut,fe(p),{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,_,T):(me(lt,ge(p,w),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):console.error("Rokt object is not available after script load.")},onError:m=>{console.error("Error loading Rokt launcher script:",m)}}),this.captureTiming(E.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+h)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ht&&(Ue(this.loggingService),this.capturePageView(e),de(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===gt&&(oe(),ce(),this.accountId&&k(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+h;if(N(a().Rokt?.setLocalSessionAttribute)&&(R(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!R(this.placementEventMappingLookup))){const t=Se(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+h}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),$e(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+h}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+h}handleIdentityComplete(e,t){return this.userAttributes=P(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+h}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const l of Object.keys(r)){const u=r[l];g(u)&&u.length>0&&(s[l]=u)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(l=>`${l}=${s[l]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(l=>{try{n(t,s,u=>{u?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),l()})}catch(u){console.error("Rokt Kit: Workspace IDSync search failed",u),this._workspaceLastSearchedIdentitiesKey=void 0,l()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&k(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,he))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,he))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...P(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,l=c?c.getMPID():null;let u;s?s.filterUserAttributes?u=s.filterUserAttributes(r,o):u=r:(console.warn("Rokt Kit: No filters available, using user attributes"),u=r),this.userAttributes=P(u);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},w=this.returnUserIdentities(c),T=this.returnLocalSessionAttributes(),G=Ne(se()),_=Ce(),L=this.readMpSessionId(),A=this.readMpDeviceId(),O={...w,...u,...p,...T,...G.length?{[ft]:JSON.stringify(G)}:{},..._?{[pt]:_}:{},...this.userIdentifiedInWorkspace?{[dt]:!0}:{},...L?{[mt]:L}:{},...A?{[Et]:A}:{},mpid:l},m=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),Lt={...e,attributes:O,...m!==void 0?{cacheMatchKeys:m}:{}},be=this.launcher.selectPlacements(Lt),ke=e.preselect===!0,Ot=()=>{ke||this.logSelectPlacementsEvent(O)};return Promise.resolve(be).then(Nt=>{if(!ke)return Nt?.context?.sessionId?.then(Ut=>this.setRoktSessionId(Ut))}).catch(()=>{}).finally(Ot),be}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(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")))}terminate(){return this.isKitReady()?(tt(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};E._allowedOriginHashes=[-553112570,549508659],E.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},E.EMAIL_SHA256_KEY="emailsha256";let y=E;function wt(){return M}function Tt(i){if(!i){window.console.log("You must pass a config object to register the kit "+h);return}if(!f(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}f(i.kits)?i.kits[h]={constructor:y}:(i.kits={},i.kits[h]={constructor:y}),window.console.log("Successfully registered "+h+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:h,constructor:y,getId:wt}),j.register=Tt,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),j})({});
1
+ var RoktKit=(function(j){"use strict";const ve=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],we=new Set(ve);function Z(i){return we.has(i.toLowerCase())}function P(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];Z(s)||(e[s]=t[s])}return e}function f(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function N(i){return typeof i=="function"}function b(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function H(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const d="mp-rokt-kit",te="__rokt_ls_probe__";function V(){try{return window.localStorage.setItem(te,"1"),window.localStorage.removeItem(te),!0}catch{return!1}}const I=()=>window.localStorage;function W(i,e=I){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function ie(i,e,t=I){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Te(i,e=I){try{e().removeItem(i)}catch{}}function R(i,e,t=I){const n=W(i,t);return f(n)?n[e]:void 0}function U(i,e,t,n=I){const r=W(i,n),s=f(r)?{...r}:{};return s[e]=t,ie(i,s,n)}function C(i,e,t=I){const n=W(i,t);if(!f(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Te(i,t):ie(i,r,t)}const z="pageViews",K="utmParams",ne=25,Le=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function re(i){return i.slice(-ne)}function se(){const i=R(d,z);return Array.isArray(i)?i:[]}function Oe(i){const e=re(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(U(d,z,n))return n.length}return 0}function oe(){C(d,z)}function Ne(i){const e=re(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Ue(i){if(R(d,K)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Le){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!U(d,K,t)){const r=V()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function Ce(){const i=R(d,K);return f(i)?i:null}function ce(){C(d,K)}function Ke(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return H(e)}const $=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","amount","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","amount","firstname","lastname","cartItems","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]}],De=6e4;function Me(i){return f(i)&&typeof i.expiresAt=="number"&&f(i.attributes)}function Fe(i,e){return`activePreselect:${i}:${e}`}function xe(i){const e=R(d,i);return Me(e)?e:null}function Ye(i,e){U(d,i,{expiresAt:Date.now()+De,attributes:e})}const Ge=5*6e4;function D(){return window.sessionStorage}function je(i){return f(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&f(i.attributes)&&g(i.mpid)}function q(i){return`pendingPreselect:${i}`}function He(i){const e=q(i),t=R(d,e,D);return je(t)?t.expiresAt<=Date.now()?(C(d,e,D),null):t:null}function Ve(i,e,t,n,r){return U(d,q(i),{expiresAt:Date.now()+Ge,pathname:e,identifier:t,attributes:n,mpid:r},D)}function k(i){C(d,q(i),D)}function v(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function We(i,e){if(i)return $.find(t=>t.accountId===i&&t.pathname===e)}function ze(i,e){if(!(!i||!g(e)))return $.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function $e(i,e){return i?$.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function qe(){return{pending:[]}}function J(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function B(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function ae(i){const e=i?.getMPID?.();return e==null?null:String(e)}function le(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r=new Set((t.optionalAttributeKeys??[]).map(c=>c.toLowerCase())),s={},o=[];for(const c of t.attributeKeys){const u=i.getEventAttributeValue(e,c),l=b(u)?i.userAttributes[c]??n[c]:u;if(b(l)){r.has(c.toLowerCase())||o.push(c);continue}s[c]=l}return{collected:s,missingKeys:o}}function Je(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function ue(i,e,t,n,r,s){const o=Fe(e,t),c=xe(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(v("skipped","active_preselection"));return}Ye(o,r),i.logPlacementDiagnostic(v("fired",s)),Je(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Be(i,e){if(!e.accountId||!e.isKitReady())return;const t=He(e.accountId);if(t){if(i.pending.some(n=>n.pathname===t.pathname)){k(e.accountId);return}if(!e.isPreselectionEnabled()){k(e.accountId);return}B(e.filteredUser)&&(k(e.accountId),ae(e.filteredUser)===t.mpid&&ue(e,e.accountId,t.identifier,t.identifier,t.attributes,"recovered"))}}function de(i,e,t,n=window.location.pathname){const r=We(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=ae(e.filteredUser);if(e.accountId&&u&&B(e.filteredUser)){const{collected:l,missingKeys:p}=le(e,t,r);if(p.length===0){const w=P(l);Ve(e.accountId,n,r.targetPageIdentifier,w,u)||c.push(v("queued","persist_failed"))}}J(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!B(e.filteredUser)){e.logPlacementDiagnostic(v("missed","no_valid_identity")),J(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=le(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(v("missed",`missing_attribute:${c}`));J(i,{event:t,pathname:n});return}ue(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function Qe(i,e,t=window.location.pathname){if(Be(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),de(i,e,r,s))})}function Xe(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function Ze(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function et(i){i.lifecycle="attached"}function tt(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function it(i){i.lifecycle="terminated"}function nt(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function rt(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const h="Rokt",M=181,st="selectPlacements",ot="apps.roktecommerce.com",ct=.1,at="ThankYouPageJourney",lt="rokt-launcher",ut="rokt-thank-you-element",dt="userIdentifiedInWorkspace",ht=3,gt=2,ft="page_events",pt="page_view_attributes",mt="mparticle_session_id",Et="mparticle_device_id",he=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},y={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},_t="apps.rokt-api.com",It="/v1/log",yt="/v1/errors",St=10;function a(){return window.mParticle}function ge(i,e){const n=[F(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function fe(i){return[F(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function F(i){const e=i!==void 0?i:_t;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function pe(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return F(r)+t}function me(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,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),n.appendChild(r)}function x(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Ee(i){const e=i?x(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(at)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function At(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function _e(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function Ie(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function ye(i,e,t){return a().generateHash([i,e,t].join(""))}function Pt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.5.0";return i&&(n+="_"+i),n}function X(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function Se(i,e){const t=ee(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ct)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?F(i):"https://apps.rokt.com";X(c+"/v1/wsdk-init/index.html?"+o),X("https://"+ot+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function bt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Rt(){return typeof window<"u"?window.location?.href:void 0}function kt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class Ae{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>St}}class Y{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new Ae,this._isEnabled=bt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:Rt(),deviceInfo:kt(),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)}).then(l=>{if(!l.ok){const p=new Error("HTTP "+l.status+" from log endpoint");throw p.statusCode=l.status,p}}).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 Pe{constructor(e,t,n,r,s){this._transport=new Y(e,t,n,r,s),this._errorUrl=pe(e?.errorUrl,e?.integrationDomain,yt)}report(e){if(!e)return;const t=e.severity||y.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class be{constructor(e,t,n,r,s,o){this._transport=new Y(e,n,r,s,o),this._placementDiagnosticTransport=new Y(e,n,r,s),this._loggingUrl=pe(e?.loggingUrl,e?.integrationDomain,It),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,y.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?y.ERROR:y.WARNING})}})}}function vt(i){const e=H(window.location.href),t=i.EventAttributes?.title||document.title,n=Ke(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const E=class E{constructor(){this.name=h,this.id=M,this.moduleId=M,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,this._launcherAttachState=Xe(),this.accountId=null,this._preselectState=qe()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(b(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)}}capturePageView(e){let t;try{t=H(window.location.href);const n=se(),r=vt(e);n.push(r);const s=Math.min(n.length,ne),o=Oe(n);if(o===0){const c=V()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=V()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=ze(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){Qe(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&N(window.Rokt.createLauncher)}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"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[E.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!f(e))return;const t=a().EventType.Other;a().logEvent(st,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&N(t.setIntegrationAttribute)&&t.setIntegrationAttribute(M,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(N(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){Ze(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await At([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(it(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return rt(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,et(this._launcherAttachState);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,Se(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}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)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}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,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=P(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=x(o.placementEventMapping);this.placementEventMappingLookup=_e(u);const l=x(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Ie(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:w,legacyRoktExtensions:T,loadThankYouElement:G}=Ee(o.roktExtensions),_={...a().Rokt?.launcherOptions||{}};this.integrationName=Pt(_.integrationName),_.integrationName=this.integrationName,this.domain=p;const L={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},A=new Pe(L,this.integrationName,window.__rokt_li_guid__,o.accountId),O=new be(L,A,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=A,this.loggingService=O,this.isTargetingDisabled())try{oe(),ce()}catch(m){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:y.INFO,stackTrace:m instanceof Error?m.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(A),a()._registerLoggingService&&a()._registerLoggingService(O),n?(this.testHelpers={generateLauncherScript:ge,generateThankYouElementScript:fe,extractRoktExtensionConfig:Ee,hashEventMessage:ye,parseSettingsString:x,generateMappedEventLookup:_e,generateMappedEventAttributeLookup:Ie,sendAdBlockMeasurementSignals:Se,createAutoRemovedIframe:X,djb2:ee,setAllowedOriginHashes:m=>{E._allowedOriginHashes=m},ReportingTransport:Y,ErrorReportingService:Pe,LoggingService:be,RateLimiter:Ae,ErrorCodes:Q,WSDKErrorSeverity:y,resetLauncherAttachState:()=>nt(this._launcherAttachState)},this.attachLauncher(c,_),"Successfully initialized: "+h):(G&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),me(ut,fe(p),{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,_,T):(me(lt,ge(p,w),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):console.error("Rokt object is not available after script load.")},onError:m=>{console.error("Error loading Rokt launcher script:",m)}}),this.captureTiming(E.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+h)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ht&&(Ue(this.loggingService),this.capturePageView(e),de(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===gt&&(oe(),ce(),this.accountId&&k(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+h;if(N(a().Rokt?.setLocalSessionAttribute)&&(b(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!b(this.placementEventMappingLookup))){const t=ye(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+h}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),$e(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+h}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+h}handleIdentityComplete(e,t){return this.userAttributes=P(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+h}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="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];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{n(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.accountId&&k(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,he))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,he))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...P(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=P(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},w=this.returnUserIdentities(c),T=this.returnLocalSessionAttributes(),G=Ne(se()),_=Ce(),L=this.readMpSessionId(),A=this.readMpDeviceId(),O={...w,...l,...p,...T,...G.length?{[ft]:JSON.stringify(G)}:{},..._?{[pt]:_}:{},...this.userIdentifiedInWorkspace?{[dt]:!0}:{},...L?{[mt]:L}:{},...A?{[Et]:A}:{},mpid:u},m=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),Lt={...e,attributes:O,...m!==void 0?{cacheMatchKeys:m}:{}},Re=this.launcher.selectPlacements(Lt),ke=e.preselect===!0,Ot=()=>{ke||this.logSelectPlacementsEvent(O)};return Promise.resolve(Re).then(Nt=>{if(!ke)return Nt?.context?.sessionId?.then(Ut=>this.setRoktSessionId(Ut))}).catch(()=>{}).finally(Ot),Re}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(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")))}terminate(){return this.isKitReady()?(tt(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};E._allowedOriginHashes=[-553112570,549508659],E.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},E.EMAIL_SHA256_KEY="emailsha256";let S=E;function wt(){return M}function Tt(i){if(!i){window.console.log("You must pass a config object to register the kit "+h);return}if(!f(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}f(i.kits)?i.kits[h]={constructor:S}:(i.kits={},i.kits[h]={constructor:S}),window.console.log("Successfully registered "+h+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:h,constructor:S,getId:wt}),j.register=Tt,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),j})({});
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": "3.3.3",
3
+ "version": "3.5.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "module": "dist/Rokt-Kit.esm.js",