@mx-cartographer/experiences 9.7.185 → 9.7.187
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/CHANGELOG.md +11 -0
- package/dist/common/components/charts/linechart/CustomMark.es.js +26 -29
- package/dist/common/components/charts/linechart/CustomMark.es.js.map +1 -1
- package/dist/common/utils/MouseOnly.d.ts +2 -0
- package/dist/common/utils/MouseOnly.es.js +8 -0
- package/dist/common/utils/MouseOnly.es.js.map +1 -0
- package/dist/core/types/localization/InsightsFeedCopy.d.ts +2 -0
- package/dist/insights/hooks/useContainerDimensions.es.js +11 -9
- package/dist/insights/hooks/useContainerDimensions.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js +79 -77
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/TransactionHistoryBlock.es.js.map +1 -1
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.d.ts +2 -0
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js +29 -30
- package/dist/insights-v2/actionBlocks/TransactionHistoryBlock/layout.es.js.map +1 -1
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js +19 -19
- package/dist/insights-v2/blocks/ChartBlocks/DonutChartBlock/DonutChart.es.js.map +1 -1
- package/dist/insights-v2/components/chartblocks/ChartLegend.d.ts +3 -1
- package/dist/insights-v2/components/chartblocks/ChartLegend.es.js +10 -10
- package/dist/insights-v2/components/chartblocks/ChartLegend.es.js.map +1 -1
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.d.ts +3 -1
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js +32 -31
- package/dist/insights-v2/components/chartblocks/DoubleBarChart.es.js.map +1 -1
- package/dist/networth/components/NetWorthListItem.es.js +25 -24
- package/dist/networth/components/NetWorthListItem.es.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import n from "@mui/material/Stack";
|
|
2
|
-
import { Text as
|
|
3
|
-
import { Fragment as
|
|
4
|
-
var
|
|
2
|
+
import { Text as o } from "@mxenabled/mxui";
|
|
3
|
+
import { Fragment as l, jsx as e, jsxs as h } from "react/jsx-runtime";
|
|
4
|
+
var m = ({ legendItems: c, legendStyle: a, boldLabel: g = !1, variant: s = "caption" }) => /* @__PURE__ */ e(n, {
|
|
5
5
|
sx: {
|
|
6
6
|
alignItems: "flex-start",
|
|
7
7
|
flexDirection: "row",
|
|
@@ -9,9 +9,9 @@ var x = ({ legendItems: a, legendStyle: c, boldLabel: g = !1 }) => /* @__PURE__
|
|
|
9
9
|
justifyContent: "flex-start",
|
|
10
10
|
py: 4,
|
|
11
11
|
width: "100%",
|
|
12
|
-
...
|
|
12
|
+
...a
|
|
13
13
|
},
|
|
14
|
-
children:
|
|
14
|
+
children: c.map(({ color: d, label: r, formattedAmount: i }, t) => r && /* @__PURE__ */ h(n, {
|
|
15
15
|
sx: {
|
|
16
16
|
alignItems: "center",
|
|
17
17
|
flexDirection: "row",
|
|
@@ -25,15 +25,15 @@ var x = ({ legendItems: a, legendStyle: c, boldLabel: g = !1 }) => /* @__PURE__
|
|
|
25
25
|
role: "figure",
|
|
26
26
|
width: "12",
|
|
27
27
|
children: /* @__PURE__ */ e("rect", {
|
|
28
|
-
fill:
|
|
28
|
+
fill: d,
|
|
29
29
|
height: "12",
|
|
30
30
|
rx: "2",
|
|
31
31
|
width: "12"
|
|
32
32
|
})
|
|
33
|
-
}), /* @__PURE__ */ e(
|
|
33
|
+
}), /* @__PURE__ */ e(o, {
|
|
34
34
|
id: t === 0 ? "chartLegendLabel" : r,
|
|
35
|
-
variant:
|
|
36
|
-
children: i ? g ? /* @__PURE__ */ h(
|
|
35
|
+
variant: s,
|
|
36
|
+
children: i ? g ? /* @__PURE__ */ h(l, { children: [
|
|
37
37
|
/* @__PURE__ */ e("strong", { children: `${r}:` }),
|
|
38
38
|
" ",
|
|
39
39
|
i
|
|
@@ -42,7 +42,7 @@ var x = ({ legendItems: a, legendStyle: c, boldLabel: g = !1 }) => /* @__PURE__
|
|
|
42
42
|
}, r ?? t))
|
|
43
43
|
});
|
|
44
44
|
export {
|
|
45
|
-
|
|
45
|
+
m as Legend
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
//# sourceMappingURL=ChartLegend.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartLegend.es.js","names":[],"sources":["../../../../src/insights-v2/components/chartblocks/ChartLegend.tsx"],"sourcesContent":["import { Text } from '@mxenabled/mxui'\n\nimport Stack from '@mui/material/Stack'\n\nimport type { SxProps } from '@mui/material/styles'\nimport type { LegendProps } from '../../../core/types/InsightsInstanceSlotData'\n\nexport interface LegendComponentProps {\n legendItems: LegendProps[]\n legendStyle?: SxProps\n /** Bold the label (\"Spend:\") and keep the amount regular. A legend item without an amount shows its label as is. */\n boldLabel?: boolean\n}\n\nexport const Legend = ({
|
|
1
|
+
{"version":3,"file":"ChartLegend.es.js","names":[],"sources":["../../../../src/insights-v2/components/chartblocks/ChartLegend.tsx"],"sourcesContent":["import { Text } from '@mxenabled/mxui'\n\nimport Stack from '@mui/material/Stack'\n\nimport type { SxProps } from '@mui/material/styles'\nimport type { LegendProps } from '../../../core/types/InsightsInstanceSlotData'\n\nexport interface LegendComponentProps {\n legendItems: LegendProps[]\n legendStyle?: SxProps\n /** Bold the label (\"Spend:\") and keep the amount regular. A legend item without an amount shows its label as is. */\n boldLabel?: boolean\n /** Text style: caption (11px) by default; body2 (13px) where the Figma frame draws it larger. */\n variant?: 'caption' | 'body2'\n}\n\nexport const Legend = ({\n legendItems,\n legendStyle,\n boldLabel = false,\n variant = 'caption',\n}: LegendComponentProps) => {\n return (\n <Stack\n sx={{\n alignItems: 'flex-start',\n flexDirection: 'row',\n gap: 24,\n justifyContent: 'flex-start',\n py: 4,\n width: '100%',\n ...legendStyle,\n }}\n >\n {legendItems.map(\n ({ color, label, formattedAmount }, index) =>\n label && (\n <Stack key={label ?? index} sx={{ alignItems: 'center', flexDirection: 'row', gap: 8 }}>\n <svg\n aria-hidden=\"true\"\n aria-labelledby={index === 0 ? 'chartLegendLabel' : label}\n fill=\"none\"\n height=\"12\"\n role=\"figure\"\n width=\"12\"\n >\n <rect fill={color} height=\"12\" rx=\"2\" width=\"12\" />\n </svg>\n <Text id={index === 0 ? 'chartLegendLabel' : label} variant={variant}>\n {formattedAmount ? (\n boldLabel ? (\n <>\n <strong>{`${label}:`}</strong> {formattedAmount}\n </>\n ) : (\n `${label}: ${formattedAmount}`\n )\n ) : (\n label\n )}\n </Text>\n </Stack>\n ),\n )}\n </Stack>\n )\n}\n"],"mappings":";;;AAgBA,IAAa,IAAA,CAAU,EACrB,aAAA,GACA,aAAA,GACA,WAAA,IAAY,IACZ,SAAA,IAAU,UAAA,MAGR,gBAAA,EAAC,GAAD;AAAA,EACE,IAAI;AAAA,IACF,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,KAAK;AAAA,IACL,gBAAgB;AAAA,IAChB,IAAI;AAAA,IACJ,OAAO;AAAA,IACP,GAAG;AAAA,EACL;AAAA,EAEC,UAAA,EAAY,IAAA,CACV,EAAE,OAAA,GAAO,OAAA,GAAO,iBAAA,EAAA,GAAmB,MAClC,KACE,gBAAA,EAAC,GAAD;AAAA,IAA4B,IAAI;AAAA,MAAE,YAAY;AAAA,MAAU,eAAe;AAAA,MAAO,KAAK;AAAA,IAAE;AAAA,IAArF,UAAA,CACE,gBAAA,EAAC,OAAD;AAAA,MACE,eAAY;AAAA,MACZ,mBAAiB,MAAU,IAAI,qBAAqB;AAAA,MACpD,MAAK;AAAA,MACL,QAAO;AAAA,MACP,MAAK;AAAA,MACL,OAAM;AAAA,MAEN,UAAA,gBAAA,EAAC,QAAD;AAAA,QAAM,MAAM;AAAA,QAAO,QAAO;AAAA,QAAK,IAAG;AAAA,QAAI,OAAM;AAAA,MAAM,CAAA;AAAA,IAC/C,CAAA,GACL,gBAAA,EAAC,GAAD;AAAA,MAAM,IAAI,MAAU,IAAI,qBAAqB;AAAA,MAAgB,SAAA;AAAA,MAC1D,UAAA,IACC,IACE,gBAAA,EAAA,GAAA,EAAA,UAAA;AAAA,QACE,gBAAA,EAAC,UAAD,EAAA,UAAS,GAAG,CAAA,IAAiB,CAAA;AAAA,QAAC;AAAA,QAAE;AAAA,MAChC,EAAA,CAAA,IAEF,GAAG,CAAA,KAAU,CAAA,KAGf;AAAA,IAEE,CAAA,CACD;AAAA,EAxBK,GAAA,KAAS,CAwBd,CAEb;AACK,CAAA"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Legends } from '../../../core';
|
|
2
2
|
import { DataSet } from '../../../core/types/InsightsInstanceSlotData';
|
|
3
|
+
import { LegendComponentProps } from './ChartLegend';
|
|
3
4
|
/** A full card's plot box; when set, the y-axis also ends at the tallest bar (Figma 1243:73833). */
|
|
4
5
|
export interface PlotSize {
|
|
5
6
|
height: number;
|
|
@@ -13,6 +14,7 @@ interface DoubleBarChartProps {
|
|
|
13
14
|
isMini?: boolean;
|
|
14
15
|
legendPosition?: 'top' | 'bottom';
|
|
15
16
|
boldLabel?: boolean;
|
|
17
|
+
legendVariant?: LegendComponentProps['variant'];
|
|
16
18
|
plotSize?: PlotSize;
|
|
17
19
|
selectedIndex?: number;
|
|
18
20
|
onBarClick: (columnIndex: number, subIndex: number) => void;
|
|
@@ -23,5 +25,5 @@ interface DoubleBarChartProps {
|
|
|
23
25
|
* selection, or data-shaping of its own. This mirrors BarChartV2; the DoubleBarChartBlock card
|
|
24
26
|
* wrapper builds the data and injects the store behavior, exactly as BarchartBlock wraps BarChartV2.
|
|
25
27
|
*/
|
|
26
|
-
export declare const DoubleBarChart: ({ bars, colors, legends, isMini, legendPosition, boldLabel, plotSize, selectedIndex, onBarClick, }: DoubleBarChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
28
|
+
export declare const DoubleBarChart: ({ bars, colors, legends, isMini, legendPosition, boldLabel, legendVariant, plotSize, selectedIndex, onBarClick, }: DoubleBarChartProps) => import("react/jsx-runtime").JSX.Element;
|
|
27
29
|
export {};
|
|
@@ -1,37 +1,38 @@
|
|
|
1
1
|
import { EmptyBarChart as A } from "./EmptyBarChart.es.js";
|
|
2
2
|
import { useContainerDimensions as T } from "../../hooks/useContainerDimensions.es.js";
|
|
3
|
-
import { CustomDoubleBarPlotMXUI as
|
|
4
|
-
import { Legend as
|
|
5
|
-
import
|
|
6
|
-
import
|
|
3
|
+
import { CustomDoubleBarPlotMXUI as N } from "./CustomDoubleBar.es.js";
|
|
4
|
+
import { Legend as R } from "./ChartLegend.es.js";
|
|
5
|
+
import M from "react";
|
|
6
|
+
import D from "@mui/material/Stack";
|
|
7
7
|
import { jsx as o, jsxs as b } from "react/jsx-runtime";
|
|
8
|
-
import
|
|
9
|
-
import { BarPlot as
|
|
10
|
-
import { ChartContainer as
|
|
11
|
-
import { ChartsXAxis as
|
|
12
|
-
var
|
|
8
|
+
import K from "@mui/material/Box";
|
|
9
|
+
import { BarPlot as P } from "@mui/x-charts/BarChart";
|
|
10
|
+
import { ChartContainer as _ } from "@mui/x-charts/ChartContainer";
|
|
11
|
+
import { ChartsXAxis as j } from "@mui/x-charts/ChartsXAxis";
|
|
12
|
+
var G = {
|
|
13
13
|
height: 172,
|
|
14
14
|
top: 0,
|
|
15
15
|
bottom: 16
|
|
16
|
-
},
|
|
16
|
+
}, O = {
|
|
17
17
|
height: 120,
|
|
18
18
|
top: 0,
|
|
19
19
|
bottom: 16
|
|
20
|
-
},
|
|
21
|
-
const m =
|
|
22
|
-
...
|
|
20
|
+
}, V = ({ bars: r, colors: n, legends: x, isMini: l = !1, legendPosition: s = "bottom", boldLabel: g = !1, legendVariant: y, plotSize: u, selectedIndex: C, onBarClick: I }) => {
|
|
21
|
+
const m = C ?? r.length - 1, k = 5e-3, w = 0.16, c = l ? void 0 : u, i = l ? O : {
|
|
22
|
+
...G,
|
|
23
23
|
...c
|
|
24
|
-
}, h = c ? Math.max(0, ...r.flatMap(({ main: e, comparison: t }) => [Number(e) || 0, Number(t) || 0])) : 0, d =
|
|
25
|
-
|
|
24
|
+
}, h = c ? Math.max(0, ...r.flatMap(({ main: e, comparison: t }) => [Number(e) || 0, Number(t) || 0])) : 0, d = M.useRef(null), { height: L, width: S } = T(d), B = ({ dataIndex: e, seriesId: t }) => {
|
|
25
|
+
I(e, Number(t.split("-").pop()));
|
|
26
26
|
}, p = x?.map((e, t) => ({
|
|
27
27
|
color: n[t] ?? "transparent",
|
|
28
28
|
...e
|
|
29
|
-
})), f = !!p?.length && /* @__PURE__ */ o(
|
|
29
|
+
})), f = !!p?.length && /* @__PURE__ */ o(R, {
|
|
30
30
|
boldLabel: g,
|
|
31
31
|
legendItems: p,
|
|
32
|
-
legendStyle: { ml: 24 }
|
|
32
|
+
legendStyle: { ml: 24 },
|
|
33
|
+
variant: y
|
|
33
34
|
});
|
|
34
|
-
return r.length > 0 ? /* @__PURE__ */ b(
|
|
35
|
+
return r.length > 0 ? /* @__PURE__ */ b(D, {
|
|
35
36
|
sx: {
|
|
36
37
|
mb: 0,
|
|
37
38
|
width: "100%",
|
|
@@ -39,7 +40,7 @@ var j = {
|
|
|
39
40
|
},
|
|
40
41
|
children: [
|
|
41
42
|
s === "top" && f,
|
|
42
|
-
/* @__PURE__ */ o(
|
|
43
|
+
/* @__PURE__ */ o(K, {
|
|
43
44
|
ref: d,
|
|
44
45
|
sx: {
|
|
45
46
|
height: i.height,
|
|
@@ -52,10 +53,10 @@ var j = {
|
|
|
52
53
|
userSelect: "none"
|
|
53
54
|
}
|
|
54
55
|
},
|
|
55
|
-
children: /* @__PURE__ */ b(
|
|
56
|
+
children: /* @__PURE__ */ b(_, {
|
|
56
57
|
colors: n,
|
|
57
58
|
dataset: r,
|
|
58
|
-
height:
|
|
59
|
+
height: L,
|
|
59
60
|
margin: {
|
|
60
61
|
bottom: i.bottom,
|
|
61
62
|
left: 24,
|
|
@@ -69,10 +70,10 @@ var j = {
|
|
|
69
70
|
dataKey: "comparison",
|
|
70
71
|
type: "bar"
|
|
71
72
|
}],
|
|
72
|
-
width:
|
|
73
|
+
width: S,
|
|
73
74
|
xAxis: [{
|
|
74
|
-
barGapRatio:
|
|
75
|
-
categoryGapRatio:
|
|
75
|
+
barGapRatio: k,
|
|
76
|
+
categoryGapRatio: w,
|
|
76
77
|
dataKey: "label",
|
|
77
78
|
scaleType: "band"
|
|
78
79
|
}],
|
|
@@ -80,7 +81,7 @@ var j = {
|
|
|
80
81
|
width: 0,
|
|
81
82
|
max: h
|
|
82
83
|
} : { width: 0 }],
|
|
83
|
-
children: [/* @__PURE__ */ o(
|
|
84
|
+
children: [/* @__PURE__ */ o(j, {
|
|
84
85
|
disableTicks: !1,
|
|
85
86
|
slots: { axisTickLabel: ({ text: e, ...t }) => {
|
|
86
87
|
const a = r[m]?.label;
|
|
@@ -99,16 +100,16 @@ var j = {
|
|
|
99
100
|
fill: "text.secondary",
|
|
100
101
|
fontWeight: 400
|
|
101
102
|
}
|
|
102
|
-
}), /* @__PURE__ */ o(
|
|
103
|
-
onItemClick: (e, { dataIndex: t, seriesId: a }) =>
|
|
103
|
+
}), /* @__PURE__ */ o(P, {
|
|
104
|
+
onItemClick: (e, { dataIndex: t, seriesId: a }) => B({
|
|
104
105
|
dataIndex: t,
|
|
105
106
|
seriesId: a.toString()
|
|
106
107
|
}),
|
|
107
108
|
slots: { bar: (e) => {
|
|
108
|
-
const { ownerState: t, ...a } = e,
|
|
109
|
-
return /* @__PURE__ */ o(
|
|
109
|
+
const { ownerState: t, ...a } = e, v = m === t.dataIndex ? t.color : `${t.color}50`;
|
|
110
|
+
return /* @__PURE__ */ o(N, {
|
|
110
111
|
...a,
|
|
111
|
-
color:
|
|
112
|
+
color: v,
|
|
112
113
|
data: r,
|
|
113
114
|
series: {
|
|
114
115
|
index: t.dataIndex,
|
|
@@ -130,7 +131,7 @@ var j = {
|
|
|
130
131
|
}) : /* @__PURE__ */ o(A, {});
|
|
131
132
|
};
|
|
132
133
|
export {
|
|
133
|
-
|
|
134
|
+
V as DoubleBarChart
|
|
134
135
|
};
|
|
135
136
|
|
|
136
137
|
//# sourceMappingURL=DoubleBarChart.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DoubleBarChart.es.js","names":[],"sources":["../../../../src/insights-v2/components/chartblocks/DoubleBarChart.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { BarPlot } from '@mui/x-charts/BarChart'\nimport { ChartContainer } from '@mui/x-charts/ChartContainer'\nimport { ChartsXAxis } from '@mui/x-charts/ChartsXAxis'\n\nimport { useContainerDimensions } from '../../hooks/useContainerDimensions'\nimport type { Legends } from '../../../core'\nimport type { DataSet, LegendProps } from '../../../core/types/InsightsInstanceSlotData'\n\nimport { CustomDoubleBarPlotMXUI } from './CustomDoubleBar'\nimport { Legend } from './ChartLegend'\nimport { EmptyBarChart } from './EmptyBarChart'\n\n/** A full card's plot box; when set, the y-axis also ends at the tallest bar (Figma 1243:73833). */\nexport interface PlotSize {\n height: number\n top: number\n bottom: number\n}\n\ninterface DoubleBarChartProps {\n // Shaped comparison series (one entry per month column), built by the caller (buildComparisonSeries)\n // \\u2014 mirroring how BarchartBlock builds `data` for BarChartV2.\n bars: DataSet[]\n // Two-entry palette [main, comparison]. Resolved by the caller (the card via getLayoutConfig). This\n // prop is the only color hook \\u2014 getLayoutConfig itself is never modified.\n colors: string[]\n // Legend items (toLegendItems over the block's additional_data); mapped onto the palette below.\n legends?: Legends[]\n isMini?: boolean\n // Where the legend sits, as BarChartV2's prop of the same name: below the chart (card) by default,\n // above it in the drawer.\n legendPosition?: 'top' | 'bottom'\n // Bold the legend label (\"Spend:\"), keeping the amount regular. Off by default.\n boldLabel?: boolean\n // A variant's full-card plot box (mini ignores it).\n plotSize?: PlotSize\n // The emphasized column (the drawer's selected month); defaults to the most recent (last) column.\n selectedIndex?: number\n // Called on a bar click with the clicked column and its sub-series (0 = main, 1 = comparison); the\n // caller decides what a click does (card opens the drawer, drill-down updates its selection).\n onBarClick: (columnIndex: number, subIndex: number) => void\n}\n\nconst FULL_PLOT: PlotSize = { height: 172, top: 0, bottom: 16 }\nconst MINI_PLOT: PlotSize = { height: 120, top: 0, bottom: 16 }\n\n/**\n * Pure double-bar chart (month columns x main/comparison). Presentational and self-contained \\u2014 it\n * receives shaped data + palette as props and reports clicks via onBarClick, holding no store,\n * selection, or data-shaping of its own. This mirrors BarChartV2; the DoubleBarChartBlock card\n * wrapper builds the data and injects the store behavior, exactly as BarchartBlock wraps BarChartV2.\n */\nexport const DoubleBarChart = ({\n bars,\n colors,\n legends,\n isMini = false,\n legendPosition = 'bottom',\n boldLabel = false,\n plotSize,\n selectedIndex,\n onBarClick,\n}: DoubleBarChartProps) => {\n // The selected column (default: the most recent, last) is emphasized; the others are dimmed.\n const selectedTabIndex = selectedIndex ?? bars.length - 1\n const barGapRatio = 0.005\n const categoryGapRatio = 0.16\n\n const fitted = isMini ? undefined : plotSize\n const plot = isMini ? MINI_PLOT : { ...FULL_PLOT, ...fitted }\n const tallestBar = fitted\n ? Math.max(\n 0,\n ...bars.flatMap(({ main, comparison }) => [Number(main) || 0, Number(comparison) || 0]),\n )\n : 0\n\n const containerRef = React.useRef<HTMLDivElement>(null)\n const { height, width } = useContainerDimensions(containerRef)\n\n const handleBarClick = ({ dataIndex, seriesId }: { dataIndex: number; seriesId: string }) => {\n const seriesType = Number(seriesId.split('-').pop())\n onBarClick(dataIndex, seriesType)\n }\n\n // colors can be empty for an unregistered variant (getLayoutConfig miss); fall back to transparent\n // so a swatch never renders as default-black.\n const legendItems = legends?.map((legend, index) => ({\n color: colors[index] ?? 'transparent',\n ...legend,\n })) as LegendProps[]\n\n const legend = !!legendItems?.length && (\n <Legend boldLabel={boldLabel} legendItems={legendItems} legendStyle={{ ml: 24 }} />\n )\n\n return bars.length > 0 ? (\n <Stack sx={{ mb: 0, width: '100%', p: 0 }}>\n {legendPosition === 'top' && legend}\n <Box\n ref={containerRef}\n sx={{\n height: plot.height,\n touchAction: 'pan-y',\n width: '100%',\n p: 0,\n m: 0,\n '& svg': {\n touchAction: 'pan-y',\n userSelect: 'none',\n },\n }}\n >\n <ChartContainer\n colors={colors}\n dataset={bars as any[]}\n height={height}\n margin={{\n bottom: plot.bottom,\n left: 24,\n right: 24,\n top: plot.top,\n }}\n series={[\n { dataKey: 'main', type: 'bar' },\n { dataKey: 'comparison', type: 'bar' },\n ]}\n width={width}\n xAxis={[\n {\n barGapRatio,\n categoryGapRatio,\n dataKey: 'label',\n scaleType: 'band',\n },\n ]}\n yAxis={[tallestBar > 0 ? { width: 0, max: tallestBar } : { width: 0 }]}\n >\n <ChartsXAxis\n disableTicks={false}\n slots={{\n axisTickLabel: ({ text, ...restProps }) => {\n const selectedLabel = bars[selectedTabIndex]?.label\n return (\n <text\n {...restProps}\n style={\n {\n ...restProps.style,\n fontWeight: selectedLabel === text ? 700 : 400,\n } as React.CSSProperties\n }\n >\n {text}\n </text>\n )\n },\n }}\n sx={{\n '.MuiChartsAxis-line': {\n stroke: 'border.darker',\n },\n }}\n tickLabelStyle={{\n fontSize: 11,\n fill: 'text.secondary',\n fontWeight: 400,\n }}\n />\n <BarPlot\n onItemClick={(_, { dataIndex, seriesId }) =>\n handleBarClick({ dataIndex, seriesId: seriesId.toString() })\n }\n slots={{\n bar: (props) => {\n const { ownerState, ...defaultProps } = props\n const isSelected = selectedTabIndex === ownerState.dataIndex\n const barColor = isSelected ? ownerState.color : `${ownerState.color}50`\n\n return (\n <CustomDoubleBarPlotMXUI\n {...defaultProps}\n color={barColor}\n data={bars}\n series={{\n index: ownerState.dataIndex,\n type: Number(ownerState.id?.toString().split('-').pop() ?? 0),\n }}\n style={{\n height: props.height,\n x: props.x,\n y: props.y,\n width: props.width,\n }}\n />\n )\n },\n }}\n />\n </ChartContainer>\n </Box>\n\n {legendPosition === 'bottom' && legend}\n </Stack>\n ) : (\n <EmptyBarChart />\n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AAA,gBAGD,UAAA;AAAA,cACG,CAAA;AAAA,YAEV,EACF;AAAA,YACA,IAAI,EACF,uBAAuB,EACrB,QAAQ,gBACV,EACF;AAAA,YACA,gBAAgB;AAAA,cACd,UAAU;AAAA,cACV,MAAM;AAAA,cACN,YAAY;AAAA,YACd;AAAA,UACD,CAAA,GACD,gBAAA,EAAC,GAAD;AAAA,YACE,aAAA,CAAc,GAAG,EAAE,WAAA,GAAW,UAAA,EAAA,MAC5B,EAAe;AAAA,cAAE,WAAA;AAAA,cAAW,UAAU,EAAS,SAAS;AAAA,YAAE,CAAC;AAAA,YAE7D,OAAO,EACL,KAAA,CAAM,MAAU;AACd,oBAAM,EAAE,YAAA,GAAY,GAAG,EAAA,IAAiB,GAElC,IADa,MAAqB,EAAW,YACrB,EAAW,QAAQ,GAAG,EAAW,KAAA;AAE/D,qBACE,gBAAA,EAAC,GAAD;AAAA,gBACE,GAAI;AAAA,gBACJ,OAAO;AAAA,gBACP,MAAM;AAAA,gBACN,QAAQ;AAAA,kBACN,OAAO,EAAW;AAAA,kBAClB,MAAM,OAAO,EAAW,IAAI,SAAS,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK,CAAC;AAAA,gBAC9D;AAAA,gBACA,OAAO;AAAA,kBACL,QAAQ,EAAM;AAAA,kBACd,GAAG,EAAM;AAAA,kBACT,GAAG,EAAM;AAAA,kBACT,OAAO,EAAM;AAAA,gBACf;AAAA,cACD,CAAA;AAAA,YAEL,EACF;AAAA,UACD,CAAA,CACa;AAAA;MACb,CAAA;AAAA,MAEJ,MAAmB,YAAY;AAAA,IAC3B;AAAA,EAEP,CAAA,IAAA,gBAAA,EAAC,GAAD,CAAgB,CAAA;AAEpB"}
|
|
1
|
+
{"version":3,"file":"DoubleBarChart.es.js","names":[],"sources":["../../../../src/insights-v2/components/chartblocks/DoubleBarChart.tsx"],"sourcesContent":["import React from 'react'\n\nimport Box from '@mui/material/Box'\nimport Stack from '@mui/material/Stack'\n\nimport { BarPlot } from '@mui/x-charts/BarChart'\nimport { ChartContainer } from '@mui/x-charts/ChartContainer'\nimport { ChartsXAxis } from '@mui/x-charts/ChartsXAxis'\n\nimport { useContainerDimensions } from '../../hooks/useContainerDimensions'\nimport type { Legends } from '../../../core'\nimport type { DataSet, LegendProps } from '../../../core/types/InsightsInstanceSlotData'\n\nimport { CustomDoubleBarPlotMXUI } from './CustomDoubleBar'\nimport { Legend, type LegendComponentProps } from './ChartLegend'\nimport { EmptyBarChart } from './EmptyBarChart'\n\n/** A full card's plot box; when set, the y-axis also ends at the tallest bar (Figma 1243:73833). */\nexport interface PlotSize {\n height: number\n top: number\n bottom: number\n}\n\ninterface DoubleBarChartProps {\n // Shaped comparison series (one entry per month column), built by the caller (buildComparisonSeries)\n // \\u2014 mirroring how BarchartBlock builds `data` for BarChartV2.\n bars: DataSet[]\n // Two-entry palette [main, comparison]. Resolved by the caller (the card via getLayoutConfig). This\n // prop is the only color hook \\u2014 getLayoutConfig itself is never modified.\n colors: string[]\n // Legend items (toLegendItems over the block's additional_data); mapped onto the palette below.\n legends?: Legends[]\n isMini?: boolean\n // Where the legend sits, as BarChartV2's prop of the same name: below the chart (card) by default,\n // above it in the drawer.\n legendPosition?: 'top' | 'bottom'\n // Bold the legend label (\"Spend:\"), keeping the amount regular. Off by default.\n boldLabel?: boolean\n // The legend's text style; ChartLegend's default (caption) when absent.\n legendVariant?: LegendComponentProps['variant']\n // A variant's full-card plot box (mini ignores it).\n plotSize?: PlotSize\n // The emphasized column (the drawer's selected month); defaults to the most recent (last) column.\n selectedIndex?: number\n // Called on a bar click with the clicked column and its sub-series (0 = main, 1 = comparison); the\n // caller decides what a click does (card opens the drawer, drill-down updates its selection).\n onBarClick: (columnIndex: number, subIndex: number) => void\n}\n\nconst FULL_PLOT: PlotSize = { height: 172, top: 0, bottom: 16 }\nconst MINI_PLOT: PlotSize = { height: 120, top: 0, bottom: 16 }\n\n/**\n * Pure double-bar chart (month columns x main/comparison). Presentational and self-contained \\u2014 it\n * receives shaped data + palette as props and reports clicks via onBarClick, holding no store,\n * selection, or data-shaping of its own. This mirrors BarChartV2; the DoubleBarChartBlock card\n * wrapper builds the data and injects the store behavior, exactly as BarchartBlock wraps BarChartV2.\n */\nexport const DoubleBarChart = ({\n bars,\n colors,\n legends,\n isMini = false,\n legendPosition = 'bottom',\n boldLabel = false,\n legendVariant,\n plotSize,\n selectedIndex,\n onBarClick,\n}: DoubleBarChartProps) => {\n // The selected column (default: the most recent, last) is emphasized; the others are dimmed.\n const selectedTabIndex = selectedIndex ?? bars.length - 1\n const barGapRatio = 0.005\n const categoryGapRatio = 0.16\n\n const fitted = isMini ? undefined : plotSize\n const plot = isMini ? MINI_PLOT : { ...FULL_PLOT, ...fitted }\n const tallestBar = fitted\n ? Math.max(\n 0,\n ...bars.flatMap(({ main, comparison }) => [Number(main) || 0, Number(comparison) || 0]),\n )\n : 0\n\n const containerRef = React.useRef<HTMLDivElement>(null)\n const { height, width } = useContainerDimensions(containerRef)\n\n const handleBarClick = ({ dataIndex, seriesId }: { dataIndex: number; seriesId: string }) => {\n const seriesType = Number(seriesId.split('-').pop())\n onBarClick(dataIndex, seriesType)\n }\n\n // colors can be empty for an unregistered variant (getLayoutConfig miss); fall back to transparent\n // so a swatch never renders as default-black.\n const legendItems = legends?.map((legend, index) => ({\n color: colors[index] ?? 'transparent',\n ...legend,\n })) as LegendProps[]\n\n const legend = !!legendItems?.length && (\n <Legend\n boldLabel={boldLabel}\n legendItems={legendItems}\n legendStyle={{ ml: 24 }}\n variant={legendVariant}\n />\n )\n\n return bars.length > 0 ? (\n <Stack sx={{ mb: 0, width: '100%', p: 0 }}>\n {legendPosition === 'top' && legend}\n <Box\n ref={containerRef}\n sx={{\n height: plot.height,\n touchAction: 'pan-y',\n width: '100%',\n p: 0,\n m: 0,\n '& svg': {\n touchAction: 'pan-y',\n userSelect: 'none',\n },\n }}\n >\n <ChartContainer\n colors={colors}\n dataset={bars as any[]}\n height={height}\n margin={{\n bottom: plot.bottom,\n left: 24,\n right: 24,\n top: plot.top,\n }}\n series={[\n { dataKey: 'main', type: 'bar' },\n { dataKey: 'comparison', type: 'bar' },\n ]}\n width={width}\n xAxis={[\n {\n barGapRatio,\n categoryGapRatio,\n dataKey: 'label',\n scaleType: 'band',\n },\n ]}\n yAxis={[tallestBar > 0 ? { width: 0, max: tallestBar } : { width: 0 }]}\n >\n <ChartsXAxis\n disableTicks={false}\n slots={{\n axisTickLabel: ({ text, ...restProps }) => {\n const selectedLabel = bars[selectedTabIndex]?.label\n return (\n <text\n {...restProps}\n style={\n {\n ...restProps.style,\n fontWeight: selectedLabel === text ? 700 : 400,\n } as React.CSSProperties\n }\n >\n {text}\n </text>\n )\n },\n }}\n sx={{\n '.MuiChartsAxis-line': {\n stroke: 'border.darker',\n },\n }}\n tickLabelStyle={{\n fontSize: 11,\n fill: 'text.secondary',\n fontWeight: 400,\n }}\n />\n <BarPlot\n onItemClick={(_, { dataIndex, seriesId }) =>\n handleBarClick({ dataIndex, seriesId: seriesId.toString() })\n }\n slots={{\n bar: (props) => {\n const { ownerState, ...defaultProps } = props\n const isSelected = selectedTabIndex === ownerState.dataIndex\n const barColor = isSelected ? ownerState.color : `${ownerState.color}50`\n\n return (\n <CustomDoubleBarPlotMXUI\n {...defaultProps}\n color={barColor}\n data={bars}\n series={{\n index: ownerState.dataIndex,\n type: Number(ownerState.id?.toString().split('-').pop() ?? 0),\n }}\n style={{\n height: props.height,\n x: props.x,\n y: props.y,\n width: props.width,\n }}\n />\n )\n },\n }}\n />\n </ChartContainer>\n </Box>\n\n {legendPosition === 'bottom' && legend}\n </Stack>\n ) : (\n <EmptyBarChart />\n )\n}\n"],"mappings":";;;;;;;;;;;AAkDA,IAAM,IAAsB;AAAA,EAAE,QAAQ;AAAA,EAAK,KAAK;AAAA,EAAG,QAAQ;AAAG,GACxD,IAAsB;AAAA,EAAE,QAAQ;AAAA,EAAK,KAAK;AAAA,EAAG,QAAQ;AAAG,GAQjD,IAAA,CAAkB,EAC7B,MAAA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AA,GACD,gBAAA,EAAC,GAAD;AAAA,YACE,aAAA,CAAc,GAAG,EAAE,WAAA,GAAW,UAAA,EAAA,MAC5B,EAAe;AAAA,cAAE,WAAA;AAAA,cAAW,UAAU,EAAS,SAAS;AAAA,YAAE,CAAC;AAAA,YAE7D,OAAO,EACL,KAAA,CAAM,MAAU;AACd,oBAAM,EAAE,YAAA,GAAY,GAAG,EAAA,IAAiB,GAElC,IADa,MAAqB,EAAW,YACrB,EAAW,QAAQ,GAAG,EAAW,KAAA;AAE/D,qBACE,gBAAA,EAAC,GAAD;AAAA,gBACE,GAAI;AAAA,gBACJ,OAAO;AAAA,gBACP,MAAM;AAAA,gBACN,QAAQ;AAAA,kBACN,OAAO,EAAW;AAAA,kBAClB,MAAM,OAAO,EAAW,IAAI,SAAS,EAAE,MAAM,GAAG,EAAE,IAAI,KAAK,CAAC;AAAA,gBAC9D;AAAA,gBACA,OAAO;AAAA,kBACL,QAAQ,EAAM;AAAA,kBACd,GAAG,EAAM;AAAA,kBACT,GAAG,EAAM;AAAA,kBACT,OAAO,EAAM;AAAA,gBACf;AAAA,cACD,CAAA;AAAA,YAEL,EACF;AAAA,UACD,CAAA,CACa;AAAA;MACb,CAAA;AAAA,MAEJ,MAAmB,YAAY;AAAA,IAC3B;AAAA,EAEP,CAAA,IAAA,gBAAA,EAAC,GAAD,CAAgB,CAAA;AAEpB"}
|
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
import { fromTimestampToMonthYear as
|
|
2
|
-
import { CurrencyText as
|
|
1
|
+
import { fromTimestampToMonthYear as a } from "../../core/utils/DateUtil.es.js";
|
|
2
|
+
import { CurrencyText as u } from "../../common/components/CurrencyText.es.js";
|
|
3
|
+
import { mouseOnly as m } from "../../common/utils/MouseOnly.es.js";
|
|
3
4
|
import e from "react";
|
|
4
|
-
import { observer as
|
|
5
|
+
import { observer as y } from "mobx-react-lite";
|
|
5
6
|
import v from "@mui/material/Stack";
|
|
6
|
-
import { Text as
|
|
7
|
-
import { jsx as t, jsxs as
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
var
|
|
13
|
-
const [i,
|
|
7
|
+
import { Text as d } from "@mxenabled/mxui";
|
|
8
|
+
import { jsx as t, jsxs as s } from "react/jsx-runtime";
|
|
9
|
+
import I from "@mui/material/Divider";
|
|
10
|
+
import L from "@mui/material/ListItem";
|
|
11
|
+
import g from "@mui/material/ListItemButton";
|
|
12
|
+
import T from "@mui/material/ListItemText";
|
|
13
|
+
var b = ({ item: r, getStyles: n, isHovered: f = !1, isSelected: o = !1, onItemClick: l, onMouseEnter: p, onMouseLeave: c }) => {
|
|
14
|
+
const [i, h] = e.useState({ color: "" });
|
|
14
15
|
return e.useEffect(() => {
|
|
15
|
-
|
|
16
|
-
}, [
|
|
16
|
+
h(n(r));
|
|
17
|
+
}, [f, o]), /* @__PURE__ */ s(e.Fragment, { children: [/* @__PURE__ */ t(L, {
|
|
17
18
|
sx: {
|
|
18
19
|
...i,
|
|
19
20
|
minHeight: 44,
|
|
20
21
|
"&:hover": { color: o ? "inherit" : i.color }
|
|
21
22
|
},
|
|
22
|
-
children: /* @__PURE__ */ t(
|
|
23
|
-
onClick: (
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
children: /* @__PURE__ */ t(g, {
|
|
24
|
+
onClick: (x) => l?.(x, r.x),
|
|
25
|
+
onPointerEnter: m(() => p(r.x)),
|
|
26
|
+
onPointerLeave: m(c),
|
|
26
27
|
sx: {
|
|
27
28
|
minHeight: 20,
|
|
28
29
|
padding: 12
|
|
29
30
|
},
|
|
30
|
-
children: /* @__PURE__ */ t(
|
|
31
|
+
children: /* @__PURE__ */ t(T, { primary: /* @__PURE__ */ s(v, {
|
|
31
32
|
direction: "row",
|
|
32
33
|
justifyContent: "space-between",
|
|
33
34
|
sx: { fontWeight: 400 },
|
|
34
|
-
children: [/* @__PURE__ */ t(
|
|
35
|
+
children: [/* @__PURE__ */ t(d, {
|
|
35
36
|
variant: "body1",
|
|
36
|
-
children:
|
|
37
|
-
}), /* @__PURE__ */ t(
|
|
37
|
+
children: a(r.x)
|
|
38
|
+
}), /* @__PURE__ */ t(u, {
|
|
38
39
|
amount: r.y,
|
|
39
40
|
sx: { color: "inherit" },
|
|
40
41
|
variant: "body1"
|
|
41
42
|
})]
|
|
42
43
|
}) })
|
|
43
44
|
})
|
|
44
|
-
}), /* @__PURE__ */ t(
|
|
45
|
-
},
|
|
45
|
+
}), /* @__PURE__ */ t(I, {})] }, r.x);
|
|
46
|
+
}, M = y(b);
|
|
46
47
|
export {
|
|
47
|
-
|
|
48
|
+
M as default
|
|
48
49
|
};
|
|
49
50
|
|
|
50
51
|
//# sourceMappingURL=NetWorthListItem.es.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NetWorthListItem.es.js","names":[],"sources":["../../../src/networth/components/NetWorthListItem.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\nimport React from 'react'\n\nimport Divider from '@mui/material/Divider'\nimport ListItem from '@mui/material/ListItem'\nimport ListItemButton from '@mui/material/ListItemButton'\nimport ListItemText from '@mui/material/ListItemText'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { CurrencyText } from '../../common/'\n\nimport { fromTimestampToMonthYear } from '../../core/utils/DateUtil'\n\nimport { NetWorth } from '../../core/types/NetWorth'\n\ninterface NetWorthListItemProps {\n item: NetWorth\n getStyles: (item: NetWorth) => { backgroundColor: string; borderBottom: string; color: string }\n isHovered: boolean\n isSelected: boolean\n onItemClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>, dataIndex: number) => void\n onMouseEnter: (dataIndex: number) => void\n onMouseLeave: () => void\n}\n\nconst NetWorthListItem: React.FC<NetWorthListItemProps> = ({\n item: dataPoint,\n getStyles,\n isHovered = false,\n isSelected = false,\n onItemClick,\n onMouseEnter,\n onMouseLeave,\n}) => {\n const [listItemStyles, setListItemStyles] = React.useState({\n color: '',\n })\n\n React.useEffect(() => {\n setListItemStyles(getStyles(dataPoint))\n }, [isHovered, isSelected])\n\n return (\n <React.Fragment key={dataPoint.x}>\n <ListItem\n sx={{\n ...listItemStyles,\n minHeight: 44,\n '&:hover': { color: isSelected ? 'inherit' : listItemStyles.color },\n }}\n >\n <ListItemButton\n onClick={(event) => onItemClick?.(event, dataPoint.x)}\n
|
|
1
|
+
{"version":3,"file":"NetWorthListItem.es.js","names":[],"sources":["../../../src/networth/components/NetWorthListItem.tsx"],"sourcesContent":["import { observer } from 'mobx-react-lite'\nimport React from 'react'\n\nimport Divider from '@mui/material/Divider'\nimport ListItem from '@mui/material/ListItem'\nimport ListItemButton from '@mui/material/ListItemButton'\nimport ListItemText from '@mui/material/ListItemText'\nimport Stack from '@mui/material/Stack'\n\nimport { Text } from '@mxenabled/mxui'\n\nimport { CurrencyText } from '../../common/'\nimport { mouseOnly } from '../../common/utils/MouseOnly'\n\nimport { fromTimestampToMonthYear } from '../../core/utils/DateUtil'\n\nimport { NetWorth } from '../../core/types/NetWorth'\n\ninterface NetWorthListItemProps {\n item: NetWorth\n getStyles: (item: NetWorth) => { backgroundColor: string; borderBottom: string; color: string }\n isHovered: boolean\n isSelected: boolean\n onItemClick?: (event: React.MouseEvent<HTMLDivElement, MouseEvent>, dataIndex: number) => void\n onMouseEnter: (dataIndex: number) => void\n onMouseLeave: () => void\n}\n\nconst NetWorthListItem: React.FC<NetWorthListItemProps> = ({\n item: dataPoint,\n getStyles,\n isHovered = false,\n isSelected = false,\n onItemClick,\n onMouseEnter,\n onMouseLeave,\n}) => {\n const [listItemStyles, setListItemStyles] = React.useState({\n color: '',\n })\n\n React.useEffect(() => {\n setListItemStyles(getStyles(dataPoint))\n }, [isHovered, isSelected])\n\n return (\n <React.Fragment key={dataPoint.x}>\n <ListItem\n sx={{\n ...listItemStyles,\n minHeight: 44,\n '&:hover': { color: isSelected ? 'inherit' : listItemStyles.color },\n }}\n >\n <ListItemButton\n onClick={(event) => onItemClick?.(event, dataPoint.x)}\n onPointerEnter={mouseOnly(() => onMouseEnter(dataPoint.x))}\n onPointerLeave={mouseOnly(onMouseLeave)}\n sx={{ minHeight: 20, padding: 12 }}\n >\n <ListItemText\n primary={\n <Stack direction=\"row\" justifyContent=\"space-between\" sx={{ fontWeight: 400 }}>\n <Text variant=\"body1\">{fromTimestampToMonthYear(dataPoint.x)}</Text>\n <CurrencyText amount={dataPoint.y} sx={{ color: 'inherit' }} variant=\"body1\" />\n </Stack>\n }\n />\n </ListItemButton>\n </ListItem>\n <Divider />\n </React.Fragment>\n )\n}\n\nexport default observer(NetWorthListItem)\n"],"mappings":";;;;;;;;;;;;AA4BA,IAAM,IAAA,CAAqD,EACzD,MAAM,GACN,WAAA,GACA,WAAA,IAAY,IACZ,YAAA,IAAa,IACb,aAAA,GACA,cAAA,GACA,cAAA,EAAA,MACI;AACJ,QAAM,CAAC,GAAgB,CAAA,IAAqB,EAAM,SAAS,EACzD,OAAO,GACT,CAAC;AAED,SAAA,EAAM,UAAA,MAAgB;AACpB,IAAA,EAAkB,EAAU,CAAS,CAAC;AAAA,EACxC,GAAG,CAAC,GAAW,CAAU,CAAC,GAGxB,gBAAA,EAAC,EAAM,UAAP,EAAA,UAAA,CACE,gBAAA,EAAC,GAAD;AAAA,IACE,IAAI;AAAA,MACF,GAAG;AAAA,MACH,WAAW;AAAA,MACX,WAAW,EAAE,OAAO,IAAa,YAAY,EAAe,MAAM;AAAA,IACpE;AAAA,IAEA,UAAA,gBAAA,EAAC,GAAD;AAAA,MACE,SAAA,CAAU,MAAU,IAAc,GAAO,EAAU,CAAC;AAAA,MACpD,gBAAgB,EAAA,MAAgB,EAAa,EAAU,CAAC,CAAC;AAAA,MACzD,gBAAgB,EAAU,CAAY;AAAA,MACtC,IAAI;AAAA,QAAE,WAAW;AAAA,QAAI,SAAS;AAAA,MAAG;AAAA,MAEjC,UAAA,gBAAA,EAAC,GAAD,EACE,SACE,gBAAA,EAAC,GAAD;AAAA,QAAO,WAAU;AA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