PageSourceSearch

https://vintagemenuart.com/cdn/shop/t/29/assets/cart-recommendations.js?v=70005626286225720301761600916

js vintagemenuart.com collected 2026-09-24 21:06:51 UTC 3,453 bytes, 2 lines download raw bytes

1/*! Copyright (c) Safe As Milk. All rights reserved. */import Cart from"cart-store";class CartRecommendations extends HTMLElement{async connectedCallback(){this.sectionId=this.getAttribute("section-id"),this.recommendationsAmount=10,this.recommendations=[],this.sectionTitle=this.querySelector("cart-recommendations-title"),this.container=this.querySelector("[cart-recommendations-content]"),this.itemsScroll=this.querySelector("items-scroll"),this.intent=this.getAttribute("product-recommendations-type"),this.cards=Array.from(this.container.children),this.unsubscribe=Cart.subscribe(((state,prevState)=>{const getCartProductsWithoutBeingAdded=(items,productVariantsBeingAdded)=>items.reduce(((ids,item)=>{const id=item.product_id.toString();return productVariantsBeingAdded.includes(item.variant_id.toString())||ids.includes(id)||ids.push(id),ids}),[]),previousFinalCartProductsIds=getCartProductsWithoutBeingAdded(prevState.cart.items,prevState.productVariantsBeingAdded),finalCartProductsIds=getCartProductsWithoutBeingAdded(state.cart.items,state.productVariantsBeingAdded),prepareRecommendations=(recommendationItems,cartProductsIds)=>Object.values(recommendationItems).reduce(((recommendations,value)=>{const weightedRecommendations=value.products.reduce(((uniqueProducts,product,i)=>(!recommendations.find((r=>r.item.id===product.id))&&!cartProductsIds.includes(product.id.toString())&&uniqueProducts.push({weight:(i+1)/value.weight,item:product}),uniqueProducts)),[]);return[...recommendations,...weightedRecommendations]}),[]).sort(((a,b)=>a.weight-b.weight)).slice(0,this.recommendationsAmount),newRecommendations=prepareRecommendations(state.recommendations.items,finalCartProductsIds),oldRecommendations=prepareRecommendations(prevState.recommendations.items,previousFinalCartProductsIds);if(newRecommendations.map((({item})=>item.id)).toString()===oldRecommendations.map((({item})=>item.id)).toString())return;this.recommendations=newRecommendations,this.cards=this.cards.reduce(((newItems,item)=>{const cardProductId=item.getAttribute("product-id");return this.recommendations.find((({item:i})=>i.id.toString()===cardProductId))?(newItems.push(item),newItems):(item.remove(),newItems)}),[]);const currentCardsProductIds=this.cards.map((card=>card.getAttribute("product-id"))),newCards=[];this.recommendations.forEach((({item},i)=>{if(currentCardsProductIds.includes(item.id.toString())){const oldCard=this.cards.find((j=>j.getAttribute("product-id")===item.id.toString()));currentCardsProductIds.indexOf(oldCard.getAttribute("product-id"))!==i&&(i===0?this.container.prepend(oldCard):newCards[i-1].after(oldCard)),newCards.push(oldCard)}else{const newCard=this.#createCard();i===0?this.container.prepend(newCard):newCards[i-1].after(newCard),newCard.sectionId=this.sectionId,newCard.product=item,newCard.id=`cart-recommendation--${item.id}`,newCards.push(newCard)}})),this.cards=newCards,this.itemsScroll&&this.itemsScroll.smoothScrollItems(0),this.recommendations.length>0?this.removeAttribute("hidden"):this.setAttribute("hidden","")})),await Cart.enableCartRecommendations(this.intent)}disconnectedCallback(){this.unsubscribe()}#createCard(){return document.getElementById(`${this.sectionId}--template-cart-recommendations-card`).content.cloneNode(!0).children[0]}}customElements.define("cart-recommendations",CartRecommendations);
2//# sourceMappingURL=/cdn/shop/t/29/assets/cart-recommendations.js.map?v=70005626286225720301761600916

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.