(self.webpackChunk_klaviyo_onsite_modules=self.webpackChunk_klaviyo_onsite_modules||[]).push([[7913,4928],{47849:function(e,t,n){"use strict";n.d(t,{P:function(){return r},f:function(){return i}});const r="triggering-state-update";class i extends CustomEvent{constructor(e){super(r,{detail:e})}}},94988:function(e,t,n){"use strict";n.d(t,{Gi:function(){return a},KS:function(){return i}});var r=n(12276);class i extends CustomEvent{constructor(e){super(r.Rc,{detail:e})}}const o=[],s=e=>{const t=new i(e);window.dispatchEvent(t)},a=e=>{if(window.onsiteTelemetryLoaded){for(;o.length>0;){const e=o.shift();e&&s(e)}s(e)}else o.push(e)}},12276:function(e,t,n){"use strict";n.d(t,{Rc:function(){return r},T4:function(){return s},Xf:function(){return o},lv:function(){return i}});const r="ONSITE_TELEMETRICS_EVENT",i="visitor-tracking",o="signup-forms",s="onsite_visitor_tracking"},88176:function(e,t,n){"use strict";n.d(t,{UF:function(){return P},mq:function(){return U},oO:function(){return O},rN:function(){return j}});const r="qualify",i="open",o="close",s="closeTeaser",a="submit",c="stepSubmit",u="embedOpen",d="redirectedToUrl",l="subscribedViaSMS",f="failedAgeGate",v="viewedStep",p="redirectedToUrlFromStep",m="submitOptInCode",g="triggeredBotProtection",y="falsePositiveBotProtection",w="requestBlockedByWAF",_="redirectedToDeepLink",h="clickedRedirectToInbox",S="hideRedirectToInbox",E="failedToRedirectToInbox",b="submitBackInStockForm",k="dynamicButtonBackInStockClicked",T="dynamicButtonBackInStockPlaced",I="submitBackInStockStep",O="klaviyojsSessionStarted",U="userIdentified",j={[r]:"qualifyModal",[i]:"openModal",[o]:"closeModal",[s]:"closeTeaser",[a]:"submitModal",[c]:"stepSubmit",errorView:"showErrorView",[u]:"loadedEmbed",[d]:"redirectedToUrl",[l]:"subscribedViaSMS",submitRateLimit:"submitRateLimit",klaviyoBranding:"clickedKlaviyoBranding",showEmailField:"showEmailField",showShopLogin:"showShopLogin",shopLoginSuccess:"shopLoginSuccess",[f]:"failedAgeGate",[v]:"viewedStep",[p]:"redirectedToUrlFromStep",[m]:"submitOptInCode",resendOptInCode:"resendOptInCode",openFormActionFormOpened:"openFormActionFormOpened",[g]:"triggeredBotProtection",[y]:"falsePositiveBotProtection",[w]:"requestBlockedByWAF",submitSpinToWin:"submitSpinToWin",receivedOutcomeView:"receivedOutcomeView",receivedOutcomeViewAndCouponCode:"receivedOutcomeViewAndCouponCode",[_]:"redirectedToDeepLink",[h]:h,[S]:S,[E]:E,[b]:"submitBackInStockForm",[k]:"dynamicButtonBackInStockClicked",[T]:"dynamicButtonBackInStockPlaced",[I]:"submitBackInStockStep",[O]:O,[U]:U},C="viewed_form",x="engaged_with_form",B="submitted_form_step",L="bot_protection",P={[r]:"qualified_form",[i]:C,[o]:"closed_form",[s]:"closed_teaser",[u]:C,[a]:x,[d]:x,[l]:x,[m]:x,[f]:"failed_age_gate",[v]:"viewed_form_step",[c]:B,[p]:B,[g]:L,[y]:L,[w]:L,[_]:x,[b]:"submitted_back_in_stock_form",[k]:"dynamic_button_back_in_stock_clicked",[T]:"dynamic_button_back_in_stock_placed",[I]:"submitted_back_in_stock_form_step",[O]:"klaviyojs_session_started",[U]:"user_identified"}},53236:function(e,t,n){"use strict";var r=n(12276),i=n(88176),o=n(47849),s=n(25598),a=n(84509),c=n(46456),u=n(27655),d=function(){return u.Z.Date.now()},l=/\s/;var f=function(e){for(var t=e.length;t--&&l.test(e.charAt(t)););return t},v=/^\s+/;var p=function(e){return e?e.slice(0,f(e)+1).replace(v,""):e},m=n(11412),g=/^[-+]0x[0-9a-f]+$/i,y=/^0b[01]+$/i,w=/^0o[0-7]+$/i,_=parseInt;var h=function(e){if("number"==typeof e)return e;if((0,m.Z)(e))return NaN;if((0,c.Z)(e)){var t="function"==typeof e.valueOf?e.valueOf():e;e=(0,c.Z)(t)?t+"":t}if("string"!=typeof e)return 0===e?e:+e;e=p(e);var n=y.test(e);return n||w.test(e)?_(e.slice(2),n?2:8):g.test(e)?NaN:+e},S=Math.max,E=Math.min;var b=function(e,t,n){var r,i,o,s,a,u,l=0,f=!1,v=!1,p=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var n=r,o=i;return r=i=void 0,l=t,s=e.apply(o,n)}function g(e){return l=e,a=setTimeout(w,t),f?m(e):s}function y(e){var n=e-u;return void 0===u||n>=t||n<0||v&&e-l>=o}function w(){var e=d();if(y(e))return _(e);a=setTimeout(w,function(e){var n=t-(e-u);return v?E(n,o-(e-l)):n}(e))}function _(e){return a=void 0,p&&r?m(e):(r=i=void 0,s)}function b(){var e=d(),n=y(e);if(r=arguments,i=this,u=e,n){if(void 0===a)return g(u);if(v)return clearTimeout(a),a=setTimeout(w,t),m(u)}return void 0===a&&(a=setTimeout(w,t)),s}return t=h(t)||0,(0,c.Z)(n)&&(f=!!n.leading,o=(v="maxWait"in n)?S(h(n.maxWait)||0,t):o,p="trailing"in n?!!n.trailing:p),b.cancel=function(){void 0!==a&&clearTimeout(a),l=0,r=u=i=a=void 0},b.flush=function(){return void 0===a?s:_(d())},b},k=n(5645),T=n.n(k),I=(n(92461),n(60873),n(87100)),O=n(83187),U=n(93648),j=n(71721),C=n(22314),x=n(12948),B=n(75902),L=n(267);const P="__kla_session",H=(()=>{const e="https:"===window.location.protocol;return{path:"/",sameSite:e?"None":"Lax",secure:e}})(),N=(e,t)=>{(0,B.zP)(e,t,1800,Object.assign({},H))},R=async({updateExpiryTime:e=!0,_isRecoveryAttempt:t=!1}={})=>{if(!await(async()=>{var e,t;if("true"===(0,B.ej)("__kla_off"))return!1;const n=null==(e=window.Shopify)||null==(e=e.customerPrivacy)||null==e.userCanBeTracked?void 0:e.userCanBeTracked(),r=await(null==(t=window.klaviyo)||null==t.account?void 0:t.account()),i="string"==typeof r&&r.length>0;return n||i})())return;const n=(0,B.ej)(P);if(!n){const e={sessionId:(0,L.Z)(),sentSessionStartedEvent:!1,sentUserIdentifiedEvent:!1};return r=P,i=JSON.stringify(e),(0,B.d8)(r,i,1800,Object.assign({},H)),e}var r,i;try{e&&N(P,n);const r=JSON.parse(n);if((e=>"object"==typeof e&&null!==e&&"sessionId"in e&&"string"==typeof e.sessionId&&"sentSessionStartedEvent"in e&&"boolean"==typeof e.sentSessionStartedEvent&&"sentUserIdentifiedEvent"in e&&"boolean"==typeof e.sentUserIdentifiedEvent)(r))return r;if(!t)return(0,s.Yd)("Malformed session cookie detected, attempting recovery"),(e=>{(0,B.kT)(e,Object.assign({},H))})(P),R({updateExpiryTime:e,_isRecoveryAttempt:!0});throw new Error(`Malformed session cookie: ${r}`)}catch(e){return void(0,s.Yd)("Error parsing session cookie",{error:e,stack:e instanceof Error?e.stack:void 0})}};let M=Promise.resolve(!1);const $=({sentSessionStartedEvent:e=!1,sentUserIdentifiedEvent:t=!1})=>(M=M.then((async()=>{const n=await R({updateExpiryTime:!1});if(!n)return!1;const r=Object.assign({},n);let i=!1;return e&&!n.sentSessionStartedEvent&&(r.sentSessionStartedEvent=!0,i=!0),t&&!n.sentUserIdentifiedEvent&&(r.sentUserIdentifiedEvent=!0,i=!0),i&&N(P,JSON.stringify(r)),i})).catch((e=>((0,s.Yd)("Error updating session cookie",{error:e,stack:null==e?void 0:e.stack}),!1))),M),F=["formId","form_id"],A=async(e,t)=>{const n=(0,U.$j)(window.location.toString()),r=(0,j.af)(),o=(0,j.FU)(),s=(0,C.Z)()?"MOBILE":"DESKTOP",a=Object.keys(i.rN),c=Object.values(i.rN),u=t?await(async({updateExpiryTime:e=!0}={})=>{const t=await R({updateExpiryTime:e});return null==t?void 0:t.sessionId})():void 0;return e.map((e=>{var t,d,l,f,v,p;const m=(e=>e in i.rN)(e.metric)?i.rN[e.metric]:e.metric;if(!a.includes(m)&&!c.includes(m))throw new Error(`Invalid metric: ${m}`);const g=i.UF[e.metric],y=e.eventDetails||{},{formId:w,form_id:_}=y,h=T()(y,F),S=null!=w?w:_;return{metric:m,metric_service_event_name:null!=(t=e.metricServiceEventName)?t:g,log_to_statsd:null==(d=e.logToStatsd)||d,statsd_info:e.statsdInfo,log_to_s3:null==(l=e.logToS3)||l,log_to_metrics_service:null!=(f=e.logToMetricsService)?f:!!g,event_details:Object.assign({},h,n,{form_id:S,device_type:s,hostname:window.location.hostname,href:window.location.href,page_url:`${window.location.origin}${window.location.pathname}`,first_referrer:null==o||null==(v=o.$referrer)?void 0:v.first_page,referrer:null==o||null==(p=o.$last_referrer)?void 0:p.first_page,user_agent:navigator.userAgent,locale:navigator.language},r||{},{klaviyo_js_session_id:u})}}))},q=async e=>{const{metricGroup:t,events:n,companyId:i,sample:o=1,useSession:s=!0}=e.detail;try{const e=await A(n,s),a=await(({metricGroup:e,events:t,companyId:n,sample:r=1})=>Math.random()>r?Promise.resolve(null):(0,I.Z)(`https://a.klaviyo.com/onsite/track-analytics?company_id=${n}`,{method:"POST",mode:"no-cors",body:JSON.stringify((0,O.Y)({metricGroup:e,events:t})),headers:{"Content-Type":"application/json",accept:"application/json"}}))({metricGroup:t||r.Xf,companyId:i,sample:o,events:e});return a}catch(e){return((e,t)=>{const n="undefined"!=typeof ProgressEvent&&e instanceof ProgressEvent||void 0!==window.XMLHttpRequestProgressEvent&&e instanceof window.XMLHttpRequestProgressEvent,r=e instanceof Error;!n&&r&&(0,x.T)(e,{tags:{logMetric:"True"},extra:{events:t}})})(e,n),null}};var z=n(94988);const Z=()=>{const e=window.klaviyoModulesObject;return null==e?void 0:e.companyId},Y=(e,t,n)=>{var r;if(!i.UF[e])return null;const o=null==(r=(0,j.zy)())?void 0:r.$exchange_id;return[Object.assign({metric:e,metricServiceEventName:i.UF[e],logToMetricsService:!0,logToS3:!0,logToStatsd:!0,statsdInfo:void 0},n,{eventDetails:{exchangeId:o,isIdentified:t.isIdentified,isClient:!0}})]};var D=new class{constructor(){this._eventHandlers=new Map}get eventHandlers(){return this._eventHandlers}registerEventHandler(e,t,n){this._eventHandlers.has(e)&&this.unregisterEventHandler(e),this._eventHandlers.set(e,{eventType:t,callback:n}),window.addEventListener(t,n)}unregisterEventHandler(e){const t=this._eventHandlers.get(e);t&&(this._eventHandlers.delete(e),window.removeEventListener(t.eventType,t.callback))}clear(){for(const e of this._eventHandlers.values())window.removeEventListener(e.eventType,e.callback);this._eventHandlers.clear()}};const V="sentSessionStartedEvent";let K=!1;const G=()=>{if(K)return!0;try{var e;return JSON.parse(null!=(e=sessionStorage.getItem(V))?e:"false")}catch(e){return(0,s.Yd)(`Error getting session started event in session storage: ${e}`),!0}},J="sentUserIdentifiedEvent";let W=!1;const X=()=>{if(W)return!0;try{var e;return JSON.parse(null!=(e=sessionStorage.getItem(J))?e:"false")}catch(e){return(0,s.Yd)(`Error getting user identified event in session storage: ${e}`),!0}},Q=e=>{let t=!1;return b((async n=>{if(!t){t=!0;try{await e(n)}catch(e){(0,s.Yd)("Error visitor tracking event handler",{error:e,stack:e instanceof Error?e.stack:void 0})}finally{t=!1}}}),500)},ee=Q((async({detail:e})=>{if(G())return void D.unregisterEventHandler(i.oO);if(!(({visitedUrls:e,elapsedTime:t,scrollPercentage:n})=>e.length>=2||t>=1e4||n>=50)(e.state))return;if(!await $({sentSessionStartedEvent:!0}))return;const t=r.lv,n=Z(),o=Y(i.oO,e.state);if(!o||!n)return;const a=new z.KS({metricGroup:t,companyId:n,events:o});window.dispatchEvent(a),(e=>{K=e;try{sessionStorage.setItem(V,JSON.stringify(e))}catch(e){(0,s.Yd)(`Error setting session started event in session storage: ${e}`)}})(!0),D.unregisterEventHandler(i.oO),(0,s.Yd)(`Session started event sent. Unregistering event handler. Event handlers remaining: ${D.eventHandlers.size}`)})),te=Q((async({detail:e})=>{if(X())return void D.unregisterEventHandler(i.mq);if(!e.state.isIdentified)return;if(!await $({sentUserIdentifiedEvent:!0}))return;const t=r.lv,n=Z(),o=Y(i.mq,e.state);if(!o||!n)return;const a=new z.KS({metricGroup:t,companyId:n,events:o});window.dispatchEvent(a),(e=>{W=e;try{sessionStorage.setItem(J,JSON.stringify(e))}catch(e){(0,s.Yd)(`Error setting user identified event in session storage: ${e}`)}})(!0),D.unregisterEventHandler(i.mq),(0,s.Yd)(`User identified event sent. Unregistering event handler. Event handlers remaining: ${D.eventHandlers.size}`)})),ne=()=>{(0,a.O)(r.T4)&&(D.clear(),window.onsiteTelemetryLoaded=!1)};let re=!1;const ie=async()=>{if(re)(0,s.Yd)("Telemetry already initialized, skipping.");else{re=!0;try{if(ne(),!(0,a.O)(r.T4))return;D.registerEventHandler(r.Rc,r.Rc,q);const e=await R({updateExpiryTime:!1}),t=!1===(null==e?void 0:e.sentSessionStartedEvent)&&!G(),n=!1===(null==e?void 0:e.sentUserIdentifiedEvent)&&!X();t&&D.registerEventHandler(i.oO,o.P,ee),n&&D.registerEventHandler(i.mq,o.P,te),window.onsiteTelemetryLoaded=!0}catch(e){(0,s.Yd)("Error during onsite telemetry setup",{error:e,stack:e instanceof Error?e.stack:void 0}),ne()}}};(async()=>{ie()})()},51311:function(e,t,n){var r,i,o,s,a,c,u,d,l,f,v,p,m,g,y,w;o=function(e,t,n){if(!l(t)||v(t)||p(t)||m(t)||d(t))return t;var r,i=0,s=0;if(f(t))for(r=[],s=t.length;i