import{createElement as e,Fragment as t}from"../../../../external/preact/dist/preact.js";import{OrderPaymentMethods as o}from"./OrderPaymentMethods.js";import{InstantPaymentMethods as r}from"./InstantPaymentMethods.js";import{useCoreContext as n}from"../../../../core/Context/CoreProvider.js";import{useBrandLogoConfiguration as l}from"./useBrandLogoConfiguration.js";import s from"./PaymentMethodsContainer.js";import{useEffect as a}from"../../../../external/preact/hooks/dist/hooks.js";function i(e,t,o){return t in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}function p(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{},r=Object.keys(o);"function"==typeof Object.getOwnPropertySymbols&&(r=r.concat(Object.getOwnPropertySymbols(o).filter(function(e){return Object.getOwnPropertyDescriptor(o,e).enumerable}))),r.forEach(function(t){i(e,t,o[t])})}return e}function c(e,t){return t=null!=t?t:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):function(e){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t.push.apply(t,o)}return t}(Object(t)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(t,o))}),e}function d(e,t){if(null==e)return{};var o,r,n,l={};if("undefined"!=typeof Reflect&&Reflect.ownKeys){for(o=Reflect.ownKeys(e),n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r]);return l}if(l=function(e,t){if(null==e)return{};var o,r,n={},l=Object.getOwnPropertyNames(e);for(r=0;r<l.length;r++)o=l[r],t.indexOf(o)>=0||Object.prototype.propertyIsEnumerable.call(e,o)&&(n[o]=e[o]);return n}(e,t),Object.getOwnPropertySymbols)for(o=Object.getOwnPropertySymbols(e),n=0;n<o.length;n++)r=o[n],t.indexOf(r)>=0||Object.prototype.propertyIsEnumerable.call(e,r)&&(l[r]=e[r]);return l}const y=i=>{let{paymentMethods:y,instantPaymentMethods:u,storedPaymentMethods:m,openFirstStoredPaymentMethod:f,openFirstPaymentMethod:b,openPaymentMethod:O,order:h,orderStatus:P=null,onOrderCancel:j,onSelect:g=()=>{}}=i,M=d(i,["paymentMethods","instantPaymentMethods","storedPaymentMethods","openFirstStoredPaymentMethod","openFirstPaymentMethod","openPaymentMethod","order","orderStatus","onOrderCancel","onSelect"]);const{i18n:v}=n(),S=l(y),w=(null==u?void 0:u.length)>0,C=(null==m?void 0:m.length)>0,x=w||C?v.get("paymentMethodsList.otherPayments.label"):"";return a(()=>{if(null==O?void 0:O.type){const e=null==y?void 0:y.find(e=>e.type===(null==O?void 0:O.type));if(e)return void g(e);console.warn(`Drop-in: payment method type "${null==O?void 0:O.type}" not found`)}const e=null==m?void 0:m[0],t=null==y?void 0:y[0];if(e||t){var o;if(f&&!0===(null==e||null===(o=e.props)||void 0===o?void 0:o.oneClick))return void g(e);b&&g(t)}},[m,y,f,b,O]),e(t,null,P&&e(o,{order:h,orderStatus:P,onOrderCancel:j,brandLogoConfiguration:S}),w&&e(r,{paymentMethods:u,onSelect:g}),C&&e(s,c(p({},M),{label:v.get("paymentMethodsList.storedPayments.label"),classNameModifiers:["storedPayments"],paymentMethods:m,onSelect:g})),!!y.length&&e(s,c(p({},M),{label:x,classNameModifiers:["otherPayments"],paymentMethods:y,onSelect:g})))};export{y as default};
//# sourceMappingURL=PaymentMethodList.js.map
