Module 326084

2,408 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,{P7:()=>E,aK:()=>c,kZ:()=>I,o:()=>u,xM:()=>A,xm:()=>h}),n(321073);var i,r,a=n(562465),s=n(228366);n(493336);var l=n(889227);n(309010);var o=n(38405),d=n(652215),c=((i={})[i.REDEEMED=1]="REDEEMED",i[i.PENDING=2]="PENDING",i[i.CONVERTED=3]="CONVERTED",i),u=((r={})[r.SUCCESS=1]="SUCCESS",r[r.FAIL=2]="FAIL",r);let _=new class{cache;expiration;constructor(){this.cache=new Map,this.expiration=Date.now()+6e5}set(e,t){this.cache.set(e,t)}get(e){return this._checkExpiration(),this.cache.get(e)}has(e){return this._checkExpiration(),this.cache.has(e)}_checkExpiration(){this.expiration<Date.now()&&this.cache.clear()}};async function E(e,t,n){let i=JSON.stringify({index:e,searchQuery:t});if(_.has(i))return _.get(i);let{users:r,next_index:s}=(await a.Bo.post({url:d.Rsh.GET_REFERRAL_ELIGIBLE_USERS,body:{index:e,limit:n??10,search_query:t},oldFormErrors:!0,rejectWithError:!1})).body,o={users:r.map(e=>new l.A(e)),nextIndex:s};return _.set(i,o),o}function A(){return s.h.dispatch({type:"BILLING_REFERRALS_REMAINING_FETCH_START"}),a.Bo.get({url:d.Rsh.GET_REFERRALS_REMAINING,oldFormErrors:!0,rejectWithError:!1}).then(e=>{let t=new Map;if(null!=e.body&&null!=e.body.recipient_status)for(let n in e.body.recipient_status){let i=e.body.recipient_status[n];t.set(n,i)}s.h.dispatch({type:"BILLING_REFERRALS_REMAINING_FETCH_SUCCESS",referrals_remaining:null!=e.body&&null!=e.body.referrals_remaining?e.body.referrals_remaining:0,sent_user_ids:null!=e.body&&null!=e.body.sent_user_ids?e.body.sent_user_ids:[],refresh_at:e.body?.refresh_at??null,recipient_status:t,has_eligible_friends:e.body?.has_eligible_friends??!1,reminder_state_id:e.body?.reminder_state_id??null})},e=>{e?.status!==404&&s.h.dispatch({type:"BILLING_REFERRALS_REMAINING_FETCH_FAIL"})})}async function h(e){let t=[],n=new Map;for(let i of e)try{let e=(await a.Bo.post({url:d.Rsh.CREATE_REFERRAL(i),oldFormErrors:!0,rejectWithError:!0})).body??null;null!=e&&t.push(e),n.set(i,1)}catch(e){o.A.captureException(e),n.set(i,2)}return s.h.dispatch({type:"CREATE_REFERRALS_SUCCESS",userTrialOffers:t}),n}async function I(e){try{let t=(await a.Bo.get({url:d.Rsh.REFERRAL_OFFER_ID_RESOLVE(e),oldFormErrors:!0,rejectWithError:!1})).body??null;return s.h.dispatch({type:"BILLING_REFERRAL_RESOLVE_SUCCESS",userTrialOffer:t}),{userTrialOffer:t}}catch(t){s.h.dispatch({type:"BILLING_REFERRAL_RESOLVE_FAIL",userTrialOfferId:e})}}}