@tesouro/embedded-components-react 0.3.35 → 0.3.37

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 (23) hide show
  1. package/README.md +10 -10
  2. package/dist/index.d.ts +15 -0
  3. package/dist/lib/CardDetailsWidget.d.ts +15 -0
  4. package/dist/lib/CardsWidget.d.ts +15 -0
  5. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/data-access/dist/index5.js +33 -31
  6. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index6.js +5 -9
  7. package/dist/libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index7.js +98 -92
  8. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index.js +3 -2
  9. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index5.js +16 -9
  10. package/dist/libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index6.js +25 -0
  11. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index3.js +21 -2
  12. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index4.js +9 -2
  13. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index5.js +1 -0
  14. package/dist/libs/tesouro-embedded-components-react/card-details-widget/feature/dist/index6.js +115 -59
  15. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +21 -19
  16. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/apiErrorStatus.js +26 -0
  17. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/isApiForbiddenError.js +7 -0
  18. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/isApiNotFoundError.js +4 -23
  19. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/isUserDataNotFoundError.js +7 -6
  20. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +177 -166
  21. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +139 -127
  22. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  23. package/package.json +1 -1
package/README.md CHANGED
@@ -272,19 +272,19 @@ One page of an organization's credit **or** debit cards, with a scope-gated "Sho
272
272
 
273
273
  ### CardDetailsWidget
274
274
 
275
- Read-only details for one credit **or** debit card — status, form factor, program, masked card number, and copyable cardholder and nickname rows. It renders panel content rather than its own drawer, so it sits on a page of your own as readily as inside chrome you already have.
275
+ Read-only details for one credit **or** debit card — status, form factor, program, masked card number, and copyable cardholder and nickname rows. A debit card can also reveal its number, expiry and security code on demand. It renders panel content rather than its own drawer, so it sits on a page of your own as readily as inside chrome you already have.
276
276
 
277
277
  #### Props
278
278
 
279
- | Prop | Type | Default | Description |
280
- | ---------------- | --------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
281
- | `cardId` | `string` | **Required** | Id of the card to show. |
282
- | `cardProgram` | `'credit' \| 'debit'` | **Required** | Which issuing program `cardId` belongs to. Selects the endpoint the card is fetched from. |
283
- | `onClose` | `() => void` | `undefined` | Called when the header's close control is pressed. Omit it and no close control is rendered at all. |
284
- | `labels` | `PartialDeep<CardDetailsWidgetLabels>` | English labels | Overrides the panel's own copy — header, card face alt text, row headings, copy-button accessible names, and the loading/error/not-found screens. |
285
- | `featureLabels` | `PartialDeep<CardDetailsFeatureLabels>` | English labels | Overrides the copy this widget resolves rather than passes through — status, form-factor and program vocabulary, plus the copy-success toast. |
286
- | `bankLogoSrc` | `string` | `undefined` | Bank logo for the card face. Omit and the face renders without a logo rather than with a placeholder. |
287
- | `bankLogoAlt` | `string` | `undefined` | Alt text for `bankLogoSrc`. Falls back to `labels.cardFace.bankLogoAlt`. |
279
+ | Prop | Type | Default | Description |
280
+ | ---------------- | --------------------------------------- | -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
281
+ | `cardId` | `string` | **Required** | Id of the card to show. |
282
+ | `cardProgram` | `'credit' \| 'debit'` | **Required** | Which issuing program `cardId` belongs to. Selects the endpoint the card is fetched from. |
283
+ | `onClose` | `() => void` | `undefined` | Called when the header's close control is pressed. Omit it and no close control is rendered at all. |
284
+ | `labels` | `PartialDeep<CardDetailsWidgetLabels>` | English labels | Overrides the panel's own copy — header, card face alt text, row headings, copy-button accessible names, and the loading/error/not-found screens. |
285
+ | `featureLabels` | `PartialDeep<CardDetailsFeatureLabels>` | English labels | Overrides the copy this widget resolves rather than passes through — status, form-factor and program vocabulary, the copy-success toast, and the refused-reveal sentence. |
286
+ | `bankLogoSrc` | `string` | `undefined` | Bank logo for the card face. Omit and the face renders without a logo rather than with a placeholder. |
287
+ | `bankLogoAlt` | `string` | `undefined` | Alt text for `bankLogoSrc`. Falls back to `labels.cardFace.bankLogoAlt`. |
288
288
 
289
289
  ### CreateCardWidget
290
290
 
package/dist/index.d.ts CHANGED
@@ -2235,6 +2235,21 @@ type PartialDeep$3<T> = {
2235
2235
  interface CardDetailsFeatureLabels {
2236
2236
  /** Confirmation toast after a copy affordance writes to the clipboard. */
2237
2237
  copySuccessToast: string;
2238
+ /**
2239
+ * Replaces the panel's generic reveal error when the credentials call was
2240
+ * refused (HTTP 403).
2241
+ *
2242
+ * It lives here rather than on the panel because deciding that a failure was a
2243
+ * refusal means reading the error, which is this layer's job — the panel is
2244
+ * handed one already-chosen sentence either way, and its own
2245
+ * `credentials.errorDescription` still covers every other failure.
2246
+ *
2247
+ * The wording deliberately does not tell the reader to ask for a permission.
2248
+ * Reading a debit card and reading its credentials take the same scope, so a
2249
+ * reader looking at this panel already holds it; a 403 here means the call was
2250
+ * refused for this session, which asking an admin for a role will not fix.
2251
+ */
2252
+ revealNotPermittedDescription: string;
2238
2253
  /** Program wording on the card face, keyed on the widget's `cardProgram`. */
2239
2254
  programLabels: Record<CardProgram, string>;
2240
2255
  /** Status badge wording, keyed on the generated card status. */
@@ -764,6 +764,21 @@ type PartialDeep<T> = {
764
764
  interface CardDetailsFeatureLabels {
765
765
  /** Confirmation toast after a copy affordance writes to the clipboard. */
766
766
  copySuccessToast: string;
767
+ /**
768
+ * Replaces the panel's generic reveal error when the credentials call was
769
+ * refused (HTTP 403).
770
+ *
771
+ * It lives here rather than on the panel because deciding that a failure was a
772
+ * refusal means reading the error, which is this layer's job — the panel is
773
+ * handed one already-chosen sentence either way, and its own
774
+ * `credentials.errorDescription` still covers every other failure.
775
+ *
776
+ * The wording deliberately does not tell the reader to ask for a permission.
777
+ * Reading a debit card and reading its credentials take the same scope, so a
778
+ * reader looking at this panel already holds it; a 403 here means the call was
779
+ * refused for this session, which asking an admin for a role will not fix.
780
+ */
781
+ revealNotPermittedDescription: string;
767
782
  /** Program wording on the card face, keyed on the widget's `cardProgram`. */
768
783
  programLabels: Record<CardProgram, string>;
769
784
  /** Status badge wording, keyed on the generated card status. */
@@ -851,6 +851,21 @@ type PartialDeep$2<T> = {
851
851
  interface CardDetailsFeatureLabels {
852
852
  /** Confirmation toast after a copy affordance writes to the clipboard. */
853
853
  copySuccessToast: string;
854
+ /**
855
+ * Replaces the panel's generic reveal error when the credentials call was
856
+ * refused (HTTP 403).
857
+ *
858
+ * It lives here rather than on the panel because deciding that a failure was a
859
+ * refusal means reading the error, which is this layer's job — the panel is
860
+ * handed one already-chosen sentence either way, and its own
861
+ * `credentials.errorDescription` still covers every other failure.
862
+ *
863
+ * The wording deliberately does not tell the reader to ask for a permission.
864
+ * Reading a debit card and reading its credentials take the same scope, so a
865
+ * reader looking at this panel already holds it; a 403 here means the call was
866
+ * refused for this session, which asking an admin for a role will not fix.
867
+ */
868
+ revealNotPermittedDescription: string;
854
869
  /** Program wording on the card face, keyed on the widget's `cardProgram`. */
855
870
  programLabels: Record<CardProgram, string>;
856
871
  /** Status badge wording, keyed on the generated card status. */
@@ -12,17 +12,18 @@ import { useEffect as a, useMemo as o } from "react";
12
12
  import { useInfiniteQuery as s } from "@tanstack/react-query";
13
13
  //#region ../../libs/tesouro-embedded-components-react/bank-accounts-widget/data-access/dist/index5.js
14
14
  var c = 100, l = ["ACTIVE", "INVITED"];
15
- function u(l, u) {
16
- let { client: d, organizationId: f, authEpoch: p } = e(), m = t(f), h = r({
17
- client: d,
18
- headers: m,
15
+ function u(l, u, d) {
16
+ let { client: f, organizationId: p, authEpoch: m } = e(), h = t(p), g = d?.length ? { Permissions: d } : {}, _ = r({
17
+ client: f,
18
+ headers: h,
19
19
  query: {
20
20
  Status: l,
21
- Limit: c
21
+ Limit: c,
22
+ ...g
22
23
  }
23
- }), g = s({
24
+ }), v = s({
24
25
  queryKey: [
25
- ...i(h, p).queryKey,
26
+ ...i(_, m).queryKey,
26
27
  "all",
27
28
  l
28
29
  ],
@@ -30,11 +31,12 @@ function u(l, u) {
30
31
  initialPageParam: void 0,
31
32
  queryFn: async ({ signal: e, pageParam: t }) => {
32
33
  let { data: r } = await n({
33
- client: d,
34
- headers: m,
34
+ client: f,
35
+ headers: h,
35
36
  query: {
36
37
  Status: l,
37
38
  Limit: c,
39
+ ...g,
38
40
  ...t ? { PaginationToken: t } : {}
39
41
  },
40
42
  signal: e,
@@ -48,31 +50,31 @@ function u(l, u) {
48
50
  }
49
51
  });
50
52
  a(() => {
51
- !u || !g.hasNextPage || g.isFetchingNextPage || g.isError || g.fetchNextPage();
53
+ !u || !v.hasNextPage || v.isFetchingNextPage || v.isError || v.fetchNextPage();
52
54
  }, [
53
55
  u,
54
- g.hasNextPage,
55
- g.isFetchingNextPage,
56
- g.isError,
57
- g.fetchNextPage
56
+ v.hasNextPage,
57
+ v.isFetchingNextPage,
58
+ v.isError,
59
+ v.fetchNextPage
58
60
  ]);
59
- let _ = o(() => {
60
- if (g.data) return {
61
- data: g.data.pages.flatMap((e) => e.data ?? []),
61
+ let y = o(() => {
62
+ if (v.data) return {
63
+ data: v.data.pages.flatMap((e) => e.data ?? []),
62
64
  nextPaginationToken: null,
63
65
  prevPaginationToken: null
64
66
  };
65
- }, [g.data]);
67
+ }, [v.data]);
66
68
  return {
67
- ...g,
68
- data: _
69
+ ...v,
70
+ data: y
69
71
  };
70
72
  }
71
- function d({ enabled: t } = {}) {
72
- let { organizationId: n, widgetToken: r } = e(), i = !!(n && r) && (t === !0 || t === void 0), a = u("ACTIVE", i), s = u("INVITED", i), c = o(() => {
73
+ function d({ enabled: t, permissions: n } = {}) {
74
+ let { organizationId: r, widgetToken: i } = e(), a = !!(r && i) && (t === !0 || t === void 0), s = u("ACTIVE", a, n), c = u("INVITED", a, n), d = o(() => {
73
75
  let e = /* @__PURE__ */ new Map();
74
76
  for (let t of l) {
75
- let n = t === "ACTIVE" ? a.data?.data ?? [] : s.data?.data ?? [];
77
+ let n = t === "ACTIVE" ? s.data?.data ?? [] : c.data?.data ?? [];
76
78
  for (let t of n) e.set(t.id, t);
77
79
  }
78
80
  return {
@@ -80,15 +82,15 @@ function d({ enabled: t } = {}) {
80
82
  nextPaginationToken: null,
81
83
  prevPaginationToken: null
82
84
  };
83
- }, [a.data, s.data]), d = a.isLoading || s.isLoading, f = a.isFetchingNextPage || s.isFetchingNextPage, p = a.hasNextPage || s.hasNextPage, m = a.isError || s.isError;
85
+ }, [s.data, c.data]), f = s.isLoading || c.isLoading, p = s.isFetchingNextPage || c.isFetchingNextPage, m = s.hasNextPage || c.hasNextPage, h = s.isError || c.isError;
84
86
  return {
85
- ...a,
86
- data: c,
87
- isLoading: d,
88
- isFetchingNextPage: f,
89
- hasNextPage: p,
90
- isError: m,
91
- isSuccess: a.isSuccess && s.isSuccess
87
+ ...s,
88
+ data: d,
89
+ isLoading: f,
90
+ isFetchingNextPage: p,
91
+ hasNextPage: m,
92
+ isError: h,
93
+ isSuccess: s.isSuccess && c.isSuccess
92
94
  };
93
95
  }
94
96
  //#endregion
@@ -26,25 +26,21 @@ function r(e, n) {
26
26
  if (r) return e.find((e) => e.key.toLowerCase() === r.toLowerCase())?.description;
27
27
  }
28
28
  function i(e) {
29
- let t = e?.trim().toLowerCase() ?? "", n = t.includes(":") ? t.slice(t.lastIndexOf(":") + 1) : t;
30
- return n === "admin" || n === "administrator";
31
- }
32
- function a(e) {
33
29
  return e.trim() ? e.split("_").filter(Boolean).map((e) => e.length <= 3 && e === e.toUpperCase() ? e.toUpperCase() : e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "";
34
30
  }
35
- function o(e, o) {
31
+ function a(e, a, o) {
36
32
  return e.map((e) => {
37
- let s = e.role ?? "", c = t(o, s) || s.trim(), l = n(o, s) || a(c), u = r(o, s) ?? "";
33
+ let s = e.role ?? "", c = t(a, s) || s.trim(), l = n(a, s) || i(c), u = r(a, s) ?? "";
38
34
  return {
39
35
  id: e.id,
40
36
  name: e.name,
41
37
  role: l,
42
38
  roleDescription: u,
43
- locked: i(c) || i(s)
39
+ locked: o.has(e.id)
44
40
  };
45
41
  });
46
42
  }
47
- function s(e, { selectedUserIds: t, disabled: n, fallbackTooltip: r, onUserToggle: i }) {
43
+ function o(e, { selectedUserIds: t, disabled: n, fallbackTooltip: r, onUserToggle: i }) {
48
44
  return e.map((e) => ({
49
45
  key: e.id,
50
46
  name: e.name,
@@ -58,4 +54,4 @@ function s(e, { selectedUserIds: t, disabled: n, fallbackTooltip: r, onUserToggl
58
54
  }));
59
55
  }
60
56
  //#endregion
61
- export { i as isAdminRoleKey, r as resolveOrganizationRoleDescription, n as resolveOrganizationRoleDisplayName, t as resolveOrganizationRoleKey, s as toAccessRows, e as toOrganizationRoleOptions, o as toTeamMembers };
57
+ export { r as resolveOrganizationRoleDescription, n as resolveOrganizationRoleDisplayName, t as resolveOrganizationRoleKey, o as toAccessRows, e as toOrganizationRoleOptions, a as toTeamMembers };
@@ -3,53 +3,55 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { useAllBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
7
- import { useAllOrganizationRolesQuery as n } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
6
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
+ import { useAllBankAccountsQuery as n } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
8
+ import { useAllOrganizationRolesQuery as r } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
9
+ import "../../../shared/data-access/dist/index.js";
8
10
  import "../../../shared/ui/dist/index.js";
9
- import { useAnalyticsTrack as r } from "../../../shared/feature/dist/lib/analytics/hooks.js";
10
- import { TESOURO_NEW_EMBEDDED_BANK_ACCOUNT_CREATED_SUCCESS_EVENT as ee, emitWidgetDomEvent as te } from "../../../shared/util/dist/lib/widgetDomEvents.js";
11
- import { useWidgetConfig as ne, useWidgetError as re, useWidgetLoading as ie } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
+ import { useAnalyticsTrack as ee } from "../../../shared/feature/dist/lib/analytics/hooks.js";
12
+ import { TESOURO_NEW_EMBEDDED_BANK_ACCOUNT_CREATED_SUCCESS_EVENT as te, emitWidgetDomEvent as ne } from "../../../shared/util/dist/lib/widgetDomEvents.js";
13
+ import { useWidgetConfig as re, useWidgetError as ie, useWidgetLoading as ae } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
14
  import "../../../shared/feature/dist/index.js";
13
15
  import { BankAccountsWidgetAnalyticsEvent as i } from "./index2.js";
14
- import { copyTextToClipboard as ae, formatAmountLabel as a, formatTotalAvailableBalanceLabel as oe, maskAccountNumber as o } from "./index3.js";
15
- import { DEFAULT_FEATURE_LABELS as se } from "./index4.js";
16
- import { getBankAccountsPermissions as ce } from "./index5.js";
17
- import { toAccessRows as le, toOrganizationRoleOptions as ue, toTeamMembers as de } from "./index6.js";
18
- import { DEFAULT_LABELS as fe } from "../../ui/dist/lib/labels.js";
16
+ import { copyTextToClipboard as oe, formatAmountLabel as a, formatTotalAvailableBalanceLabel as se, maskAccountNumber as o } from "./index3.js";
17
+ import { DEFAULT_FEATURE_LABELS as ce } from "./index4.js";
18
+ import { getBankAccountsPermissions as le } from "./index5.js";
19
+ import { toAccessRows as ue, toOrganizationRoleOptions as de, toTeamMembers as fe } from "./index6.js";
20
+ import { DEFAULT_LABELS as pe } from "../../ui/dist/lib/labels.js";
19
21
  import "../../ui/dist/index.js";
20
- import { useCreateBankAccountMutation as pe } from "../../data-access/dist/index3.js";
21
- import { useGrantBankAccountAccessMutation as me } from "../../data-access/dist/index4.js";
22
- import { useAllOrganizationUsersQuery as he } from "../../data-access/dist/index5.js";
22
+ import { useCreateBankAccountMutation as me } from "../../data-access/dist/index3.js";
23
+ import { useGrantBankAccountAccessMutation as he } from "../../data-access/dist/index4.js";
24
+ import { useAllOrganizationUsersQuery as s } from "../../data-access/dist/index5.js";
23
25
  import "../../data-access/dist/index.js";
24
26
  import { filterRolesForOrganization as ge } from "../../../../shared/util-validation/dist/index6.js";
25
- import { useCallback as _e, useEffect as s, useMemo as c, useRef as ve, useState as l } from "react";
26
- import { useControllableState as ye } from "@radix-ui/react-use-controllable-state";
27
+ import { useCallback as _e, useEffect as ve, useMemo as c, useRef as ye, useState as l } from "react";
28
+ import { useControllableState as be } from "@radix-ui/react-use-controllable-state";
27
29
  //#region ../../libs/tesouro-embedded-components-react/bank-accounts-widget/feature/dist/index7.js
28
- var u = { nickname: "" };
30
+ var u = { nickname: "" }, xe = t.BankAccountWriteOrg;
29
31
  function d(e, t) {
30
32
  return e !== void 0 && t !== void 0 && e !== t;
31
33
  }
32
- function f({ labels: a, featureLabels: o, isBankingTaglineVisible: f = !0, bankLogoSrc: xe, bankLogoAlt: Se, depositAgreementUrl: Ce, selectedAccountId: we, defaultSelectedAccountId: Te, onSelectedAccountIdChange: Ee, "data-testid": De } = {}) {
33
- let Oe = {
34
- ...fe,
35
- ...a
34
+ function f({ labels: t, featureLabels: a, isBankingTaglineVisible: o = !0, bankLogoSrc: f, bankLogoAlt: Ce, depositAgreementUrl: we, selectedAccountId: Te, defaultSelectedAccountId: Ee, onSelectedAccountIdChange: De, "data-testid": Oe } = {}) {
35
+ let ke = {
36
+ ...pe,
37
+ ...t
36
38
  }, p = {
37
- ...se,
38
- ...o
39
- }, m = r(), { organizationId: h, widgetToken: ke, initResponse: g } = ne(), Ae = ie(), _ = !!re(), v = !!(h && ke), y = c(() => ce(g?.scopes), [g?.scopes]), je = v && y.canRead && !!g, b = g?.userId ?? void 0, [x, Me] = l(h);
40
- h !== void 0 && h !== x && Me(h);
41
- let [S, Ne] = l(b);
42
- b !== void 0 && b !== S && Ne(b);
43
- let [Pe, C] = ye({
44
- prop: we,
45
- defaultProp: Te ?? null,
46
- onChange: Ee,
39
+ ...ce,
40
+ ...a
41
+ }, m = ee(), { organizationId: h, widgetToken: Ae, initResponse: g } = re(), je = ae(), _ = !!ie(), v = !!(h && Ae), y = c(() => le(g?.scopes), [g?.scopes]), Me = v && y.canRead && !!g, b = g?.userId ?? void 0, [x, Ne] = l(h);
42
+ h !== void 0 && h !== x && Ne(h);
43
+ let [S, Pe] = l(b);
44
+ b !== void 0 && b !== S && Pe(b);
45
+ let [Fe, C] = be({
46
+ prop: Te,
47
+ defaultProp: Ee ?? null,
48
+ onChange: De,
47
49
  caller: "BankAccountsWidget"
48
- }), w = ve({
50
+ }), w = ye({
49
51
  organizationId: x,
50
52
  userId: S
51
- }), Fe = d(w.current.organizationId, x) || d(w.current.userId, S);
52
- s(() => {
53
+ }), Ie = d(w.current.organizationId, x) || d(w.current.userId, S);
54
+ ve(() => {
53
55
  let e = w.current;
54
56
  w.current = {
55
57
  organizationId: x,
@@ -60,63 +62,67 @@ function f({ labels: a, featureLabels: o, isBankingTaglineVisible: f = !0, bankL
60
62
  S,
61
63
  C
62
64
  ]);
63
- let T = Fe ? null : Pe, E = je && !T, D = _e((e) => {
65
+ let T = Ie ? null : Fe, E = Me && !T, D = _e((e) => {
64
66
  C(e);
65
- }, [C]), [O, k] = l(!1), [A, j] = l(u), [M, N] = l([]), [Ie, P] = l(!1), [F, I] = l(), [Le, Re] = l({}), [L, R] = l({});
66
- s(() => {
67
+ }, [C]), [O, k] = l(!1), [A, j] = l(u), [M, N] = l([]), [Le, P] = l(!1), [F, I] = l(), [L, Re] = l({}), [R, z] = l({});
68
+ ve(() => {
67
69
  m(i.Mounted);
68
70
  }, [m]);
69
- let z = t({ enabled: E }), B = pe(), V = me(), H = O, U = he({ enabled: H }), W = n({ enabled: H }), G = c(() => {
70
- let e = W.data?.data ?? [], t = h ? ge(e, {
71
+ let B = n({ enabled: E }), V = me(), H = he(), U = O, W = s({ enabled: U }), G = r({ enabled: U }), K = s({
72
+ enabled: U,
73
+ permissions: [xe]
74
+ }), ze = c(() => new Set((K.data?.data ?? []).filter((e) => e.organizationId === h).map((e) => e.id)), [K.data?.data, h]), q = c(() => {
75
+ let e = G.data?.data ?? [], t = h ? ge(e, {
71
76
  organizationId: h,
72
77
  organizationTypes: g?.organizationTypes ?? []
73
78
  }) : e;
74
- return de(U.data?.data ?? [], ue(t));
79
+ return fe(W.data?.data ?? [], de(t), ze);
75
80
  }, [
81
+ ze,
82
+ G.data?.data,
76
83
  W.data?.data,
77
- U.data?.data,
78
84
  h,
79
85
  g?.organizationTypes
80
- ]), K = U.isLoading || U.isFetchingNextPage || !!U.hasNextPage || W.isResolving, q = !K && !U.isError, J = E ? z.data?.data ?? [] : [], Y = [.../* @__PURE__ */ new Set([...G.filter((e) => e.locked).map((e) => e.id), ...M])], X = g?.bankName?.trim() ?? "", ze = g?.vspName?.trim() ?? "", Be = Ce?.trim() || void 0, Z = v && y.canWrite, Q = !z.hasNextPage && !z.isFetchingNextPage, Ve = c(() => Q ? oe(J) : void 0, [J, Q]), He = J.length > 1 && y.canRead && Q, $ = _e(async (t, n, r) => {
81
- await ae(r) && (e.success(n === "account" ? p.copyAccountNumberToast : p.copyRoutingNumberToast), R((e) => ({
86
+ ]), Be = W.isLoading || W.isFetchingNextPage || !!W.hasNextPage || G.isResolving || K.isLoading || K.isFetchingNextPage || !!K.hasNextPage, Ve = !Be && !W.isError && !K.isError, J = E ? B.data?.data ?? [] : [], Y = [.../* @__PURE__ */ new Set([...q.filter((e) => e.locked).map((e) => e.id), ...M])], He = g?.bankName?.trim() ?? "", Ue = g?.vspName?.trim() ?? "", We = we?.trim() || void 0, X = v && y.canWrite, Z = !B.hasNextPage && !B.isFetchingNextPage, Ge = c(() => Z ? se(J) : void 0, [J, Z]), Ke = J.length > 1 && y.canRead && Z, Q = _e(async (t, n, r) => {
87
+ await oe(r) && (e.success(n === "account" ? p.copyAccountNumberToast : p.copyRoutingNumberToast), z((e) => ({
82
88
  ...e,
83
89
  [t]: n
84
90
  })), window.setTimeout(() => {
85
- R((e) => ({
91
+ z((e) => ({
86
92
  ...e,
87
93
  [t]: void 0
88
94
  }));
89
95
  }, 2e3));
90
- }, [p.copyAccountNumberToast, p.copyRoutingNumberToast]), Ue = c(() => J.map((e) => be(e, p, {
91
- isAccountNumberVisible: Le[e.id] ?? !1,
92
- isAccountNumberCopied: L[e.id] === "account",
93
- isRoutingNumberCopied: L[e.id] === "routing",
96
+ }, [p.copyAccountNumberToast, p.copyRoutingNumberToast]), qe = c(() => J.map((e) => Se(e, p, {
97
+ isAccountNumberVisible: L[e.id] ?? !1,
98
+ isAccountNumberCopied: R[e.id] === "account",
99
+ isRoutingNumberCopied: R[e.id] === "routing",
94
100
  onToggleAccountNumberVisibility: () => Re((t) => ({
95
101
  ...t,
96
102
  [e.id]: !t[e.id]
97
103
  })),
98
- onCopyAccountNumber: () => void $(e.id, "account", e.accountNumber),
99
- onCopyRoutingNumber: () => void $(e.id, "routing", e.routingNumber),
104
+ onCopyAccountNumber: () => void Q(e.id, "account", e.accountNumber),
105
+ onCopyRoutingNumber: () => void Q(e.id, "routing", e.routingNumber),
100
106
  onSelect: () => {
101
107
  D(e.id), m(i.AccountSelected, { accountId: e.id });
102
108
  }
103
109
  })), [
104
110
  J,
105
- Le,
106
111
  L,
112
+ R,
107
113
  p,
108
- $,
114
+ Q,
109
115
  D,
110
116
  m
111
- ]), We = (t) => {
112
- V.mutate({
117
+ ]), Je = (t) => {
118
+ H.mutate({
113
119
  path: { id: t },
114
120
  body: { userIds: Y }
115
121
  }, { onSuccess: () => {
116
- te(ee), e.success(p.createSuccessToast), j(u), N([]), I(void 0), P(!1), k(!1);
122
+ ne(te), e.success(p.createSuccessToast), j(u), N([]), I(void 0), P(!1), k(!1);
117
123
  } });
118
- }, Ge = () => {
119
- if (Z && q) {
124
+ }, Ye = () => {
125
+ if (X && Ve) {
120
126
  if (A.nickname.trim() === "") {
121
127
  P(!0);
122
128
  return;
@@ -126,61 +132,61 @@ function f({ labels: a, featureLabels: o, isBankingTaglineVisible: f = !0, bankL
126
132
  return;
127
133
  }
128
134
  if (F) {
129
- We(F);
135
+ Je(F);
130
136
  return;
131
137
  }
132
- B.mutate({ body: { nickname: A.nickname.trim() } }, { onSuccess: (e) => {
133
- m(i.AccountCreated, { accountId: e?.id }), e?.id && (I(e.id), We(e.id));
138
+ V.mutate({ body: { nickname: A.nickname.trim() } }, { onSuccess: (e) => {
139
+ m(i.AccountCreated, { accountId: e?.id }), e?.id && (I(e.id), Je(e.id));
134
140
  } });
135
141
  }
136
- }, Ke = (e, t) => {
137
- G.find((t) => t.id === e)?.locked || N((n) => t ? [.../* @__PURE__ */ new Set([...n, e])] : n.filter((t) => t !== e));
138
- }, qe = (e) => {
139
- e && !Z || (e && (j(u), N([]), I(void 0), P(!1), B.reset(), V.reset()), k(e));
140
- }, Je = B.isPending || V.isPending, Ye = le(G, {
142
+ }, Xe = (e, t) => {
143
+ q.find((t) => t.id === e)?.locked || N((n) => t ? [.../* @__PURE__ */ new Set([...n, e])] : n.filter((t) => t !== e));
144
+ }, Ze = (e) => {
145
+ e && !X || (e && (j(u), N([]), I(void 0), P(!1), V.reset(), H.reset()), k(e));
146
+ }, $ = V.isPending || H.isPending, Qe = ue(q, {
141
147
  selectedUserIds: M,
142
- disabled: Je || !y.canWrite,
143
- fallbackTooltip: Oe.teamMemberAccessTooltip,
144
- onUserToggle: Ke
148
+ disabled: $ || !y.canWrite,
149
+ fallbackTooltip: ke.teamMemberAccessTooltip,
150
+ onUserToggle: Xe
145
151
  });
146
152
  return {
147
- "data-testid": De,
153
+ "data-testid": Oe,
148
154
  selectedAccountId: T,
149
- bankDisplayName: X,
150
- bankLogoSrc: xe,
151
- bankLogoAlt: Se,
152
- availableBalanceLabel: Ve,
153
- shouldDisplayAvailableBalance: He,
154
- isBankingTaglineVisible: f,
155
- accountCards: Ue,
155
+ bankDisplayName: He,
156
+ bankLogoSrc: f,
157
+ bankLogoAlt: Ce,
158
+ availableBalanceLabel: Ge,
159
+ shouldDisplayAvailableBalance: Ke,
160
+ isBankingTaglineVisible: o,
161
+ accountCards: qe,
156
162
  shouldDisplayAddAccountCard: y.canWrite,
157
- isLoading: !_ && (!v || Ae && !g || E && (z.isLoading || z.isFetchingNextPage || z.hasNextPage)),
158
- isError: _ || E && z.isError,
163
+ isLoading: !_ && (!v || je && !g || E && (B.isLoading || B.isFetchingNextPage || B.hasNextPage)),
164
+ isError: _ || E && B.isError,
159
165
  isCreateOpen: O,
160
166
  createForm: A,
161
167
  legalCopy: {
162
- bankName: X,
163
- vspName: ze,
164
- agreementUrl: Be
168
+ bankName: He,
169
+ vspName: Ue,
170
+ agreementUrl: We
165
171
  },
166
- accessRows: Ye,
167
- isTeamMembersLoading: K,
168
- isTeamMembersError: U.isError,
169
- isCreateSubmitDisabled: !Z || !q || A.nickname.trim() === "" || Y.length === 0,
170
- isCreateError: B.isError || V.isError,
171
- hasNicknameError: Ie,
172
- isSubmitting: Je,
173
- isCreateDisabled: !Z,
174
- onCreateOpenChange: qe,
172
+ accessRows: Qe,
173
+ isTeamMembersLoading: Be,
174
+ isTeamMembersError: W.isError || K.isError,
175
+ isCreateSubmitDisabled: !X || !Ve || A.nickname.trim() === "" || Y.length === 0,
176
+ isCreateError: V.isError || H.isError,
177
+ hasNicknameError: Le,
178
+ isSubmitting: $,
179
+ isCreateDisabled: !X,
180
+ onCreateOpenChange: Ze,
175
181
  onCreateFormChange: (e) => {
176
182
  P(!1), j(e);
177
183
  },
178
- onCreateSubmit: Ge,
179
- onAddAccountClick: () => qe(!0),
184
+ onCreateSubmit: Ye,
185
+ onAddAccountClick: () => Ze(!0),
180
186
  onSelectAccount: D
181
187
  };
182
188
  }
183
- function be(e, t, n) {
189
+ function Se(e, t, n) {
184
190
  return {
185
191
  id: e.id,
186
192
  name: e.nickname?.trim() || t.accountFallback,
@@ -1,4 +1,5 @@
1
1
  import "./index2.js";
2
2
  import { useCreditCardDetailsQuery as e } from "./index4.js";
3
- import { useDebitCardDetailsQuery as t } from "./index5.js";
4
- export { e as useCreditCardDetailsQuery, t as useDebitCardDetailsQuery };
3
+ import { useDebitCardCredentialsQuery as t } from "./index5.js";
4
+ import { useDebitCardDetailsQuery as n } from "./index6.js";
5
+ export { e as useCreditCardDetailsQuery, t as useDebitCardCredentialsQuery, n as useDebitCardDetailsQuery };
@@ -4,22 +4,29 @@
4
4
  "use client";
5
5
  import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
6
  import { organizationHeaders as t } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
7
- import { getDebitCardByIdOptions as n } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
+ import { getDebitCardCredentialsOptions as n } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
8
8
  import { withAuthEpoch as r } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
9
+ import { isApiForbiddenError as i } from "../../../shared/data-access/dist/lib/isApiForbiddenError.js";
9
10
  import "../../../shared/data-access/dist/index.js";
10
- import { withNotFoundOutcome as i } from "./index3.js";
11
11
  import { useQuery as a } from "@tanstack/react-query";
12
12
  //#region ../../libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index5.js
13
13
  function o({ cardId: o, enabled: s }) {
14
- let { client: c, organizationId: l, widgetToken: u, authEpoch: d } = e(), f = n({
14
+ let { client: c, organizationId: l, widgetToken: u, authEpoch: d } = e(), f = !!(o && l && u) && s, p = f ? o ?? "" : "", m = n({
15
15
  client: c,
16
16
  headers: t(l),
17
- path: { id: o ?? "" }
18
- }), p = a({
19
- ...r(f, d),
20
- enabled: !!(o && l && u) && s !== !1
17
+ path: { id: p }
18
+ }), h = a({
19
+ ...r(m, d),
20
+ enabled: f,
21
+ staleTime: 0,
22
+ gcTime: 0,
23
+ retry: !1,
24
+ placeholderData: void 0
21
25
  });
22
- return i(p);
26
+ return {
27
+ ...h,
28
+ isForbidden: h.isError && i(h.error)
29
+ };
23
30
  }
24
31
  //#endregion
25
- export { o as useDebitCardDetailsQuery };
32
+ export { o as useDebitCardCredentialsQuery };
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useEmbedApi as e } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
6
+ import { organizationHeaders as t } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
7
+ import { getDebitCardByIdOptions as n } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
8
+ import { withAuthEpoch as r } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
9
+ import "../../../shared/data-access/dist/index.js";
10
+ import { withNotFoundOutcome as i } from "./index3.js";
11
+ import { useQuery as a } from "@tanstack/react-query";
12
+ //#region ../../libs/tesouro-embedded-components-react/card-details-widget/data-access/dist/index6.js
13
+ function o({ cardId: o, enabled: s }) {
14
+ let { client: c, organizationId: l, widgetToken: u, authEpoch: d } = e(), f = n({
15
+ client: c,
16
+ headers: t(l),
17
+ path: { id: o ?? "" }
18
+ }), p = a({
19
+ ...r(f, d),
20
+ enabled: !!(o && l && u) && s !== !1
21
+ });
22
+ return i(p);
23
+ }
24
+ //#endregion
25
+ export { o as useDebitCardDetailsQuery };
@@ -4,7 +4,26 @@ function t(t) {
4
4
  let n = t.trim().slice(-4);
5
5
  return n ? `${e} ${e} ${e} ${n}` : "";
6
6
  }
7
- async function n(e) {
7
+ function n(e) {
8
+ let t = e.replace(/\s+/g, "");
9
+ return t ? (t.match(/.{1,4}/g) ?? []).join(" ") : "";
10
+ }
11
+ function r(e) {
12
+ let t = e.trim();
13
+ if (!t) return "";
14
+ let n = /^(\d{4})-(\d{2})(?:\D|$)/.exec(t);
15
+ if (n) {
16
+ let [, e, t] = n;
17
+ return `${t}/${e.slice(-2)}`;
18
+ }
19
+ let r = /^(\d{2})\/(\d{2}|\d{4})$/.exec(t);
20
+ if (r) {
21
+ let [, e, t] = r;
22
+ return `${e}/${t.slice(-2)}`;
23
+ }
24
+ return t;
25
+ }
26
+ async function i(e) {
8
27
  if (!e.trim()) return !1;
9
28
  try {
10
29
  return await navigator.clipboard.writeText(e), !0;
@@ -13,4 +32,4 @@ async function n(e) {
13
32
  }
14
33
  }
15
34
  //#endregion
16
- export { n as copyTextToClipboard, t as maskCardNumber };
35
+ export { i as copyTextToClipboard, n as formatCardNumber, r as formatExpirationDate, t as maskCardNumber };