(()=>{var e,o;window.eu_owb=window.eu_owb||{},window.eu_owb.admin_order=window.eu_owb.admin_order||{},e=jQuery,(o=window.eu_owb).admin_order={params:{},init:function(){var n=o.admin_order;n.params=eu_owb_woocommerce_admin_order_params,e(document).on("click",".eu-owb-reject-withdrawal-request-start",n.onRejectRequest),e(document).on("click",".eu-owb-woocommerce-needs-confirmation",n.onConfirm),e(document).on("click",".eu-owb-order-withdrawal-order-save",n.onSave),e(document).on("click",".eu-owb-order-toggle-order-search",n.onToggleInlineEdit),e(document).on("click","a.wc-action-button-reject",n.onToggleInlineEdit),n.initEnhanced()},onToggleInlineEdit:function(n){o.admin_order;var a=e(this).parents("td");return n.preventDefault(),a.find(".eu-owb-order-inline-edit-wrapper").toggleClass("hidden"),!1},onSave:function(){var n=o.admin_order,a=e(this).data("save"),r=e(this).data("id"),i=e(this).parents("tr"),t=e(this),d=i.find("#"+a+"_"+r).val();let c={};c[a]=d;const s={order_id:r,action:"eu_owb_woocommerce_save_withdrawal_order",security:n.params.save_order_nonce,props:c,inline_action:t.data("action")?t.data("action"):"edit"};return t.addClass("eu-owb-woocommerce-is-loading disabled"),t.append('<span class="spinner is-active"></span>'),t.prop("disabled",!0),e.ajax({type:"POST",url:n.params.ajax_url,data:s,dataType:"json"}).done(function(e){t.removeClass("eu-owb-woocommerce-is-loading disabled"),t.find(".spinner").remove(),t.prop("disabled",!1),t.addClass("eu-owb-woocommerce-success"),setTimeout(()=>{window.location.reload()},50)}).fail(function(e){t.removeClass("eu-owb-woocommerce-is-loading disabled"),t.find(".spinner").remove(),t.prop("disabled",!1)}),!1},initEnhanced:function(){var n=o.admin_order;try{e(document.body).on("wc-enhanced-select-init",function(){e(":input.eu-owb-order-search").filter(":not(.enhanced)").each(function(){var o={allowClear:!!e(this).data("allow_clear"),placeholder:e(this).data("placeholder"),minimumInputLength:e(this).data("minimum_input_length")?e(this).data("minimum_input_length"):"1",escapeMarkup:function(e){return e},ajax:{url:n.params.ajax_url,dataType:"json",delay:1e3,data:function(o){return{term:o.term,action:"eu_owb_woocommerce_json_search_orders",security:n.params.search_orders_nonce,exclude:e(this).data("exclude")}},processResults:function(o){var n=[];return o&&e.each(o,function(e,o){n.push({id:e,text:o})}),{results:n}},cache:!0}};e(this).selectWoo(o).addClass("enhanced")})}),e("html").on("click",function(o){this===o.target&&e(":input.eu-owb-order-search").filter(".select2-hidden-accessible").selectWoo("close")})}catch(e){window.console.log(e)}},onConfirm:function(n){o.admin_order;var a=e(this).data("confirm");confirm(a)||n.preventDefault()},onRejectRequest:function(){o.admin_order;var n=e(this).parents(".eu-owb-order-withdrawal-request");return n.find(".eu-owb-reject-withdrawal-request-form").toggleClass("hidden"),n.find("#eu_owb_reject_reason").focus(),!1}},e(document).ready(function(){o.admin_order.init()}),((window.owbWC=window.owbWC||{}).static=window.owbWC.static||{})["admin-order"]={}})();