(()=>{"use strict";var e={20:(e,t,r)=>{var o=r(609),a=Symbol.for("react.element"),i=(Symbol.for("react.fragment"),Object.prototype.hasOwnProperty),c=o.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,n={key:!0,ref:!0,__self:!0,__source:!0};t.jsx=function(e,t,r){var o,s={},d=null,l=null;for(o in void 0!==r&&(d=""+r),void 0!==t.key&&(d=""+t.key),void 0!==t.ref&&(l=t.ref),t)i.call(t,o)&&!n.hasOwnProperty(o)&&(s[o]=t[o]);if(e&&e.defaultProps)for(o in t=e.defaultProps)void 0===s[o]&&(s[o]=t[o]);return{$$typeof:a,type:e,key:d,ref:l,props:s,_owner:c.current}}},848:(e,t,r)=>{e.exports=r(20)},609:e=>{e.exports=window.React}},t={};const r=window.wc.wcBlocksRegistry,o=window.wp.i18n,a=window.wc.wcSettings,i=window.wp.htmlEntities,c=window.wp.element,n=window.wc.blocksCheckout,s=window.wp.data,d=window.wc.wcBlocksData;var l=function r(o){var a=t[o];if(void 0!==a)return a.exports;var i=t[o]={exports:{}};return e[o](i,i.exports,r),i.exports}(848);const u=(0,a.getPaymentMethodData)("direct-debit",{}),_=(0,o.__)("Direct debit","woocommerce-germanized"),p=(0,i.decodeEntities)(u?.title||"")||_,w=e=>{const{PaymentMethodLabel:t}=e.components;return(0,l.jsx)(t,{text:p})},m=({billing:e,eventRegistration:t,emitResponse:r,components:a})=>{const{values:i}=(0,s.useSelect)(e=>({values:e(d.PAYMENT_STORE_KEY).getPaymentMethodData()}),[]),{__internalSetPaymentMethodData:u}=(0,s.useDispatch)(d.PAYMENT_STORE_KEY),{extensionData:_}=(0,s.useSelect)(e=>{const t=e(d.CHECKOUT_STORE_KEY).getExtensionData();return{extensionData:t.hasOwnProperty("woocommerce-germanized")?t["woocommerce-germanized"]:{}}}),p=[{key:"direct_debit_account_holder",label:(0,o.__)("Account holder","woocommerce-germanized"),type:"text",required:!0,errorMessage:"",autocomplete:"",autocapitalize:""},{key:"direct_debit_account_iban",label:(0,o.__)("IBAN","woocommerce-germanized"),type:"text",required:!0,errorMessage:"",autocomplete:"",autocapitalize:""},{key:"direct_debit_account_bic",label:(0,o.__)("BIC/SWIFT","woocommerce-germanized"),type:"text",required:!0,errorMessage:"",autocomplete:"",autocapitalize:""}],w=(0,c.useRef)({});return(0,l.jsx)("div",{className:"wc-gzd-direct-debit-fields",children:p.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}`},r=i.hasOwnProperty(e.key)?i[e.key]:"";return(0,l.jsx)(n.ValidatedTextInput,{ref:t=>w.current[e.key]=t,...t,value:r,onChange:t=>(u({...i,[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,o.__)("Please enter a valid BIC/SWIFT","woocommerce-germanized")),!1}else if("direct_debit_account_iban"===e.key){const e=function(e){let t,r=e.slice(0,2);for(let o=2;o<e.length;o+=7)t=String(r)+e.substring(o,o+7),r=parseInt(t,10)%97;return r},r={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},a=t.value.toUpperCase().replace(/[^A-Z0-9]/g,""),i=a.match(/^([A-Z]{2})(\d{2})([A-Z\d]+)$/);let c,n=!0;if(i&&a.length===r[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,o.__)("Please enter a valid IBAN","woocommerce-germanized")),!1}return!0}},e.key)})})},y={name:"direct-debit",label:(0,l.jsx)(w,{}),content:(0,l.jsx)(m,{}),edit:(0,l.jsx)(m,{}),canMakePayment:()=>!0,ariaLabel:p,supports:{features:u?.supports??[]}};(0,r.registerPaymentMethod)(y),((window.wcGzd=window.wcGzd||{}).blocks=window.wcGzd.blocks||{})["wc-gzd-payment-method-direct-debit"]={}})();