(function(w){"use strict";var f=f||{};f.init=function(){f.$body=w(document.body),f.$window=w(window),f.$header=w("#site-header");this.singleProductGallery();this.productImageZoom();f.$body.on("ecomus_product_gallery_zoom",function(){f.productImageZoom()});this.productLightBox();this.ecomusMore();this.productTabsDropdown();this.upsellsProductCarousel();this.relatedProductCarousel()};f.productGallery=function(o,t=w(".woocommerce-product-gallery")){if(typeof Swiper==="undefined"){return}var r=w(window);var i=null;var s=null;function n(e,t){if(e.length<1){return}return new Swiper(e.get(0),t)}function e(e){e.enable()}function a(e){e.disable()}function c(e){var t={loop:false,autoplay:false,speed:800,spaceBetween:30,watchOverflow:true,autoHeight:true,navigation:{nextEl:e.find(".swiper-button-next").get(0),prevEl:e.find(".swiper-button-prev").get(0)},on:{init:function(){setTimeout(function(){e.css("opacity",1)},100);f.$body.trigger("ecomus_product_gallery_init")},slideChange:function(){if(this.slides[this.realIndex].getAttribute("data-zoom_status")=="false"){this.$el.parent().addClass("swiper-item-current-extra")}else{if(this.$el.parent().hasClass("swiper-item-current-extra")){this.$el.parent().removeClass("swiper-item-current-extra")}}},slideChangeTransitionEnd:function(){f.$body.trigger("ecomus_product_gallery_slideChangeTransitionEnd")}}};if(s){t.thumbs={swiper:s}}return t}function l(){var e=t.find(".woocommerce-product-gallery__wrapper");e.addClass("woocommerce-product-gallery__slider swiper");e.wrapInner('<div class="swiper-wrapper"></div>');e.find(".swiper-wrapper").after('<span class="ecomus-svg-icon em-button-light ecomus-swiper-button swiper-button swiper-button-prev"><svg width="7" height="11" viewBox="0 0 7 11" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.5 11L0 5.5L5.5 0L6.47625 0.97625L1.9525 5.5L6.47625 10.0238L5.5 11Z" fill="currentColor"/></svg></span>');e.find(".swiper-wrapper").after('<span class="ecomus-svg-icon em-button-light ecomus-swiper-button swiper-button swiper-button-next"><svg width="7" height="11" viewBox="0 0 7 11" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.5 11L7 5.5L1.5 0L0.52375 0.97625L5.0475 5.5L0.52375 10.0238L1.5 11Z" fill="currentColor"/></svg></span>');e.find(".woocommerce-product-gallery__image").addClass("swiper-slide");return n(e,c(e))}function u(t){var e={spaceBetween:10,watchOverflow:true,watchSlidesProgress:true,autoHeight:true,on:{beforeInit:function(){var e=1;t.find(".swiper-slide").each(function(){w(this).parent().find(".swiper-slide:nth-child("+e+")").css("--animation-delay",e*3/10+"s");e++})},init:function(){setTimeout(function(){t.css("opacity",1)},100);f.$body.trigger("ecomus_product_thumbnails_init")}}};if(o){e.breakpoints={0:{direction:"horizontal",slidesPerView:5},1200:{direction:"vertical",slidesPerView:"auto"}}}else{e.direction="horizontal";e.slidesPerView=5}return e}function d(){var e=t.find(".ecomus-product-gallery-thumbnails");e.addClass("swiper");e.wrapInner('<div class="woocommerce-product-thumbnail__nav swiper-wrapper"></div>');e.find(".woocommerce-product-gallery__image").addClass("swiper-slide");return n(e,u(e))}function p(){if(r.width()<1200){e(s);e(i)}else{a(s);a(i)}}function m(){t.imagesLoaded(function(){var e=t.find(".ecomus-product-gallery-thumbnails");e.appendTo(t);s=d();i=l();if(typeof ecomusData.product_gallery_slider!=="undefined"&&!ecomusData.product_gallery_slider){t.addClass("woocommerce-product-gallery--reponsive");p();r.on("resize",function(){p()})}})}m()};f.singleProductGallery=function(){var e=w("div.product .woocommerce-product-gallery");if(!e.length){return}if(e.hasClass("woocommerce-product-gallery--vertical")){w(".woocommerce-product-gallery").on("product_thumbnails_slider_vertical wc-product-gallery-after-init",function(){f.productGallery(true)})}else{f.productGallery(false);w(".woocommerce-product-gallery").on("product_thumbnails_slider_horizontal",function(){f.productGallery(false)})}};f.productImageZoom=function(){if(typeof Drift==="undefined"){return}var e=w(".product-gallery-summary");if(!e){return}if(ecomusData.product_image_zoom=="none"){return}var t=e.find(".entry-summary"),o=e.find(".woocommerce-product-gallery__wrapper");if(ecomusData.product_image_zoom=="bounding"){var r=w('<div class="ecomus-product-zoom-wrapper" />');t.prepend(r)}var i={containInline:true};if(ecomusData.product_image_zoom=="bounding"){i.paneContainer=r.get(0);i.hoverBoundingBox=true;i.zoomFactor=2}if(ecomusData.product_image_zoom=="inner"){i.zoomFactor=3}if(ecomusData.product_image_zoom=="magnifier"){i.zoomFactor=2;i.inlinePane=true}o.find(".woocommerce-product-gallery__image").each(function(){var e=w(this),t=e.find("img"),o=e.find("a").attr("href");if(e.hasClass("ecomus-product-video")||e.data("zoom_status")==false){return}if(ecomusData.product_image_zoom=="inner"){i.paneContainer=e.get(0)}t.attr("data-zoom",o);new Drift(t.get(0),i)});w(".single-product div.product .product-gallery-summary .variations_form").on("show_variation hide_variation",function(){var e=w(this).closest(".product-gallery-summary"),t=e.find(".woocommerce-product-gallery__wrapper .woocommerce-product-gallery__image").eq(0),o=t.find("a").attr("href"),r=t.find("img");r.attr("data-zoom",o)});f.$window.on("resize",function(){if(f.$window.width()<1200){if(!w(".single-product div.product .woocommerce-product-gallery").hasClass("woocommerce-product-gallery--has-zoom")){return}var e=false;w(".woocommerce-product-gallery--has-zoom .woocommerce-product-gallery__image").on("touchstart",function(){e=true});w(".woocommerce-product-gallery--has-zoom .woocommerce-product-gallery__image").on("touchmove",function(){e=false});w(".woocommerce-product-gallery--has-zoom .woocommerce-product-gallery__image").on("touchend",function(){if(e){w(this).addClass("zoom-enable")}else{w(this).removeClass("zoom-enable")}})}})};f.ecomusMore=function(){var e=w(document).find(".short-description__content");e.each(function(){if(jQuery(this)[0].scrollHeight>jQuery(this)[0].clientHeight){jQuery(this).siblings(".short-description__more").removeClass("hidden")}});w(document.body).on("click",".short-description__more",function(e){e.preventDefault();var t=w(this).data("settings"),o=t.more,r=t.less;if(w(this).hasClass("less")){w(this).removeClass("less");w(this).text(o);w(this).siblings(".short-description__content").removeAttr("style")}else{w(this).addClass("less");w(this).text(r);w(this).siblings(".short-description__content").css("-webkit-line-clamp","inherit")}})};f.productLightBox=function(){var e=w(".woocommerce-product-gallery");w(".woocommerce-product-gallery__image").on("click","a",function(e){return false});if(!e){return}if(!ecomusData.product_image_lightbox){return}t();f.$body.on("ecomus_product_gallery_lightbox",function(){t()});w(document).on("click",".ecomus-button--product-lightbox",function(e){e.preventDefault();var t=w(".pswp")[0],o=n(w(this).siblings(".woocommerce-product-gallery__wrapper").find(".woocommerce-product-gallery__image")),r=w(this).siblings(".woocommerce-product-gallery__wrapper").find(".swiper-slide-active");var i=w.extend({index:w(r).index(),addCaptionHTMLFn:function(e,t){if(!e.title){t.children[0].textContent="";return false}t.children[0].textContent=e.title;return true}},wc_single_product_params.photoswipe_options);var s=new PhotoSwipe(t,PhotoSwipeUI_Default,o,i);s.init()});function t(){w(".woocommerce-product-gallery__image").on("click","a",function(e){return false});e.append('<a href="#" class="ecomus-button--product-lightbox em-flex em-flex-align-center em-flex-center"><span class="ecomus-svg-icon ecomus-svg-icon--fullscreen"><svg width="24" height="24" aria-hidden="true" role="img" focusable="false" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M17.672 17.0111L17.672 12.0526L16.4091 12.0526L16.4091 15.4846L11.5285 10.604L10.6352 11.4972L15.5158 16.3778L12.082 16.3796L12.082 17.6425L17.0405 17.6425C17.3878 17.6407 17.6701 17.3584 17.672 17.0111ZM2.48608 16.3778L5.91808 16.3778L5.91808 17.6407L0.961377 17.6425C0.78679 17.6425 0.628951 17.5701 0.515665 17.4568C0.40053 17.3417 0.329985 17.1856 0.329948 17.0111L0.329912 12.0525H1.59277V15.4845L6.47335 10.6039L7.36662 11.4972L2.48604 16.3778L2.48608 16.3778ZM15.514 1.56337H12.082L12.0819 0.300476L17.0405 0.300512C17.1234 0.300625 17.2054 0.317088 17.2819 0.348957C17.3584 0.380826 17.4278 0.427474 17.4862 0.486229C17.6032 0.603249 17.6719 0.764822 17.6719 0.931941L17.6701 5.88864L16.4072 5.88864L16.4072 2.45664L11.5267 7.33722L10.6334 6.44395L15.514 1.56337ZM6.47523 7.33722L7.3685 6.44395L2.48608 1.56152L5.91993 1.56337L5.91808 0.298663L0.961377 0.300512C0.878435 0.300435 0.796292 0.316715 0.719649 0.34842C0.643005 0.380126 0.573367 0.426633 0.514718 0.485282C0.456069 0.543931 0.409562 0.613569 0.377857 0.690212C0.346151 0.766856 0.329871 0.848999 0.329948 0.931941L0.328062 5.88868L1.59277 5.89053L1.59281 2.45479L6.47523 7.33722Z"></path></svg></span></a>')}function n(e){var l=[];if(e.length>0){e.each(function(e,t){var o=w(t).find("img");if(w(t).hasClass("ecomus-product-video")){var r=w(t).find(".ecomus-video-wrapper").html();if(r.length){var i={html:'<div class="pswp__video">'+r+"</div>"};l.push(i)}}else if(o.length){var s=o.attr("data-large_image"),n=o.attr("data-large_image_width"),a=o.attr("data-large_image_height"),c=o.attr("alt"),i={alt:c,src:s,w:n,h:a,title:o.attr("data-caption")?o.attr("data-caption"):o.attr("title")};l.push(i)}})}return l}};f.productTabsDropdown=function(){var e=w(".woocommerce-tabs--dropdown");if(!e){return}if(ecomusData.product_tabs_layout!=="accordion"){return}e.on("click",".woocommerce-tabs-title",function(){if(w(this).hasClass("active")){if(w(this).closest(".woocommerce-tabs--dropdown").hasClass("wc-tabs-first--opened")){w(this).closest(".woocommerce-tabs--dropdown").removeClass("wc-tabs-first--opened")}w(this).removeClass("active");w(this).siblings(".woocommerce-tabs-content").slideUp(200)}else{w(this).addClass("active");w(this).siblings(".woocommerce-tabs-content").slideDown(200)}});w("a.woocommerce-review-link").on("click",function(){w("#tab-reviews .woocommerce-tabs-title:not(.active)").trigger("click")});w(document).ready(function(){if(window.location.href.indexOf("#reviews")>-1){w("#tab-reviews .woocommerce-tabs-title:not(.active)").trigger("click")}})};f.upsellsProductCarousel=function(){var e=ecomusData.upsells_products_columns;f.productsCarousel(w(".products.upsells"),e)};f.relatedProductCarousel=function(){var e=ecomusData.related_products_columns;f.productsCarousel(w(".products.related"),e)};f.productsCarousel=function(s,e){if(!s.length){return}var t=s.find("ul.products");t.wrap('<div class="products-carousel swiper ecomus-carousel--elementor" data-spacing="30"></div>');t.after('<div class="swiper-pagination swiper-pagination-bullet--small"></div>');t.addClass("swiper-wrapper");t.find("li.product").addClass("swiper-slide");if(ecomusData.product_card_hover=="slider"){t.parent().after('<span class="ecomus-svg-icon swiper-button-outline-dark ecomus-swiper-button swiper-button swiper-button-prev"><svg width="7" height="11" viewBox="0 0 7 11" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.5 11L0 5.5L5.5 0L6.47625 0.97625L1.9525 5.5L6.47625 10.0238L5.5 11Z" fill="currentColor"/></svg></span>');t.parent().after('<span class="ecomus-svg-icon swiper-button-outline-dark ecomus-swiper-button swiper-button swiper-button-next"><svg width="7" height="11" viewBox="0 0 7 11" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.5 11L7 5.5L1.5 0L0.52375 0.97625L5.0475 5.5L0.52375 10.0238L1.5 11Z" fill="currentColor"/></svg></span>')}else{t.after('<span class="ecomus-svg-icon swiper-button-light ecomus-swiper-button swiper-button swiper-button-prev"><svg width="7" height="11" viewBox="0 0 7 11" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M5.5 11L0 5.5L5.5 0L6.47625 0.97625L1.9525 5.5L6.47625 10.0238L5.5 11Z" fill="currentColor"/></svg></span>');t.after('<span class="ecomus-svg-icon swiper-button-light ecomus-swiper-button swiper-button swiper-button-next"><svg width="7" height="11" viewBox="0 0 7 11" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M1.5 11L7 5.5L1.5 0L0.52375 0.97625L5.0475 5.5L0.52375 10.0238L1.5 11Z" fill="currentColor"/></svg></span>')}var o=t.closest(".products-carousel"),n=t.find(".product-thumbnail");var r={loop:false,autoplay:false,speed:800,watchSlidesVisibility:true,watchOverflow:true,navigation:{nextEl:s.find(".ecomus-swiper-button.swiper-button-next").get(0),prevEl:s.find(".ecomus-swiper-button.swiper-button-prev").get(0)},pagination:{el:o.find(".swiper-pagination").get(0),type:"bullets",clickable:true},on:{init:function(){this.$el.css("opacity",1)},beforeInit:function(){var i=this;if(n.length>0){n.imagesLoaded(function(){var e=n.outerHeight(),t=s.find("h2").first(),o=e/2;if(ecomusData.product_card_hover==="slider"){s.addClass("em-product-hover--slider");if(t.length){var r=t.outerHeight();o=o+r}}else{o=e/2+15}w(i.navigation.$nextEl).css({"--em-arrow-top":o+"px"});w(i.navigation.$prevEl).css({"--em-arrow-top":o+"px"})})}},resize:function(){var i=this;if(n.length>0){n.imagesLoaded(function(){var e=n.outerHeight(),t=s.find("h2").first(),o=e/2;if(ecomusData.product_card_hover==="slider"){s.addClass("product-hover--slider");if(t.length){var r=t.outerHeight();o=o+r}}else{o=e/2+15}w(i.navigation.$nextEl).css({"--em-arrow-top":o+"px"});w(i.navigation.$prevEl).css({"--em-arrow-top":o+"px"})})}}},spaceBetween:o.data("spacing"),breakpoints:{300:{slidesPerView:e.mobile,slidesPerGroup:2,spaceBetween:15},768:{slidesPerView:e.tablet,spaceBetween:o.data("spacing")},1200:{slidesPerView:e.desktop}}};new Swiper(o.get(0),r)};f.init()})(jQuery);