Module 73079

3,710 characters · in no known chunk
Dependencies
Required by (2)
Lazily required by (0)none
Lazily requires (0)none
Source Raw
function(e,t,n){"use strict";n.d(t,{A:()=>C});var i=n(627968),r=n(64700),s=n(503698),a=n.n(s),o=n(17928),l=n(821609),u=n(289873),c=n(452027),d=n(721101),_=n(405139),h=n(626584),f=n(812745),p=n(192087),E=n(723702),m=n(652215),g=n(375708),A=n(998460),I=n(653307);let T=new h.A("ChoosePaymentSourceType"),S={[m.hes.CARD]:f.Ay.Types.UNKNOWN,[m.hes.PAYPAL]:f.Ay.Types.PAYPAL,[m.hes.SOFORT]:f.Ay.Types.SOFORT,[m.hes.GIROPAY]:f.Ay.Types.GIROPAY,[m.hes.PRZELEWY24]:f.Ay.Types.PRZELEWY24,[m.hes.PAYSAFE_CARD]:f.Ay.Types.PAYSAFECARD,[m.hes.GCASH]:f.Ay.Types.GCASH,[m.hes.GRABPAY_MY]:f.Ay.Types.GRABPAY,[m.hes.MOMO_WALLET]:f.Ay.Types.MOMO_WALLET,[m.hes.VENMO]:f.Ay.Types.VENMO,[m.hes.KAKAOPAY]:f.Ay.Types.KAKAOPAY,[m.hes.GOPAY_WALLET]:f.Ay.Types.GOPAY_WALLET,[m.hes.BANCONTACT]:f.Ay.Types.BANCONTACT,[m.hes.EPS]:f.Ay.Types.EPS,[m.hes.IDEAL]:f.Ay.Types.IDEAL,[m.hes.CASH_APP]:f.Ay.Types.CASH_APP};class y extends r.PureComponent{constructor(e){super(e),this.state={applePayLoaded:!1,googlePayLoaded:!1}}componentDidMount(){(this.props.paymentRequestWallets??[]).length>0&&setTimeout(()=>{this.considerPaymentRequestWalletsLoaded()},1e3)}considerPaymentRequestWalletsLoaded(){let e=this.props.paymentRequestWallets??[];if(0===e.length||!this.arePaymentRequestWalletsLoading())return;T.warn(`Payment request wallets failed to load in time: ${e.join(", ")}. Max time allowed: 1000 ms`);let t=e.reduce((e,t)=>({...e,[`${t}Loaded`]:!0}),{});this.setState(t)}arePaymentRequestWalletsLoading(){if((0,E.isDesktop)())return!1;let e=this.props.paymentRequestWallets??[];if(0===e.length)return!1;for(let t of e)if(!this.state[`${t}Loaded`])return!0;return!1}createPaymentButtons(e){return e.map((e,t)=>{let n=S[e],r=p.w[e](),s=null==this.props.paymentSourceTypeRestrictions||this.props.paymentSourceTypeRestrictions?.includes(e);return(0,i.jsx)(l.$,{autoFocus:0===t&&s,onClick:()=>this.props.onChooseType(e),disabled:!s,fullWidth:!0,text:r,icon:()=>(0,i.jsx)(f.Ay,{className:A.iA,type:n})},e)})}render(){let e,{onChooseType:t,className:n,onStripePaymentMethodReceived:r,paymentRequestPaymentContext:s,isEligibleForTrial:o=!1,paymentSourceCreationContext:l}=this.props,d=this.props.paymentRequestWallets??[],h={iconClassName:A.iA,paymentLabel:g.intl.string(g.t.ZURqX0),onStripePaymentMethodReceived:r,onChooseType:t,paymentRequestPaymentContext:s},f=d.map((e,t)=>{let n=()=>this.setState({[`${e}Loaded`]:!0}),r={onValidPaymentRequest:n,onPaymentRequestFailure:n},s=`${e}-${t}`;return"applePay"===e?(0,i.jsx)(_.Mv,{...h,...r},s):(0,i.jsx)(_.dP,{...h,...r},s)}),p=this.arePaymentRequestWalletsLoading(),E=null==l||l.loading||p,m=null!=l&&!l.loading&&null!=l.error,T=null==l||l.loading||null==l.data?null:l.data;if(E)e=(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:A.R,children:f}),(0,i.jsx)(u.y,{type:u.y.Type.SPINNING_CIRCLE})]});else if(m)e=(0,i.jsx)("div",{className:A.kL,children:g.intl.string(g.t["rTU7/z"])});else if(null!=T){let t=this.createPaymentButtons(T.allowed_payment_source_types);e=(0,i.jsx)("div",{children:(0,i.jsxs)("div",{className:a()(I.LV,I.xM,A.kL),children:[t,f]})})}else e=(0,i.jsxs)("div",{children:[(0,i.jsx)("div",{className:A.R,children:f}),(0,i.jsx)(u.y,{type:u.y.Type.SPINNING_CIRCLE})]});return(0,i.jsxs)("div",{children:[o&&(0,i.jsx)("hr",{className:A.cL}),(0,i.jsx)("div",{className:n,children:(0,i.jsx)(c.D,{label:o?g.intl.string(g.t.tywMsW):g.intl.string(g.t["8lqkf8"]),children:e})}),o&&(0,i.jsx)("hr",{className:A.nD})]})}}let C=o.Ay.connectStores([d.A],()=>{let e=d.A;return{paymentSourceCreationContext:e.loading?{loading:!0,error:null,data:null}:null!=e.error?{loading:!1,error:e.error,data:null}:null!=e.data?{loading:!1,error:null,data:e.data}:{loading:!0,error:null,data:null}}})(y)}