1(function(){"use strict";const CONFIG=window.FilterUtils?.CONFIG,Utils=window.FilterUtils?.Utils,AjaxHandler=window.AjaxHandler;if(!CONFIG||!Utils||!AjaxHandler){console.error("[filter-ajax.js] Dependencies not found. Ensure collection-filter.js is loaded first.");return}const AjaxFilter={init(){!this.debouncedFetchHandler&&Utils&&(this.debouncedFetchHandler=Utils.debounce(href=>{AjaxFilter.handleFilterWithFetch(href)},200))},bindEvents(){},handleFilterTagClick(link){const href=link.getAttribute("href");this.debouncedFetchHandler?this.debouncedFetchHandler(href):this.handleFilterWithFetch(href)},debouncedFetchHandler:null,async handleFilterWithFetch(href){try{const result=await AjaxHandler.getFilteredContent(href);if(result)window.history.replaceState(null,null,href),await this.updateContentOptimized(result),requestAnimationFrame(()=>{this.reinitializeComponents(),typeof window.LoadingManager<"u"&&window.LoadingManager.hideCollectionLoading(),href&&(href.includes("page=")||typeof URL<"u"&&new URL(href,window.location.origin).searchParams.has("page"))&&window.scrollTo({top:0,behavior:"smooth"}),document.dispatchEvent(new CustomEvent("filterContentLoaded",{detail:{url:href,result}}))});else throw new Error("No content received from server")}catch(error){Utils.error("Failed to load filter results:",error),typeof window.LoadingManager<"u"&&window.LoadingManager.hideCollectionLoading(),(!navigator.onLine||error.message.includes("HTTP 5"))&&(window.location.href=href)}},async updateContentOptimized(result){try{if(result.collection){const existingCollection=document.querySelector(".collection");existingCollection&&Utils.updateDOMEfficiently(existingCollection,result.collection.innerHTML)}if(result.products){const grid=document.getElementById("ProductGridContainer"),existingProducts=grid&&(grid.querySelector(".collection__main")||grid.querySelector(".collection .product-list")||grid.querySelector(".collection__products"))||document.querySelector("#ProductGridContainer .collection__main")||document.querySelector(".collection__main")||document.querySelector(".collection .product-list:not(.product-list--carousel)")||document.querySelector(".collection__products");if(existingProducts)Utils.updateDOMEfficiently(existingProducts,result.products.innerHTML);else{const collectionEl=grid&&grid.querySelector(".collection")||document.querySelector(".collection.filter-transition-fast")||document.querySelector(".collection");if(collectionEl){const wrapper=document.createElement("div");wrapper.className="collection__main",wrapper.innerHTML=result.products.innerHTML,collectionEl.innerHTML="",collectionEl.appendChild(wrapper),typeof console<"u"&&console.log&&console.log("[Filter OR] Replaced .collection content with product grid at:",collectionEl)}else if(grid){const main=document.createElement("div");main.className="collection__main",main.innerHTML=result.products.innerHTML;const hero=grid.querySelector(".collection-hero-top");hero&&hero.nextElementSibling?grid.insertBefore(main,hero.nextElementSibling):grid.appendChild(main),typeof console<"u"&&console.log&&console.log("[Filter OR] Appended .collection__main to #ProductGridContainer (no .collection found)")}else typeof console<"u"&&console.warn&&console.warn("[Filter OR] No target: looked for #ProductGridContainer .collection, .collection")}}if(result.filters){const existingFilters=document.querySelector(".collection-filter");existingFilters&&(typeof window.AccordionManager<"u"&&window.AccordionManager.saveAccordionStates(),Utils.updateDOMEfficiently(existingFilters,result.filters.innerHTML),requestAnimationFrame(()=>{typeof window.AccordionManager<"u"&&window.AccordionManager.restoreAccordionStates()}))}if(result.pagination&&result.pagination.innerHTML){const existingPagination=(document.getElementById("ProductGridContainer")||document).querySelector(".collection__main .pagination, .collection__main [data-pagination], .pagination, [data-pagination]");if(existingPagination){let paginationHTML=result.pagination.innerHTML;if(existingPagination.tagName==="NAV"&&/^\s*<nav[\s>]/i.test(paginationHTML)){const innerMatch=paginationHTML.match(/<nav[^>]*>([\s\S]*?)<\/nav>\s*$/i);innerMatch&&(paginationHTML=innerMatch[1])}Utils.updateDOMEfficiently(existingPagination,paginationHTML)}}
1if(result.productCount){const existingCount=document.querySelector(".collection-header__count, [data-product-count]");existingCount&&(existingCount.textContent=result.productCount.textContent)}}catch(error){Utils.error("Error updating content optimally:",error),this.updateContent(result.html)}},updateContent(data){const tempDiv=document.createElement("div");tempDiv.innerHTML=data;const newProductList=tempDiv.querySelector(".collection .collection__main")||tempDiv.querySelector(".product-list")||tempDiv.querySelector('[id*="product-list"]')||tempDiv.querySelector(".collection__products-wrapper .collection"),newFilter=tempDiv.querySelector(".collection-filter"),existingProductList=document.querySelector(".collection .collection__main")||document.querySelector(".product-list")||document.querySelector('[id*="product-list"]'),existingFilter=document.querySelector(".collection-filter");if(newProductList&&existingProductList)existingProductList.innerHTML="",existingProductList.innerHTML=newProductList.innerHTML,existingProductList.style.opacity="1",existingProductList.style.transition="none",existingProductList.style.transform="none",existingProductList.offsetHeight,this.waitForContentLoad(existingProductList);else{Utils.error("Failed to find product content in new or existing DOM");const newCollection=tempDiv.querySelector(".collection"),existingCollection=document.querySelector(".collection");newCollection&&existingCollection&&(existingCollection.innerHTML=newCollection.innerHTML,this.waitForContentLoad(existingCollection))}if(newFilter&&existingFilter){const loadingOverlay=existingFilter.querySelector(".filter-loading-overlay");existingFilter.innerHTML=newFilter.innerHTML,loadingOverlay&&existingFilter.insertBefore(loadingOverlay,existingFilter.firstChild)}},waitForContentLoad(container){const images=container.querySelectorAll("img"),totalImages=images.length;let loadedImages=0,contentLoadTimeout;const progressIndicator=document.getElementById("loading-progress"),dispatchContentLoaded=()=>{contentLoadTimeout&&clearTimeout(contentLoadTimeout),progressIndicator&&(progressIndicator.textContent="");const event=new CustomEvent("contentLoaded");document.dispatchEvent(event)};if(totalImages===0){requestAnimationFrame(dispatchContentLoaded);return}const checkImageLoaded=()=>{loadedImages++,loadedImages>=totalImages&&requestAnimationFrame(dispatchContentLoaded)};images.forEach((img,index)=>{img.complete&&img.naturalWidth>0?checkImageLoaded():(img.addEventListener("load",checkImageLoaded,{once:!0}),img.addEventListener("error",()=>{checkImageLoaded()},{once:!0}))}),contentLoadTimeout=setTimeout(()=>{dispatchContentLoaded()},4e3)},reinitializeComponents(options={}){const main=document.querySelector(CONFIG.selectors.collectionMain);main&&main.classList.remove("updating");const showFilterBtn=document.getElementById("show_filter");if(showFilterBtn&&showFilterBtn.classList.remove("opacity-low"),typeof window.AccordionManager<"u"&&(window.AccordionManager.restoreAccordionStates(),window.AccordionManager.bindAccordionEvents()),typeof window.FilterSelectionManager<"u"&&(options.skipFilterStateSync||window.FilterSelectionManager.initializeAppliedFilters(),window.FilterSelectionManager.updateApplyButton()),requestAnimationFrame(()=>{typeof window.SelectedFiltersManager<"u"&&window.SelectedFiltersManager.updateDisplay()}),typeof window.filterBar=="function"&&window.filterBar(),typeof $<"u"&&typeof $.fn.slick<"u"){const filterBar=$(".filter-bar");filterBar.hasClass("slick-initialized")&&filterBar.slick("unslick"),window.innerWidth<=700&&requestAnimationFrame(()=>{typeof window.slickslider=="function"?window.slickslider():filterBar.slick({slidesToShow:2,dots:!0,mobileFirst:!0,prevArrow:'<button class="slick-arrow slick-prev" aria-label="Previous filter"><svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 36 36" fill="none"><circle cx="18" cy="18" r="18" fill="#FFFFFF"></circle><path d="M21 12L13 18.5L21 25" stroke="#B6637B" stroke-width="3" stroke-linecap="round"></path></svg></button>',nextArrow:'<button class="slick-arrow slick-next" aria-label="Next filter"><svg xmlns="http://www.w3.org/2000/svg" width="23" height="23" viewBox="0 0 36 36" fill="none"><circle cx="18" cy="18" r="18" fill="#FFFFFF"></circle><path d="M21 12L13 18.5L21 25" stroke="#B6637B" stroke-width="3" stroke-linecap="round"></path></svg></button>',responsive:[{breakpoint:768,settings:"unslick",slidesToShow:2}]})})}}};window.AjaxFilter=AjaxFilter,document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{typeof window.CollectionFilterSystem<"u"}):typeof window.CollectionFilterSystem<"u"})(); 2//# sourceMappingURL=/cdn/shop/t/558/assets/filter-ajax.js.map?v=56609103870017740341780602937
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.