Module 205463

2,095 characters · in 8f413802c945c52b.js
Dependencies
Required by (0)none
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(t,e,r){r.d(e,{default:()=>C});var n=r(627968),i=r(64700),a=r(189213),o=r(964486),s=r(174459),l=r(137728),u=r(751877),c=r(788868),d=r(88001),m=r(652215),_=r(466919),p=r(375708);let f={1:"what_you_lose",2:"confirmation"},P=t=>{let{onClose:e,currentUser:r,onNext:i,...o}=t;return(0,n.jsx)(a.Modal,{title:p.intl.formatToPlainString(_.default["4e7WtF"],{premiumGroupProductName:(0,d.DP)()}),subtitle:p.intl.formatToPlainString(_.default["3kVEg0"],{cooldownMonths:d.wl}),onClose:e,...o,actions:[{text:p.intl.string(_.default.UFHNtO),variant:"secondary",onClick:e},{text:p.intl.string(p.t["3PatSz"]),variant:"primary",onClick:i}],children:(0,n.jsx)(l.l,{currentUser:r,premiumType:c.PremiumTypes.TIER_2,onClose:e,isDowngrade:!1,isPremiumRebrand:!0})})},w=t=>{let{onClose:e,onConfirm:r,isRemovingUser:i,...o}=t;return(0,n.jsx)(a.Modal,{size:"md",title:p.intl.formatToPlainString(_.default.IrvJHs,{premiumGroupProductName:(0,d.DP)()}),subtitle:p.intl.formatToPlainString(_.default.cQDYKU,{premiumGroupProductName:(0,d.DP)(),cooldownMonths:d.wl}),onClose:e,actions:[{text:p.intl.string(_.default.UFHNtO),variant:"secondary",onClick:e},{text:p.intl.string(p.t["cY+Oob"]),variant:"critical-primary",onClick:r,loading:i}],...o})},C=t=>{let{premiumGroupSubscriptionId:e,currentUser:r,onClose:a,...l}=t,[c,d]=i.useState(1),[_,p]=i.useState(!1),C=i.useRef(0),E=i.useRef(0);(0,o.Ay)(()=>{let t=Date.now();C.current=t,E.current=t,s.default.track(m.HAw.PREMIUM_GROUP_MEMBER_CANCELLATION_STARTED,{subscription_id:e})});let M=(t,r)=>{s.default.track(m.HAw.PREMIUM_GROUP_MEMBER_CANCELLATION_STEP,{subscription_id:e,from_step:f[t],to_step:r,step_duration_ms:Date.now()-E.current,flow_duration_ms:Date.now()-C.current}),E.current=Date.now()},R=async()=>{M(c,null),await a()},T=async()=>{p(!0),(await (0,u.oO)(e,r.id)).ok&&(s.default.track(m.HAw.PREMIUM_GROUP_MEMBER_CANCELLATION_COMPLETED,{subscription_id:e}),a()),p(!1)};switch(c){case 1:return(0,n.jsx)(P,{...l,onNext:()=>{M(c,f[2]),d(2)},currentUser:r,onClose:R});case 2:return(0,n.jsx)(w,{...l,onConfirm:T,onClose:R,isRemovingUser:_});default:return null}}}