1class SiteCarousel extends HTMLElement{constructor(){super(),this.swiper=null,this.config=null}connectedCallback(){const bulletActiveClass=(this.getAttribute("active-style")||"bar").toLowerCase()==="dot"?"active-dot":"active-bar";this.config=this.dataset.config?JSON.parse(this.dataset.config):{slidesPerView:3,spaceBetween:20},window.matchMedia("(prefers-reduced-motion: reduce)").matches&&this.config.autoplay&&delete this.config.autoplay;const pagerColors=this.dataset.pagerColors?this.dataset.pagerColors.split(",").filter(c=>c.trim()):[];this.swiper=new Swiper(`#${this.dataset.id} .swiper`,{...this.config,a11y:{enabled:!0,prevSlideMessage:"Previous slide",nextSlideMessage:"Next slide",paginationBulletMessage:"Go to slide {{index}}"},navigation:{nextEl:this.querySelector(".carousel-next"),prevEl:this.querySelector(".carousel-prev")},pagination:{clickable:!0,el:this.querySelector(".carousel-pager"),bulletClass:"carousel-pager-item",bulletActiveClass,renderBullet:(index,className)=>`<button type="button" class="${className}" aria-label="Go to slide ${index+1}"></button>`},on:{init:()=>{this.classList.remove("opacity-0"),pagerColors.length>0&&this.updatePagerColors(0,pagerColors)},slideChange:()=>{pagerColors.length>0&&this.updatePagerColors(this.swiper.activeIndex,pagerColors)}}})}updatePagerColors(activeIndex,pagerColors){const color=pagerColors[activeIndex]||"#651c32";this.querySelectorAll(".carousel-pager-item").forEach(bullet=>{bullet.style.backgroundColor=color})}previous(){this.swiper&&this.swiper.slidePrev()}next(){this.swiper&&this.swiper.slideNext()}slideTo(i){this.swiper&&this.swiper.slideTo(i)}}customElements.define("site-carousel",SiteCarousel);class SiteHeader extends HTMLElement{connectedCallback(){this.body=document.querySelector("body"),this.header=this.querySelector("header"),this.hamburgerButton=document.querySelector(".hamburger-button-js"),this.closeButton=document.querySelector(".close-hamburger-button-js"),this.hamburgerMenuContainer=document.querySelector(".hamburger-menu-content-js"),this.toggleHamburgerMenu()}toggleHamburgerMenu(){this.hamburgerButton&&this.hamburgerButton.addEventListener("click",e=>{this.hamburgerMenuContainer.classList.contains("opacity-95")?(e.target.innerHTML="Menu",this.closeHamburgerMenu()):(e.target.innerHTML="Close",this.openHamburgerMenu())})}openHamburgerMenu(){this.hamburgerMenuContainer.classList.remove("invisible","opacity-0"),this.hamburgerMenuContainer.classList.add("opacity-95"),this.body.classList.add("overflow-hidden")}closeHamburgerMenu(){this.hamburgerMenuContainer.classList.add("invisible","opacity-0"),this.hamburgerMenuContainer.classList.remove("opacity-95"),this.body.classList.remove("overflow-hidden")}cartOrFlyoutOpen(ctx){const menuToggle=this.header.querySelector('[data-trigger="toggle-menu"');this.isMobile&&(ctx==="cart"&&(this.header.querySelector('[data-trigger="close-cart"').classList.remove("hidden"),menuToggle.classList.add("hidden")),ctx==="flyout"&&(menuToggle.querySelector("span:nth-child(1)").classList.add("hidden"),menuToggle.querySelector("span:nth-child(2)").classList.remove("hidden")),ctx==="filters"&&(this.header.querySelector('[data-trigger="close-filters"]').classList.remove("hidden"),menuToggle.classList.add("hidden")))}}customElements.define("site-header",SiteHeader);class NewsletterForm extends HTMLElement{connectedCallback(){const listId=this.dataset.listId,statusText=this.querySelector(".success");this.addEventListener("submit",e=>{e.preventDefault();const $form=this.querySelector("form"),$email=this.querySelector('[type="email"]'),$submit=this.querySelector('[type="submit"]'),$error=this.querySelector(".error"),submitText=$submit.innerHTML,email=$email.value,body={email,listId};$submit.innerHTML=this.dataset.loadingText,$error.classList.add("hidden");const config={body:JSON.stringify(body),method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}};if(listId)try{fetch("https://hunni-serverless.vercel.app/api/ghia/subscribe",config).then(res=>res.json()).then(data=>{$form.reset(),$email.blur(),$submit.innerHTML=submitText,success.classList.toggle("active"),window.cvg({method:"track",eventName:"Subscribed To Newsletter",properties:{form:"Footer",formId:"XLSVK5"},profileProperties:{$email:email},aliases:[`urn:email:${email}`]})}),statusText&&statusText.classList.toggle("hidden")}catch{$submit.innerHTML=submitText,$error.classList.remove("hidden")}})}}customElements.define("newsletter-form",NewsletterForm);class SelectInput extends HTMLElement{constructor(){super()}connectedCallback(){const select=this.querySelector("select"),input=select.closest(".text-input");select.value&&input&&input.classList.add("active"),select.addEventListener("change",e=>{this.setActiveValue(e.target.value),input&&input.classList.add("active")})}setActiveValue(val){const activeOption=Array.from(this.querySelectorAll("option")).find(o=>o.value===val),target=this.querySelector(".select-target");activeOption&&(target.innerHTML=activeOption.innerHTML)}}customElements.define("select-input",SelectInput);class CloverProductItem extends HTMLElement{constructor(){super(),this.selectedSellingPlanId=null,this.selectedSellingPlanPrice=null}connectedCallback(){const variantsDataScript=this.querySelector("#selling-plans-data");this.variantsData=JSON.parse(variantsDataScript.textContent),this.variantButtons=this.querySelectorAll(".variant-option-button"),this.variantSelect=this.querySelector("#variant-select"),this.sellingPlanSelect=this.querySelector("#selling-plan-select"),this.purchaseOption=this.querySelectorAll('input[name^="purchase-option"]'),this.sellingPlanInput=this.querySelector("#sellin-plan-id"),this.variantInput=this.querySelector("#variant-id"),this.atcFullPrice=this.querySelector("#atc-full-price"),this.atcDiscountPrice=this.querySelector("#atc-discount-price"),this.subBoxOneTimePrice=this.querySelector("#sub-box-one-time-price"),this.subBoxSubPrice=this.querySelector("#sub-box-sub-price"),this.pillInputs=this.querySelectorAll('input[type="radio"][name^="options["]'),this.oneTimePurchase=this.querySelector("[id^='one-time-purchase']");const currentVariantId=new URL(window.location.href).searchParams.get("variant");this.selectedVariant=this.variantsData.find(variant=>variant.id===currentVariantId)||this.variantsData.find(variant=>variant.available==="true")||this.variantsData[0];const finalDiscountSpan=this.querySelector(".final-discount");finalDiscountSpan&&(this.defaultSubscriptionDiscountText=finalDiscountSpan.textContent.trim()),this.updateAtcBisButtons(),this.initEventListeners(),this.resizeSelect()}updateSubscriptionDiscountOverride(){const span=this.querySelector(".final-discount");
1if(!span||!this.selectedVariant)return;const override=((this.selectedVariant.metafields||{}).custom||{}).subscription_discount_display_override;override?span.textContent=`${override}%`:this.defaultSubscriptionDiscountText&&(span.textContent=this.defaultSubscriptionDiscountText)}resizeSelect(){if(this.variantSelect){const selectedOption=Array.from(this.variantSelect.querySelectorAll("option")).find(option=>option.selected),virtualSelect=this.variantSelect.cloneNode(!0);virtualSelect.style.position="absolute",virtualSelect.style.visibility="hidden",virtualSelect.style.maxWidth="none",virtualSelect.innerHTML=`<option>${selectedOption.textContent}</option>`,this.variantSelect.parentElement.appendChild(virtualSelect);const width=virtualSelect.offsetWidth;this.variantSelect.style.maxWidth=width<52?"none":`${width}px`,virtualSelect.remove()}}initEventListeners(){this.variantButtons.forEach(button=>{button.addEventListener("click",event=>this.handleVariantClick(event,button.dataset.variantId))}),this.variantSelect&&this.variantSelect.addEventListener("change",e=>{const variantId=e.target.value,productEl=this.closest("clover-product-item");if(productEl){const variantInput=productEl.querySelector("#variant-id");variantInput&&(variantInput.value=variantId),productEl.handleVariantClick(e,variantId)}}),this.pillInputs.forEach(radio=>{radio.addEventListener("change",e=>{const variantId=e.target.value;this.handleVariantClick(e,variantId)})}),this.purchaseOption&&(this.sellingPlanSelect&&this.sellingPlanSelect.addEventListener("change",e=>{const planId=this.sellingPlanSelect.querySelector(`option[value="${e.target.value}"]`).dataset.sellingPlanId;this.oneTimePurchase&&this.oneTimePurchase.checked||(this.sellingPlanInput.value=planId)}),this.purchaseOption.forEach(radio=>{radio.addEventListener("change",()=>{this.oneTimePurchase&&this.oneTimePurchase.checked?(this.querySelectorAll(".variant-description").forEach(el=>{const span=el.querySelector("span");span&&(span.innerText=el.dataset.pricePerUnit)}),this.sellingPlanInput&&(this.sellingPlanInput.value=""),this.atcDiscountPrice&&(this.atcDiscountPrice.textContent=""),this.atcFullPrice&&(this.atcFullPrice.textContent=this.selectedVariant.variant_price)):(this.querySelectorAll(".variant-description").forEach(el=>{const span=el.querySelector("span");span&&(span.innerText=el.dataset.subPerUnit)}),this.selectFirstSellingPlan(this.selectedVariant.selling_plans))})}))}handlePillChange(){const selectedOptions=[],optionGroups={};if(this.pillInputs.forEach(input=>{const name=input.name;optionGroups[name]||(optionGroups[name]=[]),input.checked&&optionGroups[name].push(input.value)}),Object.keys(optionGroups).forEach(name=>{selectedOptions.push(optionGroups[name][0])}),this.variantSelect){const selectedVariantTitle=Array.from(this.variantSelect.options).find(option=>selectedOptions.every(opt=>option.text.includes(opt)));if(selectedVariantTitle){const variantId=selectedVariantTitle.value;this.handleVariantClick(null,variantId)}}}updateAtcBisButtons(){if(!this.selectedVariant)return;const atc=this.querySelector(".product-atc"),bis=this.querySelector(".klaviyo-bis-trigger");this.selectedVariant.available===!0||this.selectedVariant.available==="true"?(atc&&atc.classList.remove("hidden"),bis&&(bis.classList.add("!hidden"),bis.classList.remove("!block"))):(atc&&atc.classList.add("hidden"),bis&&(bis.classList.remove("!hidden"),bis.classList.add("!block")))}handleVariantClick(event,variantId){if(this.selectedVariant=this.variantsData.find(variant=>variant.id===variantId),this.selectedVariant){const atc=this.querySelector(".product-atc"),bis=this.querySelector(".klaviyo-bis-trigger");this.selectedVariant.available=="true"?(atc&&atc.classList.remove("hidden"),bis&&(bis.classList.add("!hidden"),bis.classList.remove("!block"))):(atc&&atc.classList.add("hidden"),bis&&(bis.classList.remove("!hidden"),bis.classList.add("!block"))),this.subBoxOneTimePrice&&(this.subBoxOneTimePrice.textContent=this.selectedVariant.variant_price),this.atcFullPrice&&(this.atcFullPrice.textContent=this.selectedVariant.variant_price),this.atcDiscountPrice&&(this.selectedVariant.variant_compare_at_price?this.atcDiscountPrice.textContent=this.selectedVariant.variant_compare_at_price:this.atcDiscountPrice.textContent="");const subBoxSub=this.querySelector(".sub-box-sub"),firstPlan=this.selectedVariant.selling_plans[0];if(firstPlan&&firstPlan.price){const priceString=firstPlan.price,currencySymbol=priceString.replace(/[\d.-]/g,"").trim(),priceValue=parseFloat(priceString.replace(/[^\d.-]/g,"")),formattedPrice=this.formatPrice(priceValue);subBoxSub&&subBoxSub.classList.remove("hidden"),this.subBoxSubPrice&&(this.subBoxSubPrice.textContent=formattedPrice)}else this.oneTimePurchase&&this.oneTimePurchase.click(),subBoxSub&&subBoxSub.classList.add("hidden");this.variantInput&&(this.variantInput.value=this.selectedVariant.id),this.oneTimePurchase&&this.oneTimePurchase.checked?this.sellingPlanInput&&(this.sellingPlanInput.value=""):this.selectFirstSellingPlan(this.selectedVariant.selling_plans),this.variantButtons.forEach(btn=>btn.classList.remove("!border-[#AD2725]"));const selectedButton=Array.from(this.variantButtons).find(btn=>btn.dataset.variantId===variantId);if(selectedButton&&selectedButton.classList.add("!border-[#AD2725]"),this.variantSelect&&(this.variantSelect.value=variantId),this.resizeSelect(),window.location.pathname.includes("/product/")){const url=new URL(window.location.href);
1url.searchParams.set("variant",variantId),window.history.replaceState({},"",url)}}this.updateSubscriptionDiscountOverride()}updateSellingPlans(sellingPlans){const matchingSellingPlan=sellingPlans.filter(plan=>plan.selected_plan),subscriptionBox=this.sellingPlanSelect?.closest(".subscription-toggle-js")||null;!this.sellingPlanSelect||!subscriptionBox||(subscriptionBox.classList.toggle("hidden",matchingSellingPlan.length<=0),this.sellingPlanSelect.innerHTML=sellingPlans.map(plan=>plan.selected_plan?` 2 <option 3 id="${plan.plan_id}" 4 value="${plan.value}" 5 data-selling-plan-id="${plan.plan_id}" 6 data-selling-plan-price="${plan.price}" 7 > 8 ${plan.value.replace("-"," ")} 9 </option> 10 `:"").join(""))}formatPrice(price){return new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2,maximumFractionDigits:2}).format(price).replace(".00","")}selectFirstSellingPlan(sellingPlans=[]){const selectEl=this.container?.querySelector?.("#selling-plan-select")||document.getElementById("selling-plan-select"),firstOption=selectEl?.querySelector("option")||null,firstPlan=sellingPlans.find(p=>p.selected_plan);let chosenPlan=firstPlan||null;if(selectEl&&selectEl.options.length>0&&(selectEl.selectedIndex=0),firstOption&&(!firstPlan||firstOption.id!==firstPlan.plan_id)){const match=sellingPlans.find(p=>p.plan_id===firstOption.id);match&&(chosenPlan=match)}if(!chosenPlan&&sellingPlans.length&&(chosenPlan=sellingPlans[0]),!!chosenPlan){if(this.selectedSellingPlanId=chosenPlan.plan_id,this.selectedSellingPlanPrice=chosenPlan.price,typeof this.selectedSellingPlanPrice=="string"){const priceValue=parseFloat(this.selectedSellingPlanPrice.replace(/[^\d.-]/g,"")),formattedPrice=this.formatPrice(priceValue);this.atcFullPrice&&(this.atcFullPrice.textContent=formattedPrice),this.atcDiscountPrice&&(this.atcDiscountPrice.textContent=this.selectedVariant.variant_price)}this.sellingPlanInput&&(this.sellingPlanInput.value=this.selectedSellingPlanId)}}}customElements.define("clover-product-item",CloverProductItem);class SimpleCollapse extends HTMLElement{connectedCallback(){this.initEventListeners()}initEventListeners(){const collapseHeader=this.querySelector(".collapse-header"),collapseContent=this.querySelector(".collapse-content");collapseContent&&!collapseContent.id&&(SimpleCollapse._uid=(SimpleCollapse._uid||0)+1,collapseContent.id=`simple-collapse-content-${SimpleCollapse._uid}`),collapseHeader&&(collapseHeader.tagName!=="BUTTON"&&(collapseHeader.setAttribute("role","button"),collapseHeader.setAttribute("tabindex","0"),collapseHeader.addEventListener("keydown",e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this.toggleCollpase())})),collapseContent&&collapseHeader.setAttribute("aria-controls",collapseContent.id),collapseHeader.setAttribute("aria-expanded",collapseContent&&collapseContent.classList.contains("expanded")?"true":"false")),collapseHeader.addEventListener("click",()=>this.toggleCollpase())}toggleCollpase(){const collapseHeader=this.querySelector(".collapse-header"),collapseContent=this.querySelector(".collapse-content"),collapseIcon=this.querySelector(".collapse-icon");collapseContent.classList.contains("expanded")?(collapseContent.style.maxHeight="0px",collapseContent.classList.remove("expanded"),collapseHeader&&collapseHeader.setAttribute("aria-expanded","false"),collapseIcon.dataset.isEdit||(collapseIcon.style.transform="rotate(0deg)")):(collapseContent.style.maxHeight=collapseContent.scrollHeight+"px",collapseContent.classList.add("expanded"),collapseHeader&&collapseHeader.setAttribute("aria-expanded","true"),collapseIcon.dataset.isEdit||(collapseIcon.style.transform="rotate(45deg)"))}}customElements.define("simple-collapse",SimpleCollapse);class SmoothScroll extends HTMLElement{constructor(){super(),this.hasAttribute("role")||this.setAttribute("role","link"),this.hasAttribute("tabindex")||this.setAttribute("tabindex","0"),this._initSmoothScroll()}_scrollToTarget(){const targetId=this.getAttribute("href").substring(1),targetElement=document.getElementById(targetId);if(targetElement){const offsetPosition=targetElement.getBoundingClientRect().top+window.scrollY-100;window.scrollTo({top:offsetPosition,behavior:"smooth"})}}_initSmoothScroll(){this.addEventListener("click",e=>{e.preventDefault(),this._scrollToTarget()}),this.addEventListener("keydown",e=>{(e.key==="Enter"||e.key===" ")&&(e.preventDefault(),this._scrollToTarget())})}}customElements.define("smooth-scroll",SmoothScroll);class CartToggle extends HTMLElement{constructor(){super()}connectedCallback(){this.querySelector("button")||console.warn("Cart toggle component should have a button as a child!"),this.addEventListener("click",e=>{const cart=document.querySelector("site-cart");cart&&cart.toggleCart()})}}customElements.define("cart-toggle",CartToggle);class CartItem extends HTMLElement{constructor(){super()}connectedCallback(){this.cart=this.closest("site-cart"),this.itemTotals=this.querySelector(".item-totals"),this.quantityInputEl=this.querySelector("number-input input"),this.cartIndex=parseInt(this.dataset.cartIndex,10),this.variantId=this.dataset.variantId,this.addRemoveBundleEvent(),this.addSubscriptionHandlers(),this.addQuantityChangeEvent(),this.addRemoveEvent()}showLoader(){this.itemTotals&&(this.itemTotals.firstElementChild.classList.add("hidden"),this.itemTotals.lastElementChild.classList.remove("hidden"))}hideLoader(){this.itemTotals&&(this.itemTotals.firstElementChild.classList.remove("hidden"),this.itemTotals.lastElementChild.classList.add("hidden"))}
10addSubscriptionHandlers(){const upgradeButtonEl=this.querySelector(".upgrade-to-sub-js"),sellingPlanSelectEl=this.querySelector(".selling-plan-select");upgradeButtonEl&&sellingPlanSelectEl&&(upgradeButtonEl.addEventListener("click",()=>{sellingPlanSelectEl.focus(),sellingPlanSelectEl.click()}),sellingPlanSelectEl.addEventListener("change",async()=>{const planId=sellingPlanSelectEl.value;if(!planId)return;const quantity=this.quantityInputEl?parseInt(this.quantityInputEl.value,10):1;await this.convertLineToSubscription({planId,quantity})}))}async convertLineToSubscription({planId,quantity}){this.showLoader();try{await fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({line:this.cartIndex,quantity:0})}),await this.cart.addVariantToCart(this.variantId,quantity,parseInt(planId,10)),this.hideLoader(),this.cart.handleRewards()}catch(err){alert(err.message)}}addQuantityChangeEvent(){this.quantityInputEl&&this.quantityInputEl.addEventListener("change",()=>{this.showLoader(),this.cart.updateQuantity(this.cartIndex,+this.quantityInputEl.value)})}addRemoveEvent(){const itemRemove=this.querySelector(".item-remove");itemRemove&&itemRemove.addEventListener("click",async e=>{this.showLoader();const updates={[this.variantId]:0};await this.cart.updateCart(updates),this.cart.handleRewards()})}addRemoveBundleEvent(){const bundleRemove=document.querySelector(".bundle-remove");bundleRemove&&bundleRemove.addEventListener("click",async e=>{const bundleItems=Array.from(this.cart.querySelectorAll("[data-bundle-id]"));bundleItems.forEach(item=>{item.showLoader()});const updates=bundleItems.reduce((acc,item)=>({...acc,[item.variantId]:0}),{});await this.cart.updateCart(updates),await this.cart.handleRewards()})}}customElements.define("cart-item",CartItem);class SiteCart extends HTMLElement{constructor(){super(),this.cart=null,this._lastFocused=null,this._onKeydown=null}connectedCallback(){this.cart=document.querySelector(".site-cart"),this.handleRewards()}getFocusableElements(){return Array.from(this.cart.querySelectorAll("a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]")).filter(el=>el.getAttribute("tabindex")!=="-1"&&el.getClientRects().length>0)}setToggleExpanded(expanded){document.querySelectorAll('[aria-controls="CartDrawer"]').forEach(toggle=>{toggle.setAttribute("aria-expanded",expanded?"true":"false")})}openCart(){this.cart&&(this.cart.classList.add("active"),document.body.style.overflow="hidden",this.setToggleExpanded(!0),this._lastFocused=document.activeElement,window.setTimeout(()=>{const closeButton=this.cart.querySelector("#close-menu"),focusables=this.getFocusableElements(),target=closeButton||focusables[0];target&&target.focus()},100),this._onKeydown=e=>{if(e.key==="Escape"){this.closeCart();return}if(e.key!=="Tab")return;const focusables=this.getFocusableElements();if(!focusables.length)return;const first=focusables[0],last=focusables[focusables.length-1],active=document.activeElement;e.shiftKey?(active===first||!this.cart.contains(active))&&(e.preventDefault(),last.focus()):(active===last||!this.cart.contains(active))&&(e.preventDefault(),first.focus())},document.addEventListener("keydown",this._onKeydown))}closeCart(){this.cart&&(this.cart.classList.remove("active"),document.body.removeAttribute("style"),this.setToggleExpanded(!1),this._onKeydown&&(document.removeEventListener("keydown",this._onKeydown),this._onKeydown=null),this._lastFocused&&document.contains(this._lastFocused)&&this._lastFocused.focus(),this._lastFocused=null)}toggleCart(){this.cart.classList.contains("active")?this.closeCart():this.openCart()}getCartSections(){return[{section:"main-cart-items",selector:"#main-cart-items"},{section:"main-cart-footer",selector:"#main-cart-footer"},{section:"main-cart-header",selector:"#main-cart-header"},{section:"main-cart-recommendations",selector:"#main-cart-recommendations"},{section:"header",selector:"#header"}]}getSectionInnerHTML(html,selector){const el=new DOMParser().parseFromString(html,"text/html").querySelector(selector);return el?el.innerHTML:""}renderCartSections(sections){const getSections=this.getCartSections();
10Object.keys(sections).forEach(sectionKey=>{const activeSection=getSections.find(s=>s.section===sectionKey),elToReplace=document.querySelector(activeSection.selector);if(elToReplace){const html=this.getSectionInnerHTML(sections[sectionKey],activeSection.selector);elToReplace&&(elToReplace.innerHTML=html)}})}buildConfig(body){return{body,method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"}}}addVariantToCart(id,quantity=1,sellingPlan){const items=[sellingPlan?{id,quantity,selling_plan:sellingPlan}:{id,quantity}],sections=this.getCartSections().map(s=>s.section),body=JSON.stringify({items,sections}),config=this.buildConfig(body);return this.cart.classList.contains("active")||this.toggleCart(),fetch("/cart/add",config).then(response=>response.json()).then(response=>{if(response.status){window.ghiaReport&&window.ghiaReport("cart_error",{error_message:response.description||response.message,error_stage:"add_rejected",variant_id:items[0]&&items[0].id,selling_plan:sellingPlan||"none",http_status:response.status}),this.handleErrorMessage(response.description);return}this.renderCartSections(response.sections),this.handleRewards(),document.dispatchEvent(new CustomEvent("cart:updated"))}).catch(e=>{window.ghiaReport&&window.ghiaReport("cart_error",{error_message:e&&e.message?e.message:String(e),error_stage:"add_exception",variant_id:items[0]&&items[0].id,selling_plan:sellingPlan||"none"})})}updateQuantity(line,quantity){const sections=this.getCartSections().map(s=>s.section),body=JSON.stringify({line,quantity,sections}),config=this.buildConfig(body);return fetch("/cart/change",config).then(response=>response.json()).then(response=>{this.renderCartSections(response.sections),this.handleRewards(),document.dispatchEvent(new CustomEvent("cart:updated"))}).catch(e=>{window.ghiaReport&&window.ghiaReport("cart_error",{error_message:e&&e.message?e.message:String(e),error_stage:"change_exception"})})}updateCart(updates,shouldRefresh=!0){const sections=this.getCartSections().map(s=>s.section),body=JSON.stringify({updates,sections}),config=this.buildConfig(body);return console.log(updates),fetch("/cart/update",config).then(response=>response.json()).then(response=>{shouldRefresh&&this.renderCartSections(response.sections),document.dispatchEvent(new CustomEvent("cart:updated"))}).catch(()=>{})}addSellingPlan(variantId,sellingPlan){const sections=this.getCartSections().map(s=>s.section),body=JSON.stringify({id:variantId,selling_plan:sellingPlan,sections}),config=this.buildConfig(body);return fetch("/cart/change",config).then(response=>response.json()).then(response=>{this.renderCartSections(response.sections),this.addSelectEvents(),document.dispatchEvent(new CustomEvent("cart:updated"))}).catch(()=>{})}async addBundleVariantToCart(parentVariantId,childVariantsId,sellingPlan){const getStayAiGuid=()=>{let d=new Date().getTime(),d2=performance&&performance.now&&performance.now()*1e3||0;return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,c=>{let r=Math.random()*16;return d>0?(r=(d+r)%16|0,d=Math.floor(d/16)):(r=(d2+r)%16|0,d2=Math.floor(d2/16)),(c=="x"?r:r&7|8).toString(16)})},token=(await(await fetch("/cart.js")).json()).token.split("?key")[0],stayAiGuid=getStayAiGuid(),bundleData=document.querySelector("custom-bundle").bundleData.data,cartItems=childVariantsId.map(childVariantId=>({id:childVariantId,quantity:1,properties:{__pdqId:token,_bundle_id:stayAiGuid},selling_plan:sellingPlan})),items=[{id:parentVariantId,quantity:1,properties:{__pdqId:token,_bundle_id:stayAiGuid,_bundle_parent:!0,_bundle_max:12,_bundle_min:3},selling_plan:sellingPlan},...cartItems],sections=this.getCartSections().map(s=>s.section),body=JSON.stringify({items,sections}),config=this.buildConfig(body);return this.cart.classList.contains("active")||this.toggleCart(),fetch("/cart/add",config).then(response=>response.json()).then(response=>{if(response.status){window.ghiaReport&&window.ghiaReport("cart_error",{error_message:response.description||response.message,error_stage:"add_rejected",variant_id:items[0]&&items[0].id,selling_plan:sellingPlan||"none",http_status:response.status}),this.handleErrorMessage(response.description);return}this.renderCartSections(response.sections),this.handleRewards(),document.dispatchEvent(new CustomEvent("cart:updated"))}).catch(e=>{window.ghiaReport&&window.ghiaReport("cart_error",{error_message:e&&e.message?e.message:String(e),error_stage:"add_exception",variant_id:items[0]&&items[0].id,selling_plan:sellingPlan||"none"})})}setCartNote(note){const body=JSON.stringify({note}),config=this.buildConfig(body);return fetch("/cart/update",config).then(response=>response.json()).then(response=>{this.renderCartSections(response.sections),document.dispatchEvent(new CustomEvent("cart:updated"))}).catch(()=>{})}async fetchCart(){const uri=window.Shopify.routes.root+"cart.js";return await(await fetch(uri,{method:"GET",headers:{"Content-Type":"application/json"}})).json()}async handleRewards(){const cart=await this.fetchCart(),rewards=this.querySelector("cart-rewards");if(!rewards)return;const subtotal=cart.total_price,shippingThreshold=Number(rewards.dataset.shippingThreshold),giftThreshold=Number(rewards.dataset.giftThreshold),giftEnabled=rewards.dataset.giftEnabled==="true",hasSubscription=Array.isArray(cart.items)&&cart.items.some(item=>!!item.selling_plan_allocation||!!item.selling_plan||!!item.selling_plan_id||item.properties&&("shipping_interval_unit_type"in item.properties||"subscription_id"in item.properties||"subscription"in item.properties)),formatCurrency=amount=>new Intl.NumberFormat("en-US",{style:"currency",currency:"USD",minimumFractionDigits:2}).format(amount/100).replace(".00",""),toggleIconState=(type,isAchieved)=>{const iconWrapper=rewards.querySelector(`[data-icon="${type}"]`);if(!iconWrapper)return;iconWrapper.classList.toggle("bg-burgundy",isAchieved);const img=iconWrapper.querySelector(".icon-image"),check=iconWrapper.querySelector(".icon-check");img&&img.classList.toggle("hidden",isAchieved),check&&check.classList.toggle("hidden",!isAchieved)},emptyMsg=rewards.querySelector('[data-status="empty"]'),pendingMsg=rewards.querySelector('[data-status="pending"]'),mixedMsg=rewards.querySelector('[data-status="shipping-earned-gift-pending"]'),earnedMsg=rewards.querySelector('[data-status="earned"]');[emptyMsg,pendingMsg,mixedMsg,earnedMsg].forEach(el=>el?.classList.add("hidden"));const shippingMet=hasSubscription||subtotal>=shippingThreshold,giftMet=giftEnabled&&subtotal>=giftThreshold;if(toggleIconState("shipping",shippingMet),toggleIconState("gift",giftEnabled&&giftMet),subtotal===0&&!hasSubscription)emptyMsg?.classList.remove("hidden");else if(shippingMet&&giftEnabled&&giftMet)earnedMsg?.classList.remove("hidden");else if(shippingMet&&giftEnabled&&!giftMet){const giftRemaining=giftThreshold-subtotal,giftSpan=mixedMsg?.querySelector(".gift-remaining");giftSpan&&(giftSpan.textContent=formatCurrency(giftRemaining)),mixedMsg?.classList.remove("hidden")}else if(shippingMet)shippingMet&&!giftEnabled&&earnedMsg?.classList.remove("hidden");else{const shippingRemaining=shippingThreshold-subtotal,shippingSpan=pendingMsg?.querySelector(".shipping-remaining");if(shippingSpan&&(shippingSpan.textContent=formatCurrency(shippingRemaining)),giftEnabled){const giftRemaining=giftThreshold-subtotal,giftSpan=pendingMsg?.querySelector(".gift-remaining");giftSpan&&(giftSpan.textContent=formatCurrency(giftRemaining))}pendingMsg?.classList.remove("hidden")}let nextThreshold;if(giftEnabled){const thresholds=[shippingThreshold,giftThreshold].sort((a,b)=>a-b);nextThreshold=thresholds.find(t=>subtotal<t)||thresholds[1]}else nextThreshold=shippingThreshold;const progress=hasSubscription?100:Math.min(subtotal/nextThreshold*100,100),bar=rewards.querySelector(".percentage-bar");bar&&(bar.style.width=`${progress}%`)}}customElements.define("site-cart",SiteCart);class NumberInput extends HTMLElement{constructor(){super(),this.input=this.querySelector("input"),this.changeEvent=ne
10w Event("change",{bubbles:!0}),this.querySelectorAll("button").forEach(button=>button.addEventListener("click",this.onButtonClick.bind(this)))}onButtonClick(event){event.preventDefault();const previousValue=this.input.value,button=event.target.closest("button");button&&(button.name==="increment"?this.input.stepUp():this.input.stepDown(),previousValue!==this.input.value&&this.input.dispatchEvent(this.changeEvent))}}customElements.define("number-input",NumberInput);class CartAdd extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListener("click",async e=>{const form=e.target.closest("form");e.preventDefault();const isBundleForm=this.dataset.isBundleForm==="true",$id=form.querySelector('[name="id"]'),$qty=form.querySelector('[name="quantity"]'),$sellingPlan=form.querySelector('[name="selling_plan"]'),qty=$qty?$qty.value:1,sellingPlan=$sellingPlan&&$sellingPlan.value?$sellingPlan.value.trim():null;if($id){const cart=document.querySelector("site-cart");if(cart)if(isBundleForm){const variantId=document.querySelector(".tab-input-button.active").dataset.variantId,selectedItems=document.querySelector("custom-bundle")?.selectedItems;await cart.addBundleVariantToCart(variantId,selectedItems.map(({id})=>id),sellingPlan)}else await cart.addVariantToCart($id.value,qty,sellingPlan)}})}}customElements.define("cart-add",CartAdd);class CartRemove extends HTMLElement{constructor(){super()}connectedCallback(){this.addEventListener("click",async e=>{e.preventDefault();const cart=document.querySelector("site-cart"),idx=this.dataset.index;cart&&await cart.updateQuantity(idx,0)})}}customElements.define("cart-remove",CartRemove);class DynamicSelect extends HTMLElement{connectedCallback(){this.select=this.querySelector("select"),this.label=this.querySelector("label"),this.select&&(this.updateLabel(this.select),this.initEventListeners())}initEventListeners(){this.select.addEventListener("change",()=>{this.updateLabel(this.select),this.resizeSelect(this.select)})}updateLabel(select){if(!this.label||!select)return;const selectedOption=select.selectedOptions[0];this.label.textContent=selectedOption?selectedOption.textContent:""}resizeSelect(select){if(!select)return;const container=this.querySelector(".select-container"),selectedOption=select.selectedOptions[0],virtualSelect=document.createElement("span");virtualSelect.style.position="absolute",virtualSelect.style.visibility="hidden",virtualSelect.style.whiteSpace="nowrap",virtualSelect.textContent=selectedOption.textContent,document.body.appendChild(virtualSelect);const width=virtualSelect.offsetWidth;container.style.minWidth=`${width+32}px`,select.style.minWidth=`${width+32}px`,virtualSelect.remove()}}customElements.define("dynamic-select",DynamicSelect);class DisplaySelector extends HTMLElement{connectedCallback(){this.buttons=this.querySelectorAll("[id^='button-selector-']"),this.contents=this.querySelectorAll("[id^='content-selector-']"),this.linkSelector=this.querySelector("#link-selector"),this.initEventListeners()}initEventListeners(){this.buttons.forEach(button=>{const activate=()=>{const selectorHandle=button.id.replace("button-selector-","");this.updateVisibleContent(selectorHandle),this.updateLinkElement(button),this.updateButtonStyles(button)};button.addEventListener("mouseover",activate),button.addEventListener("focus",activate)})}updateVisibleContent(selectorHandle){this.contents.forEach(content=>{content.id===`content-selector-${selectorHandle}`?(content.classList.remove("invisible","opacity-0","absolute"),content.classList.add("opacity-100")):(content.classList.add("invisible","opacity-0","absolute"),content.classList.remove("opacity-100"))})}updateLinkElement(button){const href=button.getAttribute("data-link-url");href&&(this.linkSelector.setAttribute("href",href),this.linkSelector.setAttribute("title",`${button.textContent.trim()} Collection`))}updateButtonStyles(activeButton){this.buttons.forEach(button=>{button===activeButton?button.classList.add("underline","underline-offset-4"):button.classList.remove("underline","underline-offset-4")})}}customElements.define("display-selector",DisplaySelector);class HeaderMenu extends HTMLElement{connectedCallback(){this.megaMenuLink=this.querySelector("#mega-menu-link"),this.megaMenuContainer=this.querySelector(".mega-menu-container"),this.resizeMegaMenu(),this.megaMenuListeners()}resizeMegaMenu(){const scrollbarWidth=window.innerWidth-document.documentElement.clientWidth;this.querySelector(".mega-menu-container").style.width=`calc(100vw - ${scrollbarWidth}px)`}megaMenuListeners(){this.megaMenuLink.addEventListener("mouseenter",()=>{this.openMegaMenu()}),this.megaMenuLink.addEventListener("mouseleave",()=>{this.closeMegaMenu()}),this.megaMenuContainer.addEventListener("mouseenter",()=>{this.openMegaMenu()}),this.megaMenuContainer.addEventListener("mouseleave",()=>{this.closeMegaMenu()}),this.megaMenuLink.addEventListener("focusin",()=>{this.openMegaMenu()}),this.addEventListener("focusout",e=>{this.contains(e.relatedTarget)||this.closeMegaMenu()}),this.addEventListener("keydown",e=>{if(e.key==="Escape"){this.closeMegaMenu();const link=this.megaMenuLink.querySelector("a")||this.megaMenuLink;typeof link.focus=="function"&&link.focus()}})}iconArrowStyle(){const icon=this.querySelector(".icon-arrow");icon.classList.contains("rotate-180")?icon.classList.remove("rotate-180"):icon.classList.add("rotate-180")}
10openMegaMenu(){this.megaMenuContainer.classList.contains("active")||(this.megaMenuContainer.classList.add("active"),this.iconArrowStyle(),this.setLinkExpanded(!0))}closeMegaMenu(){this.megaMenuContainer.classList.contains("active")&&(this.megaMenuContainer.classList.remove("active"),this.iconArrowStyle(),this.setLinkExpanded(!1))}setLinkExpanded(expanded){(this.megaMenuLink.querySelector("a")||this.megaMenuLink).setAttribute("aria-expanded",expanded?"true":"false")}}customElements.define("header-menu",HeaderMenu);class PillSelector extends HTMLElement{connectedCallback(){this.querySelectorAll('input[type="radio"]').forEach(input=>{input.addEventListener("change",e=>{const name=input.name;if(this.querySelectorAll(`input[name="${name}"]`).forEach(radio=>{radio.closest("label").classList.remove("!bg-burgundy","!text-cream"),radio.closest("label").classList.add("text-burgundy")}),input.checked){input.closest("label").classList.add("!bg-burgundy","!text-cream"),input.closest("label").classList.remove("text-burgundy");const variantId=input.value;this.querySelectorAll(".variant-description").forEach(el=>{el.classList.toggle("hidden",el.dataset.variantId!==variantId)})}})})}}customElements.define("pill-selector",PillSelector);class VariantSelectorSwipe extends HTMLElement{connectedCallback(){this.setupListeners()}setupListeners(){const select=this.querySelector("#variant-select"),carousels=document.querySelectorAll(".media-carousel");select&&select.addEventListener("change",e=>{const variantId=e.target.value,rawAssociatedGalleryImageIndex=e.target.querySelector("option:checked").dataset.associatedGalleryImageIndex,associatedGalleryImageIndex=rawAssociatedGalleryImageIndex?+rawAssociatedGalleryImageIndex-1:null,productEl=this.closest("clover-product-item");if(productEl){const variantInput=productEl.querySelector("#variant-id");variantInput&&(variantInput.value=variantId),productEl.handleVariantClick(e,variantId)}this.syncCarouselToVariant(variantId,carousels,associatedGalleryImageIndex)}),this.querySelectorAll('input[type="radio"]').forEach(radio=>{radio.addEventListener("change",e=>{const variantId=e.target.value,associatedGalleryImageIndex=e.target.dataset.associatedGalleryImageIndex?+e.target.dataset.associatedGalleryImageIndex-1:null,productEl=this.closest("clover-product-item");if(productEl){const variantInput=productEl.querySelector("#variant-id");variantInput&&(variantInput.value=variantId),productEl.handleVariantClick(e,variantId)}this.syncCarouselToVariant(variantId,carousels,associatedGalleryImageIndex)})})}syncCarouselToVariant(variantId,carousels,associatedGalleryImageIndex){associatedGalleryImageIndex!==0&&!associatedGalleryImageIndex||carousels.forEach(carousel=>{if(console.log("### associatedGalleryImageIndex",associatedGalleryImageIndex),!carousel)return;const slides=Array.from(carousel.querySelectorAll(".swiper-slide")),selectedSlide=slides.find(slide=>slide.dataset.variantId===variantId);selectedSlide&&(carousel.activeIndex=slides.indexOf(selectedSlide),carousel.slideTo(associatedGalleryImageIndex))})}}customElements.define("variant-selector-swipe",VariantSelectorSwipe);class CheckoutButton extends HTMLElement{connectedCallback(){const button=this.querySelector("button");button.addEventListener("click",async e=>{button.innerText="Checkout Out...";const fromVal=document.querySelector('input[name="note_from"]').value,toVal=document.querySelector('input[name="note_to"]').value,messageVal=document.querySelector('textarea[name="note_message"]').value.replace(/\n/g," ");if(messageVal){const giftNote=` 11 ${fromVal?`From: ${fromVal}`:""} 12 ${toVal?`To: ${toVal}`:""} 13 ${messageVal?`Message: ${messageVal}`:""} 14 `;await document.querySelector("site-cart").setCartNote(giftNote)}window.location.href="/checkout"})}}customElements.define("checkout-button",CheckoutButton);class GiftNoteSubmit extends HTMLElement{constructor(){super()}connectedCallback(){this.variantId=this.dataset.variantId,this.noteToInput=this.querySelector('input[name="note_to"]'),this.noteFromInput=this.querySelector('input[name="note_from"]'),this.noteMessageInput=this.querySelector('textarea[name="note_message"]'),this.submitBtn=this.querySelector(".gift-note-submit-btn"),this.collapseIcon=this.closest("simple-collapse").querySelector(".collapse-icon"),this.initEventListeners(),this.loadNoteFromCart()}initEventListeners(){this.submitBtn.addEventListener("click",()=>this.handleSubmit()),document.addEventListener("cart:updated",()=>this.checkVariantInCart())}async handleSubmit(){const toVal=this.noteToInput.value,fromVal=this.noteFromInput.value,messageVal=this.noteMessageInput.value.replace(/\n/g," ");
14if(!messageVal.trim())return;this.setSubmittingState(!0);const giftNote=`From: ${fromVal} 15To: ${toVal} 16Message: ${messageVal}`,cart=document.querySelector("site-cart");if(cart){if(await cart.setCartNote(giftNote),this.variantId&&this.variantId.trim()){const giftItemIndex=(await fetch("/cart.js").then(r=>r.json())).items.findIndex(item=>item.properties&&item.properties._gift_note_item);giftItemIndex===-1?await this.addVariantToCart():await this.updateGiftItemProperties(giftItemIndex+1,toVal,fromVal,messageVal)}this.updateCollapseIcon(!0),this.closeCollapse(),this.setSubmittingState(!1)}}setSubmittingState(isSubmitting){isSubmitting?(this.submitBtn.disabled=!0,this.submitBtn.dataset.originalText=this.submitBtn.textContent,this.submitBtn.textContent="Submitting..."):(this.submitBtn.disabled=!1,this.submitBtn.textContent=this.submitBtn.dataset.originalText||"Submit")}async addVariantToCart(){const sections=["main-cart-items","main-cart-footer","main-cart-header","main-cart-recommendations","header"];try{const toVal=this.noteToInput.value,fromVal=this.noteFromInput.value,messageVal=this.noteMessageInput.value.replace(/\n/g," "),addData=await(await fetch("/cart/add.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({items:[{id:parseInt(this.variantId),quantity:1,properties:{_gift_note_item:"true",_sort_order:"999",To:toVal||"",From:fromVal||"",Message:messageVal||""}}],sections})})).json();if(addData.status||addData.errors){console.warn("Could not add gift variant to cart:",addData);return}const cart=document.querySelector("site-cart");cart&&(cart.renderCartSections(addData.sections),cart.handleRewards(),document.dispatchEvent(new CustomEvent("cart:updated")))}catch(error){console.warn("Error adding gift variant to cart:",error)}}async updateGiftItemProperties(lineIndex,toVal,fromVal,message){const messageVal=message.replace(/\n/g," "),sections=["main-cart-items","main-cart-footer","main-cart-header","main-cart-recommendations","header"];try{const updateData=await(await fetch("/cart/change.js",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({line:lineIndex,properties:{_gift_note_item:"true",_sort_order:"999",To:toVal||"",From:fromVal||"",Message:messageVal||""},sections})})).json();if(updateData.status||updateData.errors){console.warn("Could not update gift item properties:",updateData);return}const cart=document.querySelector("site-cart");cart&&(cart.renderCartSections(updateData.sections),cart.handleRewards(),document.dispatchEvent(new CustomEvent("cart:updated")))}catch(error){console.warn("Error updating gift item properties:",error)}}closeCollapse(){const collapse=this.closest("simple-collapse");collapse&&collapse.toggleCollpase()}async loadNoteFromCart(){try{const data=await(await fetch("/cart.js")).json();data&&data.note&&(this.parseAndPopulateNote(data.note),this.updateCollapseIcon(!0))}catch(error){console.error("Error loading cart note:",error)}}parseAndPopulateNote(note){const fromMatch=note.match(/From:\s*(.+?)(?:\n|$)/),toMatch=note.match(/To:\s*(.+?)(?:\n|$)/),messageMatch=note.match(/Message:\s*(.+?)(?:\n|$)/s);fromMatch&&fromMatch[1]&&(this.noteFromInput.value=fromMatch[1].trim()),toMatch&&toMatch[1]&&(this.noteToInput.value=toMatch[1].trim()),messageMatch&&messageMatch[1]&&(this.noteMessageInput.value=messageMatch[1].trim())}updateCollapseIcon(hasNote){hasNote?(this.collapseIcon.innerHTML='<span class="text-sm underline">Edit</span>',this.collapseIcon.dataset.isEdit="true",this.collapseIcon.style.transform="none"):(this.collapseIcon.innerHTML=`<svg width="16" viewB
16ox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg"> 17 <path d="M9.51465 1.01489L9.51465 17.9855" stroke="#661B32" stroke-width="1.5" stroke-linecap="round"/> 18 <path d="M18 9.50012L1.02944 9.50012" stroke="#661B32" stroke-width="1.5" stroke-linecap="round"/> 19 </svg>`,delete this.collapseIcon.dataset.isEdit)}async checkVariantInCart(){if(!(!this.variantId||!this.variantId.trim()))try{const data=await(await fetch("/cart.js")).json();!data.items.some(item=>item.variant_id.toString()===this.variantId)&&data.note&&await this.clearNote()}catch(error){console.error("Error checking variant in cart:",error)}}async clearNote(){const cart=document.querySelector("site-cart");cart&&(await cart.setCartNote(""),this.noteToInput.value="",this.noteFromInput.value="",this.noteMessageInput.value="",this.updateCollapseIcon(!1))}}customElements.define("gift-note-submit",GiftNoteSubmit);class PressGrid extends HTMLElement{connectedCallback(){this.ctaButton=this.querySelector(".button"),this.maskContainer=this.querySelector(".mask-container"),this.ctaButton&&this.ctaButton.addEventListener("click",()=>this.expandGridContainer()),this.observeVideos()}observeVideos(){const videos=this.querySelectorAll("video");if(!videos.length)return;const observer=new IntersectionObserver(entries=>{entries.forEach(entry=>{const video=entry.target;entry.isIntersecting?video.play().catch(()=>{}):video.pause()})},{threshold:.25});videos.forEach(video=>observer.observe(video))}playAllVideos(){this.querySelectorAll("video").forEach(video=>{video.play().catch(()=>{})})}expandGridContainer(){this.mainContent=this.querySelector(".main-content-js"),this.mainContent.classList.contains("max-h-[750px]")?(this.mainContent.classList.remove("max-h-[750px]"),this.maskContainer.classList.add("hidden"),this.ctaButton.innerText="View Less",this.playAllVideos()):(this.mainContent.classList.add("max-h-[750px]"),this.maskContainer.classList.remove("hidden"),this.ctaButton.innerText="View More")}}customElements.define("press-grid",PressGrid);class KlaviyoSignup extends HTMLElement{constructor(){super()}connectedCallback(){this.form=this.querySelector("form"),this.form&&this.form.addEventListener("submit",e=>{e.preventDefault(),this.submitForm(e)})}async submitForm(e){const error=this.querySelector(".error"),success2=this.querySelector(".success"),email=this.form.querySelector('[type="email"]'),submit=this.form.querySelector('[type="submit"]'),listId=this.dataset.listId,submitText=submit.innerHTML;error.innerHTML="",submit.innerHTML="Submitting...";const payload={data:{type:"subscription",attributes:{profile:{data:{type:"profile",attributes:{email:email.value,subscriptions:{email:{marketing:{consent:"SUBSCRIBED"}}}}}}},...listId&&{relationships:{list:{data:{type:"list",id:listId}}}}}};try{const resp=await fetch("https://a.klaviyo.com/client/subscriptions/?company_id=LL98XZ",{method:"POST",headers:{Accept:"application/vnd.api+json","Content-Type":"application/vnd.api+json",revision:"2025-01-15"},body:JSON.stringify(payload)});if(!resp.ok){const errorData=await resp.json();throw new Error(errorData.errors?.[0]?.detail||"Klaviyo subscription request failed")}this.form.reset(),submit.innerHTML=submitText,success2.classList.remove("hidden"),email.blur()}catch(e2){error.classList.remove("hidden"),error.innerHTML=e2.message||"Oops, there was an error. Please try again.",submit.innerHTML=submitText}}}customElements.define("klaviyo-signup",KlaviyoSignup);class ProductChecker extends HTMLElement{constructor(){super()}connectedCallback(){this.productHandle=this.dataset.productHandle,this.currentUrl=new URL(window.location.href),this.productId=this.dataset.productId,this.checkProductHandle(),this.productHandle==="giftcard"&&this.observeVariantChanges()}checkProductHandle(){this.productHandle=="giftcard"&&this.updateUrl(this.productId)}observeVariantChanges(){const variantInput=document.querySelector("#variant-id");variantInput&&(new MutationObserver(()=>{variantInput.value&&this.updateUrl(variantInput.value)}).observe(variantInput,{attributes:!0,attributeFilter:["value"]}),variantInput.addEventListener("input",()=>{variantInput.value&&this.updateUrl(variantInput.value)}),variantInput.addEventListener("change",()=>{variantInput.value&&this.updateUrl(variantInput.value)}))}updateUrl(variantId){const url=new URL(window.location.href);
19url.searchParams.set("variant",variantId),window.history.replaceState({},"",url.toString())}}customElements.define("product-checker",ProductChecker);class SmartMarquee extends HTMLElement{constructor(){super(),this._raf=null,this._supportsHover=typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(hover: hover)").matches,this._wrapper=null,this._onResize=this._onResize.bind(this),this._onPauseEnter=this._onPauseEnter.bind(this),this._onPauseLeave=this._onPauseLeave.bind(this),this._pauseTargets=new Set,this._sectionId=null}connectedCallback(){this._sectionId=this.getAttribute("data-section-id")||this.closest("[data-section-id]")?.getAttribute("data-section-id")||null,(this.getAttribute("direction")||"").toLowerCase()==="reverse"?this.setAttribute("data-direction","reverse"):this.removeAttribute("data-direction"),this.refresh(),this._attachPauseTargets();const baseTrack=this.querySelector('[data-smart-marquee-track="base"]');baseTrack&&typeof ResizeObserver<"u"&&(this._trackObserver=new ResizeObserver(()=>{this._raf&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>this.refresh())}),this._trackObserver.observe(baseTrack)),window.addEventListener("resize",this._onResize)}disconnectedCallback(){window.removeEventListener("resize",this._onResize),this._detachPauseTargets(),this._raf&&cancelAnimationFrame(this._raf),this._trackObserver&&this._trackObserver.disconnect()}_onResize(){this._raf&&cancelAnimationFrame(this._raf),this._raf=requestAnimationFrame(()=>this.refresh())}_attachPauseTargets(){const scope=(this._sectionId?document.querySelector(`[data-section-id="${this._sectionId}"]`):null)||this;Array.from(scope.querySelectorAll("[data-smart-marquee-pause]")).filter(el=>el.closest("smart-marquee")===this).forEach(el=>{this._pauseTargets.has(el)||(this._pauseTargets.add(el),el.addEventListener("mouseenter",this._onPauseEnter),el.addEventListener("mouseleave",this._onPauseLeave))})}_detachPauseTargets(){this._pauseTargets.forEach(el=>{el.removeEventListener("mouseenter",this._onPauseEnter),el.removeEventListener("mouseleave",this._onPauseLeave)}),this._pauseTargets.clear()}_onPauseEnter(){this.pause()}_onPauseLeave(){this.resume()}_setPausedState(isPaused){if(this._wrapper=this._wrapper||this.querySelector(".smart-marquee-wrapper"),!!this._wrapper){try{(this._wrapper.getAnimations?this._wrapper.getAnimations():[]).forEach(a=>isPaused?a.pause():a.play())}catch{}this._wrapper.style.animationPlayState=isPaused?"paused":"running"}}pause(){this.classList.add("is-paused"),this._setPausedState(!0)}resume(){this.classList.remove("is-paused"),this._setPausedState(!1)}refresh(){const wrapper=this.querySelector(".smart-marquee-wrapper");if(!wrapper||(this._wrapper=wrapper,!this.getBoundingClientRect().width))return;this.classList.add("is-looping");const baseTrack=wrapper.querySelector('[data-smart-marquee-track="base"]');if(baseTrack){const pxPerSecond=parseFloat(this.getAttribute("data-speed"))||50,duration=baseTrack.getBoundingClientRect().width/pxPerSecond;wrapper.style.animationDuration=`${duration}s`}this._attachPauseTargets(),this.classList.contains("is-paused")&&this._setPausedState(!0)}}if(customElements.define("smart-marquee",SmartMarquee),window.matchMedia("(prefers-reduced-motion: reduce)").matches){const pauseAutoplayVideos=()=>{document.querySelectorAll("video[autoplay]").forEach(video=>{video.removeAttribute("autoplay"),video.pause()})};document.readyState==="loading"?document.addEventListener("DOMContentLoaded",pauseAutoplayVideos):pauseAutoplayVideos()} 20//# sourceMappingURL=/cdn/shop/t/243/assets/web-components.js.map?v=132494185112185805831786908510
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.