@ammarkhalidfarooq/dashboard-package 0.5.16 → 0.5.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -885,6 +885,1454 @@ var Dashboard = function Dashboard(_ref) {
885
885
  });
886
886
  };
887
887
 
888
+ function formatNumber(num) {
889
+ if (num >= 1000000000) {
890
+ return (num / 1000000000).toFixed(1).replace(/\.0$/, "") + "B";
891
+ }
892
+ if (num >= 1000000) {
893
+ return (num / 1000000).toFixed(1).replace(/\.0$/, "") + "M";
894
+ }
895
+ if (num >= 1000) {
896
+ return (num / 1000).toFixed(1).replace(/\.0$/, "") + "K";
897
+ }
898
+ return (num !== null && num !== void 0 ? num : 0).toString();
899
+ }
900
+
901
+ var W = 794;
902
+ var H = 1123;
903
+ var MX = 32; // horizontal margin
904
+ var CW = W - MX * 2; // 730 px usable width
905
+
906
+ // ─── Number helpers ───────────────────────────────────────────────────────────
907
+ var d$ = function d$(v) {
908
+ return "$".concat(formatNumber(Number(v !== null && v !== void 0 ? v : 0)));
909
+ };
910
+ var pct = function pct(v) {
911
+ var dp = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
912
+ return "".concat(Number(v !== null && v !== void 0 ? v : 0).toFixed(dp), "%");
913
+ };
914
+ var signed = function signed(v) {
915
+ var suffix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "%";
916
+ var n = Number(v !== null && v !== void 0 ? v : 0);
917
+ return "".concat(n >= 0 ? "+" : "").concat(n.toFixed(2)).concat(suffix);
918
+ };
919
+
920
+ // ─── SVG line sparkline ───────────────────────────────────────────────────────
921
+ var Sparkline = function Sparkline(_ref) {
922
+ var _ref$data = _ref.data,
923
+ data = _ref$data === void 0 ? [] : _ref$data,
924
+ _ref$color = _ref.color,
925
+ color = _ref$color === void 0 ? "#6366F1" : _ref$color,
926
+ _ref$width = _ref.width,
927
+ width = _ref$width === void 0 ? 120 : _ref$width,
928
+ _ref$height = _ref.height,
929
+ height = _ref$height === void 0 ? 40 : _ref$height;
930
+ var vals = data.length >= 2 ? data : [0, 0];
931
+ var max = Math.max.apply(Math, _toConsumableArray(vals).concat([0]));
932
+ var min = Math.min.apply(Math, _toConsumableArray(vals).concat([0]));
933
+ var range = max - min || 1;
934
+ var pad = 3;
935
+ var pts = vals.map(function (v, i) {
936
+ return [pad + i / (vals.length - 1) * (width - pad * 2), pad + (height - pad * 2) - (v - min) / range * (height - pad * 2)];
937
+ });
938
+ var d = pts.map(function (p, i) {
939
+ return "".concat(i === 0 ? "M" : "L").concat(p[0].toFixed(1), ",").concat(p[1].toFixed(1));
940
+ }).join(" ");
941
+ var area = "".concat(d, " L").concat((width - pad).toFixed(1), ",").concat(height, " L").concat(pad, ",").concat(height, " Z");
942
+ var gradId = "sp-".concat(color.replace(/[^a-z0-9]/gi, ""));
943
+ return /*#__PURE__*/jsxs("svg", {
944
+ width: width,
945
+ height: height,
946
+ style: {
947
+ display: "block",
948
+ overflow: "visible"
949
+ },
950
+ children: [/*#__PURE__*/jsx("defs", {
951
+ children: /*#__PURE__*/jsxs("linearGradient", {
952
+ id: gradId,
953
+ x1: "0",
954
+ y1: "0",
955
+ x2: "0",
956
+ y2: "1",
957
+ children: [/*#__PURE__*/jsx("stop", {
958
+ offset: "0%",
959
+ stopColor: color,
960
+ stopOpacity: "0.15"
961
+ }), /*#__PURE__*/jsx("stop", {
962
+ offset: "100%",
963
+ stopColor: color,
964
+ stopOpacity: "0"
965
+ })]
966
+ })
967
+ }), /*#__PURE__*/jsx("path", {
968
+ d: area,
969
+ fill: "url(#".concat(gradId, ")")
970
+ }), /*#__PURE__*/jsx("path", {
971
+ d: d,
972
+ fill: "none",
973
+ stroke: color,
974
+ strokeWidth: 2,
975
+ strokeLinecap: "round",
976
+ strokeLinejoin: "round"
977
+ })]
978
+ });
979
+ };
980
+
981
+ // ─── SVG multi-series line chart ──────────────────────────────────────────────
982
+ var LineChart = function LineChart(_ref2) {
983
+ var _ref2$series = _ref2.series,
984
+ series = _ref2$series === void 0 ? [] : _ref2$series,
985
+ _ref2$categories = _ref2.categories,
986
+ categories = _ref2$categories === void 0 ? [] : _ref2$categories,
987
+ _ref2$width = _ref2.width,
988
+ width = _ref2$width === void 0 ? CW : _ref2$width,
989
+ _ref2$height = _ref2.height,
990
+ height = _ref2$height === void 0 ? 180 : _ref2$height;
991
+ var allVals = series.flatMap(function (s) {
992
+ return s.data || [];
993
+ });
994
+ if (!allVals.length) {
995
+ return /*#__PURE__*/jsx("div", {
996
+ style: {
997
+ height: height,
998
+ background: "#F9FAFB",
999
+ borderRadius: 6
1000
+ }
1001
+ });
1002
+ }
1003
+ var COLORS = ["#6366F1", "#10B981", "#06B6D4"];
1004
+ var PL = 46,
1005
+ PR = 8,
1006
+ PT = 8,
1007
+ PB = 22;
1008
+ var IW = width - PL - PR;
1009
+ var IH = height - PT - PB;
1010
+ var max = Math.max.apply(Math, _toConsumableArray(allVals).concat([0]));
1011
+ var min = 0;
1012
+ var range = max - min || 1;
1013
+ var xp = function xp(i, n) {
1014
+ return PL + i / Math.max(n - 1, 1) * IW;
1015
+ };
1016
+ var yp = function yp(v) {
1017
+ return PT + IH - (v - min) / range * IH;
1018
+ };
1019
+ var yTicks = [0, 0.25, 0.5, 0.75, 1].map(function (t) {
1020
+ return min + t * range;
1021
+ });
1022
+ var step = Math.max(1, Math.floor(categories.length / 6));
1023
+ var shownCats = categories.filter(function (_, i) {
1024
+ return i % step === 0 || i === categories.length - 1;
1025
+ });
1026
+ return /*#__PURE__*/jsxs("svg", {
1027
+ width: width,
1028
+ height: height,
1029
+ style: {
1030
+ display: "block"
1031
+ },
1032
+ children: [yTicks.map(function (v, i) {
1033
+ var y = yp(v);
1034
+ var label = v >= 10000 ? "$".concat((v / 1000).toFixed(0), "K") : v >= 1000 ? "$".concat((v / 1000).toFixed(1), "K") : "$".concat(v.toFixed(0));
1035
+ return /*#__PURE__*/jsxs("g", {
1036
+ children: [/*#__PURE__*/jsx("line", {
1037
+ x1: PL,
1038
+ y1: y,
1039
+ x2: width - PR,
1040
+ y2: y,
1041
+ stroke: "#F3F4F6",
1042
+ strokeWidth: 1
1043
+ }), /*#__PURE__*/jsx("text", {
1044
+ x: PL - 4,
1045
+ y: y + 3.5,
1046
+ textAnchor: "end",
1047
+ fontSize: 9,
1048
+ fill: "#9CA3AF",
1049
+ children: label
1050
+ })]
1051
+ }, i);
1052
+ }), series.map(function (s, si) {
1053
+ var data = s.data || [];
1054
+ if (!data.length) return null;
1055
+ var pathD = data.map(function (v, i) {
1056
+ return "".concat(i === 0 ? "M" : "L").concat(xp(i, data.length).toFixed(1), ",").concat(yp(v).toFixed(1));
1057
+ }).join(" ");
1058
+ return /*#__PURE__*/jsx("path", {
1059
+ d: pathD,
1060
+ fill: "none",
1061
+ stroke: COLORS[si % COLORS.length],
1062
+ strokeWidth: 2,
1063
+ strokeLinecap: "round",
1064
+ strokeLinejoin: "round"
1065
+ }, si);
1066
+ }), shownCats.map(function (label, i) {
1067
+ var origIdx = categories.indexOf(label);
1068
+ var x = xp(origIdx < 0 ? i * step : origIdx, categories.length);
1069
+ return /*#__PURE__*/jsx("text", {
1070
+ x: x,
1071
+ y: height - 5,
1072
+ textAnchor: "middle",
1073
+ fontSize: 9,
1074
+ fill: "#9CA3AF",
1075
+ children: label
1076
+ }, i);
1077
+ })]
1078
+ });
1079
+ };
1080
+
1081
+ // ─── SVG donut ────────────────────────────────────────────────────────────────
1082
+ var Donut = function Donut(_ref3) {
1083
+ var _ref3$segments = _ref3.segments,
1084
+ segments = _ref3$segments === void 0 ? [] : _ref3$segments,
1085
+ _ref3$size = _ref3.size,
1086
+ size = _ref3$size === void 0 ? 88 : _ref3$size,
1087
+ centerVal = _ref3.centerVal,
1088
+ centerLabel = _ref3.centerLabel;
1089
+ var total = segments.reduce(function (s, g) {
1090
+ return s + (g.value || 0);
1091
+ }, 0) || 1;
1092
+ var r = (size - 18) / 2;
1093
+ var cx = size / 2;
1094
+ var cy = size / 2;
1095
+ var circ = 2 * Math.PI * r;
1096
+ var cumulDash = 0;
1097
+ return /*#__PURE__*/jsxs("svg", {
1098
+ width: size,
1099
+ height: size,
1100
+ style: {
1101
+ display: "block"
1102
+ },
1103
+ children: [/*#__PURE__*/jsx("circle", {
1104
+ cx: cx,
1105
+ cy: cy,
1106
+ r: r,
1107
+ fill: "none",
1108
+ stroke: "#E5E7EB",
1109
+ strokeWidth: 12
1110
+ }), segments.map(function (seg, i) {
1111
+ var dash = seg.value / total * circ;
1112
+ var el = /*#__PURE__*/jsx("circle", {
1113
+ cx: cx,
1114
+ cy: cy,
1115
+ r: r,
1116
+ fill: "none",
1117
+ stroke: seg.color || "#6366F1",
1118
+ strokeWidth: 12,
1119
+ strokeDasharray: "".concat(dash, " ").concat(circ),
1120
+ strokeDashoffset: -cumulDash,
1121
+ strokeLinecap: "butt",
1122
+ transform: "rotate(-90 ".concat(cx, " ").concat(cy, ")")
1123
+ }, i);
1124
+ cumulDash += dash;
1125
+ return el;
1126
+ }), centerVal && /*#__PURE__*/jsx("text", {
1127
+ x: cx,
1128
+ y: cy - (centerLabel ? 5 : 0),
1129
+ textAnchor: "middle",
1130
+ fontSize: 14,
1131
+ fontWeight: "bold",
1132
+ fill: "#111827",
1133
+ children: centerVal
1134
+ }), centerLabel && /*#__PURE__*/jsx("text", {
1135
+ x: cx,
1136
+ y: cy + 13,
1137
+ textAnchor: "middle",
1138
+ fontSize: 9,
1139
+ fill: "#6B7280",
1140
+ children: centerLabel
1141
+ })]
1142
+ });
1143
+ };
1144
+
1145
+ // ─── Shared primitives ────────────────────────────────────────────────────────
1146
+ var Divider = function Divider(_ref4) {
1147
+ var _ref4$mt = _ref4.mt,
1148
+ mt = _ref4$mt === void 0 ? 0 : _ref4$mt,
1149
+ _ref4$mb = _ref4.mb,
1150
+ mb = _ref4$mb === void 0 ? 0 : _ref4$mb;
1151
+ return /*#__PURE__*/jsx("div", {
1152
+ style: {
1153
+ borderTop: "1px solid #E5E7EB",
1154
+ marginTop: mt,
1155
+ marginBottom: mb
1156
+ }
1157
+ });
1158
+ };
1159
+ var Panel = function Panel(_ref5) {
1160
+ var children = _ref5.children,
1161
+ title = _ref5.title,
1162
+ subtitle = _ref5.subtitle,
1163
+ action = _ref5.action,
1164
+ _ref5$style = _ref5.style,
1165
+ style = _ref5$style === void 0 ? {} : _ref5$style;
1166
+ return /*#__PURE__*/jsxs("div", {
1167
+ style: _objectSpread2({
1168
+ border: "1px solid #E5E7EB",
1169
+ borderRadius: 8,
1170
+ background: "#fff",
1171
+ padding: 12,
1172
+ display: "flex",
1173
+ flexDirection: "column",
1174
+ boxSizing: "border-box"
1175
+ }, style),
1176
+ children: [(title || subtitle || action) && /*#__PURE__*/jsxs("div", {
1177
+ style: {
1178
+ display: "flex",
1179
+ justifyContent: "space-between",
1180
+ alignItems: "flex-start",
1181
+ marginBottom: 8,
1182
+ flexShrink: 0
1183
+ },
1184
+ children: [/*#__PURE__*/jsxs("div", {
1185
+ children: [title && /*#__PURE__*/jsx("div", {
1186
+ style: {
1187
+ fontSize: 12,
1188
+ fontWeight: 700,
1189
+ color: "#111827",
1190
+ lineHeight: 1.2
1191
+ },
1192
+ children: title
1193
+ }), subtitle && /*#__PURE__*/jsx("div", {
1194
+ style: {
1195
+ fontSize: 9.5,
1196
+ color: "#9CA3AF",
1197
+ marginTop: 2
1198
+ },
1199
+ children: subtitle
1200
+ })]
1201
+ }), action && /*#__PURE__*/jsx("div", {
1202
+ style: {
1203
+ fontSize: 9.5,
1204
+ color: "#6366F1",
1205
+ fontWeight: 500,
1206
+ flexShrink: 0
1207
+ },
1208
+ children: action
1209
+ })]
1210
+ }), children]
1211
+ });
1212
+ };
1213
+ var MiniTable = function MiniTable(_ref6) {
1214
+ var _ref6$head = _ref6.head,
1215
+ head = _ref6$head === void 0 ? [] : _ref6$head,
1216
+ _ref6$rows = _ref6.rows,
1217
+ rows = _ref6$rows === void 0 ? [] : _ref6$rows;
1218
+ return /*#__PURE__*/jsxs("table", {
1219
+ style: {
1220
+ width: "100%",
1221
+ borderCollapse: "collapse",
1222
+ fontSize: 9.5,
1223
+ tableLayout: "fixed"
1224
+ },
1225
+ children: [/*#__PURE__*/jsx("thead", {
1226
+ children: /*#__PURE__*/jsx("tr", {
1227
+ style: {
1228
+ background: "#F9FAFB"
1229
+ },
1230
+ children: head.map(function (h, i) {
1231
+ return /*#__PURE__*/jsx("th", {
1232
+ style: {
1233
+ padding: "4px 6px",
1234
+ textAlign: i === 0 ? "left" : "right",
1235
+ fontWeight: 700,
1236
+ fontSize: 8.5,
1237
+ letterSpacing: "0.3px",
1238
+ color: "#6B7280",
1239
+ borderBottom: "1px solid #E5E7EB"
1240
+ },
1241
+ children: h
1242
+ }, i);
1243
+ })
1244
+ })
1245
+ }), /*#__PURE__*/jsx("tbody", {
1246
+ children: rows.map(function (row, ri) {
1247
+ return /*#__PURE__*/jsx("tr", {
1248
+ style: {
1249
+ background: ri % 2 === 1 ? "#F9FAFB" : "#fff"
1250
+ },
1251
+ children: row.map(function (cell, ci) {
1252
+ return /*#__PURE__*/jsx("td", {
1253
+ style: {
1254
+ padding: "4px 6px",
1255
+ textAlign: ci === 0 ? "left" : "right",
1256
+ color: "#374151",
1257
+ borderBottom: ri < rows.length - 1 ? "1px solid #F3F4F6" : "none"
1258
+ },
1259
+ children: cell
1260
+ }, ci);
1261
+ })
1262
+ }, ri);
1263
+ })
1264
+ })]
1265
+ });
1266
+ };
1267
+ var KpiCard = function KpiCard(_ref7) {
1268
+ var title = _ref7.title,
1269
+ value = _ref7.value,
1270
+ trend = _ref7.trend,
1271
+ detail = _ref7.detail;
1272
+ var neg = "".concat(trend).trim().startsWith("-");
1273
+ return /*#__PURE__*/jsxs("div", {
1274
+ style: {
1275
+ border: "1px solid #E5E7EB",
1276
+ borderRadius: 8,
1277
+ padding: "10px 12px 9px",
1278
+ background: "#fff",
1279
+ flex: 1,
1280
+ minWidth: 0,
1281
+ boxSizing: "border-box",
1282
+ display: "flex",
1283
+ flexDirection: "column",
1284
+ gap: 2
1285
+ },
1286
+ children: [/*#__PURE__*/jsx("div", {
1287
+ style: {
1288
+ fontSize: 8,
1289
+ fontWeight: 700,
1290
+ letterSpacing: "0.7px",
1291
+ color: "#6B7280",
1292
+ textTransform: "uppercase"
1293
+ },
1294
+ children: title
1295
+ }), /*#__PURE__*/jsx("div", {
1296
+ style: {
1297
+ fontSize: 17,
1298
+ fontWeight: 800,
1299
+ color: "#111827",
1300
+ lineHeight: 1.1,
1301
+ marginTop: 2
1302
+ },
1303
+ children: value
1304
+ }), /*#__PURE__*/jsx("div", {
1305
+ style: {
1306
+ fontSize: 10.5,
1307
+ fontWeight: 600,
1308
+ color: neg ? "#DC2626" : "#16A34A"
1309
+ },
1310
+ children: trend
1311
+ }), /*#__PURE__*/jsx("div", {
1312
+ style: {
1313
+ fontSize: 8.5,
1314
+ color: "#9CA3AF",
1315
+ lineHeight: 1.4
1316
+ },
1317
+ children: detail
1318
+ })]
1319
+ });
1320
+ };
1321
+ var StatPair = function StatPair(_ref8) {
1322
+ var label = _ref8.label,
1323
+ val = _ref8.val,
1324
+ trend = _ref8.trend;
1325
+ var neg = "".concat(trend).trim().startsWith("-");
1326
+ return /*#__PURE__*/jsxs("div", {
1327
+ style: {
1328
+ marginBottom: 6
1329
+ },
1330
+ children: [/*#__PURE__*/jsx("div", {
1331
+ style: {
1332
+ fontSize: 8.5,
1333
+ color: "#9CA3AF",
1334
+ marginBottom: 1
1335
+ },
1336
+ children: label
1337
+ }), /*#__PURE__*/jsxs("div", {
1338
+ style: {
1339
+ display: "flex",
1340
+ alignItems: "baseline",
1341
+ gap: 4
1342
+ },
1343
+ children: [/*#__PURE__*/jsx("span", {
1344
+ style: {
1345
+ fontSize: 13,
1346
+ fontWeight: 700,
1347
+ color: "#111827"
1348
+ },
1349
+ children: val
1350
+ }), trend && /*#__PURE__*/jsx("span", {
1351
+ style: {
1352
+ fontSize: 9.5,
1353
+ fontWeight: 600,
1354
+ color: neg ? "#DC2626" : "#16A34A"
1355
+ },
1356
+ children: trend
1357
+ })]
1358
+ })]
1359
+ });
1360
+ };
1361
+ var PageHeader = function PageHeader(_ref9) {
1362
+ var dateLabel = _ref9.dateLabel,
1363
+ generatedLabel = _ref9.generatedLabel,
1364
+ activeFilters = _ref9.activeFilters,
1365
+ page = _ref9.page;
1366
+ return /*#__PURE__*/jsxs("div", {
1367
+ style: {
1368
+ padding: "22px ".concat(MX, "px 12px"),
1369
+ borderBottom: "1px solid #E5E7EB",
1370
+ flexShrink: 0
1371
+ },
1372
+ children: [/*#__PURE__*/jsx("div", {
1373
+ style: {
1374
+ display: "flex",
1375
+ justifyContent: "space-between",
1376
+ alignItems: "center"
1377
+ },
1378
+ children: /*#__PURE__*/jsxs("div", {
1379
+ style: {
1380
+ display: "flex",
1381
+ alignItems: "baseline",
1382
+ gap: 10
1383
+ },
1384
+ children: [/*#__PURE__*/jsx("span", {
1385
+ style: {
1386
+ fontSize: 20,
1387
+ fontWeight: 800,
1388
+ color: "#111827",
1389
+ letterSpacing: "-0.5px"
1390
+ },
1391
+ children: "Madinah"
1392
+ }), /*#__PURE__*/jsx("span", {
1393
+ style: {
1394
+ fontSize: 8.5,
1395
+ fontWeight: 700,
1396
+ letterSpacing: "1.5px",
1397
+ color: "#9CA3AF",
1398
+ textTransform: "uppercase"
1399
+ },
1400
+ children: "PERFORMANCE REPORT"
1401
+ })]
1402
+ })
1403
+ }), /*#__PURE__*/jsx("div", {
1404
+ style: {
1405
+ marginTop: 8,
1406
+ fontSize: 13.5,
1407
+ fontWeight: 700,
1408
+ color: "#111827"
1409
+ },
1410
+ children: "Dashboard overview \u2014 Overall"
1411
+ }), /*#__PURE__*/jsxs("div", {
1412
+ style: {
1413
+ display: "flex",
1414
+ justifyContent: "space-between",
1415
+ marginTop: 2
1416
+ },
1417
+ children: [/*#__PURE__*/jsxs("div", {
1418
+ children: [/*#__PURE__*/jsx("div", {
1419
+ style: {
1420
+ fontSize: 10.5,
1421
+ color: "#374151"
1422
+ },
1423
+ children: dateLabel
1424
+ }), /*#__PURE__*/jsxs("div", {
1425
+ style: {
1426
+ fontSize: 9.5,
1427
+ color: "#9CA3AF",
1428
+ marginTop: 1
1429
+ },
1430
+ children: ["30-day window \xB7 Generated ", generatedLabel]
1431
+ })]
1432
+ }), /*#__PURE__*/jsxs("div", {
1433
+ style: {
1434
+ fontSize: 9,
1435
+ color: "#9CA3AF",
1436
+ textAlign: "right",
1437
+ alignSelf: "flex-end"
1438
+ },
1439
+ children: ["Page ", page, " of 2"]
1440
+ })]
1441
+ }), activeFilters && /*#__PURE__*/jsxs("div", {
1442
+ style: {
1443
+ marginTop: 7,
1444
+ display: "inline-flex",
1445
+ gap: 5,
1446
+ background: "#F9FAFB",
1447
+ border: "1px solid #E5E7EB",
1448
+ borderRadius: 4,
1449
+ padding: "3px 9px",
1450
+ fontSize: 8.5
1451
+ },
1452
+ children: [/*#__PURE__*/jsx("span", {
1453
+ style: {
1454
+ fontWeight: 700,
1455
+ color: "#374151",
1456
+ letterSpacing: "0.4px"
1457
+ },
1458
+ children: "ACTIVE FILTERS"
1459
+ }), /*#__PURE__*/jsx("span", {
1460
+ style: {
1461
+ color: "#6B7280"
1462
+ },
1463
+ children: activeFilters
1464
+ })]
1465
+ })]
1466
+ });
1467
+ };
1468
+ var PageFooter = function PageFooter(_ref0) {
1469
+ var generatedLabel = _ref0.generatedLabel,
1470
+ page = _ref0.page;
1471
+ return /*#__PURE__*/jsx("div", {
1472
+ style: {
1473
+ padding: "7px ".concat(MX, "px"),
1474
+ borderTop: "1px solid #E5E7EB",
1475
+ marginTop: "auto",
1476
+ flexShrink: 0
1477
+ },
1478
+ children: /*#__PURE__*/jsxs("span", {
1479
+ style: {
1480
+ fontSize: 8,
1481
+ color: "#9CA3AF"
1482
+ },
1483
+ children: ["Confidential \xB7 Generated by Dashboard \xB7 ", generatedLabel, " \xA0\xA0 Page ", page, " of 2 \xB7 madinah.com"]
1484
+ })
1485
+ });
1486
+ };
1487
+
1488
+ // ─── Main component ───────────────────────────────────────────────────────────
1489
+ var ExportPdfLayout = /*#__PURE__*/React.forwardRef(function (_ref1, ref) {
1490
+ var _apiData$overviewStat, _apiData$trafficSourc, _apiData$trafficSourc2, _apiData$overviewStat2, _apiData$roasCard, _ob$peakDay;
1491
+ var _ref1$apiData = _ref1.apiData,
1492
+ apiData = _ref1$apiData === void 0 ? {} : _ref1$apiData,
1493
+ _ref1$dateName = _ref1.dateName,
1494
+ dateName = _ref1$dateName === void 0 ? "Last Period" : _ref1$dateName;
1495
+ var now = new Date();
1496
+ var generatedLabel = now.toLocaleDateString("en-US", {
1497
+ month: "short",
1498
+ day: "numeric",
1499
+ year: "numeric"
1500
+ }) + " · " + now.toLocaleTimeString("en-US", {
1501
+ hour: "2-digit",
1502
+ minute: "2-digit"
1503
+ }) + " GMT";
1504
+ var dateLabel = dateName;
1505
+ var activeFilters = (apiData === null || apiData === void 0 ? void 0 : apiData.activeFilters) || "";
1506
+
1507
+ // ── data ──────────────────────────────────────────────────────────────────
1508
+ var overview = (apiData === null || apiData === void 0 || (_apiData$overviewStat = apiData.overviewStats) === null || _apiData$overviewStat === void 0 ? void 0 : _apiData$overviewStat.overview) || {};
1509
+ var growth = (overview === null || overview === void 0 ? void 0 : overview.growthPercentage) || {};
1510
+ var totalRaised = Number((overview === null || overview === void 0 ? void 0 : overview.totalRevenue) || 0);
1511
+ var netRaised = Number((overview === null || overview === void 0 ? void 0 : overview.netRevenue) || 0);
1512
+ var totalDonors = Number((overview === null || overview === void 0 ? void 0 : overview.totalDonations) || 0);
1513
+ var avgDonation = Number((overview === null || overview === void 0 ? void 0 : overview.overallAVGDonations) || 0);
1514
+ var convRate = Number((overview === null || overview === void 0 ? void 0 : overview.conversionRate) || 0);
1515
+ var totalVisits = Number((apiData === null || apiData === void 0 ? void 0 : apiData.totalVisits) || 0);
1516
+ var passThrough = totalRaised > 0 ? "".concat((netRaised / totalRaised * 100).toFixed(1), "% pass-through") : "–";
1517
+ var refundsRaw = (apiData === null || apiData === void 0 ? void 0 : apiData.refundAndChargeBacks) || {};
1518
+ var refundRate = Number((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRate) || 0);
1519
+ var chargebackRate = Number((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.chargebackRate) || 0);
1520
+
1521
+ // donor mix
1522
+ var donorMixRaw = apiData === null || apiData === void 0 ? void 0 : apiData.donorPieChartData;
1523
+ var newDonors = 0,
1524
+ returningDonors = 0,
1525
+ mixAvgGift = avgDonation;
1526
+ if (Array.isArray(donorMixRaw)) {
1527
+ var nd = donorMixRaw.find(function (d) {
1528
+ return /new/i.test(d.type);
1529
+ }) || {};
1530
+ var rd = donorMixRaw.find(function (d) {
1531
+ return /returning/i.test(d.type);
1532
+ }) || {};
1533
+ newDonors = nd.totalDonations || 0;
1534
+ returningDonors = rd.totalDonations || 0;
1535
+ var totAmt = (nd.totalAmount || 0) + (rd.totalAmount || 0);
1536
+ var totCnt = newDonors + returningDonors;
1537
+ mixAvgGift = totCnt > 0 ? totAmt / totCnt : avgDonation;
1538
+ } else if (donorMixRaw) {
1539
+ newDonors = donorMixRaw.newDonors || 0;
1540
+ returningDonors = donorMixRaw.returningDonors || 0;
1541
+ mixAvgGift = donorMixRaw.avgGift || avgDonation;
1542
+ }
1543
+ var totalMix = newDonors + returningDonors || 1;
1544
+ var newPct = Math.round(newDonors / totalMix * 100);
1545
+ var retPct = 100 - newPct;
1546
+
1547
+ // recurring / one-time
1548
+ var recData = Array.isArray(apiData === null || apiData === void 0 ? void 0 : apiData.recurringBarChartData) ? apiData.recurringBarChartData : [];
1549
+ var recurringTotal = recData.reduce(function (s, i) {
1550
+ return s + Number(i.recurring || i.recurringAmount || 0);
1551
+ }, 0);
1552
+ var oneTimeTotal = recData.reduce(function (s, i) {
1553
+ return s + Number(i.oneTime || i.oneTimeAmount || 0);
1554
+ }, 0);
1555
+
1556
+ // donor geography
1557
+ var geoRaw = apiData === null || apiData === void 0 ? void 0 : apiData.donorGeography;
1558
+ var geoList = Array.isArray(geoRaw) ? geoRaw : Array.isArray(geoRaw === null || geoRaw === void 0 ? void 0 : geoRaw.data) ? geoRaw.data : [];
1559
+
1560
+ // traffic source
1561
+ var trafficItems = Array.isArray(apiData === null || apiData === void 0 || (_apiData$trafficSourc = apiData.trafficSourceData) === null || _apiData$trafficSourc === void 0 ? void 0 : _apiData$trafficSourc.data) ? apiData.trafficSourceData.data : [];
1562
+ var trafficTotal = Number((apiData === null || apiData === void 0 || (_apiData$trafficSourc2 = apiData.trafficSourceData) === null || _apiData$trafficSourc2 === void 0 ? void 0 : _apiData$trafficSourc2.totalRevenue) || 0);
1563
+
1564
+ // revenue trend series
1565
+ var stackedTR = (apiData === null || apiData === void 0 || (_apiData$overviewStat2 = apiData.overviewStats) === null || _apiData$overviewStat2 === void 0 ? void 0 : _apiData$overviewStat2.totalRaised) || {};
1566
+ var revSeries = [{
1567
+ name: "Email",
1568
+ data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || []).map(function (i) {
1569
+ return i.value || 0;
1570
+ })
1571
+ }, {
1572
+ name: "Organic",
1573
+ data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic) || []).map(function (i) {
1574
+ return i.value || 0;
1575
+ })
1576
+ }, {
1577
+ name: "Paid Ads",
1578
+ data: ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || []).map(function (i) {
1579
+ return i.value || 0;
1580
+ })
1581
+ }].filter(function (s) {
1582
+ return s.data.length > 0;
1583
+ });
1584
+ var revCats = ((stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.organic) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.paidAds) || (stackedTR === null || stackedTR === void 0 ? void 0 : stackedTR.email) || []).map(function (i) {
1585
+ return i.date || "";
1586
+ });
1587
+
1588
+ // campaigns
1589
+ var campaigns = (apiData === null || apiData === void 0 ? void 0 : apiData.activeCampaigns) || [];
1590
+
1591
+ // order bump
1592
+ var ob = (apiData === null || apiData === void 0 ? void 0 : apiData.orderBumpDetails) || {};
1593
+ var obData = ((ob === null || ob === void 0 ? void 0 : ob.chart) || []).map(function (i) {
1594
+ return Number(i.revenue || 0);
1595
+ });
1596
+
1597
+ // upsell / downsell
1598
+ var up = (apiData === null || apiData === void 0 ? void 0 : apiData.upSellDetails) || {};
1599
+ var dn = (apiData === null || apiData === void 0 ? void 0 : apiData.downSellDetails) || {};
1600
+
1601
+ // referrals
1602
+ var refCard = (apiData === null || apiData === void 0 ? void 0 : apiData.referralDetails) || {};
1603
+ var refData = ((refCard === null || refCard === void 0 ? void 0 : refCard.chartData) || []).map(function (i) {
1604
+ return Number(i.revenue || 0);
1605
+ });
1606
+ var C = {
1607
+ indigo: "#6366F1",
1608
+ emerald: "#10B981",
1609
+ cyan: "#06B6D4"
1610
+ };
1611
+ var headerProps = {
1612
+ dateLabel: dateLabel,
1613
+ generatedLabel: generatedLabel,
1614
+ activeFilters: activeFilters
1615
+ };
1616
+ return /*#__PURE__*/jsxs("div", {
1617
+ ref: ref,
1618
+ style: {
1619
+ display: "inline-flex",
1620
+ flexDirection: "column",
1621
+ gap: 0,
1622
+ background: "#fff"
1623
+ },
1624
+ children: [/*#__PURE__*/jsxs("div", {
1625
+ "data-export-page": "1",
1626
+ style: {
1627
+ width: W,
1628
+ height: H,
1629
+ background: "#fff",
1630
+ display: "flex",
1631
+ flexDirection: "column",
1632
+ fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
1633
+ boxSizing: "border-box",
1634
+ overflow: "hidden"
1635
+ },
1636
+ children: [/*#__PURE__*/jsx(PageHeader, _objectSpread2(_objectSpread2({}, headerProps), {}, {
1637
+ page: 1
1638
+ })), /*#__PURE__*/jsxs("div", {
1639
+ style: {
1640
+ flex: 1,
1641
+ padding: "12px ".concat(MX, "px 10px"),
1642
+ display: "flex",
1643
+ flexDirection: "column",
1644
+ gap: 10,
1645
+ overflow: "hidden"
1646
+ },
1647
+ children: [/*#__PURE__*/jsxs("div", {
1648
+ style: {
1649
+ display: "flex",
1650
+ gap: 7
1651
+ },
1652
+ children: [/*#__PURE__*/jsx(KpiCard, {
1653
+ title: "Total Raised",
1654
+ value: d$(totalRaised),
1655
+ trend: "".concat(signed(growth === null || growth === void 0 ? void 0 : growth.totalRevenue), " vs ").concat(dateLabel),
1656
+ detail: "".concat(passThrough, " \xB7 ").concat(formatNumber(totalDonors), " donors \xB7 ").concat(d$(avgDonation), " avg \xB7 ").concat(formatNumber(totalVisits), " visits")
1657
+ }), /*#__PURE__*/jsx(KpiCard, {
1658
+ title: "Net Raised",
1659
+ value: d$(netRaised),
1660
+ trend: signed(growth === null || growth === void 0 ? void 0 : growth.netRevenue),
1661
+ detail: passThrough
1662
+ }), /*#__PURE__*/jsx(KpiCard, {
1663
+ title: "Total Donors",
1664
+ value: "".concat(formatNumber(totalDonors)),
1665
+ trend: signed(growth === null || growth === void 0 ? void 0 : growth.totalDonations),
1666
+ detail: "".concat(formatNumber(newDonors), " new \xB7 ").concat(formatNumber(returningDonors), " returning")
1667
+ }), /*#__PURE__*/jsx(KpiCard, {
1668
+ title: "Avg Donation",
1669
+ value: d$(avgDonation),
1670
+ trend: signed(growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations),
1671
+ detail: "Median ".concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.medianGift) || 0), " \xB7 top decile ").concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.topDecileGift) || 0))
1672
+ }), /*#__PURE__*/jsx(KpiCard, {
1673
+ title: "ROAS",
1674
+ value: "".concat(formatNumber((_apiData$roasCard = apiData === null || apiData === void 0 ? void 0 : apiData.roasCard) !== null && _apiData$roasCard !== void 0 ? _apiData$roasCard : 0), "\xD7"),
1675
+ trend: signed(apiData === null || apiData === void 0 ? void 0 : apiData.roasCardPrev, "×"),
1676
+ detail: "".concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.adSpend) || 0), " spend \xB7 ").concat(d$((apiData === null || apiData === void 0 ? void 0 : apiData.attributedRevenue) || 0), " attrib.")
1677
+ }), /*#__PURE__*/jsx(KpiCard, {
1678
+ title: "Conversion",
1679
+ value: pct(convRate, 1),
1680
+ trend: "".concat(signed(growth === null || growth === void 0 ? void 0 : growth.conversionRate, "pp")),
1681
+ detail: "".concat(formatNumber(totalDonors), " from ").concat(formatNumber(totalVisits), " visits")
1682
+ }), /*#__PURE__*/jsx(KpiCard, {
1683
+ title: "Refund Rate",
1684
+ value: pct(refundRate, 2),
1685
+ trend: "".concat(signed(refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange, "pp")),
1686
+ detail: "".concat(formatNumber((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundCount) || 0), " refunds this period")
1687
+ })]
1688
+ }), /*#__PURE__*/jsxs("div", {
1689
+ style: {
1690
+ border: "1px solid #E5E7EB",
1691
+ borderRadius: 8,
1692
+ background: "#fff",
1693
+ padding: "12px 14px 10px",
1694
+ flex: 1
1695
+ },
1696
+ children: [/*#__PURE__*/jsxs("div", {
1697
+ style: {
1698
+ display: "flex",
1699
+ justifyContent: "space-between",
1700
+ alignItems: "flex-start",
1701
+ marginBottom: 6
1702
+ },
1703
+ children: [/*#__PURE__*/jsxs("div", {
1704
+ children: [/*#__PURE__*/jsx("div", {
1705
+ style: {
1706
+ fontSize: 13,
1707
+ fontWeight: 700,
1708
+ color: "#111827"
1709
+ },
1710
+ children: "Total revenue trend"
1711
+ }), /*#__PURE__*/jsx("div", {
1712
+ style: {
1713
+ fontSize: 9.5,
1714
+ color: "#9CA3AF",
1715
+ marginTop: 1
1716
+ },
1717
+ children: "Last 30 days \xB7 daily aggregation"
1718
+ })]
1719
+ }), /*#__PURE__*/jsxs("div", {
1720
+ style: {
1721
+ textAlign: "right"
1722
+ },
1723
+ children: [/*#__PURE__*/jsx("span", {
1724
+ style: {
1725
+ fontSize: 15,
1726
+ fontWeight: 800,
1727
+ color: "#111827"
1728
+ },
1729
+ children: d$(totalRaised)
1730
+ }), /*#__PURE__*/jsxs("span", {
1731
+ style: {
1732
+ marginLeft: 8,
1733
+ fontSize: 10.5,
1734
+ fontWeight: 600,
1735
+ color: "#16A34A"
1736
+ },
1737
+ children: [signed(growth === null || growth === void 0 ? void 0 : growth.totalRevenue), " vs ", dateLabel]
1738
+ })]
1739
+ })]
1740
+ }), /*#__PURE__*/jsx("div", {
1741
+ style: {
1742
+ display: "flex",
1743
+ gap: 14,
1744
+ marginBottom: 6
1745
+ },
1746
+ children: [["Email", C.indigo], ["Organic", C.emerald], ["Paid Ads", C.cyan]].map(function (_ref10) {
1747
+ var _ref11 = _slicedToArray(_ref10, 2),
1748
+ name = _ref11[0],
1749
+ color = _ref11[1];
1750
+ return /*#__PURE__*/jsxs("div", {
1751
+ style: {
1752
+ display: "flex",
1753
+ alignItems: "center",
1754
+ gap: 5
1755
+ },
1756
+ children: [/*#__PURE__*/jsx("div", {
1757
+ style: {
1758
+ width: 20,
1759
+ height: 2.5,
1760
+ background: color,
1761
+ borderRadius: 2
1762
+ }
1763
+ }), /*#__PURE__*/jsx("span", {
1764
+ style: {
1765
+ fontSize: 9.5,
1766
+ color: "#6B7280"
1767
+ },
1768
+ children: name
1769
+ })]
1770
+ }, name);
1771
+ })
1772
+ }), /*#__PURE__*/jsx(LineChart, {
1773
+ series: revSeries,
1774
+ categories: revCats,
1775
+ width: CW - 28,
1776
+ height: 480
1777
+ })]
1778
+ })]
1779
+ }), /*#__PURE__*/jsx(PageFooter, {
1780
+ generatedLabel: generatedLabel,
1781
+ page: 1
1782
+ })]
1783
+ }), /*#__PURE__*/jsxs("div", {
1784
+ "data-export-page": "2",
1785
+ style: {
1786
+ width: W,
1787
+ height: H,
1788
+ background: "#fff",
1789
+ display: "flex",
1790
+ flexDirection: "column",
1791
+ fontFamily: "'Helvetica Neue', Helvetica, Arial, sans-serif",
1792
+ boxSizing: "border-box",
1793
+ overflow: "hidden"
1794
+ },
1795
+ children: [/*#__PURE__*/jsx(PageHeader, _objectSpread2(_objectSpread2({}, headerProps), {}, {
1796
+ page: 2
1797
+ })), /*#__PURE__*/jsxs("div", {
1798
+ style: {
1799
+ flex: 1,
1800
+ padding: "10px ".concat(MX, "px 8px"),
1801
+ display: "flex",
1802
+ flexDirection: "column",
1803
+ gap: 8,
1804
+ overflow: "hidden"
1805
+ },
1806
+ children: [/*#__PURE__*/jsx(Panel, {
1807
+ title: "Active campaigns",
1808
+ subtitle: "Live fundraisers ranked by velocity",
1809
+ action: "View all \u2192",
1810
+ children: /*#__PURE__*/jsx(MiniTable, {
1811
+ head: ["CAMPAIGN", "RAISED", "PROGRESS", "DONORS", "AVG GIFT", "STATUS"],
1812
+ rows: campaigns.length ? campaigns.map(function (c) {
1813
+ return [c.title || "Untitled", d$(c.collectedAmount || 0), "".concat(Math.round((c.collectedAmount || 0) / (c.usdTargetAmount || 1) * 100), "%"), "".concat(formatNumber(c.uniqueDonationsCount || 0)), d$(c.avgGift || 0), c.status || "Active"];
1814
+ }) : [["-", "$0", "0%", "0", "$0", "-"]]
1815
+ })
1816
+ }), /*#__PURE__*/jsxs("div", {
1817
+ style: {
1818
+ display: "flex",
1819
+ gap: 8,
1820
+ flexShrink: 0
1821
+ },
1822
+ children: [/*#__PURE__*/jsx(Panel, {
1823
+ title: "Donor mix",
1824
+ subtitle: "Acquisition vs retention",
1825
+ style: {
1826
+ flex: 1
1827
+ },
1828
+ children: /*#__PURE__*/jsxs("div", {
1829
+ style: {
1830
+ display: "flex",
1831
+ alignItems: "center",
1832
+ gap: 14
1833
+ },
1834
+ children: [/*#__PURE__*/jsx(Donut, {
1835
+ segments: [{
1836
+ value: newDonors,
1837
+ color: C.indigo
1838
+ }, {
1839
+ value: returningDonors,
1840
+ color: C.emerald
1841
+ }],
1842
+ size: 88,
1843
+ centerVal: "".concat(formatNumber(totalMix)),
1844
+ centerLabel: "donors"
1845
+ }), /*#__PURE__*/jsxs("div", {
1846
+ style: {
1847
+ flex: 1
1848
+ },
1849
+ children: [/*#__PURE__*/jsxs("div", {
1850
+ style: {
1851
+ display: "flex",
1852
+ alignItems: "center",
1853
+ gap: 6,
1854
+ marginBottom: 5
1855
+ },
1856
+ children: [/*#__PURE__*/jsx("div", {
1857
+ style: {
1858
+ width: 9,
1859
+ height: 9,
1860
+ borderRadius: "50%",
1861
+ background: C.indigo,
1862
+ flexShrink: 0
1863
+ }
1864
+ }), /*#__PURE__*/jsxs("span", {
1865
+ style: {
1866
+ fontSize: 10,
1867
+ color: "#374151"
1868
+ },
1869
+ children: ["New donors ", formatNumber(newDonors), " \xB7 ", newPct, "%"]
1870
+ })]
1871
+ }), /*#__PURE__*/jsxs("div", {
1872
+ style: {
1873
+ display: "flex",
1874
+ alignItems: "center",
1875
+ gap: 6,
1876
+ marginBottom: 9
1877
+ },
1878
+ children: [/*#__PURE__*/jsx("div", {
1879
+ style: {
1880
+ width: 9,
1881
+ height: 9,
1882
+ borderRadius: "50%",
1883
+ background: C.emerald,
1884
+ flexShrink: 0
1885
+ }
1886
+ }), /*#__PURE__*/jsxs("span", {
1887
+ style: {
1888
+ fontSize: 10,
1889
+ color: "#374151"
1890
+ },
1891
+ children: ["Returning ", formatNumber(returningDonors), " \xB7 ", retPct, "%"]
1892
+ })]
1893
+ }), /*#__PURE__*/jsx(Divider, {
1894
+ mb: 7
1895
+ }), /*#__PURE__*/jsx("div", {
1896
+ style: {
1897
+ fontSize: 15,
1898
+ fontWeight: 800,
1899
+ color: "#111827"
1900
+ },
1901
+ children: d$(mixAvgGift)
1902
+ }), /*#__PURE__*/jsx("div", {
1903
+ style: {
1904
+ fontSize: 8.5,
1905
+ color: "#9CA3AF"
1906
+ },
1907
+ children: "Avg gift"
1908
+ }), /*#__PURE__*/jsxs("div", {
1909
+ style: {
1910
+ fontSize: 9,
1911
+ color: "#16A34A",
1912
+ marginTop: 1
1913
+ },
1914
+ children: [signed(growth === null || growth === void 0 ? void 0 : growth.overallAVGDonations), " vs ", dateLabel]
1915
+ })]
1916
+ })]
1917
+ })
1918
+ }), /*#__PURE__*/jsx(Panel, {
1919
+ title: "Recurring vs one-time",
1920
+ subtitle: "Donation type \xB7 weekly",
1921
+ style: {
1922
+ flex: 1
1923
+ },
1924
+ children: function () {
1925
+ var tot = recurringTotal + oneTimeTotal || 1;
1926
+ var rPct = recurringTotal / tot * 100;
1927
+ var oPct = oneTimeTotal / tot * 100;
1928
+ return /*#__PURE__*/jsxs("div", {
1929
+ style: {
1930
+ display: "flex",
1931
+ flexDirection: "column",
1932
+ gap: 10,
1933
+ marginTop: 4
1934
+ },
1935
+ children: [/*#__PURE__*/jsxs("div", {
1936
+ children: [/*#__PURE__*/jsxs("div", {
1937
+ style: {
1938
+ display: "flex",
1939
+ justifyContent: "space-between",
1940
+ marginBottom: 3
1941
+ },
1942
+ children: [/*#__PURE__*/jsx("span", {
1943
+ style: {
1944
+ fontSize: 10,
1945
+ color: "#374151"
1946
+ },
1947
+ children: "Recurring"
1948
+ }), /*#__PURE__*/jsx("span", {
1949
+ style: {
1950
+ fontSize: 10,
1951
+ fontWeight: 700,
1952
+ color: "#111827"
1953
+ },
1954
+ children: d$(recurringTotal)
1955
+ })]
1956
+ }), /*#__PURE__*/jsx("div", {
1957
+ style: {
1958
+ height: 10,
1959
+ background: "#EEF2FF",
1960
+ borderRadius: 3
1961
+ },
1962
+ children: /*#__PURE__*/jsx("div", {
1963
+ style: {
1964
+ width: "".concat(rPct, "%"),
1965
+ height: "100%",
1966
+ background: C.indigo,
1967
+ borderRadius: 3
1968
+ }
1969
+ })
1970
+ })]
1971
+ }), /*#__PURE__*/jsxs("div", {
1972
+ children: [/*#__PURE__*/jsxs("div", {
1973
+ style: {
1974
+ display: "flex",
1975
+ justifyContent: "space-between",
1976
+ marginBottom: 3
1977
+ },
1978
+ children: [/*#__PURE__*/jsx("span", {
1979
+ style: {
1980
+ fontSize: 10,
1981
+ color: "#374151"
1982
+ },
1983
+ children: "One-time"
1984
+ }), /*#__PURE__*/jsx("span", {
1985
+ style: {
1986
+ fontSize: 10,
1987
+ fontWeight: 700,
1988
+ color: "#111827"
1989
+ },
1990
+ children: d$(oneTimeTotal)
1991
+ })]
1992
+ }), /*#__PURE__*/jsx("div", {
1993
+ style: {
1994
+ height: 10,
1995
+ background: "#EEF2FF",
1996
+ borderRadius: 3
1997
+ },
1998
+ children: /*#__PURE__*/jsx("div", {
1999
+ style: {
2000
+ width: "".concat(oPct, "%"),
2001
+ height: "100%",
2002
+ background: "#C7D2FE",
2003
+ borderRadius: 3
2004
+ }
2005
+ })
2006
+ })]
2007
+ })]
2008
+ });
2009
+ }()
2010
+ })]
2011
+ }), /*#__PURE__*/jsxs("div", {
2012
+ style: {
2013
+ display: "flex",
2014
+ gap: 8,
2015
+ flexShrink: 0
2016
+ },
2017
+ children: [/*#__PURE__*/jsx(Panel, {
2018
+ title: "Donor geography",
2019
+ subtitle: "Top countries \xB7 ".concat(formatNumber(totalDonors), " total"),
2020
+ style: {
2021
+ flex: 1
2022
+ },
2023
+ children: (geoList.length ? geoList.slice(0, 6) : []).map(function (g, i) {
2024
+ return /*#__PURE__*/jsxs("div", {
2025
+ style: {
2026
+ display: "flex",
2027
+ justifyContent: "space-between",
2028
+ padding: "3.5px 0",
2029
+ borderBottom: i < 5 ? "1px solid #F3F4F6" : "none"
2030
+ },
2031
+ children: [/*#__PURE__*/jsx("span", {
2032
+ style: {
2033
+ fontSize: 9.5,
2034
+ color: "#374151"
2035
+ },
2036
+ children: g.country || g.name || "-"
2037
+ }), /*#__PURE__*/jsxs("span", {
2038
+ style: {
2039
+ fontSize: 9.5,
2040
+ color: "#6B7280"
2041
+ },
2042
+ children: [formatNumber(g.totalDonors || g.donors || 0), " \xB7 ", formatNumber(g.percentage || 0), "%"]
2043
+ })]
2044
+ }, i);
2045
+ })
2046
+ }), /*#__PURE__*/jsxs(Panel, {
2047
+ title: "Refunds & chargebacks",
2048
+ subtitle: "Trust health \xB7 30-day window",
2049
+ style: {
2050
+ flex: 1
2051
+ },
2052
+ children: [/*#__PURE__*/jsxs("div", {
2053
+ style: {
2054
+ display: "flex",
2055
+ gap: 18,
2056
+ marginBottom: 8
2057
+ },
2058
+ children: [/*#__PURE__*/jsxs("div", {
2059
+ children: [/*#__PURE__*/jsx("div", {
2060
+ style: {
2061
+ fontSize: 8,
2062
+ fontWeight: 700,
2063
+ letterSpacing: "0.5px",
2064
+ color: "#6B7280",
2065
+ marginBottom: 2
2066
+ },
2067
+ children: "REFUNDS"
2068
+ }), /*#__PURE__*/jsx("div", {
2069
+ style: {
2070
+ fontSize: 18,
2071
+ fontWeight: 800,
2072
+ color: "#111827"
2073
+ },
2074
+ children: pct(refundRate, 1)
2075
+ }), /*#__PURE__*/jsx("div", {
2076
+ style: {
2077
+ fontSize: 9.5,
2078
+ color: "#16A34A",
2079
+ fontWeight: 600
2080
+ },
2081
+ children: signed(refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundRateChange, "pp")
2082
+ })]
2083
+ }), /*#__PURE__*/jsxs("div", {
2084
+ children: [/*#__PURE__*/jsx("div", {
2085
+ style: {
2086
+ fontSize: 8,
2087
+ fontWeight: 700,
2088
+ letterSpacing: "0.5px",
2089
+ color: "#6B7280",
2090
+ marginBottom: 2
2091
+ },
2092
+ children: "CHARGEBACKS"
2093
+ }), /*#__PURE__*/jsx("div", {
2094
+ style: {
2095
+ fontSize: 18,
2096
+ fontWeight: 800,
2097
+ color: "#111827"
2098
+ },
2099
+ children: pct(chargebackRate, 1)
2100
+ }), /*#__PURE__*/jsx("div", {
2101
+ style: {
2102
+ fontSize: 9.5,
2103
+ color: "#9CA3AF"
2104
+ },
2105
+ children: "stable"
2106
+ })]
2107
+ })]
2108
+ }), /*#__PURE__*/jsx(Divider, {
2109
+ mb: 6
2110
+ }), /*#__PURE__*/jsxs("div", {
2111
+ style: {
2112
+ fontSize: 8.5,
2113
+ color: "#6B7280",
2114
+ lineHeight: 1.5
2115
+ },
2116
+ children: [d$((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.refundAmount) || 0), " refunded \xB7 ", d$((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.disputedAmount) || 0), " disputed \xB7 ", formatNumber((refundsRaw === null || refundsRaw === void 0 ? void 0 : refundsRaw.casesLost) || 0), " cases lost"]
2117
+ })]
2118
+ }), /*#__PURE__*/jsx(Panel, {
2119
+ title: "Traffic source",
2120
+ subtitle: "Revenue by channel \xB7 30 days",
2121
+ style: {
2122
+ flex: 1
2123
+ },
2124
+ children: /*#__PURE__*/jsx(MiniTable, {
2125
+ head: ["SOURCE", "REVENUE", "SHARE"],
2126
+ rows: [].concat(_toConsumableArray(trafficItems.map(function (t) {
2127
+ return [t.source || t.name || "-", d$(t.revenue || t.raised || 0), "".concat(formatNumber(t.share || t.percentage || 0), "%")];
2128
+ })), _toConsumableArray(trafficItems.length ? [["Total", d$(trafficTotal), ""]] : []))
2129
+ })
2130
+ }), /*#__PURE__*/jsxs(Panel, {
2131
+ title: "Order Bump",
2132
+ subtitle: "Revenue trend \xB7 last 30 days",
2133
+ style: {
2134
+ flex: 1
2135
+ },
2136
+ children: [/*#__PURE__*/jsx("div", {
2137
+ style: {
2138
+ fontSize: 17,
2139
+ fontWeight: 800,
2140
+ color: "#111827"
2141
+ },
2142
+ children: d$((ob === null || ob === void 0 ? void 0 : ob.totalRevenue) || 0)
2143
+ }), /*#__PURE__*/jsxs("div", {
2144
+ style: {
2145
+ fontSize: 10,
2146
+ color: "#16A34A",
2147
+ fontWeight: 600,
2148
+ marginBottom: 5
2149
+ },
2150
+ children: [signed(ob === null || ob === void 0 ? void 0 : ob.growthPercentage), " vs ", dateLabel]
2151
+ }), /*#__PURE__*/jsx(Sparkline, {
2152
+ data: obData.length ? obData : [0, 1],
2153
+ color: C.indigo,
2154
+ width: 110,
2155
+ height: 34
2156
+ }), /*#__PURE__*/jsx(Divider, {
2157
+ mt: 8,
2158
+ mb: 7
2159
+ }), /*#__PURE__*/jsx("div", {
2160
+ style: {
2161
+ display: "flex",
2162
+ gap: 12
2163
+ },
2164
+ children: [["Avg/day", d$((ob === null || ob === void 0 ? void 0 : ob.averagePerDay) || 0)], ["Peak day", d$((ob === null || ob === void 0 || (_ob$peakDay = ob.peakDay) === null || _ob$peakDay === void 0 ? void 0 : _ob$peakDay.amount) || 0)], ["Orders", formatNumber((ob === null || ob === void 0 ? void 0 : ob.totalOrders) || 0)]].map(function (_ref12) {
2165
+ var _ref13 = _slicedToArray(_ref12, 2),
2166
+ l = _ref13[0],
2167
+ v = _ref13[1];
2168
+ return /*#__PURE__*/jsxs("div", {
2169
+ children: [/*#__PURE__*/jsx("div", {
2170
+ style: {
2171
+ fontSize: 8,
2172
+ color: "#9CA3AF"
2173
+ },
2174
+ children: l
2175
+ }), /*#__PURE__*/jsx("div", {
2176
+ style: {
2177
+ fontSize: 11.5,
2178
+ fontWeight: 700,
2179
+ color: "#111827"
2180
+ },
2181
+ children: v
2182
+ })]
2183
+ }, l);
2184
+ })
2185
+ })]
2186
+ })]
2187
+ }), /*#__PURE__*/jsxs("div", {
2188
+ style: {
2189
+ display: "flex",
2190
+ gap: 8,
2191
+ flexShrink: 0
2192
+ },
2193
+ children: [/*#__PURE__*/jsx(Panel, {
2194
+ title: "Upsell",
2195
+ subtitle: "Acceptance & raised",
2196
+ style: {
2197
+ flex: 1
2198
+ },
2199
+ children: /*#__PURE__*/jsxs("div", {
2200
+ style: {
2201
+ display: "flex",
2202
+ alignItems: "center",
2203
+ gap: 12
2204
+ },
2205
+ children: [/*#__PURE__*/jsx(Donut, {
2206
+ segments: [{
2207
+ value: (up === null || up === void 0 ? void 0 : up.acceptanceRate) || 0,
2208
+ color: C.indigo
2209
+ }, {
2210
+ value: Math.max(0, 100 - ((up === null || up === void 0 ? void 0 : up.acceptanceRate) || 0)),
2211
+ color: "#E5E7EB"
2212
+ }],
2213
+ size: 76,
2214
+ centerVal: "".concat(formatNumber((up === null || up === void 0 ? void 0 : up.acceptanceRate) || 0), "%"),
2215
+ centerLabel: "accepted"
2216
+ }), /*#__PURE__*/jsxs("div", {
2217
+ style: {
2218
+ flex: 1
2219
+ },
2220
+ children: [/*#__PURE__*/jsx(StatPair, {
2221
+ label: "Acceptance",
2222
+ val: pct((up === null || up === void 0 ? void 0 : up.acceptanceRate) || 0, 1),
2223
+ trend: signed(up === null || up === void 0 ? void 0 : up.acceptanceGrowth)
2224
+ }), /*#__PURE__*/jsx(StatPair, {
2225
+ label: "Raised",
2226
+ val: d$((up === null || up === void 0 ? void 0 : up.raised) || 0),
2227
+ trend: signed(up === null || up === void 0 ? void 0 : up.raisedGrowth)
2228
+ })]
2229
+ })]
2230
+ })
2231
+ }), /*#__PURE__*/jsx(Panel, {
2232
+ title: "Downsell",
2233
+ subtitle: "Acceptance & raised",
2234
+ style: {
2235
+ flex: 1
2236
+ },
2237
+ children: /*#__PURE__*/jsxs("div", {
2238
+ style: {
2239
+ display: "flex",
2240
+ alignItems: "center",
2241
+ gap: 12
2242
+ },
2243
+ children: [/*#__PURE__*/jsx(Donut, {
2244
+ segments: [{
2245
+ value: (dn === null || dn === void 0 ? void 0 : dn.acceptanceRate) || 0,
2246
+ color: C.cyan
2247
+ }, {
2248
+ value: Math.max(0, 100 - ((dn === null || dn === void 0 ? void 0 : dn.acceptanceRate) || 0)),
2249
+ color: "#E5E7EB"
2250
+ }],
2251
+ size: 76,
2252
+ centerVal: "".concat(formatNumber((dn === null || dn === void 0 ? void 0 : dn.acceptanceRate) || 0), "%"),
2253
+ centerLabel: "accepted"
2254
+ }), /*#__PURE__*/jsxs("div", {
2255
+ style: {
2256
+ flex: 1
2257
+ },
2258
+ children: [/*#__PURE__*/jsx(StatPair, {
2259
+ label: "Acceptance",
2260
+ val: pct((dn === null || dn === void 0 ? void 0 : dn.acceptanceRate) || 0, 1),
2261
+ trend: signed(dn === null || dn === void 0 ? void 0 : dn.acceptanceGrowth)
2262
+ }), /*#__PURE__*/jsx(StatPair, {
2263
+ label: "Raised",
2264
+ val: d$((dn === null || dn === void 0 ? void 0 : dn.raised) || 0),
2265
+ trend: signed(dn === null || dn === void 0 ? void 0 : dn.raisedGrowth)
2266
+ })]
2267
+ })]
2268
+ })
2269
+ }), /*#__PURE__*/jsxs(Panel, {
2270
+ title: "Referrals",
2271
+ subtitle: "Revenue trend \xB7 last 30 days",
2272
+ style: {
2273
+ flex: 1
2274
+ },
2275
+ children: [/*#__PURE__*/jsx("div", {
2276
+ style: {
2277
+ fontSize: 17,
2278
+ fontWeight: 800,
2279
+ color: "#111827"
2280
+ },
2281
+ children: d$((refCard === null || refCard === void 0 ? void 0 : refCard.totalRevenue) || 0)
2282
+ }), /*#__PURE__*/jsxs("div", {
2283
+ style: {
2284
+ fontSize: 10,
2285
+ color: "#16A34A",
2286
+ fontWeight: 600,
2287
+ marginBottom: 5
2288
+ },
2289
+ children: [signed(refCard === null || refCard === void 0 ? void 0 : refCard.growthPercentage), " vs ", dateLabel]
2290
+ }), /*#__PURE__*/jsx(Sparkline, {
2291
+ data: refData.length ? refData : [0, 1],
2292
+ color: C.emerald,
2293
+ width: 110,
2294
+ height: 34
2295
+ }), /*#__PURE__*/jsx(Divider, {
2296
+ mt: 8,
2297
+ mb: 7
2298
+ }), /*#__PURE__*/jsx("div", {
2299
+ style: {
2300
+ display: "flex",
2301
+ gap: 12
2302
+ },
2303
+ children: [["Referrers", formatNumber((refCard === null || refCard === void 0 ? void 0 : refCard.totalReferrers) || 0)], ["Avg gift", d$((refCard === null || refCard === void 0 ? void 0 : refCard.averageGift) || 0)], ["Conv. rate", pct((refCard === null || refCard === void 0 ? void 0 : refCard.conversionRate) || 0, 1)]].map(function (_ref14) {
2304
+ var _ref15 = _slicedToArray(_ref14, 2),
2305
+ l = _ref15[0],
2306
+ v = _ref15[1];
2307
+ return /*#__PURE__*/jsxs("div", {
2308
+ children: [/*#__PURE__*/jsx("div", {
2309
+ style: {
2310
+ fontSize: 8,
2311
+ color: "#9CA3AF"
2312
+ },
2313
+ children: l
2314
+ }), /*#__PURE__*/jsx("div", {
2315
+ style: {
2316
+ fontSize: 11.5,
2317
+ fontWeight: 700,
2318
+ color: "#111827"
2319
+ },
2320
+ children: v
2321
+ })]
2322
+ }, l);
2323
+ })
2324
+ })]
2325
+ })]
2326
+ })]
2327
+ }), /*#__PURE__*/jsx(PageFooter, {
2328
+ generatedLabel: generatedLabel,
2329
+ page: 2
2330
+ })]
2331
+ })]
2332
+ });
2333
+ });
2334
+ ExportPdfLayout.displayName = "ExportPdfLayout";
2335
+
888
2336
  var OverallSection$2 = /*#__PURE__*/lazy(function () {
889
2337
  return Promise.resolve().then(function () { return OverallSection$1; });
890
2338
  });
@@ -917,139 +2365,96 @@ var NewOverview = function NewOverview(_ref) {
917
2365
  _useState4 = _slicedToArray(_useState3, 2),
918
2366
  activeSection = _useState4[0],
919
2367
  setActiveSection = _useState4[1];
920
- var exportCaptureRef = useRef(null);
2368
+ var _useState5 = useState(false),
2369
+ _useState6 = _slicedToArray(_useState5, 2),
2370
+ showExportLayout = _useState6[0],
2371
+ setShowExportLayout = _useState6[1];
2372
+ var exportLayoutRef = useRef(null);
921
2373
  useEffect(function () {
922
2374
  if (activeSectionProp) {
923
2375
  var capitalized = activeSectionProp.charAt(0).toUpperCase() + activeSectionProp.slice(1).toLowerCase();
924
2376
  setActiveSection(capitalized);
925
2377
  }
926
2378
  }, [activeSectionProp]);
2379
+
2380
+ // Step 1 – mount the off-screen export layout whenever the trigger fires
927
2381
  useEffect(function () {
928
- if (exportTrigger <= 0) return;
929
- var buildAndDownloadPdf = /*#__PURE__*/function () {
2382
+ if (exportTrigger > 0) setShowExportLayout(true);
2383
+ }, [exportTrigger]);
2384
+
2385
+ // Step 2 – once the layout is in the DOM, capture each page and build the PDF
2386
+ useEffect(function () {
2387
+ if (!showExportLayout) return;
2388
+ var doPdfExport = /*#__PURE__*/function () {
930
2389
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
931
- var captureNode, _yield$Promise$all, _yield$Promise$all2, jsPDF, html2canvasModule, html2canvas, dateLabel, generatedAt, generatedLabel, canvas, sectionImageWidth, sectionImageHeight, doc, pageWidth, pageHeight, marginX, contentTop, contentBottom, contentWidth, contentHeight, pxPerPt, pageSliceHeightPx, totalPages, addHeader, addFooter, i, startY, sliceHeight, pageCanvas, pageCtx, pageImage, renderHeight, safeDate, _t;
2390
+ var container, pageEls, _yield$Promise$all, _yield$Promise$all2, jsPDF, html2canvasModule, html2canvas, doc, pdfW, pdfH, i, el, cvs, safeDate, _t;
932
2391
  return _regenerator().w(function (_context) {
933
2392
  while (1) switch (_context.p = _context.n) {
934
2393
  case 0:
935
2394
  _context.p = 0;
936
- if (!(activeSection !== "Overall")) {
937
- _context.n = 1;
2395
+ _context.n = 1;
2396
+ return new Promise(function (r) {
2397
+ return requestAnimationFrame(function () {
2398
+ return requestAnimationFrame(r);
2399
+ });
2400
+ });
2401
+ case 1:
2402
+ _context.n = 2;
2403
+ return new Promise(function (r) {
2404
+ return setTimeout(r, 400);
2405
+ });
2406
+ case 2:
2407
+ container = exportLayoutRef.current;
2408
+ if (container) {
2409
+ _context.n = 3;
938
2410
  break;
939
2411
  }
940
2412
  return _context.a(2);
941
- case 1:
942
- captureNode = exportCaptureRef.current;
943
- if (captureNode) {
944
- _context.n = 2;
2413
+ case 3:
2414
+ pageEls = container.querySelectorAll("[data-export-page]");
2415
+ if (pageEls.length) {
2416
+ _context.n = 4;
945
2417
  break;
946
2418
  }
947
2419
  return _context.a(2);
948
- case 2:
949
- _context.n = 3;
2420
+ case 4:
2421
+ _context.n = 5;
950
2422
  return Promise.all([import('jspdf'), Promise.resolve().then(function () { return html2canvas_esm; })]);
951
- case 3:
2423
+ case 5:
952
2424
  _yield$Promise$all = _context.v;
953
2425
  _yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
954
2426
  jsPDF = _yield$Promise$all2[0].jsPDF;
955
2427
  html2canvasModule = _yield$Promise$all2[1];
956
2428
  html2canvas = html2canvasModule["default"] || html2canvasModule;
957
- dateLabel = dateName || "Last Period";
958
- generatedAt = new Date();
959
- generatedLabel = "".concat(generatedAt.toLocaleDateString(), " ").concat(generatedAt.toLocaleTimeString(), " GMT");
960
- _context.n = 4;
961
- return new Promise(function (resolve) {
962
- return setTimeout(resolve, 900);
963
- });
964
- case 4:
965
- _context.n = 5;
966
- return html2canvas(captureNode, {
967
- scale: 2,
968
- useCORS: true,
969
- backgroundColor: "#ffffff",
970
- width: captureNode.scrollWidth,
971
- height: captureNode.scrollHeight,
972
- windowWidth: captureNode.scrollWidth,
973
- windowHeight: captureNode.scrollHeight,
974
- scrollX: 0,
975
- scrollY: -window.scrollY
976
- });
977
- case 5:
978
- canvas = _context.v;
979
- sectionImageWidth = canvas.width;
980
- sectionImageHeight = canvas.height;
981
2429
  doc = new jsPDF({
982
2430
  unit: "pt",
983
2431
  format: "a4"
984
2432
  });
985
- pageWidth = doc.internal.pageSize.getWidth();
986
- pageHeight = doc.internal.pageSize.getHeight();
987
- marginX = 40;
988
- contentTop = 112;
989
- contentBottom = 40;
990
- contentWidth = pageWidth - marginX * 2;
991
- contentHeight = pageHeight - contentTop - contentBottom;
992
- pxPerPt = sectionImageWidth / contentWidth;
993
- pageSliceHeightPx = Math.max(1, Math.floor(contentHeight * pxPerPt));
994
- totalPages = Math.max(1, Math.ceil(sectionImageHeight / pageSliceHeightPx));
995
- addHeader = function addHeader() {
996
- doc.setFont("helvetica", "bold");
997
- doc.setTextColor(17, 24, 39);
998
- doc.setFontSize(17);
999
- doc.text("Madinah", marginX, 34);
1000
- doc.setFontSize(9.5);
1001
- doc.setTextColor(75, 85, 99);
1002
- doc.text("PERFORMANCE REPORT", marginX, 50);
1003
- doc.setTextColor(17, 24, 39);
1004
- doc.setFontSize(12);
1005
- doc.text("Dashboard overview — Overall", marginX, 72);
1006
- doc.setFont("helvetica", "normal");
1007
- doc.setFontSize(9);
1008
- doc.setTextColor(107, 114, 128);
1009
- doc.text("".concat(dateLabel), marginX, 88);
1010
- doc.text("30-day window \xB7 Generated ".concat(generatedLabel), marginX, 100);
1011
- var activeFilters = (apiData === null || apiData === void 0 ? void 0 : apiData.activeFilters) || "";
1012
- if (activeFilters) {
1013
- doc.setFontSize(8);
1014
- doc.setTextColor(55, 65, 81);
1015
- doc.text("ACTIVE FILTERS ".concat(activeFilters), marginX, 110);
1016
- }
1017
- };
1018
- addFooter = function addFooter(pageNumber, totalPages) {
1019
- doc.setFont("helvetica", "normal");
1020
- doc.setTextColor(107, 114, 128);
1021
- doc.setFontSize(8);
1022
- doc.text("Confidential \xB7 Generated by Dashboard \xB7 ".concat(generatedLabel, " \xB7 Page ").concat(pageNumber, " of ").concat(totalPages, " \xB7 madinah.com"), marginX, pageHeight - 18);
1023
- };
2433
+ pdfW = doc.internal.pageSize.getWidth();
2434
+ pdfH = doc.internal.pageSize.getHeight();
1024
2435
  i = 0;
1025
2436
  case 6:
1026
- if (!(i < totalPages)) {
2437
+ if (!(i < pageEls.length)) {
1027
2438
  _context.n = 9;
1028
2439
  break;
1029
2440
  }
1030
- if (i > 0) doc.addPage();
1031
- addHeader();
1032
- startY = i * pageSliceHeightPx;
1033
- sliceHeight = Math.min(pageSliceHeightPx, sectionImageHeight - startY);
1034
- pageCanvas = document.createElement("canvas");
1035
- pageCanvas.width = sectionImageWidth;
1036
- pageCanvas.height = sliceHeight;
1037
- pageCtx = pageCanvas.getContext("2d");
1038
- if (pageCtx) {
1039
- _context.n = 7;
1040
- break;
1041
- }
1042
- return _context.a(3, 8);
2441
+ el = pageEls[i];
2442
+ _context.n = 7;
2443
+ return html2canvas(el, {
2444
+ scale: 2,
2445
+ useCORS: true,
2446
+ backgroundColor: "#ffffff",
2447
+ width: el.offsetWidth,
2448
+ height: el.offsetHeight,
2449
+ windowWidth: el.offsetWidth,
2450
+ windowHeight: el.offsetHeight
2451
+ });
1043
2452
  case 7:
1044
- pageCtx.fillStyle = "#ffffff";
1045
- pageCtx.fillRect(0, 0, pageCanvas.width, pageCanvas.height);
1046
- pageCtx.drawImage(canvas, 0, startY, sectionImageWidth, sliceHeight, 0, 0, sectionImageWidth, sliceHeight);
1047
- pageImage = pageCanvas.toDataURL("image/png");
1048
- renderHeight = sliceHeight / pxPerPt;
1049
- doc.addImage(pageImage, "PNG", marginX, contentTop, contentWidth, renderHeight, undefined, "FAST");
1050
- addFooter(i + 1, totalPages);
2453
+ cvs = _context.v;
2454
+ if (i > 0) doc.addPage();
2455
+ doc.addImage(cvs.toDataURL("image/png"), "PNG", 0, 0, pdfW, pdfH, undefined, "FAST");
1051
2456
  case 8:
1052
- i += 1;
2457
+ i++;
1053
2458
  _context.n = 6;
1054
2459
  break;
1055
2460
  case 9:
@@ -1060,19 +2465,22 @@ var NewOverview = function NewOverview(_ref) {
1060
2465
  case 10:
1061
2466
  _context.p = 10;
1062
2467
  _t = _context.v;
1063
- // Keep console message for host app debugging when export dependency is missing.
1064
2468
  console.error("Failed to export overall dashboard PDF:", _t);
1065
2469
  case 11:
2470
+ _context.p = 11;
2471
+ setShowExportLayout(false);
2472
+ return _context.f(11);
2473
+ case 12:
1066
2474
  return _context.a(2);
1067
2475
  }
1068
- }, _callee, null, [[0, 10]]);
2476
+ }, _callee, null, [[0, 10, 11, 12]]);
1069
2477
  }));
1070
- return function buildAndDownloadPdf() {
2478
+ return function doPdfExport() {
1071
2479
  return _ref2.apply(this, arguments);
1072
2480
  };
1073
2481
  }();
1074
- buildAndDownloadPdf();
1075
- }, [exportTrigger, activeSection, apiData, dateName]);
2482
+ doPdfExport();
2483
+ }, [showExportLayout]);
1076
2484
  var currentData = metric === "Revenue" ? revenueData : donationsData;
1077
2485
  var oneTimeData = (apiData === null || apiData === void 0 ? void 0 : apiData.oneTimeDonations) || [];
1078
2486
  var oneTimeValues = oneTimeData.length > 0 ? oneTimeData.map(function (item) {
@@ -1232,15 +2640,14 @@ var NewOverview = function NewOverview(_ref) {
1232
2640
  data: [8, 9, 11, 10, 10, 12, 9, 11, 10],
1233
2641
  categories: categories
1234
2642
  }];
1235
- return /*#__PURE__*/jsx(Box, {
1236
- ref: exportCaptureRef,
2643
+ return /*#__PURE__*/jsxs(Box, {
1237
2644
  sx: {
1238
2645
  minHeight: "100vh",
1239
2646
  display: "flex",
1240
2647
  flexDirection: "column",
1241
2648
  alignItems: "stretch"
1242
2649
  },
1243
- children: /*#__PURE__*/jsxs(Suspense, {
2650
+ children: [/*#__PURE__*/jsxs(Suspense, {
1244
2651
  fallback: /*#__PURE__*/jsx(Box, {
1245
2652
  sx: {
1246
2653
  display: "flex",
@@ -1270,7 +2677,22 @@ var NewOverview = function NewOverview(_ref) {
1270
2677
  sx: {},
1271
2678
  children: /*#__PURE__*/jsx(EmailSection$2, {})
1272
2679
  })]
1273
- })
2680
+ }), showExportLayout && /*#__PURE__*/jsx("div", {
2681
+ "aria-hidden": "true",
2682
+ style: {
2683
+ position: "fixed",
2684
+ top: 0,
2685
+ left: "-9999px",
2686
+ zIndex: -1,
2687
+ pointerEvents: "none",
2688
+ opacity: 1
2689
+ },
2690
+ children: /*#__PURE__*/jsx(ExportPdfLayout, {
2691
+ ref: exportLayoutRef,
2692
+ apiData: apiData,
2693
+ dateName: dateName
2694
+ })
2695
+ })]
1274
2696
  });
1275
2697
  };
1276
2698
 
@@ -3311,19 +4733,6 @@ var DonorMixCard = function DonorMixCard(_ref) {
3311
4733
  });
3312
4734
  };
3313
4735
 
3314
- function formatNumber(num) {
3315
- if (num >= 1000000000) {
3316
- return (num / 1000000000).toFixed(1).replace(/\.0$/, "") + "B";
3317
- }
3318
- if (num >= 1000000) {
3319
- return (num / 1000000).toFixed(1).replace(/\.0$/, "") + "M";
3320
- }
3321
- if (num >= 1000) {
3322
- return (num / 1000).toFixed(1).replace(/\.0$/, "") + "K";
3323
- }
3324
- return (num !== null && num !== void 0 ? num : 0).toString();
3325
- }
3326
-
3327
4736
  var TrafficSourceCard = function TrafficSourceCard(_ref) {
3328
4737
  var _ref$title = _ref.title,
3329
4738
  title = _ref$title === void 0 ? "Traffic source" : _ref$title,