jQuery(function(a){function b(){var b=a("select#product-type").val(),c=a("input#_virtual:checked").size(),d=a("input#_downloadable:checked").size(),e=".hide_if_downloadable, .hide_if_virtual",f=".show_if_downloadable, .show_if_virtual, .show_if_external";a.each(woocommerce_admin_meta_boxes.product_types,function(a,b){e=e+", .hide_if_"+b,f=f+", .show_if_"+b}),a(e).show(),a(f).hide(),d&&a(".show_if_downloadable").show(),c&&a(".show_if_virtual").show(),a(".show_if_"+b).show(),d&&a(".hide_if_downloadable").hide(),c&&a(".hide_if_virtual").hide(),a(".hide_if_"+b).hide(),a("input#_manage_stock").change()}function c(){a(".product_attributes .woocommerce_attribute").each(function(b,c){a(".attribute_position",c).val(parseInt(a(c).index(".product_attributes .woocommerce_attribute")))})}a("#titlediv #title").keyup(function(b){var c=b.keyCode||b.which;return"9"==c&&a("#woocommerce-coupon-description").size()>0?(b.stopPropagation(),a("#woocommerce-coupon-description").focus(),!1):void 0}),a("select#discount_type").change(function(){var b=a(this).val();"fixed_product"==b||"percent_product"==b?a(".limit_usage_to_x_items_field").show():a(".limit_usage_to_x_items_field").hide()}).change(),a(function(){a('[id$="-all"] > ul.categorychecklist').each(function(){var b=a(this),c=b.find(":checked").first();if(c.length){var d=b.find("input").position().top,e=c.position().top;b.closest(".tabs-panel").scrollTop(e-d+5)}})}),a("#upsell_product_data").bind("keypress",function(a){return 13==a.keyCode?!1:void 0}),a(".type_box").appendTo("#woocommerce-product-data h3.hndle span"),a(function(){a("#woocommerce-product-data h3.hndle").unbind("click.postboxes"),jQuery("#woocommerce-product-data").on("click","h3.hndle",function(b){a(b.target).filter("input, option, label, select").length||a("#woocommerce-product-data").toggleClass("closed")})}),a(function(){jQuery(".wc-metabox > h3").click(function(){a(this).parent(".wc-metabox").toggleClass("closed").toggleClass("open")})}),a("#order-emails a.show-order-emails").click(function(){return a("#order-emails-select").is(":hidden")&&(a("#order-emails-select").slideDown("fast"),a(this).hide()),!1}),a("#order-emails a.hide-order-emails").click(function(){return a('input[name="order_email[]"]').each(function(){a(this).attr("checked",!1)}),a("#order-emails-select").is(":visible")&&(a("#order-emails-select").slideUp("fast"),a("#order-emails a.show-order-emails").show()),!1}),a("#catalog-visibility .edit-catalog-visibility").click(function(){return a("#catalog-visibility-select").is(":hidden")&&(a("#catalog-visibility-select").slideDown("fast"),a(this).hide()),!1}),a("#catalog-visibility .save-post-visibility").click(function(){a("#catalog-visibility-select").slideUp("fast"),a("#catalog-visibility .edit-catalog-visibility").show();var b=(a("input[name=_visibility]:checked").val(),a("input[name=_visibility]:checked").attr("data-label"));return a("input[name=_featured]").is(":checked")&&(b=b+", "+woocommerce_admin_meta_boxes.featured_label,a("input[name=_featured]").attr("checked","checked")),a("#catalog-visibility-display").text(b),!1}),a("#catalog-visibility .cancel-post-visibility").click(function(){a("#catalog-visibility-select").slideUp("fast"),a("#catalog-visibility .edit-catalog-visibility").show();var b=a("#current_visibility").val(),c=a("#current_featured").val();a("input[name=_visibility]").removeAttr("checked"),a("input[name=_visibility][value="+b+"]").attr("checked","checked");var d=a("input[name=_visibility]:checked").attr("data-label");return"yes"==c?(d=d+", "+woocommerce_admin_meta_boxes.featured_label,a("input[name=_featured]").attr("checked","checked")):a("input[name=_featured]").removeAttr("checked"),a("#catalog-visibility-display").text(d),!1}),a("ul.wc-tabs").show(),a("div.panel-wrap").each(function(){a(this).find("div.panel:not(:first)").hide()}),a("ul.wc-tabs a").click(function(){var b=a(this).closest("div.panel-wrap");return a("ul.wc-tabs li",b).removeClass("active"),a(this).parent().addClass("active"),a("div.panel",b).hide(),a(a(this).attr("href")).show(),!1}),jQuery("select.chosen_select").chosen(),jQuery("select.chosen_select_nostd").chosen({allow_single_deselect:"true"}),jQuery("select.ajax_chosen_select_products").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c}),jQuery("select.ajax_chosen_select_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_products_and_variations",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c}),jQuery("select.ajax_chosen_select_downloadable_products_and_variations").ajaxChosen({method:"GET",url:woocommerce_admin_meta_boxes.ajax_url,dataType:"json",afterTypeDelay:100,data:{action:"woocommerce_json_search_downloadable_products_and_variations",security:woocommerce_admin_meta_boxes.search_products_nonce}},function(b){var c={};return a.each(b,function(a,b){c[a]=b}),c}),jQuery("#woocommerce-order-actions input, #woocommerce-order-actions a").click(function(){window.onbeforeunload=""}),a("a.edit_address").click(function(b){a(this).hide(),a(this).closest(".order_data_column").find("div.address").hide(),a(this).closest(".order_data_column").find("div.edit_address").show(),b.preventDefault()}),a("#order_items_list").on("init_row","tr.item",function(){var b=a(this),c=b.find("input.quantity"),d=c.val(),e=accounting.unformat(b.find("input.line_subtotal").val(),woocommerce_admin.mon_decimal_point),f=accounting.unformat(b.find("input.line_total").val(),woocommerce_admin.mon_decimal_point),g=accounting.unformat(b.find("input.line_tax").val(),woocommerce_admin.mon_decimal_point),h=accounting.unformat(b.find("input.line_subtotal_tax").val(),woocommerce_admin.mon_decimal_point);d?(unit_subtotal=parseFloat(accounting.toFixed(e/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_subtotal_tax=parseFloat(accounting.toFixed(h/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_total=parseFloat(accounting.toFixed(f/d,woocommerce_admin_meta_boxes.rounding_precision)),unit_total_tax=parseFloat(accounting.toFixed(g/d,woocommerce_admin_meta_boxes.rounding_precision))):unit_subtotal=unit_subtotal_tax=unit_total=unit_total_tax=0,c.attr("data-o_qty",d),b.attr("data-unit_subtotal",unit_subtotal),b.attr("data-unit_subtotal_tax",unit_subtotal_tax),b.attr("data-unit_total",unit_total),b.attr("data-unit_total_tax",unit_total_tax)}),a("#order_items_list tr.item").each(function(){a(this).trigger("init_row"),a(this).find(".edit").hide()}),a("#order_items_list").on("click","a.edit_order_item",function(){return a(this).closest("tr").find(".view").hide(),a(this).closest("tr").find(".edit").show(),a(this).hide(),!1}),a("#order_items_list").on("change","input.quantity",function(){var b=a(this).closest("tr.item"),c=a(this).val(),d=b.attr("data-unit_subtotal"),e=b.attr("data-unit_subtotal_tax"),f=b.attr("data-unit_total"),g=b.attr("data-unit_total_tax"),h=(a(this).attr("data-o_qty"),parseFloat(accounting.formatNumber(d*c,woocommerce_admin_meta_boxes.rounding_precision,""))),i=parseFloat(accounting.formatNumber(e*c,woocommerce_admin_meta_boxes.rounding_precision,"")),j=parseFloat(accounting.formatNumber(f*c,woocommerce_admin_meta_boxes.rounding_precision,"")),k=parseFloat(accounting.formatNumber(g*c,woocommerce_admin_meta_boxes.rounding_precision,""));h=h.toString().replace(".",woocommerce_admin.mon_decimal_point),i=i.toString().replace(".",woocommerce_admin.mon_decimal_point),j=j.toString().replace(".",woocommerce_admin.mon_decimal_point),k=k.toString().replace(".",woocommerce_admin.mon_decimal_point),b.find("input.line_subtotal").val(h),b.find("input.line_total").val(j),b.find("input.line_subtotal_tax").val(i),b.find("input.line_tax").val(k),a(this).trigger("quantity_changed")}),a("#order_items_list").on("change","input.line_subtotal",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_subtotal",e)}),a("#order_items_list").on("change","input.line_total",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_total",e)}),a("#order_items_list").on("change","input.line_subtotal_tax",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_subtotal_tax",e)}),a("#order_items_list").on("change","input.line_tax",function(){var b=a(this).closest("tr.item"),c=b.find("input.quantity"),d=c.val(),e=d?accounting.toFixed(a(this).val()/d,woocommerce_admin_meta_boxes.rounding_precision):0;b.attr("data-unit_total_tax",e)}),a("#woocommerce-order-totals").on("change input",".order_taxes_amount, .order_taxes_shipping_amount, .shipping_cost, #_order_discount",function(){var b=a(this),c=b.closest(".totals_group").find("input[type=number], .wc_input_price"),d=0;c.each(function(){a(this).val()&&(d+=accounting.unformat(a(this).val(),woocommerce_admin.mon_decimal_point))}),(b.is(".order_taxes_amount")||b.is(".order_taxes_shipping_amount"))&&(d=round(d,woocommerce_admin_meta_boxes.currency_format_num_decimals,woocommerce_admin_meta_boxes.tax_rounding_mode));var e=accounting.formatMoney(d,{symbol:woocommerce_admin_meta_boxes.currency_format_symbol,decimal:woocommerce_admin_meta_boxes.currency_format_decimal_sep,thousand:woocommerce_admin_meta_boxes.currency_format_thousand_sep,precision:woocommerce_admin_meta_boxes.currency_format_num_decimals,format:woocommerce_admin_meta_boxes.currency_format});b.closest(".totals_group").find("span.inline_total").text(e)}),a("span.inline_total").closest(".totals_group").find("input").change(),a("button.calc_line_taxes").click(function(){a(".woocommerce_order_items_wrapper").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b=confirm(woocommerce_admin_meta_boxes.calc_line_taxes);if(b){var c=a("#order_items_list").find("tr.item, tr.fee"),d=a("#_shipping_country").val(),e=a("#_billing_country").val();if(d)var f=d,g=a("#_shipping_state").val(),h=a("#_shipping_postcode").val(),i=a("#_shipping_city").val();else if(e)var f=e,g=a("#_billing_state").val(),h=a("#_billing_postcode").val(),i=a("#_billing_city").val();else var f=woocommerce_admin_meta_boxes.base_country,g="",h="",i="";var j={};c.each(function(){var b=a(this),c=b.find("input.order_item_id").val(),d=b.find("input.line_subtotal").val(),e=b.find("input.line_total").val(),f=b.find("select.tax_class").val();j[c]={},j[c].line_subtotal=d,j[c].line_total=e,j[c].tax_class=f}),order_shipping=0,a("#shipping_rows").find("input[type=number], .wc_input_price").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),order_shipping+=parseFloat(cost)});var k={action:"woocommerce_calc_line_taxes",order_id:woocommerce_admin_meta_boxes.post_id,items:j,shipping:order_shipping,country:f,state:g,postcode:h,city:i,security:woocommerce_admin_meta_boxes.calc_totals_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,k,function(b){b&&(c.each(function(){var c=a(this),d=c.find("input.order_item_id").val();c.find(".edit_order_item").click(),b.item_taxes[d]&&(c.find("input.line_tax").val(b.item_taxes[d].line_tax).change(),c.find("input.line_subtotal_tax").val(b.item_taxes[d].line_subtotal_tax).change()),b.tax_row_html&&a("#tax_rows").empty().append(b.tax_row_html)}),a("#tax_rows").find("input").change()),a(".woocommerce_order_items_wrapper").unblock()})}else a(".woocommerce_order_items_wrapper").unblock();return!1}),a("button.calc_totals").click(function(){a("#woocommerce-order-totals").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b=confirm(woocommerce_admin_meta_boxes.calc_totals);if(b){var c=0,d=0,e=0,f=a("#_order_discount").val()||"0";f=accounting.unformat(f.replace(",",".")),a("#shipping_rows").find("input[type=number], .wc_input_price").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),e+=parseFloat(cost)}),a("#tax_rows").find("input[type=number], .wc_input_price").each(function(){cost=a(this).val()||"0",cost=accounting.unformat(cost,woocommerce_admin.mon_decimal_point),d+=parseFloat(cost)}),a("#order_items_list tr.item, #order_items_list tr.fee").each(function(){line_total=a(this).find("input.line_total").val()||"0",c+=accounting.unformat(line_total.replace(",","."))}),"yes"==woocommerce_admin_meta_boxes.round_at_subtotal&&(d=parseFloat(accounting.toFixed(d,woocommerce_admin_meta_boxes.rounding_precision))),a("#_order_total").val(accounting.formatNumber(c+d+e-f,woocommerce_admin_meta_boxes.currency_format_num_decimals,"",woocommerce_admin.mon_decimal_point)).change()}return a("#woocommerce-order-totals").unblock(),!1}),a("#woocommerce-order-items button.add_order_item").click(function(){var b=a("select#add_item_id").val();return b?(count=b.length,a("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.each(b,function(b,c){var d={action:"woocommerce_add_order_item",item_to_add:c,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,d,function(b){a("table.woocommerce_order_items tbody#order_items_list").append(b),--count||(a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","").val(""),jQuery(".tips").tipTip({attribute:"data-tip",fadeIn:50,fadeOut:50,delay:200}),a("select#add_item_id").trigger("chosen:updated"),a("table.woocommerce_order_items").unblock()),a("#order_items_list tr.new_row").trigger("init_row").removeClass("new_row")})})):a("select#add_item_id, #add_item_id_chosen .chosen-choices").css("border-color","red"),!1}),a("#woocommerce-order-items button.add_order_fee").click(function(){a("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b={action:"woocommerce_add_order_fee",order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.order_item_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,b,function(b){a("table.woocommerce_order_items tbody#order_items_list").append(b),a("table.woocommerce_order_items").unblock()}),!1}),a("#order_items_list").on("click","button.add_order_item_meta",function(){var b=a(this),c=b.closest("tr.item"),d={order_item_id:c.attr("data-order_item_id"),action:"woocommerce_add_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};return a("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){c.find("tbody.meta_items").append(b),a("table.woocommerce_order_items").unblock()}}),!1}),a("#order_items_list").on("click","button.remove_order_item_meta",function(){var b=confirm(woocommerce_admin_meta_boxes.remove_item_meta);if(b){var c=a(this).closest("tr"),d={meta_id:c.attr("data-meta_id"),action:"woocommerce_remove_order_item_meta",security:woocommerce_admin_meta_boxes.order_item_nonce};a("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(){c.hide(),a("table.woocommerce_order_items").unblock()}})}return!1}),a("#woocommerce-order-items").on("click","input.check-column",function(){a(this).is(":checked")?a("#woocommerce-order-items").find(".check-column input").attr("checked","checked"):a("#woocommerce-order-items").find(".check-column input").removeAttr("checked")}),a("#woocommerce-order-items").on("click",".do_bulk_action",function(){var b=a(this).closest(".bulk_actions").find("select").val(),c=a("#woocommerce-order-items").find(".check-column input:checked"),d=[];if(a(c).each(function(){var b=a(this).closest("tr.item, tr.fee");d.push(b.attr("data-order_item_id"))}),0==d.length)return void alert(woocommerce_admin_meta_boxes.i18n_select_items);if("delete"==b){var e=confirm(woocommerce_admin_meta_boxes.remove_item_notice);if(e){a("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var f={order_item_ids:d,action:"woocommerce_remove_order_item",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(){a(c).each(function(){a(this).closest("tr.item, tr.fee").remove()}),a("table.woocommerce_order_items").unblock()}})}}else if("reduce_stock"==b){a("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var g={};a(c).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");g[b.attr("data-order_item_id")]=c.val()});var f={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:d,order_item_qty:g,action:"woocommerce_reduce_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(b){alert(b),a("table.woocommerce_order_items").unblock()}})}else if("increase_stock"==b){a("table.woocommerce_order_items").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var g={};a(c).each(function(){var b=a(this).closest("tr.item, tr.fee"),c=b.find("input.quantity");g[b.attr("data-order_item_id")]=c.val()});var f={order_id:woocommerce_admin_meta_boxes.post_id,order_item_ids:d,order_item_qty:g,action:"woocommerce_increase_order_item_stock",security:woocommerce_admin_meta_boxes.order_item_nonce};a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:f,type:"POST",success:function(b){alert(b),a("table.woocommerce_order_items").unblock()}})}return!1}),a(".order_download_permissions").on("click","button.grant_access",function(){var b=a("select#grant_access_id").val();if(b){a(".order_download_permissions").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_grant_access_to_download",product_ids:b,loop:a(".order_download_permissions .wc-metabox").size(),order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.grant_access_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(b){b?a(".order_download_permissions .wc-metaboxes").append(b):alert(woocommerce_admin_meta_boxes.i18n_download_permission_fail),a(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0}),a("#grant_access_id").val("").trigger("chosen:updated"),a(".order_download_permissions").unblock()}),!1}}),a(".order_download_permissions").on("click","button.revoke_access",function(b){b.preventDefault();var c=confirm(woocommerce_admin_meta_boxes.i18n_permission_revoke);if(c){var d=a(this).parent().parent(),e=a(this).attr("rel").split(",")[0],f=a(this).attr("rel").split(",")[1];if(e>0){a(d).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var g={action:"woocommerce_revoke_access_to_download",product_id:e,download_id:f,order_id:woocommerce_admin_meta_boxes.post_id,security:woocommerce_admin_meta_boxes.revoke_access_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,g,function(){a(d).fadeOut("300",function(){a(d).remove()})})}else a(d).fadeOut("300",function(){a(d).remove()})}return!1}),a("button.load_customer_billing").click(function(){var b=confirm(woocommerce_admin_meta_boxes.load_billing);if(b){var c=a("#customer_user").val();if(!c)return alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var d={user_id:c,type_to_load:"billing",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){var c=b;c&&(a("input#_billing_first_name").val(c.billing_first_name),a("input#_billing_last_name").val(c.billing_last_name),a("input#_billing_company").val(c.billing_company),a("input#_billing_address_1").val(c.billing_address_1),a("input#_billing_address_2").val(c.billing_address_2),a("input#_billing_city").val(c.billing_city),a("input#_billing_postcode").val(c.billing_postcode),a("#_billing_country").val(c.billing_country),a("input#_billing_state").val(c.billing_state),a("input#_billing_email").val(c.billing_email),a("input#_billing_phone").val(c.billing_phone)),a(".edit_address").unblock()}})}return!1}),a("button.load_customer_shipping").click(function(){var b=confirm(woocommerce_admin_meta_boxes.load_shipping);if(b){var c=a("#customer_user").val();if(!c)return alert(woocommerce_admin_meta_boxes.no_customer_selected),!1;var d={user_id:c,type_to_load:"shipping",action:"woocommerce_get_customer_details",security:woocommerce_admin_meta_boxes.get_customer_details_nonce};a(this).closest(".edit_address").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a.ajax({url:woocommerce_admin_meta_boxes.ajax_url,data:d,type:"POST",success:function(b){var c=b;c&&(a("input#_shipping_first_name").val(c.shipping_first_name),a("input#_shipping_last_name").val(c.shipping_last_name),a("input#_shipping_company").val(c.shipping_company),a("input#_shipping_address_1").val(c.shipping_address_1),a("input#_shipping_address_2").val(c.shipping_address_2),a("input#_shipping_city").val(c.shipping_city),a("input#_shipping_postcode").val(c.shipping_postcode),a("#_shipping_country").val(c.shipping_country),a("input#_shipping_state").val(c.shipping_state)),a(".edit_address").unblock()}})}return!1}),a("button.billing-same-as-shipping").click(function(){var b=confirm(woocommerce_admin_meta_boxes.copy_billing);return b&&(a("input#_shipping_first_name").val(a("input#_billing_first_name").val()),a("input#_shipping_last_name").val(a("input#_billing_last_name").val()),a("input#_shipping_company").val(a("input#_billing_company").val()),a("input#_shipping_address_1").val(a("input#_billing_address_1").val()),a("input#_shipping_address_2").val(a("input#_billing_address_2").val()),a("input#_shipping_city").val(a("input#_billing_city").val()),a("input#_shipping_postcode").val(a("input#_billing_postcode").val()),a("#_shipping_country").val(a("#_billing_country").val()),a("input#_shipping_state").val(a("input#_billing_state").val())),!1}),a(".totals_group").on("click","a.add_total_row",function(){return a(this).closest(".totals_group").find(".total_rows").append(a(this).data("row")),!1}),a(".total_rows").on("click","a.delete_total_row",function(){$row=a(this).closest(".total_row");var b=$row.attr("data-order_item_id");return b?$row.append('').hide():$row.remove(),!1}),a("#woocommerce-order-notes").on("click","a.add_note",function(){if(a("textarea#add_order_note").val()){a("#woocommerce-order-notes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b={action:"woocommerce_add_order_note",post_id:woocommerce_admin_meta_boxes.post_id,note:a("textarea#add_order_note").val(),note_type:a("select#order_note_type").val(),security:woocommerce_admin_meta_boxes.add_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,b,function(b){a("ul.order_notes").prepend(b),a("#woocommerce-order-notes").unblock(),a("#add_order_note").val("")}),!1}}),a("#woocommerce-order-notes").on("click","a.delete_note",function(){var b=a(this).closest("li.note");a(b).block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var c={action:"woocommerce_delete_order_note",note_id:a(b).attr("rel"),security:woocommerce_admin_meta_boxes.delete_order_note_nonce};return a.post(woocommerce_admin_meta_boxes.ajax_url,c,function(){a(b).remove()}),!1}),a("select#product-type").change(function(){var c=a(this).val();"variable"==c?(a("input#_manage_stock").change(),a("input#_downloadable").prop("checked",!1),a("input#_virtual").removeAttr("checked")):"grouped"==c?(a("input#_downloadable").prop("checked",!1),a("input#_virtual").removeAttr("checked")):"external"==c&&(a("input#_downloadable").prop("checked",!1),a("input#_virtual").removeAttr("checked")),b(),a("ul.wc-tabs li:visible").eq(0).find("a").click(),a("body").trigger("woocommerce-product-type-change",c,a(this))}).change(),a("ul.wc-tabs li:visible").eq(0).find("a").click(),a("input#_downloadable, input#_virtual").change(function(){b()}),a(".sale_price_dates_fields").each(function(){var b=a(this),c=!1,d=b.closest("div, table");b.find("input").each(function(){""!=a(this).val()&&(c=!0)}),c?(d.find(".sale_schedule").hide(),d.find(".sale_price_dates_fields").show()):(d.find(".sale_schedule").show(),d.find(".sale_price_dates_fields").hide())}),a("#woocommerce-product-data").on("click",".sale_schedule",function(){var b=a(this).closest("div, table");return a(this).hide(),b.find(".cancel_sale_schedule").show(),b.find(".sale_price_dates_fields").show(),!1}),a("#woocommerce-product-data").on("click",".cancel_sale_schedule",function(){var b=a(this).closest("div, table");return a(this).hide(),b.find(".sale_schedule").show(),b.find(".sale_price_dates_fields").hide(),b.find(".sale_price_dates_fields").find("input").val(""),!1}),a("#woocommerce-product-data").on("click",".downloadable_files a.insert",function(){return a(this).closest(".downloadable_files").find("tbody").append(a(this).data("row")),!1}),a("#woocommerce-product-data").on("click",".downloadable_files a.delete",function(){return a(this).closest("tr").remove(),!1}),a("input#_manage_stock").change(function(){a(this).is(":checked")?a("div.stock_fields").show():a("div.stock_fields").hide()}).change();var d=a(".sale_price_dates_fields input").datepicker({defaultDate:"",dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0,onSelect:function(b){var c=a(this).is("#_sale_price_dates_from, .sale_price_dates_from")?"minDate":"maxDate",e=a(this).data("datepicker"),f=a.datepicker.parseDate(e.settings.dateFormat||a.datepicker._defaults.dateFormat,b,e.settings);d.not(this).datepicker("option",c,f)}});a(".date-picker").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0,showOn:"button",buttonImage:woocommerce_admin_meta_boxes.calendar_image,buttonImageOnly:!0}),a(".date-picker-field").datepicker({dateFormat:"yy-mm-dd",numberOfMonths:1,showButtonPanel:!0}),jQuery(".wc-metaboxes-wrapper").on("click",".wc-metabox h3",function(b){a(b.target).filter(":input, option").length||jQuery(this).next(".wc-metabox-content").toggle()}).on("click",".expand_all",function(){return jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").show(),!1}).on("click",".close_all",function(){return jQuery(this).closest(".wc-metaboxes-wrapper").find(".wc-metabox > table").hide(),!1}),jQuery(".wc-metabox.closed").each(function(){jQuery(this).find(".wc-metabox-content").hide()}),a(".product_attributes select.multiselect").chosen();var e=a(".product_attributes").find(".woocommerce_attribute").get();e.sort(function(b,c){var d=parseInt(a(b).attr("rel")),e=parseInt(a(c).attr("rel"));return e>d?-1:d>e?1:0}),a(e).each(function(b,c){a(".product_attributes").append(c)}),a("button.add_attribute").on("click",function(){var b=a(".product_attributes .woocommerce_attribute").size(),d=a("select.attribute_taxonomy").val();if(d){var e=a(".product_attributes .woocommerce_attribute."+d);a(".product_attributes").append(a(e)),a(e).show().find(".woocommerce_attribute_data").show(),c()}else{var f=a("select#product-type").val();enable_variation="variable"!=f?'style="display:none;"':"",a(".product_attributes").append('
")}a("select.attribute_taxonomy").val("")}),a(".product_attributes").on("blur","input.attribute_name",function(){a(this).closest(".woocommerce_attribute").find("strong.attribute_name").text(a(this).val())}),a(".product_attributes").on("click","button.select_all_attributes",function(){return a(this).closest("td").find("select option").attr("selected","selected"),a(this).closest("td").find("select").trigger("chosen:updated"),!1}),a(".product_attributes").on("click","button.select_no_attributes",function(){return a(this).closest("td").find("select option").removeAttr("selected"),a(this).closest("td").find("select").trigger("chosen:updated"),!1}),a(".product_attributes").on("click","button.remove_row",function(){var b=confirm(woocommerce_admin_meta_boxes.remove_attribute); if(b){var d=a(this).parent().parent();d.is(".taxonomy")?(d.find("select, input[type=text]").val(""),d.hide()):(d.find("select, input[type=text]").val(""),d.hide(),c())}return!1}),a(".product_attributes").sortable({items:".woocommerce_attribute",cursor:"move",axis:"y",handle:"h3",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65,placeholder:"wc-metabox-sortable-placeholder",start:function(a,b){b.item.css("background-color","#f6f6f6")},stop:function(a,b){b.item.removeAttr("style"),c()}}),a(".product_attributes").on("click","button.add_new_attribute",function(){a(".product_attributes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b=a(this).attr("data-attribute"),c=a(this).closest(".woocommerce_attribute_data"),d=prompt(woocommerce_admin_meta_boxes.new_attribute_prompt);if(d){var e={action:"woocommerce_add_new_attribute",taxonomy:b,term:d,security:woocommerce_admin_meta_boxes.add_attribute_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,e,function(b){b.error?alert(b.error):b.slug&&(c.find("select.attribute_values").append('"),c.find("select.attribute_values").trigger("chosen:updated")),a(".product_attributes").unblock()})}else a(".product_attributes").unblock();return!1}),a(".save_attributes").on("click",function(){a(".product_attributes").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}});var b={post_id:woocommerce_admin_meta_boxes.post_id,data:a(".product_attributes").find("input, select, textarea").serialize(),action:"woocommerce_save_attributes",security:woocommerce_admin_meta_boxes.save_attributes_nonce};a.post(woocommerce_admin_meta_boxes.ajax_url,b,function(){var b=window.location.toString();b=b.replace("post-new.php?","post.php?post="+woocommerce_admin_meta_boxes.post_id+"&action=edit&"),a("#variable_product_options").block({message:null,overlayCSS:{background:"#fff url("+woocommerce_admin_meta_boxes.plugin_url+"/assets/images/ajax-loader.gif) no-repeat center",opacity:.6}}),a("#variable_product_options").load(b+" #variable_product_options_inner",function(){a("#variable_product_options").unblock()}),a(".product_attributes").unblock()})});var f,g;jQuery(document).on("click",".upload_file_button",function(b){var c=a(this);if(g=c.closest("tr").find("td.file_url input"),b.preventDefault(),f)return void f.open();var d=[new wp.media.controller.Library({library:wp.media.query(),multiple:!0,title:c.data("choose"),priority:20,filterable:"uploaded"})];f=wp.media.frames.downloadable_file=wp.media({title:c.data("choose"),library:{type:""},button:{text:c.data("update")},multiple:!0,states:d}),f.on("select",function(){var a="",b=f.state().get("selection");b.map(function(b){b=b.toJSON(),b.url&&(a=b.url)}),g.val(a)}),f.on("ready",function(){f.uploader.options.uploader.params={type:"downloadable_product"}}),f.open()}),jQuery(".downloadable_files tbody").sortable({items:"tr",cursor:"move",axis:"y",handle:"td.sort",scrollSensitivity:40,forcePlaceholderSize:!0,helper:"clone",opacity:.65});var h,i=a("#product_image_gallery"),j=a("#product_images_container ul.product_images");jQuery(".add_product_images").on("click","a",function(b){var c=a(this),d=i.val();return b.preventDefault(),h?void h.open():(h=wp.media.frames.product_gallery=wp.media({title:c.data("choose"),button:{text:c.data("update")},states:[new wp.media.controller.Library({title:c.data("choose"),filterable:"all",multiple:!0})]}),h.on("select",function(){var a=h.state().get("selection");a.map(function(a){a=a.toJSON(),a.id&&(d=d?d+","+a.id:a.id,j.append('