@amos.com/amos-js 0.9.13 → 0.9.15

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
@@ -85,82 +85,55 @@ function i(e) {
85
85
  //#endregion
86
86
  //#region src/types.ts
87
87
  function a(e) {
88
- if (!e || typeof e != "object") return;
89
- let t = {};
90
- for (let [n, r] of Object.entries(e)) {
91
- if (typeof r == "string") {
92
- if (r.length === 0) continue;
93
- t[n] = r;
94
- continue;
95
- }
96
- typeof r == "number" && Number.isFinite(r) && (t[n] = r);
97
- }
98
- return Object.keys(t).length > 0 ? t : void 0;
99
- }
100
- function o(e) {
101
- let t = {};
102
- if (e.fullWidth !== void 0 && (t.fullWidth = e.fullWidth), e.buttonstyle !== void 0 && (t.buttonstyle = e.buttonstyle), e.type !== void 0 && (t.type = e.type), e.locale !== void 0 && (t.locale = e.locale), e.style !== void 0) {
103
- let n = a(e.style);
104
- n && (t.style = n);
105
- }
106
- return t;
107
- }
108
- function s(e) {
109
- let t = {};
110
- if (e.fullWidth !== void 0 && (t.fullWidth = e.fullWidth), e.buttonType !== void 0 && (t.buttonType = e.buttonType), e.buttonColor !== void 0 && (t.buttonColor = e.buttonColor), e.buttonRadius !== void 0 && (t.buttonRadius = e.buttonRadius), e.buttonSizeMode !== void 0 && (t.buttonSizeMode = e.buttonSizeMode), e.buttonLocale !== void 0 && (t.buttonLocale = e.buttonLocale), e.buttonBorderType !== void 0 && (t.buttonBorderType = e.buttonBorderType), e.style !== void 0) {
111
- let n = a(e.style);
112
- n && (t.style = n);
113
- }
114
- return t;
115
- }
116
- function c(e) {
117
88
  return e;
118
89
  }
119
90
  //#endregion
120
91
  //#region src/messaging.ts
121
- function l(e) {
92
+ function o(e) {
122
93
  return new URL(e.src).origin;
123
94
  }
124
- function u(e) {
125
- e?.contentWindow && e.contentWindow.postMessage(c({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), l(e));
95
+ function s(e) {
96
+ e?.contentWindow && e.contentWindow.postMessage(a({ type: "PARENT_ACKNOWLEDGED_IFRAME_READY" }), o(e));
126
97
  }
127
- function d({ iframe: e, appearance: t = {} }) {
128
- e?.contentWindow && e.contentWindow.postMessage(c({
98
+ function c({ iframe: e, appearance: t = {} }) {
99
+ e?.contentWindow && e.contentWindow.postMessage(a({
129
100
  type: "UPDATE_APPEARANCE",
130
101
  appearance: t
131
- }), l(e));
102
+ }), o(e));
132
103
  }
133
- function f({ iframe: e, props: t }) {
134
- e?.contentWindow && e.contentWindow.postMessage(c({
104
+ function l({ iframe: e, props: t, height: n }) {
105
+ e?.contentWindow && e.contentWindow.postMessage(a({
135
106
  type: "UPDATE_APPLE_PAY_BUTTON",
136
- props: o(t)
137
- }), l(e));
107
+ height: n,
108
+ props: t
109
+ }), o(e));
138
110
  }
139
- function p({ iframe: e, props: t }) {
140
- e?.contentWindow && e.contentWindow.postMessage(c({
111
+ function u({ iframe: e, props: t, height: n }) {
112
+ e?.contentWindow && e.contentWindow.postMessage(a({
141
113
  type: "UPDATE_GOOGLE_PAY_BUTTON",
142
- props: s(t)
143
- }), l(e));
114
+ height: n,
115
+ props: t
116
+ }), o(e));
144
117
  }
145
- function m({ iframe: e, amount: t }) {
146
- e?.contentWindow && e.contentWindow.postMessage(c({
118
+ function d({ iframe: e, amount: t }) {
119
+ e?.contentWindow && e.contentWindow.postMessage(a({
147
120
  type: "UPDATE_AMOUNT",
148
121
  amount: t
149
- }), l(e));
122
+ }), o(e));
150
123
  }
151
- function h({ iframe: e, merchantName: t }) {
152
- e?.contentWindow && e.contentWindow.postMessage(c({
124
+ function f({ iframe: e, merchantName: t }) {
125
+ e?.contentWindow && e.contentWindow.postMessage(a({
153
126
  type: "UPDATE_MERCHANT_NAME",
154
127
  merchantName: t
155
- }), l(e));
128
+ }), o(e));
156
129
  }
157
- function g({ iframe: e }) {
130
+ function p({ iframe: e }) {
158
131
  let t = crypto.randomUUID();
159
132
  return new Promise((n) => {
160
- e?.contentWindow && e.contentWindow.postMessage(c({
133
+ e?.contentWindow && e.contentWindow.postMessage(a({
161
134
  type: "VALIDATE_FORM",
162
135
  requestId: t
163
- }), l(e));
136
+ }), o(e));
164
137
  let r = setTimeout(() => {
165
138
  window.removeEventListener("message", i), n(!1);
166
139
  }, 5e3);
@@ -170,211 +143,213 @@ function g({ iframe: e }) {
170
143
  window.addEventListener("message", i);
171
144
  });
172
145
  }
173
- function _({ iframe: e }) {
174
- e?.contentWindow && e.contentWindow.postMessage(c({ type: "RESET_FORM" }), l(e));
146
+ function m({ iframe: e }) {
147
+ e?.contentWindow && e.contentWindow.postMessage(a({ type: "RESET_FORM" }), o(e));
175
148
  }
176
- function v({ iframe: e, token: t }) {
149
+ function h({ iframe: e, token: t }) {
177
150
  if (!e?.contentWindow) return;
178
151
  let { payment_intent_id: n } = r(t).payload;
179
- e.contentWindow.postMessage(c({
152
+ e.contentWindow.postMessage(a({
180
153
  type: "CONFIRM_PAYMENT_INTENT",
181
154
  token: t,
182
155
  id: n ?? void 0
183
- }), l(e));
156
+ }), o(e));
184
157
  }
185
- function y({ iframe: e, token: t }) {
158
+ function g({ iframe: e, token: t }) {
186
159
  if (!e?.contentWindow) return;
187
160
  let { setup_intent_id: n } = r(t).payload;
188
- e.contentWindow.postMessage(c({
161
+ e.contentWindow.postMessage(a({
189
162
  type: "CONFIRM_SETUP_INTENT",
190
163
  token: t,
191
164
  id: n ?? void 0
192
- }), l(e));
165
+ }), o(e));
193
166
  }
194
- function b({ iframe: e, result: t }) {
195
- e?.contentWindow && e.contentWindow.postMessage(c({
167
+ function _({ iframe: e, result: t }) {
168
+ e?.contentWindow && e.contentWindow.postMessage(a({
196
169
  type: "CONFIRMATION_RESULT",
197
170
  result: t
198
- }), l(e));
171
+ }), o(e));
199
172
  }
200
173
  //#endregion
201
174
  //#region src/apple-pay.ts
202
- function x(e) {
175
+ function v(e) {
203
176
  return `${i(e)}/iframe/apple-pay?token=${e}`;
204
177
  }
205
- function S() {
206
- return "40px";
178
+ function y() {
179
+ return "48px";
207
180
  }
208
- function C(e) {
209
- e.contentWindow?.postMessage(c({ type: "APPLE_PAY_CANCEL" }), l(e));
181
+ function b(e) {
182
+ e.contentWindow?.postMessage(a({ type: "APPLE_PAY_CANCEL" }), o(e));
210
183
  }
211
- function w(e, r) {
212
- let i = { ...r };
213
- function a() {
214
- m({
184
+ function x(e, { height: r = "48px", ...i }) {
185
+ let a = {
186
+ ...i,
187
+ height: r
188
+ };
189
+ function o() {
190
+ d({
215
191
  iframe: e,
216
- amount: i.amount
192
+ amount: a.amount
217
193
  });
218
194
  }
219
- function o() {
220
- h({
195
+ function u() {
196
+ f({
221
197
  iframe: e,
222
- merchantName: i.merchantName
198
+ merchantName: a.merchantName
223
199
  });
224
200
  }
225
- function s() {
226
- f({
201
+ function p() {
202
+ l({
227
203
  iframe: e,
228
- props: i
204
+ height: a.height ?? "48px",
205
+ props: a.buttonProps ?? {}
229
206
  });
230
207
  }
231
- function c(r) {
208
+ function m(r) {
232
209
  if (r.source === e.contentWindow) switch (r.data.type) {
233
210
  case "IFRAME_READY":
234
- u(e), d({
211
+ s(e), c({
235
212
  iframe: e,
236
- appearance: i.appearance
237
- }), a(), o(), s();
213
+ appearance: {}
214
+ }), o(), u(), p();
238
215
  break;
239
216
  case "UPDATE_HEIGHT":
240
- i.onHeightChange?.(r.data.height);
217
+ a.onHeightChange?.(r.data.height);
241
218
  break;
242
219
  case "UPDATE_APPEARANCE":
243
- d({
220
+ c({
244
221
  iframe: e,
245
222
  appearance: r.data.appearance
246
223
  });
247
224
  break;
248
225
  case "UPDATED_APPEARANCE":
249
- i.onAppearanceReady?.();
226
+ a.onAppearanceReady?.();
250
227
  break;
251
228
  case "APPLE_PAY_WINDOW_OPEN":
252
229
  t({ onCancel: () => {
253
- C(e), n();
230
+ b(e), n();
254
231
  } });
255
232
  break;
256
233
  case "APPLE_PAY_WINDOW_CLOSE":
257
234
  n();
258
235
  break;
259
236
  case "CREATE_PAYMENT_INTENT":
260
- i.onInitiatePaymentIntentRequest({
237
+ a.onInitiatePaymentIntentRequest({
261
238
  paymentIntentCreateAttributes: r.data.paymentIntentCreateAttributes,
262
239
  customerCreateAttributes: r.data.customerCreateAttributes
263
240
  }).then((t) => {
264
- v({
241
+ h({
265
242
  iframe: e,
266
243
  token: t
267
244
  });
268
245
  }).catch((e) => {
269
- n(), i.onResult({
246
+ n(), a.onResult({
270
247
  status: "failed",
271
248
  errorMessage: e instanceof Error ? e.message : "Unknown error"
272
249
  });
273
250
  });
274
251
  break;
275
- case "CONFIRMATION_RESULT": n(), i.onResult(r.data.result);
252
+ case "CONFIRMATION_RESULT": n(), a.onResult(r.data.result);
276
253
  }
277
254
  }
278
- return window.addEventListener("message", c), {
279
- update(t) {
280
- let n = "appearance" in t, r = "amount" in t, c = "merchantName" in t, l = "fullWidth" in t || "buttonstyle" in t || "type" in t || "locale" in t || "style" in t;
281
- i = {
282
- ...i,
283
- ...t
284
- }, n && d({
285
- iframe: e,
286
- appearance: i.appearance
287
- }), r && a(), c && o(), l && s();
255
+ return window.addEventListener("message", m), {
256
+ update(e) {
257
+ let t = "amount" in e, n = "merchantName" in e, r = "height" in e || "buttonProps" in e;
258
+ a = {
259
+ ...a,
260
+ ...e
261
+ }, t && o(), n && u(), r && p();
288
262
  },
289
263
  destroy() {
290
- window.removeEventListener("message", c), n();
264
+ window.removeEventListener("message", m), n();
291
265
  }
292
266
  };
293
267
  }
294
268
  //#endregion
295
269
  //#region src/google-pay.ts
296
- function T(e) {
270
+ function S(e) {
297
271
  return `${i(e)}/iframe/google-pay?token=${e}`;
298
272
  }
299
- function E() {
300
- return "40px";
273
+ function C() {
274
+ return "48px";
301
275
  }
302
- function D(e, t) {
303
- let n = { ...t };
304
- function r() {
305
- m({
276
+ function w(e, { height: t = "48px", ...n }) {
277
+ let r = {
278
+ ...n,
279
+ height: t
280
+ };
281
+ function i() {
282
+ d({
306
283
  iframe: e,
307
- amount: n.amount
284
+ amount: r.amount
308
285
  });
309
286
  }
310
- function i() {
311
- h({
287
+ function a() {
288
+ f({
312
289
  iframe: e,
313
- merchantName: n.merchantName
290
+ merchantName: r.merchantName
314
291
  });
315
292
  }
316
- function a() {
317
- p({
293
+ function o() {
294
+ u({
318
295
  iframe: e,
319
- props: n
296
+ height: r.height ?? "48px",
297
+ props: r.buttonProps ?? {}
320
298
  });
321
299
  }
322
- function o(t) {
300
+ function l(t) {
323
301
  if (t.source === e.contentWindow) switch (t.data.type) {
324
302
  case "IFRAME_READY":
325
- u(e), d({
303
+ s(e), c({
326
304
  iframe: e,
327
- appearance: n.appearance
328
- }), r(), i(), a();
305
+ appearance: {}
306
+ }), i(), a(), o();
329
307
  break;
330
308
  case "UPDATE_HEIGHT":
331
- n.onHeightChange?.(t.data.height);
309
+ r.onHeightChange?.(t.data.height);
332
310
  break;
333
311
  case "UPDATE_APPEARANCE":
334
- d({
312
+ c({
335
313
  iframe: e,
336
314
  appearance: t.data.appearance
337
315
  });
338
316
  break;
339
317
  case "UPDATED_APPEARANCE":
340
- n.onAppearanceReady?.();
318
+ r.onAppearanceReady?.();
341
319
  break;
342
320
  case "CREATE_PAYMENT_INTENT":
343
- n.onInitiatePaymentIntentRequest({
321
+ r.onInitiatePaymentIntentRequest({
344
322
  paymentIntentCreateAttributes: t.data.paymentIntentCreateAttributes,
345
323
  customerCreateAttributes: t.data.customerCreateAttributes
346
324
  }).then((t) => {
347
- v({
325
+ h({
348
326
  iframe: e,
349
327
  token: t
350
328
  });
351
329
  }).catch((e) => {
352
- n.onResult({
330
+ r.onResult({
353
331
  status: "failed",
354
332
  errorMessage: e instanceof Error ? e.message : "Unknown error"
355
333
  });
356
334
  });
357
335
  break;
358
- case "CONFIRMATION_RESULT": n.onResult(t.data.result);
336
+ case "CONFIRMATION_RESULT": r.onResult(t.data.result);
359
337
  }
360
338
  }
361
- return window.addEventListener("message", o), {
362
- update(t) {
363
- let o = "appearance" in t, s = "amount" in t, c = "merchantName" in t, l = "fullWidth" in t || "buttonType" in t || "buttonColor" in t || "buttonRadius" in t || "buttonSizeMode" in t || "buttonLocale" in t || "buttonBorderType" in t || "style" in t;
364
- n = {
365
- ...n,
366
- ...t
367
- }, o && d({
368
- iframe: e,
369
- appearance: n.appearance
370
- }), s && r(), c && i(), l && a();
339
+ return window.addEventListener("message", l), {
340
+ update(e) {
341
+ let t = "amount" in e, n = "merchantName" in e, s = "height" in e || "buttonProps" in e;
342
+ r = {
343
+ ...r,
344
+ ...e
345
+ }, t && i(), n && a(), s && o();
371
346
  },
372
347
  destroy() {
373
- window.removeEventListener("message", o);
348
+ window.removeEventListener("message", l);
374
349
  }
375
350
  };
376
351
  }
377
- function O({ paymentData: e }) {
352
+ function T({ paymentData: e }) {
378
353
  return { paymentMethod: {
379
354
  type: "googlepay",
380
355
  billing_address_attributes: {
@@ -393,7 +368,7 @@ function O({ paymentData: e }) {
393
368
  }
394
369
  //#endregion
395
370
  //#region src/form-skeleton.ts
396
- var k = "amos-js-form-skeleton-styles", A = {
371
+ var E = "amos-js-form-skeleton-styles", D = {
397
372
  "--accent": "oklch(0.97 0 0)",
398
373
  "--radius": "0.625rem",
399
374
  "--input-height": "2.25rem",
@@ -401,71 +376,71 @@ var k = "amos-js-form-skeleton-styles", A = {
401
376
  "--field-gap": "1rem",
402
377
  "--control-gap": "0.5rem",
403
378
  "--label-font-size": "0.875rem"
404
- }, j = "\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";
405
- function M() {
406
- if (document.getElementById(k)) return;
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;
407
382
  let e = document.createElement("style");
408
- e.id = k, e.textContent = j, document.head.appendChild(e);
383
+ e.id = E, e.textContent = O, document.head.appendChild(e);
409
384
  }
410
- function N(e, t) {
411
- for (let [t, n] of Object.entries(A)) e.style.setProperty(t, n);
385
+ function A(e, t) {
386
+ for (let [t, n] of Object.entries(D)) e.style.setProperty(t, n);
412
387
  let n = t?.themeVariables;
413
388
  if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && r.trim() !== "" && e.style.setProperty(t, r.trim());
414
389
  }
415
- function P(e, t) {
390
+ function j(e, t) {
416
391
  let n = document.createElement("div");
417
392
  if (n.className = e, t) for (let e of t) n.appendChild(e);
418
393
  return n;
419
394
  }
420
- function F(e, t) {
421
- let n = P("amos-js-form-skeleton-field");
422
- t !== void 0 && (n.style.flexGrow = String(t)), e === "above" && n.appendChild(P("amos-js-form-skeleton-label"));
423
- let r = P("amos-js-form-skeleton-input");
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");
424
399
  return e === "floating" && r.classList.add("amos-js-form-skeleton-input-floating"), n.appendChild(r), n;
425
400
  }
426
- function I(e, t) {
427
- return P(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
401
+ function N(e, t) {
402
+ return j(t ? "amos-js-form-skeleton-row-stack" : "amos-js-form-skeleton-row", e);
428
403
  }
429
- function L({ labels: e, requirement: t, wrapCountryZip: n }) {
404
+ function P({ labels: e, requirement: t, wrapCountryZip: n }) {
430
405
  return t === "full" ? [
431
- F(e),
432
- F(e),
433
- I([
434
- F(e, 1.4),
435
- F(e, .7),
436
- F(e, .8)
406
+ M(e),
407
+ M(e),
408
+ N([
409
+ M(e, 1.4),
410
+ M(e, .7),
411
+ M(e, .8)
437
412
  ], !1),
438
- F(e)
439
- ] : [I([F(e), F(e)], n)];
413
+ M(e)
414
+ ] : [N([M(e), M(e)], n)];
440
415
  }
441
- function R(e) {
416
+ function F(e) {
442
417
  let t = e.appearance?.labels ?? "above", n = e.billingAddressRequirement ?? "country";
443
418
  if (e.kind === "card") {
444
- let r = [F(t), I([F(t), F(t)], !1)];
445
- return e.additionalFields?.cardholderName && r.push(F(t)), r.push(...L({
419
+ let r = [M(t), N([M(t), M(t)], !1)];
420
+ return e.additionalFields?.cardholderName && r.push(M(t)), r.push(...P({
446
421
  labels: t,
447
422
  requirement: n,
448
423
  wrapCountryZip: !1
449
424
  })), r;
450
425
  }
451
426
  return [
452
- F(t),
453
- I([F(t), F(t)], !0),
454
- F(t),
455
- I([F("above"), F("above")], !0),
456
- ...L({
427
+ M(t),
428
+ N([M(t), M(t)], !0),
429
+ M(t),
430
+ N([M("above"), M("above")], !0),
431
+ ...P({
457
432
  labels: t,
458
433
  requirement: n,
459
434
  wrapCountryZip: !0
460
435
  })
461
436
  ];
462
437
  }
463
- function z(e) {
464
- M();
465
- let t = P("amos-js-form-skeleton");
438
+ function I(e) {
439
+ k();
440
+ let t = j("amos-js-form-skeleton");
466
441
  t.setAttribute("aria-hidden", "true");
467
442
  function n(e) {
468
- N(t, e.appearance), t.replaceChildren(...R(e));
443
+ A(t, e.appearance), t.replaceChildren(...F(e));
469
444
  }
470
445
  return n(e), {
471
446
  element: t,
@@ -474,14 +449,14 @@ function z(e) {
474
449
  }
475
450
  //#endregion
476
451
  //#region src/payment-method-form.ts
477
- var B = {
452
+ var L = {
478
453
  country: 212,
479
454
  full: 452
480
- }, V = 80, H = {
455
+ }, R = 80, z = {
481
456
  country: 400,
482
457
  full: 640
483
458
  };
484
- function U(e, t = { cardholderName: !1 }, n = "country") {
459
+ function B(e, t = { cardholderName: !1 }, n = "country") {
485
460
  let r = Object.entries(t).filter(([, e]) => e).map(([e]) => e).join(","), a = new URLSearchParams({
486
461
  token: e,
487
462
  additionalFields: r,
@@ -489,25 +464,25 @@ function U(e, t = { cardholderName: !1 }, n = "country") {
489
464
  });
490
465
  return `${i(e)}/iframe/card?${a}`;
491
466
  }
492
- function W(e, t = "country") {
467
+ function V(e, t = "country") {
493
468
  let n = new URLSearchParams({
494
469
  token: e,
495
470
  billingAddressRequirement: t
496
471
  });
497
472
  return `${i(e)}/iframe/bank?${n}`;
498
473
  }
499
- function G(e = { cardholderName: !1 }, t = "country") {
500
- return `${(B[t] ?? B.country) + (e.cardholderName ? V : 0)}px`;
474
+ function H(e = { cardholderName: !1 }, t = "country") {
475
+ return `${(L[t] ?? L.country) + (e.cardholderName ? R : 0)}px`;
501
476
  }
502
- function K(e = "country") {
503
- return `${H[e] ?? H.country}px`;
477
+ function U(e = "country") {
478
+ return `${z[e] ?? z.country}px`;
504
479
  }
505
- function q(e, t) {
480
+ function W(e, t) {
506
481
  let n = { ...t };
507
482
  function r(t) {
508
483
  if (t.source === e.contentWindow) switch (t.data.type) {
509
484
  case "IFRAME_READY":
510
- u(e), d({
485
+ s(e), c({
511
486
  iframe: e,
512
487
  appearance: n.appearance
513
488
  });
@@ -516,7 +491,7 @@ function q(e, t) {
516
491
  n.onHeightChange?.(t.data.height);
517
492
  break;
518
493
  case "UPDATE_APPEARANCE":
519
- d({
494
+ c({
520
495
  iframe: e,
521
496
  appearance: t.data.appearance
522
497
  });
@@ -536,7 +511,7 @@ function q(e, t) {
536
511
  n = {
537
512
  ...n,
538
513
  ...t
539
- }, r && d({
514
+ }, r && c({
540
515
  iframe: e,
541
516
  appearance: n.appearance
542
517
  });
@@ -548,7 +523,7 @@ function q(e, t) {
548
523
  }
549
524
  //#endregion
550
525
  //#region src/mount.ts
551
- function J(e) {
526
+ function G(e) {
552
527
  if (typeof e == "string") {
553
528
  let t = document.querySelector(e);
554
529
  if (!(t instanceof HTMLElement)) throw Error(`[amos-js] Container "${e}" did not match any HTMLElement.`);
@@ -556,19 +531,19 @@ function J(e) {
556
531
  }
557
532
  return e;
558
533
  }
559
- var Y = {
534
+ var K = {
560
535
  width: "calc(100% + 8px)",
561
536
  transition: "opacity 150ms ease-in, height 200ms ease-in-out",
562
537
  margin: "0 -4px",
563
538
  opacity: "0",
564
539
  border: "0"
565
- }, X = {
540
+ }, q = {
566
541
  width: "100%",
567
542
  transition: "height 200ms ease-in-out",
568
543
  margin: "0",
569
544
  opacity: "0",
570
545
  border: "0"
571
- }, Z = {
546
+ }, J = {
572
547
  position: "absolute",
573
548
  top: "0",
574
549
  left: "-4px",
@@ -578,15 +553,15 @@ var Y = {
578
553
  transition: "none",
579
554
  pointerEvents: "none"
580
555
  };
581
- function Q({ src: e, title: t, name: n, height: r, allow: i, style: a = Y }) {
582
- let o = document.createElement("iframe");
583
- return o.src = e, o.title = t, o.name = n, o.setAttribute("role", "presentation"), o.scrolling = "no", i && (o.allow = i), Object.assign(o.style, a, { height: r }), o;
556
+ function Y({ src: e, title: t, name: n, height: r, allow: i, className: a, style: o = K }) {
557
+ let s = document.createElement("iframe");
558
+ 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;
584
559
  }
585
- function $({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
560
+ function X({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
586
561
  let i = document.createElement("div");
587
562
  i.style.position = "relative", i.style.width = "100%", i.setAttribute("aria-busy", "true");
588
- let a = z(r);
589
- Object.assign(t.style, Z), i.append(a.element, t), e.appendChild(i);
563
+ let a = I(r);
564
+ Object.assign(t.style, J), i.append(a.element, t), e.appendChild(i);
590
565
  let o = !1, s = !1, c, l = r.appearance, u, d;
591
566
  function f() {
592
567
  return i.getBoundingClientRect().height;
@@ -598,7 +573,7 @@ function $({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
598
573
  if (o) return;
599
574
  o = !0, d !== void 0 && (clearTimeout(d), d = void 0);
600
575
  let e = f(), n = p(), r = Number.isFinite(n) ? Math.max(n, e) : e;
601
- t.style.transition = "none", t.style.position = "", t.style.top = "", t.style.left = "", t.style.margin = Y.margin ?? "", t.style.height = `${r}px`, t.style.opacity = "1", t.style.pointerEvents = "", a.element.remove(), i.removeAttribute("aria-busy"), u = setTimeout(() => {
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(() => {
602
577
  t.style.transition = "height 200ms ease-in-out";
603
578
  }, 400);
604
579
  }
@@ -607,7 +582,7 @@ function $({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
607
582
  let e = p(), t = f();
608
583
  Number.isFinite(e) && e >= t - 2 && m();
609
584
  }
610
- let g = q(t, {
585
+ let g = W(t, {
611
586
  ...n,
612
587
  onHeightChange: (e) => {
613
588
  c = e, o ? t.style.height = e : h(), n.onHeightChange?.(e);
@@ -631,15 +606,15 @@ function $({ host: e, iframe: t, listenerOptions: n, skeletonOptions: r }) {
631
606
  }
632
607
  };
633
608
  }
634
- function ee(e, t) {
635
- let n = J(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
636
- return $({
609
+ function Z(e, t) {
610
+ let n = G(e), { renderToken: r, additionalFields: i = { cardholderName: !1 }, billingAddressRequirement: a = "country", ...o } = t;
611
+ return X({
637
612
  host: n,
638
- iframe: Q({
639
- src: U(r, i, a),
613
+ iframe: Y({
614
+ src: B(r, i, a),
640
615
  title: "Secure credit card payment method form powered by Amos",
641
616
  name: "amos-credit-card-payment-method-form",
642
- height: G(i, a)
617
+ height: H(i, a)
643
618
  }),
644
619
  listenerOptions: o,
645
620
  skeletonOptions: {
@@ -650,15 +625,15 @@ function ee(e, t) {
650
625
  }
651
626
  });
652
627
  }
653
- function te(e, t) {
654
- let n = J(e), { renderToken: r, billingAddressRequirement: i = "country", ...a } = t;
655
- return $({
628
+ function Q(e, t) {
629
+ let n = G(e), { renderToken: r, billingAddressRequirement: i = "country", ...a } = t;
630
+ return X({
656
631
  host: n,
657
- iframe: Q({
658
- src: W(r, i),
632
+ iframe: Y({
633
+ src: V(r, i),
659
634
  title: "Secure bank account payment method form powered by Amos",
660
635
  name: "amos-bank-account-payment-method-form",
661
- height: K(i)
636
+ height: U(i)
662
637
  }),
663
638
  listenerOptions: a,
664
639
  skeletonOptions: {
@@ -668,59 +643,61 @@ function te(e, t) {
668
643
  }
669
644
  });
670
645
  }
671
- function ne(e, t) {
672
- let n = J(e), { renderToken: r, ...i } = t, a = Q({
673
- src: T(r),
646
+ function $(e, t) {
647
+ let n = G(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Y({
648
+ src: S(r),
674
649
  title: "Secure Google Pay button powered by Amos",
675
650
  name: "amos-google-pay-button",
676
- height: E(),
651
+ height: o.height ?? C(),
677
652
  allow: "payment",
678
- style: X
653
+ className: i,
654
+ style: q
679
655
  });
680
- n.appendChild(a);
681
- let o = D(a, {
682
- ...i,
656
+ Object.assign(s.style, a), n.appendChild(s);
657
+ let c = w(s, {
658
+ ...o,
683
659
  onHeightChange: (e) => {
684
- a.style.height = e, i.onHeightChange?.(e);
660
+ s.style.height = e, o.onHeightChange?.(e);
685
661
  },
686
662
  onAppearanceReady: () => {
687
- a.style.opacity = "1", i.onAppearanceReady?.();
663
+ s.style.opacity = "1", o.onAppearanceReady?.();
688
664
  }
689
665
  });
690
666
  return {
691
- iframe: a,
692
- update: o.update,
667
+ iframe: s,
668
+ update: c.update,
693
669
  destroy() {
694
- o.destroy(), a.remove();
670
+ c.destroy(), s.remove();
695
671
  }
696
672
  };
697
673
  }
698
- function re(e, t) {
699
- let n = J(e), { renderToken: r, ...i } = t, a = Q({
700
- src: x(r),
674
+ function ee(e, t) {
675
+ let n = G(e), { renderToken: r, iframeClassName: i, iframeStyle: a, ...o } = t, s = Y({
676
+ src: v(r),
701
677
  title: "Secure Apple Pay button powered by Amos",
702
678
  name: "amos-apple-pay-button",
703
- height: S(),
679
+ height: o.height ?? y(),
704
680
  allow: "payment",
705
- style: X
681
+ className: i,
682
+ style: q
706
683
  });
707
- n.appendChild(a);
708
- let o = w(a, {
709
- ...i,
684
+ Object.assign(s.style, a), n.appendChild(s);
685
+ let c = x(s, {
686
+ ...o,
710
687
  onHeightChange: (e) => {
711
- a.style.height = e, i.onHeightChange?.(e);
688
+ s.style.height = e, o.onHeightChange?.(e);
712
689
  },
713
690
  onAppearanceReady: () => {
714
- a.style.opacity = "1", i.onAppearanceReady?.();
691
+ s.style.opacity = "1", o.onAppearanceReady?.();
715
692
  }
716
693
  });
717
694
  return {
718
- iframe: a,
719
- update: o.update,
695
+ iframe: s,
696
+ update: c.update,
720
697
  destroy() {
721
- o.destroy(), a.remove();
698
+ c.destroy(), s.remove();
722
699
  }
723
700
  };
724
701
  }
725
702
  //#endregion
726
- export { w as attachApplePayButtonListeners, D as attachGooglePayButtonListeners, q as attachPaymentMethodFormListeners, v as confirmPaymentIntent, y as confirmSetupIntent, c as createMessage, r as decodeJwt, O as formatGooglePayPaymentData, S as getApplePayButtonInitialHeight, x as getApplePayButtonSrc, K as getBankAccountFormInitialHeight, W as getBankAccountFormSrc, G as getCreditCardFormInitialHeight, U as getCreditCardFormSrc, i as getEmbedOrigin, E as getGooglePayButtonInitialHeight, T as getGooglePayButtonSrc, re as mountAmosApplePayButton, te as mountAmosBankAccountPaymentMethodForm, ee as mountAmosCreditCardPaymentMethodForm, ne as mountAmosGooglePayButton, o as pickApplePayButtonElementProps, s as pickGooglePayButtonElementProps, _ as resetForm, b as sendConfirmationResult, u as sendParentReadyMessage, a as serializeWalletButtonStyle, m as updateAmount, d as updateAppearance, f as updateApplePayButton, p as updateGooglePayButton, h as updateMerchantName, g as validateForm };
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 };