(()=>{"use strict";var e,t={5582:(e,t,n)=>{var i=n(1622),r=n(8330);window.newspackRAS=window.newspackRAS||[],window.newspackRAS.push(function(e){const t=(e="otp")=>{(0,r.eK)({skipAuthenticatedCheck:!0,skipNewslettersSignup:!0,backButtonClosesModal:!0,initialState:e,closeOnSuccess:!0,skipSuccess:!1,onClose:()=>window.location.reload()})};(0,i.Qc)(function(){const n=document.getElementById("newspack-my-account__newspack-reader-verification"),i=document.querySelectorAll(".newspack__reader-verification");[...i].length&&i.forEach(n=>{const i=n.querySelector("[data-send-otp]"),r=i.closest(".newspack-ui__modal-container");let o=!1;i&&i.addEventListener("click",()=>{i.disabled=!0,(()=>{const t=new FormData;return t.set("action","newspack_reader_registration_verification"),t.set("nonce",reader_registration_block_config.verification_nonce),fetch(reader_registration_block_config.verification_url,{method:"POST",headers:{Accept:"application/json"},body:t}).then(t=>{if(!t.ok)throw new Error(t.statusText);return e.setOTPTimer(),t.json()})})().then(()=>{o=!0,r&&r.setAttribute("data-state","closed"),t("otp")}).catch(()=>{i.disabled=!1,i.textContent=i.textContent.trim();const e=n.querySelector("p:not(:has(button))");e&&(e.textContent="Something went wrong. Please try again.")})}),r&&r.addEventListener("closeModal",()=>{o||window.location.reload()})}),document.querySelectorAll(".newspack-registration").forEach(i=>{const r=i.querySelector("form");if(!r)return;let o=new FormData(r),a=!1;const s=i.querySelector(".newspack-registration__response"),c=r.querySelector('button[type="submit"]'),d=document.createElement("span");d.classList.add("spinner"),r.startLoginFlow=()=>{s.classList.add("newspack-registration--hidden"),s.innerHTML="",c.disabled=!0,c.appendChild(d),i.classList.add("newspack-registration--in-progress")},r.endLoginFlow=(l=null,p=500,u=null)=>{if(a)return;let g;if(u?.existing_user&&!u?.authenticated&&u?.action){const n=u.email||r.npe?.value;if(c.contains(d)&&c.removeChild(d),c.disabled=!1,i.classList.remove("newspack-registration--in-progress"),e.setReaderEmail(n),"otp"===u.action){if(e.getOTPHash())e.setOTPTimer(),t("otp");else{const i=new FormData;i.set("reader-activation-auth-form","1"),i.set("npe",n),i.set("action","link"),fetch(r.getAttribute("action")||window.location.pathname,{method:"POST",headers:{Accept:"application/json"},body:i}).then(n=>{200===n.status?(e.setOTPTimer(),t("otp")):t("signin")}).catch(()=>t("signin"))}return}return void t(u.action)}const h=!u?.existing_user&&reader_registration_block_config.require_account_verification&&!0!==u?.verified,m=i.querySelector(".newspack-registration__registration-success");if(m?.classList.add("newspack-registration--hidden"),l){g=document.createElement("p"),g.textContent=l;const e=m?.querySelector("p");e&&u?.sso&&e.replaceWith(g)}const w=200===p;if(i.classList.add("newspack-registration--"+(w?"success":"error")),w){if(a=!0,h||u?.existing_user||(r.remove(),m.classList.remove("newspack-registration--hidden")),u?.email){if(o=new FormData(r),e.setReaderEmail(u.email),e.setAuthenticated(u?.authenticated),h){u.verification_nonce&&(reader_registration_block_config.verification_nonce=u.verification_nonce);const e=n.querySelector(".email-address");e&&(e.textContent=u.email),n.setAttribute("data-state","open")}if(u.authenticated&&!h){const t={email:u.email},n=o.getAll("lists[]");o.has("newspack_popup_id")&&(t.newspack_popup_id=o.get("newspack_popup_id")),o.has("gate_post_id")&&(t.gate_post_id=o.get("gate_post_id")),u?.sso&&(t.sso=!0),n?.length&&e.dispatchActivity("newsletter_signup",{...t,newsletters_subscription_method:"reader-registration",lists:n}),u?.existing_user?e.dispatchActivity("reader_logged_in",{...t,login_method:u?.metadata?.login_method||"registration-block"}):e.dispatchActivity("reader_registered",{...t,registration_method:u?.metadata?.registration_method||"registration-block"})}}}else g&&(s.appendChild(g),s.classList.remove("newspack-registration--hidden"));c.contains(d)&&c.removeChild(d),c.disabled=!1,i.classList.remove("newspack-registration--in-progress")},r.addEventListener("submit",e=>(e.preventDefault(),r.startLoginFlow(),r.npe?.value?(o=new FormData(r),o.has("npe")&&o.get("npe")?void fetch(r.getAttribute("action")||window.location.pathname,{method:"POST",headers:{Accept:"application/json"},body:o}).then(e=>{e.json().then(({message:t,data:n})=>r.endLoginFlow(t,e.status,n)).catch(()=>r.endLoginFlow("An error occurred.",e.status||400))}).catch(e=>{r.endLoginFlow(e?.message||"An error occurred.",400)}):r.endLoginFlow("Please enter a valid email address.",400)):r.endLoginFlow("Please enter a valid email address.",400))),e.on("reader",({detail:e})=>{e.authenticated&&!a&&r.endLoginFlow(null,200,{existing_user:!0})})})})})}},n={};function i(e){var r=n[e];if(void 0!==r)return r.exports;var o=n[e]={id:e,loaded:!1,exports:{}};return t[e](o,o.exports,i),o.loaded=!0,o.exports}i.m=t,e=[],i.O=(t,n,r,o)=>{if(!n){var a=1/0;for(l=0;l=o)&&Object.keys(i.O).every(e=>i.O[e](n[c]))?n.splice(c--,1):(s=!1,o0&&e[l-1][2]>o;l--)e[l]=e[l-1];e[l]=[n,r,o]},i.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return i.d(t,{a:t}),t},i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.nmd=e=>(e.paths=[],e.children||(e.children=[]),e),i.j=2636,(()=>{var e;i.g.importScripts&&(e=i.g.location+"");var t=i.g.document;if(!e&&t&&(t.currentScript&&"SCRIPT"===t.currentScript.tagName.toUpperCase()&&(e=t.currentScript.src),!e)){var n=t.getElementsByTagName("script");if(n.length)for(var r=n.length-1;r>-1&&(!e||!/^http(s?):/.test(e));)e=n[r--].src}if(!e)throw new Error("Automatic publicPath is not supported in this browser");e=e.replace(/^blob:/,"").replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),i.p=e})(),(()=>{var e={2636:0};i.O.j=t=>0===e[t];var t=(t,n)=>{var r,o,[a,s,c]=n,d=0;if(a.some(t=>0!==e[t])){for(r in s)i.o(s,r)&&(i.m[r]=s[r]);if(c)var l=c(i)}for(t&&t(n);di(5582));r=i.O(r)})();