jQuery(document).ready(function(t){"use strict";const n=function(n,a){const e=t(n).parents("td");e.addClass("loading"),t.ajax({type:"GET",url:Gianalytics.endpoint,dataType:"json",data:{nonce:Gianalytics.nonce,action:Gianalytics.action,target:t(n).attr("id").replace("ga-",""),account_id:t("#ga-account").val(),profile_id:t("#ga-profile").val()},success:function(c){if(e.removeClass("loading"),c.success){const e=t("#"+t(n).attr("data-child"));t.each(c.items,function(n,a){const c=document.createElement("option");t(c).attr("value",a.id).text(a.name),e.append(c)}),a&&a(e)}else window.alert(c.message)}})};t(".ga-profile-select","#ga-connection").change(function(){const a=parseInt(t(this).attr("data-clear-target"),10);t("select","#ga-connection").each(function(n,e){n>=a&&t(e).find("option").each(function(n,a){n>0&&t(a).remove()})}),n(this)});const a=t("#ga-account");a.length&&"0"!==a.attr("data-ga-account-id")&&n(a,function(a){a.find("option").each(function(n,e){t(e).attr("value")===a.attr("data-ga-profile-id")&&(t(e).prop("selected",!0),a.addClass("success"))}),"0"!==a.attr("data-ga-profile-id")&&n(a,function(n){n.find("option").each(function(a,e){t(e).attr("value")===n.attr("data-ga-view-id")&&(t(e).prop("selected",!0),n.addClass("success"))})})});const e=function(){"0"!==t(this).val()?t(this).addClass("success"):t(this).removeClass("success")};t("select","#ga-connection").change(e).each(e),t("#cron-checker").submit(function(n){n.preventDefault();const a=this;t(this).ajaxSubmit({dataType:"json",success:function(n){t(a).find("pre").text(JSON.stringify(n.items,function(t,n){return n},4))},error:function(t,n,a){window.alert(a)}})}),t("#ajax-checker").submit(function(n){n.preventDefault();const a=t(this),e=a.find("input[type=radio]:checked");e.length&&(a.find("input[name=_wpnonce]").val(e.attr("data-nonce")),a.ajaxSubmit({dataType:"json",success:function(t){a.find("pre").text(JSON.stringify(t,function(t,n){return n},4))},error:function(t,n,a){window.alert(a)}}))})});