(()=>{"use strict";const e=(e,t,o)=>{let n;return function(){const i=this,c=arguments;clearTimeout(n),n=setTimeout((function(){n=null,o||e.apply(i,c)}),t),o&&!n&&e.apply(i,c)}},t=(e,t,o)=>{const n=o=>String.prototype.split.call(t,o).filter(Boolean).reduce(((e,t)=>null!=e?e[t]:e),e),i=n(/[,[\]]+?/)||n(/[,[\].]+?/);return void 0===i||i===e?o:i},o=e=>!(!e||"string"!=typeof e)&&(-1!==e.indexOf("cart/add.js")||-1!==e.indexOf("cart/change.js")),n=()=>"/cart"===t(window,"location.pathname",""),i=()=>{let e=t(window,"Shopify.shop.permanent_domain")||t(window,"Shopify.shop")||t(window,"CHDataObject.store_urls.store_url")||t(window,"Klickly_BoldCommerce.shop");if((!e||"string"!=typeof e)&&document.currentScript.src){e=new URL(document.currentScript.src).searchParams.get("shop")}return e},c=()=>t(window,"meta.product.id"),r={deserialize(e){const t={};return e.replace(/([^=]*)=([^&]*)&*/g,((e,o,n)=>{t[o]=encodeURIComponent(n)})),t}};function s(e){const t=("https:"==document.location.protocol?"https://":"http://")+"pixel.sitescout.com/iap/"+e;(new Image).src=t,function(e){var t=("https:"==document.location.protocol?"https://":"http://")+"pixel.sitescout.com/dmp/asyncPixelSync",o=e.createElement("iframe");(o.frameElement||o).style.cssText="width: 0; height: 0; border: 0; display:none;",o.src="javascript:false",e.body.appendChild(o);var n=o.contentWindow.document;n.open().write("<body onload=\"window.location.href='"+t+"'\">"),n.close()}(document)}const{SCRIPT_TAG_GTM_ID:a}={NODE_ENV:"production",TRACK_URL:"https://kst.klickly.com",TRACK_API_URL:"https://dl-api.klickly.com",EXTERNAL_CHECKOUT_API:"https://external-checkout-api.klickly.com",PIXEL_SCRIPT_URL:"https://analytics.klickly.com/pixel.js?v=2.0.2",SCRIPT_TAG_DOMAIN_FILTER_LIST:"",SCRIPT_TAG_GTM_ID:"GTM-NMDRPTH",ANALYTICS_API_URL:"https://analytics-api.klickly.com"};let l=!1;const d=e=>!!l&&(window.dataLayer.push(e),!0),{TRACK_API_URL:p,EXTERNAL_CHECKOUT_API:h,ANALYTICS_API_URL:u}={NODE_ENV:"production",TRACK_URL:"https://kst.klickly.com",TRACK_API_URL:"https://dl-api.klickly.com",EXTERNAL_CHECKOUT_API:"https://external-checkout-api.klickly.com",PIXEL_SCRIPT_URL:"https://analytics.klickly.com/pixel.js?v=2.0.2",SCRIPT_TAG_DOMAIN_FILTER_LIST:"",SCRIPT_TAG_GTM_ID:"GTM-NMDRPTH",ANALYTICS_API_URL:"https://analytics-api.klickly.com"},m=e=>{try{return JSON.parse(e.response)}catch(t){return e.response}},_=({baseURL:e,withCredentials:t=!0,httpMethod:o="POST"})=>(n,i)=>{const c=new XMLHttpRequest;return c.withCredentials=t,c.open(o,`${e}${n}`,!0),c.setRequestHeader("Content-Type","application/json"),c.send(JSON.stringify(i)),new Promise(((e,t)=>{c.onreadystatechange=()=>{4===c.readyState&&(c.status>=200&&c.status<300?e({data:m(c)}):t(c.statusText))}}))},y=_({baseURL:p}),w=_({baseURL:h}),k=_({baseURL:window.location.origin,httpMethod:"GET"}),f=_({baseURL:u,httpMethod:"GET"});class g{static get(e){let t=document.cookie.match(new RegExp("(?:^|; )"+e.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g,"\\$1")+"=([^;]*)"));return t?decodeURIComponent(t[1]):void 0}static set(e,t,o={}){if((o={path:"/",secure:!0,sameSite:"none",...o}).expires)o.expires instanceof Date&&(o.expires=o.expires.toUTCString());else{const e=new Date;e.setDate(e.getDate()+365),o.expires=e.toUTCString()}let n=encodeURIComponent(e)+"="+encodeURIComponent(t);for(let e in o){n+="; "+e;let t=o[e];!0!==t&&(n+="="+t)}document.cookie=n}static remove(e){g.set(e,"",{expires:new Date(0)})}}class T{static get(e){try{return localStorage.getItem(e)}catch(e){return}}static set(e,t){try{return localStorage.setItem(e,t),T.get(e)===t}catch(e){return!1}}static remove(e){try{localStorage.removeItem(e)}catch(e){return!1}}}class I{static get(e){try{return sessionStorage.getItem(e)}catch(e){return}}static set(e,t){try{return sessionStorage.setItem(e,t),I.get(e)===t}catch(e){return!1}}static remove(e){try{sessionStorage.removeItem(e)}catch(e){return!1}}}const R=[g,T,I];class C{static get(e){let t;for(let o=0;o<R.length&&(t=R[o].get(e),!t);o++);return t}static set(e,t){for(let o=0;o<R.length;o++)R[o].set(e,t)}static remove(e){for(let t=0;t<R.length;t++)R[t].remove(e)}}const L=document.currentScript?document.currentScript.src:"",x=L&&"string"==typeof L?r.deserialize(L.slice(L.indexOf("?")+1)):{};x.gtm_enabled&&(()=>{if(!a)return;l=!0;const e=document.createElement("script");e.type="text/javascript",e.async=!0,e.text=`(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':\n            new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],\n        j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=\n        'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);\n    })(window,document,'script','dataLayer','${a}');`,document.head.appendChild(e),window.dataLayer=window.dataLayer||[]})();const{SCRIPT_TAG_DOMAIN_FILTER_LIST:A}={NODE_ENV:"production",TRACK_URL:"https://kst.klickly.com",TRACK_API_URL:"https://dl-api.klickly.com",EXTERNAL_CHECKOUT_API:"https://external-checkout-api.klickly.com",PIXEL_SCRIPT_URL:"https://analytics.klickly.com/pixel.js?v=2.0.2",SCRIPT_TAG_DOMAIN_FILTER_LIST:"",SCRIPT_TAG_GTM_ID:"GTM-NMDRPTH",ANALYTICS_API_URL:"https://analytics-api.klickly.com"},v=A?A.split(","):[],S=i(),E=v.includes(S),N={shopDomain:S,externalId:c(),checkout:(()=>{let e;return window.chData&&window.chData.order?(e={order_id:Number(window.chData.order.order_id)||null},e.referrer=document.location.host||""):window.Klickly_BoldCommerce&&window.Klickly_BoldCommerce.order_name?e={order_name:window.Klickly_BoldCommerce.order_name}:window.Klickly_Zipify&&window.Klickly_Zipify.order_id?e={order_id:Number(window.Klickly_Zipify.order_id)}:window.Klickly_Recharge&&window.Klickly_Recharge.order_id?e={order_id:Number(window.Klickly_Recharge.order_id)}:window.Shopify&&window.Shopify.checkout&&(e=t(window,"Shopify.checkout",{}),e.referrer=t(document,"location.host",""),e.customer=t(window,"Shopify.Checkout.customer"),e.geolocatedAddress=t(window,"Shopify.Checkout.geolocatedAddress",""),"string"==typeof e.order_id&&(e.order_id=Number(e.order_id))),e})(),userGaId:(()=>{const e=("; "+document.cookie).split("; _ga=");if(2===e.length){const t=e.pop().split(";").shift();return t.slice(6,t.length)}})()},P="externalClicks",U="externalViews",D="externalCartAdds",b=window.navigator?.userAgentData||{},K=b.brands?.map((e=>e.brand)).filter(Boolean)||[],M=K.includes("Chromium")&&K.includes("Lighthouse");async function j(e,t=!0){try{if(e.checkout){const t=[],o=C.get("_klpixel_cid"),n=C.get("_klpixel_hash"),i=C.get("_klpixel_token");return o&&t.push("cid="+o),n&&t.push("hash="+n),i&&t.push("token="+i),w("/receiver?"+t.join("&"),e)}if(!E){const{data:t}=await y("/events/shop?returnCookie=1",e);return T.set("_klickly_common_sid",t._klickly_common_sid),!0}return}catch(e){}finally{if(S&&!E&&t){let e="visit";n()&&(e="cart"),N.checkout&&(e="checkout"),function(e,t){const o=(x[`b_type_${t}`]||"").split(",").filter((e=>!!e));if(!o.length)return y("/ads/tags",{shopDomain:e,audienceAction:t}).then((({data:e=[]})=>{e.forEach((e=>{s(e)}))}));o.forEach((e=>{s(e)}))}(S,e),d({event:"klicklyDataPush",klickly_event_name:e,klickly_cid:C.get("_klpixel_cid"),klickly_shop:S.replace(".myshopify.com",""),klickly_product:N.externalId||null})}}}function O(e=!1,t=!1){if(!E)return k("/cart.js").then((({data:o})=>{if(window.klpixel&&e&&window.klpixel("event","cartChanged",{cart:o}),o&&o.items&&o.items.length){j({...N,eventName:D,cart:o},t)}}))}if(S){(function(e){return!N.checkout&&"1"===x.tw||"1"===x.ga4?f(`/pixels?shop_domain=${e}`).then((({data:e})=>e.pixels)):Promise.resolve([])})(S).then((e=>{e.forEach((e=>{const t=`${e.name}_t`;(e=>{const t=e-Date.now();return!e||"number"!=typeof t||Math.floor(t/36e5)>24})(C.get(t))&&(((e={})=>{const t=document.createElement("iframe");Object.assign(t,e),t.style.display="none",t.style.position="absolute",t.style.top="-1000px",t.style.left="-1000px",t.style.width="0",t.style.height="0",t.style.border="none",t.style.overflow="hidden",t.style.zIndex="-1",t.style.visibility="hidden",t.style.opacity="0",t.style.pointerEvents="none",document.body.appendChild(t)})({id:`kl_${e.name}_iframe`,src:e.src}),C.set(t,Date.now()))}))})).catch((()=>null)),M||function(e){((e,t,o,n)=>{if(e[n])return;const i=e[n]=function(){i.track&&i.ready?i.track.apply(i,arguments):i.queue.push(arguments)};i.queue=[];const c=t.createElement("script");c.id="klpixel-script",c.async=!0,c.src=o;const r=t.getElementsByTagName("script")[0];r.parentNode.insertBefore(c,r)})(window,document,"https://analytics.klickly.com/pixel.js?v=2.0.2","klpixel"),window.klpixel("init","shopify.shop"),window.klpixel("config","listeners",{change:!1,click:Boolean(e.externalId),scroll:!1,popstate:!1,mouseover:!1,visibilitychange:!1}),window.klpixel("fetch_cookie"),window.klpixel("meta","shop",e),window.klpixel("eyeota_event",{shop_domain:i(),product_id:c()}),e.checkout?window.klpixel("event","purchase"):window.klpixel("event","pageView")}({...N,eventName:void 0}),n()?O(!1,!0):(N.eventName=U,j(N)),N.checkout||!N.externalId||E||document.body&&document.body.addEventListener&&document.body.addEventListener("click",e((function(){j({...N,eventName:P},!1)}),2e3)),N.checkout&&(C.remove("tw_t"),C.remove("ga4_t"));const t=XMLHttpRequest.prototype.open,r=window.fetch;window.fetch=function(){return r.apply(this,arguments).then((e=>(e.ok&&o(arguments[0])&&O(!0),e)))},XMLHttpRequest.prototype.open=function(){this.addEventListener("load",(function(){200===this.status&&o(this.responseURL)&&O(!0)})),t.apply(this,arguments)}}E||M||s("357c6e9d4d9b263b")})();