!function(){"use strict";var t={n:function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(e,{a:e}),e},d:function(n,e){for(var a in e)t.o(e,a)&&!t.o(n,a)&&Object.defineProperty(n,a,{enumerable:!0,get:e[a]})},o:function(t,n){return Object.prototype.hasOwnProperty.call(t,n)}},n=jQuery,e=t.n(n);function a(t,n){for(var e=0;e<n.length;e++){var a=n[e];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}var r=function(){function t(){!function(t,n){if(!(t instanceof n))throw new TypeError("Cannot call a class as a function")}(this,t),this.addButtons(),this.editingEvents(),this.saveEvents()}var n,r,i;return n=t,(r=[{key:"addButtons",value:function(){var t=e()("#rank_math_seo_details, #rank_math_title, #rank_math_description, #rank_math_image_alt, #rank_math_image_title");t.each((function(){var t=e()(this);t.append(' <a href=#" class="dashicons dashicons-edit" title="'+rankMath.bulkEditTitle+'"></a>'),t.wrapInner("<span/>"),t.append(' <span><a href="#" class="button button-primary button-small rank-math-column-save-all">'+rankMath.buttonSaveAll+'</a> <a href="#" class="button-link button-link-delete rank-math-column-cancel-all">'+rankMath.buttonCancel+"</a></span>")})),t.on("click",".dashicons-edit, .rank-math-column-cancel-all",(function(n){n.preventDefault();var a=e()(this).closest("th");e()(this).hasClass("rank-math-column-cancel-all")?(t.removeClass("bulk-editing"),e()(".rank-math-column-cancel","td.bulk-editing.dirty").trigger("click"),e()("td.bulk-editing").removeClass("bulk-editing")):(a.toggleClass("bulk-editing"),e()("td.column-"+a.attr("id")).toggleClass("bulk-editing"))}))}},{key:"editingEvents",value:function(){e()(".rank-math-column-value").on("input",(function(){var t=e()(this),n=t.closest("td");t.text()!==t.prev().text()?n.addClass("dirty"):n.removeClass("dirty")})).on("keypress",(function(t){if(13===t.keyCode)return e()(this).parent().find(".rank-math-column-save").trigger("click"),!1})),e()(".rank-math-column-cancel").on("click",(function(t){t.preventDefault();var n=e()(this).closest("td");n.removeClass("dirty");var a=n.find(".rank-math-column-value").prev(".rank-math-column-display");a.find("span").length&&(a=a.find("span")),n.find(".rank-math-column-value").text(a.text())}))}},{key:"saveEvents",value:function(){var t=this;e()(".rank-math-column-save-all").on("click",(function(n){n.preventDefault();var a=e()(this),r={},i=[];if(e()(".dirty.bulk-editing").each((function(){var t=e()(this),n=parseInt(t.closest("tr").attr("id").replace("post-","")),a=t.find(".rank-math-column-value");i.push(t),r[n]=r[n]||{},r[n][a.data("field")]=a.text()})),e().isEmptyObject(r))return e()(a.next()).trigger("click"),!0;t.save(r).done((function(n){n.success&&(i.forEach((function(n){t.setColumn(n)})),e()(a.next()).trigger("click"))}))})),e()(".rank-math-column-save").on("click",(function(n){n.preventDefault();var a=e()(this).closest(".dirty"),r=parseInt(a.closest("tr").attr("id").replace("post-","")),i=a.find(".rank-math-column-value"),l={};l[r]={},l[r][i.data("field")]=i.text(),t.save(l).done((function(n){n.success&&t.setColumn(a)}))}))}},{key:"setColumn",value:function(t){t.removeClass("dirty bulk-editing");var n=t.find(".rank-math-column-value").prev(".rank-math-column-display");n.find("span").length&&(n=n.find("span"));var e=document.createElement("div");e.innerHTML=t.find(".rank-math-column-value").text(),n.text(e.innerText)}},{key:"save",value:function(t){return e().ajax({url:rankMath.endpoint+"/updateMetaBulk",method:"POST",beforeSend:function(t){t.setRequestHeader("X-WP-Nonce",rankMath.restNonce)},data:{rows:t}})}}])&&a(n.prototype,r),i&&a(n,i),Object.defineProperty(n,"prototype",{writable:!1}),t}();e()((function(){new r}))}();