jQuery(function(c){"use strict";var s=c(ywdpd_qty_args.column_product_info_class).find(ywdpd_qty_args.product_price_classes).html(),a=function(){var t;"yes"==ywdpd_qty_args.is_default_qty_enabled&&(t=c(document).find("#ywdpd-table-discounts"),("yes"===ywdpd_qty_args.show_minimum_price?t.find("td.qty-price-info").last():t.find("td.qty-price-info").first()).click())},r=function(t,d,a){t=t.find(".woocommerce-Price-amount.amount"),d=c(d).html(),a=c(a).html();c(ywdpd_qty_args.column_product_info_class).find(".woocommerce-variation-price").length?(t=c(ywdpd_qty_args.column_product_info_class).find(".woocommerce-variation-price").find(".woocommerce-Price-amount.amount")).length&&t.each(function(){c(this).parent("del").length?c(this).html(d):c(this).html(a)}):t.length&&t.each(function(){c(this).parent("del").length?c(this).html(d):c(this).html(a)})},i=function(t){var d=t.html(),a="*"==t.data("qtymax")||ywdpd_qty_args.select_minimum_quantity?t.data("qtymin"):t.data("qtymax"),i=t.closest(ywdpd_qty_args.column_product_info_class).find(ywdpd_qty_args.product_qty_classes),n="",e=(n=c(ywdpd_qty_args.column_product_info_class).find(".woocommerce-variation-price").length?c(ywdpd_qty_args.column_product_info_class).find(".woocommerce-variation-price").find(".price"):t.closest(ywdpd_qty_args.column_product_info_class).find(ywdpd_qty_args.product_price_classes)).find("del").length?n.find("del").html():"",s=t.index(),o=!1;c("td").removeClass("ywdpd_qty_active"),o="horizontal"===ywdpd_qty_args.template?(o=c(document).find("#ywdpd-table-discounts td.qty-info").get(s-1),c(o)):t.parent().find("td.qty-info"),t.addClass("ywdpd_qty_active"),o&&c(o).addClass("ywdpd_qty_active"),i.val(a),r(n,e,d)};c(document).on("click","#ywdpd-table-discounts td.qty-price-info",function(t){var d=c(this);i(d)}),c(document).on("click","#ywdpd-table-discounts td.qty-info",function(t){!function(t){var d=t.index();c("td.qty-info").removeClass("ywdpd_qty_active"),t.addClass("ywdpd_qty_active");var a=!1;(a="horizontal"===ywdpd_qty_args.template?(a=c(document).find("#ywdpd-table-discounts td.qty-price-info").get(d-1),c(a)):t.parent().find("td.qty-price-info"))&&i(a)}(c(this))}),c(document).on("change","form.cart .qty",function(t){var d,a,i,n,e;c(document).find("#ywdpd-table-discounts").length&&"yes"==ywdpd_qty_args.is_change_qty_enabled&&(d=c(this).val(),a=n=!1,0<parseInt(d)&&(c("#ywdpd-table-discounts td.qty-info").removeClass("ywdpd_qty_active"),c("#ywdpd-table-discounts td.qty-price-info").removeClass("ywdpd_qty_active"),"horizontal"===ywdpd_qty_args.template?(n=c("#ywdpd-table-discounts").find("td.qty-info").filter(function(){return"*"!==c(this).data("qtymax")?c(this).data("qtymin")<=d&&c(this).data("qtymax")>=d:c(this).data("qtymin")<=d})).length?(i=n.index(),a=c("#ywdpd-table-discounts td.qty-price-info").get(i-1),a=c(a)):n=!1:n=!!(a=c("#ywdpd-table-discounts").find("td.qty-price-info").filter(function(){return"*"!==c(this).data("qtymax")?c(this).data("qtymin")<=d&&c(this).data("qtymax")>=d:c(this).data("qtymin")<=d})).length&&a.parent().find("td.qty-info"),n?(n.addClass("ywdpd_qty_active"),a.addClass("ywdpd_qty_active"),n=(i=a.closest(ywdpd_qty_args.column_product_info_class).find(ywdpd_qty_args.product_price_classes)).find("del").length?i.find("del").html():"",e=a.html(),r(i,n,e)):(c("ywdpd-table-discounts").find("tr,td").removeClass("ywdpd_qty_active"),c(ywdpd_qty_args.column_product_info_class).find(ywdpd_qty_args.product_price_classes).html(s),""!==(e=c(".ywdpd-table-discounts-wrapper").data("default_variation_price_html"))&&void 0!==e&&c(ywdpd_qty_args.column_product_info_class).find(".woocommerce-variation-price").length&&c(ywdpd_qty_args.column_product_info_class).find(".woocommerce-variation-price").html(e))))});var t=c('[name|="product_id"]'),d=(t.val(),c('[name|="variation_id"]')),t=t.closest("form"),n=!1,n=c(".ywdpd-table-discounts-wrapper-sh").length?c(".ywdpd-table-discounts-wrapper-sh"):c(".ywdpd-table-discounts-wrapper");if(c(ywdpd_qty_args.variation_form_class).on("found_variation",t,function(t,d){(c(".ywdpd-table-discounts-wrapper-sh").length?c(".ywdpd-table-discounts-wrapper-sh"):c(".ywdpd-table-discounts-wrapper")).replaceWith(d.table_price),c(".ywdpd-table-discounts-wrapper").data("default_variation_price_html",d.price_html),a()}),!d.length)return a(),!1;d.on("change",function(){""==c(this).val()&&((c(".ywdpd-table-discounts-wrapper-sh").length?c(".ywdpd-table-discounts-wrapper-sh"):c(".ywdpd-table-discounts-wrapper")).replaceWith(n),c(".ywdpd-table-discounts-wrapper").data("default_variation_price_html",""))})});