Loading
function(e,t,n){"use strict";n.d(t,{E:()=>f,p:()=>g}),n(321073);var l=n(64700),i=n(602853),s=n(661531),r=n(964486),a=n(655857),o=n(626584),u=n(739508),c=n(71532),d=n(219538),m=n(648335),h=n(818348);let p=new o.A("useStripePaymentElementOptions"),f=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}}},g=e=>{let{onSetupError:t,elementsAppearanceOptions:n={}}=e,[i,s]=l.useState(void 0),[o,g]=l.useState(null),[E,A]=l.useState(!0),[C,x]=l.useState([]),{displayCurrency:I}=(0,a.Jn)(),_=l.useMemo(()=>{let e=["pix","card"],t=C.find(e=>e.payment_source_type===h.he.PAYPAL);return null!=t&&e.push(t.custom_payment_method_id),e},[C]),{customPaymentMethods:S,customPaymentMethodIdsToSourceTypes:y}=l.useMemo(()=>({customPaymentMethods:(0,m.Dd)(C),customPaymentMethodIdsToSourceTypes:C.reduce((e,t)=>(e[t.custom_payment_method_id]=t.payment_source_type,e),{})}),[C]),v=l.useCallback(async()=>{try{let{client_secret:e,custom_payment_methods:t}=await (0,d.w)({body:{currency:I}});x(t),s(e)}catch(e){g(e),null!=t&&t(e),p.error("there was an error on setup for Payment Elements: ",e),(0,u.pM)(e,{tags:{source:"payment_elements"}})}A(!1)},[t,I]);(0,r.Ay)(()=>{v()});let{elementsAppearance:T,elementsAppearanceOptions:N}=f(n),j=(0,c.PU)(),b=l.useMemo(()=>E?null:{clientSecret:i,appearance:T,locale:j,customPaymentMethods:S,paymentMethodCreation:"manual"},[T,j,i,S,E]),R={setupError:o,customPaymentMethods:S,customPaymentMethodIdsToSourceTypes:y,paymentMethodOrder:_,elementsAppearanceOptions:N};return null==i||null==b||E?{...R,isLoading:!0,elementsOptions:b,setupIntentSecret:i}:{...R,isLoading:!1,elementsOptions:b,setupIntentSecret:i}}}