"use strict";var mParticle=(function(){var fe={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",encode:function(t){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(t)))}catch(r){console.error("Error encoding cookie values into Base64:"+r)}return this._encode(t)},_encode:function(t){var r="",i,o,n,s,a,u,l,d=0;for(t=Ft.encode(t);d>2,a=(i&3)>4,u=(o&15)>6,l=n&63,isNaN(o)?u=l=64:isNaN(n)&&(l=64),r=r+fe._keyStr.charAt(s)+fe._keyStr.charAt(a)+fe._keyStr.charAt(u)+fe._keyStr.charAt(l);return r},decode:function(t){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(t)))}catch(r){}return fe._decode(t)},_decode:function(t){var r="",i,o,n,s,a,u,l,d=0;for(t=t.replace(/[^A-Za-z0-9\+\/\=]/g,"");d>4,o=(a&15)>2,n=(u&3)127&&o>6|192),r+=String.fromCharCode(o&63|128)):(r+=String.fromCharCode(o>>12|224),r+=String.fromCharCode(o>>6&63|128),r+=String.fromCharCode(o&63|128))}return r},decode:function(t){for(var r="",i=0,o=0,n=0,s=0;i191&&o>>0;if(typeof t!="function")throw new TypeError(t+" is not a function");for(arguments.length>1&&(i=r),o=0;o>>0;if(typeof t!="function")throw new TypeError(t+" is not a function");for(arguments.length>1&&(i=r),o=new Array(a),n=0;n>>0;if(typeof t!="function")throw new TypeError;for(var o=[],n=arguments.length>=2?arguments[1]:void 0,s=0;s0&&n[n.length-1])&&(l[0]===6||l[0]===2)){r=0;continue}if(l[0]===3&&(!n||l[1]>n[0]&&l[1]=0;for(var o=t.length;i>i/4).toString(16):(i^Math.random()*16>>i/4).toString(16)},ft=function e(t){return t===void 0&&(t=""),t?Fr():"".concat(1e7,"-").concat(1e3,"-").concat(4e3,"-").concat(8e3,"-").concat(1e11).replace(/[018]/g,e)},Nr=function(t){if(!t)return 100;var r=ge(t);return Math.abs(r%100)+1},x=function(t){var r=Object.prototype.toString.call(t);return r==="[object Object]"||r==="[object Error]"},se=function(t){if(isNaN(t)||!isFinite(t))return 0;var r=parseFloat(t);return isNaN(r)?0:r},Rr=function(t){try{return t?JSON.parse(t.replace(/"/g,'"')):[]}catch(r){throw new Error("Settings string contains invalid JSON")}},we=function(t){return vt(t)?t:null},Vr=function(t){return t.replace(/,/g,"|")},Hr=function(t){return t.replace(/\|/g,",")},Br=function(t){return t.replace(/\'/g,'"')},qr=function(t){return t.replace(/\"/g,"'")},Rt=function(t,r){return t.replace("%%mpid%%",r)},Vt=function(t){return t.replace(/&/g,"&")},Kr=function(t,r,i,o,n){var s=Vt(r),a=i?Vt(i):null,u=Rt(s,t),l=a?Rt(a,t):"",d=u+encodeURIComponent(l);if(o){var g=d.includes("?")?"&":"?";d+="".concat(g,"domain=").concat(o)}if(n){var g=d.includes("?")?"&":"?";d+="".concat(g,"google_hm=").concat(n)}return d},xr={"+":"-","/":"_","=":""},jr=function(t){return btoa(t).replace(/[+/=]/g,function(r){return xr[r]})},Wr=function(t){return t==="false"||t==="0"?!1:!!t},Qr=function(t){return decodeURIComponent(t.replace(/\+/g," "))},zr=function(t){return t.indexOf('"')===0&&(t=t.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\/g,"\\")),t},Ht=function(t){return typeof t=="string"},Te=function(t){return typeof t=="number"},Jr=function(t){return typeof t=="boolean"},ve=function(t){return typeof t=="function"},Gr=function(t){return t!==void 0&&!x(t)&&!Array.isArray(t)},Bt=function(t){return Te(t)||Ht(t)||Jr(t)},$r=function(t){return vt(t)?t.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"_"):""},Yr=function(t){return t===$r(t)},vt=function(t){return Ht(t)||Te(t)},F=function(t){return t==null||!(Object.keys(t)||t).length},Xr=function(t,r){return t.slice(0,r).concat(t.slice(r+1),t[r])},qt=function(t,r){r===void 0&&(r=[]);var i,o={},n={};if(!t)return o;if(typeof URL!="undefined"&&typeof URLSearchParams!="undefined"){var s=new URL(t);i=new URLSearchParams(s.search)}else i=Zr(t);return i.forEach(function(a,u){n[u.toLowerCase()]=a}),F(r)?n:(r.forEach(function(a){var u=n[a.toLowerCase()];u&&(o[a]=u)}),o)},Zr=function(t){var r={},i=t.split("?")[1]||"",o=i.split("&");return o.forEach(function(n){var s=n.split("="),a=s[0],u=s.slice(1),l=u.join("=");if(a&&l!==void 0)try{r[a]=decodeURIComponent(l||"")}catch(d){console.error("Failed to decode value for key ".concat(a,": ").concat(d))}}),{get:function(s){return r[s]},forEach:function(s){for(var a in r)r.hasOwnProperty(a)&&s(r[a],a)}}},ei=function(t){var r=function(){try{return typeof window=="undefined"?[]:window.document.cookie.split(";").map(function(s){return s.trim()})}catch(s){return console.error("Unable to parse cookies",s),[]}},i=function(s,a){for(var u={},l=0,d=s;l=L.ViewCart&&t=e.MINIMUM_INTERVAL_MILLIS,this.uploadIntervalMillis=s},e.prototype.shouldDebounceAndUpdateLastASTTime=function(){var t=Date.now();return t-this.lastASTEventTime0&&this.mpInstance.Logger.warning("Offline batch storage is over quota. Dropped "+"".concat(t," oldest batch(es)."))},e.prototype.uploadBatches=function(t,r){return $(this,void 0,void 0,function(){var i,o,n,s,a,u,l;return Y(this,function(d){switch(d.label){case 0:if(i=t.filter(function(g){return!F(g.events)}),F(i))return[2,null];this.mpInstance.Logger.isVerbose()&&(o=Qe(i,this.mpInstance._Store.SDKConfig.isDevelopmentMode),this.mpInstance.Logger.verbose("Uploading batches: ".concat(JSON.stringify(o))),this.mpInstance.Logger.verbose("Batch count: ".concat(i.length))),n=0,d.label=1;case 1:return n=200&&u.status=500||u.status===429)return this.mpInstance.Logger.error("HTTP error status ".concat(u.status," received")),[2,i.slice(n,i.length)];if(u.status>=401)return this.mpInstance.Logger.error("HTTP error status ".concat(u.status," while uploading - please verify your API key.")),[2,null];throw console.error("HTTP error status ".concat(u.status," while uploading events."),u),new Error("Uncaught HTTP Error ".concat(u.status,". Batch upload will be re-attempted."))}return[3,5];case 4:return l=d.sent(),this.mpInstance.Logger.error("Error sending event to mParticle servers. ".concat(l)),[2,i.slice(n,i.length)];case 5:return n++,[3,1];case 6:return[2,null]}})})},e.CONTENT_TYPE="text/plain;charset=UTF-8",e.MINIMUM_INTERVAL_MILLIS=500,e})(),Re={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",IDENTITY_MISMATCH:"IDENTITY_MISMATCH",MP_DEPRECATED_METHOD_USAGE:"MP_DEPRECATED_METHOD_USAGE"},Ve={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Oi=m.IdentityMethods.Modify,Pt={isNumber:Te,isFunction:ve,isStringOrNumber:vt,isValidAttributeValue:Gr,isValidKeyValue:function(t){return!!(t&&!x(t)&&!Array.isArray(t)&&!this.isFunction(t))},removeFalsyIdentityValues:function(t,r){if(!t||!t.userIdentities)return t;var i={},o=I({},t.userIdentities);for(var n in t.userIdentities)if(t.userIdentities.hasOwnProperty(n)){var s=t.userIdentities[n];s!==null&&!s&&(r.warning("Identity value for '".concat(n,"' is falsy (").concat(s,"). This value will be removed from the request.")),delete o[n])}return i.userIdentities=o,i},validateIdentities:function(t,r){var i={userIdentities:1,onUserAlias:1,copyUserAttributes:1};if(t){if(r===Oi&&(x(t.userIdentities)&&!Object.keys(t.userIdentities).length||!x(t.userIdentities)))return{valid:!1,error:m.Messages.ValidationMessages.ModifyIdentityRequestUserIdentitiesPresent};for(var o in t)if(t.hasOwnProperty(o)){if(!i[o])return{valid:!1,error:m.Messages.ValidationMessages.IdentityRequesetInvalidKey};if(o==="onUserAlias"&&!Pt.isFunction(t[o]))return{valid:!1,error:m.Messages.ValidationMessages.OnUserAliasType}}if(Object.keys(t).length===0)return{valid:!0};if(t.userIdentities===void 0)return{valid:!1,error:m.Messages.ValidationMessages.UserIdentities};if(t.userIdentities!==null&&!x(t.userIdentities))return{valid:!1,error:m.Messages.ValidationMessages.UserIdentities};if(x(t.userIdentities)&&Object.keys(t.userIdentities).length){for(var n in t.userIdentities)if(t.userIdentities.hasOwnProperty(n)){if(h.IdentityType.getIdentityType(n)===!1)return{valid:!1,error:m.Messages.ValidationMessages.UserIdentitiesInvalidKey};if(!(typeof t.userIdentities[n]=="string"||t.userIdentities[n]===null))return{valid:!1,error:m.Messages.ValidationMessages.UserIdentitiesInvalidValues}}}}return{valid:!0}}},bt=m.HTTPCodes,Fi=function(t,r,i,o,n,s,a,u){return $(void 0,void 0,void 0,function(){var l,d,g,p,v,y,S,C,w,b,T,U;return Y(this,function(M){switch(M.label){case 0:if(!ve(n))return s.error("search called without a callback function; skipping request."),[2];if(l=function(j){try{n(j)}catch(q){s.error("Error invoking search callback: "+le(q))}},d=Pt.removeFalsyIdentityValues({userIdentities:t!=null?t:{}},s).userIdentities,!Object.values(d!=null?d:{}).some(function(D){return typeof D=="string"&&D.length>0}))return s.verbose("Identity search called with empty identifiers; skipping request."),l({httpCode:bt.noHttpCoverage}),[2];if(!r)return s.verbose("search called without a workspace API key; skipping request."),l({httpCode:bt.noHttpCoverage}),[2];M.label=1;case 1:return M.trys.push([1,9,,10]),g=i(),p=I(I({},g),{known_identities:I({},d)}),v={method:"post",headers:{Accept:"application/json","Content-Type":"application/json","x-mp-key":r},body:JSON.stringify(p)},y=a||(window.fetch?new Ee(o):new Ie(o)),s.verbose("Sending search request to "+o),[4,y.upload(v,o)];case 2:if(S=M.sent(),C=void 0,!ve(S.json))return[3,7];M.label=3;case 3:return M.trys.push([3,5,,6]),[4,S.json()];case 4:return C=M.sent(),[3,6];case 5:return M.sent(),s.verbose("search response had no parseable JSON body."),[3,6];case 6:return[3,8];case 7:if(w=S,w!=null&&w.responseText)try{C=JSON.parse(w.responseText)}catch(D){s.verbose("search XHR response was not valid JSON.")}M.label=8;case 8:return S.status===We?s.verbose("search received 200 OK."):S.status===kr?s.verbose("search received 404 (no match)."):s.verbose("search received non-success status "+S.status),l({httpCode:S.status,body:C}),[3,10];case 9:return b=M.sent(),T=le(b),U="Error sending search request: "+T,s.error(U),u==null||u.report({message:U,code:Re.IDENTITY_REQUEST,severity:Ve.ERROR}),l({httpCode:bt.noHttpCoverage}),[3,10];case 10:return[2]}})})},ze=m.IdentityMethods,Ni=ze.Identify,Ri=ze.Modify,Vi=ze.Login,Hi=ze.Logout,Bi=m.HTTPCodes,qi=m.Messages,Jt="x-mp-max-age",Ki=function(t,r,i,o,n){if(!n){var s=Ji(o==null?void 0:o.cacheMaxAge);switch(t){case Vi:case Ni:xi(t,r,s,i,o);break;case Ri:case Hi:i.purge();break}}},xi=function(t,r,i,o,n){var s=n.responseText,a=n.status,u=o.retrieve()||{},l=wt(t,r),d=ge(l),g=s.mpid,p=s.is_logged_in,v={mpid:g,is_logged_in:p};u[d]={responseText:JSON.stringify(v),status:a,expireTimestamp:i},o.store(u)},wt=function(t,r){var i="device_application_stamp",o="".concat(t,":").concat(i,"=").concat(r.device_application_stamp,";"),n=Object.keys(r).length,s="";if(n){var a=new Array;for(var u in r)u!==i&&(a[h.IdentityType.getIdentityType(u)]=r[u]);s=a.reduce(function(l,d,g){var p=h.IdentityType.getIdentityName(g);return"".concat(l).concat(p,"=").concat(d,";")},o)}return s},ji=function(t,r,i){var o=i==null?void 0:i.retrieve();if(!o)return!1;var n=wt(t,r),s=ge(n);if(!o.hasOwnProperty(s))return!1;var a=o[s].expireTimestamp;return!(ae._Store.SDKConfig.integrationDelayTimeout)return!1;for(var n in r)if(r[n]===!0)return!0;return!1},this.createMainStorageName=function(r){return r?Zt.currentStorageName+"_"+r:Zt.currentStorageName},this.converted=zr,this.findKeyInObject=Or,this.parseNumber=se,this.inArray=Ue,this.isObject=x,this.decoded=Qr,this.parseStringOrNumber=we,this.generateHash=ge,this.generateUniqueId=ft,this.Validators=Pt}var He=m.Messages,er="mParticleAndroid",Tt="mParticle";function io(e){if(Object.prototype.hasOwnProperty.call(window,e))return window[e]}function oo(e,t){return e[t]}function no(e){var t=this;this.initializeSessionAttributes=function(r){var i=m.NativeSdkPaths.SetSessionAttribute,o=JSON.stringify({key:"$src_env",value:"webview"}),n=JSON.stringify({key:"$src_key",value:r});t.sendToNative(i,o),r&&t.sendToNative(i,n)},this.isBridgeV2Available=function(r){var i,o;if(!r)return!1;var n=er+"_"+r+"_v2",s=Tt+"_"+r+"_v2";return!!(!((o=(i=window.webkit)===null||i===void 0?void 0:i.messageHandlers)===null||o===void 0)&&o.hasOwnProperty(s)||window.mParticle&&window.mParticle.uiwebviewBridgeName&&window.mParticle.uiwebviewBridgeName===s||window.hasOwnProperty(n))},this.isWebviewEnabled=function(r,i){return e._Store.bridgeV2Available=t.isBridgeV2Available(r),e._Store.bridgeV1Available=t.isBridgeV1Available(),i===2?e._Store.bridgeV2Available:window.mParticle&&window.mParticle.uiwebviewBridgeName&&window.mParticle.uiwebviewBridgeName!==Tt+"_"+r+"_v2"?!1:inew Date(r).getTime()+t*uo:!0};function ae(e,t,r){t.warning(e.warningMessage),r==null||r.report({message:e.methodName,code:Re.MP_DEPRECATED_METHOD_USAGE,severity:Ve.WARNING})}var Be=m.Messages;function go(e){var t=this;this.initialize=function(){var o;if(e._Store.sessionId){var n=e._Store,s=n.dateLastEventSent,a=n.SDKConfig,u=a.sessionTimeout;if(r(s==null?void 0:s.getTime(),u))t.endSession(),t.startNewSession();else{var l=e.Identity.getCurrentUser(),d=a.identifyRequest,g=((o=e._CookieConsentManager)===null||o===void 0?void 0:o.getNoFunctional())&&!ke(e._Store);!g&&Yi(l,d)&&(e.Identity.identify(d,a.identityCallback),e._Store.identifyCalled=!0,e._Store.SDKConfig.identityCallback=null)}}else t.startNewSession()},this.getSession=function(){return ae({methodName:"SessionManager.getSession()",warningMessage:ye("SessionManager.getSession()",!1,"SessionManager.getSessionId()")},e.Logger,e._ErrorReportingDispatcher),this.getSessionId()},this.getSessionId=function(){return e._Store.sessionId},this.startNewSession=function(){var o;if(e.Logger.verbose(Be.InformationMessages.StartingNewSession),e._Helpers.canLog()){e._Store.sessionId=e._Helpers.generateUniqueId().toUpperCase();var n=e.Identity.getCurrentUser(),s=n?n.getMPID():null;if(s&&(e._Store.currentSessionMPIDs=[s]),!e._Store.sessionStartDate){var a=new Date;e._Store.sessionStartDate=a,e._Store.dateLastEventSent=a}t.setSessionTimer();var u=((o=e._CookieConsentManager)===null||o===void 0?void 0:o.getNoFunctional())&&!ke(e._Store);!e._Store.identifyCalled&&!u&&(e.Identity.identify(e._Store.SDKConfig.identifyRequest,e._Store.SDKConfig.identityCallback),e._Store.identifyCalled=!0,e._Store.SDKConfig.identityCallback=null),e._Events.logEvent({messageType:h.MessageType.SessionStart})}else e.Logger.verbose(Be.InformationMessages.AbandonStartSession)},this.endSession=function(o){var n,s,a,u;if(e.Logger.verbose(Be.InformationMessages.StartingEndSession),o){i();return}if(!e._Helpers.canLog()){e.Logger.verbose(Be.InformationMessages.AbandonEndSession),(n=e._timeOnSiteTimer)===null||n===void 0||n.resetTimer();return}var l=e._Persistence.getPersistence();if(!l||l.gs&&!l.gs.sid){e.Logger.verbose(Be.InformationMessages.NoSessionToEnd),(s=e._timeOnSiteTimer)===null||s===void 0||s.resetTimer();return}if(l.gs.sid&&e._Store.sessionId!==l.gs.sid&&(e._Store.sessionId=l.gs.sid),!((a=l==null?void 0:l.gs)===null||a===void 0)&&a.les){var d=e._Store.SDKConfig.sessionTimeout;r(l.gs.les,d)?i():(t.setSessionTimer(),(u=e._timeOnSiteTimer)===null||u===void 0||u.resetTimer())}},this.setSessionTimer=function(){var o=e._Store.SDKConfig.sessionTimeout*6e4;e._Store.globalTimer=window.setTimeout(function(){t.endSession()},o)},this.resetSessionTimer=function(){e._Store.webviewBridgeEnabled||(e._Store.sessionId||t.startNewSession(),t.clearSessionTimeout(),t.setSessionTimer()),t.startNewSessionIfNeeded()},this.clearSessionTimeout=function(){clearTimeout(e._Store.globalTimer)},this.startNewSessionIfNeeded=function(){if(!e._Store.webviewBridgeEnabled){var o=e._Persistence.getPersistence();!e._Store.sessionId&&o&&(o.sid?e._Store.sessionId=o.sid:t.startNewSession())}};function r(o,n){if(!o||!n||n=s}function i(){var o;e._Events.logEvent({messageType:h.MessageType.SessionEnd}),e._Store.nullifySession(),(o=e._timeOnSiteTimer)===null||o===void 0||o.resetTimer()}}var Ge=m.Messages;function fo(e){var t=this;this.convertTransactionAttributesToProductAction=function(r,i){r.hasOwnProperty("Id")&&(i.TransactionId=r.Id),r.hasOwnProperty("Affiliation")&&(i.Affiliation=r.Affiliation),r.hasOwnProperty("CouponCode")&&(i.CouponCode=r.CouponCode),r.hasOwnProperty("Revenue")&&(i.TotalAmount=this.sanitizeAmount(r.Revenue,"Revenue")),r.hasOwnProperty("Shipping")&&(i.ShippingAmount=this.sanitizeAmount(r.Shipping,"Shipping")),r.hasOwnProperty("Tax")&&(i.TaxAmount=this.sanitizeAmount(r.Tax,"Tax")),r.hasOwnProperty("Step")&&(i.CheckoutStep=r.Step),r.hasOwnProperty("Option")&&(i.CheckoutOptions=r.Option)},this.calculateProductActionTotalAmount=function(r){if(!r||r.TotalAmount!=null)return r;var i=0;return Array.isArray(r.ProductList)&&r.ProductList.forEach(function(o){i+=se(o.Quantity)*se(o.Price)}),i+=se(r.ShippingAmount)+se(r.TaxAmount),r.TotalAmount=i,r},this.getProductActionEventName=function(r){switch(r){case h.ProductActionType.AddToCart:return"AddToCart";case h.ProductActionType.AddToWishlist:return"AddToWishlist";case h.ProductActionType.Checkout:return"Checkout";case h.ProductActionType.CheckoutOption:return"CheckoutOption";case h.ProductActionType.Click:return"Click";case h.ProductActionType.Purchase:return"Purchase";case h.ProductActionType.Refund:return"Refund";case h.ProductActionType.RemoveFromCart:return"RemoveFromCart";case h.ProductActionType.RemoveFromWishlist:return"RemoveFromWishlist";case h.ProductActionType.ViewDetail:return"ViewDetail";case h.ProductActionType.ViewCart:return"ViewCart";case h.ProductActionType.AddShippingInfo:return"AddShippingInfo";case h.ProductActionType.AddPaymentInfo:return"AddPaymentInfo";case h.ProductActionType.PaymentMethodSelected:return"PaymentMethodSelected";case h.ProductActionType.PaymentAttempted:return"PaymentAttempted";case h.ProductActionType.PaymentSucceeded:return"PaymentSucceeded";case h.ProductActionType.PaymentFailed:return"PaymentFailed";case h.ProductActionType.RefundInitiated:return"RefundInitiated";case h.ProductActionType.Unknown:default:return"Unknown"}},this.getPromotionActionEventName=function(r){switch(r){case h.PromotionActionType.PromotionClick:return"PromotionClick";case h.PromotionActionType.PromotionView:return"PromotionView";default:return"Unknown"}},this.convertProductActionToEventType=function(r){switch(r){case h.ProductActionType.AddToCart:return h.CommerceEventType.ProductAddToCart;case h.ProductActionType.AddToWishlist:return h.CommerceEventType.ProductAddToWishlist;case h.ProductActionType.Checkout:return h.CommerceEventType.ProductCheckout;case h.ProductActionType.CheckoutOption:return h.CommerceEventType.ProductCheckoutOption;case h.ProductActionType.Click:return h.CommerceEventType.ProductClick;case h.ProductActionType.Purchase:return h.CommerceEventType.ProductPurchase;case h.ProductActionType.Refund:return h.CommerceEventType.ProductRefund;case h.ProductActionType.RemoveFromCart:return h.CommerceEventType.ProductRemoveFromCart;case h.ProductActionType.RemoveFromWishlist:return h.CommerceEventType.ProductRemoveFromWishlist;case h.ProductActionType.Unknown:return h.EventType.Unknown;case h.ProductActionType.ViewDetail:return h.CommerceEventType.ProductViewDetail;case h.ProductActionType.ViewCart:case h.ProductActionType.AddShippingInfo:case h.ProductActionType.AddPaymentInfo:case h.ProductActionType.PaymentMethodSelected:case h.ProductActionType.PaymentAttempted:case h.ProductActionType.PaymentSucceeded:case h.ProductActionType.PaymentFailed:case h.ProductActionType.RefundInitiated:return h.EventType.Unknown;default:return e.Logger.error("Could not convert product action type "+r+" to event type"),null}},this.convertPromotionActionToEventType=function(r){switch(r){case h.PromotionActionType.PromotionClick:return h.CommerceEventType.PromotionClick;case h.PromotionActionType.PromotionView:return h.CommerceEventType.PromotionView;default:return e.Logger.error("Could not convert promotion action type "+r+" to event type"),null}},this.generateExpandedEcommerceName=function(r,i){return"eCommerce - "+r+" - "+(i?"Total":"Item")},this.extractProductAttributes=function(r,i){i.CouponCode&&(r["Coupon Code"]=i.CouponCode),i.Brand&&(r.Brand=i.Brand),i.Category&&(r.Category=i.Category),i.Name&&(r.Name=i.Name),i.Sku&&(r.Id=i.Sku),i.Price&&(r["Item Price"]=i.Price),i.Quantity&&(r.Quantity=i.Quantity),i.Position&&(r.Position=i.Position),i.Variant&&(r.Variant=i.Variant),r["Total Product Amount"]=i.TotalAmount||0},this.extractTransactionId=function(r,i){i.TransactionId&&(r["Transaction Id"]=i.TransactionId)},this.extractActionAttributes=function(r,i){t.extractTransactionId(r,i),i.Affiliation&&(r.Affiliation=i.Affiliation),i.CouponCode&&(r["Coupon Code"]=i.CouponCode),i.TotalAmount&&(r["Total Amount"]=i.TotalAmount),i.ShippingAmount&&(r["Shipping Amount"]=i.ShippingAmount),i.TaxAmount&&(r["Tax Amount"]=i.TaxAmount),i.CheckoutOptions&&(r["Checkout Options"]=i.CheckoutOptions),i.CheckoutStep&&(r["Checkout Step"]=i.CheckoutStep)},this.extractPromotionAttributes=function(r,i){i.Id&&(r.Id=i.Id),i.Creative&&(r.Creative=i.Creative),i.Name&&(r.Name=i.Name),i.Position&&(r.Position=i.Position)},this.buildProductList=function(r,i){return i?Array.isArray(i)?i:[i]:r.ShoppingCart.ProductList},this.createProduct=function(r,i,o,n,s,a,u,l,d,g){if(g=e._Helpers.sanitizeAttributes(g,r),typeof r!="string")return e.Logger.error("Name is required when creating a product"),null;if(!e._Helpers.Validators.isStringOrNumber(i))return e.Logger.error("SKU is required when creating a product, and must be a string or a number"),null;if(e._Helpers.Validators.isStringOrNumber(o))o=e._Helpers.parseNumber(o);else return e.Logger.error("Price is required when creating a product, and must be a string or a number"),null;return l&&!e._Helpers.Validators.isNumber(l)&&(e.Logger.error("Position must be a number, it will be set to null."),l=null),e._Helpers.Validators.isStringOrNumber(n)?n=e._Helpers.parseNumber(n):n=1,{Name:r,Sku:i,Price:o,Quantity:n,Brand:u,Variant:s,Category:a,Position:l,CouponCode:d,TotalAmount:n*o,Attributes:g}},this.createPromotion=function(r,i,o,n){return e._Helpers.Validators.isStringOrNumber(r)?{Id:r,Creative:i,Name:o,Position:n}:(e.Logger.error(Ge.ErrorMessages.PromotionIdRequired),null)},this.createImpression=function(r,i){return typeof r!="string"?(e.Logger.error("Name is required when creating an impression."),null):i?{Name:r,Product:i}:(e.Logger.error("Product is required when creating an impression."),null)},this.createTransactionAttributes=function(r,i,o,n,s,a){return e._Helpers.Validators.isStringOrNumber(r)?{Id:r,Affiliation:i,CouponCode:o,Revenue:n,Shipping:s,Tax:a}:(e.Logger.error(Ge.ErrorMessages.TransactionIdRequired),null)},this.expandProductImpression=function(r){var i=[];return r.ProductImpressions&&r.ProductImpressions.forEach(function(o){o.ProductList&&o.ProductList.forEach(function(n){var s=ne(!1,{},r.EventAttributes);if(n.Attributes)for(var a in n.Attributes)s[a]=n.Attributes[a];t.extractProductAttributes(s,n),o.ProductImpressionList&&(s["Product Impression List"]=o.ProductImpressionList);var u=e._ServerModel.createEventObject({messageType:h.MessageType.PageEvent,name:t.generateExpandedEcommerceName("Impression"),data:s,eventType:h.EventType.Transaction});i.push(u)})}),i},this.expandCommerceEvent=function(r){return r?t.expandProductAction(r).concat(t.expandPromotionAction(r)).concat(t.expandProductImpression(r)):null},this.expandPromotionAction=function(r){var i=[];if(!r.PromotionAction)return i;var o=r.PromotionAction.PromotionList;return o.forEach(function(n){var s=ne(!1,{},r.EventAttributes);t.extractPromotionAttributes(s,n);var a=e._ServerModel.createEventObject({messageType:h.MessageType.PageEvent,name:t.generateExpandedEcommerceName(h.PromotionActionType.getExpansionName(r.PromotionAction.PromotionActionType)),data:s,eventType:h.EventType.Transaction});i.push(a)}),i},this.expandProductAction=function(r){var i=[];if(!r.ProductAction)return i;var o=!1;if(r.ProductAction.ProductActionType===h.ProductActionType.Purchase||r.ProductAction.ProductActionType===h.ProductActionType.Refund){var n=ne(!1,{},r.EventAttributes);n["Product Count"]=r.ProductAction.ProductList?r.ProductAction.ProductList.length:0,t.extractActionAttributes(n,r.ProductAction),r.CurrencyCode&&(n["Currency Code"]=r.CurrencyCode);var s=e._ServerModel.createEventObject({messageType:h.MessageType.PageEvent,name:t.generateExpandedEcommerceName(h.ProductActionType.getExpansionName(r.ProductAction.ProductActionType),!0),data:n,eventType:h.EventType.Transaction});i.push(s)}else o=!0;var a=r.ProductAction.ProductList;return a&&a.forEach(function(u){var l=ne(!1,r.EventAttributes,u.Attributes);o?t.extractActionAttributes(l,r.ProductAction):t.extractTransactionId(l,r.ProductAction),t.extractProductAttributes(l,u);var d=e._ServerModel.createEventObject({messageType:h.MessageType.PageEvent,name:t.generateExpandedEcommerceName(h.ProductActionType.getExpansionName(r.ProductAction.ProductActionType)),data:l,eventType:h.EventType.Transaction});i.push(d)}),i},this.createCommerceEventObject=function(r,i){var o,n=e._Helpers.extend;return e.Logger.verbose(Ge.InformationMessages.StartingLogCommerceEvent),e._Helpers.canLog()?(o=e._ServerModel.createEventObject({messageType:h.MessageType.Commerce,sourceMessageId:i==null?void 0:i.sourceMessageId}),o.EventName="eCommerce - ",o.CurrencyCode=e._Store.currencyCode,o.ShoppingCart=[],o.CustomFlags=n(o.CustomFlags,r),o):(e.Logger.verbose(Ge.InformationMessages.AbandonLogEvent),null)},this.sanitizeAmount=function(r,i){if(!e._Helpers.Validators.isStringOrNumber(r)){var o=[i,"must be of type number. A",G(r),"was passed. Converting to 0"].join(" ");return e.Logger.warning(o),0}return e._Helpers.parseNumber(r)}}var vo=(function(){function e(t,r){r===void 0&&(r=!1),this.noFunctional=r,this.isTrackerActive=!1,this.localStorageName="",this.startTime=0,this.totalTime=0,this.localStorageName="mprtcl-tos-".concat(t),this.timerVault=new _t(this.localStorageName),this.noFunctional||this.loadTimeFromStorage(),this.addHandlers(),document.hidden===!1&&this.startTracking()}return e.prototype.addHandlers=function(){var t=this;document.addEventListener("visibilitychange",function(){return t.handleVisibilityChange()}),window.addEventListener("blur",function(){return t.handleWindowBlur()}),window.addEventListener("focus",function(){return t.handleWindowFocus()}),window.addEventListener("storage",function(r){return t.syncAcrossTabs(r)}),window.addEventListener("beforeunload",function(){return t.updateTimeInPersistence()})},e.prototype.handleVisibilityChange=function(){document.hidden?this.stopTracking():this.startTracking()},e.prototype.handleWindowBlur=function(){this.isTrackerActive&&this.stopTracking()},e.prototype.handleWindowFocus=function(){this.isTrackerActive||this.startTracking()},e.prototype.syncAcrossTabs=function(t){if(t.key===this.localStorageName&&t.newValue!==null){var r=parseFloat(t.newValue)||0;this.totalTime=r}},e.prototype.updateTimeInPersistence=function(){this.isTrackerActive&&!this.noFunctional&&this.timerVault.store(Math.round(this.totalTime))},e.prototype.loadTimeFromStorage=function(){var t=this.timerVault.retrieve();Te(t)&&t!==null&&(this.totalTime=t)},e.prototype.startTracking=function(){document.hidden||(this.startTime=Math.floor(performance.now()),this.isTrackerActive=!0)},e.prototype.stopTracking=function(){this.isTrackerActive&&(this.setTotalTime(),this.updateTimeInPersistence(),this.isTrackerActive=!1)},e.prototype.setTotalTime=function(){if(this.isTrackerActive){var t=Math.floor(performance.now());this.totalTime+=t-this.startTime,this.startTime=t}},e.prototype.getTimeInForeground=function(){return this.setTotalTime(),this.updateTimeInPersistence(),this.totalTime},e.prototype.resetTimer=function(){this.totalTime=0,this.updateTimeInPersistence()},e})();function At(e){var t=e?I({},e):{},r=t.noDeviceId===!0||t.noDeviceID===!0;return r&&(t.noDeviceId=!0,t.noFunctional=!0,t.noTargeting=!0),t}function ho(e){var t={};for(var r in m.DefaultConfig)m.DefaultConfig.hasOwnProperty(r)&&(t[r]=m.DefaultConfig[r]);if(e)for(var r in e)e.hasOwnProperty(r)&&(t[r]=e[r]);for(var r in m.DefaultBaseUrls)t[r]=m.DefaultBaseUrls[r];return t.flags=t.flags||{},t}function tr(e,t,r){var i=this,o=t._Helpers.createMainStorageName,n=t._NativeSdkHelpers.isWebviewEnabled,s={isEnabled:!0,sessionAttributes:{},localSessionAttributes:{},currentSessionMPIDs:[],consentState:null,sessionId:null,isFirstRun:null,clientId:null,deviceId:null,devToken:null,serverSettings:{},dateLastEventSent:null,sessionStartDate:null,currentPosition:null,isTracking:!1,watchPositionId:null,cartProducts:[],eventQueue:[],currencyCode:null,globalTimer:null,context:null,configurationLoaded:!1,identityCallInFlight:!1,identityCallFailed:!1,identifyRequestCount:0,SDKConfig:{},nonCurrentUserMPIDs:{},identifyCalled:!1,isLoggedIn:!1,cookieSyncDates:{},integrationAttributes:{},requireDelay:!0,isLocalStorageAvailable:null,storageName:null,activeForwarders:[],kits:{},sideloadedKits:[],configuredForwarders:[],pixelConfigurations:[],wrapperSDKInfo:{name:"none",version:null,isInfoSet:!1},roktAccountId:null,integrationName:null,persistenceData:{gs:{}}};for(var a in s)this[a]=s[a];if(this.devToken=r||null,this.integrationDelayTimeoutStart=Date.now(),this.SDKConfig=ho(e),e){e.hasOwnProperty("flags")||(this.SDKConfig.flags={}),this.SDKConfig.flags=rr(e),e.deviceId&&(this.deviceId=e.deviceId),e.hasOwnProperty("isDevelopmentMode")?this.SDKConfig.isDevelopmentMode=Wr(e.isDevelopmentMode):this.SDKConfig.isDevelopmentMode=!1;var u=ir(e,this.SDKConfig.flags,r);for(var l in u)this.SDKConfig[l]=u[l];if(this.SDKConfig.useNativeSdk=!!e.useNativeSdk,this.SDKConfig.kits=e.kits||{},this.SDKConfig.sideloadedKits=e.sideloadedKits||[],e.hasOwnProperty("isIOS")?this.SDKConfig.isIOS=e.isIOS:this.SDKConfig.isIOS=window.mParticle&&window.mParticle.isIOS?window.mParticle.isIOS:!1,e.hasOwnProperty("useCookieStorage")?this.SDKConfig.useCookieStorage=e.useCookieStorage:this.SDKConfig.useCookieStorage=!1,e.hasOwnProperty("maxProducts")?this.SDKConfig.maxProducts=e.maxProducts:this.SDKConfig.maxProducts=m.DefaultConfig.maxProducts,e.hasOwnProperty("maxCookieSize")?this.SDKConfig.maxCookieSize=e.maxCookieSize:this.SDKConfig.maxCookieSize=m.DefaultConfig.maxCookieSize,e.hasOwnProperty("appName")&&(this.SDKConfig.appName=e.appName),e.hasOwnProperty("package")&&(this.SDKConfig.package=e.package),e.hasOwnProperty("integrationDelayTimeout")?this.SDKConfig.integrationDelayTimeout=e.integrationDelayTimeout:this.SDKConfig.integrationDelayTimeout=m.DefaultConfig.integrationDelayTimeout,e.hasOwnProperty("identifyRequest")&&(this.SDKConfig.identifyRequest=e.identifyRequest),e.hasOwnProperty("identityCallback")){var d=e.identityCallback;t._Helpers.Validators.isFunction(d)?this.SDKConfig.identityCallback=e.identityCallback:t.Logger.warning("The optional callback must be a function. You tried entering a(n) "+G(d)+" . Callback not set. Please set your callback again.")}if(e.hasOwnProperty("appVersion")&&(this.SDKConfig.appVersion=e.appVersion),e.hasOwnProperty("appName")&&(this.SDKConfig.appName=e.appName),e.hasOwnProperty("sessionTimeout")&&(this.SDKConfig.sessionTimeout=e.sessionTimeout),e.hasOwnProperty("dataPlan")){this.SDKConfig.dataPlan={PlanVersion:null,PlanId:null};var g=e.dataPlan;g.planId&&(Yr(g.planId)?this.SDKConfig.dataPlan.PlanId=g.planId:t.Logger.error("Your data plan id must be a string and match the data plan slug format (i.e. under_case_slug)")),g.planVersion&&(Te(g.planVersion)?this.SDKConfig.dataPlan.PlanVersion=g.planVersion:t.Logger.error("Your data plan version must be a number"))}else this.SDKConfig.dataPlan={};if(e.hasOwnProperty("forceHttps")?this.SDKConfig.forceHttps=e.forceHttps:this.SDKConfig.forceHttps=!0,this.SDKConfig.customFlags=e.customFlags||{},e.hasOwnProperty("minWebviewBridgeVersion")?this.SDKConfig.minWebviewBridgeVersion=e.minWebviewBridgeVersion:this.SDKConfig.minWebviewBridgeVersion=1,e.hasOwnProperty("aliasMaxWindow")?this.SDKConfig.aliasMaxWindow=e.aliasMaxWindow:this.SDKConfig.aliasMaxWindow=m.DefaultConfig.aliasMaxWindow,e.hasOwnProperty("dataPlanOptions")){var p=e.dataPlanOptions;(!p.hasOwnProperty("dataPlanVersion")||!p.hasOwnProperty("blockUserAttributes")||!p.hasOwnProperty("blockEventAttributes")||!p.hasOwnProperty("blockEvents")||!p.hasOwnProperty("blockUserIdentities"))&&t.Logger.error('Ensure your config.dataPlanOptions object has the following keys: a "dataPlanVersion" object, and "blockUserAttributes", "blockEventAttributes", "blockEvents", "blockUserIdentities" booleans')}e.hasOwnProperty("onCreateBatch")&&(typeof e.onCreateBatch=="function"?this.SDKConfig.onCreateBatch=e.onCreateBatch:(t.Logger.error("config.onCreateBatch must be a function"),this.SDKConfig.onCreateBatch=void 0))}this._getFromPersistence=function(v,y){return v?(i.syncPersistenceData(),i.persistenceData&&i.persistenceData[v]&&i.persistenceData[v][y]?i.persistenceData[v][y]:null):null},this._setPersistence=function(v,y,S){var C;v&&(i.syncPersistenceData(),i.persistenceData&&(i.persistenceData[v]?i.persistenceData[v][y]=S:i.persistenceData[v]=(C={},C[y]=S,C),x(i.persistenceData[v][y])&&F(i.persistenceData[v][y])&&delete i.persistenceData[v][y],t._Persistence.savePersistence(i.persistenceData)))},this.hasInvalidIdentifyRequest=function(){var v=i.SDKConfig.identifyRequest;return x(v)&&x(v.userIdentities)&&F(v.userIdentities)||!v},this.getConsentState=function(v){var y=t._Consent.ConsentSerialization.fromMinifiedJsonObject,S=i._getFromPersistence(v,"con");return F(S)?null:y(S)},this.setConsentState=function(v,y){var S=t._Consent.ConsentSerialization.toMinifiedJsonObject;(y||y===null)&&i._setPersistence(v,"con",S(y))},this.getDeviceId=function(){return i.deviceId},this.setDeviceId=function(v){i.deviceId=v,i.persistenceData.gs.das=v,t._Persistence.update()},this.getFirstSeenTime=function(v){return i._getFromPersistence(v,"fst")},this.setFirstSeenTime=function(v,y){if(v){var S=y||new Date().getTime();i._setPersistence(v,"fst",S)}},this.getLastSeenTime=function(v){if(!v)return null;var y=t.Identity.getCurrentUser();return v===(y==null?void 0:y.getMPID())?new Date().getTime():i._getFromPersistence(v,"lst")},this.setLastSeenTime=function(v,y){if(v){var S=y||new Date().getTime();i._setPersistence(v,"lst",S)}},this.getLocalSessionAttributes=function(){return i.localSessionAttributes||{}},this.setLocalSessionAttribute=function(v,y){var S;i.localSessionAttributes[v]=y,i.persistenceData.gs.lsa=I(I({},i.persistenceData.gs.lsa||{}),(S={},S[v]=y,S)),t._Persistence.savePersistence(i.persistenceData)},this.syncPersistenceData=function(){var v=t._Persistence.getPersistence();i.persistenceData=ne({},i.persistenceData,v)},this.getUserAttributes=function(v){return i._getFromPersistence(v,"ua")||{}},this.setUserAttributes=function(v,y){return i._setPersistence(v,"ua",y)},this.getUserIdentities=function(v){return i._getFromPersistence(v,"ui")||{}},this.setUserIdentities=function(v,y){i._setPersistence(v,"ui",y)},this.getRoktAccountId=function(){return i.roktAccountId},this.setRoktAccountId=function(v){i.roktAccountId=v},this.getIntegrationName=function(){return i.integrationName},this.setIntegrationName=function(v){i.integrationName=v},this.getTimeOnSite=function(){var v;return(v=t._timeOnSiteTimer)===null||v===void 0?void 0:v.getTimeInForeground()},this.getTotalTimeOnSite=function(){return i.sessionStartDate?Date.now()-i.sessionStartDate.getTime():void 0},this.addMpidToSessionHistory=function(v,y){var S=i.currentSessionMPIDs.indexOf(v);if(v&&y!==v&&S=0&&(i.currentSessionMPIDs=Xr(i.currentSessionMPIDs,S))},this.nullifySession=function(){i.sessionId=null,i.dateLastEventSent=null,i.sessionStartDate=null,i.sessionAttributes={},i.localSessionAttributes={},t._Persistence.update()},this.processConfig=function(v){var y=v.workspaceToken,S=v.requiredWebviewBridgeName;v.flags&&(i.SDKConfig.flags=rr(v));var C=ir(v,i.SDKConfig.flags,r);for(var w in C)i.SDKConfig[w]=C[w];if(y){i.SDKConfig.workspaceToken=y;var b=At(v==null?void 0:v.launcherOptions).noFunctional;t._timeOnSiteTimer=new vo(y,b)}else t.Logger.warning("You should have a workspaceToken on your config object for security purposes.");i.storageName=o(y),i.SDKConfig.requiredWebviewBridgeName=S||y,i.webviewBridgeEnabled=n(i.SDKConfig.requiredWebviewBridgeName,i.SDKConfig.minWebviewBridgeVersion),i.configurationLoaded=!0}}function rr(e){var t={},r=m.FeatureFlags,i=r.ReportBatching,o=r.EventBatchingIntervalMillis,n=r.OfflineStorage,s=r.DirectUrlRouting,a=r.CacheIdentity,u=r.AudienceAPI,l=r.CaptureIntegrationSpecificIds,d=r.CaptureIntegrationSpecificIdsV2,g=r.AstBackgroundEvents,p=r.AutoLogPageView;return e.flags?(t[i]=e.flags[i]||!1,t[o]=se(e.flags[o])||m.DefaultConfig.uploadInterval,t[n]=e.flags[n]||"0",t[s]=e.flags[s]==="True",t[a]=e.flags[a]==="True",t[u]=e.flags[u]==="True",t[l]=e.flags[l]==="True",t[d]=e.flags[d]||"none",t[g]=e.flags[g]==="True",t[p]=e.flags[p]==="True",t):{}}function ir(e,t,r){return r?F(e.domain)&&t.directURLRouting?po(e,r):or(e):{}}function or(e){var t=m.DefaultBaseUrls,r=m.CNAMEUrlPaths,i={};if(!F(e.domain)){for(var o in r)i[o]="".concat(e.domain).concat(r[o]);return i}for(var n in t)i[n]=e[n]||t[n];return i}function po(e,t){var r=m.DefaultBaseUrls,i={},o="us1",n=t.split("-"),s=n.lengthf}function v(c,f,_,A){var k;for(var O in c)c.hasOwnProperty(O)&&(k=b(c,f,_),p(k,A)&&(Ke[O]||O===c.cu||delete c[O]));return k}function y(c){var f={};for(var _ in c)c.hasOwnProperty(_)&&(Ke[_]||_===c.cu||(f[_]=1));return f}function S(c,f,_,A,k,O){var K;for(var Q in f)K=b(c,A,k),p(K,O)&&f.hasOwnProperty(Q)&&_.indexOf(Q)===-1&&delete c[Q];return K}function C(c,f,_){if(c[f]){e.Logger.verbose("Size of new encoded cookie is larger than maxCookieSize setting of "+_+". Removing from cookie the earliest logged in MPID containing: "+JSON.stringify(c[f],null,2)),delete c[f];return}e.Logger.error("Unable to save MPID data to cookies because the resulting encoded cookie is larger than the maxCookieSize setting of "+_+". We recommend using a maxCookieSize of 1500.")}function w(c,f,_,A,k){for(var O,K=0;K0:e._Helpers.isObject(c)?Object.keys(c).length>0:!1}function j(c,f){if(!c[f]||!D(c[f])){delete c[f];return}c[f]=$e.encode(JSON.stringify(c[f]))}function q(c){for(var f in c)if(c.hasOwnProperty(f)){if(Ye[f]){j(c,f);continue}if(f==="ie"){c[f]=c[f]?1:0;continue}c[f]||delete c[f]}}function W(c,f){var _=c[f];if(e._Helpers.isObject(_)&&Object.keys(_).length){c[f]=$e.encode(JSON.stringify(_));return}delete c[f]}function Z(c){for(var f in c)c.hasOwnProperty(f)&&Ye[f]&&W(c,f)}function ee(c){for(var f in c)c.hasOwnProperty(f)&&(Ke[f]||Z(c[f]))}this.encodePersistence=function(c){var f=JSON.parse(c);return q(f.gs),ee(f),Lr(JSON.stringify(f))};function ue(c){for(var f in c)if(c.hasOwnProperty(f)){if(Ye[f]){c[f]=JSON.parse($e.decode(c[f]));continue}f==="ie"&&(c[f]=!!c[f])}}function de(c){for(var f in c)c.hasOwnProperty(f)&&Ye[f]&&c[f].length&&(c[f]=JSON.parse($e.decode(c[f])))}function J(c){for(var f in c)if(c.hasOwnProperty(f)){if(!Ke[f]){de(c[f]);continue}f==="l"&&(c[f]=!!c[f])}}this.decodePersistence=function(c){try{if(!c)return;var f=JSON.parse(Dr(c));return e._Helpers.isObject(f)&&Object.keys(f).length&&(ue(f.gs),J(f)),JSON.stringify(f)}catch(_){e.Logger.error("Problem with decoding cookie")}},this.getCookieDomain=function(){if(e._Store.SDKConfig.cookieDomain)return e._Store.SDKConfig.cookieDomain;var c=t.getDomain(document,location.hostname);return c===""?"":"."+c},this.getDomain=function(c,f){var _,A,k="mptest=cookie",O=f.split(".");for(_=O.length-1;_>=0;_--)if(A=O.slice(_).join("."),c.cookie=k+";domain=."+A+";",c.cookie.indexOf(k)>-1)return c.cookie=k.split("=")[0]+"=;domain=."+A+";expires=Thu, 01 Jan 1970 00:00:01 GMT;",A;return""},this.saveUserCookieSyncDatesToPersistence=function(c,f){if(f){var _=t.getPersistence();_&&(_[c]?_[c].csd=f:_[c]={csd:f}),t.savePersistence(_)}},this.swapCurrentUser=function(c,f,_){if(c&&f&&c!==f){var A=t.getPersistence();A&&(A.cu=f,A.gs.csm=_,t.savePersistence(A))}},this.savePersistence=function(c){var f;if(!(!((f=e._CookieConsentManager)===null||f===void 0)&&f.getNoFunctional())){var _=t.encodePersistence(JSON.stringify(c)),A=new Date,k=e._Store.storageName,O=new Date(A.getTime()+e._Store.SDKConfig.cookieExpiration*24*60*60*1e3).toUTCString(),K=t.getCookieDomain(),Q;if(K===""?Q="":Q=";domain="+K,e._Store.SDKConfig.useCookieStorage){var pe=t.reduceAndEncodePersistence(c,O,Q,e._Store.SDKConfig.maxCookieSize);window.document.cookie=encodeURIComponent(k)+"="+pe}else if(e._Store.isLocalStorageAvailable)try{localStorage.setItem(e._Store.storageName,_)}catch(Oe){e.Logger.error("Error saving persistence to localStorage.")}}},this.getPersistence=function(){var c=this.useLocalStorage()?this.getLocalStorage():this.getCookie();return c},this.getFirstSeenTime=function(c){if(!c)return null;var f=t.getPersistence();return f&&f[c]&&f[c].fst?f[c].fst:null},this.setFirstSeenTime=function(c,f){if(c){f||(f=new Date().getTime());var _=t.getPersistence();_&&(_[c]||(_[c]={}),_[c].fst||(_[c].fst=f,t.savePersistence(_)))}},this.getLastSeenTime=function(c){if(!c)return null;if(c===e.Identity.getCurrentUser().getMPID())return new Date().getTime();var f=t.getPersistence();return f&&f[c]&&f[c].lst?f[c].lst:null},this.setLastSeenTime=function(c,f){if(c){f||(f=new Date().getTime());var _=t.getPersistence();_&&_[c]&&(_[c].lst=f,t.savePersistence(_))}},this.getDeviceId=function(){return e._Store.deviceId},this.setDeviceId=function(c){e._Store.deviceId=c,t.update()},this.resetPersistence=function(){localStorage.clear(),t.expireCookies(Xe.cookieName),t.expireCookies(Xe.cookieNameV2),t.expireCookies(Xe.cookieNameV3),t.expireCookies(Xe.cookieNameV4),t.expireCookies(e._Store.storageName);var c=sr();if(c!=null&&c._isTestEnv){var f="abcdef";localStorage.removeItem(e._Helpers.createMainStorageName(f)),t.expireCookies(e._Helpers.createMainStorageName(f))}},this.forwardingStatsBatches={uploadsTable:{},forwardingStatsEventQueue:[]}}var Et=["pushState","replaceState"],ar="__mpApvWrapped__",xe="__mpApv__",ur=["utm_source","utm_medium","utm_campaign","utm_term","utm_content","utm_id","gclid","gbraid","wbraid","fbclid","msclkid","ttclid","twclid","li_fat_id","dclid","client_id","redirect_uri","response_type","scope","state","code","nonce","page","limit","offset","cursor","per_page","q","search","ref","referrer"],lr=function(t){return qt(t,ur)},dr=function(t){return ur.filter(function(r){return r in t})},cr=function(t){var r=dr(t.params).map(function(i){return"".concat(i,"=").concat(encodeURIComponent(t.params[i]))}).join("&");return r?"".concat(t.path,"?").concat(r):t.path},mo=function(t,r){return r!==t},_o=function(t){return!!t&&t.history!==void 0&&typeof t.history.pushState=="function"&&typeof t.addEventListener=="function"},Co=function(t){var r=t.params,i=t.hostname,o=t.title,n=t.path;return{messageType:me.PageView,name:"PageView",data:I(I({},r),{hostname:i,title:o,path:n}),eventType:z.Unknown}},Ze=function(){return typeof window=="undefined"?null:window},gr=function(){return{initialPageViewFired:!1}},It=function(){var t=Ze();return t?t[xe]:void 0},fr=function(){var t=Ze();return t?(t[xe]||(t[xe]=gr()),t[xe]):null},vr=function(){var t=It();return t?t.tracker:void 0},Po=function(){var t=It();return!!(t&&t.initialPageViewFired)},bo=function(){var t=fr();t&&(t.initialPageViewFired=!0)},wo=function(){var t=Ze();if(t){var r=vr();r&&r.teardown(),t[xe]=gr()}},To=function(t){var r=fr();r&&(r.tracker=t)},Ao=function(t){var r=It();r&&r.tracker===t&&(r.tracker=void 0)},hr=function(){return{path:window.location.pathname,params:lr(Se())}},Me=function(t){if(!t)return"";var r=dr(t.params);return r.length?"".concat(t.path," (params: ").concat(r.join(),")"):t.path},Eo=function(t,r){if(window.history.pushState[ar])return r("[patch] history already wrapped, skipping to avoid double-wrap \u2014 STACKED WRAPPER DETECTED"),null;var i={},o={};Et.forEach(function(s){var a=window.history[s];i[s]=a;var u=function(){for(var d=[],g=0;g _Events.logEvent(PageView) (page: ".concat(Me(t),", title: ").concat(r,")")),this.mpInstance._Events.logEvent(i)},e.prototype.log=function(t){this.mpInstance.Logger.verbose("mParticle APV: ".concat(t))},e})(),Le=m.Messages;function ko(e){var t=this;this.logEvent=function(r,i){if(e.Logger.verbose(Le.InformationMessages.StartingLogEvent+": "+r.name),e._Helpers.canLog()){var o=e._ServerModel.createEventObject(r);e._APIClient.sendEventToServer(o,i)}else e.Logger.verbose(Le.InformationMessages.AbandonLogEvent)},this.startTracking=function(r){if(!e._Store.isTracking)"geolocation"in navigator&&(e._Store.watchPositionId=navigator.geolocation.watchPosition(o,n));else{var i={coords:{latitude:e._Store.currentPosition.lat,longitude:e._Store.currentPosition.lng}};s(r,i)}function o(a){e._Store.currentPosition={lat:a.coords.latitude,lng:a.coords.longitude},s(r,a),r=null,e._Store.isTracking=!0}function n(){s(r),r=null,e._Store.isTracking=!1}function s(a,u){if(a)try{u?a(u):a()}catch(l){e.Logger.error("Error invoking the callback passed to startTrackingLocation."),e.Logger.error(l)}}},this.stopTracking=function(){e._Store.isTracking&&(navigator.geolocation.clearWatch(e._Store.watchPositionId),e._Store.currentPosition=null,e._Store.isTracking=!1)},this.logOptOut=function(){e.Logger.verbose(Le.InformationMessages.StartingLogOptOut);var r=e._ServerModel.createEventObject({messageType:h.MessageType.OptOut,eventType:h.EventType.Other});e._APIClient.sendEventToServer(r)},this.logAST=function(){t.logEvent({messageType:h.MessageType.AppStateTransition})},this.logPageView=function(){t.logEvent({messageType:h.MessageType.PageView,name:"PageView",data:I(I({},lr(Se())),{hostname:window.location.hostname,title:window.document.title}),eventType:h.EventType.Unknown})},this.logCheckoutEvent=function(r,i,o,n){var s=e._Ecommerce.createCommerceEventObject(n);s&&(s.EventName+=e._Ecommerce.getProductActionEventName(h.ProductActionType.Checkout),s.EventCategory=h.CommerceEventType.ProductCheckout,s.ProductAction={ProductActionType:h.ProductActionType.Checkout,CheckoutStep:r,CheckoutOptions:i,ProductList:[]},t.logCommerceEvent(s,o))},this.logProductActionEvent=function(r,i,o,n,s,a){var u=e._Ecommerce.createCommerceEventObject(n,a),l=Array.isArray(i)?i:[i];l.forEach(function(d){d.TotalAmount&&(d.TotalAmount=e._Ecommerce.sanitizeAmount(d.TotalAmount,"TotalAmount")),d.Position&&(d.Position=e._Ecommerce.sanitizeAmount(d.Position,"Position")),d.Price&&(d.Price=e._Ecommerce.sanitizeAmount(d.Price,"Price")),d.Quantity&&(d.Quantity=e._Ecommerce.sanitizeAmount(d.Quantity,"Quantity"))}),u&&(u.EventCategory=e._Ecommerce.convertProductActionToEventType(r),u.EventName+=e._Ecommerce.getProductActionEventName(r),u.ProductAction={ProductActionType:r,ProductList:l},h.ProductActionType.isRoktCommerceType(r)&&(u.CustomFlags=u.CustomFlags||{},u.CustomFlags["Rokt.CommerceEventType"]=h.ProductActionType.getExpansionName(r)),e._Helpers.isObject(s)&&e._Ecommerce.convertTransactionAttributesToProductAction(s,u.ProductAction),t.logCommerceEvent(u,o,a))},this.logPurchaseEvent=function(r,i,o,n){var s=e._Ecommerce.createCommerceEventObject(n);s&&(s.EventName+=e._Ecommerce.getProductActionEventName(h.ProductActionType.Purchase),s.EventCategory=h.CommerceEventType.ProductPurchase,s.ProductAction={ProductActionType:h.ProductActionType.Purchase},s.ProductAction.ProductList=e._Ecommerce.buildProductList(s,i),e._Ecommerce.convertTransactionAttributesToProductAction(r,s.ProductAction),t.logCommerceEvent(s,o))},this.logRefundEvent=function(r,i,o,n){if(!r){e.Logger.error(Le.ErrorMessages.TransactionRequired);return}var s=e._Ecommerce.createCommerceEventObject(n);s&&(s.EventName+=e._Ecommerce.getProductActionEventName(h.ProductActionType.Refund),s.EventCategory=h.CommerceEventType.ProductRefund,s.ProductAction={ProductActionType:h.ProductActionType.Refund},s.ProductAction.ProductList=e._Ecommerce.buildProductList(s,i),e._Ecommerce.convertTransactionAttributesToProductAction(r,s.ProductAction),t.logCommerceEvent(s,o))},this.logPromotionEvent=function(r,i,o,n,s){var a=e._Ecommerce.createCommerceEventObject(n);a&&(a.EventName+=e._Ecommerce.getPromotionActionEventName(r),a.EventCategory=e._Ecommerce.convertPromotionActionToEventType(r),a.PromotionAction={PromotionActionType:r,PromotionList:Array.isArray(i)?i:[i]},t.logCommerceEvent(a,o,s))},this.logImpressionEvent=function(r,i,o,n){var s=e._Ecommerce.createCommerceEventObject(o);s&&(s.EventName+="Impression",s.EventCategory=h.CommerceEventType.ProductImpression,Array.isArray(r)||(r=[r]),s.ProductImpressions=[],r.forEach(function(a){s.ProductImpressions.push({ProductImpressionList:a.Name,ProductList:Array.isArray(a.Product)?a.Product:[a.Product]})}),t.logCommerceEvent(s,i,n))},this.logCommerceEvent=function(r,i,o){if(e.Logger.verbose(Le.InformationMessages.StartingLogCommerceEvent),r.ProductAction&&r.EventCategory===null){e.Logger.error("Commerce event not sent. The mParticle.ProductActionType you passed was invalid. Re-check your code.");return}var n=e._Helpers.sanitizeAttributes(i,r.EventName);e._Helpers.canLog()?(e._Store.webviewBridgeEnabled&&(r.ShoppingCart={}),n&&(r.EventAttributes=n),r.ProductAction&&e._Ecommerce.calculateProductActionTotalAmount(r.ProductAction),e._APIClient.sendEventToServer(r,o),e._Persistence.update()):e.Logger.verbose(Le.InformationMessages.AbandonLogEvent)},this.addEventHandler=function(r,i,o,n,s){var a=[],u=function(p){var v=function(){l.href?window.location.href=l.href:l.submit&&l.submit()};e.Logger.verbose("DOM event triggered, handling event"),t.logEvent({messageType:h.MessageType.PageEvent,name:typeof o=="function"?o(l):o,data:typeof n=="function"?n(l):n,eventType:s||h.EventType.Other}),(l.href&&l.target!=="_blank"||l.submit)&&(p.preventDefault?p.preventDefault():p.returnValue=!1,setTimeout(v,e._Store.SDKConfig.timeout))},l,d;if(!i){e.Logger.error("Can't bind event, selector is required");return}if(typeof i=="string"?a=document.querySelectorAll(i):i.nodeType&&(a=[i]),a.length)for(e.Logger.verbose("Found "+a.length+" element"+(a.length>1?"s":"")+", attaching event handlers"),d=0;d0,l=u?Wo(a,n):!1;return n.includeOnMatch===l}catch(d){return!0}},this.isEnabledForUnknownUser=function(n,s){return!((!s||!s.isLoggedIn())&&n)},this.applyToForwarders=function(n,s){e._Store.activeForwarders.length&&e._Store.activeForwarders.forEach(function(a){var u=a[n];if(u)try{var l=a[n](s);l&&e.Logger.verbose(l)}catch(d){e.Logger.verbose(d)}})},this.sendEventToForwarders=function(n){if(!(e._Store.webviewBridgeEnabled||!e._Store.activeForwarders)){var s=H.hashEventName(n.EventName,n.EventCategory),a=H.hashEventType(n.EventCategory),u=function(d){if(!No(n.EventDataType,n.EventAttributes,d)){var g=ne(!0,{},n);if(!Ro(n.EventDataType,s,a,d)&&(g.EventAttributes=Vo(n.EventDataType,n.EventCategory,n.EventName,g.EventAttributes,d),g.UserIdentities=Ho(g.UserIdentities,d.userIdentityFilters),g.UserAttributes=H.filterUserAttributes(g.UserAttributes,d.userAttributeFilters),!!d.process)){e.Logger.verbose("Sending message to forwarder: "+d.name);var p=d.process(g);p&&e.Logger.verbose(p)}}};e._Store.activeForwarders.forEach(function(l){u(l)})}},this.handleForwarderUserAttributes=function(n,s,a){t&&t.isAttributeKeyBlocked(s)||!e._Store.activeForwarders.length||e._Store.activeForwarders.forEach(function(u){var l=u[n];if(!(!l||H.isFilteredUserAttribute(s,u.userAttributeFilters)))try{var d=void 0;n===o.setUserAttribute?d=u.setUserAttribute(s,a):n===o.removeUserAttribute&&(d=u.removeUserAttribute(s)),d&&e.Logger.verbose(d)}catch(g){e.Logger.error(g)}})},this.setForwarderUserIdentities=function(n){e._Store.activeForwarders.forEach(function(s){var a=e._Helpers.filterUserIdentities(n,s.userIdentityFilters);s.setUserIdentity&&a.forEach(function(u){var l=s.setUserIdentity(u.Identity,u.Type);l&&e.Logger.verbose(l)})})},this.setForwarderOnUserIdentified=function(n){e._Store.activeForwarders.forEach(function(s){var a=kt(n.getMPID(),s,e,t);if(s.onUserIdentified){var u=s.onUserIdentified(a);u&&e.Logger.verbose(u)}})},this.setForwarderOnIdentityComplete=function(n,s){var a=jo[s];a&&e._Store.activeForwarders.forEach(function(u){var l=u[a];if(l){var d=kt(n.getMPID(),u,e,t),g=l.call(u,d,d.getUserIdentities());g&&e.Logger.verbose(g)}})},this.getForwarderStatsQueue=function(){return e._Persistence.forwardingStatsBatches.forwardingStatsEventQueue},this.setForwarderStatsQueue=function(n){e._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=n},this.processForwarders=function(n,s){n?(this.processUIEnabledKits(n),this.processSideloadedKits(n),i.initForwarders(e._Store.SDKConfig.identifyRequest.userIdentities,s)):e.Logger.warning("No config was passed. Cannot process forwarders")},this.processUIEnabledKits=function(n){var s=this.returnKitConstructors();try{Array.isArray(n.kitConfigs)&&n.kitConfigs.length&&n.kitConfigs.forEach(function(a){i.configureUIEnabledKit(a,s)})}catch(a){e.Logger.error("MP Kits not configured propertly. Kits may not be initialized. "+a)}},this.returnKitConstructors=function(){var n={};return F(e._Store.SDKConfig.kits)?F(e._preInit.forwarderConstructors)||e._preInit.forwarderConstructors.forEach(function(s){if(s.suffix){var a="".concat(s.name,"-").concat(s.suffix);n[a]=s}else n[s.name]=s}):n=e._Store.SDKConfig.kits,n},this.configureUIEnabledKit=function(n,s){var a=null,u=n;for(var l in s){var d=void 0;if(u.suffix&&(d="".concat(u.name,"-").concat(u.suffix)),(l===d||l===u.name)&&(u.isDebug===e._Store.SDKConfig.isDevelopmentMode||u.isSandbox===e._Store.SDKConfig.isDevelopmentMode)){a=this.returnConfiguredKit(s[l],u),e._Store.configuredForwarders.push(a);break}}},this.processSideloadedKits=function(n){try{if(Array.isArray(n.sideloadedKits)){var s={kits:{}},a=n.sideloadedKits;a.forEach(function(g){try{g.kitInstance.register(s);var p=g.kitInstance.name;s.kits[p].filters=g.filterDictionary}catch(v){console.error("Error registering sideloaded kit "+g.kitInstance.name)}});for(var u in s.kits){var l=s.kits[u];i.configureSideloadedKit(l)}if(!F(s.kits)){var d=Object.keys(s.kits);e._Store.sideloadedKitsCount=d.length}}}catch(g){e.Logger.error("Sideloaded Kits not configured propertly. Kits may not be initialized. "+g)}},this.configureSideloadedKit=function(n){e._Store.configuredForwarders.push(this.returnConfiguredKit(n,n.filters))},this.returnConfiguredKit=function(n,s){s===void 0&&(s={});var a=new n.constructor;return a.id=s.moduleId,a.isSandbox=s.isDebug||s.isSandbox,a.hasSandbox=s.hasDebugString==="true",a.isVisible=s.isVisible||!0,a.settings=s.settings||{},a.eventNameFilters=s.eventNameFilters||[],a.eventTypeFilters=s.eventTypeFilters||[],a.attributeFilters=s.attributeFilters||[],a.screenNameFilters=s.screenNameFilters||[],a.screenAttributeFilters=s.screenAttributeFilters||[],a.userIdentityFilters=s.userIdentityFilters||[],a.userAttributeFilters=s.userAttributeFilters||[],a.filteringEventAttributeValue=s.filteringEventAttributeValue||{},a.filteringUserAttributeValue=s.filteringUserAttributeValue||{},a.eventSubscriptionId=s.eventSubscriptionId||null,a.filteringConsentRuleValues=s.filteringConsentRuleValues||{},a.excludeAnonymousUser=s.excludeAnonymousUser||!1,a},this.configurePixel=function(n){(n.isDebug===e._Store.SDKConfig.isDevelopmentMode||n.isProduction!==e._Store.SDKConfig.isDevelopmentMode)&&e._Store.pixelConfigurations.push(n)},this.processPixelConfigs=function(n){try{F(n.pixelConfigs)||n.pixelConfigs.forEach(function(s){i.configurePixel(s)})}catch(s){e.Logger.error("Cookie Sync configs not configured propertly. Cookie Sync may not be initialized. "+s)}},this.sendSingleForwardingStatsToServer=function(n){return $(r,void 0,void 0,function(){var s,a,u,l;return Y(this,function(d){switch(d.label){case 0:return s={method:"post",body:JSON.stringify(n),headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"text/plain;charset=UTF-8"}},[4,this.forwarderStatsUploader.upload(s)];case 1:return a=d.sent(),a.status===202?u="Successfully sent forwarding stats to mParticle Servers":u="Issue with forwarding stats to mParticle Servers, received HTTP Code of "+a.statusText,(l=e==null?void 0:e.Logger)===null||l===void 0||l.verbose(u),[2]}})})}}var rt=h.MessageType,zo=h.ApplicationTransitionType;function Jo(e,t){var r=[];t.flags={};for(var i in e.CustomFlags)r=[],e.CustomFlags.hasOwnProperty(i)&&(Array.isArray(e.CustomFlags[i])?e.CustomFlags[i].forEach(function(o){Bt(o)&&r.push(o.toString())}):Bt(e.CustomFlags[i])&&r.push(e.CustomFlags[i].toString()),r.length&&(t.flags[i]=r))}function Go(e){return{id:we(e.Sku),nm:we(e.Name),pr:se(e.Price),qt:se(e.Quantity),br:we(e.Brand),va:we(e.Variant),ca:we(e.Category),ps:se(e.Position),cc:we(e.CouponCode),tpa:se(e.TotalAmount),attrs:e.Attributes}}function Mt(e){return e?e.map(function(t){return Go(t)}):[]}function yr(e){var t=this;this.convertToConsentStateV2DTO=function(r){if(!r)return null;var i={},o=r.getGDPRConsentState();if(o){var n={};i.gdpr=n;for(var s in o)if(o.hasOwnProperty(s)){var a=o[s];i.gdpr[s]={},typeof a.Consented=="boolean"&&(n[s].c=a.Consented),typeof a.Timestamp=="number"&&(n[s].ts=a.Timestamp),typeof a.ConsentDocument=="string"&&(n[s].d=a.ConsentDocument),typeof a.Location=="string"&&(n[s].l=a.Location),typeof a.HardwareId=="string"&&(n[s].h=a.HardwareId)}}var u=r.getCCPAConsentState();return u&&(i.ccpa={data_sale_opt_out:{c:u.Consented,ts:u.Timestamp,d:u.ConsentDocument,l:u.Location,h:u.HardwareId}}),i},this.createEventObject=function(r,i){var o,n,s,a={},u={},l=r.messageType===h.MessageType.OptOut?!e._Store.isEnabled:null;if(e._Store.sessionId||r.messageType===h.MessageType.OptOut||e._Store.webviewBridgeEnabled){var d=I({},r.customFlags),g=e._Store.integrationAttributes,p=e._Helpers.getFeatureFlag,v=p&&p(m.FeatureFlags.CaptureIntegrationSpecificIds),y=p&&(p(m.FeatureFlags.CaptureIntegrationSpecificIdsV2)||""),S=y&&y!==m.CaptureIntegrationSpecificIdsV2Modes.None||v===!0;if(S){e._IntegrationCapture.capture();var C=e._IntegrationCapture.getClickIdsAsCustomFlags();d=I(I({},C),d);var w=e._IntegrationCapture.getClickIdsAsIntegrationAttributes();g=I(I({},w),g)}r.hasOwnProperty("toEventAPIObject")?u=r.toEventAPIObject():u={EventName:r.name||String(r.messageType),EventCategory:r.eventType,EventAttributes:e._Helpers.sanitizeAttributes(r.data,r.name),ActiveTimeOnSite:(o=e._timeOnSiteTimer)===null||o===void 0?void 0:o.getTimeInForeground(),TotalTimeOnSite:(s=(n=e._Store).getTotalTimeOnSite)===null||s===void 0?void 0:s.call(n),PageUrl:Se()||null,SourceMessageId:r.sourceMessageId||e._Helpers.generateUniqueId(),EventDataType:r.messageType,CustomFlags:d,UserAttributeChanges:r.userAttributeChanges,UserIdentityChanges:r.userIdentityChanges},r.messageType!==h.MessageType.SessionEnd&&(e._Store.dateLastEventSent=new Date),a={Store:e._Store.serverSettings,SDKVersion:m.sdkVersion,SessionId:e._Store.sessionId,SessionStartDate:e._Store.sessionStartDate?e._Store.sessionStartDate.getTime():0,Debug:e._Store.SDKConfig.isDevelopmentMode,Location:e._Store.currentPosition,OptOut:l,ExpandedEventCount:0,AppVersion:e.getAppVersion(),AppName:e.getAppName(),Package:e._Store.SDKConfig.package,ClientGeneratedId:e._Store.clientId,DeviceId:e._Store.deviceId,IntegrationAttributes:g,CurrencyCode:e._Store.currencyCode,DataPlan:e._Store.SDKConfig.dataPlan?e._Store.SDKConfig.dataPlan:{}},u.EventDataType===rt.AppStateTransition&&(u.IsFirstRun=e._Store.isFirstRun,u.LaunchReferral=window.location.href||null),u.CurrencyCode=e._Store.currencyCode;var b=i||e.Identity.getCurrentUser();return Ct(b,u),r.messageType===h.MessageType.SessionEnd&&(u.SessionLength=e._Store.dateLastEventSent.getTime()-e._Store.sessionStartDate.getTime(),u.currentSessionMPIDs=e._Store.currentSessionMPIDs,u.EventAttributes=e._Store.sessionAttributes,e._Store.currentSessionMPIDs=[],e._Store.sessionStartDate=null),a.Timestamp=e._Store.dateLastEventSent.getTime(),ne({},u,a)}return null},this.convertEventToV2DTO=function(r){var i={n:r.EventName,et:r.EventCategory,ua:r.UserAttributes,ui:r.UserIdentities,ia:r.IntegrationAttributes,str:r.Store,attrs:r.EventAttributes,sdk:r.SDKVersion,sid:r.SessionId,sl:r.SessionLength,ssd:r.SessionStartDate,dt:r.EventDataType,dbg:r.Debug,ct:r.Timestamp,lc:r.Location,o:r.OptOut,eec:r.ExpandedEventCount,av:r.AppVersion,cgid:r.ClientGeneratedId,das:r.DeviceId,mpid:r.MPID,smpids:r.currentSessionMPIDs};r.DataPlan&&r.DataPlan.PlanId&&(i.dp_id=r.DataPlan.PlanId,r.DataPlan.PlanVersion&&(i.dp_v=r.DataPlan.PlanVersion));var o=t.convertToConsentStateV2DTO(r.ConsentState);return o&&(i.con=o),r.EventDataType===rt.AppStateTransition&&(i.fr=r.IsFirstRun,i.iu=!1,i.at=zo.AppInit,i.lr=r.LaunchReferral,i.attrs=null),r.CustomFlags&&Jo(r,i),r.EventDataType===rt.Commerce?(i.cu=r.CurrencyCode,r.ShoppingCart&&(i.sc={pl:Mt(r.ShoppingCart.ProductList)}),r.ProductAction?i.pd={an:r.ProductAction.ProductActionType,cs:e._Helpers.parseNumber(r.ProductAction.CheckoutStep),co:r.ProductAction.CheckoutOptions,pl:Mt(r.ProductAction.ProductList),ti:r.ProductAction.TransactionId,ta:r.ProductAction.Affiliation,tcc:r.ProductAction.CouponCode,tr:e._Helpers.parseNumber(r.ProductAction.TotalAmount),ts:e._Helpers.parseNumber(r.ProductAction.ShippingAmount),tt:e._Helpers.parseNumber(r.ProductAction.TaxAmount)}:r.PromotionAction?i.pm={an:r.PromotionAction.PromotionActionType,pl:r.PromotionAction.PromotionList.map(function(n){return{id:n.Id,nm:n.Name,cr:n.Creative,ps:n.Position?n.Position:0}})}:r.ProductImpressions&&(i.pi=r.ProductImpressions.map(function(n){return{pil:n.ProductImpressionList,pl:Mt(n.ProductList)}}))):r.EventDataType===rt.Profile&&(i.pet=r.ProfileMessageType),i}}function $o(e){this.startForwardingStatsTimer=function(){window.mParticle._forwardingStatsTimer=setInterval(function(){t()},e._Store.SDKConfig.forwarderStatsTimeout)};function t(){var r=e._Forwarders.getForwarderStatsQueue(),i=e._Persistence.forwardingStatsBatches.uploadsTable,o=Date.now();r.length&&(i[o]={uploading:!1,data:r},e._Forwarders.setForwarderStatsQueue([]));for(var n in i)(function(s){if(i.hasOwnProperty(s)&&i[s].uploading===!1){var a=function(){u.readyState===4&&(u.status===200||u.status===202?(e.Logger.verbose("Successfully sent "+u.statusText+" from server"),delete i[s]):u.status.toString()[0]==="4"?u.status!==429&&delete i[s]:i[s].uploading=!1)},u=e._Helpers.createXHR(a),l=i[s].data;i[s].uploading=!0,e._APIClient.sendBatchForwardingStatsToServer(l,u)}})(n)}}var Yo=(function(){function e(t,r,i){this.url="",this.logger=i,this.url="https://".concat(t).concat(r,"/audience"),this.userAudienceAPI=window.fetch?new Ee(this.url):new Ie(this.url)}return e.prototype.sendGetUserAudienceRequest=function(t,r){return $(this,void 0,void 0,function(){var i,o,n,s,a,u;return Y(this,function(l){switch(l.label){case 0:this.logger.verbose("Fetching user audiences from server"),i={method:"GET",headers:{Accept:"*/*"}},o="".concat(this.url,"?mpid=").concat(t),l.label=1;case 1:return l.trys.push([1,6,,7]),[4,this.userAudienceAPI.upload(i,o)];case 2:return n=l.sent(),n.status>=200&&n.status=0&&(u[h.IdentityType.getIdentityType(d)]=l[d])}return u},createAliasNetworkRequest:function(s){return{request_id:e._Helpers.generateUniqueId(),request_type:"alias",environment:e._Store.SDKConfig.isDevelopmentMode?"development":"production",api_key:e._Store.devToken,data:{destination_mpid:s.destinationMpid,source_mpid:s.sourceMpid,start_unixtime_ms:s.startTime,end_unixtime_ms:s.endTime,scope:s.scope,device_application_stamp:e._Store.deviceId}}},convertAliasToNative:function(s){return{DestinationMpid:s.destinationMpid,SourceMpid:s.sourceMpid,StartUnixtimeMs:s.startTime,EndUnixtimeMs:s.endTime,Scope:s.scope}},convertToNative:function(s){var a=[];if(s!=null&&s.userIdentities){for(var u in s.userIdentities)s.userIdentities.hasOwnProperty(u)&&a.push({Type:h.IdentityType.getIdentityType(u),Identity:s.userIdentities[u]});return{UserIdentities:a}}}},this.IdentityAPI={HTTPCodes:X,identify:function(s,a){var u,l=e.Identity.getCurrentUser(),d=e._Identity.IdentityRequest.preProcessIdentityRequest(s,a,nt);if(l&&(u=l.getMPID()),d.valid){var g=e._Identity.IdentityRequest.createIdentityRequest(d.cleanedIdentities,m.platform,m.sdkVendor,m.sdkVersion,e._Store.deviceId,e._Store.context,u);if(e._Helpers.getFeatureFlag(m.FeatureFlags.CacheIdentity)){var p=Gt(g.known_identities,o.idCache,o.parseIdentityResponse,u,a,s,nt);if(p)return}e._Helpers.canLog()?e._Store.webviewBridgeEnabled?(e._NativeSdkHelpers.sendToNative(m.NativeSdkPaths.Identify,JSON.stringify(e._Identity.IdentityRequest.convertToNative(s))),e._Helpers.invokeCallback(a,X.nativeIdentityRequest,"Identify request sent to native sdk")):e._IdentityAPIClient.sendIdentityRequest(g,nt,a,s,o.parseIdentityResponse,u,g.known_identities):(e._Helpers.invokeCallback(a,X.loggingDisabledOrMissingAPIKey,B.InformationMessages.AbandonLogEvent),e.Logger.verbose(B.InformationMessages.AbandonLogEvent))}else e._Helpers.invokeCallback(a,X.validationIssue,d.error),e.Logger.verbose(d)},logout:function(s,a){var u,l=e.Identity.getCurrentUser(),d=e._Identity.IdentityRequest.preProcessIdentityRequest(s,a,mr);if(l&&(u=l.getMPID()),d.valid){var g,p=e._Identity.IdentityRequest.createIdentityRequest(d.cleanedIdentities,m.platform,m.sdkVendor,m.sdkVersion,e._Store.deviceId,e._Store.context,u);e._Helpers.canLog()?e._Store.webviewBridgeEnabled?(e._NativeSdkHelpers.sendToNative(m.NativeSdkPaths.Logout,JSON.stringify(e._Identity.IdentityRequest.convertToNative(s))),e._Helpers.invokeCallback(a,X.nativeIdentityRequest,"Logout request sent to native sdk")):(e._IdentityAPIClient.sendIdentityRequest(p,mr,a,s,o.parseIdentityResponse,u),g=e._ServerModel.createEventObject({messageType:h.MessageType.Profile}),g.ProfileMessageType=h.ProfileMessageType.Logout,e._Store.activeForwarders.length&&e._Store.activeForwarders.forEach(function(v){var y=v;y.logOut&&y.logOut(g)})):(e._Helpers.invokeCallback(a,X.loggingDisabledOrMissingAPIKey,B.InformationMessages.AbandonLogEvent),e.Logger.verbose(B.InformationMessages.AbandonLogEvent))}else e._Helpers.invokeCallback(a,X.validationIssue,d.error),e.Logger.verbose(d)},login:function(s,a){var u,l=e.Identity.getCurrentUser(),d=e._Identity.IdentityRequest.preProcessIdentityRequest(s,a,Ut);if(l&&(u=l.getMPID()),d.valid){var g=e._Identity.IdentityRequest.createIdentityRequest(d.cleanedIdentities,m.platform,m.sdkVendor,m.sdkVersion,e._Store.deviceId,e._Store.context,u);if(e._Helpers.getFeatureFlag(m.FeatureFlags.CacheIdentity)){var p=Gt(g.known_identities,o.idCache,o.parseIdentityResponse,u,a,s,Ut);if(p)return}e._Helpers.canLog()?e._Store.webviewBridgeEnabled?(e._NativeSdkHelpers.sendToNative(m.NativeSdkPaths.Login,JSON.stringify(e._Identity.IdentityRequest.convertToNative(s))),e._Helpers.invokeCallback(a,X.nativeIdentityRequest,"Login request sent to native sdk")):e._IdentityAPIClient.sendIdentityRequest(g,Ut,a,s,o.parseIdentityResponse,u,g.known_identities):(e._Helpers.invokeCallback(a,X.loggingDisabledOrMissingAPIKey,B.InformationMessages.AbandonLogEvent),e.Logger.verbose(B.InformationMessages.AbandonLogEvent))}else e._Helpers.invokeCallback(a,X.validationIssue,d.error),e.Logger.verbose(d)},modify:function(s,a){var u,l=e.Identity.getCurrentUser(),d=e._Identity.IdentityRequest.preProcessIdentityRequest(s,a,je);if(l&&(u=l.getMPID()),d.valid){var g=s!=null&&s.userIdentities?d.cleanedIdentities.userIdentities:{},p=e._Identity.IdentityRequest.createModifyIdentityRequest(l?l.getUserIdentities().userIdentities:{},g,m.platform,m.sdkVendor,m.sdkVersion,e._Store.context);e._Helpers.canLog()?e._Store.webviewBridgeEnabled?(e._NativeSdkHelpers.sendToNative(m.NativeSdkPaths.Modify,JSON.stringify(e._Identity.IdentityRequest.convertToNative(s))),e._Helpers.invokeCallback(a,X.nativeIdentityRequest,"Modify request sent to native sdk")):e._IdentityAPIClient.sendIdentityRequest(p,je,a,s,o.parseIdentityResponse,u):(e._Helpers.invokeCallback(a,X.loggingDisabledOrMissingAPIKey,B.InformationMessages.AbandonLogEvent),e.Logger.verbose(B.InformationMessages.AbandonLogEvent))}else e._Helpers.invokeCallback(a,X.validationIssue,d.error),e.Logger.verbose(d)},getCurrentUser:function(){var s;return e._Store?(s=e._Store.mpid,s?(s=e._Store.mpid.slice(),o.mParticleUser(s,e._Store.isLoggedIn)):e._Store.webviewBridgeEnabled?o.mParticleUser():null):null},getUser:function(s){var a=e._Persistence.getPersistence();return a&&a[s]&&!m.SDKv2NonMPIDCookieKeys.hasOwnProperty(s)?o.mParticleUser(s):null},getUsers:function(){var s=e._Persistence.getPersistence(),a=[];if(s)for(var u in s)m.SDKv2NonMPIDCookieKeys.hasOwnProperty(u)||a.push(o.mParticleUser(u));return a.sort(function(l,d){var g=l.getLastSeenTime()||0,p=d.getLastSeenTime()||0;return g>p?-1:1}),a},aliasUsers:function(s,a){var u;if((!s.destinationMpid||!s.sourceMpid)&&(u=B.ValidationMessages.AliasMissingMpid),s.destinationMpid===s.sourceMpid&&(u=B.ValidationMessages.AliasNonUniqueMpid),(!s.startTime||!s.endTime)&&(u=B.ValidationMessages.AliasMissingTime),s.startTime>s.endTime&&(u=B.ValidationMessages.AliasStartBeforeEndTime),u){e.Logger.warning(u),e._Helpers.invokeAliasCallback(a,X.validationIssue,u);return}if(e._Helpers.canLog())if(e._Store.webviewBridgeEnabled)e._NativeSdkHelpers.sendToNative(m.NativeSdkPaths.Alias,JSON.stringify(e._Identity.IdentityRequest.convertAliasToNative(s))),e._Helpers.invokeAliasCallback(a,X.nativeIdentityRequest,"Alias request sent to native sdk");else{e.Logger.verbose(B.InformationMessages.StartingAliasRequest+": "+s.sourceMpid+" -> "+s.destinationMpid);var l=e._Identity.IdentityRequest.createAliasNetworkRequest(s);e._IdentityAPIClient.sendAliasRequest(l,a)}else e._Helpers.invokeAliasCallback(a,X.loggingDisabledOrMissingAPIKey,B.InformationMessages.AbandonAliasUsers),e.Logger.verbose(B.InformationMessages.AbandonAliasUsers)},search:function(s,a,u){Zi(e,s,a,u)},createAliasRequest:function(s,a,u){try{if(!a||!s)return e.Logger.error("'destinationUser' and 'sourceUser' must both be present"),null;var l=s.getFirstSeenTime();l||e.Identity.getUsers().forEach(function(p){p.getFirstSeenTime()&&(!l||p.getFirstSeenTime()0&&U.forEach(function(M){return i.addToMatchLookups(M)})}catch(M){this.mpInstance.Logger.error("There was an issue with the data plan: "+M)}}return e.prototype.addToMatchLookups=function(t){var r,i,o;if(!t.match||!t.validator){this.mpInstance.Logger.warning("Data Plan Point is not valid' + ".concat(t));return}var n=this.generateMatchKey(t.match),s=this.getPlannedProperties(t.match.type,t.validator);this.dataPlanMatchLookups[n]=s,(((r=t==null?void 0:t.match)===null||r===void 0?void 0:r.type)===N.ProductImpression||((i=t==null?void 0:t.match)===null||i===void 0?void 0:i.type)===N.ProductAction||((o=t==null?void 0:t.match)===null||o===void 0?void 0:o.type)===N.PromotionAction)&&(n=this.generateProductAttributeMatchKey(t.match),s=this.getProductProperties(t.match.type,t.validator),this.dataPlanMatchLookups[n]=s)},e.prototype.generateMatchKey=function(t){var r=t.criteria||"";switch(t.type){case N.CustomEvent:var i=r;return[N.CustomEvent,i.custom_event_type,i.event_name].join(":");case N.ScreenView:var o=r;return[N.ScreenView,"",o.screen_name].join(":");case N.ProductAction:var n=r;return[t.type,n.action].join(":");case N.PromotionAction:var s=r;return[t.type,s.action].join(":");case N.ProductImpression:var a=r;return[t.type,a.action].join(":");case N.UserIdentities:case N.UserAttributes:return[t.type].join(":");default:return null}},e.prototype.generateProductAttributeMatchKey=function(t){var r=t.criteria||"";switch(t.type){case N.ProductAction:var i=r;return[t.type,i.action,"ProductAttributes"].join(":");case N.PromotionAction:var o=r;return[t.type,o.action,"ProductAttributes"].join(":");case N.ProductImpression:return[t.type,"ProductAttributes"].join(":");default:return null}},e.prototype.getPlannedProperties=function(t,r){var i,o,n,s,a,u,l,d,g,p;switch(t){case N.CustomEvent:case N.ScreenView:case N.ProductAction:case N.PromotionAction:case N.ProductImpression:if(g=(s=(n=(o=(i=r==null?void 0:r.definition)===null||i===void 0?void 0:i.properties)===null||o===void 0?void 0:o.data)===null||n===void 0?void 0:n.properties)===null||s===void 0?void 0:s.custom_attributes,g){if(g.additionalProperties===!0||g.additionalProperties===void 0)return!0;for(var v={},y=0,S=Object.keys(g.properties);y=Mr)throw new Error("Received HTTP Code of "+T.status);return e._Store.identityCallInFlight=!1,e._Store.identityCallFailed=!1,J="Received HTTP Code of "+T.status,v.error("Error sending identity request to servers - "+J),p(i,st.noHttpCoverage,J),[2]}case 8:return e._Store.identityCallInFlight=!1,e._Store.identityCallFailed=!1,M&&v.verbose(M),!((l=e._RoktManager)===null||l===void 0)&&l.isInitialized&&(de=e._Store.identifyRequestCount,e.captureTiming("".concat(de,"-identityRequestEnd"))),n(U,S,i,o,r,a,!1),[3,10];case 9:return ue=f.sent(),e._Store.identityCallInFlight=!1,e._Store.identityCallFailed=!0,!((d=e._RoktManager)===null||d===void 0)&&d.isInitialized&&(de=e._Store.identifyRequestCount,e.captureTiming("".concat(de,"-identityRequestEnd"))),J=le(ue),c="Error sending identity request to servers - "+J,v.error(c),y==null||y.report({message:c,code:Re.IDENTITY_REQUEST,severity:Ve.ERROR}),(g=e.processQueueOnIdentityFailure)===null||g===void 0||g.call(e),p(i,st.noHttpCoverage,J),[3,10];case 10:return[2]}})})},this.getUploadUrl=function(t,r){var i=e._Helpers.createServiceUrl(e._Store.SDKConfig.identityUrl),o=t===ln?i+r+"/"+t:i+t;return o},this.getIdentityResponseFromFetch=function(t,r){return{status:t.status,responseText:r,cacheMaxAge:parseInt(t.headers.get(Jt))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(t){return{status:t.status,responseText:t.responseText?JSON.parse(t.responseText):{},cacheMaxAge:se(t.getResponseHeader(Jt)||""),expireTimestamp:0}}}var cn=function(t,r,i){if(!t||!r)return"";var o=r==null?void 0:r.split("//");if(!o)return"";var n=o[1].split("/"),s=n[0].split("."),a=1;s.length>=3&&(a=2);var u=i||Date.now();return"fb.".concat(a,".").concat(u,".").concat(t)},ie={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_identities",INTEGRATION_ATTRIBUTES:"integration_attributes"},gn={fbclid:{mappedKey:"Facebook.ClickId",processor:cn,output:ie.CUSTOM_FLAGS},_fbp:{mappedKey:"Facebook.BrowserId",output:ie.CUSTOM_FLAGS},_fbc:{mappedKey:"Facebook.ClickId",output:ie.CUSTOM_FLAGS},gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:ie.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:ie.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:ie.CUSTOM_FLAGS},ttclid:{mappedKey:"TikTok.Callback",output:ie.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:ie.PARTNER_IDENTITIES},ScCid:{mappedKey:"SnapchatConversions.ClickId",output:ie.CUSTOM_FLAGS},_scid:{mappedKey:"SnapchatConversions.Cookie1",output:ie.CUSTOM_FLAGS}},_r={rtid:{mappedKey:"passbackconversiontrackingid",output:ie.INTEGRATION_ATTRIBUTES,moduleId:1277},rclid:{mappedKey:"passbackconversiontrackingid",output:ie.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:ie.INTEGRATION_ATTRIBUTES,moduleId:1277}},fn=(function(){function e(t){this.initialTimestamp=Date.now(),this.captureMode=t,this.filteredPartnerIdentityMappings=this.filterMappings(ie.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(ie.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(ie.INTEGRATION_ATTRIBUTES)}return e.prototype.capture=function(){var t=this.captureQueryParams()||{},r=this.captureCookies()||{},i=this.captureLocalStorage()||{};t.fbclid&&r._fbc&&delete r._fbc;var o=t.rtid||t.rclid,n=i.RoktTransactionId,s=r.RoktTransactionId;o?(n&&delete i.RoktTransactionId,s&&delete r.RoktTransactionId):n&&s&&delete r.RoktTransactionId,this.clickIds=I(I(I(I({},this.clickIds),t),i),r)},e.prototype.captureCookies=function(){var t=this.getAllowedKeysForMode(),r=ei(t);return this.applyProcessors(r,Se(),this.initialTimestamp)},e.prototype.captureQueryParams=function(){var t=this.getQueryParams();return this.applyProcessors(t,Se(),this.initialTimestamp)},e.prototype.captureLocalStorage=function(){for(var t=this.getAllowedKeysForMode(),r={},i=0,o=t;i=400||ut