(function(){"use strict";const logger=e=>{console.error("GTM SS Suite:",e)},tcWrapper=e=>(...r)=>{try{e(...r)}catch(e2){logger(e2)}},suiteVars={userId:"___SKVX_GTM_SUITE--userId",lastCollectionPathname:"___SKVX_GTM_SUITE--lastCollectionPathname",userOnSignupPath:"___SKVX_GTM_SUITE--userOnSignupPath",userLoggedIn:"___SKVX_GTM_SUITE--userLoggedIn",cart:"___SKVX_GTM_SUITE--cart",cookies:"___SKVX_GTM_SUITE--cookies",params:"___SKVX_GTM_SUITE--params"},suiteDefaultEvents=["dl_add_payment_info","dl_add_shipping_info","dl_add_to_cart","dl_begin_checkout","dl_login","dl_purchase","dl_remove_from_cart","dl_select_item","dl_sign_up","dl_subscription_purchase","dl_user_data","dl_view_cart","dl_view_item","dl_view_item_list","dl_view_search_results","dl_vpq_complete","dl_vpq_start","dl_view_analysis"],getCookiesFromStorage=()=>{const e=localStorage.getItem(suiteVars.cookies);return e!==null?JSON.parse(e):{}},getMarketingParams=()=>{const e=localStorage.getItem(suiteVars.params);return e!==null?JSON.parse(e):{}};let mergedEvent={};const handleDLEvent=async(dlEvent,ssUrl)=>{const storedCookies=getCookiesFromStorage(),storedParams=getMarketingParams(),userDataEvent=window.dataLayer.find(r=>r.event==="dl_user_data"),marketingCookies={...storedCookies._fbp&&{_fbp:storedCookies._fbp},...storedCookies._fbc&&{_fbc:storedCookies._fbc},...storedCookies._ga&&{_ga:storedCookies._ga}};if(mergedEvent={...mergedEvent,...dlEvent,marketing:{...dlEvent.marketing,...marketingCookies}},userDataEvent&&(mergedEvent.user_properties?mergedEvent.user_properties={...mergedEvent.user_properties,...userDataEvent.user_properties}:mergedEvent.user_properties=userDataEvent.user_properties),dlEvent.event&&suiteDefaultEvents.includes(dlEvent.event)){const searchParams=new URLSearchParams({source_url:encodeURIComponent(document.location.href)});storedParams.fbtest&&searchParams.append("test",storedParams.fbtest);const finalUrl=`${ssUrl}/browserEvents?${searchParams.toString()}`;await fetch(finalUrl,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(mergedEvent)})}},methods={listen:ssUrl=>{window.dataLayer=window.dataLayer??[],window.dataLayer.forEach(t2=>{handleDLEvent(t2,ssUrl)});const t=window.dataLayer.push;window.dataLayer.push=function(...n){return n.forEach(t2=>{handleDLEvent(t2,ssUrl)}),t.apply(window.dataLayer,Array.prototype.slice.call(arguments,0))}}};window.SkVxGtmSuiteListener={handlers:{listen:tcWrapper(methods.listen)}}})(); //# sourceMappingURL=/cdn/shop/t/1/assets/gtm-listener.js.map