Loading
function(e,t,n){"use strict";n.d(t,{E:()=>p,p:()=>f}),n(321073);var l=n(64700),i=n(602853),s=n(661531),r=n(964486),a=n(626584),o=n(739508),u=n(71532),c=n(219538),d=n(648335),m=n(818348);let h=new a.A("useStripePaymentElementOptions"),p=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=(0,i.r)(s.A.colors.MODAL_BACKGROUND),n=(0,i.r)(s.A.colors.TEXT_STRONG),r=(0,i.r)(s.A.colors.INPUT_BACKGROUND_DEFAULT),a=e.theme??"flat",o=e.colorText??n.hex(),u=e.colorBackground??t.hex(),c=e.inputBackgroundColor??r.hex(),d=e.tabBackgroundColor??r.hex(),m=e.tabSelectedBackgroundColor??null;return{elementsAppearance:l.useMemo(()=>({theme:a,variables:{colorText:o,colorBackground:u},rules:{".Input":{backgroundColor:c},".Tab":{backgroundColor:d},...null!=m?{".Tab--selected":{backgroundColor:m}}:{}}}),[a,o,u,c,d,m]),elementsAppearanceOptions:{theme:a,colorText:o,colorBackground:u,inputBackgroundColor:c,tabBackgroundColor:d}}},f=e=>{let{onSetupError:t,elementsAppearanceOptions:n={}}=e,[i,s]=l.useState(void 0),[a,f]=l.useState(null),[g,E]=l.useState(!0),[A,C]=l.useState([]),x=l.useMemo(()=>{let e=["card"],t=A.find(e=>e.payment_source_type===m.he.PAYPAL);return null!=t&&e.push(t.custom_payment_method_id),e},[A]),{customPaymentMethods:I,customPaymentMethodIdsToSourceTypes:_}=l.useMemo(()=>({customPaymentMethods:(0,d.Dd)(A),customPaymentMethodIdsToSourceTypes:A.reduce((e,t)=>(e[t.custom_payment_method_id]=t.payment_source_type,e),{})}),[A]),S=l.useCallback(async()=>{try{let{client_secret:e,custom_payment_methods:t}=await (0,c.w)();C(t),s(e)}catch(e){f(e),null!=t&&t(e),h.error("there was an error on setup for Payment Elements: ",e),(0,o.pM)(e,{tags:{source:"payment_elements"}})}E(!1)},[t]);(0,r.Ay)(()=>{S()});let{elementsAppearance:y,elementsAppearanceOptions:v}=p(n),T=(0,u.PU)(),N=l.useMemo(()=>g?null:{clientSecret:i,appearance:y,locale:T,customPaymentMethods:I,paymentMethodCreation:"manual"},[y,T,i,I,g]),j={setupError:a,customPaymentMethods:I,customPaymentMethodIdsToSourceTypes:_,paymentMethodOrder:x,elementsAppearanceOptions:v};return null==i||null==N||g?{...j,isLoading:!0,elementsOptions:N,setupIntentSecret:i}:{...j,isLoading:!1,elementsOptions:N,setupIntentSecret:i}}}