1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3667],{3667:(e,t,n)=>{n.r(t),n.d(t,{PAYMENT_ISSUE_CODES:()=>u,default:()=>p});var l=n(95155),a=n(12115),s=n(78519),r=n(919),i=n(52987),o=n(99708),d=n(27816),c=n(91078),h=n(54679),m=n(1131);let u=new Set(["card_verification_failed","payment_declined"]);function x(e){if(!e)return null;let t=new Date(e);return Number.isNaN(t.getTime())?null:t.toLocaleDateString("en-US",{month:"long",day:"numeric",year:"numeric"})}function p(e){var t,n;let{isOpen:p,onClose:g,targetPlanCode:f,onChanged:w,onUpdatePaymentMethod:N,successNote:y}=e,[j,b]=(0,a.useState)("loading"),[v,C]=(0,a.useState)(null),[P,k]=(0,a.useState)(null),[S,A]=(0,a.useState)(null),[T,F]=(0,a.useState)(null),[_,E]=(0,a.useState)(null);(0,a.useEffect)(()=>{if(!p||!f)return;let e=!1;return b("loading"),C(null),k(null),A(null),(async()=>{try{let t=await fetch("/api/recurly/subscription/change-self/preview",{method:"POST",headers:await (0,m.getAuthHeaders)(),body:JSON.stringify({targetPlanCode:f})}),n=await t.json();if(e)return;if(!t.ok)throw Error((null==n?void 0:n.error)||"Could not preview this plan change.");C(n.preview),b("confirm")}catch(t){if(e)return;k((null==t?void 0:t.message)||"Could not preview this plan change."),b("error")}})(),()=>{e=!0}},[p,f]);let Y=async()=>{b("processing"),k(null),A(null);try{let e=await fetch("/api/recurly/subscription/change-self",{method:"POST",headers:await (0,m.getAuthHeaders)(),body:JSON.stringify({targetPlanCode:f})}),t=await e.json();if(!e.ok)throw"string"==typeof(null==t?void 0:t.code)&&A(t.code),Error((null==t?void 0:t.error)||"The plan change could not be completed.");F((null==t?void 0:t.newPlanName)||(null==v?void 0:v.targetPlanName)||"your new plan"),E("number"==typeof(null==t?void 0:t.chargedToday)?t.chargedToday:null),b("success"),setTimeout(()=>{null==w||w({newPlanCode:(null==t?void 0:t.newPlanCode)||f,newPlanName:(null==t?void 0:t.newPlanName)||""})},1200)}catch(e){k((null==e?void 0:e.message)||"The plan change could not be completed."),b("error")}},O=x(null!=(t=null==v?void 0:v.effectiveAt)?t:null),U=x(null!=(n=null==v?void 0:v.nextBillingAt)?n:null),D=(null==v?void 0:v.timeframe)==="now"&&(null==v?void 0:v.mode)==="prorated";return(0,l.jsx)(h.lG,{open:p,onOpenChange:e=>{e||"processing"===j||g()},children:(0,l.jsxs)(h.Cf,{className:"bg-gradient-to-br from-slate-900/95 via-indigo-950/95 to-slate-900/95 backdrop-blur-md border border-white/15 text-white w-[95vw] max-w-md p-0 overflow-hidden",children:[(0,l.jsx)(h.c7,{className:"px-6 pt-6",children:(0,l.jsxs)("div",{className:"flex items-center gap-3",children:[(0,l.jsx)("div",{className:"w-12 h-12 rounded-2xl bg-gradient-to-br from-indigo-500/25 to-purple-500/25 border border-indigo-400/40 flex items-center justify-center shrink-0",children:(0,l.jsx)(s.A,{className:"h-6 w-6 text-indigo-200"})}),(0,l.jsxs)("div",{children:[(0,l.jsx)(h.L3,{className:"text-lg font-bold leading-tight",children:v?"".concat(v.isUpgrade?"Upgrade to":"Switch to"," ").concat(v.targetPlanName):"Change plan"}),(0,l.jsx)(h.rr,{className:"text-white/60 text-xs mt-0.5",children:"Billed to your card on file"})]})]})}),(0,l.jsxs)("div",{className:"px-6 pb-6 pt-4 space-y-4",children:["loading"===j&&(0,l.jsxs)("div",{className:"flex flex-col items-center gap-3 py-8",children:[(0,l.jsx)(r.A,{className:"h-8 w-8 text-indigo-300 animate-spin"}),(0,l.jsx)("p",{className:"text-white/80 text-sm",children:"Calculating your prorated totalâ¦"})]}),"confirm"===j&&v&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"flex items-center justify-center gap-2 text-sm text-white/80",children:[(0,l.jsx)("span",{children:v.currentPlanName}),(0,l.jsx)(i.A,{className:"h-4 w-4 text-white/40"}),(0,l.jsx)("span",{className:"font-semibold text-white",children:v.targetPlanName})]}),(0,l.jsxs)("div",{className:"rounded-xl bg-white/5 border border-white/10 p-4 space-y-2",children:[v.lineItems.map((e,t)=>(0,l.jsxs)("div",{className:"flex items-baseline justify-between gap-3 text-sm",children:[(0,l.jsx)("span",{className:e.isCredit?"text-emerald-300/90":"text-white/80",children:e.description}),(0,l.jsxs)("span",{className:"shrink-0 ".concat(e.isCredit?"text-emerald-300":"text-white"),children:[e.isCredit?"â":"","$",Math.abs(e.amount).toFixed(2)]})]},t)),v.lineItems.length>0&&(0,l.jsx)("div",{className:"border-t border-white/10"}),(0,l.jsxs)("div",{className:"flex items-baseline justify-between",children:[(0,l.jsx)("span",{className:"text-white font-semibold text-sm",children:D?"Due today (difference only)":"Due today"}),(0,l.jsxs)("span",{className:"text-2xl font-bold text-white",children:["$",v.dueToday.toFixed(2)]})]})]}),(0,l.jsxs)("p",{className:"text-white/50 text-xs flex items-start gap-1.5",children:[(0,l.jsx)(o.A,{className:"h-3.5 w-3.5 mt-0.5 shrink-0"}),D?(0,l.jsxs)(l.Fragment,{children:["You only pay the difference between ",v.currentPlanName," and"," ",v.targetPlanName," for the rest of your current billing period â the unused days you already paid for are credited. Your renewal date does not change",U?" (".concat(U,")"):"","; from then on you are billed the regular ",v.targetPlanName," price."]}):"now"===v.timeframe?(0,l.jsxs)(l.Fragment,{children:["You pay the full ",v.targetPlanName," price today. A new billing period starts now",U?" and renews on ".concat(U):"",". Unused time on ",v.currentPlanName," is not credited â included
1sending on the new plan is billed as a full period."]}):(0,l.jsxs)(l.Fragment,{children:["Nothing is charged today. Your plan changes",O?" on ".concat(O):" at your next renewal"," and you keep your current features until then."]})]}),(0,l.jsx)("button",{onClick:Y,className:"w-full py-3 rounded-xl bg-gradient-to-r from-indigo-500 to-purple-600 hover:from-indigo-400 hover:to-purple-500 text-white font-semibold shadow-lg transition-colors",children:v.dueToday>0?"Confirm & Pay $".concat(v.dueToday.toFixed(2)):"Confirm plan change"}),(0,l.jsx)("button",{onClick:g,className:"w-full py-2 text-white/50 hover:text-white/80 text-sm transition-colors",children:"Cancel"})]}),"processing"===j&&(0,l.jsxs)("div",{className:"flex flex-col items-center gap-3 py-8",children:[(0,l.jsx)(r.A,{className:"h-8 w-8 text-indigo-300 animate-spin"}),(0,l.jsx)("p",{className:"text-white/80 text-sm",children:"Applying your plan changeâ¦"})]}),"success"===j&&(0,l.jsxs)("div",{className:"flex flex-col items-center gap-3 py-8",children:[(0,l.jsx)(d.A,{className:"h-10 w-10 text-emerald-400"}),(0,l.jsxs)("p",{className:"text-white font-semibold",children:["You're on ",T]}),null!==_&&_>0&&(0,l.jsxs)("p",{className:"text-emerald-300 text-sm",children:["$",_.toFixed(2)," charged to your card on file"]}),(0,l.jsx)("p",{className:"text-white/60 text-sm text-center",children:null!=y?y:"Your new features are unlocked. This page will refresh in a moment."})]}),"error"===j&&(0,l.jsxs)(l.Fragment,{children:[(0,l.jsxs)("div",{className:"rounded-xl bg-red-500/10 border border-red-400/30 p-4 flex items-start gap-2.5",children:[(0,l.jsx)(c.A,{className:"h-5 w-5 text-red-300 shrink-0 mt-0.5"}),(0,l.jsxs)("div",{children:[(0,l.jsx)("p",{className:"text-red-200 text-sm font-medium",children:S&&u.has(S)?"Card on file declined":"Plan change unavailable"}),(0,l.jsx)("p",{className:"text-red-200/80 text-xs mt-1",children:P})]})]}),S&&u.has(S)&&N&&(0,l.jsxs)("button",{onClick:N,className:"w-full py-3 rounded-xl bg-gradient-to-r from-indigo-500 to-purple-600 hover:from-indigo-400 hover:to-purple-500 text-white font-semibold shadow-lg transition-colors flex items-center justify-center gap-2",children:[(0,l.jsx)(s.A,{className:"h-4 w-4"}),"Update payment method"]}),(0,l.jsx)("button",{onClick:g,className:"w-full py-2 text-white/50 hover:text-white/80 text-sm transition-colors",children:"Close"})]})]})]})})}}}]);
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.