/** Shopify CDN: Minification failed

Line 18:2 Unexpected "constructor("
Line 19:4 Expected identifier but found "super("
Line 21:8 Expected ":"
Line 22:8 Expected ":"
Line 23:8 Expected ":"
Line 24:8 Expected ":"
Line 25:8 Expected ":"
Line 26:8 Expected ":"
Line 27:8 Expected ":"
Line 28:8 Expected ":"
... and 43 more hidden warnings

**/
.m-featured-collection{display:block}.m-featured-collection .m-product-list{position:relative}.m-featured-collection__button{justify-content:center;margin-top:60px}.m-featured-collection__button .m-button.m\:hidden{display:none !important}@media screen and (max-width: 1279px){.m-featured-collection__button{margin-top:40px}}@media screen and (max-width: 767px){.m-featured-collection__button{margin-top:30px}}.m-featured-collection--show-countdown{--color-flash-sale: #C02C30}.bg-dark .m-featured-collection--show-countdown{--color-flash-sale: rgb(var(--bg-white))}.bg-dark .m-featured-collection--show-countdown .m-flashsale-countdown__box{color:rgb(var(--text-black))}.m-featured-collection--show-countdown .m-section__header{display:flex;align-items:flex-end;justify-content:space-between;border-bottom:2px solid var(--color-flash-sale)}.m-featured-collection--show-countdown .m-section__header h2{color:var(--color-flash-sale);font-weight:700}@media screen and (max-width: 767px){.m-featured-collection--show-countdown .m-flashsale-countdown{height:40px;padding:0 5px}.m-featured-collection--show-countdown .m-flashsale-countdown:before{display:none}.m-featured-collection--show-countdown .m-flashsale-countdown__box{font-size:18px;min-width:34px;text-align:center}}.m-flashsale-countdown{display:inline-flex;font-size:26px;font-weight:500;color:#fff;background:var(--color-flash-sale);height:50px;padding:0 10px;align-items:center;position:relative}.m-flashsale-countdown__wrapper{display:flex}.m-flashsale-countdown:before{content:"";width:0;height:0;border-bottom:50px solid var(--color-flash-sale);border-left:25px solid rgba(0,0,0,0);position:absolute;right:100%}.m-flashsale-countdown__box{padding:0 5px;position:relative;min-width:50px;text-align:center}.m-flashsale-countdown__box:after{content:":";position:absolute;right:-5px}.m-flashsale-countdown__box:last-child:after{display:none}
class FeaturedCollection extends HTMLElement {
  constructor() {
    super();
    
    this.enableSlider = this.dataset.enableSlider === 'true';
    this.mobileDisableSlider = this.dataset.mobileDisableSlider === 'true';
    this.showPagination = this.dataset.showPagination === 'true';
    this.showNavigation = this.dataset.showNavigation === 'true';
    this.autoscroll = this.dataset.autoscroll === 'true';
    this.autoscrollSpeed = parseInt(this.dataset.autoscrollSpeed) * 1000 || 5000;
    this.pauseOnHover = this.dataset.pauseOnHover === 'true';
    this.infiniteLoad = this.dataset.infiniteLoad === 'true';
    this.maxPages = parseInt(this.dataset.maxPages) || 3;
    this.buttonType = this.dataset.buttonType;
    this.itemsPerRow = parseInt(this.dataset.items) || 4;
    this.totalPages = parseInt(this.dataset.totalPages) || 1;
    this.currentPage = 1;
    this.isLoading = false;
    this.autoscrollInterval = null;
    
    if (this.enableSlider) {
      this.initSlider();
    }
    
    if (this.buttonType === 'load') {
      this.initLoadMore();
    }
    
    if (this.enableSlider && this.autoscroll) {
      this.initAutoscroll();
    }
  }

  initSlider() {
    const sliderEl = this.querySelector('.swiper-container');
    if (!sliderEl) return;
    
    this.swiper = new Swiper(sliderEl, {
      slidesPerView: 'auto',
      spaceBetween: parseInt(getComputedStyle(this).getPropertyValue('--column-gap')),
      resistanceRatio: 0,
      watchOverflow: true,
      navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev'
      },
      pagination: {
        el: '.swiper-pagination',
        clickable: true
      },
      breakpoints: {
        768: {
          slidesPerView: this.itemsPerRow,
          spaceBetween: parseInt(getComputedStyle(this).getPropertyValue('--column-gap'))
        }
      }
    });
  }

  initAutoscroll() {
    const slider = this.querySelector('.swiper-container');
    if (!slider) return;

    if (this.pauseOnHover) {
      slider.addEventListener('mouseenter', () => {
        this.pauseAutoscroll();
      });
      slider.addEventListener('mouseleave', () => {
        this.resumeAutoscroll();
      });
    }

    this.startAutoscroll();
  }

  startAutoscroll() {
    if (!this.swiper || this.swiper.destroyed) return;
    
    this.autoscrollInterval = setInterval(() => {
      if (this.swiper.isEnd) {
        this.swiper.slideTo(0);
      } else {
        this.swiper.slideNext();
      }
    }, this.autoscrollSpeed);
  }

  pauseAutoscroll() {
    if (this.autoscrollInterval) {
      clearInterval(this.autoscrollInterval);
      this.autoscrollInterval = null;
    }
  }

  resumeAutoscroll() {
    if (!this.autoscrollInterval) {
      this.startAutoscroll();
    }
  }

  initLoadMore() {
    const loadMoreBtn = this.querySelector('[data-load-more]');
    if (!loadMoreBtn) return;
    
    loadMoreBtn.addEventListener('click', () => {
      if (this.isLoading || this.currentPage >= this.totalPages || this.currentPage >= this.maxPages) return;
      
      this.isLoading = true;
      loadMoreBtn.classList.add('m-spinner-button--loading');
      
      this.currentPage++;
      const url = `${this.dataset.url}?page=${this.currentPage}`;
      
      fetch(url)
        .then(response => response.text())
        .then(text => {
          const html = new DOMParser().parseFromString(text, 'text/html');
          const newProducts = html.querySelector('[data-products-container]').innerHTML;
          const productsContainer = this.querySelector('[data-products-container]');
          
          productsContainer.insertAdjacentHTML('beforeend', newProducts);
          
          if (this.enableSlider) {
            this.swiper.update();
          }
          
          if (this.currentPage >= this.totalPages || this.currentPage >= this.maxPages) {
            loadMoreBtn.style.display = 'none';
          }
        })
        .catch(error => {
          console.error('Error loading more products:', error);
        })
        .finally(() => {
          this.isLoading = false;
          loadMoreBtn.classList.remove('m-spinner-button--loading');
        });
    });
  }

  disconnectedCallback() {
    this.pauseAutoscroll();
    if (this.swiper) {
      this.swiper.destroy();
    }
  }
}

customElements.define('m-featured-collection', FeaturedCollection);