1(function(){"use strict";var MOBILE_QUERY="(max-width: 749px)",DIRECTION_THRESHOLD=2;class MpStickyBuy extends HTMLElement{constructor(){super(),this.wrapper=null,this.inner=null,this.variants=null,this.blockObserver=null,this.footerObserver=null,this.domObserver=null,this.heightObserver=null,this.controller=null,this.blockPosition="visible",this.scrollDirection=null,this.lastScrollY=0,this.footerVisible=!1,this.revealed=!1,this.stuck=!1}connectedCallback(){var self=this;this.variants=this.querySelector(".mp-sticky-buy__variants"),this.media=window.matchMedia(MOBILE_QUERY),this.controller=new AbortController,this.lastScrollY=window.scrollY;var signal=this.controller.signal;this.media.addEventListener("change",function(){self.sync()},{signal}),window.addEventListener("scroll",function(){self.trackScroll()},{passive:!0,signal}),document.addEventListener("variant:update",function(){self.syncVariants()},{signal}),document.addEventListener("variant:selected",function(){self.syncVariants()},{signal}),document.addEventListener("click",function(event){self.handleClick(event)},{signal}),this.sync()}disconnectedCallback(){this.controller&&this.controller.abort(),this.unwatch(),this.teardown()}get scope(){var section=this.closest(".shopify-section");return(section||document).querySelector(".product-details")}get picker(){var section=this.closest(".shopify-section")||document,productId=this.dataset.productId,selector=productId?'variant-picker[data-product-id="'+productId+'"]':"variant-picker";return section.querySelector(selector)}get form(){var root=this.inner||this.scope;return root?root.querySelector(".buy-buttons-block product-form-component"):null}sync(){this.isConnected&&(this.media.matches?this.setup():this.teardown())}setup(){if(!this.wrapper){var scope=this.scope,found=scope&&this.collect(scope);if(!found){this.watch();return}this.unwatch();var wrapper=document.createElement("div");wrapper.className="mp-sticky-buy",wrapper.dataset.stuck="false";var inner=document.createElement("div");inner.className="mp-sticky-buy__inner",wrapper.appendChild(inner);var gap=window.getComputedStyle(found.parent).rowGap;gap&&gap!=="normal"&&wrapper.style.setProperty("--mp-sticky-buy-flow-gap",gap),found.parent.insertBefore(wrapper,found.nodes[0]),found.nodes.forEach(function(node){inner.appendChild(node)}),this.variants&&inner.insertBefore(this.variants,inner.firstChild),this.wrapper=wrapper,this.inner=inner;var self=this;this.heightObserver=new ResizeObserver(function(){self.publishHeight()}),this.heightObserver.observe(inner),this.syncVariants(),this.observe()}}teardown(){if(this.blockObserver&&(this.blockObserver.disconnect(),this.blockObserver=null),this.footerObserver&&(this.footerObserver.disconnect(),this.footerObserver=null),this.heightObserver&&(this.heightObserver.disconnect(),this.heightObserver=null),!!this.wrapper){this.unstick(),this.variants&&this.appendChild(this.variants);var parent=this.wrapper.parentElement;if(parent&&this.inner)for(;this.inner.firstChild;)parent.insertBefore(this.inner.firstChild,this.wrapper);this.wrapper.remove(),this.wrapper=null,this.inner=null,this.blockPosition="visible",this.footerVisible=!1,this.revealed=!1}}collect(scope){var buyButtons=scope.querySelector(".buy-buttons-block");if(!buyButtons)return null;var rootGroup=scope.querySelector(":scope > .group-block"),group=buyButtons.closest(".group-block"),start=group&&group!==rootGroup?group:buyButtons,parent=start.parentElement;if(!parent)return null;var nodes=[start],shipping=scope.querySelector("mp-shipping-dates");if(shipping&&shipping.parentElement===parent)for(var node=start.nextElementSibling,between=[];node;){if(between.push(node),node===shipping){nodes=nodes.concat(between);break}node=node.nextElementSibling}return{parent,nodes}}observe(){var self=this;this.blockObserver=new IntersectionObserver(function(entries){var entry=entries[entries.length-1];entry&&(entry.isIntersecting?self.blockPosition="visible":self.blockPosition=entry.boundingClientRect.bottom<=0?"above":"below",self.update())}),this.blockObserver.observe(this.wrapper);var footer=document.querySelector("footer")||document.querySelector('[class*="footer-group"]');footer&&(this.footerObserver=new IntersectionObserver(function(entries){var entry=entries[entries.length-1];
1entry&&(self.footerVisible=entry.isIntersecting,self.update())}),this.footerObserver.observe(footer))}trackScroll(){var y=window.scrollY,delta=y-this.lastScrollY;Math.abs(delta)<DIRECTION_THRESHOLD||(this.lastScrollY=y,this.scrollDirection=delta>0?"down":"up",this.update())}update(){this.blockPosition!=="above"?this.revealed=!1:this.scrollDirection==="down"&&(this.revealed=!0),this.revealed&&!this.footerVisible?this.stick():this.unstick()}stick(){this.stuck||!this.wrapper||!this.inner||(this.wrapper.style.minHeight=this.inner.offsetHeight+"px",this.wrapper.dataset.stuck="true",this.stuck=!0,this.publishHeight())}unstick(){!this.stuck||!this.wrapper||(this.wrapper.dataset.stuck="false",this.wrapper.style.minHeight="",this.stuck=!1,this.publishHeight())}publishHeight(){var root=document.documentElement;if(!this.stuck||!this.inner){root.style.removeProperty("--mp-sticky-buy-height");return}root.style.setProperty("--mp-sticky-buy-height",Math.round(this.inner.getBoundingClientRect().height)+"px")}handleClick(event){var target=event.target;if(target instanceof Element){var swatch=target.closest(".mp-sticky-buy__swatch");if(!(!swatch||!this.variants||!this.variants.contains(swatch))){var picker=this.picker,input=picker&&this.findInput(picker,swatch.dataset.optionPosition,swatch.dataset.optionValue);!input||input.checked||(this.claimVariant(input.dataset.variantId),input.click(),this.syncVariants())}}}claimVariant(variantId){var form=this.form;if(form){var input=form.querySelector('input[name="id"]');if(input){if(variantId){input.value=variantId;return}var container=form.querySelector("add-to-cart-component");if(container&&typeof container.disable=="function"){container.disable();return}var button=form.querySelector('[ref="addToCartButton"]');button&&(button.disabled=!0)}}}syncVariants(){if(this.variants){var picker=this.picker;if(picker)for(var options=this.variants.querySelectorAll(".mp-sticky-buy__option"),i=0;i<options.length;i++){for(var option=options[i],position=option.dataset.optionPosition,swatches=option.querySelectorAll(".mp-sticky-buy__swatch"),selected="",j=0;j<swatches.length;j++){var swatch=swatches[j],input=this.findInput(picker,position,swatch.dataset.optionValue),checked=!!input&&input.checked;checked&&(selected=swatch.dataset.optionValue||""),swatch.classList.toggle("mp-sticky-buy__swatch--active",checked),swatch.setAttribute("aria-pressed",checked?"true":"false"),swatch.classList.toggle("mp-sticky-buy__swatch--unavailable",!input||input.dataset.optionAvailable==="false")}var value=option.querySelector("[data-mp-option-value]");value&&selected&&(value.textContent=selected)}}}findInput(picker,position,value){return!position||!value?null:picker.querySelector('input[type="radio"][data-input-id^="'+position+'-"][value="'+CSS.escape(value)+'"]')}watch(){if(!this.domObserver){var root=this.closest(".shopify-section");if(root){var self=this;this.domObserver=new MutationObserver(function(){self.setup()}),this.domObserver.observe(root,{childList:!0,subtree:!0})}}}unwatch(){this.domObserver&&(this.domObserver.disconnect(),this.domObserver=null)}}customElements.get("mp-sticky-buy")||customElements.define("mp-sticky-buy",MpStickyBuy)})(); 2//# sourceMappingURL=/cdn/shop/t/46/assets/mp-sticky-buy.js.map?v=73979604285657901351790018842
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.