(()=>{"use strict";var e={n:t=>{var a=t&&t.__esModule?()=>t.default:()=>t;return e.d(a,{a}),a},d:(t,a)=>{for(var i in a)e.o(a,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:a[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=jQuery;var a;(a=e.n(t)())((function(){var e;(a("#bulk-action-selector-top, #bulk-action-selector-bottom").on("change",(function(){var e=a(this),t=e.closest(".tablenav").find(".redirection-category-filter"),i=e.closest(".tablenav").find(".category-filter-submit");"bulk_add_redirection_category"===e.val()?(t.data("oldval",t.val()).val("none").insertAfter(e),i.addClass("hidden")):(t.insertBefore(i),t.data("oldval")&&(t.val(t.data("oldval")),t.data("oldval","")),i.removeClass("hidden"))})),a(".add-redirection-category-button").on("click",(function(){var e=a(this),t=e.siblings(".add-redirection-category-input");e.addClass("disabled"),t.prop("disabled",!0),a.ajax({url:ajaxurl,type:"POST",dataType:"xml",data:{action:"add-rank_math_redirection_category","_ajax_nonce-add-rank_math_redirection_category":rankMath.add_redirection_category_nonce,newrank_math_redirection_category:t.val(),newrank_math_redirection_category_parent:-1}}).always((function(i){t.val(""),e.removeClass("disabled"),t.prop("disabled",!1);var n=i.getElementsByTagName("response_data")[0].innerHTML.slice(9,-3);a(n).appendTo(e.siblings(".cmb2-checkbox-list")).find("input").prop("name","redirection_category[]")}))})),a(".add-redirection-category-input").on("keydown",(function(e){if(13===e.keyCode)return e.preventDefault(),e.stopPropagation(),a(this).siblings(".add-redirection-category-button").trigger("click"),!1})),a("#rank-math-contextual-help-link").on("click",(function(e){e.preventDefault(),a("#contextual-help-link").trigger("click")})),a("#csv-panel-export-redirections").on("submit",(function(){var e=a(this);e.find('button[type="submit"]').prop("disabled",!0).siblings(".input-loading").css("visibility","visible"),setTimeout((function(){e.find('button[type="submit"]').prop("disabled",!1).siblings(".input-loading").css("visibility","hidden")}),5e3)})),a("#panel-import").on("submit",(function(){return confirm(rankMath.confirmRedirectionsCsvImport)})),a("#csv-import-redirections-cancel").on("click",(function(){return confirm(rankMath.confirmRedirectionsCsvCancel)})),a("#csv-import-redirections-progress-details").length)&&(e=setInterval((function(){a.ajax({url:ajaxurl,type:"GET",dataType:"html",data:{action:"csv_import_redirections_progress",_ajax_nonce:rankMath.csvProgressNonce}}).done((function(t){if(a("#csv-import-redirections-progress-details").html(t),a(t).hasClass("import-finished"))return clearInterval(e),void a("#csv-import-cancel").remove();a(t).find("#csv-import-progress-value").length||a("#csv-import-cancel").addClass("disabled").prop("disabled",!0).siblings(".input-loading").hide()}))}),3e3));"#import-export-box"===window.location.hash&&a(".rank-math-redirections-form.rank-math-importexport-form").show();var t=a("#start_date"),i=t.val(),n=a("#end_date"),r=n.val(),o=a(".cmb2-id-status"),c=!1,s=!1,d=new Date;d.setUTCHours(0,0,0,0);var l=function(e){o.css("opacity","0.4").find("input").prop("disabled",!0).filter('[value="'+e+'"]').prop("checked",!0)},p=function(e,t){e>d?l("inactive"):t>d&&(isNaN(e)||e>=d)?l("active"):o.css("opacity","1").find("input").prop("disabled",!1),u(e,t)},u=function(e,a){if("function"==typeof n.datepicker){if(isNaN(e))n.datepicker("option","minDate",null);else{var i=new Date(e);i.setUTCDate(i.getUTCDate()+1),n.datepicker("option","minDate",i)}if(isNaN(a))t.datepicker("option","maxDate",null);else{var r=new Date(a);r.setUTCDate(r.getUTCDate()-1),t.datepicker("option","maxDate",r)}}};t.on("change",(function(e){var t=a(this).val(),n=new Date(t),o=new Date(r);if(r&&t&&n>=o)return a(this).val(""),void(i="");i=t,p(n,o)})).on("focus",(function(e){if(!c){var a=new Date(d);a.setUTCDate(a.getUTCDate()+1),t.datepicker("option","minDate",a),c=!0}})),n.on("change",(function(e){var t=a(this).val(),n=new Date(t),o=new Date(i);return i&&t&&n<=o||n<=d?(a(this).val(""),void(r="")):(r=t,void p(o,n))})).on("focus",(function(e){if(!s){var t=new Date(d);t.setUTCDate(t.getUTCDate()+1),n.datepicker("option","minDate",t),s=!0}})).trigger("change")}))})();