(()=>{if(!globalThis.window?.eddLoginLinkInitialized){void 0!==globalThis.window&&(globalThis.window.eddLoginLinkInitialized=!0);const d="undefined"==typeof edd_login_link_vars?{}:edd_login_link_vars,i=!(!d.enabled||"1"!==d.enabled),o=d.strings||{},a=d.policy||{};function e(e,t,n){if(!e)return;const d=e.querySelector(".edd-login-link__message"),i=e.querySelector("[data-edd-login-link-send]");d&&(d.textContent=t),n&&i&&i.remove(),e.classList.remove("edd-alert","edd-alert-success","edd-alert-error"),n?e.classList.add("edd-alert","edd-alert-success"):e.classList.add("edd-alert","edd-alert-error")}function t(e,t){const n=document.querySelector('[data-edd-login-link="'+e+'"]');n&&(n.hidden=!t)}function n(e){const t={enabled:!0,visibility:"existing_account",default_hidden:!1};return a.contexts?.[e]?{...t,...a.contexts[e]}:t}i&&(document.querySelectorAll("[data-edd-login-link]").forEach((function(e){const t=n(e.dataset.eddLoginLink);t.enabled?e.hidden=!!t.default_hidden:e.hidden=!0})),document.addEventListener("edd:checkout-email-check-complete",(function(e){var d,i;const o=null!==(d=e?.detail?.emailField)&&void 0!==d?d:document.querySelector('[name="edd_email"]'),a=null!==(i=e?.detail?.code)&&void 0!==i?i:"";if(!o?.value?.trim())return void t("checkout-email",!1);const l=function(e,t){const d=n("checkout-email");return!!d.enabled&&("entered_email"===d.visibility?!!e?.value?.trim():"email_used"===t||"edd-customer-email-exists"===t)}(o,a);l&&o&&o.setCustomValidity(""),t("checkout-email",l)})),document.addEventListener("input",(function(e){"edd_email"===e.target?.name&&(e.target.value?.trim()||t("checkout-email",!1))})),document.addEventListener("click",(function(t){const n=t.target.closest("[data-edd-login-link-send]");if(!n)return;const i=n.closest("[data-edd-login-link]");if(!i)return;const a=function(e){return"checkout-login"===e?document.querySelector('[name="edd_user_login"]')||document.getElementById("edd_user_login"):document.querySelector('[name="edd_email"]')}(i.dataset.eddLoginLink);if(!(l=a)||!l.value?.trim())return void(a&&(a.setCustomValidity(o.field_required||""),a.reportValidity(),a.addEventListener("input",(function(){a.setCustomValidity("")}),{once:!0})));var l;a&&a.setCustomValidity("");const c=a?a.value.trim():"";c&&async function(t,n,i){i.disabled=!0;const a=document.createElement("span");a.className="edd-loading-ajax edd-loading",i.after(a);const l=new AbortController,c=setTimeout((function(){l.abort()}),15e3),s=new FormData;s.append("action","edd_send_login_link"),s.append("email",t),d.nonce&&s.append("nonce",d.nonce);try{const t=await fetch(d.ajaxurl,{method:"POST",body:s,signal:l.signal}),i=await t.json();let a="";const c=!!i?.success;a=i?.data?.message?i.data.message:c?o.sent||"":o.error||"",e(n,a,c)}catch{e(n,o.error||"",!1)}finally{clearTimeout(c),a.remove(),i.disabled=!1}}(c,i,n)})))}})();