Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(a){varc=a.querySelector("[data-members-error]");a.addEventListener("submit",functionr(e){a.removeEventListener("submit",r),e.preventDefault(),c&&(c.innerText=""),a.classList.remove("success","invalid","error");for(vart=e.target.querySelector("input[data-members-email]").value,n=void0,o=[],s=e.target.querySelectorAll("input[data-members-label]")||[],i=0;i<s.length;++i)o.push(s[i].value);a.dataset.membersForm&&(n=a.dataset.membersForm),a.classList.add("loading"),fetch("{{blog-url}}/members/api/send-magic-link/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t,emailType:n,labels:o})}).then(function(e){a.addEventListener("submit",r),a.classList.remove("loading"),e.ok?a.classList.add("success"):(c&&(c.innerText="There was an error sending the email, please try again"),a.classList.add("error"))})})}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(a){varc=a.querySelector("[data-members-error]");a.addEventListener("click",functionr(e){a.removeEventListener("click",r),e.preventDefault();vart,n,o=a.dataset.membersPlan,s=a.dataset.membersSuccess,i=a.dataset.membersCancel;s&&(t=newURL(s,window.location.href).href),i&&(n=newURL(i,window.location.href).href),c&&(c.innerText=""),a.classList.add("loading"),fetch("{{blog-url}}/members/api/session",{credentials:"same-origin"}).then(function(e){returne.ok?e.text():null}).then(function(e){returnfetch("{{blog-url}}/members/api/create-stripe-checkout-session/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({plan:o,identity:e,successUrl:t,cancelUrl:n})}).then(function(e){if(!e.ok)thrownewError("Could not create stripe checkout session");returne.json()})}).then(function(e){returnStripe(e.publicKey).redirectToCheckout({sessionId:e.sessionId})}).then(function(e){if(e.error)thrownewError(e.error.message)}).catch(function(e){console.error(e),a.addEventListener("click",r),a.classList.remove("loading"),c&&(c.innerText=e.message),a.classList.add("error")})})}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(t){varn,o,s=t.querySelector("[data-members-error]"),e=t.dataset.membersSuccess,r=t.dataset.membersCancel;e&&(n=newURL(e,window.location.href).href),r&&(o=newURL(r,window.location.href).href),t.addEventListener("click",functionr(e){t.removeEventListener("click",r),e.preventDefault(),s&&(s.innerText=""),t.classList.add("loading"),fetch("{{blog-url}}/members/api/session",{credentials:"same-origin"}).then(function(e){returne.ok?e.text():null}).then(function(e){returnfetch("{{blog-url}}/members/api/create-stripe-update-session/",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:e,successUrl:n,cancelUrl:o})}).then(function(e){if(!e.ok)thrownewError("Could not create stripe checkout session");returne.json()})}).then(function(e){returnStripe(e.publicKey).redirectToCheckout({sessionId:e.sessionId})}).then(function(e){if(e.error)thrownewError(e.error.message)}).catch(function(e){console.error(e),t.addEventListener("click",r),t.classList.remove("loading"),s&&(s.innerText=e.message),t.classList.add("error")})})}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(t){t.addEventListener("click",functionr(e){t.removeEventListener("click",r),e.preventDefault(),t.classList.remove("error"),t.classList.add("loading"),fetch("{{blog-url}}/members/api/session",{method:"DELETE"}).then(function(e){e.ok?window.location.reload():(t.addEventListener("click",r),t.classList.remove("loading"),t.classList.add("error"))})})}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(n){varo=n.parentElement.querySelector("[data-members-error]");n.addEventListener("click",functionr(e){n.removeEventListener("click",r),e.preventDefault(),n.classList.remove("error"),n.classList.add("loading");vart=n.dataset.membersCancelSubscription;retu