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