!function(){"use strict";var e={};(function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})})(e);var t,a=window.React,o=window.wc.wcBlocksRegistry,r=window.wp.i18n,i=window.wc.wcSettings,c=window.wp.htmlEntities,n=window.wp.element,d=window.wc.blocksCheckout,l=window.wp.data,s=window.wc.wcBlocksData;const u=(0,i.getPaymentMethodData)("direct-debit",{}),m=(0,r.__)("Direct debit","woocommerce-germanized"),w=(0,c.decodeEntities)(u?.title||"")||m,p=({billing:e,eventRegistration:t,emitResponse:o,components:i})=>{const{values:c}=(0,l.useSelect)((e=>({values:e(s.PAYMENT_STORE_KEY).getPaymentMethodData()})),[]),{__internalSetPaymentMethodData:u}=(0,l.useDispatch)(s.PAYMENT_STORE_KEY),{extensionData:m}=(0,l.useSelect)((e=>{const t=e(s.CHECKOUT_STORE_KEY).getExtensionData();return{extensionData:t.hasOwnProperty("woocommerce-germanized")?t["woocommerce-germanized"]:{}}})),w=[{key:"direct_debit_account_holder",label:(0,r.__)("Account holder","woocommerce-germanized"),type:"text",required:!0,errorMessage:"",autocomplete:"",autocapitalize:""},{key:"direct_debit_account_iban",label:(0,r.__)("IBAN","woocommerce-germanized"),type:"text",required:!0,errorMessage:"",autocomplete:"",autocapitalize:""},{key:"direct_debit_account_bic",label:(0,r.__)("BIC/SWIFT","woocommerce-germanized"),type:"text",required:!0,errorMessage:"",autocomplete:"",autocapitalize:""}],p=(0,n.useRef)({});return(0,a.createElement)("div",{className:"wc-gzd-direct-debit-fields"},w.map((e=>{const t={id:`${e.key}`,errorId:`${e.key}`,label:e.required?e.label:e.optionalLabel,autoCapitalize:e.autocapitalize,autoComplete:e.autocomplete,errorMessage:e.errorMessage,required:e.required,className:`wc-gzd-direct-debit__${e.key}`},o=c.hasOwnProperty(e.key)?c[e.key]:"";return(0,a.createElement)(d.ValidatedTextInput,{key:e.key,ref:t=>p.current[e.key]=t,...t,value:o,onChange:t=>(u({...c,[e.key]:t}),t),customFormatter:t=>("direct_debit_account_bic"===e.key?t=(t=t.toUpperCase()).replace(/[^\w]/g,""):"direct_debit_account_iban"===e.key&&(t=(t=t.toUpperCase()).replace(/[^\w\s]/g,"")),t),customValidation:t=>{if("direct_debit_account_bic"===e.key){if(!/^([a-zA-Z]){4}([a-zA-Z]){2}([0-9a-zA-Z]){2}([0-9a-zA-Z]{3})?$/.test(t.value))return t.setCustomValidity((0,r.__)("Please enter a valid BIC/SWIFT","woocommerce-germanized")),!1}else if("direct_debit_account_iban"===e.key){const e=function(e){let t,a=e.slice(0,2);for(let o=2;o<e.length;o+=7)t=String(a)+e.substring(o,o+7),a=parseInt(t,10)%97;return a},a={AD:24,AE:23,AL:28,AT:20,AZ:28,BA:20,BE:16,BG:22,BH:22,BR:29,CH:21,CR:21,CY:28,CZ:24,DE:22,DK:18,DO:28,EE:20,ES:24,LC:30,FI:18,FO:18,FR:27,GB:22,GI:23,GL:18,GR:27,GT:28,HR:21,HU:28,IE:22,IL:23,IS:26,IT:27,JO:30,KW:30,KZ:20,LB:28,LI:21,LT:20,LU:20,LV:21,MC:27,MD:24,ME:22,MK:19,MR:27,MT:31,MU:30,NL:18,NO:15,PK:24,PL:28,PS:29,PT:25,QA:29,RO:24,RS:22,SA:24,SE:24,SI:19,SK:24,SM:27,TN:24,TR:26},o=t.value.toUpperCase().replace(/[^A-Z0-9]/g,""),i=o.match(/^([A-Z]{2})(\d{2})([A-Z\d]+)$/);let c,n=!0;if(i&&o.length===a[i[1]]?(c=(i[3]+i[1]+i[2]).replace(/[A-Z]/g,(e=>e.charCodeAt(0)-55)),n=1===e(c)):n=!1,!n)return t.setCustomValidity((0,r.__)("Please enter a valid IBAN","woocommerce-germanized")),!1}return!0}})})))},_={name:"direct-debit",label:(0,a.createElement)((e=>{const{PaymentMethodLabel:t}=e.components;return(0,a.createElement)(t,{text:w})}),null),content:(0,a.createElement)(p,null),edit:(0,a.createElement)(p,null),canMakePayment:()=>!0,ariaLabel:w,supports:{features:null!==(t=u?.supports)&&void 0!==t?t:[]}};(0,o.registerPaymentMethod)(_),((window.wcGzd=window.wcGzd||{}).blocks=window.wcGzd.blocks||{})["wc-gzd-payment-method-direct-debit"]=e}();