(p=>{p(document).ready(function(){var e,t,h,u,f,i,a,n,o;$makeaholic.isSingle&&"product"===$makeaholic.postType&&"slider"===$makeaholic.productFeatureStyle&&(e=p("#woo-single-info").find(".woo-single-gallery"),t={},e.hasClass("has-thumbs-slider")&&(o=e.children(".makeaholic-thumbs-swiper").MakeaholicSwiper(),t={thumbs:{swiper:o}}),h=e.children(".makeaholic-main-swiper").MakeaholicSwiper(t),u=p(".variations_form"),f=u.data("product_variations"),h)&&h.$wrapperEl&&u.find("select").on("change",function(){if(h&&h.$wrapperEl){for(var e=!0,t=!1,i={},a=u.serializeArray(),n=0;n<a.length;n++){var o=a[n].name;if("attribute_"===o.substring(0,10)&&(i[o]=a[n].value,""===a[n].value)){e=!1;break}}if(!0===e){for(var r=Object.entries(i),s=0,l=0,n=f.length-1;0<=n;n--){var c=f[n],d=Object.entries(c.attributes),m=0;d.forEach(([i,a])=>{r.forEach(([e,t])=>{e!==i||t!==a&&""!==a||m++})}),l<m&&(l=m,s=c.image_id)}s?p(h.$wrapperEl[0]).find(".swiper-slide").each(function(e){var t=p(this).attr("data-image-id");if(parseInt(t)===s)return h.slideTo(e),!1}):t=!0}else t=!0;t&&(t=h.$wrapperEl.find(".product-main-image").index(),h.slideTo(t))}}),p(".quantity-discount-table").on("change",'input[name="quantity_discount"]',function(){var e=p(this).val(),t=p("#woo-single-info"),i=t.find(".quantity .qty");0<t.length&&i.val(e).trigger("change")}),"1"!==$makeaholicWoo.singleProductStickyBar||(i=p("#sticky-product-bar")).length<=0||(i.on("click",".sticky-product-bar-close",function(e){i.addClass("hide")}),a=p(".entry-product form.cart").find(".single_add_to_cart_button").offset().top,n="showing",p(window).on("scroll",function(){var e=p(this).scrollTop();a<e?i.addClass(n):i.removeClass(n)})),(o=p("#commentform")).on("click",".comment-form__attachment-button",function(){p(this).closest(".comment-form").find(".comment-form-attachment__input").trigger("click")}),o.on("change",".comment-form-attachment__input",function(e){var t=p(this).closest(".comment-form").find(".comment-form__attachment-button"),e=this.files&&1<this.files.length?$makeaholicProductSingle.i18n.filesSelected.replace("{count}",this.files.length):e.target.value.split("\\").pop();t.find(".button-text").text(e)}),p(".reviews-summary").on("click",".tm-button",function(e){e.preventDefault();var e=p(this).attr("href"),e=p(e),t=p("#"+e.attr("aria-labelledby")),i=p(".question-form-wrapper, #review_form_wrapper",e),a=p(".question-list-container, .reviews-content",e),e=("none"===e.css("display")?(e.show().siblings(".wc-tab").hide(),t.addClass("active").siblings().removeClass("active"),i.slideDown()):i.slideToggle(),p(".wc-tabs").outerHeight(!0)),t=0,i=0<(i=a.offset().top-e-(t=p(document.body).hasClass("header-sticky-enable")?p("#page-header").outerHeight():t))?i:0;p("html, body").animate({scrollTop:i})})})})(jQuery);