@bigcommerce/checkout-sdk 1.588.0 → 1.589.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/checkout-button.js +1 -1
- package/dist/checkout-button.umd.js +1 -1
- package/dist/checkout-sdk.d.ts +37 -21
- package/dist/checkout-sdk.js +1 -1
- package/dist/checkout-sdk.js.map +1 -1
- package/dist/checkout-sdk.umd.js +1 -1
- package/dist/checkout-sdk.umd.js.map +1 -1
- package/docs/README.md +2 -1
- package/docs/interfaces/BraintreeFastlaneShippingInitializeOptions.md +24 -0
- package/docs/interfaces/PayPalCommerceFastlaneShippingInitializeOptions.md +24 -0
- package/docs/interfaces/ShippingInitializeOptions.md +14 -4
- package/package.json +1 -1
- package/docs/interfaces/BraintreeAcceleratedCheckoutShippingInitializeOptions.md +0 -33
package/dist/checkout-button.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"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 r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[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,{createCheckoutButtonInitializer:()=>du,createTimeout:()=>r.createTimeout});var n={};e.r(n),e.d(n,{createApplePayButtonStrategy:()=>rs,createBoltButtonStrategy:()=>ls,createGooglePayBraintreeButtonStrategy:()=>Os,createGooglePayPayPalCommerceButtonStrategy:()=>ks,createPayPalCommerceAlternativeMethodsButtonStrategy:()=>tu,createPayPalCommerceButtonStrategy:()=>Ks,createPayPalCommerceCreditButtonStrategy:()=>Qs,createPayPalCommerceVenmoButtonStrategy:()=>$s,createPaypalExpressButtonStrategy:()=>cu});const r=require("@bigcommerce/request-sender"),i=require("@bigcommerce/form-poster"),o=require("tslib"),a=require("@bigcommerce/data-store"),s=function(e){function t(t){var n,r,i=this.constructor,o=e.call(this,t||"An unexpected error has occurred.")||this;return o.name="StandardError",o.type="standard",n=o,r=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,i):o.stack=new Error(o.message).stack,o}return(0,o.__extends)(t,e),t}(Error);var u={body:{},headers:{},status:0};const c=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.message,o=r.errors,a=this,s=t||u,c=s.body,d=s.headers,l=s.status;return(a=e.call(this,i||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=c,a.headers=d,a.status=l,a.errors=o||[],a}return(0,o.__extends)(t,e),t}(s),d=function(e){function t(t){var n=e.call(this,t,{message:"There is a problem processing your payment. Please try again later."})||this;return n.name="PaymentMethodInvalidError",n.type="payment_method_invalid",n}return(0,o.__extends)(t,e),t}(c);const l=function(e){function t(t){var n,r,i=this.constructor,o=e.call(this,t||"An unexpected error has occurred.")||this;return o.name="StandardError",o.type="standard",n=o,r=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,i):o.stack=new Error(o.message).stack,o}return(0,o.__extends)(t,e),t}(Error);var p={body:{},headers:{},status:0};const h=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.message,o=r.errors,a=this,s=t||p,u=s.body,c=s.headers,d=s.status;return(a=e.call(this,i||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=u,a.headers=c,a.status=d,a.errors=o||[],a}return(0,o.__extends)(t,e),t}(l),f=function(e){function t(t,n){var r=e.call(this,t,{message:n||"An unexpected error has occurred. The checkout process cannot continue as a result."})||this;return r.name="UnrecoverableError",r.type="unrecoverable",r}return(0,o.__extends)(t,e),t}(h),m=require("lodash");function g(e){return e.reduce((function(e,t){return t?(0,o.__spreadArrays)(e,[t]):e}),[]).join(" ")}function y(e,t){var n=e.body.errors,r=void 0===n?[]:n;return new h(e,{message:_(r)||t,errors:r})}function _(e){if(Array.isArray(e))return e.reduce((function(e,t){return t&&t.message?(0,o.__spreadArrays)(e,[t.message]):e}),[]).join(" ")}const v=function(e){function t(t){var n=e.call(this,t,{message:"The request has timed out or aborted."})||this;return n.name="TimeoutError",n.type="timeout",n}return(0,o.__extends)(t,e),t}(h),C=function(){function e(){this._factoryMethods={},this.register("default",(function(e,t){return new h(e,{message:t})})),this.register("internal",(function(e,t){return function(e,t){var n=e.body,r=n.errors,i=void 0===r?[]:r;return new h(e,{message:g(i)||n.detail||n.title||t,errors:i.length?i.map((function(e){return{code:n.type,message:e}})):[{code:n.type,message:n.detail||n.title}]})}(e,t)})),this.register("storefront",(function(e,t){return function(e,t){var n=e.body;return new h(e,{message:t||n.detail||n.title,errors:[{code:n.code||n.type,message:n.detail||n.title}]})}(e,t)})),this.register("payment",(function(e,t){return y(e,t)})),this.register("timeout",(function(e){return new v(e)}))}return e.prototype.register=function(e,t){this._factoryMethods[e]=t},e.prototype.createError=function(e,t){return(this._factoryMethods[this._getType(e)]||this._factoryMethods.default)(e,t)},e.prototype._getType=function(e){if(0===e.status)return"timeout";if(this._isStorefrontErrorResponseBody(e.body))return"storefront";if(this._isInternalErrorResponseBody(e.body)){var t=(0,m.last)(e.body.type.split("/"));return t&&this._factoryMethods[t]?t:"internal"}var n=(0,m.last)(e.body&&e.body.errors);return n&&n.code&&this._factoryMethods[n.code]?n.code:"payment"},e.prototype._isStorefrontErrorResponseBody=function(e){var t=e;return!this._isInternalErrorResponseBody(e)&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status&&"string"==typeof t.detail},e.prototype._isInternalErrorResponseBody=function(e){var t=e;return"object"==typeof t.errors&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status},e}(),S=require("rxjs"),I=require("rxjs/operators");var w,E,b,P;function A(e,t){return Array.isArray(e)?e.map((function(e){return A(e,t)})):(0,m.isPlainObject)(e)?(0,m.transform)((0,m.omitBy)(e,t),(function(e,n,r){e[r]=A(n,t)}),{}):e}function T(e,t){return function(e){return e.type===E.ClearError}(t)?A(e,(function(e){return e===t.payload})):e}function O(e,t,n){return e===t||(e&&t&&"object"==typeof e&&"object"==typeof t?Array.isArray(e)&&Array.isArray(t)?function(e,t,n){if(e.length!==t.length)return!1;for(var r=0,i=e.length;r<i;r++)if(!O(e[r],t[r],n))return!1;return!0}(e,t,n):!Array.isArray(e)&&!Array.isArray(t)&&(e instanceof Date&&t instanceof Date?function(e,t){return e.getTime()===t.getTime()}(e,t):!(e instanceof Date||t instanceof Date)&&(e instanceof RegExp&&t instanceof RegExp?function(e,t){return e.toString()===t.toString()}(e,t):!(e instanceof RegExp||t instanceof RegExp)&&function(e,t,n){var r=n&&n.keyFilter,i=r?Object.keys(e).filter(r):Object.keys(e),o=r?Object.keys(t).filter(r):Object.keys(t);if(i.length!==o.length)return!1;for(var a=0,s=i.length;a<s;a++){var u=i[a];if(!Object.prototype.hasOwnProperty.call(t,u))return!1;if(!O(e[u],t[u],n))return!1}return!0}(e,t,n))):e===t)}function R(e,t){return void 0===t||O(e,t)?e:t}function M(e,t,n){var r;return e&&Object.prototype.hasOwnProperty.call(e,t)&&O(e[t],n)?e:(0,o.__assign)((0,o.__assign)({},e),((r={})[t]=n,r))}!function(e){e.LoadCheckoutRequested="LOAD_CHECKOUT_REQUESTED",e.LoadCheckoutSucceeded="LOAD_CHECKOUT_SUCCEEDED",e.LoadCheckoutFailed="LOAD_CHECKOUT_FAILED",e.UpdateCheckoutRequested="UPDATE_CHECKOUT_REQUESTED",e.UpdateCheckoutSucceeded="UPDATE_CHECKOUT_SUCCEEDED",e.UpdateCheckoutFailed="UPDATE_CHECKOUT_FAILED"}(w||(w={})),function(e){e.ClearError="CLEAR_ERROR"}(E||(E={})),function(e){e.UpdateSubscriptionsRequested="UPDATE_SUBSCRIPTIONS_REQUESTED",e.UpdateSubscriptionsSucceeded="UPDATE_SUBSCRIPTIONS_SUCCEEDED",e.UpdateSubscriptionsFailed="UPDATE_SUBSCRIPTIONS_FAILED"}(b||(b={})),function(e){e.UpdateBillingAddressRequested="UPDATE_BILLING_ADDRESS_REQUESTED",e.UpdateBillingAddressSucceeded="UPDATE_BILLING_ADDRESS_SUCCEEDED",e.UpdateBillingAddressFailed="UPDATE_BILLING_ADDRESS_FAILED",e.ContinueAsGuestRequested="CONTINUE_AS_GUEST_REQUESTED",e.ContinueAsGuestSucceeded="CONTINUE_AS_GUEST_SUCCEEDED",e.ContinueAsGuestFailed="CONTINUE_AS_GUEST_FAILED"}(P||(P={}));var k={errors:{},statuses:{}};function D(e,t){return void 0===e&&(e=k),(0,a.combineReducers)({data:N,errors:(0,a.composeReducers)(L,T),statuses:z})(e,t)}function N(e,t){switch(t.type){case P.UpdateBillingAddressSucceeded:case P.ContinueAsGuestSucceeded:case w.LoadCheckoutSucceeded:return R(e,t.payload&&t.payload.billingAddress);default:return e}}function L(e,t){switch(void 0===e&&(e=k.errors),t.type){case w.LoadCheckoutRequested:case w.LoadCheckoutSucceeded:return M(e,"loadError",void 0);case w.LoadCheckoutFailed:return M(e,"loadError",t.payload);case P.UpdateBillingAddressRequested:case P.UpdateBillingAddressSucceeded:return M(e,"updateError",void 0);case P.UpdateBillingAddressFailed:return M(e,"updateError",t.payload);case b.UpdateSubscriptionsRequested:case b.UpdateSubscriptionsSucceeded:case P.ContinueAsGuestRequested:case P.ContinueAsGuestSucceeded:return M(e,"continueAsGuestError",void 0);case b.UpdateSubscriptionsFailed:case P.ContinueAsGuestFailed:return M(e,"continueAsGuestError",t.payload);default:return e}}function z(e,t){switch(void 0===e&&(e=k.statuses),t.type){case w.LoadCheckoutRequested:return M(e,"isLoading",!0);case w.LoadCheckoutSucceeded:case w.LoadCheckoutFailed:return M(e,"isLoading",!1);case P.UpdateBillingAddressRequested:return M(e,"isUpdating",!0);case P.UpdateBillingAddressFailed:case P.UpdateBillingAddressSucceeded:return M(e,"isUpdating",!1);case P.ContinueAsGuestRequested:case b.UpdateSubscriptionsRequested:return M(e,"isContinuingAsGuest",!0);case b.UpdateSubscriptionsSucceeded:case b.UpdateSubscriptionsFailed:case P.ContinueAsGuestFailed:case P.ContinueAsGuestSucceeded:return M(e,"isContinuingAsGuest",!1);default:return e}}function F(e){return(0,m.isPlainObject)(e)}const U=function e(t,n,r){var i=(r||{}).matchObject,o=void 0===i?function(e,t){return void 0!==e.id&&e.id===t.id}:i;if(!t)return n;if(!n||t===n)return t;var a=0,s=0,u=function(e,t,n){return a+=e===t?1:0,s+=e===n?1:0,e},c=n.map((function(n,r){var i=t&&t[r];return F(i)&&F(n)?o(i,n)?u(q(i,n),i,n):u(R(i,n),i,n):(0,m.isArray)(i)&&(0,m.isArray)(n)?u(e(i,n),i,n):u(R(i,n),i,n)}));return a===n.length&&t&&t.length===n.length?t:s===n.length?n:c},q=function e(t,n){return t?n&&t!==n?Object.keys(n).reduce((function(t,r){var i=t[r],o=n[r];return F(i)&&F(o)?M(t,r,e(i,o)):(0,m.isArray)(i)&&(0,m.isArray)(o)?M(t,r,U(i,o)):M(t,r,o)}),t):t:n};var B,G,x;!function(e){e.ApplyCouponRequested="APPLY_COUPON_REQUESTED",e.ApplyCouponSucceeded="APPLY_COUPON_SUCCEEDED",e.ApplyCouponFailed="APPLY_COUPON_FAILED",e.RemoveCouponRequested="REMOVE_COUPON_REQUESTED",e.RemoveCouponSucceeded="REMOVE_COUPON_SUCCEEDED",e.RemoveCouponFailed="REMOVE_COUPON_FAILED"}(B||(B={})),function(e){e.ApplyGiftCertificateRequested="APPLY_GIFT_CERTIFICATE_REQUESTED",e.ApplyGiftCertificateSucceeded="APPLY_GIFT_CERTIFICATE_SUCCEEDED",e.ApplyGiftCertificateFailed="APPLY_GIFT_CERTIFICATE_FAILED",e.RemoveGiftCertificateRequested="REMOVE_GIFT_CERTIFICATE_REQUESTED",e.RemoveGiftCertificateSucceeded="REMOVE_GIFT_CERTIFICATE_SUCCEEDED",e.RemoveGiftCertificateFailed="REMOVE_GIFT_CERTIFICATE_FAILED"}(G||(G={})),function(e){e.CreateConsignmentsRequested="CREATE_CONSIGNMENTS_REQUESTED",e.CreateConsignmentsSucceeded="CREATE_CONSIGNMENTS_SUCCEEDED",e.CreateConsignmentsFailed="CREATE_CONSIGNMENTS_FAILED",e.UpdateConsignmentRequested="UPDATE_CONSIGNMENT_REQUESTED",e.UpdateConsignmentSucceeded="UPDATE_CONSIGNMENT_SUCCEEDED",e.UpdateConsignmentFailed="UPDATE_CONSIGNMENT_FAILED",e.DeleteConsignmentRequested="DELETE_CONSIGNMENT_REQUESTED",e.DeleteConsignmentSucceeded="DELETE_CONSIGNMENT_SUCCEEDED",e.DeleteConsignmentFailed="DELETE_CONSIGNMENT_FAILED",e.UpdateShippingOptionRequested="UPDATE_SHIPPING_OPTION_REQUESTED",e.UpdateShippingOptionSucceeded="UPDATE_SHIPPING_OPTION_SUCCEEDED",e.UpdateShippingOptionFailed="UPDATE_SHIPPING_OPTION_FAILED",e.LoadShippingOptionsRequested="LOAD_SHIPPING_OPTIONS_REQUESTED",e.LoadShippingOptionsSucceeded="LOAD_SHIPPING_OPTIONS_SUCCEEDED",e.LoadShippingOptionsFailed="LOAD_SHIPPING_OPTIONS_FAILED"}(x||(x={}));var Y,V={errors:{},statuses:{}};function H(e,t){return void 0===e&&(e=V),(0,a.combineReducers)({data:j,errors:(0,a.composeReducers)(K,T),statuses:W})(e,t)}function j(e,t){switch(t.type){case P.UpdateBillingAddressSucceeded:case w.LoadCheckoutSucceeded:case x.CreateConsignmentsSucceeded:case x.DeleteConsignmentSucceeded:case x.UpdateConsignmentSucceeded:case x.UpdateShippingOptionSucceeded:case x.LoadShippingOptionsSucceeded:case B.ApplyCouponSucceeded:case B.RemoveCouponSucceeded:case G.ApplyGiftCertificateSucceeded:case G.RemoveGiftCertificateSucceeded:return q(e,t.payload&&t.payload.cart);default:return e}}function W(e,t){switch(void 0===e&&(e=V.statuses),t.type){case w.LoadCheckoutRequested:return M(e,"isLoading",!0);case w.LoadCheckoutFailed:case w.LoadCheckoutSucceeded:return M(e,"isLoading",!1);default:return e}}function K(e,t){switch(void 0===e&&(e=V.errors),t.type){case w.LoadCheckoutRequested:case w.LoadCheckoutSucceeded:return M(e,"loadError",void 0);case w.LoadCheckoutFailed:return M(e,"loadError",t.payload);default:return e}}!function(e){e.InitializeButtonFailed="INITIALIZE_BUTTON_FAILED",e.InitializeButtonRequested="INITIALIZE_BUTTON_REQUESTED",e.InitializeButtonSucceeded="INITIALIZE_BUTTON_SUCCEEDED",e.DeinitializeButtonFailed="DEINITIALIZE_BUTTON_FAILED",e.DeinitializeButtonRequested="DEINITIALIZE_BUTTON_REQUESTED",e.DeinitializeButtonSucceeded="DEINITIALIZE_BUTTON_SUCCEEDED"}(Y||(Y={}));var J,Z={data:{},errors:{},statuses:{}},Q={initializedContainers:{}},X={},$={};function ee(e,t){var n,r,i;return void 0===e&&(e=Z),t.meta&&t.meta.methodId?(0,a.combineReducers)({data:(0,a.combineReducers)((n={},n[t.meta.methodId]=te,n)),errors:(0,a.combineReducers)((r={},r[t.meta.methodId]=ne,r)),statuses:(0,a.combineReducers)((i={},i[t.meta.methodId]=re,i))})(e,t):e}function te(e,t){var n;switch(void 0===e&&(e=Q),t.type){case Y.InitializeButtonSucceeded:return t.meta&&t.meta.containerId?q(e,{initializedContainers:(n={},n[t.meta.containerId]=!0,n)}):e;case Y.DeinitializeButtonSucceeded:return M(e,"initializedContainers",{})}return e}function ne(e,t){switch(void 0===e&&(e=X),t.type){case Y.InitializeButtonRequested:case Y.InitializeButtonSucceeded:return M(e,"initializeError",void 0);case Y.InitializeButtonFailed:return M(e,"initializeError",t.payload);case Y.DeinitializeButtonRequested:case Y.DeinitializeButtonSucceeded:return M(e,"deinitializeError",void 0);case Y.DeinitializeButtonFailed:return M(e,"deinitializeError",t.payload);default:return e}}function re(e,t){switch(void 0===e&&(e=$),t.type){case Y.InitializeButtonRequested:return M(e,"isInitializing",!0);case Y.InitializeButtonFailed:case Y.InitializeButtonSucceeded:return M(e,"isInitializing",!1);case Y.DeinitializeButtonRequested:return M(e,"isDeinitializing",!0);case Y.DeinitializeButtonFailed:case Y.DeinitializeButtonSucceeded:return M(e,"isDeinitializing",!1);default:return e}}!function(e){e.LoadConfigRequested="LOAD_CONFIG_REQUESTED",e.LoadConfigSucceeded="LOAD_CONFIG_SUCCEEDED",e.LoadConfigFailed="LOAD_CONFIG_FAILED"}(J||(J={}));var ie,oe={meta:{},errors:{},statuses:{}};function ae(e,t){return void 0===e&&(e=oe),(0,a.combineReducers)({data:se,errors:(0,a.composeReducers)(ue,T),statuses:ce})(e,t)}function se(e,t){return t.type===J.LoadConfigSucceeded?q(e,t.payload):e}function ue(e,t){switch(void 0===e&&(e=oe.errors),t.type){case J.LoadConfigSucceeded:return M(e,"loadError",void 0);case J.LoadConfigFailed:return M(e,"loadError",t.payload);default:return e}}function ce(e,t){switch(void 0===e&&(e=oe.statuses),t.type){case J.LoadConfigRequested:return M(e,"isLoading",!0);case J.LoadConfigSucceeded:case J.LoadConfigFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.LoadOrderRequested="LOAD_ORDER_REQUESTED",e.LoadOrderSucceeded="LOAD_ORDER_SUCCEEDED",e.LoadOrderFailed="LOAD_ORDER_FAILED",e.LoadOrderPaymentsRequested="LOAD_ORDER_PAYMENTS_REQUESTED",e.LoadOrderPaymentsSucceeded="LOAD_ORDER_PAYMENTS_SUCCEEDED",e.LoadOrderPaymentsFailed="LOAD_ORDER_PAYMENTS_FAILED",e.SubmitOrderRequested="SUBMIT_ORDER_REQUESTED",e.SubmitOrderSucceeded="SUBMIT_ORDER_SUCCEEDED",e.SubmitOrderFailed="SUBMIT_ORDER_FAILED",e.FinalizeOrderRequested="FINALIZE_ORDER_REQUESTED",e.FinalizeOrderSucceeded="FINALIZE_ORDER_SUCCEEDED",e.FinalizeOrderFailed="FINALIZE_ORDER_FAILED"}(ie||(ie={}));var de={errors:{},statuses:{}};function le(e,t){return void 0===e&&(e=de),(0,a.combineReducers)({data:pe,errors:(0,a.composeReducers)(he,T),statuses:fe})(e,t)}function pe(e,t){switch(t.type){case w.LoadCheckoutSucceeded:case B.ApplyCouponSucceeded:case x.UpdateShippingOptionSucceeded:case B.RemoveCouponSucceeded:case ie.LoadOrderSucceeded:return U(e,t.payload&&t.payload.coupons);default:return e}}function he(e,t){switch(void 0===e&&(e={}),t.type){case B.ApplyCouponRequested:case B.ApplyCouponSucceeded:return M(e,"applyCouponError",void 0);case B.ApplyCouponFailed:return M(e,"applyCouponError",t.payload);case B.RemoveCouponRequested:case B.RemoveCouponSucceeded:return M(e,"removeCouponError",void 0);case B.RemoveCouponFailed:return M(e,"removeCouponError",t.payload);default:return e}}function fe(e,t){switch(void 0===e&&(e={}),t.type){case B.ApplyCouponRequested:return M(e,"isApplyingCoupon",!0);case B.ApplyCouponSucceeded:case B.ApplyCouponFailed:return M(e,"isApplyingCoupon",!1);case B.RemoveCouponRequested:return M(e,"isRemovingCoupon",!0);case B.RemoveCouponSucceeded:case B.RemoveCouponFailed:return M(e,"isRemovingCoupon",!1);default:return e}}var me,ge={errors:{},statuses:{}};function ye(e,t){return void 0===e&&(e=ge),(0,a.combineReducers)({data:_e,errors:(0,a.composeReducers)(ve,T),statuses:Ce})(e,t)}function _e(e,t){switch(t.type){case w.LoadCheckoutSucceeded:case x.CreateConsignmentsSucceeded:case x.UpdateConsignmentSucceeded:case x.DeleteConsignmentSucceeded:case x.UpdateShippingOptionSucceeded:case B.ApplyCouponSucceeded:case B.RemoveCouponSucceeded:case G.ApplyGiftCertificateSucceeded:case G.RemoveGiftCertificateSucceeded:return U(e,t.payload&&t.payload.giftCertificates);default:return e}}function ve(e,t){switch(void 0===e&&(e=ge.errors),t.type){case G.ApplyGiftCertificateRequested:case G.ApplyGiftCertificateSucceeded:return M(e,"applyGiftCertificateError",void 0);case G.ApplyGiftCertificateFailed:return M(e,"applyGiftCertificateError",t.payload);case G.RemoveGiftCertificateRequested:case G.RemoveGiftCertificateSucceeded:return M(e,"removeGiftCertificateError",void 0);case G.RemoveGiftCertificateFailed:return M(e,"removeGiftCertificateError",t.payload);default:return e}}function Ce(e,t){switch(void 0===e&&(e=ge.statuses),t.type){case G.ApplyGiftCertificateRequested:return M(e,"isApplyingGiftCertificate",!0);case G.ApplyGiftCertificateSucceeded:case G.ApplyGiftCertificateFailed:return M(e,"isApplyingGiftCertificate",!1);case G.RemoveGiftCertificateRequested:return M(e,"isRemovingGiftCertificate",!0);case G.RemoveGiftCertificateSucceeded:case G.RemoveGiftCertificateFailed:return M(e,"isRemovingGiftCertificate",!1);default:return e}}!function(e){e.SignInCustomerRequested="SIGN_IN_CUSTOMER_REQUESTED",e.SignInCustomerSucceeded="SIGN_IN_CUSTOMER_SUCCEEDED",e.SignInCustomerFailed="SIGN_IN_CUSTOMER_FAILED",e.SignOutCustomerRequested="SIGN_OUT_CUSTOMER_REQUESTED",e.SignOutCustomerSucceeded="SIGN_OUT_CUSTOMER_SUCCEEDED",e.SignOutCustomerFailed="SIGN_OUT_CUSTOMER_FAILED",e.CreateCustomerRequested="CREATE_CUSTOMER_REQUESTED",e.CreateCustomerSucceeded="CREATE_CUSTOMER_SUCCEEDED",e.CreateCustomerFailed="CREATE_CUSTOMER_FAILED",e.CreateCustomerAddressRequested="CREATE_CUSTOMER_ADDRESS_REQUESTED",e.CreateCustomerAddressSucceeded="CREATE_CUSTOMER_ADDRESS_SUCCEEDED",e.CreateCustomerAddressFailed="CREATE_CUSTOMER_ADDRESS_FAILED",e.StripeLinkAuthenticated="STRIPE_LINK_AUTHENTICATED"}(me||(me={}));var Se,Ie={errors:{},statuses:{}};function we(e,t){return void 0===e&&(e=Ie),(0,a.combineReducers)({data:Ee,errors:(0,a.composeReducers)(be,T),statuses:Pe})(e,t)}function Ee(e,t){switch(t.type){case P.ContinueAsGuestSucceeded:case w.LoadCheckoutSucceeded:return q(e,t.payload&&t.payload.customer);case me.CreateCustomerAddressSucceeded:return q(e,t.payload);default:return e}}function be(e,t){switch(void 0===e&&(e=Ie.errors),t.type){case me.CreateCustomerRequested:case me.CreateCustomerSucceeded:return M(e,"createError",void 0);case me.CreateCustomerFailed:return M(e,"createError",t.payload);case me.CreateCustomerAddressRequested:case me.CreateCustomerAddressSucceeded:return M(e,"createAddressError",void 0);case me.CreateCustomerAddressFailed:return M(e,"createAddressError",t.payload);default:return e}}function Pe(e,t){switch(void 0===e&&(e=Ie.statuses),t.type){case me.CreateCustomerRequested:return M(e,"isCreating",!0);case me.CreateCustomerFailed:case me.CreateCustomerSucceeded:return M(e,"isCreating",!1);case me.CreateCustomerAddressRequested:return M(e,"isCreatingAddress",!0);case me.CreateCustomerAddressFailed:case me.CreateCustomerAddressSucceeded:return M(e,"isCreatingAddress",!1);default:return e}}!function(e){e.SignInFailed="CUSTOMER_STRATEGY_SIGN_IN_FAILED",e.SignInRequested="CUSTOMER_STRATEGY_SIGN_IN_REQUESTED",e.SignInSucceeded="CUSTOMER_STRATEGY_SIGN_IN_SUCCEEDED",e.SignOutFailed="CUSTOMER_STRATEGY_SIGN_OUT_FAILED",e.SignOutRequested="CUSTOMER_STRATEGY_SIGN_OUT_REQUESTED",e.SignOutSucceeded="CUSTOMER_STRATEGY_SIGN_OUT_SUCCEEDED",e.ExecutePaymentMethodCheckoutFailed="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_FAILED",e.ExecutePaymentMethodCheckoutRequested="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_REQUESTED",e.ExecutePaymentMethodCheckoutSucceeded="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_SUCCEEDED",e.InitializeFailed="CUSTOMER_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="CUSTOMER_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="CUSTOMER_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="CUSTOMER_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="CUSTOMER_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="CUSTOMER_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="CUSTOMER_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="CUSTOMER_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="CUSTOMER_STRATEGY_WIDGET_INTERACTION_FAILED"}(Se||(Se={}));var Ae,Te={data:{},errors:{},statuses:{}};function Oe(e,t){return void 0===e&&(e=Te),(0,a.combineReducers)({data:Re,errors:(0,a.composeReducers)(Me,T),statuses:ke})(e,t)}function Re(e,t){var n,r;switch(void 0===e&&(e=Te.data),t.type){case Se.InitializeSucceeded:return q(e,((n={})[t.meta&&t.meta.methodId]={isInitialized:!0},n));case Se.DeinitializeSucceeded:return q(e,((r={})[t.meta&&t.meta.methodId]={isInitialized:!1},r))}return e}function Me(e,t){var n;switch(void 0===e&&(e=Te.errors),t.type){case Se.InitializeRequested:case Se.InitializeSucceeded:return q(e,{initializeErrors:(0,o.__assign)({},e.initializeErrors),initializeMethodId:e.initializeMethodId?e.initializeMethodId:void 0});case Se.InitializeFailed:return q(e,{initializeErrors:(0,o.__assign)((0,o.__assign)({},e.initializeErrors),(n={},n[t.meta&&t.meta.methodId]=t.payload,n)),initializeMethodId:t.meta&&t.meta.methodId});case Se.DeinitializeRequested:case Se.DeinitializeSucceeded:return q(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Se.DeinitializeFailed:return q(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Se.SignInRequested:case Se.SignInSucceeded:return q(e,{signInError:void 0,signInMethodId:void 0});case Se.SignInFailed:return q(e,{signInError:t.payload,signInMethodId:t.meta&&t.meta.methodId});case Se.SignOutRequested:case Se.SignOutSucceeded:return q(e,{signOutError:void 0,signOutMethodId:void 0});case Se.SignOutFailed:return q(e,{signOutError:t.payload,signOutMethodId:t.meta&&t.meta.methodId});case Se.ExecutePaymentMethodCheckoutRequested:case Se.ExecutePaymentMethodCheckoutSucceeded:return q(e,{executePaymentMethodCheckoutError:void 0,executePaymentMethodCheckoutMethodId:void 0});case Se.ExecutePaymentMethodCheckoutFailed:return q(e,{executePaymentMethodCheckoutError:t.payload,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Se.WidgetInteractionStarted:case Se.WidgetInteractionFinished:return q(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Se.WidgetInteractionFailed:return q(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function ke(e,t){switch(void 0===e&&(e=Te.statuses),t.type){case Se.InitializeRequested:return q(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Se.InitializeFailed:case Se.InitializeSucceeded:return q(e,{isInitializing:!1,initializeMethodId:void 0});case Se.DeinitializeRequested:return q(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Se.DeinitializeFailed:case Se.DeinitializeSucceeded:return q(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Se.SignInRequested:return q(e,{isSigningIn:!0,signInMethodId:t.meta&&t.meta.methodId});case Se.SignInFailed:case Se.SignInSucceeded:return q(e,{isSigningIn:!1,signInMethodId:void 0});case Se.SignOutRequested:return q(e,{isSigningOut:!0,signOutMethodId:t.meta&&t.meta.methodId});case Se.SignOutFailed:case Se.SignOutSucceeded:return q(e,{isSigningOut:!1,signOutMethodId:void 0});case Se.ExecutePaymentMethodCheckoutRequested:return q(e,{isExecutingPaymentMethodCheckout:!0,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Se.ExecutePaymentMethodCheckoutFailed:case Se.ExecutePaymentMethodCheckoutSucceeded:return q(e,{isExecutingPaymentMethodCheckout:!1,executePaymentMethodCheckoutMethodId:void 0});case Se.WidgetInteractionStarted:return q(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Se.WidgetInteractionFinished:case Se.WidgetInteractionFailed:return q(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.LoadExtensionsRequested="LOAD_EXTENSIONS_REQUESTED",e.LoadExtensionsSucceeded="LOAD_EXTENSIONS_SUCCEEDED",e.LoadExtensionsFailed="LOAD_EXTENSIONS_FAILED",e.RenderExtensionRequested="RENDER_EXTENSION_REQUESTED",e.RenderExtensionSucceeded="RENDER_EXTENSION_SUCCEEDED",e.RenderExtensionFailed="RENDER_EXTENSION_FAILED"}(Ae||(Ae={}));var De,Ne={errors:{},statuses:{}};function Le(e,t){return void 0===e&&(e=Ne),(0,a.combineReducers)({data:ze,errors:(0,a.composeReducers)(Fe,T),statuses:Ue})(e,t)}function ze(e,t){return t.type===Ae.LoadExtensionsSucceeded?U(e,t.payload):e}function Fe(e,t){switch(void 0===e&&(e=Ne.errors),t.type){case Ae.LoadExtensionsRequested:case Ae.LoadExtensionsSucceeded:return M(e,"loadError",void 0);case Ae.RenderExtensionRequested:case Ae.RenderExtensionSucceeded:return M(e,"renderError",void 0);case Ae.LoadExtensionsFailed:return M(e,"loadError",t.payload);case Ae.RenderExtensionFailed:return M(e,"renderError",t.payload);default:return e}}function Ue(e,t){switch(void 0===e&&(e=Ne.statuses),t.type){case Ae.LoadExtensionsRequested:return M(e,"isLoading",!0);case Ae.LoadExtensionsSucceeded:case Ae.LoadExtensionsFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.LoadFormFieldsRequested="LOAD_FORM_FIELDS_REQUESTED",e.LoadFormFieldsSucceeded="LOAD_FORM_FIELDS_SUCCEEDED",e.LoadFormFieldsFailed="LOAD_FORM_FIELDS_FAILED"}(De||(De={}));var qe,Be={errors:{},statuses:{}};function Ge(e,t){return void 0===e&&(e=Be),(0,a.combineReducers)({data:xe,errors:(0,a.composeReducers)(Ye,T),statuses:Ve})(e,t)}function xe(e,t){return t.type===De.LoadFormFieldsSucceeded?q(e,t.payload):e}function Ye(e,t){switch(void 0===e&&(e=Be.errors),t.type){case De.LoadFormFieldsSucceeded:return M(e,"loadError",void 0);case De.LoadFormFieldsFailed:return M(e,"loadError",t.payload);default:return e}}function Ve(e,t){switch(void 0===e&&(e=Be.statuses),t.type){case De.LoadFormFieldsRequested:return M(e,"isLoading",!0);case De.LoadFormFieldsSucceeded:case De.LoadFormFieldsFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.LoadCountriesRequested="LOAD_COUNTRIES_REQUESTED",e.LoadCountriesSucceeded="LOAD_COUNTRIES_SUCCEEDED",e.LoadCountriesFailed="LOAD_COUNTRIES_FAILED"}(qe||(qe={}));var He={errors:{},statuses:{}};function je(e,t){return void 0===e&&(e=He),(0,a.combineReducers)({data:We,errors:(0,a.composeReducers)(Ke,T),statuses:Je})(e,t)}function We(e,t){return t.type===qe.LoadCountriesSucceeded?U(e,t.payload):e}function Ke(e,t){switch(void 0===e&&(e=He.errors),t.type){case qe.LoadCountriesRequested:case qe.LoadCountriesSucceeded:return M(e,"loadError",void 0);case qe.LoadCountriesFailed:return M(e,"loadError",t.payload);default:return e}}function Je(e,t){switch(void 0===e&&(e=He.statuses),t.type){case qe.LoadCountriesRequested:return M(e,"isLoading",!0);case qe.LoadCountriesSucceeded:case qe.LoadCountriesFailed:return M(e,"isLoading",!1);default:return e}}var Ze={errors:{},meta:{},statuses:{}};function Qe(e,t){return void 0===e&&(e=Ze),(0,a.combineReducers)({data:Xe,errors:(0,a.composeReducers)(et,T),meta:$e,statuses:tt})(e,t)}function Xe(e,t){switch(t.type){case ie.LoadOrderSucceeded:case ie.LoadOrderPaymentsSucceeded:return q(e,(0,m.omit)(t.payload,["billingAddress","coupons"]));default:return e}}function $e(e,t){switch(t.type){case ie.FinalizeOrderSucceeded:case ie.SubmitOrderSucceeded:return q(e,(0,o.__assign)((0,o.__assign)({},t.meta),{callbackUrl:t.payload&&t.payload.order.callbackUrl,orderToken:t.payload&&t.payload.order.token,payment:t.payload&&t.payload.order&&t.payload.order.payment}));default:return e}}function et(e,t){switch(void 0===e&&(e=Ze.errors),t.type){case ie.LoadOrderRequested:case ie.LoadOrderSucceeded:case ie.LoadOrderPaymentsSucceeded:case ie.LoadOrderPaymentsRequested:return M(e,"loadError",void 0);case ie.LoadOrderFailed:case ie.LoadOrderPaymentsFailed:return M(e,"loadError",t.payload);default:return e}}function tt(e,t){switch(void 0===e&&(e=Ze.statuses),t.type){case ie.LoadOrderRequested:case ie.LoadOrderPaymentsRequested:return M(e,"isLoading",!0);case ie.LoadOrderSucceeded:case ie.LoadOrderFailed:case ie.LoadOrderPaymentsSucceeded:case ie.LoadOrderPaymentsFailed:return M(e,"isLoading",!1);default:return e}}var nt,rt,it={};function ot(e,t){return void 0===e&&(e=it),(0,a.combineReducers)({data:at})(e,t)}function at(e,t){switch(t.type){case ie.LoadOrderPaymentsSucceeded:case ie.LoadOrderSucceeded:return R(e,t.payload&&t.payload.billingAddress);default:return e}}function st(e,t){return void 0===e&&(e={}),(0,a.combineReducers)({data:ut})(e,t)}function ut(e,t){return t.type===nt.SubmitPaymentSucceeded?t.payload:e}!function(e){e.SubmitPaymentRequested="SUBMIT_PAYMENT_REQUESTED",e.SubmitPaymentSucceeded="SUBMIT_PAYMENT_SUCCEEDED",e.SubmitPaymentFailed="SUBMIT_PAYMENT_FAILED",e.InitializeOffsitePaymentRequested="INITIALIZE_OFFSITE_PAYMENT_REQUESTED",e.InitializeOffsitePaymentSucceeded="INITIALIZE_OFFSITE_PAYMENT_SUCCEEDED",e.InitializeOffsitePaymentFailed="INITIALIZE_OFFSITE_PAYMENT_FAILED"}(nt||(nt={})),function(e){e.LoadPaymentMethodRequested="LOAD_PAYMENT_METHOD_REQUESTED",e.LoadPaymentMethodSucceeded="LOAD_PAYMENT_METHOD_SUCCEEDED",e.LoadPaymentMethodFailed="LOAD_PAYMENT_METHOD_FAILED",e.LoadPaymentMethodsRequested="LOAD_PAYMENT_METHODS_REQUESTED",e.LoadPaymentMethodsSucceeded="LOAD_PAYMENT_METHODS_SUCCEEDED",e.LoadPaymentMethodsFailed="LOAD_PAYMENT_METHODS_FAILED"}(rt||(rt={}));var ct,dt={errors:{},statuses:{}};function lt(e,t){return void 0===e&&(e=dt),(0,a.combineReducers)({data:pt,errors:(0,a.composeReducers)(ft,T),meta:ht,statuses:mt})(e,t)}function pt(e,t){switch(t.type){case rt.LoadPaymentMethodSucceeded:return function(e,t,n){if(!t)return e;var r=(0,m.pick)(t,"id"),i=(0,m.findIndex)(e,"object"==typeof n?(0,m.pickBy)(n):n||r),a=(0,o.__spreadArrays)(e);if(-1===i)a.push(t);else{var s=e[i];a[i]=F(s)&&F(t)?q(s,t):t}return a}(e||[],t.payload,t.payload&&{id:t.payload.id,gateway:t.payload.gateway});case rt.LoadPaymentMethodsSucceeded:return U(e,t.payload,{matchObject:function(e,t){return e.id===t.id&&e.gateway===t.gateway}});default:return e}}function ht(e,t){return t.type===rt.LoadPaymentMethodsSucceeded?q(e,t.meta):e}function ft(e,t){switch(void 0===e&&(e=dt.errors),t.type){case rt.LoadPaymentMethodsRequested:case rt.LoadPaymentMethodsSucceeded:return M(e,"loadError",void 0);case rt.LoadPaymentMethodsFailed:return M(e,"loadError",t.payload);case rt.LoadPaymentMethodRequested:case rt.LoadPaymentMethodSucceeded:return q(e,{loadMethodId:void 0,loadMethodError:void 0});case rt.LoadPaymentMethodFailed:return q(e,{loadMethodId:t.meta.methodId,loadMethodError:t.payload});default:return e}}function mt(e,t){switch(void 0===e&&(e=dt.statuses),t.type){case rt.LoadPaymentMethodsRequested:return M(e,"isLoading",!0);case rt.LoadPaymentMethodsSucceeded:case rt.LoadPaymentMethodsFailed:return M(e,"isLoading",!1);case rt.LoadPaymentMethodRequested:return q(e,{isLoadingMethod:!0,loadMethodId:t.meta.methodId});case rt.LoadPaymentMethodSucceeded:case rt.LoadPaymentMethodFailed:return q(e,{isLoadingMethod:!1,loadMethodId:void 0});default:return e}}!function(e){e.ExecuteFailed="PAYMENT_STRATEGY_EXECUTE_FAILED",e.ExecuteRequested="PAYMENT_STRATEGY_EXECUTE_REQUESTED",e.ExecuteSucceeded="PAYMENT_STRATEGY_EXECUTE_SUCCEEDED",e.FinalizeFailed="PAYMENT_STRATEGY_FINALIZE_FAILED",e.FinalizeRequested="PAYMENT_STRATEGY_FINALIZE_REQUESTED",e.FinalizeSucceeded="PAYMENT_STRATEGY_FINALIZE_SUCCEEDED",e.InitializeFailed="PAYMENT_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="PAYMENT_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="PAYMENT_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="PAYMENT_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="PAYMENT_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="PAYMENT_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="PAYMENT_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="PAYMENT_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="PAYMENT_STRATEGY_WIDGET_INTERACTION_FAILED"}(ct||(ct={}));var gt,yt={data:{},errors:{},statuses:{}};function _t(e,t){return void 0===e&&(e=yt),(0,a.combineReducers)({data:vt,errors:(0,a.composeReducers)(Ct,T),statuses:St})(e,t)}function vt(e,t){var n,r;switch(void 0===e&&(e=yt.data),t.type){case ct.InitializeSucceeded:if(t.meta){var i=t.meta,o=i.methodId,a=i.gatewayId;return q(e,((n={})[a?o+"."+a:o]={isInitialized:!0},n))}break;case ct.DeinitializeSucceeded:if(t.meta){var s=t.meta;return o=s.methodId,a=s.gatewayId,q(e,((r={})[a?o+"."+a:o]={isInitialized:!1},r))}}return e}function Ct(e,t){switch(void 0===e&&(e=yt.errors),t.type){case ct.InitializeRequested:case ct.InitializeSucceeded:return q(e,{initializeError:void 0,initializeMethodId:void 0});case ct.InitializeFailed:var n=t.meta&&t.meta.methodId;if(t.meta){var r=t.meta,i=r.methodId;n=(a=r.gatewayId)?i+"."+a:i}return q(e,{initializeError:t.payload,initializeMethodId:n});case ct.DeinitializeRequested:case ct.DeinitializeSucceeded:return q(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case ct.DeinitializeFailed:var o=t.meta&&t.meta.methodId;if(t.meta){var a,s=t.meta;i=s.methodId,o=(a=s.gatewayId)?i+"."+a:i}return q(e,{deinitializeError:t.payload,deinitializeMethodId:o});case ct.ExecuteRequested:case ct.ExecuteSucceeded:return q(e,{executeError:void 0,executeMethodId:void 0});case ct.ExecuteFailed:return q(e,{executeError:t.payload,executeMethodId:t.meta&&t.meta.methodId});case ct.FinalizeRequested:case ct.FinalizeSucceeded:return q(e,{finalizeError:void 0,finalizeMethodId:void 0});case ct.FinalizeFailed:return q(e,{finalizeError:t.payload,finalizeMethodId:t.meta&&t.meta.methodId});case ct.WidgetInteractionStarted:case ct.WidgetInteractionFinished:return q(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case ct.WidgetInteractionFailed:return q(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function St(e,t){switch(void 0===e&&(e=yt.statuses),t.type){case ct.InitializeRequested:var n=t.meta&&t.meta.methodId;if(t.meta){var r=t.meta,i=r.methodId;n=(a=r.gatewayId)?i+"."+a:i}return q(e,{isInitializing:!0,initializeMethodId:n});case ct.InitializeFailed:case ct.InitializeSucceeded:return q(e,{isInitializing:!1,initializeMethodId:void 0});case ct.DeinitializeRequested:var o=t.meta&&t.meta.methodId;if(t.meta){var a,s=t.meta;i=s.methodId,o=(a=s.gatewayId)?i+"."+a:i}return q(e,{isDeinitializing:!0,deinitializeMethodId:o});case ct.DeinitializeFailed:case ct.DeinitializeSucceeded:return q(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case ct.ExecuteRequested:return q(e,{isExecuting:!0,executeMethodId:t.meta&&t.meta.methodId});case ct.ExecuteFailed:case ct.ExecuteSucceeded:return q(e,{isExecuting:!1,executeMethodId:void 0});case ct.FinalizeRequested:return q(e,{isFinalizing:!0,finalizeMethodId:t.meta&&t.meta.methodId});case ct.FinalizeFailed:case ct.FinalizeSucceeded:return q(e,{isFinalizing:!1,finalizeMethodId:void 0});case ct.WidgetInteractionStarted:return q(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case ct.WidgetInteractionFinished:case ct.WidgetInteractionFailed:return q(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.UpdatePaymentProviderCustomer="UPDATE_PAYMENT_PROVIDER_CUSTOMER"}(gt||(gt={}));var It,wt={data:{}};function Et(e,t){return void 0===e&&(e=wt),(0,a.combineReducers)({data:bt})(e,t)}function bt(e,t){return void 0===e&&(e=wt.data),t.type===gt.UpdatePaymentProviderCustomer?q(e,t.payload):e}!function(e){e.LoadInstrumentsRequested="LOAD_INSTRUMENTS_REQUESTED",e.LoadInstrumentsSucceeded="LOAD_INSTRUMENTS_SUCCEEDED",e.LoadInstrumentsFailed="LOAD_INSTRUMENTS_FAILED",e.DeleteInstrumentRequested="DELETE_INSTRUMENT_REQUESTED",e.DeleteInstrumentSucceeded="DELETE_INSTRUMENT_SUCCEEDED",e.DeleteInstrumentFailed="DELETE_INSTRUMENT_FAILED"}(It||(It={}));var Pt,At={data:[],errors:{},statuses:{}};function Tt(e,t){return void 0===e&&(e=At),(0,a.combineReducers)({data:Ot,errors:(0,a.composeReducers)(Mt,T),meta:Rt,statuses:kt})(e,t)}function Ot(e,t){return void 0===e&&(e=At.data),t.type===It.LoadInstrumentsSucceeded?U(e,t.payload&&t.payload.vaultedInstruments||[]):e}function Rt(e,t){switch(t.type){case It.LoadInstrumentsSucceeded:case It.DeleteInstrumentSucceeded:return q(e,t.meta);default:return e}}function Mt(e,t){switch(void 0===e&&(e=At.errors),t.type){case It.LoadInstrumentsRequested:case It.LoadInstrumentsSucceeded:return M(e,"loadError",void 0);case It.DeleteInstrumentRequested:case It.DeleteInstrumentSucceeded:return q(e,{deleteError:void 0,failedInstrument:void 0});case It.LoadInstrumentsFailed:return M(e,"loadError",t.payload);case It.DeleteInstrumentFailed:return q(e,{deleteError:t.payload,failedInstrument:t.meta.instrumentId});default:return e}}function kt(e,t){switch(void 0===e&&(e=At.statuses),t.type){case It.LoadInstrumentsRequested:return M(e,"isLoading",!0);case It.DeleteInstrumentRequested:return q(e,{isDeleting:!0,deletingInstrument:t.meta.instrumentId});case It.LoadInstrumentsSucceeded:case It.LoadInstrumentsFailed:return M(e,"isLoading",!1);case It.DeleteInstrumentSucceeded:case It.DeleteInstrumentFailed:return q(e,{isDeleting:!1,deletingInstrument:void 0});default:return e}}!function(e){e.ForgetCheckoutRemoteCustomerRequested="FORGET_CHECKOUT_REMOTE_CUSTOMER_REQUESTED",e.ForgetCheckoutRemoteCustomerSucceeded="FORGET_CHECKOUT_REMOTE_CUSTOMER_SUCCEEDED",e.ForgetCheckoutRemoteCustomerFailed="FORGET_CHECKOUT_REMOTE_CUSTOMER_FAILED",e.InitializeRemoteBillingRequested="INITIALIZE_REMOTE_BILLING_REQUESTED",e.InitializeRemoteBillingSucceeded="INITIALIZE_REMOTE_BILLING_SUCCEEDED",e.InitializeRemoteBillingFailed="INITIALIZE_REMOTE_BILLING_FAILED",e.InitializeRemoteShippingRequested="INITIALIZE_REMOTE_SHIPPING_REQUESTED",e.InitializeRemoteShippingSucceeded="INITIALIZE_REMOTE_SHIPPING_SUCCEEDED",e.InitializeRemoteShippingFailed="INITIALIZE_REMOTE_SHIPPING_FAILED",e.InitializeRemotePaymentRequested="INITIALIZE_REMOTE_PAYMENT_REQUESTED",e.InitializeRemotePaymentSucceeded="INITIALIZE_REMOTE_PAYMENT_SUCCEEDED",e.InitializeRemotePaymentFailed="INITIALIZE_REMOTE_PAYMENT_FAILED",e.LoadRemoteSettingsRequested="LOAD_REMOTE_SETTINGS_REQUESTED",e.LoadRemoteSettingsSucceeded="LOAD_REMOTE_SETTINGS_SUCCEEDED",e.LoadRemoteSettingsFailed="LOAD_REMOTE_SETTINGS_FAILED",e.SignOutRemoteCustomerRequested="SIGN_OUT_REMOTE_CUSTOMER_REQUESTED",e.SignOutRemoteCustomerSucceeded="SIGN_OUT_REMOTE_CUSTOMER_SUCCEEDED",e.SignOutRemoteCustomerFailed="SIGN_OUT_REMOTE_CUSTOMER_FAILED",e.UpdateRemoteCheckout="UPDATE_REMOTE_CHECKOUT"}(Pt||(Pt={}));var Dt={data:{}};function Nt(e,t){var n;return void 0===e&&(e=Dt),t.meta&&t.meta.methodId?(0,a.combineReducers)({data:(0,a.combineReducers)((n={},n[t.meta.methodId]=Lt,n))})(e,t):e}function Lt(e,t){switch(t.type){case Pt.InitializeRemoteBillingSucceeded:return M(e,"billing",t.payload&&t.payload.billing);case Pt.InitializeRemoteShippingSucceeded:return M(e,"shipping",t.payload&&t.payload.shipping);case Pt.LoadRemoteSettingsSucceeded:return M(e,"settings",t.payload);case Pt.UpdateRemoteCheckout:return q(e,t.payload);default:return e}}var zt,Ft={errors:{updateShippingOptionError:{},updateError:{},deleteError:{}},statuses:{isUpdating:{},isUpdatingShippingOption:{},isDeleting:{}}};function Ut(e,t){return void 0===e&&(e=Ft),(0,a.combineReducers)({data:qt,errors:(0,a.composeReducers)(Bt,T),statuses:Gt})(e,t)}function qt(e,t){switch(t.type){case w.LoadCheckoutSucceeded:case x.LoadShippingOptionsSucceeded:case x.CreateConsignmentsSucceeded:case x.UpdateConsignmentSucceeded:case x.DeleteConsignmentSucceeded:case x.UpdateShippingOptionSucceeded:case B.ApplyCouponSucceeded:case B.RemoveCouponSucceeded:return U(e,t.payload&&t.payload.consignments);case me.SignOutCustomerSucceeded:return U(e,[]);default:return e}}function Bt(e,t){var n,r,i,o,a,s;switch(void 0===e&&(e=Ft.errors),t.type){case w.LoadCheckoutRequested:case w.LoadCheckoutSucceeded:case x.LoadShippingOptionsSucceeded:case x.LoadShippingOptionsRequested:return M(e,"loadError",void 0);case w.LoadCheckoutFailed:case x.LoadShippingOptionsFailed:return M(e,"loadError",t.payload);case x.CreateConsignmentsRequested:case x.CreateConsignmentsSucceeded:return M(e,"createError",void 0);case x.CreateConsignmentsFailed:return M(e,"createError",t.payload);case x.UpdateConsignmentSucceeded:case x.UpdateConsignmentRequested:return t.meta?q(e,{updateError:(n={},n[t.meta.id]=void 0,n)}):e;case x.UpdateConsignmentFailed:return t.meta?q(e,{updateError:(r={},r[t.meta.id]=t.payload,r)}):e;case x.DeleteConsignmentSucceeded:case x.DeleteConsignmentRequested:return t.meta?q(e,{deleteError:(i={},i[t.meta.id]=void 0,i)}):e;case x.DeleteConsignmentFailed:return t.meta?q(e,{deleteError:(o={},o[t.meta.id]=t.payload,o)}):e;case x.UpdateShippingOptionRequested:case x.UpdateShippingOptionSucceeded:return t.meta?q(e,{updateShippingOptionError:(a={},a[t.meta.id]=void 0,a)}):e;case x.UpdateShippingOptionFailed:return t.meta?q(e,{updateShippingOptionError:(s={},s[t.meta.id]=t.payload,s)}):e;default:return e}}function Gt(e,t){var n,r,i,o,a,s;switch(void 0===e&&(e=Ft.statuses),t.type){case w.LoadCheckoutRequested:return M(e,"isLoading",!0);case x.LoadShippingOptionsRequested:return M(e,"isLoadingShippingOptions",!0);case w.LoadCheckoutSucceeded:case w.LoadCheckoutFailed:return M(e,"isLoading",!1);case x.LoadShippingOptionsSucceeded:case x.LoadShippingOptionsFailed:return M(e,"isLoadingShippingOptions",!1);case x.CreateConsignmentsRequested:return M(e,"isCreating",!0);case x.CreateConsignmentsSucceeded:case x.CreateConsignmentsFailed:return M(e,"isCreating",!1);case x.UpdateConsignmentRequested:return t.meta?q(e,{isUpdating:(n={},n[t.meta.id]=!0,n)}):e;case x.UpdateConsignmentSucceeded:case x.UpdateConsignmentFailed:return t.meta?q(e,{isUpdating:(r={},r[t.meta.id]=!1,r)}):e;case x.DeleteConsignmentRequested:return t.meta?q(e,{isDeleting:(i={},i[t.meta.id]=!0,i)}):e;case x.DeleteConsignmentSucceeded:case x.DeleteConsignmentFailed:return t.meta?q(e,{isDeleting:(o={},o[t.meta.id]=!1,o)}):e;case x.UpdateShippingOptionRequested:return t.meta?q(e,{isUpdatingShippingOption:(a={},a[t.meta.id]=!0,a)}):e;case x.UpdateShippingOptionSucceeded:case x.UpdateShippingOptionFailed:return t.meta?q(e,{isUpdatingShippingOption:(s={},s[t.meta.id]=!1,s)}):e;default:return e}}function xt(e,t){var n={};return Object.keys(e).forEach((function(r){var i=e[r],o=t?t+"."+r:r;"object"==typeof i?Object.assign(n,xt(i,o)):n[o]=i})),n}function Yt(e){return Object.keys(e).sort().reduce((function(t,n){var r;return(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=e[n],r))}),{})}!function(e){e.LoadPickupOptionsRequested="LOAD_PICKUP_OPTIONS_REQUESTED",e.LoadPickupOptionsSucceeded="LOAD_PICKUP_OPTIONS_SUCCEEDED",e.LoadPickupOptionsFailed="LOAD_PICKUP_OPTIONS_FAILED"}(zt||(zt={}));var Vt,Ht={errors:{},statuses:{}};function jt(e,t){return void 0===e&&(e=Ht),(0,a.combineReducers)({data:Wt,errors:(0,a.composeReducers)(Kt,T),statuses:Jt})(e,t)}function Wt(e,t){if(t.type!==zt.LoadPickupOptionsSucceeded)return e;if(t.meta){var n=Yt(xt({consignmentId:t.meta.consignmentId,searchArea:t.meta.searchArea}));return M(e,btoa(""+JSON.stringify(n)),t.payload)}}function Kt(e,t){switch(void 0===e&&(e=Ht.errors),t.type){case zt.LoadPickupOptionsRequested:case zt.LoadPickupOptionsSucceeded:return M(e,"loadError",void 0);case zt.LoadPickupOptionsFailed:return M(e,"loadError",t.payload);default:return e}}function Jt(e,t){switch(void 0===e&&(e=Ht.statuses),t.type){case zt.LoadPickupOptionsRequested:return M(e,"isLoading",!0);case zt.LoadPickupOptionsSucceeded:case zt.LoadPickupOptionsFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.LoadShippingCountriesRequested="LOAD_SHIPPING_COUNTRIES_REQUESTED",e.LoadShippingCountriesSucceeded="LOAD_SHIPPING_COUNTRIES_SUCCEEDED",e.LoadShippingCountriesFailed="LOAD_SHIPPING_COUNTRIES_FAILED"}(Vt||(Vt={}));var Zt,Qt={errors:{},statuses:{}};function Xt(e,t){return void 0===e&&(e=Qt),(0,a.combineReducers)({data:$t,errors:(0,a.composeReducers)(en,T),statuses:tn})(e,t)}function $t(e,t){return t.type===Vt.LoadShippingCountriesSucceeded?U(e,t.payload):e}function en(e,t){switch(void 0===e&&(e=Qt.errors),t.type){case Vt.LoadShippingCountriesRequested:case Vt.LoadShippingCountriesSucceeded:return M(e,"loadError",void 0);case Vt.LoadShippingCountriesFailed:return M(e,"loadError",t.payload);default:return e}}function tn(e,t){switch(void 0===e&&(e=Qt.statuses),t.type){case Vt.LoadShippingCountriesRequested:return M(e,"isLoading",!0);case Vt.LoadShippingCountriesSucceeded:case Vt.LoadShippingCountriesFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.UpdateAddressFailed="SHIPPING_STRATEGY_UPDATE_ADDRESS_FAILED",e.UpdateAddressRequested="SHIPPING_STRATEGY_UPDATE_ADDRESS_REQUESTED",e.UpdateAddressSucceeded="SHIPPING_STRATEGY_UPDATE_ADDRESS_SUCCEEDED",e.SelectOptionFailed="SHIPPING_STRATEGY_SELECT_OPTION_FAILED",e.SelectOptionRequested="SHIPPING_STRATEGY_SELECT_OPTION_REQUESTED",e.SelectOptionSucceeded="SHIPPING_STRATEGY_SELECT_OPTION_SUCCEEDED",e.InitializeFailed="SHIPPING_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="SHIPPING_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="SHIPPING_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="SHIPPING_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="SHIPPING_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="SHIPPING_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="SHIPPING_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="SHIPPING_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="SHIPPING_STRATEGY_WIDGET_INTERACTION_FAILED"}(Zt||(Zt={}));var nn,rn={data:{},errors:{},statuses:{}};function on(e,t){return void 0===e&&(e=rn),(0,a.combineReducers)({data:an,errors:(0,a.composeReducers)(sn,T),statuses:un})(e,t)}function an(e,t){var n,r;switch(void 0===e&&(e=rn.data),t.type){case Zt.InitializeSucceeded:return q(e,((n={})[t.meta&&t.meta.methodId]={isInitialized:!0},n));case Zt.DeinitializeSucceeded:return q(e,((r={})[t.meta&&t.meta.methodId]={isInitialized:!1},r))}return e}function sn(e,t){switch(void 0===e&&(e=rn.errors),t.type){case Zt.InitializeRequested:case Zt.InitializeSucceeded:return q(e,{initializeError:void 0,initializeMethodId:void 0});case Zt.InitializeFailed:return q(e,{initializeError:t.payload,initializeMethodId:t.meta&&t.meta.methodId});case Zt.DeinitializeRequested:case Zt.DeinitializeSucceeded:return q(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Zt.DeinitializeFailed:return q(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Zt.UpdateAddressRequested:case Zt.UpdateAddressSucceeded:return q(e,{updateAddressError:void 0,updateAddressMethodId:void 0});case Zt.UpdateAddressFailed:return q(e,{updateAddressError:t.payload,updateAddressMethodId:t.meta&&t.meta.methodId});case Zt.SelectOptionRequested:case Zt.SelectOptionSucceeded:return q(e,{selectOptionError:void 0,selectOptionMethodId:void 0});case Zt.SelectOptionFailed:return q(e,{selectOptionError:t.payload,selectOptionMethodId:t.meta&&t.meta.methodId});case Zt.WidgetInteractionStarted:case Zt.WidgetInteractionFinished:return q(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Zt.WidgetInteractionFailed:return q(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta&&t.meta.methodId});default:return e}}function un(e,t){switch(void 0===e&&(e=rn.statuses),t.type){case Zt.InitializeRequested:return q(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Zt.InitializeFailed:case Zt.InitializeSucceeded:return q(e,{isInitializing:!1,initializeMethodId:void 0});case Zt.DeinitializeRequested:return q(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Zt.DeinitializeFailed:case Zt.DeinitializeSucceeded:return q(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Zt.UpdateAddressRequested:return q(e,{isUpdatingAddress:!0,updateAddressMethodId:t.meta&&t.meta.methodId});case Zt.UpdateAddressFailed:case Zt.UpdateAddressSucceeded:return q(e,{isUpdatingAddress:!1,updateAddressMethodId:void 0});case Zt.SelectOptionRequested:return q(e,{isSelectingOption:!0,selectOptionMethodId:t.meta&&t.meta.methodId});case Zt.SelectOptionFailed:case Zt.SelectOptionSucceeded:return q(e,{isSelectingOption:!1,selectOptionMethodId:void 0});case Zt.WidgetInteractionStarted:return q(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta&&t.meta.methodId});case Zt.WidgetInteractionFinished:case Zt.WidgetInteractionFailed:return q(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.SendSignInEmailRequested="SEND_SIGNIN_EMAIL_REQUESTED",e.SendSignInEmailSucceeded="SEND_SIGNIN_EMAIL_SUCCEEDED",e.SendSignInEmailFailed="SEND_SIGNIN_EMAIL_FAILED"}(nn||(nn={}));var cn,dn={errors:{},statuses:{}};function ln(e,t){return void 0===e&&(e=dn),(0,a.combineReducers)({data:pn,errors:(0,a.composeReducers)(hn,T),statuses:fn})(e,t)}function pn(e,t){return t.type===nn.SendSignInEmailSucceeded?q(e,t.payload):e}function hn(e,t){switch(void 0===e&&(e=dn.errors),t.type){case nn.SendSignInEmailRequested:case nn.SendSignInEmailSucceeded:return M(e,"sendError",void 0);case nn.SendSignInEmailFailed:return M(e,"sendError",t.payload);default:return e}}function fn(e,t){switch(void 0===e&&(e=dn.statuses),t.type){case nn.SendSignInEmailRequested:return M(e,"isSending",!0);case nn.SendSignInEmailFailed:case nn.SendSignInEmailSucceeded:return M(e,"isSending",!1);default:return e}}!function(e){e.ApplyStoreCreditRequested="APPLY_STORE_CREDIT_REQUESTED",e.ApplyStoreCreditSucceeded="APPLY_STORE_CREDIT_SUCCEEDED",e.ApplyStoreCreditFailed="APPLY_STORE_CREDIT_FAILED"}(cn||(cn={}));var mn={errors:{},statuses:{}};function gn(e,t){return void 0===e&&(e=mn),(0,a.combineReducers)({errors:(0,a.composeReducers)(yn,T),statuses:_n})(e,t)}function yn(e,t){switch(void 0===e&&(e=mn.errors),t.type){case cn.ApplyStoreCreditRequested:case cn.ApplyStoreCreditSucceeded:return M(e,"applyError",void 0);case cn.ApplyStoreCreditFailed:return M(e,"applyError",t.payload);default:return e}}function _n(e,t){switch(void 0===e&&(e=mn.statuses),t.type){case cn.ApplyStoreCreditRequested:return M(e,"isApplying",!0);case cn.ApplyStoreCreditSucceeded:case cn.ApplyStoreCreditFailed:return M(e,"isApplying",!1);default:return e}}var vn,Cn={errors:{},statuses:{}};function Sn(e,t){return void 0===e&&(e=Cn),(0,a.combineReducers)({errors:(0,a.composeReducers)(In,T),statuses:wn})(e,t)}function In(e,t){switch(void 0===e&&(e=Cn.errors),t.type){case b.UpdateSubscriptionsRequested:case b.UpdateSubscriptionsSucceeded:return M(e,"updateError",void 0);case b.UpdateSubscriptionsFailed:return M(e,"updateError",t.payload);default:return e}}function wn(e,t){switch(void 0===e&&(e=Cn.statuses),t.type){case b.UpdateSubscriptionsRequested:return M(e,"isUpdating",!0);case b.UpdateSubscriptionsFailed:case b.UpdateSubscriptionsSucceeded:return M(e,"isUpdating",!1);default:return e}}!function(e){e.InitializeFailed="SPAM_PROTECTION_INITIALIZE_FAILED",e.InitializeSucceeded="SPAM_PROTECTION_INITIALIZE_SUCCEEDED",e.InitializeRequested="SPAM_PROTECTION_INITIALIZE_REQUESTED",e.VerifyCheckoutRequested="SPAM_PROTECTION_CHECKOUT_VERIFY_REQUESTED",e.VerifyCheckoutSucceeded="SPAM_PROTECTION_CHECKOUT_VERIFY_SUCCEEDED",e.VerifyCheckoutFailed="SPAM_PROTECTION_CHECKOUT_VERIFY_FAILED",e.ExecuteRequested="SPAM_PROTECTION_EXECUTE_REQUESTED",e.ExecuteSucceeded="SPAM_PROTECTION_EXECUTE_SUCCEEDED",e.ExecuteFailed="SPAM_PROTECTION_EXECUTE_FAILED"}(vn||(vn={}));var En={errors:{},statuses:{}};function bn(e,t){return void 0===e&&(e=En),(0,a.combineReducers)({data:Pn,errors:(0,a.composeReducers)(An,T),statuses:Tn})(e,t)}function Pn(e,t){switch(t.type){case w.LoadCheckoutSucceeded:case w.UpdateCheckoutSucceeded:case cn.ApplyStoreCreditSucceeded:case P.UpdateBillingAddressSucceeded:case B.ApplyCouponSucceeded:case B.RemoveCouponSucceeded:case x.CreateConsignmentsSucceeded:case x.UpdateConsignmentSucceeded:case x.DeleteConsignmentSucceeded:case x.UpdateShippingOptionSucceeded:case x.LoadShippingOptionsSucceeded:case G.ApplyGiftCertificateSucceeded:case G.RemoveGiftCertificateSucceeded:case vn.VerifyCheckoutSucceeded:return q(e,(0,m.omit)(t.payload,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));case ie.SubmitOrderSucceeded:return M(e,"orderId",t.payload&&t.payload.order.orderId);default:return e}}function An(e,t){switch(void 0===e&&(e=En.errors),t.type){case w.LoadCheckoutRequested:case w.LoadCheckoutSucceeded:return M(e,"loadError",void 0);case w.LoadCheckoutFailed:return M(e,"loadError",t.payload);case w.UpdateCheckoutRequested:case w.UpdateCheckoutSucceeded:return M(e,"updateError",void 0);case w.UpdateCheckoutFailed:return M(e,"updateError",t.payload);default:return e}}function Tn(e,t){switch(void 0===e&&(e=En.statuses),t.type){case w.LoadCheckoutRequested:return M(e,"isLoading",!0);case w.LoadCheckoutFailed:case w.LoadCheckoutSucceeded:return M(e,"isLoading",!1);case w.UpdateCheckoutRequested:return M(e,"isUpdating",!0);case w.UpdateCheckoutFailed:case w.UpdateCheckoutSucceeded:return M(e,"isUpdating",!1);case vn.ExecuteRequested:return M(e,"isExecutingSpamCheck",!0);case vn.ExecuteFailed:case vn.ExecuteSucceeded:return M(e,"isExecutingSpamCheck",!1);default:return e}}const On=require("@bigcommerce/memoize");var Rn;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentProviderCustomer=13]="MissingPaymentProviderCustomer",e[e.MissingPaymentRedirectUrl=14]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=15]="MissingPaymentStatus",e[e.MissingPaymentToken=16]="MissingPaymentToken",e[e.MissingShippingAddress=17]="MissingShippingAddress"}(Rn||(Rn={}));const Mn=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Rn.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case Rn.MissingCart:return"Unable to proceed because cart data is unavailable.";case Rn.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case Rn.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case Rn.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case Rn.MissingCheckoutConfig:case Rn.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case Rn.MissingOrder:return"Unable to proceed because order data is unavailable.";case Rn.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case Rn.MissingPayment:return"Unable to proceed because payment data is unavailable.";case Rn.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case Rn.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case Rn.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case Rn.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(t))||this;return n.subtype=t,n.name="MissingDataError",n.type="missing_data",n}return(0,o.__extends)(t,e),t}(l),kn=require("reselect"),Dn=(Nn=kn.createSelector,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.pop();return Nn.apply(void 0,(0,o.__spreadArrays)(e,[function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n.apply(void 0,e);return"function"==typeof r?(0,On.memoize)(r):r}]))});var Nn;function Ln(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function zn(e){return function(e,t){var n=Object.create(e);return function(e,t){for(var n=Object.getPrototypeOf(e);n;)t(n),n=Object.getPrototypeOf(n)}(e,(function(t){Object.getOwnPropertyNames(t).forEach((function(t){"constructor"!==t&&"function"==typeof n[t]&&"_"!==t.charAt(0)&&(n[t]=function(e,t){return function(){for(var n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return(0,a.deepFreeze)((n=e[t]).call.apply(n,(0,o.__spreadArrays)([e],r)))}}(e,t))}))})),n}(e)}var Fn="PAYMENT_TYPE_HOSTED",Un="ACKNOWLEDGE",qn="FINALIZE";const Bn={"mollie.credit_card":{provider:"mollie",method:"credit_card"},"adyenv2.scheme":{provider:"adyenv2",method:"scheme"},"adyenv3.scheme":{provider:"adyenv3",method:"scheme"},"adyenv2.bcmc":{provider:"adyenv2",method:"bcmc"},"adyenv2.ideal":{provider:"adyenv2",method:"ideal"},"adyenv2.sepadirectdebit":{provider:"adyenv2",method:"sepadirectdebit"},"adyenv2.directEbanking":{provider:"adyenv2",method:"directEbanking"},"adyenv2.giropay":{provider:"adyenv2",method:"giropay"},barclays:{provider:"barclays",method:"credit_card"},braintree:{provider:"braintree",method:"credit_card"},braintreepaypal:{provider:"braintree",method:"paypal"},braintreeach:{provider:"braintree",method:"ach"},authorizenet:{provider:"authorizenet",method:"credit_card"},elavon:{provider:"elavon",method:"credit_card"},checkoutcom:{provider:"checkoutcom",method:"credit_card"},"checkoutcom.credit_card":{provider:"checkoutcom",method:"credit_card"},"checkoutcom.card":{provider:"checkoutcom",method:"card"},sagepay:{provider:"sagepay",method:"credit_card"},stripe:{provider:"stripe",method:"credit_card"},"stripev3.card":{provider:"stripev3",method:"card"},"stripeupe.card":{provider:"stripeupe",method:"card"},cybersource:{provider:"cybersource",method:"credit_card"},cybersourcev2:{provider:"cybersourcev2",method:"credit_card"},bnz:{provider:"bnz",method:"credit_card"},converge:{provider:"converge",method:"credit_card"},bluesnapv2:{provider:"bluesnapv2",method:"credit_card"},"bluesnapdirect.credit_card":{provider:"bluesnapdirect",method:"credit_card"},"bluesnapdirect.ecp":{provider:"bluesnapdirect",method:"ecp"},"bluesnapdirect.sepa_direct_debit":{provider:"bluesnapdirect",method:"sepa_direct_debit"},orbital:{provider:"orbital",method:"credit_card"},paymetric:{provider:"paymetric",method:"credit_card"},bolt:{provider:"bolt",method:"credit_card"},"barclaycard.credit_card":{provider:"barclaycard",method:"credit_card"},digitalriver:{provider:"digitalriver",method:"credit_card"},moneris:{provider:"moneris",method:"credit_card"},cba_mpgs:{provider:"cba_mpgs",method:"credit_card"},worldpayaccess:{provider:"worldpayaccess",method:"credit_card"},squarev2:{provider:"squarev2",method:"credit_card"},paypalcommercecreditcards:{provider:"paypalcommerce",method:"credit_card"},paypalcommerce:{provider:"paypalcommerce",method:"paypal"},tdonlinemart:{provider:"tdonlinemart",method:"credit_card"}};function Gn(e){return(0,m.pickBy)({firstName:e.firstName,lastName:e.lastName,company:e.company,address1:e.address1,address2:e.address2,city:e.city,stateOrProvince:e.stateOrProvince,countryCode:e.countryCode,postalCode:e.postalCode,phone:e.phone,customFields:e.customFields},m.identity)}var xn={errors:{},statuses:{}};function Yn(){var e,t,n,r,i,a,s,u,c,d,l,p,h,f,g,y,_,v,C,S,I,w,E,b,P,A,T,O,R,M,D,N,L,z,F,U,q,B,G,x,Y,H,j,W,K,J,Q,X,$,ee=(e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingBillingAddress)}))}})),n=Dn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),r=Dn((function(e){return e.errors.continueAsGuestError}),(function(e){return function(){return e}})),i=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=Dn((function(e){return!!e.statuses.isUpdating}),(function(e){return function(){return e}})),s=Dn((function(e){return!!e.statuses.isContinuingAsGuest}),(function(e){return function(){return e}})),u=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(o){return void 0===o&&(o=k),{getBillingAddress:e(o),getBillingAddressOrThrow:t(o),getUpdateError:n(o),getContinueAsGuestError:r(o),getLoadError:i(o),isUpdating:a(o),isContinuingAsGuest:s(o),isLoading:u(o)}}))),te=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingCart)}))}})),n=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),r=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(i){return void 0===i&&(i=V),{getCart:e(i),getCartOrThrow:t(i),getLoadError:n(i),isLoading:r(i)}}))}(),ne=(c=Dn((function(e){return e}),(function(e){return function(){return e}})),d=Dn((function(e){return e.statuses}),(function(e){return(0,On.memoize)((function(t){if(t){var n=e[t];return!0===(n&&n.isInitializing)}return(0,m.some)(e,{isInitializing:!0})}))})),l=Dn((function(e){return e.data}),(function(e){return(0,On.memoize)((function(t,n){var r=e[t];return!!r&&(n?!0===r.initializedContainers[n]:(0,m.some)(r.initializedContainers,(function(e){return!0===e})))}))})),p=Dn((function(e){return e.statuses}),(function(e){return(0,On.memoize)((function(t){if(t){var n=e[t];return!0===(n&&n.isDeinitializing)}return(0,m.some)(e,{isDeinitializing:!0})}))})),h=Dn((function(e){return e.errors}),(function(e){return(0,On.memoize)((function(t){var n=t?e[t]:(0,m.find)((0,m.values)(e),(function(e){return!(!e||!e.initializeError)}));return n&&n.initializeError}))})),f=Dn((function(e){return e.errors}),(function(e){return(0,On.memoize)((function(t){var n=t?e[t]:(0,m.find)((0,m.values)(e),(function(e){return!(!e||!e.deinitializeError)}));return n&&n.deinitializeError}))})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=Z),{getState:c(e),isInitializing:d(e),isInitialized:l(e),isDeinitializing:p(e),getInitializeError:h(e),getDeinitializeError:f(e)}}))),re=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.data}),(function(e){return function(t){if(e){var n=e.context.flashMessages;if(n)return void 0!==t?n.filter((function(e){var n=e.type;return t===n})):n}}})),n=Dn((function(e){return e.data}),(function(e,t){var n=t.formState;return n&&n.data}),(function(e,t){return function(){return e&&t?(0,o.__assign)((0,o.__assign)({},e.storeConfig),{formFields:t}):void 0}})),r=Dn(n,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingCheckoutConfig)}))}})),i=Dn((function(e){return e.data&&e.data.context}),(function(e){return function(){return e}})),a=Dn((function(e){return e.meta&&e.meta.externalSource}),(function(e){return function(){return e}})),s=Dn((function(e){var t;return null===(t=e.meta)||void 0===t?void 0:t.host}),(function(e){return function(){return e}})),u=Dn((function(e){var t;return null===(t=e.meta)||void 0===t?void 0:t.locale}),(function(e){return function(){return e}})),c=Dn((function(e){return e.meta&&e.meta.variantIdentificationToken}),(function(e){return function(){return e}})),d=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),l=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(o,p){return void 0===o&&(o=oe),{getConfig:e(o),getFlashMessages:t(o),getStoreConfig:n(o,{formState:p}),getStoreConfigOrThrow:r(o,{formState:p}),getContextConfig:i(o),getExternalSource:a(o),getHost:s(o),getLocale:u(o),getVariantIdentificationToken:c(o),getLoadError:d(o),isLoading:l(o)}}))}(),ie=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(r){return void 0===r&&(r=He),{getCountries:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),ae=(g=Dn((function(e){return e.data}),(function(e){return function(){return e}})),y=Dn((function(e){return e.errors.removeCouponError}),(function(e){return function(){return e}})),_=Dn((function(e){return e.errors.applyCouponError}),(function(e){return function(){return e}})),v=Dn((function(e){return!!e.statuses.isApplyingCoupon}),(function(e){return function(){return e}})),C=Dn((function(e){return!!e.statuses.isRemovingCoupon}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=de),{getCoupons:g(e),getRemoveError:y(e),getApplyError:_(e),isApplying:v(e),isRemoving:C(e)}}))),se=(S=Dn((function(e){return e.data}),(function(e){return function(){return e}})),I=Dn(S,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingCustomer)}))}})),w=Dn((function(e){return e.errors.createError}),(function(e){return function(){return e}})),E=Dn((function(e){return!!e.statuses.isCreating}),(function(e){return function(){return e}})),b=Dn((function(e){return e.errors.createAddressError}),(function(e){return function(){return e}})),P=Dn((function(e){return!!e.statuses.isCreatingAddress}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=Ie),{getCustomer:S(e),getCustomerOrThrow:I(e),getCreateAccountError:w(e),isCreatingCustomerAccount:E(e),getCreateAddressError:b(e),isCreatingCustomerAddress:P(e)}}))),ue=function(){var e=Dn((function(e){return e.errors.signInMethodId}),(function(e){return e.errors.signInError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=Dn((function(e){return e.errors.signOutMethodId}),(function(e){return e.errors.signOutError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=Dn((function(e){return e.errors.executePaymentMethodCheckoutMethodId}),(function(e){return e.errors.executePaymentMethodCheckoutError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=Dn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeErrors}),(function(e,t){return function(n){if(e&&t)return n?t[n]:t[e]}})),i=Dn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),o=Dn((function(e){return e.statuses.signInMethodId}),(function(e){return e.statuses.isSigningIn}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),a=Dn((function(e){return e.statuses.signOutMethodId}),(function(e){return e.statuses.isSigningOut}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=Dn((function(e){return e.statuses.executePaymentMethodCheckoutMethodId}),(function(e){return e.statuses.isExecutingPaymentMethodCheckout}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),u=Dn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),c=Dn((function(e){return e.data}),(function(e){return function(t){return!(!e[t]||!e[t].isInitialized)}})),d=Dn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(l){return void 0===l&&(l=Te),{getSignInError:e(l),getSignOutError:t(l),getExecutePaymentMethodCheckoutError:n(l),getInitializeError:r(l),getWidgetInteractionError:i(l),isSigningIn:o(l),isSigningOut:a(l),isExecutingPaymentMethodCheckout:s(l),isInitializing:u(l),isInitialized:c(l),isWidgetInteracting:d(l)}}))}(),ce=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.errors.removeGiftCertificateError}),(function(e){return function(){return e}})),n=Dn((function(e){return e.errors.applyGiftCertificateError}),(function(e){return function(){return e}})),r=Dn((function(e){return!!e.statuses.isApplyingGiftCertificate}),(function(e){return function(){return e}})),i=Dn((function(e){return!!e.statuses.isRemovingGiftCertificate}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(o){return void 0===o&&(o=ge),{getGiftCertificates:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:r(o),isRemoving:i(o)}}))}(),le=function(){var e=Dn((function(e){return e.data}),(function(e){return function(t){if(e){var n=t.gateway?t.gateway+"."+t.id:t.id,r=Bn[n];return r?(0,m.filter)(e,r):[]}}})),t=Dn((function(e){return e.data}),(function(e){return void 0===e&&(e=[]),function(t){var n=(0,m.values)(Bn);return e.find((function(e){return e.bigpayToken===t&&"card"===e.type&&n.some((function(t){return(0,m.isMatch)(e,t)}))}))}})),n=Dn(t,(function(e){return function(t){return Ln(e(t),(function(){return new Mn(Rn.MissingPaymentInstrument)}))}})),r=Dn((function(e){return e.data}),(function(e){return function(){if(e)return(0,m.flatMap)(Bn,(function(t){return(0,m.filter)(e,(function(e){return(0,m.isMatch)(e,t)}))}))}})),i=Dn((function(e){return e.meta}),(function(e){return function(){return e}})),o=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=Dn((function(e){return e.errors.failedInstrument}),(function(e){return e.errors.deleteError}),(function(e,t){return function(n){if(!n||e===n)return t}})),s=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}})),u=Dn((function(e){return e.statuses.deletingInstrument}),(function(e){return e.statuses.isDeleting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(c){return void 0===c&&(c=At),{getCardInstrument:t(c),getCardInstrumentOrThrow:n(c),getInstruments:r(c),getInstrumentsByPaymentMethod:e(c),getInstrumentsMeta:i(c),getLoadError:o(c),getDeleteError:a(c),isLoading:s(c),isDeleting:u(c)}}))}(),pe=function(){var e=Dn((function(e){return e.data}),(function(e){return function(t,n){void 0===t&&(t=[]);var r=(0,m.find)(t,{code:n});return(e?e.shippingAddress:[]).map((function(e){return a(e,t,r)}))}})),t=Dn((function(e){return e.data}),(function(e){return function(t,n){void 0===t&&(t=[]);var r=(0,m.find)(t,{code:n});return(e?e.billingAddress:[]).map((function(e){return a(e,t,r)}))}})),n=Dn((function(e){return e.data}),(function(e){return function(){return e?e.customerAccount:[]}})),r=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));function a(e,t,n){return"countryCode"===e.name?function(e,t,n){if(void 0===t&&(t=[]),!t.length)return e;var r=(n||{}).code,i=void 0===r?"":r,a=t.map((function(e){return{value:e.code,label:e.name}}));return(0,o.__assign)((0,o.__assign)({},e),{options:{items:a},default:i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,t,n):"stateOrProvince"===e.name?function(e,t){var n=t||{},r=n.subdivisions,i=void 0===r?[]:r,a=n.requiresState;if(!i.length)return(0,o.__assign)((0,o.__assign)({},e),{required:null!=a&&a});var s=i.map((function(e){return{value:e.code,label:e.name}}));return(0,o.__assign)((0,o.__assign)({},e),{name:"stateOrProvinceCode",options:{items:s},required:null==a||a,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,n):"postalCode"===e.name?function(e,t){var n=(t||{}).hasPostalCodes,r=void 0===n?[]:n;return void 0===r?e:(0,o.__assign)((0,o.__assign)({},e),{required:Boolean(r)})}(e,n):e}return(0,On.memoizeOne)((function(o){return void 0===o&&(o=Be),{getShippingAddressFields:e(o),getBillingAddressFields:t(o),getCustomerAccountFields:n(o),getLoadError:r(o),isLoading:i(o)}}))}(),he=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.meta}),(function(e){return function(){return e}})),n=Dn((function(e){return e.data}),(function(e){return function(t,n){return n?(0,m.find)(e,{id:t,gateway:n}):(0,m.find)(e,{id:t})}})),r=Dn(n,(function(e){return function(t,n){return Ln(e(t,n),(function(){return new Mn(Rn.MissingPaymentMethod)}))}})),i=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),o=Dn((function(e){return e.errors.loadMethodId}),(function(e){return e.errors.loadMethodError}),(function(e,t){return function(n){if(!n||e===n)return t}})),a=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}})),s=Dn((function(e){return e.statuses.loadMethodId}),(function(e){return e.statuses.isLoadingMethod}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(u){return void 0===u&&(u=dt),{getPaymentMethods:e(u),getPaymentMethodsMeta:t(u),getPaymentMethod:n(u),getPaymentMethodOrThrow:r(u),getLoadError:i(u),getLoadMethodError:o(u),isLoading:a(u),isLoadingMethod:s(u)}}))}(),fe=function(){var e=Dn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=Dn((function(e){return e.errors.executeMethodId}),(function(e){return e.errors.executeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=Dn((function(e){return e.errors.finalizeMethodId}),(function(e){return e.errors.finalizeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=Dn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),i=Dn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),o=Dn((function(e){return e.data}),(function(e){return function(t){var n=t.gatewayId?t.methodId+"."+t.gatewayId:t.methodId;return!(!e[n]||!e[n].isInitialized)}})),a=Dn((function(e){return e.statuses.executeMethodId}),(function(e){return e.statuses.isExecuting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=Dn((function(e){return e.statuses.finalizeMethodId}),(function(e){return e.statuses.isFinalizing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),u=Dn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(c){return void 0===c&&(c=yt),{getInitializeError:e(c),getExecuteError:t(c),getFinalizeError:n(c),getWidgetInteractingError:r(c),isInitializing:i(c),isInitialized:o(c),isExecuting:a(c),isFinalizing:s(c),isWidgetInteracting:u(c)}}))}(),me=function(){var e=Dn((function(e){return e.data}),(function(e){return function(t,n){if(e){var r=Yt(xt({consignmentId:t,searchArea:n})),i=btoa(""+JSON.stringify(r));return e[i]}}})),t=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(r){return void 0===r&&(r=Ht),{getPickupOptions:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),ye=(A=Dn((function(e){return e.data}),(function(e){return function(){return e}})),T=Dn(A,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentProviderCustomer)}))}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=wt),{getPaymentProviderCustomer:A(e),getPaymentProviderCustomerOrThrow:T(e)}}))),_e=(O=Dn((function(e){return e.data}),(function(e){return function(t){return e[t]}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=Dt),{getCheckout:O(e)}}))),ve=(R=Dn((function(e){return e.data}),(function(e){return function(){var t=null==e?void 0:e.find((function(e){return!e.selectedPickupOption}));return null==t?void 0:t.shippingAddress}})),M=Dn(R,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingShippingAddress)}))}})),D=Dn((function(e){return e.data}),(function(e){return function(){var t=null==e?void 0:e.filter((function(e){return!e.selectedPickupOption}));return t?t.map((function(e){return e.shippingAddress})):[]}})),N=Dn(D,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingShippingAddress)}))}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=Ft),{getShippingAddress:R(e),getShippingAddressOrThrow:M(e),getShippingAddresses:D(e),getShippingAddressesOrThrow:N(e)}}))),Ce=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}}));return(0,On.memoizeOne)((function(r){return void 0===r&&(r=Qt),{getShippingCountries:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),Se=function(){var e=Dn((function(e){return e.errors.updateAddressMethodId}),(function(e){return e.errors.updateAddressError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=Dn((function(e){return e.errors.selectOptionMethodId}),(function(e){return e.errors.selectOptionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=Dn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=Dn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),i=Dn((function(e){return e.statuses.updateAddressMethodId}),(function(e){return e.statuses.isUpdatingAddress}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),o=Dn((function(e){return e.statuses.selectOptionMethodId}),(function(e){return e.statuses.isSelectingOption}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),a=Dn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=Dn((function(e){return e.data}),(function(e){return function(t){return!(!e[t]||!e[t].isInitialized)}})),u=Dn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(c){return void 0===c&&(c=rn),{getUpdateAddressError:e(c),getSelectOptionError:t(c),getInitializeError:n(c),getWidgetInteractionError:r(c),isUpdatingAddress:i(c),isSelectingOption:o(c),isInitializing:a(c),isInitialized:s(c),isWidgetInteracting:u(c)}}))}(),we=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingConsignments)}))}})),n=Dn((function(e){return e.data}),(function(e){return function(t){if(e&&e.length)return(0,m.find)(e,{id:t})}})),r=Dn((function(e){return e.data}),(function(e){return function(t){if(e&&e.length)return(0,m.find)(e,(function(e){return n=e.shippingAddress,r=t,(0,m.isEqual)(Gn(n),Gn(r));var n,r}))}})),i=Dn((function(e){return e.data}),(function(e){return function(){if(e&&e.length)return e[0].selectedShippingOption}})),o=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=Dn((function(e){return e.errors.createError}),(function(e){return function(){return e}})),s=Dn((function(e){return e.errors.loadShippingOptionsError}),(function(e){return function(){return e}})),u=Dn(e,(function(e,t){return t.cart.getCart}),(function(e,t){return function(){var n=t();if(!n)return[];var r=(e()||[]).reduce((function(e,t){return e.concat(t.lineItemIds)}),[]);return(n.lineItems.physicalItems||[]).filter((function(e){return r.indexOf(e.id)<0}))}})),c=Dn((function(e){return e.errors.updateError}),(function(e){return function(t){return t?e[t]:(0,m.find)(e)}})),d=Dn((function(e){return e.errors.deleteError}),(function(e){return function(t){return t?e[t]:(0,m.find)(e)}})),l=Dn(r,c,a,(function(e,t,n){return function(r){var i=e(r);return i?t(i.id):n()}})),p=Dn((function(e){return e.errors.updateShippingOptionError}),(function(e){return function(t){return t?e[t]:(0,m.find)(e)}})),h=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!0===e}})),f=Dn((function(e){return e.statuses.isLoadingShippingOptions}),(function(e){return function(){return!0===e}})),g=Dn((function(e){return e.statuses.isCreating}),(function(e){return function(){return!0===e}})),y=Dn((function(e){return e.statuses.isUpdating}),(function(e){return function(t){return t?!0===e[t]:!0===(0,m.find)(e)}})),_=Dn((function(e){return e.statuses.isDeleting}),(function(e){return function(t){return t?!0===e[t]:!0===(0,m.find)(e)}})),v=Dn(r,y,g,(function(e,t,n){return function(r){var i=e(r);return i?t(i.id):n()}})),C=Dn((function(e){return e.statuses.isUpdatingShippingOption}),(function(e){return function(t){return t?!0===e[t]:!0===(0,m.find)(e)}}));return(0,On.memoizeOne)((function(m,S){return void 0===m&&(m=Ft),{getConsignments:e(m),getConsignmentsOrThrow:t(m),getConsignmentById:n(m),getConsignmentByAddress:r(m),getShippingOption:i(m),getLoadError:o(m),getCreateError:a(m),getLoadShippingOptionsError:s(m),getUnassignedItems:u(m,{cart:S}),getUpdateError:c(m),getDeleteError:d(m),getItemAssignmentError:l(m),getUpdateShippingOptionError:p(m),isLoading:h(m),isLoadingShippingOptions:f(m),isCreating:g(m),isUpdating:y(m),isDeleting:_(m),isAssigningItems:v(m),isUpdatingShippingOption:C(m)}}))}(),Ee=function(){var e=Dn((function(e){return e.data}),(function(e,t){return t.billingAddress.getBillingAddress}),(function(e,t){return t.cart.getCart}),(function(e,t){return t.customer.getCustomer}),(function(e,t){return t.consignments.getConsignments}),(function(e,t){return t.coupons.getCoupons}),(function(e,t){return t.giftCertificates.getGiftCertificates}),(function(e,t,n,r,i,a,s){return function(){var u=t(),c=n(),d=r(),l=i()||[],p=a()||[],h=s()||[];if(e&&c&&d)return(0,o.__assign)((0,o.__assign)({},e),{billingAddress:u,cart:c,customer:d,consignments:l,coupons:p,giftCertificates:h})}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingCheckout)}))}})),n=Dn(e,(function(e){return function(t){var n=e();if(n){var r=n.grandTotal||0,i=n.customer.storeCredit||0;return t?Math.max(r-i,0):n.outstandingBalance}}})),r=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=Dn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),a=Dn((function(e){return e.statuses.isExecutingSpamCheck}),(function(e){return function(){return!0===e}})),s=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!0===e}})),u=Dn((function(e){return e.statuses.isUpdating}),(function(e){return function(){return!0===e}}));return(0,On.memoizeOne)((function(o,c,d,l,p,h,f){return void 0===o&&(o=En),{getCheckout:e(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getCheckoutOrThrow:t(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getOutstandingBalance:n(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getLoadError:r(o),getUpdateError:i(o),isExecutingSpamCheck:a(o),isLoading:s(o),isUpdating:u(o)}}))}(),be=function(){var e=Dn((function(e){return e.data}),(function(e,t){return t.billingAddress.getOrderBillingAddress()}),(function(e,t){return t.coupons.getCoupons()}),(function(e,t,n){return void 0===n&&(n=[]),function(){if(e&&t)return(0,o.__assign)((0,o.__assign)({},e),{billingAddress:t,coupons:n})}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingOrder)}))}})),n=Dn((function(e){return e.meta}),(function(e){return function(){return e}})),r=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=Dn((function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.payments}),(function(e){return void 0===e&&(e=[]),function(t){var n=e.find((function(e){return e.providerId===t}));return null==n?void 0:n.paymentId}})),a=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(o,s,u){return void 0===o&&(o=Ze),{getOrder:e(o,{billingAddress:s,coupons:u}),getOrderOrThrow:t(o,{billingAddress:s,coupons:u}),getOrderMeta:n(o),getLoadError:r(o),getPaymentId:i(o),isLoading:a(o)}}))}(),Pe=(L=Dn((function(e){return e.data}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=it),{getOrderBillingAddress:L(e)}}))),Ae=(z=Dn((function(e){return e.order.getOrderMeta}),(function(e){return function(){var t=e();return t&&t.payment}})),F=Dn((function(e){return e.order.getOrder}),(function(e){return function(){var t=e();return(0,m.find)(t&&t.payments,(function(e){var t=e.providerId;return"giftcertificate"!==t&&"storecredit"!==t}))}})),U=Dn((function(e){return e.checkout.getCheckout}),(function(e){return function(){var t=e();return(0,m.find)(t&&t.payments,(function(e){return e.providerType===Fn}))}})),q=Dn(z,U,F,(function(e,t,n){return function(){var r=e();if(r&&r.id)return{providerId:r.id,gatewayId:r.gateway};var i=t()||n();return i&&i.providerId?{providerId:i.providerId,gatewayId:i.gatewayId}:void 0}})),B=Dn(q,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentId)}))}})),G=Dn(z,U,F,(function(e,t,n){return function(){var r=e();if(r&&r.status)return r.status.replace("PAYMENT_STATUS_","");var i=t()||n();return i?i.detail.step:void 0}})),x=Dn(G,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentStatus)}))}})),Y=Dn((function(e){return e.order.getOrderMeta}),(function(e){return function(){var t=e();return t&&t.token}})),H=Dn(Y,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentToken)}))}})),j=Dn(z,(function(e){return function(){var t=e();return t&&t.redirectUrl}})),W=Dn(j,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentRedirectUrl)}))}})),K=Dn((function(e){return e.checkout.getOutstandingBalance}),(function(e){return function(t){void 0===t&&(t=!1);var n=e(t);return!!n&&n>0}})),J=Dn(G,(function(e){return function(t){return!(!t||!t.nonce)||e()===Un||e()===qn}})),(0,On.memoizeOne)((function(e,t){return{getPaymentId:q({checkout:e,order:t}),getPaymentIdOrThrow:B({checkout:e,order:t}),getPaymentStatus:G({checkout:e,order:t}),getPaymentStatusOrThrow:x({checkout:e,order:t}),getPaymentToken:Y({checkout:e,order:t}),getPaymentTokenOrThrow:H({checkout:e,order:t}),getPaymentRedirectUrl:j({checkout:e,order:t}),getPaymentRedirectUrlOrThrow:W({checkout:e,order:t}),isPaymentDataRequired:K({checkout:e,order:t}),isPaymentDataSubmitted:J({checkout:e,order:t})}}))),Oe=function(){var e=Dn((function(e){return e.errors.applyError}),(function(e){return function(){return e}})),t=Dn((function(e){return!!e.statuses.isApplying}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(n){return void 0===n&&(n=xn),{getApplyError:e(n),isApplying:t(n)}}))}(),Re=function(){var e=Dn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),t=Dn((function(e){return!!e.statuses.isUpdating}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(n){return void 0===n&&(n=Cn),{getUpdateError:e(n),isUpdating:t(n)}}))}(),Me=(Q=Dn((function(e){return e.data}),(function(e){return function(){return e}})),X=Dn((function(e){return e.errors.sendError}),(function(e){return function(){return e}})),$=Dn((function(e){return!!e.statuses.isSending}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=dn),{getEmail:Q(e),getSendError:X(e),isSending:$(e)}}))),ke=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.data}),(function(e){return function(t){return null==e?void 0:e.find((function(e){return e.region===t}))}})),n=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),r=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}}));return(0,On.memoizeOne)((function(i){return void 0===i&&(i=Ne),{getExtensions:e(i),getExtensionByRegion:t(i),getLoadError:n(i),isLoading:r(i)}}))}();return function(e,t){void 0===t&&(t={});var n,r=ee(e.billingAddress),i=te(e.cart),o=ne(e.checkoutButton),a=ie(e.countries),s=ae(e.coupons),u=se(e.customer),c=ue(e.customerStrategies),d=ke(e.extensions),l=pe(e.formFields),p=ce(e.giftCertificates),h=le(e.instruments),f=Pe(e.orderBillingAddress),m=he(e.paymentMethods),g=ye(e.paymentProviderCustomer),y=fe(e.paymentStrategies),_=me(e.pickupOptions),v=_e(e.remoteCheckout),C=ve(e.consignments),S=Ce(e.shippingCountries),I=Se(e.shippingStrategies),w=Re(e.subscriptions),E=Oe(e.storeCredit),b=Me(e.signInEmail),P=we(e.consignments,i),A=Ee(e.checkout,r,i,P,s,u,p),T=be(e.order,f,s),O=Ae(A,T),R={billingAddress:r,cart:i,checkout:A,checkoutButton:o,config:re(e.config,e.formFields),consignments:P,countries:a,coupons:s,customer:u,customerStrategies:c,extensions:d,form:l,giftCertificates:p,instruments:h,order:T,orderBillingAddress:f,payment:O,paymentMethods:m,paymentProviderCustomer:g,paymentStrategies:y,pickupOptions:_,remoteCheckout:v,shippingAddress:C,shippingCountries:S,shippingStrategies:I,signInEmail:b,subscriptions:w,storeCredit:E};return t.shouldWarnMutation?(n=R,Object.keys(n).reduce((function(e,t){return e[t]=zn(n[t]),e}),{})):R}}function Vn(e,t){void 0===e&&(e={});var n,r,i=(n=new C,["catalog_only","empty_cart","invalid_order_id","invalid_order_token","missing_order_token","missing_provider_token","missing_shipping_method","order_completion_error","order_could_not_be_finalized_error","order_create_failed","provider_fatal_error","provider_setup_error","stock_too_low"].forEach((function(e){n.register(e,(function(e,t){return new f(e,t)}))})),n.register("invalid_payment_provider",(function(e){return new d(e)})),n.register("payment_config_not_found",(function(e){return new d(e)})),r=n,function(e){return(0,S.from)(e).pipe((0,I.catchError)((function(e){if(e instanceof Error||e.payload instanceof Error)throw e;if((n=e.payload)&&"object"==typeof n&&["body","headers","status","statusText"].every((function(e){return Object.prototype.hasOwnProperty.call(n,e)}))){var t=e.payload.body&&e.payload.body.detail;throw(0,o.__assign)((0,o.__assign)({},e),{payload:r.createError(e.payload,t)})}var n;throw e})))}),s=Yn();return(0,a.createDataStore)((0,a.combineReducers)({billingAddress:D,cart:H,checkout:bn,checkoutButton:ee,config:ae,consignments:Ut,countries:je,coupons:le,customer:we,customerStrategies:Oe,extensions:Le,formFields:Ge,giftCertificates:ye,instruments:Tt,orderBillingAddress:ot,order:Qe,payment:st,paymentMethods:lt,paymentStrategies:_t,pickupOptions:jt,paymentProviderCustomer:Et,remoteCheckout:Nt,shippingCountries:Xt,shippingStrategies:on,signInEmail:ln,subscriptions:Sn,storeCredit:gn}),e,(0,o.__assign)({actionTransformer:i,stateTransformer:function(e){return s(e)}},t))}function Hn(e,t,n){var r=new WeakMap;function i(e){var n=this;return function(){for(var i,a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var u,c=a[a.length-1];if(!(u=c,u&&"boolean"==typeof u.useCache?c:{useCache:!1}).useCache)return e.call.apply(e,(0,o.__spreadArrays)([n],a));var d,l=r.get(n)||{};return r.get(n)||r.set(n,l),l[t]||(l[t]=(d=e,(0,On.memoize)((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=d.call.apply(d,(0,o.__spreadArrays)([this],e));return n instanceof S.Observable?(0,S.from)(n).pipe((0,I.shareReplay)()):"function"==typeof n?(0,On.memoize)((function(e){return(0,S.from)(n(e)).pipe((0,I.shareReplay)())})):n})))),(i=l[t]).call.apply(i,(0,o.__spreadArrays)([n],a))}}return{get:function(){if("function"!=typeof n.value)throw new Error("Decorator should be used in functions");var e=i.call(this,n.value);return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:e})),e}}}var jn=function(e){return!!e};const Wn=function(){function e(e){this._requestSender=e}return e.prototype.loadPaymentMethodsById=function(e,t){var n=this;return function(r){return new S.Observable((function(i){var s,u=null===(s=r.getState().cart.getCart())||void 0===s?void 0:s.id,c=u?(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{cartId:u}):(0,o.__assign)({},null==t?void 0:t.params);i.next((0,a.createAction)(rt.LoadPaymentMethodsRequested)),Promise.all(e.map((function(e){return(0,o.__awaiter)(n,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._requestSender.loadPaymentMethod(e,(0,o.__assign)((0,o.__assign)({},t),{params:c}))];case 1:return[2,n.sent().body];case 2:return n.sent(),[2,void 0];case 3:return[2]}}))}))}))).then((function(e){var t=e.filter(jn);i.next((0,a.createAction)(rt.LoadPaymentMethodsSucceeded,t)),i.complete()})).catch((function(e){i.next((0,a.createAction)(rt.LoadPaymentMethodsFailed,e)),i.complete()}))}))}},e.prototype.loadPaymentMethods=function(e){var t=this;return function(n){return S.Observable.create((function(r){var i=n.getState().cart.getCartOrThrow();r.next((0,a.createAction)(rt.LoadPaymentMethodsRequested)),t._requestSender.loadPaymentMethods((0,o.__assign)((0,o.__assign)({},e),{params:(0,o.__assign)((0,o.__assign)({},null==e?void 0:e.params),{cartId:i.id})})).then((function(e){var n={deviceSessionId:e.headers["x-device-session-id"],sessionHash:e.headers["x-session-hash"]},i=e.body,o=Array.isArray(i)?t._filterApplePay(i):i;r.next((0,a.createAction)(rt.LoadPaymentMethodsSucceeded,o,n)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(rt.LoadPaymentMethodsFailed,e))}))}))}},e.prototype.loadPaymentMethod=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var s,u=null===(s=r.getState().cart.getCart())||void 0===s?void 0:s.id,c=u?(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{cartId:u}):(0,o.__assign)({},null==t?void 0:t.params);i.next((0,a.createAction)(rt.LoadPaymentMethodRequested,void 0,{methodId:e})),n._requestSender.loadPaymentMethod(e,(0,o.__assign)((0,o.__assign)({},t),{params:c})).then((function(t){i.next((0,a.createAction)(rt.LoadPaymentMethodSucceeded,t.body,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(rt.LoadPaymentMethodFailed,t,{methodId:e}))}))}))}},e.prototype._filterApplePay=function(e){return(0,m.filter)(e,(function(e){return!("applepay"===e.id&&!function(e){return"ApplePaySession"in e}(window))}))},(0,o.__decorate)([Hn],e.prototype,"loadPaymentMethod",null),e}();var Kn;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(Kn||(Kn={}));const Jn=Kn;var Zn="This API endpoint is for internal use only and may change in the future",Qn={"X-Checkout-SDK-Version":"1.588.0"};const Xn=function(){function e(e){this._requestSender=e}return e.prototype.loadPaymentMethods=function(e){var t=void 0===e?{}:e,n=t.timeout,r=t.params;return this._requestSender.get("/api/storefront/payments",{timeout:n,headers:(0,o.__assign)({Accept:Jn.JsonV1,"X-API-INTERNAL":Zn},Qn),params:r})},e.prototype.loadPaymentMethod=function(e,t){var n=void 0===t?{}:t,r=n.timeout,i=n.params,a="/api/storefront/payments/"+e;return this._requestSender.get(a,{timeout:r,headers:(0,o.__assign)({Accept:Jn.JsonV1,"X-API-INTERNAL":Zn},Qn),params:i})},e}(),$n=require("@bigcommerce/script-loader");function er(e,t,n){return(r=t)&&r.type&&r.error?(0,S.concat)((0,S.of)(t),(0,S.throwError)((0,a.createErrorAction)(e,t.payload,n))):(0,S.throwError)((0,a.createErrorAction)(e,t,n));var r}const tr=function(e){function t(t){var n=e.call(this,t||"Unable to continue as a guest because the customer is already signed in.")||this;return n.name="UnableToContinueAsGuestError",n.type="unable_to_continue_as_guest",n}return(0,o.__extends)(t,e),t}(l),nr=function(){function e(e,t){this._requestSender=e,this._subscriptionActionCreator=t}return e.prototype.continueAsGuest=function(e,t){var n=this;return function(r){var i=r.getState(),s=i.checkout.getCheckout();if(!s)throw new Mn(Rn.MissingCheckout);var u=i.customer.getCustomer();if(u&&!u.isGuest)throw new tr;var c,d=i.billingAddress.getBillingAddress();if(d){d.country;var l=(0,o.__rest)(d,["country"]);c=(0,o.__assign)((0,o.__assign)({},l),e)}else c=e;return(0,S.merge)((0,S.concat)((0,S.of)((0,a.createAction)(P.ContinueAsGuestRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._createOrUpdateBillingAddress(s.id,c,t)];case 1:return e=n.sent().body,[2,(0,a.createAction)(P.ContinueAsGuestSucceeded,e)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(P.ContinueAsGuestFailed,e)}))),n._updateCustomerConsent(e,t))}},e.prototype.updateAddress=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var s=r.getState(),u=s.checkout.getCheckout();if(!u)throw new Mn(Rn.MissingCheckout);i.next((0,a.createAction)(P.UpdateBillingAddressRequested));var c=s.billingAddress.getBillingAddress(),d=(0,o.__assign)((0,o.__assign)({},e),{email:void 0===e.email&&c?c.email:e.email});c&&c.id&&(d.id=c.id),n._createOrUpdateBillingAddress(u.id,d,t).then((function(e){var t=e.body;i.next((0,a.createAction)(P.UpdateBillingAddressSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(P.UpdateBillingAddressFailed,e))}))}))}},e.prototype._updateCustomerConsent=function(e,t){var n=e.email,r=e.acceptsAbandonedCartEmails,i=e.acceptsMarketingNewsletter;return null==r&&null==i?(0,S.empty)():this._subscriptionActionCreator.updateSubscriptions({email:n,acceptsMarketingNewsletter:i||!1,acceptsAbandonedCartEmails:r||!1},t)},e.prototype._createOrUpdateBillingAddress=function(e,t,n){return t.id?this._requestSender.updateAddress(e,t,n):this._requestSender.createAddress(e,t,n)},e}();var rr={include:["cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","promotions.banners"].join(",")};const ir=function(){function e(e){this._requestSender=e}return e.prototype.createAddress=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/billing-address",a=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post(i,{body:t,params:rr,headers:a,timeout:r})},e.prototype.updateAddress=function(e,t,n){var r=(void 0===n?{}:n).timeout,i=t.id,a=(0,o.__rest)(t,["id"]),s="/api/storefront/checkouts/"+e+"/billing-address/"+i,u=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.put(s,{params:rr,body:a,headers:u,timeout:r})},e}(),or=function(){function e(e){this._requestSender=e}return e.prototype.createBuyNowCart=function(e,t){var n=(void 0===t?{}:t).timeout,r=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post("/api/storefront/carts",{body:e,headers:r,timeout:n})},e}(),ar=function(){function e(e,t,n){this._checkoutRequestSender=e,this._configActionCreator=t,this._formFieldsActionCreator=n}return e.prototype.loadCheckout=function(e,t){var n=this;return function(r){return(0,S.concat)((0,S.of)((0,a.createAction)(w.LoadCheckoutRequested)),(0,S.merge)(n._configActionCreator.loadConfig((0,o.__assign)((0,o.__assign)({},t),{useCache:!0,params:(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{checkoutId:e})})),n._formFieldsActionCreator.loadFormFields((0,o.__assign)((0,o.__assign)({},t),{useCache:!0}))),(0,S.defer)((function(){return n._checkoutRequestSender.loadCheckout(e,t).then((function(e){var t=e.body;return(0,a.createAction)(w.LoadCheckoutSucceeded,n._shouldTransformCustomerAddress(r.getState().config.getStoreConfigOrThrow())?n._transformCustomerAddresses(t):t)}))}))).pipe((0,I.catchError)((function(e){return er(w.LoadCheckoutFailed,e)})))}},e.prototype.loadDefaultCheckout=function(e){var t=this;return function(n){return(0,S.concat)((0,S.of)((0,a.createAction)(w.LoadCheckoutRequested)),(0,S.merge)(t._configActionCreator.loadConfig(),t._formFieldsActionCreator.loadFormFields((0,o.__assign)((0,o.__assign)({},e),{useCache:!0}))),(0,S.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=n.getState(),!(r=t.config.getContextConfig())||!r.checkoutId)throw new Mn(Rn.MissingCheckoutConfig);return[4,this._checkoutRequestSender.loadCheckout(r.checkoutId,e)];case 1:return i=o.sent().body,[2,(0,a.createAction)(w.LoadCheckoutSucceeded,this._shouldTransformCustomerAddress(t.config.getStoreConfigOrThrow())?this._transformCustomerAddresses(i):i)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(w.LoadCheckoutFailed,e)})))}},e.prototype.updateCheckout=function(e,t){var n=this;return function(r){return new S.Observable((function(i){var o=r.getState().checkout.getCheckout();if(!o)throw new Mn(Rn.MissingCheckout);i.next((0,a.createAction)(w.UpdateCheckoutRequested)),n._checkoutRequestSender.updateCheckout(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(w.UpdateCheckoutSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(w.UpdateCheckoutFailed,e))}))}))}},e.prototype.loadCurrentCheckout=function(e){var t=this;return function(n){var r=n.getState().checkout.getCheckout();if(!r)throw new Mn(Rn.MissingCheckout);return t.loadCheckout(r.id,e)(n)}},e.prototype._shouldTransformCustomerAddress=function(e){var t;return null===(t=e.checkoutSettings.features["CHECKOUT-8183.set_shouldSaveAddress_false_for_existing_address"])||void 0===t||t},e.prototype._transformCustomerAddresses=function(e){return(0,o.__assign)((0,o.__assign)({},e),{customer:(0,o.__assign)((0,o.__assign)({},e.customer),{addresses:e.customer.addresses.map((function(e){return(0,o.__assign)((0,o.__assign)({},e),{shouldSaveAddress:!1})}))})})},e}();function sr(e){return(0,m.uniq)(e).join(",")}function ur(e,t){return void 0===t&&(t=[]),Array.isArray(t)?sr((0,o.__spreadArrays)(e,t)):function(e,t){var n=(0,m.keys)((0,m.pickBy)(t,(function(e){return!e}))),r=(0,m.keys)((0,m.filter)(t));return sr((0,o.__spreadArrays)((0,m.difference)(e,n),r))}(e,t)}const cr=["cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","customer.customerGroup","payments","promotions.banners"],dr=function(e){function t(t){var n=e.call(this,t,{message:t.body.title})||this;return n.name="CheckoutNotAvailableError",n.type="checkout_not_available",n}return(0,o.__extends)(t,e),t}(h),lr=function(){function e(e){this._requestSender=e}return e.prototype.loadCheckout=function(e,t){var n=void 0===t?{}:t,r=n.params,i=(void 0===r?{}:r).include,a=n.timeout,s="/api/storefront/checkout/"+e,u=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.get(s,{params:{include:ur(cr,i)},headers:u,timeout:a}).catch((function(e){if(e.status>=400&&e.status<500)throw new dr(e);throw e}))},e.prototype.updateCheckout=function(e,t,n){var r=void 0===n?{}:n,i=r.params,a=(void 0===i?{}:i).include,s=r.timeout,u="/api/storefront/checkout/"+e,c=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.put(u,{params:{include:ur(cr,a)},body:t,headers:c,timeout:s})},e}(),pr=function(){function e(){}return e.prototype.isEqual=function(e,t){return(0,m.isEqual)(this._normalize(e),this._normalize(t))},e.prototype._normalize=function(e){return{cartAmount:e.cartAmount,currency:e.currency,id:e.id,lineItems:{digitalItems:e.lineItems.digitalItems.slice().sort((function(e,t){return(""+e.productId+e.variantId).localeCompare(""+t.productId+t.variantId)})).map((function(e){return{extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId}})),giftCertificates:e.lineItems.giftCertificates.slice().sort((function(e,t){return(""+e.id).localeCompare(""+t.id)})).map((function(e){return{amount:e.amount,recipient:e.recipient}})),physicalItems:e.lineItems.physicalItems.slice().sort((function(e,t){return(""+e.productId+e.variantId).localeCompare(""+t.productId+t.variantId)})).map((function(e){return{extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId,giftWrapping:e.giftWrapping}}))}}},e}(),hr=function(e){function t(t,n){var r=e.call(this,"An update to your shopping cart has been detected and your available shipping costs have been updated.")||this;return r.name="CartChangedError",r.type="cart_changed",r.data={previous:t,updated:n},r}return(0,o.__extends)(t,e),t}(l),fr=function(){function e(e){this._checkoutRequestSender=e}return e.prototype.validate=function(e,t){var n=this;if(!e)throw new Mn(Rn.MissingCheckout);return this._checkoutRequestSender.loadCheckout(e.id,t).then((function(t){var r=new pr;if(!(e.outstandingBalance===t.body.outstandingBalance&&n._compareCoupons(e.coupons,t.body.coupons)&&n._compareGiftCertificates(e.giftCertificates,t.body.giftCertificates)&&r.isEqual(e.cart,t.body.cart)))throw new hr(n._getComparableCheckout(e),n._getComparableCheckout(t.body))}))},e.prototype._compareCoupons=function(e,t){return(0,m.isEqual)((0,m.map)(e,"code"),(0,m.map)(t,"code"))},e.prototype._compareGiftCertificates=function(e,t){return(0,m.isEqual)((0,m.map)(e,"code"),(0,m.map)(t,"code"))},e.prototype._getComparableCheckout=function(e){var t=e.cart,n=e.coupons,r=e.giftCertificates,i=e.outstandingBalance;return{cart:{cartAmount:t.cartAmount,currency:t.currency,lineItems:t.lineItems},coupons:n,giftCertificates:r,outstandingBalance:i}},e}(),mr=function(){function e(e){this._configRequestSender=e}return e.prototype.loadConfig=function(e){var t=this;return S.Observable.create((function(n){n.next((0,a.createAction)(J.LoadConfigRequested)),t._configRequestSender.loadConfig(e).then((function(e){n.next((0,a.createAction)(J.LoadConfigSucceeded,e.body)),n.complete()})).catch((function(e){n.error((0,a.createErrorAction)(J.LoadConfigFailed,e))}))}))},(0,o.__decorate)([Hn],e.prototype,"loadConfig",null),e}(),gr=function(){function e(e){this._requestSender=e}return e.prototype.loadConfig=function(e){var t=void 0===e?{}:e,n=t.timeout,r=t.params;return this._requestSender.get("/api/storefront/checkout-settings",{timeout:n,headers:(0,o.__assign)({Accept:Jn.JsonV1,"X-API-INTERNAL":Zn},Qn),params:r}).catch((function(e){if(e.status>=400&&e.status<500)throw new dr(e);throw e}))},e}();function yr(e){var t=e;return"object"==typeof t&&"object"==typeof t.payload&&"string"==typeof t.payload.token}const _r=function(){function e(e,t,n){this._customerRequestSender=e,this._checkoutActionCreator=t,this._spamProtectionActionCreator=n}return e.prototype.createCustomer=function(e,t){var n=this;return function(r){var i=r.getState().config.getStoreConfigOrThrow().checkoutSettings.isStorefrontSpamProtectionEnabled,s=function(i){return(0,S.from)(n._customerRequestSender.createAccount((0,o.__assign)((0,o.__assign)({},e),{token:i}),t)).pipe((0,I.switchMap)((function(){return(0,S.concat)(n._checkoutActionCreator.loadCurrentCheckout(t)(r),(0,S.of)((0,a.createAction)(me.CreateCustomerSucceeded)))})))};return(0,S.concat)((0,S.of)((0,a.createAction)(me.CreateCustomerRequested)),i?(0,S.from)(n._spamProtectionActionCreator.execute()(r)).pipe((0,I.switchMap)((function(e){var t;return yr(e)?(0,S.concat)((0,S.of)(e),s(null===(t=e.payload)||void 0===t?void 0:t.token)):(0,S.of)(e)}))):s()).pipe((0,I.catchError)((function(e){return er(me.CreateCustomerFailed,e)})))}},e.prototype.createAddress=function(e,t){var n=this;return(0,S.concat)((0,S.of)((0,a.createAction)(me.CreateCustomerAddressRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._customerRequestSender.createAddress(e,t)];case 1:return n=r.sent().body,[2,(0,a.createAction)(me.CreateCustomerAddressSucceeded,n)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(me.CreateCustomerAddressFailed,e)})))},e.prototype.signInCustomer=function(e,t){var n=this;return function(r){return(0,S.concat)((0,S.of)((0,a.createAction)(me.SignInCustomerRequested)),(0,S.from)(n._customerRequestSender.signInCustomer(e,t)).pipe((0,I.switchMap)((function(e){var i=e.body;return(0,S.concat)(n._checkoutActionCreator.loadCurrentCheckout(t)(r),(0,S.of)((0,a.createAction)(me.SignInCustomerSucceeded,i.data)))})))).pipe((0,I.catchError)((function(e){return er(me.SignInCustomerFailed,e)})))}},e.prototype.signOutCustomer=function(e){var t=this;return function(n){return(0,S.concat)((0,S.of)((0,a.createAction)(me.SignOutCustomerRequested)),(0,S.from)(t._customerRequestSender.signOutCustomer(e)).pipe((0,I.switchMap)((function(r){var i=r.body;return(0,S.concat)(t._checkoutActionCreator.loadCurrentCheckout(e)(n),(0,S.of)((0,a.createAction)(me.SignOutCustomerSucceeded,i.data)))})))).pipe((0,I.catchError)((function(e){return er(me.SignOutCustomerFailed,e)})))}},e}(),vr=function(){function e(e){this._requestSender=e}return e.prototype.createAccount=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/api/storefront/customer",{timeout:n,headers:Qn,body:e})},e.prototype.createAddress=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/api/storefront/customer-address",{timeout:n,headers:Qn,body:e})},e.prototype.signInCustomer=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/internalapi/v1/checkout/customer",{timeout:n,headers:Qn,body:e})},e.prototype.signOutCustomer=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.delete("/internalapi/v1/checkout/customer",{timeout:t,headers:Qn})},e}(),Cr=function(){function e(e){this._formFieldsRequestSender=e}return e.prototype.loadFormFields=function(e){var t=this;return(0,S.concat)((0,S.of)((0,a.createAction)(De.LoadFormFieldsRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._formFieldsRequestSender.loadFields(e)];case 1:return t=n.sent().body,[2,(0,a.createAction)(De.LoadFormFieldsSucceeded,t)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(De.LoadFormFieldsFailed,e)})))},(0,o.__decorate)([Hn],e.prototype,"loadFormFields",null),e}(),Sr=function(){function e(e){this._requestSender=e}return e.prototype.loadFields=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.get("/api/storefront/form-fields",{timeout:t,headers:(0,o.__assign)({Accept:Jn.JsonV1,"X-API-INTERNAL":Zn},Qn)})},e}(),Ir=function(e){var t=this,n=new Promise((function(e,n){t.cancel=n}));this.promise=Promise.race([e,n])},wr=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the required element is unexpectedly detached from the page.")||this;return n.name="UnexpectedDetachmentError",n.type="unexpected_detachment",n}return(0,o.__extends)(t,e),t}(l),Er=function(){function e(e){this._mutationObserver=e}return e.prototype.ensurePresence=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=new Ir(t),(r=this._mutationObserver.create((function(t){t.forEach((function(t){0!==Array.from(t.removedNodes).filter((function(t){return e.some((function(e){return t===e||t.contains(e)}))})).length&&n.cancel(new wr)}))}))).observe(document.body,{childList:!0,subtree:!0}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.promise];case 2:return i=o.sent(),r.disconnect(),[2,i];case 3:throw a=o.sent(),r.disconnect(),a;case 4:return[2]}}))}))},e}();var br=function(){function e(e){void 0===e&&(e=window),this._window=e}return e.prototype.create=function(e){return new this._window.MutationObserver(e)},e}();const Pr=function(e){function t(t){var n=e.call(this,t||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return(0,o.__extends)(t,e),t}(l);function Ar(e){if(!/^(https?:)?\/\//.test(e))throw new Pr("The provided URL must be absolute.");var t=document.createElement("a");t.href=e;var n=t.port&&-1!==e.indexOf(t.hostname+":"+t.port)?t.port:"";return{hash:t.hash,hostname:t.hostname,href:t.href,origin:t.protocol+"//"+t.hostname+(n?":"+n:""),pathname:t.pathname,port:n,protocol:t.protocol,search:t.search}}function Tr(e,t){return e.type===t}const Or=function(){function e(e,t,n){this._targetWindow=t,this._context=n,this._targetOrigin="*"===e?"*":Ar(e).origin}return e.prototype.post=function(e,t){var n=this,r=this._targetWindow;if(window!==r){if(!r)throw new Error("Unable to post message because target window is not set.");var i=t&&(0,S.fromEvent)(window,"message").pipe((0,I.filter)((function(e){return e.origin===n._targetOrigin&&Tr(e.data,e.data.type)&&-1!==[t.successType,t.errorType].indexOf(e.data.type)})),(0,I.map)((function(e){if(t.errorType===e.data.type)throw e.data;return e.data})),(0,I.take)(1)).toPromise();return r.postMessage((0,o.__assign)((0,o.__assign)({},e),{context:this._context}),this._targetOrigin),i}},e.prototype.setTarget=function(e){this._targetWindow=e},e.prototype.setContext=function(e){this._context=e},e}(),Rr=function(e,t,n){return t&&n?Mr(0,t,n):function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,o.__extends)(t,e),t}(e);return Object.getOwnPropertyNames(e.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Mr(e.prototype,n,r))})),t}(e)};function Mr(e,t,n){if("function"!=typeof n.value)return n;var r=n.value;return{get:function(){var e=r.bind(this);return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:e})),e},set:function(e){r=e}}}const kr=function(){function e(e){var t;this._sourceOrigins=[Ar(e).origin,(t=Ar(e),Ar(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,"www."+t.hostname))).origin],this._isListening=!1,this._listeners={}}return e.prototype.listen=function(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))},e.prototype.stopListen=function(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))},e.prototype.addListener=function(e,t){var n=this._listeners[e];n||(this._listeners[e]=n=[]),-1===n.indexOf(t)&&n.push(t)},e.prototype.removeListener=function(e,t){var n=this._listeners[e];if(n){var r=n.indexOf(t);r>=0&&n.splice(r,1)}},e.prototype.trigger=function(e,t){var n=this._listeners[e.type];n&&n.forEach((function(n){return t?n(e,t):n(e)}))},e.prototype._handleMessage=function(e){if(-1!==this._sourceOrigins.indexOf(e.origin)&&Tr(e.data,e.data.type)){var t=e.data,n=t.context,r=(0,o.__rest)(t,["context"]);this.trigger(r,n)}},(0,o.__decorate)([Rr],e.prototype,"_handleMessage",null),e}(),Dr=function(e){function t(){var t=e.call(this,"You haven't complete our spam protection challenge. Please try again.")||this;return t.name="SpamProtectionChallengeNotCompletedError",t.type="spam_protection_challenge_not_completed",t}return(0,o.__extends)(t,e),t}(l),Nr=function(e){function t(){var t=e.call(this,"Please complete our human verification challenge and try again.")||this;return t.name="CardingProtectionChallengeNotCompletedError",t.type="carding_protection_challenge_not_completed",t}return(0,o.__extends)(t,e),t}(l),Lr=function(e){function t(){var t=e.call(this,"We were not able to verify that you are not a robot. Please try again.")||this;return t.name="CardingProtectionFailedError",t.type="carding_protection_failed",t}return(0,o.__extends)(t,e),t}(l),zr=function(){function e(e){this._googleRecaptcha=e}return e.prototype.handle=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return"string"==typeof e?[2,this.handleWithRecaptchaSitekey(e,t)]:[2,this.handleWithPaymentHumanVerificationRequestError(e)]}))}))},e.prototype.handleWithPaymentHumanVerificationRequestError=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!this._isPaymentHumanVerificationRequest(e))throw e;return[4,this._initialize(e.body.additional_action_required.data.key)];case 1:return t.sent(),[2,this._performRecaptcha()]}}))}))},e.prototype.handleWithRecaptchaSitekey=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("recaptcha_v2"!==e)throw Error("Human verification method is not supported.");if(!t)throw Error("Recaptcha site key is missing.");return[4,this._initialize(t)];case 1:return n.sent(),[2,this._performRecaptcha()]}}))}))},e.prototype._performRecaptcha=function(){var e=this;return this._googleRecaptcha.execute().pipe((0,I.take)(1)).pipe((0,I.switchMap)((function(t){var n=t.error,r=t.token;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){if(n instanceof Dr)throw new Nr;if(n||!r)throw new Lr;return[2,{type:"recaptcha_v2_verification",data:{human_verification_token:r}}]}))}))}))).toPromise()},e.prototype._initialize=function(e){var t="cardingProtectionContainer",n=document.getElementById(t);return n&&n.parentNode&&n.parentNode.removeChild(n),(n=document.createElement("div")).setAttribute("id",t),document.body.appendChild(n),this._googleRecaptcha.load(t,e)},e.prototype._isPaymentHumanVerificationRequest=function(e){var t=e.body||{},n=t.additional_action_required;return"additional_action_required"===t.status&&n&&"recaptcha_v2_verification"===n.type},e}();var Fr;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(Fr||(Fr={}));const Ur=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Fr.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case Fr.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case Fr.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case Fr.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(t))||this;return n.subtype=t,n.name="NotInitializedError",n.type="not_initialized",n}return(0,o.__extends)(t,e),t}(l),qr=function(e){function t(){var t=e.call(this,"We were not able to complete your spam protection verification. Please try again.")||this;return t.name="SpamProtectionFailedError",t.type="spam_protection_failed",t}return(0,o.__extends)(t,e),t}(l),Br=function(e){function t(){var t=e.call(this,"Spam protection is not loaded. Please try again.")||this;return t.name="SpamProtectionNotLoadedError",t.type="spam_protection_failed",t}return(0,o.__extends)(t,e),t}(l),Gr=function(){function e(e,t){var n=this;this.googleRecaptchaScriptLoader=e,this.mutationObserverFactory=t,this._memoized=(0,On.memoize)((function(e,t,r){var i=new S.Subject;if(!r)throw new Error;return n._widgetId=e.render(r.id,{sitekey:t,size:"invisible",callback:function(){i.next({token:e.getResponse(n._widgetId)}),e.reset(n._widgetId)},"error-callback":function(){i.next({error:new qr})}}),i}),{isEqual:function(e,t){return e===t}})}return e.prototype.load=function(e,t){var n=this;return this.googleRecaptchaScriptLoader.load().then((function(r){r&&(n._event$=n._memoized(r,t,document.getElementById(e)),n._recaptcha=r)}))},e.prototype.execute=function(){var e=this;return(0,S.defer)((function(){var t=e._event$,n=e._recaptcha;if(!t||!n)throw new Ur(Fr.SpamProtectionNotInitialized);return(0,S.defer)((function(){var e=document.querySelector('iframe[src*="bframe"]');return e?(0,S.of)(e):(0,S.throwError)(new Br)})).pipe((0,I.retryWhen)((function(e){return e.pipe((0,I.delay)(250),(0,I.switchMap)((function(e,t){return t<28?(0,S.of)(e):(0,S.throwError)(e)})))})),(0,I.switchMap)((function(r){return e._watchRecaptchaChallengeWindow(t,r),n.execute(e._widgetId),t})),(0,I.catchError)((function(e){return(0,S.of)({error:e})})))}))},e.prototype._watchRecaptchaChallengeWindow=function(e,t){var n=t.parentElement;if(!n)throw new Br;var r=n.parentElement;if(!r)throw new Br;this.mutationObserverFactory.create((function(){"hidden"===r.style.visibility&&e.next({error:new Dr})})).observe(r,{attributes:!0,attributeFilter:["style"]})},e}(),xr=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(){return this._loadPromise||(this._loadPromise=this._loadScript()),this._loadPromise},e.prototype._loadScript=function(){var e=this,t="initRecaptcha",n=["onload="+t,"render=explicit"].join("&");return new Promise((function(r,i){e._window[t]=function(){return r(e._window.grecaptcha)},e._scriptLoader.loadScript("//www.google.com/recaptcha/api.js?"+n).catch((function(t){e._loadPromise=void 0,i(t)}))}))},e}();function Yr(e){return new Gr(new xr(e),new br)}const Vr=function(e){function t(t){var n=e.call(this,t||"Unable to proceed due to invalid configuration provided for the hosted payment form.")||this;return n.name="InvalidHostedFormConfigError",n.type="invalid_hosted_form_config",n}return(0,o.__extends)(t,e),t}(l),Hr=function(e){function t(t){var n=e.call(this,t||"Unable to proceed due to an unknown error with the hosted payment form.")||this;return n.name="InvalidHostedFormError",n.type="invalid_hosted_form",n}return(0,o.__extends)(t,e),t}(l),jr=function(e){function t(t){var n=e.call(this,(0,o.__spreadArrays)(["Unable to proceed due to invalid user input values"],(0,m.flatMap)((0,m.values)(t),(function(e){return(0,m.map)(e,(function(e){return e.message}))}))).join(". "))||this;return n.errors=t,n.name="InvalidHostedFormValueError",n.type="invalid_hosted_form_value",n}return(0,o.__extends)(t,e),t}(l);var Wr,Kr;!function(e){e.AttachRequested="HOSTED_FIELD:ATTACH_REQUESTED",e.SubmitRequested="HOSTED_FIELD:SUBMITTED_REQUESTED",e.ValidateRequested="HOSTED_FIELD:VALIDATE_REQUESTED",e.StoredCardRequested="HOSTED_FIELD:STORED_CARD_REQUESTED"}(Wr||(Wr={})),function(e){e.AttachSucceeded="HOSTED_INPUT:ATTACH_SUCCEEDED",e.AttachFailed="HOSTED_INPUT:ATTACH_FAILED",e.BinChanged="HOSTED_INPUT:BIN_CHANGED",e.Blurred="HOSTED_INPUT:BLURRED",e.Changed="HOSTED_INPUT:CHANGED",e.CardTypeChanged="HOSTED_INPUT:CARD_TYPE_CHANGED",e.Entered="HOSTED_INPUT:ENTERED",e.Focused="HOSTED_INPUT:FOCUSED",e.SubmitSucceeded="HOSTED_INPUT:SUBMIT_SUCCEEDED",e.SubmitFailed="HOSTED_INPUT:SUBMIT_FAILED",e.Validated="HOSTED_INPUT:VALIDATED",e.StoredCardSucceeded="HOSTED_INPUT:STORED_CARD_SUCCEEDED",e.StoredCardFailed="HOSTED_INPUT:STORED_CARD_FAILED"}(Kr||(Kr={}));const Jr=function(){function e(e,t,n,r,i,o,a,s,u){this._type=e,this._containerId=t,this._placeholder=n,this._accessibilityLabel=r,this._styles=i,this._eventPoster=o,this._eventListener=a,this._detachmentObserver=s,this._cardInstrument=u,this._iframe=document.createElement("iframe"),this._iframe.src="/checkout/payment/hosted-field?version=1.588.0",this._iframe.style.border="none",this._iframe.style.height="100%",this._iframe.style.overflow="hidden",this._iframe.style.width="100%"}return e.prototype.getType=function(){return this._type},e.prototype.attach=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n=this;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:if(!(e=document.getElementById(this._containerId)))throw new Vr("Unable to proceed because the provided container ID is not valid.");return e.appendChild(this._iframe),this._eventListener.listen(),t=(0,S.fromEvent)(this._iframe,"load").pipe((0,I.switchMap)((function(e){var t=e.target;return(0,o.__awaiter)(n,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!(e=t&&t.contentWindow))throw new Error("The content window of the iframe cannot be accessed.");return this._eventPoster.setTarget(e),[4,this._eventPoster.post({type:Wr.AttachRequested,payload:{accessibilityLabel:this._accessibilityLabel,cardInstrument:this._cardInstrument,fontUrls:this._getFontUrls(),placeholder:this._placeholder,styles:this._styles,origin:document.location.origin,type:this._type}},{successType:Kr.AttachSucceeded,errorType:Kr.AttachFailed})];case 1:return n.sent(),[2]}}))}))})),(0,I.take)(1)).toPromise(),[4,this._detachmentObserver.ensurePresence([this._iframe],t)];case 1:return r.sent(),[2]}}))}))},e.prototype.detach=function(){this._iframe.parentElement&&(this._iframe.parentElement.removeChild(this._iframe),this._eventListener.stopListen())},e.prototype.submitForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=this._eventPoster.post({type:Wr.SubmitRequested,payload:{fields:e,data:t}},{successType:Kr.SubmitSucceeded,errorType:Kr.SubmitFailed}),[4,this._detachmentObserver.ensurePresence([this._iframe],n)];case 1:return[2,i.sent()];case 2:if(r=i.sent(),this._isSubmitErrorEvent(r)){if("hosted_form_error"===r.payload.error.code)throw new Hr(r.payload.error.message);if(r.payload.response)throw y(r.payload.response);throw new Error(r.payload.error.message)}throw r;case 3:return[2]}}))}))},e.prototype.submitStoredCardForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){return n=this._eventPoster.post({type:Wr.StoredCardRequested,payload:{fields:e,data:t}},{successType:Kr.StoredCardSucceeded,errorType:Kr.StoredCardFailed}),[2,this._detachmentObserver.ensurePresence([this._iframe],n)]}))}))},e.prototype.validateForm=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e=this._eventPoster.post({type:Wr.ValidateRequested},{successType:Kr.Validated}),[4,this._detachmentObserver.ensurePresence([this._iframe],e)];case 1:if(!(t=n.sent().payload).isValid)throw new jr(t.errors);return[2]}}))}))},e.prototype._getFontUrls=function(){var e=this,t="fonts.googleapis.com",n=document.querySelectorAll("link[href*='"+t+"'][rel='stylesheet']");return Array.prototype.slice.call(n).filter((function(e){return Ar(e.href).hostname===t})).filter((function(t){return(0,m.values)(e._styles).map((function(e){return e&&e.fontFamily})).filter((function(e){return"string"==typeof e})).some((function(e){return e.split(/,\s/).some((function(e){return-1!==t.href.indexOf(e.replace(" ","+"))}))}))})).map((function(e){return e.href}))},e.prototype._isSubmitErrorEvent=function(e){return e.type===Kr.SubmitFailed},e}(),Zr=function(){function e(e,t,n,r,i){var a=this;this._fields=e,this._eventListener=t,this._payloadTransformer=n,this._eventCallbacks=r,this._paymentHumanVerificationHandler=i,this._handleEnter=function(e){var t=e.payload;return(0,o.__awaiter)(a,void 0,void 0,(function(){var e,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.validate()];case 1:return r.sent(),[3,3];case 2:if("InvalidHostedFormValueError"!==(e=r.sent()).name)throw e;return[3,3];case 3:return(void 0===(n=this._eventCallbacks.onEnter)?m.noop:n)(t),[2]}}))}))};var s=this._eventCallbacks,u=s.onBlur,c=void 0===u?m.noop:u,d=s.onCardTypeChange,l=void 0===d?m.noop:d,p=s.onFocus,h=void 0===p?m.noop:p,f=s.onValidate,g=void 0===f?m.noop:f;this._eventListener.addListener(Kr.Blurred,(function(e){var t=e.payload;return c(t)})),this._eventListener.addListener(Kr.CardTypeChanged,(function(e){var t=e.payload;return l(t)})),this._eventListener.addListener(Kr.Focused,(function(e){var t=e.payload;return h(t)})),this._eventListener.addListener(Kr.Validated,(function(e){var t=e.payload;return g(t)})),this._eventListener.addListener(Kr.Entered,this._handleEnter),this._eventListener.addListener(Kr.CardTypeChanged,(function(e){var t=e.payload;return a._cardType=t.cardType})),this._eventListener.addListener(Kr.BinChanged,(function(e){var t=e.payload;return a._bin=t.bin}))}return e.prototype.getBin=function(){return this._bin},e.prototype.getCardType=function(){return this._cardType},e.prototype.attach=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this._eventListener.listen(),e=this._getFirstField(),t=(0,m.without)(this._fields,e),[4,e.attach()];case 1:return n.sent(),[4,Promise.all(t.map((function(e){return e.attach()})))];case 2:return n.sent(),[2]}}))}))},e.prototype.detach=function(){this._eventListener.stopListen(),this._fields.forEach((function(e){e.detach()}))},e.prototype.submit=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this._getFirstField().submitForm(this._fields.map((function(e){return e.getType()})),this._payloadTransformer.transform(e,t))];case 1:case 4:return[2,i.sent()];case 2:return n=i.sent(),[4,this._paymentHumanVerificationHandler.handle(n)];case 3:return r=i.sent(),[4,this._getFirstField().submitForm(this._fields.map((function(e){return e.getType()})),this._payloadTransformer.transform(e,r))];case 5:return[2]}}))}))},e.prototype.submitStoredCard=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._getFirstField().submitStoredCardForm(e.fields,e.data)]}))}))},e.prototype.validate=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this._getFirstField().validateForm()]}))}))},e.prototype._getFirstField=function(){var e=this._fields[0];if(!e)throw new Vr("Unable to proceed because the payment form has no field defined.");return e},e}();function Qr(e){return Boolean(e.instrumentId)}const Xr=function(){function e(e){this._store=e}return e.prototype.transform=function(e,t){var n=this._store.getState(),r=n.checkout.getCheckout(),i=n.config.getConfig(),o=n.instruments.getInstrumentsMeta(),a=n.order.getOrder(),s=n.order.getOrderMeta(),u=(0,m.omit)(e.paymentData,"ccExpiry","ccName","ccNumber","ccCvv"),c=n.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),d=n.paymentMethods.getPaymentMethodsMeta(),l=o&&u&&Qr(u)?n.payment.getPaymentToken()+", "+o.vaultAccessToken:n.payment.getPaymentToken();if(!l)throw new Mn(Rn.MissingPaymentToken);return{additionalAction:t,authToken:l,checkout:r,config:i,order:a,orderMeta:s,payment:u,paymentMethod:c,paymentMethodMeta:d}},e}(),$r=function(){function e(e){this._store=e}return e.prototype.create=function(e,t){var n=this,r=Object.keys(t.fields).reduce((function(r,i){var a=t.fields[i];return a?(0,o.__spreadArrays)(r,[new Jr(i,a.containerId,a.placeholder||"",a.accessibilityLabel||"",t.styles||{},new Or(e),new kr(e),new Er(new br),"instrumentId"in a?n._getCardInstrument(a.instrumentId):void 0)]):r}),[]);return new Zr(r,new kr(e),new Xr(this._store),(0,m.pick)(t,"onBlur","onEnter","onFocus","onCardTypeChange","onValidate"),new zr(Yr((0,$n.createScriptLoader)())))},e.prototype._getCardInstrument=function(e){var t=(0,this._store.getState().instruments.getCardInstrument)(e);if(!t)throw new Mn(Rn.MissingPaymentInstrument);return t},e}(),ei=function(e){function t(){var t=e.call(this,"You haven't complete our spam check. Please try again.")||this;return t.name="SpamProtectionNotCompletedError",t.type="spam_protection_not_completed",t}return(0,o.__extends)(t,e),t}(l),ti=function(){function e(e,t){this._orderRequestSender=e,this._checkoutValidator=t}return e.prototype.loadOrder=function(e,t){var n=this;return new S.Observable((function(r){r.next((0,a.createAction)(ie.LoadOrderRequested)),n._orderRequestSender.loadOrder(e,t).then((function(e){r.next((0,a.createAction)(ie.LoadOrderSucceeded,e.body)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(ie.LoadOrderFailed,e))}))}))},e.prototype.loadOrderPayments=function(e,t){var n=this;return new S.Observable((function(r){r.next((0,a.createAction)(ie.LoadOrderPaymentsRequested)),n._orderRequestSender.loadOrder(e,t).then((function(e){r.next((0,a.createAction)(ie.LoadOrderPaymentsSucceeded,e.body)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(ie.LoadOrderPaymentsFailed,e))}))}))},e.prototype.loadCurrentOrder=function(e){var t=this;return function(n){return(0,S.defer)((function(){var r=t._getCurrentOrderId(n.getState());if(!r)throw new Mn(Rn.MissingOrderId);return t.loadOrder(r,e)}))}},e.prototype.submitOrder=function(e,t){var n=this;return function(r){return(0,S.concat)((0,S.of)((0,a.createAction)(ie.SubmitOrderRequested)),(0,S.defer)((function(){var i=r.getState(),s=i.config.getExternalSource(),u=i.config.getVariantIdentificationToken(),c=i.checkout.getCheckout();if(!c)throw new Mn(Rn.MissingCheckout);if(c.shouldExecuteSpamCheck)throw new ei;return(0,S.from)(n._checkoutValidator.validate(c,t).then((function(){return n._orderRequestSender.submitOrder(n._mapToOrderRequestBody(null!=e?e:{},c.id,c.customerMessage,s),(0,o.__assign)((0,o.__assign)({},t),{headers:{checkoutVariant:u}}))}))).pipe((0,I.switchMap)((function(e){return(0,S.concat)(n.loadOrder(e.body.data.order.orderId,t),(0,S.of)((0,a.createAction)(ie.SubmitOrderSucceeded,e.body.data,(0,o.__assign)((0,o.__assign)({},e.body.meta),{token:e.headers.token}))))})))})).pipe((0,I.catchError)((function(e){return er(ie.SubmitOrderFailed,e)}))))}},e.prototype.finalizeOrder=function(e,t){var n=this;return(0,S.concat)((0,S.of)((0,a.createAction)(ie.FinalizeOrderRequested)),(0,S.from)(this._orderRequestSender.finalizeOrder(e,t)).pipe((0,I.switchMap)((function(r){return(0,S.concat)(n.loadOrder(e,t),(0,S.of)((0,a.createAction)(ie.FinalizeOrderSucceeded,r.body.data)))})))).pipe((0,I.catchError)((function(e){return er(ie.FinalizeOrderFailed,e)})))},e.prototype._getCurrentOrderId=function(e){var t=e.order.getOrder(),n=e.checkout.getCheckout();return t&&t.orderId||n&&n.orderId},e.prototype._mapToOrderRequestBody=function(e,t,n,r){var i=e.payment,a=(0,o.__rest)(e,["payment"]);return i?(0,o.__assign)((0,o.__assign)({},a),{cartId:t,customerMessage:n,externalSource:r,payment:{paymentData:i.paymentData,name:i.methodId,gateway:i.gatewayId}}):(0,o.__assign)((0,o.__assign)({},a),{cartId:t,customerMessage:n,externalSource:r})},e}(),ni=function(e){function t(t){var n=e.call(this,t||"Your checkout could not be processed because some details have changed. Please review your order and try again.")||this;return n.name="CartConsistencyError",n.type="cart_consistency",n}return(0,o.__extends)(t,e),t}(l),ri=function(e){function t(t){var n=e.call(this,t||"The tax provider is unavailable.")||this;return n.name="OrderTaxProviderUnavailableError",n.type="tax_provider_unavailable",n}return(0,o.__extends)(t,e),t}(l),ii=function(){function e(e){this._requestSender=e}return e.prototype.loadOrder=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/orders/"+e,i=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.get(r,{params:{include:sr(["payments","lineItems.physicalItems.socialMedia","lineItems.physicalItems.options","lineItems.physicalItems.categories","lineItems.digitalItems.socialMedia","lineItems.digitalItems.options","lineItems.digitalItems.categories"])},headers:i,timeout:n})},e.prototype.submitOrder=function(e,t){var n=void 0===t?{}:t,r=n.headers,i=n.timeout;return this._requestSender.post("/internalapi/v1/checkout/order",{body:e,headers:(0,m.omitBy)((0,o.__assign)({"X-Checkout-Variant":r&&r.checkoutVariant},Qn),m.isNil),timeout:i}).catch((function(e){if("tax_provider_unavailable"===e.body.type)throw new ri;if("cart_has_changed"===e.body.type)throw new ni;throw e}))},e.prototype.finalizeOrder=function(e,t){var n=(void 0===t?{}:t).timeout,r="/internalapi/v1/checkout/order/"+e;return this._requestSender.post(r,{timeout:n,headers:Qn})},e}(),oi=function(){function e(e,t,n,r){var i=this;this._paymentRequestSender=e,this._orderActionCreator=t,this._paymentRequestTransformer=n,this._paymentHumanVerificationHandler=r,this.initializeOffsitePayment=function(e){var t=e.methodId,n=e.gatewayId,r=e.instrumentId,o=e.target,s=e.promise,u=e.shouldSaveInstrument,c=e.shouldSetAsDefaultInstrument;return function(e){var d;r?d={formattedPayload:{bigpay_token:r}}:u&&(d={formattedPayload:{vault_payment_instrument:u,set_as_default_stored_instrument:c||null}});var l=i._paymentRequestTransformer.transform({gatewayId:n,methodId:t,paymentData:d},e.getState());return(0,S.concat)((0,S.of)((0,a.createAction)(nt.InitializeOffsitePaymentRequested)),Promise.race([i._paymentRequestSender.initializeOffsitePayment(l,o),s].filter(Boolean)).then((function(){return(0,a.createAction)(nt.InitializeOffsitePaymentSucceeded)}))).pipe((0,I.catchError)((function(e){return er(nt.InitializeOffsitePaymentFailed,e)})))}}}return e.prototype.submitPayment=function(e){var t=this;return function(n){return(0,S.concat)((0,S.of)((0,a.createAction)(nt.SubmitPaymentRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(e,n.getState()))];case 1:case 4:return[2,i.sent()];case 2:return t=i.sent(),[4,this._paymentHumanVerificationHandler.handle(t)];case 3:return r=i.sent(),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform((0,o.__assign)((0,o.__assign)({},e),{additionalAction:r}),n.getState()))];case 5:return[2]}}))}))})).pipe((0,I.switchMap)((function(e){var r=e.body;return(0,S.concat)(t._orderActionCreator.loadCurrentOrder()(n),(0,S.of)((0,a.createAction)(nt.SubmitPaymentSucceeded,r)))})))).pipe((0,I.catchError)((function(e){return er(nt.SubmitPaymentFailed,e)})))}},e}(),ai=function(){function e(e){this._client=e}return e.prototype.submitPayment=function(e){var t=this;return new Promise((function(n,r){t._client.submitPayment(e,(function(e,i){e?r(t._transformResponse(e)):n(t._transformResponse(i))}))}))},e.prototype.initializeOffsitePayment=function(e,t){var n=this;return new Promise((function(){n._client.initializeOffsitePayment(e,null,t)}))},e.prototype._transformResponse=function(e){return{headers:e.headers,body:e.data,status:e.status,statusText:e.statusText}},e}(),si=require("@bigcommerce/bigpay-client");function ui(e,t){var n;return function(e){return void 0!==e.id}(e)?n=e.id:t&&t.length&&(n=t[0].id),{id:n,firstName:e.firstName,lastName:e.lastName,company:e.company,addressLine1:e.address1,addressLine2:e.address2,city:e.city,province:e.stateOrProvince,provinceCode:e.stateOrProvinceCode,postCode:e.postalCode,country:e.country,countryCode:e.countryCode,phone:e.phone,customFields:e.customFields}}const ci=function(){function e(e){this._decimalPlaces=e}return e.prototype.toInteger=function(e){return Math.round(e*Math.pow(10,this._decimalPlaces))},e}();var di,li=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function pi(e){return{code:e.code,discount:e.displayName,discountType:li.indexOf(e.couponType)}}function hi(e){return{code:e.code,discountedAmount:e.used,remainingBalance:e.remaining,giftCertificate:{balance:e.balance,code:e.code,purchaseDate:e.purchaseDate}}}function fi(e,t,n){return void 0===n&&(n="id"),Object.keys(e).reduce((function(r,i){return(0,o.__spreadArrays)(r,e[i].map((function(e){return"giftCertificates"===i?function(e,t){var n=new ci(t);return{id:e.id,imageUrl:"",name:e.name,amount:e.amount,amountAfterDiscount:e.amount,discount:0,integerAmount:n.toInteger(e.amount),integerAmountAfterDiscount:n.toInteger(e.amount),integerUnitPrice:n.toInteger(e.amount),integerUnitPriceAfterDiscount:n.toInteger(e.amount),integerDiscount:0,quantity:1,sender:e.sender,recipient:e.recipient,type:"ItemGiftCertificateEntity",attributes:[],variantId:null}}(e,t):function(e,t,n,r){void 0===r&&(r="id");var i=new ci(n);return{id:e[r],imageUrl:e.imageUrl,amount:e.extendedListPrice,amountAfterDiscount:e.extendedSalePrice,discount:e.discountAmount,integerAmount:i.toInteger(e.extendedListPrice),integerAmountAfterDiscount:i.toInteger(e.extendedSalePrice),integerDiscount:i.toInteger(e.discountAmount),integerUnitPrice:i.toInteger(e.listPrice),integerUnitPriceAfterDiscount:i.toInteger(e.salePrice),downloadsPageUrl:e.downloadPageUrl,name:e.name,quantity:e.quantity,brand:e.brand,sku:e.sku,categoryNames:e.categoryNames,variantId:e.variantId,productId:e.productId,attributes:(e.options||[]).map((function(e){return{name:e.name,value:e.value}})),addedByPromotion:e.addedByPromotion,type:t}}(e,function(e){switch(e){case"physicalItems":return"ItemPhysicalEntity";case"digitalItems":return"ItemDigitalEntity";case"giftCertificates":return"ItemGiftCertificateEntity";default:return""}}(i),t,n)})))}),[])}function mi(e){var t,n,r=e.cart.currency.decimalPlaces,i=new ci(r);return{id:e.cart.id,items:fi(e.cart.lineItems,r),currency:e.cart.currency.code,coupon:{discountedAmount:(0,m.reduce)(e.cart.coupons,(function(e,t){return e+t.discountedAmount}),0),coupons:e.cart.coupons.map(pi)},discount:{amount:e.cart.discountAmount,integerAmount:i.toInteger(e.cart.discountAmount)},discountNotifications:(t=e.promotions,n=[],(t||[]).forEach((function(e){(e.banners||[]).forEach((function(e){n.push({placeholders:[],discountType:null,message:"",messageHtml:e.text})}))})),n),giftCertificate:{totalDiscountedAmount:(0,m.reduce)(e.giftCertificates,(function(e,t){return e+t.used}),0),appliedGiftCertificates:(0,m.keyBy)(e.giftCertificates.map(hi),"code")},shipping:{amount:e.shippingCostTotal,integerAmount:i.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(e.shippingCostBeforeDiscount),required:(0,m.some)(e.cart.lineItems.physicalItems,(function(e){return e.isShippingRequired}))},subtotal:{amount:e.subtotal,integerAmount:i.toInteger(e.subtotal)},storeCredit:{amount:e.customer?e.customer.storeCredit:0},taxSubtotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:i.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.grandTotal,integerAmount:i.toInteger(e.grandTotal)}}}!function(e){e.APPLEPAY="applepay",e.AMAZON_PAY_V2="amazonpay",e.BRAINTREE_PAYPAL="braintreepaypal",e.BRAINTREE_VENMO="braintreevenmo",e.BRAINTREE_PAYPAL_CREDIT="braintreepaypalcredit",e.GOOGLEPAY_ADYENV2="googlepayadyenv2",e.GOOGLEPAY_ADYENV3="googlepayadyenv3",e.GOOGLEPAY_AUTHORIZENET="googlepayauthorizenet",e.GOOGLEPAY_BNZ="googlepaybnz",e.GOOGLEPAY_BRAINTREE="googlepaybraintree",e.GOOGLEPAY_CHECKOUTCOM="googlepaycheckoutcom",e.GOOGLEPAY_CYBERSOURCEV2="googlepaycybersourcev2",e.GOOGLEPAY_ORBITAL="googlepayorbital",e.GOOGLEPAY_STRIPE="googlepaystripe",e.GOOGLEPAY_STRIPEUPE="googlepaystripeupe",e.GOOGLEPAY_WORLDPAYACCESS="googlepayworldpayaccess",e.MASTERPASS="masterpass",e.PAYPALEXPRESS="paypalexpress"}(di||(di={}));const gi=di;function yi(e,t){var n=e.firstName||t.firstName||"",r=e.lastName||t.lastName||"";return{addresses:(e.addresses||[]).map((function(e){return ui(e)})),customerId:e.id,isGuest:e.isGuest,storeCredit:e.storeCredit,email:e.email||t.email||"",firstName:n,lastName:r,name:e.fullName||[n,r].join(" "),customerGroupName:e.customerGroup&&e.customerGroup.name}}const _i=function(){function e(){}return e.prototype.format=function(e){var t=e.split(new RegExp("\\s*/\\s*")),n=t[0],r=void 0===n?"":n,i=t[1],o=void 0===i?"":i,a=r.slice(0,2),s=4===o.length?o.slice(-2):o?o.slice(0,2):r.slice(2);return e.length<2?r:e.length>3&&!s?a:a+" / "+s},e.prototype.toObject=function(e){var t=e.split(new RegExp("\\s*/\\s*")),n=t[0],r=void 0===n?"":n,i=t[1],o=void 0===i?"":i;return/^\d+$/.test(r)&&/^\d+$/.test(o)?{month:1===r.length?"0"+r:r.slice(0,2),year:2===o.length?"20"+o:o.slice(0,4)}:{month:"",year:""}},e}(),vi=require("card-validator"),Ci=function(){function e(){}return e.prototype.format=function(e){var t=(0,vi.number)(e).card;if(!t)return e;var n=(0,m.max)((0,vi.creditCardType)(e).map((function(e){return(0,m.max)(e.lengths)}))),r=this.unformat(e).slice(0,n);return t.gaps.filter((function(e){return r.length>e})).reduce((function(e,t,n){return[e.slice(0,t+n),e.slice(t+n)].join(" ")}),r)},e.prototype.unformat=function(e){return(0,vi.number)(e).card?e.replace(new RegExp(" ","g"),""):e},e}();function Si(e,t){void 0===t&&(t={});var n,r,i=e.currency.decimalPlaces,o=new ci(i);return{id:e.orderId,items:fi(e.lineItems,e.currency.decimalPlaces,"productId"),orderId:e.orderId,currency:e.currency.code,customerCanBeCreated:e.customerCanBeCreated,payment:wi(e.payments,t.payment),subtotal:{amount:e.baseAmount,integerAmount:o.toInteger(e.baseAmount)},coupon:{discountedAmount:(0,m.reduce)(e.coupons,(function(e,t){return e+t.discountedAmount}),0),coupons:e.coupons.map(pi)},discount:{amount:e.discountAmount,integerAmount:o.toInteger(e.discountAmount)},token:t.orderToken,callbackUrl:t.callbackUrl,discountNotifications:[],giftCertificate:(n=e.payments,r=(0,m.filter)(n,{providerId:"giftcertificate"}),{totalDiscountedAmount:(0,m.reduce)(r,(function(e,t){return t.amount+e}),0),appliedGiftCertificates:(0,m.keyBy)(r.map((function(e){return{code:e.detail.code,discountedAmount:e.amount,remainingBalance:e.detail.remaining,giftCertificate:{balance:e.amount+e.detail.remaining,code:e.detail.code,purchaseDate:""}}})),"code")}),socialData:bi(e),status:e.status,hasDigitalItems:e.hasDigitalItems,isDownloadable:e.isDownloadable,isComplete:e.isComplete,shipping:{amount:e.shippingCostTotal,integerAmount:o.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:o.toInteger(e.shippingCostBeforeDiscount)},storeCredit:{amount:Ii(e.payments)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:o.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:o.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.orderAmount,integerAmount:e.orderAmountAsInteger}}}function Ii(e){var t=(0,m.find)(e,{providerId:"storecredit"});return t?t.amount:0}function wi(e,t){void 0===t&&(t={});var n,r=(0,m.find)(e,Ei);return r?{id:r.providerId,status:(n=r.detail.step,"PAYMENT_STATUS_"+n),helpText:r.detail.instructions,returnUrl:t.returnUrl}:{}}function Ei(e){return"giftcertificate"!==e.providerId&&"storecredit"!==e.providerId}function bi(e){var t={};return(0,o.__spreadArrays)(e.lineItems.physicalItems,e.lineItems.digitalItems).forEach((function(e){var n;t[e.id]=(n=e,["fb","tw","gp"].reduce((function(e,t){var r=n.socialMedia&&(0,m.find)(n.socialMedia,(function(e){return e.code===t}));return r?(e[t]={name:n.name,description:n.name,image:n.imageUrl,url:r.link,shareText:r.text,sharingLink:r.link,channelName:r.channel,channelCode:r.code},e):e}),{}))})),t}function Pi(e,t){return{description:e.description,module:e.type,price:e.cost,id:e.id,selected:t,isRecommended:e.isRecommended,imageUrl:e.imageUrl,transitTime:e.transitTime}}const Ai=function(){function e(){this._cardExpiryFormatter=new _i,this._cardNumberFormatter=new Ci}return e.prototype.transform=function(e,t){var n,r=t.billingAddress.getBillingAddress(),i=t.checkout.getCheckout(),a=t.customer.getCustomer(),s=t.order.getOrder(),u=t.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),c=this._mapShippingAddress(t,u),d=t.consignments.getConsignments(),l=t.consignments.getShippingOption(),p=t.config.getStoreConfig(),h=t.config.getContextConfig(),f=t.instruments.getInstrumentsMeta(),g=t.paymentMethods.getPaymentMethodsMeta(),y=t.order.getOrderMeta(),_=a&&r&&yi(a,r),v=f&&e.paymentData&&(Qr(e.paymentData)||(n=e.paymentData.formattedPayload)&&("string"==typeof n.bigpay_token||Boolean(n.bigpay_token&&n.bigpay_token.token)))?t.payment.getPaymentToken()+", "+f.vaultAccessToken:t.payment.getPaymentToken();if(!v)throw new Mn(Rn.MissingPaymentToken);return{additionalAction:e.additionalAction,authToken:v,customer:_,billingAddress:r&&ui(r),shippingAddress:c&&ui(c,d),shippingOption:l&&Pi(l,!0),cart:i&&mi(i),order:s&&Si(s,y),orderMeta:y,payment:e.paymentData,paymentMethod:u&&this._transformPaymentMethod(u),quoteMeta:{request:(0,o.__assign)((0,o.__assign)({},g),{geoCountryCode:h&&h.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:(0,m.pick)(p&&p.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},e.prototype.transformWithHostedFormData=function(e,t,n){var r=t.additionalAction,i=t.authToken,a=t.checkout,s=t.config,u=t.order,c=t.orderMeta,d=t.payment,l=void 0===d?{}:d,p=t.paymentMethod,h=t.paymentMethodMeta,f=a&&a.consignments[0],g=f&&f.shippingAddress,y=f&&f.selectedShippingOption;return{additionalAction:r,authToken:i,paymentMethod:p&&this._transformPaymentMethod(p),customer:u&&u.billingAddress&&a&&yi(a.customer,u.billingAddress),billingAddress:u&&u.billingAddress&&ui(u.billingAddress),shippingAddress:g&&a&&ui(g,a.consignments),shippingOption:y&&Pi(y,!0),cart:a&&mi(a),order:u&&Si(u,c),orderMeta:c,payment:this._transformHostedInputValues(e,l,n),quoteMeta:{request:(0,o.__assign)((0,o.__assign)({},h),{geoCountryCode:s&&s.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:s&&(0,m.pick)(s.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},e.prototype._transformPaymentMethod=function(e){return"multi-option"!==e.method||e.gateway?e.initializationData&&e.initializationData.gateway?(0,o.__assign)((0,o.__assign)({},e),{id:e.initializationData.gateway}):e.id===gi.BRAINTREE_VENMO?(0,o.__assign)((0,o.__assign)({},e),{id:gi.BRAINTREE_PAYPAL}):e:(0,o.__assign)((0,o.__assign)({},e),{gateway:e.id})},e.prototype._transformHostedInputValues=function(e,t,n){return"instrumentId"in t?(0,o.__assign)((0,o.__assign)({},t),{ccCvv:e.cardCodeVerification,ccNumber:e.cardNumberVerification&&this._cardNumberFormatter.unformat(e.cardNumberVerification),hostedFormNonce:n}):(0,o.__assign)((0,o.__assign)({},t),{ccCvv:e.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(e.cardExpiry||""),ccName:e.cardName||"",ccNumber:this._cardNumberFormatter.unformat(e.cardNumber||""),hostedFormNonce:n})},e.prototype._mapShippingAddress=function(e,t){var n,r,i,o;if(t){var a=null===(r=null===(n=t.initializationData)||void 0===n?void 0:n.bopis)||void 0===r?void 0:r.enabled,s=null===(o=null===(i=t.initializationData)||void 0===i?void 0:i.bopis)||void 0===o?void 0:o.requiredAddress,u=e.consignments.getConsignments(),c=null==u?void 0:u.every((function(e){return e.selectedPickupOption}));if(a&&c&&"none"===s)return}return e.shippingAddress.getShippingAddress()},e}(),Ti=function(){function e(){}return e.prototype.updatePaymentProviderCustomer=function(e){return(0,S.of)((0,a.createAction)(gt.UpdatePaymentProviderCustomer,e))},e}(),Oi=function(){function e(e,t){this._remoteCheckoutRequestSender=e,this._checkoutActionCreator=t}return e.prototype.initializeBilling=function(e,t,n){var r=this;return S.Observable.create((function(i){i.next((0,a.createAction)(Pt.InitializeRemoteBillingRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializeBilling(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Pt.InitializeRemoteBillingSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Pt.InitializeRemoteBillingFailed,t,{methodId:e}))}))}))},e.prototype.initializeShipping=function(e,t,n){var r=this;return S.Observable.create((function(i){i.next((0,a.createAction)(Pt.InitializeRemoteShippingRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializeShipping(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Pt.InitializeRemoteShippingSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Pt.InitializeRemoteShippingFailed,t,{methodId:e}))}))}))},e.prototype.initializePayment=function(e,t,n){var r=this;return S.Observable.create((function(i){i.next((0,a.createAction)(Pt.InitializeRemotePaymentRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializePayment(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Pt.InitializeRemotePaymentSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Pt.InitializeRemotePaymentFailed,t,{methodId:e}))}))}))},e.prototype.loadSettings=function(e,t){var n=this;return S.Observable.create((function(r){r.next((0,a.createAction)(Pt.LoadRemoteSettingsRequested,void 0,{methodId:e})),n._remoteCheckoutRequestSender.loadSettings(e,t).then((function(t){var n=t.body;r.next((0,a.createAction)(Pt.LoadRemoteSettingsSucceeded,n,{methodId:e})),r.complete()})).catch((function(t){r.error((0,a.createErrorAction)(Pt.LoadRemoteSettingsFailed,t,{methodId:e}))}))}))},e.prototype.signOut=function(e,t){var n=this;return S.Observable.create((function(r){r.next((0,a.createAction)(Pt.SignOutRemoteCustomerRequested,void 0,{methodId:e})),n._remoteCheckoutRequestSender.signOut(e,t).then((function(){r.next((0,a.createAction)(Pt.SignOutRemoteCustomerSucceeded,void 0,{methodId:e})),r.complete()})).catch((function(t){r.error((0,a.createErrorAction)(Pt.SignOutRemoteCustomerFailed,t,{methodId:e}))}))}))},e.prototype.forgetCheckout=function(e,t){var n=this;return(0,S.concat)((0,S.of)((0,a.createAction)(Pt.ForgetCheckoutRemoteCustomerRequested,void 0,{methodId:e})),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._remoteCheckoutRequestSender.forgetCheckout(t)];case 1:return n.sent(),[4,this._checkoutActionCreator.loadCurrentCheckout()];case 2:return n.sent(),[2,(0,a.createAction)(Pt.ForgetCheckoutRemoteCustomerSucceeded,void 0,{methodId:e})]}}))}))}))).pipe((0,I.catchError)((function(t){return er(Pt.ForgetCheckoutRemoteCustomerFailed,t,{methodId:e})})))},e.prototype.updateCheckout=function(e,t){return(0,a.createAction)(Pt.UpdateRemoteCheckout,t,{methodId:e})},e}(),Ri=function(){function e(e){this._requestSender=e}return e.prototype.initializeBilling=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/billing";return this._requestSender.get(i,{params:t,timeout:r,headers:Qn})},e.prototype.initializeShipping=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/shipping";return this._requestSender.get(i,{params:t,timeout:r,headers:Qn})},e.prototype.initializePayment=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/payment";return this._requestSender.get(i,{params:t,timeout:r,headers:Qn})},e.prototype.loadSettings=function(e,t){var n=(void 0===t?{}:t).timeout,r="/remote-checkout/"+e+"/settings";return this._requestSender.get(r,{timeout:n,headers:Qn})},e.prototype.signOut=function(e,t){var n=(void 0===t?{}:t).timeout,r="/remote-checkout/"+e+"/signout";return this._requestSender.get(r,{timeout:n,headers:Qn})},e.prototype.generateToken=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.get("/remote-checkout-token",{timeout:t,headers:Qn})},e.prototype.trackAuthorizationEvent=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.post("/remote-checkout/events/shopper-checkout-service-provider-authorization-requested",{timeout:t,headers:Qn})},e.prototype.forgetCheckout=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.post("/remote-checkout/forget-checkout",{timeout:t,headers:Qn})},e}();var Mi;!function(e){e.AvailableShippingOptions="consignments.availableShippingOptions",e.PhysicalItemsCategoryNames="cart.lineItems.physicalItems.categoryNames",e.DigitalItemsCategoryNames="cart.lineItems.digitalItems.categoryNames"}(Mi||(Mi={}));const ki=function(){function e(e,t){this._consignmentRequestSender=e,this._checkoutRequestSender=t}return e.prototype.unassignItemsByAddress=function(e,t){var n=this;return function(r){var i=r.getState();if(!i.checkout.getCheckout())throw new Mn(Rn.MissingCheckout);var o=n._consignmentHasAddress(e)?e.address:e.shippingAddress,a=i.consignments.getConsignmentByAddress(o);if(!a)throw new Pr("No consignment found for the specified address");var s=n._removeLineItems(e.lineItems,a,i.cart.getCart());return s.length?n.updateConsignment({id:a.id,address:o,lineItems:s},t)(r):n.deleteConsignment(a.id,t)(r)}},e.prototype.assignItemsByAddress=function(e,t){var n=this;return function(r){var i=r.getState(),o=n._consignmentHasAddress(e)?e.address:e.shippingAddress,a=i.consignments.getConsignmentByAddress(o);return n._createOrUpdateConsignment({id:a&&a.id,address:o,lineItems:n._addLineItems(e.lineItems,a,i.cart.getCart())},t)(r)}},e.prototype.selectShippingOption=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState(),s=o.checkout.getCheckout(),u=o.consignments.getConsignments();if(!s)throw new Mn(Rn.MissingCheckout);if(!u||!u.length)throw new Mn(Rn.MissingConsignments);var c={id:u[0].id,shippingOptionId:e},d={id:u[0].id};i.next((0,a.createAction)(x.UpdateShippingOptionRequested,void 0,d)),n._consignmentRequestSender.updateConsignment(s.id,c,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.UpdateShippingOptionSucceeded,t,d)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.UpdateShippingOptionFailed,e,d))}))}))}},e.prototype.loadShippingOptions=function(e){var t=this;return function(n){return S.Observable.create((function(r){var i=n.getState().checkout.getCheckout();if(!i)throw new Mn(Rn.MissingCheckout);r.next((0,a.createAction)(x.LoadShippingOptionsRequested)),t._checkoutRequestSender.loadCheckout(i.id,(0,o.__assign)((0,o.__assign)({},e),{params:{include:[Mi.AvailableShippingOptions]}})).then((function(e){var t=e.body;r.next((0,a.createAction)(x.LoadShippingOptionsSucceeded,t)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(x.LoadShippingOptionsFailed,e))}))}))}},e.prototype.updateAddress=function(e,t){var n=this;return function(r){var i=n._getUpdateAddressRequestBody(e,r),o=r.getState().consignments.getConsignments();return o&&o.length&&(i.id=o[0].id),n._createOrUpdateConsignment(i,t)(r)}},e.prototype.createConsignments=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Mn(Rn.MissingCheckout);i.next((0,a.createAction)(x.CreateConsignmentsRequested)),n._consignmentRequestSender.createConsignments(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.CreateConsignmentsSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.CreateConsignmentsFailed,e))}))}))}},e.prototype.updateConsignment=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Mn(Rn.MissingCheckout);var s={id:e.id};i.next((0,a.createAction)(x.UpdateConsignmentRequested,void 0,s)),n._consignmentRequestSender.updateConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.UpdateConsignmentSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.UpdateConsignmentFailed,e,s))}))}))}},e.prototype.deleteConsignment=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState().checkout.getCheckout(),s={id:e};if(!o||!o.id)throw new Mn(Rn.MissingCheckout);i.next((0,a.createAction)(x.DeleteConsignmentRequested,void 0,s)),n._consignmentRequestSender.deleteConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.DeleteConsignmentSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.DeleteConsignmentFailed,e,s))}))}))}},e.prototype.updateShippingOption=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Mn(Rn.MissingCheckout);var s={id:e.id};i.next((0,a.createAction)(x.UpdateShippingOptionRequested,void 0,s)),n._consignmentRequestSender.updateConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.UpdateShippingOptionSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.UpdateShippingOptionFailed,e,s))}))}))}},e.prototype._createOrUpdateConsignment=function(e,t){var n=this;return function(r){var i=r.getState().checkout.getCheckout();if(!i||!i.id)throw new Mn(Rn.MissingCheckout);return n._isUpdateConsignmentRequest(e)?n.updateConsignment(e,t)(r):n.createConsignments([e],t)(r)}},e.prototype._getUpdateAddressRequestBody=function(e,t){var n=t.getState().cart.getCart();if(!n)throw new Mn(Rn.MissingCart);var r=n.lineItems,i=r.physicalItems,a=r.customItems,s=void 0===a?[]:a;return{address:e,lineItems:(0,o.__spreadArrays)(i,s).map((function(e){return{itemId:e.id,quantity:e.quantity}}))}},e.prototype._removeLineItems=function(e,t,n){if(!n)throw new Mn(Rn.MissingCart);return this._hydrateLineItems(t.lineItemIds,n).map((function(t){var n=(0,m.find)(e,(function(e){return e.itemId===t.itemId}));return(0,o.__assign)((0,o.__assign)({},t),{quantity:n?t.quantity-n.quantity:t.quantity})})).filter((function(e){return e.quantity>0}))},e.prototype._addLineItems=function(e,t,n){if(!t)return e;if(!n)throw new Mn(Rn.MissingCart);return e.concat(this._hydrateLineItems(t.lineItemIds,n)).filter((function(e){return e.quantity>0}))},e.prototype._hydrateLineItems=function(e,t){return e.map((function(e){var n=(0,m.find)(t.lineItems.physicalItems,(function(t){return t.id===e}));return{itemId:e,quantity:n?n.quantity:0}}))},e.prototype._isUpdateConsignmentRequest=function(e){return!!e.id},e.prototype._consignmentHasAddress=function(e){return"object"==typeof e&&"address"in e},e}();var Di=["consignments.availableShippingOptions","cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","promotions.banners"];const Ni=function(){function e(e){this._requestSender=e}return e.prototype.createConsignments=function(e,t,n){var r=void 0===n?{}:n,i=r.timeout,a=r.params,s=(void 0===a?{}:a).include,u="/api/storefront/checkouts/"+e+"/consignments",c=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post(u,{body:t,params:{include:ur(Di,s)},headers:c,timeout:i})},e.prototype.updateConsignment=function(e,t,n){var r=void 0===n?{}:n,i=r.timeout,a=r.params,s=(void 0===a?{}:a).include,u=t.id,c=(0,o.__rest)(t,["id"]),d="/api/storefront/checkouts/"+e+"/consignments/"+u,l=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.put(d,{body:c,params:{include:ur(Di,s)},headers:l,timeout:i})},e.prototype.deleteConsignment=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/consignments/"+t,a=(0,o.__assign)({Accept:Jn.JsonV1},Qn),s=sr(Di);return this._requestSender.delete(i,{params:{include:s},headers:a,timeout:r})},e}(),Li=function(){function e(e){this._shippingCountryRequestSender=e}return e.prototype.loadCountries=function(e){var t=this;return S.Observable.create((function(n){n.next((0,a.createAction)(Vt.LoadShippingCountriesRequested)),t._shippingCountryRequestSender.loadCountries(e).then((function(e){n.next((0,a.createAction)(Vt.LoadShippingCountriesSucceeded,e.body.data)),n.complete()})).catch((function(e){n.error((0,a.createErrorAction)(Vt.LoadShippingCountriesFailed,e))}))}))},e}(),zi=function(){function e(e,t){this._requestSender=e,this._config=t}return e.prototype.loadCountries=function(e){var t=(void 0===e?{}:e).timeout,n=(0,o.__assign)({"Accept-Language":this._config.locale},Qn);return this._requestSender.get("/internalapi/v1/shipping/countries",{headers:n,timeout:t})},e}(),Fi=function(){function e(e,t){this._googleRecaptcha=e,this._requestSender=t}return e.prototype.initialize=function(e){var t=this;return function(n){return(0,S.concat)((0,S.of)((0,a.createAction)(vn.InitializeRequested,void 0)),(0,S.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r,i,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t=e?e.containerId:"spamProtectionContainer",e||document.getElementById(t)||((r=document.createElement("div")).setAttribute("id",t),document.body.appendChild(r)),i=n.getState(),s=i.config.getStoreConfigOrThrow(),u=s.checkoutSettings.googleRecaptchaSitekey,[4,this._googleRecaptcha.load(t,u)];case 1:return o.sent(),[2,(0,a.createAction)(vn.InitializeSucceeded)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(vn.InitializeFailed,e)})))}},e.prototype.verifyCheckoutSpamProtection=function(){var e=this;return function(t){return(0,S.defer)((function(){var n=t.getState().checkout.getCheckout();if(!n)throw new Mn(Rn.MissingCheckout);return(0,S.concat)((0,S.of)((0,a.createAction)(vn.VerifyCheckoutRequested)),(0,S.from)(e.execute()(t)).pipe((0,I.switchMap)((function(t){return yr(t)&&t.payload?(0,S.from)(e._requestSender.validate(n.id,t.payload.token)).pipe((0,I.switchMap)((function(e){var n=e.body;return(0,S.concat)((0,S.of)(t),(0,S.of)((0,a.createAction)(vn.VerifyCheckoutSucceeded,n)))}))):(0,S.of)(t)})))).pipe((0,I.catchError)((function(e){return er(vn.VerifyCheckoutFailed,e)})))}))}},e.prototype.execute=function(){var e=this;return function(t){return(0,S.concat)((0,S.of)((0,a.createAction)(vn.ExecuteRequested)),e.initialize()(t),e._googleRecaptcha.execute().pipe((0,I.take)(1)).pipe((0,I.switchMap)((function(t){var n=t.error,r=t.token;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){if(n instanceof Dr)throw n;if(n||!r)throw new qr;return[2,(0,a.createAction)(vn.ExecuteSucceeded,{token:r})]}))}))})))).pipe((0,I.catchError)((function(e){return er(vn.ExecuteFailed,e)})))}},e}(),Ui=function(){function e(e){this._requestSender=e}return e.prototype.validate=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/spam-protection",a=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post(i,{body:{token:t},headers:a,timeout:r})},e}(),qi=function(){function e(e){this._storeCreditRequestSender=e}return e.prototype.applyStoreCredit=function(e,t){var n=this;return function(r){return(0,S.concat)((0,S.of)((0,a.createAction)(cn.ApplyStoreCreditRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n,i,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=r.getState(),!(i=n.checkout.getCheckout()))throw new Mn(Rn.MissingCheckout);return[4,e?this._storeCreditRequestSender.applyStoreCredit(i.id,t):this._storeCreditRequestSender.removeStoreCredit(i.id,t)];case 1:return s=o.sent().body,[2,(0,a.createAction)(cn.ApplyStoreCreditSucceeded,s)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(cn.ApplyStoreCreditFailed,e)})))}},e}(),Bi=function(){function e(e){this._requestSender=e}return e.prototype.applyStoreCredit=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/checkouts/"+e+"/store-credit",i=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post(r,{headers:i,timeout:n,params:{include:sr(cr)}})},e.prototype.removeStoreCredit=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/checkouts/"+e+"/store-credit",i=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.delete(r,{headers:i,timeout:n,params:{include:sr(cr)}})},e}(),Gi=function(e){function t(t){var n=e.call(this,t)||this;return n.name="UpdateSubscriptionsError",n.type="update_subscriptions",n}return(0,o.__extends)(t,e),t}(h),xi=function(){function e(e){this._subscriptionsRequestSender=e}return e.prototype.updateSubscriptions=function(e,t){var n=this;return(0,S.concat)((0,S.of)((0,a.createAction)(b.UpdateSubscriptionsRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._subscriptionsRequestSender.updateSubscriptions(e,t)];case 1:return n=r.sent().body,[2,(0,a.createAction)(b.UpdateSubscriptionsSucceeded,n)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(b.UpdateSubscriptionsFailed,new Gi(e))})))},e}(),Yi=function(){function e(e){this._requestSender=e}return e.prototype.updateSubscriptions=function(e,t){var n=(void 0===t?{}:t).timeout,r=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post("/api/storefront/subscriptions",{body:e,headers:r,timeout:n})},e}();var Vi=(0,m.memoize)((function(e){return Array.isArray(e)?e.map((function(e){return Hi(e)})):F(e)?Object.keys(e).reduce((function(t,n){var r;return(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Hi(e[n]),r))}),{}):e}));Vi.cache=new WeakMap;var Hi=function(e){return"object"==typeof e&&null!==e?Vi(e):e};function ji(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Hi(e.apply(void 0,t))}}function Wi(e){var t=e.billingAddress,n=t.getBillingAddress,r=t.getBillingAddressOrThrow,i=e.cart,o=i.getCart,a=i.getCartOrThrow,s=e.checkout,u=s.getCheckout,c=s.getCheckoutOrThrow,d=s.getOutstandingBalance,l=e.config,p=l.getContextConfig,h=l.getHost,f=l.getLocale,m=l.getStoreConfig,g=l.getStoreConfigOrThrow,y=e.consignments,_=y.getConsignments,v=y.getConsignmentsOrThrow,C=e.countries.getCountries,S=e.customer,I=S.getCustomer,w=S.getCustomerOrThrow,E=e.instruments,b=E.getCardInstrument,P=E.getCardInstrumentOrThrow,A=E.getInstruments,T=e.order,O=T.getOrder,R=T.getOrderOrThrow,M=e.payment,k=M.getPaymentToken,D=M.getPaymentTokenOrThrow,N=M.getPaymentId,L=M.getPaymentIdOrThrow,z=M.getPaymentStatus,F=M.getPaymentStatusOrThrow,U=M.getPaymentRedirectUrl,q=M.getPaymentRedirectUrlOrThrow,B=M.isPaymentDataRequired,G=e.paymentMethods,x=G.getPaymentMethod,Y=G.getPaymentMethodOrThrow,V=e.paymentProviderCustomer,H=V.getPaymentProviderCustomer,j=V.getPaymentProviderCustomerOrThrow,W=e.paymentStrategies.isInitialized,K=e.shippingAddress,J=K.getShippingAddress,Z=K.getShippingAddressOrThrow,Q=K.getShippingAddresses,X=K.getShippingAddressesOrThrow,$=e.shippingCountries.getShippingCountries;return{getHost:ji(h),getLocale:ji(f),getBillingAddress:ji(n),getBillingAddressOrThrow:ji(r),getCart:ji(o),getCartOrThrow:ji(a),getCheckout:ji(u),getCheckoutOrThrow:ji(c),getCountries:ji(C),getStoreConfig:ji(m),getStoreConfigOrThrow:ji(g),getConsignments:ji(_),getConsignmentsOrThrow:ji(v),getContextConfig:ji(p),getCustomer:ji(I),getCustomerOrThrow:ji(w),getCardInstrument:ji(b),getInstruments:ji(A),getCardInstrumentOrThrow:ji(P),getOrder:ji(O),getOrderOrThrow:ji(R),getPaymentToken:k,getPaymentTokenOrThrow:D,getPaymentId:N,getPaymentIdOrThrow:L,getPaymentStatus:z,getPaymentStatusOrThrow:F,getPaymentRedirectUrl:U,getPaymentRedirectUrlOrThrow:q,getPaymentMethod:ji(x),getPaymentMethodOrThrow:ji(Y),getPaymentProviderCustomer:ji(H),getPaymentProviderCustomerOrThrow:ji(j),getShippingAddress:ji(J),getShippingAddressOrThrow:ji(Z),getShippingAddresses:ji(Q),getShippingAddressesOrThrow:ji(X),getShippingCountries:ji($),getOutstandingBalance:ji(d),isPaymentDataRequired:B,isPaymentMethodInitialized:W}}const Ki=function(){function e(e,t,n,r,i,o,a,s,u,c,d,l,p,h,f,m,g){this._store=e,this._storeProjectionFactory=t,this._checkoutActionCreator=n,this._checkoutValidator=r,this._hostedFormFactory=i,this._orderActionCreator=o,this._billingAddressActionCreator=a,this._consignmentActionCreator=s,this._paymentMethodActionCreator=u,this._paymentActionCreator=c,this._customerActionCreator=d,this._cartRequestSender=l,this._storeCreditActionCreator=p,this._spamProtectionActionCreator=h,this._paymentProviderCustomerActionCreator=f,this._shippingCountryActionCreator=m,this._remoteCheckoutActionCreator=g,this._storeProjection=this._storeProjectionFactory.create(this._store)}return e.prototype.createHostedForm=function(e,t){return this._hostedFormFactory.create(e,t)},e.prototype.subscribe=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return(t=this._storeProjection).subscribe.apply(t,(0,o.__spreadArrays)([e],n))},e.prototype.getState=function(){return this._storeProjection.getState()},e.prototype.initializeOffsitePayment=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentActionCreator.initializeOffsitePayment(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadCheckout=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e?[4,this._store.dispatch(this._checkoutActionCreator.loadCheckout(e))]:[3,2];case 1:return t.sent(),[3,4];case 2:return[4,this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout())];case 3:t.sent(),t.label=4;case 4:return[2,this._storeProjection.getState()]}}))}))},e.prototype.loadDefaultCheckout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 1:return e.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadPaymentMethod=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadPaymentMethods=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethods(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.submitOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._orderActionCreator.submitOrder(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.submitPayment=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentActionCreator.submitPayment(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.finalizeOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=this._store.getState().order.getOrderOrThrow,[4,this._store.dispatch(this._orderActionCreator.finalizeOrder(t().orderId,e))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updateBillingAddress=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._billingAddressActionCreator.updateAddress(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updateShippingAddress=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.updateAddress(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.selectShippingOption=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.selectShippingOption(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.signInCustomer=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._customerActionCreator.signInCustomer(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.signOutCustomer=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._customerActionCreator.signOutCustomer(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.createBuyNowCart=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._cartRequestSender.createBuyNowCart(e,t)];case 1:return[2,n.sent().body]}}))}))},e.prototype.applyStoreCredit=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._storeCreditActionCreator.applyStoreCredit(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.verifyCheckoutSpamProtection=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return this._store.getState().checkout.getCheckoutOrThrow().shouldExecuteSpamCheck?[4,this._store.dispatch(this._spamProtectionActionCreator.verifyCheckoutSpamProtection())]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2,this._storeProjection.getState()]}}))}))},e.prototype.loadCurrentOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._orderActionCreator.loadCurrentOrder(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updatePaymentProviderCustomer=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentProviderCustomerActionCreator.updatePaymentProviderCustomer(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadShippingCountries=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._shippingCountryActionCreator.loadCountries(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.deleteConsignment=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.deleteConsignment(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.initializePayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.initializePayment(e,t,n))];case 1:return r.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.forgetCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.forgetCheckout(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.validateCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._checkoutValidator.validate(e,t)];case 1:return n.sent(),[2]}}))}))},e}();var Ji;!function(e){e.Synchronize="SYNCHRONIZE"}(Ji||(Ji={}));const Zi=function(){function e(e){this._transformSelectors=e}return e.prototype.create=function(e){return function(e,t){var n=(0,a.createDataStore)((function(e,t){return t.type===Ji.Synchronize?t.payload:e}),e.getState(),{stateTransformer:t});return e.subscribe((function(e){n.dispatch((0,a.createAction)(Ji.Synchronize,e))}),{initial:!1}),n}(e,this._transformSelectors)},e}();const Qi=require("shallowequal");var Xi=e.n(Qi);function $i(e){return Object.prototype.hasOwnProperty.call(e,"cacheKey")}const eo=function(){function e(e){this._lastId=0,this._map={maps:[]},this._usedMaps=[],this._options=(0,o.__assign)({maxSize:0,isEqual:Xi(),onExpire:m.noop},e)}return e.prototype.getKey=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._resolveMap.apply(this,e),r=n.index,i=n.parentMap,o=n.map;return o&&o.cacheKey?o.usedCount++:o=this._generateMap(i,e.slice(r)),this._removeLeastUsedMap(o),o.cacheKey},e.prototype.getUsedCount=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._resolveMap.apply(this,e).map;return n?n.usedCount:0},e.prototype._resolveMap=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0,i=this._map;i.maps.length;){for(var o=!1,a=0;a<i.maps.length;a++){var s=i.maps[a];if(this._options.isEqual(s.value,t[r])){if((e=i.maps).unshift.apply(e,i.maps.splice(a,1)),(0===t.length||r===t.length-1)&&$i(s))return{index:r,map:s,parentMap:i};o=!0,i=s,r++;break}}if(!o)break}return{index:r,parentMap:i}},e.prototype._generateMap=function(e,t){var n,r=0,i=e;do{n={maps:[],parentMap:i,usedCount:1,value:t[r]},i.maps.unshift(n),i=n,r++}while(r<t.length);var o=n;return o.cacheKey=""+ ++this._lastId,o},e.prototype._removeLeastUsedMap=function(e){if(this._options.maxSize){var t=this._usedMaps.indexOf(e);if(this._usedMaps.splice(-1===t?0:t,-1===t?0:1,e),!(this._usedMaps.length<=this._options.maxSize)){var n=this._usedMaps.pop();n&&(this._removeMap(n),this._options.onExpire(n.cacheKey))}}},e.prototype._removeMap=function(e){e.parentMap&&(e.parentMap.maps.splice(e.parentMap.maps.indexOf(e),1),function(e){return Object.prototype.hasOwnProperty.call(e,"parentMap")}(e.parentMap)||this._removeMap(e.parentMap))},e}();function to(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,o.__extends)(t,e),t}(e);return Object.getOwnPropertyNames(e.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,function(e,t,n){if("function"!=typeof n.value)return n;var r=new eo,i=n.value,a=(0,On.memoize)(i);return Rr(e,t,{get:function(){var e=this,s=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var s=a.call.apply(a,(0,o.__spreadArrays)([e],t));if(1===r.getUsedCount.apply(r,t))return s;var u=i.call.apply(i,(0,o.__spreadArrays)([e],t));return O(u,s,{keyFilter:function(e){return!function(e){return 0===(""+e).indexOf("$$")||0===(""+e).indexOf("_")}(e)}})?s:(a.cache.set(r.getKey.apply(r,t),u),u)};return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:s})),s},set:function(e){r=new eo,i=e,a=(0,On.memoize)(i)}})}(e.prototype,n,r))})),t}const no=function(){function e(e){this._checkoutButton=e.checkoutButton}return e.prototype.getInitializeButtonError=function(e){return this._checkoutButton.getInitializeError(e)},e.prototype.getDeinitializeButtonError=function(e){return this._checkoutButton.getDeinitializeError(e)},(0,o.__decorate)([to],e)}(),ro=function(){function e(e){this._checkoutButton=e.checkoutButton}return e.prototype.isInitializingButton=function(e){return this._checkoutButton.isInitializing(e)},e.prototype.isDeinitializingButton=function(e){return this._checkoutButton.isDeinitializing(e)},(0,o.__decorate)([to],e)}();function io(e){return{errors:new no(e),statuses:new ro(e)}}const oo=function(){function e(e,t){var n=this;this._store=e,this._buttonStrategyActionCreator=t,this._state=io(this._store.getState()),this._store.subscribe((function(e){n._state=io(e)}))}return e.prototype.getState=function(){return this._state},e.prototype.subscribe=function(e){for(var t,n=this,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(t=this._store).subscribe.apply(t,(0,o.__spreadArrays)([function(){return e(n.getState())},function(e){return e.checkoutButton.getState()}],r.map((function(e){return function(t){return e(io(t))}}))))},e.prototype.initializeButton=function(e){var t,n=this,r=(t=e.containerId,/^\w[\w\-\:\.]*$/.test(t)?[e.containerId]:function(e,t){var n=document.querySelectorAll(e);if(!n.length)throw new Pr("Unable to find any element with the specified selector: "+e);return Array.prototype.slice.call(n).map((function(e){return e.id||(e.id=(0,m.uniqueId)(t)),e.id}))}(e.containerId,e.methodId+"-container"));return Promise.all(r.map((function(t){var r=n._buttonStrategyActionCreator.initialize((0,o.__assign)((0,o.__assign)({},e),{containerId:t})),i="checkoutButtonStrategy:"+e.methodId+":"+t;return n._store.dispatch(r,{queueId:i})}))).then((function(){return n.getState()}))},e.prototype.deinitializeButton=function(e){var t=this,n=this._buttonStrategyActionCreator.deinitialize(e),r="checkoutButtonStrategy:"+e.methodId;return this._store.dispatch(n,{queueId:r}).then((function(){return t.getState()}))},(0,o.__decorate)([Rr],e)}(),ao=function(){function e(e,t,n){this._registry=e,this._registryV2=t,this._paymentMethodActionCreator=n}return e.prototype.initialize=function(e){var t=this;return function(n){var r={methodId:e.methodId,containerId:e.containerId};if(n.getState().checkoutButton.isInitialized(e.methodId,e.containerId))return(0,S.empty)();var i=e.currencyCode?{params:{currencyCode:e.currencyCode}}:{},s=(0,o.__assign)((0,o.__assign)({},i),{timeout:e.timeout,useCache:!0});return(0,S.concat)((0,S.of)((0,a.createAction)(Y.InitializeButtonRequested,void 0,r)),t._paymentMethodActionCreator.loadPaymentMethod(e.methodId,s)(n),(0,S.defer)((function(){return t._getStrategy(e.methodId).initialize(e).then((function(){return(0,a.createAction)(Y.InitializeButtonSucceeded,void 0,r)}))}))).pipe((0,I.catchError)((function(e){return er(Y.InitializeButtonFailed,e,r)})))}},e.prototype.deinitialize=function(e){var t=this;return function(n){var r={methodId:e.methodId};return n.getState().checkoutButton.isInitialized(e.methodId)?(0,S.concat)((0,S.of)((0,a.createAction)(Y.DeinitializeButtonRequested,void 0,r)),(0,S.defer)((function(){return t._getStrategy(e.methodId).deinitialize().then((function(){return(0,a.createAction)(Y.DeinitializeButtonSucceeded,void 0,r)}))}))).pipe((0,I.catchError)((function(e){return er(Y.DeinitializeButtonFailed,e,r)}))):(0,S.empty)()}},e.prototype._getStrategy=function(e){var t;try{t=this._registryV2.get({id:e})}catch(n){t=this._registry.get(e)}return t},e}();const so=function(e){function t(t){var n=e.call(this,t||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return(0,o.__extends)(t,e),t}(s);var uo;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(uo||(uo={}));const co=function(e){function t(t){var n=e.call(this,function(e){switch(e){case uo.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case uo.MissingCart:return"Unable to proceed because cart data is unavailable.";case uo.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case uo.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case uo.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case uo.MissingCheckoutConfig:case uo.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case uo.MissingOrder:return"Unable to proceed because order data is unavailable.";case uo.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case uo.MissingPayment:return"Unable to proceed because payment data is unavailable.";case uo.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case uo.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case uo.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(t))||this;return n.subtype=t,n.name="MissingDataError",n.type="missing_data",n}return(0,o.__extends)(t,e),t}(s);function lo(e){return t=e.lineItems.physicalItems.filter((function(e){return!e.addedByPromotion})),(0,m.reduce)(t,(function(e,t){return e+t.quantity}),0);var t}function po(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}var ho;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(ho||(ho={}));const fo=function(e){function t(t){var n=e.call(this,function(e){switch(e){case ho.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case ho.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case ho.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case ho.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(t))||this;return n.subtype=t,n.name="NotInitializedError",n.type="not_initialized",n}return(0,o.__extends)(t,e),t}(s);var mo,go,yo,_o,vo,Co,So={de:"eu",jp:"fe",uk:"eu",us:"na"};!function(e){e.en_US="en_US",e.en_GB="en_GB",e.de_DE="de_DE",e.fr_FR="fr_FR",e.it_IT="it_IT",e.es_ES="es_ES",e.ja_JP="ja_JP"}(mo||(mo={})),function(e){e.Home="Home",e.Product="Product",e.Cart="Cart",e.Checkout="Checkout",e.Other="Other"}(go||(go={})),function(e){e.USD="USD",e.EUR="EUR",e.GBP="GBP",e.JPY="JPY"}(yo||(yo={})),function(e){e.PayAndShip="PayAndShip",e.PayOnly="PayOnly"}(_o||(_o={})),function(e){e.Gold="Gold",e.LightGray="LightGray",e.DarkGray="DarkGray"}(vo||(vo={})),function(e){e.C0001="C0001"}(Co||(Co={}));const Io=function(){function e(e){this.amazonPayV2ScriptLoader=e}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=this,[4,this.amazonPayV2ScriptLoader.load(e)];case 1:return t.amazonPayV2SDK=n.sent(),this.buttonParentContainer=this.buttonParentContainer||this.createAmazonPayButtonParentContainer(),[2]}}))}))},e.prototype.deinitialize=function(){var e;return this.amazonPayV2Button=void 0,null===(e=this.buttonParentContainer)||void 0===e||e.remove(),this.buttonParentContainer=void 0,this.amazonPayV2SDK=void 0,Promise.resolve()},e.prototype.bindButton=function(e,t,n){this.getAmazonPayV2SDK().Pay.bindChangeAction("#"+e,{amazonCheckoutSessionId:t,changeAction:n})},e.prototype.createButton=function(e,t){this.amazonPayV2Button=this.getAmazonPayV2SDK().Pay.renderButton("#"+e,t)},e.prototype.prepareCheckout=function(e){var t=this,n=this.prepareRequestConfig(e);this.getAmazonPayV2Button().onClick((function(){t.getAmazonPayV2Button().initCheckout(n)}))},e.prototype.prepareCheckoutWithCreationRequestConfig=function(e){var t=this;this.getAmazonPayV2Button().onClick((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e()];case 1:return(t=r.sent())&&(n=this.prepareRequestConfig(t.createCheckoutSessionConfig,t.estimatedOrderAmount,t.productType),this.getAmazonPayV2Button().initCheckout(n)),[2]}}))}))}))},e.prototype.signout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return this.amazonPayV2SDK&&this.amazonPayV2SDK.Pay.signout(),[2,Promise.resolve()]}))}))},e.prototype.renderAmazonPayButton=function(e){var t=e.buttonColor,n=e.checkoutState,r=e.containerId,i=e.decoupleCheckoutInitiation,o=void 0!==i&&i,a=e.methodId,s=e.options,u=e.placement,c=document.querySelector("#"+r);if(!c)throw new so("Unable to render the Amazon Pay button to an invalid HTML container element.");var d=c.appendChild(this.getButtonParentContainer()).id;s&&(s.design=Co.C0001);var l=null!=s?s:this.getAmazonPayV2ButtonOptions(n,a,u,o,t);return this.createButton(d,l),this.getButtonParentContainer()},e.prototype.updateBuyNowFlowFlag=function(e){this.isBuyNowFlow=Boolean(e)},e.prototype.isPh4Enabled=function(e,t){var n=!!e["PROJECT-3483.amazon_pay_ph4"],r=!!e["INT-6885.amazon_pay_ph4_us_only"];return n&&r?"US"===t:n},e.prototype.prepareRequestConfig=function(e,t,n){var r=e.publicKeyId,i=(0,o.__rest)(e,["publicKeyId"]);return(0,o.__assign)((0,o.__assign)({createCheckoutSessionConfig:this.isEnvironmentSpecific(r)?i:e},t&&{estimatedOrderAmount:t}),n&&{productType:n})},e.prototype.createAmazonPayButtonParentContainer=function(){var e=Math.random().toString(16).substr(-4),t=document.createElement("div");return t.id="amazonpay_button_parent_container_"+e,t},e.prototype.getAmazonPayV2ButtonOptions=function(e,t,n,r,i){var a,s=e.cart.getCart,u=e.checkout.getCheckout,c=e.config.getStoreConfigOrThrow,d=e.paymentMethods.getPaymentMethodOrThrow;void 0===r&&(r=!1),void 0===i&&(i=vo.Gold);var l=d(t),p=l.config,h=p.merchantId,f=p.testMode,m=l.initializationData;if(!m)throw new co(uo.MissingPaymentMethod);var g=m.checkoutLanguage,y=m.checkoutSessionMethod,_=m.createCheckoutSessionConfig,v=m.extractAmazonCheckoutSessionId,C=m.ledgerCurrency,S=m.publicKeyId,I=void 0===S?"":S;if(!h||!C||!_)throw new co(uo.MissingPaymentMethod);var w={merchantId:h,ledgerCurrency:C,checkoutLanguage:g,placement:n,buttonColor:i,design:Co.C0001};if(this.isBuyNowFlow)return(0,o.__assign)((0,o.__assign)({},w),{sandbox:!!f});var E=s();w.productType=E&&0===lo(E)?_o.PayOnly:_o.PayAndShip;var b=c(),P=b.checkoutSettings.features,A=b.storeProfile,T=A.shopPath,O=A.storeCountryCode;if(this.isPh4Enabled(P,O)){var R=null===(a=u())||void 0===a?void 0:a.outstandingBalance.toString(),M=null==E?void 0:E.currency.code,k=(0,o.__assign)({},w),D=void 0;return this.isEnvironmentSpecific(I)?(k.publicKeyId=I,D=_):(k.sandbox=!!f,D=(0,o.__assign)((0,o.__assign)({},_),{publicKeyId:I})),r||(k.createCheckoutSessionConfig=D),R&&M&&(k.estimatedOrderAmount={amount:R,currencyCode:M}),k}var N={method:y,url:P["INT-5826.amazon_relative_url"]?"/remote-checkout/"+t+"/payment-session":T+"/remote-checkout/"+t+"/payment-session",extractAmazonCheckoutSessionId:v};return(0,o.__assign)((0,o.__assign)({},w),{createCheckoutSession:N,sandbox:!!f})},e.prototype.isEnvironmentSpecific=function(e){return/^(SANDBOX|LIVE)/.test(e)},e.prototype.getAmazonPayV2SDK=function(){return this.getOrThrow(this.amazonPayV2SDK)},e.prototype.getButtonParentContainer=function(){return this.getOrThrow(this.buttonParentContainer)},e.prototype.getAmazonPayV2Button=function(){return this.getOrThrow(this.amazonPayV2Button)},e.prototype.getOrThrow=function(e){return po(e,(function(){return new fo(ho.PaymentNotInitialized)}))},e}(),wo=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method is not loaded or ready to be used.")||this;return n.name="PaymentMethodClientUnavailableError",n.type="payment_method_client_unavailable",n}return(0,o.__extends)(t,e),t}(s),Eo=function(){function e(e,t){void 0===t&&(t=window),this.scriptLoader=e,this.windowWithAmazonPay=t}return e.prototype.load=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return t=e.initializationData,n=(null==t?void 0:t.region)||"us",r=So[n],[4,this.scriptLoader.loadScript("https://static-"+r+".payments-amazon.com/checkout.js")];case 1:if(i.sent(),!this.windowWithAmazonPay.amazon)throw new wo;return[2,this.windowWithAmazonPay.amazon]}}))}))},e}();var bo,Po,Ao,To,Oo,Ro="3.95.0",Mo="3.95.0-connect-alpha.12",ko="3.101.0-fastlane-beta.7.2";!function(e){e.Sandbox="sandbox",e.Production="production"}(bo||(bo={})),function(e){e.Client="client",e.Connect="connect",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(Po||(Po={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(Ao||(Ao={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(To||(To={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Oo||(Oo={}));const Do=function(){function e(e,t){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSdkVersion=Ro}return e.prototype.initialize=function(e){var t=null==e?void 0:e.checkoutSettings.features,n=t&&t["PROJECT-5505.PayPal_Accelerated_Checkout_v2_for_Braintree"],r=t&&t["PROJECT-6266.braintree_fastlane"]?ko:Mo;this.braintreeSdkVersion=n?r:Ro},e.prototype.loadClient=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.Client,"client.min.js")]}))}))},e.prototype.loadConnect=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.Connect,"connect.min.js")]}))}))},e.prototype.loadFastlane=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.Fastlane,"fastlane.min.js")]}))}))},e.prototype.loadPaypalCheckout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.PaypalCheckout,"paypal-checkout.min.js")]}))}))},e.prototype.loadPaypal=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.Paypal,"paypal.min.js")]}))}))},e.prototype.loadBraintreeLocalMethods=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.LocalPayment,"local-payment.min.js")]}))}))},e.prototype.loadDataCollector=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.DataCollector,"data-collector.min.js")]}))}))},e.prototype.loadUsBankAccount=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.UsBankAccount,"us-bank-account.min.js")]}))}))},e.prototype.loadGooglePayment=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.GooglePayment,"google-payment.min.js")]}))}))},e.prototype.load3DS=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.ThreeDSecure,"three-d-secure.min.js")]}))}))},e.prototype.loadVisaCheckout=function(){return this.loadBraintreeModuleOrThrow(Po.VisaCheckout,"visa-checkout.min.js")},e.prototype.loadVenmoCheckout=function(){return this.loadBraintreeModuleOrThrow(Po.Venmo,"venmo.min.js")},e.prototype.loadHostedFields=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.HostedFields,"hosted-fields.min.js")]}))}))},e.prototype.loadBraintreeModuleOrThrow=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return(n=this.getBraintreeModule(e))?[2,n]:(r="//js.braintreegateway.com/web/"+this.braintreeSdkVersion+"/js/"+t,i=this.getIntegrityValuesByModuleName(e)[this.braintreeSdkVersion],[4,this.scriptLoader.loadScript(r,i?{async:!0,attributes:{integrity:i,crossorigin:"anonymous"}}:void 0)]);case 1:if(o.sent(),!(n=this.getBraintreeModule(e)))throw new wo;return[2,n]}}))}))},e.prototype.getBraintreeModule=function(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]},e.prototype.getIntegrityValuesByModuleName=function(e){var t,n,r,i,o,a,s,u,c,d,l,p,h;switch(e){case Po.Client:return(t={})[Ro]="sha384-5q9Kkv64ho8xutoRBtnaeRE1Ux47T6+LSRpsRmKrKSq7SiZOXn0Mv2XWXVQvCFJj",t[Mo]="sha384-cpfxkJc2j2IgFLlXdJEhNVkCief/ezpYjc3d/QC7psgcdB7AZRZVSCWBrWHJd8kV",t[ko]="sha384-WFefLU7p2TWWSJ17dsTC2uZF0qylvIUEXI7ZaQiWiMPGHtvQlpjc53WirI93FZtv",t;case Po.Connect:return(n={})[Mo]="sha384-F/Vm+lvAqbrFfTjVSXul1yeJablUdRQXoGSpXX5ub24OKFeMuITbFiY1TTK1QlxY",n;case Po.PaypalCheckout:return(r={})[Ro]="sha384-sozUyB/9Y4TygM5npllDME7tGVRo9/4Fh1clHUiPI1F2Q922yyJsMtL5fcFtZHdT",r[Mo]="sha384-b/Bkr377Yi/i9fGXP9adBSYC+Z2//ruSfUlkIni9AjL/YFeu/ygqtgYyJdAEAsr7",r[ko]="sha384-M5Uymuf5O0lh9Dyu+4soyJzefD1uUsL3m3fakhOuIH6C/FXGvii+XHGSGwQwxeJJ",r;case Po.Paypal:return(i={})[Ro]="sha384-Kw2YNA/MLpnN7vkRO3LOCNB0ZrSgT0UZiucLokB06z+0591xAAWgcf9v8AKjCwCX",i[Mo]="sha384-2T9Nx2wNbrtrj7SFleQU/i/trUmvBvf3Lmj/enmh9KESjit397Vaaps6EkI18MGt",i[ko]="sha384-R9O45bWivOlvh5zNaZeRaL0Vie0i6RgNpcD+anBxCVV0Lasox0rsayskrWpOcckT",i;case Po.LocalPayment:return(o={})[Ro]="sha384-P4U+tVQc9ja0VB3w4O6kTlLtIsBPGgsnFQlEdMYVYlU5BF5QP1aoIUhbmLXi0ewT",o[Mo]="sha384-ARWRFedVLKaSGVUD0YTsHxkzRZ/Cc2BD994a3NqnXoCP+iRM7XeRs1ulS4E+i9ts",o[ko]="sha384-76tfvCYa9NzY9D66qhNk0cwnecFNOIUw/G+uNE4AhOZ/+Nhej6Po/8zvoOElmE/1",o;case Po.DataCollector:return(a={})[Ro]="sha384-MYeeYlFD7uDuhGi2ZmrRth4uLy52c+MmJhlrIeNsZCpstpX3qQJI389DB/a2137k",a[Mo]="sha384-L12Sd8K1LbH+gXLvRG54pH+vdCJUnpepjTb6qG2HiD8NvJYLZS/VjJ671OCXr5Vz",a[ko]="sha384-zpZXyctWw5HY7JwKnhbSRzkOnIkNv8hYoEEyMKkJnpoIT2BijSjiXkNxtSI6lig9",a;case Po.UsBankAccount:return(s={})[Ro]="sha384-fyOBNpf/tlxbtQsgTICLilgs48q2M8n7gHcsGlmDK945m3pGZzmOdoTKSihFxwEe",s[Mo]="sha384-mBAnHTYdpowjxBu8uRyjsdzDxTLpoZohyMvINZYEV3OyonbtFIjB9/k1k4A2vWrC",s[ko]="sha384-WwIPgRv2U5MDKNnHUhlvuwa4xOFjK0U6RfIk07n6QF5N9WX3q2qW1pdIfnEX0P8b",s;case Po.GooglePayment:return(u={})[Ro]="sha384-4ePQT3gULIgtQDyvx+F4rXu9DcyWrOP1dxHCoCO8uESGC8BoDbPVAxDiugVawQjJ",u[Mo]="sha384-OL0G9k2ShrnVAtkmS4Q4Fg7SHi5IxM6B8dgB8GDn1kIcl8rYoGG+FPjrLvfxJO++",u[ko]="sha384-p0G7HnR6D/f81mKyLqCkr9fEwbDWCwwK8lVZmaudReYXt7bGD3mVO0y9HFsZQhfQ",u;case Po.ThreeDSecure:return(c={})[Ro]="sha384-kBYpTT1+KcpIHYwnFE6XY3xQkdmazh9F4r9ufjh/cIFXAZFpP96XYNyW8PvHuiJ8",c[Mo]="sha384-ashYIRvaw82mbN1eOd7B43a0La3ngECGkjMK6qbr7UNYb613xBJipfWnNHahDEj6",c[ko]="sha384-cs4wDHFa3sU5X2n8S/9qte1uPxRPy7Kp/KL14lYurOXbXxMZma0660Gfo0a6AUS1",c;case Po.VisaCheckout:return(d={})[Ro]="sha384-XzzKn9jU+Lvx1tJscq9e+nMRNBybQnSgSTXn1/PS0v6JxOUQlgFIBjI9ER8CODFt",d[Mo]="sha384-YUiwmkaPgw7G/n4k2XVoNjsAtn2J+m8cA5oPhGH7y/o90302cwzLiFS23bNAw1e0",d[ko]="sha384-iMFvsiulnHPuXwzbm5r/DPdATPCPn6J4aVNyTheAvM3e5FLA1j/wZTCAYxM081cP",d;case Po.Venmo:return(l={})[Ro]="sha384-AfqcRXnzzimKHVeUXcJNlB6ti2rmN9UJaZrLFU21pj779Db0zIJtBMdVcwb64NEm",l[Mo]="sha384-CXsbLYSCKdOjrs8CILcaOLBkdI/d7jWlym/+lnzbda8MS/X58DCHrskKp7mPaDxG",l[ko]="sha384-prmYZ8RvB+/Nuld/7DbA6VfQ+vgDVSwR2Bos6s2FPhoOWf4fYW+YnYA0j9G4bS5/",l;case Po.HostedFields:return(p={})[Ro]="sha384-7I4A3VPyzQnBGG7F2aiC9We5tN3Py+cYyPWoqiQJaXCEIVLX2goBaku2lGhZXpyK",p[Mo]="sha384-5l3JvGSYH74qGQJB8IlsrUAqeqrH58vkIkxJoW+LH7O99z4Np2BceIcFvZ46QGld",p[ko]="sha384-0gdeYixIb/qimY4JRVwaybygpjWS7O4NtcwQPEJwFhx0nGBKE+NxbkQXOiTXY5QY",p;case Po.Fastlane:return(h={})[ko]="sha384-Ca2r1xkeRMuYnf7qxF1rf9RrxNNYv/yqkVNZJ8f3CX6vwiagJNl7L65/3zWyu2hH",h;default:throw new Error("Unexpected fileName value")}},e}(),No=function(){function e(e){var t,n,r;this._factories={},this._instances={},this._defaultToken=null!==(t=null==e?void 0:e.defaultToken)&&void 0!==t?t:"default",this._useFallback=null===(n=null==e?void 0:e.useFallback)||void 0===n||n,this._tokenResolver=null!==(r=null==e?void 0:e.tokenResolver)&&void 0!==r?r:function(e){return e}}return e.prototype.get=function(e,t){try{return this._getInstance(e||this._defaultToken,t||e||this._defaultToken)}catch(e){if(!this._useFallback)throw e;return this._getInstance(this._defaultToken,t||this._defaultToken)}},e.prototype.register=function(e,t){if(this._hasFactory(e))throw new Pr("'"+e+"' is already registered.");this._factories[e]=t},e.prototype._hasFactory=function(e){return!!this._factories[e]},e.prototype._hasInstance=function(e){return!!this._instances[e]},e.prototype._getInstance=function(e,t){if(!this._hasInstance(t)){var n=this._tokenResolver(e,Object.keys(this._factories)),r=n&&this._factories[n];if(!r)throw new Pr("'"+e+"' is not registered.");this._instances[t]=r()}return this._instances[t]},e}();var Lo,zo,Fo,Uo,qo,Bo=["buttons","messages"];!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Lo||(Lo={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(zo||(zo={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(Fo||(Fo={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Uo||(Uo={})),function(e){e.PILL="pill",e.RECT="rect"}(qo||(qo={}));const Go=function(e){function t(t){var n=e.call(this,t||"Unsupported browser error")||this;return n.name="UnsupportedBrowserError",n.type="unsupported_browser",n}return(0,o.__extends)(t,e),t}(l),xo=function(){function e(e){this._braintreeScriptLoader=e,this._dataCollectors={},this._window=window}return e.prototype.initialize=function(e,t){this._clientToken=e,this._braintreeScriptLoader.initialize(t)},e.prototype.getClient=function(){var e=this;if(!this._clientToken)throw new Ur(Fr.PaymentNotInitialized);return this._client||(this._client=this._braintreeScriptLoader.loadClient().then((function(t){return t.create({authorization:e._clientToken})}))),this._client},e.prototype.getPaypalCheckout=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,this.getClient()];case 1:return r=o.sent(),[4,this._braintreeScriptLoader.loadPaypalCheckout()];case 2:return i=o.sent(),a={client:r},s=function(r,i){if(r)return n(r);u._window.paypal?t(i):i.loadPayPalSDK(u._getPayPalSDKConfig(e),(function(){return t(i)}))},this._paypalCheckout=i.create(a,s),[2,this._paypalCheckout]}}))}))},e.prototype.getVenmoCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this._venmoCheckout?[3,3]:[4,this.getClient()];case 1:return n=o.sent(),[4,this._braintreeScriptLoader.loadVenmoCheckout()];case 2:r=o.sent(),i={client:n,allowDesktop:!0,paymentMethodUsage:"multi_use"},a=function(n,r){return n?t(n):r.isBrowserSupported()?void e(r):t(new Go)},this._venmoCheckout=r.create(i,a),o.label=3;case 3:return[2,this._venmoCheckout]}}))}))},e.prototype.get3DS=function(){return this._3ds||(this._3ds=Promise.all([this.getClient(),this._braintreeScriptLoader.load3DS()]).then((function(e){var t=e[0];return e[1].create({client:t,version:2})}))),this._3ds},e.prototype.getDataCollector=function(e){var t=e&&e.paypal?"paypal":"default",n=this._dataCollectors[t];return n||(n=Promise.all([this.getClient(),this._braintreeScriptLoader.loadDataCollector()]).then((function(t){var n=t[0];return t[1].create((0,o.__assign)({client:n,kount:!0},e))})).catch((function(e){if(e&&"DATA_COLLECTOR_KOUNT_NOT_ENABLED"===e.code)return{deviceData:void 0,teardown:function(){return Promise.resolve()}};throw e})),this._dataCollectors[t]=n),n},e.prototype.getVisaCheckout=function(){return this._visaCheckout||(this._visaCheckout=Promise.all([this.getClient(),this._braintreeScriptLoader.loadVisaCheckout()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this._visaCheckout},e.prototype.createHostedFields=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,Promise.all([this.getClient(),this._braintreeScriptLoader.loadHostedFields()])];case 1:return t=r.sent(),n=t[0],[2,t[1].create((0,o.__assign)((0,o.__assign)({},e),{client:n}))]}}))}))},e.prototype.teardown=function(){var e=this;return Promise.all([this._teardown(this._3ds),this._teardown(this._dataCollectors.default),this._teardown(this._dataCollectors.paypal),this._teardown(this._paypalCheckout),this._teardown(this._venmoCheckout),this._teardown(this._visaCheckout)]).then((function(){e._3ds=void 0,e._dataCollectors={},e._paypalCheckout=void 0,e._venmoCheckout=void 0,e._visaCheckout=void 0}))},e.prototype._teardown=function(e){return e?e.then((function(e){return e.teardown()})).catch((function(e){if("METHOD_CALLED_AFTER_TEARDOWN"!==e.code)throw e})):Promise.resolve()},e.prototype._getPayPalSDKConfig=function(e){return(0,o.__assign)((0,o.__assign)({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:Bo.toString(),intent:e.intent})},e}(),Yo=function(e){function t(t){var n=e.call(this,"Unable to synchronize your checkout details with a third party provider. Please try again later.")||this;return n.error=t,n.name="RemoteCheckoutSynchronizationError",n.type="remote_checkout_synchronization",n}return(0,o.__extends)(t,e),t}(l);var Vo,Ho,jo,Wo,Ko,Jo;function Zo(e){var t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}!function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(Vo||(Vo={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Ho||(Ho={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(jo||(jo={})),function(e){e.Long="long",e.Short="short"}(Wo||(Wo={})),function(e){e.Default="default",e.Black="black",e.White="white"}(Ko||(Ko={})),function(e){e.Min="MIN",e.Full="FULL"}(Jo||(Jo={}));const Qo=function(){function e(e,t,n,r,i,o,a){this._store=e,this._paymentMethodActionCreator=t,this._googlePayScriptLoader=n,this._googlePayInitializer=r,this._billingAddressActionCreator=i,this._consignmentActionCreator=o,this._requestSender=a,this._isBuyNowFlow=!1,this._shouldThrowError=!0}return e.prototype.initialize=function(e,t){return this._methodId=e,this._configureWallet(t)},e.prototype.deinitialize=function(){return this._googlePayInitializer.teardown()},e.prototype.createButton=function(e,t,n){if(void 0===t&&(t=Wo.Short),void 0===n&&(n=Ko.Default),!this._googlePayClient)throw new Ur(Fr.PaymentNotInitialized);return this._googlePayClient.createButton({buttonColor:n,buttonType:t,onClick:e})},e.prototype.updatePaymentDataRequest=function(e){var t,n,r,i,a,s,u=this._getPaymentDataRequest();this._paymentDataRequest=(0,o.__assign)((0,o.__assign)((0,o.__assign)({},u),e),{merchantInfo:(0,o.__assign)((0,o.__assign)({},null!==(t=u.merchantInfo)&&void 0!==t?t:{}),null!==(n=e.merchantInfo)&&void 0!==n?n:{}),transactionInfo:(0,o.__assign)((0,o.__assign)({},null!==(r=u.transactionInfo)&&void 0!==r?r:{}),null!==(i=e.transactionInfo)&&void 0!==i?i:{}),shippingAddressParameters:(0,o.__assign)((0,o.__assign)({},null!==(a=u.shippingAddressParameters)&&void 0!==a?a:{}),null!==(s=e.shippingAddressParameters)&&void 0!==s?s:{})})},e.prototype.displayWallet=function(){if(!this._googlePayClient)throw new Ur(Fr.PaymentNotInitialized);return this._googlePayClient.loadPaymentData(this._getPaymentDataRequest())},e.prototype.handleSuccess=function(e){var t=this;return this._googlePayInitializer.parseResponse(e).then((function(e){return t._postForm(e)})).then((function(){return t._updateBillingAddress(e)}))},e.prototype.updateShippingAddress=function(e){return this._store.dispatch(this._consignmentActionCreator.updateAddress(this._mapGooglePayAddressToShippingAddress(e)))},e.prototype.updateBuyNowFlowFlag=function(e){this._isBuyNowFlow=e},e.prototype.updateShouldThrowInvalidError=function(e){this._shouldThrowError=e},e.prototype._configureWallet=function(e){var t,n=this,r=null===(t=this._store.getState().config.getStoreConfig())||void 0===t?void 0:t.checkoutSettings.features,i=r&&r["INT-5826.google_hostname_alias"]?{params:{origin:window.location.hostname}}:void 0,o=this._getMethodId();return this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(o,i)).then((function(t){var r=n._getCheckout(t),i=t.paymentMethods.getPaymentMethod(o),a=!!t.shippingAddress.getShippingAddress();if(!i)throw new Mn(Rn.MissingPaymentMethod);var s=i.config.testMode;return Promise.all([n._googlePayScriptLoader.load(),n._googlePayInitializer.initialize(r,i,a)]).then((function(t){var r=t[0],i=t[1];return n._googlePayClient=n._getGooglePayClient(r,s,e),n._paymentDataRequest=i,n._googlePayClient.isReadyToPay({allowedPaymentMethods:[{type:i.allowedPaymentMethods[0].type,parameters:{allowedAuthMethods:i.allowedPaymentMethods[0].parameters.allowedAuthMethods,allowedCardNetworks:i.allowedPaymentMethods[0].parameters.allowedCardNetworks}}],apiVersion:i.apiVersion,apiVersionMinor:i.apiVersionMinor}).then((function(e){var t=e.result;if(t)return t;if(!n._shouldThrowError)return t;throw new d}))}))}))},e.prototype._getCardInformation=function(e){return(0,o.__assign)({type:e.cardType,number:e.lastFour},(null==e?void 0:e.bin)?{bin:null==e?void 0:e.bin}:{})},e.prototype._getCheckout=function(e){if(!this._isBuyNowFlow){var t=e.checkout.getCheckout();if(!t)throw new Mn(Rn.MissingCheckout);return t}},e.prototype._getPaymentDataRequest=function(){if(!this._paymentDataRequest)throw new Yo;return this._paymentDataRequest},e.prototype._getGooglePayClient=function(e,t,n){if(void 0===t)throw new Mn(Rn.MissingPaymentMethod);var r=t?"TEST":"PRODUCTION";return new e.payments.api.PaymentsClient((0,o.__assign)({environment:r},null!=n?n:{}))},e.prototype._getMethodId=function(){if(!this._methodId)throw new Ur(Fr.PaymentNotInitialized);return this._methodId},e.prototype._mapGooglePayAddressToBillingAddress=function(e,t,n){var r=Zo(e.paymentMethodData.info.billingAddress.name),i=r[0],o=r[1],a=e.paymentMethodData.info.billingAddress.address1,s=e.paymentMethodData.info.billingAddress.locality,u=e.paymentMethodData.info.billingAddress.postalCode,c=e.paymentMethodData.info.billingAddress.countryCode;if(!(i&&a&&s&&u&&c))throw new Mn(Rn.MissingBillingAddress);return{id:t,firstName:i,lastName:o,company:e.paymentMethodData.info.billingAddress.companyName,address1:a,address2:e.paymentMethodData.info.billingAddress.address2+e.paymentMethodData.info.billingAddress.address3,city:s,stateOrProvince:e.paymentMethodData.info.billingAddress.administrativeArea,stateOrProvinceCode:e.paymentMethodData.info.billingAddress.administrativeArea,postalCode:u,countryCode:c,phone:e.paymentMethodData.info.billingAddress.phoneNumber,customFields:[],email:n||e.email}},e.prototype._mapGooglePayAddressToShippingAddress=function(e){var t=Zo(e.name);return{firstName:t[0],lastName:t[1],company:e.companyName,address1:e.address1,address2:e.address2+e.address3,city:e.locality,stateOrProvince:e.administrativeArea,stateOrProvinceCode:e.administrativeArea,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phoneNumber,customFields:[]}},e.prototype._postForm=function(e){var t=e.details,n=this._isBuyNowFlow?this._store.getState().cart.getCartOrThrow().id:void 0;return this._requestSender.post("/checkout.php",{headers:(0,o.__assign)({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},Qn),body:(0,o.__assign)({payment_type:e.type,nonce:e.nonce,tokenFormat:e.tokenFormat,provider:this._getMethodId(),action:"set_external_checkout",card_information:this._getCardInformation(t)},n&&{cart_id:n})})},e.prototype._updateBillingAddress=function(e){var t=this._store.getState().billingAddress.getBillingAddress();if(!t)throw new Mn(Rn.MissingBillingAddress);var n=this._mapGooglePayAddressToBillingAddress(e,t.id,t.email);return this._store.dispatch(this._billingAddressActionCreator.updateAddress(n))},e}();const Xo=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method is not loaded or ready to be used.")||this;return n.name="PaymentMethodClientUnavailableError",n.type="payment_method_client_unavailable",n}return(0,o.__extends)(t,e),t}(l),$o=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(){var e=this;return this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js").then((function(){if(!e._window.google)throw new Xo;return e._window.google}))},e}();function ea(e,t){var n=(0,r.createRequestSender)(),i=(0,$n.getScriptLoader)();return new Qo(e,new Wn(new Xn(n)),new $o(i),t,new nr(new ir(n),new xi(new Yi(n))),new ki(new Ni(n),new lr(n)),n)}const ta=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({type:n,nonce:r,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.storeCountry,u=o.googleMerchantName,c=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:c,merchantName:u},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"adyen",gatewayMerchantId:a}}}],transactionInfo:{countryCode:s,currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),na=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({type:n,nonce:r,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.storeCountry,u=o.googleMerchantName,c=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:c,merchantName:u},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"adyen",gatewayMerchantId:a}}}],transactionInfo:{countryCode:s,currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}();var ra={apiVersion:2,apiVersionMinor:0};const ia=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({type:n,nonce:btoa(r),details:{cardType:o,lastFour:a}})},e.prototype._getGooglePaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",a=t.initializationData,s=a.paymentGatewayId,u=a.storeCountry,c=a.googleMerchantName,d=a.googleMerchantId,l=a.platformToken,p=t.supportedCards,h=this._getPaymentGatewaySpecification(s),f=this._getCardPaymentMethod(h,p);return(0,o.__assign)((0,o.__assign)({},ra),{allowedPaymentMethods:[f],transactionInfo:{totalPriceStatus:Ho.FINAL,totalPrice:i,currencyCode:r,countryCode:u},merchantInfo:{merchantName:c,merchantId:d,authJwt:l},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}})},e.prototype._getPaymentGatewaySpecification=function(e){return{type:"PAYMENT_GATEWAY",parameters:{gateway:"authorizenet",gatewayMerchantId:e}}},e.prototype._getCardPaymentMethod=function(e,t){return{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:e}},e}(),oa=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({nonce:btoa(r),type:n,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.googleMerchantName,u=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"cybersource",gatewayMerchantId:a}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),aa=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method has thrown an unexpected error.")||this;return n.name="PaymentMethodFailedError",n.type="payment_method_client_invalid",n}return(0,o.__extends)(t,e),t}(s),sa=function(){function e(e){this._requestSender=e,this._publishableKey="",this._testMode=!0,this._errorMessage="Unable to parse response from GooglePay."}return e.prototype.initialize=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return this._publishableKey=t.initializationData.checkoutcomkey,this._testMode=!!t.config.testMode,[2,this._mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2(e,t.initializationData,n)]}))}))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:try{t=JSON.parse(e.paymentMethodData.tokenizationData.token)}catch(e){throw new Pr(this._errorMessage)}if(!t.signature||!t.protocolVersion||!t.signedMessage)throw new aa(this._errorMessage);return[4,this._convertToken(this._testMode,this._publishableKey,t)];case 1:return n=i.sent(),r={nonce:n.token,type:"CreditCard",description:e.paymentMethodData.description,details:{cardType:e.paymentMethodData.info.cardNetwork,lastFour:e.paymentMethodData.info.cardDetails}},n.token_format&&(r.tokenFormat=n.token_format),[2,r]}}))}))},e.prototype._convertToken=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,this._requestCheckoutcomTokenize(e,t,{type:"googlepay",token_data:n})];case 1:if(!(r=i.sent())||!r.token)throw new aa("Unable to parse response from Checkout.com");return[2,r]}}))}))},e.prototype._requestCheckoutcomTokenize=function(e,t,n){return void 0===n&&(n={}),(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return r=e?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",[4,this._requestSender.post(r,{credentials:!1,body:n,headers:{"Content-Type":Jn.Json,Authorization:t,"X-XSRF-TOKEN":null}})];case 1:return[2,i.sent().body]}}))}))},e.prototype._mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"";return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:t.platformToken,merchantId:t.googleMerchantId,merchantName:t.googleMerchantName},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","JCB","MASTERCARD","VISA"],billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"checkoutltd",gatewayMerchantId:t.checkoutcomkey}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),ua=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({nonce:btoa(r),type:n,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.googleMerchantName,u=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"cybersource",gatewayMerchantId:a}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),ca=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({nonce:btoa(r),type:n,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.googleMerchantName,u=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"chase",gatewayMerchantId:a}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),da=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){try{var t=JSON.parse(e.paymentMethodData.tokenizationData.token);return Promise.resolve({nonce:t.id,type:t.type,details:{cardType:t.card.brand,lastFour:t.card.last4}})}catch(e){throw new Pr("Unable to parse response from Google Pay.")}},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=(null==e?void 0:e.consignments)||[],a=t.initializationData,s=a.googleMerchantName,u=a.googleMerchantId,c=a.platformToken,d=a.stripeVersion,l=a.stripePublishableKey,p=a.stripeConnectedAccount,h=a.bopis,f=t.supportedCards,g=o.every((function(e){return e.selectedPickupOption}));return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:c,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:f.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":d,"stripe:publishableKey":l+"/"+p}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!((null==h?void 0:h.enabled)&&g&&"none"===(null==h?void 0:h.requiredAddress)||n),shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),la=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t;try{t=JSON.parse(e.paymentMethodData.tokenizationData.token)}catch(e){throw new Pr("Unable to parse response from Google Pay.")}if(!(t.id&&t.type&&t.card&&t.card.brand&&t.card.last4))throw new aa("Unable to parse response from Google Pay.");return Promise.resolve({nonce:t.id,type:t.type,details:{cardType:t.card.brand,lastFour:t.card.last4}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.cart.currency.decimalPlaces)||2,o=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,i).toFixed(i):"",a=t.initializationData,s=a.googleMerchantName,u=a.googleMerchantId,c=a.platformToken,d=a.stripeVersion,l=a.stripePublishableKey,p=a.stripeConnectedAccount;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:c,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":d,"stripe:publishableKey":l+"/"+p}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:o},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),pa=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({nonce:btoa(r),type:n,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.storeCountry,u=o.googleMerchantName,c=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:c,merchantName:u},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"worldpay",gatewayMerchantId:a}}}],transactionInfo:{countryCode:s,currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),ha=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(e){var t=e.useMasterpassSrc,n=e.language,r=e.testMode,i=e.checkoutId;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t?(e=["https://"+(r?"sandbox.":"")+"src.mastercard.com/srci/integration/merchant.js",["locale="+n,"checkoutid="+i].join("&")].join("?"),[4,this._scriptLoader.loadScript(e)]):[3,2];case 1:case 3:if(o.sent(),!this._window.masterpass)throw new Xo;return[2,this._window.masterpass];case 2:return[4,this._scriptLoader.loadScript("//"+(r?"sandbox.":"")+"masterpass.com/integration/merchant.js")]}}))}))},e}(),fa=function(){function e(e){this._scriptLoader=e,this._window=window}return e.prototype.loadPaypal=function(e){return void 0===e&&(e=""),(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t="//www.paypalobjects.com/api/checkout.min.js",n={async:!0,attributes:{"data-merchant-id":e}},e?[4,this._scriptLoader.loadScript(t,n)]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,this._scriptLoader.loadScript(t)];case 3:r.sent(),r.label=4;case 4:if(!this._window.paypal)throw new Xo;return[2,this._window.paypal]}}))}))},e}(),ma=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during buy now cart creation process. Please try again later.")||this;return n.name="BuyNowCartCreationError",n.type="buy_now_cart_creation_error",n}return(0,o.__extends)(t,e),t}(l);function ga(e){return e instanceof Object&&"buyNowInitializeOptions"in e}const ya=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during config creation process. Please try again later.")||this;return n.name="AmazonPayV2ConfigCreationError",n.type="amazon_pay_v2_config_creation_error",n}return(0,o.__extends)(t,e),t}(l),_a=function(){function e(e,t,n,r,i){this._store=e,this._checkoutActionCreator=t,this._amazonPayV2PaymentProcessor=n,this._cartRequestSender=r,this._amazonPayV2ConfigRequestSender=i}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.methodId,r=e.containerId,i=e.amazonpay,a=(i||{}).buttonColor,!n||!r)throw new Pr('Unable to proceed because "methodId" or "containerId" argument is not provided.');return s=this._store.getState().paymentMethods.getPaymentMethodOrThrow,[4,this._amazonPayV2PaymentProcessor.initialize(s(n))];case 1:return o.sent(),i?[3,3]:[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:o.sent(),o.label=3;case 3:return u=ga(i)?void 0:i,ga(i)&&"function"==typeof(null===(t=null==i?void 0:i.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody)&&(this._buyNowInitializeOptions=i.buyNowInitializeOptions,this._buyNowInitializeOptions&&this._amazonPayV2PaymentProcessor.updateBuyNowFlowFlag(!0)),this._amazonPayV2PaymentProcessor.renderAmazonPayButton({checkoutState:this._store.getState(),containerId:r,methodId:n,options:u,placement:go.Cart,buttonColor:a}),this._buyNowInitializeOptions&&this._amazonPayV2PaymentProcessor.prepareCheckoutWithCreationRequestConfig(this._getCheckoutCreationRequestConfig.bind(this)),[2]}}))}))},e.prototype.deinitialize=function(){return this._amazonPayV2PaymentProcessor.deinitialize()},e.prototype._createBuyNowCart=function(){var e,t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:if(!(n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e)))throw new Mn(Rn.MissingCart);r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(n)];case 2:return[2,r.sent().body];case 3:throw r.sent(),new ma;case 4:return[2]}}))}))},e.prototype._createCheckoutConfig=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this._amazonPayV2ConfigRequestSender.createCheckoutConfig(e)];case 1:return t=a.sent().body,n=t.payload,r=t.public_key,i=(0,o.__rest)(t,["payload","public_key"]),[2,(0,o.__assign)({payloadJSON:n,publicKeyId:r},i)];case 2:throw a.sent(),new ya;case 3:return[2]}}))}))},e.prototype._getCheckoutCreationRequestConfig=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._createBuyNowCart()];case 1:return(e=n.sent())?(t={amount:String(e.baseAmount),currencyCode:e.currency.code},[4,this._createCheckoutConfig(e.id)]):[3,3];case 2:return[2,{createCheckoutSessionConfig:n.sent(),estimatedOrderAmount:t,productType:0===lo(e)?_o.PayOnly:_o.PayAndShip}];case 3:return[2]}}))}))},e}(),va=function(){function e(e){this._requestSender=e}return e.prototype.createCheckoutConfig=function(e){var t={cartId:e},n=(0,o.__assign)({"X-API-INTERNAL":Zn,"Content-Type":Jn.Json},Qn);return this._requestSender.post("/api/storefront/payment/amazonpay",{headers:n,body:t})},e}();function Ca(e){return{recipientName:e.firstName+" "+e.lastName,line1:e.address1,line2:e.address2,city:e.city,state:e.stateOrProvinceCode,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone}}function Sa(e){var t=e.color,n=e.fundingicons,r=e.height,i=e.layout,o=e.shape,a=e.size,s=e.tagline,u={color:t,fundingicons:n,height:Ia(r),layout:i,shape:o||"rect",size:a,tagline:s};return(0,m.omitBy)(u,m.isNil)}function Ia(e){return"number"!=typeof e||e>55?55:e<25?25:e}function wa(e){var t=e.billingAddress,n=e.email,r=e.firstName,i=e.lastName,o=e.phone,a=e.shippingAddress,s=t||a;return{email:n,first_name:r,last_name:i,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}}function Ea(e){var t=e.email,n=e.phone,r=e.shippingAddress,i=((null==r?void 0:r.recipientName)||"").split(" ");return{email:t,first_name:i[0]||"",last_name:i[1]||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}}const ba=function(){function e(e,t,n,r,i,o){this._store=e,this._checkoutActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._window=o}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f,m,g,y=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreepaypal,n=e.containerId,r=e.methodId,a=(i=t||{}).messagingContainerId,s=i.onError,!r)throw new Pr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Pr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Pr('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');if(!t.buyNowInitializeOptions)return[3,1];if(u=this._store.getState(),c=u.paymentMethods.getPaymentMethodOrThrow(r),!t.currencyCode)throw new Pr('Unable to initialize payment because "options.braintreepaypal.currencyCode" argument is not provided.');return d=t.currencyCode,[3,3];case 1:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:u=o.sent(),c=u.paymentMethods.getPaymentMethodOrThrow(r),d=u.cart.getCartOrThrow().currency.code,o.label=3;case 3:if(l=u.config.getStoreConfig(),p=c.clientToken,h=c.initializationData,!p||!h)throw new Mn(Rn.MissingPaymentMethod);return f={currency:d,intent:h.intent,isCreditEnabled:h.isCreditEnabled},m=function(e){y._renderPayPalComponents(e,t,n,r,Boolean(c.config.testMode))},g=function(e){return y._handleError(e,n,a,s)},this._braintreeSDKCreator.initialize(p,l),[4,this._braintreeSDKCreator.getPaypalCheckout(f,m,g)];case 4:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._renderPayPalComponents=function(e,t,n,r,i){var o=t.messagingContainerId;this._renderPayPalMessages(o),this._renderPayPalButton(e,t,n,r,i)},e.prototype._renderPayPalButton=function(e,t,n,r,i){var o=this,a=t.style,s=t.shouldProcessPayment,u=t.onAuthorizeError,c=this._window.paypal,d=null==c?void 0:c.FUNDING.PAYPAL;if(c&&d){var l=a?Sa(a):{},p=c.Buttons({env:i?"sandbox":"production",commit:!1,fundingSource:d,style:l,createOrder:function(){return o._setupPayment(e,t,r)},onApprove:function(t){return o._tokenizePayment(t,e,r,s,u)}});p.isEligible()&&p.render("#"+n)}else this._removeElement(n)},e.prototype._renderPayPalMessages=function(e){var t=e&&Boolean(document.getElementById(e)),n=this._window.paypal;if(n&&t){var r=this._store.getState().cart.getCartOrThrow();n.Messages({amount:r.cartAmount,placement:"cart"}).render("#"+e)}else this._removeElement(e)},e.prototype._setupPayment=function(e,t,n){var r,i;return(0,o.__awaiter)(this,void 0,void 0,(function(){var a,s,u,c,d,l,p,h,f,m,g,y;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:a=t.buyNowInitializeOptions,s=t.shippingAddress,u=t.onPaymentError,o.label=1;case 1:return o.trys.push([1,7,,8]),d=this,[4,this._createBuyNowCart({buyNowInitializeOptions:a})];case 2:return d._buyNowCart=o.sent(),this._buyNowCart?(c=this._store.getState(),[3,5]):[3,3];case 3:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 4:c=o.sent(),o.label=5;case 5:return l=c.customer.getCustomer(),p=c.paymentMethods.getPaymentMethodOrThrow(n),h=this._buyNowCart?this._buyNowCart.cartAmount:c.checkout.getCheckoutOrThrow().outstandingBalance,f=null!==(r=t.currencyCode)&&void 0!==r?r:c.config.getStoreConfigOrThrow().currency.code,m=s||(null==l?void 0:l.addresses[0]),g=m?Ca(m):void 0,[4,e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:g,amount:h,currency:f,offerCredit:!1,intent:null===(i=p.initializationData)||void 0===i?void 0:i.intent})];case 6:return[2,o.sent()];case 7:throw y=o.sent(),u&&u(y),y;case 8:return[2]}}))}))},e.prototype._createBuyNowCart=function(e){var t=e.buyNowInitializeOptions;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==t?void 0:t.getBuyNowCartRequestBody))return[3,4];if(!(e=t.getBuyNowCartRequestBody()))throw new Mn(Rn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(e)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new ma;case 4:return[2]}}))}))},e.prototype._tokenizePayment=function(e,t,n,r,i){var a;return(0,o.__awaiter)(this,void 0,void 0,(function(){var s,u,c,d,l,p;return(0,o.__generator)(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this._braintreeSDKCreator.getDataCollector({paypal:!0})];case 1:return s=h.sent().deviceData,[4,t.tokenizePayment(e)];case 2:return u=h.sent(),c=u.details,d=u.nonce,l=null===(a=this._buyNowCart)||void 0===a?void 0:a.id,this._formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",provider:n,action:r?"process_payment":"set_external_checkout",nonce:d,device_data:s,billing_address:JSON.stringify(wa(c)),shipping_address:JSON.stringify(Ea(c))},l&&{cart_id:l})),[2,u];case 3:throw p=h.sent(),i&&i(p),p;case 4:return[2]}}))}))},e.prototype._handleError=function(e,t,n,r){this._removeElement(t),this._removeElement(n),r&&r(e)},e.prototype._removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e}();var Pa,Aa,Ta,Oa,Ra;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Pa||(Pa={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Aa||(Aa={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(Ta||(Ta={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Oa||(Oa={})),function(e){e.PILL="pill",e.RECT="rect"}(Ra||(Ra={}));const Ma=function(){function e(e,t,n,r,i,o){this._store=e,this._checkoutActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._window=o}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreepaypalcredit,n=e.containerId,!(r=e.methodId))throw new Pr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Pr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Pr('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');if(!t.buyNowInitializeOptions)return[3,1];if(i=this._store.getState(),a=i.paymentMethods.getPaymentMethodOrThrow(r),!t.currencyCode)throw new Pr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');return s=t.currencyCode,[3,3];case 1:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:i=o.sent(),a=i.paymentMethods.getPaymentMethodOrThrow(r),s=i.cart.getCartOrThrow().currency.code,o.label=3;case 3:if(u=i.config.getStoreConfig(),c=a.clientToken,d=a.initializationData,!c||!d)throw new Mn(Rn.MissingPaymentMethod);return l={currency:s,intent:d.intent,isCreditEnabled:d.isCreditEnabled},p=function(e){return f._renderPayPalButton(e,t,n,r,Boolean(a.config.testMode))},h=function(e){return f._handleError(e,n,t.onError)},this._braintreeSDKCreator.initialize(c,u),[4,this._braintreeSDKCreator.getPaypalCheckout(l,p,h)];case 4:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._renderPayPalButton=function(e,t,n,r,i){var a=this,s=t.style,u=t.shouldProcessPayment,c=t.onAuthorizeError,d=this._window.paypal,l=!1;if(d){var p=[d.FUNDING.PAYLATER,d.FUNDING.CREDIT],h=s?Sa(s):{};p.forEach((function(s){var p=s===d.FUNDING.CREDIT?(0,o.__assign)({label:Oa.CREDIT},h):h;if(!l){var f=d.Buttons({env:i?"sandbox":"production",commit:!1,fundingSource:s,style:p,createOrder:function(){return a._setupPayment(e,t,r)},onApprove:function(t){return a._tokenizePayment(t,e,r,u,c)}});f.isEligible()&&(f.render("#"+n),l=!0)}}))}d&&l||this._removeElement(n)},e.prototype._setupPayment=function(e,t,n){var r,i;return(0,o.__awaiter)(this,void 0,void 0,(function(){var a,s,u,c,d,l,p,h,f,m,g,y;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:a=t.onPaymentError,s=t.shippingAddress,u=t.buyNowInitializeOptions,o.label=1;case 1:return o.trys.push([1,7,,8]),d=this,[4,this._createBuyNowCart({buyNowInitializeOptions:u})];case 2:return d._buyNowCart=o.sent(),this._buyNowCart?(c=this._store.getState(),[3,5]):[3,3];case 3:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 4:c=o.sent(),o.label=5;case 5:return l=c.customer.getCustomer(),p=c.paymentMethods.getPaymentMethodOrThrow(n),h=this._buyNowCart?this._buyNowCart.cartAmount:c.checkout.getCheckoutOrThrow().outstandingBalance,f=null!==(r=t.currencyCode)&&void 0!==r?r:c.config.getStoreConfigOrThrow().currency.code,m=s||(null==l?void 0:l.addresses[0]),g=m?Ca(m):void 0,[4,e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:g,amount:h,currency:f,offerCredit:!0,intent:null===(i=p.initializationData)||void 0===i?void 0:i.intent})];case 6:return[2,o.sent()];case 7:throw y=o.sent(),a&&a(y),y;case 8:return[2]}}))}))},e.prototype._createBuyNowCart=function(e){var t=e.buyNowInitializeOptions;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==t?void 0:t.getBuyNowCartRequestBody))return[3,4];if(!(e=t.getBuyNowCartRequestBody()))throw new Mn(Rn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(e)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new ma;case 4:return[2]}}))}))},e.prototype._tokenizePayment=function(e,t,n,r,i){var a;return(0,o.__awaiter)(this,void 0,void 0,(function(){var s,u,c,d,l,p;return(0,o.__generator)(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this._braintreeSDKCreator.getDataCollector({paypal:!0})];case 1:return s=h.sent().deviceData,[4,t.tokenizePayment(e)];case 2:return u=h.sent(),c=u.details,d=u.nonce,l=null===(a=this._buyNowCart)||void 0===a?void 0:a.id,this._formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",provider:n,action:r?"process_payment":"set_external_checkout",nonce:d,device_data:s,billing_address:JSON.stringify(wa(c)),shipping_address:JSON.stringify(Ea(c))},l&&{cart_id:l})),[2,u];case 3:throw p=h.sent(),i&&i(p),p;case 4:return[2]}}))}))},e.prototype._handleError=function(e,t,n){this._removeElement(t),n&&n(e)},e.prototype._removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e}();var ka=function(e){var t,n=e.color;return{backgroundColor:(t=n||"",t===Ta.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:'url("/app/assets/img/payment-providers/venmo-logo-'+(n===Ta.WHITE?Ta.BLUE:Ta.WHITE)+'.svg")',backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:"36px",minWidth:"150px",height:"100%",width:"100%",border:n===Ta.WHITE?"1px solid black":"none"}};const Da=function(){function e(e,t,n,r,i){this._store=e,this._paymentMethodActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._onError=m.noop}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreevenmo,n=e.containerId,!(r=e.methodId))throw new Pr('Unable to initialize payment because "options.methodId" argument is not provided.');return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(r))];case 1:if(i=o.sent(),a=i.config.getStoreConfig(),s=i.paymentMethods.getPaymentMethodOrThrow(r),u=s.clientToken,c=s.initializationData,d=c.paymentButtonStyles,l=(d||{}).cartButtonStyles,p=(null==t?void 0:t.style)||l,!u||!c)throw new Mn(Rn.MissingPaymentMethod);if(!n)throw new Pr('Unable to initialize payment because "options.containerId" argument is not provided.');return this._onError=(null==t?void 0:t.onError)||this._handleError,this._braintreeSDKCreator.initialize(u,a),[4,this._braintreeSDKCreator.getVenmoCheckout((function(e){return h._handleInitializationVenmoSuccess(e,n,null==t?void 0:t.buyNowInitializeOptions,p)}),(function(e){return h._handleInitializationVenmoError(e,n)}))];case 2:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._handleError=function(e){throw new Error(e.message)},e.prototype._handleInitializationVenmoSuccess=function(e,t,n,r){return this._renderVenmoButton(e,t,n,r)},e.prototype._handleInitializationVenmoError=function(e,t){return this._removeVenmoContainer(t),this._onError(e)},e.prototype._removeVenmoContainer=function(e){var t=document.getElementById(e);t&&t.remove()},e.prototype._renderVenmoButton=function(e,t,n,r){var i=this,a=document.getElementById(t),s=(r||{}).color;if(!a)throw new Pr("Unable to create wallet button without valid container ID.");a.setAttribute("aria-label","Venmo"),Object.assign(a.style,ka(r||{})),a.addEventListener("click",(function(){return(0,o.__awaiter)(i,void 0,void 0,(function(){var t,r=this;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return a.setAttribute("disabled","true"),[4,this._createBuyNowCart(n)];case 1:return t=i.sent(),e.tokenize&&e.tokenize((function(e,n){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return a.removeAttribute("disabled"),e?[2,this._onError(e)]:[4,this._handlePostForm(n,null==t?void 0:t.id)];case 1:return r.sent(),[2]}}))}))})),[2]}}))}))})),s===Ta.BLUE&&(a.addEventListener("mouseenter",(function(){a.style.backgroundColor="#0a7fc2"})),a.addEventListener("mouseleave",(function(){a.style.backgroundColor=ka(r||{}).backgroundColor})))},e.prototype._createBuyNowCart=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,4];if(!(t=e.getBuyNowCartRequestBody()))throw new Mn(Rn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(t)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new ma;case 4:return[2]}}))}))},e.prototype._handlePostForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return[4,this._braintreeSDKCreator.getDataCollector()];case 1:return n=a.sent().deviceData,r=e.nonce,i=e.details,this._formPoster.postForm("/checkout.php",(0,o.__assign)({nonce:r,provider:gi.BRAINTREE_VENMO,payment_type:"paypal",device_data:n,action:"set_external_checkout",billing_address:JSON.stringify(wa(i)),shipping_address:JSON.stringify(Ea(i))},t&&{cart_id:t})),[2]}}))}))},e}(),Na=function(){function e(e,t,n,r,i){this._store=e,this._formPoster=t,this._checkoutActionCreator=n,this._googlePayPaymentProcessor=r,this._cartRequestSender=i}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.containerId,n=e.methodId,r=e.currencyCode,i=this._getGooglePayOptions(e),a=i.buyNowInitializeOptions,!t||!n)throw new so('Unable to proceed because "containerId" argument is not provided.');if(s=this._store.getState(),u=s.paymentMethods.getPaymentMethod(n),c=((null==u?void 0:u.config)||{}).testMode,this._methodId=n,this._isBuyNowFlow=!!a,!this._isBuyNowFlow)return[3,2];if(!r)throw new so('Unable to initialize payment because "options.currencyCode" argument is not provided.');return d=i.buyNowInitializeOptions,this._googlePayPaymentProcessor.updateBuyNowFlowFlag(this._isBuyNowFlow),[4,this._googlePayPaymentProcessor.initialize(this._getMethodId(),this._getGooglePayClientOptions(r,c,d))];case 1:return o.sent(),[3,5];case 2:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 3:return o.sent(),[4,this._googlePayPaymentProcessor.initialize(this._getMethodId())];case 4:o.sent(),o.label=5;case 5:return this._walletButton=this._createSignInButton(t,i,r),[2]}}))}))},e.prototype.deinitialize=function(){return this._walletButton&&this._walletButton.parentNode&&(this._walletButton.parentNode.removeChild(this._walletButton),this._walletButton=void 0),this._googlePayPaymentProcessor.deinitialize()},e.prototype._getGooglePayClientOptions=function(e,t,n){var r=this;return{environment:t?"TEST":"PRODUCTION",paymentDataCallbacks:{onPaymentDataChanged:function(t){var i=t.callbackTrigger;return(0,o.__awaiter)(r,void 0,void 0,(function(){var t,r,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(i!==Vo.INITIALIZE)return[2];o.label=1;case 1:return o.trys.push([1,5,,6]),t=this,[4,this._createBuyNowCart(n)];case 2:return t._buyNowCart=o.sent(),this._buyNowCart?(r=this._buyNowCart,a=r.id,s=r.cartAmount,[4,this._store.dispatch(this._checkoutActionCreator.loadCheckout(a))]):[3,4];case 3:return o.sent(),[2,{newTransactionInfo:{currencyCode:e,totalPrice:String(s),totalPriceStatus:Ho.FINAL}}];case 4:return[3,6];case 5:throw u=o.sent(),new ma(u);case 6:return[2]}}))}))}}}},e.prototype._createSignInButton=function(e,t,n){var r=this,i=document.getElementById(e),o=t.buttonType,a=t.buttonColor;if(!i)throw new so("Unable to create sign-in button without valid container ID.");var s=this._googlePayPaymentProcessor.createButton((function(e){return r._handleWalletButtonClick(e,n)}),o,a);return i.appendChild(s),s},e.prototype._getMethodId=function(){if(!this._methodId)throw new fo(ho.PaymentNotInitialized);return this._methodId},e.prototype._getGooglePayOptions=function(e){if(e.methodId===gi.GOOGLEPAY_ADYENV2&&e.googlepayadyenv2)return e.googlepayadyenv2;if(e.methodId===gi.GOOGLEPAY_ADYENV3&&e.googlepayadyenv3)return e.googlepayadyenv3;if(e.methodId===gi.GOOGLEPAY_AUTHORIZENET&&e.googlepayauthorizenet)return e.googlepayauthorizenet;if(e.methodId===gi.GOOGLEPAY_BNZ&&e.googlepaybnz)return e.googlepaybnz;if(e.methodId===gi.GOOGLEPAY_BRAINTREE&&e.googlepaybraintree)return e.googlepaybraintree;if(e.methodId===gi.GOOGLEPAY_CHECKOUTCOM&&e.googlepaycheckoutcom)return e.googlepaycheckoutcom;if(e.methodId===gi.GOOGLEPAY_CYBERSOURCEV2&&e.googlepaycybersourcev2)return e.googlepaycybersourcev2;if(e.methodId===gi.GOOGLEPAY_ORBITAL&&e.googlepayorbital)return e.googlepayorbital;if(e.methodId===gi.GOOGLEPAY_STRIPE&&e.googlepaystripe)return e.googlepaystripe;if(e.methodId===gi.GOOGLEPAY_STRIPEUPE&&e.googlepaystripeupe)return e.googlepaystripeupe;if(e.methodId===gi.GOOGLEPAY_WORLDPAYACCESS&&e.googlepayworldpayaccess)return e.googlepayworldpayaccess;throw new so},e.prototype._createBuyNowCart=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,4];if(!(t=e.getBuyNowCartRequestBody()))throw new co(uo.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(t)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new ma;case 4:return[2]}}))}))},e.prototype._handleWalletButtonClick=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:e.preventDefault(),i.label=1;case 1:return i.trys.push([1,7,,8]),this._isBuyNowFlow&&t&&this._googlePayPaymentProcessor.updatePaymentDataRequest({transactionInfo:{currencyCode:t,totalPrice:"0",totalPriceStatus:Ho.ESTIMATED},callbackIntents:[jo.OFFER]}),[4,this._googlePayPaymentProcessor.displayWallet()];case 2:return n=i.sent(),[4,this._googlePayPaymentProcessor.handleSuccess(n)];case 3:return i.sent(),lo(this._store.getState().cart.getCartOrThrow())>0&&n.shippingAddress?[4,this._googlePayPaymentProcessor.updateShippingAddress(n.shippingAddress)]:[3,5];case 4:i.sent(),i.label=5;case 5:return[4,this._onPaymentSelectComplete()];case 6:return i.sent(),[3,8];case 7:if((r=i.sent())&&"CANCELED"!==r.message)throw r;return[3,8];case 8:return[2]}}))}))},e.prototype._onPaymentSelectComplete=function(){var e,t=null===(e=this._buyNowCart)||void 0===e?void 0:e.id;this._formPoster.postForm("/checkout.php",(0,o.__assign)({headers:(0,o.__assign)({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},Qn)},t&&{action:"set_external_checkout",provider:this._methodId,cart_id:t}))},(0,o.__decorate)([Rr],e.prototype,"_handleWalletButtonClick",null),e}();var La={es:["es_es","es_mx","es_pe","es_co","es_ar","es_cl"],en:["en_us","en_gb","en_ca","en_es","en_fr","en_ie","en_sg","en_au","en_nz","en_my","en_hk","en_th","en_ae","en_sa","en_qa","en_kw","en_za"],pt:["pt_br"],zu:["zu_za"],ar:["ar_sa","ar_ae","ar_qa","ar_kw"],zh:["zh_sg","zh_hk"],ms:["ms_my"],uk:["uk_ua"],sv:["sv_se"],hr:["hr_hr"],pl:["pl_pl"],nl:["nl_be"],it:["it_it"],de:["de_de"],fr:["fr_fr","fr_ca"]};function za(e){var t=e.replace("-","_").toLowerCase().split("_"),n=t[0],r=n+"_"+t[1],i=La[n];return i?i.indexOf(r)>-1?r:i[0]:"en_us"}const Fa=function(){function e(e,t,n,r){this._store=e,this._checkoutActionCreator=t,this._masterpassScriptLoader=n,this._locale=r}return e.prototype.initialize=function(e){var t=this,n=e.containerId,r=e.methodId;if(!n||!r)throw new Pr('Unable to proceed because "containerId" argument is not provided.');return this._methodId=r,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then((function(e){var n=e.paymentMethods.getPaymentMethod(r);if(!n||!n.initializationData.checkoutId)throw new Mn(Rn.MissingPaymentMethod);var i={useMasterpassSrc:n.initializationData.isMasterpassSrcEnabled,language:za(t._locale),testMode:n.config.testMode,checkoutId:n.initializationData.checkoutId};return t._masterpassScriptLoader.load(i)})).then((function(e){t._masterpassClient=e,t._signInButton=t._createSignInButton(n)}))},e.prototype.deinitialize=function(){return this._signInButton&&this._signInButton.parentNode&&(this._signInButton.removeEventListener("click",this._handleWalletButtonClick),this._signInButton.parentNode.removeChild(this._signInButton),this._signInButton=void 0),Promise.resolve()},e.prototype._createSignInButton=function(e){var t=document.getElementById(e),n=this._store.getState(),r=this._methodId?n.paymentMethods.getPaymentMethod(this._methodId):null,i=n.config.getStoreConfig();if(!t)throw new Error("Need a container to place the button");if(!r)throw new Mn(Rn.MissingPaymentMethod);if(!i)throw new Pr("Unable to retrieve store configuration");var o=document.createElement("input");if(o.type="image",r.initializationData.isMasterpassSrcEnabled){var a=r.config.testMode?"sandbox.":"",s=r.initializationData.checkoutId,u=["locale="+za(this._locale),"paymentmethod=master,visa,amex,discover","checkoutid="+s];o.src=["https://"+a+"src.mastercard.com/assets/img/btn/src_chk_btn_126x030px.svg",u.join("&")].join("?")}else o.src="https://static.masterpass.com/dyn/img/btn/global/mp_chk_btn_160x037px.svg";return t.appendChild(o),o.addEventListener("click",this._handleWalletButtonClick),o},e.prototype._createMasterpassPayload=function(){var e=this._store.getState(),t=e.checkout.getCheckout(),n=this._methodId?e.paymentMethods.getPaymentMethod(this._methodId):null;if(!t)throw new Mn(Rn.MissingCheckout);if(!n)throw new Mn(Rn.MissingPaymentMethod);return{checkoutId:n.initializationData.checkoutId,allowedCardTypes:n.initializationData.allowedCardTypes,amount:t.cart.cartAmount.toString(),currency:t.cart.currency.code,cartId:t.cart.id,callbackUrl:("cart",window.location.origin+"/checkout.php?action=set_external_checkout&provider=masterpass&gateway=stripe&origin=cart")}},e.prototype._handleWalletButtonClick=function(){if(!this._masterpassClient)throw new Ur(Fr.CheckoutButtonNotInitialized);this._masterpassClient.checkout(this._createMasterpassPayload())},(0,o.__decorate)([Rr],e.prototype,"_handleWalletButtonClick",null),e}(),Ua=function(){function e(e,t,n,r,i){void 0===i&&(i=""),this._store=e,this._checkoutActionCreator=t,this._paypalScriptLoader=n,this._formPoster=r,this._host=i}return e.prototype.initialize=function(e){var t=this,n=e.paypal,r=this._store.getState(),i=this._paymentMethod=r.paymentMethods.getPaymentMethod(e.methodId);if(!n)throw new Pr;if(!i)throw new Mn(Rn.MissingPaymentMethod);return this._paypalScriptLoader.loadPaypal(i.config.merchantId).then((function(r){var a,s,u;if(!i||!i.config.merchantId)throw new Mn(Rn.MissingPaymentMethod);var c=i.config.merchantId,d=i.config.testMode?"sandbox":"production",l=((a={})[d]=n.clientId,a),p=r.FUNDING.CREDIT||"credit",h=n.allowCredit?[p]:[],f=n.allowCredit?[]:[p];return r.Button.render({env:d,client:l,commit:n.shouldProcessPayment,funding:{allowed:h,disallowed:f},style:(0,o.__assign)((0,o.__assign)({shape:Ra.RECT},(0,m.pick)(n.style,"layout","color","label","shape","tagline","fundingicons")),{size:"paypalexpress"===i.id&&"small"===(null===(s=n.style)||void 0===s?void 0:s.size)?Aa.RESPONSIVE:null===(u=n.style)||void 0===u?void 0:u.size}),payment:function(e,r){return t._setupPayment(c,r,n.onPaymentError)},onAuthorize:function(e,r){return t._tokenizePayment(e,r,n.shouldProcessPayment,n.onAuthorizeError)}},e.containerId)}))},e.prototype.deinitialize=function(){return this._paymentMethod=void 0,Promise.resolve()},e.prototype._setupPayment=function(e,t,n){var r=this;if(!t)throw new Ur(Fr.CheckoutButtonNotInitialized);return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then((function(n){var i=n.cart.getCart(),a=i?i.id:"";return t.request.post(r._host+"/api/storefront/payment/paypalexpress",{merchantId:e,cartId:a},{headers:(0,o.__assign)({"X-API-INTERNAL":Zn},Qn)})})).then((function(e){return e.id})).catch((function(e){throw n&&n(e),e}))},e.prototype._tokenizePayment=function(e,t,n,r){var i=this;if(!this._paymentMethod)throw new Ur(Fr.CheckoutButtonNotInitialized);if(!t)throw new Ur(Fr.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new Mn(Rn.MissingPayment);var o=this._paymentMethod.id;return t.payment.get(e.paymentID).then((function(t){i._formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:o,action:n?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(t.payer.payer_info)})}))},e}();function qa(){try{return process.env.NODE_ENV||0}catch(e){return"development"}}const Ba=function(){function e(e){this._console=e}return e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["log"],e))},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["info"],e))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["warn"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["error"],e))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["debug"],e))},e.prototype._logToConsole=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._console&&this._console[e]&&(t=this._console[e]).call.apply(t,(0,o.__spreadArrays)([this._console],n))},e}(),Ga=function(){function e(){}return e.prototype.log=function(){},e.prototype.info=function(){},e.prototype.warn=function(){},e.prototype.error=function(){},e.prototype.debug=function(){},e}();var xa,Ya=(void 0===(xa="test"!==qa())&&(xa=!0),xa?new Ba(console):new Ga);const Va=function(){function e(e){void 0===e&&(e=!1),this._useFallback=e,this._registry=new No({tokenResolver:this._resolveToken.bind(this),useFallback:this._useFallback})}return e.prototype.get=function(e){return this._registry.get(this._encodeToken(e))},e.prototype.register=function(e,t){this._registry.register(this._encodeToken(e),t)},e.prototype._encodeToken=function(e){return btoa(JSON.stringify(e))},e.prototype._decodeToken=function(e){return JSON.parse(atob(e))},e.prototype._resolveToken=function(e,t){var n,r=this,i=this._decodeToken(e),o=[];t.forEach((function(e){for(var t=r._decodeToken(e),n={token:e,matches:0,default:!1},a=0,s=Object.entries(t);a<s.length;a++){var u=s[a],c=u[0],d=u[1];if(c in i&&i[c]!==d){n.matches=0;break}c in i&&i[c]===d&&n.matches++,"default"===c&&!0===d&&(n.default=!0)}o.push(n)}));var a=o.sort((function(e,t){return t.matches-e.matches})).filter((function(e){return e.matches>0}));a.length>1&&a[0].matches===a[1].matches&&"development"===qa()&&Ya.warn("The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.");var s=a[0];if(s&&s.token)return s.token;if(this._useFallback){var u=null===(n=o.find((function(e){return e.default})))||void 0===n?void 0:n.token;if(u)return u}throw new Error("Unable to resolve to a registered token with the provided token.")},e}(),Ha=require("@braintree/browser-detection");function ja(e){var t,n,r,i,o,a,s,u,c,d,l,p,h,f,m,g;return{root:{backgroundColorPrimary:Wa(null===(t=null==e?void 0:e.root)||void 0===t?void 0:t.backgroundColorPrimary)||"transparent",errorColor:Wa(null===(n=null==e?void 0:e.root)||void 0===n?void 0:n.errorColor)||"#C40B0B",fontFamily:Wa(null===(r=null==e?void 0:e.root)||void 0===r?void 0:r.fontFamily)||"Montserrat, Helvetica, Arial, sans-serif"},input:{borderRadius:Wa(null===(i=null==e?void 0:e.input)||void 0===i?void 0:i.borderRadius)||"0.25rem",borderColor:Wa(null===(o=null==e?void 0:e.input)||void 0===o?void 0:o.borderColor)||"#9E9E9E",focusBorderColor:Wa(null===(a=null==e?void 0:e.input)||void 0===a?void 0:a.focusBorderColor)||"#4496F6"},toggle:{colorPrimary:Wa(null===(s=null==e?void 0:e.toggle)||void 0===s?void 0:s.colorPrimary)||"#0F005E",colorSecondary:Wa(null===(u=null==e?void 0:e.toggle)||void 0===u?void 0:u.colorSecondary)||"#ffffff"},text:{body:{color:Wa(null===(d=null===(c=null==e?void 0:e.text)||void 0===c?void 0:c.body)||void 0===d?void 0:d.color)||"#222222",fontSize:Wa(null===(p=null===(l=null==e?void 0:e.text)||void 0===l?void 0:l.body)||void 0===p?void 0:p.fontSize)||"1rem"},caption:{color:Wa(null===(f=null===(h=null==e?void 0:e.text)||void 0===h?void 0:h.caption)||void 0===f?void 0:f.color)||"#515151",fontSize:Wa(null===(g=null===(m=null==e?void 0:e.text)||void 0===m?void 0:m.caption)||void 0===g?void 0:g.fontSize)||"1rem"}},branding:Wa(null==e?void 0:e.branding)||"light"}}function Wa(e){return e&&"string"==typeof e?e:null}const Ka=function(){function e(e,t,n){this.braintreeScriptLoader=e,this.braintreeHostWindow=t,this.overlay=n,this.dataCollectors={}}return e.prototype.initialize=function(e,t){this.clientToken=e,this.braintreeScriptLoader.initialize(t)},e.prototype.getBraintreeConnect=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t&&window.localStorage.setItem("axoEnv","sandbox"),this.braintreeHostWindow.braintreeConnect?[3,5]:(r=this.getClientTokenOrThrow(),[4,this.getClient()]);case 1:return i=o.sent(),[4,this.getSessionId(e)];case 2:return a=o.sent(),[4,this.braintreeScriptLoader.loadConnect()];case 3:return s=o.sent(),u=this.braintreeHostWindow,[4,s.create({authorization:r,client:i,deviceData:a,styles:ja(n)})];case 4:u.braintreeConnect=o.sent(),o.label=5;case 5:return[2,this.braintreeHostWindow.braintreeConnect]}}))}))},e.prototype.getBraintreeFastlane=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),this.braintreeHostWindow.braintreeFastlane?[3,5]:(r=this.getClientTokenOrThrow(),[4,this.getClient()]);case 1:return i=o.sent(),[4,this.getSessionId(e)];case 2:return a=o.sent(),[4,this.braintreeScriptLoader.loadFastlane()];case 3:return s=o.sent(),u=this.braintreeHostWindow,[4,s.create({authorization:r,client:i,deviceData:a,styles:ja(n)})];case 4:u.braintreeFastlane=o.sent(),o.label=5;case 5:return[2,this.braintreeHostWindow.braintreeFastlane]}}))}))},e.prototype.getClient=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this.client?[3,2]:(e=this.getClientTokenOrThrow(),[4,this.braintreeScriptLoader.loadClient()]);case 1:t=n.sent(),this.client=t.create({authorization:e}),n.label=2;case 2:return[2,this.client]}}))}))},e.prototype.getPaypal=function(){return this.braintreePaypal||(this.braintreePaypal=Promise.all([this.getClient(),this.braintreeScriptLoader.loadPaypal()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this.braintreePaypal},e.prototype.paypal=function(e){var t=this,n=e.shouldSaveInstrument,r=(0,o.__rest)(e,["shouldSaveInstrument"]),i=(0,Ha.supportsPopups)();return this.getPaypal().then((function(e){var a;return i&&(null===(a=t.overlay)||void 0===a||a.show({onClick:function(){return e.focusWindow()}})),e.tokenize((0,o.__assign)({enableShippingAddress:!0,flow:n?"vault":"checkout",useraction:"commit"},r))})).then((function(e){var n;return null===(n=t.overlay)||void 0===n||n.remove(),e})).catch((function(e){var n;throw null===(n=t.overlay)||void 0===n||n.remove(),e}))},e.prototype.getPaypalCheckout=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u,c=this;return(0,o.__generator)(this,(function(d){switch(d.label){case 0:return[4,this.getClient()];case 1:return r=d.sent(),[4,this.braintreeScriptLoader.loadPaypalCheckout()];case 2:return i=d.sent(),a={client:r},s=function(r,i){if(r)return n(r);var a=(0,o.__assign)((0,o.__assign)({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:Bo.toString(),intent:e.intent});c.braintreeHostWindow.paypal?t(i):i.loadPayPalSDK(a,(function(){return t(i)}))},u=this,[4,i.create(a,s)];case 3:return u.paypalCheckout=d.sent(),[2,this.paypalCheckout]}}))}))},e.prototype.loadBraintreeLocalMethods=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,this.getClient()];case 1:return n=o.sent(),[4,this.braintreeScriptLoader.loadBraintreeLocalMethods()];case 2:return r=o.sent(),this.braintreeLocalMethods?[3,4]:(i=this,[4,r.create({client:n,merchantAccountId:t},(function(t,n){if(t)throw new Error(t.message);e(n)}))]);case 3:i.braintreeLocalMethods=o.sent(),o.label=4;case 4:return[2,this.braintreeLocalMethods]}}))}))},e.prototype.get3DS=function(){return this.threeDS||(this.threeDS=Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]).then((function(e){var t=e[0];return e[1].create({client:t,version:2})}))),this.threeDS},e.prototype.getDataCollector=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:if(t=(null==e?void 0:e.paypal)?"paypal":"default",n=this.dataCollectors[t])return[3,7];u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.getClient()];case 2:return r=u.sent(),[4,this.braintreeScriptLoader.loadDataCollector()];case 3:return i=u.sent(),a=(0,o.__assign)({client:r,kount:!0},e),[4,i.create(a)];case 4:return n=u.sent(),[3,6];case 5:if(c=s=u.sent(),!Boolean("object"==typeof c&&null!==c&&("type"in c||"message"in c||"code"in c))||"DATA_COLLECTOR_KOUNT_NOT_ENABLED"!==s.code)throw s;return n={deviceData:void 0,teardown:function(){return Promise.resolve()}},[3,6];case 6:this.dataCollectors[t]=n,u.label=7;case 7:return[2,n]}var c}))}))},e.prototype.getGooglePaymentComponent=function(){return this.googlePay||(this.googlePay=Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this.googlePay},e.prototype.getBraintreeEnv=function(e){return void 0===e&&(e=!1),e?bo.Sandbox:bo.Production},e.prototype.mapToBraintreeShippingAddressOverride=function(e){return{recipientName:e.firstName+" "+e.lastName,line1:e.address1,line2:e.address2,city:e.city,state:e.stateOrProvinceCode,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone}},e.prototype.mapToLegacyShippingAddress=function(e){var t=e.email,n=e.phone,r=e.shippingAddress,i=((null==r?void 0:r.recipientName)||"").split(" ");return{email:t,first_name:i[0]||"",last_name:i[1]||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}},e.prototype.mapToLegacyBillingAddress=function(e){var t=e.billingAddress,n=e.email,r=e.firstName,i=e.lastName,o=e.phone,a=e.shippingAddress,s=t||a;return{email:n,first_name:r,last_name:i,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}},e.prototype.removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e.prototype.getSessionId=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this.getDataCollector({riskCorrelationId:e})];case 1:return[2,t.sent().deviceData]}}))}))},e.prototype.teardown=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this.teardownModule(this.dataCollectors.default)];case 1:return e.sent(),[4,this.teardownModule(this.dataCollectors.paypal)];case 2:return e.sent(),this.dataCollectors={},[4,this.teardownModule(this.paypalCheckout)];case 3:return e.sent(),this.paypalCheckout=void 0,[2]}}))}))},e.prototype.teardownModule=function(e){return e?e.teardown():Promise.resolve()},e.prototype.getClientTokenOrThrow=function(){if(!this.clientToken)throw new fo(ho.PaymentNotInitialized);return this.clientToken},e}();function Ja(e,t){return Object.assign(e,{resolveIds:t})}const Za=function(e){function t(t){var n=e.call(this,t||"Payment process was cancelled.")||this;return n.name="PaymentMethodCancelledError",n.type="payment_cancelled",n}return(0,o.__extends)(t,e),t}(s);const Qa=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during buy now cart creation process. Please try again later.")||this;return n.name="BuyNowCartCreationError",n.type="buy_now_cart_creation_error",n}return(0,o.__extends)(t,e),t}(s);var Xa;function $a(e){if(!function(e){return"ApplePaySession"in e}(e))throw new Error("Apple pay is not supported")}!function(e){e.BRAINTREE="braintree"}(Xa||(Xa={}));const es=function(){function e(){}return e.prototype.create=function(e){return $a(window),new ApplePaySession(1,e)},e}();var ts;!function(e){e.Subtotal="Subtotal",e.Shipping="Shipping"}(ts||(ts={}));const ns=function(){function e(e,t,n,r){this._requestSender=e,this._paymentIntegrationService=t,this._sessionFactory=n,this._braintreeIntegrationService=r,this._onAuthorizeCallback=m.noop,this._subTotalLabel=ts.Subtotal,this._shippingLabel=ts.Shipping}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.methodId,r=e.containerId,i=e.applepay,$a(window),!n||!i)throw new co(uo.MissingPaymentMethod);return a=i.buttonClassName,s=i.onPaymentAuthorize,u=i.buyNowInitializeOptions,c=i.requiresShipping,this._requiresShipping=c,this._buyNowInitializeOptions=u,this._onAuthorizeCallback=s,u?[3,2]:[4,this._paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return[4,this._paymentIntegrationService.loadPaymentMethod(n)];case 3:return o.sent(),d=this._paymentIntegrationService.getState(),this._paymentMethod=d.getPaymentMethodOrThrow(n),d.getCart()?[4,this._paymentIntegrationService.verifyCheckoutSpamProtection()]:[3,5];case 4:o.sent(),o.label=5;case 5:return(null===(t=this._paymentMethod.initializationData)||void 0===t?void 0:t.gateway)!==Xa.BRAINTREE?[3,7]:[4,this._initializeBraintreeIntegrationService()];case 6:o.sent(),o.label=7;case 7:return this._applePayButton=this._createButton(r,a),this._applePayButton.addEventListener("click",this._handleWalletButtonClick.bind(this)),[2,Promise.resolve()]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype._createButton=function(e,t){void 0===t&&(t="apple-pay-checkout-button");var n=document.getElementById(e);if(!n)throw new so("Unable to create wallet button without valid container ID.");document.body.classList.add("apple-pay-supported");var r=document.createElement("div");return r.setAttribute("class",t),r.setAttribute("role","button"),r.setAttribute("aria-label","Apple Pay button"),n.appendChild(r),r},e.prototype._handleWalletButtonClick=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d,l,p,h,f;return(0,o.__generator)(this,(function(o){if(e.preventDefault(),!this._paymentMethod||!this._paymentMethod.initializationData)throw new co(uo.MissingPaymentMethod);return this._buyNowInitializeOptions&&"function"==typeof this._buyNowInitializeOptions.getBuyNowCartRequestBody?(n=this._paymentMethod.initializationData,r=n.countryCode,i=n.currencyCode,a=n.merchantCapabilities,s=n.supportedNetworks,u=n.storeName,h=this._getRequestWithEmptyTotal(r,i,s,a),this._requiresShipping&&(null===(t=h.requiredShippingContactFields)||void 0===t||t.push("postalAddress")),f=this._sessionFactory.create(h),this._handleApplePayEvents(f,this._paymentMethod,u),f.begin()):(c=this._paymentIntegrationService.getState(),d=c.getCartOrThrow(),l=c.getStoreConfigOrThrow(),p=c.getCheckoutOrThrow(),h=this._getBaseRequest(d,p,l,this._paymentMethod),f=this._sessionFactory.create(h),this._handleApplePayEvents(f,this._paymentMethod,l.storeProfile.storeName),f.begin()),[2]}))}))},e.prototype._getRequestWithEmptyTotal=function(e,t,n,r){return{countryCode:e,currencyCode:t,supportedNetworks:n,merchantCapabilities:r,total:{label:"",amount:"0",type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"]}},e.prototype._getBaseRequest=function(e,t,n,r){var i,o=n.storeProfile,a=o.storeCountryCode,s=o.storeName,u=e.currency,c=u.code,d=u.decimalPlaces,l=r.initializationData,p=l.merchantCapabilities,h=l.supportedNetworks,f=e.lineItems.physicalItems.length>0,m={requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"],countryCode:a,currencyCode:c,merchantCapabilities:p,supportedNetworks:h,lineItems:[],total:f?{label:s,amount:""+t.grandTotal.toFixed(d),type:"pending"}:{label:s,amount:""+t.grandTotal.toFixed(d),type:"final"}};if(f)null===(i=m.requiredShippingContactFields)||void 0===i||i.push("postalAddress");else{var g=[{label:this._subTotalLabel,amount:""+t.subtotal.toFixed(d)}];t.taxes.forEach((function(e){return g.push({label:e.name,amount:""+e.amount.toFixed(d)})})),m.lineItems=g}return m},e.prototype._handleApplePayEvents=function(e,t,n){var r=this;e.onvalidatemerchant=function(n){return(0,o.__awaiter)(r,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._onValidateMerchant(t,n)];case 1:return r=i.sent().body,e.completeMerchantValidation(r),[3,3];case 2:throw i.sent(),new Error("Merchant validation failed");case 3:return[2]}}))}))},this._buyNowInitializeOptions&&!this._requiresShipping&&(e.onpaymentmethodselected=function(){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._createBuyNowCart()];case 1:return t.sent(),this._handlePaymentMethodSelected(e),[2]}}))}))}),e.onshippingcontactselected=function(t){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this._buyNowInitializeOptions&&this._requiresShipping?[4,this._createBuyNowCart()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[4,this._handleShippingContactSelected(e,n,t)];case 3:return r.sent(),[2]}}))}))},e.onshippingmethodselected=function(t){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._handleShippingMethodSelected(e,n,t)];case 1:return r.sent(),[2]}}))}))},e.oncancel=function(){return(0,o.__awaiter)(r,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),e="/remote-checkout/"+t.id+"/signout",[4,this._requestSender.get(e)];case 1:return n.sent(),[4,this._paymentIntegrationService.loadCheckout()];case 2:return[2,n.sent()];case 3:throw n.sent(),new Za;case 4:return[2]}}))}))},e.onpaymentauthorized=function(n){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return[2,this._onPaymentAuthorized(n,e,t)]}))}))}},e.prototype._createBuyNowCart=function(){var e,t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,3,,4]),!(n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e)))throw new co(uo.MissingCart);return[4,this._paymentIntegrationService.createBuyNowCart(n)];case 1:return r=i.sent(),[4,this._paymentIntegrationService.loadCheckout(r.id)];case 2:return i.sent(),[3,4];case 3:throw i.sent(),new Qa;case 4:return[2]}}))}))},e.prototype._handlePaymentMethodSelected=function(e){var t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow(),r=t.getStoreConfigOrThrow(),i=t.getCheckoutOrThrow();if(!this._paymentMethod||!this._paymentMethod.initializationData)throw new co(uo.MissingPaymentMethod);var o=this._getBaseRequest(n,i,r,this._paymentMethod);delete o.total.type,e.completePaymentMethodSelection({newTotal:o.total,newLineItems:o.lineItems})},e.prototype._handleShippingContactSelected=function(e,t,n){var r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l,p,h,f,m,g;return(0,o.__generator)(this,(function(y){switch(y.label){case 0:i=this._transformContactToAddress(n.shippingContact),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,this._paymentIntegrationService.updateShippingAddress(i)];case 2:return y.sent(),[3,4];case 3:throw y.sent(),e.abort(),new Error("Shipping address update failed");case 4:if(a=this._paymentIntegrationService.getState(),s=a.getCartOrThrow().currency.decimalPlaces,u=a.getCheckoutOrThrow(),c=null===(r=u.consignments[0].selectedShippingOption)||void 0===r?void 0:r.id,d=u.consignments[0].availableShippingOptions,l=null==d?void 0:d.find((function(e){return e.id===c})),p=null==d?void 0:d.filter((function(e){return e.id!==c})),h=l?[{label:l.description,amount:""+l.cost.toFixed(s),detail:l.additionalDescription,identifier:l.id}]:[],p&&(0,o.__spreadArrays)(p.filter((function(e){return e.isRecommended})),p.filter((function(e){return!e.isRecommended}))).forEach((function(e){return h.push({label:e.description,amount:""+e.cost.toFixed(s),detail:e.additionalDescription,identifier:e.id})})),!(d instanceof Array))throw new Error("Shipping options not available.");if(0===d.length)return e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,[],{type:"pending",label:t,amount:""+u.grandTotal.toFixed(s)},[]),[2];f=d.find((function(e){return e.isRecommended})),m=f?f.id:d[0].id,g=l?l.id:m,y.label=5;case 5:return y.trys.push([5,7,,8]),[4,this._updateShippingOption(g)];case 6:return y.sent(),[3,8];case 7:throw y.sent(),new Error("Shipping options update failed");case 8:return a=this._paymentIntegrationService.getState(),u=a.getCheckoutOrThrow(),e.completeShippingContactSelection({newShippingMethods:h,newTotal:{type:"final",label:t,amount:""+u.grandTotal.toFixed(s)},newLineItems:this._getUpdatedLineItems(u,s)}),[2]}}))}))},e.prototype._handleShippingMethodSelected=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:r=n.shippingMethod.identifier,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this._updateShippingOption(r)];case 2:return o.sent(),[3,4];case 3:throw o.sent(),e.abort(),new Error("Shipping option selection update failed.");case 4:return i=this._paymentIntegrationService.getState(),a=i.getCartOrThrow().currency.decimalPlaces,s=i.getCheckoutOrThrow(),e.completeShippingMethodSelection({newTotal:{type:"final",label:t,amount:""+s.grandTotal.toFixed(a)},newLineItems:this._getUpdatedLineItems(s,a)}),[2]}}))}))},e.prototype._getUpdatedLineItems=function(e,t){var n=[{label:this._subTotalLabel,amount:""+e.subtotal.toFixed(t)}];return e.taxes.forEach((function(e){return n.push({label:e.name,amount:""+e.amount.toFixed(t)})})),n.push({label:this._shippingLabel,amount:""+e.shippingCostTotal.toFixed(t)}),n},e.prototype._updateShippingOption=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._paymentIntegrationService.selectShippingOption(e)]}))}))},e.prototype._onValidateMerchant=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){return n=["validationUrl="+t.validationURL,"merchantIdentifier="+e.initializationData.merchantId,"displayName="+e.initializationData.storeName,"domainName="+window.location.hostname].join("&"),[2,this._requestSender.post((i=e.initializationData.paymentsUrl,i+"/api/public/v1/payments/applepay/validate_merchant"),{credentials:!1,headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","X-XSRF-TOKEN":null},body:n})];var i}))}))},e.prototype._onPaymentAuthorized=function(e,t,n){var r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l,p,h,f,m,g,y;return(0,o.__generator)(this,(function(_){switch(_.label){case 0:return i=e.payment,a=i.token,s=i.billingContact,u=i.shippingContact,c=this._paymentIntegrationService.getState(),d=c.getCartOrThrow(),l=d.lineItems.physicalItems.length>0,(null===(r=n.initializationData)||void 0===r?void 0:r.gateway)!==Xa.BRAINTREE?[3,2]:[4,this._getBraintreeDeviceData()];case 1:p=_.sent(),_.label=2;case 2:h={methodId:n.id,paymentData:{deviceSessionId:p,formattedPayload:{apple_pay_token:{payment_data:a.paymentData,payment_method:a.paymentMethod,transaction_id:a.transactionIdentifier}}}},f=this._transformContactToAddress(s),m=this._transformContactToAddress(u),g=null==u?void 0:u.emailAddress,y=(null==u?void 0:u.phoneNumber)||"",_.label=3;case 3:return _.trys.push([3,9,,10]),[4,this._paymentIntegrationService.updateBillingAddress((0,o.__assign)((0,o.__assign)({},f),{email:g,phone:y}))];case 4:return _.sent(),l?[4,this._paymentIntegrationService.updateShippingAddress(m)]:[3,6];case 5:_.sent(),_.label=6;case 6:return[4,this._paymentIntegrationService.submitOrder({useStoreCredit:!1})];case 7:return _.sent(),[4,this._paymentIntegrationService.submitPayment(h)];case 8:return _.sent(),t.completePayment(ApplePaySession.STATUS_SUCCESS),[2,this._onAuthorizeCallback()];case 9:throw _.sent(),t.completePayment(ApplePaySession.STATUS_FAILURE),new Error("Payment cannot complete");case 10:return[2]}}))}))},e.prototype._transformContactToAddress=function(e){return{firstName:(null==e?void 0:e.givenName)||"",lastName:(null==e?void 0:e.familyName)||"",city:(null==e?void 0:e.locality)||"",company:"",address1:(null==e?void 0:e.addressLines)&&e.addressLines[0]||"",address2:(null==e?void 0:e.addressLines)&&e.addressLines[1]||"",postalCode:(null==e?void 0:e.postalCode)||"",countryCode:(null==e?void 0:e.countryCode)||"",phone:(null==e?void 0:e.phoneNumber)||"",stateOrProvince:(null==e?void 0:e.administrativeArea)||"",stateOrProvinceCode:(null==e?void 0:e.administrativeArea)||"",customFields:[]}},e.prototype._getBraintreeDeviceData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._braintreeIntegrationService.getDataCollector()];case 1:return[2,e.sent().deviceData]}}))}))},e.prototype._initializeBraintreeIntegrationService=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._paymentIntegrationService.loadPaymentMethod(Xa.BRAINTREE)];case 1:return e=r.sent(),t=e.getStoreConfig(),(n=e.getPaymentMethodOrThrow(Xa.BRAINTREE)).clientToken&&n.initializationData?(this._braintreeIntegrationService.initialize(n.clientToken,t),[2]):[2]}}))}))},e}(),rs=Ja((function(e){var t=e.getState().getHost,n=window;return new ns((0,r.createRequestSender)({host:t()}),e,new es,new Ka(new Do((0,$n.getScriptLoader)(),n),n))}),[{id:"applepay"}]),is=require("query-string"),os=function(e){function t(t){var n=e.call(this,t||"Not implemented.")||this;return n.name="NotImplementedError",n.type="not_implemented",n}return(0,o.__extends)(t,e),t}(s);var as,ss,us;!function(e){e.SandboxMode="bolt_sandbox",e.StagingMode="bolt_staging",e.DevelopmentMode="bolt_development"}(as||(as={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(ss||(ss={})),function(e){e.Pill="pill",e.Rect="rect"}(us||(us={}));const cs=function(){function e(e,t,n){void 0===n&&(n=window),this.paymentIntegrationService=e,this.boltScriptLoader=t,this.boltHostWindow=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.bolt,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.style,!r)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new so('Unable to initialize payment because "options.bolt" argument is not provided.');if(!Boolean(a))throw new os("Only buy now flow is implemented for Bolt button");if(!(null==a?void 0:a.storefrontApiToken)||"string"!=typeof a.storefrontApiToken)throw new so('Unable to initialize payment because "options.storefrontApiToken" argument is not provided.');return u=this.paymentIntegrationService.getState(),c=u.getPaymentMethodOrThrow(r),d=c.initializationData,l=c.config,h=(p=d||{}).publishableKey,f=p.developerConfig,[4,this.boltScriptLoader.loadBoltClient(h,l.testMode,f,"BigCommerce",a.storefrontApiToken)];case 1:return o.sent(),this.renderButton(n,c,s),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r;"function"==typeof(null===(r=this.boltHostWindow.BoltConnect)||void 0===r?void 0:r.setupProductPageCheckout)&&(this.addButtonContainer(e,t,n),this.boltHostWindow.BoltConnect.setupProductPageCheckout())},e.prototype.addButtonContainer=function(e,t,n){var r=document.getElementById(e);if(r){var i=document.createElement("div"),o=document.createElement("object");i.setAttribute("id","product-page-checkout-wrapper"),i.setAttribute("class","bolt-button-wrapper"),i.setAttribute("style","display:none"),i.setAttribute("data-tid","product-page-checkout-wrapper"),o.setAttribute("data",this.getBoltObjectData(t,n)),o.setAttribute("class","bolt-product-checkout-button"),i.append(o),r.innerHTML="",r.append(i)}},e.prototype.getBoltObjectData=function(e,t){var n=e.initializationData,r=e.config,i=n||{},o=i.publishableKey,a=i.developerConfig,s=this.boltScriptLoader.getDomainURL(!!r.testMode,a),u=this.getButtonHeight(null==t?void 0:t.size),c=this.getButtonBorderRadius(null==t?void 0:t.shape,u);return(0,is.stringifyUrl)({url:"https://"+s+"/v1/checkout_button",query:{publishable_key:o,variant:"ppc",height:u,border_radius:c}})},e.prototype.getButtonHeight=function(e){if(e)switch(e){case ss.Small:return 25;case ss.Large:return 45;case ss.Medium:default:return 40}},e.prototype.getButtonBorderRadius=function(e,t){if(e)switch(e){case us.Pill:return t?Math.round(t/2):void 0;case us.Rect:default:return 4}},e}(),ds=function(){function e(e,t){void 0===t&&(t=window),this.scriptLoader=e,this.boltHostWindow=t}return e.prototype.loadBoltClient=function(e,t,n,r,i){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(this.boltHostWindow.BoltCheckout)return[2,this.boltHostWindow.BoltCheckout];if(!e)throw new so('Unable to initialize payment because "publishableKey" argument is not provided.');return[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/connect-bigcommerce.js",this.getScriptOptions("bolt-connect",e,r,i))];case 1:return o.sent(),[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/track.js",this.getScriptOptions("bolt-track",e))];case 2:if(o.sent(),!this.boltHostWindow.BoltCheckout)throw new wo;return[2,this.boltHostWindow.BoltCheckout]}}))}))},e.prototype.loadBoltEmbedded=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return r={async:!0,attributes:{id:"bolt-embedded"}},[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/embed.js",r)];case 1:if(i.sent(),!this.boltHostWindow.Bolt)throw new wo;return[2,this.boltHostWindow.Bolt(e)]}}))}))},e.prototype.getDomainURL=function(e,t){if(!e)return"connect.bolt.com";if(t)switch(t.developerMode){case as.StagingMode:return"connect-staging.bolt.com";case as.DevelopmentMode:return"connect."+t.developerDomain}return"connect-sandbox.bolt.com"},e.prototype.getScriptOptions=function(e,t,n,r){return{async:!0,attributes:(0,o.__assign)((0,o.__assign)({id:e,"data-publishable-key":t},n&&{"data-shopping-cart-id":n}),r&&{"data-storefront-api-token":r})}},e}(),ls=Ja((function(e){return new cs(e,new ds((0,$n.getScriptLoader)()))}),[{id:"bolt"}]);var ps,hs,fs,ms,gs,ys,_s,vs;function Cs(e){return e in ys}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(ps||(ps={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(hs||(hs={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(fs||(fs={})),function(e){e.pill="pill",e.rect="rect"}(ms||(ms={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(gs||(gs={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(ys||(ys={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(_s||(_s={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(vs||(vs={}));const Ss=function(){function e(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1}return e.prototype.mapToShippingAddressRequestBody=function(e){var t=e.shippingAddress;if(t){var n=this._paymentIntegrationService.getState().getShippingAddress()||{},r=n.company,i=void 0===r?"":r,o=n.phone,a=void 0===o?"":o;return this._mapToAddressRequestBody(t,i,a)}},e.prototype.mapToBillingAddressRequestBody=function(e){var t=e.paymentMethodData.info.billingAddress;if(t){var n=this._paymentIntegrationService.getState().getBillingAddress()||{},r=n.company,i=void 0===r?"":r,a=n.phone,s=void 0===a?"":a,u=n.email,c=void 0===u?e.email:u;return(0,o.__assign)((0,o.__assign)({},this._mapToAddressRequestBody(t,i,s)),{email:c})}},e.prototype.mapToExternalCheckoutData=function(e){var t,n=e.paymentMethodData,r=n.tokenizationData.token,i=n.info,a=i.cardNetwork,s=i.cardDetails;return Promise.resolve((0,o.__assign)({nonce:r,card_information:{type:a,number:s}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))},e.prototype.getRequiredData=function(){var e;return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return t={emailRequired:!0},this._isBuyNowFlow?[2,(0,o.__assign)((0,o.__assign)({},t),{shippingAddressRequired:!0,shippingAddressParameters:{phoneNumberRequired:!0}})]:this._isShippingAddressRequired()?[4,this._paymentIntegrationService.loadShippingCountries()]:[3,2];case 1:n=i.sent(),r=null===(e=n.getShippingCountries())||void 0===e?void 0:e.map((function(e){return e.code})),t.shippingAddressRequired=!0,t.shippingAddressParameters=(0,o.__assign)({phoneNumberRequired:!0},r&&{allowedCountryCodes:r}),i.label=2;case 2:return[2,t]}}))}))},e.prototype.getNonce=function(e){var t,n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new co(uo.MissingPaymentToken);return Promise.resolve(n)},e.prototype.extraPaymentData=function(){return Promise.resolve(void 0)},e.prototype.getMerchantInfo=function(){var e=this.getGooglePayInitializationData();return{merchantName:e.googleMerchantName,merchantId:e.googleMerchantId,authJwt:e.platformToken}},e.prototype.getTransactionInfo=function(){return{currencyCode:this._isBuyNowFlow?this._getCurrencyCodeOrThrow():(0,this._paymentIntegrationService.getState().getCartOrThrow)().currency.code,totalPriceStatus:gs.ESTIMATED,totalPrice:"0"}},e.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new so("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}},e.prototype.getCardParameters=function(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(Cs).map((function(e){return ys[e]})),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}},e.prototype.initialize=function(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()},e.prototype.getGooglePayInitializationData=function(){return po(this.getPaymentMethod().initializationData,(function(){return new so("Missing initialization data.")}))},e.prototype.getPaymentMethod=function(){return po(this._getPaymentMethodFn,(function(){return new fo(ho.PaymentNotInitialized)}))()},e.prototype.getGatewayIdentifier=function(){return this._gatewayIdentifier},e.prototype.setGatewayIdentifier=function(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()},e.prototype._isShippingAddressRequired=function(){var e,t,n=this._paymentIntegrationService.getState(),r=n.getCartOrThrow,i=n.getStoreConfig;return void 0===(0,n.getShippingAddress)()&&(e=r(),t=i(),!!e&&(!!e.lineItems.physicalItems.some((function(e){return e.isShippingRequired}))||!!(t&&t.checkoutSettings.features["CHECKOUT-4936.enable_custom_item_shipping"]&&e.lineItems.customItems)&&e.lineItems.customItems.length>0))},e.prototype._mapToAddressRequestBody=function(e,t,n){var r=e.name,i=e.address1,o=e.address2,a=e.address3,s=e.locality,u=e.administrativeArea,c=e.countryCode,d=e.postalCode,l=e.phoneNumber,p=this._getFirstAndLastName(r);return{firstName:p[0],lastName:p[1],company:t,address1:i,address2:(o+" "+a).trim(),city:s,stateOrProvince:u,stateOrProvinceCode:u,countryCode:c,postalCode:d,phone:l||n,customFields:[]}},e.prototype._getFirstAndLastName=function(e){var t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]},e.prototype._getCurrencyCodeOrThrow=function(){return po(this._currencyCode,(function(){return new so('Unable to initialize payment because "options.currencyCode" argument is not provided.')}))},e}(),Is=function(e){function t(t,n){var r=e.call(this,"braintree",t)||this;return r._braintreeService=n,r._service=t,r}return(0,o.__extends)(t,e),t.prototype.initialize=function(t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(l){switch(l.label){case 0:return[4,e.prototype.initialize.call(this,t,n,r)];case 1:if(l.sent(),!(i=e.prototype.getPaymentMethod.call(this)).clientToken||!i.initializationData)throw new co(uo.MissingPaymentMethod);return this._braintreeService.initialize(i.clientToken,this._service.getState().getStoreConfig()),[4,this._braintreeService.getGooglePaymentComponent()];case 2:return a=l.sent(),c=(u=a).createPaymentDataRequest,d=[{merchantInfo:e.prototype.getMerchantInfo.call(this),transactionInfo:e.prototype.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}}],[4,e.prototype.getRequiredData.call(this)];case 3:return s=c.apply(u,[o.__assign.apply(void 0,d.concat([l.sent()]))]),this._paymentGatewayParameters=s.paymentMethodTokenizationParameters.parameters,[2,Promise.resolve()]}}))}))},t.prototype.getNonce=function(t){var n;return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u,c,d,l;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,e.prototype.getNonce.call(this,t)];case 1:if(r=o.sent(),i=e.prototype.getPaymentMethod.call(this),a=i.clientToken,s=i.initializationData,!a||!s||!(null===(n=s.card_information)||void 0===n?void 0:n.bin))throw new co(uo.MissingPaymentMethod);return u=s.isThreeDSecureEnabled,c=s.card_information.bin,u?[4,this._braintreeService.get3DS()]:[3,4];case 2:return d=o.sent(),l=this._service.getState().getOrderOrThrow().orderAmount,[4,this._braintreePresent3DSChallenge(d,l,r,c)];case 3:return[2,o.sent().nonce];case 4:return[2,r]}}))}))},t.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e={},[4,this._getBraintreeDeviceData()];case 1:return[2,(e.deviceSessionId=t.sent(),e)]}}))}))},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:n=i.sent();try{r=JSON.parse(n.nonce)}catch(e){throw new so("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"androidPayCards"in e}(e))throw new co(uo.MissingPaymentToken)}(r),n.nonce=r.androidPayCards[0].nonce,n.card_information.bin=r.androidPayCards[0].details.bin,[2,n]}}))}))},t.prototype.getCardParameters=function(){return e.prototype.getCardParameters.call(this)},t.prototype.getPaymentGatewayParameters=function(){if(!this._paymentGatewayParameters)throw new co(uo.MissingPaymentMethod);return this._paymentGatewayParameters},t.prototype._getBraintreeDeviceData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._braintreeService.getDataCollector()];case 1:return[2,e.sent().deviceData]}}))}))},t.prototype._braintreePresent3DSChallenge=function(e,t,n,r){return new Ir(e.verifyCard({amount:t,bin:r,nonce:n,onLookupComplete:function(e,t){t()}})).promise},t}(Ss);var ws;!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.WORLDPAY_ACCESS="googlepayworldpayaccess"}(ws||(ws={}));const Es=function(){function e(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.methodId||(l=e.methodId,!Object.values(ws).includes(l)))throw new so('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new so('Unable to proceed because "containerId" is not a valid key.');if(!(n=e[this._getMethodOrThrow()]))throw new so("Unable to proceed without valid options.");r=n.buyNowInitializeOptions,i=n.currencyCode,a=n.buttonColor,s=n.buttonType,u=n.onError,c=this._paymentIntegrationService.getState(),o.label=1;case 1:return o.trys.push([1,2,,4]),d=c.getPaymentMethodOrThrow(this._getMethodOrThrow()),[3,4];case 2:return o.sent(),[4,this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow())];case 3:return c=o.sent(),d=c.getPaymentMethodOrThrow(this._getMethodOrThrow()),[3,4];case 4:if(this._countryCode=null===(t=d.initializationData)||void 0===t?void 0:t.storeCountry,!r)return[3,6];if(!i)throw new so('Unable to initialize payment because "options.currencyCode" argument is not provided.');return this._currencyCode=i,this._buyNowInitializeOptions=r,[4,this._googlePayPaymentProcessor.initialize((function(){return d}),this._getGooglePayClientOptions(),!!r,i)];case 5:return o.sent(),[3,9];case 6:return[4,this._paymentIntegrationService.loadDefaultCheckout()];case 7:return o.sent(),[4,this._googlePayPaymentProcessor.initialize((function(){return d}),this._getGooglePayClientOptions())];case 8:o.sent(),o.label=9;case 9:return this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=a?a:"default",buttonType:null!=s?s:"plain",onClick:this._handleClick(u)}),[2]}var l}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype._handleClick=function(e){var t=this;return function(n){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:n.preventDefault(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this._interactWithPaymentSheet()];case 2:return i.sent(),[3,4];case 3:if(t=i.sent(),r=t,"object"==typeof(o=t)&&null!==o&&"statusCode"in o){if("CANCELED"===t.statusCode)throw new Za;r=new aa(JSON.stringify(t))}throw null==e||e(new aa("An error occurred while requesting your Google Pay payment details.")),r;case 4:return[2]}var o}))}))}},e.prototype._interactWithPaymentSheet=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,this._googlePayPaymentProcessor.showPaymentSheet()];case 1:return e=i.sent(),t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e),n=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(e),r="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0,t?[4,this._paymentIntegrationService.updateBillingAddress(t)]:[3,3];case 2:i.sent(),i.label=3;case 3:return n?[4,this._paymentIntegrationService.updateShippingAddress(n)]:[3,5];case 4:i.sent(),i.label=5;case 5:return[4,this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),e,r)];case 6:return i.sent(),[2]}}))}))},e.prototype._getGooglePayClientOptions=function(){var e=this;return{paymentDataCallbacks:{onPaymentDataChanged:function(t){var n=t.callbackTrigger;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return n!==vs.INITIALIZE?[2]:this._buyNowInitializeOptions?[2,this._getBuyNowTransactionInfo()]:[2,this._getTransactionInfo()]}))}))}}}},e.prototype._createBuyNowCartOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,4];t=e.getBuyNowCartRequestBody(),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._paymentIntegrationService.createBuyNowCart(t)];case 2:return[2,n.sent()];case 3:throw n.sent(),new Qa;case 4:return[2]}}))}))},e.prototype._getBuyNowTransactionInfo=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),e=this,[4,this._createBuyNowCartOrThrow(this._buyNowInitializeOptions)];case 1:return e._buyNowCart=a.sent(),this._buyNowCart?(t=this._buyNowCart,n=t.id,r=t.cartAmount,[4,this._paymentIntegrationService.loadCheckout(n)]):[3,3];case 2:return a.sent(),[2,{newTransactionInfo:(0,o.__assign)((0,o.__assign)({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:String(r),totalPriceStatus:gs.FINAL})}];case 3:return[3,5];case 4:throw i=a.sent(),new Qa(i);case 5:return[2]}}))}))},e.prototype._getTransactionInfo=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:return[4,this._paymentIntegrationService.loadCheckout()];case 1:return u.sent(),e=this._paymentIntegrationService.getState(),t=e.getCheckoutOrThrow,n=e.getCartOrThrow,r=n().currency,i=r.code,a=r.decimalPlaces,s=(0,m.round)(t().outstandingBalance,a).toFixed(a),[2,{newTransactionInfo:(0,o.__assign)((0,o.__assign)({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:i,totalPriceStatus:gs.FINAL,totalPrice:s})}]}}))}))},e.prototype._getMethodOrThrow=function(){return po(this._methodId,(function(){return new fo(ho.PaymentNotInitialized)}))},e.prototype._getCurrencyCodeOrThrow=function(){return po(this._currencyCode,(function(){return new so('Unable to initialize payment because "options.currencyCode" argument is not provided.')}))},e}();var bs={"X-Checkout-SDK-Version":"1.588.0"};const Ps=function(){function e(e,t,n,r){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=r,this._baseRequest={apiVersion:2,apiVersionMinor:0}}return e.prototype.initialize=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return i=this,[4,this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t)];case 1:return i._paymentsClient=o.sent(),[4,this._gateway.initialize(e,n,r)];case 2:return o.sent(),[4,this._buildPayloads()];case 3:return o.sent(),[4,this._determineReadinessToPay()];case 4:return o.sent(),this._prefetchGooglePaymentData(),[2]}}))}))},e.prototype.getNonce=function(e){return this._gateway.getNonce(e)},e.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this._gateway.extraPaymentData()]}))}))},e.prototype.addPaymentButton=function(e,t){var n=document.querySelector("#"+e);if(!n)throw new so("Unable to render the Google Pay button to an invalid HTML container element.");var r=this._getPaymentsClient().createButton((0,o.__assign)((0,o.__assign)({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(r)},e.prototype.showPaymentSheet=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){return e=this._getPaymentDataRequest(),[2,this._getPaymentsClient().loadPaymentData(e)]}))}))},e.prototype.setExternalCheckoutXhr=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return[2,this._setExternalCheckout(e,t)]}))}))},e.prototype.setExternalCheckoutForm=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return[2,this._setExternalCheckout(e,t,!0,n)]}))}))},e.prototype.mapToBillingAddressRequestBody=function(e){return this._gateway.mapToBillingAddressRequestBody(e)},e.prototype.mapToShippingAddressRequestBody=function(e){return this._gateway.mapToShippingAddressRequestBody(e)},e.prototype.processAdditionalAction=function(e){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e):Promise.reject(e)},e.prototype.signOut=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._requestSender.get("/remote-checkout/"+e+"/signout")];case 1:return t.sent(),[2]}}))}))},e.prototype._setExternalCheckout=function(e,t,n,r){return void 0===n&&(n=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u=this;return(0,o.__generator)(this,(function(c){switch(c.label){case 0:return i="/checkout.php",s=[{action:"set_external_checkout",provider:e}],[4,this._gateway.mapToExternalCheckoutData(t)];case 1:return a=o.__assign.apply(void 0,s.concat([c.sent()])),n?[2,new Promise((function(e){u._formPoster.postForm(r?r+"/checkout":i,(0,o.__assign)((0,o.__assign)({},a),{card_information:JSON.stringify(a.card_information)}),e)}))]:[4,this._requestSender.post(i,{headers:(0,o.__assign)({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},bs),body:a})];case 2:return c.sent(),[2]}}))}))},e.prototype._prefetchGooglePaymentData=function(){var e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)},e.prototype._determineReadinessToPay=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest())];case 1:if(!1===t.sent().result)throw new aa("Google Pay is not supported by the current device and browser, please try another payment method.");return[3,3];case 2:if((e=t.sent())instanceof aa)throw e;throw new aa;case 3:return[2]}}))}))},e.prototype._buildPayloads=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()},this._cardPaymentMethod=(0,o.__assign)((0,o.__assign)({},this._baseCardPaymentMethod),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:this._gateway.getPaymentGatewayParameters()}}),e=this,t=[(0,o.__assign)((0,o.__assign)({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()})],[4,this._gateway.getRequiredData()];case 1:return e._paymentDataRequest=o.__assign.apply(void 0,[o.__assign.apply(void 0,t.concat([n.sent()])),{callbackIntents:[_s.OFFER]}]),this._isReadyToPayRequest=(0,o.__assign)((0,o.__assign)({},this._baseRequest),{allowedPaymentMethods:[this._baseCardPaymentMethod]}),[2]}}))}))},e.prototype._getBaseCardPaymentMethod=function(){return this._getOrThrow(this._baseCardPaymentMethod)},e.prototype._getPaymentDataRequest=function(){return this._getOrThrow(this._paymentDataRequest)},e.prototype._getIsReadyToPayRequest=function(){return this._getOrThrow(this._isReadyToPayRequest)},e.prototype._getPaymentsClient=function(){return this._getOrThrow(this._paymentsClient)},e.prototype._getOrThrow=function(e){return po(e,(function(){return new fo(ho.PaymentNotInitialized)}))},e}();const As=function(){function e(e){this._scriptLoader=e,this._window=window}return e.prototype.getGooglePaymentsClient=function(e,t){return void 0===e&&(e=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js")];case 1:if(n.sent(),!this._window.google)throw new wo;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient((0,o.__assign)({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),[2,this._paymentsClient]}}))}))},e}();function Ts(){return new As((0,$n.getScriptLoader)())}const Os=Ja((function(e){var t=(0,r.createRequestSender)(),n=window,o=new Ka(new Do((0,$n.getScriptLoader)(),n),n);return new Es(e,new Ps(Ts(),new Is(e,o),t,(0,i.createFormPoster)()))}),[{id:"googlepaybraintree"}]),Rs=function(e){function t(t,n){var r=e.call(this,"paypalsb",t)||this;return r.paypalCommerceScriptLoader=n,r.service=t,r}return(0,o.__extends)(t,e),t.prototype.initialize=function(t,n,r){var i,a,s,u,c;return(0,o.__awaiter)(this,void 0,void 0,(function(){var d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!(d=null!==(a=null===(i=this.service.getState().getStoreConfig())||void 0===i?void 0:i.currency.code)&&void 0!==a?a:r))throw new co(uo.MissingPaymentMethod);return[4,e.prototype.initialize.call(this,t,n,d)];case 1:if(o.sent(),!(l=e.prototype.getPaymentMethod.call(this)).initializationData)throw new co(uo.MissingPaymentMethod);return function(e){if(!function(e){return!!e.initializationData&&"attributionId"in e.initializationData&&"isVenmoEnabled"in e.initializationData&&"isGooglePayEnabled"in e.initializationData&&"isPayPalCreditAvailable"in e.initializationData}(e))throw new co(uo.MissingPaymentMethod)}(l),[4,this.paypalCommerceScriptLoader.getPayPalSDK(l,d)];case 2:return o.sent(),p=this,[4,this.paypalCommerceScriptLoader.getGooglePayConfigOrThrow()];case 3:return p.googlepayConfig=o.sent(),h=this.googlepayConfig.allowedPaymentMethods,this.setGatewayIdentifier(null===(c=null===(u=null===(s=h[0])||void 0===s?void 0:s.tokenizationSpecification)||void 0===u?void 0:u.parameters)||void 0===c?void 0:c.gateway),[2]}}))}))},t.prototype.getPaymentGatewayParameters=function(){if(this.googlepayConfig){var e=this.googlepayConfig.allowedPaymentMethods[0].tokenizationSpecification.parameters.gatewayMerchantId;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e}}return{gateway:this.getGatewayIdentifier()}},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(Ss),Ms=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalSDK=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){return i=this.getPayPalSdkScriptConfigOrThrow(e,t,n),[2,this.loadPayPalSDK(i,r)]}))}))},e.prototype.getGooglePayConfigOrThrow=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!this.window.paypal)throw new wo;return this.googlepayConfig?[3,2]:(e=this,[4,this.window.paypal.Googlepay().config()]);case 1:e.googlepayConfig=t.sent(),t.label=2;case 2:return[2,this.googlepayConfig]}}))}))},e.prototype.loadPayPalSDK=function(e,t){return void 0===t&&(t=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this.window.paypal&&!t?[3,2]:(n=this.transformConfig(e.options),r=this.transformConfig(e.attributes),i=new URLSearchParams(n).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})]);case 1:o.sent(),o.label=2;case 2:if(!this.window.paypal)throw new wo;return[2,this.window.paypal]}}))}))},e.prototype.getPayPalSdkScriptConfigOrThrow=function(e,t,n){void 0===n&&(n=!0);var r=e.id,i=e.clientToken,a=e.initializationData;if(!(null==a?void 0:a.clientId))throw new co(uo.MissingPaymentMethod);var s=a.intent,u=a.clientId,c=a.merchantId,d=a.buyerCountry,l=a.attributionId,p=a.isVenmoEnabled,h=a.isHostedCheckoutEnabled,f=a.isPayPalCreditAvailable,m=a.isDeveloperModeApplicable,g=a.availableAlternativePaymentMethods,y=void 0===g?[]:g,_=a.enabledAlternativePaymentMethods,v=void 0===_?[]:_,C=a.isGooglePayEnabled,S=h||n,I="paypalcommercecreditcards"===r,w=I?["card"]:[],E=I?[]:["card"],b=n?["card-fields"]:[],P=f?["credit","paylater"]:[],A=f?[]:["credit","paylater"],T=n||!S,O=T&&p?["venmo"]:[],R=T&&p?[]:["venmo"],M=T?v:[],k=T?y.filter((function(e){return!v.includes(e)})):y,D=(0,o.__spreadArrays)(E,A,R,k),N=(0,o.__spreadArrays)(w,P,O,M),L=C?["googlepay"]:[];return{options:(0,o.__assign)({"client-id":u,"merchant-id":c,"enable-funding":N.length>0?N:void 0,"disable-funding":D.length>0?D:void 0,commit:S,components:(0,o.__spreadArrays)(["buttons","hosted-fields","messages","payment-fields","legal"],L,b),currency:t,intent:s},m&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":l,"data-client-token":i}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}(),ks=Ja((function(e){return new Es(e,new Ps(Ts(),new Rs(e,new Ms((0,$n.getScriptLoader)())),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaypaypalcommerce"}]);var Ds,Ns,Ls,zs,Fs,Us,qs;!function(e){e.BuyNow="BUY_NOW"}(Ds||(Ds={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Ns||(Ns={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Ls||(Ls={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(zs||(zs={})),function(e){e.pill="pill",e.rect="rect"}(Fs||(Fs={})),function(e){e.OXXO="oxxo"}(Us||(Us={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(qs||(qs={}));const Bs=function(){function e(e,t,n,r){this.formPoster=e,this.paymentIntegrationService=t,this.paypalCommerceRequestSender=n,this.paypalCommerceScriptLoader=r}return e.prototype.loadPayPalSdk=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return i=this.paymentIntegrationService.getState(),a=t||i.getCartOrThrow().currency.code,s=i.getPaymentMethodOrThrow(e),u=this,[4,this.paypalCommerceScriptLoader.getPayPalSDK(s,a,n,r)];case 1:return u.paypalSdk=o.sent(),[2,this.paypalSdk]}}))}))},e.prototype.getPayPalSdkOrThrow=function(){if(!this.paypalSdk)throw new wo;return this.paypalSdk},e.prototype.createBuyNowCartOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!(t=e.getBuyNowCartRequestBody()))throw new co(uo.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.paymentIntegrationService.createBuyNowCart(t)];case 2:return[2,n.sent()];case 3:throw n.sent(),new Qa;case 4:return[2]}}))}))},e.prototype.createOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return n=this.paymentIntegrationService.getState().getCartOrThrow().id,[4,this.paypalCommerceRequestSender.createOrder(e,(0,o.__assign)({cartId:n},t))];case 1:return[2,r.sent().orderId]}}))}))},e.prototype.createOrderCardFields=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(s){switch(s.label){case 0:return n=this.paymentIntegrationService.getState().getCartOrThrow().id,[4,this.paypalCommerceRequestSender.createOrder(e,(0,o.__assign)({cartId:n},t))];case 1:return r=s.sent(),i=r.orderId,a=r.setupToken,[2,(0,o.__assign)({orderId:i},a?{setupToken:a}:{})]}}))}))},e.prototype.updateOrder=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:e=this.paymentIntegrationService.getState(),t=e.getCartOrThrow(),n=e.getConsignmentsOrThrow()[0],r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.paypalCommerceRequestSender.updateOrder({availableShippingOptions:n.availableShippingOptions,cartId:t.id,selectedShippingOption:n.selectedShippingOption})];case 2:return r.sent(),[3,4];case 3:throw r.sent(),new c;case 4:return[2]}}))}))},e.prototype.getOrderStatus=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.paypalCommerceRequestSender.getOrderStatus(e,t)];case 1:return[2,n.sent().status];case 2:throw n.sent(),new c;case 3:return[2]}}))}))},e.prototype.tokenizePayment=function(e,t){var n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new co(uo.MissingOrderId);return this.formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===Ds.BuyNow&&{cart_id:n.id}))},e.prototype.submitPayment=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return n={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}},[4,this.paymentIntegrationService.submitPayment({methodId:e,paymentData:n})];case 1:return r.sent(),[2]}}))}))},e.prototype.getShippingOptionOrThrow=function(e){var t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],r=n.find((function(e){return e.isRecommended})),i=(e?n.find((function(t){return t.id===e})):n.find((function(e){var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)})))||r||n[0];if(!i)throw new Error("Your order can't be shipped to this address");return i},e.prototype.getAddress=function(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:"",company:"",address1:(null==e?void 0:e.address1)||"",address2:"",city:(null==e?void 0:e.city)||"",countryCode:(null==e?void 0:e.countryCode)||"",postalCode:(null==e?void 0:e.postalCode)||"",stateOrProvince:"",stateOrProvinceCode:(null==e?void 0:e.stateOrProvinceCode)||"",customFields:[]}},e.prototype.getBillingAddressFromOrderDetails=function(e){var t=e.payer;return this.getAddress({firstName:t.name.given_name,lastName:t.name.surname,email:t.email_address,address1:t.address.address_line_1,city:t.address.admin_area_2,countryCode:t.address.country_code,postalCode:t.address.postal_code,stateOrProvinceCode:t.address.admin_area_1})},e.prototype.getShippingAddressFromOrderDetails=function(e){var t,n,r=e.payer,i=(null===(n=null===(t=e.purchase_units[0])||void 0===t?void 0:t.shipping)||void 0===n?void 0:n.address)||{};return this.getAddress({firstName:r.name.given_name,lastName:r.name.surname,email:r.email_address,address1:i.address_line_1,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})},e.prototype.getValidButtonStyle=function(e){var t=e||{},n=t.color,r=t.height,i=t.label,o=t.shape,a={color:n&&zs[n]?n:void 0,height:this.getValidHeight(r),label:i&&Ls[i]?i:void 0,shape:o&&Fs[o]?o:void 0};return(0,m.omitBy)(a,m.isNil)},e.prototype.getValidHeight=function(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40},e.prototype.removeElement=function(e){var t=e&&document.getElementById(e);t&&(t.style.display="none")},e}();var Gs,xs="This API endpoint is for internal use only and may change in the future";!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(Gs||(Gs={}));const Ys=Gs,Vs=function(){function e(e){this.requestSender=e}return e.prototype.createOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return n="/api/storefront/payment/"+e,r=t,i=(0,o.__assign)({"X-API-INTERNAL":xs,"Content-Type":Ys.Json},bs),[4,this.requestSender.post(n,{headers:i,body:r})];case 1:return[2,a.sent().body]}}))}))},e.prototype.updateOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t=e,n=(0,o.__assign)({"X-API-INTERNAL":xs,"Content-Type":Ys.Json},bs),[4,this.requestSender.put("/api/storefront/initialization/paypalcommerce",{headers:n,body:t})];case 1:return[2,r.sent().body]}}))}))},e.prototype.getOrderStatus=function(e,t){return void 0===e&&(e="paypalcommerce"),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return n="/api/storefront/initialization/"+e,r=(0,o.__assign)({"X-API-INTERNAL":xs,"Content-Type":Ys.Json},bs),[4,this.requestSender.get(n,(0,o.__assign)({headers:r},t))];case 1:return[2,i.sent().body]}}))}))},e}(),Hs=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalSDK=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){return i=this.getPayPalSdkScriptConfigOrThrow(e,t,n),[2,this.loadPayPalSDK(i,r)]}))}))},e.prototype.loadPayPalSDK=function(e,t){return void 0===t&&(t=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this.window.paypal&&!t?[3,2]:(n=this.transformConfig(e.options),r=this.transformConfig(e.attributes),i=new URLSearchParams(n).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})]);case 1:o.sent(),o.label=2;case 2:if(!this.window.paypal)throw new wo;return[2,this.window.paypal]}}))}))},e.prototype.getPayPalSdkScriptConfigOrThrow=function(e,t,n){void 0===n&&(n=!0);var r=e.id,i=e.clientToken,a=e.initializationData;if(!(null==a?void 0:a.clientId))throw new co(uo.MissingPaymentMethod);var s=a.intent,u=a.clientId,c=a.merchantId,d=a.buyerCountry,l=a.attributionId,p=a.isVenmoEnabled,h=a.isHostedCheckoutEnabled,f=a.isPayPalCreditAvailable,m=a.isDeveloperModeApplicable,g=a.availableAlternativePaymentMethods,y=void 0===g?[]:g,_=a.enabledAlternativePaymentMethods,v=void 0===_?[]:_,C=a.isGooglePayEnabled,S=h||n,I="paypalcommercecreditcards"===r,w=I?["card"]:[],E=I?[]:["card"],b=f?["credit","paylater"]:[],P=f?[]:["credit","paylater"],A=n||!S,T=A&&p?["venmo"]:[],O=A&&p?[]:["venmo"],R=A?v:[],M=A?y.filter((function(e){return!v.includes(e)})):y,k=C?["googlepay"]:[],D=n?["card-fields"]:[],N=(0,o.__spreadArrays)(E,P,O,M),L=(0,o.__spreadArrays)(w,b,T,R);return{options:(0,o.__assign)({"client-id":u,"merchant-id":c,"enable-funding":L.length>0?L:void 0,"disable-funding":N.length>0?N:void 0,commit:S,components:(0,o.__spreadArrays)(["buttons","hosted-fields","payment-fields","legal"],k,D),currency:t,intent:s},m&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":l,"data-client-token":i}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}(),js=function(e){var t=e.getState().getHost;return new Bs((0,i.createFormPoster)(),e,new Vs((0,r.createRequestSender)({host:t()})),new Hs((0,$n.getScriptLoader)()))},Ws=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.paypalcommerce,r=e.containerId,i=e.methodId,a=Boolean(null==n?void 0:n.buyNowInitializeOptions),!i)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!r)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.paypalcommerce" argument is not provided.');if(a&&!n.currencyCode)throw new so('Unable to initialize payment because "options.paypalcommerce.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new so('Unable to initialize payment because "options.paypalcommerce.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return a?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return s=a?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(i,s,!1)];case 3:return o.sent(),this.renderButton(r,i,n),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.buyNowInitializeOptions,a=n.style,s=n.onComplete,u=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),c=(this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t).initializationData||{}).isHostedCheckoutEnabled,d={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommerce")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},l={onClick:function(){return r.handleClick(i)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},p={onShippingChange:function(e){return r.onShippingChange(e)},onApprove:function(e,n){return r.onHostedCheckoutApprove(e,n,t,s)}},h=(0,o.__assign)((0,o.__assign)((0,o.__assign)({fundingSource:u.FUNDING.PAYPAL,style:this.paypalCommerceIntegrationService.getValidButtonStyle(a)},d),i&&l),c&&p),f=u.Buttons(h);f.isEligible()?f.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.onHostedCheckoutApprove=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.orderID)throw new co(uo.MissingOrderId);return i=this.paymentIntegrationService.getState(),a=i.getCartOrThrow(),[4,t.order.get()];case 1:s=o.sent(),o.label=2;case 2:return o.trys.push([2,9,,10]),u=this.paypalCommerceIntegrationService.getBillingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateBillingAddress(u)];case 3:return o.sent(),a.lineItems.physicalItems.length>0?(c=this.paypalCommerceIntegrationService.getShippingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateShippingAddress(c)]):[3,6];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:o.sent(),o.label=6;case 6:return[4,this.paymentIntegrationService.submitOrder({},{params:{methodId:n}})];case 7:return o.sent(),[4,this.paypalCommerceIntegrationService.submitPayment(n,e.orderID)];case 8:return o.sent(),r&&"function"==typeof r&&r(),[2,!0];case 9:throw d=o.sent(),new Error(d);case 10:return[2]}}))}))},e.prototype.onShippingChange=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=this.paypalCommerceIntegrationService.getAddress({city:e.shipping_address.city,countryCode:e.shipping_address.country_code,postalCode:e.shipping_address.postal_code,stateOrProvinceCode:e.shipping_address.state}),o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(n)];case 2:return o.sent(),[4,this.paymentIntegrationService.updateShippingAddress(n)];case 3:return o.sent(),r=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(null===(t=e.selected_shipping_option)||void 0===t?void 0:t.id),[4,this.paymentIntegrationService.selectShippingOption(r.id)];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return o.sent(),[3,7];case 6:throw i=o.sent(),new Error(i);case 7:return[2]}}))}))},e}(),Ks=Ja((function(e){return new Ws(e,js(e))}),[{id:"paypalcommerce"}]),Js=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalAxo=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.window.paypalAxo?[3,2]:(r=this.getPayPalSdkConnectConfiguration(e,t,n),[4,this.loadPayPalSdk(r)]);case 1:if(i.sent(),!this.window.paypalAxo)throw new wo;i.label=2;case 2:return[2,this.window.paypalAxo]}}))}))},e.prototype.getPayPalFastlaneSdk=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.window.paypalFastlaneSdk?[3,2]:(r=this.getPayPalFastlaneSdkConfiguration(e,t,n),[4,this.loadPayPalSdk(r)]);case 1:if(i.sent(),!this.window.paypalFastlaneSdk)throw new wo;i.label=2;case 2:return[2,this.window.paypalFastlaneSdk]}}))}))},e.prototype.getPayPalMessages=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.window.paypalMessages?[3,2]:(n=this.getPayPalSdkMessagesConfiguration(e,t),[4,this.loadPayPalSdk(n)]);case 1:if(r.sent(),!this.window.paypalMessages)throw new wo;r.label=2;case 2:return[2,this.window.paypalMessages]}}))}))},e.prototype.loadPayPalSdk=function(e){var t=e.options,n=e.attributes;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e=this.transformConfig(t),r=this.transformConfig(n),i=new URLSearchParams(e).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})];case 1:return o.sent(),[2]}}))}))},e.prototype.getPayPalSdkConnectConfiguration=function(e,t,n){var r=e.clientToken,i=e.initializationData;if(!i||!i.clientId)throw new co(uo.MissingPaymentMethod);var o=i.intent,a=i.clientId,s=i.merchantId,u=i.attributionId,c=i.connectClientToken;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["connect"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalAxo","data-partner-attribution-id":u,"data-user-id-token":c||r}}},e.prototype.getPayPalFastlaneSdkConfiguration=function(e,t,n){var r=e.clientToken,i=e.initializationData;if(!i||!i.clientId)throw new co(uo.MissingPaymentMethod);var o=i.intent,a=i.clientId,s=i.merchantId,u=i.attributionId,c=i.connectClientToken;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":u,"data-user-id-token":c||r}}},e.prototype.getPayPalSdkMessagesConfiguration=function(e,t){var n=e.initializationData;if(!n||!n.clientId)throw new co(uo.MissingPaymentMethod);var r=n.clientId,i=n.merchantId,a=n.attributionId,s=n.isDeveloperModeApplicable,u=n.buyerCountry;return{options:(0,o.__assign)({"client-id":r,"merchant-id":i,components:["messages"],currency:t},s&&{"buyer-country":u}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}(),Zs=function(){function e(e,t,n){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t,this.paypalCommerceSdk=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercecredit,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.currencyCode,u=i.messagingContainerId,c=!!a,!r)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new so('Unable to initialize payment because "options.paypalcommercecredit" argument is not provided.');if(c&&!s)throw new so('Unable to initialize payment because "options.paypalcommercecredit.currencyCode" argument is not provided.');if(c&&"function"!=typeof(null==a?void 0:a.getBuyNowCartRequestBody))throw new so('Unable to initialize payment because "options.paypalcommercecredit.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return c?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return d=this.paymentIntegrationService.getState(),l=c?s:d.getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,l,!1)];case 3:return o.sent(),this.renderButton(n,r,t),l&&u?(p=d.getPaymentMethodOrThrow(r),[4,this.paypalCommerceSdk.getPayPalMessages(p,l)]):[3,5];case 4:h=o.sent(),this.renderMessages(h,u),o.label=5;case 5:return[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.buyNowInitializeOptions,a=n.style,s=n.onComplete,u=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),c=(this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t).initializationData||{}).isHostedCheckoutEnabled,d={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercecredit")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},l={onClick:function(){return r.handleClick(i)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},p={onShippingChange:function(e){return r.onShippingChange(e)},onApprove:function(e,n){return r.onHostedCheckoutApprove(e,n,t,s)}},h=[u.FUNDING.PAYLATER,u.FUNDING.CREDIT],f=!1;h.forEach((function(t){if(!f){var n=(0,o.__assign)((0,o.__assign)((0,o.__assign)({fundingSource:t,style:r.paypalCommerceIntegrationService.getValidButtonStyle(a)},d),i&&l),c&&p),s=u.Buttons(n);s.isEligible()&&(s.render("#"+e),f=!0)}})),f||this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.onHostedCheckoutApprove=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.orderID)throw new co(uo.MissingOrderId);return i=this.paymentIntegrationService.getState(),a=i.getCartOrThrow(),[4,t.order.get()];case 1:s=o.sent(),o.label=2;case 2:return o.trys.push([2,9,,10]),u=this.paypalCommerceIntegrationService.getBillingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateBillingAddress(u)];case 3:return o.sent(),a.lineItems.physicalItems.length>0?(c=this.paypalCommerceIntegrationService.getShippingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateShippingAddress(c)]):[3,6];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:o.sent(),o.label=6;case 6:return[4,this.paymentIntegrationService.submitOrder({},{params:{methodId:n}})];case 7:return o.sent(),[4,this.paypalCommerceIntegrationService.submitPayment(n,e.orderID)];case 8:return o.sent(),r&&"function"==typeof r&&r(),[2,!0];case 9:throw d=o.sent(),new Error(d);case 10:return[2]}}))}))},e.prototype.onShippingChange=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=this.paypalCommerceIntegrationService.getAddress({city:e.shipping_address.city,countryCode:e.shipping_address.country_code,postalCode:e.shipping_address.postal_code,stateOrProvinceCode:e.shipping_address.state}),o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(n)];case 2:return o.sent(),[4,this.paymentIntegrationService.updateShippingAddress(n)];case 3:return o.sent(),r=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(null===(t=e.selected_shipping_option)||void 0===t?void 0:t.id),[4,this.paymentIntegrationService.selectShippingOption(r.id)];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return o.sent(),[3,7];case 6:throw i=o.sent(),new Error(i);case 7:return[2]}}))}))},e.prototype.renderMessages=function(e,t){if(t&&document.getElementById(t)){var n={amount:this.paymentIntegrationService.getState().getCartOrThrow().cartAmount,placement:"cart",style:{layout:"text"}};e.Messages(n).render("#"+t)}},e}(),Qs=Ja((function(e){return new Zs(e,js(e),new Js((0,$n.createScriptLoader)()))}),[{id:"paypalcommercecredit"}]),Xs=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercevenmo,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.currencyCode,u=!!a,!r)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new so('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');if(u&&!s)throw new so('Unable to initialize payment because "options.paypalcommercevenmo.currencyCode" argument is not provided.');if(u&&"function"!=typeof(null==a?void 0:a.getBuyNowCartRequestBody))throw new so('Unable to initialize payment because "options.paypalcommercevenmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return u?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return c=u?s:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,c,!1)];case 3:return o.sent(),this.renderButton(n,r,t),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.buyNowInitializeOptions,a=n.style,s=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),u=s.FUNDING.VENMO,c={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercevenmo")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},d={onClick:function(){return r.handleClick(i)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},l=(0,o.__assign)((0,o.__assign)({fundingSource:u,style:this.getValidVenmoButtonStyles(a)},c),i&&d),p=s.Buttons(l);p.isEligible()?p.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.getValidVenmoButtonStyles=function(e){var t=this.paypalCommerceIntegrationService.getValidButtonStyle(e);return t.color===zs.gold?(0,o.__assign)((0,o.__assign)({},t),{color:void 0}):t},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e}(),$s=Ja((function(e){return new Xs(e,js(e))}),[{id:"paypalcommercevenmo"}]),eu=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercealternativemethods,n=e.containerId,r=e.methodId,a=(i=t||{}).apm,s=i.buyNowInitializeOptions,u=i.currencyCode,c=!!s,!r)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new so('Unable to initialize payment because "options.paypalcommercealternativemethods" argument is not provided.');if(!a)throw new so('Unable to initialize payment because "options.paypalcommercealternativemethods.apm" argument is not provided.');if(c&&!u)throw new so('Unable to initialize payment because "options.paypalcommercealternativemethods.currencyCode" argument is not provided.');if(c&&"function"!=typeof(null==s?void 0:s.getBuyNowCartRequestBody))throw new so('Unable to initialize payment because "options.paypalcommercealternativemethods.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return c?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return d=c?u:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,d,!1)];case 3:return o.sent(),this.renderButton(n,r,t),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.apm,a=n.buyNowInitializeOptions,s=n.style,u=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow();if(!Object.values(u.FUNDING).includes(i))throw new so('Unable to initialize PayPal button because "options.paypalcommercealternativemethods.apm" argument is not valid funding source.');var c={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercealternativemethod")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},d={onClick:function(){return r.handleClick(a)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},l=(0,o.__assign)((0,o.__assign)({fundingSource:i,style:this.paypalCommerceIntegrationService.getValidButtonStyle(s)},c),a&&d),p=u.Buttons(l);p.isEligible()?p.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e}(),tu=Ja((function(e){return new eu(e,js(e))}),[{id:"paypalcommercealternativemethods"}]);var nu,ru,iu,ou,au;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(nu||(nu={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(ru||(ru={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(iu||(iu={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(ou||(ou={})),function(e){e.PILL="pill",e.RECT="rect"}(au||(au={}));const su=function(){function e(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(t=this.paymentIntegrationService.getState(),n=t.getPaymentMethodOrThrow(e.methodId),!e.paypal)throw new so;if(!n.config.merchantId)throw new co(uo.MissingPaymentMethod);return[4,this.paypalExpressScriptLoader.loadPaypalSDK(n.config.merchantId)];case 1:return r=i.sent(),this.renderButton(e,r),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t){var n,r=this,i=e.containerId,o=e.methodId,a=e.paypal,s=a.allowCredit,u=a.clientId,c=a.onPaymentError,d=a.shouldProcessPayment,l=a.style,p=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!p.config.merchantId)throw new co(uo.MissingPaymentMethod);var h=p.config.merchantId,f=p.config.testMode?"sandbox":"production",m=((n={})[f]=u,n),g=t.FUNDING.CREDIT||"credit",y=s?[g]:[],_=s?[]:[g];return t.Button.render({env:f,client:m,commit:d,funding:{allowed:y,disallowed:_},style:this.getStyle(l),payment:function(e,t){return r.setupPayment(h,t,c)},onAuthorize:function(e,t){return r.tokenizePayment(e,o,t,d)}},i)},e.prototype.getStyle=function(e){var t=e||{},n=t.color,r=t.fundingicons,i=t.label,o=t.layout,a=t.shape,s=t.size,u=t.tagline;return{color:n,fundingicons:r,label:i,layout:o,shape:a||au.RECT,size:"small"===s?ru.RESPONSIVE:s,tagline:u}},e.prototype.setupPayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:if(!t)throw new fo(ho.CheckoutButtonNotInitialized);u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.paymentIntegrationService.loadDefaultCheckout()];case 2:return r=u.sent(),i=r.getCartOrThrow().id,a=r.getHost()||"",[4,t.request.post(a+"/api/storefront/payment/paypalexpress",{merchantId:e,cartId:i},{headers:(0,o.__assign)({"X-API-INTERNAL":xs},bs)})];case 3:return[2,u.sent().id];case 4:throw s=u.sent(),n&&n(s),s;case 5:return[2]}}))}))},e.prototype.tokenizePayment=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!n)throw new fo(ho.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new co(uo.MissingPayment);return i=this.paymentIntegrationService.getState(),a=i.getPaymentMethodOrThrow(t),[4,n.payment.get(e.paymentID)];case 1:return s=o.sent(),[2,this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:a.id,action:r?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(s.payer.payer_info)})]}}))}))},e}();const uu=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.loadPaypalSDK=function(e){return void 0===e&&(e=""),(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=(0,o.__assign)({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}}),[4,this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t)];case 1:if(n.sent(),!this.window.paypal)throw new wo;return[2,this.window.paypal]}}))}))},e}(),cu=Ja((function(e){return new su(e,new uu((0,$n.getScriptLoader)()),(0,i.createFormPoster)())}),[{id:"paypalexpress"}]);function du(e){var t=null!=e?e:{},o=t.host,a=t.locale,s=void 0===a?"en":a,u=Vn(),c=(0,r.createRequestSender)({host:o}),d=(0,i.createFormPoster)({host:o}),l=function(e,t){void 0===t&&(t=n);for(var r=new Va,i=function(t){if(!function(e){return"resolveIds"in e}(t))return"continue";for(var n=0,i=t.resolveIds;n<i.length;n++){var o=i[n];r.register(o,(function(){return t(e)}))}},o=0,a=Object.entries(t);o<a.length;o++)i(a[o][1]);return r}(function(e){var t=e.getState().config,n=t.getHost,i=t.getLocale,o=(0,r.createRequestSender)({host:n()}),a=new Zi(Wi),s=new ar(new lr(o),new mr(new gr(o)),new Cr(new Sr(o))),u=new fr(new lr(o)),c=new $r(e),d=new ti(new ii(o),new fr(new lr(o))),l=new nr(new ir(o),new xi(new Yi(o))),p=new ki(new Ni(o),new lr(o)),h=new Wn(new Xn(o)),f=new oi(new ai(function(e){var t=(0,si.createClient)();return e.subscribe((function(e){var n=e.config.getStoreConfig();n&&t.setHost(n.paymentSettings.bigpayBaseUrl)}),(function(e){return e.config.getStoreConfig()})),t}(e)),d,new Ai,new zr(Yr((0,$n.createScriptLoader)()))),m=new _r(new vr(o),s,new Fi(Yr((0,$n.createScriptLoader)()),new Ui(o))),g=new qi(new Bi(o)),y=Yr((0,$n.createScriptLoader)()),_=new Ui(o),v=new Fi(y,_),C=new or(o),S=new Ti,I=new Li(new zi(o,{locale:i()})),w=new Oi(new Ri(o),s);return new Ki(e,a,s,u,c,d,l,p,h,f,m,C,g,v,S,I,w)}(u));return new oo(u,new ao(function(e,t,n,r,i){var o=new No,a=(0,$n.getScriptLoader)(),s=new lr(t),u=new ar(s,new mr(new gr(t)),new Cr(new Sr(t))),c=new Wn(new Xn(t)),d=new xo(new Do(a,window)),l=new or(t),p=new va(t);return o.register(gi.AMAZON_PAY_V2,(function(){return new _a(e,u,new Io(new Eo((0,$n.getScriptLoader)())),l,p)})),o.register(gi.BRAINTREE_PAYPAL,(function(){return new ba(e,u,l,d,n,window)})),o.register(gi.BRAINTREE_PAYPAL_CREDIT,(function(){return new Ma(e,u,l,d,n,window)})),o.register(gi.BRAINTREE_VENMO,(function(){return new Da(e,c,l,d,n)})),o.register(gi.GOOGLEPAY_ADYENV2,(function(){return new Na(e,n,u,ea(e,new ta),l)})),o.register(gi.GOOGLEPAY_ADYENV3,(function(){return new Na(e,n,u,ea(e,new na),l)})),o.register(gi.GOOGLEPAY_AUTHORIZENET,(function(){return new Na(e,n,u,ea(e,new ia),l)})),o.register(gi.GOOGLEPAY_BNZ,(function(){return new Na(e,n,u,ea(e,new oa),l)})),o.register(gi.GOOGLEPAY_CHECKOUTCOM,(function(){return new Na(e,n,u,ea(e,new sa(t)),l)})),o.register(gi.GOOGLEPAY_CYBERSOURCEV2,(function(){return new Na(e,n,u,ea(e,new ua),l)})),o.register(gi.GOOGLEPAY_ORBITAL,(function(){return new Na(e,n,u,ea(e,new ca),l)})),o.register(gi.GOOGLEPAY_STRIPE,(function(){return new Na(e,n,u,ea(e,new da),l)})),o.register(gi.GOOGLEPAY_STRIPEUPE,(function(){return new Na(e,n,u,ea(e,new la),l)})),o.register(gi.MASTERPASS,(function(){return new Fa(e,u,new ha(a),r)})),o.register(gi.PAYPALEXPRESS,(function(){return new Ua(e,u,new fa(a),n,i)})),o.register(gi.GOOGLEPAY_WORLDPAYACCESS,(function(){return new Na(e,n,u,ea(e,new pa),l)})),o}(u,c,d,s,o),l,new Wn(new Xn(c))))}module.exports=t})();
|
|
1
|
+
(()=>{"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 r in n)e.o(n,r)&&!e.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:n[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,{createCheckoutButtonInitializer:()=>du,createTimeout:()=>r.createTimeout});var n={};e.r(n),e.d(n,{createApplePayButtonStrategy:()=>rs,createBoltButtonStrategy:()=>ls,createGooglePayBraintreeButtonStrategy:()=>Os,createGooglePayPayPalCommerceButtonStrategy:()=>ks,createPayPalCommerceAlternativeMethodsButtonStrategy:()=>tu,createPayPalCommerceButtonStrategy:()=>Ks,createPayPalCommerceCreditButtonStrategy:()=>Qs,createPayPalCommerceVenmoButtonStrategy:()=>$s,createPaypalExpressButtonStrategy:()=>cu});const r=require("@bigcommerce/request-sender"),i=require("@bigcommerce/form-poster"),o=require("tslib"),a=require("@bigcommerce/data-store"),s=function(e){function t(t){var n,r,i=this.constructor,o=e.call(this,t||"An unexpected error has occurred.")||this;return o.name="StandardError",o.type="standard",n=o,r=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,i):o.stack=new Error(o.message).stack,o}return(0,o.__extends)(t,e),t}(Error);var u={body:{},headers:{},status:0};const c=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.message,o=r.errors,a=this,s=t||u,c=s.body,d=s.headers,l=s.status;return(a=e.call(this,i||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=c,a.headers=d,a.status=l,a.errors=o||[],a}return(0,o.__extends)(t,e),t}(s),d=function(e){function t(t){var n=e.call(this,t,{message:"There is a problem processing your payment. Please try again later."})||this;return n.name="PaymentMethodInvalidError",n.type="payment_method_invalid",n}return(0,o.__extends)(t,e),t}(c);const l=function(e){function t(t){var n,r,i=this.constructor,o=e.call(this,t||"An unexpected error has occurred.")||this;return o.name="StandardError",o.type="standard",n=o,r=i.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(o,i):o.stack=new Error(o.message).stack,o}return(0,o.__extends)(t,e),t}(Error);var p={body:{},headers:{},status:0};const h=function(e){function t(t,n){var r=void 0===n?{}:n,i=r.message,o=r.errors,a=this,s=t||p,u=s.body,c=s.headers,d=s.status;return(a=e.call(this,i||"An unexpected error has occurred.")||this).name="RequestError",a.type="request",a.body=u,a.headers=c,a.status=d,a.errors=o||[],a}return(0,o.__extends)(t,e),t}(l),f=function(e){function t(t,n){var r=e.call(this,t,{message:n||"An unexpected error has occurred. The checkout process cannot continue as a result."})||this;return r.name="UnrecoverableError",r.type="unrecoverable",r}return(0,o.__extends)(t,e),t}(h),m=require("lodash");function g(e){return e.reduce((function(e,t){return t?(0,o.__spreadArrays)(e,[t]):e}),[]).join(" ")}function y(e,t){var n=e.body.errors,r=void 0===n?[]:n;return new h(e,{message:_(r)||t,errors:r})}function _(e){if(Array.isArray(e))return e.reduce((function(e,t){return t&&t.message?(0,o.__spreadArrays)(e,[t.message]):e}),[]).join(" ")}const v=function(e){function t(t){var n=e.call(this,t,{message:"The request has timed out or aborted."})||this;return n.name="TimeoutError",n.type="timeout",n}return(0,o.__extends)(t,e),t}(h),C=function(){function e(){this._factoryMethods={},this.register("default",(function(e,t){return new h(e,{message:t})})),this.register("internal",(function(e,t){return function(e,t){var n=e.body,r=n.errors,i=void 0===r?[]:r;return new h(e,{message:g(i)||n.detail||n.title||t,errors:i.length?i.map((function(e){return{code:n.type,message:e}})):[{code:n.type,message:n.detail||n.title}]})}(e,t)})),this.register("storefront",(function(e,t){return function(e,t){var n=e.body;return new h(e,{message:t||n.detail||n.title,errors:[{code:n.code||n.type,message:n.detail||n.title}]})}(e,t)})),this.register("payment",(function(e,t){return y(e,t)})),this.register("timeout",(function(e){return new v(e)}))}return e.prototype.register=function(e,t){this._factoryMethods[e]=t},e.prototype.createError=function(e,t){return(this._factoryMethods[this._getType(e)]||this._factoryMethods.default)(e,t)},e.prototype._getType=function(e){if(0===e.status)return"timeout";if(this._isStorefrontErrorResponseBody(e.body))return"storefront";if(this._isInternalErrorResponseBody(e.body)){var t=(0,m.last)(e.body.type.split("/"));return t&&this._factoryMethods[t]?t:"internal"}var n=(0,m.last)(e.body&&e.body.errors);return n&&n.code&&this._factoryMethods[n.code]?n.code:"payment"},e.prototype._isStorefrontErrorResponseBody=function(e){var t=e;return!this._isInternalErrorResponseBody(e)&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status&&"string"==typeof t.detail},e.prototype._isInternalErrorResponseBody=function(e){var t=e;return"object"==typeof t.errors&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status},e}(),S=require("rxjs"),I=require("rxjs/operators");var w,E,b,P;function A(e,t){return Array.isArray(e)?e.map((function(e){return A(e,t)})):(0,m.isPlainObject)(e)?(0,m.transform)((0,m.omitBy)(e,t),(function(e,n,r){e[r]=A(n,t)}),{}):e}function T(e,t){return function(e){return e.type===E.ClearError}(t)?A(e,(function(e){return e===t.payload})):e}function O(e,t,n){return e===t||(e&&t&&"object"==typeof e&&"object"==typeof t?Array.isArray(e)&&Array.isArray(t)?function(e,t,n){if(e.length!==t.length)return!1;for(var r=0,i=e.length;r<i;r++)if(!O(e[r],t[r],n))return!1;return!0}(e,t,n):!Array.isArray(e)&&!Array.isArray(t)&&(e instanceof Date&&t instanceof Date?function(e,t){return e.getTime()===t.getTime()}(e,t):!(e instanceof Date||t instanceof Date)&&(e instanceof RegExp&&t instanceof RegExp?function(e,t){return e.toString()===t.toString()}(e,t):!(e instanceof RegExp||t instanceof RegExp)&&function(e,t,n){var r=n&&n.keyFilter,i=r?Object.keys(e).filter(r):Object.keys(e),o=r?Object.keys(t).filter(r):Object.keys(t);if(i.length!==o.length)return!1;for(var a=0,s=i.length;a<s;a++){var u=i[a];if(!Object.prototype.hasOwnProperty.call(t,u))return!1;if(!O(e[u],t[u],n))return!1}return!0}(e,t,n))):e===t)}function R(e,t){return void 0===t||O(e,t)?e:t}function M(e,t,n){var r;return e&&Object.prototype.hasOwnProperty.call(e,t)&&O(e[t],n)?e:(0,o.__assign)((0,o.__assign)({},e),((r={})[t]=n,r))}!function(e){e.LoadCheckoutRequested="LOAD_CHECKOUT_REQUESTED",e.LoadCheckoutSucceeded="LOAD_CHECKOUT_SUCCEEDED",e.LoadCheckoutFailed="LOAD_CHECKOUT_FAILED",e.UpdateCheckoutRequested="UPDATE_CHECKOUT_REQUESTED",e.UpdateCheckoutSucceeded="UPDATE_CHECKOUT_SUCCEEDED",e.UpdateCheckoutFailed="UPDATE_CHECKOUT_FAILED"}(w||(w={})),function(e){e.ClearError="CLEAR_ERROR"}(E||(E={})),function(e){e.UpdateSubscriptionsRequested="UPDATE_SUBSCRIPTIONS_REQUESTED",e.UpdateSubscriptionsSucceeded="UPDATE_SUBSCRIPTIONS_SUCCEEDED",e.UpdateSubscriptionsFailed="UPDATE_SUBSCRIPTIONS_FAILED"}(b||(b={})),function(e){e.UpdateBillingAddressRequested="UPDATE_BILLING_ADDRESS_REQUESTED",e.UpdateBillingAddressSucceeded="UPDATE_BILLING_ADDRESS_SUCCEEDED",e.UpdateBillingAddressFailed="UPDATE_BILLING_ADDRESS_FAILED",e.ContinueAsGuestRequested="CONTINUE_AS_GUEST_REQUESTED",e.ContinueAsGuestSucceeded="CONTINUE_AS_GUEST_SUCCEEDED",e.ContinueAsGuestFailed="CONTINUE_AS_GUEST_FAILED"}(P||(P={}));var k={errors:{},statuses:{}};function D(e,t){return void 0===e&&(e=k),(0,a.combineReducers)({data:N,errors:(0,a.composeReducers)(L,T),statuses:z})(e,t)}function N(e,t){switch(t.type){case P.UpdateBillingAddressSucceeded:case P.ContinueAsGuestSucceeded:case w.LoadCheckoutSucceeded:return R(e,t.payload&&t.payload.billingAddress);default:return e}}function L(e,t){switch(void 0===e&&(e=k.errors),t.type){case w.LoadCheckoutRequested:case w.LoadCheckoutSucceeded:return M(e,"loadError",void 0);case w.LoadCheckoutFailed:return M(e,"loadError",t.payload);case P.UpdateBillingAddressRequested:case P.UpdateBillingAddressSucceeded:return M(e,"updateError",void 0);case P.UpdateBillingAddressFailed:return M(e,"updateError",t.payload);case b.UpdateSubscriptionsRequested:case b.UpdateSubscriptionsSucceeded:case P.ContinueAsGuestRequested:case P.ContinueAsGuestSucceeded:return M(e,"continueAsGuestError",void 0);case b.UpdateSubscriptionsFailed:case P.ContinueAsGuestFailed:return M(e,"continueAsGuestError",t.payload);default:return e}}function z(e,t){switch(void 0===e&&(e=k.statuses),t.type){case w.LoadCheckoutRequested:return M(e,"isLoading",!0);case w.LoadCheckoutSucceeded:case w.LoadCheckoutFailed:return M(e,"isLoading",!1);case P.UpdateBillingAddressRequested:return M(e,"isUpdating",!0);case P.UpdateBillingAddressFailed:case P.UpdateBillingAddressSucceeded:return M(e,"isUpdating",!1);case P.ContinueAsGuestRequested:case b.UpdateSubscriptionsRequested:return M(e,"isContinuingAsGuest",!0);case b.UpdateSubscriptionsSucceeded:case b.UpdateSubscriptionsFailed:case P.ContinueAsGuestFailed:case P.ContinueAsGuestSucceeded:return M(e,"isContinuingAsGuest",!1);default:return e}}function F(e){return(0,m.isPlainObject)(e)}const U=function e(t,n,r){var i=(r||{}).matchObject,o=void 0===i?function(e,t){return void 0!==e.id&&e.id===t.id}:i;if(!t)return n;if(!n||t===n)return t;var a=0,s=0,u=function(e,t,n){return a+=e===t?1:0,s+=e===n?1:0,e},c=n.map((function(n,r){var i=t&&t[r];return F(i)&&F(n)?o(i,n)?u(q(i,n),i,n):u(R(i,n),i,n):(0,m.isArray)(i)&&(0,m.isArray)(n)?u(e(i,n),i,n):u(R(i,n),i,n)}));return a===n.length&&t&&t.length===n.length?t:s===n.length?n:c},q=function e(t,n){return t?n&&t!==n?Object.keys(n).reduce((function(t,r){var i=t[r],o=n[r];return F(i)&&F(o)?M(t,r,e(i,o)):(0,m.isArray)(i)&&(0,m.isArray)(o)?M(t,r,U(i,o)):M(t,r,o)}),t):t:n};var B,G,x;!function(e){e.ApplyCouponRequested="APPLY_COUPON_REQUESTED",e.ApplyCouponSucceeded="APPLY_COUPON_SUCCEEDED",e.ApplyCouponFailed="APPLY_COUPON_FAILED",e.RemoveCouponRequested="REMOVE_COUPON_REQUESTED",e.RemoveCouponSucceeded="REMOVE_COUPON_SUCCEEDED",e.RemoveCouponFailed="REMOVE_COUPON_FAILED"}(B||(B={})),function(e){e.ApplyGiftCertificateRequested="APPLY_GIFT_CERTIFICATE_REQUESTED",e.ApplyGiftCertificateSucceeded="APPLY_GIFT_CERTIFICATE_SUCCEEDED",e.ApplyGiftCertificateFailed="APPLY_GIFT_CERTIFICATE_FAILED",e.RemoveGiftCertificateRequested="REMOVE_GIFT_CERTIFICATE_REQUESTED",e.RemoveGiftCertificateSucceeded="REMOVE_GIFT_CERTIFICATE_SUCCEEDED",e.RemoveGiftCertificateFailed="REMOVE_GIFT_CERTIFICATE_FAILED"}(G||(G={})),function(e){e.CreateConsignmentsRequested="CREATE_CONSIGNMENTS_REQUESTED",e.CreateConsignmentsSucceeded="CREATE_CONSIGNMENTS_SUCCEEDED",e.CreateConsignmentsFailed="CREATE_CONSIGNMENTS_FAILED",e.UpdateConsignmentRequested="UPDATE_CONSIGNMENT_REQUESTED",e.UpdateConsignmentSucceeded="UPDATE_CONSIGNMENT_SUCCEEDED",e.UpdateConsignmentFailed="UPDATE_CONSIGNMENT_FAILED",e.DeleteConsignmentRequested="DELETE_CONSIGNMENT_REQUESTED",e.DeleteConsignmentSucceeded="DELETE_CONSIGNMENT_SUCCEEDED",e.DeleteConsignmentFailed="DELETE_CONSIGNMENT_FAILED",e.UpdateShippingOptionRequested="UPDATE_SHIPPING_OPTION_REQUESTED",e.UpdateShippingOptionSucceeded="UPDATE_SHIPPING_OPTION_SUCCEEDED",e.UpdateShippingOptionFailed="UPDATE_SHIPPING_OPTION_FAILED",e.LoadShippingOptionsRequested="LOAD_SHIPPING_OPTIONS_REQUESTED",e.LoadShippingOptionsSucceeded="LOAD_SHIPPING_OPTIONS_SUCCEEDED",e.LoadShippingOptionsFailed="LOAD_SHIPPING_OPTIONS_FAILED"}(x||(x={}));var Y,V={errors:{},statuses:{}};function H(e,t){return void 0===e&&(e=V),(0,a.combineReducers)({data:j,errors:(0,a.composeReducers)(K,T),statuses:W})(e,t)}function j(e,t){switch(t.type){case P.UpdateBillingAddressSucceeded:case w.LoadCheckoutSucceeded:case x.CreateConsignmentsSucceeded:case x.DeleteConsignmentSucceeded:case x.UpdateConsignmentSucceeded:case x.UpdateShippingOptionSucceeded:case x.LoadShippingOptionsSucceeded:case B.ApplyCouponSucceeded:case B.RemoveCouponSucceeded:case G.ApplyGiftCertificateSucceeded:case G.RemoveGiftCertificateSucceeded:return q(e,t.payload&&t.payload.cart);default:return e}}function W(e,t){switch(void 0===e&&(e=V.statuses),t.type){case w.LoadCheckoutRequested:return M(e,"isLoading",!0);case w.LoadCheckoutFailed:case w.LoadCheckoutSucceeded:return M(e,"isLoading",!1);default:return e}}function K(e,t){switch(void 0===e&&(e=V.errors),t.type){case w.LoadCheckoutRequested:case w.LoadCheckoutSucceeded:return M(e,"loadError",void 0);case w.LoadCheckoutFailed:return M(e,"loadError",t.payload);default:return e}}!function(e){e.InitializeButtonFailed="INITIALIZE_BUTTON_FAILED",e.InitializeButtonRequested="INITIALIZE_BUTTON_REQUESTED",e.InitializeButtonSucceeded="INITIALIZE_BUTTON_SUCCEEDED",e.DeinitializeButtonFailed="DEINITIALIZE_BUTTON_FAILED",e.DeinitializeButtonRequested="DEINITIALIZE_BUTTON_REQUESTED",e.DeinitializeButtonSucceeded="DEINITIALIZE_BUTTON_SUCCEEDED"}(Y||(Y={}));var J,Z={data:{},errors:{},statuses:{}},Q={initializedContainers:{}},X={},$={};function ee(e,t){var n,r,i;return void 0===e&&(e=Z),t.meta&&t.meta.methodId?(0,a.combineReducers)({data:(0,a.combineReducers)((n={},n[t.meta.methodId]=te,n)),errors:(0,a.combineReducers)((r={},r[t.meta.methodId]=ne,r)),statuses:(0,a.combineReducers)((i={},i[t.meta.methodId]=re,i))})(e,t):e}function te(e,t){var n;switch(void 0===e&&(e=Q),t.type){case Y.InitializeButtonSucceeded:return t.meta&&t.meta.containerId?q(e,{initializedContainers:(n={},n[t.meta.containerId]=!0,n)}):e;case Y.DeinitializeButtonSucceeded:return M(e,"initializedContainers",{})}return e}function ne(e,t){switch(void 0===e&&(e=X),t.type){case Y.InitializeButtonRequested:case Y.InitializeButtonSucceeded:return M(e,"initializeError",void 0);case Y.InitializeButtonFailed:return M(e,"initializeError",t.payload);case Y.DeinitializeButtonRequested:case Y.DeinitializeButtonSucceeded:return M(e,"deinitializeError",void 0);case Y.DeinitializeButtonFailed:return M(e,"deinitializeError",t.payload);default:return e}}function re(e,t){switch(void 0===e&&(e=$),t.type){case Y.InitializeButtonRequested:return M(e,"isInitializing",!0);case Y.InitializeButtonFailed:case Y.InitializeButtonSucceeded:return M(e,"isInitializing",!1);case Y.DeinitializeButtonRequested:return M(e,"isDeinitializing",!0);case Y.DeinitializeButtonFailed:case Y.DeinitializeButtonSucceeded:return M(e,"isDeinitializing",!1);default:return e}}!function(e){e.LoadConfigRequested="LOAD_CONFIG_REQUESTED",e.LoadConfigSucceeded="LOAD_CONFIG_SUCCEEDED",e.LoadConfigFailed="LOAD_CONFIG_FAILED"}(J||(J={}));var ie,oe={meta:{},errors:{},statuses:{}};function ae(e,t){return void 0===e&&(e=oe),(0,a.combineReducers)({data:se,errors:(0,a.composeReducers)(ue,T),statuses:ce})(e,t)}function se(e,t){return t.type===J.LoadConfigSucceeded?q(e,t.payload):e}function ue(e,t){switch(void 0===e&&(e=oe.errors),t.type){case J.LoadConfigSucceeded:return M(e,"loadError",void 0);case J.LoadConfigFailed:return M(e,"loadError",t.payload);default:return e}}function ce(e,t){switch(void 0===e&&(e=oe.statuses),t.type){case J.LoadConfigRequested:return M(e,"isLoading",!0);case J.LoadConfigSucceeded:case J.LoadConfigFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.LoadOrderRequested="LOAD_ORDER_REQUESTED",e.LoadOrderSucceeded="LOAD_ORDER_SUCCEEDED",e.LoadOrderFailed="LOAD_ORDER_FAILED",e.LoadOrderPaymentsRequested="LOAD_ORDER_PAYMENTS_REQUESTED",e.LoadOrderPaymentsSucceeded="LOAD_ORDER_PAYMENTS_SUCCEEDED",e.LoadOrderPaymentsFailed="LOAD_ORDER_PAYMENTS_FAILED",e.SubmitOrderRequested="SUBMIT_ORDER_REQUESTED",e.SubmitOrderSucceeded="SUBMIT_ORDER_SUCCEEDED",e.SubmitOrderFailed="SUBMIT_ORDER_FAILED",e.FinalizeOrderRequested="FINALIZE_ORDER_REQUESTED",e.FinalizeOrderSucceeded="FINALIZE_ORDER_SUCCEEDED",e.FinalizeOrderFailed="FINALIZE_ORDER_FAILED"}(ie||(ie={}));var de={errors:{},statuses:{}};function le(e,t){return void 0===e&&(e=de),(0,a.combineReducers)({data:pe,errors:(0,a.composeReducers)(he,T),statuses:fe})(e,t)}function pe(e,t){switch(t.type){case w.LoadCheckoutSucceeded:case B.ApplyCouponSucceeded:case x.UpdateShippingOptionSucceeded:case B.RemoveCouponSucceeded:case ie.LoadOrderSucceeded:return U(e,t.payload&&t.payload.coupons);default:return e}}function he(e,t){switch(void 0===e&&(e={}),t.type){case B.ApplyCouponRequested:case B.ApplyCouponSucceeded:return M(e,"applyCouponError",void 0);case B.ApplyCouponFailed:return M(e,"applyCouponError",t.payload);case B.RemoveCouponRequested:case B.RemoveCouponSucceeded:return M(e,"removeCouponError",void 0);case B.RemoveCouponFailed:return M(e,"removeCouponError",t.payload);default:return e}}function fe(e,t){switch(void 0===e&&(e={}),t.type){case B.ApplyCouponRequested:return M(e,"isApplyingCoupon",!0);case B.ApplyCouponSucceeded:case B.ApplyCouponFailed:return M(e,"isApplyingCoupon",!1);case B.RemoveCouponRequested:return M(e,"isRemovingCoupon",!0);case B.RemoveCouponSucceeded:case B.RemoveCouponFailed:return M(e,"isRemovingCoupon",!1);default:return e}}var me,ge={errors:{},statuses:{}};function ye(e,t){return void 0===e&&(e=ge),(0,a.combineReducers)({data:_e,errors:(0,a.composeReducers)(ve,T),statuses:Ce})(e,t)}function _e(e,t){switch(t.type){case w.LoadCheckoutSucceeded:case x.CreateConsignmentsSucceeded:case x.UpdateConsignmentSucceeded:case x.DeleteConsignmentSucceeded:case x.UpdateShippingOptionSucceeded:case B.ApplyCouponSucceeded:case B.RemoveCouponSucceeded:case G.ApplyGiftCertificateSucceeded:case G.RemoveGiftCertificateSucceeded:return U(e,t.payload&&t.payload.giftCertificates);default:return e}}function ve(e,t){switch(void 0===e&&(e=ge.errors),t.type){case G.ApplyGiftCertificateRequested:case G.ApplyGiftCertificateSucceeded:return M(e,"applyGiftCertificateError",void 0);case G.ApplyGiftCertificateFailed:return M(e,"applyGiftCertificateError",t.payload);case G.RemoveGiftCertificateRequested:case G.RemoveGiftCertificateSucceeded:return M(e,"removeGiftCertificateError",void 0);case G.RemoveGiftCertificateFailed:return M(e,"removeGiftCertificateError",t.payload);default:return e}}function Ce(e,t){switch(void 0===e&&(e=ge.statuses),t.type){case G.ApplyGiftCertificateRequested:return M(e,"isApplyingGiftCertificate",!0);case G.ApplyGiftCertificateSucceeded:case G.ApplyGiftCertificateFailed:return M(e,"isApplyingGiftCertificate",!1);case G.RemoveGiftCertificateRequested:return M(e,"isRemovingGiftCertificate",!0);case G.RemoveGiftCertificateSucceeded:case G.RemoveGiftCertificateFailed:return M(e,"isRemovingGiftCertificate",!1);default:return e}}!function(e){e.SignInCustomerRequested="SIGN_IN_CUSTOMER_REQUESTED",e.SignInCustomerSucceeded="SIGN_IN_CUSTOMER_SUCCEEDED",e.SignInCustomerFailed="SIGN_IN_CUSTOMER_FAILED",e.SignOutCustomerRequested="SIGN_OUT_CUSTOMER_REQUESTED",e.SignOutCustomerSucceeded="SIGN_OUT_CUSTOMER_SUCCEEDED",e.SignOutCustomerFailed="SIGN_OUT_CUSTOMER_FAILED",e.CreateCustomerRequested="CREATE_CUSTOMER_REQUESTED",e.CreateCustomerSucceeded="CREATE_CUSTOMER_SUCCEEDED",e.CreateCustomerFailed="CREATE_CUSTOMER_FAILED",e.CreateCustomerAddressRequested="CREATE_CUSTOMER_ADDRESS_REQUESTED",e.CreateCustomerAddressSucceeded="CREATE_CUSTOMER_ADDRESS_SUCCEEDED",e.CreateCustomerAddressFailed="CREATE_CUSTOMER_ADDRESS_FAILED",e.StripeLinkAuthenticated="STRIPE_LINK_AUTHENTICATED"}(me||(me={}));var Se,Ie={errors:{},statuses:{}};function we(e,t){return void 0===e&&(e=Ie),(0,a.combineReducers)({data:Ee,errors:(0,a.composeReducers)(be,T),statuses:Pe})(e,t)}function Ee(e,t){switch(t.type){case P.ContinueAsGuestSucceeded:case w.LoadCheckoutSucceeded:return q(e,t.payload&&t.payload.customer);case me.CreateCustomerAddressSucceeded:return q(e,t.payload);default:return e}}function be(e,t){switch(void 0===e&&(e=Ie.errors),t.type){case me.CreateCustomerRequested:case me.CreateCustomerSucceeded:return M(e,"createError",void 0);case me.CreateCustomerFailed:return M(e,"createError",t.payload);case me.CreateCustomerAddressRequested:case me.CreateCustomerAddressSucceeded:return M(e,"createAddressError",void 0);case me.CreateCustomerAddressFailed:return M(e,"createAddressError",t.payload);default:return e}}function Pe(e,t){switch(void 0===e&&(e=Ie.statuses),t.type){case me.CreateCustomerRequested:return M(e,"isCreating",!0);case me.CreateCustomerFailed:case me.CreateCustomerSucceeded:return M(e,"isCreating",!1);case me.CreateCustomerAddressRequested:return M(e,"isCreatingAddress",!0);case me.CreateCustomerAddressFailed:case me.CreateCustomerAddressSucceeded:return M(e,"isCreatingAddress",!1);default:return e}}!function(e){e.SignInFailed="CUSTOMER_STRATEGY_SIGN_IN_FAILED",e.SignInRequested="CUSTOMER_STRATEGY_SIGN_IN_REQUESTED",e.SignInSucceeded="CUSTOMER_STRATEGY_SIGN_IN_SUCCEEDED",e.SignOutFailed="CUSTOMER_STRATEGY_SIGN_OUT_FAILED",e.SignOutRequested="CUSTOMER_STRATEGY_SIGN_OUT_REQUESTED",e.SignOutSucceeded="CUSTOMER_STRATEGY_SIGN_OUT_SUCCEEDED",e.ExecutePaymentMethodCheckoutFailed="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_FAILED",e.ExecutePaymentMethodCheckoutRequested="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_REQUESTED",e.ExecutePaymentMethodCheckoutSucceeded="CUSTOMER_STRATEGY_EXECUTE_PAYMENT_METHOD_CHECKOUT_SUCCEEDED",e.InitializeFailed="CUSTOMER_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="CUSTOMER_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="CUSTOMER_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="CUSTOMER_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="CUSTOMER_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="CUSTOMER_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="CUSTOMER_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="CUSTOMER_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="CUSTOMER_STRATEGY_WIDGET_INTERACTION_FAILED"}(Se||(Se={}));var Ae,Te={data:{},errors:{},statuses:{}};function Oe(e,t){return void 0===e&&(e=Te),(0,a.combineReducers)({data:Re,errors:(0,a.composeReducers)(Me,T),statuses:ke})(e,t)}function Re(e,t){var n,r;switch(void 0===e&&(e=Te.data),t.type){case Se.InitializeSucceeded:return q(e,((n={})[t.meta&&t.meta.methodId]={isInitialized:!0},n));case Se.DeinitializeSucceeded:return q(e,((r={})[t.meta&&t.meta.methodId]={isInitialized:!1},r))}return e}function Me(e,t){var n;switch(void 0===e&&(e=Te.errors),t.type){case Se.InitializeRequested:case Se.InitializeSucceeded:return q(e,{initializeErrors:(0,o.__assign)({},e.initializeErrors),initializeMethodId:e.initializeMethodId?e.initializeMethodId:void 0});case Se.InitializeFailed:return q(e,{initializeErrors:(0,o.__assign)((0,o.__assign)({},e.initializeErrors),(n={},n[t.meta&&t.meta.methodId]=t.payload,n)),initializeMethodId:t.meta&&t.meta.methodId});case Se.DeinitializeRequested:case Se.DeinitializeSucceeded:return q(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Se.DeinitializeFailed:return q(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Se.SignInRequested:case Se.SignInSucceeded:return q(e,{signInError:void 0,signInMethodId:void 0});case Se.SignInFailed:return q(e,{signInError:t.payload,signInMethodId:t.meta&&t.meta.methodId});case Se.SignOutRequested:case Se.SignOutSucceeded:return q(e,{signOutError:void 0,signOutMethodId:void 0});case Se.SignOutFailed:return q(e,{signOutError:t.payload,signOutMethodId:t.meta&&t.meta.methodId});case Se.ExecutePaymentMethodCheckoutRequested:case Se.ExecutePaymentMethodCheckoutSucceeded:return q(e,{executePaymentMethodCheckoutError:void 0,executePaymentMethodCheckoutMethodId:void 0});case Se.ExecutePaymentMethodCheckoutFailed:return q(e,{executePaymentMethodCheckoutError:t.payload,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Se.WidgetInteractionStarted:case Se.WidgetInteractionFinished:return q(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Se.WidgetInteractionFailed:return q(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function ke(e,t){switch(void 0===e&&(e=Te.statuses),t.type){case Se.InitializeRequested:return q(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Se.InitializeFailed:case Se.InitializeSucceeded:return q(e,{isInitializing:!1,initializeMethodId:void 0});case Se.DeinitializeRequested:return q(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Se.DeinitializeFailed:case Se.DeinitializeSucceeded:return q(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Se.SignInRequested:return q(e,{isSigningIn:!0,signInMethodId:t.meta&&t.meta.methodId});case Se.SignInFailed:case Se.SignInSucceeded:return q(e,{isSigningIn:!1,signInMethodId:void 0});case Se.SignOutRequested:return q(e,{isSigningOut:!0,signOutMethodId:t.meta&&t.meta.methodId});case Se.SignOutFailed:case Se.SignOutSucceeded:return q(e,{isSigningOut:!1,signOutMethodId:void 0});case Se.ExecutePaymentMethodCheckoutRequested:return q(e,{isExecutingPaymentMethodCheckout:!0,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Se.ExecutePaymentMethodCheckoutFailed:case Se.ExecutePaymentMethodCheckoutSucceeded:return q(e,{isExecutingPaymentMethodCheckout:!1,executePaymentMethodCheckoutMethodId:void 0});case Se.WidgetInteractionStarted:return q(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Se.WidgetInteractionFinished:case Se.WidgetInteractionFailed:return q(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.LoadExtensionsRequested="LOAD_EXTENSIONS_REQUESTED",e.LoadExtensionsSucceeded="LOAD_EXTENSIONS_SUCCEEDED",e.LoadExtensionsFailed="LOAD_EXTENSIONS_FAILED",e.RenderExtensionRequested="RENDER_EXTENSION_REQUESTED",e.RenderExtensionSucceeded="RENDER_EXTENSION_SUCCEEDED",e.RenderExtensionFailed="RENDER_EXTENSION_FAILED"}(Ae||(Ae={}));var De,Ne={errors:{},statuses:{}};function Le(e,t){return void 0===e&&(e=Ne),(0,a.combineReducers)({data:ze,errors:(0,a.composeReducers)(Fe,T),statuses:Ue})(e,t)}function ze(e,t){return t.type===Ae.LoadExtensionsSucceeded?U(e,t.payload):e}function Fe(e,t){switch(void 0===e&&(e=Ne.errors),t.type){case Ae.LoadExtensionsRequested:case Ae.LoadExtensionsSucceeded:return M(e,"loadError",void 0);case Ae.RenderExtensionRequested:case Ae.RenderExtensionSucceeded:return M(e,"renderError",void 0);case Ae.LoadExtensionsFailed:return M(e,"loadError",t.payload);case Ae.RenderExtensionFailed:return M(e,"renderError",t.payload);default:return e}}function Ue(e,t){switch(void 0===e&&(e=Ne.statuses),t.type){case Ae.LoadExtensionsRequested:return M(e,"isLoading",!0);case Ae.LoadExtensionsSucceeded:case Ae.LoadExtensionsFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.LoadFormFieldsRequested="LOAD_FORM_FIELDS_REQUESTED",e.LoadFormFieldsSucceeded="LOAD_FORM_FIELDS_SUCCEEDED",e.LoadFormFieldsFailed="LOAD_FORM_FIELDS_FAILED"}(De||(De={}));var qe,Be={errors:{},statuses:{}};function Ge(e,t){return void 0===e&&(e=Be),(0,a.combineReducers)({data:xe,errors:(0,a.composeReducers)(Ye,T),statuses:Ve})(e,t)}function xe(e,t){return t.type===De.LoadFormFieldsSucceeded?q(e,t.payload):e}function Ye(e,t){switch(void 0===e&&(e=Be.errors),t.type){case De.LoadFormFieldsSucceeded:return M(e,"loadError",void 0);case De.LoadFormFieldsFailed:return M(e,"loadError",t.payload);default:return e}}function Ve(e,t){switch(void 0===e&&(e=Be.statuses),t.type){case De.LoadFormFieldsRequested:return M(e,"isLoading",!0);case De.LoadFormFieldsSucceeded:case De.LoadFormFieldsFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.LoadCountriesRequested="LOAD_COUNTRIES_REQUESTED",e.LoadCountriesSucceeded="LOAD_COUNTRIES_SUCCEEDED",e.LoadCountriesFailed="LOAD_COUNTRIES_FAILED"}(qe||(qe={}));var He={errors:{},statuses:{}};function je(e,t){return void 0===e&&(e=He),(0,a.combineReducers)({data:We,errors:(0,a.composeReducers)(Ke,T),statuses:Je})(e,t)}function We(e,t){return t.type===qe.LoadCountriesSucceeded?U(e,t.payload):e}function Ke(e,t){switch(void 0===e&&(e=He.errors),t.type){case qe.LoadCountriesRequested:case qe.LoadCountriesSucceeded:return M(e,"loadError",void 0);case qe.LoadCountriesFailed:return M(e,"loadError",t.payload);default:return e}}function Je(e,t){switch(void 0===e&&(e=He.statuses),t.type){case qe.LoadCountriesRequested:return M(e,"isLoading",!0);case qe.LoadCountriesSucceeded:case qe.LoadCountriesFailed:return M(e,"isLoading",!1);default:return e}}var Ze={errors:{},meta:{},statuses:{}};function Qe(e,t){return void 0===e&&(e=Ze),(0,a.combineReducers)({data:Xe,errors:(0,a.composeReducers)(et,T),meta:$e,statuses:tt})(e,t)}function Xe(e,t){switch(t.type){case ie.LoadOrderSucceeded:case ie.LoadOrderPaymentsSucceeded:return q(e,(0,m.omit)(t.payload,["billingAddress","coupons"]));default:return e}}function $e(e,t){switch(t.type){case ie.FinalizeOrderSucceeded:case ie.SubmitOrderSucceeded:return q(e,(0,o.__assign)((0,o.__assign)({},t.meta),{callbackUrl:t.payload&&t.payload.order.callbackUrl,orderToken:t.payload&&t.payload.order.token,payment:t.payload&&t.payload.order&&t.payload.order.payment}));default:return e}}function et(e,t){switch(void 0===e&&(e=Ze.errors),t.type){case ie.LoadOrderRequested:case ie.LoadOrderSucceeded:case ie.LoadOrderPaymentsSucceeded:case ie.LoadOrderPaymentsRequested:return M(e,"loadError",void 0);case ie.LoadOrderFailed:case ie.LoadOrderPaymentsFailed:return M(e,"loadError",t.payload);default:return e}}function tt(e,t){switch(void 0===e&&(e=Ze.statuses),t.type){case ie.LoadOrderRequested:case ie.LoadOrderPaymentsRequested:return M(e,"isLoading",!0);case ie.LoadOrderSucceeded:case ie.LoadOrderFailed:case ie.LoadOrderPaymentsSucceeded:case ie.LoadOrderPaymentsFailed:return M(e,"isLoading",!1);default:return e}}var nt,rt,it={};function ot(e,t){return void 0===e&&(e=it),(0,a.combineReducers)({data:at})(e,t)}function at(e,t){switch(t.type){case ie.LoadOrderPaymentsSucceeded:case ie.LoadOrderSucceeded:return R(e,t.payload&&t.payload.billingAddress);default:return e}}function st(e,t){return void 0===e&&(e={}),(0,a.combineReducers)({data:ut})(e,t)}function ut(e,t){return t.type===nt.SubmitPaymentSucceeded?t.payload:e}!function(e){e.SubmitPaymentRequested="SUBMIT_PAYMENT_REQUESTED",e.SubmitPaymentSucceeded="SUBMIT_PAYMENT_SUCCEEDED",e.SubmitPaymentFailed="SUBMIT_PAYMENT_FAILED",e.InitializeOffsitePaymentRequested="INITIALIZE_OFFSITE_PAYMENT_REQUESTED",e.InitializeOffsitePaymentSucceeded="INITIALIZE_OFFSITE_PAYMENT_SUCCEEDED",e.InitializeOffsitePaymentFailed="INITIALIZE_OFFSITE_PAYMENT_FAILED"}(nt||(nt={})),function(e){e.LoadPaymentMethodRequested="LOAD_PAYMENT_METHOD_REQUESTED",e.LoadPaymentMethodSucceeded="LOAD_PAYMENT_METHOD_SUCCEEDED",e.LoadPaymentMethodFailed="LOAD_PAYMENT_METHOD_FAILED",e.LoadPaymentMethodsRequested="LOAD_PAYMENT_METHODS_REQUESTED",e.LoadPaymentMethodsSucceeded="LOAD_PAYMENT_METHODS_SUCCEEDED",e.LoadPaymentMethodsFailed="LOAD_PAYMENT_METHODS_FAILED"}(rt||(rt={}));var ct,dt={errors:{},statuses:{}};function lt(e,t){return void 0===e&&(e=dt),(0,a.combineReducers)({data:pt,errors:(0,a.composeReducers)(ft,T),meta:ht,statuses:mt})(e,t)}function pt(e,t){switch(t.type){case rt.LoadPaymentMethodSucceeded:return function(e,t,n){if(!t)return e;var r=(0,m.pick)(t,"id"),i=(0,m.findIndex)(e,"object"==typeof n?(0,m.pickBy)(n):n||r),a=(0,o.__spreadArrays)(e);if(-1===i)a.push(t);else{var s=e[i];a[i]=F(s)&&F(t)?q(s,t):t}return a}(e||[],t.payload,t.payload&&{id:t.payload.id,gateway:t.payload.gateway});case rt.LoadPaymentMethodsSucceeded:return U(e,t.payload,{matchObject:function(e,t){return e.id===t.id&&e.gateway===t.gateway}});default:return e}}function ht(e,t){return t.type===rt.LoadPaymentMethodsSucceeded?q(e,t.meta):e}function ft(e,t){switch(void 0===e&&(e=dt.errors),t.type){case rt.LoadPaymentMethodsRequested:case rt.LoadPaymentMethodsSucceeded:return M(e,"loadError",void 0);case rt.LoadPaymentMethodsFailed:return M(e,"loadError",t.payload);case rt.LoadPaymentMethodRequested:case rt.LoadPaymentMethodSucceeded:return q(e,{loadMethodId:void 0,loadMethodError:void 0});case rt.LoadPaymentMethodFailed:return q(e,{loadMethodId:t.meta.methodId,loadMethodError:t.payload});default:return e}}function mt(e,t){switch(void 0===e&&(e=dt.statuses),t.type){case rt.LoadPaymentMethodsRequested:return M(e,"isLoading",!0);case rt.LoadPaymentMethodsSucceeded:case rt.LoadPaymentMethodsFailed:return M(e,"isLoading",!1);case rt.LoadPaymentMethodRequested:return q(e,{isLoadingMethod:!0,loadMethodId:t.meta.methodId});case rt.LoadPaymentMethodSucceeded:case rt.LoadPaymentMethodFailed:return q(e,{isLoadingMethod:!1,loadMethodId:void 0});default:return e}}!function(e){e.ExecuteFailed="PAYMENT_STRATEGY_EXECUTE_FAILED",e.ExecuteRequested="PAYMENT_STRATEGY_EXECUTE_REQUESTED",e.ExecuteSucceeded="PAYMENT_STRATEGY_EXECUTE_SUCCEEDED",e.FinalizeFailed="PAYMENT_STRATEGY_FINALIZE_FAILED",e.FinalizeRequested="PAYMENT_STRATEGY_FINALIZE_REQUESTED",e.FinalizeSucceeded="PAYMENT_STRATEGY_FINALIZE_SUCCEEDED",e.InitializeFailed="PAYMENT_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="PAYMENT_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="PAYMENT_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="PAYMENT_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="PAYMENT_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="PAYMENT_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="PAYMENT_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="PAYMENT_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="PAYMENT_STRATEGY_WIDGET_INTERACTION_FAILED"}(ct||(ct={}));var gt,yt={data:{},errors:{},statuses:{}};function _t(e,t){return void 0===e&&(e=yt),(0,a.combineReducers)({data:vt,errors:(0,a.composeReducers)(Ct,T),statuses:St})(e,t)}function vt(e,t){var n,r;switch(void 0===e&&(e=yt.data),t.type){case ct.InitializeSucceeded:if(t.meta){var i=t.meta,o=i.methodId,a=i.gatewayId;return q(e,((n={})[a?o+"."+a:o]={isInitialized:!0},n))}break;case ct.DeinitializeSucceeded:if(t.meta){var s=t.meta;return o=s.methodId,a=s.gatewayId,q(e,((r={})[a?o+"."+a:o]={isInitialized:!1},r))}}return e}function Ct(e,t){switch(void 0===e&&(e=yt.errors),t.type){case ct.InitializeRequested:case ct.InitializeSucceeded:return q(e,{initializeError:void 0,initializeMethodId:void 0});case ct.InitializeFailed:var n=t.meta&&t.meta.methodId;if(t.meta){var r=t.meta,i=r.methodId;n=(a=r.gatewayId)?i+"."+a:i}return q(e,{initializeError:t.payload,initializeMethodId:n});case ct.DeinitializeRequested:case ct.DeinitializeSucceeded:return q(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case ct.DeinitializeFailed:var o=t.meta&&t.meta.methodId;if(t.meta){var a,s=t.meta;i=s.methodId,o=(a=s.gatewayId)?i+"."+a:i}return q(e,{deinitializeError:t.payload,deinitializeMethodId:o});case ct.ExecuteRequested:case ct.ExecuteSucceeded:return q(e,{executeError:void 0,executeMethodId:void 0});case ct.ExecuteFailed:return q(e,{executeError:t.payload,executeMethodId:t.meta&&t.meta.methodId});case ct.FinalizeRequested:case ct.FinalizeSucceeded:return q(e,{finalizeError:void 0,finalizeMethodId:void 0});case ct.FinalizeFailed:return q(e,{finalizeError:t.payload,finalizeMethodId:t.meta&&t.meta.methodId});case ct.WidgetInteractionStarted:case ct.WidgetInteractionFinished:return q(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case ct.WidgetInteractionFailed:return q(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function St(e,t){switch(void 0===e&&(e=yt.statuses),t.type){case ct.InitializeRequested:var n=t.meta&&t.meta.methodId;if(t.meta){var r=t.meta,i=r.methodId;n=(a=r.gatewayId)?i+"."+a:i}return q(e,{isInitializing:!0,initializeMethodId:n});case ct.InitializeFailed:case ct.InitializeSucceeded:return q(e,{isInitializing:!1,initializeMethodId:void 0});case ct.DeinitializeRequested:var o=t.meta&&t.meta.methodId;if(t.meta){var a,s=t.meta;i=s.methodId,o=(a=s.gatewayId)?i+"."+a:i}return q(e,{isDeinitializing:!0,deinitializeMethodId:o});case ct.DeinitializeFailed:case ct.DeinitializeSucceeded:return q(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case ct.ExecuteRequested:return q(e,{isExecuting:!0,executeMethodId:t.meta&&t.meta.methodId});case ct.ExecuteFailed:case ct.ExecuteSucceeded:return q(e,{isExecuting:!1,executeMethodId:void 0});case ct.FinalizeRequested:return q(e,{isFinalizing:!0,finalizeMethodId:t.meta&&t.meta.methodId});case ct.FinalizeFailed:case ct.FinalizeSucceeded:return q(e,{isFinalizing:!1,finalizeMethodId:void 0});case ct.WidgetInteractionStarted:return q(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case ct.WidgetInteractionFinished:case ct.WidgetInteractionFailed:return q(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.UpdatePaymentProviderCustomer="UPDATE_PAYMENT_PROVIDER_CUSTOMER"}(gt||(gt={}));var It,wt={data:{}};function Et(e,t){return void 0===e&&(e=wt),(0,a.combineReducers)({data:bt})(e,t)}function bt(e,t){return void 0===e&&(e=wt.data),t.type===gt.UpdatePaymentProviderCustomer?q(e,t.payload):e}!function(e){e.LoadInstrumentsRequested="LOAD_INSTRUMENTS_REQUESTED",e.LoadInstrumentsSucceeded="LOAD_INSTRUMENTS_SUCCEEDED",e.LoadInstrumentsFailed="LOAD_INSTRUMENTS_FAILED",e.DeleteInstrumentRequested="DELETE_INSTRUMENT_REQUESTED",e.DeleteInstrumentSucceeded="DELETE_INSTRUMENT_SUCCEEDED",e.DeleteInstrumentFailed="DELETE_INSTRUMENT_FAILED"}(It||(It={}));var Pt,At={data:[],errors:{},statuses:{}};function Tt(e,t){return void 0===e&&(e=At),(0,a.combineReducers)({data:Ot,errors:(0,a.composeReducers)(Mt,T),meta:Rt,statuses:kt})(e,t)}function Ot(e,t){return void 0===e&&(e=At.data),t.type===It.LoadInstrumentsSucceeded?U(e,t.payload&&t.payload.vaultedInstruments||[]):e}function Rt(e,t){switch(t.type){case It.LoadInstrumentsSucceeded:case It.DeleteInstrumentSucceeded:return q(e,t.meta);default:return e}}function Mt(e,t){switch(void 0===e&&(e=At.errors),t.type){case It.LoadInstrumentsRequested:case It.LoadInstrumentsSucceeded:return M(e,"loadError",void 0);case It.DeleteInstrumentRequested:case It.DeleteInstrumentSucceeded:return q(e,{deleteError:void 0,failedInstrument:void 0});case It.LoadInstrumentsFailed:return M(e,"loadError",t.payload);case It.DeleteInstrumentFailed:return q(e,{deleteError:t.payload,failedInstrument:t.meta.instrumentId});default:return e}}function kt(e,t){switch(void 0===e&&(e=At.statuses),t.type){case It.LoadInstrumentsRequested:return M(e,"isLoading",!0);case It.DeleteInstrumentRequested:return q(e,{isDeleting:!0,deletingInstrument:t.meta.instrumentId});case It.LoadInstrumentsSucceeded:case It.LoadInstrumentsFailed:return M(e,"isLoading",!1);case It.DeleteInstrumentSucceeded:case It.DeleteInstrumentFailed:return q(e,{isDeleting:!1,deletingInstrument:void 0});default:return e}}!function(e){e.ForgetCheckoutRemoteCustomerRequested="FORGET_CHECKOUT_REMOTE_CUSTOMER_REQUESTED",e.ForgetCheckoutRemoteCustomerSucceeded="FORGET_CHECKOUT_REMOTE_CUSTOMER_SUCCEEDED",e.ForgetCheckoutRemoteCustomerFailed="FORGET_CHECKOUT_REMOTE_CUSTOMER_FAILED",e.InitializeRemoteBillingRequested="INITIALIZE_REMOTE_BILLING_REQUESTED",e.InitializeRemoteBillingSucceeded="INITIALIZE_REMOTE_BILLING_SUCCEEDED",e.InitializeRemoteBillingFailed="INITIALIZE_REMOTE_BILLING_FAILED",e.InitializeRemoteShippingRequested="INITIALIZE_REMOTE_SHIPPING_REQUESTED",e.InitializeRemoteShippingSucceeded="INITIALIZE_REMOTE_SHIPPING_SUCCEEDED",e.InitializeRemoteShippingFailed="INITIALIZE_REMOTE_SHIPPING_FAILED",e.InitializeRemotePaymentRequested="INITIALIZE_REMOTE_PAYMENT_REQUESTED",e.InitializeRemotePaymentSucceeded="INITIALIZE_REMOTE_PAYMENT_SUCCEEDED",e.InitializeRemotePaymentFailed="INITIALIZE_REMOTE_PAYMENT_FAILED",e.LoadRemoteSettingsRequested="LOAD_REMOTE_SETTINGS_REQUESTED",e.LoadRemoteSettingsSucceeded="LOAD_REMOTE_SETTINGS_SUCCEEDED",e.LoadRemoteSettingsFailed="LOAD_REMOTE_SETTINGS_FAILED",e.SignOutRemoteCustomerRequested="SIGN_OUT_REMOTE_CUSTOMER_REQUESTED",e.SignOutRemoteCustomerSucceeded="SIGN_OUT_REMOTE_CUSTOMER_SUCCEEDED",e.SignOutRemoteCustomerFailed="SIGN_OUT_REMOTE_CUSTOMER_FAILED",e.UpdateRemoteCheckout="UPDATE_REMOTE_CHECKOUT"}(Pt||(Pt={}));var Dt={data:{}};function Nt(e,t){var n;return void 0===e&&(e=Dt),t.meta&&t.meta.methodId?(0,a.combineReducers)({data:(0,a.combineReducers)((n={},n[t.meta.methodId]=Lt,n))})(e,t):e}function Lt(e,t){switch(t.type){case Pt.InitializeRemoteBillingSucceeded:return M(e,"billing",t.payload&&t.payload.billing);case Pt.InitializeRemoteShippingSucceeded:return M(e,"shipping",t.payload&&t.payload.shipping);case Pt.LoadRemoteSettingsSucceeded:return M(e,"settings",t.payload);case Pt.UpdateRemoteCheckout:return q(e,t.payload);default:return e}}var zt,Ft={errors:{updateShippingOptionError:{},updateError:{},deleteError:{}},statuses:{isUpdating:{},isUpdatingShippingOption:{},isDeleting:{}}};function Ut(e,t){return void 0===e&&(e=Ft),(0,a.combineReducers)({data:qt,errors:(0,a.composeReducers)(Bt,T),statuses:Gt})(e,t)}function qt(e,t){switch(t.type){case w.LoadCheckoutSucceeded:case x.LoadShippingOptionsSucceeded:case x.CreateConsignmentsSucceeded:case x.UpdateConsignmentSucceeded:case x.DeleteConsignmentSucceeded:case x.UpdateShippingOptionSucceeded:case B.ApplyCouponSucceeded:case B.RemoveCouponSucceeded:return U(e,t.payload&&t.payload.consignments);case me.SignOutCustomerSucceeded:return U(e,[]);default:return e}}function Bt(e,t){var n,r,i,o,a,s;switch(void 0===e&&(e=Ft.errors),t.type){case w.LoadCheckoutRequested:case w.LoadCheckoutSucceeded:case x.LoadShippingOptionsSucceeded:case x.LoadShippingOptionsRequested:return M(e,"loadError",void 0);case w.LoadCheckoutFailed:case x.LoadShippingOptionsFailed:return M(e,"loadError",t.payload);case x.CreateConsignmentsRequested:case x.CreateConsignmentsSucceeded:return M(e,"createError",void 0);case x.CreateConsignmentsFailed:return M(e,"createError",t.payload);case x.UpdateConsignmentSucceeded:case x.UpdateConsignmentRequested:return t.meta?q(e,{updateError:(n={},n[t.meta.id]=void 0,n)}):e;case x.UpdateConsignmentFailed:return t.meta?q(e,{updateError:(r={},r[t.meta.id]=t.payload,r)}):e;case x.DeleteConsignmentSucceeded:case x.DeleteConsignmentRequested:return t.meta?q(e,{deleteError:(i={},i[t.meta.id]=void 0,i)}):e;case x.DeleteConsignmentFailed:return t.meta?q(e,{deleteError:(o={},o[t.meta.id]=t.payload,o)}):e;case x.UpdateShippingOptionRequested:case x.UpdateShippingOptionSucceeded:return t.meta?q(e,{updateShippingOptionError:(a={},a[t.meta.id]=void 0,a)}):e;case x.UpdateShippingOptionFailed:return t.meta?q(e,{updateShippingOptionError:(s={},s[t.meta.id]=t.payload,s)}):e;default:return e}}function Gt(e,t){var n,r,i,o,a,s;switch(void 0===e&&(e=Ft.statuses),t.type){case w.LoadCheckoutRequested:return M(e,"isLoading",!0);case x.LoadShippingOptionsRequested:return M(e,"isLoadingShippingOptions",!0);case w.LoadCheckoutSucceeded:case w.LoadCheckoutFailed:return M(e,"isLoading",!1);case x.LoadShippingOptionsSucceeded:case x.LoadShippingOptionsFailed:return M(e,"isLoadingShippingOptions",!1);case x.CreateConsignmentsRequested:return M(e,"isCreating",!0);case x.CreateConsignmentsSucceeded:case x.CreateConsignmentsFailed:return M(e,"isCreating",!1);case x.UpdateConsignmentRequested:return t.meta?q(e,{isUpdating:(n={},n[t.meta.id]=!0,n)}):e;case x.UpdateConsignmentSucceeded:case x.UpdateConsignmentFailed:return t.meta?q(e,{isUpdating:(r={},r[t.meta.id]=!1,r)}):e;case x.DeleteConsignmentRequested:return t.meta?q(e,{isDeleting:(i={},i[t.meta.id]=!0,i)}):e;case x.DeleteConsignmentSucceeded:case x.DeleteConsignmentFailed:return t.meta?q(e,{isDeleting:(o={},o[t.meta.id]=!1,o)}):e;case x.UpdateShippingOptionRequested:return t.meta?q(e,{isUpdatingShippingOption:(a={},a[t.meta.id]=!0,a)}):e;case x.UpdateShippingOptionSucceeded:case x.UpdateShippingOptionFailed:return t.meta?q(e,{isUpdatingShippingOption:(s={},s[t.meta.id]=!1,s)}):e;default:return e}}function xt(e,t){var n={};return Object.keys(e).forEach((function(r){var i=e[r],o=t?t+"."+r:r;"object"==typeof i?Object.assign(n,xt(i,o)):n[o]=i})),n}function Yt(e){return Object.keys(e).sort().reduce((function(t,n){var r;return(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=e[n],r))}),{})}!function(e){e.LoadPickupOptionsRequested="LOAD_PICKUP_OPTIONS_REQUESTED",e.LoadPickupOptionsSucceeded="LOAD_PICKUP_OPTIONS_SUCCEEDED",e.LoadPickupOptionsFailed="LOAD_PICKUP_OPTIONS_FAILED"}(zt||(zt={}));var Vt,Ht={errors:{},statuses:{}};function jt(e,t){return void 0===e&&(e=Ht),(0,a.combineReducers)({data:Wt,errors:(0,a.composeReducers)(Kt,T),statuses:Jt})(e,t)}function Wt(e,t){if(t.type!==zt.LoadPickupOptionsSucceeded)return e;if(t.meta){var n=Yt(xt({consignmentId:t.meta.consignmentId,searchArea:t.meta.searchArea}));return M(e,btoa(""+JSON.stringify(n)),t.payload)}}function Kt(e,t){switch(void 0===e&&(e=Ht.errors),t.type){case zt.LoadPickupOptionsRequested:case zt.LoadPickupOptionsSucceeded:return M(e,"loadError",void 0);case zt.LoadPickupOptionsFailed:return M(e,"loadError",t.payload);default:return e}}function Jt(e,t){switch(void 0===e&&(e=Ht.statuses),t.type){case zt.LoadPickupOptionsRequested:return M(e,"isLoading",!0);case zt.LoadPickupOptionsSucceeded:case zt.LoadPickupOptionsFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.LoadShippingCountriesRequested="LOAD_SHIPPING_COUNTRIES_REQUESTED",e.LoadShippingCountriesSucceeded="LOAD_SHIPPING_COUNTRIES_SUCCEEDED",e.LoadShippingCountriesFailed="LOAD_SHIPPING_COUNTRIES_FAILED"}(Vt||(Vt={}));var Zt,Qt={errors:{},statuses:{}};function Xt(e,t){return void 0===e&&(e=Qt),(0,a.combineReducers)({data:$t,errors:(0,a.composeReducers)(en,T),statuses:tn})(e,t)}function $t(e,t){return t.type===Vt.LoadShippingCountriesSucceeded?U(e,t.payload):e}function en(e,t){switch(void 0===e&&(e=Qt.errors),t.type){case Vt.LoadShippingCountriesRequested:case Vt.LoadShippingCountriesSucceeded:return M(e,"loadError",void 0);case Vt.LoadShippingCountriesFailed:return M(e,"loadError",t.payload);default:return e}}function tn(e,t){switch(void 0===e&&(e=Qt.statuses),t.type){case Vt.LoadShippingCountriesRequested:return M(e,"isLoading",!0);case Vt.LoadShippingCountriesSucceeded:case Vt.LoadShippingCountriesFailed:return M(e,"isLoading",!1);default:return e}}!function(e){e.UpdateAddressFailed="SHIPPING_STRATEGY_UPDATE_ADDRESS_FAILED",e.UpdateAddressRequested="SHIPPING_STRATEGY_UPDATE_ADDRESS_REQUESTED",e.UpdateAddressSucceeded="SHIPPING_STRATEGY_UPDATE_ADDRESS_SUCCEEDED",e.SelectOptionFailed="SHIPPING_STRATEGY_SELECT_OPTION_FAILED",e.SelectOptionRequested="SHIPPING_STRATEGY_SELECT_OPTION_REQUESTED",e.SelectOptionSucceeded="SHIPPING_STRATEGY_SELECT_OPTION_SUCCEEDED",e.InitializeFailed="SHIPPING_STRATEGY_INITIALIZE_FAILED",e.InitializeRequested="SHIPPING_STRATEGY_INITIALIZE_REQUESTED",e.InitializeSucceeded="SHIPPING_STRATEGY_INITIALIZE_SUCCEEDED",e.DeinitializeFailed="SHIPPING_STRATEGY_DEINITIALIZE_FAILED",e.DeinitializeRequested="SHIPPING_STRATEGY_DEINITIALIZE_REQUESTED",e.DeinitializeSucceeded="SHIPPING_STRATEGY_DEINITIALIZE_SUCCEEDED",e.WidgetInteractionStarted="SHIPPING_STRATEGY_WIDGET_INTERACTION_STARTED",e.WidgetInteractionFinished="SHIPPING_STRATEGY_WIDGET_INTERACTION_FINISHED",e.WidgetInteractionFailed="SHIPPING_STRATEGY_WIDGET_INTERACTION_FAILED"}(Zt||(Zt={}));var nn,rn={data:{},errors:{},statuses:{}};function on(e,t){return void 0===e&&(e=rn),(0,a.combineReducers)({data:an,errors:(0,a.composeReducers)(sn,T),statuses:un})(e,t)}function an(e,t){var n,r;switch(void 0===e&&(e=rn.data),t.type){case Zt.InitializeSucceeded:return q(e,((n={})[t.meta&&t.meta.methodId]={isInitialized:!0},n));case Zt.DeinitializeSucceeded:return q(e,((r={})[t.meta&&t.meta.methodId]={isInitialized:!1},r))}return e}function sn(e,t){switch(void 0===e&&(e=rn.errors),t.type){case Zt.InitializeRequested:case Zt.InitializeSucceeded:return q(e,{initializeError:void 0,initializeMethodId:void 0});case Zt.InitializeFailed:return q(e,{initializeError:t.payload,initializeMethodId:t.meta&&t.meta.methodId});case Zt.DeinitializeRequested:case Zt.DeinitializeSucceeded:return q(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Zt.DeinitializeFailed:return q(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Zt.UpdateAddressRequested:case Zt.UpdateAddressSucceeded:return q(e,{updateAddressError:void 0,updateAddressMethodId:void 0});case Zt.UpdateAddressFailed:return q(e,{updateAddressError:t.payload,updateAddressMethodId:t.meta&&t.meta.methodId});case Zt.SelectOptionRequested:case Zt.SelectOptionSucceeded:return q(e,{selectOptionError:void 0,selectOptionMethodId:void 0});case Zt.SelectOptionFailed:return q(e,{selectOptionError:t.payload,selectOptionMethodId:t.meta&&t.meta.methodId});case Zt.WidgetInteractionStarted:case Zt.WidgetInteractionFinished:return q(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Zt.WidgetInteractionFailed:return q(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta&&t.meta.methodId});default:return e}}function un(e,t){switch(void 0===e&&(e=rn.statuses),t.type){case Zt.InitializeRequested:return q(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Zt.InitializeFailed:case Zt.InitializeSucceeded:return q(e,{isInitializing:!1,initializeMethodId:void 0});case Zt.DeinitializeRequested:return q(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Zt.DeinitializeFailed:case Zt.DeinitializeSucceeded:return q(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Zt.UpdateAddressRequested:return q(e,{isUpdatingAddress:!0,updateAddressMethodId:t.meta&&t.meta.methodId});case Zt.UpdateAddressFailed:case Zt.UpdateAddressSucceeded:return q(e,{isUpdatingAddress:!1,updateAddressMethodId:void 0});case Zt.SelectOptionRequested:return q(e,{isSelectingOption:!0,selectOptionMethodId:t.meta&&t.meta.methodId});case Zt.SelectOptionFailed:case Zt.SelectOptionSucceeded:return q(e,{isSelectingOption:!1,selectOptionMethodId:void 0});case Zt.WidgetInteractionStarted:return q(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta&&t.meta.methodId});case Zt.WidgetInteractionFinished:case Zt.WidgetInteractionFailed:return q(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}!function(e){e.SendSignInEmailRequested="SEND_SIGNIN_EMAIL_REQUESTED",e.SendSignInEmailSucceeded="SEND_SIGNIN_EMAIL_SUCCEEDED",e.SendSignInEmailFailed="SEND_SIGNIN_EMAIL_FAILED"}(nn||(nn={}));var cn,dn={errors:{},statuses:{}};function ln(e,t){return void 0===e&&(e=dn),(0,a.combineReducers)({data:pn,errors:(0,a.composeReducers)(hn,T),statuses:fn})(e,t)}function pn(e,t){return t.type===nn.SendSignInEmailSucceeded?q(e,t.payload):e}function hn(e,t){switch(void 0===e&&(e=dn.errors),t.type){case nn.SendSignInEmailRequested:case nn.SendSignInEmailSucceeded:return M(e,"sendError",void 0);case nn.SendSignInEmailFailed:return M(e,"sendError",t.payload);default:return e}}function fn(e,t){switch(void 0===e&&(e=dn.statuses),t.type){case nn.SendSignInEmailRequested:return M(e,"isSending",!0);case nn.SendSignInEmailFailed:case nn.SendSignInEmailSucceeded:return M(e,"isSending",!1);default:return e}}!function(e){e.ApplyStoreCreditRequested="APPLY_STORE_CREDIT_REQUESTED",e.ApplyStoreCreditSucceeded="APPLY_STORE_CREDIT_SUCCEEDED",e.ApplyStoreCreditFailed="APPLY_STORE_CREDIT_FAILED"}(cn||(cn={}));var mn={errors:{},statuses:{}};function gn(e,t){return void 0===e&&(e=mn),(0,a.combineReducers)({errors:(0,a.composeReducers)(yn,T),statuses:_n})(e,t)}function yn(e,t){switch(void 0===e&&(e=mn.errors),t.type){case cn.ApplyStoreCreditRequested:case cn.ApplyStoreCreditSucceeded:return M(e,"applyError",void 0);case cn.ApplyStoreCreditFailed:return M(e,"applyError",t.payload);default:return e}}function _n(e,t){switch(void 0===e&&(e=mn.statuses),t.type){case cn.ApplyStoreCreditRequested:return M(e,"isApplying",!0);case cn.ApplyStoreCreditSucceeded:case cn.ApplyStoreCreditFailed:return M(e,"isApplying",!1);default:return e}}var vn,Cn={errors:{},statuses:{}};function Sn(e,t){return void 0===e&&(e=Cn),(0,a.combineReducers)({errors:(0,a.composeReducers)(In,T),statuses:wn})(e,t)}function In(e,t){switch(void 0===e&&(e=Cn.errors),t.type){case b.UpdateSubscriptionsRequested:case b.UpdateSubscriptionsSucceeded:return M(e,"updateError",void 0);case b.UpdateSubscriptionsFailed:return M(e,"updateError",t.payload);default:return e}}function wn(e,t){switch(void 0===e&&(e=Cn.statuses),t.type){case b.UpdateSubscriptionsRequested:return M(e,"isUpdating",!0);case b.UpdateSubscriptionsFailed:case b.UpdateSubscriptionsSucceeded:return M(e,"isUpdating",!1);default:return e}}!function(e){e.InitializeFailed="SPAM_PROTECTION_INITIALIZE_FAILED",e.InitializeSucceeded="SPAM_PROTECTION_INITIALIZE_SUCCEEDED",e.InitializeRequested="SPAM_PROTECTION_INITIALIZE_REQUESTED",e.VerifyCheckoutRequested="SPAM_PROTECTION_CHECKOUT_VERIFY_REQUESTED",e.VerifyCheckoutSucceeded="SPAM_PROTECTION_CHECKOUT_VERIFY_SUCCEEDED",e.VerifyCheckoutFailed="SPAM_PROTECTION_CHECKOUT_VERIFY_FAILED",e.ExecuteRequested="SPAM_PROTECTION_EXECUTE_REQUESTED",e.ExecuteSucceeded="SPAM_PROTECTION_EXECUTE_SUCCEEDED",e.ExecuteFailed="SPAM_PROTECTION_EXECUTE_FAILED"}(vn||(vn={}));var En={errors:{},statuses:{}};function bn(e,t){return void 0===e&&(e=En),(0,a.combineReducers)({data:Pn,errors:(0,a.composeReducers)(An,T),statuses:Tn})(e,t)}function Pn(e,t){switch(t.type){case w.LoadCheckoutSucceeded:case w.UpdateCheckoutSucceeded:case cn.ApplyStoreCreditSucceeded:case P.UpdateBillingAddressSucceeded:case B.ApplyCouponSucceeded:case B.RemoveCouponSucceeded:case x.CreateConsignmentsSucceeded:case x.UpdateConsignmentSucceeded:case x.DeleteConsignmentSucceeded:case x.UpdateShippingOptionSucceeded:case x.LoadShippingOptionsSucceeded:case G.ApplyGiftCertificateSucceeded:case G.RemoveGiftCertificateSucceeded:case vn.VerifyCheckoutSucceeded:return q(e,(0,m.omit)(t.payload,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));case ie.SubmitOrderSucceeded:return M(e,"orderId",t.payload&&t.payload.order.orderId);default:return e}}function An(e,t){switch(void 0===e&&(e=En.errors),t.type){case w.LoadCheckoutRequested:case w.LoadCheckoutSucceeded:return M(e,"loadError",void 0);case w.LoadCheckoutFailed:return M(e,"loadError",t.payload);case w.UpdateCheckoutRequested:case w.UpdateCheckoutSucceeded:return M(e,"updateError",void 0);case w.UpdateCheckoutFailed:return M(e,"updateError",t.payload);default:return e}}function Tn(e,t){switch(void 0===e&&(e=En.statuses),t.type){case w.LoadCheckoutRequested:return M(e,"isLoading",!0);case w.LoadCheckoutFailed:case w.LoadCheckoutSucceeded:return M(e,"isLoading",!1);case w.UpdateCheckoutRequested:return M(e,"isUpdating",!0);case w.UpdateCheckoutFailed:case w.UpdateCheckoutSucceeded:return M(e,"isUpdating",!1);case vn.ExecuteRequested:return M(e,"isExecutingSpamCheck",!0);case vn.ExecuteFailed:case vn.ExecuteSucceeded:return M(e,"isExecutingSpamCheck",!1);default:return e}}const On=require("@bigcommerce/memoize");var Rn;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentProviderCustomer=13]="MissingPaymentProviderCustomer",e[e.MissingPaymentRedirectUrl=14]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=15]="MissingPaymentStatus",e[e.MissingPaymentToken=16]="MissingPaymentToken",e[e.MissingShippingAddress=17]="MissingShippingAddress"}(Rn||(Rn={}));const Mn=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Rn.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case Rn.MissingCart:return"Unable to proceed because cart data is unavailable.";case Rn.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case Rn.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case Rn.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case Rn.MissingCheckoutConfig:case Rn.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case Rn.MissingOrder:return"Unable to proceed because order data is unavailable.";case Rn.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case Rn.MissingPayment:return"Unable to proceed because payment data is unavailable.";case Rn.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case Rn.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case Rn.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case Rn.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(t))||this;return n.subtype=t,n.name="MissingDataError",n.type="missing_data",n}return(0,o.__extends)(t,e),t}(l),kn=require("reselect"),Dn=(Nn=kn.createSelector,function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=e.pop();return Nn.apply(void 0,(0,o.__spreadArrays)(e,[function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var r=n.apply(void 0,e);return"function"==typeof r?(0,On.memoize)(r):r}]))});var Nn;function Ln(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function zn(e){return function(e,t){var n=Object.create(e);return function(e,t){for(var n=Object.getPrototypeOf(e);n;)t(n),n=Object.getPrototypeOf(n)}(e,(function(t){Object.getOwnPropertyNames(t).forEach((function(t){"constructor"!==t&&"function"==typeof n[t]&&"_"!==t.charAt(0)&&(n[t]=function(e,t){return function(){for(var n,r=[],i=0;i<arguments.length;i++)r[i]=arguments[i];return(0,a.deepFreeze)((n=e[t]).call.apply(n,(0,o.__spreadArrays)([e],r)))}}(e,t))}))})),n}(e)}var Fn="PAYMENT_TYPE_HOSTED",Un="ACKNOWLEDGE",qn="FINALIZE";const Bn={"mollie.credit_card":{provider:"mollie",method:"credit_card"},"adyenv2.scheme":{provider:"adyenv2",method:"scheme"},"adyenv3.scheme":{provider:"adyenv3",method:"scheme"},"adyenv2.bcmc":{provider:"adyenv2",method:"bcmc"},"adyenv2.ideal":{provider:"adyenv2",method:"ideal"},"adyenv2.sepadirectdebit":{provider:"adyenv2",method:"sepadirectdebit"},"adyenv2.directEbanking":{provider:"adyenv2",method:"directEbanking"},"adyenv2.giropay":{provider:"adyenv2",method:"giropay"},barclays:{provider:"barclays",method:"credit_card"},braintree:{provider:"braintree",method:"credit_card"},braintreepaypal:{provider:"braintree",method:"paypal"},braintreeach:{provider:"braintree",method:"ach"},authorizenet:{provider:"authorizenet",method:"credit_card"},elavon:{provider:"elavon",method:"credit_card"},checkoutcom:{provider:"checkoutcom",method:"credit_card"},"checkoutcom.credit_card":{provider:"checkoutcom",method:"credit_card"},"checkoutcom.card":{provider:"checkoutcom",method:"card"},sagepay:{provider:"sagepay",method:"credit_card"},stripe:{provider:"stripe",method:"credit_card"},"stripev3.card":{provider:"stripev3",method:"card"},"stripeupe.card":{provider:"stripeupe",method:"card"},cybersource:{provider:"cybersource",method:"credit_card"},cybersourcev2:{provider:"cybersourcev2",method:"credit_card"},bnz:{provider:"bnz",method:"credit_card"},converge:{provider:"converge",method:"credit_card"},bluesnapv2:{provider:"bluesnapv2",method:"credit_card"},"bluesnapdirect.credit_card":{provider:"bluesnapdirect",method:"credit_card"},"bluesnapdirect.ecp":{provider:"bluesnapdirect",method:"ecp"},"bluesnapdirect.sepa_direct_debit":{provider:"bluesnapdirect",method:"sepa_direct_debit"},orbital:{provider:"orbital",method:"credit_card"},paymetric:{provider:"paymetric",method:"credit_card"},bolt:{provider:"bolt",method:"credit_card"},"barclaycard.credit_card":{provider:"barclaycard",method:"credit_card"},digitalriver:{provider:"digitalriver",method:"credit_card"},moneris:{provider:"moneris",method:"credit_card"},cba_mpgs:{provider:"cba_mpgs",method:"credit_card"},worldpayaccess:{provider:"worldpayaccess",method:"credit_card"},squarev2:{provider:"squarev2",method:"credit_card"},paypalcommercecreditcards:{provider:"paypalcommerce",method:"credit_card"},paypalcommerce:{provider:"paypalcommerce",method:"paypal"},tdonlinemart:{provider:"tdonlinemart",method:"credit_card"}};function Gn(e){return(0,m.pickBy)({firstName:e.firstName,lastName:e.lastName,company:e.company,address1:e.address1,address2:e.address2,city:e.city,stateOrProvince:e.stateOrProvince,countryCode:e.countryCode,postalCode:e.postalCode,phone:e.phone,customFields:e.customFields},m.identity)}var xn={errors:{},statuses:{}};function Yn(){var e,t,n,r,i,a,s,u,c,d,l,p,h,f,g,y,_,v,C,S,I,w,E,b,P,A,T,O,R,M,D,N,L,z,F,U,q,B,G,x,Y,H,j,W,K,J,Q,X,$,ee=(e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingBillingAddress)}))}})),n=Dn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),r=Dn((function(e){return e.errors.continueAsGuestError}),(function(e){return function(){return e}})),i=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=Dn((function(e){return!!e.statuses.isUpdating}),(function(e){return function(){return e}})),s=Dn((function(e){return!!e.statuses.isContinuingAsGuest}),(function(e){return function(){return e}})),u=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(o){return void 0===o&&(o=k),{getBillingAddress:e(o),getBillingAddressOrThrow:t(o),getUpdateError:n(o),getContinueAsGuestError:r(o),getLoadError:i(o),isUpdating:a(o),isContinuingAsGuest:s(o),isLoading:u(o)}}))),te=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingCart)}))}})),n=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),r=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(i){return void 0===i&&(i=V),{getCart:e(i),getCartOrThrow:t(i),getLoadError:n(i),isLoading:r(i)}}))}(),ne=(c=Dn((function(e){return e}),(function(e){return function(){return e}})),d=Dn((function(e){return e.statuses}),(function(e){return(0,On.memoize)((function(t){if(t){var n=e[t];return!0===(n&&n.isInitializing)}return(0,m.some)(e,{isInitializing:!0})}))})),l=Dn((function(e){return e.data}),(function(e){return(0,On.memoize)((function(t,n){var r=e[t];return!!r&&(n?!0===r.initializedContainers[n]:(0,m.some)(r.initializedContainers,(function(e){return!0===e})))}))})),p=Dn((function(e){return e.statuses}),(function(e){return(0,On.memoize)((function(t){if(t){var n=e[t];return!0===(n&&n.isDeinitializing)}return(0,m.some)(e,{isDeinitializing:!0})}))})),h=Dn((function(e){return e.errors}),(function(e){return(0,On.memoize)((function(t){var n=t?e[t]:(0,m.find)((0,m.values)(e),(function(e){return!(!e||!e.initializeError)}));return n&&n.initializeError}))})),f=Dn((function(e){return e.errors}),(function(e){return(0,On.memoize)((function(t){var n=t?e[t]:(0,m.find)((0,m.values)(e),(function(e){return!(!e||!e.deinitializeError)}));return n&&n.deinitializeError}))})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=Z),{getState:c(e),isInitializing:d(e),isInitialized:l(e),isDeinitializing:p(e),getInitializeError:h(e),getDeinitializeError:f(e)}}))),re=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.data}),(function(e){return function(t){if(e){var n=e.context.flashMessages;if(n)return void 0!==t?n.filter((function(e){var n=e.type;return t===n})):n}}})),n=Dn((function(e){return e.data}),(function(e,t){var n=t.formState;return n&&n.data}),(function(e,t){return function(){return e&&t?(0,o.__assign)((0,o.__assign)({},e.storeConfig),{formFields:t}):void 0}})),r=Dn(n,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingCheckoutConfig)}))}})),i=Dn((function(e){return e.data&&e.data.context}),(function(e){return function(){return e}})),a=Dn((function(e){return e.meta&&e.meta.externalSource}),(function(e){return function(){return e}})),s=Dn((function(e){var t;return null===(t=e.meta)||void 0===t?void 0:t.host}),(function(e){return function(){return e}})),u=Dn((function(e){var t;return null===(t=e.meta)||void 0===t?void 0:t.locale}),(function(e){return function(){return e}})),c=Dn((function(e){return e.meta&&e.meta.variantIdentificationToken}),(function(e){return function(){return e}})),d=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),l=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(o,p){return void 0===o&&(o=oe),{getConfig:e(o),getFlashMessages:t(o),getStoreConfig:n(o,{formState:p}),getStoreConfigOrThrow:r(o,{formState:p}),getContextConfig:i(o),getExternalSource:a(o),getHost:s(o),getLocale:u(o),getVariantIdentificationToken:c(o),getLoadError:d(o),isLoading:l(o)}}))}(),ie=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(r){return void 0===r&&(r=He),{getCountries:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),ae=(g=Dn((function(e){return e.data}),(function(e){return function(){return e}})),y=Dn((function(e){return e.errors.removeCouponError}),(function(e){return function(){return e}})),_=Dn((function(e){return e.errors.applyCouponError}),(function(e){return function(){return e}})),v=Dn((function(e){return!!e.statuses.isApplyingCoupon}),(function(e){return function(){return e}})),C=Dn((function(e){return!!e.statuses.isRemovingCoupon}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=de),{getCoupons:g(e),getRemoveError:y(e),getApplyError:_(e),isApplying:v(e),isRemoving:C(e)}}))),se=(S=Dn((function(e){return e.data}),(function(e){return function(){return e}})),I=Dn(S,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingCustomer)}))}})),w=Dn((function(e){return e.errors.createError}),(function(e){return function(){return e}})),E=Dn((function(e){return!!e.statuses.isCreating}),(function(e){return function(){return e}})),b=Dn((function(e){return e.errors.createAddressError}),(function(e){return function(){return e}})),P=Dn((function(e){return!!e.statuses.isCreatingAddress}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=Ie),{getCustomer:S(e),getCustomerOrThrow:I(e),getCreateAccountError:w(e),isCreatingCustomerAccount:E(e),getCreateAddressError:b(e),isCreatingCustomerAddress:P(e)}}))),ue=function(){var e=Dn((function(e){return e.errors.signInMethodId}),(function(e){return e.errors.signInError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=Dn((function(e){return e.errors.signOutMethodId}),(function(e){return e.errors.signOutError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=Dn((function(e){return e.errors.executePaymentMethodCheckoutMethodId}),(function(e){return e.errors.executePaymentMethodCheckoutError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=Dn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeErrors}),(function(e,t){return function(n){if(e&&t)return n?t[n]:t[e]}})),i=Dn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),o=Dn((function(e){return e.statuses.signInMethodId}),(function(e){return e.statuses.isSigningIn}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),a=Dn((function(e){return e.statuses.signOutMethodId}),(function(e){return e.statuses.isSigningOut}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=Dn((function(e){return e.statuses.executePaymentMethodCheckoutMethodId}),(function(e){return e.statuses.isExecutingPaymentMethodCheckout}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),u=Dn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),c=Dn((function(e){return e.data}),(function(e){return function(t){return!(!e[t]||!e[t].isInitialized)}})),d=Dn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(l){return void 0===l&&(l=Te),{getSignInError:e(l),getSignOutError:t(l),getExecutePaymentMethodCheckoutError:n(l),getInitializeError:r(l),getWidgetInteractionError:i(l),isSigningIn:o(l),isSigningOut:a(l),isExecutingPaymentMethodCheckout:s(l),isInitializing:u(l),isInitialized:c(l),isWidgetInteracting:d(l)}}))}(),ce=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.errors.removeGiftCertificateError}),(function(e){return function(){return e}})),n=Dn((function(e){return e.errors.applyGiftCertificateError}),(function(e){return function(){return e}})),r=Dn((function(e){return!!e.statuses.isApplyingGiftCertificate}),(function(e){return function(){return e}})),i=Dn((function(e){return!!e.statuses.isRemovingGiftCertificate}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(o){return void 0===o&&(o=ge),{getGiftCertificates:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:r(o),isRemoving:i(o)}}))}(),le=function(){var e=Dn((function(e){return e.data}),(function(e){return function(t){if(e){var n=t.gateway?t.gateway+"."+t.id:t.id,r=Bn[n];return r?(0,m.filter)(e,r):[]}}})),t=Dn((function(e){return e.data}),(function(e){return void 0===e&&(e=[]),function(t){var n=(0,m.values)(Bn);return e.find((function(e){return e.bigpayToken===t&&"card"===e.type&&n.some((function(t){return(0,m.isMatch)(e,t)}))}))}})),n=Dn(t,(function(e){return function(t){return Ln(e(t),(function(){return new Mn(Rn.MissingPaymentInstrument)}))}})),r=Dn((function(e){return e.data}),(function(e){return function(){if(e)return(0,m.flatMap)(Bn,(function(t){return(0,m.filter)(e,(function(e){return(0,m.isMatch)(e,t)}))}))}})),i=Dn((function(e){return e.meta}),(function(e){return function(){return e}})),o=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=Dn((function(e){return e.errors.failedInstrument}),(function(e){return e.errors.deleteError}),(function(e,t){return function(n){if(!n||e===n)return t}})),s=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}})),u=Dn((function(e){return e.statuses.deletingInstrument}),(function(e){return e.statuses.isDeleting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(c){return void 0===c&&(c=At),{getCardInstrument:t(c),getCardInstrumentOrThrow:n(c),getInstruments:r(c),getInstrumentsByPaymentMethod:e(c),getInstrumentsMeta:i(c),getLoadError:o(c),getDeleteError:a(c),isLoading:s(c),isDeleting:u(c)}}))}(),pe=function(){var e=Dn((function(e){return e.data}),(function(e){return function(t,n){void 0===t&&(t=[]);var r=(0,m.find)(t,{code:n});return(e?e.shippingAddress:[]).map((function(e){return a(e,t,r)}))}})),t=Dn((function(e){return e.data}),(function(e){return function(t,n){void 0===t&&(t=[]);var r=(0,m.find)(t,{code:n});return(e?e.billingAddress:[]).map((function(e){return a(e,t,r)}))}})),n=Dn((function(e){return e.data}),(function(e){return function(){return e?e.customerAccount:[]}})),r=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));function a(e,t,n){return"countryCode"===e.name?function(e,t,n){if(void 0===t&&(t=[]),!t.length)return e;var r=(n||{}).code,i=void 0===r?"":r,a=t.map((function(e){return{value:e.code,label:e.name}}));return(0,o.__assign)((0,o.__assign)({},e),{options:{items:a},default:i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,t,n):"stateOrProvince"===e.name?function(e,t){var n=t||{},r=n.subdivisions,i=void 0===r?[]:r,a=n.requiresState;if(!i.length)return(0,o.__assign)((0,o.__assign)({},e),{required:null!=a&&a});var s=i.map((function(e){return{value:e.code,label:e.name}}));return(0,o.__assign)((0,o.__assign)({},e),{name:"stateOrProvinceCode",options:{items:s},required:null==a||a,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,n):"postalCode"===e.name?function(e,t){var n=(t||{}).hasPostalCodes,r=void 0===n?[]:n;return void 0===r?e:(0,o.__assign)((0,o.__assign)({},e),{required:Boolean(r)})}(e,n):e}return(0,On.memoizeOne)((function(o){return void 0===o&&(o=Be),{getShippingAddressFields:e(o),getBillingAddressFields:t(o),getCustomerAccountFields:n(o),getLoadError:r(o),isLoading:i(o)}}))}(),he=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.meta}),(function(e){return function(){return e}})),n=Dn((function(e){return e.data}),(function(e){return function(t,n){return n?(0,m.find)(e,{id:t,gateway:n}):(0,m.find)(e,{id:t})}})),r=Dn(n,(function(e){return function(t,n){return Ln(e(t,n),(function(){return new Mn(Rn.MissingPaymentMethod)}))}})),i=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),o=Dn((function(e){return e.errors.loadMethodId}),(function(e){return e.errors.loadMethodError}),(function(e,t){return function(n){if(!n||e===n)return t}})),a=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}})),s=Dn((function(e){return e.statuses.loadMethodId}),(function(e){return e.statuses.isLoadingMethod}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(u){return void 0===u&&(u=dt),{getPaymentMethods:e(u),getPaymentMethodsMeta:t(u),getPaymentMethod:n(u),getPaymentMethodOrThrow:r(u),getLoadError:i(u),getLoadMethodError:o(u),isLoading:a(u),isLoadingMethod:s(u)}}))}(),fe=function(){var e=Dn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=Dn((function(e){return e.errors.executeMethodId}),(function(e){return e.errors.executeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=Dn((function(e){return e.errors.finalizeMethodId}),(function(e){return e.errors.finalizeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=Dn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),i=Dn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),o=Dn((function(e){return e.data}),(function(e){return function(t){var n=t.gatewayId?t.methodId+"."+t.gatewayId:t.methodId;return!(!e[n]||!e[n].isInitialized)}})),a=Dn((function(e){return e.statuses.executeMethodId}),(function(e){return e.statuses.isExecuting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=Dn((function(e){return e.statuses.finalizeMethodId}),(function(e){return e.statuses.isFinalizing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),u=Dn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(c){return void 0===c&&(c=yt),{getInitializeError:e(c),getExecuteError:t(c),getFinalizeError:n(c),getWidgetInteractingError:r(c),isInitializing:i(c),isInitialized:o(c),isExecuting:a(c),isFinalizing:s(c),isWidgetInteracting:u(c)}}))}(),me=function(){var e=Dn((function(e){return e.data}),(function(e){return function(t,n){if(e){var r=Yt(xt({consignmentId:t,searchArea:n})),i=btoa(""+JSON.stringify(r));return e[i]}}})),t=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(r){return void 0===r&&(r=Ht),{getPickupOptions:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),ye=(A=Dn((function(e){return e.data}),(function(e){return function(){return e}})),T=Dn(A,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentProviderCustomer)}))}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=wt),{getPaymentProviderCustomer:A(e),getPaymentProviderCustomerOrThrow:T(e)}}))),_e=(O=Dn((function(e){return e.data}),(function(e){return function(t){return e[t]}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=Dt),{getCheckout:O(e)}}))),ve=(R=Dn((function(e){return e.data}),(function(e){return function(){var t=null==e?void 0:e.find((function(e){return!e.selectedPickupOption}));return null==t?void 0:t.shippingAddress}})),M=Dn(R,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingShippingAddress)}))}})),D=Dn((function(e){return e.data}),(function(e){return function(){var t=null==e?void 0:e.filter((function(e){return!e.selectedPickupOption}));return t?t.map((function(e){return e.shippingAddress})):[]}})),N=Dn(D,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingShippingAddress)}))}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=Ft),{getShippingAddress:R(e),getShippingAddressOrThrow:M(e),getShippingAddresses:D(e),getShippingAddressesOrThrow:N(e)}}))),Ce=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),n=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}}));return(0,On.memoizeOne)((function(r){return void 0===r&&(r=Qt),{getShippingCountries:e(r),getLoadError:t(r),isLoading:n(r)}}))}(),Se=function(){var e=Dn((function(e){return e.errors.updateAddressMethodId}),(function(e){return e.errors.updateAddressError}),(function(e,t){return function(n){if(!n||e===n)return t}})),t=Dn((function(e){return e.errors.selectOptionMethodId}),(function(e){return e.errors.selectOptionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),n=Dn((function(e){return e.errors.initializeMethodId}),(function(e){return e.errors.initializeError}),(function(e,t){return function(n){if(!n||e===n)return t}})),r=Dn((function(e){return e.errors.widgetInteractionMethodId}),(function(e){return e.errors.widgetInteractionError}),(function(e,t){return function(n){if(!n||e===n)return t}})),i=Dn((function(e){return e.statuses.updateAddressMethodId}),(function(e){return e.statuses.isUpdatingAddress}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),o=Dn((function(e){return e.statuses.selectOptionMethodId}),(function(e){return e.statuses.isSelectingOption}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),a=Dn((function(e){return e.statuses.initializeMethodId}),(function(e){return e.statuses.isInitializing}),(function(e,t){return function(n){return!(n&&e!==n||!t)}})),s=Dn((function(e){return e.data}),(function(e){return function(t){return!(!e[t]||!e[t].isInitialized)}})),u=Dn((function(e){return e.statuses.widgetInteractionMethodId}),(function(e){return e.statuses.isWidgetInteracting}),(function(e,t){return function(n){return!(n&&e!==n||!t)}}));return(0,On.memoizeOne)((function(c){return void 0===c&&(c=rn),{getUpdateAddressError:e(c),getSelectOptionError:t(c),getInitializeError:n(c),getWidgetInteractionError:r(c),isUpdatingAddress:i(c),isSelectingOption:o(c),isInitializing:a(c),isInitialized:s(c),isWidgetInteracting:u(c)}}))}(),we=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingConsignments)}))}})),n=Dn((function(e){return e.data}),(function(e){return function(t){if(e&&e.length)return(0,m.find)(e,{id:t})}})),r=Dn((function(e){return e.data}),(function(e){return function(t){if(e&&e.length)return(0,m.find)(e,(function(e){return n=e.shippingAddress,r=t,(0,m.isEqual)(Gn(n),Gn(r));var n,r}))}})),i=Dn((function(e){return e.data}),(function(e){return function(){if(e&&e.length)return e[0].selectedShippingOption}})),o=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),a=Dn((function(e){return e.errors.createError}),(function(e){return function(){return e}})),s=Dn((function(e){return e.errors.loadShippingOptionsError}),(function(e){return function(){return e}})),u=Dn(e,(function(e,t){return t.cart.getCart}),(function(e,t){return function(){var n=t();if(!n)return[];var r=(e()||[]).reduce((function(e,t){return e.concat(t.lineItemIds)}),[]);return(n.lineItems.physicalItems||[]).filter((function(e){return r.indexOf(e.id)<0}))}})),c=Dn((function(e){return e.errors.updateError}),(function(e){return function(t){return t?e[t]:(0,m.find)(e)}})),d=Dn((function(e){return e.errors.deleteError}),(function(e){return function(t){return t?e[t]:(0,m.find)(e)}})),l=Dn(r,c,a,(function(e,t,n){return function(r){var i=e(r);return i?t(i.id):n()}})),p=Dn((function(e){return e.errors.updateShippingOptionError}),(function(e){return function(t){return t?e[t]:(0,m.find)(e)}})),h=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!0===e}})),f=Dn((function(e){return e.statuses.isLoadingShippingOptions}),(function(e){return function(){return!0===e}})),g=Dn((function(e){return e.statuses.isCreating}),(function(e){return function(){return!0===e}})),y=Dn((function(e){return e.statuses.isUpdating}),(function(e){return function(t){return t?!0===e[t]:!0===(0,m.find)(e)}})),_=Dn((function(e){return e.statuses.isDeleting}),(function(e){return function(t){return t?!0===e[t]:!0===(0,m.find)(e)}})),v=Dn(r,y,g,(function(e,t,n){return function(r){var i=e(r);return i?t(i.id):n()}})),C=Dn((function(e){return e.statuses.isUpdatingShippingOption}),(function(e){return function(t){return t?!0===e[t]:!0===(0,m.find)(e)}}));return(0,On.memoizeOne)((function(m,S){return void 0===m&&(m=Ft),{getConsignments:e(m),getConsignmentsOrThrow:t(m),getConsignmentById:n(m),getConsignmentByAddress:r(m),getShippingOption:i(m),getLoadError:o(m),getCreateError:a(m),getLoadShippingOptionsError:s(m),getUnassignedItems:u(m,{cart:S}),getUpdateError:c(m),getDeleteError:d(m),getItemAssignmentError:l(m),getUpdateShippingOptionError:p(m),isLoading:h(m),isLoadingShippingOptions:f(m),isCreating:g(m),isUpdating:y(m),isDeleting:_(m),isAssigningItems:v(m),isUpdatingShippingOption:C(m)}}))}(),Ee=function(){var e=Dn((function(e){return e.data}),(function(e,t){return t.billingAddress.getBillingAddress}),(function(e,t){return t.cart.getCart}),(function(e,t){return t.customer.getCustomer}),(function(e,t){return t.consignments.getConsignments}),(function(e,t){return t.coupons.getCoupons}),(function(e,t){return t.giftCertificates.getGiftCertificates}),(function(e,t,n,r,i,a,s){return function(){var u=t(),c=n(),d=r(),l=i()||[],p=a()||[],h=s()||[];if(e&&c&&d)return(0,o.__assign)((0,o.__assign)({},e),{billingAddress:u,cart:c,customer:d,consignments:l,coupons:p,giftCertificates:h})}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingCheckout)}))}})),n=Dn(e,(function(e){return function(t){var n=e();if(n){var r=n.grandTotal||0,i=n.customer.storeCredit||0;return t?Math.max(r-i,0):n.outstandingBalance}}})),r=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=Dn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),a=Dn((function(e){return e.statuses.isExecutingSpamCheck}),(function(e){return function(){return!0===e}})),s=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!0===e}})),u=Dn((function(e){return e.statuses.isUpdating}),(function(e){return function(){return!0===e}}));return(0,On.memoizeOne)((function(o,c,d,l,p,h,f){return void 0===o&&(o=En),{getCheckout:e(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getCheckoutOrThrow:t(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getOutstandingBalance:n(o,{billingAddress:c,cart:d,consignments:l,coupons:p,customer:h,giftCertificates:f}),getLoadError:r(o),getUpdateError:i(o),isExecutingSpamCheck:a(o),isLoading:s(o),isUpdating:u(o)}}))}(),be=function(){var e=Dn((function(e){return e.data}),(function(e,t){return t.billingAddress.getOrderBillingAddress()}),(function(e,t){return t.coupons.getCoupons()}),(function(e,t,n){return void 0===n&&(n=[]),function(){if(e&&t)return(0,o.__assign)((0,o.__assign)({},e),{billingAddress:t,coupons:n})}})),t=Dn(e,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingOrder)}))}})),n=Dn((function(e){return e.meta}),(function(e){return function(){return e}})),r=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),i=Dn((function(e){var t;return null===(t=e.data)||void 0===t?void 0:t.payments}),(function(e){return void 0===e&&(e=[]),function(t){var n=e.find((function(e){return e.providerId===t}));return null==n?void 0:n.paymentId}})),a=Dn((function(e){return!!e.statuses.isLoading}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(o,s,u){return void 0===o&&(o=Ze),{getOrder:e(o,{billingAddress:s,coupons:u}),getOrderOrThrow:t(o,{billingAddress:s,coupons:u}),getOrderMeta:n(o),getLoadError:r(o),getPaymentId:i(o),isLoading:a(o)}}))}(),Pe=(L=Dn((function(e){return e.data}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=it),{getOrderBillingAddress:L(e)}}))),Ae=(z=Dn((function(e){return e.order.getOrderMeta}),(function(e){return function(){var t=e();return t&&t.payment}})),F=Dn((function(e){return e.order.getOrder}),(function(e){return function(){var t=e();return(0,m.find)(t&&t.payments,(function(e){var t=e.providerId;return"giftcertificate"!==t&&"storecredit"!==t}))}})),U=Dn((function(e){return e.checkout.getCheckout}),(function(e){return function(){var t=e();return(0,m.find)(t&&t.payments,(function(e){return e.providerType===Fn}))}})),q=Dn(z,U,F,(function(e,t,n){return function(){var r=e();if(r&&r.id)return{providerId:r.id,gatewayId:r.gateway};var i=t()||n();return i&&i.providerId?{providerId:i.providerId,gatewayId:i.gatewayId}:void 0}})),B=Dn(q,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentId)}))}})),G=Dn(z,U,F,(function(e,t,n){return function(){var r=e();if(r&&r.status)return r.status.replace("PAYMENT_STATUS_","");var i=t()||n();return i?i.detail.step:void 0}})),x=Dn(G,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentStatus)}))}})),Y=Dn((function(e){return e.order.getOrderMeta}),(function(e){return function(){var t=e();return t&&t.token}})),H=Dn(Y,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentToken)}))}})),j=Dn(z,(function(e){return function(){var t=e();return t&&t.redirectUrl}})),W=Dn(j,(function(e){return function(){return Ln(e(),(function(){return new Mn(Rn.MissingPaymentRedirectUrl)}))}})),K=Dn((function(e){return e.checkout.getOutstandingBalance}),(function(e){return function(t){void 0===t&&(t=!1);var n=e(t);return!!n&&n>0}})),J=Dn(G,(function(e){return function(t){return!(!t||!t.nonce)||e()===Un||e()===qn}})),(0,On.memoizeOne)((function(e,t){return{getPaymentId:q({checkout:e,order:t}),getPaymentIdOrThrow:B({checkout:e,order:t}),getPaymentStatus:G({checkout:e,order:t}),getPaymentStatusOrThrow:x({checkout:e,order:t}),getPaymentToken:Y({checkout:e,order:t}),getPaymentTokenOrThrow:H({checkout:e,order:t}),getPaymentRedirectUrl:j({checkout:e,order:t}),getPaymentRedirectUrlOrThrow:W({checkout:e,order:t}),isPaymentDataRequired:K({checkout:e,order:t}),isPaymentDataSubmitted:J({checkout:e,order:t})}}))),Oe=function(){var e=Dn((function(e){return e.errors.applyError}),(function(e){return function(){return e}})),t=Dn((function(e){return!!e.statuses.isApplying}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(n){return void 0===n&&(n=xn),{getApplyError:e(n),isApplying:t(n)}}))}(),Re=function(){var e=Dn((function(e){return e.errors.updateError}),(function(e){return function(){return e}})),t=Dn((function(e){return!!e.statuses.isUpdating}),(function(e){return function(){return e}}));return(0,On.memoizeOne)((function(n){return void 0===n&&(n=Cn),{getUpdateError:e(n),isUpdating:t(n)}}))}(),Me=(Q=Dn((function(e){return e.data}),(function(e){return function(){return e}})),X=Dn((function(e){return e.errors.sendError}),(function(e){return function(){return e}})),$=Dn((function(e){return!!e.statuses.isSending}),(function(e){return function(){return e}})),(0,On.memoizeOne)((function(e){return void 0===e&&(e=dn),{getEmail:Q(e),getSendError:X(e),isSending:$(e)}}))),ke=function(){var e=Dn((function(e){return e.data}),(function(e){return function(){return e}})),t=Dn((function(e){return e.data}),(function(e){return function(t){return null==e?void 0:e.find((function(e){return e.region===t}))}})),n=Dn((function(e){return e.errors.loadError}),(function(e){return function(){return e}})),r=Dn((function(e){return e.statuses.isLoading}),(function(e){return function(){return!!e}}));return(0,On.memoizeOne)((function(i){return void 0===i&&(i=Ne),{getExtensions:e(i),getExtensionByRegion:t(i),getLoadError:n(i),isLoading:r(i)}}))}();return function(e,t){void 0===t&&(t={});var n,r=ee(e.billingAddress),i=te(e.cart),o=ne(e.checkoutButton),a=ie(e.countries),s=ae(e.coupons),u=se(e.customer),c=ue(e.customerStrategies),d=ke(e.extensions),l=pe(e.formFields),p=ce(e.giftCertificates),h=le(e.instruments),f=Pe(e.orderBillingAddress),m=he(e.paymentMethods),g=ye(e.paymentProviderCustomer),y=fe(e.paymentStrategies),_=me(e.pickupOptions),v=_e(e.remoteCheckout),C=ve(e.consignments),S=Ce(e.shippingCountries),I=Se(e.shippingStrategies),w=Re(e.subscriptions),E=Oe(e.storeCredit),b=Me(e.signInEmail),P=we(e.consignments,i),A=Ee(e.checkout,r,i,P,s,u,p),T=be(e.order,f,s),O=Ae(A,T),R={billingAddress:r,cart:i,checkout:A,checkoutButton:o,config:re(e.config,e.formFields),consignments:P,countries:a,coupons:s,customer:u,customerStrategies:c,extensions:d,form:l,giftCertificates:p,instruments:h,order:T,orderBillingAddress:f,payment:O,paymentMethods:m,paymentProviderCustomer:g,paymentStrategies:y,pickupOptions:_,remoteCheckout:v,shippingAddress:C,shippingCountries:S,shippingStrategies:I,signInEmail:b,subscriptions:w,storeCredit:E};return t.shouldWarnMutation?(n=R,Object.keys(n).reduce((function(e,t){return e[t]=zn(n[t]),e}),{})):R}}function Vn(e,t){void 0===e&&(e={});var n,r,i=(n=new C,["catalog_only","empty_cart","invalid_order_id","invalid_order_token","missing_order_token","missing_provider_token","missing_shipping_method","order_completion_error","order_could_not_be_finalized_error","order_create_failed","provider_fatal_error","provider_setup_error","stock_too_low"].forEach((function(e){n.register(e,(function(e,t){return new f(e,t)}))})),n.register("invalid_payment_provider",(function(e){return new d(e)})),n.register("payment_config_not_found",(function(e){return new d(e)})),r=n,function(e){return(0,S.from)(e).pipe((0,I.catchError)((function(e){if(e instanceof Error||e.payload instanceof Error)throw e;if((n=e.payload)&&"object"==typeof n&&["body","headers","status","statusText"].every((function(e){return Object.prototype.hasOwnProperty.call(n,e)}))){var t=e.payload.body&&e.payload.body.detail;throw(0,o.__assign)((0,o.__assign)({},e),{payload:r.createError(e.payload,t)})}var n;throw e})))}),s=Yn();return(0,a.createDataStore)((0,a.combineReducers)({billingAddress:D,cart:H,checkout:bn,checkoutButton:ee,config:ae,consignments:Ut,countries:je,coupons:le,customer:we,customerStrategies:Oe,extensions:Le,formFields:Ge,giftCertificates:ye,instruments:Tt,orderBillingAddress:ot,order:Qe,payment:st,paymentMethods:lt,paymentStrategies:_t,pickupOptions:jt,paymentProviderCustomer:Et,remoteCheckout:Nt,shippingCountries:Xt,shippingStrategies:on,signInEmail:ln,subscriptions:Sn,storeCredit:gn}),e,(0,o.__assign)({actionTransformer:i,stateTransformer:function(e){return s(e)}},t))}function Hn(e,t,n){var r=new WeakMap;function i(e){var n=this;return function(){for(var i,a=[],s=0;s<arguments.length;s++)a[s]=arguments[s];var u,c=a[a.length-1];if(!(u=c,u&&"boolean"==typeof u.useCache?c:{useCache:!1}).useCache)return e.call.apply(e,(0,o.__spreadArrays)([n],a));var d,l=r.get(n)||{};return r.get(n)||r.set(n,l),l[t]||(l[t]=(d=e,(0,On.memoize)((function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=d.call.apply(d,(0,o.__spreadArrays)([this],e));return n instanceof S.Observable?(0,S.from)(n).pipe((0,I.shareReplay)()):"function"==typeof n?(0,On.memoize)((function(e){return(0,S.from)(n(e)).pipe((0,I.shareReplay)())})):n})))),(i=l[t]).call.apply(i,(0,o.__spreadArrays)([n],a))}}return{get:function(){if("function"!=typeof n.value)throw new Error("Decorator should be used in functions");var e=i.call(this,n.value);return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:e})),e}}}var jn=function(e){return!!e};const Wn=function(){function e(e){this._requestSender=e}return e.prototype.loadPaymentMethodsById=function(e,t){var n=this;return function(r){return new S.Observable((function(i){var s,u=null===(s=r.getState().cart.getCart())||void 0===s?void 0:s.id,c=u?(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{cartId:u}):(0,o.__assign)({},null==t?void 0:t.params);i.next((0,a.createAction)(rt.LoadPaymentMethodsRequested)),Promise.all(e.map((function(e){return(0,o.__awaiter)(n,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this._requestSender.loadPaymentMethod(e,(0,o.__assign)((0,o.__assign)({},t),{params:c}))];case 1:return[2,n.sent().body];case 2:return n.sent(),[2,void 0];case 3:return[2]}}))}))}))).then((function(e){var t=e.filter(jn);i.next((0,a.createAction)(rt.LoadPaymentMethodsSucceeded,t)),i.complete()})).catch((function(e){i.next((0,a.createAction)(rt.LoadPaymentMethodsFailed,e)),i.complete()}))}))}},e.prototype.loadPaymentMethods=function(e){var t=this;return function(n){return S.Observable.create((function(r){var i=n.getState().cart.getCartOrThrow();r.next((0,a.createAction)(rt.LoadPaymentMethodsRequested)),t._requestSender.loadPaymentMethods((0,o.__assign)((0,o.__assign)({},e),{params:(0,o.__assign)((0,o.__assign)({},null==e?void 0:e.params),{cartId:i.id})})).then((function(e){var n={deviceSessionId:e.headers["x-device-session-id"],sessionHash:e.headers["x-session-hash"]},i=e.body,o=Array.isArray(i)?t._filterApplePay(i):i;r.next((0,a.createAction)(rt.LoadPaymentMethodsSucceeded,o,n)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(rt.LoadPaymentMethodsFailed,e))}))}))}},e.prototype.loadPaymentMethod=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var s,u=null===(s=r.getState().cart.getCart())||void 0===s?void 0:s.id,c=u?(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{cartId:u}):(0,o.__assign)({},null==t?void 0:t.params);i.next((0,a.createAction)(rt.LoadPaymentMethodRequested,void 0,{methodId:e})),n._requestSender.loadPaymentMethod(e,(0,o.__assign)((0,o.__assign)({},t),{params:c})).then((function(t){i.next((0,a.createAction)(rt.LoadPaymentMethodSucceeded,t.body,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(rt.LoadPaymentMethodFailed,t,{methodId:e}))}))}))}},e.prototype._filterApplePay=function(e){return(0,m.filter)(e,(function(e){return!("applepay"===e.id&&!function(e){return"ApplePaySession"in e}(window))}))},(0,o.__decorate)([Hn],e.prototype,"loadPaymentMethod",null),e}();var Kn;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(Kn||(Kn={}));const Jn=Kn;var Zn="This API endpoint is for internal use only and may change in the future",Qn={"X-Checkout-SDK-Version":"1.589.1"};const Xn=function(){function e(e){this._requestSender=e}return e.prototype.loadPaymentMethods=function(e){var t=void 0===e?{}:e,n=t.timeout,r=t.params;return this._requestSender.get("/api/storefront/payments",{timeout:n,headers:(0,o.__assign)({Accept:Jn.JsonV1,"X-API-INTERNAL":Zn},Qn),params:r})},e.prototype.loadPaymentMethod=function(e,t){var n=void 0===t?{}:t,r=n.timeout,i=n.params,a="/api/storefront/payments/"+e;return this._requestSender.get(a,{timeout:r,headers:(0,o.__assign)({Accept:Jn.JsonV1,"X-API-INTERNAL":Zn},Qn),params:i})},e}(),$n=require("@bigcommerce/script-loader");function er(e,t,n){return(r=t)&&r.type&&r.error?(0,S.concat)((0,S.of)(t),(0,S.throwError)((0,a.createErrorAction)(e,t.payload,n))):(0,S.throwError)((0,a.createErrorAction)(e,t,n));var r}const tr=function(e){function t(t){var n=e.call(this,t||"Unable to continue as a guest because the customer is already signed in.")||this;return n.name="UnableToContinueAsGuestError",n.type="unable_to_continue_as_guest",n}return(0,o.__extends)(t,e),t}(l),nr=function(){function e(e,t){this._requestSender=e,this._subscriptionActionCreator=t}return e.prototype.continueAsGuest=function(e,t){var n=this;return function(r){var i=r.getState(),s=i.checkout.getCheckout();if(!s)throw new Mn(Rn.MissingCheckout);var u=i.customer.getCustomer();if(u&&!u.isGuest)throw new tr;var c,d=i.billingAddress.getBillingAddress();if(d){d.country;var l=(0,o.__rest)(d,["country"]);c=(0,o.__assign)((0,o.__assign)({},l),e)}else c=e;return(0,S.merge)((0,S.concat)((0,S.of)((0,a.createAction)(P.ContinueAsGuestRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._createOrUpdateBillingAddress(s.id,c,t)];case 1:return e=n.sent().body,[2,(0,a.createAction)(P.ContinueAsGuestSucceeded,e)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(P.ContinueAsGuestFailed,e)}))),n._updateCustomerConsent(e,t))}},e.prototype.updateAddress=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var s=r.getState(),u=s.checkout.getCheckout();if(!u)throw new Mn(Rn.MissingCheckout);i.next((0,a.createAction)(P.UpdateBillingAddressRequested));var c=s.billingAddress.getBillingAddress(),d=(0,o.__assign)((0,o.__assign)({},e),{email:void 0===e.email&&c?c.email:e.email});c&&c.id&&(d.id=c.id),n._createOrUpdateBillingAddress(u.id,d,t).then((function(e){var t=e.body;i.next((0,a.createAction)(P.UpdateBillingAddressSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(P.UpdateBillingAddressFailed,e))}))}))}},e.prototype._updateCustomerConsent=function(e,t){var n=e.email,r=e.acceptsAbandonedCartEmails,i=e.acceptsMarketingNewsletter;return null==r&&null==i?(0,S.empty)():this._subscriptionActionCreator.updateSubscriptions({email:n,acceptsMarketingNewsletter:i||!1,acceptsAbandonedCartEmails:r||!1},t)},e.prototype._createOrUpdateBillingAddress=function(e,t,n){return t.id?this._requestSender.updateAddress(e,t,n):this._requestSender.createAddress(e,t,n)},e}();var rr={include:["cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","promotions.banners"].join(",")};const ir=function(){function e(e){this._requestSender=e}return e.prototype.createAddress=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/billing-address",a=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post(i,{body:t,params:rr,headers:a,timeout:r})},e.prototype.updateAddress=function(e,t,n){var r=(void 0===n?{}:n).timeout,i=t.id,a=(0,o.__rest)(t,["id"]),s="/api/storefront/checkouts/"+e+"/billing-address/"+i,u=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.put(s,{params:rr,body:a,headers:u,timeout:r})},e}(),or=function(){function e(e){this._requestSender=e}return e.prototype.createBuyNowCart=function(e,t){var n=(void 0===t?{}:t).timeout,r=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post("/api/storefront/carts",{body:e,headers:r,timeout:n})},e}(),ar=function(){function e(e,t,n){this._checkoutRequestSender=e,this._configActionCreator=t,this._formFieldsActionCreator=n}return e.prototype.loadCheckout=function(e,t){var n=this;return function(r){return(0,S.concat)((0,S.of)((0,a.createAction)(w.LoadCheckoutRequested)),(0,S.merge)(n._configActionCreator.loadConfig((0,o.__assign)((0,o.__assign)({},t),{useCache:!0,params:(0,o.__assign)((0,o.__assign)({},null==t?void 0:t.params),{checkoutId:e})})),n._formFieldsActionCreator.loadFormFields((0,o.__assign)((0,o.__assign)({},t),{useCache:!0}))),(0,S.defer)((function(){return n._checkoutRequestSender.loadCheckout(e,t).then((function(e){var t=e.body;return(0,a.createAction)(w.LoadCheckoutSucceeded,n._shouldTransformCustomerAddress(r.getState().config.getStoreConfigOrThrow())?n._transformCustomerAddresses(t):t)}))}))).pipe((0,I.catchError)((function(e){return er(w.LoadCheckoutFailed,e)})))}},e.prototype.loadDefaultCheckout=function(e){var t=this;return function(n){return(0,S.concat)((0,S.of)((0,a.createAction)(w.LoadCheckoutRequested)),(0,S.merge)(t._configActionCreator.loadConfig(),t._formFieldsActionCreator.loadFormFields((0,o.__assign)((0,o.__assign)({},e),{useCache:!0}))),(0,S.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=n.getState(),!(r=t.config.getContextConfig())||!r.checkoutId)throw new Mn(Rn.MissingCheckoutConfig);return[4,this._checkoutRequestSender.loadCheckout(r.checkoutId,e)];case 1:return i=o.sent().body,[2,(0,a.createAction)(w.LoadCheckoutSucceeded,this._shouldTransformCustomerAddress(t.config.getStoreConfigOrThrow())?this._transformCustomerAddresses(i):i)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(w.LoadCheckoutFailed,e)})))}},e.prototype.updateCheckout=function(e,t){var n=this;return function(r){return new S.Observable((function(i){var o=r.getState().checkout.getCheckout();if(!o)throw new Mn(Rn.MissingCheckout);i.next((0,a.createAction)(w.UpdateCheckoutRequested)),n._checkoutRequestSender.updateCheckout(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(w.UpdateCheckoutSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(w.UpdateCheckoutFailed,e))}))}))}},e.prototype.loadCurrentCheckout=function(e){var t=this;return function(n){var r=n.getState().checkout.getCheckout();if(!r)throw new Mn(Rn.MissingCheckout);return t.loadCheckout(r.id,e)(n)}},e.prototype._shouldTransformCustomerAddress=function(e){var t;return null===(t=e.checkoutSettings.features["CHECKOUT-8183.set_shouldSaveAddress_false_for_existing_address"])||void 0===t||t},e.prototype._transformCustomerAddresses=function(e){return(0,o.__assign)((0,o.__assign)({},e),{customer:(0,o.__assign)((0,o.__assign)({},e.customer),{addresses:e.customer.addresses.map((function(e){return(0,o.__assign)((0,o.__assign)({},e),{shouldSaveAddress:!1})}))})})},e}();function sr(e){return(0,m.uniq)(e).join(",")}function ur(e,t){return void 0===t&&(t=[]),Array.isArray(t)?sr((0,o.__spreadArrays)(e,t)):function(e,t){var n=(0,m.keys)((0,m.pickBy)(t,(function(e){return!e}))),r=(0,m.keys)((0,m.filter)(t));return sr((0,o.__spreadArrays)((0,m.difference)(e,n),r))}(e,t)}const cr=["cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","customer.customerGroup","payments","promotions.banners"],dr=function(e){function t(t){var n=e.call(this,t,{message:t.body.title})||this;return n.name="CheckoutNotAvailableError",n.type="checkout_not_available",n}return(0,o.__extends)(t,e),t}(h),lr=function(){function e(e){this._requestSender=e}return e.prototype.loadCheckout=function(e,t){var n=void 0===t?{}:t,r=n.params,i=(void 0===r?{}:r).include,a=n.timeout,s="/api/storefront/checkout/"+e,u=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.get(s,{params:{include:ur(cr,i)},headers:u,timeout:a}).catch((function(e){if(e.status>=400&&e.status<500)throw new dr(e);throw e}))},e.prototype.updateCheckout=function(e,t,n){var r=void 0===n?{}:n,i=r.params,a=(void 0===i?{}:i).include,s=r.timeout,u="/api/storefront/checkout/"+e,c=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.put(u,{params:{include:ur(cr,a)},body:t,headers:c,timeout:s})},e}(),pr=function(){function e(){}return e.prototype.isEqual=function(e,t){return(0,m.isEqual)(this._normalize(e),this._normalize(t))},e.prototype._normalize=function(e){return{cartAmount:e.cartAmount,currency:e.currency,id:e.id,lineItems:{digitalItems:e.lineItems.digitalItems.slice().sort((function(e,t){return(""+e.productId+e.variantId).localeCompare(""+t.productId+t.variantId)})).map((function(e){return{extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId}})),giftCertificates:e.lineItems.giftCertificates.slice().sort((function(e,t){return(""+e.id).localeCompare(""+t.id)})).map((function(e){return{amount:e.amount,recipient:e.recipient}})),physicalItems:e.lineItems.physicalItems.slice().sort((function(e,t){return(""+e.productId+e.variantId).localeCompare(""+t.productId+t.variantId)})).map((function(e){return{extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId,giftWrapping:e.giftWrapping}}))}}},e}(),hr=function(e){function t(t,n){var r=e.call(this,"An update to your shopping cart has been detected and your available shipping costs have been updated.")||this;return r.name="CartChangedError",r.type="cart_changed",r.data={previous:t,updated:n},r}return(0,o.__extends)(t,e),t}(l),fr=function(){function e(e){this._checkoutRequestSender=e}return e.prototype.validate=function(e,t){var n=this;if(!e)throw new Mn(Rn.MissingCheckout);return this._checkoutRequestSender.loadCheckout(e.id,t).then((function(t){var r=new pr;if(!(e.outstandingBalance===t.body.outstandingBalance&&n._compareCoupons(e.coupons,t.body.coupons)&&n._compareGiftCertificates(e.giftCertificates,t.body.giftCertificates)&&r.isEqual(e.cart,t.body.cart)))throw new hr(n._getComparableCheckout(e),n._getComparableCheckout(t.body))}))},e.prototype._compareCoupons=function(e,t){return(0,m.isEqual)((0,m.map)(e,"code"),(0,m.map)(t,"code"))},e.prototype._compareGiftCertificates=function(e,t){return(0,m.isEqual)((0,m.map)(e,"code"),(0,m.map)(t,"code"))},e.prototype._getComparableCheckout=function(e){var t=e.cart,n=e.coupons,r=e.giftCertificates,i=e.outstandingBalance;return{cart:{cartAmount:t.cartAmount,currency:t.currency,lineItems:t.lineItems},coupons:n,giftCertificates:r,outstandingBalance:i}},e}(),mr=function(){function e(e){this._configRequestSender=e}return e.prototype.loadConfig=function(e){var t=this;return S.Observable.create((function(n){n.next((0,a.createAction)(J.LoadConfigRequested)),t._configRequestSender.loadConfig(e).then((function(e){n.next((0,a.createAction)(J.LoadConfigSucceeded,e.body)),n.complete()})).catch((function(e){n.error((0,a.createErrorAction)(J.LoadConfigFailed,e))}))}))},(0,o.__decorate)([Hn],e.prototype,"loadConfig",null),e}(),gr=function(){function e(e){this._requestSender=e}return e.prototype.loadConfig=function(e){var t=void 0===e?{}:e,n=t.timeout,r=t.params;return this._requestSender.get("/api/storefront/checkout-settings",{timeout:n,headers:(0,o.__assign)({Accept:Jn.JsonV1,"X-API-INTERNAL":Zn},Qn),params:r}).catch((function(e){if(e.status>=400&&e.status<500)throw new dr(e);throw e}))},e}();function yr(e){var t=e;return"object"==typeof t&&"object"==typeof t.payload&&"string"==typeof t.payload.token}const _r=function(){function e(e,t,n){this._customerRequestSender=e,this._checkoutActionCreator=t,this._spamProtectionActionCreator=n}return e.prototype.createCustomer=function(e,t){var n=this;return function(r){var i=r.getState().config.getStoreConfigOrThrow().checkoutSettings.isStorefrontSpamProtectionEnabled,s=function(i){return(0,S.from)(n._customerRequestSender.createAccount((0,o.__assign)((0,o.__assign)({},e),{token:i}),t)).pipe((0,I.switchMap)((function(){return(0,S.concat)(n._checkoutActionCreator.loadCurrentCheckout(t)(r),(0,S.of)((0,a.createAction)(me.CreateCustomerSucceeded)))})))};return(0,S.concat)((0,S.of)((0,a.createAction)(me.CreateCustomerRequested)),i?(0,S.from)(n._spamProtectionActionCreator.execute()(r)).pipe((0,I.switchMap)((function(e){var t;return yr(e)?(0,S.concat)((0,S.of)(e),s(null===(t=e.payload)||void 0===t?void 0:t.token)):(0,S.of)(e)}))):s()).pipe((0,I.catchError)((function(e){return er(me.CreateCustomerFailed,e)})))}},e.prototype.createAddress=function(e,t){var n=this;return(0,S.concat)((0,S.of)((0,a.createAction)(me.CreateCustomerAddressRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._customerRequestSender.createAddress(e,t)];case 1:return n=r.sent().body,[2,(0,a.createAction)(me.CreateCustomerAddressSucceeded,n)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(me.CreateCustomerAddressFailed,e)})))},e.prototype.signInCustomer=function(e,t){var n=this;return function(r){return(0,S.concat)((0,S.of)((0,a.createAction)(me.SignInCustomerRequested)),(0,S.from)(n._customerRequestSender.signInCustomer(e,t)).pipe((0,I.switchMap)((function(e){var i=e.body;return(0,S.concat)(n._checkoutActionCreator.loadCurrentCheckout(t)(r),(0,S.of)((0,a.createAction)(me.SignInCustomerSucceeded,i.data)))})))).pipe((0,I.catchError)((function(e){return er(me.SignInCustomerFailed,e)})))}},e.prototype.signOutCustomer=function(e){var t=this;return function(n){return(0,S.concat)((0,S.of)((0,a.createAction)(me.SignOutCustomerRequested)),(0,S.from)(t._customerRequestSender.signOutCustomer(e)).pipe((0,I.switchMap)((function(r){var i=r.body;return(0,S.concat)(t._checkoutActionCreator.loadCurrentCheckout(e)(n),(0,S.of)((0,a.createAction)(me.SignOutCustomerSucceeded,i.data)))})))).pipe((0,I.catchError)((function(e){return er(me.SignOutCustomerFailed,e)})))}},e}(),vr=function(){function e(e){this._requestSender=e}return e.prototype.createAccount=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/api/storefront/customer",{timeout:n,headers:Qn,body:e})},e.prototype.createAddress=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/api/storefront/customer-address",{timeout:n,headers:Qn,body:e})},e.prototype.signInCustomer=function(e,t){var n=(void 0===t?{}:t).timeout;return this._requestSender.post("/internalapi/v1/checkout/customer",{timeout:n,headers:Qn,body:e})},e.prototype.signOutCustomer=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.delete("/internalapi/v1/checkout/customer",{timeout:t,headers:Qn})},e}(),Cr=function(){function e(e){this._formFieldsRequestSender=e}return e.prototype.loadFormFields=function(e){var t=this;return(0,S.concat)((0,S.of)((0,a.createAction)(De.LoadFormFieldsRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._formFieldsRequestSender.loadFields(e)];case 1:return t=n.sent().body,[2,(0,a.createAction)(De.LoadFormFieldsSucceeded,t)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(De.LoadFormFieldsFailed,e)})))},(0,o.__decorate)([Hn],e.prototype,"loadFormFields",null),e}(),Sr=function(){function e(e){this._requestSender=e}return e.prototype.loadFields=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.get("/api/storefront/form-fields",{timeout:t,headers:(0,o.__assign)({Accept:Jn.JsonV1,"X-API-INTERNAL":Zn},Qn)})},e}(),Ir=function(e){var t=this,n=new Promise((function(e,n){t.cancel=n}));this.promise=Promise.race([e,n])},wr=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the required element is unexpectedly detached from the page.")||this;return n.name="UnexpectedDetachmentError",n.type="unexpected_detachment",n}return(0,o.__extends)(t,e),t}(l),Er=function(){function e(e){this._mutationObserver=e}return e.prototype.ensurePresence=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=new Ir(t),(r=this._mutationObserver.create((function(t){t.forEach((function(t){0!==Array.from(t.removedNodes).filter((function(t){return e.some((function(e){return t===e||t.contains(e)}))})).length&&n.cancel(new wr)}))}))).observe(document.body,{childList:!0,subtree:!0}),o.label=1;case 1:return o.trys.push([1,3,,4]),[4,n.promise];case 2:return i=o.sent(),r.disconnect(),[2,i];case 3:throw a=o.sent(),r.disconnect(),a;case 4:return[2]}}))}))},e}();var br=function(){function e(e){void 0===e&&(e=window),this._window=e}return e.prototype.create=function(e){return new this._window.MutationObserver(e)},e}();const Pr=function(e){function t(t){var n=e.call(this,t||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return(0,o.__extends)(t,e),t}(l);function Ar(e){if(!/^(https?:)?\/\//.test(e))throw new Pr("The provided URL must be absolute.");var t=document.createElement("a");t.href=e;var n=t.port&&-1!==e.indexOf(t.hostname+":"+t.port)?t.port:"";return{hash:t.hash,hostname:t.hostname,href:t.href,origin:t.protocol+"//"+t.hostname+(n?":"+n:""),pathname:t.pathname,port:n,protocol:t.protocol,search:t.search}}function Tr(e,t){return e.type===t}const Or=function(){function e(e,t,n){this._targetWindow=t,this._context=n,this._targetOrigin="*"===e?"*":Ar(e).origin}return e.prototype.post=function(e,t){var n=this,r=this._targetWindow;if(window!==r){if(!r)throw new Error("Unable to post message because target window is not set.");var i=t&&(0,S.fromEvent)(window,"message").pipe((0,I.filter)((function(e){return e.origin===n._targetOrigin&&Tr(e.data,e.data.type)&&-1!==[t.successType,t.errorType].indexOf(e.data.type)})),(0,I.map)((function(e){if(t.errorType===e.data.type)throw e.data;return e.data})),(0,I.take)(1)).toPromise();return r.postMessage((0,o.__assign)((0,o.__assign)({},e),{context:this._context}),this._targetOrigin),i}},e.prototype.setTarget=function(e){this._targetWindow=e},e.prototype.setContext=function(e){this._context=e},e}(),Rr=function(e,t,n){return t&&n?Mr(0,t,n):function(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,o.__extends)(t,e),t}(e);return Object.getOwnPropertyNames(e.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Mr(e.prototype,n,r))})),t}(e)};function Mr(e,t,n){if("function"!=typeof n.value)return n;var r=n.value;return{get:function(){var e=r.bind(this);return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:e})),e},set:function(e){r=e}}}const kr=function(){function e(e){var t;this._sourceOrigins=[Ar(e).origin,(t=Ar(e),Ar(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,"www."+t.hostname))).origin],this._isListening=!1,this._listeners={}}return e.prototype.listen=function(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))},e.prototype.stopListen=function(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))},e.prototype.addListener=function(e,t){var n=this._listeners[e];n||(this._listeners[e]=n=[]),-1===n.indexOf(t)&&n.push(t)},e.prototype.removeListener=function(e,t){var n=this._listeners[e];if(n){var r=n.indexOf(t);r>=0&&n.splice(r,1)}},e.prototype.trigger=function(e,t){var n=this._listeners[e.type];n&&n.forEach((function(n){return t?n(e,t):n(e)}))},e.prototype._handleMessage=function(e){if(-1!==this._sourceOrigins.indexOf(e.origin)&&Tr(e.data,e.data.type)){var t=e.data,n=t.context,r=(0,o.__rest)(t,["context"]);this.trigger(r,n)}},(0,o.__decorate)([Rr],e.prototype,"_handleMessage",null),e}(),Dr=function(e){function t(){var t=e.call(this,"You haven't complete our spam protection challenge. Please try again.")||this;return t.name="SpamProtectionChallengeNotCompletedError",t.type="spam_protection_challenge_not_completed",t}return(0,o.__extends)(t,e),t}(l),Nr=function(e){function t(){var t=e.call(this,"Please complete our human verification challenge and try again.")||this;return t.name="CardingProtectionChallengeNotCompletedError",t.type="carding_protection_challenge_not_completed",t}return(0,o.__extends)(t,e),t}(l),Lr=function(e){function t(){var t=e.call(this,"We were not able to verify that you are not a robot. Please try again.")||this;return t.name="CardingProtectionFailedError",t.type="carding_protection_failed",t}return(0,o.__extends)(t,e),t}(l),zr=function(){function e(e){this._googleRecaptcha=e}return e.prototype.handle=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return"string"==typeof e?[2,this.handleWithRecaptchaSitekey(e,t)]:[2,this.handleWithPaymentHumanVerificationRequestError(e)]}))}))},e.prototype.handleWithPaymentHumanVerificationRequestError=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!this._isPaymentHumanVerificationRequest(e))throw e;return[4,this._initialize(e.body.additional_action_required.data.key)];case 1:return t.sent(),[2,this._performRecaptcha()]}}))}))},e.prototype.handleWithRecaptchaSitekey=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("recaptcha_v2"!==e)throw Error("Human verification method is not supported.");if(!t)throw Error("Recaptcha site key is missing.");return[4,this._initialize(t)];case 1:return n.sent(),[2,this._performRecaptcha()]}}))}))},e.prototype._performRecaptcha=function(){var e=this;return this._googleRecaptcha.execute().pipe((0,I.take)(1)).pipe((0,I.switchMap)((function(t){var n=t.error,r=t.token;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){if(n instanceof Dr)throw new Nr;if(n||!r)throw new Lr;return[2,{type:"recaptcha_v2_verification",data:{human_verification_token:r}}]}))}))}))).toPromise()},e.prototype._initialize=function(e){var t="cardingProtectionContainer",n=document.getElementById(t);return n&&n.parentNode&&n.parentNode.removeChild(n),(n=document.createElement("div")).setAttribute("id",t),document.body.appendChild(n),this._googleRecaptcha.load(t,e)},e.prototype._isPaymentHumanVerificationRequest=function(e){var t=e.body||{},n=t.additional_action_required;return"additional_action_required"===t.status&&n&&"recaptcha_v2_verification"===n.type},e}();var Fr;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(Fr||(Fr={}));const Ur=function(e){function t(t){var n=e.call(this,function(e){switch(e){case Fr.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case Fr.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case Fr.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case Fr.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(t))||this;return n.subtype=t,n.name="NotInitializedError",n.type="not_initialized",n}return(0,o.__extends)(t,e),t}(l),qr=function(e){function t(){var t=e.call(this,"We were not able to complete your spam protection verification. Please try again.")||this;return t.name="SpamProtectionFailedError",t.type="spam_protection_failed",t}return(0,o.__extends)(t,e),t}(l),Br=function(e){function t(){var t=e.call(this,"Spam protection is not loaded. Please try again.")||this;return t.name="SpamProtectionNotLoadedError",t.type="spam_protection_failed",t}return(0,o.__extends)(t,e),t}(l),Gr=function(){function e(e,t){var n=this;this.googleRecaptchaScriptLoader=e,this.mutationObserverFactory=t,this._memoized=(0,On.memoize)((function(e,t,r){var i=new S.Subject;if(!r)throw new Error;return n._widgetId=e.render(r.id,{sitekey:t,size:"invisible",callback:function(){i.next({token:e.getResponse(n._widgetId)}),e.reset(n._widgetId)},"error-callback":function(){i.next({error:new qr})}}),i}),{isEqual:function(e,t){return e===t}})}return e.prototype.load=function(e,t){var n=this;return this.googleRecaptchaScriptLoader.load().then((function(r){r&&(n._event$=n._memoized(r,t,document.getElementById(e)),n._recaptcha=r)}))},e.prototype.execute=function(){var e=this;return(0,S.defer)((function(){var t=e._event$,n=e._recaptcha;if(!t||!n)throw new Ur(Fr.SpamProtectionNotInitialized);return(0,S.defer)((function(){var e=document.querySelector('iframe[src*="bframe"]');return e?(0,S.of)(e):(0,S.throwError)(new Br)})).pipe((0,I.retryWhen)((function(e){return e.pipe((0,I.delay)(250),(0,I.switchMap)((function(e,t){return t<28?(0,S.of)(e):(0,S.throwError)(e)})))})),(0,I.switchMap)((function(r){return e._watchRecaptchaChallengeWindow(t,r),n.execute(e._widgetId),t})),(0,I.catchError)((function(e){return(0,S.of)({error:e})})))}))},e.prototype._watchRecaptchaChallengeWindow=function(e,t){var n=t.parentElement;if(!n)throw new Br;var r=n.parentElement;if(!r)throw new Br;this.mutationObserverFactory.create((function(){"hidden"===r.style.visibility&&e.next({error:new Dr})})).observe(r,{attributes:!0,attributeFilter:["style"]})},e}(),xr=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(){return this._loadPromise||(this._loadPromise=this._loadScript()),this._loadPromise},e.prototype._loadScript=function(){var e=this,t="initRecaptcha",n=["onload="+t,"render=explicit"].join("&");return new Promise((function(r,i){e._window[t]=function(){return r(e._window.grecaptcha)},e._scriptLoader.loadScript("//www.google.com/recaptcha/api.js?"+n).catch((function(t){e._loadPromise=void 0,i(t)}))}))},e}();function Yr(e){return new Gr(new xr(e),new br)}const Vr=function(e){function t(t){var n=e.call(this,t||"Unable to proceed due to invalid configuration provided for the hosted payment form.")||this;return n.name="InvalidHostedFormConfigError",n.type="invalid_hosted_form_config",n}return(0,o.__extends)(t,e),t}(l),Hr=function(e){function t(t){var n=e.call(this,t||"Unable to proceed due to an unknown error with the hosted payment form.")||this;return n.name="InvalidHostedFormError",n.type="invalid_hosted_form",n}return(0,o.__extends)(t,e),t}(l),jr=function(e){function t(t){var n=e.call(this,(0,o.__spreadArrays)(["Unable to proceed due to invalid user input values"],(0,m.flatMap)((0,m.values)(t),(function(e){return(0,m.map)(e,(function(e){return e.message}))}))).join(". "))||this;return n.errors=t,n.name="InvalidHostedFormValueError",n.type="invalid_hosted_form_value",n}return(0,o.__extends)(t,e),t}(l);var Wr,Kr;!function(e){e.AttachRequested="HOSTED_FIELD:ATTACH_REQUESTED",e.SubmitRequested="HOSTED_FIELD:SUBMITTED_REQUESTED",e.ValidateRequested="HOSTED_FIELD:VALIDATE_REQUESTED",e.StoredCardRequested="HOSTED_FIELD:STORED_CARD_REQUESTED"}(Wr||(Wr={})),function(e){e.AttachSucceeded="HOSTED_INPUT:ATTACH_SUCCEEDED",e.AttachFailed="HOSTED_INPUT:ATTACH_FAILED",e.BinChanged="HOSTED_INPUT:BIN_CHANGED",e.Blurred="HOSTED_INPUT:BLURRED",e.Changed="HOSTED_INPUT:CHANGED",e.CardTypeChanged="HOSTED_INPUT:CARD_TYPE_CHANGED",e.Entered="HOSTED_INPUT:ENTERED",e.Focused="HOSTED_INPUT:FOCUSED",e.SubmitSucceeded="HOSTED_INPUT:SUBMIT_SUCCEEDED",e.SubmitFailed="HOSTED_INPUT:SUBMIT_FAILED",e.Validated="HOSTED_INPUT:VALIDATED",e.StoredCardSucceeded="HOSTED_INPUT:STORED_CARD_SUCCEEDED",e.StoredCardFailed="HOSTED_INPUT:STORED_CARD_FAILED"}(Kr||(Kr={}));const Jr=function(){function e(e,t,n,r,i,o,a,s,u){this._type=e,this._containerId=t,this._placeholder=n,this._accessibilityLabel=r,this._styles=i,this._eventPoster=o,this._eventListener=a,this._detachmentObserver=s,this._cardInstrument=u,this._iframe=document.createElement("iframe"),this._iframe.src="/checkout/payment/hosted-field?version=1.589.1",this._iframe.style.border="none",this._iframe.style.height="100%",this._iframe.style.overflow="hidden",this._iframe.style.width="100%"}return e.prototype.getType=function(){return this._type},e.prototype.attach=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n=this;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:if(!(e=document.getElementById(this._containerId)))throw new Vr("Unable to proceed because the provided container ID is not valid.");return e.appendChild(this._iframe),this._eventListener.listen(),t=(0,S.fromEvent)(this._iframe,"load").pipe((0,I.switchMap)((function(e){var t=e.target;return(0,o.__awaiter)(n,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!(e=t&&t.contentWindow))throw new Error("The content window of the iframe cannot be accessed.");return this._eventPoster.setTarget(e),[4,this._eventPoster.post({type:Wr.AttachRequested,payload:{accessibilityLabel:this._accessibilityLabel,cardInstrument:this._cardInstrument,fontUrls:this._getFontUrls(),placeholder:this._placeholder,styles:this._styles,origin:document.location.origin,type:this._type}},{successType:Kr.AttachSucceeded,errorType:Kr.AttachFailed})];case 1:return n.sent(),[2]}}))}))})),(0,I.take)(1)).toPromise(),[4,this._detachmentObserver.ensurePresence([this._iframe],t)];case 1:return r.sent(),[2]}}))}))},e.prototype.detach=function(){this._iframe.parentElement&&(this._iframe.parentElement.removeChild(this._iframe),this._eventListener.stopListen())},e.prototype.submitForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),n=this._eventPoster.post({type:Wr.SubmitRequested,payload:{fields:e,data:t}},{successType:Kr.SubmitSucceeded,errorType:Kr.SubmitFailed}),[4,this._detachmentObserver.ensurePresence([this._iframe],n)];case 1:return[2,i.sent()];case 2:if(r=i.sent(),this._isSubmitErrorEvent(r)){if("hosted_form_error"===r.payload.error.code)throw new Hr(r.payload.error.message);if(r.payload.response)throw y(r.payload.response);throw new Error(r.payload.error.message)}throw r;case 3:return[2]}}))}))},e.prototype.submitStoredCardForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){return n=this._eventPoster.post({type:Wr.StoredCardRequested,payload:{fields:e,data:t}},{successType:Kr.StoredCardSucceeded,errorType:Kr.StoredCardFailed}),[2,this._detachmentObserver.ensurePresence([this._iframe],n)]}))}))},e.prototype.validateForm=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e=this._eventPoster.post({type:Wr.ValidateRequested},{successType:Kr.Validated}),[4,this._detachmentObserver.ensurePresence([this._iframe],e)];case 1:if(!(t=n.sent().payload).isValid)throw new jr(t.errors);return[2]}}))}))},e.prototype._getFontUrls=function(){var e=this,t="fonts.googleapis.com",n=document.querySelectorAll("link[href*='"+t+"'][rel='stylesheet']");return Array.prototype.slice.call(n).filter((function(e){return Ar(e.href).hostname===t})).filter((function(t){return(0,m.values)(e._styles).map((function(e){return e&&e.fontFamily})).filter((function(e){return"string"==typeof e})).some((function(e){return e.split(/,\s/).some((function(e){return-1!==t.href.indexOf(e.replace(" ","+"))}))}))})).map((function(e){return e.href}))},e.prototype._isSubmitErrorEvent=function(e){return e.type===Kr.SubmitFailed},e}(),Zr=function(){function e(e,t,n,r,i){var a=this;this._fields=e,this._eventListener=t,this._payloadTransformer=n,this._eventCallbacks=r,this._paymentHumanVerificationHandler=i,this._handleEnter=function(e){var t=e.payload;return(0,o.__awaiter)(a,void 0,void 0,(function(){var e,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this.validate()];case 1:return r.sent(),[3,3];case 2:if("InvalidHostedFormValueError"!==(e=r.sent()).name)throw e;return[3,3];case 3:return(void 0===(n=this._eventCallbacks.onEnter)?m.noop:n)(t),[2]}}))}))};var s=this._eventCallbacks,u=s.onBlur,c=void 0===u?m.noop:u,d=s.onCardTypeChange,l=void 0===d?m.noop:d,p=s.onFocus,h=void 0===p?m.noop:p,f=s.onValidate,g=void 0===f?m.noop:f;this._eventListener.addListener(Kr.Blurred,(function(e){var t=e.payload;return c(t)})),this._eventListener.addListener(Kr.CardTypeChanged,(function(e){var t=e.payload;return l(t)})),this._eventListener.addListener(Kr.Focused,(function(e){var t=e.payload;return h(t)})),this._eventListener.addListener(Kr.Validated,(function(e){var t=e.payload;return g(t)})),this._eventListener.addListener(Kr.Entered,this._handleEnter),this._eventListener.addListener(Kr.CardTypeChanged,(function(e){var t=e.payload;return a._cardType=t.cardType})),this._eventListener.addListener(Kr.BinChanged,(function(e){var t=e.payload;return a._bin=t.bin}))}return e.prototype.getBin=function(){return this._bin},e.prototype.getCardType=function(){return this._cardType},e.prototype.attach=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this._eventListener.listen(),e=this._getFirstField(),t=(0,m.without)(this._fields,e),[4,e.attach()];case 1:return n.sent(),[4,Promise.all(t.map((function(e){return e.attach()})))];case 2:return n.sent(),[2]}}))}))},e.prototype.detach=function(){this._eventListener.stopListen(),this._fields.forEach((function(e){e.detach()}))},e.prototype.submit=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this._getFirstField().submitForm(this._fields.map((function(e){return e.getType()})),this._payloadTransformer.transform(e,t))];case 1:case 4:return[2,i.sent()];case 2:return n=i.sent(),[4,this._paymentHumanVerificationHandler.handle(n)];case 3:return r=i.sent(),[4,this._getFirstField().submitForm(this._fields.map((function(e){return e.getType()})),this._payloadTransformer.transform(e,r))];case 5:return[2]}}))}))},e.prototype.submitStoredCard=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._getFirstField().submitStoredCardForm(e.fields,e.data)]}))}))},e.prototype.validate=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this._getFirstField().validateForm()]}))}))},e.prototype._getFirstField=function(){var e=this._fields[0];if(!e)throw new Vr("Unable to proceed because the payment form has no field defined.");return e},e}();function Qr(e){return Boolean(e.instrumentId)}const Xr=function(){function e(e){this._store=e}return e.prototype.transform=function(e,t){var n=this._store.getState(),r=n.checkout.getCheckout(),i=n.config.getConfig(),o=n.instruments.getInstrumentsMeta(),a=n.order.getOrder(),s=n.order.getOrderMeta(),u=(0,m.omit)(e.paymentData,"ccExpiry","ccName","ccNumber","ccCvv"),c=n.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),d=n.paymentMethods.getPaymentMethodsMeta(),l=o&&u&&Qr(u)?n.payment.getPaymentToken()+", "+o.vaultAccessToken:n.payment.getPaymentToken();if(!l)throw new Mn(Rn.MissingPaymentToken);return{additionalAction:t,authToken:l,checkout:r,config:i,order:a,orderMeta:s,payment:u,paymentMethod:c,paymentMethodMeta:d}},e}(),$r=function(){function e(e){this._store=e}return e.prototype.create=function(e,t){var n=this,r=Object.keys(t.fields).reduce((function(r,i){var a=t.fields[i];return a?(0,o.__spreadArrays)(r,[new Jr(i,a.containerId,a.placeholder||"",a.accessibilityLabel||"",t.styles||{},new Or(e),new kr(e),new Er(new br),"instrumentId"in a?n._getCardInstrument(a.instrumentId):void 0)]):r}),[]);return new Zr(r,new kr(e),new Xr(this._store),(0,m.pick)(t,"onBlur","onEnter","onFocus","onCardTypeChange","onValidate"),new zr(Yr((0,$n.createScriptLoader)())))},e.prototype._getCardInstrument=function(e){var t=(0,this._store.getState().instruments.getCardInstrument)(e);if(!t)throw new Mn(Rn.MissingPaymentInstrument);return t},e}(),ei=function(e){function t(){var t=e.call(this,"You haven't complete our spam check. Please try again.")||this;return t.name="SpamProtectionNotCompletedError",t.type="spam_protection_not_completed",t}return(0,o.__extends)(t,e),t}(l),ti=function(){function e(e,t){this._orderRequestSender=e,this._checkoutValidator=t}return e.prototype.loadOrder=function(e,t){var n=this;return new S.Observable((function(r){r.next((0,a.createAction)(ie.LoadOrderRequested)),n._orderRequestSender.loadOrder(e,t).then((function(e){r.next((0,a.createAction)(ie.LoadOrderSucceeded,e.body)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(ie.LoadOrderFailed,e))}))}))},e.prototype.loadOrderPayments=function(e,t){var n=this;return new S.Observable((function(r){r.next((0,a.createAction)(ie.LoadOrderPaymentsRequested)),n._orderRequestSender.loadOrder(e,t).then((function(e){r.next((0,a.createAction)(ie.LoadOrderPaymentsSucceeded,e.body)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(ie.LoadOrderPaymentsFailed,e))}))}))},e.prototype.loadCurrentOrder=function(e){var t=this;return function(n){return(0,S.defer)((function(){var r=t._getCurrentOrderId(n.getState());if(!r)throw new Mn(Rn.MissingOrderId);return t.loadOrder(r,e)}))}},e.prototype.submitOrder=function(e,t){var n=this;return function(r){return(0,S.concat)((0,S.of)((0,a.createAction)(ie.SubmitOrderRequested)),(0,S.defer)((function(){var i=r.getState(),s=i.config.getExternalSource(),u=i.config.getVariantIdentificationToken(),c=i.checkout.getCheckout();if(!c)throw new Mn(Rn.MissingCheckout);if(c.shouldExecuteSpamCheck)throw new ei;return(0,S.from)(n._checkoutValidator.validate(c,t).then((function(){return n._orderRequestSender.submitOrder(n._mapToOrderRequestBody(null!=e?e:{},c.id,c.customerMessage,s),(0,o.__assign)((0,o.__assign)({},t),{headers:{checkoutVariant:u}}))}))).pipe((0,I.switchMap)((function(e){return(0,S.concat)(n.loadOrder(e.body.data.order.orderId,t),(0,S.of)((0,a.createAction)(ie.SubmitOrderSucceeded,e.body.data,(0,o.__assign)((0,o.__assign)({},e.body.meta),{token:e.headers.token}))))})))})).pipe((0,I.catchError)((function(e){return er(ie.SubmitOrderFailed,e)}))))}},e.prototype.finalizeOrder=function(e,t){var n=this;return(0,S.concat)((0,S.of)((0,a.createAction)(ie.FinalizeOrderRequested)),(0,S.from)(this._orderRequestSender.finalizeOrder(e,t)).pipe((0,I.switchMap)((function(r){return(0,S.concat)(n.loadOrder(e,t),(0,S.of)((0,a.createAction)(ie.FinalizeOrderSucceeded,r.body.data)))})))).pipe((0,I.catchError)((function(e){return er(ie.FinalizeOrderFailed,e)})))},e.prototype._getCurrentOrderId=function(e){var t=e.order.getOrder(),n=e.checkout.getCheckout();return t&&t.orderId||n&&n.orderId},e.prototype._mapToOrderRequestBody=function(e,t,n,r){var i=e.payment,a=(0,o.__rest)(e,["payment"]);return i?(0,o.__assign)((0,o.__assign)({},a),{cartId:t,customerMessage:n,externalSource:r,payment:{paymentData:i.paymentData,name:i.methodId,gateway:i.gatewayId}}):(0,o.__assign)((0,o.__assign)({},a),{cartId:t,customerMessage:n,externalSource:r})},e}(),ni=function(e){function t(t){var n=e.call(this,t||"Your checkout could not be processed because some details have changed. Please review your order and try again.")||this;return n.name="CartConsistencyError",n.type="cart_consistency",n}return(0,o.__extends)(t,e),t}(l),ri=function(e){function t(t){var n=e.call(this,t||"The tax provider is unavailable.")||this;return n.name="OrderTaxProviderUnavailableError",n.type="tax_provider_unavailable",n}return(0,o.__extends)(t,e),t}(l),ii=function(){function e(e){this._requestSender=e}return e.prototype.loadOrder=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/orders/"+e,i=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.get(r,{params:{include:sr(["payments","lineItems.physicalItems.socialMedia","lineItems.physicalItems.options","lineItems.physicalItems.categories","lineItems.digitalItems.socialMedia","lineItems.digitalItems.options","lineItems.digitalItems.categories"])},headers:i,timeout:n})},e.prototype.submitOrder=function(e,t){var n=void 0===t?{}:t,r=n.headers,i=n.timeout;return this._requestSender.post("/internalapi/v1/checkout/order",{body:e,headers:(0,m.omitBy)((0,o.__assign)({"X-Checkout-Variant":r&&r.checkoutVariant},Qn),m.isNil),timeout:i}).catch((function(e){if("tax_provider_unavailable"===e.body.type)throw new ri;if("cart_has_changed"===e.body.type)throw new ni;throw e}))},e.prototype.finalizeOrder=function(e,t){var n=(void 0===t?{}:t).timeout,r="/internalapi/v1/checkout/order/"+e;return this._requestSender.post(r,{timeout:n,headers:Qn})},e}(),oi=function(){function e(e,t,n,r){var i=this;this._paymentRequestSender=e,this._orderActionCreator=t,this._paymentRequestTransformer=n,this._paymentHumanVerificationHandler=r,this.initializeOffsitePayment=function(e){var t=e.methodId,n=e.gatewayId,r=e.instrumentId,o=e.target,s=e.promise,u=e.shouldSaveInstrument,c=e.shouldSetAsDefaultInstrument;return function(e){var d;r?d={formattedPayload:{bigpay_token:r}}:u&&(d={formattedPayload:{vault_payment_instrument:u,set_as_default_stored_instrument:c||null}});var l=i._paymentRequestTransformer.transform({gatewayId:n,methodId:t,paymentData:d},e.getState());return(0,S.concat)((0,S.of)((0,a.createAction)(nt.InitializeOffsitePaymentRequested)),Promise.race([i._paymentRequestSender.initializeOffsitePayment(l,o),s].filter(Boolean)).then((function(){return(0,a.createAction)(nt.InitializeOffsitePaymentSucceeded)}))).pipe((0,I.catchError)((function(e){return er(nt.InitializeOffsitePaymentFailed,e)})))}}}return e.prototype.submitPayment=function(e){var t=this;return function(n){return(0,S.concat)((0,S.of)((0,a.createAction)(nt.SubmitPaymentRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,5]),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(e,n.getState()))];case 1:case 4:return[2,i.sent()];case 2:return t=i.sent(),[4,this._paymentHumanVerificationHandler.handle(t)];case 3:return r=i.sent(),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform((0,o.__assign)((0,o.__assign)({},e),{additionalAction:r}),n.getState()))];case 5:return[2]}}))}))})).pipe((0,I.switchMap)((function(e){var r=e.body;return(0,S.concat)(t._orderActionCreator.loadCurrentOrder()(n),(0,S.of)((0,a.createAction)(nt.SubmitPaymentSucceeded,r)))})))).pipe((0,I.catchError)((function(e){return er(nt.SubmitPaymentFailed,e)})))}},e}(),ai=function(){function e(e){this._client=e}return e.prototype.submitPayment=function(e){var t=this;return new Promise((function(n,r){t._client.submitPayment(e,(function(e,i){e?r(t._transformResponse(e)):n(t._transformResponse(i))}))}))},e.prototype.initializeOffsitePayment=function(e,t){var n=this;return new Promise((function(){n._client.initializeOffsitePayment(e,null,t)}))},e.prototype._transformResponse=function(e){return{headers:e.headers,body:e.data,status:e.status,statusText:e.statusText}},e}(),si=require("@bigcommerce/bigpay-client");function ui(e,t){var n;return function(e){return void 0!==e.id}(e)?n=e.id:t&&t.length&&(n=t[0].id),{id:n,firstName:e.firstName,lastName:e.lastName,company:e.company,addressLine1:e.address1,addressLine2:e.address2,city:e.city,province:e.stateOrProvince,provinceCode:e.stateOrProvinceCode,postCode:e.postalCode,country:e.country,countryCode:e.countryCode,phone:e.phone,customFields:e.customFields}}const ci=function(){function e(e){this._decimalPlaces=e}return e.prototype.toInteger=function(e){return Math.round(e*Math.pow(10,this._decimalPlaces))},e}();var di,li=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function pi(e){return{code:e.code,discount:e.displayName,discountType:li.indexOf(e.couponType)}}function hi(e){return{code:e.code,discountedAmount:e.used,remainingBalance:e.remaining,giftCertificate:{balance:e.balance,code:e.code,purchaseDate:e.purchaseDate}}}function fi(e,t,n){return void 0===n&&(n="id"),Object.keys(e).reduce((function(r,i){return(0,o.__spreadArrays)(r,e[i].map((function(e){return"giftCertificates"===i?function(e,t){var n=new ci(t);return{id:e.id,imageUrl:"",name:e.name,amount:e.amount,amountAfterDiscount:e.amount,discount:0,integerAmount:n.toInteger(e.amount),integerAmountAfterDiscount:n.toInteger(e.amount),integerUnitPrice:n.toInteger(e.amount),integerUnitPriceAfterDiscount:n.toInteger(e.amount),integerDiscount:0,quantity:1,sender:e.sender,recipient:e.recipient,type:"ItemGiftCertificateEntity",attributes:[],variantId:null}}(e,t):function(e,t,n,r){void 0===r&&(r="id");var i=new ci(n);return{id:e[r],imageUrl:e.imageUrl,amount:e.extendedListPrice,amountAfterDiscount:e.extendedSalePrice,discount:e.discountAmount,integerAmount:i.toInteger(e.extendedListPrice),integerAmountAfterDiscount:i.toInteger(e.extendedSalePrice),integerDiscount:i.toInteger(e.discountAmount),integerUnitPrice:i.toInteger(e.listPrice),integerUnitPriceAfterDiscount:i.toInteger(e.salePrice),downloadsPageUrl:e.downloadPageUrl,name:e.name,quantity:e.quantity,brand:e.brand,sku:e.sku,categoryNames:e.categoryNames,variantId:e.variantId,productId:e.productId,attributes:(e.options||[]).map((function(e){return{name:e.name,value:e.value}})),addedByPromotion:e.addedByPromotion,type:t}}(e,function(e){switch(e){case"physicalItems":return"ItemPhysicalEntity";case"digitalItems":return"ItemDigitalEntity";case"giftCertificates":return"ItemGiftCertificateEntity";default:return""}}(i),t,n)})))}),[])}function mi(e){var t,n,r=e.cart.currency.decimalPlaces,i=new ci(r);return{id:e.cart.id,items:fi(e.cart.lineItems,r),currency:e.cart.currency.code,coupon:{discountedAmount:(0,m.reduce)(e.cart.coupons,(function(e,t){return e+t.discountedAmount}),0),coupons:e.cart.coupons.map(pi)},discount:{amount:e.cart.discountAmount,integerAmount:i.toInteger(e.cart.discountAmount)},discountNotifications:(t=e.promotions,n=[],(t||[]).forEach((function(e){(e.banners||[]).forEach((function(e){n.push({placeholders:[],discountType:null,message:"",messageHtml:e.text})}))})),n),giftCertificate:{totalDiscountedAmount:(0,m.reduce)(e.giftCertificates,(function(e,t){return e+t.used}),0),appliedGiftCertificates:(0,m.keyBy)(e.giftCertificates.map(hi),"code")},shipping:{amount:e.shippingCostTotal,integerAmount:i.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(e.shippingCostBeforeDiscount),required:(0,m.some)(e.cart.lineItems.physicalItems,(function(e){return e.isShippingRequired}))},subtotal:{amount:e.subtotal,integerAmount:i.toInteger(e.subtotal)},storeCredit:{amount:e.customer?e.customer.storeCredit:0},taxSubtotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:i.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.grandTotal,integerAmount:i.toInteger(e.grandTotal)}}}!function(e){e.APPLEPAY="applepay",e.AMAZON_PAY_V2="amazonpay",e.BRAINTREE_PAYPAL="braintreepaypal",e.BRAINTREE_VENMO="braintreevenmo",e.BRAINTREE_PAYPAL_CREDIT="braintreepaypalcredit",e.GOOGLEPAY_ADYENV2="googlepayadyenv2",e.GOOGLEPAY_ADYENV3="googlepayadyenv3",e.GOOGLEPAY_AUTHORIZENET="googlepayauthorizenet",e.GOOGLEPAY_BNZ="googlepaybnz",e.GOOGLEPAY_BRAINTREE="googlepaybraintree",e.GOOGLEPAY_CHECKOUTCOM="googlepaycheckoutcom",e.GOOGLEPAY_CYBERSOURCEV2="googlepaycybersourcev2",e.GOOGLEPAY_ORBITAL="googlepayorbital",e.GOOGLEPAY_STRIPE="googlepaystripe",e.GOOGLEPAY_STRIPEUPE="googlepaystripeupe",e.GOOGLEPAY_WORLDPAYACCESS="googlepayworldpayaccess",e.MASTERPASS="masterpass",e.PAYPALEXPRESS="paypalexpress"}(di||(di={}));const gi=di;function yi(e,t){var n=e.firstName||t.firstName||"",r=e.lastName||t.lastName||"";return{addresses:(e.addresses||[]).map((function(e){return ui(e)})),customerId:e.id,isGuest:e.isGuest,storeCredit:e.storeCredit,email:e.email||t.email||"",firstName:n,lastName:r,name:e.fullName||[n,r].join(" "),customerGroupName:e.customerGroup&&e.customerGroup.name}}const _i=function(){function e(){}return e.prototype.format=function(e){var t=e.split(new RegExp("\\s*/\\s*")),n=t[0],r=void 0===n?"":n,i=t[1],o=void 0===i?"":i,a=r.slice(0,2),s=4===o.length?o.slice(-2):o?o.slice(0,2):r.slice(2);return e.length<2?r:e.length>3&&!s?a:a+" / "+s},e.prototype.toObject=function(e){var t=e.split(new RegExp("\\s*/\\s*")),n=t[0],r=void 0===n?"":n,i=t[1],o=void 0===i?"":i;return/^\d+$/.test(r)&&/^\d+$/.test(o)?{month:1===r.length?"0"+r:r.slice(0,2),year:2===o.length?"20"+o:o.slice(0,4)}:{month:"",year:""}},e}(),vi=require("card-validator"),Ci=function(){function e(){}return e.prototype.format=function(e){var t=(0,vi.number)(e).card;if(!t)return e;var n=(0,m.max)((0,vi.creditCardType)(e).map((function(e){return(0,m.max)(e.lengths)}))),r=this.unformat(e).slice(0,n);return t.gaps.filter((function(e){return r.length>e})).reduce((function(e,t,n){return[e.slice(0,t+n),e.slice(t+n)].join(" ")}),r)},e.prototype.unformat=function(e){return(0,vi.number)(e).card?e.replace(new RegExp(" ","g"),""):e},e}();function Si(e,t){void 0===t&&(t={});var n,r,i=e.currency.decimalPlaces,o=new ci(i);return{id:e.orderId,items:fi(e.lineItems,e.currency.decimalPlaces,"productId"),orderId:e.orderId,currency:e.currency.code,customerCanBeCreated:e.customerCanBeCreated,payment:wi(e.payments,t.payment),subtotal:{amount:e.baseAmount,integerAmount:o.toInteger(e.baseAmount)},coupon:{discountedAmount:(0,m.reduce)(e.coupons,(function(e,t){return e+t.discountedAmount}),0),coupons:e.coupons.map(pi)},discount:{amount:e.discountAmount,integerAmount:o.toInteger(e.discountAmount)},token:t.orderToken,callbackUrl:t.callbackUrl,discountNotifications:[],giftCertificate:(n=e.payments,r=(0,m.filter)(n,{providerId:"giftcertificate"}),{totalDiscountedAmount:(0,m.reduce)(r,(function(e,t){return t.amount+e}),0),appliedGiftCertificates:(0,m.keyBy)(r.map((function(e){return{code:e.detail.code,discountedAmount:e.amount,remainingBalance:e.detail.remaining,giftCertificate:{balance:e.amount+e.detail.remaining,code:e.detail.code,purchaseDate:""}}})),"code")}),socialData:bi(e),status:e.status,hasDigitalItems:e.hasDigitalItems,isDownloadable:e.isDownloadable,isComplete:e.isComplete,shipping:{amount:e.shippingCostTotal,integerAmount:o.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:o.toInteger(e.shippingCostBeforeDiscount)},storeCredit:{amount:Ii(e.payments)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:o.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:o.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.orderAmount,integerAmount:e.orderAmountAsInteger}}}function Ii(e){var t=(0,m.find)(e,{providerId:"storecredit"});return t?t.amount:0}function wi(e,t){void 0===t&&(t={});var n,r=(0,m.find)(e,Ei);return r?{id:r.providerId,status:(n=r.detail.step,"PAYMENT_STATUS_"+n),helpText:r.detail.instructions,returnUrl:t.returnUrl}:{}}function Ei(e){return"giftcertificate"!==e.providerId&&"storecredit"!==e.providerId}function bi(e){var t={};return(0,o.__spreadArrays)(e.lineItems.physicalItems,e.lineItems.digitalItems).forEach((function(e){var n;t[e.id]=(n=e,["fb","tw","gp"].reduce((function(e,t){var r=n.socialMedia&&(0,m.find)(n.socialMedia,(function(e){return e.code===t}));return r?(e[t]={name:n.name,description:n.name,image:n.imageUrl,url:r.link,shareText:r.text,sharingLink:r.link,channelName:r.channel,channelCode:r.code},e):e}),{}))})),t}function Pi(e,t){return{description:e.description,module:e.type,price:e.cost,id:e.id,selected:t,isRecommended:e.isRecommended,imageUrl:e.imageUrl,transitTime:e.transitTime}}const Ai=function(){function e(){this._cardExpiryFormatter=new _i,this._cardNumberFormatter=new Ci}return e.prototype.transform=function(e,t){var n,r=t.billingAddress.getBillingAddress(),i=t.checkout.getCheckout(),a=t.customer.getCustomer(),s=t.order.getOrder(),u=t.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),c=this._mapShippingAddress(t,u),d=t.consignments.getConsignments(),l=t.consignments.getShippingOption(),p=t.config.getStoreConfig(),h=t.config.getContextConfig(),f=t.instruments.getInstrumentsMeta(),g=t.paymentMethods.getPaymentMethodsMeta(),y=t.order.getOrderMeta(),_=a&&r&&yi(a,r),v=f&&e.paymentData&&(Qr(e.paymentData)||(n=e.paymentData.formattedPayload)&&("string"==typeof n.bigpay_token||Boolean(n.bigpay_token&&n.bigpay_token.token)))?t.payment.getPaymentToken()+", "+f.vaultAccessToken:t.payment.getPaymentToken();if(!v)throw new Mn(Rn.MissingPaymentToken);return{additionalAction:e.additionalAction,authToken:v,customer:_,billingAddress:r&&ui(r),shippingAddress:c&&ui(c,d),shippingOption:l&&Pi(l,!0),cart:i&&mi(i),order:s&&Si(s,y),orderMeta:y,payment:e.paymentData,paymentMethod:u&&this._transformPaymentMethod(u),quoteMeta:{request:(0,o.__assign)((0,o.__assign)({},g),{geoCountryCode:h&&h.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:(0,m.pick)(p&&p.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},e.prototype.transformWithHostedFormData=function(e,t,n){var r=t.additionalAction,i=t.authToken,a=t.checkout,s=t.config,u=t.order,c=t.orderMeta,d=t.payment,l=void 0===d?{}:d,p=t.paymentMethod,h=t.paymentMethodMeta,f=a&&a.consignments[0],g=f&&f.shippingAddress,y=f&&f.selectedShippingOption;return{additionalAction:r,authToken:i,paymentMethod:p&&this._transformPaymentMethod(p),customer:u&&u.billingAddress&&a&&yi(a.customer,u.billingAddress),billingAddress:u&&u.billingAddress&&ui(u.billingAddress),shippingAddress:g&&a&&ui(g,a.consignments),shippingOption:y&&Pi(y,!0),cart:a&&mi(a),order:u&&Si(u,c),orderMeta:c,payment:this._transformHostedInputValues(e,l,n),quoteMeta:{request:(0,o.__assign)((0,o.__assign)({},h),{geoCountryCode:s&&s.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:s&&(0,m.pick)(s.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},e.prototype._transformPaymentMethod=function(e){return"multi-option"!==e.method||e.gateway?e.initializationData&&e.initializationData.gateway?(0,o.__assign)((0,o.__assign)({},e),{id:e.initializationData.gateway}):e.id===gi.BRAINTREE_VENMO?(0,o.__assign)((0,o.__assign)({},e),{id:gi.BRAINTREE_PAYPAL}):e:(0,o.__assign)((0,o.__assign)({},e),{gateway:e.id})},e.prototype._transformHostedInputValues=function(e,t,n){return"instrumentId"in t?(0,o.__assign)((0,o.__assign)({},t),{ccCvv:e.cardCodeVerification,ccNumber:e.cardNumberVerification&&this._cardNumberFormatter.unformat(e.cardNumberVerification),hostedFormNonce:n}):(0,o.__assign)((0,o.__assign)({},t),{ccCvv:e.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(e.cardExpiry||""),ccName:e.cardName||"",ccNumber:this._cardNumberFormatter.unformat(e.cardNumber||""),hostedFormNonce:n})},e.prototype._mapShippingAddress=function(e,t){var n,r,i,o;if(t){var a=null===(r=null===(n=t.initializationData)||void 0===n?void 0:n.bopis)||void 0===r?void 0:r.enabled,s=null===(o=null===(i=t.initializationData)||void 0===i?void 0:i.bopis)||void 0===o?void 0:o.requiredAddress,u=e.consignments.getConsignments(),c=null==u?void 0:u.every((function(e){return e.selectedPickupOption}));if(a&&c&&"none"===s)return}return e.shippingAddress.getShippingAddress()},e}(),Ti=function(){function e(){}return e.prototype.updatePaymentProviderCustomer=function(e){return(0,S.of)((0,a.createAction)(gt.UpdatePaymentProviderCustomer,e))},e}(),Oi=function(){function e(e,t){this._remoteCheckoutRequestSender=e,this._checkoutActionCreator=t}return e.prototype.initializeBilling=function(e,t,n){var r=this;return S.Observable.create((function(i){i.next((0,a.createAction)(Pt.InitializeRemoteBillingRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializeBilling(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Pt.InitializeRemoteBillingSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Pt.InitializeRemoteBillingFailed,t,{methodId:e}))}))}))},e.prototype.initializeShipping=function(e,t,n){var r=this;return S.Observable.create((function(i){i.next((0,a.createAction)(Pt.InitializeRemoteShippingRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializeShipping(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Pt.InitializeRemoteShippingSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Pt.InitializeRemoteShippingFailed,t,{methodId:e}))}))}))},e.prototype.initializePayment=function(e,t,n){var r=this;return S.Observable.create((function(i){i.next((0,a.createAction)(Pt.InitializeRemotePaymentRequested,void 0,{methodId:e})),r._remoteCheckoutRequestSender.initializePayment(e,t,n).then((function(t){var n=t.body,r=void 0===n?{}:n;i.next((0,a.createAction)(Pt.InitializeRemotePaymentSucceeded,r,{methodId:e})),i.complete()})).catch((function(t){i.error((0,a.createErrorAction)(Pt.InitializeRemotePaymentFailed,t,{methodId:e}))}))}))},e.prototype.loadSettings=function(e,t){var n=this;return S.Observable.create((function(r){r.next((0,a.createAction)(Pt.LoadRemoteSettingsRequested,void 0,{methodId:e})),n._remoteCheckoutRequestSender.loadSettings(e,t).then((function(t){var n=t.body;r.next((0,a.createAction)(Pt.LoadRemoteSettingsSucceeded,n,{methodId:e})),r.complete()})).catch((function(t){r.error((0,a.createErrorAction)(Pt.LoadRemoteSettingsFailed,t,{methodId:e}))}))}))},e.prototype.signOut=function(e,t){var n=this;return S.Observable.create((function(r){r.next((0,a.createAction)(Pt.SignOutRemoteCustomerRequested,void 0,{methodId:e})),n._remoteCheckoutRequestSender.signOut(e,t).then((function(){r.next((0,a.createAction)(Pt.SignOutRemoteCustomerSucceeded,void 0,{methodId:e})),r.complete()})).catch((function(t){r.error((0,a.createErrorAction)(Pt.SignOutRemoteCustomerFailed,t,{methodId:e}))}))}))},e.prototype.forgetCheckout=function(e,t){var n=this;return(0,S.concat)((0,S.of)((0,a.createAction)(Pt.ForgetCheckoutRemoteCustomerRequested,void 0,{methodId:e})),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._remoteCheckoutRequestSender.forgetCheckout(t)];case 1:return n.sent(),[4,this._checkoutActionCreator.loadCurrentCheckout()];case 2:return n.sent(),[2,(0,a.createAction)(Pt.ForgetCheckoutRemoteCustomerSucceeded,void 0,{methodId:e})]}}))}))}))).pipe((0,I.catchError)((function(t){return er(Pt.ForgetCheckoutRemoteCustomerFailed,t,{methodId:e})})))},e.prototype.updateCheckout=function(e,t){return(0,a.createAction)(Pt.UpdateRemoteCheckout,t,{methodId:e})},e}(),Ri=function(){function e(e){this._requestSender=e}return e.prototype.initializeBilling=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/billing";return this._requestSender.get(i,{params:t,timeout:r,headers:Qn})},e.prototype.initializeShipping=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/shipping";return this._requestSender.get(i,{params:t,timeout:r,headers:Qn})},e.prototype.initializePayment=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/remote-checkout/"+e+"/payment";return this._requestSender.get(i,{params:t,timeout:r,headers:Qn})},e.prototype.loadSettings=function(e,t){var n=(void 0===t?{}:t).timeout,r="/remote-checkout/"+e+"/settings";return this._requestSender.get(r,{timeout:n,headers:Qn})},e.prototype.signOut=function(e,t){var n=(void 0===t?{}:t).timeout,r="/remote-checkout/"+e+"/signout";return this._requestSender.get(r,{timeout:n,headers:Qn})},e.prototype.generateToken=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.get("/remote-checkout-token",{timeout:t,headers:Qn})},e.prototype.trackAuthorizationEvent=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.post("/remote-checkout/events/shopper-checkout-service-provider-authorization-requested",{timeout:t,headers:Qn})},e.prototype.forgetCheckout=function(e){var t=(void 0===e?{}:e).timeout;return this._requestSender.post("/remote-checkout/forget-checkout",{timeout:t,headers:Qn})},e}();var Mi;!function(e){e.AvailableShippingOptions="consignments.availableShippingOptions",e.PhysicalItemsCategoryNames="cart.lineItems.physicalItems.categoryNames",e.DigitalItemsCategoryNames="cart.lineItems.digitalItems.categoryNames"}(Mi||(Mi={}));const ki=function(){function e(e,t){this._consignmentRequestSender=e,this._checkoutRequestSender=t}return e.prototype.unassignItemsByAddress=function(e,t){var n=this;return function(r){var i=r.getState();if(!i.checkout.getCheckout())throw new Mn(Rn.MissingCheckout);var o=n._consignmentHasAddress(e)?e.address:e.shippingAddress,a=i.consignments.getConsignmentByAddress(o);if(!a)throw new Pr("No consignment found for the specified address");var s=n._removeLineItems(e.lineItems,a,i.cart.getCart());return s.length?n.updateConsignment({id:a.id,address:o,lineItems:s},t)(r):n.deleteConsignment(a.id,t)(r)}},e.prototype.assignItemsByAddress=function(e,t){var n=this;return function(r){var i=r.getState(),o=n._consignmentHasAddress(e)?e.address:e.shippingAddress,a=i.consignments.getConsignmentByAddress(o);return n._createOrUpdateConsignment({id:a&&a.id,address:o,lineItems:n._addLineItems(e.lineItems,a,i.cart.getCart())},t)(r)}},e.prototype.selectShippingOption=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState(),s=o.checkout.getCheckout(),u=o.consignments.getConsignments();if(!s)throw new Mn(Rn.MissingCheckout);if(!u||!u.length)throw new Mn(Rn.MissingConsignments);var c={id:u[0].id,shippingOptionId:e},d={id:u[0].id};i.next((0,a.createAction)(x.UpdateShippingOptionRequested,void 0,d)),n._consignmentRequestSender.updateConsignment(s.id,c,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.UpdateShippingOptionSucceeded,t,d)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.UpdateShippingOptionFailed,e,d))}))}))}},e.prototype.loadShippingOptions=function(e){var t=this;return function(n){return S.Observable.create((function(r){var i=n.getState().checkout.getCheckout();if(!i)throw new Mn(Rn.MissingCheckout);r.next((0,a.createAction)(x.LoadShippingOptionsRequested)),t._checkoutRequestSender.loadCheckout(i.id,(0,o.__assign)((0,o.__assign)({},e),{params:{include:[Mi.AvailableShippingOptions]}})).then((function(e){var t=e.body;r.next((0,a.createAction)(x.LoadShippingOptionsSucceeded,t)),r.complete()})).catch((function(e){r.error((0,a.createErrorAction)(x.LoadShippingOptionsFailed,e))}))}))}},e.prototype.updateAddress=function(e,t){var n=this;return function(r){var i=n._getUpdateAddressRequestBody(e,r),o=r.getState().consignments.getConsignments();return o&&o.length&&(i.id=o[0].id),n._createOrUpdateConsignment(i,t)(r)}},e.prototype.createConsignments=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Mn(Rn.MissingCheckout);i.next((0,a.createAction)(x.CreateConsignmentsRequested)),n._consignmentRequestSender.createConsignments(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.CreateConsignmentsSucceeded,t)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.CreateConsignmentsFailed,e))}))}))}},e.prototype.updateConsignment=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Mn(Rn.MissingCheckout);var s={id:e.id};i.next((0,a.createAction)(x.UpdateConsignmentRequested,void 0,s)),n._consignmentRequestSender.updateConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.UpdateConsignmentSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.UpdateConsignmentFailed,e,s))}))}))}},e.prototype.deleteConsignment=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState().checkout.getCheckout(),s={id:e};if(!o||!o.id)throw new Mn(Rn.MissingCheckout);i.next((0,a.createAction)(x.DeleteConsignmentRequested,void 0,s)),n._consignmentRequestSender.deleteConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.DeleteConsignmentSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.DeleteConsignmentFailed,e,s))}))}))}},e.prototype.updateShippingOption=function(e,t){var n=this;return function(r){return S.Observable.create((function(i){var o=r.getState().checkout.getCheckout();if(!o||!o.id)throw new Mn(Rn.MissingCheckout);var s={id:e.id};i.next((0,a.createAction)(x.UpdateShippingOptionRequested,void 0,s)),n._consignmentRequestSender.updateConsignment(o.id,e,t).then((function(e){var t=e.body;i.next((0,a.createAction)(x.UpdateShippingOptionSucceeded,t,s)),i.complete()})).catch((function(e){i.error((0,a.createErrorAction)(x.UpdateShippingOptionFailed,e,s))}))}))}},e.prototype._createOrUpdateConsignment=function(e,t){var n=this;return function(r){var i=r.getState().checkout.getCheckout();if(!i||!i.id)throw new Mn(Rn.MissingCheckout);return n._isUpdateConsignmentRequest(e)?n.updateConsignment(e,t)(r):n.createConsignments([e],t)(r)}},e.prototype._getUpdateAddressRequestBody=function(e,t){var n=t.getState().cart.getCart();if(!n)throw new Mn(Rn.MissingCart);var r=n.lineItems,i=r.physicalItems,a=r.customItems,s=void 0===a?[]:a;return{address:e,lineItems:(0,o.__spreadArrays)(i,s).map((function(e){return{itemId:e.id,quantity:e.quantity}}))}},e.prototype._removeLineItems=function(e,t,n){if(!n)throw new Mn(Rn.MissingCart);return this._hydrateLineItems(t.lineItemIds,n).map((function(t){var n=(0,m.find)(e,(function(e){return e.itemId===t.itemId}));return(0,o.__assign)((0,o.__assign)({},t),{quantity:n?t.quantity-n.quantity:t.quantity})})).filter((function(e){return e.quantity>0}))},e.prototype._addLineItems=function(e,t,n){if(!t)return e;if(!n)throw new Mn(Rn.MissingCart);return e.concat(this._hydrateLineItems(t.lineItemIds,n)).filter((function(e){return e.quantity>0}))},e.prototype._hydrateLineItems=function(e,t){return e.map((function(e){var n=(0,m.find)(t.lineItems.physicalItems,(function(t){return t.id===e}));return{itemId:e,quantity:n?n.quantity:0}}))},e.prototype._isUpdateConsignmentRequest=function(e){return!!e.id},e.prototype._consignmentHasAddress=function(e){return"object"==typeof e&&"address"in e},e}();var Di=["consignments.availableShippingOptions","cart.lineItems.physicalItems.options","cart.lineItems.digitalItems.options","customer","promotions.banners"];const Ni=function(){function e(e){this._requestSender=e}return e.prototype.createConsignments=function(e,t,n){var r=void 0===n?{}:n,i=r.timeout,a=r.params,s=(void 0===a?{}:a).include,u="/api/storefront/checkouts/"+e+"/consignments",c=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post(u,{body:t,params:{include:ur(Di,s)},headers:c,timeout:i})},e.prototype.updateConsignment=function(e,t,n){var r=void 0===n?{}:n,i=r.timeout,a=r.params,s=(void 0===a?{}:a).include,u=t.id,c=(0,o.__rest)(t,["id"]),d="/api/storefront/checkouts/"+e+"/consignments/"+u,l=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.put(d,{body:c,params:{include:ur(Di,s)},headers:l,timeout:i})},e.prototype.deleteConsignment=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/consignments/"+t,a=(0,o.__assign)({Accept:Jn.JsonV1},Qn),s=sr(Di);return this._requestSender.delete(i,{params:{include:s},headers:a,timeout:r})},e}(),Li=function(){function e(e){this._shippingCountryRequestSender=e}return e.prototype.loadCountries=function(e){var t=this;return S.Observable.create((function(n){n.next((0,a.createAction)(Vt.LoadShippingCountriesRequested)),t._shippingCountryRequestSender.loadCountries(e).then((function(e){n.next((0,a.createAction)(Vt.LoadShippingCountriesSucceeded,e.body.data)),n.complete()})).catch((function(e){n.error((0,a.createErrorAction)(Vt.LoadShippingCountriesFailed,e))}))}))},e}(),zi=function(){function e(e,t){this._requestSender=e,this._config=t}return e.prototype.loadCountries=function(e){var t=(void 0===e?{}:e).timeout,n=(0,o.__assign)({"Accept-Language":this._config.locale},Qn);return this._requestSender.get("/internalapi/v1/shipping/countries",{headers:n,timeout:t})},e}(),Fi=function(){function e(e,t){this._googleRecaptcha=e,this._requestSender=t}return e.prototype.initialize=function(e){var t=this;return function(n){return(0,S.concat)((0,S.of)((0,a.createAction)(vn.InitializeRequested,void 0)),(0,S.defer)((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r,i,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t=e?e.containerId:"spamProtectionContainer",e||document.getElementById(t)||((r=document.createElement("div")).setAttribute("id",t),document.body.appendChild(r)),i=n.getState(),s=i.config.getStoreConfigOrThrow(),u=s.checkoutSettings.googleRecaptchaSitekey,[4,this._googleRecaptcha.load(t,u)];case 1:return o.sent(),[2,(0,a.createAction)(vn.InitializeSucceeded)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(vn.InitializeFailed,e)})))}},e.prototype.verifyCheckoutSpamProtection=function(){var e=this;return function(t){return(0,S.defer)((function(){var n=t.getState().checkout.getCheckout();if(!n)throw new Mn(Rn.MissingCheckout);return(0,S.concat)((0,S.of)((0,a.createAction)(vn.VerifyCheckoutRequested)),(0,S.from)(e.execute()(t)).pipe((0,I.switchMap)((function(t){return yr(t)&&t.payload?(0,S.from)(e._requestSender.validate(n.id,t.payload.token)).pipe((0,I.switchMap)((function(e){var n=e.body;return(0,S.concat)((0,S.of)(t),(0,S.of)((0,a.createAction)(vn.VerifyCheckoutSucceeded,n)))}))):(0,S.of)(t)})))).pipe((0,I.catchError)((function(e){return er(vn.VerifyCheckoutFailed,e)})))}))}},e.prototype.execute=function(){var e=this;return function(t){return(0,S.concat)((0,S.of)((0,a.createAction)(vn.ExecuteRequested)),e.initialize()(t),e._googleRecaptcha.execute().pipe((0,I.take)(1)).pipe((0,I.switchMap)((function(t){var n=t.error,r=t.token;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){if(n instanceof Dr)throw n;if(n||!r)throw new qr;return[2,(0,a.createAction)(vn.ExecuteSucceeded,{token:r})]}))}))})))).pipe((0,I.catchError)((function(e){return er(vn.ExecuteFailed,e)})))}},e}(),Ui=function(){function e(e){this._requestSender=e}return e.prototype.validate=function(e,t,n){var r=(void 0===n?{}:n).timeout,i="/api/storefront/checkouts/"+e+"/spam-protection",a=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post(i,{body:{token:t},headers:a,timeout:r})},e}(),qi=function(){function e(e){this._storeCreditRequestSender=e}return e.prototype.applyStoreCredit=function(e,t){var n=this;return function(r){return(0,S.concat)((0,S.of)((0,a.createAction)(cn.ApplyStoreCreditRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n,i,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=r.getState(),!(i=n.checkout.getCheckout()))throw new Mn(Rn.MissingCheckout);return[4,e?this._storeCreditRequestSender.applyStoreCredit(i.id,t):this._storeCreditRequestSender.removeStoreCredit(i.id,t)];case 1:return s=o.sent().body,[2,(0,a.createAction)(cn.ApplyStoreCreditSucceeded,s)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(cn.ApplyStoreCreditFailed,e)})))}},e}(),Bi=function(){function e(e){this._requestSender=e}return e.prototype.applyStoreCredit=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/checkouts/"+e+"/store-credit",i=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post(r,{headers:i,timeout:n,params:{include:sr(cr)}})},e.prototype.removeStoreCredit=function(e,t){var n=(void 0===t?{}:t).timeout,r="/api/storefront/checkouts/"+e+"/store-credit",i=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.delete(r,{headers:i,timeout:n,params:{include:sr(cr)}})},e}(),Gi=function(e){function t(t){var n=e.call(this,t)||this;return n.name="UpdateSubscriptionsError",n.type="update_subscriptions",n}return(0,o.__extends)(t,e),t}(h),xi=function(){function e(e){this._subscriptionsRequestSender=e}return e.prototype.updateSubscriptions=function(e,t){var n=this;return(0,S.concat)((0,S.of)((0,a.createAction)(b.UpdateSubscriptionsRequested)),(0,S.defer)((function(){return(0,o.__awaiter)(n,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._subscriptionsRequestSender.updateSubscriptions(e,t)];case 1:return n=r.sent().body,[2,(0,a.createAction)(b.UpdateSubscriptionsSucceeded,n)]}}))}))}))).pipe((0,I.catchError)((function(e){return er(b.UpdateSubscriptionsFailed,new Gi(e))})))},e}(),Yi=function(){function e(e){this._requestSender=e}return e.prototype.updateSubscriptions=function(e,t){var n=(void 0===t?{}:t).timeout,r=(0,o.__assign)({Accept:Jn.JsonV1},Qn);return this._requestSender.post("/api/storefront/subscriptions",{body:e,headers:r,timeout:n})},e}();var Vi=(0,m.memoize)((function(e){return Array.isArray(e)?e.map((function(e){return Hi(e)})):F(e)?Object.keys(e).reduce((function(t,n){var r;return(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Hi(e[n]),r))}),{}):e}));Vi.cache=new WeakMap;var Hi=function(e){return"object"==typeof e&&null!==e?Vi(e):e};function ji(e){return function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return Hi(e.apply(void 0,t))}}function Wi(e){var t=e.billingAddress,n=t.getBillingAddress,r=t.getBillingAddressOrThrow,i=e.cart,o=i.getCart,a=i.getCartOrThrow,s=e.checkout,u=s.getCheckout,c=s.getCheckoutOrThrow,d=s.getOutstandingBalance,l=e.config,p=l.getContextConfig,h=l.getHost,f=l.getLocale,m=l.getStoreConfig,g=l.getStoreConfigOrThrow,y=e.consignments,_=y.getConsignments,v=y.getConsignmentsOrThrow,C=e.countries.getCountries,S=e.customer,I=S.getCustomer,w=S.getCustomerOrThrow,E=e.instruments,b=E.getCardInstrument,P=E.getCardInstrumentOrThrow,A=E.getInstruments,T=e.order,O=T.getOrder,R=T.getOrderOrThrow,M=e.payment,k=M.getPaymentToken,D=M.getPaymentTokenOrThrow,N=M.getPaymentId,L=M.getPaymentIdOrThrow,z=M.getPaymentStatus,F=M.getPaymentStatusOrThrow,U=M.getPaymentRedirectUrl,q=M.getPaymentRedirectUrlOrThrow,B=M.isPaymentDataRequired,G=e.paymentMethods,x=G.getPaymentMethod,Y=G.getPaymentMethodOrThrow,V=e.paymentProviderCustomer,H=V.getPaymentProviderCustomer,j=V.getPaymentProviderCustomerOrThrow,W=e.paymentStrategies.isInitialized,K=e.shippingAddress,J=K.getShippingAddress,Z=K.getShippingAddressOrThrow,Q=K.getShippingAddresses,X=K.getShippingAddressesOrThrow,$=e.shippingCountries.getShippingCountries;return{getHost:ji(h),getLocale:ji(f),getBillingAddress:ji(n),getBillingAddressOrThrow:ji(r),getCart:ji(o),getCartOrThrow:ji(a),getCheckout:ji(u),getCheckoutOrThrow:ji(c),getCountries:ji(C),getStoreConfig:ji(m),getStoreConfigOrThrow:ji(g),getConsignments:ji(_),getConsignmentsOrThrow:ji(v),getContextConfig:ji(p),getCustomer:ji(I),getCustomerOrThrow:ji(w),getCardInstrument:ji(b),getInstruments:ji(A),getCardInstrumentOrThrow:ji(P),getOrder:ji(O),getOrderOrThrow:ji(R),getPaymentToken:k,getPaymentTokenOrThrow:D,getPaymentId:N,getPaymentIdOrThrow:L,getPaymentStatus:z,getPaymentStatusOrThrow:F,getPaymentRedirectUrl:U,getPaymentRedirectUrlOrThrow:q,getPaymentMethod:ji(x),getPaymentMethodOrThrow:ji(Y),getPaymentProviderCustomer:ji(H),getPaymentProviderCustomerOrThrow:ji(j),getShippingAddress:ji(J),getShippingAddressOrThrow:ji(Z),getShippingAddresses:ji(Q),getShippingAddressesOrThrow:ji(X),getShippingCountries:ji($),getOutstandingBalance:ji(d),isPaymentDataRequired:B,isPaymentMethodInitialized:W}}const Ki=function(){function e(e,t,n,r,i,o,a,s,u,c,d,l,p,h,f,m,g){this._store=e,this._storeProjectionFactory=t,this._checkoutActionCreator=n,this._checkoutValidator=r,this._hostedFormFactory=i,this._orderActionCreator=o,this._billingAddressActionCreator=a,this._consignmentActionCreator=s,this._paymentMethodActionCreator=u,this._paymentActionCreator=c,this._customerActionCreator=d,this._cartRequestSender=l,this._storeCreditActionCreator=p,this._spamProtectionActionCreator=h,this._paymentProviderCustomerActionCreator=f,this._shippingCountryActionCreator=m,this._remoteCheckoutActionCreator=g,this._storeProjection=this._storeProjectionFactory.create(this._store)}return e.prototype.createHostedForm=function(e,t){return this._hostedFormFactory.create(e,t)},e.prototype.subscribe=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];return(t=this._storeProjection).subscribe.apply(t,(0,o.__spreadArrays)([e],n))},e.prototype.getState=function(){return this._storeProjection.getState()},e.prototype.initializeOffsitePayment=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentActionCreator.initializeOffsitePayment(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadCheckout=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e?[4,this._store.dispatch(this._checkoutActionCreator.loadCheckout(e))]:[3,2];case 1:return t.sent(),[3,4];case 2:return[4,this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout())];case 3:t.sent(),t.label=4;case 4:return[2,this._storeProjection.getState()]}}))}))},e.prototype.loadDefaultCheckout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 1:return e.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadPaymentMethod=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadPaymentMethods=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethods(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.submitOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._orderActionCreator.submitOrder(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.submitPayment=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentActionCreator.submitPayment(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.finalizeOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=this._store.getState().order.getOrderOrThrow,[4,this._store.dispatch(this._orderActionCreator.finalizeOrder(t().orderId,e))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updateBillingAddress=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._billingAddressActionCreator.updateAddress(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updateShippingAddress=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.updateAddress(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.selectShippingOption=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.selectShippingOption(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.signInCustomer=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._customerActionCreator.signInCustomer(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.signOutCustomer=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._customerActionCreator.signOutCustomer(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.createBuyNowCart=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._cartRequestSender.createBuyNowCart(e,t)];case 1:return[2,n.sent().body]}}))}))},e.prototype.applyStoreCredit=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._storeCreditActionCreator.applyStoreCredit(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.verifyCheckoutSpamProtection=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return this._store.getState().checkout.getCheckoutOrThrow().shouldExecuteSpamCheck?[4,this._store.dispatch(this._spamProtectionActionCreator.verifyCheckoutSpamProtection())]:[3,2];case 1:e.sent(),e.label=2;case 2:return[2,this._storeProjection.getState()]}}))}))},e.prototype.loadCurrentOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._orderActionCreator.loadCurrentOrder(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.updatePaymentProviderCustomer=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._paymentProviderCustomerActionCreator.updatePaymentProviderCustomer(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.loadShippingCountries=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._store.dispatch(this._shippingCountryActionCreator.loadCountries(e))];case 1:return t.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.deleteConsignment=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._consignmentActionCreator.deleteConsignment(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.initializePayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.initializePayment(e,t,n))];case 1:return r.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.forgetCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._store.dispatch(this._remoteCheckoutActionCreator.forgetCheckout(e,t))];case 1:return n.sent(),[2,this._storeProjection.getState()]}}))}))},e.prototype.validateCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._checkoutValidator.validate(e,t)];case 1:return n.sent(),[2]}}))}))},e}();var Ji;!function(e){e.Synchronize="SYNCHRONIZE"}(Ji||(Ji={}));const Zi=function(){function e(e){this._transformSelectors=e}return e.prototype.create=function(e){return function(e,t){var n=(0,a.createDataStore)((function(e,t){return t.type===Ji.Synchronize?t.payload:e}),e.getState(),{stateTransformer:t});return e.subscribe((function(e){n.dispatch((0,a.createAction)(Ji.Synchronize,e))}),{initial:!1}),n}(e,this._transformSelectors)},e}();const Qi=require("shallowequal");var Xi=e.n(Qi);function $i(e){return Object.prototype.hasOwnProperty.call(e,"cacheKey")}const eo=function(){function e(e){this._lastId=0,this._map={maps:[]},this._usedMaps=[],this._options=(0,o.__assign)({maxSize:0,isEqual:Xi(),onExpire:m.noop},e)}return e.prototype.getKey=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._resolveMap.apply(this,e),r=n.index,i=n.parentMap,o=n.map;return o&&o.cacheKey?o.usedCount++:o=this._generateMap(i,e.slice(r)),this._removeLeastUsedMap(o),o.cacheKey},e.prototype.getUsedCount=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];var n=this._resolveMap.apply(this,e).map;return n?n.usedCount:0},e.prototype._resolveMap=function(){for(var e,t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];for(var r=0,i=this._map;i.maps.length;){for(var o=!1,a=0;a<i.maps.length;a++){var s=i.maps[a];if(this._options.isEqual(s.value,t[r])){if((e=i.maps).unshift.apply(e,i.maps.splice(a,1)),(0===t.length||r===t.length-1)&&$i(s))return{index:r,map:s,parentMap:i};o=!0,i=s,r++;break}}if(!o)break}return{index:r,parentMap:i}},e.prototype._generateMap=function(e,t){var n,r=0,i=e;do{n={maps:[],parentMap:i,usedCount:1,value:t[r]},i.maps.unshift(n),i=n,r++}while(r<t.length);var o=n;return o.cacheKey=""+ ++this._lastId,o},e.prototype._removeLeastUsedMap=function(e){if(this._options.maxSize){var t=this._usedMaps.indexOf(e);if(this._usedMaps.splice(-1===t?0:t,-1===t?0:1,e),!(this._usedMaps.length<=this._options.maxSize)){var n=this._usedMaps.pop();n&&(this._removeMap(n),this._options.onExpire(n.cacheKey))}}},e.prototype._removeMap=function(e){e.parentMap&&(e.parentMap.maps.splice(e.parentMap.maps.indexOf(e),1),function(e){return Object.prototype.hasOwnProperty.call(e,"parentMap")}(e.parentMap)||this._removeMap(e.parentMap))},e}();function to(e){var t=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return(0,o.__extends)(t,e),t}(e);return Object.getOwnPropertyNames(e.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(e.prototype,n);r&&"constructor"!==n&&Object.defineProperty(t.prototype,n,function(e,t,n){if("function"!=typeof n.value)return n;var r=new eo,i=n.value,a=(0,On.memoize)(i);return Rr(e,t,{get:function(){var e=this,s=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];var s=a.call.apply(a,(0,o.__spreadArrays)([e],t));if(1===r.getUsedCount.apply(r,t))return s;var u=i.call.apply(i,(0,o.__spreadArrays)([e],t));return O(u,s,{keyFilter:function(e){return!function(e){return 0===(""+e).indexOf("$$")||0===(""+e).indexOf("_")}(e)}})?s:(a.cache.set(r.getKey.apply(r,t),u),u)};return Object.defineProperty(this,t,(0,o.__assign)((0,o.__assign)({},n),{value:s})),s},set:function(e){r=new eo,i=e,a=(0,On.memoize)(i)}})}(e.prototype,n,r))})),t}const no=function(){function e(e){this._checkoutButton=e.checkoutButton}return e.prototype.getInitializeButtonError=function(e){return this._checkoutButton.getInitializeError(e)},e.prototype.getDeinitializeButtonError=function(e){return this._checkoutButton.getDeinitializeError(e)},(0,o.__decorate)([to],e)}(),ro=function(){function e(e){this._checkoutButton=e.checkoutButton}return e.prototype.isInitializingButton=function(e){return this._checkoutButton.isInitializing(e)},e.prototype.isDeinitializingButton=function(e){return this._checkoutButton.isDeinitializing(e)},(0,o.__decorate)([to],e)}();function io(e){return{errors:new no(e),statuses:new ro(e)}}const oo=function(){function e(e,t){var n=this;this._store=e,this._buttonStrategyActionCreator=t,this._state=io(this._store.getState()),this._store.subscribe((function(e){n._state=io(e)}))}return e.prototype.getState=function(){return this._state},e.prototype.subscribe=function(e){for(var t,n=this,r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];return(t=this._store).subscribe.apply(t,(0,o.__spreadArrays)([function(){return e(n.getState())},function(e){return e.checkoutButton.getState()}],r.map((function(e){return function(t){return e(io(t))}}))))},e.prototype.initializeButton=function(e){var t,n=this,r=(t=e.containerId,/^\w[\w\-\:\.]*$/.test(t)?[e.containerId]:function(e,t){var n=document.querySelectorAll(e);if(!n.length)throw new Pr("Unable to find any element with the specified selector: "+e);return Array.prototype.slice.call(n).map((function(e){return e.id||(e.id=(0,m.uniqueId)(t)),e.id}))}(e.containerId,e.methodId+"-container"));return Promise.all(r.map((function(t){var r=n._buttonStrategyActionCreator.initialize((0,o.__assign)((0,o.__assign)({},e),{containerId:t})),i="checkoutButtonStrategy:"+e.methodId+":"+t;return n._store.dispatch(r,{queueId:i})}))).then((function(){return n.getState()}))},e.prototype.deinitializeButton=function(e){var t=this,n=this._buttonStrategyActionCreator.deinitialize(e),r="checkoutButtonStrategy:"+e.methodId;return this._store.dispatch(n,{queueId:r}).then((function(){return t.getState()}))},(0,o.__decorate)([Rr],e)}(),ao=function(){function e(e,t,n){this._registry=e,this._registryV2=t,this._paymentMethodActionCreator=n}return e.prototype.initialize=function(e){var t=this;return function(n){var r={methodId:e.methodId,containerId:e.containerId};if(n.getState().checkoutButton.isInitialized(e.methodId,e.containerId))return(0,S.empty)();var i=e.currencyCode?{params:{currencyCode:e.currencyCode}}:{},s=(0,o.__assign)((0,o.__assign)({},i),{timeout:e.timeout,useCache:!0});return(0,S.concat)((0,S.of)((0,a.createAction)(Y.InitializeButtonRequested,void 0,r)),t._paymentMethodActionCreator.loadPaymentMethod(e.methodId,s)(n),(0,S.defer)((function(){return t._getStrategy(e.methodId).initialize(e).then((function(){return(0,a.createAction)(Y.InitializeButtonSucceeded,void 0,r)}))}))).pipe((0,I.catchError)((function(e){return er(Y.InitializeButtonFailed,e,r)})))}},e.prototype.deinitialize=function(e){var t=this;return function(n){var r={methodId:e.methodId};return n.getState().checkoutButton.isInitialized(e.methodId)?(0,S.concat)((0,S.of)((0,a.createAction)(Y.DeinitializeButtonRequested,void 0,r)),(0,S.defer)((function(){return t._getStrategy(e.methodId).deinitialize().then((function(){return(0,a.createAction)(Y.DeinitializeButtonSucceeded,void 0,r)}))}))).pipe((0,I.catchError)((function(e){return er(Y.DeinitializeButtonFailed,e,r)}))):(0,S.empty)()}},e.prototype._getStrategy=function(e){var t;try{t=this._registryV2.get({id:e})}catch(n){t=this._registry.get(e)}return t},e}();const so=function(e){function t(t){var n=e.call(this,t||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return(0,o.__extends)(t,e),t}(s);var uo;!function(e){e[e.MissingBillingAddress=0]="MissingBillingAddress",e[e.MissingCart=1]="MissingCart",e[e.MissingCheckout=2]="MissingCheckout",e[e.MissingConsignments=3]="MissingConsignments",e[e.MissingCustomer=4]="MissingCustomer",e[e.MissingCheckoutConfig=5]="MissingCheckoutConfig",e[e.MissingOrder=6]="MissingOrder",e[e.MissingOrderConfig=7]="MissingOrderConfig",e[e.MissingOrderId=8]="MissingOrderId",e[e.MissingPayment=9]="MissingPayment",e[e.MissingPaymentId=10]="MissingPaymentId",e[e.MissingPaymentInstrument=11]="MissingPaymentInstrument",e[e.MissingPaymentMethod=12]="MissingPaymentMethod",e[e.MissingPaymentRedirectUrl=13]="MissingPaymentRedirectUrl",e[e.MissingPaymentStatus=14]="MissingPaymentStatus",e[e.MissingPaymentToken=15]="MissingPaymentToken",e[e.MissingShippingAddress=16]="MissingShippingAddress"}(uo||(uo={}));const co=function(e){function t(t){var n=e.call(this,function(e){switch(e){case uo.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case uo.MissingCart:return"Unable to proceed because cart data is unavailable.";case uo.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case uo.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case uo.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case uo.MissingCheckoutConfig:case uo.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case uo.MissingOrder:return"Unable to proceed because order data is unavailable.";case uo.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case uo.MissingPayment:return"Unable to proceed because payment data is unavailable.";case uo.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case uo.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case uo.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(t))||this;return n.subtype=t,n.name="MissingDataError",n.type="missing_data",n}return(0,o.__extends)(t,e),t}(s);function lo(e){return t=e.lineItems.physicalItems.filter((function(e){return!e.addedByPromotion})),(0,m.reduce)(t,(function(e,t){return e+t.quantity}),0);var t}function po(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}var ho;!function(e){e[e.CheckoutButtonNotInitialized=0]="CheckoutButtonNotInitialized",e[e.CustomerNotInitialized=1]="CustomerNotInitialized",e[e.PaymentNotInitialized=2]="PaymentNotInitialized",e[e.ShippingNotInitialized=3]="ShippingNotInitialized",e[e.SpamProtectionNotInitialized=4]="SpamProtectionNotInitialized"}(ho||(ho={}));const fo=function(e){function t(t){var n=e.call(this,function(e){switch(e){case ho.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case ho.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case ho.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case ho.SpamProtectionNotInitialized:return"Unable to proceed because the checkout spam protection has not been initialized.";default:return"Unable to proceed because the required component has not been initialized."}}(t))||this;return n.subtype=t,n.name="NotInitializedError",n.type="not_initialized",n}return(0,o.__extends)(t,e),t}(s);var mo,go,yo,_o,vo,Co,So={de:"eu",jp:"fe",uk:"eu",us:"na"};!function(e){e.en_US="en_US",e.en_GB="en_GB",e.de_DE="de_DE",e.fr_FR="fr_FR",e.it_IT="it_IT",e.es_ES="es_ES",e.ja_JP="ja_JP"}(mo||(mo={})),function(e){e.Home="Home",e.Product="Product",e.Cart="Cart",e.Checkout="Checkout",e.Other="Other"}(go||(go={})),function(e){e.USD="USD",e.EUR="EUR",e.GBP="GBP",e.JPY="JPY"}(yo||(yo={})),function(e){e.PayAndShip="PayAndShip",e.PayOnly="PayOnly"}(_o||(_o={})),function(e){e.Gold="Gold",e.LightGray="LightGray",e.DarkGray="DarkGray"}(vo||(vo={})),function(e){e.C0001="C0001"}(Co||(Co={}));const Io=function(){function e(e){this.amazonPayV2ScriptLoader=e}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=this,[4,this.amazonPayV2ScriptLoader.load(e)];case 1:return t.amazonPayV2SDK=n.sent(),this.buttonParentContainer=this.buttonParentContainer||this.createAmazonPayButtonParentContainer(),[2]}}))}))},e.prototype.deinitialize=function(){var e;return this.amazonPayV2Button=void 0,null===(e=this.buttonParentContainer)||void 0===e||e.remove(),this.buttonParentContainer=void 0,this.amazonPayV2SDK=void 0,Promise.resolve()},e.prototype.bindButton=function(e,t,n){this.getAmazonPayV2SDK().Pay.bindChangeAction("#"+e,{amazonCheckoutSessionId:t,changeAction:n})},e.prototype.createButton=function(e,t){this.amazonPayV2Button=this.getAmazonPayV2SDK().Pay.renderButton("#"+e,t)},e.prototype.prepareCheckout=function(e){var t=this,n=this.prepareRequestConfig(e);this.getAmazonPayV2Button().onClick((function(){t.getAmazonPayV2Button().initCheckout(n)}))},e.prototype.prepareCheckoutWithCreationRequestConfig=function(e){var t=this;this.getAmazonPayV2Button().onClick((function(){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e()];case 1:return(t=r.sent())&&(n=this.prepareRequestConfig(t.createCheckoutSessionConfig,t.estimatedOrderAmount,t.productType),this.getAmazonPayV2Button().initCheckout(n)),[2]}}))}))}))},e.prototype.signout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return this.amazonPayV2SDK&&this.amazonPayV2SDK.Pay.signout(),[2,Promise.resolve()]}))}))},e.prototype.renderAmazonPayButton=function(e){var t=e.buttonColor,n=e.checkoutState,r=e.containerId,i=e.decoupleCheckoutInitiation,o=void 0!==i&&i,a=e.methodId,s=e.options,u=e.placement,c=document.querySelector("#"+r);if(!c)throw new so("Unable to render the Amazon Pay button to an invalid HTML container element.");var d=c.appendChild(this.getButtonParentContainer()).id;s&&(s.design=Co.C0001);var l=null!=s?s:this.getAmazonPayV2ButtonOptions(n,a,u,o,t);return this.createButton(d,l),this.getButtonParentContainer()},e.prototype.updateBuyNowFlowFlag=function(e){this.isBuyNowFlow=Boolean(e)},e.prototype.isPh4Enabled=function(e,t){var n=!!e["PROJECT-3483.amazon_pay_ph4"],r=!!e["INT-6885.amazon_pay_ph4_us_only"];return n&&r?"US"===t:n},e.prototype.prepareRequestConfig=function(e,t,n){var r=e.publicKeyId,i=(0,o.__rest)(e,["publicKeyId"]);return(0,o.__assign)((0,o.__assign)({createCheckoutSessionConfig:this.isEnvironmentSpecific(r)?i:e},t&&{estimatedOrderAmount:t}),n&&{productType:n})},e.prototype.createAmazonPayButtonParentContainer=function(){var e=Math.random().toString(16).substr(-4),t=document.createElement("div");return t.id="amazonpay_button_parent_container_"+e,t},e.prototype.getAmazonPayV2ButtonOptions=function(e,t,n,r,i){var a,s=e.cart.getCart,u=e.checkout.getCheckout,c=e.config.getStoreConfigOrThrow,d=e.paymentMethods.getPaymentMethodOrThrow;void 0===r&&(r=!1),void 0===i&&(i=vo.Gold);var l=d(t),p=l.config,h=p.merchantId,f=p.testMode,m=l.initializationData;if(!m)throw new co(uo.MissingPaymentMethod);var g=m.checkoutLanguage,y=m.checkoutSessionMethod,_=m.createCheckoutSessionConfig,v=m.extractAmazonCheckoutSessionId,C=m.ledgerCurrency,S=m.publicKeyId,I=void 0===S?"":S;if(!h||!C||!_)throw new co(uo.MissingPaymentMethod);var w={merchantId:h,ledgerCurrency:C,checkoutLanguage:g,placement:n,buttonColor:i,design:Co.C0001};if(this.isBuyNowFlow)return(0,o.__assign)((0,o.__assign)({},w),{sandbox:!!f});var E=s();w.productType=E&&0===lo(E)?_o.PayOnly:_o.PayAndShip;var b=c(),P=b.checkoutSettings.features,A=b.storeProfile,T=A.shopPath,O=A.storeCountryCode;if(this.isPh4Enabled(P,O)){var R=null===(a=u())||void 0===a?void 0:a.outstandingBalance.toString(),M=null==E?void 0:E.currency.code,k=(0,o.__assign)({},w),D=void 0;return this.isEnvironmentSpecific(I)?(k.publicKeyId=I,D=_):(k.sandbox=!!f,D=(0,o.__assign)((0,o.__assign)({},_),{publicKeyId:I})),r||(k.createCheckoutSessionConfig=D),R&&M&&(k.estimatedOrderAmount={amount:R,currencyCode:M}),k}var N={method:y,url:P["INT-5826.amazon_relative_url"]?"/remote-checkout/"+t+"/payment-session":T+"/remote-checkout/"+t+"/payment-session",extractAmazonCheckoutSessionId:v};return(0,o.__assign)((0,o.__assign)({},w),{createCheckoutSession:N,sandbox:!!f})},e.prototype.isEnvironmentSpecific=function(e){return/^(SANDBOX|LIVE)/.test(e)},e.prototype.getAmazonPayV2SDK=function(){return this.getOrThrow(this.amazonPayV2SDK)},e.prototype.getButtonParentContainer=function(){return this.getOrThrow(this.buttonParentContainer)},e.prototype.getAmazonPayV2Button=function(){return this.getOrThrow(this.amazonPayV2Button)},e.prototype.getOrThrow=function(e){return po(e,(function(){return new fo(ho.PaymentNotInitialized)}))},e}(),wo=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method is not loaded or ready to be used.")||this;return n.name="PaymentMethodClientUnavailableError",n.type="payment_method_client_unavailable",n}return(0,o.__extends)(t,e),t}(s),Eo=function(){function e(e,t){void 0===t&&(t=window),this.scriptLoader=e,this.windowWithAmazonPay=t}return e.prototype.load=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return t=e.initializationData,n=(null==t?void 0:t.region)||"us",r=So[n],[4,this.scriptLoader.loadScript("https://static-"+r+".payments-amazon.com/checkout.js")];case 1:if(i.sent(),!this.windowWithAmazonPay.amazon)throw new wo;return[2,this.windowWithAmazonPay.amazon]}}))}))},e}();var bo,Po,Ao,To,Oo,Ro="3.95.0",Mo="3.95.0-connect-alpha.12",ko="3.101.0-fastlane-beta.7.2";!function(e){e.Sandbox="sandbox",e.Production="production"}(bo||(bo={})),function(e){e.Client="client",e.Connect="connect",e.DataCollector="dataCollector",e.Fastlane="fastlane",e.GooglePayment="googlePayment",e.HostedFields="hostedFields",e.LocalPayment="localPayment",e.Paypal="paypal",e.PaypalCheckout="paypalCheckout",e.ThreeDSecure="threeDSecure",e.UsBankAccount="usBankAccount",e.Venmo="venmo",e.VisaCheckout="visaCheckout"}(Po||(Po={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(Ao||(Ao={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(To||(To={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Oo||(Oo={}));const Do=function(){function e(e,t){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSdkVersion=Ro}return e.prototype.initialize=function(e){var t=null==e?void 0:e.checkoutSettings.features,n=t&&t["PROJECT-5505.PayPal_Accelerated_Checkout_v2_for_Braintree"],r=t&&t["PROJECT-6266.braintree_fastlane"]?ko:Mo;this.braintreeSdkVersion=n?r:Ro},e.prototype.loadClient=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.Client,"client.min.js")]}))}))},e.prototype.loadConnect=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.Connect,"connect.min.js")]}))}))},e.prototype.loadFastlane=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.Fastlane,"fastlane.min.js")]}))}))},e.prototype.loadPaypalCheckout=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.PaypalCheckout,"paypal-checkout.min.js")]}))}))},e.prototype.loadPaypal=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.Paypal,"paypal.min.js")]}))}))},e.prototype.loadBraintreeLocalMethods=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.LocalPayment,"local-payment.min.js")]}))}))},e.prototype.loadDataCollector=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.DataCollector,"data-collector.min.js")]}))}))},e.prototype.loadUsBankAccount=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.UsBankAccount,"us-bank-account.min.js")]}))}))},e.prototype.loadGooglePayment=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.GooglePayment,"google-payment.min.js")]}))}))},e.prototype.load3DS=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.ThreeDSecure,"three-d-secure.min.js")]}))}))},e.prototype.loadVisaCheckout=function(){return this.loadBraintreeModuleOrThrow(Po.VisaCheckout,"visa-checkout.min.js")},e.prototype.loadVenmoCheckout=function(){return this.loadBraintreeModuleOrThrow(Po.Venmo,"venmo.min.js")},e.prototype.loadHostedFields=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this.loadBraintreeModuleOrThrow(Po.HostedFields,"hosted-fields.min.js")]}))}))},e.prototype.loadBraintreeModuleOrThrow=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return(n=this.getBraintreeModule(e))?[2,n]:(r="//js.braintreegateway.com/web/"+this.braintreeSdkVersion+"/js/"+t,i=this.getIntegrityValuesByModuleName(e)[this.braintreeSdkVersion],[4,this.scriptLoader.loadScript(r,i?{async:!0,attributes:{integrity:i,crossorigin:"anonymous"}}:void 0)]);case 1:if(o.sent(),!(n=this.getBraintreeModule(e)))throw new wo;return[2,n]}}))}))},e.prototype.getBraintreeModule=function(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]},e.prototype.getIntegrityValuesByModuleName=function(e){var t,n,r,i,o,a,s,u,c,d,l,p,h;switch(e){case Po.Client:return(t={})[Ro]="sha384-5q9Kkv64ho8xutoRBtnaeRE1Ux47T6+LSRpsRmKrKSq7SiZOXn0Mv2XWXVQvCFJj",t[Mo]="sha384-cpfxkJc2j2IgFLlXdJEhNVkCief/ezpYjc3d/QC7psgcdB7AZRZVSCWBrWHJd8kV",t[ko]="sha384-WFefLU7p2TWWSJ17dsTC2uZF0qylvIUEXI7ZaQiWiMPGHtvQlpjc53WirI93FZtv",t;case Po.Connect:return(n={})[Mo]="sha384-F/Vm+lvAqbrFfTjVSXul1yeJablUdRQXoGSpXX5ub24OKFeMuITbFiY1TTK1QlxY",n;case Po.PaypalCheckout:return(r={})[Ro]="sha384-sozUyB/9Y4TygM5npllDME7tGVRo9/4Fh1clHUiPI1F2Q922yyJsMtL5fcFtZHdT",r[Mo]="sha384-b/Bkr377Yi/i9fGXP9adBSYC+Z2//ruSfUlkIni9AjL/YFeu/ygqtgYyJdAEAsr7",r[ko]="sha384-M5Uymuf5O0lh9Dyu+4soyJzefD1uUsL3m3fakhOuIH6C/FXGvii+XHGSGwQwxeJJ",r;case Po.Paypal:return(i={})[Ro]="sha384-Kw2YNA/MLpnN7vkRO3LOCNB0ZrSgT0UZiucLokB06z+0591xAAWgcf9v8AKjCwCX",i[Mo]="sha384-2T9Nx2wNbrtrj7SFleQU/i/trUmvBvf3Lmj/enmh9KESjit397Vaaps6EkI18MGt",i[ko]="sha384-R9O45bWivOlvh5zNaZeRaL0Vie0i6RgNpcD+anBxCVV0Lasox0rsayskrWpOcckT",i;case Po.LocalPayment:return(o={})[Ro]="sha384-P4U+tVQc9ja0VB3w4O6kTlLtIsBPGgsnFQlEdMYVYlU5BF5QP1aoIUhbmLXi0ewT",o[Mo]="sha384-ARWRFedVLKaSGVUD0YTsHxkzRZ/Cc2BD994a3NqnXoCP+iRM7XeRs1ulS4E+i9ts",o[ko]="sha384-76tfvCYa9NzY9D66qhNk0cwnecFNOIUw/G+uNE4AhOZ/+Nhej6Po/8zvoOElmE/1",o;case Po.DataCollector:return(a={})[Ro]="sha384-MYeeYlFD7uDuhGi2ZmrRth4uLy52c+MmJhlrIeNsZCpstpX3qQJI389DB/a2137k",a[Mo]="sha384-L12Sd8K1LbH+gXLvRG54pH+vdCJUnpepjTb6qG2HiD8NvJYLZS/VjJ671OCXr5Vz",a[ko]="sha384-zpZXyctWw5HY7JwKnhbSRzkOnIkNv8hYoEEyMKkJnpoIT2BijSjiXkNxtSI6lig9",a;case Po.UsBankAccount:return(s={})[Ro]="sha384-fyOBNpf/tlxbtQsgTICLilgs48q2M8n7gHcsGlmDK945m3pGZzmOdoTKSihFxwEe",s[Mo]="sha384-mBAnHTYdpowjxBu8uRyjsdzDxTLpoZohyMvINZYEV3OyonbtFIjB9/k1k4A2vWrC",s[ko]="sha384-WwIPgRv2U5MDKNnHUhlvuwa4xOFjK0U6RfIk07n6QF5N9WX3q2qW1pdIfnEX0P8b",s;case Po.GooglePayment:return(u={})[Ro]="sha384-4ePQT3gULIgtQDyvx+F4rXu9DcyWrOP1dxHCoCO8uESGC8BoDbPVAxDiugVawQjJ",u[Mo]="sha384-OL0G9k2ShrnVAtkmS4Q4Fg7SHi5IxM6B8dgB8GDn1kIcl8rYoGG+FPjrLvfxJO++",u[ko]="sha384-p0G7HnR6D/f81mKyLqCkr9fEwbDWCwwK8lVZmaudReYXt7bGD3mVO0y9HFsZQhfQ",u;case Po.ThreeDSecure:return(c={})[Ro]="sha384-kBYpTT1+KcpIHYwnFE6XY3xQkdmazh9F4r9ufjh/cIFXAZFpP96XYNyW8PvHuiJ8",c[Mo]="sha384-ashYIRvaw82mbN1eOd7B43a0La3ngECGkjMK6qbr7UNYb613xBJipfWnNHahDEj6",c[ko]="sha384-cs4wDHFa3sU5X2n8S/9qte1uPxRPy7Kp/KL14lYurOXbXxMZma0660Gfo0a6AUS1",c;case Po.VisaCheckout:return(d={})[Ro]="sha384-XzzKn9jU+Lvx1tJscq9e+nMRNBybQnSgSTXn1/PS0v6JxOUQlgFIBjI9ER8CODFt",d[Mo]="sha384-YUiwmkaPgw7G/n4k2XVoNjsAtn2J+m8cA5oPhGH7y/o90302cwzLiFS23bNAw1e0",d[ko]="sha384-iMFvsiulnHPuXwzbm5r/DPdATPCPn6J4aVNyTheAvM3e5FLA1j/wZTCAYxM081cP",d;case Po.Venmo:return(l={})[Ro]="sha384-AfqcRXnzzimKHVeUXcJNlB6ti2rmN9UJaZrLFU21pj779Db0zIJtBMdVcwb64NEm",l[Mo]="sha384-CXsbLYSCKdOjrs8CILcaOLBkdI/d7jWlym/+lnzbda8MS/X58DCHrskKp7mPaDxG",l[ko]="sha384-prmYZ8RvB+/Nuld/7DbA6VfQ+vgDVSwR2Bos6s2FPhoOWf4fYW+YnYA0j9G4bS5/",l;case Po.HostedFields:return(p={})[Ro]="sha384-7I4A3VPyzQnBGG7F2aiC9We5tN3Py+cYyPWoqiQJaXCEIVLX2goBaku2lGhZXpyK",p[Mo]="sha384-5l3JvGSYH74qGQJB8IlsrUAqeqrH58vkIkxJoW+LH7O99z4Np2BceIcFvZ46QGld",p[ko]="sha384-0gdeYixIb/qimY4JRVwaybygpjWS7O4NtcwQPEJwFhx0nGBKE+NxbkQXOiTXY5QY",p;case Po.Fastlane:return(h={})[ko]="sha384-Ca2r1xkeRMuYnf7qxF1rf9RrxNNYv/yqkVNZJ8f3CX6vwiagJNl7L65/3zWyu2hH",h;default:throw new Error("Unexpected fileName value")}},e}(),No=function(){function e(e){var t,n,r;this._factories={},this._instances={},this._defaultToken=null!==(t=null==e?void 0:e.defaultToken)&&void 0!==t?t:"default",this._useFallback=null===(n=null==e?void 0:e.useFallback)||void 0===n||n,this._tokenResolver=null!==(r=null==e?void 0:e.tokenResolver)&&void 0!==r?r:function(e){return e}}return e.prototype.get=function(e,t){try{return this._getInstance(e||this._defaultToken,t||e||this._defaultToken)}catch(e){if(!this._useFallback)throw e;return this._getInstance(this._defaultToken,t||this._defaultToken)}},e.prototype.register=function(e,t){if(this._hasFactory(e))throw new Pr("'"+e+"' is already registered.");this._factories[e]=t},e.prototype._hasFactory=function(e){return!!this._factories[e]},e.prototype._hasInstance=function(e){return!!this._instances[e]},e.prototype._getInstance=function(e,t){if(!this._hasInstance(t)){var n=this._tokenResolver(e,Object.keys(this._factories)),r=n&&this._factories[n];if(!r)throw new Pr("'"+e+"' is not registered.");this._instances[t]=r()}return this._instances[t]},e}();var Lo,zo,Fo,Uo,qo,Bo=["buttons","messages"];!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Lo||(Lo={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(zo||(zo={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(Fo||(Fo={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Uo||(Uo={})),function(e){e.PILL="pill",e.RECT="rect"}(qo||(qo={}));const Go=function(e){function t(t){var n=e.call(this,t||"Unsupported browser error")||this;return n.name="UnsupportedBrowserError",n.type="unsupported_browser",n}return(0,o.__extends)(t,e),t}(l),xo=function(){function e(e){this._braintreeScriptLoader=e,this._dataCollectors={},this._window=window}return e.prototype.initialize=function(e,t){this._clientToken=e,this._braintreeScriptLoader.initialize(t)},e.prototype.getClient=function(){var e=this;if(!this._clientToken)throw new Ur(Fr.PaymentNotInitialized);return this._client||(this._client=this._braintreeScriptLoader.loadClient().then((function(t){return t.create({authorization:e._clientToken})}))),this._client},e.prototype.getPaypalCheckout=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,this.getClient()];case 1:return r=o.sent(),[4,this._braintreeScriptLoader.loadPaypalCheckout()];case 2:return i=o.sent(),a={client:r},s=function(r,i){if(r)return n(r);u._window.paypal?t(i):i.loadPayPalSDK(u._getPayPalSDKConfig(e),(function(){return t(i)}))},this._paypalCheckout=i.create(a,s),[2,this._paypalCheckout]}}))}))},e.prototype.getVenmoCheckout=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this._venmoCheckout?[3,3]:[4,this.getClient()];case 1:return n=o.sent(),[4,this._braintreeScriptLoader.loadVenmoCheckout()];case 2:r=o.sent(),i={client:n,allowDesktop:!0,paymentMethodUsage:"multi_use"},a=function(n,r){return n?t(n):r.isBrowserSupported()?void e(r):t(new Go)},this._venmoCheckout=r.create(i,a),o.label=3;case 3:return[2,this._venmoCheckout]}}))}))},e.prototype.get3DS=function(){return this._3ds||(this._3ds=Promise.all([this.getClient(),this._braintreeScriptLoader.load3DS()]).then((function(e){var t=e[0];return e[1].create({client:t,version:2})}))),this._3ds},e.prototype.getDataCollector=function(e){var t=e&&e.paypal?"paypal":"default",n=this._dataCollectors[t];return n||(n=Promise.all([this.getClient(),this._braintreeScriptLoader.loadDataCollector()]).then((function(t){var n=t[0];return t[1].create((0,o.__assign)({client:n,kount:!0},e))})).catch((function(e){if(e&&"DATA_COLLECTOR_KOUNT_NOT_ENABLED"===e.code)return{deviceData:void 0,teardown:function(){return Promise.resolve()}};throw e})),this._dataCollectors[t]=n),n},e.prototype.getVisaCheckout=function(){return this._visaCheckout||(this._visaCheckout=Promise.all([this.getClient(),this._braintreeScriptLoader.loadVisaCheckout()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this._visaCheckout},e.prototype.createHostedFields=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,Promise.all([this.getClient(),this._braintreeScriptLoader.loadHostedFields()])];case 1:return t=r.sent(),n=t[0],[2,t[1].create((0,o.__assign)((0,o.__assign)({},e),{client:n}))]}}))}))},e.prototype.teardown=function(){var e=this;return Promise.all([this._teardown(this._3ds),this._teardown(this._dataCollectors.default),this._teardown(this._dataCollectors.paypal),this._teardown(this._paypalCheckout),this._teardown(this._venmoCheckout),this._teardown(this._visaCheckout)]).then((function(){e._3ds=void 0,e._dataCollectors={},e._paypalCheckout=void 0,e._venmoCheckout=void 0,e._visaCheckout=void 0}))},e.prototype._teardown=function(e){return e?e.then((function(e){return e.teardown()})).catch((function(e){if("METHOD_CALLED_AFTER_TEARDOWN"!==e.code)throw e})):Promise.resolve()},e.prototype._getPayPalSDKConfig=function(e){return(0,o.__assign)((0,o.__assign)({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:Bo.toString(),intent:e.intent})},e}(),Yo=function(e){function t(t){var n=e.call(this,"Unable to synchronize your checkout details with a third party provider. Please try again later.")||this;return n.error=t,n.name="RemoteCheckoutSynchronizationError",n.type="remote_checkout_synchronization",n}return(0,o.__extends)(t,e),t}(l);var Vo,Ho,jo,Wo,Ko,Jo;function Zo(e){var t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}!function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(Vo||(Vo={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Ho||(Ho={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(jo||(jo={})),function(e){e.Long="long",e.Short="short"}(Wo||(Wo={})),function(e){e.Default="default",e.Black="black",e.White="white"}(Ko||(Ko={})),function(e){e.Min="MIN",e.Full="FULL"}(Jo||(Jo={}));const Qo=function(){function e(e,t,n,r,i,o,a){this._store=e,this._paymentMethodActionCreator=t,this._googlePayScriptLoader=n,this._googlePayInitializer=r,this._billingAddressActionCreator=i,this._consignmentActionCreator=o,this._requestSender=a,this._isBuyNowFlow=!1,this._shouldThrowError=!0}return e.prototype.initialize=function(e,t){return this._methodId=e,this._configureWallet(t)},e.prototype.deinitialize=function(){return this._googlePayInitializer.teardown()},e.prototype.createButton=function(e,t,n){if(void 0===t&&(t=Wo.Short),void 0===n&&(n=Ko.Default),!this._googlePayClient)throw new Ur(Fr.PaymentNotInitialized);return this._googlePayClient.createButton({buttonColor:n,buttonType:t,onClick:e})},e.prototype.updatePaymentDataRequest=function(e){var t,n,r,i,a,s,u=this._getPaymentDataRequest();this._paymentDataRequest=(0,o.__assign)((0,o.__assign)((0,o.__assign)({},u),e),{merchantInfo:(0,o.__assign)((0,o.__assign)({},null!==(t=u.merchantInfo)&&void 0!==t?t:{}),null!==(n=e.merchantInfo)&&void 0!==n?n:{}),transactionInfo:(0,o.__assign)((0,o.__assign)({},null!==(r=u.transactionInfo)&&void 0!==r?r:{}),null!==(i=e.transactionInfo)&&void 0!==i?i:{}),shippingAddressParameters:(0,o.__assign)((0,o.__assign)({},null!==(a=u.shippingAddressParameters)&&void 0!==a?a:{}),null!==(s=e.shippingAddressParameters)&&void 0!==s?s:{})})},e.prototype.displayWallet=function(){if(!this._googlePayClient)throw new Ur(Fr.PaymentNotInitialized);return this._googlePayClient.loadPaymentData(this._getPaymentDataRequest())},e.prototype.handleSuccess=function(e){var t=this;return this._googlePayInitializer.parseResponse(e).then((function(e){return t._postForm(e)})).then((function(){return t._updateBillingAddress(e)}))},e.prototype.updateShippingAddress=function(e){return this._store.dispatch(this._consignmentActionCreator.updateAddress(this._mapGooglePayAddressToShippingAddress(e)))},e.prototype.updateBuyNowFlowFlag=function(e){this._isBuyNowFlow=e},e.prototype.updateShouldThrowInvalidError=function(e){this._shouldThrowError=e},e.prototype._configureWallet=function(e){var t,n=this,r=null===(t=this._store.getState().config.getStoreConfig())||void 0===t?void 0:t.checkoutSettings.features,i=r&&r["INT-5826.google_hostname_alias"]?{params:{origin:window.location.hostname}}:void 0,o=this._getMethodId();return this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(o,i)).then((function(t){var r=n._getCheckout(t),i=t.paymentMethods.getPaymentMethod(o),a=!!t.shippingAddress.getShippingAddress();if(!i)throw new Mn(Rn.MissingPaymentMethod);var s=i.config.testMode;return Promise.all([n._googlePayScriptLoader.load(),n._googlePayInitializer.initialize(r,i,a)]).then((function(t){var r=t[0],i=t[1];return n._googlePayClient=n._getGooglePayClient(r,s,e),n._paymentDataRequest=i,n._googlePayClient.isReadyToPay({allowedPaymentMethods:[{type:i.allowedPaymentMethods[0].type,parameters:{allowedAuthMethods:i.allowedPaymentMethods[0].parameters.allowedAuthMethods,allowedCardNetworks:i.allowedPaymentMethods[0].parameters.allowedCardNetworks}}],apiVersion:i.apiVersion,apiVersionMinor:i.apiVersionMinor}).then((function(e){var t=e.result;if(t)return t;if(!n._shouldThrowError)return t;throw new d}))}))}))},e.prototype._getCardInformation=function(e){return(0,o.__assign)({type:e.cardType,number:e.lastFour},(null==e?void 0:e.bin)?{bin:null==e?void 0:e.bin}:{})},e.prototype._getCheckout=function(e){if(!this._isBuyNowFlow){var t=e.checkout.getCheckout();if(!t)throw new Mn(Rn.MissingCheckout);return t}},e.prototype._getPaymentDataRequest=function(){if(!this._paymentDataRequest)throw new Yo;return this._paymentDataRequest},e.prototype._getGooglePayClient=function(e,t,n){if(void 0===t)throw new Mn(Rn.MissingPaymentMethod);var r=t?"TEST":"PRODUCTION";return new e.payments.api.PaymentsClient((0,o.__assign)({environment:r},null!=n?n:{}))},e.prototype._getMethodId=function(){if(!this._methodId)throw new Ur(Fr.PaymentNotInitialized);return this._methodId},e.prototype._mapGooglePayAddressToBillingAddress=function(e,t,n){var r=Zo(e.paymentMethodData.info.billingAddress.name),i=r[0],o=r[1],a=e.paymentMethodData.info.billingAddress.address1,s=e.paymentMethodData.info.billingAddress.locality,u=e.paymentMethodData.info.billingAddress.postalCode,c=e.paymentMethodData.info.billingAddress.countryCode;if(!(i&&a&&s&&u&&c))throw new Mn(Rn.MissingBillingAddress);return{id:t,firstName:i,lastName:o,company:e.paymentMethodData.info.billingAddress.companyName,address1:a,address2:e.paymentMethodData.info.billingAddress.address2+e.paymentMethodData.info.billingAddress.address3,city:s,stateOrProvince:e.paymentMethodData.info.billingAddress.administrativeArea,stateOrProvinceCode:e.paymentMethodData.info.billingAddress.administrativeArea,postalCode:u,countryCode:c,phone:e.paymentMethodData.info.billingAddress.phoneNumber,customFields:[],email:n||e.email}},e.prototype._mapGooglePayAddressToShippingAddress=function(e){var t=Zo(e.name);return{firstName:t[0],lastName:t[1],company:e.companyName,address1:e.address1,address2:e.address2+e.address3,city:e.locality,stateOrProvince:e.administrativeArea,stateOrProvinceCode:e.administrativeArea,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phoneNumber,customFields:[]}},e.prototype._postForm=function(e){var t=e.details,n=this._isBuyNowFlow?this._store.getState().cart.getCartOrThrow().id:void 0;return this._requestSender.post("/checkout.php",{headers:(0,o.__assign)({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},Qn),body:(0,o.__assign)({payment_type:e.type,nonce:e.nonce,tokenFormat:e.tokenFormat,provider:this._getMethodId(),action:"set_external_checkout",card_information:this._getCardInformation(t)},n&&{cart_id:n})})},e.prototype._updateBillingAddress=function(e){var t=this._store.getState().billingAddress.getBillingAddress();if(!t)throw new Mn(Rn.MissingBillingAddress);var n=this._mapGooglePayAddressToBillingAddress(e,t.id,t.email);return this._store.dispatch(this._billingAddressActionCreator.updateAddress(n))},e}();const Xo=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method is not loaded or ready to be used.")||this;return n.name="PaymentMethodClientUnavailableError",n.type="payment_method_client_unavailable",n}return(0,o.__extends)(t,e),t}(l),$o=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(){var e=this;return this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js").then((function(){if(!e._window.google)throw new Xo;return e._window.google}))},e}();function ea(e,t){var n=(0,r.createRequestSender)(),i=(0,$n.getScriptLoader)();return new Qo(e,new Wn(new Xn(n)),new $o(i),t,new nr(new ir(n),new xi(new Yi(n))),new ki(new Ni(n),new lr(n)),n)}const ta=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({type:n,nonce:r,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.storeCountry,u=o.googleMerchantName,c=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:c,merchantName:u},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"adyen",gatewayMerchantId:a}}}],transactionInfo:{countryCode:s,currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),na=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({type:n,nonce:r,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.storeCountry,u=o.googleMerchantName,c=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:c,merchantName:u},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"adyen",gatewayMerchantId:a}}}],transactionInfo:{countryCode:s,currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}();var ra={apiVersion:2,apiVersionMinor:0};const ia=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({type:n,nonce:btoa(r),details:{cardType:o,lastFour:a}})},e.prototype._getGooglePaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",a=t.initializationData,s=a.paymentGatewayId,u=a.storeCountry,c=a.googleMerchantName,d=a.googleMerchantId,l=a.platformToken,p=t.supportedCards,h=this._getPaymentGatewaySpecification(s),f=this._getCardPaymentMethod(h,p);return(0,o.__assign)((0,o.__assign)({},ra),{allowedPaymentMethods:[f],transactionInfo:{totalPriceStatus:Ho.FINAL,totalPrice:i,currencyCode:r,countryCode:u},merchantInfo:{merchantName:c,merchantId:d,authJwt:l},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}})},e.prototype._getPaymentGatewaySpecification=function(e){return{type:"PAYMENT_GATEWAY",parameters:{gateway:"authorizenet",gatewayMerchantId:e}}},e.prototype._getCardPaymentMethod=function(e,t){return{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:e}},e}(),oa=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({nonce:btoa(r),type:n,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.googleMerchantName,u=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"cybersource",gatewayMerchantId:a}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),aa=function(e){function t(t){var n=e.call(this,t||"Unable to proceed because the client library of a payment method has thrown an unexpected error.")||this;return n.name="PaymentMethodFailedError",n.type="payment_method_client_invalid",n}return(0,o.__extends)(t,e),t}(s),sa=function(){function e(e){this._requestSender=e,this._publishableKey="",this._testMode=!0,this._errorMessage="Unable to parse response from GooglePay."}return e.prototype.initialize=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return this._publishableKey=t.initializationData.checkoutcomkey,this._testMode=!!t.config.testMode,[2,this._mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2(e,t.initializationData,n)]}))}))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:try{t=JSON.parse(e.paymentMethodData.tokenizationData.token)}catch(e){throw new Pr(this._errorMessage)}if(!t.signature||!t.protocolVersion||!t.signedMessage)throw new aa(this._errorMessage);return[4,this._convertToken(this._testMode,this._publishableKey,t)];case 1:return n=i.sent(),r={nonce:n.token,type:"CreditCard",description:e.paymentMethodData.description,details:{cardType:e.paymentMethodData.info.cardNetwork,lastFour:e.paymentMethodData.info.cardDetails}},n.token_format&&(r.tokenFormat=n.token_format),[2,r]}}))}))},e.prototype._convertToken=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,this._requestCheckoutcomTokenize(e,t,{type:"googlepay",token_data:n})];case 1:if(!(r=i.sent())||!r.token)throw new aa("Unable to parse response from Checkout.com");return[2,r]}}))}))},e.prototype._requestCheckoutcomTokenize=function(e,t,n){return void 0===n&&(n={}),(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return r=e?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",[4,this._requestSender.post(r,{credentials:!1,body:n,headers:{"Content-Type":Jn.Json,Authorization:t,"X-XSRF-TOKEN":null}})];case 1:return[2,i.sent().body]}}))}))},e.prototype._mapGooglePayCheckoutcomDataRequestToGooglePayDataRequestV2=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"";return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:t.platformToken,merchantId:t.googleMerchantId,merchantName:t.googleMerchantName},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","JCB","MASTERCARD","VISA"],billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"checkoutltd",gatewayMerchantId:t.checkoutcomkey}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),ua=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({nonce:btoa(r),type:n,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.googleMerchantName,u=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"cybersource",gatewayMerchantId:a}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),ca=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({nonce:btoa(r),type:n,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.googleMerchantName,u=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"chase",gatewayMerchantId:a}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),da=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){try{var t=JSON.parse(e.paymentMethodData.tokenizationData.token);return Promise.resolve({nonce:t.id,type:t.type,details:{cardType:t.card.brand,lastFour:t.card.last4}})}catch(e){throw new Pr("Unable to parse response from Google Pay.")}},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=(null==e?void 0:e.consignments)||[],a=t.initializationData,s=a.googleMerchantName,u=a.googleMerchantId,c=a.platformToken,d=a.stripeVersion,l=a.stripePublishableKey,p=a.stripeConnectedAccount,h=a.bopis,f=t.supportedCards,g=o.every((function(e){return e.selectedPickupOption}));return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:c,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:f.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":d,"stripe:publishableKey":l+"/"+p}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!((null==h?void 0:h.enabled)&&g&&"none"===(null==h?void 0:h.requiredAddress)||n),shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),la=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t;try{t=JSON.parse(e.paymentMethodData.tokenizationData.token)}catch(e){throw new Pr("Unable to parse response from Google Pay.")}if(!(t.id&&t.type&&t.card&&t.card.brand&&t.card.last4))throw new aa("Unable to parse response from Google Pay.");return Promise.resolve({nonce:t.id,type:t.type,details:{cardType:t.card.brand,lastFour:t.card.last4}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.cart.currency.decimalPlaces)||2,o=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,i).toFixed(i):"",a=t.initializationData,s=a.googleMerchantName,u=a.googleMerchantId,c=a.platformToken,d=a.stripeVersion,l=a.stripePublishableKey,p=a.stripeConnectedAccount;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:c,merchantId:u,merchantName:s},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"stripe","stripe:version":d,"stripe:publishableKey":l+"/"+p}}}],transactionInfo:{currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:o},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),pa=function(){function e(){}return e.prototype.initialize=function(e,t,n){return Promise.resolve(this._getGooglePayPaymentDataRequest(e,t,n))},e.prototype.teardown=function(){return Promise.resolve()},e.prototype.parseResponse=function(e){var t=e.paymentMethodData,n=t.type,r=t.tokenizationData.token,i=t.info,o=i.cardNetwork,a=i.cardDetails;return Promise.resolve({nonce:btoa(r),type:n,details:{cardType:o,lastFour:a}})},e.prototype._getGooglePayPaymentDataRequest=function(e,t,n){var r=(null==e?void 0:e.cart.currency.code)||"",i=(null==e?void 0:e.outstandingBalance)?(0,m.round)(e.outstandingBalance,2).toFixed(2):"",o=t.initializationData,a=o.gatewayMerchantId,s=o.storeCountry,u=o.googleMerchantName,c=o.googleMerchantId;return{apiVersion:2,apiVersionMinor:0,merchantInfo:{authJwt:o.platformToken,merchantId:c,merchantName:u},allowedPaymentMethods:[{type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:t.supportedCards.map((function(e){return"MC"===e?"MASTERCARD":e})),billingAddressRequired:!0,billingAddressParameters:{format:Jo.Full,phoneNumberRequired:!0}},tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:{gateway:"worldpay",gatewayMerchantId:a}}}],transactionInfo:{countryCode:s,currencyCode:r,totalPriceStatus:Ho.FINAL,totalPrice:i},emailRequired:!0,shippingAddressRequired:!n,shippingAddressParameters:{phoneNumberRequired:!0}}},e}(),ha=function(){function e(e,t){void 0===t&&(t=window),this._scriptLoader=e,this._window=t}return e.prototype.load=function(e){var t=e.useMasterpassSrc,n=e.language,r=e.testMode,i=e.checkoutId;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t?(e=["https://"+(r?"sandbox.":"")+"src.mastercard.com/srci/integration/merchant.js",["locale="+n,"checkoutid="+i].join("&")].join("?"),[4,this._scriptLoader.loadScript(e)]):[3,2];case 1:case 3:if(o.sent(),!this._window.masterpass)throw new Xo;return[2,this._window.masterpass];case 2:return[4,this._scriptLoader.loadScript("//"+(r?"sandbox.":"")+"masterpass.com/integration/merchant.js")]}}))}))},e}(),fa=function(){function e(e){this._scriptLoader=e,this._window=window}return e.prototype.loadPaypal=function(e){return void 0===e&&(e=""),(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t="//www.paypalobjects.com/api/checkout.min.js",n={async:!0,attributes:{"data-merchant-id":e}},e?[4,this._scriptLoader.loadScript(t,n)]:[3,2];case 1:return r.sent(),[3,4];case 2:return[4,this._scriptLoader.loadScript(t)];case 3:r.sent(),r.label=4;case 4:if(!this._window.paypal)throw new Xo;return[2,this._window.paypal]}}))}))},e}(),ma=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during buy now cart creation process. Please try again later.")||this;return n.name="BuyNowCartCreationError",n.type="buy_now_cart_creation_error",n}return(0,o.__extends)(t,e),t}(l);function ga(e){return e instanceof Object&&"buyNowInitializeOptions"in e}const ya=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during config creation process. Please try again later.")||this;return n.name="AmazonPayV2ConfigCreationError",n.type="amazon_pay_v2_config_creation_error",n}return(0,o.__extends)(t,e),t}(l),_a=function(){function e(e,t,n,r,i){this._store=e,this._checkoutActionCreator=t,this._amazonPayV2PaymentProcessor=n,this._cartRequestSender=r,this._amazonPayV2ConfigRequestSender=i}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.methodId,r=e.containerId,i=e.amazonpay,a=(i||{}).buttonColor,!n||!r)throw new Pr('Unable to proceed because "methodId" or "containerId" argument is not provided.');return s=this._store.getState().paymentMethods.getPaymentMethodOrThrow,[4,this._amazonPayV2PaymentProcessor.initialize(s(n))];case 1:return o.sent(),i?[3,3]:[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:o.sent(),o.label=3;case 3:return u=ga(i)?void 0:i,ga(i)&&"function"==typeof(null===(t=null==i?void 0:i.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody)&&(this._buyNowInitializeOptions=i.buyNowInitializeOptions,this._buyNowInitializeOptions&&this._amazonPayV2PaymentProcessor.updateBuyNowFlowFlag(!0)),this._amazonPayV2PaymentProcessor.renderAmazonPayButton({checkoutState:this._store.getState(),containerId:r,methodId:n,options:u,placement:go.Cart,buttonColor:a}),this._buyNowInitializeOptions&&this._amazonPayV2PaymentProcessor.prepareCheckoutWithCreationRequestConfig(this._getCheckoutCreationRequestConfig.bind(this)),[2]}}))}))},e.prototype.deinitialize=function(){return this._amazonPayV2PaymentProcessor.deinitialize()},e.prototype._createBuyNowCart=function(){var e,t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:if(!(n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e)))throw new Mn(Rn.MissingCart);r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(n)];case 2:return[2,r.sent().body];case 3:throw r.sent(),new ma;case 4:return[2]}}))}))},e.prototype._createCheckoutConfig=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return a.trys.push([0,2,,3]),[4,this._amazonPayV2ConfigRequestSender.createCheckoutConfig(e)];case 1:return t=a.sent().body,n=t.payload,r=t.public_key,i=(0,o.__rest)(t,["payload","public_key"]),[2,(0,o.__assign)({payloadJSON:n,publicKeyId:r},i)];case 2:throw a.sent(),new ya;case 3:return[2]}}))}))},e.prototype._getCheckoutCreationRequestConfig=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._createBuyNowCart()];case 1:return(e=n.sent())?(t={amount:String(e.baseAmount),currencyCode:e.currency.code},[4,this._createCheckoutConfig(e.id)]):[3,3];case 2:return[2,{createCheckoutSessionConfig:n.sent(),estimatedOrderAmount:t,productType:0===lo(e)?_o.PayOnly:_o.PayAndShip}];case 3:return[2]}}))}))},e}(),va=function(){function e(e){this._requestSender=e}return e.prototype.createCheckoutConfig=function(e){var t={cartId:e},n=(0,o.__assign)({"X-API-INTERNAL":Zn,"Content-Type":Jn.Json},Qn);return this._requestSender.post("/api/storefront/payment/amazonpay",{headers:n,body:t})},e}();function Ca(e){return{recipientName:e.firstName+" "+e.lastName,line1:e.address1,line2:e.address2,city:e.city,state:e.stateOrProvinceCode,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone}}function Sa(e){var t=e.color,n=e.fundingicons,r=e.height,i=e.layout,o=e.shape,a=e.size,s=e.tagline,u={color:t,fundingicons:n,height:Ia(r),layout:i,shape:o||"rect",size:a,tagline:s};return(0,m.omitBy)(u,m.isNil)}function Ia(e){return"number"!=typeof e||e>55?55:e<25?25:e}function wa(e){var t=e.billingAddress,n=e.email,r=e.firstName,i=e.lastName,o=e.phone,a=e.shippingAddress,s=t||a;return{email:n,first_name:r,last_name:i,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}}function Ea(e){var t=e.email,n=e.phone,r=e.shippingAddress,i=((null==r?void 0:r.recipientName)||"").split(" ");return{email:t,first_name:i[0]||"",last_name:i[1]||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}}const ba=function(){function e(e,t,n,r,i,o){this._store=e,this._checkoutActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._window=o}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f,m,g,y=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreepaypal,n=e.containerId,r=e.methodId,a=(i=t||{}).messagingContainerId,s=i.onError,!r)throw new Pr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Pr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Pr('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');if(!t.buyNowInitializeOptions)return[3,1];if(u=this._store.getState(),c=u.paymentMethods.getPaymentMethodOrThrow(r),!t.currencyCode)throw new Pr('Unable to initialize payment because "options.braintreepaypal.currencyCode" argument is not provided.');return d=t.currencyCode,[3,3];case 1:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:u=o.sent(),c=u.paymentMethods.getPaymentMethodOrThrow(r),d=u.cart.getCartOrThrow().currency.code,o.label=3;case 3:if(l=u.config.getStoreConfig(),p=c.clientToken,h=c.initializationData,!p||!h)throw new Mn(Rn.MissingPaymentMethod);return f={currency:d,intent:h.intent,isCreditEnabled:h.isCreditEnabled},m=function(e){y._renderPayPalComponents(e,t,n,r,Boolean(c.config.testMode))},g=function(e){return y._handleError(e,n,a,s)},this._braintreeSDKCreator.initialize(p,l),[4,this._braintreeSDKCreator.getPaypalCheckout(f,m,g)];case 4:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._renderPayPalComponents=function(e,t,n,r,i){var o=t.messagingContainerId;this._renderPayPalMessages(o),this._renderPayPalButton(e,t,n,r,i)},e.prototype._renderPayPalButton=function(e,t,n,r,i){var o=this,a=t.style,s=t.shouldProcessPayment,u=t.onAuthorizeError,c=this._window.paypal,d=null==c?void 0:c.FUNDING.PAYPAL;if(c&&d){var l=a?Sa(a):{},p=c.Buttons({env:i?"sandbox":"production",commit:!1,fundingSource:d,style:l,createOrder:function(){return o._setupPayment(e,t,r)},onApprove:function(t){return o._tokenizePayment(t,e,r,s,u)}});p.isEligible()&&p.render("#"+n)}else this._removeElement(n)},e.prototype._renderPayPalMessages=function(e){var t=e&&Boolean(document.getElementById(e)),n=this._window.paypal;if(n&&t){var r=this._store.getState().cart.getCartOrThrow();n.Messages({amount:r.cartAmount,placement:"cart"}).render("#"+e)}else this._removeElement(e)},e.prototype._setupPayment=function(e,t,n){var r,i;return(0,o.__awaiter)(this,void 0,void 0,(function(){var a,s,u,c,d,l,p,h,f,m,g,y;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:a=t.buyNowInitializeOptions,s=t.shippingAddress,u=t.onPaymentError,o.label=1;case 1:return o.trys.push([1,7,,8]),d=this,[4,this._createBuyNowCart({buyNowInitializeOptions:a})];case 2:return d._buyNowCart=o.sent(),this._buyNowCart?(c=this._store.getState(),[3,5]):[3,3];case 3:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 4:c=o.sent(),o.label=5;case 5:return l=c.customer.getCustomer(),p=c.paymentMethods.getPaymentMethodOrThrow(n),h=this._buyNowCart?this._buyNowCart.cartAmount:c.checkout.getCheckoutOrThrow().outstandingBalance,f=null!==(r=t.currencyCode)&&void 0!==r?r:c.config.getStoreConfigOrThrow().currency.code,m=s||(null==l?void 0:l.addresses[0]),g=m?Ca(m):void 0,[4,e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:g,amount:h,currency:f,offerCredit:!1,intent:null===(i=p.initializationData)||void 0===i?void 0:i.intent})];case 6:return[2,o.sent()];case 7:throw y=o.sent(),u&&u(y),y;case 8:return[2]}}))}))},e.prototype._createBuyNowCart=function(e){var t=e.buyNowInitializeOptions;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==t?void 0:t.getBuyNowCartRequestBody))return[3,4];if(!(e=t.getBuyNowCartRequestBody()))throw new Mn(Rn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(e)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new ma;case 4:return[2]}}))}))},e.prototype._tokenizePayment=function(e,t,n,r,i){var a;return(0,o.__awaiter)(this,void 0,void 0,(function(){var s,u,c,d,l,p;return(0,o.__generator)(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this._braintreeSDKCreator.getDataCollector({paypal:!0})];case 1:return s=h.sent().deviceData,[4,t.tokenizePayment(e)];case 2:return u=h.sent(),c=u.details,d=u.nonce,l=null===(a=this._buyNowCart)||void 0===a?void 0:a.id,this._formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",provider:n,action:r?"process_payment":"set_external_checkout",nonce:d,device_data:s,billing_address:JSON.stringify(wa(c)),shipping_address:JSON.stringify(Ea(c))},l&&{cart_id:l})),[2,u];case 3:throw p=h.sent(),i&&i(p),p;case 4:return[2]}}))}))},e.prototype._handleError=function(e,t,n,r){this._removeElement(t),this._removeElement(n),r&&r(e)},e.prototype._removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e}();var Pa,Aa,Ta,Oa,Ra;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Pa||(Pa={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Aa||(Aa={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(Ta||(Ta={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Oa||(Oa={})),function(e){e.PILL="pill",e.RECT="rect"}(Ra||(Ra={}));const Ma=function(){function e(e,t,n,r,i,o){this._store=e,this._checkoutActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._window=o}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreepaypalcredit,n=e.containerId,!(r=e.methodId))throw new Pr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new Pr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new Pr('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');if(!t.buyNowInitializeOptions)return[3,1];if(i=this._store.getState(),a=i.paymentMethods.getPaymentMethodOrThrow(r),!t.currencyCode)throw new Pr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');return s=t.currencyCode,[3,3];case 1:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 2:i=o.sent(),a=i.paymentMethods.getPaymentMethodOrThrow(r),s=i.cart.getCartOrThrow().currency.code,o.label=3;case 3:if(u=i.config.getStoreConfig(),c=a.clientToken,d=a.initializationData,!c||!d)throw new Mn(Rn.MissingPaymentMethod);return l={currency:s,intent:d.intent,isCreditEnabled:d.isCreditEnabled},p=function(e){return f._renderPayPalButton(e,t,n,r,Boolean(a.config.testMode))},h=function(e){return f._handleError(e,n,t.onError)},this._braintreeSDKCreator.initialize(c,u),[4,this._braintreeSDKCreator.getPaypalCheckout(l,p,h)];case 4:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._renderPayPalButton=function(e,t,n,r,i){var a=this,s=t.style,u=t.shouldProcessPayment,c=t.onAuthorizeError,d=this._window.paypal,l=!1;if(d){var p=[d.FUNDING.PAYLATER,d.FUNDING.CREDIT],h=s?Sa(s):{};p.forEach((function(s){var p=s===d.FUNDING.CREDIT?(0,o.__assign)({label:Oa.CREDIT},h):h;if(!l){var f=d.Buttons({env:i?"sandbox":"production",commit:!1,fundingSource:s,style:p,createOrder:function(){return a._setupPayment(e,t,r)},onApprove:function(t){return a._tokenizePayment(t,e,r,u,c)}});f.isEligible()&&(f.render("#"+n),l=!0)}}))}d&&l||this._removeElement(n)},e.prototype._setupPayment=function(e,t,n){var r,i;return(0,o.__awaiter)(this,void 0,void 0,(function(){var a,s,u,c,d,l,p,h,f,m,g,y;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:a=t.onPaymentError,s=t.shippingAddress,u=t.buyNowInitializeOptions,o.label=1;case 1:return o.trys.push([1,7,,8]),d=this,[4,this._createBuyNowCart({buyNowInitializeOptions:u})];case 2:return d._buyNowCart=o.sent(),this._buyNowCart?(c=this._store.getState(),[3,5]):[3,3];case 3:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 4:c=o.sent(),o.label=5;case 5:return l=c.customer.getCustomer(),p=c.paymentMethods.getPaymentMethodOrThrow(n),h=this._buyNowCart?this._buyNowCart.cartAmount:c.checkout.getCheckoutOrThrow().outstandingBalance,f=null!==(r=t.currencyCode)&&void 0!==r?r:c.config.getStoreConfigOrThrow().currency.code,m=s||(null==l?void 0:l.addresses[0]),g=m?Ca(m):void 0,[4,e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:g,amount:h,currency:f,offerCredit:!0,intent:null===(i=p.initializationData)||void 0===i?void 0:i.intent})];case 6:return[2,o.sent()];case 7:throw y=o.sent(),a&&a(y),y;case 8:return[2]}}))}))},e.prototype._createBuyNowCart=function(e){var t=e.buyNowInitializeOptions;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==t?void 0:t.getBuyNowCartRequestBody))return[3,4];if(!(e=t.getBuyNowCartRequestBody()))throw new Mn(Rn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(e)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new ma;case 4:return[2]}}))}))},e.prototype._tokenizePayment=function(e,t,n,r,i){var a;return(0,o.__awaiter)(this,void 0,void 0,(function(){var s,u,c,d,l,p;return(0,o.__generator)(this,(function(h){switch(h.label){case 0:return h.trys.push([0,3,,4]),[4,this._braintreeSDKCreator.getDataCollector({paypal:!0})];case 1:return s=h.sent().deviceData,[4,t.tokenizePayment(e)];case 2:return u=h.sent(),c=u.details,d=u.nonce,l=null===(a=this._buyNowCart)||void 0===a?void 0:a.id,this._formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",provider:n,action:r?"process_payment":"set_external_checkout",nonce:d,device_data:s,billing_address:JSON.stringify(wa(c)),shipping_address:JSON.stringify(Ea(c))},l&&{cart_id:l})),[2,u];case 3:throw p=h.sent(),i&&i(p),p;case 4:return[2]}}))}))},e.prototype._handleError=function(e,t,n){this._removeElement(t),n&&n(e)},e.prototype._removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e}();var ka=function(e){var t,n=e.color;return{backgroundColor:(t=n||"",t===Ta.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:'url("/app/assets/img/payment-providers/venmo-logo-'+(n===Ta.WHITE?Ta.BLUE:Ta.WHITE)+'.svg")',backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:"36px",minWidth:"150px",height:"100%",width:"100%",border:n===Ta.WHITE?"1px solid black":"none"}};const Da=function(){function e(e,t,n,r,i){this._store=e,this._paymentMethodActionCreator=t,this._cartRequestSender=n,this._braintreeSDKCreator=r,this._formPoster=i,this._onError=m.noop}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h=this;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.braintreevenmo,n=e.containerId,!(r=e.methodId))throw new Pr('Unable to initialize payment because "options.methodId" argument is not provided.');return[4,this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(r))];case 1:if(i=o.sent(),a=i.config.getStoreConfig(),s=i.paymentMethods.getPaymentMethodOrThrow(r),u=s.clientToken,c=s.initializationData,d=c.paymentButtonStyles,l=(d||{}).cartButtonStyles,p=(null==t?void 0:t.style)||l,!u||!c)throw new Mn(Rn.MissingPaymentMethod);if(!n)throw new Pr('Unable to initialize payment because "options.containerId" argument is not provided.');return this._onError=(null==t?void 0:t.onError)||this._handleError,this._braintreeSDKCreator.initialize(u,a),[4,this._braintreeSDKCreator.getVenmoCheckout((function(e){return h._handleInitializationVenmoSuccess(e,n,null==t?void 0:t.buyNowInitializeOptions,p)}),(function(e){return h._handleInitializationVenmoError(e,n)}))];case 2:return o.sent(),[2]}}))}))},e.prototype.deinitialize=function(){return this._braintreeSDKCreator.teardown(),Promise.resolve()},e.prototype._handleError=function(e){throw new Error(e.message)},e.prototype._handleInitializationVenmoSuccess=function(e,t,n,r){return this._renderVenmoButton(e,t,n,r)},e.prototype._handleInitializationVenmoError=function(e,t){return this._removeVenmoContainer(t),this._onError(e)},e.prototype._removeVenmoContainer=function(e){var t=document.getElementById(e);t&&t.remove()},e.prototype._renderVenmoButton=function(e,t,n,r){var i=this,a=document.getElementById(t),s=(r||{}).color;if(!a)throw new Pr("Unable to create wallet button without valid container ID.");a.setAttribute("aria-label","Venmo"),Object.assign(a.style,ka(r||{})),a.addEventListener("click",(function(){return(0,o.__awaiter)(i,void 0,void 0,(function(){var t,r=this;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return a.setAttribute("disabled","true"),[4,this._createBuyNowCart(n)];case 1:return t=i.sent(),e.tokenize&&e.tokenize((function(e,n){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return a.removeAttribute("disabled"),e?[2,this._onError(e)]:[4,this._handlePostForm(n,null==t?void 0:t.id)];case 1:return r.sent(),[2]}}))}))})),[2]}}))}))})),s===Ta.BLUE&&(a.addEventListener("mouseenter",(function(){a.style.backgroundColor="#0a7fc2"})),a.addEventListener("mouseleave",(function(){a.style.backgroundColor=ka(r||{}).backgroundColor})))},e.prototype._createBuyNowCart=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,4];if(!(t=e.getBuyNowCartRequestBody()))throw new Mn(Rn.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(t)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new ma;case 4:return[2]}}))}))},e.prototype._handlePostForm=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return[4,this._braintreeSDKCreator.getDataCollector()];case 1:return n=a.sent().deviceData,r=e.nonce,i=e.details,this._formPoster.postForm("/checkout.php",(0,o.__assign)({nonce:r,provider:gi.BRAINTREE_VENMO,payment_type:"paypal",device_data:n,action:"set_external_checkout",billing_address:JSON.stringify(wa(i)),shipping_address:JSON.stringify(Ea(i))},t&&{cart_id:t})),[2]}}))}))},e}(),Na=function(){function e(e,t,n,r,i){this._store=e,this._formPoster=t,this._checkoutActionCreator=n,this._googlePayPaymentProcessor=r,this._cartRequestSender=i}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.containerId,n=e.methodId,r=e.currencyCode,i=this._getGooglePayOptions(e),a=i.buyNowInitializeOptions,!t||!n)throw new so('Unable to proceed because "containerId" argument is not provided.');if(s=this._store.getState(),u=s.paymentMethods.getPaymentMethod(n),c=((null==u?void 0:u.config)||{}).testMode,this._methodId=n,this._isBuyNowFlow=!!a,!this._isBuyNowFlow)return[3,2];if(!r)throw new so('Unable to initialize payment because "options.currencyCode" argument is not provided.');return d=i.buyNowInitializeOptions,this._googlePayPaymentProcessor.updateBuyNowFlowFlag(this._isBuyNowFlow),[4,this._googlePayPaymentProcessor.initialize(this._getMethodId(),this._getGooglePayClientOptions(r,c,d))];case 1:return o.sent(),[3,5];case 2:return[4,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout())];case 3:return o.sent(),[4,this._googlePayPaymentProcessor.initialize(this._getMethodId())];case 4:o.sent(),o.label=5;case 5:return this._walletButton=this._createSignInButton(t,i,r),[2]}}))}))},e.prototype.deinitialize=function(){return this._walletButton&&this._walletButton.parentNode&&(this._walletButton.parentNode.removeChild(this._walletButton),this._walletButton=void 0),this._googlePayPaymentProcessor.deinitialize()},e.prototype._getGooglePayClientOptions=function(e,t,n){var r=this;return{environment:t?"TEST":"PRODUCTION",paymentDataCallbacks:{onPaymentDataChanged:function(t){var i=t.callbackTrigger;return(0,o.__awaiter)(r,void 0,void 0,(function(){var t,r,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(i!==Vo.INITIALIZE)return[2];o.label=1;case 1:return o.trys.push([1,5,,6]),t=this,[4,this._createBuyNowCart(n)];case 2:return t._buyNowCart=o.sent(),this._buyNowCart?(r=this._buyNowCart,a=r.id,s=r.cartAmount,[4,this._store.dispatch(this._checkoutActionCreator.loadCheckout(a))]):[3,4];case 3:return o.sent(),[2,{newTransactionInfo:{currencyCode:e,totalPrice:String(s),totalPriceStatus:Ho.FINAL}}];case 4:return[3,6];case 5:throw u=o.sent(),new ma(u);case 6:return[2]}}))}))}}}},e.prototype._createSignInButton=function(e,t,n){var r=this,i=document.getElementById(e),o=t.buttonType,a=t.buttonColor;if(!i)throw new so("Unable to create sign-in button without valid container ID.");var s=this._googlePayPaymentProcessor.createButton((function(e){return r._handleWalletButtonClick(e,n)}),o,a);return i.appendChild(s),s},e.prototype._getMethodId=function(){if(!this._methodId)throw new fo(ho.PaymentNotInitialized);return this._methodId},e.prototype._getGooglePayOptions=function(e){if(e.methodId===gi.GOOGLEPAY_ADYENV2&&e.googlepayadyenv2)return e.googlepayadyenv2;if(e.methodId===gi.GOOGLEPAY_ADYENV3&&e.googlepayadyenv3)return e.googlepayadyenv3;if(e.methodId===gi.GOOGLEPAY_AUTHORIZENET&&e.googlepayauthorizenet)return e.googlepayauthorizenet;if(e.methodId===gi.GOOGLEPAY_BNZ&&e.googlepaybnz)return e.googlepaybnz;if(e.methodId===gi.GOOGLEPAY_BRAINTREE&&e.googlepaybraintree)return e.googlepaybraintree;if(e.methodId===gi.GOOGLEPAY_CHECKOUTCOM&&e.googlepaycheckoutcom)return e.googlepaycheckoutcom;if(e.methodId===gi.GOOGLEPAY_CYBERSOURCEV2&&e.googlepaycybersourcev2)return e.googlepaycybersourcev2;if(e.methodId===gi.GOOGLEPAY_ORBITAL&&e.googlepayorbital)return e.googlepayorbital;if(e.methodId===gi.GOOGLEPAY_STRIPE&&e.googlepaystripe)return e.googlepaystripe;if(e.methodId===gi.GOOGLEPAY_STRIPEUPE&&e.googlepaystripeupe)return e.googlepaystripeupe;if(e.methodId===gi.GOOGLEPAY_WORLDPAYACCESS&&e.googlepayworldpayaccess)return e.googlepayworldpayaccess;throw new so},e.prototype._createBuyNowCart=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,4];if(!(t=e.getBuyNowCartRequestBody()))throw new co(uo.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._cartRequestSender.createBuyNowCart(t)];case 2:return[2,n.sent().body];case 3:throw n.sent(),new ma;case 4:return[2]}}))}))},e.prototype._handleWalletButtonClick=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:e.preventDefault(),i.label=1;case 1:return i.trys.push([1,7,,8]),this._isBuyNowFlow&&t&&this._googlePayPaymentProcessor.updatePaymentDataRequest({transactionInfo:{currencyCode:t,totalPrice:"0",totalPriceStatus:Ho.ESTIMATED},callbackIntents:[jo.OFFER]}),[4,this._googlePayPaymentProcessor.displayWallet()];case 2:return n=i.sent(),[4,this._googlePayPaymentProcessor.handleSuccess(n)];case 3:return i.sent(),lo(this._store.getState().cart.getCartOrThrow())>0&&n.shippingAddress?[4,this._googlePayPaymentProcessor.updateShippingAddress(n.shippingAddress)]:[3,5];case 4:i.sent(),i.label=5;case 5:return[4,this._onPaymentSelectComplete()];case 6:return i.sent(),[3,8];case 7:if((r=i.sent())&&"CANCELED"!==r.message)throw r;return[3,8];case 8:return[2]}}))}))},e.prototype._onPaymentSelectComplete=function(){var e,t=null===(e=this._buyNowCart)||void 0===e?void 0:e.id;this._formPoster.postForm("/checkout.php",(0,o.__assign)({headers:(0,o.__assign)({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},Qn)},t&&{action:"set_external_checkout",provider:this._methodId,cart_id:t}))},(0,o.__decorate)([Rr],e.prototype,"_handleWalletButtonClick",null),e}();var La={es:["es_es","es_mx","es_pe","es_co","es_ar","es_cl"],en:["en_us","en_gb","en_ca","en_es","en_fr","en_ie","en_sg","en_au","en_nz","en_my","en_hk","en_th","en_ae","en_sa","en_qa","en_kw","en_za"],pt:["pt_br"],zu:["zu_za"],ar:["ar_sa","ar_ae","ar_qa","ar_kw"],zh:["zh_sg","zh_hk"],ms:["ms_my"],uk:["uk_ua"],sv:["sv_se"],hr:["hr_hr"],pl:["pl_pl"],nl:["nl_be"],it:["it_it"],de:["de_de"],fr:["fr_fr","fr_ca"]};function za(e){var t=e.replace("-","_").toLowerCase().split("_"),n=t[0],r=n+"_"+t[1],i=La[n];return i?i.indexOf(r)>-1?r:i[0]:"en_us"}const Fa=function(){function e(e,t,n,r){this._store=e,this._checkoutActionCreator=t,this._masterpassScriptLoader=n,this._locale=r}return e.prototype.initialize=function(e){var t=this,n=e.containerId,r=e.methodId;if(!n||!r)throw new Pr('Unable to proceed because "containerId" argument is not provided.');return this._methodId=r,this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then((function(e){var n=e.paymentMethods.getPaymentMethod(r);if(!n||!n.initializationData.checkoutId)throw new Mn(Rn.MissingPaymentMethod);var i={useMasterpassSrc:n.initializationData.isMasterpassSrcEnabled,language:za(t._locale),testMode:n.config.testMode,checkoutId:n.initializationData.checkoutId};return t._masterpassScriptLoader.load(i)})).then((function(e){t._masterpassClient=e,t._signInButton=t._createSignInButton(n)}))},e.prototype.deinitialize=function(){return this._signInButton&&this._signInButton.parentNode&&(this._signInButton.removeEventListener("click",this._handleWalletButtonClick),this._signInButton.parentNode.removeChild(this._signInButton),this._signInButton=void 0),Promise.resolve()},e.prototype._createSignInButton=function(e){var t=document.getElementById(e),n=this._store.getState(),r=this._methodId?n.paymentMethods.getPaymentMethod(this._methodId):null,i=n.config.getStoreConfig();if(!t)throw new Error("Need a container to place the button");if(!r)throw new Mn(Rn.MissingPaymentMethod);if(!i)throw new Pr("Unable to retrieve store configuration");var o=document.createElement("input");if(o.type="image",r.initializationData.isMasterpassSrcEnabled){var a=r.config.testMode?"sandbox.":"",s=r.initializationData.checkoutId,u=["locale="+za(this._locale),"paymentmethod=master,visa,amex,discover","checkoutid="+s];o.src=["https://"+a+"src.mastercard.com/assets/img/btn/src_chk_btn_126x030px.svg",u.join("&")].join("?")}else o.src="https://static.masterpass.com/dyn/img/btn/global/mp_chk_btn_160x037px.svg";return t.appendChild(o),o.addEventListener("click",this._handleWalletButtonClick),o},e.prototype._createMasterpassPayload=function(){var e=this._store.getState(),t=e.checkout.getCheckout(),n=this._methodId?e.paymentMethods.getPaymentMethod(this._methodId):null;if(!t)throw new Mn(Rn.MissingCheckout);if(!n)throw new Mn(Rn.MissingPaymentMethod);return{checkoutId:n.initializationData.checkoutId,allowedCardTypes:n.initializationData.allowedCardTypes,amount:t.cart.cartAmount.toString(),currency:t.cart.currency.code,cartId:t.cart.id,callbackUrl:("cart",window.location.origin+"/checkout.php?action=set_external_checkout&provider=masterpass&gateway=stripe&origin=cart")}},e.prototype._handleWalletButtonClick=function(){if(!this._masterpassClient)throw new Ur(Fr.CheckoutButtonNotInitialized);this._masterpassClient.checkout(this._createMasterpassPayload())},(0,o.__decorate)([Rr],e.prototype,"_handleWalletButtonClick",null),e}(),Ua=function(){function e(e,t,n,r,i){void 0===i&&(i=""),this._store=e,this._checkoutActionCreator=t,this._paypalScriptLoader=n,this._formPoster=r,this._host=i}return e.prototype.initialize=function(e){var t=this,n=e.paypal,r=this._store.getState(),i=this._paymentMethod=r.paymentMethods.getPaymentMethod(e.methodId);if(!n)throw new Pr;if(!i)throw new Mn(Rn.MissingPaymentMethod);return this._paypalScriptLoader.loadPaypal(i.config.merchantId).then((function(r){var a,s,u;if(!i||!i.config.merchantId)throw new Mn(Rn.MissingPaymentMethod);var c=i.config.merchantId,d=i.config.testMode?"sandbox":"production",l=((a={})[d]=n.clientId,a),p=r.FUNDING.CREDIT||"credit",h=n.allowCredit?[p]:[],f=n.allowCredit?[]:[p];return r.Button.render({env:d,client:l,commit:n.shouldProcessPayment,funding:{allowed:h,disallowed:f},style:(0,o.__assign)((0,o.__assign)({shape:Ra.RECT},(0,m.pick)(n.style,"layout","color","label","shape","tagline","fundingicons")),{size:"paypalexpress"===i.id&&"small"===(null===(s=n.style)||void 0===s?void 0:s.size)?Aa.RESPONSIVE:null===(u=n.style)||void 0===u?void 0:u.size}),payment:function(e,r){return t._setupPayment(c,r,n.onPaymentError)},onAuthorize:function(e,r){return t._tokenizePayment(e,r,n.shouldProcessPayment,n.onAuthorizeError)}},e.containerId)}))},e.prototype.deinitialize=function(){return this._paymentMethod=void 0,Promise.resolve()},e.prototype._setupPayment=function(e,t,n){var r=this;if(!t)throw new Ur(Fr.CheckoutButtonNotInitialized);return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then((function(n){var i=n.cart.getCart(),a=i?i.id:"";return t.request.post(r._host+"/api/storefront/payment/paypalexpress",{merchantId:e,cartId:a},{headers:(0,o.__assign)({"X-API-INTERNAL":Zn},Qn)})})).then((function(e){return e.id})).catch((function(e){throw n&&n(e),e}))},e.prototype._tokenizePayment=function(e,t,n,r){var i=this;if(!this._paymentMethod)throw new Ur(Fr.CheckoutButtonNotInitialized);if(!t)throw new Ur(Fr.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new Mn(Rn.MissingPayment);var o=this._paymentMethod.id;return t.payment.get(e.paymentID).then((function(t){i._formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:o,action:n?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(t.payer.payer_info)})}))},e}();function qa(){try{return process.env.NODE_ENV||0}catch(e){return"development"}}const Ba=function(){function e(e){this._console=e}return e.prototype.log=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["log"],e))},e.prototype.info=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["info"],e))},e.prototype.warn=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["warn"],e))},e.prototype.error=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["error"],e))},e.prototype.debug=function(){for(var e=[],t=0;t<arguments.length;t++)e[t]=arguments[t];this._logToConsole.apply(this,(0,o.__spreadArrays)(["debug"],e))},e.prototype._logToConsole=function(e){for(var t,n=[],r=1;r<arguments.length;r++)n[r-1]=arguments[r];this._console&&this._console[e]&&(t=this._console[e]).call.apply(t,(0,o.__spreadArrays)([this._console],n))},e}(),Ga=function(){function e(){}return e.prototype.log=function(){},e.prototype.info=function(){},e.prototype.warn=function(){},e.prototype.error=function(){},e.prototype.debug=function(){},e}();var xa,Ya=(void 0===(xa="test"!==qa())&&(xa=!0),xa?new Ba(console):new Ga);const Va=function(){function e(e){void 0===e&&(e=!1),this._useFallback=e,this._registry=new No({tokenResolver:this._resolveToken.bind(this),useFallback:this._useFallback})}return e.prototype.get=function(e){return this._registry.get(this._encodeToken(e))},e.prototype.register=function(e,t){this._registry.register(this._encodeToken(e),t)},e.prototype._encodeToken=function(e){return btoa(JSON.stringify(e))},e.prototype._decodeToken=function(e){return JSON.parse(atob(e))},e.prototype._resolveToken=function(e,t){var n,r=this,i=this._decodeToken(e),o=[];t.forEach((function(e){for(var t=r._decodeToken(e),n={token:e,matches:0,default:!1},a=0,s=Object.entries(t);a<s.length;a++){var u=s[a],c=u[0],d=u[1];if(c in i&&i[c]!==d){n.matches=0;break}c in i&&i[c]===d&&n.matches++,"default"===c&&!0===d&&(n.default=!0)}o.push(n)}));var a=o.sort((function(e,t){return t.matches-e.matches})).filter((function(e){return e.matches>0}));a.length>1&&a[0].matches===a[1].matches&&"development"===qa()&&Ya.warn("The provided query matches at least two strategies with the same specificity. This warning can be resolved by making their resolve ID more specific.");var s=a[0];if(s&&s.token)return s.token;if(this._useFallback){var u=null===(n=o.find((function(e){return e.default})))||void 0===n?void 0:n.token;if(u)return u}throw new Error("Unable to resolve to a registered token with the provided token.")},e}(),Ha=require("@braintree/browser-detection");function ja(e){var t,n,r,i,o,a,s,u,c,d,l,p,h,f,m,g;return{root:{backgroundColorPrimary:Wa(null===(t=null==e?void 0:e.root)||void 0===t?void 0:t.backgroundColorPrimary)||"transparent",errorColor:Wa(null===(n=null==e?void 0:e.root)||void 0===n?void 0:n.errorColor)||"#C40B0B",fontFamily:Wa(null===(r=null==e?void 0:e.root)||void 0===r?void 0:r.fontFamily)||"Montserrat, Helvetica, Arial, sans-serif"},input:{borderRadius:Wa(null===(i=null==e?void 0:e.input)||void 0===i?void 0:i.borderRadius)||"0.25rem",borderColor:Wa(null===(o=null==e?void 0:e.input)||void 0===o?void 0:o.borderColor)||"#9E9E9E",focusBorderColor:Wa(null===(a=null==e?void 0:e.input)||void 0===a?void 0:a.focusBorderColor)||"#4496F6"},toggle:{colorPrimary:Wa(null===(s=null==e?void 0:e.toggle)||void 0===s?void 0:s.colorPrimary)||"#0F005E",colorSecondary:Wa(null===(u=null==e?void 0:e.toggle)||void 0===u?void 0:u.colorSecondary)||"#ffffff"},text:{body:{color:Wa(null===(d=null===(c=null==e?void 0:e.text)||void 0===c?void 0:c.body)||void 0===d?void 0:d.color)||"#222222",fontSize:Wa(null===(p=null===(l=null==e?void 0:e.text)||void 0===l?void 0:l.body)||void 0===p?void 0:p.fontSize)||"1rem"},caption:{color:Wa(null===(f=null===(h=null==e?void 0:e.text)||void 0===h?void 0:h.caption)||void 0===f?void 0:f.color)||"#515151",fontSize:Wa(null===(g=null===(m=null==e?void 0:e.text)||void 0===m?void 0:m.caption)||void 0===g?void 0:g.fontSize)||"1rem"}},branding:Wa(null==e?void 0:e.branding)||"light"}}function Wa(e){return e&&"string"==typeof e?e:null}const Ka=function(){function e(e,t,n){this.braintreeScriptLoader=e,this.braintreeHostWindow=t,this.overlay=n,this.dataCollectors={}}return e.prototype.initialize=function(e,t){this.clientToken=e,this.braintreeScriptLoader.initialize(t)},e.prototype.getBraintreeConnect=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t&&window.localStorage.setItem("axoEnv","sandbox"),this.braintreeHostWindow.braintreeConnect?[3,5]:(r=this.getClientTokenOrThrow(),[4,this.getClient()]);case 1:return i=o.sent(),[4,this.getSessionId(e)];case 2:return a=o.sent(),[4,this.braintreeScriptLoader.loadConnect()];case 3:return s=o.sent(),u=this.braintreeHostWindow,[4,s.create({authorization:r,client:i,deviceData:a,styles:ja(n)})];case 4:u.braintreeConnect=o.sent(),o.label=5;case 5:return[2,this.braintreeHostWindow.braintreeConnect]}}))}))},e.prototype.getBraintreeFastlane=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),this.braintreeHostWindow.braintreeFastlane?[3,5]:(r=this.getClientTokenOrThrow(),[4,this.getClient()]);case 1:return i=o.sent(),[4,this.getSessionId(e)];case 2:return a=o.sent(),[4,this.braintreeScriptLoader.loadFastlane()];case 3:return s=o.sent(),u=this.braintreeHostWindow,[4,s.create({authorization:r,client:i,deviceData:a,styles:ja(n)})];case 4:u.braintreeFastlane=o.sent(),o.label=5;case 5:return[2,this.braintreeHostWindow.braintreeFastlane]}}))}))},e.prototype.getClient=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this.client?[3,2]:(e=this.getClientTokenOrThrow(),[4,this.braintreeScriptLoader.loadClient()]);case 1:t=n.sent(),this.client=t.create({authorization:e}),n.label=2;case 2:return[2,this.client]}}))}))},e.prototype.getPaypal=function(){return this.braintreePaypal||(this.braintreePaypal=Promise.all([this.getClient(),this.braintreeScriptLoader.loadPaypal()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this.braintreePaypal},e.prototype.paypal=function(e){var t=this,n=e.shouldSaveInstrument,r=(0,o.__rest)(e,["shouldSaveInstrument"]),i=(0,Ha.supportsPopups)();return this.getPaypal().then((function(e){var a;return i&&(null===(a=t.overlay)||void 0===a||a.show({onClick:function(){return e.focusWindow()}})),e.tokenize((0,o.__assign)({enableShippingAddress:!0,flow:n?"vault":"checkout",useraction:"commit"},r))})).then((function(e){var n;return null===(n=t.overlay)||void 0===n||n.remove(),e})).catch((function(e){var n;throw null===(n=t.overlay)||void 0===n||n.remove(),e}))},e.prototype.getPaypalCheckout=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u,c=this;return(0,o.__generator)(this,(function(d){switch(d.label){case 0:return[4,this.getClient()];case 1:return r=d.sent(),[4,this.braintreeScriptLoader.loadPaypalCheckout()];case 2:return i=d.sent(),a={client:r},s=function(r,i){if(r)return n(r);var a=(0,o.__assign)((0,o.__assign)({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:Bo.toString(),intent:e.intent});c.braintreeHostWindow.paypal?t(i):i.loadPayPalSDK(a,(function(){return t(i)}))},u=this,[4,i.create(a,s)];case 3:return u.paypalCheckout=d.sent(),[2,this.paypalCheckout]}}))}))},e.prototype.loadBraintreeLocalMethods=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,this.getClient()];case 1:return n=o.sent(),[4,this.braintreeScriptLoader.loadBraintreeLocalMethods()];case 2:return r=o.sent(),this.braintreeLocalMethods?[3,4]:(i=this,[4,r.create({client:n,merchantAccountId:t},(function(t,n){if(t)throw new Error(t.message);e(n)}))]);case 3:i.braintreeLocalMethods=o.sent(),o.label=4;case 4:return[2,this.braintreeLocalMethods]}}))}))},e.prototype.get3DS=function(){return this.threeDS||(this.threeDS=Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]).then((function(e){var t=e[0];return e[1].create({client:t,version:2})}))),this.threeDS},e.prototype.getDataCollector=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:if(t=(null==e?void 0:e.paypal)?"paypal":"default",n=this.dataCollectors[t])return[3,7];u.label=1;case 1:return u.trys.push([1,5,,6]),[4,this.getClient()];case 2:return r=u.sent(),[4,this.braintreeScriptLoader.loadDataCollector()];case 3:return i=u.sent(),a=(0,o.__assign)({client:r,kount:!0},e),[4,i.create(a)];case 4:return n=u.sent(),[3,6];case 5:if(c=s=u.sent(),!Boolean("object"==typeof c&&null!==c&&("type"in c||"message"in c||"code"in c))||"DATA_COLLECTOR_KOUNT_NOT_ENABLED"!==s.code)throw s;return n={deviceData:void 0,teardown:function(){return Promise.resolve()}},[3,6];case 6:this.dataCollectors[t]=n,u.label=7;case 7:return[2,n]}var c}))}))},e.prototype.getGooglePaymentComponent=function(){return this.googlePay||(this.googlePay=Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]).then((function(e){var t=e[0];return e[1].create({client:t})}))),this.googlePay},e.prototype.getBraintreeEnv=function(e){return void 0===e&&(e=!1),e?bo.Sandbox:bo.Production},e.prototype.mapToBraintreeShippingAddressOverride=function(e){return{recipientName:e.firstName+" "+e.lastName,line1:e.address1,line2:e.address2,city:e.city,state:e.stateOrProvinceCode,postalCode:e.postalCode,countryCode:e.countryCode,phone:e.phone}},e.prototype.mapToLegacyShippingAddress=function(e){var t=e.email,n=e.phone,r=e.shippingAddress,i=((null==r?void 0:r.recipientName)||"").split(" ");return{email:t,first_name:i[0]||"",last_name:i[1]||"",phone_number:n,address_line_1:null==r?void 0:r.line1,address_line_2:null==r?void 0:r.line2,city:null==r?void 0:r.city,state:null==r?void 0:r.state,country_code:null==r?void 0:r.countryCode,postal_code:null==r?void 0:r.postalCode}},e.prototype.mapToLegacyBillingAddress=function(e){var t=e.billingAddress,n=e.email,r=e.firstName,i=e.lastName,o=e.phone,a=e.shippingAddress,s=t||a;return{email:n,first_name:r,last_name:i,phone_number:o,address_line_1:null==s?void 0:s.line1,address_line_2:null==s?void 0:s.line2,city:null==s?void 0:s.city,state:null==s?void 0:s.state,country_code:null==s?void 0:s.countryCode,postal_code:null==s?void 0:s.postalCode}},e.prototype.removeElement=function(e){var t=e&&document.getElementById(e);t&&t.remove()},e.prototype.getSessionId=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this.getDataCollector({riskCorrelationId:e})];case 1:return[2,t.sent().deviceData]}}))}))},e.prototype.teardown=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this.teardownModule(this.dataCollectors.default)];case 1:return e.sent(),[4,this.teardownModule(this.dataCollectors.paypal)];case 2:return e.sent(),this.dataCollectors={},[4,this.teardownModule(this.paypalCheckout)];case 3:return e.sent(),this.paypalCheckout=void 0,[2]}}))}))},e.prototype.teardownModule=function(e){return e?e.teardown():Promise.resolve()},e.prototype.getClientTokenOrThrow=function(){if(!this.clientToken)throw new fo(ho.PaymentNotInitialized);return this.clientToken},e}();function Ja(e,t){return Object.assign(e,{resolveIds:t})}const Za=function(e){function t(t){var n=e.call(this,t||"Payment process was cancelled.")||this;return n.name="PaymentMethodCancelledError",n.type="payment_cancelled",n}return(0,o.__extends)(t,e),t}(s);const Qa=function(e){function t(t){var n=e.call(this,t||"An unexpected error has occurred during buy now cart creation process. Please try again later.")||this;return n.name="BuyNowCartCreationError",n.type="buy_now_cart_creation_error",n}return(0,o.__extends)(t,e),t}(s);var Xa;function $a(e){if(!function(e){return"ApplePaySession"in e}(e))throw new Error("Apple pay is not supported")}!function(e){e.BRAINTREE="braintree"}(Xa||(Xa={}));const es=function(){function e(){}return e.prototype.create=function(e){return $a(window),new ApplePaySession(1,e)},e}();var ts;!function(e){e.Subtotal="Subtotal",e.Shipping="Shipping"}(ts||(ts={}));const ns=function(){function e(e,t,n,r){this._requestSender=e,this._paymentIntegrationService=t,this._sessionFactory=n,this._braintreeIntegrationService=r,this._onAuthorizeCallback=m.noop,this._subTotalLabel=ts.Subtotal,this._shippingLabel=ts.Shipping}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.methodId,r=e.containerId,i=e.applepay,$a(window),!n||!i)throw new co(uo.MissingPaymentMethod);return a=i.buttonClassName,s=i.onPaymentAuthorize,u=i.buyNowInitializeOptions,c=i.requiresShipping,this._requiresShipping=c,this._buyNowInitializeOptions=u,this._onAuthorizeCallback=s,u?[3,2]:[4,this._paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return[4,this._paymentIntegrationService.loadPaymentMethod(n)];case 3:return o.sent(),d=this._paymentIntegrationService.getState(),this._paymentMethod=d.getPaymentMethodOrThrow(n),d.getCart()?[4,this._paymentIntegrationService.verifyCheckoutSpamProtection()]:[3,5];case 4:o.sent(),o.label=5;case 5:return(null===(t=this._paymentMethod.initializationData)||void 0===t?void 0:t.gateway)!==Xa.BRAINTREE?[3,7]:[4,this._initializeBraintreeIntegrationService()];case 6:o.sent(),o.label=7;case 7:return this._applePayButton=this._createButton(r,a),this._applePayButton.addEventListener("click",this._handleWalletButtonClick.bind(this)),[2,Promise.resolve()]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype._createButton=function(e,t){void 0===t&&(t="apple-pay-checkout-button");var n=document.getElementById(e);if(!n)throw new so("Unable to create wallet button without valid container ID.");document.body.classList.add("apple-pay-supported");var r=document.createElement("div");return r.setAttribute("class",t),r.setAttribute("role","button"),r.setAttribute("aria-label","Apple Pay button"),n.appendChild(r),r},e.prototype._handleWalletButtonClick=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d,l,p,h,f;return(0,o.__generator)(this,(function(o){if(e.preventDefault(),!this._paymentMethod||!this._paymentMethod.initializationData)throw new co(uo.MissingPaymentMethod);return this._buyNowInitializeOptions&&"function"==typeof this._buyNowInitializeOptions.getBuyNowCartRequestBody?(n=this._paymentMethod.initializationData,r=n.countryCode,i=n.currencyCode,a=n.merchantCapabilities,s=n.supportedNetworks,u=n.storeName,h=this._getRequestWithEmptyTotal(r,i,s,a),this._requiresShipping&&(null===(t=h.requiredShippingContactFields)||void 0===t||t.push("postalAddress")),f=this._sessionFactory.create(h),this._handleApplePayEvents(f,this._paymentMethod,u),f.begin()):(c=this._paymentIntegrationService.getState(),d=c.getCartOrThrow(),l=c.getStoreConfigOrThrow(),p=c.getCheckoutOrThrow(),h=this._getBaseRequest(d,p,l,this._paymentMethod),f=this._sessionFactory.create(h),this._handleApplePayEvents(f,this._paymentMethod,l.storeProfile.storeName),f.begin()),[2]}))}))},e.prototype._getRequestWithEmptyTotal=function(e,t,n,r){return{countryCode:e,currencyCode:t,supportedNetworks:n,merchantCapabilities:r,total:{label:"",amount:"0",type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"]}},e.prototype._getBaseRequest=function(e,t,n,r){var i,o=n.storeProfile,a=o.storeCountryCode,s=o.storeName,u=e.currency,c=u.code,d=u.decimalPlaces,l=r.initializationData,p=l.merchantCapabilities,h=l.supportedNetworks,f=e.lineItems.physicalItems.length>0,m={requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"],countryCode:a,currencyCode:c,merchantCapabilities:p,supportedNetworks:h,lineItems:[],total:f?{label:s,amount:""+t.grandTotal.toFixed(d),type:"pending"}:{label:s,amount:""+t.grandTotal.toFixed(d),type:"final"}};if(f)null===(i=m.requiredShippingContactFields)||void 0===i||i.push("postalAddress");else{var g=[{label:this._subTotalLabel,amount:""+t.subtotal.toFixed(d)}];t.taxes.forEach((function(e){return g.push({label:e.name,amount:""+e.amount.toFixed(d)})})),m.lineItems=g}return m},e.prototype._handleApplePayEvents=function(e,t,n){var r=this;e.onvalidatemerchant=function(n){return(0,o.__awaiter)(r,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,this._onValidateMerchant(t,n)];case 1:return r=i.sent().body,e.completeMerchantValidation(r),[3,3];case 2:throw i.sent(),new Error("Merchant validation failed");case 3:return[2]}}))}))},this._buyNowInitializeOptions&&!this._requiresShipping&&(e.onpaymentmethodselected=function(){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._createBuyNowCart()];case 1:return t.sent(),this._handlePaymentMethodSelected(e),[2]}}))}))}),e.onshippingcontactselected=function(t){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this._buyNowInitializeOptions&&this._requiresShipping?[4,this._createBuyNowCart()]:[3,2];case 1:r.sent(),r.label=2;case 2:return[4,this._handleShippingContactSelected(e,n,t)];case 3:return r.sent(),[2]}}))}))},e.onshippingmethodselected=function(t){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._handleShippingMethodSelected(e,n,t)];case 1:return r.sent(),[2]}}))}))},e.oncancel=function(){return(0,o.__awaiter)(r,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),e="/remote-checkout/"+t.id+"/signout",[4,this._requestSender.get(e)];case 1:return n.sent(),[4,this._paymentIntegrationService.loadCheckout()];case 2:return[2,n.sent()];case 3:throw n.sent(),new Za;case 4:return[2]}}))}))},e.onpaymentauthorized=function(n){return(0,o.__awaiter)(r,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return[2,this._onPaymentAuthorized(n,e,t)]}))}))}},e.prototype._createBuyNowCart=function(){var e,t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(i.trys.push([0,3,,4]),!(n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e)))throw new co(uo.MissingCart);return[4,this._paymentIntegrationService.createBuyNowCart(n)];case 1:return r=i.sent(),[4,this._paymentIntegrationService.loadCheckout(r.id)];case 2:return i.sent(),[3,4];case 3:throw i.sent(),new Qa;case 4:return[2]}}))}))},e.prototype._handlePaymentMethodSelected=function(e){var t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow(),r=t.getStoreConfigOrThrow(),i=t.getCheckoutOrThrow();if(!this._paymentMethod||!this._paymentMethod.initializationData)throw new co(uo.MissingPaymentMethod);var o=this._getBaseRequest(n,i,r,this._paymentMethod);delete o.total.type,e.completePaymentMethodSelection({newTotal:o.total,newLineItems:o.lineItems})},e.prototype._handleShippingContactSelected=function(e,t,n){var r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l,p,h,f,m,g;return(0,o.__generator)(this,(function(y){switch(y.label){case 0:i=this._transformContactToAddress(n.shippingContact),y.label=1;case 1:return y.trys.push([1,3,,4]),[4,this._paymentIntegrationService.updateShippingAddress(i)];case 2:return y.sent(),[3,4];case 3:throw y.sent(),e.abort(),new Error("Shipping address update failed");case 4:if(a=this._paymentIntegrationService.getState(),s=a.getCartOrThrow().currency.decimalPlaces,u=a.getCheckoutOrThrow(),c=null===(r=u.consignments[0].selectedShippingOption)||void 0===r?void 0:r.id,d=u.consignments[0].availableShippingOptions,l=null==d?void 0:d.find((function(e){return e.id===c})),p=null==d?void 0:d.filter((function(e){return e.id!==c})),h=l?[{label:l.description,amount:""+l.cost.toFixed(s),detail:l.additionalDescription,identifier:l.id}]:[],p&&(0,o.__spreadArrays)(p.filter((function(e){return e.isRecommended})),p.filter((function(e){return!e.isRecommended}))).forEach((function(e){return h.push({label:e.description,amount:""+e.cost.toFixed(s),detail:e.additionalDescription,identifier:e.id})})),!(d instanceof Array))throw new Error("Shipping options not available.");if(0===d.length)return e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,[],{type:"pending",label:t,amount:""+u.grandTotal.toFixed(s)},[]),[2];f=d.find((function(e){return e.isRecommended})),m=f?f.id:d[0].id,g=l?l.id:m,y.label=5;case 5:return y.trys.push([5,7,,8]),[4,this._updateShippingOption(g)];case 6:return y.sent(),[3,8];case 7:throw y.sent(),new Error("Shipping options update failed");case 8:return a=this._paymentIntegrationService.getState(),u=a.getCheckoutOrThrow(),e.completeShippingContactSelection({newShippingMethods:h,newTotal:{type:"final",label:t,amount:""+u.grandTotal.toFixed(s)},newLineItems:this._getUpdatedLineItems(u,s)}),[2]}}))}))},e.prototype._handleShippingMethodSelected=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:r=n.shippingMethod.identifier,o.label=1;case 1:return o.trys.push([1,3,,4]),[4,this._updateShippingOption(r)];case 2:return o.sent(),[3,4];case 3:throw o.sent(),e.abort(),new Error("Shipping option selection update failed.");case 4:return i=this._paymentIntegrationService.getState(),a=i.getCartOrThrow().currency.decimalPlaces,s=i.getCheckoutOrThrow(),e.completeShippingMethodSelection({newTotal:{type:"final",label:t,amount:""+s.grandTotal.toFixed(a)},newLineItems:this._getUpdatedLineItems(s,a)}),[2]}}))}))},e.prototype._getUpdatedLineItems=function(e,t){var n=[{label:this._subTotalLabel,amount:""+e.subtotal.toFixed(t)}];return e.taxes.forEach((function(e){return n.push({label:e.name,amount:""+e.amount.toFixed(t)})})),n.push({label:this._shippingLabel,amount:""+e.shippingCostTotal.toFixed(t)}),n},e.prototype._updateShippingOption=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){return[2,this._paymentIntegrationService.selectShippingOption(e)]}))}))},e.prototype._onValidateMerchant=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){return n=["validationUrl="+t.validationURL,"merchantIdentifier="+e.initializationData.merchantId,"displayName="+e.initializationData.storeName,"domainName="+window.location.hostname].join("&"),[2,this._requestSender.post((i=e.initializationData.paymentsUrl,i+"/api/public/v1/payments/applepay/validate_merchant"),{credentials:!1,headers:{Accept:"application/json","Content-Type":"application/x-www-form-urlencoded","X-XSRF-TOKEN":null},body:n})];var i}))}))},e.prototype._onPaymentAuthorized=function(e,t,n){var r;return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d,l,p,h,f,m,g,y;return(0,o.__generator)(this,(function(_){switch(_.label){case 0:return i=e.payment,a=i.token,s=i.billingContact,u=i.shippingContact,c=this._paymentIntegrationService.getState(),d=c.getCartOrThrow(),l=d.lineItems.physicalItems.length>0,(null===(r=n.initializationData)||void 0===r?void 0:r.gateway)!==Xa.BRAINTREE?[3,2]:[4,this._getBraintreeDeviceData()];case 1:p=_.sent(),_.label=2;case 2:h={methodId:n.id,paymentData:{deviceSessionId:p,formattedPayload:{apple_pay_token:{payment_data:a.paymentData,payment_method:a.paymentMethod,transaction_id:a.transactionIdentifier}}}},f=this._transformContactToAddress(s),m=this._transformContactToAddress(u),g=null==u?void 0:u.emailAddress,y=(null==u?void 0:u.phoneNumber)||"",_.label=3;case 3:return _.trys.push([3,9,,10]),[4,this._paymentIntegrationService.updateBillingAddress((0,o.__assign)((0,o.__assign)({},f),{email:g,phone:y}))];case 4:return _.sent(),l?[4,this._paymentIntegrationService.updateShippingAddress(m)]:[3,6];case 5:_.sent(),_.label=6;case 6:return[4,this._paymentIntegrationService.submitOrder({useStoreCredit:!1})];case 7:return _.sent(),[4,this._paymentIntegrationService.submitPayment(h)];case 8:return _.sent(),t.completePayment(ApplePaySession.STATUS_SUCCESS),[2,this._onAuthorizeCallback()];case 9:throw _.sent(),t.completePayment(ApplePaySession.STATUS_FAILURE),new Error("Payment cannot complete");case 10:return[2]}}))}))},e.prototype._transformContactToAddress=function(e){return{firstName:(null==e?void 0:e.givenName)||"",lastName:(null==e?void 0:e.familyName)||"",city:(null==e?void 0:e.locality)||"",company:"",address1:(null==e?void 0:e.addressLines)&&e.addressLines[0]||"",address2:(null==e?void 0:e.addressLines)&&e.addressLines[1]||"",postalCode:(null==e?void 0:e.postalCode)||"",countryCode:(null==e?void 0:e.countryCode)||"",phone:(null==e?void 0:e.phoneNumber)||"",stateOrProvince:(null==e?void 0:e.administrativeArea)||"",stateOrProvinceCode:(null==e?void 0:e.administrativeArea)||"",customFields:[]}},e.prototype._getBraintreeDeviceData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._braintreeIntegrationService.getDataCollector()];case 1:return[2,e.sent().deviceData]}}))}))},e.prototype._initializeBraintreeIntegrationService=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,this._paymentIntegrationService.loadPaymentMethod(Xa.BRAINTREE)];case 1:return e=r.sent(),t=e.getStoreConfig(),(n=e.getPaymentMethodOrThrow(Xa.BRAINTREE)).clientToken&&n.initializationData?(this._braintreeIntegrationService.initialize(n.clientToken,t),[2]):[2]}}))}))},e}(),rs=Ja((function(e){var t=e.getState().getHost,n=window;return new ns((0,r.createRequestSender)({host:t()}),e,new es,new Ka(new Do((0,$n.getScriptLoader)(),n),n))}),[{id:"applepay"}]),is=require("query-string"),os=function(e){function t(t){var n=e.call(this,t||"Not implemented.")||this;return n.name="NotImplementedError",n.type="not_implemented",n}return(0,o.__extends)(t,e),t}(s);var as,ss,us;!function(e){e.SandboxMode="bolt_sandbox",e.StagingMode="bolt_staging",e.DevelopmentMode="bolt_development"}(as||(as={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(ss||(ss={})),function(e){e.Pill="pill",e.Rect="rect"}(us||(us={}));const cs=function(){function e(e,t,n){void 0===n&&(n=window),this.paymentIntegrationService=e,this.boltScriptLoader=t,this.boltHostWindow=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h,f;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.bolt,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.style,!r)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new so('Unable to initialize payment because "options.bolt" argument is not provided.');if(!Boolean(a))throw new os("Only buy now flow is implemented for Bolt button");if(!(null==a?void 0:a.storefrontApiToken)||"string"!=typeof a.storefrontApiToken)throw new so('Unable to initialize payment because "options.storefrontApiToken" argument is not provided.');return u=this.paymentIntegrationService.getState(),c=u.getPaymentMethodOrThrow(r),d=c.initializationData,l=c.config,h=(p=d||{}).publishableKey,f=p.developerConfig,[4,this.boltScriptLoader.loadBoltClient(h,l.testMode,f,"BigCommerce",a.storefrontApiToken)];case 1:return o.sent(),this.renderButton(n,c,s),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r;"function"==typeof(null===(r=this.boltHostWindow.BoltConnect)||void 0===r?void 0:r.setupProductPageCheckout)&&(this.addButtonContainer(e,t,n),this.boltHostWindow.BoltConnect.setupProductPageCheckout())},e.prototype.addButtonContainer=function(e,t,n){var r=document.getElementById(e);if(r){var i=document.createElement("div"),o=document.createElement("object");i.setAttribute("id","product-page-checkout-wrapper"),i.setAttribute("class","bolt-button-wrapper"),i.setAttribute("style","display:none"),i.setAttribute("data-tid","product-page-checkout-wrapper"),o.setAttribute("data",this.getBoltObjectData(t,n)),o.setAttribute("class","bolt-product-checkout-button"),i.append(o),r.innerHTML="",r.append(i)}},e.prototype.getBoltObjectData=function(e,t){var n=e.initializationData,r=e.config,i=n||{},o=i.publishableKey,a=i.developerConfig,s=this.boltScriptLoader.getDomainURL(!!r.testMode,a),u=this.getButtonHeight(null==t?void 0:t.size),c=this.getButtonBorderRadius(null==t?void 0:t.shape,u);return(0,is.stringifyUrl)({url:"https://"+s+"/v1/checkout_button",query:{publishable_key:o,variant:"ppc",height:u,border_radius:c}})},e.prototype.getButtonHeight=function(e){if(e)switch(e){case ss.Small:return 25;case ss.Large:return 45;case ss.Medium:default:return 40}},e.prototype.getButtonBorderRadius=function(e,t){if(e)switch(e){case us.Pill:return t?Math.round(t/2):void 0;case us.Rect:default:return 4}},e}(),ds=function(){function e(e,t){void 0===t&&(t=window),this.scriptLoader=e,this.boltHostWindow=t}return e.prototype.loadBoltClient=function(e,t,n,r,i){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(this.boltHostWindow.BoltCheckout)return[2,this.boltHostWindow.BoltCheckout];if(!e)throw new so('Unable to initialize payment because "publishableKey" argument is not provided.');return[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/connect-bigcommerce.js",this.getScriptOptions("bolt-connect",e,r,i))];case 1:return o.sent(),[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/track.js",this.getScriptOptions("bolt-track",e))];case 2:if(o.sent(),!this.boltHostWindow.BoltCheckout)throw new wo;return[2,this.boltHostWindow.BoltCheckout]}}))}))},e.prototype.loadBoltEmbedded=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return r={async:!0,attributes:{id:"bolt-embedded"}},[4,this.scriptLoader.loadScript("//"+this.getDomainURL(!!t,n)+"/embed.js",r)];case 1:if(i.sent(),!this.boltHostWindow.Bolt)throw new wo;return[2,this.boltHostWindow.Bolt(e)]}}))}))},e.prototype.getDomainURL=function(e,t){if(!e)return"connect.bolt.com";if(t)switch(t.developerMode){case as.StagingMode:return"connect-staging.bolt.com";case as.DevelopmentMode:return"connect."+t.developerDomain}return"connect-sandbox.bolt.com"},e.prototype.getScriptOptions=function(e,t,n,r){return{async:!0,attributes:(0,o.__assign)((0,o.__assign)({id:e,"data-publishable-key":t},n&&{"data-shopping-cart-id":n}),r&&{"data-storefront-api-token":r})}},e}(),ls=Ja((function(e){return new cs(e,new ds((0,$n.getScriptLoader)()))}),[{id:"bolt"}]);var ps,hs,fs,ms,gs,ys,_s,vs;function Cs(e){return e in ys}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(ps||(ps={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(hs||(hs={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(fs||(fs={})),function(e){e.pill="pill",e.rect="rect"}(ms||(ms={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(gs||(gs={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(ys||(ys={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(_s||(_s={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(vs||(vs={}));const Ss=function(){function e(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1}return e.prototype.mapToShippingAddressRequestBody=function(e){var t=e.shippingAddress;if(t){var n=this._paymentIntegrationService.getState().getShippingAddress()||{},r=n.company,i=void 0===r?"":r,o=n.phone,a=void 0===o?"":o;return this._mapToAddressRequestBody(t,i,a)}},e.prototype.mapToBillingAddressRequestBody=function(e){var t=e.paymentMethodData.info.billingAddress;if(t){var n=this._paymentIntegrationService.getState().getBillingAddress()||{},r=n.company,i=void 0===r?"":r,a=n.phone,s=void 0===a?"":a,u=n.email,c=void 0===u?e.email:u;return(0,o.__assign)((0,o.__assign)({},this._mapToAddressRequestBody(t,i,s)),{email:c})}},e.prototype.mapToExternalCheckoutData=function(e){var t,n=e.paymentMethodData,r=n.tokenizationData.token,i=n.info,a=i.cardNetwork,s=i.cardDetails;return Promise.resolve((0,o.__assign)({nonce:r,card_information:{type:a,number:s}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))},e.prototype.getRequiredData=function(){var e;return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return t={emailRequired:!0},this._isBuyNowFlow?[2,(0,o.__assign)((0,o.__assign)({},t),{shippingAddressRequired:!0,shippingAddressParameters:{phoneNumberRequired:!0}})]:this._isShippingAddressRequired()?[4,this._paymentIntegrationService.loadShippingCountries()]:[3,2];case 1:n=i.sent(),r=null===(e=n.getShippingCountries())||void 0===e?void 0:e.map((function(e){return e.code})),t.shippingAddressRequired=!0,t.shippingAddressParameters=(0,o.__assign)({phoneNumberRequired:!0},r&&{allowedCountryCodes:r}),i.label=2;case 2:return[2,t]}}))}))},e.prototype.getNonce=function(e){var t,n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new co(uo.MissingPaymentToken);return Promise.resolve(n)},e.prototype.extraPaymentData=function(){return Promise.resolve(void 0)},e.prototype.getMerchantInfo=function(){var e=this.getGooglePayInitializationData();return{merchantName:e.googleMerchantName,merchantId:e.googleMerchantId,authJwt:e.platformToken}},e.prototype.getTransactionInfo=function(){return{currencyCode:this._isBuyNowFlow?this._getCurrencyCodeOrThrow():(0,this._paymentIntegrationService.getState().getCartOrThrow)().currency.code,totalPriceStatus:gs.ESTIMATED,totalPrice:"0"}},e.prototype.getPaymentGatewayParameters=function(){var e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new so("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}},e.prototype.getCardParameters=function(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(Cs).map((function(e){return ys[e]})),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}},e.prototype.initialize=function(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()},e.prototype.getGooglePayInitializationData=function(){return po(this.getPaymentMethod().initializationData,(function(){return new so("Missing initialization data.")}))},e.prototype.getPaymentMethod=function(){return po(this._getPaymentMethodFn,(function(){return new fo(ho.PaymentNotInitialized)}))()},e.prototype.getGatewayIdentifier=function(){return this._gatewayIdentifier},e.prototype.setGatewayIdentifier=function(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()},e.prototype._isShippingAddressRequired=function(){var e,t,n=this._paymentIntegrationService.getState(),r=n.getCartOrThrow,i=n.getStoreConfig;return void 0===(0,n.getShippingAddress)()&&(e=r(),t=i(),!!e&&(!!e.lineItems.physicalItems.some((function(e){return e.isShippingRequired}))||!!(t&&t.checkoutSettings.features["CHECKOUT-4936.enable_custom_item_shipping"]&&e.lineItems.customItems)&&e.lineItems.customItems.length>0))},e.prototype._mapToAddressRequestBody=function(e,t,n){var r=e.name,i=e.address1,o=e.address2,a=e.address3,s=e.locality,u=e.administrativeArea,c=e.countryCode,d=e.postalCode,l=e.phoneNumber,p=this._getFirstAndLastName(r);return{firstName:p[0],lastName:p[1],company:t,address1:i,address2:(o+" "+a).trim(),city:s,stateOrProvince:u,stateOrProvinceCode:u,countryCode:c,postalCode:d,phone:l||n,customFields:[]}},e.prototype._getFirstAndLastName=function(e){var t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]},e.prototype._getCurrencyCodeOrThrow=function(){return po(this._currencyCode,(function(){return new so('Unable to initialize payment because "options.currencyCode" argument is not provided.')}))},e}(),Is=function(e){function t(t,n){var r=e.call(this,"braintree",t)||this;return r._braintreeService=n,r._service=t,r}return(0,o.__extends)(t,e),t.prototype.initialize=function(t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(l){switch(l.label){case 0:return[4,e.prototype.initialize.call(this,t,n,r)];case 1:if(l.sent(),!(i=e.prototype.getPaymentMethod.call(this)).clientToken||!i.initializationData)throw new co(uo.MissingPaymentMethod);return this._braintreeService.initialize(i.clientToken,this._service.getState().getStoreConfig()),[4,this._braintreeService.getGooglePaymentComponent()];case 2:return a=l.sent(),c=(u=a).createPaymentDataRequest,d=[{merchantInfo:e.prototype.getMerchantInfo.call(this),transactionInfo:e.prototype.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}}],[4,e.prototype.getRequiredData.call(this)];case 3:return s=c.apply(u,[o.__assign.apply(void 0,d.concat([l.sent()]))]),this._paymentGatewayParameters=s.paymentMethodTokenizationParameters.parameters,[2,Promise.resolve()]}}))}))},t.prototype.getNonce=function(t){var n;return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s,u,c,d,l;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return[4,e.prototype.getNonce.call(this,t)];case 1:if(r=o.sent(),i=e.prototype.getPaymentMethod.call(this),a=i.clientToken,s=i.initializationData,!a||!s||!(null===(n=s.card_information)||void 0===n?void 0:n.bin))throw new co(uo.MissingPaymentMethod);return u=s.isThreeDSecureEnabled,c=s.card_information.bin,u?[4,this._braintreeService.get3DS()]:[3,4];case 2:return d=o.sent(),l=this._service.getState().getOrderOrThrow().orderAmount,[4,this._braintreePresent3DSChallenge(d,l,r,c)];case 3:return[2,o.sent().nonce];case 4:return[2,r]}}))}))},t.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return e={},[4,this._getBraintreeDeviceData()];case 1:return[2,(e.deviceSessionId=t.sent(),e)]}}))}))},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:n=i.sent();try{r=JSON.parse(n.nonce)}catch(e){throw new so("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"androidPayCards"in e}(e))throw new co(uo.MissingPaymentToken)}(r),n.nonce=r.androidPayCards[0].nonce,n.card_information.bin=r.androidPayCards[0].details.bin,[2,n]}}))}))},t.prototype.getCardParameters=function(){return e.prototype.getCardParameters.call(this)},t.prototype.getPaymentGatewayParameters=function(){if(!this._paymentGatewayParameters)throw new co(uo.MissingPaymentMethod);return this._paymentGatewayParameters},t.prototype._getBraintreeDeviceData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){switch(e.label){case 0:return[4,this._braintreeService.getDataCollector()];case 1:return[2,e.sent().deviceData]}}))}))},t.prototype._braintreePresent3DSChallenge=function(e,t,n,r){return new Ir(e.verifyCard({amount:t,bin:r,nonce:n,onLookupComplete:function(e,t){t()}})).promise},t}(Ss);var ws;!function(e){e.ADYEN_V2="googlepayadyenv2",e.ADYEN_V3="googlepayadyenv3",e.AUTHORIZE_NET="googlepayauthorizenet",e.BNZ="googlepaybnz",e.BRAINTREE="googlepaybraintree",e.PAYPAL_COMMERCE="googlepaypaypalcommerce",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.WORLDPAY_ACCESS="googlepayworldpayaccess"}(ws||(ws={}));const Es=function(){function e(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.methodId||(l=e.methodId,!Object.values(ws).includes(l)))throw new so('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new so('Unable to proceed because "containerId" is not a valid key.');if(!(n=e[this._getMethodOrThrow()]))throw new so("Unable to proceed without valid options.");r=n.buyNowInitializeOptions,i=n.currencyCode,a=n.buttonColor,s=n.buttonType,u=n.onError,c=this._paymentIntegrationService.getState(),o.label=1;case 1:return o.trys.push([1,2,,4]),d=c.getPaymentMethodOrThrow(this._getMethodOrThrow()),[3,4];case 2:return o.sent(),[4,this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow())];case 3:return c=o.sent(),d=c.getPaymentMethodOrThrow(this._getMethodOrThrow()),[3,4];case 4:if(this._countryCode=null===(t=d.initializationData)||void 0===t?void 0:t.storeCountry,!r)return[3,6];if(!i)throw new so('Unable to initialize payment because "options.currencyCode" argument is not provided.');return this._currencyCode=i,this._buyNowInitializeOptions=r,[4,this._googlePayPaymentProcessor.initialize((function(){return d}),this._getGooglePayClientOptions(),!!r,i)];case 5:return o.sent(),[3,9];case 6:return[4,this._paymentIntegrationService.loadDefaultCheckout()];case 7:return o.sent(),[4,this._googlePayPaymentProcessor.initialize((function(){return d}),this._getGooglePayClientOptions())];case 8:o.sent(),o.label=9;case 9:return this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=a?a:"default",buttonType:null!=s?s:"plain",onClick:this._handleClick(u)}),[2]}var l}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype._handleClick=function(e){var t=this;return function(n){return(0,o.__awaiter)(t,void 0,void 0,(function(){var t,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:n.preventDefault(),i.label=1;case 1:return i.trys.push([1,3,,4]),[4,this._interactWithPaymentSheet()];case 2:return i.sent(),[3,4];case 3:if(t=i.sent(),r=t,"object"==typeof(o=t)&&null!==o&&"statusCode"in o){if("CANCELED"===t.statusCode)throw new Za;r=new aa(JSON.stringify(t))}throw null==e||e(new aa("An error occurred while requesting your Google Pay payment details.")),r;case 4:return[2]}var o}))}))}},e.prototype._interactWithPaymentSheet=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return[4,this._googlePayPaymentProcessor.showPaymentSheet()];case 1:return e=i.sent(),t=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(e),n=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(e),r="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0,t?[4,this._paymentIntegrationService.updateBillingAddress(t)]:[3,3];case 2:i.sent(),i.label=3;case 3:return n?[4,this._paymentIntegrationService.updateShippingAddress(n)]:[3,5];case 4:i.sent(),i.label=5;case 5:return[4,this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),e,r)];case 6:return i.sent(),[2]}}))}))},e.prototype._getGooglePayClientOptions=function(){var e=this;return{paymentDataCallbacks:{onPaymentDataChanged:function(t){var n=t.callbackTrigger;return(0,o.__awaiter)(e,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return n!==vs.INITIALIZE?[2]:this._buyNowInitializeOptions?[2,this._getBuyNowTransactionInfo()]:[2,this._getTransactionInfo()]}))}))}}}},e.prototype._createBuyNowCartOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if("function"!=typeof(null==e?void 0:e.getBuyNowCartRequestBody))return[3,4];t=e.getBuyNowCartRequestBody(),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this._paymentIntegrationService.createBuyNowCart(t)];case 2:return[2,n.sent()];case 3:throw n.sent(),new Qa;case 4:return[2]}}))}))},e.prototype._getBuyNowTransactionInfo=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return a.trys.push([0,4,,5]),e=this,[4,this._createBuyNowCartOrThrow(this._buyNowInitializeOptions)];case 1:return e._buyNowCart=a.sent(),this._buyNowCart?(t=this._buyNowCart,n=t.id,r=t.cartAmount,[4,this._paymentIntegrationService.loadCheckout(n)]):[3,3];case 2:return a.sent(),[2,{newTransactionInfo:(0,o.__assign)((0,o.__assign)({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:String(r),totalPriceStatus:gs.FINAL})}];case 3:return[3,5];case 4:throw i=a.sent(),new Qa(i);case 5:return[2]}}))}))},e.prototype._getTransactionInfo=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n,r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:return[4,this._paymentIntegrationService.loadCheckout()];case 1:return u.sent(),e=this._paymentIntegrationService.getState(),t=e.getCheckoutOrThrow,n=e.getCartOrThrow,r=n().currency,i=r.code,a=r.decimalPlaces,s=(0,m.round)(t().outstandingBalance,a).toFixed(a),[2,{newTransactionInfo:(0,o.__assign)((0,o.__assign)({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:i,totalPriceStatus:gs.FINAL,totalPrice:s})}]}}))}))},e.prototype._getMethodOrThrow=function(){return po(this._methodId,(function(){return new fo(ho.PaymentNotInitialized)}))},e.prototype._getCurrencyCodeOrThrow=function(){return po(this._currencyCode,(function(){return new so('Unable to initialize payment because "options.currencyCode" argument is not provided.')}))},e}();var bs={"X-Checkout-SDK-Version":"1.589.1"};const Ps=function(){function e(e,t,n,r){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=r,this._baseRequest={apiVersion:2,apiVersionMinor:0}}return e.prototype.initialize=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return i=this,[4,this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t)];case 1:return i._paymentsClient=o.sent(),[4,this._gateway.initialize(e,n,r)];case 2:return o.sent(),[4,this._buildPayloads()];case 3:return o.sent(),[4,this._determineReadinessToPay()];case 4:return o.sent(),this._prefetchGooglePaymentData(),[2]}}))}))},e.prototype.getNonce=function(e){return this._gateway.getNonce(e)},e.prototype.extraPaymentData=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(e){return[2,this._gateway.extraPaymentData()]}))}))},e.prototype.addPaymentButton=function(e,t){var n=document.querySelector("#"+e);if(!n)throw new so("Unable to render the Google Pay button to an invalid HTML container element.");var r=this._getPaymentsClient().createButton((0,o.__assign)((0,o.__assign)({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(r)},e.prototype.showPaymentSheet=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){return e=this._getPaymentDataRequest(),[2,this._getPaymentsClient().loadPaymentData(e)]}))}))},e.prototype.setExternalCheckoutXhr=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){return[2,this._setExternalCheckout(e,t)]}))}))},e.prototype.setExternalCheckoutForm=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(r){return[2,this._setExternalCheckout(e,t,!0,n)]}))}))},e.prototype.mapToBillingAddressRequestBody=function(e){return this._gateway.mapToBillingAddressRequestBody(e)},e.prototype.mapToShippingAddressRequestBody=function(e){return this._gateway.mapToShippingAddressRequestBody(e)},e.prototype.processAdditionalAction=function(e){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e):Promise.reject(e)},e.prototype.signOut=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return[4,this._requestSender.get("/remote-checkout/"+e+"/signout")];case 1:return t.sent(),[2]}}))}))},e.prototype._setExternalCheckout=function(e,t,n,r){return void 0===n&&(n=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u=this;return(0,o.__generator)(this,(function(c){switch(c.label){case 0:return i="/checkout.php",s=[{action:"set_external_checkout",provider:e}],[4,this._gateway.mapToExternalCheckoutData(t)];case 1:return a=o.__assign.apply(void 0,s.concat([c.sent()])),n?[2,new Promise((function(e){u._formPoster.postForm(r?r+"/checkout":i,(0,o.__assign)((0,o.__assign)({},a),{card_information:JSON.stringify(a.card_information)}),e)}))]:[4,this._requestSender.post(i,{headers:(0,o.__assign)({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},bs),body:a})];case 2:return c.sent(),[2]}}))}))},e.prototype._prefetchGooglePaymentData=function(){var e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)},e.prototype._determineReadinessToPay=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest())];case 1:if(!1===t.sent().result)throw new aa("Google Pay is not supported by the current device and browser, please try another payment method.");return[3,3];case 2:if((e=t.sent())instanceof aa)throw e;throw new aa;case 3:return[2]}}))}))},e.prototype._buildPayloads=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()},this._cardPaymentMethod=(0,o.__assign)((0,o.__assign)({},this._baseCardPaymentMethod),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:this._gateway.getPaymentGatewayParameters()}}),e=this,t=[(0,o.__assign)((0,o.__assign)({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()})],[4,this._gateway.getRequiredData()];case 1:return e._paymentDataRequest=o.__assign.apply(void 0,[o.__assign.apply(void 0,t.concat([n.sent()])),{callbackIntents:[_s.OFFER]}]),this._isReadyToPayRequest=(0,o.__assign)((0,o.__assign)({},this._baseRequest),{allowedPaymentMethods:[this._baseCardPaymentMethod]}),[2]}}))}))},e.prototype._getBaseCardPaymentMethod=function(){return this._getOrThrow(this._baseCardPaymentMethod)},e.prototype._getPaymentDataRequest=function(){return this._getOrThrow(this._paymentDataRequest)},e.prototype._getIsReadyToPayRequest=function(){return this._getOrThrow(this._isReadyToPayRequest)},e.prototype._getPaymentsClient=function(){return this._getOrThrow(this._paymentsClient)},e.prototype._getOrThrow=function(e){return po(e,(function(){return new fo(ho.PaymentNotInitialized)}))},e}();const As=function(){function e(e){this._scriptLoader=e,this._window=window}return e.prototype.getGooglePaymentsClient=function(e,t){return void 0===e&&(e=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return[4,this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js")];case 1:if(n.sent(),!this._window.google)throw new wo;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient((0,o.__assign)({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),[2,this._paymentsClient]}}))}))},e}();function Ts(){return new As((0,$n.getScriptLoader)())}const Os=Ja((function(e){var t=(0,r.createRequestSender)(),n=window,o=new Ka(new Do((0,$n.getScriptLoader)(),n),n);return new Es(e,new Ps(Ts(),new Is(e,o),t,(0,i.createFormPoster)()))}),[{id:"googlepaybraintree"}]),Rs=function(e){function t(t,n){var r=e.call(this,"paypalsb",t)||this;return r.paypalCommerceScriptLoader=n,r.service=t,r}return(0,o.__extends)(t,e),t.prototype.initialize=function(t,n,r){var i,a,s,u,c;return(0,o.__awaiter)(this,void 0,void 0,(function(){var d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!(d=null!==(a=null===(i=this.service.getState().getStoreConfig())||void 0===i?void 0:i.currency.code)&&void 0!==a?a:r))throw new co(uo.MissingPaymentMethod);return[4,e.prototype.initialize.call(this,t,n,d)];case 1:if(o.sent(),!(l=e.prototype.getPaymentMethod.call(this)).initializationData)throw new co(uo.MissingPaymentMethod);return function(e){if(!function(e){return!!e.initializationData&&"attributionId"in e.initializationData&&"isVenmoEnabled"in e.initializationData&&"isGooglePayEnabled"in e.initializationData&&"isPayPalCreditAvailable"in e.initializationData}(e))throw new co(uo.MissingPaymentMethod)}(l),[4,this.paypalCommerceScriptLoader.getPayPalSDK(l,d)];case 2:return o.sent(),p=this,[4,this.paypalCommerceScriptLoader.getGooglePayConfigOrThrow()];case 3:return p.googlepayConfig=o.sent(),h=this.googlepayConfig.allowedPaymentMethods,this.setGatewayIdentifier(null===(c=null===(u=null===(s=h[0])||void 0===s?void 0:s.tokenizationSpecification)||void 0===u?void 0:u.parameters)||void 0===c?void 0:c.gateway),[2]}}))}))},t.prototype.getPaymentGatewayParameters=function(){if(this.googlepayConfig){var e=this.googlepayConfig.allowedPaymentMethods[0].tokenizationSpecification.parameters.gatewayMerchantId;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e}}return{gateway:this.getGatewayIdentifier()}},t.prototype.mapToExternalCheckoutData=function(t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return[4,e.prototype.mapToExternalCheckoutData.call(this,t)];case 1:return(n=r.sent()).nonce=btoa(n.nonce),[2,n]}}))}))},t}(Ss),Ms=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalSDK=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){return i=this.getPayPalSdkScriptConfigOrThrow(e,t,n),[2,this.loadPayPalSDK(i,r)]}))}))},e.prototype.getGooglePayConfigOrThrow=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e;return(0,o.__generator)(this,(function(t){switch(t.label){case 0:if(!this.window.paypal)throw new wo;return this.googlepayConfig?[3,2]:(e=this,[4,this.window.paypal.Googlepay().config()]);case 1:e.googlepayConfig=t.sent(),t.label=2;case 2:return[2,this.googlepayConfig]}}))}))},e.prototype.loadPayPalSDK=function(e,t){return void 0===t&&(t=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this.window.paypal&&!t?[3,2]:(n=this.transformConfig(e.options),r=this.transformConfig(e.attributes),i=new URLSearchParams(n).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})]);case 1:o.sent(),o.label=2;case 2:if(!this.window.paypal)throw new wo;return[2,this.window.paypal]}}))}))},e.prototype.getPayPalSdkScriptConfigOrThrow=function(e,t,n){void 0===n&&(n=!0);var r=e.id,i=e.clientToken,a=e.initializationData;if(!(null==a?void 0:a.clientId))throw new co(uo.MissingPaymentMethod);var s=a.intent,u=a.clientId,c=a.merchantId,d=a.buyerCountry,l=a.attributionId,p=a.isVenmoEnabled,h=a.isHostedCheckoutEnabled,f=a.isPayPalCreditAvailable,m=a.isDeveloperModeApplicable,g=a.availableAlternativePaymentMethods,y=void 0===g?[]:g,_=a.enabledAlternativePaymentMethods,v=void 0===_?[]:_,C=a.isGooglePayEnabled,S=h||n,I="paypalcommercecreditcards"===r,w=I?["card"]:[],E=I?[]:["card"],b=n?["card-fields"]:[],P=f?["credit","paylater"]:[],A=f?[]:["credit","paylater"],T=n||!S,O=T&&p?["venmo"]:[],R=T&&p?[]:["venmo"],M=T?v:[],k=T?y.filter((function(e){return!v.includes(e)})):y,D=(0,o.__spreadArrays)(E,A,R,k),N=(0,o.__spreadArrays)(w,P,O,M),L=C?["googlepay"]:[];return{options:(0,o.__assign)({"client-id":u,"merchant-id":c,"enable-funding":N.length>0?N:void 0,"disable-funding":D.length>0?D:void 0,commit:S,components:(0,o.__spreadArrays)(["buttons","hosted-fields","messages","payment-fields","legal"],L,b),currency:t,intent:s},m&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":l,"data-client-token":i}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}(),ks=Ja((function(e){return new Es(e,new Ps(Ts(),new Rs(e,new Ms((0,$n.getScriptLoader)())),(0,r.createRequestSender)(),(0,i.createFormPoster)()))}),[{id:"googlepaypaypalcommerce"}]);var Ds,Ns,Ls,zs,Fs,Us,qs;!function(e){e.BuyNow="BUY_NOW"}(Ds||(Ds={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(Ns||(Ns={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Ls||(Ls={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(zs||(zs={})),function(e){e.pill="pill",e.rect="rect"}(Fs||(Fs={})),function(e){e.OXXO="oxxo"}(Us||(Us={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(qs||(qs={}));const Bs=function(){function e(e,t,n,r){this.formPoster=e,this.paymentIntegrationService=t,this.paypalCommerceRequestSender=n,this.paypalCommerceScriptLoader=r}return e.prototype.loadPayPalSdk=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return i=this.paymentIntegrationService.getState(),a=t||i.getCartOrThrow().currency.code,s=i.getPaymentMethodOrThrow(e),u=this,[4,this.paypalCommerceScriptLoader.getPayPalSDK(s,a,n,r)];case 1:return u.paypalSdk=o.sent(),[2,this.paypalSdk]}}))}))},e.prototype.getPayPalSdkOrThrow=function(){if(!this.paypalSdk)throw new wo;return this.paypalSdk},e.prototype.createBuyNowCartOrThrow=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:if(!(t=e.getBuyNowCartRequestBody()))throw new co(uo.MissingCart);n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.paymentIntegrationService.createBuyNowCart(t)];case 2:return[2,n.sent()];case 3:throw n.sent(),new Qa;case 4:return[2]}}))}))},e.prototype.createOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return n=this.paymentIntegrationService.getState().getCartOrThrow().id,[4,this.paypalCommerceRequestSender.createOrder(e,(0,o.__assign)({cartId:n},t))];case 1:return[2,r.sent().orderId]}}))}))},e.prototype.createOrderCardFields=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(s){switch(s.label){case 0:return n=this.paymentIntegrationService.getState().getCartOrThrow().id,[4,this.paypalCommerceRequestSender.createOrder(e,(0,o.__assign)({cartId:n},t))];case 1:return r=s.sent(),i=r.orderId,a=r.setupToken,[2,(0,o.__assign)({orderId:i},a?{setupToken:a}:{})]}}))}))},e.prototype.updateOrder=function(){return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:e=this.paymentIntegrationService.getState(),t=e.getCartOrThrow(),n=e.getConsignmentsOrThrow()[0],r.label=1;case 1:return r.trys.push([1,3,,4]),[4,this.paypalCommerceRequestSender.updateOrder({availableShippingOptions:n.availableShippingOptions,cartId:t.id,selectedShippingOption:n.selectedShippingOption})];case 2:return r.sent(),[3,4];case 3:throw r.sent(),new c;case 4:return[2]}}))}))},e.prototype.getOrderStatus=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,this.paypalCommerceRequestSender.getOrderStatus(e,t)];case 1:return[2,n.sent().status];case 2:throw n.sent(),new c;case 3:return[2]}}))}))},e.prototype.tokenizePayment=function(e,t){var n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new co(uo.MissingOrderId);return this.formPoster.postForm("/checkout.php",(0,o.__assign)({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===Ds.BuyNow&&{cart_id:n.id}))},e.prototype.submitPayment=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return n={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}},[4,this.paymentIntegrationService.submitPayment({methodId:e,paymentData:n})];case 1:return r.sent(),[2]}}))}))},e.prototype.getShippingOptionOrThrow=function(e){var t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],r=n.find((function(e){return e.isRecommended})),i=(e?n.find((function(t){return t.id===e})):n.find((function(e){var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)})))||r||n[0];if(!i)throw new Error("Your order can't be shipped to this address");return i},e.prototype.getAddress=function(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:"",company:"",address1:(null==e?void 0:e.address1)||"",address2:"",city:(null==e?void 0:e.city)||"",countryCode:(null==e?void 0:e.countryCode)||"",postalCode:(null==e?void 0:e.postalCode)||"",stateOrProvince:"",stateOrProvinceCode:(null==e?void 0:e.stateOrProvinceCode)||"",customFields:[]}},e.prototype.getBillingAddressFromOrderDetails=function(e){var t=e.payer;return this.getAddress({firstName:t.name.given_name,lastName:t.name.surname,email:t.email_address,address1:t.address.address_line_1,city:t.address.admin_area_2,countryCode:t.address.country_code,postalCode:t.address.postal_code,stateOrProvinceCode:t.address.admin_area_1})},e.prototype.getShippingAddressFromOrderDetails=function(e){var t,n,r=e.payer,i=(null===(n=null===(t=e.purchase_units[0])||void 0===t?void 0:t.shipping)||void 0===n?void 0:n.address)||{};return this.getAddress({firstName:r.name.given_name,lastName:r.name.surname,email:r.email_address,address1:i.address_line_1,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})},e.prototype.getValidButtonStyle=function(e){var t=e||{},n=t.color,r=t.height,i=t.label,o=t.shape,a={color:n&&zs[n]?n:void 0,height:this.getValidHeight(r),label:i&&Ls[i]?i:void 0,shape:o&&Fs[o]?o:void 0};return(0,m.omitBy)(a,m.isNil)},e.prototype.getValidHeight=function(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40},e.prototype.removeElement=function(e){var t=e&&document.getElementById(e);t&&(t.style.display="none")},e}();var Gs,xs="This API endpoint is for internal use only and may change in the future";!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(Gs||(Gs={}));const Ys=Gs,Vs=function(){function e(e){this.requestSender=e}return e.prototype.createOrder=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(a){switch(a.label){case 0:return n="/api/storefront/payment/"+e,r=t,i=(0,o.__assign)({"X-API-INTERNAL":xs,"Content-Type":Ys.Json},bs),[4,this.requestSender.post(n,{headers:i,body:r})];case 1:return[2,a.sent().body]}}))}))},e.prototype.updateOrder=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return t=e,n=(0,o.__assign)({"X-API-INTERNAL":xs,"Content-Type":Ys.Json},bs),[4,this.requestSender.put("/api/storefront/initialization/paypalcommerce",{headers:n,body:t})];case 1:return[2,r.sent().body]}}))}))},e.prototype.getOrderStatus=function(e,t){return void 0===e&&(e="paypalcommerce"),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return n="/api/storefront/initialization/"+e,r=(0,o.__assign)({"X-API-INTERNAL":xs,"Content-Type":Ys.Json},bs),[4,this.requestSender.get(n,(0,o.__assign)({headers:r},t))];case 1:return[2,i.sent().body]}}))}))},e}(),Hs=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalSDK=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i;return(0,o.__generator)(this,(function(o){return i=this.getPayPalSdkScriptConfigOrThrow(e,t,n),[2,this.loadPayPalSDK(i,r)]}))}))},e.prototype.loadPayPalSDK=function(e,t){return void 0===t&&(t=!1),(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return this.window.paypal&&!t?[3,2]:(n=this.transformConfig(e.options),r=this.transformConfig(e.attributes),i=new URLSearchParams(n).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})]);case 1:o.sent(),o.label=2;case 2:if(!this.window.paypal)throw new wo;return[2,this.window.paypal]}}))}))},e.prototype.getPayPalSdkScriptConfigOrThrow=function(e,t,n){void 0===n&&(n=!0);var r=e.id,i=e.clientToken,a=e.initializationData;if(!(null==a?void 0:a.clientId))throw new co(uo.MissingPaymentMethod);var s=a.intent,u=a.clientId,c=a.merchantId,d=a.buyerCountry,l=a.attributionId,p=a.isVenmoEnabled,h=a.isHostedCheckoutEnabled,f=a.isPayPalCreditAvailable,m=a.isDeveloperModeApplicable,g=a.availableAlternativePaymentMethods,y=void 0===g?[]:g,_=a.enabledAlternativePaymentMethods,v=void 0===_?[]:_,C=a.isGooglePayEnabled,S=h||n,I="paypalcommercecreditcards"===r,w=I?["card"]:[],E=I?[]:["card"],b=f?["credit","paylater"]:[],P=f?[]:["credit","paylater"],A=n||!S,T=A&&p?["venmo"]:[],O=A&&p?[]:["venmo"],R=A?v:[],M=A?y.filter((function(e){return!v.includes(e)})):y,k=C?["googlepay"]:[],D=n?["card-fields"]:[],N=(0,o.__spreadArrays)(E,P,O,M),L=(0,o.__spreadArrays)(w,b,T,R);return{options:(0,o.__assign)({"client-id":u,"merchant-id":c,"enable-funding":L.length>0?L:void 0,"disable-funding":N.length>0?N:void 0,commit:S,components:(0,o.__spreadArrays)(["buttons","hosted-fields","payment-fields","legal"],k,D),currency:t,intent:s},m&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":l,"data-client-token":i}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}(),js=function(e){var t=e.getState().getHost;return new Bs((0,i.createFormPoster)(),e,new Vs((0,r.createRequestSender)({host:t()})),new Hs((0,$n.getScriptLoader)()))},Ws=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(n=e.paypalcommerce,r=e.containerId,i=e.methodId,a=Boolean(null==n?void 0:n.buyNowInitializeOptions),!i)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!r)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.paypalcommerce" argument is not provided.');if(a&&!n.currencyCode)throw new so('Unable to initialize payment because "options.paypalcommerce.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new so('Unable to initialize payment because "options.paypalcommerce.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return a?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return s=a?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(i,s,!1)];case 3:return o.sent(),this.renderButton(r,i,n),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.buyNowInitializeOptions,a=n.style,s=n.onComplete,u=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),c=(this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t).initializationData||{}).isHostedCheckoutEnabled,d={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommerce")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},l={onClick:function(){return r.handleClick(i)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},p={onShippingChange:function(e){return r.onShippingChange(e)},onApprove:function(e,n){return r.onHostedCheckoutApprove(e,n,t,s)}},h=(0,o.__assign)((0,o.__assign)((0,o.__assign)({fundingSource:u.FUNDING.PAYPAL,style:this.paypalCommerceIntegrationService.getValidButtonStyle(a)},d),i&&l),c&&p),f=u.Buttons(h);f.isEligible()?f.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.onHostedCheckoutApprove=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.orderID)throw new co(uo.MissingOrderId);return i=this.paymentIntegrationService.getState(),a=i.getCartOrThrow(),[4,t.order.get()];case 1:s=o.sent(),o.label=2;case 2:return o.trys.push([2,9,,10]),u=this.paypalCommerceIntegrationService.getBillingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateBillingAddress(u)];case 3:return o.sent(),a.lineItems.physicalItems.length>0?(c=this.paypalCommerceIntegrationService.getShippingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateShippingAddress(c)]):[3,6];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:o.sent(),o.label=6;case 6:return[4,this.paymentIntegrationService.submitOrder({},{params:{methodId:n}})];case 7:return o.sent(),[4,this.paypalCommerceIntegrationService.submitPayment(n,e.orderID)];case 8:return o.sent(),r&&"function"==typeof r&&r(),[2,!0];case 9:throw d=o.sent(),new Error(d);case 10:return[2]}}))}))},e.prototype.onShippingChange=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=this.paypalCommerceIntegrationService.getAddress({city:e.shipping_address.city,countryCode:e.shipping_address.country_code,postalCode:e.shipping_address.postal_code,stateOrProvinceCode:e.shipping_address.state}),o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(n)];case 2:return o.sent(),[4,this.paymentIntegrationService.updateShippingAddress(n)];case 3:return o.sent(),r=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(null===(t=e.selected_shipping_option)||void 0===t?void 0:t.id),[4,this.paymentIntegrationService.selectShippingOption(r.id)];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return o.sent(),[3,7];case 6:throw i=o.sent(),new Error(i);case 7:return[2]}}))}))},e}(),Ks=Ja((function(e){return new Ws(e,js(e))}),[{id:"paypalcommerce"}]),Js=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.getPayPalAxo=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.window.paypalAxo?[3,2]:(r=this.getPayPalSdkConnectConfiguration(e,t,n),[4,this.loadPayPalSdk(r)]);case 1:if(i.sent(),!this.window.paypalAxo)throw new wo;i.label=2;case 2:return[2,this.window.paypalAxo]}}))}))},e.prototype.getPayPalFastlaneSdk=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:return this.window.paypalFastlaneSdk?[3,2]:(r=this.getPayPalFastlaneSdkConfiguration(e,t,n),[4,this.loadPayPalSdk(r)]);case 1:if(i.sent(),!this.window.paypalFastlaneSdk)throw new wo;i.label=2;case 2:return[2,this.window.paypalFastlaneSdk]}}))}))},e.prototype.getPayPalMessages=function(e,t){return(0,o.__awaiter)(this,void 0,void 0,(function(){var n;return(0,o.__generator)(this,(function(r){switch(r.label){case 0:return this.window.paypalMessages?[3,2]:(n=this.getPayPalSdkMessagesConfiguration(e,t),[4,this.loadPayPalSdk(n)]);case 1:if(r.sent(),!this.window.paypalMessages)throw new wo;r.label=2;case 2:return[2,this.window.paypalMessages]}}))}))},e.prototype.loadPayPalSdk=function(e){var t=e.options,n=e.attributes;return(0,o.__awaiter)(this,void 0,void 0,(function(){var e,r,i,a;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:return e=this.transformConfig(t),r=this.transformConfig(n),i=new URLSearchParams(e).toString(),a="https://www.paypal.com/sdk/js?"+i,[4,this.scriptLoader.loadScript(a,{async:!0,attributes:r})];case 1:return o.sent(),[2]}}))}))},e.prototype.getPayPalSdkConnectConfiguration=function(e,t,n){var r=e.clientToken,i=e.initializationData;if(!i||!i.clientId)throw new co(uo.MissingPaymentMethod);var o=i.intent,a=i.clientId,s=i.merchantId,u=i.attributionId,c=i.connectClientToken;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["connect"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalAxo","data-partner-attribution-id":u,"data-user-id-token":c||r}}},e.prototype.getPayPalFastlaneSdkConfiguration=function(e,t,n){var r=e.clientToken,i=e.initializationData;if(!i||!i.clientId)throw new co(uo.MissingPaymentMethod);var o=i.intent,a=i.clientId,s=i.merchantId,u=i.attributionId,c=i.connectClientToken;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":u,"data-user-id-token":c||r}}},e.prototype.getPayPalSdkMessagesConfiguration=function(e,t){var n=e.initializationData;if(!n||!n.clientId)throw new co(uo.MissingPaymentMethod);var r=n.clientId,i=n.merchantId,a=n.attributionId,s=n.isDeveloperModeApplicable,u=n.buyerCountry;return{options:(0,o.__assign)({"client-id":r,"merchant-id":i,components:["messages"],currency:t},s&&{"buyer-country":u}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}},e.prototype.transformConfig=function(e){var t={};return Object.keys(e).forEach((function(n){var r,i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=(0,o.__assign)((0,o.__assign)({},t),((r={})[n]=Array.isArray(i)?i.join(","):i,r)))})),t},e}(),Zs=function(){function e(e,t,n){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t,this.paypalCommerceSdk=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d,l,p,h;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercecredit,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.currencyCode,u=i.messagingContainerId,c=!!a,!r)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new so('Unable to initialize payment because "options.paypalcommercecredit" argument is not provided.');if(c&&!s)throw new so('Unable to initialize payment because "options.paypalcommercecredit.currencyCode" argument is not provided.');if(c&&"function"!=typeof(null==a?void 0:a.getBuyNowCartRequestBody))throw new so('Unable to initialize payment because "options.paypalcommercecredit.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return c?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return d=this.paymentIntegrationService.getState(),l=c?s:d.getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,l,!1)];case 3:return o.sent(),this.renderButton(n,r,t),l&&u?(p=d.getPaymentMethodOrThrow(r),[4,this.paypalCommerceSdk.getPayPalMessages(p,l)]):[3,5];case 4:h=o.sent(),this.renderMessages(h,u),o.label=5;case 5:return[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.buyNowInitializeOptions,a=n.style,s=n.onComplete,u=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),c=(this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t).initializationData||{}).isHostedCheckoutEnabled,d={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercecredit")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},l={onClick:function(){return r.handleClick(i)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},p={onShippingChange:function(e){return r.onShippingChange(e)},onApprove:function(e,n){return r.onHostedCheckoutApprove(e,n,t,s)}},h=[u.FUNDING.PAYLATER,u.FUNDING.CREDIT],f=!1;h.forEach((function(t){if(!f){var n=(0,o.__assign)((0,o.__assign)((0,o.__assign)({fundingSource:t,style:r.paypalCommerceIntegrationService.getValidButtonStyle(a)},d),i&&l),c&&p),s=u.Buttons(n);s.isEligible()&&(s.render("#"+e),f=!0)}})),f||this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e.prototype.onHostedCheckoutApprove=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!e.orderID)throw new co(uo.MissingOrderId);return i=this.paymentIntegrationService.getState(),a=i.getCartOrThrow(),[4,t.order.get()];case 1:s=o.sent(),o.label=2;case 2:return o.trys.push([2,9,,10]),u=this.paypalCommerceIntegrationService.getBillingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateBillingAddress(u)];case 3:return o.sent(),a.lineItems.physicalItems.length>0?(c=this.paypalCommerceIntegrationService.getShippingAddressFromOrderDetails(s),[4,this.paymentIntegrationService.updateShippingAddress(c)]):[3,6];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:o.sent(),o.label=6;case 6:return[4,this.paymentIntegrationService.submitOrder({},{params:{methodId:n}})];case 7:return o.sent(),[4,this.paypalCommerceIntegrationService.submitPayment(n,e.orderID)];case 8:return o.sent(),r&&"function"==typeof r&&r(),[2,!0];case 9:throw d=o.sent(),new Error(d);case 10:return[2]}}))}))},e.prototype.onShippingChange=function(e){var t;return(0,o.__awaiter)(this,void 0,void 0,(function(){var n,r,i;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:n=this.paypalCommerceIntegrationService.getAddress({city:e.shipping_address.city,countryCode:e.shipping_address.country_code,postalCode:e.shipping_address.postal_code,stateOrProvinceCode:e.shipping_address.state}),o.label=1;case 1:return o.trys.push([1,6,,7]),[4,this.paymentIntegrationService.updateBillingAddress(n)];case 2:return o.sent(),[4,this.paymentIntegrationService.updateShippingAddress(n)];case 3:return o.sent(),r=this.paypalCommerceIntegrationService.getShippingOptionOrThrow(null===(t=e.selected_shipping_option)||void 0===t?void 0:t.id),[4,this.paymentIntegrationService.selectShippingOption(r.id)];case 4:return o.sent(),[4,this.paypalCommerceIntegrationService.updateOrder()];case 5:return o.sent(),[3,7];case 6:throw i=o.sent(),new Error(i);case 7:return[2]}}))}))},e.prototype.renderMessages=function(e,t){if(t&&document.getElementById(t)){var n={amount:this.paymentIntegrationService.getState().getCartOrThrow().cartAmount,placement:"cart",style:{layout:"text"}};e.Messages(n).render("#"+t)}},e}(),Qs=Ja((function(e){return new Zs(e,js(e),new Js((0,$n.createScriptLoader)()))}),[{id:"paypalcommercecredit"}]),Xs=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercevenmo,n=e.containerId,r=e.methodId,a=(i=t||{}).buyNowInitializeOptions,s=i.currencyCode,u=!!a,!r)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new so('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');if(u&&!s)throw new so('Unable to initialize payment because "options.paypalcommercevenmo.currencyCode" argument is not provided.');if(u&&"function"!=typeof(null==a?void 0:a.getBuyNowCartRequestBody))throw new so('Unable to initialize payment because "options.paypalcommercevenmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return u?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return c=u?s:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,c,!1)];case 3:return o.sent(),this.renderButton(n,r,t),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.buyNowInitializeOptions,a=n.style,s=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),u=s.FUNDING.VENMO,c={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercevenmo")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},d={onClick:function(){return r.handleClick(i)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},l=(0,o.__assign)((0,o.__assign)({fundingSource:u,style:this.getValidVenmoButtonStyles(a)},c),i&&d),p=s.Buttons(l);p.isEligible()?p.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.getValidVenmoButtonStyles=function(e){var t=this.paypalCommerceIntegrationService.getValidButtonStyle(e);return t.color===zs.gold?(0,o.__assign)((0,o.__assign)({},t),{color:void 0}):t},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e}(),$s=Ja((function(e){return new Xs(e,js(e))}),[{id:"paypalcommercevenmo"}]),eu=function(){function e(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r,i,a,s,u,c,d;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(t=e.paypalcommercealternativemethods,n=e.containerId,r=e.methodId,a=(i=t||{}).apm,s=i.buyNowInitializeOptions,u=i.currencyCode,c=!!s,!r)throw new so('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new so('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new so('Unable to initialize payment because "options.paypalcommercealternativemethods" argument is not provided.');if(!a)throw new so('Unable to initialize payment because "options.paypalcommercealternativemethods.apm" argument is not provided.');if(c&&!u)throw new so('Unable to initialize payment because "options.paypalcommercealternativemethods.currencyCode" argument is not provided.');if(c&&"function"!=typeof(null==s?void 0:s.getBuyNowCartRequestBody))throw new so('Unable to initialize payment because "options.paypalcommercealternativemethods.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');return c?[3,2]:[4,this.paymentIntegrationService.loadDefaultCheckout()];case 1:o.sent(),o.label=2;case 2:return d=c?u:this.paymentIntegrationService.getState().getCartOrThrow().currency.code,[4,this.paypalCommerceIntegrationService.loadPayPalSdk(r,d,!1)];case 3:return o.sent(),this.renderButton(n,r,t),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t,n){var r=this,i=n.apm,a=n.buyNowInitializeOptions,s=n.style,u=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow();if(!Object.values(u.FUNDING).includes(i))throw new so('Unable to initialize PayPal button because "options.paypalcommercealternativemethods.apm" argument is not valid funding source.');var c={createOrder:function(){return r.paypalCommerceIntegrationService.createOrder("paypalcommercealternativemethod")},onApprove:function(e){var n=e.orderID;return r.paypalCommerceIntegrationService.tokenizePayment(t,n)}},d={onClick:function(){return r.handleClick(a)},onCancel:function(){return r.paymentIntegrationService.loadDefaultCheckout()}},l=(0,o.__assign)((0,o.__assign)({fundingSource:i,style:this.paypalCommerceIntegrationService.getValidButtonStyle(s)},c),a&&d),p=u.Buttons(l);p.isEligible()?p.render("#"+e):this.paypalCommerceIntegrationService.removeElement(e)},e.prototype.handleClick=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return e?[4,this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e)]:[3,3];case 1:return t=n.sent(),[4,this.paymentIntegrationService.loadCheckout(t.id)];case 2:n.sent(),n.label=3;case 3:return[2]}}))}))},e}(),tu=Ja((function(e){return new eu(e,js(e))}),[{id:"paypalcommercealternativemethods"}]);var nu,ru,iu,ou,au;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(nu||(nu={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(ru||(ru={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(iu||(iu={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(ou||(ou={})),function(e){e.PILL="pill",e.RECT="rect"}(au||(au={}));const su=function(){function e(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}return e.prototype.initialize=function(e){return(0,o.__awaiter)(this,void 0,void 0,(function(){var t,n,r;return(0,o.__generator)(this,(function(i){switch(i.label){case 0:if(t=this.paymentIntegrationService.getState(),n=t.getPaymentMethodOrThrow(e.methodId),!e.paypal)throw new so;if(!n.config.merchantId)throw new co(uo.MissingPaymentMethod);return[4,this.paypalExpressScriptLoader.loadPaypalSDK(n.config.merchantId)];case 1:return r=i.sent(),this.renderButton(e,r),[2]}}))}))},e.prototype.deinitialize=function(){return Promise.resolve()},e.prototype.renderButton=function(e,t){var n,r=this,i=e.containerId,o=e.methodId,a=e.paypal,s=a.allowCredit,u=a.clientId,c=a.onPaymentError,d=a.shouldProcessPayment,l=a.style,p=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!p.config.merchantId)throw new co(uo.MissingPaymentMethod);var h=p.config.merchantId,f=p.config.testMode?"sandbox":"production",m=((n={})[f]=u,n),g=t.FUNDING.CREDIT||"credit",y=s?[g]:[],_=s?[]:[g];return t.Button.render({env:f,client:m,commit:d,funding:{allowed:y,disallowed:_},style:this.getStyle(l),payment:function(e,t){return r.setupPayment(h,t,c)},onAuthorize:function(e,t){return r.tokenizePayment(e,o,t,d)}},i)},e.prototype.getStyle=function(e){var t=e||{},n=t.color,r=t.fundingicons,i=t.label,o=t.layout,a=t.shape,s=t.size,u=t.tagline;return{color:n,fundingicons:r,label:i,layout:o,shape:a||au.RECT,size:"small"===s?ru.RESPONSIVE:s,tagline:u}},e.prototype.setupPayment=function(e,t,n){return(0,o.__awaiter)(this,void 0,void 0,(function(){var r,i,a,s;return(0,o.__generator)(this,(function(u){switch(u.label){case 0:if(!t)throw new fo(ho.CheckoutButtonNotInitialized);u.label=1;case 1:return u.trys.push([1,4,,5]),[4,this.paymentIntegrationService.loadDefaultCheckout()];case 2:return r=u.sent(),i=r.getCartOrThrow().id,a=r.getHost()||"",[4,t.request.post(a+"/api/storefront/payment/paypalexpress",{merchantId:e,cartId:i},{headers:(0,o.__assign)({"X-API-INTERNAL":xs},bs)})];case 3:return[2,u.sent().id];case 4:throw s=u.sent(),n&&n(s),s;case 5:return[2]}}))}))},e.prototype.tokenizePayment=function(e,t,n,r){return(0,o.__awaiter)(this,void 0,void 0,(function(){var i,a,s;return(0,o.__generator)(this,(function(o){switch(o.label){case 0:if(!n)throw new fo(ho.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new co(uo.MissingPayment);return i=this.paymentIntegrationService.getState(),a=i.getPaymentMethodOrThrow(t),[4,n.payment.get(e.paymentID)];case 1:return s=o.sent(),[2,this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:a.id,action:r?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(s.payer.payer_info)})]}}))}))},e}();const uu=function(){function e(e){this.scriptLoader=e,this.window=window}return e.prototype.loadPaypalSDK=function(e){return void 0===e&&(e=""),(0,o.__awaiter)(this,void 0,void 0,(function(){var t;return(0,o.__generator)(this,(function(n){switch(n.label){case 0:return t=(0,o.__assign)({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}}),[4,this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t)];case 1:if(n.sent(),!this.window.paypal)throw new wo;return[2,this.window.paypal]}}))}))},e}(),cu=Ja((function(e){return new su(e,new uu((0,$n.getScriptLoader)()),(0,i.createFormPoster)())}),[{id:"paypalexpress"}]);function du(e){var t=null!=e?e:{},o=t.host,a=t.locale,s=void 0===a?"en":a,u=Vn(),c=(0,r.createRequestSender)({host:o}),d=(0,i.createFormPoster)({host:o}),l=function(e,t){void 0===t&&(t=n);for(var r=new Va,i=function(t){if(!function(e){return"resolveIds"in e}(t))return"continue";for(var n=0,i=t.resolveIds;n<i.length;n++){var o=i[n];r.register(o,(function(){return t(e)}))}},o=0,a=Object.entries(t);o<a.length;o++)i(a[o][1]);return r}(function(e){var t=e.getState().config,n=t.getHost,i=t.getLocale,o=(0,r.createRequestSender)({host:n()}),a=new Zi(Wi),s=new ar(new lr(o),new mr(new gr(o)),new Cr(new Sr(o))),u=new fr(new lr(o)),c=new $r(e),d=new ti(new ii(o),new fr(new lr(o))),l=new nr(new ir(o),new xi(new Yi(o))),p=new ki(new Ni(o),new lr(o)),h=new Wn(new Xn(o)),f=new oi(new ai(function(e){var t=(0,si.createClient)();return e.subscribe((function(e){var n=e.config.getStoreConfig();n&&t.setHost(n.paymentSettings.bigpayBaseUrl)}),(function(e){return e.config.getStoreConfig()})),t}(e)),d,new Ai,new zr(Yr((0,$n.createScriptLoader)()))),m=new _r(new vr(o),s,new Fi(Yr((0,$n.createScriptLoader)()),new Ui(o))),g=new qi(new Bi(o)),y=Yr((0,$n.createScriptLoader)()),_=new Ui(o),v=new Fi(y,_),C=new or(o),S=new Ti,I=new Li(new zi(o,{locale:i()})),w=new Oi(new Ri(o),s);return new Ki(e,a,s,u,c,d,l,p,h,f,m,C,g,v,S,I,w)}(u));return new oo(u,new ao(function(e,t,n,r,i){var o=new No,a=(0,$n.getScriptLoader)(),s=new lr(t),u=new ar(s,new mr(new gr(t)),new Cr(new Sr(t))),c=new Wn(new Xn(t)),d=new xo(new Do(a,window)),l=new or(t),p=new va(t);return o.register(gi.AMAZON_PAY_V2,(function(){return new _a(e,u,new Io(new Eo((0,$n.getScriptLoader)())),l,p)})),o.register(gi.BRAINTREE_PAYPAL,(function(){return new ba(e,u,l,d,n,window)})),o.register(gi.BRAINTREE_PAYPAL_CREDIT,(function(){return new Ma(e,u,l,d,n,window)})),o.register(gi.BRAINTREE_VENMO,(function(){return new Da(e,c,l,d,n)})),o.register(gi.GOOGLEPAY_ADYENV2,(function(){return new Na(e,n,u,ea(e,new ta),l)})),o.register(gi.GOOGLEPAY_ADYENV3,(function(){return new Na(e,n,u,ea(e,new na),l)})),o.register(gi.GOOGLEPAY_AUTHORIZENET,(function(){return new Na(e,n,u,ea(e,new ia),l)})),o.register(gi.GOOGLEPAY_BNZ,(function(){return new Na(e,n,u,ea(e,new oa),l)})),o.register(gi.GOOGLEPAY_CHECKOUTCOM,(function(){return new Na(e,n,u,ea(e,new sa(t)),l)})),o.register(gi.GOOGLEPAY_CYBERSOURCEV2,(function(){return new Na(e,n,u,ea(e,new ua),l)})),o.register(gi.GOOGLEPAY_ORBITAL,(function(){return new Na(e,n,u,ea(e,new ca),l)})),o.register(gi.GOOGLEPAY_STRIPE,(function(){return new Na(e,n,u,ea(e,new da),l)})),o.register(gi.GOOGLEPAY_STRIPEUPE,(function(){return new Na(e,n,u,ea(e,new la),l)})),o.register(gi.MASTERPASS,(function(){return new Fa(e,u,new ha(a),r)})),o.register(gi.PAYPALEXPRESS,(function(){return new Ua(e,u,new fa(a),n,i)})),o.register(gi.GOOGLEPAY_WORLDPAYACCESS,(function(){return new Na(e,n,u,ea(e,new pa),l)})),o}(u,c,d,s,o),l,new Wn(new Xn(c))))}module.exports=t})();
|
|
2
2
|
//# sourceMappingURL=checkout-button.js.map
|