(()=>{var e={1669:e=>{"use strict";e.exports=jQuery}},t={};function n(i){var o=t[i];if(void 0!==o)return o.exports;var c=t[i]={exports:{}};return e[i](c,c.exports,n),c.exports}var i=n(1669),o=n(1669),c={vars:{customer_card_wrap_editable:i("#edit-customer-info .editable"),customer_card_wrap_edit_item:i("#edit-customer-info .edit-item"),user_id:i('input[name="customerinfo[user_id]"]')},init:function(){this.edit_customer(),this.add_email(),this.user_search(),this.remove_user(),this.cancel_edit(),this.change_country(),this.delete_checked()},edit_customer:function(){i(document.body).on("click","#edit-customer",(function(e){e.preventDefault(),c.vars.customer_card_wrap_editable.hide(),c.vars.customer_card_wrap_edit_item.show().css("display","flex")}))},add_email:function(){i(document.body).on("click","#add-customer-email",(function(e){e.preventDefault();const t=i(this),n=t.parents(".customer-section"),o=n.find(".notice-wrap"),c={edd_action:"customer-add-email",customer_id:n.find('input[name="customer-id"]').val(),email:n.find('input[name="additional-email"]').val(),primary:n.find('input[name="make-additional-primary"]').is(":checked"),_wpnonce:n.find('input[name="add_email_nonce"]').val()};o.empty(),t.attr("disabled",!0).addClass("updating-message"),i.post(ajaxurl,c,(function(e){setTimeout((function(){!0===e.success?window.location.href=e.redirect:(t.attr("disabled",!1).removeClass("updating-message"),o.append('<div class="notice notice-error inline"><p>'+e.message+"</p></div>"))}),342)}),"json")}))},user_search:function(){i(document.body).on("click.eddSelectUser",".edd_user_search_results a",(function(e){e.preventDefault();const t=i(this).data("userid");c.vars.user_id.val(t)}))},remove_user:function(){i(document.body).on("click","#disconnect-customer",(function(e){if(e.preventDefault(),confirm(edd_vars.disconnect_customer)){const e={edd_action:"disconnect-userid",customer_id:i('input[name="customerinfo[id]"]').val(),_wpnonce:i("#edit-customer-info #_wpnonce").val()};i.post(ajaxurl,e,(function(e){window.location.href=window.location.href}),"json")}}))},cancel_edit:function(){i(document.body).on("click","#edd-edit-customer-cancel",(function(e){e.preventDefault(),c.vars.customer_card_wrap_edit_item.hide(),c.vars.customer_card_wrap_editable.show(),i(".edd_user_search_results").html("")}))},change_country:function(){i('select[name="customerinfo[country]"]').on("change",(function(){const e=i(this),t=i(':input[name="customerinfo[region]"]'),n={action:"edd_get_shop_states",country:e.val(),nonce:e.data("nonce"),field_name:"customerinfo[region]"};return i.post(ajaxurl,n,(function(e){console.log(e),"nostates"===e?t.replaceWith('<input type="text" name="'+n.field_name+'" value="" class="edd-edit-toggles medium-text"/>'):t.replaceWith(e)})),!1}))},delete_checked:function(){i("#edd-customer-delete-confirm").on("change",(function(){const e=i("#edd-customer-delete-records"),t=i("#edd-delete-customer");i(this).prop("checked")?(e.attr("disabled",!1),t.attr("disabled",!1)):(e.attr("disabled",!0),e.prop("checked",!1),t.attr("disabled",!0))}))}};o(document).ready((function(e){c.init()}))})();