(()=>{"use strict";const e=window.wp.htmlEntities,t=window.wp.element,n=window.ReactJSXRuntime,{registerPaymentMethod:o}=window.wc.wcBlocksRegistry,{getSetting:s}=window.wc.wcSettings,r=s("payxpert_cc_data",{}),i=(0,e.decodeEntities)(r.title);let c=!1;const a=o=>{const s=[];c="FR"===o.billing.billingAddress.country;const i=Boolean(r?.seamless),a=r?.seamless?.prefix,{eventRegistration:p,emitResponse:l}=o,d=p?.onPaymentSetup,u=p?.onCheckoutSuccess;return(0,t.useEffect)(()=>{if(!(i&&a&&d&&l))return;const e=document.querySelector('input[name="radio-control-wc-payment-method-options"]:checked')?.value;if(e!==a)return;const t=d(async()=>{const e=document.querySelector(`.payxpert-seamless-container[data-method="${a}"]`);if(!e)return{type:l.responseTypes.ERROR};const t=e.querySelector(".payxpert_nonce")?.value,n=e.querySelector(".customerToken")?.value;return t&&n?{type:l.responseTypes.SUCCESS,meta:{paymentMethodData:{payxpert_nonce:t,[`${a}_customer_token`]:n}}}:{type:l.responseTypes.ERROR}});return()=>{"function"==typeof t&&t()}},[l?.responseTypes,d,a]),(0,t.useEffect)(()=>{i&&"function"==typeof window.mountPayxpertIframe&&(window.togglePlaceOrder(),window.mountPayxpertIframe())},[]),(0,t.useEffect)(()=>{if(i&&u)return u(e=>{"function"==typeof window.payxpertStoreOrderIdFromCheckout&&window.payxpertStoreOrderIdFromCheckout(e),"function"==typeof window.triggerPayxpertPaymentCall&&window.triggerPayxpertPaymentCall()})},[u]),r?.description&&s.push((0,n.jsx)("div",{dangerouslySetInnerHTML:{__html:(0,e.decodeEntities)(r.description)}},"description")),s.length>0?(0,n.jsx)(n.Fragment,{children:s}):""},p=e=>{const{PaymentMethodLabel:t}=e.components,o="cb.png";return c?r.icons.includes(o)||r.icons.push(o):r.icons=r.icons.filter(e=>e!==o),(0,n.jsxs)("span",{style:{width:"100%"},children:[(0,n.jsx)(t,{text:i}),(0,n.jsx)(l,{})]})},l=()=>Array.isArray(r.icons)&&0!==r.icons.length?(0,n.jsx)("span",{style:{float:"right"},children:r.icons.map((e,t)=>(0,n.jsx)("img",{src:`${r.icon_path}/${e}`,style:{marginLeft:"5px",verticalAlign:"middle"},alt:e},t))}):null;o({name:"payxpert_cc",label:(0,n.jsx)(p,{}),content:(0,n.jsx)(a,{}),edit:(0,n.jsx)(a,{}),canMakePayment:()=>!0,ariaLabel:i,supports:{features:r.supports}})})();