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