(()=>{var e,a;window.shiptastic=window.shiptastic||{},window.shiptastic.admin=window.shiptastic.admin||{},e=jQuery,(a=window.shiptastic).admin.shipments_admin={params:{},init:function(){var t=a.admin.shipments_admin;t.params=wc_shiptastic_admin_params,e(document).on("click","a.woocommerce-shiptastic-input-toggle-trigger",this.onInputToggleClick).on("change",".wc-shiptastic-toggle-input",t.onChangeToggleInput).on("click","a.wc-shiptastic-ajax-action",t.ajaxAction)},ajaxAction:function(){var t=a.admin.shipments_admin,i=e(this),s={...Object.fromEntries(new URLSearchParams(i.data("args"))),action:"woocommerce_stc_"+i.data("action"),security:i.data("nonce"),args:i.data("args")};return i.addClass("wc-shiptastic-is-loading"),i.append('<span class="spinner is-active"></span>'),i.prop("disabled",!0),e(".wp-core-ui").find(".wc-shiptastic-ajax-error").remove(),t.doAjax(s,(function(e){if(i.find(".spinner").remove(),i.removeClass("wc-shiptastic-is-loading"),i.prop("disabled",!1),e.hasOwnProperty("redirect")&&!0===e.redirect){var a=e.url.length>0?e.url:i.attr("href");window.location.href=a}else e.hasOwnProperty("success_text")&&e.success_text.length>0&&(i.addClass("wc-shiptastic-success"),i.text(e.success_text))}),(function(a){i.find(".spinner").remove(),i.removeClass("wc-shiptastic-is-loading"),i.prop("disabled",!1);var t=e("#wpbody-content").find(".wrap"),s=!1,o='<div class="notice notice-error wc-shiptastic-ajax-error"><p>'+a.message+"</p></div>";e(".wc-shiptastic-error-wrapper").length>0&&(t=e(".wc-shiptastic-error-wrapper"),s=!0),s?t.append(o):t.before(o),e(".wc-shiptastic-ajax-error")[0].scrollIntoView({behavior:"smooth",block:"start"})})),!1},doAjax:function(t,i,s){var o=a.admin.shipments_admin,n=o.params.ajax_url,c=o.$wrapper;i=i||o.onAjaxSuccess,s=s||o.onAjaxError,e.ajax({type:"POST",url:n,data:t,success:function(e){e.success?i.apply(c,[e]):s.apply(c,[e])},error:function(e){s.apply(c,[e])},dataType:"json"})},onAjaxError:function(e){},onAjaxSuccess:function(e){},onChangeToggleInput:function(){var a=e(this),t=a.parents("fieldset").find("span.woocommerce-shiptastic-input-toggle"),i=a.is(":checked");i&&!t.hasClass("woocommerce-input-toggle--enabled")?(t.removeClass("woocommerce-input-toggle--disabled"),t.addClass("woocommerce-input-toggle--enabled")):i||t.hasClass("woocommerce-input-toggle--disabled")||(t.removeClass("woocommerce-input-toggle--enabled"),t.addClass("woocommerce-input-toggle--disabled"))},onInputToggleClick:function(){var a=e(this).find("span.woocommerce-shiptastic-input-toggle"),t=a.parents("fieldset"),i=t.find("input[type=checkbox]").length>0?t.find("input[type=checkbox]"):a.parent().nextAll("input[type=checkbox]:first"),s=a.hasClass("woocommerce-input-toggle--enabled");return a.removeClass("woocommerce-input-toggle--enabled"),a.removeClass("woocommerce-input-toggle--disabled"),s?(i.prop("checked",!1),a.addClass("woocommerce-input-toggle--disabled")):(i.prop("checked",!0),a.addClass("woocommerce-input-toggle--enabled")),i.trigger("change"),!1}},e(document).ready((function(){a.admin.shipments_admin.init()})),((window.wcShiptastic=window.wcShiptastic||{}).static=window.wcShiptastic.static||{}).admin={}})();