/*! * Genesys Predictive Engagement v2.1717.0 * Copyright (c) 2014-2025 Genesys Cloud Services, Inc. All rights reserved. * * https://developer.genesys.cloud/commdigital/digital/webmessaging/messengersdk/ */(()=>{var e={914:function(e,t,i){var s;/*! https://mths.be/base64 v1.0.0 by @mathias | MIT license */e=i.nmd(e),function(n){var r=t,o=(e&&e.exports,"object"==typeof i.g&&i.g);o.global!==o&&o.window;var a=function(e){this.message=e};(a.prototype=new Error).name="InvalidCharacterError";var c=function(e){throw new a(e)},u="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",h=/[\t\n\f\r ]/g,l={encode:function(e){e=String(e),/[^\0-\xFF]/.test(e)&&c("The string to be encoded contains characters outside of the Latin1 range.");for(var t,i,s,n,r=e.length%3,o="",a=-1,h=e.length-r;++a>18&63)+u.charAt(n>>12&63)+u.charAt(n>>6&63)+u.charAt(63&n);return 2==r?(t=e.charCodeAt(a)<<8,i=e.charCodeAt(++a),o+=u.charAt((n=t+i)>>10)+u.charAt(n>>4&63)+u.charAt(n<<2&63)+"="):1==r&&(n=e.charCodeAt(a),o+=u.charAt(n>>2)+u.charAt(n<<4&63)+"=="),o},decode:function(e){var t=(e=String(e).replace(h,"")).length;t%4==0&&(t=(e=e.replace(/==?$/,"")).length),(t%4==1||/[^+a-zA-Z0-9/]/.test(e))&&c("Invalid character: the string to be decoded is not correctly encoded.");for(var i,s,n=0,r="",o=-1;++o>(-2*n&6)));return r},version:"1.0.0"};void 0===(s=function(){return l}.call(t,i,t,e))||(e.exports=s)}()},31:(e,t)=>{!function(e){var t,i,s,n=String.fromCharCode;function r(e){for(var t,i,s=[],n=0,r=e.length;n=55296&&t<=56319&&n=55296&&e<=57343)throw Error("Lone surrogate U+"+e.toString(16).toUpperCase()+" is not a scalar value")}function a(e,t){return n(e>>t&63|128)}function c(e){if(0==(4294967168&e))return n(e);var t="";return 0==(4294965248&e)?t=n(e>>6&31|192):0==(4294901760&e)?(o(e),t=n(e>>12&15|224),t+=a(e,6)):0==(4292870144&e)&&(t=n(e>>18&7|240),t+=a(e,12),t+=a(e,6)),t+=n(63&e|128)}function u(){if(s>=i)throw Error("Invalid byte index");var e=255&t[s];if(s++,128==(192&e))return 63&e;throw Error("Invalid continuation byte")}function h(){var e,n;if(s>i)throw Error("Invalid byte index");if(s==i)return!1;if(e=255&t[s],s++,0==(128&e))return e;if(192==(224&e)){if((n=(31&e)<<6|u())>=128)return n;throw Error("Invalid continuation byte")}if(224==(240&e)){if((n=(15&e)<<12|u()<<6|u())>=2048)return o(n),n;throw Error("Invalid continuation byte")}if(240==(248&e)&&(n=(7&e)<<18|u()<<12|u()<<6|u())>=65536&&n<=1114111)return n;throw Error("Invalid UTF-8 detected")}e.version="3.0.0",e.encode=function(e){for(var t=r(e),i=t.length,s=-1,n="";++s65535&&(r+=n((t-=65536)>>>10&1023|55296),t=56320|1023&t),r+=n(t);return r}(a)}}(t)}},t={};function i(s){var n=t[s];if(void 0!==n)return n.exports;var r=t[s]={id:s,loaded:!1,exports:{}};return e[s].call(r.exports,r,r.exports,i),r.loaded=!0,r.exports}i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var s in t)i.o(t,s)&&!i.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),(()=>{"use strict";var e,t,s,n,r,o;function a(e,t,i){return new Promise((s=>{t.subscribe(`${e}.ready`,(()=>{i&&"function"==typeof i&&i(),s(e)}))}))}!function(e){e.Command="command",e.RegisterPlugin="registerPlugin"}(e||(e={}));class c{constructor(e){this.plugin=e}}!function(e){e.Cookies="Cookies",e.LocalStorage="LocalStorage"}(t||(t={}));class u extends c{constructor(e){super(e),this.plugin=e}}!function(e){e.Get="Cookies.get",e.Set="Cookies.set",e.Remove="Cookies.remove"}(s||(s={}));class h extends u{constructor(e){super(e)}get(e){return this.plugin.command(s.Get,{name:e})}set(e,t,i){return this.plugin.command(s.Set,{name:e,value:t,expireInSecs:i})}remove(e){return this.plugin.command(s.Remove,{name:e})}}class l{constructor(){this.observers=[]}notify(e){this.observers.forEach((t=>{t(e)}))}subscribe(e){return this.observers.includes(e)||this.observers.push(e),()=>{this.unsubscribe(e)}}unsubscribe(e){const t=this.observers.indexOf(e);t>-1&&this.observers.splice(t,1)}}function d(e){return!!e&&""!==e.trim()}!function(e){e.Input="input",e.Select="select",e.Textarea="textarea"}(n||(n={}));class g{static serialize(e){const t=g.getInputData(e),i=g.getSelectData(e),s=g.getTextareaData(e);return Object.assign({},t,i,s)}static getFormLabel(e){return e.getAttribute("name")||e.getAttribute("id")||e.getAttribute("action")||""}static findSubmitLikeButtons(e){const t=g.asArray(e.querySelectorAll("input,button")).filter((e=>g.isSubmitLikeButton(e)));return e.hasAttribute("id")&&g.asArray(document.querySelectorAll(`input[form="${e.id}"],button[form="${e.id}"]`)).filter((e=>g.isSubmitLikeButton(e))).forEach((e=>t.push(e))),t}static getTrackableInputs(e){const t=g.asArray(e.querySelectorAll(n.Input));return e.hasAttribute("id")&&g.asArray(document.querySelectorAll(`${n.Input}[form="${e.id}"]`)).forEach((e=>t.push(e))),t.filter((e=>g.hasValidName(e)&&g.isTrackableInputType(e.type)))}static getTrackableSelects(e){const t=g.asArray(e.querySelectorAll(n.Select));return e.hasAttribute("id")&&g.asArray(document.querySelectorAll(`${n.Select}[form="${e.id}"]`)).forEach((e=>t.push(e))),t.filter((e=>g.hasValidName(e)))}static getTrackableTextareas(e){const t=g.asArray(e.querySelectorAll(n.Textarea));return e.hasAttribute("id")&&g.asArray(document.querySelectorAll(`${n.Textarea}[form="${e.id}"]`)).forEach((e=>t.push(e))),t.filter((e=>g.hasValidName(e)))}static asArray(e){return Array.prototype.slice.call(e)}static getInputData(e){return g.getTrackableInputs(e).filter((e=>g.hasValue(e)&&"radio"!==e.type&&"checkbox"!==e.type||e.checked)).reduce(((e,t)=>(e[t.name]=t.value,e)),{})}static getTextareaData(e){return g.getTrackableTextareas(e).filter((e=>g.hasValue(e))).reduce(((e,t)=>(e[t.name]=t.value,e)),{})}static getSelectData(e){return g.getTrackableSelects(e).reduce(((e,t)=>{const i=g.getSelectedOptionsValues(t);return""!==i&&(e[t.name]=i),e}),{})}static getSelectedOptionsValues(e){return g.asArray(e.options).filter((e=>e.selected&&g.hasValue(e))).map((e=>e.value)).join(g.separator)}static isTrackableInputType(e){return["password","submit","hidden"].every((t=>t!==e))}static hasValidName(e){return d(e.name)&&!g.isSensitive(e.name)}static hasValue(e){return d(e.value)}static isSensitive(e){const t=g.sanitizeFieldName(e);return g.isSensitiveRegex.test(t)}static sanitizeFieldName(e){return e.toLowerCase().replace(/[^a-z0-9]/g,"")}static isSubmitLikeButton(e){const t=["type","value"].some((t=>g.attributeValueIsSubmit(t,e))),i=["id","name","class"].some((t=>g.attributeValueIncludesSubmit(t,e)));return t||i}static attributeValueIsSubmit(e,t){return"submit"===(t.getAttribute(e)||"").toLowerCase()}static attributeValueIncludesSubmit(e,t){return(t.getAttribute(e)||"").toLowerCase().includes("submit")}}g.isSensitiveRegex=/pass|billing|creditcard|cardnum|^cc|ccnum|exp|seccode|securitycode|securitynum|cvc|cvv|ssn|socialsec|socsec|csc/i,g.separator=", ",function(e){e.Blur="blur",e.BeforeUnload="beforeunload",e.Click="click",e.Focus="focus",e.Submit="submit"}(r||(r={})),function(e){e.Pristine="pristine",e.Tracking="tracking",e.Submitted="submitted",e.Abandoned="abandoned"}(o||(o={}));class m extends l{constructor(e){super(),this.form=e,this.formLabel="",this.formData={},this.formState=o.Pristine,this.trackedFields=[],this.formLabel=g.getFormLabel(e),this.attachFormHandler()}getFormState(){return this.formState}setFormState(e){this.formState=e,e!==o.Abandoned&&e!==o.Submitted||this.notify({formState:this.formState,formLabel:this.formLabel,formData:this.formData})}abandonIfMissing(){document.body.contains(this.form)||this.setFormState(o.Abandoned)}attachFormHandler(){[...g.getTrackableInputs(this.form),...g.getTrackableSelects(this.form),...g.getTrackableTextareas(this.form)].forEach((e=>this.trackField(e))),this.attachSubmitHandlers()}attachSubmitHandlers(){this.trackFormSubmitEvent(),this.wrapNativeFormSubmit(),g.findSubmitLikeButtons(this.form).forEach((e=>{this.handleSubmitOnCLick(e)}))}trackFormSubmitEvent(){this.form.addEventListener(r.Submit,(()=>this.handleSubmit()),!1)}wrapNativeFormSubmit(){const e=this.form.submit.bind(this.form);this.form.submit=()=>{this.handleSubmit(),e()}}trackField(e){e.addEventListener(r.Blur,(()=>this.handleBlur()),!1),this.trackedFields.push(e)}hasTrackedFieldsInError(){return this.trackedFields.some((e=>e.classList.contains("error")))}formIsValid(){return this.form.hasAttribute("novalidate")?!this.hasTrackedFieldsInError():this.form.checkValidity()}handleSubmit(){this.formIsValid()&&Object.keys(this.formData).length&&this.formState===o.Tracking&&this.setFormState(o.Submitted)}handleBlur(){this.formState=o.Tracking,this.formLabel=g.getFormLabel(this.form),this.formData=g.serialize(this.form)}handleSubmitOnCLick(e){e.addEventListener(r.Click,(()=>this.handleSubmit()),!1)}}const v={};var p,f,b=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};!function(e){e.GetCustomerId="Identifiers.getCustomerId",e.GetSessionId="Identifiers.getSessionId",e.GetAll="Identifiers.getAll",e.GetSessionCount="Identifiers.getSessionCount",e.GetSessionTimestamps="Identifiers.getSessionTimestamps"}(p||(p={})),function(e){e.NewSessionId="Identifiers.newSessionId",e.NewCustomerId="Identifiers.newCustomerId",e.IdentifiersPurged="Identifiers.identifiersPurged"}(f||(f={}));class w extends c{constructor(e){super(e),this.eventPublisher=new l,this.disabled=!1,this.useCache=!1,window.addEventListener(r.BeforeUnload,(()=>this.useCache=!0),!1)}disable(){this.disabled=!0}getCustomerId(e={createDisabled:!1,touchDisabled:!1}){return b(this,void 0,void 0,(function*(){return yield this.fetchCached(this.plugin.command,p.GetCustomerId,e)}))}getSessionId(e={createDisabled:!1,touchDisabled:!1}){return b(this,void 0,void 0,(function*(){return yield this.fetchCached(this.plugin.command,p.GetSessionId,e)}))}getAll(e={createDisabled:!1,touchDisabled:!1}){return b(this,void 0,void 0,(function*(){return yield this.fetchCached(this.plugin.command,p.GetAll,e)}))}getSessionTimestamps(){return b(this,void 0,void 0,(function*(){return yield this.fetchCached(this.plugin.command,p.GetSessionTimestamps)}))}getSessionCount(){return b(this,void 0,void 0,(function*(){return yield this.fetchCached(this.plugin.command,p.GetSessionCount)}))}subscribe(e){return this.plugin.subscribe(f.NewCustomerId,(({data:e})=>{this.eventPublisher.notify(e)})),this.plugin.subscribe(f.NewSessionId,(({data:e})=>{this.eventPublisher.notify(e)})),this.eventPublisher.subscribe(e)}fetchCached(e,t,i={createDisabled:!1,touchDisabled:!1}){return b(this,void 0,void 0,(function*(){if(this.disabled)return Promise.reject("Messenger is cleared. Please reload the page to reinitialize.");if(this.useCache||(yield new Promise((e=>setTimeout(e,2)))),this.useCache)return Promise.resolve(v[t]);const s=yield e(t,i);return v[t]=s,s}))}}class E{static toCounts(e){const[t=0,i=0,s=0,n=0]=e?e.split(".").map((e=>parseInt(e,10)||0)):[0,0,0,0];return{sessionEventCount:t,sessionPageviewCount:i,totalEventCount:s,totalPageviewCount:n}}static sessionEventsToString({sessionEventCount:e,sessionPageviewCount:t}){return`${e}.${t}`}static customerEventsToString({totalEventCount:e,totalPageviewCount:t}){return`${e}.${t}`}static toString(e){return`${e.sessionEventCount}.${e.sessionPageviewCount}.${e.totalEventCount}.${e.totalPageviewCount}`}static incrementEventCounts(e){e.sessionEventCount++,e.totalEventCount++}static incrementPageviewCounts(e){e.sessionPageviewCount++,e.totalPageviewCount++}}var y,C=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};!function(e){e.Actsc="actsc",e.Actec="actec",e.Actmr="actmr"}(y||(y={}));class S{constructor(e){this.storageService=e,this.sessionEvents={sessionPageviewCount:0,sessionEventCount:0},this.customerEvents={totalPageviewCount:0,totalEventCount:0},this.useCache=!1,this.DEFAULT_EXPIRE_CUSTOMER=31536e3,this.DEFAULT_EXPIRE_SESSION=1800,this.EVENT_COUNTS_REGEX=/^\d+\.\d+$/,window.addEventListener(r.BeforeUnload,(()=>this.useCache=!0),!1)}initialize({sessionId:e,customerId:t}){return C(this,void 0,void 0,(function*(){yield this.initCounts({sessionId:e,customerId:t});const i=this.countsToActsc(this.sessionEvents),s=this.countsToActec(this.customerEvents);0===this.sessionEvents.sessionEventCount&&(yield this.setSessionReferrer(e)),yield Promise.all([this.setSessionEventCounts(e,i),this.setCustomerEventCounts(t,s)])}))}getEventCounts({sessionId:e,customerId:t}){return C(this,void 0,void 0,(function*(){const i=(yield this.getSessionEventCounts(e))||"0.0",s=(yield this.getCustomerEventCounts(t))||"0.0";return E.toCounts(`${i}.${s}`)}))}setEventCounts({sessionId:e,customerId:t},i){return C(this,void 0,void 0,(function*(){const s=E.sessionEventsToString(i),n=E.customerEventsToString(i);yield Promise.all([this.setSessionEventCounts(e,s),this.setCustomerEventCounts(t,n)])}))}removeInvalidStoredItems(e){return C(this,void 0,void 0,(function*(){const t=[];(yield this.getInvalidStoredItems(e)).forEach((e=>{t.push(this.removeCached(e))})),yield Promise.all(t)}))}removeAllStoredItems(){return C(this,void 0,void 0,(function*(){yield Promise.all(Object.values(y).map((e=>this.removeCached(e))))}))}getSessionReferrer(e){return C(this,void 0,void 0,(function*(){const t=yield this.getCached(y.Actmr);return t&&t.includes(e)?(yield this.setCached(y.Actmr,t,this.DEFAULT_EXPIRE_SESSION),t.split(".").slice(1).join(".")):null}))}initCounts({sessionId:e,customerId:t}){return C(this,void 0,void 0,(function*(){const i=yield this.getAllJourneyStoredItems({sessionId:e,customerId:t}),s=this.convertStoredItemToCounts(i);this.sessionEvents=s.sessionEvents,this.customerEvents=s.customerEvents}))}getInvalidStoredItems({sessionId:e,customerId:t}){return C(this,void 0,void 0,(function*(){const i=[];for(const s of Object.values(y)){const n=yield this.getCached(s);"string"!=typeof n||n.includes(`${s} not found`)||n.includes(e)||n.includes(t)||i.push(s)}return i}))}convertStoredItemToCounts(e){return{sessionEvents:this.actscToCounts(e.sessionEvents),customerEvents:this.actecToCounts(e.customerEvents)}}getAllJourneyStoredItems({sessionId:e,customerId:t}){return C(this,void 0,void 0,(function*(){const[i,s]=yield Promise.all([this.getSessionEventCounts(e),this.getCustomerEventCounts(t)]);return{sessionEvents:i,customerEvents:s}}))}getSessionEventCounts(e){return C(this,void 0,void 0,(function*(){const t=yield this.getCached(y.Actsc);return t&&t.includes(e)?t.substring(e.length+1):"0.0"}))}setSessionEventCounts(e,t){return this.setCached(y.Actsc,`${e}.${t}`,this.DEFAULT_EXPIRE_SESSION)}getCustomerEventCounts(e){return C(this,void 0,void 0,(function*(){const t=yield this.getCached(y.Actec);return t&&t.includes(e)?t.substring(e.length+1):"0.0"}))}setCustomerEventCounts(e,t){return this.setCached(y.Actec,`${e}.${t}`,this.DEFAULT_EXPIRE_CUSTOMER)}actecToCounts(e){let t={totalEventCount:0,totalPageviewCount:0};if(null!==e&&e.match(this.EVENT_COUNTS_REGEX)){const[i,s]=e.split(".").map((e=>parseInt(e,10)));t={totalEventCount:i,totalPageviewCount:s}}return t}actscToCounts(e){let t={sessionEventCount:0,sessionPageviewCount:0};if(null!==e&&e.match(this.EVENT_COUNTS_REGEX)){const[i,s]=e.split(".").map((e=>parseInt(e,10)));t={sessionEventCount:i,sessionPageviewCount:s}}return t}countsToActec(e){const{totalEventCount:t,totalPageviewCount:i}=e;return[t,i].join(".")}countsToActsc(e){const{sessionEventCount:t,sessionPageviewCount:i}=e;return[t,i].join(".")}setSessionReferrer(e){return C(this,void 0,void 0,(function*(){document.referrer&&(yield this.setCached(y.Actmr,`${e}.${document.referrer}`,this.DEFAULT_EXPIRE_SESSION))}))}getCached(e){return C(this,void 0,void 0,(function*(){if(this.useCache)return Promise.resolve(v[e]);const t=yield this.storageService.get(e);return v[e]=t,t}))}setCached(e,t,i){return C(this,void 0,void 0,(function*(){return this.useCache?Promise.resolve(t):this.storageService.set(e,t,i)}))}removeCached(e){return C(this,void 0,void 0,(function*(){return this.useCache?Promise.resolve(v[e]):this.storageService.remove(e)}))}}class A extends l{timeout(e){const t=window.setTimeout((()=>{this.notify()}),e);return()=>{window.clearTimeout(t)}}}const T=3e5;class P{constructor(){this.awayStatePublisher=new l,this.idleTimer=new A,this.initialized=!1,this.isAway=!1,this.hidden=!1,this.awayTimeout=T,this.awayTimestamp=0}onAwayStateChange(e){this.awayStatePublisher.subscribe(e)}init(e=false,t=3e5){this.isAway=e,this.awayTimeout=t,this.hidden=this.isHidden(),this.initialized||(this.idleTimer.subscribe((()=>this.checkAway())),window.onclick=()=>this.setActive(),window.onmousemove=()=>this.setActive(),window.onmouseenter=()=>this.setActive(),window.onkeydown=()=>this.setActive(),window.onscroll=()=>this.setActive(),window.onwheel=()=>this.setActive(),document.addEventListener("visibilitychange",(()=>this.handleVisibilityChange())),this.initialized=!0),this.start()}isHidden(){return!document.defaultView||"hidden"===document.visibilityState}handleVisibilityChange(){this.hidden=this.isHidden(),this.hidden?this.setAway():this.setActive()}setActive(){return this.awayTimestamp=Date.now()+this.awayTimeout,this.isAway&&(this.start(),this.awayStatePublisher.notify(!1)),this.isAway=!1,!0}checkAway(){const e=Date.now();if(e{if(!("XMLHttpRequest"in window)||null===window.XMLHttpRequest)return void s(new Error("XMLHttpRequest is not supported."));const n=new XMLHttpRequest;"withCredentials"in n?(n.onreadystatechange=function(){if(4===n.readyState)if(n.status>=400)s(function(e,t){let i,s="";try{const e=JSON.parse(t);i=e.message,s=e.param}catch(e){i=t}return e>=500?new I(i,e):new D(i,e,s)}(n.status,n.responseText));else try{const e=JSON.parse(n.responseText);i(e)}catch(e){s({error:"Request failed."})}},n.open("GET",function(e,t){const i=[];for(const[e,s]of Object.entries(t))i.push(`${encodeURIComponent(e)}=${encodeURIComponent(s)}`);return`${e}?${i.join("&")}`}(e,function(e){const t={};return Object.entries(e).forEach((([e,i])=>{null!=i&&""!==i&&(t[e]=i)})),t}(t)),!0),n.send()):s(new Error("XMLHttpRequest not made withCredentials cross-domain."))}))}var L,x=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};!function(e){e.WebMessagingOffer="webMessagingOffer",e.ContentOffer="contentOffer",e.OpenAction="openAction"}(L||(L={}));class k{constructor(e,t,i,s,n){this.log=e,this.identifiers=t,this.pageviewDetails=i,this.beaconPublisher=n,this.actionPublisher=new l,this.INITIAL_TIMEOUT=2e3,this.MIN_POLL_INTERVAL=1e4,this.MIN_RETRY_INTERVAL=6e4,this.MAX_RETRY_INTERVAL=12e4,this.MAX_RETRIES=5,this.MINIMUM_PINGS_BEFORE_SET_TIME_SINCE_LAST_BEACON_MILLIS=3,this.pollInterval=this.MIN_POLL_INTERVAL,this.isAway=!1,this.idle=new P,this.previousQualifiedActions=[],this.retries=0,this.pollTimer=new A,this.previousBeaconTime=Date.now(),this.numberOfPings=0,this.beaconObserver=()=>{this.pollInterval=this.MIN_POLL_INTERVAL,this.previousBeaconTime=Date.now(),this.clearTimeout&&this.clearTimeout(),this.clearTimeout=this.pollTimer.timeout(this.INITIAL_TIMEOUT)},this.pingApiEndpoint=`${s.apiEndpoint}/api/v2/journey/deployments/${s.deploymentId}/customers/`,this.beaconPublisher.subscribe(this.beaconObserver)}start(){this.idle.init(false,3e5),this.idle.onAwayStateChange((e=>this.isAway=e)),this.pollTimer.subscribe((()=>this.poll())),this.clearTimeout=this.pollTimer.timeout(this.INITIAL_TIMEOUT)}stop(){this.clearTimeout&&this.clearTimeout()}updatePageviewDetails(e){this.pageviewDetails=e}poll(){return x(this,void 0,void 0,(function*(){if(this.isAway)return this.log("visitor is idle"),void(this.clearTimeout=this.pollTimer.timeout(this.pollInterval));let e,t;this.log("visitor is active");try{const i=yield this.identifiers.getAll({createDisabled:!0,touchDisabled:!0});e=i.customerId,t=i.sessionId}catch(i){this.log("No identifiers returned."),e=null,t=null}if(null===t||null===e)return this.log("no session or customer identifier"),void(this.clearTimeout=this.pollTimer.timeout(this.pollInterval));const i=Date.now(),s={sessionId:t,t:i,dl:this.pageviewDetails.pageUrl,dt:this.pageviewDetails.pageTitle};this.numberOfPings>this.MINIMUM_PINGS_BEFORE_SET_TIME_SINCE_LAST_BEACON_MILLIS&&(s.sinceLastBeaconMilliseconds=i-this.previousBeaconTime);const n=`${this.pingApiEndpoint}${e}/ping`;try{const{actions:e,pollIntervalMilliseconds:t}=yield N(n,s);t&&(this.pollInterval=t),e&&e.length&&this.processActions(e),this.retries=0,this.numberOfPings++,this.createNextPoll(this.pollInterval)}catch(e){this.log.error("ping failed",e),this.retryPollIfPossible()}}))}createNextPoll(e){e>=0&&(this.clearTimeout=this.pollTimer.timeout(e))}processActions(e){const t=e.filter((e=>Object.values(L).includes(e.mediaType)));let i;if(0===this.previousQualifiedActions.length)i=t;else{const e=this.previousQualifiedActions.map((e=>e.id));i=t.filter((t=>!e.includes(t.id)))}i.length>0&&this.actionPublisher.notify(i),this.previousQualifiedActions=t}retryPollIfPossible(){if(this.log("ping retryIfPossible",{retries:this.retries}),0===this.retries)this.retries+=1,this.createNextPoll(this.pollInterval);else if(this.retries0)return parseInt(e.substring(t+5,e.indexOf(".",t)),10);if(e.indexOf("Trident/")>0){const t=e.indexOf("rv:");return parseInt(e.substring(t+3,e.indexOf(".",t)),10)}const i=e.indexOf("Edge/");return i>0&&parseInt(e.substring(i+5,e.indexOf(".",i)),10)}static isIframe(){try{return window.self!==window.top}catch(e){return!0}}static isBot(e){return U.BOT_REGEX.test(e)}static isWebRTCEnabled(){return!!window.RTCPeerConnection}static includesAnyPlugins(e){return!!navigator.plugins&&e.some((e=>{try{return null!==navigator.plugins.namedItem(e)}catch(e){return!1}}))}static isFlashEnabled(){return U.includesAnyPlugins(["Shockwave Flash"])}static isJavaEnabled(){return U.includesAnyPlugins(["Java Applet Plug-in"])}static isPdfEnabled(){return U.includesAnyPlugins(["Chrome PDF Plugin","Chrome PDF Viewer"])}}U.BOT_REGEX=/bot|crawler|search|spider|robot|crawling|BingPreview|facebookexternalhit|AddThis|HubSpot/i;class ${static getBrowserHeight(){return window.innerHeight}static getBrowserWidth(){return window.innerWidth}static getDeviceHeight(){return window.screen.height}static getDeviceWidth(){return window.screen.width}}function V(e){const t=Object.create({});return Object.keys(e).forEach((i=>{void 0!==e[i]&&Object.assign(t,{[i]:e[i]})})),t}class B{static getKeywords(){const e=document.getElementsByTagName("meta");for(let t=0;t{var i;try{navigator&&"function"==typeof navigator.sendBeacon&&navigator.sendBeacon(this.url)?e():this.create(this.url).then((()=>e())).catch((()=>t()))}catch(e){e instanceof Error&&(null===(i=this.logger)||void 0===i||i.error(e.message),t()),t()}}))}create(e){return new Promise(((t,i)=>{const s=document.createElement("img");s.width=1,s.height=1,s.src=e,s.onload=()=>{s.onload=null,t()},s.onerror=()=>{s.onerror=null,i()}}))}}class z{constructor(e,t,i,s){this.baseUrl=e,this.logger=s,this.beaconData=new H(t,i)}setData(e){this.beaconData.set(e)}send(){const e=encodeURIComponent(F().encode(j().encode(JSON.stringify(this.beaconData.mapDataToParameters())))),t=`${this.baseUrl}?data=${e}&type=${this.beaconData.type}`;return new q(t,this.logger).post()}}class W{static validate(e){const t=[];return["string","number","boolean"].includes(typeof e)||(null===e||Array.isArray(e)||"object"!=typeof e?t.push('custom attribute can only be of type "string", "number", "boolean" or "object"'):(Object.prototype.hasOwnProperty.call(e,"dataType")||t.push('required "dataType" property missing'),"string"!=typeof e.dataType&&t.push('"dataType" property needs to be a "string"'),Object.prototype.hasOwnProperty.call(e,"value")||t.push('required "value" property missing'),"string"!=typeof e.value&&t.push('"value" property needs to be a "string"'))),{errors:t}}}var G=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class X{constructor(e,t,i,s,n){this.config=e,this.storageService=t,this.logger=i,this.rateLimit=s,this.beaconPublisher=n,this.journeyStorage=new S(this.storageService)}collectBeaconData(e,t,i,s,n,r,o,a){return G(this,void 0,void 0,(function*(){const{customerId:c,sessionId:u}=e,h=`${this.config.apiEndpoint}/api/v2/journey/deployments/${this.config.deploymentId}/customers/${c}/beacons`,l=new z(h,c,a,this.logger),d=i.current-i.first,g=i.current-i.previous,m=this.getTraits(r,o),v=this.getCustomAttributes(r),p=document.referrer.length>0?document.referrer:null;return l.setData(Object.assign(Object.assign({sdkVersion:"2.1717.0",sessionId:u,sessionSecondsSinceFirst:d,sessionSecondsSincePrevious:g,sessionCount:t,pageReferrerUrl:p,sessionReferrerUrl:yield this.journeyStorage.getSessionReferrer(u),traits:m,attributes:v},s),n)),l}))}sendBeacon(e){return G(this,void 0,void 0,(function*(){yield this.rateLimit.schedule((()=>e.send().then((()=>this.beaconPublisher.notify()))))}))}setEventCountsCookie(e,t){return G(this,void 0,void 0,(function*(){yield this.journeyStorage.setEventCounts(e,t)}))}getCustomAttributes(e){return Object.values(e).forEach(((e,t)=>{const{errors:i}=W.validate(e);if(i.length)throw new Error(`Custom attribute at index ${t} invalid: ${i.join(", ")}.`)})),e}getTraits(e,t){const i={};return e&&Object.keys(e).length>0&&t.forEach((t=>{const s=t.fieldName,n=t.traitName||t.fieldName;e[s]&&Object.assign(i,{[n]:e[s]})})),i}}var J=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class Q extends X{constructor(e,t,i,s,n,r,o){super(s,n,e,r,o),this.log=e,this.pageviewDetailsManager=t,this.identifiers=i,this.beaconPublisher=o,this.cxCommandName="pageview"}process({data:e,resolve:t,reject:i}){return J(this,void 0,void 0,(function*(){let s;this.log("process()",e);try{s=yield this.identifiers.getAll()}catch(e){return void(i?i(`Error in pageview command: ${e}.`):this.log.warn(`${e}`))}const n=yield this.identifiers.getSessionCount(),r=yield this.identifiers.getSessionTimestamps(),{pageTitle:o,pageLocation:a,traitsMapper:c=[],customAttributes:u={}}=e,h=this.getPageviewDetails(o,a),l=yield this.updateEventCounts(s);this.pageviewDetailsManager.updatePageviewDetails(h);try{const e=yield this.collectBeaconData(s,n,r,h,l,u,c,M.Pageview);yield this.sendBeacon(e),yield this.setEventCountsCookie(s,l),t&&t()}catch(e){i?i(`Error in ${this.cxCommandName} command: ${e}.`):this.log.error({error:e})}}))}updateEventCounts(e){return J(this,void 0,void 0,(function*(){const t=yield this.journeyStorage.getEventCounts(e);return E.incrementEventCounts(t),E.incrementPageviewCounts(t),t}))}getPageviewDetails(e,t){return{pageTitle:e||document.title,pageUrl:t?this.parsePageUrl(t):document.location.href}}parsePageUrl(e){const t=document.createElement("a");return t.href=e.trim(),t.protocol=document.location.protocol,t.host=document.location.host,t.toString()}}class Y extends l{constructor(){super(...arguments),this.pageviewDetails={pageTitle:document.title,pageUrl:document.location.href}}getCurrentPageviewDetails(){return this.pageviewDetails}updatePageviewDetails(e){e.pageTitle===this.pageviewDetails.pageTitle&&e.pageUrl===this.pageviewDetails.pageUrl||(this.pageviewDetails=e,this.notify(this.pageviewDetails))}}var K=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class Z extends X{constructor(e,t,i,s,n,r,o){super(s,n,e,r,o),this.log=e,this.pageviewDetails=t,this.identifiers=i,this.beaconPublisher=o,this.cxCommandName="record"}process({data:e,resolve:t,reject:i}){return K(this,void 0,void 0,(function*(){this.log("process()",e);const{eventName:s,traitsMapper:n=[],customAttributes:r={}}=e;try{this.validateInput(s);const e=yield this.identifiers.getAll(),i=yield this.identifiers.getSessionCount(),o=yield this.identifiers.getSessionTimestamps(),a=yield this.updateEventCounts(e),c=yield this.collectBeaconData(e,i,o,this.pageviewDetails,a,r,n,M.Record);c.setData({eventName:s}),yield this.sendBeacon(c),yield this.setEventCountsCookie(e,a),t&&t()}catch(e){i?i(`Error in ${this.cxCommandName} command: ${e}.`):this.log.error(e.message||e)}}))}updatePageviewDetails(e){this.pageviewDetails=e}updateEventCounts(e){return K(this,void 0,void 0,(function*(){const t=yield this.journeyStorage.getEventCounts(e);return E.incrementEventCounts(t),t}))}validateInput(e){if("string"!=typeof e||""===e)throw new Error('"eventName" parameter must be a non-empty string')}}var ee=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class te{constructor(e,t,i,s){this.log=e,this.identifiers=t,this.pluginConfig=i,this.rateLimit=s}validateAndSendWebActionEvent(e,t,i){var s,n,r,o,a;return ee(this,void 0,void 0,(function*(){const{data:c}=e,{journeyContext:u}=c,{customerId:h,sessionId:l}=yield this.identifiers.getAll({createDisabled:!0,touchDisabled:!0});if(this.isProactive(c)&&h&&l)try{if(h===(null===(s=u.customer)||void 0===s?void 0:s.id)&&l===(null===(n=u.customerSession)||void 0===n?void 0:n.id)){const e=`${this.pluginConfig.apiEndpoint}/api/v2/journey/deployments/${this.pluginConfig.deploymentId}/customers/${h}/beacons`,s=new z(e,h,M.WebActionEvent,this.log);s.setData({sessionId:null===(r=u.customerSession)||void 0===r?void 0:r.id,actionId:u.triggeringAction.id,actionState:i,pageUrl:t.pageUrl,errorCode:null===(o=c.inviteError)||void 0===o?void 0:o.code,errorMessage:null===(a=c.inviteError)||void 0===a?void 0:a.reason}),yield this.rateLimit.schedule((()=>s.send()))}}catch(e){this.log.error({error:e})}}))}isProactive(e){return!!(e.journeyContext&&e.journeyContext.customer&&e.journeyContext.customer.id&&e.journeyContext.customerSession&&e.journeyContext.customerSession.id&&e.journeyContext.triggeringAction&&e.journeyContext.triggeringAction.id)}}class ie extends l{constructor(e){super(),this.formSelector=e,this.trackedForms=[]}initialize(){this.asArray(document.querySelectorAll(this.formSelector)).forEach((e=>{this.isFormTrackable(e)&&this.addFormHandler(e)})),this.watchForFormsChanges(),this.addBeforeUnloadHandler()}addFormHandler(e){const t=new m(e);t.subscribe((e=>this.notify(e))),this.trackedForms.push(t)}isFormTrackable(e){return e.querySelectorAll('input:not([type="hidden"])').length>=1}watchForFormsChanges(){new MutationObserver((e=>{e.forEach((({addedNodes:e,removedNodes:t})=>{e.forEach((e=>{"FORM"===e.tagName&&e.matches(this.formSelector)&&this.isFormTrackable(e)&&this.addFormHandler(e),e.querySelectorAll&&e.querySelectorAll("form").length&&this.asArray(e.querySelectorAll(this.formSelector)).filter((e=>"FORM"===e.tagName&&this.isFormTrackable(e))).forEach((e=>this.addFormHandler(e)))}));this.asArray(t).some((e=>"FORM"===e.tagName||e.querySelectorAll&&!!e.querySelectorAll("form").length))&&this.abandonMissingForms()}))})).observe(document,{childList:!0,subtree:!0})}abandonMissingForms(){this.trackedForms.filter((e=>e.getFormState()===o.Tracking)).forEach((e=>e.abandonIfMissing()))}abandonAllTrackedForms(){this.trackedForms.filter((e=>e.getFormState()===o.Tracking)).forEach((e=>e.setFormState(o.Abandoned)))}addBeforeUnloadHandler(){window.addEventListener(r.BeforeUnload,(()=>this.abandonAllTrackedForms()),!1)}asArray(e){return Array.prototype.slice.call(e)}}var se=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class ne{constructor(e,t){this.log=e,this.record=t,this.cxCommandName="formsTrack",this.DEFAULT_FORM_SELECTOR="form",this.DEFAULT_CAPTURE_DATA_ON_ABANDON=!1,this.DEFAULT_CAPTURE_DATA_ON_SUBMIT=!0}process({data:e,resolve:t,reject:i}){return se(this,void 0,void 0,(function*(){this.log("process()",e);try{const{formName:i,selector:s,customAttributes:n,traitsMapper:r,captureFormDataOnAbandon:a,captureFormDataOnSubmit:c,transformFormData:u}=this.parse(e),h=new ie(s);h.initialize(),h.subscribe((e=>se(this,void 0,void 0,(function*(){const{formState:t,formData:s,formLabel:h}=e,l=a&&t===o.Abandoned||c&&t===o.Submitted?u(s):{};yield this.record.process({data:{eventName:this.buildEventName(i,t),customAttributes:Object.assign({label:h},n,l),traitsMapper:r}})})))),t&&t()}catch(e){i?i(`Error in ${this.cxCommandName} command: ${e}.`):this.log.error({error:e})}}))}parse({formName:e,selector:t=this.DEFAULT_FORM_SELECTOR,traitsMapper:i=[],customAttributes:s={},captureFormDataOnAbandon:n=this.DEFAULT_CAPTURE_DATA_ON_ABANDON,captureFormDataOnSubmit:r=this.DEFAULT_CAPTURE_DATA_ON_SUBMIT,transformFormData:o}){return"function"!=typeof o&&(o=e=>e),{formName:e,selector:t,customAttributes:s,traitsMapper:i,captureFormDataOnAbandon:n,captureFormDataOnSubmit:r,transformFormData:o}}buildEventName(e,t){const i=["form",t];return e&&i.unshift(this.formatFormName(e)),i.join("_")}formatFormName(e){return e.toLowerCase().replaceAll(/[\s]+/gi,"_").replaceAll(/[^a-zA-Z0-9-_]/gi,"")}}class re{static onScrollDownEvent(e,t,i){e>=t.minDepth&&(t.scrollDepthEvents=t.scrollDepthEvents.filter((({percentage:t,eventName:s,customAttributes:n})=>{if(!(e>=t))return{percentage:t,eventName:s,customAttributes:n};i({percentage:t,eventName:s,customAttributes:n})})))}static findMaxDepth(e){const t=e.reduce(((e,t)=>({percentage:Math.max(e.percentage,t.percentage)})));return t.percentage>100?100:t.percentage}static findMinDepth(e){const t=e.reduce(((e,t)=>({percentage:Math.min(e.percentage,t.percentage)})));return t.percentage<0?0:t.percentage}static addEventName(e){return e.map((({eventName:e,percentage:t,customAttributes:i})=>({eventName:e=e||`scroll_depth_${Math.floor(t)}`,percentage:t,customAttributes:i})))}}var oe=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class ae{constructor(e,t,i){this.log=e,this.record=t,this.scrollDownTracker=i,this.cxCommandName="trackScrollDepth"}process({data:e,resolve:t,reject:i}){return oe(this,void 0,void 0,(function*(){this.log("process() ",e);try{const i=this.parse(e);if(i.scrollDepthEvents.length>0){const e=e=>{re.onScrollDownEvent(e,i,this.onMatchingConfig.bind(this)),e>=i.maxDepth&&(this.unsubscriber&&this.unsubscriber(),this.scrollDownTracker.stop())};this.unsubscriber&&this.unsubscriber(),this.unsubscriber=this.scrollDownTracker.subscribe(e),this.scrollDownTracker.start()}t&&t()}catch(e){i?i(`Error in ${this.cxCommandName} command: ${e}.`):this.log.error({error:e})}}))}parse({scrollDepthEvents:e=[]}){const t={minDepth:0,maxDepth:0,scrollDepthEvents:e};return e.length>0?(t.minDepth=re.findMinDepth(e),t.maxDepth=re.findMaxDepth(e),t.scrollDepthEvents=re.addEventName(e)):this.log.warn("scrollDepthEvents is empty. Array should have at least one item of { eventName, percentage }"),t}onMatchingConfig(e){return oe(this,void 0,void 0,(function*(){const{eventName:t,percentage:i,customAttributes:s}=e,n=Object.assign({},s,{percentage:i});yield this.record.process({data:{eventName:t,customAttributes:n}})}))}}class ce{addEventListener(e,t,i){return window.addEventListener(e,t,i),()=>{window.removeEventListener(e,t,i)}}createEventHandler(e,t){return i=>{e.filter((e=>this.hasMatchingConfig(i,e))).forEach((e=>{t(e)}))}}}class ue extends ce{constructor(){super(),this.EVENT_TYPE="scroll",this.useCapture=!0}addListener(e,t){const i=this.addInViewportProperty(e),s=this.createEventHandler(i,t);return s({}),this.addEventListener(this.EVENT_TYPE,s,this.useCapture)}hasMatchingConfig(e,t){const i=document.querySelector(t.selector);return this.isElementInViewport(i)!==t.inViewport&&(t.inViewport=!t.inViewport,!0)}isElementInViewport(e){if(e){const t=e.getBoundingClientRect();return null===e.getAttribute("hidden")&&t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}return!1}addInViewportProperty(e){return e.map((e=>Object.assign(e,{inViewport:!1})))}}var he=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class le{constructor(e,t){this.log=e,this.record=t,this.cxCommandName="trackInViewport",this.inViewportTracker=new ue,this.recordedEvents=[]}process({data:e,resolve:t,reject:i}){return he(this,void 0,void 0,(function*(){this.log("process() ",e);try{const i=this.parse(e);this.removeEventListener&&this.removeEventListener(),this.removeEventListener=this.inViewportTracker.addListener(i,this.onMatchingConfig.bind(this)),t&&t()}catch(e){i?i(`Error in ${this.cxCommandName} command: ${e}.`):this.log.error({error:e})}}))}resetRecordedEvents(){this.recordedEvents=[]}parse({inViewportEvents:e=[]}){return 0===e.length&&this.log.warn("inViewportEvents is empty. Array should have at least one item of { eventName, selector }"),e}onMatchingConfig({eventName:e,inViewport:t,customAttributes:i}){return he(this,void 0,void 0,(function*(){t&&!this.recordedEvents.includes(e)&&(this.recordedEvents.push(e),yield this.record.process({data:{eventName:e,customAttributes:i}}))}))}}class de extends ce{constructor(){super(),this.EVENT_TYPE="click",this.useCapture=!0}addListener(e,t){const i=this.createEventHandler(e,t);return this.addEventListener(this.EVENT_TYPE,i,this.useCapture)}hasMatchingConfig(e,{selector:t}){return e.target.matches(t)}}var ge=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class me{constructor(e,t){this.log=e,this.record=t,this.cxCommandName="trackClickEvents",this.clickTracker=new de}process({data:e,resolve:t,reject:i}){return ge(this,void 0,void 0,(function*(){this.log("process() ",e);try{const{clickEvents:i}=this.parse(e);this.removeEventListener&&this.removeEventListener(),this.removeEventListener=this.clickTracker.addListener(i,this.onMatchingConfig.bind(this)),t&&t()}catch(e){i?i(`Error in ${this.cxCommandName} command: ${e}.`):this.log.error({error:e})}}))}parse({clickEvents:e=[]}){return 0===e.length&&this.log.warn("clickEvents is empty. Array should have at least one item of { eventName, selector }"),{clickEvents:e}}onMatchingConfig(e){return ge(this,void 0,void 0,(function*(){const{eventName:t,customAttributes:i}=e;yield this.record.process({data:{eventName:t,customAttributes:i}})}))}}const ve=["click","keydown","mousewheel","mousemove","mouseenter","scroll","touchstart"],pe=["scroll"];class fe extends l{constructor(e=1e3,t=window,i=ve){super(),this.browserWindow=t,this.trackedDomEvents=i,this.throttledNotify=function(e,t){let i=!1;return(...s)=>{i||(i=!0,e(...s),setTimeout((()=>i=!1),t))}}((()=>this.notify()),e)}start(){const{addEventListener:e}=this.browserWindow;this.trackedDomEvents.forEach((t=>e(t,this.throttledNotify,pe.includes(t))))}stop(){const{removeEventListener:e}=this.browserWindow;this.trackedDomEvents.forEach((t=>e(t,this.throttledNotify,pe.includes(t))))}}class be{constructor(e){this.idleEvent=e,this.active=!1,this.initialized=!1,this.timer=new A}init(e){this.initialized||(this.timer.subscribe((()=>{this.active=!1,e()})),this.timerCancel=this.timer.timeout(1e3*this.idleEvent.idleAfterSeconds),this.active=!0,this.initialized=!0)}remove(){this.timerCancel&&this.timerCancel()}reset(){this.initialized&&(this.active=!0,this.remove(),this.timerCancel=this.timer.timeout(1e3*this.idleEvent.idleAfterSeconds))}restart(){this.active&&this.initialized&&this.reset()}}class we extends l{constructor(){super(...arguments),this.initialized=!1,this.activityTracker=new fe,this.timers=[]}initialize(e){this.initialized&&this.remove();this.validateEventsConfig(e).forEach((e=>{const t=new be(e);t.init((()=>this.notify(e))),this.timers.push(t)})),this.initialized||this.activityTracker.subscribe((()=>this.restartActiveTimers())),this.timers.length&&(this.activityTracker.start(),this.initialized=!0)}resetAllTimers(){this.timers.forEach((e=>e.reset()))}remove(){this.timers.forEach((e=>e.remove())),this.timers.splice(0,this.timers.length),this.activityTracker.stop()}restartActiveTimers(){this.timers.forEach((e=>e.restart()))}validateEventsConfig(e=[]){return e.filter((e=>e.idleAfterSeconds>=30&&d(e.eventName))).filter(((e,t,i)=>t===i.findIndex((t=>t.eventName===e.eventName))))}}var Ee,ye,Ce=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class Se{constructor(e,t){this.log=e,this.record=t,this.cxCommandName="trackIdleEvents",this.idleEventsTracker=new we,this.idleEventsTracker.subscribe((({eventName:e,customAttributes:t})=>Ce(this,void 0,void 0,(function*(){return yield this.record.process({data:{eventName:e,customAttributes:t}})}))))}resetIdleEventsTracker(){this.idleEventsTracker.resetAllTimers()}process({data:e,resolve:t,reject:i}){return Ce(this,void 0,void 0,(function*(){this.log("process() ",e);try{const i=this.parse(e);this.idleEventsTracker.initialize(i),t&&t()}catch(e){i?i(`Error in ${this.cxCommandName} command: ${e}.`):this.log.error({error:e})}}))}parse({idleEvents:e=[]}){const t=e.filter((e=>e.eventName&&e.idleAfterSeconds));return 0===t.length&&this.log.warn("idleEvents is empty. Array should have at least one item of { eventName, idleAfterSeconds }"),t}}!function(e){e.Authenticating="Auth.authenticating",e.Authenticated="Auth.authenticated",e.AuthError="Auth.authError",e.AuthProviderError="Auth.authProviderError",e.Error="Auth.error",e.TokenError="Auth.tokenError"}(Ee||(Ee={})),function(e){e.LoggedIn="logged_in",e.Error="login_error"}(ye||(ye={}));const Ae={};Ae[Ee.AuthError]="Authentication provider failed to respond with authCode and/or redirectUrl",Ae[Ee.AuthProviderError]="Problems with handling response from authentication provider",Ae[Ee.Error]="Token exchange failed",Ae[Ee.TokenError]="Token was not provided";class Te extends c{constructor(){super(...arguments),this.authEventPublisher=new l}subscribe(e){return this.plugin.subscribe(Ee.Authenticated,(()=>{this.authEventPublisher.notify({eventName:ye.LoggedIn})})),[Ee.AuthError,Ee.AuthProviderError,Ee.Error,Ee.TokenError].forEach((e=>this.plugin.subscribe(e,(()=>{this.authEventPublisher.notify({eventName:ye.Error,errorMessage:Ae[e]})})))),this.authEventPublisher.subscribe(e)}}var Pe,Ie=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class De{constructor(e,t,i,s,n){this.identifiers=e,this.pageviewDetailsManager=t,this.log=i,this.rateLimit=s,this.config=n,this.cxCommandName="recordActionStateChange"}process({data:e,resolve:t,reject:i}){return Ie(this,void 0,void 0,(function*(){this.log("process()",e);const{actionId:s,actionState:n,errorCode:r,errorReason:o}=e;try{this.validateInput(s,n);const e=this.pageviewDetailsManager.getCurrentPageviewDetails(),{customerId:i,sessionId:a}=yield this.identifiers.getAll({createDisabled:!0,touchDisabled:!0});if(i&&a){const t=`${this.config.apiEndpoint}/api/v2/journey/deployments/${this.config.deploymentId}/customers/${i}/beacons`,c=new z(t,i,M.WebActionEvent,this.log);c.setData({sessionId:a,actionId:s,actionState:n,pageUrl:e.pageUrl,errorCode:r,errorMessage:o}),yield this.rateLimit.schedule((()=>c.send()))}t&&t()}catch(e){i?i(`Error in ${this.cxCommandName} command: ${e}.`):this.log.error({error:e})}}))}validateInput(e,t){if(!(null==e?void 0:e.trim()))throw new Error("No actionId provided");const i=Object.values(O);if(!t||!i.includes(t))throw new Error(`"actionState" parameter must be one of: ${i.join(", ")}`)}}!function(e){e.Ready="SupportCenter.ready",e.PageLoaded="SupportCenter.pageLoaded"}(Pe||(Pe={}));class Ne extends c{static isSupportCenterPage(e){return!!e.supportCenter&&!!e.supportCenter.enabled&&!!document.getElementById("genesys-support-center")}onPageLoaded(e){return this.plugin.subscribe(Pe.PageLoaded,e)}ready(){return new Promise((e=>this.plugin.subscribe(Pe.Ready,(()=>e(!0)))))}}var Le=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class xe{constructor(e,t,i,s,n){this.cxPlugin=e,this.log=t,this.identifiers=s,this.pinger=n,this.cxCommandName="clear",this.journeyStorage=new S(i)}process({data:e,commander:t,resolve:i,reject:s}){var n;return Le(this,void 0,void 0,(function*(){this.log("process()",e),"Messenger"===t?(yield this.journeyStorage.removeAllStoredItems(),this.identifiers.disable(),null===(n=this.pinger)||void 0===n||n.stop(),this.cxPlugin.republish(je.Cleared),i&&i()):s&&s("Internal Clear command called. This command can only be called from the Messenger plugin.")}))}}var ke=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};class Oe{constructor(e,t){this.interval=t,this.queueIsPolling=!1,this.queue=[],this.tokens=[],this.tokens=Array(e).fill(0)}schedule(e){const t=this.addToQueue((function(){return ke(this,void 0,void 0,(function*(){return e()}))}));return this.queueIsPolling||this.pollQueue(),t}addToQueue(e){return new Promise((t=>{this.queue.push({fn:e,resolve:t})}))}tokenAvailable(){const e=Date.now(),t=this.tokens.findIndex((t=>t0&&this.tokenAvailable();){const e=this.queue.shift();if(e){const{fn:t,resolve:i}=e;t().then(i).catch(i)}}if(this.queue.length>0){const e=Math.min(...this.tokens)-Date.now();this.queueIsPolling=!0,window.setTimeout((()=>{this.pollQueue()}),e)}else this.queueIsPolling=!1}}function Me(e,t){let i,s=0;return(...n)=>{const r=Date.now();void 0!==i&&r-s<=t&&window.clearTimeout(i),s=r,i=window.setTimeout((()=>e(...n)),t)}}class Re{constructor(){this.initialPushState=window.history.pushState,this.initialReplaceState=window.history.replaceState}static dispatchBrowserAgnosticEvent(e){let t;"function"==typeof Event?t=new Event(e):(t=document.createEvent("Event"),t.initEvent(e,!0,!0)),window.dispatchEvent(t)}patchPushState(e){var t;window.history.pushState=(t=this.initialPushState,function(i,s,n){const r=t.apply(this,[i,s,n]);return Re.dispatchBrowserAgnosticEvent("pushState"),e(),r})}patchReplaceState(e){var t;window.history.replaceState=(t=this.initialReplaceState,function(i,s,n){const r=t.apply(this,[i,s,n]);return Re.dispatchBrowserAgnosticEvent("replaceState"),e(),r})}}class Fe extends l{constructor(){super(...arguments),this.previousUrl="",this.historyStatePatcher=new Re}start(e){const{history:t,addEventListener:i}=window;if(!t.pushState||!i)return;const s=(null==e?void 0:e.checkDelay)||150,n=Me(this.checkUrl.bind(this),s);this.checkUrl(),this.historyStatePatcher.patchReplaceState(n),this.historyStatePatcher.patchPushState(n),this.managePopstateListener(n)}checkUrl(){const e=this.previousUrl,t=location.href;this.notify({oldUrl:e,newUrl:t}),this.previousUrl=t}managePopstateListener(e){const t="popstate";this.removePopstateListener&&this.removePopstateListener(),this.removePopstateListener=()=>{window.removeEventListener(t,e)},window.addEventListener(t,e)}}class _e extends l{constructor(){super(...arguments),this.depthReached=0}start(e){const t=(null==e?void 0:e.debounceRate)||0;this.depthReached=this.getScrollDepthPercent(),this.depthReached>0&&this.notify(this.depthReached),this.manageScrollListener(t)}stop(){this.removeScrollListener&&this.removeScrollListener()}getScrollDepthPercent(){const e=document.documentElement.clientHeight;return((document.documentElement.scrollTop||document.body.scrollTop)+e)/(document.documentElement.scrollHeight||document.body.scrollHeight)*100}createEventHandler(){return()=>{const e=this.getScrollDepthPercent();e-this.depthReached>0&&this.notify(e),this.depthReached=e}}manageScrollListener(e=0){const t="scroll";let i=this.createEventHandler();i=e>0?Me(i,e):i,this.removeScrollListener&&this.removeScrollListener(),this.removeScrollListener=()=>{window.removeEventListener(t,i,true)},window.addEventListener(t,i,true)}}var je,Ue,$e,Ve,Be,He,qe=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};!function(e){e.QualifiedWebMessagingOffer="qualifiedWebMessagingOffer",e.QualifiedContentOffer="qualifiedContentOffer",e.QualifiedOpenAction="qualifiedOpenAction",e.Cleared="cleared"}(je||(je={})),function(e){e.Auto="Auto",e.Once="Once",e.Off="Off"}(Ue||(Ue={})),function(e){e.Pending="Pending",e.Active="Active",e.Inactive="Inactive",e.Error="Error",e.Deleting="Deleting"}($e||($e={})),function(e){e.Offered="Engage.inviteOffered",e.Accepted="Engage.inviteAccepted",e.Rejected="Engage.inviteRejected",e.Ignored="Engage.inviteIgnored",e.Errored="Engage.inviteError",e.Started="Conversations.started",e.Closed="Conversations.closed"}(Ve||(Ve={})),function(e){e.Opened="Offers.opened",e.Closed="Offers.closed",e.Errored="Offers.errored",e.Offered="Offers.offered",e.Ignored="Offers.ignored"}(Be||(Be={}));class ze{constructor(e,t,i){var s,n,r,o,a,c;this.cxPlugin=e,this.storageService=t,this.identifiersService=i,this.DEFAULT_PAGEVIEW_CONFIG=Ue.Auto,this.pageviewDetailsManager=new Y,this.WEB_MESSAGING_ACTION_STATES_MAP={[Ve.Offered]:O.Offered,[Ve.Accepted]:O.Accepted,[Ve.Rejected]:O.Rejected,[Ve.Errored]:O.Errored,[Ve.Ignored]:O.Ignored,[Ve.Started]:O.Started,[Ve.Closed]:O.Rejected},this.CONTENT_OFFER_STATES_MAP={[Be.Opened]:O.Accepted,[Be.Closed]:O.Rejected,[Be.Errored]:O.Errored,[Be.Offered]:O.Offered,[Be.Ignored]:O.Ignored},this.deploymentConfig=this.cxPlugin.data("GenesysJS.deploymentConfig");const u=this.cxPlugin.data("GenesysJS.snippetConfig"),{initData:h={}}=this.cxPlugin;this.pluginConfig={apiEndpoint:null!==(n=null===(s=h.deploymentConfig)||void 0===s?void 0:s.apiEndpoint)&&void 0!==n?n:this.deploymentConfig.apiEndpoint,deploymentId:null!==(o=null===(r=h.snippetConfig)||void 0===r?void 0:r.deploymentId)&&void 0!==o?o:u.deploymentId,journeyEvents:null!==(c=null===(a=h.deploymentConfig)||void 0===a?void 0:a.journeyEvents)&&void 0!==c?c:this.deploymentConfig.journeyEvents,authEnabled:!!this.deploymentConfig.auth&&this.deploymentConfig.auth.enabled},this.beaconsRateLimit=new Oe(50,1e4),this.logger=this.createNamespaceLogger("journey-plugin"),this.beaconPublisher=new l}initialize(e){return qe(this,void 0,void 0,(function*(){this.deploymentConfig.status===$e.Active?!0===this.pluginConfig.journeyEvents.enabled?(yield this.initializeCookies(e),this.initializePinger(),this.initializeEventHandler(),this.registerCommands(),this.setUpPageviews(),this.registerPublishableEvents(),this.pluginConfig.authEnabled&&this.subscribeToAuthEvents()):this.logger.info("Journey Events not enabled. Journey Plugin not initializing."):this.logger.info("Deployment not active. Journey Plugin not initializing.")}))}publishReady(){this.cxPlugin.ready()}buildBaseJourneyActionEvent(e){return{journeyContext:{triggeringAction:{id:e.id,actionMap:{id:e.actionMapId,version:e.actionMapVersion}}},state:O.Qualified}}createNamespaceLogger(e){return function(e,t){const i=(...i)=>t.log(`${e}:`,...i);return i.info=(...i)=>t.log.info(`${e}:`,...i),i.warn=(...i)=>t.log.warn(`${e}:`,...i),i.error=(...i)=>t.log.error(`${e}:`,...i),i}(e,this.cxPlugin)}initializeCookies(e){return qe(this,void 0,void 0,(function*(){const t=new S(this.storageService);yield t.initialize(e),yield t.removeInvalidStoredItems(e),this.cxPlugin.subscribe(f.IdentifiersPurged,(()=>qe(this,void 0,void 0,(function*(){return yield t.removeAllStoredItems()}))))}))}initializeEventHandler(){const e=new te(this.createNamespaceLogger("eventHandler"),this.identifiersService,this.pluginConfig,this.beaconsRateLimit);Object.values(Ve).forEach((t=>this.cxPlugin.subscribe(t,(i=>{e.validateAndSendWebActionEvent(i,this.pageviewDetailsManager.getCurrentPageviewDetails(),this.WEB_MESSAGING_ACTION_STATES_MAP[t])})))),Object.values(Be).forEach((t=>this.cxPlugin.subscribe(t,(i=>{e.validateAndSendWebActionEvent(i,this.pageviewDetailsManager.getCurrentPageviewDetails(),this.CONTENT_OFFER_STATES_MAP[t])}))))}initializePinger(){this.pinger=new k(this.createNamespaceLogger("pinger"),this.identifiersService,this.pageviewDetailsManager.getCurrentPageviewDetails(),this.pluginConfig,this.beaconPublisher),this.pageviewDetailsManager.subscribe((e=>{var t;return null===(t=this.pinger)||void 0===t?void 0:t.updatePageviewDetails(e)})),this.pinger.actionPublisher.subscribe((e=>qe(this,void 0,void 0,(function*(){const{sessionId:t}=yield this.identifiersService.getAll({createDisabled:!0,touchDisabled:!0});t&&e.forEach((e=>{var t,i;const s=this.buildBaseJourneyActionEvent(e);switch(e.mediaType){case L.ContentOffer:return this.republishPluginEvent(je.QualifiedContentOffer,Object.assign(s,{contentOfferProperties:e.contentOfferProperties}));case L.WebMessagingOffer:return this.republishPluginEvent(je.QualifiedWebMessagingOffer,(null===(t=e.webMessagingOfferProperties)||void 0===t?void 0:t.offerText)?Object.assign(s,{engageContent:{offerText:null===(i=e.webMessagingOfferProperties)||void 0===i?void 0:i.offerText}}):s);case L.OpenAction:return this.republishPluginEvent(je.QualifiedOpenAction,Object.assign(s,{openActionProperties:e.openActionProperties}));default:return void this.logger.error(`Action with an unrecognized media type was received - ${e.mediaType}.`)}}))})))),this.pinger.start()}registerCommands(){this.registerPageviewCommand(),this.registerRecordCommand(),this.registerFormsTrackCommand(),this.registerTrackScrollDepthCommand(),this.registerTrackInViewportCommand(),this.registerTrackClickEventsCommand(),this.registerTrackIdleEventsCommand(),this.registerActionStateChangeCommand(),this.registerClearCommand()}registerClearCommand(){const e=new xe(this.cxPlugin,this.createNamespaceLogger("clear"),this.storageService,this.identifiersService,this.pinger);this.registerCommand(e.cxCommandName,e.process.bind(e))}registerActionStateChangeCommand(){const e=new De(this.identifiersService,this.pageviewDetailsManager,this.createNamespaceLogger("actionStateChange"),this.beaconsRateLimit,this.pluginConfig);this.registerCommand(e.cxCommandName,e.process.bind(e))}registerFormsTrackCommand(){const e=new Z(this.createNamespaceLogger("record"),this.pageviewDetailsManager.getCurrentPageviewDetails(),this.identifiersService,this.pluginConfig,this.storageService,this.beaconsRateLimit,this.beaconPublisher),t=new ne(this.createNamespaceLogger("formsTrack"),e);this.pageviewDetailsManager.subscribe((t=>e.updatePageviewDetails(t))),this.registerCommand(t.cxCommandName,t.process.bind(t));const{formsTrackEvents:i}=this.pluginConfig.journeyEvents;null==i||i.forEach((e=>t.process({data:e})))}getPageviewCommand(){return this.pageviewCommand||(this.pageviewCommand=new Q(this.createNamespaceLogger("pageview"),this.pageviewDetailsManager,this.identifiersService,this.pluginConfig,this.storageService,this.beaconsRateLimit,this.beaconPublisher)),this.pageviewCommand}registerPageviewCommand(){const e=this.getPageviewCommand();this.registerCommand(e.cxCommandName,e.process.bind(e))}setUpPageviews(){var e;const t=this.getPageviewCommand(),i=null!==(e=this.pluginConfig.journeyEvents.pageviewConfig)&&void 0!==e?e:this.DEFAULT_PAGEVIEW_CONFIG;switch(i){case Ue.Auto:Ne.isSupportCenterPage(this.deploymentConfig)?(this.logger.info(`Configuration of pageview events tracking: "${i}". Enabling Support Center "page loaded" tracker.`),this.setUpSupportCenterTracker(t)):(this.logger.info(`Configuration of pageview events tracking: "${i}". Enabling URL change tracker.`),this.setUpUrlTracker(t));break;case Ue.Once:this.logger.info(`Configuration of pageview events tracking: "${i}". Sending single pageview event.`),t.process({data:{}});break;case Ue.Off:default:this.logger.info(`Configuration of pageview events tracking: "${i}". Disabling automated pageview events.`)}}setUpUrlTracker(e){const t=new Fe,i=Me((()=>{e.process({data:{}})}),100);t.subscribe((({oldUrl:e,newUrl:t})=>{e!==t&&i()})),t.start()}setUpSupportCenterTracker(e){new Ne(this.cxPlugin).onPageLoaded((()=>e.process({data:{}})))}republishPluginEvent(e,t){this.cxPlugin.republish(e,t)}registerPublishableEvents(){this.cxPlugin.registerEvents(Object.values(je))}registerCommand(e,t){this.cxPlugin.registerCommand(e,(e=>t(e)))}registerRecordCommand(){const e=new Z(this.createNamespaceLogger("record"),this.pageviewDetailsManager.getCurrentPageviewDetails(),this.identifiersService,this.pluginConfig,this.storageService,this.beaconsRateLimit,this.beaconPublisher);this.pageviewDetailsManager.subscribe((t=>e.updatePageviewDetails(t))),this.registerCommand(e.cxCommandName,e.process.bind(e))}registerTrackScrollDepthCommand(){const e=this.createNamespaceLogger("trackScrollDepth"),t=new Z(e,this.pageviewDetailsManager.getCurrentPageviewDetails(),this.identifiersService,this.pluginConfig,this.storageService,this.beaconsRateLimit,this.beaconPublisher),i=new _e,s=new ae(e,t,i);this.pageviewDetailsManager.subscribe((e=>t.updatePageviewDetails(e))),this.registerCommand(s.cxCommandName,s.process.bind(s));const{scrollDepthEvents:n}=this.pluginConfig.journeyEvents;(null==n?void 0:n.length)&&s.process({data:{scrollDepthEvents:n}})}registerTrackInViewportCommand(){const e=this.createNamespaceLogger("trackInViewport"),t=new Z(e,this.pageviewDetailsManager.getCurrentPageviewDetails(),this.identifiersService,this.pluginConfig,this.storageService,this.beaconsRateLimit,this.beaconPublisher),i=new le(e,t);this.pageviewDetailsManager.subscribe((e=>{i.resetRecordedEvents(),t.updatePageviewDetails(e)})),this.registerCommand(i.cxCommandName,i.process.bind(i));const{inViewportEvents:s}=this.pluginConfig.journeyEvents;(null==s?void 0:s.length)&&i.process({data:{inViewportEvents:s}})}registerTrackClickEventsCommand(){const e=this.createNamespaceLogger("trackClickEvents"),t=new Z(e,this.pageviewDetailsManager.getCurrentPageviewDetails(),this.identifiersService,this.pluginConfig,this.storageService,this.beaconsRateLimit,this.beaconPublisher),i=new me(e,t);this.pageviewDetailsManager.subscribe((e=>t.updatePageviewDetails(e))),this.registerCommand(i.cxCommandName,i.process.bind(i));const{clickEvents:s}=this.pluginConfig.journeyEvents;(null==s?void 0:s.length)&&i.process({data:{clickEvents:s}})}registerTrackIdleEventsCommand(){const e=this.createNamespaceLogger("trackIdleEvents"),t=new Z(e,this.pageviewDetailsManager.getCurrentPageviewDetails(),this.identifiersService,this.pluginConfig,this.storageService,this.beaconsRateLimit,this.beaconPublisher),i=new Se(e,t);this.pageviewDetailsManager.subscribe((e=>{i.resetIdleEventsTracker(),t.updatePageviewDetails(e)})),this.registerCommand(i.cxCommandName,i.process.bind(i));const{idleEvents:s}=this.pluginConfig.journeyEvents;(null==s?void 0:s.length)&&i.process({data:{idleEvents:s}})}subscribeToAuthEvents(){const e=new Te(this.cxPlugin),t=this.createNamespaceLogger("authEvents"),i=new Z(t,this.pageviewDetailsManager.getCurrentPageviewDetails(),this.identifiersService,this.pluginConfig,this.storageService,this.beaconsRateLimit,this.beaconPublisher);e.subscribe((({eventName:e,errorMessage:t})=>{const s={eventName:e};t&&(s.customAttributes={errorMessage:t}),i.process({data:{eventName:s.eventName,customAttributes:s.customAttributes,traitsMapper:s.traitsMapper}})}))}}!function(e){e.Get="LocalStorage.get",e.Set="LocalStorage.set",e.Remove="LocalStorage.remove"}(He||(He={}));class We extends u{constructor(e){super(e)}get(e){return this.plugin.command(He.Get,{name:e})}set(e,t,i){return this.plugin.command(He.Set,{name:e,value:t,expireInSecs:i})}remove(e){return this.plugin.command(He.Remove,{name:e})}}var Ge=function(e,t,i,s){return new(i||(i=Promise))((function(n,r){function o(e){try{c(s.next(e))}catch(e){r(e)}}function a(e){try{c(s.throw(e))}catch(e){r(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,a)}c((s=s.apply(e,t||[])).next())}))};Genesys("registerPlugin","Journey",(e=>Ge(void 0,void 0,void 0,(function*(){const[i]=yield Promise.all([Promise.any([a(t.Cookies,e),a(t.LocalStorage,e)]),a("Identifiers",e)]),s=i===t.LocalStorage?new We(e):new h(e),n=new w(e),r=new ze(e,s,n),o=yield n.getAll();yield r.initialize(o),r.publishReady()}))))})()})();