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