1import{morph}from"@theme/morph";class KwaySwatches extends HTMLElement{#abortController=null;#fetchAbortController=null;connectedCallback(){if(this.#abortController=new AbortController,!(this.dataset.enableCardRefresh==="true"))this.addEventListener("click",this.#handleClick,{signal:this.#abortController.signal});else{const productUrl=this.dataset.productUrl;if(!productUrl)return;this.addEventListener("click",()=>{this.classList.contains("kway-swatches__pill--selected")||this.refreshCard(productUrl)},{signal:this.#abortController.signal})}}disconnectedCallback(){this.#abortController?.abort(),this.#abortController=null,this.#fetchAbortController?.abort(),this.#fetchAbortController=null}#handleClick=event=>{const productUrl=this.dataset.productUrl;if(productUrl){if(this.closest('[id*="ProductInformation-"]')){event.preventDefault(),location.replace(productUrl);return}this.dataset.enableCardRefresh==="true"&&(event.preventDefault(),this.refreshCard(productUrl))}};refreshCard(pillHref){const productCard=this.closest("product-card");if(!productCard)return;const pillsContainer=this.closest(".kway-swatches__pills");let previousSelected=null;pillsContainer&&(previousSelected=pillsContainer.querySelector(".kway-swatches__pill--selected"),previousSelected&&previousSelected.classList.remove("kway-swatches__pill--selected")),this.classList.add("kway-swatches__pill--selected");const requestUrl=`${new URL(pillHref,window.location.origin).pathname}?section_id=section-rendering-product-card`;this.#fetchAbortController?.abort(),this.#fetchAbortController=new AbortController,fetch(requestUrl,{signal:this.#fetchAbortController.signal}).then(response=>response.text()).then(responseText=>{const newProductCard=new DOMParser().parseFromString(responseText,"text/html").querySelector("product-card");if(!newProductCard)throw new Error("Fetched content does not contain a product card");const elementSelectors=[[".card-gallery",".card-gallery"],["product-price","product-price"],[".product-features",".product-features"]];for(const[currentSelector,newSelector]of elementSelectors){const currentEl=productCard.querySelector(currentSelector),newEl=newProductCard.querySelector(newSelector);currentEl&&newEl&&morph(currentEl,newEl)}for(const attr of newProductCard.attributes)(attr.name.startsWith("data-gtm-")||attr.name==="data-is-gtm-item")&&productCard.setAttribute(attr.name,attr.value)}).catch(error=>{error.name==="AbortError"?console.warn("Fetch aborted by user"):(console.error(error),this.#revertSelectedState(previousSelected))})}#revertSelectedState(previousSelected){this.classList.remove("kway-swatches__pill--selected"),previousSelected&&previousSelected.classList.add("kway-swatches__pill--selected")}}customElements.get("kway-swatches")||customElements.define("kway-swatches",KwaySwatches); 2//# sourceMappingURL=/cdn/shop/t/299/assets/kway-swatches.js.map?v=21201443546380403051790091657
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.