Loading
function(e,t,n){"use strict";n.d(t,{B:()=>_});var l=n(64700),i=n(17928),s=n(688810),r=n(753390),a=n(120700),o=n(211159),u=n(166532),c=n(566980),d=n(615310),m=n(216641),h=n(825755),p=n(174459),f=n(428262),g=n(526151),E=n(20654),A=n(303557),C=n(652215),x=n(788868),I=n(818348);function _(e){let{onComplete:t}=e,{guildId:n,intent:_,onSubscribeComplete:S,flowStartTime:y,numGuildBoostsToPurchase:v,analyticsLocation:T,analyticsSourceLocation:N,paymentModalArgs:j}=(0,g.Oe)(),{setIsSubmittingCurrentStep:b,paymentSources:R}=j,{premiumGuildSubscriptionPlanId:P}=(0,A.l)(),{paymentSourceId:L,setPurchaseState:M,setPurchaseError:O,loadId:w,startTime:k}=(0,o.t4)(e=>({paymentSourceId:e.paymentSourceId,setPurchaseState:e.setPurchaseState,setPurchaseError:e.setPurchaseError,loadId:e.contextMetadata.loadId,startTime:e.contextMetadata.startTime})),D=(0,d.l)(),U=(0,s.Db)(),G=(0,i.bG)([h.A],()=>h.A.popupCallbackCalled),F={baseAnalyticsData:l.useMemo(()=>({load_id:w,payment_type:I.fr[I.VV.SUBSCRIPTION],subscription_type:C.rzx.PREMIUM,subscription_plan_id:P,sku_id:(0,f.mH)(x.pe.GUILD),quantity:v,location:T,source:N,location_stack:U,checkout_flow:a.C.GUILD_BOOST_CHECKOUT,is_gift:!1,eligible_for_trial:!1,guild_id:n??void 0}),[w,P,v,T,N,U,n]),flowStartTime:y,startTime:k,guildId:n,onComplete:t,onSubscribeComplete:S,paymentSourceId:L,paymentSources:R,setIsSubmittingCurrentStep:b,setPurchaseError:O,setPurchaseState:M,setStep:D},V=l.useRef(F);return l.useEffect(()=>{V.current=F}),l.useEffect(()=>{let{baseAnalyticsData:e,flowStartTime:t,startTime:n,guildId:l,onComplete:i,onSubscribeComplete:s,paymentSourceId:a,paymentSources:o,setIsSubmittingCurrentStep:d,setPurchaseError:f,setPurchaseState:g,setStep:A}=V.current;(async()=>{if(!0===G)try{if(null==h.A.redirectedPaymentId)return;await (0,r.tn)(h.A.redirectedPaymentId),p.default.track(C.HAw.PAYMENT_FLOW_SUCCEEDED,{...e,duration_ms:Date.now()-n,payment_source_type:(0,m.g)(o,a)??void 0}),f(null),A(u.pn.CONFIRM),g(c.h.COMPLETED),null!=l&&await (0,E.a)(l,null!=_),s?.(),null!=i&&i()}catch(i){g(c.h.FAIL),f(i);let{guild_id:n,...l}=e;p.default.track(C.HAw.PAYMENT_FLOW_FAILED,{...l,payment_error_code:i?.code,payment_gateway:C.kM_.STRIPE,payment_source_id:a,duration_ms:Date.now()-t})}finally{d(!1),(0,r.bl)()}})()},[G,_]),null}}