@tryghost/portal 2.62.0 → 2.62.1
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 +1 -1
- package/umd/portal.min.js +1 -1
package/package.json
CHANGED
package/umd/portal.min.js
CHANGED
|
@@ -7533,5 +7533,5 @@ html[dir="rtl"] .gh-portal-list-toggle-wrapper .gh-portal-list-detail {
|
|
|
7533
7533
|
.gh-portal-hide {
|
|
7534
7534
|
display: none;
|
|
7535
7535
|
}
|
|
7536
|
-
`;function k5({site:e}){return Zm+g5+uL+LL+XL+TL()+lL+iL+sL+Ow+L6+z6+H6()+lp+Y6+y5+b5+G6+e5+t5+n5+i5+s5+c5+h5}const nh=class nh 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:Ul({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:v("jamie@example.com"),label:v("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=v(a?"Sending login link...":"Continue");const r=!!a;return t==="signin:failed"&&(i=v("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:v("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:v("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=$l({site:t})&&Sn({site:t});return ea({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Rl,{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:v("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(bx,{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:v("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()]})})]})}};nh.contextType=H;let _p=nh;const v5=({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:v("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:v("Contact support")})})})})]})},w5=()=>{const{member:e,brandColor:t}=S.useContext(H),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(Jm,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:v("Your account")})]})},x5=()=>{const{site:e,action:t,brandColor:n,doAction:a}=S.useContext(H);if(!$l({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:v("View plans"),onClick:()=>r(),brandColor:n,style:{width:"100%"}})},E5=()=>{const{member:e,site:t}=S.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&&Qm({member:e})){const o=Qm({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:v("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(np({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:v("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:v("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:v("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx(x5,{})]})},S5=()=>{const{member:e,doAction:t,action:n,brandColor:a}=S.useContext(H),i=Ft({member:e});if(!i||!i.cancel_at_period_end)return null;const r=i.cancel_at_period_end?v("Continue subscription"):v("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 m=i.current_period_end;return u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:En(m)})})};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%"}})]})},C5=e=>S.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("defs",null,S.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),S.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"}),S.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"})),$5=()=>{const{member:e,site:t,doAction:n}=S.useContext(H),a=()=>{const p=Ft({member:e});n("manageBilling",{subscriptionId:p.id})},i=()=>{const{is_stripe_configured:p}=t;p&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},r=({price:p,isComplimentary:y,subscription:k})=>{const{next_payment:j}=k||{};let b="";if(p){const{amount:z=0,currency:R,interval:_}=p;b=`${Intl.NumberFormat("en",{currency:R,style:"currency"}).format(z/100)}/${v(_)}`}const w=Qm({member:e});y&&(w?b=`${v("Complimentary")} - ${v("Expires {expiryDate}",{expiryDate:w})}`:b=b?`${v("Complimentary")} (${b})`:v("Complimentary"));let E="";const P=np({sub:k});if(P&&(E="gh-portal-account-old-price"),P)return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(j5,{subscription:k})]});let $=T5({nextPayment:j});$&&(E="gh-portal-account-old-price");const F=()=>$?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(C5,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:$})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(F,{})]})},o=({isPaid:p})=>Ni({site:t})&&!p?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:y=>i(),"data-test-button":"change-plan",children:v("Change")}),s=({defaultCardLast4:p})=>{if(p){const y=`**** **** **** ${p}`;return u.jsx("p",{children:y})}return null},l=({defaultCardLast4:p,isComplimentary:y})=>{const{action:k}=S.useContext(H),j=k==="manageBilling:running"?u.jsx(Ii,{className:"gh-portal-billing-button-loader"}):v("Update");return y?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Billing info & receipts")}),u.jsx(s,{defaultCardLast4:p})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:b=>a(),"data-test-button":"manage-billing",children:j})]})},c=Ft({member:e}),m=Qn({member:e}),f=rn({member:e});if(c||m){const{price:p,default_payment_card_last4:y}=c||{};let k=v("Plan");return jl({site:t})&&Uw({member:e})&&(k=Uw({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k}),u.jsx(r,{price:p,isComplimentary:m,subscription:c})]}),u.jsx(o,{isPaid:f})]}),u.jsx(l,{isComplimentary:m,defaultCardLast4:y})]})}return null};function j5({subscription:e}){if(np({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:v("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function T5({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";let n="";t.duration==="forever"?n=v("Forever"):t.duration==="once"?n=v("Next payment"):t.duration==="repeating"&&t.end&&(n=v("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 P5(){const{member:e,site:t,doAction:n}=S.useContext(H);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let r=v(i?"Subscribed":"Unsubscribed");const o=s=>{var m;s.preventDefault();const l=za({site:t}),c=(m=e==null?void 0:e.newsletters)!=null&&m.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:v("Email newsletter")}),u.jsxs("p",{children:[r," ",ap({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:v("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Dl,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{o(s)},checked:i})})]})}const Ux=e=>S.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},S.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"}),S.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 z5(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(Ux,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:v("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:v("You're currently not receiving emails")})]})}function A5(){const{doAction:e,member:t,site:n}=S.useContext(H),a=Bw({member:t}),i=oo({site:n}),r=Tl({site:n}),o=a?"emailSuppressed":"accountEmail",s=!i&&!r,l=()=>a||s?u.jsx(z5,{}):u.jsx("p",{children:v("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("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:v("Manage")})]})}const N5=()=>{var o;const{member:e,site:t}=S.useContext(H),n=!!((o=t.labs)!=null&&o.transistor),a=e==null?void 0:e.uuid,[i,r]=S.useState(!1);return S.useEffect(()=>{if(!n||!a){r(!1);return}r(!1);const s=new AbortController;return(async()=>{try{const c=await fetch(`https://partner.transistor.fm/ghost/member/${a}`,{signal:s.signal});if(c.ok){const m=await c.json();s.signal.aborted||r((m==null?void 0:m.member)===!0)}}catch(c){if(s.signal.aborted)return;console.warn("Error in Transistor request",c)}})(),()=>s.abort()},[n,a]),{transistor:{enabled:n,hasPodcasts:i,memberUuid:a}}},I5=(e,t)=>lo({site:e})&&oo({site:e})||Tl({site:e})||Bw({member:t}),M5=e=>!lo({site:e})&&oo({site:e})&&!Tl({site:e}),F5=()=>{const{member:e,doAction:t,site:n}=S.useContext(H),{name:a,email:i}=e,{transistor:r}=N5(),o=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=I5(n,e),l=M5(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||v("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:v("Edit")})]}),u.jsx($5,{}),s&&u.jsx(A5,{}),l&&u.jsx(P5,{}),u.jsx(f5,{hasPodcasts:r.hasPodcasts,memberUuid:r.memberUuid})]})})},D5=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(Oe,{}),u.jsx(w5,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(E5,{}),u.jsx(S5,{}),u.jsx(F5,{})]})]}),ah=class ah 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(D5,{}),u.jsx(v5,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ah.contextType=H;let Rp=ah;const ih=class ih 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:Ul({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=v("Save");this.context.action==="updateProfile:failed"&&(n=v("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:v("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:v("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(Jm,{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:v("Jamie Larson"),label:v("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("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(Rl,{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}};ih.contextType=H;let Up=ih;function O5(){const{brandColor:e,lastPage:t,doAction:n}=S.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:v("Email preferences")})]})}function _5({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(Dl,{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 R5({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=S.useContext(H),i=!!n;if(!t)return null;const r=async(o,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:v("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:v("Comments")}),u.jsx("p",{children:v("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Dl,{id:"comments",onToggle:r,checked:i,dataTestId:"switch-input"})})]})}function U5({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=S.useContext(H),i=za({site:a});return n?i.map(r=>u.jsx(_5,{newsletter:r,subscribedNewsletters:e,setSubscribedNewsletters:t},r==null?void 0:r.id)):null}function L5({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:v("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Lx({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:r,isPaidMember:o,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:m,member:f,site:p}=S.useContext(H),y=!(n!=null&&n.length)&&(s&&!l||!s),j=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),u.jsx(O5,{}),u.jsx(j,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(U5,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:b=>{let w=b.map(E=>({id:E.id}));a(w)}}),u.jsx(R5,{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:y,brandColor:c,isPrimary:!1,label:v("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(ap({member:f})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(L5,{isPaid:o,site:p,subscribedNewsletters:n})}),ap({member:f})&&!y&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:v("Not receiving emails?")}),u.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>m("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[v("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function Y5(){const{member:e,doAction:t,site:n,pageData:a}=S.useContext(H);let i,r;a&&(i=a.newsletterUuid,r=a.action);const[o,s]=S.useState(!0),l=za({site:n}),c=oo({site:n});S.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),S.useEffect(()=>{if(i&&r==="unsubscribe"){const b=e==null?void 0:e.newsletters.filter(w=>w.uuid!==i);y(b),s(!1),t("updateNewsletterPreference",{newsletters:b})}},[]);const m=()=>{if(a.comments&&k){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:v("{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:v("{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)||[]],[p,y]=S.useState(f),{comments_enabled:k}=n,{enable_comment_notifications:j}=e||{};return S.useEffect(()=>{y((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(Lx,{hasNewslettersEnabled:c,notification:i?m:null,subscribedNewsletters:p,updateSubscribedNewsletters:b=>{y(b),t("updateNewsletterPreference",{newsletters:b}),t("showPopupNotification",{action:"updated:success",message:v("Email preferences updated.")})},updateCommentNotifications:async b=>{t("updateNewsletterPreference",{enableCommentNotifications:b})},unsubscribeAll:()=>{y([]),t("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")});const b={newsletters:[]};k&&(b.enableCommentNotifications=!1),t("updateNewsletterPreference",b)},isPaidMember:rn({member:e}),isCommentsEnabled:k!=="off",enableCommentNotifications:j})}function B5(){const{site:e}=S.useContext(H),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function V5(){const{site:e}=S.useContext(H),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(B5,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Yx({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 H5(){const{site:e,api:t,pageData:n,member:a,doAction:i}=S.useContext(H),[r,o]=S.useState(),[s,l]=S.useState(!0),c=za({site:e}),m=c.filter(_=>_.subscribe_on_signup),[f,p]=S.useState(!1),[y,k]=S.useState(m),[j,b]=S.useState(!1),{comments_enabled:w}=e,{enable_comment_notifications:E=!1}=r||{},P=oo({site:e}),$=async _=>{a?i("updateNewsletterPreference",{newsletters:_}):await Yx({api:t,memberUuid:n.uuid,key:n.key,newsletters:_}),k(_);const D={action:"updated:success",message:v("Email preferences updated.")};i("showPopupNotification",D)},F=async _=>{let D;a?(await i("updateNewsletterPreference",{enableCommentNotifications:_}),D={...a,enable_comment_notifications:_}):D=await Yx({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:_}),o(D),i("showPopupNotification",{action:"updated:success",message:v("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}),k([]),o(_),i("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")})};if(S.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)||[];k(D),(c==null?void 0:c.length)===1&&!w&&!n.newsletterUuid?await $([]):n.newsletterUuid?await $(D==null?void 0:D.filter(X=>X.uuid!==n.newsletterUuid)):n.comments&&w&&await F(!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(cp,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:v("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:v("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:v("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!w&&!j)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(Oe,{}),u.jsx(V5,{}),u.jsx("h1",{className:"gh-portal-main-title",children:v("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("{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:v("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:v("{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:v("{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(Lx,{hasNewslettersEnabled:P,notification:R,subscribedNewsletters:y,updateSubscribedNewsletters:async _=>{await $(_),p(!0)},updateCommentNotifications:F,unsubscribeAll:async()=>{await z(),p(!0)},isPaidMember:(r==null?void 0:r.status)!=="free",isCommentsEnabled:w!=="off",enableCommentNotifications:E})}function W5(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=S.useContext(H);S.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(lo({site:i})||Tl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:v("You have been successfully resubscribed")})):n("back"))},[a,n,i,v]);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(Ux,{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:v("Emails disabled")}),u.jsx("p",{children:v("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:v("Re-enable emails"),isRunning:r})]})}function G5(){const{brandColor:e,doAction:t,site:n,pageData:a}=S.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:v("Why has my email been disabled?")}),u.jsx("p",{children:v("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:v("Spam complaints")}),u.jsx("p",{children:v("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:v("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:v("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:v("Permanent failure (bounce)")}),u.jsx("p",{children:v("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:v("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:v("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:v("Need more help? Contact support")})})]})]})}function K5(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:r}=S.useContext(H),o=uo({site:n}),s=`mailto:${o}`,l=LU({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:v("Help! I'm not receiving emails")}),u.jsx("p",{children:v("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:v("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Check spam & promotions folders")}),u.jsx("p",{children:v(`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:v("Create a new contact")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Check with your mail provider")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Get in touch for help")}),u.jsx("p",{children:u.jsx(ut,{string:v("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 Lp={signin:_p,signup:Ip,accountHome:Rp,accountPlan:wp,accountProfile:Up,accountEmail:Y5,signupNewsletter:Ep,unsubscribe:H5,magiclink:Mp,loading:ko,offer:Dp,feedback:Q6,emailSuppressed:W5,emailSuppressionFAQ:G5,emailReceivingFAQ:K5,support:()=>{const[e,t]=S.useState(!0),[n,a]=S.useState(null),[i,r]=S.useState(null),{member:o,site:s}=S.useContext(H);return S.useEffect(()=>{async function l(){const c=s.url,m=window.location.origin+window.location.pathname,f=o?`${m}?action=support&success=true`:`${m}#/portal/support/success`,p=m,y=Hl({siteUrl:c});try{const k=await y.member.checkoutDonation({successUrl:f,cancelUrl:p,personalNote:v("Add a personal note")});k.url&&window.location.replace(k.url)}catch(k){k.type&&k.type==="DisabledFeatureError"?r(v("This site is not accepting payments at the moment.")):a(v("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(r(v("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(ko,{})}):n?u.jsx(Op,{error:n}):i?u.jsx(Op,{error:i}):null},supportSuccess:r5,supportError:Op,recommendations:p5},Yp=function({page:e}){return Object.keys(Lp).includes(e)?e:"signup"},q5=function({page:e}){return e.includes("account")},J5=function({page:e}){return e.includes("offer")},Z5=e=>S.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.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"})),rh=class rh 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(Z5,{}),"Powered by Ghost"]})}};rh.contextType=H;let Wl=rh;const Bx=()=>({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 X5({message:e}){return Ai()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const oh=class oh 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;Yp({page:t});const n=Lp[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(Fp,{})}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=Al({site:a,pageQuery:n}).length;Yp({page:t});const l={...Bx().page[t]};let c="",m="regular",f="",p=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":p="account-home";break;case"accountProfile":p="account-profile";break;case"accountPlan":p="account-plan";break;default:f="Cookies must be enabled in your browser.",p=t;break}o>1&&!Vt({site:a})&&Sn({site:a,pageQuery:n})&&t==="signup"&&(p+=" full-size",m="full");const y=so({site:a});(y&&o>2||!y&&o>1)&&t==="accountPlan"&&(p+=" full-size",m="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(p+=" large-size");let k="gh-portal-popup-container";$e(["preview"])&&(p+=" preview"),$e(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(k+=" preview"),$e(["dev"])&&(k+=" dev");const j=`${k} ${c} ${p}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+p,onClick:b=>this.handlePopupClose(b),children:[this.renderPopupNotification(),u.jsxs("div",{className:j,style:l,ref:b=>this.node=b,tabIndex:-1,children:[u.jsx(X5,{message:f}),this.renderActivePage(),m==="full"?u.jsx("div",{className:"gh-portal-powered inside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Wl,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Wl,{})})]})}};oh.contextType=H;let Bp=oh;const sh=class sh extends re.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=Lp[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=k5({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=Bx(),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(Km,{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(Bp,{isMobile:r})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};sh.contextType=H;let Vp=sh;Gl({products:Hp({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 Q5(){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 Gl({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=Hp({numOfProducts:1}),portalProducts:s=o.map(X=>X.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:m="all",freePriceName:f="Free",freePriceDescription:p="Free preview",isStripeConfigured:y=!0,portalButton:k=!0,portalName:j=!0,portalButtonIcon:b="icon-1",portalButtonSignupText:w="Subscribe now",portalButtonStyle:E="icon-and-text",membersSupportAddress:P="support@example.com",editorDefaultEmailRecipients:$="visibility",newsletters:F=[],posts:z=e8(),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:m,free_price_name:f,free_price_description:p,is_stripe_configured:y,portal_button:k,portal_name:j,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:F,recommendations:_,recommendations_enabled:!!D,editor_default_email_recipients:$,posts:z}}function Vx({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:m=null,status:f="active",tierId:p="",tierName:y="Basic",redemptionType:k="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:m,status:f,tier:{id:`${p}`,name:y},redemption_type:k}}function Wt({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:Q5(),email:t,name:e,firstname:n,paid:i,subscribed:o,avatar_image:r,subscriptions:a,email_suppression:s,newsletters:l}}function e8({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(t8({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function t8({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 Hp({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=Hx({});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:Wx({numOfBenefits:o}),trial_days:s}}function Hx({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:Wx({numOfBenefits:a})}}function Wx({numOfBenefits:e}){const t=at();return[Kl({name:`Limited early adopter pricing #${t.substring(0,6)}`}),Kl({name:`Latest gear reviews #${t.substring(6,12)}`}),Kl({name:`Weekly email newsletter #${t.substring(12,18)}`}),Kl({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function Kl({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=a8,priceId:l=`price_${at()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:m="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:f=!1,trialEndAt:p=null,nextPayment:y=null,tier:k=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:m,trial_end_at:p,next_payment:y,tier:k,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 Gx(){const e=Hp({numOfProducts:1}),t=e.map(a=>a.id);return Gl({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}Gx();const n8=Gl({products:[Oi({numOfBenefits:2,type:"free"})]}),a8=Vx({tierId:(Xx=n8.products[0])==null?void 0:Xx.id});Wt(),Wt({paid:!0,subscriptions:[Na()]}),Wt({paid:!0,subscriptions:[]}),Wt({paid:!0,subscriptions:[Na({amount:0})]}),Wt({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),Gx();const ql=[Hx({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=Gl({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:ql,portalProducts:ql.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}]}),Kx=Vx({tierId:(Qx=_i.products[1])==null?void 0:Qx.id}),Jl={free:Wt({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Wt({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:Wt({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Wt({paid:!0,subscriptions:[Na({amount:0})]}),preview:Wt({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]})};function i8(){var n;if(!ql||!ql[1])return null;let e=(n=_i==null?void 0:_i.products)==null?void 0:n[1].monthlyPrice,t=Wt({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 r8(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 o8({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function s8({state:e}){return{showPopup:!e.showPopup}}function l8({data:e}){return{showPopup:!0,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function u8({state:e}){return e.lastPage?{page:e.lastPage}:qx({state:e})}function qx({state:e}){return Xm(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function c8({data:e}){return{showNotification:!0,...e}}function d8(){return{showNotification:!1}}async function m8({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:v("Failed to log out, please try again")})}}}async function p8({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,v("Failed to log in, please try again"))})}}}function h8({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 f8({data:e,api:t}){var a;const n=v("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 g8({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 m;if(a.toLowerCase()==="free"){const f=await n.member.getIntegrityToken();({inboxLinks:m}=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:m,pageData:{...t.pageData||{},email:(o||"").trim()}}}catch(a){const i=xn(a,v("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 y8({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:v("Failed to process checkout, please try again")})}}}async function b8({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(),m="updateSubscription:success";return{action:m,popupNotification:Ee({type:m,autoHide:!0,closeable:!0,state:t,status:"success",message:v("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:v("Failed to update subscription, please try again")})}}}async function k8({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:v("Failed to cancel subscription, please try again")})}}}async function v8({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:v("Failed to cancel subscription, please try again")})}}}async function w8({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 x8({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:v("Failed to update billing information, please try again")})}}}async function E8({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:v("Failed to open billing portal, please try again")})}}}async function S8(){return{popupNotification:null}}async function C8({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 $8({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:v("Failed to update newsletter settings")})}}}async function j8({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:v("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:Ee({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:v("Your email has failed to resubscribe, please try again")})}}}async function T8({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:v("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function P8({data:e,state:t,api:n}){const{email:a}=e,i=_U({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 z8({data:e,state:t,api:n}){var r;const a=(r=e==null?void 0:e.name)==null?void 0:r.trim();if(UU({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 A8({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 N8({data:e,state:t,api:n}){const[a,i]=await Promise.all([z8({data:e,state:t,api:n}),P8({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:v("Check your inbox to verify email update")})};const r=a.success?v("Failed to send verification email"):v("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?v("Account details updated successfully"):v("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,v("Failed to send verification email")):s=v("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:v("Account details updated successfully")})}}async function I8({data:{siteUrl:e},state:t}){const n=Hl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,r=Lw(),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 M8({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 F8({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const D8={togglePopup:s8,openPopup:l8,closePopup:qx,switchPage:o8,openNotification:c8,closeNotification:d8,back:u8,signout:m8,signin:p8,startSigninOTCFromCustomForm:h8,verifyOTC:f8,signup:g8,updateSubscription:b8,cancelSubscription:k8,continueSubscription:v8,applyOffer:w8,updateNewsletter:T8,updateProfile:N8,refreshMemberData:A8,clearPopupNotification:S8,editBilling:x8,manageBilling:E8,checkoutPlan:y8,updateNewsletterPreference:$8,showPopupNotification:C8,removeEmailFromSuppressionList:j8,oneClickSubscribe:I8,trackRecommendationClicked:M8,trackRecommendationSubscribed:F8};async function O8({action:e,data:t,state:n,api:a}){const i=D8[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Jx(e,t){e&&(e.innerText=t)}function _8(e,t,n){t.classList.add("error");const a=v("There was an error sending the email, please try again");Jx(n,xn(e,a))}async function R8({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:r,captureException:o}){var $,F;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=(($=t==null?void 0:t.dataset)==null?void 0:$.membersAutoredirect)||"true",m=s==null?void 0:s.value,f=((l==null?void 0:l.value)||"").trim()||void 0,p,y=[],k=[],j=e.target.querySelectorAll("input[data-members-label]")||[];for(let z=0;z<j.length;++z)y.push(j[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)k.push({name:b[z].value});t.dataset.membersForm&&(p=t.dataset.membersForm);const w=p==="signin"&&((F=t==null?void 0:t.dataset)==null?void 0:F.membersOtc)==="true";t.classList.add("loading");const E=co(),P={email:m,emailType:p,labels:y,name:f,autoRedirect:c==="true"};w&&(P.includeOTC=!0),E&&(P.urlHistory=E),b.length>0?P.newsletters=k:(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:(m||"").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,v("Failed to send magic link email"));Jx(n,X),t.classList.add("error")}}catch(z){_8(z,t,n)}}function U8({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=jU(i,s.toLowerCase()),c=t.dataset.membersSuccess,m=t.dataset.membersCancel,f,p;c&&(f=new URL(c,window.location.href).href),m&&(p=new URL(m,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const y=r?{checkoutType:"upgrade"}:{},k=co();return k&&(y.urlHistory=k),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(j){return j.ok?j.text():null}).then(function(j){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:j,successUrl:f,cancelUrl:p,metadata:y})}).then(function(b){if(!b.ok)throw new Error(v("Could not create stripe checkout session"));return b.json()})}).then(function(j){return j.url?window.location.assign(j.url):window.Stripe(j.publicKey).redirectToCheckout({sessionId:j.sessionId}).then(function(w){if(w.error)throw new Error(w.error.message)})}).catch(function(j){console.error(j),t.addEventListener("click",o),t.classList.remove("loading"),n&&(n.innerText=j.message),t.classList.add("error")})}function L8({siteUrl:e,site:t={},member:n,doAction:a,captureException:i}={}){e&&(e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(r){let o=r.querySelector("[data-members-error]");function s(l){R8({event:l,errorEl:o,form:r,siteUrl:e,submitHandler:s,doAction:a,captureException:i})}r.addEventListener("submit",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(r){let o=r.querySelector("[data-members-error]");function s(l){U8({el:r,event:l,errorEl:o,member:n,site:t,siteUrl:e,clickHandler:s})}r.addEventListener("click",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(r){let o=r.querySelector("[data-members-error]"),s=r.dataset.membersSuccess,l=r.dataset.membersCancel,c,m;s&&(c=new URL(s,window.location.href).href),l&&(m=new URL(l,window.location.href).href);function f(p){r.removeEventListener("click",f),p.preventDefault(),o&&(o.innerText=""),r.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(y){return y.ok?y.text():null}).then(function(y){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:y,successUrl:c,cancelUrl:m})}).then(function(k){if(!k.ok)throw new Error(v("Could not create stripe checkout session"));return k.json()})}).then(function(y){return window.Stripe(y.publicKey).redirectToCheckout({sessionId:y.sessionId})}).then(function(y){if(y.error)throw new Error(v(y.error.message))}).catch(function(y){console.error(y),r.addEventListener("click",f),r.classList.remove("loading"),o&&(o.innerText=y.message),r.classList.add("error")})}r.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(r){let o=r.querySelector("[data-members-error]"),s=r.dataset.membersReturn,l;s&&(l=new URL(s,window.location.href).href);function c(m){r.removeEventListener("click",c),m.preventDefault(),o&&(o.innerText=""),r.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(f){return f.ok?f.text():null}).then(function(f){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:f,returnUrl:l})}).then(function(p){if(!p.ok)throw new Error(v("Could not create Stripe billing portal session"));return p.json()})}).then(function(f){return window.location.assign(f.url)}).catch(function(f){console.error(f),r.addEventListener("click",c),r.classList.remove("loading"),o&&(o.innerText=f.message),r.classList.add("error")})}r.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(r){function o(s){r.removeEventListener("click",o),s.preventDefault(),r.classList.remove("error"),r.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(l){l.ok?window.location.replace(e):(r.addEventListener("click",o),r.classList.remove("loading"),r.classList.add("error"))})}r.addEventListener("click",o)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(r){let o=r.parentElement.querySelector("[data-members-error]");function s(l){r.removeEventListener("click",s),l.preventDefault(),r.classList.remove("error"),r.classList.add("loading");let c=r.dataset.membersCancelSubscription;return o&&(o.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/${c}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,smart_cancel:!0})})}).then(function(m){m.ok?window.location.reload():(r.addEventListener("click",s),r.classList.remove("loading"),r.classList.add("error"),o&&(o.innerText=v("There was an error cancelling your subscription, please try again.")))})}r.addEventListener("click",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(r){let o=r.parentElement.querySelector("[data-members-error]");function s(l){r.removeEventListener("click",s),l.preventDefault(),r.classList.remove("error"),r.classList.add("loading");let c=r.dataset.membersContinueSubscription;return o&&(o.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/${c}/`,{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():(r.addEventListener("click",s),r.classList.remove("loading"),r.classList.add("error"),o&&(o.innerText=v("There was an error continuing your subscription, please try again.")))})}r.addEventListener("click",s)}))}const Y8={showPopup:!0,site:_i,member:Jl.free,page:"accountEmail",...i8(),pageData:Kx};function B8({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Yd,{children:t}):u.jsx(u.Fragment,{children:t})}class V8 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(),L8({siteUrl:o,site:s.site,member:s.member,doAction:s.doAction,captureException:Vs})}}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(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Sl.changeLanguage(m);const f={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:r,pageData:c,popupNotification:o,dir:Sl.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const p=document.querySelectorAll("[data-lexical-signup-form]");p.length>0&&p.forEach(y=>{y.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:m,...f}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...o,...l,...m,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...r,...s,...f,...c}}fetchDevData(){return $e(["dev"])&&!this.state.customSiteUrl?Y8:$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||Kx.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 m of n.entries()){const f=m[0],p=decodeURIComponent(m[1]);if(f==="button")a.site.portal_button=JSON.parse(p);else if(f==="name")a.site.portal_name=JSON.parse(p);else if(f==="isFree"&&JSON.parse(p))i.push("free");else if(f==="isMonthly"&&JSON.parse(p))i.push("monthly");else if(f==="isYearly"&&JSON.parse(p))i.push("yearly");else if(f==="portalPrices")r=p?p.split(","):[];else if(f==="portalProducts")o=p?p.split(","):[];else if(f==="page"&&p)a.page=p;else if(f==="accentColor"&&(p===""||p))a.site.accent_color=p;else if(f==="buttonIcon"&&p)a.site.portal_button_icon=p;else if(f==="signupButtonText")a.site.portal_button_signup_text=p||"";else if(f==="signupTermsHtml")a.site.portal_signup_terms_html=p||"";else if(f==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(p);else if(f==="buttonStyle"&&p)a.site.portal_button_style=p;else if(f==="monthlyPrice"&&!isNaN(Number(p)))a.site.plans.monthly=Number(p),s=Number(p);else if(f==="yearlyPrice"&&!isNaN(Number(p)))a.site.plans.yearly=Number(p),l=Number(p);else if(f==="currency"&&p){const y=p.toUpperCase();a.site.plans.currency=y,a.site.plans.currency_symbol=De(y),c=y}else f==="disableBackground"?a.site.disableBackground=JSON.parse(p):f==="membersSignupAccess"&&p?a.site.members_signup_access=p:f==="portalDefaultPlan"&&p&&(a.site.portal_default_plan=p)}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}=Zw({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(zU({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+?)\/?$/,m=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,p,y]=i.match(f),k=parseInt(y);if(k===1||k===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:p,score:k}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${p}/${k}/`}}}if(i&&m.test(i)){const[,p]=i.match(m),{page:y,pageQuery:k,pageData:j}=this.getPageFromLinkPath(p,t)||{},b=["accountPlan","accountProfile"].includes(y)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(k)||s.test(k)||l.test(k)||c.test(k)),...y?{page:y}:{},...k?{pageQuery:k}:{},...j?{pageData:j}:{},...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||Hl({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.62.0|ghost@${i}`;n&&n.dsn&&mT({dsn:n.dsn,environment:n.env||"development",release:o,beforeSend:s=>vU({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if($e(["test"]))return null;const a=RU({site:t});let i=ip({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),JU({member:n})){const l=n.email,c=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:l,uid:c});else{const m=window._fprom||[];window._fprom=m,m.push(["event","signup"]),m.push(["email",l]),m.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 O8({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,v("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(Xm(),!rn({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||VU({offer:o})||!HU({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:m}=Aa({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:m})}else{const{tierId:c,cadence:m}=Aa({site:t,priceId:l.id});this.dispatchAction("signup",{plan:l.id,offerId:n,tierId:c,cadence:m})}}}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}Ww({site:t,pageQuery:n})&&(r=Ww({site:t,pageQuery:n}));const o=TU({site:t,priceId:r});if(n&&n!=="free"){Xm();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 P6(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=Vt({site:t})||!Sn({site:t})?"signin":"signup";n=a?"accountHome":i}return Yp({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return $e(["dev","preview"],{customSiteUrl:a})?q5({page:t})||J5({page:t})?$e(["dev"],{customSiteUrl:a})?n||Jl.free:$e(["preview"])?Jl.preview:Jl.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:r,page:o,lastPage:s,showPopup:l,pageQuery:c,pageData:m,popupNotification:f,customSiteUrl:p,dir:y,scrollbarWidth:k,otcRef:j,inboxLinks:b}=this.state,w=this.getContextPage({site:t,page:o,member:n}),E=this.getContextMember({page:w,member:n,customSiteUrl:p});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:r,brandColor:this.getAccentColor(),page:w,pageQuery:c,pageData:m,member:E,lastPage:s,showPopup:l,popupNotification:f,customSiteUrl:p,dir:y,scrollbarWidth:k,otcRef:j,inboxLinks:b,doAction:(P,$)=>this.dispatchAction(P,$)}}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(r8)}render(){return this.state.initStatus==="success"?u.jsx(B8,{site:this.state.site,children:u.jsxs(H.Provider,{value:this.getContextFromState(),children:[u.jsx(Vp,{}),u.jsx(sp,{}),u.jsx(pp,{})]})}):null}}const Zx="ghost-portal-root";function H8(){const e=document.createElement("div");e.id=Zx,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function W8(){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 G8(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function K8(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=W8(),r=e||window.location.origin;H8(),G8(),wC.render(u.jsx(re.StrictMode,{children:u.jsx(V8,{siteUrl:r,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Zx))}K8()});
|
|
7536
|
+
`;function k5({site:e}){return Zm+g5+uL+LL+XL+TL()+lL+iL+sL+Ow+L6+z6+H6()+lp+Y6+y5+b5+G6+e5+t5+n5+i5+s5+c5+h5}const nh=class nh 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:Ul({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:v("jamie@example.com"),label:v("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=v(a?"Sending login link...":"Continue");const r=!!a;return t==="signin:failed"&&(i=v("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:v("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:v("Sign up")})})]})}renderForm(){const{site:t}=this.context,n=$l({site:t})&&Sn({site:t});return ea({site:t})?u.jsxs("section",{children:[u.jsx("div",{className:"gh-portal-section",children:u.jsx(Rl,{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:v("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(bx,{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:v("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()]})})]})}};nh.contextType=H;let _p=nh;const v5=({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:v("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:v("Contact support")})})})})]})},w5=()=>{const{member:e,brandColor:t}=S.useContext(H),n=e.avatar_image;return u.jsxs("header",{className:"gh-portal-account-header",children:[u.jsx(Jm,{gravatar:n,style:{userIcon:{color:t,width:"56px",height:"56px",padding:"2px"}}}),u.jsx("h2",{className:"gh-portal-main-title",children:v("Your account")})]})},x5=()=>{const{site:e,action:t,brandColor:n,doAction:a}=S.useContext(H);if(!$l({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:v("View plans"),onClick:()=>r(),brandColor:n,style:{width:"100%"}})},E5=()=>{const{member:e,site:t}=S.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&&Qm({member:e})){const o=Qm({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:v("Your subscription will expire on {expiryDate}",{expiryDate:s})})})}if(a!=null&&a.cancel_at_period_end||i)return null;if(np({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:v("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:v("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:v("You currently have a free membership, upgrade to a paid subscription for full access.")}),u.jsx(x5,{})]})},S5=()=>{const{member:e,doAction:t,action:n,brandColor:a}=S.useContext(H),i=Ft({member:e});if(!i||!i.cancel_at_period_end)return null;const r=i.cancel_at_period_end?v("Continue subscription"):v("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 m=i.current_period_end;return u.jsx("p",{className:"gh-portal-text-center gh-portal-free-ctatext",children:v("Your subscription will expire on {expiryDate}",{expiryDate:En(m)})})};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%"}})]})},C5=e=>S.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.createElement("defs",null,S.createElement("style",null,".a{fill:none;stroke:currentColor;stroke-linecap:round;stroke-linejoin:round;stroke-width:1.5px;}")),S.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"}),S.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"})),$5=()=>{const{member:e,site:t,doAction:n}=S.useContext(H),a=()=>{const p=Ft({member:e});n("manageBilling",{subscriptionId:p.id})},i=()=>{const{is_stripe_configured:p}=t;p&&n("switchPage",{page:"accountPlan",lastPage:"accountHome"})},r=({price:p,isComplimentary:y,subscription:k})=>{const{next_payment:j}=k||{};let b="";if(p){const{amount:z=0,currency:R,interval:_}=p;b=`${Intl.NumberFormat("en",{currency:R,style:"currency"}).format(z/100)}/${v(_)}`}const w=Qm({member:e});y&&(w?b=`${v("Complimentary")} - ${v("Expires {expiryDate}",{expiryDate:w})}`:b=b?`${v("Complimentary")} (${b})`:v("Complimentary"));let E="";const P=np({sub:k});if(P&&(E="gh-portal-account-old-price"),P)return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(j5,{subscription:k})]});let $=T5({nextPayment:j});$&&(E="gh-portal-account-old-price");const F=()=>$?u.jsxs("p",{className:"gh-portal-account-discountcontainer","data-testid":"offer-label",children:[u.jsx(C5,{className:"gh-portal-account-tagicon"}),u.jsx("span",{children:$})]}):null;return u.jsxs(u.Fragment,{children:[u.jsx("p",{className:E,children:b}),u.jsx(F,{})]})},o=({isPaid:p})=>Ni({site:t})&&!p?null:u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:y=>i(),"data-test-button":"change-plan",children:v("Change")}),s=({defaultCardLast4:p})=>{if(p){const y=`**** **** **** ${p}`;return u.jsx("p",{children:y})}return null},l=({defaultCardLast4:p,isComplimentary:y})=>{const{action:k}=S.useContext(H),j=k==="manageBilling:running"?u.jsx(Ii,{className:"gh-portal-billing-button-loader"}):v("Update");return y?null:u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("Billing info & receipts")}),u.jsx(s,{defaultCardLast4:p})]}),u.jsx("button",{className:"gh-portal-btn gh-portal-btn-list",onClick:b=>a(),"data-test-button":"manage-billing",children:j})]})},c=Ft({member:e}),m=Qn({member:e}),f=rn({member:e});if(c||m){const{price:p,default_payment_card_last4:y}=c||{};let k=v("Plan");return jl({site:t})&&Uw({member:e})&&(k=Uw({member:e})),u.jsxs(u.Fragment,{children:[u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:k}),u.jsx(r,{price:p,isComplimentary:m,subscription:c})]}),u.jsx(o,{isPaid:f})]}),u.jsx(l,{isComplimentary:m,defaultCardLast4:y})]})}return null};function j5({subscription:e}){if(np({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:v("Free Trial – Ends {trialEnd}",{trialEnd:t})})})})}return null}function T5({nextPayment:e}){if(!e)return"";const t=e.discount;if(!t)return"";let n="";t.duration==="forever"?n=v("Forever"):t.duration==="once"?n=v("Next payment"):t.duration==="repeating"&&t.end&&(n=v("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 P5(){const{member:e,site:t,doAction:n}=S.useContext(H);let{newsletters:a}=e;const i=!!(a!=null&&a.length);let r=v(i?"Subscribed":"Unsubscribed");const o=s=>{var m;s.preventDefault();const l=za({site:t}),c=(m=e==null?void 0:e.newsletters)!=null&&m.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:v("Email newsletter")}),u.jsxs("p",{children:[r," ",ap({member:e})&&i&&u.jsx("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>n("switchPage",{page:"emailReceivingFAQ",lastPage:"accountHome"}),children:v("Not receiving emails?")})]})]}),u.jsx("div",{children:u.jsx(Dl,{dataTestId:"default-newsletter-toggle",id:"default-newsletter-toggle",onToggle:s=>{o(s)},checked:i})})]})}const Ux=e=>S.createElement("svg",{fill:"none",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 20 20",...e},S.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"}),S.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 z5(){return u.jsxs("p",{className:"gh-portal-email-notice",children:[u.jsx(Ux,{className:"gh-portal-email-notice-icon"}),u.jsx("span",{className:"gh-mobile-only",children:v("You're not receiving emails")}),u.jsx("span",{className:"gh-desktop-only",children:v("You're currently not receiving emails")})]})}function A5(){const{doAction:e,member:t,site:n}=S.useContext(H),a=Bw({member:t}),i=oo({site:n}),r=Tl({site:n}),o=a?"emailSuppressed":"accountEmail",s=!i&&!r,l=()=>a||s?u.jsx(z5,{}):u.jsx("p",{children:v("Update your preferences")});return u.jsxs("section",{children:[u.jsxs("div",{className:"gh-portal-list-detail",children:[u.jsx("h3",{children:v("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:v("Manage")})]})}const N5=()=>{var o;const{member:e,site:t}=S.useContext(H),n=!!((o=t.labs)!=null&&o.transistor),a=e==null?void 0:e.uuid,[i,r]=S.useState(!1);return S.useEffect(()=>{if(!n||!a){r(!1);return}r(!1);const s=new AbortController;return(async()=>{try{const c=await fetch(`https://partner.transistor.fm/ghost/member/${a}`,{signal:s.signal});if(c.ok){const m=await c.json();s.signal.aborted||r((m==null?void 0:m.member)===!0)}}catch(c){if(s.signal.aborted)return;console.warn("Error in Transistor request",c)}})(),()=>s.abort()},[n,a]),{transistor:{enabled:n,hasPodcasts:i,memberUuid:a}}},I5=(e,t)=>lo({site:e})&&oo({site:e})||Tl({site:e})||Bw({member:t}),M5=e=>!lo({site:e})&&oo({site:e})&&!Tl({site:e}),F5=()=>{const{member:e,doAction:t,site:n}=S.useContext(H),{name:a,email:i}=e,{transistor:r}=N5(),o=()=>{t("switchPage",{page:"accountProfile",lastPage:"accountHome"})},s=I5(n,e),l=M5(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||v("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:v("Edit")})]}),u.jsx($5,{}),s&&u.jsx(A5,{}),l&&u.jsx(P5,{}),u.jsx(f5,{hasPodcasts:r.hasPodcasts,memberUuid:r.memberUuid})]})})},D5=()=>u.jsxs("div",{className:"gh-portal-content gh-portal-account-main",children:[u.jsx(Oe,{}),u.jsx(w5,{}),u.jsxs("section",{className:"gh-portal-account-data",children:[u.jsx(E5,{}),u.jsx(S5,{}),u.jsx(F5,{})]})]}),ah=class ah 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(D5,{}),u.jsx(v5,{onClose:()=>this.context.doAction("closePopup"),handleSignout:i=>this.handleSignout(i),supportAddress:a})]})}};ah.contextType=H;let Rp=ah;const ih=class ih 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:Ul({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=v("Save");this.context.action==="updateProfile:failed"&&(n=v("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:v("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:v("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(Jm,{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:v("Jamie Larson"),label:v("Name"),name:"name",required:!1,errorMessage:a.name||""},{type:"email",value:t.email,placeholder:v("jamie@example.com"),label:v("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(Rl,{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}};ih.contextType=H;let Up=ih;function O5(){const{brandColor:e,lastPage:t,doAction:n}=S.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:v("Email preferences")})]})}function _5({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(Dl,{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 R5({updateCommentNotifications:e,isCommentsEnabled:t,enableCommentNotifications:n}){const{doAction:a}=S.useContext(H),i=!!n;if(!t)return null;const r=async(o,s)=>{await e(s),a("showPopupNotification",{action:"updated:success",message:v("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:v("Comments")}),u.jsx("p",{children:v("Get notified when someone replies to your comment")})]}),u.jsx("div",{style:{display:"flex",alignItems:"center"},children:u.jsx(Dl,{id:"comments",onToggle:r,checked:i,dataTestId:"switch-input"})})]})}function U5({subscribedNewsletters:e,setSubscribedNewsletters:t,hasNewslettersEnabled:n}){const{site:a}=S.useContext(H),i=za({site:a});return n?i.map(r=>u.jsx(_5,{newsletter:r,subscribedNewsletters:e,setSubscribedNewsletters:t},r==null?void 0:r.id)):null}function L5({site:e,isPaid:t}){return t?u.jsx("p",{style:{textAlign:"center",marginTop:"12px",marginBottom:"0",color:"var(--grey6)"},children:v("Unsubscribing from emails will not cancel your paid subscription to {title}",{title:e==null?void 0:e.title})}):null}function Lx({hasNewslettersEnabled:e,notification:t,subscribedNewsletters:n,updateSubscribedNewsletters:a,updateCommentNotifications:i,unsubscribeAll:r,isPaidMember:o,isCommentsEnabled:s,enableCommentNotifications:l}){const{brandColor:c,doAction:m,member:f,site:p}=S.useContext(H),y=!(n!=null&&n.length)&&(s&&!l||!s),j=t||(()=>null);return u.jsxs("div",{className:"gh-portal-content with-footer",children:[u.jsx(Oe,{}),u.jsx(O5,{}),u.jsx(j,{}),u.jsx("div",{className:"gh-portal-section flex",children:u.jsxs("div",{className:"gh-portal-list",children:[u.jsx(U5,{hasNewslettersEnabled:e,subscribedNewsletters:n,setSubscribedNewsletters:b=>{let w=b.map(E=>({id:E.id}));a(w)}}),u.jsx(R5,{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:y,brandColor:c,isPrimary:!1,label:v("Unsubscribe from all emails"),isDestructive:!0,style:{width:"100%",zIndex:900},dataTestId:"unsubscribe-from-all-emails"})}),u.jsxs("footer",{className:"gh-portal-action-footer"+(ap({member:f})?" gh-feature-suppressions":""),children:[u.jsx("div",{style:{width:"100%"},children:u.jsx(L5,{isPaid:o,site:p,subscribedNewsletters:n})}),ap({member:f})&&!y&&u.jsxs("div",{className:"gh-portal-footer-secondary",children:[u.jsx("span",{className:"gh-portal-footer-secondary-light",children:v("Not receiving emails?")}),u.jsxs("button",{className:"gh-portal-btn-text gh-email-faq-page-button",onClick:()=>m("switchPage",{page:"emailReceivingFAQ",pageData:{direct:!1}}),children:[v("Get help")," ",u.jsx("span",{className:"right-arrow",children:"→"})]})]})]})]})}function Y5(){const{member:e,doAction:t,site:n,pageData:a}=S.useContext(H);let i,r;a&&(i=a.newsletterUuid,r=a.action);const[o,s]=S.useState(!0),l=za({site:n}),c=oo({site:n});S.useEffect(()=>{e||t("switchPage",{page:"signin"})},[e,t]),S.useEffect(()=>{if(i&&r==="unsubscribe"){const b=e==null?void 0:e.newsletters.filter(w=>w.uuid!==i);y(b),s(!1),t("updateNewsletterPreference",{newsletters:b})}},[]);const m=()=>{if(a.comments&&k){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:v("{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:v("{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)||[]],[p,y]=S.useState(f),{comments_enabled:k}=n,{enable_comment_notifications:j}=e||{};return S.useEffect(()=>{y((e==null?void 0:e.newsletters)||[])},[e==null?void 0:e.newsletters]),u.jsx(Lx,{hasNewslettersEnabled:c,notification:i?m:null,subscribedNewsletters:p,updateSubscribedNewsletters:b=>{y(b),t("updateNewsletterPreference",{newsletters:b}),t("showPopupNotification",{action:"updated:success",message:v("Email preferences updated.")})},updateCommentNotifications:async b=>{t("updateNewsletterPreference",{enableCommentNotifications:b})},unsubscribeAll:()=>{y([]),t("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")});const b={newsletters:[]};k&&(b.enableCommentNotifications=!1),t("updateNewsletterPreference",b)},isPaidMember:rn({member:e}),isCommentsEnabled:k!=="off",enableCommentNotifications:j})}function B5(){const{site:e}=S.useContext(H),t=e.icon;return t?u.jsx("img",{className:"gh-portal-unsubscribe-logo",src:t,alt:e.title}):null}function V5(){const{site:e}=S.useContext(H),t=e.title||"";return u.jsxs("header",{className:"gh-portal-header",children:[u.jsx(B5,{}),u.jsx("h2",{className:"gh-portal-publication-title",children:t})]})}async function Yx({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 H5(){const{site:e,api:t,pageData:n,member:a,doAction:i}=S.useContext(H),[r,o]=S.useState(),[s,l]=S.useState(!0),c=za({site:e}),m=c.filter(_=>_.subscribe_on_signup),[f,p]=S.useState(!1),[y,k]=S.useState(m),[j,b]=S.useState(!1),{comments_enabled:w}=e,{enable_comment_notifications:E=!1}=r||{},P=oo({site:e}),$=async _=>{a?i("updateNewsletterPreference",{newsletters:_}):await Yx({api:t,memberUuid:n.uuid,key:n.key,newsletters:_}),k(_);const D={action:"updated:success",message:v("Email preferences updated.")};i("showPopupNotification",D)},F=async _=>{let D;a?(await i("updateNewsletterPreference",{enableCommentNotifications:_}),D={...a,enable_comment_notifications:_}):D=await Yx({api:t,memberUuid:n.uuid,key:n.key,enableCommentNotifications:_}),o(D),i("showPopupNotification",{action:"updated:success",message:v("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}),k([]),o(_),i("showPopupNotification",{action:"updated:success",message:v("Unsubscribed from all emails.")})};if(S.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)||[];k(D),(c==null?void 0:c.length)===1&&!w&&!n.newsletterUuid?await $([]):n.newsletterUuid?await $(D==null?void 0:D.filter(X=>X.uuid!==n.newsletterUuid)):n.comments&&w&&await F(!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(cp,{})}),u.jsx("h1",{className:"gh-portal-main-title",children:v("That didn't go to plan")}),u.jsx("div",{children:u.jsx("p",{className:"gh-portal-text-center",children:v("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:v("Close"),isRunning:!1,tabIndex:3,classes:"sticky bottom"})]});if((c==null?void 0:c.length)===1&&!w&&!j)return u.jsxs("div",{className:"gh-portal-content gh-portal-unsubscribe with-footer",children:[u.jsx(Oe,{}),u.jsx(V5,{}),u.jsx("h1",{className:"gh-portal-main-title",children:v("Successfully unsubscribed")}),u.jsxs("div",{children:[u.jsx("p",{className:"gh-portal-text-center",children:u.jsx(ut,{string:v("{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:v("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:v("{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:v("{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(Lx,{hasNewslettersEnabled:P,notification:R,subscribedNewsletters:y,updateSubscribedNewsletters:async _=>{await $(_),p(!0)},updateCommentNotifications:F,unsubscribeAll:async()=>{await z(),p(!0)},isPaidMember:(r==null?void 0:r.status)!=="free",isCommentsEnabled:w!=="off",enableCommentNotifications:E})}function W5(){const{brandColor:e,lastPage:t,doAction:n,action:a,site:i}=S.useContext(H);S.useEffect(()=>{["removeEmailFromSuppressionList:success"].includes(a)&&n("refreshMemberData"),["removeEmailFromSuppressionList:failed","refreshMemberData:failed"].includes(a)&&n("back"),["refreshMemberData:success"].includes(a)&&(lo({site:i})||Tl({site:i})?(n("switchPage",{page:"accountEmail",lastPage:"accountHome"}),n("showPopupNotification",{message:v("You have been successfully resubscribed")})):n("back"))},[a,n,i,v]);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(Ux,{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:v("Emails disabled")}),u.jsx("p",{children:v("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:v("Re-enable emails"),isRunning:r})]})}function G5(){const{brandColor:e,doAction:t,site:n,pageData:a}=S.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:v("Why has my email been disabled?")}),u.jsx("p",{children:v("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:v("Spam complaints")}),u.jsx("p",{children:v("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:v("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:v("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:v("Permanent failure (bounce)")}),u.jsx("p",{children:v("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:v("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:v("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:v("Need more help? Contact support")})})]})]})}function K5(){const{brandColor:e,doAction:t,site:n,lastPage:a,member:i,pageData:r}=S.useContext(H),o=uo({site:n}),s=`mailto:${o}`,l=LU({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:v("Help! I'm not receiving emails")}),u.jsx("p",{children:v("If you're not receiving the email newsletter you've subscribed to, here are a few things to check.")}),u.jsx("h4",{children:v("Verify your email address is correct")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Check spam & promotions folders")}),u.jsx("p",{children:v(`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:v("Create a new contact")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Send an email and say hi!")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Check with your mail provider")}),u.jsx("p",{children:u.jsx(ut,{string:v("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:v("Get in touch for help")}),u.jsx("p",{children:u.jsx(ut,{string:v("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 Lp={signin:_p,signup:Ip,accountHome:Rp,accountPlan:wp,accountProfile:Up,accountEmail:Y5,signupNewsletter:Ep,unsubscribe:H5,magiclink:Mp,loading:ko,offer:Dp,feedback:Q6,emailSuppressed:W5,emailSuppressionFAQ:G5,emailReceivingFAQ:K5,support:()=>{const[e,t]=S.useState(!0),[n,a]=S.useState(null),[i,r]=S.useState(null),{member:o,site:s}=S.useContext(H);return S.useEffect(()=>{async function l(){const c=s.url,m=window.location.origin+window.location.pathname,f=o?`${m}?action=support&success=true`:`${m}#/portal/support/success`,p=m,y=Hl({siteUrl:c});try{const k=await y.member.checkoutDonation({successUrl:f,cancelUrl:p,personalNote:v("Add a personal note")});k.url&&window.location.replace(k.url)}catch(k){k.type&&k.type==="DisabledFeatureError"?r(v("This site is not accepting payments at the moment.")):a(v("Something went wrong, please try again later.")),t(!1)}}s&&s.donations_enabled===!1?(r(v("This site is not accepting donations at the moment.")),t(!1)):l()},[]),e?u.jsx("div",{children:u.jsx(ko,{})}):n?u.jsx(Op,{error:n}):i?u.jsx(Op,{error:i}):null},supportSuccess:r5,supportError:Op,recommendations:p5},Yp=function({page:e}){return Object.keys(Lp).includes(e)?e:"signup"},q5=function({page:e}){return e.includes("account")},J5=function({page:e}){return e.includes("offer")},Z5=e=>S.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},S.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"})),rh=class rh 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(Z5,{}),"Powered by Ghost"]})}};rh.contextType=H;let Wl=rh;const Bx=()=>({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 X5({message:e}){return Ai()?u.jsx("div",{className:"gh-portal-cookiebanner",children:e}):null}const oh=class oh 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;Yp({page:t});const n=Lp[t];return u.jsx(n,{})}renderPopupNotification(){const{popupNotification:t}=this.context;return!t||!t.type?null:u.jsx(Fp,{})}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=Al({site:a,pageQuery:n}).length;Yp({page:t});const l={...Bx().page[t]};let c="",m="regular",f="",p=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":p="account-home";break;case"accountProfile":p="account-profile";break;case"accountPlan":p="account-plan";break;default:f="Cookies must be enabled in your browser.",p=t;break}o>1&&!Vt({site:a})&&Sn({site:a,pageQuery:n})&&t==="signup"&&(p+=" full-size",m="full");const y=so({site:a});(y&&o>2||!y&&o>1)&&t==="accountPlan"&&(p+=" full-size",m="full"),(t==="emailSuppressionFAQ"||t==="emailReceivingFAQ")&&(p+=" large-size");let k="gh-portal-popup-container";$e(["preview"])&&(p+=" preview"),$e(["preview"],{customSiteUrl:i})&&!a.disableBackground&&(k+=" preview"),$e(["dev"])&&(k+=" dev");const j=`${k} ${c} ${p}`;return this.sendPortalPreviewReadyEvent(),u.jsxs(u.Fragment,{children:[u.jsxs("div",{className:"gh-portal-popup-wrapper "+p,onClick:b=>this.handlePopupClose(b),children:[this.renderPopupNotification(),u.jsxs("div",{className:j,style:l,ref:b=>this.node=b,tabIndex:-1,children:[u.jsx(X5,{message:f}),this.renderActivePage(),m==="full"?u.jsx("div",{className:"gh-portal-powered inside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Wl,{})}):""]})]}),u.jsx("div",{className:"gh-portal-powered outside "+($e(["preview"])?"hidden ":"")+p,children:u.jsx(Wl,{})})]})}};oh.contextType=H;let Bp=oh;const sh=class sh extends re.Component{constructor(t){super(t),this.state={height:null}}renderCurrentPage(t){const n=Lp[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=k5({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=Bx(),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(Km,{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(Bp,{isMobile:r})]})})}render(){const{showPopup:t}=this.context;return t?this.renderFrameContainer():null}};sh.contextType=H;let Vp=sh;Gl({products:Hp({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 Q5(){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 Gl({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=Hp({numOfProducts:1}),portalProducts:s=o.map(X=>X.id),accentColor:l="#45C32E",portalPlans:c=["free","monthly","yearly"],membersSignupAccess:m="all",freePriceName:f="Free",freePriceDescription:p="Free preview",isStripeConfigured:y=!0,portalButton:k=!0,portalName:j=!0,portalButtonIcon:b="icon-1",portalButtonSignupText:w="Subscribe now",portalButtonStyle:E="icon-and-text",membersSupportAddress:P="support@example.com",editorDefaultEmailRecipients:$="visibility",newsletters:F=[],posts:z=e8(),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:m,free_price_name:f,free_price_description:p,is_stripe_configured:y,portal_button:k,portal_name:j,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:F,recommendations:_,recommendations_enabled:!!D,editor_default_email_recipients:$,posts:z}}function Vx({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:m=null,status:f="active",tierId:p="",tierName:y="Basic",redemptionType:k="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:m,status:f,tier:{id:`${p}`,name:y},redemption_type:k}}function Wt({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:Q5(),email:t,name:e,firstname:n,paid:i,subscribed:o,avatar_image:r,subscriptions:a,email_suppression:s,newsletters:l}}function e8({numOfPosts:e=3}={}){const t=[];for(let n=0;n<e;n++)t.push(t8({title:`Post ${n+1}`,slug:`post-${n+1}`}));return t.slice(0,e)}function t8({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 Hp({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=Hx({});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:Wx({numOfBenefits:o}),trial_days:s}}function Hx({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:Wx({numOfBenefits:a})}}function Wx({numOfBenefits:e}){const t=at();return[Kl({name:`Limited early adopter pricing #${t.substring(0,6)}`}),Kl({name:`Latest gear reviews #${t.substring(6,12)}`}),Kl({name:`Weekly email newsletter #${t.substring(12,18)}`}),Kl({name:`Listen to my podcast #${t.substring(18)}`})].slice(0,e)}function Kl({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=a8,priceId:l=`price_${at()}`,startDate:c="2021-10-05T03:18:30.000Z",currentPeriodEnd:m="2022-10-05T03:18:30.000Z",cancelAtPeriodEnd:f=!1,trialEndAt:p=null,nextPayment:y=null,tier:k=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:m,trial_end_at:p,next_payment:y,tier:k,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 Gx(){const e=Hp({numOfProducts:1}),t=e.map(a=>a.id);return Gl({products:e,portalPlans:["free","monthly","yearly"],portalProducts:t})}Gx();const n8=Gl({products:[Oi({numOfBenefits:2,type:"free"})]}),a8=Vx({tierId:(Xx=n8.products[0])==null?void 0:Xx.id});Wt(),Wt({paid:!0,subscriptions:[Na()]}),Wt({paid:!0,subscriptions:[]}),Wt({paid:!0,subscriptions:[Na({amount:0})]}),Wt({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]}),Gx();const ql=[Hx({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=Gl({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:ql,portalProducts:ql.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}]}),Kx=Vx({tierId:(Qx=_i.products[1])==null?void 0:Qx.id}),Jl={free:Wt({name:"Jamie Larson",email:"jamie@example.com",firstname:"Jamie",subscriptions:[],paid:!1,avatarImage:"",subscribed:!0}),paid:Wt({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:Wt({paid:!0,subscriptions:[]}),complimentaryWithSubscription:Wt({paid:!0,subscriptions:[Na({amount:0})]}),preview:Wt({paid:!0,subscriptions:[Na({amount:1500,startDate:"2019-05-01T11:42:40.000Z",currentPeriodEnd:"2021-06-05T11:42:40.000Z"})]})};function i8(){var n;if(!ql||!ql[1])return null;let e=(n=_i==null?void 0:_i.products)==null?void 0:n[1].monthlyPrice,t=Wt({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 r8(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 o8({data:e,state:t}){return{page:e.page,popupNotification:null,lastPage:e.lastPage||null,pageData:e.pageData||t.pageData}}function s8({state:e}){return{showPopup:!e.showPopup}}function l8({data:e}){return{showPopup:!0,page:e.page,...e.pageQuery?{pageQuery:e.pageQuery}:{},...e.pageData?{pageData:e.pageData}:{}}}function u8({state:e}){return e.lastPage?{page:e.lastPage}:qx({state:e})}function qx({state:e}){return Xm(),{showPopup:!1,lastPage:null,pageQuery:"",popupNotification:null,page:e.page==="magiclink"?"":e.page}}function c8({data:e}){return{showNotification:!0,...e}}function d8(){return{showNotification:!1}}async function m8({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:v("Failed to log out, please try again")})}}}async function p8({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,v("Failed to log in, please try again"))})}}}function h8({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 f8({data:e,api:t}){var a;const n=v("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 g8({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 m;if(a.toLowerCase()==="free"){const f=await n.member.getIntegrityToken();({inboxLinks:m}=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:m,pageData:{...t.pageData||{},email:(o||"").trim()}}}catch(a){const i=xn(a,v("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 y8({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:v("Failed to process checkout, please try again")})}}}async function b8({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(),m="updateSubscription:success";return{action:m,popupNotification:Ee({type:m,autoHide:!0,closeable:!0,state:t,status:"success",message:v("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:v("Failed to update subscription, please try again")})}}}async function k8({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:v("Failed to cancel subscription, please try again")})}}}async function v8({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:v("Failed to cancel subscription, please try again")})}}}async function w8({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 x8({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:v("Failed to update billing information, please try again")})}}}async function E8({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:v("Failed to open billing portal, please try again")})}}}async function S8(){return{popupNotification:null}}async function C8({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 $8({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:v("Failed to update newsletter settings")})}}}async function j8({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:v("You have been successfully resubscribed")})}}catch{return{action:"removeEmailFromSuppressionList:failed",popupNotification:Ee({type:"removeEmailFromSuppressionList:failed",autoHide:!0,closeable:!0,state:e,status:"error",message:v("Your email has failed to resubscribe, please try again")})}}}async function T8({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:v("Email newsletter settings updated")})}}catch{return{action:"updateNewsletter:failed",popupNotification:Ee({type:"updateNewsletter:failed",autoHide:!0,closeable:!0,state:t,status:"error",message:v("Failed to update newsletter settings")})}}}async function P8({data:e,state:t,api:n}){const{email:a}=e,i=_U({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 z8({data:e,state:t,api:n}){var r;const a=(r=e==null?void 0:e.name)==null?void 0:r.trim();if(UU({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 A8({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 N8({data:e,state:t,api:n}){const[a,i]=await Promise.all([z8({data:e,state:t,api:n}),P8({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:v("Check your inbox to verify email update")})};const r=a.success?v("Failed to send verification email"):v("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?v("Account details updated successfully"):v("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,v("Failed to send verification email")):s=v("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:v("Account details updated successfully")})}}async function I8({data:{siteUrl:e},state:t}){const n=Hl({siteUrl:e,apiUrl:"not-defined"}),{member:a}=t,i=window.location.href,r=Lw(),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 M8({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 F8({data:{recommendationId:e},api:t}){return t.recommendations.trackSubscribed({recommendationId:e}),{}}const D8={togglePopup:s8,openPopup:l8,closePopup:qx,switchPage:o8,openNotification:c8,closeNotification:d8,back:u8,signout:m8,signin:p8,startSigninOTCFromCustomForm:h8,verifyOTC:f8,signup:g8,updateSubscription:b8,cancelSubscription:k8,continueSubscription:v8,applyOffer:w8,updateNewsletter:T8,updateProfile:N8,refreshMemberData:A8,clearPopupNotification:S8,editBilling:x8,manageBilling:E8,checkoutPlan:y8,updateNewsletterPreference:$8,showPopupNotification:C8,removeEmailFromSuppressionList:j8,oneClickSubscribe:I8,trackRecommendationClicked:M8,trackRecommendationSubscribed:F8};async function O8({action:e,data:t,state:n,api:a}){const i=D8[e];return i?await i({data:t,state:n,api:a})||{}:{}}function Jx(e,t){e&&(e.innerText=t)}function _8(e,t,n){t.classList.add("error");const a=v("There was an error sending the email, please try again");Jx(n,xn(e,a))}async function R8({event:e,form:t,errorEl:n,siteUrl:a,submitHandler:i,doAction:r,captureException:o}){var $,F;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=(($=t==null?void 0:t.dataset)==null?void 0:$.membersAutoredirect)||"true",m=s==null?void 0:s.value,f=((l==null?void 0:l.value)||"").trim()||void 0,p,y=[],k=[],j=e.target.querySelectorAll("input[data-members-label]")||[];for(let z=0;z<j.length;++z)y.push(j[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)k.push({name:b[z].value});t.dataset.membersForm&&(p=t.dataset.membersForm);const w=p==="signin"&&((F=t==null?void 0:t.dataset)==null?void 0:F.membersOtc)==="true";t.classList.add("loading");const E=co(),P={email:m,emailType:p,labels:y,name:f,autoRedirect:c==="true"};w&&(P.includeOTC=!0),E&&(P.urlHistory=E),b.length>0?P.newsletters=k:(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:(m||"").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,v("Failed to send magic link email"));Jx(n,X),t.classList.add("error")}}catch(z){_8(z,t,n)}}function U8({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=jU(i,s.toLowerCase()),c=t.dataset.membersSuccess,m=t.dataset.membersCancel,f,p;c&&(f=new URL(c,window.location.href).href),m&&(p=new URL(m,window.location.href).href),n&&(n.innerText=""),t.classList.add("loading");const y=r?{checkoutType:"upgrade"}:{},k=co();return k&&(y.urlHistory=k),fetch(`${a}/members/api/session`,{credentials:"same-origin"}).then(function(j){return j.ok?j.text():null}).then(function(j){return fetch(`${a}/members/api/create-stripe-checkout-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...l,identity:j,successUrl:f,cancelUrl:p,metadata:y})}).then(function(b){if(!b.ok)throw new Error(v("Could not create stripe checkout session"));return b.json()})}).then(function(j){return j.url?window.location.assign(j.url):window.Stripe(j.publicKey).redirectToCheckout({sessionId:j.sessionId}).then(function(w){if(w.error)throw new Error(w.error.message)})}).catch(function(j){console.error(j),t.addEventListener("click",o),t.classList.remove("loading"),n&&(n.innerText=j.message),t.classList.add("error")})}function L8({siteUrl:e,site:t={},member:n,doAction:a,captureException:i}={}){e&&(e=e.replace(/\/$/,""),Array.prototype.forEach.call(document.querySelectorAll("form[data-members-form]"),function(r){let o=r.querySelector("[data-members-error]");function s(l){R8({event:l,errorEl:o,form:r,siteUrl:e,submitHandler:s,doAction:a,captureException:i})}r.addEventListener("submit",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-plan]"),function(r){let o=r.querySelector("[data-members-error]");function s(l){U8({el:r,event:l,errorEl:o,member:n,site:t,siteUrl:e,clickHandler:s})}r.addEventListener("click",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-edit-billing]"),function(r){let o=r.querySelector("[data-members-error]"),s=r.dataset.membersSuccess,l=r.dataset.membersCancel,c,m;s&&(c=new URL(s,window.location.href).href),l&&(m=new URL(l,window.location.href).href);function f(p){r.removeEventListener("click",f),p.preventDefault(),o&&(o.innerText=""),r.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(y){return y.ok?y.text():null}).then(function(y){return fetch(`${e}/members/api/create-stripe-update-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:y,successUrl:c,cancelUrl:m})}).then(function(k){if(!k.ok)throw new Error(v("Could not create stripe checkout session"));return k.json()})}).then(function(y){return window.Stripe(y.publicKey).redirectToCheckout({sessionId:y.sessionId})}).then(function(y){if(y.error)throw new Error(v(y.error.message))}).catch(function(y){console.error(y),r.addEventListener("click",f),r.classList.remove("loading"),o&&(o.innerText=y.message),r.classList.add("error")})}r.addEventListener("click",f)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-manage-billing]"),function(r){let o=r.querySelector("[data-members-error]"),s=r.dataset.membersReturn,l;s&&(l=new URL(s,window.location.href).href);function c(m){r.removeEventListener("click",c),m.preventDefault(),o&&(o.innerText=""),r.classList.add("loading"),fetch(`${e}/members/api/session`,{credentials:"same-origin"}).then(function(f){return f.ok?f.text():null}).then(function(f){return fetch(`${e}/members/api/create-stripe-billing-portal-session/`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:f,returnUrl:l})}).then(function(p){if(!p.ok)throw new Error(v("Could not create Stripe billing portal session"));return p.json()})}).then(function(f){return window.location.assign(f.url)}).catch(function(f){console.error(f),r.addEventListener("click",c),r.classList.remove("loading"),o&&(o.innerText=f.message),r.classList.add("error")})}r.addEventListener("click",c)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-signout]"),function(r){function o(s){r.removeEventListener("click",o),s.preventDefault(),r.classList.remove("error"),r.classList.add("loading"),fetch(`${e}/members/api/session`,{method:"DELETE"}).then(function(l){l.ok?window.location.replace(e):(r.addEventListener("click",o),r.classList.remove("loading"),r.classList.add("error"))})}r.addEventListener("click",o)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-cancel-subscription]"),function(r){let o=r.parentElement.querySelector("[data-members-error]");function s(l){r.removeEventListener("click",s),l.preventDefault(),r.classList.remove("error"),r.classList.add("loading");let c=r.dataset.membersCancelSubscription;return o&&(o.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/${c}/`,{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({identity:m,smart_cancel:!0})})}).then(function(m){m.ok?window.location.reload():(r.addEventListener("click",s),r.classList.remove("loading"),r.classList.add("error"),o&&(o.innerText=v("There was an error cancelling your subscription, please try again.")))})}r.addEventListener("click",s)}),Array.prototype.forEach.call(document.querySelectorAll("[data-members-continue-subscription]"),function(r){let o=r.parentElement.querySelector("[data-members-error]");function s(l){r.removeEventListener("click",s),l.preventDefault(),r.classList.remove("error"),r.classList.add("loading");let c=r.dataset.membersContinueSubscription;return o&&(o.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/${c}/`,{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():(r.addEventListener("click",s),r.classList.remove("loading"),r.classList.add("error"),o&&(o.innerText=v("There was an error continuing your subscription, please try again.")))})}r.addEventListener("click",s)}))}const Y8={showPopup:!0,site:_i,member:Jl.free,page:"accountEmail",...i8(),pageData:Kx};function B8({site:e,children:t}){const{portal_sentry:n}=e||{};return n&&n.dsn?u.jsx(Yd,{children:t}):u.jsx(u.Fragment,{children:t})}class V8 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(),L8({siteUrl:o,site:s.site,member:s.member,doAction:s.doAction,captureException:Vs})}}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(),m=this.props.siteI18nEnabled&&(this.props.locale||t.locale)||"en";Sl.changeLanguage(m);const f={site:t,member:n,offers:a,page:i,lastPage:s,pageQuery:l,showPopup:r,pageData:c,popupNotification:o,dir:Sl.dir()||"ltr",action:"init:success",initStatus:"success",locale:m};if(this.handleSignupQuery({site:t,pageQuery:l,member:n}),this.setState(f),this.hashHandler=()=>{this.updateStateForPreviewLinks()},window.addEventListener("hashchange",this.hashHandler,!1),!n){const p=document.querySelectorAll("[data-lexical-signup-form]");p.length>0&&p.forEach(y=>{y.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:m,...f}=this.fetchNotificationData();return{member:n,offers:a,page:"",site:{...t,...o,...l,...m,...i,plans:{...(i||{}).plans,...(t||{}).plans,...(l||{}).plans}},...r,...s,...f,...c}}fetchDevData(){return $e(["dev"])&&!this.state.customSiteUrl?Y8:$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||Kx.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 m of n.entries()){const f=m[0],p=decodeURIComponent(m[1]);if(f==="button")a.site.portal_button=JSON.parse(p);else if(f==="name")a.site.portal_name=JSON.parse(p);else if(f==="isFree"&&JSON.parse(p))i.push("free");else if(f==="isMonthly"&&JSON.parse(p))i.push("monthly");else if(f==="isYearly"&&JSON.parse(p))i.push("yearly");else if(f==="portalPrices")r=p?p.split(","):[];else if(f==="portalProducts")o=p?p.split(","):[];else if(f==="page"&&p)a.page=p;else if(f==="accentColor"&&(p===""||p))a.site.accent_color=p;else if(f==="buttonIcon"&&p)a.site.portal_button_icon=p;else if(f==="signupButtonText")a.site.portal_button_signup_text=p||"";else if(f==="signupTermsHtml")a.site.portal_signup_terms_html=p||"";else if(f==="signupCheckboxRequired")a.site.portal_signup_checkbox_required=JSON.parse(p);else if(f==="buttonStyle"&&p)a.site.portal_button_style=p;else if(f==="monthlyPrice"&&!isNaN(Number(p)))a.site.plans.monthly=Number(p),s=Number(p);else if(f==="yearlyPrice"&&!isNaN(Number(p)))a.site.plans.yearly=Number(p),l=Number(p);else if(f==="currency"&&p){const y=p.toUpperCase();a.site.plans.currency=y,a.site.plans.currency_symbol=De(y),c=y}else f==="disableBackground"?a.site.disableBackground=JSON.parse(p):f==="membersSignupAccess"&&p?a.site.members_signup_access=p:f==="portalDefaultPlan"&&p&&(a.site.portal_default_plan=p)}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}=Zw({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(zU({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+?)\/?$/,m=/^\/portal\/?(?:\/(\w+(?:\/\w+)*))?\/?$/,f=/^\/feedback\/(\w+?)\/(\w+?)\/?$/;if(i&&f.test(i)){const[,p,y]=i.match(f),k=parseInt(y);if(k===1||k===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:p,score:k}}:{showPopup:!0,page:"signin",pageData:{redirect:t.url+`#/feedback/${p}/${k}/`}}}if(i&&m.test(i)){const[,p]=i.match(m),{page:y,pageQuery:k,pageData:j}=this.getPageFromLinkPath(p,t)||{},b=["accountPlan","accountProfile"].includes(y)?"accountHome":null;return{showPopup:!(["monthly","yearly"].includes(k)||s.test(k)||l.test(k)||c.test(k)),...y?{page:y}:{},...k?{pageQuery:k}:{},...j?{pageData:j}:{},...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||Hl({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.62.1|ghost@${i}`;n&&n.dsn&&mT({dsn:n.dsn,environment:n.env||"development",release:o,beforeSend:s=>vU({event:s})?s:null,allowUrls:[/https?:\/\/((www)\.)?unpkg\.com\/@tryghost\/portal/]})}setupFirstPromoter({site:t,member:n}){if($e(["test"]))return null;const a=RU({site:t});let i=ip({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),JU({member:n})){const l=n.email,c=n.uuid;if(window.$FPROM)window.$FPROM.trackSignup({email:l,uid:c});else{const m=window._fprom||[];window._fprom=m,m.push(["event","signup"]),m.push(["email",l]),m.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 O8({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,v("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(Xm(),!rn({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||VU({offer:o})||!HU({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:m}=Aa({site:t,priceId:l.id});this.dispatchAction("checkoutPlan",{plan:l.id,offerId:n,tierId:c,cadence:m})}else{const{tierId:c,cadence:m}=Aa({site:t,priceId:l.id});this.dispatchAction("signup",{plan:l.id,offerId:n,tierId:c,cadence:m})}}}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}Ww({site:t,pageQuery:n})&&(r=Ww({site:t,pageQuery:n}));const o=TU({site:t,priceId:r});if(n&&n!=="free"){Xm();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 P6(t)}getContextPage({site:t,page:n,member:a}){if(!n||n==="default"){const i=Vt({site:t})||!Sn({site:t})?"signin":"signup";n=a?"accountHome":i}return Yp({page:n})}getContextMember({page:t,member:n,customSiteUrl:a}){return $e(["dev","preview"],{customSiteUrl:a})?q5({page:t})||J5({page:t})?$e(["dev"],{customSiteUrl:a})?n||Jl.free:$e(["preview"])?Jl.preview:Jl.paid:null:n}getContextFromState(){const{site:t,member:n,offers:a,action:i,actionErrorMessage:r,page:o,lastPage:s,showPopup:l,pageQuery:c,pageData:m,popupNotification:f,customSiteUrl:p,dir:y,scrollbarWidth:k,otcRef:j,inboxLinks:b}=this.state,w=this.getContextPage({site:t,page:o,member:n}),E=this.getContextMember({page:w,member:n,customSiteUrl:p});return{api:this.GhostApi,site:t,offers:a,action:i,actionErrorMessage:r,brandColor:this.getAccentColor(),page:w,pageQuery:c,pageData:m,member:E,lastPage:s,showPopup:l,popupNotification:f,customSiteUrl:p,dir:y,scrollbarWidth:k,otcRef:j,inboxLinks:b,doAction:(P,$)=>this.dispatchAction(P,$)}}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(r8)}render(){return this.state.initStatus==="success"?u.jsx(B8,{site:this.state.site,children:u.jsxs(H.Provider,{value:this.getContextFromState(),children:[u.jsx(Vp,{}),u.jsx(sp,{}),u.jsx(pp,{})]})}):null}}const Zx="ghost-portal-root";function H8(){const e=document.createElement("div");e.id=Zx,e.setAttribute("data-testid","portal-root"),document.body.appendChild(e)}function W8(){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 G8(){const e=new URL(window.location.href);e.searchParams.get("token")&&(e.searchParams.delete("token"),window.history.replaceState({},document.title,e.href))}function K8(){const{siteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i}=W8(),r=e||window.location.origin;H8(),G8(),wC.render(u.jsx(re.StrictMode,{children:u.jsx(V8,{siteUrl:r,customSiteUrl:e,apiKey:t,apiUrl:n,siteI18nEnabled:a,locale:i})}),document.getElementById(Zx))}K8()});
|
|
7537
7537
|
//# sourceMappingURL=portal.min.js.map
|