(()=>{"use strict";const e=window.wc.wcBlocksRegistry,t=window.wp.element;function n(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,a,i,c,o=[],l=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;l=!1}else for(;!(l=(r=i.call(n)).done)&&(o.push(r.value),o.length!==t);l=!0);}catch(e){s=!0,a=e}finally{try{if(!l&&null!=n.return&&(c=n.return(),Object(c)!==c))return}finally{if(s)throw a}}return o}}(e,t)||function(e,t){if(e){if("string"==typeof e)return r(e,t);var n={}.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(e,t):void 0}}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=Array(t);n<t;n++)r[n]=e[n];return r}var a=wc.wcSettings.getSetting("ppcp-pay-upon-invoice-gateway_data"),i="de"===a.siteLanguage,c=function(e){var r=e.eventRegistration,c=e.emitResponse,o=r.onPaymentSetup,l=n((0,t.useState)(""),2),s=l[0],u=l[1],p=n((0,t.useState)(""),2),m=p[0],d=p[1];(0,t.useEffect)(function(){var e=o(function(){return a.requiresBirthDate&&!s?{type:c.responseTypes.ERROR,message:i?"Bitte geben Sie Ihr Geburtsdatum ein.":"Please enter your birth date."}:{type:c.responseTypes.SUCCESS,meta:{paymentMethodData:{billing_birth_date:s,billing_phone:m}}}});return function(){return e()}},[o,c.responseTypes.SUCCESS,c.responseTypes.ERROR,s,m]);var y=i?a.ratepayTerms.de:a.ratepayTerms.en;return React.createElement("div",{className:"ppcp-pui-fields"},a.description&&React.createElement("div",{dangerouslySetInnerHTML:{__html:a.description}}),a.icon&&React.createElement("div",{className:"wc-block-components-payment-method-icons wc-block-components-payment-method-icons--align-right"},React.createElement("img",{className:"wc-block-components-payment-method-icon wc-block-components-payment-method-icon--".concat(a.id),src:a.icon,alt:a.title})),React.createElement("p",{className:"form-row form-row-wide"},React.createElement("label",{htmlFor:"ppcp-pui-birth-date"},i?"Geburtsdatum":"Birth date"),React.createElement("input",{type:"date",id:"ppcp-pui-birth-date",className:"input-text",value:s,onChange:function(e){return u(e.target.value)},required:!0})),a.requiresPhone&&React.createElement("p",{className:"form-row form-row-wide"},React.createElement("label",{htmlFor:"ppcp-pui-phone"},i?"Telefon":"Phone"),React.createElement("input",{type:"tel",id:"ppcp-pui-phone",className:"input-text",value:m,onChange:function(e){return d(e.target.value)},required:!0})),React.createElement("div",{className:"ppcp-pui-ratepay-terms",dangerouslySetInnerHTML:{__html:y}}))};(0,e.registerPaymentMethod)({name:a.id,label:React.createElement("div",{dangerouslySetInnerHTML:{__html:a.title}}),content:React.createElement(c,null),edit:React.createElement("div",null),ariaLabel:a.title,canMakePayment:function(){return!0},supports:{features:a.supports}})})();