@idonatedev/idonate-sdk 1.1.0-dev6 → 1.1.0-dev7

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.
@@ -276,6 +276,7 @@ class iDonateClient {
276
276
  return tokenize_1.Tokenizer.create(gateway, container, {
277
277
  organizationId: this.organizationId,
278
278
  embedId: this.embedId,
279
+ clientConfig: this.config,
279
280
  });
280
281
  });
281
282
  }
@@ -20,9 +20,10 @@ export declare class CardConnectTokenizer extends Tokenizer {
20
20
  private tokenizationResolve?;
21
21
  private tokenizationReject?;
22
22
  private constructor();
23
- static create(gateway: PaymentGateway, container: TokenizerContainer, config?: {
23
+ static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
24
24
  organizationId: string;
25
25
  embedId: string;
26
+ clientConfig: ConfigHandler;
26
27
  }): Promise<CardConnectTokenizer>;
27
28
  private createInternalElements;
28
29
  private createCreditCardFields;
@@ -44,10 +44,8 @@ class CardConnectTokenizer extends Tokenizer_1.Tokenizer {
44
44
  if (container.mode === 'bank_account' && container.bankCountry === 'CA') {
45
45
  throw new Error('CardConnect does not support Canadian bank accounts');
46
46
  }
47
- const baseUrl = (_a = gateway.config) === null || _a === void 0 ? void 0 : _a.base_url;
48
- if (!baseUrl) {
49
- throw new Error('CardConnect base URL not configured');
50
- }
47
+ let baseUrl = ((_a = gateway.config) === null || _a === void 0 ? void 0 : _a.base_url) || config.clientConfig.cardConnectBaseUrl;
48
+ config.cardConnectBaseUrl = baseUrl;
51
49
  const mergedStyles = (0, styles_1.mergeStyles)(styles_1.DEFAULT_UNIFIED_STYLES, container.styling);
52
50
  const iframeUrl = CardConnectTokenizer.generateIframeUrl(baseUrl, container);
53
51
  const iframe = CardConnectTokenizer.createIframe(iframeUrl, mergedStyles);
@@ -14,8 +14,9 @@ export declare class SpreedlyTokenizer extends Tokenizer {
14
14
  private cvvEl;
15
15
  private expiryId;
16
16
  private containerEl?;
17
- private organizationId?;
18
- private embedId?;
17
+ private organizationId;
18
+ private embedId;
19
+ private clientConfig;
19
20
  private bankCountry;
20
21
  private routingNumberEl?;
21
22
  private accountNumberEl?;
@@ -24,9 +25,10 @@ export declare class SpreedlyTokenizer extends Tokenizer {
24
25
  private transitNumberEl?;
25
26
  private enableTestMode;
26
27
  private constructor();
27
- static create(gateway: PaymentGateway, container: TokenizerContainer, config?: {
28
+ static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
28
29
  organizationId: string;
29
30
  embedId: string;
31
+ clientConfig: ConfigHandler;
30
32
  }): Promise<SpreedlyTokenizer>;
31
33
  private init;
32
34
  tokenize(paymentData: PaymentData): Promise<PaymentToken>;
@@ -8,16 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
11
  Object.defineProperty(exports, "__esModule", { value: true });
15
12
  exports.SpreedlyTokenizer = void 0;
16
13
  const Tokenizer_1 = require("./Tokenizer");
17
14
  const types_1 = require("./types");
18
15
  const constants_1 = require("../constants");
19
16
  const typeAdapters_1 = require("../typeAdapters");
20
- const config_handler_1 = __importDefault(require("../config-handler"));
21
17
  const spreedly_secure_1 = require("./spreedly-secure");
22
18
  const styles_1 = require("./styles");
23
19
  const tokenizer_constants_1 = require("./tokenizer-constants");
@@ -74,21 +70,24 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
74
70
  if (container.mode !== 'bank_account') {
75
71
  yield SpreedlyTokenizer.ensureSpreedlyLoaded();
76
72
  }
77
- const environmentKey = (_a = gateway.config) === null || _a === void 0 ? void 0 : _a.environment_key;
73
+ let environmentKey = (_a = gateway.config) === null || _a === void 0 ? void 0 : _a.environment_key;
74
+ if (!environmentKey && config.clientConfig.spreedlyEnvironmentKey) {
75
+ environmentKey = config.clientConfig.spreedlyEnvironmentKey;
76
+ }
78
77
  if (!environmentKey) {
79
- throw new Error('Spreedly environment key not configured');
78
+ environmentKey = '';
80
79
  }
81
80
  const tokenizer = new SpreedlyTokenizer(environmentKey, container.containerId, container.styling, container.mode || 'credit_card', container.bankCountry || 'US', container.enableTestMode || false);
82
- tokenizer.organizationId = config === null || config === void 0 ? void 0 : config.organizationId;
83
- tokenizer.embedId = config === null || config === void 0 ? void 0 : config.embedId;
81
+ tokenizer.organizationId = config.organizationId;
82
+ tokenizer.embedId = config.embedId;
83
+ tokenizer.clientConfig = config.clientConfig;
84
84
  tokenizer.createInternalElements();
85
85
  let securityArgs;
86
86
  if (container.mode === 'credit_card' &&
87
87
  (config === null || config === void 0 ? void 0 : config.organizationId) &&
88
88
  (config === null || config === void 0 ? void 0 : config.embedId)) {
89
89
  try {
90
- const configHandler = new config_handler_1.default({});
91
- securityArgs = yield (0, spreedly_secure_1.fetchSpreedlySecurityArgs)(configHandler, config.organizationId, config.embedId);
90
+ securityArgs = yield (0, spreedly_secure_1.fetchSpreedlySecurityArgs)(config.clientConfig, config.organizationId, config.embedId);
92
91
  }
93
92
  catch (error) {
94
93
  console.warn('Failed to fetch security args, using standard tokenization');
@@ -380,7 +379,7 @@ class SpreedlyTokenizer extends Tokenizer_1.Tokenizer {
380
379
  accountType: accountType,
381
380
  accountHolderType: accountHolderType,
382
381
  },
383
- }, new config_handler_1.default({ spreedlyEnvironmentKey: this.environmentKey }));
382
+ }, this.clientConfig);
384
383
  return {
385
384
  token: result,
386
385
  lastFour: accountNumber.slice(-4),
@@ -1,4 +1,5 @@
1
1
  import { CardData, BankAccountData, PaymentData, PaymentToken, ValidationResult, TokenizerEvent, TokenizerStylingComplete, CardType, PaymentGateway, TokenizerContainer, PaymentMethodMode } from './types';
2
+ import ConfigHandler from '../config-handler';
2
3
  export declare abstract class Tokenizer {
3
4
  protected mode: PaymentMethodMode;
4
5
  protected eventHandlers: Map<TokenizerEvent, Set<(data?: any) => void>>;
@@ -28,8 +29,9 @@ export declare abstract class Tokenizer {
28
29
  expiryId: string;
29
30
  cvvId: string;
30
31
  };
31
- static create(gateway: PaymentGateway, container: TokenizerContainer, config?: {
32
+ static create(gateway: PaymentGateway, container: TokenizerContainer, config: {
32
33
  organizationId: string;
33
34
  embedId: string;
35
+ clientConfig: ConfigHandler;
34
36
  }): Promise<Tokenizer>;
35
37
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@idonatedev/idonate-sdk",
3
3
  "author": "iDonate",
4
- "version": "1.1.0-dev6",
4
+ "version": "1.1.0-dev7",
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)}}))},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,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_first_name:null===(i=t.tribute)||void 0===i?void 0:i.tributeFirstName,tribute_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 S={};return t.utm&&(t.utm.campaign&&(S.utm_campaign=t.utm.campaign),t.utm.content&&(S.utm_content=t.utm.content),t.utm.medium&&(S.utm_medium=t.utm.medium),t.utm.source&&(S.utm_source=t.utm.source),t.utm.term&&(S.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),_),S),{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:function(e,t,n){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};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;const r=i(n(330));t.SDK_VERSION=r.default.version,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@${r.default.version}`,"Content-Type":"application/json"}},330:e=>{e.exports=JSON.parse('{"name":"@idonatedev/idonate-sdk","author":"iDonate","version":"1.1.0-dev6","sideEffects":false,"description":"iDonate Web SDK","engines":{"node":">=20.18.0"},"main":"dist/index.js","unpkg":"umd/idonate-sdk.js","types":"dist/index.d.ts","files":["/dist","/umd"],"scripts":{"test":"jest","test:server":"node e2e/test-server.js","test:e2e":"playwright test","test:e2e:with-server":"npm run test:server & sleep 2 && playwright test; kill $!","lint":"npx eslint \'src/**/*.ts\'","lint:fix":"npx eslint --fix \'src/**/*.ts\'","format":"npx prettier --write \'src/**/*.ts\'","build":"npx tsc && webpack","watch":"npx tsc -w & webpack --watch","dev:server":"http-server -p 8000 -c-1 -o /e2e/donation-flow-enhanced.html","dev":"concurrently \\"npm run dev:server\\" \\"npm run watch\\" --names \\"server,build\\" --prefix-colors \\"blue,green\\"","prepare":"husky install"},"devDependencies":{"@playwright/test":"^1.48.2","@types/jest":"^29.5.14","@typescript-eslint/eslint-plugin":"^8.18.2","@typescript-eslint/parser":"^8.18.2","concurrently":"^9.2.0","eslint":"^9.17.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.2","http-server":"^14.1.1","husky":"^9.1.7","jest":"^29.7.0","jest-environment-jsdom":"^30.0.5","lint-staged":"^15.3.0","playwright":"^1.48.2","prettier":"^3.4.2","ts-jest":"^29.2.5","ts-loader":"^9.5.1","ts-node":"^10.9.2","typescript":"^5.7.3","webpack":"^5.97.1","webpack-cli":"^5.1.4"},"prettier":{"singleQuote":true,"trailingComma":"es5"},"lint-staged":{"*.ts":["prettier --write","eslint --fix"]},"dependencies":{"@types/applepayjs":"^14.0.9","@types/googlepay":"^0.7.7","@types/grecaptcha":"^3.0.9","@types/spreedly-iframe-browser":"^1.0.3","@types/uuid":"^8.3.1","uuid":"^8.3.2"}}')},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}getMode(){return this.mode}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t)}off(e,t){const n=this.eventHandlers.get(e);n&&n.delete(t)}emit(e,t){const n=this.eventHandlers.get(e);n&&n.forEach(e=>{try{e(t)}catch(e){}})}isCardData(e){return"expiryMonth"in e&&"expiryYear"in e}isBankAccountData(e){return"routingNumber"in e&&"accountNumber"in e}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)}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.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"}}},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.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(367);Object.defineProperty(t,"TokenizationError",{enumerable:!0,get:function(){return u.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){super(),this.iframeUrl=t,this.containerId=n,this.isReady=!1,this.enableTestMode=!1,this.mode=i,this.enableTestMode=r,this.iframe=e;const o=new URL(t);this.expectedOrigin=`${o.protocol}//${o.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 n;if("bank_account"===t.mode&&"CA"===t.bankCountry)throw new Error("CardConnect does not support Canadian bank accounts");const i=null===(n=e.config)||void 0===n?void 0:n.base_url;if(!i)throw new Error("CardConnect base URL not configured");const r=(0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,t.styling),o=u.generateIframeUrl(i,t),a=u.createIframe(o,r),s=new u(a,o,t.containerId,t.mode||"credit_card",t.enableTestMode||!1);return s.createInternalElements(t),yield s.init(),s})}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.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,e.styling);Object.assign(t.style,n.container),"bank_account"===this.mode?this.createBankAccountFields(t,n):this.createCreditCardFields(t,n)}createCreditCardFields(e,t){this.iframe.style.width="100%",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",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.isReady=!0,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.isReady=!0,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 t,n,i;const r=(null===(t=this.routingNumberEl)||void 0===t?void 0:t.value)||e.routingNumber,o=(null===(n=this.accountNumberEl)||void 0===n?void 0:n.value)||e.accountNumber,d=(null===(i=this.accountTypeEl)||void 0===i?void 0:i.value)||e.accountType;if(!r||!o)throw new a.TokenizationError("Routing number and account number are required","VALIDATION_ERROR");if(!(0,c.validateRoutingNumber)(r))throw new a.TokenizationError("Invalid routing number","VALIDATION_ERROR");if(!(0,c.validateAccountNumber)(o))throw new a.TokenizationError("Invalid account number","VALIDATION_ERROR");const l=new URL(this.iframeUrl).origin,h=new s.default({});return h.cardConnectBaseUrl=l,{token:(yield u.tokenizeBankAccount(r,o,h)).token,lastFour:o.slice(-4),accountType:d,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;return"credit_card"===this.mode&&"0"===(null===(e=this.cachedTokenResult)||void 0===e?void 0:e.errorCode)?{token:this.cachedTokenResult.token,lastFour:this.cachedTokenResult.token.slice(-4),cardType:this.normalizeCardType("unknown"),provider:"cardconnect"}: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={token:t.token,lastFour:t.token.slice(-4),cardType:this.normalizeCardType("unknown"),provider:"cardconnect"};this.tokenizationResolve&&(this.tokenizationResolve(e),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",e)}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);"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})}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",orientation:"horizontal",formatinput:"true",unique:"true",norsa:"true",placeholder:"Card Number *",placeholdermonth:"MM",placeholderyear:"YYYY",placeholdercvv:"CVV",invalidcreditcardevent:"true",invalidexpiry:"true",invalidcvv:"true"}),i=(0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,t.styling),r=u.generateCardConnectCss(i),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){var t,n,i,r,o,a,s,d,l;const c=[];c.push("body{margin:0;padding:0;display:flex;align-items:center;}"),c.push("form{margin:0;padding:0;display:flex;width:100%;align-items:center;}"),c.push("label{display:none;}"),c.push("br{display:none;}");const u="0"===e.container.gap,h=u?"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(";");c.push(`input{${n};}`),c.push(`select{${n};}`)}if(u){const a=["width:60%","margin:0"];(null===(t=e.input)||void 0===t?void 0:t.borderRadius)&&a.push(`border-radius:${e.input.borderRadius} 0 0 ${e.input.borderRadius}`),a.push("border-right:none"),c.push(`input#ccnumfield{${a.join(";")};}`);const s=["width:10%","margin:0","margin-right:-12px","border-radius:0",`border-left:${(null===(n=e.input)||void 0===n?void 0:n.border)||"1px solid #ccc"}`,"border-right:none"];c.push(`select#ccexpirymonth{${s.join(";")};}`);const d=["width:10%","border-radius:0",`border-left:${(null===(i=e.input)||void 0===i?void 0:i.border)||"1px solid #ccc"}`,"border-right:none"];c.push(`select#ccexpiryyear{${d.join(";")};}`);const l=["width:20%","margin:0","margin-left:-12px"];(null===(r=e.input)||void 0===r?void 0:r.borderRadius)&&l.push(`border-radius:0 ${e.input.borderRadius} ${e.input.borderRadius} 0`),l.push(`border-left:${(null===(o=e.input)||void 0===o?void 0:o.border)||"1px solid #ccc"}`),c.push(`input#cccvvfield{${l.join(";")};}`)}else{const t=h.replace(/[^\d.]/g,""),n=h.replace(/[\d.]/g,""),i=parseFloat(t)/2,r=[`width:calc(60% - ${t}${n})`,`margin-right:${h}`];(null===(a=e.input)||void 0===a?void 0:a.borderRadius)&&r.push(`border-radius:${e.input.borderRadius}`),c.push(`input#ccnumfield{${r.join(";")};}`);const o=[`width:calc(10% - ${i}${n})`,`margin-right:calc(${h} / 2)`];(null===(s=e.input)||void 0===s?void 0:s.borderRadius)&&o.push(`border-radius:${e.input.borderRadius}`),c.push(`select#ccexpirymonth{${o.join(";")};}`);const u=[`width:calc(10% - ${i}${n})`,`margin-right:${h}`];(null===(d=e.input)||void 0===d?void 0:d.borderRadius)&&u.push(`border-radius:${e.input.borderRadius}`),c.push(`select#ccexpiryyear{${u.join(";")};}`);const p=["width:20%"];(null===(l=e.input)||void 0===l?void 0:l.borderRadius)&&p.push(`border-radius:${e.input.borderRadius}`),c.push(`input#cccvvfield{${p.join(";")};}`)}if(e.focus){const t=[];e.focus.borderColor&&t.push(`border-color:${e.focus.borderColor}`),e.focus.outline&&t.push(`outline:${e.focus.outline}`),e.focus.boxShadow&&t.push(`box-shadow:${e.focus.boxShadow}`),t.length>0&&c.push(`input:focus{${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&&c.push(`.error{${t.join(";")};}`)}return encodeURIComponent(c.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:()=>O,parse:()=>b,stringify:()=>c,v1:()=>y,v3:()=>T,v4:()=>I,v5:()=>k,validate:()=>s,version:()=>P});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 S(e,t,n,i,r,o,a){return E(t^n^i,e,t,r,o,a)}function w(e,t,n,i,r,o,a){return E(n^(t|~i),e,t,r,o,a)}const T=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=S(n,i=N(i,r,o,n,e[a+12],20,-1926607734),r,o,e[a+5],4,-378558),o=S(o,n,i,r,e[a+8],11,-2022574463),r=S(r,o,n,i,e[a+11],16,1839030562),i=S(i,r,o,n,e[a+14],23,-35309556),n=S(n,i,r,o,e[a+1],4,-1530992060),o=S(o,n,i,r,e[a+4],11,1272893353),r=S(r,o,n,i,e[a+7],16,-155497632),i=S(i,r,o,n,e[a+10],23,-1094730640),n=S(n,i,r,o,e[a+13],4,681279174),o=S(o,n,i,r,e[a],11,-358537222),r=S(r,o,n,i,e[a+3],16,-722521979),i=S(i,r,o,n,e[a+6],23,76029189),n=S(n,i,r,o,e[a+9],4,-640364487),o=S(o,n,i,r,e[a+12],11,-421815835),r=S(r,o,n,i,e[a+15],16,530742520),n=w(n,i=S(i,r,o,n,e[a+2],23,-995338651),r,o,e[a],6,-198630844),o=w(o,n,i,r,e[a+7],10,1126891415),r=w(r,o,n,i,e[a+14],15,-1416354905),i=w(i,r,o,n,e[a+5],21,-57434055),n=w(n,i,r,o,e[a+12],6,1700485571),o=w(o,n,i,r,e[a+3],10,-1894986606),r=w(r,o,n,i,e[a+10],15,-1051523),i=w(i,r,o,n,e[a+1],21,-2054922799),n=w(n,i,r,o,e[a+8],6,1873313359),o=w(o,n,i,r,e[a+15],10,-30611744),r=w(r,o,n,i,e[a+6],15,-1560198380),i=w(i,r,o,n,e[a+13],21,1309151649),n=w(n,i,r,o,e[a+4],6,-145523070),o=w(o,n,i,r,e[a+11],10,-1120210379),r=w(r,o,n,i,e[a+2],15,718787259),i=w(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))}),I=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]]}),O="00000000-0000-0000-0000-000000000000",P=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.borderColor="",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,this.embedId=t,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})})}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]}}},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))};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())})},r=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.SpreedlyTokenizer=void 0;const o=n(415),a=n(367),s=n(247),d=n(156),l=r(n(731)),c=n(592),u=n(454),h=n(799),p=n(631);class m extends o.Tokenizer{constructor(e,t,n,i="credit_card",r="US",o=!1){if(super(),this.environmentKey=e,this.containerId=t,this.isReady=!1,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,u.mergeStyles)(u.DEFAULT_UNIFIED_STYLES,n);const a=this.generateFieldIds(t);this.numberEl=a.numberId,this.cvvEl=a.cvvId,this.expiryId=a.expiryId}static create(e,t,n){return i(this,void 0,void 0,function*(){var i;"bank_account"!==t.mode&&(yield m.ensureSpreedlyLoaded());const r=null===(i=e.config)||void 0===i?void 0:i.environment_key;if(!r)throw new Error("Spreedly environment key not configured");const o=new m(r,t.containerId,t.styling,t.mode||"credit_card",t.bankCountry||"US",t.enableTestMode||!1);let a;if(o.organizationId=null==n?void 0:n.organizationId,o.embedId=null==n?void 0:n.embedId,o.createInternalElements(),"credit_card"===t.mode&&(null==n?void 0:n.organizationId)&&(null==n?void 0:n.embedId))try{const e=new l.default({});a=yield(0,c.fetchSpreedlySecurityArgs)(e,n.organizationId,n.embedId)}catch(e){console.warn("Failed to fetch security args, using standard tokenization")}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.isReady=!0,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"))},h.INIT_TIMEOUT);this.spreedly.on("ready",()=>{clearTimeout(i),this.isReady=!0,this.spreedly.setPlaceholder("number",h.PLACEHOLDERS.cardNumber),this.spreedly.setFieldType("number","text"),this.spreedly.setNumberFormat("prettyFormat"),this.spreedly.setPlaceholder("cvv",h.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 a.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,o,s,d,l;const c=setTimeout(()=>{this.spreedly&&this.spreedly.removeHandlers&&this.spreedly.removeHandlers(),n(new a.TokenizationError("Tokenization timeout","TIMEOUT"))},h.TOKENIZE_TIMEOUT),u=()=>{clearTimeout(c),this.spreedly&&this.spreedly.removeHandlers&&this.spreedly.removeHandlers()};this.spreedly.on("paymentMethod",(e,n)=>{u();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=>{u(),n(new a.TokenizationError(e))});const p=this.parseExpiry(this.expiryEl);if(!p)return u(),void n(new a.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.line1,address2:null===(r=e.address)||void 0===r?void 0:r.line2,city:null===(o=e.address)||void 0===o?void 0:o.city,state:null===(s=e.address)||void 0===s?void 0:s.state,zip:null===(d=e.address)||void 0===d?void 0:d.postalCode,country:null===(l=e.address)||void 0===l?void 0:l.country})})})}createCanadianBankAccountFields(e){this.institutionNumberEl=(0,p.createInputElement)(`${this.containerId}-institution`,"text","Inst *",3),Object.assign(this.institutionNumberEl.style,{flex:h.CANADIAN_BANK_FIELD_FLEX.institutionNumber.flex,minWidth:h.CANADIAN_BANK_FIELD_FLEX.institutionNumber.minWidth}),this.applyInputStyles(this.institutionNumberEl,this.mergedStyles,"left"),this.institutionNumberEl.addEventListener("blur",()=>{!(0,p.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,p.createInputElement)(`${this.containerId}-transit`,"text","Transit *",5),Object.assign(this.transitNumberEl.style,{flex:h.CANADIAN_BANK_FIELD_FLEX.transitNumber.flex,minWidth:h.CANADIAN_BANK_FIELD_FLEX.transitNumber.minWidth}),this.applyInputStyles(this.transitNumberEl,this.mergedStyles,"middle"),this.transitNumberEl.addEventListener("blur",()=>{!(0,p.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,p.createInputElement)(`${this.containerId}-account`,"text","Account Number *"),Object.assign(this.accountNumberEl.style,{flex:h.CANADIAN_BANK_FIELD_FLEX.accountNumber.flex,minWidth:h.CANADIAN_BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.accountNumberEl.addEventListener("blur",()=>{!(0,p.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,p.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:h.CANADIAN_BANK_FIELD_FLEX.accountType.flex,minWidth:h.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,o,s,d,c,u,h,y,b;if(!this.isReady)throw new Error("Tokenizer not initialized");if("bank_account"!==this.mode)throw new Error("Tokenizer not in bank account mode");let v,f;const g=(null===(t=this.accountTypeEl)||void 0===t?void 0:t.value)||e.accountType;if("CA"===this.bankCountry){const t=(null===(n=this.institutionNumberEl)||void 0===n?void 0:n.value)||e.institutionNumber,o=(null===(i=this.transitNumberEl)||void 0===i?void 0:i.value)||e.transitNumber;if(f=(null===(r=this.accountNumberEl)||void 0===r?void 0:r.value)||e.accountNumber,!t||!o||!f)throw new a.TokenizationError("Institution number, transit number, and account number are required","VALIDATION_ERROR");if(!(0,p.validateInstitutionNumber)(t))throw new a.TokenizationError("Institution number must be 3 digits","VALIDATION_ERROR");if(!(0,p.validateTransitNumber)(o))throw new a.TokenizationError("Transit number must be 5 digits","VALIDATION_ERROR");if(!(0,p.validateCanadianAccountNumber)(f))throw new a.TokenizationError("Invalid account number","VALIDATION_ERROR");v=(0,p.formatCanadianRoutingNumber)(t,o)}else{if(v=(null===(o=this.routingNumberEl)||void 0===o?void 0:o.value)||e.routingNumber,f=(null===(s=this.accountNumberEl)||void 0===s?void 0:s.value)||e.accountNumber,!v||!f)throw new a.TokenizationError("Routing number and account number are required","VALIDATION_ERROR");if(!(0,p.validateRoutingNumber)(v))throw new a.TokenizationError("Invalid routing number","VALIDATION_ERROR");if(!(0,p.validateAccountNumber)(f))throw new a.TokenizationError("Invalid account number","VALIDATION_ERROR")}return{token:yield m.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.line1,address2:null===(c=e.address)||void 0===c?void 0:c.line2,city:null===(u=e.address)||void 0===u?void 0:u.city,state:null===(h=e.address)||void 0===h?void 0:h.state,zip:null===(y=e.address)||void 0===y?void 0:y.postalCode,country:null===(b=e.address)||void 0===b?void 0:b.country},account:{accountNumber:f,routingNumber:v,accountType:g,accountHolderType:"personal"}},new l.default({spreedlyEnvironmentKey:this.environmentKey})),lastFour:f.slice(-4),accountType:g,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,p.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,p.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,p.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,p.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,p.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;if(!this.isReady)return;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){const t=(0,p.createFieldContainer)(this.numberEl,h.FIELD_FLEX.cardNumber.flex,h.FIELD_FLEX.cardNumber.minWidth);t.style.height=this.mergedStyles.input.height,e.appendChild(t),this.expiryEl=(0,p.createInputElement)(this.expiryId,"text",h.PLACEHOLDERS.expiry,h.FIELD_CONSTRAINTS.expiry.maxLength),Object.assign(this.expiryEl.style,{flex:h.FIELD_FLEX.expiry.flex,minWidth:h.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,p.createFieldContainer)(this.cvvEl,h.FIELD_FLEX.cvv.flex,h.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){this.routingNumberEl=(0,p.createInputElement)(`${this.containerId}-routing`,"text","Routing *",9),Object.assign(this.routingNumberEl.style,{flex:h.BANK_FIELD_FLEX.routingNumber.flex,minWidth:h.BANK_FIELD_FLEX.routingNumber.minWidth}),this.applyInputStyles(this.routingNumberEl,this.mergedStyles,"left"),this.routingNumberEl.addEventListener("blur",()=>{!(0,p.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,p.createInputElement)(`${this.containerId}-account`,"text","Account Number *",17),Object.assign(this.accountNumberEl.style,{flex:h.BANK_FIELD_FLEX.accountNumber.flex,minWidth:h.BANK_FIELD_FLEX.accountNumber.minWidth}),this.applyInputStyles(this.accountNumberEl,this.mergedStyles,"middle"),this.accountNumberEl.addEventListener("blur",()=>{!(0,p.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,p.createAccountTypeSelect)(`${this.containerId}-account-type`),Object.assign(this.accountTypeEl.style,{flex:h.BANK_FIELD_FLEX.accountType.flex,minWidth:h.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,p.validateInstitutionNumber)(this.institutionNumberEl.value),t=(0,p.validateTransitNumber)(this.transitNumberEl.value),n=(0,p.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,p.validateRoutingNumber)(this.routingNumberEl.value),t=(0,p.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 m.loadScript("https://core.spreedly.com/iframe/iframe-v1.min.js","spreedly-iframe-script"),yield m.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(s.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(d.unpackSpreedlyResponse).then(d.extractSpreedlyToken)}static tokenizeCreditCard(e,t){return void 0===t.spreedlyEnvironmentKey?Promise.reject(new Error("Spreedly is not configured.")):fetch(s.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(d.unpackSpreedlyResponse).then(d.extractSpreedlyToken)}static tokenizePayPal(e,t){if(void 0===t.spreedlyEnvironmentKey)throw new Error("Spreedly is not configured.");return fetch(s.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(d.unpackSpreedlyResponse).then(d.extractSpreedlyToken)}}t.SpreedlyTokenizer=m},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)}}))},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,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_first_name:null===(i=t.tribute)||void 0===i?void 0:i.tributeFirstName,tribute_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 S={};return t.utm&&(t.utm.campaign&&(S.utm_campaign=t.utm.campaign),t.utm.content&&(S.utm_content=t.utm.content),t.utm.medium&&(S.utm_medium=t.utm.medium),t.utm.source&&(S.utm_source=t.utm.source),t.utm.term&&(S.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),_),S),{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:function(e,t,n){var i=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};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;const r=i(n(330));t.SDK_VERSION=r.default.version,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@${r.default.version}`,"Content-Type":"application/json"}},330:e=>{e.exports=JSON.parse('{"name":"@idonatedev/idonate-sdk","author":"iDonate","version":"1.1.0-dev7","sideEffects":false,"description":"iDonate Web SDK","engines":{"node":">=20.18.0"},"main":"dist/index.js","unpkg":"umd/idonate-sdk.js","types":"dist/index.d.ts","files":["/dist","/umd"],"scripts":{"test":"jest","test:server":"node e2e/test-server.js","test:e2e":"playwright test","test:e2e:with-server":"npm run test:server & sleep 2 && playwright test; kill $!","lint":"npx eslint \'src/**/*.ts\'","lint:fix":"npx eslint --fix \'src/**/*.ts\'","format":"npx prettier --write \'src/**/*.ts\'","build":"npx tsc && webpack","watch":"npx tsc -w & webpack --watch","dev:server":"http-server -p 8000 -c-1 -o /e2e/donation-flow-enhanced.html","dev":"concurrently \\"npm run dev:server\\" \\"npm run watch\\" --names \\"server,build\\" --prefix-colors \\"blue,green\\"","prepare":"husky install"},"devDependencies":{"@playwright/test":"^1.48.2","@types/jest":"^29.5.14","@typescript-eslint/eslint-plugin":"^8.18.2","@typescript-eslint/parser":"^8.18.2","concurrently":"^9.2.0","eslint":"^9.17.0","eslint-config-prettier":"^9.1.0","eslint-plugin-prettier":"^5.2.2","http-server":"^14.1.1","husky":"^9.1.7","jest":"^29.7.0","jest-environment-jsdom":"^30.0.5","lint-staged":"^15.3.0","playwright":"^1.48.2","prettier":"^3.4.2","ts-jest":"^29.2.5","ts-loader":"^9.5.1","ts-node":"^10.9.2","typescript":"^5.7.3","webpack":"^5.97.1","webpack-cli":"^5.1.4"},"prettier":{"singleQuote":true,"trailingComma":"es5"},"lint-staged":{"*.ts":["prettier --write","eslint --fix"]},"dependencies":{"@types/applepayjs":"^14.0.9","@types/googlepay":"^0.7.7","@types/grecaptcha":"^3.0.9","@types/spreedly-iframe-browser":"^1.0.3","@types/uuid":"^8.3.1","uuid":"^8.3.2"}}')},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}getMode(){return this.mode}on(e,t){this.eventHandlers.has(e)||this.eventHandlers.set(e,new Set),this.eventHandlers.get(e).add(t)}off(e,t){const n=this.eventHandlers.get(e);n&&n.delete(t)}emit(e,t){const n=this.eventHandlers.get(e);n&&n.forEach(e=>{try{e(t)}catch(e){}})}isCardData(e){return"expiryMonth"in e&&"expiryYear"in e}isBankAccountData(e){return"routingNumber"in e&&"accountNumber"in e}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)}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.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"}}},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.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(367);Object.defineProperty(t,"TokenizationError",{enumerable:!0,get:function(){return u.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){super(),this.iframeUrl=t,this.containerId=n,this.isReady=!1,this.enableTestMode=!1,this.mode=i,this.enableTestMode=r,this.iframe=e;const o=new URL(t);this.expectedOrigin=`${o.protocol}//${o.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);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.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,e.styling);Object.assign(t.style,n.container),"bank_account"===this.mode?this.createBankAccountFields(t,n):this.createCreditCardFields(t,n)}createCreditCardFields(e,t){this.iframe.style.width="100%",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",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.isReady=!0,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.isReady=!0,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 t,n,i;const r=(null===(t=this.routingNumberEl)||void 0===t?void 0:t.value)||e.routingNumber,o=(null===(n=this.accountNumberEl)||void 0===n?void 0:n.value)||e.accountNumber,d=(null===(i=this.accountTypeEl)||void 0===i?void 0:i.value)||e.accountType;if(!r||!o)throw new a.TokenizationError("Routing number and account number are required","VALIDATION_ERROR");if(!(0,c.validateRoutingNumber)(r))throw new a.TokenizationError("Invalid routing number","VALIDATION_ERROR");if(!(0,c.validateAccountNumber)(o))throw new a.TokenizationError("Invalid account number","VALIDATION_ERROR");const l=new URL(this.iframeUrl).origin,h=new s.default({});return h.cardConnectBaseUrl=l,{token:(yield u.tokenizeBankAccount(r,o,h)).token,lastFour:o.slice(-4),accountType:d,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;return"credit_card"===this.mode&&"0"===(null===(e=this.cachedTokenResult)||void 0===e?void 0:e.errorCode)?{token:this.cachedTokenResult.token,lastFour:this.cachedTokenResult.token.slice(-4),cardType:this.normalizeCardType("unknown"),provider:"cardconnect"}: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={token:t.token,lastFour:t.token.slice(-4),cardType:this.normalizeCardType("unknown"),provider:"cardconnect"};this.tokenizationResolve&&(this.tokenizationResolve(e),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",e)}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);"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})}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",orientation:"horizontal",formatinput:"true",unique:"true",norsa:"true",placeholder:"Card Number *",placeholdermonth:"MM",placeholderyear:"YYYY",placeholdercvv:"CVV",invalidcreditcardevent:"true",invalidexpiry:"true",invalidcvv:"true"}),i=(0,d.mergeStyles)(d.DEFAULT_UNIFIED_STYLES,t.styling),r=u.generateCardConnectCss(i),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){var t,n,i,r,o,a,s,d,l;const c=[];c.push("body{margin:0;padding:0;display:flex;align-items:center;}"),c.push("form{margin:0;padding:0;display:flex;width:100%;align-items:center;}"),c.push("label{display:none;}"),c.push("br{display:none;}");const u="0"===e.container.gap,h=u?"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(";");c.push(`input{${n};}`),c.push(`select{${n};}`)}if(u){const a=["width:60%","margin:0"];(null===(t=e.input)||void 0===t?void 0:t.borderRadius)&&a.push(`border-radius:${e.input.borderRadius} 0 0 ${e.input.borderRadius}`),a.push("border-right:none"),c.push(`input#ccnumfield{${a.join(";")};}`);const s=["width:10%","margin:0","margin-right:-12px","border-radius:0",`border-left:${(null===(n=e.input)||void 0===n?void 0:n.border)||"1px solid #ccc"}`,"border-right:none"];c.push(`select#ccexpirymonth{${s.join(";")};}`);const d=["width:10%","border-radius:0",`border-left:${(null===(i=e.input)||void 0===i?void 0:i.border)||"1px solid #ccc"}`,"border-right:none"];c.push(`select#ccexpiryyear{${d.join(";")};}`);const l=["width:20%","margin:0","margin-left:-12px"];(null===(r=e.input)||void 0===r?void 0:r.borderRadius)&&l.push(`border-radius:0 ${e.input.borderRadius} ${e.input.borderRadius} 0`),l.push(`border-left:${(null===(o=e.input)||void 0===o?void 0:o.border)||"1px solid #ccc"}`),c.push(`input#cccvvfield{${l.join(";")};}`)}else{const t=h.replace(/[^\d.]/g,""),n=h.replace(/[\d.]/g,""),i=parseFloat(t)/2,r=[`width:calc(60% - ${t}${n})`,`margin-right:${h}`];(null===(a=e.input)||void 0===a?void 0:a.borderRadius)&&r.push(`border-radius:${e.input.borderRadius}`),c.push(`input#ccnumfield{${r.join(";")};}`);const o=[`width:calc(10% - ${i}${n})`,`margin-right:calc(${h} / 2)`];(null===(s=e.input)||void 0===s?void 0:s.borderRadius)&&o.push(`border-radius:${e.input.borderRadius}`),c.push(`select#ccexpirymonth{${o.join(";")};}`);const u=[`width:calc(10% - ${i}${n})`,`margin-right:${h}`];(null===(d=e.input)||void 0===d?void 0:d.borderRadius)&&u.push(`border-radius:${e.input.borderRadius}`),c.push(`select#ccexpiryyear{${u.join(";")};}`);const p=["width:20%"];(null===(l=e.input)||void 0===l?void 0:l.borderRadius)&&p.push(`border-radius:${e.input.borderRadius}`),c.push(`input#cccvvfield{${p.join(";")};}`)}if(e.focus){const t=[];e.focus.borderColor&&t.push(`border-color:${e.focus.borderColor}`),e.focus.outline&&t.push(`outline:${e.focus.outline}`),e.focus.boxShadow&&t.push(`box-shadow:${e.focus.boxShadow}`),t.length>0&&c.push(`input:focus{${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&&c.push(`.error{${t.join(";")};}`)}return encodeURIComponent(c.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:()=>O,parse:()=>b,stringify:()=>c,v1:()=>y,v3:()=>w,v4:()=>I,v5:()=>k,validate:()=>s,version:()=>P});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 S(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=S(n,i=N(i,r,o,n,e[a+12],20,-1926607734),r,o,e[a+5],4,-378558),o=S(o,n,i,r,e[a+8],11,-2022574463),r=S(r,o,n,i,e[a+11],16,1839030562),i=S(i,r,o,n,e[a+14],23,-35309556),n=S(n,i,r,o,e[a+1],4,-1530992060),o=S(o,n,i,r,e[a+4],11,1272893353),r=S(r,o,n,i,e[a+7],16,-155497632),i=S(i,r,o,n,e[a+10],23,-1094730640),n=S(n,i,r,o,e[a+13],4,681279174),o=S(o,n,i,r,e[a],11,-358537222),r=S(r,o,n,i,e[a+3],16,-722521979),i=S(i,r,o,n,e[a+6],23,76029189),n=S(n,i,r,o,e[a+9],4,-640364487),o=S(o,n,i,r,e[a+12],11,-421815835),r=S(r,o,n,i,e[a+15],16,530742520),n=T(n,i=S(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))}),I=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]]}),O="00000000-0000-0000-0000-000000000000",P=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.borderColor="",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,this.embedId=t,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]}}},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))};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){if(super(),this.environmentKey=e,this.containerId=t,this.isReady=!1,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.mergeStyles)(l.DEFAULT_UNIFIED_STYLES,n);const a=this.generateFieldIds(t);this.numberEl=a.numberId,this.cvvEl=a.cvvId,this.expiryId=a.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);let a;if(o.organizationId=n.organizationId,o.embedId=n.embedId,o.clientConfig=n.clientConfig,o.createInternalElements(),"credit_card"===t.mode&&(null==n?void 0:n.organizationId)&&(null==n?void 0:n.embedId))try{a=yield(0,d.fetchSpreedlySecurityArgs)(n.clientConfig,n.organizationId,n.embedId)}catch(e){console.warn("Failed to fetch security args, using standard tokenization")}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.isReady=!0,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.isReady=!0,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.line1,address2:null===(r=e.address)||void 0===r?void 0:r.line2,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.postalCode,country:null===(l=e.address)||void 0===l?void 0:l.country})})})}createCanadianBankAccountFields(e){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)||e.accountType;if("CA"===this.bankCountry){const t=(null===(n=this.institutionNumberEl)||void 0===n?void 0:n.value)||e.institutionNumber,a=(null===(i=this.transitNumberEl)||void 0===i?void 0:i.value)||e.transitNumber;if(v=(null===(r=this.accountNumberEl)||void 0===r?void 0:r.value)||e.accountNumber,!t||!a||!v)throw new o.TokenizationError("Institution number, transit number, and account number are required","VALIDATION_ERROR");if(!(0,u.validateInstitutionNumber)(t))throw new o.TokenizationError("Institution number must be 3 digits","VALIDATION_ERROR");if(!(0,u.validateTransitNumber)(a))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)(t,a)}else{if(b=(null===(a=this.routingNumberEl)||void 0===a?void 0:a.value)||e.routingNumber,v=(null===(s=this.accountNumberEl)||void 0===s?void 0:s.value)||e.accountNumber,!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.line1,address2:null===(l=e.address)||void 0===l?void 0:l.line2,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.postalCode,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;if(!this.isReady)return;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){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){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)})());