1function getFocusableElements(container){return Array.from(container.querySelectorAll("summary, a[href], button:enabled, [tabindex]:not([tabindex^='-']), [draggable], area, input:not([type=hidden]):enabled, select:enabled, textarea:enabled, object, iframe"))}const trapFocusHandlers={};function trapFocus(container,priorityElement=null){const elements=getFocusableElements(container);let first;priorityElement?first=priorityElement:first=elements[0];const last=elements[elements.length-1];removeTrapFocus(),trapFocusHandlers.focusin=event=>{event.target!==container&&event.target!==last&&event.target!==first||document.addEventListener("keydown",trapFocusHandlers.keydown)},trapFocusHandlers.focusout=function(){document.removeEventListener("keydown",trapFocusHandlers.keydown)},trapFocusHandlers.keydown=function(event){event.code.toUpperCase()==="TAB"&&(event.target===last&&!event.shiftKey&&(event.preventDefault(),first.focus()),(event.target===container||event.target===first)&&event.shiftKey&&(event.preventDefault(),last.focus()))},document.addEventListener("focusout",trapFocusHandlers.focusout),document.addEventListener("focusin",trapFocusHandlers.focusin),first.focus()}function removeTrapFocus(elementToFocus=null){document.removeEventListener("focusin",trapFocusHandlers.focusin),document.removeEventListener("focusout",trapFocusHandlers.focusout),document.removeEventListener("keydown",trapFocusHandlers.keydown),elementToFocus&&elementToFocus.focus()}function debounce(fn,wait){let t;return(...args)=>{clearTimeout(t),t=setTimeout(()=>fn.apply(this,args),wait)}}function throttle(fn,wait){let t=!1;return(...args)=>{t||(fn.apply(this,args),t=!0,setTimeout(()=>t=!1,wait))}}typeof window.Woolman>"u"&&(window.Woolman={}),Woolman.bind=function(fn,scope){return function(){return fn.apply(scope,arguments)}},Woolman.init=function(){if(Woolman.ModalsAndDrawers.init(),Woolman.Header.init(),Woolman.DetailsAccordions.init(),!Shopify||!Shopify.designMode)return;let lastSelection={sectionId:void 0,blockId:void 0};document.addEventListener("shopify:section:load",evt=>{"shopify-section-"+evt.detail.sectionId===Woolman.Header.cache.section.id&&(Woolman.ModalsAndDrawers.init(),Woolman.Header.init()),document.querySelector(`[data-modal][data-section-id="${evt.detail.sectionId}"]`)&&Woolman.ModalsAndDrawers.showModalOrDrawer(document.querySelector(`[data-modal][data-section-id="${evt.detail.sectionId}"]`).id),console.log("shopify:section:load sectionId",evt.detail.sectionId),console.log("lastSelection",lastSelection)}),document.addEventListener("shopify:block:select",evt=>{const sectionId="shopify-section-"+evt.detail.sectionId,selectedBlock=[...document.getElementById(sectionId).querySelectorAll("[data-shopify-editor-block]")].find(x=>JSON.parse(x.dataset.shopifyEditorBlock).id===evt.detail.blockId);if(sectionId===Woolman.Header.cache.section.id){if(selectedBlock){Woolman.Header.cache.openButton.click();const accordion=selectedBlock.closest("[data-accordion-item]").querySelector("input"),label=selectedBlock.closest("[data-accordion-item]").querySelector("label");accordion.checked||label.click()}}else sectionId.includes("modal")&&document.getElementById(sectionId).querySelector("[data-modal]")&&selectedBlock&&Woolman.ModalsAndDrawers.showModalOrDrawer(document.getElementById(sectionId).querySelector("[data-modal]").id);lastSelection.sectionId=evt.detail.sectionId,lastSelection.blockId=evt.detail.blockId,console.log("shopify:block:select",evt.detail.sectionId,evt.detail.blockId),console.log("lastSelection",lastSelection)}),document.addEventListener("shopify:section:unload",evt=>{console.log("shopify:section:unload sectionId",evt.detail.sectionId)}),document.addEventListener("shopify:section:select",evt=>{console.log("shopify:section:select",evt.detail.sectionId),lastSelection={sectionId:evt.detail.sectionId,blockId:evt.detail.blockId},evt.detail.sectionId.includes("modal")&&document.querySelector(`[data-modal][data-section-id="${evt.detail.sectionId}"]`)&&Woolman.ModalsAndDrawers.showModalOrDrawer(document.querySelector(`[data-modal][data-section-id="${evt.detail.sectionId}"]`).id),console.log("lastSelection",lastSelection)}),document.addEventListener("shopify:section:deselect",evt=>{console.log("shopify:section:deselect",evt.detail.sectionId),lastSelection={sectionId:void 0,blockId:void 0},evt.detail.sectionId.includes("modal")&&document.querySelector(`[data-modal][data-section-id="${evt.detail.sectionId}"]`)&&Woolman.ModalsAndDrawers.closeModalOrDrawer(document.querySelector(`[data-modal][data-section-id="${evt.detail.sectionId}"]`).id),console.log("lastSelection",lastSelection)})},Woolman.Utils={debugMode:!0,prepareQueryParams:()=>
1{if(Shopify.queryParams=Shopify.queryParams||{},location.search.length){const params=location.search.substr(1).split("&");for(let i=0;i<params.length;i++){const keyValue=params[i].split("=");keyValue.length&&(Shopify.queryParams[decodeURIComponent(keyValue[0])]=decodeURIComponent(keyValue[1]).replaceAll("+"," "))}}return Shopify.queryParams},formatMoney(cents,format){const default_money_format=theme.settings.moneyFormat||"\u20AC{{amount}}";typeof cents=="string"&&(cents=cents.replace(".","")),window?.Shopify?.currency?.rate&&(cents=cents*parseFloat(window.Shopify.currency.rate||1));var value="",placeholderRegex=/\{\{\s*(\w+)\s*\}\}/,formatString=format||default_money_format;function defaultOption(opt,def){return typeof opt>"u"?def:opt}function formatWithDelimiters(number,precision,thousands,decimal){if(precision=defaultOption(precision,2),thousands=defaultOption(thousands,","),decimal=defaultOption(decimal,"."),isNaN(number)||number==null)return 0;number=(number/100).toFixed(precision);var parts=number.split("."),dollars=parts[0].replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+thousands),cents2=parts[1]?decimal+parts[1]:"";return dollars+cents2}switch(formatString.match(placeholderRegex)[1]){case"amount":value=formatWithDelimiters(cents,2);break;case"amount_no_decimals":value=formatWithDelimiters(cents,0);break;case"amount_with_comma_separator":value=formatWithDelimiters(cents,2,".",",");break;case"amount_no_decimals_with_comma_separator":value=formatWithDelimiters(cents,0,".",",");break}return formatString.replace(placeholderRegex,value)}},Woolman.Header={selectors:{header:"MainHeader",cartBlip:".cart-blip"},cache:{header:void 0,cartBlip:void 0,section:void 0,openButton:void 0},init:function(){this.cache.header=document.getElementById(this.selectors.header),this.cache.cartBlip=this.cache.header.querySelector(this.selectors.cartBlip),this.cache.section=this.cache.header.closest(".shopify-section"),this.cache.openButton=this.cache.header.querySelector('[href="#drawer-menu"]'),document.addEventListener("ajaxProduct:added",this.updateCartBlip.bind(this)),document.addEventListener("cart:update",this.updateCartBlip.bind(this)),this.cache.header.dataset.stickyBehavior!=="none"&&this.initStickyBehavior(this.cache.header.dataset.stickyBehavior)},initStickyBehavior(behaviorType){const stickyConfig={headerHeight:this.cache.header.clientHeight,behavior:behaviorType};if(document.documentElement.classList.add("sticky-header-initialized",`sticky-header-${behaviorType}`),document.documentElement.style.setProperty("--sticky-header-margin-top",`${stickyConfig.headerHeight}px`),behaviorType==="scroll"||behaviorType==="fixed"){let prevScroll=window.scrollY||document.documentElement.scrollTop,curScroll,direction=0,prevDirection=0;const toggleStickyHeader=(direction2,curScroll2)=>{direction2===1||curScroll2<stickyConfig.headerHeight?document.documentElement.classList.remove("sticky-header-hide"):direction2===2&&curScroll2>stickyConfig.headerHeight&&document.documentElement.classList.add("sticky-header-hide"),prevDirection=direction2};window.addEventListener("scroll",throttle(()=>{curScroll=window.scrollY||document.documentElement.scrollTop,curScroll>=300?document.documentElement.classList.add("sticky-header-show"):document.documentElement.classList.remove("sticky-header-show"),curScroll>prevScroll?direction=2:direction=1,direction!==prevDirection&&behaviorType==="scroll"&&toggleStickyHeader(direction,curScroll),prevScroll=curScroll},50)),setInterval(()=>{direction===2&&behaviorType==="scroll"&&curScroll>=900&&toggleStickyHeader(direction,curScroll),window.scrollY===0&&document.documentElement.classList.remove("sticky-header-show","sticky-header-hide")},200)}},async updateCartBlip(e){const cart=e.detail&&e.detail.cart&&e.detail.cart.item_count||await(async function(){return await(await fetch("/cart.json")).json()})();this.cache.cartBlip.textContent=cart.item_count||0,cart&&cart.item_count==0?(this.cache.cartBlip.setAttribute("hidden",!0),this.cache.cartBlip.closest(".header-item__link").classList.remove("has-blip-visible")):(this.cache.cartBlip.removeAttribute("hidden"),this.cache.cartBlip.closest(".header-item__link").classList.add("has-blip-visible"));const total_in_notification=document.querySelector("#cart-notification-link .cart-total");total_in_notification&&(total_in_notification.textContent=cart.item_count)}
1},Woolman.ModalsAndDrawers={settings:{selectors:{modalLink:'a[href*="#modal"]:not(.quick-buy_link)',drawerLink:'a[href*="#drawer"]',searchDrawer:"#drawer-search-coi",searchButton:".search-button-wrapper"}},focusTraps:{},updateSearchButtonFocus:function(){const drawer=document.querySelector(this.settings.selectors.searchDrawer),btn=document.querySelector(this.settings.selectors.searchButton);!btn||!drawer||(drawer.classList.contains("is-open")?btn.classList.add("focused"):btn.classList.remove("focused"))},openFilterSectionInDrawer:function(drawerEl,rawName){if(!drawerEl||!rawName)return;const wanted=String(rawName).trim().toLowerCase(),groups=drawerEl.querySelectorAll("details[data-filter-name]");let target=null;groups.forEach(d=>{(d.getAttribute("data-filter-name")||"").trim().toLowerCase()===wanted?(d.setAttribute("open","open"),target=d):d.removeAttribute("open")}),target&&(target.querySelector("summary")?.focus?.(),target.scrollIntoView({behavior:"smooth",block:"start"}))},init:function(){document.querySelectorAll(this.settings.selectors.modalLink).forEach(modalLink=>{modalLink.addEventListener("click",event=>{event.preventDefault();const targetId=event.currentTarget.getAttribute("href").substring(1).split("?")[0],slideIndex=event.currentTarget.getAttribute("href").substring(1).split("?slide=")[1],scrollToId=event.currentTarget.getAttribute("href").substring(1).split("?scroll=")[1];this.showModalOrDrawer(targetId,parseInt(slideIndex),scrollToId)})}),document.querySelectorAll(this.settings.selectors.drawerLink).forEach(drawerLink=>{drawerLink.addEventListener("click",event=>{event.preventDefault();const targetId=event.currentTarget.getAttribute("href").substring(1).split("?")[0],filterTarget=drawerLink.getAttribute("data-filter-target"),drawerEl=document.getElementById(targetId);drawerEl&&filterTarget&&(drawerEl.setAttribute("data-open-filter",filterTarget),this.openFilterSectionInDrawer(drawerEl,filterTarget));const inputSearch=document.querySelector(drawerLink.dataset.drawerPriorityFocus);this.showModalOrDrawer(targetId,null,null,inputSearch)})});const closeBtns=document.querySelectorAll("[data-close]");closeBtns&&closeBtns.forEach(closeBtn=>{closeBtn.addEventListener("click",this.closeModalOrDrawerOrDrawerFromEvent.bind(this))});const overlays=document.querySelectorAll("[data-overlay]");overlays&&overlays.forEach(overlay=>{overlay.addEventListener("click",this.closeModalOrDrawerOrDrawerFromEvent.bind(this))});const externalDrawerClosers=document.querySelectorAll("[data-drawer-close]");externalDrawerClosers.length&&externalDrawerClosers.forEach(el=>{el.addEventListener("click",event=>{event.preventDefault();const attrTarget=el.getAttribute("data-drawer-target")||el.getAttribute("aria-controls")||"";let targetId="";if(attrTarget)targetId=attrTarget.replace(/^#/,"");else{const href=el.getAttribute("href")||"";href.startsWith("#")&&href.length>1&&(targetId=href.slice(1))}if(targetId)this.closeModalOrDrawer(targetId);else{const openDrawer=document.querySelector(".drawer.is-open");openDrawer&&(removeTrapFocus?.(),openDrawer.classList.remove("is-open"),document.body.classList.remove("overflow-hidden"),Woolman.ModalsAndDrawers.updateSearchButtonFocus())}})}),document.addEventListener("keydown",event=>{(event.key==="Escape"||event.keyCode===27)&&(document.querySelectorAll(".drawer").forEach(drawer=>{drawer.classList.remove("is-open")}),document.querySelectorAll(".modal").forEach(modal=>{modal.classList.remove("is-open")}),document.body.classList.remove("overflow-hidden"),Woolman.ModalsAndDrawers.updateSearchButtonFocus(),removeTrapFocus?.())},!1);const watchDrawer=document.querySelector(Woolman.ModalsAndDrawers.settings.selectors.searchDrawer);watchDrawer&&(new MutationObserver(()=>Woolman.ModalsAndDrawers.updateSearchButtonFocus()).observe(watchDrawer,{attributes:!0,attributeFilter:["class"]}),Woolman.ModalsAndDrawers.updateSearchButtonFocus())},showModalOrDrawer:function(targetId,slideIndex,scrollToId,priorityElement=null){const targetElement=document.getElementById(targetId);if(!targetElement&&Woolman.Utils.debugMode&&console.warn("No modal/drawer element specified"),!!targetElement&&!targetElement.classList.contains("is-open")){if(targetElement.classList.add("initialized","is-open"),document.body.classList.add("overflow-hidden"),Woolman.ModalsAndDrawers.updateSearchButtonFocus(),setTimeout(()=>{trapFocus(targetElement,priorityElement);const requested=targetElement.getAttribute("data-open-filter");requested&&this.openFilterSectionInDrawer(targetElement,requested)},100),slideIndex)setTimeout(()=>{targetElement.querySelector("gridy-slider")?.scrollToSlide?.(slideIndex-1)},600);else if(scrollToId){const scrollToElement=document.getElementById(scrollToId);targetElement.querySelector(".gridy-track")?.scrollTo?.({top:scrollToElement.offsetTop,left:scrollToElement.offsetLeft,behavior:"instant"})}}},closeModalOrDrawer:function(targetId){const targetElement=document.getElementById(targetId);targetElement&&(targetElement.classList.remove("is-open"),document.body.classList.remove("overflow-hidden"),removeTrapFocus?.(),Woolman.ModalsAndDrawers.updateSearchButtonFocus())},closeModalOrDrawerOrDrawerFromEvent:function(event){event.preventDefault(),removeTrapFocus?.();const parentElement=event.currentTarget.closest("[data-parent]")||document.querySelector(".drawer.is-open")||document.querySelector(".modal.is-open");parentElement&&parentElement.classList.remove("is-open"),document.body.classList.remove("overflow-hidden"),Woolman.ModalsAndDrawers.updateSearchButtonFocus()}};let woolman_window_size=window.innerWidth;window.addEventListener("resize",debounce(()=>{window.innerWidth!=woolman_window_size&&(woolman_window_size=window.innerWidth,document.dispatchEvent(new CustomEvent("woolman:resize")))}),250);class Accordion{constructor(el){this.el=el,this.summary=el.querySelector("summary"),this.content=el.querySelector(".content"),this.animation=null,this.isClosing=!1,this.isExpanding=!1,this.summary.addEventListener("click",e=>this.onClick(e)),this.toggleByViewport(),document.addEventListener("woolman:resize",this.toggleByViewport.bind(this))}onClick(e){e.preventDefault(),this.el.style.overflow="hidden",this.isClosing||!this.el.open?this.open():(this.isExpanding||this.el.open)&&this.shrink()}shrink(){this.isClosing=!0;const startHeight=`${this.el.offsetHeight}px`,endHeight=`${this.summary.offsetHeight}px`;this.animation&&this.animation.cancel(),this.animation=this.el.animate({height:[startHeight,endHeight]},{duration:400,easing:"ease-in-out"}),this.animation.onfinish=()=>this.onAnimationFinish(!1),this.animation.oncancel=()=>this.isClosing=!1}open(){this.el.style.height=`${this.el.offsetHeight}px`,this.el.open=!0,window.requestAnimationFrame(()=>this.expand())}expand(){this.isExpanding=!0;const startHeight=`${this.el.offsetHeight}px`,endHeight=`${this.summary.offsetHeight+this.content.offsetHeight}px`;this.animation&&this.animation.cancel(),this.animation=this.el.animate({height:[startHeight,endHeight]},{duration:400,easing:"ease-out"}),this.animation.onfinish=()=>this.onAnimationFinish(!0),this.animation.oncancel=()=>this.isExpanding=!1}onAnimationFinish(open){this.el.open=open,this.animation=null,this.isClosing=!1,this.isExpanding=!1,this.el.style.height=this.el.style.overflow=""}toggleByViewport(){let mobileClose=this.el.dataset.mobileClose!=null?JSON.parse(this.el.dataset.mobileClose):!1,desktopOpen=this.el.dataset.desktopOpen!=null?JSON.parse(this.el.dataset.desktopOpen):!1;woolman_window_size>
1=768&&desktopOpen?this.el.open=!0:mobileClose&&(this.el.open=!1)}}Woolman.DetailsAccordions={init:function(){document.querySelectorAll("details").forEach(el=>{new Accordion(el)})}},(function(){function setHeaderContentHeight(){const el=document.querySelector(".header-content"),h=el?Math.ceil(el.getBoundingClientRect().height):0;document.documentElement.style.setProperty("--header-content-height",`${h}px`)}if(window.addEventListener("load",setHeaderContentHeight),document.addEventListener("DOMContentLoaded",setHeaderContentHeight),document.addEventListener("woolman:resize",setHeaderContentHeight),"ResizeObserver"in window){const target=document.querySelector(".header-content");target&&new ResizeObserver(setHeaderContentHeight).observe(target)}window.Woolman=window.Woolman||{},Woolman.setHeaderContentHeight=setHeaderContentHeight})(),Woolman.init();class LocalizationForm extends HTMLElement{constructor(){super(),this.elements={input:this.querySelector('input[name="locale_code"], input[name="country_code"]')},this.querySelectorAll("a").forEach(item=>item.addEventListener("click",this.onItemClick.bind(this)))}onItemClick(event){event.preventDefault();const form=this.querySelector("form");this.elements.input.value=event.currentTarget.dataset.value;let return_to_value=form.querySelector('[name="return_to"]').value,indexOfFilters=return_to_value.indexOf("?filter");if(indexOfFilters!==-1){let replacedSubstring=return_to_value.substring(indexOfFilters).replace(/%2C/g,",");form.querySelector('[name="return_to"]').value=return_to_value.substring(0,indexOfFilters)+replacedSubstring}form&&form.submit()}}customElements.define("localization-form",LocalizationForm);class SuperPoweredVideo extends HTMLElement{constructor(){if(super(),this.video=this.querySelector("video")||this.querySelector("iframe"),this.container=this.closest(".video-container")||null,this.container&&this.attachClickListener(this.closest(".video-container")),this.video.nodeName==="IFRAME"&&this.video.src&&this.video.src.includes("youtube")&&!this.container&&this.video.addEventListener("load",this.onVideoLoad.bind(this)),!(this.dataset.autoplay||!1)||this.container)return;const videoType=this.video.nodeName==="VIDEO"?"video":"iframe",videoHost=this.video.nodeName==="VIDEO"?"shopify":this.video.src.includes("youtube")?"youtube":"vimeo";new IntersectionObserver(entries=>{entries.forEach(entry=>{entry.isIntersecting?videoType=="video"?this.video.play():videoHost=="youtube"?this.video.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}',"*"):videoHost=="vimeo"&&this.video.contentWindow.postMessage('{"method":"play"}',"*"):videoType=="video"?this.video.pause():videoHost=="youtube"?this.video.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}',"*"):videoHost=="vimeo"&&this.video.contentWindow.postMessage('{"method":"pause"}',"*")})},{threshold:.5}).observe(this.video)}attachClickListener(videoContainer){videoContainer&&(videoContainer.addEventListener("click",e=>{this.video.paused?this.video.play():this.video.pause()}),this.video.onplay=()=>{videoContainer.querySelector("button").hidden=!0},this.video.onpause=()=>{videoContainer.querySelector("button").hidden=!1})}onVideoLoad(){this.video.contentWindow.postMessage('{"event":"command","func":"playVideo","args":""}',"*")}}customElements.define("superpowered-video",SuperPoweredVideo);class GridySlider extends HTMLElement{constructor(){super(),this.track=this.querySelector(".gridy-track"),this.slides=this.querySelectorAll(".gridy-track > *");const child_count=this.track.childElementCount,data_ipr_desktop=parseInt(this.dataset.iprDesktop,10)||1,data_ipr_tablet=parseInt(this.dataset.iprTablet,10)||data_ipr_desktop,data_ipr_mobile=parseInt(this.dataset.iprMobile,10)||1,data_init_scroll_to=this.dataset.initScrollTo,data_autoplay=this.dataset.autoplay!=null?JSON.parse(this.dataset.autoplay):!1,data_autoplay_delay=parseInt(this.dataset.autoplayDelay,10)||5e3,data_is_thumbnails_slider=this.dataset.thumbnailsFor!=null,data_indicator=this.dataset.indicator!=null?JSON.parse(this.dataset.indicator):!1,data_sliding_behavior=this.dataset.slidingBehavior,data_thumbnail_slider=document.getElementById(`thumbnail-${this.id}`),data_track_overflow_visible=this.dataset.overflowVisible!=null;if(this.config={slide_count:child_count,current_slide:0,active_slide_offset:0,ipr_desktop:data_ipr_desktop,ipr_tablet:data_ipr_tablet,ipr_mobile:data_ipr_mobile,breakpoint_tablet:768,breakpoint_desktop:1024,arrows:!0,autoplay:data_autoplay||!1,autoplay_delay:data_autoplay_delay,timer:null,is_thumbnails_slider:data_is_thumbnails_slider,thumbnails_for:void 0,thumbnail_slider:data_thumbnail_slider,indicator:data_indicator,track_overflow_visible:data_track_overflow_visible,sliding_behavior:data_sliding_behavior||"all"},data_init_scroll_to!=null&&this.scrollToSlideByID(data_init_scroll_to),this.config.arrows&&(this.buttons=this.querySelectorAll("[data-gridy-arrow]"),this.buttons.forEach(arrowButton=>{arrowButton.addEventListener("click",this.onArrowClick.bind(this))}
1)),this.config.autoplay&&(this.autoplayGridy(),this.addEventListener("mouseenter",this.clearAutoplayTimer),this.addEventListener("mouseleave",this.autoplayGridy),this.addEventListener("touchenter",this.clearAutoplayTimer),this.addEventListener("touchleave",this.autoplayGridy)),this.config.is_thumbnails_slider&&(this.config.active_slide_offset=2,this.config.thumbnails_for=document.getElementById(this.dataset.thumbnailsFor),this.thumbnail=this.querySelectorAll("[data-thumbnail-btn]"),this.thumbnail.forEach(thumbnail=>{thumbnail.addEventListener("click",this.onThumbnailClick.bind(this))})),this.config.indicator&&(this.indicator_dots=this.querySelectorAll("[data-indicator-dot]"),this.indicator_current=this.querySelector("[data-indicator-current]")),!this.config.is_thumbnails_slider){let scrollTimeout;this.track.addEventListener("scroll",function(){clearTimeout(scrollTimeout),scrollTimeout=setTimeout(this.afterScrollStops.bind(this),0)}.bind(this))}}afterScrollStops(){let slideInView=this.firstSlideInView();this.config.current_slide=slideInView,this.setActiveSlide(this.slides[slideInView+this.config.active_slide_offset]),this.config.thumbnail_slider&&this.config.thumbnail_slider.scrollToSlide(slideInView)}autoplayGridy(){this.config.timer=setInterval(this.scrollByIPR.bind(this),this.config.autoplay_delay,"next")}clearAutoplayTimer(){clearInterval(this.config.timer),this.config.timer=null}onThumbnailClick(event){event.preventDefault(),this.config.current_slide=Array.from(event.currentTarget.parentNode.children).indexOf(event.currentTarget),this.config.thumbnails_for.scrollToSlideByID(event.currentTarget.dataset.itemId),this.scrollToSlide(this.config.current_slide)}onArrowClick(event){this.scrollByIPR(event.currentTarget.dataset.direction)}scrollByIPR(direction){let currentIPR=this.getCurrentIPR(),slideMultiplier=this.config.sliding_behavior=="all"?currentIPR:1,newCurrentSlide=this.config.current_slide,lastToShow=this.config.slide_count-currentIPR;direction==="next"?(newCurrentSlide=newCurrentSlide+slideMultiplier,this.config.current_slide>=lastToShow&&(newCurrentSlide=0)):direction==="prev"&&(newCurrentSlide=newCurrentSlide-slideMultiplier,this.config.current_slide>0&&newCurrentSlide<0?newCurrentSlide=0:newCurrentSlide<0&&(newCurrentSlide=lastToShow)),this.config.current_slide=newCurrentSlide,this.scrollToSlide(newCurrentSlide)}scrollToSlide(newPosition){if(isNaN(newPosition))return;let slidePosWithOffset=newPosition-this.config.active_slide_offset,newScrollToSlidePos=slidePosWithOffset>0?slidePosWithOffset:0;const slideInNewScrollToPos=this.slides[newScrollToSlidePos];let scrollToLeft=slideInNewScrollToPos.offsetLeft,scrollToTop=slideInNewScrollToPos.offsetTop;this.config.track_overflow_visible&&(scrollToLeft=this.slides[newScrollToSlidePos].offsetLeft-this.slides[0].offsetLeft),this.track.scrollTo({left:scrollToLeft,top:scrollToTop,behavior:"smooth"}),this.slides.forEach(item=>{item.classList.remove("active")}),this.slides[newPosition].classList.add("active")}scrollToSlideByID(slideID){const theSlide=document.getElementById(slideID),newPosition=Array.from(theSlide.parentNode.children).indexOf(theSlide);this.scrollToSlide(newPosition)}setActiveSlide(slide){this.slides.forEach(item=>{item.classList.remove("active")}),slide.classList.add("active"),this.config.indicator&&(this.indicator_current.textContent=this.config.current_slide+1,this.indicator_dots.forEach(dot=>{dot.classList.remove("active")}),this.indicator_dots[this.config.current_slide].classList.add("active"))}getCurrentIPR(){let currentIPR=this.config.ipr_mobile;return woolman_window_size>=this.config.breakpoint_desktop?currentIPR=this.config.ipr_desktop:woolman_window_size>=this.config.breakpoint_tablet&&(currentIPR=this.config.ipr_tablet),currentIPR}firstSlideInView(){const containerBounds=this.track.getBoundingClientRect();let bestIndex=this.config.current_slide,bestRatio=0;return this.slides.forEach((slide,index)=>{const slideBounds=slide.getBoundingClientRect(),visibleLeft=Math.max(slideBounds.left,containerBounds.left),visibleRight=Math.min(slideBounds.right,containerBounds.right),ratioVisible=Math.max(0,visibleRight-visibleLeft)/slideBounds.width;ratioVisible>bestRatio&&(bestRatio=ratioVisible,bestIndex=index)}),bestIndex}}customElements.define("gridy-slider",GridySlider);class QuantityInput extends HTMLElement{constructor(){super(),this.input=this.querySelector("input"),this.changeEvent=ne
1w 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;event.target.name==="plus"?this.input.stepUp():this.input.stepDown(),previousValue!==this.input.value&&this.input.dispatchEvent(this.changeEvent)}}customElements.define("quantity-input",QuantityInput);function pushDataLayer(event,data){window.dataLayer=window.dataLayer||[],window.dataLayer.push({event,...data})}class HeaderElement extends HTMLElement{static allPredictiveSearchInstances=new Set;constructor(){super(),this.element=this,this.searchDropdown=this.element.querySelector(".search-dropdown"),this.cachedResults={},this.abortController=null,this.setRecentSearches(),this.lastSearchValue=this.element.querySelector("#search-dropdown__bar")?.value||"",this.delegate=new Delegate(this.element),this.debouncedHandleSearch=this.debounce(this.handleSearch.bind(this),500),this.constructor.allPredictiveSearchInstances.add(this)}connectedCallback(){this.searchDropdown&&(this.delegate.on("input","#search-dropdown__bar",this.handleInputChange.bind(this)),this.delegate.on("keydown","#search-dropdown__bar",event=>{if(event.key==="Enter")return this.openSearchPage(event)}),this.delegate.on("submit",'form[role="search"]',this.openSearchPage.bind(this)),this.delegate.on("click",'[data-action="search-term"]',this.handleTermClick.bind(this)),this.setActiveSearchTab(),this.runSearchCountsFromUrl())}disconnectedCallback(){this.delegate.destroy(),this.constructor.allPredictiveSearchInstances.delete(this)}closeSearchDropdown(){this.searchDropdown&&(this.searchDropdown.setAttribute("aria-expanded","false"),bodyScrollLock.clearAllBodyScrollLocks?.(),setTimeout(()=>{this.searchDropdown.style.display="none"},300))}debounce(fn,delay){let t;return(...a)=>{clearTimeout(t),t=setTimeout(()=>fn.apply(this,a),delay)}}setLiveRegionLoadingState(){const liveRegion=this.element.querySelector("[data-predictive-search-live-region]")||document.getElementById("predictive-search-status")||this.element.querySelector(".predictive-search-status");liveRegion&&(liveRegion.setAttribute("aria-hidden","false"),liveRegion.textContent="Loading results\u2026")}clearLiveRegion(){const liveRegion=this.element.querySelector("[data-predictive-search-live-region]")||document.getElementById("predictive-search-status")||this.element.querySelector(".predictive-search-status");liveRegion&&(liveRegion.textContent="",liveRegion.setAttribute("aria-hidden","true"))}handleInputChange(event){this.debouncedHandleSearch(event)}async handleSearch(event){const input=event?.target?.closest("input")||this.element.querySelector("#search-dropdown__bar");input&&requestAnimationFrame(async()=>{let preTranslatedValue=input.value||"";if(preTranslatedValue===this.lastSearchValue)return;if(this.lastSearchValue=preTranslatedValue,!preTranslatedValue.trim()){this.setSearchToDefault();return}const value=await this.getTranslatedValue(preTranslatedValue);
1this.getSearchResults(value).catch(()=>{});const sliderHtml=await this.fetchProductSlider(value);this.updateSlider(sliderHtml),this.fetchSearchCounts(value)})}async openSearchPage(event){event.preventDefault(),event.stopPropagation();const value=(event.target.closest("input")||this.element.querySelector("#search-dropdown__bar"))?.value||"";this.saveRecentSearch(value);const translatedValue=await this.getTranslatedValue(value),params=new URLSearchParams;params.append("q",translatedValue);const type=window.location.search.includes("article")?"article":"product";params.append("type",type);const query=Shopify.routes.root+"search?"+params.toString();window.location=query}async getTranslatedValue(value){if(!this.searchDropdown||this.searchDropdown.hasAttribute("data-disable-translate"))return value;const url="https://coi-translation-app-feff18122737.herokuapp.com/translate",headers={"Content-Type":"application/json","User-Agent":"insomnia/11.2.0","x-api-key":"0a3f1c42-8f98-4b99-bbdf-58b30ee74e1c"};let locale=Shopify.locale?.toUpperCase?.()||"EN-GB";(locale==="EN"||!["EN-GB","DA","NL","FI","FR","DE","IT","PL","ES","SV"].includes(locale))&&(locale="EN-GB");try{const response=await fetch(url,{method:"POST",headers,body:JSON.stringify({text:value,to:locale})});if(!response.ok)throw new Error(`HTTP error! Status: ${response.status}`);return(await response.json()).translatedText||value}catch(error){return console.error("Error translating text:",error),value}}getSearchResults(searchTerm){const queryKey=(searchTerm||"").trim().replace(/\s+/g,"-").toLowerCase();if(!queryKey)return Promise.resolve();if(this.setLiveRegionLoadingState(),this.abortController&&this.abortController.abort(),this.abortController=new AbortController,this.cachedResults[queryKey])return this.renderSearchResults(this.cachedResults[queryKey]),this.clearLiveRegion(),Promise.resolve();const url=`${window.routes&&window.routes.predictive_search_url||(window.Shopify?.routes?.root?`${Shopify.routes.root}search/suggest`:"/search/suggest")}?q=${encodeURIComponent(searchTerm)}§ion_id=${encodeURIComponent("predictive-search-coi")}`;return fetch(url,{signal:this.abortController.signal,credentials:"same-origin"}).then(response=>{if(!response.ok){const error=new Error(response.status);throw this.closeSearchDropdown(),error}return response.text()}).then(text=>{const host=new DOMParser().parseFromString(text,"text/html").querySelector("#shopify-section-predictive-search-coi"),resultsMarkup=host?host.innerHTML:text;this.constructor.allPredictiveSearchInstances.forEach(inst=>{inst.cachedResults[queryKey]=resultsMarkup}),this.renderSearchResults(resultsMarkup),this.clearLiveRegion()}).catch(error=>{if(!(error?.name==="AbortError"||error?.code===20))throw this.closeSearchDropdown(),error})}async fetchProductSlider(value){const queryOptions={method:"GET",credentials:"same-origin"},url=`${Shopify.routes.root}search?q=${encodeURIComponent(value)}&type=product&view=ajax§ion_id=helper_search-dropdown-slider`;try{const response=await fetch(url,queryOptions);if(!response.ok)throw response;return await response.text()}catch(e){return console.error("Slider fetch error:",e),""}}renderSearchResults(resultsMarkup){if(!resultsMarkup)return;const container=this.element.querySelector(".search-dropdown__results");if(!container)return;const predictiveWrap=container.querySelector(".search-dropdown__predictive"),recentSuggested=container.querySelector(".search-dropdown__recent-and-suggested"),tempDiv=document.createElement("div");tempDiv.innerHTML=resultsMarkup;const hasQueries=tempDiv.querySelector(".search-dropdown__suggestions a"),hasCollections=tempDiv.querySelector(".search-dropdown__collections a"),hasProducts=tempDiv.querySelector("gridy-slider .card-product"),hasNoResults=tempDiv.querySelector(".search-dropdown__no-results");if(hasQueries||hasCollections){predictiveWrap&&(predictiveWrap.innerHTML=resultsMarkup,predictiveWrap.hidden=!1,predictiveWrap.setAttribute("aria-hidden","false")),recentSuggested&&(recentSuggested.style.display="none");return}if(hasProducts&&!hasNoResults){predictiveWrap&&(predictiveWrap.innerHTML="",predictiveWrap.hidden=!0,predictiveWrap.setAttribute("aria-hidden","true")),recentSuggested&&(recentSuggested.style.display="");return}hasNoResults&&(predictiveWrap&&(predictiveWrap.innerHTML=resultsMarkup,predictiveWrap.hidden=!1,predictiveWrap.setAttribute("aria-hidden","false")),recentSuggested&&(recentSuggested.style.display="none"))}updateSlider(html){if(!html)return;const div=document.createElement("div");div.innerHTML=html;const newSwiper=div.querySelector("gridy-slider"),oldSwiper=this.element.querySelector("gridy-slider");oldSwiper&&newSwiper&&oldSwiper.replaceWith(newSwiper)}setSearchToDefault(){const results=this.element.querySelector(".search-dropdown__results");if(!results)return;const predictiveWrap=results.querySelector(".search-dropdown__predictive"),recentSuggested=results.querySelector(".search-dropdown__recent-and-suggested");predictiveWrap&&(predictiveWrap.innerHTML="",predictiveWrap.hidden=!0,predictiveWrap.setAttribute("aria-hidden","true")),recentSuggested&&(recentSuggested.style.display=""),this.clearLiveRegion(),this.setRecentSearches()}saveRecentSearch(searchTerm){const term=(searchTerm||"").trim();if(!term)return;const existing=(localStorage.getItem("equestrian-recent-searches")||"").split(";").map(s=>
1s.trim()).filter(Boolean),lc=term.toLowerCase(),limited=[term,...existing.filter(t=>t.toLowerCase()!==lc)].slice(0,3);localStorage.setItem("equestrian-recent-searches",limited.join(";"))}setRecentSearches(){const string=localStorage.getItem("equestrian-recent-searches");if(!string)return;const recentSearches=this.element.querySelector(".search-dropdown__recent-results");if(!recentSearches)return;const array=string.split(";");recentSearches.innerHTML="",array.forEach(item=>{recentSearches.appendChild(this.buildRecentHtml(item))});const recentWrapper=this.element.querySelector(".search-dropdown__recent");recentWrapper&&(recentWrapper.style.display="block")}buildRecentHtml(string){const div=document.createElement("div");return div.tabIndex=0,div.dataset.action="search-term",div.dataset.value=string,div.textContent=string,div.classList.add("search-dropdown__text-result-item"),div}handleTermClick(event){const termElem=event.target.closest('[data-action="search-term"]');if(!termElem)return;const value=termElem.dataset.value,input=this.element.querySelector("#search-dropdown__bar");input&&(input.value=value,this.openSearchPage({preventDefault(){},stopPropagation(){},target:input}))}async fetchSearchCounts(value){if(!(!value||value.trim()===""))try{const queryOptions={method:"GET",credentials:"same-origin"},productHtml=await(await fetch(`${Shopify.routes.root}search?q=${encodeURIComponent(value)}&type=product`,queryOptions)).text(),articleHtml=await(await fetch(`${Shopify.routes.root}search?q=${encodeURIComponent(value)}&type=article`,queryOptions)).text(),productCount=this.extractCountFromHtml(productHtml),articleCount=this.extractCountFromHtml(articleHtml);this.updateSearchCounts(productCount,articleCount)}
1catch(err){console.error("Error fetching search counts:",err),this.updateSearchCounts(0,0)}}extractCountFromHtml(html){try{const tempDiv=document.createElement("div");tempDiv.innerHTML=html;const gridElement=tempDiv.querySelector("[data-filtered-count]");if(gridElement){const count=parseInt(gridElement.getAttribute("data-filtered-count"));if(!isNaN(count))return count}const countElement=tempDiv.querySelector("#products-count-ajax");if(countElement){const numberMatch=(countElement.textContent||countElement.innerText||"").match(/\d+/);if(numberMatch)return parseInt(numberMatch[0])}const resultItems=tempDiv.querySelectorAll("#product-grid-ajax > *:not(.loading)");return resultItems.length>0?resultItems.length:(tempDiv.querySelector(".search-dropdown__no-results, .main-search__no-results"),0)}catch(e){return console.error("Error parsing HTML for count:",e),0}}updateSearchCounts(productCount,articleCount){const productTarget=document.querySelector('[data-search-count="product"]'),articleTarget=document.querySelector('[data-search-count="article"]');productTarget&&(productTarget.textContent=`(${productCount})`),articleTarget&&(articleTarget.textContent=`(${articleCount})`)}async runSearchCountsFromUrl(){if(!window.location.pathname.includes("/search"))return;const query=new URLSearchParams(window.location.search).get("q");query&&await this.fetchSearchCounts(query)}setActiveSearchTab(){const type=new URLSearchParams(window.location.search).get("type"),productTab=document.querySelector(".main-search__search-type-product"),articleTab=document.querySelector(".main-search__search-type-article");type==="article"?(articleTab?.classList.add("active"),productTab?.classList.remove("active")):(productTab?.classList.add("active"),articleTab?.classList.remove("active"))}}customElements.define("header-element",HeaderElement); 2//# sourceMappingURL=/cdn/shop/t/104/assets/global.js.map?v=84049653144804922611789996707
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.