@tesouro/embedded-components-react 0.3.50 → 0.3.51

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -71,7 +71,7 @@ import "./lib/InsightsWidget.js";
71
71
  import "./lib/ChartOfAccountsWidget.js";
72
72
  import "./lib/HelpWidget.js";
73
73
  import "./lib/InvoicingWidget.js";
74
- import { LinkedAccountsWidget as he } from "./libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index9.js";
74
+ import { LinkedAccountsWidget as he } from "./libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index10.js";
75
75
  import "./lib/LinkedAccountsWidget.js";
76
76
  import { ADDITIONAL_OWNERS_LABELS_EN as ge } from "./libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index4.js";
77
77
  import { BUSINESS_DETAILS_LABELS_EN as _e } from "./libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index6.js";
@@ -1,3 +1,3 @@
1
- import { LinkedAccountsWidget as e } from "../libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index9.js";
1
+ import { LinkedAccountsWidget as e } from "../libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index10.js";
2
2
  import "../libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index.js";
3
3
  export { e as LinkedAccountsWidget };
@@ -1,4 +1,4 @@
1
- //#region ../../libs/shared/util-validation/dist/index22.js
1
+ //#region ../../libs/shared/util-validation/dist/index23.js
2
2
  function e(e) {
3
3
  let t = typeof e == "string" ? Number(e) : e;
4
4
  return typeof t == "number" && Number.isFinite(t) ? t : Infinity;
@@ -0,0 +1,6 @@
1
+ //#region ../../libs/shared/util-validation/dist/index7.js
2
+ function e(e, t) {
3
+ return e.filter((e) => e.organizationId === t);
4
+ }
5
+ //#endregion
6
+ export { e as filterUsersForOrganization };
@@ -15,32 +15,33 @@ import { WidgetProvider as s } from "../../../shared/feature/dist/lib/WidgetProv
15
15
  import { getStateOptions as ee } from "../../../shared/util/dist/lib/usStates.js";
16
16
  import { useWidgetConfig as te } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
17
17
  import "../../../shared/feature/dist/index.js";
18
+ import { filterUsersForOrganization as ne } from "../../../../shared/util-validation/dist/index7.js";
18
19
  import { CREATE_CARD_WIDGET_LABELS_EN as c } from "../../ui/dist/lib/CreateCardWidget/labels.js";
19
20
  import { CreateCardView as l, MailingOptionValue as u } from "../../ui/dist/lib/CreateCardWidget/types.js";
20
- import { CreateCardWidget as ne } from "../../ui/dist/lib/CreateCardWidget/CreateCardWidget.js";
21
+ import { CreateCardWidget as re } from "../../ui/dist/lib/CreateCardWidget/CreateCardWidget.js";
21
22
  import "../../ui/dist/index.js";
22
- import { CardFormatValue as d, buildCreateDebitCardRequest as re, createDebitCardReference as ie, formatBusinessAddress as ae, isBusinessAddressComplete as oe, isManualAddressComplete as se } from "./index3.js";
23
- import { resolveCreateCardFeatureLabels as ce } from "./index5.js";
24
- import { CreateCardWidgetAnalyticsEvent as le, WIDGET_NAME as ue } from "./index2.js";
25
- import { SpendLimitPeriodValue as f, buildPerTransactionMaximumVelocityControlRequest as de, buildSpendLimitVelocityControlRequest as fe, parseControlAmountToMinorUnits as pe } from "./index4.js";
26
- import { getCreateCardPermissions as me } from "./index6.js";
27
- import { useCreateCardCardholderOptions as he } from "./index7.js";
28
- import { useCreateCard as ge } from "../../data-access/dist/index2.js";
29
- import { useCreateDebitCardMutation as _e } from "../../data-access/dist/index4.js";
30
- import { useCreateVelocityControlMutation as ve } from "../../data-access/dist/index5.js";
31
- import { useManageDebitCardAccessMutation as ye } from "../../data-access/dist/index6.js";
32
- import { useCreateCardOrganizationQuery as be } from "../../data-access/dist/index7.js";
23
+ import { CardFormatValue as d, buildCreateDebitCardRequest as ie, createDebitCardReference as ae, formatBusinessAddress as oe, isBusinessAddressComplete as se, isManualAddressComplete as ce } from "./index3.js";
24
+ import { resolveCreateCardFeatureLabels as le } from "./index5.js";
25
+ import { CreateCardWidgetAnalyticsEvent as ue, WIDGET_NAME as de } from "./index2.js";
26
+ import { SpendLimitPeriodValue as f, buildPerTransactionMaximumVelocityControlRequest as fe, buildSpendLimitVelocityControlRequest as pe, parseControlAmountToMinorUnits as me } from "./index4.js";
27
+ import { getCreateCardPermissions as he } from "./index6.js";
28
+ import { useCreateCardCardholderOptions as ge } from "./index7.js";
29
+ import { useCreateCard as _e } from "../../data-access/dist/index2.js";
30
+ import { useCreateDebitCardMutation as ve } from "../../data-access/dist/index4.js";
31
+ import { useCreateVelocityControlMutation as ye } from "../../data-access/dist/index5.js";
32
+ import { useManageDebitCardAccessMutation as be } from "../../data-access/dist/index6.js";
33
+ import { useCreateCardOrganizationQuery as xe } from "../../data-access/dist/index7.js";
33
34
  import "../../data-access/dist/index.js";
34
35
  import { useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
35
- import { Fragment as xe, jsx as _, jsxs as Se } from "react/jsx-runtime";
36
+ import { Fragment as Se, jsx as _, jsxs as Ce } from "react/jsx-runtime";
36
37
  //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index8.js
37
- var Ce = t.DebitCardIssueOrg, we = {
38
+ var we = t.DebitCardIssueOrg, Te = {
38
39
  street: "",
39
40
  city: "",
40
41
  state: "",
41
42
  zip: ""
42
- }, Te = 3e3, v = 5e3;
43
- function Ee(e, t) {
43
+ }, Ee = 3e3, v = 5e3;
44
+ function De(e, t) {
44
45
  if (e === "PENDING_ACTIVATION") return {
45
46
  title: t.success.pendingActivationTitle,
46
47
  description: t.success.pendingActivationDescription
@@ -50,49 +51,49 @@ function Ee(e, t) {
50
51
  description: t.success.createdDescription
51
52
  };
52
53
  }
53
- function De(e) {
54
+ function Oe(e) {
54
55
  let t = e?.trim().slice(-4);
55
56
  return t ? `••••${t}` : void 0;
56
57
  }
57
- function Oe(e, t) {
58
- let n = e.nickname?.trim(), r = De(e.accountNumber);
58
+ function ke(e, t) {
59
+ let n = e.nickname?.trim(), r = Oe(e.accountNumber);
59
60
  return n && r ? `${n} (${r})` : n || r || t;
60
61
  }
61
- function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose: y, onCancel: ke, onViewCard: Ae }) {
62
- let je = o(), { isReady: b } = ge(), { initResponse: Me, organizationId: x } = te(), S = m(() => me(Me?.scopes), [Me?.scopes]), C = ce(ue), w = {
62
+ function y({ cardArtSrc: t, labels: s, featureLabels: de, className: Oe, onClose: y, onCancel: Ae, onViewCard: je }) {
63
+ let Me = o(), { isReady: b } = _e(), { initResponse: Ne, organizationId: x } = te(), S = m(() => he(Ne?.scopes), [Ne?.scopes]), C = le(de), w = {
63
64
  ...c,
64
65
  ...s,
65
66
  setup: {
66
67
  ...c.setup,
67
68
  ...s?.setup
68
69
  }
69
- }, Ne = m(() => [{
70
+ }, Pe = m(() => [{
70
71
  value: d.Virtual,
71
72
  label: w.setup.cardFormatVirtual
72
73
  }, {
73
74
  value: d.Physical,
74
75
  label: w.setup.cardFormatPhysical
75
- }], [w.setup.cardFormatPhysical, w.setup.cardFormatVirtual]), Pe = m(() => ee(), []), [Fe, T] = g(l.Setup), [E, Ie] = g(null), [D, Le] = g(null), [Re, ze] = g(null), [O, k] = g(null), [A, Be] = g(we), [Ve, He] = g(null), [Ue, We] = g(null), [j, M] = g(!1), [N, P] = g(""), [F, I] = g(null), [L, R] = g(!1), [z, B] = g(""), [V, H] = g(!1), [U, W] = g([]), Ge = () => {
76
- Ie(null), Le(null), ze(null), k(null), Be(we), He(null), We(null), M(!1), P(""), I(null), R(!1), B(""), H(!1), W([]), T(l.Setup);
77
- }, Ke = h(x);
78
- x && x !== Ke.current && (Ke.current = x, Ge());
76
+ }], [w.setup.cardFormatPhysical, w.setup.cardFormatVirtual]), Fe = m(() => ee(), []), [Ie, T] = g(l.Setup), [E, Le] = g(null), [D, Re] = g(null), [ze, Be] = g(null), [O, k] = g(null), [A, Ve] = g(Te), [He, Ue] = g(null), [We, Ge] = g(null), [j, M] = g(!1), [N, P] = g(""), [F, I] = g(null), [L, R] = g(!1), [z, B] = g(""), [V, H] = g(!1), [U, W] = g([]), Ke = () => {
77
+ Le(null), Re(null), Be(null), k(null), Ve(Te), Ue(null), Ge(null), M(!1), P(""), I(null), R(!1), B(""), H(!1), W([]), T(l.Setup);
78
+ }, qe = h(x);
79
+ x && x !== qe.current && (qe.current = x, Ke());
79
80
  let G = h(!0);
80
81
  p(() => (G.current = !0, () => {
81
82
  G.current = !1;
82
83
  }), []), p(() => {
83
- je(le.Mounted);
84
- }, [je]);
85
- let { options: qe, isError: K, refetch: Je } = he({ enabled: b && S.canReadUsers }), q = i({
84
+ Me(ue.Mounted);
85
+ }, [Me]);
86
+ let { options: Je, isError: K, refetch: Ye } = ge({ enabled: b && S.canReadUsers }), q = i({
86
87
  enabled: b && S.canReadUsers,
87
- permissions: [Ce]
88
- }), Ye = m(() => !b || !S.canReadUsers || q.isResolving || q.isError ? [] : (q.data?.data ?? []).filter((e) => e.organizationId === x).map((e) => e.id), [
88
+ permissions: [we]
89
+ }), Xe = m(() => !b || !S.canReadUsers || q.isResolving || q.isError ? [] : ne(q.data?.data ?? [], x).map((e) => e.id), [
89
90
  q.data?.data,
90
91
  q.isError,
91
92
  q.isResolving,
92
93
  b,
93
94
  x,
94
95
  S.canReadUsers
95
- ]), J = !!q.isError && b && S.canReadUsers, Xe = b && S.canReadUsers && q.isResolving, Y = h(null);
96
+ ]), J = !!q.isError && b && S.canReadUsers, Ze = b && S.canReadUsers && q.isResolving, Y = h(null);
96
97
  p(() => {
97
98
  if (!J) {
98
99
  Y.current !== null && (e.dismiss(Y.current), Y.current = null);
@@ -115,17 +116,17 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
115
116
  C.toast.retry,
116
117
  J
117
118
  ]);
118
- let Ze = be({ enabled: b && S.canReadOrganization }), X = n({ enabled: b && S.canReadFundingAccounts }), Qe = r({ enabled: b && S.canReadMerchantCategoryGroups }), $e = _e(), et = ve(), tt = ye(), Z = !!X.isError && b && S.canReadFundingAccounts, Q = m(() => Z ? [] : (X.data?.data ?? []).map((e) => ({
119
+ let Qe = xe({ enabled: b && S.canReadOrganization }), X = n({ enabled: b && S.canReadFundingAccounts }), $e = r({ enabled: b && S.canReadMerchantCategoryGroups }), et = ve(), tt = ye(), nt = be(), Z = !!X.isError && b && S.canReadFundingAccounts, Q = m(() => Z ? [] : (X.data?.data ?? []).map((e) => ({
119
120
  value: e.id,
120
- label: Oe(e, C.untitledFundingAccount)
121
+ label: ke(e, C.untitledFundingAccount)
121
122
  })), [
122
123
  X.data?.data,
123
124
  C.untitledFundingAccount,
124
125
  Z
125
- ]), nt = m(() => (Qe.data?.data ?? []).map((e) => ({
126
+ ]), $ = m(() => ($e.data?.data ?? []).map((e) => ({
126
127
  value: e.id,
127
128
  label: e.name
128
- })), [Qe.data?.data]), rt = Re ?? (Q.length === 1 ? Q[0].value : null), it = Ze.data?.address, at = ae(it), ot = oe(it), $ = D === d.Physical, st = $ && O === u.BusinessAddress && !!at, ct = $ && O === u.DifferentAddress, lt = Z || Q.length > 0, ut = b && S.canWriteAuthorizationControls, dt = m(() => [
129
+ })), [$e.data?.data]), rt = ze ?? (Q.length === 1 ? Q[0].value : null), it = Qe.data?.address, at = oe(it), ot = se(it), st = D === d.Physical, ct = st && O === u.BusinessAddress && !!at, lt = st && O === u.DifferentAddress, ut = Z || Q.length > 0, dt = b && S.canWriteAuthorizationControls, ft = m(() => [
129
130
  {
130
131
  value: f.OneTime,
131
132
  label: C.spendLimit.periodOneTime
@@ -142,7 +143,7 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
142
143
  C.spendLimit.periodDaily,
143
144
  C.spendLimit.periodMonthly,
144
145
  C.spendLimit.periodOneTime
145
- ]), ft = m(() => [
146
+ ]), pt = m(() => [
146
147
  {
147
148
  value: f.OneTime,
148
149
  variant: "warning",
@@ -164,45 +165,45 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
164
165
  C.spendLimit.monthlyResetNotice,
165
166
  C.spendLimit.oneTimeWarningDescription,
166
167
  C.spendLimit.oneTimeWarningTitle
167
- ]), pt = j && (pe(N) === null || F === null), mt = L && pe(z) === null, ht = V && U.length === 0, gt = nt.length === 0 && !V;
168
- ut || (j && M(!1), N !== "" && P(""), F !== null && I(null), L && R(!1), z !== "" && B(""), V && H(!1), U.length > 0 && W([]));
169
- let _t = m(() => ({
168
+ ]), mt = j && (me(N) === null || F === null), ht = L && me(z) === null, gt = V && U.length === 0, _t = $.length === 0 && !V;
169
+ dt || (j && M(!1), N !== "" && P(""), F !== null && I(null), L && R(!1), z !== "" && B(""), V && H(!1), U.length > 0 && W([]));
170
+ let vt = m(() => ({
170
171
  isSpendLimitEnabled: j,
171
172
  onSpendLimitEnabledChange: (e) => {
172
173
  M(e), e && I((e) => e ?? f.Monthly);
173
174
  },
174
175
  spendLimitAmount: N,
175
176
  onSpendLimitAmountChange: P,
176
- spendLimitPeriodOptions: dt,
177
+ spendLimitPeriodOptions: ft,
177
178
  selectedSpendLimitPeriod: F,
178
179
  onSpendLimitPeriodSelect: I,
179
- spendLimitPeriodNotices: ft,
180
+ spendLimitPeriodNotices: pt,
180
181
  isMerchantCategoriesEnabled: V,
181
182
  onMerchantCategoriesEnabledChange: H,
182
- merchantCategoryOptions: nt,
183
+ merchantCategoryOptions: $,
183
184
  selectedMerchantCategories: U,
184
185
  onMerchantCategoryToggle: (e) => {
185
186
  W((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
186
187
  },
187
- isMerchantCategoriesToggleDisabled: gt,
188
+ isMerchantCategoriesToggleDisabled: _t,
188
189
  isPerTransactionMaximumEnabled: L,
189
190
  onPerTransactionMaximumEnabledChange: R,
190
191
  perTransactionMaximumAmount: z,
191
192
  onPerTransactionMaximumAmountChange: B
192
193
  }), [
193
194
  V,
194
- gt,
195
+ _t,
195
196
  L,
196
197
  j,
197
- nt,
198
+ $,
198
199
  z,
199
200
  U,
200
201
  F,
201
202
  N,
202
- ft,
203
- dt
204
- ]), vt = !b || !S.canIssue || $e.isPending || et.isPending || tt.isPending || K || Z || J || Xe || !E || !D || !rt || pt || mt || ht || D === d.Physical && (!O || O === u.BusinessAddress && !ot || O === u.DifferentAddress && !se(A)), yt = m(() => {
205
- let e = Ee(Ue, C);
203
+ pt,
204
+ ft
205
+ ]), yt = !b || !S.canIssue || et.isPending || tt.isPending || nt.isPending || K || Z || J || Ze || !E || !D || !rt || mt || ht || gt || D === d.Physical && (!O || O === u.BusinessAddress && !ot || O === u.DifferentAddress && !ce(A)), bt = m(() => {
206
+ let e = De(We, C);
206
207
  return {
207
208
  ...s,
208
209
  success: {
@@ -211,12 +212,12 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
211
212
  }
212
213
  };
213
214
  }, [
214
- Ue,
215
+ We,
215
216
  C,
216
217
  s
217
- ]), bt = async () => {
218
+ ]), xt = async () => {
218
219
  if (!b) return;
219
- let t = ie(), n = re({
220
+ let t = ae(), n = ie({
220
221
  cardholderUserId: E,
221
222
  format: D,
222
223
  bankAccountId: rt,
@@ -229,15 +230,15 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
229
230
  T(l.Preparing);
230
231
  let r = e.loading(C.toast.creating);
231
232
  try {
232
- let t = await $e.mutateAsync({ body: n });
233
+ let t = await et.mutateAsync({ body: n });
233
234
  if (!G.current) {
234
235
  e.dismiss(r);
235
236
  return;
236
237
  }
237
- He(t.id), We(t.cardStatus);
238
+ Ue(t.id), Ge(t.cardStatus);
238
239
  let i = [];
239
240
  if (j) {
240
- let e = fe({
241
+ let e = pe({
241
242
  cardId: t.id,
242
243
  amount: N,
243
244
  period: F,
@@ -247,7 +248,7 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
247
248
  e && i.push(e);
248
249
  }
249
250
  if (L) {
250
- let e = de({
251
+ let e = fe({
251
252
  cardId: t.id,
252
253
  amount: z,
253
254
  id: crypto.randomUUID(),
@@ -257,7 +258,7 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
257
258
  }
258
259
  let a = !1;
259
260
  if (i.length > 0) try {
260
- await Promise.all(i.map((e) => et.mutateAsync({ body: e })));
261
+ await Promise.all(i.map((e) => tt.mutateAsync({ body: e })));
261
262
  } catch {
262
263
  a = !0;
263
264
  }
@@ -266,11 +267,11 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
266
267
  return;
267
268
  }
268
269
  let o = !1;
269
- if (Ye.length > 0) try {
270
- await tt.mutateAsync({ body: {
270
+ if (Xe.length > 0) try {
271
+ await nt.mutateAsync({ body: {
271
272
  debitCardIds: [t.id],
272
273
  type: "GRANT",
273
- userIds: Ye
274
+ userIds: Xe
274
275
  } });
275
276
  } catch {
276
277
  o = !0;
@@ -302,7 +303,7 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
302
303
  }
303
304
  e.success(C.toast.success, {
304
305
  id: r,
305
- duration: Te
306
+ duration: Ee
306
307
  });
307
308
  } catch {
308
309
  if (!G.current) {
@@ -315,60 +316,60 @@ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose
315
316
  });
316
317
  }
317
318
  };
318
- return /* @__PURE__ */ Se(xe, { children: [/* @__PURE__ */ _(a, {}), /* @__PURE__ */ _(ne, {
319
- view: Fe,
319
+ return /* @__PURE__ */ Ce(Se, { children: [/* @__PURE__ */ _(a, {}), /* @__PURE__ */ _(re, {
320
+ view: Ie,
320
321
  cardArtSrc: t,
321
- labels: yt,
322
- className: De,
323
- cardholderOptions: qe,
322
+ labels: bt,
323
+ className: Oe,
324
+ cardholderOptions: Je,
324
325
  selectedCardholder: E,
325
- onCardholderSelect: Ie,
326
+ onCardholderSelect: Le,
326
327
  isCardholderError: K,
327
- onCardholderRetry: K ? Je : void 0,
328
- cardFormatOptions: Ne,
328
+ onCardholderRetry: K ? Ye : void 0,
329
+ cardFormatOptions: Pe,
329
330
  selectedCardFormat: D,
330
331
  onCardFormatSelect: (e) => {
331
- Le(e), k(null);
332
+ Re(e), k(null);
332
333
  },
333
- isFundingAccountVisible: lt,
334
+ isFundingAccountVisible: ut,
334
335
  fundingAccountOptions: Q,
335
336
  selectedFundingAccount: rt,
336
- onFundingAccountSelect: ze,
337
+ onFundingAccountSelect: Be,
337
338
  isFundingAccountError: Z,
338
339
  onFundingAccountRetry: Z ? () => {
339
340
  X.refetch();
340
341
  } : void 0,
341
- isMailingSectionVisible: $,
342
+ isMailingSectionVisible: st,
342
343
  selectedMailingOption: O,
343
344
  onMailingOptionSelect: k,
344
345
  businessAddress: at,
345
- isBusinessAddressVisible: st,
346
- isManualAddressVisible: ct,
346
+ isBusinessAddressVisible: ct,
347
+ isManualAddressVisible: lt,
347
348
  manualAddress: A,
348
- onManualAddressChange: (e) => Be((t) => ({
349
+ onManualAddressChange: (e) => Ve((t) => ({
349
350
  ...t,
350
351
  ...e
351
352
  })),
352
- stateOptions: Pe,
353
- isCardControlsSectionVisible: ut,
354
- cardControls: _t,
355
- isCreateDisabled: vt,
353
+ stateOptions: Fe,
354
+ isCardControlsSectionVisible: dt,
355
+ cardControls: vt,
356
+ isCreateDisabled: yt,
356
357
  onCreateClick: () => {
357
- bt();
358
+ xt();
358
359
  },
359
360
  onCancelClick: () => {
360
- ke?.(), y?.();
361
+ Ae?.(), y?.();
361
362
  },
362
363
  onClose: y,
363
- onCreateAnotherClick: Ge,
364
- onViewCardClick: Ae && Ve ? () => {
365
- Ae(Ve);
364
+ onCreateAnotherClick: Ke,
365
+ onViewCardClick: je && He ? () => {
366
+ je(He);
366
367
  } : void 0
367
368
  })] });
368
369
  }
369
- function ke({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: a, implementation: o, uiFramework: ee, errorFallback: te, onError: c, analytics: l, disclosuresAcceptance: u, providerLabels: ne, ...d }) {
370
+ function Ae({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: a, implementation: o, uiFramework: ee, errorFallback: te, onError: ne, analytics: c, disclosuresAcceptance: l, providerLabels: u, ...re }) {
370
371
  return /* @__PURE__ */ _(s, {
371
- widgetName: ue,
372
+ widgetName: de,
372
373
  baseUrl: e,
373
374
  widgetToken: t,
374
375
  organizationId: n,
@@ -378,12 +379,12 @@ function ke({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, ga
378
379
  implementation: o,
379
380
  uiFramework: ee,
380
381
  errorFallback: te,
381
- onError: c,
382
- analytics: l,
383
- disclosuresAcceptance: u,
384
- providerLabels: ne,
385
- children: /* @__PURE__ */ _(y, { ...d })
382
+ onError: ne,
383
+ analytics: c,
384
+ disclosuresAcceptance: l,
385
+ providerLabels: u,
386
+ children: /* @__PURE__ */ _(y, { ...re })
386
387
  });
387
388
  }
388
389
  //#endregion
389
- export { ke as CreateCardWidget, Oe as formatFundingAccountLabel };
390
+ export { Ae as CreateCardWidget, ke as formatFundingAccountLabel };
@@ -1,3 +1,3 @@
1
1
  import "./index4.js";
2
- import { LinkedAccountsWidget as e } from "./index9.js";
2
+ import { LinkedAccountsWidget as e } from "./index10.js";
3
3
  export { e as LinkedAccountsWidget };
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { EmbeddedToaster as e } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
6
+ import "../../../shared/ui/dist/index.js";
7
+ import { WidgetProvider as t } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
8
+ import "../../../shared/feature/dist/index.js";
9
+ import { WIDGET_NAME as n } from "./index2.js";
10
+ import { LinkedAccountsWidgetUi as r } from "../../ui/dist/index16.js";
11
+ import "../../ui/dist/index.js";
12
+ import { useLinkedAccountsWidget as i } from "./index9.js";
13
+ import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
14
+ //#region ../../libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index10.js
15
+ function c({ labels: t, featureLabels: n }) {
16
+ let c = i({
17
+ labels: t,
18
+ featureLabels: n
19
+ });
20
+ return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(e, {}), /* @__PURE__ */ o(r, {
21
+ labels: t,
22
+ ...c
23
+ })] });
24
+ }
25
+ function l({ baseUrl: e, widgetToken: r, organizationId: i, configClient: a, gatewayRouting: s, linkComponent: l, implementation: u, uiFramework: d, errorFallback: f, onError: p, analytics: m, disclosuresAcceptance: h, providerLabels: g, ..._ }) {
26
+ return /* @__PURE__ */ o(t, {
27
+ widgetName: n,
28
+ baseUrl: e,
29
+ widgetToken: r,
30
+ organizationId: i,
31
+ configClient: a,
32
+ gatewayRouting: s,
33
+ linkComponent: l,
34
+ implementation: u,
35
+ uiFramework: d,
36
+ errorFallback: f,
37
+ onError: p,
38
+ analytics: m,
39
+ disclosuresAcceptance: h,
40
+ providerLabels: g,
41
+ children: /* @__PURE__ */ o(c, { ..._ })
42
+ });
43
+ }
44
+ //#endregion
45
+ export { l as LinkedAccountsWidget, l as default };
@@ -1,59 +1,22 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { useAllOrganizationUsersQuery as e } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
6
+ import { filterUsersForOrganization as t } from "../../../../shared/util-validation/dist/index7.js";
7
+ import "../../data-access/dist/index.js";
8
+ import { useMemo as n } from "react";
1
9
  //#region ../../libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index7.js
2
- function e(e) {
3
- return e.filter((e) => {
4
- let t = e.status?.toUpperCase() ?? "";
5
- return !!e.key.trim() && (t === "ACTIVE" || t === "");
6
- }).map((e) => ({
7
- key: e.key.trim(),
8
- name: e.name,
9
- description: e.description?.trim() || e.name
10
- }));
11
- }
12
- function t(e, t) {
13
- let n = t?.trim() ?? "";
14
- if (!n) return;
15
- let r = n.toLowerCase(), i = e.find((e) => e.key.toLowerCase() === r);
16
- if (i) return i.key;
17
- let a = e.find((e) => e.name.toLowerCase() === r);
18
- if (a) return a.key;
19
- }
20
- function n(e, n) {
21
- let r = t(e, n);
22
- if (r) return e.find((e) => e.key.toLowerCase() === r.toLowerCase())?.name;
23
- }
24
- function r(e, n) {
25
- let r = t(e, n);
26
- if (r) return e.find((e) => e.key.toLowerCase() === r.toLowerCase())?.description;
27
- }
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
- 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
- }
35
- function o(e, o) {
36
- 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) ?? "";
38
- return {
39
- id: e.id,
40
- name: e.name,
41
- role: l,
42
- roleDescription: u,
43
- locked: i(c) || i(s)
44
- };
10
+ function r({ enabled: r, permissionKey: i, organizationId: a }) {
11
+ let o = e({
12
+ enabled: r,
13
+ permissions: [i]
45
14
  });
46
- }
47
- function s(e, { selectedUserIds: t, disabled: n, fallbackTooltip: r, onUserToggle: i }) {
48
- return e.map((e) => ({
49
- key: e.id,
50
- name: e.name,
51
- role: e.role,
52
- roleTooltip: e.roleDescription || r,
53
- checked: e.locked || t.includes(e.id),
54
- disabled: n || e.locked,
55
- onToggle: (t) => i(e.id, t)
56
- }));
15
+ return {
16
+ userIds: n(() => new Set(t(o.data?.data ?? [], a).map((e) => e.id)), [o.data?.data, a]),
17
+ isResolving: o.isResolving,
18
+ isError: o.isError
19
+ };
57
20
  }
58
21
  //#endregion
59
- export { i as isAdminRoleKey, r as resolveOrganizationRoleDescription, n as resolveOrganizationRoleDisplayName, t as resolveOrganizationRoleKey, s as toAccessRows, e as toOrganizationRoleOptions, o as toTeamMembers };
22
+ export { r as useAdminEligibleUserIds };
@@ -1,274 +1,55 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { useAllOrganizationRolesQuery as t } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
7
- import { useAllOrganizationUsersQuery as n } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
8
- import "../../../shared/ui/dist/index.js";
9
- import { useAnalyticsTrack as ee } from "../../../shared/feature/dist/lib/analytics/hooks.js";
10
- import { getInitials as te } from "../../../shared/util/dist/lib/getInitials.js";
11
- import { TESOURO_NEW_EXTERNAL_BANK_ACCOUNT_LINKED_SUCCESS_EVENT as ne, emitWidgetDomEvent as r } from "../../../shared/util/dist/lib/widgetDomEvents.js";
12
- import { extractApiErrorMessage as re } from "../../../shared/util/dist/lib/apiErrors.js";
13
- import { useWidgetConfig as ie, useWidgetError as ae, useWidgetLoading as oe } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
14
- import "../../../shared/feature/dist/index.js";
15
- import { filterRolesForOrganization as se } from "../../../../shared/util-validation/dist/index6.js";
16
- import { DEFAULT_FEATURE_LABELS as ce } from "./index4.js";
17
- import { LinkedAccountsWidgetAnalyticsEvent as i } from "./index2.js";
18
- import { EMPTY_CONNECT_FORM as a, EMPTY_EDIT_FORM as le, EMPTY_VERIFY_FORM as o, isConnectStep1Valid as s, isRoutingNumberValid as ue, isVerifyAmountInRange as c, isVerifyFormValid as l, parseVerifyAmountToMinorUnits as de, sanitizeRoutingNumberInput as fe, toEditForm as pe, toUpdateBody as me } from "./index3.js";
19
- import { getLinkedAccountsPermissions as he } from "./index5.js";
20
- import { toAccountRows as ge } from "./index6.js";
21
- import { toAccessRows as _e, toOrganizationRoleOptions as ve, toTeamMembers as ye } from "./index7.js";
22
- import { DEFAULT_LABELS as be } from "../../ui/dist/index15.js";
23
- import "../../ui/dist/index.js";
24
- import { useConnectExternalBankAccountMutation as xe } from "../../data-access/dist/index3.js";
25
- import { useExternalBankAccountsQuery as Se } from "../../data-access/dist/index4.js";
26
- import { useGrantExternalBankAccountAccessMutation as Ce } from "../../data-access/dist/index5.js";
27
- import { useLinkExternalBankAccountMutation as we } from "../../data-access/dist/index6.js";
28
- import { useUnlinkExternalBankAccountMutation as Te } from "../../data-access/dist/index9.js";
29
- import { useUpdateExternalBankAccountMutation as Ee } from "../../data-access/dist/index10.js";
30
- import { useValidateExternalBankAccountMutation as De } from "../../data-access/dist/index11.js";
31
- import "../../data-access/dist/index.js";
32
- import { useCallback as Oe, useEffect as ke, useMemo as u, useState as d } from "react";
33
1
  //#region ../../libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index8.js
34
- function Ae(e) {
35
- let t = e;
36
- return typeof e == "object" && !!e && "verificationStatus" in e && t.verificationStatus === "VERIFIED";
2
+ function e(e) {
3
+ return e.filter((e) => {
4
+ let t = e.status?.toUpperCase() ?? "";
5
+ return !!e.key.trim() && (t === "ACTIVE" || t === "");
6
+ }).map((e) => ({
7
+ key: e.key.trim(),
8
+ name: e.name,
9
+ description: e.description?.trim() || e.name
10
+ }));
37
11
  }
38
- var f = "tesouro.linkedAccounts.locallySentMicroDepositAccountIds.v1";
39
- function je() {
40
- if (typeof window > "u") return /* @__PURE__ */ new Set();
41
- try {
42
- let e = window.sessionStorage.getItem(f), t = e ? JSON.parse(e) : [];
43
- return new Set(Array.isArray(t) ? t.filter(p) : []);
44
- } catch {
45
- return /* @__PURE__ */ new Set();
46
- }
12
+ function t(e, t) {
13
+ let n = t?.trim() ?? "";
14
+ if (!n) return;
15
+ let r = n.toLowerCase(), i = e.find((e) => e.key.toLowerCase() === r);
16
+ if (i) return i.key;
17
+ let a = e.find((e) => e.name.toLowerCase() === r);
18
+ if (a) return a.key;
47
19
  }
48
- function p(e) {
49
- return typeof e == "string";
20
+ function n(e, n) {
21
+ let r = t(e, n);
22
+ if (r) return e.find((e) => e.key.toLowerCase() === r.toLowerCase())?.name;
50
23
  }
51
- function m(e) {
52
- if (!(typeof window > "u")) try {
53
- window.sessionStorage.setItem(f, JSON.stringify([...e]));
54
- } catch {}
24
+ function r(e, n) {
25
+ let r = t(e, n);
26
+ if (r) return e.find((e) => e.key.toLowerCase() === r.toLowerCase())?.description;
55
27
  }
56
- function h(e, t) {
57
- let n = new Set(e).add(t);
58
- return m(n), n;
28
+ function i(e) {
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(" ") : "";
59
30
  }
60
- function g({ labels: f, featureLabels: p }) {
61
- let m = {
62
- ...be,
63
- ...f
64
- }, g = {
65
- ...ce,
66
- ...p
67
- }, _ = ee(), { organizationId: v, widgetToken: Me, initResponse: y } = ie(), Ne = oe(), b = !!ae(), x = !!(v && Me), S = u(() => he(y?.scopes), [y?.scopes]), C = x && S.canRead && !!y, [w, T] = d(), [E, Pe] = d(!1), [D, O] = d(1), [k, A] = d([]), [j, M] = d(), [Fe, N] = d(), [Ie, Le] = d(je), [Re, P] = d(!1), [ze, Be] = d(!1), [Ve, F] = d(!1), [He, I] = d(!1), [L, R] = d(), [z, Ue] = d(a), [We, Ge] = d(le), [B, Ke] = d(o);
68
- ke(() => {
69
- _(i.Mounted);
70
- }, [_]);
71
- let V = Se({
72
- limit: 100,
73
- enabled: C
74
- }), H = xe(), U = Ce(), W = Ee(), G = Te(), K = we(), q = De(), qe = E && D >= 2, J = n({ enabled: qe }), Y = t({ enabled: qe }), X = u(() => {
75
- let e = Y.data?.data ?? [], t = v ? se(e, {
76
- organizationId: v,
77
- organizationTypes: y?.organizationTypes ?? []
78
- }) : e;
79
- return ye(J.data?.data ?? [], ve(t));
80
- }, [
81
- Y.data?.data,
82
- J.data?.data,
83
- v,
84
- y?.organizationTypes
85
- ]), Je = J.isLoading || J.isFetchingNextPage || !!J.hasNextPage || Y.isResolving, Ye = !Je && !J.isError, Z = C ? V.data?.data ?? [] : [], Q = u(() => Z.map((e) => e.verificationStatus === "UNVERIFIED" && Ie.has(e.id) ? {
86
- ...e,
87
- verificationStatus: "VERIFICATION_SENT"
88
- } : e), [Z, Ie]), Xe = [.../* @__PURE__ */ new Set([...X.filter((e) => e.locked).map((e) => e.id), ...k])], Ze = Oe((e) => {
89
- H.reset(), U.reset(), K.reset(), Ue({
90
- ...e,
91
- routingNumber: fe(e.routingNumber)
92
- });
93
- }, [
94
- H,
95
- U,
96
- K
97
- ]), Qe = () => {
98
- O(3), r(ne);
99
- }, $e = (e) => {
100
- if (!S.canMicroDeposit) {
101
- Qe();
102
- return;
103
- }
104
- N("connect"), K.mutate({ path: { id: e } }, { onSuccess: () => {
105
- N(void 0), Le((t) => h(t, e)), _(i.AccountLinked, { accountId: e }), Qe();
106
- } });
107
- }, et = (e) => {
108
- U.mutate({
109
- path: { id: e },
110
- body: { userIds: Xe }
111
- }, { onSuccess: () => $e(e) });
112
- }, tt = () => {
113
- if (x && S.canWrite) {
114
- if (D === 1) {
115
- if (!s(z)) return;
116
- O(2);
117
- return;
118
- }
119
- if (D === 2 && Ye) {
120
- if (j) {
121
- et(j.id);
122
- return;
123
- }
124
- H.mutate({ body: {
125
- nickname: z.nickname.trim(),
126
- accountNumber: z.accountNumber.trim(),
127
- routingNumber: z.routingNumber.trim(),
128
- nameOnAccount: z.nickname.trim(),
129
- type: z.type
130
- } }, { onSuccess: (e) => {
131
- _(i.AccountConnected, { accountId: e?.id }), M(e), e?.id && et(e.id);
132
- } });
133
- }
134
- }
135
- }, nt = () => {
136
- D === 2 && O(1);
137
- }, rt = (e, t) => {
138
- X.find((t) => t.id === e)?.locked || A((n) => t ? [.../* @__PURE__ */ new Set([...n, e])] : n.filter((t) => t !== e));
139
- }, it = (e) => {
140
- e && !x || e && !S.canWrite || (e && (O(1), Ue(a), A([]), M(void 0), N(void 0), H.reset(), U.reset(), K.reset()), Pe(e));
141
- }, at = (e) => {
142
- if (!x || !S.canWrite) return;
143
- let t = Z.find((t) => t.id === e);
144
- T(e), Ge(pe(t)), P(!0);
145
- }, ot = (e) => {
146
- e && !x || e && !S.canWrite || P(e);
147
- }, st = () => {
148
- if (!x || !S.canWrite || !w) return;
149
- let t = Z.find((e) => e.id === w), n = me(We, t);
150
- Object.keys(n).length !== 0 && W.mutate({
151
- path: { id: w },
152
- body: n
153
- }, { onSuccess: () => {
154
- _(i.AccountUpdated, { accountId: w }), e.success(g.editSuccessToast), P(!1);
155
- } });
156
- }, ct = (e) => {
157
- x && S.canWrite && (T(e), Ke(o), I(!1), F(!1), Be(!0));
158
- }, lt = (e) => {
159
- e && !x || e && !S.canWrite || (e || (I(!1), F(!1)), Be(e));
160
- }, ut = (e) => {
161
- q.reset(), I(!1), Ke(e);
162
- }, dt = () => {
163
- if (!x || !S.canWrite || !w || !l(B)) return;
164
- let e = de(B.firstAmount), t = de(B.secondAmount);
165
- e !== null && t !== null && (I(!1), q.mutate({
166
- path: { id: w },
167
- body: {
168
- firstAmount: e,
169
- secondAmount: t
170
- }
171
- }, { onSuccess: (e) => {
172
- if (!Ae(e)) {
173
- I(!0);
174
- return;
175
- }
176
- _(i.AccountVerified, { accountId: w }), r("tesouro-new-external-bank-account-linked-success"), F(!0);
177
- } }));
178
- }, ft = (e) => {
179
- x && S.canMicroDeposit && (N("row"), K.mutate({ path: { id: e } }, { onSuccess: () => {
180
- N(void 0), Le((t) => h(t, e)), _(i.AccountLinked, { accountId: e });
181
- } }));
182
- }, pt = (e) => {
183
- x && S.canWrite && R(e);
184
- }, mt = (e) => {
185
- e || R(void 0);
186
- }, ht = () => {
187
- if (!x || !S.canWrite || !L) return;
188
- let t = L;
189
- G.mutate({ path: { id: t } }, { onSuccess: () => {
190
- _(i.AccountUnlinked, { accountId: t }), e.success(g.unlinkSuccessToast), R(void 0);
191
- } });
192
- }, gt = H.isPending || U.isPending || W.isPending || q.isPending || G.isPending || K.isPending, _t = S.canWrite, vt = !x || gt, $ = K.isError && Fe === "connect", yt = _e(X, {
193
- selectedUserIds: k,
194
- disabled: vt || !_t,
195
- fallbackTooltip: m.teamMemberAccessTooltip,
196
- onUserToggle: rt
197
- }), bt = X.filter((e) => e.locked).length + k.length, xt = X.filter((e) => e.locked || k.includes(e.id)), St = j ? {
198
- nickname: j.nickname || z.nickname.trim(),
199
- maskedAccountNumber: j.accountNumber,
200
- users: xt.map((e) => ({
201
- key: e.id,
202
- initials: te(e.name),
31
+ function a(e, a, o) {
32
+ return e.map((e) => {
33
+ let s = e.role ?? "", c = t(a, s) || s.trim(), l = n(a, s) || i(c), u = r(a, s) ?? "";
34
+ return {
35
+ id: e.id,
203
36
  name: e.name,
204
- role: e.role
205
- }))
206
- } : void 0, Ct = ge(Q, g, S, {
207
- labels: m,
208
- onEditSelect: at,
209
- onVerifySelect: ct,
210
- onLinkSelect: ft,
211
- onUnlinkSelect: pt
212
- }), wt = u(() => {
213
- if (!H.isError && !U.isError && !$) return;
214
- let e = H.error ?? U.error ?? ($ ? K.error : void 0);
215
- return re(e) ?? m.actionErrorTitle;
216
- }, [
217
- H.error,
218
- H.isError,
219
- U.error,
220
- U.isError,
221
- $,
222
- K.error,
223
- m.actionErrorTitle
224
- ]);
225
- return {
226
- rows: Ct,
227
- isLoading: !b && (!x || Ne && !y || C && V.isLoading),
228
- isError: b || C && V.isError,
229
- isConnectOpen: E,
230
- isEditOpen: Re,
231
- isVerifyOpen: ze,
232
- isVerifySuccess: Ve,
233
- verifyAccountName: Q.find((e) => e.id === w)?.nickname,
234
- verifyAccountNumber: Q.find((e) => e.id === w)?.accountNumber,
235
- isUnlinkOpen: !!L,
236
- unlinkAccountNumber: Q.find((e) => e.id === L)?.accountNumber,
237
- connectStep: D,
238
- accessRows: yt,
239
- accessGrantedCount: bt,
240
- connectSummary: St,
241
- isTeamMembersLoading: Je,
242
- isTeamMembersError: J.isError,
243
- isConnectNextDisabled: D === 1 ? !s(z) : D === 2 && !Ye,
244
- isConnectRoutingNumberInvalid: z.routingNumber.trim() !== "" && !ue(z.routingNumber),
245
- connectErrorMessage: wt,
246
- isVerifyFirstAmountInvalid: B.firstAmount.trim() !== "" && !c(B.firstAmount),
247
- isVerifySecondAmountInvalid: B.secondAmount.trim() !== "" && !c(B.secondAmount),
248
- isVerifySubmitDisabled: !l(B),
249
- isActionDisabled: vt,
250
- canConnect: _t,
251
- isSubmitting: gt,
252
- isActionError: K.isError || G.isError || H.isError || U.isError || W.isError || q.isError || He,
253
- isConnectError: H.isError || U.isError || $,
254
- isEditError: W.isError,
255
- isVerifyError: q.isError || He,
256
- connectForm: z,
257
- editForm: We,
258
- verifyForm: B,
259
- onConnectOpenChange: it,
260
- onEditOpenChange: ot,
261
- onVerifyOpenChange: lt,
262
- onUnlinkOpenChange: mt,
263
- onConnectFormChange: Ze,
264
- onEditFormChange: Ge,
265
- onVerifyFormChange: ut,
266
- onConnectNext: tt,
267
- onConnectBack: nt,
268
- onEditSubmit: st,
269
- onVerifySubmit: dt,
270
- onUnlinkConfirm: ht
271
- };
37
+ role: l,
38
+ roleDescription: u,
39
+ locked: o.has(e.id)
40
+ };
41
+ });
42
+ }
43
+ function o(e, { selectedUserIds: t, disabled: n, fallbackTooltip: r, onUserToggle: i }) {
44
+ return e.map((e) => ({
45
+ key: e.id,
46
+ name: e.name,
47
+ role: e.role,
48
+ roleTooltip: e.roleDescription || r,
49
+ checked: e.locked || t.includes(e.id),
50
+ disabled: n || e.locked,
51
+ onToggle: (t) => i(e.id, t)
52
+ }));
272
53
  }
273
54
  //#endregion
274
- export { g as useLinkedAccountsWidget };
55
+ export { r as resolveOrganizationRoleDescription, n as resolveOrganizationRoleDisplayName, t as resolveOrganizationRoleKey, o as toAccessRows, e as toOrganizationRoleOptions, a as toTeamMembers };
@@ -2,44 +2,283 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { EmbeddedToaster as e } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
+ import { useAllOrganizationRolesQuery as n } from "../../../shared/data-access/dist/lib/role/useAllOrganizationRolesQuery.js";
8
+ import { useAllOrganizationUsersQuery as ee } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
9
+ import "../../../shared/data-access/dist/index.js";
6
10
  import "../../../shared/ui/dist/index.js";
7
- import { WidgetProvider as t } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
11
+ import { useAnalyticsTrack as te } from "../../../shared/feature/dist/lib/analytics/hooks.js";
12
+ import { getInitials as ne } from "../../../shared/util/dist/lib/getInitials.js";
13
+ import { TESOURO_NEW_EXTERNAL_BANK_ACCOUNT_LINKED_SUCCESS_EVENT as re, emitWidgetDomEvent as r } from "../../../shared/util/dist/lib/widgetDomEvents.js";
14
+ import { extractApiErrorMessage as ie } from "../../../shared/util/dist/lib/apiErrors.js";
15
+ import { useWidgetConfig as ae, useWidgetError as oe, useWidgetLoading as se } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
8
16
  import "../../../shared/feature/dist/index.js";
9
- import { WIDGET_NAME as n } from "./index2.js";
10
- import { LinkedAccountsWidgetUi as r } from "../../ui/dist/index16.js";
17
+ import { filterRolesForOrganization as ce } from "../../../../shared/util-validation/dist/index6.js";
18
+ import { filterUsersForOrganization as le } from "../../../../shared/util-validation/dist/index7.js";
19
+ import { DEFAULT_FEATURE_LABELS as ue } from "./index4.js";
20
+ import { LinkedAccountsWidgetAnalyticsEvent as i } from "./index2.js";
21
+ import { EMPTY_CONNECT_FORM as de, EMPTY_EDIT_FORM as fe, EMPTY_VERIFY_FORM as pe, isConnectStep1Valid as me, isRoutingNumberValid as he, isVerifyAmountInRange as ge, isVerifyFormValid as a, parseVerifyAmountToMinorUnits as o, sanitizeRoutingNumberInput as _e, toEditForm as ve, toUpdateBody as ye } from "./index3.js";
22
+ import { getLinkedAccountsPermissions as be } from "./index5.js";
23
+ import { toAccountRows as xe } from "./index6.js";
24
+ import { useConnectExternalBankAccountMutation as Se } from "../../data-access/dist/index3.js";
25
+ import { useExternalBankAccountsQuery as Ce } from "../../data-access/dist/index4.js";
26
+ import { useGrantExternalBankAccountAccessMutation as we } from "../../data-access/dist/index5.js";
27
+ import { useLinkExternalBankAccountMutation as Te } from "../../data-access/dist/index6.js";
28
+ import { useUnlinkExternalBankAccountMutation as Ee } from "../../data-access/dist/index9.js";
29
+ import { useUpdateExternalBankAccountMutation as De } from "../../data-access/dist/index10.js";
30
+ import { useValidateExternalBankAccountMutation as Oe } from "../../data-access/dist/index11.js";
31
+ import "../../data-access/dist/index.js";
32
+ import { useAdminEligibleUserIds as ke } from "./index7.js";
33
+ import { toAccessRows as Ae, toOrganizationRoleOptions as je, toTeamMembers as Me } from "./index8.js";
34
+ import { DEFAULT_LABELS as Ne } from "../../ui/dist/index15.js";
11
35
  import "../../ui/dist/index.js";
12
- import { useLinkedAccountsWidget as i } from "./index8.js";
13
- import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
36
+ import { useCallback as Pe, useEffect as Fe, useMemo as s, useState as c } from "react";
14
37
  //#region ../../libs/tesouro-embedded-components-react/linked-accounts-widget/feature/dist/index9.js
15
- function c({ labels: t, featureLabels: n }) {
16
- let c = i({
17
- labels: t,
18
- featureLabels: n
19
- });
20
- return /* @__PURE__ */ s(a, { children: [/* @__PURE__ */ o(e, {}), /* @__PURE__ */ o(r, {
21
- labels: t,
22
- ...c
23
- })] });
38
+ function Ie(e) {
39
+ let t = e;
40
+ return typeof e == "object" && !!e && "verificationStatus" in e && t.verificationStatus === "VERIFIED";
24
41
  }
25
- function l({ baseUrl: e, widgetToken: r, organizationId: i, configClient: a, gatewayRouting: s, linkComponent: l, implementation: u, uiFramework: d, errorFallback: f, onError: p, analytics: m, disclosuresAcceptance: h, providerLabels: g, ..._ }) {
26
- return /* @__PURE__ */ o(t, {
27
- widgetName: n,
28
- baseUrl: e,
29
- widgetToken: r,
30
- organizationId: i,
31
- configClient: a,
32
- gatewayRouting: s,
33
- linkComponent: l,
34
- implementation: u,
35
- uiFramework: d,
36
- errorFallback: f,
37
- onError: p,
38
- analytics: m,
39
- disclosuresAcceptance: h,
40
- providerLabels: g,
41
- children: /* @__PURE__ */ o(c, { ..._ })
42
- });
42
+ var l = "tesouro.linkedAccounts.locallySentMicroDepositAccountIds.v1";
43
+ function Le() {
44
+ if (typeof window > "u") return /* @__PURE__ */ new Set();
45
+ try {
46
+ let e = window.sessionStorage.getItem(l), t = e ? JSON.parse(e) : [];
47
+ return new Set(Array.isArray(t) ? t.filter(u) : []);
48
+ } catch {
49
+ return /* @__PURE__ */ new Set();
50
+ }
51
+ }
52
+ function u(e) {
53
+ return typeof e == "string";
54
+ }
55
+ function d(e) {
56
+ if (!(typeof window > "u")) try {
57
+ window.sessionStorage.setItem(l, JSON.stringify([...e]));
58
+ } catch {}
59
+ }
60
+ function f(e, t) {
61
+ let n = new Set(e).add(t);
62
+ return d(n), n;
63
+ }
64
+ var Re = t.ExternalBankAccountWriteOrg;
65
+ function p({ labels: t, featureLabels: l }) {
66
+ let u = {
67
+ ...Ne,
68
+ ...t
69
+ }, d = {
70
+ ...ue,
71
+ ...l
72
+ }, p = te(), { organizationId: m, widgetToken: ze, initResponse: h } = ae(), Be = se(), g = !!oe(), _ = !!(m && ze), v = s(() => be(h?.scopes), [h?.scopes]), y = _ && v.canRead && !!h, [b, Ve] = c(), [He, Ue] = c(!1), [x, S] = c(1), [C, w] = c([]), [T, E] = c(), [We, D] = c(), [O, Ge] = c(Le), [Ke, k] = c(!1), [qe, Je] = c(!1), [Ye, A] = c(!1), [Xe, j] = c(!1), [M, N] = c(), [P, F] = c(de), [I, L] = c(fe), [R, z] = c(pe);
73
+ Fe(() => {
74
+ p(i.Mounted);
75
+ }, [p]);
76
+ let B = Ce({
77
+ limit: 100,
78
+ enabled: y
79
+ }), V = Se(), H = we(), U = De(), W = Ee(), G = Te(), K = Oe(), q = He && x >= 2, J = ee({ enabled: q }), Y = n({ enabled: q }), { userIds: Ze, isResolving: Qe, isError: $e } = ke({
80
+ enabled: q,
81
+ permissionKey: Re,
82
+ organizationId: m
83
+ }), X = s(() => {
84
+ let e = Y.data?.data ?? [], t = m ? ce(e, {
85
+ organizationId: m,
86
+ organizationTypes: h?.organizationTypes ?? []
87
+ }) : e, n = le(J.data?.data ?? [], m);
88
+ return Me(n, je(t), Ze);
89
+ }, [
90
+ Ze,
91
+ Y.data?.data,
92
+ J.data?.data,
93
+ m,
94
+ h?.organizationTypes
95
+ ]), et = J.isLoading || J.isFetchingNextPage || !!J.hasNextPage || Y.isResolving || Qe, tt = !et && !J.isError && !$e, Z = y ? B.data?.data ?? [] : [], Q = s(() => Z.map((e) => e.verificationStatus === "UNVERIFIED" && O.has(e.id) ? {
96
+ ...e,
97
+ verificationStatus: "VERIFICATION_SENT"
98
+ } : e), [Z, O]), nt = [.../* @__PURE__ */ new Set([...X.filter((e) => e.locked).map((e) => e.id), ...C])], rt = Pe((e) => {
99
+ V.reset(), H.reset(), G.reset(), F({
100
+ ...e,
101
+ routingNumber: _e(e.routingNumber)
102
+ });
103
+ }, [
104
+ V,
105
+ H,
106
+ G
107
+ ]), it = () => {
108
+ S(3), r(re);
109
+ }, at = (e) => {
110
+ if (!v.canMicroDeposit) {
111
+ it();
112
+ return;
113
+ }
114
+ D("connect"), G.mutate({ path: { id: e } }, { onSuccess: () => {
115
+ D(void 0), Ge((t) => f(t, e)), p(i.AccountLinked, { accountId: e }), it();
116
+ } });
117
+ }, ot = (e) => {
118
+ H.mutate({
119
+ path: { id: e },
120
+ body: { userIds: nt }
121
+ }, { onSuccess: () => at(e) });
122
+ }, st = () => {
123
+ if (_ && v.canWrite) {
124
+ if (x === 1) {
125
+ if (!me(P)) return;
126
+ S(2);
127
+ return;
128
+ }
129
+ if (x === 2 && tt) {
130
+ if (T) {
131
+ ot(T.id);
132
+ return;
133
+ }
134
+ V.mutate({ body: {
135
+ nickname: P.nickname.trim(),
136
+ accountNumber: P.accountNumber.trim(),
137
+ routingNumber: P.routingNumber.trim(),
138
+ nameOnAccount: P.nickname.trim(),
139
+ type: P.type
140
+ } }, { onSuccess: (e) => {
141
+ p(i.AccountConnected, { accountId: e?.id }), E(e), e?.id && ot(e.id);
142
+ } });
143
+ }
144
+ }
145
+ }, ct = () => {
146
+ x === 2 && S(1);
147
+ }, lt = (e, t) => {
148
+ X.find((t) => t.id === e)?.locked || w((n) => t ? [.../* @__PURE__ */ new Set([...n, e])] : n.filter((t) => t !== e));
149
+ }, ut = (e) => {
150
+ e && !_ || e && !v.canWrite || (e && (S(1), F(de), w([]), E(void 0), D(void 0), V.reset(), H.reset(), G.reset()), Ue(e));
151
+ }, dt = (e) => {
152
+ if (!_ || !v.canWrite) return;
153
+ let t = Z.find((t) => t.id === e);
154
+ Ve(e), L(ve(t)), k(!0);
155
+ }, ft = (e) => {
156
+ e && !_ || e && !v.canWrite || k(e);
157
+ }, pt = () => {
158
+ if (!_ || !v.canWrite || !b) return;
159
+ let t = Z.find((e) => e.id === b), n = ye(I, t);
160
+ Object.keys(n).length !== 0 && U.mutate({
161
+ path: { id: b },
162
+ body: n
163
+ }, { onSuccess: () => {
164
+ p(i.AccountUpdated, { accountId: b }), e.success(d.editSuccessToast), k(!1);
165
+ } });
166
+ }, mt = (e) => {
167
+ _ && v.canWrite && (Ve(e), z(pe), j(!1), A(!1), Je(!0));
168
+ }, ht = (e) => {
169
+ e && !_ || e && !v.canWrite || (e || (j(!1), A(!1)), Je(e));
170
+ }, gt = (e) => {
171
+ K.reset(), j(!1), z(e);
172
+ }, _t = () => {
173
+ if (!_ || !v.canWrite || !b || !a(R)) return;
174
+ let e = o(R.firstAmount), t = o(R.secondAmount);
175
+ e !== null && t !== null && (j(!1), K.mutate({
176
+ path: { id: b },
177
+ body: {
178
+ firstAmount: e,
179
+ secondAmount: t
180
+ }
181
+ }, { onSuccess: (e) => {
182
+ if (!Ie(e)) {
183
+ j(!0);
184
+ return;
185
+ }
186
+ p(i.AccountVerified, { accountId: b }), r("tesouro-new-external-bank-account-linked-success"), A(!0);
187
+ } }));
188
+ }, vt = (e) => {
189
+ _ && v.canMicroDeposit && (D("row"), G.mutate({ path: { id: e } }, { onSuccess: () => {
190
+ D(void 0), Ge((t) => f(t, e)), p(i.AccountLinked, { accountId: e });
191
+ } }));
192
+ }, yt = (e) => {
193
+ _ && v.canWrite && N(e);
194
+ }, bt = (e) => {
195
+ e || N(void 0);
196
+ }, xt = () => {
197
+ if (!_ || !v.canWrite || !M) return;
198
+ let t = M;
199
+ W.mutate({ path: { id: t } }, { onSuccess: () => {
200
+ p(i.AccountUnlinked, { accountId: t }), e.success(d.unlinkSuccessToast), N(void 0);
201
+ } });
202
+ }, St = V.isPending || H.isPending || U.isPending || K.isPending || W.isPending || G.isPending, Ct = v.canWrite, wt = !_ || St, $ = G.isError && We === "connect", Tt = Ae(X, {
203
+ selectedUserIds: C,
204
+ disabled: wt || !Ct,
205
+ fallbackTooltip: u.teamMemberAccessTooltip,
206
+ onUserToggle: lt
207
+ }), Et = X.filter((e) => e.locked).length + C.length, Dt = X.filter((e) => e.locked || C.includes(e.id)), Ot = T ? {
208
+ nickname: T.nickname || P.nickname.trim(),
209
+ maskedAccountNumber: T.accountNumber,
210
+ users: Dt.map((e) => ({
211
+ key: e.id,
212
+ initials: ne(e.name),
213
+ name: e.name,
214
+ role: e.role
215
+ }))
216
+ } : void 0, kt = xe(Q, d, v, {
217
+ labels: u,
218
+ onEditSelect: dt,
219
+ onVerifySelect: mt,
220
+ onLinkSelect: vt,
221
+ onUnlinkSelect: yt
222
+ }), At = s(() => {
223
+ if (!V.isError && !H.isError && !$) return;
224
+ let e = V.error ?? H.error ?? ($ ? G.error : void 0);
225
+ return ie(e) ?? u.actionErrorTitle;
226
+ }, [
227
+ V.error,
228
+ V.isError,
229
+ H.error,
230
+ H.isError,
231
+ $,
232
+ G.error,
233
+ u.actionErrorTitle
234
+ ]);
235
+ return {
236
+ rows: kt,
237
+ isLoading: !g && (!_ || Be && !h || y && B.isLoading),
238
+ isError: g || y && B.isError,
239
+ isConnectOpen: He,
240
+ isEditOpen: Ke,
241
+ isVerifyOpen: qe,
242
+ isVerifySuccess: Ye,
243
+ verifyAccountName: Q.find((e) => e.id === b)?.nickname,
244
+ verifyAccountNumber: Q.find((e) => e.id === b)?.accountNumber,
245
+ isUnlinkOpen: !!M,
246
+ unlinkAccountNumber: Q.find((e) => e.id === M)?.accountNumber,
247
+ connectStep: x,
248
+ accessRows: Tt,
249
+ accessGrantedCount: Et,
250
+ connectSummary: Ot,
251
+ isTeamMembersLoading: et,
252
+ isTeamMembersError: J.isError || $e,
253
+ isConnectNextDisabled: x === 1 ? !me(P) : x === 2 && !tt,
254
+ isConnectRoutingNumberInvalid: P.routingNumber.trim() !== "" && !he(P.routingNumber),
255
+ connectErrorMessage: At,
256
+ isVerifyFirstAmountInvalid: R.firstAmount.trim() !== "" && !ge(R.firstAmount),
257
+ isVerifySecondAmountInvalid: R.secondAmount.trim() !== "" && !ge(R.secondAmount),
258
+ isVerifySubmitDisabled: !a(R),
259
+ isActionDisabled: wt,
260
+ canConnect: Ct,
261
+ isSubmitting: St,
262
+ isActionError: G.isError || W.isError || V.isError || H.isError || U.isError || K.isError || Xe,
263
+ isConnectError: V.isError || H.isError || $,
264
+ isEditError: U.isError,
265
+ isVerifyError: K.isError || Xe,
266
+ connectForm: P,
267
+ editForm: I,
268
+ verifyForm: R,
269
+ onConnectOpenChange: ut,
270
+ onEditOpenChange: ft,
271
+ onVerifyOpenChange: ht,
272
+ onUnlinkOpenChange: bt,
273
+ onConnectFormChange: rt,
274
+ onEditFormChange: L,
275
+ onVerifyFormChange: gt,
276
+ onConnectNext: st,
277
+ onConnectBack: ct,
278
+ onEditSubmit: pt,
279
+ onVerifySubmit: _t,
280
+ onUnlinkConfirm: xt
281
+ };
43
282
  }
44
283
  //#endregion
45
- export { l as LinkedAccountsWidget, l as default };
284
+ export { p as useLinkedAccountsWidget };
@@ -6,7 +6,7 @@ import { useAllOrganizationRolesQuery as e } from "../../../../data-access/dist/
6
6
  import { useRolePermissionsQueries as t } from "../../../../data-access/dist/lib/role/useRolePermissionsQueries.js";
7
7
  import { useAllOrganizationUsersQuery as n } from "../../../../data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
8
8
  import "../../../../data-access/dist/index.js";
9
- import { sortRolesBySortOrdinal as r } from "../../../../../../shared/util-validation/dist/index22.js";
9
+ import { sortRolesBySortOrdinal as r } from "../../../../../../shared/util-validation/dist/index23.js";
10
10
  import { useCallback as i, useMemo as a } from "react";
11
11
  //#region ../../libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApproverOptions.js
12
12
  function o(e) {
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.3.50", n = "d34577d7c74f2e48149e1bdc0da76b7dce632a72", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.3.51", n = "e8fe6632b2204444ac55fca7a28df5312c8d1273", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -1,6 +1,6 @@
1
1
  import { getInitials as e } from "../../../shared/util/dist/lib/getInitials.js";
2
2
  import { filterRolesForOrganization as t, isRoleVisibleForOrganization as n } from "../../../../shared/util-validation/dist/index6.js";
3
- import { sortRolesBySortOrdinal as r } from "../../../../shared/util-validation/dist/index22.js";
3
+ import { sortRolesBySortOrdinal as r } from "../../../../shared/util-validation/dist/index23.js";
4
4
  import { bareRoleKey as i, resolveOrganizationRoleDescription as a, resolveOrganizationRoleDisplayName as o, resolveOrganizationRoleIcon as s, resolveOrganizationRoleKeyForUser as c, rolesForMemberOrganization as l, stripRoleNamespace as u, toRoleDisplayOptions as d } from "./index9.js";
5
5
  import { roleIconForKey as f } from "./index10.js";
6
6
  //#region ../../libs/tesouro-embedded-components-react/team-widget/feature/dist/index11.js
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.3.50",
3
+ "version": "0.3.51",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {