@alfadocs/ui-kit 0.43.0 → 0.45.0

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.
Files changed (129) hide show
  1. package/dist/_chunks/{alia-sidebar-BpX4z_af.js → alia-sidebar-Be8FhKYd.js} +332 -237
  2. package/dist/_chunks/{autocomplete-DIgdhCGJ.js → autocomplete-CDqxB68B.js} +2 -2
  3. package/dist/_chunks/bmi-calculator-CQqXTVNL.js +258 -0
  4. package/dist/_chunks/{booking-CtLwaxkK.js → booking-DlDVuWMd.js} +2 -2
  5. package/dist/_chunks/{calculator-dialog-DdexHrTP.js → calculator-dialog-D-nfvteH.js} +2 -2
  6. package/dist/_chunks/{cycle-calculator-Dln-y1k_.js → cycle-calculator-KxA8dqDf.js} +73 -54
  7. package/dist/_chunks/dialog-BTpZV6It.js +223 -0
  8. package/dist/_chunks/{due-date-calculator-Cc4dRqTI.js → due-date-calculator-mFxpHLml.js} +73 -49
  9. package/dist/_chunks/{editable-currency-cell-renderer-9jqwDv5x.js → editable-currency-cell-renderer-BEBUQl9P.js} +2 -2
  10. package/dist/_chunks/{freemium-paywall-BLXESpH4.js → freemium-paywall-BYist2sJ.js} +2 -2
  11. package/dist/_chunks/gestational-age-calculator-gWI_uRA1.js +203 -0
  12. package/dist/_chunks/insert-result-C5ABnzDl.js +711 -0
  13. package/dist/_chunks/{marketplace-app-shell-Dc5cTIt8.js → marketplace-app-shell-Gfsf78ge.js} +2 -2
  14. package/dist/_chunks/{patient-search-DPe2ZYEL.js → patient-search-CocVcGJ3.js} +2 -2
  15. package/dist/_chunks/{payment-form-BzVsG6Ks.js → payment-form-DqEiEJRO.js} +247 -195
  16. package/dist/_chunks/{pdf-viewer-B6MC6VTx.js → pdf-viewer-CWEXTlwq.js} +2 -2
  17. package/dist/_chunks/{practice-results-CrLpEiiW.js → practice-results-DDi-kvaD.js} +2 -2
  18. package/dist/_chunks/{pregnancy-weight-gain-zZL5Ir2-.js → pregnancy-weight-gain-BtEHaSqy.js} +78 -56
  19. package/dist/_chunks/{search-bar-CP6wUJFY.js → search-bar-CvN_S0jW.js} +2 -2
  20. package/dist/_chunks/{search-input-C1C3jQpD.js → search-input-D3aMvi4l.js} +2 -2
  21. package/dist/_chunks/{sign-document-B-3k_0LO.js → sign-document-BCyLpFHJ.js} +2 -2
  22. package/dist/_chunks/{sign-in-with-alfadocs-button-DeHBFRNS.js → sign-in-with-alfadocs-button-CuYn_kKP.js} +2 -2
  23. package/dist/_chunks/{social-sign-in-button-X54ySJr1.js → social-sign-in-button-uJYLM366.js} +2 -2
  24. package/dist/_chunks/{spinner-CCByyvcb.js → spinner-OjQNn8oN.js} +7 -3
  25. package/dist/_chunks/{transcript-panel-CR7VY1uw.js → transcript-panel-B4HiC7ed.js} +2 -2
  26. package/dist/_chunks/{unit-converter-CuXCXJhK.js → unit-converter-u3CwNDpP.js} +96 -74
  27. package/dist/_chunks/{wallet-pay-button-DK4ESYge.js → wallet-pay-button-DuDPBlCO.js} +2 -2
  28. package/dist/agent-catalog.json +1 -1
  29. package/dist/components/_shared/banded-gauge.d.ts +193 -0
  30. package/dist/components/_shared/index.d.ts +1 -1
  31. package/dist/components/_shared/insert-result.d.ts +173 -10
  32. package/dist/components/autocomplete/index.js +1 -1
  33. package/dist/components/bmi-calculator/bmi-calculator.d.ts +6 -0
  34. package/dist/components/bmi-calculator/index.js +1 -1
  35. package/dist/components/booking/index.js +1 -1
  36. package/dist/components/calculator-dialog/index.js +1 -1
  37. package/dist/components/cycle-calculator/cycle-calculator.d.ts +6 -0
  38. package/dist/components/cycle-calculator/index.js +1 -1
  39. package/dist/components/data-table/index.js +1 -1
  40. package/dist/components/dialog/dialog.d.ts +1 -0
  41. package/dist/components/dialog/index.js +1 -1
  42. package/dist/components/due-date-calculator/due-date-calculator.d.ts +6 -0
  43. package/dist/components/due-date-calculator/index.js +1 -1
  44. package/dist/components/freemium-paywall/index.js +1 -1
  45. package/dist/components/gestational-age-calculator/gestational-age-calculator.d.ts +6 -0
  46. package/dist/components/gestational-age-calculator/index.js +1 -1
  47. package/dist/components/index.d.ts +1 -1
  48. package/dist/components/patient-search/index.js +1 -1
  49. package/dist/components/payment-form/index.js +1 -1
  50. package/dist/components/payment-form/payment-form.d.ts +24 -2
  51. package/dist/components/pdf-viewer/index.js +1 -1
  52. package/dist/components/practice-results/index.js +1 -1
  53. package/dist/components/pregnancy-weight-gain/index.js +1 -1
  54. package/dist/components/pregnancy-weight-gain/pregnancy-weight-gain.d.ts +6 -0
  55. package/dist/components/search-bar/index.js +1 -1
  56. package/dist/components/search-input/index.js +1 -1
  57. package/dist/components/sign-document/index.js +1 -1
  58. package/dist/components/sign-in-with-alfadocs-button/index.js +1 -1
  59. package/dist/components/social-sign-in-button/index.js +1 -1
  60. package/dist/components/spinner/index.js +1 -1
  61. package/dist/components/spinner/spinner.d.ts +2 -2
  62. package/dist/components/transcript-panel/index.js +1 -1
  63. package/dist/components/unit-converter/index.js +1 -1
  64. package/dist/components/unit-converter/unit-converter.d.ts +6 -0
  65. package/dist/components/wallet-pay-button/index.js +1 -1
  66. package/dist/i18n/locales/ar.d.ts +1 -1
  67. package/dist/i18n/locales/ar.js +1 -1
  68. package/dist/i18n/locales/de.d.ts +1 -1
  69. package/dist/i18n/locales/de.js +1 -1
  70. package/dist/i18n/locales/el.d.ts +1 -1
  71. package/dist/i18n/locales/el.js +1 -1
  72. package/dist/i18n/locales/en.d.ts +1 -1
  73. package/dist/i18n/locales/en.js +1 -1
  74. package/dist/i18n/locales/es.d.ts +1 -1
  75. package/dist/i18n/locales/es.js +1 -1
  76. package/dist/i18n/locales/fr.d.ts +1 -1
  77. package/dist/i18n/locales/fr.js +1 -1
  78. package/dist/i18n/locales/hi.d.ts +1 -1
  79. package/dist/i18n/locales/hi.js +1 -1
  80. package/dist/i18n/locales/it.d.ts +1 -1
  81. package/dist/i18n/locales/it.js +1 -1
  82. package/dist/i18n/locales/ja.d.ts +1 -1
  83. package/dist/i18n/locales/ja.js +1 -1
  84. package/dist/i18n/locales/nl.d.ts +1 -1
  85. package/dist/i18n/locales/nl.js +1 -1
  86. package/dist/i18n/locales/pl.d.ts +1 -1
  87. package/dist/i18n/locales/pl.js +1 -1
  88. package/dist/i18n/locales/pt.d.ts +1 -1
  89. package/dist/i18n/locales/pt.js +1 -1
  90. package/dist/i18n/locales/ro.d.ts +1 -1
  91. package/dist/i18n/locales/ro.js +1 -1
  92. package/dist/i18n/locales/ru.d.ts +1 -1
  93. package/dist/i18n/locales/ru.js +1 -1
  94. package/dist/i18n/locales/sq.d.ts +1 -1
  95. package/dist/i18n/locales/sq.js +1 -1
  96. package/dist/i18n/locales/sv.d.ts +1 -1
  97. package/dist/i18n/locales/sv.js +1 -1
  98. package/dist/i18n/locales/tr.d.ts +1 -1
  99. package/dist/i18n/locales/tr.js +1 -1
  100. package/dist/i18n/locales/zh.d.ts +1 -1
  101. package/dist/i18n/locales/zh.js +1 -1
  102. package/dist/index.js +497 -496
  103. package/dist/locales/ar.json +1 -1
  104. package/dist/locales/de.json +1 -1
  105. package/dist/locales/el.json +1 -1
  106. package/dist/locales/en.json +1 -1
  107. package/dist/locales/es.json +1 -1
  108. package/dist/locales/fr.json +1 -1
  109. package/dist/locales/hi.json +1 -1
  110. package/dist/locales/it.json +1 -1
  111. package/dist/locales/ja.json +1 -1
  112. package/dist/locales/nl.json +1 -1
  113. package/dist/locales/pl.json +1 -1
  114. package/dist/locales/pt.json +1 -1
  115. package/dist/locales/ro.json +1 -1
  116. package/dist/locales/ru.json +1 -1
  117. package/dist/locales/sq.json +1 -1
  118. package/dist/locales/sv.json +1 -1
  119. package/dist/locales/tr.json +1 -1
  120. package/dist/locales/zh.json +1 -1
  121. package/dist/patterns/alia-assistant/alia-types.d.ts +20 -0
  122. package/dist/patterns/alia-assistant/index.js +1 -1
  123. package/dist/patterns/marketplace-app-shell/index.js +1 -1
  124. package/dist/tokens.css +1 -1
  125. package/package.json +1 -1
  126. package/dist/_chunks/bmi-calculator-DuVSFDuw.js +0 -259
  127. package/dist/_chunks/dialog-DOYgd75U.js +0 -224
  128. package/dist/_chunks/gestational-age-calculator-ZMSrzkRW.js +0 -179
  129. package/dist/_chunks/insert-result-DisOY2G-.js +0 -243
@@ -1,17 +1,17 @@
1
- import { jsx as t, jsxs as m, Fragment as ne } from "react/jsx-runtime";
2
- import { forwardRef as se, useState as C, useEffect as R, useRef as V, useMemo as j, useImperativeHandle as ae, useId as oe, useCallback as ie } from "react";
3
- import { c as z } from "./index-D2ZczOXr.js";
4
- import { useTranslation as q } from "react-i18next";
5
- import { S as J } from "./spinner-CCByyvcb.js";
6
- import { A as W } from "./alert-ywPR59NE.js";
7
- import { loadStripe as de } from "@stripe/stripe-js";
8
- import { Elements as ce, useStripe as le, useElements as me, PaymentElement as ue, AddressElement as pe } from "@stripe/react-stripe-js";
9
- import { u as fe } from "./registry-nPAVE19X.js";
10
- function Y() {
1
+ import { jsx as t, jsxs as m, Fragment as oe } from "react/jsx-runtime";
2
+ import { forwardRef as ie, useState as z, useEffect as D, useRef as q, useMemo as G, useImperativeHandle as de, useId as ce, useCallback as le } from "react";
3
+ import { c as R } from "./index-D2ZczOXr.js";
4
+ import { useTranslation as K } from "react-i18next";
5
+ import { S as re } from "./spinner-OjQNn8oN.js";
6
+ import { A as Q } from "./alert-ywPR59NE.js";
7
+ import { loadStripe as me } from "@stripe/stripe-js";
8
+ import { Elements as ue, useStripe as pe, useElements as fe, PaymentElement as be, AddressElement as ve } from "@stripe/react-stripe-js";
9
+ import { u as ye } from "./registry-nPAVE19X.js";
10
+ function te() {
11
11
  return typeof document < "u" && typeof window < "u";
12
12
  }
13
- function B(r) {
14
- if (!Y())
13
+ function H(r) {
14
+ if (!te())
15
15
  return { theme: "stripe" };
16
16
  const n = r ?? document.documentElement, s = getComputedStyle(n), e = (a) => s.getPropertyValue(a).trim();
17
17
  return {
@@ -69,20 +69,20 @@ function B(r) {
69
69
  }
70
70
  };
71
71
  }
72
- function be(r, n) {
73
- if (!Y()) return () => {
72
+ function ge(r, n) {
73
+ if (!te()) return () => {
74
74
  };
75
- const s = document.documentElement, e = () => r(B(n)), i = new MutationObserver(e);
76
- i.observe(s, {
75
+ const s = document.documentElement, e = () => r(H(n)), o = new MutationObserver(e);
76
+ o.observe(s, {
77
77
  attributes: !0,
78
78
  attributeFilter: ["class", "dir", "lang"]
79
79
  });
80
- const a = window.matchMedia("(prefers-color-scheme: dark)"), f = window.matchMedia("(prefers-reduced-motion: reduce)");
81
- return a.addEventListener("change", e), f.addEventListener("change", e), () => {
82
- i.disconnect(), a.removeEventListener("change", e), f.removeEventListener("change", e);
80
+ const a = window.matchMedia("(prefers-color-scheme: dark)"), c = window.matchMedia("(prefers-reduced-motion: reduce)");
81
+ return a.addEventListener("change", e), c.addEventListener("change", e), () => {
82
+ o.disconnect(), a.removeEventListener("change", e), c.removeEventListener("change", e);
83
83
  };
84
84
  }
85
- const ye = {
85
+ const he = {
86
86
  id: "payment-form",
87
87
  capabilities: ["submit"],
88
88
  state: {},
@@ -108,7 +108,7 @@ const ye = {
108
108
  description: "Sourced from the id prop."
109
109
  }
110
110
  }
111
- }, ge = /* @__PURE__ */ new Set([
111
+ }, we = /* @__PURE__ */ new Set([
112
112
  "BIF",
113
113
  "CLP",
114
114
  "DJF",
@@ -127,21 +127,21 @@ const ye = {
127
127
  "XOF",
128
128
  "XPF"
129
129
  ]);
130
- function $(r, n, s) {
131
- const e = n.toUpperCase(), i = ge.has(e) ? r : r / 100;
130
+ function O(r, n, s) {
131
+ const e = n.toUpperCase(), o = we.has(e) ? r : r / 100;
132
132
  try {
133
133
  return new Intl.NumberFormat(s, {
134
134
  style: "currency",
135
135
  currency: e
136
- }).format(i);
136
+ }).format(o);
137
137
  } catch {
138
138
  return new Intl.NumberFormat("en", {
139
139
  style: "currency",
140
140
  currency: e
141
- }).format(i);
141
+ }).format(o);
142
142
  }
143
143
  }
144
- function ve(r) {
144
+ function xe(r) {
145
145
  if (r === void 0) return null;
146
146
  const n = r.trim();
147
147
  if (n === "" || typeof window > "u") return null;
@@ -152,10 +152,10 @@ function ve(r) {
152
152
  return null;
153
153
  }
154
154
  }
155
- function X(r) {
155
+ function Ee(r) {
156
156
  return r && r.replace(/\d{4,}/g, "****");
157
157
  }
158
- function he(r) {
158
+ function Ne(r) {
159
159
  switch (r) {
160
160
  case "incorrect_number":
161
161
  case "invalid_number":
@@ -181,7 +181,7 @@ function he(r) {
181
181
  return "payment.error.generic";
182
182
  }
183
183
  }
184
- const we = z(
184
+ const ke = R(
185
185
  [
186
186
  "ds:payment-form-alfadocs ds:flex ds:flex-col",
187
187
  "ds:gap-[var(--spacing-md)]",
@@ -190,11 +190,11 @@ const we = z(
190
190
  "ds:p-[var(--spacing-md)]",
191
191
  "ds:aria-disabled:opacity-[var(--opacity-50)] ds:aria-disabled:cursor-not-allowed"
192
192
  ].join(" ")
193
- ), T = z(
193
+ ), V = R(
194
194
  ["ds:flex ds:flex-col ds:gap-[var(--spacing-xs)]"].join(" ")
195
- ), E = z(
195
+ ), F = R(
196
196
  ["type-label", "ds:text-[var(--foreground)]"].join(" ")
197
- ), Q = z(
197
+ ), ne = R(
198
198
  [
199
199
  "ds:flex ds:items-baseline ds:justify-between",
200
200
  "ds:gap-[var(--spacing-sm)]",
@@ -204,7 +204,7 @@ const we = z(
204
204
  "ds:rounded-[var(--radius-sm)]",
205
205
  "ds:text-[var(--foreground)]"
206
206
  ].join(" ")
207
- ), ee = z(
207
+ ), se = R(
208
208
  [
209
209
  "ds:inline-flex ds:items-center ds:justify-center ds:gap-[var(--spacing-xs)]",
210
210
  "ds:[min-block-size:var(--min-target-size)]",
@@ -224,143 +224,175 @@ const we = z(
224
224
  "ds:aria-busy:cursor-wait"
225
225
  ].join(" ")
226
226
  );
227
- function xe(r) {
227
+ function Ce(r) {
228
228
  const {
229
229
  amount: n,
230
230
  currency: s,
231
231
  locale: e,
232
- billingAddress: i,
232
+ billingAddress: o,
233
233
  returnUrl: a,
234
- onSuccess: f,
235
- onError: N
236
- } = r, { t: o } = q(), k = le(), S = me(), g = oe(), b = j(
237
- () => `pay-${g.replace(/[^a-zA-Z0-9-_]/g, "")}`,
238
- [g]
239
- ), F = `${b}-payment`, L = `${b}-address`, v = `${b}-error`, [u, h] = C(!1), [A, P] = C(!1), [w, x] = C(null), [U, d] = C(""), c = V(f), l = V(N);
240
- R(() => {
241
- c.current = f, l.current = N;
242
- }, [f, N]);
243
- const D = ie(
234
+ clientSecret: c,
235
+ onCreatePaymentIntent: I,
236
+ onSuccess: P,
237
+ onError: _
238
+ } = r, { t: i } = K(), h = pe(), v = fe(), w = ce(), y = G(
239
+ () => `pay-${w.replace(/[^a-zA-Z0-9-_]/g, "")}`,
240
+ [w]
241
+ ), M = `${y}-payment`, T = `${y}-address`, g = `${y}-error`, [u, x] = z(!1), [L, U] = z(!1), [E, S] = z(null), [j, l] = z(""), d = q(P), N = q(_);
242
+ D(() => {
243
+ d.current = P, N.current = _;
244
+ }, [P, _]);
245
+ const B = le(
244
246
  async (p) => {
245
- var G, H, O, K;
246
- if (p && p.preventDefault(), !k || !S || u) return;
247
- h(!0), x(null), d("");
248
- const _ = ve(a);
249
- if (a !== void 0 && _ === null) {
250
- x("payment.error.invalidReturnUrl"), d(o("payment.error.invalidReturnUrl")), (G = l.current) == null || G.call(l, {
247
+ var X, Z, J;
248
+ if (p && p.preventDefault(), !h || !v || u) return;
249
+ x(!0), S(null), l("");
250
+ const k = (f, A) => {
251
+ var Y;
252
+ const b = Ne(f), C = Ee(A ?? "");
253
+ S(b), l(i(b)), (Y = N.current) == null || Y.call(N, {
254
+ code: f,
255
+ translatedMessage: C || i(b)
256
+ });
257
+ }, $ = xe(a);
258
+ if (a !== void 0 && $ === null) {
259
+ S("payment.error.invalidReturnUrl"), l(i("payment.error.invalidReturnUrl")), (X = N.current) == null || X.call(N, {
251
260
  code: "invalid_return_url",
252
- translatedMessage: o("payment.error.invalidReturnUrl")
253
- }), h(!1);
261
+ translatedMessage: i("payment.error.invalidReturnUrl")
262
+ }), x(!1);
254
263
  return;
255
264
  }
265
+ const W = $ ? { return_url: $ } : {};
256
266
  try {
257
- const y = await k.confirmPayment({
258
- elements: S,
259
- confirmParams: _ ? { return_url: _ } : {},
260
- redirect: "if_required"
261
- });
262
- if (y.error) {
263
- const M = y.error.code ?? "generic", I = he(M), te = X(y.error.message ?? "");
264
- x(I), d(o(I)), (H = l.current) == null || H.call(l, {
265
- code: M,
266
- translatedMessage: te || o(I)
267
+ if (c !== void 0) {
268
+ const C = await h.confirmPayment({
269
+ elements: v,
270
+ confirmParams: W,
271
+ redirect: "if_required"
267
272
  });
273
+ if (C.error) {
274
+ k(C.error.code ?? "generic", C.error.message);
275
+ return;
276
+ }
277
+ C.paymentIntent && ((Z = d.current) == null || Z.call(d, C.paymentIntent.id));
278
+ return;
279
+ }
280
+ const { error: f } = await v.submit();
281
+ if (f) {
282
+ k(f.code ?? "generic", f.message);
268
283
  return;
269
284
  }
270
- y.paymentIntent && ((O = c.current) == null || O.call(c, y.paymentIntent.id));
271
- } catch (y) {
272
- const M = y instanceof Error ? y.message : "", I = X(M);
273
- x("payment.error.generic"), d(o("payment.error.generic")), (K = l.current) == null || K.call(l, {
274
- code: "unexpected",
275
- translatedMessage: I || o("payment.error.generic")
285
+ if (!I)
286
+ return;
287
+ const A = await I(), b = await h.confirmPayment({
288
+ elements: v,
289
+ clientSecret: A,
290
+ confirmParams: W,
291
+ redirect: "if_required"
276
292
  });
293
+ if (b.error) {
294
+ k(b.error.code ?? "generic", b.error.message);
295
+ return;
296
+ }
297
+ b.paymentIntent && ((J = d.current) == null || J.call(d, b.paymentIntent.id));
298
+ } catch (f) {
299
+ const A = f instanceof Error ? f.message : "";
300
+ k("unexpected", A);
277
301
  } finally {
278
- h(!1);
302
+ x(!1);
279
303
  }
280
304
  },
281
- [k, S, u, a, o]
305
+ [
306
+ h,
307
+ v,
308
+ u,
309
+ a,
310
+ c,
311
+ I,
312
+ i
313
+ ]
282
314
  );
283
- R(() => {
284
- const p = document.getElementById(b);
315
+ D(() => {
316
+ const p = document.getElementById(y);
285
317
  if (!p) return;
286
- const _ = () => {
287
- D();
318
+ const k = () => {
319
+ B();
288
320
  };
289
- return p.addEventListener("payment-form:submit", _), () => p.removeEventListener("payment-form:submit", _);
290
- }, [b, D]);
291
- const re = !k || !S || !A || u;
321
+ return p.addEventListener("payment-form:submit", k), () => p.removeEventListener("payment-form:submit", k);
322
+ }, [y, B]);
323
+ const ae = !h || !v || u || !(c === void 0 && !I) && !L;
292
324
  return /* @__PURE__ */ t(
293
325
  "form",
294
326
  {
295
- id: b,
296
- onSubmit: D,
297
- "aria-label": o("payment.ariaLabel"),
327
+ id: y,
328
+ onSubmit: B,
329
+ "aria-label": i("payment.ariaLabel"),
298
330
  "aria-busy": u || void 0,
299
331
  noValidate: !0,
300
332
  children: /* @__PURE__ */ m("div", { className: "ds:flex ds:flex-col ds:gap-[var(--spacing-md)]", children: [
301
- /* @__PURE__ */ m("div", { className: Q(), children: [
302
- /* @__PURE__ */ t("span", { className: E(), children: o("payment.amountLabel") }),
303
- /* @__PURE__ */ t("span", { className: "type-title-card", "data-testid": "payment-amount", children: $(n, s, e) })
333
+ /* @__PURE__ */ m("div", { className: ne(), children: [
334
+ /* @__PURE__ */ t("span", { className: F(), children: i("payment.amountLabel") }),
335
+ /* @__PURE__ */ t("span", { className: "type-title-card", "data-testid": "payment-amount", children: O(n, s, e) })
304
336
  ] }),
305
337
  /* @__PURE__ */ m(
306
338
  "label",
307
339
  {
308
- htmlFor: F,
309
- className: T(),
340
+ htmlFor: M,
341
+ className: V(),
310
342
  "data-testid": "payment-field",
311
343
  children: [
312
- /* @__PURE__ */ t("span", { className: E(), children: o("payment.fields.card") }),
344
+ /* @__PURE__ */ t("span", { className: F(), children: i("payment.fields.card") }),
313
345
  /* @__PURE__ */ t(
314
- ue,
346
+ be,
315
347
  {
316
- id: F,
348
+ id: M,
317
349
  options: {
318
350
  layout: { type: "accordion", defaultCollapsed: !1 }
319
351
  },
320
352
  onChange: (p) => {
321
- P(p.complete === !0), p.complete && (x(null), d(""));
353
+ U(p.complete === !0), p.complete && (S(null), l(""));
322
354
  }
323
355
  }
324
356
  )
325
357
  ]
326
358
  }
327
359
  ),
328
- i ? /* @__PURE__ */ m(
360
+ o ? /* @__PURE__ */ m(
329
361
  "label",
330
362
  {
331
- htmlFor: L,
332
- className: T(),
363
+ htmlFor: T,
364
+ className: V(),
333
365
  "data-testid": "payment-address",
334
366
  children: [
335
- /* @__PURE__ */ t("span", { className: E(), children: o("payment.billingAddress") }),
336
- /* @__PURE__ */ t(pe, { id: L, options: { mode: "billing" } })
367
+ /* @__PURE__ */ t("span", { className: F(), children: i("payment.billingAddress") }),
368
+ /* @__PURE__ */ t(ve, { id: T, options: { mode: "billing" } })
337
369
  ]
338
370
  }
339
371
  ) : null,
340
- w ? /* @__PURE__ */ t(
341
- W,
372
+ E ? /* @__PURE__ */ t(
373
+ Q,
342
374
  {
343
- id: v,
375
+ id: g,
344
376
  variant: "error",
345
377
  live: "polite",
346
378
  "data-testid": "payment-error",
347
- children: /* @__PURE__ */ t(W.Description, { children: U })
379
+ children: /* @__PURE__ */ t(Q.Description, { children: j })
348
380
  }
349
381
  ) : null,
350
382
  /* @__PURE__ */ t(
351
383
  "button",
352
384
  {
353
385
  type: "submit",
354
- "aria-disabled": re || void 0,
386
+ "aria-disabled": ae || void 0,
355
387
  "aria-busy": u || void 0,
356
- "aria-describedby": w ? v : void 0,
357
- className: ee(),
388
+ "aria-describedby": E ? g : void 0,
389
+ className: se(),
358
390
  "data-testid": "payment-submit",
359
- children: u ? /* @__PURE__ */ m(ne, { children: [
360
- /* @__PURE__ */ t(J, { size: "sm", label: o("payment.processing") }),
361
- /* @__PURE__ */ t("span", { children: o("payment.processing") })
362
- ] }) : /* @__PURE__ */ t("span", { children: o("payment.submit", {
363
- amount: $(n, s, e)
391
+ children: u ? /* @__PURE__ */ m(oe, { children: [
392
+ /* @__PURE__ */ t(re, { size: "sm", label: i("payment.processing") }),
393
+ /* @__PURE__ */ t("span", { children: i("payment.processing") })
394
+ ] }) : /* @__PURE__ */ t("span", { children: i("payment.submit", {
395
+ amount: O(n, s, e)
364
396
  }) })
365
397
  }
366
398
  )
@@ -368,7 +400,7 @@ function xe(r) {
368
400
  }
369
401
  );
370
402
  }
371
- const Z = /* @__PURE__ */ new Set([
403
+ const ee = /* @__PURE__ */ new Set([
372
404
  "auto",
373
405
  "ar",
374
406
  "bg",
@@ -420,116 +452,136 @@ const Z = /* @__PURE__ */ new Set([
420
452
  "zh-HK",
421
453
  "zh-TW"
422
454
  ]);
423
- function Ne(r) {
455
+ function Ie(r) {
424
456
  if (!r) return "auto";
425
457
  const n = r === "cn" ? "zh" : r;
426
- if (Z.has(n))
458
+ if (ee.has(n))
427
459
  return n;
428
460
  const s = n.split("-")[0];
429
- return Z.has(s) ? s : "auto";
461
+ return ee.has(s) ? s : "auto";
430
462
  }
431
- const ke = se(
463
+ const _e = ie(
432
464
  ({
433
465
  id: r,
434
466
  clientSecret: n,
435
- publishableKey: s,
436
- currency: e,
437
- amount: i,
438
- onSuccess: a,
439
- onError: f,
440
- billingAddress: N = !1,
441
- locale: o,
442
- ariaLabel: k,
443
- returnUrl: S,
444
- stripePromise: g,
445
- className: b
446
- }, F) => {
447
- const { i18n: L } = q(), v = Ne(o ?? L.language ?? "en"), [u, h] = C(g ?? null);
448
- R(() => {
449
- if (g !== void 0) {
450
- h(g);
467
+ mode: s = "payment",
468
+ onCreatePaymentIntent: e,
469
+ publishableKey: o,
470
+ currency: a,
471
+ amount: c,
472
+ onSuccess: I,
473
+ onError: P,
474
+ billingAddress: _ = !1,
475
+ locale: i,
476
+ ariaLabel: h,
477
+ returnUrl: v,
478
+ stripePromise: w,
479
+ className: y
480
+ }, M) => {
481
+ const { i18n: T } = K(), g = Ie(i ?? T.language ?? "en"), [u, x] = z(w ?? null);
482
+ D(() => {
483
+ if (w !== void 0) {
484
+ x(w);
451
485
  return;
452
486
  }
453
- if (!s) {
454
- h(null);
487
+ if (!o) {
488
+ x(null);
455
489
  return;
456
490
  }
457
- h(de(s));
458
- }, [g, s]);
459
- const [A, P] = C(
460
- () => B()
491
+ x(me(o));
492
+ }, [w, o]);
493
+ const [L, U] = z(
494
+ () => H()
461
495
  );
462
- R(() => (P(B()), be(P)), []);
463
- const w = V(null), x = j(
496
+ D(() => (U(H()), ge(U)), []);
497
+ const E = q(null), S = G(
464
498
  () => ({
465
499
  submit: async () => {
466
- var c;
467
- const d = (c = w.current) == null ? void 0 : c.querySelector("form");
468
- d && d.dispatchEvent(
500
+ var d;
501
+ const l = (d = E.current) == null ? void 0 : d.querySelector("form");
502
+ l && l.dispatchEvent(
469
503
  new CustomEvent("payment-form:submit", { bubbles: !0 })
470
504
  );
471
505
  },
472
506
  reset: () => {
473
- var c;
474
- const d = (c = w.current) == null ? void 0 : c.querySelector("form");
475
- d instanceof HTMLFormElement && d.reset();
507
+ var d;
508
+ const l = (d = E.current) == null ? void 0 : d.querySelector("form");
509
+ l instanceof HTMLFormElement && l.reset();
476
510
  }
477
511
  }),
478
512
  []
479
513
  );
480
- ae(F, () => w.current, []), fe(ye, x, r);
481
- const U = j(
482
- () => ({
483
- clientSecret: n,
484
- appearance: A,
485
- locale: v
486
- }),
487
- [n, A, v]
514
+ de(M, () => E.current, []), ye(he, S, r);
515
+ const j = G(
516
+ () => n !== void 0 ? (
517
+ // Immediate mode — the consumer already created the intent.
518
+ { clientSecret: n, appearance: L, locale: g }
519
+ ) : (
520
+ // Deferred-intent mode — no secret yet; Stripe needs the intent
521
+ // shape (mode + amount + currency) to render the Payment Element.
522
+ // Stripe expects a lowercase ISO-4217 currency here.
523
+ {
524
+ mode: s,
525
+ amount: c,
526
+ currency: a.toLowerCase(),
527
+ appearance: L,
528
+ locale: g
529
+ }
530
+ ),
531
+ [n, s, c, a, L, g]
488
532
  );
489
533
  return /* @__PURE__ */ t(
490
534
  "div",
491
535
  {
492
- ref: w,
493
- "aria-label": k,
494
- className: [we(), b].filter(Boolean).join(" "),
536
+ ref: E,
537
+ "aria-label": h,
538
+ className: [ke(), y].filter(Boolean).join(" "),
495
539
  "data-component": "payment-form",
496
540
  "data-component-id": r,
497
541
  "data-testid": "payment-form-root",
498
- children: u && n ? /* @__PURE__ */ t(
499
- ce,
500
- {
501
- stripe: u,
502
- options: U,
503
- children: /* @__PURE__ */ t(
504
- xe,
505
- {
506
- amount: i,
507
- currency: e,
508
- locale: v,
509
- billingAddress: N,
510
- returnUrl: S,
511
- onSuccess: a,
512
- onError: f
513
- }
514
- )
515
- },
516
- n
542
+ children: u ? (
543
+ // Render the real Payment Element whenever a Stripe instance is
544
+ // available — in immediate mode (clientSecret present) AND in
545
+ // deferred mode (no secret). The skeleton is reserved for the
546
+ // no-Stripe case (missing publishableKey / injected null).
547
+ /* @__PURE__ */ t(
548
+ ue,
549
+ {
550
+ stripe: u,
551
+ options: j,
552
+ children: /* @__PURE__ */ t(
553
+ Ce,
554
+ {
555
+ amount: c,
556
+ currency: a,
557
+ locale: g,
558
+ billingAddress: _,
559
+ returnUrl: v,
560
+ clientSecret: n,
561
+ onCreatePaymentIntent: e,
562
+ onSuccess: I,
563
+ onError: P
564
+ }
565
+ )
566
+ },
567
+ n ?? "deferred"
568
+ )
517
569
  ) : /* @__PURE__ */ t(
518
570
  Se,
519
571
  {
520
- amount: i,
521
- currency: e,
522
- locale: v,
523
- billingAddress: N
572
+ amount: c,
573
+ currency: a,
574
+ locale: g,
575
+ billingAddress: _
524
576
  }
525
577
  )
526
578
  }
527
579
  );
528
580
  }
529
581
  );
530
- ke.displayName = "PaymentForm";
582
+ _e.displayName = "PaymentForm";
531
583
  function Se(r) {
532
- const { amount: n, currency: s, locale: e, billingAddress: i } = r, { t: a } = q();
584
+ const { amount: n, currency: s, locale: e, billingAddress: o } = r, { t: a } = K();
533
585
  return /* @__PURE__ */ m(
534
586
  "div",
535
587
  {
@@ -537,12 +589,12 @@ function Se(r) {
537
589
  "data-testid": "payment-skeleton",
538
590
  "aria-busy": "true",
539
591
  children: [
540
- /* @__PURE__ */ m("div", { className: Q(), children: [
541
- /* @__PURE__ */ t("span", { className: E(), children: a("payment.amountLabel") }),
542
- /* @__PURE__ */ t("span", { className: "type-title-card", children: $(n, s, e) })
592
+ /* @__PURE__ */ m("div", { className: ne(), children: [
593
+ /* @__PURE__ */ t("span", { className: F(), children: a("payment.amountLabel") }),
594
+ /* @__PURE__ */ t("span", { className: "type-title-card", children: O(n, s, e) })
543
595
  ] }),
544
- /* @__PURE__ */ m("div", { className: T(), children: [
545
- /* @__PURE__ */ t("span", { className: E(), children: a("payment.fields.card") }),
596
+ /* @__PURE__ */ m("div", { className: V(), children: [
597
+ /* @__PURE__ */ t("span", { className: F(), children: a("payment.fields.card") }),
546
598
  /* @__PURE__ */ t(
547
599
  "div",
548
600
  {
@@ -551,8 +603,8 @@ function Se(r) {
551
603
  }
552
604
  )
553
605
  ] }),
554
- i ? /* @__PURE__ */ m("div", { className: T(), "data-testid": "payment-address", children: [
555
- /* @__PURE__ */ t("span", { className: E(), children: a("payment.billingAddress") }),
606
+ o ? /* @__PURE__ */ m("div", { className: V(), "data-testid": "payment-address", children: [
607
+ /* @__PURE__ */ t("span", { className: F(), children: a("payment.billingAddress") }),
556
608
  /* @__PURE__ */ t(
557
609
  "div",
558
610
  {
@@ -566,10 +618,10 @@ function Se(r) {
566
618
  {
567
619
  type: "button",
568
620
  "aria-disabled": "true",
569
- className: ee(),
621
+ className: se(),
570
622
  disabled: !0,
571
623
  children: [
572
- /* @__PURE__ */ t(J, { size: "sm", label: a("payment.processing") }),
624
+ /* @__PURE__ */ t(re, { size: "sm", label: a("payment.processing") }),
573
625
  /* @__PURE__ */ t("span", { children: a("payment.processing") })
574
626
  ]
575
627
  }
@@ -579,12 +631,12 @@ function Se(r) {
579
631
  );
580
632
  }
581
633
  export {
582
- ke as P,
583
- we as a,
584
- X as b,
585
- he as c,
586
- $ as f,
587
- ye as p,
588
- ee as s
634
+ _e as P,
635
+ ke as a,
636
+ Ee as b,
637
+ Ne as c,
638
+ O as f,
639
+ he as p,
640
+ se as s
589
641
  };
590
- //# sourceMappingURL=payment-form-BzVsG6Ks.js.map
642
+ //# sourceMappingURL=payment-form-DqEiEJRO.js.map