PageSourceSearch

https://www.readers.com/cdn/shop/t/236/assets/global.js?v=145620862185718595461778062538

js readers.com collected 2026-09-26 01:43:32 UTC 64,373 bytes, 18 lines download raw bytes

1function formatPower(val){const num=parseFloat(val);return isNaN(num)?val:num.toFixed(2)}function 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"))}document.querySelectorAll('[id^="Details-"] summary').forEach(summary=>{summary.setAttribute("role","button"),summary.setAttribute("aria-expanded",summary.parentNode.hasAttribute("open")),summary.nextElementSibling.getAttribute("id")&&summary.setAttribute("aria-controls",summary.nextElementSibling.id),summary.addEventListener("click",event=>{event.currentTarget.setAttribute("aria-expanded",!event.currentTarget.closest("details").hasAttribute("open"))}),!summary.closest("header-drawer, menu-drawer")&&summary.parentElement.addEventListener("keyup",onKeyUpEscape)}),(function(){const colorAttributes=["color","first pair color","second pair color","third pair color"];function getColorFieldset(label){for(const attr of colorAttributes){const fieldset=label.closest(`fieldset[data-variant-attribute="${attr}"]`);if(fieldset)return fieldset}return null}function getVariantForFieldsetValue(variantSelects,targetFieldset,targetValue){if(!variantSelects||!targetFieldset)return null;const options=Array.from(variantSelects.querySelectorAll("select, fieldset"),element=>{if(element.tagName==="SELECT")return element.value;if(element.tagName==="FIELDSET")return element===targetFieldset?targetValue:Array.from(element.querySelectorAll("input")).find(radio=>radio.checked)?.value});return(typeof variantSelects.getVariantData=="function"?variantSelects.getVariantData():[]).find(variant=>!variant.options.map((option,index)=>options[index]===option).includes(!1))||null}function getVariantFromCurrentSelection(variantSelects){if(!variantSelects)return null;const options=Array.from(variantSelects.querySelectorAll("select, fieldset"),element=>{if(element.tagName==="SELECT")return element.value;if(element.tagName==="FIELDSET")return Array.from(element.querySelectorAll("input")).find(radio=>radio.checked)?.value});return(typeof variantSelects.getVariantData=="function"?variantSelects.getVariantData():[]).find(variant=>!variant.options.map((option,index)=>options[index]===option).includes(!1))||null}function applyHoverGalleryPreview(variantSelects,variant){if(!variantSelects||!variant)return;const selectedVariantBeforeHover=variantSelects.currentVariant,selectedCustomVariantBeforeHover=variantSelects.customCurrentVariant;variantSelects.currentVariant=variant;try{typeof variantSelects.getCustomData=="function"&&(variantSelects.customCurrentVariant=variantSelects.getCustomData().find(item=>item.id===variant.id)||null)}catch{variantSelects.customCurrentVariant=null}typeof variantSelects.updatePdpGalleryGrid=="function"&&variantSelects.updatePdpGalleryGrid(),typeof variantSelects.updateMedia=="function"&&variantSelects.updateMedia(),variantSelects.currentVariant=selectedVariantBeforeHover,variantSelects.customCurrentVariant=selectedCustomVariantBeforeHover}document.addEventListener("mouseenter",function(e){if(!e.target||!e.target.closest)return;const label=e.target.closest("label.pdp-color-swatch");if(!label)return;const input=document.getElementById(label.getAttribute("for"));if(!input)return;const fieldset=getColorFieldset(label);if(!fieldset)return;const colorNameSpan=fieldset.querySelector('[class*="form__label--option"]');if(!colorNameSpan)return;fieldset.dataset.currentColor||(fieldset.dataset.currentColor=colorNameSpan.innerHTML),colorNameSpan.innerHTML=input.value;const variantSelects=label.closest("variant-selects");if(!variantSelects||input.classList.contains("disabled"))return;const hoverVariant=getVariantForFieldsetValue(variantSelects,fieldset,input.value);applyHoverGalleryPreview(variantSelects,hoverVariant)},!0),document.addEventListener("mouseleave",function(e){if(!e.target||!e.target.closest)return;const label=e.target.closest("label.pdp-color-swatch");if(!label)return;const fieldset=getColorFieldset(label);if(!fieldset)return;const colorNameSpan=fieldset.querySelector('[class*="form__label--option"]');if(!colorNameSpan)return;const checkedInput=fieldset.querySelector('input[type="radio"]:checked');checkedInput?(colorNameSpan.innerHTML=checkedInput.value,fieldset.dataset.currentColor=checkedInput.value):fieldset.dataset.currentColor&&(colorNameSpan.innerHTML=fieldset.dataset.currentColor);const variantSelects=label.closest("variant-selects");if(!variantSelects)return;const selectedVariant=getVariantFromCurrentSelection(variantSelects);applyHoverGalleryPreview(variantSelects,selectedVariant)},!0)})();const trapFocusHandlers={};function trapFocus(container,elementToFocus=container){var elements=getFocusableElements(container),first=elements[0],last=elements[elements.length-1];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),elementToFocus.focus(),elementToFocus.tagName==="INPUT"&&["search","text","email","url"].includes(elementToFocus.type)&&elementToFocus.value&&elementToFocus.setSelectionRange(0,elementToFocus.value.length)}try{document.querySelector(":focus-visible")}catch{focusVisiblePolyfill()}function focusVisiblePolyfill(){const navKeys=["ARROWUP","ARROWDOWN","ARROWLEFT","ARROWRIGHT","TAB","ENTER","SPACE","ESCAPE","HOME","END","PAGEUP","PAGEDOWN"];let currentFocusedElement=null,mouseClick=null;window.addEventListener("keydown",event=>{navKeys.includes(event.code.toUpperCase())&&(mouseClick=!1)}),window.addEventListener("mousedown",event=>{mouseClick=!0}),window.addEventListener("focus",()=>{currentFocusedElement&&currentFocusedElement.classList.remove("focused"),!mouseClick&&(currentFocusedElement=document.activeElement,currentFocusedElement.classList.add("focused"))},!0)}function pauseAllMedia(){document.querySelectorAll(".js-youtube").forEach(video=>{video.contentWindow.postMessage('{"event":"command","func":"pauseVideo","args":""}',"*")}),document.querySelectorAll(".js-vimeo").forEach(video=>{video.contentWindow.postMessage('{"method":"pause"}',"*")}),document.querySelectorAll("video").forEach(video=>video.pause()),document.querySelectorAll("product-model").forEach(model=>{model.modelViewerUI&&model.modelViewerUI.pause()})}function removeTrapFocus(elementToFocus=null){document.removeEventListener("focusin",trapFocusHandlers.focusin),document.removeEventListener("focusout",trapFocusHandlers.focusout),document.removeEventListener("keydown",trapFocusHandlers.keydown),elementToFocus&&elementToFocus.focus()}function onKeyUpEscape(event){if(event.code.toUpperCase()!=="ESCAPE")return;const openDetailsElement=event.target.closest("details[open]");if(!openDetailsElement)return;const summaryElement=openDetailsElement.querySelector("summary");openDetailsElement.removeAttribute("open"),summaryElement.setAttribute("aria-expanded",!1),summaryElement.focus()}class QuantityInput extends HTMLElement{constructor(){super(),this.input=this.querySelector("input"),this.changeEvent=ne
1w Event("change",{bubbles:!0}),this.input.addEventListener("change",this.onInputChange.bind(this)),this.querySelectorAll(".quantity__button").forEach(button=>button.addEventListener("click",this.onButtonClick.bind(this)))}quantityUpdateUnsubscriber=void 0;connectedCallback(){this.validateQtyRules(),this.quantityUpdateUnsubscriber=subscribe(PUB_SUB_EVENTS.quantityUpdate,this.validateQtyRules.bind(this))}disconnectedCallback(){this.quantityUpdateUnsubscriber&&this.quantityUpdateUnsubscriber()}onInputChange(event){this.validateQtyRules()}onButtonClick(event){event.preventDefault();const button=event.target.closest(".quantity__button");if(!button)return;const action=button.getAttribute("name"),previousValue=this.input.value,min=this.input.min?parseInt(this.input.min):null,max=this.input.max?parseInt(this.input.max):null;console.log("[QuantityInput] click:",action,"| current value:",previousValue,"| min:",min,"| max:",max),action==="plus"?this.input.stepUp():this.input.stepDown(),console.log("[QuantityInput] new value:",this.input.value),previousValue!==this.input.value&&this.input.dispatchEvent(this.changeEvent)}validateQtyRules(){const value=parseInt(this.input.value);if(this.input.min){const min=parseInt(this.input.min),buttonMinus=this.querySelector(".quantity__button[name='minus']");buttonMinus&&buttonMinus.classList.toggle("disabled",value<=min)}if(this.input.max){const max=parseInt(this.input.max),buttonPlus=this.querySelector(".quantity__button[name='plus']");buttonPlus&&buttonPlus.classList.toggle("disabled",value>=max)}}}customElements.define("quantity-input",QuantityInput);function debounce(fn,wait){let t;return(...args)=>{clearTimeout(t),t=setTimeout(()=>fn.apply(this,args),wait)}}function throttle(fn,delay){let lastCall=0;return function(...args){const now=new Date().getTime();if(!(now-lastCall<delay))return lastCall=now,fn(...args)}}function fetchConfig(type="json"){return{method:"POST",headers:{"Content-Type":"application/json",Accept:`application/${type}`}}}typeof window.Shopify>"u"&&(window.Shopify={}),Shopify.bind=function(fn,scope){return function(){return fn.apply(scope,arguments)}},Shopify.setSelectorByValue=function(selector,value){for(var i=0,count=selector.options.length;i<count;i++){var option=selector.options[i];if(value==option.value||value==option.innerHTML)return selector.selectedIndex=i,i}},Shopify.addListener=function(target,eventName,callback){target.addEventListener?target.addEventListener(eventName,callback,!1):target.attachEvent("on"+eventName,callback)},Shopify.postLink=function(path,options){options=options||{};var method=options.method||"post",params=options.parameters||{},redirectUrl=options.redirectUrl,form=document.createElement("form");form.setAttribute("method",method),form.setAttribute("action",path);for(var key in params){var hiddenField=document.createElement("input");hiddenField.setAttribute("type","hidden"),hiddenField.setAttribute("name",key),hiddenField.setAttribute("value",params[key]),form.appendChild(hiddenField)}document.body.appendChild(form),redirectUrl?fetch(path,{method,body:new URLSearchParams(new FormData(form))}).then(function(response){response.ok?window.location.href=redirectUrl:console.error("Submit failed")}).catch(function(error){console.error("Error:",error)}):form.submit(),document.body.removeChild(form)},Shopify.CountryProvinceSelector=function(country_domid,province_domid,options){this.countryEl=document.getElementById(country_domid),this.provinceEl=document.getElementById(province_domid),this.provinceContainer=document.getElementById(options.hideElement||province_domid),Shopify.addListener(this.countryEl,"change",Shopify.bind(this.countryHandler,this)),this.initCountry(),this.initProvince()},Shopify.CountryProvinceSelector.prototype={initCountry:function(){var value=this.countryEl.getAttribute("data-default");Shopify.setSelectorByValue(this.countryEl,value),this.countryHandler()},initProvince:function(){var value=this.provinceEl.getAttribute("data-default");value&&this.provinceEl.options.length>0&&Shopify.setSelectorByValue(this.provinceEl,value)},countryHandler:function(e){var opt=this.countryEl.options[this.countryEl.selectedIndex],raw=opt.getAttribute("data-provinces"),provinces=JSON.parse(raw);if(this.clearOptions(this.provinceEl),provinces&&provinces.length==0)this.provinceContainer.style.display="none";else{for(var i=0;i<provinces.length;i++){var opt=document.createElement("option");opt.value=provinces[i][0],opt.innerHTML=provinces[i][1],this.provinceEl.appendChild(opt)}this.provinceContainer.style.display=""}},clearOptions:function(selector){for(;selector.firstChild;)selector.removeChild(selector.firstChild)},setOptions:function(selector,values){for(var i=0,count=values.length;i<values.length;i++){var opt=document.createElement("option");opt.value=values[i],opt.innerHTML=values[i],selector.appendChild(opt)}}};class MenuDrawer extends HTMLElement{constructor(){super(),this.mainDetailsToggle=this.querySelector("details"),this.addEventListener("keyup",this.onKeyUp.bind(this)),this.addEventListener("focusout",this.onFocusOut.bind(this)),this.bindEvents()}bindEvents(){this.querySelectorAll("summary").forEach(summary=>summary.addEventListener("click",this.onSummaryClick.bind(this))),this.querySelectorAll("button:not(.localization-selector):not(.country-selector__close-button):not(.country-filter__reset-button)").forEach(button=>button.addEventListener("click",this.onCloseButtonClick.bind(this)))}onKeyUp(event){if(event.code.toUpperCase()!=="ESCAPE")return;const openDetailsElement=event.target.closest("details[open]");openDetailsElement&&(openDetailsElement===this.mainDetailsToggle?this.closeMenuDrawer(event,this.mainDetailsToggle.querySelector("summary")):this.closeSubmenu(openDetailsElement))}onSummaryClick(event){const summaryElement=event.currentTarget,detailsElement=summaryElement.parentNode,parentMenuElement=detailsElement.closest(".has-submenu"),isOpen=detailsElement.hasAttribute("open"),reducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)"),prevActiveElement=detailsElement.parentNode.parentNode.querySelector("details[open]");function addTrapFocus(){trapFocus(summaryElement.nextElementSibling,detailsElement.querySelector("button")),summaryElement.nextElementSibling.removeEventListener("transitionend",addTrapFocus)}if(detailsElement===this.mainDetailsToggle)isOpen&&event.preventDefault(),isOpen?this.closeMenuDrawer(event,summaryElement):this.openMenuDrawer(summaryElement),window.matchMedia("(max-width: 999px)")&&document.documentElement.style.setProperty("--viewport-height",`${window.innerHeight}px`);
1else{if(prevActiveElement!==null&&prevActiveElement!==detailsElement&&!prevActiveElement.contains(detailsElement)){prevActiveElement.removeAttribute("open");const prevChildActiveElement=prevActiveElement.querySelector("details[open]");prevChildActiveElement!==null&&prevChildActiveElement.removeAttribute("open")}setTimeout(()=>{summaryElement.setAttribute("aria-expanded",!0),parentMenuElement&&parentMenuElement.classList.add("submenu-open"),!reducedMotion||reducedMotion.matches?addTrapFocus():summaryElement.nextElementSibling.addEventListener("transitionend",addTrapFocus)},100)}}openMenuDrawer(summaryElement){setTimeout(()=>{this.mainDetailsToggle.classList.add("menu-opening")}),summaryElement.setAttribute("aria-expanded",!0),trapFocus(this.mainDetailsToggle,summaryElement),document.body.classList.add(`overflow-hidden-${this.dataset.breakpoint}`)}closeMenuDrawer(event,elementToFocus=!1){event!==void 0&&(this.mainDetailsToggle.classList.remove("menu-opening"),this.mainDetailsToggle.querySelectorAll("details").forEach(details=>{details.removeAttribute("open"),details.classList.remove("menu-opening")}),this.mainDetailsToggle.querySelectorAll(".submenu-open").forEach(submenu=>{submenu.classList.remove("submenu-open")}),document.body.classList.remove(`overflow-hidden-${this.dataset.breakpoint}`),removeTrapFocus(elementToFocus),this.closeAnimation(this.mainDetailsToggle),event instanceof KeyboardEvent&&elementToFocus?.setAttribute("aria-expanded",!1))}onFocusOut(){setTimeout(()=>{this.mainDetailsToggle.hasAttribute("open")&&!this.mainDetailsToggle.contains(document.activeElement)&&this.closeMenuDrawer()})}onCloseButtonClick(event){const detailsElement=event.currentTarget.closest("details");this.closeSubmenu(detailsElement)}closeSubmenu(detailsElement){const parentMenuElement=detailsElement.closest(".submenu-open");parentMenuElement&&parentMenuElement.classList.remove("submenu-open"),detailsElement.classList.remove("menu-opening"),detailsElement.querySelector("summary").setAttribute("aria-expanded",!1),removeTrapFocus(detail
1sElement.querySelector("summary")),this.closeAnimation(detailsElement)}closeAnimation(detailsElement){let animationStart;const handleAnimation=time=>{animationStart===void 0&&(animationStart=time),time-animationStart<400?window.requestAnimationFrame(handleAnimation):(detailsElement.removeAttribute("open"),detailsElement.closest("details[open]")&&trapFocus(detailsElement.closest("details[open]"),detailsElement.querySelector("summary")))};window.requestAnimationFrame(handleAnimation)}}customElements.define("menu-drawer",MenuDrawer);class HeaderDrawer extends MenuDrawer{constructor(){super()}openMenuDrawer(summaryElement){this.header=this.header||document.querySelector(".section-header"),this.borderOffset=this.borderOffset||this.closest(".header-wrapper").classList.contains("header-wrapper--border-bottom")?1:0,document.documentElement.style.setProperty("--header-bottom-position",`${parseInt(this.header.getBoundingClientRect().bottom-this.borderOffset)}px`),this.header.classList.add("menu-open"),setTimeout(()=>{this.mainDetailsToggle.classList.add("menu-opening")}),summaryElement.setAttribute("aria-expanded",!0),window.addEventListener("resize",this.onResize),trapFocus(this.mainDetailsToggle,summaryElement),document.body.classList.add(`overflow-hidden-${this.dataset.breakpoint}`)}closeMenuDrawer(event,elementToFocus){elementToFocus&&(super.closeMenuDrawer(event,elementToFocus),this.header.classList.remove("menu-open"),window.removeEventListener("resize",this.onResize))}onResize=()=>{this.header&&document.documentElement.style.setProperty("--header-bottom-position",`${parseInt(this.header.getBoundingClientRect().bottom-this.borderOffset)}px`),document.documentElement.style.setProperty("--viewport-height",`${window.innerHeight}px`)}}customElements.define("header-drawer",HeaderDrawer);class ModalDialog extends HTMLElement{constructor(){super(),this.querySelector('[id^="ModalClose-"]').addEventListener("click",this.hide.bind(this,!1)),this.querySelectorAll(".popup-close-button").forEach(button=>{button.addEventListener("click",this.hide.bind(this,!1))}),this.addEventListener("keyup",event=>{event.code==="Escape"&&this.hide()}),this.classList.contains("media-modal")?this.addEventListener("pointerup",event=>{event.pointerType==="mouse"&&!event.target.closest("deferred-media, product-model")&&this.hide()}):this.addEventListener("click",event=>{event.target===this&&this.hide()})}connectedCallback(){this.moved||(this.moved=!0,document.body.appendChild(this))}show(opener){this.openedBy=opener;const popup=this.querySelector(".template-popup");document.body.classList.add("overflow-hidden"),this.setAttribute("open",""),popup&&popup.loadContent(),trapFocus(this,this.querySelector('[role="dialog"]')),window.pauseAllMedia()}hide(){document.body.classList.remove("overflow-hidden"),document.body.dispatchEvent(new CustomEvent("modalClosed")),this.removeAttribute("open"),removeTrapFocus(this.openedBy),window.pauseAllMedia()}}customElements.define("modal-dialog",ModalDialog);class ModalOpener extends HTMLElement{constructor(){super();const button=this.querySelector("button");button&&button.addEventListener("click",e=>{e.preventDefault();const modal=document.querySelector(this.getAttribute("data-modal"));modal&&modal.show(button)})}}customElements.define("modal-opener",ModalOpener);class DeferredMedia extends HTMLElement{constructor(){super();const poster=this.querySelector('[id^="Deferred-Poster-"]');poster&&poster.addEventListener("click",this.loadContent.bind(this))}loadContent(focus=!0){if(window.pauseAllMedia(),!this.getAttribute("loaded")){const content=document.createElement("div");content.appendChild(this.querySelector("template").content.firstElementChild.cloneNode(!0)),this.setAttribute("loaded",!0);const deferredElement=this.appendChild(content.querySelector("video, model-viewer, iframe"));focus&&deferredElement.focus(),deferredElement.nodeName=="VIDEO"&&deferredElement.getAttribute("autoplay")&&deferredElement.play()}}}customElements.define("deferred-media",DeferredMedia);class SliderComponent extends HTMLElement{constructor(){if(super(),this.slider=this.querySelector('[id^="Slider-"]'),this.sliderItems=this.querySelectorAll('[id^="Slide-"]'),this.enableSliderLooping=!1,this.currentPageElement=this.querySelector(".slider-counter--current"),this.pageTotalElement=this.querySelector(".slider-counter--total"),this.prevButton=this.querySelector('button[name="previous"]'),this.nextButton=this.querySelector('button[name="next"]'),!this.slider||!this.nextButton)return;this.initPages(),new ResizeObserver(entries=>this.initPages()).observe(this.slider),this.slider.addEventListener("scroll",this.update.bind(this)),this.prevButton.addEventListener("click",this.onButtonClick.bind(this)),this.nextButton.addEventListener("click",this.onButtonClick.bind(this))}initPages(){this.sliderItemsToShow=Array.from(this.sliderItems).filter(element=>element.clientWidth>0),!(this.sliderItemsToShow.length<2)&&(this.sliderItemOffset=this.sliderItemsToShow[1].offsetLeft-this.sliderItemsToShow[0].offsetLeft,this.slidesPerPage=Math.floor((this.slider.clientWidth-this.sliderItemsToShow[0].offsetLeft)/this.sliderItemOffset),this.totalPages=this.sliderItemsToShow.length-this.slidesPerPage+1,this.update())}resetPages(){this.sliderItems=this.querySelectorAll('[id^="Slide-"]'),this.sliderItems.length==1&&this.querySelectorAll(".slider-button")?.forEach(button=>button.style.display="none"),this.initPages()}update(){if(!this.slider||!this.nextButton)return;const previousPage=this.currentPage;this.currentPage=Math.round(this.slider.scrollLeft/this.sliderItemOffset)+1,this.currentPageElement&&this.pageTotalElement&&(this.currentPageElement.textContent=this.currentPage,this.pageTotalElement.textContent=this.totalPages),this.currentPage!=previousPage&&this.dispatchEvent(new CustomEvent("slideChanged",{detail:{currentPage:this.currentPage,currentElement:this.sliderItemsToShow[this.currentPage-1]}})),!this.enableSliderLooping&&(this.isSlideVisible(this.sliderItemsToShow[0])&&this.slider.scrollLeft===0?this.prevButton.setAttribute("disabled","disabled"):this.prevButton.removeAttribute("disabled"),this.isSlideVisible(this.sliderItemsToShow[this.sliderItemsToShow.length-1])?this.nextButton.setAttribute("disabled","disabled"):this.nextButton.removeAttribute("disabled"))}isSlideVisible(element,offset=0){const lastVisibleSlide=this.slider.clientWidth+this.slider.scrollLeft-offset;return element.offsetLeft+element.clientWidth<=lastVisibleSlide&&element.offsetLeft>=this.slider.scrollLeft}onButtonClick(event){event.preventDefault();const step=event.currentTarget.dataset.step||1;this.slideScrollPosition=event.currentTarget.name==="next"?this.slider.scrollLeft+step*this.sliderItemOffset:this.slider.scrollLeft-step*this.sliderItemOffset,this.setSlidePosition(this.slideScrollPosition)}setSlidePosition(position){this.slider.scrollTo({left:position})}}customElements.define("slider-component",SliderComponent);class SlideshowComponent extends SliderComponent{constructor(){super(),this.sliderControlWrapper=this.querySelector(".slider-buttons"),this.enableSliderLooping=!0,this.sliderControlWrapper&&(this.sliderFirstItemNode=this.slider.querySelector(".slideshow__slide"),this.sliderItemsToShow.length>0&&(this.currentPage=1),this.announcementBarSlider=this.querySelector(".announcement-bar-slider"),this.announcerBarAnimationDelay=this.announcementBarSlider?250:0,this.sliderControlLinksArray=Array.from(this.sliderControlWrapper.querySelectorAll(".slider-counter__link")),this.sliderControlLinksArray.forEach(link=>link.addEventListener("click",this.linkToSlide.bind(this))),this.slider.addEventListener("scroll",this.setSlideVisibility.bind(this)),this.setSlideVisibility(),this.announcementBarSlider&&(this.announcementBarArrowButtonWasClicked=!1,this.reducedMotion=window.matchMedia("(prefers-reduced-motion: reduce)"),this.reducedMotion.addEventListener("change",()=>{this.slider.getAttribute("data-autoplay")==="true"&&this.setAutoPlay()}
1),[this.prevButton,this.nextButton].forEach(button=>{button.addEventListener("click",()=>{this.announcementBarArrowButtonWasClicked=!0},{once:!0})})),this.slider.getAttribute("data-autoplay")==="true"&&this.setAutoPlay())}static get observedAttributes(){return["data-reset"]}attributeChangedCallback(name,oldValue,newValue){oldValue=="false"&&(this.resetPages(),this.sliderFirstItemNode=this.slider.querySelector(".slideshow__slide"),this.setAttribute("data-reset","false"))}setAutoPlay(){this.autoplaySpeed=this.slider.dataset.speed*1e3,this.addEventListener("mouseover",this.focusInHandling.bind(this)),this.addEventListener("mouseleave",this.focusOutHandling.bind(this)),this.addEventListener("focusin",this.focusInHandling.bind(this)),this.addEventListener("focusout",this.focusOutHandling.bind(this)),this.querySelector(".slideshow__autoplay")?(this.sliderAutoplayButton=this.querySelector(".slideshow__autoplay"),this.sliderAutoplayButton.addEventListener("click",this.autoPlayToggle.bind(this)),this.autoplayButtonIsSetToPlay=!0,this.play()):this.reducedMotion.matches||this.announcementBarArrowButtonWasClicked?this.pause():this.play()}onButtonClick(event){super.onButtonClick(event),this.wasClicked=!0;const isFirstSlide=this.currentPage===1,isLastSlide=this.currentPage===this.sliderItemsToShow.length;if(!isFirstSlide&&!isLastSlide){this.applyAnimationToAnnouncementBar(event.currentTarget.name);return}isFirstSlide&&event.currentTarget.name==="previous"?this.slideScrollPosition=this.slider.scrollLeft+this.sliderFirstItemNode.clientWidth*this.sliderItemsToShow.length:isLastSlide&&event.currentTarget.name==="next"&&(this.slideScrollPosition=0),this.setSlidePosition(this.slideScrollPosition),this.applyAnimationToAnnouncementBar(event.currentTarget.name)}setSlidePosition(position){this.setPositionTimeout&&clearTimeout(this.setPositionTimeout),this.setPositionTimeout=setTimeout(()=>{this.slider.scrollTo({left:position})},this.announcerBarAnimationDelay)}update(){super.update(),this.sliderControlButtons=this.querySelectorAll(".slider-counter__link"),this.prevButton.removeAttribute("disabled"),this.sliderControlButtons.length&&(this.sliderControlButtons.forEach(link=>{link.classList.remove("slider-counter__link--active"),link.removeAttribute("aria-current")}),this.sliderControlButtons[this.currentPage-1].classList.add("slider-counter__link--active"),this.sliderControlButtons[this.currentPage-1].setAttribute("aria-current",!0))}autoPlayToggle(){this.togglePlayButtonState(this.autoplayButtonIsSetToPlay),this.autoplayButtonIsSetToPlay?this.pause():this.play(),this.autoplayButtonIsSetToPlay=!this.autoplayButtonIsSetToPlay}focusOutHandling(event){if(this.sliderAutoplayButton){const focusedOnAutoplayButton=event.target===this.sliderAutoplayButton||this.sliderAutoplayButton.contains(event.target);if(!this.autoplayButtonIsSetToPlay||focusedOnAutoplayButton)return;this.play()}else!this.reducedMotion.matches&&!this.announcementBarArrowButtonWasClicked&&this.play()}focusInHandling(event){this.sliderAutoplayButton?(event.target===this.sliderAutoplayButton||this.sliderAutoplayButton.contains(event.target))&&this.autoplayButtonIsSetToPlay?this.play():this.autoplayButtonIsSetToPlay&&this.pause():this.announcementBarSlider.contains(event.target)&&this.pause()}play(){this.slider.setAttribute("aria-live","off"),clearInterval(this.autoplay),this.autoplay=setInterval(this.autoRotateSlides.bind(this),this.autoplaySpeed)}pause(){this.slider.setAttribute("aria-live","polite"),clearInterval(this.autoplay)}togglePlayButtonState(pauseAutoplay){pauseAutoplay?(this.sliderAutoplayButton.classList.add("slideshow__autoplay--paused"),this.sliderAutoplayButton.setAttribute("aria-label",window.accessibilityStrings.playSlideshow)):(this.sliderAutoplayButton.classList.remove("slideshow__autoplay--paused"),this.sliderAutoplayButton.setAttribute("aria-label",window.accessibilityStrings.pauseSlideshow))}autoRotateSlides(){if(!this.sliderItems.length)return;const slideScrollPosition=this.currentPage===this.sliderItems.length?0:this.slider.scrollLeft+this.sliderItemOffset;this.setSlidePosition(slideScrollPosition),this.applyAnimationToAnnouncementBar()}setSlideVisibility(event){this.sliderItemsToShow.forEach((item,index)=>{const linkElements=item.querySelectorAll("a");index===this.currentPage-1?(linkElements.length&&linkElements.forEac
1h(button=>{button.removeAttribute("tabindex")}),item.setAttribute("aria-hidden","false"),item.removeAttribute("tabindex")):(linkElements.length&&linkElements.forEach(button=>{button.setAttribute("tabindex","-1")}),item.setAttribute("aria-hidden","true"),item.setAttribute("tabindex","-1"))}),this.wasClicked=!1}applyAnimationToAnnouncementBar(button="next"){if(!this.announcementBarSlider)return;const itemsCount=this.sliderItems.length,increment=button==="next"?1:-1,currentIndex=this.currentPage-1;let nextIndex=(currentIndex+increment)%itemsCount;nextIndex=nextIndex===-1?itemsCount-1:nextIndex;const nextSlide=this.sliderItems[nextIndex],currentSlide=this.sliderItems[currentIndex];if(!currentSlide||!nextSlide)return;const animationClassIn="announcement-bar-slider--fade-in",animationClassOut="announcement-bar-slider--fade-out",isFirstSlide=currentIndex===0,isLastSlide=currentIndex===itemsCount-1,direction=button==="next"&&!isLastSlide||button==="previous"&&isFirstSlide?"next":"previous";currentSlide.classList.add(`${animationClassOut}-${direction}`),nextSlide.classList.add(`${animationClassIn}-${direction}`),setTimeout(()=>{currentSlide.classList.remove(`${animationClassOut}-${direction}`),nextSlide.classList.remove(`${animationClassIn}-${direction}`)},this.announcerBarAnimationDelay*2)}linkToSlide(event){event.preventDefault();const slideScrollPosition=this.slider.scrollLeft+this.sliderFirstItemNode.clientWidth*(this.sliderControlLinksArray.indexOf(event.currentTarget)+1-this.currentPage);this.slider.scrollTo({left:slideScrollPosition})}}customElements.define("slideshow-component",SlideshowComponent);class VariantSelects extends HTMLElement{constructor(){super(),this.addEventListener("change",this.onVariantChange),subscribe(PUB_SUB_EVENTS.variantChange,this.handleVariantChangeForLowStock.bind(this)),this.productType=this.dataset.productType,this.variantData=this.getVariantData()}connectedCallback(){this.productType=="Multipack"?this.updateVariantStatusesMultipack():this.updateVariantStatuses(),this.querySelectorAll(".tw-lens-type-option").forEach(button=>{button.addEventListener("click",()=>{const input=button.querySelector('input[type="radio"]');input&&!input.checked&&(input.checked=!0,input.dispatchEvent(new Event("change",{bubbles:!0})))})}),this.updateOptions(),this.updateMasterId(),this.updateSelectedOptions()}onVariantChange(event){this.updateOptions(),this.updateMasterId(),this.updateSelectedSwatchValue(event),this.toggleAddButton(!0,"",!1),this.updatePickupAvailability(),this.removeErrorMessage(),this.productType=="Multipack"?this.updateVariantStatusesMultipack():this.updateVariantStatuses();const lensTypeFieldset=document.querySelector('[data-variant-attribute="lens type"]');if(lensTypeFieldset&&lensTypeFieldset.querySelectorAll('input[type="radio"]').length>1)if(this.currentVariant){const buyButtonBlock=document.getElementById(`BuyButtonsBlock-${this.dataset.section}`);buyButtonBlock&&buyButtonBlock.setAttribute("data-available",this.currentVariant.available);try{this.customCurrentVariant=this.getCustomData().find(variant=>variant.id===this.currentVariant.id)}catch{this.customCurrentVariant=null}this.updateSelectedOptions(),this.updateSwiperGallery(),this.updateModalGallery(),this.updatePdpGalleryGrid(),this.updateFeatures(),this.updateLowStockMessage(),this.updateMedia(),this.updateURL(),this.updateVariantInput(),this.updateShopPayInstallmentsVisibility(),this.renderProductInfo(),this.updateShareUrl(),this.updateSticky()}else{const buyButtonBlock=document.getElementById(`BuyButtonsBlock-${this.dataset.section}`);buyButtonBlock&&buyButtonBlock.setAttribute("data-available","false"),this.updateShopPayInstallmentsVisibility(),this.toggleAddButton(!0,"",!0),this.setUnavailable()}else{try{this.customCurrentVariant=this.getCustomData().find(variant=>variant.id===this.currentVariant.id)}catch{this.customCurrentVariant=null}this.updateSelectedOptions(),this.updateSwiperGallery(),this.updateModalGallery(),this.updatePdpGalleryGrid(),this.updateFeatures(),this.updateLowStockMessage(),this.currentVariant?(this.updateMedia(),this.updateURL(),this.updateV
1ariantInput(),this.updateShopPayInstallmentsVisibility(),this.renderProductInfo(),this.updateShareUrl(),this.updateSticky()):(this.updateShopPayInstallmentsVisibility(),this.toggleAddButton(!0,"",!0),this.setUnavailable())}}updateSticky(){if(this.customCurrentVariant!=null&&this.customCurrentVariant!=null){var variantId=this.customCurrentVariant.id;document.querySelectorAll("#stickyAddToCart .showpricing").forEach(price=>{price.classList.add("tw-hidden")}),document.querySelector("#prices-"+variantId).classList.remove("tw-hidden"),this.customCurrentVariant.available?(document.querySelector("#stickyAddToCart button").classList.remove("tw-opacity-60"),document.querySelector("#stickyAddToCart button").removeAttribute("disabled"),document.querySelector("#stickyAddToCart .sticky-variant-id").value=variantId):(document.querySelector("#stickyAddToCart button").classList.add("tw-opacity-60"),document.querySelector("#stickyAddToCart button").setAttribute("disabled","disabled"))}}updateLowStockMessage(){this.handleVariantChangeForLowStock({data:{variant:this.currentVariant}})}handleVariantChangeForLowStock(event){const variant=event?.data?.variant,lowStockMessage=document.querySelector(".power-low-stock-message");if(!lowStockMessage||!variant)return;const inventoryDataElement=document.querySelector("#VariantInventoryData");if(!inventoryDataElement)return;const qty=JSON.parse(inventoryDataElement.textContent)[variant.id];if(typeof qty<"u"&&qty>0&&qty<=10){const qtySpan=lowStockMessage.querySelector(".power-low-stock-qty");qtySpan.textContent=qty,lowStockMessage.style.display=""}else lowStockMessage.style.display="none"}updateOptions(){this.options=Array.from(this.querySelectorAll("select, fieldset"),element=>{if(element.tagName==="SELECT")return element.value;if(element.tagName==="FIELDSET")return Array.from(element.querySelectorAll("input")).find(radio=>radio.checked)?.value})}updateMasterId(){this.currentVariant=this.getVariantData().find(variant=>!variant.options.map((option,index)=>this.options[index]===option).includes(!1))}updateSelectedSwatchValue({target}){const{name,value,tagName}=target;if(tagName==="SELECT"&&target.selectedOptions.length){const swatchValue=target.selectedOptions[0].dataset.optionSwatchValue,selectedDropdownSwatchValue=this.querySelector(`[data-selected-dropdown-swatch="${name}"] > .swatch`);if(!selectedDropdownSwatchValue)return;swatchValue?(selectedDropdownSwatchValue.style.setProperty("--swatch--background",swatchValue),selectedDropdownSwatchValue.classList.remove("swatch--unavailable")):(selectedDropdownSwatchValue.style.setProperty("--swatch--background","unset"),selectedDropdownSwatchValue.classList.add("swatch--unavailable"))}else if(tagName==="INPUT"&&target.type==="radio"){const selectedSwatchValue=this.querySelector(`[data-selected-swatch-value="${name}"]`);selectedSwatchValue&&(selectedSwatchValue.innerHTML=value)}}updateMedia(){if(!this.currentVariant||!this.currentVariant.featured_media)return;document.querySelectorAll(`[id^="MediaGallery-${this.dataset.section}"]`).forEach(mediaGallery=>mediaGallery.setActiveMedia(`${this.dataset.section}-${this.currentVariant.featured_media.id}`,!0));const modalContent=document.querySelector(`#ProductModal-${this.dataset.section} .product-media-modal__content`);if(!modalContent)return;const newMediaModal=modalContent.querySelector(`[data-media-id="${this.currentVariant.featured_media.id}"]`);modalContent.prepend(newMediaModal)}updateURL(){!this.currentVariant||this.dataset.updateUrl==="false"||window.history.replaceState({},"",`${this.dataset.url}?variant=${this.currentVariant.id}`)}updateShareUrl(){const shareButton=document.getElementById(`Share-${this.dataset.section}`);!shareButton||!shareButton.updateUrl||shareButton.updateUrl(`${window.shopUrl}${this.dataset.url}?variant=${this.currentVariant.id}`)}updateVariantInput(){document.querySelectorAll(`#product-form-${this.dataset.section}, #product-form-installment-${this.dataset.section}, #product-form-installment-buy-${this.dataset.section}`).forEach(productForm=>{const input=productForm.querySelector('input[name="id"]');input&&(input.value=this.currentVariant.id,input.dispatchEvent(new Event("change",{bubbles:!0})))})}updateShopPayInstallmentsVisibility(){const wrapper=document.getElementById(`ShopPayInstallments-${this.dataset.section}`);if(!wrapper)return;const isAvailable=!!(this.currentVariant&&this.currentVariant.available);wrapper.style.display=isAvailable?"":"none",wrapper.setAttribute("aria-hidden",(!isAvailable).toString())}updateVariantStatuses(){const selectedOptionOneVariants=this.variantData.filter(variant=>this.querySelector(":checked").value===variant.option1),inputWrappers=[...this.querySelectorAll(".product-form__input")];
1inputWrappers.forEach((option,index)=>{if(index===0)return;const optionInputs=[...option.querySelectorAll('input[type="radio"], option')];if(index==1){const previousOptionSelected=inputWrappers[index-1].querySelector(":checked").value;var nextOptionSelected=null;inputWrappers[index+1]!=null&&(nextOptionSelected=inputWrappers[index+1].querySelector(":checked").value),this.setInputAvailability(optionInputs,index,[previousOptionSelected,nextOptionSelected],selectedOptionOneVariants)}else if(index==2){const firstOptionSelected=inputWrappers[index-2].querySelector(":checked").value,secondOptionSelected=inputWrappers[index-1].querySelector(":checked").value;this.setInputAvailability(optionInputs,index,[firstOptionSelected,secondOptionSelected],selectedOptionOneVariants)}}),this.updateLensTypeButtonsAvailability()}updateLensTypeButtonsAvailability(){const lensTypeButtons=this.querySelectorAll(".tw-lens-type-option");if(lensTypeButtons.length===0)return;const powerFieldset=this.querySelector('[data-variant-attribute="power"]');if(!powerFieldset)return;const selectedPower=powerFieldset.querySelector("input:checked")?.value;selectedPower&&lensTypeButtons.forEach(button=>{const lensType=button.dataset.lensTypeValue,isSelected=button.querySelector('input[type="radio"]')?.checked||!1,isAvailable=this.variantData.some(variant=>variant.option1===lensType&&variant.option2===selectedPower&&variant.available);isSelected&&isAvailable?(button.style.border="1.5px solid #45423D",button.style.background="#FFF"):isSelected&&!isAvailable?(button.style.border="1.5px solid #45423D",button.style.background="#F5F5F4"):!isSelected&&isAvailable?(button.style.border="1px solid #D8D8D8",button.style.background="#FFF"):(button.style.border="1px solid #D8D8D8",button.style.background="#F5F5F4"),button.dataset.inStock=isAvailable.toString(),button.dataset.selected=isSelected.toString()})}setInputAvailability(elementList,index,currentValues,selectedOptionOneVariants){elementList.forEach(element=>{const value=element.getAttribute("value");if(index==1)if(currentValues[1]==null)var availableElement=selectedOptionOneVariants.filter(variant=>variant.available&&variant.options[0]===currentValues[0]&&variant.options[1]===value);else var availableElement=selectedOptionOneVariants.filter(variant=>variant.available&&variant.options[0]===currentValues[0]&&variant.options[1]===value&&variant.options[2]===currentValues[1]);else var availableElement=selectedOptionOneVariants.filter(variant=>variant.available&&variant.options[0]===currentValues[0]&&variant.options[1]===currentValues[1]&&variant.options[2]===value);availableElement.length==0?availableElement=!1:availableElement=!0,element.tagName==="INPUT"?element.classList.toggle("disabled",!availableElement):element.tagName==="OPTION"&&(element.innerText=availableElement?value:window.variantStrings.unavailable_with_option.replace("[value]",value))})}updateVariantStatusesMultipack(){const firstChecked=this.querySelector(":checked");if(!firstChecked)return;const selectedOptionOneVariants=this.variantData.filter(variant=>firstChecked.value===variant.option1),inputWrappers=[...this.querySelectorAll(".product-form__input")];inputWrappers.forEach((option,index)=>{if(index===0)return;const optionInputs=[...option.querySelectorAll('input[type="radio"], option')],prevChecked=inputWrappers[index-1].querySelector(":checked");if(!prevChecked)return;const previousOptionSelected=prevChecked.value,availableOptionInputsValue=selectedOptionOneVariants.filter(variant=>variant.available&&variant[`option${index}`]===previousOptionSelected).map(variantOption=>variantOption[`option${index+1}`]);this.setInputAvailabilityMultipack(optionInputs,availableOptionInputsValue)})}setInputAvailabilityMultipack(elementList,availableValuesList){elementList.forEach(element=>{const value=element.getAttribute("value"),availableElement=availableValuesList.includes(value);element.tagName==="INPUT"?element.classList.toggle("disabled",!availableElement):element.tagName==="OPTION"&&(element.innerText=availableElement?value:window.variantStrings.unavailable_with_option.replace("[value]",value))})}updatePickupAvailability(){const pickUpAvailability=document.querySelector("pickup-availability");pickUpAvailability&&(this.currentVariant&&this.currentVariant.available?pickUpAvailability.fetchAvailability(this.currentVariant.id):(pickUpAvailability.removeAttribute("available"),pickUpAvailability.innerHTML=""))}removeErrorMessage(){const section=this.closest("section");if(!section)return;const productForm=section.querySelector("product-form");productForm&&productForm.handleErrorMessage()}renderProductInfo(){const requestedVariantId=this.currentVariant.id,sectionId=this.dataset.originalSection?this.dataset.originalSection:this.dataset.section;fetch(`${this.dataset.url}?variant=${requestedVariantId}&section_id=${this.dataset.originalSection?this.dataset.originalSection:this.dataset.section}`).then(response=>response.text()).then(responseText=>{if(this.currentVariant.id!==requestedVariantId)return;const html=new DOMParser().parseFromString(responseText,"text/html"),destination=document.getElementById(`price-${this.dataset.section}`),source=html.getElementById(`price-${this.dataset.originalSection?this.dataset.originalSection:this.dataset.section}`),skuSource=html.getElementById(`Sku-${this.dataset.originalSection?this.dataset.originalSection:this.dataset.section}`),skuDestination=document.getElementById(`Sku-${this.dataset.section}`),inventorySource=html.getElementById(`Inventory-${this.dataset.originalSection?this.dataset.originalSection:this.dataset.section}`),inventoryDestination=document.getElementById(`Inventory-${this.dataset.section}`),volumePricingSource=html.getElementById(`Volume-${this.dataset.originalSection?this.dataset.originalSection:this.dataset.section}`),pricePerItemDestination=document.getElementById(`Price-Per-Item-${this.dataset.section}`),pricePerItemSource=html.getElementById(`Price-Per-Item-${this.dataset.originalSection?this.dataset.originalSection:this.dataset.section}`),volumePricingDestination=document.getElementById(`Volume-${this.dataset.section}`),qtyRules=document.getElementById(`Quantity-Rules-${this.dataset.section}`),volumeNote=document.getElementById(`Volume-Note-${this.dataset.section}`),videoPartDestination=document.querySelectorAll(".product-videos-part"),videoPartSource=html.querySelector(".product-videos-part");volumeNote&&volumeNote.classList.remove("hidden"),volumePricingDestination&&volumePricingDestination.classList.remove("hidden"),qtyRules&&qtyRules.classList.remove("hidden"),source&&destination&&(destination.innerHTML=source.innerHTML),inventorySource&&inventoryDestination&&(inventoryDestination.innerHTML=inventorySource.innerHTML),skuSource&&skuDestination&&(skuDestination.innerHTML=skuSource.innerHTML,skuDestination.classList.toggle("hidden",skuSource.classList.contains("hidden"))),volumePricingSource&&volumePricingDestination&&(volumePricingDestination.innerHTML=volumePricingSource.innerHTML),pricePerItemSource&&pricePerItemDestination&&(pricePerItemDestination.innerHTML=pricePerItemSource.innerHTML,pricePerItemDestination.classList.toggle("hidden",pricePerItemSource.classList.contains("hidden")));const price=document.getElementById(`price-${this.dataset.section}`);price&&price.classList.remove("hidden"),inventoryDestination&&inventoryDestination.classList.toggle("hidden",inventorySource.innerText==="");const addButtonUpdated=html.getElementById(`ProductSubmitButton-${sectionId}`);this.toggleAddButton(addButtonUpdated?addButtonUpdated.hasAttribute("disabled"):!0,window.variantStrings.soldOut),videoPartDestination&&videoPartDestination.forEach(elementDestination=>{elementDestination.innerHTML=videoPartSource.innerHTML});const priceMobileDestination=document.getElementById(`price-mobile-${this.dataset.section}`);source&&priceMobileDestination&&(priceMobileDestination.innerHTML=source.innerHTML);const priceBottomDestination=document.getElementById(`price-bottom-${this.dataset.section}`);source&&priceBottomDestination&&(priceBottomDestination.innerHTML=source.innerHTML);const buyButtonBlock=document.getElementById(`BuyButtonsBlock-${this.dataset.section}`);buyButtonBlock&&buyButtonBlock.setAttribute("data-available",this.currentVariant.available),publish(PUB_SUB_EVENTS.variantChange,{data:{sectionId,html,variant:this.currentVariant}})})}toggleAddButton(disable=!0,text,modifyClass=!0){const productForm=d
1ocument.getElementById(`product-form-${this.dataset.section}`);if(!productForm)return;const addButton=productForm.querySelector('[name="add"]'),addButtonText=productForm.querySelector('[name="add"] > span');addButton&&(disable?(addButton.setAttribute("disabled","disabled"),text&&(addButtonText.textContent=text)):(addButton.removeAttribute("disabled"),addButtonText.textContent=window.variantStrings.addToCart.toUpperCase()))}setUnavailable(){const button=document.getElementById(`product-form-${this.dataset.section}`),addButton=button.querySelector('[name="add"]'),addButtonText=button.querySelector('[name="add"] > span'),price=document.getElementById(`price-${this.dataset.section}`),inventory=document.getElementById(`Inventory-${this.dataset.section}`),sku=document.getElementById(`Sku-${this.dataset.section}`),pricePerItem=document.getElementById(`Price-Per-Item-${this.dataset.section}`),volumeNote=document.getElementById(`Volume-Note-${this.dataset.section}`),volumeTable=document.getElementById(`Volume-${this.dataset.section}`),qtyRules=document.getElementById(`Quantity-Rules-${this.dataset.section}`);addButton&&(addButtonText.textContent=window.variantStrings.unavailable,price&&price.classList.add("hidden"),inventory&&inventory.classList.add("hidden"),sku&&sku.classList.add("hidden"),pricePerItem&&pricePerItem.classList.add("hidden"),volumeNote&&volumeNote.classList.add("hidden"),volumeTable&&volumeTable.classList.add("hidden"),qtyRules&&qtyRules.classList.add("hidden"))}getVariantData(){return this.variantData=this.variantData||JSON.parse(this.querySelector('[type="application/json"]').textContent),this.variantData}updateSelectedOptions(){let variantOption1Label=this.querySelector(".form__label--option1"),variantOption2Label=this.querySelector(".form__label--option2"),variantOption3Label=this.querySelector(".form__label--option3");if(variantOption1Label)if(variantOption1Label.closest('[data-variant-attribute="power"]')!=null)variantOption1Label.innerHTML="+"+formatPower(this.currentVariant.option1);else{variantOption1Label.innerHTML=this.currentVariant.option1;let customCurrentVariant=this.getCustomData().find(variant=>variant.id===this.currentVariant.id);if(customCurrentVariant&&customCurrentVariant.lenstype_tooltip!=null){const tooltip_text=variantOption1Label.closest(".form__label--selected-option").querySelector(".tw-tooltip-text > p");tooltip_text&&(tooltip_text.innerHTML=customCurrentVariant.lenstype_tooltip)}}variantOption2Label&&(variantOption2Label.closest('[data-variant-attribute="power"]')!=null?variantOption2Label.innerHTML="+"+formatPower(this.currentVariant.option2):variantOption2Label.innerHTML=this.currentVariant.option2),variantOption3Label&&(variantOption3Label.closest('[data-variant-attribute="power"]')!=null?variantOption3Label.innerHTML="+"+formatPower(this.currentVariant.option3):variantOption3Label.innerHTML=this.currentVariant.option3)}updateSwiperGallery(){if(!this.customCurrentVariant)return;const getSrcImgParts=(hostname,src)=>{switch(hostname){case"readers-staging.myshopify.com":const parts=src.split("/");if(parts.length>1)return parts[1].split(".")[0].split("_")[0].toLowerCase();default:if(src&&src.split("/").length>1){let string=src.split("/")[1].split(".")[0].toLowerCase();return string.includes("_")?string=string.split("_")[0]:string=string,string}}},parser=new DOMParser,swiperWrapper=document.querySelector("pdp-swiper .swiper-wrapper");if(!swiperWrapper)return;this.customCurrentVariant.meta_images&&this.customCurrentVariant.meta_images!="#N/D"&&(document.querySelectorAll("pdp-swiper .swiper-slide").forEach(sli
1de=>{slide.remove()}),this.metaVariantImages=this.customCurrentVariant.meta_images.split(",").map(img=>{let key=img.toLowerCase().trim();const dotIdx=key.indexOf(".");return dotIdx>0?key.substring(0,dotIdx):key}),document.querySelectorAll(".script-gallery-images script").forEach(script=>{this.metaVariantImages.forEach(metaImg=>{if(getSrcImgParts(window.location.hostname,script.getAttribute("data-img-src"))==metaImg){let htmlDoc=parser.parseFromString(script.innerHTML,"text/html");swiperWrapper.appendChild(htmlDoc.querySelector(".swiper-slide"))}})}));let pdpSwiper=document.querySelector("pdp-swiper");pdpSwiper&&pdpSwiper.setAttribute("data-reset","true")}getCustomData(){return this.customVariantData=JSON.parse(this.querySelector("#CustomVariantsScript").textContent),this.customVariantData}updateModalGallery(){if(!this.customCurrentVariant)return;const parser=new DOMParser;if(this.customCurrentVariant.meta_images){const slideshow=document.querySelector("custom-product-modal .slideshow");if(!slideshow)return;document.querySelectorAll("custom-product-modal .slideshow__slide").forEach(sli
1de=>{slide.remove()}),this.metaVariantImages=this.customCurrentVariant.meta_images.split(",").map(img=>{let key=img.toLowerCase().trim();const dotIdx=key.indexOf(".");return dotIdx>0?key.substring(0,dotIdx):key});let scriptSlides=document.querySelectorAll(".script-modal-images script");const newSlides=[];scriptSlides.forEach(script=>{this.metaVariantImages.forEach(metaImg=>{if(script.getAttribute("data-img-src")==metaImg){const slide=parser.parseFromString(script.innerHTML,"text/html").querySelector(".slideshow__slide");slide&&newSlides.push({slide,src:metaImg})}})}),newSlides.sort((a,b)=>{const indexA=this.metaVariantImages.indexOf(a.src),indexB=this.metaVariantImages.indexOf(b.src);return indexA-indexB}),slideshow.innerHTML="",newSlides.forEach(slideData=>{slideshow.appendChild(slideData.slide)});const counterTotal=document.querySelector("custom-product-modal .slider-counter--total");counterTotal&&(counterTotal.textContent=newSlides.length.toString());const counterCurrent=document.querySelector("custom-product-modal .slider-counter--current");counterCurrent&&(counterCurrent.textContent="1");let modalSlider=document.querySelector(".modal-slideshow-component");modalSlider&&modalSlider.setAttribute("data-reset","true")}}updatePdpGalleryGrid(){const allGalleryGrids=document.querySelectorAll("pdp-gallery-grid"),pdpGalleryGrid=document.querySelector("pdp-gallery-grid");if(pdpGalleryGrid){if(this.customCurrentVariant&&this.customCurrentVariant.meta_images&&this.customCurrentVariant.meta_images!="#N/D"){const parser=new DOMParser,metaVariantImages=this.customCurrentVariant.meta_images.split(",").map(img=>{let key=img.toLowerCase().trim();const dotIdx=key.indexOf(".");return dotIdx>0?key.substring(0,dotIdx):key}),scriptTags=pdpGalleryGrid.querySelectorAll(".pdp-gallery-grid__all-product-images script");if(scriptTags.length===0)return;const filteredImages=[];if(scriptTags.forEach(script=>{const srcKey=(script.getAttribute("data-img-src")||"").toLowerCase();metaVariantImages.includes(srcKey)&&filteredImages.push({mediaId:script.getAttribute("data-media-id"),imgSrc:srcKey,fullSrc:script.getAttribute("data-full-src")||"",alt:script.getAttribute("data-alt")||"",html:script.innerHTML})}),filteredImages.sort((a,b)=>{const indexA=metaVariantImages.indexOf(a.imgSrc),indexB=metaVariantImages.indexOf(b.imgSrc);return indexA-indexB}),filteredImages.length>0){const mainImageContainer=pdpGalleryGrid.querySelector(".pdp-gallery-grid__main-image"),sectionId=pdpGalleryGrid.dataset.sectionId||"";if(mainImageContainer){const firstImage=filteredImages[0];mainImageContainer.setAttribute("data-media-id",`${sectionId}-${firstImage.mediaId}`);const mainImg=mainImageContainer.querySelector(".product__media img");if(mainImg&&firstImage.fullSrc){const newSrc=firstImage.fullSrc,baseSrc=newSrc.replace(/width=\d+/,"width=");mainImg.src=newSrc,mainImg.srcset=`
2              ${baseSrc.replace("width=","width=493")} 493w,
3              ${baseSrc.replace("width=","width=600")} 600w,
4              ${baseSrc.replace("width=","width=823")} 823w,
5              ${baseSrc.replace("width=","width=990")} 990w,
6              ${baseSrc.replace("width=","width=1200")} 1200w
7            `,mainImg.alt=firstImage.alt}}const thumbnailsContainer=pdpGalleryGrid.querySelector(".pdp-gallery-grid__thumbnails");if(!thumbnailsContainer)return;thumbnailsContainer.innerHTML="";const maxVisibleThumbs=4,thumbnailImages=filteredImages.slice(1),totalThumbnails=thumbnailImages.length,remainingImages=totalThumbnails>maxVisibleThumbs?totalThumbnails-maxVisibleThumbs+1:0;thumbnailImages.slice(0,maxVisibleThumbs).forEach((data,index)=>{const thumbElement=parser.parseFromString(data.html,"text/html").querySelector(".pdp-gallery-grid__thumb");if(thumbElement){if(thumbElement.setAttribute("data-index",String(index)),index===maxVisibleThumbs-1&&remainingImages>1){thumbElement.classList.add("pdp-gallery-grid__thumb--more");const overlay=document.createElement("div");overlay.className="pdp-gallery-grid__more-overlay",overlay.innerHTML=`<span class="pdp-gallery-grid__more-count">+${remainingImages}</span>`,thumbElement.appendChild(overlay)}thumbnailsContainer.appendChild(thumbElement)}});const filteredContainer=pdpGalleryGrid.querySelector(".pdp-gallery-grid__all-images");filteredContainer&&(filteredContainer.innerHTML="",filteredImages.forEac
7h(data=>{const script=document.createElement("script");script.type="text/html",script.setAttribute("data-media-id",data.mediaId),script.setAttribute("data-img-src",data.imgSrc),script.setAttribute("data-alt",data.alt),script.setAttribute("data-full-src",data.fullSrc),script.innerHTML=data.html,filteredContainer.appendChild(script)}));const wasExpanded=pdpGalleryGrid.expanded;pdpGalleryGrid.allImagesData=filteredImages,pdpGalleryGrid.expanded=!1,pdpGalleryGrid.thumbnails=pdpGalleryGrid.querySelectorAll(".pdp-gallery-grid__thumb"),pdpGalleryGrid.currentIndex=0,pdpGalleryGrid.bindEvents(),wasExpanded&&typeof pdpGalleryGrid.expandThumbnails=="function"&&pdpGalleryGrid.expandThumbnails(),this.updateMobileSwiper(pdpGalleryGrid,filteredImages)}}else if(this.customCurrentVariant&&this.customCurrentVariant.color){const colorParts=this.customCurrentVariant.color.toLowerCase().split(/[\/\s]+/).filter(c=>c.length>0),parser=new DOMParser,scriptTags=pdpGalleryGrid.querySelectorAll(".pdp-gallery-grid__all-product-images script");if(scriptTags.length>0){const filteredImages=[];if(scriptTags.forEach(script=>{const imgSrc=script.getAttribute("data-img-src")||"",srcLower=imgSrc.toLowerCase();colorParts.some(colorPart=>srcLower.includes(colorPart))&&filteredImages.push({mediaId:script.getAttribute("data-media-id"),imgSrc,fullSrc:script.getAttribute("data-full-src")||"",alt:script.getAttribute("data-alt")||"",html:script.innerHTML})}),filteredImages.length>0){const mainImageContainer=pdpGalleryGrid.querySelector(".pdp-gallery-grid__main-image");if(mainImageContainer){const firstImage=filteredImages[0],mainImg=mainImageContainer.querySelector(".product__media img");if(mainImg&&firstImage.fullSrc){const newSrc=firstImage.fullSrc,baseSrc=newSrc.replace(/width=\d+/,"width=");mainImg.src=newSrc,mainImg.srcset=`
8                  ${baseSrc.replace("width=","width=493")} 493w,
9                  ${baseSrc.replace("width=","width=600")} 600w,
10                  ${baseSrc.replace("width=","width=823")} 823w,
11                  ${baseSrc.replace("width=","width=990")} 990w,
12                  ${baseSrc.replace("width=","width=1200")} 1200w
13                `,mainImg.alt=firstImage.alt}}const thumbnailsContainer=pdpGalleryGrid.querySelector(".pdp-gallery-grid__thumbnails");if(thumbnailsContainer){thumbnailsContainer.innerHTML="";const maxVisibleThumbs=4,thumbnailImages=filteredImages.slice(1),totalThumbnails=thumbnailImages.length,remainingImages=totalThumbnails>maxVisibleThumbs?totalThumbnails-maxVisibleThumbs+1:0;thumbnailImages.slice(0,maxVisibleThumbs).forEach((data,index)=>{const thumbElement=parser.parseFromString(data.html,"text/html").querySelector(".pdp-gallery-grid__thumb");if(thumbElement){if(thumbElement.setAttribute("data-index",String(index)),index===maxVisibleThumbs-1&&remainingImages>1){thumbElement.classList.add("pdp-gallery-grid__thumb--more");const overlay=document.createElement("div");overlay.className="pdp-gallery-grid__more-overlay",overlay.innerHTML=`<span class="pdp-gallery-grid__more-count">+${remainingImages}</span>`,thumbElement.appendChild(overlay)}thumbnailsContainer.appendChild(thumbElement)}});const filteredContainer=pdpGalleryGrid.querySelector(".pdp-gallery-grid__all-images");filteredContainer&&(filteredContainer.innerHTML="",filteredImages.forEach(data=>{const script=document.createElement("script");script.type="text/html",script.setAttribute("data-media-id",data.mediaId),script.setAttribute("data-img-src",data.imgSrc),script.setAttribute("data-alt",data.alt),script.setAttribute("data-full-src",data.fullSrc),script.innerHTML=data.html,filteredContainer.appendChild(script)}));const wasExpandedFallback=pdpGalleryGrid.expanded;pdpGalleryGrid.allImagesData=filteredImages,pdpGalleryGrid.expanded=!1,pdpGalleryGrid.thumbnails=pdpGalleryGrid.querySelectorAll(".pdp-gallery-grid__thumb"),pdpGalleryGrid.currentIndex=0,pdpGalleryGrid.bindEvents(),wasExpandedFallback&&typeof pdpGalleryGrid.expandThumbnails=="function"&&pdpGalleryGrid.expandThumbnails(),this.updateMobileSwiper(pdpGalleryGrid,filteredImages)}}}}}}updateMobileSwiper(pdpGalleryGrid,filteredImages){const mobileSwiper=pdpGalleryGrid.querySelector(".pdp-gallery-grid__mobile-swiper");if(!mobileSwiper)return;const mobileSlidesContainer=mobileSwiper.querySelector(".pdp-gallery-grid__mobile-slides"),mobileProgress=mobileSwiper.querySelector(".pdp-gallery-grid__mobile-progress"),mobileCounterTotal=mobileSwiper.querySelector(".pdp-gallery-grid__mobile-counter-total"),mobileCounterCurrent=mobileSwiper.querySelector(".pdp-gallery-grid__mobile-counter-current");
13if(!mobileSlidesContainer)return;const isAccessory=pdpGalleryGrid.closest(".product")?.classList.contains("product--accessory")||document.querySelector(".product-type-accessory")!==null||pdpGalleryGrid.dataset.isAccessory==="true",existingPlaceholders=mobileSlidesContainer.querySelectorAll(".pdp-gallery-grid__mobile-slide--placeholder"),placeholderData=[];existingPlaceholders.forEach(placeholder=>{const img=placeholder.querySelector("img");img&&placeholderData.push({src:img.src,alt:img.alt||"Lifestyle image",mediaId:placeholder.dataset.mediaId})}),mobileSlidesContainer.innerHTML="";const sectionId=pdpGalleryGrid.dataset.sectionId||"";let slideIndex=0;filteredImages.forEach((data,index)=>{const slide=document.createElement("div");slide.className="pdp-gallery-grid__mobile-slide",slide.setAttribute("data-media-id",`${sectionId}-${data.mediaId}`),slide.setAttribute("data-slide-index",String(slideIndex));const img=document.createElement("img");img.className="pdp-gallery-grid__mobile-img";const fullSrc=data.fullSrc||"",baseSrc=fullSrc.replace(/width=\d+/,"width=");img.src=baseSrc?baseSrc.replace("width=","width=800"):fullSrc,img.srcset=baseSrc?`
14        ${baseSrc.replace("width=","width=400")} 400w,
15        ${baseSrc.replace("width=","width=600")} 600w,
16        ${baseSrc.replace("width=","width=800")} 800w
17      `:"",img.sizes="100vw",img.alt=data.alt||"",img.loading=index===0?"eager":"lazy",slide.appendChild(img),mobileSlidesContainer.appendChild(slide),slideIndex++,index===0&&!isAccessory&&placeholderData.length>0&&placeholderData.forEach((ph,phIndex)=>{const placeholderSlide=document.createElement("div");placeholderSlide.className="pdp-gallery-grid__mobile-slide pdp-gallery-grid__mobile-slide--placeholder",placeholderSlide.setAttribute("data-media-id",ph.mediaId||`placeholder-${phIndex+1}-${sectionId}`),placeholderSlide.setAttribute("data-slide-index",String(slideIndex));const phImg=document.createElement("img");phImg.className="pdp-gallery-grid__mobile-img",phImg.src=ph.src,phImg.alt=ph.alt,phImg.loading="lazy",placeholderSlide.appendChild(phImg),mobileSlidesContainer.appendChild(placeholderSlide),slideIndex++})});const totalSlides=slideIndex;mobileProgress&&(mobileProgress.style.setProperty("--total-slides",totalSlides),mobileProgress.setAttribute("data-total-slides",totalSlides)),mobileCounterTotal&&(mobileCounterTotal.textContent=totalSlides),mobileCounterCurrent&&(mobileCounterCurrent.textContent="1"),mobileSlidesContainer.scrollLeft=0;const progressBar=mobileSwiper.querySelector(".pdp-gallery-grid__mobile-progress-bar");progressBar&&(progressBar.style.transform="translateX(0)",progressBar.style.width=`calc(100% / ${totalSlides})`),typeof pdpGalleryGrid.initMobileSwiper=="function"&&pdpGalleryGrid.initMobileSwiper()}updateFeatures(){if(!this.customCurrentVariant)return;let featureValueLensType=document.querySelector(".feature-item.feature--lens-type .feature-value-container .feature-value"),lensTypeTooltip=document.querySelector(".feature-item.feature--lens-type .feature-value-container .tw-tooltip-text p");featureValueLensType&&(featureValueLensType.innerHTML=this.customCurrentVariant.lenstype,featureValueLensType.setAttribute("aria-label",this.customCurrentVariant.lenstype_tooltip)),lensTypeTooltip&&(lensTypeTooltip.innerHTML=this.customCurrentVariant.lenstype_tooltip)}}customElements.define("variant-selects",VariantSelects);class ProductRecommendations extends HTMLElement{constructor(){super()}connectedCallback(){const handleIntersection=(entries,observer)=>{entries[0].isIntersecting&&(observer.unobserve(this),fetch(this.dataset.url).then(response=>response.text()).then(text=>{const html=document.createElement("div");html.innerHTML=text;const recommendations=html.querySelector("product-recommendations");recommendations&&recommendations.innerHTML.trim().length&&(this.innerHTML=recommendations.innerHTML),!this.querySelector("slideshow-component")&&!this.querySelector("swiper-slider")&&this.classList.contains("complementary-products")&&this.remove(),html.querySelector(".grid__item")&&this.classList.add("product-recommendations--loaded")}).catch(e=>{console.error(e)}))};new IntersectionObserver(handleIntersection.bind(this),{rootMargin:"0px 0px 400px 0px"}).observe(this)}}customElements.define("product-recommendations",ProductRecommendations),(function(){const ua=navigator.userAgent,maxTouch=navigator.maxTouchPoints||0,isIPadOS=/Macintosh/.test(ua)&&maxTouch>1,isIOS=!isIPadOS&&/iPhone|iPod/.test(ua),isAndroid=/Android/.test(ua),root=document.documentElement;isIPadOS?root.classList.add("is-ipados"):isIOS&&root.classList.add("is-ios"),isAndroid&&root.classList.add("is-android")})();
18//# sourceMappingURL=/cdn/shop/t/236/assets/global.js.map?v=145620862185718595461778062538

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.