Ubuntu

­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­ (()=>{"use strict";var t={4744:t=>{var e=function(t){return function(t){return!!t&&"object"==typeof t}(t)&&!function(t){var e=Object.prototype.toString.call(t);return"[object RegExp]"===e||"[object Date]"===e||function(t){return t.$$typeof===n}(t)}(t)},n="function"==typeof Symbol&&Symbol.for?Symbol.for("react.element"):60103;function r(t,e){return!1!==e.clone&&e.isMergeableObject(t)?u((n=t,Array.isArray(n)?[]:{}),t,e):t;var n}function o(t,e,n){return t.concat(e).map(function(t){return r(t,n)})}function i(t){return Object.keys(t).concat(function(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}(t))}function a(t,e){try{return e in t}catch(t){return!1}}function u(t,n,c){(c=c||{}).arrayMerge=c.arrayMerge||o,c.isMergeableObject=c.isMergeableObject||e,c.cloneUnlessOtherwiseSpecified=r;var s=Array.isArray(n);return s===Array.isArray(t)?s?c.arrayMerge(t,n,c):function(t,e,n){var o={};return n.isMergeableObject(t)&&i(t).forEach(function(e){o[e]=r(t[e],n)}),i(e).forEach(function(i){(function(t,e){return a(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))})(t,i)||(a(t,i)&&n.isMergeableObject(e[i])?o[i]=function(t,e){if(!e.customMerge)return u;var n=e.customMerge(t);return"function"==typeof n?n:u}(i,n)(t[i],e[i],n):o[i]=r(e[i],n))}),o}(t,n,c):r(n,c)}u.all=function(t,e){if(!Array.isArray(t))throw new Error("first argument should be an array");return t.reduce(function(t,n){return u(t,n,e)},{})};var c=u;t.exports=c}},e={};function n(r){var o=e[r];if(void 0!==o)return o.exports;var i=e[r]={exports:{}};return t[r](i,i.exports,n),i.exports}function r(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 o(t){return o="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},o(t)}function i(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)||u(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 a(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=u(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 u(t,e){if(t){if("string"==typeof t)return c(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)?c(t,e):void 0}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n{var e=t&&t.__esModule?()=>t.default:()=>t;return n.d(e,{a:e}),e},n.d=(t,e)=>{for(var r in e)n.o(e,r)&&!n.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},n.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),"function"==typeof SuppressedError&&SuppressedError;var p=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=a(this.buttons);try{for(e.s();!(t=e.n()).done;){var n=i(t.value,1)[0];this.renderButtons(n)}}catch(t){e.e(t)}finally{e.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=a(this.messages);try{for(e.s();!(t=e.n()).done;){var n=i(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=a(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('
')),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}}])&&s(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();window.widgetBuilder=window.widgetBuilder||new p;const f=window.widgetBuilder;function h(t){return h="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},h(t)}function y(t,e){for(var n=0;n0&&void 0!==arguments[0]?arguments[0]:null;b(k,this)&&(t&&!b(S,this)||(console.groupEnd(),m(S,this,null)),t&&(console.group(t),m(S,this,t)))}}],e&&y(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),j=n(4744),O=n.n(j);function _(t){return _="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)}function C(t,e){for(var n=0;n'.concat(this.label,""),this._applyStyles(null===(n=this.ppcpConfig)||void 0===n||null===(n=n.button)||void 0===n?void 0:n.style),this.domWrapper.appendChild(R(G,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&&T(n.prototype,r),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r}(A);function L(t){return L="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},L(t)}function F(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 z(t){for(var e=1;et.length)&&(e=t.length);for(var n=0,r=Array(e);n3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&hr||r>y)&&(i[4]=n,i[5]=r,f.n=y,u=0))}if(o||n>1)return a;throw p=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(p&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!p;){i||(u?u<3?(u>1&&(f.n=-1),h(u,c)):f.n=c:f.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=(p=f.n<0)?c:n.call(r,f))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(H(e={},r,function(){return this}),e),p=s.prototype=u.prototype=Object.create(l);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,H(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,H(p,"constructor",s),H(s,"constructor",c),c.displayName="GeneratorFunction",H(s,o,"GeneratorFunction"),H(p),H(p,o,"Generator"),H(p,r,function(){return this}),H(p,"toString",function(){return"[object Generator]"}),(V=function(){return{w:i,m:f}})()}function H(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}H=function(t,e,n,r){function i(e,n){H(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))},H(t,e,n,r)}function $(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 J(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){$(i,r,o,a,u,"next",t)}function u(t){$(i,r,o,a,u,"throw",t)}a(void 0)})}}function K(t,e){for(var n=0;n1?n-1:0),o=1;o1?n-1:0),o=1;o3&&void 0!==arguments[3])||arguments[3];clearInterval(n),r?t():e("Timeout while waiting for widgetBuilder.paypal")},a=new Promise(function(t,e){var r=0,a=setInterval(function(){f.paypal?i(t,e,a):r>=n&&i(t,e,a,!1),r+=o},o)}),u=r({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,Z(rt,this).call(this);case 7:tt(ot,this,null);case 8:return t.a(2)}},t,this,[[3,5]])})),function(){return n.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 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}}(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,z(z({},t),{},{button:z(z({},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"===L(n.apiConfig)?n.createButtonInstance(t):n.createDummyButtonInstance(t)).setButtonConfig(n.buttonConfig),n.buttons[t]=r),n._configureButton(t,e)};Z(ot,this)?Z(ot,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&&K(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n,o}();const at=it;function ut(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);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}}}}(t);try{for(r.s();!(e=r.n()).done;){var o=e.value,i=o.contactField,a=void 0===i?null:i,u=o.code,c=void 0===u?null:u,s=o.message,l=a?new ApplePayError(c,a,void 0===s?null:s):new ApplePayError(c);n.push(l)}}catch(t){r.e(t)}finally{r.f()}return n}function st(t){return st="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},st(t)}function lt(){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 pt(s,"_invoke",function(n,r,o){var i,u,c,s=0,l=o||[],p=!1,f={p:0,n:0,v:t,a:h,f:h.bind(t,4),d:function(e,n){return i=e,u=0,c=t,f.n=n,a}};function h(n,r){for(u=n,c=r,e=0;!p&&s&&!o&&e3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&hr||r>y)&&(i[4]=n,i[5]=r,f.n=y,u=0))}if(o||n>1)return a;throw p=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(p&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!p;){i||(u?u<3?(u>1&&(f.n=-1),h(u,c)):f.n=c:f.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=(p=f.n<0)?c:n.call(r,f))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(pt(e={},r,function(){return this}),e),p=s.prototype=u.prototype=Object.create(l);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,pt(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,pt(p,"constructor",s),pt(s,"constructor",c),c.displayName="GeneratorFunction",pt(s,o,"GeneratorFunction"),pt(p),pt(p,o,"Generator"),pt(p,r,function(){return this}),pt(p,"toString",function(){return"[object Generator]"}),(lt=function(){return{w:i,m:f}})()}function pt(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}pt=function(t,e,n,r){function i(e,n){pt(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))},pt(t,e,n,r)}function ft(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 ht(t,e){for(var n=0;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 St(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n=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()}}}])&&Pt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),_t="ppcp-gateway",Ct={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"]};function Et(t){return Et="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},Et(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 Mt(t){for(var e=1;e=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 Nt(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n1&&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),Lt(this,r=le),r.add(this),qt(this,Ht,void 0),qt(this,$t,!1),qt(this,Jt,!1),qt(this,Kt,void 0),qt(this,Yt,void 0),qt(this,Xt,void 0),qt(this,Zt,[]),qt(this,te,void 0),qt(this,ee,void 0),qt(this,ne,void 0),qt(this,re,void 0),qt(this,oe,void 0),qt(this,ie,null),qt(this,ae,!0),qt(this,ue,!0),qt(this,ce,null),qt(this,se,[]),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),p=this.methodId.replace(/^ppcp?-/,"");Ut(Kt,this,e),Ut(te,this,i),Ut(ee,this,a),Ut(ne,this,o),Ut(re,this,u),Ut(oe,this,c),this.onClick=s,Ut(Ht,this,new P(p,e)),l&&(Qt(Ht,this).enabled=!0,function(t,e){window.ppcpPaymentButtonList=window.ppcpPaymentButtonList||{};var n=window.ppcpPaymentButtonList;n[t]=n[t]||[],n[t].push(e)}(p,this)),Ut(Yt,this,this.constructor.getWrappers(Qt(te,this),Qt(ee,this))),this.applyButtonStyles(Qt(te,this)),this.registerValidationRules(Vt(le,this,fe).bind(this),Vt(le,this,he).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 Ot(e,n)}}(Qt(ee,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 Qt($t,this)}},{key:"context",get:function(){return Qt(Kt,this)}},{key:"buttonConfig",get:function(){return Qt(te,this)}},{key:"ppcpConfig",get:function(){return Qt(ee,this)}},{key:"externalHandler",get:function(){return Qt(ne,this)||{}}},{key:"contextHandler",get:function(){return Qt(re,this)||{}}},{key:"requiresShipping",get:function(){return"function"==typeof this.contextHandler.shippingAllowed&&this.contextHandler.shippingAllowed()}},{key:"wrappers",get:function(){return Qt(Yt,this)}},{key:"style",get:function(){return Ct.MiniCart===this.context?Qt(Xt,this).MiniCart:Qt(Xt,this).Default}},{key:"wrapperId",get:function(){return Ct.MiniCart===this.context?this.wrappers.MiniCart:this.isSeparateGateway?this.wrappers.Gateway:Ct.Blocks.includes(this.context)?this.wrappers.Block:this.wrappers.Default}},{key:"isInsideClassicGateway",get:function(){return Ct.Gateways.includes(this.context)}},{key:"isSeparateGateway",get:function(){return Qt(te,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:_t===e}},{key:"isPreview",get:function(){return Ct.Preview===this.context}},{key:"isEligible",get:function(){return Qt(ie,this)},set:function(t){t!==Qt(ie,this)&&(Ut(ie,this,t),this.triggerRedraw())}},{key:"isVisible",get:function(){return Qt(ae,this)},set:function(t){Qt(ae,this)!==t&&(Ut(ae,this,t),this.triggerRedraw())}},{key:"isEnabled",get:function(){return Qt(ue,this)},set:function(t){Qt(ue,this)!==t&&(Ut(ue,this,t),this.triggerRedraw())}},{key:"wrapperElement",get:function(){return document.getElementById(this.wrapperId)}},{key:"ppcpButtonWrapperSelector",get:function(){var t,e;return Ct.Blocks.includes(this.context)?null:this.context===Ct.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(!Qt(ce,this))return!1;for(var t=Qt(ce,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=Qt(Ht,this)).log.apply(t,arguments)}},{key:"error",value:function(){var t;(t=Qt(Ht,this)).error.apply(t,arguments)}},{key:"logGroup",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;Qt(Ht,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=Rt(Qt(se,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),Ut(Xt,this,this.constructor.getStyles(t,e)),this.isInitialized&&this.triggerRedraw()}},{key:"configure",value:function(){}},{key:"init",value:function(){Ut($t,this,!0)}},{key:"reinit",value:function(){Ut($t,this,!1),Ut(ie,this,!1)}},{key:"triggerRedraw",value:function(){this.showPaymentGateway(),function(t){var e=t.event,n=t.paymentMethod,r=void 0===n?"":n;if(!It(e))throw new Error("Invalid event: ".concat(e));var o=r?"".concat(e,"-").concat(r):e;document.body.dispatchEvent(new Event(o))}({event:Bt.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(xt({event:Bt.REDRAW,paymentMethod:this.methodId,callback:function(){return t.refresh()}}),this.isInsideClassicGateway){var e=this.isSeparateGateway?this.methodId:_t;xt({event:Bt.INVALIDATE,callback:function(){return t.isVisible=!1}}),xt({event:Bt.RENDER,paymentMethod:e,callback:function(){return t.isVisible=!0}})}this.context===Ct.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(!Qt(Jt,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"),Ut(Jt,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=Rt(Qt(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()}Ut(Zt,this,[]);var s=["ppcp-button-".concat(i),"ppcp-button-apm",this.cssClass];(t=n.classList).add.apply(t,s),(e=Qt(Zt,this)).push.apply(e,s),a&&(n.style.height="".concat(a,"px")),n.style.display=this.isVisible?"block":"none";var l=this.context===Ct.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;Qt(ce,this)&&this.removeButton(),this.log("insertButton",t),Ut(ce,this,t),e.appendChild(Qt(ce,this))}}},{key:"removeButton",value:function(){if(this.isPresent&&Qt(ce,this)){this.log("removeButton");try{this.wrapperElement.removeChild(Qt(ce,this))}catch(t){}Ut(ce,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&&Gt(t.prototype,e),n&&Gt(t,n),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,n}();function fe(t,e){Qt(se,this).push({check:t,errorMessage:e,shouldPass:!1})}function he(t){Qt(se,this).push({check:t,shouldPass:!0})}function ye(t){return ye="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},ye(t)}function de(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 ve(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)?ve(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 ve(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=Array(e);n3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&hr||r>y)&&(i[4]=n,i[5]=r,f.n=y,u=0))}if(o||n>1)return a;throw p=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(p&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!p;){i||(u?u<3?(u>1&&(f.n=-1),h(u,c)):f.n=c:f.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=(p=f.n<0)?c:n.call(r,f))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(me(e={},r,function(){return this}),e),p=s.prototype=u.prototype=Object.create(l);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,me(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,me(p,"constructor",s),me(s,"constructor",c),c.displayName="GeneratorFunction",me(s,o,"GeneratorFunction"),me(p),me(p,o,"Generator"),me(p,r,function(){return this}),me(p,"toString",function(){return"[object Generator]"}),(be=function(){return{w:i,m:f}})()}function me(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}me=function(t,e,n,r){function i(e,n){me(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))},me(t,e,n,r)}function ge(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 we(t){return function(){var e=this,n=arguments;return new Promise(function(r,o){var i=t.apply(e,n);function a(t){ge(i,r,o,a,u,"next",t)}function u(t){ge(i,r,o,a,u,"throw",t)}a(void 0)})}}function ke(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 Se(t){for(var e=1;e2&&void 0!==arguments[2]?arguments[2]:{};Ie(ze,this)||xe(ze,this,Date.now()),null!=r&&r.height&&null!=r&&r.borderRadius&&xe(Ue,this,Se({},r));var o=null!=r&&r.height?r:Ie(Ue,this);if(Date.now()-Ie(ze,this)>Ie(Qe,this))return this.log("ApplePay: Timeout waiting for buttonAttributes - proceeding with initialization"),xe(Le,this,t),xe(qe,this,e),this.buttonAttributes=o||r,void this.init();null!=o&&o.height&&null!=o&&o.borderRadius?(xe(ze,this,0),xe(Le,this,t),xe(qe,this,e),this.buttonAttributes=o,this.init()):setTimeout(function(){return n.configure(t,e,r)},100)}},{key:"init",value:function(){this.isInitialized||this.validateConfiguration()&&(Oe(e,"init",this,3)([]),this.checkEligibility())}},{key:"reinit",value:(a=we(be().m(function t(){var n=this;return be().w(function(t){for(;;)switch(t.n){case 0:if(this.validateConfiguration(!0)){t.n=1;break}return t.a(2);case 1:return t.n=2,this.contextHandler.transactionInfo().then(function(t){n.transactionInfo=t}).catch(function(t){console.error("Failed to get transaction info:",t)});case 2:Oe(e,"reinit",this,3)([]),this.init();case 3:return t.a(2)}},t,this)})),function(){return a.apply(this,arguments)})},{key:"checkEligibility",value:function(){if(this.isPreview)this.isEligible=!0;else try{var t;if(null===(t=window.ApplePaySession)||void 0===t||!t.canMakePayments())return void(this.isEligible=!1);this.isEligible=!!Ie(Le,this).isEligible}catch(t){this.isEligible=!1}}},{key:"applePaySession",value:function(t){this.log("applePaySession",t);var e=new ApplePaySession(4,t);return this.requiresShipping&&(e.onshippingmethodselected=this.onShippingMethodSelected(e),e.onshippingcontactselected=this.onShippingContactSelected(e)),e.onvalidatemerchant=this.onValidateMerchant(e),e.onpaymentauthorized=this.onPaymentAuthorized(e),e.begin(),e}},{key:"applyWrapperStyles",value:function(){var t,n;Oe(e,"applyWrapperStyles",this,3)([]);var r=this.wrapperElement;if(r){var o=null!==(t=this.buttonAttributes)&&void 0!==t&&t.height||null!==(n=this.buttonAttributes)&&void 0!==n&&n.borderRadius?this.buttonAttributes:Ie(Ue,this),i=null!=o&&o.height?parseInt(o.height,10):48;isNaN(i)?(r.style.setProperty("--apple-pay-button-height","".concat(48,"px")),r.style.height="".concat(48,"px")):(r.style.setProperty("--apple-pay-button-height","".concat(i,"px")),r.style.height="".concat(i,"px"));var a=null!=o&&o.borderRadius?parseInt(o.borderRadius,10):4;isNaN(a)||(r.style.borderRadius="".concat(a,"px"))}}},{key:"addButton",value:function(){var t,e,n=this,r=this.style,o=r.color,i=r.type,a=r.language;null!==(t=this.buttonAttributes)&&void 0!==t&&t.height||null===(e=Ie(Ue,this))||void 0===e||!e.height||(this.buttonAttributes=Se({},Ie(Ue,this)));var u=document.createElement("apple-pay-button");u.id="apple-"+this.wrapperId,u.setAttribute("buttonstyle",o),u.setAttribute("type",i),u.setAttribute("locale",a),u.style.display="block",u.addEventListener("click",function(t){t.preventDefault(),n.onButtonClick()}),this.insertButton(u)}},{key:"onButtonClick",value:(i=we(be().m(function t(){var e,n,r,o,i,a,u,c;return be().w(function(t){for(;;)switch(t.p=t.n){case 0:if(this.log("onButtonClick"),e=this.paymentRequest(),window.ppcpFundingSource="apple_pay",Ct.Checkout!==this.context){t.n=6;break}n="form.woocommerce-checkout",r=new gt(PayPalCommerceGateway.labels.error.generic,document.querySelector(".woocommerce-notices-wrapper"));try{o=new FormData(document.querySelector(n)),xe(De,this,Object.fromEntries(o.entries())),this.updateRequestDataWithForm(e)}catch(t){console.error(t)}if(this.log("=== paymentRequest",e),i=this.applePaySession(e),!(a=PayPalCommerceGateway.early_checkout_validation_enabled?new dt(PayPalCommerceGateway.ajax.validate_checkout.endpoint,PayPalCommerceGateway.ajax.validate_checkout.nonce):null)){t.n=5;break}return t.p=1,t.n=2,a.validate(document.querySelector(n));case 2:if(!((u=t.v).length>0)){t.n=3;break}return r.messages(u),jQuery(document.body).trigger("checkout_error",[r.currentHtml()]),i.abort(),t.a(2);case 3:t.n=5;break;case 4:t.p=4,c=t.v,console.error(c);case 5:return t.a(2);case 6:this.applePaySession(e);case 7:return t.a(2)}},t,this,[[1,4]])})),function(){return i.apply(this,arguments)})},{key:"shouldUpdateButtonWithFormData",get:function(){var t;return Ct.Checkout===this.context&&"use_applepay"===(null===(t=this.buttonConfig)||void 0===t||null===(t=t.preferences)||void 0===t?void 0:t.checkout_data_mode)}},{key:"shouldCompletePaymentWithContextHandler",get:function(){return!this.contextHandler.shippingAllowed()||Ct.Checkout===this.context&&!this.shouldUpdateButtonWithFormData}},{key:"updateRequestDataWithForm",value:function(t){if(this.shouldUpdateButtonWithFormData&&(t.billingContact=this.fillBillingContact(Ie(De,this)),this.requiresShipping)){t.shippingContact=this.fillShippingContact(Ie(De,this));var e=this.transactionInfo.chosenShippingMethods[0];t.shippingMethods=[];var n,r=de(this.transactionInfo.shippingPackages);try{for(r.s();!(n=r.n()).done;){var o=n.value;if(e===o.id){var i={label:o.label,detail:"",amount:o.cost_str,identifier:o.id};xe(Ne,this,i),t.shippingMethods.push(i);break}}}catch(t){r.e(t)}finally{r.f()}var a,u=de(this.transactionInfo.shippingPackages);try{for(u.s();!(a=u.n()).done;){var c=a.value;e!==c.id&&t.shippingMethods.push({label:c.label,detail:"",amount:c.cost_str,identifier:c.id})}}catch(t){u.e(t)}finally{u.f()}xe(Ge,this,t),this.log("=== paymentRequest.shippingMethods",t.shippingMethods)}}},{key:"paymentRequest",value:function(){var t=Ie(Le,this),e=this.buttonConfig,n={countryCode:t.countryCode,merchantCapabilities:t.merchantCapabilities,supportedNetworks:t.supportedNetworks,requiredShippingContactFields:["postalAddress","email","phone"],requiredBillingContactFields:["postalAddress"]};this.requiresShipping||(this.shouldCompletePaymentWithContextHandler?n.requiredShippingContactFields=[]:n.requiredShippingContactFields=["email","phone"]);var r=Object.assign({},n);return r.currencyCode=e.shop.currencyCode,r.total={label:e.shop.totalLabel,type:"final",amount:this.transactionInfo.totalPrice},r}},{key:"refreshProductContextData",value:function(){var t;Ct.Product===this.context&&(Ie(Fe,this).quantity=null===(t=document.querySelector("input.qty"))||void 0===t?void 0:t.value,Ie(Fe,this).items=this.contextHandler.products(),this.log("Products updated",Ie(Fe,this)))}},{key:"adminValidation",value:function(t){fetch(this.buttonConfig.ajax_url,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({action:"ppcp_validate","woocommerce-process-checkout-nonce":this.nonce,validation:t}).toString()})}},{key:"onValidateMerchant",value:function(t){var e=this;return function(n){e.log("onvalidatemerchant call"),f.paypal.Applepay().validateMerchant({validationUrl:n.validationURL}).then(function(n){t.completeMerchantValidation(n.merchantSession),e.adminValidation(!0)}).catch(function(n){console.error(n),e.adminValidation(!1),e.log("onvalidatemerchant session abort"),t.abort()})}}},{key:"onShippingMethodSelected",value:function(t){var e=this;this.log("onshippingmethodselected",this.buttonConfig.ajax_url);var n=this.buttonConfig.ajax_url;return function(r){e.log("onshippingmethodselected call");var o=e.getShippingMethodData(r);jQuery.ajax({url:n,method:"POST",data:o,success:function(n){e.log("onshippingmethodselected ok");var o=n.data;!1===n.success&&(o.errors=ct(o.errors)),xe(Ne,e,r.shippingMethod),o.newShippingMethods=o.newShippingMethods.sort(function(t){return t.label===Ie(Ne,e).label?-1:1}),!1===n.success&&(o.errors=ct(o.errors)),t.completeShippingMethodSelection(o)},error:function(n,r,o){e.log("onshippingmethodselected error",r),console.warn(r,o),t.abort()}})}}},{key:"onShippingContactSelected",value:function(t){var e=this;this.log("onshippingcontactselected",this.buttonConfig.ajax_url);var n=this.buttonConfig.ajax_url;return function(r){e.log("onshippingcontactselected call");var o=e.getShippingContactData(r);jQuery.ajax({url:n,method:"POST",data:o,success:function(n){e.log("onshippingcontactselected ok");var o=n.data;xe(Re,e,r.shippingContact),!1===n.success&&(o.errors=ct(o.errors)),o.newShippingMethods&&xe(Ne,e,o.newShippingMethods[0]),t.completeShippingContactSelection(o)},error:function(n,r,o){e.log("onshippingcontactselected error",r),console.warn(r,o),t.abort()}})}}},{key:"getShippingContactData",value:function(t){var e=this.buttonConfig.product.id;switch(this.refreshProductContextData(),this.context){case Ct.Product:return{action:"ppcp_update_shipping_contact",product_id:e,products:JSON.stringify(Ie(Fe,this).items),caller_page:"productDetail",product_quantity:Ie(Fe,this).quantity,simplified_contact:t.shippingContact,need_shipping:this.requiresShipping,"woocommerce-process-checkout-nonce":this.nonce};case Ct.Cart:case Ct.Checkout:case Ct.BlockCart:case Ct.BlockCheckout:case Ct.MiniCart:return{action:"ppcp_update_shipping_contact",simplified_contact:t.shippingContact,caller_page:"cart",need_shipping:this.requiresShipping,"woocommerce-process-checkout-nonce":this.nonce}}}},{key:"getShippingMethodData",value:function(t){var e,n,r,o,i,a,u=this.buttonConfig.product.id;switch(this.refreshProductContextData(),this.context){case Ct.Product:return{action:"ppcp_update_shipping_method",shipping_method:t.shippingMethod,simplified_contact:this.hasValidContactInfo(Ie(Re,this))?Ie(Re,this):null!==(e=null===(n=Ie(Ge,this))||void 0===n?void 0:n.shippingContact)&&void 0!==e?e:null===(r=Ie(Ge,this))||void 0===r?void 0:r.billingContact,product_id:u,products:JSON.stringify(Ie(Fe,this).items),caller_page:"productDetail",product_quantity:Ie(Fe,this).quantity,"woocommerce-process-checkout-nonce":this.nonce};case Ct.Cart:case Ct.Checkout:case Ct.BlockCart:case Ct.BlockCheckout:case Ct.MiniCart:return{action:"ppcp_update_shipping_method",shipping_method:t.shippingMethod,simplified_contact:this.hasValidContactInfo(Ie(Re,this))?Ie(Re,this):null!==(o=null===(i=Ie(Ge,this))||void 0===i?void 0:i.shippingContact)&&void 0!==o?o:null===(a=Ie(Ge,this))||void 0===a?void 0:a.billingContact,caller_page:"cart","woocommerce-process-checkout-nonce":this.nonce}}}},{key:"onPaymentAuthorized",value:function(t){var e=this;return this.log("onpaymentauthorized"),function(){var n=we(be().m(function n(r){var o,i,a,u,c,s,l,p;return be().w(function(n){for(;;)switch(n.p=n.n){case 0:return e.log("onpaymentauthorized call"),o=function(){var t=we(be().m(function t(n){return be().w(function(t){for(;;)if(0===t.n)return t.a(2,new Promise(function(t,o){try{var i,a=n.billing_contact||Ie(Ge,e).billingContact,u=n.shipping_contact||Ie(Ge,e).shippingContact,c=Ie(Ne,e)||(Ie(Ge,e).shippingMethods||[])[0],s={action:"ppcp_create_order",caller_page:e.context,product_id:null!==(i=e.buttonConfig.product.id)&&void 0!==i?i:null,products:JSON.stringify(Ie(Fe,e).items),product_quantity:Ie(Fe,e).quantity,shipping_contact:u,billing_contact:a,token:r.payment.token,shipping_method:c,"woocommerce-process-checkout-nonce":e.nonce,funding_source:"applepay",_wp_http_referer:"/?wc-ajax=update_order_review",paypal_order_id:n.paypal_order_id};e.log("onpaymentauthorized request",e.buttonConfig.ajax_url,n),jQuery.ajax({url:e.buttonConfig.ajax_url,method:"POST",data:s,complete:function(){e.log("onpaymentauthorized complete")},success:function(n){e.log("onpaymentauthorized ok"),t(n)},error:function(t,n,r){e.log("onpaymentauthorized error",n),o(new Error(r))}})}catch(t){e.error("onpaymentauthorized catch",t)}}))},t)}));return function(e){return t.apply(this,arguments)}}(),n.n=1,e.contextHandler.createOrder();case 1:return i=n.v,e.log("onpaymentauthorized paypal order ID",i,r.payment.token,r.payment.billingContact),n.p=2,n.n=3,f.paypal.Applepay().confirmOrder({orderId:i,token:r.payment.token,billingContact:r.payment.billingContact});case 3:if(a=n.v,e.log("onpaymentauthorized confirmOrderResponse",a),!a||!a.approveApplePayPayment){n.n=13;break}if("APPROVED"!==a.approveApplePayPayment.status){n.n=11;break}if(n.p=4,!e.shouldCompletePaymentWithContextHandler){n.n=6;break}return u=!1,n.n=5,e.contextHandler.approveOrder({orderID:i},{restart:function(){return new Promise(function(t){u=!0,t()})},order:{get:function(){return new Promise(function(t){t(null)})}}});case 5:u?(e.error("onpaymentauthorized approveOrder FAIL"),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort()):(e.log("onpaymentauthorized approveOrder OK"),t.completePayment(ApplePaySession.STATUS_SUCCESS)),n.n=8;break;case 6:return c={billing_contact:r.payment.billingContact,shipping_contact:r.payment.shippingContact,paypal_order_id:i},n.n=7,o(c);case 7:"success"===(s=n.v).result?(t.completePayment(ApplePaySession.STATUS_SUCCESS),window.location.href=s.redirect):t.completePayment(ApplePaySession.STATUS_FAILURE);case 8:n.n=10;break;case 9:n.p=9,l=n.v,t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort(),console.error(l);case 10:n.n=12;break;case 11:console.error("Error status is not APPROVED"),t.completePayment(ApplePaySession.STATUS_FAILURE);case 12:n.n=14;break;case 13:console.error("Invalid confirmOrderResponse"),t.completePayment(ApplePaySession.STATUS_FAILURE);case 14:n.n=16;break;case 15:n.p=15,p=n.v,console.error("Error confirming order with applepay token",p),t.completePayment(ApplePaySession.STATUS_FAILURE),t.abort();case 16:return n.a(2)}},n,null,[[4,9],[2,15]])}));return function(_x){return n.apply(this,arguments)}}()}},{key:"fillBillingContact",value:function(t){return We(Ve,this,$e).call(this,t,"billing","")}},{key:"fillShippingContact",value:function(t){return null!=t&&t.shipping_first_name?We(Ve,this,$e).call(this,t,"shipping","billing"):this.fillBillingContact(t)}},{key:"hasValidContactInfo",value:function(t){return Array.isArray(t)?t.length>0:Object.keys(t||{}).length>0}}],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-applepay-container","ppc-button-ppcp-applepay")}},{key:"getStyles",value:function(t,e){var n=(null==t?void 0:t.button)||{},r={color:n.color,lang:n.lang,type:n.type},o={style:r,mini_cart_style:r};return function(t,e){return{Default:Mt(Mt({},t.style),e.style),MiniCart:Mt(Mt({},t.mini_cart_style),e.mini_cart_style)}}((null==e?void 0:e.button)||{},o)}}],r&&Pe(n.prototype,r),o&&Pe(n,o),Object.defineProperty(n,"prototype",{writable:!1}),n;var n,r,o,i,a}(pe);function $e(t,e,n){t&&"object"===ye(t)||(t={});var r=function(r){return t["".concat(e,"_").concat(r)]||t["".concat(n,"_").concat(r)]||""};return{givenName:r("first_name"),familyName:r("last_name"),emailAddress:r("email"),phoneNumber:r("phone"),addressLines:[r("address_1"),r("address_2")],locality:r("city"),postalCode:r("postcode"),countryCode:r("country"),administrativeArea:r("state")}}Te(He,"methodId","ppcp-applepay"),Te(He,"cssClass","ppcp-button-applepay");const Je=He;function Ke(t){return Ke="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},Ke(t)}function Ye(t,e){for(var n=0;n3?(o=y===r)&&(c=i[(u=i[4])?5:(u=3,3)],i[4]=i[5]=t):i[0]<=h&&((o=n<2&&hr||r>y)&&(i[4]=n,i[5]=r,f.n=y,u=0))}if(o||n>1)return a;throw p=!0,r}return function(o,l,y){if(s>1)throw TypeError("Generator is already running");for(p&&1===l&&h(l,y),u=l,c=y;(e=u<2?t:c)||!p;){i||(u?u<3?(u>1&&(f.n=-1),h(u,c)):f.n=c:f.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=(p=f.n<0)?c:n.call(r,f))!==a)break}catch(e){i=t,u=1,c=e}finally{s=1}}return{value:e,done:p}}}(n,o,i),!0),s}var a={};function u(){}function c(){}function s(){}e=Object.getPrototypeOf;var l=[][r]?e(e([][r]())):(sn(e={},r,function(){return this}),e),p=s.prototype=u.prototype=Object.create(l);function f(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,s):(t.__proto__=s,sn(t,o,"GeneratorFunction")),t.prototype=Object.create(p),t}return c.prototype=s,sn(p,"constructor",s),sn(s,"constructor",c),c.displayName="GeneratorFunction",sn(s,o,"GeneratorFunction"),sn(p),sn(p,o,"Generator"),sn(p,r,function(){return this}),sn(p,"toString",function(){return"[object Generator]"}),(cn=function(){return{w:i,m:f}})()}function sn(t,e,n,r){var o=Object.defineProperty;try{o({},"",{})}catch(t){o=0}sn=function(t,e,n,r){function i(e,n){sn(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))},sn(t,e,n,r)}function ln(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 pn(t,e){for(var n=0;n