Module 694080

2,739 characters · in no known chunk
Dependencies
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{Vn:()=>f,_D:()=>_,qz:()=>h,u1:()=>p});var i=n(636537),r=n(554146),s=n(228366),a=n(826673),o=n(594061),l=n(174459),u=n(723702),c=n(38405),d=n(652215);async function _(e){let t=!(arguments.length>1)||void 0===arguments[1]||arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{offerId:void 0,paymentGatewayOverride:void 0},_=arguments.length>3?arguments[3]:void 0,f=arguments.length>4?arguments[4]:void 0;if(t){s.h.dispatch({type:"BILLING_USER_OFFER_FETCH_START"});try{let t;null!=e&&l.default.track(d.HAw.FETCH_USER_OFFER_STARTED,{call_location:e});let{offerId:h,paymentGatewayOverride:p}=n,E=void 0!==p?p:(t=null,(0,u.isAndroid)()?t=d.kM_.GOOGLE:(0,u.isIOS)()&&(t=d.kM_.APPLE),t),m=await i.Bo.post({url:d.Rsh.USER_OFFER,body:null!=E||null!=h?{payment_gateway:E,offer_id:h}:{},rejectWithError:!0,retries:null!=_?_.retries:void 0}),g=m.body.user_trial_offer??null,A=m.body.user_discount??null,I=m.body.user_discount_offer??null;if(null!=h&&null!=I&&I.discount_id!==h){let e=Error("Returned user discount offer does not match offer ID request parameter");throw c.A.captureException(e,{extra:{offer_id:h,user_discount_offer:I},...f}),e}return null==g&&(0,a.k8)(r.M.NAGBAR_NOTICE_PREMIUM_TIER_TWO_TRIAL_ENDING)&&(0,o.xB)(r.M.NAGBAR_NOTICE_PREMIUM_TIER_TWO_TRIAL_ENDING),s.h.dispatch({type:"BILLING_USER_OFFER_FETCH_SUCCESS",userTrialOffer:g,userDiscount:A,userDiscountOffer:I}),{userTrialOffer:g,userDiscount:A,userDiscountOffer:I}}catch(e){s.h.dispatch({type:"BILLING_USER_OFFER_FETCH_FAIL"})}}}async function f(){s.h.dispatch({type:"BILLING_USER_OFFER_FETCH_START"});try{let e=(await i.Bo.get({url:d.Rsh.CHURN_USER_OFFER,rejectWithError:!0})).body.offer??null;return s.h.dispatch({type:"BILLING_USER_OFFER_FETCH_SUCCESS",userDiscountOffer:e}),{userDiscountOffer:e}}catch(e){s.h.dispatch({type:"BILLING_USER_OFFER_FETCH_FAIL"})}}async function h(){let e=null;try{e=(await i.Bo.post({url:d.Rsh.CHURN_USER_OFFER,rejectWithError:!0})).body.offer??null,null!=e&&s.h.dispatch({type:"BILLING_USER_OFFER_FETCH_SUCCESS",userDiscountOffer:e})}catch(e){}return e}function p(e,t){let n=null!=e&&null==e.expires_at?e.id:void 0,r=null!=t&&null==t.expires_at?t.id:void 0;if(void 0!==n||void 0!==r)return i.Bo.post({url:d.Rsh.USER_OFFER_ACKNOWLEDGED,body:{user_trial_offer_id:n,user_discount_offer_id:r},oldFormErrors:!0,rejectWithError:!1}).then(e=>{s.h.dispatch({type:"BILLING_USER_OFFER_ACKNOWLEDGED_SUCCESS",userTrialOffer:e.body.user_trial_offer??null,userDiscount:e.body.user_discount??null,userDiscountOffer:e.body.user_discount_offer??null})}).catch(e=>{404===e.status&&s.h.dispatch({type:"BILLING_USER_OFFER_ACKNOWLEDGED_SUCCESS",userTrialOffer:null,userDiscount:null,userDiscountOffer:null})})}}