mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2026-07-29 02:07:27 +08:00
4 lines
No EOL
73 KiB
JavaScript
4 lines
No EOL
73 KiB
JavaScript
(()=>{"use strict";const t=window.wc.wcBlocksRegistry,e=window.wp.element,r=window.wp.i18n;function n(t){return n="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},n(t)}function o(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",a=r.toStringTag||"@@toStringTag";function u(r,n,o,a){var u=n&&n.prototype instanceof l?n:l,f=Object.create(u.prototype);return i(f,"_invoke",function(r,n,o){var i,a,u,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,a=0,u=t,p.n=r,c}};function y(r,n){for(a=r,u=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(u=i[(a=i[4])?5:(a=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(a=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,a=0))}if(o||r>1)return c;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),a=f,u=d;(e=a<2?t:u)||!s;){i||(a?a<3?(a>1&&(p.n=-1),y(a,u)):p.n=u:p.v=u);try{if(l=2,i){if(a||(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,a<2&&(a=0)}else 1===a&&(e=i.return)&&e.call(i),a<2&&(u=TypeError("The iterator does not provide a '"+o+"' method"),a=1);i=t}else if((e=(s=p.n<0)?u:r.call(n,p))!==c)break}catch(e){i=t,a=1,u=e}finally{l=1}}return{value:e,done:s}}}(r,o,a),!0),f}var c={};function l(){}function f(){}function s(){}e=Object.getPrototypeOf;var p=[][n]?e(e([][n]())):(i(e={},n,function(){return this}),e),y=s.prototype=l.prototype=Object.create(p);function d(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,i(t,a,"GeneratorFunction")),t.prototype=Object.create(y),t}return f.prototype=s,i(y,"constructor",s),i(s,"constructor",f),f.displayName="GeneratorFunction",i(s,a,"GeneratorFunction"),i(y),i(y,a,"Generator"),i(y,n,function(){return this}),i(y,"toString",function(){return"[object Generator]"}),(o=function(){return{w:u,m:d}})()}function i(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}i=function(t,e,r,n){function a(e,r){i(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:(a("next",0),a("throw",1),a("return",2))},i(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 u(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){c(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 c(t,e,r){return(e=function(t){var e=function(t){if("object"!=n(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=n(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==n(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function f(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){l(i,n,o,a,u,"next",t)}function u(t){l(i,n,o,a,u,"throw",t)}a(void 0)})}}function s(_x){return p.apply(this,arguments)}function p(){return p=f(o().m(function t(e){var r,n,i,a,c,l,f,s,p,y,d=arguments;return o().w(function(t){for(;;)switch(t.n){case 0:return r=e.endpoint,n=e.nonce,i=d.length>1&&void 0!==d[1]?d[1]:{},t.n=1,fetch(r,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json"},body:JSON.stringify(u({nonce:n},i))});case 1:return a=t.v,t.n=2,a.json();case 2:if((c=t.v).success){t.n=3;break}throw(y=new Error((null===(l=c.data)||void 0===l?void 0:l.message)||"")).isUserFacing=Boolean(null===(f=c.data)||void 0===f?void 0:f.message),y.errors=null===(s=c.data)||void 0===s?void 0:s.errors,y.refresh=Boolean(null===(p=c.data)||void 0===p?void 0:p.refresh),y;case 3:return t.a(2,c.data)}},t)})),p.apply(this,arguments)}function y(t,e,r){return d.apply(this,arguments)}function d(){return(d=f(o().m(function t(e,r,n){return o().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,fetch(r,{method:"POST",credentials:"same-origin",headers:{"Content-Type":"application/json",Nonce:e.nonce},body:JSON.stringify(n)});case 1:if(t.v.ok){t.n=2;break}throw new Error("Store API request failed.");case 2:return t.a(2)}},t)}))).apply(this,arguments)}function v(){return"undefined"!=typeof jQuery||(console.error("[PPCP SDK v6] jQuery not present"),!1)}function m(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return h(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(h(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,h(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,h(s,"constructor",l),h(l,"constructor",c),c.displayName="GeneratorFunction",h(l,o,"GeneratorFunction"),h(s),h(s,o,"Generator"),h(s,n,function(){return this}),h(s,"toString",function(){return"[object Generator]"}),(m=function(){return{w:i,m:p}})()}function h(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}h=function(t,e,r,n){function i(e,r){h(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))},h(t,e,r,n)}function b(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,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return g(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)?g(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 g(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 w(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}var _={},S=null,j={product:"product-details",cart:"cart",checkout:"checkout","mini-cart":"mini-cart"};function O(t){return _[t]||(_[t]=new Promise(function(e,r){var n=document.createElement("script");n.src=t,n.async=!0,n.onload=e,n.onerror=function(){n.remove(),delete _[t],r(new Error("Failed to load PayPal SDK v6 script."))},document.head.appendChild(n)})),_[t]}function P(t,e){return S||(S=function(_x,t){return k.apply(this,arguments)}(t,e).catch(function(t){throw S=null,t})),S}function k(){var t;return t=m().m(function t(e,r){var n,o,i,a,u;return m().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,Promise.all([O(e.sdk_url),s(e.ajax.client_token)]);case 1:if(o=t.v,i=b(o,2),a=i[1],null!==(n=window.paypal)&&void 0!==n&&n.createInstance){t.n=2;break}throw new Error("PayPal SDK v6 global not found after script load.");case 2:return t.n=3,window.paypal.createInstance({clientToken:a.client_token,components:["paypal-payments","venmo-payments"],pageType:j[r]||"checkout",locale:e.locale});case 3:return u=t.v,document.dispatchEvent(new CustomEvent("ppcp-sdk-v6-ready",{detail:{sdkInstance:u}})),t.a(2,u)}},t)}),k=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){w(i,n,o,a,u,"next",t)}function u(t){w(i,n,o,a,u,"throw",t)}a(void 0)})},k.apply(this,arguments)}function E(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return T(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(T(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,T(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,T(s,"constructor",l),T(l,"constructor",c),c.displayName="GeneratorFunction",T(l,o,"GeneratorFunction"),T(s),T(s,o,"Generator"),T(s,n,function(){return this}),T(s,"toString",function(){return"[object Generator]"}),(E=function(){return{w:i,m:p}})()}function T(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}T=function(t,e,r,n){function i(e,r){T(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))},T(t,e,r,n)}function A(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function C(_x,t){return x.apply(this,arguments)}function x(){var t;return t=E().m(function t(e,r){var n,o,i,a,u,c;return E().w(function(t){for(;;)switch(t.n){case 0:return n=r.currencyCode,o=r.countryCode,i=r.amount,a={currencyCode:n},o&&(a.countryCode=o),i&&(a.amount=i),t.n=1,e.findEligibleMethods(a);case 1:if(u=t.v,(c={paypal:u.isEligible("paypal"),venmo:u.isEligible("venmo"),paylater:u.isEligible("paylater"),payLaterDetails:null}).paylater)try{c.payLaterDetails=u.getDetails("paylater")}catch(t){}return t.a(2,c)}},t)}),x=function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){A(i,n,o,a,u,"next",t)}function u(t){A(i,n,o,a,u,"throw",t)}a(void 0)})},x.apply(this,arguments)}function G(t){return G="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},G(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,I(n.key),n)}}function I(t){var e=function(t){if("object"!=G(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=G(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==G(e)?e:e+""}var D=function(){return t=function t(e,r,n,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.id=e,this.quantity=r,this.variations=n,this.extra=o},(e=[{key:"data",value:function(){return{id:this.id,quantity:this.quantity,variations:this.variations,extra:this.extra}}}])&&F(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();const M=D;function R(t){return R="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},R(t)}function q(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 N(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?q(Object(r),!0).forEach(function(e){L(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):q(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function L(t,e,r){return(e=Q(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function U(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"!=R(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=R(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==R(e)?e:e+""}function H(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(H=function(){return!!t})()}function B(){return B="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=K(t)););return t}(t,e);if(n){var o=Object.getOwnPropertyDescriptor(n,e);return o.get?o.get.call(arguments.length<3?t:r):o.value}},B.apply(null,arguments)}function K(t){return K=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},K(t)}function $(t,e){return $=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$(t,e)}var J=function(t){function e(t,r,n,o){var i;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),(i=function(t,e,r){return e=K(e),function(t,e){if(e&&("object"==R(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,H()?Reflect.construct(e,r||[],K(t).constructor):e.apply(t,r))}(this,e,[t,r,null,o])).booking=n,i}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&$(t,e)}(e,t),r=e,n=[{key:"data",value:function(){return N(N({},(t=e,r=this,"function"==typeof(n=B(K(1&3?t.prototype:t),"data",r))?function(t){return n.apply(r,t)}:n)([])),{},{booking:this.booking});var t,r,n}}],n&&U(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(M);const V=J;function W(t){return W="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},W(t)}function Y(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,Z(n.key),n)}}function Z(t){var e=function(t){if("object"!=W(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=W(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==W(e)?e:e+""}var z=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()}}])&&Y(e.prototype,r),n&&Y(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}();const X=z;function tt(t){return tt="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},tt(t)}function et(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,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return rt(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)?rt(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 rt(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 nt={"#billing_email":["email_address"],"#billing_last_name":["name","surname"],"#billing_first_name":["name","given_name"],"#billing_country":["address","country_code"],"#billing_address_1":["address","address_line_1"],"#billing_address_2":["address","address_line_2"],"#billing_state":["address","admin_area_1"],"#billing_city":["address","admin_area_2"],"#billing_postcode":["address","postal_code"],"#billing_phone":["phone"]};function ot(t){var e,r,n,o,i,a,u,c;return{email_address:t.email_address,phone:t.phone,name:{surname:null===(e=t.name)||void 0===e?void 0:e.surname,given_name:null===(r=t.name)||void 0===r?void 0:r.given_name},address:{country_code:null===(n=t.address)||void 0===n?void 0:n.country_code,address_line_1:null===(o=t.address)||void 0===o?void 0:o.address_line_1,address_line_2:null===(i=t.address)||void 0===i?void 0:i.address_line_2,admin_area_1:null===(a=t.address)||void 0===a?void 0:a.admin_area_1,admin_area_2:null===(u=t.address)||void 0===u?void 0:u.admin_area_2,postal_code:null===(c=t.address)||void 0===c?void 0:c.postal_code}}}function it(){var t,e,r=null!==(t=null===(e=window)||void 0===e||null===(e=e.PayPalCommerceGateway)||void 0===e?void 0:e.payer)&&void 0!==t?t:window._PpcpPayerSessionDetails;if(!r)return null;var n,o,i,a=(i={},Object.entries(nt).forEach(function(t){var e=et(t,2),r=e[0],n=e[1],o=function(t){var e;return null===(e=document.querySelector(t))||void 0===e?void 0:e.value}(r);o&&function(t,e,r){for(var n=t,o=0;o<e.length-1;o++)n=n[e[o]]=n[e[o]]||{};n[e[e.length-1]]=r}(i,n,o)}),i.phone&&"string"==typeof i.phone&&(i.phone={phone_type:"HOME",phone_number:{national_number:i.phone}}),i);return a?(n=a,(o=function(t,e){for(var r=0,n=Object.entries(e);r<n.length;r++){var i=et(n[r],2),a=i[0],u=i[1];null!=u&&("object"===tt(u)?t[a]=o(t[a]||{},u):t[a]=u)}return t})(ot(r),ot(n))):ot(r)}function at(t){return at="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},at(t)}function ut(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 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&&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 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}function lt(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,ft(n.key),n)}}function ft(t){var e=function(t){if("object"!=at(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=at(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==at(e)?e:e+""}var st=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.cartItemKeys=e},e=[{key:"getEndpoint",value:function(){var t="/?wc-ajax=%%endpoint%%";return"undefined"!=typeof wc_cart_fragments_params&&wc_cart_fragments_params.wc_ajax_url&&(t=wc_cart_fragments_params.wc_ajax_url),t.toString().replace("%%endpoint%%","remove_from_cart")}},{key:"addFromPurchaseUnits",value:function(t){var e,r=ut(t||[]);try{for(r.s();!(e=r.n()).done;){var n,o=ut(e.value.items||[]);try{for(o.s();!(n=o.n()).done;){var i=n.value;i.cart_item_key&&this.cartItemKeys.push(i.cart_item_key)}}catch(t){o.e(t)}finally{o.f()}}}catch(t){r.e(t)}finally{r.f()}return this}},{key:"removeFromCart",value:function(){var t=this;return new Promise(function(e,r){if(t.cartItemKeys&&t.cartItemKeys.length){var n,o=t.cartItemKeys.length,i=0,a=function(){++i>=o&&e()},u=ut(t.cartItemKeys);try{for(u.s();!(n=u.n()).done;){var c=n.value,l=new URLSearchParams;l.append("cart_item_key",c),c?fetch(t.getEndpoint(),{method:"POST",credentials:"same-origin",body:l}).then(function(t){return t.json()}).then(function(){a()}).catch(function(){a()}):a()}}catch(t){u.e(t)}finally{u.f()}}else e()})}}],e&<(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();const pt=st;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 dt(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,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||mt(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 vt(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=mt(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 mt(t,e){if(t){if("string"==typeof t)return ht(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)?ht(t,e):void 0}}function ht(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,gt(n.key),n)}}function gt(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 wt=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"getPrefixedFields",value:function(t,e){var r,n={},o=vt(new FormData(t).entries());try{for(o.s();!(r=o.n()).done;){var i=dt(r.value,2),a=i[0],u=i[1];e&&!a.startsWith(e)||(n[a]=u)}}catch(t){o.e(t)}finally{o.f()}return n}},{key:"getFilteredFields",value:function(t,e,r){var n,o=new FormData(t),i={},a={},u=vt(o.entries());try{var c=function(){var t=dt(n.value,2),o=t[0],u=t[1];if(-1!==o.indexOf("[]")){var c=o;a[c]=a[c]||0,o=o.replace("[]","[".concat(a[c],"]")),a[c]++}return o?e&&-1!==e.indexOf(o)||r&&r.some(function(t){return o.startsWith(t)})?0:void(i[o]=u):0};for(u.s();!(n=u.n()).done;)c()}catch(t){u.e(t)}finally{u.f()}return i}}],null&&bt(t.prototype,null),e&&bt(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function _t(t){return _t="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},_t(t)}function St(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,jt(n.key),n)}}function jt(t){var e=function(t){if("object"!=_t(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=_t(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(e)?e:e+""}var Ot,Pt,kt,Et=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"cleanHashParams",value:function(){var t=this;if(window.location.hash){var e=window.location.hash.substring(1).split("&").filter(function(e){var r=e.split("=")[0];return!t.PAYPAL_PARAMS.includes(r)});if(e.length>0){var r="#"+e.join("&");window.history.replaceState(null,"",window.location.pathname+window.location.search+r)}else window.history.replaceState(null,"",window.location.pathname+window.location.search)}}},{key:"isResumeFlow",value:function(){return!!window.location.hash&&window.location.hash.substring(1).split("&").some(function(t){return"switch_initiated_time"===t.split("=")[0]})}},{key:"reloadButtonsIfRequired",value:function(t){this.isResumeFlow()&&(this.cleanHashParams(),jQuery(t).trigger("ppcp-reload-buttons"))}}],null&&St(t.prototype,null),e&&St(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();Ot=Et,kt=["onApprove","token","PayerID","payerID","button_session_id","billingToken","orderID","switch_initiated_time","onCancel","onError"],(Pt=jt(Pt="PAYPAL_PARAMS"))in Ot?Object.defineProperty(Ot,Pt,{value:kt,enumerable:!0,configurable:!0,writable:!0}):Ot[Pt]=kt;const Tt=Et;function At(t){return At="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},At(t)}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}function xt(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,Gt(n.key),n)}}function Gt(t){var e=function(t){if("object"!=At(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=At(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==At(e)?e:e+""}var Ft=function(){return function(t,e){return e&&xt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(function t(e,r,n,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.config=e,this.cartUpdater=r,this.formElement=n,this.errorHandler=o,this.cartHelper=null},[{key:"subscriptionsConfiguration",value:function(t){var e=this;return{createSubscription:function(r,n){return n.subscription.create({plan_id:t,custom_id:e.config.subscription_custom_id})},onApprove:function(t,r){fetch(e.config.ajax.approve_subscription.endpoint,{method:"POST",credentials:"same-origin",body:JSON.stringify({nonce:e.config.ajax.approve_subscription.nonce,order_id:t.orderID,subscription_id:t.subscriptionID})}).then(function(t){return t.json()}).then(function(){var t=e.getSubscriptionProducts();fetch(e.config.ajax.change_cart.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({nonce:e.config.ajax.change_cart.nonce,products:t})}).then(function(t){return t.json()}).then(function(t){if(!t.success)throw console.log(t),Error(t.data.message);location.href=e.config.redirect})})},onError:function(t){console.error(t),Tt.reloadButtonsIfRequired(e.config.button.wrapper)}}}},{key:"getSubscriptionProducts",value:function(){var t=document.querySelector('[name="add-to-cart"]').value;return[new M(t,1,this.variations(),this.extraFields())]}},{key:"configuration",value:function(){var t,e,r=this;return{createOrder:this.createOrder(),onApprove:(t=this,e=this.errorHandler,function(r,n){var o=X.fullPage();o.block();var i=!t.config.vaultingEnabled||"venmo"!==r.paymentSource,a={nonce:t.config.ajax.approve_order.nonce,order_id:r.orderID,funding_source:window.ppcpFundingSource,should_create_wc_order:i};return i&&r.payer&&(a.payer=r.payer),i&&r.shippingAddress&&(a.shipping_address=r.shippingAddress),fetch(t.config.ajax.approve_order.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify(a)}).then(function(t){return t.json()}).then(function(r){var o;if(!r.success)return e.genericError(),n.restart().catch(function(){e.genericError()});var i,a=null===(o=r.data)||void 0===o?void 0:o.order_received_url;i=a||t.config.redirect,setTimeout(function(){window.location.href=i},200)}).finally(function(){o.unblock()})}),onError:function(t){r.refreshMiniCart(),t&&"create-order-error"===t.type||r.errorHandler.genericError(),Tt.reloadButtonsIfRequired(r.config.button.wrapper)},onCancel:function(){r.isBookingProduct()?r.cleanCart():r.refreshMiniCart(),Tt.reloadButtonsIfRequired(r.config.button.wrapper)}}}},{key:"getProducts",value:function(){var t=this;if(this.isBookingProduct()){var e=document.querySelector('[name="add-to-cart"]').value;return[new V(e,1,wt.getPrefixedFields(this.formElement,"wc_bookings_field"),this.extraFields())]}if(this.isGroupedProduct()){var r=[];return this.formElement.querySelectorAll('input[type="number"]').forEach(function(e){if(e.value){var n=e.getAttribute("name").match(/quantity\[([\d]*)\]/);if(2===n.length){var o=parseInt(n[1]),i=parseInt(e.value);r.push(new M(o,i,null,t.extraFields()))}}}),r}var n=document.querySelector('[name="add-to-cart"]').value,o=document.querySelector('[name="quantity"]').value,i=this.variations();return[new M(n,o,i,this.extraFields())]}},{key:"extraFields",value:function(){return wt.getFilteredFields(this.formElement,["add-to-cart","quantity","product_id","variation_id"],["attribute_","wc_bookings_field"])}},{key:"createOrder",value:function(){var t=this;this.cartHelper=null;var e=this.errorHandler;return function(r,n){var o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};return e.clear(),t.cartUpdater.update(function(r){t.cartHelper=(new pt).addFromPurchaseUnits(r);var n=it(),o=void 0!==t.config.bn_codes[t.config.context]?t.config.bn_codes[t.config.context]:"";return fetch(t.config.ajax.create_order.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({nonce:t.config.ajax.create_order.nonce,purchase_units:r,payer:n,bn_code:o,payment_method:"ppcp-gateway",funding_source:window.ppcpFundingSource,context:t.config.context})}).then(function(t){return t.json()}).then(function(t){if(!t.success)throw console.error(t),e.clear(),e.message(t.data.message),{type:"create-order-error"};return t.data.id})},t.getProducts(),o.updateCartOptions||{})}}},{key:"updateCart",value:function(t){return this.cartUpdater.update(function(t){return t},this.getProducts(),t)}},{key:"variations",value:function(){return this.hasVariations()?function(t){return function(t){if(Array.isArray(t))return Ct(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||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)||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.")}()}(this.formElement.querySelectorAll("[name^='attribute_']")).map(function(t){return{value:t.value,name:t.name}}):null}},{key:"hasVariations",value:function(){return this.formElement.classList.contains("variations_form")}},{key:"isGroupedProduct",value:function(){return this.formElement.classList.contains("grouped_form")}},{key:"isBookingProduct",value:function(){return!!this.formElement.querySelector(".wc-booking-product-id")}},{key:"cleanCart",value:function(){var t=this;this.cartHelper.removeFromCart().then(function(){t.refreshMiniCart()}).catch(function(e){t.refreshMiniCart()})}},{key:"refreshMiniCart",value:function(){jQuery(document.body).trigger("wc_fragment_refresh")}}])}();const It=Ft;function Dt(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return Mt(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Mt(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Mt(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,Mt(s,"constructor",l),Mt(l,"constructor",c),c.displayName="GeneratorFunction",Mt(l,o,"GeneratorFunction"),Mt(s),Mt(s,o,"Generator"),Mt(s,n,function(){return this}),Mt(s,"toString",function(){return"[object Generator]"}),(Dt=function(){return{w:i,m:p}})()}function Mt(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Mt=function(t,e,r,n){function i(e,r){Mt(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))},Mt(t,e,r,n)}function Rt(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function qt(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){Rt(i,n,o,a,u,"next",t)}function u(t){Rt(i,n,o,a,u,"throw",t)}a(void 0)})}}var Nt=function(t){return window.location.assign(t)};function Lt(){var t=document.querySelector('form [name="add-to-cart"]')||document.querySelector('form [name="product_id"]'),e=null==t?void 0:t.closest("form");if(!e)throw new Error("Product form not found.");return new It(null,null,e,null).getProducts().map(function(t){return t.data()})}function Ut(){return Ut=qt(Dt().m(function t(e,r,n){var o,i,a,u,c,l;return Dt().w(function(t){for(;;)switch(t.n){case 0:if(o=[],"product"!==r){t.n=2;break}return t.n=1,s(e.ajax.change_cart,{products:Lt()});case 1:o=t.v;case 2:return i={context:r,purchase_units:o,payment_method:"ppcp-gateway",funding_source:n||"paypal",save_order_in_session:1},"checkout"===r&&((a=document.querySelector("form.checkout"))&&(i.form_encoded=new URLSearchParams(new FormData(a)).toString(),i.createaccount=!(null===(u=a.querySelector("#createaccount"))||void 0===u||!u.checked)),(c=it())&&(i.payer=c)),t.n=3,s(e.ajax.create_order,i);case 3:return l=t.v,t.a(2,{orderId:l.id})}},t)})),Ut.apply(this,arguments)}function Qt(t,e,r,n){return Ht.apply(this,arguments)}function Ht(){return Ht=qt(Dt().m(function t(e,r,n,o){var i,a,u,c,l,f;return Dt().w(function(t){for(;;)switch(t.p=t.n){case 0:return a=!e.vaulting_enabled||"venmo"!==n,t.p=1,t.n=2,s(e.ajax.approve_order,{order_id:o,funding_source:n,should_create_wc_order:a});case 2:u=t.v,t.n=6;break;case 3:if(t.p=3,f=t.v,a){t.n=4;break}throw f;case 4:return t.n=5,s(e.ajax.approve_order,{order_id:o,funding_source:n,should_create_wc_order:!1});case 5:u=t.v;case 6:if(null===(i=u)||void 0===i||!i.order_received_url){t.n=7;break}return Nt(u.order_received_url),t.a(2);case 7:if("checkout"!==r||"undefined"==typeof jQuery){t.n=8;break}if(!(c=jQuery("form.checkout")).length){t.n=8;break}return(l=document.querySelector("#payment_method_ppcp-gateway"))&&!l.checked&&(l.checked=!0,jQuery(l).trigger("change")),c.trigger("submit"),t.a(2);case 8:Nt(e.urls.checkout);case 9:return t.a(2)}},t,null,[[1,3]])})),Ht.apply(this,arguments)}function Bt(t,e){return Kt.apply(this,arguments)}function Kt(){return Kt=qt(Dt().m(function t(e,r){return Dt().w(function(t){for(;;)if(0===t.n)return t.a(2,s(e.ajax.get_order,{order_id:r}))},t)})),Kt.apply(this,arguments)}function $t(t,e,r){return Jt.apply(this,arguments)}function Jt(){return Jt=qt(Dt().m(function t(e,r,n){return Dt().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,s(e.ajax.approve_order,{order_id:n,funding_source:r,should_create_wc_order:!1});case 1:return t.a(2)}},t)})),Jt.apply(this,arguments)}function Vt(t,e){return Wt.apply(this,arguments)}function Wt(){return Wt=qt(Dt().m(function t(e,r){return Dt().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,s(e.ajax.update_shipping,{order_id:r});case 1:return t.a(2)}},t)})),Wt.apply(this,arguments)}function Yt(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return Zt(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Zt(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Zt(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,Zt(s,"constructor",l),Zt(l,"constructor",c),c.displayName="GeneratorFunction",Zt(l,o,"GeneratorFunction"),Zt(s),Zt(s,o,"Generator"),Zt(s,n,function(){return this}),Zt(s,"toString",function(){return"[object Generator]"}),(Yt=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 u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).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,u,"next",t)}function u(t){zt(i,n,o,a,u,"throw",t)}a(void 0)})}}function te(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{country:t.countryCode||"",state:t.adminArea1||t.state||"",postcode:t.postalCode||"",city:t.adminArea2||t.city||""}}function ee(){return ee=Xt(Yt().m(function t(e,r){var n;return Yt().w(function(t){for(;;)switch(t.n){case 0:return n=r.ajax.wc_store_api,t.n=1,y(n,n.update_customer,{shipping_address:te(e.shippingAddress)});case 1:return t.n=2,Vt(r,e.orderId);case 2:return t.a(2)}},t)})),ee.apply(this,arguments)}function re(){return re=Xt(Yt().m(function t(e,r){var n,o,i;return Yt().w(function(t){for(;;)switch(t.n){case 0:if(o=r.ajax.wc_store_api,!(i=null===(n=e.selectedShippingOption)||void 0===n?void 0:n.id)){t.n=1;break}return t.n=1,y(o,o.select_shipping_rate,{rate_id:i});case 1:return t.n=2,Vt(r,e.orderId);case 2:return t.a(2)}},t)})),re.apply(this,arguments)}function ne(t){return ne="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},ne(t)}function oe(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,ie(n.key),n)}}function ie(t){var e=function(t){if("object"!=ne(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ne(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ne(e)?e:e+""}var ae=function(){return function(t,e){return e&&oe(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),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.genericErrorText=e,this.wrapper=r},[{key:"genericError",value:function(){this.clear(),this.message(this.genericErrorText)}},{key:"appendPreparedErrorMessageElement",value:function(t){this._getMessageContainer().replaceWith(t)}},{key:"message",value:function(t){this._addMessage(t),this._scrollToMessages()}},{key:"messages",value:function(t){var e=this;t.forEach(function(t){return e._addMessage(t)}),this._scrollToMessages()}},{key:"currentHtml",value:function(){return this._getMessageContainer().outerHTML}},{key:"_addMessage",value:function(t){if("undefined"!=typeof String&&!ne(String)||0===t.length)throw new Error("A new message text must be a non-empty string.");var e=this._getMessageContainer(),r=this._prepareMessageElement(t);e.appendChild(r)}},{key:"_scrollToMessages",value:function(){jQuery.scroll_to_notices(jQuery(".woocommerce-error"))}},{key:"_getMessageContainer",value:function(){var t=document.querySelector("ul.woocommerce-error");return null===t&&((t=document.createElement("ul")).setAttribute("class","woocommerce-error"),t.setAttribute("role","alert"),jQuery(this.wrapper).prepend(t)),t}},{key:"_prepareMessageElement",value:function(t){var e=document.createElement("li");return e.innerHTML=t,e}},{key:"clear",value:function(){jQuery(".woocommerce-error, .woocommerce-message").remove()}}])}();const ue=ae;var ce={};function le(t){console.error("[PPCP SDK v6]",t);var e=document.querySelector(".woocommerce-notices-wrapper")||document.querySelector(".woocommerce")||document.body,r=new ue(ce.generic_error||"",e);return null!=t&&t.refresh&&v()&&jQuery(document.body).trigger("update_checkout"),Array.isArray(null==t?void 0:t.errors)&&t.errors.length?(r.clear(),void r.messages(t.errors)):null!=t&&t.isUserFacing&&t.message?(r.clear(),void r.message(t.message)):void(ce.generic_error&&r.genericError())}function fe(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return se(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(se(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,se(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,se(s,"constructor",l),se(l,"constructor",c),c.displayName="GeneratorFunction",se(l,o,"GeneratorFunction"),se(s),se(s,o,"Generator"),se(s,n,function(){return this}),se(s,"toString",function(){return"[object Generator]"}),(fe=function(){return{w:i,m:p}})()}function se(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}se=function(t,e,r,n){function i(e,r){se(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))},se(t,e,r,n)}function pe(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}var ye={paypal:"createPayPalOneTimePaymentSession",venmo:"createVenmoOneTimePaymentSession",paylater:"createPayLaterOneTimePaymentSession"};function de(t){"product"===t&&v()&&jQuery(document.body).trigger("wc_fragment_refresh")}function ve(t){return ve="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},ve(t)}function me(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 he(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?me(Object(r),!0).forEach(function(e){be(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):me(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function be(t,e,r){return(e=function(t){var e=function(t){if("object"!=ve(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ve(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ve(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ge(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,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return we(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)?we(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 we(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 _e(t){var e={};return Object.entries({country_code:"country",address_line_1:"address_1",address_line_2:"address_2",admin_area_1:"state",admin_area_2:"city",postal_code:"postcode"}).forEach(function(r){var n=ge(r,2),o=n[0],i=n[1];null!=t&&t[o]&&(e[i]=t[o])}),he({first_name:"",last_name:"",company:"",address_1:"",address_2:"",city:"",state:"",postcode:"",country:"",phone:""},e)}function Se(t){var e,r,n,o,i,a,u,c,l=function(t){var e,r,n=null==t||null===(e=t.purchase_units)||void 0===e||null===(e=e[0])||void 0===e?void 0:e.shipping;if(!n)return{};var o=ge(null!==(r=n.name)&&void 0!==r&&r.full_name?function(t){if(!(t=t.trim()).includes(" "))return[t,""];var e=t.split(" ");return[e.shift(),e.join(" ")]}(n.name.full_name):["",""],2),i=o[0],a=o[1];return he(he({},_e(n.address)),{},{first_name:i,last_name:a})}(t),f=l;if(null!=t&&t.payer&&!(f=he(he({},null!=(e=t.payer)&&e.address?_e(e.address):{}),{},{first_name:null!==(r=null==e||null===(n=e.name)||void 0===n?void 0:n.given_name)&&void 0!==r?r:"",last_name:null!==(o=null==e||null===(i=e.name)||void 0===i?void 0:i.surname)&&void 0!==o?o:"",email:null!==(a=null==e?void 0:e.email_address)&&void 0!==a?a:"",phone:null!==(u=null==e||null===(c=e.phone)||void 0===c||null===(c=c.phone_number)||void 0===c?void 0:c.national_number)&&void 0!==u?u:""})).address_1){var s=Object.fromEntries(Object.entries(f).filter(function(t){var e=ge(t,2),r=e[0];return""!==e[1]&&"country"!==r}));f=he(he({},l),s)}return{billingAddress:f,shippingAddress:l}}function je(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return Oe(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Oe(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Oe(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,Oe(s,"constructor",l),Oe(l,"constructor",c),c.displayName="GeneratorFunction",Oe(l,o,"GeneratorFunction"),Oe(s),Oe(s,o,"Generator"),Oe(s,n,function(){return this}),Oe(s,"toString",function(){return"[object Generator]"}),(je=function(){return{w:i,m:p}})()}function Oe(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Oe=function(t,e,r,n){function i(e,r){Oe(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))},Oe(t,e,r,n)}function Pe(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function ke(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){Pe(i,n,o,a,u,"next",t)}function u(t){Pe(i,n,o,a,u,"throw",t)}a(void 0)})}}function Ee(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return{country:t.countryCode||"",state:t.adminArea1||t.state||"",postcode:t.postalCode||"",city:t.adminArea2||t.city||""}}function Te(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return Ae(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Ae(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Ae(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,Ae(s,"constructor",l),Ae(l,"constructor",c),c.displayName="GeneratorFunction",Ae(l,o,"GeneratorFunction"),Ae(s),Ae(s,o,"Generator"),Ae(s,n,function(){return this}),Ae(s,"toString",function(){return"[object Generator]"}),(Te=function(){return{w:i,m:p}})()}function Ae(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Ae=function(t,e,r,n){function i(e,r){Ae(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))},Ae(t,e,r,n)}function Ce(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function xe(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){Ce(i,n,o,a,u,"next",t)}function u(t){Ce(i,n,o,a,u,"throw",t)}a(void 0)})}}var Ge={paypal:{tagName:"paypal-button",type:"pay"},venmo:{tagName:"venmo-button",type:"pay"},paylater:{tagName:"paypal-pay-later-button",type:""}};function Fe(t){var r=t.method,n=t.session,o=t.styles,i=t.createOrderFn,a=t.payLaterDetails,u=t.onClick,c=(0,e.useRef)(null),l=(0,e.useRef)(null);return l.current=u,(0,e.useEffect)(function(){var t=c.current;if(t&&n){var e=function(t){var e=t.method,r=t.styles,n=t.session,o=t.createOrderFn,i=t.payLaterDetails,a=t.onClick,u=Ge[e];if(!u)return null;if("paylater"===e&&(null==i||!i.productCode))return null;var c=function(t,e,r,n,o,i){var a=document.createElement(t);return e&&a.setAttribute("type",e),r.colorClass&&(a.className=r.colorClass),r.borderRadius&&a.style.setProperty("--paypal-button-border-radius",r.borderRadius),r.height&&(a.style.height=r.height),a.addEventListener("click",xe(Te().m(function t(){return Te().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,i&&i(),t.n=1,n.start({presentationMode:"auto"},o());case 1:t.n=3;break;case 2:t.p=2,le(t.v);case 3:return t.a(2)}},t,null,[[0,2]])}))),a}(u.tagName,u.type,r,n,o,a);return"paylater"===e&&(c.productCode=i.productCode,i.countryCode&&(c.countryCode=i.countryCode)),c}({method:r,styles:o,session:n,createOrderFn:i,payLaterDetails:a,onClick:function(){var t;return null===(t=l.current)||void 0===t?void 0:t.call(l)}});if(e)return t.appendChild(e),function(){e.remove()}}},[r,n]),(0,e.createElement)("div",{ref:c})}function Ie(t){return Ie="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},Ie(t)}function De(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 Me(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?De(Object(r),!0).forEach(function(e){Re(t,e,r[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):De(Object(r)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))})}return t}function Re(t,e,r){return(e=function(t){var e=function(t){if("object"!=Ie(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ie(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ie(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function qe(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return Ne(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Ne(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Ne(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,Ne(s,"constructor",l),Ne(l,"constructor",c),c.displayName="GeneratorFunction",Ne(l,o,"GeneratorFunction"),Ne(s),Ne(s,o,"Generator"),Ne(s,n,function(){return this}),Ne(s,"toString",function(){return"[object Generator]"}),(qe=function(){return{w:i,m:p}})()}function Ne(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Ne=function(t,e,r,n){function i(e,r){Ne(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))},Ne(t,e,r,n)}function Le(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function Ue(t){return function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){Le(i,n,o,a,u,"next",t)}function u(t){Le(i,n,o,a,u,"throw",t)}a(void 0)})}}function Qe(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,u=[],c=!0,l=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);c=!0);}catch(t){l=!0,o=t}finally{try{if(!c&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(l)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return He(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)?He(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 He(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 Be(t){var r,n=t.config,o=t.fundingSource,i=t.onClick,a=t.onClose,u=t.onError,c=t.onSubmit,l=t.eventRegistration,f=t.emitResponse,s=t.activePaymentMethod,p=t.shippingData,y=t.billing,d=l.onPaymentSetup,v=l.onCheckoutFail,m=f.responseTypes,h=o,b=n.page_context,g="ppcp-gateway-".concat(o),w=Qe((0,e.useState)(null),2),_=w[0],S=w[1],j=Qe((0,e.useState)(null),2),O=j[0],k=j[1],E=Qe((0,e.useState)(null),2),T=E[0],A=E[1],x=function(t){var e,r,n,o=parseInt(null==t||null===(e=t.cartTotal)||void 0===e?void 0:e.value,10);if(isNaN(o))return"";var i=null!==(r=null==t||null===(n=t.currency)||void 0===n?void 0:n.minorUnit)&&void 0!==r?r:2;return(o/Math.pow(10,i)).toFixed(i)}(y)||n.amount;(0,e.useEffect)(function(){var t=!0;return Ue(qe().m(function e(){var r,o;return qe().w(function(e){for(;;)switch(e.n){case 0:return e.n=1,P(n,b);case 1:return r=e.v,e.n=2,C(r,{currencyCode:n.currency,countryCode:n.buyer_country,amount:x});case 2:o=e.v,t&&(S(r),k(o));case 3:return e.a(2)}},e)}))().catch(function(t){console.error("[ppcp-sdk-v6] express SDK load failed",t)}),function(){t=!1}},[n,b,x]);var G=function(){var t=Ue(qe().m(function t(e){var r,i,a;return qe().w(function(t){for(;;)switch(t.n){case 0:return t.n=1,Bt(n,e.orderId);case 1:if(null==(i=t.v)||null===(r=i.purchase_units)||void 0===r||null===(r=r[0])||void 0===r||null===(r=r.shipping)||void 0===r||!r.address){t.n=2;break}return a=Se(i),t.n=2,wp.data.dispatch("wc/store/cart").updateCustomerData({billing_address:a.billingAddress,shipping_address:a.shippingAddress});case 2:return t.n=3,$t(n,o,e.orderId);case 3:A(i),c();case 4:return t.a(2)}},t)}));return function(_x){return t.apply(this,arguments)}}(),F=(0,e.useRef)({});F.current={onApprove:G,onError:function(t){u&&u((null==t?void 0:t.message)||""),a&&a()},onCancel:function(){a&&a()}};var I=(0,e.useMemo)(function(){return function(t,e){return{onShippingAddressChange:(n=ke(je().m(function r(n){var o;return je().w(function(r){for(;;)switch(r.n){case 0:return o=Ee(n.shippingAddress),r.n=1,wp.data.dispatch("wc/store/cart").updateCustomerData({shipping_address:o});case 1:if(null==e||!e.setShippingAddress){r.n=2;break}return r.n=2,e.setShippingAddress(o);case 2:return r.n=3,Vt(t,n.orderId);case 3:return r.a(2)}},r)})),function(_x){return n.apply(this,arguments)}),onShippingOptionsChange:(r=ke(je().m(function r(n){var o,i;return je().w(function(r){for(;;)switch(r.n){case 0:if(!(i=null===(o=n.selectedShippingOption)||void 0===o?void 0:o.id)){r.n=2;break}return r.n=1,wp.data.dispatch("wc/store/cart").selectShippingRate(i);case 1:if(null==e||!e.setSelectedRates){r.n=2;break}return r.n=2,e.setSelectedRates(i);case 2:return r.n=3,Vt(t,n.orderId);case 3:return r.a(2)}},r)})),function(t){return r.apply(this,arguments)})};var r,n}(n,p)},[n,p]),D=(0,e.useMemo)(function(){var t;if(!_)return null;var e={onApprove:function(t){return F.current.onApprove(t)},onError:function(t){return F.current.onError(t)},onCancel:function(){return F.current.onCancel()}};return"paypal"===h&&null!=p&&p.needsShipping&&null!==(t=n.shipping)&&void 0!==t&&t.handle_in_paypal&&(e.onShippingAddressChange=I.onShippingAddressChange,e.onShippingOptionsChange=I.onShippingOptionsChange),function(t,e,r,n){var o,i,a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:{},u={onApprove:a.onApprove||function(){var t,o=(t=fe().m(function t(o){return fe().w(function(t){for(;;)switch(t.p=t.n){case 0:return t.p=0,t.n=1,Qt(r,n,e,o.orderId);case 1:t.n=3;break;case 2:t.p=2,le(t.v);case 3:return t.a(2)}},t,null,[[0,2]])}),function(){var e=this,r=arguments;return new Promise(function(n,o){var i=t.apply(e,r);function a(t){pe(i,n,o,a,u,"next",t)}function u(t){pe(i,n,o,a,u,"throw",t)}a(void 0)})});return function(_x){return o.apply(this,arguments)}}(),onCancel:a.onCancel||function(){return de(n)},onError:a.onError||function(t){de(n),le(t)}},c="paypal"===e&&(null===(o=r.shipping)||void 0===o?void 0:o.handle_in_paypal)&&((null===(i=r.shipping)||void 0===i?void 0:i.need_shipping)||"product"===n);return a.onShippingAddressChange?u.onShippingAddressChange=a.onShippingAddressChange:c&&(u.onShippingAddressChange=function(t){return function(_x,t){return ee.apply(this,arguments)}(t,r)}),a.onShippingOptionsChange?u.onShippingOptionsChange=a.onShippingOptionsChange:c&&(u.onShippingOptionsChange=function(t){return function(t,e){return re.apply(this,arguments)}(t,r)}),t[ye[e]](u)}(_,h,n,b,e)},[_,h]);return(0,e.useEffect)(function(){if(s===g)return d(function(){var t,e={};return null!=T&&null!==(t=T.purchase_units)&&void 0!==t&&null!==(t=t[0])&&void 0!==t&&null!==(t=t.shipping)&&void 0!==t&&t.address&&(e=Se(T)),{type:m.SUCCESS,meta:Me({paymentMethodData:{paypal_order_id:null==T?void 0:T.id,funding_source:o}},e)}})},[d,T,s,g,o,m]),(0,e.useEffect)(function(){if(s===g)return v(function(){return a&&a(),!0})},[v,a,s,g]),D?(0,e.createElement)(Fe,{method:h,session:D,styles:(null===(r=n.button_styles)||void 0===r?void 0:r[b])||{},createOrderFn:function(){return function(_x,t,e){return Ut.apply(this,arguments)}(n,b,o)},payLaterDetails:null==O?void 0:O.payLaterDetails,onClick:i}):null}var Ke,$e,Je={paypal:"PayPal",venmo:"Venmo",paylater:"Pay Later"};function Ve(t){var n=t.fundingSource,o=Je[n]||"PayPal";return(0,e.createElement)("div",{className:"ppcp-sdk-v6-editor-preview",style:{padding:"12px",textAlign:"center",border:"1px dashed #c3c4c7",borderRadius:"4px",color:"#50575e"}},(0,r.sprintf)(
|
|
// translators: %s is the funding source name (PayPal, Venmo, Pay Later).
|
|
// translators: %s is the funding source name (PayPal, Venmo, Pay Later).
|
|
(0,r.__)("%s button","woocommerce-paypal-payments"),o))}function We(){var t,e,r="function"==typeof Symbol?Symbol:{},n=r.iterator||"@@iterator",o=r.toStringTag||"@@toStringTag";function i(r,n,o,i){var c=n&&n.prototype instanceof u?n:u,l=Object.create(c.prototype);return Ye(l,"_invoke",function(r,n,o){var i,u,c,l=0,f=o||[],s=!1,p={p:0,n:0,v:t,a:y,f:y.bind(t,4),d:function(e,r){return i=e,u=0,c=t,p.n=r,a}};function y(r,n){for(u=r,c=n,e=0;!s&&l&&!o&&e<f.length;e++){var o,i=f[e],y=p.p,d=i[2];r>3?(o=d===n)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=y&&((o=r<2&&y<i[1])?(u=0,p.v=n,p.n=i[1]):y<d&&(o=r<3||i[0]>n||n>d)&&(i[4]=r,i[5]=n,p.n=d,u=0))}if(o||r>1)return a;throw s=!0,n}return function(o,f,d){if(l>1)throw TypeError("Generator is already running");for(s&&1===f&&y(f,d),u=f,c=d;(e=u<2?t:c)||!s;){i||(u?u<3?(u>1&&(p.n=-1),y(u,c)):p.n=c:p.v=c);try{if(l=2,i){if(u||(o="next"),e=i[o]){if(!(e=e.call(i,c)))throw TypeError("iterator result is not an object");if(!e.done)return e;c=e.value,u<2&&(u=0)}else 1===u&&(e=i.return)&&e.call(i),u<2&&(c=TypeError("The iterator does not provide a '"+o+"' method"),u=1);i=t}else if((e=(s=p.n<0)?c:r.call(n,p))!==a)break}catch(e){i=t,u=1,c=e}finally{l=1}}return{value:e,done:s}}}(r,o,i),!0),l}var a={};function u(){}function c(){}function l(){}e=Object.getPrototypeOf;var f=[][n]?e(e([][n]())):(Ye(e={},n,function(){return this}),e),s=l.prototype=u.prototype=Object.create(f);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,Ye(t,o,"GeneratorFunction")),t.prototype=Object.create(s),t}return c.prototype=l,Ye(s,"constructor",l),Ye(l,"constructor",c),c.displayName="GeneratorFunction",Ye(l,o,"GeneratorFunction"),Ye(s),Ye(s,o,"Generator"),Ye(s,n,function(){return this}),Ye(s,"toString",function(){return"[object Generator]"}),(We=function(){return{w:i,m:p}})()}function Ye(t,e,r,n){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Ye=function(t,e,r,n){function i(e,r){Ye(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))},Ye(t,e,r,n)}function Ze(t,e,r,n,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void r(t)}u.done?e(c):Promise.resolve(c).then(n,o)}function ze(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 Xe={paypal:"PayPal",venmo:"Venmo",paylater:"Pay Later"},tr=((null===(Ke=window.wc)||void 0===Ke||null===(Ke=Ke.wcSettings)||void 0===Ke||null===($e=Ke.getSetting)||void 0===$e?void 0:$e.call(Ke,"paymentMethodData"))||{})["ppcp-sdk-v6"];function er(t){var e,r=parseInt(null==t?void 0:t.total_price,10);if(isNaN(r))return"";var n=null!==(e=null==t?void 0:t.currency_minor_unit)&&void 0!==e?e:2;return(r/Math.pow(10,n)).toFixed(n)}if(tr&&tr.page_context){var rr,nr={},or=function(t){return nr[t]||(nr[t]=P(tr,tr.page_context).then(function(e){return C(e,{currencyCode:tr.currency,countryCode:tr.buyer_country,amount:t})}).catch(function(t){return console.error("[ppcp-sdk-v6] eligibility check failed",t),{}})),nr[t]},ir=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=function(t,e){if(t){if("string"==typeof t)return ze(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)?ze(t,e):void 0}}(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}}}}(["paypal","venmo","paylater"]);try{var ar=function(){var n,o,i=rr.value;(0,t.registerExpressPaymentMethod)({name:"ppcp-gateway-".concat(i),title:"PayPal",description:(0,r.__)("Eligible users will see the PayPal button.","woocommerce-paypal-payments"),gatewayId:"ppcp-gateway",paymentMethodId:"ppcp-gateway",label:(0,e.createElement)("div",null,Xe[i]),ariaLabel:Xe[i],content:(0,e.createElement)(Be,{config:tr,fundingSource:i}),edit:(0,e.createElement)(Ve,{fundingSource:i}),canMakePayment:(n=We().m(function t(){var e,r,n,o=arguments;return We().w(function(t){for(;;)switch(t.n){case 0:return e=(o.length>0&&void 0!==o[0]?o[0]:{}).cartTotals,r=er(e)||tr.amount,t.n=1,or(r);case 1:return n=t.v,t.a(2,Boolean(n[i]))}},t)}),o=function(){var t=this,e=arguments;return new Promise(function(r,o){var i=n.apply(t,e);function a(t){Ze(i,r,o,a,u,"next",t)}function u(t){Ze(i,r,o,a,u,"throw",t)}a(void 0)})},function(){return o.apply(this,arguments)}),supports:{features:["products"]}})};for(ir.s();!(rr=ir.n()).done;)ar()}catch(t){ir.e(t)}finally{ir.f()}}})(); |