@amos.com/amos-js 0.9.16 → 0.9.18

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
@@ -83,141 +83,197 @@ function i(e) {
83
83
  }
84
84
  }
85
85
  //#endregion
86
+ //#region src/plaid-session.ts
87
+ var a = /* @__PURE__ */ new WeakMap();
88
+ function o(e, t) {
89
+ a.set(e, t);
90
+ }
91
+ function s(e) {
92
+ if (e) return a.get(e);
93
+ }
94
+ function c(e) {
95
+ e && a.delete(e);
96
+ }
97
+ //#endregion
86
98
  //#region src/types.ts
87
- function a(e) {
99
+ function l(e) {
88
100
  return e;
89
101
  }
90
102
  //#endregion
91
103
  //#region src/messaging.ts
92
- function o(e) {
104
+ function u(e) {
93
105
  return new URL(e.src).origin;
94
106
  }
95
- function s(e) {
96
- e?.contentWindow && e.contentWindow.postMessage(a({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), o(e));
107
+ function d(e) {
108
+ e?.contentWindow && e.contentWindow.postMessage(l({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), u(e));
97
109
  }
98
- function c({ iframe: e, appearance: t = {} }) {
99
- e?.contentWindow && e.contentWindow.postMessage(a({
110
+ function f({ iframe: e, appearance: t = {} }) {
111
+ e?.contentWindow && e.contentWindow.postMessage(l({
100
112
  type: "UPDATE_APPEARANCE",
101
113
  appearance: t
102
- }), o(e));
114
+ }), u(e));
103
115
  }
104
- function l({ iframe: e, props: t, height: n }) {
105
- e?.contentWindow && e.contentWindow.postMessage(a({
116
+ function p({ iframe: e, props: t, height: n }) {
117
+ e?.contentWindow && e.contentWindow.postMessage(l({
106
118
  type: "UPDATE_APPLE_PAY_BUTTON",
107
119
  height: n,
108
120
  props: t
109
- }), o(e));
121
+ }), u(e));
110
122
  }
111
- function u({ iframe: e, props: t, height: n }) {
112
- e?.contentWindow && e.contentWindow.postMessage(a({
123
+ function m({ iframe: e, props: t, height: n }) {
124
+ e?.contentWindow && e.contentWindow.postMessage(l({
113
125
  type: "UPDATE_GOOGLE_PAY_BUTTON",
114
126
  height: n,
115
127
  props: t
116
- }), o(e));
128
+ }), u(e));
117
129
  }
118
- function d({ iframe: e, amount: t }) {
119
- e?.contentWindow && e.contentWindow.postMessage(a({
130
+ function h({ iframe: e, amount: t }) {
131
+ e?.contentWindow && e.contentWindow.postMessage(l({
120
132
  type: "UPDATE_AMOUNT",
121
133
  amount: t
122
- }), o(e));
134
+ }), u(e));
123
135
  }
124
- function f({ iframe: e, merchantName: t }) {
125
- e?.contentWindow && e.contentWindow.postMessage(a({
136
+ function g({ iframe: e, merchantName: t }) {
137
+ e?.contentWindow && e.contentWindow.postMessage(l({
126
138
  type: "UPDATE_MERCHANT_NAME",
127
139
  merchantName: t
128
- }), o(e));
129
- }
130
- function p({ iframe: e }) {
131
- let t = crypto.randomUUID();
132
- return new Promise((n) => {
133
- e?.contentWindow && e.contentWindow.postMessage(a({
140
+ }), u(e));
141
+ }
142
+ function _({ iframe: e }) {
143
+ let t = s(e);
144
+ if (t?.requiresVerification) return Promise.resolve(!!t.plaid);
145
+ let n = crypto.randomUUID();
146
+ return new Promise((t) => {
147
+ e?.contentWindow && e.contentWindow.postMessage(l({
134
148
  type: "VALIDATE_FORM",
135
- requestId: t
136
- }), o(e));
149
+ requestId: n
150
+ }), u(e));
137
151
  let r = setTimeout(() => {
138
- window.removeEventListener("message", i), n(!1);
152
+ window.removeEventListener("message", i), t(!1);
139
153
  }, 5e3);
140
154
  function i(e) {
141
- e.data.type === "VALIDATE_FORM" && e.data.requestId === t && (window.removeEventListener("message", i), clearTimeout(r), n(e.data.isValid ?? !1));
155
+ e.data.type === "VALIDATE_FORM" && e.data.requestId === n && (window.removeEventListener("message", i), clearTimeout(r), t(e.data.isValid ?? !1));
142
156
  }
143
157
  window.addEventListener("message", i);
144
158
  });
145
159
  }
146
- function m({ iframe: e }) {
147
- e?.contentWindow && e.contentWindow.postMessage(a({ type: "RESET_FORM" }), o(e));
160
+ var v = 1e4;
161
+ function ee({ iframe: e }) {
162
+ let t = crypto.randomUUID();
163
+ return new Promise((n, r) => {
164
+ if (!e?.contentWindow) {
165
+ r(/* @__PURE__ */ Error("Bank form is not ready."));
166
+ return;
167
+ }
168
+ let i = e.contentWindow;
169
+ i.postMessage(l({
170
+ type: "CREATE_PLAID_LINK_TOKEN",
171
+ requestId: t
172
+ }), u(e));
173
+ let a = setTimeout(() => {
174
+ window.removeEventListener("message", o), r(/* @__PURE__ */ Error("Timed out waiting for Plaid Link token."));
175
+ }, v);
176
+ function o(e) {
177
+ if (e.source === i && e.data.type === "PLAID_LINK_TOKEN" && e.data.requestId === t) {
178
+ if (window.removeEventListener("message", o), clearTimeout(a), e.data.link_token) {
179
+ n(e.data.link_token);
180
+ return;
181
+ }
182
+ r(Error(e.data.error ?? "Could not create Plaid Link token."));
183
+ }
184
+ }
185
+ window.addEventListener("message", o);
186
+ });
187
+ }
188
+ function y({ iframe: e }) {
189
+ s(e)?.clearLinked?.(), b(e);
148
190
  }
149
- function h({ iframe: e, token: t }) {
191
+ function b(e) {
192
+ e?.contentWindow && e.contentWindow.postMessage(l({ type: "RESET_FORM" }), u(e));
193
+ }
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({
197
+ type: t,
198
+ token: n,
199
+ id: r,
200
+ ...a ? { plaid: a } : {}
201
+ }), u(e));
202
+ }
203
+ function S({ iframe: e, token: t }) {
150
204
  if (!e?.contentWindow) return;
151
205
  let { payment_intent_id: n } = r(t).payload;
152
- e.contentWindow.postMessage(a({
206
+ x({
207
+ iframe: e,
153
208
  type: "CONFIRM_PAYMENT_INTENT",
154
209
  token: t,
155
210
  id: n ?? void 0
156
- }), o(e));
211
+ });
157
212
  }
158
- function g({ iframe: e, token: t }) {
213
+ function C({ iframe: e, token: t }) {
159
214
  if (!e?.contentWindow) return;
160
215
  let { setup_intent_id: n } = r(t).payload;
161
- e.contentWindow.postMessage(a({
216
+ x({
217
+ iframe: e,
162
218
  type: "CONFIRM_SETUP_INTENT",
163
219
  token: t,
164
220
  id: n ?? void 0
165
- }), o(e));
221
+ });
166
222
  }
167
- function _({ iframe: e, result: t }) {
168
- e?.contentWindow && e.contentWindow.postMessage(a({
223
+ function w({ iframe: e, result: t }) {
224
+ e?.contentWindow && e.contentWindow.postMessage(l({
169
225
  type: "CONFIRMATION_RESULT",
170
226
  result: t
171
- }), o(e));
227
+ }), u(e));
172
228
  }
173
229
  //#endregion
174
230
  //#region src/apple-pay.ts
175
- function v(e) {
231
+ function T(e) {
176
232
  return `${i(e)}/iframe/apple-pay?token=${e}`;
177
233
  }
178
- function y() {
234
+ function E() {
179
235
  return "48px";
180
236
  }
181
- function b(e) {
182
- e.contentWindow?.postMessage(a({ type: "APPLE_PAY_CANCEL" }), o(e));
237
+ function D(e) {
238
+ e.contentWindow?.postMessage(l({ type: "APPLE_PAY_CANCEL" }), u(e));
183
239
  }
184
- function x(e, { height: r = "48px", ...i }) {
240
+ function O(e, { height: r = "48px", ...i }) {
185
241
  let a = {
186
242
  ...i,
187
243
  height: r
188
244
  };
189
245
  function o() {
190
- d({
246
+ h({
191
247
  iframe: e,
192
248
  amount: a.amount
193
249
  });
194
250
  }
195
- function u() {
196
- f({
251
+ function s() {
252
+ g({
197
253
  iframe: e,
198
254
  merchantName: a.merchantName
199
255
  });
200
256
  }
201
- function p() {
202
- l({
257
+ function c() {
258
+ p({
203
259
  iframe: e,
204
260
  height: a.height ?? "48px",
205
261
  props: a.buttonProps ?? {}
206
262
  });
207
263
  }
208
- function m(r) {
264
+ function l(r) {
209
265
  if (r.source === e.contentWindow) switch (r.data.type) {
210
266
  case "IFRAME_READY":
211
- s(e), c({
267
+ d(e), f({
212
268
  iframe: e,
213
269
  appearance: {}
214
- }), o(), u(), p();
270
+ }), o(), s(), c();
215
271
  break;
216
272
  case "UPDATE_HEIGHT":
217
273
  a.onHeightChange?.(r.data.height);
218
274
  break;
219
275
  case "UPDATE_APPEARANCE":
220
- c({
276
+ f({
221
277
  iframe: e,
222
278
  appearance: r.data.appearance
223
279
  });
@@ -227,7 +283,7 @@ function x(e, { height: r = "48px", ...i }) {
227
283
  break;
228
284
  case "APPLE_PAY_WINDOW_OPEN":
229
285
  t({ onCancel: () => {
230
- b(e), n();
286
+ D(e), n();
231
287
  } });
232
288
  break;
233
289
  case "APPLE_PAY_WINDOW_CLOSE":
@@ -238,7 +294,7 @@ function x(e, { height: r = "48px", ...i }) {
238
294
  paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
239
295
  customerCreateAttributes: r.data.customerCreateAttributes
240
296
  }).then((t) => {
241
- h({
297
+ S({
242
298
  iframe: e,
243
299
  token: t
244
300
  });
@@ -252,55 +308,155 @@ function x(e, { height: r = "48px", ...i }) {
252
308
  case "CONFIRMATION_RESULT": n(), a.onResult(r.data.result);
253
309
  }
254
310
  }
255
- return window.addEventListener("message", m), {
311
+ return window.addEventListener("message", l), {
256
312
  update(e) {
257
313
  let t = "amount" in e, n = "merchantName" in e, r = "height" in e || "buttonProps" in e;
258
314
  a = {
259
315
  ...a,
260
316
  ...e
261
- }, t && o(), n && u(), r && p();
317
+ }, t && o(), n && s(), r && c();
262
318
  },
263
319
  destroy() {
264
- window.removeEventListener("message", m), n();
320
+ window.removeEventListener("message", l), n();
265
321
  }
266
322
  };
267
323
  }
268
324
  //#endregion
325
+ //#region src/form-skeleton.ts
326
+ var k = "amos-js-form-skeleton-styles", te = {
327
+ "--accent": "oklch(0.97 0 0)",
328
+ "--radius": "0.625rem",
329
+ "--input-height": "2.25rem",
330
+ "--floating-input-height": "3.25rem",
331
+ "--field-gap": "1rem",
332
+ "--control-gap": "0.5rem",
333
+ "--label-font-size": "0.875rem"
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;
337
+ let e = document.createElement("style");
338
+ e.id = k, e.textContent = ne, document.head.appendChild(e);
339
+ }
340
+ function j(e, t) {
341
+ for (let [t, n] of Object.entries(te)) e.style.setProperty(t, n);
342
+ let n = t?.themeVariables;
343
+ if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
344
+ }
345
+ function M(e, t) {
346
+ let n = document.createElement("div");
347
+ if (n.className = e, t) for (let e of t) n.appendChild(e);
348
+ return n;
349
+ }
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");
354
+ return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
355
+ }
356
+ function P(e, t) {
357
+ return M(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
358
+ }
359
+ function re({ labels: e, requirement: t, wrapCountryZip: n }) {
360
+ return t === "full" ? [
361
+ N(e),
362
+ N(e),
363
+ P([
364
+ N(e, 1.4),
365
+ N(e, .7),
366
+ N(e, .8)
367
+ ], !1),
368
+ N(e)
369
+ ] : [P([N(e), N(e)], n)];
370
+ }
371
+ function ie(e) {
372
+ let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
373
+ if (e.kind === "card") {
374
+ let r = [N(t), P([N(t), N(t)], !1)];
375
+ return e.additionalFields?.cardholderName && r.push(N(t)), r.push(...re({
376
+ labels: t,
377
+ requirement: n,
378
+ wrapCountryZip: !1
379
+ })), r;
380
+ }
381
+ return [
382
+ N(t),
383
+ P([N(t), N(t)], !0),
384
+ N(t),
385
+ P([N("above"), N("above")], !0),
386
+ ...re({
387
+ labels: t,
388
+ requirement: n,
389
+ wrapCountryZip: !0
390
+ })
391
+ ];
392
+ }
393
+ function ae(e) {
394
+ A();
395
+ let t = M("amos-js-form-skeleton");
396
+ t.setAttribute("aria-hidden", "true");
397
+ function n(e) {
398
+ j(t, e.appearance), t.replaceChildren(...ie(e));
399
+ }
400
+ return n(e), {
401
+ element: t,
402
+ update: n
403
+ };
404
+ }
405
+ function F(e) {
406
+ A();
407
+ let t = M("amos-js-form-skeleton-input amos-js-wallet-skeleton");
408
+ t.setAttribute("aria-hidden", "true");
409
+ function n(e) {
410
+ j(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
411
+ }
412
+ return n(e), {
413
+ element: t,
414
+ update: n
415
+ };
416
+ }
417
+ function I(e) {
418
+ if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
419
+ if (typeof e == "string" && e.trim() !== "") return e.trim();
420
+ }
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";
423
+ }
424
+ //#endregion
269
425
  //#region src/google-pay.ts
270
- function S(e) {
426
+ function R(e) {
271
427
  return `${i(e)}/iframe/google-pay?token=${e}`;
272
428
  }
273
- function C() {
429
+ function z() {
274
430
  return "48px";
275
431
  }
276
- function w(e, { height: t = "48px", ...n }) {
432
+ function B(e, { height: t = "48px", ...n }) {
277
433
  let r = {
278
434
  ...n,
279
435
  height: t
280
436
  };
281
437
  function i() {
282
- d({
438
+ h({
283
439
  iframe: e,
284
440
  amount: r.amount
285
441
  });
286
442
  }
287
443
  function a() {
288
- f({
444
+ g({
289
445
  iframe: e,
290
446
  merchantName: r.merchantName
291
447
  });
292
448
  }
293
449
  function o() {
294
- u({
450
+ m({
295
451
  iframe: e,
296
452
  height: r.height ?? "48px",
297
453
  props: r.buttonProps ?? {}
298
454
  });
299
455
  }
300
- function l(t) {
456
+ function s(t) {
301
457
  if (t.source === e.contentWindow) switch (t.data.type) {
302
458
  case "IFRAME_READY":
303
- s(e), c({
459
+ d(e), f({
304
460
  iframe: e,
305
461
  appearance: {}
306
462
  }), i(), a(), o();
@@ -309,7 +465,7 @@ function w(e, { height: t = "48px", ...n }) {
309
465
  r.onHeightChange?.(t.data.height);
310
466
  break;
311
467
  case "UPDATE_APPEARANCE":
312
- c({
468
+ f({
313
469
  iframe: e,
314
470
  appearance: t.data.appearance
315
471
  });
@@ -322,7 +478,7 @@ function w(e, { height: t = "48px", ...n }) {
322
478
  paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
323
479
  customerCreateAttributes: t.data.customerCreateAttributes
324
480
  }).then((t) => {
325
- h({
481
+ S({
326
482
  iframe: e,
327
483
  token: t
328
484
  });
@@ -336,7 +492,7 @@ function w(e, { height: t = "48px", ...n }) {
336
492
  case "CONFIRMATION_RESULT": r.onResult(t.data.result);
337
493
  }
338
494
  }
339
- return window.addEventListener("message", l), {
495
+ return window.addEventListener("message", s), {
340
496
  update(e) {
341
497
  let t = "amount" in e, n = "merchantName" in e, s = "height" in e || "buttonProps" in e;
342
498
  r = {
@@ -345,11 +501,11 @@ function w(e, { height: t = "48px", ...n }) {
345
501
  }, t && i(), n && a(), s && o();
346
502
  },
347
503
  destroy() {
348
- window.removeEventListener("message", l);
504
+ window.removeEventListener("message", s);
349
505
  }
350
506
  };
351
507
  }
352
- function T({ paymentData: e }) {
508
+ function oe({ paymentData: e }) {
353
509
  return { paymentMethod: {
354
510
  type: "googlepay",
355
511
  billing_address_attributes: {
@@ -367,96 +523,15 @@ function T({ paymentData: e }) {
367
523
  } };
368
524
  }
369
525
  //#endregion
370
- //#region src/form-skeleton.ts
371
- var E = "amos-js-form-skeleton-styles", D = {
372
- "--accent": "oklch(0.97 0 0)",
373
- "--radius": "0.625rem",
374
- "--input-height": "2.25rem",
375
- "--floating-input-height": "3.25rem",
376
- "--field-gap": "1rem",
377
- "--control-gap": "0.5rem",
378
- "--label-font-size": "0.875rem"
379
- }, O = "\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@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";
380
- function k() {
381
- if (document.getElementById(E)) return;
382
- let e = document.createElement("style");
383
- e.id = E, e.textContent = O, document.head.appendChild(e);
384
- }
385
- function A(e, t) {
386
- for (let [t, n] of Object.entries(D)) e.style.setProperty(t, n);
387
- let n = t?.themeVariables;
388
- if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
389
- }
390
- function j(e, t) {
391
- let n = document.createElement("div");
392
- if (n.className = e, t) for (let e of t) n.appendChild(e);
393
- return n;
394
- }
395
- function M(e, t) {
396
- let n = j("amos-js-form-skeleton-field");
397
- t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(j("amos-js-form-skeleton-label"));
398
- let r = j("amos-js-form-skeleton-input");
399
- return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
400
- }
401
- function N(e, t) {
402
- return j(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
403
- }
404
- function P({ labels: e, requirement: t, wrapCountryZip: n }) {
405
- return t === "full" ? [
406
- M(e),
407
- M(e),
408
- N([
409
- M(e, 1.4),
410
- M(e, .7),
411
- M(e, .8)
412
- ], !1),
413
- M(e)
414
- ] : [N([M(e), M(e)], n)];
415
- }
416
- function F(e) {
417
- let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
418
- if (e.kind === "card") {
419
- let r = [M(t), N([M(t), M(t)], !1)];
420
- return e.additionalFields?.cardholderName && r.push(M(t)), r.push(...P({
421
- labels: t,
422
- requirement: n,
423
- wrapCountryZip: !1
424
- })), r;
425
- }
426
- return [
427
- M(t),
428
- N([M(t), M(t)], !0),
429
- M(t),
430
- N([M("above"), M("above")], !0),
431
- ...P({
432
- labels: t,
433
- requirement: n,
434
- wrapCountryZip: !0
435
- })
436
- ];
437
- }
438
- function I(e) {
439
- k();
440
- let t = j("amos-js-form-skeleton");
441
- t.setAttribute("aria-hidden", "true");
442
- function n(e) {
443
- A(t, e.appearance), t.replaceChildren(...F(e));
444
- }
445
- return n(e), {
446
- element: t,
447
- update: n
448
- };
449
- }
450
- //#endregion
451
526
  //#region src/payment-method-form.ts
452
- var L = {
527
+ var V = {
453
528
  country: 212,
454
529
  full: 452
455
- }, R = 80, z = {
530
+ }, se = 80, H = {
456
531
  country: 400,
457
532
  full: 640
458
533
  };
459
- function B(e, t = { cardholderName: !1 }, n = "country") {
534
+ function U(e, t = { cardholderName: !1 }, n = "country") {
460
535
  let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
461
536
  token: e,
462
537
  additionalFields: r,
@@ -464,25 +539,25 @@ function B(e, t = { cardholderName: !1 }, n = "country") {
464
539
  });
465
540
  return `${i(e)}/iframe/card?${a}`;
466
541
  }
467
- function V(e, t = "country") {
542
+ function W(e, t = "country") {
468
543
  let n = new URLSearchParams({
469
544
  token: e,
470
545
  billingAddressRequirement: t
471
546
  });
472
547
  return `${i(e)}/iframe/bank?${n}`;
473
548
  }
474
- function H(e = { cardholderName: !1 }, t = "country") {
475
- return `${(L[t] ?? L.country) + (e.cardholderName ? R : 0)}px`;
549
+ function G(e = { cardholderName: !1 }, t = "country") {
550
+ return `${(V[t] ?? V.country) + (e.cardholderName ? se : 0)}px`;
476
551
  }
477
- function U(e = "country") {
478
- return `${z[e] ?? z.country}px`;
552
+ function K(e = "country") {
553
+ return `${H[e] ?? H.country}px`;
479
554
  }
480
- function W(e, t) {
555
+ function q(e, t) {
481
556
  let n = { ...t };
482
557
  function r(t) {
483
558
  if (t.source === e.contentWindow) switch (t.data.type) {
484
559
  case "IFRAME_READY":
485
- s(e), c({
560
+ d(e), f({
486
561
  iframe: e,
487
562
  appearance: n.appearance
488
563
  });
@@ -491,7 +566,7 @@ function W(e, t) {
491
566
  n.onHeightChange?.(t.data.height);
492
567
  break;
493
568
  case "UPDATE_APPEARANCE":
494
- c({
569
+ f({
495
570
  iframe: e,
496
571
  appearance: t.data.appearance
497
572
  });
@@ -500,6 +575,7 @@ function W(e, t) {
500
575
  n.onAppearanceReady?.();
501
576
  break;
502
577
  case "FORM_VALIDITY_CHANGE":
578
+ if (s(e)?.requiresVerification) break;
503
579
  n.onValidityChange?.({ isValid: t.data.isValid });
504
580
  break;
505
581
  case "CONFIRMATION_RESULT": n.onResult(t.data.result);
@@ -511,7 +587,7 @@ function W(e, t) {
511
587
  n = {
512
588
  ...n,
513
589
  ...t
514
- }, r && c({
590
+ }, r && f({
515
591
  iframe: e,
516
592
  appearance: n.appearance
517
593
  });
@@ -522,8 +598,187 @@ function W(e, t) {
522
598
  };
523
599
  }
524
600
  //#endregion
601
+ //#region src/plaid.ts
602
+ var J = "https://cdn.plaid.com/link/v2/stable/link-initialize.js";
603
+ function Y({ amount: e, achThreshold: t }) {
604
+ return t == null ? !1 : e == null || e >= t;
605
+ }
606
+ function ce(e) {
607
+ if (e == null) return;
608
+ let t = e.trim();
609
+ if (t === "") return;
610
+ let n = Number(t.replace(/[^\d.]/g, ""));
611
+ if (Number.isFinite(n)) return Math.round(n * 100);
612
+ }
613
+ function le(e) {
614
+ return e.account_id ?? e.account?.id ?? e.accounts?.[0]?.id;
615
+ }
616
+ function ue(e) {
617
+ let t = e.account ?? e.accounts?.[0];
618
+ return {
619
+ bankName: e.institution?.name ?? "Bank account",
620
+ last4: t?.mask ?? ""
621
+ };
622
+ }
623
+ var X;
624
+ function de() {
625
+ for (let e of document.querySelectorAll(`script[src="${J}"]`)) e.remove();
626
+ }
627
+ function fe() {
628
+ return typeof window > "u" ? Promise.reject(/* @__PURE__ */ Error("Plaid Link requires a browser")) : window.Plaid ? Promise.resolve() : X || (de(), X = new Promise((e, t) => {
629
+ let n = document.createElement("script");
630
+ n.src = J, n.async = !0;
631
+ let r = (e) => {
632
+ n.remove(), X = void 0, t(Error(e));
633
+ };
634
+ n.addEventListener("load", () => {
635
+ if (window.Plaid) {
636
+ e();
637
+ return;
638
+ }
639
+ r("Plaid Link failed to initialize");
640
+ }, { once: !0 }), n.addEventListener("error", () => r("Failed to load Plaid Link"), { once: !0 }), document.head.append(n);
641
+ }), X);
642
+ }
643
+ async function pe({ token: e, onSuccess: t, onExit: n, signal: r }) {
644
+ if (await fe(), r?.aborted) return () => {};
645
+ if (!window.Plaid) throw Error("Plaid Link failed to initialize");
646
+ let i = window.Plaid.create({
647
+ token: e,
648
+ onSuccess: t,
649
+ onExit: (e) => {
650
+ n?.(e);
651
+ }
652
+ });
653
+ return r?.aborted ? (i.destroy(), () => {}) : (i.open(), () => {
654
+ i.destroy();
655
+ });
656
+ }
657
+ //#endregion
658
+ //#region src/plaid-bank-ui.ts
659
+ 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";
660
+ function ge() {
661
+ if (document.getElementById(me)) return;
662
+ let e = document.createElement("style");
663
+ e.id = me, e.textContent = he, document.head.append(e);
664
+ }
665
+ function _e(e, t, n) {
666
+ for (let t of n) e.style.removeProperty(t);
667
+ n.length = 0;
668
+ let r = t?.themeVariables;
669
+ if (r) for (let [t, i] of Object.entries(r)) typeof i == "string" && i.trim() !== "" && (e.style.setProperty(t, i.trim()), n.push(t));
670
+ }
671
+ function ve({ host: e, iframe: t, options: n }) {
672
+ ge();
673
+ let r = { ...n }, i = [], a = !1, s, l = !1, u, d = !1, f, p, m = new AbortController(), h, g = document.createElement("div");
674
+ g.className = "amos-js-plaid-panel", g.setAttribute("data-amos-plaid-panel", "true"), g.dataset.mode = "hidden", _e(g, r.appearance, i);
675
+ let _ = document.createElement("button");
676
+ _.type = "button", _.className = "amos-js-plaid-connect", _.textContent = "Connect bank account", _.setAttribute("data-testid", "amos-plaid-connect");
677
+ let v = document.createElement("div");
678
+ v.className = "amos-js-plaid-linked";
679
+ let y = document.createElement("span");
680
+ y.className = "amos-js-plaid-linked-name";
681
+ let b = document.createElement("span");
682
+ b.className = "amos-js-plaid-linked-meta";
683
+ let x = document.createElement("button");
684
+ x.type = "button", x.className = "amos-js-plaid-disconnect", x.textContent = "Disconnect", x.setAttribute("aria-label", "Disconnect bank account");
685
+ let S = document.createElement("p");
686
+ S.className = "amos-js-plaid-error", S.setAttribute("role", "alert"), v.append(y, b, x), g.append(_, v, S), e.append(g);
687
+ let C = t.parentElement;
688
+ function w(e) {
689
+ S.textContent = e ?? "";
690
+ }
691
+ function T() {
692
+ return a ? l ? !0 : Y({
693
+ amount: ce(r.amount),
694
+ achThreshold: s
695
+ }) : !1;
696
+ }
697
+ function E() {
698
+ let e = !!h;
699
+ f !== e && (f = e, r.onValidityChange?.({ isValid: e }));
700
+ }
701
+ function D() {
702
+ let e = T();
703
+ if (o(t, {
704
+ requiresVerification: e,
705
+ plaid: e ? h?.credentials : void 0,
706
+ clearLinked: O
707
+ }), !e) {
708
+ g.dataset.mode = "hidden", C && (C.style.display = ""), f = void 0;
709
+ return;
710
+ }
711
+ g.dataset.mode = h ? "linked" : "connect", C && (C.style.display = "none"), h && (y.textContent = h.bankName, b.textContent = h.last4 ? `****${h.last4}` : "Connected"), E();
712
+ }
713
+ function O() {
714
+ h = void 0, u = void 0, p?.(), p = void 0, w(void 0), D();
715
+ }
716
+ function k(e) {
717
+ if (e.source === t.contentWindow && e.data.type === "ACH_THRESHOLD") {
718
+ if (a = !0, s = e.data.achThreshold ?? void 0, l = e.data.requireVerification === !0, h && !T()) {
719
+ O();
720
+ return;
721
+ }
722
+ D();
723
+ }
724
+ }
725
+ return window.addEventListener("message", k), D(), x.addEventListener("click", () => {
726
+ O();
727
+ }), _.addEventListener("click", () => {
728
+ (async () => {
729
+ if (!(m.signal.aborted || d)) {
730
+ d = !0, _.disabled = !0, w(void 0);
731
+ try {
732
+ if (u ||= await ee({ iframe: t }), m.signal.aborted) return;
733
+ let e = u;
734
+ p?.(), p = await pe({
735
+ token: e,
736
+ signal: m.signal,
737
+ onSuccess: (e, t) => {
738
+ if (m.signal.aborted) return;
739
+ let n = le(t);
740
+ if (!n) {
741
+ w("Select a bank account to continue.");
742
+ return;
743
+ }
744
+ let r = ue(t);
745
+ h = {
746
+ credentials: {
747
+ public_token: e,
748
+ account_id: n
749
+ },
750
+ bankName: r.bankName,
751
+ last4: r.last4
752
+ }, u = void 0, D();
753
+ },
754
+ onExit: (e) => {
755
+ m.signal.aborted || e?.error_code === "INVALID_LINK_TOKEN" && (u = void 0);
756
+ }
757
+ }), m.signal.aborted && (p(), p = void 0);
758
+ } catch (e) {
759
+ if (u = void 0, m.signal.aborted) return;
760
+ w(e instanceof Error ? e.message : "Could not connect bank.");
761
+ } finally {
762
+ d = !1, m.signal.aborted || (_.disabled = !1);
763
+ }
764
+ }
765
+ })();
766
+ }), {
767
+ update(e) {
768
+ if ("amount" in e && (r.amount = e.amount), "onValidityChange" in e && (r.onValidityChange = e.onValidityChange), "appearance" in e && (r.appearance = e.appearance, _e(g, r.appearance, i)), h && !T()) {
769
+ O();
770
+ return;
771
+ }
772
+ D();
773
+ },
774
+ destroy() {
775
+ m.abort(), window.removeEventListener("message", k), p?.(), p = void 0, c(t), g.remove();
776
+ }
777
+ };
778
+ }
779
+ //#endregion
525
780
  //#region src/mount.ts
526
- function G(e) {
781
+ function Z(e) {
527
782
  if (typeof e == "string") {
528
783
  let t = document.querySelector(e);
529
784
  if (!(t instanceof HTMLElement)) throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);
@@ -531,19 +786,29 @@ function G(e) {
531
786
  }
532
787
  return e;
533
788
  }
534
- var K = {
789
+ var ye = {
535
790
  width: "calc(100% + 8px)",
536
791
  transition: "opacity 150ms ease-in, height 200ms ease-in-out",
537
792
  margin: "0 -4px",
538
793
  opacity: "0",
539
794
  border: "0"
540
- }, q = {
795
+ }, be = {
541
796
  width: "100%",
542
797
  transition: "height 200ms ease-in-out",
543
798
  margin: "0",
544
799
  opacity: "0",
545
800
  border: "0"
546
- }, J = {
801
+ }, xe = {
802
+ position: "absolute",
803
+ top: "0",
804
+ left: "0",
805
+ width: "100%",
806
+ height: "100%",
807
+ margin: "0",
808
+ opacity: "0",
809
+ transition: "none",
810
+ pointerEvents: "none"
811
+ }, Se = {
547
812
  position: "absolute",
548
813
  top: "0",
549
814
  left: "-4px",
@@ -553,15 +818,15 @@ var K = {
553
818
  transition: "none",
554
819
  pointerEvents: "none"
555
820
  };
556
- function Y({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = K }) {
821
+ function Q({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = ye }) {
557
822
  let s = document.createElement("iframe");
558
823
  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;
559
824
  }
560
- function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
825
+ function Ce({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
561
826
  let i = document.createElement("div");
562
827
  i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
563
- let a = I(r);
564
- Object.assign(t.style, J), i.append(a.element, t), e.appendChild(i);
828
+ let a = ae(r);
829
+ Object.assign(t.style, Se), i.append(a.element, t), e.appendChild(i);
565
830
  let o = !1, s = !1, c, l = r.appearance, u, d;
566
831
  function f() {
567
832
  return i.getBoundingClientRect().height;
@@ -573,7 +838,7 @@ function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
573
838
  if (o) return;
574
839
  o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
575
840
  let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
576
- t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = K.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
841
+ 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(() => {
577
842
  t.style.transition = "height 200ms ease-in-out";
578
843
  }, 400);
579
844
  }
@@ -582,7 +847,7 @@ function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
582
847
  let e = p(), t = f();
583
848
  Number.isFinite(e) && e >= t - 2 && m();
584
849
  }
585
- let g = W(t, {
850
+ let g = q(t, {
586
851
  ...n,
587
852
  onHeightChange: (e) => {
588
853
  c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
@@ -606,15 +871,63 @@ function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
606
871
  }
607
872
  };
608
873
  }
609
- function Z(e, t) {
610
- let n = G(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
611
- return X({
874
+ function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
875
+ let a = {
876
+ height: n.height ?? "48px",
877
+ borderRadius: L({
878
+ iframeStyle: r,
879
+ buttonProps: n.buttonProps
880
+ })
881
+ }, o = F(a), s = document.createElement("div");
882
+ 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);
883
+ let c = !1, l = !1, u, d = n;
884
+ function f() {
885
+ 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"));
886
+ }
887
+ function p() {
888
+ c || !l || f();
889
+ }
890
+ let m = i(t, {
891
+ ...n,
892
+ onHeightChange: (e) => {
893
+ d.onHeightChange?.(e);
894
+ },
895
+ onAppearanceReady: () => {
896
+ l = !0, p(), d.onAppearanceReady?.();
897
+ }
898
+ });
899
+ return u = setTimeout(() => {
900
+ f();
901
+ }, 1500), {
902
+ iframe: t,
903
+ update(e) {
904
+ d = {
905
+ ...d,
906
+ ...e
907
+ };
908
+ let t = { ...e };
909
+ delete t.onAppearanceReady, delete t.onHeightChange, m.update(t), a = {
910
+ height: d.height ?? a.height,
911
+ borderRadius: L({
912
+ iframeStyle: r,
913
+ buttonProps: d.buttonProps
914
+ })
915
+ }, s.style.height = a.height, c || o.update(a);
916
+ },
917
+ destroy() {
918
+ u !== void 0 && clearTimeout(u), m.destroy(), s.remove();
919
+ }
920
+ };
921
+ }
922
+ function we(e, t) {
923
+ let n = Z(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
924
+ return Ce({
612
925
  host: n,
613
- iframe: Y({
614
- src: B(r, i, a),
926
+ iframe: Q({
927
+ src: U(r, i, a),
615
928
  title: "Secure credit card payment method form powered by Amos",
616
929
  name: "amos-credit-card-payment-method-form",
617
- height: H(i, a)
930
+ height: G(i, a)
618
931
  }),
619
932
  listenerOptions: o,
620
933
  skeletonOptions: {
@@ -625,79 +938,75 @@ function Z(e, t) {
625
938
  }
626
939
  });
627
940
  }
628
- function Q(e, t) {
629
- let n = G(e), { renderToken: r, billingAddressRequirement: i = "country", ...a } = t;
630
- return X({
941
+ function Te(e, t) {
942
+ let n = Z(e), { renderToken: r, billingAddressRequirement: i = "country", amount: a, ...o } = t, s = Q({
943
+ src: W(r, i),
944
+ title: "Secure bank account payment method form powered by Amos",
945
+ name: "amos-bank-account-payment-method-form",
946
+ height: K(i)
947
+ }), c = Ce({
631
948
  host: n,
632
- iframe: Y({
633
- src: V(r, i),
634
- title: "Secure bank account payment method form powered by Amos",
635
- name: "amos-bank-account-payment-method-form",
636
- height: U(i)
637
- }),
638
- listenerOptions: a,
949
+ iframe: s,
950
+ listenerOptions: o,
639
951
  skeletonOptions: {
640
952
  kind: "bank",
641
- appearance: a.appearance,
953
+ appearance: o.appearance,
642
954
  billingAddressRequirement: i
643
955
  }
956
+ }), l = ve({
957
+ host: n,
958
+ iframe: s,
959
+ options: {
960
+ amount: a,
961
+ appearance: o.appearance,
962
+ onValidityChange: o.onValidityChange
963
+ }
644
964
  });
965
+ return {
966
+ iframe: s,
967
+ update(e) {
968
+ c.update(e), l.update(e);
969
+ },
970
+ destroy() {
971
+ l.destroy(), c.destroy();
972
+ }
973
+ };
645
974
  }
646
- function $(e, t) {
647
- let n = G(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Y({
648
- src: S(r),
975
+ function Ee(e, t) {
976
+ let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Q({
977
+ src: R(r),
649
978
  title: "Secure Google Pay button powered by Amos",
650
979
  name: "amos-google-pay-button",
651
- height: o.height ?? C(),
980
+ height: o.height ?? z(),
652
981
  allow: "payment",
653
982
  className: i,
654
- style: q
655
- });
656
- Object.assign(s.style, a), n.appendChild(s);
657
- let c = w(s, {
658
- ...o,
659
- onHeightChange: (e) => {
660
- s.style.height = e, o.onHeightChange?.(e);
661
- },
662
- onAppearanceReady: () => {
663
- s.style.opacity = "1", o.onAppearanceReady?.();
664
- }
983
+ style: be
665
984
  });
666
- return {
985
+ return Object.assign(s.style, a), $({
986
+ host: n,
667
987
  iframe: s,
668
- update: c.update,
669
- destroy() {
670
- c.destroy(), s.remove();
671
- }
672
- };
988
+ listenerOptions: o,
989
+ iframeStyle: a,
990
+ attachListeners: B
991
+ });
673
992
  }
674
- function ee(e, t) {
675
- let n = G(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Y({
676
- src: v(r),
993
+ function De(e, t) {
994
+ let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Q({
995
+ src: T(r),
677
996
  title: "Secure Apple Pay button powered by Amos",
678
997
  name: "amos-apple-pay-button",
679
- height: o.height ?? y(),
998
+ height: o.height ?? E(),
680
999
  allow: "payment",
681
1000
  className: i,
682
- style: q
683
- });
684
- Object.assign(s.style, a), n.appendChild(s);
685
- let c = x(s, {
686
- ...o,
687
- onHeightChange: (e) => {
688
- s.style.height = e, o.onHeightChange?.(e);
689
- },
690
- onAppearanceReady: () => {
691
- s.style.opacity = "1", o.onAppearanceReady?.();
692
- }
1001
+ style: be
693
1002
  });
694
- return {
1003
+ return Object.assign(s.style, a), $({
1004
+ host: n,
695
1005
  iframe: s,
696
- update: c.update,
697
- destroy() {
698
- c.destroy(), s.remove();
699
- }
700
- };
1006
+ listenerOptions: o,
1007
+ iframeStyle: a,
1008
+ attachListeners: O
1009
+ });
701
1010
  }
702
1011
  //#endregion
703
- export { x as attachApplePayButtonListeners, w as attachGooglePayButtonListeners, W as attachPaymentMethodFormListeners, h as confirmPaymentIntent, g as confirmSetupIntent, a as createMessage, r as decodeJwt, T as formatGooglePayPaymentData, y as getApplePayButtonInitialHeight, v as getApplePayButtonSrc, U as getBankAccountFormInitialHeight, V as getBankAccountFormSrc, H as getCreditCardFormInitialHeight, B as getCreditCardFormSrc, i as getEmbedOrigin, C as getGooglePayButtonInitialHeight, S as getGooglePayButtonSrc, ee as mountAmosApplePayButton, Q as mountAmosBankAccountPaymentMethodForm, Z as mountAmosCreditCardPaymentMethodForm, $ as mountAmosGooglePayButton, m as resetForm, _ as sendConfirmationResult, s as sendParentReadyMessage, d as updateAmount, c as updateAppearance, l as updateApplePayButton, u as updateGooglePayButton, f as updateMerchantName, p as validateForm };
1012
+ 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 };