!function(e){var t={};function n(o){if(t[o])return t[o].exports;var r=t[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,o){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(n.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(o,r,function(t){return e[t]}.bind(null,r));return o},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=6)}([function(e,t){e.exports=window.wp.element},function(e,t){e.exports=window.wp.htmlEntities},function(e,t){e.exports=window.wc.wcBlocksRegistry},function(e,t){e.exports=window.wp.hooks},function(e,t){e.exports=window.wc.wcSettings},function(e,t){e.exports=window.React},function(e,t,n){"use strict";n.r(t);var o=n(0),r=n(2),c=n(1),i=n(3),a=n(4);function s({settings:e}){return Object(o.createElement)("div",{id:"wc_xpay-wrapper"},Object(o.createElement)("div",{id:"wc_xpay_widget"}),Object(o.createElement)("div",{id:"wc_xpay_payment-message",class:"hidden"}))}n(5);const{useEffect:l}=window.wp.element,p=Object(a.getSetting)("xpay_data",{}),u=Object(c.decodeEntities)(p.title)||"XPay",d=({eventRegistration:e,emitResponse:t})=>{const{onCheckoutSuccess:n,onCheckoutFail:r}=e;return l(()=>n(y),[n]),l(()=>r(f),[r]),Object(o.createElement)(o.Fragment,null,Object(c.decodeEntities)(p.description||""),Object(o.createElement)(s,{settings:p}))};function y(e){let t=JSON.parse(e.processingResponse.paymentDetails.xpay_data);try{let n=t.customer;window.WC_XPAY.confirmPayment("card",t.clientSecret,n,t.encryptionKey).then(e=>{console.log(e),0==e.error&&(-1===t.redirect.indexOf("https://")||-1===t.redirect.indexOf("http://")?window.location=t.redirect:window.location=decodeURI(t.redirect))}).catch(t=>{"object"==typeof t?(i.doAction("xpayBlockPaymentError",t,e),w(t.message)):w(t)})}catch(e){console.log(e)}}function f(e){return JSON.parse(e.processingResponse.paymentDetails.xpay_data),{message:e.processingResponse.paymentDetails.messages}}const m={name:"xpay",label:Object(o.createElement)(e=>{const{PaymentMethodLabel:t}=e.components;return Object(o.createElement)(t,{text:u})},null),content:Object(o.createElement)(d,null),edit:Object(o.createElement)(d,null),canMakePayment:()=>!0,paymentMethodId:"xpay",ariaLabel:u,supports:{features:p.supports}};async function w(e){const t=document.querySelector("#wc_xpay_payment-message");t.classList.remove("hidden"),t.textContent=e,t.innerHTML+='. <a class="xpay-try-again" style="cursor:pointer;color: red;" onClick="window.location.reload()">Retry</a>'}Object(r.registerPaymentMethod)(m)}]);