@bigcommerce/checkout-sdk 1.934.2 → 1.935.0
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/cjs/checkout-button.js +1 -1
- package/dist/cjs/checkout-sdk-essential.js +1 -1
- package/dist/cjs/checkout-sdk.js +1 -1
- package/dist/cjs/hosted-form-v2-iframe-host.js +1 -1
- package/dist/cjs/integrations/amazon-pay.js +1 -1
- package/dist/cjs/integrations/bigcommerce-payments.js +1 -1
- package/dist/cjs/integrations/braintree.js +1 -1
- package/dist/cjs/integrations/google-pay.js +1 -1
- package/dist/cjs/integrations/klarna.js +1 -1
- package/dist/cjs/integrations/paypal-commerce.js +1 -1
- package/dist/cjs/integrations/paypal-express.js +1 -1
- package/dist/cjs/integrations/zip.js +1 -1
- package/dist/cjs/wallet-button.js +1 -1
- package/dist/cjs/wallet-button.js.map +1 -1
- package/dist/esm/checkout-button.js +1 -1
- package/dist/esm/checkout-sdk-essential.js +1 -1
- package/dist/esm/checkout-sdk.js +1 -1
- package/dist/esm/hosted-form-v2-iframe-host.js +1 -1
- package/dist/esm/integrations/amazon-pay.js +1 -1
- package/dist/esm/integrations/bigcommerce-payments.js +1 -1
- package/dist/esm/integrations/braintree.js +1 -1
- package/dist/esm/integrations/google-pay.js +1 -1
- package/dist/esm/integrations/klarna.js +1 -1
- package/dist/esm/integrations/paypal-commerce.js +1 -1
- package/dist/esm/integrations/paypal-express.js +1 -1
- package/dist/esm/integrations/zip.js +1 -1
- package/dist/esm/wallet-button.js +1 -1
- package/dist/esm/wallet-button.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{createRequestSender as e,createTimeout as t}from"@bigcommerce/request-sender";import{createFormPoster as n}from"@bigcommerce/form-poster";import{combineReducers as i,composeReducers as r,createAction as o,createDataStore as a,createErrorAction as s,deepFreeze as d}from"@bigcommerce/data-store";import{difference as c,filter as u,find as l,findIndex as h,flatMap as p,identity as g,includes as m,isArray as y,isEmpty as f,isEqual as _,isMatch as S,isNil as v,isObject as C,isPlainObject as I,keyBy as w,keys as b,last as E,map as P,max as O,memoize as A,noop as T,omit as k,omitBy as R,pick as D,pickBy as M,reduce as N,round as L,some as z,transform as U,uniq as F,uniqueId as B,values as x,without as q}from"lodash";import{Observable as j,Subject as G,concat as V,defer as H,empty as W,from as Y,fromEvent as K,merge as $,of as Z,throwError as J}from"rxjs";import{catchError as Q,delay as X,filter as ee,map as te,retryWhen as ne,shareReplay as ie,switchMap as re,take as oe}from"rxjs/operators";import{memoize as ae,memoizeOne as se}from"@bigcommerce/memoize";import{createSelector as de}from"reselect";import{ScriptLoader as ce,createScriptLoader as ue,getScriptLoader as le}from"@bigcommerce/script-loader";import{stringifyUrl as he}from"query-string";import{supportsPopups as pe}from"@braintree/browser-detection";import{createClient as ge}from"@bigcommerce/bigpay-client";import{creditCardType as me,number as ye}from"card-validator";import{default as fe}from"shallowequal";var _e={d:(e,t)=>{for(var n in t)_e.o(t,n)&&!_e.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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})}},Se={};_e.r(Se),_e.d(Se,{createAmazonPayV2ButtonStrategy:()=>Nr,createApplePayButtonStrategy:()=>po,createBigCommercePaymentsButtonStrategy:()=>Ro,createBigCommercePaymentsPayLaterButtonStrategy:()=>No,createBigCommercePaymentsVenmoButtonStrategy:()=>Uo,createBoltButtonStrategy:()=>Ho,createBraintreePaypalButtonStrategy:()=>ca,createBraintreePaypalCreditButtonStrategy:()=>ha,createBraintreeVenmoButtonStrategy:()=>Ca,createBraintreeVisaCheckoutButtonStrategy:()=>ma,createGooglePayAdyenV2ButtonStrategy:()=>ls,createGooglePayAdyenV3ButtonStrategy:()=>hs,createGooglePayAuthorizeDotNetButtonStrategy:()=>gs,createGooglePayBigCommercePaymentsButtonStrategy:()=>us,createGooglePayBraintreeButtonStrategy:()=>Ja,createGooglePayCheckoutComButtonStrategy:()=>Ss,createGooglePayCybersourceButtonStrategy:()=>Cs,createGooglePayOrbitalButtonStrategy:()=>ws,createGooglePayPayPalCommerceButtonStrategy:()=>os,createGooglePayStripeButtonStrategy:()=>js,createGooglePayTdOnlineMartButtonStrategy:()=>Ks,createGooglePayWorldpayAccessButtonStrategy:()=>Vs,createLinkV2ButtonStrategy:()=>tc,createPayPalCommerceButtonStrategy:()=>md,createPayPalCommerceCreditButtonStrategy:()=>_d,createPayPalCommerceVenmoButtonStrategy:()=>Nd,createPaypalExpressButtonStrategy:()=>Vd});class ve extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}const Ce={body:{},headers:{},status:0};class Ie extends ve{constructor(e,{message:t,errors:n}={}){const{body:i,headers:r,status:o}=e||Ce;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=r,this.status=o,this.errors=n||[]}}class we extends Ie{constructor(e){super(e,{message:"There is a problem processing your payment. Please try again later."}),this.name="PaymentMethodInvalidError",this.type="payment_method_invalid"}}class be extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}const Ee={body:{},headers:{},status:0};class Pe extends be{constructor(e,{message:t,errors:n}={}){const{body:i,headers:r,status:o}=e||Ee;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=r,this.status=o,this.errors=n||[]}}class Oe extends Pe{constructor(e,t){super(e,{message:t||"An unexpected error has occurred. The checkout process cannot continue as a result."}),this.name="UnrecoverableError",this.type="unrecoverable"}}function Ae(e){return e.reduce((e,t)=>t?[...e,t]:e,[]).join(" ")}function Te(e,t){const{body:n}=e,{errors:i=[]}=n;return new Pe(e,{message:ke(i)||t,errors:i})}function ke(e){if(Array.isArray(e))return e.reduce((e,t)=>t&&t.message?[...e,t.message]:e,[]).join(" ")}class Re extends Pe{constructor(e){super(e,{message:"The request has timed out or aborted."}),this.name="TimeoutError",this.type="timeout"}}class De{constructor(){this._factoryMethods={},this.register("default",(e,t)=>new Pe(e,{message:t})),this.register("internal",(e,t)=>function(e,t){const{body:n}=e,{errors:i=[]}=n;return new Pe(e,{message:Ae(i)||n.detail||n.title||t,errors:i.length?i.map(e=>({code:n.type,message:e})):[{code:n.type,message:n.detail||n.title}]})}(e,t)),this.register("storefront",(e,t)=>function(e,t){const{body:n}=e;return new Pe(e,{message:t||n.detail||n.title,errors:[{code:n.code||n.type,message:n.detail||n.title}]})}(e,t)),this.register("payment",(e,t)=>Te(e,t)),this.register("timeout",e=>new Re(e))}register(e,t){this._factoryMethods[e]=t}createError(e,t){return(this._factoryMethods[this._getType(e)]||this._factoryMethods.default)(e,t)}_getType(e){if(0===e.status)return"timeout";if(this._isStorefrontErrorResponseBody(e.body))return"storefront";if(this._isInternalErrorResponseBody(e.body)){const t=E(e.body.type.split("/"));return t&&this._factoryMethods[t]?t:"internal"}const t=E(e.body&&e.body.errors);return t&&t.code&&this._factoryMethods[t.code]?t.code:"payment"}_isStorefrontErrorResponseBody(e){const t=e;return!this._isInternalErrorResponseBody(e)&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status&&"string"==typeof t.detail}_isInternalErrorResponseBody(e){const t=e;return"object"==typeof t.errors&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status}}function Me(e,t){return Array.isArray(e)?e.map(e=>Me(e,t)):I(e)?U(R(e,t),(e,n,i)=>{e[i]=Me(n,t)},{}):e}var Ne,Le;function ze(e,t){return function(e){return e.type===Ne.ClearError}(t)?Me(e,e=>e===t.payload):e}function Ue(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(let i=0,r=e.length;i<r;i++)if(!Ue(e[i],t[i],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){const i=n&&n.keyFilter,r=i?Object.keys(e).filter(i):Object.keys(e),o=i?Object.keys(t).filter(i):Object.keys(t);if(r.length!==o.length)return!1;for(let i=0,o=r.length;i<o;i++){const o=r[i];if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Ue(e[o],t[o],n))return!1}return!0}(e,t,n))):e===t)}function Fe(e,t,n){return e&&Object.prototype.hasOwnProperty.call(e,t)&&Ue(e[t],n)?e:Object.assign(Object.assign({},e),{[t]:n})}!function(e){e.ClearError="CLEAR_ERROR"}(Ne||(Ne={})),function(e){e.LoadB2BTokenRequested="LOAD_B2B_TOKEN_REQUESTED",e.LoadB2BTokenSucceeded="LOAD_B2B_TOKEN_SUCCEEDED",e.LoadB2BTokenFailed="LOAD_B2B_TOKEN_FAILED"}(Le||(Le={}));const Be={errors:{},statuses:{}};function xe(e=Be,t){return i({data:qe,errors:r(je,ze),statuses:Ge})(e,t)}function qe(e,t){return t.type===Le.LoadB2BTokenSucceeded?t.payload:e}function je(e=Be.errors,t){switch(t.type){case Le.LoadB2BTokenRequested:case Le.LoadB2BTokenSucceeded:return Fe(e,"loadError",void 0);case Le.LoadB2BTokenFailed:return Fe(e,"loadError",t.payload);default:return e}}function Ge(e=Be.statuses,t){switch(t.type){case Le.LoadB2BTokenRequested:return Fe(e,"isLoading",!0);case Le.LoadB2BTokenFailed:case Le.LoadB2BTokenSucceeded:return Fe(e,"isLoading",!1);default:return e}}var Ve,He,We,Ye;function Ke(e,t){return void 0===t||Ue(e,t)?e:t}!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",e.DeleteCheckoutRequested="DELETE_CHECKOUT_REQUESTED",e.DeleteCheckoutSucceeded="DELETE_CHECKOUT_SUCCEEDED",e.DeleteCheckoutFailed="DELETE_CHECKOUT_FAILED"}(Ve||(Ve={})),function(e){e.HydrateInitialState="HYDRATE_INITIAL_STATE"}(He||(He={})),function(e){e.UpdateSubscriptionsRequested="UPDATE_SUBSCRIPTIONS_REQUESTED",e.UpdateSubscriptionsSucceeded="UPDATE_SUBSCRIPTIONS_SUCCEEDED",e.UpdateSubscriptionsFailed="UPDATE_SUBSCRIPTIONS_FAILED"}(We||(We={})),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"}(Ye||(Ye={}));const $e={errors:{},statuses:{}};function Ze(e=$e,t){return i({data:Je,errors:r(Qe,ze),statuses:Xe})(e,t)}function Je(e,t){var n,i;switch(t.type){case Ye.UpdateBillingAddressSucceeded:case Ye.ContinueAsGuestSucceeded:case Ve.LoadCheckoutSucceeded:return Ke(e,t.payload&&t.payload.billingAddress);case He.HydrateInitialState:return Ke(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.billingAddress);default:return e}}function Qe(e=$e.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);case Ye.UpdateBillingAddressRequested:case Ye.UpdateBillingAddressSucceeded:return Fe(e,"updateError",void 0);case Ye.UpdateBillingAddressFailed:return Fe(e,"updateError",t.payload);case We.UpdateSubscriptionsRequested:case We.UpdateSubscriptionsSucceeded:case Ye.ContinueAsGuestRequested:case Ye.ContinueAsGuestSucceeded:return Fe(e,"continueAsGuestError",void 0);case We.UpdateSubscriptionsFailed:case Ye.ContinueAsGuestFailed:return Fe(e,"continueAsGuestError",t.payload);default:return e}}function Xe(e=$e.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutSucceeded:case Ve.LoadCheckoutFailed:return Fe(e,"isLoading",!1);case Ye.UpdateBillingAddressRequested:return Fe(e,"isUpdating",!0);case Ye.UpdateBillingAddressFailed:case Ye.UpdateBillingAddressSucceeded:return Fe(e,"isUpdating",!1);case Ye.ContinueAsGuestRequested:case We.UpdateSubscriptionsRequested:return Fe(e,"isContinuingAsGuest",!0);case We.UpdateSubscriptionsSucceeded:case We.UpdateSubscriptionsFailed:case Ye.ContinueAsGuestFailed:case Ye.ContinueAsGuestSucceeded:return Fe(e,"isContinuingAsGuest",!1);default:return e}}function et(e){return I(e)}const tt=function e(t,n,i){const{matchObject:r=(e,t)=>void 0!==e.id&&e.id===t.id}=i||{};if(!t)return n;if(!n||t===n)return t;let o=0,a=0;const s=(e,t,n)=>(o+=e===t?1:0,a+=e===n?1:0,e),d=n.map((n,i)=>{const o=t&&t[i];return et(o)&&et(n)?r(o,n)?s(nt(o,n),o,n):s(Ke(o,n),o,n):y(o)&&y(n)?s(e(o,n),o,n):s(Ke(o,n),o,n)});return o===n.length&&t&&t.length===n.length?t:a===n.length?n:d},nt=function e(t,n){return t?n&&t!==n?Object.keys(n).reduce((t,i)=>{const r=t[i],o=n[i];return et(r)&&et(o)?Fe(t,i,e(r,o)):y(r)&&y(o)?Fe(t,i,tt(r,o)):Fe(t,i,o)},t):t:n};var it,rt,ot;!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"}(it||(it={})),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"}(rt||(rt={})),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"}(ot||(ot={}));const at={errors:{},statuses:{}};function st(e=at,t){return i({data:dt,errors:r(ut,ze),statuses:ct})(e,t)}function dt(e,t){var n,i;switch(t.type){case Ye.UpdateBillingAddressSucceeded:case Ve.LoadCheckoutSucceeded:case ot.CreateConsignmentsSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case ot.LoadShippingOptionsSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:return nt(e,t.payload&&t.payload.cart);case He.HydrateInitialState:return nt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.cart);case Ve.DeleteCheckoutSucceeded:return;default:return e}}function ct(e=at.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutFailed:case Ve.LoadCheckoutSucceeded:return Fe(e,"isLoading",!1);default:return e}}function ut(e=at.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);default:return e}}var lt;!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"}(lt||(lt={}));const ht={data:{},errors:{},statuses:{}},pt={initializedContainers:{}},gt={},mt={};function yt(e=ht,t){return t.meta&&t.meta.methodId?i({data:i({[t.meta.methodId]:ft}),errors:i({[t.meta.methodId]:_t}),statuses:i({[t.meta.methodId]:St})})(e,t):e}function ft(e=pt,t){switch(t.type){case lt.InitializeButtonSucceeded:return t.meta&&t.meta.containerId?nt(e,{initializedContainers:{[t.meta.containerId]:!0}}):e;case lt.DeinitializeButtonSucceeded:return Fe(e,"initializedContainers",{})}return e}function _t(e=gt,t){switch(t.type){case lt.InitializeButtonRequested:case lt.InitializeButtonSucceeded:return Fe(e,"initializeError",void 0);case lt.InitializeButtonFailed:return Fe(e,"initializeError",t.payload);case lt.DeinitializeButtonRequested:case lt.DeinitializeButtonSucceeded:return Fe(e,"deinitializeError",void 0);case lt.DeinitializeButtonFailed:return Fe(e,"deinitializeError",t.payload);default:return e}}function St(e=mt,t){switch(t.type){case lt.InitializeButtonRequested:return Fe(e,"isInitializing",!0);case lt.InitializeButtonFailed:case lt.InitializeButtonSucceeded:return Fe(e,"isInitializing",!1);case lt.DeinitializeButtonRequested:return Fe(e,"isDeinitializing",!0);case lt.DeinitializeButtonFailed:case lt.DeinitializeButtonSucceeded:return Fe(e,"isDeinitializing",!1);default:return e}}var vt;!function(e){e.LoadConfigRequested="LOAD_CONFIG_REQUESTED",e.LoadConfigSucceeded="LOAD_CONFIG_SUCCEEDED",e.LoadConfigFailed="LOAD_CONFIG_FAILED"}(vt||(vt={}));const Ct={meta:{},errors:{},statuses:{}};function It(e=Ct,t){return i({data:wt,errors:r(bt,ze),statuses:Et})(e,t)}function wt(e,t){var n,i;switch(t.type){case vt.LoadConfigSucceeded:return nt(e,t.payload);case He.HydrateInitialState:{const r=nt(e,null===(n=t.payload)||void 0===n?void 0:n.config);return r&&(null===(i=t.payload)||void 0===i?void 0:i.b2bApiSettings)?Object.assign(Object.assign({},r),{storeConfig:Object.assign(Object.assign({},r.storeConfig),{b2bApiSettings:t.payload.b2bApiSettings})}):r}default:return e}}function bt(e=Ct.errors,t){switch(t.type){case vt.LoadConfigSucceeded:return Fe(e,"loadError",void 0);case vt.LoadConfigFailed:return Fe(e,"loadError",t.payload);default:return e}}function Et(e=Ct.statuses,t){switch(t.type){case vt.LoadConfigRequested:return Fe(e,"isLoading",!0);case vt.LoadConfigSucceeded:case vt.LoadConfigFailed:return Fe(e,"isLoading",!1);default:return e}}var Pt;!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"}(Pt||(Pt={}));const Ot={errors:{},statuses:{}};function At(e=Ot,t){return i({data:Tt,errors:r(kt,ze),statuses:Rt})(e,t)}function Tt(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case it.ApplyCouponSucceeded:case ot.UpdateShippingOptionSucceeded:case it.RemoveCouponSucceeded:case Pt.LoadOrderSucceeded:return tt(e,t.payload&&t.payload.coupons);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.coupons);default:return e}}function kt(e={},t){switch(t.type){case it.ApplyCouponRequested:case it.ApplyCouponSucceeded:return Fe(e,"applyCouponError",void 0);case it.ApplyCouponFailed:return Fe(e,"applyCouponError",t.payload);case it.RemoveCouponRequested:case it.RemoveCouponSucceeded:return Fe(e,"removeCouponError",void 0);case it.RemoveCouponFailed:return Fe(e,"removeCouponError",t.payload);default:return e}}function Rt(e={},t){switch(t.type){case it.ApplyCouponRequested:return Fe(e,"isApplyingCoupon",!0);case it.ApplyCouponSucceeded:case it.ApplyCouponFailed:return Fe(e,"isApplyingCoupon",!1);case it.RemoveCouponRequested:return Fe(e,"isRemovingCoupon",!0);case it.RemoveCouponSucceeded:case it.RemoveCouponFailed:return Fe(e,"isRemovingCoupon",!1);default:return e}}const Dt={errors:{},statuses:{}};function Mt(e=Dt,t){return i({data:Nt,errors:r(Lt,ze),statuses:zt})(e,t)}function Nt(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:return tt(e,t.payload&&t.payload.giftCertificates);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.giftCertificates);default:return e}}function Lt(e=Dt.errors,t){switch(t.type){case rt.ApplyGiftCertificateRequested:case rt.ApplyGiftCertificateSucceeded:return Fe(e,"applyGiftCertificateError",void 0);case rt.ApplyGiftCertificateFailed:return Fe(e,"applyGiftCertificateError",t.payload);case rt.RemoveGiftCertificateRequested:case rt.RemoveGiftCertificateSucceeded:return Fe(e,"removeGiftCertificateError",void 0);case rt.RemoveGiftCertificateFailed:return Fe(e,"removeGiftCertificateError",t.payload);default:return e}}function zt(e=Dt.statuses,t){switch(t.type){case rt.ApplyGiftCertificateRequested:return Fe(e,"isApplyingGiftCertificate",!0);case rt.ApplyGiftCertificateSucceeded:case rt.ApplyGiftCertificateFailed:return Fe(e,"isApplyingGiftCertificate",!1);case rt.RemoveGiftCertificateRequested:return Fe(e,"isRemovingGiftCertificate",!0);case rt.RemoveGiftCertificateSucceeded:case rt.RemoveGiftCertificateFailed:return Fe(e,"isRemovingGiftCertificate",!1);default:return e}}var Ut;!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"}(Ut||(Ut={}));const Ft={errors:{},statuses:{}};function Bt(e=Ft,t){return i({data:xt,errors:r(qt,ze),statuses:jt})(e,t)}function xt(e,t){var n,i;switch(t.type){case Ye.ContinueAsGuestSucceeded:case Ve.LoadCheckoutSucceeded:return nt(e,t.payload&&t.payload.customer);case Ut.CreateCustomerAddressSucceeded:return nt(e,t.payload);case He.HydrateInitialState:return nt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.customer);default:return e}}function qt(e=Ft.errors,t){switch(t.type){case Ut.CreateCustomerRequested:case Ut.CreateCustomerSucceeded:return Fe(e,"createError",void 0);case Ut.CreateCustomerFailed:return Fe(e,"createError",t.payload);case Ut.CreateCustomerAddressRequested:case Ut.CreateCustomerAddressSucceeded:return Fe(e,"createAddressError",void 0);case Ut.CreateCustomerAddressFailed:return Fe(e,"createAddressError",t.payload);default:return e}}function jt(e=Ft.statuses,t){switch(t.type){case Ut.CreateCustomerRequested:return Fe(e,"isCreating",!0);case Ut.CreateCustomerFailed:case Ut.CreateCustomerSucceeded:return Fe(e,"isCreating",!1);case Ut.CreateCustomerAddressRequested:return Fe(e,"isCreatingAddress",!0);case Ut.CreateCustomerAddressFailed:case Ut.CreateCustomerAddressSucceeded:return Fe(e,"isCreatingAddress",!1);default:return e}}var Gt;!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"}(Gt||(Gt={}));const Vt={data:{},errors:{},statuses:{}};function Ht(e=Vt,t){return i({data:Wt,errors:r(Yt,ze),statuses:Kt})(e,t)}function Wt(e=Vt.data,t){switch(t.type){case Gt.InitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!0}});case Gt.DeinitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!1}})}return e}function Yt(e=Vt.errors,t){switch(t.type){case Gt.InitializeRequested:case Gt.InitializeSucceeded:return nt(e,{initializeErrors:Object.assign({},e.initializeErrors),initializeMethodId:e.initializeMethodId?e.initializeMethodId:void 0});case Gt.InitializeFailed:return nt(e,{initializeErrors:Object.assign(Object.assign({},e.initializeErrors),{[t.meta&&t.meta.methodId]:t.payload}),initializeMethodId:t.meta&&t.meta.methodId});case Gt.DeinitializeRequested:case Gt.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Gt.DeinitializeFailed:return nt(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Gt.SignInRequested:case Gt.SignInSucceeded:return nt(e,{signInError:void 0,signInMethodId:void 0});case Gt.SignInFailed:return nt(e,{signInError:t.payload,signInMethodId:t.meta&&t.meta.methodId});case Gt.SignOutRequested:case Gt.SignOutSucceeded:return nt(e,{signOutError:void 0,signOutMethodId:void 0});case Gt.SignOutFailed:return nt(e,{signOutError:t.payload,signOutMethodId:t.meta&&t.meta.methodId});case Gt.ExecutePaymentMethodCheckoutRequested:case Gt.ExecutePaymentMethodCheckoutSucceeded:return nt(e,{executePaymentMethodCheckoutError:void 0,executePaymentMethodCheckoutMethodId:void 0});case Gt.ExecutePaymentMethodCheckoutFailed:return nt(e,{executePaymentMethodCheckoutError:t.payload,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Gt.WidgetInteractionStarted:case Gt.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Gt.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Kt(e=Vt.statuses,t){switch(t.type){case Gt.InitializeRequested:return nt(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Gt.InitializeFailed:case Gt.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case Gt.DeinitializeRequested:return nt(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Gt.DeinitializeFailed:case Gt.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Gt.SignInRequested:return nt(e,{isSigningIn:!0,signInMethodId:t.meta&&t.meta.methodId});case Gt.SignInFailed:case Gt.SignInSucceeded:return nt(e,{isSigningIn:!1,signInMethodId:void 0});case Gt.SignOutRequested:return nt(e,{isSigningOut:!0,signOutMethodId:t.meta&&t.meta.methodId});case Gt.SignOutFailed:case Gt.SignOutSucceeded:return nt(e,{isSigningOut:!1,signOutMethodId:void 0});case Gt.ExecutePaymentMethodCheckoutRequested:return nt(e,{isExecutingPaymentMethodCheckout:!0,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Gt.ExecutePaymentMethodCheckoutFailed:case Gt.ExecutePaymentMethodCheckoutSucceeded:return nt(e,{isExecutingPaymentMethodCheckout:!1,executePaymentMethodCheckoutMethodId:void 0});case Gt.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Gt.WidgetInteractionFinished:case Gt.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var $t;!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"}($t||($t={}));const Zt={errors:{},statuses:{}};function Jt(e=Zt,t){return i({data:Qt,errors:r(Xt,ze),statuses:en})(e,t)}function Qt(e,t){var n;return t.type===$t.LoadExtensionsSucceeded?tt(e,t.payload):t.type===He.HydrateInitialState?tt(e,null===(n=t.payload)||void 0===n?void 0:n.extensions):e}function Xt(e=Zt.errors,t){switch(t.type){case $t.LoadExtensionsRequested:case $t.LoadExtensionsSucceeded:return Fe(e,"loadError",void 0);case $t.RenderExtensionRequested:case $t.RenderExtensionSucceeded:return Fe(e,"renderError",void 0);case $t.LoadExtensionsFailed:return Fe(e,"loadError",t.payload);case $t.RenderExtensionFailed:return Fe(e,"renderError",t.payload);default:return e}}function en(e=Zt.statuses,t){switch(t.type){case $t.LoadExtensionsRequested:return Fe(e,"isLoading",!0);case $t.LoadExtensionsSucceeded:case $t.LoadExtensionsFailed:return Fe(e,"isLoading",!1);default:return e}}var tn;!function(e){e.LoadFormFieldsRequested="LOAD_FORM_FIELDS_REQUESTED",e.LoadFormFieldsSucceeded="LOAD_FORM_FIELDS_SUCCEEDED",e.LoadFormFieldsFailed="LOAD_FORM_FIELDS_FAILED"}(tn||(tn={}));const nn={errors:{},statuses:{}};function rn(e=nn,t){return i({data:on,extraFields:an,errors:r(sn,ze),statuses:dn})(e,t)}function on(e,t){var n;switch(t.type){case tn.LoadFormFieldsSucceeded:return nt(e,t.payload);case He.HydrateInitialState:return nt(e,null===(n=t.payload)||void 0===n?void 0:n.formFields);default:return e}}function an(e,t){var n,i;return t.type===He.HydrateInitialState&&null!==(i=null===(n=t.payload)||void 0===n?void 0:n.extraFields)&&void 0!==i?i:e}function sn(e=nn.errors,t){switch(t.type){case tn.LoadFormFieldsSucceeded:return Fe(e,"loadError",void 0);case tn.LoadFormFieldsFailed:return Fe(e,"loadError",t.payload);default:return e}}function dn(e=nn.statuses,t){switch(t.type){case tn.LoadFormFieldsRequested:return Fe(e,"isLoading",!0);case tn.LoadFormFieldsSucceeded:case tn.LoadFormFieldsFailed:return Fe(e,"isLoading",!1);default:return e}}var cn;!function(e){e.LoadCountriesRequested="LOAD_COUNTRIES_REQUESTED",e.LoadCountriesSucceeded="LOAD_COUNTRIES_SUCCEEDED",e.LoadCountriesFailed="LOAD_COUNTRIES_FAILED"}(cn||(cn={}));const un={errors:{},statuses:{}};function ln(e=un,t){return i({data:hn,errors:r(pn,ze),statuses:gn})(e,t)}function hn(e,t){return t.type===cn.LoadCountriesSucceeded?tt(e,t.payload):e}function pn(e=un.errors,t){switch(t.type){case cn.LoadCountriesRequested:case cn.LoadCountriesSucceeded:return Fe(e,"loadError",void 0);case cn.LoadCountriesFailed:return Fe(e,"loadError",t.payload);default:return e}}function gn(e=un.statuses,t){switch(t.type){case cn.LoadCountriesRequested:return Fe(e,"isLoading",!0);case cn.LoadCountriesSucceeded:case cn.LoadCountriesFailed:return Fe(e,"isLoading",!1);default:return e}}const mn={errors:{},meta:{},statuses:{}};function yn(e=mn,t){return i({data:fn,errors:r(Sn,ze),meta:_n,statuses:vn})(e,t)}function fn(e,t){switch(t.type){case Pt.LoadOrderSucceeded:case Pt.LoadOrderPaymentsSucceeded:return nt(e,k(t.payload,["billingAddress","coupons"]));default:return e}}function _n(e,t){var n,i;switch(t.type){case Pt.FinalizeOrderSucceeded:case Pt.SubmitOrderSucceeded:return nt(e,Object.assign(Object.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,b2bReceiptId:null===(i=null===(n=t.payload)||void 0===n?void 0:n.b2bContext)||void 0===i?void 0:i.receiptId}));default:return e}}function Sn(e=mn.errors,t){switch(t.type){case Pt.LoadOrderRequested:case Pt.LoadOrderSucceeded:case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderPaymentsRequested:return Fe(e,"loadError",void 0);case Pt.LoadOrderFailed:case Pt.LoadOrderPaymentsFailed:return Fe(e,"loadError",t.payload);default:return e}}function vn(e=mn.statuses,t){switch(t.type){case Pt.LoadOrderRequested:case Pt.LoadOrderPaymentsRequested:return Fe(e,"isLoading",!0);case Pt.LoadOrderSucceeded:case Pt.LoadOrderFailed:case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderPaymentsFailed:return Fe(e,"isLoading",!1);default:return e}}const Cn={};function In(e=Cn,t){return i({data:wn})(e,t)}function wn(e,t){switch(t.type){case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderSucceeded:return Ke(e,t.payload&&t.payload.billingAddress);default:return e}}var bn,En;function Pn(e={},t){return i({data:On})(e,t)}function On(e,t){return t.type===bn.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"}(bn||(bn={})),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"}(En||(En={}));const An={errors:{},statuses:{}};function Tn(e=An,t){return i({data:kn,errors:r(Dn,ze),meta:Rn,statuses:Mn})(e,t)}function kn(e,t){switch(t.type){case En.LoadPaymentMethodSucceeded:return function(e,t,n){if(!t)return e;const i=D(t,"id"),r="object"==typeof n?M(n):n||i,o=h(e,r),a=[...e];if(-1===o)a.push(t);else{const n=e[o];a[o]=et(n)&&et(t)?nt(n,t):t}return a}(e||[],t.payload,t.payload&&{id:t.payload.id,gateway:t.payload.gateway});case En.LoadPaymentMethodsSucceeded:return tt(e,t.payload,{matchObject:(e,t)=>e.id===t.id&&e.gateway===t.gateway});default:return e}}function Rn(e,t){return t.type===En.LoadPaymentMethodsSucceeded?nt(e,t.meta):e}function Dn(e=An.errors,t){switch(t.type){case En.LoadPaymentMethodsRequested:case En.LoadPaymentMethodsSucceeded:return Fe(e,"loadError",void 0);case En.LoadPaymentMethodsFailed:return Fe(e,"loadError",t.payload);case En.LoadPaymentMethodRequested:case En.LoadPaymentMethodSucceeded:return nt(e,{loadMethodId:void 0,loadMethodError:void 0});case En.LoadPaymentMethodFailed:return nt(e,{loadMethodId:t.meta.methodId,loadMethodError:t.payload});default:return e}}function Mn(e=An.statuses,t){switch(t.type){case En.LoadPaymentMethodsRequested:return Fe(e,"isLoading",!0);case En.LoadPaymentMethodsSucceeded:case En.LoadPaymentMethodsFailed:return Fe(e,"isLoading",!1);case En.LoadPaymentMethodRequested:return nt(e,{isLoadingMethod:!0,loadMethodId:t.meta.methodId});case En.LoadPaymentMethodSucceeded:case En.LoadPaymentMethodFailed:return nt(e,{isLoadingMethod:!1,loadMethodId:void 0});default:return e}}var Nn;!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"}(Nn||(Nn={}));const Ln={data:{},errors:{},statuses:{}};function zn(e=Ln,t){return i({data:Un,errors:r(Fn,ze),statuses:Bn})(e,t)}function Un(e=Ln.data,t){switch(t.type){case Nn.InitializeSucceeded:if(t.meta){const{methodId:n,gatewayId:i}=t.meta,r=i?`${n}.${i}`:n;return nt(e,{[r]:{isInitialized:!0}})}break;case Nn.DeinitializeSucceeded:if(t.meta){const{methodId:n,gatewayId:i}=t.meta,r=i?`${n}.${i}`:n;return nt(e,{[r]:{isInitialized:!1}})}}return e}function Fn(e=Ln.errors,t){switch(t.type){case Nn.InitializeRequested:case Nn.InitializeSucceeded:return nt(e,{initializeError:void 0,initializeMethodId:void 0});case Nn.InitializeFailed:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{initializeError:t.payload,initializeMethodId:n})}case Nn.DeinitializeRequested:case Nn.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Nn.DeinitializeFailed:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{deinitializeError:t.payload,deinitializeMethodId:n})}case Nn.ExecuteRequested:case Nn.ExecuteSucceeded:return nt(e,{executeError:void 0,executeMethodId:void 0});case Nn.ExecuteFailed:return nt(e,{executeError:t.payload,executeMethodId:t.meta&&t.meta.methodId});case Nn.FinalizeRequested:case Nn.FinalizeSucceeded:return nt(e,{finalizeError:void 0,finalizeMethodId:void 0});case Nn.FinalizeFailed:return nt(e,{finalizeError:t.payload,finalizeMethodId:t.meta&&t.meta.methodId});case Nn.WidgetInteractionStarted:case Nn.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Nn.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Bn(e=Ln.statuses,t){switch(t.type){case Nn.InitializeRequested:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{isInitializing:!0,initializeMethodId:n})}case Nn.InitializeFailed:case Nn.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case Nn.DeinitializeRequested:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{isDeinitializing:!0,deinitializeMethodId:n})}case Nn.DeinitializeFailed:case Nn.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Nn.ExecuteRequested:return nt(e,{isExecuting:!0,executeMethodId:t.meta&&t.meta.methodId});case Nn.ExecuteFailed:case Nn.ExecuteSucceeded:return nt(e,{isExecuting:!1,executeMethodId:void 0});case Nn.FinalizeRequested:return nt(e,{isFinalizing:!0,finalizeMethodId:t.meta&&t.meta.methodId});case Nn.FinalizeFailed:case Nn.FinalizeSucceeded:return nt(e,{isFinalizing:!1,finalizeMethodId:void 0});case Nn.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Nn.WidgetInteractionFinished:case Nn.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var xn;!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"}(xn||(xn={}));const qn={data:[],errors:{},statuses:{}};function jn(e=qn,t){return i({data:Gn,errors:r(Hn,ze),meta:Vn,statuses:Wn})(e,t)}function Gn(e=qn.data,t){return t.type===xn.LoadInstrumentsSucceeded?tt(e,t.payload&&t.payload.vaultedInstruments||[]):e}function Vn(e,t){switch(t.type){case xn.LoadInstrumentsSucceeded:case xn.DeleteInstrumentSucceeded:return nt(e,t.meta);default:return e}}function Hn(e=qn.errors,t){switch(t.type){case xn.LoadInstrumentsRequested:case xn.LoadInstrumentsSucceeded:return Fe(e,"loadError",void 0);case xn.DeleteInstrumentRequested:case xn.DeleteInstrumentSucceeded:return nt(e,{deleteError:void 0,failedInstrument:void 0});case xn.LoadInstrumentsFailed:return Fe(e,"loadError",t.payload);case xn.DeleteInstrumentFailed:return nt(e,{deleteError:t.payload,failedInstrument:t.meta.instrumentId});default:return e}}function Wn(e=qn.statuses,t){switch(t.type){case xn.LoadInstrumentsRequested:return Fe(e,"isLoading",!0);case xn.DeleteInstrumentRequested:return nt(e,{isDeleting:!0,deletingInstrument:t.meta.instrumentId});case xn.LoadInstrumentsSucceeded:case xn.LoadInstrumentsFailed:return Fe(e,"isLoading",!1);case xn.DeleteInstrumentSucceeded:case xn.DeleteInstrumentFailed:return nt(e,{isDeleting:!1,deletingInstrument:void 0});default:return e}}var Yn;!function(e){e.UpdatePaymentProviderCustomer="UPDATE_PAYMENT_PROVIDER_CUSTOMER"}(Yn||(Yn={}));const Kn={data:{}};function $n(e=Kn,t){return i({data:Zn})(e,t)}function Zn(e=Kn.data,t){return t.type===Yn.UpdatePaymentProviderCustomer?nt(e,t.payload):e}var Jn;!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"}(Jn||(Jn={}));const Qn={data:{}};function Xn(e=Qn,t){return t.meta&&t.meta.methodId?i({data:i({[t.meta.methodId]:ei})})(e,t):e}function ei(e,t){switch(t.type){case Jn.InitializeRemoteBillingSucceeded:return Fe(e,"billing",t.payload&&t.payload.billing);case Jn.InitializeRemoteShippingSucceeded:return Fe(e,"shipping",t.payload&&t.payload.shipping);case Jn.LoadRemoteSettingsSucceeded:return Fe(e,"settings",t.payload);case Jn.UpdateRemoteCheckout:return nt(e,t.payload);default:return e}}const ti={errors:{updateShippingOptionError:{},updateError:{},deleteError:{}},statuses:{isUpdating:{},isUpdatingShippingOption:{},isDeleting:{}}};function ni(e=ti,t){return i({data:ii,errors:r(ri,ze),statuses:oi})(e,t)}function ii(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case ot.LoadShippingOptionsSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:return tt(e,t.payload&&t.payload.consignments);case Ut.SignOutCustomerSucceeded:return tt(e,[]);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.consignments);default:return e}}function ri(e=ti.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:case ot.LoadShippingOptionsSucceeded:case ot.LoadShippingOptionsRequested:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:case ot.LoadShippingOptionsFailed:return Fe(e,"loadError",t.payload);case ot.CreateConsignmentsRequested:case ot.CreateConsignmentsSucceeded:return Fe(e,"createError",void 0);case ot.CreateConsignmentsFailed:return Fe(e,"createError",t.payload);case ot.UpdateConsignmentSucceeded:case ot.UpdateConsignmentRequested:return t.meta?nt(e,{updateError:{[t.meta.id]:void 0}}):e;case ot.UpdateConsignmentFailed:return t.meta?nt(e,{updateError:{[t.meta.id]:t.payload}}):e;case ot.DeleteConsignmentSucceeded:case ot.DeleteConsignmentRequested:return t.meta?nt(e,{deleteError:{[t.meta.id]:void 0}}):e;case ot.DeleteConsignmentFailed:return t.meta?nt(e,{deleteError:{[t.meta.id]:t.payload}}):e;case ot.UpdateShippingOptionRequested:case ot.UpdateShippingOptionSucceeded:return t.meta?nt(e,{updateShippingOptionError:{[t.meta.id]:void 0}}):e;case ot.UpdateShippingOptionFailed:return t.meta?nt(e,{updateShippingOptionError:{[t.meta.id]:t.payload}}):e;default:return e}}function oi(e=ti.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case ot.LoadShippingOptionsRequested:return Fe(e,"isLoadingShippingOptions",!0);case Ve.LoadCheckoutSucceeded:case Ve.LoadCheckoutFailed:return Fe(e,"isLoading",!1);case ot.LoadShippingOptionsSucceeded:case ot.LoadShippingOptionsFailed:return Fe(e,"isLoadingShippingOptions",!1);case ot.CreateConsignmentsRequested:return Fe(e,"isCreating",!0);case ot.CreateConsignmentsSucceeded:case ot.CreateConsignmentsFailed:return Fe(e,"isCreating",!1);case ot.UpdateConsignmentRequested:return t.meta?nt(e,{isUpdating:{[t.meta.id]:!0}}):e;case ot.UpdateConsignmentSucceeded:case ot.UpdateConsignmentFailed:return t.meta?nt(e,{isUpdating:{[t.meta.id]:!1}}):e;case ot.DeleteConsignmentRequested:return t.meta?nt(e,{isDeleting:{[t.meta.id]:!0}}):e;case ot.DeleteConsignmentSucceeded:case ot.DeleteConsignmentFailed:return t.meta?nt(e,{isDeleting:{[t.meta.id]:!1}}):e;case ot.UpdateShippingOptionRequested:return t.meta?nt(e,{isUpdatingShippingOption:{[t.meta.id]:!0}}):e;case ot.UpdateShippingOptionSucceeded:case ot.UpdateShippingOptionFailed:return t.meta?nt(e,{isUpdatingShippingOption:{[t.meta.id]:!1}}):e;default:return e}}function ai(e,t){const n={};return Object.keys(e).forEach(i=>{const r=e[i],o=t?`${t}.${i}`:i;"object"==typeof r?Object.assign(n,ai(r,o)):n[o]=r}),n}function si(e){return Object.keys(e).sort().reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{})}var di;!function(e){e.LoadPickupOptionsRequested="LOAD_PICKUP_OPTIONS_REQUESTED",e.LoadPickupOptionsSucceeded="LOAD_PICKUP_OPTIONS_SUCCEEDED",e.LoadPickupOptionsFailed="LOAD_PICKUP_OPTIONS_FAILED"}(di||(di={}));const ci={errors:{},statuses:{}};function ui(e=ci,t){return i({data:li,errors:r(hi,ze),statuses:pi})(e,t)}function li(e,t){if(t.type!==di.LoadPickupOptionsSucceeded)return e;if(t.meta){const n=si(ai({consignmentId:t.meta.consignmentId,searchArea:t.meta.searchArea}));return Fe(e,btoa(`${JSON.stringify(n)}`),t.payload)}}function hi(e=ci.errors,t){switch(t.type){case di.LoadPickupOptionsRequested:case di.LoadPickupOptionsSucceeded:return Fe(e,"loadError",void 0);case di.LoadPickupOptionsFailed:return Fe(e,"loadError",t.payload);default:return e}}function pi(e=ci.statuses,t){switch(t.type){case di.LoadPickupOptionsRequested:return Fe(e,"isLoading",!0);case di.LoadPickupOptionsSucceeded:case di.LoadPickupOptionsFailed:return Fe(e,"isLoading",!1);default:return e}}var gi;!function(e){e.LoadShippingCountriesRequested="LOAD_SHIPPING_COUNTRIES_REQUESTED",e.LoadShippingCountriesSucceeded="LOAD_SHIPPING_COUNTRIES_SUCCEEDED",e.LoadShippingCountriesFailed="LOAD_SHIPPING_COUNTRIES_FAILED"}(gi||(gi={}));const mi={errors:{},statuses:{}};function yi(e=mi,t){return i({data:fi,errors:r(_i,ze),statuses:Si})(e,t)}function fi(e,t){return t.type===gi.LoadShippingCountriesSucceeded?tt(e,t.payload):e}function _i(e=mi.errors,t){switch(t.type){case gi.LoadShippingCountriesRequested:case gi.LoadShippingCountriesSucceeded:return Fe(e,"loadError",void 0);case gi.LoadShippingCountriesFailed:return Fe(e,"loadError",t.payload);default:return e}}function Si(e=mi.statuses,t){switch(t.type){case gi.LoadShippingCountriesRequested:return Fe(e,"isLoading",!0);case gi.LoadShippingCountriesSucceeded:case gi.LoadShippingCountriesFailed:return Fe(e,"isLoading",!1);default:return e}}var vi;!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"}(vi||(vi={}));const Ci={data:{},errors:{},statuses:{}};function Ii(e=Ci,t){return i({data:wi,errors:r(bi,ze),statuses:Ei})(e,t)}function wi(e=Ci.data,t){switch(t.type){case vi.InitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!0}});case vi.DeinitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!1}})}return e}function bi(e=Ci.errors,t){switch(t.type){case vi.InitializeRequested:case vi.InitializeSucceeded:return nt(e,{initializeError:void 0,initializeMethodId:void 0});case vi.InitializeFailed:return nt(e,{initializeError:t.payload,initializeMethodId:t.meta&&t.meta.methodId});case vi.DeinitializeRequested:case vi.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case vi.DeinitializeFailed:return nt(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case vi.UpdateAddressRequested:case vi.UpdateAddressSucceeded:return nt(e,{updateAddressError:void 0,updateAddressMethodId:void 0});case vi.UpdateAddressFailed:return nt(e,{updateAddressError:t.payload,updateAddressMethodId:t.meta&&t.meta.methodId});case vi.SelectOptionRequested:case vi.SelectOptionSucceeded:return nt(e,{selectOptionError:void 0,selectOptionMethodId:void 0});case vi.SelectOptionFailed:return nt(e,{selectOptionError:t.payload,selectOptionMethodId:t.meta&&t.meta.methodId});case vi.WidgetInteractionStarted:case vi.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case vi.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta&&t.meta.methodId});default:return e}}function Ei(e=Ci.statuses,t){switch(t.type){case vi.InitializeRequested:return nt(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case vi.InitializeFailed:case vi.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case vi.DeinitializeRequested:return nt(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case vi.DeinitializeFailed:case vi.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case vi.UpdateAddressRequested:return nt(e,{isUpdatingAddress:!0,updateAddressMethodId:t.meta&&t.meta.methodId});case vi.UpdateAddressFailed:case vi.UpdateAddressSucceeded:return nt(e,{isUpdatingAddress:!1,updateAddressMethodId:void 0});case vi.SelectOptionRequested:return nt(e,{isSelectingOption:!0,selectOptionMethodId:t.meta&&t.meta.methodId});case vi.SelectOptionFailed:case vi.SelectOptionSucceeded:return nt(e,{isSelectingOption:!1,selectOptionMethodId:void 0});case vi.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta&&t.meta.methodId});case vi.WidgetInteractionFinished:case vi.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var Pi;!function(e){e.SendSignInEmailRequested="SEND_SIGNIN_EMAIL_REQUESTED",e.SendSignInEmailSucceeded="SEND_SIGNIN_EMAIL_SUCCEEDED",e.SendSignInEmailFailed="SEND_SIGNIN_EMAIL_FAILED"}(Pi||(Pi={}));const Oi={errors:{},statuses:{}};function Ai(e=Oi,t){return i({data:Ti,errors:r(ki,ze),statuses:Ri})(e,t)}function Ti(e,t){return t.type===Pi.SendSignInEmailSucceeded?nt(e,t.payload):e}function ki(e=Oi.errors,t){switch(t.type){case Pi.SendSignInEmailRequested:case Pi.SendSignInEmailSucceeded:return Fe(e,"sendError",void 0);case Pi.SendSignInEmailFailed:return Fe(e,"sendError",t.payload);default:return e}}function Ri(e=Oi.statuses,t){switch(t.type){case Pi.SendSignInEmailRequested:return Fe(e,"isSending",!0);case Pi.SendSignInEmailFailed:case Pi.SendSignInEmailSucceeded:return Fe(e,"isSending",!1);default:return e}}var Di;!function(e){e.ApplyStoreCreditRequested="APPLY_STORE_CREDIT_REQUESTED",e.ApplyStoreCreditSucceeded="APPLY_STORE_CREDIT_SUCCEEDED",e.ApplyStoreCreditFailed="APPLY_STORE_CREDIT_FAILED"}(Di||(Di={}));const Mi={errors:{},statuses:{}};function Ni(e=Mi,t){return i({errors:r(Li,ze),statuses:zi})(e,t)}function Li(e=Mi.errors,t){switch(t.type){case Di.ApplyStoreCreditRequested:case Di.ApplyStoreCreditSucceeded:return Fe(e,"applyError",void 0);case Di.ApplyStoreCreditFailed:return Fe(e,"applyError",t.payload);default:return e}}function zi(e=Mi.statuses,t){switch(t.type){case Di.ApplyStoreCreditRequested:return Fe(e,"isApplying",!0);case Di.ApplyStoreCreditSucceeded:case Di.ApplyStoreCreditFailed:return Fe(e,"isApplying",!1);default:return e}}const Ui={errors:{},statuses:{}};function Fi(e=Ui,t){return i({errors:r(Bi,ze),statuses:xi})(e,t)}function Bi(e=Ui.errors,t){switch(t.type){case We.UpdateSubscriptionsRequested:case We.UpdateSubscriptionsSucceeded:return Fe(e,"updateError",void 0);case We.UpdateSubscriptionsFailed:return Fe(e,"updateError",t.payload);default:return e}}function xi(e=Ui.statuses,t){switch(t.type){case We.UpdateSubscriptionsRequested:return Fe(e,"isUpdating",!0);case We.UpdateSubscriptionsFailed:case We.UpdateSubscriptionsSucceeded:return Fe(e,"isUpdating",!1);default:return e}}var qi;!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"}(qi||(qi={}));const ji={errors:{},statuses:{}};function Gi(e=ji,t){return i({data:Vi,errors:r(Hi,ze),statuses:Wi})(e,t)}function Vi(e,t){var n;switch(t.type){case Ve.LoadCheckoutSucceeded:case Ve.UpdateCheckoutSucceeded:case Di.ApplyStoreCreditSucceeded:case Ye.UpdateBillingAddressSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case ot.LoadShippingOptionsSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:case qi.VerifyCheckoutSucceeded:return nt(e,k(t.payload,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));case Ve.DeleteCheckoutSucceeded:return;case Pt.SubmitOrderSucceeded:return Fe(e,"orderId",t.payload&&t.payload.order.orderId);case He.HydrateInitialState:return nt(e,k(null===(n=t.payload)||void 0===n?void 0:n.checkout,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));default:return e}}function Hi(e=ji.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);case Ve.UpdateCheckoutRequested:case Ve.UpdateCheckoutSucceeded:return Fe(e,"updateError",void 0);case Ve.UpdateCheckoutFailed:return Fe(e,"updateError",t.payload);case Ve.DeleteCheckoutRequested:case Ve.DeleteCheckoutSucceeded:return Fe(e,"deleteError",void 0);case Ve.DeleteCheckoutFailed:return Fe(e,"deleteError",t.payload);default:return e}}function Wi(e=ji.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutFailed:case Ve.LoadCheckoutSucceeded:return Fe(e,"isLoading",!1);case Ve.UpdateCheckoutRequested:return Fe(e,"isUpdating",!0);case Ve.UpdateCheckoutFailed:case Ve.UpdateCheckoutSucceeded:return Fe(e,"isUpdating",!1);case Ve.DeleteCheckoutRequested:return Fe(e,"isDeleting",!0);case Ve.DeleteCheckoutFailed:case Ve.DeleteCheckoutSucceeded:return Fe(e,"isDeleting",!1);case qi.ExecuteRequested:return Fe(e,"isExecutingSpamCheck",!0);case qi.ExecuteFailed:case qi.ExecuteSucceeded:return Fe(e,"isExecutingSpamCheck",!1);default:return e}}const Yi=(Ki=de,(...e)=>{const t=e.pop();return Ki(...e,(...e)=>{const n=t(...e);return"function"==typeof n?ae(n):n})});var Ki,$i;!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"}($i||($i={}));class Zi extends be{constructor(e){super(function(e){switch(e){case $i.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case $i.MissingCart:return"Unable to proceed because cart data is unavailable.";case $i.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case $i.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case $i.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case $i.MissingCheckoutConfig:case $i.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case $i.MissingOrder:return"Unable to proceed because order data is unavailable.";case $i.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case $i.MissingPayment:return"Unable to proceed because payment data is unavailable.";case $i.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case $i.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case $i.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case $i.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function Ji(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function Qi(e){return function(e){const t=Object.create(e);return function(e,t){let n=Object.getPrototypeOf(e);for(;n;)t(n),n=Object.getPrototypeOf(n)}(e,n=>{Object.getOwnPropertyNames(n).forEach(n=>{"constructor"!==n&&"function"==typeof t[n]&&"_"!==n.charAt(0)&&(t[n]=((e,t)=>(...n)=>d(e[t].call(e,...n)))(e,n))})}),t}(e)}const Xi="b2bExtraField_";function er(e){var t;const{fieldType:n,type:i}=function(e){switch(e){case"multiline_text":return{fieldType:"multiline",type:"string"};case"number":return{fieldType:"text",type:"integer"};case"dropdown":return{fieldType:"dropdown",type:"array"};default:return{fieldType:"text",type:"string"}}}(e.type);let r;return e.config.numberOfRows&&(r={rows:e.config.numberOfRows}),(null===(t=e.config.options)||void 0===t?void 0:t.length)&&(r=Object.assign(Object.assign({},r),{items:e.config.options.map(e=>({value:e,label:e}))})),{id:`${Xi}${e.id}`,name:`${Xi}${e.id}`,custom:!1,label:e.name,hidden:!e.visibleToStorefront,required:e.isRequired,default:null!=e.config.defaultValue?String(e.config.defaultValue):void 0,fieldType:n,type:i,maxLength:e.config.maxLength,max:e.config.maxValue,options:r}}const tr={"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"},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"},moneris:{provider:"moneris",method:"credit_card"},cba_mpgs:{provider:"cba_mpgs",method:"credit_card"},worldpayaccess:{provider:"worldpayaccess",method:"credit_card"},"worldpayaccess.credit_card":{provider:"worldpayaccess",method:"credit_card"},squarev2:{provider:"squarev2",method:"credit_card"},paypalcommercecreditcards:{provider:"paypalcommerce",method:"credit_card"},paypalcommerce:{provider:"paypalcommerce",method:"paypal"},bigcommerce_payments_creditcards:{provider:"bigcommerce_payments",method:"credit_card"},bigcommerce_payments:{provider:"bigcommerce_payments",method:"paypal"},tdonlinemart:{provider:"tdonlinemart",method:"credit_card"}};function nr(e){return M({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},g)}const ir={errors:{},statuses:{}};function rr(){const e=function(){const e=Yi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.token},e=>()=>e),t=Yi(e=>e.errors.loadError,e=>()=>e),n=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=Be)=>({getToken:e(i),getLoadError:t(i),isLoading:n(i)}))}(),t=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingBillingAddress))),n=Yi(e=>e.errors.updateError,e=>()=>e),i=Yi(e=>e.errors.continueAsGuestError,e=>()=>e),r=Yi(e=>e.errors.loadError,e=>()=>e),o=Yi(e=>!!e.statuses.isUpdating,e=>()=>e),a=Yi(e=>!!e.statuses.isContinuingAsGuest,e=>()=>e),s=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((d=$e)=>({getBillingAddress:e(d),getBillingAddressOrThrow:t(d),getUpdateError:n(d),getContinueAsGuestError:i(d),getLoadError:r(d),isUpdating:o(d),isContinuingAsGuest:a(d),isLoading:s(d)}))}(),n=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingCart))),n=Yi(e=>e.errors.loadError,e=>()=>e),i=Yi(e=>!!e.statuses.isLoading,e=>()=>e),r=Yi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.locale},e=>()=>e);return se((o=at)=>({getCart:e(o),getCartOrThrow:t(o),getLoadError:n(o),isLoading:i(o),getLocale:r(o)}))}(),i=function(){const e=Yi(e=>e,e=>()=>e),t=Yi(e=>e.statuses,e=>ae(t=>{if(t){const n=e[t];return!0===(n&&n.isInitializing)}return z(e,{isInitializing:!0})})),n=Yi(e=>e.data,e=>ae((t,n)=>{const i=e[t];return!!i&&(n?!0===i.initializedContainers[n]:z(i.initializedContainers,e=>!0===e))})),i=Yi(e=>e.statuses,e=>ae(t=>{if(t){const n=e[t];return!0===(n&&n.isDeinitializing)}return z(e,{isDeinitializing:!0})})),r=Yi(e=>e.errors,e=>ae(t=>{const n=t?e[t]:l(x(e),e=>!(!e||!e.initializeError));return n&&n.initializeError})),o=Yi(e=>e.errors,e=>ae(t=>{const n=t?e[t]:l(x(e),e=>!(!e||!e.deinitializeError));return n&&n.deinitializeError}));return se((a=ht)=>({getState:e(a),isInitializing:t(a),isInitialized:n(a),isDeinitializing:i(a),getInitializeError:r(a),getDeinitializeError:o(a)}))}(),r=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.data,e=>t=>{if(!e)return;const{flashMessages:n}=e.context;return n?void 0!==t?n.filter(({type:e})=>t===e):n:void 0}),n=Yi(e=>e.data,(e,{formState:t})=>t&&t.data,(e,t={customerAccount:[],shippingAddress:[],billingAddress:[]})=>()=>e?Object.assign(Object.assign({},e.storeConfig),{formFields:t}):void 0),i=Yi(n,e=>()=>Ji(e(),()=>new Zi($i.MissingCheckoutConfig))),r=Yi(e=>e.data&&e.data.context,e=>()=>e),o=Yi(e=>e.meta&&e.meta.externalSource,e=>()=>e),a=Yi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.host},e=>()=>e),s=Yi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.locale},e=>()=>e),d=Yi(e=>e.meta&&e.meta.variantIdentificationToken,e=>()=>e),c=Yi(e=>e.errors.loadError,e=>()=>e),u=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((l=Ct,h)=>({getConfig:e(l),getFlashMessages:t(l),getStoreConfig:n(l,{formState:h}),getStoreConfigOrThrow:i(l,{formState:h}),getContextConfig:r(l),getExternalSource:o(l),getHost:a(l),getLocale:s(l),getVariantIdentificationToken:d(l),getLoadError:c(l),isLoading:u(l)}))}(),o=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.loadError,e=>()=>e),n=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=un)=>({getCountries:e(i),getLoadError:t(i),isLoading:n(i)}))}(),a=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.removeCouponError,e=>()=>e),n=Yi(e=>e.errors.applyCouponError,e=>()=>e),i=Yi(e=>!!e.statuses.isApplyingCoupon,e=>()=>e),r=Yi(e=>!!e.statuses.isRemovingCoupon,e=>()=>e);return se((o=Ot)=>({getCoupons:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:i(o),isRemoving:r(o)}))}(),s=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingCustomer))),n=Yi(e=>e.errors.createError,e=>()=>e),i=Yi(e=>!!e.statuses.isCreating,e=>()=>e),r=Yi(e=>e.errors.createAddressError,e=>()=>e),o=Yi(e=>!!e.statuses.isCreatingAddress,e=>()=>e);return se((a=Ft)=>({getCustomer:e(a),getCustomerOrThrow:t(a),getCreateAccountError:n(a),isCreatingCustomerAccount:i(a),getCreateAddressError:r(a),isCreatingCustomerAddress:o(a)}))}(),d=function(){const e=Yi(e=>e.errors.signInMethodId,e=>e.errors.signInError,(e,t)=>n=>{if(!n||e===n)return t}),t=Yi(e=>e.errors.signOutMethodId,e=>e.errors.signOutError,(e,t)=>n=>{if(!n||e===n)return t}),n=Yi(e=>e.errors.executePaymentMethodCheckoutMethodId,e=>e.errors.executePaymentMethodCheckoutError,(e,t)=>n=>{if(!n||e===n)return t}),i=Yi(e=>e.errors.initializeMethodId,e=>e.errors.initializeErrors,(e,t)=>n=>{if(e&&t)return n?t[n]:t[e]}),r=Yi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),o=Yi(e=>e.statuses.signInMethodId,e=>e.statuses.isSigningIn,(e,t)=>n=>!(n&&e!==n||!t)),a=Yi(e=>e.statuses.signOutMethodId,e=>e.statuses.isSigningOut,(e,t)=>n=>!(n&&e!==n||!t)),s=Yi(e=>e.statuses.executePaymentMethodCheckoutMethodId,e=>e.statuses.isExecutingPaymentMethodCheckout,(e,t)=>n=>!(n&&e!==n||!t)),d=Yi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),c=Yi(e=>e.data,e=>t=>!(!e[t]||!e[t].isInitialized)),u=Yi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((l=Vt)=>({getSignInError:e(l),getSignOutError:t(l),getExecutePaymentMethodCheckoutError:n(l),getInitializeError:i(l),getWidgetInteractionError:r(l),isSigningIn:o(l),isSigningOut:a(l),isExecutingPaymentMethodCheckout:s(l),isInitializing:d(l),isInitialized:c(l),isWidgetInteracting:u(l)}))}(),c=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.removeGiftCertificateError,e=>()=>e),n=Yi(e=>e.errors.applyGiftCertificateError,e=>()=>e),i=Yi(e=>!!e.statuses.isApplyingGiftCertificate,e=>()=>e),r=Yi(e=>!!e.statuses.isRemovingGiftCertificate,e=>()=>e);return se((o=Dt)=>({getGiftCertificates:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:i(o),isRemoving:r(o)}))}(),h=function(){const e=Yi(e=>e.data,e=>t=>{if(!e)return;const n=t.gateway?`${t.gateway}.${t.id}`:t.id,i=tr[n];return i?u(e,i):[]}),t=Yi(e=>e.data,(e=[])=>t=>{const n=x(tr);return e.find(e=>e.bigpayToken===t&&"card"===e.type&&n.some(t=>S(e,t)))}),n=Yi(t,e=>t=>Ji(e(t),()=>new Zi($i.MissingPaymentInstrument))),i=Yi(e=>e.data,e=>()=>{if(e)return p(tr,t=>u(e,e=>S(e,t)))}),r=Yi(e=>e.meta,e=>()=>e),o=Yi(e=>e.errors.loadError,e=>()=>e),a=Yi(e=>e.errors.failedInstrument,e=>e.errors.deleteError,(e,t)=>n=>{if(!n||e===n)return t}),s=Yi(e=>e.statuses.isLoading,e=>()=>!!e),d=Yi(e=>e.statuses.deletingInstrument,e=>e.statuses.isDeleting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=qn)=>({getCardInstrument:t(c),getCardInstrumentOrThrow:n(c),getInstruments:i(c),getInstrumentsByPaymentMethod:e(c),getInstrumentsMeta:r(c),getLoadError:o(c),getDeleteError:a(c),isLoading:s(c),isDeleting:d(c)}))}(),g=function(){const e=Yi(e=>e.data,e=>(t=[],n)=>{const i=l(t,{code:n});return(e?e.shippingAddress:[]).map(e=>s(e,t,i))}),t=Yi(e=>e.data,e=>(t=[],n)=>{const i=l(t,{code:n});return(e?e.billingAddress:[]).map(e=>s(e,t,i))}),n=Yi(e=>e.data,e=>()=>e?e.customerAccount:[]),i=Yi(e=>e.extraFields,e=>()=>e&&e.address.length?e.address.map(er):[]),r=Yi(e=>e.extraFields,e=>()=>e&&e.order.length?e.order.map(er):[]),o=Yi(e=>e.errors.loadError,e=>()=>e),a=Yi(e=>!!e.statuses.isLoading,e=>()=>e);function s(e,t,n){return"countryCode"===e.name?function(e,t=[],n){if(!t.length)return e;const{code:i=""}=n||{},r=t.map(({code:e,name:t})=>({value:e,label:t}));return Object.assign(Object.assign({},e),{options:{items:r},default:i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,t,n):"stateOrProvince"===e.name?function(e,t){const{subdivisions:n=[],requiresState:i}=t||{};if(!n.length)return Object.assign(Object.assign({},e),{required:null!=i&&i});const r=n.map(({code:e,name:t})=>({value:e,label:t}));return Object.assign(Object.assign({},e),{name:"stateOrProvinceCode",options:{items:r},required:null==i||i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,n):"postalCode"===e.name?function(e,t){const{hasPostalCodes:n=[]}=t||{};return void 0===n?e:Object.assign(Object.assign({},e),{required:Boolean(n)})}(e,n):e}return se((s=nn)=>({getShippingAddressFields:e(s),getBillingAddressFields:t(s),getCustomerAccountFields:n(s),getAddressExtraFields:i(s),getOrderExtraFields:r(s),getLoadError:o(s),isLoading:a(s)}))}(),m=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.meta,e=>()=>e),n=Yi(e=>e.data,e=>(t,n)=>l(e,n?{id:t,gateway:n}:{id:t})),i=Yi(n,e=>(t,n)=>Ji(e(t,n),()=>new Zi($i.MissingPaymentMethod))),r=Yi(e=>e.errors.loadError,e=>()=>e),o=Yi(e=>e.errors.loadMethodId,e=>e.errors.loadMethodError,(e,t)=>n=>{if(!n||e===n)return t}),a=Yi(e=>e.statuses.isLoading,e=>()=>!!e),s=Yi(e=>e.statuses.loadMethodId,e=>e.statuses.isLoadingMethod,(e,t)=>n=>!(n&&e!==n||!t));return se((d=An)=>({getPaymentMethods:e(d),getPaymentMethodsMeta:t(d),getPaymentMethod:n(d),getPaymentMethodOrThrow:i(d),getLoadError:r(d),getLoadMethodError:o(d),isLoading:a(d),isLoadingMethod:s(d)}))}(),y=function(){const e=Yi(e=>e.errors.initializeMethodId,e=>e.errors.initializeError,(e,t)=>n=>{if(!n||e===n)return t}),t=Yi(e=>e.errors.executeMethodId,e=>e.errors.executeError,(e,t)=>n=>{if(!n||e===n)return t}),n=Yi(e=>e.errors.finalizeMethodId,e=>e.errors.finalizeError,(e,t)=>n=>{if(!n||e===n)return t}),i=Yi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),r=Yi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),o=Yi(e=>e.data,e=>t=>{const n=t.gatewayId?`${t.methodId}.${t.gatewayId}`:t.methodId;return!(!e[n]||!e[n].isInitialized)}),a=Yi(e=>e.statuses.executeMethodId,e=>e.statuses.isExecuting,(e,t)=>n=>!(n&&e!==n||!t)),s=Yi(e=>e.statuses.finalizeMethodId,e=>e.statuses.isFinalizing,(e,t)=>n=>!(n&&e!==n||!t)),d=Yi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=Ln)=>({getInitializeError:e(c),getExecuteError:t(c),getFinalizeError:n(c),getWidgetInteractingError:i(c),isInitializing:r(c),isInitialized:o(c),isExecuting:a(c),isFinalizing:s(c),isWidgetInteracting:d(c)}))}(),f=function(){const e=Yi(e=>e.data,e=>(t,n)=>{if(!e)return;const i=si(ai({consignmentId:t,searchArea:n})),r=btoa(`${JSON.stringify(i)}`);return e[r]}),t=Yi(e=>e.errors.loadError,e=>()=>e),n=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=ci)=>({getPickupOptions:e(i),getLoadError:t(i),isLoading:n(i)}))}(),v=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentProviderCustomer)));return se((n=Kn)=>({getPaymentProviderCustomer:e(n),getPaymentProviderCustomerOrThrow:t(n)}))}(),C=function(){const e=Yi(e=>e.data,e=>t=>e[t]);return se((t=Qn)=>({getCheckout:e(t)}))}(),I=function(){const e=Yi(e=>e.data,e=>()=>{const t=null==e?void 0:e.find(e=>!e.selectedPickupOption);return null==t?void 0:t.shippingAddress}),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingShippingAddress))),n=Yi(e=>e.data,e=>()=>{const t=null==e?void 0:e.filter(e=>!e.selectedPickupOption);return t?t.map(e=>e.shippingAddress):[]}),i=Yi(n,e=>()=>Ji(e(),()=>new Zi($i.MissingShippingAddress)));return se((r=ti)=>({getShippingAddress:e(r),getShippingAddressOrThrow:t(r),getShippingAddresses:n(r),getShippingAddressesOrThrow:i(r)}))}(),w=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.loadError,e=>()=>e),n=Yi(e=>e.statuses.isLoading,e=>()=>!!e);return se((i=mi)=>({getShippingCountries:e(i),getLoadError:t(i),isLoading:n(i)}))}(),b=function(){const e=Yi(e=>e.errors.updateAddressMethodId,e=>e.errors.updateAddressError,(e,t)=>n=>{if(!n||e===n)return t}),t=Yi(e=>e.errors.selectOptionMethodId,e=>e.errors.selectOptionError,(e,t)=>n=>{if(!n||e===n)return t}),n=Yi(e=>e.errors.initializeMethodId,e=>e.errors.initializeError,(e,t)=>n=>{if(!n||e===n)return t}),i=Yi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),r=Yi(e=>e.statuses.updateAddressMethodId,e=>e.statuses.isUpdatingAddress,(e,t)=>n=>!(n&&e!==n||!t)),o=Yi(e=>e.statuses.selectOptionMethodId,e=>e.statuses.isSelectingOption,(e,t)=>n=>!(n&&e!==n||!t)),a=Yi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),s=Yi(e=>e.data,e=>t=>!(!e[t]||!e[t].isInitialized)),d=Yi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=Ci)=>({getUpdateAddressError:e(c),getSelectOptionError:t(c),getInitializeError:n(c),getWidgetInteractionError:i(c),isUpdatingAddress:r(c),isSelectingOption:o(c),isInitializing:a(c),isInitialized:s(c),isWidgetInteracting:d(c)}))}(),E=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingConsignments))),n=Yi(e=>e.data,e=>t=>{if(e&&e.length)return l(e,{id:t})}),i=Yi(e=>e.data,e=>t=>{if(e&&e.length)return l(e,e=>{return n=e.shippingAddress,i=t,_(nr(n),nr(i));var n,i})}),r=Yi(e=>e.data,e=>()=>{if(e&&e.length)return e[0].selectedShippingOption}),o=Yi(e=>e.errors.loadError,e=>()=>e),a=Yi(e=>e.errors.createError,e=>()=>e),s=Yi(e=>e.errors.loadShippingOptionsError,e=>()=>e),d=Yi(e,(e,{cart:t})=>t.getCart,(e,t)=>()=>{const n=t();if(!n)return[];const i=(e()||[]).reduce((e,t)=>e.concat(t.lineItemIds),[]);return(n.lineItems.physicalItems||[]).filter(e=>i.indexOf(e.id)<0)}),c=Yi(e=>e.errors.updateError,e=>t=>t?e[t]:l(e)),u=Yi(e=>e.errors.deleteError,e=>t=>t?e[t]:l(e)),h=Yi(i,c,a,(e,t,n)=>i=>{const r=e(i);return r?t(r.id):n()}),p=Yi(e=>e.errors.updateShippingOptionError,e=>t=>t?e[t]:l(e)),g=Yi(e=>e.statuses.isLoading,e=>()=>!0===e),m=Yi(e=>e.statuses.isLoadingShippingOptions,e=>()=>!0===e),y=Yi(e=>e.statuses.isCreating,e=>()=>!0===e),f=Yi(e=>e.statuses.isUpdating,e=>t=>t?!0===e[t]:!0===l(e)),S=Yi(e=>e.statuses.isDeleting,e=>t=>t?!0===e[t]:!0===l(e)),v=Yi(i,f,y,(e,t,n)=>i=>{const r=e(i);return r?t(r.id):n()}),C=Yi(e=>e.statuses.isUpdatingShippingOption,e=>t=>t?!0===e[t]:!0===l(e));return se((l=ti,_)=>({getConsignments:e(l),getConsignmentsOrThrow:t(l),getConsignmentById:n(l),getConsignmentByAddress:i(l),getShippingOption:r(l),getLoadError:o(l),getCreateError:a(l),getLoadShippingOptionsError:s(l),getUnassignedItems:d(l,{cart:_}),getUpdateError:c(l),getDeleteError:u(l),getItemAssignmentError:h(l),getUpdateShippingOptionError:p(l),isLoading:g(l),isLoadingShippingOptions:m(l),isCreating:y(l),isUpdating:f(l),isDeleting:S(l),isAssigningItems:v(l),isUpdatingShippingOption:C(l)}))}(),P=function(){const e=Yi(e=>e.data,(e,{billingAddress:t})=>t.getBillingAddress,(e,{cart:t})=>t.getCart,(e,{customer:t})=>t.getCustomer,(e,{consignments:t})=>t.getConsignments,(e,{coupons:t})=>t.getCoupons,(e,{giftCertificates:t})=>t.getGiftCertificates,(e,t,n,i,r,o,a)=>()=>{const s=t(),d=n(),c=i(),u=r()||[],l=o()||[],h=a()||[];if(e&&d&&c)return Object.assign(Object.assign({},e),{billingAddress:s,cart:d,customer:c,consignments:u,coupons:l,giftCertificates:h})}),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingCheckout))),n=Yi(e,e=>t=>{const n=e();if(!n)return;const i=n.grandTotal||0,r=n.customer.storeCredit||0;return t?Math.max(i-r,0):n.outstandingBalance}),i=Yi(e=>e.errors.loadError,e=>()=>e),r=Yi(e=>e.errors.updateError,e=>()=>e),o=Yi(e=>e.errors.deleteError,e=>()=>e),a=Yi(e=>e.statuses.isExecutingSpamCheck,e=>()=>!0===e),s=Yi(e=>e.statuses.isLoading,e=>()=>!0===e),d=Yi(e=>e.statuses.isUpdating,e=>()=>!0===e),c=Yi(e=>e.statuses.isDeleting,e=>()=>!0===e);return se((u=ji,l,h,p,g,m,y)=>({getCheckout:e(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getCheckoutOrThrow:t(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getOutstandingBalance:n(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getLoadError:i(u),getUpdateError:r(u),getDeleteError:o(u),isExecutingSpamCheck:a(u),isLoading:s(u),isUpdating:d(u),isDeleting:c(u)}))}(),O=function(){const e=Yi(e=>e.data,(e,{billingAddress:t})=>t.getOrderBillingAddress(),(e,{coupons:t})=>t.getCoupons(),(e,t,n=[])=>()=>{if(e&&t)return Object.assign(Object.assign({},e),{billingAddress:t,coupons:n})}),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingOrder))),n=Yi(e=>e.meta,e=>()=>e),i=Yi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.b2bReceiptId},e=>()=>e),r=Yi(e=>e.errors.loadError,e=>()=>e),o=Yi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.payments},(e=[])=>t=>{const n=e.find(({providerId:e})=>e===t);return null==n?void 0:n.paymentId}),a=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((s=mn,d,c)=>({getOrder:e(s,{billingAddress:d,coupons:c}),getOrderOrThrow:t(s,{billingAddress:d,coupons:c}),getOrderMeta:n(s),getB2BReceiptId:i(s),getLoadError:r(s),getPaymentId:o(s),isLoading:a(s)}))}(),A=function(){const e=Yi(e=>e.data,e=>()=>e);return se((t=Cn)=>({getOrderBillingAddress:e(t)}))}(),T=function(){const e=Yi(({order:e})=>e.getOrderMeta,e=>()=>{const t=e();return t&&t.payment}),t=Yi(({order:e})=>e.getOrder,e=>()=>{const t=e();return l(t&&t.payments,({providerId:e})=>"giftcertificate"!==e&&"storecredit"!==e)}),n=Yi(({checkout:e})=>e.getCheckout,e=>()=>{const t=e();return l(t&&t.payments,({providerType:e})=>"PAYMENT_TYPE_HOSTED"===e)}),i=Yi(e,n,t,(e,t,n)=>()=>{const i=e();if(i&&i.id)return{providerId:i.id,gatewayId:i.gateway};const r=t()||n();return r&&r.providerId?{providerId:r.providerId,gatewayId:r.gatewayId}:void 0}),r=Yi(i,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentId))),o=Yi(e,n,t,(e,t,n)=>()=>{const i=e();if(i&&i.status)return i.status.replace("PAYMENT_STATUS_","");const r=t()||n();return r?r.detail.step:void 0}),a=Yi(o,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentStatus))),s=Yi(({order:e})=>e.getOrderMeta,e=>()=>{const t=e();return t&&t.token}),d=Yi(s,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentToken))),c=Yi(e,e=>()=>{const t=e();return t&&t.redirectUrl}),u=Yi(c,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentRedirectUrl))),h=Yi(({checkout:e})=>e.getOutstandingBalance,e=>(t=!1)=>{const n=e(t);return!!n&&n>0}),p=Yi(o,e=>t=>!(!t||!t.nonce)||"ACKNOWLEDGE"===e()||"FINALIZE"===e());return se((e,t)=>({getPaymentId:i({checkout:e,order:t}),getPaymentIdOrThrow:r({checkout:e,order:t}),getPaymentStatus:o({checkout:e,order:t}),getPaymentStatusOrThrow:a({checkout:e,order:t}),getPaymentToken:s({checkout:e,order:t}),getPaymentTokenOrThrow:d({checkout:e,order:t}),getPaymentRedirectUrl:c({checkout:e,order:t}),getPaymentRedirectUrlOrThrow:u({checkout:e,order:t}),isPaymentDataRequired:h({checkout:e,order:t}),isPaymentDataSubmitted:p({checkout:e,order:t})}))}(),k=function(){const e=Yi(e=>e.errors.applyError,e=>()=>e),t=Yi(e=>!!e.statuses.isApplying,e=>()=>e);return se((n=ir)=>({getApplyError:e(n),isApplying:t(n)}))}(),R=function(){const e=Yi(e=>e.errors.updateError,e=>()=>e),t=Yi(e=>!!e.statuses.isUpdating,e=>()=>e);return se((n=Ui)=>({getUpdateError:e(n),isUpdating:t(n)}))}(),D=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.sendError,e=>()=>e),n=Yi(e=>!!e.statuses.isSending,e=>()=>e);return se((i=Oi)=>({getEmail:e(i),getSendError:t(i),isSending:n(i)}))}(),M=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.data,e=>t=>null==e?void 0:e.find(e=>e.region===t)),n=Yi(e=>e.errors.loadError,e=>()=>e),i=Yi(e=>e.statuses.isLoading,e=>()=>!!e);return se((r=Zt)=>({getExtensions:e(r),getExtensionByRegion:t(r),getLoadError:n(r),isLoading:i(r)}))}();return(u,l={})=>{const p=e(u.b2bToken),_=t(u.billingAddress),S=n(u.cart),N=i(u.checkoutButton),L=o(u.countries),z=a(u.coupons),U=s(u.customer),F=d(u.customerStrategies),B=M(u.extensions),x=g(u.formFields),q=c(u.giftCertificates),j=h(u.instruments),G=A(u.orderBillingAddress),V=m(u.paymentMethods),H=v(u.paymentProviderCustomer),W=y(u.paymentStrategies),Y=f(u.pickupOptions),K=C(u.remoteCheckout),$=I(u.consignments),Z=w(u.shippingCountries),J=b(u.shippingStrategies),Q=R(u.subscriptions),X=k(u.storeCredit),ee=D(u.signInEmail),te=E(u.consignments,S),ne=P(u.checkout,_,S,te,z,U,q),ie=O(u.order,G,z),re=T(ne,ie),oe={b2bToken:p,billingAddress:_,cart:S,checkout:ne,checkoutButton:N,config:r(u.config,u.formFields),consignments:te,countries:L,coupons:z,customer:U,customerStrategies:F,extensions:B,form:x,giftCertificates:q,instruments:j,order:ie,orderBillingAddress:G,payment:re,paymentMethods:V,paymentProviderCustomer:H,paymentStrategies:W,pickupOptions:Y,remoteCheckout:K,shippingAddress:$,shippingCountries:Z,shippingStrategies:J,signInEmail:ee,subscriptions:Q,storeCredit:X};return l.shouldWarnMutation?(ae=oe,Object.keys(ae).reduce((e,t)=>(e[t]=Qi(ae[t]),e),{})):oe;var ae}}function or(e={},t){const n=(s=function(){const e=new De;return["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(t=>{e.register(t,(e,t)=>new Oe(e,t))}),e.register("invalid_payment_provider",e=>new we(e)),e.register("payment_config_not_found",e=>new we(e)),e}(),e=>Y(e).pipe(Q(e=>{if(e instanceof Error||e.payload instanceof Error)throw e;if((t=e.payload)&&"object"==typeof t&&["body","headers","status","statusText"].every(e=>Object.prototype.hasOwnProperty.call(t,e))){const t=e.payload.body&&e.payload.body.detail;throw Object.assign(Object.assign({},e),{payload:s.createError(e.payload,t)})}var t;throw e}))),r=rr(),o=i({b2bToken:xe,billingAddress:Ze,cart:st,checkout:Gi,checkoutButton:yt,config:It,consignments:ni,countries:ln,coupons:At,customer:Bt,customerStrategies:Ht,extensions:Jt,formFields:rn,giftCertificates:Mt,instruments:jn,orderBillingAddress:In,order:yn,payment:Pn,paymentMethods:Tn,paymentStrategies:zn,pickupOptions:ui,paymentProviderCustomer:$n,remoteCheckout:Xn,shippingCountries:yi,shippingStrategies:Ii,signInEmail:Ai,subscriptions:Fi,storeCredit:Ni});var s;return a(o,e,Object.assign({actionTransformer:n,stateTransformer:e=>r(e)},t))}var ar,sr;!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"}(ar||(ar={}));class dr extends ve{constructor(e){super(function(e){switch(e){case ar.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case ar.MissingCart:return"Unable to proceed because cart data is unavailable.";case ar.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case ar.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case ar.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case ar.MissingCheckoutConfig:case ar.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case ar.MissingOrder:return"Unable to proceed because order data is unavailable.";case ar.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case ar.MissingPayment:return"Unable to proceed because payment data is unavailable.";case ar.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case ar.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case ar.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function cr(e){return t=e.lineItems.physicalItems.filter(e=>!e.addedByPromotion),N(t,(e,t)=>e+t.quantity,0);var t}function ur(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}!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"}(sr||(sr={}));class lr extends ve{constructor(e){super(function(e){switch(e){case sr.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case sr.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case sr.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case sr.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."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}const hr={de:"eu",jp:"fe",uk:"eu",us:"na"};var pr,gr,mr,yr,fr;!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"}(pr||(pr={})),function(e){e.Home="Home",e.Product="Product",e.Cart="Cart",e.Checkout="Checkout",e.Other="Other"}(gr||(gr={})),function(e){e.USD="USD",e.EUR="EUR",e.GBP="GBP",e.JPY="JPY"}(mr||(mr={})),function(e){e.PayAndShip="PayAndShip",e.PayOnly="PayOnly"}(yr||(yr={})),function(e){e.Gold="Gold",e.LightGray="LightGray",e.DarkGray="DarkGray"}(fr||(fr={}));var _r=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Sr{constructor(e){this.amazonPayV2ScriptLoader=e}initialize(e){return _r(this,void 0,void 0,function*(){this.amazonPayV2SDK=yield this.amazonPayV2ScriptLoader.load(e),this.buttonParentContainer=this.buttonParentContainer||this.createAmazonPayButtonParentContainer()})}deinitialize(){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()}bindButton(e,t,n){this.getAmazonPayV2SDK().Pay.bindChangeAction(`#${e}`,{amazonCheckoutSessionId:t,changeAction:n})}createButton(e,t){this.amazonPayV2Button=this.getAmazonPayV2SDK().Pay.renderButton(`#${e}`,t)}prepareCheckout(e){const t=this.prepareRequestConfig(e);this.getAmazonPayV2Button().onClick(()=>{this.getAmazonPayV2Button().initCheckout(t)})}prepareCheckoutWithCreationRequestConfig(e){this.getAmazonPayV2Button().onClick(()=>_r(this,void 0,void 0,function*(){const t=yield e();if(t){const e=this.prepareRequestConfig(t.createCheckoutSessionConfig,t.estimatedOrderAmount,t.productType);this.getAmazonPayV2Button().initCheckout(e)}}))}signout(){return _r(this,void 0,void 0,function*(){return this.amazonPayV2SDK&&this.amazonPayV2SDK.Pay.signout(),Promise.resolve()})}renderAmazonPayButton({buttonColor:e,checkoutState:t,containerId:n,decoupleCheckoutInitiation:i=!1,methodId:r,options:o,placement:a}){const s=document.querySelector(`#${n}`);if(!s)return;const{id:d}=s.appendChild(this.getButtonParentContainer()),c=null!=o?o:this.getAmazonPayV2ButtonOptions(t,r,a,i,e);return this.createButton(d,c),this.getButtonParentContainer()}updateBuyNowFlowFlag(e){this.isBuyNowFlow=Boolean(e)}isPh4Enabled(e,t){const n=!!e["PROJECT-3483.amazon_pay_ph4"],i=!!e["INT-6885.amazon_pay_ph4_us_only"];return n&&i?"US"===t:n}prepareRequestConfig(e,t,n){const{publicKeyId:i}=e,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["publicKeyId"]);return Object.assign(Object.assign({createCheckoutSessionConfig:this.isEnvironmentSpecific(i)?r:e},t&&{estimatedOrderAmount:t}),n&&{productType:n})}createAmazonPayButtonParentContainer(){const e=Math.random().toString(16).substr(-4),t=document.createElement("div");return t.id=`amazonpay_button_parent_container_${e}`,t}getAmazonPayV2ButtonOptions(e,t,n,i=!1,r=fr.Gold){var o;const{getCart:a,getCheckout:s,getStoreConfigOrThrow:d,getPaymentMethodOrThrow:c}=this.getCheckoutState(e),{config:{merchantId:u,testMode:l},initializationData:h}=c(t);if(!h)throw new dr(ar.MissingPaymentMethod);const{checkoutLanguage:p,checkoutSessionMethod:g,createCheckoutSessionConfig:m,extractAmazonCheckoutSessionId:y,ledgerCurrency:f,publicKeyId:_=""}=h;if(!u||!f)throw new dr(ar.MissingPaymentMethod);const S={merchantId:u,ledgerCurrency:f,checkoutLanguage:p,placement:n,buttonColor:r};if(this.isBuyNowFlow)return Object.assign(Object.assign({},S),{sandbox:!!l});const v=a();S.productType=v&&0===cr(v)?yr.PayOnly:yr.PayAndShip;const{checkoutSettings:{features:C},storeProfile:{shopPath:I,storeCountryCode:w}}=d();if(this.isPh4Enabled(C,w)){if(!m)throw new dr(ar.MissingPaymentMethod);const e=null===(o=s())||void 0===o?void 0:o.outstandingBalance.toString(),t=null==v?void 0:v.currency.code,n=Object.assign({},S);let r;return this.isEnvironmentSpecific(_)?(n.publicKeyId=_,r=m):(n.sandbox=!!l,r=Object.assign(Object.assign({},m),{publicKeyId:_})),i||(n.createCheckoutSessionConfig=r),e&&t&&(n.estimatedOrderAmount={amount:e,currencyCode:t}),n}const b={method:g,url:`${I}/remote-checkout/${t}/payment-session`,extractAmazonCheckoutSessionId:y};return Object.assign(Object.assign({},S),{createCheckoutSession:b,sandbox:!!l})}isEnvironmentSpecific(e){return/^(SANDBOX|LIVE)/.test(e)}getAmazonPayV2SDK(){return this.getOrThrow(this.amazonPayV2SDK)}getButtonParentContainer(){return this.getOrThrow(this.buttonParentContainer)}getAmazonPayV2Button(){return this.getOrThrow(this.amazonPayV2Button)}getOrThrow(e){return ur(e,()=>new lr(sr.PaymentNotInitialized))}getCheckoutState(e){return"object"==typeof(t=e)&&null!==t&&"cart"in t&&"checkout"in t&&"config"in t&&"paymentMethods"in t?{getCart:e.cart.getCart,getCheckout:e.checkout.getCheckout,getStoreConfigOrThrow:e.config.getStoreConfigOrThrow,getPaymentMethodOrThrow:t=>e.paymentMethods.getPaymentMethodOrThrow(t)}:e;var t}}class vr extends ve{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class Cr{constructor(e,t=window){this.scriptLoader=e,this.windowWithAmazonPay=t}load(e){return t=this,n=void 0,r=function*(){const{initializationData:t}=e,n=(null==t?void 0:t.region)||"us",i=hr[n];if(yield this.scriptLoader.loadScript(`https://static-${i}.payments-amazon.com/checkout.js`),!this.windowWithAmazonPay.amazon)throw new vr;return this.windowWithAmazonPay.amazon},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}}function Ir(e,t){return Object.assign(e,{resolveIds:t})}class wr extends ve{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class br extends ve{constructor(e){super(e||"An unexpected error has occurred during buy now cart creation process. Please try again later."),this.name="BuyNowCartCreationError",this.type="buy_now_cart_creation_error"}}class Er extends ve{constructor(e){super(e||"An unexpected error has occurred during config creation process. Please try again later."),this.name="AmazonPayV2ConfigCreationError",this.type="amazon_pay_v2_config_creation_error"}}function Pr(e){return e instanceof Object&&"buyNowInitializeOptions"in e}var Or=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ar{constructor(e,t,n){this.paymentIntegrationService=e,this.amazonPayV2PaymentProcessor=t,this.amazonPayV2ConfigRequestSender=n}initialize(e){return Or(this,void 0,void 0,function*(){var t;const{methodId:n,containerId:i,amazonpay:r}=e,{buttonColor:o}=r||{};if(!n||!i)throw new wr('Unable to proceed because "methodId" or "containerId" argument is not provided.');const{getPaymentMethodOrThrow:a}=this.paymentIntegrationService.getState(),s=a(n);yield this.amazonPayV2PaymentProcessor.initialize(s),r||(yield this.paymentIntegrationService.loadDefaultCheckout());const d=Pr(r)?void 0:r;Pr(r)&&"function"==typeof(null===(t=r.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody)&&(this._buyNowInitializeOptions=r.buyNowInitializeOptions,this.amazonPayV2PaymentProcessor.updateBuyNowFlowFlag(!0)),this.amazonPayV2PaymentProcessor.renderAmazonPayButton({checkoutState:this.paymentIntegrationService.getState(),containerId:i,methodId:n,options:d,placement:gr.Cart,buttonColor:o}),this._buyNowInitializeOptions&&this.amazonPayV2PaymentProcessor.prepareCheckoutWithCreationRequestConfig(this._getCheckoutCreationRequestConfig.bind(this))})}deinitialize(){return this.amazonPayV2PaymentProcessor.deinitialize()}_createBuyNowCartOrThrow(){return Or(this,void 0,void 0,function*(){var e,t;const n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e);if(!n)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(n)}catch(e){throw new br}})}_createCheckoutConfig(e){return Or(this,void 0,void 0,function*(){try{const t=(yield this.amazonPayV2ConfigRequestSender.createCheckoutConfig(e)).body,{payload:n,public_key:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["payload","public_key"]);return Object.assign({payloadJSON:n,publicKeyId:i},r)}catch(e){throw new Er}})}_getCheckoutCreationRequestConfig(){return Or(this,void 0,void 0,function*(){const e=yield this._createBuyNowCartOrThrow(),t={amount:String(e.baseAmount),currencyCode:e.currency.code};return{createCheckoutSessionConfig:yield this._createCheckoutConfig(e.id),estimatedOrderAmount:t,productType:0===cr(e)?yr.PayOnly:yr.PayAndShip}})}}const Tr="This API endpoint is for internal use only and may change in the future";var kr;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(kr||(kr={}));const Rr=kr,Dr={"X-Checkout-SDK-Version":"1.934.2"};class Mr{constructor(e){this._requestSender=e}createCheckoutConfig(e){const t={cartId:e},n=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return this._requestSender.post("/api/storefront/payment/amazonpay",{headers:n,body:t})}}const Nr=Ir(t=>{const n=e(),i=new Mr(n),r=new Sr(new Cr(le()));return new Ar(t,r,i)},[{id:"amazonpay"}]);function Lr(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}const zr="3.128.0",Ur="3.123.2",Fr="3.106.0";class Br{constructor(e){this.paymentIntegrationService=e,this.braintreeWindow=window}getSDKVersion(){const e=this.paymentIntegrationService.getState().getStoreConfig(),t=(null==e?void 0:e.checkoutSettings.features)||{};return this.getPreloadedSDKVersion()||(Lr(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?zr:Lr(t,"PAYPAL-5636.update_braintree_sdk_version")?Ur:Fr)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=l(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class xr extends ve{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var qr,jr,Gr,Vr,Hr,Wr,Yr;function Kr(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(qr||(qr={})),function(e){e.Completed="COMPLETED",e.Pending="PENDING",e.Failed="FAILED"}(jr||(jr={})),function(e){e.TRUSTLY="trustly"}(Gr||(Gr={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(Vr||(Vr={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(Hr||(Hr={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(Wr||(Wr={})),function(e){e.Visa="visa",e.Mastercard="mastercard",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.Jcb="jcb",e.UnionPay="union-pay",e.Maestro="maestro",e.Elo="elo",e.Mir="mir",e.Hiper="hiper",e.Hipercard="hipercard"}(Yr||(Yr={}));var $r,Zr,Jr,Qr=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Xr{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return Qr(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return Qr(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=yield t.create({authorization:e})}return this.client})}getDataCollectorOrThrow(e){return Qr(this,void 0,void 0,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),i=Object.assign({client:t,kount:!0},e);this.dataCollector=yield n.create(i)}catch(e){if(Kr(e)&&e.code===Wr.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return Qr(this,void 0,void 0,function*(){if(!this.googlePayment){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]);this.googlePayment=yield t.create({client:e})}return this.googlePayment})}getBraintreeThreeDS(){return Qr(this,void 0,void 0,function*(){if(!this.threeDS){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]);this.threeDS=yield t.create({client:e,version:2})}return this.threeDS})}getBraintreeLocalPayment(e){return Qr(this,void 0,void 0,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((i,r)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&r(e),i(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return Qr(this,void 0,void 0,function*(){if(!this.usBankAccount){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadUsBankAccount();this.usBankAccount=yield t.create({client:e})}return this.usBankAccount})}getBraintreeVisaCheckout(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then(([e,t])=>t.create({client:e}))),this.visaCheckout}getVisaCheckoutSdk(e){return Qr(this,void 0,void 0,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return Qr(this,void 0,void 0,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},i=yield t.create(n);if(!i.isBrowserSupported())throw new xr;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new lr(sr.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}!function(e){e.Sandbox="sandbox",e.Production="production"}($r||($r={})),function(e){e.Client="client",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"}(Zr||(Zr={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(Jr||(Jr={}));const eo={[Fr]:{[Zr.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[Zr.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[Zr.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[Zr.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[Zr.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[Zr.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[Zr.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[Zr.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[Zr.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[Zr.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[Zr.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[Zr.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Ur]:{[Zr.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[Zr.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[Zr.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[Zr.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[Zr.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[Zr.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[Zr.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[Zr.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[Zr.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[Zr.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[Zr.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[Zr.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[zr]:{[Zr.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[Zr.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[Zr.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[Zr.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[Zr.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[Zr.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[Zr.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[Zr.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[Zr.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[Zr.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[Zr.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[Zr.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var to,no=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class io{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.Client,"client.min.js")})}loadFastlane(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.Paypal,"paypal.min.js")})}loadLocalPayment(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.GooglePayment,"google-payment.min.js")})}load3DS(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(Zr.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(Zr.Venmo,"venmo.min.js")}loadHostedFields(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return no(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new vr;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return no(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),r=`//js.braintreegateway.com/web/${i}/js/${t}`,o=i in eo?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(r,o?{async:!0,attributes:{integrity:o,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new vr;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=eo[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class ro extends ve{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}!function(e){e.BRAINTREE="braintree",e.BRAINTREE_FASTLANE="braintreeacceleratedcheckout"}(to||(to={}));var oo,ao,so=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};!function(e){e.Subtotal="Subtotal",e.Shipping="Shipping"}(oo||(oo={})),function(e){e.Black="black",e.White="white",e.WhiteBorder="white-border"}(ao||(ao={}));class co{constructor(e,t,n,i,r){this._requestSender=e,this._paymentIntegrationService=t,this._sessionFactory=n,this._braintreeSdk=i,this._applePayScriptLoader=r,this._onAuthorizeCallback=T,this._subTotalLabel=oo.Subtotal,this._shippingLabel=oo.Shipping}initialize(e){return so(this,void 0,void 0,function*(){var t,n;const{methodId:i,containerId:r,applepay:o}=e;if(!i||!o)throw new dr(ar.MissingPaymentMethod);yield this._applePayScriptLoader.loadSdk();const{onPaymentAuthorize:a,buyNowInitializeOptions:s,requiresShipping:d}=o;this._requiresShipping=d,this._buyNowInitializeOptions=s,this._onAuthorizeCallback=a,s||(yield this._paymentIntegrationService.loadDefaultCheckout());const c=this._paymentIntegrationService.getState();return this._paymentMethod=c.getPaymentMethodOrThrow(i),c.getCart()&&(yield this._paymentIntegrationService.verifyCheckoutSpamProtection()),(null===(t=this._paymentMethod.initializationData)||void 0===t?void 0:t.gateway)===to.BRAINTREE&&this._paymentMethod.clientToken&&this._braintreeSdk.initialize(this._paymentMethod.clientToken),this._applePayButton=this._createButton(r,null===(n=this._paymentMethod.initializationData)||void 0===n?void 0:n.styleOption),this._applePayButton.addEventListener("click",this._handleWalletButtonClick.bind(this)),Promise.resolve()})}deinitialize(){return Promise.resolve()}_createButton(e,t){const n=document.getElementById(e);if(!n)throw new wr("Unable to create wallet button without valid container ID.");const i=this._createApplePayButtonElement(t);return n.appendChild(i),i}_createApplePayButtonElement(e){const t=document.createElement("apple-pay-button");return t.setAttribute("buttonstyle",(e=>{switch(e){case ao.White:return"white";case ao.WhiteBorder:return"white-outline";case ao.Black:default:return"black"}})(e)),t.setAttribute("type","plain"),t.setAttribute("style","--apple-pay-button-width: 100%; --apple-pay-button-height: 40px; --apple-pay-button-border-radius: 4px;"),t}_handleWalletButtonClick(e){return so(this,void 0,void 0,function*(){var t;if(e.preventDefault(),!this._paymentMethod||!this._paymentMethod.initializationData)throw new dr(ar.MissingPaymentMethod);if(this._buyNowInitializeOptions&&"function"==typeof this._buyNowInitializeOptions.getBuyNowCartRequestBody){const{countryCode:e,currencyCode:n,merchantCapabilities:i,supportedNetworks:r,storeName:o}=this._paymentMethod.initializationData,a=this._getRequestWithEmptyTotal(e,n,r,i);this._requiresShipping&&(null===(t=a.requiredShippingContactFields)||void 0===t||t.push("postalAddress"));const s=this._sessionFactory.create(a);this._handleApplePayEvents(s,this._paymentMethod,o),s.begin()}else{const e=this._paymentIntegrationService.getState(),t=e.getCartOrThrow(),n=e.getStoreConfigOrThrow(),i=e.getCheckoutOrThrow(),r=this._getBaseRequest(t,i,n,this._paymentMethod),o=this._sessionFactory.create(r);this._handleApplePayEvents(o,this._paymentMethod,n.storeProfile.storeName),o.begin()}})}_getRequestWithEmptyTotal(e,t,n,i){return{countryCode:e,currencyCode:t,supportedNetworks:n,merchantCapabilities:i,total:{label:"",amount:"0",type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"]}}_getBaseRequest(e,t,n,i){var r;const{storeProfile:{storeCountryCode:o,storeName:a}}=n,{currency:{code:s,decimalPlaces:d}}=e,{initializationData:{merchantCapabilities:c,supportedNetworks:u}}=i,l=e.lineItems.physicalItems.length>0,h={requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"],countryCode:o,currencyCode:s,merchantCapabilities:c,supportedNetworks:u,lineItems:[],total:l?{label:a,amount:`${t.grandTotal.toFixed(d)}`,type:"pending"}:{label:a,amount:`${t.grandTotal.toFixed(d)}`,type:"final"}};if(l)null===(r=h.requiredShippingContactFields)||void 0===r||r.push("postalAddress");else{const e=[{label:this._subTotalLabel,amount:`${t.subtotal.toFixed(d)}`}];t.taxes.forEach(t=>e.push({label:t.name,amount:`${t.amount.toFixed(d)}`})),h.lineItems=e}return h}_handleApplePayEvents(e,t,n){e.onvalidatemerchant=n=>so(this,void 0,void 0,function*(){try{const{body:i}=yield this._onValidateMerchant(t,n);e.completeMerchantValidation(i)}catch(e){throw new Error("Merchant validation failed")}}),this._buyNowInitializeOptions&&!this._requiresShipping&&(e.onpaymentmethodselected=()=>so(this,void 0,void 0,function*(){yield this._createBuyNowCart(),this._handlePaymentMethodSelected(e)})),e.onshippingcontactselected=t=>so(this,void 0,void 0,function*(){this._buyNowInitializeOptions&&this._requiresShipping&&(yield this._createBuyNowCart()),yield this._handleShippingContactSelected(e,n,t)}),e.onshippingmethodselected=t=>so(this,void 0,void 0,function*(){yield this._handleShippingMethodSelected(e,n,t)}),e.oncancel=()=>so(this,void 0,void 0,function*(){try{const e=`/remote-checkout/${t.id}/signout`;return yield this._requestSender.get(e),yield this._paymentIntegrationService.loadCheckout()}catch(e){throw new ro}}),e.onpaymentauthorized=n=>so(this,void 0,void 0,function*(){return this._onPaymentAuthorized(n,e,t)})}_createBuyNowCart(){return so(this,void 0,void 0,function*(){var e,t;try{const n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e);if(!n)throw new dr(ar.MissingCart);const i=yield this._paymentIntegrationService.createBuyNowCart(n);yield this._paymentIntegrationService.loadCheckout(i.id);const r=this._paymentIntegrationService.getState(),{shouldExecuteSpamCheck:o}=r.getCheckoutOrThrow();o&&(yield this._paymentIntegrationService.verifyCheckoutSpamProtection())}catch(e){throw new br}})}_handlePaymentMethodSelected(e){const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow(),i=t.getStoreConfigOrThrow(),r=t.getCheckoutOrThrow();if(!this._paymentMethod||!this._paymentMethod.initializationData)throw new dr(ar.MissingPaymentMethod);const o=this._getBaseRequest(n,r,i,this._paymentMethod);delete o.total.type,e.completePaymentMethodSelection({newTotal:o.total,newLineItems:o.lineItems})}_handleShippingContactSelected(e,t,n){return so(this,void 0,void 0,function*(){var i;const r=this._transformContactToAddress(n.shippingContact);try{yield this._paymentIntegrationService.updateShippingAddress(r)}catch(t){throw e.abort(),new Error("Shipping address update failed")}let o=this._paymentIntegrationService.getState();const{currency:{decimalPlaces:a}}=o.getCartOrThrow();let s=o.getCheckoutOrThrow();const d=null===(i=s.consignments[0].selectedShippingOption)||void 0===i?void 0:i.id,c=s.consignments[0].availableShippingOptions,u=null==c?void 0:c.find(({id:e})=>e===d),l=null==c?void 0:c.filter(e=>e.id!==d),h=u?[{label:u.description,amount:`${u.cost.toFixed(a)}`,detail:u.additionalDescription,identifier:u.id}]:[];if(l&&[...l.filter(e=>e.isRecommended),...l.filter(e=>!e.isRecommended)].forEach(e=>h.push({label:e.description,amount:`${e.cost.toFixed(a)}`,detail:e.additionalDescription,identifier:e.id})),!(c instanceof Array))throw new Error("Shipping options not available.");if(0===c.length)return void e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,[],{type:"pending",label:t,amount:`${s.grandTotal.toFixed(a)}`},[]);const p=c.find(e=>e.isRecommended),g=p?p.id:c[0].id,m=u?u.id:g;try{yield this._updateShippingOption(m)}catch(e){throw new Error("Shipping options update failed")}o=this._paymentIntegrationService.getState(),s=o.getCheckoutOrThrow(),e.completeShippingContactSelection({newShippingMethods:h,newTotal:{type:"final",label:t,amount:`${s.grandTotal.toFixed(a)}`},newLineItems:this._getUpdatedLineItems(s,a)})})}_handleShippingMethodSelected(e,t,n){return so(this,void 0,void 0,function*(){const{shippingMethod:{identifier:i}}=n;try{yield this._updateShippingOption(i)}catch(t){throw e.abort(),new Error("Shipping option selection update failed.")}const r=this._paymentIntegrationService.getState(),{currency:{decimalPlaces:o}}=r.getCartOrThrow(),a=r.getCheckoutOrThrow();e.completeShippingMethodSelection({newTotal:{type:"final",label:t,amount:`${a.grandTotal.toFixed(o)}`},newLineItems:this._getUpdatedLineItems(a,o)})})}_getUpdatedLineItems(e,t){const n=[{label:this._subTotalLabel,amount:`${e.subtotal.toFixed(t)}`}];return e.taxes.forEach(e=>n.push({label:e.name,amount:`${e.amount.toFixed(t)}`})),n.push({label:this._shippingLabel,amount:`${e.shippingCostTotal.toFixed(t)}`}),n}_updateShippingOption(e){return so(this,void 0,void 0,function*(){return this._paymentIntegrationService.selectShippingOption(e)})}_onValidateMerchant(e,t){return so(this,void 0,void 0,function*(){const n=[`validationUrl=${t.validationURL}`,`merchantIdentifier=${e.initializationData.merchantId}`,`displayName=${e.initializationData.storeName}`,`domainName=${window.location.hostname}`].join("&");return this._requestSender.post(`${e.initializationData.paymentsUrl}/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})})}_onPaymentAuthorized(e,t,n){return so(this,void 0,void 0,function*(){var i;const{token:r,billingContact:o,shippingContact:a}=e.payment,s=this._paymentIntegrationService.getState().getCartOrThrow().lineItems.physicalItems.length>0;let d;(null===(i=n.initializationData)||void 0===i?void 0:i.gateway)===to.BRAINTREE&&(d=yield this._getBraintreeDeviceData());const c={methodId:n.id,paymentData:{deviceSessionId:d,formattedPayload:{apple_pay_token:{payment_data:r.paymentData,payment_method:r.paymentMethod,transaction_id:r.transactionIdentifier}}}},u=this._transformContactToAddress(o),l=this._transformContactToAddress(a),h=null==a?void 0:a.emailAddress,p=(null==a?void 0:a.phoneNumber)||"";try{return yield this._paymentIntegrationService.updateBillingAddress(Object.assign(Object.assign({},u),{email:h,phone:p})),s&&(yield this._paymentIntegrationService.updateShippingAddress(l)),yield this._paymentIntegrationService.submitOrder({useStoreCredit:!1}),yield this._paymentIntegrationService.submitPayment(c),t.completePayment(ApplePaySession.STATUS_SUCCESS),this._onAuthorizeCallback()}catch(e){throw t.completePayment(ApplePaySession.STATUS_FAILURE),new Error("Payment cannot complete")}})}_transformContactToAddress(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:[]}}_getBraintreeDeviceData(){return so(this,void 0,void 0,function*(){try{const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e}catch(e){}})}}function uo(e){if(!function(e){return"ApplePaySession"in e}(e))throw new Error("Apple pay is not supported")}class lo{create(e){return uo(window),new ApplePaySession(1,e)}}class ho{constructor(e){this.scriptLoader=e,this.sdkVersion="1.latest"}loadSdk(){return e=this,t=void 0,i=function*(){(function(e){return"ApplePaySDK"in e})(window)||(yield this.scriptLoader.loadScript(`https://applepay.cdn-apple.com/jsapi/${this.sdkVersion}/apple-pay-sdk.js`),uo(window))},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}const po=Ir(t=>{const{getHost:n}=t.getState(),i=new Br(t);return new co(e({host:n()}),t,new lo,new Xr(new io(le(),window,i)),new ho(new ce))},[{id:"applepay"}]);var go,mo,yo,fo,_o,So,vo,Co;!function(e){e.BuyNow="BUY_NOW",e.INVOICE="B2B_INVOICE"}(go||(go={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(mo||(mo={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(yo||(yo={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(fo||(fo={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(_o||(_o={})),function(e){e.pill="pill",e.rect="rect"}(So||(So={})),function(e){e.OXXO="oxxo"}(vo||(vo={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Co||(Co={}));var Io=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class wo{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.bigCommercePaymentsRequestSender=n,this.bigCommercePaymentsScriptLoader=i}loadPayPalSdk(e,t,n,i){return Io(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e);return this.paypalSdk=yield this.bigCommercePaymentsScriptLoader.getPayPalSDK(a,o,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new vr;return this.paypalSdk}createBuyNowCartOrThrow(e){return Io(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new br}})}createOrder(e,t){return Io(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.bigCommercePaymentsRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return Io(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.bigCommercePaymentsRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e){return Io(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState(),n=t.getCartOrThrow();let i;e||(i=t.getConsignmentsOrThrow()[0]);try{yield this.bigCommercePaymentsRequestSender.updateOrder({availableShippingOptions:e?[]:null==i?void 0:i.availableShippingOptions,cartId:n.id,selectedShippingOption:e?null:null==i?void 0:i.selectedShippingOption})}catch(e){throw new Ie}})}getOrderStatus(e,t){return Io(this,void 0,void 0,function*(){try{const{status:n}=yield this.bigCommercePaymentsRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new dr(ar.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===go.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return Io(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:r}=e||{},o={color:t&&_o[t]?t:void 0,height:this.getValidHeight(n),label:i&&fo[i]?i:void 0,shape:r&&So[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var bo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Eo{constructor(e){this.requestSender=e}createOrder(e,t){return bo(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e){return bo(this,void 0,void 0,function*(){const t=e,n=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.put("/api/storefront/initialization/bigcommerce_payments",{headers:n,body:t})).body})}getOrderStatus(){return bo(this,arguments,void 0,function*(e="bigcommerce_payments",t){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}var Po=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Oo{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i){return Po(this,void 0,void 0,function*(){const r=this.getPayPalSdkScriptConfigOrThrow(e,t,n);return this.loadPayPalSDK(r,i)})}loadPayPalSDK(e){return Po(this,arguments,void 0,function*(e,t=!1){if(!this.window.bigCommercePaymentsPayPalSDK||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.bigCommercePaymentsPayPalSDK)throw new vr;return this.window.bigCommercePaymentsPayPalSDK})}getPayPalSdkScriptConfigOrThrow(e,t,n=!0){const{id:i,clientToken:r,initializationData:o}=e;if(!(null==o?void 0:o.clientId))throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isVenmoEnabled:l,isHostedCheckoutEnabled:h,isPayPalCreditAvailable:p,isDeveloperModeApplicable:g,availableAlternativePaymentMethods:m=[],enabledAlternativePaymentMethods:y=[],isGooglePayEnabled:f}=o,_=h||n,S="bigcommerce_payments_creditcards"===i,v=S?["card"]:[],C=S?[]:["card"],I=p?["credit","paylater"]:[],w=p?[]:["credit","paylater"],b=l?["venmo"]:[],E=l?[]:["venmo"],P=m.filter(e=>!y.includes(e)),O=f?["googlepay"]:[],A=n?["card-fields"]:[],T=this.filterFundingOptions([...C,...w,...E,...P]),k=this.filterFundingOptions([...v,...I,...b,...y]);return{options:Object.assign({"client-id":s,"merchant-id":d,"enable-funding":k.length>0?k:void 0,"disable-funding":T.length>0?T:void 0,commit:_,components:["buttons","hosted-fields","payment-fields","legal",...O,...A],currency:t,intent:a},g&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"bigCommercePaymentsPayPalSDK"}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}const Ao=t=>{const{getHost:i}=t.getState();return new wo(n(),t,new Eo(e({host:i()})),new Oo(le()))};var To=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ko{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return To(this,void 0,void 0,function*(){var t;const{bigcommerce_payments:n,containerId:i,methodId:r}=e,o=Boolean(null==n?void 0:n.buyNowInitializeOptions);if(!r)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.bigcommerce_payments" argument is not provided.');if(o&&!n.currencyCode)throw new wr('Unable to initialize payment because "options.bigcommerce_payments.currencyCode" argument is not provided.');if(o&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.bigcommerce_payments.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');o||(yield this.paymentIntegrationService.loadDefaultCheckout());const a=o?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(r,a,!1),this.renderButton(i,r,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},h={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},p=Object.assign(Object.assign({},!u&&{onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e)}),{onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o,u)}),g=Object.assign(Object.assign(Object.assign({fundingSource:s.FUNDING.PAYPAL,style:this.bigCommercePaymentsIntegrationService.getValidButtonStyle(r)},l),i&&h),c&&p),m=s.Buttons(g);m.isEligible()?m.render(`#${e}`):a&&"function"==typeof a?a():this.bigCommercePaymentsIntegrationService.removeElement(e)}handleClick(e){return To(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i,r){return To(this,void 0,void 0,function*(){if(!e.orderID)throw new dr(ar.MissingOrderId);const o=this.paymentIntegrationService.getState().getCartOrThrow();try{const a=o.lineItems.physicalItems.length>0;if(!r){const e=yield t.order.get(),n=this.bigCommercePaymentsIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),a){const t=this.bigCommercePaymentsIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}return a&&(yield this.bigCommercePaymentsIntegrationService.updateOrder(r)),r&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.bigCommercePaymentsIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return To(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return To(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const Ro=Ir(e=>new ko(e,Ao(e)),[{id:"bigcommerce_payments"}]);var Do=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Mo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return Do(this,void 0,void 0,function*(){const{bigcommerce_payments_paylater:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.bigcommerce_payments_paylater" argument is not provided.');if(a&&!o)throw new wr('Unable to initialize payment because "options.bigcommerce_payments_paylater.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.bigcommerce_payments_paylater.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=this.paymentIntegrationService.getState(),d=a?o:s.getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(i,d,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c}=d.initializationData||{},u={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments_paylater"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},l={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},h={onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e),onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o)},p=[s.FUNDING.PAYLATER,s.FUNDING.CREDIT];let g=!1;p.forEach(t=>{if(!g){const n=Object.assign(Object.assign(Object.assign({fundingSource:t,style:this.bigCommercePaymentsIntegrationService.getValidButtonStyle(r)},u),i&&l),c&&h),o=s.Buttons(n);o.isEligible()?(o.render(`#${e}`),g=!0):a&&"function"==typeof a&&a()}}),g||this.bigCommercePaymentsIntegrationService.removeElement(e)}handleClick(e){return Do(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i){return Do(this,void 0,void 0,function*(){if(!e.orderID)throw new dr(ar.MissingOrderId);const r=this.paymentIntegrationService.getState().getCartOrThrow(),o=yield t.order.get();try{const t=this.bigCommercePaymentsIntegrationService.getBillingAddressFromOrderDetails(o);if(yield this.paymentIntegrationService.updateBillingAddress(t),r.lineItems.physicalItems.length>0){const e=this.bigCommercePaymentsIntegrationService.getShippingAddressFromOrderDetails(o);yield this.paymentIntegrationService.updateShippingAddress(e),yield this.bigCommercePaymentsIntegrationService.updateOrder()}return yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.bigCommercePaymentsIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return Do(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return Do(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const No=Ir(e=>new Mo(e,Ao(e)),[{id:"bigcommerce_payments_paylater"}]);var Lo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class zo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return Lo(this,void 0,void 0,function*(){const{bigcommerce_payments_venmo:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.bigcommerce_payments_venmo" argument is not provided.');if(a&&!o)throw new wr('Unable to initialize payment because "options.bigcommerce_payments_venmo.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.bigcommerce_payments_venmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=a?o:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(i,s,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onEligibilityFailure:o}=n,a=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),s=a.FUNDING.VENMO,d={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments_venmo"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},c={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},u=Object.assign(Object.assign({fundingSource:s,style:this.getValidVenmoButtonStyles(r)},d),i&&c),l=a.Buttons(u);l.isEligible()?l.render(`#${e}`):o&&"function"==typeof o?o():this.bigCommercePaymentsIntegrationService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.bigCommercePaymentsIntegrationService.getValidButtonStyle(e);return t.color===_o.gold?Object.assign(Object.assign({},t),{color:void 0}):t}handleClick(e){return Lo(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}}const Uo=Ir(e=>new zo(e,Ao(e)),[{id:"bigcommerce_payments_venmo"}]);class Fo extends ve{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var Bo,xo,qo;!function(e){e.SandboxMode="bolt_sandbox",e.StagingMode="bolt_staging",e.DevelopmentMode="bolt_development"}(Bo||(Bo={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(xo||(xo={})),function(e){e.Pill="pill",e.Rect="rect"}(qo||(qo={}));class jo{constructor(e,t,n=window){this.paymentIntegrationService=e,this.boltScriptLoader=t,this.boltHostWindow=n}initialize(e){return t=this,n=void 0,r=function*(){const{bolt:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,style:o}=t||{};if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.bolt" argument is not provided.');if(!Boolean(r))throw new Fo("Only buy now flow is implemented for Bolt button");if(!(null==r?void 0:r.storefrontApiToken)||"string"!=typeof r.storefrontApiToken)throw new wr('Unable to initialize payment because "options.storefrontApiToken" argument is not provided.');const a=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(i),{initializationData:s,config:d}=a,{publishableKey:c,developerConfig:u}=s||{};yield this.boltScriptLoader.loadBoltClient(c,d.testMode,u,"BigCommerce",r.storefrontApiToken),this.renderButton(n,a,o)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}deinitialize(){return Promise.resolve()}renderButton(e,t,n){var i;"function"==typeof(null===(i=this.boltHostWindow.BoltConnect)||void 0===i?void 0:i.setupProductPageCheckout)&&(this.addButtonContainer(e,t,n),this.boltHostWindow.BoltConnect.setupProductPageCheckout())}addButtonContainer(e,t,n){const i=document.getElementById(e);if(!i)return;const r=document.createElement("div"),o=document.createElement("object");r.setAttribute("id","product-page-checkout-wrapper"),r.setAttribute("class","bolt-button-wrapper"),r.setAttribute("style","display:none"),r.setAttribute("data-tid","product-page-checkout-wrapper"),o.setAttribute("data",this.getBoltObjectData(t,n)),o.setAttribute("class","bolt-product-checkout-button"),r.append(o),i.innerHTML="",i.append(r)}getBoltObjectData(e,t){const{initializationData:n,config:i}=e,{publishableKey:r,developerConfig:o}=n||{},a=this.boltScriptLoader.getDomainURL(!!i.testMode,o),s=this.getButtonHeight(null==t?void 0:t.size),d=this.getButtonBorderRadius(null==t?void 0:t.shape,s);return he({url:`https://${a}/v1/checkout_button`,query:{publishable_key:r,variant:"ppc",height:s,border_radius:d}})}getButtonHeight(e){if(e)switch(e){case xo.Small:return 25;case xo.Large:return 45;case xo.Medium:default:return 40}}getButtonBorderRadius(e,t){if(e)switch(e){case qo.Pill:return t?Math.round(t/2):void 0;case qo.Rect:default:return 4}}}var Go=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Vo{constructor(e,t=window){this.scriptLoader=e,this.boltHostWindow=t}loadBoltClient(e,t,n,i,r){return Go(this,void 0,void 0,function*(){if(this.boltHostWindow.BoltCheckout)return this.boltHostWindow.BoltCheckout;if(!e)throw new wr('Unable to initialize payment because "publishableKey" argument is not provided.');if(yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/connect-bigcommerce.js`,this.getScriptOptions("bolt-connect",e,i,r)),yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/track.js`,this.getScriptOptions("bolt-track",e)),!this.boltHostWindow.BoltCheckout)throw new vr;return this.boltHostWindow.BoltCheckout})}loadBoltEmbedded(e,t,n){return Go(this,void 0,void 0,function*(){if(yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/embed.js`,{async:!0,attributes:{id:"bolt-embedded"}}),!this.boltHostWindow.Bolt)throw new vr;return this.boltHostWindow.Bolt(e)})}getDomainURL(e,t){if(!e)return"connect.bolt.com";if(t)switch(t.developerMode){case Bo.StagingMode:return"connect-staging.bolt.com";case Bo.DevelopmentMode:return`connect.${t.developerDomain}`}return"connect-sandbox.bolt.com"}getScriptOptions(e,t,n,i){return{async:!0,attributes:Object.assign(Object.assign({id:e,"data-publishable-key":t},n&&{"data-shopping-cart-id":n}),i&&{"data-storefront-api-token":i})}}}const Ho=Ir(e=>new jo(e,new Vo(le())),[{id:"bolt"}]);class Wo extends wr{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class Yo extends ve{constructor(e,t){super(t||"Unable to proceed because the payment form contains invalid data."),this.details=e,this.name="PaymentInvalidFormError",this.type="payment_invalid_form"}}let Ko=null;const $o=["buttons","messages"];var Zo,Jo,Qo,Xo,ea,ta;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Zo||(Zo={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Jo||(Jo={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(Qo||(Qo={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Xo||(Xo={})),function(e){e.PILL="pill",e.RECT="rect"}(ea||(ea={})),function(e){e.CART="cart",e.HOME="homepage",e.PAYMENT="payment",e.PRODUCT="product"}(ta||(ta={}));var na=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ia{constructor(e,t,n){this.braintreeScriptLoader=e,this.braintreeHostWindow=t,this.overlay=n,this.dataCollectors={}}initialize(e,t){this.clientToken=e,this.threeDSecureOptions=t}getBraintreeFastlane(e,t,n){return na(this,void 0,void 0,function*(){if(t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),!this.braintreeHostWindow.braintreeFastlane){const t=this.getClientTokenOrThrow(),i=yield this.getClient(),r=yield this.getSessionId(e),o=yield this.braintreeScriptLoader.loadFastlane(),a={root:{backgroundColorPrimary:"transparent"}};this.braintreeHostWindow.braintreeFastlane=yield o.create({authorization:t,client:i,deviceData:r,styles:n||a})}return this.braintreeHostWindow.braintreeFastlane})}getClient(){return na(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=t.create({authorization:e})}return this.client})}getPaypal(){return this.braintreePaypal||(this.braintreePaypal=Promise.all([this.getClient(),this.braintreeScriptLoader.loadPaypal()]).then(([e,t])=>t.create({client:e}))),this.braintreePaypal}paypal(e){var{shouldSaveInstrument:t}=e,n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["shouldSaveInstrument"]);const i=pe();return this.getPaypal().then(e=>{var r;return i&&(null===(r=this.overlay)||void 0===r||r.show({onClick:()=>e.focusWindow()})),e.tokenize(Object.assign({enableShippingAddress:!0,flow:t?"vault":"checkout",useraction:"commit"},n))}).then(e=>{var t;return null===(t=this.overlay)||void 0===t||t.remove(),e}).catch(e=>{var t;throw null===(t=this.overlay)||void 0===t||t.remove(),e})}getPaypalCheckout(e,t,n){return na(this,void 0,void 0,function*(){const i=yield this.getClient(),r=yield this.braintreeScriptLoader.loadPaypalCheckout(),o={client:i};return this.paypalCheckout=yield r.create(o,(i,r)=>{var o;if(i)return n(i);const a=Object.assign(Object.assign({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:$o.toString(),intent:e.intent,commit:null===(o=e.commit)||void 0===o||o});this.braintreeHostWindow.paypal?t(r):function(e,t){return Ko||(Ko=new Promise((n,i)=>{e.loadPayPalSDK(t,t=>{t?(Ko=null,i(t)):n(e)})})),Ko}(r,a).then(()=>t(r))}),this.paypalCheckout})}getDataCollector(e){return na(this,void 0,void 0,function*(){const t=(null==e?void 0:e.paypal)?"paypal":"default";let n=this.dataCollectors[t];if(!n){try{const t=yield this.getClient(),i=yield this.braintreeScriptLoader.loadDataCollector(),r=Object.assign({client:t,kount:!0},e);n=yield i.create(r)}catch(e){if(!Kr(e)||"DATA_COLLECTOR_KOUNT_NOT_ENABLED"!==e.code)throw e;n={deviceData:void 0,teardown:()=>Promise.resolve()}}this.dataCollectors[t]=n}return n})}getBraintreeEnv(e=!1){return e?$r.Sandbox:$r.Production}mapToBraintreeShippingAddressOverride(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}}mapToLegacyShippingAddress(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}mapToLegacyBillingAddress(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,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}}removeElement(e){const t=e&&document.getElementById(e);t&&t.remove()}getSessionId(e){return na(this,void 0,void 0,function*(){const{deviceData:t}=yield this.getDataCollector({riskCorrelationId:e});return t})}teardown(){return na(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollectors.default),yield this.teardownModule(this.dataCollectors.paypal),this.dataCollectors={},yield this.teardownModule(this.paypalCheckout),this.paypalCheckout=void 0})}get3DS(){return na(this,void 0,void 0,function*(){return this.threeDS||(this.threeDS=Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]).then(([e,t])=>t.create({client:e,version:2}))),this.threeDS})}getVenmoCheckout(e){return na(this,void 0,void 0,function*(){if(!this.venmoCheckout){const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadVenmoCheckout(),i=Object.assign({client:t,allowDesktop:!0,paymentMethodUsage:"multi_use"},e||{});this.venmoCheckout=yield new Promise((e,t)=>{n.create(i,(n,i)=>n?t(n):i.isBrowserSupported()?void e(i):t(new xr))})}return this.venmoCheckout})}verifyCard(e,t,n){return na(this,void 0,void 0,function*(){const i=yield this.tokenizeCard(e,t);return this.challenge3DSVerification(i,n)})}tokenizeCard(e,t){return na(this,void 0,void 0,function*(){const{paymentData:n}=e;if(!function(e){if("object"!=typeof e||null===e)return!1;const t=e;return"object"==typeof t.ccExpiry&&null!==t.ccExpiry&&"string"==typeof t.ccNumber&&"string"==typeof t.ccName}(n))throw new Wo(["payment.paymentData"]);const i=this.getErrorsRequiredFields(n);if(!f(i))throw new Yo(i);const r=this.mapToCreditCard(n,t),o=yield this.getClient(),{creditCards:a}=yield o.request(r);return{nonce:a[0].nonce,bin:a[0].details.bin}})}challenge3DSVerification(e,t){return na(this,void 0,void 0,function*(){const n=yield this.get3DS();return this.present3DSChallenge(n,t,e)})}teardownModule(e){return e?e.teardown():Promise.resolve()}getClientTokenOrThrow(){if(!this.clientToken)throw new lr(sr.PaymentNotInitialized);return this.clientToken}getErrorsRequiredFields(e){const{ccNumber:t,ccExpiry:n}=e,i={};return t||(i.ccNumber=[{message:"Credit card number is required",type:"required"}]),n||(i.ccExpiry=[{message:"Expiration date is required",type:"required"}]),i}mapToCreditCard(e,t){return{data:{creditCard:{cardholderName:e.ccName,number:e.ccNumber,cvv:e.ccCvv,expirationDate:`${e.ccExpiry.month}/${e.ccExpiry.year}`,options:{validate:!1},billingAddress:t&&{countryCodeAlpha2:t.countryCode,locality:t.city,countryName:t.country,postalCode:t.postalCode,streetAddress:t.address2?`${t.address1} ${t.address2}`:t.address1}}},endpoint:"payment_methods/credit_cards",method:"post"}}present3DSChallenge(e,t,n){const{nonce:i,bin:r}=n;if(!i)throw new lr(sr.PaymentNotInitialized);const{challengeRequested:o=!0,additionalInformation:a}=this.threeDSecureOptions||{},s=t.toFixed(2);return e.verifyCard({amount:Number(s),bin:r,challengeRequested:o,nonce:i,onLookupComplete:(e,t)=>{t()},collectDeviceData:!0,additionalInformation:a})}}function ra(e){const{color:t,fundingicons:n,height:i=40,layout:r,shape:o,size:a,tagline:s}=e||{},d={color:t,fundingicons:n,height:oa(i),layout:r,shape:o||"rect",size:a,tagline:s};return R(d,v)}function oa(e){const t=Number(e);return!t||Number.isNaN(t)?40:t>55?55:t<25?25:t}function aa(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}}var sa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class da{constructor(e,t,n,i){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeIntegrationService=n,this.braintreeHostWindow=i}initialize(e){return sa(this,void 0,void 0,function*(){const{braintreepaypal:t,containerId:n,methodId:i}=e;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');let r,o=this.paymentIntegrationService.getState();if(t.buyNowInitializeOptions){if(!t.currencyCode)throw new wr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');r=t.currencyCode}else yield this.paymentIntegrationService.loadDefaultCheckout(),o=this.paymentIntegrationService.getState(),r=o.getCartOrThrow().currency.code;const a=o.getPaymentMethodOrThrow(i),{clientToken:s,config:d,initializationData:c}=a;if(!s||!c)throw new dr(ar.MissingPaymentMethod);const u={currency:r,intent:c.intent,isCreditEnabled:c.isCreditEnabled,commit:!1};this.braintreeIntegrationService.initialize(s),yield this.braintreeIntegrationService.getPaypalCheckout(u,e=>{this.renderPayPalButton(e,t,n,i,!!d.testMode)},e=>this.handleError(e,n,t.onError))})}deinitialize(){return sa(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}renderPayPalButton(e,t,n,i,r){const{style:o,shouldProcessPayment:a,onAuthorizeError:s,onEligibilityFailure:d}=t,{paypal:c}=this.braintreeHostWindow;if(c){const u=c.Buttons({env:r?"sandbox":"production",fundingSource:c.FUNDING.PAYPAL,style:ra(o),createOrder:()=>this.setupPayment(e,t,i),onApprove:t=>this.tokenizePayment(t,e,i,a,s)});u.isEligible()?u.render(`#${n}`):d&&"function"==typeof d&&d()}else this.braintreeIntegrationService.removeElement(n)}setupPayment(e,t,n){return sa(this,void 0,void 0,function*(){var i;const{onPaymentError:r,shippingAddress:o,buyNowInitializeOptions:a}=t;try{const r="function"==typeof(null==a?void 0:a.getBuyNowCartRequestBody)?yield this.createBuyNowCart(a.getBuyNowCartRequestBody()):void 0;this.buyNowCartId=null==r?void 0:r.id;const s=this.paymentIntegrationService.getState(),d=s.getCustomer(),c=s.getPaymentMethodOrThrow(n),u=r?r.cartAmount:s.getCartOrThrow().cartAmount,l=r?t.currencyCode:s.getCartOrThrow().currency.code,h=o||(null==d?void 0:d.addresses[0]),p=h?aa(h):void 0;return yield e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:p,amount:u,currency:l,offerCredit:!1,intent:null===(i=c.initializationData)||void 0===i?void 0:i.intent})}catch(e){throw r&&(Kr(e)||e instanceof ve)&&r(e),e}})}tokenizePayment(e,t,n,i,r){return sa(this,void 0,void 0,function*(){try{const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),o=yield t.tokenizePayment(e),{details:a,nonce:s}=o,d=this.braintreeIntegrationService.mapToLegacyBillingAddress(a),c=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",provider:n,action:i?"process_payment":"set_external_checkout",nonce:s,device_data:r,billing_address:JSON.stringify(d),shipping_address:JSON.stringify(c)},this.buyNowCartId&&{cart_id:this.buyNowCartId})),o}catch(e){throw r&&(Kr(e)||e instanceof ve)&&r(e),e}})}createBuyNowCart(e){return sa(this,void 0,void 0,function*(){if(!e)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(e)}catch(e){throw new br}})}handleError(e,t,n){if(this.braintreeIntegrationService.removeElement(t),!n||!Kr(e))throw e;n(e)}}const ca=Ir(e=>{const t=window,i=new Br(e),r=new ia(new io(le(),t,i),t);return new da(e,n(),r,t)},[{id:"braintreepaypal"}]);var ua=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class la{constructor(e,t,n,i){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeIntegrationService=n,this.braintreeHostWindow=i}initialize(e){return ua(this,void 0,void 0,function*(){const{braintreepaypalcredit:t,containerId:n,methodId:i}=e;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');let r,o=this.paymentIntegrationService.getState();if(t.buyNowInitializeOptions){if(!t.currencyCode)throw new wr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');r=t.currencyCode}else yield this.paymentIntegrationService.loadDefaultCheckout(),o=this.paymentIntegrationService.getState(),r=o.getCartOrThrow().currency.code;const a=o.getPaymentMethodOrThrow(i),{clientToken:s,config:d,initializationData:c}=a;if(!s||!c)throw new dr(ar.MissingPaymentMethod);const u={currency:r,intent:c.intent,isCreditEnabled:c.isCreditEnabled,commit:!1};this.braintreeIntegrationService.initialize(s),yield this.braintreeIntegrationService.getPaypalCheckout(u,e=>{this.renderPayPalButton(e,t,n,i,!!d.testMode)},e=>this.handleError(e,n,t.onError))})}deinitialize(){return ua(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}renderPayPalButton(e,t,n,i,r){const{style:o,shouldProcessPayment:a,onAuthorizeError:s,onEligibilityFailure:d}=t,{paypal:c}=this.braintreeHostWindow;let u=!1;c&&[c.FUNDING.PAYLATER,c.FUNDING.CREDIT].forEach(l=>{const h=l===c.FUNDING.CREDIT?Object.assign({label:Xo.CREDIT},ra(o)):ra(o);if(!u){const o=c.Buttons({env:r?"sandbox":"production",fundingSource:l,style:h,createOrder:()=>this.setupPayment(e,t,i),onApprove:t=>this.tokenizePayment(t,e,i,a,s)});o.isEligible()?(o.render(`#${n}`),u=!0):c.FUNDING.CREDIT&&d&&"function"==typeof d&&d()}}),c&&u||this.braintreeIntegrationService.removeElement(n)}setupPayment(e,t,n){return ua(this,void 0,void 0,function*(){var i;const{onPaymentError:r,shippingAddress:o,buyNowInitializeOptions:a}=t;try{const r="function"==typeof(null==a?void 0:a.getBuyNowCartRequestBody)?yield this.createBuyNowCart(a.getBuyNowCartRequestBody()):void 0;this.buyNowCartId=null==r?void 0:r.id;const s=this.paymentIntegrationService.getState(),d=s.getCustomer(),c=s.getPaymentMethodOrThrow(n),u=r?r.cartAmount:s.getCartOrThrow().cartAmount,l=r?t.currencyCode:s.getCartOrThrow().currency.code,h=o||(null==d?void 0:d.addresses[0]),p=h?aa(h):void 0;return yield e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:p,amount:u,currency:l,offerCredit:!0,intent:null===(i=c.initializationData)||void 0===i?void 0:i.intent})}catch(e){throw r&&(Kr(e)||e instanceof ve)&&r(e),e}})}tokenizePayment(e,t,n,i,r){return ua(this,void 0,void 0,function*(){try{const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),o=yield t.tokenizePayment(e),{details:a,nonce:s}=o,d=this.braintreeIntegrationService.mapToLegacyBillingAddress(a),c=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",provider:n,action:i?"process_payment":"set_external_checkout",nonce:s,device_data:r,billing_address:JSON.stringify(d),shipping_address:JSON.stringify(c)},this.buyNowCartId&&{cart_id:this.buyNowCartId})),o}catch(e){throw r&&(Kr(e)||e instanceof ve)&&r(e),e}})}createBuyNowCart(e){return ua(this,void 0,void 0,function*(){if(!e)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(e)}catch(e){throw new br}})}handleError(e,t,n){if(this.braintreeIntegrationService.removeElement(t),!n||!Kr(e))throw e;n(e)}}const ha=Ir(e=>{const t=window,i=new Br(e),r=new ia(new io(le(),t,i),t);return new la(e,n(),r,t)},[{id:"braintreepaypalcredit"}]);var pa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ga{constructor(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n}initialize(e){return pa(this,void 0,void 0,function*(){const{containerId:t,methodId:n}=e;if(!n)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');yield this.paymentIntegrationService.loadPaymentMethod(n);const i=this.paymentIntegrationService.getState(),{clientToken:r,initializationData:o,config:a}=i.getPaymentMethodOrThrow(n);if(!r||!o)throw new dr(ar.MissingPaymentMethod);this.braintreeSdk.initialize(r);const s=yield this.braintreeSdk.getBraintreeVisaCheckout(),{currency:{code:d},cartAmount:c}=i.getCartOrThrow(),u=yield this.braintreeSdk.getVisaCheckoutSdk(a.testMode),l=s.createInitOptions({paymentRequest:{currencyCode:d,subtotal:String(c)},settings:{shipping:{collectShipping:!0}}});this.createSignInButton(t),yield u.init(l),u.on("payment.success",e=>pa(this,void 0,void 0,function*(){yield this.paymentSuccess(s,e)}))})}deinitialize(){return Promise.resolve()}paymentSuccess(e,t){return pa(this,void 0,void 0,function*(){return Promise.all([e.tokenize(t),this.braintreeSdk.getDataCollectorOrThrow()]).then(([e,t])=>{const n=this.paymentIntegrationService.getState(),i=n.getShippingAddress(),r=n.getBillingAddress(),{shippingAddress:o=this.toVisaCheckoutAddress(i),billingAddress:a=this.toVisaCheckoutAddress(r)}=e;return this.postForm(Object.assign(Object.assign({},e),{shippingAddress:o,billingAddress:a}),t)})})}postForm(e,t){const{userData:n,billingAddress:i,shippingAddress:r,details:o}=e,{userEmail:a}=n,{deviceData:s}=t;return this.formPoster.postForm("/checkout.php",{payment_type:e.type,nonce:e.nonce,provider:"braintreevisacheckout",action:"set_external_checkout",device_data:s,card_information:JSON.stringify({type:o.cardType,number:o.lastTwo}),billing_address:JSON.stringify(this.getAddress(a,i)),shipping_address:JSON.stringify(this.getAddress(a,r))})}toVisaCheckoutAddress(e){return e?{firstName:e.firstName,lastName:e.lastName,phoneNumber:e.phone,streetAddress:e.address1,extendedAddress:e.address2,locality:e.city,region:e.stateOrProvinceCode,countryCode:e.countryCode,postalCode:e.postalCode}:{}}getAddress(e,t={}){return{email:e,first_name:t.firstName,last_name:t.lastName,phone_number:t.phoneNumber,address_line_1:t.streetAddress,address_line_2:t.extendedAddress,city:t.locality,state:t.region,country_code:t.countryCode,postal_code:t.postalCode}}createSignInButton(e){const t=document.querySelector(`#${e}`);if(!t)throw new Error("Need a container to place the button");return this.insertVisaCheckoutButton(t)}insertVisaCheckoutButton(e){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="flex-end",t.innerHTML='\n <img\n alt="Visa Checkout"\n class="v-button"\n role="button"\n src="https://secure.checkout.visa.com/wallet-services-web/xo/button.png?acceptCanadianVisaDebit=false&cobrand=true&height=34&width=178"\n />\n <a class="v-learn v-learn-default" style="text-align: right; display: block; font-size: 10px; color: #003366;" href="#" data-locale="en_US">Tell Me More</a>',e.appendChild(t),t}}const ma=Ir(e=>{const t=window,i=new Br(e),r=new Xr(new io(le(),t,i));return new ga(e,n(),r)},[{id:"braintreevisacheckout"}]);function ya(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,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 fa(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}var _a=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const Sa=e=>{const{color:t,height:n}=e;return{backgroundColor:(i=t||"",i===Qo.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:`url("/app/assets/img/payment-providers/venmo-logo-${t===Qo.WHITE?Qo.BLUE:Qo.WHITE}.svg")`,backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:`${n||40}px`,minWidth:"150px",height:"100%",width:"100%",border:t===Qo.WHITE?"1px solid black":"none"};var i};class va{constructor(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n,this.onError=T}initialize(e){return _a(this,void 0,void 0,function*(){const{braintreevenmo:t,containerId:n,methodId:i}=e;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(i),{clientToken:o,initializationData:a}=r,{paymentButtonStyles:s}=a,{cartButtonStyles:d}=s||{},c=(null==t?void 0:t.style)||d;if(!o||!a)throw new dr(ar.MissingPaymentMethod);if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');yield this.paymentIntegrationService.loadDefaultCheckout(),this.onError=(null==t?void 0:t.onError)||this.handleError,this.braintreeSdk.initialize(o);try{const e=yield this.braintreeSdk.getVenmoCheckoutOrThrow();this.renderVenmoButton(e,n,null==t?void 0:t.buyNowInitializeOptions,c)}catch(e){(function(e){return"object"==typeof e&&null!==e&&"name"in e&&"BraintreeError"===e.name}(e)||function(e){return e instanceof xr}(e))&&this.handleInitializationVenmoError(e,n)}})}deinitialize(){return _a(this,void 0,void 0,function*(){return yield this.braintreeSdk.deinitialize(),Promise.resolve()})}handleError(e){throw new Error(e.message)}createBuyNowCart(e){return _a(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=null==e?void 0:e.getBuyNowCartRequestBody();if(!t)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new br}}})}handleInitializationVenmoError(e,t){return this.removeVenmoContainer(t),this.onError(e)}removeVenmoContainer(e){const t=document.getElementById(e);t&&t.remove()}renderVenmoButton(e,t,n,i){const r=document.getElementById(t),{color:o}=i||{};if(!r)throw new wr("Unable to create wallet button without valid container ID.");r.setAttribute("aria-label","Venmo"),Object.assign(r.style,Sa(i||{})),r.addEventListener("click",()=>_a(this,void 0,void 0,function*(){r.setAttribute("disabled","true");const t=yield this.createBuyNowCart(n);e.tokenize&&e.tokenize((e,n)=>_a(this,void 0,void 0,function*(){r.removeAttribute("disabled"),e&&this.onError(e),yield this.handlePostForm(n,null==t?void 0:t.id)}))})),o===Qo.BLUE&&(r.addEventListener("mouseenter",()=>{r.style.backgroundColor="#0a7fc2"}),r.addEventListener("mouseleave",()=>{r.style.backgroundColor=Sa(i||{}).backgroundColor}))}handlePostForm(e,t){return _a(this,void 0,void 0,function*(){const{deviceData:n}=yield this.braintreeSdk.getDataCollectorOrThrow(),{nonce:i,details:r}=e;this.formPoster.postForm("/checkout.php",Object.assign({nonce:i,provider:"braintreevenmo",payment_type:"paypal",device_data:n,action:"set_external_checkout",billing_address:JSON.stringify(ya(r)),shipping_address:JSON.stringify(fa(r))},t&&{cart_id:t}))})}}const Ca=Ir(e=>{const t=window,i=le(),r=new Br(e),o=new io(i,t,r),a=new Xr(o);return new va(e,n(),a)},[{id:"braintreevenmo"}]);class Ia{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var wa;!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.BIGCOMMERCE_PAYMENTS="googlepay_bigcommerce_payments",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.STRIPE_OCS="googlepaystripeocs",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(wa||(wa={}));const ba=function(e,t,n){return t&&n?Ea(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Ea(e.prototype,n,i))}),t}(e)};function Ea(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}class Pa{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:i,thousandsSeparator:r,decimalSeparator:o}=e;if("string"!=typeof n||"string"!=typeof i||"string"!=typeof r||"string"!=typeof o||"string"!=typeof t)throw new wr("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=i,this._thousandsSeparator=r,this._decimalSeparator=o}format(e){if("number"!=typeof e)throw new wr("Invalid amount provided");const t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?`-${n}`:n}_formatNumber(e){const t=Math.abs(e),[n,i=""]=this._toFixed(t,this._decimalPlaces).split("."),r=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?r:[r,i].join(this._decimalSeparator)}_formatCurrency(e){return"left"===this._symbolLocation.toLowerCase()?`${this._symbol}${e}`:`${e}${this._symbol}`}_toFixed(e,t){return(+`${Math.round(+`${e}e${t}`)}e${-t}`).toFixed(t)}}let Oa=class{constructor(e){this._storeConfig=e,this._customerFormatter=new Pa(this._storeConfig.shopperCurrency),this._storeFormatter=new Pa(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};Oa=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ba],Oa);const Aa=Oa;function Ta(){if("undefined"==typeof window)return!1;if(function(e){return"ReactNativeWebView"in e}(window))return!0;const e=navigator.userAgent||navigator.vendor||(function(e){return"opera"in e}(window)?window.opera:""),t=/android.+; wv/i.test(e),n=/iPhone|iPod|iPad/i.test(e)&&/AppleWebKit/i.test(e)&&!/Safari/i.test(e);return t||n}var ka,Ra,Da,Ma,Na,La,za,Ua,Fa;function Ba(e){return e in La}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(ka||(ka={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Ra||(Ra={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Da||(Da={})),function(e){e.pill="pill",e.rect="rect"}(Ma||(Ma={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Na||(Na={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(La||(La={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(za||(za={})),function(e){e.OFFER_INVALID="OFFER_INVALID",e.PAYMENT_DATA_INVALID="PAYMENT_DATA_INVALID",e.SHIPPING_ADDRESS_INVALID="SHIPPING_ADDRESS_INVALID",e.SHIPPING_ADDRESS_UNSERVICEABLE="SHIPPING_ADDRESS_UNSERVICEABLE",e.SHIPPING_OPTION_INVALID="SHIPPING_OPTION_INVALID",e.OTHER_ERROR="OTHER_ERROR"}(Ua||(Ua={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(Fa||(Fa={}));var xa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class qa{constructor(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1,this._shouldRequestShipping=!0,this._isWebViewExperimentOn=null}mapToShippingAddressRequestBody({shippingAddress:e}){if(!e)return;const{company:t="",phone:n=""}=this._paymentIntegrationService.getState().getShippingAddress()||{};return this._mapToAddressRequestBody(e,t,n)}mapToBillingAddressRequestBody(e){const{billingAddress:t}=e.paymentMethodData.info;if(!t)return;const{company:n="",phone:i="",email:r,customFields:o=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Object.assign(Object.assign({},this._mapToAddressRequestBody(t,n,i,o)),{email:r||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:i,cardDetails:r}}}=e;if(!n)throw new dr(ar.MissingPaymentToken);return Promise.resolve(Object.assign({nonce:n,card_information:{type:i,number:r}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))}getRequiredData(){return xa(this,void 0,void 0,function*(){var e;const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=null===(e=(yield this._paymentIntegrationService.loadShippingCountries()).getShippingCountries())||void 0===e?void 0:e.map(e=>e.code);return Object.assign(Object.assign({},t),{shippingAddressRequired:!0,shippingAddressParameters:Object.assign({phoneNumberRequired:!0},n&&{allowedCountryCodes:n}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[za.OFFER,za.SHIPPING_ADDRESS,za.SHIPPING_OPTION]:[za.OFFER]}getCallbackTriggers(){return{availableTriggers:[Fa.INITIALIZE,Fa.SHIPPING_ADDRESS,Fa.SHIPPING_OPTION,Fa.OFFER],initializationTrigger:[Fa.INITIALIZE],addressChangeTriggers:[Fa.INITIALIZE,Fa.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[Fa.SHIPPING_OPTION],offerChangeTriggers:[Fa.OFFER]}}getNonce(e){var t;const n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new dr(ar.MissingPaymentToken);return Promise.resolve(n)}extraPaymentData(){return Promise.resolve(void 0)}getMerchantInfo(){const{googleMerchantName:e,googleMerchantId:t,platformToken:n}=this.getGooglePayInitializationData();return{merchantName:e,merchantId:t,authJwt:n}}getTransactionInfo(){let e;const{getCartOrThrow:t}=this._paymentIntegrationService.getState();e=this._isBuyNowFlow?this._getCurrencyCodeOrThrow():t().currency.code;const n=this.getGooglePayInitializationData().storeCountry;if(this.isWebViewWithRestrictions()){const t=this.getTotalPrice();return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPrice:t,totalPriceStatus:Na.ESTIMATED})}return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:Na.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&Ta():Ta()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new wr("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(Ba).map(e=>La[e]),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}}initialize(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()}handleShippingAddressChange(e){return xa(this,void 0,void 0,function*(){var t,n,i,r;e&&(e.name=e.name||"",e.address1=e.address1||"");const o=this.mapToShippingAddressRequestBody({shippingAddress:e});o&&(yield this._paymentIntegrationService.updateShippingAddress(o));const a=this._paymentIntegrationService.getState(),s=a.getConsignments();if(!(null==s?void 0:s[0]))return;const d=s[0],c=a.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new Aa(c));const u=(d.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this)),l=null===(t=d.availableShippingOptions)||void 0===t?void 0:t.find(e=>e.isRecommended);if(u.length){const e=(null===(n=d.selectedShippingOption)||void 0===n?void 0:n.id)||(null==l?void 0:l.id)||(null===(i=u[0])||void 0===i?void 0:i.id);return!(null===(r=d.selectedShippingOption)||void 0===r?void 0:r.id)&&u[0]&&(yield this.handleShippingOptionChange((null==l?void 0:l.id)||u[0].id)),{defaultSelectedOptionId:e,shippingOptions:u}}})}handleShippingOptionChange(e){return xa(this,void 0,void 0,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t,getStoreConfigOrThrow:n}=this._paymentIntegrationService.getState(),{decimalPlaces:i}=t().currency,r=Lr(n().checkoutSettings.features,"PI-5075.google_pay_round_total_price_to_max_2_decimal_places")?Math.min(i,2):i;return L(e().outstandingBalance,r).toFixed(r)}handleCoupons(e){return xa(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let i;return yield t.reduce((e,t)=>xa(this,void 0,void 0,function*(){if(yield e,(n||[]).some(({redemptionCode:e})=>e===t))return;const r=yield this.applyCoupon(t);r&&(i=r)}),Promise.resolve()),yield(n||[]).reduce((e,n)=>xa(this,void 0,void 0,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:i}})}getAppliedCoupons(){const e=this._paymentIntegrationService.getState(),{coupons:t}=e.getCheckout()||{};return{offers:(t||[]).map(e=>{const{displayName:t,code:n}=e;return{redemptionCode:n,description:t}})}}applyCoupon(e){return xa(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:Ua.OFFER_INVALID,message:e.message,intent:Fa.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return ur(this.getPaymentMethod().initializationData,()=>new wr("Missing initialization data."))}getPaymentMethod(){return ur(this._getPaymentMethodFn,()=>new lr(sr.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),i=t();let r;return r=Lr(i.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),r&&(o=e(),a=i,!!o&&(!!o.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!a||!o.lineItems.customItems)&&o.lineItems.customItems.length>0));var o,a}_mapToAddressRequestBody(e,t,n,i){const{name:r,address1:o,address2:a,address3:s,locality:d,administrativeArea:c,countryCode:u,postalCode:l,phoneNumber:h}=e,[p,g]=this._getFirstAndLastName(r);return{firstName:p,lastName:g,company:t,address1:o,address2:`${a} ${s}`.trim(),city:d||c,stateOrProvince:c,stateOrProvinceCode:c,countryCode:u,postalCode:l,phone:h||n,customFields:i||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return ur(this._currencyCode,()=>new wr('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:i}){var r;return{id:e,label:`${(null===(r=this._currencyService)||void 0===r?void 0:r.toCustomerCurrency(t))||t} ${n}`,description:i}}}var ja=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ga extends qa{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=wa.BRAINTREE,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ja(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);let r=i.getPaymentMethod.call(this);if(r.clientToken||(r=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!r.clientToken||!r.initializationData)throw new dr(ar.MissingPaymentMethod);return this._braintreeSdk.initialize(r.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ja(this,void 0,void 0,function*(){var n;const i=yield t.getNonce.call(this,e),{clientToken:r,initializationData:o}=t.getPaymentMethod.call(this);if(!r||!o||!(null===(n=o.card_information)||void 0===n?void 0:n.bin))throw new dr(ar.MissingPaymentMethod);const{isThreeDSecureEnabled:a,card_information:{bin:s,isNetworkTokenized:d}}=o;if(a&&!d){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,i,s)).nonce}return i})}extraPaymentData(){return ja(this,void 0,void 0,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return ja(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new wr("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 dr(ar.MissingPaymentToken)}(i),n.nonce=i.androidPayCards[0].nonce,n.card_information.bin=i.androidPayCards[0].details.bin,n.card_information.isNetworkTokenized=i.androidPayCards[0].details.isNetworkTokenized,n})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){const e=Object.create(null,{getMerchantInfo:{get:()=>super.getMerchantInfo},getTransactionInfo:{get:()=>super.getTransactionInfo},getRequiredData:{get:()=>super.getRequiredData}});return ja(this,void 0,void 0,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(Object.assign({merchantInfo:e.getMerchantInfo.call(this),transactionInfo:e.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield e.getRequiredData.call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new dr(ar.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return ja(this,void 0,void 0,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,i){return new Ia(e.verifyCard({amount:t,bin:i,nonce:n,onLookupComplete:(e,t)=>{t()}})).promise}}class Va extends ve{constructor(e){super(e||"Unable to proceed because the client library of a payment method has thrown an unexpected error."),this.name="PaymentMethodFailedError",this.type="payment_method_client_invalid"}}var Ha=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Wa{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){return Ha(this,void 0,void 0,function*(){var t,n,i,r;if(!e.methodId||(r=e.methodId,!Object.values(wa).includes(r)))throw new wr('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new wr('Unable to proceed because "containerId" is not a valid key.');const o=e[this._getMethodOrThrow()];if(!o)throw new wr("Unable to proceed without valid options.");const{buyNowInitializeOptions:a,currencyCode:s,buttonColor:d,buttonType:c,onError:u}=o;let l,h=this._paymentIntegrationService.getState();try{l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){h=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null===(t=l.initializationData)||void 0===t?void 0:t.storeCountry,this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(n=l.initializationData)||void 0===n?void 0:n.isWebViewExperimentOn)),a){if(!s)throw new wr('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=s,this._buyNowInitializeOptions=a,yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions(),!!a,s)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions());this._paymentButton=null!==(i=this._paymentButton)&&void 0!==i?i:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=d?d:"default",buttonType:null!=c?c:"plain",onClick:this._handleClick(u)})})}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>Ha(this,void 0,void 0,function*(){t.preventDefault();try{this._buyNowInitializeOptions?yield this._createBuyNowCartOrThrow(this._buyNowInitializeOptions):yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(function(e){return"object"==typeof e&&null!==e&&"statusCode"in e}(t)){if("CANCELED"===t.statusCode)throw new ro;n=new Va(JSON.stringify(t))}throw null==e||e(new Va("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Ha(this,void 0,void 0,function*(){var e;const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),i=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),r="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),i&&!(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(i)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,r)})}_getGooglePayClientOptions(){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:e=>Ha(this,[e],void 0,function*({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:i}){const{availableTriggers:r,addressChangeTriggers:o,shippingOptionsChangeTriggers:a,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!r.includes(e))return;const d=o.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;a.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:c,error:u}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},l=u;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(d,c,l):this._getTransactionInfo(d,c,l)})}}}_createBuyNowCartOrThrow(e){return Ha(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=e.getBuyNowCartRequestBody();try{this._buyNowCart=yield this._paymentIntegrationService.createBuyNowCart(t),yield this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)}catch(e){if("string"==typeof e)throw new br(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:i}=this._buyNowCart,r=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:r||String(i),totalPriceStatus:Na.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return Ha(this,void 0,void 0,function*(){yield this._paymentIntegrationService.loadCheckout();const i=this._googlePayPaymentProcessor.getTotalPrice(),{code:r}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:r,totalPriceStatus:Na.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return ur(this._methodId,()=>new lr(sr.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return ur(this._currencyCode,()=>new wr('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}var Ya=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ka{constructor(e,t,n,i){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=i,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,i){return Ya(this,void 0,void 0,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,i),this._buildButtonPayloads()})}initializeWidget(){return Ya(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return Ya(this,void 0,void 0,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const i=this._getPaymentsClient().createButton(Object.assign(Object.assign({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(i)}showPaymentSheet(){return Ya(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return Ya(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return Ya(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t,!0,n)})}mapToBillingAddressRequestBody(e){return this._gateway.mapToBillingAddressRequestBody(e)}mapToShippingAddressRequestBody(e){return this._gateway.mapToShippingAddressRequestBody(e)}processAdditionalAction(e,t){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e,t):Promise.reject(e)}signOut(e){return Ya(this,void 0,void 0,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return Ya(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return Ya(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return Ya(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t){return Ya(this,arguments,void 0,function*(e,t,n=!1,i){const r="/checkout.php",o=Object.assign({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(i?`${i}/checkout`:r,Object.assign(Object.assign({},o),{card_information:JSON.stringify(o.card_information)}),e)});yield this._requestSender.post(r,{headers:Object.assign({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},Dr),body:o})})}isWebViewWithRestrictions(){return this._gateway.isWebViewWithRestrictions()}setIsWebViewExperimentOn(e){return this._gateway.setIsWebViewExperimentOn(e)}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return Ya(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new Va("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof Va)throw e;throw new Va}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return Ya(this,void 0,void 0,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=Object.assign(Object.assign({},e),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:yield this._gateway.getPaymentGatewayParameters()}});const t=this._gateway.isWebViewWithRestrictions()?{shippingOptionRequired:!1}:{callbackIntents:this._gateway.getCallbackIntents(),offerInfo:this._gateway.getAppliedCoupons()};this._paymentDataRequest=Object.assign(Object.assign(Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),t),this._isReadyToPayRequest=Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[e]})})}_getBaseCardPaymentMethod(){return this._getOrThrow(this._baseCardPaymentMethod)}_getPaymentDataRequest(){return this._getOrThrow(this._paymentDataRequest)}_getIsReadyToPayRequest(){return this._getOrThrow(this._isReadyToPayRequest)}_getPaymentsClient(){return this._getOrThrow(this._paymentsClient)}_getOrThrow(e){return ur(e,()=>new lr(sr.PaymentNotInitialized))}}class $a{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(){return e=this,t=arguments,i=function*(e=!1,t){if(yield this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js"),!this._window.google)throw new vr;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient(Object.assign({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}function Za(){return new $a(le())}const Ja=Ir(t=>{const i=e(),r=window,o=new Br(t),a=new Xr(new io(le(),r,o));return new Wa(t,new Ka(Za(),new Ga(t,a),i,n()))},[{id:"googlepaybraintree"}]),Qa=["ar_BH","ar_DZ","ar_EG","ar_JO","ar_KW","ar_MA","ar_OM","ar_QA","ar_SA","ar_TN","ar_YE","ar_AE","bg_BG","cs_CZ","da_DK","da_FO","da_GL","de_AT","de_CH","de_DE","de_LU","el_GR","en_AD","en_AE","en_AG","en_AI","en_AL","en_AM","en_AN","en_AO","en_AT","en_AU","en_AW","en_AZ","en_BB","en_BE","en_BH","en_BJ","en_BM","en_BN","en_BS","en_BT","en_BW","en_BY","en_BZ","en_C2","en_CA","en_CD","en_CG","en_CH","en_CI","en_CK","en_CL","en_CM","en_CN","en_CO","en_CR","en_CV","en_CY","en_CZ","en_DE","en_DJ","en_DK","en_DM","en_DO","en_DZ","en_EC","en_EE","en_EG","en_ER","en_ES","en_ET","en_FI","en_FJ","en_FK","en_FM","en_FO","en_FR","en_GA","en_GB","en_GD","en_GE","en_GF","en_GI","en_GL","en_GM","en_GN","en_GP","en_GR","en_GT","en_GW","en_GY","en_HK","en_HN","en_HR","en_HU","en_ID","en_IE","en_IL","en_IN","en_IS","en_IT","en_JM","en_JO","en_JP","en_KE","en_KG","en_KH","en_KI","en_KM","en_KN","en_KR","en_KW","en_KY","en_KZ","en_LA","en_LC","en_LI","en_LK","en_LS","en_LT","en_LU","en_LV","en_MA","en_MC","en_MD","en_ME","en_MG","en_MH","en_MK","en_ML","en_MN","en_MQ","en_MR","en_MS","en_MT","en_MU","en_MV","en_MW","en_MY","en_MZ","en_NA","en_NC","en_NE","en_NF","en_NG","en_NI","en_NL","en_NO","en_NP","en_NR","en_NU","en_NZ","en_OM","en_PA","en_PE","en_PF","en_PG","en_PH","en_PL","en_PM","en_PN","en_PT","en_PW","en_PY","en_QA","en_RE","en_RO","en_RS","en_RU","en_RW","en_SA","en_SB","en_SC","en_SE","en_SG","en_SH","en_SI","en_SJ","en_SK","en_SL","en_SM","en_SN","en_SO","en_SR","en_ST","en_SV","en_SZ","en_TC","en_TD","en_TG","en_TH","en_TJ","en_TM","en_TN","en_TO","en_TR","en_TT","en_TV","en_TW","en_TZ","en_UA","en_UG","en_US","en_UY","en_VA","en_VC","en_VE","en_VG","en_VN","en_VU","en_WF","en_WS","en_YE","en_YT","en_ZA","en_ZM","en_ZW","es_AD","es_AI","es_AO","es_AR","es_AW","es_BB","es_BJ","es_BM","es_BO","es_BS","es_BZ","es_CD","es_CG","es_CK","es_CL","es_CO","es_CR","es_CV","es_DJ","es_DM","es_DO","es_DZ","es_EC","es_EG","es_ER","es_ES","es_ET","es_FJ","es_FK","es_FO","es_GA","es_GD","es_GE","es_GI","es_GL","es_GM","es_GN","es_GT","es_GW","es_GY","es_HN","es_IE","es_JM","es_JO","es_KE","es_KG","es_KI","es_KM","es_KN","es_KW","es_KY","es_KZ","es_LC","es_LI","es_LS","es_LU","es_MA","es_MG","es_MH","es_ML","es_MR","es_MS","es_MU","es_MW","es_MX","es_MZ","es_NA","es_NC","es_NE","es_NF","es_NI","es_NR","es_NU","es_NZ","es_OM","es_PA","es_PE","es_PF","es_PG","es_PM","es_PN","es_PW","es_PY","es_QA","es_RS","es_RW","es_SA","es_SB","es_SC","es_SH","es_SJ","es_SL","es_SM","es_SN","es_SO","es_SR","es_ST","es_SV","es_SZ","es_TC","es_TD","es_TG","es_TJ","es_TM","es_TN","es_TT","es_TV","es_UA","es_UG","es_US","es_UY","es_VA","es_VC","es_VE","es_VG","es_VU","es_WF","es_YE","es_ZM","et_EE","fi_FI","fr_AD","fr_AE","fr_AI","fr_AM","fr_AO","fr_AW","fr_AZ","fr_BB","fr_BE","fr_BF","fr_BI","fr_BJ","fr_BM","fr_BS","fr_BZ","fr_CA","fr_CD","fr_CG","fr_CH","fr_CI","fr_CK","fr_CM","fr_CV","fr_DJ","fr_DM","fr_DO","fr_DZ","fr_EC","fr_ER","fr_ET","fr_FJ","fr_FK","fr_FO","fr_FR","fr_GA","fr_GD","fr_GE","fr_GF","fr_GI","fr_GL","fr_GM","fr_GN","fr_GP","fr_GT","fr_GW","fr_GY","fr_HN","fr_IE","fr_JM","fr_JO","fr_KE","fr_KG","fr_KI","fr_KM","fr_KN","fr_KW","fr_KY","fr_KZ","fr_LC","fr_LI","fr_LS","fr_LU","fr_MA","fr_MC","fr_MG","fr_MH","fr_ML","fr_MQ","fr_MR","fr_MS","fr_MU","fr_MW","fr_MZ","fr_NA","fr_NC","fr_NE","fr_NF","fr_NI","fr_NR","fr_NU","fr_NZ","fr_OM","fr_PA","fr_PE","fr_PF","fr_PG","fr_PM","fr_PN","fr_PW","fr_QA","fr_RE","fr_RS","fr_RW","fr_SA","fr_SB","fr_SC","fr_SH","fr_SJ","fr_SL","fr_SM","fr_SN","fr_SO","fr_SR","fr_ST","fr_SV","fr_SZ","fr_TC","fr_TD","fr_TG","fr_TJ","fr_TM","fr_TN","fr_TT","fr_TV","fr_UA","fr_UG","fr_US","fr_UY","fr_VA","fr_VC","fr_VE","fr_VG","fr_VU","fr_WF","fr_YE","fr_YT","fr_ZA","fr_ZM","he_IL","hu_HU","id_ID","it_IT","ja_JP","ko_KR","lv_LV","lt_LT","ms_BN","ms_MY","nl_BE","nl_NL","pl_PL","pt_BR","pt_PT","ro_RO","ru_EE","ru_LT","ru_LV","ru_RU","ru_UA","si_LK","sk_SK","sl_SI","sq_AL","sv_SE","tl_PH","th_TH","tr_TR","vi_VN","zh_C2","zh_CN","zh_HK","zh_TW","zh_AD","zh_AE","zh_AI","zh_AO","zh_AW","zh_BB","zh_BH","zh_BJ","zh_BM","zh_BS","zh_BZ","zh_CD","zh_CG","zh_CK","zh_CL","zh_CO","zh_CV","zh_DJ","zh_DM","zh_DO","zh_DZ","zh_EC","zh_EG","zh_ER","zh_ET","zh_FJ","zh_FK","zh_FO","zh_GA","zh_GD","zh_GE","zh_GI","zh_GL","zh_GM","zh_GN","zh_GT","zh_GW","zh_GY","zh_HN","zh_IE","zh_JM","zh_JO","zh_KE","zh_KG","zh_KI","zh_KM","zh_KN","zh_KW","zh_KY","zh_KZ","zh_LC","zh_LI","zh_LS","zh_LT","zh_LU","zh_MA","zh_MG","zh_MH","zh_ML","zh_MR","zh_MS","zh_MU","zh_MW","zh_MZ","zh_NA","zh_NC","zh_NE","zh_NF","zh_NI","zh_NR","zh_NU","zh_NZ","zh_OM","zh_PA","zh_PE","zh_PF","zh_PG","zh_PM","zh_PN","zh_PW","zh_QA","zh_RS","zh_RW","zh_SA","zh_SB","zh_SC","zh_SH","zh_SJ","zh_SL","zh_SM","zh_SN","zh_SO","zh_SR","zh_ST","zh_SV","zh_SZ","zh_TC","zh_TD","zh_TG","zh_TJ","zh_TM","zh_TN","zh_TT","zh_TV","zh_UA","zh_UG","zh_US","zh_UY","zh_VA","zh_VC","zh_VE","zh_VG","zh_VU","zh_WF","zh_YE","zh_ZA","zh_ZM"];function Xa(e){if(!e)return;let t;if(e.includes("-")){const[n,i]=e.split("-");t=`${n}_${i.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return Qa.includes(t)?t:void 0}var es=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ts{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n,i){return es(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypalFastlaneSdk)throw new vr}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,r){return es(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(r)}if(!this.window.paypalGooglePay)throw new vr;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return es(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new vr}return this.window.paypalApms})}getPayPalMessages(e,t,n){return es(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new vr;return this.window.paypalMessages})}loadPayPalSdk(e){return es(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n,i){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,attributionId:c}=o,u=Xa(i);return{options:Object.assign({"client-id":s,"merchant-id":d,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},u&&{locale:u}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,p=l||i,g=Xa(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:p,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),g&&{locale:g}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:r,clientId:o,merchantId:a,buyerCountry:s,attributionId:d,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:u=[],enabledAlternativePaymentMethods:l=[]}=i,h=l,p=u.filter(e=>!l.includes(e)),g=Xa(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":p.length>0?p:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),g&&{locale:g}),attributes:{"data-partner-attribution-id":d,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new dr(ar.MissingPaymentMethod);const{clientId:r,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:d}=i,c=Xa(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":d}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}function ns(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 dr(ar.MissingPaymentMethod)}var is=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class rs extends qa{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return is(this,void 0,void 0,function*(){var r,o,a,s,d;const c=this.service.getState(),u=null!==(o=null===(r=c.getStoreConfig())||void 0===r?void 0:r.currency.code)&&void 0!==o?o:n;if(!u)throw new dr(ar.MissingPaymentMethod);yield i.initialize.call(this,e,t,u);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new dr(ar.MissingPaymentMethod);ns(l);const h=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(l,u,c.getLocale());this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:p}=this.googlepayConfig;this.setGatewayIdentifier(null===(d=null===(s=null===(a=p[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===d?void 0:d.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return is(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const os=Ir(t=>new Wa(t,new Ka(Za(),new rs(t,new ts(le())),e(),n())),[{id:"googlepaypaypalcommerce"}]);var as=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ss{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return as(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.bigCommercePaymentsFastlaneSdk)throw new vr}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return as(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.bigCommercePaymentsGooglePay)throw new vr;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return as(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.bigCommercePaymentsApms)throw new vr}return this.window.bigCommercePaymentsApms})}getPayPalMessages(e,t){return as(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.bigCommercePaymentsMessages)throw new vr;return this.window.bigCommercePaymentsMessages})}loadPayPalSdk(e){return as(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:r}=e;if(!r||!r.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,attributionId:d}=r;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"bigCommercePaymentsFastlaneSdk","data-partner-attribution-id":d,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:r}=e;if(!r||!r.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,buyerCountry:d,attributionId:c,isHostedCheckoutEnabled:u,isDeveloperModeApplicable:l}=r,h=u||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:h,components:["googlepay"],currency:t,intent:o},l&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":c,"data-client-token":i,"data-namespace":"bigCommercePaymentsGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:i,clientId:r,merchantId:o,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:d,availableAlternativePaymentMethods:c=[],enabledAlternativePaymentMethods:u=[]}=n,l=this.filterFundingOptions(u),h=this.filterFundingOptions(c.filter(e=>!u.includes(e)));return{options:Object.assign({"client-id":r,"merchant-id":o,"enable-funding":l.length>0?l:void 0,"disable-funding":h.length>0?h:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},d&&{"buyer-country":a}),attributes:{"data-partner-attribution-id":s,"data-namespace":"bigCommercePaymentsApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new dr(ar.MissingPaymentMethod);const{clientId:i,merchantId:r,attributionId:o,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":r,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"bigCommercePaymentsMessages","data-partner-attribution-id":o}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var ds=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class cs extends qa{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ds(this,void 0,void 0,function*(){var r,o,a,s,d;const c=null!==(o=null===(r=this.service.getState().getStoreConfig())||void 0===r?void 0:r.currency.code)&&void 0!==o?o:n;if(!c)throw new dr(ar.MissingPaymentMethod);yield i.initialize.call(this,e,t,c);const u=i.getPaymentMethod.call(this);if(!u.initializationData)throw new dr(ar.MissingPaymentMethod);ns(u);const l=yield this.payPalSdkHelper.getPayPalGooglePaySdk(u,c);this.googlepayConfig=yield l.Googlepay().config();const{allowedPaymentMethods:h}=this.googlepayConfig;this.setGatewayIdentifier(null===(d=null===(s=null===(a=h[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===d?void 0:d.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return ds(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const us=Ir(t=>new Wa(t,new Ka(Za(),new cs(t,new ss(le())),e(),n())),[{id:"googlepay_bigcommerce_payments"}]),ls=Ir(t=>{const i=e();return new Wa(t,new Ka(Za(),new qa("adyen",t),i,n()))},[{id:"googlepayadyenv2"}]),hs=Ir(t=>{const i=e();return new Wa(t,new Ka(Za(),new qa("adyen",t),i,n()))},[{id:"googlepayadyenv3"}]);class ps extends qa{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new dr(ar.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const gs=Ir(t=>new Wa(t,new Ka(Za(),new ps(t),e(),n())),[{id:"googlepayauthorizenet"}]),ms=e=>"object"==typeof e&&null!==e&&"body"in e;function ys(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new dr(ar.MissingPaymentMethod)}var fs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class _s extends qa{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(ms(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return fs(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new wr("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"protocolVersion"in e&&"signature"in e&&"signedMessage"in e}(e))throw new dr(ar.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return ys(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return fs(this,void 0,void 0,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();ys(n);const{body:i}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":Rr.Json,"X-XSRF-TOKEN":null}});return i.token})}}const Ss=Ir(t=>{const i=e();return new Wa(t,new Ka(Za(),new _s(t,i),i,n()))},[{id:"googlepaycheckoutcom"}]);class vs extends qa{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Cs=Ir(t=>new Wa(t,new Ka(Za(),new vs(t),e(),n())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class Is extends qa{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const ws=Ir(t=>new Wa(t,new Ka(Za(),new Is(t),e(),n())),[{id:"googlepayorbital"}]);var bs,Es,Ps,Os,As,Ts,ks,Rs,Ds,Ms,Ns,Ls;!function(e){e.SHIPPING="shipping",e.BILLING="billing"}(bs||(bs={})),function(e){e.SPLIT="split",e.FULL="full",e.ORGANIZATION="organization"}(Es||(Es={})),function(e){e.Open="open",e.Expired="expired",e.Complete="complete"}(Ps||(Ps={})),function(e){e.Paid="paid",e.UnPaid="unpaid",e.NoPaymentRequired="no_payment_required"}(Os||(Os={})),function(e){e.SUCCESS="success",e.ERROR="error"}(As||(As={})),function(e){e.CreditCard="card",e.ACH="us_bank_account",e.Link="link",e.EPS="eps",e.GRABPAY="grabpay",e.BANCONTACT="bancontact",e.IDEAL="ideal",e.ALIPAY="alipay",e.KLARNA="klarna",e.OCS="optimized_checkout",e.CHECKOUT_SESSION="checkout_session"}(Ts||(Ts={})),function(e){e.NEVER="never",e.AUTO="auto",e.ALWAYS="always",e.PAYMENT="payment",e.IF_REQUIRED="if_required"}(ks||(ks={})),function(e){e.V3="v3",e.ACACIA="acacia",e.BASIL="basil",e.CLOVER="clover"}(Rs||(Rs={})),function(e){e.PAYMENT="payment",e.AUTHENTICATION="linkAuthentication",e.SHIPPING="address",e.EXPRESS_CHECKOUT="expressCheckout"}(Ds||(Ds={})),function(e){e.REQUIRES_PAYMENT_METHOD="requires_payment_method",e.REQUIRES_CONFIRMATION="requires_confirmation",e.REQUIRES_ACTION="requires_action",e.PROCESSING="processing",e.SUCCEEDED="succeeded",e.CANCELED="canceled"}(Ms||(Ms={})),function(e){e.CLICK="click",e.CHANGE="change",e.READY="ready",e.SHIPPING_ADDRESS_CHANGE="shippingaddresschange",e.SHIPPING_RATE_CHANGE="shippingratechange",e.CONFIRM="confirm",e.CANCEL="cancel",e.LOADER_START="loaderstart"}(Ns||(Ns={})),function(e){e.ON_SESSION="on_session",e.OFF_SESSION="off_session"}(Ls||(Ls={}));var zs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Us{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,i,r){return zs(this,void 0,void 0,function*(){if(this.stripeWindow.bcStripeClient)return this.stripeWindow.bcStripeClient;const o=yield this.load(n),{stripePublishableKey:a,stripeConnectedAccount:s}=e,d=o(a,Object.assign(Object.assign(Object.assign(Object.assign({},s?{stripeAccount:s}:{}),t?{locale:t}:{}),i?{betas:i}:{}),r?{apiVersion:r}:{}));return Object.assign(this.stripeWindow,{bcStripeClient:d}),d})}getElements(e,t){return zs(this,void 0,void 0,function*(){let n=this.stripeWindow.bcStripeElements;return n?yield this.updateStripeElements(t):(n=e.elements(t),Object.assign(this.stripeWindow,{bcStripeElements:n})),n})}updateStripeElements(e){return zs(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return zs(this,void 0,void 0,function*(){let n=yield this.getStoredStripeCheckout(t);return n||(n=yield e.initCheckout(t),Object.assign(this.stripeWindow,{bcStripeCheckout:n})),n})}load(e){return zs(this,void 0,void 0,function*(){if(!this.stripeWindow.Stripe&&(yield this.scriptLoader.loadScript(this.getScriptUrl(e)),!this.stripeWindow.Stripe))throw new vr;return this.stripeWindow.Stripe})}getScriptUrl(e){return e&&e!==Rs.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return zs(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeCheckout;if(t)try{const{actions:n,error:i}=yield t.loadActions();if(i||!n)return void this.logErrorToConsole(i);const r=yield n.getSession(),o=e.clientSecret.split("_secret_")[0];if(r.id===o)return t}catch(e){return void this.logErrorToConsole(e)}})}logErrorToConsole(e){e?console.error(e):console.error("No stripe checkout actions available on loadActions().")}}const Fs=["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"];function Bs(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new dr(ar.MissingPaymentMethod)}var xs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class qs extends qa{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return xs(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new wr("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"id"in e}(e))throw new dr(ar.MissingPaymentToken)}(i),n.nonce=i.id,n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Bs(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:i}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${i}`}}processAdditionalAction(e,t){return xs(this,void 0,void 0,function*(){var n,i;if(!t)throw new Wo(["payment"]);if(!ms(e)||("object"!=typeof(i=e.body)||null===i||!("three_ds_result"in i)||!("errors"in i)))throw e;if(z(e.body.errors,{code:"three_d_secure_required"})){const i=this.getGooglePayInitializationData();Bs(i),this.stripeUPEClient=yield this.loadStripeJs(i,t);const r=e.body.three_ds_result.token;let o,a=!1;try{o=yield this.stripeUPEClient.confirmCardPayment(r)}catch(e){try{o=yield this.stripeUPEClient.retrievePaymentIntent(r)}catch(e){a=!0}}if(null==o?void 0:o.error){if(this._throwDisplayableStripeError(o.error),this._isCancellationError(o.error))throw new ro;throw new Va}if(!(null==o?void 0:o.paymentIntent)&&!a)throw new Ie;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null===(n=null==o?void 0:o.paymentIntent)||void 0===n?void 0:n.id)||r}})}throw e})}loadStripeJs(e,t){return xs(this,void 0,void 0,function*(){if(this.stripeUPEClient)return this.stripeUPEClient;const n=this.paymentIntegrationService.getState().getCartLocale();return"googlepaystripeocs"===t&&e.useNewStripeJsVersion?this.scriptLoader.getStripeClient(e,n,Rs.CLOVER):this.scriptLoader.getStripeClient(e,n,Rs.V3,Fs,"2020-03-02;alipay_beta=v1;link_beta=v1")})}_isCancellationError(e){var t,n;return e&&-1!==(null===(n=null===(t=e.payment_intent.last_payment_error)||void 0===t?void 0:t.message)||void 0===n?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(m(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}const js=Ir(t=>new Wa(t,new Ka(Za(),new qs(t,new Us(le())),e(),n())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class Gs extends qa{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Vs=Ir(t=>new Wa(t,new Ka(Za(),new Gs(t),e(),n())),[{id:"googlepayworldpayaccess"}]);function Hs(){const{navigator:e}=window;let t;return t=e.language?e.language:e.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof e.javaEnabled&&e.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()}}var Ws=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ys extends qa{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Ws(this,void 0,void 0,function*(){return Promise.resolve({browser_info:Hs()})})}processAdditionalAction(e){return Ws(this,void 0,void 0,function*(){if(!function(e){return ms(e)&&(t=e.body,C(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&y(t.errors)&&z(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;const{three_ds_result:t}=e.body,{acs_url:n,payer_auth_request:i,merchant_data:r}=t||{};if(!n||!i||!r)throw new Wo(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:r},e,"_top")})})}}const Ks=Ir(t=>new Wa(t,new Ka(Za(),new Ys(t,n()),e(),n())),[{id:"googlepaytdonlinemart"}]);var $s,Zs,Js,Qs,Xs,ed,td,nd,id,rd,od=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ad{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return od(this,void 0,void 0,function*(){if(!this.window.paypal||r){const r=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypal)throw new vr}return this.window.paypal})}getPayPalFastlaneSdk(e,t,n,i){return od(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypalFastlaneSdk)throw new vr}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,r){return od(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(r)}if(!this.window.paypalGooglePay)throw new vr;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return od(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new vr}return this.window.paypalApms})}getPayPalMessages(e,t,n){return od(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new vr;return this.window.paypalMessages})}loadPayPalSdk(e){return od(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!a||!a.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:s,clientId:d,merchantId:c,buyerCountry:u,attributionId:l,isVenmoEnabled:h,isHostedCheckoutEnabled:p,isPayPalCreditAvailable:g,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:y=[],enabledAlternativePaymentMethods:f=[],isGooglePayEnabled:_}=a,S=p||i,v="paypalcommercecreditcards"===r||"bigcommerce_payments_creditcards"===r,C=v?["card"]:[],I=g?["credit","paylater"]:[],w=h?["venmo"]:[],b=_?["googlepay"]:[],E=i?["card-fields"]:[],P=[...v?[]:["card"],...g?[]:["credit","paylater"],...h?[]:["venmo"],...y.filter(e=>!f.includes(e))],O=[...C,...I,...w,...f],A=Xa(n);return{options:Object.assign(Object.assign({"client-id":d,"merchant-id":c,"enable-funding":O.length>0?O:void 0,"disable-funding":P.length>0?P:void 0,commit:S,components:["buttons","hosted-fields","payment-fields","legal",...b,...E],currency:t,intent:s},m&&{"buyer-country":u}),A&&{locale:A}),attributes:{"data-partner-attribution-id":l,"data-client-token":o}}}getPayPalFastlaneSdkConfiguration(e,t,n,i){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,attributionId:c}=o,u=Xa(i);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t},u&&{locale:u}),{intent:a}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,p=l||i,g=Xa(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:p,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),g&&{locale:g}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:r,clientId:o,merchantId:a,buyerCountry:s,attributionId:d,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:u=[],enabledAlternativePaymentMethods:l=[]}=i,h=l,p=u.filter(e=>!l.includes(e)),g=Xa(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":p.length>0?p:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),g&&{locale:g}),attributes:{"data-partner-attribution-id":d,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new dr(ar.MissingPaymentMethod);const{clientId:r,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:d}=i,c=Xa(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":d}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}($s||($s={})),function(e){e.Always="SCA_ALWAYS"}(Zs||(Zs={})),function(e){e.Succeeded="succeeded",e.Cancelled="cancelled",e.Errored="errored"}(Js||(Js={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(Qs||(Qs={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Xs||(Xs={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(ed||(ed={})),function(e){e.pill="pill",e.rect="rect"}(td||(td={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled",e.UNRECOGNIZED="unrecognized"}(nd||(nd={})),(id||(id={})).OXXO="oxxo",function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(rd||(rd={}));var sd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class dd{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.paypalRequestSender=n,this.paypalSdkLoader=i}loadPayPalSdk(e,t,n,i){return sd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e),s=r.getLocale();return this.paypalSdk=yield this.paypalSdkLoader.getPayPalSDK(a,o,s,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new vr;return this.paypalSdk}createBuyNowCartOrThrow(e){return sd(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new br}})}createOrder(e,t){return sd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.paypalRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return sd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.paypalRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e,t,n,i){return sd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=r.getCartOrThrow();let a;i||(a=r.getConsignmentsOrThrow()[0]);try{yield this.paypalRequestSender.updateOrder(e,Object.assign(Object.assign({availableShippingOptions:i?[]:null==a?void 0:a.availableShippingOptions,cartId:o.id,selectedShippingOption:i?null:null==a?void 0:a.selectedShippingOption},t?{methodId:t}:{}),n?{orderId:n}:{}))}catch(e){throw new Ie}})}getOrderStatus(e,t){return sd(this,void 0,void 0,function*(){try{const{status:n}=yield this.paypalRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new dr(ar.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===go.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return sd(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{if(t.selectedShippingOption){const n=t.selectedShippingOption.id;return e.id===n}return!1}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e={}){const{color:t,height:n,label:i,shape:r}=e,o={color:t&&ed[t]?t:void 0,height:this.getValidHeight(n),label:i&&Xs[i]?i:void 0,shape:r&&td[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var cd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ud{constructor(e){this.requestSender=e}createOrder(e,t){return cd(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e,t){return cd(this,void 0,void 0,function*(){const n=`/api/storefront/initialization/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.put(n,{headers:r,body:i})).body})}getOrderStatus(e,t){return cd(this,void 0,void 0,function*(){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}const ld=t=>{const{getHost:i}=t.getState();return new dd(n(),t,new ud(e({host:i()})),new ad(le()))};var hd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const pd=class{constructor(e,t){this.paymentIntegrationService=e,this.paypalIntegrationService=t}createPayPalButton(e,t,n,i){const{style:r,fundingSource:o,isHostedCheckoutEnabled:a,isServerSideShippingCallbacksEnabled:s,onClick:d,onCancel:c,onPaymentComplete:u,onError:l}=n;this.onError=l;const h=this.paypalIntegrationService.getPayPalSdkOrThrow();if(!Object.values(h.FUNDING).includes(o))throw new wr('Unable to initialize PayPal button because "fundingSource" argument is not valid funding source.');const p=Object.assign(Object.assign({},!s&&{onShippingAddressChange:t=>this.onShippingAddressChange(t,e),onShippingOptionsChange:t=>this.onShippingOptionsChange(t,e)}),{onApprove:(n,i)=>this.onHostedCheckoutApprove(n,i,t,e,u,s)});return h.Buttons(Object.assign(Object.assign(Object.assign({fundingSource:o,style:this.paypalIntegrationService.getValidButtonStyle(r),createOrder:()=>hd(this,void 0,void 0,function*(){if(i){const e=yield this.paypalIntegrationService.createBuyNowCartOrThrow(i);yield this.paymentIntegrationService.loadCheckout(e.id)}return this.paypalIntegrationService.createOrder(e)}),onApprove:({orderID:e})=>this.paypalIntegrationService.tokenizePayment(t,e)},d?{onClick:d}:{}),c?{onCancel:c}:{}),a&&p))}onHostedCheckoutApprove(e,t,n,i,r,o){return hd(this,void 0,void 0,function*(){if(!e.orderID)throw new dr(ar.MissingOrderId);const a=this.paymentIntegrationService.getState().getCartOrThrow();try{const s=a.lineItems.physicalItems.length>0;if(!o){const e=yield t.order.get(),n=this.paypalIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),s){const t=this.paypalIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}s&&(yield this.paypalIntegrationService.updateOrder(i,void 0,void 0,o)),o&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.paypalIntegrationService.submitPayment(n,e.orderID),r&&"function"==typeof r&&r()}catch(e){this.handleError(e)}})}onShippingAddressChange(e,t){return hd(this,void 0,void 0,function*(){const n=this.paypalIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(n),yield this.paymentIntegrationService.updateShippingAddress(n);const e=this.paypalIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.paypalIntegrationService.updateOrder(t)}catch(e){this.handleError(e)}})}onShippingOptionsChange(e,t){return hd(this,void 0,void 0,function*(){const n=this.paypalIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(n.id),yield this.paypalIntegrationService.updateOrder(t)}catch(e){this.handleError(e)}})}handleError(e){if("function"!=typeof this.onError)throw e;this.onError(e)}};class gd{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalIntegrationService=t,this.paypalButtonCreationService=n}initialize(e){return t=this,n=void 0,r=function*(){var t;const{paypalcommerce:n,containerId:i,methodId:r}=e,o=Boolean(null==n?void 0:n.buyNowInitializeOptions);if(!r)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.paypalcommerce" argument is not provided.');if(o&&!n.currencyCode)throw new wr('Unable to initialize payment because "options.paypalcommerce.currencyCode" argument is not provided.');if(o&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.paypalcommerce.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');o||(yield this.paymentIntegrationService.loadDefaultCheckout());const a=o?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.paypalIntegrationService.loadPayPalSdk(r,a,!1),this.renderButton(i,r,n)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.paypalIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},h=Object.assign(Object.assign({fundingSource:s.FUNDING.PAYPAL,style:this.paypalIntegrationService.getValidButtonStyle(r),isServerSideShippingCallbacksEnabled:u,isHostedCheckoutEnabled:c},i&&l),c&&o&&{onPaymentComplete:()=>o()}),p=this.paypalButtonCreationService.createPayPalButton("paypalcommerce",t,h,i);p.isEligible()?p.render(`#${e}`):a&&"function"==typeof a?a():this.paypalIntegrationService.removeElement(e)}}const md=Ir(e=>{const t=ld(e),n=new pd(e,t);return new gd(e,t,n)},[{id:"paypalcommerce"}]);var yd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class fd{constructor(e,t){this.paymentIntegrationService=e,this.paypalIntegrationService=t}initialize(e){return yd(this,void 0,void 0,function*(){const{paypalcommercecredit:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.paypalcommercecredit" argument is not provided.');if(a&&!o)throw new wr('Unable to initialize payment because "options.paypalcommercecredit.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.paypalcommercecredit.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=this.paymentIntegrationService.getState(),d=a?o:s.getCartOrThrow().currency.code;yield this.paypalIntegrationService.loadPayPalSdk(i,d,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.paypalIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={createOrder:()=>this.paypalIntegrationService.createOrder("paypalcommercecredit"),onApprove:({orderID:e})=>this.paypalIntegrationService.tokenizePayment(t,e)},h={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},p=Object.assign(Object.assign({},!u&&{onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e)}),{onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o,u)}),g=[s.FUNDING.PAYLATER,s.FUNDING.CREDIT];let m=!1;g.forEach(t=>{if(!m){const n=Object.assign(Object.assign(Object.assign({fundingSource:t,style:this.paypalIntegrationService.getValidButtonStyle(r)},l),i&&h),c&&p),o=s.Buttons(n);o.isEligible()?(o.render(`#${e}`),m=!0):a&&"function"==typeof a&&a()}}),m||this.paypalIntegrationService.removeElement(e)}handleClick(e){return yd(this,void 0,void 0,function*(){if(e){const t=yield this.paypalIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i,r){return yd(this,void 0,void 0,function*(){if(!e.orderID)throw new dr(ar.MissingOrderId);const o=this.paymentIntegrationService.getState().getCartOrThrow();try{const a=o.lineItems.physicalItems.length>0;if(!r){const e=yield t.order.get(),n=this.paypalIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),a){const t=this.paypalIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}return a&&(yield this.paypalIntegrationService.updateOrder("paypalcommerce",void 0,void 0,r)),r&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.paypalIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return yd(this,void 0,void 0,function*(){const t=this.paypalIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.paypalIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.paypalIntegrationService.updateOrder("paypalcommerce")}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return yd(this,void 0,void 0,function*(){const t=this.paypalIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.paypalIntegrationService.updateOrder("paypalcommerce")}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const _d=Ir(e=>new fd(e,ld(e)),[{id:"paypalcommercecredit"}]);var Sd,vd,Cd,Id,wd,bd,Ed;!function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(Sd||(Sd={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(vd||(vd={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Cd||(Cd={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Id||(Id={})),function(e){e.pill="pill",e.rect="rect"}(wd||(wd={})),function(e){e.OXXO="oxxo",e.IDEAL="ideal"}(bd||(bd={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Ed||(Ed={}));var Pd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Od{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.paypalCommerceRequestSender=n,this.paypalCommerceScriptLoader=i}loadPayPalSdk(e,t,n,i){return Pd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e);return this.paypalSdk=yield this.paypalCommerceScriptLoader.getPayPalSDK(a,o,r.getLocale(),n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new vr;return this.paypalSdk}createBuyNowCartOrThrow(e){return Pd(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new br}})}createOrder(e,t){return Pd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.paypalCommerceRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return Pd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.paypalCommerceRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e){return Pd(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState(),n=t.getCartOrThrow(),i=t.getConsignmentsOrThrow()[0];try{yield this.paypalCommerceRequestSender.updateOrder({availableShippingOptions:e?[]:i.availableShippingOptions,cartId:n.id,selectedShippingOption:e?null:i.selectedShippingOption})}catch(e){throw new Ie}})}getOrderStatus(e,t){return Pd(this,void 0,void 0,function*(){try{const{status:n}=yield this.paypalCommerceRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new dr(ar.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===go.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return Pd(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:r}=e||{},o={color:t&&Id[t]?t:void 0,height:this.getValidHeight(n),label:i&&Cd[i]?i:void 0,shape:r&&wd[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var Ad=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Td{constructor(e){this.requestSender=e}createOrder(e,t){return Ad(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e){return Ad(this,void 0,void 0,function*(){const t=e,n=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.put("/api/storefront/initialization/paypalcommerce",{headers:n,body:t})).body})}getOrderStatus(){return Ad(this,arguments,void 0,function*(e="paypalcommerce",t){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}var kd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Rd{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return kd(this,void 0,void 0,function*(){const o=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);return this.loadPayPalSDK(o,r)})}loadPayPalSDK(e){return kd(this,arguments,void 0,function*(e,t=!1){if(!this.window.paypal||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.paypal)throw new vr;return this.window.paypal})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!(null==a?void 0:a.clientId))throw new dr(ar.MissingPaymentMethod);const{intent:s,clientId:d,merchantId:c,buyerCountry:u,attributionId:l,isVenmoEnabled:h,isHostedCheckoutEnabled:p,isPayPalCreditAvailable:g,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:y=[],enabledAlternativePaymentMethods:f=[],isGooglePayEnabled:_}=a,S=p||i,v="paypalcommercecreditcards"===r,C=v?["card"]:[],I=g?["credit","paylater"]:[],w=h?["venmo"]:[],b=_?["googlepay"]:[],E=i?["card-fields"]:[],P=[...v?[]:["card"],...g?[]:["credit","paylater"],...h?[]:["venmo"],...y.filter(e=>!f.includes(e))],O=[...C,...I,...w,...f],A=Xa(n);return{options:Object.assign(Object.assign({"client-id":d,"merchant-id":c,"enable-funding":O.length>0?O:void 0,"disable-funding":P.length>0?P:void 0,commit:S,components:["buttons","hosted-fields","payment-fields","legal",...b,...E],currency:t,intent:s},m&&{"buyer-country":u}),A&&{locale:A}),attributes:{"data-partner-attribution-id":l,"data-client-token":o}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var Dd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Md{constructor(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}initialize(e){return Dd(this,void 0,void 0,function*(){const{paypalcommercevenmo:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');if(a&&!o)throw new wr('Unable to initialize payment because "options.paypalcommercevenmo.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.paypalcommercevenmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=a?o:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.paypalCommerceIntegrationService.loadPayPalSdk(i,s,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onEligibilityFailure:o}=n,a=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),s=a.FUNDING.VENMO,d={createOrder:()=>this.paypalCommerceIntegrationService.createOrder("paypalcommercevenmo"),onApprove:({orderID:e})=>this.paypalCommerceIntegrationService.tokenizePayment(t,e)},c={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},u=Object.assign(Object.assign({fundingSource:s,style:this.getValidVenmoButtonStyles(r)},d),i&&c),l=a.Buttons(u);l.isEligible()?l.render(`#${e}`):o&&"function"==typeof o?o():this.paypalCommerceIntegrationService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.paypalCommerceIntegrationService.getValidButtonStyle(e);return t.color===Id.gold?Object.assign(Object.assign({},t),{color:void 0}):t}handleClick(e){return Dd(this,void 0,void 0,function*(){if(e){const t=yield this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}}const Nd=Ir(t=>new Md(t,(t=>{const{getHost:i}=t.getState();return new Od(n(),t,new Td(e({host:i()})),new Rd(le()))})(t)),[{id:"paypalcommercevenmo"}]);var Ld,zd,Ud,Fd,Bd,xd;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Ld||(Ld={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(zd||(zd={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(Ud||(Ud={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Fd||(Fd={})),function(e){e.PILL="pill",e.RECT="rect"}(Bd||(Bd={})),function(e){e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE"}(xd||(xd={}));var qd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class jd{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return qd(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new wr;if(!t.config.merchantId)throw new dr(ar.MissingPaymentMethod);const n=yield this.paypalExpressScriptLoader.loadPaypalSDK(t.config.merchantId);this.renderButton(e,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t){const{containerId:n,methodId:i,paypal:r}=e,{allowCredit:o,clientId:a,onPaymentError:s,shouldProcessPayment:d,style:c}=r,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new dr(ar.MissingPaymentMethod);const l=u.config.merchantId,h=u.config.testMode?"sandbox":"production",p={[h]:a},g=t.FUNDING.CREDIT||"credit",m=o?[g]:[],y=o?[]:[g];return t.Button.render({env:h,client:p,commit:d,funding:{allowed:m,disallowed:y},style:this.getStyle(c),payment:(e,t)=>this.setupPayment(l,t,s),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,d)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:r,shape:o,size:a,tagline:s}=e||{};return{color:t,fundingicons:n,label:i,layout:r,shape:o||Bd.RECT,size:"small"===a?zd.RESPONSIVE:a,tagline:s}}setupPayment(e,t,n){return qd(this,void 0,void 0,function*(){if(!t)throw new lr(sr.CheckoutButtonNotInitialized);try{const n=yield this.paymentIntegrationService.loadDefaultCheckout(),{id:i}=n.getCartOrThrow(),r=n.getHost()||"";return(yield t.request.post(`${r}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:i},{headers:Object.assign({"X-API-INTERNAL":Tr},Dr)})).id}catch(e){throw n&&e instanceof ve&&n(e),e}})}tokenizePayment(e,t,n,i){return qd(this,void 0,void 0,function*(){if(!n)throw new lr(sr.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new dr(ar.MissingPayment);const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),o=yield n.payment.get(e.paymentID);return this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:r.id,action:i?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(o.payer.payer_info)})})}}class Gd{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(){return e=this,t=arguments,i=function*(e=""){const t=Object.assign({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}});if(yield this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t),!this.window.paypal)throw new vr;return this.window.paypal},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}const Vd=Ir(e=>new jd(e,new Gd(le()),n()),[{id:"paypalexpress"}]);var Hd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Wd{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.isMounted=!1}deinitialize(){var e;null===(e=this.checkoutEventsUnsubscribe)||void 0===e||e.call(this),this.isMounted=!1}initCheckoutEventsSubscription(e,t,n,i){this.checkoutEventsUnsubscribe=this.paymentIntegrationService.subscribe(()=>Hd(this,void 0,void 0,function*(){var r;const o=null==i?void 0:i.getElement(Ds.PAYMENT);if(o){try{yield this.updateStripePaymentIntent(e,t)}catch(e){return this.isMounted&&(o.unmount(),this.isMounted=!1),void(e instanceof Error&&(null===(r=n.onError)||void 0===r||r.call(n,e)))}this.isMounted||(yield null==i?void 0:i.fetchUpdates(),this.mountElement(o,n.containerId))}}),e=>{var t;return null===(t=e.getCheckout())||void 0===t?void 0:t.outstandingBalance},e=>{var t;return null===(t=e.getCheckout())||void 0===t?void 0:t.coupons})}mountElement(e,t){document.getElementById(t)&&(e.mount(`#${t}`),this.isMounted=!0)}mapAppearanceVariables(e){return{colorPrimary:e.fieldInnerShadow,colorBackground:e.fieldBackground,colorText:e.labelText,colorDanger:e.fieldErrorText,colorTextSecondary:e.labelText,colorTextPlaceholder:e.fieldPlaceholderText,colorIcon:e.fieldPlaceholderText}}mapInputAppearanceRules(e){return{borderColor:e.fieldBorder,color:e.fieldText,boxShadow:e.fieldInnerShadow}}throwStripeError(e){if("object"==typeof(t=e)&&null!==t&&"type"in t&&(this.throwDisplayableStripeError(e),this.isCancellationError(e)))throw new ro;var t;throw new Va}throwDisplayableStripeError(e){if(m(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}isCancellationError(e){var t;const n=null===(t=null==e?void 0:e.payment_intent.last_payment_error)||void 0===t?void 0:t.message;return!!n&&-1!==n.indexOf("canceled")}throwPaymentConfirmationProceedMessage(){throw new Va("We've received your order and are processing your payment. Once the payment is verified, your order will be completed. We will send you an email when it's completed. Please note, this process may take a few minutes depending on the processing times of your chosen method.")}isPaymentCompleted(e,t){return Hd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(e),{features:r}=n.getStoreConfigOrThrow().checkoutSettings;if(!i.clientToken||!t||!r["PI-626.Block_unnecessary_payment_confirmation_for_StripeUPE"])return!1;const{paymentIntent:o}=yield t.retrievePaymentIntent(i.clientToken);return(null==o?void 0:o.status)===Ms.SUCCEEDED})}mapStripePaymentData(e,t,n=!1){const i=this.paymentIntegrationService.getState().getBillingAddress(),{firstName:r="",lastName:o="",email:a=""}=i||{},s=this.mapStripeAddress(i);if(!e)throw new lr(sr.PaymentNotInitialized);if(!(a&&s&&s.city&&s.country&&r&&o))throw new dr(ar.MissingBillingAddress);return{elements:e,redirect:ks.IF_REQUIRED,confirmParams:Object.assign({payment_method_data:Object.assign(Object.assign({},n?{allow_redisplay:"always"}:{}),{billing_details:{email:a,address:s,name:this.getShopperFullName(i)}})},t&&{return_url:t})}}isAdditionalActionError(e){return z(e,{code:"additional_action_required"})}isSessionExpiredError(e){return z(e,{code:"authorization_expired"})}isRedirectAction(e){const{type:t,data:{redirect_url:n}}=e;return"redirect_to_url"===t&&!!n}isOnPageAdditionalAction(e){const{type:t,data:{token:n}}=e;return"additional_action_requires_payment_method"===t&&!!n}updateStripePaymentIntent(e,t){return Hd(this,void 0,void 0,function*(){const n=yield this.paymentIntegrationService.loadPaymentMethod(e,{params:{method:t}}),{clientToken:i}=n.getPaymentMethodOrThrow(t);i&&this.scriptLoader.updateStripeElements({clientSecret:i})})}getStripeJsVersion(e){return e.useNewStripeJsVersion?Rs.CLOVER:Rs.V3}mapStripeAddress(e){if(e){const{city:t,address1:n,address2:i,countryCode:r,postalCode:o,stateOrProvinceCode:a}=e;return Object.assign({city:t,country:r,postal_code:o,line1:n,line2:i},a?{state:a}:{})}throw new dr(ar.MissingBillingAddress)}getShopperFullName(e){const{firstName:t="",lastName:n=""}=e||{};return`${t} ${n}`.trim()}verifyCheckoutSpamProtection(){return Hd(this,void 0,void 0,function*(){const{shouldExecuteSpamCheck:e}=this.paymentIntegrationService.getState().getCheckoutOrThrow();e&&(yield this.paymentIntegrationService.verifyCheckoutSpamProtection())})}}const Yd={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},Kd={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},$d="embedded-checkout-loading-indicator-rotation";class Zd{constructor(e){this.styles=Object.assign(Object.assign({},Yd),e&&e.styles),this.containerStyles=Object.assign({},e&&e.containerStyles),this.defineAnimation(),this.container=this.buildContainer(),this.indicator=this.buildIndicator(),this.container.appendChild(this.indicator)}show(e){if(e){const t=document.getElementById(e);if(!t)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");t.appendChild(this.container)}this.container.style.visibility="visible",this.container.style.opacity="1"}hide(){const e=()=>{this.container.style.visibility="hidden",this.container.removeEventListener("transitionend",e)};this.container.addEventListener("transitionend",e),this.container.style.opacity="0"}buildContainer(){const e=document.createElement("div");return e.style.display="block",e.style.bottom="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.position="absolute",e.style.right="0",e.style.top="0",e.style.transition="all 250ms ease-out",e.style.opacity="0",this.setStyleAttribute(e,this.containerStyles),e}buildIndicator(){const e=document.createElement("div");return e.style.display="block",e.style.width=`${this.styles.size}px`,e.style.height=`${this.styles.size}px`,e.style.borderRadius=`${this.styles.size}px`,e.style.border="solid 1px",e.style.borderColor=`${this.styles.backgroundColor} ${this.styles.backgroundColor} ${this.styles.color} ${this.styles.color}`,e.style.margin="0 auto",e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top="50%",e.style.transform="translateY(-50%) rotate(0deg)",e.style.transformStyle="preserve-3d",e.style.animation=`${$d} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`,e}setStyleAttribute(e,t){Object.keys(t).forEach(n=>{e.style.setProperty(n,t[n])})}defineAnimation(){var e;if(document.getElementById($d))return;const t=document.createElement("style");t.id=$d,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${$d} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}class Jd{constructor(e){this._decimalPlaces=e}toInteger(e){return Math.round(e*Math.pow(10,this._decimalPlaces))}}const Qd=["AC","AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CV","CW","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MK","ML","MM","MN","MO","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SZ","TA","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","US","UY","UZ","VA","VC","VE","VG","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW","ZZ"];var Xd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ec{constructor(e,t,n,i){this.paymentIntegrationService=e,this.scriptLoader=t,this.stripeIntegrationService=n,this.loadingIndicator=i}initialize(e){return Xd(this,void 0,void 0,function*(){const{stripeocs:t,containerId:n}=e||{};if(!t||!n)throw new lr(sr.PaymentNotInitialized);const{gatewayId:i}=t;if(!i)throw new dr(ar.MissingPaymentMethod);const r=this._getMethodId(i),o=yield this.paymentIntegrationService.loadPaymentMethod(i,{params:{method:r}}),a=o.getPaymentMethodOrThrow(r,i),{loadingContainerId:s,buttonHeight:d,onComplete:c}=t;if(this._loadingIndicatorContainer=s,this._onComplete=c,!function(e){return"object"==typeof e&&null!==e&&"initializationData"in e&&void 0!==e.initializationData&&null!==e.initializationData&&"object"==typeof e.initializationData&&"stripePublishableKey"in e.initializationData&&"stripeConnectedAccount"in e.initializationData&&"shopperLanguage"in e.initializationData&&void 0!==e.initializationData.stripePublishableKey&&void 0!==e.initializationData.stripeConnectedAccount&&void 0!==e.initializationData.shopperLanguage}(a))throw new dr(ar.MissingPaymentMethod);const{initializationData:u}=a,{captureMethod:l}=u,h=this.stripeIntegrationService.getStripeJsVersion(u);this._captureMethod=l,this._stripeClient=yield this.scriptLoader.getStripeClient(u,o.getCartLocale(),h),yield this.paymentIntegrationService.loadDefaultCheckout(),yield this._mountExpressCheckoutElement(n,this._stripeClient,d),this._initializeEvents(r)})}signIn(){return Promise.resolve()}signOut(){return Promise.resolve()}executePaymentMethodCheckout(){return Promise.resolve()}deinitialize(){return Promise.resolve()}_mountExpressCheckoutElement(e,t){return Xd(this,arguments,void 0,function*(e,t,n=40){const i=this._shouldRequireShippingAddress(),r=Object.assign(Object.assign(Object.assign({shippingAddressRequired:i},i?{allowedShippingCountries:yield this._getAvailableCountries()}:{}),i?{shippingRates:[{id:"_",amount:0,displayName:"Pending rates"}]}:{}),{billingAddressRequired:!0,emailRequired:!0,phoneNumberRequired:!0,paymentMethods:{link:ks.AUTO,applePay:ks.NEVER,googlePay:ks.NEVER,amazonPay:ks.NEVER,paypal:ks.NEVER,klarna:ks.NEVER},buttonHeight:n}),{cartAmount:o=1}=this.paymentIntegrationService.getState().getCart()||{},a=Object.assign({mode:"payment",amount:this._toCents(o),currency:this._getCurrency()},this._captureMethod?{captureMethod:this._captureMethod}:{});this._stripeElements=t.elements(a),this._linkV2Element=this._stripeElements.create(Ds.EXPRESS_CHECKOUT,r),this._linkV2Element.mount(`#${e}`)})}_initializeEvents(e){this._linkV2Element&&(this._shouldRequireShippingAddress()&&(this._linkV2Element.on(Ns.SHIPPING_ADDRESS_CHANGE,e=>Xd(this,void 0,void 0,function*(){return this._onShippingAddressChange(e)})),this._linkV2Element.on(Ns.SHIPPING_RATE_CHANGE,e=>Xd(this,void 0,void 0,function*(){return this._onShippingRateChange(e)}))),this._linkV2Element.on(Ns.CONFIRM,t=>Xd(this,void 0,void 0,function*(){return this._onConfirm(t,e)})),this._linkV2Element.on(Ns.CANCEL,this._onCancel))}_onShippingAddressChange(e){return Xd(this,void 0,void 0,function*(){if(!("address"in e))return;const t=e.address,n={firstName:"",lastName:"",phone:"",company:"",address1:"",address2:"",city:(null==t?void 0:t.city)||"",countryCode:(null==t?void 0:t.country)||"",postalCode:(null==t?void 0:t.postal_code)||"",stateOrProvince:(null==t?void 0:t.state)||"",stateOrProvinceCode:(null==t?void 0:t.state)||"",customFields:[]};yield this.paymentIntegrationService.updateShippingAddress(n);const i=yield this._getAvailableShippingOptions();yield this._updateDisplayedPrice(),(null==i?void 0:i.length)?e.resolve({shippingRates:i}):e.reject()})}_onCancel(){throw new ro}_onShippingRateChange(e){return Xd(this,void 0,void 0,function*(){if("shippingRate"in e){const{shippingRate:t}=e;yield this._handleShippingOptionChange(null==t?void 0:t.id),yield this._updateDisplayedPrice(),e.resolve({})}})}_onConfirm(e,t){return Xd(this,void 0,void 0,function*(){if("billingDetails"in e&&"shippingAddress"in e&&this._stripeClient&&this._stripeElements){yield this.stripeIntegrationService.verifyCheckoutSpamProtection(),yield this._updateShippingAndBillingAddress(e),yield this.paymentIntegrationService.submitOrder();const n=this._getPaymentPayload(t);try{yield this.paymentIntegrationService.submitPayment(n)}catch(e){yield this._processAdditionalAction(e,t)}}return Promise.resolve()})}_updateShippingAndBillingAddress(e){return Xd(this,void 0,void 0,function*(){var t,n,i,r,o,a,s,d;const c=this._shouldRequireShippingAddress(),u=(null===(n=null===(t=e.shippingAddress)||void 0===t?void 0:t.name)||void 0===n?void 0:n.split(" ")[0])||(null===(r=null===(i=e.billingDetails)||void 0===i?void 0:i.name)||void 0===r?void 0:r.split(" ")[0])||"",l=(null===(a=null===(o=e.shippingAddress)||void 0===o?void 0:o.name)||void 0===a?void 0:a.split(" ")[1])||(null===(d=null===(s=e.billingDetails)||void 0===s?void 0:s.name)||void 0===d?void 0:d.split(" ")[1])||"";if(c){const t=this._mapShippingAddress(e.shippingAddress,e.billingDetails,u,l);yield this.paymentIntegrationService.updateShippingAddress(t)}const h=this._mapBillingAddress(e.shippingAddress,e.billingDetails,u,l);yield this.paymentIntegrationService.updateBillingAddress(h)})}_mapShippingAddress(e,t,n,i){var r,o,a,s,d,c,u;return{firstName:n,lastName:i,phone:(null==t?void 0:t.phone)||"",company:"",address1:(null===(r=null==e?void 0:e.address)||void 0===r?void 0:r.line1)||"",address2:(null===(o=null==e?void 0:e.address)||void 0===o?void 0:o.line2)||"",city:(null===(a=null==e?void 0:e.address)||void 0===a?void 0:a.city)||"",countryCode:(null===(s=null==e?void 0:e.address)||void 0===s?void 0:s.country)||"",postalCode:(null===(d=null==e?void 0:e.address)||void 0===d?void 0:d.postal_code)||"",stateOrProvince:(null===(c=null==e?void 0:e.address)||void 0===c?void 0:c.state)||"",stateOrProvinceCode:(null===(u=null==e?void 0:e.address)||void 0===u?void 0:u.state)||"",customFields:[]}}_mapBillingAddress(e,t,n,i){var r,o,a,s,d,c;return{email:(null==t?void 0:t.email)||"",firstName:n,lastName:i,phone:(null==t?void 0:t.phone)||"",company:"",address1:(null===(r=null==t?void 0:t.address)||void 0===r?void 0:r.line1)||"",address2:"",city:(null===(o=null==t?void 0:t.address)||void 0===o?void 0:o.city)||"",countryCode:(null===(a=null==t?void 0:t.address)||void 0===a?void 0:a.country)||"",postalCode:(null===(s=null==t?void 0:t.address)||void 0===s?void 0:s.postal_code)||"",stateOrProvince:(null===(d=null==t?void 0:t.address)||void 0===d?void 0:d.state)||"",stateOrProvinceCode:(null===(c=null==e?void 0:e.address)||void 0===c?void 0:c.state)||"",customFields:[]}}_processAdditionalAction(e,t){return Xd(this,void 0,void 0,function*(){if(!ms(e)||!this.stripeIntegrationService.isAdditionalActionError(e.body.errors))throw e;if(!this._stripeClient||!this._stripeElements)throw new lr(sr.PaymentNotInitialized);const{data:n}=e.body.additional_action_required,{token:i}=n,{paymentIntent:r}=yield this._confirmStripePaymentOrThrow(n,t),o=this._getPaymentPayload(t,(null==r?void 0:r.id)||i);try{this._toggleLoadingIndicator(!0),yield this.paymentIntegrationService.submitPayment(o),yield this._completeCheckoutFlow()}catch(e){this.stripeIntegrationService.throwPaymentConfirmationProceedMessage()}finally{this._toggleLoadingIndicator(!1)}})}_confirmStripePaymentOrThrow(e,t){return Xd(this,void 0,void 0,function*(){var n,i,r;const{token:o,redirect_url:a}=e,s=this.stripeIntegrationService.mapStripePaymentData(this._stripeElements,a);let d;try{const e=(yield this.stripeIntegrationService.isPaymentCompleted(t,this._stripeClient))?yield null===(r=this._stripeClient)||void 0===r?void 0:r.retrievePaymentIntent(o||""):yield null===(n=this._stripeClient)||void 0===n?void 0:n.confirmPayment({elements:s.elements,clientSecret:o,redirect:ks.IF_REQUIRED,confirmParams:{return_url:null===(i=s.confirmParams)||void 0===i?void 0:i.return_url}});if(d=null==e?void 0:e.error,d||!(null==e?void 0:e.paymentIntent))throw new Va;return e}catch(e){return this.stripeIntegrationService.throwStripeError(d)}})}_completeCheckoutFlow(){return Xd(this,void 0,void 0,function*(){return"function"==typeof this._onComplete?this._onComplete():(window.location.replace("/checkout/order-confirmation"),Promise.resolve())})}_getPaymentPayload(e,t){var n;const i=(null===(n=this.paymentIntegrationService.getState().getCart())||void 0===n?void 0:n.id)||"";return{methodId:e,paymentData:{formattedPayload:Object.assign(Object.assign({cart_id:i},t?{credit_card_token:{token:t}}:{}),{confirm:!1,method:Ts.Link})}}}_shouldRequireShippingAddress(){const{getCart:e}=this.paymentIntegrationService.getState(),{lineItems:t}=e()||{};return!!(null==t?void 0:t.physicalItems.length)}_updateDisplayedPrice(){return Xd(this,void 0,void 0,function*(){this._stripeElements&&this._stripeElements.update({currency:this._getCurrency(),mode:"payment",amount:yield this._getTotalPrice()})})}_getCurrency(){var e;if(!this._currencyCode){const t=null===(e=this.paymentIntegrationService.getState().getCart())||void 0===e?void 0:e.currency;t&&(this._currencyCode=t.code.toLowerCase())}return this._currencyCode}_getTotalPrice(){return Xd(this,void 0,void 0,function*(){var e;yield this.paymentIntegrationService.loadCheckout();const{getCheckoutOrThrow:t,getCart:n}=this.paymentIntegrationService.getState(),{decimalPlaces:i}=(null===(e=n())||void 0===e?void 0:e.currency)||{},r=L(t().outstandingBalance,i).toFixed(i);return this._toCents(+r)})}_getAvailableCountries(){return Xd(this,void 0,void 0,function*(){var e;return((null===(e=(yield this.paymentIntegrationService.loadShippingCountries()).getShippingCountries())||void 0===e?void 0:e.map(e=>e.code))||[]).filter(e=>Qd.includes(e))})}_getAvailableShippingOptions(){return Xd(this,void 0,void 0,function*(){var e,t,n;const i=this.paymentIntegrationService.getState().getConsignments();if(!(null==i?void 0:i[0]))return;const r=i[0],o=(r.availableShippingOptions||[]).map(this._getStripeShippingOption.bind(this)),a=null===(e=r.availableShippingOptions)||void 0===e?void 0:e.find(e=>e.isRecommended),s=null===(t=r.selectedShippingOption)||void 0===t?void 0:t.id,d=null==a?void 0:a.id;return s?o.sort(e=>e.id===s?-1:0):d?(o.sort(e=>e.id===d?-1:0),yield this._handleShippingOptionChange(d)):yield this._handleShippingOptionChange(null===(n=o[0])||void 0===n?void 0:n.id),o.slice(0,9)})}_getStripeShippingOption({id:e,cost:t,description:n}){return{id:e,displayName:n,amount:this._toCents(t)}}_handleShippingOptionChange(e){return Xd(this,void 0,void 0,function*(){if(e&&"shipping_option_unselected"!==e)return this.paymentIntegrationService.selectShippingOption(e)})}_getAmountTransformer(){if(this._amountTransformer)return this._amountTransformer;const{getCart:e}=this.paymentIntegrationService.getState(),{currency:t}=e()||{};return t?new Jd(t.decimalPlaces):void 0}_toCents(e){const t=Math.round(100*e),n=this._getAmountTransformer();return n?n.toInteger(e):t}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this.loadingIndicator.show(this._loadingIndicatorContainer):this.loadingIndicator.hide()}_getMethodId(e){const{initializationData:{checkoutSessionEnabled:t}={}}=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e);return t?Ts.CHECKOUT_SESSION:Ts.OCS}}const tc=Ir(e=>{const t=new Us(le()),n=new Zd({containerStyles:Kd});return new ec(e,t,new Wd(e,t),n)},[{id:"stripeocs"}]);var nc;function ic(e,t,n){const i=new WeakMap;function r(e){return(...n)=>{const r=n[n.length-1],{useCache:o}=(a=r)&&"boolean"==typeof a.useCache?r:{useCache:!1};var a;if(!o)return e.call(this,...n);const s=i.get(this)||{};var d;return i.get(this)||i.set(this,s),s[t]||(s[t]=(d=e,ae(function(...e){const t=d.call(this,...e);return t instanceof j?Y(t).pipe(ie()):"function"==typeof t?ae(e=>Y(t(e)).pipe(ie()),{isEqual:_}):t},{isEqual:_}))),s[t].call(this,...n)}}return{get(){if("function"!=typeof n.value)throw new Error("Decorator should be used in functions");const e=r.call(this,n.value);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e}}}!function(e){e.Standard="standard",e.Invoice="invoice"}(nc||(nc={}));var rc=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const oc=e=>!!e;class ac{constructor(e,t){this._requestSender=e,this._b2bCompanyPaymentMethodRequestSender=t}loadPaymentMethodsById(e,t){return n=>new j(i=>{var r;const a=null===(r=n.getState().cart.getCart())||void 0===r?void 0:r.id,s=a?Object.assign(Object.assign({},null==t?void 0:t.params),{cartId:a}):Object.assign({},null==t?void 0:t.params);i.next(o(En.LoadPaymentMethodsRequested)),Promise.all(e.map(e=>rc(this,void 0,void 0,function*(){try{return(yield this._requestSender.loadPaymentMethod(e,Object.assign(Object.assign({},t),{params:s}))).body}catch(e){return}}))).then(e=>{const t=e.filter(oc);i.next(o(En.LoadPaymentMethodsSucceeded,t)),i.complete()}).catch(e=>{i.next(o(En.LoadPaymentMethodsFailed,e)),i.complete()})})}loadPaymentMethods(e){return t=>j.create(n=>{const i=t.getState(),r=i.cart.getCartOrThrow();n.next(o(En.LoadPaymentMethodsRequested)),this._requestSender.loadPaymentMethods(Object.assign(Object.assign({},e),{params:Object.assign(Object.assign({},null==e?void 0:e.params),{cartId:r.id})})).then(t=>rc(this,void 0,void 0,function*(){const r={deviceSessionId:t.headers["x-device-session-id"],sessionHash:t.headers["x-session-hash"]};let a=t.body;this._shouldFilterForB2b(i)&&(a=yield this._applyB2bFilter(a,i,e)),n.next(o(En.LoadPaymentMethodsSucceeded,a,r)),n.complete()})).catch(e=>{n.error(s(En.LoadPaymentMethodsFailed,e))})})}loadPaymentMethod(e,t){return n=>j.create(i=>{var r;const a=null===(r=n.getState().cart.getCart())||void 0===r?void 0:r.id,d=a?Object.assign(Object.assign({},null==t?void 0:t.params),{cartId:a}):Object.assign({},null==t?void 0:t.params);i.next(o(En.LoadPaymentMethodRequested,void 0,{methodId:e})),this._requestSender.loadPaymentMethod(e,Object.assign(Object.assign({},t),{params:d})).then(t=>{i.next(o(En.LoadPaymentMethodSucceeded,t.body,{methodId:e})),i.complete()}).catch(t=>{i.error(s(En.LoadPaymentMethodFailed,t,{methodId:e}))})})}_shouldFilterForB2b(e){var t,n;return!!(null===(n=null===(t=e.config.getStoreConfigOrThrow().checkoutSettings)||void 0===t?void 0:t.capabilities)||void 0===n?void 0:n.payment.b2bPaymentMethodFilterType)}_applyB2bFilter(e,t,n){return rc(this,void 0,void 0,function*(){var i,r,o,a,s;const d=t.config.getStoreConfigOrThrow(),c=t.customer.getCustomerOrThrow(),u=t.cart.getCartOrThrow(),l=t.b2bToken.getToken(),h=(p=null!==(o=null===(r=null===(i=t.config.getStoreConfig())||void 0===i?void 0:i.b2bApiSettings)||void 0===r?void 0:r.baseUrl)&&void 0!==o?o:"",function(){if("undefined"==typeof window||!window.location)return!1;try{return!!new URLSearchParams(window.location.search).has("enableB2bDevMode")&&(console.log("B2B Dev Mode Enabled"),!0)}catch(e){return!1}}()?"https://api-b2b.bigcommerce.com":p);var p;if(c.isGuest||!l||!h||!u.companyId)throw new Zi($i.MissingCheckoutConfig);return(null===(s=null===(a=d.checkoutSettings)||void 0===a?void 0:a.capabilities)||void 0===s?void 0:s.payment.b2bPaymentMethodFilterType)===nc.Invoice?this._applyB2bInvoiceFilter(e,h,l,n):this._applyB2bCompanyFilter(e,u.companyId,l,h,n)})}_applyB2bCompanyFilter(e,t,n,i,r){return rc(this,void 0,void 0,function*(){const{body:o}=yield this._b2bCompanyPaymentMethodRequestSender.getB2BCompanyPaymentMethods(t,n,i,r);return function(e,t){const n=new Set(t.data.filter(e=>"1"===e.isEnabled).map(e=>e.code));return e.filter(e=>n.has(e.id))}(e,o)})}_applyB2bInvoiceFilter(e,t,n,i){return rc(this,void 0,void 0,function*(){const{body:r}=yield this._b2bCompanyPaymentMethodRequestSender.getB2BInvoiceAllowedPaymentMethods(t,n,i);return e.filter(e=>new Set(r.data.allowedMethods).has(e.id))})}}var sc;(function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)})([ic],ac.prototype,"loadPaymentMethod",null),function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(sc||(sc={}));const dc=sc,cc="This API endpoint is for internal use only and may change in the future",uc={"X-Checkout-SDK-Version":"1.934.2"};class lc{constructor(e){this._requestSender=e}loadPaymentMethods({timeout:e,params:t}={}){return this._requestSender.get("/api/storefront/payments",{timeout:e,headers:Object.assign({Accept:dc.JsonV1,"X-API-INTERNAL":cc},uc),params:t})}loadPaymentMethod(e,{timeout:t,params:n}={}){const i=`/api/storefront/payments/${e}`;return this._requestSender.get(i,{timeout:t,headers:Object.assign({Accept:dc.JsonV1,"X-API-INTERNAL":cc},uc),params:n})}}var hc=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class pc{constructor(e){this._requestSender=e}getB2BCompanyPaymentMethods(e,t,n,i){return hc(this,void 0,void 0,function*(){return this._requestSender.get(`${n}/api/v2/companies/${e}/payments`,{timeout:null==i?void 0:i.timeout,credentials:!1,headers:{authToken:t,Authorization:`Bearer ${t}`}})})}getB2BInvoiceAllowedPaymentMethods(e,t,n){return hc(this,void 0,void 0,function*(){return this._requestSender.get(`${e}/api/v1/ip/storefront/payments/bigcommerce/allowed-methods`,{timeout:null==n?void 0:n.timeout,credentials:!1,headers:{authToken:t,Authorization:`Bearer ${t}`}})})}}function gc(e,t,n){return(i=t)&&i.type&&i.error?V(Z(t),J(s(e,t.payload,n))):J(s(e,t,n));var i}class mc extends be{constructor(e){super(e||"Unable to continue as a guest because the customer is already signed in."),this.name="UnableToContinueAsGuestError",this.type="unable_to_continue_as_guest"}}class yc{constructor(e,t){this._requestSender=e,this._subscriptionActionCreator=t}continueAsGuest(e,t){return n=>{const i=n.getState(),r=i.checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);const a=i.customer.getCustomer();if(a&&!a.isGuest)throw new mc;const s=i.billingAddress.getBillingAddress();let d;if(s){const{country:t}=s,n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(s,["country"]);d=Object.assign(Object.assign({},n),e)}else d=e;const c=!f(s);return $(V(Z(o(Ye.ContinueAsGuestRequested)),H(()=>{return e=this,n=void 0,a=function*(){const{body:e}=yield this._createOrUpdateBillingAddress(r.id,d,c,t);return o(Ye.ContinueAsGuestSucceeded,e)},new((i=void 0)||(i=Promise))(function(t,r){function o(e){try{d(a.next(e))}catch(e){r(e)}}function s(e){try{d(a.throw(e))}catch(e){r(e)}}function d(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(e){e(n)})).then(o,s)}d((a=a.apply(e,n||[])).next())});var e,n,i,a})).pipe(Q(e=>gc(Ye.ContinueAsGuestFailed,e))),this._updateCustomerConsent(e,t))}}updateAddress(e,t){return n=>j.create(i=>{const r=n.getState(),a=r.checkout.getCheckout();if(!a)throw new Zi($i.MissingCheckout);i.next(o(Ye.UpdateBillingAddressRequested));const d=r.billingAddress.getBillingAddress(),c=!f(d),u=Object.assign(Object.assign({},e),{email:void 0===e.email&&d?d.email:e.email});d&&d.id&&(u.id=d.id),this._createOrUpdateBillingAddress(a.id,u,c,t).then(({body:e})=>{i.next(o(Ye.UpdateBillingAddressSucceeded,e)),i.complete()}).catch(e=>{i.error(s(Ye.UpdateBillingAddressFailed,e))})})}_updateCustomerConsent({email:e,acceptsAbandonedCartEmails:t,acceptsMarketingNewsletter:n},i){return null==t&&null==n?W():this._subscriptionActionCreator.updateSubscriptions({email:e,acceptsMarketingNewsletter:n||!1,acceptsAbandonedCartEmails:t||!1},i)}_createOrUpdateBillingAddress(e,t,n,i){return n?this._requestSender.updateAddress(e,t,i):this._requestSender.createAddress(e,t,i)}}class fc extends be{constructor(e){super(e||"Your checkout could not be processed because your cart is empty. Please add items to your cart and try again."),this.name="EmptyCartError",this.type="empty_cart"}}const _c={include:["cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","promotions.banners"].join(",")};class Sc{constructor(e){this._requestSender=e}createAddress(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/billing-address`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(i,{body:t,params:_c,headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}updateAddress(e,t,{timeout:n}={}){const{id:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["id"]),o=`/api/storefront/checkouts/${e}/billing-address/${i}`,a=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.put(o,{params:_c,body:r,headers:a,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}}class vc{constructor(e){this._requestSender=e}createBuyNowCart(e,{timeout:t}={}){const n=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post("/api/storefront/carts",{body:e,headers:n,timeout:t})}}class Cc{constructor(e,t,n){this._checkoutRequestSender=e,this._configActionCreator=t,this._formFieldsActionCreator=n}loadCheckout(e,t){return()=>V(Z(o(Ve.LoadCheckoutRequested)),$(this._configActionCreator.loadConfig({useCache:!0,timeout:null==t?void 0:t.timeout,params:{checkoutId:e}}),this._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==t?void 0:t.timeout})),H(()=>this._checkoutRequestSender.loadCheckout(e,t).then(({body:e})=>o(Ve.LoadCheckoutSucceeded,this._transformCustomerAddresses(e))))).pipe(Q(e=>gc(Ve.LoadCheckoutFailed,e)))}loadDefaultCheckout(e){return t=>V(Z(o(Ve.LoadCheckoutRequested)),$(this._configActionCreator.loadConfig({useCache:!0,timeout:null==e?void 0:e.timeout}),this._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==e?void 0:e.timeout})),H(()=>{return n=this,i=void 0,a=function*(){const n=t.getState().config.getContextConfig();if(!n||!n.checkoutId)throw new Zi($i.MissingCheckoutConfig);const{body:i}=yield this._checkoutRequestSender.loadCheckout(n.checkoutId,e);return o(Ve.LoadCheckoutSucceeded,this._transformCustomerAddresses(i))},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>gc(Ve.LoadCheckoutFailed,e)))}updateCheckout(e,t){return n=>new j(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);i.next(o(Ve.UpdateCheckoutRequested)),this._checkoutRequestSender.updateCheckout(r.id,e,t).then(({body:e})=>{i.next(o(Ve.UpdateCheckoutSucceeded,e)),i.complete()}).catch(e=>{i.error(s(Ve.UpdateCheckoutFailed,e))})})}deleteCheckout(e){return t=>new j(n=>{const i=t.getState().checkout.getCheckout();if(!i)throw new Zi($i.MissingCheckout);n.next(o(Ve.DeleteCheckoutRequested)),this._checkoutRequestSender.deleteCheckout(i.id,e).then(()=>{n.next(o(Ve.DeleteCheckoutSucceeded)),n.complete()}).catch(e=>{n.error(s(Ve.DeleteCheckoutFailed,e))})})}loadCurrentCheckout(e){return t=>{const n=t.getState().checkout.getCheckout();if(!n)throw new Zi($i.MissingCheckout);return this.loadCheckout(n.id,e)(t)}}hydrateInitialState(e){return{type:He.HydrateInitialState,payload:e}}_transformCustomerAddresses(e){return Object.assign(Object.assign({},e),{customer:Object.assign(Object.assign({},e.customer),{addresses:e.customer.addresses.map(e=>Object.assign(Object.assign({},e),{shouldSaveAddress:!1}))})})}}function Ic(e){return F(e).join(",")}function wc(e,t=[]){return Array.isArray(t)?Ic([...e,...t]):function(e,t){const n=b(M(t,e=>!e)),i=b(u(t));return Ic([...c(e,n),...i])}(e,t)}const bc=["cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","customer.customerGroup","payments","promotions.banners"];class Ec extends Pe{constructor(e){super(e,{message:e.body.title}),this.name="CheckoutNotAvailableError",this.type="checkout_not_available"}}class Pc{constructor(e){this._requestSender=e}loadCheckout(e,{params:{include:t}={},timeout:n}={}){const i=`/api/storefront/checkout/${e}`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.get(i,{params:{include:wc(bc,t)},headers:r,timeout:n}).catch(e=>{if(e.status>=400&&e.status<500)throw new Ec(e);throw e})}updateCheckout(e,t,{params:{include:n}={},timeout:i}={}){const r=`/api/storefront/checkout/${e}`,o=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.put(r,{params:{include:wc(bc,n)},body:t,headers:o,timeout:i}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}deleteCheckout(e,{timeout:t}={}){const n=`/api/storefront/carts/${e}`,i=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.delete(n,{headers:i,timeout:t})}}class Oc{isEqual(e,t){return _(this._normalize(e),this._normalize(t))}_normalize(e){return{cartAmount:e.cartAmount,currency:e.currency,id:e.id,lineItems:{digitalItems:e.lineItems.digitalItems.slice().sort((e,t)=>`${e.productId}${e.variantId}`.localeCompare(`${t.productId}${t.variantId}`)).map(e=>({extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId})),giftCertificates:e.lineItems.giftCertificates.slice().sort((e,t)=>`${e.id}`.localeCompare(`${t.id}`)).map(e=>({amount:e.amount,recipient:e.recipient})),physicalItems:e.lineItems.physicalItems.slice().sort((e,t)=>`${e.productId}${e.variantId}`.localeCompare(`${t.productId}${t.variantId}`)).map(e=>({extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId,giftWrapping:e.giftWrapping}))}}}}class Ac extends be{constructor(e,t){super("An update to your shopping cart has been detected and your available shipping costs have been updated."),this.name="CartChangedError",this.type="cart_changed",this.data={previous:e,updated:t}}}class Tc{constructor(e){this._checkoutRequestSender=e}validate(e,t){if(!e)throw new Zi($i.MissingCheckout);return this._checkoutRequestSender.loadCheckout(e.id,t).then(t=>{const n=new Oc;if(!(e.outstandingBalance===t.body.outstandingBalance&&this._compareCoupons(e.coupons,t.body.coupons)&&this._compareGiftCertificates(e.giftCertificates,t.body.giftCertificates)&&n.isEqual(e.cart,t.body.cart)))throw new Ac(this._getComparableCheckout(e),this._getComparableCheckout(t.body))})}_compareCoupons(e,t){return _(P(e,"code"),P(t,"code"))}_compareGiftCertificates(e,t){return _(P(e,"code"),P(t,"code"))}_getComparableCheckout(e){const{cart:t,coupons:n,giftCertificates:i,outstandingBalance:r}=e;return{cart:{cartAmount:t.cartAmount,currency:t.currency,lineItems:t.lineItems},coupons:n,giftCertificates:i,outstandingBalance:r}}}var kc;class Rc{constructor(e){this._configRequestSender=e}loadConfig(e){return j.create(t=>{t.next(o(vt.LoadConfigRequested)),this._configRequestSender.loadConfig(e).then(e=>{t.next(o(vt.LoadConfigSucceeded,e.body)),t.complete()}).catch(e=>{t.error(s(vt.LoadConfigFailed,e))})})}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([ic],Rc.prototype,"loadConfig",null);class Dc{constructor(e){this._requestSender=e}loadConfig({timeout:e,params:t}={}){return this._requestSender.get("/api/storefront/checkout-settings",{timeout:e,headers:Object.assign({Accept:dc.JsonV1,"X-API-INTERNAL":cc},uc),params:t}).catch(e=>{if(e.status>=400&&e.status<500)throw new Ec(e);throw e})}}class Mc{constructor(e){this._couponRequestSender=e}applyCoupon(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);i.next(o(it.ApplyCouponRequested)),this._couponRequestSender.applyCoupon(r.id,e,t).then(({body:e})=>{i.next(o(it.ApplyCouponSucceeded,e)),i.complete()}).catch(e=>{i.error(s(it.ApplyCouponFailed,e))})})}removeCoupon(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);i.next(o(it.RemoveCouponRequested)),this._couponRequestSender.removeCoupon(r.id,e,t).then(({body:e})=>{i.next(o(it.RemoveCouponSucceeded,e)),i.complete()}).catch(e=>{i.error(s(it.RemoveCouponFailed,e))})})}}!function(e){e.AvailableShippingOptions="consignments.availableShippingOptions",e.PhysicalItemsCategoryNames="cart.lineItems.physicalItems.categoryNames",e.DigitalItemsCategoryNames="cart.lineItems.digitalItems.categoryNames"}(kc||(kc={}));class Nc{constructor(e){this._requestSender=e}applyCoupon(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/coupons`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(i,{headers:r,timeout:n,params:{include:Ic([...bc,kc.AvailableShippingOptions])},body:{couponCode:t}}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}removeCoupon(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/coupons/${t}`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.delete(i,{headers:r,timeout:n,params:{include:Ic([...bc,kc.AvailableShippingOptions])}}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}}function Lc(e){const t=e;return"object"==typeof t&&"object"==typeof t.payload&&"string"==typeof t.payload.token}class zc{constructor(e,t,n){this._customerRequestSender=e,this._checkoutActionCreator=t,this._spamProtectionActionCreator=n}createCustomer(e,t){return n=>{const i=n.getState().config.getStoreConfigOrThrow(),{isStorefrontSpamProtectionEnabled:r}=i.checkoutSettings,a=i=>Y(this._customerRequestSender.createAccount(Object.assign(Object.assign({},e),{token:i}),t)).pipe(re(()=>V(this._checkoutActionCreator.loadCurrentCheckout(t)(n),Z(o(Ut.CreateCustomerSucceeded)))));return V(Z(o(Ut.CreateCustomerRequested)),r?Y(this._spamProtectionActionCreator.execute()(n)).pipe(re(e=>{var t;return Lc(e)?V(Z(e),a(null===(t=e.payload)||void 0===t?void 0:t.token)):Z(e)})):a()).pipe(Q(e=>gc(Ut.CreateCustomerFailed,e)))}}createAddress(e,t){return V(Z(o(Ut.CreateCustomerAddressRequested)),H(()=>{return n=this,i=void 0,a=function*(){const{body:n}=yield this._customerRequestSender.createAddress(e,t);return o(Ut.CreateCustomerAddressSucceeded,n)},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>gc(Ut.CreateCustomerAddressFailed,e)))}signInCustomer(e,t){return n=>{const i=n.getState().checkout.getCheckoutOrThrow(),r=i.cart.source===go.BuyNow?i.id:void 0;return V(Z(o(Ut.SignInCustomerRequested)),Y(this._customerRequestSender.signInCustomer(Object.assign(Object.assign({},e),{cartId:r}),t)).pipe(re(({body:e})=>e.data.persistentCartRetrievalInformation?V(this._checkoutActionCreator.loadCheckout(e.data.persistentCartRetrievalInformation.id,t)(n),Z(o(Ut.SignInCustomerSucceeded,e.data))):V(this._checkoutActionCreator.loadCurrentCheckout(t)(n),Z(o(Ut.SignInCustomerSucceeded,e.data)))))).pipe(Q(e=>gc(Ut.SignInCustomerFailed,e)))}}signOutCustomer(e){return t=>{const n=t.getState().checkout.getCheckoutOrThrow(),i=n.cart.source===go.BuyNow?n.id:void 0;return V(Z(o(Ut.SignOutCustomerRequested)),Y(this._customerRequestSender.signOutCustomer(e,i)).pipe(re(({body:n})=>V(this._checkoutActionCreator.loadCurrentCheckout(e)(t),Z(o(Ut.SignOutCustomerSucceeded,n.data)))))).pipe(Q(e=>gc(Ut.SignOutCustomerFailed,e)))}}}class Uc{constructor(e){this._requestSender=e}createAccount(e,{timeout:t}={}){return this._requestSender.post("/api/storefront/customer",{timeout:t,headers:uc,body:e})}createAddress(e,{timeout:t}={}){return this._requestSender.post("/api/storefront/customer-address",{timeout:t,headers:uc,body:e})}signInCustomer(e,{timeout:t}={}){return this._requestSender.post("/internalapi/v1/checkout/customer",{timeout:t,headers:uc,body:e})}signOutCustomer({timeout:e}={},t){return this._requestSender.delete("/internalapi/v1/checkout/customer",Object.assign({timeout:e,headers:uc},t&&{body:{cartId:t}}))}}class Fc{constructor(e){this._formFieldsRequestSender=e}loadFormFields(e){return V(Z(o(tn.LoadFormFieldsRequested)),H(()=>{return t=this,n=void 0,r=function*(){const{body:t}=yield this._formFieldsRequestSender.loadFields(e);return o(tn.LoadFormFieldsSucceeded,t)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r})).pipe(Q(e=>gc(tn.LoadFormFieldsFailed,e)))}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([ic],Fc.prototype,"loadFormFields",null);class Bc{constructor(e){this._requestSender=e}loadFields({timeout:e}={}){return this._requestSender.get("/api/storefront/form-fields",{timeout:e,headers:Object.assign({Accept:dc.JsonV1,"X-API-INTERNAL":cc},uc)})}}class xc extends be{constructor(e){super(e||"Unable to proceed because the required element is unexpectedly detached from the page."),this.name="UnexpectedDetachmentError",this.type="unexpected_detachment"}}class qc{constructor(e){this._mutationObserver=e}ensurePresence(e,t){return n=this,i=void 0,o=function*(){const n=new Ia(t),i=this._mutationObserver.create(t=>{t.forEach(t=>{0!==Array.from(t.removedNodes).filter(t=>e.some(e=>t===e||t.contains(e))).length&&n.cancel(new xc)})});i.observe(document.body,{childList:!0,subtree:!0});try{const e=yield n.promise;return i.disconnect(),e}catch(e){throw i.disconnect(),e}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}class jc{constructor(e=window){this._window=e}create(e){return new this._window.MutationObserver(e)}}class Gc extends be{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function Vc(e){if(!/^(https?:)?\/\//.test(e))throw new Gc("The provided URL must be absolute.");const t=document.createElement("a");t.href=e;const 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 Hc(e,t){return e.type===t}class Wc{constructor(e,t,n){this._targetWindow=t,this._context=n,this._targetOrigin="*"===e?"*":Vc(e).origin}post(e,t){const n=this._targetWindow;if(window===n)return;if(!n)throw new Error("Unable to post message because target window is not set.");const i=t&&K(window,"message").pipe(ee(e=>e.origin===this._targetOrigin&&Hc(e.data,e.data.type)&&-1!==[t.successType,t.errorType].indexOf(e.data.type)),te(e=>{if(t.errorType===e.data.type)throw e.data;return e.data}),oe(1)).toPromise();return n.postMessage(Object.assign(Object.assign({},e),{context:this._context}),this._targetOrigin),i}setTarget(e){this._targetWindow=e}setContext(e){this._context=e}}class Yc{constructor(e){var t;this._sourceOrigins=[Vc(e).origin,(t=Vc(e),Vc(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,`www.${t.hostname}`))).origin],this._isListening=!1,this._listeners={}}listen(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))}stopListen(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))}addListener(e,t){let n=this._listeners[e];n||(this._listeners[e]=n=[]),-1===n.indexOf(t)&&n.push(t)}removeListener(e,t){const n=this._listeners[e];if(!n)return;const i=n.indexOf(t);i>=0&&n.splice(i,1)}trigger(e,t){const n=this._listeners[e.type];n&&n.forEach(n=>t?n(e,t):n(e))}_handleMessage(e){if(-1===this._sourceOrigins.indexOf(e.origin)||!Hc(e.data,e.data.type))return;const t=e.data,{context:n}=t,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["context"]);this.trigger(i,n)}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([ba],Yc.prototype,"_handleMessage",null);class Kc extends be{constructor(){super("You haven't complete our spam protection challenge. Please try again."),this.name="SpamProtectionChallengeNotCompletedError",this.type="spam_protection_challenge_not_completed"}}class $c extends be{constructor(){super("Please complete our human verification challenge and try again."),this.name="CardingProtectionChallengeNotCompletedError",this.type="carding_protection_challenge_not_completed"}}class Zc extends be{constructor(){super("We were not able to verify that you are not a robot. Please try again."),this.name="CardingProtectionFailedError",this.type="carding_protection_failed"}}var Jc,Qc,Xc,eu=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class tu{constructor(e){this._googleRecaptcha=e}handle(e,t){return eu(this,void 0,void 0,function*(){return"string"==typeof e?this.handleWithRecaptchaSitekey(e,t):this.handleWithPaymentHumanVerificationRequestError(e)})}handleWithPaymentHumanVerificationRequestError(e){return eu(this,void 0,void 0,function*(){if(!this._isPaymentHumanVerificationRequest(e))throw e;return yield this._initialize(e.body.additional_action_required.data.key),this._performRecaptcha()})}handleWithRecaptchaSitekey(e,t){return eu(this,void 0,void 0,function*(){if("recaptcha_v2"!==e)throw Error("Human verification method is not supported.");if(!t)throw Error("Recaptcha site key is missing.");return yield this._initialize(t),this._performRecaptcha()})}_performRecaptcha(){return this._googleRecaptcha.execute().pipe(oe(1)).pipe(re(e=>eu(this,[e],void 0,function*({error:e,token:t}){if(e instanceof Kc)throw new $c;if(e||!t)throw new Zc;return{type:"recaptcha_v2_verification",data:{human_verification_token:t}}}))).toPromise()}_initialize(e){const t="cardingProtectionContainer";let n=document.getElementById(t);return n&&n.parentNode&&n.parentNode.removeChild(n),n=document.createElement("div"),n.setAttribute("id",t),document.body.appendChild(n),this._googleRecaptcha.load(t,e)}_isPaymentHumanVerificationRequest(e){const{additional_action_required:t,status:n}=e.body||{};return"additional_action_required"===n&&t&&"recaptcha_v2_verification"===t.type}}!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"}(Jc||(Jc={}));class nu extends be{constructor(e){super(function(e){switch(e){case Jc.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case Jc.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case Jc.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case Jc.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."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class iu extends be{constructor(){super("We were not able to complete your spam protection verification. Please try again."),this.name="SpamProtectionFailedError",this.type="spam_protection_failed"}}class ru extends be{constructor(){super("Spam protection is not loaded. Please try again."),this.name="SpamProtectionNotLoadedError",this.type="spam_protection_failed"}}class ou{constructor(e,t){this.googleRecaptchaScriptLoader=e,this.mutationObserverFactory=t,this._memoized=ae((e,t,n)=>{const i=new G;if(!n)throw new Error;return this._widgetId=e.render(n.id,{sitekey:t,size:"invisible",callback:()=>{i.next({token:e.getResponse(this._widgetId)}),e.reset(this._widgetId)},"error-callback":()=>{i.next({error:new iu})}}),i},{isEqual:(e,t)=>e===t})}load(e,t){return this.googleRecaptchaScriptLoader.load().then(n=>{n&&(this._event$=this._memoized(n,t,document.getElementById(e)),this._recaptcha=n)}).catch(e=>{throw e})}reset(e){var t;const n=document.getElementById(e);null==n||n.remove(),null===(t=this._recaptcha)||void 0===t||t.reset(this._widgetId)}execute(){return H(()=>{const e=this._event$,t=this._recaptcha;if(!e||!t)throw new nu(Jc.SpamProtectionNotInitialized);return H(()=>{const e=document.querySelector('iframe[src*="bframe"]');return e?Z(e):J(new ru)}).pipe(ne(e=>e.pipe(X(250),re((e,t)=>t<28?Z(e):J(e)))),re(n=>(this._watchRecaptchaChallengeWindow(e,n),t.execute(this._widgetId),e)),Q(e=>Z({error:e})))})}_watchRecaptchaChallengeWindow(e,t){const n=t.parentElement;if(!n)throw new ru;const i=n.parentElement;if(!i)throw new ru;this.mutationObserverFactory.create(()=>{"hidden"===i.style.visibility&&e.next({error:new Kc})}).observe(i,{attributes:!0,attributeFilter:["style"]})}}class au{constructor(e,t=window){this._scriptLoader=e,this._window=t}load(){return this._loadPromise||(this._loadPromise=this._loadScript()),this._loadPromise}_loadScript(){const e="initRecaptcha",t=[`onload=${e}`,"render=explicit"].join("&");return new Promise((n,i)=>{this._window[e]=()=>n(this._window.grecaptcha),this._scriptLoader.loadScript(`//www.google.com/recaptcha/api.js?${t}`).catch(e=>{this._loadPromise=void 0,i(e)})})}}function su(e){return new ou(new au(e),new jc)}class du extends be{constructor(e){super(e||"Unable to proceed due to invalid configuration provided for the hosted payment form."),this.name="InvalidHostedFormConfigError",this.type="invalid_hosted_form_config"}}class cu extends be{constructor(e){super(e||"Unable to proceed due to an unknown error with the hosted payment form."),this.name="InvalidHostedFormError",this.type="invalid_hosted_form"}}class uu extends be{constructor(e){super(["Unable to proceed due to invalid user input values",...p(x(e),e=>P(e,({message:e})=>e))].join(". ")),this.errors=e,this.name="InvalidHostedFormValueError",this.type="invalid_hosted_form_value"}}!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"}(Qc||(Qc={})),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"}(Xc||(Xc={}));var lu=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class hu{constructor(e,t,n,i,r,o,a,s,d,c){this._type=e,this._containerId=t,this._placeholder=n,this._accessibilityLabel=i,this._styles=r,this._eventPoster=o,this._eventListener=a,this._detachmentObserver=s,this._checkoutId=d,this._cardInstrument=c,this._iframe=document.createElement("iframe");const u=this._checkoutId?`/checkout/payment/hosted-field?version=1.934.2&checkoutId=${this._checkoutId}`:"/checkout/payment/hosted-field?version=1.934.2";this._iframe.src=u,this._iframe.style.border="none",this._iframe.style.height="100%",this._iframe.style.overflow="hidden",this._iframe.style.width="100%"}getType(){return this._type}attach(){return lu(this,void 0,void 0,function*(){const e=document.getElementById(this._containerId);if(!e)throw new du("Unable to proceed because the provided container ID is not valid.");e.appendChild(this._iframe),this._eventListener.listen();const t=K(this._iframe,"load").pipe(re(e=>lu(this,[e],void 0,function*({target:e}){const t=e&&e.contentWindow;if(!t)throw new Error("The content window of the iframe cannot be accessed.");this._eventPoster.setTarget(t),yield this._eventPoster.post({type:Qc.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:Xc.AttachSucceeded,errorType:Xc.AttachFailed})})),oe(1)).toPromise();yield this._detachmentObserver.ensurePresence([this._iframe],t)})}detach(){this._iframe.parentElement&&(this._iframe.parentElement.removeChild(this._iframe),this._eventListener.stopListen())}submitForm(e,t){return lu(this,void 0,void 0,function*(){try{const n=this._eventPoster.post({type:Qc.SubmitRequested,payload:{fields:e,data:t}},{successType:Xc.SubmitSucceeded,errorType:Xc.SubmitFailed});return yield this._detachmentObserver.ensurePresence([this._iframe],n)}catch(e){if(this._isSubmitErrorEvent(e)){if("hosted_form_error"===e.payload.error.code)throw new cu(e.payload.error.message);if(e.payload.response)throw Te(e.payload.response);throw new Error(e.payload.error.message)}throw e}})}submitStoredCardForm(e,t){return lu(this,void 0,void 0,function*(){const n=this._eventPoster.post({type:Qc.StoredCardRequested,payload:{fields:e,data:t}},{successType:Xc.StoredCardSucceeded,errorType:Xc.StoredCardFailed});return this._detachmentObserver.ensurePresence([this._iframe],n)})}validateForm(){return lu(this,void 0,void 0,function*(){const e=this._eventPoster.post({type:Qc.ValidateRequested},{successType:Xc.Validated}),{payload:t}=yield this._detachmentObserver.ensurePresence([this._iframe],e);if(!t.isValid)throw new uu(t.errors)})}_getFontUrls(){const e="fonts.googleapis.com",t=document.querySelectorAll(`link[href*='${e}'][rel='stylesheet']`);return Array.prototype.slice.call(t).filter(t=>Vc(t.href).hostname===e).filter(e=>x(this._styles).map(e=>e&&e.fontFamily).filter(e=>"string"==typeof e).some(t=>t.split(/,\s/).some(t=>-1!==e.href.indexOf(t.replace(" ","+"))))).map(e=>e.href)}_isSubmitErrorEvent(e){return e.type===Xc.SubmitFailed}}var pu=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class gu{constructor(e,t,n,i,r){this._fields=e,this._eventListener=t,this._payloadTransformer=n,this._eventCallbacks=i,this._paymentHumanVerificationHandler=r,this._handleEnter=e=>pu(this,[e],void 0,function*({payload:e}){try{yield this.validate()}catch(e){if(e instanceof Error&&"InvalidHostedFormValueError"!==e.name)throw e}const{onEnter:t=T}=this._eventCallbacks;t(e)});const{onBlur:o=T,onCardTypeChange:a=T,onFocus:s=T,onValidate:d=T}=this._eventCallbacks;this._eventListener.addListener(Xc.Blurred,({payload:e})=>o(e)),this._eventListener.addListener(Xc.CardTypeChanged,({payload:e})=>a(e)),this._eventListener.addListener(Xc.Focused,({payload:e})=>s(e)),this._eventListener.addListener(Xc.Validated,({payload:e})=>d(e)),this._eventListener.addListener(Xc.Entered,this._handleEnter),this._eventListener.addListener(Xc.CardTypeChanged,({payload:e})=>this._cardType=e.cardType),this._eventListener.addListener(Xc.BinChanged,({payload:e})=>this._bin=e.bin)}getBin(){return this._bin}getCardType(){return this._cardType}attach(){return pu(this,void 0,void 0,function*(){this._eventListener.listen();const e=this._getFirstField(),t=q(this._fields,e);yield e.attach(),yield Promise.all(t.map(e=>e.attach()))})}detach(){this._eventListener.stopListen(),this._fields.forEach(e=>{e.detach()})}submit(e,t){return pu(this,void 0,void 0,function*(){try{return yield this._getFirstField().submitForm(this._fields.map(e=>e.getType()),this._payloadTransformer.transform(e,t))}catch(t){const n=yield this._paymentHumanVerificationHandler.handle(t);return yield this._getFirstField().submitForm(this._fields.map(e=>e.getType()),this._payloadTransformer.transform(e,n))}})}submitStoredCard(e){return pu(this,void 0,void 0,function*(){return this._getFirstField().submitStoredCardForm(e.fields,e.data)})}validate(){return pu(this,void 0,void 0,function*(){return this._getFirstField().validateForm()})}_getFirstField(){const e=this._fields[0];if(!e)throw new du("Unable to proceed because the payment form has no field defined.");return e}}function mu(e){return Boolean(e.instrumentId)}class yu{constructor(e){this._store=e}transform(e,t){const n=this._store.getState(),i=n.checkout.getCheckout(),r=n.config.getConfig(),o=n.instruments.getInstrumentsMeta(),a=n.order.getOrder(),s=n.order.getOrderMeta(),d=k(e.paymentData,"ccExpiry","ccName","ccNumber","ccCvv");let c=n.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId);"worldpayaccess"===(null==c?void 0:c.gateway)&&"credit_card"===(null==c?void 0:c.id)&&(c=Object.assign(Object.assign({},c),{id:"worldpayaccess",method:"credit-card"}));const u=n.paymentMethods.getPaymentMethodsMeta(),l=o&&d&&mu(d)?`${n.payment.getPaymentToken()}, ${o.vaultAccessToken}`:n.payment.getPaymentToken();if(!l)throw new Zi($i.MissingPaymentToken);return{additionalAction:t,authToken:l,checkout:i,config:r,order:a,orderMeta:s,payment:d,paymentMethod:c,paymentMethodMeta:u}}}class fu{constructor(e){this._store=e}create(e,t,n){const i=Object.keys(t.fields).reduce((i,r)=>{const o=t.fields[r];return o?[...i,new hu(r,o.containerId,o.placeholder||"",o.accessibilityLabel||"",t.styles||{},new Wc(e),new Yc(e),new qc(new jc),n,"instrumentId"in o?this._getCardInstrument(o.instrumentId):void 0)]:i},[]);return new gu(i,new Yc(e),new yu(this._store),D(t,"onBlur","onEnter","onFocus","onCardTypeChange","onValidate"),new tu(su(ue())))}_getCardInstrument(e){const{instruments:{getCardInstrument:t}}=this._store.getState(),n=t(e);if(!n)throw new Zi($i.MissingPaymentInstrument);return n}}class _u extends be{constructor(){super("You haven't complete our spam check. Please try again."),this.name="SpamProtectionNotCompletedError",this.type="spam_protection_not_completed"}}class Su{constructor(e,t){this._orderRequestSender=e,this._checkoutValidator=t}loadOrder(e,t){return new j(n=>{n.next(o(Pt.LoadOrderRequested)),this._orderRequestSender.loadOrder(e,t).then(e=>{n.next(o(Pt.LoadOrderSucceeded,e.body)),n.complete()}).catch(e=>{n.error(s(Pt.LoadOrderFailed,e))})})}loadOrderPayments(e,t){return new j(n=>{n.next(o(Pt.LoadOrderPaymentsRequested)),this._orderRequestSender.loadOrder(e,t).then(e=>{n.next(o(Pt.LoadOrderPaymentsSucceeded,e.body)),n.complete()}).catch(e=>{n.error(s(Pt.LoadOrderPaymentsFailed,e))})})}loadCurrentOrder(e){return t=>H(()=>{const n=this._getCurrentOrderId(t.getState());if(!n)throw new Zi($i.MissingOrderId);return this.loadOrder(n,e)})}submitOrder(e,t){return n=>V(Z(o(Pt.SubmitOrderRequested)),H(()=>{const i=n.getState(),r=i.config.getExternalSource(),a=i.config.getVariantIdentificationToken(),s=i.checkout.getCheckout();if(!s)throw new Zi($i.MissingCheckout);if(s.shouldExecuteSpamCheck)throw new _u;return Y(this._checkoutValidator.validate(s,t).then(()=>this._orderRequestSender.submitOrder(this._mapToOrderRequestBody(null!=e?e:{},s.id,s.customerMessage,r),Object.assign(Object.assign({},t),{headers:{checkoutVariant:a}})))).pipe(re(e=>V(this.loadOrder(e.body.data.order.orderId,t),Z(o(Pt.SubmitOrderSucceeded,e.body.data,Object.assign(Object.assign({},e.body.meta),{token:e.headers.token}))))))}).pipe(Q(e=>gc(Pt.SubmitOrderFailed,e))))}finalizeOrder(e,t){return V(Z(o(Pt.FinalizeOrderRequested)),Y(this._orderRequestSender.finalizeOrder(e,t)).pipe(re(n=>V(this.loadOrder(e,t),Z(o(Pt.FinalizeOrderSucceeded,n.body.data)))))).pipe(Q(e=>gc(Pt.FinalizeOrderFailed,e)))}_getCurrentOrderId(e){const t=e.order.getOrder(),n=e.checkout.getCheckout();return t&&t.orderId||n&&n.orderId}_mapToOrderRequestBody(e,t,n,i){const{payment:r}=e,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["payment"]);return r?Object.assign(Object.assign({},o),{cartId:t,customerMessage:n,externalSource:i,payment:{paymentData:r.paymentData,name:r.methodId,gateway:r.gatewayId}}):Object.assign(Object.assign({},o),{cartId:t,customerMessage:n,externalSource:i})}}class vu extends be{constructor(e){super(e||"Your checkout could not be processed because some details have changed. Please review your order and try again."),this.name="CartConsistencyError",this.type="cart_consistency"}}class Cu extends be{constructor(e,t){super(t||"At least one item changed stock position. Please review your cart and try again."),this.name="CartStockPositionsChangedError",this.type="cart_stock_positions_changed",this.changedItemIds=e}}class Iu extends be{constructor(e){super(e||"The tax provider is unavailable."),this.name="OrderTaxProviderUnavailableError",this.type="tax_provider_unavailable"}}class wu extends be{constructor(e){super(e),this.name="MissingShippingMethodError",this.type="missing_shipping_method"}}class bu extends be{constructor(e){super(e),this.name="InvalidShippingAddressError",this.type="invalid_shipping_address"}}class Eu{constructor(e){this._requestSender=e}loadOrder(e,{timeout:t}={}){const n=`/api/storefront/orders/${e}`,i=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.get(n,{params:{include:Ic(["payments","lineItems.physicalItems.socialMedia","lineItems.physicalItems.options","lineItems.physicalItems.categories","lineItems.digitalItems.socialMedia","lineItems.digitalItems.options","lineItems.digitalItems.categories"])},headers:i,timeout:t})}submitOrder(e,{headers:t,timeout:n}={}){return this._requestSender.post("/internalapi/v1/checkout/order",{body:e,headers:R(Object.assign({"X-Checkout-Variant":t&&t.checkoutVariant},uc),v),timeout:n}).catch(e=>{var t,n;if("tax_provider_unavailable"===e.body.type)throw new Iu;if("cart_has_changed"===e.body.type)throw new vu;if("cart_stock_positions_changed"===e.body.type){const i=null!==(n=null===(t=e.body.errors)||void 0===t?void 0:t.changedItemIds)&&void 0!==n?n:[];throw new Cu(i)}if("missing_shipping_method"===e.body.type)throw new wu(e.body.detail);if("invalid_shipping_address"===e.body.type)throw new bu(e.body.detail);if("empty_cart"===e.body.type)throw new fc;throw e})}finalizeOrder(e,{timeout:t}={}){const n=`/internalapi/v1/checkout/order/${e}`;return this._requestSender.post(n,{timeout:t,headers:uc})}}class Pu{constructor(e,t,n,i){this._paymentRequestSender=e,this._orderActionCreator=t,this._paymentRequestTransformer=n,this._paymentHumanVerificationHandler=i,this.initializeOffsitePayment=({methodId:e,gatewayId:t,instrumentId:n,target:i,promise:r,shouldSaveInstrument:a,shouldSetAsDefaultInstrument:s})=>d=>{let c;n?c={formattedPayload:{bigpay_token:n}}:a&&(c={formattedPayload:{vault_payment_instrument:a,set_as_default_stored_instrument:s||null}});const u=this._paymentRequestTransformer.transform({gatewayId:t,methodId:e,paymentData:c},d.getState());return V(Z(o(bn.InitializeOffsitePaymentRequested)),Promise.race([this._paymentRequestSender.initializeOffsitePayment(u,i),r].filter(Boolean)).then(()=>o(bn.InitializeOffsitePaymentSucceeded))).pipe(Q(e=>gc(bn.InitializeOffsitePaymentFailed,e)))}}submitPayment(e){return t=>V(Z(o(bn.SubmitPaymentRequested)),H(()=>{return n=this,i=void 0,o=function*(){try{return yield this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(e,t.getState()))}catch(n){const i=yield this._paymentHumanVerificationHandler.handle(n);return yield this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(Object.assign(Object.assign({},e),{additionalAction:i}),t.getState()))}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}).pipe(re(({body:e})=>V(this._orderActionCreator.loadCurrentOrder()(t),Z(o(bn.SubmitPaymentSucceeded,e)))))).pipe(Q(e=>gc(bn.SubmitPaymentFailed,e)))}}class Ou{constructor(e){this._client=e}submitPayment(e){return new Promise((t,n)=>{this._client.submitPayment(e,(e,i)=>{e?n(this._transformResponse(e)):t(this._transformResponse(i))})})}initializeOffsitePayment(e,t){return new Promise(()=>{this._client.initializeOffsitePayment(e,null,t)})}_transformResponse(e){return{headers:e.headers,body:e.data,status:e.status,statusText:e.statusText}}}function Au(e,t){let 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 Tu=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function ku(e){return{code:e.code,discount:e.displayName,discountType:Tu.indexOf(e.couponType)}}function Ru(e){return{code:e.code,discountedAmount:e.used,remainingBalance:e.remaining,giftCertificate:{balance:e.balance,code:e.code,purchaseDate:e.purchaseDate}}}function Du(e){const t=[];return(e||[]).forEach(e=>{(e.banners||[]).forEach(e=>{t.push({placeholders:[],discountType:null,message:"",messageHtml:e.text})})}),t}function Mu(e,t,n="id"){return Object.keys(e).reduce((i,r)=>[...i,...e[r].map(e=>"giftCertificates"===r?function(e,t){const n=new Jd(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,i="id"){const r=new Jd(n);return{id:e[i],imageUrl:e.imageUrl,amount:e.extendedListPrice,amountAfterDiscount:e.extendedSalePrice,discount:e.discountAmount,integerAmount:r.toInteger(e.extendedListPrice),integerAmountAfterDiscount:r.toInteger(e.extendedSalePrice),integerDiscount:r.toInteger(e.discountAmount),integerUnitPrice:r.toInteger(e.listPrice),integerUnitPriceAfterDiscount:r.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(e=>({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""}}(r),t,n))],[])}function Nu(e){const t=e.cart.currency.decimalPlaces,n=new Jd(t);return{id:e.cart.id,items:Mu(e.cart.lineItems,t),currency:e.cart.currency.code,coupon:{discountedAmount:N(e.cart.coupons,(e,t)=>e+t.discountedAmount,0),coupons:e.cart.coupons.map(ku)},discount:{amount:e.cart.discountAmount,integerAmount:n.toInteger(e.cart.discountAmount)},discountNotifications:Du(e.promotions),giftCertificate:{totalDiscountedAmount:N(e.giftCertificates,(e,t)=>e+t.used,0),appliedGiftCertificates:w(e.giftCertificates.map(Ru),"code")},shipping:{amount:e.shippingCostTotal,integerAmount:n.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:n.toInteger(e.shippingCostBeforeDiscount),required:z(e.cart.lineItems.physicalItems,e=>e.isShippingRequired)},subtotal:{amount:e.subtotal,integerAmount:n.toInteger(e.subtotal)},storeCredit:{amount:e.customer?e.customer.storeCredit:0},taxSubtotal:{amount:e.taxTotal,integerAmount:n.toInteger(e.taxTotal)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:n.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:n.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.grandTotal,integerAmount:n.toInteger(e.grandTotal)}}}var Lu;!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.PAYPALEXPRESS="paypalexpress"}(Lu||(Lu={}));const zu=Lu;function Uu(e,t){const n=e.firstName||t.firstName||"",i=e.lastName||t.lastName||"";return{addresses:(e.addresses||[]).map(e=>Au(e)),customerId:e.id,isGuest:e.isGuest,storeCredit:e.storeCredit,email:e.email||t.email||"",firstName:n,lastName:i,name:e.fullName||[n,i].join(" "),customerGroupName:e.customerGroup&&e.customerGroup.name}}class Fu{format(e){const[t="",n=""]=e.split(new RegExp("\\s*/\\s*")),i=t.slice(0,2),r=4===n.length?n.slice(-2):n?n.slice(0,2):t.slice(2);return e.length<2?t:e.length>3&&!r?i:`${i} / ${r}`}toObject(e){const[t="",n=""]=e.split(new RegExp("\\s*/\\s*"));return/^\d+$/.test(t)&&/^\d+$/.test(n)?{month:1===t.length?`0${t}`:t.slice(0,2),year:2===n.length?`20${n}`:n.slice(0,4)}:{month:"",year:""}}}class Bu{format(e){const{card:t}=ye(e);if(!t)return e;const n=O(me(e).map(e=>O(e.lengths))),i=this.unformat(e).slice(0,n);return t.gaps.filter(e=>i.length>e).reduce((e,t,n)=>[e.slice(0,t+n),e.slice(t+n)].join(" "),i)}unformat(e){const{card:t}=ye(e);return t?e.replace(new RegExp(" ","g"),""):e}}function xu(e,t={}){const n=e.currency.decimalPlaces,i=new Jd(n);return{id:e.orderId,items:Mu(e.lineItems,e.currency.decimalPlaces,"productId"),orderId:e.orderId,currency:e.currency.code,customerCanBeCreated:e.customerCanBeCreated,payment:Gu(e.payments,t.payment),subtotal:{amount:e.baseAmount,integerAmount:i.toInteger(e.baseAmount)},coupon:{discountedAmount:N(e.coupons,(e,t)=>e+t.discountedAmount,0),coupons:e.coupons.map(ku)},discount:{amount:e.discountAmount,integerAmount:i.toInteger(e.discountAmount)},token:t.orderToken,callbackUrl:t.callbackUrl,discountNotifications:[],giftCertificate:ju(e.payments),socialData:Hu(e),status:e.status,hasDigitalItems:e.hasDigitalItems,isDownloadable:e.isDownloadable,isComplete:e.isComplete,shipping:{amount:e.shippingCostTotal,integerAmount:i.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(e.shippingCostBeforeDiscount)},storeCredit:{amount:qu(e.payments)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:i.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.orderAmount,integerAmount:e.orderAmountAsInteger}}}function qu(e){const t=l(e,{providerId:"storecredit"});return t?t.amount:0}function ju(e){const t=u(e,{providerId:"giftcertificate"});return{totalDiscountedAmount:N(t,(e,t)=>t.amount+e,0),appliedGiftCertificates:w(t.map(e=>({code:e.detail.code,discountedAmount:e.amount,remainingBalance:e.detail.remaining,giftCertificate:{balance:e.amount+e.detail.remaining,code:e.detail.code,purchaseDate:""}})),"code")}}function Gu(e,t={}){const n=l(e,Vu);return n?{id:n.providerId,status:(i=n.detail.step,`PAYMENT_STATUS_${i}`),helpText:n.detail.instructions,returnUrl:t.returnUrl}:{};var i}function Vu(e){return"giftcertificate"!==e.providerId&&"storecredit"!==e.providerId}function Hu(e){const t={};return[...e.lineItems.physicalItems,...e.lineItems.digitalItems].forEach(e=>{var n;t[e.id]=(n=e,["fb","tw","gp"].reduce((e,t)=>{const i=n.socialMedia&&l(n.socialMedia,e=>e.code===t);return i?(e[t]={name:n.name,description:n.name,image:n.imageUrl,url:i.link,shareText:i.text,sharingLink:i.link,channelName:i.channel,channelCode:i.code},e):e},{}))}),t}function Wu(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}}class Yu{constructor(){this._cardExpiryFormatter=new Fu,this._cardNumberFormatter=new Bu}transform(e,t){const n=t.billingAddress.getBillingAddress(),i=t.checkout.getCheckout(),r=t.customer.getCustomer(),o=t.order.getOrder(),a=t.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),s=this._mapShippingAddress(t,a),d=t.consignments.getConsignments(),c=t.consignments.getShippingOption(),u=t.config.getStoreConfig(),l=t.config.getContextConfig(),h=t.instruments.getInstrumentsMeta(),p=t.paymentMethods.getPaymentMethodsMeta(),g=t.order.getOrderMeta(),m=r&&n&&Uu(r,n),y=h&&e.paymentData&&(mu(e.paymentData)||function(e){const t=e.formattedPayload;return!!t&&("string"==typeof t.bigpay_token||Boolean(t.bigpay_token&&t.bigpay_token.token))}(e.paymentData))?`${t.payment.getPaymentToken()}, ${h.vaultAccessToken}`:t.payment.getPaymentToken();if(!y)throw new Zi($i.MissingPaymentToken);return{additionalAction:e.additionalAction,authToken:y,customer:m,billingAddress:n&&Au(n),shippingAddress:s&&Au(s,d),shippingOption:c&&Wu(c,!0),cart:i&&Nu(i),order:o&&xu(o,g),orderMeta:g,payment:e.paymentData,paymentMethod:a&&this._transformPaymentMethod(a),quoteMeta:{request:Object.assign(Object.assign({},p),{geoCountryCode:l&&l.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:D(u&&u.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}}transformWithHostedFormData(e,t,n){const{additionalAction:i,authToken:r,checkout:o,config:a,order:s,orderMeta:d,payment:c={},paymentMethod:u,paymentMethodMeta:l}=t,h=o&&o.consignments[0],p=h&&h.shippingAddress,g=h&&h.selectedShippingOption;return{additionalAction:i,authToken:r,paymentMethod:u&&this._transformPaymentMethod(u),customer:s&&s.billingAddress&&o&&Uu(o.customer,s.billingAddress),billingAddress:s&&s.billingAddress&&Au(s.billingAddress),shippingAddress:p&&o&&Au(p,o.consignments),shippingOption:g&&Wu(g,!0),cart:o&&Nu(o),order:s&&xu(s,d),orderMeta:d,payment:this._transformHostedInputValues(e,c,n),quoteMeta:{request:Object.assign(Object.assign({},l),{geoCountryCode:a&&a.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:a&&D(a.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}}_transformPaymentMethod(e){if("multi-option"===e.method&&!e.gateway)return Object.assign(Object.assign({},e),{gateway:e.id});if(e.initializationData&&e.initializationData.gateway)return Object.assign(Object.assign({},e),{id:e.initializationData.gateway});if("worldpayaccess"===e.gateway){if("credit_card"===e.id)return Object.assign(Object.assign({},e),{id:"worldpayaccess",method:"credit-card"});if("open_banking"===e.id)return Object.assign(Object.assign({},e),{id:"worldpayaccess",method:"open_banking"})}return e.id===zu.BRAINTREE_VENMO?Object.assign(Object.assign({},e),{id:zu.BRAINTREE_PAYPAL}):e}_transformHostedInputValues(e,t,n){return"instrumentId"in t?Object.assign(Object.assign({},t),{ccCvv:e.cardCodeVerification,ccNumber:e.cardNumberVerification&&this._cardNumberFormatter.unformat(e.cardNumberVerification),hostedFormNonce:n}):Object.assign(Object.assign({},t),{ccCvv:e.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(e.cardExpiry||""),ccName:e.cardName||"",ccNumber:this._cardNumberFormatter.unformat(e.cardNumber||""),hostedFormNonce:n})}_mapShippingAddress(e,t){var n,i,r,o;if(t){const a=null===(i=null===(n=t.initializationData)||void 0===n?void 0:n.bopis)||void 0===i?void 0:i.enabled,s=null===(o=null===(r=t.initializationData)||void 0===r?void 0:r.bopis)||void 0===o?void 0:o.requiredAddress,d=e.consignments.getConsignments(),c=null==d?void 0:d.every(e=>e.selectedPickupOption);if(a&&c&&"none"===s)return}return e.shippingAddress.getShippingAddress()}}class Ku{widgetInteraction(e,t){const n={methodId:t&&t.methodId};return V(Z(o(Nn.WidgetInteractionStarted,void 0,n)),H(()=>e().then(()=>o(Nn.WidgetInteractionFinished,void 0,n)))).pipe(Q(e=>gc(Nn.WidgetInteractionFailed,e,n)))}}class $u{updatePaymentProviderCustomer(e){return Z(o(Yn.UpdatePaymentProviderCustomer,e))}}class Zu{constructor(e,t){this._remoteCheckoutRequestSender=e,this._checkoutActionCreator=t}initializeBilling(e,t,n){return j.create(i=>{i.next(o(Jn.InitializeRemoteBillingRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializeBilling(e,t,n).then(({body:t={}})=>{i.next(o(Jn.InitializeRemoteBillingSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(Jn.InitializeRemoteBillingFailed,t,{methodId:e}))})})}initializeShipping(e,t,n){return j.create(i=>{i.next(o(Jn.InitializeRemoteShippingRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializeShipping(e,t,n).then(({body:t={}})=>{i.next(o(Jn.InitializeRemoteShippingSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(Jn.InitializeRemoteShippingFailed,t,{methodId:e}))})})}initializePayment(e,t,n){return j.create(i=>{i.next(o(Jn.InitializeRemotePaymentRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializePayment(e,t,n).then(({body:t={}})=>{i.next(o(Jn.InitializeRemotePaymentSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(Jn.InitializeRemotePaymentFailed,t,{methodId:e}))})})}loadSettings(e,t){return j.create(n=>{n.next(o(Jn.LoadRemoteSettingsRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.loadSettings(e,t).then(({body:t})=>{n.next(o(Jn.LoadRemoteSettingsSucceeded,t,{methodId:e})),n.complete()}).catch(t=>{n.error(s(Jn.LoadRemoteSettingsFailed,t,{methodId:e}))})})}signOut(e,t){return j.create(n=>{n.next(o(Jn.SignOutRemoteCustomerRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.signOut(e,t).then(()=>{n.next(o(Jn.SignOutRemoteCustomerSucceeded,void 0,{methodId:e})),n.complete()}).catch(t=>{n.error(s(Jn.SignOutRemoteCustomerFailed,t,{methodId:e}))})})}forgetCheckout(e,t){return V(Z(o(Jn.ForgetCheckoutRemoteCustomerRequested,void 0,{methodId:e})),H(()=>{return n=this,i=void 0,a=function*(){return yield this._remoteCheckoutRequestSender.forgetCheckout(t),yield this._checkoutActionCreator.loadCurrentCheckout(),o(Jn.ForgetCheckoutRemoteCustomerSucceeded,void 0,{methodId:e})},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(t=>gc(Jn.ForgetCheckoutRemoteCustomerFailed,t,{methodId:e})))}updateCheckout(e,t){return o(Jn.UpdateRemoteCheckout,t,{methodId:e})}}class Ju{constructor(e){this._requestSender=e}initializeBilling(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/billing`;return this._requestSender.get(i,{params:t,timeout:n,headers:uc})}initializeShipping(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/shipping`;return this._requestSender.get(i,{params:t,timeout:n,headers:uc})}initializePayment(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/payment`;return this._requestSender.get(i,{params:t,timeout:n,headers:uc})}loadSettings(e,{timeout:t}={}){const n=`/remote-checkout/${e}/settings`;return this._requestSender.get(n,{timeout:t,headers:uc})}signOut(e,{timeout:t}={}){const n=`/remote-checkout/${e}/signout`;return this._requestSender.get(n,{timeout:t,headers:uc})}generateToken({timeout:e}={}){return this._requestSender.get("/remote-checkout-token",{timeout:e,headers:uc})}trackAuthorizationEvent({timeout:e}={}){return this._requestSender.post("/remote-checkout/events/shopper-checkout-service-provider-authorization-requested",{timeout:e,headers:uc})}forgetCheckout({timeout:e}={}){return this._requestSender.post("/remote-checkout/forget-checkout",{timeout:e,headers:uc})}}class Qu{constructor(e,t){this._consignmentRequestSender=e,this._checkoutRequestSender=t}unassignItemsByAddress(e,t){return n=>{const i=n.getState();if(!i.checkout.getCheckout())throw new Zi($i.MissingCheckout);const r=this._consignmentHasAddress(e)?e.address:e.shippingAddress,o=i.consignments.getConsignmentByAddress(r);if(!o)throw new Gc("No consignment found for the specified address");const a=this._removeLineItems(e.lineItems,o,i.cart.getCart());return a.length?this.updateConsignment({id:o.id,address:r,lineItems:a},t)(n):this.deleteConsignment(o.id,t)(n)}}assignItemsByAddress(e,t){return n=>{const i=n.getState(),r=this._consignmentHasAddress(e)?e.address:e.shippingAddress,o=i.consignments.getConsignmentByAddress(r);return this._createOrUpdateConsignment({id:o&&o.id,address:r,lineItems:this._addLineItems(e.lineItems,o,i.cart.getCart())},t)(n)}}selectShippingOption(e,t){return n=>j.create(i=>{const r=n.getState(),a=r.checkout.getCheckout(),d=r.consignments.getConsignments();if(!a)throw new Zi($i.MissingCheckout);if(!d||!d.length)throw new Zi($i.MissingConsignments);const c={id:d[0].id,shippingOptionId:e},u={id:d[0].id};i.next(o(ot.UpdateShippingOptionRequested,void 0,u)),this._consignmentRequestSender.updateConsignment(a.id,c,t).then(({body:e})=>{i.next(o(ot.UpdateShippingOptionSucceeded,e,u)),i.complete()}).catch(e=>{i.error(s(ot.UpdateShippingOptionFailed,e,u))})})}loadShippingOptions(e){return t=>j.create(n=>{const i=t.getState().checkout.getCheckout();if(!i)throw new Zi($i.MissingCheckout);n.next(o(ot.LoadShippingOptionsRequested)),this._checkoutRequestSender.loadCheckout(i.id,Object.assign(Object.assign({},e),{params:{include:[kc.AvailableShippingOptions]}})).then(({body:e})=>{n.next(o(ot.LoadShippingOptionsSucceeded,e)),n.complete()}).catch(e=>{n.error(s(ot.LoadShippingOptionsFailed,e))})})}updateAddress(e,t){return n=>{const i=this._getUpdateAddressRequestBody(e,n),r=n.getState().consignments.getConsignments();return r&&r.length&&(i.id=r[0].id),this._createOrUpdateConsignment(i,t)(n)}}createConsignments(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r||!r.id)throw new Zi($i.MissingCheckout);i.next(o(ot.CreateConsignmentsRequested)),this._consignmentRequestSender.createConsignments(r.id,e,t).then(({body:e})=>{i.next(o(ot.CreateConsignmentsSucceeded,e)),i.complete()}).catch(e=>{i.error(s(ot.CreateConsignmentsFailed,e))})})}updateConsignment(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r||!r.id)throw new Zi($i.MissingCheckout);const a={id:e.id};i.next(o(ot.UpdateConsignmentRequested,void 0,a)),this._consignmentRequestSender.updateConsignment(r.id,e,t).then(({body:e})=>{i.next(o(ot.UpdateConsignmentSucceeded,e,a)),i.complete()}).catch(e=>{i.error(s(ot.UpdateConsignmentFailed,e,a))})})}deleteConsignment(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout(),a={id:e};if(!r||!r.id)throw new Zi($i.MissingCheckout);i.next(o(ot.DeleteConsignmentRequested,void 0,a)),this._consignmentRequestSender.deleteConsignment(r.id,e,t).then(({body:e})=>{i.next(o(ot.DeleteConsignmentSucceeded,e,a)),i.complete()}).catch(e=>{i.error(s(ot.DeleteConsignmentFailed,e,a))})})}updateShippingOption(e,t){return n=>j.create(i=>{var r;const a=n.getState().checkout.getCheckout(),d=n.getState().consignments.getConsignmentById(e.id);if((null===(r=null==d?void 0:d.selectedShippingOption)||void 0===r?void 0:r.id)===e.shippingOptionId)return void i.complete();if(!a||!a.id)throw new Zi($i.MissingCheckout);const c={id:e.id};i.next(o(ot.UpdateShippingOptionRequested,void 0,c)),this._consignmentRequestSender.updateConsignment(a.id,e,t).then(({body:e})=>{i.next(o(ot.UpdateShippingOptionSucceeded,e,c)),i.complete()}).catch(e=>{i.error(s(ot.UpdateShippingOptionFailed,e,c))})})}_createOrUpdateConsignment(e,t){return n=>{const i=n.getState().checkout.getCheckout();if(!i||!i.id)throw new Zi($i.MissingCheckout);return this._isUpdateConsignmentRequest(e)?this.updateConsignment(e,t)(n):this.createConsignments([e],t)(n)}}_getUpdateAddressRequestBody(e,t){const n=t.getState().cart.getCart();if(!n)throw new Zi($i.MissingCart);const{physicalItems:i,customItems:r=[]}=n.lineItems;return{address:e,lineItems:[...i,...r].map(e=>({itemId:e.id,quantity:e.quantity}))}}_removeLineItems(e,t,n){if(!n)throw new Zi($i.MissingCart);return this._hydrateLineItems(t.lineItemIds,n).map(t=>{const n=l(e,e=>e.itemId===t.itemId);return Object.assign(Object.assign({},t),{quantity:n?t.quantity-n.quantity:t.quantity})}).filter(e=>e.quantity>0)}_addLineItems(e,t,n){if(!t)return e;if(!n)throw new Zi($i.MissingCart);return e.concat(this._hydrateLineItems(t.lineItemIds,n)).filter(e=>e.quantity>0)}_hydrateLineItems(e,t){return e.map(e=>{const n=l(t.lineItems.physicalItems,t=>t.id===e);return{itemId:e,quantity:n?n.quantity:0}})}_isUpdateConsignmentRequest(e){return!!e.id}_consignmentHasAddress(e){return"object"==typeof e&&"address"in e}}const Xu=["consignments.availableShippingOptions","cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","promotions.banners"];class el{constructor(e){this._requestSender=e}createConsignments(e,t,{timeout:n,params:{include:i}={}}={}){const r=`/api/storefront/checkouts/${e}/consignments`,o=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(r,{body:t,params:{include:wc(Xu,i)},headers:o,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}updateConsignment(e,t,{timeout:n,params:{include:i}={}}={}){const{id:r}=t,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["id"]),a=`/api/storefront/checkouts/${e}/consignments/${r}`,s=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.put(a,{body:o,params:{include:wc(Xu,i)},headers:s,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}deleteConsignment(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/consignments/${t}`,r=Object.assign({Accept:dc.JsonV1},uc),o=Ic(Xu);return this._requestSender.delete(i,{params:{include:o},headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}}class tl{constructor(e,t){this._shippingCountryRequestSender=e,this._store=t}loadCountries(e){const{checkout:t}=this._store.getState(),n=t.getCheckout(),i=n?n.channelId:null;return j.create(t=>{t.next(o(gi.LoadShippingCountriesRequested)),this._shippingCountryRequestSender.loadCountries(i,e).then(e=>{t.next(o(gi.LoadShippingCountriesSucceeded,e.body.data)),t.complete()}).catch(e=>{t.error(s(gi.LoadShippingCountriesFailed,e))})})}}class nl{constructor(e,t){this._requestSender=e,this._config=t}loadCountries(e,{timeout:t}={}){const n="/internalapi/v1/shipping/countries"+(e?`?channel_id=${e}`:""),i=Object.assign({"Accept-Language":this._config.locale},uc);return this._requestSender.get(n,{headers:i,timeout:t})}}var il=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class rl{constructor(e,t){this._googleRecaptcha=e,this._requestSender=t}initialize(e){return t=>V(Z(o(qi.InitializeRequested,void 0)),H(()=>il(this,void 0,void 0,function*(){const n=e?e.containerId:"spamProtectionContainer";if(document.getElementById(n)&&this._googleRecaptcha.reset(n),!e&&!document.getElementById(n)){const e=document.createElement("div");e.setAttribute("id",n),document.body.appendChild(e)}const i=t.getState().config.getStoreConfigOrThrow().checkoutSettings.googleRecaptchaSitekey;return yield this._googleRecaptcha.load(n,i),o(qi.InitializeSucceeded)}))).pipe(Q(e=>gc(qi.InitializeFailed,e)))}verifyCheckoutSpamProtection(){return e=>H(()=>{const t=e.getState().checkout.getCheckout();if(!t)throw new Zi($i.MissingCheckout);return V(Z(o(qi.VerifyCheckoutRequested)),Y(this.execute()(e)).pipe(re(e=>Lc(e)&&e.payload?Y(this._requestSender.validate(t.id,e.payload.token)).pipe(re(({body:t})=>V(Z(e),Z(o(qi.VerifyCheckoutSucceeded,t))))):Z(e)))).pipe(Q(e=>gc(qi.VerifyCheckoutFailed,e)))})}execute(){return e=>V(Z(o(qi.ExecuteRequested)),this.initialize()(e),this._googleRecaptcha.execute().pipe(oe(1)).pipe(re(e=>il(this,[e],void 0,function*({error:e,token:t}){if(e instanceof Kc)throw e;if(e||!t)throw new iu;return o(qi.ExecuteSucceeded,{token:t})})))).pipe(Q(e=>gc(qi.ExecuteFailed,e)))}}class ol{constructor(e){this._requestSender=e}validate(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/spam-protection`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(i,{body:{token:t},headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}}class al{constructor(e){this._storeCreditRequestSender=e}applyStoreCredit(e,t){return n=>V(Z(o(Di.ApplyStoreCreditRequested)),H(()=>{return i=this,r=void 0,s=function*(){var i;const r=n.getState().checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);const{id:a}=r,s=null!==(i=null==t?void 0:t.version)&&void 0!==i?i:r.version,{body:d}=yield e?this._storeCreditRequestSender.applyStoreCredit(a,Object.assign(Object.assign({},t),{version:s})):this._storeCreditRequestSender.removeStoreCredit(a,Object.assign(Object.assign({},t),{version:s}));return o(Di.ApplyStoreCreditSucceeded,d)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{d(s.next(e))}catch(e){t(e)}}function o(e){try{d(s.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(n,o)}d((s=s.apply(i,r||[])).next())});var i,r,a,s})).pipe(Q(e=>gc(Di.ApplyStoreCreditFailed,e)))}}class sl{constructor(e){this._requestSender=e}applyStoreCredit(e,{timeout:t,version:n}={}){const i=`/api/storefront/checkouts/${e}/store-credit`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(i,{headers:r,timeout:t,params:{include:Ic(bc)},body:{version:n}})}removeStoreCredit(e,{timeout:t,version:n}={}){const i=`/api/storefront/checkouts/${e}/store-credit`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.delete(i,{headers:r,timeout:t,params:{include:Ic(bc)},body:{version:n}})}}class dl extends Pe{constructor(e){super(e),this.name="UpdateSubscriptionsError",this.type="update_subscriptions"}}class cl{constructor(e){this._subscriptionsRequestSender=e}updateSubscriptions(e,t){return V(Z(o(We.UpdateSubscriptionsRequested)),H(()=>{return n=this,i=void 0,a=function*(){const{body:n}=yield this._subscriptionsRequestSender.updateSubscriptions(e,t);return o(We.UpdateSubscriptionsSucceeded,n)},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>gc(We.UpdateSubscriptionsFailed,new dl(e))))}}class ul{constructor(e){this._requestSender=e}updateSubscriptions(e,{timeout:t}={}){const n=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post("/api/storefront/subscriptions",{body:e,headers:n,timeout:t})}}const ll=A(e=>Array.isArray(e)?e.map(e=>hl(e)):et(e)?Object.keys(e).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:hl(e[n])}),{}):e);ll.cache=new WeakMap;const hl=e=>"object"==typeof e&&null!==e?ll(e):e;function pl(e){return(...t)=>hl(e(...t))}function gl({billingAddress:{getBillingAddress:e,getBillingAddressOrThrow:t},cart:{getCart:n,getCartOrThrow:i,getLocale:r},checkout:{getCheckout:o,getCheckoutOrThrow:a,getOutstandingBalance:s},config:{getContextConfig:d,getHost:c,getLocale:u,getStoreConfig:l,getStoreConfigOrThrow:h,getConfig:p},consignments:{getConsignments:g,getConsignmentsOrThrow:m},countries:{getCountries:y},customer:{getCustomer:f,getCustomerOrThrow:_},instruments:{getCardInstrument:S,getCardInstrumentOrThrow:v,getInstruments:C,getInstrumentsMeta:I},order:{getOrder:w,getOrderOrThrow:b,getOrderMeta:E},payment:{getPaymentToken:P,getPaymentTokenOrThrow:O,getPaymentId:A,getPaymentIdOrThrow:T,getPaymentStatus:k,getPaymentStatusOrThrow:R,getPaymentRedirectUrl:D,getPaymentRedirectUrlOrThrow:M,isPaymentDataRequired:N},paymentMethods:{getPaymentMethod:L,getPaymentMethodOrThrow:z,getPaymentMethodsMeta:U},paymentProviderCustomer:{getPaymentProviderCustomer:F,getPaymentProviderCustomerOrThrow:B},paymentStrategies:{isInitialized:x},shippingAddress:{getShippingAddress:q,getShippingAddressOrThrow:j,getShippingAddresses:G,getShippingAddressesOrThrow:V},shippingCountries:{getShippingCountries:H}}){return{getHost:pl(c),getLocale:pl(u),getCartLocale:pl(r),getBillingAddress:pl(e),getBillingAddressOrThrow:pl(t),getCart:pl(n),getCartOrThrow:pl(i),getCheckout:pl(o),getCheckoutOrThrow:pl(a),getCountries:pl(y),getStoreConfig:pl(l),getStoreConfigOrThrow:pl(h),getConfig:pl(p),getConsignments:pl(g),getConsignmentsOrThrow:pl(m),getContextConfig:pl(d),getCustomer:pl(f),getCustomerOrThrow:pl(_),getCardInstrument:pl(S),getInstruments:pl(C),getCardInstrumentOrThrow:pl(v),getOrder:pl(w),getOrderOrThrow:pl(b),getOrderMeta:pl(E),getInstrumentsMeta:pl(I),getPaymentToken:P,getPaymentTokenOrThrow:O,getPaymentId:A,getPaymentIdOrThrow:T,getPaymentStatus:k,getPaymentStatusOrThrow:R,getPaymentRedirectUrl:D,getPaymentRedirectUrlOrThrow:M,getPaymentMethod:pl(L),getPaymentMethodOrThrow:pl(z),getPaymentMethodsMeta:pl(U),getPaymentProviderCustomer:pl(F),getPaymentProviderCustomerOrThrow:pl(B),getShippingAddress:pl(q),getShippingAddressOrThrow:pl(j),getShippingAddresses:pl(G),getShippingAddressesOrThrow:pl(V),getShippingCountries:pl(H),getOutstandingBalance:pl(s),isPaymentDataRequired:N,isPaymentMethodInitialized:x}}var ml,yl=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class fl{constructor(e,t,n,i,r,o,a,s,d,c,u,l,h,p,g,m,y,f,_,S){this._store=e,this._storeProjectionFactory=t,this._checkoutActionCreator=n,this._checkoutValidator=i,this._hostedFormFactory=r,this._orderActionCreator=o,this._billingAddressActionCreator=a,this._consignmentActionCreator=s,this._paymentMethodActionCreator=d,this._paymentActionCreator=c,this._paymentHumanVerificationHandler=u,this._customerActionCreator=l,this._cartRequestSender=h,this._storeCreditActionCreator=p,this._couponActionCreator=g,this._spamProtectionActionCreator=m,this._paymentProviderCustomerActionCreator=y,this._shippingCountryActionCreator=f,this._remoteCheckoutActionCreator=_,this._paymentStrategyWidgetActionCreator=S,this._storeProjection=this._storeProjectionFactory.create(this._store)}createHostedForm(e,t){const n=this._storeProjection.getState().getCheckoutOrThrow().id;return this._hostedFormFactory.create(e,t,n)}subscribe(e,...t){return this._storeProjection.subscribe(e,...t)}getState(){return this._storeProjection.getState()}initializeOffsitePayment(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentActionCreator.initializeOffsitePayment(e)),this._storeProjection.getState()})}loadCheckout(e){return yl(this,void 0,void 0,function*(){return e?yield this._store.dispatch(this._checkoutActionCreator.loadCheckout(e)):yield this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout()),this._storeProjection.getState()})}loadDefaultCheckout(){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()),this._storeProjection.getState()})}loadPaymentMethod(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(e,t)),this._storeProjection.getState()})}loadPaymentMethods(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethods(e)),this._storeProjection.getState()})}submitOrder(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._orderActionCreator.submitOrder(e,t)),this._storeProjection.getState()})}submitPayment(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentActionCreator.submitPayment(e)),this._storeProjection.getState()})}finalizeOrder(e){return yl(this,void 0,void 0,function*(){const{order:{getOrderOrThrow:t}}=this._store.getState();return yield this._store.dispatch(this._orderActionCreator.finalizeOrder(t().orderId,e)),this._storeProjection.getState()})}updateBillingAddress(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._billingAddressActionCreator.updateAddress(e)),this._storeProjection.getState()})}updateShippingAddress(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.updateAddress(e)),this._storeProjection.getState()})}selectShippingOption(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.selectShippingOption(e,t)),this._storeProjection.getState()})}signInCustomer(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._customerActionCreator.signInCustomer(e,t)),this._storeProjection.getState()})}signOutCustomer(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._customerActionCreator.signOutCustomer(e)),this._storeProjection.getState()})}createBuyNowCart(e,t){return yl(this,void 0,void 0,function*(){const{body:n}=yield this._cartRequestSender.createBuyNowCart(e,t);return n})}applyStoreCredit(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._storeCreditActionCreator.applyStoreCredit(e,t)),this._storeProjection.getState()})}applyCoupon(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._couponActionCreator.applyCoupon(e,t)),this._storeProjection.getState()})}removeCoupon(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._couponActionCreator.removeCoupon(e,t)),this._storeProjection.getState()})}verifyCheckoutSpamProtection(){return yl(this,void 0,void 0,function*(){const{checkout:e}=this._store.getState(),{shouldExecuteSpamCheck:t}=e.getCheckoutOrThrow();return t&&(yield this._store.dispatch(this._spamProtectionActionCreator.verifyCheckoutSpamProtection())),this._storeProjection.getState()})}loadCurrentOrder(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._orderActionCreator.loadCurrentOrder(e)),this._storeProjection.getState()})}updatePaymentProviderCustomer(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentProviderCustomerActionCreator.updatePaymentProviderCustomer(e)),this._storeProjection.getState()})}loadShippingCountries(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._shippingCountryActionCreator.loadCountries(e)),this._storeProjection.getState()})}deleteConsignment(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.deleteConsignment(e,t)),this._storeProjection.getState()})}initializePayment(e,t,n){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.initializePayment(e,t,n)),this._storeProjection.getState()})}forgetCheckout(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.forgetCheckout(e,t)),this._storeProjection.getState()})}remoteCheckoutSignOut(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.signOut(e,t)),this._storeProjection.getState()})}validateCheckout(e,t){return yl(this,void 0,void 0,function*(){yield this._checkoutValidator.validate(e,t)})}handlePaymentHumanVerification(e,t){return yl(this,void 0,void 0,function*(){return"string"==typeof e?this._paymentHumanVerificationHandler.handle(e,null!=t?t:""):this._paymentHumanVerificationHandler.handle(e)})}widgetInteraction(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentStrategyWidgetActionCreator.widgetInteraction(e),{queueId:"widgetInteraction"}),this._storeProjection.getState()})}}!function(e){e.Synchronize="SYNCHRONIZE"}(ml||(ml={}));class _l{constructor(e){this._transformSelectors=e}create(e){return function(e,t){const n=a((e,t)=>t.type===ml.Synchronize?t.payload:e,e.getState(),{stateTransformer:t});return e.subscribe(e=>{n.dispatch(o(ml.Synchronize,e))},{initial:!1}),n}(e,this._transformSelectors)}}const Sl=e=>{const t=B(e);return document.getElementById(t)?Sl(e):t};function vl(e){return Object.prototype.hasOwnProperty.call(e,"cacheKey")}class Cl{constructor(e){this._lastId=0,this._map={maps:[]},this._usedMaps=[],this._options=Object.assign({maxSize:0,isEqual:fe,onExpire:T},e)}getKey(...e){const t=this._resolveMap(...e),{index:n,parentMap:i}=t;let{map:r}=t;return r&&r.cacheKey?r.usedCount++:r=this._generateMap(i,e.slice(n)),this._removeLeastUsedMap(r),r.cacheKey}getUsedCount(...e){const{map:t}=this._resolveMap(...e);return t?t.usedCount:0}_resolveMap(...e){let t=0,n=this._map;for(;n.maps.length;){let i=!1;for(let r=0;r<n.maps.length;r++){const o=n.maps[r];if(this._options.isEqual(o.value,e[t])){if(n.maps.unshift(...n.maps.splice(r,1)),(0===e.length||t===e.length-1)&&vl(o))return{index:t,map:o,parentMap:n};i=!0,n=o,t++;break}}if(!i)break}return{index:t,parentMap:n}}_generateMap(e,t){let n,i=0,r=e;do{n={maps:[],parentMap:r,usedCount:1,value:t[i]},r.maps.unshift(n),r=n,i++}while(i<t.length);const o=n;return o.cacheKey=""+ ++this._lastId,o}_removeLeastUsedMap(e){if(!this._options.maxSize)return;const t=this._usedMaps.indexOf(e);if(this._usedMaps.splice(-1===t?0:t,-1===t?0:1,e),this._usedMaps.length<=this._options.maxSize)return;const n=this._usedMaps.pop();n&&(this._removeMap(n),this._options.onExpire(n.cacheKey))}_removeMap(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))}}function Il(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,function(e,t,n){if("function"!=typeof n.value)return n;let i=new Cl,r=n.value,o=ae(r);return ba(e,t,{get(){const e=(...e)=>{const t=o.call(this,...e);if(1===i.getUsedCount(...e))return t;const n=r.call(this,...e);return Ue(n,t,{keyFilter:e=>!function(e){return 0===`${e}`.indexOf("$$")||0===`${e}`.indexOf("_")}(e)})?t:(o.cache.set(i.getKey(...e),n),n)};return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=new Cl,r=e,o=ae(r)}})}(e.prototype,n,i))}),t}let wl=class{constructor(e){this._checkoutButton=e.checkoutButton}getInitializeButtonError(e){return this._checkoutButton.getInitializeError(e)}getDeinitializeButtonError(e){return this._checkoutButton.getDeinitializeError(e)}};wl=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([Il],wl);const bl=wl;let El=class{constructor(e){this._checkoutButton=e.checkoutButton}isInitializingButton(e){return this._checkoutButton.isInitializing(e)}isDeinitializingButton(e){return this._checkoutButton.isDeinitializing(e)}};El=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([Il],El);const Pl=El;function Ol(e){return{errors:new bl(e),statuses:new Pl(e)}}let Al=class{constructor(e,t){this._store=e,this._buttonStrategyActionCreator=t,this._state=Ol(this._store.getState()),this._store.subscribe(e=>{this._state=Ol(e)})}getState(){return this._state}subscribe(e,...t){return this._store.subscribe(()=>e(this.getState()),e=>e.checkoutButton.getState(),...t.map(e=>t=>e(Ol(t))))}initializeButton(e){const t=(n=e.containerId,/^\w[\w\-\:\.]*$/.test(n)?[e.containerId]:function(e,t){const n=document.querySelectorAll(e);if(!n.length)throw new Gc(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=Sl(t)),e.id))}(e.containerId,`${e.methodId}-container`));var n;return Promise.all(t.map(t=>{const n=this._buttonStrategyActionCreator.initialize(Object.assign(Object.assign({},e),{containerId:t})),i=`checkoutButtonStrategy:${e.methodId}:${t}`;return this._store.dispatch(n,{queueId:i})})).then(()=>this.getState())}deinitializeButton(e){const t=this._buttonStrategyActionCreator.deinitialize(e),n=`checkoutButtonStrategy:${e.methodId}`;return this._store.dispatch(t,{queueId:n}).then(()=>this.getState())}};Al=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ba],Al);const Tl=Al;class kl{constructor(e,t,n){this._registry=e,this._registryV2=t,this._paymentMethodActionCreator=n}initialize(e){return t=>{const n={methodId:e.methodId,containerId:e.containerId};if(t.getState().checkoutButton.isInitialized(e.methodId,e.containerId))return W();const i=e.currencyCode?{params:{currencyCode:e.currencyCode}}:{},r=Object.assign(Object.assign({},i),{timeout:e.timeout,useCache:!0});return V(Z(o(lt.InitializeButtonRequested,void 0,n)),this._paymentMethodActionCreator.loadPaymentMethod(e.methodId,r)(t),H(()=>this._getStrategy(e.methodId).initialize(e).then(()=>o(lt.InitializeButtonSucceeded,void 0,n)))).pipe(Q(e=>gc(lt.InitializeButtonFailed,e,n)))}}deinitialize(e){return t=>{const n={methodId:e.methodId};return t.getState().checkoutButton.isInitialized(e.methodId)?V(Z(o(lt.DeinitializeButtonRequested,void 0,n)),H(()=>this._getStrategy(e.methodId).deinitialize().then(()=>o(lt.DeinitializeButtonSucceeded,void 0,n)))).pipe(Q(e=>gc(lt.DeinitializeButtonFailed,e,n))):W()}}_getStrategy(e){let t;try{t=this._registryV2.get({id:e})}catch(n){t=this._registry.get(e)}return t}}class Rl{constructor(e){var t,n,i;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!==(i=null==e?void 0:e.tokenResolver)&&void 0!==i?i:e=>e}get(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)}}getFactory(e,t){const n=this._tokenResolver(e,Object.keys(this._factories),t);return n?this._factories[n]:void 0}register(e,t){if(this._hasFactory(e))throw new Gc(`'${e}' is already registered.`);this._factories[e]=t}_hasFactory(e){return!!this._factories[e]}_hasInstance(e){return!!this._instances[e]}_getInstance(e,t){if(!this._hasInstance(t)){const n=this.getFactory(e);if(!n)throw new Gc(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class Dl extends be{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}var Ml,Nl,Ll,zl,Ul;class Fl{constructor(e){this._scriptLoader=e,this._window=window}loadPaypal(){return e=this,t=arguments,i=function*(e=""){const t="//www.paypalobjects.com/api/checkout.min.js",n={async:!0,attributes:{"data-merchant-id":e}};if(e?yield this._scriptLoader.loadScript(t,n):yield this._scriptLoader.loadScript(t),!this._window.paypal)throw new Dl;return this._window.paypal},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Ml||(Ml={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Nl||(Nl={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(Ll||(Ll={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(zl||(zl={})),function(e){e.PILL="pill",e.RECT="rect"}(Ul||(Ul={}));class Bl{constructor(e,t,n,i,r=""){this._store=e,this._checkoutActionCreator=t,this._paypalScriptLoader=n,this._formPoster=i,this._host=r}initialize(e){const t=e.paypal,n=this._store.getState(),i=this._paymentMethod=n.paymentMethods.getPaymentMethod(e.methodId);if(!t)throw new Gc;if(!i)throw new Zi($i.MissingPaymentMethod);return this._paypalScriptLoader.loadPaypal(i.config.merchantId).then(n=>{var r,o;if(!i||!i.config.merchantId)throw new Zi($i.MissingPaymentMethod);const a=i.config.merchantId,s=i.config.testMode?"sandbox":"production",d={[s]:t.clientId},c=n.FUNDING.CREDIT||"credit",u=t.allowCredit?[c]:[],l=t.allowCredit?[]:[c];return n.Button.render({env:s,client:d,commit:t.shouldProcessPayment,funding:{allowed:u,disallowed:l},style:Object.assign(Object.assign({shape:Ul.RECT},D(t.style,"layout","color","label","shape","tagline","fundingicons")),{size:"paypalexpress"===i.id&&"small"===(null===(r=t.style)||void 0===r?void 0:r.size)?Nl.RESPONSIVE:null===(o=t.style)||void 0===o?void 0:o.size}),payment:(e,n)=>this._setupPayment(a,n,t.onPaymentError),onAuthorize:(e,n)=>this._tokenizePayment(e,n,t.shouldProcessPayment,t.onAuthorizeError)},e.containerId)})}deinitialize(){return this._paymentMethod=void 0,Promise.resolve()}_setupPayment(e,t,n){if(!t)throw new nu(Jc.CheckoutButtonNotInitialized);return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then(n=>{const i=n.cart.getCart(),r=i?i.id:"";return t.request.post(`${this._host}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:r},{headers:Object.assign({"X-API-INTERNAL":cc},uc)})}).then(e=>e.id).catch(e=>{throw n&&n(e),e})}_tokenizePayment(e,t,n,i){if(!this._paymentMethod)throw new nu(Jc.CheckoutButtonNotInitialized);if(!t)throw new nu(Jc.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new Zi($i.MissingPayment);const r=this._paymentMethod.id;return t.payment.get(e.paymentID).then(t=>{this._formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:r,action:n?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(t.payer.payer_info)})})}}function xl(e){return e&&"resolveIds"in e}function ql(){try{return"production"}catch(e){return"development"}}class jl{constructor(e){this._console=e}log(...e){this._logToConsole("log",...e)}info(...e){this._logToConsole("info",...e)}warn(...e){this._logToConsole("warn",...e)}error(...e){this._logToConsole("error",...e)}debug(...e){this._logToConsole("debug",...e)}_logToConsole(e,...t){this._console&&this._console[e]&&this._console[e].call(this._console,...t)}}class Gl{log(){}info(){}warn(){}error(){}debug(){}}const Vl=function(e=!0){return e?new jl(console):new Gl}("test"!==ql());class Hl{constructor(e=!1){this._useFallback=e,this._registry=new Rl({tokenResolver:this._resolveToken.bind(this),defaultToken:this._encodeToken({default:!0}),useFallback:this._useFallback})}get(e){return this._registry.get(this._encodeToken(e))}getFactory(e,t){try{return this._registry.getFactory(this._encodeToken(e),t)}catch(e){return}}getUseFallback(){return this._useFallback}register(e,t){this._registry.register(this._encodeToken(e),t)}_encodeToken(e){return btoa(JSON.stringify(e))}_decodeToken(e){return JSON.parse(atob(e))}_resolveToken(e,t,n){var i;const r=this._decodeToken(e),o=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,i]of Object.entries(t)){if(e in r&&r[e]!==i){n.matches=0;break}e in r&&r[e]===i&&n.matches++,"default"===e&&!0===i&&(n.default=!0)}o.push(n)});const a=o.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);a.length>1&&a[0].matches===a[1].matches&&"development"===ql()&&Vl.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.");const s=Object.keys(r).length;if(n){const e=a.find(e=>e.matches===s&&e.matches===e.totalKeys);if(!e)throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)} with exact match.`);return e.token}const d=a[0];if(d&&d.token)return d.token;if(this._useFallback){const e=null===(i=o.find(e=>e.default))||void 0===i?void 0:i.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)}.`)}}function Wl(t){const{host:i}=null!=t?t:{},r=or({config:{meta:{host:null==t?void 0:t.host,locale:null==t?void 0:t.locale},errors:{},statuses:{}}}),o=e({host:i}),a=n({host:i}),s=function(e,t){const n=new Hl;for(const[,i]of Object.entries(t))if(xl(i))for(const t of i.resolveIds)n.register(t,()=>i(e));return n}(function(t,n){const{config:{getHost:i,getLocale:r}}=t.getState();n||(n=e({host:i()}));const o=new _l(gl),a=new Cc(new Pc(n),new Rc(new Dc(n)),new Fc(new Bc(n))),s=new Tc(new Pc(n)),d=new fu(t),c=new Su(new Eu(n),new Tc(new Pc(n))),u=new yc(new Sc(n),new cl(new ul(n))),l=new Qu(new el(n),new Pc(n)),h=new ac(new lc(n),new pc(n)),p=new Pu(new Ou(function(e){const t=ge();return e.subscribe(e=>{const n=e.config.getStoreConfig();n&&t.setHost(n.paymentSettings.bigpayBaseUrl)},e=>e.config.getStoreConfig()),t}(t)),c,new Yu,new tu(su(ue()))),g=new tu(su(ue())),m=new zc(new Uc(n),a,new rl(su(ue()),new ol(n))),y=new al(new sl(n)),f=new Mc(new Nc(n)),_=su(ue()),S=new ol(n),v=new rl(_,S),C=new vc(n),I=new $u,w=new tl(new nl(n,{locale:r()}),t),b=new Zu(new Ju(n),a),E=new Ku;return new fl(t,o,a,s,d,c,u,l,h,p,g,m,C,y,f,v,I,w,b,E)}(r),Se);return new Tl(r,new kl(function(e,t,n,i){const r=new Rl,o=le(),a=new Pc(t),s=new Cc(a,new Rc(new Dc(t)),new Fc(new Bc(t)));return r.register(zu.PAYPALEXPRESS,()=>new Bl(e,s,new Fl(o),n,i)),r}(r,o,a,i),s,new ac(new lc(o),new pc(o))))}export{Wl as createCheckoutButtonInitializer,t as createTimeout};
|
|
1
|
+
import{createRequestSender as e,createTimeout as t}from"@bigcommerce/request-sender";import{createFormPoster as n}from"@bigcommerce/form-poster";import{combineReducers as i,composeReducers as r,createAction as o,createDataStore as a,createErrorAction as s,deepFreeze as d}from"@bigcommerce/data-store";import{difference as c,filter as u,find as l,findIndex as h,flatMap as p,identity as g,includes as m,isArray as y,isEmpty as f,isEqual as _,isMatch as S,isNil as v,isObject as C,isPlainObject as I,keyBy as w,keys as b,last as E,map as P,max as O,memoize as A,noop as T,omit as k,omitBy as R,pick as D,pickBy as M,reduce as N,round as L,some as z,transform as U,uniq as F,uniqueId as B,values as x,without as q}from"lodash";import{Observable as j,Subject as G,concat as V,defer as H,empty as W,from as Y,fromEvent as K,merge as $,of as Z,throwError as J}from"rxjs";import{catchError as Q,delay as X,filter as ee,map as te,retryWhen as ne,shareReplay as ie,switchMap as re,take as oe}from"rxjs/operators";import{memoize as ae,memoizeOne as se}from"@bigcommerce/memoize";import{createSelector as de}from"reselect";import{ScriptLoader as ce,createScriptLoader as ue,getScriptLoader as le}from"@bigcommerce/script-loader";import{stringifyUrl as he}from"query-string";import{supportsPopups as pe}from"@braintree/browser-detection";import{createClient as ge}from"@bigcommerce/bigpay-client";import{creditCardType as me,number as ye}from"card-validator";import{default as fe}from"shallowequal";var _e={d:(e,t)=>{for(var n in t)_e.o(t,n)&&!_e.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},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})}},Se={};_e.r(Se),_e.d(Se,{createAmazonPayV2ButtonStrategy:()=>Nr,createApplePayButtonStrategy:()=>po,createBigCommercePaymentsButtonStrategy:()=>Ro,createBigCommercePaymentsPayLaterButtonStrategy:()=>No,createBigCommercePaymentsVenmoButtonStrategy:()=>Uo,createBoltButtonStrategy:()=>Ho,createBraintreePaypalButtonStrategy:()=>ca,createBraintreePaypalCreditButtonStrategy:()=>ha,createBraintreeVenmoButtonStrategy:()=>Ca,createBraintreeVisaCheckoutButtonStrategy:()=>ma,createGooglePayAdyenV2ButtonStrategy:()=>ls,createGooglePayAdyenV3ButtonStrategy:()=>hs,createGooglePayAuthorizeDotNetButtonStrategy:()=>gs,createGooglePayBigCommercePaymentsButtonStrategy:()=>us,createGooglePayBraintreeButtonStrategy:()=>Ja,createGooglePayCheckoutComButtonStrategy:()=>Ss,createGooglePayCybersourceButtonStrategy:()=>Cs,createGooglePayOrbitalButtonStrategy:()=>ws,createGooglePayPayPalCommerceButtonStrategy:()=>os,createGooglePayStripeButtonStrategy:()=>js,createGooglePayTdOnlineMartButtonStrategy:()=>Ks,createGooglePayWorldpayAccessButtonStrategy:()=>Vs,createLinkV2ButtonStrategy:()=>tc,createPayPalCommerceButtonStrategy:()=>md,createPayPalCommerceCreditButtonStrategy:()=>_d,createPayPalCommerceVenmoButtonStrategy:()=>Nd,createPaypalExpressButtonStrategy:()=>Vd});class ve extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}const Ce={body:{},headers:{},status:0};class Ie extends ve{constructor(e,{message:t,errors:n}={}){const{body:i,headers:r,status:o}=e||Ce;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=r,this.status=o,this.errors=n||[]}}class we extends Ie{constructor(e){super(e,{message:"There is a problem processing your payment. Please try again later."}),this.name="PaymentMethodInvalidError",this.type="payment_method_invalid"}}class be extends Error{constructor(e){var t;super(e||"An unexpected error has occurred."),this.name="StandardError",this.type="standard",t=new.target.prototype,Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(this,new.target):this.stack=new Error(this.message).stack}}const Ee={body:{},headers:{},status:0};class Pe extends be{constructor(e,{message:t,errors:n}={}){const{body:i,headers:r,status:o}=e||Ee;super(t||"An unexpected error has occurred."),this.name="RequestError",this.type="request",this.body=i,this.headers=r,this.status=o,this.errors=n||[]}}class Oe extends Pe{constructor(e,t){super(e,{message:t||"An unexpected error has occurred. The checkout process cannot continue as a result."}),this.name="UnrecoverableError",this.type="unrecoverable"}}function Ae(e){return e.reduce((e,t)=>t?[...e,t]:e,[]).join(" ")}function Te(e,t){const{body:n}=e,{errors:i=[]}=n;return new Pe(e,{message:ke(i)||t,errors:i})}function ke(e){if(Array.isArray(e))return e.reduce((e,t)=>t&&t.message?[...e,t.message]:e,[]).join(" ")}class Re extends Pe{constructor(e){super(e,{message:"The request has timed out or aborted."}),this.name="TimeoutError",this.type="timeout"}}class De{constructor(){this._factoryMethods={},this.register("default",(e,t)=>new Pe(e,{message:t})),this.register("internal",(e,t)=>function(e,t){const{body:n}=e,{errors:i=[]}=n;return new Pe(e,{message:Ae(i)||n.detail||n.title||t,errors:i.length?i.map(e=>({code:n.type,message:e})):[{code:n.type,message:n.detail||n.title}]})}(e,t)),this.register("storefront",(e,t)=>function(e,t){const{body:n}=e;return new Pe(e,{message:t||n.detail||n.title,errors:[{code:n.code||n.type,message:n.detail||n.title}]})}(e,t)),this.register("payment",(e,t)=>Te(e,t)),this.register("timeout",e=>new Re(e))}register(e,t){this._factoryMethods[e]=t}createError(e,t){return(this._factoryMethods[this._getType(e)]||this._factoryMethods.default)(e,t)}_getType(e){if(0===e.status)return"timeout";if(this._isStorefrontErrorResponseBody(e.body))return"storefront";if(this._isInternalErrorResponseBody(e.body)){const t=E(e.body.type.split("/"));return t&&this._factoryMethods[t]?t:"internal"}const t=E(e.body&&e.body.errors);return t&&t.code&&this._factoryMethods[t.code]?t.code:"payment"}_isStorefrontErrorResponseBody(e){const t=e;return!this._isInternalErrorResponseBody(e)&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status&&"string"==typeof t.detail}_isInternalErrorResponseBody(e){const t=e;return"object"==typeof t.errors&&"string"==typeof t.title&&"string"==typeof t.type&&"number"==typeof t.status}}function Me(e,t){return Array.isArray(e)?e.map(e=>Me(e,t)):I(e)?U(R(e,t),(e,n,i)=>{e[i]=Me(n,t)},{}):e}var Ne,Le;function ze(e,t){return function(e){return e.type===Ne.ClearError}(t)?Me(e,e=>e===t.payload):e}function Ue(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(let i=0,r=e.length;i<r;i++)if(!Ue(e[i],t[i],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){const i=n&&n.keyFilter,r=i?Object.keys(e).filter(i):Object.keys(e),o=i?Object.keys(t).filter(i):Object.keys(t);if(r.length!==o.length)return!1;for(let i=0,o=r.length;i<o;i++){const o=r[i];if(!Object.prototype.hasOwnProperty.call(t,o))return!1;if(!Ue(e[o],t[o],n))return!1}return!0}(e,t,n))):e===t)}function Fe(e,t,n){return e&&Object.prototype.hasOwnProperty.call(e,t)&&Ue(e[t],n)?e:Object.assign(Object.assign({},e),{[t]:n})}!function(e){e.ClearError="CLEAR_ERROR"}(Ne||(Ne={})),function(e){e.LoadB2BTokenRequested="LOAD_B2B_TOKEN_REQUESTED",e.LoadB2BTokenSucceeded="LOAD_B2B_TOKEN_SUCCEEDED",e.LoadB2BTokenFailed="LOAD_B2B_TOKEN_FAILED"}(Le||(Le={}));const Be={errors:{},statuses:{}};function xe(e=Be,t){return i({data:qe,errors:r(je,ze),statuses:Ge})(e,t)}function qe(e,t){return t.type===Le.LoadB2BTokenSucceeded?t.payload:e}function je(e=Be.errors,t){switch(t.type){case Le.LoadB2BTokenRequested:case Le.LoadB2BTokenSucceeded:return Fe(e,"loadError",void 0);case Le.LoadB2BTokenFailed:return Fe(e,"loadError",t.payload);default:return e}}function Ge(e=Be.statuses,t){switch(t.type){case Le.LoadB2BTokenRequested:return Fe(e,"isLoading",!0);case Le.LoadB2BTokenFailed:case Le.LoadB2BTokenSucceeded:return Fe(e,"isLoading",!1);default:return e}}var Ve,He,We,Ye;function Ke(e,t){return void 0===t||Ue(e,t)?e:t}!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",e.DeleteCheckoutRequested="DELETE_CHECKOUT_REQUESTED",e.DeleteCheckoutSucceeded="DELETE_CHECKOUT_SUCCEEDED",e.DeleteCheckoutFailed="DELETE_CHECKOUT_FAILED"}(Ve||(Ve={})),function(e){e.HydrateInitialState="HYDRATE_INITIAL_STATE"}(He||(He={})),function(e){e.UpdateSubscriptionsRequested="UPDATE_SUBSCRIPTIONS_REQUESTED",e.UpdateSubscriptionsSucceeded="UPDATE_SUBSCRIPTIONS_SUCCEEDED",e.UpdateSubscriptionsFailed="UPDATE_SUBSCRIPTIONS_FAILED"}(We||(We={})),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"}(Ye||(Ye={}));const $e={errors:{},statuses:{}};function Ze(e=$e,t){return i({data:Je,errors:r(Qe,ze),statuses:Xe})(e,t)}function Je(e,t){var n,i;switch(t.type){case Ye.UpdateBillingAddressSucceeded:case Ye.ContinueAsGuestSucceeded:case Ve.LoadCheckoutSucceeded:return Ke(e,t.payload&&t.payload.billingAddress);case He.HydrateInitialState:return Ke(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.billingAddress);default:return e}}function Qe(e=$e.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);case Ye.UpdateBillingAddressRequested:case Ye.UpdateBillingAddressSucceeded:return Fe(e,"updateError",void 0);case Ye.UpdateBillingAddressFailed:return Fe(e,"updateError",t.payload);case We.UpdateSubscriptionsRequested:case We.UpdateSubscriptionsSucceeded:case Ye.ContinueAsGuestRequested:case Ye.ContinueAsGuestSucceeded:return Fe(e,"continueAsGuestError",void 0);case We.UpdateSubscriptionsFailed:case Ye.ContinueAsGuestFailed:return Fe(e,"continueAsGuestError",t.payload);default:return e}}function Xe(e=$e.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutSucceeded:case Ve.LoadCheckoutFailed:return Fe(e,"isLoading",!1);case Ye.UpdateBillingAddressRequested:return Fe(e,"isUpdating",!0);case Ye.UpdateBillingAddressFailed:case Ye.UpdateBillingAddressSucceeded:return Fe(e,"isUpdating",!1);case Ye.ContinueAsGuestRequested:case We.UpdateSubscriptionsRequested:return Fe(e,"isContinuingAsGuest",!0);case We.UpdateSubscriptionsSucceeded:case We.UpdateSubscriptionsFailed:case Ye.ContinueAsGuestFailed:case Ye.ContinueAsGuestSucceeded:return Fe(e,"isContinuingAsGuest",!1);default:return e}}function et(e){return I(e)}const tt=function e(t,n,i){const{matchObject:r=(e,t)=>void 0!==e.id&&e.id===t.id}=i||{};if(!t)return n;if(!n||t===n)return t;let o=0,a=0;const s=(e,t,n)=>(o+=e===t?1:0,a+=e===n?1:0,e),d=n.map((n,i)=>{const o=t&&t[i];return et(o)&&et(n)?r(o,n)?s(nt(o,n),o,n):s(Ke(o,n),o,n):y(o)&&y(n)?s(e(o,n),o,n):s(Ke(o,n),o,n)});return o===n.length&&t&&t.length===n.length?t:a===n.length?n:d},nt=function e(t,n){return t?n&&t!==n?Object.keys(n).reduce((t,i)=>{const r=t[i],o=n[i];return et(r)&&et(o)?Fe(t,i,e(r,o)):y(r)&&y(o)?Fe(t,i,tt(r,o)):Fe(t,i,o)},t):t:n};var it,rt,ot;!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"}(it||(it={})),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"}(rt||(rt={})),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"}(ot||(ot={}));const at={errors:{},statuses:{}};function st(e=at,t){return i({data:dt,errors:r(ut,ze),statuses:ct})(e,t)}function dt(e,t){var n,i;switch(t.type){case Ye.UpdateBillingAddressSucceeded:case Ve.LoadCheckoutSucceeded:case ot.CreateConsignmentsSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case ot.LoadShippingOptionsSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:return nt(e,t.payload&&t.payload.cart);case He.HydrateInitialState:return nt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.cart);case Ve.DeleteCheckoutSucceeded:return;default:return e}}function ct(e=at.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutFailed:case Ve.LoadCheckoutSucceeded:return Fe(e,"isLoading",!1);default:return e}}function ut(e=at.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);default:return e}}var lt;!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"}(lt||(lt={}));const ht={data:{},errors:{},statuses:{}},pt={initializedContainers:{}},gt={},mt={};function yt(e=ht,t){return t.meta&&t.meta.methodId?i({data:i({[t.meta.methodId]:ft}),errors:i({[t.meta.methodId]:_t}),statuses:i({[t.meta.methodId]:St})})(e,t):e}function ft(e=pt,t){switch(t.type){case lt.InitializeButtonSucceeded:return t.meta&&t.meta.containerId?nt(e,{initializedContainers:{[t.meta.containerId]:!0}}):e;case lt.DeinitializeButtonSucceeded:return Fe(e,"initializedContainers",{})}return e}function _t(e=gt,t){switch(t.type){case lt.InitializeButtonRequested:case lt.InitializeButtonSucceeded:return Fe(e,"initializeError",void 0);case lt.InitializeButtonFailed:return Fe(e,"initializeError",t.payload);case lt.DeinitializeButtonRequested:case lt.DeinitializeButtonSucceeded:return Fe(e,"deinitializeError",void 0);case lt.DeinitializeButtonFailed:return Fe(e,"deinitializeError",t.payload);default:return e}}function St(e=mt,t){switch(t.type){case lt.InitializeButtonRequested:return Fe(e,"isInitializing",!0);case lt.InitializeButtonFailed:case lt.InitializeButtonSucceeded:return Fe(e,"isInitializing",!1);case lt.DeinitializeButtonRequested:return Fe(e,"isDeinitializing",!0);case lt.DeinitializeButtonFailed:case lt.DeinitializeButtonSucceeded:return Fe(e,"isDeinitializing",!1);default:return e}}var vt;!function(e){e.LoadConfigRequested="LOAD_CONFIG_REQUESTED",e.LoadConfigSucceeded="LOAD_CONFIG_SUCCEEDED",e.LoadConfigFailed="LOAD_CONFIG_FAILED"}(vt||(vt={}));const Ct={meta:{},errors:{},statuses:{}};function It(e=Ct,t){return i({data:wt,errors:r(bt,ze),statuses:Et})(e,t)}function wt(e,t){var n,i;switch(t.type){case vt.LoadConfigSucceeded:return nt(e,t.payload);case He.HydrateInitialState:{const r=nt(e,null===(n=t.payload)||void 0===n?void 0:n.config);return r&&(null===(i=t.payload)||void 0===i?void 0:i.b2bApiSettings)?Object.assign(Object.assign({},r),{storeConfig:Object.assign(Object.assign({},r.storeConfig),{b2bApiSettings:t.payload.b2bApiSettings})}):r}default:return e}}function bt(e=Ct.errors,t){switch(t.type){case vt.LoadConfigSucceeded:return Fe(e,"loadError",void 0);case vt.LoadConfigFailed:return Fe(e,"loadError",t.payload);default:return e}}function Et(e=Ct.statuses,t){switch(t.type){case vt.LoadConfigRequested:return Fe(e,"isLoading",!0);case vt.LoadConfigSucceeded:case vt.LoadConfigFailed:return Fe(e,"isLoading",!1);default:return e}}var Pt;!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"}(Pt||(Pt={}));const Ot={errors:{},statuses:{}};function At(e=Ot,t){return i({data:Tt,errors:r(kt,ze),statuses:Rt})(e,t)}function Tt(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case it.ApplyCouponSucceeded:case ot.UpdateShippingOptionSucceeded:case it.RemoveCouponSucceeded:case Pt.LoadOrderSucceeded:return tt(e,t.payload&&t.payload.coupons);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.coupons);default:return e}}function kt(e={},t){switch(t.type){case it.ApplyCouponRequested:case it.ApplyCouponSucceeded:return Fe(e,"applyCouponError",void 0);case it.ApplyCouponFailed:return Fe(e,"applyCouponError",t.payload);case it.RemoveCouponRequested:case it.RemoveCouponSucceeded:return Fe(e,"removeCouponError",void 0);case it.RemoveCouponFailed:return Fe(e,"removeCouponError",t.payload);default:return e}}function Rt(e={},t){switch(t.type){case it.ApplyCouponRequested:return Fe(e,"isApplyingCoupon",!0);case it.ApplyCouponSucceeded:case it.ApplyCouponFailed:return Fe(e,"isApplyingCoupon",!1);case it.RemoveCouponRequested:return Fe(e,"isRemovingCoupon",!0);case it.RemoveCouponSucceeded:case it.RemoveCouponFailed:return Fe(e,"isRemovingCoupon",!1);default:return e}}const Dt={errors:{},statuses:{}};function Mt(e=Dt,t){return i({data:Nt,errors:r(Lt,ze),statuses:zt})(e,t)}function Nt(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:return tt(e,t.payload&&t.payload.giftCertificates);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.giftCertificates);default:return e}}function Lt(e=Dt.errors,t){switch(t.type){case rt.ApplyGiftCertificateRequested:case rt.ApplyGiftCertificateSucceeded:return Fe(e,"applyGiftCertificateError",void 0);case rt.ApplyGiftCertificateFailed:return Fe(e,"applyGiftCertificateError",t.payload);case rt.RemoveGiftCertificateRequested:case rt.RemoveGiftCertificateSucceeded:return Fe(e,"removeGiftCertificateError",void 0);case rt.RemoveGiftCertificateFailed:return Fe(e,"removeGiftCertificateError",t.payload);default:return e}}function zt(e=Dt.statuses,t){switch(t.type){case rt.ApplyGiftCertificateRequested:return Fe(e,"isApplyingGiftCertificate",!0);case rt.ApplyGiftCertificateSucceeded:case rt.ApplyGiftCertificateFailed:return Fe(e,"isApplyingGiftCertificate",!1);case rt.RemoveGiftCertificateRequested:return Fe(e,"isRemovingGiftCertificate",!0);case rt.RemoveGiftCertificateSucceeded:case rt.RemoveGiftCertificateFailed:return Fe(e,"isRemovingGiftCertificate",!1);default:return e}}var Ut;!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"}(Ut||(Ut={}));const Ft={errors:{},statuses:{}};function Bt(e=Ft,t){return i({data:xt,errors:r(qt,ze),statuses:jt})(e,t)}function xt(e,t){var n,i;switch(t.type){case Ye.ContinueAsGuestSucceeded:case Ve.LoadCheckoutSucceeded:return nt(e,t.payload&&t.payload.customer);case Ut.CreateCustomerAddressSucceeded:return nt(e,t.payload);case He.HydrateInitialState:return nt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.customer);default:return e}}function qt(e=Ft.errors,t){switch(t.type){case Ut.CreateCustomerRequested:case Ut.CreateCustomerSucceeded:return Fe(e,"createError",void 0);case Ut.CreateCustomerFailed:return Fe(e,"createError",t.payload);case Ut.CreateCustomerAddressRequested:case Ut.CreateCustomerAddressSucceeded:return Fe(e,"createAddressError",void 0);case Ut.CreateCustomerAddressFailed:return Fe(e,"createAddressError",t.payload);default:return e}}function jt(e=Ft.statuses,t){switch(t.type){case Ut.CreateCustomerRequested:return Fe(e,"isCreating",!0);case Ut.CreateCustomerFailed:case Ut.CreateCustomerSucceeded:return Fe(e,"isCreating",!1);case Ut.CreateCustomerAddressRequested:return Fe(e,"isCreatingAddress",!0);case Ut.CreateCustomerAddressFailed:case Ut.CreateCustomerAddressSucceeded:return Fe(e,"isCreatingAddress",!1);default:return e}}var Gt;!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"}(Gt||(Gt={}));const Vt={data:{},errors:{},statuses:{}};function Ht(e=Vt,t){return i({data:Wt,errors:r(Yt,ze),statuses:Kt})(e,t)}function Wt(e=Vt.data,t){switch(t.type){case Gt.InitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!0}});case Gt.DeinitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!1}})}return e}function Yt(e=Vt.errors,t){switch(t.type){case Gt.InitializeRequested:case Gt.InitializeSucceeded:return nt(e,{initializeErrors:Object.assign({},e.initializeErrors),initializeMethodId:e.initializeMethodId?e.initializeMethodId:void 0});case Gt.InitializeFailed:return nt(e,{initializeErrors:Object.assign(Object.assign({},e.initializeErrors),{[t.meta&&t.meta.methodId]:t.payload}),initializeMethodId:t.meta&&t.meta.methodId});case Gt.DeinitializeRequested:case Gt.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Gt.DeinitializeFailed:return nt(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case Gt.SignInRequested:case Gt.SignInSucceeded:return nt(e,{signInError:void 0,signInMethodId:void 0});case Gt.SignInFailed:return nt(e,{signInError:t.payload,signInMethodId:t.meta&&t.meta.methodId});case Gt.SignOutRequested:case Gt.SignOutSucceeded:return nt(e,{signOutError:void 0,signOutMethodId:void 0});case Gt.SignOutFailed:return nt(e,{signOutError:t.payload,signOutMethodId:t.meta&&t.meta.methodId});case Gt.ExecutePaymentMethodCheckoutRequested:case Gt.ExecutePaymentMethodCheckoutSucceeded:return nt(e,{executePaymentMethodCheckoutError:void 0,executePaymentMethodCheckoutMethodId:void 0});case Gt.ExecutePaymentMethodCheckoutFailed:return nt(e,{executePaymentMethodCheckoutError:t.payload,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Gt.WidgetInteractionStarted:case Gt.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Gt.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Kt(e=Vt.statuses,t){switch(t.type){case Gt.InitializeRequested:return nt(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case Gt.InitializeFailed:case Gt.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case Gt.DeinitializeRequested:return nt(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case Gt.DeinitializeFailed:case Gt.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Gt.SignInRequested:return nt(e,{isSigningIn:!0,signInMethodId:t.meta&&t.meta.methodId});case Gt.SignInFailed:case Gt.SignInSucceeded:return nt(e,{isSigningIn:!1,signInMethodId:void 0});case Gt.SignOutRequested:return nt(e,{isSigningOut:!0,signOutMethodId:t.meta&&t.meta.methodId});case Gt.SignOutFailed:case Gt.SignOutSucceeded:return nt(e,{isSigningOut:!1,signOutMethodId:void 0});case Gt.ExecutePaymentMethodCheckoutRequested:return nt(e,{isExecutingPaymentMethodCheckout:!0,executePaymentMethodCheckoutMethodId:t.meta&&t.meta.methodId});case Gt.ExecutePaymentMethodCheckoutFailed:case Gt.ExecutePaymentMethodCheckoutSucceeded:return nt(e,{isExecutingPaymentMethodCheckout:!1,executePaymentMethodCheckoutMethodId:void 0});case Gt.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Gt.WidgetInteractionFinished:case Gt.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var $t;!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"}($t||($t={}));const Zt={errors:{},statuses:{}};function Jt(e=Zt,t){return i({data:Qt,errors:r(Xt,ze),statuses:en})(e,t)}function Qt(e,t){var n;return t.type===$t.LoadExtensionsSucceeded?tt(e,t.payload):t.type===He.HydrateInitialState?tt(e,null===(n=t.payload)||void 0===n?void 0:n.extensions):e}function Xt(e=Zt.errors,t){switch(t.type){case $t.LoadExtensionsRequested:case $t.LoadExtensionsSucceeded:return Fe(e,"loadError",void 0);case $t.RenderExtensionRequested:case $t.RenderExtensionSucceeded:return Fe(e,"renderError",void 0);case $t.LoadExtensionsFailed:return Fe(e,"loadError",t.payload);case $t.RenderExtensionFailed:return Fe(e,"renderError",t.payload);default:return e}}function en(e=Zt.statuses,t){switch(t.type){case $t.LoadExtensionsRequested:return Fe(e,"isLoading",!0);case $t.LoadExtensionsSucceeded:case $t.LoadExtensionsFailed:return Fe(e,"isLoading",!1);default:return e}}var tn;!function(e){e.LoadFormFieldsRequested="LOAD_FORM_FIELDS_REQUESTED",e.LoadFormFieldsSucceeded="LOAD_FORM_FIELDS_SUCCEEDED",e.LoadFormFieldsFailed="LOAD_FORM_FIELDS_FAILED"}(tn||(tn={}));const nn={errors:{},statuses:{}};function rn(e=nn,t){return i({data:on,extraFields:an,errors:r(sn,ze),statuses:dn})(e,t)}function on(e,t){var n;switch(t.type){case tn.LoadFormFieldsSucceeded:return nt(e,t.payload);case He.HydrateInitialState:return nt(e,null===(n=t.payload)||void 0===n?void 0:n.formFields);default:return e}}function an(e,t){var n,i;return t.type===He.HydrateInitialState&&null!==(i=null===(n=t.payload)||void 0===n?void 0:n.extraFields)&&void 0!==i?i:e}function sn(e=nn.errors,t){switch(t.type){case tn.LoadFormFieldsSucceeded:return Fe(e,"loadError",void 0);case tn.LoadFormFieldsFailed:return Fe(e,"loadError",t.payload);default:return e}}function dn(e=nn.statuses,t){switch(t.type){case tn.LoadFormFieldsRequested:return Fe(e,"isLoading",!0);case tn.LoadFormFieldsSucceeded:case tn.LoadFormFieldsFailed:return Fe(e,"isLoading",!1);default:return e}}var cn;!function(e){e.LoadCountriesRequested="LOAD_COUNTRIES_REQUESTED",e.LoadCountriesSucceeded="LOAD_COUNTRIES_SUCCEEDED",e.LoadCountriesFailed="LOAD_COUNTRIES_FAILED"}(cn||(cn={}));const un={errors:{},statuses:{}};function ln(e=un,t){return i({data:hn,errors:r(pn,ze),statuses:gn})(e,t)}function hn(e,t){return t.type===cn.LoadCountriesSucceeded?tt(e,t.payload):e}function pn(e=un.errors,t){switch(t.type){case cn.LoadCountriesRequested:case cn.LoadCountriesSucceeded:return Fe(e,"loadError",void 0);case cn.LoadCountriesFailed:return Fe(e,"loadError",t.payload);default:return e}}function gn(e=un.statuses,t){switch(t.type){case cn.LoadCountriesRequested:return Fe(e,"isLoading",!0);case cn.LoadCountriesSucceeded:case cn.LoadCountriesFailed:return Fe(e,"isLoading",!1);default:return e}}const mn={errors:{},meta:{},statuses:{}};function yn(e=mn,t){return i({data:fn,errors:r(Sn,ze),meta:_n,statuses:vn})(e,t)}function fn(e,t){switch(t.type){case Pt.LoadOrderSucceeded:case Pt.LoadOrderPaymentsSucceeded:return nt(e,k(t.payload,["billingAddress","coupons"]));default:return e}}function _n(e,t){var n,i;switch(t.type){case Pt.FinalizeOrderSucceeded:case Pt.SubmitOrderSucceeded:return nt(e,Object.assign(Object.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,b2bReceiptId:null===(i=null===(n=t.payload)||void 0===n?void 0:n.b2bContext)||void 0===i?void 0:i.receiptId}));default:return e}}function Sn(e=mn.errors,t){switch(t.type){case Pt.LoadOrderRequested:case Pt.LoadOrderSucceeded:case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderPaymentsRequested:return Fe(e,"loadError",void 0);case Pt.LoadOrderFailed:case Pt.LoadOrderPaymentsFailed:return Fe(e,"loadError",t.payload);default:return e}}function vn(e=mn.statuses,t){switch(t.type){case Pt.LoadOrderRequested:case Pt.LoadOrderPaymentsRequested:return Fe(e,"isLoading",!0);case Pt.LoadOrderSucceeded:case Pt.LoadOrderFailed:case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderPaymentsFailed:return Fe(e,"isLoading",!1);default:return e}}const Cn={};function In(e=Cn,t){return i({data:wn})(e,t)}function wn(e,t){switch(t.type){case Pt.LoadOrderPaymentsSucceeded:case Pt.LoadOrderSucceeded:return Ke(e,t.payload&&t.payload.billingAddress);default:return e}}var bn,En;function Pn(e={},t){return i({data:On})(e,t)}function On(e,t){return t.type===bn.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"}(bn||(bn={})),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"}(En||(En={}));const An={errors:{},statuses:{}};function Tn(e=An,t){return i({data:kn,errors:r(Dn,ze),meta:Rn,statuses:Mn})(e,t)}function kn(e,t){switch(t.type){case En.LoadPaymentMethodSucceeded:return function(e,t,n){if(!t)return e;const i=D(t,"id"),r="object"==typeof n?M(n):n||i,o=h(e,r),a=[...e];if(-1===o)a.push(t);else{const n=e[o];a[o]=et(n)&&et(t)?nt(n,t):t}return a}(e||[],t.payload,t.payload&&{id:t.payload.id,gateway:t.payload.gateway});case En.LoadPaymentMethodsSucceeded:return tt(e,t.payload,{matchObject:(e,t)=>e.id===t.id&&e.gateway===t.gateway});default:return e}}function Rn(e,t){return t.type===En.LoadPaymentMethodsSucceeded?nt(e,t.meta):e}function Dn(e=An.errors,t){switch(t.type){case En.LoadPaymentMethodsRequested:case En.LoadPaymentMethodsSucceeded:return Fe(e,"loadError",void 0);case En.LoadPaymentMethodsFailed:return Fe(e,"loadError",t.payload);case En.LoadPaymentMethodRequested:case En.LoadPaymentMethodSucceeded:return nt(e,{loadMethodId:void 0,loadMethodError:void 0});case En.LoadPaymentMethodFailed:return nt(e,{loadMethodId:t.meta.methodId,loadMethodError:t.payload});default:return e}}function Mn(e=An.statuses,t){switch(t.type){case En.LoadPaymentMethodsRequested:return Fe(e,"isLoading",!0);case En.LoadPaymentMethodsSucceeded:case En.LoadPaymentMethodsFailed:return Fe(e,"isLoading",!1);case En.LoadPaymentMethodRequested:return nt(e,{isLoadingMethod:!0,loadMethodId:t.meta.methodId});case En.LoadPaymentMethodSucceeded:case En.LoadPaymentMethodFailed:return nt(e,{isLoadingMethod:!1,loadMethodId:void 0});default:return e}}var Nn;!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"}(Nn||(Nn={}));const Ln={data:{},errors:{},statuses:{}};function zn(e=Ln,t){return i({data:Un,errors:r(Fn,ze),statuses:Bn})(e,t)}function Un(e=Ln.data,t){switch(t.type){case Nn.InitializeSucceeded:if(t.meta){const{methodId:n,gatewayId:i}=t.meta,r=i?`${n}.${i}`:n;return nt(e,{[r]:{isInitialized:!0}})}break;case Nn.DeinitializeSucceeded:if(t.meta){const{methodId:n,gatewayId:i}=t.meta,r=i?`${n}.${i}`:n;return nt(e,{[r]:{isInitialized:!1}})}}return e}function Fn(e=Ln.errors,t){switch(t.type){case Nn.InitializeRequested:case Nn.InitializeSucceeded:return nt(e,{initializeError:void 0,initializeMethodId:void 0});case Nn.InitializeFailed:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{initializeError:t.payload,initializeMethodId:n})}case Nn.DeinitializeRequested:case Nn.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case Nn.DeinitializeFailed:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{deinitializeError:t.payload,deinitializeMethodId:n})}case Nn.ExecuteRequested:case Nn.ExecuteSucceeded:return nt(e,{executeError:void 0,executeMethodId:void 0});case Nn.ExecuteFailed:return nt(e,{executeError:t.payload,executeMethodId:t.meta&&t.meta.methodId});case Nn.FinalizeRequested:case Nn.FinalizeSucceeded:return nt(e,{finalizeError:void 0,finalizeMethodId:void 0});case Nn.FinalizeFailed:return nt(e,{finalizeError:t.payload,finalizeMethodId:t.meta&&t.meta.methodId});case Nn.WidgetInteractionStarted:case Nn.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case Nn.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta.methodId});default:return e}}function Bn(e=Ln.statuses,t){switch(t.type){case Nn.InitializeRequested:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{isInitializing:!0,initializeMethodId:n})}case Nn.InitializeFailed:case Nn.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case Nn.DeinitializeRequested:{let n=t.meta&&t.meta.methodId;if(t.meta){const{methodId:e,gatewayId:i}=t.meta;n=i?`${e}.${i}`:e}return nt(e,{isDeinitializing:!0,deinitializeMethodId:n})}case Nn.DeinitializeFailed:case Nn.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case Nn.ExecuteRequested:return nt(e,{isExecuting:!0,executeMethodId:t.meta&&t.meta.methodId});case Nn.ExecuteFailed:case Nn.ExecuteSucceeded:return nt(e,{isExecuting:!1,executeMethodId:void 0});case Nn.FinalizeRequested:return nt(e,{isFinalizing:!0,finalizeMethodId:t.meta&&t.meta.methodId});case Nn.FinalizeFailed:case Nn.FinalizeSucceeded:return nt(e,{isFinalizing:!1,finalizeMethodId:void 0});case Nn.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta.methodId});case Nn.WidgetInteractionFinished:case Nn.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var xn;!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"}(xn||(xn={}));const qn={data:[],errors:{},statuses:{}};function jn(e=qn,t){return i({data:Gn,errors:r(Hn,ze),meta:Vn,statuses:Wn})(e,t)}function Gn(e=qn.data,t){return t.type===xn.LoadInstrumentsSucceeded?tt(e,t.payload&&t.payload.vaultedInstruments||[]):e}function Vn(e,t){switch(t.type){case xn.LoadInstrumentsSucceeded:case xn.DeleteInstrumentSucceeded:return nt(e,t.meta);default:return e}}function Hn(e=qn.errors,t){switch(t.type){case xn.LoadInstrumentsRequested:case xn.LoadInstrumentsSucceeded:return Fe(e,"loadError",void 0);case xn.DeleteInstrumentRequested:case xn.DeleteInstrumentSucceeded:return nt(e,{deleteError:void 0,failedInstrument:void 0});case xn.LoadInstrumentsFailed:return Fe(e,"loadError",t.payload);case xn.DeleteInstrumentFailed:return nt(e,{deleteError:t.payload,failedInstrument:t.meta.instrumentId});default:return e}}function Wn(e=qn.statuses,t){switch(t.type){case xn.LoadInstrumentsRequested:return Fe(e,"isLoading",!0);case xn.DeleteInstrumentRequested:return nt(e,{isDeleting:!0,deletingInstrument:t.meta.instrumentId});case xn.LoadInstrumentsSucceeded:case xn.LoadInstrumentsFailed:return Fe(e,"isLoading",!1);case xn.DeleteInstrumentSucceeded:case xn.DeleteInstrumentFailed:return nt(e,{isDeleting:!1,deletingInstrument:void 0});default:return e}}var Yn;!function(e){e.UpdatePaymentProviderCustomer="UPDATE_PAYMENT_PROVIDER_CUSTOMER"}(Yn||(Yn={}));const Kn={data:{}};function $n(e=Kn,t){return i({data:Zn})(e,t)}function Zn(e=Kn.data,t){return t.type===Yn.UpdatePaymentProviderCustomer?nt(e,t.payload):e}var Jn;!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"}(Jn||(Jn={}));const Qn={data:{}};function Xn(e=Qn,t){return t.meta&&t.meta.methodId?i({data:i({[t.meta.methodId]:ei})})(e,t):e}function ei(e,t){switch(t.type){case Jn.InitializeRemoteBillingSucceeded:return Fe(e,"billing",t.payload&&t.payload.billing);case Jn.InitializeRemoteShippingSucceeded:return Fe(e,"shipping",t.payload&&t.payload.shipping);case Jn.LoadRemoteSettingsSucceeded:return Fe(e,"settings",t.payload);case Jn.UpdateRemoteCheckout:return nt(e,t.payload);default:return e}}const ti={errors:{updateShippingOptionError:{},updateError:{},deleteError:{}},statuses:{isUpdating:{},isUpdatingShippingOption:{},isDeleting:{}}};function ni(e=ti,t){return i({data:ii,errors:r(ri,ze),statuses:oi})(e,t)}function ii(e,t){var n,i;switch(t.type){case Ve.LoadCheckoutSucceeded:case ot.LoadShippingOptionsSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:return tt(e,t.payload&&t.payload.consignments);case Ut.SignOutCustomerSucceeded:return tt(e,[]);case He.HydrateInitialState:return tt(e,null===(i=null===(n=t.payload)||void 0===n?void 0:n.checkout)||void 0===i?void 0:i.consignments);default:return e}}function ri(e=ti.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:case ot.LoadShippingOptionsSucceeded:case ot.LoadShippingOptionsRequested:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:case ot.LoadShippingOptionsFailed:return Fe(e,"loadError",t.payload);case ot.CreateConsignmentsRequested:case ot.CreateConsignmentsSucceeded:return Fe(e,"createError",void 0);case ot.CreateConsignmentsFailed:return Fe(e,"createError",t.payload);case ot.UpdateConsignmentSucceeded:case ot.UpdateConsignmentRequested:return t.meta?nt(e,{updateError:{[t.meta.id]:void 0}}):e;case ot.UpdateConsignmentFailed:return t.meta?nt(e,{updateError:{[t.meta.id]:t.payload}}):e;case ot.DeleteConsignmentSucceeded:case ot.DeleteConsignmentRequested:return t.meta?nt(e,{deleteError:{[t.meta.id]:void 0}}):e;case ot.DeleteConsignmentFailed:return t.meta?nt(e,{deleteError:{[t.meta.id]:t.payload}}):e;case ot.UpdateShippingOptionRequested:case ot.UpdateShippingOptionSucceeded:return t.meta?nt(e,{updateShippingOptionError:{[t.meta.id]:void 0}}):e;case ot.UpdateShippingOptionFailed:return t.meta?nt(e,{updateShippingOptionError:{[t.meta.id]:t.payload}}):e;default:return e}}function oi(e=ti.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case ot.LoadShippingOptionsRequested:return Fe(e,"isLoadingShippingOptions",!0);case Ve.LoadCheckoutSucceeded:case Ve.LoadCheckoutFailed:return Fe(e,"isLoading",!1);case ot.LoadShippingOptionsSucceeded:case ot.LoadShippingOptionsFailed:return Fe(e,"isLoadingShippingOptions",!1);case ot.CreateConsignmentsRequested:return Fe(e,"isCreating",!0);case ot.CreateConsignmentsSucceeded:case ot.CreateConsignmentsFailed:return Fe(e,"isCreating",!1);case ot.UpdateConsignmentRequested:return t.meta?nt(e,{isUpdating:{[t.meta.id]:!0}}):e;case ot.UpdateConsignmentSucceeded:case ot.UpdateConsignmentFailed:return t.meta?nt(e,{isUpdating:{[t.meta.id]:!1}}):e;case ot.DeleteConsignmentRequested:return t.meta?nt(e,{isDeleting:{[t.meta.id]:!0}}):e;case ot.DeleteConsignmentSucceeded:case ot.DeleteConsignmentFailed:return t.meta?nt(e,{isDeleting:{[t.meta.id]:!1}}):e;case ot.UpdateShippingOptionRequested:return t.meta?nt(e,{isUpdatingShippingOption:{[t.meta.id]:!0}}):e;case ot.UpdateShippingOptionSucceeded:case ot.UpdateShippingOptionFailed:return t.meta?nt(e,{isUpdatingShippingOption:{[t.meta.id]:!1}}):e;default:return e}}function ai(e,t){const n={};return Object.keys(e).forEach(i=>{const r=e[i],o=t?`${t}.${i}`:i;"object"==typeof r?Object.assign(n,ai(r,o)):n[o]=r}),n}function si(e){return Object.keys(e).sort().reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:e[n]}),{})}var di;!function(e){e.LoadPickupOptionsRequested="LOAD_PICKUP_OPTIONS_REQUESTED",e.LoadPickupOptionsSucceeded="LOAD_PICKUP_OPTIONS_SUCCEEDED",e.LoadPickupOptionsFailed="LOAD_PICKUP_OPTIONS_FAILED"}(di||(di={}));const ci={errors:{},statuses:{}};function ui(e=ci,t){return i({data:li,errors:r(hi,ze),statuses:pi})(e,t)}function li(e,t){if(t.type!==di.LoadPickupOptionsSucceeded)return e;if(t.meta){const n=si(ai({consignmentId:t.meta.consignmentId,searchArea:t.meta.searchArea}));return Fe(e,btoa(`${JSON.stringify(n)}`),t.payload)}}function hi(e=ci.errors,t){switch(t.type){case di.LoadPickupOptionsRequested:case di.LoadPickupOptionsSucceeded:return Fe(e,"loadError",void 0);case di.LoadPickupOptionsFailed:return Fe(e,"loadError",t.payload);default:return e}}function pi(e=ci.statuses,t){switch(t.type){case di.LoadPickupOptionsRequested:return Fe(e,"isLoading",!0);case di.LoadPickupOptionsSucceeded:case di.LoadPickupOptionsFailed:return Fe(e,"isLoading",!1);default:return e}}var gi;!function(e){e.LoadShippingCountriesRequested="LOAD_SHIPPING_COUNTRIES_REQUESTED",e.LoadShippingCountriesSucceeded="LOAD_SHIPPING_COUNTRIES_SUCCEEDED",e.LoadShippingCountriesFailed="LOAD_SHIPPING_COUNTRIES_FAILED"}(gi||(gi={}));const mi={errors:{},statuses:{}};function yi(e=mi,t){return i({data:fi,errors:r(_i,ze),statuses:Si})(e,t)}function fi(e,t){return t.type===gi.LoadShippingCountriesSucceeded?tt(e,t.payload):e}function _i(e=mi.errors,t){switch(t.type){case gi.LoadShippingCountriesRequested:case gi.LoadShippingCountriesSucceeded:return Fe(e,"loadError",void 0);case gi.LoadShippingCountriesFailed:return Fe(e,"loadError",t.payload);default:return e}}function Si(e=mi.statuses,t){switch(t.type){case gi.LoadShippingCountriesRequested:return Fe(e,"isLoading",!0);case gi.LoadShippingCountriesSucceeded:case gi.LoadShippingCountriesFailed:return Fe(e,"isLoading",!1);default:return e}}var vi;!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"}(vi||(vi={}));const Ci={data:{},errors:{},statuses:{}};function Ii(e=Ci,t){return i({data:wi,errors:r(bi,ze),statuses:Ei})(e,t)}function wi(e=Ci.data,t){switch(t.type){case vi.InitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!0}});case vi.DeinitializeSucceeded:return nt(e,{[t.meta&&t.meta.methodId]:{isInitialized:!1}})}return e}function bi(e=Ci.errors,t){switch(t.type){case vi.InitializeRequested:case vi.InitializeSucceeded:return nt(e,{initializeError:void 0,initializeMethodId:void 0});case vi.InitializeFailed:return nt(e,{initializeError:t.payload,initializeMethodId:t.meta&&t.meta.methodId});case vi.DeinitializeRequested:case vi.DeinitializeSucceeded:return nt(e,{deinitializeError:void 0,deinitializeMethodId:void 0});case vi.DeinitializeFailed:return nt(e,{deinitializeError:t.payload,deinitializeMethodId:t.meta&&t.meta.methodId});case vi.UpdateAddressRequested:case vi.UpdateAddressSucceeded:return nt(e,{updateAddressError:void 0,updateAddressMethodId:void 0});case vi.UpdateAddressFailed:return nt(e,{updateAddressError:t.payload,updateAddressMethodId:t.meta&&t.meta.methodId});case vi.SelectOptionRequested:case vi.SelectOptionSucceeded:return nt(e,{selectOptionError:void 0,selectOptionMethodId:void 0});case vi.SelectOptionFailed:return nt(e,{selectOptionError:t.payload,selectOptionMethodId:t.meta&&t.meta.methodId});case vi.WidgetInteractionStarted:case vi.WidgetInteractionFinished:return nt(e,{widgetInteractionError:void 0,widgetInteractionMethodId:void 0});case vi.WidgetInteractionFailed:return nt(e,{widgetInteractionError:t.payload,widgetInteractionMethodId:t.meta&&t.meta.methodId});default:return e}}function Ei(e=Ci.statuses,t){switch(t.type){case vi.InitializeRequested:return nt(e,{isInitializing:!0,initializeMethodId:t.meta&&t.meta.methodId});case vi.InitializeFailed:case vi.InitializeSucceeded:return nt(e,{isInitializing:!1,initializeMethodId:void 0});case vi.DeinitializeRequested:return nt(e,{isDeinitializing:!0,deinitializeMethodId:t.meta&&t.meta.methodId});case vi.DeinitializeFailed:case vi.DeinitializeSucceeded:return nt(e,{isDeinitializing:!1,deinitializeMethodId:void 0});case vi.UpdateAddressRequested:return nt(e,{isUpdatingAddress:!0,updateAddressMethodId:t.meta&&t.meta.methodId});case vi.UpdateAddressFailed:case vi.UpdateAddressSucceeded:return nt(e,{isUpdatingAddress:!1,updateAddressMethodId:void 0});case vi.SelectOptionRequested:return nt(e,{isSelectingOption:!0,selectOptionMethodId:t.meta&&t.meta.methodId});case vi.SelectOptionFailed:case vi.SelectOptionSucceeded:return nt(e,{isSelectingOption:!1,selectOptionMethodId:void 0});case vi.WidgetInteractionStarted:return nt(e,{isWidgetInteracting:!0,widgetInteractionMethodId:t.meta&&t.meta.methodId});case vi.WidgetInteractionFinished:case vi.WidgetInteractionFailed:return nt(e,{isWidgetInteracting:!1,widgetInteractionMethodId:void 0});default:return e}}var Pi;!function(e){e.SendSignInEmailRequested="SEND_SIGNIN_EMAIL_REQUESTED",e.SendSignInEmailSucceeded="SEND_SIGNIN_EMAIL_SUCCEEDED",e.SendSignInEmailFailed="SEND_SIGNIN_EMAIL_FAILED"}(Pi||(Pi={}));const Oi={errors:{},statuses:{}};function Ai(e=Oi,t){return i({data:Ti,errors:r(ki,ze),statuses:Ri})(e,t)}function Ti(e,t){return t.type===Pi.SendSignInEmailSucceeded?nt(e,t.payload):e}function ki(e=Oi.errors,t){switch(t.type){case Pi.SendSignInEmailRequested:case Pi.SendSignInEmailSucceeded:return Fe(e,"sendError",void 0);case Pi.SendSignInEmailFailed:return Fe(e,"sendError",t.payload);default:return e}}function Ri(e=Oi.statuses,t){switch(t.type){case Pi.SendSignInEmailRequested:return Fe(e,"isSending",!0);case Pi.SendSignInEmailFailed:case Pi.SendSignInEmailSucceeded:return Fe(e,"isSending",!1);default:return e}}var Di;!function(e){e.ApplyStoreCreditRequested="APPLY_STORE_CREDIT_REQUESTED",e.ApplyStoreCreditSucceeded="APPLY_STORE_CREDIT_SUCCEEDED",e.ApplyStoreCreditFailed="APPLY_STORE_CREDIT_FAILED"}(Di||(Di={}));const Mi={errors:{},statuses:{}};function Ni(e=Mi,t){return i({errors:r(Li,ze),statuses:zi})(e,t)}function Li(e=Mi.errors,t){switch(t.type){case Di.ApplyStoreCreditRequested:case Di.ApplyStoreCreditSucceeded:return Fe(e,"applyError",void 0);case Di.ApplyStoreCreditFailed:return Fe(e,"applyError",t.payload);default:return e}}function zi(e=Mi.statuses,t){switch(t.type){case Di.ApplyStoreCreditRequested:return Fe(e,"isApplying",!0);case Di.ApplyStoreCreditSucceeded:case Di.ApplyStoreCreditFailed:return Fe(e,"isApplying",!1);default:return e}}const Ui={errors:{},statuses:{}};function Fi(e=Ui,t){return i({errors:r(Bi,ze),statuses:xi})(e,t)}function Bi(e=Ui.errors,t){switch(t.type){case We.UpdateSubscriptionsRequested:case We.UpdateSubscriptionsSucceeded:return Fe(e,"updateError",void 0);case We.UpdateSubscriptionsFailed:return Fe(e,"updateError",t.payload);default:return e}}function xi(e=Ui.statuses,t){switch(t.type){case We.UpdateSubscriptionsRequested:return Fe(e,"isUpdating",!0);case We.UpdateSubscriptionsFailed:case We.UpdateSubscriptionsSucceeded:return Fe(e,"isUpdating",!1);default:return e}}var qi;!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"}(qi||(qi={}));const ji={errors:{},statuses:{}};function Gi(e=ji,t){return i({data:Vi,errors:r(Hi,ze),statuses:Wi})(e,t)}function Vi(e,t){var n;switch(t.type){case Ve.LoadCheckoutSucceeded:case Ve.UpdateCheckoutSucceeded:case Di.ApplyStoreCreditSucceeded:case Ye.UpdateBillingAddressSucceeded:case it.ApplyCouponSucceeded:case it.RemoveCouponSucceeded:case ot.CreateConsignmentsSucceeded:case ot.UpdateConsignmentSucceeded:case ot.DeleteConsignmentSucceeded:case ot.UpdateShippingOptionSucceeded:case ot.LoadShippingOptionsSucceeded:case rt.ApplyGiftCertificateSucceeded:case rt.RemoveGiftCertificateSucceeded:case qi.VerifyCheckoutSucceeded:return nt(e,k(t.payload,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));case Ve.DeleteCheckoutSucceeded:return;case Pt.SubmitOrderSucceeded:return Fe(e,"orderId",t.payload&&t.payload.order.orderId);case He.HydrateInitialState:return nt(e,k(null===(n=t.payload)||void 0===n?void 0:n.checkout,["billingAddress","cart","consignments","customer","coupons","giftCertificates"]));default:return e}}function Hi(e=ji.errors,t){switch(t.type){case Ve.LoadCheckoutRequested:case Ve.LoadCheckoutSucceeded:return Fe(e,"loadError",void 0);case Ve.LoadCheckoutFailed:return Fe(e,"loadError",t.payload);case Ve.UpdateCheckoutRequested:case Ve.UpdateCheckoutSucceeded:return Fe(e,"updateError",void 0);case Ve.UpdateCheckoutFailed:return Fe(e,"updateError",t.payload);case Ve.DeleteCheckoutRequested:case Ve.DeleteCheckoutSucceeded:return Fe(e,"deleteError",void 0);case Ve.DeleteCheckoutFailed:return Fe(e,"deleteError",t.payload);default:return e}}function Wi(e=ji.statuses,t){switch(t.type){case Ve.LoadCheckoutRequested:return Fe(e,"isLoading",!0);case Ve.LoadCheckoutFailed:case Ve.LoadCheckoutSucceeded:return Fe(e,"isLoading",!1);case Ve.UpdateCheckoutRequested:return Fe(e,"isUpdating",!0);case Ve.UpdateCheckoutFailed:case Ve.UpdateCheckoutSucceeded:return Fe(e,"isUpdating",!1);case Ve.DeleteCheckoutRequested:return Fe(e,"isDeleting",!0);case Ve.DeleteCheckoutFailed:case Ve.DeleteCheckoutSucceeded:return Fe(e,"isDeleting",!1);case qi.ExecuteRequested:return Fe(e,"isExecutingSpamCheck",!0);case qi.ExecuteFailed:case qi.ExecuteSucceeded:return Fe(e,"isExecutingSpamCheck",!1);default:return e}}const Yi=(Ki=de,(...e)=>{const t=e.pop();return Ki(...e,(...e)=>{const n=t(...e);return"function"==typeof n?ae(n):n})});var Ki,$i;!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"}($i||($i={}));class Zi extends be{constructor(e){super(function(e){switch(e){case $i.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case $i.MissingCart:return"Unable to proceed because cart data is unavailable.";case $i.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case $i.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case $i.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case $i.MissingCheckoutConfig:case $i.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case $i.MissingOrder:return"Unable to proceed because order data is unavailable.";case $i.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case $i.MissingPayment:return"Unable to proceed because payment data is unavailable.";case $i.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case $i.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case $i.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case $i.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function Ji(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}function Qi(e){return function(e){const t=Object.create(e);return function(e,t){let n=Object.getPrototypeOf(e);for(;n;)t(n),n=Object.getPrototypeOf(n)}(e,n=>{Object.getOwnPropertyNames(n).forEach(n=>{"constructor"!==n&&"function"==typeof t[n]&&"_"!==n.charAt(0)&&(t[n]=((e,t)=>(...n)=>d(e[t].call(e,...n)))(e,n))})}),t}(e)}const Xi="b2bExtraField_";function er(e){var t;const{fieldType:n,type:i}=function(e){switch(e){case"multiline_text":return{fieldType:"multiline",type:"string"};case"number":return{fieldType:"text",type:"integer"};case"dropdown":return{fieldType:"dropdown",type:"array"};default:return{fieldType:"text",type:"string"}}}(e.type);let r;return e.config.numberOfRows&&(r={rows:e.config.numberOfRows}),(null===(t=e.config.options)||void 0===t?void 0:t.length)&&(r=Object.assign(Object.assign({},r),{items:e.config.options.map(e=>({value:e,label:e}))})),{id:`${Xi}${e.id}`,name:`${Xi}${e.id}`,custom:!1,label:e.name,hidden:!e.visibleToStorefront,required:e.isRequired,default:null!=e.config.defaultValue?String(e.config.defaultValue):void 0,fieldType:n,type:i,maxLength:e.config.maxLength,max:e.config.maxValue,options:r}}const tr={"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"},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"},moneris:{provider:"moneris",method:"credit_card"},cba_mpgs:{provider:"cba_mpgs",method:"credit_card"},worldpayaccess:{provider:"worldpayaccess",method:"credit_card"},"worldpayaccess.credit_card":{provider:"worldpayaccess",method:"credit_card"},squarev2:{provider:"squarev2",method:"credit_card"},paypalcommercecreditcards:{provider:"paypalcommerce",method:"credit_card"},paypalcommerce:{provider:"paypalcommerce",method:"paypal"},bigcommerce_payments_creditcards:{provider:"bigcommerce_payments",method:"credit_card"},bigcommerce_payments:{provider:"bigcommerce_payments",method:"paypal"},tdonlinemart:{provider:"tdonlinemart",method:"credit_card"}};function nr(e){return M({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},g)}const ir={errors:{},statuses:{}};function rr(){const e=function(){const e=Yi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.token},e=>()=>e),t=Yi(e=>e.errors.loadError,e=>()=>e),n=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=Be)=>({getToken:e(i),getLoadError:t(i),isLoading:n(i)}))}(),t=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingBillingAddress))),n=Yi(e=>e.errors.updateError,e=>()=>e),i=Yi(e=>e.errors.continueAsGuestError,e=>()=>e),r=Yi(e=>e.errors.loadError,e=>()=>e),o=Yi(e=>!!e.statuses.isUpdating,e=>()=>e),a=Yi(e=>!!e.statuses.isContinuingAsGuest,e=>()=>e),s=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((d=$e)=>({getBillingAddress:e(d),getBillingAddressOrThrow:t(d),getUpdateError:n(d),getContinueAsGuestError:i(d),getLoadError:r(d),isUpdating:o(d),isContinuingAsGuest:a(d),isLoading:s(d)}))}(),n=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingCart))),n=Yi(e=>e.errors.loadError,e=>()=>e),i=Yi(e=>!!e.statuses.isLoading,e=>()=>e),r=Yi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.locale},e=>()=>e);return se((o=at)=>({getCart:e(o),getCartOrThrow:t(o),getLoadError:n(o),isLoading:i(o),getLocale:r(o)}))}(),i=function(){const e=Yi(e=>e,e=>()=>e),t=Yi(e=>e.statuses,e=>ae(t=>{if(t){const n=e[t];return!0===(n&&n.isInitializing)}return z(e,{isInitializing:!0})})),n=Yi(e=>e.data,e=>ae((t,n)=>{const i=e[t];return!!i&&(n?!0===i.initializedContainers[n]:z(i.initializedContainers,e=>!0===e))})),i=Yi(e=>e.statuses,e=>ae(t=>{if(t){const n=e[t];return!0===(n&&n.isDeinitializing)}return z(e,{isDeinitializing:!0})})),r=Yi(e=>e.errors,e=>ae(t=>{const n=t?e[t]:l(x(e),e=>!(!e||!e.initializeError));return n&&n.initializeError})),o=Yi(e=>e.errors,e=>ae(t=>{const n=t?e[t]:l(x(e),e=>!(!e||!e.deinitializeError));return n&&n.deinitializeError}));return se((a=ht)=>({getState:e(a),isInitializing:t(a),isInitialized:n(a),isDeinitializing:i(a),getInitializeError:r(a),getDeinitializeError:o(a)}))}(),r=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.data,e=>t=>{if(!e)return;const{flashMessages:n}=e.context;return n?void 0!==t?n.filter(({type:e})=>t===e):n:void 0}),n=Yi(e=>e.data,(e,{formState:t})=>t&&t.data,(e,t={customerAccount:[],shippingAddress:[],billingAddress:[]})=>()=>e?Object.assign(Object.assign({},e.storeConfig),{formFields:t}):void 0),i=Yi(n,e=>()=>Ji(e(),()=>new Zi($i.MissingCheckoutConfig))),r=Yi(e=>e.data&&e.data.context,e=>()=>e),o=Yi(e=>e.meta&&e.meta.externalSource,e=>()=>e),a=Yi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.host},e=>()=>e),s=Yi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.locale},e=>()=>e),d=Yi(e=>e.meta&&e.meta.variantIdentificationToken,e=>()=>e),c=Yi(e=>e.errors.loadError,e=>()=>e),u=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((l=Ct,h)=>({getConfig:e(l),getFlashMessages:t(l),getStoreConfig:n(l,{formState:h}),getStoreConfigOrThrow:i(l,{formState:h}),getContextConfig:r(l),getExternalSource:o(l),getHost:a(l),getLocale:s(l),getVariantIdentificationToken:d(l),getLoadError:c(l),isLoading:u(l)}))}(),o=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.loadError,e=>()=>e),n=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=un)=>({getCountries:e(i),getLoadError:t(i),isLoading:n(i)}))}(),a=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.removeCouponError,e=>()=>e),n=Yi(e=>e.errors.applyCouponError,e=>()=>e),i=Yi(e=>!!e.statuses.isApplyingCoupon,e=>()=>e),r=Yi(e=>!!e.statuses.isRemovingCoupon,e=>()=>e);return se((o=Ot)=>({getCoupons:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:i(o),isRemoving:r(o)}))}(),s=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingCustomer))),n=Yi(e=>e.errors.createError,e=>()=>e),i=Yi(e=>!!e.statuses.isCreating,e=>()=>e),r=Yi(e=>e.errors.createAddressError,e=>()=>e),o=Yi(e=>!!e.statuses.isCreatingAddress,e=>()=>e);return se((a=Ft)=>({getCustomer:e(a),getCustomerOrThrow:t(a),getCreateAccountError:n(a),isCreatingCustomerAccount:i(a),getCreateAddressError:r(a),isCreatingCustomerAddress:o(a)}))}(),d=function(){const e=Yi(e=>e.errors.signInMethodId,e=>e.errors.signInError,(e,t)=>n=>{if(!n||e===n)return t}),t=Yi(e=>e.errors.signOutMethodId,e=>e.errors.signOutError,(e,t)=>n=>{if(!n||e===n)return t}),n=Yi(e=>e.errors.executePaymentMethodCheckoutMethodId,e=>e.errors.executePaymentMethodCheckoutError,(e,t)=>n=>{if(!n||e===n)return t}),i=Yi(e=>e.errors.initializeMethodId,e=>e.errors.initializeErrors,(e,t)=>n=>{if(e&&t)return n?t[n]:t[e]}),r=Yi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),o=Yi(e=>e.statuses.signInMethodId,e=>e.statuses.isSigningIn,(e,t)=>n=>!(n&&e!==n||!t)),a=Yi(e=>e.statuses.signOutMethodId,e=>e.statuses.isSigningOut,(e,t)=>n=>!(n&&e!==n||!t)),s=Yi(e=>e.statuses.executePaymentMethodCheckoutMethodId,e=>e.statuses.isExecutingPaymentMethodCheckout,(e,t)=>n=>!(n&&e!==n||!t)),d=Yi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),c=Yi(e=>e.data,e=>t=>!(!e[t]||!e[t].isInitialized)),u=Yi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((l=Vt)=>({getSignInError:e(l),getSignOutError:t(l),getExecutePaymentMethodCheckoutError:n(l),getInitializeError:i(l),getWidgetInteractionError:r(l),isSigningIn:o(l),isSigningOut:a(l),isExecutingPaymentMethodCheckout:s(l),isInitializing:d(l),isInitialized:c(l),isWidgetInteracting:u(l)}))}(),c=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.removeGiftCertificateError,e=>()=>e),n=Yi(e=>e.errors.applyGiftCertificateError,e=>()=>e),i=Yi(e=>!!e.statuses.isApplyingGiftCertificate,e=>()=>e),r=Yi(e=>!!e.statuses.isRemovingGiftCertificate,e=>()=>e);return se((o=Dt)=>({getGiftCertificates:e(o),getRemoveError:t(o),getApplyError:n(o),isApplying:i(o),isRemoving:r(o)}))}(),h=function(){const e=Yi(e=>e.data,e=>t=>{if(!e)return;const n=t.gateway?`${t.gateway}.${t.id}`:t.id,i=tr[n];return i?u(e,i):[]}),t=Yi(e=>e.data,(e=[])=>t=>{const n=x(tr);return e.find(e=>e.bigpayToken===t&&"card"===e.type&&n.some(t=>S(e,t)))}),n=Yi(t,e=>t=>Ji(e(t),()=>new Zi($i.MissingPaymentInstrument))),i=Yi(e=>e.data,e=>()=>{if(e)return p(tr,t=>u(e,e=>S(e,t)))}),r=Yi(e=>e.meta,e=>()=>e),o=Yi(e=>e.errors.loadError,e=>()=>e),a=Yi(e=>e.errors.failedInstrument,e=>e.errors.deleteError,(e,t)=>n=>{if(!n||e===n)return t}),s=Yi(e=>e.statuses.isLoading,e=>()=>!!e),d=Yi(e=>e.statuses.deletingInstrument,e=>e.statuses.isDeleting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=qn)=>({getCardInstrument:t(c),getCardInstrumentOrThrow:n(c),getInstruments:i(c),getInstrumentsByPaymentMethod:e(c),getInstrumentsMeta:r(c),getLoadError:o(c),getDeleteError:a(c),isLoading:s(c),isDeleting:d(c)}))}(),g=function(){const e=Yi(e=>e.data,e=>(t=[],n)=>{const i=l(t,{code:n});return(e?e.shippingAddress:[]).map(e=>s(e,t,i))}),t=Yi(e=>e.data,e=>(t=[],n)=>{const i=l(t,{code:n});return(e?e.billingAddress:[]).map(e=>s(e,t,i))}),n=Yi(e=>e.data,e=>()=>e?e.customerAccount:[]),i=Yi(e=>e.extraFields,e=>()=>e&&e.address.length?e.address.map(er):[]),r=Yi(e=>e.extraFields,e=>()=>e&&e.order.length?e.order.map(er):[]),o=Yi(e=>e.errors.loadError,e=>()=>e),a=Yi(e=>!!e.statuses.isLoading,e=>()=>e);function s(e,t,n){return"countryCode"===e.name?function(e,t=[],n){if(!t.length)return e;const{code:i=""}=n||{},r=t.map(({code:e,name:t})=>({value:e,label:t}));return Object.assign(Object.assign({},e),{options:{items:r},default:i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,t,n):"stateOrProvince"===e.name?function(e,t){const{subdivisions:n=[],requiresState:i}=t||{};if(!n.length)return Object.assign(Object.assign({},e),{required:null!=i&&i});const r=n.map(({code:e,name:t})=>({value:e,label:t}));return Object.assign(Object.assign({},e),{name:"stateOrProvinceCode",options:{items:r},required:null==i||i,type:"array",fieldType:"dropdown",itemtype:"string"})}(e,n):"postalCode"===e.name?function(e,t){const{hasPostalCodes:n=[]}=t||{};return void 0===n?e:Object.assign(Object.assign({},e),{required:Boolean(n)})}(e,n):e}return se((s=nn)=>({getShippingAddressFields:e(s),getBillingAddressFields:t(s),getCustomerAccountFields:n(s),getAddressExtraFields:i(s),getOrderExtraFields:r(s),getLoadError:o(s),isLoading:a(s)}))}(),m=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.meta,e=>()=>e),n=Yi(e=>e.data,e=>(t,n)=>l(e,n?{id:t,gateway:n}:{id:t})),i=Yi(n,e=>(t,n)=>Ji(e(t,n),()=>new Zi($i.MissingPaymentMethod))),r=Yi(e=>e.errors.loadError,e=>()=>e),o=Yi(e=>e.errors.loadMethodId,e=>e.errors.loadMethodError,(e,t)=>n=>{if(!n||e===n)return t}),a=Yi(e=>e.statuses.isLoading,e=>()=>!!e),s=Yi(e=>e.statuses.loadMethodId,e=>e.statuses.isLoadingMethod,(e,t)=>n=>!(n&&e!==n||!t));return se((d=An)=>({getPaymentMethods:e(d),getPaymentMethodsMeta:t(d),getPaymentMethod:n(d),getPaymentMethodOrThrow:i(d),getLoadError:r(d),getLoadMethodError:o(d),isLoading:a(d),isLoadingMethod:s(d)}))}(),y=function(){const e=Yi(e=>e.errors.initializeMethodId,e=>e.errors.initializeError,(e,t)=>n=>{if(!n||e===n)return t}),t=Yi(e=>e.errors.executeMethodId,e=>e.errors.executeError,(e,t)=>n=>{if(!n||e===n)return t}),n=Yi(e=>e.errors.finalizeMethodId,e=>e.errors.finalizeError,(e,t)=>n=>{if(!n||e===n)return t}),i=Yi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),r=Yi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),o=Yi(e=>e.data,e=>t=>{const n=t.gatewayId?`${t.methodId}.${t.gatewayId}`:t.methodId;return!(!e[n]||!e[n].isInitialized)}),a=Yi(e=>e.statuses.executeMethodId,e=>e.statuses.isExecuting,(e,t)=>n=>!(n&&e!==n||!t)),s=Yi(e=>e.statuses.finalizeMethodId,e=>e.statuses.isFinalizing,(e,t)=>n=>!(n&&e!==n||!t)),d=Yi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=Ln)=>({getInitializeError:e(c),getExecuteError:t(c),getFinalizeError:n(c),getWidgetInteractingError:i(c),isInitializing:r(c),isInitialized:o(c),isExecuting:a(c),isFinalizing:s(c),isWidgetInteracting:d(c)}))}(),f=function(){const e=Yi(e=>e.data,e=>(t,n)=>{if(!e)return;const i=si(ai({consignmentId:t,searchArea:n})),r=btoa(`${JSON.stringify(i)}`);return e[r]}),t=Yi(e=>e.errors.loadError,e=>()=>e),n=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((i=ci)=>({getPickupOptions:e(i),getLoadError:t(i),isLoading:n(i)}))}(),v=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentProviderCustomer)));return se((n=Kn)=>({getPaymentProviderCustomer:e(n),getPaymentProviderCustomerOrThrow:t(n)}))}(),C=function(){const e=Yi(e=>e.data,e=>t=>e[t]);return se((t=Qn)=>({getCheckout:e(t)}))}(),I=function(){const e=Yi(e=>e.data,e=>()=>{const t=null==e?void 0:e.find(e=>!e.selectedPickupOption);return null==t?void 0:t.shippingAddress}),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingShippingAddress))),n=Yi(e=>e.data,e=>()=>{const t=null==e?void 0:e.filter(e=>!e.selectedPickupOption);return t?t.map(e=>e.shippingAddress):[]}),i=Yi(n,e=>()=>Ji(e(),()=>new Zi($i.MissingShippingAddress)));return se((r=ti)=>({getShippingAddress:e(r),getShippingAddressOrThrow:t(r),getShippingAddresses:n(r),getShippingAddressesOrThrow:i(r)}))}(),w=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.loadError,e=>()=>e),n=Yi(e=>e.statuses.isLoading,e=>()=>!!e);return se((i=mi)=>({getShippingCountries:e(i),getLoadError:t(i),isLoading:n(i)}))}(),b=function(){const e=Yi(e=>e.errors.updateAddressMethodId,e=>e.errors.updateAddressError,(e,t)=>n=>{if(!n||e===n)return t}),t=Yi(e=>e.errors.selectOptionMethodId,e=>e.errors.selectOptionError,(e,t)=>n=>{if(!n||e===n)return t}),n=Yi(e=>e.errors.initializeMethodId,e=>e.errors.initializeError,(e,t)=>n=>{if(!n||e===n)return t}),i=Yi(e=>e.errors.widgetInteractionMethodId,e=>e.errors.widgetInteractionError,(e,t)=>n=>{if(!n||e===n)return t}),r=Yi(e=>e.statuses.updateAddressMethodId,e=>e.statuses.isUpdatingAddress,(e,t)=>n=>!(n&&e!==n||!t)),o=Yi(e=>e.statuses.selectOptionMethodId,e=>e.statuses.isSelectingOption,(e,t)=>n=>!(n&&e!==n||!t)),a=Yi(e=>e.statuses.initializeMethodId,e=>e.statuses.isInitializing,(e,t)=>n=>!(n&&e!==n||!t)),s=Yi(e=>e.data,e=>t=>!(!e[t]||!e[t].isInitialized)),d=Yi(e=>e.statuses.widgetInteractionMethodId,e=>e.statuses.isWidgetInteracting,(e,t)=>n=>!(n&&e!==n||!t));return se((c=Ci)=>({getUpdateAddressError:e(c),getSelectOptionError:t(c),getInitializeError:n(c),getWidgetInteractionError:i(c),isUpdatingAddress:r(c),isSelectingOption:o(c),isInitializing:a(c),isInitialized:s(c),isWidgetInteracting:d(c)}))}(),E=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingConsignments))),n=Yi(e=>e.data,e=>t=>{if(e&&e.length)return l(e,{id:t})}),i=Yi(e=>e.data,e=>t=>{if(e&&e.length)return l(e,e=>{return n=e.shippingAddress,i=t,_(nr(n),nr(i));var n,i})}),r=Yi(e=>e.data,e=>()=>{if(e&&e.length)return e[0].selectedShippingOption}),o=Yi(e=>e.errors.loadError,e=>()=>e),a=Yi(e=>e.errors.createError,e=>()=>e),s=Yi(e=>e.errors.loadShippingOptionsError,e=>()=>e),d=Yi(e,(e,{cart:t})=>t.getCart,(e,t)=>()=>{const n=t();if(!n)return[];const i=(e()||[]).reduce((e,t)=>e.concat(t.lineItemIds),[]);return(n.lineItems.physicalItems||[]).filter(e=>i.indexOf(e.id)<0)}),c=Yi(e=>e.errors.updateError,e=>t=>t?e[t]:l(e)),u=Yi(e=>e.errors.deleteError,e=>t=>t?e[t]:l(e)),h=Yi(i,c,a,(e,t,n)=>i=>{const r=e(i);return r?t(r.id):n()}),p=Yi(e=>e.errors.updateShippingOptionError,e=>t=>t?e[t]:l(e)),g=Yi(e=>e.statuses.isLoading,e=>()=>!0===e),m=Yi(e=>e.statuses.isLoadingShippingOptions,e=>()=>!0===e),y=Yi(e=>e.statuses.isCreating,e=>()=>!0===e),f=Yi(e=>e.statuses.isUpdating,e=>t=>t?!0===e[t]:!0===l(e)),S=Yi(e=>e.statuses.isDeleting,e=>t=>t?!0===e[t]:!0===l(e)),v=Yi(i,f,y,(e,t,n)=>i=>{const r=e(i);return r?t(r.id):n()}),C=Yi(e=>e.statuses.isUpdatingShippingOption,e=>t=>t?!0===e[t]:!0===l(e));return se((l=ti,_)=>({getConsignments:e(l),getConsignmentsOrThrow:t(l),getConsignmentById:n(l),getConsignmentByAddress:i(l),getShippingOption:r(l),getLoadError:o(l),getCreateError:a(l),getLoadShippingOptionsError:s(l),getUnassignedItems:d(l,{cart:_}),getUpdateError:c(l),getDeleteError:u(l),getItemAssignmentError:h(l),getUpdateShippingOptionError:p(l),isLoading:g(l),isLoadingShippingOptions:m(l),isCreating:y(l),isUpdating:f(l),isDeleting:S(l),isAssigningItems:v(l),isUpdatingShippingOption:C(l)}))}(),P=function(){const e=Yi(e=>e.data,(e,{billingAddress:t})=>t.getBillingAddress,(e,{cart:t})=>t.getCart,(e,{customer:t})=>t.getCustomer,(e,{consignments:t})=>t.getConsignments,(e,{coupons:t})=>t.getCoupons,(e,{giftCertificates:t})=>t.getGiftCertificates,(e,t,n,i,r,o,a)=>()=>{const s=t(),d=n(),c=i(),u=r()||[],l=o()||[],h=a()||[];if(e&&d&&c)return Object.assign(Object.assign({},e),{billingAddress:s,cart:d,customer:c,consignments:u,coupons:l,giftCertificates:h})}),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingCheckout))),n=Yi(e,e=>t=>{const n=e();if(!n)return;const i=n.grandTotal||0,r=n.customer.storeCredit||0;return t?Math.max(i-r,0):n.outstandingBalance}),i=Yi(e=>e.errors.loadError,e=>()=>e),r=Yi(e=>e.errors.updateError,e=>()=>e),o=Yi(e=>e.errors.deleteError,e=>()=>e),a=Yi(e=>e.statuses.isExecutingSpamCheck,e=>()=>!0===e),s=Yi(e=>e.statuses.isLoading,e=>()=>!0===e),d=Yi(e=>e.statuses.isUpdating,e=>()=>!0===e),c=Yi(e=>e.statuses.isDeleting,e=>()=>!0===e);return se((u=ji,l,h,p,g,m,y)=>({getCheckout:e(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getCheckoutOrThrow:t(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getOutstandingBalance:n(u,{billingAddress:l,cart:h,consignments:p,coupons:g,customer:m,giftCertificates:y}),getLoadError:i(u),getUpdateError:r(u),getDeleteError:o(u),isExecutingSpamCheck:a(u),isLoading:s(u),isUpdating:d(u),isDeleting:c(u)}))}(),O=function(){const e=Yi(e=>e.data,(e,{billingAddress:t})=>t.getOrderBillingAddress(),(e,{coupons:t})=>t.getCoupons(),(e,t,n=[])=>()=>{if(e&&t)return Object.assign(Object.assign({},e),{billingAddress:t,coupons:n})}),t=Yi(e,e=>()=>Ji(e(),()=>new Zi($i.MissingOrder))),n=Yi(e=>e.meta,e=>()=>e),i=Yi(e=>{var t;return null===(t=e.meta)||void 0===t?void 0:t.b2bReceiptId},e=>()=>e),r=Yi(e=>e.errors.loadError,e=>()=>e),o=Yi(e=>{var t;return null===(t=e.data)||void 0===t?void 0:t.payments},(e=[])=>t=>{const n=e.find(({providerId:e})=>e===t);return null==n?void 0:n.paymentId}),a=Yi(e=>!!e.statuses.isLoading,e=>()=>e);return se((s=mn,d,c)=>({getOrder:e(s,{billingAddress:d,coupons:c}),getOrderOrThrow:t(s,{billingAddress:d,coupons:c}),getOrderMeta:n(s),getB2BReceiptId:i(s),getLoadError:r(s),getPaymentId:o(s),isLoading:a(s)}))}(),A=function(){const e=Yi(e=>e.data,e=>()=>e);return se((t=Cn)=>({getOrderBillingAddress:e(t)}))}(),T=function(){const e=Yi(({order:e})=>e.getOrderMeta,e=>()=>{const t=e();return t&&t.payment}),t=Yi(({order:e})=>e.getOrder,e=>()=>{const t=e();return l(t&&t.payments,({providerId:e})=>"giftcertificate"!==e&&"storecredit"!==e)}),n=Yi(({checkout:e})=>e.getCheckout,e=>()=>{const t=e();return l(t&&t.payments,({providerType:e})=>"PAYMENT_TYPE_HOSTED"===e)}),i=Yi(e,n,t,(e,t,n)=>()=>{const i=e();if(i&&i.id)return{providerId:i.id,gatewayId:i.gateway};const r=t()||n();return r&&r.providerId?{providerId:r.providerId,gatewayId:r.gatewayId}:void 0}),r=Yi(i,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentId))),o=Yi(e,n,t,(e,t,n)=>()=>{const i=e();if(i&&i.status)return i.status.replace("PAYMENT_STATUS_","");const r=t()||n();return r?r.detail.step:void 0}),a=Yi(o,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentStatus))),s=Yi(({order:e})=>e.getOrderMeta,e=>()=>{const t=e();return t&&t.token}),d=Yi(s,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentToken))),c=Yi(e,e=>()=>{const t=e();return t&&t.redirectUrl}),u=Yi(c,e=>()=>Ji(e(),()=>new Zi($i.MissingPaymentRedirectUrl))),h=Yi(({checkout:e})=>e.getOutstandingBalance,e=>(t=!1)=>{const n=e(t);return!!n&&n>0}),p=Yi(o,e=>t=>!(!t||!t.nonce)||"ACKNOWLEDGE"===e()||"FINALIZE"===e());return se((e,t)=>({getPaymentId:i({checkout:e,order:t}),getPaymentIdOrThrow:r({checkout:e,order:t}),getPaymentStatus:o({checkout:e,order:t}),getPaymentStatusOrThrow:a({checkout:e,order:t}),getPaymentToken:s({checkout:e,order:t}),getPaymentTokenOrThrow:d({checkout:e,order:t}),getPaymentRedirectUrl:c({checkout:e,order:t}),getPaymentRedirectUrlOrThrow:u({checkout:e,order:t}),isPaymentDataRequired:h({checkout:e,order:t}),isPaymentDataSubmitted:p({checkout:e,order:t})}))}(),k=function(){const e=Yi(e=>e.errors.applyError,e=>()=>e),t=Yi(e=>!!e.statuses.isApplying,e=>()=>e);return se((n=ir)=>({getApplyError:e(n),isApplying:t(n)}))}(),R=function(){const e=Yi(e=>e.errors.updateError,e=>()=>e),t=Yi(e=>!!e.statuses.isUpdating,e=>()=>e);return se((n=Ui)=>({getUpdateError:e(n),isUpdating:t(n)}))}(),D=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.errors.sendError,e=>()=>e),n=Yi(e=>!!e.statuses.isSending,e=>()=>e);return se((i=Oi)=>({getEmail:e(i),getSendError:t(i),isSending:n(i)}))}(),M=function(){const e=Yi(e=>e.data,e=>()=>e),t=Yi(e=>e.data,e=>t=>null==e?void 0:e.find(e=>e.region===t)),n=Yi(e=>e.errors.loadError,e=>()=>e),i=Yi(e=>e.statuses.isLoading,e=>()=>!!e);return se((r=Zt)=>({getExtensions:e(r),getExtensionByRegion:t(r),getLoadError:n(r),isLoading:i(r)}))}();return(u,l={})=>{const p=e(u.b2bToken),_=t(u.billingAddress),S=n(u.cart),N=i(u.checkoutButton),L=o(u.countries),z=a(u.coupons),U=s(u.customer),F=d(u.customerStrategies),B=M(u.extensions),x=g(u.formFields),q=c(u.giftCertificates),j=h(u.instruments),G=A(u.orderBillingAddress),V=m(u.paymentMethods),H=v(u.paymentProviderCustomer),W=y(u.paymentStrategies),Y=f(u.pickupOptions),K=C(u.remoteCheckout),$=I(u.consignments),Z=w(u.shippingCountries),J=b(u.shippingStrategies),Q=R(u.subscriptions),X=k(u.storeCredit),ee=D(u.signInEmail),te=E(u.consignments,S),ne=P(u.checkout,_,S,te,z,U,q),ie=O(u.order,G,z),re=T(ne,ie),oe={b2bToken:p,billingAddress:_,cart:S,checkout:ne,checkoutButton:N,config:r(u.config,u.formFields),consignments:te,countries:L,coupons:z,customer:U,customerStrategies:F,extensions:B,form:x,giftCertificates:q,instruments:j,order:ie,orderBillingAddress:G,payment:re,paymentMethods:V,paymentProviderCustomer:H,paymentStrategies:W,pickupOptions:Y,remoteCheckout:K,shippingAddress:$,shippingCountries:Z,shippingStrategies:J,signInEmail:ee,subscriptions:Q,storeCredit:X};return l.shouldWarnMutation?(ae=oe,Object.keys(ae).reduce((e,t)=>(e[t]=Qi(ae[t]),e),{})):oe;var ae}}function or(e={},t){const n=(s=function(){const e=new De;return["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(t=>{e.register(t,(e,t)=>new Oe(e,t))}),e.register("invalid_payment_provider",e=>new we(e)),e.register("payment_config_not_found",e=>new we(e)),e}(),e=>Y(e).pipe(Q(e=>{if(e instanceof Error||e.payload instanceof Error)throw e;if((t=e.payload)&&"object"==typeof t&&["body","headers","status","statusText"].every(e=>Object.prototype.hasOwnProperty.call(t,e))){const t=e.payload.body&&e.payload.body.detail;throw Object.assign(Object.assign({},e),{payload:s.createError(e.payload,t)})}var t;throw e}))),r=rr(),o=i({b2bToken:xe,billingAddress:Ze,cart:st,checkout:Gi,checkoutButton:yt,config:It,consignments:ni,countries:ln,coupons:At,customer:Bt,customerStrategies:Ht,extensions:Jt,formFields:rn,giftCertificates:Mt,instruments:jn,orderBillingAddress:In,order:yn,payment:Pn,paymentMethods:Tn,paymentStrategies:zn,pickupOptions:ui,paymentProviderCustomer:$n,remoteCheckout:Xn,shippingCountries:yi,shippingStrategies:Ii,signInEmail:Ai,subscriptions:Fi,storeCredit:Ni});var s;return a(o,e,Object.assign({actionTransformer:n,stateTransformer:e=>r(e)},t))}var ar,sr;!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"}(ar||(ar={}));class dr extends ve{constructor(e){super(function(e){switch(e){case ar.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case ar.MissingCart:return"Unable to proceed because cart data is unavailable.";case ar.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case ar.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case ar.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case ar.MissingCheckoutConfig:case ar.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case ar.MissingOrder:return"Unable to proceed because order data is unavailable.";case ar.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case ar.MissingPayment:return"Unable to proceed because payment data is unavailable.";case ar.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case ar.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case ar.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e)),this.subtype=e,this.name="MissingDataError",this.type="missing_data"}}function cr(e){return t=e.lineItems.physicalItems.filter(e=>!e.addedByPromotion),N(t,(e,t)=>e+t.quantity,0);var t}function ur(e,t){if(null==e)throw t?t():new Error("An unexpected error has occurred.");return e}!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"}(sr||(sr={}));class lr extends ve{constructor(e){super(function(e){switch(e){case sr.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case sr.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case sr.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case sr.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."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}const hr={de:"eu",jp:"fe",uk:"eu",us:"na"};var pr,gr,mr,yr,fr;!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"}(pr||(pr={})),function(e){e.Home="Home",e.Product="Product",e.Cart="Cart",e.Checkout="Checkout",e.Other="Other"}(gr||(gr={})),function(e){e.USD="USD",e.EUR="EUR",e.GBP="GBP",e.JPY="JPY"}(mr||(mr={})),function(e){e.PayAndShip="PayAndShip",e.PayOnly="PayOnly"}(yr||(yr={})),function(e){e.Gold="Gold",e.LightGray="LightGray",e.DarkGray="DarkGray"}(fr||(fr={}));var _r=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Sr{constructor(e){this.amazonPayV2ScriptLoader=e}initialize(e){return _r(this,void 0,void 0,function*(){this.amazonPayV2SDK=yield this.amazonPayV2ScriptLoader.load(e),this.buttonParentContainer=this.buttonParentContainer||this.createAmazonPayButtonParentContainer()})}deinitialize(){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()}bindButton(e,t,n){this.getAmazonPayV2SDK().Pay.bindChangeAction(`#${e}`,{amazonCheckoutSessionId:t,changeAction:n})}createButton(e,t){this.amazonPayV2Button=this.getAmazonPayV2SDK().Pay.renderButton(`#${e}`,t)}prepareCheckout(e){const t=this.prepareRequestConfig(e);this.getAmazonPayV2Button().onClick(()=>{this.getAmazonPayV2Button().initCheckout(t)})}prepareCheckoutWithCreationRequestConfig(e){this.getAmazonPayV2Button().onClick(()=>_r(this,void 0,void 0,function*(){const t=yield e();if(t){const e=this.prepareRequestConfig(t.createCheckoutSessionConfig,t.estimatedOrderAmount,t.productType);this.getAmazonPayV2Button().initCheckout(e)}}))}signout(){return _r(this,void 0,void 0,function*(){return this.amazonPayV2SDK&&this.amazonPayV2SDK.Pay.signout(),Promise.resolve()})}renderAmazonPayButton({buttonColor:e,checkoutState:t,containerId:n,decoupleCheckoutInitiation:i=!1,methodId:r,options:o,placement:a}){const s=document.querySelector(`#${n}`);if(!s)return;const{id:d}=s.appendChild(this.getButtonParentContainer()),c=null!=o?o:this.getAmazonPayV2ButtonOptions(t,r,a,i,e);return this.createButton(d,c),this.getButtonParentContainer()}updateBuyNowFlowFlag(e){this.isBuyNowFlow=Boolean(e)}isPh4Enabled(e,t){const n=!!e["PROJECT-3483.amazon_pay_ph4"],i=!!e["INT-6885.amazon_pay_ph4_us_only"];return n&&i?"US"===t:n}prepareRequestConfig(e,t,n){const{publicKeyId:i}=e,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["publicKeyId"]);return Object.assign(Object.assign({createCheckoutSessionConfig:this.isEnvironmentSpecific(i)?r:e},t&&{estimatedOrderAmount:t}),n&&{productType:n})}createAmazonPayButtonParentContainer(){const e=Math.random().toString(16).substr(-4),t=document.createElement("div");return t.id=`amazonpay_button_parent_container_${e}`,t}getAmazonPayV2ButtonOptions(e,t,n,i=!1,r=fr.Gold){var o;const{getCart:a,getCheckout:s,getStoreConfigOrThrow:d,getPaymentMethodOrThrow:c}=this.getCheckoutState(e),{config:{merchantId:u,testMode:l},initializationData:h}=c(t);if(!h)throw new dr(ar.MissingPaymentMethod);const{checkoutLanguage:p,checkoutSessionMethod:g,createCheckoutSessionConfig:m,extractAmazonCheckoutSessionId:y,ledgerCurrency:f,publicKeyId:_=""}=h;if(!u||!f)throw new dr(ar.MissingPaymentMethod);const S={merchantId:u,ledgerCurrency:f,checkoutLanguage:p,placement:n,buttonColor:r};if(this.isBuyNowFlow)return Object.assign(Object.assign({},S),{sandbox:!!l});const v=a();S.productType=v&&0===cr(v)?yr.PayOnly:yr.PayAndShip;const{checkoutSettings:{features:C},storeProfile:{shopPath:I,storeCountryCode:w}}=d();if(this.isPh4Enabled(C,w)){if(!m)throw new dr(ar.MissingPaymentMethod);const e=null===(o=s())||void 0===o?void 0:o.outstandingBalance.toString(),t=null==v?void 0:v.currency.code,n=Object.assign({},S);let r;return this.isEnvironmentSpecific(_)?(n.publicKeyId=_,r=m):(n.sandbox=!!l,r=Object.assign(Object.assign({},m),{publicKeyId:_})),i||(n.createCheckoutSessionConfig=r),e&&t&&(n.estimatedOrderAmount={amount:e,currencyCode:t}),n}const b={method:g,url:`${I}/remote-checkout/${t}/payment-session`,extractAmazonCheckoutSessionId:y};return Object.assign(Object.assign({},S),{createCheckoutSession:b,sandbox:!!l})}isEnvironmentSpecific(e){return/^(SANDBOX|LIVE)/.test(e)}getAmazonPayV2SDK(){return this.getOrThrow(this.amazonPayV2SDK)}getButtonParentContainer(){return this.getOrThrow(this.buttonParentContainer)}getAmazonPayV2Button(){return this.getOrThrow(this.amazonPayV2Button)}getOrThrow(e){return ur(e,()=>new lr(sr.PaymentNotInitialized))}getCheckoutState(e){return"object"==typeof(t=e)&&null!==t&&"cart"in t&&"checkout"in t&&"config"in t&&"paymentMethods"in t?{getCart:e.cart.getCart,getCheckout:e.checkout.getCheckout,getStoreConfigOrThrow:e.config.getStoreConfigOrThrow,getPaymentMethodOrThrow:t=>e.paymentMethods.getPaymentMethodOrThrow(t)}:e;var t}}class vr extends ve{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}class Cr{constructor(e,t=window){this.scriptLoader=e,this.windowWithAmazonPay=t}load(e){return t=this,n=void 0,r=function*(){const{initializationData:t}=e,n=(null==t?void 0:t.region)||"us",i=hr[n];if(yield this.scriptLoader.loadScript(`https://static-${i}.payments-amazon.com/checkout.js`),!this.windowWithAmazonPay.amazon)throw new vr;return this.windowWithAmazonPay.amazon},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}}function Ir(e,t){return Object.assign(e,{resolveIds:t})}class wr extends ve{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}class br extends ve{constructor(e){super(e||"An unexpected error has occurred during buy now cart creation process. Please try again later."),this.name="BuyNowCartCreationError",this.type="buy_now_cart_creation_error"}}class Er extends ve{constructor(e){super(e||"An unexpected error has occurred during config creation process. Please try again later."),this.name="AmazonPayV2ConfigCreationError",this.type="amazon_pay_v2_config_creation_error"}}function Pr(e){return e instanceof Object&&"buyNowInitializeOptions"in e}var Or=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ar{constructor(e,t,n){this.paymentIntegrationService=e,this.amazonPayV2PaymentProcessor=t,this.amazonPayV2ConfigRequestSender=n}initialize(e){return Or(this,void 0,void 0,function*(){var t;const{methodId:n,containerId:i,amazonpay:r}=e,{buttonColor:o}=r||{};if(!n||!i)throw new wr('Unable to proceed because "methodId" or "containerId" argument is not provided.');const{getPaymentMethodOrThrow:a}=this.paymentIntegrationService.getState(),s=a(n);yield this.amazonPayV2PaymentProcessor.initialize(s),r||(yield this.paymentIntegrationService.loadDefaultCheckout());const d=Pr(r)?void 0:r;Pr(r)&&"function"==typeof(null===(t=r.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody)&&(this._buyNowInitializeOptions=r.buyNowInitializeOptions,this.amazonPayV2PaymentProcessor.updateBuyNowFlowFlag(!0)),this.amazonPayV2PaymentProcessor.renderAmazonPayButton({checkoutState:this.paymentIntegrationService.getState(),containerId:i,methodId:n,options:d,placement:gr.Cart,buttonColor:o}),this._buyNowInitializeOptions&&this.amazonPayV2PaymentProcessor.prepareCheckoutWithCreationRequestConfig(this._getCheckoutCreationRequestConfig.bind(this))})}deinitialize(){return this.amazonPayV2PaymentProcessor.deinitialize()}_createBuyNowCartOrThrow(){return Or(this,void 0,void 0,function*(){var e,t;const n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e);if(!n)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(n)}catch(e){throw new br}})}_createCheckoutConfig(e){return Or(this,void 0,void 0,function*(){try{const t=(yield this.amazonPayV2ConfigRequestSender.createCheckoutConfig(e)).body,{payload:n,public_key:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["payload","public_key"]);return Object.assign({payloadJSON:n,publicKeyId:i},r)}catch(e){throw new Er}})}_getCheckoutCreationRequestConfig(){return Or(this,void 0,void 0,function*(){const e=yield this._createBuyNowCartOrThrow(),t={amount:String(e.baseAmount),currencyCode:e.currency.code};return{createCheckoutSessionConfig:yield this._createCheckoutConfig(e.id),estimatedOrderAmount:t,productType:0===cr(e)?yr.PayOnly:yr.PayAndShip}})}}const Tr="This API endpoint is for internal use only and may change in the future";var kr;!function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(kr||(kr={}));const Rr=kr,Dr={"X-Checkout-SDK-Version":"1.935.0"};class Mr{constructor(e){this._requestSender=e}createCheckoutConfig(e){const t={cartId:e},n=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return this._requestSender.post("/api/storefront/payment/amazonpay",{headers:n,body:t})}}const Nr=Ir(t=>{const n=e(),i=new Mr(n),r=new Sr(new Cr(le()));return new Ar(t,r,i)},[{id:"amazonpay"}]);function Lr(e,t,n=!0){var i;return null!==(i=e[t])&&void 0!==i?i:n}const zr="3.128.0",Ur="3.123.2",Fr="3.106.0";class Br{constructor(e){this.paymentIntegrationService=e,this.braintreeWindow=window}getSDKVersion(){const e=this.paymentIntegrationService.getState().getStoreConfig(),t=(null==e?void 0:e.checkoutSettings.features)||{};return this.getPreloadedSDKVersion()||(Lr(t,"PAYPAL-5809.braintree_hosted_fields_fix_version")?zr:Lr(t,"PAYPAL-5636.update_braintree_sdk_version")?Ur:Fr)}getPreloadedSDKVersion(){const e=this.braintreeWindow.braintree;if(e){const t=l(Object.values(e),e=>!!e.VERSION);return null==t?void 0:t.VERSION}}}class xr extends ve{constructor(e){super(e||"Unsupported browser error"),this.name="UnsupportedBrowserError",this.type="unsupported_browser"}}var qr,jr,Gr,Vr,Hr,Wr,Yr;function Kr(e){return Boolean("object"==typeof e&&null!==e&&("type"in e||"message"in e||"code"in e))}!function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(qr||(qr={})),function(e){e.Completed="COMPLETED",e.Pending="PENDING",e.Failed="FAILED"}(jr||(jr={})),function(e){e.TRUSTLY="trustly"}(Gr||(Gr={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="cancelled",e.UNRECOGNIZED="unrecognized"}(Vr||(Vr={})),function(e){e.Customer="CUSTOMER",e.Merchant="MERCHANT",e.Network="NETWORK",e.Internal="INTERNAL",e.Unknown="UNKNOWN"}(Hr||(Hr={})),function(e){e.KountNotEnabled="DATA_COLLECTOR_KOUNT_NOT_ENABLED"}(Wr||(Wr={})),function(e){e.Visa="visa",e.Mastercard="mastercard",e.AmericanExpress="american-express",e.DinersClub="diners-club",e.Discover="discover",e.Jcb="jcb",e.UnionPay="union-pay",e.Maestro="maestro",e.Elo="elo",e.Mir="mir",e.Hiper="hiper",e.Hipercard="hipercard"}(Yr||(Yr={}));var $r,Zr,Jr,Qr=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Xr{constructor(e){this.braintreeScriptLoader=e}initialize(e){this.setClientToken(e)}deinitialize(){return Qr(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollector),this.dataCollector=void 0})}getClient(){return Qr(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=yield t.create({authorization:e})}return this.client})}getDataCollectorOrThrow(e){return Qr(this,void 0,void 0,function*(){const t={deviceData:void 0,teardown:()=>Promise.resolve()};if(!this.dataCollector)try{const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadDataCollector(),i=Object.assign({client:t,kount:!0},e);this.dataCollector=yield n.create(i)}catch(e){if(Kr(e)&&e.code===Wr.KountNotEnabled)return t;throw e}return this.dataCollector})}getBraintreeGooglePayment(){return Qr(this,void 0,void 0,function*(){if(!this.googlePayment){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadGooglePayment()]);this.googlePayment=yield t.create({client:e})}return this.googlePayment})}getBraintreeThreeDS(){return Qr(this,void 0,void 0,function*(){if(!this.threeDS){const[e,t]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]);this.threeDS=yield t.create({client:e,version:2})}return this.threeDS})}getBraintreeLocalPayment(e){return Qr(this,void 0,void 0,function*(){if(!this.braintreeLocalPayment){const[t,n]=yield Promise.all([this.getClient(),this.braintreeScriptLoader.loadLocalPayment()]);this.braintreeLocalPayment=yield new Promise((i,r)=>{n.create({client:t,merchantAccountId:e},(e,t)=>{e&&r(e),i(t)})})}return this.braintreeLocalPayment})}getUsBankAccount(){return Qr(this,void 0,void 0,function*(){if(!this.usBankAccount){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadUsBankAccount();this.usBankAccount=yield t.create({client:e})}return this.usBankAccount})}getBraintreeVisaCheckout(){return this.visaCheckout||(this.visaCheckout=Promise.all([this.getClient(),this.braintreeScriptLoader.loadVisaCheckout()]).then(([e,t])=>t.create({client:e}))),this.visaCheckout}getVisaCheckoutSdk(e){return Qr(this,void 0,void 0,function*(){return this.visaCheckoutSDK||(this.visaCheckoutSDK=yield this.braintreeScriptLoader.loadVisaCheckoutSdk(e)),this.visaCheckoutSDK})}getVenmoCheckoutOrThrow(){return Qr(this,void 0,void 0,function*(){if(!this.braintreeVenmo){const e=yield this.getClient(),t=yield this.braintreeScriptLoader.loadVenmoCheckout(),n={client:e,allowDesktop:!0,paymentMethodUsage:"multi_use"},i=yield t.create(n);if(!i.isBrowserSupported())throw new xr;this.braintreeVenmo=i}return this.braintreeVenmo})}setClientToken(e){this.clientToken=e}getClientTokenOrThrow(){if(!this.clientToken)throw new lr(sr.PaymentNotInitialized);return this.clientToken}teardownModule(e){return e?e.teardown():Promise.resolve()}}!function(e){e.Sandbox="sandbox",e.Production="production"}($r||($r={})),function(e){e.Client="client",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"}(Zr||(Zr={})),function(e){e.CardCode="cardCode",e.CardCodeVerification="cardCodeVerification",e.CardExpiry="cardExpiry",e.CardName="cardName",e.CardNumber="cardNumber",e.CardNumberVerification="cardNumberVerification"}(Jr||(Jr={}));const eo={[Fr]:{[Zr.Client]:"sha384-26BXDNnJI23JYRyFBj4xe4sVNrUSSiSSu11kxVXNM/vEPONm4LuL00w6ZaTgQewt",[Zr.PaypalCheckout]:"sha384-B+vzbZwnQtzWBthpkT4TXKUibO65tyeK7eCxSvpblgprTep2+IAXB2Cxxjrn710O",[Zr.Paypal]:"sha384-uyAGL1/3+XJAHnGoNy4eCoXdzJ4f7Ilzp+6w9PNnEjs6DCCz9WMyJjMN1gzc78U+",[Zr.LocalPayment]:"sha384-LIvOEMkIVEwVuYBdVOQc1AC5YbGGlwyfUheS0ACK218D2STuVYQlZ4FyEPowAEfT",[Zr.DataCollector]:"sha384-1bo9JDz+Kscthc085cCKWur8CLwUoBpoNyxsDi7932mCl0zFq3A5mv+FQLw9GHpV",[Zr.UsBankAccount]:"sha384-xmHBVaU+w74V+OebD3AaPONFxHUGMf+QRs8G/JxVPXNNP7MDa2jL0ICWHIe2tTfJ",[Zr.GooglePayment]:"sha384-WKDJl8mqoP82qZpMGH6AbZxnvXnSW8ILV4M64CyMLiugGMwu7LyP89wjCkHqsiBe",[Zr.ThreeDSecure]:"sha384-VQUlpGHzsGvs5XeiGFip7EXRsvoHWEXDVmgCacfbyieZI9mdBOqq3NSoyo28OCOB",[Zr.VisaCheckout]:"sha384-yx7mADfzTN0T43Q6rlH49LIg1EJ0iUZgBp/EczX9LXsUGkySgxrD+nWHQRBkyfoT",[Zr.Venmo]:"sha384-QX4rPjoj1ZDhuG0aSyKs56lEKDqTMTcjYxUHY1SzO5VZDsqIE2NTkqot7KNSCyov",[Zr.HostedFields]:"sha384-VvYBACfSu0Cr/J32uKmxG7AXcNOJE1AzIIL3kbikyS7YKp5fz5Is+NzNP/lyauNy",[Zr.Fastlane]:"sha384-9oGsZMRZwpGtDEDYa/dFt76dECqj1xAni9gIKgc3KfMIiRnR73nEeeUDLiBzxhFa"},[Ur]:{[Zr.Client]:"sha384-o+nbQGcwNNxIBeXeu3+XmbSq+Cg8R3EN3N0l5hXCgMMU2RGY0t1z0LroSEIAbfAO",[Zr.PaypalCheckout]:"sha384-WrfbWPBS4mH86GAoycPSgiH8hQ8KH7A67C93Hjhunv/xhNk2YpBn3wbFA4Fhg9U/",[Zr.Paypal]:"sha384-VF389nvvrRUgDsTXMxTYORDtVegB9IQa3Cxr//DyJnLYnz8/X8VCzEvck2c+Megt",[Zr.LocalPayment]:"sha384-tZKx2rEQbfmZpoPSY5VPmJEhaq4X75dLvwHMs3VE9U+C8lPyw+hWTIL1+GPvWCIH",[Zr.DataCollector]:"sha384-E6k3wOpP7syCDDwaRDLF06942Y00NkbwJvWi2OQXwwKzGwG5fd3E7RFUvCCecfvO",[Zr.UsBankAccount]:"sha384-258FON8LZGG0W9Qaz4Jij83pZHu30YnKjJA7gNulLBh6CclkucgF+tHDQuYFRYfW",[Zr.GooglePayment]:"sha384-taJ2p/0+n0VH328POAoBiuEbL3tnHUTE9S42hK1V+Txs3X+QYjZOyKW35JgHRFfO",[Zr.ThreeDSecure]:"sha384-+NSZH4Zj3sO5bdWvPKhU5N16QDxeueTVTnUVeleeESkhLSaz4Ob1hh/5myecc9Ym",[Zr.VisaCheckout]:"sha384-66DiBjghxk1OmBj8aksN8gbQ+CwoQcx1vPfiXUN08g1iQVM+BwewF0p7toM3i7SS",[Zr.Venmo]:"sha384-B5UwY42kE4RoLoWbQ7YpqosUlUad2/DlGWiw0HhoZbSPk30CQAaSA10ohyLDTkDU",[Zr.HostedFields]:"sha384-Aw9EesSaUeWxe36PqEHiOyOyOq8M6CIb1gw7/yHNVPRzGtFXXcd2OQ8qXrIlOj2P",[Zr.Fastlane]:"sha384-rhBL1hpZ71JqG+2TsT0Dih47mbjx8cjJCpeZjk9tw3df1gFMKfCTmMyZunhr7H4Y"},[zr]:{[Zr.Client]:"sha384-0WNxksIpRP+fYZiIdr12g6DBUQfLDzYCQJZtR/C8KkcwSGhPHfcFp3tTaGcMyFTq",[Zr.PaypalCheckout]:"sha384-lWM1jk4BOxoDNV6Kop7tVNvQgINlmEVz0c/OwM+HNHK3QC8xqwd54Ovrt2QRDTjh",[Zr.Paypal]:"sha384-fXUmVxC2EMZBDXZ7eTHSTL/LFBrHej/MSXT/vTBXvra4lzgLNGvREAp+x0GYObuH",[Zr.LocalPayment]:"sha384-pha1xGuGSkmZH5x9aqHvRaO4xLea7rmQ/79PFj9zxNzxuFcOWZg7gOP7FibygOEC",[Zr.DataCollector]:"sha384-Q6PI2F9eekWbAxhroybl+aEcvqhdowN/EQlGwBUyJOzPFn9982u9xl6SU6XfGKzc",[Zr.UsBankAccount]:"sha384-W3RLQSKJL1tQ3+Y7mP6tmkamtZ8bV4Yw/XxL9Jj5JtXHraD8loMF8hAIG5m2zK7F",[Zr.GooglePayment]:"sha384-TITQMsFWA3elDNGP2mWz2oKBo4qjt+TlqzovcaPoeBiAh/wPBi6nae50ADdgU1/i",[Zr.ThreeDSecure]:"sha384-YiycYN89ZlL/Evcaq4y1ajW1mhd7JYfZBDuOwHtIn4/Jnm20GL+/XCM+zYAwWD8D",[Zr.VisaCheckout]:"sha384-/OdaTv9qrkKzjObtUe6yzfDhHozFW/+uXlrSl736sOZRJpjGQETvpYXqMFFg69xv",[Zr.Venmo]:"sha384-dA+ojdW9vbJS4JavcXyOs9d5uZHJg5dNtYupoPSH2zsXIiYDVS5amLb/u8qmQ6oz",[Zr.HostedFields]:"sha384-31ZkS58+iaWsW06ftW52zzVZFp43WPd7pNYRiddYynSNg6Oh7WGbSFGorAUH6T1z",[Zr.Fastlane]:"sha384-jlbrwNvL3HvLAUCtLSmrnQ2GH1udCUrRS/bVmReAS5fuIVvcW8Pko/Gkg82tlgtr"}};var to,no=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class io{constructor(e,t,n){this.scriptLoader=e,this.braintreeHostWindow=t,this.braintreeSDKVersionManager=n}loadClient(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.Client,"client.min.js")})}loadFastlane(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.Fastlane,"fastlane.min.js")})}loadPaypalCheckout(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.PaypalCheckout,"paypal-checkout.min.js")})}loadPaypal(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.Paypal,"paypal.min.js")})}loadLocalPayment(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.LocalPayment,"local-payment.min.js")})}loadDataCollector(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.DataCollector,"data-collector.min.js")})}loadUsBankAccount(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.UsBankAccount,"us-bank-account.min.js")})}loadGooglePayment(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.GooglePayment,"google-payment.min.js")})}load3DS(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.ThreeDSecure,"three-d-secure.min.js")})}loadVisaCheckout(){return this.loadBraintreeModuleOrThrow(Zr.VisaCheckout,"visa-checkout.min.js")}loadVenmoCheckout(){return this.loadBraintreeModuleOrThrow(Zr.Venmo,"venmo.min.js")}loadHostedFields(){return no(this,void 0,void 0,function*(){return this.loadBraintreeModuleOrThrow(Zr.HostedFields,"hosted-fields.min.js")})}loadVisaCheckoutSdk(e){return no(this,void 0,void 0,function*(){if(this.braintreeHostWindow.V)return this.braintreeHostWindow.V;const t=e?"sha384-0eu1s1GtqzXlL9DtLgmwzC5WWlEH/ADRM0n38cVQkvtT+W/gey96rcb1LwuUOPDm":"sha384-1f1csvP3ZFxg4dILH1GaY4LHlZ0oX7Rk83rxmLlwbnIi4TM0NYzXoev1VoEiVDS6";return this.scriptLoader.loadScript(`//${e?"sandbox-":""}assets.secure.checkout.visa.com/checkout-widget/resources/js/integration/v1/sdk.js`,{async:!0,attributes:{integrity:t,crossorigin:"anonymous"}}).then(()=>{if(!this.braintreeHostWindow.V)throw new vr;return this.braintreeHostWindow.V})})}loadBraintreeModuleOrThrow(e,t){return no(this,void 0,void 0,function*(){let n=this.getBraintreeModule(e);if(n)return n;const i=this.braintreeSDKVersionManager.getSDKVersion(),r=`//js.braintreegateway.com/web/${i}/js/${t}`,o=i in eo?this.getIntegrityValuesByModuleName(e,i):void 0;if(yield this.scriptLoader.loadScript(r,o?{async:!0,attributes:{integrity:o,crossorigin:"anonymous"}}:void 0),n=this.getBraintreeModule(e),!n)throw new vr;return n})}getBraintreeModule(e){var t;return null===(t=this.braintreeHostWindow.braintree)||void 0===t?void 0:t[e]}getIntegrityValuesByModuleName(e,t){const n=eo[t][e];if(!n)throw new Error("Unexpected fileName value");return n}}class ro extends ve{constructor(e){super(e||"Payment process was cancelled."),this.name="PaymentMethodCancelledError",this.type="payment_cancelled"}}!function(e){e.BRAINTREE="braintree",e.BRAINTREE_FASTLANE="braintreeacceleratedcheckout"}(to||(to={}));var oo,ao,so=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};!function(e){e.Subtotal="Subtotal",e.Shipping="Shipping"}(oo||(oo={})),function(e){e.Black="black",e.White="white",e.WhiteBorder="white-border"}(ao||(ao={}));class co{constructor(e,t,n,i,r){this._requestSender=e,this._paymentIntegrationService=t,this._sessionFactory=n,this._braintreeSdk=i,this._applePayScriptLoader=r,this._onAuthorizeCallback=T,this._subTotalLabel=oo.Subtotal,this._shippingLabel=oo.Shipping}initialize(e){return so(this,void 0,void 0,function*(){var t,n;const{methodId:i,containerId:r,applepay:o}=e;if(!i||!o)throw new dr(ar.MissingPaymentMethod);yield this._applePayScriptLoader.loadSdk();const{onPaymentAuthorize:a,buyNowInitializeOptions:s,requiresShipping:d}=o;this._requiresShipping=d,this._buyNowInitializeOptions=s,this._onAuthorizeCallback=a,s||(yield this._paymentIntegrationService.loadDefaultCheckout());const c=this._paymentIntegrationService.getState();return this._paymentMethod=c.getPaymentMethodOrThrow(i),c.getCart()&&(yield this._paymentIntegrationService.verifyCheckoutSpamProtection()),(null===(t=this._paymentMethod.initializationData)||void 0===t?void 0:t.gateway)===to.BRAINTREE&&this._paymentMethod.clientToken&&this._braintreeSdk.initialize(this._paymentMethod.clientToken),this._applePayButton=this._createButton(r,null===(n=this._paymentMethod.initializationData)||void 0===n?void 0:n.styleOption),this._applePayButton.addEventListener("click",this._handleWalletButtonClick.bind(this)),Promise.resolve()})}deinitialize(){return Promise.resolve()}_createButton(e,t){const n=document.getElementById(e);if(!n)throw new wr("Unable to create wallet button without valid container ID.");const i=this._createApplePayButtonElement(t);return n.appendChild(i),i}_createApplePayButtonElement(e){const t=document.createElement("apple-pay-button");return t.setAttribute("buttonstyle",(e=>{switch(e){case ao.White:return"white";case ao.WhiteBorder:return"white-outline";case ao.Black:default:return"black"}})(e)),t.setAttribute("type","plain"),t.setAttribute("style","--apple-pay-button-width: 100%; --apple-pay-button-height: 40px; --apple-pay-button-border-radius: 4px;"),t}_handleWalletButtonClick(e){return so(this,void 0,void 0,function*(){var t;if(e.preventDefault(),!this._paymentMethod||!this._paymentMethod.initializationData)throw new dr(ar.MissingPaymentMethod);if(this._buyNowInitializeOptions&&"function"==typeof this._buyNowInitializeOptions.getBuyNowCartRequestBody){const{countryCode:e,currencyCode:n,merchantCapabilities:i,supportedNetworks:r,storeName:o}=this._paymentMethod.initializationData,a=this._getRequestWithEmptyTotal(e,n,r,i);this._requiresShipping&&(null===(t=a.requiredShippingContactFields)||void 0===t||t.push("postalAddress"));const s=this._sessionFactory.create(a);this._handleApplePayEvents(s,this._paymentMethod,o),s.begin()}else{const e=this._paymentIntegrationService.getState(),t=e.getCartOrThrow(),n=e.getStoreConfigOrThrow(),i=e.getCheckoutOrThrow(),r=this._getBaseRequest(t,i,n,this._paymentMethod),o=this._sessionFactory.create(r);this._handleApplePayEvents(o,this._paymentMethod,n.storeProfile.storeName),o.begin()}})}_getRequestWithEmptyTotal(e,t,n,i){return{countryCode:e,currencyCode:t,supportedNetworks:n,merchantCapabilities:i,total:{label:"",amount:"0",type:"pending"},requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"]}}_getBaseRequest(e,t,n,i){var r;const{storeProfile:{storeCountryCode:o,storeName:a}}=n,{currency:{code:s,decimalPlaces:d}}=e,{initializationData:{merchantCapabilities:c,supportedNetworks:u}}=i,l=e.lineItems.physicalItems.length>0,h={requiredBillingContactFields:["postalAddress"],requiredShippingContactFields:["email","phone"],countryCode:o,currencyCode:s,merchantCapabilities:c,supportedNetworks:u,lineItems:[],total:l?{label:a,amount:`${t.grandTotal.toFixed(d)}`,type:"pending"}:{label:a,amount:`${t.grandTotal.toFixed(d)}`,type:"final"}};if(l)null===(r=h.requiredShippingContactFields)||void 0===r||r.push("postalAddress");else{const e=[{label:this._subTotalLabel,amount:`${t.subtotal.toFixed(d)}`}];t.taxes.forEach(t=>e.push({label:t.name,amount:`${t.amount.toFixed(d)}`})),h.lineItems=e}return h}_handleApplePayEvents(e,t,n){e.onvalidatemerchant=n=>so(this,void 0,void 0,function*(){try{const{body:i}=yield this._onValidateMerchant(t,n);e.completeMerchantValidation(i)}catch(e){throw new Error("Merchant validation failed")}}),this._buyNowInitializeOptions&&!this._requiresShipping&&(e.onpaymentmethodselected=()=>so(this,void 0,void 0,function*(){yield this._createBuyNowCart(),this._handlePaymentMethodSelected(e)})),e.onshippingcontactselected=t=>so(this,void 0,void 0,function*(){this._buyNowInitializeOptions&&this._requiresShipping&&(yield this._createBuyNowCart()),yield this._handleShippingContactSelected(e,n,t)}),e.onshippingmethodselected=t=>so(this,void 0,void 0,function*(){yield this._handleShippingMethodSelected(e,n,t)}),e.oncancel=()=>so(this,void 0,void 0,function*(){try{const e=`/remote-checkout/${t.id}/signout`;return yield this._requestSender.get(e),yield this._paymentIntegrationService.loadCheckout()}catch(e){throw new ro}}),e.onpaymentauthorized=n=>so(this,void 0,void 0,function*(){return this._onPaymentAuthorized(n,e,t)})}_createBuyNowCart(){return so(this,void 0,void 0,function*(){var e,t;try{const n=null===(t=null===(e=this._buyNowInitializeOptions)||void 0===e?void 0:e.getBuyNowCartRequestBody)||void 0===t?void 0:t.call(e);if(!n)throw new dr(ar.MissingCart);const i=yield this._paymentIntegrationService.createBuyNowCart(n);yield this._paymentIntegrationService.loadCheckout(i.id);const r=this._paymentIntegrationService.getState(),{shouldExecuteSpamCheck:o}=r.getCheckoutOrThrow();o&&(yield this._paymentIntegrationService.verifyCheckoutSpamProtection())}catch(e){throw new br}})}_handlePaymentMethodSelected(e){const t=this._paymentIntegrationService.getState(),n=t.getCartOrThrow(),i=t.getStoreConfigOrThrow(),r=t.getCheckoutOrThrow();if(!this._paymentMethod||!this._paymentMethod.initializationData)throw new dr(ar.MissingPaymentMethod);const o=this._getBaseRequest(n,r,i,this._paymentMethod);delete o.total.type,e.completePaymentMethodSelection({newTotal:o.total,newLineItems:o.lineItems})}_handleShippingContactSelected(e,t,n){return so(this,void 0,void 0,function*(){var i;const r=this._transformContactToAddress(n.shippingContact);try{yield this._paymentIntegrationService.updateShippingAddress(r)}catch(t){throw e.abort(),new Error("Shipping address update failed")}let o=this._paymentIntegrationService.getState();const{currency:{decimalPlaces:a}}=o.getCartOrThrow();let s=o.getCheckoutOrThrow();const d=null===(i=s.consignments[0].selectedShippingOption)||void 0===i?void 0:i.id,c=s.consignments[0].availableShippingOptions,u=null==c?void 0:c.find(({id:e})=>e===d),l=null==c?void 0:c.filter(e=>e.id!==d),h=u?[{label:u.description,amount:`${u.cost.toFixed(a)}`,detail:u.additionalDescription,identifier:u.id}]:[];if(l&&[...l.filter(e=>e.isRecommended),...l.filter(e=>!e.isRecommended)].forEach(e=>h.push({label:e.description,amount:`${e.cost.toFixed(a)}`,detail:e.additionalDescription,identifier:e.id})),!(c instanceof Array))throw new Error("Shipping options not available.");if(0===c.length)return void e.completeShippingContactSelection(ApplePaySession.STATUS_INVALID_SHIPPING_POSTAL_ADDRESS,[],{type:"pending",label:t,amount:`${s.grandTotal.toFixed(a)}`},[]);const p=c.find(e=>e.isRecommended),g=p?p.id:c[0].id,m=u?u.id:g;try{yield this._updateShippingOption(m)}catch(e){throw new Error("Shipping options update failed")}o=this._paymentIntegrationService.getState(),s=o.getCheckoutOrThrow(),e.completeShippingContactSelection({newShippingMethods:h,newTotal:{type:"final",label:t,amount:`${s.grandTotal.toFixed(a)}`},newLineItems:this._getUpdatedLineItems(s,a)})})}_handleShippingMethodSelected(e,t,n){return so(this,void 0,void 0,function*(){const{shippingMethod:{identifier:i}}=n;try{yield this._updateShippingOption(i)}catch(t){throw e.abort(),new Error("Shipping option selection update failed.")}const r=this._paymentIntegrationService.getState(),{currency:{decimalPlaces:o}}=r.getCartOrThrow(),a=r.getCheckoutOrThrow();e.completeShippingMethodSelection({newTotal:{type:"final",label:t,amount:`${a.grandTotal.toFixed(o)}`},newLineItems:this._getUpdatedLineItems(a,o)})})}_getUpdatedLineItems(e,t){const n=[{label:this._subTotalLabel,amount:`${e.subtotal.toFixed(t)}`}];return e.taxes.forEach(e=>n.push({label:e.name,amount:`${e.amount.toFixed(t)}`})),n.push({label:this._shippingLabel,amount:`${e.shippingCostTotal.toFixed(t)}`}),n}_updateShippingOption(e){return so(this,void 0,void 0,function*(){return this._paymentIntegrationService.selectShippingOption(e)})}_onValidateMerchant(e,t){return so(this,void 0,void 0,function*(){const n=[`validationUrl=${t.validationURL}`,`merchantIdentifier=${e.initializationData.merchantId}`,`displayName=${e.initializationData.storeName}`,`domainName=${window.location.hostname}`].join("&");return this._requestSender.post(`${e.initializationData.paymentsUrl}/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})})}_onPaymentAuthorized(e,t,n){return so(this,void 0,void 0,function*(){var i;const{token:r,billingContact:o,shippingContact:a}=e.payment,s=this._paymentIntegrationService.getState().getCartOrThrow().lineItems.physicalItems.length>0;let d;(null===(i=n.initializationData)||void 0===i?void 0:i.gateway)===to.BRAINTREE&&(d=yield this._getBraintreeDeviceData());const c={methodId:n.id,paymentData:{deviceSessionId:d,formattedPayload:{apple_pay_token:{payment_data:r.paymentData,payment_method:r.paymentMethod,transaction_id:r.transactionIdentifier}}}},u=this._transformContactToAddress(o),l=this._transformContactToAddress(a),h=null==a?void 0:a.emailAddress,p=(null==a?void 0:a.phoneNumber)||"";try{return yield this._paymentIntegrationService.updateBillingAddress(Object.assign(Object.assign({},u),{email:h,phone:p})),s&&(yield this._paymentIntegrationService.updateShippingAddress(l)),yield this._paymentIntegrationService.submitOrder({useStoreCredit:!1}),yield this._paymentIntegrationService.submitPayment(c),t.completePayment(ApplePaySession.STATUS_SUCCESS),this._onAuthorizeCallback()}catch(e){throw t.completePayment(ApplePaySession.STATUS_FAILURE),new Error("Payment cannot complete")}})}_transformContactToAddress(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:[]}}_getBraintreeDeviceData(){return so(this,void 0,void 0,function*(){try{const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e}catch(e){}})}}function uo(e){if(!function(e){return"ApplePaySession"in e}(e))throw new Error("Apple pay is not supported")}class lo{create(e){return uo(window),new ApplePaySession(1,e)}}class ho{constructor(e){this.scriptLoader=e,this.sdkVersion="1.latest"}loadSdk(){return e=this,t=void 0,i=function*(){(function(e){return"ApplePaySDK"in e})(window)||(yield this.scriptLoader.loadScript(`https://applepay.cdn-apple.com/jsapi/${this.sdkVersion}/apple-pay-sdk.js`),uo(window))},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}const po=Ir(t=>{const{getHost:n}=t.getState(),i=new Br(t);return new co(e({host:n()}),t,new lo,new Xr(new io(le(),window,i)),new ho(new ce))},[{id:"applepay"}]);var go,mo,yo,fo,_o,So,vo,Co;!function(e){e.BuyNow="BUY_NOW",e.INVOICE="B2B_INVOICE"}(go||(go={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(mo||(mo={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(yo||(yo={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(fo||(fo={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(_o||(_o={})),function(e){e.pill="pill",e.rect="rect"}(So||(So={})),function(e){e.OXXO="oxxo"}(vo||(vo={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Co||(Co={}));var Io=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class wo{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.bigCommercePaymentsRequestSender=n,this.bigCommercePaymentsScriptLoader=i}loadPayPalSdk(e,t,n,i){return Io(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e);return this.paypalSdk=yield this.bigCommercePaymentsScriptLoader.getPayPalSDK(a,o,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new vr;return this.paypalSdk}createBuyNowCartOrThrow(e){return Io(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new br}})}createOrder(e,t){return Io(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.bigCommercePaymentsRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return Io(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.bigCommercePaymentsRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e){return Io(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState(),n=t.getCartOrThrow();let i;e||(i=t.getConsignmentsOrThrow()[0]);try{yield this.bigCommercePaymentsRequestSender.updateOrder({availableShippingOptions:e?[]:null==i?void 0:i.availableShippingOptions,cartId:n.id,selectedShippingOption:e?null:null==i?void 0:i.selectedShippingOption})}catch(e){throw new Ie}})}getOrderStatus(e,t){return Io(this,void 0,void 0,function*(){try{const{status:n}=yield this.bigCommercePaymentsRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new dr(ar.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===go.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return Io(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:r}=e||{},o={color:t&&_o[t]?t:void 0,height:this.getValidHeight(n),label:i&&fo[i]?i:void 0,shape:r&&So[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var bo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Eo{constructor(e){this.requestSender=e}createOrder(e,t){return bo(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e){return bo(this,void 0,void 0,function*(){const t=e,n=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.put("/api/storefront/initialization/bigcommerce_payments",{headers:n,body:t})).body})}getOrderStatus(){return bo(this,arguments,void 0,function*(e="bigcommerce_payments",t){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}var Po=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Oo{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i){return Po(this,void 0,void 0,function*(){const r=this.getPayPalSdkScriptConfigOrThrow(e,t,n);return this.loadPayPalSDK(r,i)})}loadPayPalSDK(e){return Po(this,arguments,void 0,function*(e,t=!1){if(!this.window.bigCommercePaymentsPayPalSDK||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.bigCommercePaymentsPayPalSDK)throw new vr;return this.window.bigCommercePaymentsPayPalSDK})}getPayPalSdkScriptConfigOrThrow(e,t,n=!0){const{id:i,clientToken:r,initializationData:o}=e;if(!(null==o?void 0:o.clientId))throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isVenmoEnabled:l,isHostedCheckoutEnabled:h,isPayPalCreditAvailable:p,isDeveloperModeApplicable:g,availableAlternativePaymentMethods:m=[],enabledAlternativePaymentMethods:y=[],isGooglePayEnabled:f}=o,_=h||n,S="bigcommerce_payments_creditcards"===i,v=S?["card"]:[],C=S?[]:["card"],I=p?["credit","paylater"]:[],w=p?[]:["credit","paylater"],b=l?["venmo"]:[],E=l?[]:["venmo"],P=m.filter(e=>!y.includes(e)),O=f?["googlepay"]:[],A=n?["card-fields"]:[],T=this.filterFundingOptions([...C,...w,...E,...P]),k=this.filterFundingOptions([...v,...I,...b,...y]);return{options:Object.assign({"client-id":s,"merchant-id":d,"enable-funding":k.length>0?k:void 0,"disable-funding":T.length>0?T:void 0,commit:_,components:["buttons","hosted-fields","payment-fields","legal",...O,...A],currency:t,intent:a},g&&{"buyer-country":c}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"bigCommercePaymentsPayPalSDK"}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}const Ao=t=>{const{getHost:i}=t.getState();return new wo(n(),t,new Eo(e({host:i()})),new Oo(le()))};var To=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ko{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return To(this,void 0,void 0,function*(){var t;const{bigcommerce_payments:n,containerId:i,methodId:r}=e,o=Boolean(null==n?void 0:n.buyNowInitializeOptions);if(!r)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.bigcommerce_payments" argument is not provided.');if(o&&!n.currencyCode)throw new wr('Unable to initialize payment because "options.bigcommerce_payments.currencyCode" argument is not provided.');if(o&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.bigcommerce_payments.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');o||(yield this.paymentIntegrationService.loadDefaultCheckout());const a=o?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(r,a,!1),this.renderButton(i,r,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},h={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},p=Object.assign(Object.assign({},!u&&{onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e)}),{onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o,u)}),g=Object.assign(Object.assign(Object.assign({fundingSource:s.FUNDING.PAYPAL,style:this.bigCommercePaymentsIntegrationService.getValidButtonStyle(r)},l),i&&h),c&&p),m=s.Buttons(g);m.isEligible()?m.render(`#${e}`):a&&"function"==typeof a?a():this.bigCommercePaymentsIntegrationService.removeElement(e)}handleClick(e){return To(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i,r){return To(this,void 0,void 0,function*(){if(!e.orderID)throw new dr(ar.MissingOrderId);const o=this.paymentIntegrationService.getState().getCartOrThrow();try{const a=o.lineItems.physicalItems.length>0;if(!r){const e=yield t.order.get(),n=this.bigCommercePaymentsIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),a){const t=this.bigCommercePaymentsIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}return a&&(yield this.bigCommercePaymentsIntegrationService.updateOrder(r)),r&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.bigCommercePaymentsIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return To(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return To(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const Ro=Ir(e=>new ko(e,Ao(e)),[{id:"bigcommerce_payments"}]);var Do=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Mo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return Do(this,void 0,void 0,function*(){const{bigcommerce_payments_paylater:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.bigcommerce_payments_paylater" argument is not provided.');if(a&&!o)throw new wr('Unable to initialize payment because "options.bigcommerce_payments_paylater.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.bigcommerce_payments_paylater.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=this.paymentIntegrationService.getState(),d=a?o:s.getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(i,d,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c}=d.initializationData||{},u={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments_paylater"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},l={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},h={onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e),onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o)},p=[s.FUNDING.PAYLATER,s.FUNDING.CREDIT];let g=!1;p.forEach(t=>{if(!g){const n=Object.assign(Object.assign(Object.assign({fundingSource:t,style:this.bigCommercePaymentsIntegrationService.getValidButtonStyle(r)},u),i&&l),c&&h),o=s.Buttons(n);o.isEligible()?(o.render(`#${e}`),g=!0):a&&"function"==typeof a&&a()}}),g||this.bigCommercePaymentsIntegrationService.removeElement(e)}handleClick(e){return Do(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i){return Do(this,void 0,void 0,function*(){if(!e.orderID)throw new dr(ar.MissingOrderId);const r=this.paymentIntegrationService.getState().getCartOrThrow(),o=yield t.order.get();try{const t=this.bigCommercePaymentsIntegrationService.getBillingAddressFromOrderDetails(o);if(yield this.paymentIntegrationService.updateBillingAddress(t),r.lineItems.physicalItems.length>0){const e=this.bigCommercePaymentsIntegrationService.getShippingAddressFromOrderDetails(o);yield this.paymentIntegrationService.updateShippingAddress(e),yield this.bigCommercePaymentsIntegrationService.updateOrder()}return yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.bigCommercePaymentsIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return Do(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return Do(this,void 0,void 0,function*(){const t=this.bigCommercePaymentsIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.bigCommercePaymentsIntegrationService.updateOrder()}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const No=Ir(e=>new Mo(e,Ao(e)),[{id:"bigcommerce_payments_paylater"}]);var Lo=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class zo{constructor(e,t){this.paymentIntegrationService=e,this.bigCommercePaymentsIntegrationService=t}initialize(e){return Lo(this,void 0,void 0,function*(){const{bigcommerce_payments_venmo:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.bigcommerce_payments_venmo" argument is not provided.');if(a&&!o)throw new wr('Unable to initialize payment because "options.bigcommerce_payments_venmo.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.bigcommerce_payments_venmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=a?o:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.bigCommercePaymentsIntegrationService.loadPayPalSdk(i,s,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onEligibilityFailure:o}=n,a=this.bigCommercePaymentsIntegrationService.getPayPalSdkOrThrow(),s=a.FUNDING.VENMO,d={createOrder:()=>this.bigCommercePaymentsIntegrationService.createOrder("bigcommerce_payments_venmo"),onApprove:({orderID:e})=>this.bigCommercePaymentsIntegrationService.tokenizePayment(t,e)},c={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},u=Object.assign(Object.assign({fundingSource:s,style:this.getValidVenmoButtonStyles(r)},d),i&&c),l=a.Buttons(u);l.isEligible()?l.render(`#${e}`):o&&"function"==typeof o?o():this.bigCommercePaymentsIntegrationService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.bigCommercePaymentsIntegrationService.getValidButtonStyle(e);return t.color===_o.gold?Object.assign(Object.assign({},t),{color:void 0}):t}handleClick(e){return Lo(this,void 0,void 0,function*(){if(e){const t=yield this.bigCommercePaymentsIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}}const Uo=Ir(e=>new zo(e,Ao(e)),[{id:"bigcommerce_payments_venmo"}]);class Fo extends ve{constructor(e){super(e||"Not implemented."),this.name="NotImplementedError",this.type="not_implemented"}}var Bo,xo,qo;!function(e){e.SandboxMode="bolt_sandbox",e.StagingMode="bolt_staging",e.DevelopmentMode="bolt_development"}(Bo||(Bo={})),function(e){e.Small="small",e.Medium="medium",e.Large="large"}(xo||(xo={})),function(e){e.Pill="pill",e.Rect="rect"}(qo||(qo={}));class jo{constructor(e,t,n=window){this.paymentIntegrationService=e,this.boltScriptLoader=t,this.boltHostWindow=n}initialize(e){return t=this,n=void 0,r=function*(){const{bolt:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,style:o}=t||{};if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.bolt" argument is not provided.');if(!Boolean(r))throw new Fo("Only buy now flow is implemented for Bolt button");if(!(null==r?void 0:r.storefrontApiToken)||"string"!=typeof r.storefrontApiToken)throw new wr('Unable to initialize payment because "options.storefrontApiToken" argument is not provided.');const a=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(i),{initializationData:s,config:d}=a,{publishableKey:c,developerConfig:u}=s||{};yield this.boltScriptLoader.loadBoltClient(c,d.testMode,u,"BigCommerce",r.storefrontApiToken),this.renderButton(n,a,o)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}deinitialize(){return Promise.resolve()}renderButton(e,t,n){var i;"function"==typeof(null===(i=this.boltHostWindow.BoltConnect)||void 0===i?void 0:i.setupProductPageCheckout)&&(this.addButtonContainer(e,t,n),this.boltHostWindow.BoltConnect.setupProductPageCheckout())}addButtonContainer(e,t,n){const i=document.getElementById(e);if(!i)return;const r=document.createElement("div"),o=document.createElement("object");r.setAttribute("id","product-page-checkout-wrapper"),r.setAttribute("class","bolt-button-wrapper"),r.setAttribute("style","display:none"),r.setAttribute("data-tid","product-page-checkout-wrapper"),o.setAttribute("data",this.getBoltObjectData(t,n)),o.setAttribute("class","bolt-product-checkout-button"),r.append(o),i.innerHTML="",i.append(r)}getBoltObjectData(e,t){const{initializationData:n,config:i}=e,{publishableKey:r,developerConfig:o}=n||{},a=this.boltScriptLoader.getDomainURL(!!i.testMode,o),s=this.getButtonHeight(null==t?void 0:t.size),d=this.getButtonBorderRadius(null==t?void 0:t.shape,s);return he({url:`https://${a}/v1/checkout_button`,query:{publishable_key:r,variant:"ppc",height:s,border_radius:d}})}getButtonHeight(e){if(e)switch(e){case xo.Small:return 25;case xo.Large:return 45;case xo.Medium:default:return 40}}getButtonBorderRadius(e,t){if(e)switch(e){case qo.Pill:return t?Math.round(t/2):void 0;case qo.Rect:default:return 4}}}var Go=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Vo{constructor(e,t=window){this.scriptLoader=e,this.boltHostWindow=t}loadBoltClient(e,t,n,i,r){return Go(this,void 0,void 0,function*(){if(this.boltHostWindow.BoltCheckout)return this.boltHostWindow.BoltCheckout;if(!e)throw new wr('Unable to initialize payment because "publishableKey" argument is not provided.');if(yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/connect-bigcommerce.js`,this.getScriptOptions("bolt-connect",e,i,r)),yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/track.js`,this.getScriptOptions("bolt-track",e)),!this.boltHostWindow.BoltCheckout)throw new vr;return this.boltHostWindow.BoltCheckout})}loadBoltEmbedded(e,t,n){return Go(this,void 0,void 0,function*(){if(yield this.scriptLoader.loadScript(`//${this.getDomainURL(!!t,n)}/embed.js`,{async:!0,attributes:{id:"bolt-embedded"}}),!this.boltHostWindow.Bolt)throw new vr;return this.boltHostWindow.Bolt(e)})}getDomainURL(e,t){if(!e)return"connect.bolt.com";if(t)switch(t.developerMode){case Bo.StagingMode:return"connect-staging.bolt.com";case Bo.DevelopmentMode:return`connect.${t.developerDomain}`}return"connect-sandbox.bolt.com"}getScriptOptions(e,t,n,i){return{async:!0,attributes:Object.assign(Object.assign({id:e,"data-publishable-key":t},n&&{"data-shopping-cart-id":n}),i&&{"data-storefront-api-token":i})}}}const Ho=Ir(e=>new jo(e,new Vo(le())),[{id:"bolt"}]);class Wo extends wr{constructor(e){let t="Unable to submit payment for the order because the payload is invalid.";e&&(t=`${t} Make sure the following fields are provided correctly: ${e.join(", ")}.`),super(t),this.name="PaymentArgumentInvalidError"}}class Yo extends ve{constructor(e,t){super(t||"Unable to proceed because the payment form contains invalid data."),this.details=e,this.name="PaymentInvalidFormError",this.type="payment_invalid_form"}}let Ko=null;const $o=["buttons","messages"];var Zo,Jo,Qo,Xo,ea,ta;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Zo||(Zo={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Jo||(Jo={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(Qo||(Qo={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Xo||(Xo={})),function(e){e.PILL="pill",e.RECT="rect"}(ea||(ea={})),function(e){e.CART="cart",e.HOME="homepage",e.PAYMENT="payment",e.PRODUCT="product"}(ta||(ta={}));var na=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ia{constructor(e,t,n){this.braintreeScriptLoader=e,this.braintreeHostWindow=t,this.overlay=n,this.dataCollectors={}}initialize(e,t){this.clientToken=e,this.threeDSecureOptions=t}getBraintreeFastlane(e,t,n){return na(this,void 0,void 0,function*(){if(t&&(window.localStorage.setItem("axoEnv","sandbox"),window.localStorage.setItem("fastlaneEnv","sandbox")),!this.braintreeHostWindow.braintreeFastlane){const t=this.getClientTokenOrThrow(),i=yield this.getClient(),r=yield this.getSessionId(e),o=yield this.braintreeScriptLoader.loadFastlane(),a={root:{backgroundColorPrimary:"transparent"}};this.braintreeHostWindow.braintreeFastlane=yield o.create({authorization:t,client:i,deviceData:r,styles:n||a})}return this.braintreeHostWindow.braintreeFastlane})}getClient(){return na(this,void 0,void 0,function*(){if(!this.client){const e=this.getClientTokenOrThrow(),t=yield this.braintreeScriptLoader.loadClient();this.client=t.create({authorization:e})}return this.client})}getPaypal(){return this.braintreePaypal||(this.braintreePaypal=Promise.all([this.getClient(),this.braintreeScriptLoader.loadPaypal()]).then(([e,t])=>t.create({client:e}))),this.braintreePaypal}paypal(e){var{shouldSaveInstrument:t}=e,n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["shouldSaveInstrument"]);const i=pe();return this.getPaypal().then(e=>{var r;return i&&(null===(r=this.overlay)||void 0===r||r.show({onClick:()=>e.focusWindow()})),e.tokenize(Object.assign({enableShippingAddress:!0,flow:t?"vault":"checkout",useraction:"commit"},n))}).then(e=>{var t;return null===(t=this.overlay)||void 0===t||t.remove(),e}).catch(e=>{var t;throw null===(t=this.overlay)||void 0===t||t.remove(),e})}getPaypalCheckout(e,t,n){return na(this,void 0,void 0,function*(){const i=yield this.getClient(),r=yield this.braintreeScriptLoader.loadPaypalCheckout(),o={client:i};return this.paypalCheckout=yield r.create(o,(i,r)=>{var o;if(i)return n(i);const a=Object.assign(Object.assign({currency:e.currency},e.isCreditEnabled&&{"enable-funding":"paylater"}),{components:$o.toString(),intent:e.intent,commit:null===(o=e.commit)||void 0===o||o});this.braintreeHostWindow.paypal?t(r):function(e,t){return Ko||(Ko=new Promise((n,i)=>{e.loadPayPalSDK(t,t=>{t?(Ko=null,i(t)):n(e)})})),Ko}(r,a).then(()=>t(r))}),this.paypalCheckout})}getDataCollector(e){return na(this,void 0,void 0,function*(){const t=(null==e?void 0:e.paypal)?"paypal":"default";let n=this.dataCollectors[t];if(!n){try{const t=yield this.getClient(),i=yield this.braintreeScriptLoader.loadDataCollector(),r=Object.assign({client:t,kount:!0},e);n=yield i.create(r)}catch(e){if(!Kr(e)||"DATA_COLLECTOR_KOUNT_NOT_ENABLED"!==e.code)throw e;n={deviceData:void 0,teardown:()=>Promise.resolve()}}this.dataCollectors[t]=n}return n})}getBraintreeEnv(e=!1){return e?$r.Sandbox:$r.Production}mapToBraintreeShippingAddressOverride(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}}mapToLegacyShippingAddress(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}mapToLegacyBillingAddress(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,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}}removeElement(e){const t=e&&document.getElementById(e);t&&t.remove()}getSessionId(e){return na(this,void 0,void 0,function*(){const{deviceData:t}=yield this.getDataCollector({riskCorrelationId:e});return t})}teardown(){return na(this,void 0,void 0,function*(){yield this.teardownModule(this.dataCollectors.default),yield this.teardownModule(this.dataCollectors.paypal),this.dataCollectors={},yield this.teardownModule(this.paypalCheckout),this.paypalCheckout=void 0})}get3DS(){return na(this,void 0,void 0,function*(){return this.threeDS||(this.threeDS=Promise.all([this.getClient(),this.braintreeScriptLoader.load3DS()]).then(([e,t])=>t.create({client:e,version:2}))),this.threeDS})}getVenmoCheckout(e){return na(this,void 0,void 0,function*(){if(!this.venmoCheckout){const t=yield this.getClient(),n=yield this.braintreeScriptLoader.loadVenmoCheckout(),i=Object.assign({client:t,allowDesktop:!0,paymentMethodUsage:"multi_use"},e||{});this.venmoCheckout=yield new Promise((e,t)=>{n.create(i,(n,i)=>n?t(n):i.isBrowserSupported()?void e(i):t(new xr))})}return this.venmoCheckout})}verifyCard(e,t,n){return na(this,void 0,void 0,function*(){const i=yield this.tokenizeCard(e,t);return this.challenge3DSVerification(i,n)})}tokenizeCard(e,t){return na(this,void 0,void 0,function*(){const{paymentData:n}=e;if(!function(e){if("object"!=typeof e||null===e)return!1;const t=e;return"object"==typeof t.ccExpiry&&null!==t.ccExpiry&&"string"==typeof t.ccNumber&&"string"==typeof t.ccName}(n))throw new Wo(["payment.paymentData"]);const i=this.getErrorsRequiredFields(n);if(!f(i))throw new Yo(i);const r=this.mapToCreditCard(n,t),o=yield this.getClient(),{creditCards:a}=yield o.request(r);return{nonce:a[0].nonce,bin:a[0].details.bin}})}challenge3DSVerification(e,t){return na(this,void 0,void 0,function*(){const n=yield this.get3DS();return this.present3DSChallenge(n,t,e)})}teardownModule(e){return e?e.teardown():Promise.resolve()}getClientTokenOrThrow(){if(!this.clientToken)throw new lr(sr.PaymentNotInitialized);return this.clientToken}getErrorsRequiredFields(e){const{ccNumber:t,ccExpiry:n}=e,i={};return t||(i.ccNumber=[{message:"Credit card number is required",type:"required"}]),n||(i.ccExpiry=[{message:"Expiration date is required",type:"required"}]),i}mapToCreditCard(e,t){return{data:{creditCard:{cardholderName:e.ccName,number:e.ccNumber,cvv:e.ccCvv,expirationDate:`${e.ccExpiry.month}/${e.ccExpiry.year}`,options:{validate:!1},billingAddress:t&&{countryCodeAlpha2:t.countryCode,locality:t.city,countryName:t.country,postalCode:t.postalCode,streetAddress:t.address2?`${t.address1} ${t.address2}`:t.address1}}},endpoint:"payment_methods/credit_cards",method:"post"}}present3DSChallenge(e,t,n){const{nonce:i,bin:r}=n;if(!i)throw new lr(sr.PaymentNotInitialized);const{challengeRequested:o=!0,additionalInformation:a}=this.threeDSecureOptions||{},s=t.toFixed(2);return e.verifyCard({amount:Number(s),bin:r,challengeRequested:o,nonce:i,onLookupComplete:(e,t)=>{t()},collectDeviceData:!0,additionalInformation:a})}}function ra(e){const{color:t,fundingicons:n,height:i=40,layout:r,shape:o,size:a,tagline:s}=e||{},d={color:t,fundingicons:n,height:oa(i),layout:r,shape:o||"rect",size:a,tagline:s};return R(d,v)}function oa(e){const t=Number(e);return!t||Number.isNaN(t)?40:t>55?55:t<25?25:t}function aa(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}}var sa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class da{constructor(e,t,n,i){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeIntegrationService=n,this.braintreeHostWindow=i}initialize(e){return sa(this,void 0,void 0,function*(){const{braintreepaypal:t,containerId:n,methodId:i}=e;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.braintreepaypal" argument is not provided.');let r,o=this.paymentIntegrationService.getState();if(t.buyNowInitializeOptions){if(!t.currencyCode)throw new wr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');r=t.currencyCode}else yield this.paymentIntegrationService.loadDefaultCheckout(),o=this.paymentIntegrationService.getState(),r=o.getCartOrThrow().currency.code;const a=o.getPaymentMethodOrThrow(i),{clientToken:s,config:d,initializationData:c}=a;if(!s||!c)throw new dr(ar.MissingPaymentMethod);const u={currency:r,intent:c.intent,isCreditEnabled:c.isCreditEnabled,commit:!1};this.braintreeIntegrationService.initialize(s),yield this.braintreeIntegrationService.getPaypalCheckout(u,e=>{this.renderPayPalButton(e,t,n,i,!!d.testMode)},e=>this.handleError(e,n,t.onError))})}deinitialize(){return sa(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}renderPayPalButton(e,t,n,i,r){const{style:o,shouldProcessPayment:a,onAuthorizeError:s,onEligibilityFailure:d}=t,{paypal:c}=this.braintreeHostWindow;if(c){const u=c.Buttons({env:r?"sandbox":"production",fundingSource:c.FUNDING.PAYPAL,style:ra(o),createOrder:()=>this.setupPayment(e,t,i),onApprove:t=>this.tokenizePayment(t,e,i,a,s)});u.isEligible()?u.render(`#${n}`):d&&"function"==typeof d&&d()}else this.braintreeIntegrationService.removeElement(n)}setupPayment(e,t,n){return sa(this,void 0,void 0,function*(){var i;const{onPaymentError:r,shippingAddress:o,buyNowInitializeOptions:a}=t;try{const r="function"==typeof(null==a?void 0:a.getBuyNowCartRequestBody)?yield this.createBuyNowCart(a.getBuyNowCartRequestBody()):void 0;this.buyNowCartId=null==r?void 0:r.id;const s=this.paymentIntegrationService.getState(),d=s.getCustomer(),c=s.getPaymentMethodOrThrow(n),u=r?r.cartAmount:s.getCartOrThrow().cartAmount,l=r?t.currencyCode:s.getCartOrThrow().currency.code,h=o||(null==d?void 0:d.addresses[0]),p=h?aa(h):void 0;return yield e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:p,amount:u,currency:l,offerCredit:!1,intent:null===(i=c.initializationData)||void 0===i?void 0:i.intent})}catch(e){throw r&&(Kr(e)||e instanceof ve)&&r(e),e}})}tokenizePayment(e,t,n,i,r){return sa(this,void 0,void 0,function*(){try{const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),o=yield t.tokenizePayment(e),{details:a,nonce:s}=o,d=this.braintreeIntegrationService.mapToLegacyBillingAddress(a),c=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",provider:n,action:i?"process_payment":"set_external_checkout",nonce:s,device_data:r,billing_address:JSON.stringify(d),shipping_address:JSON.stringify(c)},this.buyNowCartId&&{cart_id:this.buyNowCartId})),o}catch(e){throw r&&(Kr(e)||e instanceof ve)&&r(e),e}})}createBuyNowCart(e){return sa(this,void 0,void 0,function*(){if(!e)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(e)}catch(e){throw new br}})}handleError(e,t,n){if(this.braintreeIntegrationService.removeElement(t),!n||!Kr(e))throw e;n(e)}}const ca=Ir(e=>{const t=window,i=new Br(e),r=new ia(new io(le(),t,i),t);return new da(e,n(),r,t)},[{id:"braintreepaypal"}]);var ua=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class la{constructor(e,t,n,i){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeIntegrationService=n,this.braintreeHostWindow=i}initialize(e){return ua(this,void 0,void 0,function*(){const{braintreepaypalcredit:t,containerId:n,methodId:i}=e;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.braintreepaypalcredit" argument is not provided.');let r,o=this.paymentIntegrationService.getState();if(t.buyNowInitializeOptions){if(!t.currencyCode)throw new wr('Unable to initialize payment because "options.braintreepaypalcredit.currencyCode" argument is not provided.');r=t.currencyCode}else yield this.paymentIntegrationService.loadDefaultCheckout(),o=this.paymentIntegrationService.getState(),r=o.getCartOrThrow().currency.code;const a=o.getPaymentMethodOrThrow(i),{clientToken:s,config:d,initializationData:c}=a;if(!s||!c)throw new dr(ar.MissingPaymentMethod);const u={currency:r,intent:c.intent,isCreditEnabled:c.isCreditEnabled,commit:!1};this.braintreeIntegrationService.initialize(s),yield this.braintreeIntegrationService.getPaypalCheckout(u,e=>{this.renderPayPalButton(e,t,n,i,!!d.testMode)},e=>this.handleError(e,n,t.onError))})}deinitialize(){return ua(this,void 0,void 0,function*(){yield this.braintreeIntegrationService.teardown()})}renderPayPalButton(e,t,n,i,r){const{style:o,shouldProcessPayment:a,onAuthorizeError:s,onEligibilityFailure:d}=t,{paypal:c}=this.braintreeHostWindow;let u=!1;c&&[c.FUNDING.PAYLATER,c.FUNDING.CREDIT].forEach(l=>{const h=l===c.FUNDING.CREDIT?Object.assign({label:Xo.CREDIT},ra(o)):ra(o);if(!u){const o=c.Buttons({env:r?"sandbox":"production",fundingSource:l,style:h,createOrder:()=>this.setupPayment(e,t,i),onApprove:t=>this.tokenizePayment(t,e,i,a,s)});o.isEligible()?(o.render(`#${n}`),u=!0):c.FUNDING.CREDIT&&d&&"function"==typeof d&&d()}}),c&&u||this.braintreeIntegrationService.removeElement(n)}setupPayment(e,t,n){return ua(this,void 0,void 0,function*(){var i;const{onPaymentError:r,shippingAddress:o,buyNowInitializeOptions:a}=t;try{const r="function"==typeof(null==a?void 0:a.getBuyNowCartRequestBody)?yield this.createBuyNowCart(a.getBuyNowCartRequestBody()):void 0;this.buyNowCartId=null==r?void 0:r.id;const s=this.paymentIntegrationService.getState(),d=s.getCustomer(),c=s.getPaymentMethodOrThrow(n),u=r?r.cartAmount:s.getCartOrThrow().cartAmount,l=r?t.currencyCode:s.getCartOrThrow().currency.code,h=o||(null==d?void 0:d.addresses[0]),p=h?aa(h):void 0;return yield e.createPayment({flow:"checkout",enableShippingAddress:!0,shippingAddressEditable:!1,shippingAddressOverride:p,amount:u,currency:l,offerCredit:!0,intent:null===(i=c.initializationData)||void 0===i?void 0:i.intent})}catch(e){throw r&&(Kr(e)||e instanceof ve)&&r(e),e}})}tokenizePayment(e,t,n,i,r){return ua(this,void 0,void 0,function*(){try{const{deviceData:r}=yield this.braintreeIntegrationService.getDataCollector({paypal:!0}),o=yield t.tokenizePayment(e),{details:a,nonce:s}=o,d=this.braintreeIntegrationService.mapToLegacyBillingAddress(a),c=this.braintreeIntegrationService.mapToLegacyShippingAddress(a);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",provider:n,action:i?"process_payment":"set_external_checkout",nonce:s,device_data:r,billing_address:JSON.stringify(d),shipping_address:JSON.stringify(c)},this.buyNowCartId&&{cart_id:this.buyNowCartId})),o}catch(e){throw r&&(Kr(e)||e instanceof ve)&&r(e),e}})}createBuyNowCart(e){return ua(this,void 0,void 0,function*(){if(!e)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(e)}catch(e){throw new br}})}handleError(e,t,n){if(this.braintreeIntegrationService.removeElement(t),!n||!Kr(e))throw e;n(e)}}const ha=Ir(e=>{const t=window,i=new Br(e),r=new ia(new io(le(),t,i),t);return new la(e,n(),r,t)},[{id:"braintreepaypalcredit"}]);var pa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ga{constructor(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n}initialize(e){return pa(this,void 0,void 0,function*(){const{containerId:t,methodId:n}=e;if(!n)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');yield this.paymentIntegrationService.loadPaymentMethod(n);const i=this.paymentIntegrationService.getState(),{clientToken:r,initializationData:o,config:a}=i.getPaymentMethodOrThrow(n);if(!r||!o)throw new dr(ar.MissingPaymentMethod);this.braintreeSdk.initialize(r);const s=yield this.braintreeSdk.getBraintreeVisaCheckout(),{currency:{code:d},cartAmount:c}=i.getCartOrThrow(),u=yield this.braintreeSdk.getVisaCheckoutSdk(a.testMode),l=s.createInitOptions({paymentRequest:{currencyCode:d,subtotal:String(c)},settings:{shipping:{collectShipping:!0}}});this.createSignInButton(t),yield u.init(l),u.on("payment.success",e=>pa(this,void 0,void 0,function*(){yield this.paymentSuccess(s,e)}))})}deinitialize(){return Promise.resolve()}paymentSuccess(e,t){return pa(this,void 0,void 0,function*(){return Promise.all([e.tokenize(t),this.braintreeSdk.getDataCollectorOrThrow()]).then(([e,t])=>{const n=this.paymentIntegrationService.getState(),i=n.getShippingAddress(),r=n.getBillingAddress(),{shippingAddress:o=this.toVisaCheckoutAddress(i),billingAddress:a=this.toVisaCheckoutAddress(r)}=e;return this.postForm(Object.assign(Object.assign({},e),{shippingAddress:o,billingAddress:a}),t)})})}postForm(e,t){const{userData:n,billingAddress:i,shippingAddress:r,details:o}=e,{userEmail:a}=n,{deviceData:s}=t;return this.formPoster.postForm("/checkout.php",{payment_type:e.type,nonce:e.nonce,provider:"braintreevisacheckout",action:"set_external_checkout",device_data:s,card_information:JSON.stringify({type:o.cardType,number:o.lastTwo}),billing_address:JSON.stringify(this.getAddress(a,i)),shipping_address:JSON.stringify(this.getAddress(a,r))})}toVisaCheckoutAddress(e){return e?{firstName:e.firstName,lastName:e.lastName,phoneNumber:e.phone,streetAddress:e.address1,extendedAddress:e.address2,locality:e.city,region:e.stateOrProvinceCode,countryCode:e.countryCode,postalCode:e.postalCode}:{}}getAddress(e,t={}){return{email:e,first_name:t.firstName,last_name:t.lastName,phone_number:t.phoneNumber,address_line_1:t.streetAddress,address_line_2:t.extendedAddress,city:t.locality,state:t.region,country_code:t.countryCode,postal_code:t.postalCode}}createSignInButton(e){const t=document.querySelector(`#${e}`);if(!t)throw new Error("Need a container to place the button");return this.insertVisaCheckoutButton(t)}insertVisaCheckoutButton(e){const t=document.createElement("div");return t.style.display="flex",t.style.flexDirection="column",t.style.alignItems="flex-end",t.innerHTML='\n <img\n alt="Visa Checkout"\n class="v-button"\n role="button"\n src="https://secure.checkout.visa.com/wallet-services-web/xo/button.png?acceptCanadianVisaDebit=false&cobrand=true&height=34&width=178"\n />\n <a class="v-learn v-learn-default" style="text-align: right; display: block; font-size: 10px; color: #003366;" href="#" data-locale="en_US">Tell Me More</a>',e.appendChild(t),t}}const ma=Ir(e=>{const t=window,i=new Br(e),r=new Xr(new io(le(),t,i));return new ga(e,n(),r)},[{id:"braintreevisacheckout"}]);function ya(e){const{billingAddress:t,email:n,firstName:i,lastName:r,phone:o,shippingAddress:a}=e,s=t||a;return{email:n,first_name:i,last_name:r,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 fa(e){const{email:t,phone:n,shippingAddress:i}=e,r=(null==i?void 0:i.recipientName)||"",[o,a]=r.split(" ");return{email:t,first_name:o||"",last_name:a||"",phone_number:n,address_line_1:null==i?void 0:i.line1,address_line_2:null==i?void 0:i.line2,city:null==i?void 0:i.city,state:null==i?void 0:i.state,country_code:null==i?void 0:i.countryCode,postal_code:null==i?void 0:i.postalCode}}var _a=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const Sa=e=>{const{color:t,height:n}=e;return{backgroundColor:(i=t||"",i===Qo.WHITE?"#FFFFFF":"#3D95CE"),backgroundPosition:"50% 50%",backgroundSize:"80px auto",backgroundImage:`url("/app/assets/img/payment-providers/venmo-logo-${t===Qo.WHITE?Qo.BLUE:Qo.WHITE}.svg")`,backgroundRepeat:"no-repeat",borderRadius:"4px",cursor:"pointer",transition:"0.2s ease",minHeight:`${n||40}px`,minWidth:"150px",height:"100%",width:"100%",border:t===Qo.WHITE?"1px solid black":"none"};var i};class va{constructor(e,t,n){this.paymentIntegrationService=e,this.formPoster=t,this.braintreeSdk=n,this.onError=T}initialize(e){return _a(this,void 0,void 0,function*(){const{braintreevenmo:t,containerId:n,methodId:i}=e;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(i),{clientToken:o,initializationData:a}=r,{paymentButtonStyles:s}=a,{cartButtonStyles:d}=s||{},c=(null==t?void 0:t.style)||d;if(!o||!a)throw new dr(ar.MissingPaymentMethod);if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');yield this.paymentIntegrationService.loadDefaultCheckout(),this.onError=(null==t?void 0:t.onError)||this.handleError,this.braintreeSdk.initialize(o);try{const e=yield this.braintreeSdk.getVenmoCheckoutOrThrow();this.renderVenmoButton(e,n,null==t?void 0:t.buyNowInitializeOptions,c)}catch(e){(function(e){return"object"==typeof e&&null!==e&&"name"in e&&"BraintreeError"===e.name}(e)||function(e){return e instanceof xr}(e))&&this.handleInitializationVenmoError(e,n)}})}deinitialize(){return _a(this,void 0,void 0,function*(){return yield this.braintreeSdk.deinitialize(),Promise.resolve()})}handleError(e){throw new Error(e.message)}createBuyNowCart(e){return _a(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=null==e?void 0:e.getBuyNowCartRequestBody();if(!t)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new br}}})}handleInitializationVenmoError(e,t){return this.removeVenmoContainer(t),this.onError(e)}removeVenmoContainer(e){const t=document.getElementById(e);t&&t.remove()}renderVenmoButton(e,t,n,i){const r=document.getElementById(t),{color:o}=i||{};if(!r)throw new wr("Unable to create wallet button without valid container ID.");r.setAttribute("aria-label","Venmo"),Object.assign(r.style,Sa(i||{})),r.addEventListener("click",()=>_a(this,void 0,void 0,function*(){r.setAttribute("disabled","true");const t=yield this.createBuyNowCart(n);e.tokenize&&e.tokenize((e,n)=>_a(this,void 0,void 0,function*(){r.removeAttribute("disabled"),e&&this.onError(e),yield this.handlePostForm(n,null==t?void 0:t.id)}))})),o===Qo.BLUE&&(r.addEventListener("mouseenter",()=>{r.style.backgroundColor="#0a7fc2"}),r.addEventListener("mouseleave",()=>{r.style.backgroundColor=Sa(i||{}).backgroundColor}))}handlePostForm(e,t){return _a(this,void 0,void 0,function*(){const{deviceData:n}=yield this.braintreeSdk.getDataCollectorOrThrow(),{nonce:i,details:r}=e;this.formPoster.postForm("/checkout.php",Object.assign({nonce:i,provider:"braintreevenmo",payment_type:"paypal",device_data:n,action:"set_external_checkout",billing_address:JSON.stringify(ya(r)),shipping_address:JSON.stringify(fa(r))},t&&{cart_id:t}))})}}const Ca=Ir(e=>{const t=window,i=le(),r=new Br(e),o=new io(i,t,r),a=new Xr(o);return new va(e,n(),a)},[{id:"braintreevenmo"}]);class Ia{constructor(e){const t=new Promise((e,t)=>{this.cancel=t});this.promise=Promise.race([e,t])}}var wa;!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.BIGCOMMERCE_PAYMENTS="googlepay_bigcommerce_payments",e.CHECKOUT_COM="googlepaycheckoutcom",e.CYBERSOURCE_V2="googlepaycybersourcev2",e.ORBITAL="googlepayorbital",e.STRIPE="googlepaystripe",e.STRIPE_UPE="googlepaystripeupe",e.STRIPE_OCS="googlepaystripeocs",e.WORLDPAY_ACCESS="googlepayworldpayaccess",e.TD_ONLINE_MART="googlepaytdonlinemart"}(wa||(wa={}));const ba=function(e,t,n){return t&&n?Ea(0,t,n):function(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,Ea(e.prototype,n,i))}),t}(e)};function Ea(e,t,n){if("function"!=typeof n.value)return n;let i=n.value;return{get(){const e=i.bind(this);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=e}}}class Pa{constructor(e){if(!e)throw new Error("Currency settings missing");const{decimalPlaces:t,symbolLocation:n,symbol:i,thousandsSeparator:r,decimalSeparator:o}=e;if("string"!=typeof n||"string"!=typeof i||"string"!=typeof r||"string"!=typeof o||"string"!=typeof t)throw new wr("Invalid currency settings provided");this._decimalPlaces=parseInt(t,10),this._symbolLocation=n,this._symbol=i,this._thousandsSeparator=r,this._decimalSeparator=o}format(e){if("number"!=typeof e)throw new wr("Invalid amount provided");const t=this._formatNumber(e),n=this._formatCurrency(t);return e<0?`-${n}`:n}_formatNumber(e){const t=Math.abs(e),[n,i=""]=this._toFixed(t,this._decimalPlaces).split("."),r=n.replace(/\B(?=(\d{3})+(?!\d))/g,this._thousandsSeparator);return this._decimalPlaces<1?r:[r,i].join(this._decimalSeparator)}_formatCurrency(e){return"left"===this._symbolLocation.toLowerCase()?`${this._symbol}${e}`:`${e}${this._symbol}`}_toFixed(e,t){return(+`${Math.round(+`${e}e${t}`)}e${-t}`).toFixed(t)}}let Oa=class{constructor(e){this._storeConfig=e,this._customerFormatter=new Pa(this._storeConfig.shopperCurrency),this._storeFormatter=new Pa(this._storeConfig.currency)}toCustomerCurrency(e){const t=this._storeConfig.shopperCurrency.exchangeRate;return this._customerFormatter.format(e*t)}toStoreCurrency(e){return this._storeFormatter.format(e)}};Oa=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ba],Oa);const Aa=Oa;function Ta(){if("undefined"==typeof window)return!1;if(function(e){return"ReactNativeWebView"in e}(window))return!0;const e=navigator.userAgent||navigator.vendor||(function(e){return"opera"in e}(window)?window.opera:""),t=/android.+; wv/i.test(e),n=/iPhone|iPod|iPad/i.test(e)&&/AppleWebKit/i.test(e)&&!/Safari/i.test(e);return t||n}var ka,Ra,Da,Ma,Na,La,za,Ua,Fa;function Ba(e){return e in La}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(ka||(ka={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Ra||(Ra={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Da||(Da={})),function(e){e.pill="pill",e.rect="rect"}(Ma||(Ma={})),function(e){e.ESTIMATED="ESTIMATED",e.FINAL="FINAL",e.NOT_CURRENTLY_KNOWN="NOT_CURRENTLY_KNOWN"}(Na||(Na={})),function(e){e.AMEX="AMEX",e.DISCOVER="DISCOVER",e.INTERAC="INTERAC",e.JCB="JCB",e.MC="MASTERCARD",e.VISA="VISA"}(La||(La={})),function(e){e.OFFER="OFFER",e.PAYMENT_AUTHORIZATION="PAYMENT_AUTHORIZATION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.SHIPPING_OPTION="SHIPPING_OPTION"}(za||(za={})),function(e){e.OFFER_INVALID="OFFER_INVALID",e.PAYMENT_DATA_INVALID="PAYMENT_DATA_INVALID",e.SHIPPING_ADDRESS_INVALID="SHIPPING_ADDRESS_INVALID",e.SHIPPING_ADDRESS_UNSERVICEABLE="SHIPPING_ADDRESS_UNSERVICEABLE",e.SHIPPING_OPTION_INVALID="SHIPPING_OPTION_INVALID",e.OTHER_ERROR="OTHER_ERROR"}(Ua||(Ua={})),function(e){e.INITIALIZE="INITIALIZE",e.SHIPPING_OPTION="SHIPPING_OPTION",e.SHIPPING_ADDRESS="SHIPPING_ADDRESS",e.OFFER="OFFER"}(Fa||(Fa={}));var xa=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class qa{constructor(e,t){this._gatewayIdentifier=e,this._paymentIntegrationService=t,this._isBuyNowFlow=!1,this._shouldRequestShipping=!0,this._isWebViewExperimentOn=null}mapToShippingAddressRequestBody({shippingAddress:e}){if(!e)return;const{company:t="",phone:n=""}=this._paymentIntegrationService.getState().getShippingAddress()||{};return this._mapToAddressRequestBody(e,t,n)}mapToBillingAddressRequestBody(e){const{billingAddress:t}=e.paymentMethodData.info;if(!t)return;const{company:n="",phone:i="",email:r,customFields:o=[]}=this._paymentIntegrationService.getState().getBillingAddress()||{};return Object.assign(Object.assign({},this._mapToAddressRequestBody(t,n,i,o)),{email:r||e.email})}mapToExternalCheckoutData(e){var t;const{paymentMethodData:{tokenizationData:{token:n},info:{cardNetwork:i,cardDetails:r}}}=e;if(!n)throw new dr(ar.MissingPaymentToken);return Promise.resolve(Object.assign({nonce:n,card_information:{type:i,number:r}},this._isBuyNowFlow&&{cart_id:null===(t=this._paymentIntegrationService.getState().getCart())||void 0===t?void 0:t.id}))}getRequiredData(){return xa(this,void 0,void 0,function*(){var e;const t={emailRequired:!0};if(!this._isShippingAddressRequired())return t;const n=null===(e=(yield this._paymentIntegrationService.loadShippingCountries()).getShippingCountries())||void 0===e?void 0:e.map(e=>e.code);return Object.assign(Object.assign({},t),{shippingAddressRequired:!0,shippingAddressParameters:Object.assign({phoneNumberRequired:!0},n&&{allowedCountryCodes:n}),shippingOptionRequired:!0})})}getCallbackIntents(){return this._isShippingAddressRequired()?[za.OFFER,za.SHIPPING_ADDRESS,za.SHIPPING_OPTION]:[za.OFFER]}getCallbackTriggers(){return{availableTriggers:[Fa.INITIALIZE,Fa.SHIPPING_ADDRESS,Fa.SHIPPING_OPTION,Fa.OFFER],initializationTrigger:[Fa.INITIALIZE],addressChangeTriggers:[Fa.INITIALIZE,Fa.SHIPPING_ADDRESS],shippingOptionsChangeTriggers:[Fa.SHIPPING_OPTION],offerChangeTriggers:[Fa.OFFER]}}getNonce(e){var t;const n=null===(t=this._paymentIntegrationService.getState().getPaymentMethodOrThrow(e).initializationData)||void 0===t?void 0:t.nonce;if(!n)throw new dr(ar.MissingPaymentToken);return Promise.resolve(n)}extraPaymentData(){return Promise.resolve(void 0)}getMerchantInfo(){const{googleMerchantName:e,googleMerchantId:t,platformToken:n}=this.getGooglePayInitializationData();return{merchantName:e,merchantId:t,authJwt:n}}getTransactionInfo(){let e;const{getCartOrThrow:t}=this._paymentIntegrationService.getState();e=this._isBuyNowFlow?this._getCurrencyCodeOrThrow():t().currency.code;const n=this.getGooglePayInitializationData().storeCountry;if(this.isWebViewWithRestrictions()){const t=this.getTotalPrice();return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPrice:t,totalPriceStatus:Na.ESTIMATED})}return Object.assign(Object.assign({},n&&{countryCode:n}),{currencyCode:e,totalPriceStatus:Na.ESTIMATED,totalPrice:"0"})}isWebViewWithRestrictions(){return null!==this._isWebViewExperimentOn?this._isWebViewExperimentOn&&Ta():Ta()}setIsWebViewExperimentOn(e){this._isWebViewExperimentOn=e}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData().gatewayMerchantId;if(!e)throw new wr("Unable to proceed, gatewayMerchantId is missing.");return{gateway:this._gatewayIdentifier,gatewayMerchantId:e}}getCardParameters(){return{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:this.getPaymentMethod().supportedCards.filter(Ba).map(e=>La[e]),billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}}initialize(e,t,n){return this._getPaymentMethodFn=e,this._isBuyNowFlow=Boolean(t),this._currencyCode=n,this._isBuyNowFlow&&this._getCurrencyCodeOrThrow(),Promise.resolve()}handleShippingAddressChange(e){return xa(this,void 0,void 0,function*(){var t,n,i,r;e&&(e.name=e.name||"",e.address1=e.address1||"");const o=this.mapToShippingAddressRequestBody({shippingAddress:e});o&&(yield this._paymentIntegrationService.updateShippingAddress(o));const a=this._paymentIntegrationService.getState(),s=a.getConsignments();if(!(null==s?void 0:s[0]))return;const d=s[0],c=a.getStoreConfigOrThrow();this._currencyService||(this._currencyService=new Aa(c));const u=(d.availableShippingOptions||[]).map(this._getGooglePayShippingOption.bind(this)),l=null===(t=d.availableShippingOptions)||void 0===t?void 0:t.find(e=>e.isRecommended);if(u.length){const e=(null===(n=d.selectedShippingOption)||void 0===n?void 0:n.id)||(null==l?void 0:l.id)||(null===(i=u[0])||void 0===i?void 0:i.id);return!(null===(r=d.selectedShippingOption)||void 0===r?void 0:r.id)&&u[0]&&(yield this.handleShippingOptionChange((null==l?void 0:l.id)||u[0].id)),{defaultSelectedOptionId:e,shippingOptions:u}}})}handleShippingOptionChange(e){return xa(this,void 0,void 0,function*(){if("shipping_option_unselected"!==e)return this._paymentIntegrationService.selectShippingOption(e)})}getTotalPrice(){const{getCheckoutOrThrow:e,getCartOrThrow:t,getStoreConfigOrThrow:n}=this._paymentIntegrationService.getState(),{decimalPlaces:i}=t().currency,r=Lr(n().checkoutSettings.features,"PI-5075.google_pay_round_total_price_to_max_2_decimal_places")?Math.min(i,2):i;return L(e().outstandingBalance,r).toFixed(r)}handleCoupons(e){return xa(this,void 0,void 0,function*(){const{redemptionCodes:t=[]}=e,{offers:n}=this.getAppliedCoupons()||{};let i;return yield t.reduce((e,t)=>xa(this,void 0,void 0,function*(){if(yield e,(n||[]).some(({redemptionCode:e})=>e===t))return;const r=yield this.applyCoupon(t);r&&(i=r)}),Promise.resolve()),yield(n||[]).reduce((e,n)=>xa(this,void 0,void 0,function*(){yield e,t.includes(n.redemptionCode)||(yield this._paymentIntegrationService.removeCoupon(n.redemptionCode))}),Promise.resolve()),{newOfferInfo:this.getAppliedCoupons(),error:i}})}getAppliedCoupons(){const e=this._paymentIntegrationService.getState(),{coupons:t}=e.getCheckout()||{};return{offers:(t||[]).map(e=>{const{displayName:t,code:n}=e;return{redemptionCode:n,description:t}})}}applyCoupon(e){return xa(this,void 0,void 0,function*(){let t;try{yield this._paymentIntegrationService.applyCoupon(e)}catch(e){return e instanceof Error&&(t={reason:Ua.OFFER_INVALID,message:e.message,intent:Fa.OFFER}),t}})}setShouldRequestShipping(e){this._shouldRequestShipping=e}getGooglePayInitializationData(){return ur(this.getPaymentMethod().initializationData,()=>new wr("Missing initialization data."))}getPaymentMethod(){return ur(this._getPaymentMethodFn,()=>new lr(sr.PaymentNotInitialized))()}getGatewayIdentifier(){return this._gatewayIdentifier}setGatewayIdentifier(e){this._gatewayIdentifier=e||this.getGatewayIdentifier()}_isShippingAddressRequired(){const{getCartOrThrow:e,getStoreConfigOrThrow:t,getShippingAddress:n}=this._paymentIntegrationService.getState(),i=t();let r;return r=Lr(i.checkoutSettings.features,"PI-4290.google_pay_require_shipping_address")?this._shouldRequestShipping:void 0===n(),r&&(o=e(),a=i,!!o&&(!!o.lineItems.physicalItems.some(e=>e.isShippingRequired)||!(!a||!o.lineItems.customItems)&&o.lineItems.customItems.length>0));var o,a}_mapToAddressRequestBody(e,t,n,i){const{name:r,address1:o,address2:a,address3:s,locality:d,administrativeArea:c,countryCode:u,postalCode:l,phoneNumber:h}=e,[p,g]=this._getFirstAndLastName(r);return{firstName:p,lastName:g,company:t,address1:o,address2:`${a} ${s}`.trim(),city:d||c,stateOrProvince:c,stateOrProvinceCode:c,countryCode:u,postalCode:l,phone:h||n,customFields:i||[]}}_getFirstAndLastName(e){const t=e.split(" ");return 1===t.length?[e,""]:[t.slice(0,-1).join(" "),t[t.length-1]]}_getCurrencyCodeOrThrow(){return ur(this._currencyCode,()=>new wr('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}_getGooglePayShippingOption({id:e,cost:t,description:n,additionalDescription:i}){var r;return{id:e,label:`${(null===(r=this._currencyService)||void 0===r?void 0:r.toCustomerCurrency(t))||t} ${n}`,description:i}}}var ja=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ga extends qa{constructor(e,t){super("braintree",e),this._braintreeSdk=t,this._methodId=wa.BRAINTREE,this._service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ja(this,void 0,void 0,function*(){yield i.initialize.call(this,e,t,n);let r=i.getPaymentMethod.call(this);if(r.clientToken||(r=(yield this._service.loadPaymentMethod(this._methodId)).getPaymentMethodOrThrow(this._methodId)),!r.clientToken||!r.initializationData)throw new dr(ar.MissingPaymentMethod);return this._braintreeSdk.initialize(r.clientToken),this._braintreeGooglePayment=yield this._braintreeSdk.getBraintreeGooglePayment(),Promise.resolve()})}getNonce(e){const t=Object.create(null,{getNonce:{get:()=>super.getNonce},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ja(this,void 0,void 0,function*(){var n;const i=yield t.getNonce.call(this,e),{clientToken:r,initializationData:o}=t.getPaymentMethod.call(this);if(!r||!o||!(null===(n=o.card_information)||void 0===n?void 0:n.bin))throw new dr(ar.MissingPaymentMethod);const{isThreeDSecureEnabled:a,card_information:{bin:s,isNetworkTokenized:d}}=o;if(a&&!d){const e=yield this._braintreeSdk.getBraintreeThreeDS(),{orderAmount:t}=this._service.getState().getOrderOrThrow();return(yield this._braintreePresent3DSChallenge(e,t,i,s)).nonce}return i})}extraPaymentData(){return ja(this,void 0,void 0,function*(){return{deviceSessionId:yield this._getBraintreeDeviceData()}})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return ja(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new wr("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 dr(ar.MissingPaymentToken)}(i),n.nonce=i.androidPayCards[0].nonce,n.card_information.bin=i.androidPayCards[0].details.bin,n.card_information.isNetworkTokenized=i.androidPayCards[0].details.isNetworkTokenized,n})}getCardParameters(){return super.getCardParameters()}getPaymentGatewayParameters(){const e=Object.create(null,{getMerchantInfo:{get:()=>super.getMerchantInfo},getTransactionInfo:{get:()=>super.getTransactionInfo},getRequiredData:{get:()=>super.getRequiredData}});return ja(this,void 0,void 0,function*(){return this.getBraintreeGooglePayment().createPaymentDataRequest(Object.assign({merchantInfo:e.getMerchantInfo.call(this),transactionInfo:e.getTransactionInfo.call(this),cardRequirements:{billingAddressRequired:!0,billingAddressFormat:"FULL"}},yield e.getRequiredData.call(this))).paymentMethodTokenizationParameters.parameters})}getBraintreeGooglePayment(){if(!this._braintreeGooglePayment)throw new dr(ar.MissingPaymentMethod);return this._braintreeGooglePayment}_getBraintreeDeviceData(){return ja(this,void 0,void 0,function*(){const{deviceData:e}=yield this._braintreeSdk.getDataCollectorOrThrow();return e})}_braintreePresent3DSChallenge(e,t,n,i){return new Ia(e.verifyCard({amount:t,bin:i,nonce:n,onLookupComplete:(e,t)=>{t()}})).promise}}class Va extends ve{constructor(e){super(e||"Unable to proceed because the client library of a payment method has thrown an unexpected error."),this.name="PaymentMethodFailedError",this.type="payment_method_client_invalid"}}var Ha=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Wa{constructor(e,t){this._paymentIntegrationService=e,this._googlePayPaymentProcessor=t}initialize(e){return Ha(this,void 0,void 0,function*(){var t,n,i,r;if(!e.methodId||(r=e.methodId,!Object.values(wa).includes(r)))throw new wr('Unable to proceed because "methodId" is not a valid key.');if(this._methodId=e.methodId,!e.containerId)throw new wr('Unable to proceed because "containerId" is not a valid key.');const o=e[this._getMethodOrThrow()];if(!o)throw new wr("Unable to proceed without valid options.");const{buyNowInitializeOptions:a,currencyCode:s,buttonColor:d,buttonType:c,onError:u}=o;let l,h=this._paymentIntegrationService.getState();try{l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}catch(e){h=yield this._paymentIntegrationService.loadPaymentMethod(this._getMethodOrThrow()),l=h.getPaymentMethodOrThrow(this._getMethodOrThrow())}if(this._countryCode=null===(t=l.initializationData)||void 0===t?void 0:t.storeCountry,this._googlePayPaymentProcessor.setIsWebViewExperimentOn(!!(null===(n=l.initializationData)||void 0===n?void 0:n.isWebViewExperimentOn)),a){if(!s)throw new wr('Unable to initialize payment because "options.currencyCode" argument is not provided.');this._currencyCode=s,this._buyNowInitializeOptions=a,yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions(),!!a,s)}else yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initialize(()=>l,this._getGooglePayClientOptions());this._paymentButton=null!==(i=this._paymentButton)&&void 0!==i?i:this._googlePayPaymentProcessor.addPaymentButton(e.containerId,{buttonColor:null!=d?d:"default",buttonType:null!=c?c:"plain",onClick:this._handleClick(u)})})}deinitialize(){var e;return null===(e=this._paymentButton)||void 0===e||e.remove(),this._paymentButton=void 0,this._methodId=void 0,Promise.resolve()}_handleClick(e){return t=>Ha(this,void 0,void 0,function*(){t.preventDefault();try{this._buyNowInitializeOptions?yield this._createBuyNowCartOrThrow(this._buyNowInitializeOptions):yield this._paymentIntegrationService.loadDefaultCheckout(),yield this._googlePayPaymentProcessor.initializeWidget(),yield this._interactWithPaymentSheet()}catch(t){let n=t;if(function(e){return"object"==typeof e&&null!==e&&"statusCode"in e}(t)){if("CANCELED"===t.statusCode)throw new ro;n=new Va(JSON.stringify(t))}throw null==e||e(new Va("An error occurred while requesting your Google Pay payment details.")),n}})}_interactWithPaymentSheet(){return Ha(this,void 0,void 0,function*(){var e;const t=yield this._googlePayPaymentProcessor.showPaymentSheet(),n=this._googlePayPaymentProcessor.mapToBillingAddressRequestBody(t),i=this._googlePayPaymentProcessor.mapToShippingAddressRequestBody(t),r="/embedded-checkout"===window.location.pathname?this._paymentIntegrationService.getState().getStoreConfigOrThrow().links.siteLink:void 0;n&&(yield this._paymentIntegrationService.updateBillingAddress(n)),i&&!(null===(e=this._buyNowCart)||void 0===e?void 0:e.lineItems.digitalItems.length)&&(yield this._paymentIntegrationService.updateShippingAddress(i)),yield this._googlePayPaymentProcessor.setExternalCheckoutForm(this._getMethodOrThrow(),t,r)})}_getGooglePayClientOptions(){return this._googlePayPaymentProcessor.isWebViewWithRestrictions()?{}:{paymentDataCallbacks:{onPaymentDataChanged:e=>Ha(this,[e],void 0,function*({callbackTrigger:e,shippingAddress:t,shippingOptionData:n,offerData:i}){const{availableTriggers:r,addressChangeTriggers:o,shippingOptionsChangeTriggers:a,offerChangeTriggers:s}=this._googlePayPaymentProcessor.getCallbackTriggers();if(!r.includes(e))return;const d=o.includes(e)?yield this._googlePayPaymentProcessor.handleShippingAddressChange(t):void 0;a.includes(e)&&(yield this._googlePayPaymentProcessor.handleShippingOptionChange(n.id));const{newOfferInfo:c,error:u}=s.includes(e)?yield this._googlePayPaymentProcessor.handleCoupons(i):{},l=u;return this._buyNowInitializeOptions?this._getBuyNowTransactionInfo(d,c,l):this._getTransactionInfo(d,c,l)})}}}_createBuyNowCartOrThrow(e){return Ha(this,void 0,void 0,function*(){if("function"==typeof(null==e?void 0:e.getBuyNowCartRequestBody)){const t=e.getBuyNowCartRequestBody();try{this._buyNowCart=yield this._paymentIntegrationService.createBuyNowCart(t),yield this._paymentIntegrationService.loadCheckout(this._buyNowCart.id)}catch(e){if("string"==typeof e)throw new br(e);throw e}}})}_getBuyNowTransactionInfo(e,t,n){if(!this._buyNowCart)return;const{cartAmount:i}=this._buyNowCart,r=this._googlePayPaymentProcessor.getTotalPrice();return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:this._getCurrencyCodeOrThrow(),totalPrice:r||String(i),totalPriceStatus:Na.FINAL})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})}_getTransactionInfo(e,t,n){return Ha(this,void 0,void 0,function*(){yield this._paymentIntegrationService.loadCheckout();const i=this._googlePayPaymentProcessor.getTotalPrice(),{code:r}=this._paymentIntegrationService.getState().getCartOrThrow().currency;return Object.assign(Object.assign(Object.assign({newTransactionInfo:Object.assign(Object.assign({},this._countryCode&&{countryCode:this._countryCode}),{currencyCode:r,totalPriceStatus:Na.FINAL,totalPrice:i})},e&&{newShippingOptionParameters:e}),t&&{newOfferInfo:t}),n&&{error:n})})}_getMethodOrThrow(){return ur(this._methodId,()=>new lr(sr.PaymentNotInitialized))}_getCurrencyCodeOrThrow(){return ur(this._currencyCode,()=>new wr('Unable to initialize payment because "options.currencyCode" argument is not provided.'))}}var Ya=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ka{constructor(e,t,n,i){this._scriptLoader=e,this._gateway=t,this._requestSender=n,this._formPoster=i,this._baseRequest={apiVersion:2,apiVersionMinor:0}}initialize(e,t,n,i){return Ya(this,void 0,void 0,function*(){this._paymentsClient=yield this._scriptLoader.getGooglePaymentsClient(e().config.testMode,t),yield this._gateway.initialize(e,n,i),this._buildButtonPayloads()})}initializeWidget(){return Ya(this,void 0,void 0,function*(){yield this._buildWidgetPayloads(),yield this._determineReadinessToPay(),this._prefetchGooglePaymentData()})}getNonce(e){return this._gateway.getNonce(e)}extraPaymentData(){return Ya(this,void 0,void 0,function*(){return this._gateway.extraPaymentData()})}addPaymentButton(e,t){const n=document.querySelector(`#${e}`);if(!n)return;const i=this._getPaymentsClient().createButton(Object.assign(Object.assign({},t),{allowedPaymentMethods:[this._getBaseCardPaymentMethod()]}));return n.appendChild(i)}showPaymentSheet(){return Ya(this,void 0,void 0,function*(){const e=this._getPaymentDataRequest();return this._getPaymentsClient().loadPaymentData(e)})}setExternalCheckoutXhr(e,t){return Ya(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t)})}setExternalCheckoutForm(e,t,n){return Ya(this,void 0,void 0,function*(){return this._setExternalCheckout(e,t,!0,n)})}mapToBillingAddressRequestBody(e){return this._gateway.mapToBillingAddressRequestBody(e)}mapToShippingAddressRequestBody(e){return this._gateway.mapToShippingAddressRequestBody(e)}processAdditionalAction(e,t){return"processAdditionalAction"in this._gateway?this._gateway.processAdditionalAction(e,t):Promise.reject(e)}signOut(e){return Ya(this,void 0,void 0,function*(){yield this._requestSender.get(`/remote-checkout/${e}/signout`)})}getCallbackTriggers(){return this._gateway.getCallbackTriggers()}setShouldRequestShipping(e){return this._gateway.setShouldRequestShipping(e)}handleShippingAddressChange(e){return Ya(this,void 0,void 0,function*(){return this._gateway.handleShippingAddressChange(e)})}handleShippingOptionChange(e){return Ya(this,void 0,void 0,function*(){yield this._gateway.handleShippingOptionChange(e)})}handleCoupons(e){return Ya(this,void 0,void 0,function*(){return this._gateway.handleCoupons(e)})}getTotalPrice(){return this._gateway.getTotalPrice()}_setExternalCheckout(e,t){return Ya(this,arguments,void 0,function*(e,t,n=!1,i){const r="/checkout.php",o=Object.assign({action:"set_external_checkout",provider:e},yield this._gateway.mapToExternalCheckoutData(t));if(n)return new Promise(e=>{this._formPoster.postForm(i?`${i}/checkout`:r,Object.assign(Object.assign({},o),{card_information:JSON.stringify(o.card_information)}),e)});yield this._requestSender.post(r,{headers:Object.assign({Accept:"text/html","Content-Type":"application/x-www-form-urlencoded"},Dr),body:o})})}isWebViewWithRestrictions(){return this._gateway.isWebViewWithRestrictions()}setIsWebViewExperimentOn(e){return this._gateway.setIsWebViewExperimentOn(e)}_prefetchGooglePaymentData(){const e=this._getPaymentDataRequest();e.transactionInfo=this._gateway.getTransactionInfo(),this._getPaymentsClient().prefetchPaymentData(e)}_determineReadinessToPay(){return Ya(this,void 0,void 0,function*(){try{const{result:e}=yield this._getPaymentsClient().isReadyToPay(this._getIsReadyToPayRequest());if(!1===e)throw new Va("Google Pay is not supported by the current device and browser, please try another payment method.")}catch(e){if(e instanceof Va)throw e;throw new Va}})}_buildButtonPayloads(){this._baseCardPaymentMethod={type:"CARD",parameters:this._gateway.getCardParameters()}}_buildWidgetPayloads(){return Ya(this,void 0,void 0,function*(){const e=this._getBaseCardPaymentMethod();this._cardPaymentMethod=Object.assign(Object.assign({},e),{tokenizationSpecification:{type:"PAYMENT_GATEWAY",parameters:yield this._gateway.getPaymentGatewayParameters()}});const t=this._gateway.isWebViewWithRestrictions()?{shippingOptionRequired:!1}:{callbackIntents:this._gateway.getCallbackIntents(),offerInfo:this._gateway.getAppliedCoupons()};this._paymentDataRequest=Object.assign(Object.assign(Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[this._cardPaymentMethod],transactionInfo:this._gateway.getTransactionInfo(),merchantInfo:this._gateway.getMerchantInfo()}),yield this._gateway.getRequiredData()),t),this._isReadyToPayRequest=Object.assign(Object.assign({},this._baseRequest),{allowedPaymentMethods:[e]})})}_getBaseCardPaymentMethod(){return this._getOrThrow(this._baseCardPaymentMethod)}_getPaymentDataRequest(){return this._getOrThrow(this._paymentDataRequest)}_getIsReadyToPayRequest(){return this._getOrThrow(this._isReadyToPayRequest)}_getPaymentsClient(){return this._getOrThrow(this._paymentsClient)}_getOrThrow(e){return ur(e,()=>new lr(sr.PaymentNotInitialized))}}class $a{constructor(e){this._scriptLoader=e,this._window=window}getGooglePaymentsClient(){return e=this,t=arguments,i=function*(e=!1,t){if(yield this._scriptLoader.loadScript("https://pay.google.com/gp/p/js/pay.js"),!this._window.google)throw new vr;return void 0===this._paymentsClient&&(this._paymentsClient=new this._window.google.payments.api.PaymentsClient(Object.assign({environment:e?"TEST":"PRODUCTION"},null!=t?t:{}))),this._paymentsClient},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}function Za(){return new $a(le())}const Ja=Ir(t=>{const i=e(),r=window,o=new Br(t),a=new Xr(new io(le(),r,o));return new Wa(t,new Ka(Za(),new Ga(t,a),i,n()))},[{id:"googlepaybraintree"}]),Qa=["ar_BH","ar_DZ","ar_EG","ar_JO","ar_KW","ar_MA","ar_OM","ar_QA","ar_SA","ar_TN","ar_YE","ar_AE","bg_BG","cs_CZ","da_DK","da_FO","da_GL","de_AT","de_CH","de_DE","de_LU","el_GR","en_AD","en_AE","en_AG","en_AI","en_AL","en_AM","en_AN","en_AO","en_AT","en_AU","en_AW","en_AZ","en_BB","en_BE","en_BH","en_BJ","en_BM","en_BN","en_BS","en_BT","en_BW","en_BY","en_BZ","en_C2","en_CA","en_CD","en_CG","en_CH","en_CI","en_CK","en_CL","en_CM","en_CN","en_CO","en_CR","en_CV","en_CY","en_CZ","en_DE","en_DJ","en_DK","en_DM","en_DO","en_DZ","en_EC","en_EE","en_EG","en_ER","en_ES","en_ET","en_FI","en_FJ","en_FK","en_FM","en_FO","en_FR","en_GA","en_GB","en_GD","en_GE","en_GF","en_GI","en_GL","en_GM","en_GN","en_GP","en_GR","en_GT","en_GW","en_GY","en_HK","en_HN","en_HR","en_HU","en_ID","en_IE","en_IL","en_IN","en_IS","en_IT","en_JM","en_JO","en_JP","en_KE","en_KG","en_KH","en_KI","en_KM","en_KN","en_KR","en_KW","en_KY","en_KZ","en_LA","en_LC","en_LI","en_LK","en_LS","en_LT","en_LU","en_LV","en_MA","en_MC","en_MD","en_ME","en_MG","en_MH","en_MK","en_ML","en_MN","en_MQ","en_MR","en_MS","en_MT","en_MU","en_MV","en_MW","en_MY","en_MZ","en_NA","en_NC","en_NE","en_NF","en_NG","en_NI","en_NL","en_NO","en_NP","en_NR","en_NU","en_NZ","en_OM","en_PA","en_PE","en_PF","en_PG","en_PH","en_PL","en_PM","en_PN","en_PT","en_PW","en_PY","en_QA","en_RE","en_RO","en_RS","en_RU","en_RW","en_SA","en_SB","en_SC","en_SE","en_SG","en_SH","en_SI","en_SJ","en_SK","en_SL","en_SM","en_SN","en_SO","en_SR","en_ST","en_SV","en_SZ","en_TC","en_TD","en_TG","en_TH","en_TJ","en_TM","en_TN","en_TO","en_TR","en_TT","en_TV","en_TW","en_TZ","en_UA","en_UG","en_US","en_UY","en_VA","en_VC","en_VE","en_VG","en_VN","en_VU","en_WF","en_WS","en_YE","en_YT","en_ZA","en_ZM","en_ZW","es_AD","es_AI","es_AO","es_AR","es_AW","es_BB","es_BJ","es_BM","es_BO","es_BS","es_BZ","es_CD","es_CG","es_CK","es_CL","es_CO","es_CR","es_CV","es_DJ","es_DM","es_DO","es_DZ","es_EC","es_EG","es_ER","es_ES","es_ET","es_FJ","es_FK","es_FO","es_GA","es_GD","es_GE","es_GI","es_GL","es_GM","es_GN","es_GT","es_GW","es_GY","es_HN","es_IE","es_JM","es_JO","es_KE","es_KG","es_KI","es_KM","es_KN","es_KW","es_KY","es_KZ","es_LC","es_LI","es_LS","es_LU","es_MA","es_MG","es_MH","es_ML","es_MR","es_MS","es_MU","es_MW","es_MX","es_MZ","es_NA","es_NC","es_NE","es_NF","es_NI","es_NR","es_NU","es_NZ","es_OM","es_PA","es_PE","es_PF","es_PG","es_PM","es_PN","es_PW","es_PY","es_QA","es_RS","es_RW","es_SA","es_SB","es_SC","es_SH","es_SJ","es_SL","es_SM","es_SN","es_SO","es_SR","es_ST","es_SV","es_SZ","es_TC","es_TD","es_TG","es_TJ","es_TM","es_TN","es_TT","es_TV","es_UA","es_UG","es_US","es_UY","es_VA","es_VC","es_VE","es_VG","es_VU","es_WF","es_YE","es_ZM","et_EE","fi_FI","fr_AD","fr_AE","fr_AI","fr_AM","fr_AO","fr_AW","fr_AZ","fr_BB","fr_BE","fr_BF","fr_BI","fr_BJ","fr_BM","fr_BS","fr_BZ","fr_CA","fr_CD","fr_CG","fr_CH","fr_CI","fr_CK","fr_CM","fr_CV","fr_DJ","fr_DM","fr_DO","fr_DZ","fr_EC","fr_ER","fr_ET","fr_FJ","fr_FK","fr_FO","fr_FR","fr_GA","fr_GD","fr_GE","fr_GF","fr_GI","fr_GL","fr_GM","fr_GN","fr_GP","fr_GT","fr_GW","fr_GY","fr_HN","fr_IE","fr_JM","fr_JO","fr_KE","fr_KG","fr_KI","fr_KM","fr_KN","fr_KW","fr_KY","fr_KZ","fr_LC","fr_LI","fr_LS","fr_LU","fr_MA","fr_MC","fr_MG","fr_MH","fr_ML","fr_MQ","fr_MR","fr_MS","fr_MU","fr_MW","fr_MZ","fr_NA","fr_NC","fr_NE","fr_NF","fr_NI","fr_NR","fr_NU","fr_NZ","fr_OM","fr_PA","fr_PE","fr_PF","fr_PG","fr_PM","fr_PN","fr_PW","fr_QA","fr_RE","fr_RS","fr_RW","fr_SA","fr_SB","fr_SC","fr_SH","fr_SJ","fr_SL","fr_SM","fr_SN","fr_SO","fr_SR","fr_ST","fr_SV","fr_SZ","fr_TC","fr_TD","fr_TG","fr_TJ","fr_TM","fr_TN","fr_TT","fr_TV","fr_UA","fr_UG","fr_US","fr_UY","fr_VA","fr_VC","fr_VE","fr_VG","fr_VU","fr_WF","fr_YE","fr_YT","fr_ZA","fr_ZM","he_IL","hu_HU","id_ID","it_IT","ja_JP","ko_KR","lv_LV","lt_LT","ms_BN","ms_MY","nl_BE","nl_NL","pl_PL","pt_BR","pt_PT","ro_RO","ru_EE","ru_LT","ru_LV","ru_RU","ru_UA","si_LK","sk_SK","sl_SI","sq_AL","sv_SE","tl_PH","th_TH","tr_TR","vi_VN","zh_C2","zh_CN","zh_HK","zh_TW","zh_AD","zh_AE","zh_AI","zh_AO","zh_AW","zh_BB","zh_BH","zh_BJ","zh_BM","zh_BS","zh_BZ","zh_CD","zh_CG","zh_CK","zh_CL","zh_CO","zh_CV","zh_DJ","zh_DM","zh_DO","zh_DZ","zh_EC","zh_EG","zh_ER","zh_ET","zh_FJ","zh_FK","zh_FO","zh_GA","zh_GD","zh_GE","zh_GI","zh_GL","zh_GM","zh_GN","zh_GT","zh_GW","zh_GY","zh_HN","zh_IE","zh_JM","zh_JO","zh_KE","zh_KG","zh_KI","zh_KM","zh_KN","zh_KW","zh_KY","zh_KZ","zh_LC","zh_LI","zh_LS","zh_LT","zh_LU","zh_MA","zh_MG","zh_MH","zh_ML","zh_MR","zh_MS","zh_MU","zh_MW","zh_MZ","zh_NA","zh_NC","zh_NE","zh_NF","zh_NI","zh_NR","zh_NU","zh_NZ","zh_OM","zh_PA","zh_PE","zh_PF","zh_PG","zh_PM","zh_PN","zh_PW","zh_QA","zh_RS","zh_RW","zh_SA","zh_SB","zh_SC","zh_SH","zh_SJ","zh_SL","zh_SM","zh_SN","zh_SO","zh_SR","zh_ST","zh_SV","zh_SZ","zh_TC","zh_TD","zh_TG","zh_TJ","zh_TM","zh_TN","zh_TT","zh_TV","zh_UA","zh_UG","zh_US","zh_UY","zh_VA","zh_VC","zh_VE","zh_VG","zh_VU","zh_WF","zh_YE","zh_ZA","zh_ZM"];function Xa(e){if(!e)return;let t;if(e.includes("-")){const[n,i]=e.split("-");t=`${n}_${i.toUpperCase()}`}else t=`${e}_${e.toUpperCase()}`;return Qa.includes(t)?t:void 0}var es=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ts{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n,i){return es(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypalFastlaneSdk)throw new vr}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,r){return es(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(r)}if(!this.window.paypalGooglePay)throw new vr;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return es(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new vr}return this.window.paypalApms})}getPayPalMessages(e,t,n){return es(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new vr;return this.window.paypalMessages})}loadPayPalSdk(e){return es(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n,i){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,attributionId:c}=o,u=Xa(i);return{options:Object.assign({"client-id":s,"merchant-id":d,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t,intent:a},u&&{locale:u}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,p=l||i,g=Xa(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:p,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),g&&{locale:g}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:r,clientId:o,merchantId:a,buyerCountry:s,attributionId:d,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:u=[],enabledAlternativePaymentMethods:l=[]}=i,h=l,p=u.filter(e=>!l.includes(e)),g=Xa(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":p.length>0?p:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),g&&{locale:g}),attributes:{"data-partner-attribution-id":d,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new dr(ar.MissingPaymentMethod);const{clientId:r,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:d}=i,c=Xa(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":d}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}function ns(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 dr(ar.MissingPaymentMethod)}var is=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class rs extends qa{constructor(e,t){super("paypalsb",e),this.payPalCommerceSdk=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return is(this,void 0,void 0,function*(){var r,o,a,s,d;const c=this.service.getState(),u=null!==(o=null===(r=c.getStoreConfig())||void 0===r?void 0:r.currency.code)&&void 0!==o?o:n;if(!u)throw new dr(ar.MissingPaymentMethod);yield i.initialize.call(this,e,t,u);const l=i.getPaymentMethod.call(this);if(!l.initializationData)throw new dr(ar.MissingPaymentMethod);ns(l);const h=yield this.payPalCommerceSdk.getPayPalGooglePaySdk(l,u,c.getLocale());this.googlepayConfig=yield h.Googlepay().config();const{allowedPaymentMethods:p}=this.googlepayConfig;this.setGatewayIdentifier(null===(d=null===(s=null===(a=p[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===d?void 0:d.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return is(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const os=Ir(t=>new Wa(t,new Ka(Za(),new rs(t,new ts(le())),e(),n())),[{id:"googlepaypaypalcommerce"}]);var as=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ss{constructor(e){this.scriptLoader=e,this.window=window}getPayPalFastlaneSdk(e,t,n){return as(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsFastlaneSdk){const i=this.getPayPalFastlaneSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.bigCommercePaymentsFastlaneSdk)throw new vr}return this.window.bigCommercePaymentsFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i){return as(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsGooglePay||i){const i=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.bigCommercePaymentsGooglePay)throw new vr;return this.window.bigCommercePaymentsGooglePay})}getPayPalApmsSdk(e,t){return as(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsApms){const n=this.getPayPalApmSdkConfiguration(e,t);if(yield this.loadPayPalSdk(n),!this.window.bigCommercePaymentsApms)throw new vr}return this.window.bigCommercePaymentsApms})}getPayPalMessages(e,t){return as(this,void 0,void 0,function*(){if(!this.window.bigCommercePaymentsMessages){const n=this.getPayPalSdkMessagesConfiguration(e,t);yield this.loadPayPalSdk(n)}if(!this.window.bigCommercePaymentsMessages)throw new vr;return this.window.bigCommercePaymentsMessages})}loadPayPalSdk(e){return as(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalFastlaneSdkConfiguration(e,t,n){const{clientToken:i,initializationData:r}=e;if(!r||!r.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,attributionId:d}=r;return{options:{"client-id":a,"merchant-id":s,commit:!0,components:["fastlane","three-domain-secure"],currency:t,intent:o},attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"bigCommercePaymentsFastlaneSdk","data-partner-attribution-id":d,"data-sdk-client-token":i}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n=!0){const{clientToken:i,initializationData:r}=e;if(!r||!r.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:o,clientId:a,merchantId:s,buyerCountry:d,attributionId:c,isHostedCheckoutEnabled:u,isDeveloperModeApplicable:l}=r,h=u||n;return{options:Object.assign({"client-id":a,"merchant-id":s,commit:h,components:["googlepay"],currency:t,intent:o},l&&{"buyer-country":d}),attributes:{"data-partner-attribution-id":c,"data-client-token":i,"data-namespace":"bigCommercePaymentsGooglePay"}}}getPayPalApmSdkConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:i,clientId:r,merchantId:o,buyerCountry:a,attributionId:s,isDeveloperModeApplicable:d,availableAlternativePaymentMethods:c=[],enabledAlternativePaymentMethods:u=[]}=n,l=this.filterFundingOptions(u),h=this.filterFundingOptions(c.filter(e=>!u.includes(e)));return{options:Object.assign({"client-id":r,"merchant-id":o,"enable-funding":l.length>0?l:void 0,"disable-funding":h.length>0?h:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:i},d&&{"buyer-country":a}),attributes:{"data-partner-attribution-id":s,"data-namespace":"bigCommercePaymentsApms"}}}getPayPalSdkMessagesConfiguration(e,t){const{initializationData:n}=e;if(!n||!n.clientId)throw new dr(ar.MissingPaymentMethod);const{clientId:i,merchantId:r,attributionId:o,isDeveloperModeApplicable:a,buyerCountry:s}=n;return{options:Object.assign({"client-id":i,"merchant-id":r,components:["messages"],currency:t},a&&{"buyer-country":s}),attributes:{"data-namespace":"bigCommercePaymentsMessages","data-partner-attribution-id":o}}}filterFundingOptions(e){const t=["klarna","afterpay"];return e?e.filter(e=>!t.includes(e)):[]}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var ds=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class cs extends qa{constructor(e,t){super("googlepay_bigcommerce_payments",e),this.payPalSdkHelper=t,this.service=e}initialize(e,t,n){const i=Object.create(null,{initialize:{get:()=>super.initialize},getPaymentMethod:{get:()=>super.getPaymentMethod}});return ds(this,void 0,void 0,function*(){var r,o,a,s,d;const c=null!==(o=null===(r=this.service.getState().getStoreConfig())||void 0===r?void 0:r.currency.code)&&void 0!==o?o:n;if(!c)throw new dr(ar.MissingPaymentMethod);yield i.initialize.call(this,e,t,c);const u=i.getPaymentMethod.call(this);if(!u.initializationData)throw new dr(ar.MissingPaymentMethod);ns(u);const l=yield this.payPalSdkHelper.getPayPalGooglePaySdk(u,c);this.googlepayConfig=yield l.Googlepay().config();const{allowedPaymentMethods:h}=this.googlepayConfig;this.setGatewayIdentifier(null===(d=null===(s=null===(a=h[0])||void 0===a?void 0:a.tokenizationSpecification)||void 0===s?void 0:s.parameters)||void 0===d?void 0:d.gateway)})}getPaymentGatewayParameters(){if(this.googlepayConfig){const{allowedPaymentMethods:e}=this.googlepayConfig,{gatewayMerchantId:t}=e[0].tokenizationSpecification.parameters;return{gateway:this.getGatewayIdentifier(),gatewayMerchantId:t}}return{gateway:this.getGatewayIdentifier()}}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return ds(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n})}}const us=Ir(t=>new Wa(t,new Ka(Za(),new cs(t,new ss(le())),e(),n())),[{id:"googlepay_bigcommerce_payments"}]),ls=Ir(t=>{const i=e();return new Wa(t,new Ka(Za(),new qa("adyen",t),i,n()))},[{id:"googlepayadyenv2"}]),hs=Ir(t=>{const i=e();return new Wa(t,new Ka(Za(),new qa("adyen",t),i,n()))},[{id:"googlepayadyenv3"}]);class ps extends qa{constructor(e){super("authorizenet",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return function(e){if(!function(e){return"paymentGatewayId"in e}(e))throw new dr(ar.MissingPaymentMethod)}(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.paymentGatewayId}}}const gs=Ir(t=>new Wa(t,new Ka(Za(),new ps(t),e(),n())),[{id:"googlepayauthorizenet"}]),ms=e=>"object"==typeof e&&null!==e&&"body"in e;function ys(e){if(!function(e){return"checkoutcomkey"in e}(e))throw new dr(ar.MissingPaymentMethod)}var fs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class _s extends qa{constructor(e,t){super("checkoutltd",e),this._requestSender=t}processAdditionalAction(e){return new Promise((t,n)=>{if(ms(e)&&function(e){var t;if("object"!=typeof e||null===e)return!1;const n=e;return"string"==typeof(null===(t=n.three_ds_result)||void 0===t?void 0:t.acs_url)&&"string"==typeof n.three_ds_result.code}(e.body)&&"three_d_secure_required"===e.body.three_ds_result.code)return window.location.assign(e.body.three_ds_result.acs_url);n(e)})}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return fs(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new wr("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"protocolVersion"in e&&"signature"in e&&"signedMessage"in e}(e))throw new dr(ar.MissingPaymentToken)}(i),n.nonce=yield this._tokenize(i),n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();return ys(e),{gateway:this.getGatewayIdentifier(),gatewayMerchantId:e.checkoutcomkey}}_tokenize(e){return fs(this,void 0,void 0,function*(){const t=this.getPaymentMethod().config.testMode?"https://api.sandbox.checkout.com/tokens":"https://api.checkout.com/tokens",n=this.getGooglePayInitializationData();ys(n);const{body:i}=yield this._requestSender.post(t,{credentials:!1,body:{type:"googlepay",token_data:e},headers:{Authorization:n.checkoutcomkey,"Content-Type":Rr.Json,"X-XSRF-TOKEN":null}});return i.token})}}const Ss=Ir(t=>{const i=e();return new Wa(t,new Ka(Za(),new _s(t,i),i,n()))},[{id:"googlepaycheckoutcom"}]);class vs extends qa{constructor(e){super("cybersource",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Cs=Ir(t=>new Wa(t,new Ka(Za(),new vs(t),e(),n())),[{id:"googlepaycybersourcev2"},{id:"googlepaybnz"}]);class Is extends qa{constructor(e){super("chase",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const ws=Ir(t=>new Wa(t,new Ka(Za(),new Is(t),e(),n())),[{id:"googlepayorbital"}]);var bs,Es,Ps,Os,As,Ts,ks,Rs,Ds,Ms,Ns,Ls;!function(e){e.SHIPPING="shipping",e.BILLING="billing"}(bs||(bs={})),function(e){e.SPLIT="split",e.FULL="full",e.ORGANIZATION="organization"}(Es||(Es={})),function(e){e.Open="open",e.Expired="expired",e.Complete="complete"}(Ps||(Ps={})),function(e){e.Paid="paid",e.UnPaid="unpaid",e.NoPaymentRequired="no_payment_required"}(Os||(Os={})),function(e){e.SUCCESS="success",e.ERROR="error"}(As||(As={})),function(e){e.CreditCard="card",e.ACH="us_bank_account",e.Link="link",e.EPS="eps",e.GRABPAY="grabpay",e.BANCONTACT="bancontact",e.IDEAL="ideal",e.ALIPAY="alipay",e.KLARNA="klarna",e.OCS="optimized_checkout",e.CHECKOUT_SESSION="checkout_session"}(Ts||(Ts={})),function(e){e.NEVER="never",e.AUTO="auto",e.ALWAYS="always",e.PAYMENT="payment",e.IF_REQUIRED="if_required"}(ks||(ks={})),function(e){e.V3="v3",e.ACACIA="acacia",e.BASIL="basil",e.CLOVER="clover"}(Rs||(Rs={})),function(e){e.PAYMENT="payment",e.AUTHENTICATION="linkAuthentication",e.SHIPPING="address",e.EXPRESS_CHECKOUT="expressCheckout"}(Ds||(Ds={})),function(e){e.REQUIRES_PAYMENT_METHOD="requires_payment_method",e.REQUIRES_CONFIRMATION="requires_confirmation",e.REQUIRES_ACTION="requires_action",e.PROCESSING="processing",e.SUCCEEDED="succeeded",e.CANCELED="canceled"}(Ms||(Ms={})),function(e){e.CLICK="click",e.CHANGE="change",e.READY="ready",e.SHIPPING_ADDRESS_CHANGE="shippingaddresschange",e.SHIPPING_RATE_CHANGE="shippingratechange",e.CONFIRM="confirm",e.CANCEL="cancel",e.LOADER_START="loaderstart"}(Ns||(Ns={})),function(e){e.ON_SESSION="on_session",e.OFF_SESSION="off_session"}(Ls||(Ls={}));var zs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Us{constructor(e,t=window){this.scriptLoader=e,this.stripeWindow=t}getStripeClient(e,t,n,i,r){return zs(this,void 0,void 0,function*(){if(this.stripeWindow.bcStripeClient)return this.stripeWindow.bcStripeClient;const o=yield this.load(n),{stripePublishableKey:a,stripeConnectedAccount:s}=e,d=o(a,Object.assign(Object.assign(Object.assign(Object.assign({},s?{stripeAccount:s}:{}),t?{locale:t}:{}),i?{betas:i}:{}),r?{apiVersion:r}:{}));return Object.assign(this.stripeWindow,{bcStripeClient:d}),d})}getElements(e,t){return zs(this,void 0,void 0,function*(){let n=this.stripeWindow.bcStripeElements;return n?yield this.updateStripeElements(t):(n=e.elements(t),Object.assign(this.stripeWindow,{bcStripeElements:n})),n})}updateStripeElements(e){return zs(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeElements;t&&(t.update(e),yield t.fetchUpdates())})}getStripeCheckout(e,t){return zs(this,void 0,void 0,function*(){let n=yield this.getStoredStripeCheckout(t);return n||(n=yield e.initCheckout(t),Object.assign(this.stripeWindow,{bcStripeCheckout:n})),n})}load(e){return zs(this,void 0,void 0,function*(){if(!this.stripeWindow.Stripe&&(yield this.scriptLoader.loadScript(this.getScriptUrl(e)),!this.stripeWindow.Stripe))throw new vr;return this.stripeWindow.Stripe})}getScriptUrl(e){return e&&e!==Rs.V3?`https://js.stripe.com/${e}/stripe.js`:"https://js.stripe.com/v3/"}getStoredStripeCheckout(e){return zs(this,void 0,void 0,function*(){const t=this.stripeWindow.bcStripeCheckout;if(t)try{const{actions:n,error:i}=yield t.loadActions();if(i||!n)return void this.logErrorToConsole(i);const r=yield n.getSession(),o=e.clientSecret.split("_secret_")[0];if(r.id===o)return t}catch(e){return void this.logErrorToConsole(e)}})}logErrorToConsole(e){e?console.error(e):console.error("No stripe checkout actions available on loadActions().")}}const Fs=["payment_element_beta_2","alipay_pm_beta_1","link_default_integration_beta_1","shipping_address_element_beta_1","address_element_beta_1"];function Bs(e){if(!function(e){return"stripeConnectedAccount"in e&&"stripePublishableKey"in e&&"stripeVersion"in e}(e))throw new dr(ar.MissingPaymentMethod)}var xs=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class qs extends qa{constructor(e,t){super("stripe",e),this.paymentIntegrationService=e,this.scriptLoader=t}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return xs(this,void 0,void 0,function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);let i;try{i=JSON.parse(n.nonce)}catch(e){throw new wr("Unable to parse response from Google Pay.")}return function(e){if(!function(e){return"object"==typeof e&&null!==e&&"id"in e}(e))throw new dr(ar.MissingPaymentToken)}(i),n.nonce=i.id,n})}getPaymentGatewayParameters(){const e=this.getGooglePayInitializationData();Bs(e);const{stripeVersion:t,stripePublishableKey:n,stripeConnectedAccount:i}=e;return{gateway:this.getGatewayIdentifier(),"stripe:version":t,"stripe:publishableKey":`${n}/${i}`}}processAdditionalAction(e,t){return xs(this,void 0,void 0,function*(){var n,i;if(!t)throw new Wo(["payment"]);if(!ms(e)||("object"!=typeof(i=e.body)||null===i||!("three_ds_result"in i)||!("errors"in i)))throw e;if(z(e.body.errors,{code:"three_d_secure_required"})){const i=this.getGooglePayInitializationData();Bs(i),this.stripeUPEClient=yield this.loadStripeJs(i,t);const r=e.body.three_ds_result.token;let o,a=!1;try{o=yield this.stripeUPEClient.confirmCardPayment(r)}catch(e){try{o=yield this.stripeUPEClient.retrievePaymentIntent(r)}catch(e){a=!0}}if(null==o?void 0:o.error){if(this._throwDisplayableStripeError(o.error),this._isCancellationError(o.error))throw new ro;throw new Va}if(!(null==o?void 0:o.paymentIntent)&&!a)throw new Ie;return this.paymentIntegrationService.submitPayment({methodId:t,paymentData:{nonce:(null===(n=null==o?void 0:o.paymentIntent)||void 0===n?void 0:n.id)||r}})}throw e})}loadStripeJs(e,t){return xs(this,void 0,void 0,function*(){if(this.stripeUPEClient)return this.stripeUPEClient;const n=this.paymentIntegrationService.getState().getCartLocale();return"googlepaystripeocs"===t&&e.useNewStripeJsVersion?this.scriptLoader.getStripeClient(e,n,Rs.CLOVER):this.scriptLoader.getStripeClient(e,n,Rs.V3,Fs,"2020-03-02;alipay_beta=v1;link_beta=v1")})}_isCancellationError(e){var t,n;return e&&-1!==(null===(n=null===(t=e.payment_intent.last_payment_error)||void 0===t?void 0:t.message)||void 0===n?void 0:n.indexOf("canceled"))}_throwDisplayableStripeError(e){if(m(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}}const js=Ir(t=>new Wa(t,new Ka(Za(),new qs(t,new Us(le())),e(),n())),[{id:"googlepaystripe"},{id:"googlepaystripeupe"},{id:"googlepaystripeocs"}]);class Gs extends qa{constructor(e){super("worldpay",e)}mapToExternalCheckoutData(e){const t=Object.create(null,{mapToExternalCheckoutData:{get:()=>super.mapToExternalCheckoutData}});return n=this,i=void 0,o=function*(){const n=yield t.mapToExternalCheckoutData.call(this,e);return n.nonce=btoa(n.nonce),n},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}const Vs=Ir(t=>new Wa(t,new Ka(Za(),new Gs(t),e(),n())),[{id:"googlepayworldpayaccess"}]);function Hs(){const{navigator:e}=window;let t;return t=e.language?e.language:e.userLanguage,{color_depth:window.screen.colorDepth||24,java_enabled:"function"==typeof e.javaEnabled&&e.javaEnabled(),language:t,screen_height:window.screen.height,screen_width:window.screen.width,time_zone_offset:(new Date).getTimezoneOffset().toString()}}var Ws=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Ys extends qa{constructor(e,t){super("worldlinena",e),this.formPoster=t}extraPaymentData(){return Ws(this,void 0,void 0,function*(){return Promise.resolve({browser_info:Hs()})})}processAdditionalAction(e){return Ws(this,void 0,void 0,function*(){if(!function(e){return ms(e)&&(t=e.body,C(t)&&"object"==typeof t&&"errors"in t&&"three_ds_result"in t&&y(t.errors)&&z(t.errors,{code:"three_d_secure_required"}));var t}(e))throw e;const{three_ds_result:t}=e.body,{acs_url:n,payer_auth_request:i,merchant_data:r}=t||{};if(!n||!i||!r)throw new Wo(["formUrl","threeDSSessionData","creq"]);return new Promise(e=>{this.formPoster.postForm(n,{threeDSSessionData:i,creq:r},e,"_top")})})}}const Ks=Ir(t=>new Wa(t,new Ka(Za(),new Ys(t,n()),e(),n())),[{id:"googlepaytdonlinemart"}]);var $s,Zs,Js,Qs,Xs,ed,td,nd,id,rd,od=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ad{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return od(this,void 0,void 0,function*(){if(!this.window.paypal||r){const r=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypal)throw new vr}return this.window.paypal})}getPayPalFastlaneSdk(e,t,n,i){return od(this,void 0,void 0,function*(){if(!this.window.paypalFastlaneSdk){const r=this.getPayPalFastlaneSdkConfiguration(e,t,n,i);if(yield this.loadPayPalSdk(r),!this.window.paypalFastlaneSdk)throw new vr}return this.window.paypalFastlaneSdk})}getPayPalGooglePaySdk(e,t,n,i,r){return od(this,void 0,void 0,function*(){if(!this.window.paypalGooglePay||r){const r=this.getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i);yield this.loadPayPalSdk(r)}if(!this.window.paypalGooglePay)throw new vr;return this.window.paypalGooglePay})}getPayPalApmsSdk(e,t,n){return od(this,void 0,void 0,function*(){if(!this.window.paypalApms){const i=this.getPayPalApmSdkConfiguration(e,t,n);if(yield this.loadPayPalSdk(i),!this.window.paypalApms)throw new vr}return this.window.paypalApms})}getPayPalMessages(e,t,n){return od(this,void 0,void 0,function*(){if(!this.window.paypalMessages){const i=this.getPayPalSdkMessagesConfiguration(e,t,n);yield this.loadPayPalSdk(i)}if(!this.window.paypalMessages)throw new vr;return this.window.paypalMessages})}loadPayPalSdk(e){return od(this,arguments,void 0,function*({options:e,attributes:t}){const n=this.transformConfig(e),i=this.transformConfig(t),r=`https://www.paypal.com/sdk/js?${new URLSearchParams(n).toString()}`;yield this.scriptLoader.loadScript(r,{async:!0,attributes:i})})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!a||!a.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:s,clientId:d,merchantId:c,buyerCountry:u,attributionId:l,isVenmoEnabled:h,isHostedCheckoutEnabled:p,isPayPalCreditAvailable:g,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:y=[],enabledAlternativePaymentMethods:f=[],isGooglePayEnabled:_}=a,S=p||i,v="paypalcommercecreditcards"===r||"bigcommerce_payments_creditcards"===r,C=v?["card"]:[],I=g?["credit","paylater"]:[],w=h?["venmo"]:[],b=_?["googlepay"]:[],E=i?["card-fields"]:[],P=[...v?[]:["card"],...g?[]:["credit","paylater"],...h?[]:["venmo"],...y.filter(e=>!f.includes(e))],O=[...C,...I,...w,...f],A=Xa(n);return{options:Object.assign(Object.assign({"client-id":d,"merchant-id":c,"enable-funding":O.length>0?O:void 0,"disable-funding":P.length>0?P:void 0,commit:S,components:["buttons","hosted-fields","payment-fields","legal",...b,...E],currency:t,intent:s},m&&{"buyer-country":u}),A&&{locale:A}),attributes:{"data-partner-attribution-id":l,"data-client-token":o}}}getPayPalFastlaneSdkConfiguration(e,t,n,i){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,attributionId:c}=o,u=Xa(i);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:!0,components:["fastlane","buttons","payment-fields","hosted-fields","three-domain-secure"],currency:t},u&&{locale:u}),{intent:a}),attributes:{"data-client-metadata-id":n.replace(/-/g,""),"data-namespace":"paypalFastlaneSdk","data-partner-attribution-id":c,"data-sdk-client-token":r}}}getPayPalGooglePaySdkScriptConfigOrThrow(e,t,n,i=!0){const{clientToken:r,initializationData:o}=e;if(!o||!o.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:a,clientId:s,merchantId:d,buyerCountry:c,attributionId:u,isHostedCheckoutEnabled:l,isDeveloperModeApplicable:h}=o,p=l||i,g=Xa(n);return{options:Object.assign(Object.assign({"client-id":s,"merchant-id":d,commit:p,components:["googlepay"],currency:t,intent:a},h&&{"buyer-country":c}),g&&{locale:g}),attributes:{"data-partner-attribution-id":u,"data-client-token":r,"data-namespace":"paypalGooglePay"}}}getPayPalApmSdkConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new dr(ar.MissingPaymentMethod);const{intent:r,clientId:o,merchantId:a,buyerCountry:s,attributionId:d,isDeveloperModeApplicable:c,availableAlternativePaymentMethods:u=[],enabledAlternativePaymentMethods:l=[]}=i,h=l,p=u.filter(e=>!l.includes(e)),g=Xa(n);return{options:Object.assign(Object.assign({"client-id":o,"merchant-id":a,"enable-funding":h.length>0?h:void 0,"disable-funding":p.length>0?p:void 0,commit:!0,components:["buttons","payment-fields"],currency:t,intent:r},c&&{"buyer-country":s}),g&&{locale:g}),attributes:{"data-partner-attribution-id":d,"data-namespace":"paypalApms"}}}getPayPalSdkMessagesConfiguration(e,t,n){const{initializationData:i}=e;if(!i||!i.clientId)throw new dr(ar.MissingPaymentMethod);const{clientId:r,merchantId:o,attributionId:a,isDeveloperModeApplicable:s,buyerCountry:d}=i,c=Xa(n);return{options:Object.assign(Object.assign({"client-id":r,"merchant-id":o,components:["messages"],currency:t},s&&{"buyer-country":d}),c&&{locale:c}),attributes:{"data-namespace":"paypalMessages","data-partner-attribution-id":a}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}!function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}($s||($s={})),function(e){e.Always="SCA_ALWAYS"}(Zs||(Zs={})),function(e){e.Succeeded="succeeded",e.Cancelled="cancelled",e.Errored="errored"}(Js||(Js={})),function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(Qs||(Qs={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Xs||(Xs={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(ed||(ed={})),function(e){e.pill="pill",e.rect="rect"}(td||(td={})),function(e){e.SUCCEEDED="succeeded",e.FAILED="failed",e.CANCELED="canceled",e.UNRECOGNIZED="unrecognized"}(nd||(nd={})),(id||(id={})).OXXO="oxxo",function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(rd||(rd={}));var sd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class dd{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.paypalRequestSender=n,this.paypalSdkLoader=i}loadPayPalSdk(e,t,n,i){return sd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e),s=r.getLocale();return this.paypalSdk=yield this.paypalSdkLoader.getPayPalSDK(a,o,s,n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new vr;return this.paypalSdk}createBuyNowCartOrThrow(e){return sd(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new br}})}createOrder(e,t){return sd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.paypalRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return sd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.paypalRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e,t,n,i){return sd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=r.getCartOrThrow();let a;i||(a=r.getConsignmentsOrThrow()[0]);try{yield this.paypalRequestSender.updateOrder(e,Object.assign(Object.assign({availableShippingOptions:i?[]:null==a?void 0:a.availableShippingOptions,cartId:o.id,selectedShippingOption:i?null:null==a?void 0:a.selectedShippingOption},t?{methodId:t}:{}),n?{orderId:n}:{}))}catch(e){throw new Ie}})}getOrderStatus(e,t){return sd(this,void 0,void 0,function*(){try{const{status:n}=yield this.paypalRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new dr(ar.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===go.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return sd(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{if(t.selectedShippingOption){const n=t.selectedShippingOption.id;return e.id===n}return!1}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e={}){const{color:t,height:n,label:i,shape:r}=e,o={color:t&&ed[t]?t:void 0,height:this.getValidHeight(n),label:i&&Xs[i]?i:void 0,shape:r&&td[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var cd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ud{constructor(e){this.requestSender=e}createOrder(e,t){return cd(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e,t){return cd(this,void 0,void 0,function*(){const n=`/api/storefront/initialization/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.put(n,{headers:r,body:i})).body})}getOrderStatus(e,t){return cd(this,void 0,void 0,function*(){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}const ld=t=>{const{getHost:i}=t.getState();return new dd(n(),t,new ud(e({host:i()})),new ad(le()))};var hd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const pd=class{constructor(e,t){this.paymentIntegrationService=e,this.paypalIntegrationService=t}createPayPalButton(e,t,n,i){const{style:r,fundingSource:o,isHostedCheckoutEnabled:a,isServerSideShippingCallbacksEnabled:s,onClick:d,onCancel:c,onPaymentComplete:u,onError:l}=n;this.onError=l;const h=this.paypalIntegrationService.getPayPalSdkOrThrow();if(!Object.values(h.FUNDING).includes(o))throw new wr('Unable to initialize PayPal button because "fundingSource" argument is not valid funding source.');const p=Object.assign(Object.assign({},!s&&{onShippingAddressChange:t=>this.onShippingAddressChange(t,e),onShippingOptionsChange:t=>this.onShippingOptionsChange(t,e)}),{onApprove:(n,i)=>this.onHostedCheckoutApprove(n,i,t,e,u,s)});return h.Buttons(Object.assign(Object.assign(Object.assign({fundingSource:o,style:this.paypalIntegrationService.getValidButtonStyle(r),createOrder:()=>hd(this,void 0,void 0,function*(){if(i){const e=yield this.paypalIntegrationService.createBuyNowCartOrThrow(i);yield this.paymentIntegrationService.loadCheckout(e.id)}return this.paypalIntegrationService.createOrder(e)}),onApprove:({orderID:e})=>this.paypalIntegrationService.tokenizePayment(t,e)},d?{onClick:d}:{}),c?{onCancel:c}:{}),a&&p))}onHostedCheckoutApprove(e,t,n,i,r,o){return hd(this,void 0,void 0,function*(){if(!e.orderID)throw new dr(ar.MissingOrderId);const a=this.paymentIntegrationService.getState().getCartOrThrow();try{const s=a.lineItems.physicalItems.length>0;if(!o){const e=yield t.order.get(),n=this.paypalIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),s){const t=this.paypalIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}s&&(yield this.paypalIntegrationService.updateOrder(i,void 0,void 0,o)),o&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.paypalIntegrationService.submitPayment(n,e.orderID),r&&"function"==typeof r&&r()}catch(e){this.handleError(e)}})}onShippingAddressChange(e,t){return hd(this,void 0,void 0,function*(){const n=this.paypalIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(n),yield this.paymentIntegrationService.updateShippingAddress(n);const e=this.paypalIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.paypalIntegrationService.updateOrder(t)}catch(e){this.handleError(e)}})}onShippingOptionsChange(e,t){return hd(this,void 0,void 0,function*(){const n=this.paypalIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(n.id),yield this.paypalIntegrationService.updateOrder(t)}catch(e){this.handleError(e)}})}handleError(e){if("function"!=typeof this.onError)throw e;this.onError(e)}};class gd{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalIntegrationService=t,this.paypalButtonCreationService=n}initialize(e){return t=this,n=void 0,r=function*(){var t;const{paypalcommerce:n,containerId:i,methodId:r}=e,o=Boolean(null==n?void 0:n.buyNowInitializeOptions);if(!r)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!i)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.paypalcommerce" argument is not provided.');if(o&&!n.currencyCode)throw new wr('Unable to initialize payment because "options.paypalcommerce.currencyCode" argument is not provided.');if(o&&"function"!=typeof(null===(t=n.buyNowInitializeOptions)||void 0===t?void 0:t.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.paypalcommerce.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');o||(yield this.paymentIntegrationService.loadDefaultCheckout());const a=o?n.currencyCode:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.paypalIntegrationService.loadPayPalSdk(r,a,!1),this.renderButton(i,r,n)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.paypalIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},h=Object.assign(Object.assign({fundingSource:s.FUNDING.PAYPAL,style:this.paypalIntegrationService.getValidButtonStyle(r),isServerSideShippingCallbacksEnabled:u,isHostedCheckoutEnabled:c},i&&l),c&&o&&{onPaymentComplete:()=>o()}),p=this.paypalButtonCreationService.createPayPalButton("paypalcommerce",t,h,i);p.isEligible()?p.render(`#${e}`):a&&"function"==typeof a?a():this.paypalIntegrationService.removeElement(e)}}const md=Ir(e=>{const t=ld(e),n=new pd(e,t);return new gd(e,t,n)},[{id:"paypalcommerce"}]);var yd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class fd{constructor(e,t){this.paymentIntegrationService=e,this.paypalIntegrationService=t}initialize(e){return yd(this,void 0,void 0,function*(){const{paypalcommercecredit:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.paypalcommercecredit" argument is not provided.');if(a&&!o)throw new wr('Unable to initialize payment because "options.paypalcommercecredit.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.paypalcommercecredit.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=this.paymentIntegrationService.getState(),d=a?o:s.getCartOrThrow().currency.code;yield this.paypalIntegrationService.loadPayPalSdk(i,d,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onComplete:o,onEligibilityFailure:a}=n,s=this.paypalIntegrationService.getPayPalSdkOrThrow(),d=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),{isHostedCheckoutEnabled:c,isServerSideShippingCallbacksEnabled:u}=d.initializationData||{},l={createOrder:()=>this.paypalIntegrationService.createOrder("paypalcommercecredit"),onApprove:({orderID:e})=>this.paypalIntegrationService.tokenizePayment(t,e)},h={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},p=Object.assign(Object.assign({},!u&&{onShippingAddressChange:e=>this.onShippingAddressChange(e),onShippingOptionsChange:e=>this.onShippingOptionsChange(e)}),{onApprove:(e,n)=>this.onHostedCheckoutApprove(e,n,t,o,u)}),g=[s.FUNDING.PAYLATER,s.FUNDING.CREDIT];let m=!1;g.forEach(t=>{if(!m){const n=Object.assign(Object.assign(Object.assign({fundingSource:t,style:this.paypalIntegrationService.getValidButtonStyle(r)},l),i&&h),c&&p),o=s.Buttons(n);o.isEligible()?(o.render(`#${e}`),m=!0):a&&"function"==typeof a&&a()}}),m||this.paypalIntegrationService.removeElement(e)}handleClick(e){return yd(this,void 0,void 0,function*(){if(e){const t=yield this.paypalIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}onHostedCheckoutApprove(e,t,n,i,r){return yd(this,void 0,void 0,function*(){if(!e.orderID)throw new dr(ar.MissingOrderId);const o=this.paymentIntegrationService.getState().getCartOrThrow();try{const a=o.lineItems.physicalItems.length>0;if(!r){const e=yield t.order.get(),n=this.paypalIntegrationService.getBillingAddressFromOrderDetails(e);if(yield this.paymentIntegrationService.updateBillingAddress(n),a){const t=this.paypalIntegrationService.getShippingAddressFromOrderDetails(e);yield this.paymentIntegrationService.updateShippingAddress(t)}}return a&&(yield this.paypalIntegrationService.updateOrder("paypalcommerce",void 0,void 0,r)),r&&(yield this.paymentIntegrationService.loadCheckout()),yield this.paymentIntegrationService.submitOrder({},{params:{methodId:n}}),yield this.paypalIntegrationService.submitPayment(n,e.orderID),i&&"function"==typeof i&&i(),!0}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingAddressChange(e){return yd(this,void 0,void 0,function*(){const t=this.paypalIntegrationService.getAddress({city:e.shippingAddress.city,countryCode:e.shippingAddress.countryCode,postalCode:e.shippingAddress.postalCode,stateOrProvinceCode:e.shippingAddress.state});try{yield this.paymentIntegrationService.updateBillingAddress(t),yield this.paymentIntegrationService.updateShippingAddress(t);const e=this.paypalIntegrationService.getShippingOptionOrThrow();yield this.paymentIntegrationService.selectShippingOption(e.id),yield this.paypalIntegrationService.updateOrder("paypalcommerce")}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}onShippingOptionsChange(e){return yd(this,void 0,void 0,function*(){const t=this.paypalIntegrationService.getShippingOptionOrThrow(e.selectedShippingOption.id);try{yield this.paymentIntegrationService.selectShippingOption(t.id),yield this.paypalIntegrationService.updateOrder("paypalcommerce")}catch(e){if("string"==typeof e)throw new Error(e);throw e}})}}const _d=Ir(e=>new fd(e,ld(e)),[{id:"paypalcommercecredit"}]);var Sd,vd,Cd,Id,wd,bd,Ed;!function(e){e.Possible="POSSIBLE",e.No="NO",e.Unknown="UNKNOWN",e.Yes="YES"}(Sd||(Sd={})),function(e){e.AUTHORIZE="authorize",e.CAPTURE="capture"}(vd||(vd={})),function(e){e.paypal="paypal",e.checkout="checkout",e.buynow="buynow",e.pay="pay",e.installment="installment"}(Cd||(Cd={})),function(e){e.gold="gold",e.blue="blue",e.silver="silver",e.black="black",e.white="white"}(Id||(Id={})),function(e){e.pill="pill",e.rect="rect"}(wd||(wd={})),function(e){e.OXXO="oxxo",e.IDEAL="ideal"}(bd||(bd={})),function(e){e.Approved="APPROVED",e.Created="CREATED",e.PayerActionRequired="PAYER_ACTION_REQUIRED",e.PollingStop="POLLING_STOP",e.PollingError="POLLING_ERROR"}(Ed||(Ed={}));var Pd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Od{constructor(e,t,n,i){this.formPoster=e,this.paymentIntegrationService=t,this.paypalCommerceRequestSender=n,this.paypalCommerceScriptLoader=i}loadPayPalSdk(e,t,n,i){return Pd(this,void 0,void 0,function*(){const r=this.paymentIntegrationService.getState(),o=t||r.getCartOrThrow().currency.code,a=r.getPaymentMethodOrThrow(e);return this.paypalSdk=yield this.paypalCommerceScriptLoader.getPayPalSDK(a,o,r.getLocale(),n,i),this.paypalSdk})}getPayPalSdkOrThrow(){if(!this.paypalSdk)throw new vr;return this.paypalSdk}createBuyNowCartOrThrow(e){return Pd(this,void 0,void 0,function*(){const t=e.getBuyNowCartRequestBody();if(!t)throw new dr(ar.MissingCart);try{return yield this.paymentIntegrationService.createBuyNowCart(t)}catch(e){throw new br}})}createOrder(e,t){return Pd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i}=yield this.paypalCommerceRequestSender.createOrder(e,Object.assign({cartId:n},t));return i})}createOrderCardFields(e,t){return Pd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState().getCartOrThrow().id,{orderId:i,setupToken:r}=yield this.paypalCommerceRequestSender.createOrder(e,Object.assign({cartId:n},t));return Object.assign({orderId:i},r?{setupToken:r}:{})})}updateOrder(e){return Pd(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState(),n=t.getCartOrThrow(),i=t.getConsignmentsOrThrow()[0];try{yield this.paypalCommerceRequestSender.updateOrder({availableShippingOptions:e?[]:i.availableShippingOptions,cartId:n.id,selectedShippingOption:e?null:i.selectedShippingOption})}catch(e){throw new Ie}})}getOrderStatus(e,t){return Pd(this,void 0,void 0,function*(){try{const{status:n}=yield this.paypalCommerceRequestSender.getOrderStatus(e,t);return n}catch(e){throw new Ie}})}tokenizePayment(e,t){const n=this.paymentIntegrationService.getState().getCartOrThrow();if(!t)throw new dr(ar.MissingOrderId);return this.formPoster.postForm("/checkout.php",Object.assign({payment_type:"paypal",action:"set_external_checkout",provider:e,order_id:t},n.source===go.BuyNow&&{cart_id:n.id}))}submitPayment(e,t,n){return Pd(this,void 0,void 0,function*(){const i={formattedPayload:{vault_payment_instrument:null,set_as_default_stored_instrument:null,device_info:null,method_id:e,paypal_account:{order_id:t}}};yield this.paymentIntegrationService.submitPayment(Object.assign({methodId:e,paymentData:i},n?{gatewayId:n}:{}))})}getShippingOptionOrThrow(e){const t=this.paymentIntegrationService.getState().getConsignmentsOrThrow()[0],n=t.availableShippingOptions||[],i=n.find(e=>e.isRecommended),r=(e?n.find(t=>t.id===e):n.find(e=>{var n;return e.id===(null===(n=t.selectedShippingOption)||void 0===n?void 0:n.id)}))||i||n[0];if(!r)throw new Error("Your order can't be shipped to this address");return r}getAddress(e){return{firstName:(null==e?void 0:e.firstName)||"",lastName:(null==e?void 0:e.lastName)||"",email:(null==e?void 0:e.email)||"",phone:(null==e?void 0:e.phone)||"",company:"",address1:(null==e?void 0:e.address1)||"",address2:(null==e?void 0:e.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:[]}}getBillingAddressFromOrderDetails({payer:e}){var t,n;return this.getAddress({firstName:e.name.given_name,lastName:e.name.surname,email:e.email_address,address1:e.address.address_line_1,address2:e.address.address_line_2,city:e.address.admin_area_2,countryCode:e.address.country_code,postalCode:e.address.postal_code,stateOrProvinceCode:e.address.admin_area_1,phone:null===(n=null===(t=e.phone)||void 0===t?void 0:t.phone_number)||void 0===n?void 0:n.national_number})}getShippingAddressFromOrderDetails(e){const{payer:t,purchase_units:n}=e,{address:i,name:{full_name:r}}=n[0].shipping,[o,...a]=r.split(" ");return this.getAddress({firstName:o,lastName:a.join(" "),email:t.email_address,address1:i.address_line_1,address2:i.address_line_2,city:i.admin_area_2,countryCode:i.country_code,postalCode:i.postal_code,stateOrProvinceCode:i.admin_area_1})}getValidButtonStyle(e){const{color:t,height:n,label:i,shape:r}=e||{},o={color:t&&Id[t]?t:void 0,height:this.getValidHeight(n),label:i&&Cd[i]?i:void 0,shape:r&&wd[r]?r:void 0};return R(o,v)}getValidHeight(e){return e&&"number"==typeof e?e>55?55:e<25?25:e:40}removeElement(e){const t=e&&document.getElementById(e);t&&(t.style.display="none")}}var Ad=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Td{constructor(e){this.requestSender=e}createOrder(e,t){return Ad(this,void 0,void 0,function*(){const n=`/api/storefront/payment/${e}`,i=t,r=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.post(n,{headers:r,body:i})).body})}updateOrder(e){return Ad(this,void 0,void 0,function*(){const t=e,n=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.put("/api/storefront/initialization/paypalcommerce",{headers:n,body:t})).body})}getOrderStatus(){return Ad(this,arguments,void 0,function*(e="paypalcommerce",t){const n=`/api/storefront/initialization/${e}`,i=Object.assign({"X-API-INTERNAL":Tr,"Content-Type":Rr.Json},Dr);return(yield this.requestSender.get(n,Object.assign({headers:i},t))).body})}}var kd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Rd{constructor(e){this.scriptLoader=e,this.window=window}getPayPalSDK(e,t,n,i,r){return kd(this,void 0,void 0,function*(){const o=this.getPayPalSdkScriptConfigOrThrow(e,t,n,i);return this.loadPayPalSDK(o,r)})}loadPayPalSDK(e){return kd(this,arguments,void 0,function*(e,t=!1){if(!this.window.paypal||t){const t=this.transformConfig(e.options),n=this.transformConfig(e.attributes),i=`https://www.paypal.com/sdk/js?${new URLSearchParams(t).toString()}`;yield this.scriptLoader.loadScript(i,{async:!0,attributes:n})}if(!this.window.paypal)throw new vr;return this.window.paypal})}getPayPalSdkScriptConfigOrThrow(e,t,n,i=!0){const{id:r,clientToken:o,initializationData:a}=e;if(!(null==a?void 0:a.clientId))throw new dr(ar.MissingPaymentMethod);const{intent:s,clientId:d,merchantId:c,buyerCountry:u,attributionId:l,isVenmoEnabled:h,isHostedCheckoutEnabled:p,isPayPalCreditAvailable:g,isDeveloperModeApplicable:m,availableAlternativePaymentMethods:y=[],enabledAlternativePaymentMethods:f=[],isGooglePayEnabled:_}=a,S=p||i,v="paypalcommercecreditcards"===r,C=v?["card"]:[],I=g?["credit","paylater"]:[],w=h?["venmo"]:[],b=_?["googlepay"]:[],E=i?["card-fields"]:[],P=[...v?[]:["card"],...g?[]:["credit","paylater"],...h?[]:["venmo"],...y.filter(e=>!f.includes(e))],O=[...C,...I,...w,...f],A=Xa(n);return{options:Object.assign(Object.assign({"client-id":d,"merchant-id":c,"enable-funding":O.length>0?O:void 0,"disable-funding":P.length>0?P:void 0,commit:S,components:["buttons","hosted-fields","payment-fields","legal",...b,...E],currency:t,intent:s},m&&{"buyer-country":u}),A&&{locale:A}),attributes:{"data-partner-attribution-id":l,"data-client-token":o}}}transformConfig(e){let t={};return Object.keys(e).forEach(n=>{const i=e[n];null==i||""===i||Array.isArray(i)&&0===i.length||(t=Object.assign(Object.assign({},t),{[n]:Array.isArray(i)?i.join(","):i}))}),t}}var Dd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Md{constructor(e,t){this.paymentIntegrationService=e,this.paypalCommerceIntegrationService=t}initialize(e){return Dd(this,void 0,void 0,function*(){const{paypalcommercevenmo:t,containerId:n,methodId:i}=e,{buyNowInitializeOptions:r,currencyCode:o}=t||{},a=!!r;if(!i)throw new wr('Unable to initialize payment because "options.methodId" argument is not provided.');if(!n)throw new wr('Unable to initialize payment because "options.containerId" argument is not provided.');if(!t)throw new wr('Unable to initialize payment because "options.paypalcommercevenmo" argument is not provided.');if(a&&!o)throw new wr('Unable to initialize payment because "options.paypalcommercevenmo.currencyCode" argument is not provided.');if(a&&"function"!=typeof(null==r?void 0:r.getBuyNowCartRequestBody))throw new wr('Unable to initialize payment because "options.paypalcommercevenmo.buyNowInitializeOptions.getBuyNowCartRequestBody" argument is not provided or it is not a function.');a||(yield this.paymentIntegrationService.loadDefaultCheckout());const s=a?o:this.paymentIntegrationService.getState().getCartOrThrow().currency.code;yield this.paypalCommerceIntegrationService.loadPayPalSdk(i,s,!1),this.renderButton(n,i,t)})}deinitialize(){return Promise.resolve()}renderButton(e,t,n){const{buyNowInitializeOptions:i,style:r,onEligibilityFailure:o}=n,a=this.paypalCommerceIntegrationService.getPayPalSdkOrThrow(),s=a.FUNDING.VENMO,d={createOrder:()=>this.paypalCommerceIntegrationService.createOrder("paypalcommercevenmo"),onApprove:({orderID:e})=>this.paypalCommerceIntegrationService.tokenizePayment(t,e)},c={onClick:()=>this.handleClick(i),onCancel:()=>this.paymentIntegrationService.loadDefaultCheckout()},u=Object.assign(Object.assign({fundingSource:s,style:this.getValidVenmoButtonStyles(r)},d),i&&c),l=a.Buttons(u);l.isEligible()?l.render(`#${e}`):o&&"function"==typeof o?o():this.paypalCommerceIntegrationService.removeElement(e)}getValidVenmoButtonStyles(e){const t=this.paypalCommerceIntegrationService.getValidButtonStyle(e);return t.color===Id.gold?Object.assign(Object.assign({},t),{color:void 0}):t}handleClick(e){return Dd(this,void 0,void 0,function*(){if(e){const t=yield this.paypalCommerceIntegrationService.createBuyNowCartOrThrow(e);yield this.paymentIntegrationService.loadCheckout(t.id)}})}}const Nd=Ir(t=>new Md(t,(t=>{const{getHost:i}=t.getState();return new Od(n(),t,new Td(e({host:i()})),new Rd(le()))})(t)),[{id:"paypalcommercevenmo"}]);var Ld,zd,Ud,Fd,Bd,xd;!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Ld||(Ld={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(zd||(zd={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black"}(Ud||(Ud={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(Fd||(Fd={})),function(e){e.PILL="pill",e.RECT="rect"}(Bd||(Bd={})),function(e){e.ACKNOWLEDGE="ACKNOWLEDGE",e.FINALIZE="FINALIZE",e.INITIALIZE="INITIALIZE"}(xd||(xd={}));var qd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class jd{constructor(e,t,n){this.paymentIntegrationService=e,this.paypalExpressScriptLoader=t,this.formPoster=n}initialize(e){return qd(this,void 0,void 0,function*(){const t=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!e.paypal)throw new wr;if(!t.config.merchantId)throw new dr(ar.MissingPaymentMethod);const n=yield this.paypalExpressScriptLoader.loadPaypalSDK(t.config.merchantId);this.renderButton(e,n)})}deinitialize(){return Promise.resolve()}renderButton(e,t){const{containerId:n,methodId:i,paypal:r}=e,{allowCredit:o,clientId:a,onPaymentError:s,shouldProcessPayment:d,style:c}=r,u=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e.methodId);if(!u.config.merchantId)throw new dr(ar.MissingPaymentMethod);const l=u.config.merchantId,h=u.config.testMode?"sandbox":"production",p={[h]:a},g=t.FUNDING.CREDIT||"credit",m=o?[g]:[],y=o?[]:[g];return t.Button.render({env:h,client:p,commit:d,funding:{allowed:m,disallowed:y},style:this.getStyle(c),payment:(e,t)=>this.setupPayment(l,t,s),onAuthorize:(e,t)=>this.tokenizePayment(e,i,t,d)},n)}getStyle(e){const{color:t,fundingicons:n,label:i,layout:r,shape:o,size:a,tagline:s}=e||{};return{color:t,fundingicons:n,label:i,layout:r,shape:o||Bd.RECT,size:"small"===a?zd.RESPONSIVE:a,tagline:s}}setupPayment(e,t,n){return qd(this,void 0,void 0,function*(){if(!t)throw new lr(sr.CheckoutButtonNotInitialized);try{const n=yield this.paymentIntegrationService.loadDefaultCheckout(),{id:i}=n.getCartOrThrow(),r=n.getHost()||"";return(yield t.request.post(`${r}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:i},{headers:Object.assign({"X-API-INTERNAL":Tr},Dr)})).id}catch(e){throw n&&e instanceof ve&&n(e),e}})}tokenizePayment(e,t,n,i){return qd(this,void 0,void 0,function*(){if(!n)throw new lr(sr.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new dr(ar.MissingPayment);const r=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(t),o=yield n.payment.get(e.paymentID);return this.formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:r.id,action:i?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(o.payer.payer_info)})})}}class Gd{constructor(e){this.scriptLoader=e,this.window=window}loadPaypalSDK(){return e=this,t=arguments,i=function*(e=""){const t=Object.assign({async:!0,attributes:{"data-merchant-id":e}},e&&{attributes:{"data-merchant-id":e}});if(yield this.scriptLoader.loadScript("//www.paypalobjects.com/api/checkout.min.js",t),!this.window.paypal)throw new vr;return this.window.paypal},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}const Vd=Ir(e=>new jd(e,new Gd(le()),n()),[{id:"paypalexpress"}]);var Hd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class Wd{constructor(e,t){this.paymentIntegrationService=e,this.scriptLoader=t,this.isMounted=!1}deinitialize(){var e;null===(e=this.checkoutEventsUnsubscribe)||void 0===e||e.call(this),this.isMounted=!1}initCheckoutEventsSubscription(e,t,n,i){this.checkoutEventsUnsubscribe=this.paymentIntegrationService.subscribe(()=>Hd(this,void 0,void 0,function*(){var r;const o=null==i?void 0:i.getElement(Ds.PAYMENT);if(o){try{yield this.updateStripePaymentIntent(e,t)}catch(e){return this.isMounted&&(o.unmount(),this.isMounted=!1),void(e instanceof Error&&(null===(r=n.onError)||void 0===r||r.call(n,e)))}this.isMounted||(yield null==i?void 0:i.fetchUpdates(),this.mountElement(o,n.containerId))}}),e=>{var t;return null===(t=e.getCheckout())||void 0===t?void 0:t.outstandingBalance},e=>{var t;return null===(t=e.getCheckout())||void 0===t?void 0:t.coupons})}mountElement(e,t){document.getElementById(t)&&(e.mount(`#${t}`),this.isMounted=!0)}mapAppearanceVariables(e){return{colorPrimary:e.fieldInnerShadow,colorBackground:e.fieldBackground,colorText:e.labelText,colorDanger:e.fieldErrorText,colorTextSecondary:e.labelText,colorTextPlaceholder:e.fieldPlaceholderText,colorIcon:e.fieldPlaceholderText}}mapInputAppearanceRules(e){return{borderColor:e.fieldBorder,color:e.fieldText,boxShadow:e.fieldInnerShadow}}throwStripeError(e){if("object"==typeof(t=e)&&null!==t&&"type"in t&&(this.throwDisplayableStripeError(e),this.isCancellationError(e)))throw new ro;var t;throw new Va}throwDisplayableStripeError(e){if(m(["card_error","invalid_request_error","validation_error"],e.type))throw new Error(e.message)}isCancellationError(e){var t;const n=null===(t=null==e?void 0:e.payment_intent.last_payment_error)||void 0===t?void 0:t.message;return!!n&&-1!==n.indexOf("canceled")}throwPaymentConfirmationProceedMessage(){throw new Va("We've received your order and are processing your payment. Once the payment is verified, your order will be completed. We will send you an email when it's completed. Please note, this process may take a few minutes depending on the processing times of your chosen method.")}isPaymentCompleted(e,t){return Hd(this,void 0,void 0,function*(){const n=this.paymentIntegrationService.getState(),i=n.getPaymentMethodOrThrow(e),{features:r}=n.getStoreConfigOrThrow().checkoutSettings;if(!i.clientToken||!t||!r["PI-626.Block_unnecessary_payment_confirmation_for_StripeUPE"])return!1;const{paymentIntent:o}=yield t.retrievePaymentIntent(i.clientToken);return(null==o?void 0:o.status)===Ms.SUCCEEDED})}mapStripePaymentData(e,t,n=!1){const i=this.paymentIntegrationService.getState().getBillingAddress(),{firstName:r="",lastName:o="",email:a=""}=i||{},s=this.mapStripeAddress(i);if(!e)throw new lr(sr.PaymentNotInitialized);if(!(a&&s&&s.city&&s.country&&r&&o))throw new dr(ar.MissingBillingAddress);return{elements:e,redirect:ks.IF_REQUIRED,confirmParams:Object.assign({payment_method_data:Object.assign(Object.assign({},n?{allow_redisplay:"always"}:{}),{billing_details:{email:a,address:s,name:this.getShopperFullName(i)}})},t&&{return_url:t})}}isAdditionalActionError(e){return z(e,{code:"additional_action_required"})}isSessionExpiredError(e){return z(e,{code:"authorization_expired"})}isRedirectAction(e){const{type:t,data:{redirect_url:n}}=e;return"redirect_to_url"===t&&!!n}isOnPageAdditionalAction(e){const{type:t,data:{token:n}}=e;return"additional_action_requires_payment_method"===t&&!!n}updateStripePaymentIntent(e,t){return Hd(this,void 0,void 0,function*(){const n=yield this.paymentIntegrationService.loadPaymentMethod(e,{params:{method:t}}),{clientToken:i}=n.getPaymentMethodOrThrow(t);i&&this.scriptLoader.updateStripeElements({clientSecret:i})})}getStripeJsVersion(e){return e.useNewStripeJsVersion?Rs.CLOVER:Rs.V3}mapStripeAddress(e){if(e){const{city:t,address1:n,address2:i,countryCode:r,postalCode:o,stateOrProvinceCode:a}=e;return Object.assign({city:t,country:r,postal_code:o,line1:n,line2:i},a?{state:a}:{})}throw new dr(ar.MissingBillingAddress)}getShopperFullName(e){const{firstName:t="",lastName:n=""}=e||{};return`${t} ${n}`.trim()}verifyCheckoutSpamProtection(){return Hd(this,void 0,void 0,function*(){const{shouldExecuteSpamCheck:e}=this.paymentIntegrationService.getState().getCheckoutOrThrow();e&&(yield this.paymentIntegrationService.verifyCheckoutSpamProtection())})}}const Yd={size:70,color:"#d9d9d9",backgroundColor:"#ffffff"},Kd={position:"fixed","background-color":"rgba(0, 0, 0, 0.4)","z-index":"1000"},$d="embedded-checkout-loading-indicator-rotation";class Zd{constructor(e){this.styles=Object.assign(Object.assign({},Yd),e&&e.styles),this.containerStyles=Object.assign({},e&&e.containerStyles),this.defineAnimation(),this.container=this.buildContainer(),this.indicator=this.buildIndicator(),this.container.appendChild(this.indicator)}show(e){if(e){const t=document.getElementById(e);if(!t)throw new Error("Unable to attach the loading indicator because the parent ID is not valid.");t.appendChild(this.container)}this.container.style.visibility="visible",this.container.style.opacity="1"}hide(){const e=()=>{this.container.style.visibility="hidden",this.container.removeEventListener("transitionend",e)};this.container.addEventListener("transitionend",e),this.container.style.opacity="0"}buildContainer(){const e=document.createElement("div");return e.style.display="block",e.style.bottom="0",e.style.left="0",e.style.height="100%",e.style.width="100%",e.style.position="absolute",e.style.right="0",e.style.top="0",e.style.transition="all 250ms ease-out",e.style.opacity="0",this.setStyleAttribute(e,this.containerStyles),e}buildIndicator(){const e=document.createElement("div");return e.style.display="block",e.style.width=`${this.styles.size}px`,e.style.height=`${this.styles.size}px`,e.style.borderRadius=`${this.styles.size}px`,e.style.border="solid 1px",e.style.borderColor=`${this.styles.backgroundColor} ${this.styles.backgroundColor} ${this.styles.color} ${this.styles.color}`,e.style.margin="0 auto",e.style.position="absolute",e.style.left="0",e.style.right="0",e.style.top="50%",e.style.transform="translateY(-50%) rotate(0deg)",e.style.transformStyle="preserve-3d",e.style.animation=`${$d} 500ms infinite cubic-bezier(0.69, 0.31, 0.56, 0.83)`,e}setStyleAttribute(e,t){Object.keys(t).forEach(n=>{e.style.setProperty(n,t[n])})}defineAnimation(){var e;if(document.getElementById($d))return;const t=document.createElement("style");t.id=$d,null===(e=document.head)||void 0===e||e.appendChild(t),t.sheet instanceof CSSStyleSheet&&t.sheet.insertRule(`\n @keyframes ${$d} {\n 0% { transform: translateY(-50%) rotate(0deg); }\n 100% { transform: translateY(-50%) rotate(360deg); }\n }\n `,0)}}class Jd{constructor(e){this._decimalPlaces=e}toInteger(e){return Math.round(e*Math.pow(10,this._decimalPlaces))}}const Qd=["AC","AD","AE","AF","AG","AI","AL","AM","AO","AQ","AR","AT","AU","AW","AX","AZ","BA","BB","BD","BE","BF","BG","BH","BI","BJ","BL","BM","BN","BO","BQ","BR","BS","BT","BV","BW","BY","BZ","CA","CD","CF","CG","CH","CI","CK","CL","CM","CN","CO","CR","CV","CW","CY","CZ","DE","DJ","DK","DM","DO","DZ","EC","EE","EG","EH","ER","ES","ET","FI","FJ","FK","FO","FR","GA","GB","GD","GE","GF","GG","GH","GI","GL","GM","GN","GP","GQ","GR","GS","GT","GU","GW","GY","HK","HN","HR","HT","HU","ID","IE","IL","IM","IN","IO","IQ","IS","IT","JE","JM","JO","JP","KE","KG","KH","KI","KM","KN","KR","KW","KY","KZ","LA","LB","LC","LI","LK","LR","LS","LT","LU","LV","LY","MA","MC","MD","ME","MF","MG","MK","ML","MM","MN","MO","MQ","MR","MS","MT","MU","MV","MW","MX","MY","MZ","NA","NC","NE","NG","NI","NL","NO","NP","NR","NU","NZ","OM","PA","PE","PF","PG","PH","PK","PL","PM","PN","PR","PS","PT","PY","QA","RE","RO","RS","RU","RW","SA","SB","SC","SD","SE","SG","SH","SI","SJ","SK","SL","SM","SN","SO","SR","SS","ST","SV","SX","SZ","TA","TC","TD","TF","TG","TH","TJ","TK","TL","TM","TN","TO","TR","TT","TV","TW","TZ","UA","UG","US","UY","UZ","VA","VC","VE","VG","VN","VU","WF","WS","XK","YE","YT","ZA","ZM","ZW","ZZ"];var Xd=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class ec{constructor(e,t,n,i){this.paymentIntegrationService=e,this.scriptLoader=t,this.stripeIntegrationService=n,this.loadingIndicator=i}initialize(e){return Xd(this,void 0,void 0,function*(){const{stripeocs:t,containerId:n}=e||{};if(!t||!n)throw new lr(sr.PaymentNotInitialized);const{gatewayId:i}=t;if(!i)throw new dr(ar.MissingPaymentMethod);const r=this._getMethodId(i),o=yield this.paymentIntegrationService.loadPaymentMethod(i,{params:{method:r}}),a=o.getPaymentMethodOrThrow(r,i),{loadingContainerId:s,buttonHeight:d,onComplete:c}=t;if(this._loadingIndicatorContainer=s,this._onComplete=c,!function(e){return"object"==typeof e&&null!==e&&"initializationData"in e&&void 0!==e.initializationData&&null!==e.initializationData&&"object"==typeof e.initializationData&&"stripePublishableKey"in e.initializationData&&"stripeConnectedAccount"in e.initializationData&&"shopperLanguage"in e.initializationData&&void 0!==e.initializationData.stripePublishableKey&&void 0!==e.initializationData.stripeConnectedAccount&&void 0!==e.initializationData.shopperLanguage}(a))throw new dr(ar.MissingPaymentMethod);const{initializationData:u}=a,{captureMethod:l}=u,h=this.stripeIntegrationService.getStripeJsVersion(u);this._captureMethod=l,this._stripeClient=yield this.scriptLoader.getStripeClient(u,o.getCartLocale(),h),yield this.paymentIntegrationService.loadDefaultCheckout(),yield this._mountExpressCheckoutElement(n,this._stripeClient,d),this._initializeEvents(r)})}signIn(){return Promise.resolve()}signOut(){return Promise.resolve()}executePaymentMethodCheckout(){return Promise.resolve()}deinitialize(){return Promise.resolve()}_mountExpressCheckoutElement(e,t){return Xd(this,arguments,void 0,function*(e,t,n=40){const i=this._shouldRequireShippingAddress(),r=Object.assign(Object.assign(Object.assign({shippingAddressRequired:i},i?{allowedShippingCountries:yield this._getAvailableCountries()}:{}),i?{shippingRates:[{id:"_",amount:0,displayName:"Pending rates"}]}:{}),{billingAddressRequired:!0,emailRequired:!0,phoneNumberRequired:!0,paymentMethods:{link:ks.AUTO,applePay:ks.NEVER,googlePay:ks.NEVER,amazonPay:ks.NEVER,paypal:ks.NEVER,klarna:ks.NEVER},buttonHeight:n}),{cartAmount:o=1}=this.paymentIntegrationService.getState().getCart()||{},a=Object.assign({mode:"payment",amount:this._toCents(o),currency:this._getCurrency()},this._captureMethod?{captureMethod:this._captureMethod}:{});this._stripeElements=t.elements(a),this._linkV2Element=this._stripeElements.create(Ds.EXPRESS_CHECKOUT,r),this._linkV2Element.mount(`#${e}`)})}_initializeEvents(e){this._linkV2Element&&(this._shouldRequireShippingAddress()&&(this._linkV2Element.on(Ns.SHIPPING_ADDRESS_CHANGE,e=>Xd(this,void 0,void 0,function*(){return this._onShippingAddressChange(e)})),this._linkV2Element.on(Ns.SHIPPING_RATE_CHANGE,e=>Xd(this,void 0,void 0,function*(){return this._onShippingRateChange(e)}))),this._linkV2Element.on(Ns.CONFIRM,t=>Xd(this,void 0,void 0,function*(){return this._onConfirm(t,e)})),this._linkV2Element.on(Ns.CANCEL,this._onCancel))}_onShippingAddressChange(e){return Xd(this,void 0,void 0,function*(){if(!("address"in e))return;const t=e.address,n={firstName:"",lastName:"",phone:"",company:"",address1:"",address2:"",city:(null==t?void 0:t.city)||"",countryCode:(null==t?void 0:t.country)||"",postalCode:(null==t?void 0:t.postal_code)||"",stateOrProvince:(null==t?void 0:t.state)||"",stateOrProvinceCode:(null==t?void 0:t.state)||"",customFields:[]};yield this.paymentIntegrationService.updateShippingAddress(n);const i=yield this._getAvailableShippingOptions();yield this._updateDisplayedPrice(),(null==i?void 0:i.length)?e.resolve({shippingRates:i}):e.reject()})}_onCancel(){throw new ro}_onShippingRateChange(e){return Xd(this,void 0,void 0,function*(){if("shippingRate"in e){const{shippingRate:t}=e;yield this._handleShippingOptionChange(null==t?void 0:t.id),yield this._updateDisplayedPrice(),e.resolve({})}})}_onConfirm(e,t){return Xd(this,void 0,void 0,function*(){if("billingDetails"in e&&"shippingAddress"in e&&this._stripeClient&&this._stripeElements){yield this.stripeIntegrationService.verifyCheckoutSpamProtection(),yield this._updateShippingAndBillingAddress(e),yield this.paymentIntegrationService.submitOrder();const n=this._getPaymentPayload(t);try{yield this.paymentIntegrationService.submitPayment(n)}catch(e){yield this._processAdditionalAction(e,t)}}return Promise.resolve()})}_updateShippingAndBillingAddress(e){return Xd(this,void 0,void 0,function*(){var t,n,i,r,o,a,s,d;const c=this._shouldRequireShippingAddress(),u=(null===(n=null===(t=e.shippingAddress)||void 0===t?void 0:t.name)||void 0===n?void 0:n.split(" ")[0])||(null===(r=null===(i=e.billingDetails)||void 0===i?void 0:i.name)||void 0===r?void 0:r.split(" ")[0])||"",l=(null===(a=null===(o=e.shippingAddress)||void 0===o?void 0:o.name)||void 0===a?void 0:a.split(" ")[1])||(null===(d=null===(s=e.billingDetails)||void 0===s?void 0:s.name)||void 0===d?void 0:d.split(" ")[1])||"";if(c){const t=this._mapShippingAddress(e.shippingAddress,e.billingDetails,u,l);yield this.paymentIntegrationService.updateShippingAddress(t)}const h=this._mapBillingAddress(e.shippingAddress,e.billingDetails,u,l);yield this.paymentIntegrationService.updateBillingAddress(h)})}_mapShippingAddress(e,t,n,i){var r,o,a,s,d,c,u;return{firstName:n,lastName:i,phone:(null==t?void 0:t.phone)||"",company:"",address1:(null===(r=null==e?void 0:e.address)||void 0===r?void 0:r.line1)||"",address2:(null===(o=null==e?void 0:e.address)||void 0===o?void 0:o.line2)||"",city:(null===(a=null==e?void 0:e.address)||void 0===a?void 0:a.city)||"",countryCode:(null===(s=null==e?void 0:e.address)||void 0===s?void 0:s.country)||"",postalCode:(null===(d=null==e?void 0:e.address)||void 0===d?void 0:d.postal_code)||"",stateOrProvince:(null===(c=null==e?void 0:e.address)||void 0===c?void 0:c.state)||"",stateOrProvinceCode:(null===(u=null==e?void 0:e.address)||void 0===u?void 0:u.state)||"",customFields:[]}}_mapBillingAddress(e,t,n,i){var r,o,a,s,d,c;return{email:(null==t?void 0:t.email)||"",firstName:n,lastName:i,phone:(null==t?void 0:t.phone)||"",company:"",address1:(null===(r=null==t?void 0:t.address)||void 0===r?void 0:r.line1)||"",address2:"",city:(null===(o=null==t?void 0:t.address)||void 0===o?void 0:o.city)||"",countryCode:(null===(a=null==t?void 0:t.address)||void 0===a?void 0:a.country)||"",postalCode:(null===(s=null==t?void 0:t.address)||void 0===s?void 0:s.postal_code)||"",stateOrProvince:(null===(d=null==t?void 0:t.address)||void 0===d?void 0:d.state)||"",stateOrProvinceCode:(null===(c=null==e?void 0:e.address)||void 0===c?void 0:c.state)||"",customFields:[]}}_processAdditionalAction(e,t){return Xd(this,void 0,void 0,function*(){if(!ms(e)||!this.stripeIntegrationService.isAdditionalActionError(e.body.errors))throw e;if(!this._stripeClient||!this._stripeElements)throw new lr(sr.PaymentNotInitialized);const{data:n}=e.body.additional_action_required,{token:i}=n,{paymentIntent:r}=yield this._confirmStripePaymentOrThrow(n,t),o=this._getPaymentPayload(t,(null==r?void 0:r.id)||i);try{this._toggleLoadingIndicator(!0),yield this.paymentIntegrationService.submitPayment(o),yield this._completeCheckoutFlow()}catch(e){this.stripeIntegrationService.throwPaymentConfirmationProceedMessage()}finally{this._toggleLoadingIndicator(!1)}})}_confirmStripePaymentOrThrow(e,t){return Xd(this,void 0,void 0,function*(){var n,i,r;const{token:o,redirect_url:a}=e,s=this.stripeIntegrationService.mapStripePaymentData(this._stripeElements,a);let d;try{const e=(yield this.stripeIntegrationService.isPaymentCompleted(t,this._stripeClient))?yield null===(r=this._stripeClient)||void 0===r?void 0:r.retrievePaymentIntent(o||""):yield null===(n=this._stripeClient)||void 0===n?void 0:n.confirmPayment({elements:s.elements,clientSecret:o,redirect:ks.IF_REQUIRED,confirmParams:{return_url:null===(i=s.confirmParams)||void 0===i?void 0:i.return_url}});if(d=null==e?void 0:e.error,d||!(null==e?void 0:e.paymentIntent))throw new Va;return e}catch(e){return this.stripeIntegrationService.throwStripeError(d)}})}_completeCheckoutFlow(){return Xd(this,void 0,void 0,function*(){return"function"==typeof this._onComplete?this._onComplete():(window.location.replace("/checkout/order-confirmation"),Promise.resolve())})}_getPaymentPayload(e,t){var n;const i=(null===(n=this.paymentIntegrationService.getState().getCart())||void 0===n?void 0:n.id)||"";return{methodId:e,paymentData:{formattedPayload:Object.assign(Object.assign({cart_id:i},t?{credit_card_token:{token:t}}:{}),{confirm:!1,method:Ts.Link})}}}_shouldRequireShippingAddress(){const{getCart:e}=this.paymentIntegrationService.getState(),{lineItems:t}=e()||{};return!!(null==t?void 0:t.physicalItems.length)}_updateDisplayedPrice(){return Xd(this,void 0,void 0,function*(){this._stripeElements&&this._stripeElements.update({currency:this._getCurrency(),mode:"payment",amount:yield this._getTotalPrice()})})}_getCurrency(){var e;if(!this._currencyCode){const t=null===(e=this.paymentIntegrationService.getState().getCart())||void 0===e?void 0:e.currency;t&&(this._currencyCode=t.code.toLowerCase())}return this._currencyCode}_getTotalPrice(){return Xd(this,void 0,void 0,function*(){var e;yield this.paymentIntegrationService.loadCheckout();const{getCheckoutOrThrow:t,getCart:n}=this.paymentIntegrationService.getState(),{decimalPlaces:i}=(null===(e=n())||void 0===e?void 0:e.currency)||{},r=L(t().outstandingBalance,i).toFixed(i);return this._toCents(+r)})}_getAvailableCountries(){return Xd(this,void 0,void 0,function*(){var e;return((null===(e=(yield this.paymentIntegrationService.loadShippingCountries()).getShippingCountries())||void 0===e?void 0:e.map(e=>e.code))||[]).filter(e=>Qd.includes(e))})}_getAvailableShippingOptions(){return Xd(this,void 0,void 0,function*(){var e,t,n;const i=this.paymentIntegrationService.getState().getConsignments();if(!(null==i?void 0:i[0]))return;const r=i[0],o=(r.availableShippingOptions||[]).map(this._getStripeShippingOption.bind(this)),a=null===(e=r.availableShippingOptions)||void 0===e?void 0:e.find(e=>e.isRecommended),s=null===(t=r.selectedShippingOption)||void 0===t?void 0:t.id,d=null==a?void 0:a.id;return s?o.sort(e=>e.id===s?-1:0):d?(o.sort(e=>e.id===d?-1:0),yield this._handleShippingOptionChange(d)):yield this._handleShippingOptionChange(null===(n=o[0])||void 0===n?void 0:n.id),o.slice(0,9)})}_getStripeShippingOption({id:e,cost:t,description:n}){return{id:e,displayName:n,amount:this._toCents(t)}}_handleShippingOptionChange(e){return Xd(this,void 0,void 0,function*(){if(e&&"shipping_option_unselected"!==e)return this.paymentIntegrationService.selectShippingOption(e)})}_getAmountTransformer(){if(this._amountTransformer)return this._amountTransformer;const{getCart:e}=this.paymentIntegrationService.getState(),{currency:t}=e()||{};return t?new Jd(t.decimalPlaces):void 0}_toCents(e){const t=Math.round(100*e),n=this._getAmountTransformer();return n?n.toInteger(e):t}_toggleLoadingIndicator(e){e&&this._loadingIndicatorContainer?this.loadingIndicator.show(this._loadingIndicatorContainer):this.loadingIndicator.hide()}_getMethodId(e){const{initializationData:{checkoutSessionEnabled:t}={}}=this.paymentIntegrationService.getState().getPaymentMethodOrThrow(e);return t?Ts.CHECKOUT_SESSION:Ts.OCS}}const tc=Ir(e=>{const t=new Us(le()),n=new Zd({containerStyles:Kd});return new ec(e,t,new Wd(e,t),n)},[{id:"stripeocs"}]);var nc;function ic(e,t,n){const i=new WeakMap;function r(e){return(...n)=>{const r=n[n.length-1],{useCache:o}=(a=r)&&"boolean"==typeof a.useCache?r:{useCache:!1};var a;if(!o)return e.call(this,...n);const s=i.get(this)||{};var d;return i.get(this)||i.set(this,s),s[t]||(s[t]=(d=e,ae(function(...e){const t=d.call(this,...e);return t instanceof j?Y(t).pipe(ie()):"function"==typeof t?ae(e=>Y(t(e)).pipe(ie()),{isEqual:_}):t},{isEqual:_}))),s[t].call(this,...n)}}return{get(){if("function"!=typeof n.value)throw new Error("Decorator should be used in functions");const e=r.call(this,n.value);return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e}}}!function(e){e.Standard="standard",e.Invoice="invoice"}(nc||(nc={}));var rc=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};const oc=e=>!!e;class ac{constructor(e,t){this._requestSender=e,this._b2bCompanyPaymentMethodRequestSender=t}loadPaymentMethodsById(e,t){return n=>new j(i=>{var r;const a=null===(r=n.getState().cart.getCart())||void 0===r?void 0:r.id,s=a?Object.assign(Object.assign({},null==t?void 0:t.params),{cartId:a}):Object.assign({},null==t?void 0:t.params);i.next(o(En.LoadPaymentMethodsRequested)),Promise.all(e.map(e=>rc(this,void 0,void 0,function*(){try{return(yield this._requestSender.loadPaymentMethod(e,Object.assign(Object.assign({},t),{params:s}))).body}catch(e){return}}))).then(e=>{const t=e.filter(oc);i.next(o(En.LoadPaymentMethodsSucceeded,t)),i.complete()}).catch(e=>{i.next(o(En.LoadPaymentMethodsFailed,e)),i.complete()})})}loadPaymentMethods(e){return t=>j.create(n=>{const i=t.getState(),r=i.cart.getCartOrThrow();n.next(o(En.LoadPaymentMethodsRequested)),this._requestSender.loadPaymentMethods(Object.assign(Object.assign({},e),{params:Object.assign(Object.assign({},null==e?void 0:e.params),{cartId:r.id})})).then(t=>rc(this,void 0,void 0,function*(){const r={deviceSessionId:t.headers["x-device-session-id"],sessionHash:t.headers["x-session-hash"]};let a=t.body;this._shouldFilterForB2b(i)&&(a=yield this._applyB2bFilter(a,i,e)),n.next(o(En.LoadPaymentMethodsSucceeded,a,r)),n.complete()})).catch(e=>{n.error(s(En.LoadPaymentMethodsFailed,e))})})}loadPaymentMethod(e,t){return n=>j.create(i=>{var r;const a=null===(r=n.getState().cart.getCart())||void 0===r?void 0:r.id,d=a?Object.assign(Object.assign({},null==t?void 0:t.params),{cartId:a}):Object.assign({},null==t?void 0:t.params);i.next(o(En.LoadPaymentMethodRequested,void 0,{methodId:e})),this._requestSender.loadPaymentMethod(e,Object.assign(Object.assign({},t),{params:d})).then(t=>{i.next(o(En.LoadPaymentMethodSucceeded,t.body,{methodId:e})),i.complete()}).catch(t=>{i.error(s(En.LoadPaymentMethodFailed,t,{methodId:e}))})})}_shouldFilterForB2b(e){var t,n;return!!(null===(n=null===(t=e.config.getStoreConfigOrThrow().checkoutSettings)||void 0===t?void 0:t.capabilities)||void 0===n?void 0:n.payment.b2bPaymentMethodFilterType)}_applyB2bFilter(e,t,n){return rc(this,void 0,void 0,function*(){var i,r,o,a,s;const d=t.config.getStoreConfigOrThrow(),c=t.customer.getCustomerOrThrow(),u=t.cart.getCartOrThrow(),l=t.b2bToken.getToken(),h=(p=null!==(o=null===(r=null===(i=t.config.getStoreConfig())||void 0===i?void 0:i.b2bApiSettings)||void 0===r?void 0:r.baseUrl)&&void 0!==o?o:"",function(){if("undefined"==typeof window||!window.location)return!1;try{return!!new URLSearchParams(window.location.search).has("enableB2bDevMode")&&(console.log("B2B Dev Mode Enabled"),!0)}catch(e){return!1}}()?"https://api-b2b.bigcommerce.com":p);var p;if(c.isGuest||!l||!h||!u.companyId)throw new Zi($i.MissingCheckoutConfig);return(null===(s=null===(a=d.checkoutSettings)||void 0===a?void 0:a.capabilities)||void 0===s?void 0:s.payment.b2bPaymentMethodFilterType)===nc.Invoice?this._applyB2bInvoiceFilter(e,h,l,n):this._applyB2bCompanyFilter(e,u.companyId,l,h,n)})}_applyB2bCompanyFilter(e,t,n,i,r){return rc(this,void 0,void 0,function*(){const{body:o}=yield this._b2bCompanyPaymentMethodRequestSender.getB2BCompanyPaymentMethods(t,n,i,r);return function(e,t){const n=new Set(t.data.filter(e=>"1"===e.isEnabled).map(e=>e.code));return e.filter(e=>n.has(e.id))}(e,o)})}_applyB2bInvoiceFilter(e,t,n,i){return rc(this,void 0,void 0,function*(){const{body:r}=yield this._b2bCompanyPaymentMethodRequestSender.getB2BInvoiceAllowedPaymentMethods(t,n,i);return e.filter(e=>new Set(r.data.allowedMethods).has(e.id))})}}var sc;(function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)})([ic],ac.prototype,"loadPaymentMethod",null),function(e){e.Json="application/json",e.JsonV1="application/vnd.bc.v1+json"}(sc||(sc={}));const dc=sc,cc="This API endpoint is for internal use only and may change in the future",uc={"X-Checkout-SDK-Version":"1.935.0"};class lc{constructor(e){this._requestSender=e}loadPaymentMethods({timeout:e,params:t}={}){return this._requestSender.get("/api/storefront/payments",{timeout:e,headers:Object.assign({Accept:dc.JsonV1,"X-API-INTERNAL":cc},uc),params:t})}loadPaymentMethod(e,{timeout:t,params:n}={}){const i=`/api/storefront/payments/${e}`;return this._requestSender.get(i,{timeout:t,headers:Object.assign({Accept:dc.JsonV1,"X-API-INTERNAL":cc},uc),params:n})}}var hc=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class pc{constructor(e){this._requestSender=e}getB2BCompanyPaymentMethods(e,t,n,i){return hc(this,void 0,void 0,function*(){return this._requestSender.get(`${n}/api/v2/companies/${e}/payments`,{timeout:null==i?void 0:i.timeout,credentials:!1,headers:{authToken:t,Authorization:`Bearer ${t}`}})})}getB2BInvoiceAllowedPaymentMethods(e,t,n){return hc(this,void 0,void 0,function*(){return this._requestSender.get(`${e}/api/v1/ip/storefront/payments/bigcommerce/allowed-methods`,{timeout:null==n?void 0:n.timeout,credentials:!1,headers:{authToken:t,Authorization:`Bearer ${t}`}})})}}function gc(e,t,n){return(i=t)&&i.type&&i.error?V(Z(t),J(s(e,t.payload,n))):J(s(e,t,n));var i}class mc extends be{constructor(e){super(e||"Unable to continue as a guest because the customer is already signed in."),this.name="UnableToContinueAsGuestError",this.type="unable_to_continue_as_guest"}}class yc{constructor(e,t){this._requestSender=e,this._subscriptionActionCreator=t}continueAsGuest(e,t){return n=>{const i=n.getState(),r=i.checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);const a=i.customer.getCustomer();if(a&&!a.isGuest)throw new mc;const s=i.billingAddress.getBillingAddress();let d;if(s){const{country:t}=s,n=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(s,["country"]);d=Object.assign(Object.assign({},n),e)}else d=e;const c=!f(s);return $(V(Z(o(Ye.ContinueAsGuestRequested)),H(()=>{return e=this,n=void 0,a=function*(){const{body:e}=yield this._createOrUpdateBillingAddress(r.id,d,c,t);return o(Ye.ContinueAsGuestSucceeded,e)},new((i=void 0)||(i=Promise))(function(t,r){function o(e){try{d(a.next(e))}catch(e){r(e)}}function s(e){try{d(a.throw(e))}catch(e){r(e)}}function d(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(e){e(n)})).then(o,s)}d((a=a.apply(e,n||[])).next())});var e,n,i,a})).pipe(Q(e=>gc(Ye.ContinueAsGuestFailed,e))),this._updateCustomerConsent(e,t))}}updateAddress(e,t){return n=>j.create(i=>{const r=n.getState(),a=r.checkout.getCheckout();if(!a)throw new Zi($i.MissingCheckout);i.next(o(Ye.UpdateBillingAddressRequested));const d=r.billingAddress.getBillingAddress(),c=!f(d),u=Object.assign(Object.assign({},e),{email:void 0===e.email&&d?d.email:e.email});d&&d.id&&(u.id=d.id),this._createOrUpdateBillingAddress(a.id,u,c,t).then(({body:e})=>{i.next(o(Ye.UpdateBillingAddressSucceeded,e)),i.complete()}).catch(e=>{i.error(s(Ye.UpdateBillingAddressFailed,e))})})}_updateCustomerConsent({email:e,acceptsAbandonedCartEmails:t,acceptsMarketingNewsletter:n},i){return null==t&&null==n?W():this._subscriptionActionCreator.updateSubscriptions({email:e,acceptsMarketingNewsletter:n||!1,acceptsAbandonedCartEmails:t||!1},i)}_createOrUpdateBillingAddress(e,t,n,i){return n?this._requestSender.updateAddress(e,t,i):this._requestSender.createAddress(e,t,i)}}class fc extends be{constructor(e){super(e||"Your checkout could not be processed because your cart is empty. Please add items to your cart and try again."),this.name="EmptyCartError",this.type="empty_cart"}}const _c={include:["cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","promotions.banners"].join(",")};class Sc{constructor(e){this._requestSender=e}createAddress(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/billing-address`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(i,{body:t,params:_c,headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}updateAddress(e,t,{timeout:n}={}){const{id:i}=t,r=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["id"]),o=`/api/storefront/checkouts/${e}/billing-address/${i}`,a=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.put(o,{params:_c,body:r,headers:a,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}}class vc{constructor(e){this._requestSender=e}createBuyNowCart(e,{timeout:t}={}){const n=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post("/api/storefront/carts",{body:e,headers:n,timeout:t})}}class Cc{constructor(e,t,n){this._checkoutRequestSender=e,this._configActionCreator=t,this._formFieldsActionCreator=n}loadCheckout(e,t){return()=>V(Z(o(Ve.LoadCheckoutRequested)),$(this._configActionCreator.loadConfig({useCache:!0,timeout:null==t?void 0:t.timeout,params:{checkoutId:e}}),this._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==t?void 0:t.timeout})),H(()=>this._checkoutRequestSender.loadCheckout(e,t).then(({body:e})=>o(Ve.LoadCheckoutSucceeded,this._transformCustomerAddresses(e))))).pipe(Q(e=>gc(Ve.LoadCheckoutFailed,e)))}loadDefaultCheckout(e){return t=>V(Z(o(Ve.LoadCheckoutRequested)),$(this._configActionCreator.loadConfig({useCache:!0,timeout:null==e?void 0:e.timeout}),this._formFieldsActionCreator.loadFormFields({useCache:!0,timeout:null==e?void 0:e.timeout})),H(()=>{return n=this,i=void 0,a=function*(){const n=t.getState().config.getContextConfig();if(!n||!n.checkoutId)throw new Zi($i.MissingCheckoutConfig);const{body:i}=yield this._checkoutRequestSender.loadCheckout(n.checkoutId,e);return o(Ve.LoadCheckoutSucceeded,this._transformCustomerAddresses(i))},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>gc(Ve.LoadCheckoutFailed,e)))}updateCheckout(e,t){return n=>new j(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);i.next(o(Ve.UpdateCheckoutRequested)),this._checkoutRequestSender.updateCheckout(r.id,e,t).then(({body:e})=>{i.next(o(Ve.UpdateCheckoutSucceeded,e)),i.complete()}).catch(e=>{i.error(s(Ve.UpdateCheckoutFailed,e))})})}deleteCheckout(e){return t=>new j(n=>{const i=t.getState().checkout.getCheckout();if(!i)throw new Zi($i.MissingCheckout);n.next(o(Ve.DeleteCheckoutRequested)),this._checkoutRequestSender.deleteCheckout(i.id,e).then(()=>{n.next(o(Ve.DeleteCheckoutSucceeded)),n.complete()}).catch(e=>{n.error(s(Ve.DeleteCheckoutFailed,e))})})}loadCurrentCheckout(e){return t=>{const n=t.getState().checkout.getCheckout();if(!n)throw new Zi($i.MissingCheckout);return this.loadCheckout(n.id,e)(t)}}hydrateInitialState(e){return{type:He.HydrateInitialState,payload:e}}_transformCustomerAddresses(e){return Object.assign(Object.assign({},e),{customer:Object.assign(Object.assign({},e.customer),{addresses:e.customer.addresses.map(e=>Object.assign(Object.assign({},e),{shouldSaveAddress:!1}))})})}}function Ic(e){return F(e).join(",")}function wc(e,t=[]){return Array.isArray(t)?Ic([...e,...t]):function(e,t){const n=b(M(t,e=>!e)),i=b(u(t));return Ic([...c(e,n),...i])}(e,t)}const bc=["cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","customer.customerGroup","payments","promotions.banners"];class Ec extends Pe{constructor(e){super(e,{message:e.body.title}),this.name="CheckoutNotAvailableError",this.type="checkout_not_available"}}class Pc{constructor(e){this._requestSender=e}loadCheckout(e,{params:{include:t}={},timeout:n}={}){const i=`/api/storefront/checkout/${e}`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.get(i,{params:{include:wc(bc,t)},headers:r,timeout:n}).catch(e=>{if(e.status>=400&&e.status<500)throw new Ec(e);throw e})}updateCheckout(e,t,{params:{include:n}={},timeout:i}={}){const r=`/api/storefront/checkout/${e}`,o=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.put(r,{params:{include:wc(bc,n)},body:t,headers:o,timeout:i}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}deleteCheckout(e,{timeout:t}={}){const n=`/api/storefront/carts/${e}`,i=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.delete(n,{headers:i,timeout:t})}}class Oc{isEqual(e,t){return _(this._normalize(e),this._normalize(t))}_normalize(e){return{cartAmount:e.cartAmount,currency:e.currency,id:e.id,lineItems:{digitalItems:e.lineItems.digitalItems.slice().sort((e,t)=>`${e.productId}${e.variantId}`.localeCompare(`${t.productId}${t.variantId}`)).map(e=>({extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId})),giftCertificates:e.lineItems.giftCertificates.slice().sort((e,t)=>`${e.id}`.localeCompare(`${t.id}`)).map(e=>({amount:e.amount,recipient:e.recipient})),physicalItems:e.lineItems.physicalItems.slice().sort((e,t)=>`${e.productId}${e.variantId}`.localeCompare(`${t.productId}${t.variantId}`)).map(e=>({extendedSalePrice:e.extendedSalePrice,productId:e.productId,quantity:e.quantity,variantId:e.variantId,giftWrapping:e.giftWrapping}))}}}}class Ac extends be{constructor(e,t){super("An update to your shopping cart has been detected and your available shipping costs have been updated."),this.name="CartChangedError",this.type="cart_changed",this.data={previous:e,updated:t}}}class Tc{constructor(e){this._checkoutRequestSender=e}validate(e,t){if(!e)throw new Zi($i.MissingCheckout);return this._checkoutRequestSender.loadCheckout(e.id,t).then(t=>{const n=new Oc;if(!(e.outstandingBalance===t.body.outstandingBalance&&this._compareCoupons(e.coupons,t.body.coupons)&&this._compareGiftCertificates(e.giftCertificates,t.body.giftCertificates)&&n.isEqual(e.cart,t.body.cart)))throw new Ac(this._getComparableCheckout(e),this._getComparableCheckout(t.body))})}_compareCoupons(e,t){return _(P(e,"code"),P(t,"code"))}_compareGiftCertificates(e,t){return _(P(e,"code"),P(t,"code"))}_getComparableCheckout(e){const{cart:t,coupons:n,giftCertificates:i,outstandingBalance:r}=e;return{cart:{cartAmount:t.cartAmount,currency:t.currency,lineItems:t.lineItems},coupons:n,giftCertificates:i,outstandingBalance:r}}}var kc;class Rc{constructor(e){this._configRequestSender=e}loadConfig(e){return j.create(t=>{t.next(o(vt.LoadConfigRequested)),this._configRequestSender.loadConfig(e).then(e=>{t.next(o(vt.LoadConfigSucceeded,e.body)),t.complete()}).catch(e=>{t.error(s(vt.LoadConfigFailed,e))})})}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([ic],Rc.prototype,"loadConfig",null);class Dc{constructor(e){this._requestSender=e}loadConfig({timeout:e,params:t}={}){return this._requestSender.get("/api/storefront/checkout-settings",{timeout:e,headers:Object.assign({Accept:dc.JsonV1,"X-API-INTERNAL":cc},uc),params:t}).catch(e=>{if(e.status>=400&&e.status<500)throw new Ec(e);throw e})}}class Mc{constructor(e){this._couponRequestSender=e}applyCoupon(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);i.next(o(it.ApplyCouponRequested)),this._couponRequestSender.applyCoupon(r.id,e,t).then(({body:e})=>{i.next(o(it.ApplyCouponSucceeded,e)),i.complete()}).catch(e=>{i.error(s(it.ApplyCouponFailed,e))})})}removeCoupon(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);i.next(o(it.RemoveCouponRequested)),this._couponRequestSender.removeCoupon(r.id,e,t).then(({body:e})=>{i.next(o(it.RemoveCouponSucceeded,e)),i.complete()}).catch(e=>{i.error(s(it.RemoveCouponFailed,e))})})}}!function(e){e.AvailableShippingOptions="consignments.availableShippingOptions",e.PhysicalItemsCategoryNames="cart.lineItems.physicalItems.categoryNames",e.DigitalItemsCategoryNames="cart.lineItems.digitalItems.categoryNames"}(kc||(kc={}));class Nc{constructor(e){this._requestSender=e}applyCoupon(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/coupons`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(i,{headers:r,timeout:n,params:{include:Ic([...bc,kc.AvailableShippingOptions])},body:{couponCode:t}}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}removeCoupon(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/coupons/${t}`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.delete(i,{headers:r,timeout:n,params:{include:Ic([...bc,kc.AvailableShippingOptions])}}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}}function Lc(e){const t=e;return"object"==typeof t&&"object"==typeof t.payload&&"string"==typeof t.payload.token}class zc{constructor(e,t,n){this._customerRequestSender=e,this._checkoutActionCreator=t,this._spamProtectionActionCreator=n}createCustomer(e,t){return n=>{const i=n.getState().config.getStoreConfigOrThrow(),{isStorefrontSpamProtectionEnabled:r}=i.checkoutSettings,a=i=>Y(this._customerRequestSender.createAccount(Object.assign(Object.assign({},e),{token:i}),t)).pipe(re(()=>V(this._checkoutActionCreator.loadCurrentCheckout(t)(n),Z(o(Ut.CreateCustomerSucceeded)))));return V(Z(o(Ut.CreateCustomerRequested)),r?Y(this._spamProtectionActionCreator.execute()(n)).pipe(re(e=>{var t;return Lc(e)?V(Z(e),a(null===(t=e.payload)||void 0===t?void 0:t.token)):Z(e)})):a()).pipe(Q(e=>gc(Ut.CreateCustomerFailed,e)))}}createAddress(e,t){return V(Z(o(Ut.CreateCustomerAddressRequested)),H(()=>{return n=this,i=void 0,a=function*(){const{body:n}=yield this._customerRequestSender.createAddress(e,t);return o(Ut.CreateCustomerAddressSucceeded,n)},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>gc(Ut.CreateCustomerAddressFailed,e)))}signInCustomer(e,t){return n=>{const i=n.getState().checkout.getCheckoutOrThrow(),r=i.cart.source===go.BuyNow?i.id:void 0;return V(Z(o(Ut.SignInCustomerRequested)),Y(this._customerRequestSender.signInCustomer(Object.assign(Object.assign({},e),{cartId:r}),t)).pipe(re(({body:e})=>e.data.persistentCartRetrievalInformation?V(this._checkoutActionCreator.loadCheckout(e.data.persistentCartRetrievalInformation.id,t)(n),Z(o(Ut.SignInCustomerSucceeded,e.data))):V(this._checkoutActionCreator.loadCurrentCheckout(t)(n),Z(o(Ut.SignInCustomerSucceeded,e.data)))))).pipe(Q(e=>gc(Ut.SignInCustomerFailed,e)))}}signOutCustomer(e){return t=>{const n=t.getState().checkout.getCheckoutOrThrow(),i=n.cart.source===go.BuyNow?n.id:void 0;return V(Z(o(Ut.SignOutCustomerRequested)),Y(this._customerRequestSender.signOutCustomer(e,i)).pipe(re(({body:n})=>V(this._checkoutActionCreator.loadCurrentCheckout(e)(t),Z(o(Ut.SignOutCustomerSucceeded,n.data)))))).pipe(Q(e=>gc(Ut.SignOutCustomerFailed,e)))}}}class Uc{constructor(e){this._requestSender=e}createAccount(e,{timeout:t}={}){return this._requestSender.post("/api/storefront/customer",{timeout:t,headers:uc,body:e})}createAddress(e,{timeout:t}={}){return this._requestSender.post("/api/storefront/customer-address",{timeout:t,headers:uc,body:e})}signInCustomer(e,{timeout:t}={}){return this._requestSender.post("/internalapi/v1/checkout/customer",{timeout:t,headers:uc,body:e})}signOutCustomer({timeout:e}={},t){return this._requestSender.delete("/internalapi/v1/checkout/customer",Object.assign({timeout:e,headers:uc},t&&{body:{cartId:t}}))}}class Fc{constructor(e){this._formFieldsRequestSender=e}loadFormFields(e){return V(Z(o(tn.LoadFormFieldsRequested)),H(()=>{return t=this,n=void 0,r=function*(){const{body:t}=yield this._formFieldsRequestSender.loadFields(e);return o(tn.LoadFormFieldsSucceeded,t)},new((i=void 0)||(i=Promise))(function(e,o){function a(e){try{d(r.next(e))}catch(e){o(e)}}function s(e){try{d(r.throw(e))}catch(e){o(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof i?n:new i(function(e){e(n)})).then(a,s)}d((r=r.apply(t,n||[])).next())});var t,n,i,r})).pipe(Q(e=>gc(tn.LoadFormFieldsFailed,e)))}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([ic],Fc.prototype,"loadFormFields",null);class Bc{constructor(e){this._requestSender=e}loadFields({timeout:e}={}){return this._requestSender.get("/api/storefront/form-fields",{timeout:e,headers:Object.assign({Accept:dc.JsonV1,"X-API-INTERNAL":cc},uc)})}}class xc extends be{constructor(e){super(e||"Unable to proceed because the required element is unexpectedly detached from the page."),this.name="UnexpectedDetachmentError",this.type="unexpected_detachment"}}class qc{constructor(e){this._mutationObserver=e}ensurePresence(e,t){return n=this,i=void 0,o=function*(){const n=new Ia(t),i=this._mutationObserver.create(t=>{t.forEach(t=>{0!==Array.from(t.removedNodes).filter(t=>e.some(e=>t===e||t.contains(e))).length&&n.cancel(new xc)})});i.observe(document.body,{childList:!0,subtree:!0});try{const e=yield n.promise;return i.disconnect(),e}catch(e){throw i.disconnect(),e}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}}class jc{constructor(e=window){this._window=e}create(e){return new this._window.MutationObserver(e)}}class Gc extends be{constructor(e){super(e||"Invalid arguments have been provided."),this.name="InvalidArgumentError",this.type="invalid_argument"}}function Vc(e){if(!/^(https?:)?\/\//.test(e))throw new Gc("The provided URL must be absolute.");const t=document.createElement("a");t.href=e;const 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 Hc(e,t){return e.type===t}class Wc{constructor(e,t,n){this._targetWindow=t,this._context=n,this._targetOrigin="*"===e?"*":Vc(e).origin}post(e,t){const n=this._targetWindow;if(window===n)return;if(!n)throw new Error("Unable to post message because target window is not set.");const i=t&&K(window,"message").pipe(ee(e=>e.origin===this._targetOrigin&&Hc(e.data,e.data.type)&&-1!==[t.successType,t.errorType].indexOf(e.data.type)),te(e=>{if(t.errorType===e.data.type)throw e.data;return e.data}),oe(1)).toPromise();return n.postMessage(Object.assign(Object.assign({},e),{context:this._context}),this._targetOrigin),i}setTarget(e){this._targetWindow=e}setContext(e){this._context=e}}class Yc{constructor(e){var t;this._sourceOrigins=[Vc(e).origin,(t=Vc(e),Vc(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,`www.${t.hostname}`))).origin],this._isListening=!1,this._listeners={}}listen(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))}stopListen(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))}addListener(e,t){let n=this._listeners[e];n||(this._listeners[e]=n=[]),-1===n.indexOf(t)&&n.push(t)}removeListener(e,t){const n=this._listeners[e];if(!n)return;const i=n.indexOf(t);i>=0&&n.splice(i,1)}trigger(e,t){const n=this._listeners[e.type];n&&n.forEach(n=>t?n(e,t):n(e))}_handleMessage(e){if(-1===this._sourceOrigins.indexOf(e.origin)||!Hc(e.data,e.data.type))return;const t=e.data,{context:n}=t,i=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["context"]);this.trigger(i,n)}}!function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);o>3&&a&&Object.defineProperty(t,n,a)}([ba],Yc.prototype,"_handleMessage",null);class Kc extends be{constructor(){super("You haven't complete our spam protection challenge. Please try again."),this.name="SpamProtectionChallengeNotCompletedError",this.type="spam_protection_challenge_not_completed"}}class $c extends be{constructor(){super("Please complete our human verification challenge and try again."),this.name="CardingProtectionChallengeNotCompletedError",this.type="carding_protection_challenge_not_completed"}}class Zc extends be{constructor(){super("We were not able to verify that you are not a robot. Please try again."),this.name="CardingProtectionFailedError",this.type="carding_protection_failed"}}var Jc,Qc,Xc,eu=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class tu{constructor(e){this._googleRecaptcha=e}handle(e,t){return eu(this,void 0,void 0,function*(){return"string"==typeof e?this.handleWithRecaptchaSitekey(e,t):this.handleWithPaymentHumanVerificationRequestError(e)})}handleWithPaymentHumanVerificationRequestError(e){return eu(this,void 0,void 0,function*(){if(!this._isPaymentHumanVerificationRequest(e))throw e;return yield this._initialize(e.body.additional_action_required.data.key),this._performRecaptcha()})}handleWithRecaptchaSitekey(e,t){return eu(this,void 0,void 0,function*(){if("recaptcha_v2"!==e)throw Error("Human verification method is not supported.");if(!t)throw Error("Recaptcha site key is missing.");return yield this._initialize(t),this._performRecaptcha()})}_performRecaptcha(){return this._googleRecaptcha.execute().pipe(oe(1)).pipe(re(e=>eu(this,[e],void 0,function*({error:e,token:t}){if(e instanceof Kc)throw new $c;if(e||!t)throw new Zc;return{type:"recaptcha_v2_verification",data:{human_verification_token:t}}}))).toPromise()}_initialize(e){const t="cardingProtectionContainer";let n=document.getElementById(t);return n&&n.parentNode&&n.parentNode.removeChild(n),n=document.createElement("div"),n.setAttribute("id",t),document.body.appendChild(n),this._googleRecaptcha.load(t,e)}_isPaymentHumanVerificationRequest(e){const{additional_action_required:t,status:n}=e.body||{};return"additional_action_required"===n&&t&&"recaptcha_v2_verification"===t.type}}!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"}(Jc||(Jc={}));class nu extends be{constructor(e){super(function(e){switch(e){case Jc.CustomerNotInitialized:return"Unable to proceed because the customer step of checkout has not been initialized.";case Jc.PaymentNotInitialized:return"Unable to proceed because the payment step of checkout has not been initialized.";case Jc.ShippingNotInitialized:return"Unable to proceed because the shipping step of checkout has not been initialized.";case Jc.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."}}(e)),this.subtype=e,this.name="NotInitializedError",this.type="not_initialized"}}class iu extends be{constructor(){super("We were not able to complete your spam protection verification. Please try again."),this.name="SpamProtectionFailedError",this.type="spam_protection_failed"}}class ru extends be{constructor(){super("Spam protection is not loaded. Please try again."),this.name="SpamProtectionNotLoadedError",this.type="spam_protection_failed"}}class ou{constructor(e,t){this.googleRecaptchaScriptLoader=e,this.mutationObserverFactory=t,this._memoized=ae((e,t,n)=>{const i=new G;if(!n)throw new Error;return this._widgetId=e.render(n.id,{sitekey:t,size:"invisible",callback:()=>{i.next({token:e.getResponse(this._widgetId)}),e.reset(this._widgetId)},"error-callback":()=>{i.next({error:new iu})}}),i},{isEqual:(e,t)=>e===t})}load(e,t){return this.googleRecaptchaScriptLoader.load().then(n=>{n&&(this._event$=this._memoized(n,t,document.getElementById(e)),this._recaptcha=n)}).catch(e=>{throw e})}reset(e){var t;const n=document.getElementById(e);null==n||n.remove(),null===(t=this._recaptcha)||void 0===t||t.reset(this._widgetId)}execute(){return H(()=>{const e=this._event$,t=this._recaptcha;if(!e||!t)throw new nu(Jc.SpamProtectionNotInitialized);return H(()=>{const e=document.querySelector('iframe[src*="bframe"]');return e?Z(e):J(new ru)}).pipe(ne(e=>e.pipe(X(250),re((e,t)=>t<28?Z(e):J(e)))),re(n=>(this._watchRecaptchaChallengeWindow(e,n),t.execute(this._widgetId),e)),Q(e=>Z({error:e})))})}_watchRecaptchaChallengeWindow(e,t){const n=t.parentElement;if(!n)throw new ru;const i=n.parentElement;if(!i)throw new ru;this.mutationObserverFactory.create(()=>{"hidden"===i.style.visibility&&e.next({error:new Kc})}).observe(i,{attributes:!0,attributeFilter:["style"]})}}class au{constructor(e,t=window){this._scriptLoader=e,this._window=t}load(){return this._loadPromise||(this._loadPromise=this._loadScript()),this._loadPromise}_loadScript(){const e="initRecaptcha",t=[`onload=${e}`,"render=explicit"].join("&");return new Promise((n,i)=>{this._window[e]=()=>n(this._window.grecaptcha),this._scriptLoader.loadScript(`//www.google.com/recaptcha/api.js?${t}`).catch(e=>{this._loadPromise=void 0,i(e)})})}}function su(e){return new ou(new au(e),new jc)}class du extends be{constructor(e){super(e||"Unable to proceed due to invalid configuration provided for the hosted payment form."),this.name="InvalidHostedFormConfigError",this.type="invalid_hosted_form_config"}}class cu extends be{constructor(e){super(e||"Unable to proceed due to an unknown error with the hosted payment form."),this.name="InvalidHostedFormError",this.type="invalid_hosted_form"}}class uu extends be{constructor(e){super(["Unable to proceed due to invalid user input values",...p(x(e),e=>P(e,({message:e})=>e))].join(". ")),this.errors=e,this.name="InvalidHostedFormValueError",this.type="invalid_hosted_form_value"}}!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"}(Qc||(Qc={})),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"}(Xc||(Xc={}));var lu=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class hu{constructor(e,t,n,i,r,o,a,s,d,c){this._type=e,this._containerId=t,this._placeholder=n,this._accessibilityLabel=i,this._styles=r,this._eventPoster=o,this._eventListener=a,this._detachmentObserver=s,this._checkoutId=d,this._cardInstrument=c,this._iframe=document.createElement("iframe");const u=this._checkoutId?`/checkout/payment/hosted-field?version=1.935.0&checkoutId=${this._checkoutId}`:"/checkout/payment/hosted-field?version=1.935.0";this._iframe.src=u,this._iframe.style.border="none",this._iframe.style.height="100%",this._iframe.style.overflow="hidden",this._iframe.style.width="100%"}getType(){return this._type}attach(){return lu(this,void 0,void 0,function*(){const e=document.getElementById(this._containerId);if(!e)throw new du("Unable to proceed because the provided container ID is not valid.");e.appendChild(this._iframe),this._eventListener.listen();const t=K(this._iframe,"load").pipe(re(e=>lu(this,[e],void 0,function*({target:e}){const t=e&&e.contentWindow;if(!t)throw new Error("The content window of the iframe cannot be accessed.");this._eventPoster.setTarget(t),yield this._eventPoster.post({type:Qc.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:Xc.AttachSucceeded,errorType:Xc.AttachFailed})})),oe(1)).toPromise();yield this._detachmentObserver.ensurePresence([this._iframe],t)})}detach(){this._iframe.parentElement&&(this._iframe.parentElement.removeChild(this._iframe),this._eventListener.stopListen())}submitForm(e,t){return lu(this,void 0,void 0,function*(){try{const n=this._eventPoster.post({type:Qc.SubmitRequested,payload:{fields:e,data:t}},{successType:Xc.SubmitSucceeded,errorType:Xc.SubmitFailed});return yield this._detachmentObserver.ensurePresence([this._iframe],n)}catch(e){if(this._isSubmitErrorEvent(e)){if("hosted_form_error"===e.payload.error.code)throw new cu(e.payload.error.message);if(e.payload.response)throw Te(e.payload.response);throw new Error(e.payload.error.message)}throw e}})}submitStoredCardForm(e,t){return lu(this,void 0,void 0,function*(){const n=this._eventPoster.post({type:Qc.StoredCardRequested,payload:{fields:e,data:t}},{successType:Xc.StoredCardSucceeded,errorType:Xc.StoredCardFailed});return this._detachmentObserver.ensurePresence([this._iframe],n)})}validateForm(){return lu(this,void 0,void 0,function*(){const e=this._eventPoster.post({type:Qc.ValidateRequested},{successType:Xc.Validated}),{payload:t}=yield this._detachmentObserver.ensurePresence([this._iframe],e);if(!t.isValid)throw new uu(t.errors)})}_getFontUrls(){const e="fonts.googleapis.com",t=document.querySelectorAll(`link[href*='${e}'][rel='stylesheet']`);return Array.prototype.slice.call(t).filter(t=>Vc(t.href).hostname===e).filter(e=>x(this._styles).map(e=>e&&e.fontFamily).filter(e=>"string"==typeof e).some(t=>t.split(/,\s/).some(t=>-1!==e.href.indexOf(t.replace(" ","+"))))).map(e=>e.href)}_isSubmitErrorEvent(e){return e.type===Xc.SubmitFailed}}var pu=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class gu{constructor(e,t,n,i,r){this._fields=e,this._eventListener=t,this._payloadTransformer=n,this._eventCallbacks=i,this._paymentHumanVerificationHandler=r,this._handleEnter=e=>pu(this,[e],void 0,function*({payload:e}){try{yield this.validate()}catch(e){if(e instanceof Error&&"InvalidHostedFormValueError"!==e.name)throw e}const{onEnter:t=T}=this._eventCallbacks;t(e)});const{onBlur:o=T,onCardTypeChange:a=T,onFocus:s=T,onValidate:d=T}=this._eventCallbacks;this._eventListener.addListener(Xc.Blurred,({payload:e})=>o(e)),this._eventListener.addListener(Xc.CardTypeChanged,({payload:e})=>a(e)),this._eventListener.addListener(Xc.Focused,({payload:e})=>s(e)),this._eventListener.addListener(Xc.Validated,({payload:e})=>d(e)),this._eventListener.addListener(Xc.Entered,this._handleEnter),this._eventListener.addListener(Xc.CardTypeChanged,({payload:e})=>this._cardType=e.cardType),this._eventListener.addListener(Xc.BinChanged,({payload:e})=>this._bin=e.bin)}getBin(){return this._bin}getCardType(){return this._cardType}attach(){return pu(this,void 0,void 0,function*(){this._eventListener.listen();const e=this._getFirstField(),t=q(this._fields,e);yield e.attach(),yield Promise.all(t.map(e=>e.attach()))})}detach(){this._eventListener.stopListen(),this._fields.forEach(e=>{e.detach()})}submit(e,t){return pu(this,void 0,void 0,function*(){try{return yield this._getFirstField().submitForm(this._fields.map(e=>e.getType()),this._payloadTransformer.transform(e,t))}catch(t){const n=yield this._paymentHumanVerificationHandler.handle(t);return yield this._getFirstField().submitForm(this._fields.map(e=>e.getType()),this._payloadTransformer.transform(e,n))}})}submitStoredCard(e){return pu(this,void 0,void 0,function*(){return this._getFirstField().submitStoredCardForm(e.fields,e.data)})}validate(){return pu(this,void 0,void 0,function*(){return this._getFirstField().validateForm()})}_getFirstField(){const e=this._fields[0];if(!e)throw new du("Unable to proceed because the payment form has no field defined.");return e}}function mu(e){return Boolean(e.instrumentId)}class yu{constructor(e){this._store=e}transform(e,t){const n=this._store.getState(),i=n.checkout.getCheckout(),r=n.config.getConfig(),o=n.instruments.getInstrumentsMeta(),a=n.order.getOrder(),s=n.order.getOrderMeta(),d=k(e.paymentData,"ccExpiry","ccName","ccNumber","ccCvv");let c=n.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId);"worldpayaccess"===(null==c?void 0:c.gateway)&&"credit_card"===(null==c?void 0:c.id)&&(c=Object.assign(Object.assign({},c),{id:"worldpayaccess",method:"credit-card"}));const u=n.paymentMethods.getPaymentMethodsMeta(),l=o&&d&&mu(d)?`${n.payment.getPaymentToken()}, ${o.vaultAccessToken}`:n.payment.getPaymentToken();if(!l)throw new Zi($i.MissingPaymentToken);return{additionalAction:t,authToken:l,checkout:i,config:r,order:a,orderMeta:s,payment:d,paymentMethod:c,paymentMethodMeta:u}}}class fu{constructor(e){this._store=e}create(e,t,n){const i=Object.keys(t.fields).reduce((i,r)=>{const o=t.fields[r];return o?[...i,new hu(r,o.containerId,o.placeholder||"",o.accessibilityLabel||"",t.styles||{},new Wc(e),new Yc(e),new qc(new jc),n,"instrumentId"in o?this._getCardInstrument(o.instrumentId):void 0)]:i},[]);return new gu(i,new Yc(e),new yu(this._store),D(t,"onBlur","onEnter","onFocus","onCardTypeChange","onValidate"),new tu(su(ue())))}_getCardInstrument(e){const{instruments:{getCardInstrument:t}}=this._store.getState(),n=t(e);if(!n)throw new Zi($i.MissingPaymentInstrument);return n}}class _u extends be{constructor(){super("You haven't complete our spam check. Please try again."),this.name="SpamProtectionNotCompletedError",this.type="spam_protection_not_completed"}}class Su{constructor(e,t){this._orderRequestSender=e,this._checkoutValidator=t}loadOrder(e,t){return new j(n=>{n.next(o(Pt.LoadOrderRequested)),this._orderRequestSender.loadOrder(e,t).then(e=>{n.next(o(Pt.LoadOrderSucceeded,e.body)),n.complete()}).catch(e=>{n.error(s(Pt.LoadOrderFailed,e))})})}loadOrderPayments(e,t){return new j(n=>{n.next(o(Pt.LoadOrderPaymentsRequested)),this._orderRequestSender.loadOrder(e,t).then(e=>{n.next(o(Pt.LoadOrderPaymentsSucceeded,e.body)),n.complete()}).catch(e=>{n.error(s(Pt.LoadOrderPaymentsFailed,e))})})}loadCurrentOrder(e){return t=>H(()=>{const n=this._getCurrentOrderId(t.getState());if(!n)throw new Zi($i.MissingOrderId);return this.loadOrder(n,e)})}submitOrder(e,t){return n=>V(Z(o(Pt.SubmitOrderRequested)),H(()=>{const i=n.getState(),r=i.config.getExternalSource(),a=i.config.getVariantIdentificationToken(),s=i.checkout.getCheckout();if(!s)throw new Zi($i.MissingCheckout);if(s.shouldExecuteSpamCheck)throw new _u;return Y(this._checkoutValidator.validate(s,t).then(()=>this._orderRequestSender.submitOrder(this._mapToOrderRequestBody(null!=e?e:{},s.id,s.customerMessage,r),Object.assign(Object.assign({},t),{headers:{checkoutVariant:a}})))).pipe(re(e=>V(this.loadOrder(e.body.data.order.orderId,t),Z(o(Pt.SubmitOrderSucceeded,e.body.data,Object.assign(Object.assign({},e.body.meta),{token:e.headers.token}))))))}).pipe(Q(e=>gc(Pt.SubmitOrderFailed,e))))}finalizeOrder(e,t){return V(Z(o(Pt.FinalizeOrderRequested)),Y(this._orderRequestSender.finalizeOrder(e,t)).pipe(re(n=>V(this.loadOrder(e,t),Z(o(Pt.FinalizeOrderSucceeded,n.body.data)))))).pipe(Q(e=>gc(Pt.FinalizeOrderFailed,e)))}_getCurrentOrderId(e){const t=e.order.getOrder(),n=e.checkout.getCheckout();return t&&t.orderId||n&&n.orderId}_mapToOrderRequestBody(e,t,n,i){const{payment:r}=e,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(e,["payment"]);return r?Object.assign(Object.assign({},o),{cartId:t,customerMessage:n,externalSource:i,payment:{paymentData:r.paymentData,name:r.methodId,gateway:r.gatewayId}}):Object.assign(Object.assign({},o),{cartId:t,customerMessage:n,externalSource:i})}}class vu extends be{constructor(e){super(e||"Your checkout could not be processed because some details have changed. Please review your order and try again."),this.name="CartConsistencyError",this.type="cart_consistency"}}class Cu extends be{constructor(e,t){super(t||"At least one item changed stock position. Please review your cart and try again."),this.name="CartStockPositionsChangedError",this.type="cart_stock_positions_changed",this.changedItemIds=e}}class Iu extends be{constructor(e){super(e||"The tax provider is unavailable."),this.name="OrderTaxProviderUnavailableError",this.type="tax_provider_unavailable"}}class wu extends be{constructor(e){super(e),this.name="MissingShippingMethodError",this.type="missing_shipping_method"}}class bu extends be{constructor(e){super(e),this.name="InvalidShippingAddressError",this.type="invalid_shipping_address"}}class Eu{constructor(e){this._requestSender=e}loadOrder(e,{timeout:t}={}){const n=`/api/storefront/orders/${e}`,i=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.get(n,{params:{include:Ic(["payments","lineItems.physicalItems.socialMedia","lineItems.physicalItems.options","lineItems.physicalItems.categories","lineItems.digitalItems.socialMedia","lineItems.digitalItems.options","lineItems.digitalItems.categories"])},headers:i,timeout:t})}submitOrder(e,{headers:t,timeout:n}={}){return this._requestSender.post("/internalapi/v1/checkout/order",{body:e,headers:R(Object.assign({"X-Checkout-Variant":t&&t.checkoutVariant},uc),v),timeout:n}).catch(e=>{var t,n;if("tax_provider_unavailable"===e.body.type)throw new Iu;if("cart_has_changed"===e.body.type)throw new vu;if("cart_stock_positions_changed"===e.body.type){const i=null!==(n=null===(t=e.body.errors)||void 0===t?void 0:t.changedItemIds)&&void 0!==n?n:[];throw new Cu(i)}if("missing_shipping_method"===e.body.type)throw new wu(e.body.detail);if("invalid_shipping_address"===e.body.type)throw new bu(e.body.detail);if("empty_cart"===e.body.type)throw new fc;throw e})}finalizeOrder(e,{timeout:t}={}){const n=`/internalapi/v1/checkout/order/${e}`;return this._requestSender.post(n,{timeout:t,headers:uc})}}class Pu{constructor(e,t,n,i){this._paymentRequestSender=e,this._orderActionCreator=t,this._paymentRequestTransformer=n,this._paymentHumanVerificationHandler=i,this.initializeOffsitePayment=({methodId:e,gatewayId:t,instrumentId:n,target:i,promise:r,shouldSaveInstrument:a,shouldSetAsDefaultInstrument:s})=>d=>{let c;n?c={formattedPayload:{bigpay_token:n}}:a&&(c={formattedPayload:{vault_payment_instrument:a,set_as_default_stored_instrument:s||null}});const u=this._paymentRequestTransformer.transform({gatewayId:t,methodId:e,paymentData:c},d.getState());return V(Z(o(bn.InitializeOffsitePaymentRequested)),Promise.race([this._paymentRequestSender.initializeOffsitePayment(u,i),r].filter(Boolean)).then(()=>o(bn.InitializeOffsitePaymentSucceeded))).pipe(Q(e=>gc(bn.InitializeOffsitePaymentFailed,e)))}}submitPayment(e){return t=>V(Z(o(bn.SubmitPaymentRequested)),H(()=>{return n=this,i=void 0,o=function*(){try{return yield this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(e,t.getState()))}catch(n){const i=yield this._paymentHumanVerificationHandler.handle(n);return yield this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transform(Object.assign(Object.assign({},e),{additionalAction:i}),t.getState()))}},new((r=void 0)||(r=Promise))(function(e,t){function a(e){try{d(o.next(e))}catch(e){t(e)}}function s(e){try{d(o.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(a,s)}d((o=o.apply(n,i||[])).next())});var n,i,r,o}).pipe(re(({body:e})=>V(this._orderActionCreator.loadCurrentOrder()(t),Z(o(bn.SubmitPaymentSucceeded,e)))))).pipe(Q(e=>gc(bn.SubmitPaymentFailed,e)))}}class Ou{constructor(e){this._client=e}submitPayment(e){return new Promise((t,n)=>{this._client.submitPayment(e,(e,i)=>{e?n(this._transformResponse(e)):t(this._transformResponse(i))})})}initializeOffsitePayment(e,t){return new Promise(()=>{this._client.initializeOffsitePayment(e,null,t)})}_transformResponse(e){return{headers:e.headers,body:e.data,status:e.status,statusText:e.statusText}}}function Au(e,t){let 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 Tu=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function ku(e){return{code:e.code,discount:e.displayName,discountType:Tu.indexOf(e.couponType)}}function Ru(e){return{code:e.code,discountedAmount:e.used,remainingBalance:e.remaining,giftCertificate:{balance:e.balance,code:e.code,purchaseDate:e.purchaseDate}}}function Du(e){const t=[];return(e||[]).forEach(e=>{(e.banners||[]).forEach(e=>{t.push({placeholders:[],discountType:null,message:"",messageHtml:e.text})})}),t}function Mu(e,t,n="id"){return Object.keys(e).reduce((i,r)=>[...i,...e[r].map(e=>"giftCertificates"===r?function(e,t){const n=new Jd(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,i="id"){const r=new Jd(n);return{id:e[i],imageUrl:e.imageUrl,amount:e.extendedListPrice,amountAfterDiscount:e.extendedSalePrice,discount:e.discountAmount,integerAmount:r.toInteger(e.extendedListPrice),integerAmountAfterDiscount:r.toInteger(e.extendedSalePrice),integerDiscount:r.toInteger(e.discountAmount),integerUnitPrice:r.toInteger(e.listPrice),integerUnitPriceAfterDiscount:r.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(e=>({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""}}(r),t,n))],[])}function Nu(e){const t=e.cart.currency.decimalPlaces,n=new Jd(t);return{id:e.cart.id,items:Mu(e.cart.lineItems,t),currency:e.cart.currency.code,coupon:{discountedAmount:N(e.cart.coupons,(e,t)=>e+t.discountedAmount,0),coupons:e.cart.coupons.map(ku)},discount:{amount:e.cart.discountAmount,integerAmount:n.toInteger(e.cart.discountAmount)},discountNotifications:Du(e.promotions),giftCertificate:{totalDiscountedAmount:N(e.giftCertificates,(e,t)=>e+t.used,0),appliedGiftCertificates:w(e.giftCertificates.map(Ru),"code")},shipping:{amount:e.shippingCostTotal,integerAmount:n.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:n.toInteger(e.shippingCostBeforeDiscount),required:z(e.cart.lineItems.physicalItems,e=>e.isShippingRequired)},subtotal:{amount:e.subtotal,integerAmount:n.toInteger(e.subtotal)},storeCredit:{amount:e.customer?e.customer.storeCredit:0},taxSubtotal:{amount:e.taxTotal,integerAmount:n.toInteger(e.taxTotal)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:n.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:n.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.grandTotal,integerAmount:n.toInteger(e.grandTotal)}}}var Lu;!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.PAYPALEXPRESS="paypalexpress"}(Lu||(Lu={}));const zu=Lu;function Uu(e,t){const n=e.firstName||t.firstName||"",i=e.lastName||t.lastName||"";return{addresses:(e.addresses||[]).map(e=>Au(e)),customerId:e.id,isGuest:e.isGuest,storeCredit:e.storeCredit,email:e.email||t.email||"",firstName:n,lastName:i,name:e.fullName||[n,i].join(" "),customerGroupName:e.customerGroup&&e.customerGroup.name}}class Fu{format(e){const[t="",n=""]=e.split(new RegExp("\\s*/\\s*")),i=t.slice(0,2),r=4===n.length?n.slice(-2):n?n.slice(0,2):t.slice(2);return e.length<2?t:e.length>3&&!r?i:`${i} / ${r}`}toObject(e){const[t="",n=""]=e.split(new RegExp("\\s*/\\s*"));return/^\d+$/.test(t)&&/^\d+$/.test(n)?{month:1===t.length?`0${t}`:t.slice(0,2),year:2===n.length?`20${n}`:n.slice(0,4)}:{month:"",year:""}}}class Bu{format(e){const{card:t}=ye(e);if(!t)return e;const n=O(me(e).map(e=>O(e.lengths))),i=this.unformat(e).slice(0,n);return t.gaps.filter(e=>i.length>e).reduce((e,t,n)=>[e.slice(0,t+n),e.slice(t+n)].join(" "),i)}unformat(e){const{card:t}=ye(e);return t?e.replace(new RegExp(" ","g"),""):e}}function xu(e,t={}){const n=e.currency.decimalPlaces,i=new Jd(n);return{id:e.orderId,items:Mu(e.lineItems,e.currency.decimalPlaces,"productId"),orderId:e.orderId,currency:e.currency.code,customerCanBeCreated:e.customerCanBeCreated,payment:Gu(e.payments,t.payment),subtotal:{amount:e.baseAmount,integerAmount:i.toInteger(e.baseAmount)},coupon:{discountedAmount:N(e.coupons,(e,t)=>e+t.discountedAmount,0),coupons:e.coupons.map(ku)},discount:{amount:e.discountAmount,integerAmount:i.toInteger(e.discountAmount)},token:t.orderToken,callbackUrl:t.callbackUrl,discountNotifications:[],giftCertificate:ju(e.payments),socialData:Hu(e),status:e.status,hasDigitalItems:e.hasDigitalItems,isDownloadable:e.isDownloadable,isComplete:e.isComplete,shipping:{amount:e.shippingCostTotal,integerAmount:i.toInteger(e.shippingCostTotal),amountBeforeDiscount:e.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(e.shippingCostBeforeDiscount)},storeCredit:{amount:qu(e.payments)},taxes:e.taxes,taxTotal:{amount:e.taxTotal,integerAmount:i.toInteger(e.taxTotal)},handling:{amount:e.handlingCostTotal,integerAmount:i.toInteger(e.handlingCostTotal)},grandTotal:{amount:e.orderAmount,integerAmount:e.orderAmountAsInteger}}}function qu(e){const t=l(e,{providerId:"storecredit"});return t?t.amount:0}function ju(e){const t=u(e,{providerId:"giftcertificate"});return{totalDiscountedAmount:N(t,(e,t)=>t.amount+e,0),appliedGiftCertificates:w(t.map(e=>({code:e.detail.code,discountedAmount:e.amount,remainingBalance:e.detail.remaining,giftCertificate:{balance:e.amount+e.detail.remaining,code:e.detail.code,purchaseDate:""}})),"code")}}function Gu(e,t={}){const n=l(e,Vu);return n?{id:n.providerId,status:(i=n.detail.step,`PAYMENT_STATUS_${i}`),helpText:n.detail.instructions,returnUrl:t.returnUrl}:{};var i}function Vu(e){return"giftcertificate"!==e.providerId&&"storecredit"!==e.providerId}function Hu(e){const t={};return[...e.lineItems.physicalItems,...e.lineItems.digitalItems].forEach(e=>{var n;t[e.id]=(n=e,["fb","tw","gp"].reduce((e,t)=>{const i=n.socialMedia&&l(n.socialMedia,e=>e.code===t);return i?(e[t]={name:n.name,description:n.name,image:n.imageUrl,url:i.link,shareText:i.text,sharingLink:i.link,channelName:i.channel,channelCode:i.code},e):e},{}))}),t}function Wu(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}}class Yu{constructor(){this._cardExpiryFormatter=new Fu,this._cardNumberFormatter=new Bu}transform(e,t){const n=t.billingAddress.getBillingAddress(),i=t.checkout.getCheckout(),r=t.customer.getCustomer(),o=t.order.getOrder(),a=t.paymentMethods.getPaymentMethod(e.methodId,e.gatewayId),s=this._mapShippingAddress(t,a),d=t.consignments.getConsignments(),c=t.consignments.getShippingOption(),u=t.config.getStoreConfig(),l=t.config.getContextConfig(),h=t.instruments.getInstrumentsMeta(),p=t.paymentMethods.getPaymentMethodsMeta(),g=t.order.getOrderMeta(),m=r&&n&&Uu(r,n),y=h&&e.paymentData&&(mu(e.paymentData)||function(e){const t=e.formattedPayload;return!!t&&("string"==typeof t.bigpay_token||Boolean(t.bigpay_token&&t.bigpay_token.token))}(e.paymentData))?`${t.payment.getPaymentToken()}, ${h.vaultAccessToken}`:t.payment.getPaymentToken();if(!y)throw new Zi($i.MissingPaymentToken);return{additionalAction:e.additionalAction,authToken:y,customer:m,billingAddress:n&&Au(n),shippingAddress:s&&Au(s,d),shippingOption:c&&Wu(c,!0),cart:i&&Nu(i),order:o&&xu(o,g),orderMeta:g,payment:e.paymentData,paymentMethod:a&&this._transformPaymentMethod(a),quoteMeta:{request:Object.assign(Object.assign({},p),{geoCountryCode:l&&l.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:D(u&&u.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}}transformWithHostedFormData(e,t,n){const{additionalAction:i,authToken:r,checkout:o,config:a,order:s,orderMeta:d,payment:c={},paymentMethod:u,paymentMethodMeta:l}=t,h=o&&o.consignments[0],p=h&&h.shippingAddress,g=h&&h.selectedShippingOption;return{additionalAction:i,authToken:r,paymentMethod:u&&this._transformPaymentMethod(u),customer:s&&s.billingAddress&&o&&Uu(o.customer,s.billingAddress),billingAddress:s&&s.billingAddress&&Au(s.billingAddress),shippingAddress:p&&o&&Au(p,o.consignments),shippingOption:g&&Wu(g,!0),cart:o&&Nu(o),order:s&&xu(s,d),orderMeta:d,payment:this._transformHostedInputValues(e,c,n),quoteMeta:{request:Object.assign(Object.assign({},l),{geoCountryCode:a&&a.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:a&&D(a.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}}_transformPaymentMethod(e){if("multi-option"===e.method&&!e.gateway)return Object.assign(Object.assign({},e),{gateway:e.id});if(e.initializationData&&e.initializationData.gateway)return Object.assign(Object.assign({},e),{id:e.initializationData.gateway});if("worldpayaccess"===e.gateway){if("credit_card"===e.id)return Object.assign(Object.assign({},e),{id:"worldpayaccess",method:"credit-card"});if("open_banking"===e.id)return Object.assign(Object.assign({},e),{id:"worldpayaccess",method:"open_banking"})}return e.id===zu.BRAINTREE_VENMO?Object.assign(Object.assign({},e),{id:zu.BRAINTREE_PAYPAL}):e}_transformHostedInputValues(e,t,n){return"instrumentId"in t?Object.assign(Object.assign({},t),{ccCvv:e.cardCodeVerification,ccNumber:e.cardNumberVerification&&this._cardNumberFormatter.unformat(e.cardNumberVerification),hostedFormNonce:n}):Object.assign(Object.assign({},t),{ccCvv:e.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(e.cardExpiry||""),ccName:e.cardName||"",ccNumber:this._cardNumberFormatter.unformat(e.cardNumber||""),hostedFormNonce:n})}_mapShippingAddress(e,t){var n,i,r,o;if(t){const a=null===(i=null===(n=t.initializationData)||void 0===n?void 0:n.bopis)||void 0===i?void 0:i.enabled,s=null===(o=null===(r=t.initializationData)||void 0===r?void 0:r.bopis)||void 0===o?void 0:o.requiredAddress,d=e.consignments.getConsignments(),c=null==d?void 0:d.every(e=>e.selectedPickupOption);if(a&&c&&"none"===s)return}return e.shippingAddress.getShippingAddress()}}class Ku{widgetInteraction(e,t){const n={methodId:t&&t.methodId};return V(Z(o(Nn.WidgetInteractionStarted,void 0,n)),H(()=>e().then(()=>o(Nn.WidgetInteractionFinished,void 0,n)))).pipe(Q(e=>gc(Nn.WidgetInteractionFailed,e,n)))}}class $u{updatePaymentProviderCustomer(e){return Z(o(Yn.UpdatePaymentProviderCustomer,e))}}class Zu{constructor(e,t){this._remoteCheckoutRequestSender=e,this._checkoutActionCreator=t}initializeBilling(e,t,n){return j.create(i=>{i.next(o(Jn.InitializeRemoteBillingRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializeBilling(e,t,n).then(({body:t={}})=>{i.next(o(Jn.InitializeRemoteBillingSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(Jn.InitializeRemoteBillingFailed,t,{methodId:e}))})})}initializeShipping(e,t,n){return j.create(i=>{i.next(o(Jn.InitializeRemoteShippingRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializeShipping(e,t,n).then(({body:t={}})=>{i.next(o(Jn.InitializeRemoteShippingSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(Jn.InitializeRemoteShippingFailed,t,{methodId:e}))})})}initializePayment(e,t,n){return j.create(i=>{i.next(o(Jn.InitializeRemotePaymentRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.initializePayment(e,t,n).then(({body:t={}})=>{i.next(o(Jn.InitializeRemotePaymentSucceeded,t,{methodId:e})),i.complete()}).catch(t=>{i.error(s(Jn.InitializeRemotePaymentFailed,t,{methodId:e}))})})}loadSettings(e,t){return j.create(n=>{n.next(o(Jn.LoadRemoteSettingsRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.loadSettings(e,t).then(({body:t})=>{n.next(o(Jn.LoadRemoteSettingsSucceeded,t,{methodId:e})),n.complete()}).catch(t=>{n.error(s(Jn.LoadRemoteSettingsFailed,t,{methodId:e}))})})}signOut(e,t){return j.create(n=>{n.next(o(Jn.SignOutRemoteCustomerRequested,void 0,{methodId:e})),this._remoteCheckoutRequestSender.signOut(e,t).then(()=>{n.next(o(Jn.SignOutRemoteCustomerSucceeded,void 0,{methodId:e})),n.complete()}).catch(t=>{n.error(s(Jn.SignOutRemoteCustomerFailed,t,{methodId:e}))})})}forgetCheckout(e,t){return V(Z(o(Jn.ForgetCheckoutRemoteCustomerRequested,void 0,{methodId:e})),H(()=>{return n=this,i=void 0,a=function*(){return yield this._remoteCheckoutRequestSender.forgetCheckout(t),yield this._checkoutActionCreator.loadCurrentCheckout(),o(Jn.ForgetCheckoutRemoteCustomerSucceeded,void 0,{methodId:e})},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(t=>gc(Jn.ForgetCheckoutRemoteCustomerFailed,t,{methodId:e})))}updateCheckout(e,t){return o(Jn.UpdateRemoteCheckout,t,{methodId:e})}}class Ju{constructor(e){this._requestSender=e}initializeBilling(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/billing`;return this._requestSender.get(i,{params:t,timeout:n,headers:uc})}initializeShipping(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/shipping`;return this._requestSender.get(i,{params:t,timeout:n,headers:uc})}initializePayment(e,t,{timeout:n}={}){const i=`/remote-checkout/${e}/payment`;return this._requestSender.get(i,{params:t,timeout:n,headers:uc})}loadSettings(e,{timeout:t}={}){const n=`/remote-checkout/${e}/settings`;return this._requestSender.get(n,{timeout:t,headers:uc})}signOut(e,{timeout:t}={}){const n=`/remote-checkout/${e}/signout`;return this._requestSender.get(n,{timeout:t,headers:uc})}generateToken({timeout:e}={}){return this._requestSender.get("/remote-checkout-token",{timeout:e,headers:uc})}trackAuthorizationEvent({timeout:e}={}){return this._requestSender.post("/remote-checkout/events/shopper-checkout-service-provider-authorization-requested",{timeout:e,headers:uc})}forgetCheckout({timeout:e}={}){return this._requestSender.post("/remote-checkout/forget-checkout",{timeout:e,headers:uc})}}class Qu{constructor(e,t){this._consignmentRequestSender=e,this._checkoutRequestSender=t}unassignItemsByAddress(e,t){return n=>{const i=n.getState();if(!i.checkout.getCheckout())throw new Zi($i.MissingCheckout);const r=this._consignmentHasAddress(e)?e.address:e.shippingAddress,o=i.consignments.getConsignmentByAddress(r);if(!o)throw new Gc("No consignment found for the specified address");const a=this._removeLineItems(e.lineItems,o,i.cart.getCart());return a.length?this.updateConsignment({id:o.id,address:r,lineItems:a},t)(n):this.deleteConsignment(o.id,t)(n)}}assignItemsByAddress(e,t){return n=>{const i=n.getState(),r=this._consignmentHasAddress(e)?e.address:e.shippingAddress,o=i.consignments.getConsignmentByAddress(r);return this._createOrUpdateConsignment({id:o&&o.id,address:r,lineItems:this._addLineItems(e.lineItems,o,i.cart.getCart())},t)(n)}}selectShippingOption(e,t){return n=>j.create(i=>{const r=n.getState(),a=r.checkout.getCheckout(),d=r.consignments.getConsignments();if(!a)throw new Zi($i.MissingCheckout);if(!d||!d.length)throw new Zi($i.MissingConsignments);const c={id:d[0].id,shippingOptionId:e},u={id:d[0].id};i.next(o(ot.UpdateShippingOptionRequested,void 0,u)),this._consignmentRequestSender.updateConsignment(a.id,c,t).then(({body:e})=>{i.next(o(ot.UpdateShippingOptionSucceeded,e,u)),i.complete()}).catch(e=>{i.error(s(ot.UpdateShippingOptionFailed,e,u))})})}loadShippingOptions(e){return t=>j.create(n=>{const i=t.getState().checkout.getCheckout();if(!i)throw new Zi($i.MissingCheckout);n.next(o(ot.LoadShippingOptionsRequested)),this._checkoutRequestSender.loadCheckout(i.id,Object.assign(Object.assign({},e),{params:{include:[kc.AvailableShippingOptions]}})).then(({body:e})=>{n.next(o(ot.LoadShippingOptionsSucceeded,e)),n.complete()}).catch(e=>{n.error(s(ot.LoadShippingOptionsFailed,e))})})}updateAddress(e,t){return n=>{const i=this._getUpdateAddressRequestBody(e,n),r=n.getState().consignments.getConsignments();return r&&r.length&&(i.id=r[0].id),this._createOrUpdateConsignment(i,t)(n)}}createConsignments(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r||!r.id)throw new Zi($i.MissingCheckout);i.next(o(ot.CreateConsignmentsRequested)),this._consignmentRequestSender.createConsignments(r.id,e,t).then(({body:e})=>{i.next(o(ot.CreateConsignmentsSucceeded,e)),i.complete()}).catch(e=>{i.error(s(ot.CreateConsignmentsFailed,e))})})}updateConsignment(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout();if(!r||!r.id)throw new Zi($i.MissingCheckout);const a={id:e.id};i.next(o(ot.UpdateConsignmentRequested,void 0,a)),this._consignmentRequestSender.updateConsignment(r.id,e,t).then(({body:e})=>{i.next(o(ot.UpdateConsignmentSucceeded,e,a)),i.complete()}).catch(e=>{i.error(s(ot.UpdateConsignmentFailed,e,a))})})}deleteConsignment(e,t){return n=>j.create(i=>{const r=n.getState().checkout.getCheckout(),a={id:e};if(!r||!r.id)throw new Zi($i.MissingCheckout);i.next(o(ot.DeleteConsignmentRequested,void 0,a)),this._consignmentRequestSender.deleteConsignment(r.id,e,t).then(({body:e})=>{i.next(o(ot.DeleteConsignmentSucceeded,e,a)),i.complete()}).catch(e=>{i.error(s(ot.DeleteConsignmentFailed,e,a))})})}updateShippingOption(e,t){return n=>j.create(i=>{var r;const a=n.getState().checkout.getCheckout(),d=n.getState().consignments.getConsignmentById(e.id);if((null===(r=null==d?void 0:d.selectedShippingOption)||void 0===r?void 0:r.id)===e.shippingOptionId)return void i.complete();if(!a||!a.id)throw new Zi($i.MissingCheckout);const c={id:e.id};i.next(o(ot.UpdateShippingOptionRequested,void 0,c)),this._consignmentRequestSender.updateConsignment(a.id,e,t).then(({body:e})=>{i.next(o(ot.UpdateShippingOptionSucceeded,e,c)),i.complete()}).catch(e=>{i.error(s(ot.UpdateShippingOptionFailed,e,c))})})}_createOrUpdateConsignment(e,t){return n=>{const i=n.getState().checkout.getCheckout();if(!i||!i.id)throw new Zi($i.MissingCheckout);return this._isUpdateConsignmentRequest(e)?this.updateConsignment(e,t)(n):this.createConsignments([e],t)(n)}}_getUpdateAddressRequestBody(e,t){const n=t.getState().cart.getCart();if(!n)throw new Zi($i.MissingCart);const{physicalItems:i,customItems:r=[]}=n.lineItems;return{address:e,lineItems:[...i,...r].map(e=>({itemId:e.id,quantity:e.quantity}))}}_removeLineItems(e,t,n){if(!n)throw new Zi($i.MissingCart);return this._hydrateLineItems(t.lineItemIds,n).map(t=>{const n=l(e,e=>e.itemId===t.itemId);return Object.assign(Object.assign({},t),{quantity:n?t.quantity-n.quantity:t.quantity})}).filter(e=>e.quantity>0)}_addLineItems(e,t,n){if(!t)return e;if(!n)throw new Zi($i.MissingCart);return e.concat(this._hydrateLineItems(t.lineItemIds,n)).filter(e=>e.quantity>0)}_hydrateLineItems(e,t){return e.map(e=>{const n=l(t.lineItems.physicalItems,t=>t.id===e);return{itemId:e,quantity:n?n.quantity:0}})}_isUpdateConsignmentRequest(e){return!!e.id}_consignmentHasAddress(e){return"object"==typeof e&&"address"in e}}const Xu=["consignments.availableShippingOptions","cart.lineItems.physicalItems.options","cart.lineItems.physicalItems.stockPosition","cart.lineItems.digitalItems.options","cart.lineItems.digitalItems.stockPosition","customer","promotions.banners"];class el{constructor(e){this._requestSender=e}createConsignments(e,t,{timeout:n,params:{include:i}={}}={}){const r=`/api/storefront/checkouts/${e}/consignments`,o=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(r,{body:t,params:{include:wc(Xu,i)},headers:o,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}updateConsignment(e,t,{timeout:n,params:{include:i}={}}={}){const{id:r}=t,o=function(e,t){var n={};for(var i in e)Object.prototype.hasOwnProperty.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(e);r<i.length;r++)t.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(e,i[r])&&(n[i[r]]=e[i[r]])}return n}(t,["id"]),a=`/api/storefront/checkouts/${e}/consignments/${r}`,s=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.put(a,{body:o,params:{include:wc(Xu,i)},headers:s,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}deleteConsignment(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/consignments/${t}`,r=Object.assign({Accept:dc.JsonV1},uc),o=Ic(Xu);return this._requestSender.delete(i,{params:{include:o},headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}}class tl{constructor(e,t){this._shippingCountryRequestSender=e,this._store=t}loadCountries(e){const{checkout:t}=this._store.getState(),n=t.getCheckout(),i=n?n.channelId:null;return j.create(t=>{t.next(o(gi.LoadShippingCountriesRequested)),this._shippingCountryRequestSender.loadCountries(i,e).then(e=>{t.next(o(gi.LoadShippingCountriesSucceeded,e.body.data)),t.complete()}).catch(e=>{t.error(s(gi.LoadShippingCountriesFailed,e))})})}}class nl{constructor(e,t){this._requestSender=e,this._config=t}loadCountries(e,{timeout:t}={}){const n="/internalapi/v1/shipping/countries"+(e?`?channel_id=${e}`:""),i=Object.assign({"Accept-Language":this._config.locale},uc);return this._requestSender.get(n,{headers:i,timeout:t})}}var il=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class rl{constructor(e,t){this._googleRecaptcha=e,this._requestSender=t}initialize(e){return t=>V(Z(o(qi.InitializeRequested,void 0)),H(()=>il(this,void 0,void 0,function*(){const n=e?e.containerId:"spamProtectionContainer";if(document.getElementById(n)&&this._googleRecaptcha.reset(n),!e&&!document.getElementById(n)){const e=document.createElement("div");e.setAttribute("id",n),document.body.appendChild(e)}const i=t.getState().config.getStoreConfigOrThrow().checkoutSettings.googleRecaptchaSitekey;return yield this._googleRecaptcha.load(n,i),o(qi.InitializeSucceeded)}))).pipe(Q(e=>gc(qi.InitializeFailed,e)))}verifyCheckoutSpamProtection(){return e=>H(()=>{const t=e.getState().checkout.getCheckout();if(!t)throw new Zi($i.MissingCheckout);return V(Z(o(qi.VerifyCheckoutRequested)),Y(this.execute()(e)).pipe(re(e=>Lc(e)&&e.payload?Y(this._requestSender.validate(t.id,e.payload.token)).pipe(re(({body:t})=>V(Z(e),Z(o(qi.VerifyCheckoutSucceeded,t))))):Z(e)))).pipe(Q(e=>gc(qi.VerifyCheckoutFailed,e)))})}execute(){return e=>V(Z(o(qi.ExecuteRequested)),this.initialize()(e),this._googleRecaptcha.execute().pipe(oe(1)).pipe(re(e=>il(this,[e],void 0,function*({error:e,token:t}){if(e instanceof Kc)throw e;if(e||!t)throw new iu;return o(qi.ExecuteSucceeded,{token:t})})))).pipe(Q(e=>gc(qi.ExecuteFailed,e)))}}class ol{constructor(e){this._requestSender=e}validate(e,t,{timeout:n}={}){const i=`/api/storefront/checkouts/${e}/spam-protection`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(i,{body:{token:t},headers:r,timeout:n}).catch(e=>{if("empty_cart"===e.body.type)throw new fc;throw e})}}class al{constructor(e){this._storeCreditRequestSender=e}applyStoreCredit(e,t){return n=>V(Z(o(Di.ApplyStoreCreditRequested)),H(()=>{return i=this,r=void 0,s=function*(){var i;const r=n.getState().checkout.getCheckout();if(!r)throw new Zi($i.MissingCheckout);const{id:a}=r,s=null!==(i=null==t?void 0:t.version)&&void 0!==i?i:r.version,{body:d}=yield e?this._storeCreditRequestSender.applyStoreCredit(a,Object.assign(Object.assign({},t),{version:s})):this._storeCreditRequestSender.removeStoreCredit(a,Object.assign(Object.assign({},t),{version:s}));return o(Di.ApplyStoreCreditSucceeded,d)},new((a=void 0)||(a=Promise))(function(e,t){function n(e){try{d(s.next(e))}catch(e){t(e)}}function o(e){try{d(s.throw(e))}catch(e){t(e)}}function d(t){var i;t.done?e(t.value):(i=t.value,i instanceof a?i:new a(function(e){e(i)})).then(n,o)}d((s=s.apply(i,r||[])).next())});var i,r,a,s})).pipe(Q(e=>gc(Di.ApplyStoreCreditFailed,e)))}}class sl{constructor(e){this._requestSender=e}applyStoreCredit(e,{timeout:t,version:n}={}){const i=`/api/storefront/checkouts/${e}/store-credit`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post(i,{headers:r,timeout:t,params:{include:Ic(bc)},body:{version:n}})}removeStoreCredit(e,{timeout:t,version:n}={}){const i=`/api/storefront/checkouts/${e}/store-credit`,r=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.delete(i,{headers:r,timeout:t,params:{include:Ic(bc)},body:{version:n}})}}class dl extends Pe{constructor(e){super(e),this.name="UpdateSubscriptionsError",this.type="update_subscriptions"}}class cl{constructor(e){this._subscriptionsRequestSender=e}updateSubscriptions(e,t){return V(Z(o(We.UpdateSubscriptionsRequested)),H(()=>{return n=this,i=void 0,a=function*(){const{body:n}=yield this._subscriptionsRequestSender.updateSubscriptions(e,t);return o(We.UpdateSubscriptionsSucceeded,n)},new((r=void 0)||(r=Promise))(function(e,t){function o(e){try{d(a.next(e))}catch(e){t(e)}}function s(e){try{d(a.throw(e))}catch(e){t(e)}}function d(t){var n;t.done?e(t.value):(n=t.value,n instanceof r?n:new r(function(e){e(n)})).then(o,s)}d((a=a.apply(n,i||[])).next())});var n,i,r,a})).pipe(Q(e=>gc(We.UpdateSubscriptionsFailed,new dl(e))))}}class ul{constructor(e){this._requestSender=e}updateSubscriptions(e,{timeout:t}={}){const n=Object.assign({Accept:dc.JsonV1},uc);return this._requestSender.post("/api/storefront/subscriptions",{body:e,headers:n,timeout:t})}}const ll=A(e=>Array.isArray(e)?e.map(e=>hl(e)):et(e)?Object.keys(e).reduce((t,n)=>Object.assign(Object.assign({},t),{[n]:hl(e[n])}),{}):e);ll.cache=new WeakMap;const hl=e=>"object"==typeof e&&null!==e?ll(e):e;function pl(e){return(...t)=>hl(e(...t))}function gl({billingAddress:{getBillingAddress:e,getBillingAddressOrThrow:t},cart:{getCart:n,getCartOrThrow:i,getLocale:r},checkout:{getCheckout:o,getCheckoutOrThrow:a,getOutstandingBalance:s},config:{getContextConfig:d,getHost:c,getLocale:u,getStoreConfig:l,getStoreConfigOrThrow:h,getConfig:p},consignments:{getConsignments:g,getConsignmentsOrThrow:m},countries:{getCountries:y},customer:{getCustomer:f,getCustomerOrThrow:_},instruments:{getCardInstrument:S,getCardInstrumentOrThrow:v,getInstruments:C,getInstrumentsMeta:I},order:{getOrder:w,getOrderOrThrow:b,getOrderMeta:E},payment:{getPaymentToken:P,getPaymentTokenOrThrow:O,getPaymentId:A,getPaymentIdOrThrow:T,getPaymentStatus:k,getPaymentStatusOrThrow:R,getPaymentRedirectUrl:D,getPaymentRedirectUrlOrThrow:M,isPaymentDataRequired:N},paymentMethods:{getPaymentMethod:L,getPaymentMethodOrThrow:z,getPaymentMethodsMeta:U},paymentProviderCustomer:{getPaymentProviderCustomer:F,getPaymentProviderCustomerOrThrow:B},paymentStrategies:{isInitialized:x},shippingAddress:{getShippingAddress:q,getShippingAddressOrThrow:j,getShippingAddresses:G,getShippingAddressesOrThrow:V},shippingCountries:{getShippingCountries:H}}){return{getHost:pl(c),getLocale:pl(u),getCartLocale:pl(r),getBillingAddress:pl(e),getBillingAddressOrThrow:pl(t),getCart:pl(n),getCartOrThrow:pl(i),getCheckout:pl(o),getCheckoutOrThrow:pl(a),getCountries:pl(y),getStoreConfig:pl(l),getStoreConfigOrThrow:pl(h),getConfig:pl(p),getConsignments:pl(g),getConsignmentsOrThrow:pl(m),getContextConfig:pl(d),getCustomer:pl(f),getCustomerOrThrow:pl(_),getCardInstrument:pl(S),getInstruments:pl(C),getCardInstrumentOrThrow:pl(v),getOrder:pl(w),getOrderOrThrow:pl(b),getOrderMeta:pl(E),getInstrumentsMeta:pl(I),getPaymentToken:P,getPaymentTokenOrThrow:O,getPaymentId:A,getPaymentIdOrThrow:T,getPaymentStatus:k,getPaymentStatusOrThrow:R,getPaymentRedirectUrl:D,getPaymentRedirectUrlOrThrow:M,getPaymentMethod:pl(L),getPaymentMethodOrThrow:pl(z),getPaymentMethodsMeta:pl(U),getPaymentProviderCustomer:pl(F),getPaymentProviderCustomerOrThrow:pl(B),getShippingAddress:pl(q),getShippingAddressOrThrow:pl(j),getShippingAddresses:pl(G),getShippingAddressesOrThrow:pl(V),getShippingCountries:pl(H),getOutstandingBalance:pl(s),isPaymentDataRequired:N,isPaymentMethodInitialized:x}}var ml,yl=function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};class fl{constructor(e,t,n,i,r,o,a,s,d,c,u,l,h,p,g,m,y,f,_,S){this._store=e,this._storeProjectionFactory=t,this._checkoutActionCreator=n,this._checkoutValidator=i,this._hostedFormFactory=r,this._orderActionCreator=o,this._billingAddressActionCreator=a,this._consignmentActionCreator=s,this._paymentMethodActionCreator=d,this._paymentActionCreator=c,this._paymentHumanVerificationHandler=u,this._customerActionCreator=l,this._cartRequestSender=h,this._storeCreditActionCreator=p,this._couponActionCreator=g,this._spamProtectionActionCreator=m,this._paymentProviderCustomerActionCreator=y,this._shippingCountryActionCreator=f,this._remoteCheckoutActionCreator=_,this._paymentStrategyWidgetActionCreator=S,this._storeProjection=this._storeProjectionFactory.create(this._store)}createHostedForm(e,t){const n=this._storeProjection.getState().getCheckoutOrThrow().id;return this._hostedFormFactory.create(e,t,n)}subscribe(e,...t){return this._storeProjection.subscribe(e,...t)}getState(){return this._storeProjection.getState()}initializeOffsitePayment(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentActionCreator.initializeOffsitePayment(e)),this._storeProjection.getState()})}loadCheckout(e){return yl(this,void 0,void 0,function*(){return e?yield this._store.dispatch(this._checkoutActionCreator.loadCheckout(e)):yield this._store.dispatch(this._checkoutActionCreator.loadCurrentCheckout()),this._storeProjection.getState()})}loadDefaultCheckout(){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()),this._storeProjection.getState()})}loadPaymentMethod(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethod(e,t)),this._storeProjection.getState()})}loadPaymentMethods(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentMethodActionCreator.loadPaymentMethods(e)),this._storeProjection.getState()})}submitOrder(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._orderActionCreator.submitOrder(e,t)),this._storeProjection.getState()})}submitPayment(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentActionCreator.submitPayment(e)),this._storeProjection.getState()})}finalizeOrder(e){return yl(this,void 0,void 0,function*(){const{order:{getOrderOrThrow:t}}=this._store.getState();return yield this._store.dispatch(this._orderActionCreator.finalizeOrder(t().orderId,e)),this._storeProjection.getState()})}updateBillingAddress(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._billingAddressActionCreator.updateAddress(e)),this._storeProjection.getState()})}updateShippingAddress(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.updateAddress(e)),this._storeProjection.getState()})}selectShippingOption(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.selectShippingOption(e,t)),this._storeProjection.getState()})}signInCustomer(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._customerActionCreator.signInCustomer(e,t)),this._storeProjection.getState()})}signOutCustomer(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._customerActionCreator.signOutCustomer(e)),this._storeProjection.getState()})}createBuyNowCart(e,t){return yl(this,void 0,void 0,function*(){const{body:n}=yield this._cartRequestSender.createBuyNowCart(e,t);return n})}applyStoreCredit(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._storeCreditActionCreator.applyStoreCredit(e,t)),this._storeProjection.getState()})}applyCoupon(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._couponActionCreator.applyCoupon(e,t)),this._storeProjection.getState()})}removeCoupon(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._couponActionCreator.removeCoupon(e,t)),this._storeProjection.getState()})}verifyCheckoutSpamProtection(){return yl(this,void 0,void 0,function*(){const{checkout:e}=this._store.getState(),{shouldExecuteSpamCheck:t}=e.getCheckoutOrThrow();return t&&(yield this._store.dispatch(this._spamProtectionActionCreator.verifyCheckoutSpamProtection())),this._storeProjection.getState()})}loadCurrentOrder(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._orderActionCreator.loadCurrentOrder(e)),this._storeProjection.getState()})}updatePaymentProviderCustomer(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentProviderCustomerActionCreator.updatePaymentProviderCustomer(e)),this._storeProjection.getState()})}loadShippingCountries(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._shippingCountryActionCreator.loadCountries(e)),this._storeProjection.getState()})}deleteConsignment(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._consignmentActionCreator.deleteConsignment(e,t)),this._storeProjection.getState()})}initializePayment(e,t,n){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.initializePayment(e,t,n)),this._storeProjection.getState()})}forgetCheckout(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.forgetCheckout(e,t)),this._storeProjection.getState()})}remoteCheckoutSignOut(e,t){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._remoteCheckoutActionCreator.signOut(e,t)),this._storeProjection.getState()})}validateCheckout(e,t){return yl(this,void 0,void 0,function*(){yield this._checkoutValidator.validate(e,t)})}handlePaymentHumanVerification(e,t){return yl(this,void 0,void 0,function*(){return"string"==typeof e?this._paymentHumanVerificationHandler.handle(e,null!=t?t:""):this._paymentHumanVerificationHandler.handle(e)})}widgetInteraction(e){return yl(this,void 0,void 0,function*(){return yield this._store.dispatch(this._paymentStrategyWidgetActionCreator.widgetInteraction(e),{queueId:"widgetInteraction"}),this._storeProjection.getState()})}}!function(e){e.Synchronize="SYNCHRONIZE"}(ml||(ml={}));class _l{constructor(e){this._transformSelectors=e}create(e){return function(e,t){const n=a((e,t)=>t.type===ml.Synchronize?t.payload:e,e.getState(),{stateTransformer:t});return e.subscribe(e=>{n.dispatch(o(ml.Synchronize,e))},{initial:!1}),n}(e,this._transformSelectors)}}const Sl=e=>{const t=B(e);return document.getElementById(t)?Sl(e):t};function vl(e){return Object.prototype.hasOwnProperty.call(e,"cacheKey")}class Cl{constructor(e){this._lastId=0,this._map={maps:[]},this._usedMaps=[],this._options=Object.assign({maxSize:0,isEqual:fe,onExpire:T},e)}getKey(...e){const t=this._resolveMap(...e),{index:n,parentMap:i}=t;let{map:r}=t;return r&&r.cacheKey?r.usedCount++:r=this._generateMap(i,e.slice(n)),this._removeLeastUsedMap(r),r.cacheKey}getUsedCount(...e){const{map:t}=this._resolveMap(...e);return t?t.usedCount:0}_resolveMap(...e){let t=0,n=this._map;for(;n.maps.length;){let i=!1;for(let r=0;r<n.maps.length;r++){const o=n.maps[r];if(this._options.isEqual(o.value,e[t])){if(n.maps.unshift(...n.maps.splice(r,1)),(0===e.length||t===e.length-1)&&vl(o))return{index:t,map:o,parentMap:n};i=!0,n=o,t++;break}}if(!i)break}return{index:t,parentMap:n}}_generateMap(e,t){let n,i=0,r=e;do{n={maps:[],parentMap:r,usedCount:1,value:t[i]},r.maps.unshift(n),r=n,i++}while(i<t.length);const o=n;return o.cacheKey=""+ ++this._lastId,o}_removeLeastUsedMap(e){if(!this._options.maxSize)return;const t=this._usedMaps.indexOf(e);if(this._usedMaps.splice(-1===t?0:t,-1===t?0:1,e),this._usedMaps.length<=this._options.maxSize)return;const n=this._usedMaps.pop();n&&(this._removeMap(n),this._options.onExpire(n.cacheKey))}_removeMap(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))}}function Il(e){const t=class extends e{};return Object.getOwnPropertyNames(e.prototype).forEach(n=>{const i=Object.getOwnPropertyDescriptor(e.prototype,n);i&&"constructor"!==n&&Object.defineProperty(t.prototype,n,function(e,t,n){if("function"!=typeof n.value)return n;let i=new Cl,r=n.value,o=ae(r);return ba(e,t,{get(){const e=(...e)=>{const t=o.call(this,...e);if(1===i.getUsedCount(...e))return t;const n=r.call(this,...e);return Ue(n,t,{keyFilter:e=>!function(e){return 0===`${e}`.indexOf("$$")||0===`${e}`.indexOf("_")}(e)})?t:(o.cache.set(i.getKey(...e),n),n)};return Object.defineProperty(this,t,Object.assign(Object.assign({},n),{value:e})),e},set(e){i=new Cl,r=e,o=ae(r)}})}(e.prototype,n,i))}),t}let wl=class{constructor(e){this._checkoutButton=e.checkoutButton}getInitializeButtonError(e){return this._checkoutButton.getInitializeError(e)}getDeinitializeButtonError(e){return this._checkoutButton.getDeinitializeError(e)}};wl=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([Il],wl);const bl=wl;let El=class{constructor(e){this._checkoutButton=e.checkoutButton}isInitializingButton(e){return this._checkoutButton.isInitializing(e)}isDeinitializingButton(e){return this._checkoutButton.isDeinitializing(e)}};El=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([Il],El);const Pl=El;function Ol(e){return{errors:new bl(e),statuses:new Pl(e)}}let Al=class{constructor(e,t){this._store=e,this._buttonStrategyActionCreator=t,this._state=Ol(this._store.getState()),this._store.subscribe(e=>{this._state=Ol(e)})}getState(){return this._state}subscribe(e,...t){return this._store.subscribe(()=>e(this.getState()),e=>e.checkoutButton.getState(),...t.map(e=>t=>e(Ol(t))))}initializeButton(e){const t=(n=e.containerId,/^\w[\w\-\:\.]*$/.test(n)?[e.containerId]:function(e,t){const n=document.querySelectorAll(e);if(!n.length)throw new Gc(`Unable to find any element with the specified selector: ${e}`);return Array.prototype.slice.call(n).map(e=>(e.id||(e.id=Sl(t)),e.id))}(e.containerId,`${e.methodId}-container`));var n;return Promise.all(t.map(t=>{const n=this._buttonStrategyActionCreator.initialize(Object.assign(Object.assign({},e),{containerId:t})),i=`checkoutButtonStrategy:${e.methodId}:${t}`;return this._store.dispatch(n,{queueId:i})})).then(()=>this.getState())}deinitializeButton(e){const t=this._buttonStrategyActionCreator.deinitialize(e),n=`checkoutButtonStrategy:${e.methodId}`;return this._store.dispatch(t,{queueId:n}).then(()=>this.getState())}};Al=function(e,t,n,i){var r,o=arguments.length,a=o<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,i);else for(var s=e.length-1;s>=0;s--)(r=e[s])&&(a=(o<3?r(a):o>3?r(t,n,a):r(t,n))||a);return o>3&&a&&Object.defineProperty(t,n,a),a}([ba],Al);const Tl=Al;class kl{constructor(e,t,n){this._registry=e,this._registryV2=t,this._paymentMethodActionCreator=n}initialize(e){return t=>{const n={methodId:e.methodId,containerId:e.containerId};if(t.getState().checkoutButton.isInitialized(e.methodId,e.containerId))return W();const i=e.currencyCode?{params:{currencyCode:e.currencyCode}}:{},r=Object.assign(Object.assign({},i),{timeout:e.timeout,useCache:!0});return V(Z(o(lt.InitializeButtonRequested,void 0,n)),this._paymentMethodActionCreator.loadPaymentMethod(e.methodId,r)(t),H(()=>this._getStrategy(e.methodId).initialize(e).then(()=>o(lt.InitializeButtonSucceeded,void 0,n)))).pipe(Q(e=>gc(lt.InitializeButtonFailed,e,n)))}}deinitialize(e){return t=>{const n={methodId:e.methodId};return t.getState().checkoutButton.isInitialized(e.methodId)?V(Z(o(lt.DeinitializeButtonRequested,void 0,n)),H(()=>this._getStrategy(e.methodId).deinitialize().then(()=>o(lt.DeinitializeButtonSucceeded,void 0,n)))).pipe(Q(e=>gc(lt.DeinitializeButtonFailed,e,n))):W()}}_getStrategy(e){let t;try{t=this._registryV2.get({id:e})}catch(n){t=this._registry.get(e)}return t}}class Rl{constructor(e){var t,n,i;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!==(i=null==e?void 0:e.tokenResolver)&&void 0!==i?i:e=>e}get(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)}}getFactory(e,t){const n=this._tokenResolver(e,Object.keys(this._factories),t);return n?this._factories[n]:void 0}register(e,t){if(this._hasFactory(e))throw new Gc(`'${e}' is already registered.`);this._factories[e]=t}_hasFactory(e){return!!this._factories[e]}_hasInstance(e){return!!this._instances[e]}_getInstance(e,t){if(!this._hasInstance(t)){const n=this.getFactory(e);if(!n)throw new Gc(`'${e}' is not registered.`);this._instances[t]=n()}return this._instances[t]}}class Dl extends be{constructor(e){super(e||"Unable to proceed because the client library of a payment method is not loaded or ready to be used."),this.name="PaymentMethodClientUnavailableError",this.type="payment_method_client_unavailable"}}var Ml,Nl,Ll,zl,Ul;class Fl{constructor(e){this._scriptLoader=e,this._window=window}loadPaypal(){return e=this,t=arguments,i=function*(e=""){const t="//www.paypalobjects.com/api/checkout.min.js",n={async:!0,attributes:{"data-merchant-id":e}};if(e?yield this._scriptLoader.loadScript(t,n):yield this._scriptLoader.loadScript(t),!this._window.paypal)throw new Dl;return this._window.paypal},new((n=void 0)||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())});var e,t,n,i}}!function(e){e.HORIZONTAL="horizontal",e.VERTICAL="vertical"}(Ml||(Ml={})),function(e){e.SMALL="small",e.MEDIUM="medium",e.LARGE="large",e.RESPONSIVE="responsive"}(Nl||(Nl={})),function(e){e.GOLD="gold",e.BLUE="blue",e.SIlVER="silver",e.BLACK="black",e.WHITE="white"}(Ll||(Ll={})),function(e){e.CHECKOUT="checkout",e.PAY="pay",e.BUYNOW="buynow",e.PAYPAL="paypal",e.CREDIT="credit"}(zl||(zl={})),function(e){e.PILL="pill",e.RECT="rect"}(Ul||(Ul={}));class Bl{constructor(e,t,n,i,r=""){this._store=e,this._checkoutActionCreator=t,this._paypalScriptLoader=n,this._formPoster=i,this._host=r}initialize(e){const t=e.paypal,n=this._store.getState(),i=this._paymentMethod=n.paymentMethods.getPaymentMethod(e.methodId);if(!t)throw new Gc;if(!i)throw new Zi($i.MissingPaymentMethod);return this._paypalScriptLoader.loadPaypal(i.config.merchantId).then(n=>{var r,o;if(!i||!i.config.merchantId)throw new Zi($i.MissingPaymentMethod);const a=i.config.merchantId,s=i.config.testMode?"sandbox":"production",d={[s]:t.clientId},c=n.FUNDING.CREDIT||"credit",u=t.allowCredit?[c]:[],l=t.allowCredit?[]:[c];return n.Button.render({env:s,client:d,commit:t.shouldProcessPayment,funding:{allowed:u,disallowed:l},style:Object.assign(Object.assign({shape:Ul.RECT},D(t.style,"layout","color","label","shape","tagline","fundingicons")),{size:"paypalexpress"===i.id&&"small"===(null===(r=t.style)||void 0===r?void 0:r.size)?Nl.RESPONSIVE:null===(o=t.style)||void 0===o?void 0:o.size}),payment:(e,n)=>this._setupPayment(a,n,t.onPaymentError),onAuthorize:(e,n)=>this._tokenizePayment(e,n,t.shouldProcessPayment,t.onAuthorizeError)},e.containerId)})}deinitialize(){return this._paymentMethod=void 0,Promise.resolve()}_setupPayment(e,t,n){if(!t)throw new nu(Jc.CheckoutButtonNotInitialized);return this._store.dispatch(this._checkoutActionCreator.loadDefaultCheckout()).then(n=>{const i=n.cart.getCart(),r=i?i.id:"";return t.request.post(`${this._host}/api/storefront/payment/paypalexpress`,{merchantId:e,cartId:r},{headers:Object.assign({"X-API-INTERNAL":cc},uc)})}).then(e=>e.id).catch(e=>{throw n&&n(e),e})}_tokenizePayment(e,t,n,i){if(!this._paymentMethod)throw new nu(Jc.CheckoutButtonNotInitialized);if(!t)throw new nu(Jc.CheckoutButtonNotInitialized);if(!e.paymentID||!e.payerID)throw new Zi($i.MissingPayment);const r=this._paymentMethod.id;return t.payment.get(e.paymentID).then(t=>{this._formPoster.postForm("/checkout.php",{payment_type:"paypal",provider:r,action:n?"process_payment":"set_external_checkout",paymentId:e.paymentID,payerId:e.payerID,payerInfo:JSON.stringify(t.payer.payer_info)})})}}function xl(e){return e&&"resolveIds"in e}function ql(){try{return"production"}catch(e){return"development"}}class jl{constructor(e){this._console=e}log(...e){this._logToConsole("log",...e)}info(...e){this._logToConsole("info",...e)}warn(...e){this._logToConsole("warn",...e)}error(...e){this._logToConsole("error",...e)}debug(...e){this._logToConsole("debug",...e)}_logToConsole(e,...t){this._console&&this._console[e]&&this._console[e].call(this._console,...t)}}class Gl{log(){}info(){}warn(){}error(){}debug(){}}const Vl=function(e=!0){return e?new jl(console):new Gl}("test"!==ql());class Hl{constructor(e=!1){this._useFallback=e,this._registry=new Rl({tokenResolver:this._resolveToken.bind(this),defaultToken:this._encodeToken({default:!0}),useFallback:this._useFallback})}get(e){return this._registry.get(this._encodeToken(e))}getFactory(e,t){try{return this._registry.getFactory(this._encodeToken(e),t)}catch(e){return}}getUseFallback(){return this._useFallback}register(e,t){this._registry.register(this._encodeToken(e),t)}_encodeToken(e){return btoa(JSON.stringify(e))}_decodeToken(e){return JSON.parse(atob(e))}_resolveToken(e,t,n){var i;const r=this._decodeToken(e),o=[];t.forEach(e=>{const t=this._decodeToken(e),n={token:e,matches:0,default:!1,totalKeys:Object.keys(t).length};for(const[e,i]of Object.entries(t)){if(e in r&&r[e]!==i){n.matches=0;break}e in r&&r[e]===i&&n.matches++,"default"===e&&!0===i&&(n.default=!0)}o.push(n)});const a=o.sort((e,t)=>t.matches-e.matches).filter(e=>e.matches>0);a.length>1&&a[0].matches===a[1].matches&&"development"===ql()&&Vl.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.");const s=Object.keys(r).length;if(n){const e=a.find(e=>e.matches===s&&e.matches===e.totalKeys);if(!e)throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)} with exact match.`);return e.token}const d=a[0];if(d&&d.token)return d.token;if(this._useFallback){const e=null===(i=o.find(e=>e.default))||void 0===i?void 0:i.token;if(e)return e}throw new Error(`Unable to resolve to a registered token with the provided token for ${JSON.stringify(r)}.`)}}function Wl(t){const{host:i}=null!=t?t:{},r=or({config:{meta:{host:null==t?void 0:t.host,locale:null==t?void 0:t.locale},errors:{},statuses:{}}}),o=e({host:i}),a=n({host:i}),s=function(e,t){const n=new Hl;for(const[,i]of Object.entries(t))if(xl(i))for(const t of i.resolveIds)n.register(t,()=>i(e));return n}(function(t,n){const{config:{getHost:i,getLocale:r}}=t.getState();n||(n=e({host:i()}));const o=new _l(gl),a=new Cc(new Pc(n),new Rc(new Dc(n)),new Fc(new Bc(n))),s=new Tc(new Pc(n)),d=new fu(t),c=new Su(new Eu(n),new Tc(new Pc(n))),u=new yc(new Sc(n),new cl(new ul(n))),l=new Qu(new el(n),new Pc(n)),h=new ac(new lc(n),new pc(n)),p=new Pu(new Ou(function(e){const t=ge();return e.subscribe(e=>{const n=e.config.getStoreConfig();n&&t.setHost(n.paymentSettings.bigpayBaseUrl)},e=>e.config.getStoreConfig()),t}(t)),c,new Yu,new tu(su(ue()))),g=new tu(su(ue())),m=new zc(new Uc(n),a,new rl(su(ue()),new ol(n))),y=new al(new sl(n)),f=new Mc(new Nc(n)),_=su(ue()),S=new ol(n),v=new rl(_,S),C=new vc(n),I=new $u,w=new tl(new nl(n,{locale:r()}),t),b=new Zu(new Ju(n),a),E=new Ku;return new fl(t,o,a,s,d,c,u,l,h,p,g,m,C,y,f,v,I,w,b,E)}(r),Se);return new Tl(r,new kl(function(e,t,n,i){const r=new Rl,o=le(),a=new Pc(t),s=new Cc(a,new Rc(new Dc(t)),new Fc(new Bc(t)));return r.register(zu.PAYPALEXPRESS,()=>new Bl(e,s,new Fl(o),n,i)),r}(r,o,a,i),s,new ac(new lc(o),new pc(o))))}export{Wl as createCheckoutButtonInitializer,t as createTimeout};
|
|
2
2
|
//# sourceMappingURL=checkout-button.js.map
|