react-semaphor 0.1.540 → 0.1.542
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/analytics-protocol/index.js +75 -75
- package/dist/assistant-context/index.js +1 -1
- package/dist/brand-studio/index.js +3 -3
- package/dist/briefings/index.js +50 -45
- package/dist/chunks/apply-dashboard-operations-Btbp2-6v.js +2260 -0
- package/dist/chunks/{assistant-chat-ya7xopaC.js → assistant-chat-oHF5lTjA.js} +12 -12
- package/dist/chunks/bookmark-state-CXw7lZ50.js +118 -0
- package/dist/chunks/{calendar-day-equality-Bpl15IBo.js → calendar-day-equality-BmJAWduY.js} +180 -207
- package/dist/chunks/comparison-window-caption-ChIyd_-L.js +1618 -0
- package/dist/chunks/custom-visual-inputs-DUtpYZOk.js +323 -0
- package/dist/chunks/{dashboard-briefing-launcher-DJI-zfEq.js → dashboard-briefing-launcher-B-cm719R.js} +18 -18
- package/dist/chunks/{dashboard-controls-Dh7HqoKy.js → dashboard-controls-CIn22Qgp.js} +69 -70
- package/dist/chunks/{dashboard-filter-value-compatibility-D95O4nd7.js → dashboard-filter-value-compatibility-CwQ_iSNb.js} +2 -2
- package/dist/chunks/{dashboard-json-BnmlB71h.js → dashboard-json-ZUYsIExq.js} +4 -4
- package/dist/chunks/{dashboard-B6Bithfl.js → dashboard-s5WJBcK8.js} +1 -1
- package/dist/chunks/{document-dashboard-inputs-BrYYlRVo.js → document-dashboard-inputs-C6MJVyoI.js} +2357 -4948
- package/dist/chunks/document-sheet-utils-BsZUnHRl.js +3619 -0
- package/dist/chunks/{edit-dashboard-visual-CydOkSko.js → edit-dashboard-visual-DLdereA7.js} +728 -728
- package/dist/chunks/{filter-value-text-BhWugPWE.js → filter-value-text-CYsVYPuD.js} +18 -19
- package/dist/chunks/index-CV5rHq5D.js +2673 -0
- package/dist/chunks/{matrix-analytical-definition-bcprSe4u.js → matrix-analytical-definition-C7Gb0e12.js} +1 -1
- package/dist/chunks/{matrix-card-CJn1hB5V.js → matrix-card-DjwWcCo8.js} +2 -2
- package/dist/chunks/{matrix-formatter-DQ8avoIQ.js → matrix-formatter-BnsTX90d.js} +430 -417
- package/dist/chunks/{matrix-member-presentation-BNPSDKBG.js → matrix-member-presentation-CQGdVks6.js} +1 -1
- package/dist/chunks/{matrix-operation-contract-B8PBF1Gd.js → matrix-operation-contract-8OIO4gob.js} +65 -65
- package/dist/chunks/metric-comparison-DEwi9uc2.js +498 -0
- package/dist/chunks/numeric-presentation-BSAqPpHt.js +5227 -0
- package/dist/chunks/{pivot-header-presentation-MkcKnjn3.js → pivot-header-presentation-DHcx1XGQ.js} +1 -1
- package/dist/chunks/{pivot-result-identity-D6hhcRXi.js → pivot-result-identity-DJhXXcns.js} +1 -1
- package/dist/chunks/pivot-result-lifecycle-BBlAfBA0.js +1155 -0
- package/dist/chunks/raw-temporal-presentation-CZ2r0Vb_.js +585 -0
- package/dist/chunks/{report-preferences-dialog-neMDolLg.js → report-preferences-dialog-MRUWpMcJ.js} +75 -75
- package/dist/chunks/{report-runtime-context-B984Nq1E.js → report-runtime-context-Dq8XyODK.js} +1 -1
- package/dist/chunks/{saved-dashboard-context-CCrLpfSQ.js → saved-dashboard-context-DjPqgFly.js} +233 -206
- package/dist/chunks/{selection-reducer-vKIb_jS6.js → selection-reducer-Dj_8xD69.js} +1 -1
- package/dist/chunks/{semaphor-ready-indicator--4DWtVBu.js → semaphor-ready-indicator-BWSpRsPj.js} +38555 -40449
- package/dist/chunks/{shelf-drop-preview-context-CpdB5ois.js → shelf-drop-preview-context-CQbFLm3q.js} +6 -6
- package/dist/chunks/sort-target-MT1WK1vX.js +29 -0
- package/dist/chunks/{source-entity-resolution-CVA1a85c.js → source-entity-resolution-BYn9giz3.js} +1 -1
- package/dist/chunks/{switch-DWEWiv1J.js → switch-C3jLxlG0.js} +2 -2
- package/dist/chunks/table-export-sheet-BHSnuZHd.js +949 -0
- package/dist/chunks/table-settings-CLZocegs.js +501 -0
- package/dist/chunks/temporal-bucket-D7NBrrtL.js +2071 -0
- package/dist/chunks/{token-types-bxUxXDX2.js → token-types-DBbZVQsm.js} +1 -1
- package/dist/chunks/{use-create-flow-overlay-state-8g6Zhphh.js → use-create-flow-overlay-state-BJDNqdOh.js} +151 -151
- package/dist/chunks/{validators-Ej1DdCXa.js → validators-DMHTpf7a.js} +73 -73
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.js +399 -380
- package/dist/data-app-sdk/index.js +5 -5
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.js +9 -9
- package/dist/format-utils/index.js +346 -238
- package/dist/index.js +174 -175
- package/dist/pdf-export-policy/index.js +20 -10
- package/dist/report-runtime-context/index.js +1 -1
- package/dist/surfboard/index.js +2 -2
- package/dist/types/briefings/attachment-outcomes.d.ts +23 -0
- package/dist/types/briefings/attachments.d.ts +17 -1
- package/dist/types/briefings/index.d.ts +6 -3
- package/dist/types/index.js +48 -48
- package/dist/types/lib/api/exports-api.d.ts +11 -65
- package/dist/types/lib/dashboard-inputs/control-contract-overrides.d.ts +17 -0
- package/dist/types/lib/dashboard-viewer/export-table-view.d.ts +2 -0
- package/dist/types/lib/hooks/use-dashboard-card.d.ts +2 -0
- package/dist/types/lib/hooks/use-dashboard.d.ts +3 -6
- package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +8 -2
- package/dist/types/lib/matrix-table/matrix-delivery.d.ts +8 -6
- package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +50 -0
- package/dist/types/lib/query-context/card-server-request.d.ts +5 -1
- package/dist/types/lib/types/common-types.d.ts +7 -0
- package/dist/types/lib/types/explorer-types.d.ts +8 -2
- package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +3 -3
- package/dist/types/shared/assistant-context/index.d.ts +1 -1
- package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +23 -6
- package/dist/types/shared/dashboard-authoring/card-export-request.d.ts +173 -0
- package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +20 -0
- package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
- package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +4 -3
- package/dist/types/shared/format-utils/attachment-filter-line.d.ts +14 -0
- package/dist/types/shared/format-utils/exporters/export-cells.d.ts +90 -0
- package/dist/types/shared/format-utils/exporters/export-file-format.d.ts +44 -0
- package/dist/types/shared/format-utils/exporters/index.d.ts +6 -0
- package/dist/types/shared/format-utils/exporters/xlsx-file.d.ts +90 -0
- package/dist/types/shared/format-utils/filter-line.d.ts +7 -0
- package/dist/types/shared/format-utils/formatters/date-formatter.d.ts +8 -12
- package/dist/types/shared/format-utils/formatters/index.d.ts +1 -1
- package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +2 -0
- package/dist/types/shared/format-utils/index.d.ts +3 -0
- package/dist/types/shared/format-utils/matrix-continuation.d.ts +55 -9
- package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +21 -1
- package/dist/types/shared/format-utils/matrix-export-xlsx.d.ts +27 -0
- package/dist/types/shared/format-utils/pdf-export-policy.d.ts +9 -0
- package/dist/types/shared/format-utils/presentation-execution.d.ts +27 -2
- package/dist/types/shared/format-utils/raw-temporal.d.ts +8 -0
- package/dist/types/shared/format-utils/table-export/index.d.ts +8 -0
- package/dist/types/shared/format-utils/table-export/prepare-table-export.d.ts +50 -0
- package/dist/types/shared/format-utils/table-export/table-export-formatting.d.ts +47 -0
- package/dist/types/shared/format-utils/table-export/table-export-raw-temporal.d.ts +40 -0
- package/dist/types/shared/format-utils/table-export/table-export-result.d.ts +31 -0
- package/dist/types/shared/format-utils/table-export/table-export-sheet.d.ts +38 -0
- package/dist/types/shared/format-utils/temporal-bucket.d.ts +9 -0
- package/package.json +2 -1
- package/dist/chunks/aggregate-table-row-presentation-BjK9YfMI.js +0 -979
- package/dist/chunks/apply-dashboard-operations-C-iahGka.js +0 -402
- package/dist/chunks/bookmark-state-k7y5SNGf.js +0 -331
- package/dist/chunks/calculated-field-identity-DcBS2NPP.js +0 -2161
- package/dist/chunks/canonical-result-keys-CEQefvdO.js +0 -33
- package/dist/chunks/common-types-CUf03Htv.js +0 -288
- package/dist/chunks/csv-utils-GUfKyT1J.js +0 -56
- package/dist/chunks/custom-visual-inputs-BrUOIwln.js +0 -3288
- package/dist/chunks/document-sheet-utils-C1eEldxs.js +0 -1076
- package/dist/chunks/index-CqMiAkay.js +0 -3164
- package/dist/chunks/matrix-definition-DQDI2okF.js +0 -206
- package/dist/chunks/metric-comparison-CojWeLqx.js +0 -392
- package/dist/chunks/pivot-result-lifecycle-8qCDmpKc.js +0 -804
- package/dist/chunks/raw-temporal-D61lr48Y.js +0 -1464
- package/dist/chunks/temporal-bucket-D8JF7zKz.js +0 -575
- package/dist/chunks/temporal-bucket-contract-DaOajRC7.js +0 -108
|
@@ -0,0 +1,3619 @@
|
|
|
1
|
+
var jt = Object.defineProperty;
|
|
2
|
+
var Ut = (e, t, n) => t in e ? jt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
|
|
3
|
+
var qe = (e, t, n) => Ut(e, typeof t != "symbol" ? t + "" : t, n);
|
|
4
|
+
import { z as L, l as j, A as Q, ac as Gt, G as Te, a0 as Qt, R as Ht, T as Jt, al as Ve, u as st, a9 as Yt } from "./validators-DMHTpf7a.js";
|
|
5
|
+
import "./matrix-operation-contract-8OIO4gob.js";
|
|
6
|
+
import { S as _e } from "./analytics-base-schemas-BFAoRlkU.js";
|
|
7
|
+
import { ZodError as Wt } from "zod";
|
|
8
|
+
import { w as Xt, b as Zt, o as en, r as ie, ak as tn, al as nn, am as lt, s as rn, ag as ct, an as on, ah as an, $ as ut, af as dt, n as sn, ao as ln, V as mt, X as ft, C as cn, _ as un, Y as je, Z as dn, H as mn, F as fn, U as pn, R as yn } from "./numeric-presentation-BSAqPpHt.js";
|
|
9
|
+
import { canonicalizeSupportedCurrencyCode as pt } from "../value-format-preferences/index.js";
|
|
10
|
+
import { F as gn, n as bn, q as hn, t as q, p as yt, C as he } from "./table-settings-CLZocegs.js";
|
|
11
|
+
import { q as Cn, s as gt, t as pe, f as Y, D as vn, u as te, v as In } from "./matrix-formatter-BnsTX90d.js";
|
|
12
|
+
import { i as re } from "./temporal-bucket-D7NBrrtL.js";
|
|
13
|
+
import { i as Fn, a as bt } from "./matrix-card-DjwWcCo8.js";
|
|
14
|
+
import { Z as Tn, S as _n } from "./pivot-result-lifecycle-BBlAfBA0.js";
|
|
15
|
+
import { s as w } from "./stable-serialize-CfqXeiBP.js";
|
|
16
|
+
import { g as xn } from "./matrix-analytical-definition-C7Gb0e12.js";
|
|
17
|
+
import { D as Sn, C as xe, r as E } from "./metric-comparison-DEwi9uc2.js";
|
|
18
|
+
import { f as Dn, s as Mn } from "./sort-target-MT1WK1vX.js";
|
|
19
|
+
import { r as Pn } from "./pivot-result-identity-DJhXXcns.js";
|
|
20
|
+
import { p as Kn } from "./pivot-header-presentation-DHcx1XGQ.js";
|
|
21
|
+
import { isPdfTableCardType as kn, FAST_PDF_POLICY as Bn } from "../pdf-export-policy/index.js";
|
|
22
|
+
const An = (e, t) => {
|
|
23
|
+
const n = {};
|
|
24
|
+
if (e === null || t === null)
|
|
25
|
+
return t;
|
|
26
|
+
const i = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
|
|
27
|
+
for (const r of i) {
|
|
28
|
+
if (!(r in e) && r in t) {
|
|
29
|
+
n[r] = t[r];
|
|
30
|
+
continue;
|
|
31
|
+
}
|
|
32
|
+
if (r in e && !(r in t)) {
|
|
33
|
+
n[r] = void 0;
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const o = e[r], a = t[r];
|
|
37
|
+
if (!Ce(o, a))
|
|
38
|
+
if (Array.isArray(o) && Array.isArray(a))
|
|
39
|
+
n[r] = a;
|
|
40
|
+
else if (Ue(o) && Ue(a)) {
|
|
41
|
+
const s = An(o, a);
|
|
42
|
+
Object.keys(s).length > 0 && (n[r] = s);
|
|
43
|
+
} else
|
|
44
|
+
n[r] = a;
|
|
45
|
+
}
|
|
46
|
+
return n;
|
|
47
|
+
}, Ce = (e, t) => {
|
|
48
|
+
if (e === t) return !0;
|
|
49
|
+
if (e && t && typeof e == "object" && typeof t == "object") {
|
|
50
|
+
if (Array.isArray(e) && Array.isArray(t))
|
|
51
|
+
return e.length !== t.length ? !1 : e.every((r, o) => Ce(r, t[o]));
|
|
52
|
+
const n = Object.keys(e), i = Object.keys(t);
|
|
53
|
+
return n.length !== i.length ? !1 : n.every((r) => Ce(e[r], t[r]));
|
|
54
|
+
}
|
|
55
|
+
return !1;
|
|
56
|
+
}, Ue = (e) => e !== null && typeof e == "object" && !Array.isArray(e), Ge = (e) => {
|
|
57
|
+
if (e === null || typeof e != "object")
|
|
58
|
+
return e;
|
|
59
|
+
if (e instanceof Date)
|
|
60
|
+
return new Date(e);
|
|
61
|
+
if (e instanceof RegExp)
|
|
62
|
+
return new RegExp(e);
|
|
63
|
+
if (Array.isArray(e))
|
|
64
|
+
return e.map((n) => Ge(n));
|
|
65
|
+
const t = {};
|
|
66
|
+
for (const n in e)
|
|
67
|
+
Object.prototype.hasOwnProperty.call(e, n) && (t[n] = Ge(e[n]));
|
|
68
|
+
return t;
|
|
69
|
+
}, Qe = /\[\[\s*param\.([A-Za-z0-9_.-]+)\s*\]\]/g, He = /\bparam\s*\(\s*(['"])([^'"]+)\1/g;
|
|
70
|
+
function wn(e) {
|
|
71
|
+
const t = [];
|
|
72
|
+
let n = 0;
|
|
73
|
+
for (; n < e.length; ) {
|
|
74
|
+
const i = e.indexOf("{{", n), r = e.indexOf("{%", n);
|
|
75
|
+
let o = -1, a = "";
|
|
76
|
+
if (i === -1 ? (o = r, a = "%}") : r === -1 || i < r ? (o = i, a = "}}") : (o = r, a = "%}"), o === -1)
|
|
77
|
+
break;
|
|
78
|
+
const s = e.indexOf(a, o + 2);
|
|
79
|
+
if (s === -1) {
|
|
80
|
+
n = o + 2;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
t.push(e.slice(o + 2, s)), n = s + 2;
|
|
84
|
+
}
|
|
85
|
+
return t;
|
|
86
|
+
}
|
|
87
|
+
function ht(e) {
|
|
88
|
+
var i, r;
|
|
89
|
+
if (!e)
|
|
90
|
+
return [];
|
|
91
|
+
const t = /* @__PURE__ */ new Set();
|
|
92
|
+
let n;
|
|
93
|
+
for (Qe.lastIndex = 0; (n = Qe.exec(e)) !== null; ) {
|
|
94
|
+
const o = (i = n[1]) == null ? void 0 : i.trim();
|
|
95
|
+
o && t.add(o);
|
|
96
|
+
}
|
|
97
|
+
for (const o of wn(e))
|
|
98
|
+
for (He.lastIndex = 0; (n = He.exec(o)) !== null; ) {
|
|
99
|
+
const a = (r = n[2]) == null ? void 0 : r.trim();
|
|
100
|
+
a && t.add(a);
|
|
101
|
+
}
|
|
102
|
+
return Array.from(t);
|
|
103
|
+
}
|
|
104
|
+
function Ct(e) {
|
|
105
|
+
const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
|
|
106
|
+
for (const i of e.controlBindings || [])
|
|
107
|
+
t.add(i.controlId), i.target === "sql_param" && n.set(i.paramId, i.controlId);
|
|
108
|
+
for (const i of ht(e.sql))
|
|
109
|
+
t.add(n.get(i) ?? i);
|
|
110
|
+
return Array.from(t);
|
|
111
|
+
}
|
|
112
|
+
function $r(e) {
|
|
113
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
114
|
+
for (const i of e.controlBindings || [])
|
|
115
|
+
i.target === "sql_param" && n.set(i.paramId, i.controlId);
|
|
116
|
+
for (const i of ht(e.sql))
|
|
117
|
+
t.set(i, {
|
|
118
|
+
paramId: i,
|
|
119
|
+
controlId: n.get(i) ?? i
|
|
120
|
+
});
|
|
121
|
+
return Array.from(t.values());
|
|
122
|
+
}
|
|
123
|
+
function be(e) {
|
|
124
|
+
return (e == null ? void 0 : e.trim()) || void 0;
|
|
125
|
+
}
|
|
126
|
+
function Je(e) {
|
|
127
|
+
return e.split(".").at(-1) || e;
|
|
128
|
+
}
|
|
129
|
+
function Ye(e, t) {
|
|
130
|
+
var c, l;
|
|
131
|
+
const n = be(t);
|
|
132
|
+
if (!n) return;
|
|
133
|
+
const i = Je(n), r = be((c = e.fieldMeta) == null ? void 0 : c.name);
|
|
134
|
+
if (r && r !== n && r !== i)
|
|
135
|
+
return;
|
|
136
|
+
const o = be(
|
|
137
|
+
(l = e.fieldMeta) == null ? void 0 : l.qualifiedFieldName
|
|
138
|
+
);
|
|
139
|
+
if (o && Je(o) !== i)
|
|
140
|
+
return;
|
|
141
|
+
const a = n.includes(".") ? n : void 0, s = o != null && o.includes(".") ? o : void 0;
|
|
142
|
+
if (!(a && s && a !== s))
|
|
143
|
+
return {
|
|
144
|
+
leafName: i,
|
|
145
|
+
...a || s ? {
|
|
146
|
+
qualifiedFieldName: a || s
|
|
147
|
+
} : {}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
function We(e, t) {
|
|
151
|
+
return Ye(e, t) || Ye({}, t);
|
|
152
|
+
}
|
|
153
|
+
function Xe({
|
|
154
|
+
source: e,
|
|
155
|
+
sourceFieldName: t,
|
|
156
|
+
target: n,
|
|
157
|
+
targetFieldName: i
|
|
158
|
+
}) {
|
|
159
|
+
const r = We(
|
|
160
|
+
e,
|
|
161
|
+
t
|
|
162
|
+
), o = We(
|
|
163
|
+
n,
|
|
164
|
+
i
|
|
165
|
+
);
|
|
166
|
+
return !r || !o || r.leafName !== o.leafName ? !1 : o.qualifiedFieldName ? r.qualifiedFieldName === o.qualifiedFieldName : !0;
|
|
167
|
+
}
|
|
168
|
+
function me(e, t) {
|
|
169
|
+
var r, o;
|
|
170
|
+
const n = On(e);
|
|
171
|
+
if (n) return n;
|
|
172
|
+
const i = (o = (r = e == null ? void 0 : e.fieldMeta) == null ? void 0 : r.nativeDataType) == null ? void 0 : o.trim();
|
|
173
|
+
if (Se(e == null ? void 0 : e.fieldMeta, t) && i && i !== "date" && i !== "datetime")
|
|
174
|
+
return i;
|
|
175
|
+
}
|
|
176
|
+
function On(e) {
|
|
177
|
+
var n;
|
|
178
|
+
const t = (n = e == null ? void 0 : e.nativeDataType) == null ? void 0 : n.trim();
|
|
179
|
+
return t && t !== "date" && t !== "datetime" ? t : void 0;
|
|
180
|
+
}
|
|
181
|
+
function Se(e, t) {
|
|
182
|
+
var a, s;
|
|
183
|
+
const n = t.trim();
|
|
184
|
+
if (!n) return !1;
|
|
185
|
+
const i = n.split(".").at(-1), r = (a = e == null ? void 0 : e.qualifiedFieldName) == null ? void 0 : a.trim();
|
|
186
|
+
if (r && !(r === n || !r.includes(".") && r === i))
|
|
187
|
+
return !1;
|
|
188
|
+
const o = (s = e == null ? void 0 : e.name) == null ? void 0 : s.trim();
|
|
189
|
+
return o && o !== n && o !== i ? !1 : !!(r || o);
|
|
190
|
+
}
|
|
191
|
+
function Nn({
|
|
192
|
+
fieldName: e,
|
|
193
|
+
definition: t,
|
|
194
|
+
value: n
|
|
195
|
+
}) {
|
|
196
|
+
if ((t == null ? void 0 : t.column) === e) {
|
|
197
|
+
const i = me(t, e);
|
|
198
|
+
if (i)
|
|
199
|
+
return i;
|
|
200
|
+
}
|
|
201
|
+
return (n == null ? void 0 : n.name) === e ? me(n, e) : void 0;
|
|
202
|
+
}
|
|
203
|
+
function En({
|
|
204
|
+
definition: e,
|
|
205
|
+
value: t,
|
|
206
|
+
sourceValue: n = t
|
|
207
|
+
}) {
|
|
208
|
+
const i = e && Xe({
|
|
209
|
+
source: e,
|
|
210
|
+
sourceFieldName: e.column,
|
|
211
|
+
target: t,
|
|
212
|
+
targetFieldName: t.name
|
|
213
|
+
}) ? e : void 0, r = n && Xe({
|
|
214
|
+
source: n,
|
|
215
|
+
sourceFieldName: n.name,
|
|
216
|
+
target: t,
|
|
217
|
+
targetFieldName: t.name
|
|
218
|
+
}) ? n : void 0, o = (i ? me(i, i.column) : void 0) || (r ? me(r, r.name) : void 0);
|
|
219
|
+
return vt({
|
|
220
|
+
carrier: t,
|
|
221
|
+
nativeDataType: o,
|
|
222
|
+
projectNestedNativeDataType: Se(
|
|
223
|
+
t.fieldMeta,
|
|
224
|
+
t.name
|
|
225
|
+
)
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
function Lr({
|
|
229
|
+
filterDefinitions: e,
|
|
230
|
+
filterValues: t
|
|
231
|
+
}) {
|
|
232
|
+
if (!(e != null && e.length) || !t.length)
|
|
233
|
+
return t;
|
|
234
|
+
const n = new Map(
|
|
235
|
+
e.map((o) => [o.id, o])
|
|
236
|
+
);
|
|
237
|
+
let i = !1;
|
|
238
|
+
const r = t.map((o) => {
|
|
239
|
+
if (typeof o.name != "string" || !o.name.trim())
|
|
240
|
+
return o;
|
|
241
|
+
const a = n.get(o.filterId);
|
|
242
|
+
if (!a)
|
|
243
|
+
return o;
|
|
244
|
+
const s = En({
|
|
245
|
+
definition: a,
|
|
246
|
+
value: o
|
|
247
|
+
});
|
|
248
|
+
return i || (i = s !== o), s;
|
|
249
|
+
});
|
|
250
|
+
return i ? r : t;
|
|
251
|
+
}
|
|
252
|
+
function zr(e) {
|
|
253
|
+
const t = Nn({
|
|
254
|
+
fieldName: e.column,
|
|
255
|
+
definition: e
|
|
256
|
+
});
|
|
257
|
+
return vt({
|
|
258
|
+
carrier: e,
|
|
259
|
+
nativeDataType: t,
|
|
260
|
+
projectNestedNativeDataType: Se(
|
|
261
|
+
e.fieldMeta,
|
|
262
|
+
e.column
|
|
263
|
+
)
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
function vt({
|
|
267
|
+
carrier: e,
|
|
268
|
+
nativeDataType: t,
|
|
269
|
+
projectNestedNativeDataType: n
|
|
270
|
+
}) {
|
|
271
|
+
var l;
|
|
272
|
+
const i = (l = e.fieldMeta) == null ? void 0 : l.nativeDataType;
|
|
273
|
+
if (t) {
|
|
274
|
+
if (e.nativeDataType === t && (!e.fieldMeta || (n ? i === t : !i)))
|
|
275
|
+
return e;
|
|
276
|
+
const { nativeDataType: u, ...m } = e.fieldMeta || {};
|
|
277
|
+
return {
|
|
278
|
+
...e,
|
|
279
|
+
nativeDataType: t,
|
|
280
|
+
...e.fieldMeta ? {
|
|
281
|
+
fieldMeta: n ? {
|
|
282
|
+
...e.fieldMeta,
|
|
283
|
+
nativeDataType: t
|
|
284
|
+
} : m
|
|
285
|
+
} : {}
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
if (e.nativeDataType === void 0 && i === void 0)
|
|
289
|
+
return e;
|
|
290
|
+
const {
|
|
291
|
+
nativeDataType: r,
|
|
292
|
+
fieldMeta: o,
|
|
293
|
+
...a
|
|
294
|
+
} = e, { nativeDataType: s, ...c } = o || {};
|
|
295
|
+
return {
|
|
296
|
+
...a,
|
|
297
|
+
...o ? { fieldMeta: c } : {}
|
|
298
|
+
};
|
|
299
|
+
}
|
|
300
|
+
function Ze(e) {
|
|
301
|
+
const t = /* @__PURE__ */ new Set();
|
|
302
|
+
for (const n of [e.name, e.sourceField]) {
|
|
303
|
+
if (!n) continue;
|
|
304
|
+
const i = L(n);
|
|
305
|
+
if (!i) continue;
|
|
306
|
+
t.add(i);
|
|
307
|
+
const r = i.split("."), o = r[r.length - 1];
|
|
308
|
+
o && t.add(o);
|
|
309
|
+
}
|
|
310
|
+
return t;
|
|
311
|
+
}
|
|
312
|
+
function It(e, t) {
|
|
313
|
+
const n = j(e), i = j(t);
|
|
314
|
+
return n === "unknown" || i === "unknown" ? !1 : (n === "date" || n === "datetime") && (i === "date" || i === "datetime") ? !0 : n === i;
|
|
315
|
+
}
|
|
316
|
+
function Rn(e, t) {
|
|
317
|
+
return Q(e.field.source, t.field.source) && L(e.field.name) === L(t.field.name) && L(e.field.sourceField || e.field.name) === L(t.field.sourceField || t.field.name);
|
|
318
|
+
}
|
|
319
|
+
function $n(e, t) {
|
|
320
|
+
if (e.kind !== "field") return !1;
|
|
321
|
+
const n = Ze(t), i = Ze(e.field);
|
|
322
|
+
return It(t.dataType, e.field.dataType) && [...i].some((r) => n.has(r));
|
|
323
|
+
}
|
|
324
|
+
function qr(e) {
|
|
325
|
+
const t = e.candidates.filter(
|
|
326
|
+
(n) => $n(
|
|
327
|
+
n,
|
|
328
|
+
e.logicalValueField
|
|
329
|
+
)
|
|
330
|
+
);
|
|
331
|
+
return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
|
|
332
|
+
}
|
|
333
|
+
function Vr(e) {
|
|
334
|
+
const t = [];
|
|
335
|
+
for (const n of e.acceptedTargets)
|
|
336
|
+
!It(
|
|
337
|
+
e.logicalValueField.dataType,
|
|
338
|
+
n.field.dataType
|
|
339
|
+
) || t.some(
|
|
340
|
+
(i) => Rn(i, n)
|
|
341
|
+
) || t.push(n);
|
|
342
|
+
return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
|
|
343
|
+
}
|
|
344
|
+
function Ln(e) {
|
|
345
|
+
return (e.field.sourceField || e.field.name).trim() || void 0;
|
|
346
|
+
}
|
|
347
|
+
function jr(e) {
|
|
348
|
+
if (e.inventory.kind !== "sql" || e.target.kind !== "field")
|
|
349
|
+
return { status: "ineligible" };
|
|
350
|
+
const t = Xt(
|
|
351
|
+
e.inventory,
|
|
352
|
+
e.target.field.source
|
|
353
|
+
), n = Ln(e.target);
|
|
354
|
+
if (!t || !n) return { status: "ineligible" };
|
|
355
|
+
if (t.executionTable) {
|
|
356
|
+
const a = [
|
|
357
|
+
t.executionTable.databaseName,
|
|
358
|
+
t.executionTable.schemaName,
|
|
359
|
+
t.executionTable.tableName,
|
|
360
|
+
n
|
|
361
|
+
].filter(Boolean).join(".");
|
|
362
|
+
return {
|
|
363
|
+
status: "eligible",
|
|
364
|
+
source: t.source,
|
|
365
|
+
executionIdentifier: a
|
|
366
|
+
};
|
|
367
|
+
}
|
|
368
|
+
if (e.inventory.pinnedCatalogSources.length !== 1)
|
|
369
|
+
return { status: "ineligible" };
|
|
370
|
+
const i = L(n), r = (e.candidateTargets || []).filter(
|
|
371
|
+
(a) => L(
|
|
372
|
+
a.field.sourceField || a.field.name
|
|
373
|
+
) === i
|
|
374
|
+
), o = [];
|
|
375
|
+
for (const a of r)
|
|
376
|
+
o.some(
|
|
377
|
+
(s) => Q(s, a.field.source)
|
|
378
|
+
) || o.push(a.field.source);
|
|
379
|
+
return o.length > 1 ? { status: "ineligible" } : {
|
|
380
|
+
status: "eligible",
|
|
381
|
+
source: t.source,
|
|
382
|
+
executionIdentifier: n
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
const zn = Object.freeze({ mode: "all_applicable" });
|
|
386
|
+
function qn(e) {
|
|
387
|
+
if (e === void 0)
|
|
388
|
+
return { ok: !0, dependencies: { ...zn } };
|
|
389
|
+
const t = Gt(e, "dashboard");
|
|
390
|
+
if (!t.ok)
|
|
391
|
+
return {
|
|
392
|
+
ok: !1,
|
|
393
|
+
error: "Invalid dashboard option dependency policy.",
|
|
394
|
+
issues: t.errors.map((i) => i.message)
|
|
395
|
+
};
|
|
396
|
+
const n = e;
|
|
397
|
+
switch (n.mode) {
|
|
398
|
+
case "independent":
|
|
399
|
+
return { ok: !0, dependencies: { mode: "independent" } };
|
|
400
|
+
case "explicit":
|
|
401
|
+
return {
|
|
402
|
+
ok: !0,
|
|
403
|
+
dependencies: {
|
|
404
|
+
mode: "explicit",
|
|
405
|
+
includeInputIds: [...n.includeInputIds || []]
|
|
406
|
+
}
|
|
407
|
+
};
|
|
408
|
+
case "all_applicable":
|
|
409
|
+
return {
|
|
410
|
+
ok: !0,
|
|
411
|
+
dependencies: {
|
|
412
|
+
mode: "all_applicable",
|
|
413
|
+
...n.excludeInputIds ? { excludeInputIds: [...n.excludeInputIds] } : {}
|
|
414
|
+
}
|
|
415
|
+
};
|
|
416
|
+
default:
|
|
417
|
+
return {
|
|
418
|
+
ok: !1,
|
|
419
|
+
error: "Invalid dashboard option dependency policy.",
|
|
420
|
+
issues: ["Dashboard option dependencies must declare a mode."]
|
|
421
|
+
};
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
function Vn(e) {
|
|
425
|
+
if (e === void 0) return { ok: !0, population: void 0 };
|
|
426
|
+
const t = { ok: !1, error: "Invalid option population." };
|
|
427
|
+
if (!e || typeof e != "object" || Array.isArray(e)) return t;
|
|
428
|
+
const n = e;
|
|
429
|
+
if (n.kind === "option_source")
|
|
430
|
+
return { ok: !0, population: { kind: "option_source" } };
|
|
431
|
+
if (n.kind !== "related_population") return t;
|
|
432
|
+
const i = n.baseSource;
|
|
433
|
+
if (!i || i.kind !== "semantic" || !Te(i))
|
|
434
|
+
return t;
|
|
435
|
+
const r = n.relationshipHint;
|
|
436
|
+
return r !== void 0 && (!r || typeof r != "object" || r.relationshipIds !== void 0 && (!Array.isArray(r.relationshipIds) || r.relationshipIds.some(
|
|
437
|
+
(o) => typeof o != "string" || !o.trim()
|
|
438
|
+
))) ? t : {
|
|
439
|
+
ok: !0,
|
|
440
|
+
population: {
|
|
441
|
+
kind: "related_population",
|
|
442
|
+
baseSource: i,
|
|
443
|
+
...r ? { relationshipHint: r } : {}
|
|
444
|
+
}
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
function Ur(e) {
|
|
448
|
+
const { dependencies: t } = e, n = /* @__PURE__ */ new Set([
|
|
449
|
+
e.targetInputId,
|
|
450
|
+
...t.excludeInputIds || []
|
|
451
|
+
]);
|
|
452
|
+
return t.mode === "independent" ? [] : t.mode === "explicit" ? (t.includeInputIds || []).filter(
|
|
453
|
+
(i) => !n.has(i)
|
|
454
|
+
) : e.peerInputIds.filter((i) => !n.has(i));
|
|
455
|
+
}
|
|
456
|
+
function Gr(e, t, n) {
|
|
457
|
+
if (t === n) return e;
|
|
458
|
+
let i = !1;
|
|
459
|
+
const r = (a) => a != null && a.includes(t) ? (i = !0, Array.from(
|
|
460
|
+
new Set(a.map((s) => s === t ? n : s))
|
|
461
|
+
)) : a, o = e.map((a) => {
|
|
462
|
+
const s = a.optionDependencies;
|
|
463
|
+
if (!s) return a;
|
|
464
|
+
const c = r(s.includeInputIds), l = r(s.excludeInputIds);
|
|
465
|
+
return c === s.includeInputIds && l === s.excludeInputIds ? a : {
|
|
466
|
+
...a,
|
|
467
|
+
optionDependencies: {
|
|
468
|
+
...s,
|
|
469
|
+
...c ? { includeInputIds: c } : {},
|
|
470
|
+
...l ? { excludeInputIds: l } : {}
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
});
|
|
474
|
+
return i ? o : e;
|
|
475
|
+
}
|
|
476
|
+
function Qr(e, t) {
|
|
477
|
+
const n = jn(
|
|
478
|
+
e.dependencies,
|
|
479
|
+
t
|
|
480
|
+
);
|
|
481
|
+
return n === e.dependencies ? e : { ...e, dependencies: n };
|
|
482
|
+
}
|
|
483
|
+
function jn(e, t) {
|
|
484
|
+
if (!(t != null && t.length) || e.mode !== "explicit")
|
|
485
|
+
return e;
|
|
486
|
+
const n = new Set(e.includeInputIds || []), i = Array.from(new Set(t)).filter(
|
|
487
|
+
(r) => n.has(r)
|
|
488
|
+
);
|
|
489
|
+
return i.length ? { ...e, omitInputIds: i } : e;
|
|
490
|
+
}
|
|
491
|
+
class Un extends Error {
|
|
492
|
+
constructor(n) {
|
|
493
|
+
super(n.map((i) => i.message).join(" "));
|
|
494
|
+
qe(this, "issues");
|
|
495
|
+
this.name = "DashboardFilterMappingContractError", this.issues = n;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
const Gn = {
|
|
499
|
+
string: !0,
|
|
500
|
+
number: !0,
|
|
501
|
+
boolean: !0,
|
|
502
|
+
date: !0,
|
|
503
|
+
datetime: !0
|
|
504
|
+
};
|
|
505
|
+
function k(e) {
|
|
506
|
+
return typeof e == "string" && e.trim().length > 0;
|
|
507
|
+
}
|
|
508
|
+
function P(e) {
|
|
509
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
510
|
+
}
|
|
511
|
+
function ue(e) {
|
|
512
|
+
return Array.isArray(e) && e.every((t) => typeof t == "string");
|
|
513
|
+
}
|
|
514
|
+
function Qn(e) {
|
|
515
|
+
if (!P(e)) return !1;
|
|
516
|
+
switch (e.kind) {
|
|
517
|
+
case "allSheets":
|
|
518
|
+
return e.sheetKinds === void 0 || ue(e.sheetKinds) && e.sheetKinds.every(
|
|
519
|
+
(t) => t === "dashboard" || t === "document"
|
|
520
|
+
);
|
|
521
|
+
case "sheets":
|
|
522
|
+
return ue(e.sheetIds);
|
|
523
|
+
case "cards":
|
|
524
|
+
return ue(e.cardIds);
|
|
525
|
+
case "documentSections":
|
|
526
|
+
return k(e.sheetId) && ue(e.sectionIds);
|
|
527
|
+
default:
|
|
528
|
+
return !1;
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
function Hn(e) {
|
|
532
|
+
return e === "shared" || e === "perSheet" || e === "perCard" || e === "perDocumentSection";
|
|
533
|
+
}
|
|
534
|
+
function Jn(e) {
|
|
535
|
+
return P(e) ? k(e.id) && k(e.column) && k(e.dataType) : !1;
|
|
536
|
+
}
|
|
537
|
+
function Yn(e, t, n, i) {
|
|
538
|
+
var s;
|
|
539
|
+
if (!P(t)) {
|
|
540
|
+
i.push({
|
|
541
|
+
code: "invalid_option_source",
|
|
542
|
+
path: n,
|
|
543
|
+
message: `${n} must be a semantic or physical option source.`,
|
|
544
|
+
inputId: e
|
|
545
|
+
});
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const r = t.source, o = [
|
|
549
|
+
["labelField", t.labelField],
|
|
550
|
+
["valueField", t.valueField],
|
|
551
|
+
["searchField", t.searchField]
|
|
552
|
+
];
|
|
553
|
+
if (!P(r) || r.kind !== "semantic" && r.kind !== "physical" || !Te(r) || !P(t.labelField) || !P(t.valueField) || t.searchField !== void 0 && !P(t.searchField) || t.disambiguationFields !== void 0 && (!Array.isArray(t.disambiguationFields) || !t.disambiguationFields.every(P))) {
|
|
554
|
+
i.push({
|
|
555
|
+
code: "invalid_option_source",
|
|
556
|
+
path: n,
|
|
557
|
+
message: `${n} must contain a valid semantic or physical source and field references.`,
|
|
558
|
+
inputId: e
|
|
559
|
+
});
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
for (const [c, l] of o)
|
|
563
|
+
l !== void 0 && P(l) && (!k(l.name) || l.source !== void 0 && !Q(
|
|
564
|
+
l.source,
|
|
565
|
+
r
|
|
566
|
+
)) && i.push({
|
|
567
|
+
code: "invalid_option_source",
|
|
568
|
+
path: `${n}.${c}`,
|
|
569
|
+
message: `${n}.${c} must be a named field belonging to the declared option source.`,
|
|
570
|
+
inputId: e
|
|
571
|
+
});
|
|
572
|
+
for (const [c, l] of ((s = t.disambiguationFields) == null ? void 0 : s.entries()) || [])
|
|
573
|
+
(!P(l) || !k(l.name) || l.source !== void 0 && !Q(
|
|
574
|
+
l.source,
|
|
575
|
+
r
|
|
576
|
+
)) && i.push({
|
|
577
|
+
code: "invalid_option_source",
|
|
578
|
+
path: `${n}.disambiguationFields[${c}]`,
|
|
579
|
+
message: `${n}.disambiguationFields[${c}] must be a named field belonging to the declared option source.`,
|
|
580
|
+
inputId: e
|
|
581
|
+
});
|
|
582
|
+
const a = t.valueField;
|
|
583
|
+
["string", "number", "boolean", "date", "datetime"].includes(
|
|
584
|
+
String(a.dataType)
|
|
585
|
+
) || i.push({
|
|
586
|
+
code: "invalid_option_source",
|
|
587
|
+
path: `${n}.valueField.dataType`,
|
|
588
|
+
message: `${n}.valueField.dataType must be a known option-value datatype.`,
|
|
589
|
+
inputId: e
|
|
590
|
+
});
|
|
591
|
+
}
|
|
592
|
+
function Wn(e, t, n) {
|
|
593
|
+
var i;
|
|
594
|
+
if (e.optionDependencies !== void 0) {
|
|
595
|
+
const r = qn(e.optionDependencies);
|
|
596
|
+
r.ok ? P(e.optionDependencies) && e.optionDependencies.omitInputIds !== void 0 && n.push({
|
|
597
|
+
code: "invalid_option_dependencies",
|
|
598
|
+
path: `${t}.optionDependencies.omitInputIds`,
|
|
599
|
+
message: `${t}.optionDependencies cannot persist a browse override (omitInputIds).`,
|
|
600
|
+
inputId: e.id
|
|
601
|
+
}) : n.push({
|
|
602
|
+
code: "invalid_option_dependencies",
|
|
603
|
+
path: `${t}.optionDependencies`,
|
|
604
|
+
message: `${t}.optionDependencies ${r.issues.join("; ") || r.error}`,
|
|
605
|
+
inputId: e.id
|
|
606
|
+
});
|
|
607
|
+
}
|
|
608
|
+
if (e.optionPopulation !== void 0) {
|
|
609
|
+
const r = Vn(e.optionPopulation);
|
|
610
|
+
r.ok ? ((i = r.population) == null ? void 0 : i.kind) === "related_population" && !Xn(e.optionSource) && n.push({
|
|
611
|
+
code: "invalid_option_population",
|
|
612
|
+
path: `${t}.optionPopulation`,
|
|
613
|
+
message: `${t}.optionPopulation related_population requires an authored semantic optionSource.`,
|
|
614
|
+
inputId: e.id
|
|
615
|
+
}) : n.push({
|
|
616
|
+
code: "invalid_option_population",
|
|
617
|
+
path: `${t}.optionPopulation`,
|
|
618
|
+
message: `${t}.optionPopulation must be option_source or a related_population with a complete semantic baseSource.`,
|
|
619
|
+
inputId: e.id
|
|
620
|
+
});
|
|
621
|
+
}
|
|
622
|
+
}
|
|
623
|
+
function Xn(e) {
|
|
624
|
+
return P(e) && P(e.source) && e.source.kind === "semantic";
|
|
625
|
+
}
|
|
626
|
+
function Zn(e, t, n, i, r, o) {
|
|
627
|
+
var l;
|
|
628
|
+
if (k(t.bindingId) || r.push({
|
|
629
|
+
code: "invalid_binding_id",
|
|
630
|
+
path: `${n}.bindingId`,
|
|
631
|
+
message: `${n}.bindingId must be an opaque non-empty id.`,
|
|
632
|
+
inputId: e,
|
|
633
|
+
cardId: t.cardId
|
|
634
|
+
}), ((l = t.target) == null ? void 0 : l.kind) !== "field") {
|
|
635
|
+
r.push({
|
|
636
|
+
code: "unsupported_target",
|
|
637
|
+
path: `${n}.target`,
|
|
638
|
+
message: `${n}.target must be one direct field target.`,
|
|
639
|
+
inputId: e,
|
|
640
|
+
cardId: t.cardId,
|
|
641
|
+
bindingId: t.bindingId
|
|
642
|
+
});
|
|
643
|
+
return;
|
|
644
|
+
}
|
|
645
|
+
const a = t.target.field;
|
|
646
|
+
if (!k(a == null ? void 0 : a.name) || !a.source || a.source.kind !== "semantic" && a.source.kind !== "physical" || !Te(a.source)) {
|
|
647
|
+
r.push({
|
|
648
|
+
code: "invalid_target_field",
|
|
649
|
+
path: `${n}.target.field`,
|
|
650
|
+
message: `${n}.target.field must have a name and a source-qualified semantic or physical identity.`,
|
|
651
|
+
inputId: e,
|
|
652
|
+
cardId: t.cardId,
|
|
653
|
+
bindingId: t.bindingId
|
|
654
|
+
});
|
|
655
|
+
return;
|
|
656
|
+
}
|
|
657
|
+
if (Object.prototype.hasOwnProperty.call(
|
|
658
|
+
Gn,
|
|
659
|
+
a.dataType
|
|
660
|
+
) || r.push({
|
|
661
|
+
code: "unknown_target_data_type",
|
|
662
|
+
path: `${n}.target.field.dataType`,
|
|
663
|
+
message: `${n}.target.field.dataType must be known.`,
|
|
664
|
+
inputId: e,
|
|
665
|
+
cardId: t.cardId,
|
|
666
|
+
bindingId: t.bindingId
|
|
667
|
+
}), a.sourceField !== void 0 && !k(a.sourceField) && r.push({
|
|
668
|
+
code: "invalid_target_field",
|
|
669
|
+
path: `${n}.target.field.sourceField`,
|
|
670
|
+
message: `${n}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,
|
|
671
|
+
inputId: e,
|
|
672
|
+
cardId: t.cardId,
|
|
673
|
+
bindingId: t.bindingId
|
|
674
|
+
}), !o) return;
|
|
675
|
+
const s = i.get(t.cardId);
|
|
676
|
+
if (!s) {
|
|
677
|
+
r.push({
|
|
678
|
+
code: "unknown_card",
|
|
679
|
+
path: `${n}.cardId`,
|
|
680
|
+
message: `${n}.cardId '${t.cardId}' does not exist.`,
|
|
681
|
+
inputId: e,
|
|
682
|
+
cardId: t.cardId,
|
|
683
|
+
bindingId: t.bindingId
|
|
684
|
+
});
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
const c = Zt(s);
|
|
688
|
+
(c.kind === "unconfigured" || !en(c, a.source)) && r.push({
|
|
689
|
+
code: "unavailable_card_source",
|
|
690
|
+
path: `${n}.target.field.source`,
|
|
691
|
+
message: `${n}.target field source is not declared by card '${s.id}'.`,
|
|
692
|
+
inputId: e,
|
|
693
|
+
cardId: s.id,
|
|
694
|
+
bindingId: t.bindingId
|
|
695
|
+
});
|
|
696
|
+
}
|
|
697
|
+
function ei(e, t, n, i, r, o) {
|
|
698
|
+
if (t === void 0) return;
|
|
699
|
+
if (!P(t) || t.kind !== "cardMappings" || !Array.isArray(t.cards)) {
|
|
700
|
+
r.push({
|
|
701
|
+
code: "invalid_application",
|
|
702
|
+
path: n,
|
|
703
|
+
message: `${n} must be a cardMappings application with a cards array.`,
|
|
704
|
+
inputId: e
|
|
705
|
+
});
|
|
706
|
+
return;
|
|
707
|
+
}
|
|
708
|
+
const a = /* @__PURE__ */ new Set();
|
|
709
|
+
t.cards.forEach((s, c) => {
|
|
710
|
+
const l = `${n}.cards[${c}]`;
|
|
711
|
+
if (!k(s == null ? void 0 : s.cardId)) {
|
|
712
|
+
r.push({
|
|
713
|
+
code: "unknown_card",
|
|
714
|
+
path: `${l}.cardId`,
|
|
715
|
+
message: `${l}.cardId is required.`,
|
|
716
|
+
inputId: e
|
|
717
|
+
});
|
|
718
|
+
return;
|
|
719
|
+
}
|
|
720
|
+
if (a.has(s.cardId)) {
|
|
721
|
+
r.push({
|
|
722
|
+
code: "duplicate_card_application",
|
|
723
|
+
path: `${l}.cardId`,
|
|
724
|
+
message: `${n} contains more than one entry for card '${s.cardId}'.`,
|
|
725
|
+
inputId: e,
|
|
726
|
+
cardId: s.cardId
|
|
727
|
+
});
|
|
728
|
+
return;
|
|
729
|
+
}
|
|
730
|
+
if (a.add(s.cardId), o && !i.has(s.cardId)) {
|
|
731
|
+
r.push({
|
|
732
|
+
code: "unknown_card",
|
|
733
|
+
path: `${l}.cardId`,
|
|
734
|
+
message: `${l}.cardId '${s.cardId}' does not exist.`,
|
|
735
|
+
inputId: e,
|
|
736
|
+
cardId: s.cardId
|
|
737
|
+
});
|
|
738
|
+
return;
|
|
739
|
+
}
|
|
740
|
+
s.kind === "bound" ? Zn(
|
|
741
|
+
e,
|
|
742
|
+
s,
|
|
743
|
+
l,
|
|
744
|
+
i,
|
|
745
|
+
r,
|
|
746
|
+
o
|
|
747
|
+
) : s.kind !== "excluded" && r.push({
|
|
748
|
+
code: "invalid_application",
|
|
749
|
+
path: l,
|
|
750
|
+
message: `${l}.kind must be 'bound' or 'excluded'.`,
|
|
751
|
+
inputId: e,
|
|
752
|
+
cardId: s.cardId
|
|
753
|
+
});
|
|
754
|
+
});
|
|
755
|
+
}
|
|
756
|
+
function ti({
|
|
757
|
+
inputs: e,
|
|
758
|
+
dashboardFilters: t,
|
|
759
|
+
cards: n = [],
|
|
760
|
+
validateCardTargets: i = !1
|
|
761
|
+
}) {
|
|
762
|
+
const r = [], o = new Map(
|
|
763
|
+
(t || []).map((l) => [l.id, l])
|
|
764
|
+
), a = new Map(
|
|
765
|
+
i ? n.map((l) => [l.id, l]) : []
|
|
766
|
+
), s = [], c = /* @__PURE__ */ new Map();
|
|
767
|
+
return e != null && !Array.isArray(e) ? (r.push({
|
|
768
|
+
code: "invalid_input",
|
|
769
|
+
path: "dashboard.inputs",
|
|
770
|
+
message: "dashboard.inputs must be an array when present."
|
|
771
|
+
}), { ok: !1, inputs: s, issues: r }) : ((Array.isArray(e) ? e : []).forEach((l, u) => {
|
|
772
|
+
const m = `dashboard.inputs[${u}]`;
|
|
773
|
+
if (!P(l) || l.kind !== "filter" && l.kind !== "control" || !k(l.id) || !k(l.label) || !k(l.variableName) || !Qn(l.scope) || !Hn(l.runtimeScope)) {
|
|
774
|
+
r.push({
|
|
775
|
+
code: "invalid_input",
|
|
776
|
+
path: m,
|
|
777
|
+
message: `${m} must be a complete filter or control Dashboard Input envelope.`,
|
|
778
|
+
inputId: P(l) && typeof l.id == "string" ? l.id : void 0
|
|
779
|
+
});
|
|
780
|
+
return;
|
|
781
|
+
}
|
|
782
|
+
if (l.kind === "control" && !P(l.control)) {
|
|
783
|
+
r.push({
|
|
784
|
+
code: "invalid_input",
|
|
785
|
+
path: `${m}.control`,
|
|
786
|
+
message: `${m}.control must be a control definition.`,
|
|
787
|
+
inputId: l.id
|
|
788
|
+
});
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
const f = l;
|
|
792
|
+
if (f.kind === "control") {
|
|
793
|
+
s.push(f);
|
|
794
|
+
return;
|
|
795
|
+
}
|
|
796
|
+
const y = f.filter, p = f.filterReference, d = y !== void 0, h = !!p;
|
|
797
|
+
if (d && h) {
|
|
798
|
+
r.push({
|
|
799
|
+
code: "both_filter_definitions",
|
|
800
|
+
path: m,
|
|
801
|
+
message: `${m} must contain either filter or filterReference, not both.`,
|
|
802
|
+
inputId: f.id
|
|
803
|
+
});
|
|
804
|
+
return;
|
|
805
|
+
}
|
|
806
|
+
if (!d && !h) {
|
|
807
|
+
r.push({
|
|
808
|
+
code: "missing_filter_definition",
|
|
809
|
+
path: m,
|
|
810
|
+
message: `${m} must contain filter or filterReference.`,
|
|
811
|
+
inputId: f.id
|
|
812
|
+
});
|
|
813
|
+
return;
|
|
814
|
+
}
|
|
815
|
+
if (d && !Jn(y)) {
|
|
816
|
+
r.push({
|
|
817
|
+
code: "invalid_input",
|
|
818
|
+
path: `${m}.filter`,
|
|
819
|
+
message: `${m}.filter must be a complete dashboard filter definition.`,
|
|
820
|
+
inputId: f.id
|
|
821
|
+
});
|
|
822
|
+
return;
|
|
823
|
+
}
|
|
824
|
+
let b, v;
|
|
825
|
+
if (d)
|
|
826
|
+
b = y, v = "embedded";
|
|
827
|
+
else {
|
|
828
|
+
if ((p == null ? void 0 : p.kind) !== "dashboardFilter") {
|
|
829
|
+
r.push({
|
|
830
|
+
code: "invalid_filter_reference",
|
|
831
|
+
path: `${m}.filterReference.kind`,
|
|
832
|
+
message: `${m}.filterReference.kind must be 'dashboardFilter'.`,
|
|
833
|
+
inputId: f.id
|
|
834
|
+
});
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
const C = typeof (p == null ? void 0 : p.filterId) == "string" ? p.filterId : void 0;
|
|
838
|
+
if (b = C ? o.get(C) : void 0, v = "dashboardFilter", !b) {
|
|
839
|
+
r.push({
|
|
840
|
+
code: "orphaned_filter_reference",
|
|
841
|
+
path: `${m}.filterReference.filterId`,
|
|
842
|
+
message: `${m}.filterReference cannot resolve dashboard filter '${C || ""}'.`,
|
|
843
|
+
inputId: f.id
|
|
844
|
+
});
|
|
845
|
+
return;
|
|
846
|
+
}
|
|
847
|
+
if (b.kind === "global-date") {
|
|
848
|
+
r.push({
|
|
849
|
+
code: "global_date_reference",
|
|
850
|
+
path: `${m}.filterReference`,
|
|
851
|
+
message: `${m}.filterReference cannot reference the Global Date filter.`,
|
|
852
|
+
inputId: f.id
|
|
853
|
+
});
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
const F = c.get(b.id);
|
|
857
|
+
if (F) {
|
|
858
|
+
r.push({
|
|
859
|
+
code: "duplicate_filter_reference",
|
|
860
|
+
path: `${m}.filterReference.filterId`,
|
|
861
|
+
message: `${m}.filterReference duplicates dashboard filter '${b.id}' already owned by Dashboard Input '${F}'.`,
|
|
862
|
+
inputId: f.id
|
|
863
|
+
});
|
|
864
|
+
return;
|
|
865
|
+
}
|
|
866
|
+
c.set(b.id, f.id);
|
|
867
|
+
}
|
|
868
|
+
if (!b) return;
|
|
869
|
+
if (f.forceSelection !== void 0 && typeof f.forceSelection != "boolean" && r.push({
|
|
870
|
+
code: "invalid_input",
|
|
871
|
+
path: `${m}.forceSelection`,
|
|
872
|
+
message: `${m}.forceSelection must be a boolean.`,
|
|
873
|
+
inputId: f.id
|
|
874
|
+
}), f.optionSource !== void 0 && Yn(
|
|
875
|
+
f.id,
|
|
876
|
+
f.optionSource,
|
|
877
|
+
`${m}.optionSource`,
|
|
878
|
+
r
|
|
879
|
+
), Wn(f, m, r), f.application && b.kind === "global-date") {
|
|
880
|
+
r.push({
|
|
881
|
+
code: "global_date_reference",
|
|
882
|
+
path: `${m}.application`,
|
|
883
|
+
message: `${m}.application cannot map the Global Date filter.`,
|
|
884
|
+
inputId: f.id
|
|
885
|
+
});
|
|
886
|
+
return;
|
|
887
|
+
}
|
|
888
|
+
f.application && f.scope.kind !== "allSheets" && f.scope.kind !== "sheets" && r.push({
|
|
889
|
+
code: "unsupported_mapped_scope",
|
|
890
|
+
path: `${m}.scope`,
|
|
891
|
+
message: `${m}.scope must be allSheets or sheets when cardMappings are present.`,
|
|
892
|
+
inputId: f.id
|
|
893
|
+
}), ei(
|
|
894
|
+
f.id,
|
|
895
|
+
f.application,
|
|
896
|
+
`${m}.application`,
|
|
897
|
+
a,
|
|
898
|
+
r,
|
|
899
|
+
i
|
|
900
|
+
);
|
|
901
|
+
const {
|
|
902
|
+
filter: x,
|
|
903
|
+
filterReference: O,
|
|
904
|
+
// A reference-backed authored input must shadow the generated
|
|
905
|
+
// dashboard-filter compatibility input. Older writers may have copied
|
|
906
|
+
// the compatibility marker onto the reference; never preserve it.
|
|
907
|
+
compatibility: K,
|
|
908
|
+
...A
|
|
909
|
+
} = f;
|
|
910
|
+
s.push({
|
|
911
|
+
...A,
|
|
912
|
+
filter: b,
|
|
913
|
+
...d && K ? { compatibility: K } : {},
|
|
914
|
+
...f.optionSource ? {
|
|
915
|
+
optionSource: f.optionSource
|
|
916
|
+
} : {},
|
|
917
|
+
...f.optionDependencies ? { optionDependencies: f.optionDependencies } : {},
|
|
918
|
+
...f.optionPopulation ? { optionPopulation: f.optionPopulation } : {},
|
|
919
|
+
definitionOrigin: v
|
|
920
|
+
});
|
|
921
|
+
}), r.length ? { ok: !1, inputs: s, issues: r } : { ok: !0, inputs: s });
|
|
922
|
+
}
|
|
923
|
+
function Hr(e) {
|
|
924
|
+
const t = ti(e);
|
|
925
|
+
if (!t.ok) throw new Un(t.issues);
|
|
926
|
+
return t.inputs;
|
|
927
|
+
}
|
|
928
|
+
function Jr(e = () => globalThis.crypto.randomUUID()) {
|
|
929
|
+
return e();
|
|
930
|
+
}
|
|
931
|
+
function ni(e, t) {
|
|
932
|
+
return e.name === t.name && e.qualifiedEntityName === t.qualifiedEntityName;
|
|
933
|
+
}
|
|
934
|
+
function Yr(e, t, n) {
|
|
935
|
+
var r, o;
|
|
936
|
+
if (n.sortPolicy === "dropUnrelatedSorts") {
|
|
937
|
+
const a = new Set(
|
|
938
|
+
(e.metricColumns || []).map((s) => s.id)
|
|
939
|
+
);
|
|
940
|
+
return {
|
|
941
|
+
...e,
|
|
942
|
+
groupByColumns: [t],
|
|
943
|
+
sortByColumns: (e.sortByColumns || []).filter(
|
|
944
|
+
(s) => s.id === t.id || a.has(s.id)
|
|
945
|
+
)
|
|
946
|
+
};
|
|
947
|
+
}
|
|
948
|
+
const i = (r = e.groupByColumns) == null ? void 0 : r[0];
|
|
949
|
+
return {
|
|
950
|
+
...e,
|
|
951
|
+
groupByColumns: [t],
|
|
952
|
+
sortByColumns: (o = e.sortByColumns) == null ? void 0 : o.map(
|
|
953
|
+
(a) => i && ni(a, i) ? {
|
|
954
|
+
...t,
|
|
955
|
+
role: "sortby",
|
|
956
|
+
direction: a.direction
|
|
957
|
+
} : a
|
|
958
|
+
)
|
|
959
|
+
};
|
|
960
|
+
}
|
|
961
|
+
const ii = 6;
|
|
962
|
+
function Wr(e) {
|
|
963
|
+
if (!(e === void 0 || !Number.isFinite(e)) && Number.isInteger(e))
|
|
964
|
+
return Math.max(0, Math.min(ii, e));
|
|
965
|
+
}
|
|
966
|
+
function Ft(e) {
|
|
967
|
+
var t;
|
|
968
|
+
return ((t = e == null ? void 0 : e.comparison) == null ? void 0 : t.mode) === "explicit" ? e.comparison.spec : void 0;
|
|
969
|
+
}
|
|
970
|
+
function ri(e) {
|
|
971
|
+
var t;
|
|
972
|
+
return ((t = Ft(e)) == null ? void 0 : t.kind) || "none";
|
|
973
|
+
}
|
|
974
|
+
function Xr(e) {
|
|
975
|
+
const t = Ft(e);
|
|
976
|
+
return (t == null ? void 0 : t.kind) === "target" ? t.targetValue : void 0;
|
|
977
|
+
}
|
|
978
|
+
function Zr(e) {
|
|
979
|
+
return (e == null ? void 0 : e.semanticComparisonPolarity) || (e == null ? void 0 : e.comparisonPolarity) || Sn;
|
|
980
|
+
}
|
|
981
|
+
function De(e, t) {
|
|
982
|
+
const n = Object.entries(e || {}).filter(
|
|
983
|
+
([o, a]) => a.output.outputId === o
|
|
984
|
+
);
|
|
985
|
+
if (!t.name) return;
|
|
986
|
+
const i = E({
|
|
987
|
+
...t,
|
|
988
|
+
name: t.name
|
|
989
|
+
}), r = n.filter(
|
|
990
|
+
([, o]) => o.output.metricAlias === i
|
|
991
|
+
);
|
|
992
|
+
return r.length === 1 ? r[0][1] : void 0;
|
|
993
|
+
}
|
|
994
|
+
function Tt(e, t) {
|
|
995
|
+
const n = De(e, t);
|
|
996
|
+
return {
|
|
997
|
+
comparisonKind: (n == null ? void 0 : n.type) ?? ri(t),
|
|
998
|
+
metadata: n
|
|
999
|
+
};
|
|
1000
|
+
}
|
|
1001
|
+
function Me(e) {
|
|
1002
|
+
return (e == null ? void 0 : e.showComparison) ?? xe.showComparison;
|
|
1003
|
+
}
|
|
1004
|
+
function eo(e, t) {
|
|
1005
|
+
const n = /* @__PURE__ */ new Set([e.currentColumnKey]);
|
|
1006
|
+
if (!Me(t) || e.availability.status !== "available")
|
|
1007
|
+
return n;
|
|
1008
|
+
switch (e.comparisonColumnKey && n.add(e.comparisonColumnKey), (t == null ? void 0 : t.displayMode) ?? xe.displayMode) {
|
|
1009
|
+
case "difference":
|
|
1010
|
+
e.deltaColumnKey && n.add(e.deltaColumnKey);
|
|
1011
|
+
break;
|
|
1012
|
+
case "percent_change":
|
|
1013
|
+
e.percentChangeColumnKey && n.add(e.percentChangeColumnKey);
|
|
1014
|
+
break;
|
|
1015
|
+
case "both":
|
|
1016
|
+
e.deltaColumnKey && n.add(e.deltaColumnKey), e.percentChangeColumnKey && n.add(e.percentChangeColumnKey);
|
|
1017
|
+
break;
|
|
1018
|
+
case "ratio":
|
|
1019
|
+
e.ratioColumnKey && n.add(e.ratioColumnKey);
|
|
1020
|
+
break;
|
|
1021
|
+
}
|
|
1022
|
+
return n;
|
|
1023
|
+
}
|
|
1024
|
+
function _t(e) {
|
|
1025
|
+
const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
|
|
1026
|
+
return Object.entries(e || {}).forEach(([c, l]) => {
|
|
1027
|
+
const u = l.output;
|
|
1028
|
+
u.outputId === c && (t.add(u.currentColumnKey), n.add(u.currentColumnKey), u.availability.status === "available" && (u.comparisonColumnKey && (i.add(u.comparisonColumnKey), s.set(
|
|
1029
|
+
u.comparisonColumnKey,
|
|
1030
|
+
{
|
|
1031
|
+
metricName: l.displayName || u.metricId,
|
|
1032
|
+
comparisonLabel: l.displayLabel || "Comparison"
|
|
1033
|
+
}
|
|
1034
|
+
)), u.deltaColumnKey && (t.add(u.deltaColumnKey), r.add(u.deltaColumnKey)), u.percentChangeColumnKey && (t.add(u.percentChangeColumnKey), o.add(u.percentChangeColumnKey)), u.ratioColumnKey && (t.add(u.ratioColumnKey), a.add(u.ratioColumnKey)), u.rowStatusColumnKey && (t.add(u.rowStatusColumnKey), n.add(u.rowStatusColumnKey)), u.currentBucketColumnKey && (t.add(u.currentBucketColumnKey), n.add(u.currentBucketColumnKey)), u.comparisonSourceBucketColumnKey && (t.add(u.comparisonSourceBucketColumnKey), n.add(u.comparisonSourceBucketColumnKey))));
|
|
1035
|
+
}), {
|
|
1036
|
+
internalKeys: t,
|
|
1037
|
+
bookkeepingKeys: n,
|
|
1038
|
+
comparisonColumnKeys: i,
|
|
1039
|
+
deltaColumnKeys: r,
|
|
1040
|
+
percentChangeColumnKeys: o,
|
|
1041
|
+
ratioColumnKeys: a,
|
|
1042
|
+
comparisonSeriesLabels: s
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
function to(e) {
|
|
1046
|
+
switch (e) {
|
|
1047
|
+
case "previous_period":
|
|
1048
|
+
return "Previous";
|
|
1049
|
+
case "previous_year":
|
|
1050
|
+
return "Last Year";
|
|
1051
|
+
case "target":
|
|
1052
|
+
return "Target";
|
|
1053
|
+
default:
|
|
1054
|
+
return "Comparison";
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
function xt(e, t, n) {
|
|
1058
|
+
var i;
|
|
1059
|
+
if (((i = n == null ? void 0 : n.output) == null ? void 0 : i.availability.status) === "available" && n.output.comparisonColumnKey)
|
|
1060
|
+
return n.output.comparisonColumnKey;
|
|
1061
|
+
}
|
|
1062
|
+
function oi(e, t) {
|
|
1063
|
+
return `${e} Δ`;
|
|
1064
|
+
}
|
|
1065
|
+
function no(e, t) {
|
|
1066
|
+
return De(e, t);
|
|
1067
|
+
}
|
|
1068
|
+
function ai(e, t) {
|
|
1069
|
+
return e.rawKey === t.rawKey && e.outputKey === t.outputKey;
|
|
1070
|
+
}
|
|
1071
|
+
function ye(e) {
|
|
1072
|
+
var s;
|
|
1073
|
+
const { card: t, columnKeyMap: n, metricAlias: i, metricId: r } = e;
|
|
1074
|
+
if (!(t != null && t.config) || !n || !i || ie(t) !== "config")
|
|
1075
|
+
return;
|
|
1076
|
+
const o = (s = n.byMetricAlias) == null ? void 0 : s[i];
|
|
1077
|
+
if (!o) return;
|
|
1078
|
+
const a = (t.config.metricColumns || []).filter((c) => {
|
|
1079
|
+
var u;
|
|
1080
|
+
if (r && c.id !== r) return !1;
|
|
1081
|
+
const l = (u = n.byMetricAlias) == null ? void 0 : u[E(c)];
|
|
1082
|
+
return !!(l && ai(o, l));
|
|
1083
|
+
});
|
|
1084
|
+
return a.length === 1 ? a[0] : void 0;
|
|
1085
|
+
}
|
|
1086
|
+
function io(e, t) {
|
|
1087
|
+
return t ? { ...e, config: t } : e;
|
|
1088
|
+
}
|
|
1089
|
+
function si(e) {
|
|
1090
|
+
return [
|
|
1091
|
+
e.alias,
|
|
1092
|
+
e.name,
|
|
1093
|
+
e.qualifiedFieldName,
|
|
1094
|
+
e.id
|
|
1095
|
+
].filter((t) => !!t);
|
|
1096
|
+
}
|
|
1097
|
+
function N(e) {
|
|
1098
|
+
return e != null && e.config ? ie(e) === "config" : !1;
|
|
1099
|
+
}
|
|
1100
|
+
function ro(e, t) {
|
|
1101
|
+
const n = new Set(
|
|
1102
|
+
[e.metricAlias, e.alias].filter(
|
|
1103
|
+
(o) => !!o
|
|
1104
|
+
)
|
|
1105
|
+
), i = t.findIndex(
|
|
1106
|
+
(o) => [E(o), o.alias].some(
|
|
1107
|
+
(a) => !!a && n.has(a)
|
|
1108
|
+
)
|
|
1109
|
+
);
|
|
1110
|
+
if (i >= 0) return i;
|
|
1111
|
+
const r = t.map((o, a) => ({ metric: o, index: a })).filter(({ metric: o }) => o.id === e.metricId);
|
|
1112
|
+
return r.length === 1 ? r[0].index : -1;
|
|
1113
|
+
}
|
|
1114
|
+
function et(e) {
|
|
1115
|
+
return JSON.stringify({
|
|
1116
|
+
fields: e.pivotFields ?? [],
|
|
1117
|
+
values: e.pivotValues ?? []
|
|
1118
|
+
});
|
|
1119
|
+
}
|
|
1120
|
+
function li(e, t, n, i) {
|
|
1121
|
+
if (t === -1 || n === -1 || t === n)
|
|
1122
|
+
return null;
|
|
1123
|
+
const r = [...e], [o] = r.splice(t, 1), a = i === "before" ? n > t ? n - 1 : n : n > t ? n : n + 1;
|
|
1124
|
+
return r.splice(a, 0, o), r;
|
|
1125
|
+
}
|
|
1126
|
+
function Z(e, t, n) {
|
|
1127
|
+
if (!(e != null && e.length)) return null;
|
|
1128
|
+
const i = e.findIndex(
|
|
1129
|
+
(o) => n(o).includes(t.draggingColumnId)
|
|
1130
|
+
), r = e.findIndex(
|
|
1131
|
+
(o) => n(o).includes(t.targetColumnId)
|
|
1132
|
+
);
|
|
1133
|
+
return li(e, i, r, t.side);
|
|
1134
|
+
}
|
|
1135
|
+
function ee(e, t, n) {
|
|
1136
|
+
return n ? {
|
|
1137
|
+
...e ?? {},
|
|
1138
|
+
[t]: n
|
|
1139
|
+
} : null;
|
|
1140
|
+
}
|
|
1141
|
+
function oo(e, t, n) {
|
|
1142
|
+
if (!N(e) || !n) return null;
|
|
1143
|
+
const i = e.config;
|
|
1144
|
+
return e.type === "detailTable" ? ee(
|
|
1145
|
+
i,
|
|
1146
|
+
"detailColumns",
|
|
1147
|
+
Z(
|
|
1148
|
+
i == null ? void 0 : i.detailColumns,
|
|
1149
|
+
t,
|
|
1150
|
+
(r) => V(r, "detail", n)
|
|
1151
|
+
)
|
|
1152
|
+
) : ee(
|
|
1153
|
+
i,
|
|
1154
|
+
"groupByColumns",
|
|
1155
|
+
Z(
|
|
1156
|
+
i == null ? void 0 : i.groupByColumns,
|
|
1157
|
+
t,
|
|
1158
|
+
(r) => V(r, "groupby", n)
|
|
1159
|
+
)
|
|
1160
|
+
) ?? ee(
|
|
1161
|
+
i,
|
|
1162
|
+
"metricColumns",
|
|
1163
|
+
Z(
|
|
1164
|
+
i == null ? void 0 : i.metricColumns,
|
|
1165
|
+
t,
|
|
1166
|
+
(r) => V(r, "metric", n)
|
|
1167
|
+
)
|
|
1168
|
+
);
|
|
1169
|
+
}
|
|
1170
|
+
function ci(e) {
|
|
1171
|
+
var t, n, i, r, o, a;
|
|
1172
|
+
return N(e) ? e.type === "detailTable" ? !!((n = (t = e.config) == null ? void 0 : t.detailColumns) != null && n.length) : !!((r = (i = e.config) == null ? void 0 : i.groupByColumns) != null && r.length || (a = (o = e.config) == null ? void 0 : o.metricColumns) != null && a.length) : !1;
|
|
1173
|
+
}
|
|
1174
|
+
function ao(e, t) {
|
|
1175
|
+
return ci(e) && !!t;
|
|
1176
|
+
}
|
|
1177
|
+
function so(e, t, n) {
|
|
1178
|
+
var i, r;
|
|
1179
|
+
return !N(e) || !n ? null : ee(
|
|
1180
|
+
e.config,
|
|
1181
|
+
"groupByColumns",
|
|
1182
|
+
Z(
|
|
1183
|
+
(i = e.config) == null ? void 0 : i.groupByColumns,
|
|
1184
|
+
t,
|
|
1185
|
+
(o) => V(
|
|
1186
|
+
o,
|
|
1187
|
+
"groupby",
|
|
1188
|
+
n
|
|
1189
|
+
)
|
|
1190
|
+
)
|
|
1191
|
+
) ?? ee(
|
|
1192
|
+
e.config,
|
|
1193
|
+
"metricColumns",
|
|
1194
|
+
Z(
|
|
1195
|
+
(r = e.config) == null ? void 0 : r.metricColumns,
|
|
1196
|
+
t,
|
|
1197
|
+
(o) => V(
|
|
1198
|
+
o,
|
|
1199
|
+
"metric",
|
|
1200
|
+
n
|
|
1201
|
+
)
|
|
1202
|
+
)
|
|
1203
|
+
);
|
|
1204
|
+
}
|
|
1205
|
+
function V(e, t, n) {
|
|
1206
|
+
if (!n) return [];
|
|
1207
|
+
const i = t === "metric" ? [
|
|
1208
|
+
E(e),
|
|
1209
|
+
e.alias
|
|
1210
|
+
].filter((o) => !!o).flatMap((o) => {
|
|
1211
|
+
var s;
|
|
1212
|
+
const a = (s = n.byMetricAlias) == null ? void 0 : s[o];
|
|
1213
|
+
return a ? [a] : [];
|
|
1214
|
+
}) : [], r = Pn(
|
|
1215
|
+
n,
|
|
1216
|
+
e.id,
|
|
1217
|
+
t
|
|
1218
|
+
);
|
|
1219
|
+
return [...i, r].flatMap((o) => [o == null ? void 0 : o.outputKey, o == null ? void 0 : o.rawKey]).filter((o) => !!o);
|
|
1220
|
+
}
|
|
1221
|
+
function oe(e, t, n, i) {
|
|
1222
|
+
const r = V(
|
|
1223
|
+
e,
|
|
1224
|
+
t,
|
|
1225
|
+
i
|
|
1226
|
+
);
|
|
1227
|
+
return i ? r.find(
|
|
1228
|
+
(o) => n.includes(o)
|
|
1229
|
+
) : si(e).find(
|
|
1230
|
+
(o) => n.includes(o)
|
|
1231
|
+
);
|
|
1232
|
+
}
|
|
1233
|
+
function St(e, t, n) {
|
|
1234
|
+
if (!N(t) || !n)
|
|
1235
|
+
return;
|
|
1236
|
+
const i = t.type === "detailTable" ? [{ role: "detail", fields: t.config.detailColumns }] : [
|
|
1237
|
+
{ role: "groupby", fields: t.config.groupByColumns },
|
|
1238
|
+
{ role: "metric", fields: t.config.metricColumns }
|
|
1239
|
+
];
|
|
1240
|
+
for (const { role: r, fields: o } of i)
|
|
1241
|
+
for (const a of o || [])
|
|
1242
|
+
if (oe(
|
|
1243
|
+
a,
|
|
1244
|
+
r,
|
|
1245
|
+
[e],
|
|
1246
|
+
n
|
|
1247
|
+
) === e && typeof a.label == "string" && a.label.length > 0)
|
|
1248
|
+
return a.label;
|
|
1249
|
+
}
|
|
1250
|
+
function ui(e, t) {
|
|
1251
|
+
if (!e) return;
|
|
1252
|
+
const n = JSON.stringify(t), i = t.every((r) => r !== null) ? t.join("__") : void 0;
|
|
1253
|
+
return e[n] || (i ? e[i] : void 0);
|
|
1254
|
+
}
|
|
1255
|
+
function di(e, t, n) {
|
|
1256
|
+
if (!e) return;
|
|
1257
|
+
let i = e, r = !1;
|
|
1258
|
+
return t.forEach((o, a) => {
|
|
1259
|
+
const s = n[a] ?? "";
|
|
1260
|
+
[
|
|
1261
|
+
o.entityName ? `{{${o.entityName}.${o.name}}}` : void 0,
|
|
1262
|
+
`{{${o.name}}}`
|
|
1263
|
+
].filter((l) => !!l).forEach((l) => {
|
|
1264
|
+
i.includes(l) && (i = i.split(l).join(s), r = !0);
|
|
1265
|
+
});
|
|
1266
|
+
}), r && i.trim() ? i : void 0;
|
|
1267
|
+
}
|
|
1268
|
+
function mi(e) {
|
|
1269
|
+
const t = (e.card.config.metricColumns || []).filter(
|
|
1270
|
+
(n) => n.id === e.metricId && E(n) === e.metricAlias
|
|
1271
|
+
);
|
|
1272
|
+
return t.length === 1 ? t[0] : ye({
|
|
1273
|
+
card: e.card,
|
|
1274
|
+
columnKeyMap: e.columnKeyMap,
|
|
1275
|
+
metricAlias: e.metricAlias,
|
|
1276
|
+
metricId: e.metricId
|
|
1277
|
+
});
|
|
1278
|
+
}
|
|
1279
|
+
function Pe(e) {
|
|
1280
|
+
var a;
|
|
1281
|
+
const t = (a = e.resultColumn) == null ? void 0 : a.pivotIdentity, n = e.card.config.pivotByColumns || [];
|
|
1282
|
+
if (!t || n.length === 0 || t.members.length !== n.length || t.members.some(
|
|
1283
|
+
(s, c) => {
|
|
1284
|
+
var l;
|
|
1285
|
+
return s.fieldId !== ((l = n[c]) == null ? void 0 : l.id);
|
|
1286
|
+
}
|
|
1287
|
+
))
|
|
1288
|
+
return;
|
|
1289
|
+
const i = e.card.config.metricColumns || [], r = mi({
|
|
1290
|
+
card: e.card,
|
|
1291
|
+
columnKeyMap: e.columnKeyMap,
|
|
1292
|
+
metricId: t.metricId,
|
|
1293
|
+
metricAlias: t.metricAlias
|
|
1294
|
+
}), o = i.length === 0 && t.metricId === _e;
|
|
1295
|
+
if (!(!r && !o))
|
|
1296
|
+
return {
|
|
1297
|
+
resultColumn: e.resultColumn,
|
|
1298
|
+
identity: t,
|
|
1299
|
+
pivotFields: n,
|
|
1300
|
+
authoredMetrics: i,
|
|
1301
|
+
authoredMetric: r
|
|
1302
|
+
};
|
|
1303
|
+
}
|
|
1304
|
+
function fi(e) {
|
|
1305
|
+
const {
|
|
1306
|
+
columnId: t,
|
|
1307
|
+
card: n,
|
|
1308
|
+
columnKeyMap: i,
|
|
1309
|
+
resultColumns: r,
|
|
1310
|
+
temporalPresentation: o,
|
|
1311
|
+
metricLabelOverride: a
|
|
1312
|
+
} = e;
|
|
1313
|
+
if (!N(n) || n.type !== "table")
|
|
1314
|
+
return;
|
|
1315
|
+
const s = Pe({
|
|
1316
|
+
resultColumn: r == null ? void 0 : r.find((v) => v.key === t),
|
|
1317
|
+
card: n,
|
|
1318
|
+
columnKeyMap: i
|
|
1319
|
+
});
|
|
1320
|
+
if (!s) return;
|
|
1321
|
+
const { identity: c, pivotFields: l, authoredMetrics: u, authoredMetric: m } = s, y = Kn({
|
|
1322
|
+
members: c.members,
|
|
1323
|
+
resolveTemporalFormat: (v) => {
|
|
1324
|
+
var x;
|
|
1325
|
+
return (x = tn({
|
|
1326
|
+
presentation: o,
|
|
1327
|
+
fieldId: v,
|
|
1328
|
+
role: "pivotby"
|
|
1329
|
+
})) == null ? void 0 : x.resolved.format;
|
|
1330
|
+
}
|
|
1331
|
+
}).memberLabels.map(
|
|
1332
|
+
(v) => v || "(Blank)"
|
|
1333
|
+
), p = c.members.map((v) => v.value), d = ui(m == null ? void 0 : m.valueAliases, p) || di(
|
|
1334
|
+
m == null ? void 0 : m.aliasTemplate,
|
|
1335
|
+
l,
|
|
1336
|
+
y
|
|
1337
|
+
), h = d ? [d] : y, b = a || (u.length > 1 ? (m == null ? void 0 : m.label) || (m == null ? void 0 : m.name) : void 0);
|
|
1338
|
+
return [...h, ...b ? [b] : []].join(" / ");
|
|
1339
|
+
}
|
|
1340
|
+
function pi(e, t, n, i) {
|
|
1341
|
+
var r;
|
|
1342
|
+
return (r = ye({
|
|
1343
|
+
card: n,
|
|
1344
|
+
columnKeyMap: i,
|
|
1345
|
+
metricAlias: e,
|
|
1346
|
+
metricId: t
|
|
1347
|
+
})) == null ? void 0 : r.label;
|
|
1348
|
+
}
|
|
1349
|
+
function lo(e, t, n, i = "") {
|
|
1350
|
+
return e && (pi(
|
|
1351
|
+
e.metricAlias || e.alias,
|
|
1352
|
+
e.metricId,
|
|
1353
|
+
t,
|
|
1354
|
+
n
|
|
1355
|
+
) || e.displayLabel || e.metricLabel || e.metricName || e.alias) || i;
|
|
1356
|
+
}
|
|
1357
|
+
function z(e, t, n, i) {
|
|
1358
|
+
return e != null && e.length ? e.map(
|
|
1359
|
+
(r) => oe(
|
|
1360
|
+
r,
|
|
1361
|
+
n,
|
|
1362
|
+
t,
|
|
1363
|
+
i
|
|
1364
|
+
)
|
|
1365
|
+
).filter((r) => !!r) : [];
|
|
1366
|
+
}
|
|
1367
|
+
function tt(e, t, n, i) {
|
|
1368
|
+
if (!N(t) || !i) return e;
|
|
1369
|
+
const r = [], o = (a) => {
|
|
1370
|
+
a && e.includes(a) && !r.includes(a) && r.push(a);
|
|
1371
|
+
};
|
|
1372
|
+
return t.type === "detailTable" ? z(
|
|
1373
|
+
t.config.detailColumns,
|
|
1374
|
+
e,
|
|
1375
|
+
"detail",
|
|
1376
|
+
i
|
|
1377
|
+
).forEach(o) : (z(
|
|
1378
|
+
t.config.groupByColumns,
|
|
1379
|
+
e,
|
|
1380
|
+
"groupby",
|
|
1381
|
+
i
|
|
1382
|
+
).forEach(o), z(
|
|
1383
|
+
t.config.metricColumns,
|
|
1384
|
+
e,
|
|
1385
|
+
"metric",
|
|
1386
|
+
i
|
|
1387
|
+
).forEach((a) => {
|
|
1388
|
+
o(a), o(n == null ? void 0 : n(a));
|
|
1389
|
+
})), e.forEach(o), r;
|
|
1390
|
+
}
|
|
1391
|
+
function yi(e, t) {
|
|
1392
|
+
var f, y, p;
|
|
1393
|
+
const { keys: n, card: i, columnKeyMap: r, resultColumns: o } = e;
|
|
1394
|
+
if (!((f = i.config.pivotByColumns) != null && f.length)) return null;
|
|
1395
|
+
if (!r || !(o != null && o.length)) return [...n];
|
|
1396
|
+
const a = n.every(
|
|
1397
|
+
(d) => o.some((h) => h.key === d)
|
|
1398
|
+
), s = [
|
|
1399
|
+
...z(
|
|
1400
|
+
i.config.groupByColumns,
|
|
1401
|
+
n,
|
|
1402
|
+
"groupby",
|
|
1403
|
+
r
|
|
1404
|
+
),
|
|
1405
|
+
...z(
|
|
1406
|
+
i.config.metricColumns,
|
|
1407
|
+
n,
|
|
1408
|
+
"metric",
|
|
1409
|
+
r
|
|
1410
|
+
)
|
|
1411
|
+
].length === (((y = i.config.groupByColumns) == null ? void 0 : y.length) || 0) + (((p = i.config.metricColumns) == null ? void 0 : p.length) || 0);
|
|
1412
|
+
if (!a || !s)
|
|
1413
|
+
return [...n];
|
|
1414
|
+
const c = o.filter(
|
|
1415
|
+
(d) => d.pivotIdentity && n.includes(d.key)
|
|
1416
|
+
);
|
|
1417
|
+
if (c.some(
|
|
1418
|
+
(d) => !Pe({
|
|
1419
|
+
resultColumn: d,
|
|
1420
|
+
card: i,
|
|
1421
|
+
columnKeyMap: r
|
|
1422
|
+
})
|
|
1423
|
+
))
|
|
1424
|
+
return [...n];
|
|
1425
|
+
const l = c.map((d) => d.key);
|
|
1426
|
+
if (l.length === 0) return [...n];
|
|
1427
|
+
const u = [], m = (d) => {
|
|
1428
|
+
d && n.includes(d) && !u.includes(d) && u.push(d);
|
|
1429
|
+
};
|
|
1430
|
+
return z(
|
|
1431
|
+
i.config.groupByColumns,
|
|
1432
|
+
n,
|
|
1433
|
+
"groupby",
|
|
1434
|
+
r
|
|
1435
|
+
).forEach(m), l.forEach(m), z(
|
|
1436
|
+
i.config.metricColumns,
|
|
1437
|
+
n,
|
|
1438
|
+
"metric",
|
|
1439
|
+
r
|
|
1440
|
+
).forEach((d) => {
|
|
1441
|
+
m(d), m(t(d));
|
|
1442
|
+
}), n.forEach(m), u;
|
|
1443
|
+
}
|
|
1444
|
+
function gi(e) {
|
|
1445
|
+
var c;
|
|
1446
|
+
const { keys: t, card: n, comparisonMetadata: i, columnKeyMap: r, resultColumns: o } = e;
|
|
1447
|
+
if ((n == null ? void 0 : n.type) !== "table")
|
|
1448
|
+
return tt(
|
|
1449
|
+
t,
|
|
1450
|
+
n,
|
|
1451
|
+
void 0,
|
|
1452
|
+
r
|
|
1453
|
+
);
|
|
1454
|
+
const a = /* @__PURE__ */ new Map();
|
|
1455
|
+
(((c = n.config) == null ? void 0 : c.metricColumns) || []).forEach((l) => {
|
|
1456
|
+
const { comparisonKind: u, metadata: m } = Tt(i, l);
|
|
1457
|
+
if (u === "none") return;
|
|
1458
|
+
const f = l.label || l.name, y = oe(
|
|
1459
|
+
l,
|
|
1460
|
+
"metric",
|
|
1461
|
+
t,
|
|
1462
|
+
r
|
|
1463
|
+
);
|
|
1464
|
+
if (!y) return;
|
|
1465
|
+
const p = xt(
|
|
1466
|
+
f,
|
|
1467
|
+
u,
|
|
1468
|
+
m
|
|
1469
|
+
);
|
|
1470
|
+
p && a.set(y, p);
|
|
1471
|
+
});
|
|
1472
|
+
const s = (l) => a.get(l) ?? null;
|
|
1473
|
+
if (N(n)) {
|
|
1474
|
+
const l = yi(
|
|
1475
|
+
{ keys: t, card: n, columnKeyMap: r, resultColumns: o },
|
|
1476
|
+
s
|
|
1477
|
+
);
|
|
1478
|
+
if (l) return l;
|
|
1479
|
+
}
|
|
1480
|
+
return tt(
|
|
1481
|
+
t,
|
|
1482
|
+
n,
|
|
1483
|
+
s,
|
|
1484
|
+
r
|
|
1485
|
+
);
|
|
1486
|
+
}
|
|
1487
|
+
function co(e, t, n) {
|
|
1488
|
+
var o;
|
|
1489
|
+
const i = (o = t == null ? void 0 : t.config) == null ? void 0 : o.groupByColumns;
|
|
1490
|
+
if (!(i != null && i.length) || !N(t) || !n)
|
|
1491
|
+
return e;
|
|
1492
|
+
const r = (a) => i.find((s) => V(
|
|
1493
|
+
s,
|
|
1494
|
+
"groupby",
|
|
1495
|
+
n
|
|
1496
|
+
).some(
|
|
1497
|
+
(l) => [a.alias, a.name, a.id].includes(l)
|
|
1498
|
+
));
|
|
1499
|
+
return [...e].sort((a, s) => {
|
|
1500
|
+
const c = r(a), l = r(s), u = c ? i.indexOf(c) : -1, m = l ? i.indexOf(l) : -1;
|
|
1501
|
+
return u === -1 && m === -1 ? 0 : u === -1 ? 1 : m === -1 ? -1 : u - m;
|
|
1502
|
+
});
|
|
1503
|
+
}
|
|
1504
|
+
function uo(e, t, n) {
|
|
1505
|
+
var l;
|
|
1506
|
+
const i = (l = t == null ? void 0 : t.config) == null ? void 0 : l.metricColumns;
|
|
1507
|
+
if (!(i != null && i.length) || !N(t) || !n)
|
|
1508
|
+
return e;
|
|
1509
|
+
const r = new Map(
|
|
1510
|
+
e.filter((u) => u.isMetricColumn).map((u) => [
|
|
1511
|
+
u,
|
|
1512
|
+
ye({
|
|
1513
|
+
card: t,
|
|
1514
|
+
columnKeyMap: n,
|
|
1515
|
+
metricAlias: u.metricAlias || u.alias,
|
|
1516
|
+
metricId: u.metricId
|
|
1517
|
+
})
|
|
1518
|
+
])
|
|
1519
|
+
);
|
|
1520
|
+
if ([...r.values()].some((u) => !u))
|
|
1521
|
+
return e;
|
|
1522
|
+
const o = (u) => i.indexOf(r.get(u)), a = (u, m) => {
|
|
1523
|
+
const f = o(u), y = o(m);
|
|
1524
|
+
return f === -1 && y === -1 ? 0 : f === -1 ? 1 : y === -1 ? -1 : f - y;
|
|
1525
|
+
}, s = [];
|
|
1526
|
+
let c = 0;
|
|
1527
|
+
for (; c < e.length; ) {
|
|
1528
|
+
const u = e[c];
|
|
1529
|
+
if (!u.isMetricColumn) {
|
|
1530
|
+
s.push(u), c += 1;
|
|
1531
|
+
continue;
|
|
1532
|
+
}
|
|
1533
|
+
const m = et(u), f = [];
|
|
1534
|
+
for (; c < e.length && e[c].isMetricColumn && et(e[c]) === m; )
|
|
1535
|
+
f.push(e[c]), c += 1;
|
|
1536
|
+
s.push(...f.sort(a));
|
|
1537
|
+
}
|
|
1538
|
+
return s;
|
|
1539
|
+
}
|
|
1540
|
+
function H(e) {
|
|
1541
|
+
return e == null ? void 0 : e.map(
|
|
1542
|
+
({
|
|
1543
|
+
format: t,
|
|
1544
|
+
semanticTemporalPresentation: n,
|
|
1545
|
+
...i
|
|
1546
|
+
}) => i
|
|
1547
|
+
);
|
|
1548
|
+
}
|
|
1549
|
+
function ne(e) {
|
|
1550
|
+
if (!e)
|
|
1551
|
+
return;
|
|
1552
|
+
const {
|
|
1553
|
+
format: t,
|
|
1554
|
+
semanticTemporalPresentation: n,
|
|
1555
|
+
...i
|
|
1556
|
+
} = e;
|
|
1557
|
+
return U(i);
|
|
1558
|
+
}
|
|
1559
|
+
function bi(e, t) {
|
|
1560
|
+
const { dateFormat: n, customFormat: i, ...r } = ne(e.field);
|
|
1561
|
+
return {
|
|
1562
|
+
...e,
|
|
1563
|
+
field: t ? r : ne(e.field)
|
|
1564
|
+
};
|
|
1565
|
+
}
|
|
1566
|
+
function Ke(e, t = !1) {
|
|
1567
|
+
if (e)
|
|
1568
|
+
return {
|
|
1569
|
+
...e,
|
|
1570
|
+
conditions: e.conditions.map((n) => bi(n, t)),
|
|
1571
|
+
groups: e.groups.map((n) => Ke(n, t))
|
|
1572
|
+
};
|
|
1573
|
+
}
|
|
1574
|
+
function U(e) {
|
|
1575
|
+
var n, i;
|
|
1576
|
+
const t = { ...e };
|
|
1577
|
+
return (n = t.calculatedFormula) != null && n.inputFields && (t.calculatedFormula = {
|
|
1578
|
+
...t.calculatedFormula,
|
|
1579
|
+
inputFields: t.calculatedFormula.inputFields.map(
|
|
1580
|
+
(r) => ne(r)
|
|
1581
|
+
)
|
|
1582
|
+
}), (i = t.parameters) != null && i.filters && (t.parameters = {
|
|
1583
|
+
...t.parameters,
|
|
1584
|
+
filters: Ke(t.parameters.filters)
|
|
1585
|
+
}), t;
|
|
1586
|
+
}
|
|
1587
|
+
function hi(e, t) {
|
|
1588
|
+
var n, i;
|
|
1589
|
+
return t.cardType === "detailTable" ? (n = H(e)) == null ? void 0 : n.map(U) : !rn(t.cardType) || t.temporalResultOwner !== "config" ? (i = H(e)) == null ? void 0 : i.map(U) : e == null ? void 0 : e.map((r) => {
|
|
1590
|
+
const o = lt(r), a = ne(o ?? r);
|
|
1591
|
+
if (!o)
|
|
1592
|
+
return a;
|
|
1593
|
+
const { dateFormat: s, customFormat: c, ...l } = a;
|
|
1594
|
+
return l;
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
function Ci(e, t) {
|
|
1598
|
+
var n;
|
|
1599
|
+
return t.cardType !== "pivotTable" || t.temporalResultOwner !== "config" ? (n = H(e)) == null ? void 0 : n.map(U) : e == null ? void 0 : e.map((i) => {
|
|
1600
|
+
const r = lt(i), o = ne(r ?? i);
|
|
1601
|
+
if (!r) return o;
|
|
1602
|
+
const { dateFormat: a, customFormat: s, ...c } = o;
|
|
1603
|
+
return c;
|
|
1604
|
+
});
|
|
1605
|
+
}
|
|
1606
|
+
function vi(e) {
|
|
1607
|
+
var t;
|
|
1608
|
+
return (t = H(e)) == null ? void 0 : t.map(U);
|
|
1609
|
+
}
|
|
1610
|
+
function Ii(e, t) {
|
|
1611
|
+
if (!e)
|
|
1612
|
+
return;
|
|
1613
|
+
const n = { type: t.cardType, config: e };
|
|
1614
|
+
return nn(n) ? Fi(n, t) : e.matrix === void 0 ? {} : { matrix: e.matrix };
|
|
1615
|
+
}
|
|
1616
|
+
function Fi(e, t = {}) {
|
|
1617
|
+
var o, a;
|
|
1618
|
+
const n = e.config;
|
|
1619
|
+
if (!n) return;
|
|
1620
|
+
const i = { ...t, cardType: e.type };
|
|
1621
|
+
return {
|
|
1622
|
+
...n,
|
|
1623
|
+
groupByColumns: hi(n.groupByColumns, i),
|
|
1624
|
+
metricColumns: (o = H(n.metricColumns)) == null ? void 0 : o.map(
|
|
1625
|
+
U
|
|
1626
|
+
),
|
|
1627
|
+
pivotByColumns: Ci(n.pivotByColumns, i),
|
|
1628
|
+
sortByColumns: (a = H(n.sortByColumns)) == null ? void 0 : a.map(
|
|
1629
|
+
U
|
|
1630
|
+
),
|
|
1631
|
+
detailColumns: vi(n.detailColumns),
|
|
1632
|
+
filters: Ke(n.filters)
|
|
1633
|
+
};
|
|
1634
|
+
}
|
|
1635
|
+
function Dt(e, t) {
|
|
1636
|
+
if (!(typeof e != "number" || typeof t != "number"))
|
|
1637
|
+
return e === t ? t : void 0;
|
|
1638
|
+
}
|
|
1639
|
+
function Ti(e, t) {
|
|
1640
|
+
if (!(e != null && e.type) || e.type === "auto")
|
|
1641
|
+
return;
|
|
1642
|
+
if (e.type === "date")
|
|
1643
|
+
return Cn({
|
|
1644
|
+
locale: e.locale,
|
|
1645
|
+
pattern: e.dateFormat,
|
|
1646
|
+
timezone: e.timezone,
|
|
1647
|
+
sourceTimezone: e.sourceTimezone,
|
|
1648
|
+
relative: e.relative,
|
|
1649
|
+
prefix: e.prefix,
|
|
1650
|
+
suffix: e.suffix
|
|
1651
|
+
});
|
|
1652
|
+
if (e.type === "duration")
|
|
1653
|
+
return gt({
|
|
1654
|
+
inputUnit: e.durationInputUnit,
|
|
1655
|
+
outputStyle: e.durationDisplayStyle,
|
|
1656
|
+
largestUnit: e.durationLargestUnit,
|
|
1657
|
+
smallestUnit: e.durationSmallestUnit,
|
|
1658
|
+
maxUnits: e.durationMaxUnits,
|
|
1659
|
+
prefix: e.prefix,
|
|
1660
|
+
suffix: e.suffix,
|
|
1661
|
+
negativeStyle: e.negativeInParentheses ? "parentheses" : "minus"
|
|
1662
|
+
});
|
|
1663
|
+
if (e.type !== "number" && e.type !== "currency" && e.type !== "percent" && e.type !== "scientific")
|
|
1664
|
+
return;
|
|
1665
|
+
const n = typeof e.decimalPlaces == "number" ? e.decimalPlaces : void 0;
|
|
1666
|
+
return pe(
|
|
1667
|
+
e.type,
|
|
1668
|
+
{
|
|
1669
|
+
type: e.type,
|
|
1670
|
+
currency: e.currency,
|
|
1671
|
+
locale: e.locale,
|
|
1672
|
+
prefix: e.prefix,
|
|
1673
|
+
suffix: e.suffix,
|
|
1674
|
+
minimumFractionDigits: e.minimumFractionDigits ?? n,
|
|
1675
|
+
maximumFractionDigits: e.maximumFractionDigits ?? n,
|
|
1676
|
+
useGrouping: e.useGrouping,
|
|
1677
|
+
compact: !!e.useSuffix,
|
|
1678
|
+
negativeStyle: e.negativeInParentheses ? "parentheses" : "minus",
|
|
1679
|
+
scale: e.multiplyBy,
|
|
1680
|
+
percentValueMode: e.type === "percent" ? typeof e.multiplyBy == "number" ? "whole" : e.percentValueMode || "fraction" : void 0
|
|
1681
|
+
},
|
|
1682
|
+
t
|
|
1683
|
+
);
|
|
1684
|
+
}
|
|
1685
|
+
function _i(e) {
|
|
1686
|
+
const t = Ti(e, {
|
|
1687
|
+
preserveOmittedProperties: !0
|
|
1688
|
+
});
|
|
1689
|
+
if (!t || t.type !== "currency")
|
|
1690
|
+
return t;
|
|
1691
|
+
const n = !te(e == null ? void 0 : e.currency) && typeof (e == null ? void 0 : e.decimalPlaces) == "number";
|
|
1692
|
+
return {
|
|
1693
|
+
...t,
|
|
1694
|
+
currency: n ? "USD" : t.currency
|
|
1695
|
+
};
|
|
1696
|
+
}
|
|
1697
|
+
function Mt(e) {
|
|
1698
|
+
if (!e)
|
|
1699
|
+
return;
|
|
1700
|
+
const t = te(e.currency), n = te(e.locale), i = typeof e.prefix == "string" ? e.prefix : void 0, r = typeof e.suffix == "string" ? e.suffix : void 0, o = t ? "currency" : r === "%" ? "percent" : "number";
|
|
1701
|
+
return pe(o, {
|
|
1702
|
+
type: o,
|
|
1703
|
+
currency: t,
|
|
1704
|
+
locale: n,
|
|
1705
|
+
prefix: i,
|
|
1706
|
+
suffix: r,
|
|
1707
|
+
minimumFractionDigits: e.minimumFractionDigits,
|
|
1708
|
+
maximumFractionDigits: e.maximumFractionDigits,
|
|
1709
|
+
decimals: e.decimalPlaces,
|
|
1710
|
+
useGrouping: e.useGrouping,
|
|
1711
|
+
percentValueMode: o === "percent" ? e.percentValueMode || "whole" : void 0
|
|
1712
|
+
});
|
|
1713
|
+
}
|
|
1714
|
+
function xi(e) {
|
|
1715
|
+
if (!e)
|
|
1716
|
+
return;
|
|
1717
|
+
const t = te(e.currency), n = te(e.locale), i = typeof e.suffix == "string" ? e.suffix : void 0, r = t ? "currency" : i === "%" ? "percent" : "number";
|
|
1718
|
+
return pe(r, {
|
|
1719
|
+
type: r,
|
|
1720
|
+
currency: t,
|
|
1721
|
+
locale: n,
|
|
1722
|
+
suffix: i,
|
|
1723
|
+
minimumFractionDigits: e.minimumFractionDigits,
|
|
1724
|
+
maximumFractionDigits: e.maximumFractionDigits,
|
|
1725
|
+
decimals: e.decimalPlaces,
|
|
1726
|
+
useGrouping: e.useGrouping,
|
|
1727
|
+
percentValueMode: r === "percent" ? e.percentValueMode || "whole" : void 0
|
|
1728
|
+
});
|
|
1729
|
+
}
|
|
1730
|
+
function Pt(e, t) {
|
|
1731
|
+
if (!e)
|
|
1732
|
+
return;
|
|
1733
|
+
if (e.style === "duration")
|
|
1734
|
+
return gt({
|
|
1735
|
+
...e.duration,
|
|
1736
|
+
prefix: e.prefix,
|
|
1737
|
+
suffix: e.suffix,
|
|
1738
|
+
negativeStyle: e.negativeStyle
|
|
1739
|
+
});
|
|
1740
|
+
const n = e.style === "currency" ? "currency" : e.style === "percent" ? "percent" : e.style === "scientific" ? "scientific" : e.style === "decimal" ? "number" : void 0;
|
|
1741
|
+
if (n)
|
|
1742
|
+
return pe(
|
|
1743
|
+
n,
|
|
1744
|
+
{
|
|
1745
|
+
type: n,
|
|
1746
|
+
currency: e.currency,
|
|
1747
|
+
locale: e.locale,
|
|
1748
|
+
minimumFractionDigits: e.minimumFractionDigits,
|
|
1749
|
+
maximumFractionDigits: e.maximumFractionDigits,
|
|
1750
|
+
useGrouping: e.useGrouping,
|
|
1751
|
+
percentValueMode: n === "percent" ? e.percentValueMode || "whole" : void 0,
|
|
1752
|
+
scale: e.scale,
|
|
1753
|
+
compact: e.compact,
|
|
1754
|
+
negativeStyle: e.negativeStyle,
|
|
1755
|
+
prefix: e.prefix,
|
|
1756
|
+
suffix: e.suffix
|
|
1757
|
+
},
|
|
1758
|
+
t
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1761
|
+
function Si(e) {
|
|
1762
|
+
return !!(e && e.minimumFractionDigits === void 0 && e.maximumFractionDigits === void 0 && typeof e.currency == "string" && e.currency.length > 0 && typeof e.locale == "string" && e.locale.length > 0 && typeof e.showDataBar == "boolean" && typeof e.dataBarColor == "string" && e.dataBarColor.length > 0);
|
|
1763
|
+
}
|
|
1764
|
+
function mo(e) {
|
|
1765
|
+
const t = Pt(e, {
|
|
1766
|
+
preserveOmittedProperties: !0
|
|
1767
|
+
});
|
|
1768
|
+
return !t || !re(t) || !Si(e) ? t : {
|
|
1769
|
+
...t,
|
|
1770
|
+
minimumFractionDigits: t.minimumFractionDigits === void 0 && t.maximumFractionDigits === void 0 ? 0 : t.minimumFractionDigits,
|
|
1771
|
+
maximumFractionDigits: t.minimumFractionDigits === void 0 && t.maximumFractionDigits === void 0 ? 2 : t.maximumFractionDigits
|
|
1772
|
+
};
|
|
1773
|
+
}
|
|
1774
|
+
function fo(e, t) {
|
|
1775
|
+
const n = Y(e, t);
|
|
1776
|
+
if (n) {
|
|
1777
|
+
if (n.type === "date")
|
|
1778
|
+
return {
|
|
1779
|
+
type: "date",
|
|
1780
|
+
locale: n.locale,
|
|
1781
|
+
dateFormat: n.pattern,
|
|
1782
|
+
timezone: n.timezone,
|
|
1783
|
+
sourceTimezone: n.sourceTimezone,
|
|
1784
|
+
relative: n.relative,
|
|
1785
|
+
prefix: n.prefix,
|
|
1786
|
+
suffix: n.suffix
|
|
1787
|
+
};
|
|
1788
|
+
if (n.type === "duration")
|
|
1789
|
+
return {
|
|
1790
|
+
type: "duration",
|
|
1791
|
+
durationInputUnit: n.inputUnit,
|
|
1792
|
+
durationDisplayStyle: n.outputStyle,
|
|
1793
|
+
durationLargestUnit: n.largestUnit,
|
|
1794
|
+
durationSmallestUnit: n.smallestUnit,
|
|
1795
|
+
durationMaxUnits: n.maxUnits,
|
|
1796
|
+
prefix: n.prefix,
|
|
1797
|
+
suffix: n.suffix,
|
|
1798
|
+
negativeInParentheses: n.negativeStyle === "parentheses"
|
|
1799
|
+
};
|
|
1800
|
+
if (re(n))
|
|
1801
|
+
return {
|
|
1802
|
+
type: n.type,
|
|
1803
|
+
locale: n.locale,
|
|
1804
|
+
currency: n.type === "currency" ? n.currency : void 0,
|
|
1805
|
+
decimalPlaces: t != null && t.preserveOmittedProperties ? void 0 : Dt(
|
|
1806
|
+
n.minimumFractionDigits,
|
|
1807
|
+
n.maximumFractionDigits
|
|
1808
|
+
),
|
|
1809
|
+
minimumFractionDigits: n.minimumFractionDigits,
|
|
1810
|
+
maximumFractionDigits: n.maximumFractionDigits,
|
|
1811
|
+
useGrouping: n.useGrouping,
|
|
1812
|
+
prefix: n.prefix,
|
|
1813
|
+
suffix: n.suffix,
|
|
1814
|
+
useSuffix: !!n.compact,
|
|
1815
|
+
negativeInParentheses: n.negativeStyle === "parentheses",
|
|
1816
|
+
multiplyBy: n.type === "percent" ? n.scale ?? (n.percentValueMode === "whole" ? 1 : 100) : n.scale,
|
|
1817
|
+
percentValueMode: n.type === "percent" ? n.percentValueMode : void 0
|
|
1818
|
+
};
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
function po(e, t) {
|
|
1822
|
+
const n = Y(e, t);
|
|
1823
|
+
return (n == null ? void 0 : n.type) === "duration" ? {
|
|
1824
|
+
style: "duration",
|
|
1825
|
+
duration: {
|
|
1826
|
+
inputUnit: n.inputUnit,
|
|
1827
|
+
outputStyle: n.outputStyle,
|
|
1828
|
+
largestUnit: n.largestUnit,
|
|
1829
|
+
smallestUnit: n.smallestUnit,
|
|
1830
|
+
maxUnits: n.maxUnits
|
|
1831
|
+
},
|
|
1832
|
+
prefix: n.prefix,
|
|
1833
|
+
suffix: n.suffix,
|
|
1834
|
+
negativeStyle: n.negativeStyle,
|
|
1835
|
+
showDataBar: !1,
|
|
1836
|
+
dataBarColor: "#3b82f6",
|
|
1837
|
+
dataBarMinValue: void 0,
|
|
1838
|
+
dataBarMaxValue: void 0
|
|
1839
|
+
} : !n || !re(n) ? void 0 : {
|
|
1840
|
+
style: n.type === "currency" ? "currency" : n.type === "percent" ? "percent" : n.type === "scientific" ? "scientific" : "decimal",
|
|
1841
|
+
currency: n.type === "currency" && n.currency || (t != null && t.preserveOmittedProperties ? void 0 : "USD"),
|
|
1842
|
+
locale: n.locale || (t != null && t.preserveOmittedProperties ? void 0 : vn),
|
|
1843
|
+
minimumFractionDigits: n.minimumFractionDigits ?? (t != null && t.preserveOmittedProperties ? void 0 : 0),
|
|
1844
|
+
maximumFractionDigits: n.maximumFractionDigits ?? (t != null && t.preserveOmittedProperties ? void 0 : 2),
|
|
1845
|
+
useGrouping: typeof n.useGrouping == "boolean" ? n.useGrouping : !0,
|
|
1846
|
+
percentValueMode: n.type === "percent" ? n.percentValueMode || "fraction" : "whole",
|
|
1847
|
+
scale: n.scale,
|
|
1848
|
+
compact: n.compact,
|
|
1849
|
+
negativeStyle: n.negativeStyle,
|
|
1850
|
+
prefix: n.prefix,
|
|
1851
|
+
suffix: n.suffix,
|
|
1852
|
+
showDataBar: !1,
|
|
1853
|
+
dataBarColor: "#3b82f6",
|
|
1854
|
+
dataBarMinValue: void 0,
|
|
1855
|
+
dataBarMaxValue: void 0
|
|
1856
|
+
};
|
|
1857
|
+
}
|
|
1858
|
+
function yo(e) {
|
|
1859
|
+
const t = Y(e);
|
|
1860
|
+
if (!(!t || !re(t)))
|
|
1861
|
+
return {
|
|
1862
|
+
decimalPlaces: Dt(
|
|
1863
|
+
t.minimumFractionDigits,
|
|
1864
|
+
t.maximumFractionDigits
|
|
1865
|
+
),
|
|
1866
|
+
minimumFractionDigits: t.minimumFractionDigits,
|
|
1867
|
+
maximumFractionDigits: t.maximumFractionDigits,
|
|
1868
|
+
currency: t.type === "currency" ? t.currency : void 0,
|
|
1869
|
+
locale: t.locale,
|
|
1870
|
+
prefix: t.prefix,
|
|
1871
|
+
suffix: t.suffix || (t.type === "percent" ? "%" : void 0),
|
|
1872
|
+
useGrouping: t.useGrouping,
|
|
1873
|
+
percentValueMode: t.type === "percent" ? t.percentValueMode : void 0,
|
|
1874
|
+
enabled: !0
|
|
1875
|
+
};
|
|
1876
|
+
}
|
|
1877
|
+
function fe(e) {
|
|
1878
|
+
return (e == null ? void 0 : e.type) === "number" || (e == null ? void 0 : e.type) === "currency";
|
|
1879
|
+
}
|
|
1880
|
+
function Kt(e) {
|
|
1881
|
+
var n, i;
|
|
1882
|
+
const t = (i = (n = e.preferences) == null ? void 0 : n.formatNumber) == null ? void 0 : i.enabled;
|
|
1883
|
+
return t === !1 || t === "false";
|
|
1884
|
+
}
|
|
1885
|
+
function Di(e) {
|
|
1886
|
+
return (e == null ? void 0 : e.type) === "number";
|
|
1887
|
+
}
|
|
1888
|
+
function Mi(e) {
|
|
1889
|
+
var n;
|
|
1890
|
+
if (!Di(e))
|
|
1891
|
+
return !1;
|
|
1892
|
+
const t = (n = e == null ? void 0 : e.numberFormat) == null ? void 0 : n.style;
|
|
1893
|
+
return t === void 0 || t === "decimal" || t === "currency";
|
|
1894
|
+
}
|
|
1895
|
+
function Pi(e, t) {
|
|
1896
|
+
const n = t == null ? void 0 : t.type;
|
|
1897
|
+
if (n && n !== "none" && n !== "number")
|
|
1898
|
+
return { currencyBindable: !1 };
|
|
1899
|
+
const i = n === "number" ? t != null && t.numberFormat ? Pt(t.numberFormat, {
|
|
1900
|
+
preserveOmittedProperties: !0
|
|
1901
|
+
}) : { type: "number" } : void 0, r = Y(e.format, {
|
|
1902
|
+
preserveOmittedProperties: !0
|
|
1903
|
+
}), o = j(e.dataType) === "number" ? { type: "number" } : void 0, s = (t == null ? void 0 : t.inheritMetricFormat) === !1 || !!(t != null && t.numberFormat) && (t == null ? void 0 : t.inheritMetricFormat) !== !0 ? i : r || o || i;
|
|
1904
|
+
return {
|
|
1905
|
+
authoredFormat: s,
|
|
1906
|
+
currencyBindable: fe(s)
|
|
1907
|
+
};
|
|
1908
|
+
}
|
|
1909
|
+
function Ki(e, t) {
|
|
1910
|
+
var c, l;
|
|
1911
|
+
const n = Y(t.format, {
|
|
1912
|
+
preserveOmittedProperties: !0
|
|
1913
|
+
}), i = xi(
|
|
1914
|
+
(c = e.preferences) == null ? void 0 : c.numberAxisFormat
|
|
1915
|
+
), r = Kt(e) ? void 0 : Mt((l = e.preferences) == null ? void 0 : l.formatNumber), o = j(t.dataType) === "number" ? { type: "number" } : void 0, a = n || i || r || o;
|
|
1916
|
+
return {
|
|
1917
|
+
authoredFormat: a,
|
|
1918
|
+
source: n ? "semantic" : i ? "number_axis" : r ? "legacy" : o ? "inferred" : void 0,
|
|
1919
|
+
currencyBindable: fe(a)
|
|
1920
|
+
};
|
|
1921
|
+
}
|
|
1922
|
+
function ve(e, t = {}) {
|
|
1923
|
+
var f, y, p, d, h, b;
|
|
1924
|
+
const n = t.metricIndex ?? 0, i = !!((f = e.sql) != null && f.trim()), r = _i(
|
|
1925
|
+
(p = (y = e.preferences) == null ? void 0 : y.kpiVisualOptions) == null ? void 0 : p.formatOptions
|
|
1926
|
+
), o = n === 0 ? Mt((d = e.preferences) == null ? void 0 : d.formatNumber) : void 0, a = Kt(e);
|
|
1927
|
+
if (i) {
|
|
1928
|
+
const v = t.resultColumnKey ? {
|
|
1929
|
+
kind: "column",
|
|
1930
|
+
columnKey: t.resultColumnKey
|
|
1931
|
+
} : void 0;
|
|
1932
|
+
return {
|
|
1933
|
+
target: v,
|
|
1934
|
+
authoredFormat: r || o,
|
|
1935
|
+
currencyBindable: !a && !!v && fe(r)
|
|
1936
|
+
};
|
|
1937
|
+
}
|
|
1938
|
+
const s = (b = (h = e.config) == null ? void 0 : h.metricColumns) == null ? void 0 : b[n], c = s != null && s.id ? {
|
|
1939
|
+
kind: "metric",
|
|
1940
|
+
metricId: s.id
|
|
1941
|
+
} : void 0, l = Y(s == null ? void 0 : s.format, {
|
|
1942
|
+
preserveOmittedProperties: !0
|
|
1943
|
+
}), u = j(s == null ? void 0 : s.dataType) === "number" ? { type: "number" } : void 0, m = r || l || o || u;
|
|
1944
|
+
return {
|
|
1945
|
+
target: c,
|
|
1946
|
+
authoredFormat: m,
|
|
1947
|
+
currencyBindable: !a && ct(e.type) && !!c && fe(m)
|
|
1948
|
+
};
|
|
1949
|
+
}
|
|
1950
|
+
function kt(e, t = []) {
|
|
1951
|
+
const n = Fn(e);
|
|
1952
|
+
if (n.status !== "ready") return [];
|
|
1953
|
+
const { spec: i, presentation: r } = n.config, o = on(t);
|
|
1954
|
+
return i.measures.map((a) => {
|
|
1955
|
+
var p, d;
|
|
1956
|
+
const s = a.kind === "aggregate" ? o(a.field, i.source) : void 0, c = a.kind === "calculated" ? a.definition.format : ((p = a.field.derivedField) == null ? void 0 : p.format) ?? (s == null ? void 0 : s.format) ?? (s == null ? void 0 : s.resolvedField.format), l = In(r.measureFormats[a.id], c), u = a.kind === "calculated" ? a.definition.dataType : ["MIN", "MAX"].includes(a.aggregate) ? ((d = a.field.derivedField) == null ? void 0 : d.dataType) ?? (s == null ? void 0 : s.resolvedField.dataType) ?? a.field.dataType : "number", m = j(u) === "number", f = a.kind === "calculated" || !!(s || a.field.derivedField || a.field.name === "*"), y = l && re(l) ? l : !l && m && f ? { type: "number" } : void 0;
|
|
1957
|
+
return { measureId: a.id, label: Tn(a, r), canonical: y };
|
|
1958
|
+
});
|
|
1959
|
+
}
|
|
1960
|
+
function ki(e) {
|
|
1961
|
+
var t, n;
|
|
1962
|
+
return e.type === "detailTable" ? ((t = e.config) == null ? void 0 : t.detailColumns) || [] : ((n = e.config) == null ? void 0 : n.metricColumns) || [];
|
|
1963
|
+
}
|
|
1964
|
+
function Bi(e) {
|
|
1965
|
+
return new Set(
|
|
1966
|
+
gn(e).flatMap(
|
|
1967
|
+
(t) => (t.controlBindings || []).filter(ut).map((n) => n.controlId)
|
|
1968
|
+
)
|
|
1969
|
+
);
|
|
1970
|
+
}
|
|
1971
|
+
function Ai(e, t) {
|
|
1972
|
+
const n = [
|
|
1973
|
+
t.id,
|
|
1974
|
+
t.alias,
|
|
1975
|
+
t.label,
|
|
1976
|
+
t.name,
|
|
1977
|
+
t.qualifiedFieldName
|
|
1978
|
+
].filter((o) => !!o);
|
|
1979
|
+
for (const o of n)
|
|
1980
|
+
if (e[o])
|
|
1981
|
+
return e[o];
|
|
1982
|
+
const i = new Set(
|
|
1983
|
+
n.map((o) => o.trim().toLowerCase())
|
|
1984
|
+
), r = Object.entries(e).find(
|
|
1985
|
+
([o]) => i.has(o.trim().toLowerCase())
|
|
1986
|
+
);
|
|
1987
|
+
return r == null ? void 0 : r[1];
|
|
1988
|
+
}
|
|
1989
|
+
function nt(e) {
|
|
1990
|
+
return [
|
|
1991
|
+
...new Map(
|
|
1992
|
+
e.map((t) => [
|
|
1993
|
+
J(t),
|
|
1994
|
+
t
|
|
1995
|
+
])
|
|
1996
|
+
).values()
|
|
1997
|
+
];
|
|
1998
|
+
}
|
|
1999
|
+
function wi(e, t = [], n) {
|
|
2000
|
+
var O, K, A;
|
|
2001
|
+
const i = !!((O = e.sql) != null && O.trim()), r = ct(e.type), o = i && r && e.type !== "kpi" && e.type !== "matrixTable", a = ki(e), s = ((A = (K = e.preferences) == null ? void 0 : K.tablePrefs) == null ? void 0 : A.columnSettingsMap) || {}, c = !i && e.type === "kpi" ? a.map(
|
|
2002
|
+
(C, F) => ve(e, { metricIndex: F })
|
|
2003
|
+
) : [], l = !i && e.type === "matrixTable" ? kt(e, n) : [], u = (i ? [] : a).map(
|
|
2004
|
+
(C) => ({
|
|
2005
|
+
kind: "metric",
|
|
2006
|
+
metricId: C.id
|
|
2007
|
+
})
|
|
2008
|
+
), m = l.map(
|
|
2009
|
+
(C) => ({
|
|
2010
|
+
kind: "matrix_measure",
|
|
2011
|
+
measureId: C.measureId
|
|
2012
|
+
})
|
|
2013
|
+
), f = l.filter((C) => {
|
|
2014
|
+
var F, T;
|
|
2015
|
+
return ((F = C.canonical) == null ? void 0 : F.type) === "number" || ((T = C.canonical) == null ? void 0 : T.type) === "currency";
|
|
2016
|
+
}).map(
|
|
2017
|
+
(C) => ({
|
|
2018
|
+
kind: "matrix_measure",
|
|
2019
|
+
measureId: C.measureId
|
|
2020
|
+
})
|
|
2021
|
+
), y = e.type === "matrixTable" ? [] : e.type === "kpi" ? c.filter((C) => C.currencyBindable).flatMap(
|
|
2022
|
+
(C) => C.target ? [C.target] : []
|
|
2023
|
+
) : (i || !r ? [] : a).filter(
|
|
2024
|
+
(C) => (an(e.type) ? Pi(
|
|
2025
|
+
C,
|
|
2026
|
+
Ai(s, C)
|
|
2027
|
+
) : Ki(e, C)).currencyBindable
|
|
2028
|
+
).map(
|
|
2029
|
+
(C) => ({
|
|
2030
|
+
kind: "metric",
|
|
2031
|
+
metricId: C.id
|
|
2032
|
+
})
|
|
2033
|
+
), p = [...new Set(t)], d = (o ? p : []).map(
|
|
2034
|
+
(C) => ({
|
|
2035
|
+
kind: "column",
|
|
2036
|
+
columnKey: C
|
|
2037
|
+
})
|
|
2038
|
+
), h = (o ? p : []).filter(
|
|
2039
|
+
(C) => Mi(
|
|
2040
|
+
s[C]
|
|
2041
|
+
)
|
|
2042
|
+
).map(
|
|
2043
|
+
(C) => ({
|
|
2044
|
+
kind: "column",
|
|
2045
|
+
columnKey: C
|
|
2046
|
+
})
|
|
2047
|
+
), b = (i && e.type === "kpi" ? p.slice(0, 1) : []).map(
|
|
2048
|
+
(C) => ({
|
|
2049
|
+
kind: "column",
|
|
2050
|
+
columnKey: C
|
|
2051
|
+
})
|
|
2052
|
+
), v = i && e.type === "kpi" ? ve(e, {
|
|
2053
|
+
resultColumnKey: p[0]
|
|
2054
|
+
}) : void 0, x = r && (v != null && v.currencyBindable) ? b : [];
|
|
2055
|
+
return {
|
|
2056
|
+
knownTargets: nt([
|
|
2057
|
+
...e.type === "matrixTable" ? m : u,
|
|
2058
|
+
...d,
|
|
2059
|
+
...b
|
|
2060
|
+
]),
|
|
2061
|
+
eligibleTargets: nt([
|
|
2062
|
+
...y,
|
|
2063
|
+
...f,
|
|
2064
|
+
...h,
|
|
2065
|
+
...x
|
|
2066
|
+
])
|
|
2067
|
+
};
|
|
2068
|
+
}
|
|
2069
|
+
function go(e, t) {
|
|
2070
|
+
const n = ve(e, {
|
|
2071
|
+
resultColumnKey: t
|
|
2072
|
+
});
|
|
2073
|
+
return n.currencyBindable ? n.target : void 0;
|
|
2074
|
+
}
|
|
2075
|
+
function bo(e) {
|
|
2076
|
+
var t;
|
|
2077
|
+
return (t = e.card.sql) != null && t.trim() ? { kind: "column", columnKey: e.columnKey } : e.metricId ? { kind: "metric", metricId: e.metricId } : void 0;
|
|
2078
|
+
}
|
|
2079
|
+
function J(e) {
|
|
2080
|
+
return e.kind === "metric" ? `metric:${e.metricId}` : e.kind === "column" ? `column:${e.columnKey}` : `matrix_measure:${e.measureId}`;
|
|
2081
|
+
}
|
|
2082
|
+
function Oi(e) {
|
|
2083
|
+
if (!e || typeof e != "object" || Array.isArray(e))
|
|
2084
|
+
return;
|
|
2085
|
+
const t = e;
|
|
2086
|
+
if (t.kind === "metric" && typeof t.metricId == "string" && t.metricId.trim())
|
|
2087
|
+
return { kind: "metric", metricId: t.metricId };
|
|
2088
|
+
if (t.kind === "column" && typeof t.columnKey == "string" && t.columnKey.trim())
|
|
2089
|
+
return { kind: "column", columnKey: t.columnKey };
|
|
2090
|
+
if (t.kind === "matrix_measure" && typeof t.measureId == "string" && t.measureId.trim())
|
|
2091
|
+
return { kind: "matrix_measure", measureId: t.measureId };
|
|
2092
|
+
}
|
|
2093
|
+
function it(e) {
|
|
2094
|
+
const t = pt(e);
|
|
2095
|
+
return typeof e == "string" && e === t ? t : void 0;
|
|
2096
|
+
}
|
|
2097
|
+
function Bt(e) {
|
|
2098
|
+
if (e.type !== "enum" || e.source.kind !== "manual")
|
|
2099
|
+
return { diagnostic: "invalid_control_type" };
|
|
2100
|
+
const t = e.source.options.map(
|
|
2101
|
+
(n) => it(n.value)
|
|
2102
|
+
);
|
|
2103
|
+
if (t.length === 0 || t.some((n) => !n))
|
|
2104
|
+
return { diagnostic: "invalid_currency_option" };
|
|
2105
|
+
if (e.requiredAtExecution) {
|
|
2106
|
+
const n = e.initialValueStrategy === "saved_default" ? it(e.defaultValue) : void 0;
|
|
2107
|
+
if (!n || !t.includes(n))
|
|
2108
|
+
return { diagnostic: "invalid_control_default" };
|
|
2109
|
+
}
|
|
2110
|
+
return {
|
|
2111
|
+
control: e,
|
|
2112
|
+
currencies: t
|
|
2113
|
+
};
|
|
2114
|
+
}
|
|
2115
|
+
function ho(e) {
|
|
2116
|
+
return "control" in Bt(e);
|
|
2117
|
+
}
|
|
2118
|
+
function At(e) {
|
|
2119
|
+
const t = Bi(e.dashboard);
|
|
2120
|
+
if (t.size === 0)
|
|
2121
|
+
return {
|
|
2122
|
+
definitions: e.definitions || [],
|
|
2123
|
+
values: e.values || {}
|
|
2124
|
+
};
|
|
2125
|
+
const n = new Set(
|
|
2126
|
+
[...t].filter(
|
|
2127
|
+
(i) => !e.referencedControlIds.has(i)
|
|
2128
|
+
)
|
|
2129
|
+
);
|
|
2130
|
+
return {
|
|
2131
|
+
definitions: (e.definitions || []).filter(
|
|
2132
|
+
(i) => !n.has(i.id)
|
|
2133
|
+
),
|
|
2134
|
+
values: Object.fromEntries(
|
|
2135
|
+
Object.entries(e.values || {}).filter(
|
|
2136
|
+
([i]) => !n.has(i)
|
|
2137
|
+
)
|
|
2138
|
+
)
|
|
2139
|
+
};
|
|
2140
|
+
}
|
|
2141
|
+
function Co(e) {
|
|
2142
|
+
return At({
|
|
2143
|
+
...e,
|
|
2144
|
+
referencedControlIds: new Set(
|
|
2145
|
+
Ct({
|
|
2146
|
+
sql: e.filterSql,
|
|
2147
|
+
controlBindings: []
|
|
2148
|
+
})
|
|
2149
|
+
)
|
|
2150
|
+
});
|
|
2151
|
+
}
|
|
2152
|
+
function vo(e) {
|
|
2153
|
+
var t;
|
|
2154
|
+
return At({
|
|
2155
|
+
...e,
|
|
2156
|
+
referencedControlIds: new Set(
|
|
2157
|
+
Ct({
|
|
2158
|
+
sql: (t = e.source) == null ? void 0 : t.sql,
|
|
2159
|
+
controlBindings: []
|
|
2160
|
+
})
|
|
2161
|
+
)
|
|
2162
|
+
});
|
|
2163
|
+
}
|
|
2164
|
+
function wt(e) {
|
|
2165
|
+
return {
|
|
2166
|
+
knownKeys: new Set(
|
|
2167
|
+
e.knownTargets.map(J)
|
|
2168
|
+
),
|
|
2169
|
+
eligibleKeys: new Set(
|
|
2170
|
+
e.eligibleTargets.map(J)
|
|
2171
|
+
),
|
|
2172
|
+
controlsById: new Map(
|
|
2173
|
+
(e.controls || []).map((t) => [t.id, t])
|
|
2174
|
+
)
|
|
2175
|
+
};
|
|
2176
|
+
}
|
|
2177
|
+
function Ot(e, t) {
|
|
2178
|
+
if (!e || typeof e != "object" || e.target !== "presentation_currency")
|
|
2179
|
+
return {};
|
|
2180
|
+
const n = e, i = typeof n.controlId == "string" && n.controlId.trim() ? n.controlId : void 0;
|
|
2181
|
+
if (!i)
|
|
2182
|
+
return { diagnostic: { code: "invalid_binding_shape" } };
|
|
2183
|
+
const r = Oi(
|
|
2184
|
+
n.presentationTarget
|
|
2185
|
+
);
|
|
2186
|
+
if (!r)
|
|
2187
|
+
return {
|
|
2188
|
+
diagnostic: { code: "missing_target", controlId: i }
|
|
2189
|
+
};
|
|
2190
|
+
const o = J(r);
|
|
2191
|
+
if (!t.knownKeys.has(o))
|
|
2192
|
+
return {
|
|
2193
|
+
diagnostic: { code: "stale_target", controlId: i }
|
|
2194
|
+
};
|
|
2195
|
+
if (!t.eligibleKeys.has(o))
|
|
2196
|
+
return {
|
|
2197
|
+
diagnostic: { code: "inapplicable_target", controlId: i }
|
|
2198
|
+
};
|
|
2199
|
+
const a = t.controlsById.get(i);
|
|
2200
|
+
if (!a)
|
|
2201
|
+
return {
|
|
2202
|
+
diagnostic: { code: "missing_control", controlId: i }
|
|
2203
|
+
};
|
|
2204
|
+
const s = Bt(a);
|
|
2205
|
+
return "diagnostic" in s ? {
|
|
2206
|
+
diagnostic: { code: s.diagnostic, controlId: i }
|
|
2207
|
+
} : {
|
|
2208
|
+
binding: {
|
|
2209
|
+
controlId: i,
|
|
2210
|
+
presentationTarget: r,
|
|
2211
|
+
control: s.control,
|
|
2212
|
+
currencies: s.currencies
|
|
2213
|
+
}
|
|
2214
|
+
};
|
|
2215
|
+
}
|
|
2216
|
+
function Io(e) {
|
|
2217
|
+
const t = wt(e);
|
|
2218
|
+
return (e.bindings || []).flatMap((n) => {
|
|
2219
|
+
const i = Ot(n, t);
|
|
2220
|
+
return "diagnostic" in i ? [i.diagnostic] : [];
|
|
2221
|
+
});
|
|
2222
|
+
}
|
|
2223
|
+
function Ni(e) {
|
|
2224
|
+
var r;
|
|
2225
|
+
const t = [], n = J(e.target), i = wt(e);
|
|
2226
|
+
for (const o of e.bindings || []) {
|
|
2227
|
+
const a = Ot(o, i);
|
|
2228
|
+
if ("diagnostic" in a) {
|
|
2229
|
+
t.push(a.diagnostic);
|
|
2230
|
+
continue;
|
|
2231
|
+
}
|
|
2232
|
+
const s = a.binding;
|
|
2233
|
+
if (!s || J(
|
|
2234
|
+
s.presentationTarget
|
|
2235
|
+
) !== n) continue;
|
|
2236
|
+
const l = pt(
|
|
2237
|
+
(r = e.values) == null ? void 0 : r[s.control.id]
|
|
2238
|
+
);
|
|
2239
|
+
if (!(!l || !s.currencies.includes(l)))
|
|
2240
|
+
return { currency: l, diagnostics: t };
|
|
2241
|
+
}
|
|
2242
|
+
return { diagnostics: t };
|
|
2243
|
+
}
|
|
2244
|
+
function Fo(e, t, n, i) {
|
|
2245
|
+
const r = { ...e, config: { ...e.config, matrix: t } }, o = wi(r, [], i), a = kt(r, i), s = { ...t.presentation.measureFormats };
|
|
2246
|
+
for (const c of a) {
|
|
2247
|
+
const l = { kind: "matrix_measure", measureId: c.measureId }, { currency: u } = Ni({
|
|
2248
|
+
...n,
|
|
2249
|
+
...o,
|
|
2250
|
+
bindings: e.controlBindings,
|
|
2251
|
+
target: l
|
|
2252
|
+
});
|
|
2253
|
+
if (!u || !c.canonical) continue;
|
|
2254
|
+
const { locale: m, ...f } = c.canonical;
|
|
2255
|
+
s[c.measureId] = { ...f, type: "currency", currency: u };
|
|
2256
|
+
}
|
|
2257
|
+
return { ...t.presentation, measureFormats: s };
|
|
2258
|
+
}
|
|
2259
|
+
function Ei(e, t) {
|
|
2260
|
+
if (!e || typeof e != "object" || !("kind" in e))
|
|
2261
|
+
return e;
|
|
2262
|
+
switch (e.kind) {
|
|
2263
|
+
case "manual":
|
|
2264
|
+
return {
|
|
2265
|
+
kind: "manual",
|
|
2266
|
+
...t != null && t.includePresentation ? {
|
|
2267
|
+
options: e.options.map((n) => ({
|
|
2268
|
+
value: n.value,
|
|
2269
|
+
label: n.label,
|
|
2270
|
+
presentation: n.presentation
|
|
2271
|
+
}))
|
|
2272
|
+
} : {
|
|
2273
|
+
optionValues: e.options.map((n) => n.value).sort()
|
|
2274
|
+
}
|
|
2275
|
+
};
|
|
2276
|
+
case "dataset_values":
|
|
2277
|
+
return {
|
|
2278
|
+
kind: "dataset_values",
|
|
2279
|
+
fieldId: e.fieldId,
|
|
2280
|
+
connectionId: e.connectionId || ""
|
|
2281
|
+
};
|
|
2282
|
+
case "field_allowlist":
|
|
2283
|
+
return {
|
|
2284
|
+
kind: "field_allowlist",
|
|
2285
|
+
fieldIds: [...e.fieldIds].sort()
|
|
2286
|
+
};
|
|
2287
|
+
case "metric_allowlist":
|
|
2288
|
+
return {
|
|
2289
|
+
kind: "metric_allowlist",
|
|
2290
|
+
metricIds: [...e.metricIds].sort()
|
|
2291
|
+
};
|
|
2292
|
+
case "sql_query":
|
|
2293
|
+
return {
|
|
2294
|
+
kind: "sql_query",
|
|
2295
|
+
connectionId: e.connectionId,
|
|
2296
|
+
sql: e.sql,
|
|
2297
|
+
valueColumn: e.valueColumn,
|
|
2298
|
+
labelColumn: e.labelColumn
|
|
2299
|
+
};
|
|
2300
|
+
default:
|
|
2301
|
+
return e;
|
|
2302
|
+
}
|
|
2303
|
+
}
|
|
2304
|
+
function Ri(e, t) {
|
|
2305
|
+
return {
|
|
2306
|
+
id: e.id,
|
|
2307
|
+
scope: e.scope,
|
|
2308
|
+
type: e.type,
|
|
2309
|
+
source: Ei(e.source, t),
|
|
2310
|
+
initialValueStrategy: e.initialValueStrategy,
|
|
2311
|
+
defaultValue: e.defaultValue,
|
|
2312
|
+
requiredAtExecution: e.requiredAtExecution,
|
|
2313
|
+
...t != null && t.includePresentation ? {
|
|
2314
|
+
label: e.label,
|
|
2315
|
+
helpText: e.helpText,
|
|
2316
|
+
hidden: e.hidden,
|
|
2317
|
+
locked: e.locked,
|
|
2318
|
+
placement: e.placement,
|
|
2319
|
+
showLabel: e.showLabel,
|
|
2320
|
+
toolbarWidth: e.toolbarWidth
|
|
2321
|
+
} : {}
|
|
2322
|
+
};
|
|
2323
|
+
}
|
|
2324
|
+
function $i(e, t) {
|
|
2325
|
+
return e.target === "sql_param" || e.target === "presentation_currency" ? e : e.target === "config_field_selector" && !(t != null && t.includePresentation) ? {
|
|
2326
|
+
...e,
|
|
2327
|
+
mapping: Object.fromEntries(
|
|
2328
|
+
Object.entries(e.mapping).sort(([n], [i]) => n.localeCompare(i)).map(([n, i]) => {
|
|
2329
|
+
if ("kind" in i) return [n, i];
|
|
2330
|
+
const r = { ...i };
|
|
2331
|
+
return delete r.format, delete r.dateFormat, delete r.customFormat, delete r.semanticTemporalPresentation, [n, r];
|
|
2332
|
+
})
|
|
2333
|
+
)
|
|
2334
|
+
} : {
|
|
2335
|
+
...e,
|
|
2336
|
+
mapping: Object.fromEntries(
|
|
2337
|
+
Object.entries(e.mapping).sort(([n], [i]) => n.localeCompare(i)).map(([n, i]) => [
|
|
2338
|
+
n,
|
|
2339
|
+
i && typeof i == "object" && !Array.isArray(i) ? Object.fromEntries(
|
|
2340
|
+
Object.entries(i).sort(
|
|
2341
|
+
([r], [o]) => r.localeCompare(o)
|
|
2342
|
+
)
|
|
2343
|
+
) : i
|
|
2344
|
+
])
|
|
2345
|
+
)
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
function rt(e = [], t) {
|
|
2349
|
+
return [...e].map((n) => Ri(n, t)).sort(
|
|
2350
|
+
(n, i) => n.id.localeCompare(i.id) || n.scope.localeCompare(i.scope) || n.type.localeCompare(i.type)
|
|
2351
|
+
);
|
|
2352
|
+
}
|
|
2353
|
+
function Li(e = [], t) {
|
|
2354
|
+
return e.filter(
|
|
2355
|
+
(n) => (t == null ? void 0 : t.includePresentation) || !ut(n)
|
|
2356
|
+
).map((n) => $i(n, t)).sort(
|
|
2357
|
+
(n, i) => w(n).localeCompare(w(i))
|
|
2358
|
+
);
|
|
2359
|
+
}
|
|
2360
|
+
function zi(e, t) {
|
|
2361
|
+
return e ? w({
|
|
2362
|
+
controlDefinitions: rt(e.controlDefinitions, t),
|
|
2363
|
+
cardControlDefinitions: rt(
|
|
2364
|
+
e.cardControlDefinitions,
|
|
2365
|
+
t
|
|
2366
|
+
),
|
|
2367
|
+
controlBindings: Li(e.controlBindings, t)
|
|
2368
|
+
}) : "__none__";
|
|
2369
|
+
}
|
|
2370
|
+
const qi = ["table", "detailTable"], ot = (e) => qi.includes(e.type), Vi = "calendar-context";
|
|
2371
|
+
function ji(e) {
|
|
2372
|
+
const { id: t, label: n, field: i, ...r } = e;
|
|
2373
|
+
return {
|
|
2374
|
+
...r,
|
|
2375
|
+
field: ke(
|
|
2376
|
+
i
|
|
2377
|
+
)
|
|
2378
|
+
};
|
|
2379
|
+
}
|
|
2380
|
+
function ge(e) {
|
|
2381
|
+
if (!e)
|
|
2382
|
+
return;
|
|
2383
|
+
const { id: t, conditions: n, groups: i, ...r } = e;
|
|
2384
|
+
return {
|
|
2385
|
+
...r,
|
|
2386
|
+
conditions: n.map(ji),
|
|
2387
|
+
groups: i.map((o) => ge(o))
|
|
2388
|
+
};
|
|
2389
|
+
}
|
|
2390
|
+
function ke(e) {
|
|
2391
|
+
var i, r;
|
|
2392
|
+
const { label: t, ...n } = e;
|
|
2393
|
+
return {
|
|
2394
|
+
...n,
|
|
2395
|
+
...(i = e.calculatedFormula) != null && i.inputFields ? {
|
|
2396
|
+
calculatedFormula: {
|
|
2397
|
+
...e.calculatedFormula,
|
|
2398
|
+
inputFields: e.calculatedFormula.inputFields.map(
|
|
2399
|
+
ke
|
|
2400
|
+
)
|
|
2401
|
+
}
|
|
2402
|
+
} : {},
|
|
2403
|
+
...(r = e.parameters) != null && r.filters ? {
|
|
2404
|
+
parameters: {
|
|
2405
|
+
...e.parameters,
|
|
2406
|
+
filters: ge(
|
|
2407
|
+
e.parameters.filters
|
|
2408
|
+
)
|
|
2409
|
+
}
|
|
2410
|
+
} : {}
|
|
2411
|
+
};
|
|
2412
|
+
}
|
|
2413
|
+
function Ui(e) {
|
|
2414
|
+
const t = (n) => n == null ? void 0 : n.map(ke);
|
|
2415
|
+
return {
|
|
2416
|
+
...e,
|
|
2417
|
+
groupByColumns: t(e.groupByColumns),
|
|
2418
|
+
metricColumns: t(e.metricColumns),
|
|
2419
|
+
pivotByColumns: t(e.pivotByColumns),
|
|
2420
|
+
sortByColumns: t(e.sortByColumns),
|
|
2421
|
+
detailColumns: t(e.detailColumns),
|
|
2422
|
+
filters: e.filters ? ge(e.filters) : void 0
|
|
2423
|
+
};
|
|
2424
|
+
}
|
|
2425
|
+
function Gi(e, t, n) {
|
|
2426
|
+
if (!e)
|
|
2427
|
+
return JSON.stringify(e);
|
|
2428
|
+
if (n === "matrixTable" && e.matrix) return w(xn(e.matrix.spec));
|
|
2429
|
+
const { matrix: i, ...r } = e, o = t ? Ui(r) : r;
|
|
2430
|
+
return JSON.stringify({
|
|
2431
|
+
...o,
|
|
2432
|
+
filters: ge(o.filters)
|
|
2433
|
+
});
|
|
2434
|
+
}
|
|
2435
|
+
function Qi(e) {
|
|
2436
|
+
if (!e)
|
|
2437
|
+
return null;
|
|
2438
|
+
const { format: t, ...n } = e;
|
|
2439
|
+
return n;
|
|
2440
|
+
}
|
|
2441
|
+
function Hi(e, t) {
|
|
2442
|
+
const n = /* @__PURE__ */ new Map();
|
|
2443
|
+
for (const r of (t == null ? void 0 : t.controlDefinitions) || [])
|
|
2444
|
+
n.set(r.id, r.type);
|
|
2445
|
+
for (const r of (t == null ? void 0 : t.cardControlDefinitions) || [])
|
|
2446
|
+
n.set(r.id, r.type);
|
|
2447
|
+
const i = Object.fromEntries(
|
|
2448
|
+
Object.entries(e || {}).map(([r, o]) => n.get(r) === "multi_enum" && Array.isArray(o) ? [
|
|
2449
|
+
r,
|
|
2450
|
+
[...o].sort(
|
|
2451
|
+
(a, s) => w(a).localeCompare(w(s))
|
|
2452
|
+
)
|
|
2453
|
+
] : [r, o])
|
|
2454
|
+
);
|
|
2455
|
+
return w(i);
|
|
2456
|
+
}
|
|
2457
|
+
function Ji(e, {
|
|
2458
|
+
finalFiltersKey: t,
|
|
2459
|
+
cardFilterValues: n,
|
|
2460
|
+
controlValues: i,
|
|
2461
|
+
controlDefinitions: r,
|
|
2462
|
+
cardControlDefinitions: o,
|
|
2463
|
+
controlBindings: a,
|
|
2464
|
+
queryRelevantConfig: s,
|
|
2465
|
+
resolvedPrimaryDateField: c,
|
|
2466
|
+
globalDateComparison: l,
|
|
2467
|
+
calendarContext: u
|
|
2468
|
+
}) {
|
|
2469
|
+
const { filterColumns: m, ...f } = e.queryConfig || {}, y = m == null ? void 0 : m.filter(
|
|
2470
|
+
(x) => {
|
|
2471
|
+
var O, K;
|
|
2472
|
+
return (K = (O = e.queryConfig) == null ? void 0 : O.filters) == null ? void 0 : K.some((A) => A.filterColumnName === x.name);
|
|
2473
|
+
}
|
|
2474
|
+
), p = (e == null ? void 0 : e.sql) || "", d = sn((e == null ? void 0 : e.python) || ""), h = e.type === "pivotTable" ? "pivotTable" : ["table", "aggregateTable", "detailTable", "matrixTable"].includes(
|
|
2475
|
+
e.type
|
|
2476
|
+
) ? "table" : e.type === "kpi" ? "kpi" : "chart", b = s || Ii(e.config, { cardType: e.type }), v = ln.includes(
|
|
2477
|
+
e.type
|
|
2478
|
+
);
|
|
2479
|
+
return [
|
|
2480
|
+
"query",
|
|
2481
|
+
e == null ? void 0 : e.id,
|
|
2482
|
+
h,
|
|
2483
|
+
p,
|
|
2484
|
+
d,
|
|
2485
|
+
JSON.stringify(n),
|
|
2486
|
+
Hi(i, {
|
|
2487
|
+
controlDefinitions: r,
|
|
2488
|
+
cardControlDefinitions: o
|
|
2489
|
+
}),
|
|
2490
|
+
zi({
|
|
2491
|
+
controlDefinitions: r,
|
|
2492
|
+
cardControlDefinitions: o,
|
|
2493
|
+
controlBindings: a
|
|
2494
|
+
}),
|
|
2495
|
+
w(
|
|
2496
|
+
Qi(c)
|
|
2497
|
+
),
|
|
2498
|
+
w(l ?? null),
|
|
2499
|
+
Vi,
|
|
2500
|
+
w(u),
|
|
2501
|
+
JSON.stringify(f),
|
|
2502
|
+
JSON.stringify(y),
|
|
2503
|
+
Gi(
|
|
2504
|
+
b,
|
|
2505
|
+
v,
|
|
2506
|
+
e.type
|
|
2507
|
+
),
|
|
2508
|
+
t
|
|
2509
|
+
];
|
|
2510
|
+
}
|
|
2511
|
+
function Yi(e, t, n) {
|
|
2512
|
+
var s, c, l;
|
|
2513
|
+
const i = Ji(e, t), r = w(i), o = ((s = n == null ? void 0 : n.resolvePaginationConfig) == null ? void 0 : s.call(n, r)) ?? e.paginationConfig, a = ot(e) && dt(e.config) || ot(e) && e.sql && ((l = (c = e.preferences) == null ? void 0 : c.tablePrefs) == null ? void 0 : l.enableDevModePagination);
|
|
2514
|
+
return {
|
|
2515
|
+
queryKey: [
|
|
2516
|
+
...i,
|
|
2517
|
+
a ? JSON.stringify(o) : ""
|
|
2518
|
+
],
|
|
2519
|
+
queryInputIdentity: r,
|
|
2520
|
+
paginationConfig: o
|
|
2521
|
+
};
|
|
2522
|
+
}
|
|
2523
|
+
function To(e, t, n, i) {
|
|
2524
|
+
return Yi(
|
|
2525
|
+
e,
|
|
2526
|
+
{
|
|
2527
|
+
finalFiltersKey: t.finalFiltersKey,
|
|
2528
|
+
cardFilterValues: t.cardFilterValues,
|
|
2529
|
+
controlValues: t.controlValues,
|
|
2530
|
+
controlDefinitions: t.controlDefinitions,
|
|
2531
|
+
cardControlDefinitions: t.cardControlDefinitions,
|
|
2532
|
+
controlBindings: t.controlBindings,
|
|
2533
|
+
queryRelevantConfig: t.queryRelevantConfig,
|
|
2534
|
+
resolvedPrimaryDateField: t.resolvedPrimaryDateField || void 0,
|
|
2535
|
+
globalDateComparison: t.globalDateComparison,
|
|
2536
|
+
calendarContext: n
|
|
2537
|
+
},
|
|
2538
|
+
i
|
|
2539
|
+
);
|
|
2540
|
+
}
|
|
2541
|
+
function Nt(e) {
|
|
2542
|
+
const t = {
|
|
2543
|
+
...xe,
|
|
2544
|
+
...e.presentation
|
|
2545
|
+
}, n = t.displayMode, {
|
|
2546
|
+
bookkeepingKeys: i,
|
|
2547
|
+
comparisonColumnKeys: r,
|
|
2548
|
+
deltaColumnKeys: o,
|
|
2549
|
+
percentChangeColumnKeys: a,
|
|
2550
|
+
ratioColumnKeys: s
|
|
2551
|
+
} = _t(e.comparisonMetadata), c = /* @__PURE__ */ new Set();
|
|
2552
|
+
t.showComparison && (n === "difference" || n === "both") && o.forEach((f) => c.add(f)), t.showComparison && (n === "percent_change" || n === "both") && a.forEach((f) => c.add(f)), t.showComparison && n === "ratio" && s.forEach((f) => c.add(f));
|
|
2553
|
+
const l = new Set(i);
|
|
2554
|
+
t.showComparison || r.forEach((f) => l.add(f)), [o, a, s].forEach(
|
|
2555
|
+
(f) => f.forEach((y) => {
|
|
2556
|
+
c.has(y) || l.add(y);
|
|
2557
|
+
})
|
|
2558
|
+
);
|
|
2559
|
+
const u = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
|
|
2560
|
+
return Object.entries(e.comparisonMetadata || {}).forEach(
|
|
2561
|
+
([f, y]) => {
|
|
2562
|
+
var b;
|
|
2563
|
+
const p = y.output;
|
|
2564
|
+
if (!p || p.outputId !== f || p.availability.status !== "available")
|
|
2565
|
+
return;
|
|
2566
|
+
const d = ((b = e.resolveMetricName) == null ? void 0 : b.call(e, {
|
|
2567
|
+
metricId: p.metricId,
|
|
2568
|
+
metricAlias: p.metricAlias
|
|
2569
|
+
})) || y.displayName || p.metricId, h = y.displayLabel || "Comparison";
|
|
2570
|
+
p.comparisonColumnKey && (u.set(
|
|
2571
|
+
p.comparisonColumnKey,
|
|
2572
|
+
`${d} (${h})`
|
|
2573
|
+
), m.set(p.comparisonColumnKey, {
|
|
2574
|
+
metricId: p.metricId,
|
|
2575
|
+
metricAlias: p.metricAlias,
|
|
2576
|
+
kind: "comparison"
|
|
2577
|
+
})), p.deltaColumnKey && c.has(p.deltaColumnKey) && (u.set(p.deltaColumnKey, `${d} Difference`), m.set(p.deltaColumnKey, {
|
|
2578
|
+
metricId: p.metricId,
|
|
2579
|
+
metricAlias: p.metricAlias,
|
|
2580
|
+
kind: "delta"
|
|
2581
|
+
})), p.percentChangeColumnKey && c.has(p.percentChangeColumnKey) && (u.set(
|
|
2582
|
+
p.percentChangeColumnKey,
|
|
2583
|
+
`${d} Percent Change`
|
|
2584
|
+
), m.set(p.percentChangeColumnKey, {
|
|
2585
|
+
metricId: p.metricId,
|
|
2586
|
+
metricAlias: p.metricAlias,
|
|
2587
|
+
kind: "percent_change"
|
|
2588
|
+
})), p.ratioColumnKey && c.has(p.ratioColumnKey) && (u.set(
|
|
2589
|
+
p.ratioColumnKey,
|
|
2590
|
+
`${d} Ratio (current ÷ comparison)`
|
|
2591
|
+
), m.set(p.ratioColumnKey, {
|
|
2592
|
+
metricId: p.metricId,
|
|
2593
|
+
metricAlias: p.metricAlias,
|
|
2594
|
+
kind: "ratio"
|
|
2595
|
+
}));
|
|
2596
|
+
}
|
|
2597
|
+
), {
|
|
2598
|
+
excludedKeys: l,
|
|
2599
|
+
selectedDerivedKeys: c,
|
|
2600
|
+
columnLabels: u,
|
|
2601
|
+
columnPresentationOwners: m
|
|
2602
|
+
};
|
|
2603
|
+
}
|
|
2604
|
+
function _o(e) {
|
|
2605
|
+
var t, n;
|
|
2606
|
+
return Nt({
|
|
2607
|
+
comparisonMetadata: e.comparisonMetadata,
|
|
2608
|
+
presentation: (n = (t = e.card) == null ? void 0 : t.preferences) == null ? void 0 : n.comparisonPresentation,
|
|
2609
|
+
resolveMetricName: ({ metricId: i, metricAlias: r }) => {
|
|
2610
|
+
var o;
|
|
2611
|
+
return (o = ye({
|
|
2612
|
+
card: e.card,
|
|
2613
|
+
columnKeyMap: e.columnKeyMap,
|
|
2614
|
+
metricId: i,
|
|
2615
|
+
metricAlias: r
|
|
2616
|
+
})) == null ? void 0 : o.label;
|
|
2617
|
+
}
|
|
2618
|
+
});
|
|
2619
|
+
}
|
|
2620
|
+
function xo(e) {
|
|
2621
|
+
var n;
|
|
2622
|
+
return (((n = e.card.config) == null ? void 0 : n.metricColumns) || []).filter(
|
|
2623
|
+
(i) => {
|
|
2624
|
+
var r;
|
|
2625
|
+
return ((r = i.comparison) == null ? void 0 : r.mode) === "explicit";
|
|
2626
|
+
}
|
|
2627
|
+
).some(
|
|
2628
|
+
(i) => !De(e.comparisonMetadata, i)
|
|
2629
|
+
);
|
|
2630
|
+
}
|
|
2631
|
+
function Be(e) {
|
|
2632
|
+
const t = e.config ?? {};
|
|
2633
|
+
return e.type === "detailTable" ? [{ role: "detail", fields: t.detailColumns ?? [] }] : [
|
|
2634
|
+
{ role: "groupby", fields: t.groupByColumns ?? [] },
|
|
2635
|
+
{ role: "metric", fields: t.metricColumns ?? [] },
|
|
2636
|
+
{ role: "detail", fields: t.detailColumns ?? [] }
|
|
2637
|
+
];
|
|
2638
|
+
}
|
|
2639
|
+
function Ae(e, t) {
|
|
2640
|
+
if (e.id)
|
|
2641
|
+
return t === "metric" ? {
|
|
2642
|
+
kind: "metric",
|
|
2643
|
+
metricId: e.id,
|
|
2644
|
+
metricAlias: E(e)
|
|
2645
|
+
} : { kind: "dimension", role: t, fieldId: e.id };
|
|
2646
|
+
}
|
|
2647
|
+
function at(e) {
|
|
2648
|
+
const t = /* @__PURE__ */ new Map();
|
|
2649
|
+
for (const n of e) t.set(n, (t.get(n) ?? 0) + 1);
|
|
2650
|
+
return t;
|
|
2651
|
+
}
|
|
2652
|
+
function Wi(e, t) {
|
|
2653
|
+
var m, f;
|
|
2654
|
+
const n = [...t.keys], i = new Set(n), r = t.columnKeyMap, o = Be(e).flatMap(
|
|
2655
|
+
({ role: y, fields: p }) => p.flatMap((d) => {
|
|
2656
|
+
const h = Ae(d, y);
|
|
2657
|
+
return h ? [
|
|
2658
|
+
{
|
|
2659
|
+
identity: h,
|
|
2660
|
+
columnId: q(h),
|
|
2661
|
+
field: d,
|
|
2662
|
+
// Identity comes from result metadata (PLAN B2): no key map, no address.
|
|
2663
|
+
outputKey: r ? oe(d, y, n, r) : void 0
|
|
2664
|
+
}
|
|
2665
|
+
] : [];
|
|
2666
|
+
})
|
|
2667
|
+
), a = at(o.map((y) => y.columnId)), s = at(
|
|
2668
|
+
o.flatMap(
|
|
2669
|
+
(y) => y.outputKey ? [y.outputKey] : []
|
|
2670
|
+
)
|
|
2671
|
+
), c = /* @__PURE__ */ new Map(), l = /* @__PURE__ */ new Map();
|
|
2672
|
+
for (const y of o) {
|
|
2673
|
+
if (a.get(y.columnId) !== 1) continue;
|
|
2674
|
+
const p = y.outputKey && s.get(y.outputKey) === 1 ? y.outputKey : void 0;
|
|
2675
|
+
c.set(y.columnId, {
|
|
2676
|
+
columnId: y.columnId,
|
|
2677
|
+
identity: y.identity,
|
|
2678
|
+
field: y.field,
|
|
2679
|
+
baseKey: p,
|
|
2680
|
+
// Today's header for the column's own key; a metric shown only as pivot
|
|
2681
|
+
// members is named by its field.
|
|
2682
|
+
authorLabel: p ? St(p, e, r) ?? p : y.field.label || y.field.name || y.columnId
|
|
2683
|
+
}), p && l.set(p, { columnId: y.columnId, part: "base" });
|
|
2684
|
+
}
|
|
2685
|
+
const u = e.config;
|
|
2686
|
+
if (e.type === "table" && ((m = u == null ? void 0 : u.pivotByColumns) != null && m.length) && ((f = t.columns) != null && f.length)) {
|
|
2687
|
+
const y = e;
|
|
2688
|
+
for (const p of t.columns) {
|
|
2689
|
+
if (!p.pivotIdentity || !i.has(p.key) || l.has(p.key))
|
|
2690
|
+
continue;
|
|
2691
|
+
const d = Pe({
|
|
2692
|
+
resultColumn: p,
|
|
2693
|
+
card: y,
|
|
2694
|
+
columnKeyMap: r
|
|
2695
|
+
});
|
|
2696
|
+
if (!d) continue;
|
|
2697
|
+
const h = {
|
|
2698
|
+
kind: "metric",
|
|
2699
|
+
metricId: d.identity.metricId,
|
|
2700
|
+
metricAlias: d.identity.metricAlias
|
|
2701
|
+
}, b = q(h);
|
|
2702
|
+
if (d.authoredMetric) {
|
|
2703
|
+
if (!c.has(b))
|
|
2704
|
+
continue;
|
|
2705
|
+
} else {
|
|
2706
|
+
if (d.identity.metricId !== _e)
|
|
2707
|
+
continue;
|
|
2708
|
+
c.has(b) || c.set(b, { columnId: b, identity: h, authorLabel: "Count" });
|
|
2709
|
+
}
|
|
2710
|
+
l.set(p.key, { columnId: b, part: "pivot-member" });
|
|
2711
|
+
}
|
|
2712
|
+
}
|
|
2713
|
+
for (const [y, p] of Object.entries(
|
|
2714
|
+
t.comparisonMetadata ?? {}
|
|
2715
|
+
)) {
|
|
2716
|
+
const d = p.output;
|
|
2717
|
+
if (d.outputId !== y || d.availability.status !== "available")
|
|
2718
|
+
continue;
|
|
2719
|
+
const h = q({
|
|
2720
|
+
kind: "metric",
|
|
2721
|
+
metricId: d.metricId,
|
|
2722
|
+
metricAlias: d.metricAlias
|
|
2723
|
+
});
|
|
2724
|
+
if (c.has(h))
|
|
2725
|
+
for (const b of [
|
|
2726
|
+
d.comparisonColumnKey,
|
|
2727
|
+
d.deltaColumnKey,
|
|
2728
|
+
d.percentChangeColumnKey,
|
|
2729
|
+
d.ratioColumnKey
|
|
2730
|
+
])
|
|
2731
|
+
b && !l.has(b) && l.set(b, { columnId: h, part: "comparison" });
|
|
2732
|
+
}
|
|
2733
|
+
return { entries: c, owners: l };
|
|
2734
|
+
}
|
|
2735
|
+
function Xi(e) {
|
|
2736
|
+
const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
|
|
2737
|
+
for (const i of e.keys) {
|
|
2738
|
+
const r = { kind: "result", key: i }, o = q(r);
|
|
2739
|
+
t.set(o, {
|
|
2740
|
+
columnId: o,
|
|
2741
|
+
identity: r,
|
|
2742
|
+
baseKey: i,
|
|
2743
|
+
authorLabel: i
|
|
2744
|
+
}), n.set(i, { columnId: o, part: "base" });
|
|
2745
|
+
}
|
|
2746
|
+
return { entries: t, owners: n };
|
|
2747
|
+
}
|
|
2748
|
+
function So(e) {
|
|
2749
|
+
const t = /* @__PURE__ */ new Set();
|
|
2750
|
+
for (const n of e ?? [])
|
|
2751
|
+
if (n && typeof n == "object")
|
|
2752
|
+
for (const i of Object.keys(n)) t.add(i);
|
|
2753
|
+
return [...t];
|
|
2754
|
+
}
|
|
2755
|
+
function Zi(e, t) {
|
|
2756
|
+
if (e.toLowerCase() !== "count") return !1;
|
|
2757
|
+
const n = t == null ? void 0 : t.find((i) => (i == null ? void 0 : i[e]) != null);
|
|
2758
|
+
return n ? typeof n[e] == "number" : !1;
|
|
2759
|
+
}
|
|
2760
|
+
function er(e, t, n, i) {
|
|
2761
|
+
var c, l, u, m;
|
|
2762
|
+
let r = [...t.keys], o = /* @__PURE__ */ new Map();
|
|
2763
|
+
const a = t.comparisonMetadata;
|
|
2764
|
+
if (n === "screen") {
|
|
2765
|
+
const f = _t(a);
|
|
2766
|
+
r = r.filter((p) => !f.internalKeys.has(p));
|
|
2767
|
+
const y = e.type === "table" ? (c = e.preferences) == null ? void 0 : c.comparisonPresentation : void 0;
|
|
2768
|
+
Me(y) || (r = r.filter((p) => !f.comparisonColumnKeys.has(p)));
|
|
2769
|
+
} else {
|
|
2770
|
+
const f = Nt({
|
|
2771
|
+
comparisonMetadata: a,
|
|
2772
|
+
presentation: (l = e.preferences) == null ? void 0 : l.comparisonPresentation,
|
|
2773
|
+
resolveMetricName: i
|
|
2774
|
+
});
|
|
2775
|
+
r = r.filter((y) => !f.excludedKeys.has(y)), o = f.columnLabels;
|
|
2776
|
+
}
|
|
2777
|
+
const s = e.config;
|
|
2778
|
+
return e.type === "table" && !((u = s == null ? void 0 : s.metricColumns) != null && u.length) && ((m = s == null ? void 0 : s.groupByColumns) != null && m.length) && !e.sql && (r = r.filter((f) => !Zi(f, t.rows))), {
|
|
2779
|
+
keys: gi({
|
|
2780
|
+
keys: r,
|
|
2781
|
+
card: e,
|
|
2782
|
+
comparisonMetadata: a,
|
|
2783
|
+
columnKeyMap: t.columnKeyMap,
|
|
2784
|
+
resultColumns: t.columns
|
|
2785
|
+
}),
|
|
2786
|
+
exportLabels: o
|
|
2787
|
+
};
|
|
2788
|
+
}
|
|
2789
|
+
function tr(e, t, n) {
|
|
2790
|
+
var r, o;
|
|
2791
|
+
const i = /* @__PURE__ */ new Map();
|
|
2792
|
+
if (e.type !== "table" || !Me((r = e.preferences) == null ? void 0 : r.comparisonPresentation))
|
|
2793
|
+
return i;
|
|
2794
|
+
for (const a of ((o = e.config) == null ? void 0 : o.metricColumns) ?? []) {
|
|
2795
|
+
const { comparisonKind: s, metadata: c } = Tt(
|
|
2796
|
+
t.comparisonMetadata,
|
|
2797
|
+
a
|
|
2798
|
+
);
|
|
2799
|
+
if (s === "none" || !oe(
|
|
2800
|
+
a,
|
|
2801
|
+
"metric",
|
|
2802
|
+
[...n],
|
|
2803
|
+
t.columnKeyMap
|
|
2804
|
+
)) continue;
|
|
2805
|
+
const u = xt(
|
|
2806
|
+
a.label || a.name,
|
|
2807
|
+
s,
|
|
2808
|
+
c
|
|
2809
|
+
);
|
|
2810
|
+
u && i.set(u, { metric: a, kind: s });
|
|
2811
|
+
}
|
|
2812
|
+
return i;
|
|
2813
|
+
}
|
|
2814
|
+
function nr(e) {
|
|
2815
|
+
const t = Be(e);
|
|
2816
|
+
return [
|
|
2817
|
+
...t.filter((n) => n.role === "metric"),
|
|
2818
|
+
...t.filter((n) => n.role !== "metric")
|
|
2819
|
+
];
|
|
2820
|
+
}
|
|
2821
|
+
function ir(e, t, n) {
|
|
2822
|
+
if (!t.length) return [];
|
|
2823
|
+
const i = nr(e), r = [], o = /* @__PURE__ */ new Set();
|
|
2824
|
+
for (const a of t) {
|
|
2825
|
+
const s = Dn(i, a);
|
|
2826
|
+
if (!s) continue;
|
|
2827
|
+
const c = i[s.group], l = Ae(c.fields[s.index], c.role);
|
|
2828
|
+
if (!l) continue;
|
|
2829
|
+
const u = q(l);
|
|
2830
|
+
!n.has(u) || o.has(u) || (o.add(u), r.push({
|
|
2831
|
+
columnId: u,
|
|
2832
|
+
direction: a.direction === "desc" ? "desc" : "asc"
|
|
2833
|
+
}));
|
|
2834
|
+
}
|
|
2835
|
+
return r;
|
|
2836
|
+
}
|
|
2837
|
+
function rr(e, t) {
|
|
2838
|
+
return e ? "query" : t === "server" ? "page-only" : "browser";
|
|
2839
|
+
}
|
|
2840
|
+
function Et(e, t) {
|
|
2841
|
+
var n, i, r;
|
|
2842
|
+
return !!t && ((r = (i = (n = e.preferences) == null ? void 0 : n.tablePrefs) == null ? void 0 : i.columnVisibility) == null ? void 0 : r[t]) === !1;
|
|
2843
|
+
}
|
|
2844
|
+
function or(e) {
|
|
2845
|
+
return e.type !== "table" && e.type !== "detailTable" ? "card-type" : hn(e) ? void 0 : "author-disabled";
|
|
2846
|
+
}
|
|
2847
|
+
function Ie(e, t) {
|
|
2848
|
+
const n = [], i = /* @__PURE__ */ new Map();
|
|
2849
|
+
for (const r of e) {
|
|
2850
|
+
const o = t(r), a = o ? `column:${o.columnId}` : `key:${r}`;
|
|
2851
|
+
let s = i.get(a);
|
|
2852
|
+
s || (s = { id: a, columnId: o == null ? void 0 : o.columnId, keys: [] }, i.set(a, s), n.push(s)), s.keys.push(r);
|
|
2853
|
+
}
|
|
2854
|
+
return n;
|
|
2855
|
+
}
|
|
2856
|
+
function de(e, t, n) {
|
|
2857
|
+
const i = Ie(e, t), r = new Set(n), o = new Map(
|
|
2858
|
+
i.flatMap(
|
|
2859
|
+
(s) => s.columnId ? [[s.columnId, s]] : []
|
|
2860
|
+
)
|
|
2861
|
+
), a = n.flatMap((s) => {
|
|
2862
|
+
const c = o.get(s);
|
|
2863
|
+
return c ? [c] : [];
|
|
2864
|
+
});
|
|
2865
|
+
return i.forEach((s, c) => {
|
|
2866
|
+
if (s.columnId && r.has(s.columnId)) return;
|
|
2867
|
+
const l = c > 0 ? i[c - 1] : void 0, u = l ? a.indexOf(l) + 1 : 0;
|
|
2868
|
+
a.splice(u, 0, s);
|
|
2869
|
+
}), a.flatMap((s) => s.keys);
|
|
2870
|
+
}
|
|
2871
|
+
function ar(e) {
|
|
2872
|
+
return e != null && e.pivotIdentity ? JSON.stringify(e.pivotIdentity.members.map((t) => t.value)) : void 0;
|
|
2873
|
+
}
|
|
2874
|
+
function sr(e, t, n, i) {
|
|
2875
|
+
const r = e.findIndex(
|
|
2876
|
+
(l) => {
|
|
2877
|
+
var u;
|
|
2878
|
+
return ((u = t(l)) == null ? void 0 : u.part) === "pivot-member";
|
|
2879
|
+
}
|
|
2880
|
+
);
|
|
2881
|
+
if (r === -1) return de(e, t, n);
|
|
2882
|
+
let o = r;
|
|
2883
|
+
e.forEach((l, u) => {
|
|
2884
|
+
var m;
|
|
2885
|
+
((m = t(l)) == null ? void 0 : m.part) === "pivot-member" && (o = u);
|
|
2886
|
+
});
|
|
2887
|
+
const a = new Map(
|
|
2888
|
+
(i ?? []).map((l) => [l.key, l])
|
|
2889
|
+
), s = [];
|
|
2890
|
+
let c;
|
|
2891
|
+
for (const l of e.slice(r, o + 1)) {
|
|
2892
|
+
const u = ar(a.get(l)) ?? `key:${l}`;
|
|
2893
|
+
(!s.length || u !== c) && s.push([]), s[s.length - 1].push(l), c = u;
|
|
2894
|
+
}
|
|
2895
|
+
return [
|
|
2896
|
+
...de(e.slice(0, r), t, n),
|
|
2897
|
+
...s.flatMap((l) => de(l, t, n)),
|
|
2898
|
+
...de(e.slice(o + 1), t, n)
|
|
2899
|
+
];
|
|
2900
|
+
}
|
|
2901
|
+
function Do(e) {
|
|
2902
|
+
if (ie(e) !== "config") return;
|
|
2903
|
+
const t = /* @__PURE__ */ new Set();
|
|
2904
|
+
for (const { role: n, fields: i } of Be(e))
|
|
2905
|
+
for (const r of i) {
|
|
2906
|
+
const o = Ae(r, n);
|
|
2907
|
+
o && t.add(q(o));
|
|
2908
|
+
}
|
|
2909
|
+
return t;
|
|
2910
|
+
}
|
|
2911
|
+
function Mo(e) {
|
|
2912
|
+
const t = yt(e);
|
|
2913
|
+
return (t == null ? void 0 : t.kind) === "metric" && t.metricId === _e;
|
|
2914
|
+
}
|
|
2915
|
+
function Po(e) {
|
|
2916
|
+
var Re, $e, Le, ze;
|
|
2917
|
+
const { card: t, result: n } = e, i = e.projection ?? "screen", r = ie(t) === "config", o = or(t), a = o === "card-type" ? void 0 : o === "author-disabled" ? (Re = e.settings) != null && Re.sort ? { sort: e.settings.sort } : void 0 : e.settings, s = rr(r, e.paginationMode), c = n.columnKeyMap, l = r ? Wi(t, n) : Xi(n), u = (g) => {
|
|
2918
|
+
var I, _;
|
|
2919
|
+
return g && ((_ = (I = a == null ? void 0 : a.labels) == null ? void 0 : I[g]) == null ? void 0 : _.trim()) || void 0;
|
|
2920
|
+
}, m = (g) => q({ kind: "metric", ...g }), { keys: f, exportLabels: y } = er(
|
|
2921
|
+
t,
|
|
2922
|
+
n,
|
|
2923
|
+
i,
|
|
2924
|
+
(g) => {
|
|
2925
|
+
var _;
|
|
2926
|
+
const I = m(g);
|
|
2927
|
+
return u(l.entries.has(I) ? I : void 0) ?? ((_ = l.entries.get(I)) == null ? void 0 : _.authorLabel);
|
|
2928
|
+
}
|
|
2929
|
+
), p = (g) => Et(t, g), d = (g) => {
|
|
2930
|
+
const I = l.owners.get(g);
|
|
2931
|
+
if (!I || o === "card-type") return;
|
|
2932
|
+
const _ = l.entries.get(I.columnId);
|
|
2933
|
+
if (!(!_ || _.baseKey && p(_.baseKey)))
|
|
2934
|
+
return I;
|
|
2935
|
+
}, h = f.filter((g) => !p(g)), v = Ie(h, d).flatMap(
|
|
2936
|
+
(g) => g.columnId ? [g.columnId] : []
|
|
2937
|
+
), x = new Set(v), O = r ? ir(
|
|
2938
|
+
t,
|
|
2939
|
+
(($e = t.config) == null ? void 0 : $e.sortByColumns) ?? [],
|
|
2940
|
+
l.entries
|
|
2941
|
+
).filter((g) => x.has(g.columnId)) : [], K = [
|
|
2942
|
+
...(a == null ? void 0 : a.order) ?? [],
|
|
2943
|
+
...(a == null ? void 0 : a.hidden) ?? [],
|
|
2944
|
+
...Object.keys((a == null ? void 0 : a.labels) ?? {}),
|
|
2945
|
+
...((a == null ? void 0 : a.sort) ?? []).map((g) => g.columnId)
|
|
2946
|
+
], A = [
|
|
2947
|
+
...new Set(K.filter((g) => !x.has(g)))
|
|
2948
|
+
];
|
|
2949
|
+
let C;
|
|
2950
|
+
if (a != null && a.sort && s !== "page-only") {
|
|
2951
|
+
const g = a.sort.filter(
|
|
2952
|
+
(I) => x.has(I.columnId)
|
|
2953
|
+
);
|
|
2954
|
+
C = g.length || !a.sort.length ? g : void 0;
|
|
2955
|
+
}
|
|
2956
|
+
const F = bn(
|
|
2957
|
+
a ? {
|
|
2958
|
+
order: (Le = a.order) == null ? void 0 : Le.filter(
|
|
2959
|
+
(g) => x.has(g)
|
|
2960
|
+
),
|
|
2961
|
+
hidden: (ze = a.hidden) == null ? void 0 : ze.filter(
|
|
2962
|
+
(g) => x.has(g)
|
|
2963
|
+
),
|
|
2964
|
+
labels: Object.fromEntries(
|
|
2965
|
+
Object.entries(a.labels ?? {}).filter(
|
|
2966
|
+
([g]) => x.has(g)
|
|
2967
|
+
)
|
|
2968
|
+
),
|
|
2969
|
+
sort: C
|
|
2970
|
+
} : void 0
|
|
2971
|
+
), T = F == null ? void 0 : F.order, S = T ? sr(h, d, T, n.columns) : h, B = T ? [...S, ...f.filter(p)] : f, D = Ie(S, d).flatMap(
|
|
2972
|
+
(g) => g.columnId ? [g.columnId] : []
|
|
2973
|
+
), M = new Set((F == null ? void 0 : F.hidden) ?? []);
|
|
2974
|
+
D.length && D.every((g) => M.has(g)) && M.delete(D[0]);
|
|
2975
|
+
const R = i === "screen" ? tr(t, n, f) : /* @__PURE__ */ new Map(), se = (g, I) => {
|
|
2976
|
+
const _ = u(I == null ? void 0 : I.columnId);
|
|
2977
|
+
if ((I == null ? void 0 : I.part) === "base" && _) return _;
|
|
2978
|
+
const $ = R.get(g);
|
|
2979
|
+
if ($)
|
|
2980
|
+
return oi(
|
|
2981
|
+
((I == null ? void 0 : I.part) === "comparison" ? _ : void 0) ?? ($.metric.label || $.metric.name),
|
|
2982
|
+
$.kind
|
|
2983
|
+
);
|
|
2984
|
+
const W = y.get(g);
|
|
2985
|
+
if (W) return W;
|
|
2986
|
+
const X = fi({
|
|
2987
|
+
columnId: g,
|
|
2988
|
+
card: t,
|
|
2989
|
+
columnKeyMap: c,
|
|
2990
|
+
resultColumns: n.columns,
|
|
2991
|
+
// No temporal presentation: a flat table never formats pivot members
|
|
2992
|
+
// as dates (its temporal activation covers group columns only).
|
|
2993
|
+
metricLabelOverride: (I == null ? void 0 : I.part) === "pivot-member" ? _ : void 0
|
|
2994
|
+
});
|
|
2995
|
+
return X || (St(g, t, c) ?? g);
|
|
2996
|
+
}, G = B.map((g) => {
|
|
2997
|
+
var _;
|
|
2998
|
+
const I = d(g);
|
|
2999
|
+
return {
|
|
3000
|
+
outputKey: g,
|
|
3001
|
+
...I ? { columnId: I.columnId } : {},
|
|
3002
|
+
part: (I == null ? void 0 : I.part) ?? ((_ = l.owners.get(g)) == null ? void 0 : _.part) ?? "base",
|
|
3003
|
+
visible: !p(g) && !(I && M.has(I.columnId)),
|
|
3004
|
+
label: se(g, I)
|
|
3005
|
+
};
|
|
3006
|
+
}), le = Object.fromEntries(
|
|
3007
|
+
G.map((g) => [g.outputKey, g.label])
|
|
3008
|
+
), Ne = s === "page-only" ? [] : s === "query" ? O : (F == null ? void 0 : F.sort) ?? [], qt = new Map(
|
|
3009
|
+
Ne.map((g) => [g.columnId, g.direction])
|
|
3010
|
+
), Vt = Ne.flatMap((g) => {
|
|
3011
|
+
var _;
|
|
3012
|
+
const I = (_ = l.entries.get(g.columnId)) == null ? void 0 : _.baseKey;
|
|
3013
|
+
return I && h.includes(I) ? [{ outputKey: I, desc: g.direction === "desc" }] : [];
|
|
3014
|
+
}), Ee = !o && !!(F != null && F.order || F != null && F.hidden || F != null && F.labels);
|
|
3015
|
+
let ce;
|
|
3016
|
+
if (o)
|
|
3017
|
+
ce = { available: !1, reason: o };
|
|
3018
|
+
else if (!D.length)
|
|
3019
|
+
ce = { available: !1, reason: "no-addressable-columns" };
|
|
3020
|
+
else {
|
|
3021
|
+
const g = new Set(T ?? []), I = D.filter(
|
|
3022
|
+
(_) => !M.has(_)
|
|
3023
|
+
).length;
|
|
3024
|
+
ce = {
|
|
3025
|
+
available: !0,
|
|
3026
|
+
canReset: Ee,
|
|
3027
|
+
items: D.map((_) => {
|
|
3028
|
+
const $ = l.entries.get(_), W = M.has(_), X = qt.get(_);
|
|
3029
|
+
return {
|
|
3030
|
+
columnId: _,
|
|
3031
|
+
label: u(_) ?? $.authorLabel,
|
|
3032
|
+
authorLabel: $.authorLabel,
|
|
3033
|
+
hidden: W,
|
|
3034
|
+
isNew: T !== void 0 && !g.has(_),
|
|
3035
|
+
canHide: !W && I > 1,
|
|
3036
|
+
...X ? { sort: X } : {}
|
|
3037
|
+
};
|
|
3038
|
+
})
|
|
3039
|
+
};
|
|
3040
|
+
}
|
|
3041
|
+
return {
|
|
3042
|
+
columns: G,
|
|
3043
|
+
visibleKeys: G.filter((g) => g.visible).map((g) => g.outputKey),
|
|
3044
|
+
labels: le,
|
|
3045
|
+
sortMode: s,
|
|
3046
|
+
clientSort: Vt,
|
|
3047
|
+
panel: ce,
|
|
3048
|
+
...F ? { settings: F } : {},
|
|
3049
|
+
dropped: A,
|
|
3050
|
+
isCustomized: Ee,
|
|
3051
|
+
canSort: o !== "card-type" && s !== "page-only",
|
|
3052
|
+
author: { order: v }
|
|
3053
|
+
};
|
|
3054
|
+
}
|
|
3055
|
+
function Ko(e, t) {
|
|
3056
|
+
var n;
|
|
3057
|
+
return (n = Rt(e, t)) == null ? void 0 : n.field;
|
|
3058
|
+
}
|
|
3059
|
+
function Rt(e, t) {
|
|
3060
|
+
const n = yt(t), i = e.config;
|
|
3061
|
+
if (!n || !i) return;
|
|
3062
|
+
let r = [], o;
|
|
3063
|
+
if (n.kind === "dimension")
|
|
3064
|
+
o = n.role, r = ((n.role === "detail" ? i.detailColumns : i.groupByColumns) ?? []).filter((s) => s.id === n.fieldId);
|
|
3065
|
+
else if (n.kind === "metric")
|
|
3066
|
+
o = "metric", r = (i.metricColumns ?? []).filter(
|
|
3067
|
+
(a) => a.id === n.metricId && E(a) === n.metricAlias
|
|
3068
|
+
);
|
|
3069
|
+
else
|
|
3070
|
+
return;
|
|
3071
|
+
return r.length === 1 ? { field: r[0], role: o } : void 0;
|
|
3072
|
+
}
|
|
3073
|
+
function ko(e, t) {
|
|
3074
|
+
const n = t == null ? void 0 : t.sort;
|
|
3075
|
+
if (!n || !e.config || e.type !== "table" && e.type !== "detailTable" || ie(e) !== "config")
|
|
3076
|
+
return e.config;
|
|
3077
|
+
const i = n.flatMap((r) => {
|
|
3078
|
+
const o = Rt(e, r.columnId);
|
|
3079
|
+
if (!o) return [];
|
|
3080
|
+
const a = Mn(o.field, o.role);
|
|
3081
|
+
return Et(e, a) ? [] : [
|
|
3082
|
+
{
|
|
3083
|
+
...o.field,
|
|
3084
|
+
alias: a,
|
|
3085
|
+
role: "sortby",
|
|
3086
|
+
direction: r.direction
|
|
3087
|
+
}
|
|
3088
|
+
];
|
|
3089
|
+
});
|
|
3090
|
+
return n.length > 0 && i.length === 0 ? e.config : { ...e.config, sortByColumns: i };
|
|
3091
|
+
}
|
|
3092
|
+
function lr(e) {
|
|
3093
|
+
if (!e.name)
|
|
3094
|
+
return;
|
|
3095
|
+
const t = e.entityName && e.entityName !== "SEMAPHOR_CALCULATED_FIELD" ? e.entityName : void 0;
|
|
3096
|
+
if (e.role === "metric") {
|
|
3097
|
+
let n = "aggregate" in e && typeof e.aggregate == "string" ? e.aggregate : "metric";
|
|
3098
|
+
if ("expression" in e && typeof e.expression == "string") {
|
|
3099
|
+
const i = e.expression.match(
|
|
3100
|
+
/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i
|
|
3101
|
+
);
|
|
3102
|
+
n = i ? i[1].toLowerCase() : "expr";
|
|
3103
|
+
} else
|
|
3104
|
+
n = n.toLowerCase();
|
|
3105
|
+
return t && t !== e.name ? `${t}_${e.name}_${n}` : `${e.name}_${n}`;
|
|
3106
|
+
}
|
|
3107
|
+
return t && t !== e.name ? `${t}_${e.name}` : e.name;
|
|
3108
|
+
}
|
|
3109
|
+
function ae(e) {
|
|
3110
|
+
return Array.from(
|
|
3111
|
+
new Set(
|
|
3112
|
+
[
|
|
3113
|
+
e.id,
|
|
3114
|
+
e.alias,
|
|
3115
|
+
e.label,
|
|
3116
|
+
e.name,
|
|
3117
|
+
e.qualifiedFieldName,
|
|
3118
|
+
lr(e)
|
|
3119
|
+
].map((t) => typeof t == "string" ? t.trim() : "").filter(Boolean)
|
|
3120
|
+
)
|
|
3121
|
+
);
|
|
3122
|
+
}
|
|
3123
|
+
function we(e, t) {
|
|
3124
|
+
const n = t ?? e.config, i = (n == null ? void 0 : n.detailColumns) || [], r = (n == null ? void 0 : n.groupByColumns) || [], o = (n == null ? void 0 : n.metricColumns) || [];
|
|
3125
|
+
return [
|
|
3126
|
+
...i.map((a) => ({ ...a, role: "detail" })),
|
|
3127
|
+
...r.map((a) => ({ ...a, role: "groupby" })),
|
|
3128
|
+
...o.map((a) => ({ ...a, role: "metric" }))
|
|
3129
|
+
].filter((a) => !!a.id);
|
|
3130
|
+
}
|
|
3131
|
+
function Bo(e, t) {
|
|
3132
|
+
return t ? !ae(e).some(
|
|
3133
|
+
(n) => t[n] === !1
|
|
3134
|
+
) : !0;
|
|
3135
|
+
}
|
|
3136
|
+
function Ao(e, t) {
|
|
3137
|
+
for (const n of ae(e))
|
|
3138
|
+
if (t != null && t[n])
|
|
3139
|
+
return n;
|
|
3140
|
+
return e.label || e.name || e.alias || e.id;
|
|
3141
|
+
}
|
|
3142
|
+
function Oe(e) {
|
|
3143
|
+
var t;
|
|
3144
|
+
return e.type === "table" && !((t = e.sql) != null && t.trim()) && !!e.config;
|
|
3145
|
+
}
|
|
3146
|
+
function $t(e) {
|
|
3147
|
+
var t, n, i, r;
|
|
3148
|
+
return ((r = (i = (n = (t = e.preferences) == null ? void 0 : t.tablePrefs) == null ? void 0 : n.tableStyle) == null ? void 0 : i.totals) == null ? void 0 : r.enabled) === !0;
|
|
3149
|
+
}
|
|
3150
|
+
function Lt(e) {
|
|
3151
|
+
return Oe(e) ? $t(e) : !1;
|
|
3152
|
+
}
|
|
3153
|
+
function cr(e, t, n) {
|
|
3154
|
+
if (!Lt(e))
|
|
3155
|
+
return;
|
|
3156
|
+
const i = we(e, n).filter((r) => r.role !== "metric").map((r) => new Set(ae(r)));
|
|
3157
|
+
return t.find(
|
|
3158
|
+
(r) => i.some((o) => o.has(r))
|
|
3159
|
+
);
|
|
3160
|
+
}
|
|
3161
|
+
function wo({
|
|
3162
|
+
card: e,
|
|
3163
|
+
effectiveCardConfig: t,
|
|
3164
|
+
visibleColumnIds: n,
|
|
3165
|
+
totalsByColumnId: i
|
|
3166
|
+
}) {
|
|
3167
|
+
if (!Lt(e) || !i || Object.keys(i).length === 0)
|
|
3168
|
+
return;
|
|
3169
|
+
const r = cr(
|
|
3170
|
+
e,
|
|
3171
|
+
n,
|
|
3172
|
+
t
|
|
3173
|
+
), o = new Set(
|
|
3174
|
+
we(e, t).filter((a) => a.role !== "metric").flatMap(ae)
|
|
3175
|
+
);
|
|
3176
|
+
return Object.fromEntries(
|
|
3177
|
+
n.map((a) => [
|
|
3178
|
+
a,
|
|
3179
|
+
a === r ? "Total" : o.has(a) || !Object.prototype.hasOwnProperty.call(i, a) ? null : i[a]
|
|
3180
|
+
])
|
|
3181
|
+
);
|
|
3182
|
+
}
|
|
3183
|
+
function Oo(e) {
|
|
3184
|
+
var t, n, i, r, o, a;
|
|
3185
|
+
return Oe(e) ? {
|
|
3186
|
+
...e,
|
|
3187
|
+
preferences: {
|
|
3188
|
+
...e.preferences,
|
|
3189
|
+
tablePrefs: {
|
|
3190
|
+
...(t = e.preferences) == null ? void 0 : t.tablePrefs,
|
|
3191
|
+
tableStyle: {
|
|
3192
|
+
...(i = (n = e.preferences) == null ? void 0 : n.tablePrefs) == null ? void 0 : i.tableStyle,
|
|
3193
|
+
totals: {
|
|
3194
|
+
...(a = (o = (r = e.preferences) == null ? void 0 : r.tablePrefs) == null ? void 0 : o.tableStyle) == null ? void 0 : a.totals,
|
|
3195
|
+
enabled: !0
|
|
3196
|
+
}
|
|
3197
|
+
}
|
|
3198
|
+
}
|
|
3199
|
+
}
|
|
3200
|
+
} : e;
|
|
3201
|
+
}
|
|
3202
|
+
function ur(e, t, n) {
|
|
3203
|
+
if (!Oe(e) || !$t(e))
|
|
3204
|
+
return;
|
|
3205
|
+
const i = we(e, t), r = new Set(
|
|
3206
|
+
_n(
|
|
3207
|
+
i.filter((c) => c.role === "metric")
|
|
3208
|
+
)
|
|
3209
|
+
), o = i.filter((c) => c.role !== "metric"), a = n && o.find(
|
|
3210
|
+
(c) => ae(c).includes(n)
|
|
3211
|
+
) || o[0], s = [];
|
|
3212
|
+
for (const c of i) {
|
|
3213
|
+
if (c === a) {
|
|
3214
|
+
s.push({
|
|
3215
|
+
fieldId: c.id,
|
|
3216
|
+
role: c.role,
|
|
3217
|
+
behavior: "label",
|
|
3218
|
+
label: "Total"
|
|
3219
|
+
});
|
|
3220
|
+
continue;
|
|
3221
|
+
}
|
|
3222
|
+
if (c.role === "metric") {
|
|
3223
|
+
const l = E(c);
|
|
3224
|
+
s.push({
|
|
3225
|
+
fieldId: c.id,
|
|
3226
|
+
role: c.role,
|
|
3227
|
+
behavior: "sum",
|
|
3228
|
+
...r.has(l) ? { metricAlias: l } : {}
|
|
3229
|
+
});
|
|
3230
|
+
}
|
|
3231
|
+
}
|
|
3232
|
+
return s.length ? {
|
|
3233
|
+
source: "documentFlatTable",
|
|
3234
|
+
columns: s
|
|
3235
|
+
} : void 0;
|
|
3236
|
+
}
|
|
3237
|
+
function No(e) {
|
|
3238
|
+
var t, n, i, r, o, a;
|
|
3239
|
+
return {
|
|
3240
|
+
...e,
|
|
3241
|
+
preferences: {
|
|
3242
|
+
...e.preferences,
|
|
3243
|
+
tablePrefs: {
|
|
3244
|
+
...(t = e.preferences) == null ? void 0 : t.tablePrefs,
|
|
3245
|
+
tableStyle: {
|
|
3246
|
+
...(i = (n = e.preferences) == null ? void 0 : n.tablePrefs) == null ? void 0 : i.tableStyle,
|
|
3247
|
+
totals: {
|
|
3248
|
+
...(a = (o = (r = e.preferences) == null ? void 0 : r.tablePrefs) == null ? void 0 : o.tableStyle) == null ? void 0 : a.totals,
|
|
3249
|
+
enabled: !1
|
|
3250
|
+
}
|
|
3251
|
+
}
|
|
3252
|
+
}
|
|
3253
|
+
}
|
|
3254
|
+
};
|
|
3255
|
+
}
|
|
3256
|
+
const Eo = 1e4, dr = 500, mr = 250;
|
|
3257
|
+
function Fe(e) {
|
|
3258
|
+
return e.type === "table" || e.type === "detailTable";
|
|
3259
|
+
}
|
|
3260
|
+
function fr(e) {
|
|
3261
|
+
var t, n, i;
|
|
3262
|
+
return !!((t = e.sql) != null && t.trim() && Fe(e) && ((i = (n = e.preferences) == null ? void 0 : n.tablePrefs) != null && i.enableDevModePagination));
|
|
3263
|
+
}
|
|
3264
|
+
function Ro(e) {
|
|
3265
|
+
return e === "export-full-with-cap" ? dr : mr;
|
|
3266
|
+
}
|
|
3267
|
+
function pr({
|
|
3268
|
+
card: e,
|
|
3269
|
+
isTablePrintMode: t,
|
|
3270
|
+
isPrintDisplayMode: n,
|
|
3271
|
+
isDocumentSectionRuntime: i,
|
|
3272
|
+
documentTableDataPolicy: r
|
|
3273
|
+
}) {
|
|
3274
|
+
var l, u;
|
|
3275
|
+
const o = i && r !== void 0 && Fe(e), a = t && !o || e.type === "pivotTable" && n, s = dt(e.config) && Fe(e) && !e.sql, c = o ? fr(e) : !!(e.sql && ((u = (l = e.preferences) == null ? void 0 : l.tablePrefs) != null && u.enableDevModePagination));
|
|
3276
|
+
return !a && (s || c);
|
|
3277
|
+
}
|
|
3278
|
+
function yr(e) {
|
|
3279
|
+
var t, n, i;
|
|
3280
|
+
return ((t = e.paginationConfig) == null ? void 0 : t.pageSize) || ((i = (n = e.preferences) == null ? void 0 : n.tablePrefs) == null ? void 0 : i.pageSize) || 50;
|
|
3281
|
+
}
|
|
3282
|
+
function $o({
|
|
3283
|
+
current: e,
|
|
3284
|
+
defaultPageSize: t,
|
|
3285
|
+
queryInputIdentity: n
|
|
3286
|
+
}) {
|
|
3287
|
+
return (e == null ? void 0 : e.queryInputIdentity) === n ? {
|
|
3288
|
+
page: e.page,
|
|
3289
|
+
pageSize: e.pageSize
|
|
3290
|
+
} : {
|
|
3291
|
+
page: 1,
|
|
3292
|
+
pageSize: (e == null ? void 0 : e.pageSize) ?? t
|
|
3293
|
+
};
|
|
3294
|
+
}
|
|
3295
|
+
function Lo(e, t, n) {
|
|
3296
|
+
return (e == null ? void 0 : e.queryInputIdentity) === n && e.page === t.page && e.pageSize === t.pageSize;
|
|
3297
|
+
}
|
|
3298
|
+
function zo(e, t) {
|
|
3299
|
+
return !e || !t || e.page === t.page && e.pageSize === t.pageSize ? e : {
|
|
3300
|
+
...e,
|
|
3301
|
+
page: t.page,
|
|
3302
|
+
pageSize: t.pageSize,
|
|
3303
|
+
hasPrevPage: t.page > 1
|
|
3304
|
+
};
|
|
3305
|
+
}
|
|
3306
|
+
function qo(e) {
|
|
3307
|
+
return { page: 1, pageSize: yr(e) };
|
|
3308
|
+
}
|
|
3309
|
+
function Vo(e) {
|
|
3310
|
+
var a, s, c, l, u, m;
|
|
3311
|
+
const { card: t } = e, n = pr({
|
|
3312
|
+
card: t,
|
|
3313
|
+
isTablePrintMode: ((a = e.display) == null ? void 0 : a.isTablePrintMode) ?? !1,
|
|
3314
|
+
isPrintDisplayMode: ((s = e.display) == null ? void 0 : s.isPrintDisplayMode) ?? !1,
|
|
3315
|
+
isDocumentSectionRuntime: !!e.documentSection,
|
|
3316
|
+
documentTableDataPolicy: (c = e.documentSection) == null ? void 0 : c.documentTableDataPolicy
|
|
3317
|
+
}), { page: i } = e, r = e.tableTotalsRequest ?? (e.documentSection ? void 0 : ur(t, e.finalConfig)), o = !!((l = e.display) != null && l.deliveryStrict && e.display.isTablePrintMode && !e.documentSection && kn(t.type));
|
|
3318
|
+
return {
|
|
3319
|
+
...r ? { tableTotalsRequest: r } : {},
|
|
3320
|
+
...o ? { sourceRowProbe: { limit: Bn.maxRows } } : {},
|
|
3321
|
+
...n ? {
|
|
3322
|
+
pagination: {
|
|
3323
|
+
page: (i == null ? void 0 : i.page) || 1,
|
|
3324
|
+
pageSize: (i == null ? void 0 : i.pageSize) || ((m = (u = t.preferences) == null ? void 0 : u.tablePrefs) == null ? void 0 : m.pageSize) || 50
|
|
3325
|
+
}
|
|
3326
|
+
} : {}
|
|
3327
|
+
};
|
|
3328
|
+
}
|
|
3329
|
+
function gr(e, t = {}) {
|
|
3330
|
+
var r, o, a;
|
|
3331
|
+
const n = ((r = e.connectionId) == null ? void 0 : r.trim()) || void 0;
|
|
3332
|
+
if (t.editorDevMode) return n;
|
|
3333
|
+
const i = ((a = (o = e.dataSource) == null ? void 0 : o.connectionId) == null ? void 0 : a.trim()) || void 0;
|
|
3334
|
+
return e.sql ? n || i : i || n;
|
|
3335
|
+
}
|
|
3336
|
+
function br(e, t) {
|
|
3337
|
+
var n;
|
|
3338
|
+
return {
|
|
3339
|
+
connectionId: t,
|
|
3340
|
+
connectionType: ((n = e.dataSource) == null ? void 0 : n.connectionType) || "unknown",
|
|
3341
|
+
mode: "database",
|
|
3342
|
+
selectedEntities: []
|
|
3343
|
+
};
|
|
3344
|
+
}
|
|
3345
|
+
function jo(e, t, n = {}) {
|
|
3346
|
+
const i = gr(e, n);
|
|
3347
|
+
if (!i)
|
|
3348
|
+
throw new Error("No connection ID found for card");
|
|
3349
|
+
const r = t.cardDataSource || e.dataSource;
|
|
3350
|
+
return {
|
|
3351
|
+
connectionId: i,
|
|
3352
|
+
requestPayloadBase: {
|
|
3353
|
+
...t,
|
|
3354
|
+
cardDataSource: n.liveDataSource ? r : r || br(e, i)
|
|
3355
|
+
}
|
|
3356
|
+
};
|
|
3357
|
+
}
|
|
3358
|
+
const hr = /* @__PURE__ */ new Set([
|
|
3359
|
+
"day",
|
|
3360
|
+
"week",
|
|
3361
|
+
"month",
|
|
3362
|
+
"quarter",
|
|
3363
|
+
"year",
|
|
3364
|
+
"hour",
|
|
3365
|
+
"minute",
|
|
3366
|
+
"second"
|
|
3367
|
+
]);
|
|
3368
|
+
function Uo(e) {
|
|
3369
|
+
let t = e.spec;
|
|
3370
|
+
const n = mt(
|
|
3371
|
+
e.controlDefinitions || [],
|
|
3372
|
+
e.cardControlDefinitions || []
|
|
3373
|
+
), i = (e.controlBindings || []).filter(
|
|
3374
|
+
(d) => d.target !== "sql_param"
|
|
3375
|
+
), r = i.filter(
|
|
3376
|
+
(d) => d.target === "config_metric_selector" || d.target === "config_field_selector"
|
|
3377
|
+
), o = i.filter(
|
|
3378
|
+
(d) => d.target === "config_grain" || d.target === "config_aggregation"
|
|
3379
|
+
), a = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Map();
|
|
3380
|
+
let c;
|
|
3381
|
+
const l = () => {
|
|
3382
|
+
if (c) return c;
|
|
3383
|
+
const d = e.catalog, h = /* @__PURE__ */ new Map();
|
|
3384
|
+
for (const b of d) {
|
|
3385
|
+
const v = h.get(b.id) ?? [];
|
|
3386
|
+
h.set(b.id, [...v, b]);
|
|
3387
|
+
}
|
|
3388
|
+
return c = { refs: d, byId: h }, c;
|
|
3389
|
+
}, u = (d, h) => {
|
|
3390
|
+
throw new pn(d, {
|
|
3391
|
+
code: yn,
|
|
3392
|
+
...h ? { controlId: h } : {}
|
|
3393
|
+
});
|
|
3394
|
+
}, m = (d, h) => {
|
|
3395
|
+
var v;
|
|
3396
|
+
if (d.derivedField) return d.derivedField.dataType;
|
|
3397
|
+
const b = l().refs.filter((x) => x.field.name === d.name && Q(x.field.source ?? e.spec.source, d.source ?? e.spec.source));
|
|
3398
|
+
return b.length > 1 ? u("The selected field is ambiguous in the authorized Matrix field catalog.", h) : j(((v = b[0]) == null ? void 0 : v.field.dataType) ?? d.dataType);
|
|
3399
|
+
}, f = (d, h) => cn(d, h.target, (b) => m(b, h.controlId)), y = Qt.safeParse(t);
|
|
3400
|
+
if (!y.success) return u(y.error.message);
|
|
3401
|
+
t = y.data;
|
|
3402
|
+
const p = [...r, ...o].map((d) => {
|
|
3403
|
+
const h = ft({ binding: d, definitions: n, controlValues: e.controlValues }), b = !d.matrixTargetId && h !== void 0 && h !== he ? f(y.data, d) : [];
|
|
3404
|
+
return {
|
|
3405
|
+
binding: d,
|
|
3406
|
+
selectedValue: h,
|
|
3407
|
+
targetId: d.matrixTargetId ?? (b.length === 1 ? b[0].id : void 0)
|
|
3408
|
+
};
|
|
3409
|
+
});
|
|
3410
|
+
for (const { binding: d, targetId: h, selectedValue: b } of p) {
|
|
3411
|
+
if (b === void 0 || b === he)
|
|
3412
|
+
continue;
|
|
3413
|
+
const v = (T) => u(T, d.controlId), x = d.target === "config_metric_selector" || d.target === "config_aggregation", O = f(t, d);
|
|
3414
|
+
(!h || !O.some((T) => T.id === h)) && v("Choose a valid Matrix level or measure target for this control.");
|
|
3415
|
+
const K = `${d.target}:${h}`;
|
|
3416
|
+
a.has(K) && v("Multiple controls cannot replace the same Matrix target."), a.add(K);
|
|
3417
|
+
const A = (T) => {
|
|
3418
|
+
const S = (l().byId.get(T.id) ?? []).filter((D) => !T.source || Q(T.source, D.field.source ?? e.spec.source));
|
|
3419
|
+
if (S.length !== 1) return v(S.length ? "The selected field is ambiguous in the authorized Matrix field catalog." : "The selected field is not in the authorized Matrix field catalog.");
|
|
3420
|
+
const B = Jt.safeParse(S[0].field);
|
|
3421
|
+
return B.success ? B.data : v(B.error.message);
|
|
3422
|
+
}, C = d.target === "config_metric_selector" || d.target === "config_field_selector" ? d.mapping[b] : void 0, F = C && typeof C == "object" && "kind" in C && C.kind === "matrix_instance" ? C.id : void 0;
|
|
3423
|
+
if (x) {
|
|
3424
|
+
s.set(h, d.controlId);
|
|
3425
|
+
const T = F === void 0 ? void 0 : y.data.measures.find(
|
|
3426
|
+
(M) => M.id === F && M.kind === "aggregate"
|
|
3427
|
+
);
|
|
3428
|
+
F !== void 0 && !T && v("The selected Matrix aggregate measure is no longer available.");
|
|
3429
|
+
const S = d.target === "config_metric_selector" && !T ? un({ binding: d, selectedValue: b }) : void 0, B = ((T == null ? void 0 : T.kind) === "aggregate" ? T.aggregate : S == null ? void 0 : S.aggregate) ?? (d.target === "config_aggregation" ? je({ binding: d, selectedValue: b }) : void 0), D = B === void 0 ? void 0 : Ht.safeParse(B);
|
|
3430
|
+
D && !D.success && v("This aggregation is not supported by Matrix."), t = {
|
|
3431
|
+
...t,
|
|
3432
|
+
measures: t.measures.map(
|
|
3433
|
+
(M) => M.id !== h || M.kind !== "aggregate" ? M : {
|
|
3434
|
+
...M,
|
|
3435
|
+
...S ? { field: A(S) } : {},
|
|
3436
|
+
...(T == null ? void 0 : T.kind) === "aggregate" ? { field: T.field } : {},
|
|
3437
|
+
aggregate: D != null && D.success ? D.data : M.aggregate
|
|
3438
|
+
}
|
|
3439
|
+
)
|
|
3440
|
+
};
|
|
3441
|
+
} else {
|
|
3442
|
+
const T = F === void 0 ? void 0 : [...y.data.rows, ...y.data.columns].find(
|
|
3443
|
+
(M) => M.id === F
|
|
3444
|
+
);
|
|
3445
|
+
F !== void 0 && !T && v("The selected Matrix level is no longer available.");
|
|
3446
|
+
const S = d.target === "config_field_selector" && !T ? dn({ binding: d, selectedValue: b }) : void 0, B = d.target === "config_grain" ? je({ binding: d, selectedValue: b }) : T ? T.grain : S == null ? void 0 : S.granularity;
|
|
3447
|
+
B !== void 0 && !hr.has(B) && v("This time grain is not supported by Matrix.");
|
|
3448
|
+
const D = (M) => M.map((R) => {
|
|
3449
|
+
if (R.id !== h) return R;
|
|
3450
|
+
const se = (T == null ? void 0 : T.field) ?? (S ? A(S) : R.field), G = m(se, d.controlId), le = B ?? (S && Ve(G) ? R.grain : void 0);
|
|
3451
|
+
return le && !Ve(G) && v("A time grain requires a temporal Matrix level."), { ...R, field: se, grain: le };
|
|
3452
|
+
});
|
|
3453
|
+
t = {
|
|
3454
|
+
...t,
|
|
3455
|
+
rows: D(t.rows),
|
|
3456
|
+
columns: D(t.columns)
|
|
3457
|
+
};
|
|
3458
|
+
}
|
|
3459
|
+
}
|
|
3460
|
+
for (const [d, h] of Array.from(s)) {
|
|
3461
|
+
const b = t.measures.find((x) => x.id === d);
|
|
3462
|
+
if (!b || b.kind !== "aggregate") continue;
|
|
3463
|
+
const v = m(b.field, h);
|
|
3464
|
+
mn(v).some((x) => x.value === b.aggregate) || u(`Aggregation '${b.aggregate}' is not eligible for this Matrix field datatype.`, h);
|
|
3465
|
+
}
|
|
3466
|
+
try {
|
|
3467
|
+
return fn(y.data, t);
|
|
3468
|
+
} catch (d) {
|
|
3469
|
+
if (d instanceof Wt) return u(d.message);
|
|
3470
|
+
throw d;
|
|
3471
|
+
}
|
|
3472
|
+
}
|
|
3473
|
+
function zt(e, t) {
|
|
3474
|
+
const n = [], i = (r) => {
|
|
3475
|
+
if (r.source) {
|
|
3476
|
+
const o = Yt.safeParse(r.source);
|
|
3477
|
+
if (o.success) n.push(o.data);
|
|
3478
|
+
else if (t) throw o.error;
|
|
3479
|
+
}
|
|
3480
|
+
r.derivedField && Object.values(r.derivedField.inputs).forEach((o) => i(o.field));
|
|
3481
|
+
};
|
|
3482
|
+
for (const r of e) {
|
|
3483
|
+
if (r.target !== "config_field_selector" && r.target !== "config_metric_selector") continue;
|
|
3484
|
+
const o = t == null ? void 0 : t.get(r), a = t ? o && o !== he ? [r.mapping[o]] : [] : Object.values(r.mapping);
|
|
3485
|
+
for (const s of a)
|
|
3486
|
+
s && "role" in s && i(s);
|
|
3487
|
+
}
|
|
3488
|
+
return n;
|
|
3489
|
+
}
|
|
3490
|
+
function Go(e, t = [], n = []) {
|
|
3491
|
+
return st([...bt(e), ...zt(t), ...n]);
|
|
3492
|
+
}
|
|
3493
|
+
function Qo(e, t = {}) {
|
|
3494
|
+
const n = t.controlBindings ?? [], i = mt(t.controlDefinitions ?? [], t.cardControlDefinitions ?? []), r = new Map(n.filter((o) => o.target === "config_field_selector" || o.target === "config_metric_selector").map((o) => [o, ft({ binding: o, definitions: i, controlValues: t.controlValues })]));
|
|
3495
|
+
return st([...bt(e), ...zt(n, r)]);
|
|
3496
|
+
}
|
|
3497
|
+
function Cr(e) {
|
|
3498
|
+
return (e == null ? void 0 : e.kind) === "document";
|
|
3499
|
+
}
|
|
3500
|
+
function Ho(e) {
|
|
3501
|
+
return (e || []).filter((t) => !Cr(t));
|
|
3502
|
+
}
|
|
3503
|
+
export {
|
|
3504
|
+
Ko as $,
|
|
3505
|
+
So as A,
|
|
3506
|
+
Ki as B,
|
|
3507
|
+
Pi as C,
|
|
3508
|
+
Un as D,
|
|
3509
|
+
fo as E,
|
|
3510
|
+
Ti as F,
|
|
3511
|
+
Di as G,
|
|
3512
|
+
Si as H,
|
|
3513
|
+
Pt as I,
|
|
3514
|
+
mo as J,
|
|
3515
|
+
po as K,
|
|
3516
|
+
xi as L,
|
|
3517
|
+
Mt as M,
|
|
3518
|
+
Wr as N,
|
|
3519
|
+
bo as O,
|
|
3520
|
+
kt as P,
|
|
3521
|
+
ve as Q,
|
|
3522
|
+
xo as R,
|
|
3523
|
+
io as S,
|
|
3524
|
+
cr as T,
|
|
3525
|
+
ur as U,
|
|
3526
|
+
wi as V,
|
|
3527
|
+
J as W,
|
|
3528
|
+
_o as X,
|
|
3529
|
+
Ni as Y,
|
|
3530
|
+
Do as Z,
|
|
3531
|
+
Mo as _,
|
|
3532
|
+
Ge as a,
|
|
3533
|
+
zr as a0,
|
|
3534
|
+
Lr as a1,
|
|
3535
|
+
ri as a2,
|
|
3536
|
+
Ct as a3,
|
|
3537
|
+
Bi as a4,
|
|
3538
|
+
Ke as a5,
|
|
3539
|
+
ko as a6,
|
|
3540
|
+
Ii as a7,
|
|
3541
|
+
Vo as a8,
|
|
3542
|
+
qo as a9,
|
|
3543
|
+
go as aA,
|
|
3544
|
+
eo as aB,
|
|
3545
|
+
$t as aC,
|
|
3546
|
+
Tt as aD,
|
|
3547
|
+
oe as aE,
|
|
3548
|
+
xt as aF,
|
|
3549
|
+
no as aG,
|
|
3550
|
+
to as aH,
|
|
3551
|
+
ao as aI,
|
|
3552
|
+
ci as aJ,
|
|
3553
|
+
oo as aK,
|
|
3554
|
+
so as aL,
|
|
3555
|
+
ht as aM,
|
|
3556
|
+
Co as aN,
|
|
3557
|
+
Xr as aO,
|
|
3558
|
+
vo as aP,
|
|
3559
|
+
yo as aQ,
|
|
3560
|
+
Oo as aR,
|
|
3561
|
+
No as aS,
|
|
3562
|
+
we as aT,
|
|
3563
|
+
Bo as aU,
|
|
3564
|
+
Ao as aV,
|
|
3565
|
+
Ro as aW,
|
|
3566
|
+
Eo as aX,
|
|
3567
|
+
mr as aY,
|
|
3568
|
+
Fo as aa,
|
|
3569
|
+
An as ab,
|
|
3570
|
+
ho as ac,
|
|
3571
|
+
Io as ad,
|
|
3572
|
+
ki as ae,
|
|
3573
|
+
_i as af,
|
|
3574
|
+
Oe as ag,
|
|
3575
|
+
Lt as ah,
|
|
3576
|
+
Zr as ai,
|
|
3577
|
+
Ho as aj,
|
|
3578
|
+
zi as ak,
|
|
3579
|
+
wo as al,
|
|
3580
|
+
co as am,
|
|
3581
|
+
uo as an,
|
|
3582
|
+
lo as ao,
|
|
3583
|
+
ro as ap,
|
|
3584
|
+
pr as aq,
|
|
3585
|
+
yr as ar,
|
|
3586
|
+
$o as as,
|
|
3587
|
+
Lo as at,
|
|
3588
|
+
Fe as au,
|
|
3589
|
+
fr as av,
|
|
3590
|
+
gr as aw,
|
|
3591
|
+
zo as ax,
|
|
3592
|
+
_t as ay,
|
|
3593
|
+
Me as az,
|
|
3594
|
+
jo as b,
|
|
3595
|
+
To as c,
|
|
3596
|
+
Go as d,
|
|
3597
|
+
$r as e,
|
|
3598
|
+
Qo as f,
|
|
3599
|
+
$n as g,
|
|
3600
|
+
Vr as h,
|
|
3601
|
+
jr as i,
|
|
3602
|
+
Hr as j,
|
|
3603
|
+
Jr as k,
|
|
3604
|
+
Yr as l,
|
|
3605
|
+
En as m,
|
|
3606
|
+
ti as n,
|
|
3607
|
+
Uo as o,
|
|
3608
|
+
zn as p,
|
|
3609
|
+
qn as q,
|
|
3610
|
+
qr as r,
|
|
3611
|
+
Vn as s,
|
|
3612
|
+
Ur as t,
|
|
3613
|
+
Gr as u,
|
|
3614
|
+
jn as v,
|
|
3615
|
+
Qr as w,
|
|
3616
|
+
Cr as x,
|
|
3617
|
+
ot as y,
|
|
3618
|
+
Po as z
|
|
3619
|
+
};
|