← Back
Editing: ppcp-googlepay-js-boot-admin.js
(()=>{"use strict";const t={n:e=>{const n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},cw:t=>{var e;return()=>{if(t){var n=t;t=0,e={exports:{}},n.call(e.exports,e,e.exports)}return e.exports}},d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.hasOwn(t,e)};var e=t.cw(function(t,e){var n=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 o(t,e){return!1!==e.clone&&e.isMergeableObject(t)?c((n=t,Array.isArray(n)?[]:{}),t,e):t;var n}function i(t,e,n){return t.concat(e).map(function(t){return o(t,n)})}function a(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 u(t,e){try{return e in t}catch(t){return!1}}function c(t,e,r){(r=r||{}).arrayMerge=r.arrayMerge||i,r.isMergeableObject=r.isMergeableObject||n,r.cloneUnlessOtherwiseSpecified=o;var s=Array.isArray(e);return s===Array.isArray(t)?s?r.arrayMerge(t,e,r):function(t,e,n){var r={};return n.isMergeableObject(t)&&a(t).forEach(function(e){r[e]=o(t[e],n)}),a(e).forEach(function(i){(function(t,e){return u(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,i)||(u(t,i)&&n.isMergeableObject(e[i])?r[i]=function(t,e){if(!e.customMerge)return c;var n=e.customMerge(t);return"function"==typeof n?n:c}(i,n)(t[i],e[i],n):r[i]=o(e[i],n))}),r}(t,e,r):o(e,r)}c.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,n){return c(t,n,e)},{})};var s=c;t.exports=s});function n(t,e){void 0===e&&(e=Promise),function(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");var n=t.environment;if(n&&"production"!==n&&"sandbox"!==n)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.")}(t,e);var n=t.url,r=t.attributes;if("string"!=typeof n||0===n.length)throw new Error("Invalid url.");if(void 0!==r&&"object"!=typeof r)throw new Error("Expected attributes to be an object.");return new e(function(t,e){if("undefined"==typeof document)return t();var o,i,a,u;i=(o={url:n,attributes:r,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load. Check the HTTP status code and response body in DevTools to learn more.'));return e(t)}}).onSuccess,a=o.onError,u=function(t,e){void 0===e&&(e={});var n=document.createElement("script");return n.src=t,Object.keys(e).forEach(function(t){n.setAttribute(t,e[t]),"data-csp-nonce"===t&&n.setAttribute("nonce",e["data-csp-nonce"])}),n}(o.url,o.attributes),u.onerror=a,u.onload=i,document.head.insertBefore(u,document.head.firstElementChild)})}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 o(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||a(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 i(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=a(t))||e&&t&&"number"==typeof t.length){n&&(t=n);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 o,i=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){u=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(u)throw o}}}}function a(t,e){if(t){if("string"==typeof t)return u(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(t,e):void 0}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function c(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,s(r.key),r)}}function s(t){var e=function(t){if("object"!=r(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=r(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==r(e)?e:e+""}"function"==typeof SuppressedError&&SuppressedError;var l=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 n=this.buttons.get(e),r=this.paypal.Buttons(n.options);if(r.isEligible()){var o=this.buildWrapperTarget(t);o&&(r.hasReturned()?r.resume():r.render(o))}else this.buttons.delete(e)}}},{key:"renderAllButtons",value:function(){var t,e=i(this.buttons);try{for(e.s();!(t=e.n()).done;){var n=o(t.value,1)[0];this.renderButtons(n)}}catch(t){e.e(t)}finally{e.f()}}},{key:"removeButtons",value:function(t){var e,n=i(this.buttons);try{for(n.s();!(e=n.n()).done;){var r=o(e.value,2),a=r[0],u=r[1];(Array.isArray(u.wrapper)?u.wrapper[0]:u.wrapper)===t&&this.buttons.delete(a)}}catch(t){n.e(t)}finally{n.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 n=this.messages.get(t);if(this.hasRendered(t))document.querySelector(t).setAttribute("data-pp-amount",n.options.amount);else{var r=this.paypal.Messages(n.options);r.render(n.wrapper),setTimeout(function(){e.hasRendered(t)||r.render(n.wrapper)},100)}}}},{key:"renderAllMessages",value:function(){var t,e=i(this.messages);try{for(e.s();!(t=e.n()).done;){var n=o(t.value,2),r=n[0];n[1],this.renderMessages(r)}}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 n,r=i(t.slice(1));try{for(r.s();!(n=r.n()).done;)e+=" .item-"+n.value}catch(t){r.e(t)}finally{r.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 n=jQuery(t[0]);if(!n.length)return;var r="item-"+t[1],o=n.find("."+r);o.length||(o=jQuery('<div class="'.concat(r,'"></div>')),n.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}}])&&c(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();window.widgetBuilder=window.widgetBuilder||new l;const f=window.widgetBuilder;function p(t){return p="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},p(t)}function h(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,y(r.key),r)}}function y(t){var e=function(t){if("object"!=p(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=p(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==p(e)?e:e+""}function d(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function v(t,e){return t.get(m(t,e))}function b(t,e,n){return t.set(m(t,e),n),n}function m(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var g=new WeakMap,w=new WeakMap,P=new WeakMap,S=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),d(this,g,""),d(this,w,!1),d(this,P,null);for(var e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];n.length&&b(g,this,"[".concat(n.join(" | "),"]"))},e=[{key:"enabled",set:function(t){b(w,this,t)}},{key:"log",value:function(){if(v(w,this)){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];(t=console).log.apply(t,[v(g,this)].concat(n))}}},{key:"error",value:function(){for(var t,e=arguments.length,n=new Array(e),r=0;r<e;r++)n[r]=arguments[r];(t=console).error.apply(t,[v(g,this)].concat(n))}},{key:"group",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;v(w,this)&&(t&&!v(P,this)||(console.groupEnd(),b(P,this,null)),t&&(console.group(t),b(P,this,t)))}}],e&&h(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function O(){return O.c||(O.c=t.n(e()))}function k(t){return k="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},k(t)}function j(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,_(r.key),r)}}function _(t){var e=function(t){if("object"!=k(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=k(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==k(e)?e:e+""}e();const E=function(){return t=function t(e){var n=e.selector,r=e.apiConfig,o=e.methodName,i=void 0===o?"":o;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.apiConfig=r,this.defaultAttributes={},this.buttonConfig={},this.ppcpConfig={},this.isDynamic=!0,this.methodName=i,this.methodSlug=this.methodName.toLowerCase().replace(/[^a-z]+/g,""),this.selector=n,this.wrapper=n,this.domWrapper=null},(e=[{key:"createNewWrapper",value:function(){var t=document.createElement("div"),e=this.selector.replace("#",""),n="ppcp-preview-button ppcp-button-apm ppcp-button-".concat(this.methodSlug);return t.setAttribute("id",e),t.setAttribute("class",n),t}},{key:"setDynamic",value:function(t){return this.isDynamic=t,this}},{key:"setButtonConfig",value:function(t){return this.buttonConfig=O()()(this.defaultAttributes,t),this.buttonConfig.button.wrapper=this.selector,this}},{key:"setPpcpConfig",value:function(t){return this.ppcpConfig=O()()({},t),this}},{key:"dynamicPreviewConfig",value:function(t,e){}},{key:"createButton",value:function(t){throw new Error('The "createButton" method must be implemented by the derived class')}},{key:"render",value:function(){var t=this;if(this.isDynamic||this.buttonConfig.is_enabled){if(this.domWrapper)this._emptyWrapper(),this._showWrapper();else{if(!this.wrapper)return void console.error("Skip render, button is not configured yet");this.domWrapper=this.createNewWrapper(),this._insertWrapper()}this.isVisible=!0;var e=O()()({},this.buttonConfig),n=this.isDynamic?O()()({},this.ppcpConfig):{};e.button.wrapper=this.selector,this.dynamicPreviewConfig(e,n);var r=e.button.wrapper.replace(/^#/,"");if(r===this.ppcpConfig.button.wrapper.replace(/^#/,""))throw new Error('[APM Preview Button] Infinite loop detected. Provide different selectors for the button/ppcp wrapper elements! Selector: "#'.concat(r,'"'));this.createButton(e),setTimeout(function(){return t._showWrapper()})}}},{key:"remove",value:function(){this.isVisible=!1,this.domWrapper&&(this._hideWrapper(),this._emptyWrapper())}},{key:"_showWrapper",value:function(){this.domWrapper.style.display=""}},{key:"_hideWrapper",value:function(){this.domWrapper.style.display="none"}},{key:"_emptyWrapper",value:function(){this.domWrapper.innerHTML=""}},{key:"_insertWrapper",value:function(){var t=document.querySelector(this.wrapper);t.parentNode.insertBefore(this.domWrapper,t.nextSibling)}}])&&j(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function C(t){return C="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},C(t)}function A(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,T(r.key),r)}}function T(t){var e=function(t){if("object"!=C(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=C(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==C(e)?e:e+""}function I(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(I=function(){return!!t})()}function B(){return B="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=M(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},B.apply(null,arguments)}function M(t){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},M(t)}function D(t,e){return D=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},D(t,e)}function R(t,e){return t.get(W(t,e))}function W(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var x=new WeakMap,N=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}(n=function(t,e,n){return e=M(e),function(t,e){if(e&&("object"==C(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,I()?Reflect.construct(e,n||[],M(t).constructor):e.apply(t,n))}(this,e,[t]),x,void 0),n.selector="".concat(t.selector,"Dummy"),n.label=t.label||"Not Available",n}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&&D(t,e)}(e,t),n=e,r=[{key:"createNewWrapper",value:function(){var t,n,r,o=(t=e,n=this,"function"==typeof(r=B(M(1&3?t.prototype:t),"createNewWrapper",n))?function(t){return r.apply(n,t)}:r)([]);return o.classList.add("ppcp-button-apm","ppcp-button-dummy"),o}},{key:"createButton",value:function(t){var e,n,r,o;null===(e=R(x,this))||void 0===e||e.remove(),r=x,o=document.createElement("div"),r.set(W(r,this),o),R(x,this).innerHTML='<div class="reason">'.concat(this.label,"</div>"),this._applyStyles(null===(n=this.ppcpConfig)||void 0===n||null===(n=n.button)||void 0===n?void 0:n.style),this.domWrapper.appendChild(R(x,this))}},{key:"_applyStyles",value:function(t){this.domWrapper.classList.remove("ppcp-button-pill","ppcp-button-rect"),this.domWrapper.classList.add("ppcp-button-".concat(t.shape)),t.height&&(this.domWrapper.style.height="".concat(t.height,"px"))}}],r&&A(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(E);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 L(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function q(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?L(Object(n),!0).forEach(function(e){Q(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):L(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Q(t,e,n){return(e=$(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function z(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function H(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return F(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,p.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],h=p.p,y=i[2];n>3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(u=0,p.v=r,p.n=i[1]):h<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,p.n=y,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),h(u,c)):p.n=c:p.v=c);try{if(s=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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(F(e={},r,function(){return this}),e),f=s.prototype=u.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,F(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return c.prototype=s,F(f,"constructor",s),F(s,"constructor",c),c.displayName="GeneratorFunction",F(s,o,"GeneratorFunction"),F(f),F(f,o,"Generator"),F(f,r,function(){return this}),F(f,"toString",function(){return"[object Generator]"}),(H=function(){return{w:i,m:p}})()}function F(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}F=function(t,e,n,r){function i(e,n){F(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},F(t,e,n,r)}function V(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function U(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){V(i,r,o,a,u,"next",t)}function u(t){V(i,r,o,a,u,"throw",t)}a(void 0)})}}function Y(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,$(r.key),r)}}function $(t){var e=function(t){if("object"!=G(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==G(e)?e:e+""}function J(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function K(t,e){return t.get(X(t,e))}function Z(t,e,n){return t.set(X(t,e),n),n}function X(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var tt=new WeakMap,et=new WeakMap,nt=new WeakMap,rt=function(){return t=function t(e){var n,r,o,i,a,u=this,c=e.methodName,s=e.buttonConfig,l=e.defaultAttributes;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),J(this,tt,void 0),J(this,et,void 0),J(this,nt,void 0),this.methodName=c,this.buttonConfig=s,this.defaultAttributes=l,this.isEnabled=!0,this.buttons={},this.apiConfig=null,this.apiError="",Z(tt,this,new S(this.methodName,"preview-manager")),K(tt,this).enabled=!0,Z(nt,this,new Promise(function(t){Z(et,u,t)})),this.bootstrap=this.bootstrap.bind(this),this.renderPreview=this.renderPreview.bind(this),this._configureAllButtons=(n=this._configureAllButtons.bind(this),r={timeoutId:null,args:null},i=function(){r.timeoutId&&(n.apply(null,r.args||[]),o())},a=function(){o();for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];r.args=e,r.timeoutId=window.setTimeout(i,100)},a.cancel=o=function(){r.timeoutId&&window.clearTimeout(r.timeoutId),r.timeoutId=null,r.args=null},a.flush=i,a),this.registerEventListeners()},e=[{key:"fetchConfig",value:(o=U(H().m(function t(e){return H().w(function(t){for(;;)switch(t.n){case 0:throw new Error('The "fetchConfig" method must be implemented by the derived class');case 1:return t.a(2)}},t)})),function(_x){return o.apply(this,arguments)})},{key:"createButtonInstance",value:function(t){throw new Error('The "createButtonInstance" method must be implemented by the derived class')}},{key:"createDummyButtonInstance",value:function(t){return new N({selector:t,label:this.apiError,methodName:this.methodName})}},{key:"registerEventListeners",value:function(){jQuery(document).one("DOMContentLoaded",this.bootstrap),jQuery(document).on("ppcp_paypal_render_preview",this.renderPreview),jQuery(document).on("ppcp_paypal_render_preview_".concat(this.methodName),this.renderPreview)}},{key:"log",value:function(t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=K(tt,this)).log.apply(e,[t].concat(r))}},{key:"error",value:function(t){for(var e,n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];(e=K(tt,this)).error.apply(e,[t].concat(r))}},{key:"isDynamic",value:function(){return!!document.querySelector('[data-ppcp-apm-name="'.concat(this.methodName,'"]'))}},{key:"bootstrap",value:(r=U(H().m(function t(){var e,r,o,i,a,u,c=this;return H().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=1e4,o=200,null!==(e=this.buttonConfig)&&void 0!==e&&e.sdk_url&&f){t.n=1;break}return this.error("Button could not be configured."),t.a(2);case 1:if(window.PayPalCommerceGatewaySettings){t.n=2;break}return this.error("PayPal settings are not fully loaded. Please clear the cache and reload the page."),t.a(2);case 2:return i=function(t,e,n){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];clearInterval(n),r?t():e("Timeout while waiting for widgetBuilder.paypal")},a=new Promise(function(t,e){var n=0,a=setInterval(function(){f.paypal?i(t,e,a):n>=r&&i(t,e,a,!1),n+=o},o)}),u=n({url:this.buttonConfig.sdk_url}),t.n=3,Promise.all([u,a]).catch(function(t){console.log("Failed to load ".concat(c.methodName," dependencies:"),t)});case 3:return t.p=3,t.n=4,this.fetchConfig(f.paypal);case 4:this.apiConfig=t.v,t.n=6;break;case 5:t.p=5,t.v,this.apiConfig=null;case 6:return t.n=7,K(et,this).call(this);case 7:Z(nt,this,null);case 8:return t.a(2)}},t,this,[[3,5]])})),function(){return r.apply(this,arguments)})},{key:"renderPreview",value:function(t,e){var n=e.button.wrapper;n?this.shouldInsertPreviewButton(n)?this.buttons[n]?this._configureButton(n,e):this._addButton(n,e):this.log("Skip preview rendering for this preview-box",n):this.error("Button did not provide a wrapper ID",e)}},{key:"shouldInsertPreviewButton",value:function(t){var e,n=null!==(e=document.querySelector(t).closest(".ppcp-preview").dataset.ppcpPreviewBlock)&&void 0!==e?e:"all";return"all"===n||this.methodName===n}},{key:"_configureButton",value:function(t,e){this.log("configureButton",t,e),this.buttons[t].setDynamic(this.isDynamic()).setPpcpConfig(e).render()}},{key:"_configureAllButtons",value:function(t){var e=this;this.log("configureAllButtons",t),Object.entries(this.buttons).forEach(function(n){var r,o=function(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(t,e)||function(t,e){if(t){if("string"==typeof t)return z(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(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.")}()}(n,2),i=o[0],a=o[1],u=null===(r=t.button)||void 0===r?void 0:r.wrapper;u&&a.wrapper!==u||e._configureButton(i,q(q({},t),{},{button:q(q({},t.button),{},{wrapper:a.wrapper})}))})}},{key:"_addButton",value:function(t,e){var n=this;this.log("addButton",t,e);var r=function(){var r;n.buttons[t]||(n.log("createButton.new",t),(r=n.apiConfig&&"object"===G(n.apiConfig)?n.createButtonInstance(t):n.createDummyButtonInstance(t)).setButtonConfig(n.buttonConfig),n.buttons[t]=r),n._configureButton(t,e)};K(nt,this)?K(nt,this).then(r):r()}},{key:"renderButtons",value:function(){return this.isEnabled?Object.values(this.buttons).forEach(function(t){return t.render()}):Object.values(this.buttons).forEach(function(t){return t.remove()}),this}},{key:"enable",value:function(){return this.isEnabled||(this.isEnabled=!0,this.renderButtons()),this}},{key:"disable",value:function(){return this.isEnabled||(this.isEnabled=!1,this.renderButtons()),this}}],e&&Y(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,o}();const ot=rt;function it(t){return it="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},it(t)}function at(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function ut(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?at(Object(n),!0).forEach(function(e){ct(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):at(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function ct(t,e,n){return(e=function(t){var e=function(t){if("object"!=it(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=it(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==it(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var st=Object.freeze({INVALIDATE:"ppcp_invalidate_methods",RENDER:"ppcp_render_method",REDRAW:"ppcp_redraw_method"});function lt(t){return Object.values(st).includes(t)}function ft(t){var e=t.event,n=t.paymentMethod,r=void 0===n?"":n,o=t.callback;if(!lt(e))throw new Error("Invalid event: ".concat(e));var i=r?"".concat(e,"-").concat(r):e;document.body.addEventListener(i,o)}function pt(t){return pt="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},pt(t)}function ht(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return yt(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?yt(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);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 o,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function yt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function dt(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,vt(r.key),r)}}function vt(t){var e=function(t){if("object"!=pt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=pt(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pt(e)?e:e+""}var bt=function(){return t=function t(e,n){var r=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.selector=e,this.selectorInContainer=n,this.containers=[],this.reloadContainers(),jQuery(window).resize(function(){r.refresh()}).resize(),jQuery(document).on("ppcp-smart-buttons-init",function(){r.refresh()}),jQuery(document).on("ppcp-shown ppcp-hidden ppcp-enabled ppcp-disabled",function(t,e){r.refresh(),setTimeout(r.refresh.bind(r),200)}),new MutationObserver(this.observeElementsCallback.bind(this)).observe(document.body,{childList:!0,subtree:!0})},(e=[{key:"observeElementsCallback",value:function(t,e){var n,r=this.selector+", .widget_shopping_cart, .widget_shopping_cart_content",o=!1,i=ht(t);try{for(i.s();!(n=i.n()).done;){var a=n.value;"childList"===a.type&&a.addedNodes.forEach(function(t){t.matches&&t.matches(r)&&(o=!0)})}}catch(t){i.e(t)}finally{i.f()}o&&(this.reloadContainers(),this.refresh())}},{key:"reloadContainers",value:function(){var t=this;jQuery(this.selector).each(function(e,n){var r=jQuery(n).parent();t.containers.some(function(t){return t.is(r)})||t.containers.push(r)})}},{key:"refresh",value:function(){var t,e=this,n=ht(this.containers);try{var r=function(){var n=t.value,r=jQuery(n),o=r.width();r.removeClass("ppcp-width-500 ppcp-width-300 ppcp-width-min"),o>=500?r.addClass("ppcp-width-500"):o>=300?r.addClass("ppcp-width-300"):r.addClass("ppcp-width-min");var i=r.children(":visible").first();r.find(e.selectorInContainer).each(function(t,e){var n=jQuery(e);if(n.is(i))return n.css("margin-top","0px"),!0;var r=n.height(),o=Math.max(11,Math.round(.3*r));n.css("margin-top","".concat(o,"px"))})};for(n.s();!(t=n.n()).done;)r()}catch(t){n.e(t)}finally{n.f()}}}])&&dt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),mt="ppcp-gateway",gt={Cart:"cart",Checkout:"checkout",BlockCart:"cart-block",BlockCheckout:"checkout-block",Product:"product",MiniCart:"mini-cart",PayNow:"pay-now",Preview:"preview",Blocks:["cart-block","checkout-block"],Gateways:["checkout","pay-now"]},wt=function(t){return"string"==typeof t?document.querySelector(t):t};function Pt(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return St(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,p.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],h=p.p,y=i[2];n>3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(u=0,p.v=r,p.n=i[1]):h<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,p.n=y,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),h(u,c)):p.n=c:p.v=c);try{if(s=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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(St(e={},r,function(){return this}),e),f=s.prototype=u.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,St(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return c.prototype=s,St(f,"constructor",s),St(s,"constructor",c),c.displayName="GeneratorFunction",St(s,o,"GeneratorFunction"),St(f),St(f,o,"Generator"),St(f,r,function(){return this}),St(f,"toString",function(){return"[object Generator]"}),(Pt=function(){return{w:i,m:p}})()}function St(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}St=function(t,e,n,r){function i(e,n){St(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},St(t,e,n,r)}function Ot(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function kt(t){var e=(null==t?void 0:t.message)||"unknown error";return null!=t&&t.status?"HTTP ".concat(t.status," ").concat(e):e}function jt(){var t;return t=Pt().m(function t(e,n,r){var o,i,a=arguments;return Pt().w(function(t){for(;;)switch(t.p=t.n){case 0:if(o=a.length>3&&void 0!==a[3]?a[3]:"",i=a.length>4&&void 0!==a[4]?a[4]:"error",t.p=1,("error"===i||"warning"===i?console.error:console.info)("[PPCP ".concat(n,"] ").concat(r),o),null!=e&&e.endpoint){t.n=2;break}return t.a(2);case 2:return t.n=3,fetch(e.endpoint,{method:"POST",credentials:"same-origin",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify({nonce:e.nonce,tag:n,event:r,message:String(o),level:i})});case 3:t.n=5;break;case 4:t.p=4,t.v;case 5:return t.a(2)}},t,null,[[1,4]])}),jt=function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){Ot(i,r,o,a,u,"next",t)}function u(t){Ot(i,r,o,a,u,"throw",t)}a(void 0)})},jt.apply(this,arguments)}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 Et(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(t){if("string"==typeof t)return Ct(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?Ct(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);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 o,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,o=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw o}}}}function Ct(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}function At(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Mt(r.key),r)}}function Tt(t,e,n){It(t,e),e.set(t,n)}function It(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function Bt(t,e,n){return(e=Mt(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Mt(t){var e=function(t){if("object"!=_t(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=_t(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(e)?e:e+""}function Dt(t,e){return t.get(Wt(t,e))}function Rt(t,e,n){return t.set(Wt(t,e),n),n}function Wt(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var xt=new WeakMap,Nt=new WeakMap,Gt=new WeakMap,Lt=new WeakMap,qt=new WeakMap,Qt=new WeakMap,zt=new WeakMap,Ht=new WeakMap,Ft=new WeakMap,Vt=new WeakMap,Ut=new WeakMap,Yt=new WeakMap,$t=new WeakMap,Jt=new WeakMap,Kt=new WeakMap,Zt=new WeakMap,Xt=new WeakMap,te=new WeakSet,ee=function(){return t=function t(e){var n,r,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},u=arguments.length>4&&void 0!==arguments[4]?arguments[4]:null,c=arguments.length>5&&void 0!==arguments[5]?arguments[5]:{},s=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),It(this,r=te),r.add(this),Tt(this,xt,void 0),Tt(this,Nt,!1),Tt(this,Gt,!1),Tt(this,Lt,void 0),Tt(this,qt,void 0),Tt(this,Qt,void 0),Tt(this,zt,[]),Tt(this,Ht,void 0),Tt(this,Ft,void 0),Tt(this,Vt,void 0),Tt(this,Ut,void 0),Tt(this,Yt,void 0),Tt(this,$t,null),Tt(this,Jt,!0),Tt(this,Kt,!0),Tt(this,Zt,null),Tt(this,Xt,[]),this.methodId===t.methodId)throw new Error("Cannot initialize the PaymentButton base class");i||(i={});var l=!(null===(n=i)||void 0===n||!n.is_debug),f=this.methodId.replace(/^ppcp?-/,"");Rt(Lt,this,e),Rt(Ht,this,i),Rt(Ft,this,a),Rt(Vt,this,o),Rt(Ut,this,u),Rt(Yt,this,c),this.onClick=s,Rt(xt,this,new S(f,e)),l&&(Dt(xt,this).enabled=!0,function(t,e){window.ppcpPaymentButtonList=window.ppcpPaymentButtonList||{};var n=window.ppcpPaymentButtonList;n[t]=n[t]||[],n[t].push(e)}(f,this)),Rt(qt,this,this.constructor.getWrappers(Dt(Ht,this),Dt(Ft,this))),this.applyButtonStyles(Dt(Ht,this)),this.registerValidationRules(Wt(te,this,ne).bind(this),Wt(te,this,re).bind(this)),function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:".ppcp-button-apm",n=e;if(!window.ppcpApmButtons){if(t&&t.button){var r=t.button.wrapper;jQuery(r).children('div[class^="item-"]').length>0&&(e+=", ".concat(r,' div[class^="item-"]'),n+=', div[class^="item-"]')}window.ppcpApmButtons=new bt(e,n)}}(Dt(Ft,this)),this.initEventListeners()},e=[{key:"methodId",get:function(){return this.constructor.methodId}},{key:"cssClass",get:function(){return this.constructor.cssClass}},{key:"isInitialized",get:function(){return Dt(Nt,this)}},{key:"context",get:function(){return Dt(Lt,this)}},{key:"buttonConfig",get:function(){return Dt(Ht,this)}},{key:"ppcpConfig",get:function(){return Dt(Ft,this)}},{key:"externalHandler",get:function(){return Dt(Vt,this)||{}}},{key:"contextHandler",get:function(){return Dt(Ut,this)||{}}},{key:"requiresShipping",get:function(){return"function"==typeof this.contextHandler.shippingAllowed&&this.contextHandler.shippingAllowed()}},{key:"wrappers",get:function(){return Dt(qt,this)}},{key:"style",get:function(){return gt.MiniCart===this.context?Dt(Qt,this).MiniCart:Dt(Qt,this).Default}},{key:"wrapperId",get:function(){return gt.MiniCart===this.context?this.wrappers.MiniCart:this.isSeparateGateway?this.wrappers.Gateway:gt.Blocks.includes(this.context)?this.wrappers.Block:this.wrappers.Default}},{key:"isInsideClassicGateway",get:function(){return gt.Gateways.includes(this.context)}},{key:"isSeparateGateway",get:function(){return Dt(Ht,this).is_wc_gateway_enabled&&this.isInsideClassicGateway}},{key:"isCurrentGateway",get:function(){if(!this.isInsideClassicGateway)return!0;var t,e=(t=document.querySelector('input[name="payment_method"]:checked'))?t.value:null;return this.isSeparateGateway?this.methodId===e:mt===e}},{key:"isPreview",get:function(){return gt.Preview===this.context}},{key:"isEligible",get:function(){return Dt($t,this)},set:function(t){t!==Dt($t,this)&&(Rt($t,this,t),this.triggerRedraw())}},{key:"isVisible",get:function(){return Dt(Jt,this)},set:function(t){Dt(Jt,this)!==t&&(Rt(Jt,this,t),this.triggerRedraw())}},{key:"isEnabled",get:function(){return Dt(Kt,this)},set:function(t){Dt(Kt,this)!==t&&(Rt(Kt,this,t),this.triggerRedraw())}},{key:"wrapperElement",get:function(){return document.getElementById(this.wrapperId)}},{key:"ppcpButtonWrapperSelector",get:function(){var t,e;return gt.Blocks.includes(this.context)?null:this.context===gt.MiniCart?null===(e=this.ppcpConfig)||void 0===e||null===(e=e.button)||void 0===e?void 0:e.mini_cart_wrapper:null===(t=this.ppcpConfig)||void 0===t||null===(t=t.button)||void 0===t?void 0:t.wrapper}},{key:"isPresent",get:function(){return this.wrapperElement instanceof HTMLElement}},{key:"isButtonAttached",get:function(){if(!Dt(Zt,this))return!1;for(var t=Dt(Zt,this).parentElement;null!==(e=t)&&void 0!==e&&e.parentElement;){var e;if("BODY"===t.tagName)return!0;t=t.parentElement}return!1}},{key:"log",value:function(){var t;(t=Dt(xt,this)).log.apply(t,arguments)}},{key:"error",value:function(){var t;(t=Dt(xt,this)).error.apply(t,arguments)}},{key:"logEvent",value:function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"error";!function(_x,t,e){jt.apply(this,arguments)}(null===(e=this.ppcpConfig)||void 0===e||null===(e=e.ajax)||void 0===e?void 0:e.frontend_log,this.methodId,t,n,r)}},{key:"logGroup",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;Dt(xt,this).group(t)}},{key:"registerValidationRules",value:function(t,e){}},{key:"validateConfiguration",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],n=Et(Dt(Xt,this));try{for(n.s();!(t=n.n()).done;){var r=t.value,o=r.check();if(r.shouldPass&&o)return!0;if(!r.shouldPass&&o)return!e&&r.errorMessage&&this.error(r.errorMessage),!1}}catch(t){n.e(t)}finally{n.f()}return!0}},{key:"applyButtonStyles",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null;e||(e=this.ppcpConfig),Rt(Qt,this,this.constructor.getStyles(t,e)),this.isInitialized&&this.triggerRedraw()}},{key:"configure",value:function(){}},{key:"init",value:function(){Rt(Nt,this,!0)}},{key:"reinit",value:function(){Rt(Nt,this,!1),Rt($t,this,!1)}},{key:"triggerRedraw",value:function(){this.showPaymentGateway(),function(t){var e=t.event,n=t.paymentMethod,r=void 0===n?"":n;if(!lt(e))throw new Error("Invalid event: ".concat(e));var o=r?"".concat(e,"-").concat(r):e;document.body.dispatchEvent(new Event(o))}({event:st.REDRAW,paymentMethod:this.methodId})}},{key:"syncProductButtonsState",value:function(){var t,e=document.querySelector(this.ppcpButtonWrapperSelector);e&&(this.isVisible=function(t){return!!(t.offsetWidth||t.offsetHeight||t.getClientRects().length)}(e),this.isEnabled=!((t=wt(e))&&jQuery(t).hasClass("ppcp-disabled")))}},{key:"initEventListeners",value:function(){var t=this;if(ft({event:st.REDRAW,paymentMethod:this.methodId,callback:function(){return t.refresh()}}),this.isInsideClassicGateway){var e=this.isSeparateGateway?this.methodId:mt;ft({event:st.INVALIDATE,callback:function(){return t.isVisible=!1}}),ft({event:st.RENDER,paymentMethod:e,callback:function(){return t.isVisible=!0}})}this.context===gt.Product&&(jQuery(document).on("ppcp-shown ppcp-hidden ppcp-enabled ppcp-disabled",function(e,n){jQuery(n.selector).is(t.ppcpButtonWrapperSelector)&&t.syncProductButtonsState()}),this.syncProductButtonsState())}},{key:"refresh",value:function(){this.isPresent&&(this.isEligible?(this.applyWrapperStyles(),this.isEligible&&this.isCurrentGateway&&this.isVisible&&(this.isButtonAttached||(this.log("refresh.addButton"),this.addButton()))):this.wrapperElement.style.display="none")}},{key:"showPaymentGateway",value:function(){if(!Dt(Gt,this)&&this.isSeparateGateway&&this.isEligible){var t='style[data-hide-gateway="'.concat(this.methodId,'"]'),e="#".concat(this.wrappers.Default),n=document.querySelector(".wc_payment_method.payment_method_".concat(this.methodId));document.querySelectorAll(t).forEach(function(t){return t.remove()}),"none"!==n.style.display&&""!==n.style.display||(n.style.display="block"),document.querySelectorAll(e).forEach(function(t){return t.remove()}),this.log("Show gateway"),Rt(Gt,this,!0),this.isVisible=this.isCurrentGateway}}},{key:"applyWrapperStyles",value:function(){var t,e,n=this.wrapperElement;if(n){var r,o=this.style,i=o.shape,a=o.height,u=Et(Dt(zt,this));try{for(u.s();!(r=u.n()).done;){var c=r.value;n.classList.remove(c)}}catch(t){u.e(t)}finally{u.f()}Rt(zt,this,[]);var s=["ppcp-button-".concat(i),"ppcp-button-apm",this.cssClass];(t=n.classList).add.apply(t,s),(e=Dt(zt,this)).push.apply(e,s),a&&(n.style.height="".concat(a,"px")),n.style.display=this.isVisible?"block":"none";var l=this.context===gt.Product?"form.cart":null;!function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r=wt(t);r&&(e?(jQuery(r).removeClass("ppcp-disabled").off("mouseup").find("> *").css("pointer-events",""),function(t,e){jQuery(document).trigger("ppcp-enabled",{handler:"ButtonsDisabler.setEnabled",action:"enable",selector:t,element:e})}(t,r)):(jQuery(r).addClass("ppcp-disabled").on("mouseup",function(t){if(t.stopImmediatePropagation(),n){var e=jQuery(n);e.find(".single_add_to_cart_button").hasClass("disabled")&&e.find(":submit").trigger("click")}}).find("> *").css("pointer-events","none"),function(t,e){jQuery(document).trigger("ppcp-disabled",{handler:"ButtonsDisabler.setEnabled",action:"disable",selector:t,element:e})}(t,r)))}(n,this.isEnabled,l)}}},{key:"addButton",value:function(){throw new Error("Must be implemented by the child class")}},{key:"insertButton",value:function(t){if(this.isPresent){var e=this.wrapperElement;Dt(Zt,this)&&this.removeButton(),this.log("insertButton",t),Rt(Zt,this,t),e.appendChild(Dt(Zt,this))}}},{key:"removeButton",value:function(){if(this.isPresent&&Dt(Zt,this)){this.log("removeButton");try{this.wrapperElement.removeChild(Dt(Zt,this))}catch(t){}Rt(Zt,this,null)}}}],n=[{key:"createButton",value:function(t,e,n,r,o,i){var a,u=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null,c=(a="__ppcpPBInstances",document.body[a]||Object.defineProperty(document.body,a,{value:new Map,enumerable:!1,writable:!1,configurable:!1}),document.body[a]),s="".concat(this.methodId,".").concat(t);if(!c.has(s)){var l=new this(t,e,n,r,o,i,u);c.set(s,l)}return c.get(s)}},{key:"getWrappers",value:function(t,e){throw new Error("Must be implemented in the child class")}},{key:"getStyles",value:function(t,e){throw new Error("Must be implemented in the child class")}}],e&&At(t.prototype,e),n&&At(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function ne(t,e){Dt(Xt,this).push({check:t,errorMessage:e,shouldPass:!1})}function re(t){Dt(Xt,this).push({check:t,shouldPass:!0})}function oe(t){return oe="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},oe(t)}function ie(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,ae(r.key),r)}}function ae(t){var e=function(t){if("object"!=oe(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=oe(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==oe(e)?e:e+""}Bt(ee,"methodId","generic"),Bt(ee,"cssClass","");const ue=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},(e=[{key:"update",value:function(t){var e=this;return new Promise(function(n,r){fetch(e.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"same-origin",body:JSON.stringify({nonce:e.config.nonce,paymentData:t})}).then(function(t){return t.json()}).then(function(t){t.success&&n(t.data)})})}}])&&ie(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();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 se(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n<e;n++)r[n]=t[n];return r}var le={"#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 fe(t){Object.entries(le).forEach(function(e){var n,r,o=(r=2,function(t){if(Array.isArray(t))return t}(n=e)||function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,i,a,u=[],c=!0,s=!1;try{if(i=(n=n.call(t)).next,0===e){if(Object(n)!==n)return;c=!1}else for(;!(c=(r=i.call(n)).done)&&(u.push(r.value),u.length!==e);c=!0);}catch(t){s=!0,o=t}finally{try{if(!c&&null!=n.return&&(a=n.return(),Object(a)!==a))return}finally{if(s)throw o}}return u}}(n,r)||function(t,e){if(t){if("string"==typeof t)return se(t,e);var n={}.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?se(t,e):void 0}}(n,r)||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.")}()),i=o[0],a=o[1],u=function(t,e){return e.reduce(function(t,e){return null==t?void 0:t[e]},t)}(t,a);!function(t,e,n){var r;null!=n&&e&&("phone"===t[0]&&"object"===ce(n)&&(n=null===(r=n.phone_number)||void 0===r?void 0:r.national_number),e.value=n)}(a,document.querySelector(i),u)})}function pe(t){var e,n=arguments.length>1&&void 0!==arguments[1]&&arguments[1];(e=t)&&"object"===ce(e)&&(window._PpcpPayerSessionDetails=function(t){var e,n,r,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===(n=t.name)||void 0===n?void 0:n.given_name},address:{country_code:null===(r=t.address)||void 0===r?void 0:r.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}}}(e)),n&&fe(t)}function he(t){return he="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},he(t)}function ye(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,de(r.key),r)}}function de(t){var e=function(t){if("object"!=he(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=he(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==he(e)?e:e+""}function ve(t,e,n){be(t,e),e.set(t,n)}function be(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}function me(t,e){return t.get(we(t,e))}function ge(t,e,n){return t.set(we(t,e),n),n}function we(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}function Pe(t){return t.toLowerCase().trim().replace(/[^a-z0-9_-]/g,"_")}function Se(t){try{var e=JSON.parse(t);return{data:e.data,expires:e.expires||0}}catch(t){return null}}function Oe(t){return t?Date.now()+1e3*t:0}var ke=new WeakMap,je=new WeakMap,_e=new WeakSet;function Ee(){var t=this;this.canUseLocalStorage&&Object.keys(localStorage).forEach(function(e){if(e.startsWith(me(ke,t))){var n=Se(localStorage.getItem(e));n&&n.expires>0&&n.expires<Date.now()&&localStorage.removeItem(e)}})}function Ce(t){var e=Pe(t);if(0===e.length)throw new Error("Name cannot be empty after sanitization");return"".concat(me(ke,this)).concat(e)}function Ae(t){return Ae="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},Ae(t)}function Te(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Re(r.key),r)}}function Ie(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ie=function(){return!!t})()}function Be(t){return Be=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Be(t)}function Me(t,e){return Me=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Me(t,e)}function De(t,e,n){return(e=Re(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Re(t){var e=function(t){if("object"!=Ae(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ae(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ae(e)?e:e+""}var We=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,n){return e=Be(e),function(t,e){if(e&&("object"==Ae(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,Ie()?Reflect.construct(e,n||[],Be(t).constructor):e.apply(t,n))}(this,e,["ppcp-googlepay"])}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&&Me(t,e)}(e,t),n=e,(r=[{key:"getPayer",value:function(){return this.get(e.PAYER)}},{key:"setPayer",value:function(t){this.set(e.PAYER,t,e.PAYER_TTL)}},{key:"clearPayer",value:function(){this.clear(e.PAYER)}}])&&Te(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(function(){return t=function t(e){var n;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),be(this,n=_e),n.add(this),ve(this,ke,""),ve(this,je,null),ge(ke,this,Pe(e)+":"),we(_e,this,Ee).call(this)},e=[{key:"canUseLocalStorage",get:function(){return null===me(je,this)&&ge(je,this,function(){try{var t="__ppcp_test__";return localStorage.setItem(t,"test"),localStorage.removeItem(t),!0}catch(t){return!1}}()),me(je,this)}},{key:"set",value:function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(!this.canUseLocalStorage)throw new Error("Local storage is not available");var r=function(t,e){var n={data:t,expires:Oe(e)};return JSON.stringify(n)}(e,n),o=we(_e,this,Ce).call(this,t);localStorage.setItem(o,r)}},{key:"get",value:function(t){if(!this.canUseLocalStorage)throw new Error("Local storage is not available");var e=we(_e,this,Ce).call(this,t),n=Se(localStorage.getItem(e));return n?n.data:null}},{key:"clear",value:function(t){if(!this.canUseLocalStorage)throw new Error("Local storage is not available");var e=we(_e,this,Ce).call(this,t);localStorage.removeItem(e)}}],e&&ye(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}());De(We,"PAYER","payer"),De(We,"PAYER_TTL",900);const xe=new We;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 Ge(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return Le(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,p.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],h=p.p,y=i[2];n>3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(u=0,p.v=r,p.n=i[1]):h<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,p.n=y,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),h(u,c)):p.n=c:p.v=c);try{if(s=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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(Le(e={},r,function(){return this}),e),f=s.prototype=u.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 c.prototype=s,Le(f,"constructor",s),Le(s,"constructor",c),c.displayName="GeneratorFunction",Le(s,o,"GeneratorFunction"),Le(f),Le(f,o,"Generator"),Le(f,r,function(){return this}),Le(f,"toString",function(){return"[object Generator]"}),(Ge=function(){return{w:i,m:p}})()}function Le(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Le=function(t,e,n,r){function i(e,n){Le(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},Le(t,e,n,r)}function qe(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function Qe(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){qe(i,r,o,a,u,"next",t)}function u(t){qe(i,r,o,a,u,"throw",t)}a(void 0)})}}function ze(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,r)}return n}function He(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ze(Object(n),!0).forEach(function(e){Ze(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ze(Object(n)).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function Fe(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Xe(r.key),r)}}function Ve(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Ve=function(){return!!t})()}function Ue(t,e,n,r){var o=Ye($e(1&r?t.prototype:t),e,n);return 2&r&&"function"==typeof o?function(t){return o.apply(n,t)}:o}function Ye(){return Ye="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var r=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=$e(t)););return t}(t,e);if(r){var o=Object.getOwnPropertyDescriptor(r,e);return o.get?o.get.call(arguments.length<3?t:n):o.value}},Ye.apply(null,arguments)}function $e(t){return $e=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},$e(t)}function Je(t,e){return Je=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Je(t,e)}function Ke(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}function Ze(t,e,n){return(e=Xe(e))in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function Xe(t){var e=function(t){if("object"!=Ne(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Ne(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ne(e)?e:e+""}function tn(t,e,n){return t.set(nn(t,e),n),n}function en(t,e){return t.get(nn(t,e))}function nn(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var rn="failed",on="payerAction";function an(t){return{country_code:null==t?void 0:t.countryCode,address_line_1:null==t?void 0:t.address1,address_line_2:null==t?void 0:t.address2,admin_area_1:null==t?void 0:t.administrativeArea,admin_area_2:null==t?void 0:t.locality,postal_code:null==t?void 0:t.postalCode}}function un(t){var e,n=null==t||null===(e=t.paymentMethodData)||void 0===e||null===(e=e.info)||void 0===e?void 0:e.billingAddress;return{email_address:null==t?void 0:t.email,name:{given_name:n.name.split(" ")[0],surname:n.name.split(" ").slice(1).join(" ")},address:an(n)}}function cn(t){var e,n,r=null!==(e=null==t?void 0:t.shippingAddress)&&void 0!==e?e:null==t||null===(n=t.paymentMethodData)||void 0===n||null===(n=n.info)||void 0===n?void 0:n.billingAddress;return{name:{full_name:null==r?void 0:r.name},address:an(r)}}var sn=new WeakMap,ln=new WeakMap,fn=new WeakMap,pn=new WeakMap,hn=new WeakMap,yn=new WeakMap,dn=function(t){function e(t,n,r,o,i,a){var u,c=arguments.length>6&&void 0!==arguments[6]?arguments[6]:null;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Ke(u=function(t,e,n){return e=$e(e),function(t,e){if(e&&("object"==Ne(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,Ve()?Reflect.construct(e,n||[],$e(t).constructor):e.apply(t,n))}(this,e,[t,n,r,o,i,a,c]),sn,null),Ke(u,ln,null),Ke(u,fn,null),Ze(u,"googlePayConfig",null),Ke(u,pn,0),Ke(u,hn,1e3),Ke(u,yn,null),u.init=u.init.bind(u),u.onPaymentDataChanged=u.onPaymentDataChanged.bind(u),u.onButtonClick=u.onButtonClick.bind(u),u.onClick=c,u.log("Create instance"),u}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&&Je(t,e)}(e,t),n=e,r=[{key:"requiresShipping",get:function(){var t;return Ue(e,"requiresShipping",this,1)&&(null===(t=this.buttonConfig.shipping)||void 0===t?void 0:t.enabled)}},{key:"googlePayApi",get:function(){var t;return null===(t=window.google)||void 0===t||null===(t=t.payments)||void 0===t?void 0:t.api}},{key:"paymentsClient",get:function(){return en(sn,this)}},{key:"transactionInfo",get:function(){return en(ln,this)},set:function(t){tn(ln,this,t),this.refresh()}},{key:"registerValidationRules",value:function(t,e){var n=this;return t(function(){return!["TEST","PRODUCTION"].includes(n.buttonConfig.environment)},"Invalid environment: ".concat(this.buttonConfig.environment)),e(function(){return n.isPreview}),t(function(){return!n.googlePayConfig},"No API configuration - missing configure() call?"),t(function(){var t;return!(null!==(t=n.contextHandler)&&void 0!==t&&t.validateContext())},"Invalid context handler."),t(function(){var t;return(null===(t=n.buttonAttributes)||void 0===t?void 0:t.height)&&isNaN(parseInt(n.buttonAttributes.height))},"Invalid height in buttonAttributes"),t(function(){var t;return(null===(t=n.buttonAttributes)||void 0===t?void 0:t.borderRadius)&&isNaN(parseInt(n.buttonAttributes.borderRadius))},"Invalid borderRadius in buttonAttributes"),!0}},{key:"configure",value:function(t,e){var n=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};en(pn,this)||tn(pn,this,Date.now()),null!=r&&r.height&&null!=r&&r.borderRadius&&tn(yn,this,He({},r));var o=null!=r&&r.height?r:en(yn,this);if(Date.now()-en(pn,this)>en(hn,this))return this.log("GooglePay: Timeout waiting for buttonAttributes - proceeding with initialization"),this.googlePayConfig=t,tn(ln,this,e),this.buttonAttributes=o||r,this.allowedPaymentMethods=this.googlePayConfig.allowedPaymentMethods,this.baseCardPaymentMethod=this.allowedPaymentMethods[0],void this.init();null!=o&&o.height&&null!=o&&o.borderRadius?(tn(pn,this,0),this.googlePayConfig=t,tn(ln,this,e),this.buttonAttributes=o,this.allowedPaymentMethods=this.googlePayConfig.allowedPaymentMethods,this.baseCardPaymentMethod=this.allowedPaymentMethods[0],this.init()):setTimeout(function(){return n.configure(t,e,r)},100)}},{key:"init",value:function(){var t=this;this.isInitialized||this.validateConfiguration()&&(Ue(e,"init",this,3)([]),tn(sn,this,this.createPaymentsClient()),this.paymentsClient.isReadyToPay(this.buildReadyToPayRequest(this.allowedPaymentMethods,this.googlePayConfig)).then(function(e){t.log("PaymentsClient.isReadyToPay response:",e),t.isEligible=!!e.result}).catch(function(e){t.error(e),t.isEligible=!1}))}},{key:"reinit",value:function(){this.validateConfiguration(!0)&&(Ue(e,"reinit",this,3)([]),this.init())}},{key:"preparePaymentDataCallbacks",value:function(){var t={};return this.isPreview||this.requiresShipping&&(t.onPaymentDataChanged=this.onPaymentDataChanged),t}},{key:"createPaymentsClient",value:function(){if(!this.googlePayApi)return null;var t=this.preparePaymentDataCallbacks();return new this.googlePayApi.PaymentsClient({environment:this.buttonConfig.environment,paymentDataCallbacks:t})}},{key:"buildReadyToPayRequest",value:function(t,e){return this.log("Ready To Pay request",e,t),Object.assign({},e,{allowedPaymentMethods:t})}},{key:"addButton",value:function(){var t,n,r;if(this.paymentsClient){null!==(t=this.buttonAttributes)&&void 0!==t&&t.height||null===(n=en(yn,this))||void 0===n||!n.height||(this.buttonAttributes=He({},en(yn,this))),this.removeButton();var o=this.baseCardPaymentMethod,i=this.style,a=i.color,u=i.type,c={buttonColor:a||"black",buttonSizeMode:"fill",buttonLocale:i.language||"en",buttonType:u||"pay",buttonRadius:parseInt(null===(r=this.buttonAttributes)||void 0===r?void 0:r.borderRadius,10),onClick:this.onButtonClick,allowedPaymentMethods:[o]},s=this.paymentsClient.createButton(c);tn(fn,this,s),Ue(e,"insertButton",this,3)([s]),this.applyWrapperStyles()}}},{key:"applyWrapperStyles",value:function(){var t;Ue(e,"applyWrapperStyles",this,3)([]);var n=this.wrapperElement;if(n){var r=null!==(t=this.buttonAttributes)&&void 0!==t&&t.height?this.buttonAttributes:en(yn,this);if(null!=r&&r.height){var o=parseInt(r.height,10);isNaN(o)||(n.style.height="".concat(o,"px"),n.style.minHeight="".concat(o,"px"))}}}},{key:"removeButton",value:function(){if(this.isPresent&&en(fn,this)){this.log("removeButton");try{this.wrapperElement.removeChild(en(fn,this))}catch(t){}tn(fn,this,null)}}},{key:"onButtonClick",value:(a=Qe(Ge().m(function t(){var e,n,r,o,i=this;return Ge().w(function(t){for(;;)switch(t.n){case 0:return this.logGroup("onButtonClick"),e=function(){var t=Qe(Ge().m(function t(){var e,n;return Ge().w(function(t){for(;;)if(0===t.n)return window.ppcpFundingSource="googlepay",null===(e=i.onClick)||void 0===e||e.call(i),n=i.paymentDataRequest(),i.log("onButtonClick: paymentDataRequest",n,i.context),t.a(2,i.paymentsClient.loadPaymentData(n).then(function(t){return i.log("loadPaymentData response:",t),t}).catch(function(t){throw i.error("loadPaymentData failed:",t),t}))},t)}));return function(){return t.apply(this,arguments)}}(),n=function(){var t=Qe(Ge().m(function t(){return Ge().w(function(t){for(;;)switch(t.n){case 0:if("function"==typeof i.contextHandler.validateForm){t.n=1;break}return t.a(2,Promise.resolve());case 1:return t.a(2,i.contextHandler.validateForm().catch(function(t){throw i.error("Form validation failed:",t),t}))}},t)}));return function(){return t.apply(this,arguments)}}(),r=function(){var t=Qe(Ge().m(function t(){return Ge().w(function(t){for(;;)switch(t.n){case 0:if("function"==typeof i.contextHandler.transactionInfo){t.n=1;break}return t.a(2,Promise.resolve());case 1:return t.a(2,i.contextHandler.transactionInfo().then(function(t){i.transactionInfo=t}).catch(function(t){throw i.error("Failed to get transaction info:",t),t}))}},t)}));return function(){return t.apply(this,arguments)}}(),t.n=1,n().then(r).then(e);case 1:if(o=t.v,this.logGroup(),o){t.n=2;break}return t.a(2);case 2:return t.a(2,this.processPayment(o))}},t,this)})),function(){return a.apply(this,arguments)})},{key:"paymentDataRequest",value:function(){var t=this.requiresShipping,e=[];return t&&e.push("SHIPPING_ADDRESS","SHIPPING_OPTION"),He(He({},{apiVersion:2,apiVersionMinor:0}),{},{allowedPaymentMethods:this.googlePayConfig.allowedPaymentMethods,transactionInfo:this.transactionInfo.finalObject,merchantInfo:this.googlePayConfig.merchantInfo,callbackIntents:e,emailRequired:!0,shippingAddressRequired:t,shippingOptionRequired:t,shippingAddressParameters:this.shippingAddressParameters()})}},{key:"shippingAddressParameters",value:function(){return{allowedCountryCodes:this.buttonConfig.shipping.countries,phoneNumberRequired:!0}}},{key:"onPaymentDataChanged",value:function(t){var e=this;return this.log("onPaymentDataChanged",t),new Promise(function(){var n=Qe(Ge().m(function n(r,o){var i,a,u,c,s,l,f,p;return Ge().w(function(n){for(;;)switch(n.p=n.n){case 0:return n.p=0,a={},n.n=1,new ue(e.buttonConfig.ajax.update_payment_data).update(t);case 1:if(u=n.v,c=e.transactionInfo,s=["checkout-block","checkout","cart-block","cart","mini-cart","pay-now"].includes(e.context),e.log("onPaymentDataChanged:updatedData",u),e.log("onPaymentDataChanged:transactionInfo",c),u.country_code=c.countryCode,u.currency_code=c.currencyCode,null!==(i=u.shipping_options)&&void 0!==i&&null!==(i=i.shippingOptions)&&void 0!==i&&i.length){n.n=2;break}return a.error=e.unserviceableShippingAddressError(),r(a),n.a(2);case 2:["INITIALIZE","SHIPPING_ADDRESS"].includes(t.callbackTrigger)&&(a.newShippingOptionParameters=e.sanitizeShippingOptions(u.shipping_options)),u.total&&s?(c.setTotal(u.total,u.shipping_fee),e.syncShippingOptionWithForm(null==t||null===(l=t.shippingOptionData)||void 0===l?void 0:l.id)):c.shippingFee=e.getShippingCosts(null==t||null===(f=t.shippingOptionData)||void 0===f?void 0:f.id,u.shipping_options),a.newTransactionInfo=e.calculateNewTransactionInfo(c),r(a),n.n=4;break;case 3:n.p=3,p=n.v,e.logEvent("shipping-update-failed",kt(p)),o(p);case 4:return n.a(2)}},n,null,[[0,3]])}));return function(_x,t){return n.apply(this,arguments)}}())}},{key:"sanitizeShippingOptions",value:function(t){var e=t.shippingOptions.map(function(t){return{id:t.id,label:t.label,description:t.description}}),n=t.defaultSelectedOptionId;return e.some(function(t){return t.id===n})||(n=e[0].id),{defaultSelectedOptionId:n,shippingOptions:e}}},{key:"getShippingCosts",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=e.shippingOptions,r=void 0===n?[]:n,o=e.defaultSelectedOptionId,i=void 0===o?"":o;if(null==r||!r.length)return this.log("Cannot calculate shipping cost: No Shipping Options"),0;var a=function(t){return r.find(function(e){return e.id===t})},u=a("shipping_option_unselected"!==t&&a(t)?t:i);return Number(null==u?void 0:u.cost)||0}},{key:"unserviceableShippingAddressError",value:function(){return{reason:"SHIPPING_ADDRESS_UNSERVICEABLE",message:"Cannot ship to the selected address",intent:"SHIPPING_ADDRESS"}}},{key:"calculateNewTransactionInfo",value:function(t){return t.finalObject}},{key:"processPayment",value:(i=Qe(Ge().m(function t(e){var n,r,o,i,a,u,c,s,l,p,h,y,d,v=this;return Ge().w(function(t){for(;;)switch(t.p=t.n){case 0:return this.logGroup("processPayment"),r=un(e),o=cn(e),i=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null,r={transactionState:t};return(e||n)&&(r.error={intent:e,message:n}),v.log("processPaymentResponse",r),r},a=function(t){return v.logEvent("payment-failed",t),i("ERROR","PAYMENT_AUTHORIZATION",t)},u=function(){var t=Qe(Ge().m(function t(n){var r,o,i;return Ge().w(function(t){for(;;)switch(t.n){case 0:return r={orderId:n,paymentMethodData:e.paymentMethodData},t.n=1,f.paypal.Googlepay().confirmOrder(r);case 1:o=t.v,v.log("confirmOrder",o),i=null==o?void 0:o.status,t.n="APPROVED"===i?2:"PAYER_ACTION_REQUIRED"===i?3:4;break;case 2:return t.a(2,"approved");case 3:return t.a(2,on);case 4:return v.logEvent("confirm-order-not-approved","status=".concat(null==o?void 0:o.status)),t.a(2,rn);case 5:return t.a(2)}},t)}));return function(e){return t.apply(this,arguments)}}(),c=function(t){return v.log("initiatePayerAction",t),f.paypal.Googlepay().initiatePayerAction({orderId:t})},s=function(){var t=Qe(Ge().m(function t(e){var n;return Ge().w(function(t){for(;;)switch(t.n){case 0:return n=!0,v.log("approveOrder",e),t.n=1,v.contextHandler.approveOrder({orderID:e,payer:r,shippingAddress:o},{restart:function(){return new Promise(function(t){n=!1,t()})},order:{get:function(){return new Promise(function(t){t(null)})}}});case 1:return t.a(2,n)}},t)}));return function(e){return t.apply(this,arguments)}}(),xe.setPayer(r),pe(r),t.p=1,t.n=2,this.contextHandler.createOrder();case 2:return l=t.v,this.log("createOrder",l),t.n=3,u(l);case 3:if(p=t.v,rn!==p){t.n=4;break}n=a("TRANSACTION FAILED"),t.n=8;break;case 4:if(on!==p){t.n=6;break}return t.n=5,c(l);case 5:h=t.v,this.log("3DS verification completed",h);case 6:return t.n=7,s(l);case 7:y=t.v,n=y?i("SUCCESS"):a("FAILED TO APPROVE");case 8:t.n=10;break;case 9:t.p=9,d=t.v,n=a(d.message);case 10:return this.logGroup(),t.a(2,n)}},t,this,[[1,9]])})),function(t){return i.apply(this,arguments)})},{key:"syncShippingOptionWithForm",value:function(t){for(var e=[".woocommerce-shipping-methods",".wc-block-components-shipping-rates-control",".wc-block-components-totals-shipping"],n=t.replace(/"/g,""),r=0,o=e;r<o.length;r++){var i="".concat(o[r],' input[type="radio"][value="').concat(n,'"]'),a=document.querySelector(i);if(a)return a.click(),!0}for(var u=0,c=e;u<c.length;u++){var s="".concat(c[u],' select option[value="').concat(n,'"]'),l=document.querySelector(s);if(l){var f=l.closest("select");if(f)return f.value=n,f.dispatchEvent(new Event("change")),!0}}return!1}}],o=[{key:"getWrappers",value:function(t,e){var n,r,o;return function(){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"",n=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"",r=arguments.length>4&&void 0!==arguments[4]?arguments[4]:"",o=function(t){return t.replace(/^#/,"")};return{Default:o(arguments.length>0&&void 0!==arguments[0]?arguments[0]:""),SmartButton:o(e),Block:o(n),Gateway:o(r),MiniCart:o(t)}}((null==t||null===(n=t.button)||void 0===n?void 0:n.wrapper)||"",(null==t||null===(r=t.button)||void 0===r?void 0:r.mini_cart_wrapper)||"",(null==e||null===(o=e.button)||void 0===o?void 0:o.wrapper)||"","ppc-button-googlepay-container","ppc-button-ppcp-googlepay")}},{key:"getStyles",value:function(t,e){var n=function(t,e){return{Default:ut(ut({},t.style),e.style),MiniCart:ut(ut({},t.mini_cart_style),e.mini_cart_style)}}((null==e?void 0:e.button)||{},(null==t?void 0:t.button)||{});return"buy"===n.MiniCart.type&&(n.MiniCart.type="pay"),n}}],r&&Fe(n.prototype,r),o&&Fe(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a}(ee);Ze(dn,"methodId","ppcp-googlepay"),Ze(dn,"cssClass","google-pay");const vn=dn;function bn(t){return bn="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},bn(t)}function mn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,gn(r.key),r)}}function gn(t){var e=function(t){if("object"!=bn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=bn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bn(e)?e:e+""}function wn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(wn=function(){return!!t})()}function Pn(t){return Pn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Pn(t)}function Sn(t,e){return Sn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Sn(t,e)}function On(t,e){return t.get(kn(t,e))}function kn(t,e,n){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:n;throw new TypeError("Private element is not present on this object")}var jn=new WeakMap,En=function(t){function e(t){var n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,n){(function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")})(t,e),e.set(t,n)}(n=function(t,e,n){return e=Pn(e),function(t,e){if(e&&("object"==bn(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,wn()?Reflect.construct(e,n||[],Pn(t).constructor):e.apply(t,n))}(this,e,[t]),jn,null),n.selector="".concat(t.selector,"GooglePay"),n.defaultAttributes={button:{style:{type:"pay",color:"black",language:"en"}}},n}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&&Sn(t,e)}(e,t),n=e,(r=[{key:"createButton",value:function(t){var e,n;On(jn,this)||(e=jn,n=new vn("preview",null,t,this.ppcpConfig),e.set(kn(e,this),n)),On(jn,this).configure(this.apiConfig,null),On(jn,this).applyButtonStyles(t,this.ppcpConfig),On(jn,this).reinit()}},{key:"dynamicPreviewConfig",value:function(t,e){e.button&&t.button&&Object.assign(t.button.style,e.button.style)}}])&&mn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(E);function Cn(t){return Cn="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},Cn(t)}function An(){var t,e,n="function"==typeof Symbol?Symbol:{},r=n.iterator||"@@iterator",o=n.toStringTag||"@@toStringTag";function i(n,r,o,i){var c=r&&r.prototype instanceof u?r:u,s=Object.create(c.prototype);return Tn(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],f=!1,p={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,p.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!f&&s&&!o&&e<l.length;e++){var o,i=l[e],h=p.p,y=i[2];n>3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&h<i[1])?(u=0,p.v=r,p.n=i[1]):h<y&&(o=n<3||i[0]>r||r>y)&&(i[4]=n,i[5]=r,p.n=y,u=0))}if(o||n>1)return a;throw f=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(f&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!f;){i||(u?u<3?(u>1&&(p.n=-1),h(u,c)):p.n=c:p.v=c);try{if(s=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=(f=p.n<0)?c:n.call(r,p))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:f}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(Tn(e={},r,function(){return this}),e),f=s.prototype=u.prototype=Object.create(l);function p(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,Tn(t,o,"GeneratorFunction")),t.prototype=Object.create(f),t}return c.prototype=s,Tn(f,"constructor",s),Tn(s,"constructor",c),c.displayName="GeneratorFunction",Tn(s,o,"GeneratorFunction"),Tn(f),Tn(f,o,"Generator"),Tn(f,r,function(){return this}),Tn(f,"toString",function(){return"[object Generator]"}),(An=function(){return{w:i,m:p}})()}function Tn(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}Tn=function(t,e,n,r){function i(e,n){Tn(t,e,function(t){return this._invoke(e,n,t)})}e?o?o(t,e,{value:n,enumerable:!r,configurable:!r,writable:!r}):t[e]=n:(i("next",0),i("throw",1),i("return",2))},Tn(t,e,n,r)}function In(t,e,n,r,o,i,a){try{var u=t[i](a),c=u.value}catch(t){return void n(t)}u.done?e(c):Promise.resolve(c).then(r,o)}function Bn(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,Mn(r.key),r)}}function Mn(t){var e=function(t){if("object"!=Cn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var n=e.call(t,"string");if("object"!=Cn(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Cn(e)?e:e+""}function Dn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(t){}return(Dn=function(){return!!t})()}function Rn(t){return Rn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Rn(t)}function Wn(t,e){return Wn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Wn(t,e)}var xn=function(t){function e(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),function(t,e,n){return e=Rn(e),function(t,e){if(e&&("object"==Cn(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,Dn()?Reflect.construct(e,n||[],Rn(t).constructor):e.apply(t,n))}(this,e,[{methodName:"GooglePay",buttonConfig:window.wc_ppcp_googlepay_admin}])}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&&Wn(t,e)}(e,t),n=e,r=[{key:"fetchConfig",value:(o=An().m(function t(e){var n,r;return An().w(function(t){for(;;)switch(t.p=t.n){case 0:if(r=null==e||null===(n=e.Googlepay())||void 0===n?void 0:n.config){t.n=1;break}return this.error("configuration object cannot be retrieved from PayPal"),t.a(2,{});case 1:return t.p=1,t.n=2,r();case 2:return t.a(2,t.v);case 3:return t.p=3,t.v.message.includes("Not Eligible")&&(this.apiError="Not Eligible"),t.a(2,null)}},t,this,[[1,3]])}),i=function(){var t=this,e=arguments;return new Promise(function(n,r){var i=o.apply(t,e);function a(t){In(i,n,r,a,u,"next",t)}function u(t){In(i,n,r,a,u,"throw",t)}a(void 0)})},function(_x){return i.apply(this,arguments)})},{key:"createButtonInstance",value:function(t){return new En({selector:t,apiConfig:this.apiConfig,methodName:this.methodName})}}],r&&Bn(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i}(ot);xn.instance||(xn.instance=new xn),xn.instance})();
Save File
Cancel