/*! For license information please see cart.js.LICENSE.txt */ (()=>{"use strict";var t={n:e=>{var r=e&&e.__esModule?()=>e.default:()=>e;return t.d(r,{a:r}),r},d:(e,r)=>{for(var n in r)t.o(r,n)&&!t.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:r[n]})},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,{default:()=>g});const r=window.jQuery;var n=t.n(r);const o=window.wcPPCP.utils,a=window.wp.apiFetch;var i=t.n(a);const c=window.wcPPCP.actions;var u=t.n(c);function s(t){return s="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},s(t)}function l(){l=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function u(t,e,r,n){var o=e&&e.prototype instanceof f?e:f,a=Object.create(o.prototype),i=new x(n||[]);return a._invoke=function(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=k(i,r);if(c){if(c===p)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=h(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(t,r,i),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=u;var p={};function f(){}function d(){}function y(){}var v={};c(v,o,(function(){return this}));var g=Object.getPrototypeOf,m=g&&g(g(S([])));m&&m!==e&&r.call(m,o)&&(v=m);var w=y.prototype=f.prototype=Object.create(v);function b(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function P(t,e){function n(o,a,i,c){var u=h(t[o],t,a);if("throw"!==u.type){var l=u.arg,p=l.value;return p&&"object"==s(p)&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,i,c)}),(function(t){n("throw",t,i,c)})):e.resolve(p).then((function(t){l.value=t,i(l)}),(function(t){return n("throw",t,i,c)}))}c(u.arg)}var o;this._invoke=function(t,r){function a(){return new e((function(e,o){n(t,r,e,o)}))}return o=o?o.then(a,a):a()}}function k(t,e){var r=t.iterator[e.method];if(void 0===r){if(e.delegate=null,"throw"===e.method){if(t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method))return p;e.method="throw",e.arg=new TypeError("The iterator does not provide a 'throw' method")}return p}var n=h(r,t.iterator,e.arg);if("throw"===n.type)return e.method="throw",e.arg=n.arg,e.delegate=null,p;var o=n.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function O(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function _(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(O,this),this.reset(!0)}function S(t){if(t){var e=t[o];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function e(){for(;++n=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),_(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function h(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function p(t){for(var e=1;e1?r-1:0),o=1;o1?r-1:0),o=1;o0&&void 0!==r[0]&&r[0],this.processing){t.next=18;break}return t.prev=2,this.processing=!0,t.next=6,i()({method:"POST",url:(0,o.getRestRoute)("cart/refresh"),data:{page:this.page}});case 6:return e=t.sent,this.data=p(p({},this.data),e.cart),this.data.queryParams=e.queryParams,t.abrupt("return",e);case 12:t.prev=12,t.t0=t.catch(2),console.log(t.t0);case 15:return t.prev=15,this.processing=!1,t.finish(15);case 18:case"end":return t.stop()}}),t,this,[[2,12,15,18]])}))),function(){return d.apply(this,arguments)})},{key:"addToCart",value:(f=y(l().mark((function t(e){var r=this;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i()({method:"POST",url:(0,o.getRestRoute)("cart/item"),data:this.actions.applyFilters("add_to_cart_data",e,this)}).then((function(t){return t.cart&&(r.data=p(p({},r.data),t.cart)),t})).catch((function(t){throw t})));case 1:case"end":return t.stop()}}),t,this)}))),function(t){return f.apply(this,arguments)})},{key:"removeCartItem",value:function(t){var e=this;return i()({method:"DELETE",url:(0,o.getRestRoute)("cart/item"),data:{key:t}}).then((function(t){e.data=p(p({},e.data),t.cart)})).catch((function(t){console.log("Error removing item from cart. ",t)}))}},{key:"updateShipping",value:(h=y(l().mark((function t(e){var r=this;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i()({method:"POST",url:(0,o.getRestRoute)("cart/shipping"),data:e}).then((function(t){return t.code||(r.data=p(p({},r.data),t)),r.sanitizeResponse(t)})).catch((function(t){throw t})));case 1:case"end":return t.stop()}}),t)}))),function(t){return h.apply(this,arguments)})},{key:"updateBilling",value:(s=y(l().mark((function t(e){var r=this;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i()({method:"POST",url:(0,o.getRestRoute)("cart/billing"),data:e}).then((function(t){return t.code||(r.data=p(p({},r.data),t.cart)),t})).catch((function(t){throw t})));case 1:case"end":return t.stop()}}),t)}))),function(t){return s.apply(this,arguments)})},{key:"createOrder",value:(c=y(l().mark((function t(e){var r=this;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",i()({method:"POST",url:(0,o.getRestRoute)("cart/order"),data:e}).then((function(t){return r.sanitizeResponse(t)})));case 1:case"end":return t.stop()}}),t)}))),function(t){return c.apply(this,arguments)})},{key:"doOrderPay",value:(a=y(l().mark((function t(e){var r,n,a=this,c=arguments;return l().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=c.length>1&&void 0!==c[1]?c[1]:{},n=(0,o.getSetting)("order"),t.abrupt("return",i()({method:"POST",url:(0,o.getRestRoute)("order/pay"),data:p(p({payment_method:e},r),n)}).then((function(t){return a.sanitizeResponse(t)})));case 3:case"end":return t.stop()}}),t)}))),function(t){return a.apply(this,arguments)})},{key:"getTotal",value:function(){var t,e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"string",r=(null===(t=this.data)||void 0===t?void 0:t.total)||0;return"string"===e&&(r=r.toString()),this.actions.applyFilters("cart_total",r,this)}},{key:"getTotalCents",value:function(){var t;return this.actions.applyFilters("cart_total_cents",parseInt((null===(t=this.data)||void 0===t?void 0:t.totalCents)||0),this)}},{key:"getLineItems",value:function(){return this.data.lineItems||[]}},{key:"getShippingOptions",value:function(){return this.data.shippingOptions||[]}},{key:"getSelectedShippingMethod",value:function(){return this.data.selectedShippingMethod||""}},{key:"sanitizeResponse",value:function(t){return"string"==typeof t?t=t.replace(/<[^>]*>/g,""):Array.isArray(t)&&(t=this.sanitizeResponse(t[0])),t}}],r&&v(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}());(this.wcPPCP=this.wcPPCP||{}).cart=e})(); (()=>{"use strict";var e={d:(t,o)=>{for(var r in o)e.o(o,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:o[r]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t),e.d(t,{getPaymentMethod:()=>i,getPaymentMethods:()=>n,registerPaymentMethod:()=>r});var o={},r=function(e){o[e.id]=e},n=function(){return o},i=function(e){return o[e]?o[e]:null};(this.wcPPCP=this.wcPPCP||{}).paymentMethods=t})(); (()=>{"use strict";var e={n:t=>{var n=t&&t.__esModule?()=>t.default:()=>t;return e.d(n,{a:n}),n},d:(t,n)=>{for(var i in n)e.o(n,i)&&!e.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:n[i]})},o:(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r:e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})}},t={};e.r(t);const n=window.jQuery;var i=e.n(n);const r=window.wp.apiFetch;var o=e.n(r);const a=window.wp.hooks,l=window.wcPPCP.utils,s=window.lodash;var u=["color","label"];function c(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=n){var i,r,o=[],a=!0,l=!1;try{for(n=n.call(e);!(a=(i=n.next()).done)&&(o.push(i.value),!t||o.length!==t);a=!0);}catch(e){l=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(l)throw r}}return o}}(e,t)||g(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function d(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,i)}return n}function p(e){for(var t=1;te.length)&&(t=e.length);for(var n=0,i=new Array(t);n0}},{key:"handleOrderPay",value:function(){if(this.isOrderReview())try{var e,t,n,r,o=(null===(e=window)||void 0===e||null===(t=e.location)||void 0===t||null===(n=t.search)||void 0===n?void 0:n.match(/_ppcp_order_review=(.*)/))[1],a=JSON.parse(atob(decodeURIComponent(o))),u=(a.payment_method,a.paypal_order),c=a.fields;if((0,l.setFieldValue)(this.order_field_key,u,""),!(0,s.isEmpty)(c))for(var d in c)(0,l.setFieldValue)(d,c[d],"");if(this.setVariable("readyToCheckout",!0),this.hidePaymentButton(),this.needsShipping()&&null!==(r=i()('[name="ship_to_different_address"]'))&&void 0!==r&&r.length){var p=!(0,s.isEqual)(this.getCartAddress("billing"),this.getCartAddress("shipping"));i()('[name="ship_to_different_address"]').prop("checked",p).trigger("change")}}catch(e){console.log(e)}}},{key:"createOrder",value:function(e,t){if(this.isPage("checkout")){var n=b(b({},this.convertFormToData()),{},{context:this.getPaymentType()});return this.cart.createOrder(n)}return this.cart.doOrderPay(this.id)}},{key:"createBillingAgreement",value:function(e,t){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return this.isPage("checkout")&&(n=b(b({},this.convertFormToData()),{},{context:this.getPaymentType()})),P(C(u.prototype),"createBillingAgreement",this).call(this,e,t,n)}},{key:"createButton",value:function(){P(C(u.prototype),"createButton",this).call(this),this.paymentMethodSelected()}},{key:"displayPaymentButton",value:function(){var e;null===(e=this.getButton())||void 0===e||e.show(),this.hidePlaceOrderButton()}},{key:"hidePaymentButton",value:function(){var e;null===(e=this.getButton())||void 0===e||e.hide(),this.displayPlaceOrderButton()}},{key:"displayPlaceOrderButton",value:function(){var e;null===(e=this.getPlaceOrderButton())||void 0===e||e.removeClass("wc-ppcp-hide-button")}},{key:"hidePlaceOrderButton",value:function(){var e;null===(e=this.getPlaceOrderButton())||void 0===e||e.addClass("wc-ppcp-hide-button")}},{key:"getPlaceOrderButton",value:function(){var e=i()("#place_order");return e.length||(e=i()('[name="woocommerce_checkout_place_order"]')),e.length||(e=i()('form.checkout button[type="submit"]')),e.length||(e=i()('form[id="order_review"] button[type="submit"]')),e}},{key:"getButtonPlacement",value:function(){var e;return(null===(e=this.settings)||void 0===e?void 0:e.buttonPlacement)||"place_order"}},{key:"isPlaceOrderPlacement",value:function(){return"place_order"==this.getButtonPlacement()}},{key:"getButtonContainer",value:function(){switch(this.getButtonPlacement()){case"place_order":i()(".wc-ppcp-checkout-container").length||this.getPlaceOrderButton().after('
');break;case"payment_method":i()("div.payment_method_".concat(this.id)),i()(".wc-ppcp-payment-method__container").append('
')}return document.querySelector(".wc-ppcp-checkout-container")}},{key:"isPaymentGatewaySelected",value:function(){var e;return(null===(e=i()('[name="payment_method"]:checked'))||void 0===e?void 0:e.val())===this.id}},{key:"submitError",value:function(e){return"validation_errors"===(null==e?void 0:e.code)?(0,l.submitErrorMessage)(e.data.messages,this.getForm(),"checkout"):(0,l.submitErrorMessage)(e,this.getForm(),"checkout")}},{key:"getShippingPrefix",value:function(){var e;return null!==(e=i()('[name="ship_to_different_address"]'))&&void 0!==e&&e.length&&i()('[name="ship_to_different_address"]').is(":checked")?"shipping":"billing"}},{key:"handleOnApproveResponse",value:function(e,t){this.populateCheckoutFields(t),this.processCheckout(e,t)}},{key:"processCheckout",value:function(e,t){var n=this;this.hidePaymentButton(),this.setVariable("readyToCheckout",!0),this.update_required?(i()(document.body).one("updated_checkout",(function(){e.billingToken&&n.needsShipping()?n.displayPaymentReadyMessage():n.submitCheckoutForm(t)})),i()('[name="billing_country"],[name="billing_state"]').trigger("change"),this.shipToDifferentAddressChecked()&&i()('[name="shipping_country"],[name="shipping_state"]').trigger("change"),i()(document.body).trigger("update_checkout",{update_shipping_method:!1})):this.submitCheckoutForm(t)}},{key:"handleBillingToken",value:function(e,t){this.update_required=this.isCheckoutReviewRequired(e),P(C(u.prototype),"handleBillingToken",this).call(this,e),this.maybeShipToDifferentAddress(),this.processCheckout(t)}},{key:"isCheckoutReviewRequired",value:function(e){return!(!this.needsShipping()||this.isPayPalAddressDisabled()||(0,s.isEmpty)(e.shipping_address)||(0,s.isEqual)({city:e.shipping_address.city,state:e.shipping_address.state,postal_code:e.shipping_address.postal_code,country_code:e.shipping_address.country_code},{city:(0,l.getFieldValue)("shipping_city"),state:(0,l.getFieldValue)("shipping_state"),postal_code:(0,l.getFieldValue)("shipping_postcode"),country_code:(0,l.getFieldValue)("shipping_country")}))}},{key:"populateCheckoutFields",value:function(e){var t,n,r,o,a,u,c=this;if(!this.isAddressPopulationDisabled()&&!(0,s.isEmpty)(null==e||null===(t=e.payer)||void 0===t?void 0:t.address)){var d=(0,l.convertPayPalAddressToCart)(e.payer.address);(0,l.isValidAddress)(d,["first_name","last_name"])&&!(0,s.isEqual)(this.getCartAddress("billing"),d)&&this.populateBillingAddressFields(d)}if(null!=e&&null!==(n=e.payer)&&void 0!==n&&n.name&&((0,l.isValid)("billing_first_name")||this.populateNameFields(e.payer.name,"billing")),null!=e&&null!==(r=e.payer)&&void 0!==r&&r.email_address&&!(0,l.isValid)("billing_email")&&(0,l.setFieldValue)("billing_email",e.payer.email_address),null!=e&&null!==(o=e.payer)&&void 0!==o&&null!==(a=o.phone)&&void 0!==a&&null!==(u=a.phone_number)&&void 0!==u&&u.national_number&&((0,l.setFieldValue)("billing_phone",e.payer.phone.phone_number.national_number),this.needsShipping()&&(0,l.setFieldValue)("shipping_phone",e.payer.phone.phone_number.national_number)),!this.isAddressPopulationDisabled()&&this.needsShipping()){var p,h,g;if(!(0,s.isEmpty)(null==e||null===(p=e.purchase_units)||void 0===p||null===(h=p[0])||void 0===h||null===(g=h.shipping)||void 0===g?void 0:g.address)){var y,f,v=(0,l.convertPayPalAddressToCart)(e.purchase_units[0].shipping.address),m="";(0,s.isEqual)(this.cartAddress,v)||(this.update_required=!0,this.cartAddress=v,this.populateShippingAddressFields(v),i()(document.body).one("updated_checkout",(function(){return c.populateShippingAddressFields(v)}))),null!==(y=e.purchase_units[0].shipping)&&void 0!==y&&null!==(f=y.name)&&void 0!==f&&f.full_name&&(m=(0,l.extractFullName)(e.purchase_units[0].shipping.name.full_name),this.populateNameFields(m,"shipping")),(0,l.isValidAddress)(this.getCartFullAddress("billing"),["phone","email"])||(!m||(0,l.isValid)("billing_first_name")||(0,l.isValid)("billing_last_name")||this.populateNameFields(m,"billing"),this.populateBillingAddressFields(v))}this.maybeShipToDifferentAddress()}}},{key:"maybeShipToDifferentAddress",value:function(){var e;if(null!==(e=i()('[name="ship_to_different_address"]'))&&void 0!==e&&e.length){var t=!(0,s.isEqual)(b(b({},this.getCartAddress("billing")),{},{name:this.getFullName("billing")}),b(b({},this.getCartAddress("shipping")),{},{name:this.getFullName("shipping")}));i()('[name="ship_to_different_address"]').prop("checked",t).trigger("change")}}},{key:"getForm",value:function(){return this.isPage("checkout")?i()(this.container).closest("form.checkout"):i()(this.container).closest("form")}},{key:"validateTerms",value:function(){return!i()('[name="terms"]').filter(":visible").length||i()('[name="terms"]').is(":checked")}},{key:"validateCheckoutFields",value:function(){return!!this.validateTerms()||(this.submitError({code:"terms"}),!1)}},{key:"isTermsVisible",value:function(){return i()('[name="terms"]').filter(":visible").length>0}},{key:"handleTermsClick",value:function(){this.isPlaceOrderPlacement()&&i()('[name="terms"]').length&&(i()('[name="terms"]').is(":checked")?this.enableButtons():this.disableButtons())}},{key:"handleCheckboxChange",value:function(){this.isTermsVisible()&&setTimeout(this.handleTermsClick.bind(this),250)}},{key:"onInit",value:function(e,t,n){P(C(u.prototype),"onInit",this).call(this,e,t,n),this.isTermsVisible()&&this.handleTermsClick()}},{key:"onClick",value:function(e,t){this.isPlaceOrderPlacement()&&!this.validateTerms()&&this.submitError({code:"terms"})}},{key:"onShippingChange",value:function(e,t){var n,r;if(null!=e&&null!==(n=e.selected_shipping_option)&&void 0!==n&&n.id){e.shipping_method=e.selected_shipping_option.id,r=(0,l.extractShippingMethod)(e.selected_shipping_option.id);for(var o=0,a=Object.keys(r);o1&&void 0!==arguments[1]?arguments[1]:null,n=(0,l.getSetting)("".concat(this.id,"_data"));return n.hasOwnProperty(e)?n[e]:(t&&this.setVariable(e,t),t)}},{key:"getOption",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:null,n=this.getData();return n.hasOwnProperty(e)?n[e]:(t&&this.setOption(e,t),t)}},{key:"createButton",value:function(){var e=this,t=this.getButtonContainer();t&&!i()(t).find(".paypal-buttons").length&&(this.getSortedFunding(this.getFunding()).forEach((function(n){var i=e.paypal.Buttons(e.getButtonOptions(n));if(e.buttons[n]=i,i.isEligible())if(t instanceof NodeList){var r,o=function(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=g(e))){n&&(e=n);var i=0,r=function(){};return{s:r,n:function(){return i>=e.length?{done:!0}:{done:!1,value:e[i++]}},e:function(e){throw e},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,a=!0,l=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return a=e.done,e},e:function(e){l=!0,o=e},f:function(){try{a||null==n.return||n.return()}finally{if(l)throw o}}}}(t);try{for(o.s();!(r=o.n()).done;){var a=r.value;i.render(a)}}catch(e){o.e(e)}finally{o.f()}}else i.render(t)})),this.$button=i()(t),a.defaultHooks.doAction("wcPPCPButtonCreated",this))}},{key:"getButton",value:function(){return this.$button}},{key:"destroyButtons",value:function(){var e=this;Object.keys(this.buttons).forEach((function(t){e.buttons[t].close&&e.buttons[t].close()}))}},{key:"disableButtons",value:function(){var e=this;Object.keys(this.buttonActions).forEach((function(t){e.buttonActions[t].disable()}))}},{key:"enableButtons",value:function(){var e=this;Object.keys(this.buttonActions).forEach((function(t){e.buttonActions[t].enable()}))}},{key:"getFunding",value:function(){var e,t,n,i,r,o,a,l=[],s=(null===(e=this.settings)||void 0===e?void 0:e.funding)||[];return null!==(t=this.settings)&&void 0!==t&&null!==(n=t.paypal_sections)&&void 0!==n&&n.includes(this.getPage())&&l.push(paypal.FUNDING.PAYPAL),s.includes("paylater")&&null!==(i=this.settings)&&void 0!==i&&null!==(r=i.paylater_sections)&&void 0!==r&&r.includes(this.getPage())&&this.isCheckoutFlow()&&l.push(paypal.FUNDING.PAYLATER),s.includes("card")&&null!==(o=this.settings)&&void 0!==o&&null!==(a=o.credit_card_sections)&&void 0!==a&&a.includes(this.getPage())&&l.push(paypal.FUNDING.CARD),l}},{key:"isFundingActive",value:function(e){var t,n;return null===(t=this.settings)||void 0===t||null===(n=t.funding)||void 0===n?void 0:n.includes(e)}},{key:"isSectionEnabled",value:function(e,t){var n,i,r="".concat(e,"_sections");return null===(n=this.settings)||void 0===n||null===(i=n[r])||void 0===i?void 0:i.includes(t)}},{key:"getSortedFunding",value:function(e){var t=this.settings.buttons_order||[];return e.sort((function(e,n){return t.indexOf(e)=0||(r[n]=e[n]);return r}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(i=0;i=0||Object.prototype.propertyIsEnumerable.call(e,n)&&(r[n]=e[n])}return r}(h,u)}return null!==(c=d)&&void 0!==c&&c.height&&(d.height=parseInt(d.height)),d}},{key:"onApprove",value:function(e,t){var n=this;if((0,l.setFieldValue)(this.order_field_key,e.orderID,""),e.billingToken)return(0,l.setFieldValue)(this.billing_token_key,e.billingToken,""),this.fetchBillingToken(e.billingToken).then((function(t){n.handleBillingToken(t,e)})).catch((function(e){return n.submitError(null==e?void 0:e.message)}));t.order.get().then((function(t){n.handleOnApproveResponse(e,t)})).catch((function(e){return n.submitError(e)}))}},{key:"handleOnApproveResponse",value:function(e,t){this.populateCheckoutFields(t),this.processCartCheckout()}},{key:"fetchBillingToken",value:function(e){return o()({method:"GET",path:"/wc-ppcp/v1/billing-agreement/token/".concat(e)})}},{key:"handleBillingToken",value:function(e,t){var n,i,r,o;if((0,s.isEmpty)(e.payer_info.billing_address)||this.populateBillingAddressFields((0,l.convertPayPalAddressToCart)(e.payer_info.billing_address)),null!=e&&null!==(n=e.payer_info)&&void 0!==n&&n.first_name&&((0,l.isValid)("billing_first_name")||(0,l.setFieldValue)("first_name",e.payer_info.first_name,"billing")),null!=e&&null!==(i=e.payer_info)&&void 0!==i&&i.last_name&&((0,l.isValid)("billing_last_name")||(0,l.setFieldValue)("last_name",e.payer_info.last_name,"billing")),null!=e&&null!==(r=e.payer_info)&&void 0!==r&&r.email&&((0,l.isValid)("billing_email")||(0,l.setFieldValue)("billing_email",e.payer_info.email)),null!=e&&null!==(o=e.payer_info)&&void 0!==o&&o.phone&&((0,l.isValid)("billing_phone")||(0,l.setFieldValue)("billing_phone",e.payer_info.phone)),this.needsShipping()&&e.shipping_address&&!(0,s.isEmpty)(e.shipping_address)){var a,u,c=(0,l.convertPayPalAddressToCart)(e.shipping_address);this.populateNameFields((0,l.extractFullName)(null!==(a=e.shipping_address.recipient_name)&&void 0!==a?a:""),"shipping"),this.populateShippingAddressFields(c),(0,l.isValidAddress)(this.getCartFullAddress("billing"),["phone","email"])||((0,l.isValidFieldValue)((0,l.getFieldValue)("billing_first_name"))||(0,l.isValidFieldValue)((0,l.getFieldValue)("billing_last_name"))||this.populateNameFields(null!==(u=e.shipping_address.recipient_name)&&void 0!==u?u:"","billing"),this.populateBillingAddressFields(c))}}},{key:"createOrder",value:function(e,t){return t.order.create(args)}},{key:"createBillingAgreement",value:function(e,t){var n=this,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:null;return o()({method:"POST",url:(0,l.getRestPath)("/wc-ppcp/v1/billing-agreement/token"),data:p({payment_method:this.id,context:this.getPage()},i)}).then((function(e){return e})).catch((function(e){n.currentError=e}))}},{key:"onShippingChange",value:function(e,t){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=(0,l.convertPayPalAddressToCart)((null==e?void 0:e.shipping_address)||{},!0),a=(null==e||null===(n=e.selected_shipping_option)||void 0===n?void 0:n.id)||"";return o()({method:"POST",url:(0,l.getRestRoute)("cart/shipping"),data:p({order_id:e.orderID,address:r,shipping_method:a,payment_method:this.id},i)}).then((function(e){return e.code?t.reject():t.resolve()})).catch((function(e){return t.reject()}))}},{key:"submitError",value:function(e){}},{key:"getShippingPrefix",value:function(){return"shipping"}},{key:"getCartAddress",value:function(e){return{address_1:(0,l.getFieldValue)("address_1",e),address_2:(0,l.getFieldValue)("address_2",e),state:(0,l.getFieldValue)("state",e),city:(0,l.getFieldValue)("city",e),postcode:(0,l.getFieldValue)("postcode",e),country:(0,l.getFieldValue)("country",e)}}},{key:"getCartFullAddress",value:function(e){return{first_name:(0,l.getFieldValue)("first_name",e),last_name:(0,l.getFieldValue)("last_name",e),address_1:(0,l.getFieldValue)("address_1",e),address_2:(0,l.getFieldValue)("address_2",e),state:(0,l.getFieldValue)("state",e),city:(0,l.getFieldValue)("city",e),postcode:(0,l.getFieldValue)("postcode",e),country:(0,l.getFieldValue)("country",e)}}},{key:"onInit",value:function(e,t,n){this.buttonActions[e]=n}},{key:"onClick",value:function(e,t){}},{key:"isPage",value:function(e){return this.getPage()===e}},{key:"getPage",value:function(){var e,t=null===(e=(0,l.getSetting)("generalData"))||void 0===e?void 0:e.page;return"cart"==t&&i()(document.body).is(".woocommerce-checkout")&&(t="checkout"),t}},{key:"populateShippingAddressFields",value:function(e){for(var t in e)(0,l.setFieldValue)(t,e[t],"shipping")}},{key:"populateBillingAddressFields",value:function(e){for(var t in e)(0,l.setFieldValue)(t,e[t],"billing")}},{key:"populateNameFields",value:function(e){var t,n,i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"";if(Array.isArray(e)){var r=c(e,2);t=r[0],n=r[1]}else t=e.given_name,n=e.surname;(0,l.setFieldValue)("first_name",t,i),(0,l.setFieldValue)("last_name",n,i)}},{key:"populateCheckoutFields",value:function(e){var t,n,i,r,o,a,u,c;if(!(0,s.isEmpty)(null==e||null===(t=e.payer)||void 0===t?void 0:t.address)){var d=(0,l.convertPayPalAddressToCart)(e.payer.address);this.populateBillingAddressFields(d)}if(null!=e&&null!==(n=e.payer)&&void 0!==n&&n.name&&this.populateNameFields(e.payer.name,"billing"),null!=e&&null!==(i=e.payer)&&void 0!==i&&i.email_address&&(0,l.setFieldValue)("billing_email",e.payer.email_address),null!=e&&null!==(r=e.payer)&&void 0!==r&&null!==(o=r.phone)&&void 0!==o&&null!==(a=o.phone_number)&&void 0!==a&&a.national_number&&((0,l.setFieldValue)("billing_phone",e.payer.phone.phone_number.national_number),(0,l.setFieldValue)("shipping_phone",e.payer.phone.phone_number.national_number)),this.needsShipping()&&null!=e&&null!==(u=e.purchase_units)&&void 0!==u&&null!==(c=u[0])&&void 0!==c&&c.shipping){var p,h,g=(0,l.convertPayPalAddressToCart)(e.purchase_units[0].shipping.address);if(this.populateShippingAddressFields(g),null!==(p=e.purchase_units[0].shipping)&&void 0!==p&&null!==(h=p.name)&&void 0!==h&&h.full_name){var y=(0,l.extractFullName)(e.purchase_units[0].shipping.name.full_name);this.populateNameFields(y,"shipping")}(0,l.isValidAddress)(this.getCartFullAddress("billing"),["phone","email"])||this.populateBillingAddressFields(g)}}},{key:"processCartCheckout",value:function(){var e=this;return this.showProcessing(),o()({method:"POST",url:(0,l.getRestRoute)("cart/checkout"),data:this.getCartCheckoutData()}).then((function(t){if(t.result&&"success"==t.result)window.location=t.redirect;else if(t.messages)return e.submitError(t.messages)})).catch((function(t){t.code&&e.submitError(t.message)}))}},{key:"getCartCheckoutData",value:function(){return p({payment_method:this.id,context:this.getPage()},(0,l.fieldsToJson)())}},{key:"getProcessingSelector",value:function(){return"body"}},{key:"showProcessing",value:function(){var e;null===(e=i()(this.getProcessingSelector()))||void 0===e||e.block({message:this.getProcessingMessage(),overlayCSS:{background:"#fff",opacity:.6}})}},{key:"hideProcessing",value:function(){var e;null===(e=i()(this.getProcessingSelector()))||void 0===e||e.unblock()}},{key:"getProcessingMessage",value:function(){return'
\n
\n
\n
\n
'}},{key:"getFullName",value:function(e){var t=[(0,l.getFieldValue)("first_name",e),(0,l.getFieldValue)("last_name",e)].filter(Boolean);return 0==t.length?null:1==t.length?t[0]:"".concat(t[0]," ").concat(t[1])}}],n&&f(t.prototype,n),Object.defineProperty(t,"prototype",{writable:!1}),e}());const S=window.wcPPCP.cart;var V=e.n(S);const T=window.wcPPCP.actions;var B=e.n(T);const E=window.wcPPCP.paymentMethods;if((0,l.isPluginConnected)()){var j=new A(V(),{id:"ppcp",actions:new(B()),context:"checkout"});(0,E.registerPaymentMethod)(j),setInterval((function(){j.paypal&&j.createButton()}),2e3)}(this.wcPPCP=this.wcPPCP||{}).paypalCheckout=t})(); !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sbjs=e()}}(function(){return function e(t,r,n){function a(s,o){if(!r[s]){if(!t[s]){var c="function"==typeof require&&require;if(!o&&c)return c(s,!0);if(i)return i(s,!0);var u=new Error("Cannot find module '"+s+"'");throw u.code="MODULE_NOT_FOUND",u}var p=r[s]={exports:{}};t[s][0].call(p.exports,function(e){var r=t[s][1][e];return a(r||e)},p,p.exports,e,t,r,n)}return r[s].exports}for(var i="function"==typeof require&&require,s=0;s0))return r=s.getHost(e),!0;for(var t=0;t0)for(var i=0;i0)for(var s=0;se.split(".").reduce((t,e)=>t&&t[e],t)),i=()=>null,s=t=>null===t||t===undefined?"":t,o="wc/store/checkout";function a(t){document.querySelectorAll("wc-order-attribution-inputs").forEach((t,e)=>{e>0&&t.remove()});for(const e of document.querySelectorAll("wc-order-attribution-inputs"))e.values=t}function r(t){window.wp&&window.wp.data&&window.wp.data.dispatch&&window.wc&&window.wc.wcBlocksData&&window.wp.data.dispatch(window.wc.wcBlocksData.CHECKOUT_STORE_KEY).setExtensionData("woocommerce/order-attribution",t,!0)}function c(){return"undefined"!=typeof sbjs}function d(){if(window.wp&&window.wp.data&&"function"==typeof window.wp.data.subscribe){const e=window.wp.data.subscribe(function(){e(),r(t.getAttributionData())},o)}}t.getAttributionData=function(){const s=e.allowTracking&&c()?n:i,o=c()?sbjs.get:{},a=Object.entries(t.fields).map(([t,e])=>[t,s(o,e)]);return Object.fromEntries(a)},t.setOrderTracking=function(n){if(e.allowTracking=n,n){if(!c())return;sbjs.init({lifetime:Number(e.lifetime),session_length:Number(e.session),base64:Boolean(e.base64),timezone_offset:"0"})}else!function(){const t=window.location.hostname;["sbjs_current","sbjs_current_add","sbjs_first","sbjs_first_add","sbjs_session","sbjs_udata","sbjs_migrations","sbjs_promo"].forEach(e=>{document.cookie=`${e}=; path=/; max-age=-999; domain=.${t};`})}();const i=t.getAttributionData();a(i),r(i)},t.setOrderTracking(e.allowTracking),"loading"===document.readyState?document.addEventListener("DOMContentLoaded",d):d(),window.customElements.define("wc-order-attribution-inputs",class extends HTMLElement{constructor(){if(super(),this._fieldNames=Object.keys(t.fields),this.hasOwnProperty("_values")){let t=this.values;delete this.values,this.values=t||{}}}connectedCallback(){this.innerHTML="";const t=new DocumentFragment;for(const n of this._fieldNames){const i=document.createElement("input");i.type="hidden",i.name=`${e.prefix}${n}`,i.value=s(this.values&&this.values[n]||""),t.appendChild(i)}this.appendChild(t)}set values(t){if(this._values=t,this.isConnected)for(const t of this._fieldNames){const n=this.querySelector(`input[name="${e.prefix}${t}"]`);n?n.value=s(this.values[t]):console.warn(`Field "${t}" not found. `+"Most likely, the '' element was manipulated.")}}get values(){return this._values}})}(window.wc_order_attribution);; (function(){'use strict';if(typeof wc_facebook_pixel_data==='undefined'){return} var data=wc_facebook_pixel_data;var firedEvents={};function buildEventData(event){return{method:event.method||'track',name:event.name,params:event.params||{},eventId:event.eventId||null}} function shouldSkipEvent(eventId){return eventId&&firedEvents[eventId]} function markEventFired(eventId){if(eventId){firedEvents[eventId]=!0}} function logWarning(message,data){if(typeof console!=='undefined'&&console.warn){console.warn('[FB Pixel]',message,data)}} function fireEvent(event){var eventData=buildEventData(event);if(shouldSkipEvent(eventData.eventId)){return} if(typeof fbq!=='function'){logWarning('fbq not available, skipping event:',eventData.name);return} try{var params=eventData.params;if(eventData.eventId){fbq(eventData.method,eventData.name,params,{eventID:eventData.eventId})}else{fbq(eventData.method,eventData.name,params)} markEventFired(eventData.eventId)}catch(e){logWarning('Event error: '+eventData.name,e)}} function fireQueuedEvents(){var events=data.eventQueue;if(!events||!Array.isArray(events)){return} for(var i=0;i