/home/edulekha/www/wp-content/plugins/seo-by-rank-math/assets/admin/js/common.js
!function(){"use strict";var e={n:function(t){var a=t&&t.__esModule?function(){return t.default}:function(){return t};return e.d(a,{a:a}),a},d:function(t,a){for(var n in a)e.o(a,n)&&!e.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:a[n]})},o:function(e,t){return Object.prototype.hasOwnProperty.call(e,t)}},t=jQuery,a=e.n(t),n=wp.i18n;function i(e,t,n){return a().ajax({url:rankMath.ajaxurl,type:n||"POST",dataType:"json",data:a().extend(!0,{action:"rank_math_"+e,security:rankMath.security},t)})}function r(e,t,n,i){t=t||"error",i=i||!1;var r=a()('<div class="notice notice-'+t+' is-dismissible"><p>'+e+"</p></div>").hide();n.next(".notice").remove(),n.after(r),r.slideDown(),a()(document).trigger("wp-updates-notice-added"),i&&setTimeout((function(){r.fadeOut((function(){r.remove()}))}),i)}var o=lodash;function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function c(e,t){for(var a=0;a<t.length;a++){var n=t[a];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,l(n.key),n)}}function l(e){var t=function(e,t){if("object"!==s(e)||null===e)return e;var a=e[Symbol.toPrimitive];if(void 0!==a){var n=a.call(e,t||"default");if("object"!==s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"===s(t)?t:String(t)}var p,d=new(function(){function e(){var t,a,n;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),t=this,n="",(a=l(a="response"))in t?Object.defineProperty(t,a,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[a]=n}var t,r,s;return t=e,(r=[{key:"checkAll",value:function(){var e=this,t=a()("#setting-panel-analytics .cmb2-id-check-all-services:not(.done), #cmb2-metabox-rank-math-wizard .cmb2-id-check-all-services:not(.done)");t.length>0&&"0"===t.val()&&(t.addClass("done"),i("google_check_all_services").done((function(t){e.response=t,e.fillSelect(),e.accordions.removeClass("locked")})))}},{key:"events",value:function(){var e=this;this.saveChanges=!1,this.accountSelect=a()(".site-analytics-account"),this.profileSelect=a()(".site-console-profile"),this.propertySelect=a()(".site-analytics-property"),this.viewSelect=a()(".site-analytics-view"),this.adsenseSelect=a()(".site-adsense-account"),this.accordions=a()(".rank-math-accordion"),this.countryConsole=a()("#site-console-country"),this.countryAnalytics=a()("#site-analytics-country"),a()(".cmb2_select").on("select2:open",(function(){document.querySelector(".select2-search__field").focus()})),this.accountSelect.on("change",(function(){var t=parseInt(e.accountSelect.val());0!==t?e.fillPropertySelect(t):e.propertySelect.html('<option value="0">Select Property</option>')})),this.profileSelect.on("change",(function(){0!==parseInt(e.profileSelect.val())&&document.getElementById("enable-index-status").removeAttribute("disabled")})),a()([".rank-math-wizard-body--analytics .form-footer.rank-math-ui .button-primary",".rank-math_page_rank-math-options-general .form-footer.rank-math-ui .button-primary"].join(", ")).on("click",(function(t){e.submitButtonHandler(t)})),this.propertySelect.on("change",(function(){"create-ga4-property"!==e.propertySelect.val()?(e.response.type=(0,o.get)(e.response.accounts,[e.accountSelect.val(),"properties",e.propertySelect.val(),"type"],{}),"GA4"!==e.response.type&&(e.response.type="GA3",e.response.views=(0,o.get)(e.response.accounts,[e.accountSelect.val(),"properties",e.propertySelect.val(),"profiles"],{})),"GA4"===e.response.type?e.createNewDataStream():e.fillViewSelect()):e.createNewProperty()})),this.viewSelect.on("change",(function(e){var t=a()(e.target).find(":selected");t.data("measurement-id")&&(a()("#rank-math-analytics-measurement-id").val(t.data("measurement-id")),a()("#rank-math-analytics-stream-name").val(t.text()))})),a()(".rank-math-disconnect-google").on("click",(function(e){e.preventDefault(),confirm(rankMath.confirmDisconnect)&&i("disconnect_google").done((function(){window.location.reload()}))}))}},{key:"createNewProperty",value:function(){var e=this;confirm((0,n.__)("Are you sure, you want to create a new GA4 Property?","rank-math"))?i("create_ga4_property",{accountID:this.accountSelect.val()},"post").done((function(t){if(t.error)return e.propertySelect.val(e.propertySelect.find("option:first").val()),void alert(t.error);e.propertySelect.append('<option value="'+t.id+'">'+t.name+"</option>"),e.propertySelect.val(t.id),e.createNewDataStream(),e.response.type="GA4"})):this.propertySelect.val(this.propertySelect.find("option:first").val())}},{key:"createNewDataStream",value:function(){var e=this;this.viewSelect.html(""),this.viewSelect.prop("disabled",!0),i("get_ga4_data_streams",{propertyID:this.propertySelect.val()},"post").done((function(t){t.error?console.error(t.error):(e.response.views=t.streams,e.fillViewSelect(),e.viewSelect.trigger("change"))}))}},{key:"submitButtonHandler",value:function(e){var t=a()(e.target);e.preventDefault(),this.saveConsole(),this.saveAnalytics(),this.saveAdsense(),setTimeout((function(){t.off("click").trigger("click")}),100)}},{key:"saveConsole",value:function(){if(0!==parseInt(this.profileSelect.val())){var e={profile:this.profileSelect.val(),country:this.countryConsole.val(),enableIndexStatus:a()("#enable-index-status").is(":checked")},t=a()("#console_caching_control");t.length>0&&(e.days=t.val()),i("save_analytic_profile",e,"post")}}},{key:"saveAnalytics",value:function(){var e={accountID:this.accountSelect.val(),propertyID:this.propertySelect.val(),viewID:this.viewSelect.val(),country:this.countryAnalytics.val(),installCode:a()("#install-code").is(":checked"),anonymizeIP:a()("#anonymize-ip").is(":checked"),localGAJS:a()("#local-ga-js").is(":checked"),excludeLoggedin:a()("#exclude-loggedin").is(":checked"),measurementID:a()("#rank-math-analytics-measurement-id").val(),streamName:a()("#rank-math-analytics-stream-name").val()};if(0!==parseInt(e.accountID)&&0!==parseInt(e.propertyID)){var t=a()("#console_caching_control");t.length>0&&(e.days=t.val()),i("save_analytic_options",e,"post")}}},{key:"saveAdsense",value:function(){var e={accountID:this.adsenseSelect.val()};e.accountID&&i("save_adsense_account",e,"post")}},{key:"fillSelect",value:function(){var e=this,t=this.response,a=t.inSearchConsole,n=t.isVerified;this.fillProfileSelect(),this.fillAccountSelect(),this.fillAdsenseSelect(),a||i("add_site_console").done((function(t){e.response.sites=t.sites,e.fillProfileSelect()})),a&&!n&&i("verify_site_console"),this.saveChanges=!1}},{key:"fillAdsenseSelect",value:function(){var e=this,t=this.response.adsenseAccounts,a=void 0!==t&&t;!1!==a&&((0,o.map)(a,(function(t,a){e.adsenseSelect.append('<option value="'+a+'">'+t.name+" ("+a+")</option>")})),this.adsenseSelect.data("selected")&&this.adsenseSelect.val(this.adsenseSelect.data("selected")),this.adsenseSelect.prop("disabled",!1),this.adsenseSelect.select2())}},{key:"fillAccountSelect",value:function(){var e=this,t=this.response.accounts;(0,o.map)(t,(function(t,a){e.accountSelect.append('<option value="'+a+'">'+t.name+" ("+a+")</option>")})),this.accountSelect.data("selected")?this.accountSelect.val(this.accountSelect.data("selected")):(this.accountSelect.prop("disabled",!1),this.countryAnalytics.prop("disabled",!1),this.accountSelect.select2(),this.countryAnalytics.select2()),this.accountSelect.trigger("change")}},{key:"fillPropertySelect",value:function(e){var t=this,a=this.response,i=a.accounts,r=a.homeUrl,s=i[e].properties;this.propertySelect.html('<option value="0">Select Property</option>'),this.propertySelect.append('<option value="create-ga4-property">'+(0,n.__)("Create new GA4 Property","rank-math")+"</option>"),(0,o.map)(s,(function(e){var a=e.url===r?' selected="selected"':"";t.propertySelect.append("<option"+a+' value="'+e.id+'">'+e.name+" ("+e.id+")</option>")})),this.propertySelect.data("selected")?this.propertySelect.val(this.propertySelect.data("selected")):(this.propertySelect.prop("disabled",!1),this.propertySelect.select2()),this.propertySelect.trigger("change")}},{key:"fillProfileSelect",value:function(){var e=this,t=this.response,a=t.sites,n=t.homeUrl,i=!1;(0,o.map)(a,(function(t,a){i=a===n?' selected="selected"':"",e.profileSelect.append("<option"+i+' value="'+a+'">'+t+"</option>")})),this.profileSelect.data("selected")&&this.profileSelect.closest(".rank-math-accordion").addClass("connected"),this.profileSelect.prop("disabled",!1),this.countryConsole.prop("disabled",!1),this.profileSelect.select2(),this.countryConsole.select2()}},{key:"fillViewSelect",value:function(){var e=this,t=this.response,a=t.views,i="GA4"===t.type?(0,n.__)("Data Stream","rank-math"):(0,n.__)("View","rank-math");this.viewSelect.prev("label").text(i),(0,o.map)(a,(function(t){var a=(0,o.isUndefined)(t.measurementId)?"":t.measurementId;e.viewSelect.append('<option value="'+t.id+'" data-measurement-id="'+a+'">'+t.name+"</option>")})),this.viewSelect.data("selected")&&this.viewSelect.val(this.viewSelect.data("selected")),this.viewSelect.prop("disabled",!1),this.viewSelect.select2()}}])&&c(t.prototype,r),s&&c(t,s),Object.defineProperty(t,"prototype",{writable:!1}),e}());p=a(),String.prototype.format||(String.prototype.format=function(){var e=arguments;return this.replace(/{(\d+)}/g,(function(t,a){return void 0!==e[a]?e[a]:t}))}),String.prototype.trimRight=function(e){return void 0===e&&(e="s"),this.replace(new RegExp("["+e+"]+$"),"")},p((function(){window.rankMathAdmin={init:function(){this.misc(),this.tabs(),this.dependencyManager(),-1!==Object.values(window.rankMath.modules).indexOf("analytics")&&(d.events(),d.checkAll())},misc:function(){void 0!==a().fn.select2&&p("[data-s2]").select2(),p(".cmb-group-text-only,.cmb-group-fix-me").each((function(){var e=p(this),t=e.find(".cmb-repeatable-group"),a=t.find("> .cmb-row:eq(0) > .cmb-th");e.prepend('<div class="cmb-th"><label>'+a.find("h2").text()+"</label></div>"),t.find(".cmb-add-row").append('<span class="cmb2-metabox-description">'+a.find("p").text()+"</span>"),a.parent().remove()})),p(".rank-math-collapsible-trigger").on("click",(function(e){e.preventDefault();var t=p(this),a=p("#"+t.data("target"));t.toggleClass("open"),a.toggleClass("open")}));var e=p("#rank_math_rich_snippet"),t=e.find("option[value=review]"),n=e.val();t&&(t.prop("disabled",!0),"review"===n&&p(".cmb2-id-rank-math-review-schema-notice").removeClass("hidden"),e.on("change",(function(){null!==e.val()&&"review"!==e.val()&&p(".cmb2-id-rank-math-review-schema-notice").addClass("hidden")})))},searchConsole1:function(){var e=p(".cmb2-id-console-authorization-code"),t=p("#console_authorization_code"),a=p("#gsc-dp-info"),o=p("#console_profile"),s=o.parent().find(".rank-math-refresh"),c=t.parent(),l=p("body").hasClass("rank-math-wizard-body--analytics")?p("> p:first-of-type",".cmb-form"):p("h1",".rank-math-wrap-settings");c.on("click",".rank-math-deauthorize-account",(function(a){a.preventDefault();var c=p(this);if(c.prop("disabled",!0),t.data("authorized"))return i("search_console_deauthentication").always((function(){c.prop("disabled",!1)})).done((function(){t.val(""),t.show(),t.data("authorized",!1),e.removeClass("authorized").addClass("unauthorized"),c.html((0,n.__)("Authorize","rank-math")),o.prop("disabled",!0),s.prop("disabled",!0)})),!1;t.addClass("input-loading"),i("search_console_authentication",{code:t.val()}).always((function(){c.prop("disabled",!1),t.removeClass("input-loading")})).done((function(a){a&&!a.success&&r(a.error,"error",l),a&&a.success&&(t.hide(),t.data("authorized",!0),c.html("De-authorize Account"),s.trigger("click"),o.removeAttr("disabled"),e.removeClass("unauthorized authorizing").addClass("authorized"))}))})),o.on("change",(function(){null!==o.val()&&0===o.val().indexOf("sc-domain:")?a.removeClass("hidden"):a.addClass("hidden")})).change(),s.on("click",(function(e){e.preventDefault(),s.prop("disabled",!0),o.addClass("input-loading"),i("search_console_get_profiles").always((function(){s.prop("disabled",!1),p(".console-cache-update-manually").prop("disabled",!1),o.removeClass("input-loading")})).done((function(e){if(e&&!e.success&&r(e.error,"error",l),e&&e.success){var t=e.selected||o.val();o.html(""),p.each(e.profiles,(function(e,t){o.append('<option value="'+e+'">'+t+"</option>")})),o.val(t||Object.keys(e.profiles)[0]),s.removeClass("hidden")}}))}))},dependencyManager:function(){var e=this,t=p(".cmb-form, .rank-math-metabox-wrap");p(".cmb-repeat-group-wrap",t).each((function(){var e=p(this),t=e.next(".rank-math-cmb-dependency.hidden");t.length&&e.find("> .cmb-td").append(t)})),p(".rank-math-cmb-dependency",t).each((function(){e.loopDependencies(p(this))})),p("input, select",t).on("change",(function(){var t=p(this).attr("name");p('span[data-field="'+t+'"]').each((function(){e.loopDependencies(p(this).closest(".rank-math-cmb-dependency"))}))}))},checkDependency:function(e,t,a){return"string"==typeof t&&t.includes(",")&&"="===a?t.includes(e):"string"==typeof t&&t.includes(",")&&"!="===a?!t.includes(e):"="===a&&e===t||"=="===a&&e===t||">="===a&&e>=t||"<="===a&&e<=t||">"===a&&e>t||"<"===a&&e<t||"!="===a&&e!==t},loopDependencies:function(e){var t=this,a=e.data("relation"),n=null;e.find("span").each((function(){var e=p(this),i=p("[name='"+e.data("field")+"']"),r=i.val();i.is(":radio")&&(r=i.filter(":checked").val()),i.is(":checkbox")&&(r=i.filter(":checked").val());var o=t.checkDependency(r,e.data("value"),e.data("comparison"));if("or"===a&&o)return n=!0,!1;"and"===a&&(n=(null===n||n)&&o)}));var i=e.closest(".rank-math-cmb-group");i.length||(i=e.closest(".cmb-row")),n?i.slideDown(300):i.hide()},tabs:function(){var e,t;t=e||".rank-math-box-tabs",a()(t).children().on("click",(function(e){e.preventDefault();var t=a()(this),n=t.attr("href").substr(1);t.addClass("active-tab").siblings().removeClass("active-tab"),a()("#"+n).addClass("active-tab").siblings().removeClass("active-tab")}));var n=p(".rank-math-tabs-navigation");n.length&&n.each((function(){var e=p(this),t=e.closest(".rank-math-tabs"),a=p(">a",e),i=p(">.rank-math-tabs-content>.rank-math-tab",t),r=e.data("active-class")||"active",o=e.hasClass("before-header");a.on("click",(function(){var e=p(this),n=p(e.attr("href"));if(a.removeClass(r),i.hide(),o){var s=n.find(".cmb-type-title.tab-header").clone();s.addClass("before-header-title"),p(".before-header-title").remove(),t.prepend(s)}return e.addClass(r),n.show(),!1}));var s=window.location.hash||window.localStorage.getItem(t.attr("id"));null===s?a.eq(0).trigger("click"):(s=p('a[href="'+s+'"]',e)).length?s.trigger("click"):a.eq(0).trigger("click"),n.next().css("min-height",e.outerHeight())}))},variableInserter:function(e){var t=p("input[type=text], textarea",".rank-math-supports-variables");if(e=void 0===e||e,t.length){var a,i=this,r=p("body");if(t.attr("autocomplete","off"),t.wrap('<div class="rank-math-variables-wrap"/>'),p(".rank-math-variables-wrap").append('<a href="#" class="rank-math-variables-button button button-secondary"><span class="dashicons dashicons-arrow-down-alt2"></span></a>'),e){var o=rankMath.capitalizeTitle?"capitalize":"";p(".rank-math-variables-wrap").after('<div class="rank-math-variables-preview '+o+'" data-title="'+(0,n.__)("Example","rank-math")+'"/>'),t.on("rank_math_variable_change input",(function(e){var t=p(e.currentTarget),a=i.replaceVariables(t.val());60<a.length&&0<=t.attr("name").indexOf("title")?a=a.substring(0,60)+"...":160<a.length&&0<=t.attr("name").indexOf("description")&&(a=a.substring(0,160)+"...");var n=p("<textarea/>").html(a).val();t.parent().next(".rank-math-variables-preview").text(n)})),t.trigger("rank_math_variable_change")}var s=p("<ul/>"),c=p('<div class="rank-math-variables-dropdown"><input type="text" placeholder="'+(0,n.__)("Search …","rank-math")+'"></div>');p.each(rankMath.variables,(function(){s.append('<li data-var="%'+this.variable+'%" data-example="'+this.example+'"><strong>'+this.name+"</strong><span>"+this.description+"</span></li>")})),c.append(s),p(".rank-math-variables-wrap:eq(0)").append(c);var l=p(".rank-math-variables-button, .rank-math-variables-button *, .rank-math-variables-dropdown, .rank-math-variables-dropdown *");r.on("click",(function(e){p(e.target).is(l)||v()}));var d=c.find("input"),u=c.find("li");r.on("click",".rank-math-variables-button",(function(e){e.preventDefault();var t=p(this);t.after(c),u.show(),void 0!==(a=t.prev().data("exclude-variables"))&&(a=a.split(","),h()),c.show(),d.val("").focus()})),c.on("click","li",(function(e){e.preventDefault();var t=p(this),a=t.closest(".rank-math-variables-wrap").find("input,textarea");a.val(p.trim(a.val())+" "+t.data("var")),a.trigger("rank_math_variable_change").trigger("input"),v()})),c.on("keyup","input",(function(e){e.preventDefault();var t=p(this).val().toLowerCase();if(2>t.length)return u.show(),void h();u.hide().each((function(){var e=p(this);-1!==e.text().toLowerCase().indexOf(t)&&e.show()})),h()}))}function h(){void 0!==a&&a.forEach((function(e){c.find('[data-var="%'+e+'%"]').hide()}))}function v(){a=void 0,c.hide()}},replaceVariables:function(e){return p.each(rankMath.variables,(function(t){if(!this.example)return!0;var a=new RegExp("\\([a-z]+\\)","g");t=t.replace(a,"\\(.*?\\)"),e=e.replace(new RegExp("%+"+t+"%+","g"),this.example)})),e}},window.rankMathAdmin.init()}))}();