(()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var a in n)e.o(n,a)&&!e.o(t,a)&&Object.defineProperty(t,a,{enumerable:!0,get:n[a]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t)};const t=window.wp.domReady;var n=e.n(t);const a=window.wp.i18n,r="arraysubs-login-as-user-heading-link",s="arraysubspro-member-details-heading-link";n()(()=>{const e=window.arraySubsLoginAsUser;if(!e?.displayName||document.getElementById(r))return;if((()=>{if(document.getElementById(r))return!0;const t=document.getElementById(s),n=document.querySelector(".wrap > h1"),i=t||n;return!!i&&(i.insertAdjacentElement("afterend",(({url:e,displayName:t,isAvailable:n,reason:s})=>{const i=document.createElement(n?"a":"button");return i.id=r,i.className="page-title-action arraysubs-login-as-user-heading-link",n?i.href=e:(i.type="button",i.disabled=!0,i.classList.add("arraysubs-login-as-user-heading-link--disabled"),s&&(i.title=s,i.setAttribute("aria-label",s)))
/* translators: %s: user display name */,i.textContent=(0,a.sprintf)((0,a.__)("Login as %s","arraysubs"),t),i})({url:e.loginUrl,displayName:e.displayName||"",isAvailable:!!e.isAvailable,reason:e.reason||""})),!!t)})())return;let t=0;const n=window.setInterval(()=>{t+=1;const e=document.getElementById(r),a=document.getElementById(s);if(e&&a)return a.insertAdjacentElement("afterend",e),void window.clearInterval(n);t>=12&&window.clearInterval(n)},50)})})();