@amos.com/amos-js 0.10.3 → 0.10.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -74,13 +74,7 @@ function r(e) {
74
74
  signature: r
75
75
  };
76
76
  }
77
- function i() {
78
- if (typeof window > "u") return !1;
79
- let { hostname: e } = window.location;
80
- return e === "localhost" || e.endsWith(".localhost");
81
- }
82
- function a(e) {
83
- if (i()) return "https://embed.localhost";
77
+ function i(e) {
84
78
  let { env: t = "sandbox" } = r(e).payload;
85
79
  switch (t) {
86
80
  case "production": return "https://embed.amos.com";
@@ -89,108 +83,71 @@ function a(e) {
89
83
  }
90
84
  }
91
85
  //#endregion
92
- //#region src/types.ts
93
- function o(e) {
94
- return e;
95
- }
96
- //#endregion
97
- //#region src/log.ts
98
- var s = /* @__PURE__ */ new Set([
99
- "authorization",
100
- "cookie",
101
- "set-cookie",
102
- "x-api-key"
103
- ]), c = /* @__PURE__ */ new Set([
104
- "authorization",
105
- "encrypted_account_number",
106
- "link_token",
107
- "public_token",
108
- "token"
109
- ]);
110
- function l(e) {
111
- let t = {};
112
- for (let [n, r] of Object.entries(e)) t[n] = s.has(n.toLowerCase()) ? "[REDACTED]" : r;
113
- return t;
86
+ //#region src/plaid-session.ts
87
+ var a = /* @__PURE__ */ new WeakMap();
88
+ function o(e, t) {
89
+ a.set(e, t);
114
90
  }
115
- function u(e) {
116
- if (Array.isArray(e)) return e.map(u);
117
- if (typeof e == "object" && e) {
118
- let t = {};
119
- for (let [n, r] of Object.entries(e)) t[n] = c.has(n) ? "[REDACTED]" : u(r);
120
- return t;
121
- }
122
- return e;
91
+ function s(e) {
92
+ if (e) return a.get(e);
123
93
  }
124
- function d({ iframe: e, message: t, endpoint: n, headers: r = {}, body: i }) {
125
- e.contentWindow?.postMessage(o({
126
- type: "PARENT_INFO_LOG",
127
- message: t,
128
- endpoint: n,
129
- headers: l(r),
130
- body: u(i)
131
- }), new URL(e.src).origin);
94
+ function c(e) {
95
+ e && a.delete(e);
132
96
  }
133
97
  //#endregion
134
- //#region src/plaid-session.ts
135
- var f = /* @__PURE__ */ new WeakMap();
136
- function p(e, t) {
137
- f.set(e, t);
138
- }
139
- function m(e) {
140
- if (e) return f.get(e);
141
- }
142
- function h(e) {
143
- e && f.delete(e);
98
+ //#region src/types.ts
99
+ function l(e) {
100
+ return e;
144
101
  }
145
102
  //#endregion
146
103
  //#region src/messaging.ts
147
- function g(e) {
104
+ function u(e) {
148
105
  return new URL(e.src).origin;
149
106
  }
150
- function _(e) {
151
- e?.contentWindow && e.contentWindow.postMessage(o({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), g(e));
107
+ function d(e) {
108
+ e?.contentWindow && e.contentWindow.postMessage(l({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), u(e));
152
109
  }
153
- function v({ iframe: e, appearance: t = {} }) {
154
- e?.contentWindow && e.contentWindow.postMessage(o({
110
+ function f({ iframe: e, appearance: t = {} }) {
111
+ e?.contentWindow && e.contentWindow.postMessage(l({
155
112
  type: "UPDATE_APPEARANCE",
156
113
  appearance: t
157
- }), g(e));
114
+ }), u(e));
158
115
  }
159
- function y({ iframe: e, props: t, height: n }) {
160
- e?.contentWindow && e.contentWindow.postMessage(o({
116
+ function p({ iframe: e, props: t, height: n }) {
117
+ e?.contentWindow && e.contentWindow.postMessage(l({
161
118
  type: "UPDATE_APPLE_PAY_BUTTON",
162
119
  height: n,
163
120
  props: t
164
- }), g(e));
121
+ }), u(e));
165
122
  }
166
- function b({ iframe: e, props: t, height: n }) {
167
- e?.contentWindow && e.contentWindow.postMessage(o({
123
+ function m({ iframe: e, props: t, height: n }) {
124
+ e?.contentWindow && e.contentWindow.postMessage(l({
168
125
  type: "UPDATE_GOOGLE_PAY_BUTTON",
169
126
  height: n,
170
127
  props: t
171
- }), g(e));
128
+ }), u(e));
172
129
  }
173
- function x({ iframe: e, amount: t }) {
174
- e?.contentWindow && e.contentWindow.postMessage(o({
130
+ function h({ iframe: e, amount: t }) {
131
+ e?.contentWindow && e.contentWindow.postMessage(l({
175
132
  type: "UPDATE_AMOUNT",
176
133
  amount: t
177
- }), g(e));
134
+ }), u(e));
178
135
  }
179
- function S({ iframe: e, merchantName: t }) {
180
- e?.contentWindow && e.contentWindow.postMessage(o({
136
+ function g({ iframe: e, merchantName: t }) {
137
+ e?.contentWindow && e.contentWindow.postMessage(l({
181
138
  type: "UPDATE_MERCHANT_NAME",
182
139
  merchantName: t
183
- }), g(e));
140
+ }), u(e));
184
141
  }
185
- function C({ iframe: e }) {
186
- let t = m(e);
142
+ function _({ iframe: e }) {
143
+ let t = s(e);
187
144
  if (t?.requiresVerification) return Promise.resolve(!!t.plaid);
188
145
  let n = crypto.randomUUID();
189
146
  return new Promise((t) => {
190
- e?.contentWindow && e.contentWindow.postMessage(o({
147
+ e?.contentWindow && e.contentWindow.postMessage(l({
191
148
  type: "VALIDATE_FORM",
192
149
  requestId: n
193
- }), g(e));
150
+ }), u(e));
194
151
  let r = setTimeout(() => {
195
152
  window.removeEventListener("message", i), t(!1);
196
153
  }, 5e3);
@@ -200,7 +157,7 @@ function C({ iframe: e }) {
200
157
  window.addEventListener("message", i);
201
158
  });
202
159
  }
203
- var w = 1e4;
160
+ var v = 1e4;
204
161
  function ee({ iframe: e }) {
205
162
  let t = crypto.randomUUID();
206
163
  return new Promise((n, r) => {
@@ -209,111 +166,96 @@ function ee({ iframe: e }) {
209
166
  return;
210
167
  }
211
168
  let i = e.contentWindow;
212
- i.postMessage(o({
169
+ i.postMessage(l({
213
170
  type: "CREATE_PLAID_LINK_TOKEN",
214
171
  requestId: t
215
- }), g(e));
172
+ }), u(e));
216
173
  let a = setTimeout(() => {
217
- window.removeEventListener("message", s), r(/* @__PURE__ */ Error("Timed out waiting for Plaid Link token."));
218
- }, w);
219
- function s(e) {
174
+ window.removeEventListener("message", o), r(/* @__PURE__ */ Error("Timed out waiting for Plaid Link token."));
175
+ }, v);
176
+ function o(e) {
220
177
  if (e.source === i && e.data.type === "PLAID_LINK_TOKEN" && e.data.requestId === t) {
221
- if (window.removeEventListener("message", s), clearTimeout(a), e.data.link_token) {
178
+ if (window.removeEventListener("message", o), clearTimeout(a), e.data.link_token) {
222
179
  n(e.data.link_token);
223
180
  return;
224
181
  }
225
182
  r(Error(e.data.error ?? "Could not create Plaid Link token."));
226
183
  }
227
184
  }
228
- window.addEventListener("message", s);
185
+ window.addEventListener("message", o);
229
186
  });
230
187
  }
231
- function T({ iframe: e }) {
232
- m(e)?.clearLinked?.(), E(e);
188
+ function y({ iframe: e }) {
189
+ s(e)?.clearLinked?.(), b(e);
233
190
  }
234
- function E(e) {
235
- e?.contentWindow && e.contentWindow.postMessage(o({ type: "RESET_FORM" }), g(e));
191
+ function b(e) {
192
+ e?.contentWindow && e.contentWindow.postMessage(l({ type: "RESET_FORM" }), u(e));
236
193
  }
237
- function D({ iframe: e, type: t, token: n, id: r }) {
238
- let i = m(e), a = i?.plaid;
239
- i?.requiresVerification && !a && E(e);
240
- let s = g(e);
241
- d({
242
- iframe: e,
243
- message: t === "CONFIRM_PAYMENT_INTENT" ? "confirmPaymentIntent" : "confirmSetupIntent",
244
- endpoint: t === "CONFIRM_PAYMENT_INTENT" ? "POST /embed/payment_intents/{id}/confirm_with_payment_method" : "POST /embed/setup_intents/{id}/confirm_with_payment_method",
245
- headers: {
246
- origin: window.location.origin,
247
- "iframe-origin": s
248
- },
249
- body: {
250
- id: r,
251
- token: n,
252
- ...a ? { plaid: a } : {}
253
- }
254
- }), e.contentWindow?.postMessage(o({
194
+ function x({ iframe: e, type: t, token: n, id: r }) {
195
+ let i = s(e), a = i?.plaid;
196
+ i?.requiresVerification && !a && b(e), e.contentWindow?.postMessage(l({
255
197
  type: t,
256
198
  token: n,
257
199
  id: r,
258
200
  ...a ? { plaid: a } : {}
259
- }), g(e));
201
+ }), u(e));
260
202
  }
261
- function O({ iframe: e, token: t }) {
203
+ function S({ iframe: e, token: t }) {
262
204
  if (!e?.contentWindow) return;
263
205
  let { payment_intent_id: n } = r(t).payload;
264
- D({
206
+ x({
265
207
  iframe: e,
266
208
  type: "CONFIRM_PAYMENT_INTENT",
267
209
  token: t,
268
210
  id: n ?? void 0
269
211
  });
270
212
  }
271
- function k({ iframe: e, token: t }) {
213
+ function C({ iframe: e, token: t }) {
272
214
  if (!e?.contentWindow) return;
273
215
  let { setup_intent_id: n } = r(t).payload;
274
- D({
216
+ x({
275
217
  iframe: e,
276
218
  type: "CONFIRM_SETUP_INTENT",
277
219
  token: t,
278
220
  id: n ?? void 0
279
221
  });
280
222
  }
281
- function A({ iframe: e, result: t }) {
282
- e?.contentWindow && e.contentWindow.postMessage(o({
223
+ function w({ iframe: e, result: t }) {
224
+ e?.contentWindow && e.contentWindow.postMessage(l({
283
225
  type: "CONFIRMATION_RESULT",
284
226
  result: t
285
- }), g(e));
227
+ }), u(e));
286
228
  }
287
229
  //#endregion
288
230
  //#region src/apple-pay.ts
289
- function te(e) {
290
- return `${a(e)}/iframe/apple-pay?token=${e}`;
231
+ function T(e) {
232
+ return `${i(e)}/iframe/apple-pay?token=${e}`;
291
233
  }
292
- function j() {
234
+ function E() {
293
235
  return "48px";
294
236
  }
295
- function ne(e) {
296
- e.contentWindow?.postMessage(o({ type: "APPLE_PAY_CANCEL" }), g(e));
237
+ function D(e) {
238
+ e.contentWindow?.postMessage(l({ type: "APPLE_PAY_CANCEL" }), u(e));
297
239
  }
298
- function M(e, { height: r = "48px", ...i }) {
240
+ function O(e, { height: r = "48px", ...i }) {
299
241
  let a = {
300
242
  ...i,
301
243
  height: r
302
244
  };
303
245
  function o() {
304
- x({
246
+ h({
305
247
  iframe: e,
306
248
  amount: a.amount
307
249
  });
308
250
  }
309
251
  function s() {
310
- S({
252
+ g({
311
253
  iframe: e,
312
254
  merchantName: a.merchantName
313
255
  });
314
256
  }
315
257
  function c() {
316
- y({
258
+ p({
317
259
  iframe: e,
318
260
  height: a.height ?? "48px",
319
261
  props: a.buttonProps ?? {}
@@ -322,7 +264,7 @@ function M(e, { height: r = "48px", ...i }) {
322
264
  function l(r) {
323
265
  if (r.source === e.contentWindow) switch (r.data.type) {
324
266
  case "IFRAME_READY":
325
- _(e), v({
267
+ d(e), f({
326
268
  iframe: e,
327
269
  appearance: {}
328
270
  }), o(), s(), c();
@@ -331,7 +273,7 @@ function M(e, { height: r = "48px", ...i }) {
331
273
  a.onHeightChange?.(r.data.height);
332
274
  break;
333
275
  case "UPDATE_APPEARANCE":
334
- v({
276
+ f({
335
277
  iframe: e,
336
278
  appearance: r.data.appearance
337
279
  });
@@ -341,7 +283,7 @@ function M(e, { height: r = "48px", ...i }) {
341
283
  break;
342
284
  case "APPLE_PAY_WINDOW_OPEN":
343
285
  t({ onCancel: () => {
344
- ne(e), n();
286
+ D(e), n();
345
287
  } });
346
288
  break;
347
289
  case "APPLE_PAY_WINDOW_CLOSE":
@@ -352,7 +294,7 @@ function M(e, { height: r = "48px", ...i }) {
352
294
  paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
353
295
  customerCreateAttributes: r.data.customerCreateAttributes
354
296
  }).then((t) => {
355
- O({
297
+ S({
356
298
  iframe: e,
357
299
  token: t
358
300
  });
@@ -381,7 +323,7 @@ function M(e, { height: r = "48px", ...i }) {
381
323
  }
382
324
  //#endregion
383
325
  //#region src/form-skeleton.ts
384
- var N = "amos-js-form-skeleton-styles", re = {
326
+ var k = "amos-js-form-skeleton-styles", te = {
385
327
  "--accent": "oklch(0.97 0 0)",
386
328
  "--radius": "0.625rem",
387
329
  "--input-height": "2.25rem",
@@ -389,123 +331,123 @@ var N = "amos-js-form-skeleton-styles", re = {
389
331
  "--field-gap": "1rem",
390
332
  "--control-gap": "0.5rem",
391
333
  "--label-font-size": "0.875rem"
392
- }, ie = "\n.amos-js-form-skeleton {\n box-sizing: border-box;\n container-type: inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n margin: 0 -4px;\n padding-block: 0.25rem;\n pointer-events: none;\n width: calc(100% + 8px);\n}\n.amos-js-form-skeleton-field {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n min-width: 0;\n width: 100%;\n}\n.amos-js-form-skeleton-label {\n flex-shrink: 0;\n font-size: var(--label-font-size);\n height: 1.75rem;\n line-height: 1.75rem;\n}\n.amos-js-form-skeleton-input {\n animation: amos-js-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n background: var(--accent);\n border-radius: calc(var(--radius) * 0.8);\n box-sizing: border-box;\n height: var(--input-height);\n width: 100%;\n}\n.amos-js-form-skeleton-input-floating {\n height: var(--floating-input-height);\n}\n.amos-js-form-skeleton-row {\n align-items: flex-start;\n display: flex;\n gap: var(--control-gap);\n width: 100%;\n}\n.amos-js-form-skeleton-row-stack {\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n width: 100%;\n}\n@container (min-width: 24rem) {\n .amos-js-form-skeleton-row-stack {\n align-items: flex-start;\n flex-direction: row;\n gap: var(--control-gap);\n }\n}\n.amos-js-wallet-skeleton {\n flex: none;\n width: 100%;\n}\n@keyframes amos-js-skeleton-pulse {\n 50% { opacity: 0.5; }\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-form-skeleton-input {\n animation: none;\n }\n}\n";
393
- function P() {
394
- if (document.getElementById(N)) return;
334
+ }, ne = "\n.amos-js-form-skeleton {\n box-sizing: border-box;\n container-type: inline-size;\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n margin: 0 -4px;\n padding-block: 0.25rem;\n pointer-events: none;\n width: calc(100% + 8px);\n}\n.amos-js-form-skeleton-field {\n display: flex;\n flex: 1 1 0;\n flex-direction: column;\n min-width: 0;\n width: 100%;\n}\n.amos-js-form-skeleton-label {\n flex-shrink: 0;\n font-size: var(--label-font-size);\n height: 1.75rem;\n line-height: 1.75rem;\n}\n.amos-js-form-skeleton-input {\n animation: amos-js-skeleton-pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;\n background: var(--accent);\n border-radius: calc(var(--radius) * 0.8);\n box-sizing: border-box;\n height: var(--input-height);\n width: 100%;\n}\n.amos-js-form-skeleton-input-floating {\n height: var(--floating-input-height);\n}\n.amos-js-form-skeleton-row {\n align-items: flex-start;\n display: flex;\n gap: var(--control-gap);\n width: 100%;\n}\n.amos-js-form-skeleton-row-stack {\n display: flex;\n flex-direction: column;\n gap: var(--field-gap);\n width: 100%;\n}\n@container (min-width: 24rem) {\n .amos-js-form-skeleton-row-stack {\n align-items: flex-start;\n flex-direction: row;\n gap: var(--control-gap);\n }\n}\n.amos-js-wallet-skeleton {\n flex: none;\n width: 100%;\n}\n@keyframes amos-js-skeleton-pulse {\n 50% { opacity: 0.5; }\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-form-skeleton-input {\n animation: none;\n }\n}\n";
335
+ function A() {
336
+ if (document.getElementById(k)) return;
395
337
  let e = document.createElement("style");
396
- e.id = N, e.textContent = ie, document.head.appendChild(e);
338
+ e.id = k, e.textContent = ne, document.head.appendChild(e);
397
339
  }
398
- function ae(e, t) {
399
- for (let [t, n] of Object.entries(re)) e.style.setProperty(t, n);
340
+ function j(e, t) {
341
+ for (let [t, n] of Object.entries(te)) e.style.setProperty(t, n);
400
342
  let n = t?.themeVariables;
401
343
  if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
402
344
  }
403
- function F(e, t) {
345
+ function M(e, t) {
404
346
  let n = document.createElement("div");
405
347
  if (n.className = e, t) for (let e of t) n.appendChild(e);
406
348
  return n;
407
349
  }
408
- function I(e, t) {
409
- let n = F("amos-js-form-skeleton-field");
410
- t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(F("amos-js-form-skeleton-label"));
411
- let r = F("amos-js-form-skeleton-input");
350
+ function N(e, t) {
351
+ let n = M("amos-js-form-skeleton-field");
352
+ t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(M("amos-js-form-skeleton-label"));
353
+ let r = M("amos-js-form-skeleton-input");
412
354
  return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
413
355
  }
414
- function L(e, t) {
415
- return F(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
356
+ function P(e, t) {
357
+ return M(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
416
358
  }
417
- function R({ labels: e, requirement: t, wrapCountryZip: n }) {
359
+ function re({ labels: e, requirement: t, wrapCountryZip: n }) {
418
360
  return t === "full" ? [
419
- I(e),
420
- I(e),
421
- L([
422
- I(e, 1.4),
423
- I(e, .7),
424
- I(e, .8)
361
+ N(e),
362
+ N(e),
363
+ P([
364
+ N(e, 1.4),
365
+ N(e, .7),
366
+ N(e, .8)
425
367
  ], !1),
426
- I(e)
427
- ] : [L([I(e), I(e)], n)];
368
+ N(e)
369
+ ] : [P([N(e), N(e)], n)];
428
370
  }
429
- function oe(e) {
371
+ function ie(e) {
430
372
  let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
431
373
  if (e.kind === "card") {
432
- let r = [I(t), L([I(t), I(t)], !1)];
433
- return e.additionalFields?.cardholderName && r.push(I(t)), r.push(...R({
374
+ let r = [N(t), P([N(t), N(t)], !1)];
375
+ return e.additionalFields?.cardholderName && r.push(N(t)), r.push(...re({
434
376
  labels: t,
435
377
  requirement: n,
436
378
  wrapCountryZip: !1
437
379
  })), r;
438
380
  }
439
381
  return [
440
- I(t),
441
- L([I(t), I(t)], !0),
442
- I(t),
443
- L([I("above"), I("above")], !0),
444
- ...R({
382
+ N(t),
383
+ P([N(t), N(t)], !0),
384
+ N(t),
385
+ P([N("above"), N("above")], !0),
386
+ ...re({
445
387
  labels: t,
446
388
  requirement: n,
447
389
  wrapCountryZip: !0
448
390
  })
449
391
  ];
450
392
  }
451
- function z(e) {
452
- P();
453
- let t = F("amos-js-form-skeleton");
393
+ function ae(e) {
394
+ A();
395
+ let t = M("amos-js-form-skeleton");
454
396
  t.setAttribute("aria-hidden", "true");
455
397
  function n(e) {
456
- ae(t, e.appearance), t.replaceChildren(...oe(e));
398
+ j(t, e.appearance), t.replaceChildren(...ie(e));
457
399
  }
458
400
  return n(e), {
459
401
  element: t,
460
402
  update: n
461
403
  };
462
404
  }
463
- function B(e) {
464
- P();
465
- let t = F("amos-js-form-skeleton-input amos-js-wallet-skeleton");
405
+ function F(e) {
406
+ A();
407
+ let t = M("amos-js-form-skeleton-input amos-js-wallet-skeleton");
466
408
  t.setAttribute("aria-hidden", "true");
467
409
  function n(e) {
468
- ae(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
410
+ j(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
469
411
  }
470
412
  return n(e), {
471
413
  element: t,
472
414
  update: n
473
415
  };
474
416
  }
475
- function V(e) {
417
+ function I(e) {
476
418
  if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
477
419
  if (typeof e == "string" && e.trim() !== "") return e.trim();
478
420
  }
479
- function H({ iframeStyle: e, buttonProps: t }) {
480
- return V(e?.borderRadius) ?? V(t?.buttonRadius) ?? V(t?.style?.borderRadius) ?? V(t?.style?.["--apple-pay-button-border-radius"]) ?? "4px";
421
+ function L({ iframeStyle: e, buttonProps: t }) {
422
+ return I(e?.borderRadius) ?? I(t?.buttonRadius) ?? I(t?.style?.borderRadius) ?? I(t?.style?.["--apple-pay-button-border-radius"]) ?? "4px";
481
423
  }
482
424
  //#endregion
483
425
  //#region src/google-pay.ts
484
- function U(e) {
485
- return `${a(e)}/iframe/google-pay?token=${e}`;
426
+ function R(e) {
427
+ return `${i(e)}/iframe/google-pay?token=${e}`;
486
428
  }
487
- function W() {
429
+ function z() {
488
430
  return "48px";
489
431
  }
490
- function G(e, { height: t = "48px", ...n }) {
432
+ function B(e, { height: t = "48px", ...n }) {
491
433
  let r = {
492
434
  ...n,
493
435
  height: t
494
436
  };
495
437
  function i() {
496
- x({
438
+ h({
497
439
  iframe: e,
498
440
  amount: r.amount
499
441
  });
500
442
  }
501
443
  function a() {
502
- S({
444
+ g({
503
445
  iframe: e,
504
446
  merchantName: r.merchantName
505
447
  });
506
448
  }
507
449
  function o() {
508
- b({
450
+ m({
509
451
  iframe: e,
510
452
  height: r.height ?? "48px",
511
453
  props: r.buttonProps ?? {}
@@ -514,7 +456,7 @@ function G(e, { height: t = "48px", ...n }) {
514
456
  function s(t) {
515
457
  if (t.source === e.contentWindow) switch (t.data.type) {
516
458
  case "IFRAME_READY":
517
- _(e), v({
459
+ d(e), f({
518
460
  iframe: e,
519
461
  appearance: {}
520
462
  }), i(), a(), o();
@@ -523,7 +465,7 @@ function G(e, { height: t = "48px", ...n }) {
523
465
  r.onHeightChange?.(t.data.height);
524
466
  break;
525
467
  case "UPDATE_APPEARANCE":
526
- v({
468
+ f({
527
469
  iframe: e,
528
470
  appearance: t.data.appearance
529
471
  });
@@ -536,7 +478,7 @@ function G(e, { height: t = "48px", ...n }) {
536
478
  paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
537
479
  customerCreateAttributes: t.data.customerCreateAttributes
538
480
  }).then((t) => {
539
- O({
481
+ S({
540
482
  iframe: e,
541
483
  token: t
542
484
  });
@@ -563,7 +505,7 @@ function G(e, { height: t = "48px", ...n }) {
563
505
  }
564
506
  };
565
507
  }
566
- function se({ paymentData: e }) {
508
+ function oe({ paymentData: e }) {
567
509
  return { paymentMethod: {
568
510
  type: "googlepay",
569
511
  billing_address_attributes: {
@@ -582,40 +524,40 @@ function se({ paymentData: e }) {
582
524
  }
583
525
  //#endregion
584
526
  //#region src/payment-method-form.ts
585
- var K = {
527
+ var V = {
586
528
  country: 212,
587
529
  full: 452
588
- }, ce = 80, q = {
530
+ }, se = 80, H = {
589
531
  country: 400,
590
532
  full: 640
591
533
  };
592
- function J(e, t = { cardholderName: !1 }, n = "country") {
593
- let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), i = new URLSearchParams({
534
+ function U(e, t = { cardholderName: !1 }, n = "country") {
535
+ let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
594
536
  token: e,
595
537
  additionalFields: r,
596
538
  billingAddressRequirement: n
597
539
  });
598
- return `${a(e)}/iframe/card?${i}`;
540
+ return `${i(e)}/iframe/card?${a}`;
599
541
  }
600
- function Y(e, t = "country", n = "payment") {
542
+ function W(e, t = "country", n = "payment") {
601
543
  let r = new URLSearchParams({
602
544
  token: e,
603
545
  billingAddressRequirement: t
604
546
  });
605
- return n === "setup" && r.set("intent", "setup"), `${a(e)}/iframe/bank?${r}`;
547
+ return n === "setup" && r.set("intent", "setup"), `${i(e)}/iframe/bank?${r}`;
606
548
  }
607
- function le(e = { cardholderName: !1 }, t = "country") {
608
- return `${(K[t] ?? K.country) + (e.cardholderName ? ce : 0)}px`;
549
+ function G(e = { cardholderName: !1 }, t = "country") {
550
+ return `${(V[t] ?? V.country) + (e.cardholderName ? se : 0)}px`;
609
551
  }
610
- function ue(e = "country") {
611
- return `${q[e] ?? q.country}px`;
552
+ function K(e = "country") {
553
+ return `${H[e] ?? H.country}px`;
612
554
  }
613
- function de(e, t) {
555
+ function q(e, t) {
614
556
  let n = { ...t };
615
557
  function r(t) {
616
558
  if (t.source === e.contentWindow) switch (t.data.type) {
617
559
  case "IFRAME_READY":
618
- _(e), v({
560
+ d(e), f({
619
561
  iframe: e,
620
562
  appearance: n.appearance
621
563
  });
@@ -624,7 +566,7 @@ function de(e, t) {
624
566
  n.onHeightChange?.(t.data.height);
625
567
  break;
626
568
  case "UPDATE_APPEARANCE":
627
- v({
569
+ f({
628
570
  iframe: e,
629
571
  appearance: t.data.appearance
630
572
  });
@@ -633,7 +575,7 @@ function de(e, t) {
633
575
  n.onAppearanceReady?.();
634
576
  break;
635
577
  case "FORM_VALIDITY_CHANGE":
636
- if (m(e)?.requiresVerification) break;
578
+ if (s(e)?.requiresVerification) break;
637
579
  n.onValidityChange?.({ isValid: t.data.isValid });
638
580
  break;
639
581
  case "CARD_BRAND_CHANGE":
@@ -648,7 +590,7 @@ function de(e, t) {
648
590
  n = {
649
591
  ...n,
650
592
  ...t
651
- }, r && v({
593
+ }, r && f({
652
594
  iframe: e,
653
595
  appearance: n.appearance
654
596
  });
@@ -660,21 +602,21 @@ function de(e, t) {
660
602
  }
661
603
  //#endregion
662
604
  //#region src/plaid.ts
663
- var fe = "https://cdn.plaid.com/link/v2/stable/link-initialize.js";
664
- function pe({ amount: e, achThreshold: t }) {
605
+ var J = "https://cdn.plaid.com/link/v2/stable/link-initialize.js";
606
+ function Y({ amount: e, achThreshold: t }) {
665
607
  return t != null && (e ?? 0) >= t;
666
608
  }
667
- function me(e) {
609
+ function ce(e) {
668
610
  if (e == null) return;
669
611
  let t = e.trim();
670
612
  if (t === "") return;
671
613
  let n = Number(t.replace(/[^\d.]/g, ""));
672
614
  if (Number.isFinite(n)) return Math.round(n * 100);
673
615
  }
674
- function he(e) {
616
+ function le(e) {
675
617
  return e.account_id ?? e.account?.id ?? e.accounts?.[0]?.id;
676
618
  }
677
- function ge(e) {
619
+ function ue(e) {
678
620
  let t = e.account ?? e.accounts?.[0];
679
621
  return {
680
622
  bankName: e.institution?.name ?? "Bank account",
@@ -682,13 +624,13 @@ function ge(e) {
682
624
  };
683
625
  }
684
626
  var X;
685
- function _e() {
686
- for (let e of document.querySelectorAll(`script[src="${fe}"]`)) e.remove();
627
+ function de() {
628
+ for (let e of document.querySelectorAll(`script[src="${J}"]`)) e.remove();
687
629
  }
688
- function ve() {
689
- return typeof window > "u" ? Promise.reject(/* @__PURE__ */ Error("Plaid Link requires a browser")) : window.Plaid ? Promise.resolve() : X || (_e(), X = new Promise((e, t) => {
630
+ function fe() {
631
+ return typeof window > "u" ? Promise.reject(/* @__PURE__ */ Error("Plaid Link requires a browser")) : window.Plaid ? Promise.resolve() : X || (de(), X = new Promise((e, t) => {
690
632
  let n = document.createElement("script");
691
- n.src = fe, n.async = !0;
633
+ n.src = J, n.async = !0;
692
634
  let r = (e) => {
693
635
  n.remove(), X = void 0, t(Error(e));
694
636
  };
@@ -701,8 +643,8 @@ function ve() {
701
643
  }, { once: !0 }), n.addEventListener("error", () => r("Failed to load Plaid Link"), { once: !0 }), document.head.append(n);
702
644
  }), X);
703
645
  }
704
- async function ye({ token: e, onSuccess: t, onExit: n, signal: r }) {
705
- if (await ve(), r?.aborted) return () => {};
646
+ async function pe({ token: e, onSuccess: t, onExit: n, signal: r }) {
647
+ if (await fe(), r?.aborted) return () => {};
706
648
  if (!window.Plaid) throw Error("Plaid Link failed to initialize");
707
649
  let i = window.Plaid.create({
708
650
  token: e,
@@ -717,135 +659,126 @@ async function ye({ token: e, onSuccess: t, onExit: n, signal: r }) {
717
659
  }
718
660
  //#endregion
719
661
  //#region src/plaid-bank-ui.ts
720
- var be = "amos-js-plaid-bank-ui-styles", xe = "\n.amos-js-plaid-panel {\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n display: none;\n flex-direction: column;\n font-family: inherit;\n gap: var(--control-gap, 0.5rem);\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"connect\"],\n.amos-js-plaid-panel[data-mode=\"linked\"] {\n display: flex;\n}\n.amos-js-plaid-connect {\n align-items: center;\n background: var(--background, oklch(1 0 0));\n border: var(--input-border-width, 1px) solid var(--border, oklch(0.922 0 0));\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n box-shadow: var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05));\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n cursor: pointer;\n display: inline-flex;\n flex-shrink: 0;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n height: var(--input-height, 2.25rem);\n justify-content: center;\n line-height: 1.25;\n outline: none;\n padding: 0 var(--input-padding, 0.75rem);\n transition: color 150ms, background-color 150ms, border-color 150ms, box-shadow 150ms;\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-connect {\n display: none;\n}\n.amos-js-plaid-connect:hover:not(:disabled) {\n background: var(--accent, oklch(0.97 0 0));\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-connect:focus-visible {\n border-color: var(--ring, oklch(0.708 0 0));\n box-shadow:\n var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05)),\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-connect:disabled {\n cursor: default;\n opacity: 0.5;\n pointer-events: none;\n}\n.amos-js-plaid-linked {\n display: none;\n flex-direction: column;\n gap: 0.25rem;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-linked {\n display: flex;\n}\n.amos-js-plaid-linked-name {\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n}\n.amos-js-plaid-linked-meta {\n color: var(--muted-foreground, oklch(0.556 0 0));\n font-size: 0.75rem;\n}\n.amos-js-plaid-disconnect {\n align-self: flex-start;\n background: none;\n border: none;\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n color: var(--muted-foreground, oklch(0.556 0 0));\n cursor: pointer;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n margin-top: 0.25rem;\n outline: none;\n padding: 0;\n}\n.amos-js-plaid-disconnect:hover {\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-disconnect:focus-visible {\n box-shadow:\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-error {\n color: var(--destructive, oklch(0.577 0.245 27.325));\n display: none;\n font-size: var(--error-font-size, 0.875rem);\n margin: 0;\n}\n.amos-js-plaid-error:not(:empty) {\n display: block;\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-plaid-connect {\n transition: none;\n }\n}\n";
721
- function Se() {
722
- if (document.getElementById(be)) return;
662
+ var me = "amos-js-plaid-bank-ui-styles", he = "\n.amos-js-plaid-panel {\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n display: none;\n flex-direction: column;\n font-family: inherit;\n gap: var(--control-gap, 0.5rem);\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"connect\"],\n.amos-js-plaid-panel[data-mode=\"linked\"] {\n display: flex;\n}\n.amos-js-plaid-connect {\n align-items: center;\n background: var(--background, oklch(1 0 0));\n border: var(--input-border-width, 1px) solid var(--border, oklch(0.922 0 0));\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n box-shadow: var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05));\n box-sizing: border-box;\n color: var(--foreground, oklch(0.145 0 0));\n cursor: pointer;\n display: inline-flex;\n flex-shrink: 0;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n height: var(--input-height, 2.25rem);\n justify-content: center;\n line-height: 1.25;\n outline: none;\n padding: 0 var(--input-padding, 0.75rem);\n transition: color 150ms, background-color 150ms, border-color 150ms, box-shadow 150ms;\n width: 100%;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-connect {\n display: none;\n}\n.amos-js-plaid-connect:hover:not(:disabled) {\n background: var(--accent, oklch(0.97 0 0));\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-connect:focus-visible {\n border-color: var(--ring, oklch(0.708 0 0));\n box-shadow:\n var(--input-shadow, 0 1px 2px 0 rgb(0 0 0 / 0.05)),\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-connect:disabled {\n cursor: default;\n opacity: 0.5;\n pointer-events: none;\n}\n.amos-js-plaid-linked {\n display: none;\n flex-direction: column;\n gap: 0.25rem;\n}\n.amos-js-plaid-panel[data-mode=\"linked\"] .amos-js-plaid-linked {\n display: flex;\n}\n.amos-js-plaid-linked-name {\n font-size: var(--input-font-size, 0.875rem);\n font-weight: 500;\n}\n.amos-js-plaid-linked-meta {\n color: var(--muted-foreground, oklch(0.556 0 0));\n font-size: 0.75rem;\n}\n.amos-js-plaid-disconnect {\n align-self: flex-start;\n background: none;\n border: none;\n border-radius: calc(var(--radius, 0.625rem) * 0.8);\n color: var(--muted-foreground, oklch(0.556 0 0));\n cursor: pointer;\n font: inherit;\n font-size: var(--input-font-size, 0.875rem);\n margin-top: 0.25rem;\n outline: none;\n padding: 0;\n}\n.amos-js-plaid-disconnect:hover {\n color: var(--accent-foreground, oklch(0.205 0 0));\n}\n.amos-js-plaid-disconnect:focus-visible {\n box-shadow:\n 0 0 0 var(--ring-width, 3px)\n color-mix(in oklab, var(--ring, oklch(0.708 0 0)) 50%, transparent);\n}\n.amos-js-plaid-error {\n color: var(--destructive, oklch(0.577 0.245 27.325));\n display: none;\n font-size: var(--error-font-size, 0.875rem);\n margin: 0;\n}\n.amos-js-plaid-error:not(:empty) {\n display: block;\n}\n@media (prefers-reduced-motion: reduce) {\n .amos-js-plaid-connect {\n transition: none;\n }\n}\n";
663
+ function ge() {
664
+ if (document.getElementById(me)) return;
723
665
  let e = document.createElement("style");
724
- e.id = be, e.textContent = xe, document.head.append(e);
666
+ e.id = me, e.textContent = he, document.head.append(e);
725
667
  }
726
- function Ce(e, t, n) {
668
+ function _e(e, t, n) {
727
669
  for (let t of n) e.style.removeProperty(t);
728
670
  n.length = 0;
729
671
  let r = t?.themeVariables;
730
672
  if (r) for (let [t, i] of Object.entries(r)) typeof i == "string" && i.trim() !== "" && (e.style.setProperty(t, i.trim()), n.push(t));
731
673
  }
732
- function we({ host: e, iframe: t, options: n }) {
733
- Se();
674
+ function ve({ host: e, iframe: t, options: n }) {
675
+ ge();
734
676
  let r = {
735
677
  ...n,
736
678
  amount: n.amount ?? "0"
737
- }, i = [], a = !1, o, s = !1, c, l = !1, u, f, m = new AbortController(), g, _ = document.createElement("div");
738
- _.className = "amos-js-plaid-panel", _.setAttribute("data-amos-plaid-panel", "true"), _.dataset.mode = "hidden", Ce(_, r.appearance, i);
739
- let v = document.createElement("button");
740
- v.type = "button", v.className = "amos-js-plaid-connect", v.textContent = "Connect bank account", v.setAttribute("data-testid", "amos-plaid-connect");
741
- let y = document.createElement("div");
742
- y.className = "amos-js-plaid-linked";
679
+ }, i = [], a = !1, s, l = !1, u, d = !1, f, p, m = new AbortController(), h, g = document.createElement("div");
680
+ g.className = "amos-js-plaid-panel", g.setAttribute("data-amos-plaid-panel", "true"), g.dataset.mode = "hidden", _e(g, r.appearance, i);
681
+ let _ = document.createElement("button");
682
+ _.type = "button", _.className = "amos-js-plaid-connect", _.textContent = "Connect bank account", _.setAttribute("data-testid", "amos-plaid-connect");
683
+ let v = document.createElement("div");
684
+ v.className = "amos-js-plaid-linked";
685
+ let y = document.createElement("span");
686
+ y.className = "amos-js-plaid-linked-name";
743
687
  let b = document.createElement("span");
744
- b.className = "amos-js-plaid-linked-name";
745
- let x = document.createElement("span");
746
- x.className = "amos-js-plaid-linked-meta";
747
- let S = document.createElement("button");
748
- S.type = "button", S.className = "amos-js-plaid-disconnect", S.textContent = "Disconnect", S.setAttribute("aria-label", "Disconnect bank account");
749
- let C = document.createElement("p");
750
- C.className = "amos-js-plaid-error", C.setAttribute("role", "alert"), y.append(b, x, S), _.append(v, y, C), e.append(_);
751
- let w = t.parentElement;
752
- function T(e) {
753
- C.textContent = e ?? "";
688
+ b.className = "amos-js-plaid-linked-meta";
689
+ let x = document.createElement("button");
690
+ x.type = "button", x.className = "amos-js-plaid-disconnect", x.textContent = "Disconnect", x.setAttribute("aria-label", "Disconnect bank account");
691
+ let S = document.createElement("p");
692
+ S.className = "amos-js-plaid-error", S.setAttribute("role", "alert"), v.append(y, b, x), g.append(_, v, S), e.append(g);
693
+ let C = t.parentElement;
694
+ function w(e) {
695
+ S.textContent = e ?? "";
754
696
  }
755
- function E() {
756
- return a ? s ? !0 : pe({
757
- amount: me(r.amount),
758
- achThreshold: o
697
+ function T() {
698
+ return a ? l ? !0 : Y({
699
+ amount: ce(r.amount),
700
+ achThreshold: s
759
701
  }) : !1;
760
702
  }
761
- function D() {
762
- let e = !!g;
763
- u !== e && (u = e, r.onValidityChange?.({ isValid: e }));
703
+ function E() {
704
+ let e = !!h;
705
+ f !== e && (f = e, r.onValidityChange?.({ isValid: e }));
764
706
  }
765
- function O() {
766
- let e = E();
767
- if (p(t, {
707
+ function D() {
708
+ let e = T();
709
+ if (o(t, {
768
710
  requiresVerification: e,
769
- plaid: e ? g?.credentials : void 0,
770
- clearLinked: k
711
+ plaid: e ? h?.credentials : void 0,
712
+ clearLinked: O
771
713
  }), !e) {
772
- _.dataset.mode = "hidden", w && (w.style.display = ""), u = void 0;
714
+ g.dataset.mode = "hidden", C && (C.style.display = ""), f = void 0;
773
715
  return;
774
716
  }
775
- _.dataset.mode = g ? "linked" : "connect", w && (w.style.display = "none"), g && (b.textContent = g.bankName, x.textContent = g.last4 ? `****${g.last4}` : "Connected"), D();
717
+ g.dataset.mode = h ? "linked" : "connect", C && (C.style.display = "none"), h && (y.textContent = h.bankName, b.textContent = h.last4 ? `****${h.last4}` : "Connected"), E();
776
718
  }
777
- function k() {
778
- g = void 0, c = void 0, f?.(), f = void 0, T(void 0), O();
719
+ function O() {
720
+ h = void 0, u = void 0, p?.(), p = void 0, w(void 0), D();
779
721
  }
780
- function A(e) {
722
+ function k(e) {
781
723
  if (e.source === t.contentWindow && e.data.type === "ACH_THRESHOLD") {
782
- if (a = !0, o = e.data.achThreshold ?? void 0, s = e.data.requireVerification === !0, d({
783
- iframe: t,
784
- message: "merchant ach_threshold",
785
- endpoint: "ACH_THRESHOLD",
786
- headers: { origin: e.origin },
787
- body: {
788
- achThreshold: o,
789
- requireVerification: s
790
- }
791
- }), g && !E()) {
792
- k();
724
+ if (a = !0, s = e.data.achThreshold ?? void 0, l = e.data.requireVerification === !0, h && !T()) {
725
+ O();
793
726
  return;
794
727
  }
795
- O();
728
+ D();
796
729
  }
797
730
  }
798
- return window.addEventListener("message", A), O(), S.addEventListener("click", () => {
799
- k();
800
- }), v.addEventListener("click", () => {
731
+ return window.addEventListener("message", k), D(), x.addEventListener("click", () => {
732
+ O();
733
+ }), _.addEventListener("click", () => {
801
734
  (async () => {
802
- if (!(m.signal.aborted || l)) {
803
- l = !0, v.disabled = !0, T(void 0);
735
+ if (!(m.signal.aborted || d)) {
736
+ d = !0, _.disabled = !0, w(void 0);
804
737
  try {
805
- if (c ||= await ee({ iframe: t }), m.signal.aborted) return;
806
- let e = c;
807
- f?.(), f = await ye({
738
+ if (u ||= await ee({ iframe: t }), m.signal.aborted) return;
739
+ let e = u;
740
+ p?.(), p = await pe({
808
741
  token: e,
809
742
  signal: m.signal,
810
743
  onSuccess: (e, t) => {
811
744
  if (m.signal.aborted) return;
812
- let n = he(t);
745
+ let n = le(t);
813
746
  if (!n) {
814
- T("Select a bank account to continue.");
747
+ w("Select a bank account to continue.");
815
748
  return;
816
749
  }
817
- let r = ge(t);
818
- g = {
750
+ let r = ue(t);
751
+ h = {
819
752
  credentials: {
820
753
  public_token: e,
821
754
  account_id: n
822
755
  },
823
756
  bankName: r.bankName,
824
757
  last4: r.last4
825
- }, c = void 0, O();
758
+ }, u = void 0, D();
826
759
  },
827
760
  onExit: (e) => {
828
- m.signal.aborted || e?.error_code === "INVALID_LINK_TOKEN" && (c = void 0);
761
+ m.signal.aborted || e?.error_code === "INVALID_LINK_TOKEN" && (u = void 0);
829
762
  }
830
- }), m.signal.aborted && (f(), f = void 0);
763
+ }), m.signal.aborted && (p(), p = void 0);
831
764
  } catch (e) {
832
- if (c = void 0, m.signal.aborted) return;
833
- T(e instanceof Error ? e.message : "Could not connect bank.");
765
+ if (u = void 0, m.signal.aborted) return;
766
+ w(e instanceof Error ? e.message : "Could not connect bank.");
834
767
  } finally {
835
- l = !1, m.signal.aborted || (v.disabled = !1);
768
+ d = !1, m.signal.aborted || (_.disabled = !1);
836
769
  }
837
770
  }
838
771
  })();
839
772
  }), {
840
773
  update(e) {
841
- if ("amount" in e && (r.amount = e.amount ?? "0"), "onValidityChange" in e && (r.onValidityChange = e.onValidityChange), "appearance" in e && (r.appearance = e.appearance, Ce(_, r.appearance, i)), g && !E()) {
842
- k();
774
+ if ("amount" in e && (r.amount = e.amount ?? "0"), "onValidityChange" in e && (r.onValidityChange = e.onValidityChange), "appearance" in e && (r.appearance = e.appearance, _e(g, r.appearance, i)), h && !T()) {
775
+ O();
843
776
  return;
844
777
  }
845
- O();
778
+ D();
846
779
  },
847
780
  destroy() {
848
- m.abort(), window.removeEventListener("message", A), f?.(), f = void 0, h(t), _.remove();
781
+ m.abort(), window.removeEventListener("message", k), p?.(), p = void 0, c(t), g.remove();
849
782
  }
850
783
  };
851
784
  }
@@ -859,19 +792,19 @@ function Z(e) {
859
792
  }
860
793
  return e;
861
794
  }
862
- var Q = {
795
+ var ye = {
863
796
  width: "calc(100% + 8px)",
864
797
  transition: "opacity 150ms ease-in, height 200ms ease-in-out",
865
798
  margin: "0 -4px",
866
799
  opacity: "0",
867
800
  border: "0"
868
- }, Te = {
801
+ }, be = {
869
802
  width: "100%",
870
803
  transition: "height 200ms ease-in-out",
871
804
  margin: "0",
872
805
  opacity: "0",
873
806
  border: "0"
874
- }, Ee = {
807
+ }, xe = {
875
808
  position: "absolute",
876
809
  top: "0",
877
810
  left: "0",
@@ -881,7 +814,7 @@ var Q = {
881
814
  opacity: "0",
882
815
  transition: "none",
883
816
  pointerEvents: "none"
884
- }, De = {
817
+ }, Se = {
885
818
  position: "absolute",
886
819
  top: "0",
887
820
  left: "-4px",
@@ -891,15 +824,15 @@ var Q = {
891
824
  transition: "none",
892
825
  pointerEvents: "none"
893
826
  };
894
- function $({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = Q }) {
827
+ function Q({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = ye }) {
895
828
  let s = document.createElement("iframe");
896
829
  return s.src = e, s.title = t, s.name = n, s.setAttribute("role", "presentation"), s.scrolling = "no", i && (s.allow = i), a != null && (s.className = a), Object.assign(s.style, o, { height: r }), s;
897
830
  }
898
- function Oe({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
831
+ function Ce({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
899
832
  let i = document.createElement("div");
900
833
  i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
901
- let a = z(r);
902
- Object.assign(t.style, De), i.append(a.element, t), e.appendChild(i);
834
+ let a = ae(r);
835
+ Object.assign(t.style, Se), i.append(a.element, t), e.appendChild(i);
903
836
  let o = !1, s = !1, c, l = r.appearance, u, d;
904
837
  function f() {
905
838
  return i.getBoundingClientRect().height;
@@ -911,7 +844,7 @@ function Oe({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
911
844
  if (o) return;
912
845
  o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
913
846
  let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
914
- t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = Q.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
847
+ t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = ye.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
915
848
  t.style.transition = "height 200ms ease-in-out";
916
849
  }, 400);
917
850
  }
@@ -920,7 +853,7 @@ function Oe({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
920
853
  let e = p(), t = f();
921
854
  Number.isFinite(e) && e >= t - 2 && m();
922
855
  }
923
- let g = de(t, {
856
+ let g = q(t, {
924
857
  ...n,
925
858
  onHeightChange: (e) => {
926
859
  c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
@@ -944,15 +877,15 @@ function Oe({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
944
877
  }
945
878
  };
946
879
  }
947
- function ke({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
880
+ function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
948
881
  let a = {
949
882
  height: n.height ?? "48px",
950
- borderRadius: H({
883
+ borderRadius: L({
951
884
  iframeStyle: r,
952
885
  buttonProps: n.buttonProps
953
886
  })
954
- }, o = B(a), s = document.createElement("div");
955
- s.style.position = "relative", s.style.width = "100%", s.style.height = a.height, s.style.overflow = "hidden", s.setAttribute("aria-busy", "true"), Object.assign(t.style, Ee), t.style.height = "100%", s.append(o.element, t), e.appendChild(s);
887
+ }, o = F(a), s = document.createElement("div");
888
+ s.style.position = "relative", s.style.width = "100%", s.style.height = a.height, s.style.overflow = "hidden", s.setAttribute("aria-busy", "true"), Object.assign(t.style, xe), t.style.height = "100%", s.append(o.element, t), e.appendChild(s);
956
889
  let c = !1, l = !1, u, d = n;
957
890
  function f() {
958
891
  c || (c = !0, u !== void 0 && (clearTimeout(u), u = void 0), t.style.opacity = "1", t.style.pointerEvents = "", o.element.remove(), s.removeAttribute("aria-busy"));
@@ -981,7 +914,7 @@ function ke({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachList
981
914
  let t = { ...e };
982
915
  delete t.onAppearanceReady, delete t.onHeightChange, m.update(t), a = {
983
916
  height: d.height ?? a.height,
984
- borderRadius: H({
917
+ borderRadius: L({
985
918
  iframeStyle: r,
986
919
  buttonProps: d.buttonProps
987
920
  })
@@ -992,15 +925,15 @@ function ke({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachList
992
925
  }
993
926
  };
994
927
  }
995
- function Ae(e, t) {
928
+ function we(e, t) {
996
929
  let n = Z(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
997
- return Oe({
930
+ return Ce({
998
931
  host: n,
999
- iframe: $({
1000
- src: J(r, i, a),
932
+ iframe: Q({
933
+ src: U(r, i, a),
1001
934
  title: "Secure credit card payment method form powered by Amos",
1002
935
  name: "amos-credit-card-payment-method-form",
1003
- height: le(i, a)
936
+ height: G(i, a)
1004
937
  }),
1005
938
  listenerOptions: o,
1006
939
  skeletonOptions: {
@@ -1011,13 +944,13 @@ function Ae(e, t) {
1011
944
  }
1012
945
  });
1013
946
  }
1014
- function je(e, t) {
1015
- let n = Z(e), { renderToken: r, billingAddressRequirement: i = "country", amount: a = "0", intent: o = "payment", ...s } = t, c = $({
1016
- src: Y(r, i, o),
947
+ function Te(e, t) {
948
+ let n = Z(e), { renderToken: r, billingAddressRequirement: i = "country", amount: a = "0", intent: o = "payment", ...s } = t, c = Q({
949
+ src: W(r, i, o),
1017
950
  title: "Secure bank account payment method form powered by Amos",
1018
951
  name: "amos-bank-account-payment-method-form",
1019
- height: ue(i)
1020
- }), l = Oe({
952
+ height: K(i)
953
+ }), l = Ce({
1021
954
  host: n,
1022
955
  iframe: c,
1023
956
  listenerOptions: s,
@@ -1026,7 +959,7 @@ function je(e, t) {
1026
959
  appearance: s.appearance,
1027
960
  billingAddressRequirement: i
1028
961
  }
1029
- }), u = we({
962
+ }), u = ve({
1030
963
  host: n,
1031
964
  iframe: c,
1032
965
  options: {
@@ -1045,41 +978,41 @@ function je(e, t) {
1045
978
  }
1046
979
  };
1047
980
  }
1048
- function Me(e, t) {
1049
- let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = $({
1050
- src: U(r),
981
+ function Ee(e, t) {
982
+ let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Q({
983
+ src: R(r),
1051
984
  title: "Secure Google Pay button powered by Amos",
1052
985
  name: "amos-google-pay-button",
1053
- height: o.height ?? W(),
986
+ height: o.height ?? z(),
1054
987
  allow: "payment",
1055
988
  className: i,
1056
- style: Te
989
+ style: be
1057
990
  });
1058
- return Object.assign(s.style, a), ke({
991
+ return Object.assign(s.style, a), $({
1059
992
  host: n,
1060
993
  iframe: s,
1061
994
  listenerOptions: o,
1062
995
  iframeStyle: a,
1063
- attachListeners: G
996
+ attachListeners: B
1064
997
  });
1065
998
  }
1066
- function Ne(e, t) {
1067
- let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = $({
1068
- src: te(r),
999
+ function De(e, t) {
1000
+ let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Q({
1001
+ src: T(r),
1069
1002
  title: "Secure Apple Pay button powered by Amos",
1070
1003
  name: "amos-apple-pay-button",
1071
- height: o.height ?? j(),
1004
+ height: o.height ?? E(),
1072
1005
  allow: "payment",
1073
1006
  className: i,
1074
- style: Te
1007
+ style: be
1075
1008
  });
1076
- return Object.assign(s.style, a), ke({
1009
+ return Object.assign(s.style, a), $({
1077
1010
  host: n,
1078
1011
  iframe: s,
1079
1012
  listenerOptions: o,
1080
1013
  iframeStyle: a,
1081
- attachListeners: M
1014
+ attachListeners: O
1082
1015
  });
1083
1016
  }
1084
1017
  //#endregion
1085
- export { ie as SKELETON_STYLES, M as attachApplePayButtonListeners, G as attachGooglePayButtonListeners, de as attachPaymentMethodFormListeners, O as confirmPaymentIntent, k as confirmSetupIntent, o as createMessage, z as createPaymentMethodFormSkeleton, B as createWalletButtonSkeleton, r as decodeJwt, P as ensureSkeletonStyles, se as formatGooglePayPaymentData, j as getApplePayButtonInitialHeight, te as getApplePayButtonSrc, ue as getBankAccountFormInitialHeight, Y as getBankAccountFormSrc, le as getCreditCardFormInitialHeight, J as getCreditCardFormSrc, a as getEmbedOrigin, W as getGooglePayButtonInitialHeight, U as getGooglePayButtonSrc, ge as linkedBankLabelFromMetadata, ve as loadPlaidScript, Ne as mountAmosApplePayButton, je as mountAmosBankAccountPaymentMethodForm, Ae as mountAmosCreditCardPaymentMethodForm, Me as mountAmosGooglePayButton, ye as openPlaidLink, he as plaidAccountIdFromMetadata, pe as requiresAchVerification, T as resetForm, H as resolveWalletButtonSkeletonBorderRadius, A as sendConfirmationResult, _ as sendParentReadyMessage, x as updateAmount, v as updateAppearance, y as updateApplePayButton, b as updateGooglePayButton, S as updateMerchantName, C as validateForm };
1018
+ export { ne as SKELETON_STYLES, O as attachApplePayButtonListeners, B as attachGooglePayButtonListeners, q as attachPaymentMethodFormListeners, S as confirmPaymentIntent, C as confirmSetupIntent, l as createMessage, ae as createPaymentMethodFormSkeleton, F as createWalletButtonSkeleton, r as decodeJwt, A as ensureSkeletonStyles, oe as formatGooglePayPaymentData, E as getApplePayButtonInitialHeight, T as getApplePayButtonSrc, K as getBankAccountFormInitialHeight, W as getBankAccountFormSrc, G as getCreditCardFormInitialHeight, U as getCreditCardFormSrc, i as getEmbedOrigin, z as getGooglePayButtonInitialHeight, R as getGooglePayButtonSrc, ue as linkedBankLabelFromMetadata, fe as loadPlaidScript, De as mountAmosApplePayButton, Te as mountAmosBankAccountPaymentMethodForm, we as mountAmosCreditCardPaymentMethodForm, Ee as mountAmosGooglePayButton, pe as openPlaidLink, le as plaidAccountIdFromMetadata, Y as requiresAchVerification, y as resetForm, L as resolveWalletButtonSkeletonBorderRadius, w as sendConfirmationResult, d as sendParentReadyMessage, h as updateAmount, f as updateAppearance, p as updateApplePayButton, m as updateGooglePayButton, g as updateMerchantName, _ as validateForm };