").addClass("jp-spinner__outer").appendTo(t);n("
").addClass("jp-spinner__inner").appendTo(a),e.after(t)},handleConnectionSuccess:function(e){window.addEventListener("message",c.receiveData),a.attr("src",e.authorizeUrl+"&from="+i),a.on("load",function(){a.show(),n(".jp-connect-full__button-container").hide()}),a.hide(),n(".jp-connect-full__button-container").after(a);var t=document.createElement("link");t.rel="preload",t.as="script",t.href=jpConnect.preFetchScript,document.head.appendChild(t)},fetchPlanType:function(){return n.ajax({url:jpConnect.apiBaseUrl+"/site",type:"GET",data:{_wpnonce:jpConnect.apiSiteDataNonce},success:function(n){var e=JSON.parse(n.data);c.isPaidPlan=e.options.is_pending_plan||!e.plan.is_free}})},receiveData:function(n){if(n.origin===jpConnect.jetpackApiDomain&&n.source===a.get(0).contentWindow)switch(n.data){case"close":window.removeEventListener("message",this.receiveData),c.handleAuthorizationComplete();break;case"wpcom_nocookie":a.hide(),c.handleConnectionError()}},handleAuthorizationComplete:function(){c.isRegistering=!1,
// Fetch plan type late to make sure any stored license keys have been
// attached to the site during the connection.
c.fetchPlanType().always(function(){if(c.isPaidPlan){var n=document.createElement("a");n.href=jpConnect.dashboardUrl;var e=window.location.pathname===n.pathname&&window.location.hash!==n.hash;window.location.assign(jpConnect.dashboardUrl),e&&window.location.reload(!0)}else window.location.assign(jpConnect.plansPromptUrl)})},handleConnectionError:function(n){c.isRegistering=!1,c.handleOriginalFlow()}},r=location.hash.replace(/(#\/setup).*/,"setup");i=location.hash.split("&from=")[1],"setup"===r&&(o.length&&o.hide(),c.selectAndStartConnectionFlow())});