if(!customElements.get("collection-view")){class CollectionView extends HTMLElement{constructor(){super(),this.setInitialStates(),this.addEventListener("click",e=>{if(!e.target.classList.contains("js-btn"))return;const productGrid=document.querySelector("#product-grid");if(!productGrid)return;const btnTarget=e.target,btnSelected=this.querySelector(".js-btn[disabled]");this.updateStates(btnTarget,btnSelected,productGrid),!Shopify.designMode&&localStorage.setItem("collection-grid-cols",btnTarget.dataset.cols)})}setInitialStates(){const storedCols=localStorage.getItem("collection-grid-cols");if(Shopify.designMode||!storedCols)return;const productGrid=document.querySelector("#product-grid");if(!productGrid||productGrid.dataset.cols===storedCols)return;const newBtn=this.querySelector(`.js-btn[data-cols="${storedCols}"]`),btnSelected=this.querySelector(".js-btn[disabled]");this.updateStates(newBtn,btnSelected,productGrid)}updateStates(newBtn,initialBtn,productGrid){newBtn.setAttribute("disabled",!0),initialBtn.removeAttribute("disabled"),productGrid.dataset.cols=newBtn.dataset.cols,this.updateGridItems()}updateGridItems(){const collectionLoadMore=document.querySelector("collection-load-more");collectionLoadMore&&collectionLoadMore.toggleProductsVisibility()}}customElements.define("collection-view",CollectionView)}
//# sourceMappingURL=/cdn/shop/t/12/assets/collection-view.js.map?v=98302299362333455091682758930
