@tesouro/embedded-components-react 0.2.284 → 0.2.288

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.
@@ -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.284", n = "9bdca21363a1a1e90811da1063922771255b874e", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.2.288", n = "75f226753e2f5616b2725736a77388cbc3466f98", 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 { WIDGET_SUITE_CONTENT_LABELS_EN as e, WIDGET_SUITE_DISCLOSURE_LABELS_EN as t, WIDGET_SUITE_SECTION_LABELS_EN as n, WIDGET_SUITE_SECTION_TITLE_LABELS_EN as r } from "./index4.js";
2
- import { WIDGET_SUITE_DEFAULT_SECTIONS as i, WidgetSuiteSectionId as a } from "./index5.js";
2
+ import { WIDGET_SUITE_DEFAULT_SECTIONS as i, WidgetSuiteSectionId as a } from "./index7.js";
3
3
  import { WIDGET_SUITE_SHELL_LABELS_EN as o } from "../../ui/dist/index2.js";
4
4
  import "../../ui/dist/index.js";
5
- import { WidgetSuite as s } from "./index6.js";
5
+ import { WidgetSuite as s } from "./index8.js";
6
6
  export { e as WIDGET_SUITE_CONTENT_LABELS_EN, i as WIDGET_SUITE_DEFAULT_SECTIONS, t as WIDGET_SUITE_DISCLOSURE_LABELS_EN, n as WIDGET_SUITE_SECTION_LABELS_EN, r as WIDGET_SUITE_SECTION_TITLE_LABELS_EN, o as WIDGET_SUITE_SHELL_LABELS_EN, s as WidgetSuite, a as WidgetSuiteSectionId };
@@ -2,96 +2,89 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
- import "../../../shared/data-access/dist/index.js";
8
- import { CardProgram as n } from "../../../shared/feature/dist/lib/card/cardProgram.js";
9
- import "../../../shared/feature/dist/index.js";
10
- import { BankAccountsWidget as r } from "../../../bank-accounts-widget/feature/dist/index8.js";
11
- import "../../../bank-accounts-widget/feature/dist/index.js";
12
- import { BillPayWidget as i } from "../../../bill-pay-widget/feature/dist/index34.js";
13
- import "../../../bill-pay-widget/feature/dist/index.js";
14
- import { CardsWidget as a } from "../../../cards-widget/feature/dist/index8.js";
15
- import "../../../cards-widget/feature/dist/index.js";
16
- import { BalancesWidget as o } from "../../../balances-widget/feature/dist/index5.js";
17
- import "../../../balances-widget/feature/dist/index.js";
18
- import { InsightsWidget as s } from "../../../insights-widget/feature/dist/index11.js";
19
- import "../../../insights-widget/feature/dist/index.js";
20
- import { InvoicingWidget as c } from "../../../invoicing-widget/feature/dist/index3.js";
21
- import "../../../invoicing-widget/feature/dist/index.js";
22
- import { SettingsWidget as l } from "../../../settings-widget/feature/dist/index6.js";
23
- import "../../../settings-widget/feature/dist/index.js";
24
- import { TransfersWidget as u } from "../../../transfers-widget/feature/dist/index6.js";
25
- import "../../../transfers-widget/feature/dist/index.js";
26
- import { jsx as d, jsxs as f } from "react/jsx-runtime";
5
+ import { useCallback as e, useMemo as t } from "react";
6
+ import { useControllableState as n } from "@radix-ui/react-use-controllable-state";
27
7
  //#region ../../libs/tesouro-embedded-components-react/widget-suite/feature/dist/index5.js
28
- var p = ({ children: e }) => /* @__PURE__ */ d("div", {
29
- className: "ttw:rounded-md ttw:border ttw:border-dashed ttw:border-border ttw:p-8 ttw:text-sm ttw:text-muted-foreground",
30
- children: e
31
- }), m = {
32
- Dashboard: "dashboard",
33
- Accounts: "accounts",
34
- Cards: "cards",
35
- Transfers: "transfers",
36
- BillPay: "bill-pay",
37
- Invoicing: "invoicing",
38
- Expenses: "expenses",
39
- Settings: "settings"
40
- }, h = [
41
- m.Dashboard,
42
- m.Accounts,
43
- m.Cards,
44
- m.Transfers,
45
- m.BillPay,
46
- m.Invoicing,
47
- m.Expenses,
48
- m.Settings
49
- ], g = {
50
- [m.Dashboard]: { render: ({ grantedScopes: n }) => {
51
- let r = e(n, [t.BankAccountReadOrg]);
52
- return /* @__PURE__ */ f("div", {
53
- className: r ? "ttw:grid ttw:gap-4 ttw:md:grid-cols-2" : "ttw:grid ttw:gap-4",
54
- children: [r && /* @__PURE__ */ d(o, {}), /* @__PURE__ */ d(s, {})]
55
- });
56
- } },
57
- [m.Accounts]: {
58
- anyOfScopes: [t.BankAccountReadOrg, t.ExternalBankAccountReadOrg],
59
- rendersOwnTitle: !0,
60
- render: () => /* @__PURE__ */ d(r, {})
61
- },
62
- [m.Cards]: {
63
- anyOfScopes: [t.CreditCardReadOrg, t.DebitCardReadOrg],
64
- render: ({ grantedScopes: r, labels: i }) => /* @__PURE__ */ f("div", {
65
- className: "ttw:grid ttw:gap-8",
66
- children: [e(r, [t.CreditCardReadOrg]) && /* @__PURE__ */ d(a, {
67
- cardProgram: n.Credit,
68
- labels: i.creditCards
69
- }), e(r, [t.DebitCardReadOrg]) && /* @__PURE__ */ d(a, {
70
- cardProgram: n.Debit,
71
- labels: i.debitCards
72
- })]
73
- })
74
- },
75
- [m.Transfers]: {
76
- anyOfScopes: [t.BankAccountReadOrg],
77
- render: () => /* @__PURE__ */ d(u, {})
78
- },
79
- [m.BillPay]: {
80
- anyOfScopes: [t.PayableReadOrg],
81
- render: () => /* @__PURE__ */ d(i, {})
82
- },
83
- [m.Invoicing]: {
84
- anyOfScopes: [t.InvoiceReadOrg],
85
- render: () => /* @__PURE__ */ d(c, {})
86
- },
87
- [m.Expenses]: {
88
- anyOfScopes: [t.ExpenseReadOrg, t.ExpenseReadSelf],
89
- render: ({ labels: e }) => /* @__PURE__ */ d(p, { children: e.expensePlaceholders.expensesUnavailable })
90
- },
91
- [m.Settings]: {
92
- rendersOwnTitle: !0,
93
- render: () => /* @__PURE__ */ d(l, {})
94
- }
95
- };
8
+ var r = "WidgetSuite";
9
+ function i(e, t) {
10
+ return {
11
+ cardId: t && "cardId" in t ? t.cardId ?? null : e.cardId,
12
+ pagination: t && "pagination" in t ? t.pagination : e.pagination
13
+ };
14
+ }
15
+ function a(e, t) {
16
+ return {
17
+ section: "section" in t ? t.section : e.section,
18
+ accounts: { accountId: t.accounts && "accountId" in t.accounts ? t.accounts.accountId ?? null : e.accounts.accountId },
19
+ creditCards: i(e.creditCards, t.creditCards),
20
+ debitCards: i(e.debitCards, t.debitCards),
21
+ settings: { section: t.settings && "section" in t.settings ? t.settings.section : e.settings.section }
22
+ };
23
+ }
24
+ function o({ selection: i, defaultSelection: a, sections: o }) {
25
+ let [s, c] = n({
26
+ prop: i?.section,
27
+ defaultProp: a?.section ?? o[0],
28
+ caller: r
29
+ }), [l, u] = n({
30
+ prop: i?.accounts?.accountId,
31
+ defaultProp: a?.accounts?.accountId ?? null,
32
+ caller: r
33
+ }), [d, f] = n({
34
+ prop: i?.creditCards?.cardId,
35
+ defaultProp: a?.creditCards?.cardId ?? null,
36
+ caller: r
37
+ }), [p, m] = n({
38
+ prop: i?.debitCards?.cardId,
39
+ defaultProp: a?.debitCards?.cardId ?? null,
40
+ caller: r
41
+ }), [h, g] = n({
42
+ prop: i?.creditCards?.pagination,
43
+ defaultProp: a?.creditCards?.pagination,
44
+ caller: r
45
+ }), [_, v] = n({
46
+ prop: i?.debitCards?.pagination,
47
+ defaultProp: a?.debitCards?.pagination,
48
+ caller: r
49
+ }), [y, b] = n({
50
+ prop: i?.settings?.section,
51
+ defaultProp: void 0,
52
+ caller: r
53
+ }), x = e((e) => {
54
+ "section" in e && c(e.section), e.accounts && "accountId" in e.accounts && u(e.accounts.accountId ?? null), e.creditCards && ("cardId" in e.creditCards && f(e.creditCards.cardId ?? null), "pagination" in e.creditCards && g(e.creditCards.pagination)), e.debitCards && ("cardId" in e.debitCards && m(e.debitCards.cardId ?? null), "pagination" in e.debitCards && v(e.debitCards.pagination)), e.settings && "section" in e.settings && b(e.settings.section);
55
+ }, [
56
+ u,
57
+ f,
58
+ g,
59
+ m,
60
+ v,
61
+ c,
62
+ b
63
+ ]);
64
+ return {
65
+ resolvedSelection: t(() => ({
66
+ section: s,
67
+ accounts: { accountId: l },
68
+ creditCards: {
69
+ cardId: d,
70
+ pagination: h
71
+ },
72
+ debitCards: {
73
+ cardId: p,
74
+ pagination: _
75
+ },
76
+ settings: { section: y }
77
+ }), [
78
+ l,
79
+ d,
80
+ h,
81
+ p,
82
+ _,
83
+ s,
84
+ y
85
+ ]),
86
+ applyPatch: x
87
+ };
88
+ }
96
89
  //#endregion
97
- export { h as WIDGET_SUITE_DEFAULT_SECTIONS, g as WIDGET_SUITE_SECTIONS, m as WidgetSuiteSectionId };
90
+ export { a as mergeSuiteSelection, o as useSuiteSelection };
@@ -2,131 +2,46 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
- import "../../../shared/data-access/dist/index.js";
7
- import { ErrorState as t } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
8
- import "../../../shared/ui/dist/index.js";
9
- import { useAnalyticsTrack as n } from "../../../shared/feature/dist/lib/analytics/hooks.js";
10
- import { WidgetProvider as r } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
11
- import { useRefetchWidget as i, useWidgetConfig as a, useWidgetError as o, useWidgetInitStaleForToken as s } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
- import "../../../shared/feature/dist/index.js";
13
- import { AcceptDisclosuresWidget as c } from "../../../accept-disclosures-widget/feature/dist/index4.js";
14
- import "../../../accept-disclosures-widget/feature/dist/index.js";
15
- import { WIDGET_SUITE_CONTENT_LABELS_EN as l, WIDGET_SUITE_DISCLOSURE_LABELS_EN as u, WIDGET_SUITE_SECTION_LABELS_EN as d, WIDGET_SUITE_SECTION_TITLE_LABELS_EN as f } from "./index4.js";
16
- import { WIDGET_SUITE_SECTIONS as p } from "./index5.js";
17
- import { WIDGET_NAME as m, WidgetSuiteAnalyticsEvent as h } from "./index2.js";
18
- import { needsDisclosureAcceptance as g } from "./index3.js";
19
- import { WidgetSuiteShell as _ } from "../../ui/dist/index3.js";
20
- import { SectionPageTitle as v } from "../../ui/dist/index4.js";
21
- import "../../ui/dist/index.js";
22
- import { useCallback as y, useEffect as b, useMemo as x, useState as S } from "react";
23
- import { Fragment as C, jsx as w, jsxs as T } from "react/jsx-runtime";
5
+ import { mergeSuiteSelection as e, useSuiteSelection as t } from "./index5.js";
6
+ import { createContext as n, useCallback as r, useContext as i } from "react";
7
+ import { jsx as a } from "react/jsx-runtime";
24
8
  //#region ../../libs/tesouro-embedded-components-react/widget-suite/feature/dist/index6.js
25
- var E = {
26
- initFailed: "widget-suite-init-failed",
27
- disclosuresRefreshFailed: "widget-suite-disclosures-refresh-failed"
28
- };
29
- function D({ sections: r, labels: m, sectionLabels: D, sectionTitleLabels: O, contentLabels: k, disclosureLabels: A, showSectionTitle: j = !0 }) {
30
- let M = n();
31
- b(() => {
32
- M(h.Mounted);
33
- }, [M]);
34
- let N = {
35
- ...d,
36
- ...D
37
- }, { initResponse: P } = a(), F = o(), I = s(), L = P?.scopes, R = x(() => ({
38
- creditCards: {
39
- ...l.creditCards,
40
- ...k?.creditCards
9
+ var o = n(null);
10
+ function s({ sections: n, availableSections: i, grantedScopes: s, contentLabels: c, selection: l, defaultSelection: u, onSelectionChange: d, children: f }) {
11
+ let { resolvedSelection: p, applyPatch: m } = t({
12
+ selection: l,
13
+ defaultSelection: u,
14
+ sections: n
15
+ }), h = p.section, g = h && i.includes(h) ? h : i.at(0), _ = r((t) => {
16
+ let n = e({
17
+ ...p,
18
+ section: g
19
+ }, t);
20
+ m(t), d?.(n);
21
+ }, [
22
+ g,
23
+ m,
24
+ d,
25
+ p
26
+ ]);
27
+ return /* @__PURE__ */ a(o.Provider, {
28
+ value: {
29
+ availableSections: i,
30
+ activeSection: g,
31
+ grantedScopes: s,
32
+ contentLabels: c,
33
+ selection: l,
34
+ defaultSelection: u,
35
+ resolvedSelection: p,
36
+ navigate: _
41
37
  },
42
- debitCards: {
43
- ...l.debitCards,
44
- ...k?.debitCards
45
- },
46
- expensePlaceholders: {
47
- ...l.expensePlaceholders,
48
- ...k?.expensePlaceholders
49
- }
50
- }), [k]), [z, B] = S(r[0] ?? ""), V = i(), [H, U] = S(!1), W = y(() => U(!0), []), G = g(P), K = {
51
- ...u,
52
- ...A,
53
- initFailedState: {
54
- ...u.initFailedState,
55
- ...A?.initFailedState
56
- },
57
- refreshFailedState: {
58
- ...u.refreshFailedState,
59
- ...A?.refreshFailedState
60
- }
61
- };
62
- b(() => {
63
- !G && H && U(!1);
64
- }, [H, G]);
65
- let q = !!(P && I);
66
- if (!P && !F || q && !F) return /* @__PURE__ */ w(_, {
67
- isLoading: !0,
68
- sections: [],
69
- selectedSectionId: "",
70
- onSectionChange: B,
71
- labels: m
72
- });
73
- if ((!P || q) && F) return /* @__PURE__ */ w(t, {
74
- title: K.initFailedState.title,
75
- description: K.initFailedState.body,
76
- retryLabel: K.initFailedState.retryButton,
77
- onRetry: V,
78
- testId: E.initFailed
79
- });
80
- if (G) return H && F ? /* @__PURE__ */ w(t, {
81
- title: K.refreshFailedState.title,
82
- description: K.refreshFailedState.body,
83
- retryLabel: K.refreshFailedState.retryButton,
84
- onRetry: V,
85
- testId: E.disclosuresRefreshFailed
86
- }) : /* @__PURE__ */ w(c, { onAccepted: W });
87
- let J = P?.bankName?.trim(), Y = J ? {
88
- ...f,
89
- ...O
90
- }.bankTagline.replaceAll("{bankName}", J) : void 0, X = r.flatMap((t) => {
91
- let n = p[t];
92
- if (!n || n.anyOfScopes && !e(L, n.anyOfScopes)) return [];
93
- let r = N[t], i = n.render({
94
- grantedScopes: L,
95
- labels: R
96
- });
97
- return [{
98
- id: t,
99
- label: r,
100
- content: j && !n.rendersOwnTitle ? /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w(v, {
101
- title: r,
102
- bankTagline: Y
103
- }), i] }) : i
104
- }];
105
- }), Z = X.some((e) => e.id === z) ? z : X[0]?.id ?? "";
106
- return /* @__PURE__ */ w(_, {
107
- sections: X,
108
- selectedSectionId: Z,
109
- onSectionChange: B,
110
- labels: m
38
+ children: f
111
39
  });
112
40
  }
113
- function O({ baseUrl: e, widgetToken: t, organizationId: n, configClient: i, gatewayRouting: a, linkComponent: o, implementation: s, uiFramework: c, errorFallback: l, onError: u, analytics: d, disclosuresAcceptance: f, ...p }) {
114
- return /* @__PURE__ */ w(r, {
115
- widgetName: m,
116
- baseUrl: e,
117
- widgetToken: t,
118
- organizationId: n,
119
- configClient: i,
120
- gatewayRouting: a,
121
- linkComponent: o,
122
- implementation: s,
123
- uiFramework: c,
124
- errorFallback: l,
125
- onError: u,
126
- analytics: d,
127
- disclosuresAcceptance: f,
128
- children: /* @__PURE__ */ w(D, { ...p })
129
- });
41
+ function c() {
42
+ let e = i(o);
43
+ if (!e) throw Error("useWidgetSuiteProvider must be called inside a section rendered by WidgetSuite.");
44
+ return e;
130
45
  }
131
46
  //#endregion
132
- export { E as WIDGET_SUITE_TEST_IDS, O as WidgetSuite, O as default };
47
+ export { s as WidgetSuiteProvider, c as useWidgetSuiteProvider };
@@ -0,0 +1,148 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
+ import "../../../shared/data-access/dist/index.js";
8
+ import { CardProgram as n } from "../../../shared/feature/dist/lib/card/cardProgram.js";
9
+ import "../../../shared/feature/dist/index.js";
10
+ import { BankAccountsWidget as r } from "../../../bank-accounts-widget/feature/dist/index8.js";
11
+ import "../../../bank-accounts-widget/feature/dist/index.js";
12
+ import { BillPayWidget as i } from "../../../bill-pay-widget/feature/dist/index34.js";
13
+ import "../../../bill-pay-widget/feature/dist/index.js";
14
+ import { CardsWidget as a } from "../../../cards-widget/feature/dist/index8.js";
15
+ import "../../../cards-widget/feature/dist/index.js";
16
+ import { BalancesWidget as o } from "../../../balances-widget/feature/dist/index5.js";
17
+ import "../../../balances-widget/feature/dist/index.js";
18
+ import { InsightsWidget as s } from "../../../insights-widget/feature/dist/index11.js";
19
+ import "../../../insights-widget/feature/dist/index.js";
20
+ import { InvoicingWidget as c } from "../../../invoicing-widget/feature/dist/index3.js";
21
+ import "../../../invoicing-widget/feature/dist/index.js";
22
+ import { SettingsWidget as l } from "../../../settings-widget/feature/dist/index6.js";
23
+ import "../../../settings-widget/feature/dist/index.js";
24
+ import { TransfersWidget as u } from "../../../transfers-widget/feature/dist/index6.js";
25
+ import "../../../transfers-widget/feature/dist/index.js";
26
+ import { useWidgetSuiteProvider as d } from "./index6.js";
27
+ import { jsx as f, jsxs as p } from "react/jsx-runtime";
28
+ //#region ../../libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js
29
+ var m = ({ children: e }) => /* @__PURE__ */ f("div", {
30
+ className: "ttw:rounded-md ttw:border ttw:border-dashed ttw:border-border ttw:p-8 ttw:text-sm ttw:text-muted-foreground",
31
+ children: e
32
+ }), h = {
33
+ Dashboard: "dashboard",
34
+ Accounts: "accounts",
35
+ Cards: "cards",
36
+ Transfers: "transfers",
37
+ BillPay: "bill-pay",
38
+ Invoicing: "invoicing",
39
+ Expenses: "expenses",
40
+ Settings: "settings"
41
+ }, g = [
42
+ h.Dashboard,
43
+ h.Accounts,
44
+ h.Cards,
45
+ h.Transfers,
46
+ h.BillPay,
47
+ h.Invoicing,
48
+ h.Expenses,
49
+ h.Settings
50
+ ];
51
+ function _() {
52
+ let { grantedScopes: n, availableSections: r, navigate: i } = d(), a = e(n, [t.BankAccountReadOrg]), c = r.includes(h.Accounts), l = r.includes(h.Transfers);
53
+ return /* @__PURE__ */ p("div", {
54
+ className: a ? "ttw:grid ttw:gap-4 ttw:md:grid-cols-2" : "ttw:grid ttw:gap-4",
55
+ children: [a && /* @__PURE__ */ f(o, {
56
+ onViewAllAccountsClick: c ? () => i({ section: h.Accounts }) : void 0,
57
+ onBalanceRowClick: c ? (e) => i({
58
+ section: h.Accounts,
59
+ accounts: { accountId: e }
60
+ }) : void 0
61
+ }), /* @__PURE__ */ f(s, { onLinkExternalAccountClick: l ? () => i({ section: h.Transfers }) : void 0 })]
62
+ });
63
+ }
64
+ function v() {
65
+ let { resolvedSelection: e, navigate: t } = d();
66
+ return /* @__PURE__ */ f(r, {
67
+ selectedAccountId: e.accounts.accountId,
68
+ onSelectedAccountIdChange: (e) => t({ accounts: { accountId: e } })
69
+ });
70
+ }
71
+ function y() {
72
+ let { grantedScopes: r, contentLabels: i, resolvedSelection: o, selection: s, defaultSelection: c, navigate: l } = d();
73
+ return /* @__PURE__ */ p("div", {
74
+ className: "ttw:grid ttw:gap-8",
75
+ children: [e(r, [t.CreditCardReadOrg]) && /* @__PURE__ */ f(a, {
76
+ cardProgram: n.Credit,
77
+ labels: i.creditCards,
78
+ selectedCardId: o.creditCards.cardId,
79
+ onSelectedCardIdChange: (e) => l({ creditCards: { cardId: e } }),
80
+ pagination: s?.creditCards?.pagination,
81
+ defaultPagination: c?.creditCards?.pagination,
82
+ onPaginationChange: (e) => l({ creditCards: { pagination: e } })
83
+ }), e(r, [t.DebitCardReadOrg]) && /* @__PURE__ */ f(a, {
84
+ cardProgram: n.Debit,
85
+ labels: i.debitCards,
86
+ selectedCardId: o.debitCards.cardId,
87
+ onSelectedCardIdChange: (e) => l({ debitCards: { cardId: e } }),
88
+ pagination: s?.debitCards?.pagination,
89
+ defaultPagination: c?.debitCards?.pagination,
90
+ onPaginationChange: (e) => l({ debitCards: { pagination: e } })
91
+ })]
92
+ });
93
+ }
94
+ function b() {
95
+ return /* @__PURE__ */ f(u, {});
96
+ }
97
+ function x() {
98
+ return /* @__PURE__ */ f(i, {});
99
+ }
100
+ function S() {
101
+ return /* @__PURE__ */ f(c, {});
102
+ }
103
+ function C() {
104
+ let { contentLabels: e } = d();
105
+ return /* @__PURE__ */ f(m, { children: e.expensePlaceholders.expensesUnavailable });
106
+ }
107
+ function w() {
108
+ let { selection: e, navigate: t } = d();
109
+ return /* @__PURE__ */ f(l, {
110
+ selectedSection: e?.settings?.section,
111
+ onSelectedSectionChange: (e) => t({ settings: { section: e } })
112
+ });
113
+ }
114
+ var T = {
115
+ [h.Dashboard]: { Content: _ },
116
+ [h.Accounts]: {
117
+ anyOfScopes: [t.BankAccountReadOrg, t.ExternalBankAccountReadOrg],
118
+ rendersOwnTitle: !0,
119
+ Content: v
120
+ },
121
+ [h.Cards]: {
122
+ anyOfScopes: [t.CreditCardReadOrg, t.DebitCardReadOrg],
123
+ rendersOwnTitle: !0,
124
+ Content: y
125
+ },
126
+ [h.Transfers]: {
127
+ anyOfScopes: [t.BankAccountReadOrg],
128
+ Content: b
129
+ },
130
+ [h.BillPay]: {
131
+ anyOfScopes: [t.PayableReadOrg],
132
+ Content: x
133
+ },
134
+ [h.Invoicing]: {
135
+ anyOfScopes: [t.InvoiceReadOrg],
136
+ Content: S
137
+ },
138
+ [h.Expenses]: {
139
+ anyOfScopes: [t.ExpenseReadOrg, t.ExpenseReadSelf],
140
+ Content: C
141
+ },
142
+ [h.Settings]: {
143
+ rendersOwnTitle: !0,
144
+ Content: w
145
+ }
146
+ };
147
+ //#endregion
148
+ export { g as WIDGET_SUITE_DEFAULT_SECTIONS, T as WIDGET_SUITE_SECTIONS, h as WidgetSuiteSectionId };
@@ -0,0 +1,144 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { hasAnyScope as e } from "../../../shared/data-access/dist/lib/hasAnyScope.js";
6
+ import "../../../shared/data-access/dist/index.js";
7
+ import { ErrorState as t } from "../../../shared/ui/dist/lib/ErrorState/ErrorState.js";
8
+ import "../../../shared/ui/dist/index.js";
9
+ import { useAnalyticsTrack as n } from "../../../shared/feature/dist/lib/analytics/hooks.js";
10
+ import { WidgetProvider as r } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
11
+ import { useRefetchWidget as i, useWidgetConfig as a, useWidgetError as o, useWidgetInitStaleForToken as s } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
+ import "../../../shared/feature/dist/index.js";
13
+ import { AcceptDisclosuresWidget as c } from "../../../accept-disclosures-widget/feature/dist/index4.js";
14
+ import "../../../accept-disclosures-widget/feature/dist/index.js";
15
+ import { WIDGET_SUITE_CONTENT_LABELS_EN as l, WIDGET_SUITE_DISCLOSURE_LABELS_EN as u, WIDGET_SUITE_SECTION_LABELS_EN as d, WIDGET_SUITE_SECTION_TITLE_LABELS_EN as f } from "./index4.js";
16
+ import { WidgetSuiteProvider as p, useWidgetSuiteProvider as m } from "./index6.js";
17
+ import { WIDGET_SUITE_SECTIONS as h } from "./index7.js";
18
+ import { WIDGET_NAME as g, WidgetSuiteAnalyticsEvent as _ } from "./index2.js";
19
+ import { needsDisclosureAcceptance as v } from "./index3.js";
20
+ import { WidgetSuiteShell as y } from "../../ui/dist/index3.js";
21
+ import { SectionPageTitle as b } from "../../ui/dist/index4.js";
22
+ import "../../ui/dist/index.js";
23
+ import { useCallback as x, useEffect as S, useMemo as C, useState as w } from "react";
24
+ import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
25
+ //#region ../../libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js
26
+ var O = {
27
+ initFailed: "widget-suite-init-failed",
28
+ disclosuresRefreshFailed: "widget-suite-disclosures-refresh-failed"
29
+ };
30
+ function k({ labels: e, sectionLabels: n, sectionTitleLabels: r, disclosureLabels: l, showSectionTitle: p = !0 }) {
31
+ let { availableSections: g, activeSection: _, navigate: C } = m(), { initResponse: k } = a(), A = o(), j = s(), M = i(), N = {
32
+ ...d,
33
+ ...n
34
+ }, P = x((e) => C({ section: e }), [C]), [F, I] = w(!1), L = x(() => I(!0), []), R = v(k), z = {
35
+ ...u,
36
+ ...l,
37
+ initFailedState: {
38
+ ...u.initFailedState,
39
+ ...l?.initFailedState
40
+ },
41
+ refreshFailedState: {
42
+ ...u.refreshFailedState,
43
+ ...l?.refreshFailedState
44
+ }
45
+ };
46
+ S(() => {
47
+ !R && F && I(!1);
48
+ }, [F, R]);
49
+ let B = !!(k && j);
50
+ if (!k && !A || B && !A) return /* @__PURE__ */ E(y, {
51
+ isLoading: !0,
52
+ sections: [],
53
+ selectedSectionId: "",
54
+ onSectionChange: P,
55
+ labels: e
56
+ });
57
+ if ((!k || B) && A) return /* @__PURE__ */ E(t, {
58
+ title: z.initFailedState.title,
59
+ description: z.initFailedState.body,
60
+ retryLabel: z.initFailedState.retryButton,
61
+ onRetry: M,
62
+ testId: O.initFailed
63
+ });
64
+ if (R) return F && A ? /* @__PURE__ */ E(t, {
65
+ title: z.refreshFailedState.title,
66
+ description: z.refreshFailedState.body,
67
+ retryLabel: z.refreshFailedState.retryButton,
68
+ onRetry: M,
69
+ testId: O.disclosuresRefreshFailed
70
+ }) : /* @__PURE__ */ E(c, { onAccepted: L });
71
+ let V = k?.bankName?.trim(), H = V ? {
72
+ ...f,
73
+ ...r
74
+ }.bankTagline.replaceAll("{bankName}", V) : void 0, U = g.map((e) => {
75
+ let { Content: t, rendersOwnTitle: n } = h[e], r = N[e];
76
+ return {
77
+ id: e,
78
+ label: r,
79
+ content: p && !n ? /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(b, {
80
+ title: r,
81
+ bankTagline: H
82
+ }), /* @__PURE__ */ E(t, {})] }) : /* @__PURE__ */ E(t, {})
83
+ };
84
+ });
85
+ return /* @__PURE__ */ E(y, {
86
+ sections: U,
87
+ selectedSectionId: _ ?? "",
88
+ onSectionChange: P,
89
+ labels: e
90
+ });
91
+ }
92
+ function A({ sections: t, selection: r, defaultSelection: i, onSelectionChange: o, contentLabels: s, ...c }) {
93
+ let u = n();
94
+ S(() => {
95
+ u(_.Mounted);
96
+ }, [u]);
97
+ let { initResponse: d } = a(), f = d?.scopes, m = C(() => ({
98
+ creditCards: {
99
+ ...l.creditCards,
100
+ ...s?.creditCards
101
+ },
102
+ debitCards: {
103
+ ...l.debitCards,
104
+ ...s?.debitCards
105
+ },
106
+ expensePlaceholders: {
107
+ ...l.expensePlaceholders,
108
+ ...s?.expensePlaceholders
109
+ }
110
+ }), [s]), g = t.filter((t) => {
111
+ let n = h[t];
112
+ return !!n && (!n.anyOfScopes || e(f, n.anyOfScopes));
113
+ });
114
+ return /* @__PURE__ */ E(p, {
115
+ sections: t,
116
+ availableSections: g,
117
+ grantedScopes: f,
118
+ contentLabels: m,
119
+ selection: r,
120
+ defaultSelection: i,
121
+ onSelectionChange: o,
122
+ children: /* @__PURE__ */ E(k, { ...c })
123
+ });
124
+ }
125
+ function j({ baseUrl: e, widgetToken: t, organizationId: n, configClient: i, gatewayRouting: a, linkComponent: o, implementation: s, uiFramework: c, errorFallback: l, onError: u, analytics: d, disclosuresAcceptance: f, ...p }) {
126
+ return /* @__PURE__ */ E(r, {
127
+ widgetName: g,
128
+ baseUrl: e,
129
+ widgetToken: t,
130
+ organizationId: n,
131
+ configClient: i,
132
+ gatewayRouting: a,
133
+ linkComponent: o,
134
+ implementation: s,
135
+ uiFramework: c,
136
+ errorFallback: l,
137
+ onError: u,
138
+ analytics: d,
139
+ disclosuresAcceptance: f,
140
+ children: /* @__PURE__ */ E(A, { ...p })
141
+ });
142
+ }
143
+ //#endregion
144
+ export { O as WIDGET_SUITE_TEST_IDS, j as WidgetSuite, j as default };