1(function(){var PRODUCTS={shampoo:{keywords:["shampoo"],type:"Shampoo",label:"Kids Shampoo",icon:"\uD83E\uDDF4",urlAttr:"data-url-shampoo"},oil:{keywords:["hair oil","scalp"],type:"Hair Oil",label:"Kids Hair Oil",icon:"\uD83D\uDEE2\uFE0F",urlAttr:"data-url-oil"},bodywash:{keywords:["body wash"],type:"Body Wash",label:"Body Wash",icon:"\uD83E\uDEB7",urlAttr:"data-url-bodywash"},lotion:{keywords:["lotion"],type:"Body Lotion",label:"Body Lotion",icon:"\uD83D\uDCA7",urlAttr:"data-url-lotion"}},COMBOS=[{keywords:["complete care"],counts:["shampoo","lotion"]},{keywords:["hair care"],counts:["shampoo","oil"]},{keywords:["body care"],counts:["bodywash","lotion"]}],BUNDLES=[{key:"shampoo",label:"Shampoo",targetQty:2,bundlePrice:1299,savings:299,icon:"\uD83E\uDDF4"},{key:"bodywash",label:"Body Wash",targetQty:2,bundlePrice:1099,savings:391,icon:"\uD83E\uDEB7"},{key:"lotion",label:"Body Lotion",targetQty:2,bundlePrice:1099,savings:391,icon:"\uD83D\uDCA7"},{key:"oil",label:"Hair Oil",targetQty:2,bundlePrice:799,savings:159,icon:"\uD83D\uDEE2\uFE0F"}];function getShopifyRoute(path){var root=window.Shopify&&window.Shopify.routes&&window.Shopify.routes.root?window.Shopify.routes.root:"/";return root+path.replace(/^\/+/,"")}function parseJsonResponse(response){if(!response.ok)throw new Error("Shopify Ajax request failed with status "+response.status);return response.json()}function getUrls(){var el=document.getElementById("syoat-cmb");if(!el)return{};var urls={};return Object.keys(PRODUCTS).forEach(function(key){urls[key]=el.getAttribute(PRODUCTS[key].urlAttr)||"#"}),urls}function detectCart(cartItems){var present={shampoo:0,oil:0,bodywash:0,lotion:0};return cartItems.forEach(function(item){var title=(item.title||"").toLowerCase(),ptype=(item.product_type||"").toLowerCase(),isCombo=!1;COMBOS.forEach(function(combo){combo.keywords.some(function(kw){return title.indexOf(kw)!==-1})&&(isCombo=!0,combo.counts.forEach(function(key){present[key]+=item.quantity}))}),!isCombo&&Object.keys(PRODUCTS).forEach(function(key){var p=PRODUCTS[key],kwMatch=p.keywords.some(function(kw){return title.indexOf(kw)!==-1}),typeMatch=ptype===p.type.toLowerCase();(kwMatch||typeMatch)&&(present[key]+=item.quantity)})}),present}function getRoutineState(present,urls){var has={shampoo:present.shampoo>0,oil:present.oil>0,bodywash:present.bodywash>0,lotion:present.lotion>0};return!has.shampoo&&!has.oil&&!has.bodywash&&!has.lotion?{msg:"Build your child's complete care routine \uD83C\uDF3F",type:"empty",cta:null,url:null}:has.shampoo&&!has.oil?{msg:"\uD83D\uDEE2\uFE0F Your child's hair routine is missing Hair Oil",type:"missing",cta:"Add Hair Oil",url:urls.oil}:has.oil&&!has.shampoo?{msg:"\uD83E\uDDF4 Your child's hair routine is missing Shampoo",type:"missing",cta:"Add Shampoo",url:urls.shampoo}:has.shampoo&&has.oil&&!has.bodywash?{msg:"\uD83E\uDEB7 Your child's bath routine is missing Body Wash",type:"missing",cta:"Add Body Wash",url:urls.bodywash}:has.bodywash&&!has.lotion?{msg:"\uD83D\uDCA7 Skin needs moisture \u2014 Body Lotion is missing",type:"missing",cta:"Add Body Lotion",url:urls.lotion}:has.lotion&&!has.bodywash?{msg:"\uD83E\uDEB7 Your child's bath routine is missing Body Wash",type:"missing",cta:"Add Body Wash",url:urls.bodywash}:has.bodywash&&has.lotion&&!has.shampoo?{msg:"\uD83E\uDDF4 Complete the full routine \u2014 Shampoo is missing",type:"missing",cta:"Add Shampoo",url:urls.shampoo}:{msg:"\uD83C\uDF89 Full routine complete! Your child is all set",type:"complete",cta:null,url:null}}function updateBar(cartItems,cartDiscountTotal){var msgEl=document.getElementById("syoat-cmb-msg"),ctaEl=document.getElementById("syoat-cmb-cta"),ctaTxtEl=document.getElementById("syoat-cmb-cta-text"),savingsEl=document.getElementById("syoat-cmb-savings"),savingsVal=document.getElementById("syoat-cmb-savings-val"),items=cartItems||[],cartDiscountSaved=Math.round((cartDiscountTotal||0)/100),present=detectCart(items);if(msgEl){var urls=getUrls(),routine=getRoutineState(present,urls);msgEl.textContent=routine.msg,msgEl.className="syoat-cmb__routine-msg is-"+routine.type,routine.cta&&ctaEl&&ctaTxtEl?(ctaTxtEl.textContent=routine.cta,ctaEl.href=routine.url||"#",ctaEl.classList.remove("hidden")):ctaEl&&ctaEl.classList.add("hidden")}document.querySelectorAll("[data-syoat-bundle-upsell]").forEach(function(offerEl){var title=(offerEl.getAttribute("data-product-title")||"").toLowerCase(),productType=(offer
1El.getAttribute("data-product-type")||"").toLowerCase(),matchingBundle=null;BUNDLES.forEach(function(bundleConfig){var productConfig=PRODUCTS[bundleConfig.key];if(!(!productConfig||matchingBundle)){var keywordMatch=productConfig.keywords.some(function(keyword){return title.indexOf(keyword)!==-1}),typeMatch=productType===productConfig.type.toLowerCase();(keywordMatch||typeMatch)&&present[bundleConfig.key]===1&&(matchingBundle=bundleConfig)}});var offerMessage=offerEl.querySelector("[data-syoat-bundle-upsell-message]");if(matchingBundle&&offerMessage){var nextMessage="Add 1 more - save \u20B9"+matchingBundle.savings;offerMessage.textContent!==nextMessage&&(offerMessage.textContent=nextMessage),offerEl.classList.remove("hidden")}else offerEl.classList.add("hidden")});var compareSaved=items.reduce(function(sum,item){var cap=item._compare_at_price||0,price=item.price||0;return cap>price?sum+(cap-price)*item.quantity:sum},0);compareSaved=Math.round(compareSaved/100);var totalSaved=compareSaved+cartDiscountSaved;if(savingsEl&&savingsVal)if(totalSaved>0){var prevSaved=parseInt(savingsEl.dataset.prevSaved||"0",10);savingsVal.textContent="\u20B9"+totalSaved,savingsEl.classList.remove("hidden"),totalSaved!==prevSaved&&(savingsEl.dataset.prevSaved=totalSaved,syoatConfetti(savingsEl))}else savingsEl.classList.add("hidden"),savingsEl.dataset.prevSaved="0"}function syoatConfetti(anchorEl){if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;var COLORS=["#5b4636","#D7CABA","#f3eee7","#fcd34d","#86efac","#fca5a5","#93c5fd"],PIECES=32,DURATION=2e3,rect=anchorEl.getBoundingClientRect(),originX=rect.left+rect.width/2,originY=rect.top+rect.height/2,canvas=document.createElement("canvas");canvas.style.cssText=["position:fixed","top:0","left:0","width:100%","height:100%","pointer-events:none","z-index:99999"].join(";"),canvas.width=window.innerWidth,canvas.height=window.innerHeight,document.body.appendChild(canvas);for(var ctx=canvas.getContext("2d"),particles=[],i=0;i<PIECES;i++){var angle=Math.PI*2/PIECES*i+(Math.random()-.5)*.8,speed=3+Math.random()*5;particles.push({x:originX,y:originY,vx:Math.cos(angle)*speed,vy:Math.sin(angle)*speed-4,size:5+Math.random()*6,color:COLORS[Math.floor(Math.random()*COLORS.length)],rotation:Math.random()*Math.PI*2,rotSpeed:(Math.random()-.5)*.3,shape:Math.random()>.5?"rect":"circle",opacity:1})}var start=null;function draw(ts){start||(start=ts);var elapsed=ts-start,progress=elapsed/DURATION;ctx.clearRect(0,0,canvas.width,canvas.height),particles.forEach(function(p){p.x+=p.vx,p.y+=p.vy,p.vy+=.18,p.rotation+=p.rotSpeed,p.opacity=Math.max(0,1-progress*1.2),ctx.save(),ctx.globalAlpha=p.opacity,ctx.translate(p.x,p.y),ctx.rotate(p.rotation),ctx.fillStyle=p.color,p.shape==="rect"?ctx.fillRect(-p.size/2,-p.size/4,p.size,p.size/2):(ctx.beginPath(),ctx.arc(0,0,p.size/2,0,Math.PI*2),ctx.fill()),ctx.restore()}),elapsed<DURATION?requestAnimationFrame(draw):canvas.remove()}requestAnimationFrame(draw)}var _capCache={},_giftSyncInFlight=!1,_giftSyncBlockedUntil=0,_giftRemovalRetryCount=0,_giftAutoAddPaused=!1;try{_giftAutoAddPaused=sessionStorage.getItem("syoat-gift-auto-add-paused")==="true"}catch(error){}function pauseGiftAutoAdd(paused){_giftAutoAddPaused=paused;try{paused?sessionStorage.setItem("syoat-gift-auto-add-paused","true"):sessionStorage.removeItem("syoat-gift-auto-add-paused")}catch(error){}}function fetchCap(handle,variantId){var key=String(variantId);return _capCache[key]!==void 0?Promise.resolve(_capCache[key]):fetch(getShopifyRoute("products/"+handle+".js")).then(parseJsonResponse).then(function(p){return(p.variants||[]).forEach(function(v){_capCache[String(v.id)]=v.compare_at_price||0}),_capCache[key]||0}).catch(function(){return 0})}function isThresholdGift(item){return item.properties&&item.properties._syoat_threshold_gift==="true"}function removeChargedThresholdGifts(cart){var chargedGiftLine=-1;return(cart.items||[]).some(function(item,index){return!isThresholdGift(item)||item.final_line_price<=0?!1:(chargedGiftLine=index+1,!0)}),chargedGiftLine<1?(_giftRemovalRetryCount=0,!1):(pauseGiftAutoAdd(!0),_giftRemovalRetryCount+=1,requestGiftMutation(getShopifyRoute("cart/change.js"),{line:chargedGiftLine,quantity:0}))}function getGiftConfig(){var el=document.getElementById("syoat-cmb")||document.querySelector("[data-syoat-gift-progress]");return el?{variantId:parseInt(el.getAttribute("data-gift-variant-id")||"0",10),threshold:parseInt(el.getAttribute("data-gift-threshold")||"0",10),available:el.getAttribute("data-gift-available")==="true"}:null}function setGiftProgressError(){var el=document.querySelector("[data-syoat-gift-progress]");el&&(el.classList.remove("is-unlocked","is-adding"),el.classList.add("is-error"),el.textContent="Free gift could not be updated. Please refresh your cart.")}function getBundledSectionIds(){var ids=[],quickCart=document.querySelector('[data-section-type="quick-cart"][data-section-id]'),header=document.querySelector('[data-section-type="header"][data-section-id]');return quickCart&&ids.push(quickCart.getAttribute("data-section-id")),header&&ids.push(header.getAttribute("data-section-id")),ids.filter(
1Boolean)}function replaceSectionPart(currentRoot,freshRoot,selector){var current=currentRoot.querySelector(selector),fresh=freshRoot.querySelector(selector);current&&fresh&&(current.innerHTML=fresh.innerHTML)}function refreshBundledSections(sections){if(sections){var parser=new DOMParser;Object.keys(sections).forEach(function(sectionId){var html=sections[sectionId];if(html){var freshDoc=parser.parseFromString(html,"text/html"),freshQuickCart=freshDoc.querySelector('[data-section-type="quick-cart"]'),currentQuickCart=document.querySelector('[data-section-type="quick-cart"]');freshQuickCart&¤tQuickCart&&(replaceSectionPart(currentQuickCart,freshQuickCart,".quick-cart__heading"),replaceSectionPart(currentQuickCart,freshQuickCart,".quick-cart__items"),replaceSectionPart(currentQuickCart,freshQuickCart,".quick-cart__footer"),replaceSectionPart(currentQuickCart,freshQuickCart,"#syoat-cmb"),freshQuickCart.hasAttribute("data-syoat-charged-gift-cart")?currentQuickCart.setAttribute("data-syoat-charged-gift-cart",""):currentQuickCart.removeAttribute("data-syoat-charged-gift-cart"));var freshHeader=freshDoc.querySelector('[data-section-type="header"]'),currentHeader=document.querySelector('[data-section-type="header"]');if(freshHeader&¤tHeader){var freshCarts=freshHeader.querySelectorAll("[data-header-cart]"),currentCarts=currentHeader.querySelectorAll("[data-header-cart]");currentCarts.forEach(function(currentCart,index){var freshCart=freshCarts[index];freshCart&&(currentCart.innerHTML=freshCart.innerHTML,currentCart.setAttribute("data-cart-count",freshCart.getAttribute("data-cart-count")||"0"))})}}})}}function refreshCartAfterServerCleanup(){var sectionIds=getBundledSectionIds();if(!sectionIds.length){window.location.reload();return}var separator=window.location.pathname.indexOf("?")===-1?"?":"&",url=window.location.pathname+separator+"sections="+encodeURIComponent(sectionIds.join(","));fetch(url,{credentials:"same-origin",headers:{Accept:"application/json"}}).then(parseJsonResponse).then(function(sections){refreshBundledSections(sections),document.querySelector("[data-syoat-unpriced-gift-remove]")&&window.location.reload()}).catch(function(){window.location.reload()})}function enrichAndUpdate(cart){var items=cart.items||[];if(!items.length){updateBar([],0);return}var fetches=items.map(function(item){return fetchCap(item.handle,item.variant_id).then(function(cap){item._compare_at_price=cap||0})});Promise.all(fetches).then(function(){updateBar(items,cart.total_discount||0)})}function completeGiftMutation(response){return refreshBundledSections(response.sections),fetch(getShopifyRoute("cart.js")).then(parseJsonResponse).then(function(cart){if(_giftSyncInFlight=!1,window.theme&&(window.theme.cartData=cart),document.querySelector("[data-syoat-unpriced-gift-remove]")&&!(cart.items||[]).some(isThresholdGift)){_giftRemovalRetryCount=0,refreshCartAfterServerCleanup();return}if(document.querySelector('[data-section-type="cart"][data-syoat-charged-gift-cart]')){window.location.reload();return}enrichAndUpdate(cart),document.dispatchEvent(new CustomEvent("cart:updated",{detail:{cart:cart}})),document.dispatchEvent(new CustomEvent("quick-cart:updated",{detail:{cart:cart}}))})}function recoverGiftMutation(){return fetch(getShopifyRoute("cart.js")).then(parseJsonResponse).then(function(cart){var giftIsPresent=(cart.items||[]).some(isThresholdGift);if(_giftSyncInFlight=!1,!giftIsPresent){_giftRemovalRetryCount=0,window.theme&&(window.theme.cartData=cart),refreshCartAfterServerCleanup();return}window.theme&&(window.theme.cartData=cart),enrichAndUpdate(cart),document.dispatchEvent(new CustomEvent("cart:updated",{detail:{cart:cart}})),document.dispatchEvent(new CustomEvent("quick-cart:updated",{detail:{cart:cart}})),_giftRemovalRetryCount<3?(_giftSyncBlockedUntil=Date.now()+600,setTimeout(refreshBar,700)):(_giftSyncBlockedUntil=Date.now()+5e3,setGiftProgressError())}).catch(function(){_giftSyncInFlight=!1,_giftSyncBlockedUntil=Date.now()+5e3,setGiftProgressError()})}function requestGiftMutation(requestUrl,requestBody){var sectionIds=getBundledSectionIds();return sectionIds.length&&(requestBody.sections=sectionIds,requestBody.sections_url=window.location.pathname),_giftSyncInFlight=!0,fetch(requestUrl,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(requestBody)}).then(parseJsonResponse).then(completeGiftMutation).catch(recoverGiftMutation),!0}function addThresholdGiftFromRenderedState(){var progressEl=document.querySelector('[data-syoat-gift-progress][data-gift-state="adding"]'),config=getGiftConfig();return _giftAutoAddPaused||!progressEl||!config||!config.available||!config.variantId?!1:_giftSyncInFlight||Date.now()<_giftSyncBlockedUntil?_giftSyncInFlight:requestGiftMutation(getShopifyRoute("cart/add.js"),{items:[{id:config.variantId,quantity:1,properties:{_syoat_threshold_gift:"true"}}]})}function syncThresholdGift(cart){var config=getGiftConfig();if(!config||!config.available||!config.variantId||!config.threshold)return!1;if(_giftSyncInFlight||Date.now()<_giftSyncBlockedUntil)return _giftSyncInFlight;var markedGifts=(cart.items||[]).filter(isThresholdGift),eligibleTotal=(cart.items||[]).reduce(function(sum,item){return sum+(isThresholdGift(item)?0:item.final_line_price||0)},0),qualifies=eligibleTotal>=config.threshold;qualifies?markedGifts.some(function(item){return item.final_line_price>0})&&pauseGiftAutoAdd(!0):pauseGiftAutoAdd(!1);var updates={},requestUrl,requestBody;if(qualifies&&markedGifts.length===0){if(_giftAutoAddPaused){var progress=document.querySelector("[data-syoat-gift-progress]"),pausedMessage="Gift offer is paused because the discount did not apply.";return progress&&(progress.classList.remove("is-unlocked","is-adding"),progress.classList.add("is-error"),progress.textContent!==pausedMessage&&(progress.textContent=pausedMessage)),!1}requestUrl=getShopifyRoute("cart/add.js"),requestBody={items:[{id:config.variantId,quantity:1,properties:{_syoat_threshold_gift:"true"}}]}}else if(!qualifies&&markedGifts.length>
10)markedGifts.forEach(function(item){updates[item.key]=0});else if(qualifies&&(markedGifts.length>1||markedGifts[0].quantity!==1))markedGifts.forEach(function(item,index){updates[item.key]=index===0?1:0});else return!1;return requestUrl||(requestUrl=getShopifyRoute("cart/update.js"),requestBody={updates:updates}),requestGiftMutation(requestUrl,requestBody)}function addBundleItem(button){var variantId=parseInt(button.getAttribute("data-variant-id")||"0",10);if(!(!variantId||button.disabled)){var requestBody={items:[{id:variantId,quantity:1}]},sectionIds=getBundledSectionIds();sectionIds.length&&(requestBody.sections=sectionIds,requestBody.sections_url=window.location.pathname),button.disabled=!0,button.textContent="Adding...",fetch(getShopifyRoute("cart/add.js"),{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(requestBody)}).then(parseJsonResponse).then(function(response){return refreshBundledSections(response.sections),fetch(getShopifyRoute("cart.js")).then(parseJsonResponse)}).then(function(cart){window.theme&&(window.theme.cartData=cart),enrichAndUpdate(cart),document.dispatchEvent(new CustomEvent("cart:updated",{detail:{cart:cart}})),document.dispatchEvent(new CustomEvent("quick-cart:updated",{detail:{cart:cart}}))}).catch(function(){button.disabled=!1,button.textContent="Try again"})}}function refreshBar(){fetch(getShopifyRoute("cart.js")).then(parseJsonResponse).then(function(cart){!removeChargedThresholdGifts(cart)&&!syncThresholdGift(cart)&&enrichAndUpdate(cart)}).catch(function(){updateBar([],0)})}window.syoatRefreshCartBar=refreshBar;var _refreshTimer,_retryTimer;function refreshWithRetry(attempts){attempts=attempts||0,clearTimeout(_retryTimer);var milestoneEl=document.getElementById("syoat-cmb")||document.querySelector("[data-syoat-gift-progress]");if(!milestoneEl){attempts<5&&(_retryTimer=setTimeout(function(){refreshWithRetry(attempts+1)},200));return}refreshBar()}function scheduleRefresh(){clearTimeout(_refreshTimer),_refreshTimer=setTimeout(function(){attachObserver(),refreshWithRetry(0)},120)}var _chargedGiftGuardTimer;function hasRenderedChargedGift(){return!!document.querySelector("[data-syoat-unpriced-gift-remove]")}function guardRenderedChargedGift(){return hasRenderedChargedGift()?(document.querySelectorAll('button[name="checkout"], input[name="checkout"]').forEach(function(button){button.disabled=!0,button.setAttribute("aria-disabled","true"),button.setAttribute("aria-busy","true"),button.tagName==="INPUT"?button.value!=="Updating cart..."&&(button.value="Updating cart..."):button.textContent!=="Updating cart..."&&(button.textContent="Updating cart...")}),clearTimeout(_chargedGiftGuardTimer),_chargedGiftGuardTimer=setTimeout(function(){hasRenderedChargedGift()&&typeof window.syoatRefreshCartBar=="function"&&window.syoatRefreshCartBar()},300),!0):!1}document.addEventListener("cart:updated",scheduleRefresh),document.addEventListener("cart:item-added",scheduleRefresh),document.addEventListener("cart:refresh",scheduleRefresh),document.addEventListener("cart:change",scheduleRefresh),document.addEventListener("quick-cart:open",function(){addThresholdGiftFromRenderedState()||scheduleRefresh()}),document.addEventListener("quick-cart:updated",scheduleRefresh),document.addEventListener("click",function(event){var target=event.target;if(target&&target.closest){target.closest("[data-syoat-unpriced-gift-remove]")&&pauseGiftAutoAdd(!0);var bundleButton=target.closest("[data-syoat-bundle-add]");if(bundleButton){event.preventDefault(),addBundleItem(bundleButton);return}}target&&target.closest&&target.closest("[data-header-cart]")&&(!event.defaultPrevented&&document.querySelector(".quick-cart")&&(event.preventDefault(),document.dispatchEvent(new CustomEvent("quick-cart:open"))),scheduleRefresh())}),document.addEventListener("click",function(event){var target=event.target;!target||!target.closest||!target.closest('[name="checkout"]')||guardRenderedChargedGift()&&(event.preventDefault(),event.stopImmediatePropagation())},!0);function attachObserver(){var containerEl=document.querySelector(".quick-cart__container");containerEl&&!containerEl._syoatObserved&&(containerEl._syoatObserved=!0,new MutationObserver(function(){scheduleRefresh()}).observe(containerEl,{childList:!0,subtree:!1}));var itemsEl=document.querySelector(".quick-cart__items");itemsEl&&!itemsEl._syoatItemsObserved&&(itemsEl._syoatItemsObserved=!0,new MutationObserver(function(){scheduleRefresh()}).observe(itemsEl,{childList:!0,subtree:!0}))}document.documentElement._syoatChargedGiftObserved||(document.documentElement._syoatChargedGiftObserved=!0,new MutationObserver(function(){guardRenderedChargedGift()}).observe(document.documentElement,{childList:!0,subtree:!0})),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",function(){attachObserver(),!guardRenderedChargedGift()&&document.querySelector("[data-syoat-charged-gift-cart]")&&refreshBar()}):(attachObserver(),!guardRenderedChargedGift()&&document.querySelector("[data-syoat-charged-gift-cart]")&&refreshBar())})(); 2//# sourceMappingURL=/cdn/shop/t/62/assets/syoat-cart-milestone.js.map?v=82750350038259051711788605248
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.