https://www.thewilloughbybookclub.co.uk/cdn/shop/t/35/assets/compo…?v=138114961180989057021784636146
1(()=>{if(!customElements.get("recently-viewed-products")){class RecentlyViewedProducts extends HTMLElement{constructor(){super(),this.abortController=null,this.cacheDOMElements(),this.bindEventHandlers()}connectedCallback(){this.addEventListeners(),this.debouncedRenderRecentlyViewedProducts()}cacheDOMElements(){this.sectionId=this.getAttribute("data-wetheme-section-id"),this.isPreviewMode=this.getAttribute("data-is-preview-mode")=="true",this.wrapper=this.closest("data-recently-viewed-wrapper"),!this.sectionId||this.wrapper}bindEventHandlers(){this.debouncedRenderRecentlyViewedProductsBound=this.debouncedRenderRecentlyViewedProducts.bind(this)}addEventListeners(){window.Shopify.designMode&&document.addEventListener("shopify:section:load",this.debouncedRenderRecentlyViewedProductsBound)}debouncedRenderRecentlyViewedProducts(){this.renderTimeout&&clearTimeout(this.renderTimeout),this.abortController&&this.abortController.abort();const delay=window.Shopify.designMode?800:100;this.renderTimeout=setTimeout(()=>this.renderRecentlyViewedProducts(),delay)}async renderRecentlyViewedProducts(){try{this.abortController&&this.abortController.abort(),this.abortController=new AbortController;const recentlyViewedProducts=JSON.parse(localStorage.getItem("theme:recently-viewed-products")||"[]");if(!recentlyViewedProducts.length&&!this.isPreviewMode){this.wrapper&&(this.wrapper.style.display="none");return}const items=new Set(recentlyViewedProducts);if(this.hasAttribute("exclude-id")&&items.delete(parseInt(this.getAttribute("exclude-id"))),!items.size&&!this.isPreviewMode){this.wrapper&&(this.wrapper.style.display="none");return}const queryString=Array.from(items.values(),item=>`id:${item}`).slice(0,parseInt(this.getAttribute("data-products-to-show"))).join(" OR ");let url=`${window.Shopify.routes.root}search?type=product&q=${queryString}§ion_id=${this.sectionId}`;window.Shopify.designMode&&(url+=`&t=${Date.now()}`);const responseText=await(await fetch(url,{signal:this.abortController.signal})).text(),tempDiv=document.createElement("div");tempDiv.innerHTML=responseText;const recentlyViewedProductsElement=tempDiv.querySelector("recently-viewed-products");recentlyViewedProductsElement&&recentlyViewedProductsElement.childElementCount>0?(this.replaceChildren(...recentlyViewedProductsElement.childNodes),window.eventBus.emit("recentlyViewed:updated")):!this.isPreviewMode&&this.wrapper&&(this.wrapper.style.display="none")}catch(e){e.name!=="AbortError"&&(console.error("Error fetching recently viewed products:",e),!this.isPreviewMode&&this.wrapper&&(this.wrapper.style.display="none"))}}disconnectedCallback(){this.renderTimeout&&clearTimeout(this.renderTimeout),this.abortController&&this.abortController.abort(),window.Shopify.designMode&&document.removeEventListener("shopify:section:load",this.debouncedRenderRecentlyViewedProductsBound)}}customElements.define("recently-viewed-products",RecentlyViewedProducts)}})(); 2//# sourceMappingURL=/cdn/shop/t/35/assets/component-recently-viewed-products.js.map?v=138114961180989057021784636146
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.