!function(e){const i=idcL10n.nonce,c=idcL10n.currentUrl,n=idcL10n.apiRoot,t=e(".jp-idc-notice"),o=e(".jp-idc-notice .dops-button"),a=idcL10n.tracksUserData,s=idcL10n.tracksEventData,r=e("#wp-admin-bar-jetpack-idc"),d=e("#jp-idc-confirm-safe-mode-action"),f=e("#jp-idc-fix-connection-action"),p=e("#jp-idc-migrate-action"),l=e("#jp-idc-reconnect-site-action"),u=e(".jp-idc-error__notice");let m=!1;var _;function h(){o.prop("disabled",!0)}function j(){o.prop("disabled",!1)}function k(){u.hide(),S("confirm_safe_mode");const c=n+"jetpack/v4/identity-crisis/confirm-safe-mode";h(),e.ajax({method:"POST",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",i)},url:c,data:{},success:function(){t.hide(),r.removeClass("hide"),window.location.search&&1===window.location.search.indexOf("page=jetpack")&&window.location.reload()},error:function(e){m="confirm",g(e),j()}})}function w(){u.hide(),S("migrate");const c=n+"jetpack/v4/identity-crisis/migrate";h(),e.ajax({method:"POST",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",i)},url:c,data:{},success:function(){t.hide(),e("body").hasClass("toplevel_page_jetpack")&&window.location.reload(!0)},error:function(e){m="migrate",g(e),j()}})}function y(){u.hide(),S("start_fresh");const c=n+"jetpack/v4/identity-crisis/start-fresh";h(),e.ajax({method:"POST",beforeSend:function(e){e.setRequestHeader("X-WP-Nonce",i)},url:c,data:{},success:function(e){window.location=e+"&from=idc-notice"},error:function(e){m="start-fresh",g(e),j()}})}function g(i){const c=e(".jp-idc-error__desc");i&&i.responseJSON&&i.responseJSON.message?c.html(i.responseJSON.message):c.html(""),u.css("display","flex")}function S(e,i){void 0!==i&&"object"==typeof i||(i={}),e&&e.length&&"undefined"!=typeof analytics&&analytics.tracks&&analytics.mc&&(e=0!==(e=e.replace(/-/g,"_")).indexOf("jetpack_idc_")?"jetpack_idc_"+e:e,analytics.tracks.recordEvent(e,i),e=(e=e.replace("jetpack_idc_","")).replace(/_/g,"-"),analytics.mc.bumpStat("jetpack-idc",e))}"undefined"!=typeof analytics&&analytics.initialize(a.userid,a.username),s.isAdmin?S("notice_view"):S("non_admin_notice_view",{page:s.currentScreen}),_=void 0!==_&&_,window.location.search&&-1!==window.location.search.indexOf("jetpack_idc_clear_confirmation")&&(S("clear_confirmation_clicked"),history&&history.pushState?history.pushState({},"",c):_&&(window.location.href=c)),t.on("click",".notice-dismiss",(function(){const e="https:"===window.location.protocol;wpCookies.set("jetpack_idc_dismiss_notice","1",604800,!1,!1,e),S("non_admin_notice_dismiss",{page:s.currentScreen})})),t.on("click","#jp-idc-error__action",(function(){switch(u.hide(),m){case"confirm":k();break;case"start-fresh":y();break;case"migrate":w();break;default:return}})),d.on("click",k),f.on("click",(function(){u.hide(),S("fix_connection"),t.addClass("jp-idc-show-second-step")})),l.on("click",y),p.on("click",w)}(jQuery);