mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2026-07-28 01:57:35 +08:00
1 line
No EOL
84 KiB
JavaScript
1 line
No EOL
84 KiB
JavaScript
(()=>{"use strict";var t={4744(t){var e=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===r}(t)}(t)},r="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function n(t,e){return!1!==e.clone&&e.isMergeableObject(t)?c((r=t,Array.isArray(r)?[]:{}),t,e):t;var r}function o(t,e,r){return t.concat(e).map(function(t){return n(t,r)})}function i(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}(t))}function a(t,e){try{return e in t}catch(t){return!1}}function c(t,r,u){(u=u||{}).arrayMerge=u.arrayMerge||o,u.isMergeableObject=u.isMergeableObject||e,u.cloneUnlessOtherwiseSpecified=n;var s=Array.isArray(r);return s===Array.isArray(t)?s?u.arrayMerge(t,r,u):function(t,e,r){var o={};return r.isMergeableObject(t)&&i(t).forEach(function(e){o[e]=n(t[e],r)}),i(e).forEach(function(i){(function(t,e){return a(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,i)||(a(t,i)&&r.isMergeableObject(e[i])?o[i]=function(t,e){if(!e.customMerge)return c;var r=e.customMerge(t);return"function"==typeof r?r:c}(i,r)(t[i],e[i],r):o[i]=n(e[i],r))}),o}(t,r,u):n(r,u)}c.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,r){return c(t,r,e)},{})};var u=c;t.exports=u}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n](i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);const n=window.wc.wcBlocksRegistry,o=window.wp.i18n;var i=function(t){return t.data_client_id.has_subscriptions&&t.data_client_id.paypal_subscriptions_enabled},a=function(t){var e;return!(null==t||null===(e=t.locations_with_subscription_product)||void 0===e||!e.cart)};function c(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach(function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])}),r}function u(t,e){if(void 0===e&&(e=Promise),l(t,e),"undefined"==typeof document)return e.resolve(null);var r=function(t){var e,r,n=t.sdkBaseUrl,o=t.environment,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["sdkBaseUrl","environment"]),a=n||function(t){return"sandbox"===t?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}(o),c=i,u=Object.keys(c).filter(function(t){return void 0!==c[t]&&null!==c[t]&&""!==c[t]}).reduce(function(t,e){var r,n=c[e].toString();return r=function(t,e){return(e?"-":"")+t.toLowerCase()},"data"===(e=e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)||"crossorigin"===e?t.attributes[e]=n:t.queryParams[e]=n,t},{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((e=s,r="",Object.keys(e).forEach(function(t){0!==r.length&&(r+="&"),r+=t+"="+e[t]}),r)),attributes:l}}(t),n=r.url,o=r.attributes,i=o["data-namespace"]||"paypal",a=s(i);return o["data-js-sdk-library"]||(o["data-js-sdk-library"]="paypal-js"),function(t,e){var r=document.querySelector('script[src="'.concat(t,'"]'));if(null===r)return null;var n=c(t,e),o=r.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(n.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach(function(t){o.dataset[t]!==n.dataset[t]&&(i=!1)}),i?r:null}(n,o)&&a?e.resolve(a):function(t,e){void 0===e&&(e=Promise),l(t,e);var r=t.url,n=t.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new e(function(t,e){if("undefined"==typeof document)return t();!function(t){var e=t.onSuccess,r=t.onError,n=c(t.url,t.attributes);n.onerror=r,n.onload=e,document.head.insertBefore(n,document.head.firstElementChild)}({url:r,attributes:n,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(r,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(t)}})})}({url:n,attributes:o},e).then(function(){var t=s(i);if(t)return t;throw new Error("The window.".concat(i," global variable is not available."))})}function s(t){return window[t]}function l(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");var r=t.environment;if(r&&"production"!==r&&"sandbox"!==r)throw new Error('The `environment` option must be either "production" or "sandbox".');if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}function p(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||y(t,e)||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 d(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=y(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var _n=0,n=function(){};return{s:n,n:function(){return _n>=t.length?{done:!0}:{done:!1,value:t[_n++]}},e:function(t){throw t},f:n}}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(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}function y(t,e){if(t){if("string"==typeof t)return v(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?v(t,e):void 0}}function v(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function b(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,m(n.key),n)}}function m(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}"function"==typeof SuppressedError&&SuppressedError;var h=function(){return t=function t(){var e=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.paypal=null,this.buttons=new Map,this.messages=new Map,this.renderEventName="ppcp-render",document.ppcpWidgetBuilderStatus=function(){console.log({buttons:e.buttons,messages:e.messages})},jQuery(document).off(this.renderEventName).on(this.renderEventName,function(){e.renderAll()})},e=[{key:"setPaypal",value:function(t){this.paypal=t,jQuery(document).trigger("ppcp-paypal-loaded",t)}},{key:"registerButtons",value:function(t,e){t=this.sanitizeWrapper(t),this.buttons.set(this.toKey(t),{wrapper:t,options:e})}},{key:"renderButtons",value:function(t){t=this.sanitizeWrapper(t);var e=this.toKey(t);if(this.buttons.has(e)&&!this.hasRendered(t)){var r=this.buttons.get(e),n=this.paypal.Buttons(r.options);if(n.isEligible()){var o=this.buildWrapperTarget(t);o&&(n.hasReturned()?n.resume():n.render(o))}else this.buttons.delete(e)}}},{key:"renderAllButtons",value:function(){var t,e=d(this.buttons);try{for(e.s();!(t=e.n()).done;){var r=p(t.value,1)[0];this.renderButtons(r)}}catch(t){e.e(t)}finally{e.f()}}},{key:"removeButtons",value:function(t){var e,r=d(this.buttons);try{for(r.s();!(e=r.n()).done;){var n=p(e.value,2),o=n[0],i=n[1];(Array.isArray(i.wrapper)?i.wrapper[0]:i.wrapper)===t&&this.buttons.delete(o)}}catch(t){r.e(t)}finally{r.f()}}},{key:"registerMessages",value:function(t,e){this.messages.set(t,{wrapper:t,options:e})}},{key:"renderMessages",value:function(t){var e=this;if(this.messages.has(t)){var r=this.messages.get(t);if(this.hasRendered(t))document.querySelector(t).setAttribute("data-pp-amount",r.options.amount);else{var n=this.paypal.Messages(r.options);n.render(r.wrapper),setTimeout(function(){e.hasRendered(t)||n.render(r.wrapper)},100)}}}},{key:"renderAllMessages",value:function(){var t,e=d(this.messages);try{for(e.s();!(t=e.n()).done;){var r=p(t.value,2),n=r[0];r[1],this.renderMessages(n)}}catch(t){e.e(t)}finally{e.f()}}},{key:"renderAll",value:function(){this.renderAllButtons(),this.renderAllMessages()}},{key:"hasRendered",value:function(t){var e=t;if(Array.isArray(t)){e=t[0];var r,n=d(t.slice(1));try{for(n.s();!(r=n.n()).done;)e+=" .item-"+r.value}catch(t){n.e(t)}finally{n.f()}}var o=document.querySelector(e);return o&&o.hasChildNodes()}},{key:"sanitizeWrapper",value:function(t){return Array.isArray(t)&&1===(t=t.filter(function(t){return!!t})).length&&(t=t[0]),t}},{key:"buildWrapperTarget",value:function(t){var e=t;if(Array.isArray(t)){var r=jQuery(t[0]);if(!r.length)return;var n="item-"+t[1],o=r.find("."+n);o.length||(o=jQuery('<div class="'.concat(n,'"></div>')),r.append(o)),e=o.get(0)}return jQuery(e).length?e:null}},{key:"toKey",value:function(t){return Array.isArray(t)?JSON.stringify(t):t}}],e&&b(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();window.widgetBuilder=window.widgetBuilder||new h;const g=window.widgetBuilder;var w=r(4744),S=r.n(w),O=function(t){return t.replace(/([-_]\w)/g,function(t){return t[1].toUpperCase()})},_=["checkout","checkout-block","pay-now"],j=function(t){var e=function(t){var e={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[O(r)]=t[r]);return e}(t.url_params);t.script_attributes&&(e=S()(e,t.script_attributes));var r=function(t){var e=function(t){var e,r,n;if(!0!==(null==t||null===(e=t.user)||void 0===e?void 0:e.is_logged))return null;var o=null==t||null===(r=t.save_payment_methods)||void 0===r?void 0:r.id_token;return o?!0===(null==t||null===(n=t.vault_component)||void 0===n?void 0:n.is_eligible)&&_.includes(null==t?void 0:t.context)?null:o:null}(t);return e?{"data-user-id-token":e}:{}}(t);return S().all([e,r])};function E(t){return E="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},E(t)}function P(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,s=Object.create(u.prototype);return k(s,"_invoke",function(r,n,o){var i,c,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,c=0,u=t,p.n=r,a}};function d(r,n){for(c=r,u=n,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],d=p.p,y=i[2];r>3?(o=y===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,p.v=n,p.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,p.n=y,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,y),c=l,u=y;(e=c<2?t:u)||!f;){i||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(s=2,i){if(c||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,c<2&&(c=0)}else 1===c&&(e=i.return)&&e.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,c=1,u=e}finally{s=1}}return{value:e,done:f}}}(r,o,i),!0),s}var a={};function c(){}function u(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(k(e={},n,function(){return this}),e),f=s.prototype=c.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,k(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=s,k(f,"constructor",s),k(s,"constructor",u),u.displayName="GeneratorFunction",k(s,o,"GeneratorFunction"),k(f),k(f,o,"Generator"),k(f,n,function(){return this}),k(f,"toString",function(){return"[object Generator]"}),(P=function(){return{w:i,m:p}})()}function k(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}k=function(t,e,r,n){function i(e,r){k(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},k(t,e,r,n)}function A(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function T(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?A(Object(r),!0).forEach(function(e){D(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):A(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function D(t,e,r){return(e=function(t){var e=function(t){if("object"!=E(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=E(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==E(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function R(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}var C=new Map,x=new Map,I=function(){var t,e=(t=P().m(function t(e,r){var n,o;return P().w(function(t){for(;;)switch(t.n){case 0:if(e){t.n=1;break}throw new Error("Namespace is required");case 1:if(!C.has(e)){t.n=2;break}return console.log("Script already loaded for namespace: ".concat(e)),t.a(2,C.get(e));case 2:if(!x.has(e)){t.n=3;break}return console.log("Script loading in progress for namespace: ".concat(e)),t.a(2,x.get(e));case 3:return n=T(T({},j(r)),{},{"data-namespace":e}),o=new Promise(function(t,r){u(n).then(function(r){g.setPaypal(r),C.set(e,r),console.log("Script loaded for namespace: ".concat(e)),t(r)}).catch(function(t){console.error("Failed to load script for namespace: ".concat(e),t),r(t)}).finally(function(){x.delete(e)})}),x.set(e,o),t.a(2,o)}},t)}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){R(i,n,o,a,c,"next",t)}function c(t){R(i,n,o,a,c,"throw",t)}a(void 0)})});return function(_x,t){return e.apply(this,arguments)}}(),N=function(t,e,r){jQuery(document).trigger("ppcp-shown",{handler:t,action:"show",selector:e,element:r})},M=function(t,e){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2],n=function(t){return"string"==typeof t?document.querySelector(t):t}(t);if(n){var o=n.style.getPropertyValue("display");if(e)"none"===o&&(n.style.removeProperty("display"),N("Hiding.setVisible",t,n)),function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}(n)||(n.style.setProperty("display","block"),N("Hiding.setVisible",t,n));else{if("none"===o)return;n.style.setProperty("display","none",r?"important":""),function(t,e,r){jQuery(document).trigger("ppcp-hidden",{handler:t,action:"hide",selector:e,element:r})}("Hiding.setVisible",t,n)}}};function B(t){return B="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},B(t)}function F(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,G(n.key),n)}}function G(t){var e=function(t){if("object"!=B(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(e)?e:e+""}var L=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.optionsFingerprint=null,this.currentNumber=0},(e=[{key:"renderWithAmount",value:function(t){if(this.shouldRender()){var e={amount:t};if(this.config.placement&&(e.placement=this.config.placement),this.config.style&&(e.style=this.config.style),document.querySelector(this.config.wrapper).getAttribute("data-render-number")!==this.currentNumber.toString()&&(this.optionsFingerprint=null),!this.optionsEqual(e)){var r=document.querySelector(this.config.wrapper);this.currentNumber++,r.setAttribute("data-render-number",this.currentNumber),g.registerMessages(this.config.wrapper,e),g.renderMessages(this.config.wrapper)}}}},{key:"optionsEqual",value:function(t){var e=JSON.stringify(t);return this.optionsFingerprint===e||(this.optionsFingerprint=e,!1)}},{key:"shouldRender",value:function(){return"undefined"!=typeof paypal&&void 0!==paypal.Messages&&void 0!==this.config.wrapper&&!!document.querySelector(this.config.wrapper)}}])&&F(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();const U=L;function q(t){return q="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},q(t)}function J(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,s=Object.create(u.prototype);return V(s,"_invoke",function(r,n,o){var i,c,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,c=0,u=t,p.n=r,a}};function d(r,n){for(c=r,u=n,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],d=p.p,y=i[2];r>3?(o=y===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,p.v=n,p.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,p.n=y,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,y),c=l,u=y;(e=c<2?t:u)||!f;){i||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(s=2,i){if(c||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,c<2&&(c=0)}else 1===c&&(e=i.return)&&e.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,c=1,u=e}finally{s=1}}return{value:e,done:f}}}(r,o,i),!0),s}var a={};function c(){}function u(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(V(e={},n,function(){return this}),e),f=s.prototype=c.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,V(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=s,V(f,"constructor",s),V(s,"constructor",u),u.displayName="GeneratorFunction",V(s,o,"GeneratorFunction"),V(f),V(f,o,"Generator"),V(f,n,function(){return this}),V(f,"toString",function(){return"[object Generator]"}),(J=function(){return{w:i,m:p}})()}function V(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}V=function(t,e,r,n){function i(e,r){V(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},V(t,e,r,n)}function H(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function W(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Q(n.key),n)}}function Q(t){var e=function(t){if("object"!=q(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=q(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==q(e)?e:e+""}var K=function(){return t=function t(e,r){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.gateway=e,this.renderers=[],this.lastAmount=this.gateway.messages.amount,r&&this.renderers.push(r)},e=[{key:"init",value:(r=J().m(function t(){var e,r=this;return J().w(function(t){for(;;)switch(t.n){case 0:if(null===(e=this.gateway.messages)||void 0===e||null===(e=e.block)||void 0===e||!e.enabled){t.n=1;break}return t.n=1,this.attemptDiscoverBlocks(3);case 1:jQuery(document.body).on("ppcp_cart_rendered ppcp_checkout_rendered",function(){r.render()}),jQuery(document.body).on("ppcp_script_data_changed",function(t,e){r.gateway=e,r.render()}),jQuery(document.body).on("ppcp_cart_total_updated ppcp_checkout_total_updated ppcp_product_total_updated ppcp_block_cart_total_updated",function(t,e){r.lastAmount!==e&&(r.lastAmount=e,r.render())}),this.render();case 2:return t.a(2)}},t,this)}),n=function(){var t=this,e=arguments;return new Promise(function(n,o){var i=r.apply(t,e);function a(t){H(i,n,o,a,c,"next",t)}function c(t){H(i,n,o,a,c,"throw",t)}a(void 0)})},function(){return n.apply(this,arguments)})},{key:"attemptDiscoverBlocks",value:function(t){var e=this;return new Promise(function(r,n){e.discoverBlocks().then(function(n){!n&&t>0?setTimeout(function(){e.attemptDiscoverBlocks(t-1).then(r)},2e3):r()})})}},{key:"discoverBlocks",value:function(){var t=this;return new Promise(function(e){var r=document.querySelectorAll(".ppcp-messages");0!==r.length?(Array.from(r).forEach(function(e){e.id||(e.id="ppcp-message-".concat(Math.random().toString(36).substr(2,9)));var r={wrapper:"#"+e.id};e.getAttribute("data-pp-placement")||(r.placement=t.gateway.messages.placement),t.renderers.push(new U(r))}),e(!0)):e(!1)})}},{key:"shouldShow",value:function(t){if(!0===this.gateway.messages.is_hidden)return!1;var e={result:!0};return jQuery(document.body).trigger("ppcp_should_show_messages",[e,t.config.wrapper]),e.result}},{key:"render",value:function(){var t=this;this.renderers.forEach(function(e){var r=t.shouldShow(e);r&&function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:3e3,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:100;return new Promise(function(n,o){var i=setTimeout(function(){clearInterval(c),o('Element "'.concat(t,'" not found within ').concat(e,"ms"))},e),a=document.querySelector(t);if(a)return clearTimeout(i),void n(a);var c=setInterval(function(){var e=document.querySelector(t);e&&(clearTimeout(i),clearInterval(c),n(e))},r)})}(e.config.wrapper).then(function(){M(e.config.wrapper,r),e.renderWithAmount(t.lastAmount)}).catch(function(){})})}}],e&&W(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n}();const $=K;function z(t){return z="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},z(t)}function Z(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,X(n.key),n)}}function X(t){var e=function(t){if("object"!=z(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=z(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==z(e)?e:e+""}var Y=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.messagesBootstrap=new $(e,null),this.lastCartTotal=null},e=[{key:"init",value:function(){var t,e,r,n,o,i,a=this;this.messagesBootstrap.init(),this._updateCartTotal(),null!==(t=wp.data)&&void 0!==t&&t.subscribe&&wp.data.subscribe((e=function(){a._updateCartTotal()},r={timeoutId:null,args:null},o=function(){r.timeoutId&&(e.apply(null,r.args||[]),n())},i=function(){n();for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];r.args=e,r.timeoutId=window.setTimeout(o,300)},i.cancel=n=function(){r.timeoutId&&window.clearTimeout(r.timeoutId),r.timeoutId=null,r.args=null},i.flush=o,i))}},{key:"_getCartTotal",value:function(){if(!wp.data.select)return null;var t=wp.data.select("wc/store/cart");if(!t)return null;var e=t.getCartTotals();return parseInt(e.total_price,10)/Math.pow(10,e.currency_minor_unit)}},{key:"_updateCartTotal",value:function(){var t=this._getCartTotal();null!==t&&t!==this.lastCartTotal&&(this.lastCartTotal=t,jQuery(document.body).trigger("ppcp_block_cart_total_updated",[t]))}}],e&&Z(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();const tt=Y,et=window.wp.element;function rt(t){return rt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},rt(t)}function nt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function ot(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?nt(Object(r),!0).forEach(function(e){it(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):nt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function it(t,e,r){return(e=function(t){var e=function(t){if("object"!=rt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=rt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==rt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function at(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return ct(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?ct(t,e):void 0}}(t,e)||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 ct(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ut=function(t){var e={country_code:"country",address_line_1:"address_1",address_line_2:"address_2",admin_area_1:"state",admin_area_2:"city",postal_code:"postcode"};null!=t&&t.city&&(e={country_code:"country",state:"state",city:"city",postal_code:"postcode"});var r={};return Object.entries(e).forEach(function(e){var n=at(e,2),o=n[0],i=n[1];null!=t&&t[o]&&(r[i]=t[o])}),ot(ot({},{first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""}),r)},st=function(t){var e,r,n,o,i,a,c=null!==(e=null==t||null===(r=t.name)||void 0===r?void 0:r.given_name)&&void 0!==e?e:"",u=null!==(n=null==t||null===(o=t.name)||void 0===o?void 0:o.surname)&&void 0!==n?n:"",s=null!==(i=null==t||null===(a=t.phone)||void 0===a||null===(a=a.phone_number)||void 0===a?void 0:a.national_number)&&void 0!==i?i:"";return ot(ot({},t.address?ut(t.address):{}),{},{first_name:c,last_name:u,email:t.email_address,phone:s})},lt=function(t){var e=function(t){var e,r=null==t||null===(e=t.purchase_units)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.shipping;if(!r)return{};var n=function(t){var e=t.name?function(t){if(!(t=t.trim()).includes(" "))return[t,""];var e=t.split(" "),r=e[0];return e.shift(),[r,e.join(" ")]}(t.name.full_name):["",""],r=at(e,2),n=r[0],o=r[1];return ot(ot({},ut(t.address)),{},{first_name:n,last_name:o})}(r);if(t.payer){var o=st(t.payer);"".concat(n.first_name," ").concat(n.last_name)==="".concat(o.first_name," ").concat(o.last_name)&&(n.first_name=o.first_name,n.last_name=o.last_name)}return n}(t),r=e;if(null!=t&&t.payer&&!(r=st(t.payer)).address_line_1){var n=Object.fromEntries(Object.entries(r).filter(function(t){var e=at(t,2),r=e[0];return""!==e[1]&&"country"!==r}));r=ot(ot({},e),n)}return{billingAddress:r,shippingAddress:e}},ft=function(t){var e,r,n,o,i,a,c,u=(a=null!==(r=null==(e=t.subscriber)||null===(n=e.name)||void 0===n?void 0:n.given_name)&&void 0!==r?r:"",c=null!==(o=null==e||null===(i=e.name)||void 0===i?void 0:i.surname)&&void 0!==o?o:"",ot(ot({},e.address?ut(e.shipping_address.address):{}),{},{first_name:a,last_name:c,email:e.email_address}));return{billingAddress:u,shippingAddress:u}},pt=function(t,e){if("billingAddress"in t)return{billingAddress:pt(t.billingAddress,e.billingAddress),shippingAddress:pt(t.shippingAddress,e.shippingAddress)};var r=ot({},e);return Object.keys(e).forEach(function(t){""===e[t]&&delete r[t]}),ot(ot({},t),r)},dt=function(t){var e={};return Object.keys(t).forEach(function(r){var n=r.replace(/[\w]([A-Z])/g,function(t){return t[0]+"_"+t[1]}).toLowerCase();e[n]=t[r]}),e};function yt(t){return yt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},yt(t)}function vt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function bt(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,mt(n.key),n)}}function mt(t){var e=function(t){if("object"!=yt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yt(e)?e:e+""}var ht=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.contextBootstrapRegistry={},this.contextBootstrapWatchers=[]},e=[{key:"watchContextBootstrap",value:function(t){this.contextBootstrapWatchers.push(t),Object.values(this.contextBootstrapRegistry).forEach(t)}},{key:"registerContextBootstrap",value:function(t,e){this.contextBootstrapRegistry[t]={context:t,handler:e};var r,n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return vt(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?vt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var _n=0,n=function(){};return{s:n,n:function(){return _n>=t.length?{done:!0}:{done:!1,value:t[_n++]}},e:function(t){throw t},f:n}}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(){r=r.call(t)},n:function(){var t=r.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==r.return||r.return()}finally{if(a)throw o}}}}(this.contextBootstrapWatchers);try{for(n.s();!(r=n.n()).done;)(0,r.value)(this.contextBootstrapRegistry[t])}catch(t){n.e(t)}finally{n.f()}}}],e&&bt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();window.ppcpResources=window.ppcpResources||{};const gt=window.ppcpResources.ButtonModuleWatcher=window.ppcpResources.ButtonModuleWatcher||new ht;function wt(t){return wt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wt(t)}function St(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Ot(t,e,r){return(e=function(t){var e=function(t){if("object"!=wt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=wt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var _t=function(t,e){var r={};switch(["shape","height"].forEach(function(e){t[e]&&(r[e]=t[e])}),e){case"paypal":return t;case"paylater":return function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?St(Object(r),!0).forEach(function(e){Ot(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):St(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}({color:t.color},r);default:return r}};function jt(t){return jt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},jt(t)}function Et(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,s=Object.create(u.prototype);return Pt(s,"_invoke",function(r,n,o){var i,c,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,c=0,u=t,p.n=r,a}};function d(r,n){for(c=r,u=n,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],d=p.p,y=i[2];r>3?(o=y===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,p.v=n,p.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,p.n=y,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,y),c=l,u=y;(e=c<2?t:u)||!f;){i||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(s=2,i){if(c||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,c<2&&(c=0)}else 1===c&&(e=i.return)&&e.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,c=1,u=e}finally{s=1}}return{value:e,done:f}}}(r,o,i),!0),s}var a={};function c(){}function u(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(Pt(e={},n,function(){return this}),e),f=s.prototype=c.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,Pt(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=s,Pt(f,"constructor",s),Pt(s,"constructor",u),u.displayName="GeneratorFunction",Pt(s,o,"GeneratorFunction"),Pt(f),Pt(f,o,"Generator"),Pt(f,n,function(){return this}),Pt(f,"toString",function(){return"[object Generator]"}),(Et=function(){return{w:i,m:p}})()}function Pt(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Pt=function(t,e,r,n){function i(e,r){Pt(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},Pt(t,e,r,n)}function kt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function At(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?kt(Object(r),!0).forEach(function(e){Tt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):kt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Tt(t,e,r){return(e=function(t){var e=function(t){if("object"!=jt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=jt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==jt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Dt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Rt(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){Dt(i,n,o,a,c,"next",t)}function c(t){Dt(i,n,o,a,c,"throw",t)}a(void 0)})}}var Ct=function(){var t=Rt(Et().m(function t(e,r,n,o){var i,a,c,u,s,l,f;return Et().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,a=At({nonce:r.scriptData.ajax.create_order.nonce,bn_code:"",context:r.scriptData.context,payment_method:"ppcp-gateway",funding_source:null!==(i=window.ppcpFundingSource)&&void 0!==i?i:"paypal",createaccount:!1},(null==e?void 0:e.paymentSource)&&{payment_source:e.paymentSource}),t.n=1,fetch(r.scriptData.ajax.create_order.endpoint,{method:"POST",credentials:"same-origin",body:JSON.stringify(a)});case 1:return c=t.v,t.n=2,c.json();case 2:if((u=t.v).success){t.n=5;break}if(!((null===(s=u.data)||void 0===s||null===(s=s.details)||void 0===s?void 0:s.length)>0)){t.n=3;break}throw new Error(u.data.details.map(function(t){return"".concat(t.issue," ").concat(t.description)}).join("<br/>"));case 3:if(null===(l=u.data)||void 0===l||!l.message){t.n=4;break}throw new Error(u.data.message);case 4:throw new Error(r.scriptData.labels.error.generic);case 5:return t.a(2,u.data.id);case 6:throw t.p=6,f=t.v,console.error(f),n(f.message),o(),f;case 7:return t.a(2)}},t,null,[[0,6]])}));return function(_x,e,r,n){return t.apply(this,arguments)}}(),xt=function(){var t=Rt(Et().m(function t(e,r,n,o,i,a,c,u,s,l,f,p,d){var y,v,b,m,h,g,w,S,O,_,j,E;return Et().w(function(t){for(;;)switch(t.p=t.n){case 0:if(d(!0),t.p=1,ae(n)){t.n=3;break}return t.n=2,r.order.get();case 2:b=t.v,t.n=7;break;case 3:return t.n=4,fetch(n.scriptData.ajax.get_order.endpoint,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({nonce:n.scriptData.ajax.get_order.nonce,order_id:e.orderID})});case 4:return m=t.v,t.n=5,m.json();case 5:if((h=t.v).success){t.n=6;break}throw new Error((null===(g=h.data)||void 0===g?void 0:g.message)||n.scriptData.labels.error.generic);case 6:b=h.data;case 7:if(!(null===(y=b)||void 0===y||null===(y=y.purchase_units)||void 0===y||null===(y=y[0])||void 0===y||null===(y=y.shipping)||void 0===y?void 0:y.address)){t.n=8;break}return w=lt(b),S=[wp.data.dispatch("wc/store/cart").updateCustomerData({billing_address:w.billingAddress,shipping_address:w.shippingAddress})],o()&&(S.push(wp.data.dispatch("wc/store/cart").setBillingAddress(w.billingAddress)),i.needsShipping&&S.push(wp.data.dispatch("wc/store/cart").setShippingAddress(w.shippingAddress))),t.n=8,Promise.all(S);case 8:return a(b),t.n=9,fetch(n.scriptData.ajax.approve_order.endpoint,{method:"POST",credentials:"same-origin",body:JSON.stringify({nonce:n.scriptData.ajax.approve_order.nonce,order_id:e.orderID,funding_source:null!==(v=window.ppcpFundingSource)&&void 0!==v?v:"paypal"})});case 9:return O=t.v,t.n=10,O.json();case 10:if((_=t.v).success){t.n=13;break}if(void 0===r||void 0===r.restart){t.n=11;break}return t.a(2,r.restart());case 11:if(null===(j=_.data)||void 0===j||!j.message){t.n=12;break}throw new Error(_.data.message);case 12:throw new Error(n.scriptData.labels.error.generic);case 13:c()?(s(!0),l()):location.href=u(),t.n=15;break;case 14:throw t.p=14,E=t.v,console.error(E),d(!1),f(E.message),p(),E;case 15:return t.a(2)}},t,null,[[1,14]])}));return function(e,r,n,o,i,a,c,u,s,l,f,p,d){return t.apply(this,arguments)}}(),It=function(){var t=Rt(Et().m(function t(e,r,n){var o;return Et().w(function(t){for(;;)if(0===t.n)return o=n.scriptData.subscription_plan_id,""!==n.scriptData.variable_paypal_subscription_variation_from_cart&&(o=n.scriptData.variable_paypal_subscription_variation_from_cart),t.a(2,r.subscription.create({plan_id:o,custom_id:n.scriptData.subscription_custom_id}))},t)}));return function(e,r,n){return t.apply(this,arguments)}}(),Nt=function(){var t=Rt(Et().m(function t(e,r,n,o,i,a,c,u,s,l,f,p){var d,y,v,b,m,h,g;return Et().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,r.subscription.get();case 1:if(!(d=t.v)){t.n=2;break}return y=ft(d),v=[wp.data.dispatch("wc/store/cart").updateCustomerData({billing_address:y.billingAddress,shipping_address:y.shippingAddress})],o()&&(v.push(wp.data.dispatch("wc/store/cart").setBillingAddress(y.billingAddress)),i.needsShipping&&v.push(wp.data.dispatch("wc/store/cart").setShippingAddress(y.shippingAddress))),t.n=2,Promise.all(v);case 2:return a(d),t.n=3,fetch(n.scriptData.ajax.approve_subscription.endpoint,{method:"POST",credentials:"same-origin",body:JSON.stringify({nonce:n.scriptData.ajax.approve_subscription.nonce,order_id:e.orderID,subscription_id:e.subscriptionID})});case 3:return b=t.v,t.n=4,b.json();case 4:if((m=t.v).success){t.n=7;break}if(void 0===r||void 0===r.restart){t.n=5;break}return t.a(2,r.restart());case 5:if(null===(h=m.data)||void 0===h||!h.message){t.n=6;break}throw new Error(m.data.message);case 6:throw new Error(n.scriptData.labels.error.generic);case 7:c()?(s(!0),l()):location.href=u(),t.n=9;break;case 8:throw t.p=8,g=t.v,console.error(g),f(g.message),p(),g;case 9:return t.a(2)}},t,null,[[0,8]])}));return function(e,r,n,o,i,a,c,u,s,l,f,p){return t.apply(this,arguments)}}(),Mt=function(){var t=Rt(Et().m(function t(e){return Et().w(function(t){for(;;)if(0===t.n)return t.a(2,fetch(e.scriptData.ajax.create_setup_token.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({nonce:e.scriptData.ajax.create_setup_token.nonce,payment_method:"ppcp-gateway"})}).then(function(t){return t.json()}).then(function(t){return t.data.id}).catch(function(t){console.error(t)}))},t)}));return function(e){return t.apply(this,arguments)}}(),Bt=function(){var t=Rt(Et().m(function t(e,r,n){var o,i,a,c;return Et().w(function(t){for(;;)switch(t.n){case 0:return o=r.scriptData.ajax.create_payment_token_for_guest.endpoint,i={nonce:r.scriptData.ajax.create_payment_token_for_guest.nonce,vault_setup_token:e},r.scriptData.user.is_logged_in&&(o=r.scriptData.ajax.create_payment_token.endpoint,i={nonce:r.scriptData.ajax.create_payment_token.nonce,vault_setup_token:e,is_free_trial_cart:r.scriptData.is_free_trial_cart}),t.n=1,fetch(o,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});case 1:return a=t.v,t.n=2,a.json();case 2:!0===(c=t.v).success&&n(),console.error(c);case 3:return t.a(2)}},t)}));return function(e,r,n){return t.apply(this,arguments)}}();const Ft=window.React;var Gt=r.n(Ft);function Lt(t){return Lt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Lt(t)}function Ut(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,qt(n.key),n)}}function qt(t){var e=function(t){if("object"!=Lt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Lt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lt(e)?e:e+""}var Jt=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"form.woocommerce-checkout";!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.target=e}return e=t,n=[{key:"fullPage",value:function(){return new t(window)}}],(r=[{key:"setTarget",value:function(t){this.target=t}},{key:"block",value:function(){jQuery(this.target).block({message:null,overlayCSS:{background:"#fff",opacity:.6},baseZ:1e4})}},{key:"unblock",value:function(){jQuery(this.target).unblock()}}])&&Ut(e.prototype,r),n&&Ut(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();const Vt=Jt;function Ht(t){return Ht="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ht(t)}function Wt(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Qt(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Wt(Object(r),!0).forEach(function(e){Kt(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Wt(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Kt(t,e,r){return(e=function(t){var e=function(t){if("object"!=Ht(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ht(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ht(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $t(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,s=Object.create(u.prototype);return zt(s,"_invoke",function(r,n,o){var i,c,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,c=0,u=t,p.n=r,a}};function d(r,n){for(c=r,u=n,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],d=p.p,y=i[2];r>3?(o=y===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,p.v=n,p.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,p.n=y,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,y),c=l,u=y;(e=c<2?t:u)||!f;){i||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(s=2,i){if(c||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,c<2&&(c=0)}else 1===c&&(e=i.return)&&e.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,c=1,u=e}finally{s=1}}return{value:e,done:f}}}(r,o,i),!0),s}var a={};function c(){}function u(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(zt(e={},n,function(){return this}),e),f=s.prototype=c.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,zt(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=s,zt(f,"constructor",s),zt(s,"constructor",u),u.displayName="GeneratorFunction",zt(s,o,"GeneratorFunction"),zt(f),zt(f,o,"Generator"),zt(f,n,function(){return this}),zt(f,"toString",function(){return"[object Generator]"}),($t=function(){return{w:i,m:p}})()}function zt(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}zt=function(t,e,r,n){function i(e,r){zt(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},zt(t,e,r,n)}function Zt(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function Xt(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){Zt(i,n,o,a,c,"next",t)}function c(t){Zt(i,n,o,a,c,"throw",t)}a(void 0)})}}function Yt(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return te(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?te(t,e):void 0}}(t,e)||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 te(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ee,re,ne,oe=!1,ie=null,ae=function(t){return t.scriptData.appswitch.enabled&&!t.scriptData.final_review_enabled&&t.scriptData.server_side_shipping_callback.enabled},ce=function(t){var e=t.config,r=t.onClick,n=t.onClose,o=t.onSubmit,c=t.onError,u=t.eventRegistration,s=t.emitResponse,l=t.activePaymentMethod,f=t.shippingData,p=t.isEditing,d=t.fundingSource,y=t.buttonAttributes,v=u.onPaymentSetup,b=u.onCheckoutFail,m=u.onCheckoutValidation,h=s.responseTypes,g=Yt((0,et.useState)(null),2),w=g[0],S=g[1],O=Yt((0,et.useState)(!1),2),_=O[0],j=O[1],E=Yt((0,et.useState)(!1),2),P=E[0],k=E[1],A=Yt((0,et.useState)(!1),2),T=A[0],D=A[1],R=Yt((0,et.useState)(!1),2),C=R[0],x=R[1],N=(0,Ft.useRef)(null),M=(0,Ft.useRef)(null);T||(ie||(ie=I("ppcpBlocksPaypalExpressButtons",e.scriptData)),ie.then(function(){return D(!0)}));var B=d?"".concat(e.id,"-").concat(d):e.id;(0,et.useEffect)(function(){C?(M.current||(M.current=Vt.fullPage()),M.current.block()):M.current&&M.current.unblock()},[C]),(0,et.useEffect)(function(){var t;if(!_&&null!==(t=e.scriptData.continuation)&&void 0!==t&&t.order){try{var r=lt(e.scriptData.continuation.order),n=wp.data.select("wc/store/cart").getCustomerData(),o=pt(n,r);wp.data.dispatch("wc/store/cart").setBillingAddress(o.billingAddress),f.needsShipping&&wp.data.dispatch("wc/store/cart").setShippingAddress(o.shippingAddress)}catch(t){console.error(t)}j(!0)}},[f.needsShipping,_]);var F=function(){var t=new URL(e.scriptData.redirect);return t.searchParams.append("ppcp-continuation-redirect",(new Date).getTime().toString()),t.toString()};(0,et.useEffect)(function(){return m(function(){return!!e.scriptData.continuation||!P||!wp.data.select("wc/store/validation").hasValidationErrors()||(location.href=F(),{type:h.ERROR})})},[m,P]);var G=function(t,e){if(p)return e.reject();window.ppcpFundingSource=t.fundingSource,r()},L=function(){ae(e)||n()},U=function(){return q()&&e.needShipping},q=function(){return!(e.finalReviewEnabled||"venmo"===window.ppcpFundingSource&&e.scriptData.vaultingEnabled)},J=null,V=null;if(f.needsShipping&&U()&&(J=function(){var t=Xt($t().m(function t(r,n){var o,i,a,c,u;return $t().w(function(t){for(;;)switch(t.p=t.n){case 0:if(t.p=0,!(i=null===(o=r.selectedShippingOption)||void 0===o?void 0:o.id)){t.n=2;break}return t.n=1,wp.data.dispatch("wc/store/cart").selectShippingRate(i);case 1:return t.n=2,f.setSelectedRates(i);case 2:return t.n=3,fetch(e.ajax.update_shipping.endpoint,{method:"POST",credentials:"same-origin",body:JSON.stringify({nonce:e.ajax.update_shipping.nonce,order_id:r.orderID})});case 3:return a=t.v,t.n=4,a.json();case 4:if((c=t.v).success){t.n=5;break}throw new Error(c.data.message);case 5:t.n=7;break;case 6:t.p=6,u=t.v,console.error(u),n.reject();case 7:return t.a(2)}},t,null,[[0,6]])}));return function(_x,e){return t.apply(this,arguments)}}(),V=function(){var t=Xt($t().m(function t(r,n){var o,i,a,c;return $t().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,o=ut(dt(r.shippingAddress)),t.n=1,wp.data.dispatch("wc/store/cart").updateCustomerData({shipping_address:o});case 1:return t.n=2,f.setShippingAddress(o);case 2:return t.n=3,fetch(e.ajax.update_shipping.endpoint,{method:"POST",credentials:"same-origin",body:JSON.stringify({nonce:e.ajax.update_shipping.nonce,order_id:r.orderID})});case 3:return i=t.v,t.n=4,i.json();case 4:if((a=t.v).success){t.n=5;break}throw new Error(a.data.message);case 5:t.n=7;break;case 6:t.p=6,c=t.v,console.error(c),n.reject();case 7:return t.a(2)}},t,null,[[0,6]])}));return function(e,r){return t.apply(this,arguments)}}()),(0,et.useEffect)(function(){if(l===B){var t=v(function(){var t,r,n;if(a(e.scriptData)&&e.scriptData.is_free_trial_cart)return{type:h.SUCCESS};if(e.scriptData.continuation)return{type:h.SUCCESS,meta:{paymentMethodData:{paypal_order_id:e.scriptData.continuation.order_id,funding_source:null!==(n=window.ppcpFundingSource)&&void 0!==n?n:"paypal"}}};var o={};return null!==(t=w.purchase_units)&&void 0!==t&&null!==(t=t[0])&&void 0!==t&&null!==(t=t.shipping)&&void 0!==t&&t.address&&(o=lt(w)),{type:h.SUCCESS,meta:Qt({paymentMethodData:{paypal_order_id:w.id,funding_source:null!==(r=window.ppcpFundingSource)&&void 0!==r?r:"paypal"}},o)}});return function(){t()}}},[v,w,l]),(0,et.useEffect)(function(){return b(function(){x(!1)})},[b]),(0,et.useEffect)(function(){if(l===B)return b(function(t){var r=t.processingResponse;return console.error(r),n&&n(),e.scriptData.continuation||a(e.scriptData)&&e.scriptData.is_free_trial_cart||q()&&(location.href=F()),!0})},[b,n,l]),e.scriptData.continuation)return React.createElement("div",{dangerouslySetInnerHTML:{__html:e.scriptData.continuation.cancel.html}});oe||(gt.registerContextBootstrap(e.scriptData.context,{createOrder:function(t){return Ct(t,e,c,n)},onApprove:function(t,r){return xt(t,r,e,U,f,S,q,F,k,o,c,n,x)}}),oe=!0);var H=_t(e.scriptData.button.style,d);if(void 0!==y&&(H.height=null!=y&&y.height?Number(y.height):H.height,H.borderRadius=null!=y&&y.borderRadius?Number(y.borderRadius):H.borderRadius),!T)return null;var W=ppcpBlocksPaypalExpressButtons.Buttons.driver("react",{React,ReactDOM}),Q=function(t){return e.scriptData.server_side_shipping_callback.enabled||"venmo"===t?null:function(t,e){U()&&J(t,e)}},K=function(t){return e.scriptData.server_side_shipping_callback.enabled||"venmo"===t?null:function(t,e){return U()?V(t,e):null}};return a(e.scriptData)&&e.scriptData.is_free_trial_cart?React.createElement(W,{style:H,onClick:G,onCancel:L,onError:n,createVaultSetupToken:function(){return Mt(e)},onApprove:function(t){var r=t.vaultSetupToken;return Bt(r,e,o)}}):i(e.scriptData)?React.createElement(W,{fundingSource:d,style:H,onClick:G,onCancel:L,onError:n,createSubscription:function(t,r){return It(t,r,e)},onApprove:function(t,r){return Nt(t,r,e,U,f,S,q,F,k,o,c,n)},onShippingOptionsChange:Q(d),onShippingAddressChange:K(d)}):React.createElement(W,{ref:N,appSwitchWhenAvailable:ae(e),fundingSource:d,style:H,onInit:function(){if("paypal"===d){var t,e,r=null===(t=N.current)||void 0===t||null===(t=t.state)||void 0===t?void 0:t.parent;null!=r&&null!==(e=r.hasReturned)&&void 0!==e&&e.call(r)&&r.resume()}},onClick:G,onCancel:L,onError:n,createOrder:function(t){return Ct(t,e,c,n)},onApprove:function(t,r){return xt(t,r,e,U,f,S,q,F,k,o,c,n,x)},onShippingOptionsChange:Q(d),onShippingAddressChange:K(d)})};!function(t){t.INITIAL="initial",t.PENDING="pending",t.REJECTED="rejected",t.RESOLVED="resolved"}(ee||(ee={})),function(t){t.LOADING_STATUS="setLoadingStatus",t.RESET_OPTIONS="resetOptions",t.SET_BRAINTREE_INSTANCE="braintreeInstance"}(re||(re={})),function(t){t.NUMBER="number",t.CVV="cvv",t.EXPIRATION_DATE="expirationDate",t.EXPIRATION_MONTH="expirationMonth",t.EXPIRATION_YEAR="expirationYear",t.POSTAL_CODE="postalCode"}(ne||(ne={}));var ue=function(){return ue=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},ue.apply(this,arguments)};function se(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}function le(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}"function"==typeof SuppressedError&&SuppressedError;var fe="data-react-paypal-script-id",pe="react-paypal-js",de="dataNamespace",ye="dataSdkIntegrationSource",ve="3.117.0",be=("https://js.braintreegateway.com/web/".concat(ve,"/js/client.min.js"),"https://js.braintreegateway.com/web/".concat(ve,"/js/paypal-checkout.min.js"),"paypal");function me(t){return void 0===t&&(t=be),window[t]}function he(t){var e=t.reactComponentName,r=t.sdkComponentKey,n=t.sdkRequestedComponents,o=void 0===n?"":n,i=t.sdkDataNamespace,a=void 0===i?be:i,c=r.charAt(0).toUpperCase().concat(r.substring(1)),u="Unable to render <".concat(e," /> because window.").concat(a,".").concat(c," is undefined."),s="string"==typeof o?o:o.join(",");if(!s.includes(r)){var l=[s,r].filter(Boolean).join();u+="\nTo fix the issue, add '".concat(r,"' to the list of components passed to the parent PayPalScriptProvider:")+"\n`<PayPalScriptProvider options={{ components: '".concat(l,"'}}>`.")}return u}function ge(t){var e=t,r=fe;e[r];var n=se(e,[r+""]);return"react-paypal-js-".concat(function(t){for(var e="",r=0;r<t.length;r++){var n=t[r].charCodeAt(0)*r;t[r+1]&&(n+=t[r+1].charCodeAt(0)*(r-1)),e+=String.fromCharCode(97+Math.abs(n)%26)}return e}(JSON.stringify(n)))}function we(t,e){var r,n,o,i;switch(e.type){case re.LOADING_STATUS:return"object"==typeof e.value?ue(ue({},t),{loadingStatus:e.value.state,loadingStatusErrorMessage:e.value.message}):ue(ue({},t),{loadingStatus:e.value});case re.RESET_OPTIONS:return o=t.options[fe],(null==(i=self.document.querySelector("script[".concat(fe,'="').concat(o,'"]')))?void 0:i.parentNode)&&i.parentNode.removeChild(i),ue(ue({},t),{loadingStatus:ee.PENDING,options:ue(ue((r={},r[ye]=pe,r),e.value),(n={},n[fe]="".concat(ge(e.value)),n))});case re.SET_BRAINTREE_INSTANCE:return ue(ue({},t),{braintreePayPalCheckoutInstance:e.value});default:return t}}var Se=(0,Ft.createContext)(null);function Oe(){var t=function(t){if("function"==typeof(null==t?void 0:t.dispatch)&&0!==t.dispatch.length)return t;throw new Error("usePayPalScriptReducer must be used within a PayPalScriptProvider")}((0,Ft.useContext)(Se));return[ue(ue({},t),{isInitial:t.loadingStatus===ee.INITIAL,isPending:t.loadingStatus===ee.PENDING,isResolved:t.loadingStatus===ee.RESOLVED,isRejected:t.loadingStatus===ee.REJECTED}),t.dispatch]}(0,Ft.createContext)({});var _e=function(t){var e,r,n,o=t.className,i=void 0===o?"":o,a=t.disabled,c=void 0!==a&&a,u=t.children,s=t.forceReRender,l=void 0===s?[]:s,f=se(t,["className","disabled","children","forceReRender"]),p=c?{opacity:.38}:{},d="".concat(i," ").concat(c?"paypal-buttons-disabled":"").trim(),y=(0,Ft.useRef)(null),v=(0,Ft.useRef)(null),b=(r=f,n=(0,Ft.useRef)(new Proxy({},{get:function(t,e,r){return"function"==typeof t[e]?function(){for(var r=[],n=0;n<arguments.length;n++)r[n]=arguments[n];return t[e].apply(t,r)}:Reflect.get(t,e,r)}})),n.current=Object.assign(n.current,r),n.current),m=Oe()[0],h=m.isResolved,g=m.options,w=(0,Ft.useState)(null),S=w[0],O=w[1],_=(0,Ft.useState)(!0),j=_[0],E=_[1],P=(0,Ft.useState)(null)[1];function k(){null!==v.current&&v.current.close().catch(function(){})}return(null===(e=v.current)||void 0===e?void 0:e.updateProps)&&v.current.updateProps({message:f.message}),(0,Ft.useEffect)(function(){if(!1===h)return k;var t=me(g.dataNamespace);if(void 0===t||void 0===t.Buttons)return P(function(){throw new Error(he({reactComponentName:_e.displayName,sdkComponentKey:"buttons",sdkRequestedComponents:g.components,sdkDataNamespace:g[de]}))}),k;try{v.current=t.Buttons(ue(ue({},b),{onInit:function(t,e){O(e),"function"==typeof f.onInit&&f.onInit(t,e)}}))}catch(t){return P(function(){throw new Error("Failed to render <PayPalButtons /> component. Failed to initialize: ".concat(t))})}return!1===v.current.isEligible()?(E(!1),k):y.current?(v.current.render(y.current).catch(function(t){null!==y.current&&0!==y.current.children.length&&P(function(){throw new Error("Failed to render <PayPalButtons /> component. ".concat(t))})}),k):k},le(le([h],l,!0),[f.fundingSource],!1)),(0,Ft.useEffect)(function(){null!==S&&(!0===c?S.disable().catch(function(){}):S.enable().catch(function(){}))},[c,S]),Gt().createElement(Gt().Fragment,null,j?Gt().createElement("div",{ref:y,style:p,className:d}):u)};function je(t,e){void 0===e&&(e={});var r=document.createElement("script");return r.src=t,Object.keys(e).forEach(function(t){r.setAttribute(t,e[t]),"data-csp-nonce"===t&&r.setAttribute("nonce",e["data-csp-nonce"])}),r}function Ee(t,e){if(void 0===e&&(e=Promise),ke(t,e),"undefined"==typeof document)return e.resolve(null);var r=function(t){var e,r,n=t.sdkBaseUrl,o=t.environment,i=function(t,e){var r={};for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&e.indexOf(n)<0&&(r[n]=t[n]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(n=Object.getOwnPropertySymbols(t);o<n.length;o++)e.indexOf(n[o])<0&&Object.prototype.propertyIsEnumerable.call(t,n[o])&&(r[n[o]]=t[n[o]])}return r}(t,["sdkBaseUrl","environment"]),a=n||function(t){return"sandbox"===t?"https://www.sandbox.paypal.com/sdk/js":"https://www.paypal.com/sdk/js"}(o),c=i,u=Object.keys(c).filter(function(t){return void 0!==c[t]&&null!==c[t]&&""!==c[t]}).reduce(function(t,e){var r,n=c[e].toString();return r=function(t,e){return(e?"-":"")+t.toLowerCase()},"data"===(e=e.replace(/[A-Z]+(?![a-z])|[A-Z]/g,r)).substring(0,4)||"crossorigin"===e?t.attributes[e]=n:t.queryParams[e]=n,t},{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((e=s,r="",Object.keys(e).forEach(function(t){0!==r.length&&(r+="&"),r+=t+"="+e[t]}),r)),attributes:l}}(t),n=r.url,o=r.attributes,i=o["data-namespace"]||"paypal",a=Pe(i);return o["data-js-sdk-library"]||(o["data-js-sdk-library"]="paypal-js"),function(t,e){var r=document.querySelector('script[src="'.concat(t,'"]'));if(null===r)return null;var n=je(t,e),o=r.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(n.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach(function(t){o.dataset[t]!==n.dataset[t]&&(i=!1)}),i?r:null}(n,o)&&a?e.resolve(a):function(t,e){void 0===e&&(e=Promise),ke(t,e);var r=t.url,n=t.attributes;if("string"!=typeof r||0===r.length)throw new Error("Invalid url.");if(void 0!==n&&"object"!=typeof n)throw new Error("Expected attributes to be an object.");return new e(function(t,e){if("undefined"==typeof document)return t();!function(t){var e=t.url,r=t.attributes,n=t.onSuccess,o=t.onError,i=je(e,r);i.onerror=o,i.onload=n,document.head.insertBefore(i,document.head.firstElementChild)}({url:r,attributes:n,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(r,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(t)}})})}({url:n,attributes:o},e).then(function(){var t=Pe(i);if(t)return t;throw new Error("The window.".concat(i," global variable is not available."))})}function Pe(t){return window[t]}function ke(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");var r=t.environment;if(r&&"production"!==r&&"sandbox"!==r)throw new Error('The `environment` option must be either "production" or "sandbox".');if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}_e.displayName="PayPalButtons","function"==typeof SuppressedError&&SuppressedError;var Ae=function(t){var e=t.className,r=void 0===e?"":e,n=t.children,o=se(t,["className","children"]),i=Oe()[0],a=i.isResolved,c=i.options,u=(0,Ft.useRef)(null),s=(0,Ft.useState)(!0),l=s[0],f=s[1],p=(0,Ft.useState)(null)[1];return(0,Ft.useEffect)(function(){if(!1!==a){var t=me(c[de]);if(void 0===t||void 0===t.Marks)return p(function(){throw new Error(he({reactComponentName:Ae.displayName,sdkComponentKey:"marks",sdkRequestedComponents:c.components,sdkDataNamespace:c[de]}))});!function(t){var e=u.current;if(!e||!t.isEligible())return f(!1);e.firstChild&&e.removeChild(e.firstChild),t.render(e).catch(function(t){null!==e&&0!==e.children.length&&p(function(){throw new Error("Failed to render <PayPalMarks /> component. ".concat(t))})})}(t.Marks(ue({},o)))}},[a,o.fundingSource]),Gt().createElement(Gt().Fragment,null,l?Gt().createElement("div",{ref:u,className:r}):n)};Ae.displayName="PayPalMarks";var Te=function(t){var e=t.className,r=void 0===e?"":e,n=t.forceReRender,o=void 0===n?[]:n,i=se(t,["className","forceReRender"]),a=Oe()[0],c=a.isResolved,u=a.options,s=(0,Ft.useRef)(null),l=(0,Ft.useRef)(null),f=(0,Ft.useState)(null)[1];return(0,Ft.useEffect)(function(){if(!1!==c){var t=me(u[de]);if(void 0===t||void 0===t.Messages)return f(function(){throw new Error(he({reactComponentName:Te.displayName,sdkComponentKey:"messages",sdkRequestedComponents:u.components,sdkDataNamespace:u[de]}))});l.current=t.Messages(ue({},i)),l.current.render(s.current).catch(function(t){null!==s.current&&0!==s.current.children.length&&f(function(){throw new Error("Failed to render <PayPalMessages /> component. ".concat(t))})})}},le([c],o,!0)),Gt().createElement("div",{ref:s,className:r})};Te.displayName="PayPalMessages";var De=function(t){var e,r=t.options,n=void 0===r?{clientId:"test"}:r,o=t.children,i=t.deferLoading,a=void 0!==i&&i,c=(0,Ft.useReducer)(we,{options:ue(ue({},n),(e={},e.dataJsSdkLibrary=pe,e[ye]=pe,e[fe]="".concat(ge(n)),e)),loadingStatus:a?ee.INITIAL:ee.PENDING}),u=c[0],s=c[1];return(0,Ft.useEffect)(function(){if(!1===a&&u.loadingStatus===ee.INITIAL)return s({type:re.LOADING_STATUS,value:ee.PENDING});if(u.loadingStatus===ee.PENDING){var t=!0;return Ee(u.options).then(function(){t&&s({type:re.LOADING_STATUS,value:ee.RESOLVED})}).catch(function(e){console.error("".concat("Failed to load the PayPal JS SDK script."," ").concat(e)),t&&s({type:re.LOADING_STATUS,value:{state:ee.REJECTED,message:String(e)}})}),function(){t=!1}}},[u.options,a,u.loadingStatus]),Gt().createElement(Se.Provider,{value:ue(ue({},u),{dispatch:s})},o)};function Re(){}function Ce(t){return Ce="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Ce(t)}function xe(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}function Ie(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?xe(Object(r),!0).forEach(function(e){Ne(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):xe(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Ne(t,e,r){return(e=function(t){var e=function(t){if("object"!=Ce(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ce(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ce(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}(0,Ft.createContext)({cardFieldsForm:null,fields:{},registerField:Re,unregisterField:Re});var Me=function(t){var e=t.config,r=t.fundingSource,n=t.buttonAttributes,o=(0,et.useMemo)(function(){return Ie(Ie({clientId:"test"},e.scriptData.url_params),{},{dataNamespace:"ppcp-blocks-editor-paypal-buttons",components:"buttons"})},[]),i=(0,et.useMemo)(function(){var t=_t(e.scriptData.button.style,r);return n?Ie(Ie({},t),{},{height:n.height?Number(n.height):t.height,borderRadius:n.borderRadius?Number(n.borderRadius):t.borderRadius}):t},[r,n]);return React.createElement(De,{options:o},React.createElement(_e,{className:"ppc-button-container-".concat(r),fundingSource:r,style:i,forceReRender:[n||{}],onClick:function(){return!1}}))},Be=function(t){var e=t.components,r=t.config,n=e.PaymentMethodIcons;return React.createElement(React.Fragment,null,React.createElement("span",{dangerouslySetInnerHTML:{__html:r.title}}),React.createElement(n,{icons:r.icon,align:"right"}))},Fe=function(t){var e=t.description,r=t.placeOrderButtonDescription;return r?React.createElement("div",null,React.createElement("p",{dangerouslySetInnerHTML:{__html:e}}),React.createElement("p",{style:{textAlign:"center"},className:"ppcp-place-order-description",dangerouslySetInnerHTML:{__html:r}})):React.createElement("div",{dangerouslySetInnerHTML:{__html:e}})};function Ge(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,s=Object.create(u.prototype);return Le(s,"_invoke",function(r,n,o){var i,c,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,c=0,u=t,p.n=r,a}};function d(r,n){for(c=r,u=n,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],d=p.p,y=i[2];r>3?(o=y===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,p.v=n,p.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,p.n=y,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,y),c=l,u=y;(e=c<2?t:u)||!f;){i||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(s=2,i){if(c||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,c<2&&(c=0)}else 1===c&&(e=i.return)&&e.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,c=1,u=e}finally{s=1}}return{value:e,done:f}}}(r,o,i),!0),s}var a={};function c(){}function u(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(Le(e={},n,function(){return this}),e),f=s.prototype=c.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,Le(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=s,Le(f,"constructor",s),Le(s,"constructor",u),u.displayName="GeneratorFunction",Le(s,o,"GeneratorFunction"),Le(f),Le(f,o,"Generator"),Le(f,n,function(){return this}),Le(f,"toString",function(){return"[object Generator]"}),(Ge=function(){return{w:i,m:p}})()}function Le(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Le=function(t,e,r,n){function i(e,r){Le(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},Le(t,e,r,n)}function Ue(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function qe(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){Ue(i,n,o,a,c,"next",t)}function c(t){Ue(i,n,o,a,c,"throw",t)}a(void 0)})}}function Je(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return Ve(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Ve(t,e):void 0}}(t,e)||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 Ve(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var He="ppcpVaultComponent",We=null,Qe=function(t){var e=t.config,r=t.onApproveOrder,n=t.onRenderError,o=(0,et.useRef)(null),i=(0,et.useRef)(null),a=Je((0,et.useState)(!1),2),c=a[0],s=a[1],l=Je((0,et.useState)(!1),2),f=l[0],p=l[1],d=e.scriptData.vault_component;return(0,et.useEffect)(function(){var t;if(null!==(t=window[He])&&void 0!==t&&t.SavedPaymentMethods)s(!0);else{if(!We){var r,o={clientId:e.scriptData.client_id,components:"saved-payment-methods,buttons,messages",commit:"false","data-namespace":He,"data-sdk-client-token":d.sdk_client_token},i=null===(r=e.scriptData.script_attributes)||void 0===r?void 0:r.sdkBaseUrl;i&&(o.sdkBaseUrl=i),We=u(o)}We.then(function(){return s(!0)}).catch(function(t){console.error("Failed to load PayPal SDK for Vault:",t),We=null,p(!0),null==n||n()})}},[]),(0,et.useEffect)(function(){if(c&&o.current&&!i.current){var t,e,a=window[He];if(null==a||!a.SavedPaymentMethods)return console.error("PayPal SavedPaymentMethods SDK component not available."),p(!0),void(null==n||n());try{i.current=a.SavedPaymentMethods({createOrder:(e=qe(Ge().m(function t(){var e,r,n;return Ge().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,fetch(d.ajax.create_order.endpoint,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify({nonce:d.ajax.create_order.nonce,vault_token_id:d.token_id})});case 1:return e=t.v,t.n=2,e.json();case 2:if((r=t.v).success){t.n=3;break}throw new Error((null===(n=r.data)||void 0===n?void 0:n.message)||"Order creation failed.");case 3:return t.a(2,r.data.id)}},t)})),function(){return e.apply(this,arguments)}),onApprove:(t=qe(Ge().m(function t(e){return Ge().w(function(t){for(;;)switch(t.n){case 0:null==r||r(e.orderID);case 1:return t.a(2)}},t)})),function(_x){return t.apply(this,arguments)}),onCancel:function(){},onError:function(t){console.error("Vault Component error:",t)}}),i.current.render(o.current).catch(function(t){console.error("Vault Component render failed:",t),p(!0),null==n||n()})}catch(t){console.error("Vault Component init failed:",t),p(!0),null==n||n()}return function(){var t,e;null===(t=i.current)||void 0===t||null===(e=t.close)||void 0===e||e.call(t),i.current=null}}},[c]),f?null:React.createElement("div",{id:"ppcp-vault-component-container",ref:o,style:{minHeight:"48px"}})};function Ke(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,a,c=[],u=!0,s=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=i.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(s)throw o}}return c}}(t,e)||function(t,e){if(t){if("string"==typeof t)return $e(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?$e(t,e):void 0}}(t,e)||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 $e(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var ze=function(t){var e,r,n=t.config,o=t.token,i=t.eventRegistration,a=t.emitResponse,c=i.onPaymentSetup,u=a.responseTypes,s=Ke((0,et.useState)(null),2),l=s[0],f=s[1],p=Ke((0,et.useState)(!1),2),d=p[0],y=p[1],v=Ke((0,et.useState)(null),2),b=v[0],m=v[1],h=null==n||null===(e=n.scriptData)||void 0===e?void 0:e.vault_component,g=!0===(null==h?void 0:h.is_eligible),w=o&&"0"!==o&&0!==o,S=!0===(null==n||null===(r=n.scriptData)||void 0===r?void 0:r.is_free_trial_cart),O=g&&w&&!S&&!d,_=(0,et.useCallback)(function(){y(!0)},[]),j=(0,et.useCallback)(function(t){f(t)},[]);return(0,et.useEffect)(function(){return c(function(){return l?{type:u.SUCCESS,meta:{paymentMethodData:{paypal_order_id:l,funding_source:"paypal"}}}:{type:u.SUCCESS}})},[c,u,l]),(0,et.useLayoutEffect)(function(){var t,e;if(O){var r=function(t){var e;if(!t)return null;var r=document.querySelector('input[name="radio-control-wc-payment-method-saved-tokens"][value="'.concat(t,'"]'));return null!==(e=null==r?void 0:r.closest(".wc-block-components-radio-control__option"))&&void 0!==e?e:null}(null==h?void 0:h.wc_token_id);if(r){var n=null!==(t=r.querySelector(".wc-block-components-radio-control__option-layout"))&&void 0!==t?t:r.querySelector(".wc-block-components-radio-control__label"),o=null!==(e=null==n?void 0:n.style.display)&&void 0!==e?e:"";n&&(n.style.display="none");var i=document.createElement("div");return i.id="ppcp-vault-component",r.appendChild(i),m(i),function(){n&&(n.style.display=o),i.remove()}}m(null)}else m(null)},[O,null==h?void 0:h.wc_token_id]),O&&b?(0,et.createPortal)(React.createElement(Qe,{config:n,onApproveOrder:j,onRenderError:_}),b):null};function Ze(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var u=n&&n.prototype instanceof c?n:c,s=Object.create(u.prototype);return Xe(s,"_invoke",function(r,n,o){var i,c,u,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:d,f:d.bind(t,4),d:function(e,r){return i=e,c=0,u=t,p.n=r,a}};function d(r,n){for(c=r,u=n,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],d=p.p,y=i[2];r>3?(o=y===n)&&(u=i[(c=i[4])?5:(c=3,3)],i[4]=i[5]=t):i[0]<=d&&((o=r<2&&d<i[1])?(c=0,p.v=n,p.n=i[1]):d<y&&(o=r<3||i[0]>n||n>y)&&(i[4]=r,i[5]=n,p.n=y,c=0))}if(o||r>1)return a;throw f=!0,n}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&d(l,y),c=l,u=y;(e=c<2?t:u)||!f;){i||(c?c<3?(c>1&&(p.n=-1),d(c,u)):p.n=u:p.v=u);try{if(s=2,i){if(c||(o="next"),e=i[o]){if(!(e=e.call(i,u)))throw TypeError("iterator result is not an object");if(!e.done)return e;u=e.value,c<2&&(c=0)}else 1===c&&(e=i.return)&&e.call(i),c<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),c=1);i=t}else if((e=(f=p.n<0)?u:r.call(n,p))!==a)break}catch(e){i=t,c=1,u=e}finally{s=1}}return{value:e,done:f}}}(r,o,i),!0),s}var a={};function c(){}function u(){}function s(){}e=Object.getPrototypeOf;var l=[][n]?e(e([][n]())):(Xe(e={},n,function(){return this}),e),f=s.prototype=c.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,Xe(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return u.prototype=s,Xe(f,"constructor",s),Xe(s,"constructor",u),u.displayName="GeneratorFunction",Xe(s,o,"GeneratorFunction"),Xe(f),Xe(f,o,"Generator"),Xe(f,n,function(){return this}),Xe(f,"toString",function(){return"[object Generator]"}),(Ze=function(){return{w:i,m:p}})()}function Xe(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Xe=function(t,e,r,n){function i(e,r){Xe(t,e,function(t){return this._invoke(e,r,t)})}e?o?o(t,e,{value:r,enumerable:!n,configurable:!n,writable:!n}):t[e]=r:(i("next",0),i("throw",1),i("return",2))},Xe(t,e,r,n)}function Ye(t,e,r,n,o,i,a){try{var c=t[i](a),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function tr(t,e){if(t){if("string"==typeof t)return er(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?er(t,e):void 0}}function er(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var rr=wc.wcSettings.getSetting("ppcp-gateway_data");window.ppcpFundingSource=rr.fundingSource;var nr,or,ir,ar=null,cr=["products"],ur=!0;if(a(rr.scriptData)&&(nr=rr.scriptData,ur=!(a(nr)&&(!(null!==(or=nr.user)&&void 0!==or&&or.is_logged||"cart-block"!==nr.context)&&nr.is_free_trial_cart||(void 0!==nr.subscription_button_allowed?!nr.subscription_button_allowed:!i(nr)&&!nr.can_save_vault_token||i(nr)&&!nr.subscription_product_allowed))),cr.push("subscriptions")),ur)if(rr.placeOrderEnabled&&!rr.scriptData.continuation&&((0,n.registerPaymentMethod)({name:rr.id,label:React.createElement(Be,{config:rr}),content:React.createElement(Fe,{config:rr,description:rr.description,placeOrderButtonDescription:rr.placeOrderButtonDescription}),savedTokenComponent:React.createElement(ze,{config:rr}),edit:React.createElement("div",{dangerouslySetInnerHTML:{__html:rr.description}}),placeOrderButtonLabel:rr.placeOrderButtonText,ariaLabel:rr.title,canMakePayment:function(t){var e;if(rr.scriptData.is_free_trial_cart)return!0;var r=null==t||null===(e=t.cartTotals)||void 0===e?void 0:e.total_price;return parseInt(r)>0},supports:{features:cr,showSavedCards:!0}}),(0,window.wc.blocksCheckout.registerCheckoutFilters)(rr.id,{placeOrderButtonLabel:function(t){var e,r=null===(e=window.wp)||void 0===e||null===(e=e.data)||void 0===e?void 0:e.select("wc/store/payment");return(null==r?void 0:r.getActivePaymentMethod())===rr.id?rr.placeOrderButtonText:t}})),rr.scriptData.continuation)(0,n.registerPaymentMethod)({name:rr.id,label:React.createElement("div",{dangerouslySetInnerHTML:{__html:rr.title}}),content:React.createElement(ce,{config:rr,isEditing:!1}),edit:React.createElement(Me,{config:rr,fundingSource:"paypal"}),ariaLabel:rr.title,canMakePayment:function(){return!0},supports:{features:[].concat(cr,["ppcp_continuation"])}});else if(rr.smartButtonsEnabled){var sr,lr=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=tr(t))){e&&(t=e);var _n=0,r=function(){};return{s:r,n:function(){return _n>=t.length?{done:!0}:{done:!1,value:t[_n++]}},e:function(t){throw t},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 n,o=!0,i=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){i=!0,n=t},f:function(){try{o||null==e.return||e.return()}finally{if(i)throw n}}}}(rr.scriptData.is_free_trial_cart?["paypal"]:["paypal"].concat(function(t){if(Array.isArray(t))return er(t)}(ir=rr.enabledFundingSources)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(ir)||tr(ir)||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.")}()));try{var fr=function(){var t,e,r=sr.value;(0,n.registerExpressPaymentMethod)({name:"".concat(rr.id,"-").concat(r),title:"PayPal",description:(0,o.__)("Eligible users will see the PayPal button.","woocommerce-paypal-payments"),gatewayId:"ppcp-gateway",paymentMethodId:rr.id,label:React.createElement("div",{dangerouslySetInnerHTML:{__html:rr.title}}),content:React.createElement(ce,{config:rr,isEditing:!1,fundingSource:r}),edit:React.createElement(Me,{config:rr,fundingSource:r}),ariaLabel:rr.title,canMakePayment:(t=Ze().m(function t(){return Ze().w(function(t){for(;;)switch(t.n){case 0:return ar||(ar=I("ppcpBlocksPaypalExpressButtons",rr.scriptData)).then(function(){new tt(rr.scriptData).init()}),t.n=1,ar;case 1:return t.a(2,ppcpBlocksPaypalExpressButtons.Buttons({fundingSource:r}).isEligible())}},t)}),e=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){Ye(i,n,o,a,c,"next",t)}function c(t){Ye(i,n,o,a,c,"throw",t)}a(void 0)})},function(){return e.apply(this,arguments)}),supports:{features:cr,style:["height","borderRadius"],showSavedCards:!0}})};for(lr.s();!(sr=lr.n()).done;)fr()}catch(t){lr.e(t)}finally{lr.f()}}})(); |