mirror of
https://gh.wpcy.net/https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2026-04-25 01:02:18 +08:00
1 line
No EOL
77 KiB
JavaScript
1 line
No EOL
77 KiB
JavaScript
(()=>{"use strict";var e={4744:e=>{var t=function(e){return function(e){return!!e&&"object"==typeof e}(e)&&!function(e){var t=Object.prototype.toString.call(e);return"[object RegExp]"===t||"[object Date]"===t||function(e){return e.$$typeof===n}(e)}(e)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(e,t){return!1!==t.clone&&t.isMergeableObject(e)?c((n=e,Array.isArray(n)?[]:{}),e,t):e;var n}function o(e,t,n){return e.concat(t).map(function(e){return r(e,n)})}function i(e){return Object.keys(e).concat(function(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(t){return Object.propertyIsEnumerable.call(e,t)}):[]}(e))}function a(e,t){try{return t in e}catch(e){return!1}}function c(e,n,u){(u=u||{}).arrayMerge=u.arrayMerge||o,u.isMergeableObject=u.isMergeableObject||t,u.cloneUnlessOtherwiseSpecified=r;var s=Array.isArray(n);return s===Array.isArray(e)?s?u.arrayMerge(e,n,u):function(e,t,n){var o={};return n.isMergeableObject(e)&&i(e).forEach(function(t){o[t]=r(e[t],n)}),i(t).forEach(function(i){(function(e,t){return a(e,t)&&!(Object.hasOwnProperty.call(e,t)&&Object.propertyIsEnumerable.call(e,t))})(e,i)||(a(e,i)&&n.isMergeableObject(t[i])?o[i]=function(e,t){if(!t.customMerge)return c;var n=t.customMerge(e);return"function"==typeof n?n:c}(i,n)(e[i],t[i],n):o[i]=r(t[i],n))}),o}(e,n,u):r(n,u)}c.all=function(e,t){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(e,n){return c(e,n,t)},{})};var u=c;e.exports=u}},t={};function n(r){var o=t[r];if(void 0!==o)return o.exports;var i=t[r]={exports:{}};return e[r](i,i.exports,n),i.exports}n.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return n.d(t,{a:t}),t},n.d=(e,t)=>{for(var r in t)n.o(t,r)&&!n.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t);const r=window.wp.element,o=window.wp.i18n,i=window.wc.wcBlocksRegistry,a=window.wp.data;function c(e){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},c(e)}function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,s(r.key),r)}}function s(e){var t=function(e){if("object"!=c(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=c(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==c(t)?t:t+""}var l=function(){return e=function e(t){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.namespace=t,this.connection=null,this.identity=null,this.profile=null,this.FastlaneCardComponent=null,this.FastlanePaymentComponent=null,this.FastlaneWatermarkComponent=null},(t=[{key:"connect",value:function(e){var t=this;return new Promise(function(n,r){window[t.namespace]?window[t.namespace].Fastlane(e).then(function(e){t.init(e),n()}).catch(function(e){console.error(e),r(e)}):r(new Error("Namespace ".concat(t.namespace," not found on window object")))})}},{key:"init",value:function(e){this.connection=e,this.identity=this.connection.identity,this.profile=this.connection.profile,this.FastlaneCardComponent=this.connection.FastlaneCardComponent,this.FastlanePaymentComponent=this.connection.FastlanePaymentComponent,this.FastlaneWatermarkComponent=this.connection.FastlaneWatermarkComponent}},{key:"setLocale",value:function(e){this.connection.setLocale(e)}}])&&u(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();const f=l;function d(e){var t,n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"info",i=null===(t=window.wc_ppcp_axo)||void 0===t?void 0:t.wp_debug,a=null===(n=window.wc_ppcp_axo)||void 0===n||null===(n=n.ajax)||void 0===n||null===(n=n.frontend_logger)||void 0===n?void 0:n.endpoint,c=null===(r=window.wc_ppcp_axo)||void 0===r?void 0:r.logging_enabled;if(i)switch(o){case"error":console.error("[AXO] ".concat(e));break;case"warn":console.warn("[AXO] ".concat(e));break;default:console.log("[AXO] ".concat(e))}a&&c&&fetch(a,{method:"POST",credentials:"same-origin",body:JSON.stringify({nonce:window.wc_ppcp_axo.ajax.frontend_logger.nonce,log:{message:e,level:o}})})}function p(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,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return y(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)?y(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 y(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}function m(e){return m="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},m(e)}var v=function(e){return"object"===m(e)&&null!==e},b=function(e){return v(e)?Object.fromEntries(Object.entries(e).map(function(e){var t=p(e,2),n=t[0],r=t[1];return[n,v(r)?b(r):r]}).filter(function(e){var t=p(e,2),n=(t[0],t[1]);return v(n)?Object.keys(n).length>0:function(e){return""!==e}(n)})):e};function h(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 g=["VISA","MASTERCARD","AMEX","DISCOVER"];const w=function(e){var t=e.merchant_country||"US";return(0,r.useMemo)(function(){var n,r,o=new Set((null===(n=e.allowed_cards)||void 0===n?void 0:n[t])||g),i=new Set((e.disable_cards||[]).map(function(e){return e.toUpperCase()}));return(r=o,function(e){if(Array.isArray(e))return h(e)}(r)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(r)||function(e,t){if(e){if("string"==typeof e)return h(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)?h(e,t):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).filter(function(e){return!i.has(e)})},[e.allowed_cards,e.disable_cards,t])};function S(e){return S="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},S(e)}function E(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function O(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?E(Object(n),!0).forEach(function(t){k(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function k(e,t,n){return(t=function(e){var t=function(e){if("object"!=S(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=S(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==S(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}var _="woocommerce-paypal-payments/axo-block",A={isPayPalLoaded:!1,isGuest:!0,isAxoActive:!1,isAxoScriptLoaded:!1,isEmailSubmitted:!1,isEmailLookupCompleted:!1,shippingAddress:null,cardDetails:null,phoneNumber:"",cardChangeHandler:null};if(!(0,a.select)(_)){var j=(0,a.createReduxStore)(_,{reducer:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:A,t=arguments.length>1?arguments[1]:void 0;switch(t.type){case"SET_IS_PAYPAL_LOADED":return O(O({},e),{},{isPayPalLoaded:t.payload});case"SET_IS_GUEST":return O(O({},e),{},{isGuest:t.payload});case"SET_IS_AXO_ACTIVE":return O(O({},e),{},{isAxoActive:t.payload});case"SET_IS_AXO_SCRIPT_LOADED":return O(O({},e),{},{isAxoScriptLoaded:t.payload});case"SET_IS_EMAIL_SUBMITTED":return O(O({},e),{},{isEmailSubmitted:t.payload});case"SET_IS_EMAIL_LOOKUP_COMPLETED":return O(O({},e),{},{isEmailLookupCompleted:t.payload});case"SET_SHIPPING_ADDRESS":return O(O({},e),{},{shippingAddress:t.payload});case"SET_CARD_DETAILS":return O(O({},e),{},{cardDetails:t.payload});case"SET_PHONE_NUMBER":return O(O({},e),{},{phoneNumber:t.payload});case"SET_CARD_CHANGE_HANDLER":return O(O({},e),{},{cardChangeHandler:t.payload});default:return e}},actions:{setIsPayPalLoaded:function(e){return{type:"SET_IS_PAYPAL_LOADED",payload:e}},setIsGuest:function(e){return{type:"SET_IS_GUEST",payload:e}},setIsAxoActive:function(e){return{type:"SET_IS_AXO_ACTIVE",payload:e}},setIsAxoScriptLoaded:function(e){return{type:"SET_IS_AXO_SCRIPT_LOADED",payload:e}},setIsEmailSubmitted:function(e){return{type:"SET_IS_EMAIL_SUBMITTED",payload:e}},setIsEmailLookupCompleted:function(e){return{type:"SET_IS_EMAIL_LOOKUP_COMPLETED",payload:e}},setShippingAddress:function(e){return{type:"SET_SHIPPING_ADDRESS",payload:e}},setCardDetails:function(e){return{type:"SET_CARD_DETAILS",payload:e}},setPhoneNumber:function(e){return{type:"SET_PHONE_NUMBER",payload:e}},setCardChangeHandler:function(e){return{type:"SET_CARD_CHANGE_HANDLER",payload:e}}},selectors:{getIsPayPalLoaded:function(e){return e.isPayPalLoaded},getIsGuest:function(e){return e.isGuest},getIsAxoActive:function(e){return e.isAxoActive},getIsAxoScriptLoaded:function(e){return e.isAxoScriptLoaded},getIsEmailSubmitted:function(e){return e.isEmailSubmitted},getIsEmailLookupCompleted:function(e){return e.isEmailLookupCompleted},getShippingAddress:function(e){return e.shippingAddress},getCardDetails:function(e){return e.cardDetails},getPhoneNumber:function(e){return e.phoneNumber},getCardChangeHandler:function(e){return e.cardChangeHandler}}});(0,a.register)(j)}var P=function(e){(0,a.dispatch)(_).setIsGuest(e)},C=function(e){(0,a.dispatch)(_).setIsEmailLookupCompleted(e)};function x(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return T(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(T(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,T(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,T(f,"constructor",s),T(s,"constructor",u),u.displayName="GeneratorFunction",T(s,o,"GeneratorFunction"),T(f),T(f,o,"Generator"),T(f,r,function(){return this}),T(f,"toString",function(){return"[object Generator]"}),(x=function(){return{w:i,m:d}})()}function T(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}T=function(e,t,n,r){function i(t,n){T(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},T(e,t,n,r)}function I(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function L(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}const N=function(e,t,n){var o,i,c=(o=(0,r.useState)(null),i=2,function(e){if(Array.isArray(e))return e}(o)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(o,i)||function(e,t){if(e){if("string"==typeof e)return L(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)?L(e,t):void 0}}(o,i)||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.")}()),u=c[0],s=c[1],l=(0,r.useRef)(!1),p=(0,r.useRef)({axoConfig:t,ppcpConfig:n}),y=(0,r.useCallback)(b,[]),m=(0,a.useSelect)(function(e){return{isPayPalLoaded:e(_).getIsPayPalLoaded()}},[]).isPayPalLoaded,v=w(t),h=(0,r.useMemo)(function(){return y(p.current.axoConfig.style_options)},[y]),g=function(e){return(0,r.useMemo)(function(){var t=e.enabled_shipping_locations||[];return Array.isArray(t)?t:[]},[e.enabled_shipping_locations])}(t);return(0,r.useEffect)(function(){var t=function(){var t,n=(t=x().m(function t(){var n,r;return x().w(function(t){for(;;)switch(t.p=t.n){case 0:if(!l.current&&!u&&m){t.n=1;break}return t.a(2);case 1:return l.current=!0,d("Init Fastlane"),t.p=2,n=new f(e),p.current.axoConfig.environment.is_sandbox&&window.localStorage.setItem("axoEnv","sandbox"),t.n=3,n.connect({locale:p.current.ppcpConfig.locale,styles:h,cardOptions:{allowedBrands:v},shippingAddressOptions:{allowedLocations:g}});case 3:n.setLocale("en_us"),s(n),t.n=5;break;case 4:t.p=4,r=t.v,d("Failed to initialize Fastlane: ".concat(r),"error");case 5:return t.p=5,l.current=!1,t.f(5);case 6:return t.a(2)}},t,null,[[2,4,5,6]])}),function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(e){I(i,r,o,a,c,"next",e)}function c(e){I(i,r,o,a,c,"throw",e)}a(void 0)})});return function(){return n.apply(this,arguments)}}();t()},[u,h,m,e,v,g]),(0,r.useEffect)(function(){p.current={axoConfig:t,ppcpConfig:n}},[t,n]),u},G=function(){var e=(0,a.useSelect)(function(e){return e("wc/store/cart").getCustomerData()}),t=(0,a.useDispatch)("wc/store/cart"),n=t.setShippingAddress,o=t.setBillingAddress,i=(0,r.useCallback)(function(e){n(e)},[n]),c=(0,r.useCallback)(function(e){o(e)},[o]);return(0,r.useMemo)(function(){return{shippingAddress:e.shippingAddress,billingAddress:e.billingAddress,setShippingAddress:i,setBillingAddress:c}},[e.shippingAddress,e.billingAddress,i,c])};function R(e,t){void 0===t&&(t={});var n=document.createElement("script");return n.src=e,Object.keys(t).forEach(function(e){n.setAttribute(e,t[e]),"data-csp-nonce"===e&&n.setAttribute("nonce",t["data-csp-nonce"])}),n}function D(e,t){if(void 0===t&&(t=Promise),M(e,t),"undefined"==typeof document)return t.resolve(null);var n=function(e){var t,n,r=e.sdkBaseUrl,o=e.environment,i=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["sdkBaseUrl","environment"]),a=r||function(e){return"sandbox"===e?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}(o),c=i,u=Object.keys(c).filter(function(e){return void 0!==c[e]&&null!==c[e]&&""!==c[e]}).reduce(function(e,t){var n,r=c[t].toString();return n=function(e,t){return(t?"-":"")+e.toLowerCase()},"data"===(t=t.replace(/[A-Z]+(?![a-z])|[A-Z]/g,n)).substring(0,4)||"crossorigin"===t?e.attributes[t]=r:e.queryParams[t]=r,e},{queryParams:{},attributes:{}}),s=u.queryParams,l=u.attributes;return s["merchant-id"]&&-1!==s["merchant-id"].indexOf(",")&&(l["data-merchant-id"]=s["merchant-id"],s["merchant-id"]="*"),{url:"".concat(a,"?").concat((t=s,n="",Object.keys(t).forEach(function(e){0!==n.length&&(n+="&"),n+=e+"="+t[e]}),n)),attributes:l}}(e),r=n.url,o=n.attributes,i=o["data-namespace"]||"paypal",a=F(i);return o["data-js-sdk-library"]||(o["data-js-sdk-library"]="paypal-js"),function(e,t){var n=document.querySelector('script[src="'.concat(e,'"]'));if(null===n)return null;var r=R(e,t),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach(function(e){o.dataset[e]!==r.dataset[e]&&(i=!1)}),i?n:null}(r,o)&&a?t.resolve(a):function(e,t){void 0===t&&(t=Promise),M(e,t);var n=e.url,r=e.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new t(function(e,t){if("undefined"==typeof document)return e();!function(e){var t=e.onSuccess,n=e.onError,r=R(e.url,e.attributes);r.onerror=n,r.onload=t,document.head.insertBefore(r,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return e()},onError:function(){var e=new Error('The script "'.concat(n,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return t(e)}})})}({url:r,attributes:o},t).then(function(){var e=F(i);if(e)return e;throw new Error("The window.".concat(i," global variable is not available."))})}function F(e){return window[e]}function M(e,t){if("object"!=typeof e||null===e)throw new Error("Expected an options object.");var n=e.environment;if(n&&"production"!==n&&"sandbox"!==n)throw new Error('The `environment` option must be either "production" or "sandbox".');if(void 0!==t&&"function"!=typeof t)throw new Error("Expected PromisePonyfill to be a function.")}function B(e){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},B(e)}function U(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,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,t)||q(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 H(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=q(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var _n=0,r=function(){};return{s:r,n:function(){return _n>=e.length?{done:!0}:{done:!1,value:e[_n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,i=!0,a=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){a=!0,o=e},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function q(e,t){if(e){if("string"==typeof e)return W(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)?W(e,t):void 0}}function W(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}function J(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,X(r.key),r)}}function X(e){var t=function(e){if("object"!=B(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=B(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==B(t)?t:t+""}"function"==typeof SuppressedError&&SuppressedError;var $=function(){return e=function e(){var t=this;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this.paypal=null,this.buttons=new Map,this.messages=new Map,this.renderEventName="ppcp-render",document.ppcpWidgetBuilderStatus=function(){console.log({buttons:t.buttons,messages:t.messages})},jQuery(document).off(this.renderEventName).on(this.renderEventName,function(){t.renderAll()})},(t=[{key:"setPaypal",value:function(e){this.paypal=e,jQuery(document).trigger("ppcp-paypal-loaded",e)}},{key:"registerButtons",value:function(e,t){e=this.sanitizeWrapper(e),this.buttons.set(this.toKey(e),{wrapper:e,options:t})}},{key:"renderButtons",value:function(e){e=this.sanitizeWrapper(e);var t=this.toKey(e);if(this.buttons.has(t)&&!this.hasRendered(e)){var n=this.buttons.get(t),r=this.paypal.Buttons(n.options);if(r.isEligible()){var o=this.buildWrapperTarget(e);o&&(r.hasReturned()?r.resume():r.render(o))}else this.buttons.delete(t)}}},{key:"renderAllButtons",value:function(){var e,t=H(this.buttons);try{for(t.s();!(e=t.n()).done;){var n=U(e.value,1)[0];this.renderButtons(n)}}catch(e){t.e(e)}finally{t.f()}}},{key:"registerMessages",value:function(e,t){this.messages.set(e,{wrapper:e,options:t})}},{key:"renderMessages",value:function(e){var t=this;if(this.messages.has(e)){var n=this.messages.get(e);if(this.hasRendered(e))document.querySelector(e).setAttribute("data-pp-amount",n.options.amount);else{var r=this.paypal.Messages(n.options);r.render(n.wrapper),setTimeout(function(){t.hasRendered(e)||r.render(n.wrapper)},100)}}}},{key:"renderAllMessages",value:function(){var e,t=H(this.messages);try{for(t.s();!(e=t.n()).done;){var n=U(e.value,2),r=n[0];n[1],this.renderMessages(r)}}catch(e){t.e(e)}finally{t.f()}}},{key:"renderAll",value:function(){this.renderAllButtons(),this.renderAllMessages()}},{key:"hasRendered",value:function(e){var t=e;if(Array.isArray(e)){t=e[0];var n,r=H(e.slice(1));try{for(r.s();!(n=r.n()).done;)t+=" .item-"+n.value}catch(e){r.e(e)}finally{r.f()}}var o=document.querySelector(t);return o&&o.hasChildNodes()}},{key:"sanitizeWrapper",value:function(e){return Array.isArray(e)&&1===(e=e.filter(function(e){return!!e})).length&&(e=e[0]),e}},{key:"buildWrapperTarget",value:function(e){var t=e;if(Array.isArray(e)){var n=jQuery(e[0]);if(!n.length)return;var r="item-"+e[1],o=n.find("."+r);o.length||(o=jQuery('<div class="'.concat(r,'"></div>')),n.append(o)),t=o.get(0)}return jQuery(t).length?t:null}},{key:"toKey",value:function(e){return Array.isArray(e)?JSON.stringify(e):e}}])&&J(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,t}();window.widgetBuilder=window.widgetBuilder||new $;const z=window.widgetBuilder;var K=n(4744),V=n.n(K),Q=function(e){return e.replace(/([-_]\w)/g,function(e){return e[1].toUpperCase()})},Y=function(e){var t=function(e){var t={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[Q(n)]=e[n]);return t}(e.url_params);e.script_attributes&&(t=V()(t,e.script_attributes));var n=function(e){var t,n,r=null==e||null===(t=e.save_payment_methods)||void 0===t?void 0:t.id_token;return r&&!0===(null==e||null===(n=e.user)||void 0===n?void 0:n.is_logged)?{"data-user-id-token":r}:{}}(e);return V().all([t,n])};function Z(e){return Z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Z(e)}function ee(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return te(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(te(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,te(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,te(f,"constructor",s),te(s,"constructor",u),u.displayName="GeneratorFunction",te(s,o,"GeneratorFunction"),te(f),te(f,o,"Generator"),te(f,r,function(){return this}),te(f,"toString",function(){return"[object Generator]"}),(ee=function(){return{w:i,m:d}})()}function te(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}te=function(e,t,n,r){function i(t,n){te(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},te(e,t,n,r)}function ne(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function re(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?ne(Object(n),!0).forEach(function(t){oe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ne(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function oe(e,t,n){return(t=function(e){var t=function(e){if("object"!=Z(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=Z(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==Z(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ie(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}var ae=new Map,ce=new Map,ue=function(){var e,t=(e=ee().m(function e(t,n){var r,o;return ee().w(function(e){for(;;)switch(e.n){case 0:if(t){e.n=1;break}throw new Error("Namespace is required");case 1:if(!ae.has(t)){e.n=2;break}return console.log("Script already loaded for namespace: ".concat(t)),e.a(2,ae.get(t));case 2:if(!ce.has(t)){e.n=3;break}return console.log("Script loading in progress for namespace: ".concat(t)),e.a(2,ce.get(t));case 3:return r=re(re({},Y(n)),{},{"data-namespace":t}),o=new Promise(function(e,n){D(r).then(function(n){z.setPaypal(n),ae.set(t,n),console.log("Script loaded for namespace: ".concat(t)),e(n)}).catch(function(e){console.error("Failed to load script for namespace: ".concat(t),e),n(e)}).finally(function(){ce.delete(t)})}),ce.set(t,o),e.a(2,o)}},e)}),function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ie(i,r,o,a,c,"next",e)}function c(e){ie(i,r,o,a,c,"throw",e)}a(void 0)})});return function(_x,e){return t.apply(this,arguments)}}();function se(e){return se="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},se(e)}function le(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return fe(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(fe(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,fe(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,fe(f,"constructor",s),fe(s,"constructor",u),u.displayName="GeneratorFunction",fe(s,o,"GeneratorFunction"),fe(f),fe(f,o,"Generator"),fe(f,r,function(){return this}),fe(f,"toString",function(){return"[object Generator]"}),(le=function(){return{w:i,m:d}})()}function fe(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}fe=function(e,t,n,r){function i(t,n){fe(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},fe(e,t,n,r)}function de(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function pe(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?de(Object(n),!0).forEach(function(t){ye(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):de(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ye(e,t,n){return(t=function(e){var t=function(e){if("object"!=se(e)||!e)return e;var t=e[Symbol.toPrimitive];if(void 0!==t){var n=t.call(e,"string");if("object"!=se(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"==se(t)?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function me(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function ve(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return be(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(be(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,be(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,be(f,"constructor",s),be(s,"constructor",u),u.displayName="GeneratorFunction",be(s,o,"GeneratorFunction"),be(f),be(f,o,"Generator"),be(f,r,function(){return this}),be(f,"toString",function(){return"[object Generator]"}),(ve=function(){return{w:i,m:d}})()}function be(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}be=function(e,t,n,r){function i(t,n){be(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},be(e,t,n,r)}function he(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}const ge=function(e){var t=e.fastlaneSdk,n=e.name,o=void 0===n?"fastlane-watermark-container":n,i=e.includeAdditionalInfo,a=void 0===i||i,c=(0,r.useRef)(null),u=(0,r.useRef)(null);return(0,r.useEffect)(function(){var e=function(){var e,n=(e=ve().m(function e(){var n,r;return ve().w(function(e){for(;;)switch(e.p=e.n){case 0:if(c.current){e.n=1;break}return e.a(2);case 1:return c.current.innerHTML="",e.p=2,e.n=3,t.FastlaneWatermarkComponent({includeAdditionalInfo:a});case 3:n=e.v,u.current=n,n.render("#".concat(o)),e.n=5;break;case 4:e.p=4,r=e.v,d("Error rendering watermark: ".concat(r),"error");case 5:return e.a(2)}},e,null,[[2,4]])}),function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){he(i,r,o,a,c,"next",e)}function c(e){he(i,r,o,a,c,"throw",e)}a(void 0)})});return function(){return n.apply(this,arguments)}}();return e(),function(){c.current&&(c.current.innerHTML="")}},[t,o,a]),React.createElement("div",{id:o,ref:c})};var we={container:null,root:null},Se=function(){if(we.root&&we.root.unmount(),we.container)if(we.container.parentNode)we.container.parentNode.removeChild(we.container);else{var e=document.querySelector(".wc-block-checkout-axo-block-watermark-container");e&&e.remove()}Object.assign(we,{container:null,root:null})};const Ee=function(e){var t=e.fastlaneSdk,n=(0,a.useSelect)(function(e){return e(_).getIsAxoActive()}),o=(0,a.useSelect)(function(e){return e(_).getIsAxoScriptLoaded()}),i=window.wc_ppcp_axo;return(0,r.useEffect)(function(){if("1"===(null==i?void 0:i.show_watermark))return n||!n&&!o?(function(){var e=document.querySelector(".wp-block-woocommerce-checkout-contact-information-block .wc-block-components-text-input");if(e&&!we.container){var t=e.querySelector('input[id="email"]');if(t){we.container=document.createElement("div"),we.container.setAttribute("class","wc-block-checkout-axo-block-watermark-container");var n=e.querySelector(".wc-block-axo-email-submit-button-container")||t;n.parentNode.insertBefore(we.container,n.nextSibling),we.root=(0,r.createRoot)(we.container)}}}(),function(e){var t,n=e.isAxoActive,o=e.fastlaneSdk;t=n||e.isAxoScriptLoaded?n?(0,r.createElement)(ge,{fastlaneSdk:o,name:"fastlane-watermark-email",includeAdditionalInfo:!0}):null:(0,r.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"}),we.root&&we.root.render(t)}({isAxoActive:n,isAxoScriptLoaded:o,fastlaneSdk:t})):Se(),Se},[t,n,o]),null},Oe=function(e){var t=e.handleSubmit,n=(0,a.useSelect)(function(e){return{isGuest:e(_).getIsGuest(),isAxoActive:e(_).getIsAxoActive(),isEmailSubmitted:e(_).getIsEmailSubmitted()}}),r=n.isGuest,i=n.isAxoActive,c=n.isEmailSubmitted;return r&&i?React.createElement("button",{type:"button",onClick:t,className:"wc-block-components-button wp-element-button ".concat(c?"is-loading":""),disabled:c},React.createElement("span",{className:"wc-block-components-button__text",style:{visibility:c?"hidden":"visible"}},(0,o.__)("Continue","woocommerce-paypal-payments")),c&&React.createElement("span",{className:"wc-block-components-spinner","aria-hidden":"true",style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)"}})):null};function ke(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return _e(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(_e(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,_e(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,_e(f,"constructor",s),_e(s,"constructor",u),u.displayName="GeneratorFunction",_e(s,o,"GeneratorFunction"),_e(f),_e(f,o,"Generator"),_e(f,r,function(){return this}),_e(f,"toString",function(){return"[object Generator]"}),(ke=function(){return{w:i,m:d}})()}function _e(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}_e=function(e,t,n,r){function i(t,n){_e(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},_e(e,t,n,r)}function Ae(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}var je=null,Pe={container:null,root:null,unsubscribe:null},Ce=null,xe=function(){return je||(je=document.getElementById("email")),je},Te=function(e,t){e&&t||d("Shipping or billing address is missing: ".concat(JSON.stringify({shippingAddress:e,billingAddress:t})),"warn");var n={shippingAddress:e,billingAddress:t};d("Snapshot data: ".concat(JSON.stringify(n)));try{localStorage.setItem("axoOriginalCheckoutFields",JSON.stringify(n))}catch(e){d("Error saving to localStorage: ".concat(e),"error")}},Ie=function(e,t,n){d("Populating WooCommerce fields with profile data: ".concat(JSON.stringify(e)));var r=(0,a.dispatch)("wc/store/checkout");"function"==typeof r.__internalSetUseShippingAsBilling&&r.__internalSetUseShippingAsBilling(!1);var o=e.shippingAddress,i=o.address,c=o.name,u=o.phoneNumber,s={first_name:c.firstName,last_name:c.lastName,address_1:i.addressLine1,address_2:i.addressLine2||"",city:i.adminArea2,state:i.adminArea1||"",postcode:i.postalCode,country:i.countryCode,phone:u.nationalNumber};d("Setting WooCommerce shipping address: ".concat(JSON.stringify(s))),t(s);var l=e.card.paymentSource.card.billingAddress,f={first_name:e.name.firstName,last_name:e.name.lastName,address_1:l.addressLine1,address_2:l.addressLine2||"",city:l.adminArea2,state:l.adminArea1,postcode:l.postalCode,country:l.countryCode};d("Setting WooCommerce billing address: ".concat(JSON.stringify(f))),n(f),"function"==typeof r.setEditingShippingAddress&&r.setEditingShippingAddress(!1),"function"==typeof r.setEditingBillingAddress&&r.setEditingBillingAddress(!1)};const Le=function(e){var t=e.onChangeShippingAddressClick;return React.createElement("a",{className:"wc-block-axo-change-link",role:"button",onClick:function(e){e.preventDefault(),t()}},(0,o.__)("Choose a different shipping address","woocommerce-paypal-payments"))},Ne=function(e){var t=e.onChangeShippingAddressClick;return(0,r.useEffect)(function(){var e=document.querySelector("#shipping-fields .wc-block-components-checkout-step__heading");if(e&&!e.querySelector(".wc-block-checkout-axo-block-card__edit")){var n=document.createElement("span");n.className="wc-block-checkout-axo-block-card__edit",e.appendChild(n);var o=(0,r.createRoot)(n);return o.render(React.createElement(Le,{onChangeShippingAddressClick:t})),function(){o.unmount(),n.remove()}}},[t]),null};var Ge=function(e){if(!document.querySelector("#shipping-fields .wc-block-checkout-axo-block-card__edit")){var t=document.createElement("div");document.body.appendChild(t),(0,r.createRoot)(t).render(React.createElement(Ne,{onChangeShippingAddressClick:e}))}};function Re(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return De(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(De(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,De(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,De(f,"constructor",s),De(s,"constructor",u),u.displayName="GeneratorFunction",De(s,o,"GeneratorFunction"),De(f),De(f,o,"Generator"),De(f,r,function(){return this}),De(f,"toString",function(){return"[object Generator]"}),(Re=function(){return{w:i,m:d}})()}function De(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}De=function(e,t,n,r){function i(t,n){De(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},De(e,t,n,r)}function Fe(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}var Me=function(e,t){d("Update the phone prefill value: ".concat(t)),e.updatePrefills({phoneNumber:t})};var Be="wc/store/checkout",Ue=function(){var e=(0,a.useSelect)(function(e){var t=e(Be);return{isEditingShippingAddress:!t.getEditingShippingAddress||t.getEditingShippingAddress(),isEditingBillingAddress:!t.getEditingBillingAddress||t.getEditingBillingAddress()}},[]),t=e.isEditingShippingAddress,n=e.isEditingBillingAddress,o=(0,a.useDispatch)(Be),i=o.setEditingShippingAddress,c=o.setEditingBillingAddress;return{isEditingShippingAddress:t,isEditingBillingAddress:n,setShippingAddressEditing:(0,r.useCallback)(function(e){"function"==typeof i&&i(e)},[i]),setBillingAddressEditing:(0,r.useCallback)(function(e){"function"==typeof c&&c(e)},[c])}};function He(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return qe(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(qe(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,qe(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,qe(f,"constructor",s),qe(s,"constructor",u),u.displayName="GeneratorFunction",qe(s,o,"GeneratorFunction"),qe(f),qe(f,o,"Generator"),qe(f,r,function(){return this}),qe(f,"toString",function(){return"[object Generator]"}),(He=function(){return{w:i,m:d}})()}function qe(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}qe=function(e,t,n,r){function i(t,n){qe(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},qe(e,t,n,r)}function We(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function Je(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){We(i,r,o,a,c,"next",e)}function c(e){We(i,r,o,a,c,"throw",e)}a(void 0)})}}function Xe(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return $e(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):($e(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,$e(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,$e(f,"constructor",s),$e(s,"constructor",u),u.displayName="GeneratorFunction",$e(s,o,"GeneratorFunction"),$e(f),$e(f,o,"Generator"),$e(f,r,function(){return this}),$e(f,"toString",function(){return"[object Generator]"}),(Xe=function(){return{w:i,m:d}})()}function $e(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}$e=function(e,t,n,r){function i(t,n){$e(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},$e(e,t,n,r)}function ze(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function Ke(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ze(i,r,o,a,c,"next",e)}function c(e){ze(i,r,o,a,c,"throw",e)}a(void 0)})}}function Ve(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return Qe(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(Qe(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,Qe(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,Qe(f,"constructor",s),Qe(s,"constructor",u),u.displayName="GeneratorFunction",Qe(s,o,"GeneratorFunction"),Qe(f),Qe(f,o,"Generator"),Qe(f,r,function(){return this}),Qe(f,"toString",function(){return"[object Generator]"}),(Ve=function(){return{w:i,m:d}})()}function Qe(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}Qe=function(e,t,n,r){function i(t,n){Qe(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},Qe(e,t,n,r)}function Ye(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}const Ze=function(e,t,n,o,i){var c=(0,a.useDispatch)(_),u=c.setIsAxoActive,s=c.setIsAxoScriptLoaded,l=c.setShippingAddress,f=c.setCardDetails,p=c.setCardChangeHandler,y=function(e,t,n){var o=(0,a.useDispatch)(_).setIsPayPalLoaded,i=(0,a.useSelect)(function(e){return{isPayPalLoaded:e(_).getIsPayPalLoaded()}},[]).isPayPalLoaded;return(0,r.useEffect)(function(){var r=function(){var r,a=(r=le().m(function r(){var a,c,u,s;return le().w(function(r){for(;;)switch(r.p=r.n){case 0:if(i||!n){r.n=7;break}return a=window.wc_ppcp_axo,r.p=1,r.n=2,fetch(a.ajax.axo_script_attributes.endpoint,{method:"POST",credentials:"same-origin",body:JSON.stringify({nonce:a.ajax.axo_script_attributes.nonce})});case 2:return c=r.v,r.n=3,c.json();case 3:if((u=r.v).success){r.n=4;break}return d("Failed to load axo script attributes: ".concat(u.data.message),"error"),r.a(2);case 4:return r.n=5,ue(e,pe(pe({},t),{},{script_attributes:pe(pe({},t.script_attributes),{},{"data-sdk-client-token":u.data.sdk_client_token})}));case 5:o(!0),r.n=7;break;case 6:r.p=6,s=r.v,d("Error loading PayPal script for namespace: ".concat(e,". Error: ").concat(s),"error");case 7:return r.a(2)}},r,null,[[1,6]])}),function(){var e=this,t=arguments;return new Promise(function(n,o){var i=r.apply(e,t);function a(e){me(i,n,o,a,c,"next",e)}function c(e){me(i,n,o,a,c,"throw",e)}a(void 0)})});return function(){return a.apply(this,arguments)}}();r()},[t,n,i]),i}(e,t,n),m=function(e){var t=Ue().setBillingAddressEditing,n=G().setBillingAddress,o=(0,a.useDispatch)(_).setCardDetails;return(0,r.useCallback)(Ke(Xe().m(function r(){var i,a,c,u,s,l,f,p,y,m,v;return Xe().w(function(r){for(;;)switch(r.n){case 0:if(!e){r.n=4;break}return r.n=1,e.profile.showCardSelector();case 1:if(a=r.v,c=a.selectionChanged,u=a.selectedCard,!c||null==u||null===(i=u.paymentSource)||void 0===i||!i.card){r.n=3;break}return s=u.paymentSource.card,l=s.name,f=s.billingAddress,p="",y="",l&&(m=l.split(" "),p=m[0],y=m.slice(1).join(" ")),v={first_name:p,last_name:y,address_1:(null==f?void 0:f.addressLine1)||"",address_2:(null==f?void 0:f.addressLine2)||"",city:(null==f?void 0:f.adminArea2)||"",state:(null==f?void 0:f.adminArea1)||"",postcode:(null==f?void 0:f.postalCode)||"",country:(null==f?void 0:f.countryCode)||""},r.n=2,Promise.all([new Promise(function(e){o(u),e()}),new Promise(function(e){n(v),e()}),new Promise(function(e){t(!1),e()})]);case 2:r.n=4;break;case 3:d("Selected card or billing address is missing.","error");case 4:return r.a(2)}},r)})),[e,o,n,t])}(o),v=function(e,t){var n=Ue().setShippingAddressEditing,o=G().setShippingAddress;return(0,r.useCallback)(Je(He().m(function r(){var i,a,c,u,s,l,f;return He().w(function(r){for(;;)switch(r.n){case 0:if(!e){r.n=3;break}return r.n=1,e.profile.showShippingAddressSelector();case 1:if(i=r.v,a=i.selectionChanged,c=i.selectedAddress,!a){r.n=3;break}return t(c),u=c.address,s=c.name,l=c.phoneNumber,f={first_name:s.firstName,last_name:s.lastName,address_1:u.addressLine1,address_2:u.addressLine2||"",city:u.adminArea2,state:u.adminArea1||"",postcode:u.postalCode,country:u.countryCode,phone:l.nationalNumber},r.n=2,new Promise(function(e){o(f),e()});case 2:return r.n=3,new Promise(function(e){n(!1),e()});case 3:return r.a(2)}},r)})),[e,t,o,n])}(o,l),b=G(),h=b.shippingAddress,g=b.billingAddress,w=b.setShippingAddress,S=b.setBillingAddress;return function(e){var t,n,o,i,c,u=(0,a.useDispatch)(_).setPhoneNumber,s=(0,a.useSelect)(function(e){return{phoneNumber:e(_).getPhoneNumber()}}).phoneNumber,l=G(),f=l.shippingAddress,d=l.billingAddress,p=(0,r.useRef)((t=Me,n={timeoutId:null,args:null},o=function(){n.timeoutId&&window.clearTimeout(n.timeoutId),n.timeoutId=null,n.args=null},i=function(){n.timeoutId&&(t.apply(null,n.args||[]),o())},c=function(){o();for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];n.args=t,n.timeoutId=window.setTimeout(i,250)},c.cancel=o,c.flush=i,c)).current,y=(0,r.useCallback)(function(){var e=(null==d?void 0:d.phone)||"",t=(null==f?void 0:f.phone)||"",n=function(){var e=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:"").replace(/^\+?[01]+/,"").replace(/[^0-9]/g,"");return 10===e.length?e:""}(e||t);n&&n!==s&&u(n)},[d,f,s,u]);(0,r.useEffect)(function(){y()},[y]),(0,r.useEffect)(function(){e&&s&&p(e,s)},[p,e,s]),(0,r.useEffect)(function(){return function(){null!=p&&p.cancel&&p.cancel()}},[p])}(i),function(e){var t=(0,a.useDispatch)(_),n=t.setShippingAddress,o=t.setCardDetails,i=t.setIsGuest,c=(0,r.useRef)(!1);(0,r.useEffect)(function(){if(e&&!c.current){var t=new URLSearchParams(window.location.search);if("1"===t.get("ppcp_fastlane_error")){t.delete("ppcp_fastlane_error");var r=new URL(window.location);r.search=t.toString(),window.history.replaceState({},"",r),c.current=!0;var a=function(){var t,r=(t=Ve().m(function t(){var r,a,c,u,s;return Ve().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,null==(r=document.getElementById("email"))||!r.value){t.n=3;break}return t.n=1,e.identity.lookupCustomerByEmail(r.value);case 1:if(a=t.v,wp.data.dispatch(_).setIsEmailSubmitted(!0),null==a||!a.customerContextId){t.n=3;break}return c=a.customerContextId,t.n=2,e.identity.triggerAuthenticationFlow(c);case 2:"succeeded"===(null==(u=t.v)?void 0:u.authenticationState)&&(s=u.profileData,i(!1),null!=s&&s.shippingAddress&&n(s.shippingAddress),null!=s&&s.card&&o(s.card),C(!0));case 3:t.n=5;break;case 4:t.p=4,t.v,d("Failed to restore Fastlane session","warn");case 5:return t.a(2)}},t,null,[[0,4]])}),function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(e){Ye(i,r,o,a,c,"next",e)}function c(e){Ye(i,r,o,a,c,"throw",e)}a(void 0)})});return function(){return r.apply(this,arguments)}}();a()}}},[e,n,o,i])}(o),(0,r.useEffect)(function(){var e,t,n;e=".wc-block-components-express-payment--checkout, .wp-block-woocommerce-checkout-express-payment-block",t="wc-block-axo-is-authenticated",(n=function(){var n=document.querySelector(e);n?(0,a.select)(_).getIsGuest()?n.classList.remove(t):n.classList.add(t):d("Authentication class target element not found: ".concat(e),"warn")})(),(0,a.subscribe)(function(){n()}),function(){var e=".wp-block-woocommerce-checkout-fields-block",t="wc-block-axo-email-lookup-completed",n=function(){var n=document.querySelector(e);n?(0,a.select)(_).getIsEmailLookupCompleted()?n.classList.add(t):n.classList.remove(t):d("Email lookup completed class target element not found: ".concat(e),"warn")};n(),(0,a.subscribe)(function(){n()})}(),function(){var e=".wp-block-woocommerce-checkout-fields-block",t="wc-block-axo-is-loaded",n="wc-block-axo-is-authenticated",r="wc-block-axo-email-lookup-completed",o=function(){var o=document.querySelector(e);if(o){var i=(0,a.select)(_).getIsAxoActive(),c=(0,a.select)(_).getIsGuest(),u=(0,a.select)(_).getIsEmailLookupCompleted();i?o.classList.add(t):o.classList.remove(t),c?o.classList.remove(n):o.classList.add(n),u?o.classList.add(r):o.classList.remove(r)}else d("Checkout block class target element not found: ".concat(e),"warn")};o(),(0,a.subscribe)(function(){o()})}()},[]),(0,r.useEffect)(function(){if(function(e){var t=document.createElement("div");document.body.appendChild(t),(0,r.createRoot)(t).render((0,r.createElement)(Ee,{fastlaneSdk:e}))}(o),y&&o){s(!0),u(!0),p(m);var e=function(e,t,n,r,o,i,a,c,u){return function(){var s,l=(s=Re().m(function s(l){var f,p,y,m,v;return Re().w(function(s){for(;;)switch(s.p=s.n){case 0:if(s.p=0,d("Email value being looked up: ".concat(l)),e){s.n=1;break}throw new Error("FastlaneSDK is not initialized");case 1:if(e.identity){s.n=2;break}throw new Error("FastlaneSDK identity object is not available");case 2:return s.n=3,e.identity.lookupCustomerByEmail(l);case 3:if(f=s.v,d("Lookup response: ".concat(JSON.stringify(f))),f&&""===f.customerContextId&&C(!0),f&&f.customerContextId){s.n=4;break}return d("No customerContextId found in the response","warn"),s.a(2);case 4:return s.n=5,e.identity.triggerAuthenticationFlow(f.customerContextId);case 5:if((p=s.v)&&p.authenticationState){s.n=6;break}throw new Error("Invalid authentication response");case 6:y=p.authenticationState,m=p.profileData,p&&C(!0),"succeeded"===y?(r(o,i),P(!1),m&&m.shippingAddress&&t(m.shippingAddress),m&&m.card&&n(m.card),d("Profile Data: ".concat(JSON.stringify(m))),Ie(m,a,c),Ge(u)):d("Authentication failed or did not succeed","warn"),s.n=8;break;case 7:throw s.p=7,v=s.v,d("Error during email lookup or authentication:\n\t\t\t\t".concat(v)),v;case 8:return s.a(2)}},s,null,[[0,7]])}),function(){var e=this,t=arguments;return new Promise(function(n,r){var o=s.apply(e,t);function i(e){Fe(o,n,r,i,a,"next",e)}function a(e){Fe(o,n,r,i,a,"throw",e)}i(void 0)})});return function(_x){return l.apply(this,arguments)}}()}(o,l,f,Te,h,g,w,S,v);!function(e){var t=xe();if(t){var n=function(){var n,r=(n=ke().m(function n(){var r;return ke().w(function(n){for(;;)switch(n.p=n.n){case 0:if(!wp.data.select(_).getIsEmailSubmitted()&&t.value){n.n=1;break}return n.a(2);case 1:return wp.data.dispatch(_).setIsEmailSubmitted(!0),o(),n.p=2,n.n=3,e(t.value);case 3:n.n=5;break;case 4:n.p=4,r=n.v,d("Error during email submission: ".concat(r),"error");case 5:return n.p=5,wp.data.dispatch(_).setIsEmailSubmitted(!1),o(),n.f(5);case 6:return n.a(2)}},n,null,[[2,4,5,6]])}),function(){var e=this,t=arguments;return new Promise(function(r,o){var i=n.apply(e,t);function a(e){Ae(i,r,o,a,c,"next",e)}function c(e){Ae(i,r,o,a,c,"throw",e)}a(void 0)})});return function(){return r.apply(this,arguments)}}();Ce=function(e){var t=wp.data.select(_).getIsAxoActive();"Enter"===e.key&&t&&(e.preventDefault(),n())},t.addEventListener("keydown",Ce),Pe.container||(Pe.container=document.createElement("div"),Pe.container.setAttribute("class","wc-block-axo-email-submit-button-container"),t.parentNode.insertBefore(Pe.container,t.nextSibling),Pe.root=(0,r.createRoot)(Pe.container));var o=function(){Pe.root&&Pe.root.render((0,r.createElement)(Oe,{handleSubmit:n}))};o(),Pe.unsubscribe=wp.data.subscribe(function(){o()})}else d("Email input element not found. Functionality not added.","warn")}(e)}},[y,o,u,s,h,g,w,S,v,m,l,f,i,p]),y};function et(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return tt(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(tt(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,tt(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,tt(f,"constructor",s),tt(s,"constructor",u),u.displayName="GeneratorFunction",tt(s,o,"GeneratorFunction"),tt(f),tt(f,o,"Generator"),tt(f,r,function(){return this}),tt(f,"toString",function(){return"[object Generator]"}),(et=function(){return{w:i,m:d}})()}function tt(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}tt=function(e,t,n,r){function i(t,n){tt(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},tt(e,t,n,r)}function nt(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function rt(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){nt(i,r,o,a,c,"next",e)}function c(e){nt(i,r,o,a,c,"throw",e)}a(void 0)})}}function ot(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,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(e,t)||function(e,t){if(e){if("string"==typeof e)return it(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)?it(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 it(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 at={VISA:"visa-light.svg",MASTERCARD:"mastercard-light.svg",AMEX:"amex-light.svg",DISCOVER:"discover-light.svg",DINERS:"dinersclub-light.svg",JCB:"jcb-light.svg",UNIONPAY:"unionpay-light.svg"};const ct=function(e){e.fastlaneSdk,e.showWatermark;var t,n,o=(0,a.useSelect)(function(e){return{card:e(_).getCardDetails()}},[]).card,i=null!==(t=null==o||null===(n=o.paymentSource)||void 0===n?void 0:n.card)&&void 0!==t?t:{},c=i.brand,u=i.lastDigits,s=i.expiry,l=i.name,f=(0,r.useMemo)(function(){return at[c]?React.createElement("img",{className:"wc-block-axo-block-card__meta-icon",title:c,src:"".concat(window.wc_ppcp_axo.icons_directory).concat(at[c]),alt:c}):React.createElement("span",null,c)},[c]),d=s?"".concat(s.split("-")[1],"/").concat(s.split("-")[0]):"";return React.createElement("div",{className:"wc-block-checkout-axo-block-card"},React.createElement("div",{className:"wc-block-checkout-axo-block-card__inner"},React.createElement("div",{className:"wc-block-checkout-axo-block-card__content"},React.createElement("div",{className:"wc-block-checkout-axo-block-card__meta"},React.createElement("div",{className:"wc-block-checkout-axo-block-card__meta-logo"},f),React.createElement("div",{className:"wc-block-checkout-axo-block-card__meta-container"},React.createElement("div",{className:"wc-block-checkout-axo-block-card__meta-digits"},"•••• ".concat(u)),React.createElement("div",{className:"wc-block-checkout-axo-block-card__meta-name"},l),React.createElement("div",{className:"wc-block-checkout-axo-block-card__meta-expiry"},d))))))},ut=function(){var e=(0,a.useSelect)(function(e){return{isGuest:e(_).getIsGuest(),cardDetails:e(_).getCardDetails(),cardChangeHandler:e(_).getCardChangeHandler()}},[]),t=e.isGuest,n=e.cardDetails,i=e.cardChangeHandler;return!t&&n&&i?(0,r.createElement)("a",{className:"wc-block-checkout-axo-block-card__edit wc-block-axo-change-link",role:"button",onClick:function(e){e.preventDefault(),i()}},(0,o.__)("Choose a different card","woocommerce-paypal-payments")):null};function st(){var e,t,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var u=r&&r.prototype instanceof c?r:c,s=Object.create(u.prototype);return lt(s,"_invoke",function(n,r,o){var i,c,u,s=0,l=o||[],f=!1,d={p:0,n:0,v:e,a:p,f:p.bind(e,4),d:function(t,n){return i=t,c=0,u=e,d.n=n,a}};function p(n,r){for(c=n,u=r,t=0;!f&&s&&!o&&t<l.length;t++){var o,i=l[t],p=d.p,y=i[2];n>3?(o=y===r)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=e):i[0]<=p&&((o=n<2&&p<i[1])?(c=0,d.v=r,d.n=i[1]):p<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,d.n=y,c=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&p(l,y),c=l,u=y;(t=c<2?e:u)||!f;){i||(c?c<3?(c>1&&(d.n=-1),p(c,u)):d.n=u:d.v=u);try{if(s=2,i){if(c||(o="next"),t=i[o]){if(!(t=t.call(i,u)))throw TypeError("iterator result is not an object");if(!t.done)return t;u=t.value,c<2&&(c=0)}else 1===c&&(t=i.return)&&t.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=e}else if((t=(f=d.n<0)?u:n.call(r,d))!==a)break}catch(t){i=e,c=1,u=t}finally{s=1}}return{value:t,done:f}}}(n,o,i),!0),s}var a={};function c(){}function u(){}function s(){}t=Object.getPrototypeOf;var l=[][r]?t(t([][r]())):(lt(t={},r,function(){return this}),t),f=s.prototype=c.prototype=Object.create(l);function d(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,s):(e.__proto__=s,lt(e,o,"GeneratorFunction")),e.prototype=Object.create(f),e}return u.prototype=s,lt(f,"constructor",s),lt(s,"constructor",u),u.displayName="GeneratorFunction",lt(s,o,"GeneratorFunction"),lt(f),lt(f,o,"Generator"),lt(f,r,function(){return this}),lt(f,"toString",function(){return"[object Generator]"}),(st=function(){return{w:i,m:d}})()}function lt(e,t,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(e){o=0}lt=function(e,t,n,r){function i(t,n){lt(e,t,function(e){return this._invoke(t,n,e)})}t?o?o(e,t,{value:n,enumerable:!r,configurable:!r,writable:!r}):e[t]=n:(i("next",0),i("throw",1),i("return",2))},lt(e,t,n,r)}function ft(e,t,n,r,o,i,a){try{var c=e[i](a),u=c.value}catch(e){return void n(e)}c.done?t(u):Promise.resolve(u).then(r,o)}function dt(e){return function(){var t=this,n=arguments;return new Promise(function(r,o){var i=e.apply(t,n);function a(e){ft(i,r,o,a,c,"next",e)}function c(e){ft(i,r,o,a,c,"throw",e)}a(void 0)})}}function pt(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 yt=function(e){var t,n,o=e.fastlaneSdk,i=e.onPaymentLoad,c=(t=(0,r.useState)(!1),n=2,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,n)||function(e,t){if(e){if("string"==typeof e)return pt(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)?pt(e,t):void 0}}(t,n)||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.")}()),u=c[0],s=c[1],l=(0,a.useSelect)(function(e){return{isGuest:e(_).getIsGuest(),isEmailLookupCompleted:e(_).getIsEmailLookupCompleted(),cardDetails:e(_).getCardDetails()}},[]),f=l.isGuest,p=l.isEmailLookupCompleted,y=l.cardDetails,m=window.wc_ppcp_axo,v=(0,r.useCallback)(dt(st().m(function e(){var t,n;return st().w(function(e){for(;;)switch(e.p=e.n){case 0:if(!(f&&p&&u||!f&&!y)){e.n=4;break}return e.p=1,e.n=2,o.FastlaneCardComponent({fields:{cardholderName:{enabled:"yes"===m.name_on_card}}});case 2:t=e.v,document.querySelector("#fastlane-card")&&(t.render("#fastlane-card"),i(t)),e.n=4;break;case 3:e.p=3,n=e.v,d("Error loading payment component: ".concat(n),"error");case 4:return e.a(2)}},e,null,[[1,3]])})),[f,p,u,y,o,i]);return(0,r.useEffect)(function(){f&&p&&s(!0)},[f,p]),(0,r.useEffect)(function(){u&&v()},[u,v]),function(){var e=wc.wcSettings.getSetting("ppcp-axo-gateway_data");return f&&!p?React.createElement("div",{id:"ppcp-axo-block-radio-content"},e.description):f&&p||!f&&!y?React.createElement("div",{id:"fastlane-card"}):React.createElement(ct,{fastlaneSdk:o,showWatermark:!f})}()};const mt=function(e){var t=e.components,n=e.config,r=window.wc_ppcp_axo,o=t.PaymentMethodIcons;return React.createElement(React.Fragment,null,React.createElement("span",{dangerouslySetInnerHTML:{__html:n.title}}),React.createElement(o,{icons:null==r?void 0:r.card_icons}),React.createElement(ut,null))};function vt(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 bt="ppcpBlocksPaypalAxo",ht=wc.wcSettings.getSetting("".concat("ppcp-axo-gateway","_data")),gt=function(e){var t,n,i,c,u,s=e.eventRegistration,l=e.emitResponse,f=s.onPaymentSetup,p=(c=(0,r.useState)(null),u=2,function(e){if(Array.isArray(e))return e}(c)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var r,o,i,a,c=[],u=!0,s=!1;try{if(i=(n=n.call(e)).next,0===t){if(Object(n)!==n)return;u=!1}else for(;!(u=(r=i.call(n)).done)&&(c.push(r.value),c.length!==t);u=!0);}catch(e){s=!0,o=e}finally{try{if(!u&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(c,u)||function(e,t){if(e){if("string"==typeof e)return vt(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)?vt(e,t):void 0}}(c,u)||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.")}()),y=p[0],m=p[1],v=function(e){var t=ot((0,r.useState)(!1),2),n=t[0],o=t[1],i=ot((0,r.useState)(e),2),a=i[0],c=i[1];return(0,r.useEffect)(function(){var e=function(){void 0!==window.PayPalCommerceGateway?(c(window.PayPalCommerceGateway),o(!0)):d("PayPal Commerce Gateway config not loaded.","error")};return"loading"===document.readyState?document.addEventListener("DOMContentLoaded",e):e(),function(){document.removeEventListener("DOMContentLoaded",e)}},[]),{isConfigLoaded:n,ppcpConfig:a}}(ht),b=v.isConfigLoaded,h=v.ppcpConfig,g=window.wc_ppcp_axo,w=N(bt,g,h),S=function(e,t,n){var o=(0,a.useSelect)(function(e){return{cardDetails:e(_).getCardDetails()}},[]).cardDetails;return(0,r.useCallback)(rt(et().m(function r(){var i,a,c;return et().w(function(r){for(;;)switch(r.n){case 0:if(i=!(null==o||!o.id),(a=null==o?void 0:o.id)||!t){r.n=2;break}return r.n=1,t.getPaymentToken(n).then(function(e){return e.id});case 1:a=r.v;case 2:if(a){r.n=3;break}return c="tokenization error",t||(c="initialization error"),r.a(2,{type:e.responseTypes.ERROR,message:"Could not process the payment (".concat(c,")")});case 3:return r.a(2,{type:e.responseTypes.SUCCESS,meta:{paymentMethodData:{fastlane_member:i,axo_nonce:a}}})}},r)})),[null==o?void 0:o.id,e.responseTypes.ERROR,e.responseTypes.SUCCESS,t,n])}(l,y,(t=G(),n=t.billingAddress,i=t.shippingAddress,(0,r.useMemo)(function(){var e,t=((e=n).first_name||e.last_name)&&e.address_1&&e.city&&e.postcode&&e.country?n:i;return{cardholderName:{fullName:"".concat(t.first_name," ").concat(t.last_name)},billingAddress:{addressLine1:t.address_1,addressLine2:t.address_2,adminArea1:t.state,adminArea2:t.city,postalCode:t.postcode,countryCode:t.country}}},[n,i]))),E=Ze(bt,h,b,w,y),O=function(e,t,n){return(0,r.useEffect)(function(){var n=e(t);return function(){n()}},[e,t]),{handlePaymentLoad:(0,r.useCallback)(function(e){n(e)},[n])}}(f,S,m).handlePaymentLoad;return function(){var e=(0,a.useDispatch)(_),t=e.setIsAxoActive,n=e.setIsGuest,o=e.setIsEmailLookupCompleted,i=G(),c=i.setShippingAddress,u=i.setBillingAddress;(0,r.useEffect)(function(){return function(){d("Cleaning up: Restoring WooCommerce fields"),function(e,t){var n;d("Attempting to restore original fields");try{n=localStorage.getItem("axoOriginalCheckoutFields"),d("Data retrieved from localStorage: ".concat(JSON.stringify(n)))}catch(e){d("Error retrieving from localStorage: ".concat(e),"error")}if(n)try{var r=JSON.parse(n);r.shippingAddress?e(r.shippingAddress):d("No shipping address found in saved data","warn"),r.billingAddress?(d("Restoring billing address:\n\t\t\t\t\t".concat(JSON.stringify(r.billingAddress))),t(r.billingAddress)):d("No billing address found in saved data","warn")}catch(e){d("Error parsing saved data: ".concat(e))}else d("No data found in localStorage under axoOriginalCheckoutFields","warn")}(c,u)}},[c,u]),(0,r.useEffect)(function(){return function(){var e,i;d("Cleaning up Axo component"),t(!1),n(!0),o(!1),(e=document.querySelector("#shipping-fields .wc-block-checkout-axo-block-card__edit"))&&((0,r.createRoot)(e).unmount(),e.remove()),Se(),Pe.root&&(d("Removing email functionality"),(i=xe())&&Ce&&i.removeEventListener("keydown",Ce),Pe.root&&Pe.root.unmount(),Pe.unsubscribe&&Pe.unsubscribe(),Pe.container&&Pe.container.parentNode&&Pe.container.parentNode.removeChild(Pe.container),Pe={container:null,root:null,unsubscribe:null},Ce=null)}},[])}(),b?E?w?React.createElement(yt,{fastlaneSdk:w,onPaymentLoad:O}):React.createElement(React.Fragment,null,(0,o.__)("Loading Fastlane…","woocommerce-paypal-payments")):React.createElement(React.Fragment,null,(0,o.__)("Loading PayPal script…","woocommerce-paypal-payments")):React.createElement(React.Fragment,null,(0,o.__)("Loading configuration…","woocommerce-paypal-payments"))};(0,i.registerPaymentMethod)({name:ht.id,label:React.createElement(mt,{config:ht}),content:React.createElement(gt,null),edit:(0,r.createElement)(ht.title),ariaLabel:ht.title,canMakePayment:function(){return!0},supports:{showSavedCards:!0,features:ht.supports}})})(); |