@bigcommerce/checkout-sdk 1.702.0 → 1.703.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/checkout-button.js +1 -1
- package/dist/checkout-button.umd.js +1 -1
- package/dist/checkout-sdk.js +1 -1
- package/dist/checkout-sdk.umd.js +1 -1
- package/dist/hosted-form-v2-iframe-content.js +1 -1
- package/dist/hosted-form-v2-iframe-content.js.map +1 -1
- package/dist/hosted-form-v2-iframe-content.umd.js +1 -1
- package/dist/hosted-form-v2-iframe-content.umd.js.map +1 -1
- package/dist/hosted-form-v2-iframe-host.js +1 -1
- package/dist/hosted-form-v2-iframe-host.umd.js +1 -1
- package/dist/hosted-form.js +1 -1
- package/dist/hosted-form.js.map +1 -1
- package/dist/hosted-form.umd.js +1 -1
- package/dist/hosted-form.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/hosted-form.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{initializeHostedInput:()=>At,notifyInitializeError:()=>Tt});var n,r=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=function(){return o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)};const i=function(t,e,n){return e&&n?a(0,e,n):function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(t);return Object.getOwnPropertyNames(t.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t.prototype,n);r&&"constructor"!==n&&Object.defineProperty(e.prototype,n,a(t.prototype,n,r))})),e}(t)};function a(t,e,n){if("function"!=typeof n.value)return n;var r=n.value;return{get:function(){var t=r.bind(this);return Object.defineProperty(this,e,o(o({},n),{value:t})),t},set:function(t){r=t}}}var s=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const c=function(t){function e(e){var n,r,o=this.constructor,i=t.call(this,e||"An unexpected error has occurred.")||this;return i.name="StandardError",i.type="standard",n=i,r=o.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,o):i.stack=new Error(i.message).stack,i}return s(e,t),e}(Error);var u=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const p=function(t){function e(e){var n=t.call(this,e||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return u(e,t),e}(c);function d(t){if(!/^(https?:)?\/\//.test(t))throw new p("The provided URL must be absolute.");var e=document.createElement("a");e.href=t;var n=e.port&&-1!==t.indexOf("".concat(e.hostname,":").concat(e.port))?e.port:"";return{hash:e.hash,hostname:e.hostname,href:e.href,origin:"".concat(e.protocol,"//").concat(e.hostname).concat(n?":".concat(n):""),pathname:e.pathname,port:n,protocol:e.protocol,search:e.search}}function l(t){return d(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,"www.".concat(t.hostname)))}function f(t,e){return t.type===e}const h=function(){function t(t){this._sourceOrigins=[d(t).origin,l(d(t)).origin],this._isListening=!1,this._listeners={}}return t.prototype.listen=function(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))},t.prototype.stopListen=function(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))},t.prototype.addListener=function(t,e){var n=this._listeners[t];n||(this._listeners[t]=n=[]),-1===n.indexOf(e)&&n.push(e)},t.prototype.removeListener=function(t,e){var n=this._listeners[t];if(n){var r=n.indexOf(e);r>=0&&n.splice(r,1)}},t.prototype.trigger=function(t,e){var n=this._listeners[t.type];n&&n.forEach((function(n){return e?n(t,e):n(t)}))},t.prototype._handleMessage=function(t){if(-1!==this._sourceOrigins.indexOf(t.origin)&&f(t.data,t.data.type)){var e=t.data,n=e.context,r=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(e,["context"]);this.trigger(r,n)}},function(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);i>3&&a&&Object.defineProperty(e,n,a)}([i],t.prototype,"_handleMessage",null),t}(),y=function(){function t(){}return t.prototype.setNonce=function(t){this._nonce=t},t.prototype.getNonce=function(){return this._nonce},t}();var m;function g(){return m=m||new y}const _=require("@bigcommerce/bigpay-client"),v=require("@bigcommerce/request-sender"),b=require("rxjs"),C=require("rxjs/operators");var w=function(){return w=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},w.apply(this,arguments)};const E=function(){function t(t,e,n){this._targetWindow=e,this._context=n,this._targetOrigin="*"===t?"*":d(t).origin}return t.prototype.post=function(t,e){var n=this,r=this._targetWindow;if(window!==r){if(!r)throw new Error("Unable to post message because target window is not set.");var o=e&&(0,b.fromEvent)(window,"message").pipe((0,C.filter)((function(t){return t.origin===n._targetOrigin&&f(t.data,t.data.type)&&-1!==[e.successType,e.errorType].indexOf(t.data.type)})),(0,C.map)((function(t){if(e.errorType===t.data.type)throw t.data;return t.data})),(0,C.take)(1)).toPromise();return r.postMessage(w(w({},t),{context:this._context}),this._targetOrigin),o}},t.prototype.setTarget=function(t){this._targetWindow=t},t.prototype.setContext=function(t){this._context=t},t}(),O=function(){function t(t){this._client=t}return t.prototype.submitPayment=function(t){var e=this;return new Promise((function(n,r){e._client.submitPayment(t,(function(t,o){t?r(e._transformResponse(t)):n(e._transformResponse(o))}))}))},t.prototype.initializeOffsitePayment=function(t,e){var n=this;return new Promise((function(){n._client.initializeOffsitePayment(t,null,e)}))},t.prototype._transformResponse=function(t){return{headers:t.headers,body:t.data,status:t.status,statusText:t.statusText}},t}(),P=require("lodash");function A(t,e){var n;return function(t){return void 0!==t.id}(t)?n=t.id:e&&e.length&&(n=e[0].id),{id:n,firstName:t.firstName,lastName:t.lastName,company:t.company,addressLine1:t.address1,addressLine2:t.address2,city:t.city,province:t.stateOrProvince,provinceCode:t.stateOrProvinceCode,postCode:t.postalCode,country:t.country,countryCode:t.countryCode,phone:t.phone,customFields:t.customFields}}const I=function(){function t(t){this._decimalPlaces=t}return t.prototype.toInteger=function(t){return Math.round(t*Math.pow(10,this._decimalPlaces))},t}();var T=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function S(t){return{code:t.code,discount:t.displayName,discountType:T.indexOf(t.couponType)}}function x(t){return{code:t.code,discountedAmount:t.used,remainingBalance:t.remaining,giftCertificate:{balance:t.balance,code:t.code,purchaseDate:t.purchaseDate}}}var N,M=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function D(t,e,n){return void 0===n&&(n="id"),Object.keys(t).reduce((function(r,o){return M(M([],r,!0),t[o].map((function(t){return"giftCertificates"===o?function(t,e){var n=new I(e);return{id:t.id,imageUrl:"",name:t.name,amount:t.amount,amountAfterDiscount:t.amount,discount:0,integerAmount:n.toInteger(t.amount),integerAmountAfterDiscount:n.toInteger(t.amount),integerUnitPrice:n.toInteger(t.amount),integerUnitPriceAfterDiscount:n.toInteger(t.amount),integerDiscount:0,quantity:1,sender:t.sender,recipient:t.recipient,type:"ItemGiftCertificateEntity",attributes:[],variantId:null}}(t,e):function(t,e,n,r){void 0===r&&(r="id");var o=new I(n);return{id:t[r],imageUrl:t.imageUrl,amount:t.extendedListPrice,amountAfterDiscount:t.extendedSalePrice,discount:t.discountAmount,integerAmount:o.toInteger(t.extendedListPrice),integerAmountAfterDiscount:o.toInteger(t.extendedSalePrice),integerDiscount:o.toInteger(t.discountAmount),integerUnitPrice:o.toInteger(t.listPrice),integerUnitPriceAfterDiscount:o.toInteger(t.salePrice),downloadsPageUrl:t.downloadPageUrl,name:t.name,quantity:t.quantity,brand:t.brand,sku:t.sku,categoryNames:t.categoryNames,variantId:t.variantId,productId:t.productId,attributes:(t.options||[]).map((function(t){return{name:t.name,value:t.value}})),addedByPromotion:t.addedByPromotion,type:e}}(t,function(t){switch(t){case"physicalItems":return"ItemPhysicalEntity";case"digitalItems":return"ItemDigitalEntity";case"giftCertificates":return"ItemGiftCertificateEntity";default:return""}}(o),e,n)})),!0)}),[])}function V(t){var e,n,r=t.cart.currency.decimalPlaces,o=new I(r);return{id:t.cart.id,items:D(t.cart.lineItems,r),currency:t.cart.currency.code,coupon:{discountedAmount:(0,P.reduce)(t.cart.coupons,(function(t,e){return t+e.discountedAmount}),0),coupons:t.cart.coupons.map(S)},discount:{amount:t.cart.discountAmount,integerAmount:o.toInteger(t.cart.discountAmount)},discountNotifications:(e=t.promotions,n=[],(e||[]).forEach((function(t){(t.banners||[]).forEach((function(t){n.push({placeholders:[],discountType:null,message:"",messageHtml:t.text})}))})),n),giftCertificate:{totalDiscountedAmount:(0,P.reduce)(t.giftCertificates,(function(t,e){return t+e.used}),0),appliedGiftCertificates:(0,P.keyBy)(t.giftCertificates.map(x),"code")},shipping:{amount:t.shippingCostTotal,integerAmount:o.toInteger(t.shippingCostTotal),amountBeforeDiscount:t.shippingCostBeforeDiscount,integerAmountBeforeDiscount:o.toInteger(t.shippingCostBeforeDiscount),required:(0,P.some)(t.cart.lineItems.physicalItems,(function(t){return t.isShippingRequired}))},subtotal:{amount:t.subtotal,integerAmount:o.toInteger(t.subtotal)},storeCredit:{amount:t.customer?t.customer.storeCredit:0},taxSubtotal:{amount:t.taxTotal,integerAmount:o.toInteger(t.taxTotal)},taxes:t.taxes,taxTotal:{amount:t.taxTotal,integerAmount:o.toInteger(t.taxTotal)},handling:{amount:t.handlingCostTotal,integerAmount:o.toInteger(t.handlingCostTotal)},grandTotal:{amount:t.grandTotal,integerAmount:o.toInteger(t.grandTotal)}}}!function(t){t.APPLEPAY="applepay",t.AMAZON_PAY_V2="amazonpay",t.BRAINTREE_PAYPAL="braintreepaypal",t.BRAINTREE_VENMO="braintreevenmo",t.BRAINTREE_PAYPAL_CREDIT="braintreepaypalcredit",t.GOOGLEPAY_ADYENV2="googlepayadyenv2",t.GOOGLEPAY_ADYENV3="googlepayadyenv3",t.GOOGLEPAY_AUTHORIZENET="googlepayauthorizenet",t.GOOGLEPAY_BNZ="googlepaybnz",t.GOOGLEPAY_BRAINTREE="googlepaybraintree",t.GOOGLEPAY_CHECKOUTCOM="googlepaycheckoutcom",t.GOOGLEPAY_CYBERSOURCEV2="googlepaycybersourcev2",t.GOOGLEPAY_ORBITAL="googlepayorbital",t.GOOGLEPAY_STRIPE="googlepaystripe",t.GOOGLEPAY_STRIPEUPE="googlepaystripeupe",t.GOOGLEPAY_WORLDPAYACCESS="googlepayworldpayaccess",t.MASTERPASS="masterpass",t.PAYPALEXPRESS="paypalexpress"}(N||(N={}));const k=N;var j,L=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t[t.MissingBillingAddress=0]="MissingBillingAddress",t[t.MissingCart=1]="MissingCart",t[t.MissingCheckout=2]="MissingCheckout",t[t.MissingConsignments=3]="MissingConsignments",t[t.MissingCustomer=4]="MissingCustomer",t[t.MissingCheckoutConfig=5]="MissingCheckoutConfig",t[t.MissingOrder=6]="MissingOrder",t[t.MissingOrderConfig=7]="MissingOrderConfig",t[t.MissingOrderId=8]="MissingOrderId",t[t.MissingPayment=9]="MissingPayment",t[t.MissingPaymentId=10]="MissingPaymentId",t[t.MissingPaymentInstrument=11]="MissingPaymentInstrument",t[t.MissingPaymentMethod=12]="MissingPaymentMethod",t[t.MissingPaymentProviderCustomer=13]="MissingPaymentProviderCustomer",t[t.MissingPaymentRedirectUrl=14]="MissingPaymentRedirectUrl",t[t.MissingPaymentStatus=15]="MissingPaymentStatus",t[t.MissingPaymentToken=16]="MissingPaymentToken",t[t.MissingShippingAddress=17]="MissingShippingAddress"}(j||(j={}));const R=function(t){function e(e){var n=t.call(this,function(t){switch(t){case j.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case j.MissingCart:return"Unable to proceed because cart data is unavailable.";case j.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case j.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case j.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case j.MissingCheckoutConfig:case j.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case j.MissingOrder:return"Unable to proceed because order data is unavailable.";case j.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case j.MissingPayment:return"Unable to proceed because payment data is unavailable.";case j.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case j.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case j.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case j.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e))||this;return n.subtype=e,n.name="MissingDataError",n.type="missing_data",n}return L(e,t),e}(c);function U(t,e){var n=t.firstName||e.firstName||"",r=t.lastName||e.lastName||"";return{addresses:(t.addresses||[]).map((function(t){return A(t)})),customerId:t.id,isGuest:t.isGuest,storeCredit:t.storeCredit,email:t.email||e.email||"",firstName:n,lastName:r,name:t.fullName||[n,r].join(" "),customerGroupName:t.customerGroup&&t.customerGroup.name}}const F=function(){function t(){}return t.prototype.format=function(t){var e=t.split(new RegExp("\\s*".concat("/","\\s*"))),n=e[0],r=void 0===n?"":n,o=e[1],i=void 0===o?"":o,a=r.slice(0,2),s=4===i.length?i.slice(-2):i?i.slice(0,2):r.slice(2);return t.length<2?r:t.length>3&&!s?a:"".concat(a," ").concat("/"," ").concat(s)},t.prototype.toObject=function(t){var e=t.split(new RegExp("\\s*".concat("/","\\s*"))),n=e[0],r=void 0===n?"":n,o=e[1],i=void 0===o?"":o;return/^\d+$/.test(r)&&/^\d+$/.test(i)?{month:1===r.length?"0".concat(r):r.slice(0,2),year:2===i.length?"20".concat(i):i.slice(0,4)}:{month:"",year:""}},t}(),q=require("card-validator"),H=function(){function t(){}return t.prototype.format=function(t){var e=(0,q.number)(t).card;if(!e)return t;var n=(0,P.max)((0,q.creditCardType)(t).map((function(t){return(0,P.max)(t.lengths)}))),r=this.unformat(t).slice(0,n);return e.gaps.filter((function(t){return r.length>t})).reduce((function(t,e,n){return[t.slice(0,e+n),t.slice(e+n)].join(" ")}),r)},t.prototype.unformat=function(t){return(0,q.number)(t).card?t.replace(new RegExp(" ","g"),""):t},t}();var B=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function G(t,e){void 0===e&&(e={});var n,r,o=t.currency.decimalPlaces,i=new I(o);return{id:t.orderId,items:D(t.lineItems,t.currency.decimalPlaces,"productId"),orderId:t.orderId,currency:t.currency.code,customerCanBeCreated:t.customerCanBeCreated,payment:z(t.payments,e.payment),subtotal:{amount:t.baseAmount,integerAmount:i.toInteger(t.baseAmount)},coupon:{discountedAmount:(0,P.reduce)(t.coupons,(function(t,e){return t+e.discountedAmount}),0),coupons:t.coupons.map(S)},discount:{amount:t.discountAmount,integerAmount:i.toInteger(t.discountAmount)},token:e.orderToken,callbackUrl:e.callbackUrl,discountNotifications:[],giftCertificate:(n=t.payments,r=(0,P.filter)(n,{providerId:"giftcertificate"}),{totalDiscountedAmount:(0,P.reduce)(r,(function(t,e){return e.amount+t}),0),appliedGiftCertificates:(0,P.keyBy)(r.map((function(t){return{code:t.detail.code,discountedAmount:t.amount,remainingBalance:t.detail.remaining,giftCertificate:{balance:t.amount+t.detail.remaining,code:t.detail.code,purchaseDate:""}}})),"code")}),socialData:Q(t),status:t.status,hasDigitalItems:t.hasDigitalItems,isDownloadable:t.isDownloadable,isComplete:t.isComplete,shipping:{amount:t.shippingCostTotal,integerAmount:i.toInteger(t.shippingCostTotal),amountBeforeDiscount:t.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(t.shippingCostBeforeDiscount)},storeCredit:{amount:Y(t.payments)},taxes:t.taxes,taxTotal:{amount:t.taxTotal,integerAmount:i.toInteger(t.taxTotal)},handling:{amount:t.handlingCostTotal,integerAmount:i.toInteger(t.handlingCostTotal)},grandTotal:{amount:t.orderAmount,integerAmount:t.orderAmountAsInteger}}}function Y(t){var e=(0,P.find)(t,{providerId:"storecredit"});return e?e.amount:0}function z(t,e){void 0===e&&(e={});var n,r=(0,P.find)(t,W);return r?{id:r.providerId,status:(n=r.detail.step,"PAYMENT_STATUS_".concat(n)),helpText:r.detail.instructions,returnUrl:e.returnUrl}:{}}function W(t){return"giftcertificate"!==t.providerId&&"storecredit"!==t.providerId}function Q(t){var e={};return B(B([],t.lineItems.physicalItems,!0),t.lineItems.digitalItems,!0).forEach((function(t){var n;e[t.id]=(n=t,["fb","tw","gp"].reduce((function(t,e){var r=n.socialMedia&&(0,P.find)(n.socialMedia,(function(t){return t.code===e}));return r?(t[e]={name:n.name,description:n.name,image:n.imageUrl,url:r.link,shareText:r.text,sharingLink:r.link,channelName:r.channel,channelCode:r.code},t):t}),{}))})),e}function Z(t,e){return{description:t.description,module:t.type,price:t.cost,id:t.id,selected:e,isRecommended:t.isRecommended,imageUrl:t.imageUrl,transitTime:t.transitTime}}var $=function(){return $=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},$.apply(this,arguments)};const J=function(){function t(){this._cardExpiryFormatter=new F,this._cardNumberFormatter=new H}return t.prototype.transform=function(t,e){var n,r=e.billingAddress.getBillingAddress(),o=e.checkout.getCheckout(),i=e.customer.getCustomer(),a=e.order.getOrder(),s=e.paymentMethods.getPaymentMethod(t.methodId,t.gatewayId),c=this._mapShippingAddress(e,s),u=e.consignments.getConsignments(),p=e.consignments.getShippingOption(),d=e.config.getStoreConfig(),l=e.config.getContextConfig(),f=e.instruments.getInstrumentsMeta(),h=e.paymentMethods.getPaymentMethodsMeta(),y=e.order.getOrderMeta(),m=i&&r&&U(i,r),g=f&&t.paymentData&&(n=t.paymentData,Boolean(n.instrumentId)||function(t){var e=t.formattedPayload;return!!e&&("string"==typeof e.bigpay_token||Boolean(e.bigpay_token&&e.bigpay_token.token))}(t.paymentData))?"".concat(e.payment.getPaymentToken(),", ").concat(f.vaultAccessToken):e.payment.getPaymentToken();if(!g)throw new R(j.MissingPaymentToken);return{additionalAction:t.additionalAction,authToken:g,customer:m,billingAddress:r&&A(r),shippingAddress:c&&A(c,u),shippingOption:p&&Z(p,!0),cart:o&&V(o),order:a&&G(a,y),orderMeta:y,payment:t.paymentData,paymentMethod:s&&this._transformPaymentMethod(s),quoteMeta:{request:$($({},h),{geoCountryCode:l&&l.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:(0,P.pick)(d&&d.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},t.prototype.transformWithHostedFormData=function(t,e,n){var r=e.additionalAction,o=e.authToken,i=e.checkout,a=e.config,s=e.order,c=e.orderMeta,u=e.payment,p=void 0===u?{}:u,d=e.paymentMethod,l=e.paymentMethodMeta,f=i&&i.consignments[0],h=f&&f.shippingAddress,y=f&&f.selectedShippingOption;return{additionalAction:r,authToken:o,paymentMethod:d&&this._transformPaymentMethod(d),customer:s&&s.billingAddress&&i&&U(i.customer,s.billingAddress),billingAddress:s&&s.billingAddress&&A(s.billingAddress),shippingAddress:h&&i&&A(h,i.consignments),shippingOption:y&&Z(y,!0),cart:i&&V(i),order:s&&G(s,c),orderMeta:c,payment:this._transformHostedInputValues(t,p,n),quoteMeta:{request:$($({},l),{geoCountryCode:a&&a.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:a&&(0,P.pick)(a.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},t.prototype._transformPaymentMethod=function(t){return"multi-option"!==t.method||t.gateway?t.initializationData&&t.initializationData.gateway?$($({},t),{id:t.initializationData.gateway}):t.id===k.BRAINTREE_VENMO?$($({},t),{id:k.BRAINTREE_PAYPAL}):t:$($({},t),{gateway:t.id})},t.prototype._transformHostedInputValues=function(t,e,n){return $($({},e),"instrumentId"in e?{ccCvv:t.cardCodeVerification,ccNumber:t.cardNumberVerification&&this._cardNumberFormatter.unformat(t.cardNumberVerification),hostedFormNonce:n}:{ccCvv:t.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(t.cardExpiry||""),ccName:t.cardName||"",ccNumber:this._cardNumberFormatter.unformat(t.cardNumber||""),hostedFormNonce:n})},t.prototype._mapShippingAddress=function(t,e){var n,r,o,i;if(e){var a=null===(r=null===(n=e.initializationData)||void 0===n?void 0:n.bopis)||void 0===r?void 0:r.enabled,s=null===(i=null===(o=e.initializationData)||void 0===o?void 0:o.bopis)||void 0===i?void 0:i.requiredAddress,c=t.consignments.getConsignments(),u=null==c?void 0:c.every((function(t){return t.selectedPickupOption}));if(a&&u&&"none"===s)return}return t.shippingAddress.getShippingAddress()},t}();var K=function(){return K=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},K.apply(this,arguments)};const X=function(){function t(t){this._requestSender=t}return t.prototype.submitPaymentInstrument=function(t,e){return n=this,r=void 0,i=function(){var n,r,o,i,a,s,c,u,p,d,l;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(f){switch(f.label){case 0:return n=t.providerId,r=t.currencyCode,o=t.paymentsUrl,i=t.shopperId,a=t.storeHash,s=t.vaultToken,c=e.billingAddress,u=e.instrument,p=e.defaultInstrument,d="".concat(o,"/stores/").concat(a,"/customers/").concat(i,"/stored_instruments"),l={headers:{Authorization:s,Accept:"application/vnd.bc.v1+json","Content-Type":"application/vnd.bc.v1+json"},body:JSON.stringify({instrument:{type:u.type,cardholder_name:u.cardholderName,number:u.number,expiry_month:u.expiryMonth,expiry_year:u.expiryYear,verification_value:u.verificationValue},billing_address:K(K(K(K(K(K({email:c.email,address1:c.address1},c.address2&&{address2:c.address2}),{city:c.city,postal_code:c.postalCode,country_code:c.countryCode}),c.company&&{company:c.company}),{first_name:c.firstName,last_name:c.lastName}),c.phone&&{phone:c.phone}),c.stateOrProvinceCode&&{state_or_province_code:c.stateOrProvinceCode}),provider_id:n,default_instrument:p,currency_code:r})},[4,this._requestSender.post(d,l)];case 1:return f.sent(),[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function s(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,s)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},t}();var tt;!function(t){t.CardCode="cardCode",t.CardCodeVerification="cardCodeVerification",t.CardExpiry="cardExpiry",t.CardName="cardName",t.CardNumber="cardNumber",t.CardNumberVerification="cardNumberVerification"}(tt||(tt={}));const et=tt;function nt(t){switch(t){case et.CardCode:return"cc-csc";case et.CardExpiry:return"cc-exp";case et.CardName:return"cc-name";case et.CardNumber:return"cc-number";default:return""}}const rt=function(){function t(t,e,n){var r=this;this._form=t,this._fieldTypes=e,this._inputAggregator=n,this._handleChange=function(t){var e=t.target;if(!e)throw new Error("Unable to get a reference to the target of the change event.");var n=r._inputAggregator.getInputs().find((function(t){return r._getAutocompleteElementId(t.getType())===e.id}));n&&n.setValue(e.value)},this._inputs=this._fieldTypes.map((function(t){return r._createInput(t)}))}return t.prototype.attach=function(){var t=this;this._inputs.forEach((function(e){return t._form.appendChild(e)}))},t.prototype.detach=function(){this._inputs.forEach((function(t){t.parentElement&&t.parentElement.removeChild(t)}))},t.prototype._createInput=function(t){var e=document.createElement("input");return e.autocomplete=nt(t),e.id=this._getAutocompleteElementId(t),e.tabIndex=-1,e.style.position="absolute",e.style.opacity="0",e.style.zIndex="-1",e.addEventListener("change",this._handleChange),e},t.prototype._getAutocompleteElementId=function(t){return"autocomplete-".concat((0,P.kebabCase)(t))},t}();var ot,it;!function(t){t.AttachRequested="HOSTED_FIELD:ATTACH_REQUESTED",t.SubmitRequested="HOSTED_FIELD:SUBMITTED_REQUESTED",t.ValidateRequested="HOSTED_FIELD:VALIDATE_REQUESTED",t.StoredCardRequested="HOSTED_FIELD:STORED_CARD_REQUESTED"}(ot||(ot={})),function(t){t.AttachSucceeded="HOSTED_INPUT:ATTACH_SUCCEEDED",t.AttachFailed="HOSTED_INPUT:ATTACH_FAILED",t.BinChanged="HOSTED_INPUT:BIN_CHANGED",t.Blurred="HOSTED_INPUT:BLURRED",t.Changed="HOSTED_INPUT:CHANGED",t.CardTypeChanged="HOSTED_INPUT:CARD_TYPE_CHANGED",t.Entered="HOSTED_INPUT:ENTERED",t.Focused="HOSTED_INPUT:FOCUSED",t.SubmitSucceeded="HOSTED_INPUT:SUBMIT_SUCCEEDED",t.SubmitFailed="HOSTED_INPUT:SUBMIT_FAILED",t.Validated="HOSTED_INPUT:VALIDATED",t.StoredCardSucceeded="HOSTED_INPUT:STORED_CARD_SUCCEEDED",t.StoredCardFailed="HOSTED_INPUT:STORED_CARD_FAILED"}(it||(it={}));const at=function(){function t(t,e,n,r,o,i,a,s,c,u,p,d,l){var f=this;this._type=t,this._form=e,this._placeholder=n,this._accessibilityLabel=r,this._autocomplete=o,this._styles=i,this._fontUrls=a,this._eventListener=s,this._eventPoster=c,this._inputAggregator=u,this._inputValidator=p,this._paymentHandler=d,this._storedCardHandler=l,this._isTouched=!1,this._handleInput=function(t){var e=t.target;f._processChange(e.value)},this._handleBlur=function(){f._applyStyles(f._styles.default),f._validateForm(),f._eventPoster.post({type:it.Blurred,payload:{fieldType:f._type}})},this._handleFocus=function(){f._applyStyles(f._styles.focus),f._eventPoster.post({type:it.Focused,payload:{fieldType:f._type}})},this._handleValidate=function(){f._validateForm()},this._handleSubmit=function(t){t.preventDefault(),f._eventPoster.post({type:it.Entered,payload:{fieldType:f._type}})},this._forceFocusToInput=function(){document.activeElement===document.body&&(navigator.userAgent.toLowerCase().indexOf("safari")>-1?""===f._input.value&&(f._input.setAttribute("value"," "),f._input.setSelectionRange(0,1),f._input.setAttribute("value","")):f._input.focus())},this._input=document.createElement("input"),this._input.addEventListener("input",this._handleInput),this._input.addEventListener("blur",this._handleBlur),this._input.addEventListener("focus",this._handleFocus),this._eventListener.addListener(ot.ValidateRequested,this._handleValidate),this._eventListener.addListener(ot.SubmitRequested,this._paymentHandler.handle),this._eventListener.addListener(ot.StoredCardRequested,this._storedCardHandler.handle),this._configureInput()}return t.prototype.getType=function(){return this._type},t.prototype.getValue=function(){return this._input.value},t.prototype.setValue=function(t){this._processChange(t)},t.prototype.isTouched=function(){return this._isTouched},t.prototype.attach=function(){this._form.appendChild(this._input),this._form.addEventListener("submit",this._handleSubmit),this._loadFonts(),this._eventPoster.setTarget(window.parent),this._eventListener.listen(),window.addEventListener("focus",this._forceFocusToInput),window.hostedInput=this,this._eventPoster.post({type:it.AttachSucceeded})},t.prototype.detach=function(){this._input.parentElement&&this._input.parentElement.removeChild(this._input),this._form.removeEventListener("submit",this._handleSubmit),this._unloadFonts(),window.removeEventListener("focus",this._forceFocusToInput),this._eventListener.stopListen()},t.prototype._formatValue=function(t){this._input.value=t},t.prototype._notifyChange=function(t){this._eventPoster.post({type:it.Changed,payload:{fieldType:this._type}})},t.prototype._configureInput=function(){switch(this._input.style.backgroundColor="transparent",this._input.style.border="0",this._input.style.display="block",this._input.style.height="100%",this._input.style.margin="0",this._input.style.outline="none",this._input.style.padding="0",this._input.style.width="100%",this._input.id=(0,P.kebabCase)(this._type),this._input.placeholder=this._placeholder,this._input.autocomplete=this._autocomplete,this._input.setAttribute("aria-label",this._accessibilityLabel),this._applyStyles(this._styles.default),this._input.id){case"card-code":case"card-expiry":case"card-number":this._input.type="text",this._input.inputMode="numeric",this._input.pattern="[0-9]*";break;case"card-name":this._input.type="text",this._input.inputMode="text"}},t.prototype._applyStyles=function(t){var e=this;void 0===t&&(t={});var n={color:t.color,fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight};Object.keys(n).forEach((function(t){n[t]&&(e._input.style[t]=n[t]||"")}))},t.prototype._loadFonts=function(){this._fontLinks||(this._fontLinks=this._fontUrls.filter((function(t){return"fonts.googleapis.com"===d(t).hostname})).filter((function(t){return!document.querySelector("link[href='".concat(t,"'][rel='stylesheet']"))})).map((function(t){var e=document.createElement("link");return e.rel="stylesheet",e.href=t,document.head.appendChild(e),e})))},t.prototype._unloadFonts=function(){this._fontLinks&&(this._fontLinks.forEach((function(t){t.parentElement&&t.parentElement.removeChild(t)})),this._fontLinks=void 0)},t.prototype._validateForm=function(){return t=this,e=void 0,r=function(){var t,e;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(n){switch(n.label){case 0:return t=this._inputAggregator.getInputValues(),[4,this._inputValidator.validate(t)];case 1:return(e=n.sent()).isValid?this._applyStyles(this._styles.default):this._applyStyles(this._styles.error),this._eventPoster.post({type:it.Validated,payload:e}),[2]}}))},new((n=void 0)||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}));var t,e,n,r},t.prototype._processChange=function(t){t!==this._previousValue&&(this._isTouched=!0,this._formatValue(t),this._validateForm(),this._notifyChange(t),this._previousValue=t)},t}();var st=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const ct=function(t){function e(e,n,r,o,i,a,s,c,u,p,d,l,f){var h=t.call(this,et.CardExpiry,e,n,r,o,i,a,s,c,u,p,d,l)||this;return h._formatter=f,h}return st(e,t),e.prototype._formatValue=function(t){this._input.value=this._formatter.format(t)},e}(at);var ut=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const pt=function(t){function e(e,n,r,o,i,a,s,c,u,p,d,l,f,h,y){var m=t.call(this,e,n,r,o,i,a,s,c,u,p,d,l,f)||this;return m._autocompleteFieldset=h,m._formatter=y,m}return ut(e,t),e.prototype.attach=function(){t.prototype.attach.call(this),this._autocompleteFieldset.attach()},e.prototype._notifyChange=function(t){var e=(0,q.number)(t).card,n=this._previousValue&&(0,q.number)(this._previousValue).card;(0,P.get)(n,"type")!==(0,P.get)(e,"type")&&this._eventPoster.post({type:it.CardTypeChanged,payload:{cardType:e?e.type:void 0}});var r=this._formatter.unformat(t),o=this._previousValue?this._formatter.unformat(this._previousValue):"",i=r.length>=6&&(0,q.number)(r).isPotentiallyValid?r.substr(0,6):"";i!==(o.length>=6?o.substr(0,6):"")&&this._eventPoster.post({type:it.BinChanged,payload:{bin:i}})},e.prototype._formatValue=function(t){var e=this._input.selectionEnd,n=this._formatter.format(t);e===t.length&&t.length<n.length?this._input.setSelectionRange(n.length,n.length):this._input.setSelectionRange(e||0,e||0),this._input.value=n},e}(at);var dt=function(){return dt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},dt.apply(this,arguments)},lt=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};const ft=function(){function t(t){this._parentWindow=t}return t.prototype.getInputs=function(t){return Array.prototype.slice.call(this._parentWindow.frames).reduce((function(e,n){try{var r=n.hostedInput;return!r||t&&!t(r)?e:lt(lt([],e,!0),[r],!1)}catch(t){if(t instanceof DOMException)return e;if(t instanceof Error&&"Permission denied"===t.message)return e;throw t}}),[])},t.prototype.getInputValues=function(t){return this.getInputs(t).reduce((function(t,e){var n;return dt(dt({},t),((n={})[e.getType()]=e.getValue(),n))}),{})},t}();var ht=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const yt=function(t){function e(e){var n=t.call(this,function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}(["Unable to proceed due to invalid user input values"],(0,P.flatMap)((0,P.values)(e),(function(t){return(0,P.map)(t,(function(t){return t.message}))})),!0).join(". "))||this;return n.errors=e,n.name="InvalidHostedFormValueError",n.type="invalid_hosted_form_value",n}return ht(e,t),e}(c);const mt=function(){function t(t,e,n,r,o,i){var a=this;this._inputAggregator=t,this._inputValidator=e,this._inputStorage=n,this._eventPoster=r,this._paymentRequestSender=o,this._paymentRequestTransformer=i,this.handle=function(t){var e,n,r,o,i=t.payload.data;return e=a,n=void 0,o=function(){var t,e,n,r,o;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(a){switch(a.label){case 0:return t=this._inputAggregator.getInputValues(),[4,this._inputValidator.validate(t)];case 1:if(e=a.sent(),this._eventPoster.post({type:it.Validated,payload:e}),!e.isValid)return n=new yt(e.errors),[2,this._eventPoster.post({type:it.SubmitFailed,payload:{error:{code:(0,P.snakeCase)(n.name),message:n.message}}})];a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transformWithHostedFormData(t,i,this._inputStorage.getNonce()||""))];case 3:return r=a.sent(),this._eventPoster.post({type:it.SubmitSucceeded,payload:{response:r}}),[3,5];case 4:return o=a.sent(),this._isPaymentErrorResponse(o)?this._eventPoster.post({type:it.SubmitFailed,payload:{error:o.body.errors[0],response:o}}):this._isErrorResponse(o)&&this._eventPoster.post({type:it.SubmitFailed,payload:{error:{code:(0,P.snakeCase)(o.name),message:o.message}}}),[3,5];case 5:return[2]}}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}c((o=o.apply(e,n||[])).next())}))}}return t.prototype._isPaymentErrorResponse=function(t){var e=(t||{}).body,n=(void 0===e?{}:e).errors,r=void 0===n?[]:n;return"string"==typeof(r[0]&&r[0].code)&&"string"==typeof(r[0]&&r[0].message)},t.prototype._isErrorResponse=function(t){return"object"==typeof t&&null!==t&&("name"in t&&"string"==typeof t.name||!("name"in t))&&("message"in t&&"string"==typeof t.message||!("message"in t))},t}();const gt=function(t,e,n,r){var o=this;this._inputAggregator=t,this._inputValidator=e,this._eventPoster=n,this._storedCardRequestSender=r,this.handle=function(t){return e=o,n=void 0,i=function(){var e,n,r,o,i,a,s,c,u,p,d;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(l){switch(l.label){case 0:return e=t.payload,n=e.data,r=e.fields,o=this._inputAggregator.getInputValues(),[4,this._inputValidator.validate(o)];case 1:if(i=l.sent(),this._eventPoster.post({type:it.Validated,payload:i}),!i.isValid)return[2,this._eventPoster.post({type:it.StoredCardFailed})];a=r.defaultInstrument,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(r,["defaultInstrument"]),c=o.cardExpiry?o.cardExpiry.split("/"):[],u=c[0],p=c[1],l.label=2;case 2:return l.trys.push([2,4,,5]),[4,this._storedCardRequestSender.submitPaymentInstrument(n,{billingAddress:s,instrument:{type:"card",cardholderName:o.cardName||"",number:o.cardNumber?o.cardNumber.replace(/ /g,""):"",expiryMonth:Number(u.trim()),expiryYear:Number("20".concat(p.trim())),verificationValue:null!==(d=o.cardCode)&&void 0!==d?d:""},defaultInstrument:a})];case 3:return l.sent(),this._eventPoster.post({type:it.StoredCardSucceeded}),[3,5];case 4:return l.sent(),this._eventPoster.post({type:it.StoredCardFailed}),[3,5];case 5:return[2]}}))},new((r=void 0)||(r=Promise))((function(t,o){function a(t){try{c(i.next(t))}catch(t){o(t)}}function s(t){try{c(i.throw(t))}catch(t){o(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}c((i=i.apply(e,n||[])).next())}));var e,n,r,i}},_t=require("yup");var vt=function(){return vt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},vt.apply(this,arguments)},bt=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};const Ct=function(){function t(t){this._cardInstrument=t,this._completeSchema={cardCode:this._getCardCodeSchema(),cardCodeVerification:this._getCardCodeVerificationSchema(),cardExpiry:this._getCardExpirySchema(),cardName:this._getCardNameSchema(),cardNumber:this._getCardNumberSchema(),cardNumberVerification:this._getCardNumberVerificationSchema()},this._configureCardValidator()}return t.prototype.validate=function(t){return e=this,n=void 0,o=function(){var e,n,r,o;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(i){switch(i.label){case 0:for(r in e={},n={errors:{},isValid:!0},t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=this._completeSchema[r],n.errors[r]=[]);i.label=1;case 1:return i.trys.push([1,3,,4]),[4,(0,_t.object)(e).validate(t,{abortEarly:!1})];case 2:return i.sent(),[2,n];case 3:if(o=i.sent(),this._isValidationErrorType(o))throw o;return[2,{errors:Object.keys(n.errors).reduce((function(t,e){var n;return vt(vt({},t),((n={})[e]=o.inner.filter((function(t){return t.path===e})).map((function(t){return{fieldType:t.path,message:t.errors.join(" "),type:t.type}})),n))}),{}),isValid:!1}];case 4:return[2]}}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}c((o=o.apply(e,n||[])).next())}));var e,n,r,o},t.prototype._configureCardValidator=function(){var t=q.creditCardType.getTypeInfo("discover"),e=q.creditCardType.getTypeInfo("jcb"),n=q.creditCardType.getTypeInfo("visa");q.creditCardType.updateCard("visa",{lengths:bt([13],n.lengths||[],!0)}),q.creditCardType.updateCard("discover",{patterns:bt(bt([],t.patterns||[],!0),[[810,817]],!1)}),q.creditCardType.addCard({niceType:"Mada",type:"mada",patterns:[400861,401757,407197,407395,409201,410685,412565,417633,419593,422817,422818,422819,428331,428671,428672,428673,431361,432328,434107,439954,440533,440647,440795,445564,446393,446404,446672,455036,455708,457865,458456,462220,468540,468541,468542,468543,483010,483011,483012,484783,486094,486095,486096,489317,489318,489319,493428,504300,506968,508160,513213,520058,521076,524130,524514,529415,529741,530060,530906,531095,531196,532013,535825,535989,536023,537767,539931,543085,543357,549760,554180,557606,558848,585265,588845,588846,588847,588848,588849,588850,588851,588982,588983,589005,589206,604906,605141,636120,968201,968202,968203,968204,968205,968206,968207,968208,968209,968210,968211],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}),q.creditCardType.updateCard("jcb",{patterns:bt(bt([],e.patterns||[],!0),[3088,3337,3338],!1)})},t.prototype._getCardCodeSchema=function(){return(0,_t.string)().required("CVV is required").test({message:"CVV must be valid",name:"invalid_card_code",test:function(t){var e=(0,q.number)(this.parent.cardNumber||"").card;return(0,q.cvv)(t,e&&e.code?e.code.size:void 0).isValid}})},t.prototype._getCardCodeVerificationSchema=function(){var t=this;return(0,_t.string)().required("CVV is required").test({message:"CVV must be valid",name:"invalid_card_code",test:function(e){void 0===e&&(e="");var n=t._cardInstrument&&t._mapFromInstrumentCardType(t._cardInstrument.brand),r=n&&q.creditCardType.getTypeInfo(n);return(0,q.cvv)(e,r&&r.code?r.code.size:void 0).isValid}})},t.prototype._getCardExpirySchema=function(){return(0,_t.string)().required("Expiration date is required").test({message:"Expiration date must be a valid future date in MM / YY format",name:"invalid_card_expiry",test:function(t){return(0,q.expirationDate)(t).isValid}})},t.prototype._getCardNameSchema=function(){return(0,_t.string)().max(200).required("Full name is required")},t.prototype._getCardNumberSchema=function(){return(0,_t.string)().required("Credit card number is required").test({message:"Credit card number must be valid",name:"invalid_card_number",test:function(t){return(0,q.number)(t).isValid}})},t.prototype._getCardNumberVerificationSchema=function(){var t=this;return(0,_t.string)().required("Credit card number is required").test({message:"Credit card number must be valid",name:"invalid_card_number",test:function(t){return void 0===t&&(t=""),(0,q.number)(t).isValid}}).test({message:"The card number entered does not match the card stored in your account",name:"mismatched_card_number",test:function(e){return void 0===e&&(e=""),!!t._cardInstrument&&e.slice(-t._cardInstrument.last4.length)===t._cardInstrument.last4}})},t.prototype._mapFromInstrumentCardType=function(t){switch(t){case"amex":case"american_express":return"american-express";case"diners":return"diners-club";default:return t}},t.prototype._isValidationErrorType=function(t){return"name"in t&&"ValidationError"!==t.name},t}(),wt=function(){function t(t){this._parentOrigin=t}return t.prototype.create=function(t,e,n,r,o,i,a){void 0===n&&(n={}),void 0===r&&(r=[]),void 0===o&&(o=""),void 0===i&&(i=function(t){switch(t){case et.CardCode:case et.CardCodeVerification:return"CVC";case et.CardExpiry:return"Expiration";case et.CardName:return"Name on card";case et.CardNumber:case et.CardNumberVerification:return"Credit card number"}}(e));var s=nt(e);return e===et.CardNumber?this._createNumberInput(e,t,n,r,o,i,s):e===et.CardNumberVerification?this._createNumberInput(e,t,n,r,o,i,s,a):e===et.CardExpiry?this._createExpiryInput(t,n,r,o,i,s):e===et.CardCodeVerification?this._createInput(e,t,n,r,o,i,s,a):this._createInput(e,t,n,r,o,i,s)},t.prototype.normalizeParentOrigin=function(t){this._parentOrigin!==t&&(this._parentOrigin!==l(d(t)).origin&&t!==l(d(this._parentOrigin)).origin||(this._parentOrigin=t))},t.prototype.getParentOrigin=function(){return this._parentOrigin},t.prototype._createExpiryInput=function(t,e,n,r,o,i){return void 0===o&&(o=""),void 0===i&&(i=""),new ct(t,r,o,i,e,n,new h(this._parentOrigin),new E(this._parentOrigin,window.parent),new ft(window.parent),new Ct,this._createPaymentHandler(),this._createStoredCardHandler(),new F)},t.prototype._createNumberInput=function(t,e,n,r,o,i,a,s){return void 0===i&&(i=""),void 0===a&&(a=""),new pt(t,e,o,i,a,n,r,new h(this._parentOrigin),new E(this._parentOrigin,window.parent),new ft(window.parent),new Ct(s),this._createPaymentHandler(s),this._createStoredCardHandler(s),new rt(e,[et.CardCode,et.CardExpiry,et.CardName],new ft(window.parent)),new H)},t.prototype._createInput=function(t,e,n,r,o,i,a,s){return void 0===i&&(i=""),void 0===a&&(a=""),new at(t,e,o,i,a,n,r,new h(this._parentOrigin),new E(this._parentOrigin,window.parent),new ft(window.parent),new Ct(s),this._createPaymentHandler(s),this._createStoredCardHandler(s))},t.prototype._createPaymentHandler=function(t){return new mt(new ft(window.parent),new Ct(t),g(),new E(this._parentOrigin,window.parent),new O((0,_.createClient)()),new J)},t.prototype._createStoredCardHandler=function(t){return new gt(new ft(window.parent),new Ct(t),new E(this._parentOrigin,window.parent),new X((0,v.createRequestSender)()))},t}();var Et=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const Ot=function(t){function e(e){var n=t.call(this,e||"Unable to proceed due to invalid configuration provided for the hosted payment form.")||this;return n.name="InvalidHostedFormConfigError",n.type="invalid_hosted_form_config",n}return Et(e,t),e}(c),Pt=function(){function t(t,e,n){this._factory=t,this._storage=e,this._eventListener=n}return t.prototype.initialize=function(t,e){var n=this;e&&this._storage.setNonce(e);var r=this._createFormContainer(t);return this._resetPageStyles(t),this._eventListener.listen(),(0,b.fromEvent)(this._eventListener,ot.AttachRequested).pipe((0,C.map)((function(t){var e=t.payload,o=e.accessibilityLabel,i=e.cardInstrument,a=e.fontUrls,s=e.placeholder,c=e.styles,u=e.origin,p=e.type;u&&n._factory.normalizeParentOrigin(u);var d=n._factory.create(r,p,c,a,s,o,i);return d.attach(),d})),(0,C.take)(1)).toPromise()},t.prototype._resetPageStyles=function(t){[document.querySelector("html"),document.querySelector("body"),document.getElementById(t)].forEach((function(t){t&&(t.style.height="100%",t.style.width="100%",t.style.overflow="hidden",t.style.padding="0",t.style.margin="0")}))},t.prototype._createFormContainer=function(t){var e=document.getElementById(t);if(!e)throw new Ot("Unable to proceed because the provided container ID is not valid.");var n=document.createElement("form"),r=document.createElement("button");return n.noValidate=!0,n.style.height="100%",n.style.width="100%",r.style.display="none",e.appendChild(n),n.appendChild(r),n},t}();function At(t){var e=t.containerId,n=t.nonce,r=t.parentOrigin;return new Pt(new wt(r),g(),new h(r)).initialize(e,n)}var It=new E("*",window.parent);function Tt(t){It.post({type:it.AttachFailed,payload:{error:t}})}module.exports=e})();
|
|
1
|
+
(()=>{"use strict";var t={d:(e,n)=>{for(var r in n)t.o(n,r)&&!t.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:n[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},e={};t.r(e),t.d(e,{initializeHostedInput:()=>At,notifyInitializeError:()=>Tt});var n,r=(n=function(t,e){return n=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},n(t,e)},function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}n(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}),o=function(){return o=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},o.apply(this,arguments)};const i=function(t,e,n){return e&&n?a(0,e,n):function(t){var e=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return r(e,t),e}(t);return Object.getOwnPropertyNames(t.prototype).forEach((function(n){var r=Object.getOwnPropertyDescriptor(t.prototype,n);r&&"constructor"!==n&&Object.defineProperty(e.prototype,n,a(t.prototype,n,r))})),e}(t)};function a(t,e,n){if("function"!=typeof n.value)return n;var r=n.value;return{get:function(){var t=r.bind(this);return Object.defineProperty(this,e,o(o({},n),{value:t})),t},set:function(t){r=t}}}var s=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const c=function(t){function e(e){var n,r,o=this.constructor,i=t.call(this,e||"An unexpected error has occurred.")||this;return i.name="StandardError",i.type="standard",n=i,r=o.prototype,Object.setPrototypeOf?Object.setPrototypeOf(n,r):n.__proto__=r,"function"==typeof Error.captureStackTrace?Error.captureStackTrace(i,o):i.stack=new Error(i.message).stack,i}return s(e,t),e}(Error);var u=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const d=function(t){function e(e){var n=t.call(this,e||"Invalid arguments have been provided.")||this;return n.name="InvalidArgumentError",n.type="invalid_argument",n}return u(e,t),e}(c);function p(t){if(!/^(https?:)?\/\//.test(t))throw new d("The provided URL must be absolute.");var e=document.createElement("a");e.href=t;var n=e.port&&-1!==t.indexOf("".concat(e.hostname,":").concat(e.port))?e.port:"";return{hash:e.hash,hostname:e.hostname,href:e.href,origin:"".concat(e.protocol,"//").concat(e.hostname).concat(n?":".concat(n):""),pathname:e.pathname,port:n,protocol:e.protocol,search:e.search}}function l(t){return p(0===t.hostname.indexOf("www")?t.href:t.href.replace(t.hostname,"www.".concat(t.hostname)))}function f(t,e){return t.type===e}const h=function(){function t(t){this._sourceOrigins=[p(t).origin,l(p(t)).origin],this._isListening=!1,this._listeners={}}return t.prototype.listen=function(){this._isListening||(this._isListening=!0,window.addEventListener("message",this._handleMessage))},t.prototype.stopListen=function(){this._isListening&&(this._isListening=!1,window.removeEventListener("message",this._handleMessage))},t.prototype.addListener=function(t,e){var n=this._listeners[t];n||(this._listeners[t]=n=[]),-1===n.indexOf(e)&&n.push(e)},t.prototype.removeListener=function(t,e){var n=this._listeners[t];if(n){var r=n.indexOf(e);r>=0&&n.splice(r,1)}},t.prototype.trigger=function(t,e){var n=this._listeners[t.type];n&&n.forEach((function(n){return e?n(t,e):n(t)}))},t.prototype._handleMessage=function(t){if(-1!==this._sourceOrigins.indexOf(t.origin)&&f(t.data,t.data.type)){var e=t.data,n=e.context,r=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(e,["context"]);this.trigger(r,n)}},function(t,e,n,r){var o,i=arguments.length,a=i<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(t,e,n,r);else for(var s=t.length-1;s>=0;s--)(o=t[s])&&(a=(i<3?o(a):i>3?o(e,n,a):o(e,n))||a);i>3&&a&&Object.defineProperty(e,n,a)}([i],t.prototype,"_handleMessage",null),t}(),y=function(){function t(){}return t.prototype.setNonce=function(t){this._nonce=t},t.prototype.getNonce=function(){return this._nonce},t}();var m;function g(){return m=m||new y}const _=require("@bigcommerce/bigpay-client"),v=require("@bigcommerce/request-sender"),b=require("rxjs"),C=require("rxjs/operators");var w=function(){return w=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},w.apply(this,arguments)};const E=function(){function t(t,e,n){this._targetWindow=e,this._context=n,this._targetOrigin="*"===t?"*":p(t).origin}return t.prototype.post=function(t,e){var n=this,r=this._targetWindow;if(window!==r){if(!r)throw new Error("Unable to post message because target window is not set.");var o=e&&(0,b.fromEvent)(window,"message").pipe((0,C.filter)((function(t){return t.origin===n._targetOrigin&&f(t.data,t.data.type)&&-1!==[e.successType,e.errorType].indexOf(t.data.type)})),(0,C.map)((function(t){if(e.errorType===t.data.type)throw t.data;return t.data})),(0,C.take)(1)).toPromise();return r.postMessage(w(w({},t),{context:this._context}),this._targetOrigin),o}},t.prototype.setTarget=function(t){this._targetWindow=t},t.prototype.setContext=function(t){this._context=t},t}(),O=function(){function t(t){this._client=t}return t.prototype.submitPayment=function(t){var e=this;return new Promise((function(n,r){e._client.submitPayment(t,(function(t,o){t?r(e._transformResponse(t)):n(e._transformResponse(o))}))}))},t.prototype.initializeOffsitePayment=function(t,e){var n=this;return new Promise((function(){n._client.initializeOffsitePayment(t,null,e)}))},t.prototype._transformResponse=function(t){return{headers:t.headers,body:t.data,status:t.status,statusText:t.statusText}},t}(),P=require("lodash");function A(t,e){var n;return function(t){return void 0!==t.id}(t)?n=t.id:e&&e.length&&(n=e[0].id),{id:n,firstName:t.firstName,lastName:t.lastName,company:t.company,addressLine1:t.address1,addressLine2:t.address2,city:t.city,province:t.stateOrProvince,provinceCode:t.stateOrProvinceCode,postCode:t.postalCode,country:t.country,countryCode:t.countryCode,phone:t.phone,customFields:t.customFields}}const I=function(){function t(t){this._decimalPlaces=t}return t.prototype.toInteger=function(t){return Math.round(t*Math.pow(10,this._decimalPlaces))},t}();var T=["per_item_discount","percentage_discount","per_total_discount","shipping_discount","free_shipping"];function S(t){return{code:t.code,discount:t.displayName,discountType:T.indexOf(t.couponType)}}function x(t){return{code:t.code,discountedAmount:t.used,remainingBalance:t.remaining,giftCertificate:{balance:t.balance,code:t.code,purchaseDate:t.purchaseDate}}}var N,M=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function D(t,e,n){return void 0===n&&(n="id"),Object.keys(t).reduce((function(r,o){return M(M([],r,!0),t[o].map((function(t){return"giftCertificates"===o?function(t,e){var n=new I(e);return{id:t.id,imageUrl:"",name:t.name,amount:t.amount,amountAfterDiscount:t.amount,discount:0,integerAmount:n.toInteger(t.amount),integerAmountAfterDiscount:n.toInteger(t.amount),integerUnitPrice:n.toInteger(t.amount),integerUnitPriceAfterDiscount:n.toInteger(t.amount),integerDiscount:0,quantity:1,sender:t.sender,recipient:t.recipient,type:"ItemGiftCertificateEntity",attributes:[],variantId:null}}(t,e):function(t,e,n,r){void 0===r&&(r="id");var o=new I(n);return{id:t[r],imageUrl:t.imageUrl,amount:t.extendedListPrice,amountAfterDiscount:t.extendedSalePrice,discount:t.discountAmount,integerAmount:o.toInteger(t.extendedListPrice),integerAmountAfterDiscount:o.toInteger(t.extendedSalePrice),integerDiscount:o.toInteger(t.discountAmount),integerUnitPrice:o.toInteger(t.listPrice),integerUnitPriceAfterDiscount:o.toInteger(t.salePrice),downloadsPageUrl:t.downloadPageUrl,name:t.name,quantity:t.quantity,brand:t.brand,sku:t.sku,categoryNames:t.categoryNames,variantId:t.variantId,productId:t.productId,attributes:(t.options||[]).map((function(t){return{name:t.name,value:t.value}})),addedByPromotion:t.addedByPromotion,type:e}}(t,function(t){switch(t){case"physicalItems":return"ItemPhysicalEntity";case"digitalItems":return"ItemDigitalEntity";case"giftCertificates":return"ItemGiftCertificateEntity";default:return""}}(o),e,n)})),!0)}),[])}function V(t){var e,n,r=t.cart.currency.decimalPlaces,o=new I(r);return{id:t.cart.id,items:D(t.cart.lineItems,r),currency:t.cart.currency.code,coupon:{discountedAmount:(0,P.reduce)(t.cart.coupons,(function(t,e){return t+e.discountedAmount}),0),coupons:t.cart.coupons.map(S)},discount:{amount:t.cart.discountAmount,integerAmount:o.toInteger(t.cart.discountAmount)},discountNotifications:(e=t.promotions,n=[],(e||[]).forEach((function(t){(t.banners||[]).forEach((function(t){n.push({placeholders:[],discountType:null,message:"",messageHtml:t.text})}))})),n),giftCertificate:{totalDiscountedAmount:(0,P.reduce)(t.giftCertificates,(function(t,e){return t+e.used}),0),appliedGiftCertificates:(0,P.keyBy)(t.giftCertificates.map(x),"code")},shipping:{amount:t.shippingCostTotal,integerAmount:o.toInteger(t.shippingCostTotal),amountBeforeDiscount:t.shippingCostBeforeDiscount,integerAmountBeforeDiscount:o.toInteger(t.shippingCostBeforeDiscount),required:(0,P.some)(t.cart.lineItems.physicalItems,(function(t){return t.isShippingRequired}))},subtotal:{amount:t.subtotal,integerAmount:o.toInteger(t.subtotal)},storeCredit:{amount:t.customer?t.customer.storeCredit:0},taxSubtotal:{amount:t.taxTotal,integerAmount:o.toInteger(t.taxTotal)},taxes:t.taxes,taxTotal:{amount:t.taxTotal,integerAmount:o.toInteger(t.taxTotal)},handling:{amount:t.handlingCostTotal,integerAmount:o.toInteger(t.handlingCostTotal)},grandTotal:{amount:t.grandTotal,integerAmount:o.toInteger(t.grandTotal)}}}!function(t){t.APPLEPAY="applepay",t.AMAZON_PAY_V2="amazonpay",t.BRAINTREE_PAYPAL="braintreepaypal",t.BRAINTREE_VENMO="braintreevenmo",t.BRAINTREE_PAYPAL_CREDIT="braintreepaypalcredit",t.GOOGLEPAY_ADYENV2="googlepayadyenv2",t.GOOGLEPAY_ADYENV3="googlepayadyenv3",t.GOOGLEPAY_AUTHORIZENET="googlepayauthorizenet",t.GOOGLEPAY_BNZ="googlepaybnz",t.GOOGLEPAY_BRAINTREE="googlepaybraintree",t.GOOGLEPAY_CHECKOUTCOM="googlepaycheckoutcom",t.GOOGLEPAY_CYBERSOURCEV2="googlepaycybersourcev2",t.GOOGLEPAY_ORBITAL="googlepayorbital",t.GOOGLEPAY_STRIPE="googlepaystripe",t.GOOGLEPAY_STRIPEUPE="googlepaystripeupe",t.GOOGLEPAY_WORLDPAYACCESS="googlepayworldpayaccess",t.MASTERPASS="masterpass",t.PAYPALEXPRESS="paypalexpress"}(N||(N={}));const k=N;var j,L=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();!function(t){t[t.MissingBillingAddress=0]="MissingBillingAddress",t[t.MissingCart=1]="MissingCart",t[t.MissingCheckout=2]="MissingCheckout",t[t.MissingConsignments=3]="MissingConsignments",t[t.MissingCustomer=4]="MissingCustomer",t[t.MissingCheckoutConfig=5]="MissingCheckoutConfig",t[t.MissingOrder=6]="MissingOrder",t[t.MissingOrderConfig=7]="MissingOrderConfig",t[t.MissingOrderId=8]="MissingOrderId",t[t.MissingPayment=9]="MissingPayment",t[t.MissingPaymentId=10]="MissingPaymentId",t[t.MissingPaymentInstrument=11]="MissingPaymentInstrument",t[t.MissingPaymentMethod=12]="MissingPaymentMethod",t[t.MissingPaymentProviderCustomer=13]="MissingPaymentProviderCustomer",t[t.MissingPaymentRedirectUrl=14]="MissingPaymentRedirectUrl",t[t.MissingPaymentStatus=15]="MissingPaymentStatus",t[t.MissingPaymentToken=16]="MissingPaymentToken",t[t.MissingShippingAddress=17]="MissingShippingAddress"}(j||(j={}));const R=function(t){function e(e){var n=t.call(this,function(t){switch(t){case j.MissingBillingAddress:return"Unable to proceed because billing address data is unavailable.";case j.MissingCart:return"Unable to proceed because cart data is unavailable.";case j.MissingConsignments:return"Unable to proceed because consignments data is unavailable.";case j.MissingCheckout:return"Unable to proceed because checkout data is unavailable.";case j.MissingCustomer:return"Unable to proceed because customer data is unavailable.";case j.MissingCheckoutConfig:case j.MissingOrderConfig:return"Unable to proceed because configuration data is unavailable.";case j.MissingOrder:return"Unable to proceed because order data is unavailable.";case j.MissingOrderId:return"Unable to proceed because order ID is unavailable or not generated yet.";case j.MissingPayment:return"Unable to proceed because payment data is unavailable.";case j.MissingPaymentToken:return"Unable to proceed because the token required to submit a payment is missing.";case j.MissingPaymentMethod:return"Unable to proceed because payment method data is unavailable or not properly configured.";case j.MissingPaymentProviderCustomer:return"Unable to proceed because payment provider customer is unavailable.";case j.MissingShippingAddress:return"Unable to proceed because shipping address data is unavailable.";default:return"Unable to proceed because the required data is unavailable."}}(e))||this;return n.subtype=e,n.name="MissingDataError",n.type="missing_data",n}return L(e,t),e}(c);function U(t,e){var n=t.firstName||e.firstName||"",r=t.lastName||e.lastName||"";return{addresses:(t.addresses||[]).map((function(t){return A(t)})),customerId:t.id,isGuest:t.isGuest,storeCredit:t.storeCredit,email:t.email||e.email||"",firstName:n,lastName:r,name:t.fullName||[n,r].join(" "),customerGroupName:t.customerGroup&&t.customerGroup.name}}const F=function(){function t(){}return t.prototype.format=function(t){var e=t.split(new RegExp("\\s*".concat("/","\\s*"))),n=e[0],r=void 0===n?"":n,o=e[1],i=void 0===o?"":o,a=r.slice(0,2),s=4===i.length?i.slice(-2):i?i.slice(0,2):r.slice(2);return t.length<2?r:t.length>3&&!s?a:"".concat(a," ").concat("/"," ").concat(s)},t.prototype.toObject=function(t){var e=t.split(new RegExp("\\s*".concat("/","\\s*"))),n=e[0],r=void 0===n?"":n,o=e[1],i=void 0===o?"":o;return/^\d+$/.test(r)&&/^\d+$/.test(i)?{month:1===r.length?"0".concat(r):r.slice(0,2),year:2===i.length?"20".concat(i):i.slice(0,4)}:{month:"",year:""}},t}(),q=require("card-validator"),H=function(){function t(){}return t.prototype.format=function(t){var e=(0,q.number)(t).card;if(!e)return t;var n=(0,P.max)((0,q.creditCardType)(t).map((function(t){return(0,P.max)(t.lengths)}))),r=this.unformat(t).slice(0,n);return e.gaps.filter((function(t){return r.length>t})).reduce((function(t,e,n){return[t.slice(0,e+n),t.slice(e+n)].join(" ")}),r)},t.prototype.unformat=function(t){return(0,q.number)(t).card?t.replace(new RegExp(" ","g"),""):t},t}();var B=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};function G(t,e){void 0===e&&(e={});var n,r,o=t.currency.decimalPlaces,i=new I(o);return{id:t.orderId,items:D(t.lineItems,t.currency.decimalPlaces,"productId"),orderId:t.orderId,currency:t.currency.code,customerCanBeCreated:t.customerCanBeCreated,payment:z(t.payments,e.payment),subtotal:{amount:t.baseAmount,integerAmount:i.toInteger(t.baseAmount)},coupon:{discountedAmount:(0,P.reduce)(t.coupons,(function(t,e){return t+e.discountedAmount}),0),coupons:t.coupons.map(S)},discount:{amount:t.discountAmount,integerAmount:i.toInteger(t.discountAmount)},token:e.orderToken,callbackUrl:e.callbackUrl,discountNotifications:[],giftCertificate:(n=t.payments,r=(0,P.filter)(n,{providerId:"giftcertificate"}),{totalDiscountedAmount:(0,P.reduce)(r,(function(t,e){return e.amount+t}),0),appliedGiftCertificates:(0,P.keyBy)(r.map((function(t){return{code:t.detail.code,discountedAmount:t.amount,remainingBalance:t.detail.remaining,giftCertificate:{balance:t.amount+t.detail.remaining,code:t.detail.code,purchaseDate:""}}})),"code")}),socialData:Q(t),status:t.status,hasDigitalItems:t.hasDigitalItems,isDownloadable:t.isDownloadable,isComplete:t.isComplete,shipping:{amount:t.shippingCostTotal,integerAmount:i.toInteger(t.shippingCostTotal),amountBeforeDiscount:t.shippingCostBeforeDiscount,integerAmountBeforeDiscount:i.toInteger(t.shippingCostBeforeDiscount)},storeCredit:{amount:Y(t.payments)},taxes:t.taxes,taxTotal:{amount:t.taxTotal,integerAmount:i.toInteger(t.taxTotal)},handling:{amount:t.handlingCostTotal,integerAmount:i.toInteger(t.handlingCostTotal)},grandTotal:{amount:t.orderAmount,integerAmount:t.orderAmountAsInteger}}}function Y(t){var e=(0,P.find)(t,{providerId:"storecredit"});return e?e.amount:0}function z(t,e){void 0===e&&(e={});var n,r=(0,P.find)(t,W);return r?{id:r.providerId,status:(n=r.detail.step,"PAYMENT_STATUS_".concat(n)),helpText:r.detail.instructions,returnUrl:e.returnUrl}:{}}function W(t){return"giftcertificate"!==t.providerId&&"storecredit"!==t.providerId}function Q(t){var e={};return B(B([],t.lineItems.physicalItems,!0),t.lineItems.digitalItems,!0).forEach((function(t){var n;e[t.id]=(n=t,["fb","tw","gp"].reduce((function(t,e){var r=n.socialMedia&&(0,P.find)(n.socialMedia,(function(t){return t.code===e}));return r?(t[e]={name:n.name,description:n.name,image:n.imageUrl,url:r.link,shareText:r.text,sharingLink:r.link,channelName:r.channel,channelCode:r.code},t):t}),{}))})),e}function Z(t,e){return{description:t.description,module:t.type,price:t.cost,id:t.id,selected:e,isRecommended:t.isRecommended,imageUrl:t.imageUrl,transitTime:t.transitTime}}var $=function(){return $=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},$.apply(this,arguments)};const J=function(){function t(){this._cardExpiryFormatter=new F,this._cardNumberFormatter=new H}return t.prototype.transform=function(t,e){var n,r=e.billingAddress.getBillingAddress(),o=e.checkout.getCheckout(),i=e.customer.getCustomer(),a=e.order.getOrder(),s=e.paymentMethods.getPaymentMethod(t.methodId,t.gatewayId),c=this._mapShippingAddress(e,s),u=e.consignments.getConsignments(),d=e.consignments.getShippingOption(),p=e.config.getStoreConfig(),l=e.config.getContextConfig(),f=e.instruments.getInstrumentsMeta(),h=e.paymentMethods.getPaymentMethodsMeta(),y=e.order.getOrderMeta(),m=i&&r&&U(i,r),g=f&&t.paymentData&&(n=t.paymentData,Boolean(n.instrumentId)||function(t){var e=t.formattedPayload;return!!e&&("string"==typeof e.bigpay_token||Boolean(e.bigpay_token&&e.bigpay_token.token))}(t.paymentData))?"".concat(e.payment.getPaymentToken(),", ").concat(f.vaultAccessToken):e.payment.getPaymentToken();if(!g)throw new R(j.MissingPaymentToken);return{additionalAction:t.additionalAction,authToken:g,customer:m,billingAddress:r&&A(r),shippingAddress:c&&A(c,u),shippingOption:d&&Z(d,!0),cart:o&&V(o),order:a&&G(a,y),orderMeta:y,payment:t.paymentData,paymentMethod:s&&this._transformPaymentMethod(s),quoteMeta:{request:$($({},h),{geoCountryCode:l&&l.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:(0,P.pick)(p&&p.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},t.prototype.transformWithHostedFormData=function(t,e,n){var r=e.additionalAction,o=e.authToken,i=e.checkout,a=e.config,s=e.order,c=e.orderMeta,u=e.payment,d=void 0===u?{}:u,p=e.paymentMethod,l=e.paymentMethodMeta,f=i&&i.consignments[0],h=f&&f.shippingAddress,y=f&&f.selectedShippingOption;return{additionalAction:r,authToken:o,paymentMethod:p&&this._transformPaymentMethod(p),customer:s&&s.billingAddress&&i&&U(i.customer,s.billingAddress),billingAddress:s&&s.billingAddress&&A(s.billingAddress),shippingAddress:h&&i&&A(h,i.consignments),shippingOption:y&&Z(y,!0),cart:i&&V(i),order:s&&G(s,c),orderMeta:c,payment:this._transformHostedInputValues(t,d,n),quoteMeta:{request:$($({},l),{geoCountryCode:a&&a.context.geoCountryCode})},source:"bigcommerce-checkout-js-sdk",store:a&&(0,P.pick)(a.storeConfig.storeProfile,["storeHash","storeId","storeLanguage","storeName"])}},t.prototype._transformPaymentMethod=function(t){return"multi-option"!==t.method||t.gateway?t.initializationData&&t.initializationData.gateway?$($({},t),{id:t.initializationData.gateway}):t.id===k.BRAINTREE_VENMO?$($({},t),{id:k.BRAINTREE_PAYPAL}):t:$($({},t),{gateway:t.id})},t.prototype._transformHostedInputValues=function(t,e,n){return $($({},e),"instrumentId"in e?{ccCvv:t.cardCodeVerification,ccNumber:t.cardNumberVerification&&this._cardNumberFormatter.unformat(t.cardNumberVerification),hostedFormNonce:n}:{ccCvv:t.cardCode,ccExpiry:this._cardExpiryFormatter.toObject(t.cardExpiry||""),ccName:t.cardName||"",ccNumber:this._cardNumberFormatter.unformat(t.cardNumber||""),hostedFormNonce:n})},t.prototype._mapShippingAddress=function(t,e){var n,r,o,i;if(e){var a=null===(r=null===(n=e.initializationData)||void 0===n?void 0:n.bopis)||void 0===r?void 0:r.enabled,s=null===(i=null===(o=e.initializationData)||void 0===o?void 0:o.bopis)||void 0===i?void 0:i.requiredAddress,c=t.consignments.getConsignments(),u=null==c?void 0:c.every((function(t){return t.selectedPickupOption}));if(a&&u&&"none"===s)return}return t.shippingAddress.getShippingAddress()},t}();var K=function(){return K=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},K.apply(this,arguments)};const X=function(){function t(t){this._requestSender=t}return t.prototype.submitPaymentInstrument=function(t,e){return n=this,r=void 0,i=function(){var n,r,o,i,a,s,c,u,d,p,l;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(f){switch(f.label){case 0:return n=t.providerId,r=t.currencyCode,o=t.paymentsUrl,i=t.shopperId,a=t.storeHash,s=t.vaultToken,c=e.billingAddress,u=e.instrument,d=e.defaultInstrument,p="".concat(o,"/stores/").concat(a,"/customers/").concat(i,"/stored_instruments"),l={headers:{Authorization:s,Accept:"application/vnd.bc.v1+json","Content-Type":"application/vnd.bc.v1+json"},body:JSON.stringify({instrument:{type:u.type,cardholder_name:u.cardholderName,number:u.number,expiry_month:u.expiryMonth,expiry_year:u.expiryYear,verification_value:u.verificationValue},billing_address:K(K(K(K(K(K({email:c.email,address1:c.address1},c.address2&&{address2:c.address2}),{city:c.city,postal_code:c.postalCode,country_code:c.countryCode}),c.company&&{company:c.company}),{first_name:c.firstName,last_name:c.lastName}),c.phone&&{phone:c.phone}),c.stateOrProvinceCode&&{state_or_province_code:c.stateOrProvinceCode}),provider_id:n,default_instrument:d,currency_code:r})},[4,this._requestSender.post(p,l)];case 1:return f.sent(),[2]}}))},new((o=void 0)||(o=Promise))((function(t,e){function a(t){try{c(i.next(t))}catch(t){e(t)}}function s(t){try{c(i.throw(t))}catch(t){e(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof o?n:new o((function(t){t(n)}))).then(a,s)}c((i=i.apply(n,r||[])).next())}));var n,r,o,i},t}();var tt;!function(t){t.CardCode="cardCode",t.CardCodeVerification="cardCodeVerification",t.CardExpiry="cardExpiry",t.CardName="cardName",t.CardNumber="cardNumber",t.CardNumberVerification="cardNumberVerification"}(tt||(tt={}));const et=tt;function nt(t){switch(t){case et.CardCode:return"cc-csc";case et.CardExpiry:return"cc-exp";case et.CardName:return"cc-name";case et.CardNumber:return"cc-number";default:return""}}const rt=function(){function t(t,e,n){var r=this;this._form=t,this._fieldTypes=e,this._inputAggregator=n,this._handleChange=function(t){var e=t.target;if(!e)throw new Error("Unable to get a reference to the target of the change event.");var n=r._inputAggregator.getInputs().find((function(t){return r._getAutocompleteElementId(t.getType())===e.id}));n&&n.setValue(e.value)},this._inputs=this._fieldTypes.map((function(t){return r._createInput(t)}))}return t.prototype.attach=function(){var t=this;this._inputs.forEach((function(e){return t._form.appendChild(e)}))},t.prototype.detach=function(){this._inputs.forEach((function(t){t.parentElement&&t.parentElement.removeChild(t)}))},t.prototype._createInput=function(t){var e=document.createElement("input");return e.autocomplete=nt(t),e.id=this._getAutocompleteElementId(t),e.tabIndex=-1,e.style.position="absolute",e.style.opacity="0",e.style.zIndex="-1",e.addEventListener("change",this._handleChange),e},t.prototype._getAutocompleteElementId=function(t){return"autocomplete-".concat((0,P.kebabCase)(t))},t}();var ot,it;!function(t){t.AttachRequested="HOSTED_FIELD:ATTACH_REQUESTED",t.SubmitRequested="HOSTED_FIELD:SUBMITTED_REQUESTED",t.ValidateRequested="HOSTED_FIELD:VALIDATE_REQUESTED",t.StoredCardRequested="HOSTED_FIELD:STORED_CARD_REQUESTED"}(ot||(ot={})),function(t){t.AttachSucceeded="HOSTED_INPUT:ATTACH_SUCCEEDED",t.AttachFailed="HOSTED_INPUT:ATTACH_FAILED",t.BinChanged="HOSTED_INPUT:BIN_CHANGED",t.Blurred="HOSTED_INPUT:BLURRED",t.Changed="HOSTED_INPUT:CHANGED",t.CardTypeChanged="HOSTED_INPUT:CARD_TYPE_CHANGED",t.Entered="HOSTED_INPUT:ENTERED",t.Focused="HOSTED_INPUT:FOCUSED",t.SubmitSucceeded="HOSTED_INPUT:SUBMIT_SUCCEEDED",t.SubmitFailed="HOSTED_INPUT:SUBMIT_FAILED",t.Validated="HOSTED_INPUT:VALIDATED",t.StoredCardSucceeded="HOSTED_INPUT:STORED_CARD_SUCCEEDED",t.StoredCardFailed="HOSTED_INPUT:STORED_CARD_FAILED"}(it||(it={}));const at=function(){function t(t,e,n,r,o,i,a,s,c,u,d,p,l){var f=this;this._type=t,this._form=e,this._placeholder=n,this._accessibilityLabel=r,this._autocomplete=o,this._styles=i,this._fontUrls=a,this._eventListener=s,this._eventPoster=c,this._inputAggregator=u,this._inputValidator=d,this._paymentHandler=p,this._storedCardHandler=l,this._isTouched=!1,this._handleInput=function(t){var e=t.target;f._processChange(e.value)},this._handleBlur=function(){f._applyStyles(f._styles.default),f._validateForm(),f._eventPoster.post({type:it.Blurred,payload:{fieldType:f._type}})},this._handleFocus=function(){f._applyStyles(f._styles.focus),f._eventPoster.post({type:it.Focused,payload:{fieldType:f._type}})},this._handleValidate=function(){f._validateForm()},this._handleSubmit=function(t){t.preventDefault(),f._eventPoster.post({type:it.Entered,payload:{fieldType:f._type}})},this._forceFocusToInput=function(){document.activeElement===document.body&&(navigator.userAgent.toLowerCase().indexOf("safari")>-1?""===f._input.value&&(f._input.setAttribute("value"," "),f._input.setSelectionRange(0,1),f._input.setAttribute("value","")):f._input.focus())},this._input=document.createElement("input"),this._input.addEventListener("input",this._handleInput),this._input.addEventListener("blur",this._handleBlur),this._input.addEventListener("focus",this._handleFocus),this._eventListener.addListener(ot.ValidateRequested,this._handleValidate),this._eventListener.addListener(ot.SubmitRequested,this._paymentHandler.handle),this._eventListener.addListener(ot.StoredCardRequested,this._storedCardHandler.handle),this._configureInput()}return t.prototype.getType=function(){return this._type},t.prototype.getValue=function(){return this._input.value},t.prototype.setValue=function(t){this._processChange(t)},t.prototype.isTouched=function(){return this._isTouched},t.prototype.attach=function(){this._form.appendChild(this._input),this._form.addEventListener("submit",this._handleSubmit),this._loadFonts(),this._eventPoster.setTarget(window.parent),this._eventListener.listen(),window.addEventListener("focus",this._forceFocusToInput),window.hostedInput=this,this._eventPoster.post({type:it.AttachSucceeded})},t.prototype.detach=function(){this._input.parentElement&&this._input.parentElement.removeChild(this._input),this._form.removeEventListener("submit",this._handleSubmit),this._unloadFonts(),window.removeEventListener("focus",this._forceFocusToInput),this._eventListener.stopListen()},t.prototype._formatValue=function(t){this._input.value=t},t.prototype._notifyChange=function(t){this._eventPoster.post({type:it.Changed,payload:{fieldType:this._type}})},t.prototype._configureInput=function(){switch(this._input.style.backgroundColor="transparent",this._input.style.border="0",this._input.style.display="block",this._input.style.height="100%",this._input.style.margin="0",this._input.style.outline="none",this._input.style.padding="0",this._input.style.width="100%",this._input.id=(0,P.kebabCase)(this._type),this._input.placeholder=this._placeholder,this._input.autocomplete=this._autocomplete,this._input.setAttribute("aria-label",this._accessibilityLabel),this._applyStyles(this._styles.default),this._input.id){case"card-code":case"card-expiry":case"card-number":this._input.type="text",this._input.inputMode="numeric",this._input.pattern="[0-9]*";break;case"card-name":this._input.type="text",this._input.inputMode="text"}},t.prototype._applyStyles=function(t){var e=this;void 0===t&&(t={});var n={color:t.color,fontFamily:t.fontFamily,fontSize:t.fontSize,fontWeight:t.fontWeight};Object.keys(n).forEach((function(t){n[t]&&(e._input.style[t]=n[t]||"")}))},t.prototype._loadFonts=function(){this._fontLinks||(this._fontLinks=this._fontUrls.filter((function(t){return"fonts.googleapis.com"===p(t).hostname})).filter((function(t){return!document.querySelector("link[href='".concat(t,"'][rel='stylesheet']"))})).map((function(t){var e=document.createElement("link");return e.rel="stylesheet",e.href=t,document.head.appendChild(e),e})))},t.prototype._unloadFonts=function(){this._fontLinks&&(this._fontLinks.forEach((function(t){t.parentElement&&t.parentElement.removeChild(t)})),this._fontLinks=void 0)},t.prototype._validateForm=function(){return t=this,e=void 0,r=function(){var t,e;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(n){switch(n.label){case 0:return t=this._inputAggregator.getInputValues(),[4,this._inputValidator.validate(t)];case 1:return(e=n.sent()).isValid?this._applyStyles(this._styles.default):this._applyStyles(this._styles.error),this._eventPoster.post({type:it.Validated,payload:e}),[2]}}))},new((n=void 0)||(n=Promise))((function(o,i){function a(t){try{c(r.next(t))}catch(t){i(t)}}function s(t){try{c(r.throw(t))}catch(t){i(t)}}function c(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,s)}c((r=r.apply(t,e||[])).next())}));var t,e,n,r},t.prototype._processChange=function(t){t!==this._previousValue&&(this._isTouched=!0,this._formatValue(t),this._validateForm(),this._notifyChange(t),this._previousValue=t)},t}();var st=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const ct=function(t){function e(e,n,r,o,i,a,s,c,u,d,p,l,f){var h=t.call(this,et.CardExpiry,e,n,r,o,i,a,s,c,u,d,p,l)||this;return h._formatter=f,h}return st(e,t),e.prototype._formatValue=function(t){this._input.value=this._formatter.format(t)},e}(at);var ut=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const dt=function(t){function e(e,n,r,o,i,a,s,c,u,d,p,l,f,h,y){var m=t.call(this,e,n,r,o,i,a,s,c,u,d,p,l,f)||this;return m._autocompleteFieldset=h,m._formatter=y,m}return ut(e,t),e.prototype.attach=function(){t.prototype.attach.call(this),this._autocompleteFieldset.attach()},e.prototype._notifyChange=function(t){var e=(0,q.number)(t).card,n=this._previousValue&&(0,q.number)(this._previousValue).card;(0,P.get)(n,"type")!==(0,P.get)(e,"type")&&this._eventPoster.post({type:it.CardTypeChanged,payload:{cardType:e?e.type:void 0}});var r=this._formatter.unformat(t),o=this._previousValue?this._formatter.unformat(this._previousValue):"",i=r.length>=6&&(0,q.number)(r).isPotentiallyValid?r.substr(0,6):"";i!==(o.length>=6?o.substr(0,6):"")&&this._eventPoster.post({type:it.BinChanged,payload:{bin:i}})},e.prototype._formatValue=function(t){var e=this._input.selectionEnd,n=this._formatter.format(t);e===t.length&&t.length<n.length?this._input.setSelectionRange(n.length,n.length):this._input.setSelectionRange(e||0,e||0),this._input.value=n},e}(at);var pt=function(){return pt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},pt.apply(this,arguments)},lt=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};const ft=function(){function t(t){this._parentWindow=t}return t.prototype.getInputs=function(t){return Array.prototype.slice.call(this._parentWindow.frames).reduce((function(e,n){try{var r=n.hostedInput;return!r||t&&!t(r)?e:lt(lt([],e,!0),[r],!1)}catch(t){if(t instanceof DOMException)return e;if(t instanceof Error&&"Permission denied"===t.message)return e;throw t}}),[])},t.prototype.getInputValues=function(t){return this.getInputs(t).reduce((function(t,e){var n;return pt(pt({},t),((n={})[e.getType()]=e.getValue(),n))}),{})},t}();var ht=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const yt=function(t){function e(e){var n=t.call(this,function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))}(["Unable to proceed due to invalid user input values"],(0,P.flatMap)((0,P.values)(e),(function(t){return(0,P.map)(t,(function(t){return t.message}))})),!0).join(". "))||this;return n.errors=e,n.name="InvalidHostedFormValueError",n.type="invalid_hosted_form_value",n}return ht(e,t),e}(c);const mt=function(){function t(t,e,n,r,o,i){var a=this;this._inputAggregator=t,this._inputValidator=e,this._inputStorage=n,this._eventPoster=r,this._paymentRequestSender=o,this._paymentRequestTransformer=i,this.handle=function(t){var e,n,r,o,i=t.payload.data;return e=a,n=void 0,o=function(){var t,e,n,r,o;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(a){switch(a.label){case 0:return t=this._inputAggregator.getInputValues(),[4,this._inputValidator.validate(t)];case 1:if(e=a.sent(),this._eventPoster.post({type:it.Validated,payload:e}),!e.isValid)return n=new yt(e.errors),[2,this._eventPoster.post({type:it.SubmitFailed,payload:{error:{code:(0,P.snakeCase)(n.name),message:n.message}}})];a.label=2;case 2:return a.trys.push([2,4,,5]),[4,this._paymentRequestSender.submitPayment(this._paymentRequestTransformer.transformWithHostedFormData(t,i,this._inputStorage.getNonce()||""))];case 3:return r=a.sent(),this._eventPoster.post({type:it.SubmitSucceeded,payload:{response:r}}),[3,5];case 4:return o=a.sent(),this._isPaymentErrorResponse(o)?this._eventPoster.post({type:it.SubmitFailed,payload:{error:o.body.errors[0],response:o}}):this._isErrorResponse(o)&&this._eventPoster.post({type:it.SubmitFailed,payload:{error:{code:(0,P.snakeCase)(o.name),message:o.message}}}),[3,5];case 5:return[2]}}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}c((o=o.apply(e,n||[])).next())}))}}return t.prototype._isPaymentErrorResponse=function(t){var e=(t||{}).body,n=(void 0===e?{}:e).errors,r=void 0===n?[]:n;return"string"==typeof(r[0]&&r[0].code)&&"string"==typeof(r[0]&&r[0].message)},t.prototype._isErrorResponse=function(t){return"object"==typeof t&&null!==t&&("name"in t&&"string"==typeof t.name||!("name"in t))&&("message"in t&&"string"==typeof t.message||!("message"in t))},t}();const gt=function(t,e,n,r){var o=this;this._inputAggregator=t,this._inputValidator=e,this._eventPoster=n,this._storedCardRequestSender=r,this.handle=function(t){return e=o,n=void 0,i=function(){var e,n,r,o,i,a,s,c,u,d,p;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(l){switch(l.label){case 0:return e=t.payload,n=e.data,r=e.fields,o=this._inputAggregator.getInputValues(),[4,this._inputValidator.validate(o)];case 1:if(i=l.sent(),this._eventPoster.post({type:it.Validated,payload:i}),!i.isValid)return[2,this._eventPoster.post({type:it.StoredCardFailed})];a=r.defaultInstrument,s=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(r,["defaultInstrument"]),c=o.cardExpiry?o.cardExpiry.split("/"):[],u=c[0],d=c[1],l.label=2;case 2:return l.trys.push([2,4,,5]),[4,this._storedCardRequestSender.submitPaymentInstrument(n,{billingAddress:s,instrument:{type:"card",cardholderName:o.cardName||"",number:o.cardNumber?o.cardNumber.replace(/ /g,""):"",expiryMonth:Number(u.trim()),expiryYear:Number("20".concat(d.trim())),verificationValue:null!==(p=o.cardCode)&&void 0!==p?p:""},defaultInstrument:a})];case 3:return l.sent(),this._eventPoster.post({type:it.StoredCardSucceeded}),[3,5];case 4:return l.sent(),this._eventPoster.post({type:it.StoredCardFailed}),[3,5];case 5:return[2]}}))},new((r=void 0)||(r=Promise))((function(t,o){function a(t){try{c(i.next(t))}catch(t){o(t)}}function s(t){try{c(i.throw(t))}catch(t){o(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}c((i=i.apply(e,n||[])).next())}));var e,n,r,i}},_t=require("yup");var vt=function(){return vt=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},vt.apply(this,arguments)},bt=function(t,e,n){if(n||2===arguments.length)for(var r,o=0,i=e.length;o<i;o++)!r&&o in e||(r||(r=Array.prototype.slice.call(e,0,o)),r[o]=e[o]);return t.concat(r||Array.prototype.slice.call(e))};const Ct=function(){function t(t){this._cardInstrument=t,this._completeSchema={cardCode:this._getCardCodeSchema(),cardCodeVerification:this._getCardCodeVerificationSchema(),cardExpiry:this._getCardExpirySchema(),cardName:this._getCardNameSchema(),cardNumber:this._getCardNumberSchema(),cardNumberVerification:this._getCardNumberVerificationSchema()},this._configureCardValidator()}return t.prototype.validate=function(t){return e=this,n=void 0,o=function(){var e,n,r,o;return function(t,e){var n,r,o,i,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function s(i){return function(s){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;a;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return a.label++,{value:i[1],done:!1};case 5:a.label++,r=i[1],i=[0];continue;case 7:i=a.ops.pop(),a.trys.pop();continue;default:if(!((o=(o=a.trys).length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){a=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){a.label=i[1];break}if(6===i[0]&&a.label<o[1]){a.label=o[1],o=i;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(i);break}o[2]&&a.ops.pop(),a.trys.pop();continue}i=e.call(t,a)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,s])}}}(this,(function(i){switch(i.label){case 0:for(r in e={},n={errors:{},isValid:!0},t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=this._completeSchema[r],n.errors[r]=[]);i.label=1;case 1:return i.trys.push([1,3,,4]),[4,(0,_t.object)(e).validate(t,{abortEarly:!1})];case 2:return i.sent(),[2,n];case 3:if(o=i.sent(),this._isValidationErrorType(o))throw o;return[2,{errors:Object.keys(n.errors).reduce((function(t,e){var n;return vt(vt({},t),((n={})[e]=o.inner.filter((function(t){return t.path===e})).map((function(t){return{fieldType:t.path,message:t.errors.join(" "),type:t.type}})),n))}),{}),isValid:!1}];case 4:return[2]}}))},new((r=void 0)||(r=Promise))((function(t,i){function a(t){try{c(o.next(t))}catch(t){i(t)}}function s(t){try{c(o.throw(t))}catch(t){i(t)}}function c(e){var n;e.done?t(e.value):(n=e.value,n instanceof r?n:new r((function(t){t(n)}))).then(a,s)}c((o=o.apply(e,n||[])).next())}));var e,n,r,o},t.prototype._configureCardValidator=function(){var t=q.creditCardType.getTypeInfo("discover"),e=q.creditCardType.getTypeInfo("jcb"),n=q.creditCardType.getTypeInfo("visa");q.creditCardType.updateCard("visa",{lengths:bt([13],n.lengths||[],!0)}),q.creditCardType.updateCard("discover",{patterns:bt(bt([],t.patterns||[],!0),[[810,817]],!1)}),q.creditCardType.addCard({niceType:"Mada",type:"mada",patterns:[400861,401757,407197,407395,409201,410685,412565,417633,419593,422817,422818,422819,428331,428671,428672,428673,431361,432328,434107,439954,440533,440647,440795,445564,446393,446404,446672,455036,455708,457865,458456,462220,468540,468541,468542,468543,483010,483011,483012,484783,486094,486095,486096,489317,489318,489319,493428,504300,506968,508160,513213,520058,521076,524130,524514,529415,529741,530060,530906,531095,531196,532013,535825,535989,536023,537767,539931,543085,543357,549760,554180,557606,558848,585265,588845,588846,588847,588848,588849,588850,588851,588982,588983,589005,589206,604906,605141,636120,968201,968202,968203,968204,968205,968206,968207,968208,968209,968210,968211],gaps:[4,8,12],lengths:[16,18,19],code:{name:"CVV",size:3}}),q.creditCardType.updateCard("jcb",{patterns:bt(bt([],e.patterns||[],!0),[3088,3337,3338],!1)})},t.prototype._getCardCodeSchema=function(){return(0,_t.string)().required("CVV is required").test({message:"CVV must be valid",name:"invalid_card_code",test:function(t){var e=(0,q.number)(this.parent.cardNumber||"").card;return(0,q.cvv)(t,e&&e.code?e.code.size:void 0).isValid}})},t.prototype._getCardCodeVerificationSchema=function(){var t=this;return(0,_t.string)().required("CVV is required").test({message:"CVV must be valid",name:"invalid_card_code",test:function(e){void 0===e&&(e="");var n=t._cardInstrument&&t._mapFromInstrumentCardType(t._cardInstrument.brand),r=n&&q.creditCardType.getTypeInfo(n);return(0,q.cvv)(e,r&&r.code?r.code.size:void 0).isValid}})},t.prototype._getCardExpirySchema=function(){return(0,_t.string)().required("Expiration date is required").test({message:"Expiration date must be a valid future date in MM / YY format",name:"invalid_card_expiry",test:function(t){return(0,q.expirationDate)(t).isValid}})},t.prototype._getCardNameSchema=function(){return(0,_t.string)().max(200).required("Full name is required").test({message:"Credit card name must be valid",name:"invalid_card_name",test:function(t){var e=t.replace(/\s/g,"").match(/[0-9]+/g);if(!(null==e?void 0:e.length))return!0;for(var n=0,r=e;n<r.length;n++){var o=r[n];if((0,q.number)(o).isValid)return!1}return!0}})},t.prototype._getCardNumberSchema=function(){return(0,_t.string)().required("Credit card number is required").test({message:"Credit card number must be valid",name:"invalid_card_number",test:function(t){return(0,q.number)(t).isValid}})},t.prototype._getCardNumberVerificationSchema=function(){var t=this;return(0,_t.string)().required("Credit card number is required").test({message:"Credit card number must be valid",name:"invalid_card_number",test:function(t){return void 0===t&&(t=""),(0,q.number)(t).isValid}}).test({message:"The card number entered does not match the card stored in your account",name:"mismatched_card_number",test:function(e){return void 0===e&&(e=""),!!t._cardInstrument&&e.slice(-t._cardInstrument.last4.length)===t._cardInstrument.last4}})},t.prototype._mapFromInstrumentCardType=function(t){switch(t){case"amex":case"american_express":return"american-express";case"diners":return"diners-club";default:return t}},t.prototype._isValidationErrorType=function(t){return"name"in t&&"ValidationError"!==t.name},t}(),wt=function(){function t(t){this._parentOrigin=t}return t.prototype.create=function(t,e,n,r,o,i,a){void 0===n&&(n={}),void 0===r&&(r=[]),void 0===o&&(o=""),void 0===i&&(i=function(t){switch(t){case et.CardCode:case et.CardCodeVerification:return"CVC";case et.CardExpiry:return"Expiration";case et.CardName:return"Name on card";case et.CardNumber:case et.CardNumberVerification:return"Credit card number"}}(e));var s=nt(e);return e===et.CardNumber?this._createNumberInput(e,t,n,r,o,i,s):e===et.CardNumberVerification?this._createNumberInput(e,t,n,r,o,i,s,a):e===et.CardExpiry?this._createExpiryInput(t,n,r,o,i,s):e===et.CardCodeVerification?this._createInput(e,t,n,r,o,i,s,a):this._createInput(e,t,n,r,o,i,s)},t.prototype.normalizeParentOrigin=function(t){this._parentOrigin!==t&&(this._parentOrigin!==l(p(t)).origin&&t!==l(p(this._parentOrigin)).origin||(this._parentOrigin=t))},t.prototype.getParentOrigin=function(){return this._parentOrigin},t.prototype._createExpiryInput=function(t,e,n,r,o,i){return void 0===o&&(o=""),void 0===i&&(i=""),new ct(t,r,o,i,e,n,new h(this._parentOrigin),new E(this._parentOrigin,window.parent),new ft(window.parent),new Ct,this._createPaymentHandler(),this._createStoredCardHandler(),new F)},t.prototype._createNumberInput=function(t,e,n,r,o,i,a,s){return void 0===i&&(i=""),void 0===a&&(a=""),new dt(t,e,o,i,a,n,r,new h(this._parentOrigin),new E(this._parentOrigin,window.parent),new ft(window.parent),new Ct(s),this._createPaymentHandler(s),this._createStoredCardHandler(s),new rt(e,[et.CardCode,et.CardExpiry,et.CardName],new ft(window.parent)),new H)},t.prototype._createInput=function(t,e,n,r,o,i,a,s){return void 0===i&&(i=""),void 0===a&&(a=""),new at(t,e,o,i,a,n,r,new h(this._parentOrigin),new E(this._parentOrigin,window.parent),new ft(window.parent),new Ct(s),this._createPaymentHandler(s),this._createStoredCardHandler(s))},t.prototype._createPaymentHandler=function(t){return new mt(new ft(window.parent),new Ct(t),g(),new E(this._parentOrigin,window.parent),new O((0,_.createClient)()),new J)},t.prototype._createStoredCardHandler=function(t){return new gt(new ft(window.parent),new Ct(t),new E(this._parentOrigin,window.parent),new X((0,v.createRequestSender)()))},t}();var Et=function(){var t=function(e,n){return t=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])},t(e,n)};return function(e,n){if("function"!=typeof n&&null!==n)throw new TypeError("Class extends value "+String(n)+" is not a constructor or null");function r(){this.constructor=e}t(e,n),e.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}}();const Ot=function(t){function e(e){var n=t.call(this,e||"Unable to proceed due to invalid configuration provided for the hosted payment form.")||this;return n.name="InvalidHostedFormConfigError",n.type="invalid_hosted_form_config",n}return Et(e,t),e}(c),Pt=function(){function t(t,e,n){this._factory=t,this._storage=e,this._eventListener=n}return t.prototype.initialize=function(t,e){var n=this;e&&this._storage.setNonce(e);var r=this._createFormContainer(t);return this._resetPageStyles(t),this._eventListener.listen(),(0,b.fromEvent)(this._eventListener,ot.AttachRequested).pipe((0,C.map)((function(t){var e=t.payload,o=e.accessibilityLabel,i=e.cardInstrument,a=e.fontUrls,s=e.placeholder,c=e.styles,u=e.origin,d=e.type;u&&n._factory.normalizeParentOrigin(u);var p=n._factory.create(r,d,c,a,s,o,i);return p.attach(),p})),(0,C.take)(1)).toPromise()},t.prototype._resetPageStyles=function(t){[document.querySelector("html"),document.querySelector("body"),document.getElementById(t)].forEach((function(t){t&&(t.style.height="100%",t.style.width="100%",t.style.overflow="hidden",t.style.padding="0",t.style.margin="0")}))},t.prototype._createFormContainer=function(t){var e=document.getElementById(t);if(!e)throw new Ot("Unable to proceed because the provided container ID is not valid.");var n=document.createElement("form"),r=document.createElement("button");return n.noValidate=!0,n.style.height="100%",n.style.width="100%",r.style.display="none",e.appendChild(n),n.appendChild(r),n},t}();function At(t){var e=t.containerId,n=t.nonce,r=t.parentOrigin;return new Pt(new wt(r),g(),new h(r)).initialize(e,n)}var It=new E("*",window.parent);function Tt(t){It.post({type:it.AttachFailed,payload:{error:t}})}module.exports=e})();
|
|
2
2
|
//# sourceMappingURL=hosted-form.js.map
|