1import"@archetype-themes/scripts/config";if(theme.recentlyViewedIds=[],theme.config.hasLocalStorage){const recentIds=window.localStorage.getItem("recently-viewed");recentIds&&typeof recentIds!==void 0&&(theme.recentlyViewedIds=JSON.parse(recentIds))}class RecentlyViewed extends HTMLElement{constructor(){super(),this.initialized=!1,this.container=this,this.sectionId=this.container.getAttribute("data-section-id"),this.maxProducts=this.container.getAttribute("data-max-products"),this.init(),document.dispatchEvent(new CustomEvent("recently-viewed:loaded",{detail:{sectionId:this.sectionId}}))}addIdToRecentlyViewed(id){id&&(theme.recentlyViewedIds.includes(id)&&theme.recentlyViewedIds.splice(theme.recentlyViewedIds.indexOf(id),1),theme.recentlyViewedIds.unshift(id),theme.config.hasLocalStorage&&window.localStorage.setItem("recently-viewed",JSON.stringify(theme.recentlyViewedIds)))}init(){if(this.addIdToRecentlyViewed(this.dataset.productId),this.initialized)return;if(this.initialized=!0,!theme.recentlyViewedIds.length){this.container.classList.add("hide");return}this.outputContainer=this.container.querySelector(`#RecentlyViewed-${this.sectionId}`);const currentId=this.container.getAttribute("data-product-id");let url=`${theme.routes.search}?view=recently-viewed&type=product&q=`,products="",i=0;theme.recentlyViewedIds.forEach(val=>{val!==currentId&&(i>=this.maxProducts||(products+=`id:${val} OR `,i++))}),url=url+encodeURIComponent(products),fetch(url).then(response=>response.text()).then(text=>{const html=document.createElement("div");if(html.innerHTML=text,html.querySelectorAll(".grid-product").length>0){const results=html.querySelector(".product-grid");this.outputContainer.append(results)}else this.container.classList.add("hide")}).catch(e=>{console.error(e)})}disconnectedCallback(){this.initialized=!1}}customElements.define("recently-viewed",RecentlyViewed); 2//# sourceMappingURL=/cdn/shop/t/118/assets/section-recently-viewed.js.map?v=173223767998598904081791017970
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.