@tesouro/embedded-components-react 0.2.255 → 0.2.256

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.
@@ -3,40 +3,38 @@
3
3
  "use client";
4
4
  "use client";
5
5
  import { Dialog as e, DialogContent as t, DialogTitle as n } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { useEmbedApi as r } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
7
- import "../../../shared/data-access/dist/index.js";
8
- import { OnboardingShell as i } from "../../../shared/ui/dist/lib/OnboardingShell/OnboardingShell.js";
6
+ import { OnboardingShell as r } from "../../../shared/ui/dist/lib/OnboardingShell/OnboardingShell.js";
9
7
  import "../../../shared/ui/dist/index.js";
10
- import { useAnalyticsTrack as a } from "../../../shared/feature/dist/lib/analytics/hooks.js";
11
- import { WidgetProvider as ee } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
8
+ import { useAnalyticsTrack as i } from "../../../shared/feature/dist/lib/analytics/hooks.js";
9
+ import { WidgetProvider as a } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
12
10
  import { getStateOptions as o } from "../../../shared/util/dist/lib/usStates.js";
13
11
  import { extractApiErrorMessage as s } from "../../../shared/util/dist/lib/apiErrors.js";
14
- import { useRefetchWidget as te, useWidgetConfig as ne } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
15
- import { getNaicsOptions as c } from "../../../shared/feature/dist/lib/naicsCodeMap.js";
12
+ import { useRefetchWidget as c, useWidgetConfig as l } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
13
+ import { getNaicsOptions as u } from "../../../shared/feature/dist/lib/naicsCodeMap.js";
16
14
  import "../../../shared/feature/dist/index.js";
17
- import { ADDITIONAL_OWNERS_LABELS_EN as l } from "../../ui/dist/index4.js";
18
- import { interpolateBankName as u } from "../../ui/dist/index6.js";
19
- import { ResultStep as re } from "../../ui/dist/index11.js";
20
- import { MarketingWidget as ie } from "../../ui/dist/index28.js";
15
+ import { ADDITIONAL_OWNERS_LABELS_EN as d } from "../../ui/dist/index4.js";
16
+ import { interpolateBankName as f } from "../../ui/dist/index6.js";
17
+ import { ResultStep as ee } from "../../ui/dist/index11.js";
18
+ import { MarketingWidget as te } from "../../ui/dist/index28.js";
21
19
  import "../../ui/dist/index.js";
22
- import { BusinessDetailsStep as ae } from "./index9.js";
23
- import { PersonalDetailsStep as oe } from "./index11.js";
24
- import { AdditionalOwnersStep as se } from "./index13.js";
25
- import { buildCreateApplicationBody as ce, buildUpdateApplicationBody as d } from "./index14.js";
26
- import { OnboardingAnalyticsEvent as f, WIDGET_NAME as p } from "./index15.js";
27
- import { DEFAULT_LABELS as m } from "./index16.js";
28
- import { ApplicationClientSecretProvider as h, useApplicationClientSecret as le } from "../../data-access/dist/index2.js";
29
- import { useCreateApplication as ue } from "../../data-access/dist/index4.js";
30
- import { useUpdateApplication as de } from "../../data-access/dist/index6.js";
31
- import { useSubmitApplication as fe } from "../../data-access/dist/index7.js";
32
- import { usePollApplicationCompletion as pe } from "../../data-access/dist/index8.js";
33
- import { OnboardingSuppressionReason as me } from "../../data-access/dist/index9.js";
34
- import { useOrganizationOnboardingSuppression as he } from "../../data-access/dist/index10.js";
20
+ import { BusinessDetailsStep as ne } from "./index9.js";
21
+ import { PersonalDetailsStep as re } from "./index11.js";
22
+ import { AdditionalOwnersStep as ie } from "./index13.js";
23
+ import { buildCreateApplicationBody as ae, buildUpdateApplicationBody as p } from "./index14.js";
24
+ import { OnboardingAnalyticsEvent as m, WIDGET_NAME as h } from "./index15.js";
25
+ import { DEFAULT_LABELS as g } from "./index16.js";
26
+ import { ApplicationClientSecretProvider as oe, useApplicationClientSecret as se } from "../../data-access/dist/index2.js";
27
+ import { useCreateApplication as ce } from "../../data-access/dist/index4.js";
28
+ import { useUpdateApplication as le } from "../../data-access/dist/index6.js";
29
+ import { useSubmitApplication as ue } from "../../data-access/dist/index7.js";
30
+ import { usePollApplicationCompletion as de } from "../../data-access/dist/index8.js";
31
+ import { OnboardingSuppressionReason as fe } from "../../data-access/dist/index9.js";
32
+ import { useOrganizationOnboardingSuppression as pe } from "../../data-access/dist/index10.js";
35
33
  import "../../data-access/dist/index.js";
36
- import { useCallback as g, useEffect as _, useMemo as v, useRef as ge, useState as y } from "react";
37
- import { Fragment as _e, jsx as b, jsxs as x } from "react/jsx-runtime";
34
+ import { useCallback as _, useEffect as v, useMemo as y, useRef as me, useState as b } from "react";
35
+ import { Fragment as he, jsx as x, jsxs as S } from "react/jsx-runtime";
38
36
  //#region ../../libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js
39
- var ve = {
37
+ var ge = {
40
38
  companyLegalName: "",
41
39
  companyDbaName: "",
42
40
  businessAddress: "",
@@ -50,7 +48,7 @@ var ve = {
50
48
  naicsCode: "",
51
49
  isAuthorized: null,
52
50
  isCheckboxChecked: !1
53
- }, ye = {
51
+ }, _e = {
54
52
  firstName: "",
55
53
  lastName: "",
56
54
  dateOfBirth: void 0,
@@ -64,7 +62,7 @@ var ve = {
64
62
  ownsOver25Percent: null,
65
63
  ownershipPercentage: null
66
64
  };
67
- function be(e, t) {
65
+ function ve(e, t) {
68
66
  if (e === 0) return {
69
67
  title: t.businessReviewTitle,
70
68
  subtitle: t.businessReviewSubtitle
@@ -74,7 +72,7 @@ function be(e, t) {
74
72
  subtitle: t.personalReviewSubtitle
75
73
  };
76
74
  let n = {
77
- ...l,
75
+ ...d,
78
76
  ...t.additionalOwners
79
77
  };
80
78
  return {
@@ -82,55 +80,55 @@ function be(e, t) {
82
80
  subtitle: n.subheading
83
81
  };
84
82
  }
85
- function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard: ee, labels: l, initialBusinessDetails: p, initialPersonalDetails: h, initialAdditionalOwners: S, bankLogoSrc: C, disclosureLinks: xe, marketingContent: w = null, open: Se, defaultOpen: Ce, onOpenChange: we }) {
86
- let T = a();
87
- _(() => {
88
- T(f.Mounted);
89
- }, [T]);
90
- let E = {
91
- ...m,
92
- ...l,
83
+ function ye({ onEmbeddedOnboardingCompletedSuccessfully: a, onNavigateToDashboard: d, labels: h, initialBusinessDetails: oe, initialPersonalDetails: ye, initialAdditionalOwners: C, bankLogoSrc: be, disclosureLinks: xe, marketingContent: w = null, open: Se, defaultOpen: T, onOpenChange: Ce }) {
84
+ let E = i();
85
+ v(() => {
86
+ E(m.Mounted);
87
+ }, [E]);
88
+ let D = {
89
+ ...g,
90
+ ...h,
93
91
  stepIndicator: {
94
- ...m.stepIndicator,
95
- ...l?.stepIndicator
92
+ ...g.stepIndicator,
93
+ ...h?.stepIndicator
96
94
  },
97
- businessDetails: l?.businessDetails ?? {},
98
- personalDetails: l?.personalDetails ?? {},
99
- additionalOwners: l?.additionalOwners ?? {},
95
+ businessDetails: h?.businessDetails ?? {},
96
+ personalDetails: h?.personalDetails ?? {},
97
+ additionalOwners: h?.additionalOwners ?? {},
100
98
  result: {
101
- ...m.result,
102
- ...l?.result
99
+ ...g.result,
100
+ ...h?.result
103
101
  }
104
- }, D = ne().initResponse, { termsHref: Te, privacyHref: Ee, electronicCommunicationHref: De, patriotActHref: Oe } = xe ?? {}, ke = w !== null, O = Se === void 0, [Ae, k] = y(!1), [je, Me] = y(!0), [Ne, Pe] = y(() => Ce ?? !1), Fe = C ?? w?.bankLogoSrc ?? void 0, A = O ? Ne : Se, Ie = Ce ?? !1, j = g((e) => {
105
- O && Pe(e), we?.(e);
106
- }, [we, O]), Le = g(() => {
107
- T(f.OpenMarketing), k(!0);
108
- }, [T]), Re = g(() => {
109
- k(!1);
110
- }, []), ze = g(() => {
111
- T(f.BeginOnboarding), k(!1), j(!0);
112
- }, [j, T]), Be = g(() => {
113
- Me(!1), r();
114
- }, [r]), Ve = te(), [M, N] = y(0), [He, Ue] = y(() => ({
115
- ...ve,
116
- ...p
117
- })), [P, We] = y(() => ({
118
- ...ye,
119
- ...h
120
- })), [Ge, Ke] = y(() => S ?? []), [F, qe] = y(null), [I, Je] = y(null), [L, Ye] = y(null), [R, Xe] = y(null), [Ze, z] = y(null), [B, V] = y(!1), [H, U] = y(null), W = ue(), G = de(), K = fe(), Qe = pe(), { setClientSecret: $e } = le(), q = he(), J = ge(null);
121
- _(() => () => J.current?.abort(), []);
122
- let et = v(() => c(E.businessDetails.naicsTitles), [E.businessDetails.naicsTitles]), tt = v(() => o(E.businessDetails.stateTitles), [E.businessDetails.stateTitles]), nt = v(() => o(E.personalDetails.stateTitles), [E.personalDetails.stateTitles]), rt = v(() => o(E.additionalOwners.stateTitles), [E.additionalOwners.stateTitles]), Y = B || H !== null, it = D?.status === "ACTIVE" || D?.status === "INACTIVE", X = D?.status === "INVITED", Z = !!D && !Y && (it || X || q.isSuppressed), Q = Z ? it ? me.UserAlreadyOnboarded : X ? me.UserInvitedToOrganization : q.reason : null;
123
- if (_(() => {
124
- !Z || !Q || (T(f.Suppressed, { reason: Q }), console.info(`[onboarding] not shown: ${Q}`));
102
+ }, O = l().initResponse, { termsHref: we, privacyHref: Te, electronicCommunicationHref: Ee, patriotActHref: De } = xe ?? {}, Oe = w !== null, k = Se === void 0, [ke, A] = b(!1), [Ae, je] = b(!0), [Me, Ne] = b(() => T ?? !1), Pe = be ?? w?.bankLogoSrc ?? void 0, Fe = k ? Me : Se, Ie = T ?? !1, j = _((e) => {
103
+ k && Ne(e), Ce?.(e);
104
+ }, [Ce, k]), Le = _(() => {
105
+ E(m.OpenMarketing), A(!0);
106
+ }, [E]), Re = _(() => {
107
+ A(!1);
108
+ }, []), ze = _(() => {
109
+ E(m.BeginOnboarding), A(!1), j(!0);
110
+ }, [j, E]), Be = _(() => {
111
+ je(!1), a();
112
+ }, [a]), Ve = c(), [M, N] = b(0), [He, Ue] = b(() => ({
113
+ ...ge,
114
+ ...oe
115
+ })), [P, We] = b(() => ({
116
+ ..._e,
117
+ ...ye
118
+ })), [Ge, Ke] = b(() => C ?? []), [F, qe] = b(null), [I, Je] = b(null), [L, Ye] = b(null), [R, Xe] = b(null), [Ze, z] = b(null), [B, V] = b(!1), [H, U] = b(null), W = ce(), G = le(), K = ue(), Qe = de(), { setClientSecret: $e } = se(), q = pe(), J = me(null);
119
+ v(() => () => J.current?.abort(), []);
120
+ let et = y(() => u(D.businessDetails.naicsTitles), [D.businessDetails.naicsTitles]), tt = y(() => o(D.businessDetails.stateTitles), [D.businessDetails.stateTitles]), nt = y(() => o(D.personalDetails.stateTitles), [D.personalDetails.stateTitles]), rt = y(() => o(D.additionalOwners.stateTitles), [D.additionalOwners.stateTitles]), Y = B || H !== null, X = O?.status === "ACTIVE" || O?.status === "INACTIVE", it = O?.status === "INVITED", Z = !!O && !Y && (X || it || q.isSuppressed), Q = Z ? X ? fe.UserAlreadyOnboarded : it ? fe.UserInvitedToOrganization : q.reason : null;
121
+ if (v(() => {
122
+ !Z || !Q || (E(m.Suppressed, { reason: Q }), console.info(`[onboarding] not shown: ${Q}`));
125
123
  }, [
126
124
  Z,
127
125
  Q,
128
- T
129
- ]), !D || !Y && (Z || !q.isResolved)) return null;
126
+ E
127
+ ]), !O || !Y && (Z || !q.isResolved)) return null;
130
128
  let at = F?.companyStructure === "SOLE_PROPRIETORSHIP", ot = [
131
- E.stepIndicator.business,
132
- E.stepIndicator.personal,
133
- E.stepIndicator.ownership
129
+ D.stepIndicator.business,
130
+ D.stepIndicator.personal,
131
+ D.stepIndicator.ownership
134
132
  ], st = M === 0 ? F : M === 1 ? I : M === 2 ? L : null, $ = W.isPending || G.isPending || K.isPending || B, ct = () => {
135
133
  z(null), N((e) => e === 0 ? 0 : e - 1);
136
134
  }, lt = () => {
@@ -143,7 +141,7 @@ function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard
143
141
  try {
144
142
  let r = await K.mutateAsync({ path: { id: e } });
145
143
  if (t.signal.aborted) return;
146
- if (!r.id) throw Error(E.submitFailedError);
144
+ if (!r.id) throw Error(D.submitFailedError);
147
145
  n = !0, (await Qe(e, { signal: t.signal })).status === "complete" ? (U("success"), Ve(), Be()) : U("pending");
148
146
  } catch (e) {
149
147
  if (e instanceof DOMException && e.name === "AbortError") return;
@@ -159,7 +157,7 @@ function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard
159
157
  if (!F) return;
160
158
  let e = R;
161
159
  if (!e) {
162
- let t = await W.mutateAsync({ body: ce(F) });
160
+ let t = await W.mutateAsync({ body: ae(F) });
163
161
  e = t.id, Xe(e), t.clientSecret && $e(t.clientSecret);
164
162
  }
165
163
  N(1);
@@ -167,7 +165,7 @@ function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard
167
165
  if (!I || !F || !R) return;
168
166
  await G.mutateAsync({
169
167
  path: { id: R },
170
- body: d({
168
+ body: p({
171
169
  businessDetails: F,
172
170
  applicant: I
173
171
  })
@@ -176,28 +174,28 @@ function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard
176
174
  if (!L || !R) return;
177
175
  await G.mutateAsync({
178
176
  path: { id: R },
179
- body: d({ businessOwners: L })
177
+ body: p({ businessOwners: L })
180
178
  }), await ut(R);
181
179
  }
182
180
  } catch (e) {
183
- let t = s(e) ?? (e instanceof Error ? e.message : void 0) ?? E.genericRetryError;
181
+ let t = s(e) ?? (e instanceof Error ? e.message : void 0) ?? D.genericRetryError;
184
182
  z(t);
185
183
  }
186
- }, ft = be(Math.min(M, 2), E), pt = D.bankName?.trim() || E.fallbackBankName, mt = u(E.shellFdicDisclaimer, pt);
184
+ }, ft = ve(Math.min(M, 2), D), pt = O.bankName?.trim() || D.fallbackBankName, mt = f(D.shellFdicDisclaimer, pt);
187
185
  if (Y) {
188
- let r = F?.companyLegalName ?? "", i = D.bankName?.trim() || E.fallbackBankName, a = H ?? "pending", o = a === "success", s = {
189
- ...m.result,
190
- ...E.result
186
+ let r = F?.companyLegalName ?? "", i = O.bankName?.trim() || D.fallbackBankName, a = H ?? "pending", o = a === "success", s = {
187
+ ...g.result,
188
+ ...D.result
191
189
  };
192
- return /* @__PURE__ */ b(e, {
193
- open: A,
190
+ return /* @__PURE__ */ x(e, {
191
+ open: Fe,
194
192
  onOpenChange: j,
195
- children: /* @__PURE__ */ x(t, {
193
+ children: /* @__PURE__ */ S(t, {
196
194
  className: "ttw:grid ttw:max-h-[95vh] ttw:w-[720px] ttw:max-w-[calc(100vw-2rem)] ttw:grid-rows-[1fr] ttw:gap-0 ttw:overflow-hidden ttw:rounded-2xl ttw:p-0",
197
- children: [/* @__PURE__ */ b(n, {
195
+ children: [/* @__PURE__ */ x(n, {
198
196
  className: "ttw:sr-only",
199
- children: E.modalTitle
200
- }), /* @__PURE__ */ b(re, {
197
+ children: D.modalTitle
198
+ }), /* @__PURE__ */ x(ee, {
201
199
  status: a,
202
200
  isLoading: B,
203
201
  loadingMessage: s.loadingMessage,
@@ -207,17 +205,17 @@ function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard
207
205
  followUpEmail: I?.workEmail ?? "",
208
206
  emailBoxLead: s.pendingEmailBoxLead,
209
207
  navigateToDashboardLabel: s.navigateToDashboard,
210
- bankLogoSrc: Fe,
211
- bankLogoAlt: u(s.bankLogoAlt, i),
212
- fdicDisclaimer: u(s.fdicDisclaimer, i),
213
- onNavigateToDashboard: ee
208
+ bankLogoSrc: Pe,
209
+ bankLogoAlt: f(s.bankLogoAlt, i),
210
+ fdicDisclaimer: f(s.fdicDisclaimer, i),
211
+ onNavigateToDashboard: d
214
212
  })]
215
213
  })
216
214
  });
217
215
  }
218
- let ht = M === 2 ? E.submit : E.next, gt = st === null || $;
219
- return /* @__PURE__ */ x(_e, { children: [ke && je && w ? /* @__PURE__ */ b(ie, {
220
- open: Ae,
216
+ let ht = M === 2 ? D.submit : D.next, gt = st === null || $;
217
+ return /* @__PURE__ */ S(he, { children: [Oe && Ae && w ? /* @__PURE__ */ x(te, {
218
+ open: ke,
221
219
  isVisible: !0,
222
220
  vspLogo: w.vspLogo,
223
221
  bankingText: w.bankingText,
@@ -231,8 +229,8 @@ function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard
231
229
  onOpenMarketingModal: Le,
232
230
  onCloseMarketingModal: Re,
233
231
  onPrimaryCtaClick: ze
234
- }) : null, /* @__PURE__ */ x(i, {
235
- open: A,
232
+ }) : null, /* @__PURE__ */ S(r, {
233
+ open: Fe,
236
234
  defaultOpen: Ie,
237
235
  onOpenChange: j,
238
236
  title: ft.title,
@@ -250,33 +248,33 @@ function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard
250
248
  nextIcon: null,
251
249
  errorMessage: Ze,
252
250
  labels: {
253
- backButton: M === 0 ? E.cancel : E.back,
254
- cancelButton: E.cancel
251
+ backButton: M === 0 ? D.cancel : D.back,
252
+ cancelButton: D.cancel
255
253
  },
256
254
  children: [
257
- M === 0 ? /* @__PURE__ */ b(ae, {
255
+ M === 0 ? /* @__PURE__ */ x(ne, {
258
256
  value: He,
259
257
  onValueChange: Ue,
260
258
  onSnapshotChange: qe,
261
259
  naicsOptions: et,
262
260
  stateOptions: tt,
263
261
  isSubmitting: $,
264
- labels: E.businessDetails,
262
+ labels: D.businessDetails,
265
263
  bankName: pt,
266
- termsHref: Te,
267
- privacyHref: Ee,
268
- electronicCommunicationHref: De,
269
- patriotActHref: Oe
264
+ termsHref: we,
265
+ privacyHref: Te,
266
+ electronicCommunicationHref: Ee,
267
+ patriotActHref: De
270
268
  }, "business") : null,
271
- M === 1 ? /* @__PURE__ */ b(oe, {
269
+ M === 1 ? /* @__PURE__ */ x(re, {
272
270
  value: P,
273
271
  onValueChange: We,
274
272
  onSnapshotChange: Je,
275
273
  stateOptions: nt,
276
274
  isSubmitting: $,
277
- labels: E.personalDetails
275
+ labels: D.personalDetails
278
276
  }, "personal") : null,
279
- M === 2 ? /* @__PURE__ */ b(se, {
277
+ M === 2 ? /* @__PURE__ */ x(ie, {
280
278
  owners: Ge,
281
279
  onOwnersChange: Ke,
282
280
  primaryOwnerName: `${P.firstName} ${P.lastName}`.trim(),
@@ -284,30 +282,30 @@ function S({ onEmbeddedOnboardingCompletedSuccessfully: r, onNavigateToDashboard
284
282
  stateOptions: rt,
285
283
  onSnapshotChange: Ye,
286
284
  isSubmitting: $,
287
- labels: E.additionalOwners
285
+ labels: D.additionalOwners
288
286
  }) : null
289
287
  ]
290
288
  })] });
291
289
  }
292
- function C({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, linkComponent: i, implementation: a, uiFramework: o, errorFallback: s, onError: te, analytics: ne, ...c }) {
293
- return /* @__PURE__ */ b(ee, {
290
+ function C({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, linkComponent: i, implementation: o, uiFramework: s, errorFallback: c, onError: l, analytics: u, ...d }) {
291
+ return /* @__PURE__ */ x(a, {
294
292
  baseUrl: e,
295
293
  widgetToken: t,
296
294
  organizationId: n,
297
295
  configClient: r,
298
296
  linkComponent: i,
299
- implementation: a,
300
- uiFramework: o,
301
- errorFallback: s,
302
- onError: te,
303
- analytics: ne,
304
- widgetName: p,
305
- children: /* @__PURE__ */ b(xe, { ...c })
297
+ implementation: o,
298
+ uiFramework: s,
299
+ errorFallback: c,
300
+ onError: l,
301
+ analytics: u,
302
+ widgetName: h,
303
+ children: /* @__PURE__ */ x(be, { ...d })
306
304
  });
307
305
  }
308
- function xe(e) {
309
- let { authEpoch: t } = r();
310
- return /* @__PURE__ */ b(h, { children: /* @__PURE__ */ b(S, { ...e }, t) }, t);
306
+ function be(e) {
307
+ let { initResponse: t } = l(), n = t?.userId ?? null, [r, i] = b(n), [a, o] = b(0);
308
+ return n !== r && (i(n), r !== null && n !== null && o((e) => e + 1)), /* @__PURE__ */ x(oe, { children: /* @__PURE__ */ x(ye, { ...e }, a) }, a);
311
309
  }
312
310
  //#endregion
313
311
  export { C as BankAccountOnboardingWidget, C as default };
@@ -1,9 +1,11 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/data-access/dist/lib/withAuthEpoch.js
2
- function e(e, t) {
2
+ var e = (e) => e;
3
+ function t(t, n) {
3
4
  return {
4
- ...e,
5
- queryKey: [...e.queryKey, { authEpoch: t }]
5
+ placeholderData: e,
6
+ ...t,
7
+ queryKey: [...t.queryKey, { authEpoch: n }]
6
8
  };
7
9
  }
8
10
  //#endregion
9
- export { e as withAuthEpoch };
11
+ export { t as withAuthEpoch };
@@ -11,10 +11,10 @@ import { WidgetProvider as l } from "./lib/WidgetProvider/WidgetProvider.js";
11
11
  import { WidgetTokenRefreshProvider as u } from "./lib/WidgetProvider/WidgetTokenRefreshProvider.js";
12
12
  import { useOptionalWidgetToken as d, useWidgetToken as f } from "./lib/WidgetProvider/useWidgetToken.js";
13
13
  import { RefreshingRootWidgetProvider as p } from "./lib/WidgetProvider/RefreshingRootWidgetProvider.js";
14
- import { useOwnWidgetConfig as m, useRefetchWidget as h, useWidgetConfig as g, useWidgetError as _, useWidgetLoading as v } from "./lib/WidgetProvider/hooks.js";
14
+ import { useOwnWidgetConfig as m, useRefetchWidget as h, useWidgetConfig as g, useWidgetError as _, useWidgetInitStaleForToken as v, useWidgetLoading as y } from "./lib/WidgetProvider/hooks.js";
15
15
  import "./lib/WidgetProvider/index.js";
16
- import { getNaicsOptions as y } from "./lib/naicsCodeMap.js";
17
- import { CardProgram as b } from "./lib/card/cardProgram.js";
18
- import { CARD_STATUS_LABELS_EN as x, CARD_STATUS_TONE as S, CARD_TYPE_LABELS_EN as C } from "./lib/card/cardPresentation.js";
16
+ import { getNaicsOptions as b } from "./lib/naicsCodeMap.js";
17
+ import { CardProgram as x } from "./lib/card/cardProgram.js";
18
+ import { CARD_STATUS_LABELS_EN as S, CARD_STATUS_TONE as C, CARD_TYPE_LABELS_EN as w } from "./lib/card/cardPresentation.js";
19
19
  import "./lib/analytics/index.js";
20
- export { x as CARD_STATUS_LABELS_EN, S as CARD_STATUS_TONE, C as CARD_TYPE_LABELS_EN, b as CardProgram, t as Implementation, p as RefreshingRootWidgetProvider, s as RootWidgetProvider, l as WidgetProvider, u as WidgetTokenRefreshProvider, e as cloneEmbeddedClient, n as getGlobalWidgetConfig, a as getGlobalWidgetInitState, y as getNaicsOptions, r as setGlobalWidgetConfig, o as subscribeToGlobalWidgetInitState, i as updateGlobalWidgetConfig, c as useAnalyticsTrack, d as useOptionalWidgetToken, m as useOwnWidgetConfig, h as useRefetchWidget, g as useWidgetConfig, _ as useWidgetError, v as useWidgetLoading, f as useWidgetToken };
20
+ export { S as CARD_STATUS_LABELS_EN, C as CARD_STATUS_TONE, w as CARD_TYPE_LABELS_EN, x as CardProgram, t as Implementation, p as RefreshingRootWidgetProvider, s as RootWidgetProvider, l as WidgetProvider, u as WidgetTokenRefreshProvider, e as cloneEmbeddedClient, n as getGlobalWidgetConfig, a as getGlobalWidgetInitState, b as getNaicsOptions, r as setGlobalWidgetConfig, o as subscribeToGlobalWidgetInitState, i as updateGlobalWidgetConfig, c as useAnalyticsTrack, d as useOptionalWidgetToken, m as useOwnWidgetConfig, h as useRefetchWidget, g as useWidgetConfig, _ as useWidgetError, v as useWidgetInitStaleForToken, y as useWidgetLoading, f as useWidgetToken };
@@ -12,13 +12,16 @@ function s() {
12
12
  return i(n)?.own ?? null;
13
13
  }
14
14
  function c() {
15
- return i(n)?.refetch ?? r;
15
+ return i(n)?.initResponseStaleForToken ?? !1;
16
16
  }
17
17
  function l() {
18
- return i(n)?.loading ?? !1;
18
+ return i(n)?.refetch ?? r;
19
19
  }
20
20
  function u() {
21
+ return i(n)?.loading ?? !1;
22
+ }
23
+ function d() {
21
24
  return i(n)?.error ?? null;
22
25
  }
23
26
  //#endregion
24
- export { s as useOwnWidgetConfig, c as useRefetchWidget, o as useWidgetConfig, u as useWidgetError, l as useWidgetLoading };
27
+ export { s as useOwnWidgetConfig, l as useRefetchWidget, o as useWidgetConfig, d as useWidgetError, c as useWidgetInitStaleForToken, u as useWidgetLoading };
@@ -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.2.255", n = "2ad40c79a29e42ce7d0d910602a36d6aeacdca18", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.2.256", n = "92eb36f8b554b495b2b78067fa7b86326c571f92", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -5,53 +5,80 @@
5
5
  import { useEmbedApi as e } from "../../../../data-access/dist/lib/EmbedApiContext.js";
6
6
  import "../../../../data-access/dist/index.js";
7
7
  import { useOptionalWidgetToken as t } from "../../../../feature/dist/lib/WidgetProvider/useWidgetToken.js";
8
- import { useWidgetConfig as n, useWidgetError as r } from "../../../../feature/dist/lib/WidgetProvider/hooks.js";
8
+ import { useWidgetConfig as n, useWidgetError as r, useWidgetInitStaleForToken as i } from "../../../../feature/dist/lib/WidgetProvider/hooks.js";
9
9
  import "../../../../feature/dist/index.js";
10
- import { MoniteProvider as i } from "../../../../../monite-sdk/dist/index605.js";
10
+ import { MoniteProvider as a } from "../../../../../monite-sdk/dist/index605.js";
11
11
  import "../../../../../monite-sdk/dist/index.js";
12
- import { useMemo as a } from "react";
13
- import { jsx as o } from "react/jsx-runtime";
12
+ import { useMemo as o, useState as s } from "react";
13
+ import { jsx as c } from "react/jsx-runtime";
14
14
  //#region ../../libs/tesouro-embedded-components-react/shared/monite-wrapper/feature/dist/lib/MoniteWrapper.js
15
- var s = 0;
16
- function c(e) {
15
+ var l = 0;
16
+ function u(e) {
17
17
  return e instanceof Error ? e : Error(String(e));
18
18
  }
19
- function l({ finopsThemeColors: l, children: u }) {
20
- let { baseUrl: d, organizationId: f, initResponse: p, widgetToken: m } = n(), { client: h } = e(), g = r(), _ = t(), v = _ !== null, y = _?.state, b = _?.refresh, x = _?.getState;
21
- if (g) throw g;
22
- if (y?.status === "error") throw y.error instanceof Error ? y.error : Error(String(y.error));
23
- let S = p?.userId ?? null, C = v ? y?.status === "ready" : !!m, w = a(() => {
24
- let e = h.getConfig();
19
+ function d({ finopsThemeColors: d, children: f }) {
20
+ let { baseUrl: p, organizationId: m, initResponse: h, widgetToken: g } = n(), { client: _ } = e(), v = t(), y = v !== null, b = v?.state, x = v?.refresh, S = v?.getState, C = y && b?.status === "ready" ? b.widgetToken : g ?? null, w = y && b?.status === "ready" ? b.exp : void 0, T = i(), [E, D] = s(() => ({
21
+ organizationId: m,
22
+ widgetToken: C,
23
+ widgetTokenExp: w
24
+ }));
25
+ !T && (E.organizationId !== m || E.widgetToken !== C || E.widgetTokenExp !== w) && D({
26
+ organizationId: m,
27
+ widgetToken: C,
28
+ widgetTokenExp: w
29
+ });
30
+ let O = T ? E.organizationId : m, k = T ? E.widgetToken : C, A = T ? E.widgetTokenExp : w, j = r();
31
+ if (j) throw j;
32
+ if (b?.status === "error") throw b.error instanceof Error ? b.error : Error(String(b.error));
33
+ let M = h?.userId ?? null, N = y ? b?.status === "ready" : !!g, P = o(() => {
34
+ let e = _.getConfig();
25
35
  return async (t, n) => {
26
36
  let r = t instanceof Request ? t : new Request(t, n);
27
- for (let t of h.interceptors.request.fns) t && (r = await t(r, e));
37
+ for (let t of _.interceptors.request.fns) t && (r = await t(r, e));
38
+ if (T) {
39
+ if (!k) throw Error("MoniteWrapper.fetch: widget token is not ready during init refresh");
40
+ r = new Request(r), r.headers.has("X-Client-Secret") ? (r.headers.delete("Authorization"), r.headers.set("X-Widget-Token", k)) : (r.headers.set("Authorization", `Bearer ${k}`), r.headers.has("X-Widget-Token") && r.headers.set("X-Widget-Token", k));
41
+ }
28
42
  return globalThis.fetch(r);
29
43
  };
30
- }, [h]), T = a(() => !d || !f ? null : {
31
- apiUrl: d,
32
- entityId: f,
33
- fetch: w,
44
+ }, [
45
+ _,
46
+ T,
47
+ k
48
+ ]), F = o(() => !p || !O ? null : {
49
+ apiUrl: p,
50
+ entityId: O,
51
+ fetch: P,
34
52
  fetchToken: async () => {
35
- if (!v) {
36
- if (!m) throw Error("MoniteWrapper.fetchToken: widget token is not ready");
53
+ if (T) {
54
+ if (!k) throw Error("MoniteWrapper.fetchToken: widget token is not ready during init refresh");
55
+ let e = Date.now() / 1e3;
56
+ return {
57
+ access_token: k,
58
+ expires_in: A === void 0 ? l : Math.max(0, A - e),
59
+ token_type: "Bearer"
60
+ };
61
+ }
62
+ if (!y) {
63
+ if (!g) throw Error("MoniteWrapper.fetchToken: widget token is not ready");
37
64
  return {
38
- access_token: m,
39
- expires_in: s,
65
+ access_token: g,
66
+ expires_in: l,
40
67
  token_type: "Bearer"
41
68
  };
42
69
  }
43
- if (!b || !x) throw Error("MoniteWrapper.fetchToken: token refresh provider is unavailable");
70
+ if (!x || !S) throw Error("MoniteWrapper.fetchToken: token refresh provider is unavailable");
44
71
  let e = !1, t = () => {
45
- let e = x();
46
- if (e.status === "error") throw c(e.error);
72
+ let e = S();
73
+ if (e.status === "error") throw u(e.error);
47
74
  return e;
48
75
  }, n = (e) => {
49
76
  if (e.status !== "ready") throw Error("MoniteWrapper.fetchToken: widget token is not ready after refresh()");
50
77
  return e;
51
- }, r = x();
52
- if (r.status === "error") throw c(r.error);
53
- if (r.status !== "ready" && (await b(), e = !0, r = t()), r = n(r), r.exp === void 0 && !e && (await b(), r = n(t())), r.exp === void 0 && r.lastError !== void 0) throw c(r.lastError);
54
- let i = Date.now() / 1e3, a = r.exp === void 0 ? s : Math.max(0, r.exp - i);
78
+ }, r = S();
79
+ if (r.status === "error") throw u(r.error);
80
+ if (r.status !== "ready" && (await x(), e = !0, r = t()), r = n(r), r.exp === void 0 && !e && (await x(), r = n(t())), r.exp === void 0 && r.lastError !== void 0) throw u(r.lastError);
81
+ let i = Date.now() / 1e3, a = r.exp === void 0 ? l : Math.max(0, r.exp - i);
55
82
  return {
56
83
  access_token: r.widgetToken,
57
84
  expires_in: a,
@@ -59,22 +86,25 @@ function l({ finopsThemeColors: l, children: u }) {
59
86
  };
60
87
  }
61
88
  }, [
62
- d,
89
+ p,
90
+ S,
91
+ y,
92
+ T,
93
+ P,
94
+ k,
95
+ A,
96
+ O,
63
97
  x,
64
- v,
65
- w,
66
- f,
67
- b,
68
- m
69
- ]), E = a(() => new Set(p?.scopes ?? []), [p?.scopes]), D = a(() => {
70
- if (!l) return;
98
+ g
99
+ ]), I = o(() => new Set(h?.scopes ?? []), [h?.scopes]), L = o(() => {
100
+ if (!d) return;
71
101
  let e = {};
72
- return l.primary && (e.primary = l.primary), l.primaryForeground && (e.primaryForeground = l.primaryForeground), Object.keys(e).length > 0 ? { colors: e } : void 0;
73
- }, [l]);
74
- return !C || !T || !p || !d || !f ? null : /* @__PURE__ */ o(i, {
75
- monite: T,
76
- theme: D,
77
- userPermissions: E,
102
+ return d.primary && (e.primary = d.primary), d.primaryForeground && (e.primaryForeground = d.primaryForeground), Object.keys(e).length > 0 ? { colors: e } : void 0;
103
+ }, [d]);
104
+ return !N || !F || !h || !p || !O ? null : /* @__PURE__ */ c(a, {
105
+ monite: F,
106
+ theme: L,
107
+ userPermissions: I,
78
108
  componentSettings: {
79
109
  receivables: {
80
110
  bankAccountCountries: ["US"],
@@ -87,8 +117,8 @@ function l({ finopsThemeColors: l, children: u }) {
87
117
  availableAPDocuments: []
88
118
  }
89
119
  },
90
- children: u
91
- }, S ?? "no-user");
120
+ children: f
121
+ }, M ?? "no-user");
92
122
  }
93
123
  //#endregion
94
- export { l as MoniteWrapper };
124
+ export { d as MoniteWrapper };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.2.255",
3
+ "version": "0.2.256",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "packageDepSync": {