Build 555975stable
Module 679374
1,786 characters · in 125fa66124f99f4e.jsDependencies
Source Raw
function(e,t,r){r.d(t,{_5:()=>I,rV:()=>x});var n=r(627968),l=r(64700),u=r(430993),a=r(834730),i=r(20742),s=r(534479),c=r(211287),o=r(739508),d=r(624210),p=r(573582),f=r(818348),h=r(480642),m=r(375708);let y=l.createContext(null),I=()=>l.useContext(y);function v(e){let{renderModalProps:t,children:r}=e,l=(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(i.rQ,{}),(0,n.jsx)(u.c,{children:r})]});return null!=t?(0,n.jsx)(h.Jg,{...t,children:l}):l}function x(e){let{loadId:t,skuIDs:r,paymentGateway:u,onOrderCreated:i,renderModalProps:h,children:I}=e,{order:x,isCreateOrderLoading:S,createOrderError:E,shouldBlockOnOrderCreation:C}=function(e){let{skuIDs:t,paymentGateway:r,loadId:n,onOrderCreated:u}=e,a=p.A.useConfig({location:"payment_modal"}).enabled,i=c.A.useConfig({location:"payment_modal"}).enabled,s=r===f.kM.VIRTUAL_CURRENCY,h=s?i:a,m=s&&i,y=t?.[0],[I,v]=(0,l.useState)(null),[x,S]=(0,l.useState)(null),[E,C]=(0,l.useState)(m),P=(0,l.useRef)(!1),_=(0,l.useCallback)(async e=>{let{skuId:t}=e;C(!0);try{let e=await (0,d.fS)({skuId:t,paymentGateway:r,loadId:n});v(e),null!=u&&u(e)}catch(l){let e=l instanceof Error?l:Error(String(l));(0,o.gr)(l)||(0,o.pM)(e,{tags:{source:"create_order"},extra:{skuId:t,paymentGateway:String(r),loadId:n}}),S(e)}finally{C(!1)}},[r,n,u]);return(0,l.useEffect)(()=>{h&&null!=y&&(null!=I||null!=x||P.current||(P.current=!0,_({skuId:y})))},[y,h,I,_,x]),{order:I,isCreateOrderLoading:E,createOrderError:x,shouldBlockOnOrderCreation:m}}({skuIDs:r,paymentGateway:u,loadId:t,onOrderCreated:i});if(C){if(S)return(0,n.jsx)(v,{renderModalProps:h,children:(0,n.jsx)(s.A,{})});else if(null!=E)return(0,n.jsx)(v,{renderModalProps:h,children:(0,n.jsx)(a.E,{variant:"text-md/normal",children:m.intl.string(m.t.F8FvUy)})})}return(0,n.jsx)(y.Provider,{value:x,children:I})}}