import Swiper from 'swiper';
import SwiperCore, { Navigation, Pagination, Autoplay } from 'swiper/core';
SwiperCore.use([Navigation, Pagination, Autoplay]);

export default () => {

  const blocks = document.querySelectorAll('.muy-slider');
  blocks.forEach(block => {
    const slider = $(block).find('.swiper');
    const slideToShow = slider.data('slide-to-show');
    const autoplay = slider.data('autoplay');
    const pause = slider.data('pause');
    const autoplaySpeed = slider.data('autoplay-speed');
    const infiniteLoop = slider.data('loop');
    const autoHeight = slider.data('auto-height');

    const swiper = new Swiper(slider[0], {
      pagination: true,
      modules: [Navigation, Pagination, Autoplay],
      pagination: {
        el: block.querySelector('.swiper-pagination'),
        clickable: true,
      },
      navigation: {
        nextEl: block.querySelector('.swiper-next'),
        prevEl: block.querySelector('.swiper-prev'),
      },
      autoplay: {
        delay: autoplaySpeed,
      },
      slidesPerView: slideToShow ? slideToShow : 1,
      autoplay: autoplay ? true : false,
      loop: infiniteLoop ? true : false,
      pauseOnMouseEnter: pause ? true : false,
      autoHeight: autoHeight == true ? true : false,
      allowTouchMove: true,
      draggable: true,
    });
  });
}