(function ($) {
  "use strict";

  // Scroll Animations
  const online_book_printing_observer = new IntersectionObserver((entries) => {
    entries.forEach((entry) => {
      if (entry.isIntersecting) {
        entry.target.classList.add('animations-show-item');
        online_book_printing_observer.unobserve(entry.target);
      } else {
        entry.target.classList.remove('animations-show-item');
      }
    });
  });

  const online_book_printing_hiddenElements = document.querySelectorAll('.animations-hidden-item');
  online_book_printing_hiddenElements.forEach((el) =>
    online_book_printing_observer.observe(el)
  );

  // Slider
  $(document).ready(function () {
    let online_book_printing_swiper = new Swiper(".mySwiper", {
      loop: true,
      spaceBetween: 15,
      slidesPerView: 3.5,
      autoplay: true,
      breakpoints: {
	      0: {
	        slidesPerView: 1,
	      },
	      768: {
	        slidesPerView: 2.3,
	      },
	      992: {
	        slidesPerView: 2.5,
	      },
	      1200: {
	        slidesPerView: 3.5,
	      }
	    },
      pagination: {
        el: ".swiper-pagination",
        type: "progressbar"
      },

      navigation: {
        nextEl: ".swiper-button-next",
        prevEl: ".swiper-button-prev"
      },

      on: {
        init: function () {
          online_book_printing_updateSlideNumber(this);
        },
        slideChange: function () {
          online_book_printing_updateSlideNumber(this);
        }
      }
    });

    function online_book_printing_updateSlideNumber(swiper) {
      let online_book_printing_current = swiper.realIndex + 1;
      $('.current-slide').text(online_book_printing_current.toString().padStart(2, '0'));
    }
  });

  // Book Slider
  $(document).ready(function () {
    const online_book_printing_swiper = new Swiper(".mySwiper1", {
      spaceBetween: 25,
      centeredSlides: true,
      loop: true,
      breakpoints: {
        0: {
          slidesPerView: 1,
        },
        768: {
          slidesPerView: 3,
        },
        992: {
          slidesPerView: 5,
        }
      },
      autoplay: true,
      speed: 600,
      slidesPerGroup: 1,
      watchSlidesProgress: true,
    });
  });
})(jQuery);