(()=>{var e,o;e=jQuery,o={init:function(){e("body").on("click","a#dokan-become-wholesale-customer-btn",this.makeWholesaleCustomer),e("input[name=variation_id]").on("change",this.triggerVariationWholesale),e(".dokan-wholesale-options").on("change",".wholesaleCheckbox",this.toggleWholesaleWrapper),e("body").on("change",".dokan-variation-wholesale .wholesaleCheckbox",this.toggleWholesaleVariationWrapper)},triggerVariationWholesale:function(o){o.preventDefault();const a=e(".variations_form").data("product_variations"),i=e("input[name=variation_id]").val();setTimeout(()=>{for(let s=0;s<a.length;s++)if(a[s].variation_id==i){const i=a[s];if(DokanWholesale.check_permission)if("yes"==i._enable_wholesale){var o=DokanWholesale.variation_wholesale_string.wholesale_price+": <strong>"+DokanWholesale.currency_symbol+i._wholesale_price+"</strong> ("+DokanWholesale.variation_wholesale_string.minimum_quantity+": <strong>"+i._wholesale_quantity+"</strong>)";e(".single_variation").append('<div class="woocommerce-variation-wholesale">'+o+"</div>")}else e(".single_variation").find(".woocommerce-variation-wholesale").remove()}},400)},makeWholesaleCustomer:function(o){o.preventDefault();var a=e(this),i=dokan.rest.root+dokan.rest.version+"/wholesale/register",s={id:a.data("id")};jQuery(".dokan-wholesale-migration-wrapper").block({message:null,overlayCSS:{background:"#fff url("+dokan.ajax_loader+") no-repeat center",opacity:.6}}),e.post(i,s,function(e){"active"==e.wholesale_status?a.closest("li").html('<div class="woocommerce-message" style="margin-bottom:0px">'+dokan.wholesale.activeStatusMessage+"</div>"):a.closest("li").html('<div class="woocommerce-info" style="margin-bottom:0px">'+dokan.wholesale.deactiveStatusMessage+"</div>"),jQuery(".dokan-wholesale-migration-wrapper").unblock()})},toggleWholesaleWrapper:function(){e(this).is(":checked")?e(".show_if_wholesale").slideDown("fast"):e(".show_if_wholesale").slideUp("fast")},toggleWholesaleVariationWrapper:function(){e(this).is(":checked")?e(this).closest(".dokan-variation-wholesale").find(".show_if_variation_wholesale").slideDown("fast"):e(this).closest(".dokan-variation-wholesale").find(".show_if_variation_wholesale").slideUp("fast")}},e(document).ready(function(){o.init()})})();