Loading
function(e,t,r){r.d(t,{Bf:()=>h,Ce:()=>_,J$:()=>E});var n=r(636537),l=r(73153),a=r(913122),i=r(626584),d=r(977445),c=r(67480),s=r(38405),o=r(652215);let u=new i.A("VirtualCurrencyActionCreators");async function h(){l.h.dispatch({type:"VIRTUAL_CURRENCY_BALANCE_FETCH"});try{let e=await n.Bo.get({url:o.Rsh.VIRTUAL_CURRENCY_USER_BALANCE,rejectWithError:!1}),t=e.body.balance;return l.h.dispatch({type:"VIRTUAL_CURRENCY_BALANCE_FETCH_SUCCESS",balance:t}),e.body}catch(t){let e=t instanceof a.Ey?t:new a.Ey(t);l.h.dispatch({type:"VIRTUAL_CURRENCY_BALANCE_FETCH_FAIL",error:e})}}async function _(){l.h.dispatch({type:"VIRTUAL_CURRENCY_TOTAL_REDEEMED_FETCH"});try{let e=await n.Bo.get({url:o.Rsh.VIRTUAL_CURRENCY_USER_TOTAL_REDEEMED,rejectWithError:!1}),t=e.body.total_redeemed;return l.h.dispatch({type:"VIRTUAL_CURRENCY_TOTAL_REDEEMED_FETCH_SUCCESS",totalRedeemed:t}),e.body}catch(t){let e=t instanceof a.Ey?t:new a.Ey(t);l.h.dispatch({type:"VIRTUAL_CURRENCY_TOTAL_REDEEMED_FETCH_FAIL",error:e})}}async function E(e){let{skuId:t,loadId:r,onRedeemStart:i,onRedeemSucceed:_,onRedeemFail:E,shouldRefetchBalance:R=!0}=e;l.h.dispatch({type:"VIRTUAL_CURRENCY_REDEEM_START",skuId:t}),i?.();try{let e=c.A.get(t),a=e?.applicationId,i=null!=a&&(0,d.Fs)(a),E={checkout_session_id:r};i&&(E.test_mode=!0);let C=(await n.Bo.post({url:o.Rsh.VIRTUAL_CURRENCY_SKU_REDEEM(t),body:E,rejectWithError:!1})).body;if(null==C||!Array.isArray(C)){let e="Could not read entitlements from Virtual Currency redemption response. Response: ",t=Error(e,C);throw u.error(e,C),s.A.captureException(t,{tags:{app_context:"virtual_currency"}}),t}return l.h.dispatch({type:"VIRTUAL_CURRENCY_REDEEM_SUCCESS",skuId:t,entitlements:C}),R&&h(),_?.(C),C}catch(r){let e=r instanceof a.Ey?r:new a.Ey(r);l.h.dispatch({type:"VIRTUAL_CURRENCY_REDEEM_FAIL",skuId:t,error:e}),R&&h(),E?.(e)}}}