(()=>{"use strict";var t={n:e=>{var n=e&&e.__esModule?()=>e.default:()=>e;return t.d(n,{a:n}),n},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.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{ConfigurationError:()=>pt,SHIPPING_OPTION_REGEX:()=>R,convertCartAddressToPayPal:()=>U,convertFormToJson:()=>at,convertPayPalAddressToCart:()=>J,debounce:()=>lt,extractFullName:()=>W,extractShippingMethod:()=>$,fieldsToJson:()=>L,formatPaymentMethod:()=>ut,getErrorMessage:()=>H,getFieldValue:()=>N,getPage:()=>Y,getPayPalQueryParams:()=>F,getRestPath:()=>K,getRestRoute:()=>X,getSetting:()=>q,isAddPaymentMethod:()=>ot,isAdminUser:()=>st,isCart:()=>tt,isCheckout:()=>Z,isFieldRequired:()=>dt,isMiniCartEnabled:()=>it,isOrderPay:()=>et,isPluginConnected:()=>ct,isProduct:()=>nt,isProduction:()=>ft,isShop:()=>rt,isValid:()=>Q,isValidAddress:()=>G,isValidFieldValue:()=>z,loadPayPalSdk:()=>M,setFieldValue:()=>B,setSetting:()=>D,submitErrorMessage:()=>V});const n=window.lodash,r=window.jQuery;var o=t.n(r);const i=window.wp.hooks;function a(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}function u(t,e){if(void 0===e&&(e=c()),s(t,e),"undefined"==typeof window)return e.resolve(null);var n=function(t){var e="https://www.paypal.com/sdk/js";t.sdkBaseURL&&(e=t.sdkBaseURL,delete t.sdkBaseURL),function(t){var e=t["merchant-id"],n=t["data-merchant-id"],r="",o="";Array.isArray(e)?e.length>1?(r="*",o=e.toString()):r=e.toString():"string"==typeof e&&e.length>0?r=e:"string"==typeof n&&n.length>0&&(r="*",o=n),t["merchant-id"]=r,t["data-merchant-id"]=o}(t);var n,r,o=Object.keys(t).filter((function(e){return void 0!==t[e]&&null!==t[e]&&""!==t[e]})).reduce((function(e,n){var r=t[n].toString();return"data-"===n.substring(0,5)?e.dataAttributes[n]=r:e.queryParams[n]=r,e}),{queryParams:{},dataAttributes:{}}),i=o.queryParams,a=o.dataAttributes;return{url:"".concat(e,"?").concat((n=i,r="",Object.keys(n).forEach((function(t){0!==r.length&&(r+="&"),r+=t+"="+n[t]})),r)),dataAttributes:a}}(t),r=n.url,o=n.dataAttributes,i=o["data-namespace"]||"paypal",u=l(i);return function(t,e){var n=document.querySelector('script[src="'.concat(t,'"]'));if(null===n)return null;var r=a(t,e),o=n.cloneNode();if(delete o.dataset.uidAuto,Object.keys(o.dataset).length!==Object.keys(r.dataset).length)return null;var i=!0;return Object.keys(o.dataset).forEach((function(t){o.dataset[t]!==r.dataset[t]&&(i=!1)})),i?n:null}(r,o)&&u?e.resolve(u):function(t,e){void 0===e&&(e=c()),s(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 window)return t();!function(t){var e=t.onSuccess,n=t.onError,r=a(t.url,t.attributes);r.onerror=n,r.onload=e,document.head.insertBefore(r,document.head.firstElementChild)}({url:n,attributes:r,onSuccess:function(){return t()},onError:function(){var t=new Error('The script "'.concat(n,'" failed to load.'));return window.fetch?fetch(n).then((function(n){return 200===n.status&&e(t),n.text()})).then((function(t){var n=function(t){var e=t.split("/* Original Error:")[1];return e?e.replace(/\n/g,"").replace("*/","").trim():t}(t);e(new Error(n))})).catch((function(t){e(t)})):e(t)}})}))}({url:r,attributes:o},e).then((function(){var t=l(i);if(t)return t;throw new Error("The window.".concat(i," global variable is not available."))}))}function c(){if("undefined"==typeof Promise)throw new Error("Promise is undefined. To resolve the issue, use a Promise polyfill.");return Promise}function l(t){return window[t]}function s(t,e){if("object"!=typeof t||null===t)throw new Error("Expected an options object.");if(void 0!==e&&"function"!=typeof e)throw new Error("Expected PromisePonyfill to be a function.")}function f(t){return f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},f(t)}var d=["locale"];function p(t,e){if(e&&("object"===f(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)}function y(t){var e="function"==typeof Map?new Map:void 0;return y=function(t){if(null===t||(n=t,-1===Function.toString.call(n).indexOf("[native code]")))return t;var n;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,r)}function r(){return v(t,arguments,m(this).constructor)}return r.prototype=Object.create(t.prototype,{constructor:{value:r,enumerable:!1,writable:!0,configurable:!0}}),h(r,t)},y(t)}function v(t,e,n){return v=b()?Reflect.construct.bind():function(t,e,n){var r=[null];r.push.apply(r,e);var o=new(Function.bind.apply(t,r));return n&&h(o,n.prototype),o},v.apply(null,arguments)}function b(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function h(t,e){return h=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},h(t,e)}function m(t){return m=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},m(t)}function g(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=P(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}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 i,a=!0,u=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==n.return||n.return()}finally{if(u)throw i}}}}function w(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=!0,u=!1;try{for(n=n.call(t);!(a=(r=n.next()).done)&&(i.push(r.value),!e||i.length!==e);a=!0);}catch(t){u=!0,o=t}finally{try{a||null==n.return||n.return()}finally{if(u)throw o}}return i}}(t,e)||P(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 P(t,e){if(t){if("string"==typeof t)return O(t,e);var n=Object.prototype.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)?O(t,e):void 0}}function O(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function j(t,e){if(null==t)return{};var n,r,o=function(t,e){if(null==t)return{};var n,r,o={},i=Object.keys(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||(o[n]=t[n]);return o}(t,e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(r=0;r<i.length;r++)n=i[r],e.indexOf(n)>=0||Object.prototype.propertyIsEnumerable.call(t,n)&&(o[n]=t[n])}return o}function E(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 _(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?E(Object(n),!0).forEach((function(e){S(t,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):E(Object(n)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))}))}return t}function S(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var A={},k=!1,C=new Map,T=null,R=/^([\w]+)\:(.+)$/,x={address_1:"address_line_1|line1",address_2:"address_line_2|line2",state:"admin_area_1|state",city:"admin_area_2|city",postcode:"postal_code",country:"country_code"},I={city:"city",state:"state",postal_code:"postcode",country_code:"country"},M=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:null;return new Promise((function(r,o){!e||(0,n.isEmpty)(e)||(0,n.isEqual)(e,A)?window.paypal&&!k?r(window.paypal):(i.defaultHooks.addAction("paypalInstanceCreated","wcPPCP",(function(t){r(t)})),i.defaultHooks.addAction("paypalLoadError","wcPPCP",(function(){o()}))):(A=e,window.paypal&&i.defaultHooks.doAction("paypalInstanceCleanup",window.paypal),k=!0,u(_({},e)).then((function(t){r(t),i.defaultHooks.doAction("paypalInstanceCreated",t,A)})).catch((function(n){var a;console.log(n);var u,c=(null==n||null===(a=n.message)||void 0===a?void 0:a.toLowerCase())||null;if(c){if(c.includes("locale")){e.locale;var l=j(e,d);return t(l).then((function(t){r(t)}))}c.includes("client-id not recognized")||c.includes("invalid query value for client-id")?u={code:"invalid_client_id"}:c.includes("invalid query value for currency")}i.defaultHooks.doAction("paypalLoadError"),o(u)})).finally((function(){k=!1})))}))},q=function(t){return void 0!==window.wcPPCPSettings&&window.wcPPCPSettings[t]||{}},D=function(t,e){if(void 0!==window.wcPPCPSettings)return window.wcPPCPSettings[t]=e},F=function(){return q("queryParams")},N=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"billing",n=arguments.length>2&&void 0!==arguments[2]&&arguments[2];return"shipping"!=t.substring(0,"shipping".length)&&"billing"!=t.substring(0,"billing".length)&&e&&(t="".concat(e,"_").concat(t)),n?C.get(t):o()('[name="'.concat(t,'"]')).length?o()('[name="'.concat(t,'"]')).val():C.get(t)},L=function(){var t={};return C.forEach((function(e,n){t[n]=e})),t},B=function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"billing";n&&"shipping"!=t.substring(0,"shipping".length)&&"billing"!=t.substring(0,"billing".length)&&(t="".concat(n,"_").concat(t)),C.set(t,e),o()('[name="'.concat(t,'"]')).length&&o()('[name="'.concat(t,'"]')).val(e)},H=function(t){var e=q("errorMessages");return"string"==typeof t?t:null!=t&&t.code&&null!=e&&e[t.code]?e[t.code]:null!=t&&t.message?t.message:void 0},V=function(t,e){var n,r,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"checkout";if(null==t||null===(n=t.message)||void 0===n||null===(r=n.toLowerCase())||void 0===r||!r.match(/detected popup close|window is closed/)){var a=H(t),u="woocommerce-NoticeGroup",c=o()(e);"checkout"===i&&(u+=" woocommerce-NoticeGroup-checkout"),a=Array.isArray(t)?'<div class="'+u+'"><ul class="woocommerce-error"><li>'+t.join("</li><li>")+"</li></ul></div>":"string"==typeof t&&/<[^>]*>/.test(t)?'<div class="'+u+'">'+t+"</div>":'<div class="'+u+'"><ul class="woocommerce-error"><li>'+a+"</li></ul></div>",o()(".woocommerce-NoticeGroup-checkout, .woocommerce-error, .woocommerce-message").remove(),c.prepend(a),o().scroll_to_notices?o().scroll_to_notices(c):o()("html, body").animate({scrollTop:c.offset().top-100},1e3)}},G=function(t){var e,r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],i="undefined"==typeof wc_address_i18n_params?q("i18n"):wc_address_i18n_params;if((0,n.isEmpty)(t))return!1;if(T||(T=JSON.parse(i.locale.replace(/&quot;/g,'"'))),!t.country||(0,n.isEmpty)(t))return!1;var a=null!==(e=T)&&void 0!==e&&e[t.country]?T[t.country]:T.default;a=o().extend(!0,{},T.default,a);var u=Object.entries(a).filter((function(t){var e=w(t,2),n=e[0];return e[1],!r.includes(n)}));for(var c in a=Object.fromEntries(u)){var l;if(null!==(l=a[c])&&void 0!==l&&l.required){var s=(null==t?void 0:t[c])||null;if(!s||null==s||!s.trim())return!1}}return!0},U=function(t){var e={};for(var n in t)if(null!=x&&x[n])if(x[n].includes("|")){var r=w(x[n].split("|"),2),o=r[0];r[1],e[o]=t[n]}else e[x[n]]=t[n];return e},J=function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n={};n=e?I:Object.fromEntries(Object.entries(x).map((function(t){var e=w(t,2),n=e[0];return[e[1],n]})));var r={};for(var o in n)if(o.includes("|")){var i,a=o.split("|"),u=g(a);try{for(u.s();!(i=u.n()).done;){var c=i.value;if(t.hasOwnProperty(c)){r[n[o]]=t[c];break}r[n[o]]=""}}catch(t){u.e(t)}finally{u.f()}}else t.hasOwnProperty(o)?r[n[o]]=t[o]:r[n[o]]="";return r},z=function(t){var e;return!!(t=null===(e=t)||void 0===e?void 0:e.trim())},Q=function(t){return z(N(t))},$=function(t){var e=t.match(R);return e?S({},e[1],e[2]):null},W=function(t){return[(t=t.trim()).split(" ").slice(0,-1).join(" "),t.split(" ").pop()]},X=function(t){var e,n,r;return(null===(e=q("generalData"))||void 0===e||null===(n=e.restRoutes)||void 0===n||null===(r=n[t])||void 0===r?void 0:r.url)||null},K=function(t){var e,n;return t=t.replace(/^\//,""),null===(e=q("generalData"))||void 0===e||null===(n=e.ajaxRestPath)||void 0===n?void 0:n.replace("%s",t)},Y=function(){return q("generalData").page},Z=function(){return"checkout"===Y()},tt=function(){return"cart"===Y()},et=function(){return"order_pay"===Y()},nt=function(){return"product"===Y()},rt=function(){return"shop"===Y()},ot=function(){return"add_payment_method"===Y()},it=function(){return!1},at=function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return t.serializeArray().reduce((function(t,n){if(e.includes(n.name))return t;var r=[];n.name.replace(/([^\[\]]*)/g,(function(t,e){""!==e&&r.push(e)}));var o=n.name.endsWith("[]");return r.reduce((function(t,e,i){var a,u;return i===r.length-1?o?(t[e]=null!==(a=t[e])&&void 0!==a?a:[],t[e].push(n.value)):t[e]=n.value:t[e]=null!==(u=t[e])&&void 0!==u?u:{},t[e]}),t),t}),{})},ut=function(t,e){var n={};Object.keys(e).forEach((function(t){n["{".concat(t,"}")]=e[t]}));var r=t;return Object.keys(n).forEach((function(t){for(;r.includes(t);)r=r.replace(t,n[t])})),r},ct=function(){var t,e;return(null===(t=q("generalData"))||void 0===t||null===(e=t.clientId)||void 0===e?void 0:e.length)>0},lt=function(t){var e,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:250;return function(){for(var r=arguments.length,o=new Array(r),i=0;i<r;i++)o[i]=arguments[i];clearTimeout(e),e=setTimeout((function(){t.apply(void 0,o)}),n)}},st=function(){var t;return!0===(null===(t=q("generalData"))||void 0===t?void 0:t.is_admin)},ft=function(){var t;return"production"===(null===(t=q("generalData"))||void 0===t?void 0:t.environment)},dt=function(t){return(q("requiredFields")||[]).includes(t)},pt=function(t){!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&&h(t,e)}(i,t);var e,n,r,o=(e=i,n=b(),function(){var t,r=m(e);if(n){var o=m(this).constructor;t=Reflect.construct(r,arguments,o)}else t=r.apply(this,arguments);return p(this,t)});function i(t){var e;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,i),(e=o.call(this,t)).name="ConfigurationError",e}return r=i,Object.defineProperty(r,"prototype",{writable:!1}),r}(y(Error));(this.wcPPCP=this.wcPPCP||{}).utils=e})();