@idonatedev/idonate-sdk 1.2.0-dev2 → 1.2.0-dev3

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/constants.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CLIENT_HEADERS = exports.CARD_CONNECT_DEFAULT_STYLE = exports.DEFAULT_APP_NAME = exports.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL = exports.FALLBACK_CF_TURNSTILE_SITE_KEY = exports.FALLBACK_PC_SCRIPT_ID = exports.FALLBACK_PC_SCRIPT_URL = exports.SANDBOX_APPLE_PAY_URL = exports.APPLE_PAY_URL = exports.SPREEDLY_TOKENIZER_URL = exports.SANDBOX_CARD_CONNECT_BASE_URL = exports.PRODUCTION_CARD_CONNECT_BASE_URL = exports.SANDBOX_BASE_URL = exports.PRODUCTION_BASE_URL = exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = '1.2.0-dev2';
4
+ exports.SDK_VERSION = '1.2.0-dev3';
5
5
  exports.PRODUCTION_BASE_URL = 'https://secure-api.idonate.com';
6
6
  exports.SANDBOX_BASE_URL = 'https://api.qa-idonate.com';
7
7
  exports.PRODUCTION_CARD_CONNECT_BASE_URL = 'https://boltgw.cardconnect.com:8443';
@@ -1,4 +1,4 @@
1
- export const SDK_VERSION = '1.2.0-dev2';
1
+ export const SDK_VERSION = '1.2.0-dev3';
2
2
  export const PRODUCTION_BASE_URL = 'https://secure-api.idonate.com';
3
3
  export const SANDBOX_BASE_URL = 'https://api.qa-idonate.com';
4
4
  export const PRODUCTION_CARD_CONNECT_BASE_URL = 'https://boltgw.cardconnect.com:8443';
@@ -31,6 +31,10 @@ interface PayPalApproveData {
31
31
  payerID?: string;
32
32
  facilitatorAccessToken?: string;
33
33
  }
34
+ export interface PayPalCreateOrderData {
35
+ amount: number;
36
+ currency?: string;
37
+ }
34
38
  export declare class PayPalTokenizer extends Tokenizer {
35
39
  private gateway;
36
40
  private containerId;
@@ -49,6 +53,7 @@ export declare class PayPalTokenizer extends Tokenizer {
49
53
  private clientConfig;
50
54
  private paymentTransactionId?;
51
55
  private paymentMethodId?;
56
+ private onCreateOrder?;
52
57
  private constructor();
53
58
  static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
54
59
  organizationId: string;
@@ -30,6 +30,7 @@ export class PayPalTokenizer extends Tokenizer {
30
30
  this.amount = config.amount;
31
31
  this.enableVenmo = (_b = config.enableVenmo) !== null && _b !== void 0 ? _b : true;
32
32
  this.locale = config.locale || 'en_US';
33
+ this.onCreateOrder = config.onCreateOrder;
33
34
  this.organizationId = configContext.organizationId;
34
35
  this.embedId = configContext.embedId;
35
36
  this.clientConfig = configContext.clientConfig;
@@ -160,13 +161,26 @@ export class PayPalTokenizer extends Tokenizer {
160
161
  }
161
162
  createOrder() {
162
163
  const endpoint = `${this.clientConfig.embedApiBaseUrl}/payment/paypal/create-order`;
164
+ let orderAmount;
165
+ let orderCurrency = this.currency;
166
+ if (this.onCreateOrder) {
167
+ const orderData = this.onCreateOrder();
168
+ orderAmount = orderData.amount;
169
+ orderCurrency = orderData.currency || this.currency;
170
+ }
171
+ else {
172
+ orderAmount = this.amount;
173
+ }
174
+ if (orderAmount === undefined || orderAmount <= 0) {
175
+ const error = new Error('Amount is required to create PayPal order');
176
+ this.handleError(error, 'Order creation failed');
177
+ return Promise.reject(error);
178
+ }
163
179
  const requestBody = {
164
180
  payment_gateway_id: this.gateway.id,
165
- currency: this.currency,
181
+ currency: orderCurrency,
182
+ amount: orderAmount,
166
183
  };
167
- if (this.amount !== undefined) {
168
- requestBody.amount = this.amount;
169
- }
170
184
  return fetch(endpoint, {
171
185
  method: 'POST',
172
186
  headers: {
@@ -2,6 +2,6 @@ import * as iats from './iats';
2
2
  export { Tokenizer } from './Tokenizer';
3
3
  export { SpreedlyTokenizer } from './SpreedlyTokenizer';
4
4
  export { CardConnectTokenizer } from './CardConnectTokenizer';
5
- export { PayPalTokenizer } from './PayPalTokenizer';
5
+ export { PayPalTokenizer, PayPalCreateOrderData } from './PayPalTokenizer';
6
6
  export { PaymentMethodType, PaymentGateway, TokenizerContainer, TokenizerStyling, CardData, PaymentData, PaymentToken, CardType, TokenizerEvent, ValidationState, ValidationResult, ValidationError, TokenizationError, } from './types';
7
7
  export { iats };
@@ -31,6 +31,10 @@ interface PayPalApproveData {
31
31
  payerID?: string;
32
32
  facilitatorAccessToken?: string;
33
33
  }
34
+ export interface PayPalCreateOrderData {
35
+ amount: number;
36
+ currency?: string;
37
+ }
34
38
  export declare class PayPalTokenizer extends Tokenizer {
35
39
  private gateway;
36
40
  private containerId;
@@ -49,6 +53,7 @@ export declare class PayPalTokenizer extends Tokenizer {
49
53
  private clientConfig;
50
54
  private paymentTransactionId?;
51
55
  private paymentMethodId?;
56
+ private onCreateOrder?;
52
57
  private constructor();
53
58
  static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
54
59
  organizationId: string;
@@ -33,6 +33,7 @@ class PayPalTokenizer extends Tokenizer_1.Tokenizer {
33
33
  this.amount = config.amount;
34
34
  this.enableVenmo = (_b = config.enableVenmo) !== null && _b !== void 0 ? _b : true;
35
35
  this.locale = config.locale || 'en_US';
36
+ this.onCreateOrder = config.onCreateOrder;
36
37
  this.organizationId = configContext.organizationId;
37
38
  this.embedId = configContext.embedId;
38
39
  this.clientConfig = configContext.clientConfig;
@@ -163,13 +164,26 @@ class PayPalTokenizer extends Tokenizer_1.Tokenizer {
163
164
  }
164
165
  createOrder() {
165
166
  const endpoint = `${this.clientConfig.embedApiBaseUrl}/payment/paypal/create-order`;
167
+ let orderAmount;
168
+ let orderCurrency = this.currency;
169
+ if (this.onCreateOrder) {
170
+ const orderData = this.onCreateOrder();
171
+ orderAmount = orderData.amount;
172
+ orderCurrency = orderData.currency || this.currency;
173
+ }
174
+ else {
175
+ orderAmount = this.amount;
176
+ }
177
+ if (orderAmount === undefined || orderAmount <= 0) {
178
+ const error = new Error('Amount is required to create PayPal order');
179
+ this.handleError(error, 'Order creation failed');
180
+ return Promise.reject(error);
181
+ }
166
182
  const requestBody = {
167
183
  payment_gateway_id: this.gateway.id,
168
- currency: this.currency,
184
+ currency: orderCurrency,
185
+ amount: orderAmount,
169
186
  };
170
- if (this.amount !== undefined) {
171
- requestBody.amount = this.amount;
172
- }
173
187
  return fetch(endpoint, {
174
188
  method: 'POST',
175
189
  headers: {
@@ -2,6 +2,6 @@ import * as iats from './iats';
2
2
  export { Tokenizer } from './Tokenizer';
3
3
  export { SpreedlyTokenizer } from './SpreedlyTokenizer';
4
4
  export { CardConnectTokenizer } from './CardConnectTokenizer';
5
- export { PayPalTokenizer } from './PayPalTokenizer';
5
+ export { PayPalTokenizer, PayPalCreateOrderData } from './PayPalTokenizer';
6
6
  export { PaymentMethodType, PaymentGateway, TokenizerContainer, TokenizerStyling, CardData, PaymentData, PaymentToken, CardType, TokenizerEvent, ValidationState, ValidationResult, ValidationError, TokenizationError, } from './types';
7
7
  export { iats };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idonatedev/idonate-sdk",
3
3
  "author": "iDonate",
4
- "version": "1.2.0-dev2",
4
+ "version": "1.2.0-dev3",
5
5
  "sideEffects": false,
6
6
  "description": "iDonate Web SDK",
7
7
  "engines": {
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.idonate=t():e.idonate=t()}(self,()=>(()=>{"use strict";var e={115:(e,t)=>{function n(){const e=new Date;return new Promise((t,n)=>{!function i(){void 0!==window.grecaptcha&&void 0!==window.grecaptcha.render?t(window.grecaptcha):(new Date).valueOf()-e.valueOf()>15e3?n(new Error("grecaptcha not loaded after 15 seconds")):setTimeout(i,250)}()})}Object.defineProperty(t,"__esModule",{value:!0}),t.RecaptchaElement=void 0,t.injectScript=function(e){if(void 0!==window.grecaptcha)throw new Error("grecaptcha is already defined");const t=document.createElement("script");t.src="https://www.google.com/recaptcha/api.js?render=explicit",t.async=!0,t.defer=!0,t.onload=e||null,"interactive"===document.readyState||"complete"===document.readyState?document.body.appendChild(t):window.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(t)})},t.wrapElement=function(e,t,n){const r=Object.assign(Object.assign({},n||{}),{sitekey:t}),o=new i(e,r);return o.render(),o};class i{constructor(e,t){this.container=e,this.params=t,this.executeResolveQueue=[]}render(){return void 0!==this.widgetId&&console.warn("rendering an already-rendered widget"),n().then(e=>{this.widgetId=e.render(this.container,Object.assign(Object.assign({},this.params),{callback:e=>{var t;this.resolvedToken=e,null===(t=this.executeResolveQueue.pop())||void 0===t||t(e)},"expired-callback":()=>{this.resolvedToken=void 0}}))})}resolveToken(){return new Promise((e,t)=>{n().then(n=>{if("invisible"!==this.params.size){const i=n.getResponse();return i?e(i):t(new Error("checkbox recaptcha is not checked"))}this.executeResolveQueue.push(e),void 0!==this.resolvedToken&&(this.resolvedToken=void 0,n.reset(this.widgetId)),n.execute(this.widgetId)}).catch(e=>{t(e)})})}}t.RecaptchaElement=i},122:function(e,t){var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.handleCFChallenge=void 0;let i=null;t.handleCFChallenge=(e,t)=>new Promise((e,r)=>n(void 0,void 0,void 0,function*(){var n,o,a;try{const r=null===window||void 0===window?void 0:window.document;if(!r||!window)throw new Error("document is not present on window");const o=r.createElement("div"),a=r.createElement("div"),s=n=>{var i;null===(i=null==n?void 0:n.render)||void 0===i||i.call(n,"#iDonateTurnstileBox",{sitekey:t.config.turnstileSiteKey,callback(t,n){o.remove(),e({token:t,preClearance:n})}})};if(window.idonateTurnstileLoadedHandler=()=>{const e=window.turnstile;a.innerHTML="",e&&(i=e),s(e)},o.setAttribute("id","idonateTurnstileWrapper"),o.style.position="fixed",o.style.top="0",o.style.bottom="0",o.style.left="0",o.style.right="0",o.style.backgroundColor="rgba(0,0,0,0.9)",o.style.transition="all 400ms",o.style.display="flex",o.style.flexDirection="column",o.style.padding="40px 30px",o.style.opacity="0",o.style.color="white",o.style.fontFamily="sans-serif",o.style.zIndex="1000",o.innerHTML='<h1 id="idonateTurnstileVerificationHeader">Last tiny step before we submit your payment:</h1>',a.setAttribute("id","iDonateTurnstileBox"),o.append(a),r.body.append(o),i)s(i);else{const e=r.createElement("script");a.innerHTML="loading ...",e.src=t.config.turnstileCdnUrl+"?render=explicit&onload=idonateTurnstileLoadedHandler",r.body.append(e)}null===(n=a.scrollIntoView)||void 0===n||n.call(a),o.style.opacity="1"}catch(e){null===(o=null===console||void 0===console?void 0:console.error)||void 0===o||o.call(console,e),null===(a=null===console||void 0===console?void 0:console.warn)||void 0===a||a.call(console,"iDonate SDK: Could not handle request, please reload the page and try again"),r(null)}}))},138:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.PayPalTokenizer=void 0;const r=n(415),o=n(367),a="paypal-sdk-script";class s extends r.Tokenizer{constructor(e,t,n,i){var r,o;super(),this.gateway=e,this.containerId=t,this.configContext=i,this.mode="credit_card";const a=e.config;if(!(null==a?void 0:a.client_id))throw new Error("PayPal gateway configuration missing client_id");this.clientId=a.client_id,this.sandboxMode=null!==(r=a.sandbox_mode)&&void 0!==r&&r,this.currency=n.currency||"USD",this.amount=n.amount,this.enableVenmo=null===(o=n.enableVenmo)||void 0===o||o,this.locale=n.locale||"en_US",this.organizationId=i.organizationId,this.embedId=i.embedId,this.clientConfig=i.clientConfig}static create(e,t,n){return i(this,void 0,void 0,function*(){const i=new s(e,t.containerId,t,n);return yield i.init(),i})}init(){return i(this,void 0,void 0,function*(){if(this.containerEl=document.getElementById(this.containerId),!this.containerEl)throw new Error(`Container element not found: ${this.containerId}`);return this.containerEl.innerHTML="",Object.assign(this.containerEl.style,{display:"flex",flexDirection:"column",gap:"0.5rem",alignItems:"stretch"}),new Promise((e,t)=>{const n=setTimeout(()=>{t(new Error("PayPal SDK initialization timeout"))},1e4);this.loadPayPalSDK().then(()=>(clearTimeout(n),this.renderButtons())).then(()=>{this.emit("ready"),this.emit("validation",{isValid:!0}),e()}).catch(e=>{clearTimeout(n),this.emit("error",new o.TokenizationError("Failed to initialize PayPal","INIT_FAILED")),t(e)})})})}loadPayPalSDK(){return i(this,void 0,void 0,function*(){if(window.paypal)return Promise.resolve();if(document.getElementById(a))return this.waitForPayPalGlobal();const e=new URLSearchParams({"client-id":this.clientId,currency:this.currency,intent:"capture"}),t=["card","paylater"];this.enableVenmo?e.set("enable-funding","venmo"):t.push("venmo"),e.set("disable-funding",t.join(","));const n=document.createElement("script");return n.id=a,n.src=`https://www.paypal.com/sdk/js?${e.toString()}`,n.async=!0,new Promise((e,t)=>{n.onload=()=>{this.waitForPayPalGlobal().then(e).catch(t)},n.onerror=()=>{t(new Error("Failed to load PayPal SDK"))},document.head.appendChild(n)})})}waitForPayPalGlobal(){return i(this,arguments,void 0,function*(e=5e3){const t=Date.now();for(;Date.now()-t<e;){if(window.paypal)return Promise.resolve();yield new Promise(e=>setTimeout(e,100))}throw new Error("Timeout waiting for PayPal SDK to load")})}renderButtons(){return i(this,void 0,void 0,function*(){if(!window.paypal)throw new Error("PayPal SDK not loaded");if(!this.containerEl)throw new Error("Container element not found");this.paypalButtonContainer=document.createElement("div"),this.paypalButtonContainer.id=`${this.containerId}-buttons`,this.paypalButtonContainer.style.minHeight="40px",this.containerEl.appendChild(this.paypalButtonContainer),yield this.renderPayPalButtons()})}renderPayPalButtons(){return i(this,void 0,void 0,function*(){if(!window.paypal||!this.paypalButtonContainer)return;const e=window.paypal.Buttons({createOrder:()=>this.createOrder(),onApprove:e=>this.handleApprove(e),onCancel:e=>this.handleCancel(e),onError:e=>this.handleError(e,"PayPal error"),style:{layout:"vertical",shape:"rect",height:40}});yield e.render(this.paypalButtonContainer)})}createOrder(){const e=`${this.clientConfig.embedApiBaseUrl}/payment/paypal/create-order`,t={payment_gateway_id:this.gateway.id,currency:this.currency};return void 0!==this.amount&&(t.amount=this.amount),fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{if(!e.orderId)throw new Error("Order creation failed: missing orderId");return this.paymentTransactionId=e.payment_transaction_id,this.paymentMethodId=e.payment_method_id,e.orderId}).catch(e=>{throw this.handleError(e,"Order creation failed"),e})}handleApprove(e){return i(this,void 0,void 0,function*(){const t={token:e.orderID,lastFour:e.orderID.slice(-4),provider:"paypal_checkout",paymentMethodId:this.paymentMethodId,paymentTransactionId:this.paymentTransactionId};this.cachedToken=t,this.emit("validation",{isValid:!0,hasToken:!0}),this.emit("tokenReady",t)})}handleCancel(e){this.emit("error",new o.TokenizationError("Payment cancelled by user","USER_CANCELLED"))}handleError(e,t){const n=(null==e?void 0:e.message)||(null==e?void 0:e.toString())||"Unknown error";this.emit("error",new o.TokenizationError(`${t}: ${n}`,(null==e?void 0:e.code)||"PAYPAL_ERROR"))}tokenize(e){return i(this,void 0,void 0,function*(){if(!this.isReady)throw new Error("Tokenizer not initialized");if(this.cachedToken)return this.cachedToken;throw new o.TokenizationError("No PayPal order approved. User must click PayPal or Venmo button to complete payment.","NO_TOKEN")})}validate(){return i(this,void 0,void 0,function*(){return{isValid:!0,errors:[]}})}clear(){this.cachedToken=void 0,this.emit("validation",{isValid:!0,hasToken:!1})}focus(e){}destroy(){this.containerEl&&(this.containerEl.innerHTML=""),this.eventHandlers.clear(),this.cachedToken=void 0}hasToken(){return!!this.cachedToken}getToken(){return this.cachedToken||null}get tokenizationMode(){return"auto"}}t.PayPalTokenizer=s},156:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buildCashPaymentPayload=function(e,t){var n,i,r,o,a,s,d,l,c,u,h,p,m,y,b,v,f;const g={country:t.billingAddress.country,address1:t.billingAddress.address1,address2:t.billingAddress.address2,city:t.billingAddress.city,state:t.billingAddress.state,zip_code:t.billingAddress.zip},E={title:t.billingContact.salutation,first_name:t.billingContact.firstName,middle_name:t.billingContact.middleName,last_name:t.billingContact.lastName,company_name:t.billingContact.company,email:t.billingContact.email,home_phone:t.billingContact.primaryPhone,timezone:(new Intl.DateTimeFormat).resolvedOptions().timeZone},_={payment_method_id:t.paymentMethodId,payment_transaction_id:t.paymentTransactionId,gateway_id:t.paymentGatewayId,amount:t.paymentAmount,type:"cash",frequency:t.recurringFrequency,start_date:t.recurringStart,end_date:t.recurringEnd,retain_on_success:t.retainPaymentMethod},N={organization_id:e,campaign_id:t.campaignId,reference_code:t.referenceCode,double_the_donation_company_id:t.corporateMatchingId,donor_id:t.donorId,hide_name:t.anonymousOptIn,show_name_to_fundraiser:t.showNameToFundraiserOptIn,email_opt_in:t.emailOptIn,donor_paid_fee:t.donorPaidFeeAmount,designation_note:t.designationNote,gift_id:t.giftId,gift_extra:t.giftExtra,gift_skipped:t.giftSkipped,p2p_fundraiser_id:t.p2pFundraiserId,p2p_fundraiser_comment:t.p2pFundraiserComment,organization_event_id:t.organizationEventId,advocate_id:t.advocateId,advocacy_program_id:t.advocacyProgramId,advocacy_team_id:t.advocacyTeamId,page_id:t.landingPageId,embed_id:t.embedId,tribute_definition_id:null===(n=t.tribute)||void 0===n?void 0:n.tributeDefinitionId,tribute_recipient_first_name:null===(i=t.tribute)||void 0===i?void 0:i.tributeFirstName,tribute_recipient_last_name:null===(r=t.tribute)||void 0===r?void 0:r.tributeLastName,tribute_address1:null===(o=t.tribute)||void 0===o?void 0:o.tributeAddress1,tribute_address2:null===(a=t.tribute)||void 0===a?void 0:a.tributeAddress2,tribute_city:null===(s=t.tribute)||void 0===s?void 0:s.tributeCity,tribute_state:null===(d=t.tribute)||void 0===d?void 0:d.tributeState,tribute_postal_code:null===(l=t.tribute)||void 0===l?void 0:l.tributePostalCode,tribute_country:null===(c=t.tribute)||void 0===c?void 0:c.tributeCountry,tribute_from_name:null===(u=t.tribute)||void 0===u?void 0:u.tributeFromName,tribute_recipient_email:null===(h=t.tribute)||void 0===h?void 0:h.tributeRecipientEmail,honorees:null===(p=t.tribute)||void 0===p?void 0:p.honorees,tribute_send_card:null===(m=t.tribute)||void 0===m?void 0:m.tributeSendCard,tribute_include_amount:null===(y=t.tribute)||void 0===y?void 0:y.tributeIncludeAmount,tribute_skipped:null===(b=t.tribute)||void 0===b?void 0:b.tributeSkipped,tribute_type:null===(v=t.tribute)||void 0===v?void 0:v.tributeType,useOnBillingAddress:null===(f=t.tribute)||void 0===f?void 0:f.useOnBillingAddress,embed_referer:window.location.href,converted_to_recurring:t.convertedToRecurring};t.designations?N.designations=t.designations:N.designations=[],t.designationId&&N.designations.push({id:t.designationId,amount:t.paymentAmount});const I={};return t.utm&&(t.utm.campaign&&(I.utm_campaign=t.utm.campaign),t.utm.content&&(I.utm_content=t.utm.content),t.utm.medium&&(I.utm_medium=t.utm.medium),t.utm.source&&(I.utm_source=t.utm.source),t.utm.term&&(I.utm_term=t.utm.term)),t.customerMeta&&[1,2,3,4,5].forEach(e=>{const n=`custom_note_${e}`;t.customerMeta[n]&&(N[n]=t.customerMeta[n],delete t.customerMeta[n])}),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},N),g),E),_),I),{customer_meta:t.customerMeta||{},recaptcha_token:t.recaptchaToken,recaptcha_type:t.recaptchaType})},t.buildDonationResult=function(e){let t,n,i,r,o;return e._raw_response.transaction&&(o=e._raw_response.transaction),e._raw_response.schedule&&(r=e._raw_response.schedule),e._raw_response.donor&&(i=e._raw_response.donor),e._raw_response.designation&&(n=e._raw_response.designation),e._raw_response.campaign&&(t=e._raw_response.campaign),Object.assign(Object.assign({},e),{campaign:t,designation:n,donor:i,schedule:r,transaction:o})},t.buildCreatePaymentMethodPayload=function(e){return{gateway_id:e.paymentGatewayId,backend_name:e.backendName,payment_method_type:e.paymentMethodType,payment_method_token:e.paymentMethodToken,donor_id:e.donorId,first_name:e.contact.firstName,last_name:e.contact.lastName,company:e.contact.company,email:e.contact.email,phone:e.contact.primaryPhone,country:e.address.country,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip_code:e.address.zip,embed_id:e.embedId,recaptcha_token:e.recaptchaToken,recaptcha_type:e.recaptchaType}},t.collapseClientErrors=function(e){return new i.ClientError(e.map(e=>e.message).join("\n "),{_rawPayload:e})},t.buildCreatePaymentMethodResult=function(e){return Object.assign(Object.assign({},e),{paymentMethodId:e._raw_response.result.id})},t.unpackSpreedlyResponse=function(e){return e.json().then(e=>{if(e.errors)throw new i.ClientError(e.errors.map(e=>e.message).join("\n "),e);return e})},t.extractSpreedlyToken=function(e){if(!e.transaction||!e.transaction.payment_method)throw new i.ClientError("Payment Method not tokenized.");return e.transaction.payment_method.token};const i=n(523)},247:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CLIENT_HEADERS=t.CARD_CONNECT_DEFAULT_STYLE=t.DEFAULT_APP_NAME=t.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL=t.FALLBACK_CF_TURNSTILE_SITE_KEY=t.FALLBACK_PC_SCRIPT_ID=t.FALLBACK_PC_SCRIPT_URL=t.SANDBOX_APPLE_PAY_URL=t.APPLE_PAY_URL=t.SPREEDLY_TOKENIZER_URL=t.SANDBOX_CARD_CONNECT_BASE_URL=t.PRODUCTION_CARD_CONNECT_BASE_URL=t.SANDBOX_BASE_URL=t.PRODUCTION_BASE_URL=t.SDK_VERSION=void 0,t.SDK_VERSION="1.2.0-dev2",t.PRODUCTION_BASE_URL="https://secure-api.idonate.com",t.SANDBOX_BASE_URL="https://api.qa-idonate.com",t.PRODUCTION_CARD_CONNECT_BASE_URL="https://boltgw.cardconnect.com:8443",t.SANDBOX_CARD_CONNECT_BASE_URL="https://boltgw-uat.cardconnect.com",t.SPREEDLY_TOKENIZER_URL="https://core.spreedly.com/v1/payment_methods.json",t.APPLE_PAY_URL="https://apple-pay-gateway.apple.com/paymentservices/paymentSession",t.SANDBOX_APPLE_PAY_URL="https://apple-pay-gateway-cert.apple.com/paymentservices/paymentSession",t.FALLBACK_PC_SCRIPT_URL="https://p.idonate.com/r",t.FALLBACK_PC_SCRIPT_ID="_3fd4dad26e8c277bc50fb2ddf8233b50bc8d9704",t.FALLBACK_CF_TURNSTILE_SITE_KEY="0x4AAAAAAAxuRxNZTvX8shIj",t.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL="https://challenges.cloudflare.com/turnstile/v0/api.js",t.DEFAULT_APP_NAME="unnamed-sdk-client",t.CARD_CONNECT_DEFAULT_STYLE="\nbody {\n margin: 0;\n}\n\nform {\n display: flex;\n}\n\nlabel#cccardlabel {\n display: none;\n}\n\nbr {\n display: none;\n}\n\nlabel#cccvvlabel {\n display: none;\n}\n\nlabel#ccexpirylabel {\n display: none;\n}\n\ninput {\n padding: 10px;\n}\n\nselect {\n padding: 10px;\n font-size: 14px;\n color: #8b959d;\n}\n\nselect#ccexpirymonth {\n margin-right: -30px;\n border: 1px solid #b6b8ba;\n border-right: 0;\n}\n\ninput#ccnumfield {\n width: 70%;\n border: 1px solid #b6b8ba;\n border-right: 0;\n border-top-left-radius: 3px;\n border-bottom-left-radius: 3px;\n font-size: 14px;\n color: #8b959d;\n}\n\nselect#ccexpiryyear {\n border: 1px solid #b6b8ba;\n border-right: 0;\n}\n\ninput#cccvvfield {\n border: 1px solid #b6b8ba;\n border-top-right-radius: 3px;\n border-bottom-right-radius: 3px;\n font-size: 14px;\n color: #8b959d;\n}\n".replace(/\s+/gi," "),t.CLIENT_HEADERS={"User-Agent":navigator.userAgent+` idonate-sdk@${t.SDK_VERSION}`,"Content-Type":"application/json"}},367:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TokenizationError=void 0;class n extends Error{constructor(e,t){super("string"==typeof e?e:e.map(e=>e.message||e).join(", ")),this.name="TokenizationError",this.code=t,Array.isArray(e)?this.errors=e.map(e=>({field:e.field||e.attribute||"unknown",message:e.message||e.error||String(e),code:e.code||e.key})):this.errors=[{field:"cardNumber",message:e,code:t}]}}t.TokenizationError=n},415:function(e,t,n){var i,r=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return o(t,e),t}),s=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.Tokenizer=void 0;const d=n(631);t.Tokenizer=class{constructor(){this.mode="credit_card",this.eventHandlers=new Map,this._isReady=!1}get isReady(){return this._isReady}getMode(){return this.mode}on(e,t){if(this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t),"ready"===e&&this._isReady)try{t()}catch(e){}}off(e,t){const n=this.eventHandlers.get(e);n&&n.delete(t)}emit(e,t){"ready"===e&&(this._isReady=!0);const n=this.eventHandlers.get(e);n&&n.forEach(e=>{try{e(t)}catch(e){}})}isCardData(e){return"credit_card"===this.mode}isBankAccountData(e){return"bank_account"===this.mode}normalizeCardType(e){return{visa:"visa",mastercard:"mastercard",master:"mastercard",americanexpress:"amex",amex:"amex",discover:"discover",dinersclub:"diners",diners:"diners",jcb:"jcb"}[e.toLowerCase().replace(/[\s-_]/g,"")]||"unknown"}addExpiryFormatter(e){e&&(e.addEventListener("input",e=>{const t=e.target;t.value=(0,d.formatExpiryInput)(t.value),this.emit("change",{field:"expiry"})}),e.addEventListener("keypress",e=>{const t=String.fromCharCode(e.which);/[0-9\/]/.test(t)||8===e.which||e.preventDefault()}))}parseExpiry(e){return(null==e?void 0:e.value)?(0,d.parseExpiryDate)(e.value):null}applyInputStyles(e,t,n){const i=t.input,r="0"===t.container.gap;if(Object.assign(e.style,{height:i.height,padding:i.padding,fontSize:i.fontSize,fontFamily:i.fontFamily,backgroundColor:i.backgroundColor,color:i.color,boxSizing:"border-box",width:"100%",transition:i.transition}),r&&n){switch(e.style.borderTop=i.border,e.style.borderBottom=i.border,n){case"left":case"middle":e.style.borderLeft=i.border,e.style.borderRight="none";break;case"right":e.style.borderLeft=i.border,e.style.borderRight=i.border}e.style.borderRadius=(0,d.getConnectedBorderRadius)(i.borderRadius,n,!0)}else e.style.border=i.border,e.style.borderRadius=i.borderRadius;(0,d.addFocusHandlers)(e,t)}generateFieldIds(e){return{numberId:`${e}-card-number`,expiryId:`${e}-expiry`,cvvId:`${e}-cvv`}}static create(e,t,i){return s(this,void 0,void 0,function*(){switch(e.backend_name){case"spreedly":{const{SpreedlyTokenizer:r}=yield Promise.resolve().then(()=>a(n(875)));return r.create(e,t,i)}case"card_connect":{const{CardConnectTokenizer:r}=yield Promise.resolve().then(()=>a(n(601)));return r.create(e,t,i)}case"paypal_checkout":{const{PayPalTokenizer:r}=yield Promise.resolve().then(()=>a(n(138)));return r.create(e,t,i)}default:throw new Error(`Unsupported payment backend: ${e.backend_name}`)}})}}},454:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_UNIFIED_STYLES=void 0,t.mergeStyles=function(e,t){return t?{input:Object.assign(Object.assign({},e.input),t.input),focus:Object.assign(Object.assign({},e.focus),t.focus),error:Object.assign(Object.assign({},e.error),t.error),container:Object.assign(Object.assign({},e.container),t.container)}:e},t.getContainerStylesForLayout=function(e,t="single-line"){return"two-line"===t?Object.assign(Object.assign({},e),{container:Object.assign(Object.assign({},e.container),{flexWrap:"wrap",rowGap:e.container.rowGap||e.container.gap})}):e},t.DEFAULT_UNIFIED_STYLES={input:{height:"40px",padding:"10px 12px",fontSize:"14px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',color:"#333",backgroundColor:"white",border:"1px solid #ccc",borderRadius:"4px",boxSizing:"border-box",width:"100%",transition:"all 0.15s ease-in-out"},focus:{borderColor:"#007bff",outline:"none",boxShadow:"0 0 0 2px rgba(0, 123, 255, 0.25)"},error:{borderColor:"#dc3545"},container:{display:"flex",gap:"1rem",alignItems:"center",flexWrap:"nowrap",rowGap:"1rem"}}},472:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.receiveEmbedData=function(){let e;return new Promise((t,n)=>{window.parent||n("Cannot receive data without parent"),e=e=>{let n;try{n=JSON.parse(e.data)}catch(e){return}n.embedData&&t(n.embedData)},window.addEventListener("message",e)}).then(t=>(window.removeEventListener("message",e),t))},t.sanitizeString=o,t.sanitizeArray=a,t.sanitizeObject=s,t.splitName=function(e){const t=e.split(" ");return{firstName:t.slice(0,-1).join(" ")||"NOT GIVEN",lastName:t.slice(-1).join(" ")}},t.parseResponse=function(e,t){return e.json().then(n=>{const o=[];if(200!==e.status&&(void 0!==n.result&&Object.keys(n.result).forEach(e=>{o.push(new i.ClientError(e+": "+n.result[e].join("\n "),{field:e}))}),void 0!==n.messages?n.messages.forEach(e=>{"error"===e.category&&o.push(new i.ClientError(e.message))}):o.push(new i.ClientError(n.message))),t&&t.throwErrors&&o.length)throw(0,r.collapseClientErrors)(o);return{errors:o,_raw_response:n}})};const i=n(523),r=n(156);function o(e){if(!e)return e;const t=document.createElement("div");t.innerHTML=e;const n=Array.from(t.getElementsByTagName("script"));for(const e of n)e.parentNode&&e.parentNode.removeChild(e);return t.innerHTML}function a(e){return e.map(s)}function s(e){if(null==e)return e;if(Array.isArray(e))return a(e);if("string"==typeof e)return o(e);if("object"==typeof e){const t={};for(const[n,i]of Object.entries(e))Array.isArray(i)?t[n]=a(i):t[n]="string"==typeof i?o(i):s(i);return t}return e}},523:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientError=t.ApplePaySessionStatus=void 0,t.ApplePaySessionStatus={STATUS_SUCCESS:"undefined"!=typeof ApplePaySession?ApplePaySession.STATUS_SUCCESS:1,STATUS_FAILURE:"undefined"!=typeof ApplePaySession?ApplePaySession.STATUS_FAILURE:0};class n extends Error{constructor(e,t){super(e),this.message=e,this.details=t,Error.captureStackTrace&&Error.captureStackTrace(this,n)}}t.ClientError=n},578:function(e,t,n){var i,r=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.iats=t.TokenizationError=t.PayPalTokenizer=t.CardConnectTokenizer=t.SpreedlyTokenizer=t.Tokenizer=void 0;const s=a(n(903));t.iats=s;var d=n(415);Object.defineProperty(t,"Tokenizer",{enumerable:!0,get:function(){return d.Tokenizer}});var l=n(875);Object.defineProperty(t,"SpreedlyTokenizer",{enumerable:!0,get:function(){return l.SpreedlyTokenizer}});var c=n(601);Object.defineProperty(t,"CardConnectTokenizer",{enumerable:!0,get:function(){return c.CardConnectTokenizer}});var u=n(138);Object.defineProperty(t,"PayPalTokenizer",{enumerable:!0,get:function(){return u.PayPalTokenizer}});var h=n(367);Object.defineProperty(t,"TokenizationError",{enumerable:!0,get:function(){return h.TokenizationError}})},592:function(e,t){var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.fetchSpreedlySecurityArgs=function(e,t,i){return n(this,void 0,void 0,function*(){if(!e.enableSpreedlySecureTokenization)throw new Error("Secure tokenization is not enabled");const r=()=>n(this,void 0,void 0,function*(){const n=yield fetch(`${e.embedApiBaseUrl}/spreedly/security-args`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organization_id:t,embed_id:i})});if(!n.ok)throw new Error(`Security args request failed: ${n.status}`);return n.json()});try{return yield r()}catch(e){if(e instanceof TypeError&&e.message.includes("fetch"))return yield new Promise(e=>setTimeout(e,1e3)),r();throw e}})}},601:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CardConnectTokenizer=void 0;const o=n(415),a=n(367),s=r(n(731)),d=n(454),l=n(799),c=n(631);class u extends o.Tokenizer{constructor(e,t,n,i="credit_card",r=!1,o="single-line"){super(),this.iframeUrl=t,this.containerId=n,this.layout=o,this.enableTestMode=!1,this.mode=i,this.enableTestMode=r,this.iframe=e;const a=new URL(t);this.expectedOrigin=`${a.protocol}//${a.host}`,this.currentValidationState={isValid:!1,cardNumber:{isValid:!1,isEmpty:!0},cvv:{isValid:!1,isEmpty:!0},expiry:{isValid:!1,isEmpty:!0}}}static create(e,t,n){return i(this,void 0,void 0,function*(){var i;if("bank_account"===t.mode&&"CA"===t.bankCountry)throw new Error("CardConnect does not support Canadian bank accounts");let r=(null===(i=e.config)||void 0===i?void 0:i.base_url)||n.clientConfig.cardConnectBaseUrl;n.cardConnectBaseUrl=r;const o=(0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,t.styling),a=u.generateIframeUrl(r,t),s=u.createIframe(a,o),l=new u(s,a,t.containerId,t.mode||"credit_card",t.enableTestMode||!1,t.layout||"single-line");return l.createInternalElements(t),yield l.init(),l})}createInternalElements(e){const t=document.getElementById(e.containerId);if(!t)throw new Error(`Container element not found: ${e.containerId}`);this.containerEl=t,t.innerHTML="";const n=(0,d.getContainerStylesForLayout)((0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,e.styling),this.layout);Object.assign(t.style,n.container),"bank_account"===this.mode?this.createBankAccountFields(t,n):this.createCreditCardFields(t,n)}createCreditCardFields(e,t){if(this.iframe.style.width="100%","two-line"===this.layout){const e=t.input.height||"40px";this.iframe.style.height=`calc((${e}) * 2 + 10px)`}else this.iframe.style.height=t.input.height||"40px";this.iframe.style.border="none",this.iframe.style.display="block",e.appendChild(this.iframe)}createBankAccountFields(e,t){this.iframe.style.display="none","two-line"===this.layout?(this.accountTypeEl=(0,c.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:"1",minWidth:l.BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,t,"left"),e.appendChild(this.accountTypeEl),this.routingNumberEl=(0,c.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:"1",minWidth:l.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,t,"right"),e.appendChild(this.routingNumberEl),this.accountNumberEl=(0,c.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:"1",flexBasis:"100%",minWidth:l.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,t),e.appendChild(this.accountNumberEl)):(this.routingNumberEl=(0,c.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:l.BANK_FIELD_FLEX.routingNumber.flex,minWidth:l.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,t,"left"),e.appendChild(this.routingNumberEl),this.accountNumberEl=(0,c.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:l.BANK_FIELD_FLEX.accountNumber.flex,minWidth:l.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,t,"middle"),e.appendChild(this.accountNumberEl),this.accountTypeEl=(0,c.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:l.BANK_FIELD_FLEX.accountType.flex,minWidth:l.BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,t,"right"),e.appendChild(this.accountTypeEl))}init(){return i(this,void 0,void 0,function*(){return"bank_account"===this.mode?(this.enableTestMode&&setTimeout(()=>{this.routingNumberEl&&(this.routingNumberEl.value="021000021",this.routingNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountNumberEl&&(this.accountNumberEl.value="9876543210",this.accountNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountTypeEl&&(this.accountTypeEl.value="checking",this.accountTypeEl.dispatchEvent(new Event("change",{bubbles:!0})))},100),this.emit("ready"),Promise.resolve()):new Promise((e,t)=>{const n=setTimeout(()=>{t(new Error("CardConnect initialization timeout"))},l.INIT_TIMEOUT);this.messageHandler=e=>{e.origin===this.expectedOrigin&&this.handleMessage(e)},window.addEventListener("message",this.messageHandler),this.iframe.onload=()=>{clearTimeout(n),this.enableTestMode&&this.mode,this.emit("ready"),e()},this.iframe.onerror=()=>{clearTimeout(n),t(new Error("Failed to load CardConnect iframe"))}})})}tokenize(e){return i(this,void 0,void 0,function*(){if(!this.isReady)throw new Error("Tokenizer not initialized");if("credit_card"===this.mode&&this.hasToken()){const e=this.getToken();if(e)return e}return"bank_account"===this.mode||this.isBankAccountData(e)?this.tokenizeBankAccountInternal(e):this.tokenizeCardInternal(e)})}tokenizeCardInternal(e){return i(this,void 0,void 0,function*(){return this.cachedTokenResult&&"0"===this.cachedTokenResult.errorCode?{token:this.cachedTokenResult.token,lastFour:this.cachedTokenResult.token.slice(-4),cardType:this.normalizeCardType("unknown"),provider:"cardconnect"}:(this.tokenizationPromise||(this.tokenizationPromise=new Promise((e,t)=>{this.tokenizationResolve=e,this.tokenizationReject=t;const n=setTimeout(()=>{this.tokenizationPromise=void 0,this.tokenizationResolve=void 0,this.tokenizationReject=void 0,t(new a.TokenizationError("Tokenization timeout - ensure all card fields are filled in iframe","TIMEOUT"))},l.TOKENIZE_TIMEOUT),i=e=>{clearTimeout(n),this.off("tokenization",i)};this.on("tokenization",i)})),this.tokenizationPromise)})}tokenizeBankAccountInternal(e){return i(this,void 0,void 0,function*(){var e,t,n;const i=null===(e=this.routingNumberEl)||void 0===e?void 0:e.value,r=null===(t=this.accountNumberEl)||void 0===t?void 0:t.value,o=(null===(n=this.accountTypeEl)||void 0===n?void 0:n.value)||"checking";if(!i||!r)throw new a.TokenizationError("Routing number and account number are required","VALIDATION_ERROR");if(!(0,c.validateRoutingNumber)(i))throw new a.TokenizationError("Invalid routing number","VALIDATION_ERROR");if(!(0,c.validateAccountNumber)(r))throw new a.TokenizationError("Invalid account number","VALIDATION_ERROR");const d=new URL(this.iframeUrl).origin,l=new s.default({});return l.cardConnectBaseUrl=d,{token:(yield u.tokenizeBankAccount(i,r,l)).token,lastFour:r.slice(-4),accountType:o,paymentMethodType:"bank_account",provider:"cardconnect"}})}validate(){return i(this,void 0,void 0,function*(){if(!this.isReady)throw new Error("Tokenizer not initialized");return"bank_account"===this.mode?this.validateBankAccountInternal():this.validateCardInternal()})}validateCardInternal(){return i(this,void 0,void 0,function*(){const e=[];return this.currentValidationState.cardNumber?this.currentValidationState.cardNumber.isEmpty?e.push({field:"cardNumber",message:"Card number is required"}):this.currentValidationState.cardNumber.isValid||e.push({field:"cardNumber",message:"Invalid card number"}):e.push({field:"cardNumber",message:"Card number is required"}),this.currentValidationState.expiry?this.currentValidationState.expiry.isEmpty?e.push({field:"expiry",message:"Expiry date is required"}):this.currentValidationState.expiry.isValid||e.push({field:"expiry",message:"Invalid expiry date"}):e.push({field:"expiry",message:"Expiry date is required"}),this.currentValidationState.cvv?this.currentValidationState.cvv.isEmpty?e.push({field:"cvv",message:"CVV is required"}):this.currentValidationState.cvv.isValid||e.push({field:"cvv",message:"Invalid CVV"}):e.push({field:"cvv",message:"CVV is required"}),{isValid:this.currentValidationState.isValid,errors:e}})}validateBankAccountInternal(){return i(this,void 0,void 0,function*(){var e,t;const n=[];return(null===(e=this.routingNumberEl)||void 0===e?void 0:e.value)?(0,c.validateRoutingNumber)(this.routingNumberEl.value)||n.push({field:"routingNumber",message:"Invalid routing number"}):n.push({field:"routingNumber",message:"Routing number is required"}),(null===(t=this.accountNumberEl)||void 0===t?void 0:t.value)?(0,c.validateAccountNumber)(this.accountNumberEl.value)||n.push({field:"accountNumber",message:"Invalid account number"}):n.push({field:"accountNumber",message:"Account number is required"}),{isValid:0===n.length,errors:n}})}clear(){var e;"bank_account"===this.mode?(this.routingNumberEl&&(this.routingNumberEl.value=""),this.accountNumberEl&&(this.accountNumberEl.value=""),this.accountTypeEl&&(this.accountTypeEl.value="checking")):null===(e=this.iframe.contentWindow)||void 0===e||e.postMessage({action:"clear"},this.expectedOrigin),this.currentValidationState={isValid:!1,cardNumber:{isValid:!1,isEmpty:!0},cvv:{isValid:!1,isEmpty:!0},expiry:{isValid:!1,isEmpty:!0}},this.emit("validation",this.currentValidationState)}focus(e){var t;if("bank_account"===this.mode)"routingNumber"===e&&this.routingNumberEl?this.routingNumberEl.focus():"accountNumber"===e&&this.accountNumberEl&&this.accountNumberEl.focus();else{const n={cardNumber:"number",cvv:"cvv",expiry:"expiry"}[e];n&&(null===(t=this.iframe.contentWindow)||void 0===t||t.postMessage({action:"focus",field:n},this.expectedOrigin))}}destroy(){this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.containerEl&&(this.containerEl.innerHTML=""),this.eventHandlers.clear()}hasToken(){var e,t;return"credit_card"===this.mode&&"0"===(null===(e=this.cachedTokenResult)||void 0===e?void 0:e.errorCode)&&!!(null===(t=this.cachedTokenResult)||void 0===t?void 0:t.token)}getToken(){var e;if("credit_card"===this.mode&&"0"===(null===(e=this.cachedTokenResult)||void 0===e?void 0:e.errorCode)){const e=this.cachedTokenResult.cardType?this.normalizeCardType(this.cachedTokenResult.cardType):this.normalizeCardType("unknown");return{token:this.cachedTokenResult.token,lastFour:this.cachedTokenResult.last4||this.cachedTokenResult.token.slice(-4),cardType:e,provider:"cardconnect"}}return null}get tokenizationMode(){return"credit_card"===this.mode?"auto":"manual"}handleMessage(e){try{const t="string"==typeof e.data?JSON.parse(e.data):e.data;if(t.token&&void 0!==t.errorCode)if(this.cachedTokenResult=t,this.emit("tokenization",t),"0"===t.errorCode){const e=t.cardType?this.normalizeCardType(t.cardType):this.normalizeCardType("unknown");t.cardType&&e!==this.currentCardType&&(this.currentCardType=e,this.emit("cardTypeChange",{cardType:e}));const n={token:t.token,lastFour:t.last4||t.token.slice(-4),cardType:e,provider:"cardconnect"};this.tokenizationResolve&&(this.tokenizationResolve(n),this.tokenizationPromise=void 0,this.tokenizationResolve=void 0,this.tokenizationReject=void 0),this.currentValidationState={isValid:!0,cardNumber:{isValid:!0,isEmpty:!1},cvv:{isValid:!0,isEmpty:!1},expiry:{isValid:!0,isEmpty:!1}},this.emit("validation",{isValid:!0}),this.emit("tokenReady",n)}else this.tokenizationReject&&(this.tokenizationReject(new a.TokenizationError(t.errorMessage||"Tokenization failed",t.errorCode||"UNKNOWN")),this.tokenizationPromise=void 0,this.tokenizationResolve=void 0,this.tokenizationReject=void 0);if("validation"!==t.event&&void 0===t.validationError||this.handleValidationMessage(t),"focus"!==t.event&&"blur"!==t.event||this.emit(t.event,{field:t.data}),("input"===t.event||"change"===t.event)&&(this.emit("change",{field:t.data}),t.cardType)){const e=this.normalizeCardType(t.cardType);e!==this.currentCardType&&(this.currentCardType=e,this.emit("cardTypeChange",{cardType:e}))}}catch(e){}}handleValidationMessage(e){var t,n,i,r,o,s;if(e.validationError){const t=e.validationError.toLowerCase();t.includes("card")||t.includes("number")?this.currentValidationState.cardNumber={isValid:!1,isEmpty:!1}:t.includes("cvv")||t.includes("security")?this.currentValidationState.cvv={isValid:!1,isEmpty:!1}:(t.includes("expir")||t.includes("month")||t.includes("year"))&&(this.currentValidationState.expiry={isValid:!1,isEmpty:!1}),this.emit("error",new a.TokenizationError(e.validationError))}this.currentValidationState.isValid=null!==(n=null===(t=this.currentValidationState.cardNumber)||void 0===t?void 0:t.isValid)&&void 0!==n&&n&&null!==(r=null===(i=this.currentValidationState.cvv)||void 0===i?void 0:i.isValid)&&void 0!==r&&r&&null!==(s=null===(o=this.currentValidationState.expiry)||void 0===o?void 0:o.isValid)&&void 0!==s&&s}static generateIframeUrl(e,t){const n=new URLSearchParams({invalidinputevent:"true",enhancedresponse:"true",useexpiry:"true",usecvv:"true",formatinput:"true",unique:"true",norsa:"true",placeholder:"Card Number *",placeholdercvv:"CVV",invalidcreditcardevent:"true",invalidexpiry:"true",invalidcvv:"true"});"two-line"===t.layout?(n.set("useexpiryfield","true"),n.set("orientation","horizontal"),n.set("placeholdermonth","MM"),n.set("placeholderyear","YYYY")):(n.set("orientation","horizontal"),n.set("placeholdermonth","MM"),n.set("placeholderyear","YYYY"));const i=(0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,t.styling),r=u.generateCardConnectCss(i,t.layout||"single-line"),o=[];return n.forEach((e,t)=>{o.push(`${encodeURIComponent(t)}=${encodeURIComponent(e)}`)}),o.push(`css=${r}`),`${e}/itoke/ajax-tokenizer.html?${o.join("&")}`}static createIframe(e,t){const n=document.createElement("iframe");return n.src=e,n.style.width="100%",n.style.height=t.input.height,n.style.border="none",n.style.overflow="hidden",n.style.display="block",n.style.minWidth="0",t.container&&(Object.entries(t.container).forEach(([e,t])=>{"height"!==e&&"width"!==e&&(n.style[e]=t)}),t.container.width&&(n.style.width=t.container.width)),n.setAttribute("scrolling","no"),n.setAttribute("title","Secure card input"),n.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),n}static generateCardConnectCss(e,t="single-line"){var n,i,r,o;const a=[];"two-line"===t?(a.push("html,form,body{margin:0;padding:0;}"),a.push("label{display:none;}"),a.push("br{display:none;}")):(a.push("body{margin:0;padding:0;display:flex;align-items:center;}"),a.push("form{margin:0;padding:0;display:flex;width:100%;align-items:center;}"),a.push("label{display:none;}"),a.push("br{display:none;}"));const s="0"===e.container.gap,d=s?"0":e.container.gap||"1rem";if(e.input){const t=[];e.input.height&&t.push(`height:${e.input.height}`),e.input.padding&&t.push(`padding:${e.input.padding}`),e.input.fontSize&&t.push(`font-size:${e.input.fontSize}`),e.input.fontFamily&&t.push(`font-family:${e.input.fontFamily}`),e.input.border&&t.push(`border:${e.input.border}`),e.input.backgroundColor&&t.push(`background-color:${e.input.backgroundColor}`),e.input.color&&t.push(`color:${e.input.color}`),t.push("box-sizing:border-box");const n=t.join(";");a.push(`input{${n};}`),a.push(`select{${n};}`)}if("two-line"===t)a.push("input#ccnumfield{width:100%;display:block;margin-bottom:8px;}"),a.push("input#ccexpiryfieldmonth{width:20%;}"),a.push("input#ccexpiryfieldyear{width:24%;}"),a.push("input#cccvvfield{width:calc(56% - 20px);}"),(null===(n=e.input)||void 0===n?void 0:n.borderRadius)&&a.push(`input{border-radius:${e.input.borderRadius};}`);else if(s)a.push("input#ccnumfield{width:44%;margin:0;}"),a.push("select#ccexpirymonth{width:16%;margin:0;margin-right:-12px;}"),a.push("select#ccexpiryyear{width:20%;}"),a.push("input#cccvvfield{width:20%;margin:0;margin-left:-12px;}"),(null===(i=e.input)||void 0===i?void 0:i.borderRadius)?(a.push(`input#ccnumfield{border-radius:${e.input.borderRadius} 0 0 ${e.input.borderRadius};border-right:none;}`),a.push("select#ccexpirymonth{border-radius:0;border-right:none;}"),a.push("select#ccexpiryyear{border-radius:0;border-right:none;}"),a.push(`input#cccvvfield{border-radius:0 ${e.input.borderRadius} ${e.input.borderRadius} 0;}`)):(a.push("input#ccnumfield{border-right:none;}"),a.push("select#ccexpirymonth{border-right:none;}"),a.push("select#ccexpiryyear{border-right:none;}"));else{const t="0"===d?"0":"8px";a.push(`input#ccnumfield{width:50%;margin-right:${t};}`),a.push(`select#ccexpirymonth{width:15%;margin-right:${t};}`),a.push(`select#ccexpiryyear{width:20%;margin-right:${t};}`),a.push("input#cccvvfield{width:15%;}"),(null===(r=e.input)||void 0===r?void 0:r.borderRadius)&&a.push(`input,select{border-radius:${e.input.borderRadius};}`)}if(e.focus){const t=[];e.focus.borderColor&&t.push(`border-color:${e.focus.borderColor}`),e.focus.outline&&t.push("outline:none"),e.focus.boxShadow&&t.push(`box-shadow:${e.focus.boxShadow}`),t.length>0&&(a.push(`input:focus{${t.join(";")};}`),a.push(`select:focus{${t.join(";")};}`),s&&(null===(o=e.input)||void 0===o?void 0:o.border)&&(a.push(`input#ccnumfield:focus{border:${e.input.border};${t.join(";")};}`),a.push(`select#ccexpirymonth:focus{border:${e.input.border};${t.join(";")};}`),a.push(`select#ccexpiryyear:focus{border:${e.input.border};${t.join(";")};}`)))}if(e.error){const t=[];e.error.borderColor&&t.push(`border-color:${e.error.borderColor}`),e.error.backgroundColor&&t.push(`background-color:${e.error.backgroundColor}`),t.length>0&&a.push(`.error{${t.join(";")};}`)}return encodeURIComponent(a.join(""))}static tokenizeBankAccount(e,t,n){return fetch(`${n.cardConnectBaseUrl}/cardsecure/api/v1/ccn/tokenize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:`${e}/${t}`,unique:!0})}).then(e=>e.json())}}t.CardConnectTokenizer=u},611:(e,t,n)=>{var i;n.r(t),n.d(t,{NIL:()=>P,parse:()=>b,stringify:()=>c,v1:()=>y,v3:()=>S,v4:()=>w,v5:()=>k,validate:()=>s,version:()=>O});var r=new Uint8Array(16);function o(){if(!i&&!(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(r)}const a=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&a.test(e)};for(var d=[],l=0;l<256;++l)d.push((l+256).toString(16).substr(1));const c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(d[e[t+0]]+d[e[t+1]]+d[e[t+2]]+d[e[t+3]]+"-"+d[e[t+4]]+d[e[t+5]]+"-"+d[e[t+6]]+d[e[t+7]]+"-"+d[e[t+8]]+d[e[t+9]]+"-"+d[e[t+10]]+d[e[t+11]]+d[e[t+12]]+d[e[t+13]]+d[e[t+14]]+d[e[t+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n};var u,h,p=0,m=0;const y=function(e,t,n){var i=t&&n||0,r=t||new Array(16),a=(e=e||{}).node||u,s=void 0!==e.clockseq?e.clockseq:h;if(null==a||null==s){var d=e.random||(e.rng||o)();null==a&&(a=u=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==s&&(s=h=16383&(d[6]<<8|d[7]))}var l=void 0!==e.msecs?e.msecs:Date.now(),y=void 0!==e.nsecs?e.nsecs:m+1,b=l-p+(y-m)/1e4;if(b<0&&void 0===e.clockseq&&(s=s+1&16383),(b<0||l>p)&&void 0===e.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");p=l,m=y,h=s;var v=(1e4*(268435455&(l+=122192928e5))+y)%4294967296;r[i++]=v>>>24&255,r[i++]=v>>>16&255,r[i++]=v>>>8&255,r[i++]=255&v;var f=l/4294967296*1e4&268435455;r[i++]=f>>>8&255,r[i++]=255&f,r[i++]=f>>>24&15|16,r[i++]=f>>>16&255,r[i++]=s>>>8|128,r[i++]=255&s;for(var g=0;g<6;++g)r[i+g]=a[g];return t||c(r)},b=function(e){if(!s(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};function v(e,t,n){function i(e,i,r,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof i&&(i=b(i)),16!==i.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(i),a.set(e,i.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,r){o=o||0;for(var s=0;s<16;++s)r[o+s]=a[s];return r}return c(a)}try{i.name=e}catch(e){}return i.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",i.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",i}function f(e){return 14+(e+64>>>9<<4)+1}function g(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function E(e,t,n,i,r,o){return g((a=g(g(t,e),g(i,o)))<<(s=r)|a>>>32-s,n);var a,s}function _(e,t,n,i,r,o,a){return E(t&n|~t&i,e,t,r,o,a)}function N(e,t,n,i,r,o,a){return E(t&i|n&~i,e,t,r,o,a)}function I(e,t,n,i,r,o,a){return E(t^n^i,e,t,r,o,a)}function T(e,t,n,i,r,o,a){return E(n^(t|~i),e,t,r,o,a)}const S=v("v3",48,function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,i="0123456789abcdef",r=0;r<n;r+=8){var o=e[r>>5]>>>r%32&255,a=parseInt(i.charAt(o>>>4&15)+i.charAt(15&o),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[f(t)-1]=t;for(var n=1732584193,i=-271733879,r=-1732584194,o=271733878,a=0;a<e.length;a+=16){var s=n,d=i,l=r,c=o;n=_(n,i,r,o,e[a],7,-680876936),o=_(o,n,i,r,e[a+1],12,-389564586),r=_(r,o,n,i,e[a+2],17,606105819),i=_(i,r,o,n,e[a+3],22,-1044525330),n=_(n,i,r,o,e[a+4],7,-176418897),o=_(o,n,i,r,e[a+5],12,1200080426),r=_(r,o,n,i,e[a+6],17,-1473231341),i=_(i,r,o,n,e[a+7],22,-45705983),n=_(n,i,r,o,e[a+8],7,1770035416),o=_(o,n,i,r,e[a+9],12,-1958414417),r=_(r,o,n,i,e[a+10],17,-42063),i=_(i,r,o,n,e[a+11],22,-1990404162),n=_(n,i,r,o,e[a+12],7,1804603682),o=_(o,n,i,r,e[a+13],12,-40341101),r=_(r,o,n,i,e[a+14],17,-1502002290),n=N(n,i=_(i,r,o,n,e[a+15],22,1236535329),r,o,e[a+1],5,-165796510),o=N(o,n,i,r,e[a+6],9,-1069501632),r=N(r,o,n,i,e[a+11],14,643717713),i=N(i,r,o,n,e[a],20,-373897302),n=N(n,i,r,o,e[a+5],5,-701558691),o=N(o,n,i,r,e[a+10],9,38016083),r=N(r,o,n,i,e[a+15],14,-660478335),i=N(i,r,o,n,e[a+4],20,-405537848),n=N(n,i,r,o,e[a+9],5,568446438),o=N(o,n,i,r,e[a+14],9,-1019803690),r=N(r,o,n,i,e[a+3],14,-187363961),i=N(i,r,o,n,e[a+8],20,1163531501),n=N(n,i,r,o,e[a+13],5,-1444681467),o=N(o,n,i,r,e[a+2],9,-51403784),r=N(r,o,n,i,e[a+7],14,1735328473),n=I(n,i=N(i,r,o,n,e[a+12],20,-1926607734),r,o,e[a+5],4,-378558),o=I(o,n,i,r,e[a+8],11,-2022574463),r=I(r,o,n,i,e[a+11],16,1839030562),i=I(i,r,o,n,e[a+14],23,-35309556),n=I(n,i,r,o,e[a+1],4,-1530992060),o=I(o,n,i,r,e[a+4],11,1272893353),r=I(r,o,n,i,e[a+7],16,-155497632),i=I(i,r,o,n,e[a+10],23,-1094730640),n=I(n,i,r,o,e[a+13],4,681279174),o=I(o,n,i,r,e[a],11,-358537222),r=I(r,o,n,i,e[a+3],16,-722521979),i=I(i,r,o,n,e[a+6],23,76029189),n=I(n,i,r,o,e[a+9],4,-640364487),o=I(o,n,i,r,e[a+12],11,-421815835),r=I(r,o,n,i,e[a+15],16,530742520),n=T(n,i=I(i,r,o,n,e[a+2],23,-995338651),r,o,e[a],6,-198630844),o=T(o,n,i,r,e[a+7],10,1126891415),r=T(r,o,n,i,e[a+14],15,-1416354905),i=T(i,r,o,n,e[a+5],21,-57434055),n=T(n,i,r,o,e[a+12],6,1700485571),o=T(o,n,i,r,e[a+3],10,-1894986606),r=T(r,o,n,i,e[a+10],15,-1051523),i=T(i,r,o,n,e[a+1],21,-2054922799),n=T(n,i,r,o,e[a+8],6,1873313359),o=T(o,n,i,r,e[a+15],10,-30611744),r=T(r,o,n,i,e[a+6],15,-1560198380),i=T(i,r,o,n,e[a+13],21,1309151649),n=T(n,i,r,o,e[a+4],6,-145523070),o=T(o,n,i,r,e[a+11],10,-1120210379),r=T(r,o,n,i,e[a+2],15,718787259),i=T(i,r,o,n,e[a+9],21,-343485551),n=g(n,s),i=g(i,d),r=g(r,l),o=g(o,c)}return[n,i,r,o]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(f(t)),i=0;i<t;i+=8)n[i>>5]|=(255&e[i/8])<<i%32;return n}(e),8*e.length))}),w=function(e,t,n){var i=(e=e||{}).random||(e.rng||o)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return c(i)};function C(e,t,n,i){switch(e){case 0:return t&n^~t&i;case 1:case 3:return t^n^i;case 2:return t&n^t&i^n&i}}function A(e,t){return e<<t|e>>>32-t}const k=v("v5",80,function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var i=unescape(encodeURIComponent(e));e=[];for(var r=0;r<i.length;++r)e.push(i.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,a=Math.ceil(o/16),s=new Array(a),d=0;d<a;++d){for(var l=new Uint32Array(16),c=0;c<16;++c)l[c]=e[64*d+4*c]<<24|e[64*d+4*c+1]<<16|e[64*d+4*c+2]<<8|e[64*d+4*c+3];s[d]=l}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var u=0;u<a;++u){for(var h=new Uint32Array(80),p=0;p<16;++p)h[p]=s[u][p];for(var m=16;m<80;++m)h[m]=A(h[m-3]^h[m-8]^h[m-14]^h[m-16],1);for(var y=n[0],b=n[1],v=n[2],f=n[3],g=n[4],E=0;E<80;++E){var _=Math.floor(E/20),N=A(y,5)+C(_,b,v,f)+g+t[_]+h[E]>>>0;g=f,f=v,v=A(b,30)>>>0,b=y,y=N}n[0]=n[0]+y>>>0,n[1]=n[1]+b>>>0,n[2]=n[2]+v>>>0,n[3]=n[3]+f>>>0,n[4]=n[4]+g>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}),P="00000000-0000-0000-0000-000000000000",O=function(e){if(!s(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}},631:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseExpiryDate=function(e){const t=e.split("/");if(2!==t.length)return null;const n=t[0],i=t[1];return 2!==n.length||2!==i.length?null:{month:n,year:"20"+i}},t.formatExpiryInput=function(e){let t=e.replace(/\D/g,"");return t=t.substring(0,4),t.length>=2?t.substring(0,2)+"/"+t.substring(2,4):t},t.withTimeout=function(e,t,n){return Promise.race([e,new Promise((e,i)=>setTimeout(()=>i(new Error(n)),t))])},t.getConnectedBorderRadius=function(e,t,n){if(!n)return e;switch(t){case"left":return`${e} 0 0 ${e}`;case"middle":return"0";case"right":return`0 ${e} ${e} 0`;default:return e}},t.addFocusHandlers=function(e,t,n,i){e.addEventListener("focus",()=>{t.focus&&Object.assign(e.style,t.focus),null==n||n()}),e.addEventListener("blur",()=>{e.style.border=t.input.border,e.style.outline="none",e.style.boxShadow="none",null==i||i()})},t.createFieldContainer=function(e,t,n,i){const r=document.createElement("div");return r.id=e,r.style.flex=t,r.style.display="flex",n&&(r.style.minWidth=n),i&&(r.style.maxWidth=i),r},t.createInputElement=function(e,t,n,i){const r=document.createElement("input");return r.id=e,r.type=t,r.placeholder=n,i&&(r.maxLength=i),r},t.validateRoutingNumber=function(e){const t=e.replace(/\D/g,"");if(9!==t.length)return!1;const n=t.split("").map(Number);return(3*n[0]+7*n[1]+1*n[2]+3*n[3]+7*n[4]+1*n[5]+3*n[6]+7*n[7]+1*n[8])%10==0},t.validateAccountNumber=function(e){const t=e.replace(/\D/g,"");return!(t.length<4||t.length>17)&&/^\d+$/.test(t)},t.maskAccountNumber=function(e){const t=e.replace(/\D/g,"");if(t.length<=4)return t;const n=t.slice(-4);return"*".repeat(t.length-4)+n},t.createAccountTypeSelect=function(e){const t=document.createElement("select");t.id=e;const n=document.createElement("option");n.value="checking",n.text="Checking";const i=document.createElement("option");return i.value="savings",i.text="Savings",t.appendChild(n),t.appendChild(i),t},t.validateInstitutionNumber=function(e){return 3===e.replace(/\D/g,"").length},t.validateTransitNumber=function(e){return 5===e.replace(/\D/g,"").length},t.validateCanadianAccountNumber=function(e){return e.replace(/\D/g,"").length>=7},t.formatCanadianRoutingNumber=function(e,t){return"0"+e.replace(/\D/g,"").padStart(3,"0")+t.replace(/\D/g,"").padStart(5,"0")}},712:function(e,t,n){var i,r=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return o(t,e),t}),s=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const l=n(523),c=n(156),u=n(247),h=n(472),p=d(n(953)),m=d(n(731)),y=n(875),b=a(n(777)),v=n(611),f=n(122),g=n(578),E={enableSandboxMode:!1,overrideBaseUrl:void 0,enableDelay:!1,secondsToDelay:0};t.default=class{get organizationId(){if(!this.currentOrganizationId)throw new Error("organizationId undefined");return this.currentOrganizationId}constructor(e,t,n){var i;this.clientKey=e,"string"==typeof t?this.embedId=t:(this.embedConfigCache=t,this.embedId=t.embed_id||"",t.organization_id&&(this.currentOrganizationId=t.organization_id)),this.currentOrganizationId||(this.currentOrganizationId=e),this.options=Object.assign({},E,n),this.allowTransaction=!1,this.config=new m.default(this.options);const r=Object.entries(this.config);for(const[e,t]of r){const n=Object.getOwnPropertyDescriptor(this,e);if(!n||void 0!==n.set)try{this[e]=t}catch(e){}}if(this.options.enableDelay&&this.options.secondsToDelay){const e=1e3*this.options.secondsToDelay;setTimeout(()=>{this.allowTransaction=!0},e)}else this.allowTransaction=!0;this.options.enableSandboxMode&&void 0!==console&&console.info(`[Sandbox] iDonate SDK Configuration (v${u.SDK_VERSION}):`,JSON.parse(JSON.stringify(this)));try{const{pcScriptBase:e,pcScriptId:t}=this.config;if(!e||!t)throw new Error("missing config");const n=(0,v.v4)(),i=window.document.createElement("script");i.setAttribute("src",e+"/"+n+".js"),i.setAttribute("id",t);let r=!1;const o=()=>{var e;try{if(r)return;window.document.body.append(i),r=!0}catch(t){null===(e=null===console||void 0===console?void 0:console.warn)||void 0===e||e.call(console,"not appended")}};o(),window.addEventListener("DOMContentLoaded",()=>{window.document.body.append(i)})}catch(e){null===(i=null===console||void 0===console?void 0:console.warn)||void 0===i||i.call(console,"Warning, partial initialization: ",String(e))}this.currentOrganizationId||this.setOrganizationId(this.clientKey)}createDonation(e){if(!this.allowTransaction)throw new Error("Wow, that was fast - try again");e.embedId||(e.embedId=this.embedId);const t=(0,c.buildCashPaymentPayload)(this.organizationId,e),n=e=>fetch(`${this.config.embedApiBaseUrl}/donate/cash-payment`,{method:"POST",headers:Object.assign(Object.assign(Object.assign({},u.CLIENT_HEADERS),e?{"cf-validation-token":e}:{}),{"User-Agent":u.CLIENT_HEADERS["User-Agent"]+" source:"+this.config.client}),body:JSON.stringify(t),credentials:"include"});return n().then(e=>s(this,void 0,void 0,function*(){if("challenge"===e.headers.get("cf-mitigated")){const t=yield(0,f.handleCFChallenge)(e,this);return n(null==t?void 0:t.token)}return e})).then(e=>(0,h.parseResponse)(e,{throwErrors:!0})).then(e=>(0,c.buildDonationResult)(e))}createTransaction(e){return this.createDonation(e).then(e=>{var t;return{transactionId:null===(t=e.transaction)||void 0===t?void 0:t.id,_raw_response:e._raw_response}})}createPaymentMethod(e){return e.embedId||(e.embedId=this.embedId),b.createPaymentMethod(e,this.config)}setOrganizationId(e){this.currentOrganizationId=e}waitForDonationResult(e,t){return new Promise((n,i)=>{setTimeout(()=>{let r;r=setInterval(()=>{fetch(`${this.config.embedApiBaseUrl}/donate/cash-payment/${e}/payment_status`,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>e.result).then(e=>{(function(e){return!!e.processed&&!!e.transaction})(e)&&(r&&(clearInterval(r),r=null),e.error&&i(new l.ClientError(e.error)),n((0,c.buildDonationResult)({_raw_response:Object.assign({campaign:null,designation:{},donor:{},form_data:{},id:null,schedule:{},transaction:{}},e)}))),null==t||t()}).catch(e=>{r&&(clearInterval(r),r=null),i(e)})},2e3)},2e3)})}tokenizeCardConnectApplePay(e){const t=new p.default(e);let n="";const i=t.begin();return new Promise((e,r)=>{i.then(i=>{i.onvalidatemerchant=e=>{const o={apple_pay_url:this.config.applePayUrl,organization_id:this.organizationId};t.createSession(o,this.config.embedApiBaseUrl).then(e=>{n=e.result.merchantSessionIdentifier,i.completeMerchantValidation(e.result)}).catch(e=>{i.abort(),r(e)})},i.onpaymentauthorized=o=>{t.tokenizeWithCardConnect(o.payment,this.config.cardConnectBaseUrl).then(t=>{var r,a;const s=Object.assign(Object.assign({},o.payment.billingContact),{email:null===(r=o.payment.shippingContact)||void 0===r?void 0:r.emailAddress,phone:null===(a=o.payment.shippingContact)||void 0===a?void 0:a.phoneNumber});e({applePaySession:i,cardConnectResponse:t,billingContact:s,merchantSessionId:n})}).catch(e=>{i.abort(),r(e)})},i.oncancel=e=>{r(new Error("Apple Pay has been closed"))}}).catch(e=>r(e))})}createTokenizer(e,t){return s(this,void 0,void 0,function*(){return g.Tokenizer.create(e,t,{organizationId:this.organizationId,embedId:this.embedId,clientConfig:this.config})})}tokenizeSpreedlyPayPal(e){return y.SpreedlyTokenizer.tokenizePayPal(e,this.config)}selectGateway(e,t,n){if(n){const t=e.find(e=>e.id===n);if(t)return t}return e[0]}getEmbedConfig(){return s(this,void 0,void 0,function*(){return this.embedConfigCache?this.embedConfigCache:(this.embedConfigPromise||(this.embedConfigPromise=b.fetchEmbedConfig(this.embedId,this.config).then(e=>(this.embedConfigCache=e,e))),this.embedConfigPromise)})}getGateway(e){return s(this,void 0,void 0,function*(){const t=yield this.getEmbedConfig(),n=t.available_gateways.find(t=>t.id===e);if(!n)throw new Error(`Gateway ${e} not found in embed configuration. Available: ${t.available_gateways.map(e=>e.id).join(", ")}`);return n})}}},731:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=n(247);t.default=class{constructor(e){e.enableSandboxMode?(this.apiBaseUrl=i.SANDBOX_BASE_URL,this.cardConnectBaseUrl=i.SANDBOX_CARD_CONNECT_BASE_URL,this.applePayUrl=i.SANDBOX_APPLE_PAY_URL):(this.apiBaseUrl=i.PRODUCTION_BASE_URL,this.cardConnectBaseUrl=i.PRODUCTION_CARD_CONNECT_BASE_URL,this.applePayUrl=i.APPLE_PAY_URL),this.client=e.sdkClientName||i.DEFAULT_APP_NAME,e.overrideBaseUrl&&(this.apiBaseUrl=e.overrideBaseUrl),this.authApiBaseUrl=e.overrideAuthApiBaseUrl||`${this.apiBaseUrl}/auth`,this.donorApiBaseUrl=e.overrideDonorApiBaseUrl||`${this.apiBaseUrl}/donor`,this.embedApiBaseUrl=e.overrideEmbedApiBaseUrl||`${this.apiBaseUrl}/embed`,e.overrideApplePayUrl&&(this.applePayUrl=e.overrideApplePayUrl),e.overrideCardConnectBaseUrl&&(this.cardConnectBaseUrl=e.overrideCardConnectBaseUrl),this.pcScriptBase=e.pcScriptBase||i.FALLBACK_PC_SCRIPT_URL,this.pcScriptId=e.pcScriptId||i.FALLBACK_PC_SCRIPT_ID,this.turnstileCdnUrl=e.turnstileCdnUrl||i.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL,this.turnstileSiteKey=e.turnstileSiteKey||i.FALLBACK_CF_TURNSTILE_SITE_KEY,(null==e?void 0:e.spreedlyEnvironmentKey)&&(this.spreedlyEnvironmentKey=e.spreedlyEnvironmentKey),this.enableDelay=e.enableDelay||!1,this.secondsToDelay=e.secondsToDelay||0,this.enableSpreedlySecureTokenization=e.enableSpreedlySecureTokenization||!1,this.organizationId=e.organizationId,this.embedId=e.embedId,this.cardConnectTokenizerUrl=`${this.cardConnectBaseUrl}/itoke/ajax-tokenizer.html`}}},740:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class n{static resolveLib(e){const t=new Date;return new Promise((n,i)=>{!function r(){if(void 0!==window.google&&void 0!==window.google.payments){const t=new google.payments.api.PaymentsClient(e);n(t)}else(new Date).valueOf()-t.valueOf()>15e3?i(new Error("pay.js not loaded after 15 seconds")):setTimeout(r,250)}()})}static injectScript(){if(void 0!==window.google&&void 0!==window.google.payments)throw new Error("google payments is already injected");const e=document.createElement("script");e.src="https://pay.google.com/gp/p/js/pay.js?render=explicit",e.async=!0,e.defer=!0,document.body.appendChild(e)}constructor(e){this.baseRequest={apiVersion:2,apiVersionMinor:0},this.baseCardPaymentMethod={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}},this.transactionInfo={countryCode:"US",currencyCode:"USD",totalPriceStatus:"FINAL",totalPrice:""},this.tokenizationSpecification={type:"PAYMENT_GATEWAY",parameters:{gateway:"cardconnect",gatewayMerchantId:""}},this.googlePayOptions={environment:"PRODUCTION"},this.paymentRequestDefaults=Object.assign(Object.assign({},this.baseRequest),{merchantInfo:{merchantId:""},transactionInfo:this.transactionInfo,emailRequired:!0,allowedPaymentMethods:[Object.assign(Object.assign({},this.baseCardPaymentMethod),{tokenizationSpecification:this.tokenizationSpecification})]}),this.paymentsClient=null;const{paymentOptions:t,cardConnectMerchantId:n,paymentDataRequest:i,baseCardPaymentMethodParameters:r={}}=e;this.tokenizationSpecification.parameters.gatewayMerchantId=n,this.paymentRequest=Object.assign({},this.paymentRequestDefaults,i),this.googlePayOptions=Object.assign({},this.googlePayOptions,Object.assign(Object.assign({},t),{merchantInfo:this.paymentRequest.merchantInfo})),this.baseCardPaymentMethod.parameters=Object.assign(Object.assign({},this.baseCardPaymentMethod.parameters),r)}getGoogleIsReadyToPayRequest(){return Object.assign({},this.baseRequest,{allowedPaymentMethods:[this.baseCardPaymentMethod]})}getGooglePaymentClient(){return new Promise((e,t)=>{this.paymentsClient?e(this.paymentsClient):n.resolveLib(this.googlePayOptions).then(t=>{this.paymentsClient=t,e(t)}).catch(e=>t(e))})}onGooglePaymentButtonClicked(e){const t=this.paymentRequest;return this.transactionInfo=Object.assign({},this.transactionInfo,e),t.transactionInfo=this.transactionInfo,new Promise((e,n)=>{this.paymentsClient?this.paymentsClient.loadPaymentData(t).then(t=>{e(t)}).catch(e=>{n(e)}):n(new Error("PaymentClient is not initialized"))})}tokenizeWithCardConnect(e,t){return fetch(`${t}/cardsecure/api/v1/ccn/tokenize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({encryptionhandler:"EC_GOOGLE_PAY",devicedata:e,unique:!0})}).then(e=>e.json())}}t.default=n},777:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPaymentMethod=function(e,t){const n=(0,i.buildCreatePaymentMethodPayload)(e);return fetch(`${t.embedApiBaseUrl}/payment/payment-methods`,{method:"POST",headers:r.CLIENT_HEADERS,body:JSON.stringify(n)}).then(e=>(0,o.parseResponse)(e,{throwErrors:!0})).then(e=>(0,i.buildCreatePaymentMethodResult)(e))},t.fetchEmbedConfig=function(e,t){return fetch(`${t.embedApiBaseUrl}/config/${e}`,{method:"GET",headers:r.CLIENT_HEADERS}).then(e=>(0,o.parseResponse)(e,{throwErrors:!0})).then(e=>e._raw_response.result)};const i=n(156),r=n(247),o=n(472)},799:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FIELD_CONSTRAINTS=t.PLACEHOLDERS=t.CANADIAN_BANK_FIELD_FLEX=t.BANK_FIELD_FLEX=t.FIELD_FLEX=t.TOKENIZE_TIMEOUT=t.INIT_TIMEOUT=void 0,t.INIT_TIMEOUT=1e4,t.TOKENIZE_TIMEOUT=3e4,t.FIELD_FLEX={cardNumber:{flex:"1 1 60%",minWidth:"150px"},expiry:{flex:"0 1 20%",minWidth:"70px"},cvv:{flex:"0 1 20%",minWidth:"60px"}},t.BANK_FIELD_FLEX={routingNumber:{flex:"0 1 30%",minWidth:"100px"},accountNumber:{flex:"1 1 45%",minWidth:"120px"},accountType:{flex:"0 1 25%",minWidth:"90px"}},t.CANADIAN_BANK_FIELD_FLEX={institutionNumber:{flex:"0 1 15%",minWidth:"60px"},transitNumber:{flex:"0 1 20%",minWidth:"80px"},accountNumber:{flex:"1 1 40%",minWidth:"110px"},accountType:{flex:"0 1 25%",minWidth:"90px"}},t.PLACEHOLDERS={cardNumber:"Card Number *",expiry:"MM/YY *",cvv:"CVV *"},t.FIELD_CONSTRAINTS={expiry:{maxLength:5,pattern:/^\d{0,2}\/?\d{0,2}$/},cvv:{maxLength:4}}},806:function(e,t,n){var i,r=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return o(t,e),t}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.GooglePay=t.ApplePay=t.constants=t.recaptcha=t.ConfigHandler=t.Client=t.shared=t.util=t.tokenize=void 0;const l=a(n(578));t.tokenize=l;const c=a(n(472));t.util=c;const u=a(n(115));t.recaptcha=u;const h=a(n(247));t.constants=h;const p=a(n(777));t.shared=p;const m=d(n(712));t.Client=m.default;const y=d(n(731));t.ConfigHandler=y.default;const b=d(n(953));t.ApplePay=b.default;const v=d(n(740));t.GooglePay=v.default,s(n(523),t)},875:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.SpreedlyTokenizer=void 0;const r=n(415),o=n(367),a=n(247),s=n(156),d=n(592),l=n(454),c=n(799),u=n(631);class h extends r.Tokenizer{constructor(e,t,n,i="credit_card",r="US",o=!1,a="single-line"){if(super(),this.environmentKey=e,this.containerId=t,this.layout=a,this.bankCountry="US",this.enableTestMode=!1,this.mode=i,this.bankCountry=r,this.enableTestMode=o,"credit_card"===i){const e=window.SpreedlyPaymentFrame;this.spreedly=e?new e:window.Spreedly}else this.spreedly=window.Spreedly;this.currentValidationState="bank_account"===i?{isValid:!1,routingNumber:{isValid:!1,isEmpty:!0},accountNumber:{isValid:!1,isEmpty:!0}}:{isValid:!1,cardNumber:{isValid:!1,isEmpty:!0},cvv:{isValid:!1,isEmpty:!0},expiry:{isValid:!1,isEmpty:!0}},this.mergedStyles=(0,l.getContainerStylesForLayout)((0,l.mergeStyles)(l.DEFAULT_UNIFIED_STYLES,n),this.layout);const s=this.generateFieldIds(t);this.numberEl=s.numberId,this.cvvEl=s.cvvId,this.expiryId=s.expiryId}static create(e,t,n){return i(this,void 0,void 0,function*(){var i;"bank_account"!==t.mode&&(yield h.ensureSpreedlyLoaded());let r=null===(i=e.config)||void 0===i?void 0:i.environment_key;!r&&n.clientConfig.spreedlyEnvironmentKey&&(r=n.clientConfig.spreedlyEnvironmentKey),r||(r="");const o=new h(r,t.containerId,t.styling,t.mode||"credit_card",t.bankCountry||"US",t.enableTestMode||!1,t.layout||"single-line");let a;if(o.organizationId=n.organizationId,o.embedId=n.embedId,o.clientConfig=n.clientConfig,o.createInternalElements(),"credit_card"===t.mode&&n.clientConfig.enableSpreedlySecureTokenization){if(!n.organizationId||!n.embedId)throw new Error("Secure tokenization is enabled but organizationId and embedId are required");try{a=yield(0,d.fetchSpreedlySecurityArgs)(n.clientConfig,n.organizationId,n.embedId)}catch(e){throw new Error(`Secure tokenization is enabled but failed to initialize: ${e instanceof Error?e.message:"Unknown error"}`)}}return yield o.init(a),o})}init(e){return i(this,void 0,void 0,function*(){return this.containerEl=document.getElementById(this.containerId),"bank_account"===this.mode?(this.enableTestMode&&setTimeout(()=>{"CA"===this.bankCountry?(this.institutionNumberEl&&(this.institutionNumberEl.value="004",this.institutionNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.transitNumberEl&&(this.transitNumberEl.value="12345",this.transitNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountNumberEl&&(this.accountNumberEl.value="1234567",this.accountNumberEl.dispatchEvent(new Event("input",{bubbles:!0})))):(this.routingNumberEl&&(this.routingNumberEl.value="021000021",this.routingNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountNumberEl&&(this.accountNumberEl.value="9876543210",this.accountNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountTypeEl&&(this.accountTypeEl.value="checking",this.accountTypeEl.dispatchEvent(new Event("change",{bubbles:!0}))))},100),this.emit("ready"),Promise.resolve()):new Promise((t,n)=>{const i=setTimeout(()=>{n(new Error("Spreedly initialization timeout"))},c.INIT_TIMEOUT);this.spreedly.on("ready",()=>{clearTimeout(i),this.spreedly.setPlaceholder("number",c.PLACEHOLDERS.cardNumber),this.spreedly.setFieldType("number","text"),this.spreedly.setNumberFormat("prettyFormat"),this.spreedly.setPlaceholder("cvv",c.PLACEHOLDERS.cvv),this.spreedly.setFieldType("cvv","text"),this.applyUnifiedStyles(),this.enableTestMode&&"credit_card"===this.mode&&this.spreedly.setValue&&(this.spreedly.setValue("number","4111111111111111"),this.spreedly.setValue("cvv","123"),setTimeout(()=>{this.expiryEl&&(this.expiryEl.value="12/34",this.expiryEl.dispatchEvent(new Event("input",{bubbles:!0})))},100)),this.emit("ready"),t()}),this.spreedly.on("errors",e=>{this.emit("error",new o.TokenizationError(e))}),this.spreedly.on("fieldEvent",(e,t,n,i)=>{this.handleFieldEvent(e,t,i)});const r={numberEl:this.numberEl,cvvEl:this.cvvEl};e&&(r.certificateToken=e.certificate_token,r.signature=e.signature,r.timestamp=e.timestamp,r.nonce=e.nonce),this.spreedly.init(this.environmentKey,r)})})}tokenize(e){return i(this,void 0,void 0,function*(){if(!this.isReady)throw new Error("Tokenizer not initialized");return"bank_account"===this.mode||this.isBankAccountData(e)?this.tokenizeBankAccountInternal(e):this.tokenizeCardInternal(e)})}tokenizeCardInternal(e){return i(this,void 0,void 0,function*(){return new Promise((t,n)=>{var i,r,a,s,d,l;const u=setTimeout(()=>{this.spreedly&&this.spreedly.removeHandlers&&this.spreedly.removeHandlers(),n(new o.TokenizationError("Tokenization timeout","TIMEOUT"))},c.TOKENIZE_TIMEOUT),h=()=>{clearTimeout(u),this.spreedly&&this.spreedly.removeHandlers&&this.spreedly.removeHandlers()};this.spreedly.on("paymentMethod",(e,n)=>{h();const i={token:e,lastFour:n.last_four_digits,cardType:this.normalizeCardType(n.card_type),provider:"spreedly"};this.emit("tokenReady",i),t(i)}),this.spreedly.on("errors",e=>{h(),n(new o.TokenizationError(e))});const p=this.parseExpiry(this.expiryEl);if(!p)return h(),void n(new o.TokenizationError("Expiration date is required","VALIDATION_ERROR"));const m=p.month,y=p.year;this.spreedly.tokenizeCreditCard({first_name:e.firstName,last_name:e.lastName,month:m,year:y,email:e.email,phone_number:e.phone,address1:null===(i=e.address)||void 0===i?void 0:i.address1,address2:null===(r=e.address)||void 0===r?void 0:r.address2,city:null===(a=e.address)||void 0===a?void 0:a.city,state:null===(s=e.address)||void 0===s?void 0:s.state,zip:null===(d=e.address)||void 0===d?void 0:d.zip,country:null===(l=e.address)||void 0===l?void 0:l.country})})})}createCanadianBankAccountFields(e){"two-line"===this.layout?(this.accountTypeEl=(0,u.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:"2",minWidth:c.CANADIAN_BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,this.mergedStyles,"left"),e.appendChild(this.accountTypeEl),this.institutionNumberEl=(0,u.createInputElement)(`${this.containerId}-institution`,"text","Inst *",3),Object.assign(this.institutionNumberEl.style,{flex:"1",minWidth:c.CANADIAN_BANK_FIELD_FLEX.institutionNumber.minWidth}),this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"middle"),this.institutionNumberEl.addEventListener("blur",()=>{!(0,u.validateInstitutionNumber)(this.institutionNumberEl.value)&&this.institutionNumberEl.value?this.applyErrorStyles(this.institutionNumberEl):this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"middle"),this.updateBankAccountValidation()}),e.appendChild(this.institutionNumberEl),this.transitNumberEl=(0,u.createInputElement)(`${this.containerId}-transit`,"text","Transit *",5),Object.assign(this.transitNumberEl.style,{flex:"2",minWidth:c.CANADIAN_BANK_FIELD_FLEX.transitNumber.minWidth}),this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"right"),this.transitNumberEl.addEventListener("blur",()=>{!(0,u.validateTransitNumber)(this.transitNumberEl.value)&&this.transitNumberEl.value?this.applyErrorStyles(this.transitNumberEl):this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"right"),this.updateBankAccountValidation()}),e.appendChild(this.transitNumberEl),this.accountNumberEl=(0,u.createInputElement)(`${this.containerId}-account`,"text","Account Number *"),Object.assign(this.accountNumberEl.style,{flex:"1",flexBasis:"100%",minWidth:c.CANADIAN_BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles),this.accountNumberEl.addEventListener("blur",()=>{!(0,u.validateCanadianAccountNumber)(this.accountNumberEl.value)&&this.accountNumberEl.value?this.applyErrorStyles(this.accountNumberEl):this.applyInputStyles(this.accountNumberEl,this.mergedStyles),this.updateBankAccountValidation()}),e.appendChild(this.accountNumberEl)):(this.institutionNumberEl=(0,u.createInputElement)(`${this.containerId}-institution`,"text","Inst *",3),Object.assign(this.institutionNumberEl.style,{flex:c.CANADIAN_BANK_FIELD_FLEX.institutionNumber.flex,minWidth:c.CANADIAN_BANK_FIELD_FLEX.institutionNumber.minWidth}),this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"left"),this.institutionNumberEl.addEventListener("blur",()=>{!(0,u.validateInstitutionNumber)(this.institutionNumberEl.value)&&this.institutionNumberEl.value?this.applyErrorStyles(this.institutionNumberEl):this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"left"),this.updateBankAccountValidation()}),e.appendChild(this.institutionNumberEl),this.transitNumberEl=(0,u.createInputElement)(`${this.containerId}-transit`,"text","Transit *",5),Object.assign(this.transitNumberEl.style,{flex:c.CANADIAN_BANK_FIELD_FLEX.transitNumber.flex,minWidth:c.CANADIAN_BANK_FIELD_FLEX.transitNumber.minWidth}),this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"middle"),this.transitNumberEl.addEventListener("blur",()=>{!(0,u.validateTransitNumber)(this.transitNumberEl.value)&&this.transitNumberEl.value?this.applyErrorStyles(this.transitNumberEl):this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"middle"),this.updateBankAccountValidation()}),e.appendChild(this.transitNumberEl),this.accountNumberEl=(0,u.createInputElement)(`${this.containerId}-account`,"text","Account Number *"),Object.assign(this.accountNumberEl.style,{flex:c.CANADIAN_BANK_FIELD_FLEX.accountNumber.flex,minWidth:c.CANADIAN_BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.accountNumberEl.addEventListener("blur",()=>{!(0,u.validateCanadianAccountNumber)(this.accountNumberEl.value)&&this.accountNumberEl.value?this.applyErrorStyles(this.accountNumberEl):this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.updateBankAccountValidation()}),e.appendChild(this.accountNumberEl),this.accountTypeEl=(0,u.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:c.CANADIAN_BANK_FIELD_FLEX.accountType.flex,minWidth:c.CANADIAN_BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,this.mergedStyles,"right"),e.appendChild(this.accountTypeEl))}tokenizeBankAccountInternal(e){return i(this,void 0,void 0,function*(){var t,n,i,r,a,s,d,l,c,p,m,y;if(!this.isReady)throw new Error("Tokenizer not initialized");if("bank_account"!==this.mode)throw new Error("Tokenizer not in bank account mode");let b,v;const f=(null===(t=this.accountTypeEl)||void 0===t?void 0:t.value)||"checking";if("CA"===this.bankCountry){const e=null===(n=this.institutionNumberEl)||void 0===n?void 0:n.value,t=null===(i=this.transitNumberEl)||void 0===i?void 0:i.value;if(v=null===(r=this.accountNumberEl)||void 0===r?void 0:r.value,!e||!t||!v)throw new o.TokenizationError("Institution number, transit number, and account number are required","VALIDATION_ERROR");if(!(0,u.validateInstitutionNumber)(e))throw new o.TokenizationError("Institution number must be 3 digits","VALIDATION_ERROR");if(!(0,u.validateTransitNumber)(t))throw new o.TokenizationError("Transit number must be 5 digits","VALIDATION_ERROR");if(!(0,u.validateCanadianAccountNumber)(v))throw new o.TokenizationError("Invalid account number","VALIDATION_ERROR");b=(0,u.formatCanadianRoutingNumber)(e,t)}else{if(b=null===(a=this.routingNumberEl)||void 0===a?void 0:a.value,v=null===(s=this.accountNumberEl)||void 0===s?void 0:s.value,!b||!v)throw new o.TokenizationError("Routing number and account number are required","VALIDATION_ERROR");if(!(0,u.validateRoutingNumber)(b))throw new o.TokenizationError("Invalid routing number","VALIDATION_ERROR");if(!(0,u.validateAccountNumber)(v))throw new o.TokenizationError("Invalid account number","VALIDATION_ERROR")}return{token:yield h.tokenizeBankAccount({contact:{firstName:e.firstName,lastName:e.lastName,email:e.email,primaryPhone:e.phone},address:{address1:null===(d=e.address)||void 0===d?void 0:d.address1,address2:null===(l=e.address)||void 0===l?void 0:l.address2,city:null===(c=e.address)||void 0===c?void 0:c.city,state:null===(p=e.address)||void 0===p?void 0:p.state,zip:null===(m=e.address)||void 0===m?void 0:m.zip,country:null===(y=e.address)||void 0===y?void 0:y.country},account:{accountNumber:v,routingNumber:b,accountType:f,accountHolderType:"personal"}},this.clientConfig),lastFour:v.slice(-4),accountType:f,paymentMethodType:"bank_account",provider:"spreedly"}})}validate(){return i(this,void 0,void 0,function*(){return"bank_account"===this.mode?this.validateBankAccountInternal():this.validateCardInternal()})}validateCardInternal(){return i(this,void 0,void 0,function*(){var e,t,n,i,r;const o=[];(null===(e=this.currentValidationState.cardNumber)||void 0===e?void 0:e.isEmpty)?o.push({field:"cardNumber",message:"Card number is required"}):(null===(t=this.currentValidationState.cardNumber)||void 0===t?void 0:t.isValid)||o.push({field:"cardNumber",message:"Invalid card number"}),(null===(n=this.currentValidationState.cvv)||void 0===n?void 0:n.isEmpty)?o.push({field:"cvv",message:"CVV is required"}):(null===(i=this.currentValidationState.cvv)||void 0===i?void 0:i.isValid)||o.push({field:"cvv",message:"Invalid CVV"});const a=this.parseExpiry(this.expiryEl);return(null===(r=this.expiryEl)||void 0===r?void 0:r.value)?a||o.push({field:"expiry",message:"Invalid expiration date"}):o.push({field:"expiry",message:"Expiration date is required"}),{isValid:0===o.length,errors:o}})}validateBankAccountInternal(){return i(this,void 0,void 0,function*(){var e,t,n,i,r;const o=[];return"CA"===this.bankCountry?((null===(e=this.institutionNumberEl)||void 0===e?void 0:e.value)?(0,u.validateInstitutionNumber)(this.institutionNumberEl.value)||o.push({field:"routingNumber",message:"Institution number must be 3 digits"}):o.push({field:"routingNumber",message:"Institution number is required"}),(null===(t=this.transitNumberEl)||void 0===t?void 0:t.value)?(0,u.validateTransitNumber)(this.transitNumberEl.value)||o.push({field:"routingNumber",message:"Transit number must be 5 digits"}):o.push({field:"routingNumber",message:"Transit number is required"}),(null===(n=this.accountNumberEl)||void 0===n?void 0:n.value)?(0,u.validateCanadianAccountNumber)(this.accountNumberEl.value)||o.push({field:"accountNumber",message:"Account number must be at least 7 digits"}):o.push({field:"accountNumber",message:"Account number is required"})):((null===(i=this.routingNumberEl)||void 0===i?void 0:i.value)?(0,u.validateRoutingNumber)(this.routingNumberEl.value)||o.push({field:"routingNumber",message:"Invalid routing number"}):o.push({field:"routingNumber",message:"Routing number is required"}),(null===(r=this.accountNumberEl)||void 0===r?void 0:r.value)?(0,u.validateAccountNumber)(this.accountNumberEl.value)||o.push({field:"accountNumber",message:"Invalid account number"}):o.push({field:"accountNumber",message:"Account number is required"})),{isValid:0===o.length,errors:o}})}applyUnifiedStyles(){var e;const t="0"===(null===(e=this.mergedStyles.container)||void 0===e?void 0:e.gap);if(this.mergedStyles.input)if(t){const e=Object.assign(Object.assign({},this.mergedStyles.input),{borderRight:"none",borderRadius:this.mergedStyles.input.borderRadius?`${this.mergedStyles.input.borderRadius} 0 0 ${this.mergedStyles.input.borderRadius}`:"0"}),t=this.stylesToCssString(e);this.spreedly.setStyle("number",t);const n=Object.assign(Object.assign({},this.mergedStyles.input),{borderRadius:this.mergedStyles.input.borderRadius?`0 ${this.mergedStyles.input.borderRadius} ${this.mergedStyles.input.borderRadius} 0`:"0"}),i=this.stylesToCssString(n);this.spreedly.setStyle("cvv",i)}else{const e=this.stylesToCssString(this.mergedStyles.input);this.spreedly.setStyle("number",e),this.spreedly.setStyle("cvv",e)}if(this.mergedStyles.focus){const e=this.stylesToCssString(this.mergedStyles.focus);this.spreedly.setStyle("number:focus",e),this.spreedly.setStyle("cvv:focus",e)}if(this.mergedStyles.error){const e=this.stylesToCssString(this.mergedStyles.error);this.spreedly.setStyle("number.invalid",e),this.spreedly.setStyle("cvv.invalid",e)}}stylesToCssString(e){return Object.entries(e).filter(([e,t])=>null!=t).map(([e,t])=>`${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t}`).join("; ")}clear(){"bank_account"===this.mode?("CA"===this.bankCountry?(this.institutionNumberEl&&(this.institutionNumberEl.value=""),this.transitNumberEl&&(this.transitNumberEl.value="")):this.routingNumberEl&&(this.routingNumberEl.value=""),this.accountNumberEl&&(this.accountNumberEl.value=""),this.accountTypeEl&&(this.accountTypeEl.selectedIndex=0)):(this.spreedly.reload(),this.expiryEl&&(this.expiryEl.value=""))}focus(e){if("bank_account"===this.mode)return"routingNumber"===e?void("CA"===this.bankCountry&&this.institutionNumberEl?this.institutionNumberEl.focus():this.routingNumberEl&&this.routingNumberEl.focus()):"accountNumber"===e&&this.accountNumberEl?void this.accountNumberEl.focus():void 0;if("expiry"===e&&this.expiryEl)return void this.expiryEl.focus();const t={cardNumber:this.numberEl,cvv:this.cvvEl,expiry:null,routingNumber:null,accountNumber:null}[e];if(t){const e=document.getElementById(t);null==e||e.focus()}}destroy(){this.spreedly&&this.spreedly.removeHandlers&&this.spreedly.removeHandlers(),this.eventHandlers.clear(),this.expiryEl}hasToken(){return!1}getToken(){return null}get tokenizationMode(){return"manual"}updateOverallValidation(){var e,t,n,i,r,o;"credit_card"===this.mode?this.currentValidationState.isValid=null!==(t=null===(e=this.currentValidationState.cardNumber)||void 0===e?void 0:e.isValid)&&void 0!==t&&t&&null!==(i=null===(n=this.currentValidationState.cvv)||void 0===n?void 0:n.isValid)&&void 0!==i&&i&&null!==(o=null===(r=this.currentValidationState.expiry)||void 0===r?void 0:r.isValid)&&void 0!==o&&o:this.currentValidationState.isValid=!0,this.emit("validation",this.currentValidationState)}handleFieldEvent(e,t,n){"input"===t&&("number"===e?(this.currentValidationState.cardNumber={isValid:n.validNumber||!1,isEmpty:0===n.numberLength},n.cardType&&"unknown"!==n.cardType&&this.emit("cardTypeChange",{cardType:this.normalizeCardType(n.cardType)})):"cvv"===e&&(this.currentValidationState.cvv={isValid:n.validCvv||!1,isEmpty:0===n.cvvLength}),this.updateOverallValidation()),"focus"===t?this.emit("focus",{field:e}):"blur"===t?this.emit("blur",{field:e}):"input"===t&&this.emit("change",{field:e})}createInternalElements(){const e=document.getElementById(this.containerId);if(!e)throw new Error(`Container element not found: ${this.containerId}`);e.innerHTML="",Object.assign(e.style,this.mergedStyles.container),"bank_account"===this.mode?this.createBankAccountFields(e):this.createCreditCardFields(e)}createCreditCardFields(e){if("two-line"===this.layout){const t=(0,u.createFieldContainer)(this.numberEl,"1",c.FIELD_FLEX.cardNumber.minWidth);t.style.height=this.mergedStyles.input.height,t.style.flexBasis="100%",e.appendChild(t),this.expiryEl=(0,u.createInputElement)(this.expiryId,"text",c.PLACEHOLDERS.expiry,c.FIELD_CONSTRAINTS.expiry.maxLength),Object.assign(this.expiryEl.style,{flex:"1",minWidth:c.FIELD_FLEX.expiry.minWidth}),this.applyInputStyles(this.expiryEl,this.mergedStyles,"left"),this.addExpiryFormatter(this.expiryEl),this.expiryEl.addEventListener("input",()=>{var e;const t=this.parseExpiry(this.expiryEl);this.currentValidationState.expiry={isValid:!!t,isEmpty:!(null===(e=this.expiryEl)||void 0===e?void 0:e.value)},this.updateOverallValidation()}),e.appendChild(this.expiryEl);const n=(0,u.createFieldContainer)(this.cvvEl,"1",c.FIELD_FLEX.cvv.minWidth);n.style.height=this.mergedStyles.input.height,e.appendChild(n)}else{const t=(0,u.createFieldContainer)(this.numberEl,c.FIELD_FLEX.cardNumber.flex,c.FIELD_FLEX.cardNumber.minWidth);t.style.height=this.mergedStyles.input.height,e.appendChild(t),this.expiryEl=(0,u.createInputElement)(this.expiryId,"text",c.PLACEHOLDERS.expiry,c.FIELD_CONSTRAINTS.expiry.maxLength),Object.assign(this.expiryEl.style,{flex:c.FIELD_FLEX.expiry.flex,minWidth:c.FIELD_FLEX.expiry.minWidth}),this.applyInputStyles(this.expiryEl,this.mergedStyles,"middle"),this.addExpiryFormatter(this.expiryEl),this.expiryEl.addEventListener("input",()=>{var e;const t=this.parseExpiry(this.expiryEl);this.currentValidationState.expiry={isValid:!!t,isEmpty:!(null===(e=this.expiryEl)||void 0===e?void 0:e.value)},this.updateOverallValidation()}),e.appendChild(this.expiryEl);const n=(0,u.createFieldContainer)(this.cvvEl,c.FIELD_FLEX.cvv.flex,c.FIELD_FLEX.cvv.minWidth);n.style.height=this.mergedStyles.input.height,e.appendChild(n)}}createBankAccountFields(e){"CA"===this.bankCountry?this.createCanadianBankAccountFields(e):this.createUSBankAccountFields(e)}createUSBankAccountFields(e){"two-line"===this.layout?(this.accountTypeEl=(0,u.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:"1",minWidth:c.BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,this.mergedStyles,"left"),e.appendChild(this.accountTypeEl),this.routingNumberEl=(0,u.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:"1",minWidth:c.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"right"),this.routingNumberEl.addEventListener("blur",()=>{!(0,u.validateRoutingNumber)(this.routingNumberEl.value)&&this.routingNumberEl.value?this.applyErrorStyles(this.routingNumberEl):this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"right"),this.updateBankAccountValidation()}),e.appendChild(this.routingNumberEl),this.accountNumberEl=(0,u.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:"1",flexBasis:"100%",minWidth:c.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles),this.accountNumberEl.addEventListener("blur",()=>{!(0,u.validateAccountNumber)(this.accountNumberEl.value)&&this.accountNumberEl.value?this.applyErrorStyles(this.accountNumberEl):this.applyInputStyles(this.accountNumberEl,this.mergedStyles),this.updateBankAccountValidation()}),e.appendChild(this.accountNumberEl)):(this.routingNumberEl=(0,u.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:c.BANK_FIELD_FLEX.routingNumber.flex,minWidth:c.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"left"),this.routingNumberEl.addEventListener("blur",()=>{!(0,u.validateRoutingNumber)(this.routingNumberEl.value)&&this.routingNumberEl.value?this.applyErrorStyles(this.routingNumberEl):this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"left"),this.updateBankAccountValidation()}),e.appendChild(this.routingNumberEl),this.accountNumberEl=(0,u.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:c.BANK_FIELD_FLEX.accountNumber.flex,minWidth:c.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.accountNumberEl.addEventListener("blur",()=>{!(0,u.validateAccountNumber)(this.accountNumberEl.value)&&this.accountNumberEl.value?this.applyErrorStyles(this.accountNumberEl):this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.updateBankAccountValidation()}),e.appendChild(this.accountNumberEl),this.accountTypeEl=(0,u.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:c.BANK_FIELD_FLEX.accountType.flex,minWidth:c.BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,this.mergedStyles,"right"),e.appendChild(this.accountTypeEl))}updateBankAccountValidation(){if("CA"===this.bankCountry){if(!this.institutionNumberEl||!this.transitNumberEl||!this.accountNumberEl)return;const e=(0,u.validateInstitutionNumber)(this.institutionNumberEl.value),t=(0,u.validateTransitNumber)(this.transitNumberEl.value),n=(0,u.validateCanadianAccountNumber)(this.accountNumberEl.value);this.currentValidationState={isValid:e&&t&&n,routingNumber:{isValid:e&&t,isEmpty:!this.institutionNumberEl.value&&!this.transitNumberEl.value,error:e?t?void 0:"Invalid transit number":"Invalid institution number"},accountNumber:{isValid:n,isEmpty:!this.accountNumberEl.value,error:n?void 0:"Account number must be at least 7 digits"}}}else{if(!this.routingNumberEl||!this.accountNumberEl)return;const e=(0,u.validateRoutingNumber)(this.routingNumberEl.value),t=(0,u.validateAccountNumber)(this.accountNumberEl.value);this.currentValidationState={isValid:e&&t,routingNumber:{isValid:e,isEmpty:!this.routingNumberEl.value,error:e?void 0:"Invalid routing number"},accountNumber:{isValid:t,isEmpty:!this.accountNumberEl.value,error:t?void 0:"Invalid account number"}}}this.emit("validation",this.currentValidationState)}validateExpiry(){if(!this.expiryEl)return;const e=this.parseExpiry(this.expiryEl);if(!e)return void this.applyErrorStyles(this.expiryEl);const t=parseInt(e.month,10),n=parseInt(e.year,10);if(t<1||t>12)return void this.applyErrorStyles(this.expiryEl);const i=new Date;new Date(n,t-1)<i?this.applyErrorStyles(this.expiryEl):this.applyInputStyles(this.expiryEl,this.mergedStyles,"middle")}applyErrorStyles(e){this.mergedStyles.error?Object.assign(e.style,this.mergedStyles.error):e.style.borderColor="#dc3545"}static ensureSpreedlyLoaded(){return i(this,void 0,void 0,function*(){window.Spreedly||(yield h.loadScript("https://core.spreedly.com/iframe/iframe-v1.min.js","spreedly-iframe-script"),yield h.waitForGlobal("Spreedly",5e3))})}static loadScript(e,t){return i(this,void 0,void 0,function*(){if(!t||!document.getElementById(t))return Array.from(document.getElementsByTagName("script")).find(t=>t.src===e)?void 0:new Promise((n,i)=>{const r=document.createElement("script");r.src=e,r.async=!0,t&&(r.id=t),r.onload=()=>n(),r.onerror=()=>i(new Error(`Failed to load script: ${e}`)),document.body.appendChild(r)})})}static waitForGlobal(e){return i(this,arguments,void 0,function*(e,t=1e4){const n=Date.now();for(;Date.now()-n<t;){const t=window[e];if(t)return t;yield new Promise(e=>setTimeout(e,100))}throw new Error(`Timeout waiting for global: ${e}`)})}static tokenizeBankAccount(e,t){return void 0===t.spreedlyEnvironmentKey?Promise.reject(new Error("Spreedly is not configured.")):fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{bank_account:{first_name:e.contact.firstName||void 0,last_name:e.contact.lastName||void 0,full_name:e.contact.fullName||void 0,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country,bank_account_number:e.account.accountNumber.replace(/\s+/g,""),bank_routing_number:e.account.routingNumber.replace(/\s+/g,""),bank_account_holder_type:e.account.accountHolderType,bank_account_type:e.account.accountType}},retained:!1})}).then(s.unpackSpreedlyResponse).then(s.extractSpreedlyToken)}static tokenizeCreditCard(e,t){return void 0===t.spreedlyEnvironmentKey?Promise.reject(new Error("Spreedly is not configured.")):fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{credit_card:{first_name:e.contact.firstName,last_name:e.contact.lastName,full_name:e.contact.fullName,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country,number:e.card.cardNumber.replace(/\s+/g,""),verification_value:e.card.verificationValue,year:e.card.expirationYear,month:e.card.expirationMonth}},retained:!1})}).then(s.unpackSpreedlyResponse).then(s.extractSpreedlyToken)}static tokenizePayPal(e,t){if(void 0===t.spreedlyEnvironmentKey)throw new Error("Spreedly is not configured.");return fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{payment_method_type:"paypal",first_name:e.contact.firstName,last_name:e.contact.lastName,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country},retained:!1})}).then(s.unpackSpreedlyResponse).then(s.extractSpreedlyToken)}}t.SpreedlyTokenizer=h},903:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizePaymentBankCanada=function(e,t,n,r,o,a,s,d,l){const c=(0,i.v4)();let u=l.address1;l.address2&&(u+="\n"+l.address2);const h={IATS_DPM_ProcessOption:"TOKEN",IATS_DPM_RecurringOn:"FALSE",IATS_DPM_ProcessID:o,IATS_DPM_RelayURL:a,IATS_DPM_ClientDefined_PaymentId:c,IATS_DPM_ClientDefined_GatewayId:s,IATS_DPM_Title:d.salutation,IATS_DPM_FirstName:d.firstName,IATS_DPM_LastName:d.lastName,IATS_DPM_Address:u,IATS_DPM_City:l.city,IATS_DPM_Province:l.state,IATS_DPM_Country:l.country,IATS_DPM_ZipCode:l.zip,IATS_DPM_Phone:d.primaryPhone,IATS_DPM_EMAIL:d.email,IATS_DPM_AccountNumber:e+t+n,IATS_DPM_MOP:"ACHEFT",IATS_DPM_AccountType:r},p=new FormData;for(const[e,t]of Object.entries(h))p.append(e,t);return fetch("https://www.iatspayments.com/netgate/IATSDPMProcess.aspx",{method:"POST",mode:"no-cors",body:p}).then(e=>e.text().then(()=>c))},t.tokenizePaymentBankUs=function(){throw new Error("US Bank Tokenization Not Yet Implemented")},t.tokenizePaymentCard=function(){throw new Error("Card Tokenization Not Yet Implemented")};const i=n(611)},953:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});const r=n(247);class o{constructor(e){this.appleSession=null,this.paymentRequestDefaults={currencyCode:"USD",countryCode:"US",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["amex","masterCard","visa","discover"],requiredBillingContactFields:["postalAddress","name"],requiredShippingContactFields:["email","phone"],total:{label:"iDonate",amount:"",type:"final"}},this.paymentRequest=Object.assign({},this.paymentRequestDefaults,e)}static isSupported(){return window.ApplePaySession&&ApplePaySession.canMakePayments()&&ApplePaySession.supportsVersion(o.ApplePayApiVersion)}begin(){return i(this,void 0,void 0,function*(){if(!o.isSupported())throw new Error("Apple Pay Not Supported");return this.appleSession=new ApplePaySession(o.ApplePayApiVersion,this.paymentRequest),this.appleSession.begin(),this.appleSession})}createSession(e,t){return fetch(`${t}/payment/create-session`,{method:"POST",headers:r.CLIENT_HEADERS,body:JSON.stringify(e)}).then(e=>e.json())}tokenizeWithCardConnect(e,t){const n=e.token.paymentData,i=`${n.data}&ectype=apple&ecsig=${n.signature}&eckey=${n.header.ephemeralPublicKey}&ectid=${n.header.transactionId}&echash=&ecpublickeyhash=${n.header.publicKeyHash}`;return fetch(`${t}/cardsecure/api/v1/ccn/tokenize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({encryptionhandler:"EC_APPLE_PAY",devicedata:i,unique:!0})}).then(e=>e.json())}}o.ApplePayApiVersion=6,t.default=o}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i].call(o.exports,o,o.exports,n),o.exports}return n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(806)})());
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.idonate=t():e.idonate=t()}(self,()=>(()=>{"use strict";var e={115:(e,t)=>{function n(){const e=new Date;return new Promise((t,n)=>{!function i(){void 0!==window.grecaptcha&&void 0!==window.grecaptcha.render?t(window.grecaptcha):(new Date).valueOf()-e.valueOf()>15e3?n(new Error("grecaptcha not loaded after 15 seconds")):setTimeout(i,250)}()})}Object.defineProperty(t,"__esModule",{value:!0}),t.RecaptchaElement=void 0,t.injectScript=function(e){if(void 0!==window.grecaptcha)throw new Error("grecaptcha is already defined");const t=document.createElement("script");t.src="https://www.google.com/recaptcha/api.js?render=explicit",t.async=!0,t.defer=!0,t.onload=e||null,"interactive"===document.readyState||"complete"===document.readyState?document.body.appendChild(t):window.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(t)})},t.wrapElement=function(e,t,n){const r=Object.assign(Object.assign({},n||{}),{sitekey:t}),o=new i(e,r);return o.render(),o};class i{constructor(e,t){this.container=e,this.params=t,this.executeResolveQueue=[]}render(){return void 0!==this.widgetId&&console.warn("rendering an already-rendered widget"),n().then(e=>{this.widgetId=e.render(this.container,Object.assign(Object.assign({},this.params),{callback:e=>{var t;this.resolvedToken=e,null===(t=this.executeResolveQueue.pop())||void 0===t||t(e)},"expired-callback":()=>{this.resolvedToken=void 0}}))})}resolveToken(){return new Promise((e,t)=>{n().then(n=>{if("invisible"!==this.params.size){const i=n.getResponse();return i?e(i):t(new Error("checkbox recaptcha is not checked"))}this.executeResolveQueue.push(e),void 0!==this.resolvedToken&&(this.resolvedToken=void 0,n.reset(this.widgetId)),n.execute(this.widgetId)}).catch(e=>{t(e)})})}}t.RecaptchaElement=i},122:function(e,t){var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.handleCFChallenge=void 0;let i=null;t.handleCFChallenge=(e,t)=>new Promise((e,r)=>n(void 0,void 0,void 0,function*(){var n,o,a;try{const r=null===window||void 0===window?void 0:window.document;if(!r||!window)throw new Error("document is not present on window");const o=r.createElement("div"),a=r.createElement("div"),s=n=>{var i;null===(i=null==n?void 0:n.render)||void 0===i||i.call(n,"#iDonateTurnstileBox",{sitekey:t.config.turnstileSiteKey,callback(t,n){o.remove(),e({token:t,preClearance:n})}})};if(window.idonateTurnstileLoadedHandler=()=>{const e=window.turnstile;a.innerHTML="",e&&(i=e),s(e)},o.setAttribute("id","idonateTurnstileWrapper"),o.style.position="fixed",o.style.top="0",o.style.bottom="0",o.style.left="0",o.style.right="0",o.style.backgroundColor="rgba(0,0,0,0.9)",o.style.transition="all 400ms",o.style.display="flex",o.style.flexDirection="column",o.style.padding="40px 30px",o.style.opacity="0",o.style.color="white",o.style.fontFamily="sans-serif",o.style.zIndex="1000",o.innerHTML='<h1 id="idonateTurnstileVerificationHeader">Last tiny step before we submit your payment:</h1>',a.setAttribute("id","iDonateTurnstileBox"),o.append(a),r.body.append(o),i)s(i);else{const e=r.createElement("script");a.innerHTML="loading ...",e.src=t.config.turnstileCdnUrl+"?render=explicit&onload=idonateTurnstileLoadedHandler",r.body.append(e)}null===(n=a.scrollIntoView)||void 0===n||n.call(a),o.style.opacity="1"}catch(e){null===(o=null===console||void 0===console?void 0:console.error)||void 0===o||o.call(console,e),null===(a=null===console||void 0===console?void 0:console.warn)||void 0===a||a.call(console,"iDonate SDK: Could not handle request, please reload the page and try again"),r(null)}}))},138:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.PayPalTokenizer=void 0;const r=n(415),o=n(367),a="paypal-sdk-script";class s extends r.Tokenizer{constructor(e,t,n,i){var r,o;super(),this.gateway=e,this.containerId=t,this.configContext=i,this.mode="credit_card";const a=e.config;if(!(null==a?void 0:a.client_id))throw new Error("PayPal gateway configuration missing client_id");this.clientId=a.client_id,this.sandboxMode=null!==(r=a.sandbox_mode)&&void 0!==r&&r,this.currency=n.currency||"USD",this.amount=n.amount,this.enableVenmo=null===(o=n.enableVenmo)||void 0===o||o,this.locale=n.locale||"en_US",this.onCreateOrder=n.onCreateOrder,this.organizationId=i.organizationId,this.embedId=i.embedId,this.clientConfig=i.clientConfig}static create(e,t,n){return i(this,void 0,void 0,function*(){const i=new s(e,t.containerId,t,n);return yield i.init(),i})}init(){return i(this,void 0,void 0,function*(){if(this.containerEl=document.getElementById(this.containerId),!this.containerEl)throw new Error(`Container element not found: ${this.containerId}`);return this.containerEl.innerHTML="",Object.assign(this.containerEl.style,{display:"flex",flexDirection:"column",gap:"0.5rem",alignItems:"stretch"}),new Promise((e,t)=>{const n=setTimeout(()=>{t(new Error("PayPal SDK initialization timeout"))},1e4);this.loadPayPalSDK().then(()=>(clearTimeout(n),this.renderButtons())).then(()=>{this.emit("ready"),this.emit("validation",{isValid:!0}),e()}).catch(e=>{clearTimeout(n),this.emit("error",new o.TokenizationError("Failed to initialize PayPal","INIT_FAILED")),t(e)})})})}loadPayPalSDK(){return i(this,void 0,void 0,function*(){if(window.paypal)return Promise.resolve();if(document.getElementById(a))return this.waitForPayPalGlobal();const e=new URLSearchParams({"client-id":this.clientId,currency:this.currency,intent:"capture"}),t=["card","paylater"];this.enableVenmo?e.set("enable-funding","venmo"):t.push("venmo"),e.set("disable-funding",t.join(","));const n=document.createElement("script");return n.id=a,n.src=`https://www.paypal.com/sdk/js?${e.toString()}`,n.async=!0,new Promise((e,t)=>{n.onload=()=>{this.waitForPayPalGlobal().then(e).catch(t)},n.onerror=()=>{t(new Error("Failed to load PayPal SDK"))},document.head.appendChild(n)})})}waitForPayPalGlobal(){return i(this,arguments,void 0,function*(e=5e3){const t=Date.now();for(;Date.now()-t<e;){if(window.paypal)return Promise.resolve();yield new Promise(e=>setTimeout(e,100))}throw new Error("Timeout waiting for PayPal SDK to load")})}renderButtons(){return i(this,void 0,void 0,function*(){if(!window.paypal)throw new Error("PayPal SDK not loaded");if(!this.containerEl)throw new Error("Container element not found");this.paypalButtonContainer=document.createElement("div"),this.paypalButtonContainer.id=`${this.containerId}-buttons`,this.paypalButtonContainer.style.minHeight="40px",this.containerEl.appendChild(this.paypalButtonContainer),yield this.renderPayPalButtons()})}renderPayPalButtons(){return i(this,void 0,void 0,function*(){if(!window.paypal||!this.paypalButtonContainer)return;const e=window.paypal.Buttons({createOrder:()=>this.createOrder(),onApprove:e=>this.handleApprove(e),onCancel:e=>this.handleCancel(e),onError:e=>this.handleError(e,"PayPal error"),style:{layout:"vertical",shape:"rect",height:40}});yield e.render(this.paypalButtonContainer)})}createOrder(){const e=`${this.clientConfig.embedApiBaseUrl}/payment/paypal/create-order`;let t,n=this.currency;if(this.onCreateOrder){const e=this.onCreateOrder();t=e.amount,n=e.currency||this.currency}else t=this.amount;if(void 0===t||t<=0){const e=new Error("Amount is required to create PayPal order");return this.handleError(e,"Order creation failed"),Promise.reject(e)}const i={payment_gateway_id:this.gateway.id,currency:n,amount:t};return fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)}).then(e=>{if(!e.ok)throw new Error(`HTTP error! status: ${e.status}`);return e.json()}).then(e=>{if(!e.orderId)throw new Error("Order creation failed: missing orderId");return this.paymentTransactionId=e.payment_transaction_id,this.paymentMethodId=e.payment_method_id,e.orderId}).catch(e=>{throw this.handleError(e,"Order creation failed"),e})}handleApprove(e){return i(this,void 0,void 0,function*(){const t={token:e.orderID,lastFour:e.orderID.slice(-4),provider:"paypal_checkout",paymentMethodId:this.paymentMethodId,paymentTransactionId:this.paymentTransactionId};this.cachedToken=t,this.emit("validation",{isValid:!0,hasToken:!0}),this.emit("tokenReady",t)})}handleCancel(e){this.emit("error",new o.TokenizationError("Payment cancelled by user","USER_CANCELLED"))}handleError(e,t){const n=(null==e?void 0:e.message)||(null==e?void 0:e.toString())||"Unknown error";this.emit("error",new o.TokenizationError(`${t}: ${n}`,(null==e?void 0:e.code)||"PAYPAL_ERROR"))}tokenize(e){return i(this,void 0,void 0,function*(){if(!this.isReady)throw new Error("Tokenizer not initialized");if(this.cachedToken)return this.cachedToken;throw new o.TokenizationError("No PayPal order approved. User must click PayPal or Venmo button to complete payment.","NO_TOKEN")})}validate(){return i(this,void 0,void 0,function*(){return{isValid:!0,errors:[]}})}clear(){this.cachedToken=void 0,this.emit("validation",{isValid:!0,hasToken:!1})}focus(e){}destroy(){this.containerEl&&(this.containerEl.innerHTML=""),this.eventHandlers.clear(),this.cachedToken=void 0}hasToken(){return!!this.cachedToken}getToken(){return this.cachedToken||null}get tokenizationMode(){return"auto"}}t.PayPalTokenizer=s},156:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.buildCashPaymentPayload=function(e,t){var n,i,r,o,a,s,d,l,c,u,h,p,m,y,b,v,f;const g={country:t.billingAddress.country,address1:t.billingAddress.address1,address2:t.billingAddress.address2,city:t.billingAddress.city,state:t.billingAddress.state,zip_code:t.billingAddress.zip},E={title:t.billingContact.salutation,first_name:t.billingContact.firstName,middle_name:t.billingContact.middleName,last_name:t.billingContact.lastName,company_name:t.billingContact.company,email:t.billingContact.email,home_phone:t.billingContact.primaryPhone,timezone:(new Intl.DateTimeFormat).resolvedOptions().timeZone},_={payment_method_id:t.paymentMethodId,payment_transaction_id:t.paymentTransactionId,gateway_id:t.paymentGatewayId,amount:t.paymentAmount,type:"cash",frequency:t.recurringFrequency,start_date:t.recurringStart,end_date:t.recurringEnd,retain_on_success:t.retainPaymentMethod},N={organization_id:e,campaign_id:t.campaignId,reference_code:t.referenceCode,double_the_donation_company_id:t.corporateMatchingId,donor_id:t.donorId,hide_name:t.anonymousOptIn,show_name_to_fundraiser:t.showNameToFundraiserOptIn,email_opt_in:t.emailOptIn,donor_paid_fee:t.donorPaidFeeAmount,designation_note:t.designationNote,gift_id:t.giftId,gift_extra:t.giftExtra,gift_skipped:t.giftSkipped,p2p_fundraiser_id:t.p2pFundraiserId,p2p_fundraiser_comment:t.p2pFundraiserComment,organization_event_id:t.organizationEventId,advocate_id:t.advocateId,advocacy_program_id:t.advocacyProgramId,advocacy_team_id:t.advocacyTeamId,page_id:t.landingPageId,embed_id:t.embedId,tribute_definition_id:null===(n=t.tribute)||void 0===n?void 0:n.tributeDefinitionId,tribute_recipient_first_name:null===(i=t.tribute)||void 0===i?void 0:i.tributeFirstName,tribute_recipient_last_name:null===(r=t.tribute)||void 0===r?void 0:r.tributeLastName,tribute_address1:null===(o=t.tribute)||void 0===o?void 0:o.tributeAddress1,tribute_address2:null===(a=t.tribute)||void 0===a?void 0:a.tributeAddress2,tribute_city:null===(s=t.tribute)||void 0===s?void 0:s.tributeCity,tribute_state:null===(d=t.tribute)||void 0===d?void 0:d.tributeState,tribute_postal_code:null===(l=t.tribute)||void 0===l?void 0:l.tributePostalCode,tribute_country:null===(c=t.tribute)||void 0===c?void 0:c.tributeCountry,tribute_from_name:null===(u=t.tribute)||void 0===u?void 0:u.tributeFromName,tribute_recipient_email:null===(h=t.tribute)||void 0===h?void 0:h.tributeRecipientEmail,honorees:null===(p=t.tribute)||void 0===p?void 0:p.honorees,tribute_send_card:null===(m=t.tribute)||void 0===m?void 0:m.tributeSendCard,tribute_include_amount:null===(y=t.tribute)||void 0===y?void 0:y.tributeIncludeAmount,tribute_skipped:null===(b=t.tribute)||void 0===b?void 0:b.tributeSkipped,tribute_type:null===(v=t.tribute)||void 0===v?void 0:v.tributeType,useOnBillingAddress:null===(f=t.tribute)||void 0===f?void 0:f.useOnBillingAddress,embed_referer:window.location.href,converted_to_recurring:t.convertedToRecurring};t.designations?N.designations=t.designations:N.designations=[],t.designationId&&N.designations.push({id:t.designationId,amount:t.paymentAmount});const I={};return t.utm&&(t.utm.campaign&&(I.utm_campaign=t.utm.campaign),t.utm.content&&(I.utm_content=t.utm.content),t.utm.medium&&(I.utm_medium=t.utm.medium),t.utm.source&&(I.utm_source=t.utm.source),t.utm.term&&(I.utm_term=t.utm.term)),t.customerMeta&&[1,2,3,4,5].forEach(e=>{const n=`custom_note_${e}`;t.customerMeta[n]&&(N[n]=t.customerMeta[n],delete t.customerMeta[n])}),Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({},N),g),E),_),I),{customer_meta:t.customerMeta||{},recaptcha_token:t.recaptchaToken,recaptcha_type:t.recaptchaType})},t.buildDonationResult=function(e){let t,n,i,r,o;return e._raw_response.transaction&&(o=e._raw_response.transaction),e._raw_response.schedule&&(r=e._raw_response.schedule),e._raw_response.donor&&(i=e._raw_response.donor),e._raw_response.designation&&(n=e._raw_response.designation),e._raw_response.campaign&&(t=e._raw_response.campaign),Object.assign(Object.assign({},e),{campaign:t,designation:n,donor:i,schedule:r,transaction:o})},t.buildCreatePaymentMethodPayload=function(e){return{gateway_id:e.paymentGatewayId,backend_name:e.backendName,payment_method_type:e.paymentMethodType,payment_method_token:e.paymentMethodToken,donor_id:e.donorId,first_name:e.contact.firstName,last_name:e.contact.lastName,company:e.contact.company,email:e.contact.email,phone:e.contact.primaryPhone,country:e.address.country,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip_code:e.address.zip,embed_id:e.embedId,recaptcha_token:e.recaptchaToken,recaptcha_type:e.recaptchaType}},t.collapseClientErrors=function(e){return new i.ClientError(e.map(e=>e.message).join("\n "),{_rawPayload:e})},t.buildCreatePaymentMethodResult=function(e){return Object.assign(Object.assign({},e),{paymentMethodId:e._raw_response.result.id})},t.unpackSpreedlyResponse=function(e){return e.json().then(e=>{if(e.errors)throw new i.ClientError(e.errors.map(e=>e.message).join("\n "),e);return e})},t.extractSpreedlyToken=function(e){if(!e.transaction||!e.transaction.payment_method)throw new i.ClientError("Payment Method not tokenized.");return e.transaction.payment_method.token};const i=n(523)},247:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.CLIENT_HEADERS=t.CARD_CONNECT_DEFAULT_STYLE=t.DEFAULT_APP_NAME=t.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL=t.FALLBACK_CF_TURNSTILE_SITE_KEY=t.FALLBACK_PC_SCRIPT_ID=t.FALLBACK_PC_SCRIPT_URL=t.SANDBOX_APPLE_PAY_URL=t.APPLE_PAY_URL=t.SPREEDLY_TOKENIZER_URL=t.SANDBOX_CARD_CONNECT_BASE_URL=t.PRODUCTION_CARD_CONNECT_BASE_URL=t.SANDBOX_BASE_URL=t.PRODUCTION_BASE_URL=t.SDK_VERSION=void 0,t.SDK_VERSION="1.2.0-dev3",t.PRODUCTION_BASE_URL="https://secure-api.idonate.com",t.SANDBOX_BASE_URL="https://api.qa-idonate.com",t.PRODUCTION_CARD_CONNECT_BASE_URL="https://boltgw.cardconnect.com:8443",t.SANDBOX_CARD_CONNECT_BASE_URL="https://boltgw-uat.cardconnect.com",t.SPREEDLY_TOKENIZER_URL="https://core.spreedly.com/v1/payment_methods.json",t.APPLE_PAY_URL="https://apple-pay-gateway.apple.com/paymentservices/paymentSession",t.SANDBOX_APPLE_PAY_URL="https://apple-pay-gateway-cert.apple.com/paymentservices/paymentSession",t.FALLBACK_PC_SCRIPT_URL="https://p.idonate.com/r",t.FALLBACK_PC_SCRIPT_ID="_3fd4dad26e8c277bc50fb2ddf8233b50bc8d9704",t.FALLBACK_CF_TURNSTILE_SITE_KEY="0x4AAAAAAAxuRxNZTvX8shIj",t.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL="https://challenges.cloudflare.com/turnstile/v0/api.js",t.DEFAULT_APP_NAME="unnamed-sdk-client",t.CARD_CONNECT_DEFAULT_STYLE="\nbody {\n margin: 0;\n}\n\nform {\n display: flex;\n}\n\nlabel#cccardlabel {\n display: none;\n}\n\nbr {\n display: none;\n}\n\nlabel#cccvvlabel {\n display: none;\n}\n\nlabel#ccexpirylabel {\n display: none;\n}\n\ninput {\n padding: 10px;\n}\n\nselect {\n padding: 10px;\n font-size: 14px;\n color: #8b959d;\n}\n\nselect#ccexpirymonth {\n margin-right: -30px;\n border: 1px solid #b6b8ba;\n border-right: 0;\n}\n\ninput#ccnumfield {\n width: 70%;\n border: 1px solid #b6b8ba;\n border-right: 0;\n border-top-left-radius: 3px;\n border-bottom-left-radius: 3px;\n font-size: 14px;\n color: #8b959d;\n}\n\nselect#ccexpiryyear {\n border: 1px solid #b6b8ba;\n border-right: 0;\n}\n\ninput#cccvvfield {\n border: 1px solid #b6b8ba;\n border-top-right-radius: 3px;\n border-bottom-right-radius: 3px;\n font-size: 14px;\n color: #8b959d;\n}\n".replace(/\s+/gi," "),t.CLIENT_HEADERS={"User-Agent":navigator.userAgent+` idonate-sdk@${t.SDK_VERSION}`,"Content-Type":"application/json"}},367:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.TokenizationError=void 0;class n extends Error{constructor(e,t){super("string"==typeof e?e:e.map(e=>e.message||e).join(", ")),this.name="TokenizationError",this.code=t,Array.isArray(e)?this.errors=e.map(e=>({field:e.field||e.attribute||"unknown",message:e.message||e.error||String(e),code:e.code||e.key})):this.errors=[{field:"cardNumber",message:e,code:t}]}}t.TokenizationError=n},415:function(e,t,n){var i,r=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return o(t,e),t}),s=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.Tokenizer=void 0;const d=n(631);t.Tokenizer=class{constructor(){this.mode="credit_card",this.eventHandlers=new Map,this._isReady=!1}get isReady(){return this._isReady}getMode(){return this.mode}on(e,t){if(this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t),"ready"===e&&this._isReady)try{t()}catch(e){}}off(e,t){const n=this.eventHandlers.get(e);n&&n.delete(t)}emit(e,t){"ready"===e&&(this._isReady=!0);const n=this.eventHandlers.get(e);n&&n.forEach(e=>{try{e(t)}catch(e){}})}isCardData(e){return"credit_card"===this.mode}isBankAccountData(e){return"bank_account"===this.mode}normalizeCardType(e){return{visa:"visa",mastercard:"mastercard",master:"mastercard",americanexpress:"amex",amex:"amex",discover:"discover",dinersclub:"diners",diners:"diners",jcb:"jcb"}[e.toLowerCase().replace(/[\s-_]/g,"")]||"unknown"}addExpiryFormatter(e){e&&(e.addEventListener("input",e=>{const t=e.target;t.value=(0,d.formatExpiryInput)(t.value),this.emit("change",{field:"expiry"})}),e.addEventListener("keypress",e=>{const t=String.fromCharCode(e.which);/[0-9\/]/.test(t)||8===e.which||e.preventDefault()}))}parseExpiry(e){return(null==e?void 0:e.value)?(0,d.parseExpiryDate)(e.value):null}applyInputStyles(e,t,n){const i=t.input,r="0"===t.container.gap;if(Object.assign(e.style,{height:i.height,padding:i.padding,fontSize:i.fontSize,fontFamily:i.fontFamily,backgroundColor:i.backgroundColor,color:i.color,boxSizing:"border-box",width:"100%",transition:i.transition}),r&&n){switch(e.style.borderTop=i.border,e.style.borderBottom=i.border,n){case"left":case"middle":e.style.borderLeft=i.border,e.style.borderRight="none";break;case"right":e.style.borderLeft=i.border,e.style.borderRight=i.border}e.style.borderRadius=(0,d.getConnectedBorderRadius)(i.borderRadius,n,!0)}else e.style.border=i.border,e.style.borderRadius=i.borderRadius;(0,d.addFocusHandlers)(e,t)}generateFieldIds(e){return{numberId:`${e}-card-number`,expiryId:`${e}-expiry`,cvvId:`${e}-cvv`}}static create(e,t,i){return s(this,void 0,void 0,function*(){switch(e.backend_name){case"spreedly":{const{SpreedlyTokenizer:r}=yield Promise.resolve().then(()=>a(n(875)));return r.create(e,t,i)}case"card_connect":{const{CardConnectTokenizer:r}=yield Promise.resolve().then(()=>a(n(601)));return r.create(e,t,i)}case"paypal_checkout":{const{PayPalTokenizer:r}=yield Promise.resolve().then(()=>a(n(138)));return r.create(e,t,i)}default:throw new Error(`Unsupported payment backend: ${e.backend_name}`)}})}}},454:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.DEFAULT_UNIFIED_STYLES=void 0,t.mergeStyles=function(e,t){return t?{input:Object.assign(Object.assign({},e.input),t.input),focus:Object.assign(Object.assign({},e.focus),t.focus),error:Object.assign(Object.assign({},e.error),t.error),container:Object.assign(Object.assign({},e.container),t.container)}:e},t.getContainerStylesForLayout=function(e,t="single-line"){return"two-line"===t?Object.assign(Object.assign({},e),{container:Object.assign(Object.assign({},e.container),{flexWrap:"wrap",rowGap:e.container.rowGap||e.container.gap})}):e},t.DEFAULT_UNIFIED_STYLES={input:{height:"40px",padding:"10px 12px",fontSize:"14px",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',color:"#333",backgroundColor:"white",border:"1px solid #ccc",borderRadius:"4px",boxSizing:"border-box",width:"100%",transition:"all 0.15s ease-in-out"},focus:{borderColor:"#007bff",outline:"none",boxShadow:"0 0 0 2px rgba(0, 123, 255, 0.25)"},error:{borderColor:"#dc3545"},container:{display:"flex",gap:"1rem",alignItems:"center",flexWrap:"nowrap",rowGap:"1rem"}}},472:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.receiveEmbedData=function(){let e;return new Promise((t,n)=>{window.parent||n("Cannot receive data without parent"),e=e=>{let n;try{n=JSON.parse(e.data)}catch(e){return}n.embedData&&t(n.embedData)},window.addEventListener("message",e)}).then(t=>(window.removeEventListener("message",e),t))},t.sanitizeString=o,t.sanitizeArray=a,t.sanitizeObject=s,t.splitName=function(e){const t=e.split(" ");return{firstName:t.slice(0,-1).join(" ")||"NOT GIVEN",lastName:t.slice(-1).join(" ")}},t.parseResponse=function(e,t){return e.json().then(n=>{const o=[];if(200!==e.status&&(void 0!==n.result&&Object.keys(n.result).forEach(e=>{o.push(new i.ClientError(e+": "+n.result[e].join("\n "),{field:e}))}),void 0!==n.messages?n.messages.forEach(e=>{"error"===e.category&&o.push(new i.ClientError(e.message))}):o.push(new i.ClientError(n.message))),t&&t.throwErrors&&o.length)throw(0,r.collapseClientErrors)(o);return{errors:o,_raw_response:n}})};const i=n(523),r=n(156);function o(e){if(!e)return e;const t=document.createElement("div");t.innerHTML=e;const n=Array.from(t.getElementsByTagName("script"));for(const e of n)e.parentNode&&e.parentNode.removeChild(e);return t.innerHTML}function a(e){return e.map(s)}function s(e){if(null==e)return e;if(Array.isArray(e))return a(e);if("string"==typeof e)return o(e);if("object"==typeof e){const t={};for(const[n,i]of Object.entries(e))Array.isArray(i)?t[n]=a(i):t[n]="string"==typeof i?o(i):s(i);return t}return e}},523:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.ClientError=t.ApplePaySessionStatus=void 0,t.ApplePaySessionStatus={STATUS_SUCCESS:"undefined"!=typeof ApplePaySession?ApplePaySession.STATUS_SUCCESS:1,STATUS_FAILURE:"undefined"!=typeof ApplePaySession?ApplePaySession.STATUS_FAILURE:0};class n extends Error{constructor(e,t){super(e),this.message=e,this.details=t,Error.captureStackTrace&&Error.captureStackTrace(this,n)}}t.ClientError=n},578:function(e,t,n){var i,r=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return o(t,e),t});Object.defineProperty(t,"__esModule",{value:!0}),t.iats=t.TokenizationError=t.PayPalTokenizer=t.CardConnectTokenizer=t.SpreedlyTokenizer=t.Tokenizer=void 0;const s=a(n(903));t.iats=s;var d=n(415);Object.defineProperty(t,"Tokenizer",{enumerable:!0,get:function(){return d.Tokenizer}});var l=n(875);Object.defineProperty(t,"SpreedlyTokenizer",{enumerable:!0,get:function(){return l.SpreedlyTokenizer}});var c=n(601);Object.defineProperty(t,"CardConnectTokenizer",{enumerable:!0,get:function(){return c.CardConnectTokenizer}});var u=n(138);Object.defineProperty(t,"PayPalTokenizer",{enumerable:!0,get:function(){return u.PayPalTokenizer}});var h=n(367);Object.defineProperty(t,"TokenizationError",{enumerable:!0,get:function(){return h.TokenizationError}})},592:function(e,t){var n=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.fetchSpreedlySecurityArgs=function(e,t,i){return n(this,void 0,void 0,function*(){if(!e.enableSpreedlySecureTokenization)throw new Error("Secure tokenization is not enabled");const r=()=>n(this,void 0,void 0,function*(){const n=yield fetch(`${e.embedApiBaseUrl}/spreedly/security-args`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({organization_id:t,embed_id:i})});if(!n.ok)throw new Error(`Security args request failed: ${n.status}`);return n.json()});try{return yield r()}catch(e){if(e instanceof TypeError&&e.message.includes("fetch"))return yield new Promise(e=>setTimeout(e,1e3)),r();throw e}})}},601:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.CardConnectTokenizer=void 0;const o=n(415),a=n(367),s=r(n(731)),d=n(454),l=n(799),c=n(631);class u extends o.Tokenizer{constructor(e,t,n,i="credit_card",r=!1,o="single-line"){super(),this.iframeUrl=t,this.containerId=n,this.layout=o,this.enableTestMode=!1,this.mode=i,this.enableTestMode=r,this.iframe=e;const a=new URL(t);this.expectedOrigin=`${a.protocol}//${a.host}`,this.currentValidationState={isValid:!1,cardNumber:{isValid:!1,isEmpty:!0},cvv:{isValid:!1,isEmpty:!0},expiry:{isValid:!1,isEmpty:!0}}}static create(e,t,n){return i(this,void 0,void 0,function*(){var i;if("bank_account"===t.mode&&"CA"===t.bankCountry)throw new Error("CardConnect does not support Canadian bank accounts");let r=(null===(i=e.config)||void 0===i?void 0:i.base_url)||n.clientConfig.cardConnectBaseUrl;n.cardConnectBaseUrl=r;const o=(0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,t.styling),a=u.generateIframeUrl(r,t),s=u.createIframe(a,o),l=new u(s,a,t.containerId,t.mode||"credit_card",t.enableTestMode||!1,t.layout||"single-line");return l.createInternalElements(t),yield l.init(),l})}createInternalElements(e){const t=document.getElementById(e.containerId);if(!t)throw new Error(`Container element not found: ${e.containerId}`);this.containerEl=t,t.innerHTML="";const n=(0,d.getContainerStylesForLayout)((0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,e.styling),this.layout);Object.assign(t.style,n.container),"bank_account"===this.mode?this.createBankAccountFields(t,n):this.createCreditCardFields(t,n)}createCreditCardFields(e,t){if(this.iframe.style.width="100%","two-line"===this.layout){const e=t.input.height||"40px";this.iframe.style.height=`calc((${e}) * 2 + 10px)`}else this.iframe.style.height=t.input.height||"40px";this.iframe.style.border="none",this.iframe.style.display="block",e.appendChild(this.iframe)}createBankAccountFields(e,t){this.iframe.style.display="none","two-line"===this.layout?(this.accountTypeEl=(0,c.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:"1",minWidth:l.BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,t,"left"),e.appendChild(this.accountTypeEl),this.routingNumberEl=(0,c.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:"1",minWidth:l.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,t,"right"),e.appendChild(this.routingNumberEl),this.accountNumberEl=(0,c.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:"1",flexBasis:"100%",minWidth:l.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,t),e.appendChild(this.accountNumberEl)):(this.routingNumberEl=(0,c.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:l.BANK_FIELD_FLEX.routingNumber.flex,minWidth:l.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,t,"left"),e.appendChild(this.routingNumberEl),this.accountNumberEl=(0,c.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:l.BANK_FIELD_FLEX.accountNumber.flex,minWidth:l.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,t,"middle"),e.appendChild(this.accountNumberEl),this.accountTypeEl=(0,c.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:l.BANK_FIELD_FLEX.accountType.flex,minWidth:l.BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,t,"right"),e.appendChild(this.accountTypeEl))}init(){return i(this,void 0,void 0,function*(){return"bank_account"===this.mode?(this.enableTestMode&&setTimeout(()=>{this.routingNumberEl&&(this.routingNumberEl.value="021000021",this.routingNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountNumberEl&&(this.accountNumberEl.value="9876543210",this.accountNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountTypeEl&&(this.accountTypeEl.value="checking",this.accountTypeEl.dispatchEvent(new Event("change",{bubbles:!0})))},100),this.emit("ready"),Promise.resolve()):new Promise((e,t)=>{const n=setTimeout(()=>{t(new Error("CardConnect initialization timeout"))},l.INIT_TIMEOUT);this.messageHandler=e=>{e.origin===this.expectedOrigin&&this.handleMessage(e)},window.addEventListener("message",this.messageHandler),this.iframe.onload=()=>{clearTimeout(n),this.enableTestMode&&this.mode,this.emit("ready"),e()},this.iframe.onerror=()=>{clearTimeout(n),t(new Error("Failed to load CardConnect iframe"))}})})}tokenize(e){return i(this,void 0,void 0,function*(){if(!this.isReady)throw new Error("Tokenizer not initialized");if("credit_card"===this.mode&&this.hasToken()){const e=this.getToken();if(e)return e}return"bank_account"===this.mode||this.isBankAccountData(e)?this.tokenizeBankAccountInternal(e):this.tokenizeCardInternal(e)})}tokenizeCardInternal(e){return i(this,void 0,void 0,function*(){return this.cachedTokenResult&&"0"===this.cachedTokenResult.errorCode?{token:this.cachedTokenResult.token,lastFour:this.cachedTokenResult.token.slice(-4),cardType:this.normalizeCardType("unknown"),provider:"cardconnect"}:(this.tokenizationPromise||(this.tokenizationPromise=new Promise((e,t)=>{this.tokenizationResolve=e,this.tokenizationReject=t;const n=setTimeout(()=>{this.tokenizationPromise=void 0,this.tokenizationResolve=void 0,this.tokenizationReject=void 0,t(new a.TokenizationError("Tokenization timeout - ensure all card fields are filled in iframe","TIMEOUT"))},l.TOKENIZE_TIMEOUT),i=e=>{clearTimeout(n),this.off("tokenization",i)};this.on("tokenization",i)})),this.tokenizationPromise)})}tokenizeBankAccountInternal(e){return i(this,void 0,void 0,function*(){var e,t,n;const i=null===(e=this.routingNumberEl)||void 0===e?void 0:e.value,r=null===(t=this.accountNumberEl)||void 0===t?void 0:t.value,o=(null===(n=this.accountTypeEl)||void 0===n?void 0:n.value)||"checking";if(!i||!r)throw new a.TokenizationError("Routing number and account number are required","VALIDATION_ERROR");if(!(0,c.validateRoutingNumber)(i))throw new a.TokenizationError("Invalid routing number","VALIDATION_ERROR");if(!(0,c.validateAccountNumber)(r))throw new a.TokenizationError("Invalid account number","VALIDATION_ERROR");const d=new URL(this.iframeUrl).origin,l=new s.default({});return l.cardConnectBaseUrl=d,{token:(yield u.tokenizeBankAccount(i,r,l)).token,lastFour:r.slice(-4),accountType:o,paymentMethodType:"bank_account",provider:"cardconnect"}})}validate(){return i(this,void 0,void 0,function*(){if(!this.isReady)throw new Error("Tokenizer not initialized");return"bank_account"===this.mode?this.validateBankAccountInternal():this.validateCardInternal()})}validateCardInternal(){return i(this,void 0,void 0,function*(){const e=[];return this.currentValidationState.cardNumber?this.currentValidationState.cardNumber.isEmpty?e.push({field:"cardNumber",message:"Card number is required"}):this.currentValidationState.cardNumber.isValid||e.push({field:"cardNumber",message:"Invalid card number"}):e.push({field:"cardNumber",message:"Card number is required"}),this.currentValidationState.expiry?this.currentValidationState.expiry.isEmpty?e.push({field:"expiry",message:"Expiry date is required"}):this.currentValidationState.expiry.isValid||e.push({field:"expiry",message:"Invalid expiry date"}):e.push({field:"expiry",message:"Expiry date is required"}),this.currentValidationState.cvv?this.currentValidationState.cvv.isEmpty?e.push({field:"cvv",message:"CVV is required"}):this.currentValidationState.cvv.isValid||e.push({field:"cvv",message:"Invalid CVV"}):e.push({field:"cvv",message:"CVV is required"}),{isValid:this.currentValidationState.isValid,errors:e}})}validateBankAccountInternal(){return i(this,void 0,void 0,function*(){var e,t;const n=[];return(null===(e=this.routingNumberEl)||void 0===e?void 0:e.value)?(0,c.validateRoutingNumber)(this.routingNumberEl.value)||n.push({field:"routingNumber",message:"Invalid routing number"}):n.push({field:"routingNumber",message:"Routing number is required"}),(null===(t=this.accountNumberEl)||void 0===t?void 0:t.value)?(0,c.validateAccountNumber)(this.accountNumberEl.value)||n.push({field:"accountNumber",message:"Invalid account number"}):n.push({field:"accountNumber",message:"Account number is required"}),{isValid:0===n.length,errors:n}})}clear(){var e;"bank_account"===this.mode?(this.routingNumberEl&&(this.routingNumberEl.value=""),this.accountNumberEl&&(this.accountNumberEl.value=""),this.accountTypeEl&&(this.accountTypeEl.value="checking")):null===(e=this.iframe.contentWindow)||void 0===e||e.postMessage({action:"clear"},this.expectedOrigin),this.currentValidationState={isValid:!1,cardNumber:{isValid:!1,isEmpty:!0},cvv:{isValid:!1,isEmpty:!0},expiry:{isValid:!1,isEmpty:!0}},this.emit("validation",this.currentValidationState)}focus(e){var t;if("bank_account"===this.mode)"routingNumber"===e&&this.routingNumberEl?this.routingNumberEl.focus():"accountNumber"===e&&this.accountNumberEl&&this.accountNumberEl.focus();else{const n={cardNumber:"number",cvv:"cvv",expiry:"expiry"}[e];n&&(null===(t=this.iframe.contentWindow)||void 0===t||t.postMessage({action:"focus",field:n},this.expectedOrigin))}}destroy(){this.messageHandler&&window.removeEventListener("message",this.messageHandler),this.containerEl&&(this.containerEl.innerHTML=""),this.eventHandlers.clear()}hasToken(){var e,t;return"credit_card"===this.mode&&"0"===(null===(e=this.cachedTokenResult)||void 0===e?void 0:e.errorCode)&&!!(null===(t=this.cachedTokenResult)||void 0===t?void 0:t.token)}getToken(){var e;if("credit_card"===this.mode&&"0"===(null===(e=this.cachedTokenResult)||void 0===e?void 0:e.errorCode)){const e=this.cachedTokenResult.cardType?this.normalizeCardType(this.cachedTokenResult.cardType):this.normalizeCardType("unknown");return{token:this.cachedTokenResult.token,lastFour:this.cachedTokenResult.last4||this.cachedTokenResult.token.slice(-4),cardType:e,provider:"cardconnect"}}return null}get tokenizationMode(){return"credit_card"===this.mode?"auto":"manual"}handleMessage(e){try{const t="string"==typeof e.data?JSON.parse(e.data):e.data;if(t.token&&void 0!==t.errorCode)if(this.cachedTokenResult=t,this.emit("tokenization",t),"0"===t.errorCode){const e=t.cardType?this.normalizeCardType(t.cardType):this.normalizeCardType("unknown");t.cardType&&e!==this.currentCardType&&(this.currentCardType=e,this.emit("cardTypeChange",{cardType:e}));const n={token:t.token,lastFour:t.last4||t.token.slice(-4),cardType:e,provider:"cardconnect"};this.tokenizationResolve&&(this.tokenizationResolve(n),this.tokenizationPromise=void 0,this.tokenizationResolve=void 0,this.tokenizationReject=void 0),this.currentValidationState={isValid:!0,cardNumber:{isValid:!0,isEmpty:!1},cvv:{isValid:!0,isEmpty:!1},expiry:{isValid:!0,isEmpty:!1}},this.emit("validation",{isValid:!0}),this.emit("tokenReady",n)}else this.tokenizationReject&&(this.tokenizationReject(new a.TokenizationError(t.errorMessage||"Tokenization failed",t.errorCode||"UNKNOWN")),this.tokenizationPromise=void 0,this.tokenizationResolve=void 0,this.tokenizationReject=void 0);if("validation"!==t.event&&void 0===t.validationError||this.handleValidationMessage(t),"focus"!==t.event&&"blur"!==t.event||this.emit(t.event,{field:t.data}),("input"===t.event||"change"===t.event)&&(this.emit("change",{field:t.data}),t.cardType)){const e=this.normalizeCardType(t.cardType);e!==this.currentCardType&&(this.currentCardType=e,this.emit("cardTypeChange",{cardType:e}))}}catch(e){}}handleValidationMessage(e){var t,n,i,r,o,s;if(e.validationError){const t=e.validationError.toLowerCase();t.includes("card")||t.includes("number")?this.currentValidationState.cardNumber={isValid:!1,isEmpty:!1}:t.includes("cvv")||t.includes("security")?this.currentValidationState.cvv={isValid:!1,isEmpty:!1}:(t.includes("expir")||t.includes("month")||t.includes("year"))&&(this.currentValidationState.expiry={isValid:!1,isEmpty:!1}),this.emit("error",new a.TokenizationError(e.validationError))}this.currentValidationState.isValid=null!==(n=null===(t=this.currentValidationState.cardNumber)||void 0===t?void 0:t.isValid)&&void 0!==n&&n&&null!==(r=null===(i=this.currentValidationState.cvv)||void 0===i?void 0:i.isValid)&&void 0!==r&&r&&null!==(s=null===(o=this.currentValidationState.expiry)||void 0===o?void 0:o.isValid)&&void 0!==s&&s}static generateIframeUrl(e,t){const n=new URLSearchParams({invalidinputevent:"true",enhancedresponse:"true",useexpiry:"true",usecvv:"true",formatinput:"true",unique:"true",norsa:"true",placeholder:"Card Number *",placeholdercvv:"CVV",invalidcreditcardevent:"true",invalidexpiry:"true",invalidcvv:"true"});"two-line"===t.layout?(n.set("useexpiryfield","true"),n.set("orientation","horizontal"),n.set("placeholdermonth","MM"),n.set("placeholderyear","YYYY")):(n.set("orientation","horizontal"),n.set("placeholdermonth","MM"),n.set("placeholderyear","YYYY"));const i=(0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,t.styling),r=u.generateCardConnectCss(i,t.layout||"single-line"),o=[];return n.forEach((e,t)=>{o.push(`${encodeURIComponent(t)}=${encodeURIComponent(e)}`)}),o.push(`css=${r}`),`${e}/itoke/ajax-tokenizer.html?${o.join("&")}`}static createIframe(e,t){const n=document.createElement("iframe");return n.src=e,n.style.width="100%",n.style.height=t.input.height,n.style.border="none",n.style.overflow="hidden",n.style.display="block",n.style.minWidth="0",t.container&&(Object.entries(t.container).forEach(([e,t])=>{"height"!==e&&"width"!==e&&(n.style[e]=t)}),t.container.width&&(n.style.width=t.container.width)),n.setAttribute("scrolling","no"),n.setAttribute("title","Secure card input"),n.setAttribute("sandbox","allow-scripts allow-same-origin allow-forms"),n}static generateCardConnectCss(e,t="single-line"){var n,i,r,o;const a=[];"two-line"===t?(a.push("html,form,body{margin:0;padding:0;}"),a.push("label{display:none;}"),a.push("br{display:none;}")):(a.push("body{margin:0;padding:0;display:flex;align-items:center;}"),a.push("form{margin:0;padding:0;display:flex;width:100%;align-items:center;}"),a.push("label{display:none;}"),a.push("br{display:none;}"));const s="0"===e.container.gap,d=s?"0":e.container.gap||"1rem";if(e.input){const t=[];e.input.height&&t.push(`height:${e.input.height}`),e.input.padding&&t.push(`padding:${e.input.padding}`),e.input.fontSize&&t.push(`font-size:${e.input.fontSize}`),e.input.fontFamily&&t.push(`font-family:${e.input.fontFamily}`),e.input.border&&t.push(`border:${e.input.border}`),e.input.backgroundColor&&t.push(`background-color:${e.input.backgroundColor}`),e.input.color&&t.push(`color:${e.input.color}`),t.push("box-sizing:border-box");const n=t.join(";");a.push(`input{${n};}`),a.push(`select{${n};}`)}if("two-line"===t)a.push("input#ccnumfield{width:100%;display:block;margin-bottom:8px;}"),a.push("input#ccexpiryfieldmonth{width:20%;}"),a.push("input#ccexpiryfieldyear{width:24%;}"),a.push("input#cccvvfield{width:calc(56% - 20px);}"),(null===(n=e.input)||void 0===n?void 0:n.borderRadius)&&a.push(`input{border-radius:${e.input.borderRadius};}`);else if(s)a.push("input#ccnumfield{width:44%;margin:0;}"),a.push("select#ccexpirymonth{width:16%;margin:0;margin-right:-12px;}"),a.push("select#ccexpiryyear{width:20%;}"),a.push("input#cccvvfield{width:20%;margin:0;margin-left:-12px;}"),(null===(i=e.input)||void 0===i?void 0:i.borderRadius)?(a.push(`input#ccnumfield{border-radius:${e.input.borderRadius} 0 0 ${e.input.borderRadius};border-right:none;}`),a.push("select#ccexpirymonth{border-radius:0;border-right:none;}"),a.push("select#ccexpiryyear{border-radius:0;border-right:none;}"),a.push(`input#cccvvfield{border-radius:0 ${e.input.borderRadius} ${e.input.borderRadius} 0;}`)):(a.push("input#ccnumfield{border-right:none;}"),a.push("select#ccexpirymonth{border-right:none;}"),a.push("select#ccexpiryyear{border-right:none;}"));else{const t="0"===d?"0":"8px";a.push(`input#ccnumfield{width:50%;margin-right:${t};}`),a.push(`select#ccexpirymonth{width:15%;margin-right:${t};}`),a.push(`select#ccexpiryyear{width:20%;margin-right:${t};}`),a.push("input#cccvvfield{width:15%;}"),(null===(r=e.input)||void 0===r?void 0:r.borderRadius)&&a.push(`input,select{border-radius:${e.input.borderRadius};}`)}if(e.focus){const t=[];e.focus.borderColor&&t.push(`border-color:${e.focus.borderColor}`),e.focus.outline&&t.push("outline:none"),e.focus.boxShadow&&t.push(`box-shadow:${e.focus.boxShadow}`),t.length>0&&(a.push(`input:focus{${t.join(";")};}`),a.push(`select:focus{${t.join(";")};}`),s&&(null===(o=e.input)||void 0===o?void 0:o.border)&&(a.push(`input#ccnumfield:focus{border:${e.input.border};${t.join(";")};}`),a.push(`select#ccexpirymonth:focus{border:${e.input.border};${t.join(";")};}`),a.push(`select#ccexpiryyear:focus{border:${e.input.border};${t.join(";")};}`)))}if(e.error){const t=[];e.error.borderColor&&t.push(`border-color:${e.error.borderColor}`),e.error.backgroundColor&&t.push(`background-color:${e.error.backgroundColor}`),t.length>0&&a.push(`.error{${t.join(";")};}`)}return encodeURIComponent(a.join(""))}static tokenizeBankAccount(e,t,n){return fetch(`${n.cardConnectBaseUrl}/cardsecure/api/v1/ccn/tokenize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:`${e}/${t}`,unique:!0})}).then(e=>e.json())}}t.CardConnectTokenizer=u},611:(e,t,n)=>{var i;n.r(t),n.d(t,{NIL:()=>P,parse:()=>b,stringify:()=>c,v1:()=>y,v3:()=>w,v4:()=>S,v5:()=>k,validate:()=>s,version:()=>O});var r=new Uint8Array(16);function o(){if(!i&&!(i="undefined"!=typeof crypto&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto)||"undefined"!=typeof msCrypto&&"function"==typeof msCrypto.getRandomValues&&msCrypto.getRandomValues.bind(msCrypto)))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return i(r)}const a=/^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000)$/i,s=function(e){return"string"==typeof e&&a.test(e)};for(var d=[],l=0;l<256;++l)d.push((l+256).toString(16).substr(1));const c=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=(d[e[t+0]]+d[e[t+1]]+d[e[t+2]]+d[e[t+3]]+"-"+d[e[t+4]]+d[e[t+5]]+"-"+d[e[t+6]]+d[e[t+7]]+"-"+d[e[t+8]]+d[e[t+9]]+"-"+d[e[t+10]]+d[e[t+11]]+d[e[t+12]]+d[e[t+13]]+d[e[t+14]]+d[e[t+15]]).toLowerCase();if(!s(n))throw TypeError("Stringified UUID is invalid");return n};var u,h,p=0,m=0;const y=function(e,t,n){var i=t&&n||0,r=t||new Array(16),a=(e=e||{}).node||u,s=void 0!==e.clockseq?e.clockseq:h;if(null==a||null==s){var d=e.random||(e.rng||o)();null==a&&(a=u=[1|d[0],d[1],d[2],d[3],d[4],d[5]]),null==s&&(s=h=16383&(d[6]<<8|d[7]))}var l=void 0!==e.msecs?e.msecs:Date.now(),y=void 0!==e.nsecs?e.nsecs:m+1,b=l-p+(y-m)/1e4;if(b<0&&void 0===e.clockseq&&(s=s+1&16383),(b<0||l>p)&&void 0===e.nsecs&&(y=0),y>=1e4)throw new Error("uuid.v1(): Can't create more than 10M uuids/sec");p=l,m=y,h=s;var v=(1e4*(268435455&(l+=122192928e5))+y)%4294967296;r[i++]=v>>>24&255,r[i++]=v>>>16&255,r[i++]=v>>>8&255,r[i++]=255&v;var f=l/4294967296*1e4&268435455;r[i++]=f>>>8&255,r[i++]=255&f,r[i++]=f>>>24&15|16,r[i++]=f>>>16&255,r[i++]=s>>>8|128,r[i++]=255&s;for(var g=0;g<6;++g)r[i+g]=a[g];return t||c(r)},b=function(e){if(!s(e))throw TypeError("Invalid UUID");var t,n=new Uint8Array(16);return n[0]=(t=parseInt(e.slice(0,8),16))>>>24,n[1]=t>>>16&255,n[2]=t>>>8&255,n[3]=255&t,n[4]=(t=parseInt(e.slice(9,13),16))>>>8,n[5]=255&t,n[6]=(t=parseInt(e.slice(14,18),16))>>>8,n[7]=255&t,n[8]=(t=parseInt(e.slice(19,23),16))>>>8,n[9]=255&t,n[10]=(t=parseInt(e.slice(24,36),16))/1099511627776&255,n[11]=t/4294967296&255,n[12]=t>>>24&255,n[13]=t>>>16&255,n[14]=t>>>8&255,n[15]=255&t,n};function v(e,t,n){function i(e,i,r,o){if("string"==typeof e&&(e=function(e){e=unescape(encodeURIComponent(e));for(var t=[],n=0;n<e.length;++n)t.push(e.charCodeAt(n));return t}(e)),"string"==typeof i&&(i=b(i)),16!==i.length)throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");var a=new Uint8Array(16+e.length);if(a.set(i),a.set(e,i.length),(a=n(a))[6]=15&a[6]|t,a[8]=63&a[8]|128,r){o=o||0;for(var s=0;s<16;++s)r[o+s]=a[s];return r}return c(a)}try{i.name=e}catch(e){}return i.DNS="6ba7b810-9dad-11d1-80b4-00c04fd430c8",i.URL="6ba7b811-9dad-11d1-80b4-00c04fd430c8",i}function f(e){return 14+(e+64>>>9<<4)+1}function g(e,t){var n=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(n>>16)<<16|65535&n}function E(e,t,n,i,r,o){return g((a=g(g(t,e),g(i,o)))<<(s=r)|a>>>32-s,n);var a,s}function _(e,t,n,i,r,o,a){return E(t&n|~t&i,e,t,r,o,a)}function N(e,t,n,i,r,o,a){return E(t&i|n&~i,e,t,r,o,a)}function I(e,t,n,i,r,o,a){return E(t^n^i,e,t,r,o,a)}function T(e,t,n,i,r,o,a){return E(n^(t|~i),e,t,r,o,a)}const w=v("v3",48,function(e){if("string"==typeof e){var t=unescape(encodeURIComponent(e));e=new Uint8Array(t.length);for(var n=0;n<t.length;++n)e[n]=t.charCodeAt(n)}return function(e){for(var t=[],n=32*e.length,i="0123456789abcdef",r=0;r<n;r+=8){var o=e[r>>5]>>>r%32&255,a=parseInt(i.charAt(o>>>4&15)+i.charAt(15&o),16);t.push(a)}return t}(function(e,t){e[t>>5]|=128<<t%32,e[f(t)-1]=t;for(var n=1732584193,i=-271733879,r=-1732584194,o=271733878,a=0;a<e.length;a+=16){var s=n,d=i,l=r,c=o;n=_(n,i,r,o,e[a],7,-680876936),o=_(o,n,i,r,e[a+1],12,-389564586),r=_(r,o,n,i,e[a+2],17,606105819),i=_(i,r,o,n,e[a+3],22,-1044525330),n=_(n,i,r,o,e[a+4],7,-176418897),o=_(o,n,i,r,e[a+5],12,1200080426),r=_(r,o,n,i,e[a+6],17,-1473231341),i=_(i,r,o,n,e[a+7],22,-45705983),n=_(n,i,r,o,e[a+8],7,1770035416),o=_(o,n,i,r,e[a+9],12,-1958414417),r=_(r,o,n,i,e[a+10],17,-42063),i=_(i,r,o,n,e[a+11],22,-1990404162),n=_(n,i,r,o,e[a+12],7,1804603682),o=_(o,n,i,r,e[a+13],12,-40341101),r=_(r,o,n,i,e[a+14],17,-1502002290),n=N(n,i=_(i,r,o,n,e[a+15],22,1236535329),r,o,e[a+1],5,-165796510),o=N(o,n,i,r,e[a+6],9,-1069501632),r=N(r,o,n,i,e[a+11],14,643717713),i=N(i,r,o,n,e[a],20,-373897302),n=N(n,i,r,o,e[a+5],5,-701558691),o=N(o,n,i,r,e[a+10],9,38016083),r=N(r,o,n,i,e[a+15],14,-660478335),i=N(i,r,o,n,e[a+4],20,-405537848),n=N(n,i,r,o,e[a+9],5,568446438),o=N(o,n,i,r,e[a+14],9,-1019803690),r=N(r,o,n,i,e[a+3],14,-187363961),i=N(i,r,o,n,e[a+8],20,1163531501),n=N(n,i,r,o,e[a+13],5,-1444681467),o=N(o,n,i,r,e[a+2],9,-51403784),r=N(r,o,n,i,e[a+7],14,1735328473),n=I(n,i=N(i,r,o,n,e[a+12],20,-1926607734),r,o,e[a+5],4,-378558),o=I(o,n,i,r,e[a+8],11,-2022574463),r=I(r,o,n,i,e[a+11],16,1839030562),i=I(i,r,o,n,e[a+14],23,-35309556),n=I(n,i,r,o,e[a+1],4,-1530992060),o=I(o,n,i,r,e[a+4],11,1272893353),r=I(r,o,n,i,e[a+7],16,-155497632),i=I(i,r,o,n,e[a+10],23,-1094730640),n=I(n,i,r,o,e[a+13],4,681279174),o=I(o,n,i,r,e[a],11,-358537222),r=I(r,o,n,i,e[a+3],16,-722521979),i=I(i,r,o,n,e[a+6],23,76029189),n=I(n,i,r,o,e[a+9],4,-640364487),o=I(o,n,i,r,e[a+12],11,-421815835),r=I(r,o,n,i,e[a+15],16,530742520),n=T(n,i=I(i,r,o,n,e[a+2],23,-995338651),r,o,e[a],6,-198630844),o=T(o,n,i,r,e[a+7],10,1126891415),r=T(r,o,n,i,e[a+14],15,-1416354905),i=T(i,r,o,n,e[a+5],21,-57434055),n=T(n,i,r,o,e[a+12],6,1700485571),o=T(o,n,i,r,e[a+3],10,-1894986606),r=T(r,o,n,i,e[a+10],15,-1051523),i=T(i,r,o,n,e[a+1],21,-2054922799),n=T(n,i,r,o,e[a+8],6,1873313359),o=T(o,n,i,r,e[a+15],10,-30611744),r=T(r,o,n,i,e[a+6],15,-1560198380),i=T(i,r,o,n,e[a+13],21,1309151649),n=T(n,i,r,o,e[a+4],6,-145523070),o=T(o,n,i,r,e[a+11],10,-1120210379),r=T(r,o,n,i,e[a+2],15,718787259),i=T(i,r,o,n,e[a+9],21,-343485551),n=g(n,s),i=g(i,d),r=g(r,l),o=g(o,c)}return[n,i,r,o]}(function(e){if(0===e.length)return[];for(var t=8*e.length,n=new Uint32Array(f(t)),i=0;i<t;i+=8)n[i>>5]|=(255&e[i/8])<<i%32;return n}(e),8*e.length))}),S=function(e,t,n){var i=(e=e||{}).random||(e.rng||o)();if(i[6]=15&i[6]|64,i[8]=63&i[8]|128,t){n=n||0;for(var r=0;r<16;++r)t[n+r]=i[r];return t}return c(i)};function C(e,t,n,i){switch(e){case 0:return t&n^~t&i;case 1:case 3:return t^n^i;case 2:return t&n^t&i^n&i}}function A(e,t){return e<<t|e>>>32-t}const k=v("v5",80,function(e){var t=[1518500249,1859775393,2400959708,3395469782],n=[1732584193,4023233417,2562383102,271733878,3285377520];if("string"==typeof e){var i=unescape(encodeURIComponent(e));e=[];for(var r=0;r<i.length;++r)e.push(i.charCodeAt(r))}else Array.isArray(e)||(e=Array.prototype.slice.call(e));e.push(128);for(var o=e.length/4+2,a=Math.ceil(o/16),s=new Array(a),d=0;d<a;++d){for(var l=new Uint32Array(16),c=0;c<16;++c)l[c]=e[64*d+4*c]<<24|e[64*d+4*c+1]<<16|e[64*d+4*c+2]<<8|e[64*d+4*c+3];s[d]=l}s[a-1][14]=8*(e.length-1)/Math.pow(2,32),s[a-1][14]=Math.floor(s[a-1][14]),s[a-1][15]=8*(e.length-1)&4294967295;for(var u=0;u<a;++u){for(var h=new Uint32Array(80),p=0;p<16;++p)h[p]=s[u][p];for(var m=16;m<80;++m)h[m]=A(h[m-3]^h[m-8]^h[m-14]^h[m-16],1);for(var y=n[0],b=n[1],v=n[2],f=n[3],g=n[4],E=0;E<80;++E){var _=Math.floor(E/20),N=A(y,5)+C(_,b,v,f)+g+t[_]+h[E]>>>0;g=f,f=v,v=A(b,30)>>>0,b=y,y=N}n[0]=n[0]+y>>>0,n[1]=n[1]+b>>>0,n[2]=n[2]+v>>>0,n[3]=n[3]+f>>>0,n[4]=n[4]+g>>>0}return[n[0]>>24&255,n[0]>>16&255,n[0]>>8&255,255&n[0],n[1]>>24&255,n[1]>>16&255,n[1]>>8&255,255&n[1],n[2]>>24&255,n[2]>>16&255,n[2]>>8&255,255&n[2],n[3]>>24&255,n[3]>>16&255,n[3]>>8&255,255&n[3],n[4]>>24&255,n[4]>>16&255,n[4]>>8&255,255&n[4]]}),P="00000000-0000-0000-0000-000000000000",O=function(e){if(!s(e))throw TypeError("Invalid UUID");return parseInt(e.substr(14,1),16)}},631:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.parseExpiryDate=function(e){const t=e.split("/");if(2!==t.length)return null;const n=t[0],i=t[1];return 2!==n.length||2!==i.length?null:{month:n,year:"20"+i}},t.formatExpiryInput=function(e){let t=e.replace(/\D/g,"");return t=t.substring(0,4),t.length>=2?t.substring(0,2)+"/"+t.substring(2,4):t},t.withTimeout=function(e,t,n){return Promise.race([e,new Promise((e,i)=>setTimeout(()=>i(new Error(n)),t))])},t.getConnectedBorderRadius=function(e,t,n){if(!n)return e;switch(t){case"left":return`${e} 0 0 ${e}`;case"middle":return"0";case"right":return`0 ${e} ${e} 0`;default:return e}},t.addFocusHandlers=function(e,t,n,i){e.addEventListener("focus",()=>{t.focus&&Object.assign(e.style,t.focus),null==n||n()}),e.addEventListener("blur",()=>{e.style.border=t.input.border,e.style.outline="none",e.style.boxShadow="none",null==i||i()})},t.createFieldContainer=function(e,t,n,i){const r=document.createElement("div");return r.id=e,r.style.flex=t,r.style.display="flex",n&&(r.style.minWidth=n),i&&(r.style.maxWidth=i),r},t.createInputElement=function(e,t,n,i){const r=document.createElement("input");return r.id=e,r.type=t,r.placeholder=n,i&&(r.maxLength=i),r},t.validateRoutingNumber=function(e){const t=e.replace(/\D/g,"");if(9!==t.length)return!1;const n=t.split("").map(Number);return(3*n[0]+7*n[1]+1*n[2]+3*n[3]+7*n[4]+1*n[5]+3*n[6]+7*n[7]+1*n[8])%10==0},t.validateAccountNumber=function(e){const t=e.replace(/\D/g,"");return!(t.length<4||t.length>17)&&/^\d+$/.test(t)},t.maskAccountNumber=function(e){const t=e.replace(/\D/g,"");if(t.length<=4)return t;const n=t.slice(-4);return"*".repeat(t.length-4)+n},t.createAccountTypeSelect=function(e){const t=document.createElement("select");t.id=e;const n=document.createElement("option");n.value="checking",n.text="Checking";const i=document.createElement("option");return i.value="savings",i.text="Savings",t.appendChild(n),t.appendChild(i),t},t.validateInstitutionNumber=function(e){return 3===e.replace(/\D/g,"").length},t.validateTransitNumber=function(e){return 5===e.replace(/\D/g,"").length},t.validateCanadianAccountNumber=function(e){return e.replace(/\D/g,"").length>=7},t.formatCanadianRoutingNumber=function(e,t){return"0"+e.replace(/\D/g,"").padStart(3,"0")+t.replace(/\D/g,"").padStart(5,"0")}},712:function(e,t,n){var i,r=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return o(t,e),t}),s=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0});const l=n(523),c=n(156),u=n(247),h=n(472),p=d(n(953)),m=d(n(731)),y=n(875),b=a(n(777)),v=n(611),f=n(122),g=n(578),E={enableSandboxMode:!1,overrideBaseUrl:void 0,enableDelay:!1,secondsToDelay:0};t.default=class{get organizationId(){if(!this.currentOrganizationId)throw new Error("organizationId undefined");return this.currentOrganizationId}constructor(e,t,n){var i;this.clientKey=e,"string"==typeof t?this.embedId=t:(this.embedConfigCache=t,this.embedId=t.embed_id||"",t.organization_id&&(this.currentOrganizationId=t.organization_id)),this.currentOrganizationId||(this.currentOrganizationId=e),this.options=Object.assign({},E,n),this.allowTransaction=!1,this.config=new m.default(this.options);const r=Object.entries(this.config);for(const[e,t]of r){const n=Object.getOwnPropertyDescriptor(this,e);if(!n||void 0!==n.set)try{this[e]=t}catch(e){}}if(this.options.enableDelay&&this.options.secondsToDelay){const e=1e3*this.options.secondsToDelay;setTimeout(()=>{this.allowTransaction=!0},e)}else this.allowTransaction=!0;this.options.enableSandboxMode&&void 0!==console&&console.info(`[Sandbox] iDonate SDK Configuration (v${u.SDK_VERSION}):`,JSON.parse(JSON.stringify(this)));try{const{pcScriptBase:e,pcScriptId:t}=this.config;if(!e||!t)throw new Error("missing config");const n=(0,v.v4)(),i=window.document.createElement("script");i.setAttribute("src",e+"/"+n+".js"),i.setAttribute("id",t);let r=!1;const o=()=>{var e;try{if(r)return;window.document.body.append(i),r=!0}catch(t){null===(e=null===console||void 0===console?void 0:console.warn)||void 0===e||e.call(console,"not appended")}};o(),window.addEventListener("DOMContentLoaded",()=>{window.document.body.append(i)})}catch(e){null===(i=null===console||void 0===console?void 0:console.warn)||void 0===i||i.call(console,"Warning, partial initialization: ",String(e))}this.currentOrganizationId||this.setOrganizationId(this.clientKey)}createDonation(e){if(!this.allowTransaction)throw new Error("Wow, that was fast - try again");e.embedId||(e.embedId=this.embedId);const t=(0,c.buildCashPaymentPayload)(this.organizationId,e),n=e=>fetch(`${this.config.embedApiBaseUrl}/donate/cash-payment`,{method:"POST",headers:Object.assign(Object.assign(Object.assign({},u.CLIENT_HEADERS),e?{"cf-validation-token":e}:{}),{"User-Agent":u.CLIENT_HEADERS["User-Agent"]+" source:"+this.config.client}),body:JSON.stringify(t),credentials:"include"});return n().then(e=>s(this,void 0,void 0,function*(){if("challenge"===e.headers.get("cf-mitigated")){const t=yield(0,f.handleCFChallenge)(e,this);return n(null==t?void 0:t.token)}return e})).then(e=>(0,h.parseResponse)(e,{throwErrors:!0})).then(e=>(0,c.buildDonationResult)(e))}createTransaction(e){return this.createDonation(e).then(e=>{var t;return{transactionId:null===(t=e.transaction)||void 0===t?void 0:t.id,_raw_response:e._raw_response}})}createPaymentMethod(e){return e.embedId||(e.embedId=this.embedId),b.createPaymentMethod(e,this.config)}setOrganizationId(e){this.currentOrganizationId=e}waitForDonationResult(e,t){return new Promise((n,i)=>{setTimeout(()=>{let r;r=setInterval(()=>{fetch(`${this.config.embedApiBaseUrl}/donate/cash-payment/${e}/payment_status`,{method:"GET",headers:{"Content-Type":"application/json"}}).then(e=>e.json()).then(e=>e.result).then(e=>{(function(e){return!!e.processed&&!!e.transaction})(e)&&(r&&(clearInterval(r),r=null),e.error&&i(new l.ClientError(e.error)),n((0,c.buildDonationResult)({_raw_response:Object.assign({campaign:null,designation:{},donor:{},form_data:{},id:null,schedule:{},transaction:{}},e)}))),null==t||t()}).catch(e=>{r&&(clearInterval(r),r=null),i(e)})},2e3)},2e3)})}tokenizeCardConnectApplePay(e){const t=new p.default(e);let n="";const i=t.begin();return new Promise((e,r)=>{i.then(i=>{i.onvalidatemerchant=e=>{const o={apple_pay_url:this.config.applePayUrl,organization_id:this.organizationId};t.createSession(o,this.config.embedApiBaseUrl).then(e=>{n=e.result.merchantSessionIdentifier,i.completeMerchantValidation(e.result)}).catch(e=>{i.abort(),r(e)})},i.onpaymentauthorized=o=>{t.tokenizeWithCardConnect(o.payment,this.config.cardConnectBaseUrl).then(t=>{var r,a;const s=Object.assign(Object.assign({},o.payment.billingContact),{email:null===(r=o.payment.shippingContact)||void 0===r?void 0:r.emailAddress,phone:null===(a=o.payment.shippingContact)||void 0===a?void 0:a.phoneNumber});e({applePaySession:i,cardConnectResponse:t,billingContact:s,merchantSessionId:n})}).catch(e=>{i.abort(),r(e)})},i.oncancel=e=>{r(new Error("Apple Pay has been closed"))}}).catch(e=>r(e))})}createTokenizer(e,t){return s(this,void 0,void 0,function*(){return g.Tokenizer.create(e,t,{organizationId:this.organizationId,embedId:this.embedId,clientConfig:this.config})})}tokenizeSpreedlyPayPal(e){return y.SpreedlyTokenizer.tokenizePayPal(e,this.config)}selectGateway(e,t,n){if(n){const t=e.find(e=>e.id===n);if(t)return t}return e[0]}getEmbedConfig(){return s(this,void 0,void 0,function*(){return this.embedConfigCache?this.embedConfigCache:(this.embedConfigPromise||(this.embedConfigPromise=b.fetchEmbedConfig(this.embedId,this.config).then(e=>(this.embedConfigCache=e,e))),this.embedConfigPromise)})}getGateway(e){return s(this,void 0,void 0,function*(){const t=yield this.getEmbedConfig(),n=t.available_gateways.find(t=>t.id===e);if(!n)throw new Error(`Gateway ${e} not found in embed configuration. Available: ${t.available_gateways.map(e=>e.id).join(", ")}`);return n})}}},731:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0});const i=n(247);t.default=class{constructor(e){e.enableSandboxMode?(this.apiBaseUrl=i.SANDBOX_BASE_URL,this.cardConnectBaseUrl=i.SANDBOX_CARD_CONNECT_BASE_URL,this.applePayUrl=i.SANDBOX_APPLE_PAY_URL):(this.apiBaseUrl=i.PRODUCTION_BASE_URL,this.cardConnectBaseUrl=i.PRODUCTION_CARD_CONNECT_BASE_URL,this.applePayUrl=i.APPLE_PAY_URL),this.client=e.sdkClientName||i.DEFAULT_APP_NAME,e.overrideBaseUrl&&(this.apiBaseUrl=e.overrideBaseUrl),this.authApiBaseUrl=e.overrideAuthApiBaseUrl||`${this.apiBaseUrl}/auth`,this.donorApiBaseUrl=e.overrideDonorApiBaseUrl||`${this.apiBaseUrl}/donor`,this.embedApiBaseUrl=e.overrideEmbedApiBaseUrl||`${this.apiBaseUrl}/embed`,e.overrideApplePayUrl&&(this.applePayUrl=e.overrideApplePayUrl),e.overrideCardConnectBaseUrl&&(this.cardConnectBaseUrl=e.overrideCardConnectBaseUrl),this.pcScriptBase=e.pcScriptBase||i.FALLBACK_PC_SCRIPT_URL,this.pcScriptId=e.pcScriptId||i.FALLBACK_PC_SCRIPT_ID,this.turnstileCdnUrl=e.turnstileCdnUrl||i.DEFAULT_CF_TURNSTILE_CDN_EXPLICIT_URL,this.turnstileSiteKey=e.turnstileSiteKey||i.FALLBACK_CF_TURNSTILE_SITE_KEY,(null==e?void 0:e.spreedlyEnvironmentKey)&&(this.spreedlyEnvironmentKey=e.spreedlyEnvironmentKey),this.enableDelay=e.enableDelay||!1,this.secondsToDelay=e.secondsToDelay||0,this.enableSpreedlySecureTokenization=e.enableSpreedlySecureTokenization||!1,this.organizationId=e.organizationId,this.embedId=e.embedId,this.cardConnectTokenizerUrl=`${this.cardConnectBaseUrl}/itoke/ajax-tokenizer.html`}}},740:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0});class n{static resolveLib(e){const t=new Date;return new Promise((n,i)=>{!function r(){if(void 0!==window.google&&void 0!==window.google.payments){const t=new google.payments.api.PaymentsClient(e);n(t)}else(new Date).valueOf()-t.valueOf()>15e3?i(new Error("pay.js not loaded after 15 seconds")):setTimeout(r,250)}()})}static injectScript(){if(void 0!==window.google&&void 0!==window.google.payments)throw new Error("google payments is already injected");const e=document.createElement("script");e.src="https://pay.google.com/gp/p/js/pay.js?render=explicit",e.async=!0,e.defer=!0,document.body.appendChild(e)}constructor(e){this.baseRequest={apiVersion:2,apiVersionMinor:0},this.baseCardPaymentMethod={type:"CARD",parameters:{allowedAuthMethods:["PAN_ONLY","CRYPTOGRAM_3DS"],allowedCardNetworks:["AMEX","DISCOVER","INTERAC","JCB","MASTERCARD","VISA"],billingAddressRequired:!0,billingAddressParameters:{format:"FULL",phoneNumberRequired:!0}}},this.transactionInfo={countryCode:"US",currencyCode:"USD",totalPriceStatus:"FINAL",totalPrice:""},this.tokenizationSpecification={type:"PAYMENT_GATEWAY",parameters:{gateway:"cardconnect",gatewayMerchantId:""}},this.googlePayOptions={environment:"PRODUCTION"},this.paymentRequestDefaults=Object.assign(Object.assign({},this.baseRequest),{merchantInfo:{merchantId:""},transactionInfo:this.transactionInfo,emailRequired:!0,allowedPaymentMethods:[Object.assign(Object.assign({},this.baseCardPaymentMethod),{tokenizationSpecification:this.tokenizationSpecification})]}),this.paymentsClient=null;const{paymentOptions:t,cardConnectMerchantId:n,paymentDataRequest:i,baseCardPaymentMethodParameters:r={}}=e;this.tokenizationSpecification.parameters.gatewayMerchantId=n,this.paymentRequest=Object.assign({},this.paymentRequestDefaults,i),this.googlePayOptions=Object.assign({},this.googlePayOptions,Object.assign(Object.assign({},t),{merchantInfo:this.paymentRequest.merchantInfo})),this.baseCardPaymentMethod.parameters=Object.assign(Object.assign({},this.baseCardPaymentMethod.parameters),r)}getGoogleIsReadyToPayRequest(){return Object.assign({},this.baseRequest,{allowedPaymentMethods:[this.baseCardPaymentMethod]})}getGooglePaymentClient(){return new Promise((e,t)=>{this.paymentsClient?e(this.paymentsClient):n.resolveLib(this.googlePayOptions).then(t=>{this.paymentsClient=t,e(t)}).catch(e=>t(e))})}onGooglePaymentButtonClicked(e){const t=this.paymentRequest;return this.transactionInfo=Object.assign({},this.transactionInfo,e),t.transactionInfo=this.transactionInfo,new Promise((e,n)=>{this.paymentsClient?this.paymentsClient.loadPaymentData(t).then(t=>{e(t)}).catch(e=>{n(e)}):n(new Error("PaymentClient is not initialized"))})}tokenizeWithCardConnect(e,t){return fetch(`${t}/cardsecure/api/v1/ccn/tokenize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({encryptionhandler:"EC_GOOGLE_PAY",devicedata:e,unique:!0})}).then(e=>e.json())}}t.default=n},777:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.createPaymentMethod=function(e,t){const n=(0,i.buildCreatePaymentMethodPayload)(e);return fetch(`${t.embedApiBaseUrl}/payment/payment-methods`,{method:"POST",headers:r.CLIENT_HEADERS,body:JSON.stringify(n)}).then(e=>(0,o.parseResponse)(e,{throwErrors:!0})).then(e=>(0,i.buildCreatePaymentMethodResult)(e))},t.fetchEmbedConfig=function(e,t){return fetch(`${t.embedApiBaseUrl}/config/${e}`,{method:"GET",headers:r.CLIENT_HEADERS}).then(e=>(0,o.parseResponse)(e,{throwErrors:!0})).then(e=>e._raw_response.result)};const i=n(156),r=n(247),o=n(472)},799:(e,t)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.FIELD_CONSTRAINTS=t.PLACEHOLDERS=t.CANADIAN_BANK_FIELD_FLEX=t.BANK_FIELD_FLEX=t.FIELD_FLEX=t.TOKENIZE_TIMEOUT=t.INIT_TIMEOUT=void 0,t.INIT_TIMEOUT=1e4,t.TOKENIZE_TIMEOUT=3e4,t.FIELD_FLEX={cardNumber:{flex:"1 1 60%",minWidth:"150px"},expiry:{flex:"0 1 20%",minWidth:"70px"},cvv:{flex:"0 1 20%",minWidth:"60px"}},t.BANK_FIELD_FLEX={routingNumber:{flex:"0 1 30%",minWidth:"100px"},accountNumber:{flex:"1 1 45%",minWidth:"120px"},accountType:{flex:"0 1 25%",minWidth:"90px"}},t.CANADIAN_BANK_FIELD_FLEX={institutionNumber:{flex:"0 1 15%",minWidth:"60px"},transitNumber:{flex:"0 1 20%",minWidth:"80px"},accountNumber:{flex:"1 1 40%",minWidth:"110px"},accountType:{flex:"0 1 25%",minWidth:"90px"}},t.PLACEHOLDERS={cardNumber:"Card Number *",expiry:"MM/YY *",cvv:"CVV *"},t.FIELD_CONSTRAINTS={expiry:{maxLength:5,pattern:/^\d{0,2}\/?\d{0,2}$/},cvv:{maxLength:4}}},806:function(e,t,n){var i,r=this&&this.__createBinding||(Object.create?function(e,t,n,i){void 0===i&&(i=n);var r=Object.getOwnPropertyDescriptor(t,n);r&&!("get"in r?!t.__esModule:r.writable||r.configurable)||(r={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,i,r)}:function(e,t,n,i){void 0===i&&(i=n),e[i]=t[n]}),o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:!0,value:t})}:function(e,t){e.default=t}),a=this&&this.__importStar||(i=function(e){return i=Object.getOwnPropertyNames||function(e){var t=[];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[t.length]=n);return t},i(e)},function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var n=i(e),a=0;a<n.length;a++)"default"!==n[a]&&r(t,e,n[a]);return o(t,e),t}),s=this&&this.__exportStar||function(e,t){for(var n in e)"default"===n||Object.prototype.hasOwnProperty.call(t,n)||r(t,e,n)},d=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.GooglePay=t.ApplePay=t.constants=t.recaptcha=t.ConfigHandler=t.Client=t.shared=t.util=t.tokenize=void 0;const l=a(n(578));t.tokenize=l;const c=a(n(472));t.util=c;const u=a(n(115));t.recaptcha=u;const h=a(n(247));t.constants=h;const p=a(n(777));t.shared=p;const m=d(n(712));t.Client=m.default;const y=d(n(731));t.ConfigHandler=y.default;const b=d(n(953));t.ApplePay=b.default;const v=d(n(740));t.GooglePay=v.default,s(n(523),t)},875:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.SpreedlyTokenizer=void 0;const r=n(415),o=n(367),a=n(247),s=n(156),d=n(592),l=n(454),c=n(799),u=n(631);class h extends r.Tokenizer{constructor(e,t,n,i="credit_card",r="US",o=!1,a="single-line"){if(super(),this.environmentKey=e,this.containerId=t,this.layout=a,this.bankCountry="US",this.enableTestMode=!1,this.mode=i,this.bankCountry=r,this.enableTestMode=o,"credit_card"===i){const e=window.SpreedlyPaymentFrame;this.spreedly=e?new e:window.Spreedly}else this.spreedly=window.Spreedly;this.currentValidationState="bank_account"===i?{isValid:!1,routingNumber:{isValid:!1,isEmpty:!0},accountNumber:{isValid:!1,isEmpty:!0}}:{isValid:!1,cardNumber:{isValid:!1,isEmpty:!0},cvv:{isValid:!1,isEmpty:!0},expiry:{isValid:!1,isEmpty:!0}},this.mergedStyles=(0,l.getContainerStylesForLayout)((0,l.mergeStyles)(l.DEFAULT_UNIFIED_STYLES,n),this.layout);const s=this.generateFieldIds(t);this.numberEl=s.numberId,this.cvvEl=s.cvvId,this.expiryId=s.expiryId}static create(e,t,n){return i(this,void 0,void 0,function*(){var i;"bank_account"!==t.mode&&(yield h.ensureSpreedlyLoaded());let r=null===(i=e.config)||void 0===i?void 0:i.environment_key;!r&&n.clientConfig.spreedlyEnvironmentKey&&(r=n.clientConfig.spreedlyEnvironmentKey),r||(r="");const o=new h(r,t.containerId,t.styling,t.mode||"credit_card",t.bankCountry||"US",t.enableTestMode||!1,t.layout||"single-line");let a;if(o.organizationId=n.organizationId,o.embedId=n.embedId,o.clientConfig=n.clientConfig,o.createInternalElements(),"credit_card"===t.mode&&n.clientConfig.enableSpreedlySecureTokenization){if(!n.organizationId||!n.embedId)throw new Error("Secure tokenization is enabled but organizationId and embedId are required");try{a=yield(0,d.fetchSpreedlySecurityArgs)(n.clientConfig,n.organizationId,n.embedId)}catch(e){throw new Error(`Secure tokenization is enabled but failed to initialize: ${e instanceof Error?e.message:"Unknown error"}`)}}return yield o.init(a),o})}init(e){return i(this,void 0,void 0,function*(){return this.containerEl=document.getElementById(this.containerId),"bank_account"===this.mode?(this.enableTestMode&&setTimeout(()=>{"CA"===this.bankCountry?(this.institutionNumberEl&&(this.institutionNumberEl.value="004",this.institutionNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.transitNumberEl&&(this.transitNumberEl.value="12345",this.transitNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountNumberEl&&(this.accountNumberEl.value="1234567",this.accountNumberEl.dispatchEvent(new Event("input",{bubbles:!0})))):(this.routingNumberEl&&(this.routingNumberEl.value="021000021",this.routingNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountNumberEl&&(this.accountNumberEl.value="9876543210",this.accountNumberEl.dispatchEvent(new Event("input",{bubbles:!0}))),this.accountTypeEl&&(this.accountTypeEl.value="checking",this.accountTypeEl.dispatchEvent(new Event("change",{bubbles:!0}))))},100),this.emit("ready"),Promise.resolve()):new Promise((t,n)=>{const i=setTimeout(()=>{n(new Error("Spreedly initialization timeout"))},c.INIT_TIMEOUT);this.spreedly.on("ready",()=>{clearTimeout(i),this.spreedly.setPlaceholder("number",c.PLACEHOLDERS.cardNumber),this.spreedly.setFieldType("number","text"),this.spreedly.setNumberFormat("prettyFormat"),this.spreedly.setPlaceholder("cvv",c.PLACEHOLDERS.cvv),this.spreedly.setFieldType("cvv","text"),this.applyUnifiedStyles(),this.enableTestMode&&"credit_card"===this.mode&&this.spreedly.setValue&&(this.spreedly.setValue("number","4111111111111111"),this.spreedly.setValue("cvv","123"),setTimeout(()=>{this.expiryEl&&(this.expiryEl.value="12/34",this.expiryEl.dispatchEvent(new Event("input",{bubbles:!0})))},100)),this.emit("ready"),t()}),this.spreedly.on("errors",e=>{this.emit("error",new o.TokenizationError(e))}),this.spreedly.on("fieldEvent",(e,t,n,i)=>{this.handleFieldEvent(e,t,i)});const r={numberEl:this.numberEl,cvvEl:this.cvvEl};e&&(r.certificateToken=e.certificate_token,r.signature=e.signature,r.timestamp=e.timestamp,r.nonce=e.nonce),this.spreedly.init(this.environmentKey,r)})})}tokenize(e){return i(this,void 0,void 0,function*(){if(!this.isReady)throw new Error("Tokenizer not initialized");return"bank_account"===this.mode||this.isBankAccountData(e)?this.tokenizeBankAccountInternal(e):this.tokenizeCardInternal(e)})}tokenizeCardInternal(e){return i(this,void 0,void 0,function*(){return new Promise((t,n)=>{var i,r,a,s,d,l;const u=setTimeout(()=>{this.spreedly&&this.spreedly.removeHandlers&&this.spreedly.removeHandlers(),n(new o.TokenizationError("Tokenization timeout","TIMEOUT"))},c.TOKENIZE_TIMEOUT),h=()=>{clearTimeout(u),this.spreedly&&this.spreedly.removeHandlers&&this.spreedly.removeHandlers()};this.spreedly.on("paymentMethod",(e,n)=>{h();const i={token:e,lastFour:n.last_four_digits,cardType:this.normalizeCardType(n.card_type),provider:"spreedly"};this.emit("tokenReady",i),t(i)}),this.spreedly.on("errors",e=>{h(),n(new o.TokenizationError(e))});const p=this.parseExpiry(this.expiryEl);if(!p)return h(),void n(new o.TokenizationError("Expiration date is required","VALIDATION_ERROR"));const m=p.month,y=p.year;this.spreedly.tokenizeCreditCard({first_name:e.firstName,last_name:e.lastName,month:m,year:y,email:e.email,phone_number:e.phone,address1:null===(i=e.address)||void 0===i?void 0:i.address1,address2:null===(r=e.address)||void 0===r?void 0:r.address2,city:null===(a=e.address)||void 0===a?void 0:a.city,state:null===(s=e.address)||void 0===s?void 0:s.state,zip:null===(d=e.address)||void 0===d?void 0:d.zip,country:null===(l=e.address)||void 0===l?void 0:l.country})})})}createCanadianBankAccountFields(e){"two-line"===this.layout?(this.accountTypeEl=(0,u.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:"2",minWidth:c.CANADIAN_BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,this.mergedStyles,"left"),e.appendChild(this.accountTypeEl),this.institutionNumberEl=(0,u.createInputElement)(`${this.containerId}-institution`,"text","Inst *",3),Object.assign(this.institutionNumberEl.style,{flex:"1",minWidth:c.CANADIAN_BANK_FIELD_FLEX.institutionNumber.minWidth}),this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"middle"),this.institutionNumberEl.addEventListener("blur",()=>{!(0,u.validateInstitutionNumber)(this.institutionNumberEl.value)&&this.institutionNumberEl.value?this.applyErrorStyles(this.institutionNumberEl):this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"middle"),this.updateBankAccountValidation()}),e.appendChild(this.institutionNumberEl),this.transitNumberEl=(0,u.createInputElement)(`${this.containerId}-transit`,"text","Transit *",5),Object.assign(this.transitNumberEl.style,{flex:"2",minWidth:c.CANADIAN_BANK_FIELD_FLEX.transitNumber.minWidth}),this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"right"),this.transitNumberEl.addEventListener("blur",()=>{!(0,u.validateTransitNumber)(this.transitNumberEl.value)&&this.transitNumberEl.value?this.applyErrorStyles(this.transitNumberEl):this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"right"),this.updateBankAccountValidation()}),e.appendChild(this.transitNumberEl),this.accountNumberEl=(0,u.createInputElement)(`${this.containerId}-account`,"text","Account Number *"),Object.assign(this.accountNumberEl.style,{flex:"1",flexBasis:"100%",minWidth:c.CANADIAN_BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles),this.accountNumberEl.addEventListener("blur",()=>{!(0,u.validateCanadianAccountNumber)(this.accountNumberEl.value)&&this.accountNumberEl.value?this.applyErrorStyles(this.accountNumberEl):this.applyInputStyles(this.accountNumberEl,this.mergedStyles),this.updateBankAccountValidation()}),e.appendChild(this.accountNumberEl)):(this.institutionNumberEl=(0,u.createInputElement)(`${this.containerId}-institution`,"text","Inst *",3),Object.assign(this.institutionNumberEl.style,{flex:c.CANADIAN_BANK_FIELD_FLEX.institutionNumber.flex,minWidth:c.CANADIAN_BANK_FIELD_FLEX.institutionNumber.minWidth}),this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"left"),this.institutionNumberEl.addEventListener("blur",()=>{!(0,u.validateInstitutionNumber)(this.institutionNumberEl.value)&&this.institutionNumberEl.value?this.applyErrorStyles(this.institutionNumberEl):this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"left"),this.updateBankAccountValidation()}),e.appendChild(this.institutionNumberEl),this.transitNumberEl=(0,u.createInputElement)(`${this.containerId}-transit`,"text","Transit *",5),Object.assign(this.transitNumberEl.style,{flex:c.CANADIAN_BANK_FIELD_FLEX.transitNumber.flex,minWidth:c.CANADIAN_BANK_FIELD_FLEX.transitNumber.minWidth}),this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"middle"),this.transitNumberEl.addEventListener("blur",()=>{!(0,u.validateTransitNumber)(this.transitNumberEl.value)&&this.transitNumberEl.value?this.applyErrorStyles(this.transitNumberEl):this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"middle"),this.updateBankAccountValidation()}),e.appendChild(this.transitNumberEl),this.accountNumberEl=(0,u.createInputElement)(`${this.containerId}-account`,"text","Account Number *"),Object.assign(this.accountNumberEl.style,{flex:c.CANADIAN_BANK_FIELD_FLEX.accountNumber.flex,minWidth:c.CANADIAN_BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.accountNumberEl.addEventListener("blur",()=>{!(0,u.validateCanadianAccountNumber)(this.accountNumberEl.value)&&this.accountNumberEl.value?this.applyErrorStyles(this.accountNumberEl):this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.updateBankAccountValidation()}),e.appendChild(this.accountNumberEl),this.accountTypeEl=(0,u.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:c.CANADIAN_BANK_FIELD_FLEX.accountType.flex,minWidth:c.CANADIAN_BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,this.mergedStyles,"right"),e.appendChild(this.accountTypeEl))}tokenizeBankAccountInternal(e){return i(this,void 0,void 0,function*(){var t,n,i,r,a,s,d,l,c,p,m,y;if(!this.isReady)throw new Error("Tokenizer not initialized");if("bank_account"!==this.mode)throw new Error("Tokenizer not in bank account mode");let b,v;const f=(null===(t=this.accountTypeEl)||void 0===t?void 0:t.value)||"checking";if("CA"===this.bankCountry){const e=null===(n=this.institutionNumberEl)||void 0===n?void 0:n.value,t=null===(i=this.transitNumberEl)||void 0===i?void 0:i.value;if(v=null===(r=this.accountNumberEl)||void 0===r?void 0:r.value,!e||!t||!v)throw new o.TokenizationError("Institution number, transit number, and account number are required","VALIDATION_ERROR");if(!(0,u.validateInstitutionNumber)(e))throw new o.TokenizationError("Institution number must be 3 digits","VALIDATION_ERROR");if(!(0,u.validateTransitNumber)(t))throw new o.TokenizationError("Transit number must be 5 digits","VALIDATION_ERROR");if(!(0,u.validateCanadianAccountNumber)(v))throw new o.TokenizationError("Invalid account number","VALIDATION_ERROR");b=(0,u.formatCanadianRoutingNumber)(e,t)}else{if(b=null===(a=this.routingNumberEl)||void 0===a?void 0:a.value,v=null===(s=this.accountNumberEl)||void 0===s?void 0:s.value,!b||!v)throw new o.TokenizationError("Routing number and account number are required","VALIDATION_ERROR");if(!(0,u.validateRoutingNumber)(b))throw new o.TokenizationError("Invalid routing number","VALIDATION_ERROR");if(!(0,u.validateAccountNumber)(v))throw new o.TokenizationError("Invalid account number","VALIDATION_ERROR")}return{token:yield h.tokenizeBankAccount({contact:{firstName:e.firstName,lastName:e.lastName,email:e.email,primaryPhone:e.phone},address:{address1:null===(d=e.address)||void 0===d?void 0:d.address1,address2:null===(l=e.address)||void 0===l?void 0:l.address2,city:null===(c=e.address)||void 0===c?void 0:c.city,state:null===(p=e.address)||void 0===p?void 0:p.state,zip:null===(m=e.address)||void 0===m?void 0:m.zip,country:null===(y=e.address)||void 0===y?void 0:y.country},account:{accountNumber:v,routingNumber:b,accountType:f,accountHolderType:"personal"}},this.clientConfig),lastFour:v.slice(-4),accountType:f,paymentMethodType:"bank_account",provider:"spreedly"}})}validate(){return i(this,void 0,void 0,function*(){return"bank_account"===this.mode?this.validateBankAccountInternal():this.validateCardInternal()})}validateCardInternal(){return i(this,void 0,void 0,function*(){var e,t,n,i,r;const o=[];(null===(e=this.currentValidationState.cardNumber)||void 0===e?void 0:e.isEmpty)?o.push({field:"cardNumber",message:"Card number is required"}):(null===(t=this.currentValidationState.cardNumber)||void 0===t?void 0:t.isValid)||o.push({field:"cardNumber",message:"Invalid card number"}),(null===(n=this.currentValidationState.cvv)||void 0===n?void 0:n.isEmpty)?o.push({field:"cvv",message:"CVV is required"}):(null===(i=this.currentValidationState.cvv)||void 0===i?void 0:i.isValid)||o.push({field:"cvv",message:"Invalid CVV"});const a=this.parseExpiry(this.expiryEl);return(null===(r=this.expiryEl)||void 0===r?void 0:r.value)?a||o.push({field:"expiry",message:"Invalid expiration date"}):o.push({field:"expiry",message:"Expiration date is required"}),{isValid:0===o.length,errors:o}})}validateBankAccountInternal(){return i(this,void 0,void 0,function*(){var e,t,n,i,r;const o=[];return"CA"===this.bankCountry?((null===(e=this.institutionNumberEl)||void 0===e?void 0:e.value)?(0,u.validateInstitutionNumber)(this.institutionNumberEl.value)||o.push({field:"routingNumber",message:"Institution number must be 3 digits"}):o.push({field:"routingNumber",message:"Institution number is required"}),(null===(t=this.transitNumberEl)||void 0===t?void 0:t.value)?(0,u.validateTransitNumber)(this.transitNumberEl.value)||o.push({field:"routingNumber",message:"Transit number must be 5 digits"}):o.push({field:"routingNumber",message:"Transit number is required"}),(null===(n=this.accountNumberEl)||void 0===n?void 0:n.value)?(0,u.validateCanadianAccountNumber)(this.accountNumberEl.value)||o.push({field:"accountNumber",message:"Account number must be at least 7 digits"}):o.push({field:"accountNumber",message:"Account number is required"})):((null===(i=this.routingNumberEl)||void 0===i?void 0:i.value)?(0,u.validateRoutingNumber)(this.routingNumberEl.value)||o.push({field:"routingNumber",message:"Invalid routing number"}):o.push({field:"routingNumber",message:"Routing number is required"}),(null===(r=this.accountNumberEl)||void 0===r?void 0:r.value)?(0,u.validateAccountNumber)(this.accountNumberEl.value)||o.push({field:"accountNumber",message:"Invalid account number"}):o.push({field:"accountNumber",message:"Account number is required"})),{isValid:0===o.length,errors:o}})}applyUnifiedStyles(){var e;const t="0"===(null===(e=this.mergedStyles.container)||void 0===e?void 0:e.gap);if(this.mergedStyles.input)if(t){const e=Object.assign(Object.assign({},this.mergedStyles.input),{borderRight:"none",borderRadius:this.mergedStyles.input.borderRadius?`${this.mergedStyles.input.borderRadius} 0 0 ${this.mergedStyles.input.borderRadius}`:"0"}),t=this.stylesToCssString(e);this.spreedly.setStyle("number",t);const n=Object.assign(Object.assign({},this.mergedStyles.input),{borderRadius:this.mergedStyles.input.borderRadius?`0 ${this.mergedStyles.input.borderRadius} ${this.mergedStyles.input.borderRadius} 0`:"0"}),i=this.stylesToCssString(n);this.spreedly.setStyle("cvv",i)}else{const e=this.stylesToCssString(this.mergedStyles.input);this.spreedly.setStyle("number",e),this.spreedly.setStyle("cvv",e)}if(this.mergedStyles.focus){const e=this.stylesToCssString(this.mergedStyles.focus);this.spreedly.setStyle("number:focus",e),this.spreedly.setStyle("cvv:focus",e)}if(this.mergedStyles.error){const e=this.stylesToCssString(this.mergedStyles.error);this.spreedly.setStyle("number.invalid",e),this.spreedly.setStyle("cvv.invalid",e)}}stylesToCssString(e){return Object.entries(e).filter(([e,t])=>null!=t).map(([e,t])=>`${e.replace(/[A-Z]/g,e=>`-${e.toLowerCase()}`)}: ${t}`).join("; ")}clear(){"bank_account"===this.mode?("CA"===this.bankCountry?(this.institutionNumberEl&&(this.institutionNumberEl.value=""),this.transitNumberEl&&(this.transitNumberEl.value="")):this.routingNumberEl&&(this.routingNumberEl.value=""),this.accountNumberEl&&(this.accountNumberEl.value=""),this.accountTypeEl&&(this.accountTypeEl.selectedIndex=0)):(this.spreedly.reload(),this.expiryEl&&(this.expiryEl.value=""))}focus(e){if("bank_account"===this.mode)return"routingNumber"===e?void("CA"===this.bankCountry&&this.institutionNumberEl?this.institutionNumberEl.focus():this.routingNumberEl&&this.routingNumberEl.focus()):"accountNumber"===e&&this.accountNumberEl?void this.accountNumberEl.focus():void 0;if("expiry"===e&&this.expiryEl)return void this.expiryEl.focus();const t={cardNumber:this.numberEl,cvv:this.cvvEl,expiry:null,routingNumber:null,accountNumber:null}[e];if(t){const e=document.getElementById(t);null==e||e.focus()}}destroy(){this.spreedly&&this.spreedly.removeHandlers&&this.spreedly.removeHandlers(),this.eventHandlers.clear(),this.expiryEl}hasToken(){return!1}getToken(){return null}get tokenizationMode(){return"manual"}updateOverallValidation(){var e,t,n,i,r,o;"credit_card"===this.mode?this.currentValidationState.isValid=null!==(t=null===(e=this.currentValidationState.cardNumber)||void 0===e?void 0:e.isValid)&&void 0!==t&&t&&null!==(i=null===(n=this.currentValidationState.cvv)||void 0===n?void 0:n.isValid)&&void 0!==i&&i&&null!==(o=null===(r=this.currentValidationState.expiry)||void 0===r?void 0:r.isValid)&&void 0!==o&&o:this.currentValidationState.isValid=!0,this.emit("validation",this.currentValidationState)}handleFieldEvent(e,t,n){"input"===t&&("number"===e?(this.currentValidationState.cardNumber={isValid:n.validNumber||!1,isEmpty:0===n.numberLength},n.cardType&&"unknown"!==n.cardType&&this.emit("cardTypeChange",{cardType:this.normalizeCardType(n.cardType)})):"cvv"===e&&(this.currentValidationState.cvv={isValid:n.validCvv||!1,isEmpty:0===n.cvvLength}),this.updateOverallValidation()),"focus"===t?this.emit("focus",{field:e}):"blur"===t?this.emit("blur",{field:e}):"input"===t&&this.emit("change",{field:e})}createInternalElements(){const e=document.getElementById(this.containerId);if(!e)throw new Error(`Container element not found: ${this.containerId}`);e.innerHTML="",Object.assign(e.style,this.mergedStyles.container),"bank_account"===this.mode?this.createBankAccountFields(e):this.createCreditCardFields(e)}createCreditCardFields(e){if("two-line"===this.layout){const t=(0,u.createFieldContainer)(this.numberEl,"1",c.FIELD_FLEX.cardNumber.minWidth);t.style.height=this.mergedStyles.input.height,t.style.flexBasis="100%",e.appendChild(t),this.expiryEl=(0,u.createInputElement)(this.expiryId,"text",c.PLACEHOLDERS.expiry,c.FIELD_CONSTRAINTS.expiry.maxLength),Object.assign(this.expiryEl.style,{flex:"1",minWidth:c.FIELD_FLEX.expiry.minWidth}),this.applyInputStyles(this.expiryEl,this.mergedStyles,"left"),this.addExpiryFormatter(this.expiryEl),this.expiryEl.addEventListener("input",()=>{var e;const t=this.parseExpiry(this.expiryEl);this.currentValidationState.expiry={isValid:!!t,isEmpty:!(null===(e=this.expiryEl)||void 0===e?void 0:e.value)},this.updateOverallValidation()}),e.appendChild(this.expiryEl);const n=(0,u.createFieldContainer)(this.cvvEl,"1",c.FIELD_FLEX.cvv.minWidth);n.style.height=this.mergedStyles.input.height,e.appendChild(n)}else{const t=(0,u.createFieldContainer)(this.numberEl,c.FIELD_FLEX.cardNumber.flex,c.FIELD_FLEX.cardNumber.minWidth);t.style.height=this.mergedStyles.input.height,e.appendChild(t),this.expiryEl=(0,u.createInputElement)(this.expiryId,"text",c.PLACEHOLDERS.expiry,c.FIELD_CONSTRAINTS.expiry.maxLength),Object.assign(this.expiryEl.style,{flex:c.FIELD_FLEX.expiry.flex,minWidth:c.FIELD_FLEX.expiry.minWidth}),this.applyInputStyles(this.expiryEl,this.mergedStyles,"middle"),this.addExpiryFormatter(this.expiryEl),this.expiryEl.addEventListener("input",()=>{var e;const t=this.parseExpiry(this.expiryEl);this.currentValidationState.expiry={isValid:!!t,isEmpty:!(null===(e=this.expiryEl)||void 0===e?void 0:e.value)},this.updateOverallValidation()}),e.appendChild(this.expiryEl);const n=(0,u.createFieldContainer)(this.cvvEl,c.FIELD_FLEX.cvv.flex,c.FIELD_FLEX.cvv.minWidth);n.style.height=this.mergedStyles.input.height,e.appendChild(n)}}createBankAccountFields(e){"CA"===this.bankCountry?this.createCanadianBankAccountFields(e):this.createUSBankAccountFields(e)}createUSBankAccountFields(e){"two-line"===this.layout?(this.accountTypeEl=(0,u.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:"1",minWidth:c.BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,this.mergedStyles,"left"),e.appendChild(this.accountTypeEl),this.routingNumberEl=(0,u.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:"1",minWidth:c.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"right"),this.routingNumberEl.addEventListener("blur",()=>{!(0,u.validateRoutingNumber)(this.routingNumberEl.value)&&this.routingNumberEl.value?this.applyErrorStyles(this.routingNumberEl):this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"right"),this.updateBankAccountValidation()}),e.appendChild(this.routingNumberEl),this.accountNumberEl=(0,u.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:"1",flexBasis:"100%",minWidth:c.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles),this.accountNumberEl.addEventListener("blur",()=>{!(0,u.validateAccountNumber)(this.accountNumberEl.value)&&this.accountNumberEl.value?this.applyErrorStyles(this.accountNumberEl):this.applyInputStyles(this.accountNumberEl,this.mergedStyles),this.updateBankAccountValidation()}),e.appendChild(this.accountNumberEl)):(this.routingNumberEl=(0,u.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:c.BANK_FIELD_FLEX.routingNumber.flex,minWidth:c.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"left"),this.routingNumberEl.addEventListener("blur",()=>{!(0,u.validateRoutingNumber)(this.routingNumberEl.value)&&this.routingNumberEl.value?this.applyErrorStyles(this.routingNumberEl):this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"left"),this.updateBankAccountValidation()}),e.appendChild(this.routingNumberEl),this.accountNumberEl=(0,u.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:c.BANK_FIELD_FLEX.accountNumber.flex,minWidth:c.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.accountNumberEl.addEventListener("blur",()=>{!(0,u.validateAccountNumber)(this.accountNumberEl.value)&&this.accountNumberEl.value?this.applyErrorStyles(this.accountNumberEl):this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.updateBankAccountValidation()}),e.appendChild(this.accountNumberEl),this.accountTypeEl=(0,u.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:c.BANK_FIELD_FLEX.accountType.flex,minWidth:c.BANK_FIELD_FLEX.accountType.minWidth}),this.applyInputStyles(this.accountTypeEl,this.mergedStyles,"right"),e.appendChild(this.accountTypeEl))}updateBankAccountValidation(){if("CA"===this.bankCountry){if(!this.institutionNumberEl||!this.transitNumberEl||!this.accountNumberEl)return;const e=(0,u.validateInstitutionNumber)(this.institutionNumberEl.value),t=(0,u.validateTransitNumber)(this.transitNumberEl.value),n=(0,u.validateCanadianAccountNumber)(this.accountNumberEl.value);this.currentValidationState={isValid:e&&t&&n,routingNumber:{isValid:e&&t,isEmpty:!this.institutionNumberEl.value&&!this.transitNumberEl.value,error:e?t?void 0:"Invalid transit number":"Invalid institution number"},accountNumber:{isValid:n,isEmpty:!this.accountNumberEl.value,error:n?void 0:"Account number must be at least 7 digits"}}}else{if(!this.routingNumberEl||!this.accountNumberEl)return;const e=(0,u.validateRoutingNumber)(this.routingNumberEl.value),t=(0,u.validateAccountNumber)(this.accountNumberEl.value);this.currentValidationState={isValid:e&&t,routingNumber:{isValid:e,isEmpty:!this.routingNumberEl.value,error:e?void 0:"Invalid routing number"},accountNumber:{isValid:t,isEmpty:!this.accountNumberEl.value,error:t?void 0:"Invalid account number"}}}this.emit("validation",this.currentValidationState)}validateExpiry(){if(!this.expiryEl)return;const e=this.parseExpiry(this.expiryEl);if(!e)return void this.applyErrorStyles(this.expiryEl);const t=parseInt(e.month,10),n=parseInt(e.year,10);if(t<1||t>12)return void this.applyErrorStyles(this.expiryEl);const i=new Date;new Date(n,t-1)<i?this.applyErrorStyles(this.expiryEl):this.applyInputStyles(this.expiryEl,this.mergedStyles,"middle")}applyErrorStyles(e){this.mergedStyles.error?Object.assign(e.style,this.mergedStyles.error):e.style.borderColor="#dc3545"}static ensureSpreedlyLoaded(){return i(this,void 0,void 0,function*(){window.Spreedly||(yield h.loadScript("https://core.spreedly.com/iframe/iframe-v1.min.js","spreedly-iframe-script"),yield h.waitForGlobal("Spreedly",5e3))})}static loadScript(e,t){return i(this,void 0,void 0,function*(){if(!t||!document.getElementById(t))return Array.from(document.getElementsByTagName("script")).find(t=>t.src===e)?void 0:new Promise((n,i)=>{const r=document.createElement("script");r.src=e,r.async=!0,t&&(r.id=t),r.onload=()=>n(),r.onerror=()=>i(new Error(`Failed to load script: ${e}`)),document.body.appendChild(r)})})}static waitForGlobal(e){return i(this,arguments,void 0,function*(e,t=1e4){const n=Date.now();for(;Date.now()-n<t;){const t=window[e];if(t)return t;yield new Promise(e=>setTimeout(e,100))}throw new Error(`Timeout waiting for global: ${e}`)})}static tokenizeBankAccount(e,t){return void 0===t.spreedlyEnvironmentKey?Promise.reject(new Error("Spreedly is not configured.")):fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{bank_account:{first_name:e.contact.firstName||void 0,last_name:e.contact.lastName||void 0,full_name:e.contact.fullName||void 0,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country,bank_account_number:e.account.accountNumber.replace(/\s+/g,""),bank_routing_number:e.account.routingNumber.replace(/\s+/g,""),bank_account_holder_type:e.account.accountHolderType,bank_account_type:e.account.accountType}},retained:!1})}).then(s.unpackSpreedlyResponse).then(s.extractSpreedlyToken)}static tokenizeCreditCard(e,t){return void 0===t.spreedlyEnvironmentKey?Promise.reject(new Error("Spreedly is not configured.")):fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{credit_card:{first_name:e.contact.firstName,last_name:e.contact.lastName,full_name:e.contact.fullName,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country,number:e.card.cardNumber.replace(/\s+/g,""),verification_value:e.card.verificationValue,year:e.card.expirationYear,month:e.card.expirationMonth}},retained:!1})}).then(s.unpackSpreedlyResponse).then(s.extractSpreedlyToken)}static tokenizePayPal(e,t){if(void 0===t.spreedlyEnvironmentKey)throw new Error("Spreedly is not configured.");return fetch(a.SPREEDLY_TOKENIZER_URL+"?"+new URLSearchParams({environment_key:t.spreedlyEnvironmentKey}),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({payment_method:{payment_method_type:"paypal",first_name:e.contact.firstName,last_name:e.contact.lastName,email:e.contact.email,address1:e.address.address1,address2:e.address.address2,city:e.address.city,state:e.address.state,zip:e.address.zip,country:e.address.country},retained:!1})}).then(s.unpackSpreedlyResponse).then(s.extractSpreedlyToken)}}t.SpreedlyTokenizer=h},903:(e,t,n)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.tokenizePaymentBankCanada=function(e,t,n,r,o,a,s,d,l){const c=(0,i.v4)();let u=l.address1;l.address2&&(u+="\n"+l.address2);const h={IATS_DPM_ProcessOption:"TOKEN",IATS_DPM_RecurringOn:"FALSE",IATS_DPM_ProcessID:o,IATS_DPM_RelayURL:a,IATS_DPM_ClientDefined_PaymentId:c,IATS_DPM_ClientDefined_GatewayId:s,IATS_DPM_Title:d.salutation,IATS_DPM_FirstName:d.firstName,IATS_DPM_LastName:d.lastName,IATS_DPM_Address:u,IATS_DPM_City:l.city,IATS_DPM_Province:l.state,IATS_DPM_Country:l.country,IATS_DPM_ZipCode:l.zip,IATS_DPM_Phone:d.primaryPhone,IATS_DPM_EMAIL:d.email,IATS_DPM_AccountNumber:e+t+n,IATS_DPM_MOP:"ACHEFT",IATS_DPM_AccountType:r},p=new FormData;for(const[e,t]of Object.entries(h))p.append(e,t);return fetch("https://www.iatspayments.com/netgate/IATSDPMProcess.aspx",{method:"POST",mode:"no-cors",body:p}).then(e=>e.text().then(()=>c))},t.tokenizePaymentBankUs=function(){throw new Error("US Bank Tokenization Not Yet Implemented")},t.tokenizePaymentCard=function(){throw new Error("Card Tokenization Not Yet Implemented")};const i=n(611)},953:function(e,t,n){var i=this&&this.__awaiter||function(e,t,n,i){return new(n||(n=Promise))(function(r,o){function a(e){try{d(i.next(e))}catch(e){o(e)}}function s(e){try{d(i.throw(e))}catch(e){o(e)}}function d(e){var t;e.done?r(e.value):(t=e.value,t instanceof n?t:new n(function(e){e(t)})).then(a,s)}d((i=i.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0});const r=n(247);class o{constructor(e){this.appleSession=null,this.paymentRequestDefaults={currencyCode:"USD",countryCode:"US",merchantCapabilities:["supports3DS","supportsCredit","supportsDebit"],supportedNetworks:["amex","masterCard","visa","discover"],requiredBillingContactFields:["postalAddress","name"],requiredShippingContactFields:["email","phone"],total:{label:"iDonate",amount:"",type:"final"}},this.paymentRequest=Object.assign({},this.paymentRequestDefaults,e)}static isSupported(){return window.ApplePaySession&&ApplePaySession.canMakePayments()&&ApplePaySession.supportsVersion(o.ApplePayApiVersion)}begin(){return i(this,void 0,void 0,function*(){if(!o.isSupported())throw new Error("Apple Pay Not Supported");return this.appleSession=new ApplePaySession(o.ApplePayApiVersion,this.paymentRequest),this.appleSession.begin(),this.appleSession})}createSession(e,t){return fetch(`${t}/payment/create-session`,{method:"POST",headers:r.CLIENT_HEADERS,body:JSON.stringify(e)}).then(e=>e.json())}tokenizeWithCardConnect(e,t){const n=e.token.paymentData,i=`${n.data}&ectype=apple&ecsig=${n.signature}&eckey=${n.header.ephemeralPublicKey}&ectid=${n.header.transactionId}&echash=&ecpublickeyhash=${n.header.publicKeyHash}`;return fetch(`${t}/cardsecure/api/v1/ccn/tokenize`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({encryptionhandler:"EC_APPLE_PAY",devicedata:i,unique:!0})}).then(e=>e.json())}}o.ApplePayApiVersion=6,t.default=o}},t={};function n(i){var r=t[i];if(void 0!==r)return r.exports;var o=t[i]={exports:{}};return e[i].call(o.exports,o,o.exports,n),o.exports}return n.d=(e,t)=>{for(var i in t)n.o(t,i)&&!n.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:t[i]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n(806)})());