@tryghost/portal 2.64.2 → 2.64.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tryghost/portal",
3
- "version": "2.64.2",
3
+ "version": "2.64.3",
4
4
  "license": "MIT",
5
5
  "repository": "https://github.com/TryGhost/Ghost",
6
6
  "author": "Ghost Foundation",
package/umd/portal.min.js CHANGED
@@ -7537,5 +7537,5 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
7537
7537
  .gh-portal-hide {
7538
7538
  display: none;
7539
7539
  }
7540
- `;function E5({site:e}){return Xm+v5+hL+WL+n6+IL()+pL+uL+mL+_w+H6+M6+q6()+up+W6+w5+x5+Z6+i5+r5+o5+l5+d5+h5+b5}const ah=class ah extends re.Component{constructor(t){super(t),this.state={email:"",token:void 0}}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(t){t.preventDefault(),this.doSignin()}doSignin(){this.setState(t=>({errors:Ll({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:r}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:r,token:i})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}onKeyDown(t){t.keyCode===13&&this.handleSignin(t)}getInputFields({state:t}){const n=t.errors||{};return[{type:"email",value:t.email,placeholder:k("jamie@example.com"),label:k("Email"),name:"email",required:!0,errorMessage:n.email||"",autoFocus:!0},{type:"text",value:t.phonenumber,placeholder:"+1 (123) 456-7890",label:"Phone number",name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}]}renderSubmitButton(){const{action:t}=this.context;let n=!1;const a=t==="signin:running";let i=k(a?"Sending login link...":"Continue");const r=!!a;return t==="signin:failed"&&(i=k("Retry"),n=!0),u.jsx(ze,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:o=>this.handleSignin(o),disabled:r,brandColor:this.context.brandColor,label:i,isRunning:a})}renderSignupMessage(){const{brandColor:t}=this.context;return u.jsxs("div",{className:"gh-portal-signup-message",children:[u.jsx("div",{children:k("Don't have an account?")}),u.jsx("button",{"data-test-button":"signup-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>this.context.doAction("switchPage",{page:"signup"}),children:u.jsx("span",{children:k("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=jl({site:t})&&Sn({site:t});return ea({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Ul,{fields:this.getInputFields({state:this.state}),onChange:(a,i)=>this.handleInputChange(a,i),onKeyDown:(a,i)=>this.onKeyDown(a,i)})}),u.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):u.jsx("section",{children:u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:k("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t}=this.context,n=t.icon;return n?u.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):ea({site:t})?null:u.jsx(Ex,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return ea({site:t})?u.jsx("h1",{className:"gh-portal-main-title",children:k("Sign in")}):u.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return u.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return u.jsxs(u.Fragment,{children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};ah.contextType=H;let Rp=ah;const S5=({handleSignout:e,supportAddress:t=""})=>{const n=`mailto:${t}`;return u.jsxs("footer",{className:"gh-portal-account-footer",children:[u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:a=>e(a),children:k("Sign out")})})}),u.jsx("div",{className:"gh-portal-account-footerright",children:u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,onClick:()=>{n&&window.open(n)},children:k("Contact support")})})})})]})},C5=()=>{const{member:e,brandColor:t}=C.useContext(H),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(Zm,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:k("Your account")})]})},$5=()=>{const{site:e,action:t,brandColor:n,doAction:a}=C.useContext(H);if(!jl({site:e})||!Sn({site:e}))return null;const i=["checkoutPlan:running"].includes(t),r=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return u.jsx(ze,{dataTestId:"view-plans",isRunning:i,label:k("View plans"),onClick:()=>r(),brandColor:n,style:{width:"100%"}})},j5=()=>{const{member:e,site:t}=C.useContext(H),{is_stripe_configured:n}=t;if(!n||Ni({site:t}))return null;const a=Ft({member:e}),i=Qn({member:e});if(i&&!a)return null;if(a){const r=a==null?void 0:a.current_period_end;if(i&&ep({member:e})){const o=ep({member:e}),s=En(o);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(ap({sub:a})){const o=En(a.trial_end_at);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("Your subscription will start on {subscriptionStart}",{subscriptionStart:o})})})}return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("Your subscription will renew on {renewalDate}",{renewalDate:En(r)})})})}return u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx($5,{})]})},T5=()=>{const{member:e,doAction:t,action:n,brandColor:a}=C.useContext(H),i=Ft({member:e});if(!i||!i.cancel_at_period_end)return null;const r=i.cancel_at_period_end?k("Continue subscription"):k("Cancel subscription"),o=["cancelSubscription:running"].includes(n),s=!!o,l=!!i.cancel_at_period_end,c=()=>{if(!i.cancel_at_period_end)return null;const p=i.current_period_end;return u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("Your subscription will expire on {expiryDate}",{expiryDate:En(p)})})};return u.jsxs("div",{className:"gh-portal-cancelcontinue-container",children:[u.jsx(c,{}),u.jsx(ze,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:o,disabled:s,isPrimary:l,brandColor:a,label:r,style:{width:"100%"}})]})},Hx=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},C.createElement("defs",null,C.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),C.createElement("path",{d:"M22.939 2.56V8.817C22.9391 9.61244 22.6232 10.3754 22.061 10.938L10.5 22.5C10.2187 22.7812 9.83721 22.9392 9.43946 22.9392C9.04172 22.9392 8.66026 22.7812 8.37896 22.5L1.49997 15.62C1.21876 15.3387 1.06079 14.9572 1.06079 14.5595C1.06079 14.1618 1.21876 13.7803 1.49997 13.499L13.061 1.938C13.6236 1.37572 14.3865 1.0599 15.182 1.06H21.439C21.8368 1.06 22.2183 1.21803 22.4996 1.49934C22.7809 1.78064 22.939 2.16217 22.939 2.56V2.56Z",className:"a"}),C.createElement("path",{d:"M17.689 7.81C16.8605 7.81 16.189 7.13842 16.189 6.31C16.189 5.48157 16.8605 4.81 17.689 4.81C18.5174 4.81 19.189 5.48157 19.189 6.31C19.189 7.13842 18.5174 7.81 17.689 7.81Z",className:"a"})),P5=()=>{const{member:e,site:t,doAction:n}=C.useContext(H),a=()=>{const m=Ft({member:e});n("manageBilling",{subscriptionId:m.id})},i=()=>{const{is_stripe_configured:m}=t;m&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},r=({price:m,isComplimentary:g,subscription:v})=>{const{next_payment:S}=v||{};let b="";if(m){const{amount:R=0,currency:_,interval:D}=m;b=`${Intl.NumberFormat("en",{currency:_,style:"currency"}).format(R/100)}/${k(D)}`}const w=ep({member:e});g&&(w?b=`${k("Complimentary")} - ${k("Expires {expiryDate}",{expiryDate:w})}`:b=b?`${k("Complimentary")} (${b})`:k("Complimentary"));let E="";if(ap({sub:v}))return E="gh-portal-account-old-price",u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(z5,{subscription:v})]});if(YU({sub:v}))return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(A5,{nextPayment:S})]});let M=N5({nextPayment:S});M&&(E="gh-portal-account-old-price");const z=()=>M?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(Hx,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:M})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(z,{})]})},o=({isPaid:m})=>Ni({site:t})&&!m?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:g=>i(),"data-test-button":"change-plan",children:k("Change")}),s=({defaultCardLast4:m})=>{if(m){const g=`**** **** **** ${m}`;return u.jsx("p",{children:g})}return null},l=({defaultCardLast4:m,isComplimentary:g})=>{const{action:v}=C.useContext(H),S=v==="manageBilling:running"?u.jsx(Ii,{className:"gh-portal-billing-button-loader"}):k("Update");return g?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k("Billing info & receipts")}),u.jsx(s,{defaultCardLast4:m})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:b=>a(),"data-test-button":"manage-billing",children:S})]})},c=Ft({member:e}),p=Qn({member:e}),f=an({member:e});if(c||p){const{price:m,default_payment_card_last4:g}=c||{};let v=k("Plan");return Tl({site:t})&&Yw({member:e})&&(v=Yw({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v}),u.jsx(r,{price:m,isComplimentary:p,subscription:c})]}),u.jsx(o,{isPaid:f})]}),u.jsx(l,{isComplimentary:p,defaultCardLast4:g})]})}return null};function z5({subscription:e}){if(ap({sub:e})){const t=En(e.trial_end_at);return u.jsx("p",{className:"gh-portal-account-discountcontainer",children:u.jsx("div",{children:u.jsx("span",{children:k("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function A5({nextPayment:e}){const t=e.discount.amount,n=t===1?"1 month free":`${t} months free`;return u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(Hx,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:n})]})}function N5({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";let n="";t.duration==="forever"?n=k("Forever"):t.duration==="once"?n=k("Next payment"):t.duration==="repeating"&&t.end&&(n=k("Ends {offerEndDate}",{offerEndDate:En(t.end)}));const a=Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100);let i="";return t.duration==="once"?i=a:i=`${a}/${e.interval}`,`${i}${n?` — ${n}`:""}`}function I5(){const{member:e,site:t,doAction:n}=C.useContext(H);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let r=k(i?"Subscribed":"Unsubscribed");const o=s=>{var p;s.preventDefault();const l=za({site:t}),c=(p=e==null?void 0:e.newsletters)!=null&&p.length?[]:l;n("updateNewsletterPreference",{newsletters:c})};return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[u.jsx("h3",{children:k("Email newsletter")}),u.jsxs("p",{children:[r," ",ip({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:k("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Ol,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{o(s)},checked:i})})]})}const Wx=e=>C.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},C.createElement("path",{d:"m12.79 12.376 4.08 4.079m-4.08 0 4.08-4.08",stroke:"red",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}),C.createElement("path",{d:"m10.439 17.994-2.664-2.652-2.86 1.478.111-4.239m0 0L1.677 9.232a1.344 1.344 0 0 1-.366-1.222 1.369 1.369 0 0 1 .904-1.05l13.111-4.374a1.369 1.369 0 0 1 1.76 1.758L15 10m-9.974 2.581 11.67-9.727",stroke:"#A3A3A3",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}));function M5(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(Wx,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:k("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:k("You're currently not receiving emails")})]})}function F5(){const{doAction:e,member:t,site:n}=C.useContext(H),a=Hw({member:t}),i=oo({site:n}),r=Pl({site:n}),o=a?"emailSuppressed":"accountEmail",s=!i&&!r,l=()=>a||s?u.jsx(M5,{}):u.jsx("p",{children:k("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k("Emails")}),l()]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:o,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:k("Manage")})]})}const D5=()=>{const{member:e,site:t}=C.useContext(H),a=t.transistor_portal_settings||{enabled:t.transistor_portal_enabled===!0,heading:t.transistor_portal_heading,description:t.transistor_portal_description,button_text:t.transistor_portal_button_text,url_template:t.transistor_portal_url_template},i=(a==null?void 0:a.enabled)===!0,r=e==null?void 0:e.uuid,o=Zw(),[s,l]=C.useState(o&&i);return C.useEffect(()=>{if(o){l(i);return}if(!i||!r){l(!1);return}l(!1);const c=new AbortController;return(async()=>{try{const f=await fetch(`https://partner.transistor.fm/ghost/member/${r}`,{signal:c.signal});if(f.ok){const m=await f.json();c.signal.aborted||l((m==null?void 0:m.member)===!0)}}catch(f){if(c.signal.aborted)return;console.warn("Error in Transistor request",f)}})(),()=>c.abort()},[i,r,o]),{transistor:{enabled:i,hasPodcasts:s,memberUuid:r,settings:a}}},O5=(e,t)=>lo({site:e})&&oo({site:e})||Pl({site:e})||Hw({member:t}),_5=e=>!lo({site:e})&&oo({site:e})&&!Pl({site:e}),R5=()=>{const{member:e,doAction:t,site:n}=C.useContext(H),{name:a,email:i}=e,{transistor:r}=D5(),o=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=O5(n,e),l=_5(n);return u.jsx("div",{children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:a||k("Account")}),u.jsx("p",{children:i})]}),u.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:c=>o(),children:k("Edit")})]}),u.jsx(P5,{}),s&&u.jsx(F5,{}),l&&u.jsx(I5,{}),r.enabled&&u.jsx(k5,{hasPodcasts:r.hasPodcasts,memberUuid:r.memberUuid,settings:r.settings})]})})},U5=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(Oe,{}),u.jsx(C5,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(j5,{}),u.jsx(T5,{}),u.jsx(R5,{})]})]}),ih=class ih extends re.Component{componentDidMount(){const{member:t,site:n}=this.context;ea({site:n})||this.context.doAction("signout"),t||this.context.doAction("switchPage",{page:"signin",pageData:{redirect:window.location.href}})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}render(){const{member:t,site:n}=this.context,a=uo({site:n});return!t||!ea({site:n})?null:u.jsxs("div",{className:"gh-portal-account-wrapper",children:[u.jsx(U5,{}),u.jsx(S5,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ih.contextType=H;let Up=ih;const rh=class rh extends re.Component{constructor(t,n){super(t,n);const{name:a="",email:i=""}=n.member||{};this.state={name:a,email:i}}componentDidMount(){const{member:t}=this.context;t||this.context.doAction("switchPage",{page:"signin"})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(t){t.preventDefault(),this.setState(n=>({errors:Ll({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(o=>!!o).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=k("Save");this.context.action==="updateProfile:failed"&&(n=k("Retry"));const a=!!t;return u.jsx(ze,{dataTestId:"save-button",isRunning:t,onClick:i=>this.onProfileSave(i),disabled:a,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return u.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:k("Delete account")})}renderAccountFooter(){return u.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),u.jsx("h3",{className:"gh-portal-main-title",children:k("Account settings")})]})}renderUserAvatar(){const t=this.context.member&&this.context.member.avatar_image,n={position:"relative",display:"flex",width:"64px",height:"64px",marginBottom:"6px",borderRadius:"100%",boxShadow:"0 0 0 3px #fff",border:"1px solid gray",overflow:"hidden",justifyContent:"center",alignItems:"center"};return u.jsx("div",{style:n,children:u.jsx(Zm,{gravatar:t,style:{userIcon:{color:"black",width:"56px",height:"56px"}}})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}getInputFields({state:t,fieldNames:n}){const a=t.errors||{},i=[{type:"text",value:t.name,placeholder:k("Jamie Larson"),label:k("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:k("jamie@example.com"),label:k("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(r=>n.includes(r.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return u.jsx("div",{className:"gh-portal-section",children:u.jsx(Ul,{fields:this.getInputFields({state:this.state}),onChange:(t,n)=>this.handleInputChange(t,n),onKeyDown:(t,n)=>this.onKeyDown(t,n)})})}render(){const{member:t}=this.context;return t?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),this.renderHeader(),u.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};rh.contextType=H;let Lp=rh;function L5(){const{brandColor:e,lastPage:t,doAction:n}=C.useContext(H);return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx("h3",{className:"gh-portal-main-title",children:k("Email preferences")})]})}function Y5({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){const a=t.some(i=>i.id===(e==null?void 0:e.id));return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:e.name}),u.jsx("p",{children:e==null?void 0:e.description})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Ol,{id:e.id,onToggle:(i,r)=>{let o=[];r?o=t.filter(s=>s.id!==e.id).concat(e):o=t.filter(s=>s.id!==e.id),n(o)},checked:a,dataTestId:"switch-input"})})]})}function B5({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=C.useContext(H),i=!!n;if(!t)return null;const r=async(o,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:k("Comment preferences updated.")})};return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k("Comments")}),u.jsx("p",{children:k("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Ol,{id:"comments",onToggle:r,checked:i,dataTestId:"switch-input"})})]})}function V5({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=C.useContext(H),i=za({site:a});return n?i.map(r=>u.jsx(Y5,{newsletter:r,subscribedNewsletters:e,setSubscribedNewsletters:t},r==null?void 0:r.id)):null}function H5({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:k("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Gx({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:r,isPaidMember:o,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:p,member:f,site:m}=C.useContext(H),g=!(n!=null&&n.length)&&(s&&!l||!s),S=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),u.jsx(L5,{}),u.jsx(S,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(V5,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:b=>{let w=b.map(E=>({id:E.id}));a(w)}}),u.jsx(B5,{isCommentsEnabled:s,enableCommentNotifications:l,updateCommentNotifications:i})]})}),u.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:u.jsx(ze,{isRunning:!1,onClick:()=>{r()},disabled:g,brandColor:c,isPrimary:!1,label:k("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(ip({member:f})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(H5,{isPaid:o,site:m,subscribedNewsletters:n})}),ip({member:f})&&!g&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:k("Not receiving emails?")}),u.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>p("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[k("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function W5(){const{member:e,doAction:t,site:n,pageData:a}=C.useContext(H);let i,r;a&&(i=a.newsletterUuid,r=a.action);const[o,s]=C.useState(!0),l=za({site:n}),c=oo({site:n});C.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),C.useEffect(()=>{if(i&&r==="unsubscribe"){const b=e==null?void 0:e.newsletters.filter(w=>w.uuid!==i);g(b),s(!1),t("updateNewsletterPreference",{newsletters:b})}},[]);const p=()=>{if(a.comments&&v){const E=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${E}`,children:u.jsx(ut,{string:k("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email})}})})})}const b=l==null?void 0:l.find(E=>E.uuid===a.newsletterUuid);if(!b)return null;const w=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${w}`,children:u.jsx(ut,{string:k("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:u.jsx("strong",{children:b==null?void 0:b.name})}})})})},f=[...(e==null?void 0:e.newsletters)||[]],[m,g]=C.useState(f),{comments_enabled:v}=n,{enable_comment_notifications:S}=e||{};return C.useEffect(()=>{g((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(Gx,{hasNewslettersEnabled:c,notification:i?p:null,subscribedNewsletters:m,updateSubscribedNewsletters:b=>{g(b),t("updateNewsletterPreference",{newsletters:b}),t("showPopupNotification",{action:"updated:success",message:k("Email preferences updated.")})},updateCommentNotifications:async b=>{t("updateNewsletterPreference",{enableCommentNotifications:b})},unsubscribeAll:()=>{g([]),t("showPopupNotification",{action:"updated:success",message:k("Unsubscribed from all emails.")});const b={newsletters:[]};v&&(b.enableCommentNotifications=!1),t("updateNewsletterPreference",b)},isPaidMember:an({member:e}),isCommentsEnabled:v!=="off",enableCommentNotifications:S})}function G5(){const{site:e}=C.useContext(H),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function K5(){const{site:e}=C.useContext(H),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(G5,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Kx({api:e,memberUuid:t,key:n,newsletters:a,enableCommentNotifications:i}){try{return await e.member.updateNewsletters({uuid:t,key:n,newsletters:a,enableCommentNotifications:i})}catch{}}function q5(){const{site:e,api:t,pageData:n,member:a,doAction:i}=C.useContext(H),[r,o]=C.useState(),[s,l]=C.useState(!0),c=za({site:e}),p=c.filter(_=>_.subscribe_on_signup),[f,m]=C.useState(!1),[g,v]=C.useState(p),[S,b]=C.useState(!1),{comments_enabled:w}=e,{enable_comment_notifications:E=!1}=r||{},P=oo({site:e}),j=async _=>{a?i("updateNewsletterPreference",{newsletters:_}):await Kx({api:t,memberUuid:n.uuid,key:n.key,newsletters:_}),v(_);const D={action:"updated:success",message:k("Email preferences updated.")};i("showPopupNotification",D)},M=async _=>{let D;a?(await i("updateNewsletterPreference",{enableCommentNotifications:_}),D={...a,enable_comment_notifications:_}):D=await Kx({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:_}),o(D),i("showPopupNotification",{action:"updated:success",message:k("Comment preferences updated.")})},z=async()=>{let _;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),_={...a},_.newsletters=[],_.enable_comment_notifications=!1):_=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),v([]),o(_),i("showPopupNotification",{action:"updated:success",message:k("Unsubscribed from all emails.")})};if(C.useEffect(()=>{(async()=>{let _;try{_=await t.member.newsletters({uuid:n.uuid,key:n.key}),o(_??null),l(!1)}catch(X){console.error("[PORTAL] Error fetching member newsletters",X),o(null),l(!1);return}if(_===null)return;const D=(_==null?void 0:_.newsletters)||[];v(D),(c==null?void 0:c.length)===1&&!w&&!n.newsletterUuid?await j([]):n.newsletterUuid?await j(D==null?void 0:D.filter(X=>X.uuid!==n.newsletterUuid)):n.comments&&w&&await M(!1)})()},[w,n.uuid,n.newsletterUuid,n.comments,e.url,c==null?void 0:c.length]),s)return u.jsx(ko,{});if(!r)return u.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:u.jsx(dp,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:k("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:k("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),u.jsx(ze,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:k("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!w&&!S)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(Oe,{}),u.jsx(K5,{}),u.jsx("h1",{className:"gh-portal-main-title",children:k("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:k("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})}),u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:k("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:u.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{b(!0)}})}})})]})]});const R=()=>{if(n.comments&&w){const X=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${X}`,children:u.jsx(ut,{string:k("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})})})}const _=c==null?void 0:c.find(X=>X.uuid===n.newsletterUuid);if(!_)return null;const D=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${D}`,children:u.jsx(ut,{string:k("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email}),newsletterName:u.jsx("strong",{children:_==null?void 0:_.name})}})})})};return u.jsx(Gx,{hasNewslettersEnabled:P,notification:R,subscribedNewsletters:g,updateSubscribedNewsletters:async _=>{await j(_),m(!0)},updateCommentNotifications:M,unsubscribeAll:async()=>{await z(),m(!0)},isPaidMember:(r==null?void 0:r.status)!=="free",isCommentsEnabled:w!=="off",enableCommentNotifications:E})}function J5(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=C.useContext(H);C.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(lo({site:i})||Pl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:k("You have been successfully resubscribed")})):n("back"))},[a,n,i,k]);const r=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),o=()=>{n("removeEmailFromSuppressionList")};return u.jsxs("div",{className:"gh-email-suppressed-page",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx(Oe,{})]}),u.jsx(Wx,{className:"gh-email-suppressed-page-icon"}),u.jsxs("div",{className:"gh-email-suppressed-page-text",children:[u.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:k("Emails disabled")}),u.jsx("p",{children:k("You're not receiving emails because you either marked a recent message as spam, or because messages could not be delivered to your provided email address.")})]}),u.jsx(ze,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:o,disabled:r,brandColor:e,label:k("Re-enable emails"),isRunning:r})]})}function Z5(){const{brandColor:e,doAction:t,site:n,pageData:a}=C.useContext(H),i=`mailto:${uo({site:n})}`,r=a&&a.direct||!1;return u.jsxs("div",{className:"gh-email-suppression-faq",children:[!r&&u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:k("Why has my email been disabled?")}),u.jsx("p",{children:k("Newsletters can be disabled on your account for two reasons: A previous email was marked as spam, or attempting to send an email resulted in a permanent failure (bounce).")}),u.jsx("h4",{children:k("Spam complaints")}),u.jsx("p",{children:k("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),u.jsx("p",{children:k("If the spam complaint was accidental, or you would like to begin receiving emails again, you can resubscribe to emails by clicking the button on the previous screen.")}),u.jsx("p",{children:k("Once resubscribed, if you still don't see emails in your inbox, check your spam folder. Some inbox providers keep a record of previous spam complaints and will continue to flag emails. If this happens, mark the latest newsletter as 'Not spam' to move it back to your primary inbox.")}),u.jsx("h4",{children:k("Permanent failure (bounce)")}),u.jsx("p",{children:k("When an inbox fails to accept an email it is commonly called a bounce. In many cases, this can be temporary. However, in some cases, a bounced email can be returned as a permanent failure when an email address is invalid or non-existent.")}),u.jsx("p",{children:k("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),u.jsx("p",{children:k("If you would like to start receiving emails again, the best next steps are to check your email address on file for any issues and then click resubscribe on the previous screen.")}),u.jsx("p",{children:u.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:i,onClick:()=>{i&&window.open(i)},children:k("Need more help? Contact support")})})]})]})}function X5(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:r}=C.useContext(H),o=uo({site:n}),s=`mailto:${o}`,l=GU({site:n}),c=r&&r.direct||!1;return u.jsxs("div",{className:"gh-email-receiving-faq",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[!c&&u.jsx(Mi,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:k("Help! I'm not receiving emails")}),u.jsx("p",{children:k("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:k("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(ut,{string:k("The email address we have for you is {memberEmail} — if that's not correct, you can update it in your <button>account settings area</button>."),mapping:{memberEmail:u.jsx("strong",{children:i.email}),button:u.jsx("button",{className:"gh-portal-btn-text",onClick:()=>t("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),u.jsx("h4",{children:k("Check spam & promotions folders")}),u.jsx("p",{children:k(`Make sure emails aren't accidentally ending up in the Spam or Promotions folders of your inbox. If they are, click on "Mark as not spam" and/or "Move to inbox".`)}),u.jsx("h4",{children:k("Create a new contact")}),u.jsx("p",{children:u.jsx(ut,{string:k("In your email client add {senderEmail} to your contacts list. This signals to your mail provider that emails sent from this address should be trusted."),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:k("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(ut,{string:k("Send an email to {senderEmail} and say hello. This can also help signal to your mail provider that emails to and from this address should be trusted."),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:k("Check with your mail provider")}),u.jsx("p",{children:u.jsx(ut,{string:k("If you have a corporate or government email account, reach out to your IT department and ask them to allow emails to be received from {senderEmail}"),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:k("Get in touch for help")}),u.jsx("p",{children:u.jsx(ut,{string:k("If you've completed all these checks and you're still not receiving emails, you can reach out to get support by contacting {supportAddress}."),mapping:{supportAddress:u.jsx("a",{href:s,onClick:()=>{s&&window.open(s)},children:o})}})})]})]})}const Yp={signin:Rp,signup:Mp,accountHome:Up,accountPlan:xp,accountProfile:Lp,accountEmail:W5,signupNewsletter:Sp,unsubscribe:q5,magiclink:Fp,loading:ko,offer:Op,feedback:a5,emailSuppressed:J5,emailSuppressionFAQ:Z5,emailReceivingFAQ:X5,support:()=>{const[e,t]=C.useState(!0),[n,a]=C.useState(null),[i,r]=C.useState(null),{member:o,site:s}=C.useContext(H);return C.useEffect(()=>{async function l(){const c=s.url,p=window.location.origin+window.location.pathname,f=o?`${p}?action=support&success=true`:`${p}#/portal/support/success`,m=p,g=Wl({siteUrl:c});try{const v=await g.member.checkoutDonation({successUrl:f,cancelUrl:m,personalNote:k("Add a personal note")});v.url&&window.location.replace(v.url)}catch(v){v.type&&v.type==="DisabledFeatureError"?r(k("This site is not accepting payments at the moment.")):a(k("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(r(k("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(ko,{})}):n?u.jsx(_p,{error:n}):i?u.jsx(_p,{error:i}):null},supportSuccess:u5,supportError:_p,recommendations:y5},Bp=function({page:e}){return Object.keys(Yp).includes(e)?e:"signup"},qx=function({page:e}){return e.includes("account")},Q5=function({page:e}){return e.includes("offer")},e8=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},C.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM11.8326 2.33879C6.37785 2.95189 3.95901 5.20797 3.41126 9.74699C3.34896 10.2632 3.22642 10.7805 3.10443 11.2954C2.93277 12.02 2.76221 12.74 2.76221 13.4458C2.76221 17.9885 6.5856 21.556 11.1283 21.556C12.8959 21.556 14.4433 20.8144 15.8756 20.048C19.0536 18.3478 22.0328 16.2597 22.0328 12.5411C22.0328 9.91512 20.1051 7.56932 18.466 5.5747C18.3834 5.47416 18.3015 5.37451 18.2206 5.27577C17.3866 4.25742 14.4333 2.04643 11.8326 2.33879Z",fill:"#15171A"})),oh=class oh extends re.Component{render(){return u.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",onClick:()=>{window.open("https://ghost.org","_blank")},children:[u.jsx(e8,{}),"Powered by Ghost"]})}};oh.contextType=H;let Gl=oh;const Jx=()=>({modalContainer:{zIndex:"3999999",position:"fixed",left:"0",top:"0",width:"100%",height:"100%",overflow:"hidden"},frame:{common:{margin:"auto",position:"relative",padding:"0",outline:"0",width:"100%",opacity:"1",overflow:"hidden",height:"100%"}},page:{links:{width:"600px"}}});function t8({message:e}){return Ai()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const sh=class sh extends re.Component{componentDidMount(){this.node&&!$e(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=t=>{t.key==="Escape"&&this.dismissPopup(t)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(t){var i;const n=t.target&&t.target.tagName;(n!=="INPUT"||n==="INPUT"&&!((i=t==null?void 0:t.target)!=null&&i.value))&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){var t,n;this.node&&$e(["preview"])&&((t=this.node)==null?void 0:t.clientHeight)!==this.lastContainerHeight&&(this.lastContainerHeight=(n=this.node)==null?void 0:n.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(t){const{page:n,otcRef:a}=this.context;$e(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;Bp({page:t});const n=Yp[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(Dp,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:t,pageQuery:n,site:a,customSiteUrl:i}=this.context,o=Nl({site:a,pageQuery:n}).length;Bp({page:t});const l={...Jx().page[t]};let c="",p="regular",f="",m=t;switch(t){case"signup":f="Cookies must be enabled in your browser to sign up.";break;case"signin":f="Cookies must be enabled in your browser to sign in.";break;case"accountHome":m="account-home";break;case"accountProfile":m="account-profile";break;case"accountPlan":m="account-plan";break;default:f="Cookies must be enabled in your browser.",m=t;break}o>1&&!rn({site:a})&&Sn({site:a,pageQuery:n})&&t==="signup"&&(m+=" full-size",p="full");const g=so({site:a});(g&&o>2||!g&&o>1)&&t==="accountPlan"&&(m+=" full-size",p="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(m+=" large-size");let v="gh-portal-popup-container";$e(["preview"])&&(m+=" preview"),$e(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(v+=" preview"),$e(["dev"])&&(v+=" dev");const S=`${v} ${c} ${m}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+m,onClick:b=>this.handlePopupClose(b),children:[this.renderPopupNotification(),u.jsxs("div",{className:S,style:l,ref:b=>this.node=b,tabIndex:-1,children:[u.jsx(t8,{message:f}),this.renderActivePage(),p==="full"?u.jsx("div",{className:"gh-portal-powered inside "+($e(["preview"])?"hidden ":"")+m,children:u.jsx(Gl,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+($e(["preview"])?"hidden ":"")+m,children:u.jsx(Gl,{})})]})}};sh.contextType=H;let Vp=sh;const lh=class lh extends re.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=Yp[t];return u.jsx(n,{})}onHeightChange(t){this.setState({height:t})}handlePopupClose(t){t.preventDefault(),t.target===t.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:t,brandColor:n}=this.context,a=E5({site:t}),i=n?`:root { --brandcolor: ${n} }`+a:a;return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:i}}),u.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:t,site:n,customSiteUrl:a}=this.context,i=Jx(),r=window.innerWidth<480,o={...i.frame.common};let s="gh-portal-popup-background";return $e(["preview"])&&(i.modalContainer.zIndex="3999997"),$e(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),$e(["dev"])&&(s+=" dev"),u.jsx("div",{style:i.modalContainer,children:u.jsxs(qm,{style:o,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[u.jsx("div",{className:s,onClick:l=>this.handlePopupClose(l)}),u.jsx(Vp,{isMobile:r})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};lh.contextType=H;let Hp=lh;Kl({products:Wp({numOfProducts:1})});function at(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function n8(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Kl({title:e="The Blueprint",description:t="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:i="https://portal.localhost",plans:r={monthly:5e3,yearly:15e4,currency:"USD"},products:o=Wp({numOfProducts:1}),portalProducts:s=o.map(X=>X.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:p="all",freePriceName:f="Free",freePriceDescription:m="Free preview",isStripeConfigured:g=!0,portalButton:v=!0,portalName:S=!0,portalButtonIcon:b="icon-1",portalButtonSignupText:w="Subscribe now",portalButtonStyle:E="icon-and-text",membersSupportAddress:P="support@example.com",editorDefaultEmailRecipients:j="visibility",newsletters:M=[],posts:z=a8(),commentsEnabled:R,recommendations:_=[],recommendationsEnabled:D}={}){return{title:e,description:t,logo:n,icon:a,accent_color:l,url:i,plans:r,products:o,portal_products:s,members_signup_access:p,free_price_name:f,free_price_description:m,is_stripe_configured:g,portal_button:v,portal_name:S,portal_plans:c,portal_button_icon:b,portal_button_signup_text:w,portal_button_style:E,members_support_address:P,comments_enabled:R!=="off",newsletters:M,recommendations:_,recommendations_enabled:!!D,editor_default_email_recipients:j,posts:z}}function Zx({name:e="Black Friday",code:t="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:a="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:i="percent",cadence:r="month",amount:o=50,duration:s="repeating",durationInMonths:l=null,currencyRestriction:c=!1,currency:p=null,status:f="active",tierId:m="",tierName:g="Basic",redemptionType:v="signup"}={}){return{id:`offer_${at()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:r,amount:o,duration:s,duration_in_months:l,currency_restriction:c,currency:p,status:f,tier:{id:`${m}`,name:g},redemption_type:v}}function Ht({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:r="",subscribed:o=!0,email_suppression:s={suppressed:!1,info:null},newsletters:l=[]}={}){return{uuid:n8(),email:t,name:e,firstname:n,paid:i,subscribed:o,avatar_image:r,subscriptions:a,email_suppression:s,newsletters:l}}function a8({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(i8({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function i8({id:e=`post_${at()}`,title:t="Post",excerpt:n="Post excerpt",slug:a="post",featured:i=!1}={}){return{id:e,title:t,excerpt:n,slug:a,featured:i}}function Wp({numOfProducts:e=3}={}){const n=[Oi({name:"Bronze",description:"Access to all members articles",monthlyPrice:Ot({interval:"month",amount:700}),yearlyPrice:Ot({interval:"year",amount:7e3}),numOfBenefits:2}),Oi({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:12e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:Ot({interval:"month",amount:18e3}),yearlyPrice:Ot({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=Xx({});return[...n,a]}function Oi({type:e="paid",name:t="Basic",description:n="",id:a=`product_${at()}`,monthlyPrice:i=Ot(),yearlyPrice:r=Ot({interval:"year"}),numOfBenefits:o=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:r,type:e,benefits:Qx({numOfBenefits:o}),trial_days:s}}function Xx({name:e="Free tier",description:t="Free tier description",id:n=`product_${at()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:Qx({numOfBenefits:a})}}function Qx({numOfBenefits:e}){const t=at();return[ql({name:`Limited early adopter pricing #${t.substring(0,6)}`}),ql({name:`Latest gear reviews #${t.substring(6,12)}`}),ql({name:`Weekly email newsletter #${t.substring(12,18)}`}),ql({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function ql({id:e=`benefit_${at()}`,name:t="Benefit"}){return{id:e,name:t}}function Ot({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:r=!0,id:o=`price_${at()}`}={}){return{id:o,active:r,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${at()}`,stripe_product_id:`prod_${at()}`,type:"recurring"}}function Na({id:e=`sub_${at()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:r=a==="month"?"Monthly":"Yearly",cardLast4:o="4242",offer:s=o8,priceId:l=`price_${at()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:p="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:f=!1,trialEndAt:m=null,nextPayment:g=null,tier:v=null}={}){return{id:e,customer:{id:`cus_${at()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${at()}`,nickname:r,amount:i,interval:a,currency:n},offer:s,status:t,start_date:c,default_payment_card_last4:o,cancel_at_period_end:f,cancellation_reason:null,current_period_end:p,trial_end_at:m,next_payment:g,tier:v,price:{id:`stripe_price_${at()}`,price_id:l,nickname:r,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${at()}`,product_id:`prod_${at()}`}}}}function eE(){const e=Wp({numOfProducts:1}),t=e.map(a=>a.id);return Kl({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}eE();const r8=Kl({products:[Oi({numOfBenefits:2,type:"free"})]}),o8=Zx({tierId:(rE=r8.products[0])==null?void 0:rE.id});Ht(),Ht({paid:!0,subscriptions:[Na()]}),Ht({paid:!0,subscriptions:[]}),Ht({paid:!0,subscriptions:[Na({amount:0})]}),Ht({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),eE();const Jl=[Xx({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Oi({name:"The Blueprint",description:"",monthlyPrice:Ot({interval:"month",amount:500}),yearlyPrice:Ot({interval:"year",amount:5e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:11e3}),numOfBenefits:4})],_i=Kl({title:"The Blueprint",description:"Thoughts, stories and ideas.",logo:"https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:"https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",accentColor:"#45C32E",url:"https://portal.localhost",plans:{monthly:5e3,yearly:15e4,currency:"USD"},products:Jl,portalProducts:Jl.map(e=>e.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",isStripeConfigured:!0,portalButton:!0,portalName:!0,portalPlans:["free","monthly","yearly"],portalButtonIcon:"icon-1",portalButtonSignupText:"Subscribe now",portalButtonStyle:"icon-and-text",membersSupportAddress:"support@example.com",commentsEnabled:!0,newsletters:[{id:"weekly",name:"Weekly Rundown",description:"Best of last week",subscribe_on_signup:!0,paid:!0},{id:"daily",name:"Daily Brief",description:"One email every day",subscribe_on_signup:!1,paid:!1}],posts:[{id:"post_66aacfe061c94e10eb6e4fc1",title:"Post 1",excerpt:"Post excerpt",slug:"post-1",featured:!1},{id:"post_66aacfe04f14b8dbb56c5721",title:"Post 2",excerpt:"Post excerpt",slug:"post-2",featured:!1},{id:"post_66aacfe03d609460819af18c",title:"Post 3",excerpt:"Post excerpt",slug:"post-3",featured:!1}]}),tE=Zx({tierId:(oE=_i.products[1])==null?void 0:oE.id}),Zl={free:Ht({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Ht({paid:!0,subscriptions:[Na({status:"active",currency:"USD",interval:"year",amount:5e3,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]}),complimentary:Ht({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Ht({paid:!0,subscriptions:[Na({amount:0})]}),preview:Ht({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]})};function s8(){var n;if(!Jl||!Jl[1])return null;let e=(n=_i==null?void 0:_i.products)==null?void 0:n[1].monthlyPrice,t=Ht({paid:!0,subscriptions:[Na({offer:null,priceId:e==null?void 0:e.id,status:"active",currency:e==null?void 0:e.currency,interval:e==null?void 0:e.interval,amount:e==null?void 0:e.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:_i,member:t}}function l8(e){const t=e.getAttribute("href"),n=new URL(t,window.location.origin);!n.hash||!n.hash.startsWith("#/portal")||t.startsWith("#/portal")||n.origin===window.location.origin&&e.setAttribute("href",n.hash)}function u8({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function c8({state:e}){return{showPopup:!e.showPopup}}function d8({data:e}){return{showPopup:!0,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function m8({state:e}){return e.lastPage?{page:e.lastPage}:nE({state:e})}function nE({state:e}){return Qm(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function p8({data:e}){return{showNotification:!0,...e}}function h8(){return{showNotification:!1}}async function f8({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:Ee({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to log out, please try again")})}}}async function g8({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:r,inboxLinks:o}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...r?{otcRef:r}:{},inboxLinks:o,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:Ee({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:xn(a,k("Failed to log in, please try again"))})}}}function y8({data:e,state:t}){const n=((e==null?void 0:e.email)||"").trim(),a=e==null?void 0:e.otcRef,i=e==null?void 0:e.inboxLinks;return a?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:a,inboxLinks:i,pageData:{...t.pageData||{},email:n},popupNotification:null}:{}}async function b8({data:e,api:t}){var a;const n=k("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),r=await t.member.verifyOTC({...e,integrityToken:i});return r.redirectUrl?window.location.assign(r.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:xn((a=r.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:xn(i,n)}}}async function k8({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}=e;s=s==null?void 0:s.trim();let p;if(a.toLowerCase()==="free"){const f=await n.member.getIntegrityToken();({inboxLinks:p}=await n.member.sendMagicLink({emailType:"signup",integrityToken:f,...e,name:s}))}else return i&&r?await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}):({tierId:i,cadence:r}=Aa({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:p,pageData:{...t.pageData||{},email:(o||"").trim()}}}catch(a){const i=xn(a,k("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:Ee({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function v8({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:r,cadence:o}=e;(!r||!o)&&({tierId:r,cadence:o}=Aa({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:r,cadence:o,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:Ee({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to process checkout, please try again")})}}}async function w8({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:r,cancelAtPeriodEnd:o}=e,{tierId:s,cadence:l}=Aa({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:l,subscriptionId:r,cancelAtPeriodEnd:o,planId:i});const c=await n.member.sessionData(),p="updateSubscription:success";return{action:p,popupNotification:Ee({type:p,autoHide:!0,closeable:!0,state:t,status:"success",message:k("Subscription plan updated successfully")}),page:"accountHome",member:c}}catch{return{action:"updateSubscription:failed",popupNotification:Ee({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to update subscription, please try again")})}}}async function x8({data:e,state:t,api:n}){try{const{subscriptionId:a,cancellationReason:i}=e;return await n.member.updateSubscription({subscriptionId:a,smartCancel:!0,cancellationReason:i}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData()}}catch{return{action:"cancelSubscription:failed",popupNotification:Ee({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to cancel subscription, please try again")})}}}async function E8({data:e,state:t,api:n}){try{const{subscriptionId:a}=e;return await n.member.updateSubscription({subscriptionId:a,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData()}}catch{return{action:"continueSubscription:failed",popupNotification:Ee({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to cancel subscription, please try again")})}}}async function S8({data:e,state:t,api:n}){try{const{offerId:a,subscriptionId:i}=e;return await n.member.applyOffer({offerId:a,subscriptionId:i}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],popupNotification:Ee({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:Ee({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function C8({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:Ee({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to update billing information, please try again")})}}}async function $8({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:Ee({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to open billing portal, please try again")})}}}async function j8(){return{popupNotification:null}}async function T8({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:Ee({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function P8({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const r={};return a&&(r.newsletters=a),i!==void 0&&(r.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(r)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:k("Failed to update newsletter settings")})}}}async function z8({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:Ee({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:k("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:Ee({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:k("Your email has failed to resubscribe, please try again")})}}}async function A8({data:e,state:t,api:n}){try{const{subscribed:a}=e,i=await n.member.update({subscribed:a});if(!i)throw new Error("Failed to update newsletter");const r="updateNewsletter:success";return{action:r,member:i,popupNotification:Ee({type:r,autoHide:!0,closeable:!0,state:t,status:"success",message:k("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:k("Failed to update newsletter settings")})}}}async function N8({data:e,state:t,api:n}){const{email:a}=e,i=VU({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(r){return{success:!1,error:r}}return null}async function I8({data:e,state:t,api:n}){var r;const a=(r=e==null?void 0:e.name)==null?void 0:r.trim();if(WU({member:t.member})!==a)try{const o=await n.member.update({name:a});if(!o)throw new Error("Failed to update member");return{member:o,success:!0}}catch(o){return{success:!1,error:o}}return null}async function M8({state:e,api:t}){if(e.member)try{const n=await t.member.sessionData();return n?{member:n,success:!0,action:"refreshMemberData:success"}:null}catch(n){return{success:!1,error:n,action:"refreshMemberData:failed"}}return null}async function F8({data:e,state:t,api:n}){const[a,i]=await Promise.all([I8({data:e,state:t,api:n}),N8({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:k("Check your inbox to verify email update")})};const r=a.success?k("Failed to send verification email"):k("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:Ee({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:r,state:t})}}else if(a){const r=a.success?"updateProfile:success":"updateProfile:failed",o=a.success?"success":"error",s=a.success?k("Account details updated successfully"):k("Failed to update account details");return{action:r,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:a.success,closeable:!0,status:o,state:t,message:s})}}else if(i){const r=i.success?"updateProfile:success":"updateProfile:failed",o=i.success?"success":"error";let s="";return i.error?s=xn(i.error,k("Failed to send verification email")):s=k("Check your inbox to verify email update"),{action:r,...i.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:i.success,closeable:!0,status:o,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:k("Account details updated successfully")})}}async function D8({data:{siteUrl:e},state:t}){const n=Wl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,r=Bw(),o=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:o,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:r,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function O8({data:{recommendationId:e},api:t}){try{const n=localStorage.getItem("ghost-recommendations-clicked"),a=n?JSON.parse(n):[];if(a.includes(e))return;a.push(e),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(a))}catch{}return t.recommendations.trackClicked({recommendationId:e}),{}}async function _8({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const R8={togglePopup:c8,openPopup:d8,closePopup:nE,switchPage:u8,openNotification:p8,closeNotification:h8,back:m8,signout:f8,signin:g8,startSigninOTCFromCustomForm:y8,verifyOTC:b8,signup:k8,updateSubscription:w8,cancelSubscription:x8,continueSubscription:E8,applyOffer:S8,updateNewsletter:A8,updateProfile:F8,refreshMemberData:M8,clearPopupNotification:j8,editBilling:C8,manageBilling:$8,checkoutPlan:v8,updateNewsletterPreference:P8,showPopupNotification:T8,removeEmailFromSuppressionList:z8,oneClickSubscribe:D8,trackRecommendationClicked:O8,trackRecommendationSubscribed:_8};async function U8({action:e,data:t,state:n,api:a}){const i=R8[e];return i?await i({data:t,state:n,api:a})||{}:{}}function aE(e,t){e&&(e.innerText=t)}function L8(e,t,n){t.classList.add("error");const a=k("There was an error sending the email, please try again");aE(n,xn(e,a))}async function Y8({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:r,captureException:o}){var j,M;t.removeEventListener("submit",i),e.preventDefault(),n&&(n.innerText=""),t.classList.remove("success","invalid","error");let s=e.target.querySelector("input[data-members-email]"),l=e.target.querySelector("input[data-members-name]"),c=((j=t==null?void 0:t.dataset)==null?void 0:j.membersAutoredirect)||"true",p=s==null?void 0:s.value,f=((l==null?void 0:l.value)||"").trim()||void 0,m,g=[],v=[],S=e.target.querySelectorAll("input[data-members-label]")||[];for(let z=0;z<S.length;++z)g.push(S[z].value);let b=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let z=0;z<b.length;++z)v.push({name:b[z].value});t.dataset.membersForm&&(m=t.dataset.membersForm);const w=m==="signin"&&((M=t==null?void 0:t.dataset)==null?void 0:M.membersOtc)==="true";t.classList.add("loading");const E=co(),P={email:p,emailType:m,labels:g,name:f,autoRedirect:c==="true"};w&&(P.includeOTC=!0),E&&(P.urlHistory=E),b.length>0?P.newsletters=v:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(P.newsletters=[]);try{const R=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),_=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...P,integrityToken:R})});if(t.addEventListener("submit",i),t.classList.remove("loading"),_.ok){t.classList.add("success");let D;if(w)try{D=await _.clone().json()}catch{D=void 0}const X=D==null?void 0:D.otc_ref;if(X&&typeof r=="function")try{r("startSigninOTCFromCustomForm",{email:(p||"").trim(),otcRef:X,inboxLinks:D==null?void 0:D.inboxLinks})}catch(ne){console.error(ne),o==null||o(ne)}}else{const D=await wn.fromApiResponse(_),X=xn(D,k("Failed to send magic link email"));aE(n,X),t.classList.add("error")}}catch(z){L8(z,t,n)}}function B8({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:r,clickHandler:o}){t.removeEventListener("click",o),e.preventDefault();let s=t.dataset.membersPlan,l=IU(i,s.toLowerCase()),c=t.dataset.membersSuccess,p=t.dataset.membersCancel,f,m;c&&(f=new URL(c,window.location.href).href),p&&(m=new URL(p,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const g=r?{checkoutType:"upgrade"}:{},v=co();return v&&(g.urlHistory=v),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:S,successUrl:f,cancelUrl:m,metadata:g})}).then(function(b){if(!b.ok)throw new Error(k("Could not create stripe checkout session"));return b.json()})}).then(function(S){return S.url?window.location.assign(S.url):window.Stripe(S.publicKey).redirectToCheckout({sessionId:S.sessionId}).then(function(w){if(w.error)throw new Error(w.error.message)})}).catch(function(S){console.error(S),t.addEventListener("click",o),t.classList.remove("loading"),n&&(n.innerText=S.message),t.classList.add("error")})}function V8({siteUrl:e,site:t={},member:n,offers:a=[],doAction:i,captureException:r}={}){if(!e)return;e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(s){let l=s.querySelector("[data-members-error]");function c(p){Y8({event:p,errorEl:l,form:s,siteUrl:e,submitHandler:c,doAction:i,captureException:r})}s.addEventListener("submit",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(s){let l=s.querySelector("[data-members-error]");function c(p){B8({el:s,event:p,errorEl:l,member:n,site:t,siteUrl:e,clickHandler:c})}s.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(s){let l=s.querySelector("[data-members-error]"),c=s.dataset.membersSuccess,p=s.dataset.membersCancel,f,m;c&&(f=new URL(c,window.location.href).href),p&&(m=new URL(p,window.location.href).href);function g(v){s.removeEventListener("click",g),v.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:S,successUrl:f,cancelUrl:m})}).then(function(b){if(!b.ok)throw new Error(k("Could not create stripe checkout session"));return b.json()})}).then(function(S){return window.Stripe(S.publicKey).redirectToCheckout({sessionId:S.sessionId})}).then(function(S){if(S.error)throw new Error(k(S.error.message))}).catch(function(S){console.error(S),s.addEventListener("click",g),s.classList.remove("loading"),l&&(l.innerText=S.message),s.classList.add("error")})}s.addEventListener("click",g)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(s){let l=s.querySelector("[data-members-error]"),c=s.dataset.membersReturn,p;c&&(p=new URL(c,window.location.href).href);function f(m){s.removeEventListener("click",f),m.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(g){return g.ok?g.text():null}).then(function(g){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:g,returnUrl:p})}).then(function(v){if(!v.ok)throw new Error(k("Could not create Stripe billing portal session"));return v.json()})}).then(function(g){return window.location.assign(g.url)}).catch(function(g){console.error(g),s.addEventListener("click",f),s.classList.remove("loading"),l&&(l.innerText=g.message),s.classList.add("error")})}s.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(s){function l(c){s.removeEventListener("click",l),c.preventDefault(),s.classList.remove("error"),s.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(p){p.ok?window.location.replace(e):(s.addEventListener("click",l),s.classList.remove("loading"),s.classList.add("error"))})}s.addEventListener("click",l)});const o=(a||[]).some(s=>s.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(s){let l=s.parentElement.querySelector("[data-members-error]");function c(p){p.preventDefault();let f=s.dataset.membersCancelSubscription;if(o){i("openPopup",{page:"accountPlan",pageData:{subscriptionId:f,action:"cancel"}});return}return s.removeEventListener("click",c),s.classList.remove("error"),s.classList.add("loading"),l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${f}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,smart_cancel:!0})})}).then(function(m){m.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=k("There was an error cancelling your subscription, please try again.")))})}s.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(s){let l=s.parentElement.querySelector("[data-members-error]");function c(p){s.removeEventListener("click",c),p.preventDefault(),s.classList.remove("error"),s.classList.add("loading");let f=s.dataset.membersContinueSubscription;return l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${f}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,cancel_at_period_end:!1})})}).then(function(m){m.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=k("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",c)})}const H8={showPopup:!0,site:_i,member:Zl.free,page:"accountEmail",...s8(),pageData:tE};function W8({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Bd,{children:t}):u.jsx(u.Fragment,{children:t})}class G8 extends re.Component{constructor(t){super(t),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,customSiteUrl:t.customSiteUrl,locale:t.locale,scrollbarWidth:0}}componentDidMount(){const t=this.getScrollbarWidth();this.setState({scrollbarWidth:t}),this.initSetup()}componentDidUpdate(t,n){var a,i,r;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(r=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:r.overflow,this.bodyMargin=window.getComputedStyle(document.body).getPropertyValue("margin-right"),window.document.body.style.overflow="hidden",this.state.scrollbarWidth&&(window.document.body.style.marginRight=`calc(${this.bodyMargin} + ${this.state.scrollbarWidth}px)`)):(window.document.body.style.overflow=this.bodyScroll||"",!this.bodyMargin||this.bodyMargin==="0px"?window.document.body.style.marginRight="":window.document.body.style.marginRight=this.bodyMargin)}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:o}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),V8({siteUrl:o,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:Hs})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(t=>{t.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t),document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),n}setupCustomTriggerButton(){this.clickHandler=a=>{a.preventDefault();const i=a.currentTarget,r=i&&i.dataset.portal,{page:o,pageQuery:s,pageData:l}=this.getPageFromLinkPath(r)||{};this.state.initStatus==="success"&&(s&&s!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:s}):this.dispatchAction("openPopup",{page:o,pageQuery:s,pageData:l}))};const t="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(t)||[],this.customTriggerButtons.forEach(a=>{a.classList.add(n),a.removeEventListener("click",this.clickHandler),a.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){var a;const t="gh-portal-open",n="gh-portal-close";(a=this.customTriggerButtons)==null||a.forEach(i=>{const r=this.state.showPopup?t:n,o=this.state.showPopup?n:t;i.classList.add(r),i.classList.remove(o)})}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:r,popupNotification:o,lastPage:s,pageQuery:l,pageData:c}=await this.fetchData(),p=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Cl.changeLanguage(p);const f={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:r,pageData:c,popupNotification:o,dir:Cl.dir()||"ltr",action:"init:success",initStatus:"success",locale:p};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const m=document.querySelectorAll("[data-lexical-signup-form]");m.length>0&&m.forEach(g=>{g.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(t){console.error("[Portal] Failed to initialize:",t),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:t,member:n,offers:a}=await this.fetchApiData(),{site:i,...r}=this.fetchDevData(),{site:o,...s}=this.fetchLinkData(t,n),{site:l,...c}=this.fetchPreviewData(),{site:p,...f}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...o,...l,...p,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...r,...s,...f,...c}}fetchDevData(){return $e(["dev"])&&!this.state.customSiteUrl?H8:$e(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){const n=new URLSearchParams(t),a={};for(let i of n.entries()){const r=i[0],o=decodeURIComponent(i[1]);r==="name"?a.name=o||"":r==="code"?a.code=o||"":r==="display_title"?a.display_title=o||"":r==="display_description"?a.display_description=o||"":r==="type"?a.type=o||"":r==="cadence"?a.cadence=o||"":r==="duration"?a.duration=o||"":r==="duration_in_months"&&!isNaN(Number(o))?a.duration_in_months=Number(o):r==="amount"&&!isNaN(Number(o))?a.amount=Number(o):r==="currency"?a.currency=o||"":r==="status"?a.status=o||"":r==="tier_id"&&(a.tier={id:o||tE.tier.id})}return{page:"offer",pageData:a}}fetchQueryStrData(t=""){const n=new URLSearchParams(t),a={site:{plans:{}}},i=[];let r,o=null,s,l,c;for(let p of n.entries()){const f=p[0],m=decodeURIComponent(p[1]);if(f==="button")a.site.portal_button=JSON.parse(m);else if(f==="name")a.site.portal_name=JSON.parse(m);else if(f==="isFree"&&JSON.parse(m))i.push("free");else if(f==="isMonthly"&&JSON.parse(m))i.push("monthly");else if(f==="isYearly"&&JSON.parse(m))i.push("yearly");else if(f==="portalPrices")r=m?m.split(","):[];else if(f==="portalProducts")o=m?m.split(","):[];else if(f==="page"&&m)a.page=m;else if(f==="accentColor"&&(m===""||m))a.site.accent_color=m;else if(f==="buttonIcon"&&m)a.site.portal_button_icon=m;else if(f==="signupButtonText")a.site.portal_button_signup_text=m||"";else if(f==="signupTermsHtml")a.site.portal_signup_terms_html=m||"";else if(f==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(m);else if(f==="buttonStyle"&&m)a.site.portal_button_style=m;else if(f==="monthlyPrice"&&!isNaN(Number(m)))a.site.plans.monthly=Number(m),s=Number(m);else if(f==="yearlyPrice"&&!isNaN(Number(m)))a.site.plans.yearly=Number(m),l=Number(m);else if(f==="currency"&&m){const g=m.toUpperCase();a.site.plans.currency=g,a.site.plans.currency_symbol=De(g),c=g}else f==="disableBackground"?a.site.disableBackground=JSON.parse(m):f==="membersSignupAccess"&&m?a.site.members_signup_access=m:f==="portalDefaultPlan"&&m?a.site.portal_default_plan=m:f==="transistorPortalSettings"&&m&&(a.site.transistor_portal_settings=JSON.parse(m))}return a.site.portal_plans=i,a.site.portal_products=o,r?a.site.portal_plans=r:s&&l&&c&&(a.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:c,amount:s,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:c,amount:l,type:"recurring",interval:"year"}]),a}fetchNotificationData(){const{type:t,status:n,duration:a,autoHide:i,closeable:r}=nx({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:Ee({type:t,status:n,duration:a,closeable:r,autoHide:i,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}fetchLinkData(t,n){const a=new URLSearchParams(window.location.search);if(a.get("action")==="unsubscribe")return a.get("key")&&a.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:a.get("uuid"),key:a.get("key"),newsletterUuid:a.get("newsletter"),comments:a.get("comments")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:a.get("newsletter"),action:"unsubscribe",redirect:t.url+"#/portal/account/newsletters"}};if(DU({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,r]=window.location.hash.substr(1).split("?"),o=new URLSearchParams(r??""),s=/^(?:(\w+?))?\/monthly$/,l=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,p=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,m,g]=i.match(f),v=parseInt(g);if(v===1||v===0)return n||o.get("uuid")&&o.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:o.get("uuid"),key:n?null:o.get("key"),postId:m,score:v}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${m}/${v}/`}}}if(i&&p.test(i)){const[,m]=i.match(p),{page:g,pageQuery:v,pageData:S}=this.getPageFromLinkPath(m,t)||{};if(!n&&g&&qx({page:g}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${m}/`}};const b=["accountPlan","accountProfile"].includes(g)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(v)||s.test(v)||l.test(v)||c.test(v)),...g?{page:g}:{},...v?{pageQuery:v}:{},...S?{pageData:S}:{},...b?{lastPage:b}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if($e(["preview"])){let n={};return $e(["offerPreview"])?n=this.fetchOfferQueryStrData(t):n=this.fetchQueryStrData(t),{...n,showPopup:!0}}return{}}getColorOverride(){const t=document.querySelector("script[data-ghost]");return t&&t.dataset.accentColor?t.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:t,customSiteUrl:n,apiUrl:a,apiKey:i}=this.props;try{this.GhostApi=this.props.api||Wl({siteUrl:t,apiUrl:a,apiKey:i});const{site:r,member:o,offers:s}=await this.GhostApi.init(),l=this.getColorOverride();return l&&(r.accent_color=l),this.setupFirstPromoter({site:r,member:o}),this.setupSentry({site:r}),{site:r,member:o,offers:s}}catch(r){if($e(["dev","test"],{customSiteUrl:n}))return{};throw r}}setupSentry({site:t}){if($e(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,o=`portal@2.64.2|ghost@${i}`;n&&n.dsn&&kT({dsn:n.dsn,environment:n.env||"development",release:o,beforeSend:s=>jU({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if($e(["test"]))return null;const a=HU({site:t});let i=rp({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.firstpromoter.com/fprom.js",r.onload=r.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),nL({member:n})){const l=n.email,c=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:l,uid:c});else{const p=window._fprom||[];window._fprom=p,p.push(["event","signup"]),p.push(["email",l]),p.push(["uid",c])}}}catch{}};const o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(r,o)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await U8({action:t,data:n,state:this.state,api:this.GhostApi});this.setState(a),a&&a.action&&!a.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(a){if(console.error(`[Portal] Failed to dispatch action: ${t}`,a),n&&n.throwErrors)throw a;const i=Ee({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:xn(a,k("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:i})}}updateStateForPreviewLinks(){const{site:t,...n}=this.fetchPreviewData(),{site:a,...i}=this.fetchLinkData(),r={site:{...this.state.site,...a||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(a||{}).plans,...(t||{}).plans}},...i,...n};this.handleSignupQuery({site:r.site,pageQuery:r.pageQuery}),this.setState(r)}async handleOfferQuery({site:t,offerId:n,member:a=this.state.member}){const{portal_button:i}=t;if(Qm(),!an({member:a})||Qn({member:a}))try{const r=await this.GhostApi.site.offer({offerId:n}),o=r==null?void 0:r.offers[0];if(!o||!o.tier||Jw({offer:o})||!ZU({site:t,offer:o}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:r==null?void 0:r.offers[0]});else{const s=Pa({site:t,productId:o.tier.id}),l=o.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:c,cadence:p}=Aa({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:p})}else{const{tierId:c,cadence:p}=Aa({site:t,priceId:l.id});this.dispatchAction("signup",{plan:l.id,offerId:n,tierId:c,cadence:p})}}}catch{}}handleSignupQuery({site:t,pageQuery:n,member:a}){const i=/^offers\/(\w+?)\/?$/;let r=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}qw({site:t,pageQuery:n})&&(r=qw({site:t,pageQuery:n}));const o=MU({site:t,priceId:r});if(n&&n!=="free"){Qm();const s=(o==null?void 0:o.id)||r;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:l,cadence:c}=Aa({site:t,priceId:s});this.dispatchAction("signup",{plan:s,tierId:l,cadence:c})}}getPageFromLinkPath(t){const n=/^signup\/?(?:\/(\w+?))?\/?$/,a=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,i=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,r=/^offers\/(\w+?)\/?$/;if(t===void 0||t==="")return{page:"default"};if(r.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,o]=t.match(a);return{page:"signup",pageQuery:`${o}/monthly`}}else if(i.test(t)){const[,o]=t.match(i);return{page:"signup",pageQuery:`${o}/yearly`}}else if(n.test(t)){const[,o]=t.match(n);return{page:"signup",pageQuery:o}}else{if(t==="signup/free")return{page:"signup",pageQuery:"free"};if(t==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(t==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(t==="signin")return{page:"signin"};if(t==="account")return{page:"accountHome"};if(t==="account/plans")return{page:"accountPlan"};if(t==="account/profile")return{page:"accountProfile"};if(t==="account/newsletters")return{page:"accountEmail"};if(t==="support")return{page:"support"};if(t==="support/success")return{page:"supportSuccess"};if(t==="support/error")return{page:"supportError"};if(t==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(t==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(t==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}return{page:"default"}}getAccentColor(){const{accent_color:t}=this.state.site||{};return I6(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=rn({site:t})||!Sn({site:t})?"signin":"signup";n=a?"accountHome":i}return Bp({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return $e(["dev","preview"],{customSiteUrl:a})?qx({page:t})||Q5({page:t})?$e(["dev"],{customSiteUrl:a})?n||Zl.free:$e(["preview"])?Zl.preview:Zl.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:r,page:o,lastPage:s,showPopup:l,pageQuery:c,pageData:p,popupNotification:f,customSiteUrl:m,dir:g,scrollbarWidth:v,otcRef:S,inboxLinks:b}=this.state,w=this.getContextPage({site:t,page:o,member:n}),E=this.getContextMember({page:w,member:n,customSiteUrl:m});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:r,brandColor:this.getAccentColor(),page:w,pageQuery:c,pageData:p,member:E,lastPage:s,showPopup:l,popupNotification:f,customSiteUrl:m,dir:g,scrollbarWidth:v,otcRef:S,inboxLinks:b,doAction:(P,j)=>this.dispatchAction(P,j)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const t=a=>{const i=a.currentTarget.dataset.recommendation;i?this.dispatchAction("trackRecommendationClicked",{recommendationId:i}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},n=this.getRecommendationButtons();for(const a of n)a.addEventListener("click",t,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"]').forEach(l8)}render(){return this.state.initStatus==="success"?u.jsx(W8,{site:this.state.site,children:u.jsxs(H.Provider,{value:this.getContextFromState(),children:[u.jsx(Hp,{}),u.jsx(lp,{}),u.jsx(hp,{})]})}):null}}const iE="ghost-portal-root";function K8(){const e=document.createElement("div");e.id=iE,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function q8(){const e=document.querySelector("script[data-ghost]");if(e){const t=e.dataset.i18n==="true",n=e.dataset.ghost,a=e.dataset.key,i=e.dataset.api,r=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:r}}return{}}function J8(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function Z8(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=q8(),r=e||window.location.origin;K8(),J8(),TC.render(u.jsx(re.StrictMode,{children:u.jsx(G8,{siteUrl:r,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(iE))}Z8()});
7540
+ `;function E5({site:e}){return Xm+v5+hL+WL+n6+IL()+pL+uL+mL+_w+H6+M6+q6()+up+W6+w5+x5+Z6+i5+r5+o5+l5+d5+h5+b5}const ah=class ah extends re.Component{constructor(t){super(t),this.state={email:"",token:void 0}}componentDidMount(){const{member:t}=this.context;t&&this.context.doAction("switchPage",{page:"accountHome"})}handleSignin(t){t.preventDefault(),this.doSignin()}doSignin(){this.setState(t=>({errors:Ll({fields:this.getInputFields({state:t})})}),async()=>{const{email:t,phonenumber:n,errors:a,token:i}=this.state,{redirect:r}=this.context.pageData??{};a&&Object.values(a).filter(s=>!!s).length>0||this.context.doAction("signin",{email:t,phonenumber:n,redirect:r,token:i})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}onKeyDown(t){t.keyCode===13&&this.handleSignin(t)}getInputFields({state:t}){const n=t.errors||{};return[{type:"email",value:t.email,placeholder:k("jamie@example.com"),label:k("Email"),name:"email",required:!0,errorMessage:n.email||"",autoFocus:!0},{type:"text",value:t.phonenumber,placeholder:"+1 (123) 456-7890",label:"Phone number",name:"phonenumber",required:!1,tabIndex:-1,autoComplete:"off",hidden:!0}]}renderSubmitButton(){const{action:t}=this.context;let n=!1;const a=t==="signin:running";let i=k(a?"Sending login link...":"Continue");const r=!!a;return t==="signin:failed"&&(i=k("Retry"),n=!0),u.jsx(ze,{dataTestId:"signin",retry:n,style:{width:"100%"},onClick:o=>this.handleSignin(o),disabled:r,brandColor:this.context.brandColor,label:i,isRunning:a})}renderSignupMessage(){const{brandColor:t}=this.context;return u.jsxs("div",{className:"gh-portal-signup-message",children:[u.jsx("div",{children:k("Don't have an account?")}),u.jsx("button",{"data-test-button":"signup-switch",className:"gh-portal-btn gh-portal-btn-link",style:{color:t},onClick:()=>this.context.doAction("switchPage",{page:"signup"}),children:u.jsx("span",{children:k("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=jl({site:t})&&Sn({site:t});return ea({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Ul,{fields:this.getInputFields({state:this.state}),onChange:(a,i)=>this.handleInputChange(a,i),onKeyDown:(a,i)=>this.onKeyDown(a,i)})}),u.jsxs("footer",{className:"gh-portal-signin-footer",children:[this.renderSubmitButton(),n&&this.renderSignupMessage()]})]}):u.jsx("section",{children:u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-members-disabled-notification","data-testid":"members-disabled-notification-text",children:k("Memberships unavailable, contact the owner for access.")})})})}renderSiteIcon(){const{site:t}=this.context,n=t.icon;return n?u.jsx("img",{className:"gh-portal-signup-logo",src:n,alt:this.context.site.title}):ea({site:t})?null:u.jsx(Ex,{className:"gh-portal-icon gh-portal-icon-invitation"})}renderSiteTitle(){const{site:t}=this.context,n=t.title;return ea({site:t})?u.jsx("h1",{className:"gh-portal-main-title",children:k("Sign in")}):u.jsx("h1",{className:"gh-portal-main-title",children:n})}renderFormHeader(){return u.jsxs("header",{className:"gh-portal-signin-header",children:[this.renderSiteIcon(),this.renderSiteTitle()]})}render(){return u.jsxs(u.Fragment,{children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-portal-logged-out-form-container",children:u.jsxs("div",{className:"gh-portal-content signin",children:[this.renderFormHeader(),this.renderForm()]})})]})}};ah.contextType=H;let Rp=ah;const S5=({handleSignout:e,supportAddress:t=""})=>{const n=`mailto:${t}`;return u.jsxs("footer",{className:"gh-portal-account-footer",children:[u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("button",{"data-test-button":"footer-signout",className:"gh-portal-btn",name:"logout","aria-label":"logout",onClick:a=>e(a),children:k("Sign out")})})}),u.jsx("div",{className:"gh-portal-account-footerright",children:u.jsx("ul",{className:"gh-portal-account-footermenu",children:u.jsx("li",{children:u.jsx("a",{"data-test-link":"footer-support",className:"gh-portal-btn gh-portal-btn-branded",href:n,onClick:()=>{n&&window.open(n)},children:k("Contact support")})})})})]})},C5=()=>{const{member:e,brandColor:t}=C.useContext(H),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(Zm,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:k("Your account")})]})},$5=()=>{const{site:e,action:t,brandColor:n,doAction:a}=C.useContext(H);if(!jl({site:e})||!Sn({site:e}))return null;const i=["checkoutPlan:running"].includes(t),r=()=>{a("switchPage",{page:"accountPlan",lastPage:"accountHome"})};return u.jsx(ze,{dataTestId:"view-plans",isRunning:i,label:k("View plans"),onClick:()=>r(),brandColor:n,style:{width:"100%"}})},j5=()=>{const{member:e,site:t}=C.useContext(H),{is_stripe_configured:n}=t;if(!n||Ni({site:t}))return null;const a=Ft({member:e}),i=Qn({member:e});if(i&&!a)return null;if(a){const r=a==null?void 0:a.current_period_end;if(i&&ep({member:e})){const o=ep({member:e}),s=En(o);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(ap({sub:a})){const o=En(a.trial_end_at);return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("Your subscription will start on {subscriptionStart}",{subscriptionStart:o})})})}return u.jsx("div",{className:"gh-portal-section",children:u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("Your subscription will renew on {renewalDate}",{renewalDate:En(r)})})})}return u.jsxs("div",{className:"gh-portal-section",children:[u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx($5,{})]})},T5=()=>{const{member:e,doAction:t,action:n,brandColor:a}=C.useContext(H),i=Ft({member:e});if(!i||!i.cancel_at_period_end)return null;const r=i.cancel_at_period_end?k("Continue subscription"):k("Cancel subscription"),o=["cancelSubscription:running"].includes(n),s=!!o,l=!!i.cancel_at_period_end,c=()=>{if(!i.cancel_at_period_end)return null;const p=i.current_period_end;return u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:k("Your subscription will expire on {expiryDate}",{expiryDate:En(p)})})};return u.jsxs("div",{className:"gh-portal-cancelcontinue-container",children:[u.jsx(c,{}),u.jsx(ze,{onClick:()=>{t("continueSubscription",{subscriptionId:i.id})},isRunning:o,disabled:s,isPrimary:l,brandColor:a,label:r,style:{width:"100%"}})]})},Hx=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},C.createElement("defs",null,C.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),C.createElement("path",{d:"M22.939 2.56V8.817C22.9391 9.61244 22.6232 10.3754 22.061 10.938L10.5 22.5C10.2187 22.7812 9.83721 22.9392 9.43946 22.9392C9.04172 22.9392 8.66026 22.7812 8.37896 22.5L1.49997 15.62C1.21876 15.3387 1.06079 14.9572 1.06079 14.5595C1.06079 14.1618 1.21876 13.7803 1.49997 13.499L13.061 1.938C13.6236 1.37572 14.3865 1.0599 15.182 1.06H21.439C21.8368 1.06 22.2183 1.21803 22.4996 1.49934C22.7809 1.78064 22.939 2.16217 22.939 2.56V2.56Z",className:"a"}),C.createElement("path",{d:"M17.689 7.81C16.8605 7.81 16.189 7.13842 16.189 6.31C16.189 5.48157 16.8605 4.81 17.689 4.81C18.5174 4.81 19.189 5.48157 19.189 6.31C19.189 7.13842 18.5174 7.81 17.689 7.81Z",className:"a"})),P5=()=>{const{member:e,site:t,doAction:n}=C.useContext(H),a=()=>{const m=Ft({member:e});n("manageBilling",{subscriptionId:m.id})},i=()=>{const{is_stripe_configured:m}=t;m&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},r=({price:m,isComplimentary:g,subscription:v})=>{const{next_payment:S}=v||{};let b="";if(m){const{amount:R=0,currency:_,interval:D}=m;b=`${Intl.NumberFormat("en",{currency:_,style:"currency"}).format(R/100)}/${k(D)}`}const w=ep({member:e});g&&(w?b=`${k("Complimentary")} - ${k("Expires {expiryDate}",{expiryDate:w})}`:b=b?`${k("Complimentary")} (${b})`:k("Complimentary"));let E="";if(ap({sub:v}))return E="gh-portal-account-old-price",u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(z5,{subscription:v})]});if(YU({sub:v}))return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(A5,{nextPayment:S})]});let M=N5({nextPayment:S});M&&(E="gh-portal-account-old-price");const z=()=>M?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(Hx,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:M})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(z,{})]})},o=({isPaid:m})=>Ni({site:t})&&!m?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:g=>i(),"data-test-button":"change-plan",children:k("Change")}),s=({defaultCardLast4:m})=>{if(m){const g=`**** **** **** ${m}`;return u.jsx("p",{children:g})}return null},l=({defaultCardLast4:m,isComplimentary:g})=>{const{action:v}=C.useContext(H),S=v==="manageBilling:running"?u.jsx(Ii,{className:"gh-portal-billing-button-loader"}):k("Update");return g?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k("Billing info & receipts")}),u.jsx(s,{defaultCardLast4:m})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:b=>a(),"data-test-button":"manage-billing",children:S})]})},c=Ft({member:e}),p=Qn({member:e}),f=an({member:e});if(c||p){const{price:m,default_payment_card_last4:g}=c||{};let v=k("Plan");return Tl({site:t})&&Yw({member:e})&&(v=Yw({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v}),u.jsx(r,{price:m,isComplimentary:p,subscription:c})]}),u.jsx(o,{isPaid:f})]}),u.jsx(l,{isComplimentary:p,defaultCardLast4:g})]})}return null};function z5({subscription:e}){if(ap({sub:e})){const t=En(e.trial_end_at);return u.jsx("p",{className:"gh-portal-account-discountcontainer",children:u.jsx("div",{children:u.jsx("span",{children:k("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function A5({nextPayment:e}){const t=e.discount.amount,n=t===1?"1 month free":`${t} months free`;return u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(Hx,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:n})]})}function N5({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";let n="";t.duration==="forever"?n=k("Forever"):t.duration==="once"?n=k("Next payment"):t.duration==="repeating"&&t.end&&(n=k("Ends {offerEndDate}",{offerEndDate:En(t.end)}));const a=Intl.NumberFormat("en",{currency:e.currency,style:"currency"}).format(e.amount/100);let i="";return t.duration==="once"?i=a:i=`${a}/${e.interval}`,`${i}${n?` — ${n}`:""}`}function I5(){const{member:e,site:t,doAction:n}=C.useContext(H);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let r=k(i?"Subscribed":"Unsubscribed");const o=s=>{var p;s.preventDefault();const l=za({site:t}),c=(p=e==null?void 0:e.newsletters)!=null&&p.length?[]:l;n("updateNewsletterPreference",{newsletters:c})};return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail email-newsletter",children:[u.jsx("h3",{children:k("Email newsletter")}),u.jsxs("p",{children:[r," ",ip({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:k("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Ol,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{o(s)},checked:i})})]})}const Wx=e=>C.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},C.createElement("path",{d:"m12.79 12.376 4.08 4.079m-4.08 0 4.08-4.08",stroke:"red",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}),C.createElement("path",{d:"m10.439 17.994-2.664-2.652-2.86 1.478.111-4.239m0 0L1.677 9.232a1.344 1.344 0 0 1-.366-1.222 1.369 1.369 0 0 1 .904-1.05l13.111-4.374a1.369 1.369 0 0 1 1.76 1.758L15 10m-9.974 2.581 11.67-9.727",stroke:"#A3A3A3",strokeWidth:1.35,strokeLinecap:"round",strokeLinejoin:"round"}));function M5(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(Wx,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:k("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:k("You're currently not receiving emails")})]})}function F5(){const{doAction:e,member:t,site:n}=C.useContext(H),a=Hw({member:t}),i=oo({site:n}),r=Pl({site:n}),o=a?"emailSuppressed":"accountEmail",s=!i&&!r,l=()=>a||s?u.jsx(M5,{}):u.jsx("p",{children:k("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k("Emails")}),l()]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:()=>{e("switchPage",{page:o,lastPage:"accountHome"})},"data-test-button":"manage-newsletters",children:k("Manage")})]})}const D5=()=>{const{member:e,site:t}=C.useContext(H),a=t.transistor_portal_settings||{enabled:t.transistor_portal_enabled===!0,heading:t.transistor_portal_heading,description:t.transistor_portal_description,button_text:t.transistor_portal_button_text,url_template:t.transistor_portal_url_template},i=(a==null?void 0:a.enabled)===!0,r=e==null?void 0:e.uuid,o=Zw(),[s,l]=C.useState(o&&i);return C.useEffect(()=>{if(o){l(i);return}if(!i||!r){l(!1);return}l(!1);const c=new AbortController;return(async()=>{try{const f=await fetch(`https://partner.transistor.fm/ghost/member/${r}`,{signal:c.signal});if(f.ok){const m=await f.json();c.signal.aborted||l((m==null?void 0:m.member)===!0)}}catch(f){if(c.signal.aborted)return;console.warn("Error in Transistor request",f)}})(),()=>c.abort()},[i,r,o]),{transistor:{enabled:i,hasPodcasts:s,memberUuid:r,settings:a}}},O5=(e,t)=>lo({site:e})&&oo({site:e})||Pl({site:e})||Hw({member:t}),_5=e=>!lo({site:e})&&oo({site:e})&&!Pl({site:e}),R5=()=>{const{member:e,doAction:t,site:n}=C.useContext(H),{name:a,email:i}=e,{transistor:r}=D5(),o=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=O5(n,e),l=_5(n);return u.jsx("div",{children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:a||k("Account")}),u.jsx("p",{children:i})]}),u.jsx("button",{"data-test-button":"edit-profile",className:"gh-portal-btn gh-portal-btn-list",onClick:c=>o(),children:k("Edit")})]}),u.jsx(P5,{}),s&&u.jsx(F5,{}),l&&u.jsx(I5,{}),r.enabled&&u.jsx(k5,{hasPodcasts:r.hasPodcasts,memberUuid:r.memberUuid,settings:r.settings})]})})},U5=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(Oe,{}),u.jsx(C5,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(j5,{}),u.jsx(T5,{}),u.jsx(R5,{})]})]}),ih=class ih extends re.Component{componentDidMount(){const{member:t,site:n}=this.context;ea({site:n})||this.context.doAction("signout"),t||this.context.doAction("switchPage",{page:"signin",pageData:{redirect:window.location.href}})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}render(){const{member:t,site:n}=this.context,a=uo({site:n});return!t||!ea({site:n})?null:u.jsxs("div",{className:"gh-portal-account-wrapper",children:[u.jsx(U5,{}),u.jsx(S5,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ih.contextType=H;let Up=ih;const rh=class rh extends re.Component{constructor(t,n){super(t,n);const{name:a="",email:i=""}=n.member||{};this.state={name:a,email:i}}componentDidMount(){const{member:t}=this.context;t||this.context.doAction("switchPage",{page:"signin"})}handleSignout(t){t.preventDefault(),this.context.doAction("signout")}onBack(){this.context.doAction("back")}onProfileSave(t){t.preventDefault(),this.setState(n=>({errors:Ll({fields:this.getInputFields({state:n})})}),()=>{const{email:n,name:a,errors:i}=this.state;i&&Object.values(i).filter(o=>!!o).length>0||(this.context.doAction("clearPopupNotification"),this.context.doAction("updateProfile",{email:n,name:a}))})}renderSaveButton(){const t=this.context.action==="updateProfile:running";let n=k("Save");this.context.action==="updateProfile:failed"&&(n=k("Retry"));const a=!!t;return u.jsx(ze,{dataTestId:"save-button",isRunning:t,onClick:i=>this.onProfileSave(i),disabled:a,brandColor:this.context.brandColor,label:n,style:{width:"100%"}})}renderDeleteAccountButton(){return u.jsx("div",{style:{cursor:"pointer",color:"red"},role:"button",children:k("Delete account")})}renderAccountFooter(){return u.jsx("footer",{className:"gh-portal-action-footer",children:this.renderSaveButton()})}renderHeader(){return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:this.context.brandColor,hidden:!this.context.lastPage,onClick:t=>this.onBack(t)}),u.jsx("h3",{className:"gh-portal-main-title",children:k("Account settings")})]})}renderUserAvatar(){const t=this.context.member&&this.context.member.avatar_image,n={position:"relative",display:"flex",width:"64px",height:"64px",marginBottom:"6px",borderRadius:"100%",boxShadow:"0 0 0 3px #fff",border:"1px solid gray",overflow:"hidden",justifyContent:"center",alignItems:"center"};return u.jsx("div",{style:n,children:u.jsx(Zm,{gravatar:t,style:{userIcon:{color:"black",width:"56px",height:"56px"}}})})}handleInputChange(t,n){const a=n.name;this.setState({[a]:t.target.value})}getInputFields({state:t,fieldNames:n}){const a=t.errors||{},i=[{type:"text",value:t.name,placeholder:k("Jamie Larson"),label:k("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:k("jamie@example.com"),label:k("Email"),name:"email",required:!0,errorMessage:a.email||""}];return n&&n.length>0?i.filter(r=>n.includes(r.name)):i}onKeyDown(t){t.keyCode===13&&this.onProfileSave(t)}renderProfileData(){return u.jsx("div",{className:"gh-portal-section",children:u.jsx(Ul,{fields:this.getInputFields({state:this.state}),onChange:(t,n)=>this.handleInputChange(t,n),onKeyDown:(t,n)=>this.onKeyDown(t,n)})})}render(){const{member:t}=this.context;return t?u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),this.renderHeader(),u.jsx("div",{className:"gh-portal-section",children:this.renderProfileData()})]}),this.renderAccountFooter()]}):null}};rh.contextType=H;let Lp=rh;function L5(){const{brandColor:e,lastPage:t,doAction:n}=C.useContext(H);return u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx("h3",{className:"gh-portal-main-title",children:k("Email preferences")})]})}function Y5({newsletter:e,subscribedNewsletters:t,setSubscribedNewsletters:n}){const a=t.some(i=>i.id===(e==null?void 0:e.id));return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:e.name}),u.jsx("p",{children:e==null?void 0:e.description})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Ol,{id:e.id,onToggle:(i,r)=>{let o=[];r?o=t.filter(s=>s.id!==e.id).concat(e):o=t.filter(s=>s.id!==e.id),n(o)},checked:a,dataTestId:"switch-input"})})]})}function B5({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=C.useContext(H),i=!!n;if(!t)return null;const r=async(o,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:k("Comment preferences updated.")})};return u.jsxs("section",{className:"gh-portal-list-toggle-wrapper","data-testid":"toggle-wrapper",children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k("Comments")}),u.jsx("p",{children:k("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Ol,{id:"comments",onToggle:r,checked:i,dataTestId:"switch-input"})})]})}function V5({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=C.useContext(H),i=za({site:a});return n?i.map(r=>u.jsx(Y5,{newsletter:r,subscribedNewsletters:e,setSubscribedNewsletters:t},r==null?void 0:r.id)):null}function H5({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:k("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Gx({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:r,isPaidMember:o,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:p,member:f,site:m}=C.useContext(H),g=!(n!=null&&n.length)&&(s&&!l||!s),S=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),u.jsx(L5,{}),u.jsx(S,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(V5,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:b=>{let w=b.map(E=>({id:E.id}));a(w)}}),u.jsx(B5,{isCommentsEnabled:s,enableCommentNotifications:l,updateCommentNotifications:i})]})}),u.jsx("div",{className:"gh-portal-btn-product gh-portal-btn-unsubscribe",style:{marginTop:"-48px",marginBottom:0},children:u.jsx(ze,{isRunning:!1,onClick:()=>{r()},disabled:g,brandColor:c,isPrimary:!1,label:k("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(ip({member:f})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(H5,{isPaid:o,site:m,subscribedNewsletters:n})}),ip({member:f})&&!g&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:k("Not receiving emails?")}),u.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>p("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[k("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function W5(){const{member:e,doAction:t,site:n,pageData:a}=C.useContext(H);let i,r;a&&(i=a.newsletterUuid,r=a.action);const[o,s]=C.useState(!0),l=za({site:n}),c=oo({site:n});C.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),C.useEffect(()=>{if(i&&r==="unsubscribe"){const b=e==null?void 0:e.newsletters.filter(w=>w.uuid!==i);g(b),s(!1),t("updateNewsletterPreference",{newsletters:b})}},[]);const p=()=>{if(a.comments&&v){const E=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${E}`,children:u.jsx(ut,{string:k("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email})}})})})}const b=l==null?void 0:l.find(E=>E.uuid===a.newsletterUuid);if(!b)return null;const w=o?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${w}`,children:u.jsx(ut,{string:k("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:e==null?void 0:e.email}),newsletterName:u.jsx("strong",{children:b==null?void 0:b.name})}})})})},f=[...(e==null?void 0:e.newsletters)||[]],[m,g]=C.useState(f),{comments_enabled:v}=n,{enable_comment_notifications:S}=e||{};return C.useEffect(()=>{g((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(Gx,{hasNewslettersEnabled:c,notification:i?p:null,subscribedNewsletters:m,updateSubscribedNewsletters:b=>{g(b),t("updateNewsletterPreference",{newsletters:b}),t("showPopupNotification",{action:"updated:success",message:k("Email preferences updated.")})},updateCommentNotifications:async b=>{t("updateNewsletterPreference",{enableCommentNotifications:b})},unsubscribeAll:()=>{g([]),t("showPopupNotification",{action:"updated:success",message:k("Unsubscribed from all emails.")});const b={newsletters:[]};v&&(b.enableCommentNotifications=!1),t("updateNewsletterPreference",b)},isPaidMember:an({member:e}),isCommentsEnabled:v!=="off",enableCommentNotifications:S})}function G5(){const{site:e}=C.useContext(H),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function K5(){const{site:e}=C.useContext(H),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(G5,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Kx({api:e,memberUuid:t,key:n,newsletters:a,enableCommentNotifications:i}){try{return await e.member.updateNewsletters({uuid:t,key:n,newsletters:a,enableCommentNotifications:i})}catch{}}function q5(){const{site:e,api:t,pageData:n,member:a,doAction:i}=C.useContext(H),[r,o]=C.useState(),[s,l]=C.useState(!0),c=za({site:e}),p=c.filter(_=>_.subscribe_on_signup),[f,m]=C.useState(!1),[g,v]=C.useState(p),[S,b]=C.useState(!1),{comments_enabled:w}=e,{enable_comment_notifications:E=!1}=r||{},P=oo({site:e}),j=async _=>{a?i("updateNewsletterPreference",{newsletters:_}):await Kx({api:t,memberUuid:n.uuid,key:n.key,newsletters:_}),v(_);const D={action:"updated:success",message:k("Email preferences updated.")};i("showPopupNotification",D)},M=async _=>{let D;a?(await i("updateNewsletterPreference",{enableCommentNotifications:_}),D={...a,enable_comment_notifications:_}):D=await Kx({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:_}),o(D),i("showPopupNotification",{action:"updated:success",message:k("Comment preferences updated.")})},z=async()=>{let _;a?(await i("updateNewsletterPreference",{newsletters:[],enableCommentNotifications:!1}),_={...a},_.newsletters=[],_.enable_comment_notifications=!1):_=await t.member.updateNewsletters({uuid:n.uuid,key:n.key,newsletters:[],enableCommentNotifications:!1}),v([]),o(_),i("showPopupNotification",{action:"updated:success",message:k("Unsubscribed from all emails.")})};if(C.useEffect(()=>{(async()=>{let _;try{_=await t.member.newsletters({uuid:n.uuid,key:n.key}),o(_??null),l(!1)}catch(X){console.error("[PORTAL] Error fetching member newsletters",X),o(null),l(!1);return}if(_===null)return;const D=(_==null?void 0:_.newsletters)||[];v(D),(c==null?void 0:c.length)===1&&!w&&!n.newsletterUuid?await j([]):n.newsletterUuid?await j(D==null?void 0:D.filter(X=>X.uuid!==n.newsletterUuid)):n.comments&&w&&await M(!1)})()},[w,n.uuid,n.newsletterUuid,n.comments,e.url,c==null?void 0:c.length]),s)return u.jsx(ko,{});if(!r)return u.jsxs("div",{className:"gh-portal-content gh-portal-feedback with-footer",children:[u.jsx(Oe,{}),u.jsx("div",{className:"gh-feedback-icon gh-feedback-icon-error",children:u.jsx(dp,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:k("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:k("We couldn't unsubscribe you as the email address was not found. Please contact the site owner.")})}),u.jsx(ze,{style:{width:"100%"},retry:!1,onClick:()=>i("closePopup"),disabled:!1,brandColor:"#000000",label:k("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!w&&!S)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(Oe,{}),u.jsx(K5,{}),u.jsx("h1",{className:"gh-portal-main-title",children:k("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:k("{memberEmail} will no longer receive this newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})}),u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:k("Didn't mean to do this? Manage your preferences <button>here</button>."),mapping:{button:u.jsx("button",{className:"gh-portal-btn-link gh-portal-btn-branded gh-portal-btn-inline",onClick:()=>{b(!0)}})}})})]})]});const R=()=>{if(n.comments&&w){const X=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${X}`,children:u.jsx(ut,{string:k("{memberEmail} will no longer receive emails when someone replies to your comments."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email})}})})})}const _=c==null?void 0:c.find(X=>X.uuid===n.newsletterUuid);if(!_)return null;const D=f?"gh-portal-hide":"";return u.jsx(u.Fragment,{children:u.jsx("p",{className:`gh-portal-text-center gh-portal-header-message ${D}`,children:u.jsx(ut,{string:k("{memberEmail} will no longer receive {newsletterName} newsletter."),mapping:{memberEmail:u.jsx("strong",{children:r==null?void 0:r.email}),newsletterName:u.jsx("strong",{children:_==null?void 0:_.name})}})})})};return u.jsx(Gx,{hasNewslettersEnabled:P,notification:R,subscribedNewsletters:g,updateSubscribedNewsletters:async _=>{await j(_),m(!0)},updateCommentNotifications:M,unsubscribeAll:async()=>{await z(),m(!0)},isPaidMember:(r==null?void 0:r.status)!=="free",isCommentsEnabled:w!=="off",enableCommentNotifications:E})}function J5(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=C.useContext(H);C.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(lo({site:i})||Pl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:k("You have been successfully resubscribed")})):n("back"))},[a,n,i,k]);const r=["removeEmailFromSuppressionList:running","refreshMemberData:running"].includes(a),o=()=>{n("removeEmailFromSuppressionList")};return u.jsxs("div",{className:"gh-email-suppressed-page",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,hidden:!t,onClick:()=>{n("back")}}),u.jsx(Oe,{})]}),u.jsx(Wx,{className:"gh-email-suppressed-page-icon"}),u.jsxs("div",{className:"gh-email-suppressed-page-text",children:[u.jsx("h3",{className:"gh-portal-main-title gh-email-suppressed-page-title",children:k("Emails disabled")}),u.jsx("p",{children:k("You're not receiving emails because you either marked a recent message as spam, or because messages could not be delivered to your provided email address.")})]}),u.jsx(ze,{dataTestId:"resubscribe-email",classes:"gh-portal-confirm-button",onClick:o,disabled:r,brandColor:e,label:k("Re-enable emails"),isRunning:r})]})}function Z5(){const{brandColor:e,doAction:t,site:n,pageData:a}=C.useContext(H),i=`mailto:${uo({site:n})}`,r=a&&a.direct||!1;return u.jsxs("div",{className:"gh-email-suppression-faq",children:[!r&&u.jsxs("header",{className:"gh-portal-detail-header",children:[u.jsx(Mi,{brandColor:e,onClick:()=>{t("switchPage",{page:"emailSuppressed",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:k("Why has my email been disabled?")}),u.jsx("p",{children:k("Newsletters can be disabled on your account for two reasons: A previous email was marked as spam, or attempting to send an email resulted in a permanent failure (bounce).")}),u.jsx("h4",{children:k("Spam complaints")}),u.jsx("p",{children:k("If a newsletter is flagged as spam, emails are automatically disabled for that address to make sure you no longer receive any unwanted messages.")}),u.jsx("p",{children:k("If the spam complaint was accidental, or you would like to begin receiving emails again, you can resubscribe to emails by clicking the button on the previous screen.")}),u.jsx("p",{children:k("Once resubscribed, if you still don't see emails in your inbox, check your spam folder. Some inbox providers keep a record of previous spam complaints and will continue to flag emails. If this happens, mark the latest newsletter as 'Not spam' to move it back to your primary inbox.")}),u.jsx("h4",{children:k("Permanent failure (bounce)")}),u.jsx("p",{children:k("When an inbox fails to accept an email it is commonly called a bounce. In many cases, this can be temporary. However, in some cases, a bounced email can be returned as a permanent failure when an email address is invalid or non-existent.")}),u.jsx("p",{children:k("In the event a permanent failure is received when attempting to send a newsletter, emails will be disabled on the account.")}),u.jsx("p",{children:k("If you would like to start receiving emails again, the best next steps are to check your email address on file for any issues and then click resubscribe on the previous screen.")}),u.jsx("p",{children:u.jsx("a",{className:"gh-portal-btn gh-portal-btn-branded no-margin-right",href:i,onClick:()=>{i&&window.open(i)},children:k("Need more help? Contact support")})})]})]})}function X5(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:r}=C.useContext(H),o=uo({site:n}),s=`mailto:${o}`,l=GU({site:n}),c=r&&r.direct||!1;return u.jsxs("div",{className:"gh-email-receiving-faq",children:[u.jsxs("header",{className:"gh-portal-detail-header",children:[!c&&u.jsx(Mi,{brandColor:e,onClick:()=>{a?t("switchPage",{page:"accountHome"}):t("switchPage",{page:"accountEmail",lastPage:"accountHome"})}}),u.jsx(Oe,{})]}),u.jsxs("div",{className:"gh-longform",children:[u.jsx("h3",{children:k("Help! I'm not receiving emails")}),u.jsx("p",{children:k("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:k("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(ut,{string:k("The email address we have for you is {memberEmail} — if that's not correct, you can update it in your <button>account settings area</button>."),mapping:{memberEmail:u.jsx("strong",{children:i.email}),button:u.jsx("button",{className:"gh-portal-btn-text",onClick:()=>t("switchPage",{lastPage:"emailReceivingFAQ",page:"accountProfile"})})}})}),u.jsx("h4",{children:k("Check spam & promotions folders")}),u.jsx("p",{children:k(`Make sure emails aren't accidentally ending up in the Spam or Promotions folders of your inbox. If they are, click on "Mark as not spam" and/or "Move to inbox".`)}),u.jsx("h4",{children:k("Create a new contact")}),u.jsx("p",{children:u.jsx(ut,{string:k("In your email client add {senderEmail} to your contacts list. This signals to your mail provider that emails sent from this address should be trusted."),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:k("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(ut,{string:k("Send an email to {senderEmail} and say hello. This can also help signal to your mail provider that emails to and from this address should be trusted."),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:k("Check with your mail provider")}),u.jsx("p",{children:u.jsx(ut,{string:k("If you have a corporate or government email account, reach out to your IT department and ask them to allow emails to be received from {senderEmail}"),mapping:{senderEmail:u.jsx("strong",{children:l})}})}),u.jsx("h4",{children:k("Get in touch for help")}),u.jsx("p",{children:u.jsx(ut,{string:k("If you've completed all these checks and you're still not receiving emails, you can reach out to get support by contacting {supportAddress}."),mapping:{supportAddress:u.jsx("a",{href:s,onClick:()=>{s&&window.open(s)},children:o})}})})]})]})}const Yp={signin:Rp,signup:Mp,accountHome:Up,accountPlan:xp,accountProfile:Lp,accountEmail:W5,signupNewsletter:Sp,unsubscribe:q5,magiclink:Fp,loading:ko,offer:Op,feedback:a5,emailSuppressed:J5,emailSuppressionFAQ:Z5,emailReceivingFAQ:X5,support:()=>{const[e,t]=C.useState(!0),[n,a]=C.useState(null),[i,r]=C.useState(null),{member:o,site:s}=C.useContext(H);return C.useEffect(()=>{async function l(){const c=s.url,p=window.location.origin+window.location.pathname,f=o?`${p}?action=support&success=true`:`${p}#/portal/support/success`,m=p,g=Wl({siteUrl:c});try{const v=await g.member.checkoutDonation({successUrl:f,cancelUrl:m,personalNote:k("Add a personal note")});v.url&&window.location.replace(v.url)}catch(v){v.type&&v.type==="DisabledFeatureError"?r(k("This site is not accepting payments at the moment.")):a(k("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(r(k("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(ko,{})}):n?u.jsx(_p,{error:n}):i?u.jsx(_p,{error:i}):null},supportSuccess:u5,supportError:_p,recommendations:y5},Bp=function({page:e}){return Object.keys(Yp).includes(e)?e:"signup"},qx=function({page:e}){return e.includes("account")},Q5=function({page:e}){return e.includes("offer")},e8=e=>C.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},C.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M24 12C24 18.6274 18.6274 24 12 24C5.37258 24 0 18.6274 0 12C0 5.37258 5.37258 0 12 0C18.6274 0 24 5.37258 24 12ZM11.8326 2.33879C6.37785 2.95189 3.95901 5.20797 3.41126 9.74699C3.34896 10.2632 3.22642 10.7805 3.10443 11.2954C2.93277 12.02 2.76221 12.74 2.76221 13.4458C2.76221 17.9885 6.5856 21.556 11.1283 21.556C12.8959 21.556 14.4433 20.8144 15.8756 20.048C19.0536 18.3478 22.0328 16.2597 22.0328 12.5411C22.0328 9.91512 20.1051 7.56932 18.466 5.5747C18.3834 5.47416 18.3015 5.37451 18.2206 5.27577C17.3866 4.25742 14.4333 2.04643 11.8326 2.33879Z",fill:"#15171A"})),oh=class oh extends re.Component{render(){return u.jsxs("a",{href:"https://ghost.org",target:"_blank",rel:"noopener noreferrer",onClick:()=>{window.open("https://ghost.org","_blank")},children:[u.jsx(e8,{}),"Powered by Ghost"]})}};oh.contextType=H;let Gl=oh;const Jx=()=>({modalContainer:{zIndex:"3999999",position:"fixed",left:"0",top:"0",width:"100%",height:"100%",overflow:"hidden"},frame:{common:{margin:"auto",position:"relative",padding:"0",outline:"0",width:"100%",opacity:"1",overflow:"hidden",height:"100%"}},page:{links:{width:"600px"}}});function t8({message:e}){return Ai()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const sh=class sh extends re.Component{componentDidMount(){this.node&&!$e(["preview"])&&!this.props.isMobile&&(this.node.focus(),this.keyUphandler=t=>{t.key==="Escape"&&this.dismissPopup(t)},this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler),this.node.ownerDocument.addEventListener("keyup",this.keyUphandler)),this.sendContainerHeightChangeEvent()}dismissPopup(t){var i;const n=t.target&&t.target.tagName;(n!=="INPUT"||n==="INPUT"&&!((i=t==null?void 0:t.target)!=null&&i.value))&&this.context.doAction("closePopup")}sendContainerHeightChangeEvent(){var t,n;this.node&&$e(["preview"])&&((t=this.node)==null?void 0:t.clientHeight)!==this.lastContainerHeight&&(this.lastContainerHeight=(n=this.node)==null?void 0:n.clientHeight,window.document.body.style.overflow="hidden",window.document.body.style["scrollbar-width"]="none",window.parent.postMessage({type:"portal-preview-updated",payload:{height:this.lastContainerHeight}},"*"))}componentDidUpdate(){this.sendContainerHeightChangeEvent()}componentWillUnmount(){this.node&&this.node.ownerDocument.removeEventListener("keyup",this.keyUphandler)}handlePopupClose(t){const{page:n,otcRef:a}=this.context;$e(["preview"])||a&&n==="magiclink"||t.target===t.currentTarget&&this.context.doAction("closePopup")}renderActivePage(){const{page:t}=this.context;Bp({page:t});const n=Yp[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(Dp,{})}sendPortalPreviewReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-preview-ready",payload:{}},"*")}render(){const{page:t,pageQuery:n,site:a,customSiteUrl:i}=this.context,o=Nl({site:a,pageQuery:n}).length;Bp({page:t});const l={...Jx().page[t]};let c="",p="regular",f="",m=t;switch(t){case"signup":f="Cookies must be enabled in your browser to sign up.";break;case"signin":f="Cookies must be enabled in your browser to sign in.";break;case"accountHome":m="account-home";break;case"accountProfile":m="account-profile";break;case"accountPlan":m="account-plan";break;default:f="Cookies must be enabled in your browser.",m=t;break}o>1&&!rn({site:a})&&Sn({site:a,pageQuery:n})&&t==="signup"&&(m+=" full-size",p="full");const g=so({site:a});(g&&o>2||!g&&o>1)&&t==="accountPlan"&&(m+=" full-size",p="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(m+=" large-size");let v="gh-portal-popup-container";$e(["preview"])&&(m+=" preview"),$e(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(v+=" preview"),$e(["dev"])&&(v+=" dev");const S=`${v} ${c} ${m}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+m,onClick:b=>this.handlePopupClose(b),children:[this.renderPopupNotification(),u.jsxs("div",{className:S,style:l,ref:b=>this.node=b,tabIndex:-1,children:[u.jsx(t8,{message:f}),this.renderActivePage(),p==="full"?u.jsx("div",{className:"gh-portal-powered inside "+($e(["preview"])?"hidden ":"")+m,children:u.jsx(Gl,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+($e(["preview"])?"hidden ":"")+m,children:u.jsx(Gl,{})})]})}};sh.contextType=H;let Vp=sh;const lh=class lh extends re.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=Yp[t];return u.jsx(n,{})}onHeightChange(t){this.setState({height:t})}handlePopupClose(t){t.preventDefault(),t.target===t.currentTarget&&this.context.doAction("closePopup")}renderFrameStyles(){const{site:t,brandColor:n}=this.context,a=E5({site:t}),i=n?`:root { --brandcolor: ${n} }`+a:a;return u.jsxs(u.Fragment,{children:[u.jsx("style",{dangerouslySetInnerHTML:{__html:i}}),u.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1, maximum-scale=1"})]})}renderFrameContainer(){const{member:t,site:n,customSiteUrl:a}=this.context,i=Jx(),r=window.innerWidth<480,o={...i.frame.common};let s="gh-portal-popup-background";return $e(["preview"])&&(i.modalContainer.zIndex="3999997"),$e(["preview"],{customSiteUrl:a})&&!n.disableBackground&&(s+=" preview"),$e(["dev"])&&(s+=" dev"),u.jsx("div",{style:i.modalContainer,children:u.jsxs(qm,{style:o,title:"portal-popup",head:this.renderFrameStyles(),dataTestId:"portal-popup-frame",dataDir:this.context.dir,children:[u.jsx("div",{className:s,onClick:l=>this.handlePopupClose(l)}),u.jsx(Vp,{isMobile:r})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};lh.contextType=H;let Hp=lh;Kl({products:Wp({numOfProducts:1})});function at(){return(new Date().getTime()/1e3|0).toString(16)+"xxxxxxxxxxxxxxxx".replace(/[x]/g,function(){return(Math.random()*16|0).toString(16)}).toLowerCase()}function n8(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(e){const t=Math.random()*16|0;return(e==="x"?t:t&3|8).toString(16)})}function Kl({title:e="The Blueprint",description:t="Thoughts, stories and ideas.",logo:n="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:a="https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",url:i="https://portal.localhost",plans:r={monthly:5e3,yearly:15e4,currency:"USD"},products:o=Wp({numOfProducts:1}),portalProducts:s=o.map(X=>X.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:p="all",freePriceName:f="Free",freePriceDescription:m="Free preview",isStripeConfigured:g=!0,portalButton:v=!0,portalName:S=!0,portalButtonIcon:b="icon-1",portalButtonSignupText:w="Subscribe now",portalButtonStyle:E="icon-and-text",membersSupportAddress:P="support@example.com",editorDefaultEmailRecipients:j="visibility",newsletters:M=[],posts:z=a8(),commentsEnabled:R,recommendations:_=[],recommendationsEnabled:D}={}){return{title:e,description:t,logo:n,icon:a,accent_color:l,url:i,plans:r,products:o,portal_products:s,members_signup_access:p,free_price_name:f,free_price_description:m,is_stripe_configured:g,portal_button:v,portal_name:S,portal_plans:c,portal_button_icon:b,portal_button_signup_text:w,portal_button_style:E,members_support_address:P,comments_enabled:R!=="off",newsletters:M,recommendations:_,recommendations_enabled:!!D,editor_default_email_recipients:j,posts:z}}function Zx({name:e="Black Friday",code:t="black-friday",displayTitle:n="Black Friday Sale!",displayDescription:a="Special deal for Black Friday. Subscribe now for only $15 per month and get additional benefits like accessing our podcast.",type:i="percent",cadence:r="month",amount:o=50,duration:s="repeating",durationInMonths:l=null,currencyRestriction:c=!1,currency:p=null,status:f="active",tierId:m="",tierName:g="Basic",redemptionType:v="signup"}={}){return{id:`offer_${at()}`,name:e,code:t,display_title:n,display_description:a,type:i,cadence:r,amount:o,duration:s,duration_in_months:l,currency_restriction:c,currency:p,status:f,tier:{id:`${m}`,name:g},redemption_type:v}}function Ht({name:e="Jamie Larson",email:t="jamie@example.com",firstname:n="Jamie",subscriptions:a=[],paid:i=!1,avatarImage:r="",subscribed:o=!0,email_suppression:s={suppressed:!1,info:null},newsletters:l=[]}={}){return{uuid:n8(),email:t,name:e,firstname:n,paid:i,subscribed:o,avatar_image:r,subscriptions:a,email_suppression:s,newsletters:l}}function a8({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(i8({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function i8({id:e=`post_${at()}`,title:t="Post",excerpt:n="Post excerpt",slug:a="post",featured:i=!1}={}){return{id:e,title:t,excerpt:n,slug:a,featured:i}}function Wp({numOfProducts:e=3}={}){const n=[Oi({name:"Bronze",description:"Access to all members articles",monthlyPrice:Ot({interval:"month",amount:700}),yearlyPrice:Ot({interval:"year",amount:7e3}),numOfBenefits:2}),Oi({name:"Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:12e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint",description:"Get access to everything and lock in early adopter pricing for life + listen to my podcast",monthlyPrice:Ot({interval:"month",amount:18e3}),yearlyPrice:Ot({interval:"year",amount:17e3}),numOfBenefits:4})].slice(0,e),a=Xx({});return[...n,a]}function Oi({type:e="paid",name:t="Basic",description:n="",id:a=`product_${at()}`,monthlyPrice:i=Ot(),yearlyPrice:r=Ot({interval:"year"}),numOfBenefits:o=2,trialDays:s=null}){return{id:a,name:t,description:n,monthlyPrice:e==="free"?null:i,yearlyPrice:e==="free"?null:r,type:e,benefits:Qx({numOfBenefits:o}),trial_days:s}}function Xx({name:e="Free tier",description:t="Free tier description",id:n=`product_${at()}`,numOfBenefits:a=2}){return{id:n,name:e,type:"free",description:t,benefits:Qx({numOfBenefits:a})}}function Qx({numOfBenefits:e}){const t=at();return[ql({name:`Limited early adopter pricing #${t.substring(0,6)}`}),ql({name:`Latest gear reviews #${t.substring(6,12)}`}),ql({name:`Weekly email newsletter #${t.substring(12,18)}`}),ql({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function ql({id:e=`benefit_${at()}`,name:t="Benefit"}){return{id:e,name:t}}function Ot({interval:e="month",amount:t=e==="month"?500:5e3,nickname:n=e==="month"?"Monthly":"Yearly",description:a=null,currency:i="usd",active:r=!0,id:o=`price_${at()}`}={}){return{id:o,active:r,nickname:n,currency:i,amount:t,interval:e,description:a,stripe_price_id:`price_${at()}`,stripe_product_id:`prod_${at()}`,type:"recurring"}}function Na({id:e=`sub_${at()}`,status:t="active",currency:n="USD",interval:a="year",amount:i=a==="month"?500:5e3,nickname:r=a==="month"?"Monthly":"Yearly",cardLast4:o="4242",offer:s=o8,priceId:l=`price_${at()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:p="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:f=!1,trialEndAt:m=null,nextPayment:g=null,tier:v=null}={}){return{id:e,customer:{id:`cus_${at()}`,name:"Jamie",email:"jamie@example.com"},plan:{id:`price_${at()}`,nickname:r,amount:i,interval:a,currency:n},offer:s,status:t,start_date:c,default_payment_card_last4:o,cancel_at_period_end:f,cancellation_reason:null,current_period_end:p,trial_end_at:m,next_payment:g,tier:v,price:{id:`stripe_price_${at()}`,price_id:l,nickname:r,amount:i,interval:a,type:"recurring",currency:n,product:{id:`stripe_prod_${at()}`,product_id:`prod_${at()}`}}}}function eE(){const e=Wp({numOfProducts:1}),t=e.map(a=>a.id);return Kl({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}eE();const r8=Kl({products:[Oi({numOfBenefits:2,type:"free"})]}),o8=Zx({tierId:(rE=r8.products[0])==null?void 0:rE.id});Ht(),Ht({paid:!0,subscriptions:[Na()]}),Ht({paid:!0,subscriptions:[]}),Ht({paid:!0,subscriptions:[Na({amount:0})]}),Ht({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),eE();const Jl=[Xx({name:"Free",description:"Free tier description which is actually a pretty long description",numOfBenefits:2}),Oi({name:"The Blueprint",description:"",monthlyPrice:Ot({interval:"month",amount:500}),yearlyPrice:Ot({interval:"year",amount:5e3}),numOfBenefits:3}),Oi({name:"Friends of the Blueprint Silver",description:"Access to all members articles and weekly podcast",monthlyPrice:Ot({interval:"month",amount:1200}),yearlyPrice:Ot({interval:"year",amount:11e3}),numOfBenefits:4})],_i=Kl({title:"The Blueprint",description:"Thoughts, stories and ideas.",logo:"https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",icon:"https://static.ghost.org/v4.0.0/images/ghost-orb-1.png",accentColor:"#45C32E",url:"https://portal.localhost",plans:{monthly:5e3,yearly:15e4,currency:"USD"},products:Jl,portalProducts:Jl.map(e=>e.id),membersSignupAccess:"all",freePriceName:"Free",freePriceDescription:"Free preview",isStripeConfigured:!0,portalButton:!0,portalName:!0,portalPlans:["free","monthly","yearly"],portalButtonIcon:"icon-1",portalButtonSignupText:"Subscribe now",portalButtonStyle:"icon-and-text",membersSupportAddress:"support@example.com",commentsEnabled:!0,newsletters:[{id:"weekly",name:"Weekly Rundown",description:"Best of last week",subscribe_on_signup:!0,paid:!0},{id:"daily",name:"Daily Brief",description:"One email every day",subscribe_on_signup:!1,paid:!1}],posts:[{id:"post_66aacfe061c94e10eb6e4fc1",title:"Post 1",excerpt:"Post excerpt",slug:"post-1",featured:!1},{id:"post_66aacfe04f14b8dbb56c5721",title:"Post 2",excerpt:"Post excerpt",slug:"post-2",featured:!1},{id:"post_66aacfe03d609460819af18c",title:"Post 3",excerpt:"Post excerpt",slug:"post-3",featured:!1}]}),tE=Zx({tierId:(oE=_i.products[1])==null?void 0:oE.id}),Zl={free:Ht({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Ht({paid:!0,subscriptions:[Na({status:"active",currency:"USD",interval:"year",amount:5e3,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]}),complimentary:Ht({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Ht({paid:!0,subscriptions:[Na({amount:0})]}),preview:Ht({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]})};function s8(){var n;if(!Jl||!Jl[1])return null;let e=(n=_i==null?void 0:_i.products)==null?void 0:n[1].monthlyPrice,t=Ht({paid:!0,subscriptions:[Na({offer:null,priceId:e==null?void 0:e.id,status:"active",currency:e==null?void 0:e.currency,interval:e==null?void 0:e.interval,amount:e==null?void 0:e.amount,cardLast4:"4242",startDate:"2021-10-05T03:18:30.000Z",currentPeriodEnd:"2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:!1})]});return{site:_i,member:t}}function l8(e){const t=e.getAttribute("href"),n=new URL(t,window.location.origin);!n.hash||!n.hash.startsWith("#/portal")||t.startsWith("#/portal")||n.origin===window.location.origin&&e.setAttribute("href",n.hash)}function u8({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function c8({state:e}){return{showPopup:!e.showPopup}}function d8({data:e}){return{showPopup:!0,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function m8({state:e}){return e.lastPage?{page:e.lastPage}:nE({state:e})}function nE({state:e}){return Qm(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function p8({data:e}){return{showNotification:!0,...e}}function h8(){return{showNotification:!1}}async function f8({api:e,state:t}){try{return await e.member.signout(),{action:"signout:success"}}catch{return{action:"signout:failed",popupNotification:Ee({type:"signout:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to log out, please try again")})}}}async function g8({data:e,api:t,state:n}){try{const a=await t.member.getIntegrityToken(),i={...e,emailType:"signin",integrityToken:a,includeOTC:!0},{otc_ref:r,inboxLinks:o}=await t.member.sendMagicLink(i);return{page:"magiclink",lastPage:"signin",...r?{otcRef:r}:{},inboxLinks:o,pageData:{...n.pageData||{},email:((e==null?void 0:e.email)||"").trim()}}}catch(a){return{action:"signin:failed",popupNotification:Ee({type:"signin:failed",autoHide:!1,closeable:!0,state:n,status:"error",message:xn(a,k("Failed to log in, please try again"))})}}}function y8({data:e,state:t}){const n=((e==null?void 0:e.email)||"").trim(),a=e==null?void 0:e.otcRef,i=e==null?void 0:e.inboxLinks;return a?{showPopup:!0,page:"magiclink",lastPage:"signin",otcRef:a,inboxLinks:i,pageData:{...t.pageData||{},email:n},popupNotification:null}:{}}async function b8({data:e,api:t}){var a;const n=k("Failed to verify code, please try again");try{const i=await t.member.getIntegrityToken(),r=await t.member.verifyOTC({...e,integrityToken:i});return r.redirectUrl?window.location.assign(r.redirectUrl):{action:"verifyOTC:failed",actionErrorMessage:xn((a=r.errors)==null?void 0:a[0],n)}}catch(i){return{action:"verifyOTC:failed",actionErrorMessage:xn(i,n)}}}async function k8({data:e,state:t,api:n}){try{let{plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}=e;s=s==null?void 0:s.trim();let p;if(a.toLowerCase()==="free"){const f=await n.member.getIntegrityToken();({inboxLinks:p}=await n.member.sendMagicLink({emailType:"signup",integrityToken:f,...e,name:s}))}else return i&&r?await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c}):({tierId:i,cadence:r}=Aa({site:t==null?void 0:t.site,priceId:a}),await n.member.checkoutPlan({plan:a,tierId:i,cadence:r,email:o,name:s,newsletters:l,offerId:c})),{page:"loading"};return{page:"magiclink",lastPage:"signup",inboxLinks:p,pageData:{...t.pageData||{},email:(o||"").trim()}}}catch(a){const i=xn(a,k("Failed to sign up, please try again"));return{action:"signup:failed",popupNotification:Ee({type:"signup:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:i})}}}async function v8({data:e,state:t,api:n}){try{let{plan:a,offerId:i,tierId:r,cadence:o}=e;(!r||!o)&&({tierId:r,cadence:o}=Aa({site:t==null?void 0:t.site,priceId:a})),await n.member.checkoutPlan({plan:a,tierId:r,cadence:o,offerId:i,metadata:{checkoutType:"upgrade"}})}catch{return{action:"checkoutPlan:failed",popupNotification:Ee({type:"checkoutPlan:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to process checkout, please try again")})}}}async function w8({data:e,state:t,api:n}){try{const{plan:a,planId:i,subscriptionId:r,cancelAtPeriodEnd:o}=e,{tierId:s,cadence:l}=Aa({site:t==null?void 0:t.site,priceId:i});await n.member.updateSubscription({planName:a,tierId:s,cadence:l,subscriptionId:r,cancelAtPeriodEnd:o,planId:i});const c=await n.member.sessionData(),p="updateSubscription:success";return{action:p,popupNotification:Ee({type:p,autoHide:!0,closeable:!0,state:t,status:"success",message:k("Subscription plan updated successfully")}),page:"accountHome",member:c}}catch{return{action:"updateSubscription:failed",popupNotification:Ee({type:"updateSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to update subscription, please try again")})}}}async function x8({data:e,state:t,api:n}){try{const{subscriptionId:a,cancellationReason:i}=e;return await n.member.updateSubscription({subscriptionId:a,smartCancel:!0,cancellationReason:i}),{action:"cancelSubscription:success",page:"accountHome",member:await n.member.sessionData()}}catch{return{action:"cancelSubscription:failed",popupNotification:Ee({type:"cancelSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to cancel subscription, please try again")})}}}async function E8({data:e,state:t,api:n}){try{const{subscriptionId:a}=e;return await n.member.updateSubscription({subscriptionId:a,cancelAtPeriodEnd:!1}),{action:"continueSubscription:success",page:"accountHome",member:await n.member.sessionData()}}catch{return{action:"continueSubscription:failed",popupNotification:Ee({type:"continueSubscription:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to cancel subscription, please try again")})}}}async function S8({data:e,state:t,api:n}){try{const{offerId:a,subscriptionId:i}=e;return await n.member.applyOffer({offerId:a,subscriptionId:i}),{action:"applyOffer:success",page:"accountHome",member:await n.member.sessionData(),offers:[],popupNotification:Ee({type:"applyOffer:success",autoHide:!0,closeable:!0,state:t,status:"success",message:"Offer applied successfully!"})}}catch{return{action:"applyOffer:failed",popupNotification:Ee({type:"applyOffer:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:"Failed to apply offer, please try again"})}}}async function C8({data:e,state:t,api:n}){try{await n.member.editBilling(e)}catch{return{action:"editBilling:failed",popupNotification:Ee({type:"editBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to update billing information, please try again")})}}}async function $8({data:e,state:t,api:n}){try{await n.member.manageBilling(e)}catch{return{action:"manageBilling:failed",popupNotification:Ee({type:"manageBilling:failed",autoHide:!1,closeable:!0,state:t,status:"error",message:k("Failed to open billing portal, please try again")})}}}async function j8(){return{popupNotification:null}}async function T8({data:e,state:t}){let{action:n,message:a=""}=e;return n=n||"showPopupNotification:success",{popupNotification:Ee({type:n,autoHide:!0,closeable:!0,state:t,status:"success",message:a})}}async function P8({data:e,state:t,api:n}){try{const{newsletters:a,enableCommentNotifications:i}=e;if(!a&&i===void 0)return{};const r={};return a&&(r.newsletters=a),i!==void 0&&(r.enableCommentNotifications=i),{action:"updateNewsletterPref:success",member:await n.member.update(r)}}catch{return{action:"updateNewsletterPref:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:k("Failed to update newsletter settings")})}}}async function z8({state:e,api:t}){try{return await t.member.deleteSuppression(),{action:"removeEmailFromSuppressionList:success",popupNotification:Ee({type:"removeEmailFromSuppressionList:success",autoHide:!0,closeable:!0,state:e,status:"success",message:k("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:Ee({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:k("Your email has failed to resubscribe, please try again")})}}}async function A8({data:e,state:t,api:n}){try{const{subscribed:a}=e,i=await n.member.update({subscribed:a});if(!i)throw new Error("Failed to update newsletter");const r="updateNewsletter:success";return{action:r,member:i,popupNotification:Ee({type:r,autoHide:!0,closeable:!0,state:t,status:"success",message:k("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:k("Failed to update newsletter settings")})}}}async function N8({data:e,state:t,api:n}){const{email:a}=e,i=VU({member:t.member});if(a!==i)try{return await n.member.updateEmailAddress({email:a}),{success:!0}}catch(r){return{success:!1,error:r}}return null}async function I8({data:e,state:t,api:n}){var r;const a=(r=e==null?void 0:e.name)==null?void 0:r.trim();if(WU({member:t.member})!==a)try{const o=await n.member.update({name:a});if(!o)throw new Error("Failed to update member");return{member:o,success:!0}}catch(o){return{success:!1,error:o}}return null}async function M8({state:e,api:t}){if(e.member)try{const n=await t.member.sessionData();return n?{member:n,success:!0,action:"refreshMemberData:success"}:null}catch(n){return{success:!1,error:n,action:"refreshMemberData:failed"}}return null}async function F8({data:e,state:t,api:n}){const[a,i]=await Promise.all([I8({data:e,state:t,api:n}),N8({data:e,state:t,api:n})]);if(a&&i){if(i.success)return{action:"updateProfile:success",...a.success?{member:a.member}:{},page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:k("Check your inbox to verify email update")})};const r=a.success?k("Failed to send verification email"):k("Failed to update account data");return{action:"updateProfile:failed",...a.success?{member:a.member}:{},popupNotification:Ee({type:"updateProfile:failed",autoHide:!0,closeable:!0,status:"error",message:r,state:t})}}else if(a){const r=a.success?"updateProfile:success":"updateProfile:failed",o=a.success?"success":"error",s=a.success?k("Account details updated successfully"):k("Failed to update account details");return{action:r,...a.success?{member:a.member}:{},...a.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:a.success,closeable:!0,status:o,state:t,message:s})}}else if(i){const r=i.success?"updateProfile:success":"updateProfile:failed",o=i.success?"success":"error";let s="";return i.error?s=xn(i.error,k("Failed to send verification email")):s=k("Check your inbox to verify email update"),{action:r,...i.success?{page:"accountHome"}:{},popupNotification:Ee({type:r,autoHide:i.success,closeable:!0,status:o,state:t,message:s})}}return{action:"updateProfile:success",page:"accountHome",popupNotification:Ee({type:"updateProfile:success",autoHide:!0,closeable:!0,status:"success",state:t,message:k("Account details updated successfully")})}}async function D8({data:{siteUrl:e},state:t}){const n=Wl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,r=Bw(),o=await n.member.getIntegrityToken();return await n.member.sendMagicLink({emailType:"signup",name:a.name,email:a.email,autoRedirect:!1,integrityToken:o,customUrlHistory:t.site.outbound_link_tagging?[{time:Date.now(),referrerSource:r,referrerMedium:"Ghost Recommendations",referrerUrl:i}]:[]}),{}}function O8({data:{recommendationId:e},api:t}){try{const n=localStorage.getItem("ghost-recommendations-clicked"),a=n?JSON.parse(n):[];if(a.includes(e))return;a.push(e),localStorage.setItem("ghost-recommendations-clicked",JSON.stringify(a))}catch{}return t.recommendations.trackClicked({recommendationId:e}),{}}async function _8({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const R8={togglePopup:c8,openPopup:d8,closePopup:nE,switchPage:u8,openNotification:p8,closeNotification:h8,back:m8,signout:f8,signin:g8,startSigninOTCFromCustomForm:y8,verifyOTC:b8,signup:k8,updateSubscription:w8,cancelSubscription:x8,continueSubscription:E8,applyOffer:S8,updateNewsletter:A8,updateProfile:F8,refreshMemberData:M8,clearPopupNotification:j8,editBilling:C8,manageBilling:$8,checkoutPlan:v8,updateNewsletterPreference:P8,showPopupNotification:T8,removeEmailFromSuppressionList:z8,oneClickSubscribe:D8,trackRecommendationClicked:O8,trackRecommendationSubscribed:_8};async function U8({action:e,data:t,state:n,api:a}){const i=R8[e];return i?await i({data:t,state:n,api:a})||{}:{}}function aE(e,t){e&&(e.innerText=t)}function L8(e,t,n){t.classList.add("error");const a=k("There was an error sending the email, please try again");aE(n,xn(e,a))}async function Y8({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:r,captureException:o}){var j,M;t.removeEventListener("submit",i),e.preventDefault(),n&&(n.innerText=""),t.classList.remove("success","invalid","error");let s=e.target.querySelector("input[data-members-email]"),l=e.target.querySelector("input[data-members-name]"),c=((j=t==null?void 0:t.dataset)==null?void 0:j.membersAutoredirect)||"true",p=s==null?void 0:s.value,f=((l==null?void 0:l.value)||"").trim()||void 0,m,g=[],v=[],S=e.target.querySelectorAll("input[data-members-label]")||[];for(let z=0;z<S.length;++z)g.push(S[z].value);let b=e.target.querySelectorAll("input[type=hidden][data-members-newsletter], input[type=checkbox][data-members-newsletter]:checked, input[type=radio][data-members-newsletter]:checked")||[];for(let z=0;z<b.length;++z)v.push({name:b[z].value});t.dataset.membersForm&&(m=t.dataset.membersForm);const w=m==="signin"&&((M=t==null?void 0:t.dataset)==null?void 0:M.membersOtc)==="true";t.classList.add("loading");const E=co(),P={email:p,emailType:m,labels:g,name:f,autoRedirect:c==="true"};w&&(P.includeOTC=!0),E&&(P.urlHistory=E),b.length>0?P.newsletters=v:(e.target.querySelectorAll("input[type=checkbox][data-members-newsletter]")||[]).length>0&&(P.newsletters=[]);try{const R=await(await fetch(`${a}/members/api/integrity-token/`,{method:"GET"})).text(),_=await fetch(`${a}/members/api/send-magic-link/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...P,integrityToken:R})});if(t.addEventListener("submit",i),t.classList.remove("loading"),_.ok){t.classList.add("success");let D;if(w)try{D=await _.clone().json()}catch{D=void 0}const X=D==null?void 0:D.otc_ref;if(X&&typeof r=="function")try{r("startSigninOTCFromCustomForm",{email:(p||"").trim(),otcRef:X,inboxLinks:D==null?void 0:D.inboxLinks})}catch(ne){console.error(ne),o==null||o(ne)}}else{const D=await wn.fromApiResponse(_),X=xn(D,k("Failed to send magic link email"));aE(n,X),t.classList.add("error")}}catch(z){L8(z,t,n)}}function B8({event:e,el:t,errorEl:n,siteUrl:a,site:i,member:r,clickHandler:o}){t.removeEventListener("click",o),e.preventDefault();let s=t.dataset.membersPlan,l=IU(i,s.toLowerCase()),c=t.dataset.membersSuccess,p=t.dataset.membersCancel,f,m;c&&(f=new URL(c,window.location.href).href),p&&(m=new URL(p,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const g=r?{checkoutType:"upgrade"}:{},v=co();return v&&(g.urlHistory=v),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:S,successUrl:f,cancelUrl:m,metadata:g})}).then(function(b){if(!b.ok)throw new Error(k("Could not create stripe checkout session"));return b.json()})}).then(function(S){return S.url?window.location.assign(S.url):window.Stripe(S.publicKey).redirectToCheckout({sessionId:S.sessionId}).then(function(w){if(w.error)throw new Error(w.error.message)})}).catch(function(S){console.error(S),t.addEventListener("click",o),t.classList.remove("loading"),n&&(n.innerText=S.message),t.classList.add("error")})}function V8({siteUrl:e,site:t={},member:n,offers:a=[],doAction:i,captureException:r}={}){if(!e)return;e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(s){let l=s.querySelector("[data-members-error]");function c(p){Y8({event:p,errorEl:l,form:s,siteUrl:e,submitHandler:c,doAction:i,captureException:r})}s.addEventListener("submit",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(s){let l=s.querySelector("[data-members-error]");function c(p){B8({el:s,event:p,errorEl:l,member:n,site:t,siteUrl:e,clickHandler:c})}s.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(s){let l=s.querySelector("[data-members-error]"),c=s.dataset.membersSuccess,p=s.dataset.membersCancel,f,m;c&&(f=new URL(c,window.location.href).href),p&&(m=new URL(p,window.location.href).href);function g(v){s.removeEventListener("click",g),v.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(S){return S.ok?S.text():null}).then(function(S){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:S,successUrl:f,cancelUrl:m})}).then(function(b){if(!b.ok)throw new Error(k("Could not create stripe checkout session"));return b.json()})}).then(function(S){return window.Stripe(S.publicKey).redirectToCheckout({sessionId:S.sessionId})}).then(function(S){if(S.error)throw new Error(k(S.error.message))}).catch(function(S){console.error(S),s.addEventListener("click",g),s.classList.remove("loading"),l&&(l.innerText=S.message),s.classList.add("error")})}s.addEventListener("click",g)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(s){let l=s.querySelector("[data-members-error]"),c=s.dataset.membersReturn,p;c&&(p=new URL(c,window.location.href).href);function f(m){s.removeEventListener("click",f),m.preventDefault(),l&&(l.innerText=""),s.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(g){return g.ok?g.text():null}).then(function(g){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:g,returnUrl:p})}).then(function(v){if(!v.ok)throw new Error(k("Could not create Stripe billing portal session"));return v.json()})}).then(function(g){return window.location.assign(g.url)}).catch(function(g){console.error(g),s.addEventListener("click",f),s.classList.remove("loading"),l&&(l.innerText=g.message),s.classList.add("error")})}s.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(s){function l(c){s.removeEventListener("click",l),c.preventDefault(),s.classList.remove("error"),s.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(p){p.ok?window.location.replace(e):(s.addEventListener("click",l),s.classList.remove("loading"),s.classList.add("error"))})}s.addEventListener("click",l)});const o=(a||[]).some(s=>s.redemption_type==="retention");Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(s){let l=s.parentElement.querySelector("[data-members-error]");function c(p){p.preventDefault();let f=s.dataset.membersCancelSubscription;if(o){i("openPopup",{page:"accountPlan",pageData:{subscriptionId:f,action:"cancel"}});return}return s.removeEventListener("click",c),s.classList.remove("error"),s.classList.add("loading"),l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${f}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,smart_cancel:!0})})}).then(function(m){m.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=k("There was an error cancelling your subscription, please try again.")))})}s.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(s){let l=s.parentElement.querySelector("[data-members-error]");function c(p){s.removeEventListener("click",c),p.preventDefault(),s.classList.remove("error"),s.classList.add("loading");let f=s.dataset.membersContinueSubscription;return l&&(l.innerText=""),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(m){return m.ok?m.text():null}).then(function(m){return fetch(`${e}/members/api/subscriptions/${f}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,cancel_at_period_end:!1})})}).then(function(m){m.ok?window.location.reload():(s.addEventListener("click",c),s.classList.remove("loading"),s.classList.add("error"),l&&(l.innerText=k("There was an error continuing your subscription, please try again.")))})}s.addEventListener("click",c)})}const H8={showPopup:!0,site:_i,member:Zl.free,page:"accountEmail",...s8(),pageData:tE};function W8({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Bd,{children:t}):u.jsx(u.Fragment,{children:t})}class G8 extends re.Component{constructor(t){super(t),this.setupCustomTriggerButton(),this.state={site:null,member:null,offers:[],page:"loading",showPopup:!1,action:"init:running",actionErrorMessage:null,initStatus:"running",lastPage:null,customSiteUrl:t.customSiteUrl,locale:t.locale,scrollbarWidth:0}}componentDidMount(){const t=this.getScrollbarWidth();this.setState({scrollbarWidth:t}),this.initSetup()}componentDidUpdate(t,n){var a,i,r;if(n.showPopup!==this.state.showPopup){this.handleCustomTriggerClassUpdate();try{this.state.showPopup?(this.bodyScroll=(r=(i=(a=window.document)==null?void 0:a.body)==null?void 0:i.style)==null?void 0:r.overflow,this.bodyMargin=window.getComputedStyle(document.body).getPropertyValue("margin-right"),window.document.body.style.overflow="hidden",this.state.scrollbarWidth&&(window.document.body.style.marginRight=`calc(${this.bodyMargin} + ${this.state.scrollbarWidth}px)`)):(window.document.body.style.overflow=this.bodyScroll||"",!this.bodyMargin||this.bodyMargin==="0px"?window.document.body.style.marginRight="":window.document.body.style.marginRight=this.bodyMargin)}catch{}}if(this.state.initStatus==="success"&&n.initStatus!==this.state.initStatus){const{siteUrl:o}=this.props,s=this.getContextFromState();this.sendPortalReadyEvent(),V8({siteUrl:o,site:s.site,member:s.member,offers:s.offers,doAction:s.doAction,captureException:Hs})}}componentWillUnmount(){clearTimeout(this.timeoutId),this.customTriggerButtons&&this.customTriggerButtons.forEach(t=>{t.removeEventListener("click",this.clickHandler)}),window.removeEventListener("hashchange",this.hashHandler,!1)}sendPortalReadyEvent(){window.self!==window.parent&&window.parent.postMessage({type:"portal-ready",payload:{}},"*")}getScrollbarWidth(){const t=document.createElement("div");t.style.visibility="hidden",t.style.overflow="scroll",document.body.appendChild(t),document.body.appendChild(t);const n=t.offsetWidth-t.clientWidth;return document.body.removeChild(t),n}setupCustomTriggerButton(){this.clickHandler=a=>{a.preventDefault();const i=a.currentTarget,r=i&&i.dataset.portal,{page:o,pageQuery:s,pageData:l}=this.getPageFromLinkPath(r)||{};this.state.initStatus==="success"&&(s&&s!=="free"?this.handleSignupQuery({site:this.state.site,pageQuery:s}):this.dispatchAction("openPopup",{page:o,pageQuery:s,pageData:l}))};const t="[data-portal]",n="gh-portal-close";this.customTriggerButtons=document.querySelectorAll(t)||[],this.customTriggerButtons.forEach(a=>{a.classList.add(n),a.removeEventListener("click",this.clickHandler),a.addEventListener("click",this.clickHandler)})}handleCustomTriggerClassUpdate(){var a;const t="gh-portal-open",n="gh-portal-close";(a=this.customTriggerButtons)==null||a.forEach(i=>{const r=this.state.showPopup?t:n,o=this.state.showPopup?n:t;i.classList.add(r),i.classList.remove(o)})}async initSetup(){try{const{site:t,member:n,offers:a,page:i,showPopup:r,popupNotification:o,lastPage:s,pageQuery:l,pageData:c}=await this.fetchData(),p=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Cl.changeLanguage(p);const f={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:r,pageData:c,popupNotification:o,dir:Cl.dir()||"ltr",action:"init:success",initStatus:"success",locale:p};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const m=document.querySelectorAll("[data-lexical-signup-form]");m.length>0&&m.forEach(g=>{g.style.display=""})}this.setupRecommendationButtons(),this.transformPortalLinksToRelative()}catch(t){console.error("[Portal] Failed to initialize:",t),this.setState({action:"init:failed",initStatus:"failed"})}}async fetchData(){const{site:t,member:n,offers:a}=await this.fetchApiData(),{site:i,...r}=this.fetchDevData(),{site:o,...s}=this.fetchLinkData(t,n),{site:l,...c}=this.fetchPreviewData(),{site:p,...f}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...o,...l,...p,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...r,...s,...f,...c}}fetchDevData(){return $e(["dev"])&&!this.state.customSiteUrl?H8:$e(["test"])?{showPopup:this.props.showPopup!==void 0?this.props.showPopup:!0}:{}}fetchOfferQueryStrData(t=""){const n=new URLSearchParams(t),a={};for(let i of n.entries()){const r=i[0],o=decodeURIComponent(i[1]);r==="name"?a.name=o||"":r==="code"?a.code=o||"":r==="display_title"?a.display_title=o||"":r==="display_description"?a.display_description=o||"":r==="type"?a.type=o||"":r==="cadence"?a.cadence=o||"":r==="duration"?a.duration=o||"":r==="duration_in_months"&&!isNaN(Number(o))?a.duration_in_months=Number(o):r==="amount"&&!isNaN(Number(o))?a.amount=Number(o):r==="currency"?a.currency=o||"":r==="status"?a.status=o||"":r==="tier_id"&&(a.tier={id:o||tE.tier.id})}return{page:"offer",pageData:a}}fetchQueryStrData(t=""){const n=new URLSearchParams(t),a={site:{plans:{}}},i=[];let r,o=null,s,l,c;for(let p of n.entries()){const f=p[0],m=decodeURIComponent(p[1]);if(f==="button")a.site.portal_button=JSON.parse(m);else if(f==="name")a.site.portal_name=JSON.parse(m);else if(f==="isFree"&&JSON.parse(m))i.push("free");else if(f==="isMonthly"&&JSON.parse(m))i.push("monthly");else if(f==="isYearly"&&JSON.parse(m))i.push("yearly");else if(f==="portalPrices")r=m?m.split(","):[];else if(f==="portalProducts")o=m?m.split(","):[];else if(f==="page"&&m)a.page=m;else if(f==="accentColor"&&(m===""||m))a.site.accent_color=m;else if(f==="buttonIcon"&&m)a.site.portal_button_icon=m;else if(f==="signupButtonText")a.site.portal_button_signup_text=m||"";else if(f==="signupTermsHtml")a.site.portal_signup_terms_html=m||"";else if(f==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(m);else if(f==="buttonStyle"&&m)a.site.portal_button_style=m;else if(f==="monthlyPrice"&&!isNaN(Number(m)))a.site.plans.monthly=Number(m),s=Number(m);else if(f==="yearlyPrice"&&!isNaN(Number(m)))a.site.plans.yearly=Number(m),l=Number(m);else if(f==="currency"&&m){const g=m.toUpperCase();a.site.plans.currency=g,a.site.plans.currency_symbol=De(g),c=g}else f==="disableBackground"?a.site.disableBackground=JSON.parse(m):f==="membersSignupAccess"&&m?a.site.members_signup_access=m:f==="portalDefaultPlan"&&m?a.site.portal_default_plan=m:f==="transistorPortalSettings"&&m&&(a.site.transistor_portal_settings=JSON.parse(m))}return a.site.portal_plans=i,a.site.portal_products=o,r?a.site.portal_plans=r:s&&l&&c&&(a.site.prices=[{id:"monthly",stripe_price_id:"dummy_stripe_monthly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Monthly",currency:c,amount:s,type:"recurring",interval:"month"},{id:"yearly",stripe_price_id:"dummy_stripe_yearly",stripe_product_id:"dummy_stripe_product",active:1,nickname:"Yearly",currency:c,amount:l,type:"recurring",interval:"year"}]),a}fetchNotificationData(){const{type:t,status:n,duration:a,autoHide:i,closeable:r}=nx({billingOnly:!0})||{};return["stripe:billing-update"].includes(t)?n==="success"?{showPopup:!0,popupNotification:Ee({type:t,status:n,duration:a,closeable:r,autoHide:i,state:this.state,message:n==="success"?"Billing info updated successfully":""})}:{showPopup:!0}:{}}fetchLinkData(t,n){const a=new URLSearchParams(window.location.search);if(a.get("action")==="unsubscribe")return a.get("key")&&a.get("uuid")?{showPopup:!0,page:"unsubscribe",pageData:{uuid:a.get("uuid"),key:a.get("key"),newsletterUuid:a.get("newsletter"),comments:a.get("comments")}}:{showPopup:!0,page:"accountEmail",pageData:{newsletterUuid:a.get("newsletter"),action:"unsubscribe",redirect:t.url+"#/portal/account/newsletters"}};if(DU({site:t})&&a.get("action")==="signup"&&a.get("success")==="true")return{showPopup:!0,page:"recommendations",pageData:{signup:!0}};const[i,r]=window.location.hash.substr(1).split("?"),o=new URLSearchParams(r??""),s=/^(?:(\w+?))?\/monthly$/,l=/^(?:(\w+?))?\/yearly$/,c=/^offers\/(\w+?)\/?$/,p=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,m,g]=i.match(f),v=parseInt(g);if(v===1||v===0)return n||o.get("uuid")&&o.get("key")?{showPopup:!0,page:"feedback",pageData:{uuid:n?null:o.get("uuid"),key:n?null:o.get("key"),postId:m,score:v}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${m}/${v}/`}}}if(i&&p.test(i)){const[,m]=i.match(p),{page:g,pageQuery:v,pageData:S}=this.getPageFromLinkPath(m,t)||{};if(!n&&g&&qx({page:g}))return{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/portal/${m}/`}};const b=["accountPlan","accountProfile"].includes(g)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(v)||s.test(v)||l.test(v)||c.test(v)),...g?{page:g}:{},...v?{pageQuery:v}:{},...S?{pageData:S}:{},...b?{lastPage:b}:{}}}return{}}fetchPreviewData(){const[,t]=window.location.hash.substr(1).split("?");if($e(["preview"])){let n={};return $e(["offerPreview"])?n=this.fetchOfferQueryStrData(t):n=this.fetchQueryStrData(t),{...n,showPopup:!0}}return{}}getColorOverride(){const t=document.querySelector("script[data-ghost]");return t&&t.dataset.accentColor?t.dataset.accentColor:!1}async fetchApiData(){const{siteUrl:t,customSiteUrl:n,apiUrl:a,apiKey:i}=this.props;try{this.GhostApi=this.props.api||Wl({siteUrl:t,apiUrl:a,apiKey:i});const{site:r,member:o,offers:s}=await this.GhostApi.init(),l=this.getColorOverride();return l&&(r.accent_color=l),this.setupFirstPromoter({site:r,member:o}),this.setupSentry({site:r}),{site:r,member:o,offers:s}}catch(r){if($e(["dev","test"],{customSiteUrl:n}))return{};throw r}}setupSentry({site:t}){if($e(["test"]))return null;const{portal_sentry:n,portal_version:a,version:i}=t,o=`portal@2.64.3|ghost@${i}`;n&&n.dsn&&kT({dsn:n.dsn,environment:n.env||"development",release:o,beforeSend:s=>jU({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if($e(["test"]))return null;const a=HU({site:t});let i=rp({site:t});if(i=i==null?void 0:i.replace(/^(\S*\.)?(\S*\.\S*)$/i,".$2"),a&&i){const r=document.createElement("script");r.type="text/javascript",r.async=!0,r.src="https://cdn.firstpromoter.com/fprom.js",r.onload=r.onreadystatechange=function(){let s=this.readyState;if(!s||s==="complete"||s==="loaded")try{if(window.$FPROM.init(a,i),nL({member:n})){const l=n.email,c=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:l,uid:c});else{const p=window._fprom||[];window._fprom=p,p.push(["event","signup"]),p.push(["email",l]),p.push(["uid",c])}}}catch{}};const o=document.getElementsByTagName("script")[0];o.parentNode.insertBefore(r,o)}}async dispatchAction(t,n){clearTimeout(this.timeoutId),this.setState({action:`${t}:running`,actionErrorMessage:null});try{const a=await U8({action:t,data:n,state:this.state,api:this.GhostApi});this.setState(a),a&&a.action&&!a.action.includes(":failed")&&(this.timeoutId=setTimeout(()=>{this.setState({action:""})},2e3))}catch(a){if(console.error(`[Portal] Failed to dispatch action: ${t}`,a),n&&n.throwErrors)throw a;const i=Ee({type:`${t}:failed`,autoHide:!0,closeable:!0,status:"error",state:this.state,meta:{error:a}});this.setState({action:`${t}:failed`,actionErrorMessage:xn(a,k("An unexpected error occured. Please try again or <a>contact support</a> if the error persists.")),popupNotification:i})}}updateStateForPreviewLinks(){const{site:t,...n}=this.fetchPreviewData(),{site:a,...i}=this.fetchLinkData(this.state.site,this.state.member),r={site:{...this.state.site,...a||{},...t||{},plans:{...this.state.site&&this.state.site.plans,...(a||{}).plans,...(t||{}).plans}},...i,...n};this.handleSignupQuery({site:r.site,pageQuery:r.pageQuery}),this.setState(r)}async handleOfferQuery({site:t,offerId:n,member:a=this.state.member}){const{portal_button:i}=t;if(Qm(),!an({member:a})||Qn({member:a}))try{const r=await this.GhostApi.site.offer({offerId:n}),o=r==null?void 0:r.offers[0];if(!o||!o.tier||Jw({offer:o})||!ZU({site:t,offer:o}))return;if(i)this.dispatchAction("openPopup",{page:"offer",pageData:r==null?void 0:r.offers[0]});else{const s=Pa({site:t,productId:o.tier.id}),l=o.cadence==="month"?s.monthlyPrice:s.yearlyPrice;if(this.dispatchAction("openPopup",{page:"loading"}),a){const{tierId:c,cadence:p}=Aa({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:p})}else{const{tierId:c,cadence:p}=Aa({site:t,priceId:l.id});this.dispatchAction("signup",{plan:l.id,offerId:n,tierId:c,cadence:p})}}}catch{}}handleSignupQuery({site:t,pageQuery:n,member:a}){const i=/^offers\/(\w+?)\/?$/;let r=n;if(i.test(n||"")){const[,s]=n.match(i);this.handleOfferQuery({site:t,offerId:s,member:a});return}qw({site:t,pageQuery:n})&&(r=qw({site:t,pageQuery:n}));const o=MU({site:t,priceId:r});if(n&&n!=="free"){Qm();const s=(o==null?void 0:o.id)||r;s!=="free"&&this.dispatchAction("openPopup",{page:"loading"});const{tierId:l,cadence:c}=Aa({site:t,priceId:s});this.dispatchAction("signup",{plan:s,tierId:l,cadence:c})}}getPageFromLinkPath(t){const n=/^signup\/?(?:\/(\w+?))?\/?$/,a=/^signup\/?(?:\/(\w+?))\/monthly\/?$/,i=/^signup\/?(?:\/(\w+?))\/yearly\/?$/,r=/^offers\/(\w+?)\/?$/;if(t===void 0||t==="")return{page:"default"};if(r.test(t))return{pageQuery:t};if(t==="signup")return{page:"signup"};if(a.test(t)){const[,o]=t.match(a);return{page:"signup",pageQuery:`${o}/monthly`}}else if(i.test(t)){const[,o]=t.match(i);return{page:"signup",pageQuery:`${o}/yearly`}}else if(n.test(t)){const[,o]=t.match(n);return{page:"signup",pageQuery:o}}else{if(t==="signup/free")return{page:"signup",pageQuery:"free"};if(t==="signup/monthly")return{page:"signup",pageQuery:"monthly"};if(t==="signup/yearly")return{page:"signup",pageQuery:"yearly"};if(t==="signin")return{page:"signin"};if(t==="account")return{page:"accountHome"};if(t==="account/plans")return{page:"accountPlan"};if(t==="account/profile")return{page:"accountProfile"};if(t==="account/newsletters")return{page:"accountEmail"};if(t==="support")return{page:"support"};if(t==="support/success")return{page:"supportSuccess"};if(t==="support/error")return{page:"supportError"};if(t==="recommendations")return{page:"recommendations",pageData:{signup:!1}};if(t==="account/newsletters/help")return{page:"emailReceivingFAQ",pageData:{direct:!0}};if(t==="account/newsletters/disabled")return{page:"emailSuppressionFAQ",pageData:{direct:!0}}}return{page:"default"}}getAccentColor(){const{accent_color:t}=this.state.site||{};return I6(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=rn({site:t})||!Sn({site:t})?"signin":"signup";n=a?"accountHome":i}return Bp({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return $e(["dev","preview"],{customSiteUrl:a})?qx({page:t})||Q5({page:t})?$e(["dev"],{customSiteUrl:a})?n||Zl.free:$e(["preview"])?Zl.preview:Zl.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:r,page:o,lastPage:s,showPopup:l,pageQuery:c,pageData:p,popupNotification:f,customSiteUrl:m,dir:g,scrollbarWidth:v,otcRef:S,inboxLinks:b}=this.state,w=this.getContextPage({site:t,page:o,member:n}),E=this.getContextMember({page:w,member:n,customSiteUrl:m});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:r,brandColor:this.getAccentColor(),page:w,pageQuery:c,pageData:p,member:E,lastPage:s,showPopup:l,popupNotification:f,customSiteUrl:m,dir:g,scrollbarWidth:v,otcRef:S,inboxLinks:b,doAction:(P,j)=>this.dispatchAction(P,j)}}getRecommendationButtons(){return document.querySelectorAll("[data-recommendation]")||[]}setupRecommendationButtons(){const t=a=>{const i=a.currentTarget.dataset.recommendation;i?this.dispatchAction("trackRecommendationClicked",{recommendationId:i}).catch(console.error):console.warn("[Portal] Invalid usage of data-recommendation attribute")},n=this.getRecommendationButtons();for(const a of n)a.addEventListener("click",t,{passive:!0})}transformPortalLinksToRelative(){document.querySelectorAll('a[href*="#/portal"]').forEach(l8)}render(){return this.state.initStatus==="success"?u.jsx(W8,{site:this.state.site,children:u.jsxs(H.Provider,{value:this.getContextFromState(),children:[u.jsx(Hp,{}),u.jsx(lp,{}),u.jsx(hp,{})]})}):null}}const iE="ghost-portal-root";function K8(){const e=document.createElement("div");e.id=iE,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function q8(){const e=document.querySelector("script[data-ghost]");if(e){const t=e.dataset.i18n==="true",n=e.dataset.ghost,a=e.dataset.key,i=e.dataset.api,r=e.dataset.locale;return{siteUrl:n,apiKey:a,apiUrl:i,siteI18nEnabled:t,locale:r}}return{}}function J8(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function Z8(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=q8(),r=e||window.location.origin;K8(),J8(),TC.render(u.jsx(re.StrictMode,{children:u.jsx(G8,{siteUrl:r,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(iE))}Z8()});
7541
7541
  //# sourceMappingURL=portal.min.js.map