(self.webpackChunk_klaviyo_onsite_modules=self.webpackChunk_klaviyo_onsite_modules||[]).push([[9255],{47849:function(e,t,n){"use strict";n.d(t,{P:function(){return s},f:function(){return r}});const s="triggering-state-update";class r extends CustomEvent{constructor(e){super(s,{detail:e})}}},98241:function(e,t,n){"use strict";n.d(t,{Fz:function(){return i},IV:function(){return o},f5:function(){return s}});const s=()=>{const e="__storage_test__";try{return!("undefined"==typeof window||!window.localStorage)&&(window.localStorage.setItem(e,e),window.localStorage.removeItem(e),!0)}catch(e){return e instanceof DOMException&&(22===e.code||1014===e.code||"QuotaExceededError"===e.name||"NS_ERROR_DOM_QUOTA_REACHED"===e.name)&&window.localStorage&&0!==window.localStorage.length}};let r;const i=(e,t)=>{if(r=void 0===r?s():r,r)try{const n=window.localStorage.getItem(e);return null===n?null:((e,t)=>{switch(t){case"string":default:return e;case"json":return JSON.parse(e)}})(n,t)}catch(e){if(e instanceof Error&&"SecurityError"===e.name&&"The operation is insecure."===e.message)return null;throw e}return null},o=(e,t,n)=>{if(r=void 0===r?s():r,r){const s=((e,t)=>{switch(t){case"string":default:return e;case"json":return JSON.stringify(e)}})(t,n);return window.localStorage.setItem(e,s),s}return null}},10527:function(e,t,n){"use strict";n(92461),n(70818),n(44159);let s=function(e){return e.PAGE_VISITS="PAGE_VISITS",e.URL_PATH_PATTERNS="URL_PATH_PATTERNS",e.DELAY="DELAY",e.SCROLL_PERCENTAGE="SCROLL_PERCENTAGE",e.CART_CONTENT="CART_CONTENT",e.EXIT_INTENT="EXIT_INTENT",e.DESKTOP_MOBILE_TARGET="DESKTOP_MOBILE_TARGET",e.EXISTING_USER="EXISTING_USER",e.COOKIE_TIMEOUT="COOKIE_TIMEOUT",e.TEASER_TIMEOUT="TEASER_TIMEOUT",e.ELEMENT_EXISTS="ELEMENT_EXISTS",e.GEO_IP="GEO_IP",e.SUPPRESS_SUCCESS_FORM="SUPPRESS_SUCCESS_FORM",e.GROUPS_TARGETING="GROUPS_TARGETING",e.JS_CUSTOM_TRIGGER="JS_CUSTOM_TRIGGER",e.CHANNEL_TARGETING="CHANNEL_TARGETING",e}({});const r=[s.PAGE_VISITS,s.DELAY,s.SCROLL_PERCENTAGE,s.EXISTING_USER],i="update-event-listeners",o="form-triggered",a="onsite-event-publish";class l extends CustomEvent{constructor(e){super(a,{detail:e})}}const u=(e,t=1e3)=>{let n;const s=()=>{n&&(clearInterval(n),n=null)};return{start:()=>{s(),n=setInterval((()=>{e()}),t)},end:s}};var c=n(71721);const d=e=>{const t=()=>e();return{start:()=>{window.cookieStore&&(window.cookieStore.removeEventListener("change",t),window.cookieStore.addEventListener("change",t))},end:()=>{window.cookieStore&&window.cookieStore.removeEventListener("change",t)}}},E=e=>{if(!(0,c.Un)())return;const t=(0,c.zy)(),n=(0,c.oQ)(),{$email:r,$exchange_id:i,$phone_number:o}=t,{$email:a,_kx:l}=n,u=!!(r||i||o||a||l);e.publish({type:s.EXISTING_USER,payload:{isIdentified:u}})};var p=n(13552);var v=n(22314);var h=n(76898),T=n(23837);let f,S;const m=async({email:e,id:t,phoneNumber:n,exchangeId:s,anonymousId:r})=>{const i=window.__klKey;if((0,h.Z)(undefined,{email:e,id:t,phoneNumber:n,exchangeId:s,anonymousId:r}))return f;S||(S=(0,T.Z)({email:e,id:t,phoneNumber:n,exchangeId:s,klaviyoCompanyId:i,anonymousId:r}));const o=await S;return o?(f=o.data,f):null},g=(e,t)=>{const n=t===s.GROUPS_TARGETING?"groupsForms":"channelsForms";let r;return async()=>{const i=(()=>{if(!(0,c.Un)())return{};const{$email:e,$exchange_id:t,$phone_number:n,$id:s,$anonymous:r}=(0,c.zy)(),{$email:i,_kx:o}=(0,c.oQ)();return{email:null!=e?e:i,exchangeId:null!=t?t:o,phoneNumber:n,id:s,anonymousId:r}})(),o=!!(null!=i&&i.email||null!=i&&i.id||null!=i&&i.phoneNumber||null!=i&&i.exchangeId||null!=i&&i.anonymousId);if(!o||(0,h.Z)(r,i))return;r=i;const a=await m({email:null==i?void 0:i.email,phoneNumber:null==i?void 0:i.phoneNumber,exchangeId:null==i?void 0:i.exchangeId,id:null==i?void 0:i.id,anonymousId:null==i?void 0:i.anonymousId});a&&(o&&e.publish({type:s.EXISTING_USER,payload:{isIdentified:!0},metadata:{origin:"groups-and-channels-listener"}}),e.publish({type:t,payload:{[n]:a}}))}};var y=n(605);var _=n(93318);let I;const w=()=>({start:()=>{},end:()=>{}}),b={[s.PAGE_VISITS]:e=>{const t=t=>{const n={type:s.PAGE_VISITS,payload:{currentPageUrl:t}};e.publish(n)},n="navigation"in window?(e=>{if(!window.navigation)throw new Error("Navigation API is not available");let t="";const n=n=>{if(!(e=>"object"==typeof e&&null!==e&&"destination"in e&&"object"==typeof e.destination&&null!==e.destination&&"url"in e.destination&&"string"==typeof e.destination.url)(n))return;const s=n.destination.url;s!==t&&(t=s,e(s))};return{start:()=>{var s;t=window.location.href,e(t),null==(s=window.navigation)||null==s.addEventListener||s.addEventListener("navigate",n)},end:()=>{var e;null==(e=window.navigation)||null==e.removeEventListener||e.removeEventListener("navigate",n)}}})(t):(e=>{let t,n="";return{start:()=>{t=new MutationObserver((()=>{const t=window.location.href;t!==n&&(n=t,e(t))})),t.observe(document,{subtree:!0,childList:!0})},end:()=>{n="",t.disconnect()}}})(t);return{start:n.start,end:n.end}},[s.URL_PATH_PATTERNS]:w,[s.DELAY]:e=>{const{start:t,end:n}=u((()=>{e.publish({type:s.DELAY,payload:{elapsedTime:1e3}})}),1e3);return{start:t,end:n}},[s.EXISTING_USER]:e=>{let t,n;const s=()=>E(e);window.cookieStore?({start:t,end:n}=d(s)):({start:t,end:n}=u(s));return{start:()=>{E(e),t()},end:n}},[s.SUPPRESS_SUCCESS_FORM]:e=>{let t={};const n=()=>{(()=>{var e;const n=(0,p.ZP)();Object.keys((null==n||null==(e=n.modal)?void 0:e.disabledForms)||[]).forEach((e=>{var s;const r=null==n||null==(s=n.modal)||null==(s=s.disabledForms)||null==(s=s[e])?void 0:s.successActionTypes;t[e]=null!=r?r:[]}))})(),e.publish({type:s.SUPPRESS_SUCCESS_FORM,payload:{formSuccessActionsMap:t}})};return{start:()=>{n(),window.addEventListener(o,n)},end:()=>{t={},window.removeEventListener(o,n)}}},[s.COOKIE_TIMEOUT]:e=>{let t={};const n=()=>{(()=>{var e;const n=(0,p.ZP)();Object.keys((null==n||null==(e=n.modal)?void 0:e.disabledForms)||[]).forEach((e=>{var s;const r=null==n||null==(s=n.modal)||null==(s=s.disabledForms)||null==(s=s[e])?void 0:s.lastCloseTime;t[e]=null!=r?r:-1}))})(),e.publish({type:s.COOKIE_TIMEOUT,payload:{formLastCloseTimeMap:t}})};return{start:()=>{n(),window.addEventListener(o,n)},end:()=>{t={},window.removeEventListener(o,n)}}},[s.TEASER_TIMEOUT]:e=>{let t={};const n=()=>{(()=>{var e;const n=(0,p.ZP)();Object.keys((null==n||null==(e=n.modal)?void 0:e.disabledTeasers)||[]).forEach((e=>{var s;const r=null==n||null==(s=n.modal)||null==(s=s.disabledTeasers)||null==(s=s[e])?void 0:s.lastCloseTime;t[e]=null!=r?r:-1}))})(),e.publish({type:s.TEASER_TIMEOUT,payload:{teaserLastCloseTimeMap:t}})};return{start:()=>{n(),window.addEventListener(o,n)},end:()=>{t={},window.removeEventListener(o,n)}}},[s.GROUPS_TARGETING]:e=>{let t,n;const r=g(e,s.GROUPS_TARGETING);window.cookieStore?({start:t,end:n}=d(r)):({start:t,end:n}=u(r));return{start:()=>{r(),t()},end:n}},[s.CHANNEL_TARGETING]:e=>{let t,n;const r=g(e,s.CHANNEL_TARGETING);window.cookieStore?({start:t,end:n}=d(r)):({start:t,end:n}=u(r));return{start:()=>{r(),t()},end:n}},[s.SCROLL_PERCENTAGE]:e=>{let t=0;const n=()=>{const n=(0,y.Z)(!0);Math.floor(n)!==Math.floor(t)&&(t=n,(t=>{const n={type:s.SCROLL_PERCENTAGE,payload:{percentage:Math.floor(t)}};e.publish(n)})(n))};return{start:()=>{window.addEventListener("scroll",n)},end:()=>{window.removeEventListener("scroll",n)}}},[s.ELEMENT_EXISTS]:e=>{const t=t=>{for(const n of t)if("childList"===n.type&&(n.addedNodes.length>0||n.removedNodes.length>0))return void e.publish({type:s.ELEMENT_EXISTS,payload:{pageChanged:!0}})};return{start:()=>{var e;I||(I=new MutationObserver(t)),null==(e=I)||e.observe(document.body,{childList:!0,subtree:!0,attributes:!1,characterData:!1})},end:()=>{I&&(I.disconnect(),I=void 0)}}},[s.CART_CONTENT]:w,[s.EXIT_INTENT]:w,[s.DESKTOP_MOBILE_TARGET]:e=>({start:()=>{(()=>{const t=(0,v.Z)()?"MOBILE":"DESKTOP";e.publish({type:s.DESKTOP_MOBILE_TARGET,payload:{deviceType:t}})})()},end:()=>{}}),[s.GEO_IP]:e=>{const t=async()=>{const t=await(async()=>{const e=await(0,_.Z)();if(!e)return null;const{data:t}=await e;return t})();if(!t)return void e.publish({type:s.GEO_IP,payload:{geoIpData:null}});const{countryCode:n,continentCode:r}=t;e.publish({type:s.GEO_IP,payload:{geoIpData:{countryCode:n,continentCode:`con_${r}`}}})};return{start:()=>{t()},end:()=>{}}},[s.JS_CUSTOM_TRIGGER]:w};var L=n(25598);class O extends Error{constructor(e){(0,L.Oc)(e),super(e)}}const R=e=>{e instanceof Error?(0,L.Oc)("Error initializing event adapter",{message:e.message,stack:e.stack}):(0,L.Oc)("Error initializing event adapter",{message:String(e)})};var C=new class{constructor(){this._activeListeners=void 0,this.boundHandleUpdateEvent=void 0,this._activeListeners=new Map,this.boundHandleUpdateEvent=this.handleUpdateEvent.bind(this)}get activeListenerTypes(){return Array.from(this.activeListeners.keys())}get activeListeners(){return this._activeListeners}start(){this.subscribeToUpdates(),this.startListeners(r)}stop(){this.unsubscribeFromUpdates(),this.stopAllActiveListeners()}startListeners(e){e.forEach((e=>{if(this.activeListeners.has(e))return;const t=b[e];if(!t){throw new O(`Listener for event type ${e} not found`)}const n=t(this);this.activeListeners.set(e,n),n.start()}))}stopAllActiveListeners(){this.activeListenerTypes.forEach((e=>this.stopListener(e)))}publish(e){const t=new l(e);window.dispatchEvent(t),e.type===s.EXISTING_USER&&e.payload.isIdentified&&this.stopListener(s.EXISTING_USER)}stopListener(e){const t=this.activeListeners.get(e);null==t||null==t.end||t.end(),this.activeListeners.delete(e)}subscribeToUpdates(){window.addEventListener(i,this.boundHandleUpdateEvent)}unsubscribeFromUpdates(){window.removeEventListener(i,this.boundHandleUpdateEvent)}handleUpdateEvent(e){try{if(!this.isUpdateEventListenersEvent(e))return;this.updateEvents(e.detail.eventsToWatch)}catch(e){R(e)}}updateEvents(e){this.activeListenerTypes.filter((t=>!e.includes(t)&&!r.includes(t))).forEach((e=>this.stopListener(e))),this.startListeners(e)}isUpdateEventListenersEvent(e){return e instanceof CustomEvent&&e.detail&&Array.isArray(e.detail.eventsToWatch)}},A=n(47849),N=n(71502);var U=function(e,t,n,s){for(var r=e.length,i=n+(s?1:-1);s?i--:++i-1};var j=function(e,t,n){for(var s=-1,r=null==e?0:e.length;++s=200){var u=t?null:Z(e);if(u)return(0,H.Z)(u);o=!1,r=D.Z,l=new N.Z}else l=t?[]:a;e:for(;++s{var e,t;const n=null!=(e=null==(t=sessionStorage)||null==t.getItem?void 0:t.getItem($))?e:"";if(!n||0===n.length)return[];let s;try{s=JSON.parse(n)}catch(e){throw Error(`klaviyoPagesVisitCount in sessionStorage is not JSON parsable ${n}`)}if(Array.isArray(s))return s;throw Error(`klaviyoPagesVisitCount in sessionStorage is not an array ${s}`)},Q=(e,t)=>{var n;const s=(e=>{if(e)return e.split("?")[0]})(null==(n=t.payload)?void 0:n.currentPageUrl);if(!(r=s,"string"==typeof r&&r.trim().length>0&&s!==e.currUrl))return e;var r;const i=K([...e.visitedUrls,s]),o=Object.assign({},e,{visitedUrls:i,currUrl:s,elapsedTimeOnCurrentPage:0});return(e=>{try{sessionStorage.setItem($,JSON.stringify(e))}catch(e){e instanceof Error&&(0,L.Oc)("Failed to save visited URLs to sessionStorage",{message:e.message,stack:e.stack})}})(o.visitedUrls),o},V=()=>({visitedUrls:z(),currUrl:"",elapsedTime:0,elapsedTimeOnCurrentPage:0,isIdentified:!1,formLastCloseTimeMap:{},teaserLastCloseTimeMap:{},formSuccessActionsMap:{},groupsForms:[],channelsForms:[],scrollPercentage:0,geoIpData:null,deviceType:null}),J=(e,t)=>{switch(t.type){case s.PAGE_VISITS:return Q(e,t);case s.DELAY:return((e,t)=>{var n;return Object.assign({},e,{elapsedTime:e.elapsedTime+(null!=(n=t.payload.elapsedTime)?n:0)})})(e,t);case s.EXISTING_USER:return((e,t)=>{var n;return Object.assign({},e,{isIdentified:null!=(n=t.payload.isIdentified)?n:e.isIdentified})})(e,t);case s.COOKIE_TIMEOUT:return((e,t)=>Object.assign({},e,{formLastCloseTimeMap:Object.assign({},e.formLastCloseTimeMap,t.payload.formLastCloseTimeMap)}))(e,t);case s.TEASER_TIMEOUT:return((e,t)=>Object.assign({},e,{teaserLastCloseTimeMap:Object.assign({},e.teaserLastCloseTimeMap,t.payload.teaserLastCloseTimeMap)}))(e,t);case s.SUPPRESS_SUCCESS_FORM:return((e,t)=>Object.assign({},e,{formSuccessActionsMap:Object.assign({},e.formSuccessActionsMap,t.payload.formSuccessActionsMap)}))(e,t);case s.GROUPS_TARGETING:return((e,t)=>{var n;return Object.assign({},e,{groupsForms:null!=(n=t.payload.groupsForms)?n:e.groupsForms})})(e,t);case s.CHANNEL_TARGETING:return((e,t)=>{var n;return Object.assign({},e,{channelsForms:null!=(n=t.payload.channelsForms)?n:e.channelsForms})})(e,t);case s.SCROLL_PERCENTAGE:return((e,t)=>{var n;return Object.assign({},e,{scrollPercentage:null!=(n=t.payload.percentage)?n:e.scrollPercentage})})(e,t);case s.GEO_IP:return((e,t)=>{var n;return Object.assign({},e,{geoIpData:null!=(n=t.payload.geoIpData)?n:e.geoIpData})})(e,t);case s.DESKTOP_MOBILE_TARGET:return((e,t)=>{var n;return Object.assign({},e,{deviceType:null!=(n=t.payload.deviceType)?n:e.deviceType})})(e,t);default:return e}};class B{constructor(){this.items=void 0,this.items=[]}get top(){return this.items[this.items.length-1]}get length(){return this.items.length}push(e){this.items.push(e),this.length>100&&this.shift()}pop(){return this.items.pop()}set(e,t){this.items[e]=t}clear(){this.items.splice(1e3)}shift(){return this.items.splice(50,this.length-50)}}var Y=new class{constructor(){this.eventQueue=void 0,this.eventsWithoutStateMutation=[s.ELEMENT_EXISTS],this.boundHandleEvent=void 0,this.eventQueue=new B,this.eventQueue.push({state:V()}),this.boundHandleEvent=this.handleEvent.bind(this)}get state(){var e;return(null==(e=this.eventQueue.top)?void 0:e.state)||V()}get lastEventType(){var e;return null==(e=this.eventQueue.top)||null==(e=e.event)?void 0:e.type}start(){this.subscribe()}stop(){this.unsubscribe(),this.eventQueue.clear()}publish(){const e=new A.f({eventType:this.lastEventType,state:this.state});window.dispatchEvent(e)}subscribe(){window.addEventListener(a,this.boundHandleEvent)}unsubscribe(){window.removeEventListener(a,this.boundHandleEvent)}handleEvent(e){try{this._handleEvent(e.detail)}catch(e){R(e)}}_handleEvent(e){const t=J(this.state,e);(0,h.Z)(this.state,t)&&!this.eventsWithoutStateMutation.includes(e.type)||(e.type===s.DELAY&&this.lastEventType===s.DELAY&&this.eventQueue.pop(),this.eventQueue.push({event:e,state:t}),this.publish())}};(()=>{try{Y.start(),C.start()}catch(e){R(e)}})()},51311:function(e,t,n){var s,r,i,o,a,l,u,c,d,E,p,v,h,T,f,S;i=function(e,t,n){if(!d(t)||p(t)||v(t)||h(t)||c(t))return t;var s,r=0,o=0;if(E(t))for(s=[],o=t.length;r