Loading
function(e,r,t){t.d(r,{i:()=>s});var n=t(64700),a=t(211287),l=t(739508),i=t(624210),o=t(573582),u=t(818348);function s(e){let{skuIDs:r,paymentGateway:t,loadId:s,onOrderCreated:d}=e,c=o.A.useConfig({location:"payment_modal"}).enabled,p=a.A.useConfig({location:"payment_modal"}).enabled,y=t===u.kM.VIRTUAL_CURRENCY,_=y?p:c,f=y&&p,E=r?.[0],[h,R]=(0,n.useState)(null),[m,b]=(0,n.useState)(null),[w,g]=(0,n.useState)(f),C=(0,n.useRef)(!1),S=(0,n.useCallback)(async e=>{let{skuId:r}=e;g(!0);try{let e=await (0,i.fS)({skuId:r,paymentGateway:t,loadId:s});R(e),null!=d&&d(e)}catch(n){let e=n instanceof Error?n:Error(String(n));(0,l.gr)(n)||(0,l.pM)(e,{tags:{source:"create_order"},extra:{skuId:r,paymentGateway:String(t),loadId:s}}),b(e)}finally{g(!1)}},[t,s,d]);return(0,n.useEffect)(()=>{_&&null!=E&&(null!=h||null!=m||C.current||(C.current=!0,S({skuId:E})))},[E,_,h,S,m]),{order:h,isCreateOrderLoading:w,createOrderError:m,shouldBlockOnOrderCreation:f}}}