@tesouro/embedded-components-react 0.11.111 → 0.11.114

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/dist/experimental/BalanceHistoryWidget.d.ts +702 -0
  2. package/dist/experimental/BalanceHistoryWidget.js +5 -0
  3. package/dist/experimental/index.d.ts +93 -2
  4. package/dist/experimental/index.js +7 -4
  5. package/dist/index.css +9 -0
  6. package/dist/index.d.ts +2607 -2525
  7. package/dist/lib/WidgetSuite.d.ts +1210 -8
  8. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/data-access/dist/index.js +3 -0
  9. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/data-access/dist/index2.js +89 -0
  10. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/data-access/dist/index3.js +19 -0
  11. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/index.js +4 -0
  12. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/BalanceHistoryWidgetFeature.js +159 -0
  13. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/labels.js +31 -0
  14. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/testIds.js +12 -0
  15. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/analytics/events.js +3 -0
  16. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/balanceHistoryView/balanceHistoryRange.js +39 -0
  17. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/balanceHistoryView/buildBalanceHistoryView.js +70 -0
  18. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index.js +3 -0
  19. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index2.js +93 -0
  20. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index3.js +19 -0
  21. package/dist/libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index4.js +176 -0
  22. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +43 -43
  23. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +115 -115
  24. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +199 -175
  25. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/WidgetFrame/WidgetFrame.js +2 -2
  27. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/DashboardSection.js +28 -19
  28. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/lib/WidgetSuite/sections/InvoicingSection.js +2 -1
  29. package/package.json +2 -1
@@ -0,0 +1,3 @@
1
+ import { useBalanceHistoryQuery as e } from "./index2.js";
2
+ import { useBalanceHistoryAccountsQuery as t } from "./index3.js";
3
+ export { t as useBalanceHistoryAccountsQuery, e as useBalanceHistoryQuery };
@@ -0,0 +1,89 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { getAggregateHistoricalBalances as e, getBankAccountHistoricalBalances as t } from "../../../shared/data-access/dist/lib/rest/sdk.gen.js";
6
+ import { getAggregateHistoricalBalancesQueryKey as n, getBankAccountHistoricalBalancesQueryKey as r } from "../../../shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js";
7
+ import { withAuthEpochInfinite as i } from "../../../shared/data-access/dist/lib/withAuthEpoch.js";
8
+ import { useEmbedApi as a } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
9
+ import { organizationHeaders as o } from "../../../shared/data-access/dist/lib/organizationHeaders.js";
10
+ import { getAllPagesNextPageParam as s, isAllPagesResolving as c, useAutoFetchNextPage as l } from "../../../shared/data-access/dist/lib/allPages.js";
11
+ import "../../../shared/data-access/dist/index.js";
12
+ import { useMemo as u } from "react";
13
+ import { useInfiniteQuery as d } from "@tanstack/react-query";
14
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/data-access/dist/index2.js
15
+ var f = 100;
16
+ function p({ accountId: p, startDate: m, endDate: h, enabled: g }) {
17
+ let { client: _, organizationId: v, widgetToken: y, authEpoch: b, organizationStatus: x } = a(), S = o(v), C = !!(v && y) && (g === !0 || g === void 0), w = {
18
+ startDate: m,
19
+ endDate: h,
20
+ limit: f
21
+ }, T = d({
22
+ ...i(n({
23
+ client: _,
24
+ headers: S,
25
+ query: w
26
+ }), {
27
+ authEpoch: b,
28
+ organizationStatus: x
29
+ }, { suffix: ["all"] }),
30
+ enabled: C && !p,
31
+ initialPageParam: void 0,
32
+ queryFn: async ({ signal: t, pageParam: n }) => {
33
+ let { data: r } = await e({
34
+ client: _,
35
+ headers: S,
36
+ query: {
37
+ ...w,
38
+ ...n ? { pagination_token: n } : {}
39
+ },
40
+ signal: t,
41
+ throwOnError: !0
42
+ });
43
+ return r;
44
+ },
45
+ getNextPageParam: s
46
+ }), E = d({
47
+ ...i(r({
48
+ client: _,
49
+ headers: S,
50
+ path: { id: p ?? "" },
51
+ query: w
52
+ }), {
53
+ authEpoch: b,
54
+ organizationStatus: x
55
+ }, { suffix: ["all"] }),
56
+ enabled: C && !!p,
57
+ initialPageParam: void 0,
58
+ queryFn: async ({ signal: e, pageParam: n }) => {
59
+ let { data: r } = await t({
60
+ client: _,
61
+ headers: S,
62
+ path: { id: p ?? "" },
63
+ query: {
64
+ ...w,
65
+ ...n ? { pagination_token: n } : {}
66
+ },
67
+ signal: e,
68
+ throwOnError: !0
69
+ });
70
+ return r;
71
+ },
72
+ getNextPageParam: s
73
+ });
74
+ l(T, C && !p), l(E, C && !!p);
75
+ let D = p ? E : T;
76
+ return {
77
+ rows: u(() => {
78
+ if (D.data) return D.data.pages.flatMap((e) => e.data.map(({ asOfDate: e, balance: t }) => ({
79
+ asOfDate: e,
80
+ balance: t
81
+ }))).sort((e, t) => e.asOfDate.localeCompare(t.asOfDate));
82
+ }, [D.data]),
83
+ isLoading: D.isLoading,
84
+ isError: D.isError,
85
+ isResolving: c(D),
86
+ refetch: D.refetch
87
+ };
88
+ }
89
+ export { p as useBalanceHistoryQuery };
@@ -0,0 +1,19 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { isAllPagesResolving as e } from "../../../shared/data-access/dist/lib/allPages.js";
6
+ import { useAllBankAccountsQuery as t } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
7
+ import "../../../shared/data-access/dist/index.js";
8
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/data-access/dist/index3.js
9
+ function n({ enabled: n } = {}) {
10
+ let r = t({ enabled: n }), { data: i, isLoading: a, isError: o, refetch: s } = r;
11
+ return {
12
+ accounts: i?.data,
13
+ isLoading: a,
14
+ isError: o,
15
+ isResolving: e(r),
16
+ refetch: s
17
+ };
18
+ }
19
+ export { n as useBalanceHistoryAccountsQuery };
@@ -0,0 +1,4 @@
1
+ import { BALANCE_HISTORY_RANGES as e, BalanceHistoryRange as t } from "./lib/balanceHistoryView/balanceHistoryRange.js";
2
+ import { BALANCE_HISTORY_WIDGET_LABELS_EN as n } from "./lib/BalanceHistoryWidget/labels.js";
3
+ import { BalanceHistoryWidget as r } from "./lib/BalanceHistoryWidget/BalanceHistoryWidgetFeature.js";
4
+ export { e as BALANCE_HISTORY_RANGES, n as BALANCE_HISTORY_WIDGET_LABELS_EN, t as BalanceHistoryRange, r as BalanceHistoryWidget };
@@ -0,0 +1,159 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { amountOutputToMajorUnits as e } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
6
+ import "../../../../../shared/util/dist/index.js";
7
+ import { OrganizationStatus as t, isOrganizationOnItsWay as n } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
8
+ import { useEmbedApi as r } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
9
+ import { Scope as i } from "../../../../../shared/data-access/dist/lib/scopes.js";
10
+ import "../../../../../shared/data-access/dist/index.js";
11
+ import { useAnalyticsTrack as a } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
12
+ import { WidgetProvider as o } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
13
+ import { useRefetchWidget as ee, useWidgetConfig as te, useWidgetError as ne, useWidgetInitStaleForToken as re, useWidgetLoading as ie } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
14
+ import { useLocalCalendarDay as ae } from "../../../../../shared/feature/dist/lib/calendar/useLocalCalendarDay.js";
15
+ import "../../../../../shared/feature/dist/index.js";
16
+ import { BALANCE_HISTORY_RANGES as oe, BalanceHistoryRange as s, balanceHistoryFetchDates as c, isBalanceHistoryRange as l, isRangeOldEnough as se, localIsoDate as u } from "../balanceHistoryView/balanceHistoryRange.js";
17
+ import { BalanceHistoryCard as ce } from "../../../../ui/dist/index4.js";
18
+ import "../../../../ui/dist/index.js";
19
+ import { BALANCE_HISTORY_WIDGET_LABELS_EN as d } from "./labels.js";
20
+ import { buildBalanceHistoryView as le, moneyFormatter as f, shortCalendarDate as ue } from "../balanceHistoryView/buildBalanceHistoryView.js";
21
+ import { BalanceHistoryWidgetAnalyticsEvent as de, WIDGET_NAME as p } from "../analytics/events.js";
22
+ import { balanceHistoryWidgetTestIds as fe } from "./testIds.js";
23
+ import { useBalanceHistoryQuery as pe } from "../../../../data-access/dist/index2.js";
24
+ import { useBalanceHistoryAccountsQuery as me } from "../../../../data-access/dist/index3.js";
25
+ import "../../../../data-access/dist/index.js";
26
+ import { useCallback as m, useEffect as h, useMemo as g, useState as _ } from "react";
27
+ import { jsx as v } from "react/jsx-runtime";
28
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/BalanceHistoryWidgetFeature.js
29
+ var y = "all", he = [];
30
+ function b({ labels: o, defaultRange: p = s.Days30, onTransferFromExternalClick: b, className: x, style: ge }) {
31
+ let S = g(() => ({
32
+ ...d,
33
+ ...o,
34
+ ranges: {
35
+ ...d.ranges,
36
+ ...o?.ranges
37
+ },
38
+ rangeSpans: {
39
+ ...d.rangeSpans,
40
+ ...o?.rangeSpans
41
+ },
42
+ rangeTooYoung: {
43
+ ...d.rangeTooYoung,
44
+ ...o?.rangeTooYoung
45
+ }
46
+ }), [o]), C = a();
47
+ h(() => {
48
+ C(de.Mounted);
49
+ }, [C]);
50
+ let [w, _e] = _(p), [T, ve] = _({}), { initResponse: E } = te(), ye = ie(), be = ne(), D = ee(), { organizationId: O, organizationStatus: k } = r(), A = k === t.Rotating, j = A && O == null, M = m((e) => ve((t) => ({
51
+ organizationId: j ? t.organizationId : O,
52
+ account: e || y
53
+ })), [O, j]), xe = n(k), N = E?.scopes?.includes(i.BankAccountReadOrg) ?? !1, P = re(), F = N && !P, I = me({ enabled: F }), L = I.accounts, R = L?.length === 1 ? L[0].id : y, z = T.organizationId === O || j ? T.account ?? R : R, B = z === y ? void 0 : z, V = L?.find(({ id: e }) => e === B), H = ae() ?? u(/* @__PURE__ */ new Date()), U = g(() => {
54
+ let e = (V ? [V.createdDateTime] : (L ?? []).map(({ createdDateTime: e }) => e)).map((e) => u(new Date(e)));
55
+ return e.length ? e.reduce((e, t) => e < t ? e : t) : void 0;
56
+ }, [V, L]), W = U ? c({
57
+ range: w,
58
+ openedDate: U,
59
+ today: H
60
+ }) : void 0, G = pe({
61
+ accountId: B,
62
+ startDate: W?.startDate ?? H,
63
+ endDate: W?.endDate ?? H,
64
+ enabled: F && !!W
65
+ }), K = W ? G.rows : U ? he : void 0, q = ye && !E || xe && !K || P && !K || I.isLoading || I.isResolving && !(A && L) || G.isLoading || G.isResolving && !(A && K), J = !!be && !K || I.isError || G.isError, Y = I.refetch, X = G.refetch, Se = m(() => {
66
+ D(), F && O && (Y(), X());
67
+ }, [
68
+ D,
69
+ Y,
70
+ X,
71
+ F,
72
+ O
73
+ ]), Ce = g(() => {
74
+ if (!L) return [];
75
+ let t = f(L[0]?.balance.currencyCode || "USD"), n = L.reduce((t, { balance: n }) => t + e(n), 0);
76
+ return [{
77
+ value: y,
78
+ label: S.allAccounts,
79
+ description: t(n)
80
+ }, ...L.map((t) => ({
81
+ value: t.id,
82
+ label: S.accountOption(t.nickname || t.nameOnAccount, t.accountNumber.slice(-4)),
83
+ description: f(t.balance.currencyCode || "USD")(e(t.balance))
84
+ }))];
85
+ }, [L, S]), Z = g(() => K && U ? le({
86
+ rows: K,
87
+ openedDate: U,
88
+ today: H,
89
+ range: w,
90
+ currencyCode: (V ?? L?.[0])?.balance.currencyCode || "USD",
91
+ holdsMoneyToday: (V ? [V] : L ?? []).some(({ balance: t }) => e(t) !== 0)
92
+ }) : void 0, [
93
+ K,
94
+ U,
95
+ H,
96
+ w,
97
+ V,
98
+ L
99
+ ]), we = oe.map((e) => {
100
+ let t = Z !== void 0 && !se(e, Z.historyDays), n = Z?.isUnfunded === !0;
101
+ return {
102
+ value: e,
103
+ label: S.ranges[e],
104
+ disabled: t || n,
105
+ disabledReason: t ? S.rangeTooYoung[e] : n ? S.rangeNeedsMoney : void 0
106
+ };
107
+ }), Q = b ? {
108
+ label: S.transferFromExternal,
109
+ onClick: b
110
+ } : void 0, Te = Z?.isUnfunded ? Z.range === void 0 ? {
111
+ title: S.addMoney,
112
+ action: Q
113
+ } : {
114
+ title: S.accountReady,
115
+ action: Q
116
+ } : void 0, $ = Z ? Z.isSinceOpened && U ? S.sinceOpened(ue(U)) : Z.range ? S.rangeSpans[Z.range] : "" : "", Ee = Z ? Z.isUnfunded ? $ : S.changeDescription($, Z.firstBalance, Z.lastBalance) : "";
117
+ return E && !N || k === t.None || !q && !J && L?.length === 0 ? null : /* @__PURE__ */ v(ce, {
118
+ accountOptions: Ce,
119
+ selectedAccount: z,
120
+ onAccountChange: M,
121
+ rangeOptions: we,
122
+ selectedRange: Z ? Z.isUnfunded ? "" : Z.range ?? "" : w,
123
+ onRangeChange: (e) => {
124
+ l(e) && _e(e);
125
+ },
126
+ change: Z?.change ?? "",
127
+ changeSpokenLabel: Z?.isChangeNegative ? S.negativeAmount(Z.changeMagnitude) : void 0,
128
+ changeDescription: Ee,
129
+ points: Z?.points ?? [],
130
+ xDomain: Z?.xDomain ?? [0, 0],
131
+ xTicks: Z?.xTicks ?? [],
132
+ yDomain: Z?.yDomain,
133
+ yTicks: Z?.yTicks,
134
+ yTickLabel: Z?.yTickLabel ?? String,
135
+ markFirstPoint: Z?.isUnfunded,
136
+ emptyNotice: Te,
137
+ isLoading: q,
138
+ isError: J,
139
+ onRetry: J ? Se : void 0,
140
+ labels: S,
141
+ testIds: fe,
142
+ className: x,
143
+ style: ge
144
+ });
145
+ }
146
+ function x({ labels: e, defaultRange: t, onTransferFromExternalClick: n, className: r, style: i, ...a }) {
147
+ return /* @__PURE__ */ v(o, {
148
+ ...a,
149
+ widgetName: p,
150
+ children: /* @__PURE__ */ v(b, {
151
+ labels: e,
152
+ defaultRange: t,
153
+ onTransferFromExternalClick: n,
154
+ className: r,
155
+ style: i
156
+ })
157
+ });
158
+ }
159
+ export { x as BalanceHistoryWidget, b as BalanceHistoryWidgetWithContext };
@@ -0,0 +1,31 @@
1
+ import { BALANCE_HISTORY_CARD_LABELS_EN as e } from "../../../../ui/dist/index3.js";
2
+ import "../../../../ui/dist/index.js";
3
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/labels.js
4
+ var t = {
5
+ ...e,
6
+ allAccounts: "All accounts",
7
+ accountOption: (e, t) => `${e} - ${t}`,
8
+ ranges: {
9
+ "30d": "30D",
10
+ "90d": "90D",
11
+ "1y": "1Y"
12
+ },
13
+ rangeSpans: {
14
+ "30d": "in the last 30 days",
15
+ "90d": "in the last 90 days",
16
+ "1y": "in the last year"
17
+ },
18
+ rangeTooYoung: {
19
+ "30d": "Available after 30 days of history",
20
+ "90d": "Available after 90 days of history",
21
+ "1y": "Available after 1 year of history"
22
+ },
23
+ rangeNeedsMoney: "Available once money is added",
24
+ sinceOpened: (e) => `since account opened ${e}`,
25
+ changeDescription: (e, t, n) => `${e} · ${t} → ${n}`,
26
+ accountReady: "This account is ready",
27
+ addMoney: "Add money to start your balance history",
28
+ transferFromExternal: "Transfer from an external account",
29
+ negativeAmount: (e) => `negative ${e}`
30
+ };
31
+ export { t as BALANCE_HISTORY_WIDGET_LABELS_EN };
@@ -0,0 +1,12 @@
1
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/BalanceHistoryWidget/testIds.js
2
+ var e = {
3
+ root: "balance-history-widget",
4
+ accountSelect: "balance-history-widget-account-select",
5
+ rangeTabs: "balance-history-widget-range-tabs",
6
+ change: "balance-history-widget-change",
7
+ chart: "balance-history-widget-chart",
8
+ skeleton: "balance-history-widget-skeleton",
9
+ error: "balance-history-widget-error",
10
+ emptyNotice: "balance-history-widget-empty-notice"
11
+ };
12
+ export { e as balanceHistoryWidgetTestIds };
@@ -0,0 +1,3 @@
1
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/analytics/events.js
2
+ var e = "balance_history_widget", t = { Mounted: `${e}.mounted` };
3
+ export { t as BalanceHistoryWidgetAnalyticsEvent, e as WIDGET_NAME };
@@ -0,0 +1,39 @@
1
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/balanceHistoryView/balanceHistoryRange.js
2
+ var e = {
3
+ Days30: "30d",
4
+ Days90: "90d",
5
+ Year: "1y"
6
+ }, t = [
7
+ e.Days30,
8
+ e.Days90,
9
+ e.Year
10
+ ], n = {
11
+ [e.Days30]: 30,
12
+ [e.Days90]: 90,
13
+ [e.Year]: 365
14
+ }, r = n[e.Year];
15
+ function i(e) {
16
+ return t.includes(e);
17
+ }
18
+ var a = 864e5, o = (e) => Date.parse(`${e}T00:00:00Z`);
19
+ function s(e, t) {
20
+ return new Date(o(e) + t * a).toISOString().slice(0, 10);
21
+ }
22
+ function c(e, t) {
23
+ return Math.round((o(t) - o(e)) / a);
24
+ }
25
+ function l(e) {
26
+ let t = String(e.getMonth() + 1).padStart(2, "0"), n = String(e.getDate()).padStart(2, "0");
27
+ return `${e.getFullYear()}-${t}-${n}`;
28
+ }
29
+ function u(t, r) {
30
+ return t === e.Days30 || r >= n[t];
31
+ }
32
+ function d({ range: e, openedDate: t, today: i }) {
33
+ let a = s(i, -1), o = c(t, i) < r ? t : s(a, 1 - n[e]);
34
+ return o <= a ? {
35
+ startDate: o,
36
+ endDate: a
37
+ } : void 0;
38
+ }
39
+ export { t as BALANCE_HISTORY_RANGES, e as BalanceHistoryRange, r as LONGEST_RANGE_DAYS, n as RANGE_DAYS, s as addDays, d as balanceHistoryFetchDates, c as daysBetween, i as isBalanceHistoryRange, u as isRangeOldEnough, l as localIsoDate };
@@ -0,0 +1,70 @@
1
+ import { amountOutputToMajorUnits as e, minorExponentForCurrency as t } from "../../../../../shared/util/dist/lib/amountOutputToMajorUnits.js";
2
+ import { formatCalendarDate as n } from "../../../../../shared/util/dist/lib/formatCalendarDate.js";
3
+ import { formatAccountingAmount as r } from "../../../../../shared/util/dist/lib/formatAccountingAmount.js";
4
+ import { formatMoneyExact as i } from "../../../../../shared/util/dist/lib/formatMoneyExact.js";
5
+ import "../../../../../shared/util/dist/index.js";
6
+ import { BalanceHistoryRange as a, LONGEST_RANGE_DAYS as o, RANGE_DAYS as s, addDays as c, daysBetween as l, isRangeOldEnough as u } from "./balanceHistoryRange.js";
7
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/feature/dist/lib/balanceHistoryView/buildBalanceHistoryView.js
8
+ var d = 14, f = s[a.Days90];
9
+ function p(e, t) {
10
+ if (t < f) return Array.from({ length: Math.floor(t / d) + 1 }, (e, t) => t * d);
11
+ let n = [];
12
+ for (let r = 0; r <= t; r++) c(e, r).endsWith("-01") && n.push(r);
13
+ return n;
14
+ }
15
+ var m = [0, 1e3];
16
+ function h(e) {
17
+ let n = t(e);
18
+ return (t) => i(t, {
19
+ currencyCode: e,
20
+ includeSpaceAfterCurrencySymbol: !1,
21
+ minimumFractionDigits: n,
22
+ maximumFractionDigits: n
23
+ });
24
+ }
25
+ var g = (e) => n(e).replace(/, \d{4}$/, "");
26
+ function _({ rows: t, openedDate: i, today: d, range: f, currencyCode: _, holdsMoneyToday: v }) {
27
+ let y = c(d, -1), b = Math.max(0, l(i, d)), x = b < o && !v && t.every((t) => e(t.balance) === 0), S = x && b > s[a.Days30] ? void 0 : x || !u(f, b) ? a.Days30 : f, C, w;
28
+ S === void 0 ? (C = i, w = y) : b < s[S] ? (C = i, w = c(i, s[S] - 1)) : (C = c(y, 1 - s[S]), w = y);
29
+ let T = C <= i, E = t[0]?.balance.currencyCode || _, D = t.filter((e) => e.asOfDate >= C && e.asOfDate <= w), O = D[0]?.asOfDate === i && e(D[0].balance) === 0, k = T && !O ? [{
30
+ asOfDate: i,
31
+ balance: {
32
+ value: 0,
33
+ currencyCode: E
34
+ }
35
+ }, ...D] : D, A = h(E), j = k.map((t) => {
36
+ let r = e(t.balance);
37
+ return {
38
+ x: l(C, t.asOfDate),
39
+ tooltipTitle: n(t.asOfDate),
40
+ value: r,
41
+ valueLabel: A(r)
42
+ };
43
+ }), M = l(C, w), N = p(C, M).map((e) => ({
44
+ value: e,
45
+ label: g(c(C, e))
46
+ })), P = j[0]?.value ?? 0, F = j[j.length - 1]?.value ?? 0, I = F - P, L = r(I, E), R = I > 0 && L.magnitude !== r(0, E).text, z = new Intl.NumberFormat("en-US", {
47
+ style: "currency",
48
+ currency: E,
49
+ notation: "compact",
50
+ maximumFractionDigits: 1
51
+ }), B = j.every((e) => e.value === 0);
52
+ return {
53
+ range: S,
54
+ historyDays: b,
55
+ isUnfunded: x,
56
+ isSinceOpened: T,
57
+ points: j,
58
+ xDomain: [0, M],
59
+ xTicks: N,
60
+ yDomain: B ? m : void 0,
61
+ yTicks: B ? [...m] : void 0,
62
+ change: R ? `+${L.text}` : L.text,
63
+ isChangeNegative: L.isNegative,
64
+ changeMagnitude: L.magnitude,
65
+ firstBalance: A(P),
66
+ lastBalance: A(F),
67
+ yTickLabel: (e) => e < 0 ? `(${z.format(-e)})` : z.format(e)
68
+ };
69
+ }
70
+ export { _ as buildBalanceHistoryView, h as moneyFormatter, g as shortCalendarDate };
@@ -0,0 +1,3 @@
1
+ import { BALANCE_HISTORY_CARD_LABELS_EN as e } from "./index3.js";
2
+ import { BalanceHistoryCard as t } from "./index4.js";
3
+ export { e as BALANCE_HISTORY_CARD_LABELS_EN, t as BalanceHistoryCard };
@@ -0,0 +1,93 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import { Area as n, AreaChart as r, CartesianGrid as i, ResponsiveContainer as a, Tooltip as o, XAxis as s, YAxis as c } from "recharts";
3
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index2.js
4
+ function l({ points: l, seriesName: u, tooltipSeparator: d, xDomain: f, xTicks: p, yDomain: m, yTicks: h, yTickLabel: g, markFirstPoint: _ = !1 }) {
5
+ let v = l.length - 1, y = new Map(p.map((e) => [e.value, e.label]));
6
+ return /* @__PURE__ */ e(a, {
7
+ width: "100%",
8
+ height: "100%",
9
+ children: /* @__PURE__ */ t(r, {
10
+ data: l,
11
+ margin: {
12
+ top: 8,
13
+ right: 16,
14
+ bottom: 0,
15
+ left: 0
16
+ },
17
+ children: [
18
+ /* @__PURE__ */ e(i, {
19
+ vertical: !1,
20
+ stroke: "var(--ttw-border)"
21
+ }),
22
+ /* @__PURE__ */ e(s, {
23
+ dataKey: "x",
24
+ type: "number",
25
+ domain: f,
26
+ ticks: p.map((e) => e.value),
27
+ tickFormatter: (e) => y.get(e) ?? "",
28
+ interval: "preserveStartEnd",
29
+ stroke: "var(--ttw-border)",
30
+ tick: { fill: "var(--ttw-muted-foreground)" },
31
+ tickLine: !1,
32
+ tickMargin: 8,
33
+ className: "ttw:text-xs"
34
+ }),
35
+ /* @__PURE__ */ e(c, {
36
+ dataKey: "value",
37
+ stroke: "var(--ttw-border)",
38
+ tick: { fill: "var(--ttw-muted-foreground)" },
39
+ tickLine: !1,
40
+ axisLine: !1,
41
+ tickFormatter: g,
42
+ domain: m ?? ["auto", "auto"],
43
+ ticks: h,
44
+ tickCount: 3,
45
+ width: "auto",
46
+ className: "ttw:text-xs"
47
+ }),
48
+ /* @__PURE__ */ e(o, {
49
+ isAnimationActive: !1,
50
+ cursor: { stroke: "var(--ttw-border)" },
51
+ content: ({ active: n, payload: r }) => {
52
+ let i = r?.[0]?.payload;
53
+ return !n || !i ? null : /* @__PURE__ */ t("div", {
54
+ className: "ttw:flex ttw:flex-col ttw:gap-1 ttw:rounded-md ttw:border ttw:border-border ttw:bg-popover ttw:px-3 ttw:py-2 ttw:text-xs ttw:text-popover-foreground ttw:shadow-md",
55
+ children: [/* @__PURE__ */ e("span", {
56
+ className: "ttw:font-medium",
57
+ children: i.tooltipTitle
58
+ }), /* @__PURE__ */ t("span", { children: [
59
+ u,
60
+ d,
61
+ /* @__PURE__ */ e("span", {
62
+ className: "ttw:tabular-nums",
63
+ children: i.valueLabel
64
+ })
65
+ ] })]
66
+ });
67
+ }
68
+ }),
69
+ /* @__PURE__ */ e(n, {
70
+ type: "monotone",
71
+ dataKey: "value",
72
+ name: u,
73
+ stroke: "var(--ttw-primary)",
74
+ strokeWidth: 2,
75
+ fill: "var(--ttw-primary)",
76
+ fillOpacity: .08,
77
+ isAnimationActive: !1,
78
+ dot: (t) => (t.index === v || _ && t.index === 0) && t.cx != null && t.cy != null ? /* @__PURE__ */ e("circle", {
79
+ cx: t.cx,
80
+ cy: t.cy,
81
+ r: 4,
82
+ fill: "var(--ttw-primary)"
83
+ }, t.index) : /* @__PURE__ */ e("g", {}, t.index),
84
+ activeDot: {
85
+ r: 4,
86
+ fill: "var(--ttw-primary)"
87
+ }
88
+ })
89
+ ]
90
+ })
91
+ });
92
+ }
93
+ export { l as BalanceHistoryChart };
@@ -0,0 +1,19 @@
1
+ // ../../libs/tesouro-embedded-components-react/balance-history-widget/ui/dist/index3.js
2
+ var e = {
3
+ title: "Balance history",
4
+ accountSelect: "Account",
5
+ accountSearchPlaceholder: "Search accounts",
6
+ accountSearchEmpty: "No matching accounts",
7
+ accountSearchClear: "Show all accounts",
8
+ rangeTabs: "Time range",
9
+ chart: "Balance over time",
10
+ seriesName: "Balance",
11
+ tooltipSeparator: ": ",
12
+ dataTable: "Balance by day",
13
+ dateColumn: "Date",
14
+ loading: "Loading balance history",
15
+ errorTitle: "Couldn’t load balance history",
16
+ errorDescription: "Check your connection and try again.",
17
+ retry: "Try again"
18
+ };
19
+ export { e as BALANCE_HISTORY_CARD_LABELS_EN };