text: (function ($) {
      "use strict";
      /* Preloader */
      $(window).on('load', function () {
          let preloaderFadeOutTime = 500;
  
          function hidePreloader() {
              var preloader = $('.spinner-wrapper');
              setTimeout(function () {
                  preloader.fadeOut(preloaderFadeOutTime);
              }, 500);
          }
  
          hidePreloader();
      });
  
      // Time line fill
      function timelineFiller() {
          // Time line fill
          if ($("#booking-timeline").length > 0) {
              if ($("#booking-shipping").is(":visible") || $(window).scrollTop() >= $('#booking-shipping').offset().top - $('.admin-sbmn-container').outerHeight() - $('#booking-timeline').outerHeight() - 50) {
  
                  $('#booking-timeline-step-shipping .booking-timeline-line').addClass('booking-timeline-line-filled');
              } else {
                  $('#booking-timeline-step-shipping .booking-timeline-line').removeClass('booking-timeline-line-filled');
              }
  
              if ($("#booking-options").is(":visible") || $(window).scrollTop() >= $('#booking-options').offset().top - $('.admin-sbmn-container').outerHeight() - $('#booking-timeline').outerHeight() - 50) {
                  $('#booking-timeline-step-options .booking-timeline-line').addClass('booking-timeline-line-filled');
              } else {
                  $('#booking-timeline-step-options .booking-timeline-line').removeClass('booking-timeline-line-filled');
              }
          }
      }
  
      timelineFiller();
      // Scroll event
      $(window).on('scroll load', function () {
          timelineFiller();
          if ($(".navbar").length > 0) {
              if ($(".navbar").offset().top > 60) {
                  $(".fixed-top").addClass("top-nav-collapse");
              } else {
                  $(".fixed-top").removeClass("top-nav-collapse");
              }
          }
  
          /* Admin header when scroll on mobile*/
          if ($('body').width() <= 768 && $(".admin-sbmn-container").length > 0) {
              if ($(window).scrollTop() >= $('.admin-header').outerHeight()) {
                  $(".admin-sbmn-container").css({"position": "fixed", "top": "0"});
              } else {
                  $(".admin-sbmn-container").css({
                      "position": "fixed",
                      "top": "" + ($('.admin-header').outerHeight() - $(window).scrollTop()) + "px"
                  });
              }
              // Booking steps
              if ($(window).scrollTop() >= $('.admin-header').outerHeight()) {
                  $("#booking-timeline").css({
                      "position": "fixed",
                      "paddingTop": "10px",
                      "top": $('.admin-sbmn-mobile').outerHeight()
                  });
                  $("#booking-main").css({
                      "marginTop": $("#booking-timeline").outerHeight()
                  });
              } else {
                  $("#booking-timeline").css({
                      "position": "relative",
                      'top': 0,
                      "paddingTop": "0",
                  });
                  $("#booking-main").css({
                      "marginTop": 0,
                  });
              }
          } else {
              // Booking steps
              if ($(window).scrollTop() >= $('.admin-header').outerHeight()) {
                  $("#booking-timeline").css({
                      "position": "fixed",
                      "width": "calc(100% / 12 * 10)",
                      "top": 0
                  });
              } else {
                  $("#booking-timeline").css({
                      "position": "fixed",
                      "width": "calc(100% / 12 * 10)",
                      "top": $('.admin-header').outerHeight() - $(window).scrollTop()
                  });
              }
          }
      });
  
      // jQuery for page scrolling feature - requires jQuery Easing plugin
      $(function () {
          $(document).on('click', 'a.page-scroll', function (event) {
              let anchor = $(this).attr('href').substring($(this).attr('href').indexOf("#") + 1);
              $('html, body').stop().animate({
                  scrollTop: $('#' + anchor).offset().top - 30
              }, 600, 'easeInOutExpo');
              event.preventDefault();
          });
  
          $(document).on('click', 'a.booking-timeline-scroll', function (event) {
              let anchor = $(this).attr('href').substring($(this).attr('href').indexOf("#") + 1);
              $('html, body').stop().animate({
                  scrollTop: $('#' + anchor).offset().top - $(".admin-sbmn-container").outerHeight() - $(".admin-header").outerHeight() - 35
              }, 600, 'easeInOutExpo');
              event.preventDefault();
          });
      });
  
      // closes the responsive menu on menu item click
      $(".navbar-nav li a").on("click", function (event) {
          if (!$(this).parent().hasClass('dropdown'))
              $(".navbar-collapse").collapse('hide');
      });
  
      /* Card Slider - Swiper */
      var cardSlider = new Swiper('.card-slider', {
          autoplay: {
              delay: 8000,
              disableOnInteraction: true
          },
          loop: true,
          navigation: {
              nextEl: '.swiper-button-next',
              prevEl: '.swiper-button-prev'
          }
      });
  
  
      /* Video Lightbox - Magnific Popup */
      $('.popup-youtube, .popup-vimeo').magnificPopup({
          disableOn: 700,
          type: 'iframe',
          mainClass: 'mfp-fade',
          removalDelay: 160,
          preloader: false,
          fixedContentPos: false,
          iframe: {
              patterns: {
                  youtube: {
                      index: 'youtube.com/',
                      id: function (url) {
                          var m = url.match(/[\\?\\&]v=([^\\?\\&]+)/);
                          if (!m || !m[1]) return null;
                          return m[1];
                      },
                      src: 'https://www.youtube.com/embed/%id%?autoplay=1'
                  },
                  vimeo: {
                      index: 'vimeo.com/',
                      id: function (url) {
                          var m = url.match(/(https?:\/\/)?(www.)?(player.)?vimeo.com\/([a-z]*\/)*([0-9]{6,11})[?]?.*/);
                          if (!m || !m[5]) return null;
                          return m[5];
                      },
                      src: 'https://player.vimeo.com/video/%id%?autoplay=1'
                  }
              }
          }
      });
  
  
      /* Lightbox - Magnific Popup */
      $('.popup-with-move-anim').magnificPopup({
          type: 'inline',
          fixedContentPos: false, /* keep it false to avoid html tag shift with margin-right: 17px */
          fixedBgPos: true,
          overflowY: 'auto',
          closeBtnInside: true,
          preloader: false,
          midClick: true,
          removalDelay: 300,
          mainClass: 'my-mfp-slide-bottom'
      });
  
  
      /* Back To Top Button */
      /*
      $('body').prepend('<a href="#header" class="back-to-top page-scroll">Back to Top</a>');
      var amountScrolled = 700;
      $(window).scroll(function () {
          if ($(window).scrollTop() > amountScrolled) {
              $('a.back-to-top').fadeIn('500');
          } else {
              $('a.back-to-top').fadeOut('500');
          }
      });
      */
  
      /* Removes Long Focus On Buttons */
      $(".button, a, button").mouseup(function () {
          $(this).blur();
      });
  
      /* JS cho menu*/
      $('.admin-sbmn-item-opening').find(".fa-angle-left").removeClass("fa-angle-left").addClass("fa-angle-down");
      $('.admin-sbmn-item-opening').next('.admin-sbmn-item-ul').css({"height": "" + $('.admin-sbmn-item-ul[data-opening=yes] li').length * Math.max(34, $('.admin-sbmn-item-ul li').outerHeight()) + "px"});
  
      $('.admin-dropdown-toggle').click(function (event) {
          event.preventDefault();
          if ($(this).hasClass('admin-sbmn-item-selecting')) {
              $(this).removeClass("admin-sbmn-item-selecting");
              $('.admin-sbmn-item-ul').attr("data-opening", "no").animate({"height": "0"}, 200, "swing");
              $(".fa-angle-down").removeClass("fa-angle-down").addClass("fa-angle-left");
              return;
          }
          $('.admin-dropdown-toggle').removeClass("admin-sbmn-item-selecting");
          $('.admin-dropdown-toggle .fa-angle-down').removeClass("fa-angle-down").addClass("fa-angle-left");
          $(this).addClass("admin-sbmn-item-selecting");
          $(this).find(".fa-angle-left").removeClass("fa-angle-left").addClass("fa-angle-down");
  
          $('.admin-sbmn-item-ul').attr("data-opening", "no").animate({"height": "0"}, 200, "swing");
          $(this).next('.admin-sbmn-item-ul').attr("data-opening", "yes").animate({"height": "" + $('.admin-sbmn-item-ul[data-opening=yes] li').length * Math.max(34, $('.admin-sbmn-item-ul li').outerHeight()) + "px"}, 100, "swing");
      });
  
      /* Nếu trên mobile, click ra ngoài thì ẩn dropdown menu */
      $('body').on('click', '.admin-content', function () {
          if ($(this).width() <= 768) {
              $('.admin-dropdown-toggle').removeClass("admin-sbmn-item-selecting");
              $('.admin-dropdown-toggle .fa-angle-down').removeClass("fa-angle-down").addClass("fa-angle-left");
              $('.admin-sbmn-item-ul').attr("data-opening", "no").animate({"height": "0"}, 100, "swing");
          }
      });
  
      /* Countdown */
      setInterval(function () {
          let end_time = 1588895999;
          let now = Math.floor(Date.now() / 1000);
          if (now <= end_time) {
              let time_left = end_time - now;
              $('#countdown .days span').text(parseInt(time_left / (24 * 60 * 60)));
              time_left = time_left % (24 * 60 * 60);
  
              $('#countdown .hours span').text(parseInt(time_left / (60 * 60)));
              time_left = time_left % (60 * 60);
  
              $('#countdown .mins span').text(parseInt(time_left / (60)));
              time_left = time_left % (60);
  
              $('#countdown .seconds span').text(time_left);
          }
      }, 1000);
  
  
      document.addEventListener('lazybeforeunveil', function (e) {
          var bg = e.target.getAttribute('data-bg');
          if (bg) {
              e.target.style.backgroundImage = 'url(' + bg + ')';
          }
      });
  
      $('.buy-package').click(function (e) {
          e.preventDefault();
          let package_id = $(this).attr('data-package');
  
          $.get("https://shopee.sale/mua-goi-dat-don/" + package_id, function (response) {
              Swal.fire({
                  icon: response.status,
                  html: response.message,
              }).then(function () {
                  if (response.url_to_redirect != undefined) {
                      window.location.href = response.url_to_redirect;
                  }
              });
          });
      });
  })(jQuery);
  