1(()=>{if(!customElements.get("custom-pagination")){class CustomPagination extends HTMLElement{constructor(){super(),this.currentPage=2,this.isLoading=!1,this.hasNextPage=!0,this.sectionId=null,this.productGrid=null,this.loadMoreButton=null}connectedCallback(){this.init()}disconnectedCallback(){this.loadMoreButton&&this.loadMoreButton.removeEventListener("click",this.handleLoadMore)}init(){this.setupElements(),this.setupEventListeners()}setupElements(){if(this.productGrid=document.querySelector("#product-grid"),this.productGrid&&(this.sectionId=this.productGrid.dataset.id),this.loadMoreButton=this.querySelector(".load-more, [data-load-more-button]"),!this.productGrid||!this.sectionId){console.warn("Custom Pagination: Product grid or section ID not found");return}}setupEventListeners(){this.loadMoreButton&&(this.handleLoadMore=this.handleLoadMore.bind(this),this.loadMoreButton.addEventListener("click",this.handleLoadMore))}handleLoadMore(event){event.preventDefault(),event.stopPropagation(),!(this.isLoading||!this.hasNextPage)&&(this.loadProducts(),event.target&&event.target.blur())}buildSectionUrl(){const currentUrl=new URL(window.location);return currentUrl.searchParams.set("section_id",this.sectionId),currentUrl.searchParams.set("page",this.currentPage),currentUrl.pathname+currentUrl.search}async loadProducts(){if(!(this.isLoading||!this.hasNextPage)){this.setLoadingState(!0);try{const url=this.buildSectionUrl(),response=await fetch(url);if(!response.ok)throw new Error(`HTTP error! status: ${response.status}`);const responseText=await response.text();this.renderProducts(responseText),this.currentPage++,this.dispatchEvent(new CustomEvent("pagination:page-loaded",{detail:{page:this.currentPage-1,url},bubbles:!0}))}catch(error){console.error("Custom Pagination: Error loading products",error)}finally{this.setLoadingState(!1)}}}renderProducts(html){const doc=new DOMParser().parseFromString(html,"text/html"),newProductGrid=doc.querySelector("#product-grid");if(!newProductGrid){this.hasNextPage=!1,this.hideLoadMoreButton();return}const newProducts=Array.from(newProductGrid.children);if(newProducts.length===0){this.hasNextPage=!1,this.hideLoadMoreButton();return}doc.querySelector("custom-pagination")||(this.hasNextPage=!1),newProducts.forEach(product=>{this.productGrid.appendChild(product)}),this.hasNextPage||this.hideLoadMoreButton(),window.dispatchEvent(new CustomEvent("product-grid:updated",{detail:{productGrid:this.productGrid}}))}setLoadingState(loading){if(this.isLoading=loading,this.loadMoreButton){this.loadMoreButton.disabled=loading,this.loadMoreButton.classList.toggle("loading",loading);const buttonText=this.loadMoreButton.querySelector("span");if(loading)this.loadMoreButton.setAttribute("aria-label","Loading...");else{const originalText=buttonText?buttonText.textContent:"Load more";this.loadMoreButton.setAttribute("aria-label",originalText)}}this.classList.toggle("loading",loading)}hideLoadMoreButton(){this.loadMoreButton&&this.loadMoreButton.classList.add("hidden")}loadMore(){this.loadProducts()}reset(){this.currentPage=2,this.hasNextPage=!0,this.isLoading=!1,this.loadMoreButton&&(this.loadMoreButton.classList.remove("hidden"),this.loadMoreButton.disabled=!1)}}customElements.define("custom-pagination",CustomPagination)}})(); 2//# sourceMappingURL=/cdn/shop/t/3/assets/custom-pagination.js.map?v=22830671684827194381763975864
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.