@amos.com/amos-js 0.9.17 → 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/README.md +30 -3
- package/dist/index.d.ts +3 -1
- package/dist/index.js +108 -2
- package/dist/index.mjs +422 -170
- package/dist/messaging.d.ts +7 -0
- package/dist/mount.d.ts +23 -3
- package/dist/plaid-bank-ui.d.ts +21 -0
- package/dist/plaid-session.d.ts +12 -0
- package/dist/plaid.d.ts +82 -0
- package/dist/types.d.ts +28 -2
- package/package.json +1 -1
- package/src/index.ts +13 -0
- package/src/messaging.ts +107 -16
- package/src/mount.ts +52 -4
- package/src/payment-method-form.ts +4 -0
- package/src/plaid-bank-ui.ts +421 -0
- package/src/plaid-session.ts +41 -0
- package/src/plaid.ts +215 -0
- package/src/types.ts +31 -2
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
|
|
99
|
+
function l(e) {
|
|
88
100
|
return e;
|
|
89
101
|
}
|
|
90
102
|
//#endregion
|
|
91
103
|
//#region src/messaging.ts
|
|
92
|
-
function
|
|
104
|
+
function u(e) {
|
|
93
105
|
return new URL(e.src).origin;
|
|
94
106
|
}
|
|
95
|
-
function
|
|
96
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
107
|
+
function d(e) {
|
|
108
|
+
e?.contentWindow && e.contentWindow.postMessage(l({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), u(e));
|
|
97
109
|
}
|
|
98
|
-
function
|
|
99
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
110
|
+
function f({ iframe: e, appearance: t = {} }) {
|
|
111
|
+
e?.contentWindow && e.contentWindow.postMessage(l({
|
|
100
112
|
type: "UPDATE_APPEARANCE",
|
|
101
113
|
appearance: t
|
|
102
|
-
}),
|
|
114
|
+
}), u(e));
|
|
103
115
|
}
|
|
104
|
-
function
|
|
105
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
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
|
-
}),
|
|
121
|
+
}), u(e));
|
|
110
122
|
}
|
|
111
|
-
function
|
|
112
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
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
|
-
}),
|
|
128
|
+
}), u(e));
|
|
117
129
|
}
|
|
118
|
-
function
|
|
119
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
130
|
+
function h({ iframe: e, amount: t }) {
|
|
131
|
+
e?.contentWindow && e.contentWindow.postMessage(l({
|
|
120
132
|
type: "UPDATE_AMOUNT",
|
|
121
133
|
amount: t
|
|
122
|
-
}),
|
|
134
|
+
}), u(e));
|
|
123
135
|
}
|
|
124
|
-
function
|
|
125
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
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
|
-
}),
|
|
129
|
-
}
|
|
130
|
-
function
|
|
131
|
-
let t =
|
|
132
|
-
return
|
|
133
|
-
|
|
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:
|
|
136
|
-
}),
|
|
149
|
+
requestId: n
|
|
150
|
+
}), u(e));
|
|
137
151
|
let r = setTimeout(() => {
|
|
138
|
-
window.removeEventListener("message", i),
|
|
152
|
+
window.removeEventListener("message", i), t(!1);
|
|
139
153
|
}, 5e3);
|
|
140
154
|
function i(e) {
|
|
141
|
-
e.data.type === "VALIDATE_FORM" && e.data.requestId ===
|
|
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
|
-
|
|
147
|
-
|
|
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);
|
|
190
|
+
}
|
|
191
|
+
function b(e) {
|
|
192
|
+
e?.contentWindow && e.contentWindow.postMessage(l({ type: "RESET_FORM" }), u(e));
|
|
148
193
|
}
|
|
149
|
-
function
|
|
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
|
-
|
|
206
|
+
x({
|
|
207
|
+
iframe: e,
|
|
153
208
|
type: "CONFIRM_PAYMENT_INTENT",
|
|
154
209
|
token: t,
|
|
155
210
|
id: n ?? void 0
|
|
156
|
-
})
|
|
211
|
+
});
|
|
157
212
|
}
|
|
158
|
-
function
|
|
213
|
+
function C({ iframe: e, token: t }) {
|
|
159
214
|
if (!e?.contentWindow) return;
|
|
160
215
|
let { setup_intent_id: n } = r(t).payload;
|
|
161
|
-
|
|
216
|
+
x({
|
|
217
|
+
iframe: e,
|
|
162
218
|
type: "CONFIRM_SETUP_INTENT",
|
|
163
219
|
token: t,
|
|
164
220
|
id: n ?? void 0
|
|
165
|
-
})
|
|
221
|
+
});
|
|
166
222
|
}
|
|
167
|
-
function
|
|
168
|
-
e?.contentWindow && e.contentWindow.postMessage(
|
|
223
|
+
function w({ iframe: e, result: t }) {
|
|
224
|
+
e?.contentWindow && e.contentWindow.postMessage(l({
|
|
169
225
|
type: "CONFIRMATION_RESULT",
|
|
170
226
|
result: t
|
|
171
|
-
}),
|
|
227
|
+
}), u(e));
|
|
172
228
|
}
|
|
173
229
|
//#endregion
|
|
174
230
|
//#region src/apple-pay.ts
|
|
175
|
-
function
|
|
231
|
+
function T(e) {
|
|
176
232
|
return `${i(e)}/iframe/apple-pay?token=${e}`;
|
|
177
233
|
}
|
|
178
|
-
function
|
|
234
|
+
function E() {
|
|
179
235
|
return "48px";
|
|
180
236
|
}
|
|
181
|
-
function
|
|
182
|
-
e.contentWindow?.postMessage(
|
|
237
|
+
function D(e) {
|
|
238
|
+
e.contentWindow?.postMessage(l({ type: "APPLE_PAY_CANCEL" }), u(e));
|
|
183
239
|
}
|
|
184
|
-
function
|
|
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
|
-
|
|
246
|
+
h({
|
|
191
247
|
iframe: e,
|
|
192
248
|
amount: a.amount
|
|
193
249
|
});
|
|
194
250
|
}
|
|
195
|
-
function
|
|
196
|
-
|
|
251
|
+
function s() {
|
|
252
|
+
g({
|
|
197
253
|
iframe: e,
|
|
198
254
|
merchantName: a.merchantName
|
|
199
255
|
});
|
|
200
256
|
}
|
|
201
|
-
function
|
|
202
|
-
|
|
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
|
|
264
|
+
function l(r) {
|
|
209
265
|
if (r.source === e.contentWindow) switch (r.data.type) {
|
|
210
266
|
case "IFRAME_READY":
|
|
211
|
-
|
|
267
|
+
d(e), f({
|
|
212
268
|
iframe: e,
|
|
213
269
|
appearance: {}
|
|
214
|
-
}), o(),
|
|
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
|
-
|
|
276
|
+
f({
|
|
221
277
|
iframe: e,
|
|
222
278
|
appearance: r.data.appearance
|
|
223
279
|
});
|
|
@@ -227,7 +283,7 @@ function b(e, { height: r = "48px", ...i }) {
|
|
|
227
283
|
break;
|
|
228
284
|
case "APPLE_PAY_WINDOW_OPEN":
|
|
229
285
|
t({ onCancel: () => {
|
|
230
|
-
|
|
286
|
+
D(e), n();
|
|
231
287
|
} });
|
|
232
288
|
break;
|
|
233
289
|
case "APPLE_PAY_WINDOW_CLOSE":
|
|
@@ -238,7 +294,7 @@ function b(e, { height: r = "48px", ...i }) {
|
|
|
238
294
|
paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
|
|
239
295
|
customerCreateAttributes: r.data.customerCreateAttributes
|
|
240
296
|
}).then((t) => {
|
|
241
|
-
|
|
297
|
+
S({
|
|
242
298
|
iframe: e,
|
|
243
299
|
token: t
|
|
244
300
|
});
|
|
@@ -252,22 +308,22 @@ function b(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",
|
|
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 &&
|
|
317
|
+
}, t && o(), n && s(), r && c();
|
|
262
318
|
},
|
|
263
319
|
destroy() {
|
|
264
|
-
window.removeEventListener("message",
|
|
320
|
+
window.removeEventListener("message", l), n();
|
|
265
321
|
}
|
|
266
322
|
};
|
|
267
323
|
}
|
|
268
324
|
//#endregion
|
|
269
325
|
//#region src/form-skeleton.ts
|
|
270
|
-
var
|
|
326
|
+
var k = "amos-js-form-skeleton-styles", te = {
|
|
271
327
|
"--accent": "oklch(0.97 0 0)",
|
|
272
328
|
"--radius": "0.625rem",
|
|
273
329
|
"--input-height": "2.25rem",
|
|
@@ -275,132 +331,132 @@ var x = "amos-js-form-skeleton-styles", S = {
|
|
|
275
331
|
"--field-gap": "1rem",
|
|
276
332
|
"--control-gap": "0.5rem",
|
|
277
333
|
"--label-font-size": "0.875rem"
|
|
278
|
-
},
|
|
279
|
-
function
|
|
280
|
-
if (document.getElementById(
|
|
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;
|
|
281
337
|
let e = document.createElement("style");
|
|
282
|
-
e.id =
|
|
338
|
+
e.id = k, e.textContent = ne, document.head.appendChild(e);
|
|
283
339
|
}
|
|
284
|
-
function
|
|
285
|
-
for (let [t, n] of Object.entries(
|
|
340
|
+
function j(e, t) {
|
|
341
|
+
for (let [t, n] of Object.entries(te)) e.style.setProperty(t, n);
|
|
286
342
|
let n = t?.themeVariables;
|
|
287
343
|
if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
|
|
288
344
|
}
|
|
289
|
-
function
|
|
345
|
+
function M(e, t) {
|
|
290
346
|
let n = document.createElement("div");
|
|
291
347
|
if (n.className = e, t) for (let e of t) n.appendChild(e);
|
|
292
348
|
return n;
|
|
293
349
|
}
|
|
294
|
-
function
|
|
295
|
-
let n =
|
|
296
|
-
t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(
|
|
297
|
-
let r =
|
|
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");
|
|
298
354
|
return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
|
|
299
355
|
}
|
|
300
|
-
function
|
|
301
|
-
return
|
|
356
|
+
function P(e, t) {
|
|
357
|
+
return M(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
|
|
302
358
|
}
|
|
303
|
-
function
|
|
359
|
+
function re({ labels: e, requirement: t, wrapCountryZip: n }) {
|
|
304
360
|
return t === "full" ? [
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
361
|
+
N(e),
|
|
362
|
+
N(e),
|
|
363
|
+
P([
|
|
364
|
+
N(e, 1.4),
|
|
365
|
+
N(e, .7),
|
|
366
|
+
N(e, .8)
|
|
311
367
|
], !1),
|
|
312
|
-
|
|
313
|
-
] : [
|
|
368
|
+
N(e)
|
|
369
|
+
] : [P([N(e), N(e)], n)];
|
|
314
370
|
}
|
|
315
|
-
function
|
|
371
|
+
function ie(e) {
|
|
316
372
|
let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
|
|
317
373
|
if (e.kind === "card") {
|
|
318
|
-
let r = [
|
|
319
|
-
return e.additionalFields?.cardholderName && r.push(
|
|
374
|
+
let r = [N(t), P([N(t), N(t)], !1)];
|
|
375
|
+
return e.additionalFields?.cardholderName && r.push(N(t)), r.push(...re({
|
|
320
376
|
labels: t,
|
|
321
377
|
requirement: n,
|
|
322
378
|
wrapCountryZip: !1
|
|
323
379
|
})), r;
|
|
324
380
|
}
|
|
325
381
|
return [
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
...
|
|
382
|
+
N(t),
|
|
383
|
+
P([N(t), N(t)], !0),
|
|
384
|
+
N(t),
|
|
385
|
+
P([N("above"), N("above")], !0),
|
|
386
|
+
...re({
|
|
331
387
|
labels: t,
|
|
332
388
|
requirement: n,
|
|
333
389
|
wrapCountryZip: !0
|
|
334
390
|
})
|
|
335
391
|
];
|
|
336
392
|
}
|
|
337
|
-
function
|
|
338
|
-
|
|
339
|
-
let t =
|
|
393
|
+
function ae(e) {
|
|
394
|
+
A();
|
|
395
|
+
let t = M("amos-js-form-skeleton");
|
|
340
396
|
t.setAttribute("aria-hidden", "true");
|
|
341
397
|
function n(e) {
|
|
342
|
-
|
|
398
|
+
j(t, e.appearance), t.replaceChildren(...ie(e));
|
|
343
399
|
}
|
|
344
400
|
return n(e), {
|
|
345
401
|
element: t,
|
|
346
402
|
update: n
|
|
347
403
|
};
|
|
348
404
|
}
|
|
349
|
-
function
|
|
350
|
-
|
|
351
|
-
let t =
|
|
405
|
+
function F(e) {
|
|
406
|
+
A();
|
|
407
|
+
let t = M("amos-js-form-skeleton-input amos-js-wallet-skeleton");
|
|
352
408
|
t.setAttribute("aria-hidden", "true");
|
|
353
409
|
function n(e) {
|
|
354
|
-
|
|
410
|
+
j(t, void 0), t.style.height = e.height, t.style.borderRadius = e.borderRadius ?? "4px";
|
|
355
411
|
}
|
|
356
412
|
return n(e), {
|
|
357
413
|
element: t,
|
|
358
414
|
update: n
|
|
359
415
|
};
|
|
360
416
|
}
|
|
361
|
-
function
|
|
417
|
+
function I(e) {
|
|
362
418
|
if (typeof e == "number" && Number.isFinite(e)) return `${e}px`;
|
|
363
419
|
if (typeof e == "string" && e.trim() !== "") return e.trim();
|
|
364
420
|
}
|
|
365
|
-
function
|
|
366
|
-
return
|
|
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";
|
|
367
423
|
}
|
|
368
424
|
//#endregion
|
|
369
425
|
//#region src/google-pay.ts
|
|
370
|
-
function
|
|
426
|
+
function R(e) {
|
|
371
427
|
return `${i(e)}/iframe/google-pay?token=${e}`;
|
|
372
428
|
}
|
|
373
|
-
function
|
|
429
|
+
function z() {
|
|
374
430
|
return "48px";
|
|
375
431
|
}
|
|
376
|
-
function
|
|
432
|
+
function B(e, { height: t = "48px", ...n }) {
|
|
377
433
|
let r = {
|
|
378
434
|
...n,
|
|
379
435
|
height: t
|
|
380
436
|
};
|
|
381
437
|
function i() {
|
|
382
|
-
|
|
438
|
+
h({
|
|
383
439
|
iframe: e,
|
|
384
440
|
amount: r.amount
|
|
385
441
|
});
|
|
386
442
|
}
|
|
387
443
|
function a() {
|
|
388
|
-
|
|
444
|
+
g({
|
|
389
445
|
iframe: e,
|
|
390
446
|
merchantName: r.merchantName
|
|
391
447
|
});
|
|
392
448
|
}
|
|
393
449
|
function o() {
|
|
394
|
-
|
|
450
|
+
m({
|
|
395
451
|
iframe: e,
|
|
396
452
|
height: r.height ?? "48px",
|
|
397
453
|
props: r.buttonProps ?? {}
|
|
398
454
|
});
|
|
399
455
|
}
|
|
400
|
-
function
|
|
456
|
+
function s(t) {
|
|
401
457
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
402
458
|
case "IFRAME_READY":
|
|
403
|
-
|
|
459
|
+
d(e), f({
|
|
404
460
|
iframe: e,
|
|
405
461
|
appearance: {}
|
|
406
462
|
}), i(), a(), o();
|
|
@@ -409,7 +465,7 @@ function L(e, { height: t = "48px", ...n }) {
|
|
|
409
465
|
r.onHeightChange?.(t.data.height);
|
|
410
466
|
break;
|
|
411
467
|
case "UPDATE_APPEARANCE":
|
|
412
|
-
|
|
468
|
+
f({
|
|
413
469
|
iframe: e,
|
|
414
470
|
appearance: t.data.appearance
|
|
415
471
|
});
|
|
@@ -422,7 +478,7 @@ function L(e, { height: t = "48px", ...n }) {
|
|
|
422
478
|
paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
|
|
423
479
|
customerCreateAttributes: t.data.customerCreateAttributes
|
|
424
480
|
}).then((t) => {
|
|
425
|
-
|
|
481
|
+
S({
|
|
426
482
|
iframe: e,
|
|
427
483
|
token: t
|
|
428
484
|
});
|
|
@@ -436,7 +492,7 @@ function L(e, { height: t = "48px", ...n }) {
|
|
|
436
492
|
case "CONFIRMATION_RESULT": r.onResult(t.data.result);
|
|
437
493
|
}
|
|
438
494
|
}
|
|
439
|
-
return window.addEventListener("message",
|
|
495
|
+
return window.addEventListener("message", s), {
|
|
440
496
|
update(e) {
|
|
441
497
|
let t = "amount" in e, n = "merchantName" in e, s = "height" in e || "buttonProps" in e;
|
|
442
498
|
r = {
|
|
@@ -445,11 +501,11 @@ function L(e, { height: t = "48px", ...n }) {
|
|
|
445
501
|
}, t && i(), n && a(), s && o();
|
|
446
502
|
},
|
|
447
503
|
destroy() {
|
|
448
|
-
window.removeEventListener("message",
|
|
504
|
+
window.removeEventListener("message", s);
|
|
449
505
|
}
|
|
450
506
|
};
|
|
451
507
|
}
|
|
452
|
-
function
|
|
508
|
+
function oe({ paymentData: e }) {
|
|
453
509
|
return { paymentMethod: {
|
|
454
510
|
type: "googlepay",
|
|
455
511
|
billing_address_attributes: {
|
|
@@ -468,14 +524,14 @@ function R({ paymentData: e }) {
|
|
|
468
524
|
}
|
|
469
525
|
//#endregion
|
|
470
526
|
//#region src/payment-method-form.ts
|
|
471
|
-
var
|
|
527
|
+
var V = {
|
|
472
528
|
country: 212,
|
|
473
529
|
full: 452
|
|
474
|
-
},
|
|
530
|
+
}, se = 80, H = {
|
|
475
531
|
country: 400,
|
|
476
532
|
full: 640
|
|
477
533
|
};
|
|
478
|
-
function
|
|
534
|
+
function U(e, t = { cardholderName: !1 }, n = "country") {
|
|
479
535
|
let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
|
|
480
536
|
token: e,
|
|
481
537
|
additionalFields: r,
|
|
@@ -483,25 +539,25 @@ function V(e, t = { cardholderName: !1 }, n = "country") {
|
|
|
483
539
|
});
|
|
484
540
|
return `${i(e)}/iframe/card?${a}`;
|
|
485
541
|
}
|
|
486
|
-
function
|
|
542
|
+
function W(e, t = "country") {
|
|
487
543
|
let n = new URLSearchParams({
|
|
488
544
|
token: e,
|
|
489
545
|
billingAddressRequirement: t
|
|
490
546
|
});
|
|
491
547
|
return `${i(e)}/iframe/bank?${n}`;
|
|
492
548
|
}
|
|
493
|
-
function
|
|
494
|
-
return `${(
|
|
549
|
+
function G(e = { cardholderName: !1 }, t = "country") {
|
|
550
|
+
return `${(V[t] ?? V.country) + (e.cardholderName ? se : 0)}px`;
|
|
495
551
|
}
|
|
496
|
-
function
|
|
497
|
-
return `${
|
|
552
|
+
function K(e = "country") {
|
|
553
|
+
return `${H[e] ?? H.country}px`;
|
|
498
554
|
}
|
|
499
|
-
function
|
|
555
|
+
function q(e, t) {
|
|
500
556
|
let n = { ...t };
|
|
501
557
|
function r(t) {
|
|
502
558
|
if (t.source === e.contentWindow) switch (t.data.type) {
|
|
503
559
|
case "IFRAME_READY":
|
|
504
|
-
|
|
560
|
+
d(e), f({
|
|
505
561
|
iframe: e,
|
|
506
562
|
appearance: n.appearance
|
|
507
563
|
});
|
|
@@ -510,7 +566,7 @@ function G(e, t) {
|
|
|
510
566
|
n.onHeightChange?.(t.data.height);
|
|
511
567
|
break;
|
|
512
568
|
case "UPDATE_APPEARANCE":
|
|
513
|
-
|
|
569
|
+
f({
|
|
514
570
|
iframe: e,
|
|
515
571
|
appearance: t.data.appearance
|
|
516
572
|
});
|
|
@@ -519,6 +575,7 @@ function G(e, t) {
|
|
|
519
575
|
n.onAppearanceReady?.();
|
|
520
576
|
break;
|
|
521
577
|
case "FORM_VALIDITY_CHANGE":
|
|
578
|
+
if (s(e)?.requiresVerification) break;
|
|
522
579
|
n.onValidityChange?.({ isValid: t.data.isValid });
|
|
523
580
|
break;
|
|
524
581
|
case "CONFIRMATION_RESULT": n.onResult(t.data.result);
|
|
@@ -530,7 +587,7 @@ function G(e, t) {
|
|
|
530
587
|
n = {
|
|
531
588
|
...n,
|
|
532
589
|
...t
|
|
533
|
-
}, r &&
|
|
590
|
+
}, r && f({
|
|
534
591
|
iframe: e,
|
|
535
592
|
appearance: n.appearance
|
|
536
593
|
});
|
|
@@ -541,8 +598,187 @@ function G(e, t) {
|
|
|
541
598
|
};
|
|
542
599
|
}
|
|
543
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
|
|
544
780
|
//#region src/mount.ts
|
|
545
|
-
function
|
|
781
|
+
function Z(e) {
|
|
546
782
|
if (typeof e == "string") {
|
|
547
783
|
let t = document.querySelector(e);
|
|
548
784
|
if (!(t instanceof HTMLElement)) throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);
|
|
@@ -550,19 +786,19 @@ function K(e) {
|
|
|
550
786
|
}
|
|
551
787
|
return e;
|
|
552
788
|
}
|
|
553
|
-
var
|
|
789
|
+
var ye = {
|
|
554
790
|
width: "calc(100% + 8px)",
|
|
555
791
|
transition: "opacity 150ms ease-in, height 200ms ease-in-out",
|
|
556
792
|
margin: "0 -4px",
|
|
557
793
|
opacity: "0",
|
|
558
794
|
border: "0"
|
|
559
|
-
},
|
|
795
|
+
}, be = {
|
|
560
796
|
width: "100%",
|
|
561
797
|
transition: "height 200ms ease-in-out",
|
|
562
798
|
margin: "0",
|
|
563
799
|
opacity: "0",
|
|
564
800
|
border: "0"
|
|
565
|
-
},
|
|
801
|
+
}, xe = {
|
|
566
802
|
position: "absolute",
|
|
567
803
|
top: "0",
|
|
568
804
|
left: "0",
|
|
@@ -572,7 +808,7 @@ var q = {
|
|
|
572
808
|
opacity: "0",
|
|
573
809
|
transition: "none",
|
|
574
810
|
pointerEvents: "none"
|
|
575
|
-
},
|
|
811
|
+
}, Se = {
|
|
576
812
|
position: "absolute",
|
|
577
813
|
top: "0",
|
|
578
814
|
left: "-4px",
|
|
@@ -582,15 +818,15 @@ var q = {
|
|
|
582
818
|
transition: "none",
|
|
583
819
|
pointerEvents: "none"
|
|
584
820
|
};
|
|
585
|
-
function
|
|
821
|
+
function Q({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = ye }) {
|
|
586
822
|
let s = document.createElement("iframe");
|
|
587
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;
|
|
588
824
|
}
|
|
589
|
-
function
|
|
825
|
+
function Ce({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
590
826
|
let i = document.createElement("div");
|
|
591
827
|
i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
|
|
592
|
-
let a =
|
|
593
|
-
Object.assign(t.style,
|
|
828
|
+
let a = ae(r);
|
|
829
|
+
Object.assign(t.style, Se), i.append(a.element, t), e.appendChild(i);
|
|
594
830
|
let o = !1, s = !1, c, l = r.appearance, u, d;
|
|
595
831
|
function f() {
|
|
596
832
|
return i.getBoundingClientRect().height;
|
|
@@ -602,7 +838,7 @@ function Q({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
602
838
|
if (o) return;
|
|
603
839
|
o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
|
|
604
840
|
let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
|
|
605
|
-
t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin =
|
|
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(() => {
|
|
606
842
|
t.style.transition = "height 200ms ease-in-out";
|
|
607
843
|
}, 400);
|
|
608
844
|
}
|
|
@@ -611,7 +847,7 @@ function Q({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
611
847
|
let e = p(), t = f();
|
|
612
848
|
Number.isFinite(e) && e >= t - 2 && m();
|
|
613
849
|
}
|
|
614
|
-
let g =
|
|
850
|
+
let g = q(t, {
|
|
615
851
|
...n,
|
|
616
852
|
onHeightChange: (e) => {
|
|
617
853
|
c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
|
|
@@ -638,12 +874,12 @@ function Q({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
|
|
|
638
874
|
function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListeners: i }) {
|
|
639
875
|
let a = {
|
|
640
876
|
height: n.height ?? "48px",
|
|
641
|
-
borderRadius:
|
|
877
|
+
borderRadius: L({
|
|
642
878
|
iframeStyle: r,
|
|
643
879
|
buttonProps: n.buttonProps
|
|
644
880
|
})
|
|
645
|
-
}, o =
|
|
646
|
-
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,
|
|
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);
|
|
647
883
|
let c = !1, l = !1, u, d = n;
|
|
648
884
|
function f() {
|
|
649
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"));
|
|
@@ -672,7 +908,7 @@ function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListe
|
|
|
672
908
|
let t = { ...e };
|
|
673
909
|
delete t.onAppearanceReady, delete t.onHeightChange, m.update(t), a = {
|
|
674
910
|
height: d.height ?? a.height,
|
|
675
|
-
borderRadius:
|
|
911
|
+
borderRadius: L({
|
|
676
912
|
iframeStyle: r,
|
|
677
913
|
buttonProps: d.buttonProps
|
|
678
914
|
})
|
|
@@ -683,15 +919,15 @@ function $({ host: e, iframe: t, listenerOptions: n, iframeStyle: r, attachListe
|
|
|
683
919
|
}
|
|
684
920
|
};
|
|
685
921
|
}
|
|
686
|
-
function
|
|
687
|
-
let n =
|
|
688
|
-
return
|
|
922
|
+
function we(e, t) {
|
|
923
|
+
let n = Z(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
|
|
924
|
+
return Ce({
|
|
689
925
|
host: n,
|
|
690
|
-
iframe:
|
|
691
|
-
src:
|
|
926
|
+
iframe: Q({
|
|
927
|
+
src: U(r, i, a),
|
|
692
928
|
title: "Secure credit card payment method form powered by Amos",
|
|
693
929
|
name: "amos-credit-card-payment-method-form",
|
|
694
|
-
height:
|
|
930
|
+
height: G(i, a)
|
|
695
931
|
}),
|
|
696
932
|
listenerOptions: o,
|
|
697
933
|
skeletonOptions: {
|
|
@@ -702,59 +938,75 @@ function ne(e, t) {
|
|
|
702
938
|
}
|
|
703
939
|
});
|
|
704
940
|
}
|
|
705
|
-
function
|
|
706
|
-
let n =
|
|
707
|
-
|
|
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({
|
|
708
948
|
host: n,
|
|
709
|
-
iframe:
|
|
710
|
-
|
|
711
|
-
title: "Secure bank account payment method form powered by Amos",
|
|
712
|
-
name: "amos-bank-account-payment-method-form",
|
|
713
|
-
height: W(i)
|
|
714
|
-
}),
|
|
715
|
-
listenerOptions: a,
|
|
949
|
+
iframe: s,
|
|
950
|
+
listenerOptions: o,
|
|
716
951
|
skeletonOptions: {
|
|
717
952
|
kind: "bank",
|
|
718
|
-
appearance:
|
|
953
|
+
appearance: o.appearance,
|
|
719
954
|
billingAddressRequirement: i
|
|
720
955
|
}
|
|
956
|
+
}), l = ve({
|
|
957
|
+
host: n,
|
|
958
|
+
iframe: s,
|
|
959
|
+
options: {
|
|
960
|
+
amount: a,
|
|
961
|
+
appearance: o.appearance,
|
|
962
|
+
onValidityChange: o.onValidityChange
|
|
963
|
+
}
|
|
721
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
|
+
};
|
|
722
974
|
}
|
|
723
|
-
function
|
|
724
|
-
let n =
|
|
725
|
-
src:
|
|
975
|
+
function Ee(e, t) {
|
|
976
|
+
let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Q({
|
|
977
|
+
src: R(r),
|
|
726
978
|
title: "Secure Google Pay button powered by Amos",
|
|
727
979
|
name: "amos-google-pay-button",
|
|
728
|
-
height: o.height ??
|
|
980
|
+
height: o.height ?? z(),
|
|
729
981
|
allow: "payment",
|
|
730
982
|
className: i,
|
|
731
|
-
style:
|
|
983
|
+
style: be
|
|
732
984
|
});
|
|
733
985
|
return Object.assign(s.style, a), $({
|
|
734
986
|
host: n,
|
|
735
987
|
iframe: s,
|
|
736
988
|
listenerOptions: o,
|
|
737
989
|
iframeStyle: a,
|
|
738
|
-
attachListeners:
|
|
990
|
+
attachListeners: B
|
|
739
991
|
});
|
|
740
992
|
}
|
|
741
|
-
function
|
|
742
|
-
let n =
|
|
743
|
-
src:
|
|
993
|
+
function De(e, t) {
|
|
994
|
+
let n = Z(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Q({
|
|
995
|
+
src: T(r),
|
|
744
996
|
title: "Secure Apple Pay button powered by Amos",
|
|
745
997
|
name: "amos-apple-pay-button",
|
|
746
|
-
height: o.height ??
|
|
998
|
+
height: o.height ?? E(),
|
|
747
999
|
allow: "payment",
|
|
748
1000
|
className: i,
|
|
749
|
-
style:
|
|
1001
|
+
style: be
|
|
750
1002
|
});
|
|
751
1003
|
return Object.assign(s.style, a), $({
|
|
752
1004
|
host: n,
|
|
753
1005
|
iframe: s,
|
|
754
1006
|
listenerOptions: o,
|
|
755
1007
|
iframeStyle: a,
|
|
756
|
-
attachListeners:
|
|
1008
|
+
attachListeners: O
|
|
757
1009
|
});
|
|
758
1010
|
}
|
|
759
1011
|
//#endregion
|
|
760
|
-
export {
|
|
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 };
|