react-semaphor 0.1.443 → 0.1.445
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 +7 -0
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +123 -107
- package/dist/appearance/index.cjs +1 -1
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +5 -4
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +526 -457
- package/dist/chunks/analyze-result-contract-BHb7sUUW.cjs +1 -0
- package/dist/chunks/analyze-result-contract-DUv3QnMl.js +29 -0
- package/dist/chunks/{braces-CbO-aIwH.js → braces-BKimshER.cjs} +1 -1
- package/dist/chunks/{code-editor-BpADiIlq.js → code-editor-B4gTfvc5.js} +6800 -6560
- package/dist/chunks/code-editor-BYVorgOf.cjs +138 -0
- package/dist/chunks/common-types-CQ6SHfLk.cjs +1 -0
- package/dist/chunks/{common-types-ClkOI-3O.js → common-types-DFsDdpH7.js} +22 -21
- package/dist/chunks/dashboard-CAiwJW3L.cjs +1397 -0
- package/dist/chunks/{dashboard-briefing-launcher-C60n8LqW.js → dashboard-briefing-launcher-2SLNOaTg.js} +26 -24
- package/dist/chunks/{dashboard-briefing-launcher-BYMLjZxG.js → dashboard-briefing-launcher-CHwjpUYz.cjs} +2 -2
- package/dist/chunks/{dashboard-controls-ti9Rcel2.js → dashboard-controls-BfL14aqO.js} +11 -9
- package/dist/chunks/{dashboard-controls-BH_fZYDU.js → dashboard-controls-BgGTg4yw.cjs} +2 -2
- package/dist/chunks/dashboard-date-comparison-definition-DZq0htjG.cjs +1 -0
- package/dist/chunks/dashboard-json-BOv8tCa9.cjs +1 -0
- package/dist/chunks/{dashboard-json-Bturr634.js → dashboard-json-BZwq3EcS.js} +14 -12
- package/dist/chunks/{dashboard-Bd1Quco-.js → dashboard-u61yfU6u.js} +50081 -47351
- package/dist/chunks/edit-dashboard-visual-BdVCH0DJ.cjs +182 -0
- package/dist/chunks/{edit-dashboard-visual-DglMds57.js → edit-dashboard-visual-njLPYip3.js} +6825 -6656
- package/dist/chunks/{editor-action-buttons-CRi0fhVW.js → editor-action-buttons-BhLX5Q6m.js} +24 -23
- package/dist/chunks/{editor-action-buttons-Cxo7_tNG.js → editor-action-buttons-CBVMFipA.cjs} +1 -1
- package/dist/chunks/{index-D7KJindZ.js → format-types-CSv0V7mm.cjs} +1 -1
- package/dist/chunks/{index-CnujJ3fa.js → format-types-CZH5w1lo.js} +23 -17
- package/dist/chunks/{layout-grid-B08pP7v6.js → layout-grid-3-HWzEwU.cjs} +1 -1
- package/dist/chunks/{metric-comparison-CPoDx56y.js → metric-comparison-BJ_Qu1ZF.js} +1 -1
- package/dist/chunks/metric-comparison-CUAJ8n4y.cjs +1 -0
- package/dist/chunks/{palette-C0yjT5Tv.js → palette-DW_l7Jr0.cjs} +1 -1
- package/dist/chunks/pivot-result-identity-B6QCWOSi.js +94 -0
- package/dist/chunks/pivot-result-identity-CDLRT-YG.cjs +1 -0
- package/dist/chunks/pivot-result-lifecycle-BM3Pl-D1.js +914 -0
- package/dist/chunks/pivot-result-lifecycle-DPc0ANwk.cjs +4 -0
- package/dist/chunks/presentation-execution-BTV-Q43g.cjs +1 -0
- package/dist/chunks/presentation-execution-CGlb7YZ6.js +637 -0
- package/dist/chunks/{report-preferences-dialog-TtwdAuNn.js → report-preferences-dialog-D_NJu2wU.js} +7 -6
- package/dist/chunks/report-preferences-dialog-r8QzOSFb.cjs +1 -0
- package/dist/chunks/report-runtime-context-C8LZFsqV.cjs +1 -0
- package/dist/chunks/report-runtime-context-Qzn11HQe.js +387 -0
- package/dist/chunks/{save-Xdc4pnys.js → save-4_uMnE6s.cjs} +1 -1
- package/dist/chunks/{search-Dcud9ajy.js → search-6ZmeMq55.cjs} +1 -1
- package/dist/chunks/temporal-bucket-BnPxGrAi.js +446 -0
- package/dist/chunks/temporal-bucket-authoring-BUZMuVca.js +205 -0
- package/dist/chunks/temporal-bucket-authoring-CPTwHzvs.cjs +1 -0
- package/dist/chunks/temporal-bucket-contract-B2bJ1oe4.js +108 -0
- package/dist/chunks/temporal-bucket-contract-ChDBWX8I.cjs +1 -0
- package/dist/chunks/temporal-bucket-pMnV-4Nj.cjs +1 -0
- package/dist/chunks/{comparison-document-migration-Dj6xZMCb.js → temporal-result-owner-Cb27SSG9.js} +152 -123
- package/dist/chunks/temporal-result-owner-f6-i65Fb.cjs +1 -0
- package/dist/chunks/token-types-BdQ8kHBm.cjs +1 -0
- package/dist/chunks/token-types-DLo91nOf.js +8 -0
- package/dist/chunks/{update-policy-DnF_74zC.js → update-policy-BxvYMYz0.cjs} +1 -1
- package/dist/chunks/{update-policy-De2NswtM.js → update-policy-eg59mQqv.js} +1 -1
- package/dist/chunks/validators-9D4KBqKD.cjs +1 -0
- package/dist/chunks/validators-wZ2WlNHc.js +4640 -0
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +136 -126
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +2 -2
- package/dist/data-app-sdk/index.js +34 -35
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +5 -5
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +9 -10
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +155 -176
- package/dist/index.cjs +1 -1
- package/dist/index.js +180 -174
- package/dist/report-runtime-context/index.cjs +1 -1
- package/dist/report-runtime-context/index.js +7 -392
- package/dist/shared/index.cjs +1 -1
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +257 -48
- package/dist/types/briefings.d.ts +138 -50
- package/dist/types/dashboard-assistant.d.ts +207 -52
- package/dist/types/dashboard-authoring.d.ts +182 -50
- package/dist/types/dashboard.d.ts +290 -48
- package/dist/types/data-app-builder.d.ts +48 -42
- package/dist/types/data-app-codegen-node.d.ts +50 -44
- package/dist/types/data-app-codegen.d.ts +50 -44
- package/dist/types/data-app-sdk-adapters.d.ts +48 -42
- package/dist/types/data-app-sdk-validation.d.ts +81 -43
- package/dist/types/data-app-sdk.d.ts +83 -45
- package/dist/types/format-utils.d.ts +645 -67
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +19 -19
- package/dist/types/main.d.ts +298 -94
- package/dist/types/report-runtime-context.d.ts +3 -0
- package/dist/types/shared.d.ts +116 -41
- package/dist/types/surfboard.d.ts +290 -48
- package/dist/types/types.d.ts +455 -65
- package/package.json +3 -1
- package/dist/chunks/analyze-result-contract-BswhsmWT.js +0 -1
- package/dist/chunks/analyze-result-contract-CfOBEwaC.js +0 -1998
- package/dist/chunks/code-editor-M7HTUhdF.js +0 -138
- package/dist/chunks/common-types-C73-Ud1-.js +0 -1
- package/dist/chunks/comparison-document-migration-DbU_BTxR.js +0 -1
- package/dist/chunks/csv-utils-BZDvO2Fw.js +0 -376
- package/dist/chunks/csv-utils-Co0WxHke.js +0 -4
- package/dist/chunks/dashboard-cB3xmTNn.js +0 -1402
- package/dist/chunks/dashboard-date-comparison-definition-DGZr3m-b.js +0 -1
- package/dist/chunks/dashboard-json-Dw_55vSZ.js +0 -1
- package/dist/chunks/edit-dashboard-visual-BUc3NBQ4.js +0 -182
- package/dist/chunks/metric-comparison-DVy3fll_.js +0 -1
- package/dist/chunks/numeric-presentation-BJs5lSar.js +0 -517
- package/dist/chunks/numeric-presentation-Dlb-Dk4c.js +0 -1
- package/dist/chunks/report-preferences-dialog-CCvFqH4Q.js +0 -1
- package/dist/chunks/source-identity-5OPV4gvg.js +0 -92
- package/dist/chunks/source-identity-Cbo2LOHQ.js +0 -1
- package/dist/chunks/validators-B2vUAqTf.js +0 -1
- package/dist/chunks/validators-Bce_J7Vd.js +0 -2448
- /package/dist/chunks/{card-config-utils-15sRtebL.js → card-config-utils-15sRtebL.cjs} +0 -0
- /package/dist/chunks/{catalog-field-grounding-Bnx-3tE0.js → catalog-field-grounding-Bnx-3tE0.cjs} +0 -0
- /package/dist/chunks/{dashboard-input-contract-DV3cshjz.js → dashboard-input-contract-DV3cshjz.cjs} +0 -0
- /package/dist/chunks/{index-Dpm_VET4.js → index-Dpm_VET4.cjs} +0 -0
- /package/dist/chunks/{index-jSrCwPQz.js → index-jSrCwPQz.cjs} +0 -0
- /package/dist/chunks/{normalize-dashboard-for-dirty-check-BXRUMVb2.js → normalize-dashboard-for-dirty-check-BXRUMVb2.cjs} +0 -0
- /package/dist/chunks/{operators-DrTQsJXv.js → operators-DrTQsJXv.cjs} +0 -0
- /package/dist/chunks/{use-debounced-dirty-check-XHSwAefL.js → use-debounced-dirty-check-XHSwAefL.cjs} +0 -0
|
@@ -0,0 +1,914 @@
|
|
|
1
|
+
var V = Object.defineProperty;
|
|
2
|
+
var U = (e, t, n) => t in e ? V(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var w = (e, t, n) => U(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { t as y, c as B, e as Z, g as D, m as L, a as b, b as q, i as G, d as X, f as H, h as Y } from "./format-types-CZH5w1lo.js";
|
|
5
|
+
import { b as h } from "./presentation-execution-CGlb7YZ6.js";
|
|
6
|
+
import { f as W } from "./temporal-bucket-BnPxGrAi.js";
|
|
7
|
+
import { m as J } from "./validators-wZ2WlNHc.js";
|
|
8
|
+
import "./analyze-result-contract-DUv3QnMl.js";
|
|
9
|
+
import { a as Q } from "./metric-comparison-BJ_Qu1ZF.js";
|
|
10
|
+
import { b as z } from "./temporal-bucket-contract-B2bJ1oe4.js";
|
|
11
|
+
import { d as ee, P as te } from "./pivot-result-identity-B6QCWOSi.js";
|
|
12
|
+
function M(e, t) {
|
|
13
|
+
const n = y(e), o = y(t), r = n.getTime() - o.getTime();
|
|
14
|
+
return r < 0 ? -1 : r > 0 ? 1 : r;
|
|
15
|
+
}
|
|
16
|
+
function ne(e) {
|
|
17
|
+
return B(e, Date.now());
|
|
18
|
+
}
|
|
19
|
+
function re(e, t) {
|
|
20
|
+
const n = y(e), o = y(t), r = n.getFullYear() - o.getFullYear(), s = n.getMonth() - o.getMonth();
|
|
21
|
+
return r * 12 + s;
|
|
22
|
+
}
|
|
23
|
+
function oe(e) {
|
|
24
|
+
return (t) => {
|
|
25
|
+
const o = (e ? Math[e] : Math.trunc)(t);
|
|
26
|
+
return o === 0 ? 0 : o;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function se(e, t) {
|
|
30
|
+
return +y(e) - +y(t);
|
|
31
|
+
}
|
|
32
|
+
function ie(e) {
|
|
33
|
+
const t = y(e);
|
|
34
|
+
return t.setHours(23, 59, 59, 999), t;
|
|
35
|
+
}
|
|
36
|
+
function ae(e) {
|
|
37
|
+
const t = y(e), n = t.getMonth();
|
|
38
|
+
return t.setFullYear(t.getFullYear(), n + 1, 0), t.setHours(23, 59, 59, 999), t;
|
|
39
|
+
}
|
|
40
|
+
function ce(e) {
|
|
41
|
+
const t = y(e);
|
|
42
|
+
return +ie(t) == +ae(t);
|
|
43
|
+
}
|
|
44
|
+
function le(e, t) {
|
|
45
|
+
const n = y(e), o = y(t), r = M(n, o), s = Math.abs(
|
|
46
|
+
re(n, o)
|
|
47
|
+
);
|
|
48
|
+
let a;
|
|
49
|
+
if (s < 1)
|
|
50
|
+
a = 0;
|
|
51
|
+
else {
|
|
52
|
+
n.getMonth() === 1 && n.getDate() > 27 && n.setDate(30), n.setMonth(n.getMonth() - r * s);
|
|
53
|
+
let i = M(n, o) === -r;
|
|
54
|
+
ce(y(e)) && s === 1 && M(e, o) === 1 && (i = !1), a = r * (s - Number(i));
|
|
55
|
+
}
|
|
56
|
+
return a === 0 ? 0 : a;
|
|
57
|
+
}
|
|
58
|
+
function ue(e, t, n) {
|
|
59
|
+
const o = se(e, t) / 1e3;
|
|
60
|
+
return oe(n == null ? void 0 : n.roundingMethod)(o);
|
|
61
|
+
}
|
|
62
|
+
function fe(e, t, n) {
|
|
63
|
+
const o = q(), r = (n == null ? void 0 : n.locale) ?? o.locale ?? Z, s = 2520, a = M(e, t);
|
|
64
|
+
if (isNaN(a))
|
|
65
|
+
throw new RangeError("Invalid time value");
|
|
66
|
+
const i = Object.assign({}, n, {
|
|
67
|
+
addSuffix: n == null ? void 0 : n.addSuffix,
|
|
68
|
+
comparison: a
|
|
69
|
+
});
|
|
70
|
+
let c, f;
|
|
71
|
+
a > 0 ? (c = y(t), f = y(e)) : (c = y(e), f = y(t));
|
|
72
|
+
const m = ue(f, c), d = (D(f) - D(c)) / 1e3, u = Math.round((m - d) / 60);
|
|
73
|
+
let p;
|
|
74
|
+
if (u < 2)
|
|
75
|
+
return n != null && n.includeSeconds ? m < 5 ? r.formatDistance("lessThanXSeconds", 5, i) : m < 10 ? r.formatDistance("lessThanXSeconds", 10, i) : m < 20 ? r.formatDistance("lessThanXSeconds", 20, i) : m < 40 ? r.formatDistance("halfAMinute", 0, i) : m < 60 ? r.formatDistance("lessThanXMinutes", 1, i) : r.formatDistance("xMinutes", 1, i) : u === 0 ? r.formatDistance("lessThanXMinutes", 1, i) : r.formatDistance("xMinutes", u, i);
|
|
76
|
+
if (u < 45)
|
|
77
|
+
return r.formatDistance("xMinutes", u, i);
|
|
78
|
+
if (u < 90)
|
|
79
|
+
return r.formatDistance("aboutXHours", 1, i);
|
|
80
|
+
if (u < L) {
|
|
81
|
+
const g = Math.round(u / 60);
|
|
82
|
+
return r.formatDistance("aboutXHours", g, i);
|
|
83
|
+
} else {
|
|
84
|
+
if (u < s)
|
|
85
|
+
return r.formatDistance("xDays", 1, i);
|
|
86
|
+
if (u < b) {
|
|
87
|
+
const g = Math.round(u / L);
|
|
88
|
+
return r.formatDistance("xDays", g, i);
|
|
89
|
+
} else if (u < b * 2)
|
|
90
|
+
return p = Math.round(u / b), r.formatDistance("aboutXMonths", p, i);
|
|
91
|
+
}
|
|
92
|
+
if (p = le(f, c), p < 12) {
|
|
93
|
+
const g = Math.round(u / b);
|
|
94
|
+
return r.formatDistance("xMonths", g, i);
|
|
95
|
+
} else {
|
|
96
|
+
const g = p % 12, x = Math.trunc(p / 12);
|
|
97
|
+
return g < 3 ? r.formatDistance("aboutXYears", x, i) : g < 9 ? r.formatDistance("overXYears", x, i) : r.formatDistance("almostXYears", x + 1, i);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function de(e, t) {
|
|
101
|
+
return fe(e, ne(e), t);
|
|
102
|
+
}
|
|
103
|
+
const F = [
|
|
104
|
+
"day",
|
|
105
|
+
"hour",
|
|
106
|
+
"minute",
|
|
107
|
+
"second",
|
|
108
|
+
"millisecond"
|
|
109
|
+
], R = {
|
|
110
|
+
day: 864e5,
|
|
111
|
+
hour: 36e5,
|
|
112
|
+
minute: 6e4,
|
|
113
|
+
second: 1e3,
|
|
114
|
+
millisecond: 1
|
|
115
|
+
}, me = {
|
|
116
|
+
day: "d",
|
|
117
|
+
hour: "hr",
|
|
118
|
+
minute: "min",
|
|
119
|
+
second: "s",
|
|
120
|
+
millisecond: "ms"
|
|
121
|
+
}, ye = {
|
|
122
|
+
day: ["day", "days"],
|
|
123
|
+
hour: ["hour", "hours"],
|
|
124
|
+
minute: ["minute", "minutes"],
|
|
125
|
+
second: ["second", "seconds"],
|
|
126
|
+
millisecond: ["millisecond", "milliseconds"]
|
|
127
|
+
};
|
|
128
|
+
function ge(e) {
|
|
129
|
+
return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
|
|
130
|
+
}
|
|
131
|
+
function P(e, t) {
|
|
132
|
+
return ge(e) ? e : t;
|
|
133
|
+
}
|
|
134
|
+
function I(e, t) {
|
|
135
|
+
return F.indexOf(P(e, t));
|
|
136
|
+
}
|
|
137
|
+
function pe(e, t) {
|
|
138
|
+
const n = I(e, "day"), o = I(t, "second"), r = Math.min(n, o), s = Math.max(n, o);
|
|
139
|
+
return F.slice(r, s + 1);
|
|
140
|
+
}
|
|
141
|
+
function he(e, t) {
|
|
142
|
+
return e * R[P(t, "second")];
|
|
143
|
+
}
|
|
144
|
+
function we(e, t) {
|
|
145
|
+
const n = pe(t.largestUnit, t.smallestUnit), o = n[n.length - 1], r = R[o];
|
|
146
|
+
let s = Math.round(e / r) * r;
|
|
147
|
+
return n.map((a) => {
|
|
148
|
+
const i = R[a], c = Math.floor(s / i);
|
|
149
|
+
return s -= c * i, { unit: a, value: c };
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
function be(e, t) {
|
|
153
|
+
const n = e.filter((s) => s.value !== 0), o = n.length > 0 ? n : [e[e.length - 1]], r = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : o.length;
|
|
154
|
+
return o.slice(0, r).map((s) => `${s.value}${me[s.unit]}`).join(" ");
|
|
155
|
+
}
|
|
156
|
+
function ve(e, t) {
|
|
157
|
+
const n = e.filter((s) => s.value !== 0), o = n.length > 0 ? n : [e[e.length - 1]], r = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : o.length;
|
|
158
|
+
return o.slice(0, r).map((s) => {
|
|
159
|
+
const [a, i] = ye[s.unit];
|
|
160
|
+
return `${s.value} ${s.value === 1 ? a : i}`;
|
|
161
|
+
}).join(" ");
|
|
162
|
+
}
|
|
163
|
+
function Me(e) {
|
|
164
|
+
const t = e.some(
|
|
165
|
+
(c) => c.unit === "day" && c.value !== 0
|
|
166
|
+
), n = e.some((c) => c.unit === "millisecond"), o = e.findIndex((c) => c.value !== 0), r = Math.max(0, e.length - 2), s = t ? 0 : o === -1 ? r : Math.min(o, r), a = o === -1 ? e.slice(r) : e.slice(s);
|
|
167
|
+
if (a.length === 0)
|
|
168
|
+
return "0";
|
|
169
|
+
const i = a.map((c, f) => c.unit === "millisecond" ? String(c.value).padStart(3, "0") : f === 0 ? String(c.value) : String(c.value).padStart(2, "0")).join(":");
|
|
170
|
+
return n ? i.replace(/:(\d{3})$/, ".$1") : i;
|
|
171
|
+
}
|
|
172
|
+
function Ae(e, t, n) {
|
|
173
|
+
const o = `${n.prefix || ""}${e}${n.suffix || ""}`;
|
|
174
|
+
return t ? n.negativeInParentheses ? `(${o})` : `-${o}` : o;
|
|
175
|
+
}
|
|
176
|
+
function xe(e, t = {}) {
|
|
177
|
+
if (e == null)
|
|
178
|
+
return "";
|
|
179
|
+
const n = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : NaN;
|
|
180
|
+
if (!Number.isFinite(n))
|
|
181
|
+
return "";
|
|
182
|
+
const o = t.inputUnit || "second", r = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", s = n < 0, a = Math.abs(he(n, o)), i = we(a, t), c = r === "digital" ? Me(i) : r === "long" ? ve(i, t.maxUnits) : be(i, t.maxUnits);
|
|
183
|
+
return Ae(c, s, t);
|
|
184
|
+
}
|
|
185
|
+
function Ce(e, t, n) {
|
|
186
|
+
const o = {
|
|
187
|
+
...t,
|
|
188
|
+
locale: t.locale ?? n
|
|
189
|
+
};
|
|
190
|
+
if (o.type === "number")
|
|
191
|
+
return h(e, o);
|
|
192
|
+
const { prefix: r, suffix: s, ...a } = o;
|
|
193
|
+
return `${r ?? ""}${h(e, {
|
|
194
|
+
...a,
|
|
195
|
+
negativeStyle: o.type === "currency" ? o.negativeStyle : "minus"
|
|
196
|
+
})}${s ?? ""}`;
|
|
197
|
+
}
|
|
198
|
+
function C(e, t, n) {
|
|
199
|
+
return e === null ? { value: e, text: null } : !t || !G(t) && t.type !== "duration" ? {
|
|
200
|
+
value: e,
|
|
201
|
+
text: h(e, { type: "number", locale: n })
|
|
202
|
+
} : t.type === "duration" ? {
|
|
203
|
+
value: e,
|
|
204
|
+
text: xe(e, {
|
|
205
|
+
inputUnit: t.inputUnit,
|
|
206
|
+
outputStyle: t.outputStyle,
|
|
207
|
+
largestUnit: t.largestUnit,
|
|
208
|
+
smallestUnit: t.smallestUnit,
|
|
209
|
+
maxUnits: t.maxUnits,
|
|
210
|
+
prefix: t.prefix,
|
|
211
|
+
suffix: t.suffix,
|
|
212
|
+
negativeInParentheses: t.negativeStyle === "parentheses"
|
|
213
|
+
})
|
|
214
|
+
} : { value: e, text: Ce(e, t, n) };
|
|
215
|
+
}
|
|
216
|
+
function _(e, t, n, o) {
|
|
217
|
+
return e === null ? { value: e, text: null } : o === "percent" ? {
|
|
218
|
+
value: e,
|
|
219
|
+
text: h(e, {
|
|
220
|
+
type: "percent",
|
|
221
|
+
locale: n,
|
|
222
|
+
minimumFractionDigits: t,
|
|
223
|
+
maximumFractionDigits: t,
|
|
224
|
+
percentValueMode: "fraction"
|
|
225
|
+
})
|
|
226
|
+
} : {
|
|
227
|
+
value: e,
|
|
228
|
+
text: h(e, {
|
|
229
|
+
type: "number",
|
|
230
|
+
locale: n,
|
|
231
|
+
minimumFractionDigits: t,
|
|
232
|
+
maximumFractionDigits: t,
|
|
233
|
+
suffix: "×"
|
|
234
|
+
})
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
function T(e, t) {
|
|
238
|
+
if (e === void 0) return t;
|
|
239
|
+
if (!Number.isInteger(e) || e < 0 || e > 6)
|
|
240
|
+
throw new RangeError("Comparison precision must be an integer from 0 to 6.");
|
|
241
|
+
return e;
|
|
242
|
+
}
|
|
243
|
+
function Ye(e, t) {
|
|
244
|
+
const n = {
|
|
245
|
+
mode: t.displayMode,
|
|
246
|
+
current: C(
|
|
247
|
+
e.currentValue,
|
|
248
|
+
t.metricFormat,
|
|
249
|
+
t.locale
|
|
250
|
+
),
|
|
251
|
+
comparison: C(
|
|
252
|
+
e.comparisonValue,
|
|
253
|
+
t.metricFormat,
|
|
254
|
+
t.locale
|
|
255
|
+
)
|
|
256
|
+
};
|
|
257
|
+
return (t.displayMode === "difference" || t.displayMode === "both") && (n.difference = C(
|
|
258
|
+
e.delta,
|
|
259
|
+
t.metricFormat,
|
|
260
|
+
t.locale
|
|
261
|
+
)), (t.displayMode === "percent_change" || t.displayMode === "both") && (n.percentChange = _(
|
|
262
|
+
e.percentChange,
|
|
263
|
+
T(t.precision, 1),
|
|
264
|
+
t.locale,
|
|
265
|
+
"percent"
|
|
266
|
+
)), t.displayMode === "ratio" && (n.ratio = _(
|
|
267
|
+
e.ratio,
|
|
268
|
+
T(t.precision, 2),
|
|
269
|
+
t.locale,
|
|
270
|
+
"ratio"
|
|
271
|
+
)), n;
|
|
272
|
+
}
|
|
273
|
+
function We(e, t) {
|
|
274
|
+
return e && e !== "auto" ? e : t;
|
|
275
|
+
}
|
|
276
|
+
function Je(e, t = /* @__PURE__ */ new Date()) {
|
|
277
|
+
try {
|
|
278
|
+
const n = {
|
|
279
|
+
timeZone: e,
|
|
280
|
+
timeZoneName: "short"
|
|
281
|
+
}, r = new Intl.DateTimeFormat("en-US", n).formatToParts(t).find((s) => s.type === "timeZoneName");
|
|
282
|
+
return (r == null ? void 0 : r.value) || e;
|
|
283
|
+
} catch {
|
|
284
|
+
return e;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
function Qe(e) {
|
|
288
|
+
try {
|
|
289
|
+
const t = {
|
|
290
|
+
timeZone: e,
|
|
291
|
+
timeZoneName: "long"
|
|
292
|
+
}, o = new Intl.DateTimeFormat("en-US", t).formatToParts(
|
|
293
|
+
/* @__PURE__ */ new Date()
|
|
294
|
+
).find((r) => r.type === "timeZoneName");
|
|
295
|
+
return (o == null ? void 0 : o.value) || e;
|
|
296
|
+
} catch {
|
|
297
|
+
return e;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function K(e, t = "auto") {
|
|
301
|
+
if (!e)
|
|
302
|
+
return /* @__PURE__ */ new Date(NaN);
|
|
303
|
+
const n = e.endsWith("Z"), o = /[+-]\d{2}:?\d{2}$/.test(e), r = /\([A-Z]{3,4}\)$/.test(e);
|
|
304
|
+
if (t === "auto")
|
|
305
|
+
return n || o || r ? new Date(e) : /* @__PURE__ */ new Date(e + "Z");
|
|
306
|
+
if (t === "local") {
|
|
307
|
+
if (n || o) {
|
|
308
|
+
const s = e.replace(/Z$/, "").replace(/[+-]\d{2}:?\d{2}$/, "");
|
|
309
|
+
return new Date(s);
|
|
310
|
+
}
|
|
311
|
+
return new Date(e);
|
|
312
|
+
} else return t === "UTC" ? n ? new Date(e) : o ? new Date(e) : /* @__PURE__ */ new Date(e + "Z") : n || o || r ? new Date(e) : Y(e, t);
|
|
313
|
+
}
|
|
314
|
+
const Re = "MM/dd/yyyy", ze = (e, t, n, o = "auto") => {
|
|
315
|
+
if (!e)
|
|
316
|
+
return "";
|
|
317
|
+
try {
|
|
318
|
+
const r = K(e, o);
|
|
319
|
+
if (isNaN(r.getTime()))
|
|
320
|
+
return e;
|
|
321
|
+
const a = (t && t.trim() ? t : Re).replace(/LLLL/g, "MMMM").replace(/LLL/g, "MMM");
|
|
322
|
+
return n && n !== "auto" ? X(r, n, a) : H(r, a);
|
|
323
|
+
} catch (r) {
|
|
324
|
+
return console.error("Date formatting error:", r), e;
|
|
325
|
+
}
|
|
326
|
+
}, et = (e, t = "auto") => {
|
|
327
|
+
if (!e)
|
|
328
|
+
return "";
|
|
329
|
+
try {
|
|
330
|
+
const n = K(e, t);
|
|
331
|
+
return isNaN(n.getTime()) ? e : de(n, { addSuffix: !0 });
|
|
332
|
+
} catch (n) {
|
|
333
|
+
return console.error("Relative time formatting error:", n), e;
|
|
334
|
+
}
|
|
335
|
+
};
|
|
336
|
+
function Se(e, t = ",") {
|
|
337
|
+
if (e == null)
|
|
338
|
+
return "";
|
|
339
|
+
const n = String(e);
|
|
340
|
+
return n.includes(t) || n.includes('"') || n.includes(`
|
|
341
|
+
`) || n.includes("\r") ? `"${n.replace(/"/g, '""')}"` : n;
|
|
342
|
+
}
|
|
343
|
+
function De(e, t = ",") {
|
|
344
|
+
return e.map((n) => Se(n, t)).join(t);
|
|
345
|
+
}
|
|
346
|
+
function Le(e, t = {}) {
|
|
347
|
+
const { delimiter: n = ",", lineEnding: o = `
|
|
348
|
+
` } = t;
|
|
349
|
+
return e.map((r) => De(r, n)).join(o);
|
|
350
|
+
}
|
|
351
|
+
function tt(e, t = {}) {
|
|
352
|
+
if (e.length === 0)
|
|
353
|
+
return "";
|
|
354
|
+
const {
|
|
355
|
+
delimiter: n = ",",
|
|
356
|
+
lineEnding: o = `
|
|
357
|
+
`,
|
|
358
|
+
includeHeaders: r = !0,
|
|
359
|
+
columns: s
|
|
360
|
+
} = t, a = s || Object.keys(e[0]), i = [];
|
|
361
|
+
r && i.push(a);
|
|
362
|
+
for (const c of e) {
|
|
363
|
+
const f = a.map((m) => {
|
|
364
|
+
const d = c[m];
|
|
365
|
+
return d == null ? "" : String(d);
|
|
366
|
+
});
|
|
367
|
+
i.push(f);
|
|
368
|
+
}
|
|
369
|
+
return Le(i, { delimiter: n, lineEnding: o });
|
|
370
|
+
}
|
|
371
|
+
const Ie = "__TOTAL__";
|
|
372
|
+
function A(e) {
|
|
373
|
+
return typeof e == "object" && e !== null && !Array.isArray(e);
|
|
374
|
+
}
|
|
375
|
+
function S(e) {
|
|
376
|
+
return e === Ie;
|
|
377
|
+
}
|
|
378
|
+
function nt(e) {
|
|
379
|
+
const t = /* @__PURE__ */ new Map(), n = (e.groupByColumns ?? []).map((r, s) => {
|
|
380
|
+
var f, m, d;
|
|
381
|
+
if (!A(r))
|
|
382
|
+
throw new Error(`Aggregate groupByColumns[${s}] is invalid`);
|
|
383
|
+
const a = typeof r.id == "string" && r.id.length > 0 ? r.id : void 0, i = a ? (d = (m = (f = e.columnKeyMap) == null ? void 0 : f.byRole) == null ? void 0 : m.groupby) == null ? void 0 : d[a] : void 0, c = (i == null ? void 0 : i.outputKey) || (i == null ? void 0 : i.rawKey) || (typeof r.alias == "string" && r.alias.length > 0 ? r.alias : typeof r.name == "string" && r.name.length > 0 ? r.name : void 0);
|
|
384
|
+
if (!c)
|
|
385
|
+
throw new Error(`Aggregate groupByColumns[${s}] has no output key`);
|
|
386
|
+
return [a, r.alias, r.name, c].forEach((u) => {
|
|
387
|
+
typeof u == "string" && u.length > 0 && t.set(u, c);
|
|
388
|
+
}), c;
|
|
389
|
+
}), o = (e.rowAggregates ?? []).flatMap((r) => !A(r) || typeof r.function != "string" || typeof r.groupLevel != "string" ? [] : [
|
|
390
|
+
{
|
|
391
|
+
function: r.function,
|
|
392
|
+
groupLevel: r.groupLevel === "ALL" ? "ALL" : t.get(r.groupLevel) || r.groupLevel,
|
|
393
|
+
...typeof r.label == "string" ? { label: r.label } : {}
|
|
394
|
+
}
|
|
395
|
+
]);
|
|
396
|
+
return { groupColumnKeys: n, rowAggregates: o };
|
|
397
|
+
}
|
|
398
|
+
function O(e) {
|
|
399
|
+
return e === "SUM" ? "Total" : e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
|
|
400
|
+
}
|
|
401
|
+
function _e(e) {
|
|
402
|
+
var n;
|
|
403
|
+
if (e.customLabel) return e.customLabel;
|
|
404
|
+
const t = O(e.aggregateFunction);
|
|
405
|
+
if (e.levelValue !== void 0 && !S(e.levelValue)) {
|
|
406
|
+
if (e.levelValue === null) {
|
|
407
|
+
const r = (n = e.formatValue) == null ? void 0 : n.call(e, null);
|
|
408
|
+
return r ? `Subtotal ${r}` : `Subtotal ${t}`;
|
|
409
|
+
}
|
|
410
|
+
const o = e.formatValue ? e.formatValue(e.levelValue) : String(e.levelValue);
|
|
411
|
+
if (o) return `Subtotal (${o})`;
|
|
412
|
+
}
|
|
413
|
+
return `Subtotal ${t}`;
|
|
414
|
+
}
|
|
415
|
+
function Te(e, t) {
|
|
416
|
+
return t || `Grand ${O(e)}`;
|
|
417
|
+
}
|
|
418
|
+
function N(e) {
|
|
419
|
+
var o, r;
|
|
420
|
+
const t = e.context.groupColumnKeys, n = typeof e.row.aggregate == "string" ? e.row.aggregate : "SUM";
|
|
421
|
+
if (e.row.isGrandTotal === !0) {
|
|
422
|
+
const s = (o = e.context.rowAggregates.find(
|
|
423
|
+
(a) => a.groupLevel === "ALL"
|
|
424
|
+
)) == null ? void 0 : o.label;
|
|
425
|
+
return {
|
|
426
|
+
kind: "grand-total",
|
|
427
|
+
cells: t.map((a, i) => ({
|
|
428
|
+
columnKey: a,
|
|
429
|
+
text: i === 0 ? Te(n, s) : "",
|
|
430
|
+
placement: i === 0 ? "label" : "empty",
|
|
431
|
+
colSpan: i === 0 ? t.length : 1
|
|
432
|
+
}))
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
if (e.row.isSubtotal === !0) {
|
|
436
|
+
if (typeof e.row.subtotalLevel != "string")
|
|
437
|
+
throw new Error("Aggregate subtotal row is missing subtotalLevel");
|
|
438
|
+
const s = t.indexOf(e.row.subtotalLevel);
|
|
439
|
+
if (s < 0)
|
|
440
|
+
throw new Error(
|
|
441
|
+
`Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`
|
|
442
|
+
);
|
|
443
|
+
const a = A(e.row.subtotalContext) ? e.row.subtotalContext : void 0, i = A(a == null ? void 0 : a.groupByValues) ? a.groupByValues : {}, c = (r = e.context.rowAggregates.find(
|
|
444
|
+
(f) => f.groupLevel === e.row.subtotalLevel && f.function === n
|
|
445
|
+
)) == null ? void 0 : r.label;
|
|
446
|
+
return {
|
|
447
|
+
kind: "subtotal",
|
|
448
|
+
cells: t.map((f, m) => {
|
|
449
|
+
if (m > s)
|
|
450
|
+
return {
|
|
451
|
+
columnKey: f,
|
|
452
|
+
text: "",
|
|
453
|
+
placement: "empty",
|
|
454
|
+
colSpan: 1
|
|
455
|
+
};
|
|
456
|
+
if (m < s) {
|
|
457
|
+
const d = e.row[f];
|
|
458
|
+
return {
|
|
459
|
+
columnKey: f,
|
|
460
|
+
text: d === void 0 || S(d) ? "" : e.formatValue(d, f),
|
|
461
|
+
placement: "value",
|
|
462
|
+
colSpan: 1
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
return {
|
|
466
|
+
columnKey: f,
|
|
467
|
+
text: _e({
|
|
468
|
+
aggregateFunction: n,
|
|
469
|
+
customLabel: c,
|
|
470
|
+
levelValue: i[f],
|
|
471
|
+
formatValue: (d) => e.formatLabelValue ? e.formatLabelValue(d, f) : String(e.formatValue(d, f) ?? "")
|
|
472
|
+
}),
|
|
473
|
+
placement: "label",
|
|
474
|
+
colSpan: t.length - s
|
|
475
|
+
};
|
|
476
|
+
})
|
|
477
|
+
};
|
|
478
|
+
}
|
|
479
|
+
return {
|
|
480
|
+
kind: "data",
|
|
481
|
+
cells: t.map((s) => {
|
|
482
|
+
const a = e.row[s];
|
|
483
|
+
return {
|
|
484
|
+
columnKey: s,
|
|
485
|
+
text: a === void 0 || S(a) ? "" : e.formatValue(a, s),
|
|
486
|
+
placement: "value",
|
|
487
|
+
colSpan: 1
|
|
488
|
+
};
|
|
489
|
+
})
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function rt(e) {
|
|
493
|
+
const t = N(e).cells.find(
|
|
494
|
+
(n) => n.columnKey === e.columnKey
|
|
495
|
+
);
|
|
496
|
+
if (!t)
|
|
497
|
+
throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);
|
|
498
|
+
return t.text;
|
|
499
|
+
}
|
|
500
|
+
function ot(e) {
|
|
501
|
+
return N(e).cells.map((t) => t.text);
|
|
502
|
+
}
|
|
503
|
+
class $e extends Error {
|
|
504
|
+
constructor(n, o) {
|
|
505
|
+
super(`${n}: ${o}`);
|
|
506
|
+
w(this, "deliveryBlocking", !0);
|
|
507
|
+
this.code = n, this.name = "PivotHeaderPresentationError";
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
function st(e) {
|
|
511
|
+
var r;
|
|
512
|
+
const t = e.mode ?? "formatted", n = e.members.map((s) => {
|
|
513
|
+
var i;
|
|
514
|
+
if (t === "canonical" || !s.temporalBucket)
|
|
515
|
+
return s.value === null ? "" : String(s.value);
|
|
516
|
+
const a = (i = e.resolveTemporalFormat) == null ? void 0 : i.call(e, s.fieldId);
|
|
517
|
+
if (!a)
|
|
518
|
+
throw new $e(
|
|
519
|
+
"missing_resolved_temporal_format",
|
|
520
|
+
`Missing resolved temporal presentation for pivot field "${s.fieldId}"`
|
|
521
|
+
);
|
|
522
|
+
return W({
|
|
523
|
+
value: s.value,
|
|
524
|
+
metadata: s.temporalBucket,
|
|
525
|
+
format: a
|
|
526
|
+
});
|
|
527
|
+
}), o = ((r = e.metricLabel) == null ? void 0 : r.trim()) || void 0;
|
|
528
|
+
return {
|
|
529
|
+
memberLabels: n,
|
|
530
|
+
...o ? { metricLabel: o } : {},
|
|
531
|
+
flattenedLabel: [
|
|
532
|
+
...n,
|
|
533
|
+
...o ? [o] : []
|
|
534
|
+
].join(" / ")
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function v(e) {
|
|
538
|
+
return Array.from(
|
|
539
|
+
new Set(
|
|
540
|
+
(e ?? []).flatMap(
|
|
541
|
+
(t) => typeof t.id == "string" && t.id ? [t.id] : []
|
|
542
|
+
)
|
|
543
|
+
)
|
|
544
|
+
);
|
|
545
|
+
}
|
|
546
|
+
function it(e) {
|
|
547
|
+
const t = e.metricFields ?? [], n = v(t), o = /* @__PURE__ */ new Map();
|
|
548
|
+
return n.forEach((r) => {
|
|
549
|
+
o.set(
|
|
550
|
+
r,
|
|
551
|
+
t.filter((s) => s.id === r).length
|
|
552
|
+
);
|
|
553
|
+
}), {
|
|
554
|
+
expectedRoleFieldIds: {
|
|
555
|
+
groupby: v(e.groupByFields),
|
|
556
|
+
metric: n.length > 0 ? n : [J],
|
|
557
|
+
pivotby: v(e.pivotByFields),
|
|
558
|
+
detail: v(e.detailFields)
|
|
559
|
+
},
|
|
560
|
+
expectedMetricAliases: t.flatMap(
|
|
561
|
+
(r) => r.id && (o.get(r.id) ?? 0) > 1 ? [Q(r)] : []
|
|
562
|
+
)
|
|
563
|
+
};
|
|
564
|
+
}
|
|
565
|
+
class l extends Error {
|
|
566
|
+
constructor(n, o) {
|
|
567
|
+
super(`invalid_pivot_result_lifecycle: ${n}`);
|
|
568
|
+
w(this, "code", "invalid_pivot_result_lifecycle");
|
|
569
|
+
w(this, "deliveryBlocking", !0);
|
|
570
|
+
this.cause = o, this.name = "PivotResultLifecycleError";
|
|
571
|
+
}
|
|
572
|
+
}
|
|
573
|
+
function je(e) {
|
|
574
|
+
if (!Array.isArray(e) || e.some(
|
|
575
|
+
(n) => !n || typeof n != "object" || Array.isArray(n) || typeof n.key != "string" || !n.key || typeof n.name != "string" || typeof n.label != "string"
|
|
576
|
+
))
|
|
577
|
+
throw new l(
|
|
578
|
+
"Canonical pivot columns must be an array of keyed, named result descriptors."
|
|
579
|
+
);
|
|
580
|
+
const t = e;
|
|
581
|
+
if (new Set(t.map((n) => n.key)).size !== t.length)
|
|
582
|
+
throw new l(
|
|
583
|
+
"Canonical pivot column keys must be unique."
|
|
584
|
+
);
|
|
585
|
+
for (const n of t) {
|
|
586
|
+
const o = z(n, {
|
|
587
|
+
metadataRequired: !1
|
|
588
|
+
});
|
|
589
|
+
if (!o.ok)
|
|
590
|
+
throw new l(
|
|
591
|
+
`Canonical pivot column "${n.key}" has invalid temporal metadata: ${o.error.message}`
|
|
592
|
+
);
|
|
593
|
+
}
|
|
594
|
+
return t;
|
|
595
|
+
}
|
|
596
|
+
function $(e) {
|
|
597
|
+
if (!e || typeof e != "object" || Array.isArray(e) || e.version !== 1 || e.source !== "explorer" || !e.byRole || typeof e.byRole != "object" || Array.isArray(e.byRole))
|
|
598
|
+
throw new l(
|
|
599
|
+
"A loaded canonical pivot result requires its role-scoped column key map."
|
|
600
|
+
);
|
|
601
|
+
const t = e, n = /* @__PURE__ */ new Set(["groupby", "metric", "pivotby", "detail"]);
|
|
602
|
+
for (const [o, r] of Object.entries(t.byRole)) {
|
|
603
|
+
if (!n.has(o) || !r || typeof r != "object" || Array.isArray(r))
|
|
604
|
+
throw new l(
|
|
605
|
+
`Canonical pivot role map contains invalid "${o}" bindings.`
|
|
606
|
+
);
|
|
607
|
+
for (const [s, a] of Object.entries(r))
|
|
608
|
+
if (!s || !a || typeof a != "object" || Array.isArray(a) || a.role !== o || typeof a.rawKey != "string" || !a.rawKey || a.outputKey !== void 0 && (typeof a.outputKey != "string" || !a.outputKey))
|
|
609
|
+
throw new l(
|
|
610
|
+
`Canonical pivot role map contains an invalid "${o}:${s}" binding.`
|
|
611
|
+
);
|
|
612
|
+
}
|
|
613
|
+
if (t.byMetricAlias !== void 0) {
|
|
614
|
+
if (!t.byMetricAlias || typeof t.byMetricAlias != "object" || Array.isArray(t.byMetricAlias))
|
|
615
|
+
throw new l(
|
|
616
|
+
"Canonical pivot metric-alias bindings must be an object."
|
|
617
|
+
);
|
|
618
|
+
for (const [o, r] of Object.entries(
|
|
619
|
+
t.byMetricAlias
|
|
620
|
+
))
|
|
621
|
+
if (!o || !r || typeof r != "object" || Array.isArray(r) || r.role !== "metric" || typeof r.rawKey != "string" || !r.rawKey || r.outputKey !== void 0 && (typeof r.outputKey != "string" || !r.outputKey))
|
|
622
|
+
throw new l(
|
|
623
|
+
`Canonical pivot metric-alias map contains an invalid "${o}" binding.`
|
|
624
|
+
);
|
|
625
|
+
}
|
|
626
|
+
return t;
|
|
627
|
+
}
|
|
628
|
+
function ke(e) {
|
|
629
|
+
if (e === void 0) return {};
|
|
630
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
631
|
+
throw new l(
|
|
632
|
+
"Canonical pivot column metadata must be an object."
|
|
633
|
+
);
|
|
634
|
+
for (const [t, n] of Object.entries(e)) {
|
|
635
|
+
if (!t || !n || typeof n != "object" || Array.isArray(n))
|
|
636
|
+
throw new l(
|
|
637
|
+
`Canonical pivot column metadata contains an invalid "${t}" classification.`
|
|
638
|
+
);
|
|
639
|
+
const { isSubtotal: o, subtotalScope: r } = n;
|
|
640
|
+
if (o !== void 0 && typeof o != "boolean" || r !== void 0 && r !== "base" && r !== "pivot-value" && r !== "grand-total" || o === !0 && r !== "pivot-value" && r !== "grand-total" || (r === "pivot-value" || r === "grand-total") && o !== !0 || r === "base" && o === !0)
|
|
641
|
+
throw new l(
|
|
642
|
+
`Canonical pivot column metadata contains an incoherent "${t}" subtotal classification.`
|
|
643
|
+
);
|
|
644
|
+
}
|
|
645
|
+
return e;
|
|
646
|
+
}
|
|
647
|
+
function j(e, t) {
|
|
648
|
+
if (!Array.isArray(e) || e.some((n) => typeof n != "string" || !n) || new Set(e).size !== e.length)
|
|
649
|
+
throw new l(
|
|
650
|
+
`Canonical pivot contract ${t} must be an array of unique field identities.`
|
|
651
|
+
);
|
|
652
|
+
return e;
|
|
653
|
+
}
|
|
654
|
+
function Ee(e, t) {
|
|
655
|
+
if (!e || typeof e != "object" || Array.isArray(e) || e.version !== 1)
|
|
656
|
+
throw new l(
|
|
657
|
+
"A canonical pivot result requires its versioned result contract."
|
|
658
|
+
);
|
|
659
|
+
const n = e, o = n.expectedRoleFieldIds;
|
|
660
|
+
if (!o || typeof o != "object" || Array.isArray(o))
|
|
661
|
+
throw new l(
|
|
662
|
+
"Canonical pivot contract role identities must be an object."
|
|
663
|
+
);
|
|
664
|
+
const s = Object.fromEntries(
|
|
665
|
+
[
|
|
666
|
+
"groupby",
|
|
667
|
+
"metric",
|
|
668
|
+
"pivotby",
|
|
669
|
+
"detail"
|
|
670
|
+
].map((u) => [
|
|
671
|
+
u,
|
|
672
|
+
j(
|
|
673
|
+
o[u],
|
|
674
|
+
`expectedRoleFieldIds.${u}`
|
|
675
|
+
)
|
|
676
|
+
])
|
|
677
|
+
), a = j(
|
|
678
|
+
n.expectedMetricAliases,
|
|
679
|
+
"expectedMetricAliases"
|
|
680
|
+
), i = n.columnKinds;
|
|
681
|
+
if (!i || typeof i != "object" || Array.isArray(i))
|
|
682
|
+
throw new l(
|
|
683
|
+
"Canonical pivot contract column kinds must be an object."
|
|
684
|
+
);
|
|
685
|
+
const c = /* @__PURE__ */ new Set([
|
|
686
|
+
"row",
|
|
687
|
+
"pivot_metric",
|
|
688
|
+
"value"
|
|
689
|
+
]), f = t.map((u) => u.key), m = Object.keys(i);
|
|
690
|
+
if (m.length !== f.length || m.some(
|
|
691
|
+
(u) => !f.includes(u) || !c.has(
|
|
692
|
+
i[u]
|
|
693
|
+
)
|
|
694
|
+
))
|
|
695
|
+
throw new l(
|
|
696
|
+
"Canonical pivot contract must classify every authoritative result column exactly once."
|
|
697
|
+
);
|
|
698
|
+
const d = ke(
|
|
699
|
+
n.columnClassifications
|
|
700
|
+
);
|
|
701
|
+
if (Object.keys(d).some(
|
|
702
|
+
(u) => !f.includes(u)
|
|
703
|
+
))
|
|
704
|
+
throw new l(
|
|
705
|
+
"Canonical pivot contract contains a classification for an unknown result column."
|
|
706
|
+
);
|
|
707
|
+
return {
|
|
708
|
+
version: 1,
|
|
709
|
+
expectedRoleFieldIds: s,
|
|
710
|
+
expectedMetricAliases: a,
|
|
711
|
+
columnKinds: i,
|
|
712
|
+
columnClassifications: d
|
|
713
|
+
};
|
|
714
|
+
}
|
|
715
|
+
function k(e, t) {
|
|
716
|
+
const n = [
|
|
717
|
+
"groupby",
|
|
718
|
+
"metric",
|
|
719
|
+
"pivotby",
|
|
720
|
+
"detail"
|
|
721
|
+
];
|
|
722
|
+
for (const s of n) {
|
|
723
|
+
const a = new Set(t.expectedRoleFieldIds[s] ?? []), i = Object.keys(e.byRole[s] ?? {});
|
|
724
|
+
if (i.length !== a.size || i.some((c) => !a.has(c)))
|
|
725
|
+
throw new l(
|
|
726
|
+
`The role-scoped ${s} bindings do not match the authored result fields.`
|
|
727
|
+
);
|
|
728
|
+
}
|
|
729
|
+
const o = new Set(t.expectedMetricAliases), r = Object.keys(e.byMetricAlias ?? {});
|
|
730
|
+
if (r.length !== o.size || r.some((s) => !o.has(s)))
|
|
731
|
+
throw new l(
|
|
732
|
+
"The metric-alias bindings do not match the authored metric instances."
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
function Fe(e) {
|
|
736
|
+
if (!Array.isArray(e) || e.some(
|
|
737
|
+
(t) => !t || typeof t != "object" || Array.isArray(t)
|
|
738
|
+
))
|
|
739
|
+
throw new l(
|
|
740
|
+
"Canonical pivot records must be an array of row objects."
|
|
741
|
+
);
|
|
742
|
+
return e;
|
|
743
|
+
}
|
|
744
|
+
function Pe(e, t) {
|
|
745
|
+
e.forEach((n, o) => {
|
|
746
|
+
t.forEach((r) => {
|
|
747
|
+
if (!Object.prototype.hasOwnProperty.call(n, r.key) || n[r.key] === void 0)
|
|
748
|
+
throw new l(
|
|
749
|
+
`Canonical pivot column "${r.key}" is absent from row ${o}.`
|
|
750
|
+
);
|
|
751
|
+
});
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
function Ke(e, t, n) {
|
|
755
|
+
const o = new Set(t.map((r) => r.key));
|
|
756
|
+
["groupby", "detail"].forEach((r) => {
|
|
757
|
+
Object.entries(e.byRole[r] ?? {}).forEach(
|
|
758
|
+
([s, a]) => {
|
|
759
|
+
const i = a.outputKey || a.rawKey;
|
|
760
|
+
if (!o.has(i) || n.columnKinds[i] !== "row")
|
|
761
|
+
throw new l(
|
|
762
|
+
`The role-scoped ${r} binding for "${s}" does not name an authoritative result column.`
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
);
|
|
766
|
+
});
|
|
767
|
+
}
|
|
768
|
+
function E(e, t) {
|
|
769
|
+
t.forEach((n) => {
|
|
770
|
+
const o = e.columnKinds[n.key];
|
|
771
|
+
if (o === "pivot_metric" && n.pivotIdentity === void 0)
|
|
772
|
+
throw new l(
|
|
773
|
+
`Physical pivot result column "${n.key}" is missing its identity.`
|
|
774
|
+
);
|
|
775
|
+
if (o !== "pivot_metric" && n.pivotIdentity !== void 0)
|
|
776
|
+
throw new l(
|
|
777
|
+
`Canonical pivot result column "${n.key}" carries pivot identity outside the physical pivot projection.`
|
|
778
|
+
);
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
function Oe(e) {
|
|
782
|
+
const t = Fe(e.records), n = je(e.columns), o = Ee(
|
|
783
|
+
e.pivotResultContract,
|
|
784
|
+
n
|
|
785
|
+
), r = o.expectedRoleFieldIds.pivotby ?? [];
|
|
786
|
+
if (e.pivotResultState === "loaded_empty") {
|
|
787
|
+
if (t.length !== 0)
|
|
788
|
+
throw new l(
|
|
789
|
+
"A loaded_empty pivot result cannot carry records."
|
|
790
|
+
);
|
|
791
|
+
if (n.some(
|
|
792
|
+
(c) => o.columnKinds[c.key] === "pivot_metric"
|
|
793
|
+
))
|
|
794
|
+
throw new l(
|
|
795
|
+
"A loaded_empty pivot result cannot carry physical pivot columns."
|
|
796
|
+
);
|
|
797
|
+
E(o, n);
|
|
798
|
+
const i = $(e.columnKeyMap);
|
|
799
|
+
return k(i, o), {
|
|
800
|
+
pivotResultState: "loaded_empty",
|
|
801
|
+
records: [],
|
|
802
|
+
columns: n,
|
|
803
|
+
columnKeyMap: i,
|
|
804
|
+
pivotResultContract: o
|
|
805
|
+
};
|
|
806
|
+
}
|
|
807
|
+
if (e.pivotResultState !== "loaded_valid")
|
|
808
|
+
throw new l(
|
|
809
|
+
"A canonical pivot result must declare loaded_empty or loaded_valid."
|
|
810
|
+
);
|
|
811
|
+
if (t.length === 0)
|
|
812
|
+
throw new l(
|
|
813
|
+
"A loaded_valid pivot result must carry at least one record."
|
|
814
|
+
);
|
|
815
|
+
const s = $(e.columnKeyMap);
|
|
816
|
+
k(s, o), Ke(s, n, o), E(o, n);
|
|
817
|
+
const a = n.filter(
|
|
818
|
+
(i) => o.columnKinds[i.key] === "pivot_metric"
|
|
819
|
+
);
|
|
820
|
+
if (r.length > 0 && a.length === 0)
|
|
821
|
+
throw new l(
|
|
822
|
+
"A loaded_valid pivot result is missing its physical pivot columns."
|
|
823
|
+
);
|
|
824
|
+
try {
|
|
825
|
+
ee(a, {
|
|
826
|
+
expectedPivotFieldIds: r,
|
|
827
|
+
columnClassifications: o.columnClassifications
|
|
828
|
+
});
|
|
829
|
+
} catch (i) {
|
|
830
|
+
throw i instanceof te ? new l(i.message, i) : i;
|
|
831
|
+
}
|
|
832
|
+
return Pe(t, n), {
|
|
833
|
+
pivotResultState: "loaded_valid",
|
|
834
|
+
records: t,
|
|
835
|
+
columns: n,
|
|
836
|
+
columnKeyMap: s,
|
|
837
|
+
pivotResultContract: o
|
|
838
|
+
};
|
|
839
|
+
}
|
|
840
|
+
function at(e) {
|
|
841
|
+
const t = /* @__PURE__ */ new Set();
|
|
842
|
+
["groupby", "detail"].forEach((s) => {
|
|
843
|
+
Object.values(e.columnKeyMap.byRole[s] ?? {}).forEach((a) => {
|
|
844
|
+
t.add(a.outputKey || a.rawKey);
|
|
845
|
+
});
|
|
846
|
+
});
|
|
847
|
+
const n = new Set(e.physicalPivotColumnKeys), o = new Set(
|
|
848
|
+
e.columns.map((s) => s.key)
|
|
849
|
+
), r = {
|
|
850
|
+
version: 1,
|
|
851
|
+
expectedRoleFieldIds: {
|
|
852
|
+
groupby: Array.from(
|
|
853
|
+
new Set(e.expectedRoleFieldIds.groupby ?? [])
|
|
854
|
+
),
|
|
855
|
+
metric: Array.from(
|
|
856
|
+
new Set(e.expectedRoleFieldIds.metric ?? [])
|
|
857
|
+
),
|
|
858
|
+
pivotby: Array.from(
|
|
859
|
+
new Set(e.expectedRoleFieldIds.pivotby ?? [])
|
|
860
|
+
),
|
|
861
|
+
detail: Array.from(
|
|
862
|
+
new Set(e.expectedRoleFieldIds.detail ?? [])
|
|
863
|
+
)
|
|
864
|
+
},
|
|
865
|
+
expectedMetricAliases: [...e.expectedMetricAliases ?? []],
|
|
866
|
+
columnKinds: Object.fromEntries(
|
|
867
|
+
e.columns.map((s) => [
|
|
868
|
+
s.key,
|
|
869
|
+
t.has(s.key) ? "row" : n.has(s.key) ? "pivot_metric" : "value"
|
|
870
|
+
])
|
|
871
|
+
),
|
|
872
|
+
columnClassifications: Object.fromEntries(
|
|
873
|
+
Object.entries(e.columnMetadata ?? {}).filter(
|
|
874
|
+
([s]) => o.has(s)
|
|
875
|
+
)
|
|
876
|
+
)
|
|
877
|
+
};
|
|
878
|
+
return Oe({
|
|
879
|
+
pivotResultState: e.records.length === 0 ? "loaded_empty" : "loaded_valid",
|
|
880
|
+
pivotResultContract: r,
|
|
881
|
+
records: e.records,
|
|
882
|
+
columns: e.columns,
|
|
883
|
+
columnKeyMap: e.columnKeyMap
|
|
884
|
+
});
|
|
885
|
+
}
|
|
886
|
+
export {
|
|
887
|
+
Ie as A,
|
|
888
|
+
$e as P,
|
|
889
|
+
ze as a,
|
|
890
|
+
De as b,
|
|
891
|
+
l as c,
|
|
892
|
+
Le as d,
|
|
893
|
+
Se as e,
|
|
894
|
+
et as f,
|
|
895
|
+
at as g,
|
|
896
|
+
it as h,
|
|
897
|
+
Te as i,
|
|
898
|
+
rt as j,
|
|
899
|
+
ot as k,
|
|
900
|
+
_e as l,
|
|
901
|
+
xe as m,
|
|
902
|
+
Ye as n,
|
|
903
|
+
Je as o,
|
|
904
|
+
Qe as p,
|
|
905
|
+
S as q,
|
|
906
|
+
tt as r,
|
|
907
|
+
Oe as s,
|
|
908
|
+
K as t,
|
|
909
|
+
N as u,
|
|
910
|
+
st as v,
|
|
911
|
+
nt as w,
|
|
912
|
+
We as x,
|
|
913
|
+
de as y
|
|
914
|
+
};
|