1"use strict";(self.webpackChunknyp_membership=self.webpackChunknyp_membership||[]).push([[746,4874,5738],{5738:function(e,n,t){t.r(n),t.d(n,{FeedbackForm:function(){return d}});var s=t(1085),o=t(9067),i=t.n(o),a=t(7309),r=t(824),c=t(7519),l=t(316);const u=[(0,a.__)("Not enough coverage of my favorite sports or teams","nypost"),(0,a.__)("Not enough coverage of my favorite writers","nypost"),(0,a.__)("Not enough events","nypost"),(0,a.__)("My favorite sports seasons are over","nypost"),(0,a.__)("Itâs too expensive","nypost"),(0,a.__)("Other","nypost")],d=({buttonLabel:e=(0,a.__)("Submit","nypost"),description:n="",onCancel:t=()=>null,onSubmit:o=()=>null,required:i=!1,hideCancel:d=!1})=>{const{handleSubmit:p,register:m,watch:b}=(0,r.mN)(),h=b("reason");return(0,s.jsxs)("form",{className:"subscription-feedback-form",onSubmit:p(e=>{const{reason:n="",text:t=""}=e;o({cancelReason:n,cancelReasonText:c.A.sanitize(t)})}),"data-testid":"subscription-feedback-form",children:[(0,s.jsx)("p",{children:n}),(0,s.jsx)("ul",{className:"subscription-feedback-form__reasons",children:u.map((e,n)=>(0,s.jsxs)("li",{children:[(0,s.jsx)("input",Object.assign({},m("reason",{required:i}),{type:"radio",id:`reason-${n}`,value:e})),(0,s.jsx)("label",{htmlFor:`reason-${n}`,children:e}),h!==e?null:(0,s.jsx)("textarea",Object.assign({name:"text","aria-label":(0,a.__)("Other Feedback","nypost"),placeholder:(0,a.__)("Could you tell us more?","nypost"),"data-testid":"subscription-feedback-other"},m("text",{setValueAs:e=>l.S.plainText(e)})))]},e))}),(0,s.jsxs)("div",{className:"input-container input-container--submit",children:[(0,s.jsx)("button",{type:"submit",className:"button button--solid","data-testid":"subscription-feedback-submit",disabled:i&&!h,children:e}),d?null:(0,s.jsx)("button",{"data-testid":"cancel",type:"button",className:"button button--secondary",onClick:t,children:(0,a.__)("Cancel","nypost")})]})]})};d.propTypes={buttonLabel:i().string,description:i().oneOfType([i().string,i().element,i().arrayOf(i().element)]),onCancel:i().func,onSubmit:i().func,required:i().bool,hideCancel:i().bool}},3807:function(e,n,t){t.d(n,{X:function(){return f}});var s=t(1085),o=t(4041),i=t(8690),a=t(7309),r=t(4120),c=t(2205),l=t(7093),u=t(8862),d=t(3486),p=t(2906),m=t(3127),b=t(7661),h=t(7682),y=t(1924),g=t(8188),_=t(4846);const f=()=>{const{state:e={},dispatch:n}=(0,r.rR)(),{dispatch:t}=(0,r.QW)(),f=(0,o.useRef)(document.documentElement),x=(0,o.useRef)(document.querySelector(".membership-dropdown__container")),{state:v,operations:j}=(0,_.i)(),S=(0,i.Zp)(),{operations:C}=(0,r.mu)(),{dropdownOpen:k}=(0,r.WP)(),{execute:N,ReCAPTCHA:T}=(0,r.Vq)(),w=(0,p.o)(g.zZ),{user:{sessionId:P="",trackingId:I=""}={}}=e,E=(0,r.ow)(),{scrollTo:M}=(0,c.Ay)({ref:k?x:f,speed:100,direction:"y"}),{selectedPlan:A}=v,{hasTrial:R=!1,planId:L=""}=A||{},{payflowCheckoutButtonLabel:F=""}=(0,u.px)(L,R),D=F||(0,a.__)("Start Subscription","nypost"),O=(...e)=>{return s=void 0,o=[...e],r=function*(e={nonce:"",error:""}){const{nonce:s}=e;j.setLoading(!0);try{yield N()}catch(e){return j.setLoading(!1),void j.setError(`Error validating reCAPTCHA: ${e.message||""}`)}const{planId:o,productId:i}=E,{status:r,message:c=""}=yield(0,l.Yw)({paymentNonce:s,planId:o,productId:i,skipTrial:j.shouldSkipTrial(),sessionId:P,trackingId:I});if("success"!==r)return j.setLoading(!1),void j.setError(`${d.y.errorSubscribing()} ${c}`);const p=yield(0,l.r7)({hadTrial:!0}),h=yield(0,l.X4)({active:!1,sessionId:P,trackingId:I}),y=(0,u.UF)(h),{activeSubscription:_,status:f}=y,x={activeSubscription:_,subscriptions:h,subscriptionStatus:f};t((0,m.yS)(x)),p&&(n((0,b.Uu)({hadTrial:!0,onboarded:!1})),n((0,b.ef)(!0))),S(g.Vy);const v=(0,a.__)("You have successfully started your subscription!","nypost");t((0,m.k5)(v)),j.setLoading(!1),M(-1/0),C.refetchPaymentMethods()},new((i=void 0)||(i=Promise))(function(e,n){function t(e){try{c(r.next(e))}catch(e){n(e)}}function a(e){try{c(r.throw(e))}catch(e){n(e)}}function c(n){var s;n.done?e(n.value):(s=n.value,s instanceof i?s:new i(function(e){e(s)})).then(t,a)}c((r=r.apply(s,o||[])).next())});var s,o,i,r};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(T,{}),v.loading||!A?(0,s.jsx)(h.Ip,{}):(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("section",{id:"free-trial-payment",className:"membership-section border-top-thick",children:(0,s.jsx)(y.A,{titleClasses:"member-subscriptions__heading sub-heading sub-heading--semi",title:(0,a.__)("Your Payment Method","nypost"),children:(0,s.jsx)(h.XN,{html:A.getBillingTextNewUser(),tagName:"p"})})}),(0,s.jsx)("section",{className:"membership-section border-top-thin",children:!1!==v.authorizationToken?(0,s.jsx)(h.Nk,{authorizationToken:v.authorizationToken,onSubmitSuccess:O,amount:A.amount}):(0,s.jsx)(h.Ip,{})}),(0,s.jsxs)("section",{className:"membership-section border-top-thin",children:[v.error?j.renderError(v.error):null,!1!==v.authorizationToken?(0,s.jsx)("div",{children:w?(0,s.jsx)(h.cy,{submitButtonText:D,authorizationToken:v.authorizationToken,onSubmitSuccess:O}):(0,s.jsx)(h.QS,{submitButtonText:D,authorizationToken:v.authorizationToken,onSubmitSuccess:O})}):(0,s.jsx)(h.Ip,{}),(0,s.jsx)(h.XN,{className:"billing-confirmation-text",html:R?d.p.forSubscribeTrial():d.p.forPayflowNoFreeTrial(A,D),tagName:"p",addAttr:["target"]})]})]})]})}},4846:function(e,n,t){t.d(n,{i:function(){return a}});var s=t(4120),o=t(4041),i=t(7093);const a=()=>{const{state:e}=(0,s.rR)(),{state:n}=(0,s.QW)(),{error:t,setError:a,renderError:r}=(0,s.MM)(),[c,l]=(0,o.useState)(!1),[u,d]=(0,o.useState)(!1),p=(0,s.ow)(),{availablePlans:m}=n,{dataLayer:{hadTrial:b=!1}={}}=e;return(0,o.useEffect)(()=>{var e,n,t,s;e=void 0,n=void 0,s=function*(){return l(yield(0,i.gf)())},new((t=void 0)||(t=Promise))(function(o,i){function a(e){try{c(s.next(e))}catch(e){i(e)}}function r(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(a,r)}c((s=s.apply(e,n||[])).next())})}
1,[]),{operations:{renderError:r,setError:a,setLoading:d,shouldSkipTrial:()=>!!b||!p.hasTrial},state:{authorizationToken:c,error:t,loading:u,plans:m,selectedPlan:p}}}},4874:function(e,n,t){t.r(n),t.d(n,{PauseSubscriptionForm:function(){return u}});var s=t(1085),o=t(4041),i=t(9067),a=t.n(i),r=t(7309),c=t(5738),l=t(5472);const u=({onPause:e=()=>{},onFeedback:n=()=>{},formState:t="open",setFormState:i=()=>{}})=>{const[a,u]=(0,o.useState)(1);if("closed"===t)return(0,s.jsx)("button",{type:"button",className:"button button--solid button--solid--alt",onClick:()=>i("open"),"data-testid":"pause-subscription-button",children:(0,r.__)("Pause Membership","nypost")});if("submitted"===t)return(0,s.jsxs)("div",{className:"pause-subscription-feedback",children:[(0,s.jsx)("p",{children:(0,r.__)("As we strive to continuously improve our service, your feedback is important to us.","nypost")}),(0,s.jsx)("hr",{}),(0,s.jsx)(c.FeedbackForm,{onCancel:n,onSubmit:e(a),description:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("strong",{children:(0,r.__)("Why did you pause your subscription with us?","nypost")}),"Â ",(0,r.__)("(Select all that apply)","nypost")]})})]});const d={option:(e,n)=>Object.assign(Object.assign({},e),{color:"black",backgroundColor:n.isSelected?"#F3F3F3":"inherit"})},p=[{value:1,label:(0,r.__)("1 Month","nypost")},{value:2,label:(0,r.__)("2 Months","nypost")},{value:3,label:(0,r.__)("3 Months","nypost")}];return(0,s.jsxs)("form",{className:"pause-subscription-form",onSubmit:e=>{e.preventDefault(),i("submitted")},"data-testid":"pause-subscription-form",children:[(0,s.jsx)("label",{htmlFor:"pause-duration",className:"t-color-black",children:(0,r.__)("Select the pause duration","nypost")}),(0,s.jsx)(l.Ay,{id:"pause-duration",className:"react-select m-top m-bottom",options:p,defaultValue:p[0],onChange:e=>u(e.value),styles:d,theme:e=>Object.assign(Object.assign({},e),{borderRadius:0})}),(0,s.jsxs)("div",{className:"input-container input-container--submit",children:[(0,s.jsx)("button",{type:"submit",className:"button button--solid button--solid--alt","data-testid":"confirm-pause",children:(0,r.__)("Confirm Pause","nypost")}),(0,s.jsx)("button",{type:"button",className:"button button--secondary",onClick:()=>i("closed"),"data-testid":"cancel-pause",children:(0,r.__)("Cancel","nypost")})]})]})};u.propTypes={onPause:a().func,onFeedback:a().func,formState:a().string,setFormState:a().func}},8450:function(e,n,t){t.d(n,{M:function(){return c}});var s=t(1085),o=(t(4041),t(9067)),i=t.n(o),a=t(3373),r=t.n(a);const c=({checkmarkColor:e="black",heading:n="",children:t})=>{if(!t)return null;const o=r()("list","list--checkmark",`list--checkmark-${e}`),i=r()("list__heading","headline");return(0,s.jsxs)("div",{className:o,"data-testid":"list-container",children:[n&&n.length?(0,s.jsx)("h3",{className:i,"data-testid":"list-heading",children:n}):null,(0,s.jsx)("ul",{"data-testid":"list",children:t})]})};c.propTypes={checkmarkColor:i().string,heading:i().string,children:i().node.isRequired}},8190:function(e,n,t){t.d(n,{s:function(){return l}});var s=t(1085),o=(t(4041),t(9067)),i=t.n(o),a=t(7309),r=t(4120),c=t(8450);const l=({checkmarkColor:e="green",displayHeadline:n=!0})=>{const t=(0,r.ow)();return(0,s.jsxs)(s.Fragment,{children:[n?(0,s.jsx)("h2",{className:"cta__headline",children:(null==t?void 0:t.trialDuration)?(0,a.__)("Don't miss on a chance to get 30 days FREE!","nypost"):(0,a.__)("Don't miss out. Subscribe today!","nypost")}):null,(0,s.jsxs)(c.M,{checkmarkColor:e,children:[(0,s.jsx)("li",{children:(0,a.__)("Read unlimited sports stories & analysis","nypost")}),(0,s.jsx)("li",{children:(0,a.__)("Get exclusive newsletters sent right to your inbox","nypost")}),(0,s.jsx)("li",{children:(0,a.__)("Interact with the best sports writers in town","nypost")})]})]})};l.propTypes={displayHeadline:i().bool,checkmarkColor:i().string}},746:function(e,n,t){t.r(n),t.d(n,{default:function(){return G}});var s=t(1085),o=t(4041),i=t(7309),a=t(4120),r=t(8188),c=t(7682);const l=[r.dH.ACTIVE_CANCELLED,r.dH.CANCELLED,r.dH.NONE,r.dH.PAST_DUE],u=()=>{const{state:e}=(0,a.rR)(),{state:n}=(0,a.QW)();console.log("SUBSCRIPTION STATE",n);const{dataLayer:{hadTrial:t=!1}={}}=e,{loading:o,data:{subscriptionsFetched:i=!1,subscriptionStatus:u}}=n;return o||!i?(0,s.jsx)(c.Ip,{}):(0,s.jsx)(s.Fragment,{children:t||u===r.dH.ACTIVE?r.UQ.includes(u)&&r.nT?(0,s.jsx)(Q,{}):l.includes(u)?(0,s.jsx)(_,{}):(0,s.jsx)(V,{}):(0,s.jsx)(N,{})})};var d=t(8758),p=t(315),m=t(1924),b=t(6673),h=t(2803),y=t(3387),g=t(9579);const _=()=>{const{state:e}=(0,a.QW)(),[n,t]=(0,o.useState)(!1),{operations:l}=(0,a.mu)(),{hasHomeDelivery:u,getHomeDeliveryMessage:_}=(0,a.TM)(),{data:{activeSubscription:f={},activeSubscription:{next_billing_date:{date:x=""}={}}={},subscriptionStatus:v=""}={},globalSuccessMessage:j=""}=e,S=l.getDefaultPaymentMethod();return(0,s.jsxs)("section",{className:"membership-section membership-section--canceled-user",children:[(0,s.jsxs)(m.A,{headingTag:"h2",titleClasses:"member-subscriptions__heading",title:(0,i.__)("Your Plan","nypost"),children:[j?(0,s.jsx)(c.nS,{message:j}):null,n?(0,s.jsx)(c.nS,{message:(0,i.__)("You've successfully restarted your subscription!","nypost")}):null,l.isPaymentMethodExpired(S)?(0,s.jsx)(b.s,{method:S}):null,l.isPaymentMethodExpiring(S)?(0,s.jsx)(h.u,{method:S}):null,v===r.dH.PAST_DUE?(0,s.jsx)(y.i,{}):null]}),n?null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(c.XN,{html:u()?_():(0,d.A)(f)?(0,i.__)("You do not have an active subscription. Reactivate below.","nypost"):x&&v===r.dH.ACTIVE_CANCELLED?(0,i.nv)((0,i.__)("You do not have an active subscription. Unless you reactivate your subscription below, your access to Post Sports+ is set to expire on %s.","nypost"),`<span class="t-bold">${(0,p.A)(x)}</span>`):(0,i.__)("You do not have an active subscription. Reactivate below.","nypost"),tagName:"p"}),u()?null:(0,s.jsx)(c.wn,{children:(0,s.jsx)(g.y,{onSuccessMessage:t,cardLayout:"horizontal"})})]})]})};var f=t(3807),x=t(3657),v=t(2205),j=t(8549),S=t(3065),C=t(8190);const k=()=>{const{dropdownOpen:e}=(0,a.WP)(),n=(0,a.ow)(),t=(0,o.useRef)(document.documentElement),r=(0,o.useRef)(document.querySelector(".membership-dropdown__container")),{scrollTo:l}=(0,v.Ay)({ref:e?r:t,speed:100,direction:"y"});return(0,s.jsx)("section",{className:"membership-section membership-section--try-it-free",children:(0,s.jsxs)(j.J,{children:[(0,s.jsx)(C.s,{}),(0,s.jsx)(c.OV,{onClick:()=>{document.querySelector("#free-trial-payment")&&l("#free-trial-payment")},children:(0,s.jsx)(S.E$,{dataId:"freeTrialButton",children:(()=>{const{hasTrial:e=!1}=n||{};return e?(0,i.__)("Try it free","nypost"):null==n?void 0:n.getCallToAction()})()})}),(0,s.jsx)(x.N_,{className:"membership-link",to:"/account/subscribe",children:(0,i.__)("Learn More","nypost")})]})})},N=()=>{const e=(0,a.ow)(),{hasHomeDelivery:n,getHomeDeliveryMessage:t}=(0,a.TM)();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("section",{className:"membership-section bottom-padding-none",children:(0,s.jsx)(m.A,{headingTag:"h2",titleClasses:"member-subscriptions__heading",title:(0,i.__)("Your Plan","nypost"),children:n()?t():(null==e?void 0:e.trialDuration)?(0,s.jsx)("p",{children:(0,i.__)("Try Post Sports+ FREE to enjoy inside access to premier sports journalism on your favorite teams.","nypost")}):(0,s.jsx)("p",{children:(0,i.__)("Join Post Sports+ to enjoy inside access to premier sports journalism on your favorite teams.","nypost")})})}),n()?null:(0,s.jsxs)(c.wn,{children:[(0,s.jsx)(c.xp,{children:(0,s.jsx)(k,{})}),(0,s.jsx)(c.rh,{children:(0,s.jsx)(c._A,{children:(0,s.jsx)(f.X,{})})})]})]})};var T=t(2415),w=t(7134),P=t(4483),I=t(3873),E=t(8862),M=t(7093),A=t(2347),R=t(3127),L=t(7661),F=t(9067),D=t.n(F),O=t(8660),H=t(4595);const Y=({heading:e=(0,i.__)("Are you sure you want to go?","nypost"),isOpen:n=!1,onClose:t=null,onSubscriptionCancelled:r=null,onSubscriptionResumed:l=null,subheading:u=(0,i.__)("Get 1 month 20% off if you stay.","nypost")})=>{const[d,p]=(0,o.useState)(!1),m=(0,o.useRef)();return(0,a.jz)(m,t),(0,s.jsx)(c.aF,{modalClass:"membership-cancellation-confirmation",isOpen:n,onClose:t,children:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h3",{className:"modal__title",id:"modal-title",children:e}),(0,s.jsx)("p",{className:"modal__text modal__text--offer",children:u}),(0,s.jsxs)("p",{className:"modal__text",children:[(0,i.__)("Enjoy exclusive, member-only content daily. ","nypost"),(0,s.jsx)("span",{children:(0,i.__)("Cancel anytime","nypost")})]}),(0,s.jsxs)("div",{className:"modal__button-container",children:[(0,s.jsx)("button",{className:"button button--solid button--solid--alt","data-testid":"resume-subscription",onClick:()=>{d||l&&"function"==typeof l&&l()},type:"button",children:(0,i.__)("Yes, I'll stay!","nypost")}),(0,s.jsx)("button",{className:"button button--secondary","data-testid":"cancel-subscription",onClick:()=>{p(!0),d||r&&"function"==typeof r&&r({isLoading:d,setIsLoading:p})},type:"button",children:(0,i.__)("Cancel Subscription","nypost")})]}),(0,s.jsx)("div",{style:{minHeight:"2em"},children:d?(0,s.jsx)(c.Ac,{}):null})]})})};Y.propTypes={heading:D().string,isOpen:D().bool,onClose:D().func,onSubscriptionCancelled:D().func,onSubscriptionResumed:D().func,subheading:D().string};const $={cancelReason:"",cancelReasonText:""},W=({accessEndDate:e="",onSubscriptionCancelled:n=null,onSubscriptionResumed:t=null,subscriptionStatus:l=null})=>{const{state:u}=(0,a.rR)(),{user:{sessionId:d="",trackingId:p=""}={}}=u,{state:{data:{activeSubscription:{id:b=null}={}}={}}={}}=(0,a.QW)(),{dropdownOpen:h=!1}=(0,O.W)(),[y,g]=(0,o.useState)(!1),[_,f]=(0,o.useState)($),[x,j]=(0,o.useState)(null),S=(0,o.useRef)(document.documentElement),C=(0,o.useRef)(document.querySelector(".membership-dropdown__container")),{scrollTo:k}=(0,v.Ay)({ref:h?C:S,speed:50,direction:"y"});(0,o.useEffect)(()=>{var e,n,t,s;e=void 0,n=void 0,s=function*(){if(!b||l===r.dH.CANCELLED)return;const[e,n]=yield Promise.all([(0,E.mt)({sessionId:d}),(0,M.AM)({sessionId:d,trackingId:p,subscriptionId:b})]);if(!e)return;const{discount_id:t=null}=e;t&&!n.includes(t)?j(Object.assign(Object.assign({},e),{discount_id:t,heading:e.heading||void 0,subheading:e.subheading||void 0})):console.log(`User already has discount being offered: [${t}]`)},new((t=void 0)||(t=Promise))(function(o,i){function a(e){try{c(s.next(e))}catch(e){i(e)}}function r(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(a,r)}c((s=s.apply(e,n||[])).next())})},[b,l,d,p]);const N=()=>{g(!1),k(-1/0)},T=({isLoading:e,setIsLoading:t,newFormResponse:s=null})=>{n&&"function"==typeof n&&n({formResponse:s||_,isLoading:e,setIsLoading:t,handleOnModalClose:N})};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("section",{className:"membership-section padding-none",children:(0,s.jsx)(m.A,{headingTag:"h2",titleClasses:"member-subscriptions__heading",title:(0,i.__)("Cancel Subscription","nypost"),children:e?(0,s.jsx)(c.XN,{html:(0,i.nv)((0,i.__)("<p>If you cancel you will have access to your account for the remainder of your billing period which ends on %s.</p>","nypost"),`<span data-testid="cancel-end-date" class="t-bold">${e}</span>`)}):null})}),(0,s.jsx)("section",{className:"membership-section border-bottom-thick top-padding-none",children:(0,s.jsx)("div",{className:"cancel-subscription-form",children:(0,s.jsx)(H.Y3,{buttonLabel:(0,i.__)("Cancel Subscription","nypost"),description:(0,i.__)("If you would like to cancel, you may do so by using the form below:","nypost"),required:!0,onSubmit:(e=$)=>{f(e),x?g(!0):T({newFormResponse:e,isLoading:!1,setIsLoading:()=>null})},hideCancel:!0})})}),!y||y&&!x?null:(0,s.jsx)(Y,{isOpen:!0,onClose:N,onSubscriptionResumed:()=>{N(),x&&((0,M.vC)({discountId:x.discount_id,sessionId:d,subscriptionId:b,trackingId:p}),j(null)),t&&"function"==typeof t&&t()},onSubscriptionCancelled:T,heading:x.heading,subheading:x.subheading})]})};W.propTypes={accessEndDate:D().string,onSubscriptionResumed:D().func,onSubscriptionCancelled:D().func,subscriptionStatus:D().string};const U=({billingText:e="",confirmText:n="",loading:t=!1,onConfirmation:o=()=>{},onCancel:a=()=>{}})=>{const r=t?(0,i.__)("Updating...","nypost"):(0,i.__)("Confirm","nypost");return(0,s.jsxs)("section",{className:"membership-section membership-section--confirm-plan-change border-bottom-thick",children:[(0,s.jsx)("p",{className:"confirmation-text",children:(0,s.jsx)(c.XN,{html:e})}),(0,s.jsxs)("div",{className:"button-container-flex",children:[(0,s.jsx)("button",{className:"button button--solid button--solid--alt",disabled:t,onClick:()=>{o&&"function"==typeof a&&o()},type:"button",children:r}),(0,s.jsx)("button",{className:"button button--secondary",disabled:t,onClick:()=>{a&&"function"==typeof a&&a()},type:"button",children:(0,i.__)("Cancel","nypost")})]}),(0,s.jsx)("p",{className:"billing-confirmation-text",children:n})]})};U.propTypes={confirmText:D().string,billingText:D().string,loading:D().bool,onConfirmation:D().func,onCancel:D().func};var X=t(4874);const z=({handleOnPauseSubscription:e,loading:n=!1})=>{const[t,a]=(0,o.useState)("closed");return(0,s.jsxs)("section",{"data-testid":"pause-subscription",className:"membership-section membership-section--subscribed-user border-top-thick",children:["submitted"!==t||n?(0,s.jsx)(m.A,{headingTag:"h2",titleClasses:"member-subscriptions__heading",title:n?(0,i.__)("Pausing Your Subscription","nypost"):(0,i.__)("Pause Subscription","nypost"),children:(0,s.jsx)("p",{children:(0,i.__)("You may pause your subscription if youâd like. This means that until you reactivate your subscription, you will not be billed or have access to subscriber-only benefits. Your billing cycle will resume after you reactivate your subscription.","nypost")})}):null,n?(0,s.jsx)(c.Ip,{height:"107px"}):(0,s.jsx)(X.PauseSubscriptionForm,{onFeedback:()=>a("closed"),onPause:e,formState:t,setFormState:a})]})};z.propTypes={handleOnPauseSubscription:D().func.isRequired,loading:D().bool};var q=function(e,n,t,s){return new(t||(t=Promise))(function(o,i){function a(e){try{c(s.next(e))}catch(e){i(e)}}function r(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(a,r)}c((s=s.apply(e,n||[])).next())})};const V=()=>{const{state:e,dispatch:n}=(0,a.QW)(),{state:{user:{sessionId:t="",trackingId:l="",account:{emailAddress:u=""}={}}={}}={},dispatch:d}
1=(0,a.rR)(),{successMessage:y,setSuccessMessage:g,renderSuccessMessage:_}=(0,a.a$)(),{error:f,setError:x,renderError:j}=(0,a.MM)(),{operations:S}=(0,a.mu)(),{dropdownOpen:C}=(0,a.WP)(),[k,N]=(0,o.useState)(null),[F,D]=(0,o.useState)(!1),[O,H]=(0,o.useState)(!1),[Y,$]=(0,o.useState)(""),[X,V]=(0,o.useState)(""),B=(0,o.useRef)(document.documentElement),Q=(0,o.useRef)(document.querySelector(".membership-dropdown__container"));let G="";const{availablePlans:Z,globalErrorMessage:J,plans:K,globalSuccessMessage:ee,data:{activeSubscription:ne,subscriptionStatus:te}}=e,{hasHomeDelivery:se,getHomeDeliveryMessage:oe}=(0,a.TM)(),{next_billing_date:{date:ie=""}={},paid_through_date:ae,pendingSubscription:{id:re=null,next_billing_date:{date:ce=null}={},plan:{id:le=null}={}}={},plan:{name:ue="",id:de=""}={}}=ne;(null==ae?void 0:ae.date)&&(G=(0,p.A)(ae.date)),ie&&(G=(0,p.A)(ie));const{scrollTo:pe}=(0,v.Ay)({ref:C?Q:B,speed:50,direction:"y"});(0,o.useEffect)(()=>{!k&&de&&N(de),!k&&de&&le&&N(le)},[k,de,le]);const me=({planId:e})=>{x(null);const n=(0,E.Md)(e,Z);N(n.planId);const t=n.getChangePlanBillingText(ue,ie),s=n.billingConfirmText();$(t),V(s);const{plan:{id:o=!1}={},pendingSubscription:{plan:{id:i=!1}={}}={}}=ne||{};D(n.planId!==o&&(!i||i!==n.planId))},be=k&&le&&k===le,he=S.getDefaultPaymentMethod();return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("section",{className:"membership-section bottom-padding-none",id:"plan",children:(0,s.jsxs)(m.A,{headingTag:"h2",titleClasses:"member-subscriptions__heading",title:(0,i.__)("Your Plan","nypost"),children:[S.isPaymentMethodExpired(he)?(0,s.jsx)(b.s,{method:he}):null,S.isPaymentMethodExpiring(he)?(0,s.jsx)(h.u,{method:he}):null,f||J?j(J||f||""):null,y||ee?_(ee||y||""):null,(0,s.jsx)(c.XN,{html:(()=>{if(K.length<1)return"";if(se())return oe();const{plan:{id:e=""}={}}=ne;if(!e)return"";const n=(0,E.Md)(e,K);if(te===r.dH.ACTIVE_PENDING){const{pendingSubscription:{plan_id:e}}=ne,t=(0,E.Md)(e,K);return n.getPendingPlanRenewText(t,ie)}return n.getPlanRenewText(ie)})(),tagName:"p"})]})}),(0,s.jsxs)("section",{className:"membership-section padding-none",children:[F?(0,s.jsx)(m.A,{titleClasses:"member-subscriptions__heading sub-heading sub-heading--semi",title:(0,i.__)("Confirm Plan Change","nypost")}):null,!F&&be?(0,s.jsx)("p",{children:(0,i.nv)((0,i.__)("You have selected a plan you will be changing to on %s.","nypost"),ce?(0,I.GP)(new Date(ce),"LLLL d, y"):(0,i.__)("unknown","nypost"))}):null,F||be?null:(0,s.jsx)("p",{children:(0,i.__)("If you would like to upgrade your plan, you may do so below.","nypost")})]}),(0,s.jsx)("section",{className:"membership-section",children:(0,s.jsx)("div",{className:"card-container",children:(()=>{if(Z.length<1)return null;const{pendingSubscription:{plan:{id:e=!1}={}}={}}=ne||{};return Z.map(n=>n.card({cardDisabled:n.planId===k||n.planId===e||n.planId===de,cardSelected:k===n.planId,onSelect:me,cardLayout:"horizontal"}))})()})}),F?(0,s.jsx)(U,{billingText:Y,confirmText:X,loading:O,onConfirmation:()=>q(void 0,void 0,void 0,function*(){H(!0);const{status:e=null,message:t=null}=yield(0,M.mS)({id:re||ne.id,planId:k});if("success"!==e)return x(t||(0,i.__)("Error changing subscription.","nypost")),N(null),D(!1),void pe(-1/0);const s=yield(0,M.X4)(),o=(0,E.UF)(s),{activeSubscription:a,status:r}=o,c={activeSubscription:a,subscriptions:s,subscriptionStatus:r};D(!1),H(!1),n((0,R.yS)(c)),g((0,i.__)("You've successfully updated your plan!","nypost")),pe(-1/0)}),onCancel:()=>{D(!1),N(null)}}):null,(0,E.to)(de,K)&&!(0,E.e9)(ne)&&r.dH.ACTIVE===te&&r.nT?(0,s.jsx)(z,{handleOnPauseSubscription:e=>s=>q(void 0,[s],void 0,function*({cancelReason:s="",cancelReasonText:o=""}){H(!0);const{token:a=""}=S.getDefaultPaymentMethod(),{next_billing_date:{date:c}={}}=ne,m=(0,P.W)((0,w.H)(c),{months:e});if(!m)return x((0,i.__)("Something went wrong pausing your subscription. Please contact support.","nypost")),void pe(-1/0);const{nonce:b}=yield(0,M.eB)(a,t,l,nypMembership.nonce);if(!(yield(0,M.ys)(ne,m,e,b,t,l)).ok)return H(!1),x((0,i.__)("Something went wrong pausing your subscription. Please contact support.","nypost")),void pe(-1/0);(0,M.r7)({pauseReason:s,pauseReasonText:o});const h=yield(0,M.X4)(),y=(0,E.UF)(h),{activeSubscription:g}=y,_={activeSubscription:g,subscriptions:h,subscriptionStatus:r.dH.ACTIVE_PAUSED};d((0,L.HC)({paused:!0,pausedLength:e})),n((0,R.yS)(_));const f=(0,p.A)(c);pe(-1/0);const v=(0,i.nv)((0,i.__)("Your subscription will pause for %s %s at the end of your billing period %s.","nypost"),`${e}`,1===e?"Month":"Months",`${f}`);H(!1),n((0,R.k5)(v)),(0,A.Z4)(u),yield(0,E.A9)({emailAddress:u,pauseLength:`${e} ${1===e?"Month":"Months"}`,pauseLengthEffectiveDate:f,billingCycleEndDate:f,cta:`${window.location.origin}/account/settings/subscription`})}),loading:O}):null,F?null:(0,s.jsx)("section",{className:"membership-section membership-section--subscribed-user border-top-thick",id:"cancel",children:(0,s.jsx)(W,{accessEndDate:G,onSubscriptionResumed:()=>{g((0,i.__)("Welcome back! Your subscription is resumed.","nypost"))},onSubscriptionCancelled:e=>q(void 0,[e],void 0,function*({formResponse:e,setIsLoading:t,handleOnModalClose:s}){var o,a;if(t(!0),!(yield(0,M.M2)({id:(null===(o=ne.pendingSubscription)||void 0===o?void 0:o.id)?ne.pendingSubscription.id:ne.id})))return t(!1),s(),void x((0,i.__)("Something went wrong cancelling your subscription. Please try again later.","nypost"));yield(0,M.r7)(e);const c=yield(0,M.X4)(),l=(0,E.UF)(c),{activeSubscription:u,status:d}=l,m={activeSubscription:u,subscriptions:c,subscriptionStatus:d};if(d===r.dH.ACTIVE_CANCELLED){const e=null===(a=null==u?void 0:u.next_billing_date)||void 0===a?void 0:a.date;!G&&e&&(0,T.G)((0,w.H)(e))&&(G=(0,p.A)(e));const t=(0,i.nv)((0,i.__)("Your subscription is canceled. You can still enjoy your subscriber-only benefits until %s.","nypost"),`${G}`);n((0,R.k5)(t))}else{const e=(0,i.nv)((0,i.__)("Your account has been cancelled.","nypost"),`${G}`);n((0,R.k5)(e))}n((0,R.yS)(m))}),subscriptionStatus:te})})]})};var B=function(e,n,t,s){return new(t||(t=Promise))(function(o,i){function a(e){try{c(s.next(e))}catch(e){i(e)}}function r(e){try{c(s.throw(e))}catch(e){i(e)}}function c(e){var n;e.done?o(e.value):(n=e.value,n instanceof t?n:new t(function(e){e(n)})).then(a,r)}c((s=s.apply(e,n||[])).next())})};const Q=()=>{const[e,n]=(0,o.useState)(!1),{dropdownOpen:t}=(0,a.WP)(),{operations:l}=(0,a.mu)(),{setSuccessMessage:u,successMessage:d,renderSuccessMessage:b}=(0,a.a$)(),{error:h,setError:y,renderError:g}=(0,a.MM)(),{state:_,dispatch:f}=(0,a.QW)(),{state:{dataLayer:{pausedLength:x=""}={},user:{sessionId:j="",trackingId:S="",account:{emailAddress:C=""}={}}={}}={},dispatch:k}=(0,a.rR)(),{data:{activeSubscription:N,subscriptions:T,subscriptionStatus:w}={},globalErrorMessage:P,globalSuccessMessage:I,plans:F}=_,{paid_through_date:D}=N,O=(0,o.useRef)(document.documentElement),H=(0,o.useRef)(document.querySelector(".membership-dropdown__container")),{scrollTo:Y}=(0,v.Ay)({ref:t?H:O,speed:50,direction:"y"}),$=()=>{n(!1),y((0,i.__)("Something went wrong pausing your subscription. Please contact support.","nypost")),Y(-1/0)};return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("section",{className:"membership-section border-bottom-thin",children:(0,s.jsxs)(m.A,{headingTag:"h2",titleClasses:"member-subscriptions__heading",title:(0,i.__)("Your Plan","nypost"),children:[h||P?g(P||h||""):null,d||I?b(I||d||""):null]})}),(0,s.jsxs)("section",{className:"membership-section border-bottom-thick",children:[(0,s.jsx)(c.XN,{html:(()=>{let e=null==N?void 0:N.pendingSubscription;if(e||([e=null]=(0,E.$Y)(T)),!e)return"";const{next_billing_date:{date:n},plan_id:t}=e,s=(0,E.Md)(t,F);return s?s.getPausedText(Number(x),n):""})(),tagName:"p"}),(0,s.jsx)("p",{children:e?(0,i.__)("We are resuming your subscription... please wait.","nypost"):(0,i.__)("Resume your subscription at any time.","nypost")}),e?(0,s.jsx)(c.Ip,{height:"100px"}):(0,s.jsx)("button",{type:"button",className:"button button--solid button--solid--alt","data-testid":"resume-membership-button",onClick:()=>B(void 0,void 0,void 0,function*(){n(!0);let e=null==N?void 0:N.pendingSubscription;e||([e=null]=(0,E.$Y)(T));const{token:t=""}=l.getDefaultPaymentMethod();if(!e)return void $();const{nonce:s}=yield(0,M.eB)(t);if(!s)return void $();if(!(yield(0,M.pw)(s,j,S,e,N)).ok)return void $();const o=yield(0,M.X4)(),i=(0,E.UF)(o),{activeSubscription:a}=i,c={activeSubscription:a,subscriptions:o,subscriptionStatus:r.dH.ACTIVE};k((0,L.HC)({paused:!1,pausedLength:null})),f((0,R.yS)(c)),n(!1),(0,A.Z4)(C,!1)}),children:(0,i.__)("Resume Subscription","nypost")})]}),(0,s.jsx)("section",{className:"membership-section membership-section--subscribed-user",children:(0,s.jsx)(W,{accessEndDate:(0,p.A)(null==D?void 0:D.date),onSubscriptionCancelled:e=>B(void 0,[e],void 0,function*({formResponse:e,setIsLoading:t,handleOnModalClose:s}){t(!0);const[{id:o=""}={}]=(0,E.$Y)(T);if(!o)return t(!1),s(),void y((0,i.__)("Something went wrong cancelling your subscription. Please try again later.","nypost"));if(yield(0,M.r7)(Object.assign(Object.assign({},e),{paused:!1,pausedLength:null})),!(yield(0,M.M2)({id:o})))return t(!1),yield(0,M.r7)({paused:!0,pausedLength:x}),s(),void y((0,i.__)("Something went wrong cancelling your subscription. Please try again later.","nypost"));const a=yield(0,M.X4)(),r=(0,E.UF)(a),{activeSubscription:c,status:l}=r,u={activeSubscription:c,subscriptions:a,subscriptionStatus:l};k((0,L.HC)({paused:!1,pausedLength:null})),f((0,R.yS)(u)),n(!1),(0,A.Z4)(C,!1)}),onSubscriptionResumed:()=>{u((0,i.__)("Welcome back! Your subscription has resumed.","nypost"))},subscriptionStatus:w})})]})};var G=()=>(0,s.jsx)("div",{className:"member-profile",children:(0,s.jsx)("div",{className:"layout__grid layout__grid--sidebar-sm layout__grid--sidebar-left",children:(0,s.jsx)("div",{className:"layout__item layout__item--main",children:(0,s.jsx)("div",{className:"layout__inner",children:(0,s.jsxs)("section",{className:"member-subscriptions__section",children:[(0,s.jsx)("h4",{className:"membership-account__heading",children:(0,i.__)("Subscription Plan","nypost")}),(0,s.jsx)(u,{})]})})})})})}}]); 2//# sourceMappingURL=746.3bf5e75be336e7cdd699.bundle.min.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.