react-semaphor 0.1.494 → 0.1.496

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +233 -218
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +5 -5
  7. package/dist/chunks/calculated-field-identity-Cq9GwHfE.js +1266 -0
  8. package/dist/chunks/calculated-field-identity-DTfyvvLC.cjs +1 -0
  9. package/dist/chunks/{constants-D47EhfJR.js → constants-CC3WKmqC.js} +14 -14
  10. package/dist/chunks/{constants-BMfm1XgO.cjs → constants-DIuhVR6J.cjs} +1 -1
  11. package/dist/chunks/{dashboard-briefing-launcher-DQFa0Ti1.js → dashboard-briefing-launcher-Bbz4cwHb.js} +9 -9
  12. package/dist/chunks/{dashboard-briefing-launcher-nWBKnd0X.cjs → dashboard-briefing-launcher-CM6LTGw5.cjs} +1 -1
  13. package/dist/chunks/{dashboard-controls-BbPWWVO-.cjs → dashboard-controls-B2nrczJl.cjs} +1 -1
  14. package/dist/chunks/{dashboard-controls-DWpnRtQI.js → dashboard-controls-BsgADy-S.js} +11 -11
  15. package/dist/chunks/{dashboard-date-comparison-definition-CKXgDzSB.js → dashboard-date-comparison-definition-Bqti6YAo.js} +1 -1
  16. package/dist/chunks/{dashboard-date-comparison-definition-DCIUwJnZ.cjs → dashboard-date-comparison-definition-C69F-zaC.cjs} +1 -1
  17. package/dist/chunks/{dashboard-json-DyTQysQF.js → dashboard-json-CA-BChbt.js} +7 -7
  18. package/dist/chunks/{dashboard-json-BFJNDHxv.cjs → dashboard-json-CwRRBSSL.cjs} +1 -1
  19. package/dist/chunks/edit-dashboard-visual-BlS27LDw.cjs +172 -0
  20. package/dist/chunks/{edit-dashboard-visual-D-gauuNQ.js → edit-dashboard-visual-CEiPgdkX.js} +7903 -7939
  21. package/dist/chunks/{editor-action-buttons-DMgnHVY1.js → editor-action-buttons-6HBjjcfK.js} +6 -6
  22. package/dist/chunks/{editor-action-buttons-B7YezrkC.cjs → editor-action-buttons-kk2BNiTe.cjs} +1 -1
  23. package/dist/chunks/{field-aggregations-J7de9KZm.js → field-aggregations-C8kZqMTD.js} +11 -11
  24. package/dist/chunks/{field-aggregations-hx8odlTh.cjs → field-aggregations-naKZ7S2Q.cjs} +1 -1
  25. package/dist/chunks/{index-DXQsuuMQ.cjs → index-BSRwdFTN.cjs} +226 -225
  26. package/dist/chunks/{index-Df4YBtX5.cjs → index-CCa-A-Yx.cjs} +1 -1
  27. package/dist/chunks/{index-CPWfCksu.js → index-Cgoz65yM.js} +39519 -38739
  28. package/dist/chunks/{index-BDtC8et3.js → index-oll4m-qi.js} +11 -11
  29. package/dist/chunks/{matrix-analytical-definition-DAFStKt2.js → matrix-analytical-definition-B1xhoCak.js} +1 -1
  30. package/dist/chunks/{matrix-analytical-definition-B3p3vF0K.cjs → matrix-analytical-definition-BK5y9XHH.cjs} +1 -1
  31. package/dist/chunks/{matrix-card-5R39CCdj.js → matrix-card-BEb6hr8i.js} +2 -2
  32. package/dist/chunks/{matrix-card-DzkJRoM4.cjs → matrix-card-Ii8yYSnw.cjs} +1 -1
  33. package/dist/chunks/{matrix-control-sources-BWbqiGmN.cjs → matrix-control-sources-CdegRBcA.cjs} +1 -1
  34. package/dist/chunks/{matrix-control-sources-DxjWV8ry.js → matrix-control-sources-cbYmqWNg.js} +5 -5
  35. package/dist/chunks/{matrix-definition-Z80mIEfu.cjs → matrix-definition-CSNthxru.cjs} +1 -1
  36. package/dist/chunks/{matrix-definition-BcJi7qGZ.js → matrix-definition-CZM5-YJX.js} +1 -1
  37. package/dist/chunks/{matrix-formatter-3QR1mqhn.cjs → matrix-formatter-C19PZAal.cjs} +1 -1
  38. package/dist/chunks/{matrix-formatter-youWVghC.js → matrix-formatter-CiXzpX6X.js} +27 -27
  39. package/dist/chunks/matrix-member-presentation-CQHvq18l.cjs +1 -0
  40. package/dist/chunks/matrix-member-presentation-CabW8mJc.js +105 -0
  41. package/dist/chunks/{matrix-operation-contract-D5I-t3i7.js → matrix-operation-contract-0Nor-C71.js} +21 -21
  42. package/dist/chunks/{matrix-operation-contract-BiUMcd6G.cjs → matrix-operation-contract-o9GXbiHw.cjs} +1 -1
  43. package/dist/chunks/{metric-comparison-vr9j4Z_Z.js → metric-comparison-Br8l0WkK.js} +1 -1
  44. package/dist/chunks/{metric-comparison-D1VRq5Os.cjs → metric-comparison-DeiOjEm5.cjs} +1 -1
  45. package/dist/chunks/{operators-C8TxpM4C.js → operators-B3zZoskU.js} +28 -10
  46. package/dist/chunks/operators-DEfKaU_V.cjs +1 -0
  47. package/dist/chunks/{pivot-header-presentation-Dcd4IBM5.cjs → pivot-header-presentation-DRv-cSIP.cjs} +1 -1
  48. package/dist/chunks/{pivot-header-presentation-BslEo_4O.js → pivot-header-presentation-DW-ti5ek.js} +3 -3
  49. package/dist/chunks/{pivot-result-identity-CmvwpG4K.cjs → pivot-result-identity-DEenUrMj.cjs} +1 -1
  50. package/dist/chunks/{pivot-result-identity-CMz27nri.js → pivot-result-identity-sZc1RaIz.js} +1 -1
  51. package/dist/chunks/{pivot-result-lifecycle-H_pntnd9.cjs → pivot-result-lifecycle-D81qcCcZ.cjs} +1 -1
  52. package/dist/chunks/{pivot-result-lifecycle-BCoOFUiU.js → pivot-result-lifecycle-DJ40gdwk.js} +7 -7
  53. package/dist/chunks/{raw-temporal-DcHmXurp.cjs → raw-temporal-DDTt2yv5.cjs} +1 -1
  54. package/dist/chunks/{raw-temporal-YWo1GEmr.js → raw-temporal-DHCZrFe7.js} +15 -15
  55. package/dist/chunks/{raw-temporal-contract-Bg1mtRGE.cjs → raw-temporal-contract-BcbV56Rc.cjs} +1 -1
  56. package/dist/chunks/{raw-temporal-contract-DY-Jd4Sc.js → raw-temporal-contract-CkvdtPYA.js} +1 -1
  57. package/dist/chunks/{report-preferences-dialog-Bt8T3To1.js → report-preferences-dialog-CVRJOCQu.js} +6 -6
  58. package/dist/chunks/{report-preferences-dialog-oT-C29vV.cjs → report-preferences-dialog-DGEq-iBF.cjs} +1 -1
  59. package/dist/chunks/{report-runtime-context-nCHl3uHC.js → report-runtime-context-BlDpc-F-.js} +1 -1
  60. package/dist/chunks/{report-runtime-context-Bb0ejvVq.cjs → report-runtime-context-lSIvyKm2.cjs} +1 -1
  61. package/dist/chunks/{semantic-format-CMPIcb8l.cjs → semantic-format--_VEin18.cjs} +1 -1
  62. package/dist/chunks/{semantic-format-UvUAyZS-.js → semantic-format-ew5zviaT.js} +2 -2
  63. package/dist/chunks/{source-entity-resolution-Dm4in31q.js → source-entity-resolution-79Rihbk3.js} +121 -107
  64. package/dist/chunks/source-entity-resolution-DPjslVgx.cjs +1 -0
  65. package/dist/chunks/{switch-DHOv6xHT.js → switch-BmyuyM7e.js} +4736 -4697
  66. package/dist/chunks/switch-nDjQC2y3.cjs +139 -0
  67. package/dist/chunks/{temporal-bucket-contract-CPuYzg7A.cjs → temporal-bucket-contract-BYR6tj6F.cjs} +1 -1
  68. package/dist/chunks/{temporal-bucket-contract-Bx5TJXF3.js → temporal-bucket-contract-C-kKQ_W4.js} +1 -1
  69. package/dist/chunks/{token-types-5buW2I6f.js → token-types-BIYFAsGq.js} +1 -1
  70. package/dist/chunks/{token-types-hl08eNuY.cjs → token-types-CkAGFhiW.cjs} +1 -1
  71. package/dist/chunks/{update-policy-BP_2uCgs.cjs → update-policy-BCtFr2Qh.cjs} +1 -1
  72. package/dist/chunks/{update-policy-D3I1J2kl.js → update-policy-CP_A1IVD.js} +2 -2
  73. package/dist/chunks/{validators-BpJDwDnG.js → validators-D-_IT-Xw.js} +1134 -1013
  74. package/dist/chunks/validators-ux2obZB9.cjs +1 -0
  75. package/dist/dashboard/index.cjs +1 -1
  76. package/dist/dashboard/index.js +1 -1
  77. package/dist/dashboard-authoring/index.cjs +3 -3
  78. package/dist/dashboard-authoring/index.js +157 -150
  79. package/dist/data-app-builder/index.cjs +1 -1
  80. package/dist/data-app-builder/index.js +2 -2
  81. package/dist/data-app-codegen/index.cjs +1 -1
  82. package/dist/data-app-codegen/index.js +2 -2
  83. package/dist/data-app-codegen-node/index.cjs +2 -2
  84. package/dist/data-app-codegen-node/index.js +33 -36
  85. package/dist/data-app-sdk/index.cjs +2 -2
  86. package/dist/data-app-sdk/index.js +232 -230
  87. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  88. package/dist/data-app-sdk-adapters/index.js +3 -3
  89. package/dist/data-app-sdk-validation/index.cjs +1 -1
  90. package/dist/data-app-sdk-validation/index.js +5 -5
  91. package/dist/format-utils/index.cjs +1 -1
  92. package/dist/format-utils/index.js +26 -26
  93. package/dist/index.cjs +1 -1
  94. package/dist/index.js +15 -15
  95. package/dist/report-runtime-context/index.cjs +1 -1
  96. package/dist/report-runtime-context/index.js +2 -2
  97. package/dist/style.css +1 -1
  98. package/dist/surfboard/index.cjs +1 -1
  99. package/dist/surfboard/index.js +2 -2
  100. package/dist/types/analytics-protocol.d.ts +265 -1
  101. package/dist/types/briefings.d.ts +55 -0
  102. package/dist/types/dashboard-assistant.d.ts +55 -1
  103. package/dist/types/dashboard-authoring.d.ts +140 -2
  104. package/dist/types/dashboard.d.ts +57 -0
  105. package/dist/types/data-app-builder.d.ts +32 -1
  106. package/dist/types/data-app-codegen-node.d.ts +32 -1
  107. package/dist/types/data-app-codegen.d.ts +32 -1
  108. package/dist/types/data-app-sdk-adapters.d.ts +32 -1
  109. package/dist/types/data-app-sdk-validation.d.ts +55 -1
  110. package/dist/types/data-app-sdk.d.ts +60 -1
  111. package/dist/types/format-utils.d.ts +9 -0
  112. package/dist/types/index.cjs +1 -1
  113. package/dist/types/index.js +4 -4
  114. package/dist/types/main.d.ts +122 -1
  115. package/dist/types/shared.d.ts +55 -0
  116. package/dist/types/surfboard.d.ts +57 -0
  117. package/dist/types/types.d.ts +57 -0
  118. package/package.json +1 -1
  119. package/dist/chunks/calculated-field-identity-CSabKrXt.js +0 -1117
  120. package/dist/chunks/calculated-field-identity-D4VOHjBJ.cjs +0 -1
  121. package/dist/chunks/edit-dashboard-visual-Dtacp_qY.cjs +0 -172
  122. package/dist/chunks/matrix-member-presentation-BEWAH5xK.js +0 -24
  123. package/dist/chunks/matrix-member-presentation-DtLGyv8w.cjs +0 -1
  124. package/dist/chunks/operators-DrTQsJXv.cjs +0 -1
  125. package/dist/chunks/source-entity-resolution-DeH38dTU.cjs +0 -1
  126. package/dist/chunks/switch-CatLIoK-.cjs +0 -139
  127. package/dist/chunks/validators-4dRtYUI1.cjs +0 -1
@@ -1,1117 +0,0 @@
1
- var ie = Object.defineProperty;
2
- var se = (e, t, n) => t in e ? ie(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var B = (e, t, n) => se(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { a7 as w, aa as R, aO as S, x as Z, ac as ae, u as oe, N as de, n as j, o as L, b0 as le, C as z } from "./validators-BpJDwDnG.js";
5
- import "./matrix-operation-contract-D5I-t3i7.js";
6
- import { l as ce, f as ue, h as fe } from "./field-aggregations-J7de9KZm.js";
7
- import { g as q } from "./matrix-analytical-definition-DAFStKt2.js";
8
- import { s as $ } from "./stable-serialize-CfqXeiBP.js";
9
- const me = (e, t) => {
10
- const n = {};
11
- if (e === null || t === null)
12
- return t;
13
- const r = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
14
- for (const i of r) {
15
- if (!(i in e) && i in t) {
16
- n[i] = t[i];
17
- continue;
18
- }
19
- if (i in e && !(i in t)) {
20
- n[i] = void 0;
21
- continue;
22
- }
23
- const s = e[i], d = t[i];
24
- if (!E(s, d))
25
- if (Array.isArray(s) && Array.isArray(d))
26
- n[i] = d;
27
- else if (H(s) && H(d)) {
28
- const a = me(s, d);
29
- Object.keys(a).length > 0 && (n[i] = a);
30
- } else
31
- n[i] = d;
32
- }
33
- return n;
34
- }, E = (e, t) => {
35
- if (e === t) return !0;
36
- if (e && t && typeof e == "object" && typeof t == "object") {
37
- if (Array.isArray(e) && Array.isArray(t))
38
- return e.length !== t.length ? !1 : e.every((i, s) => E(i, t[s]));
39
- const n = Object.keys(e), r = Object.keys(t);
40
- return n.length !== r.length ? !1 : n.every((i) => E(e[i], t[i]));
41
- }
42
- return !1;
43
- }, H = (e) => e !== null && typeof e == "object" && !Array.isArray(e), M = (e) => {
44
- if (e === null || typeof e != "object")
45
- return e;
46
- if (e instanceof Date)
47
- return new Date(e);
48
- if (e instanceof RegExp)
49
- return new RegExp(e);
50
- if (Array.isArray(e))
51
- return e.map((n) => M(n));
52
- const t = {};
53
- for (const n in e)
54
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = M(e[n]));
55
- return t;
56
- }, W = /\[\[\s*param\.([A-Za-z0-9_.-]+)\s*\]\]/g, G = /\bparam\s*\(\s*(['"])([^'"]+)\1/g;
57
- function pe(e) {
58
- const t = [];
59
- let n = 0;
60
- for (; n < e.length; ) {
61
- const r = e.indexOf("{{", n), i = e.indexOf("{%", n);
62
- let s = -1, d = "";
63
- if (r === -1 ? (s = i, d = "%}") : i === -1 || r < i ? (s = r, d = "}}") : (s = i, d = "%}"), s === -1)
64
- break;
65
- const a = e.indexOf(d, s + 2);
66
- if (a === -1) {
67
- n = s + 2;
68
- continue;
69
- }
70
- t.push(e.slice(s + 2, a)), n = a + 2;
71
- }
72
- return t;
73
- }
74
- function ee(e) {
75
- var r, i;
76
- if (!e)
77
- return [];
78
- const t = /* @__PURE__ */ new Set();
79
- let n;
80
- for (W.lastIndex = 0; (n = W.exec(e)) !== null; ) {
81
- const s = (r = n[1]) == null ? void 0 : r.trim();
82
- s && t.add(s);
83
- }
84
- for (const s of pe(e))
85
- for (G.lastIndex = 0; (n = G.exec(s)) !== null; ) {
86
- const d = (i = n[2]) == null ? void 0 : i.trim();
87
- d && t.add(d);
88
- }
89
- return Array.from(t);
90
- }
91
- function Ke(e) {
92
- const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
93
- for (const r of e.controlBindings || [])
94
- t.add(r.controlId), r.target === "sql_param" && n.set(r.paramId, r.controlId);
95
- for (const r of ee(e.sql))
96
- t.add(n.get(r) ?? r);
97
- return Array.from(t);
98
- }
99
- function he(e) {
100
- const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
101
- for (const r of e.controlBindings || [])
102
- r.target === "sql_param" && n.set(r.paramId, r.controlId);
103
- for (const r of ee(e.sql))
104
- t.set(r, {
105
- paramId: r,
106
- controlId: n.get(r) ?? r
107
- });
108
- return Array.from(t.values());
109
- }
110
- function ge(e, t) {
111
- var i;
112
- const n = (i = e.controlBindings) == null ? void 0 : i.map((s) => ({
113
- ...s,
114
- controlId: t.get(s.controlId) ?? s.controlId
115
- })), r = he(e).flatMap(
116
- ({ paramId: s, controlId: d }) => {
117
- var l;
118
- const a = t.get(d);
119
- return !a || a === d || (l = e.controlBindings) != null && l.some(
120
- (o) => o.target === "sql_param" && o.paramId === s
121
- ) ? [] : [{ target: "sql_param", paramId: s, controlId: a }];
122
- }
123
- );
124
- return r.length ? [...n ?? [], ...r] : n;
125
- }
126
- function te(e, t) {
127
- var i, s;
128
- const n = e.source === "dashboardInputAlias" ? ((i = t.inputAliases) == null ? void 0 : i[e.variableName]) ?? e : e, r = e.source === "dashboardInputAlias" && n !== e ? { ...n, export: e.export ?? "label" } : n;
129
- return r.source === "dashboardInput" ? {
130
- ...r,
131
- inputId: ((s = t.inputIds) == null ? void 0 : s[r.inputId]) ?? r.inputId
132
- } : r;
133
- }
134
- function Ue(e, t) {
135
- var i;
136
- const n = {};
137
- for (const s of [
138
- "cardIds",
139
- "sheetIds",
140
- "inputIds",
141
- "controlIds",
142
- "filterIds"
143
- ]) {
144
- const d = { ...t[s] };
145
- for (const [a, l] of Object.entries((e == null ? void 0 : e[s]) ?? {}))
146
- d[a] = ((i = t[s]) == null ? void 0 : i[l]) ?? l;
147
- Object.keys(d).length && (n[s] = d);
148
- }
149
- const r = { ...t.inputAliases };
150
- for (const [s, d] of Object.entries((e == null ? void 0 : e.inputAliases) ?? {}))
151
- r[s] = te(d, t);
152
- return Object.keys(r).length && (n.inputAliases = r), n;
153
- }
154
- function Ye(e, t) {
155
- var i, s, d, a;
156
- const n = M(e);
157
- n.controlBindings = ge(
158
- e,
159
- new Map(Object.entries(t.controlIds ?? {}))
160
- );
161
- for (const l of n.controls ?? [])
162
- l.id = ((i = t.controlIds) == null ? void 0 : i[l.id]) ?? l.id;
163
- for (const l of n.inlineFilters ?? [])
164
- l.id = ((s = t.filterIds) == null ? void 0 : s[l.id]) ?? l.id;
165
- const r = (l) => {
166
- var m, f, u;
167
- if (!l || typeof l != "object") return;
168
- if (Array.isArray(l)) {
169
- l.forEach(r);
170
- return;
171
- }
172
- const o = l;
173
- if (o.type === "variable" && o.ref && typeof o.ref == "object") {
174
- const p = o.ref;
175
- o.ref = p.source === "input" ? { ...p, inputId: ((m = t.inputIds) == null ? void 0 : m[p.inputId]) ?? p.inputId } : te(p, t);
176
- }
177
- if (typeof o.entityId == "string") {
178
- const p = o.entityId;
179
- o.fieldScope === "card" && (o.entityId = ((f = t.cardIds) == null ? void 0 : f[p]) ?? p), o.fieldScope === "sheet" && (o.entityId = ((u = t.sheetIds) == null ? void 0 : u[p]) ?? p);
180
- }
181
- for (const [p, F] of Object.entries(o))
182
- p !== "linkedReferenceOverrides" && r(F);
183
- };
184
- r(n);
185
- for (const l of Object.values(
186
- ((d = n.customCardPreferences) == null ? void 0 : d.dataInputCardIds) ?? {}
187
- ))
188
- l.cardId = ((a = t.cardIds) == null ? void 0 : a[l.cardId]) ?? l.cardId;
189
- return n;
190
- }
191
- function D(e) {
192
- return (e == null ? void 0 : e.trim()) || void 0;
193
- }
194
- function K(e) {
195
- return e.split(".").at(-1) || e;
196
- }
197
- function U(e, t) {
198
- var l, o;
199
- const n = D(t);
200
- if (!n) return;
201
- const r = K(n), i = D((l = e.fieldMeta) == null ? void 0 : l.name);
202
- if (i && i !== n && i !== r)
203
- return;
204
- const s = D(
205
- (o = e.fieldMeta) == null ? void 0 : o.qualifiedFieldName
206
- );
207
- if (s && K(s) !== r)
208
- return;
209
- const d = n.includes(".") ? n : void 0, a = s != null && s.includes(".") ? s : void 0;
210
- if (!(d && a && d !== a))
211
- return {
212
- leafName: r,
213
- ...d || a ? {
214
- qualifiedFieldName: d || a
215
- } : {}
216
- };
217
- }
218
- function Y(e, t) {
219
- return U(e, t) || U({}, t);
220
- }
221
- function J({
222
- source: e,
223
- sourceFieldName: t,
224
- target: n,
225
- targetFieldName: r
226
- }) {
227
- const i = Y(
228
- e,
229
- t
230
- ), s = Y(
231
- n,
232
- r
233
- );
234
- return !i || !s || i.leafName !== s.leafName ? !1 : s.qualifiedFieldName ? i.qualifiedFieldName === s.qualifiedFieldName : !0;
235
- }
236
- function x(e, t) {
237
- var i, s;
238
- const n = be(e);
239
- if (n) return n;
240
- const r = (s = (i = e == null ? void 0 : e.fieldMeta) == null ? void 0 : i.nativeDataType) == null ? void 0 : s.trim();
241
- if (C(e == null ? void 0 : e.fieldMeta, t) && r && r !== "date" && r !== "datetime")
242
- return r;
243
- }
244
- function be(e) {
245
- var n;
246
- const t = (n = e == null ? void 0 : e.nativeDataType) == null ? void 0 : n.trim();
247
- return t && t !== "date" && t !== "datetime" ? t : void 0;
248
- }
249
- function C(e, t) {
250
- var d, a;
251
- const n = t.trim();
252
- if (!n) return !1;
253
- const r = n.split(".").at(-1), i = (d = e == null ? void 0 : e.qualifiedFieldName) == null ? void 0 : d.trim();
254
- if (i && !(i === n || !i.includes(".") && i === r))
255
- return !1;
256
- const s = (a = e == null ? void 0 : e.name) == null ? void 0 : a.trim();
257
- return s && s !== n && s !== r ? !1 : !!(i || s);
258
- }
259
- function ye({
260
- fieldName: e,
261
- definition: t,
262
- value: n
263
- }) {
264
- if ((t == null ? void 0 : t.column) === e) {
265
- const r = x(t, e);
266
- if (r)
267
- return r;
268
- }
269
- return (n == null ? void 0 : n.name) === e ? x(n, e) : void 0;
270
- }
271
- function Ie({
272
- definition: e,
273
- value: t,
274
- sourceValue: n = t
275
- }) {
276
- const r = e && J({
277
- source: e,
278
- sourceFieldName: e.column,
279
- target: t,
280
- targetFieldName: t.name
281
- }) ? e : void 0, i = n && J({
282
- source: n,
283
- sourceFieldName: n.name,
284
- target: t,
285
- targetFieldName: t.name
286
- }) ? n : void 0, s = (r ? x(r, r.column) : void 0) || (i ? x(i, i.name) : void 0);
287
- return ne({
288
- carrier: t,
289
- nativeDataType: s,
290
- projectNestedNativeDataType: C(
291
- t.fieldMeta,
292
- t.name
293
- )
294
- });
295
- }
296
- function Je({
297
- filterDefinitions: e,
298
- filterValues: t
299
- }) {
300
- if (!(e != null && e.length) || !t.length)
301
- return t;
302
- const n = new Map(
303
- e.map((s) => [s.id, s])
304
- );
305
- let r = !1;
306
- const i = t.map((s) => {
307
- if (typeof s.name != "string" || !s.name.trim())
308
- return s;
309
- const d = n.get(s.filterId);
310
- if (!d)
311
- return s;
312
- const a = Ie({
313
- definition: d,
314
- value: s
315
- });
316
- return r || (r = a !== s), a;
317
- });
318
- return r ? i : t;
319
- }
320
- function Ve(e) {
321
- const t = ye({
322
- fieldName: e.column,
323
- definition: e
324
- });
325
- return ne({
326
- carrier: e,
327
- nativeDataType: t,
328
- projectNestedNativeDataType: C(
329
- e.fieldMeta,
330
- e.column
331
- )
332
- });
333
- }
334
- function ne({
335
- carrier: e,
336
- nativeDataType: t,
337
- projectNestedNativeDataType: n
338
- }) {
339
- var o;
340
- const r = (o = e.fieldMeta) == null ? void 0 : o.nativeDataType;
341
- if (t) {
342
- if (e.nativeDataType === t && (!e.fieldMeta || (n ? r === t : !r)))
343
- return e;
344
- const { nativeDataType: m, ...f } = e.fieldMeta || {};
345
- return {
346
- ...e,
347
- nativeDataType: t,
348
- ...e.fieldMeta ? {
349
- fieldMeta: n ? {
350
- ...e.fieldMeta,
351
- nativeDataType: t
352
- } : f
353
- } : {}
354
- };
355
- }
356
- if (e.nativeDataType === void 0 && r === void 0)
357
- return e;
358
- const {
359
- nativeDataType: i,
360
- fieldMeta: s,
361
- ...d
362
- } = e, { nativeDataType: a, ...l } = s || {};
363
- return {
364
- ...d,
365
- ...s ? { fieldMeta: l } : {}
366
- };
367
- }
368
- function V(e) {
369
- const t = /* @__PURE__ */ new Set();
370
- for (const n of [e.name, e.sourceField]) {
371
- if (!n) continue;
372
- const r = w(n);
373
- if (!r) continue;
374
- t.add(r);
375
- const i = r.split("."), s = i[i.length - 1];
376
- s && t.add(s);
377
- }
378
- return t;
379
- }
380
- function re(e, t) {
381
- const n = R(e), r = R(t);
382
- return n === "unknown" || r === "unknown" ? !1 : (n === "date" || n === "datetime") && (r === "date" || r === "datetime") ? !0 : n === r;
383
- }
384
- function ve(e, t) {
385
- return S(e.field.source, t.field.source) && w(e.field.name) === w(t.field.name) && w(e.field.sourceField || e.field.name) === w(t.field.sourceField || t.field.name);
386
- }
387
- function Fe(e, t) {
388
- if (e.kind !== "field") return !1;
389
- const n = V(t), r = V(e.field);
390
- return re(t.dataType, e.field.dataType) && [...r].some((i) => n.has(i));
391
- }
392
- function Xe(e) {
393
- const t = e.candidates.filter(
394
- (n) => Fe(
395
- n,
396
- e.logicalValueField
397
- )
398
- );
399
- return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
400
- }
401
- function Qe(e) {
402
- const t = [];
403
- for (const n of e.acceptedTargets)
404
- !re(
405
- e.logicalValueField.dataType,
406
- n.field.dataType
407
- ) || t.some(
408
- (r) => ve(r, n)
409
- ) || t.push(n);
410
- return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
411
- }
412
- const _e = /\{\{-?\s*filters\s*\|\s*where\s*-?\}\}/i, Te = /\{\{-?\s*filters\s*\|\s*and\s*-?\}\}/i, ke = /\bwhere\b/i;
413
- function we(e) {
414
- return e != null && e.trim() ? _e.test(e) || Te.test(e) : !1;
415
- }
416
- function Ze(e) {
417
- return !(e != null && e.trim()) || we(e) ? null : ke.test(e) ? {
418
- helper: "{{ filters | and }}",
419
- description: "For queries with an existing WHERE clause."
420
- } : {
421
- helper: "{{ filters | where }}",
422
- description: "For queries without a WHERE clause."
423
- };
424
- }
425
- function $e(e) {
426
- return (e.field.sourceField || e.field.name).trim() || void 0;
427
- }
428
- function et(e) {
429
- if (e.inventory.kind !== "sql" || e.target.kind !== "field")
430
- return { status: "ineligible" };
431
- const t = ce(
432
- e.inventory,
433
- e.target.field.source
434
- ), n = $e(e.target);
435
- if (!t || !n) return { status: "ineligible" };
436
- if (t.executionTable) {
437
- const d = [
438
- t.executionTable.databaseName,
439
- t.executionTable.schemaName,
440
- t.executionTable.tableName,
441
- n
442
- ].filter(Boolean).join(".");
443
- return {
444
- status: "eligible",
445
- source: t.source,
446
- executionIdentifier: d
447
- };
448
- }
449
- if (e.inventory.pinnedCatalogSources.length !== 1)
450
- return { status: "ineligible" };
451
- const r = w(n), i = (e.candidateTargets || []).filter(
452
- (d) => w(
453
- d.field.sourceField || d.field.name
454
- ) === r
455
- ), s = [];
456
- for (const d of i)
457
- s.some(
458
- (a) => S(a, d.field.source)
459
- ) || s.push(d.field.source);
460
- return s.length > 1 ? { status: "ineligible" } : {
461
- status: "eligible",
462
- source: t.source,
463
- executionIdentifier: n
464
- };
465
- }
466
- class Ne extends Error {
467
- constructor(n) {
468
- super(n.map((r) => r.message).join(" "));
469
- B(this, "issues");
470
- this.name = "DashboardFilterMappingContractError", this.issues = n;
471
- }
472
- }
473
- const Se = {
474
- string: !0,
475
- number: !0,
476
- boolean: !0,
477
- date: !0,
478
- datetime: !0
479
- };
480
- function v(e) {
481
- return typeof e == "string" && e.trim().length > 0;
482
- }
483
- function b(e) {
484
- return !!e && typeof e == "object" && !Array.isArray(e);
485
- }
486
- function N(e) {
487
- return Array.isArray(e) && e.every((t) => typeof t == "string");
488
- }
489
- function xe(e) {
490
- if (!b(e)) return !1;
491
- switch (e.kind) {
492
- case "allSheets":
493
- return e.sheetKinds === void 0 || N(e.sheetKinds) && e.sheetKinds.every(
494
- (t) => t === "dashboard" || t === "document"
495
- );
496
- case "sheets":
497
- return N(e.sheetIds);
498
- case "cards":
499
- return N(e.cardIds);
500
- case "documentSections":
501
- return v(e.sheetId) && N(e.sectionIds);
502
- default:
503
- return !1;
504
- }
505
- }
506
- function Ae(e) {
507
- return e === "shared" || e === "perSheet" || e === "perCard" || e === "perDocumentSection";
508
- }
509
- function De(e) {
510
- return b(e) ? v(e.id) && v(e.column) && v(e.dataType) : !1;
511
- }
512
- function Re(e, t, n, r) {
513
- var a;
514
- if (!b(t)) {
515
- r.push({
516
- code: "invalid_option_source",
517
- path: n,
518
- message: `${n} must be a semantic or physical option source.`,
519
- inputId: e
520
- });
521
- return;
522
- }
523
- const i = t.source, s = [
524
- ["labelField", t.labelField],
525
- ["valueField", t.valueField],
526
- ["searchField", t.searchField]
527
- ];
528
- if (!b(i) || i.kind !== "semantic" && i.kind !== "physical" || !Z(i) || !b(t.labelField) || !b(t.valueField) || t.searchField !== void 0 && !b(t.searchField) || t.disambiguationFields !== void 0 && (!Array.isArray(t.disambiguationFields) || !t.disambiguationFields.every(b))) {
529
- r.push({
530
- code: "invalid_option_source",
531
- path: n,
532
- message: `${n} must contain a valid semantic or physical source and field references.`,
533
- inputId: e
534
- });
535
- return;
536
- }
537
- for (const [l, o] of s)
538
- o !== void 0 && b(o) && (!v(o.name) || o.source !== void 0 && !S(
539
- o.source,
540
- i
541
- )) && r.push({
542
- code: "invalid_option_source",
543
- path: `${n}.${l}`,
544
- message: `${n}.${l} must be a named field belonging to the declared option source.`,
545
- inputId: e
546
- });
547
- for (const [l, o] of ((a = t.disambiguationFields) == null ? void 0 : a.entries()) || [])
548
- (!b(o) || !v(o.name) || o.source !== void 0 && !S(
549
- o.source,
550
- i
551
- )) && r.push({
552
- code: "invalid_option_source",
553
- path: `${n}.disambiguationFields[${l}]`,
554
- message: `${n}.disambiguationFields[${l}] must be a named field belonging to the declared option source.`,
555
- inputId: e
556
- });
557
- const d = t.valueField;
558
- ["string", "number", "boolean", "date", "datetime"].includes(
559
- String(d.dataType)
560
- ) || r.push({
561
- code: "invalid_option_source",
562
- path: `${n}.valueField.dataType`,
563
- message: `${n}.valueField.dataType must be a known option-value datatype.`,
564
- inputId: e
565
- });
566
- }
567
- function Ee(e, t, n, r, i, s) {
568
- var o;
569
- if (v(t.bindingId) || i.push({
570
- code: "invalid_binding_id",
571
- path: `${n}.bindingId`,
572
- message: `${n}.bindingId must be an opaque non-empty id.`,
573
- inputId: e,
574
- cardId: t.cardId
575
- }), ((o = t.target) == null ? void 0 : o.kind) !== "field") {
576
- i.push({
577
- code: "unsupported_target",
578
- path: `${n}.target`,
579
- message: `${n}.target must be one direct field target.`,
580
- inputId: e,
581
- cardId: t.cardId,
582
- bindingId: t.bindingId
583
- });
584
- return;
585
- }
586
- const d = t.target.field;
587
- if (!v(d == null ? void 0 : d.name) || !d.source || d.source.kind !== "semantic" && d.source.kind !== "physical" || !Z(d.source)) {
588
- i.push({
589
- code: "invalid_target_field",
590
- path: `${n}.target.field`,
591
- message: `${n}.target.field must have a name and a source-qualified semantic or physical identity.`,
592
- inputId: e,
593
- cardId: t.cardId,
594
- bindingId: t.bindingId
595
- });
596
- return;
597
- }
598
- if (Object.prototype.hasOwnProperty.call(
599
- Se,
600
- d.dataType
601
- ) || i.push({
602
- code: "unknown_target_data_type",
603
- path: `${n}.target.field.dataType`,
604
- message: `${n}.target.field.dataType must be known.`,
605
- inputId: e,
606
- cardId: t.cardId,
607
- bindingId: t.bindingId
608
- }), d.sourceField !== void 0 && !v(d.sourceField) && i.push({
609
- code: "invalid_target_field",
610
- path: `${n}.target.field.sourceField`,
611
- message: `${n}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,
612
- inputId: e,
613
- cardId: t.cardId,
614
- bindingId: t.bindingId
615
- }), !s) return;
616
- const a = r.get(t.cardId);
617
- if (!a) {
618
- i.push({
619
- code: "unknown_card",
620
- path: `${n}.cardId`,
621
- message: `${n}.cardId '${t.cardId}' does not exist.`,
622
- inputId: e,
623
- cardId: t.cardId,
624
- bindingId: t.bindingId
625
- });
626
- return;
627
- }
628
- const l = ue(a);
629
- (l.kind === "unconfigured" || !fe(l, d.source)) && i.push({
630
- code: "unavailable_card_source",
631
- path: `${n}.target.field.source`,
632
- message: `${n}.target field source is not declared by card '${a.id}'.`,
633
- inputId: e,
634
- cardId: a.id,
635
- bindingId: t.bindingId
636
- });
637
- }
638
- function Me(e, t, n, r, i, s) {
639
- if (t === void 0) return;
640
- if (!b(t) || t.kind !== "cardMappings" || !Array.isArray(t.cards)) {
641
- i.push({
642
- code: "invalid_application",
643
- path: n,
644
- message: `${n} must be a cardMappings application with a cards array.`,
645
- inputId: e
646
- });
647
- return;
648
- }
649
- const d = /* @__PURE__ */ new Set();
650
- t.cards.forEach((a, l) => {
651
- const o = `${n}.cards[${l}]`;
652
- if (!v(a == null ? void 0 : a.cardId)) {
653
- i.push({
654
- code: "unknown_card",
655
- path: `${o}.cardId`,
656
- message: `${o}.cardId is required.`,
657
- inputId: e
658
- });
659
- return;
660
- }
661
- if (d.has(a.cardId)) {
662
- i.push({
663
- code: "duplicate_card_application",
664
- path: `${o}.cardId`,
665
- message: `${n} contains more than one entry for card '${a.cardId}'.`,
666
- inputId: e,
667
- cardId: a.cardId
668
- });
669
- return;
670
- }
671
- if (d.add(a.cardId), s && !r.has(a.cardId)) {
672
- i.push({
673
- code: "unknown_card",
674
- path: `${o}.cardId`,
675
- message: `${o}.cardId '${a.cardId}' does not exist.`,
676
- inputId: e,
677
- cardId: a.cardId
678
- });
679
- return;
680
- }
681
- a.kind === "bound" ? Ee(
682
- e,
683
- a,
684
- o,
685
- r,
686
- i,
687
- s
688
- ) : a.kind !== "excluded" && i.push({
689
- code: "invalid_application",
690
- path: o,
691
- message: `${o}.kind must be 'bound' or 'excluded'.`,
692
- inputId: e,
693
- cardId: a.cardId
694
- });
695
- });
696
- }
697
- function Ce({
698
- inputs: e,
699
- dashboardFilters: t,
700
- cards: n = [],
701
- validateCardTargets: r = !1
702
- }) {
703
- const i = [], s = new Map(
704
- (t || []).map((o) => [o.id, o])
705
- ), d = new Map(
706
- r ? n.map((o) => [o.id, o]) : []
707
- ), a = [], l = /* @__PURE__ */ new Map();
708
- return e != null && !Array.isArray(e) ? (i.push({
709
- code: "invalid_input",
710
- path: "dashboard.inputs",
711
- message: "dashboard.inputs must be an array when present."
712
- }), { ok: !1, inputs: a, issues: i }) : ((Array.isArray(e) ? e : []).forEach((o, m) => {
713
- const f = `dashboard.inputs[${m}]`;
714
- if (!b(o) || o.kind !== "filter" && o.kind !== "control" || !v(o.id) || !v(o.label) || !v(o.variableName) || !xe(o.scope) || !Ae(o.runtimeScope)) {
715
- i.push({
716
- code: "invalid_input",
717
- path: f,
718
- message: `${f} must be a complete filter or control Dashboard Input envelope.`,
719
- inputId: b(o) && typeof o.id == "string" ? o.id : void 0
720
- });
721
- return;
722
- }
723
- if (o.kind === "control" && !b(o.control)) {
724
- i.push({
725
- code: "invalid_input",
726
- path: `${f}.control`,
727
- message: `${f}.control must be a control definition.`,
728
- inputId: o.id
729
- });
730
- return;
731
- }
732
- const u = o;
733
- if (u.kind === "control") {
734
- a.push(u);
735
- return;
736
- }
737
- const p = u.filter, F = u.filterReference, T = p !== void 0, k = !!F;
738
- if (T && k) {
739
- i.push({
740
- code: "both_filter_definitions",
741
- path: f,
742
- message: `${f} must contain either filter or filterReference, not both.`,
743
- inputId: u.id
744
- });
745
- return;
746
- }
747
- if (!T && !k) {
748
- i.push({
749
- code: "missing_filter_definition",
750
- path: f,
751
- message: `${f} must contain filter or filterReference.`,
752
- inputId: u.id
753
- });
754
- return;
755
- }
756
- if (T && !De(p)) {
757
- i.push({
758
- code: "invalid_input",
759
- path: `${f}.filter`,
760
- message: `${f}.filter must be a complete dashboard filter definition.`,
761
- inputId: u.id
762
- });
763
- return;
764
- }
765
- let y, c;
766
- if (T)
767
- y = p, c = "embedded";
768
- else {
769
- if ((F == null ? void 0 : F.kind) !== "dashboardFilter") {
770
- i.push({
771
- code: "invalid_filter_reference",
772
- path: `${f}.filterReference.kind`,
773
- message: `${f}.filterReference.kind must be 'dashboardFilter'.`,
774
- inputId: u.id
775
- });
776
- return;
777
- }
778
- const A = typeof (F == null ? void 0 : F.filterId) == "string" ? F.filterId : void 0;
779
- if (y = A ? s.get(A) : void 0, c = "dashboardFilter", !y) {
780
- i.push({
781
- code: "orphaned_filter_reference",
782
- path: `${f}.filterReference.filterId`,
783
- message: `${f}.filterReference cannot resolve dashboard filter '${A || ""}'.`,
784
- inputId: u.id
785
- });
786
- return;
787
- }
788
- if (y.kind === "global-date") {
789
- i.push({
790
- code: "global_date_reference",
791
- path: `${f}.filterReference`,
792
- message: `${f}.filterReference cannot reference the Global Date filter.`,
793
- inputId: u.id
794
- });
795
- return;
796
- }
797
- const P = l.get(y.id);
798
- if (P) {
799
- i.push({
800
- code: "duplicate_filter_reference",
801
- path: `${f}.filterReference.filterId`,
802
- message: `${f}.filterReference duplicates dashboard filter '${y.id}' already owned by Dashboard Input '${P}'.`,
803
- inputId: u.id
804
- });
805
- return;
806
- }
807
- l.set(y.id, u.id);
808
- }
809
- if (!y) return;
810
- if (u.forceSelection !== void 0 && typeof u.forceSelection != "boolean" && i.push({
811
- code: "invalid_input",
812
- path: `${f}.forceSelection`,
813
- message: `${f}.forceSelection must be a boolean.`,
814
- inputId: u.id
815
- }), u.optionSource !== void 0 && Re(
816
- u.id,
817
- u.optionSource,
818
- `${f}.optionSource`,
819
- i
820
- ), u.application && y.kind === "global-date") {
821
- i.push({
822
- code: "global_date_reference",
823
- path: `${f}.application`,
824
- message: `${f}.application cannot map the Global Date filter.`,
825
- inputId: u.id
826
- });
827
- return;
828
- }
829
- u.application && u.scope.kind !== "allSheets" && u.scope.kind !== "sheets" && i.push({
830
- code: "unsupported_mapped_scope",
831
- path: `${f}.scope`,
832
- message: `${f}.scope must be allSheets or sheets when cardMappings are present.`,
833
- inputId: u.id
834
- }), Me(
835
- u.id,
836
- u.application,
837
- `${f}.application`,
838
- d,
839
- i,
840
- r
841
- );
842
- const {
843
- filter: _,
844
- filterReference: g,
845
- // A reference-backed authored input must shadow the generated
846
- // dashboard-filter compatibility input. Older writers may have copied
847
- // the compatibility marker onto the reference; never preserve it.
848
- compatibility: I,
849
- ...h
850
- } = u;
851
- a.push({
852
- ...h,
853
- filter: y,
854
- ...T && I ? { compatibility: I } : {},
855
- ...u.optionSource ? {
856
- optionSource: u.optionSource
857
- } : {},
858
- definitionOrigin: c
859
- });
860
- }), i.length ? { ok: !1, inputs: a, issues: i } : { ok: !0, inputs: a });
861
- }
862
- function tt(e) {
863
- const t = Ce(e);
864
- if (!t.ok) throw new Ne(t.issues);
865
- return t.inputs;
866
- }
867
- function nt(e = () => globalThis.crypto.randomUUID()) {
868
- return e();
869
- }
870
- const Oe = {
871
- date: /* @__PURE__ */ new Set([
872
- "between",
873
- "not between",
874
- "=",
875
- "!=",
876
- ">",
877
- ">=",
878
- "<",
879
- "<=",
880
- "is null",
881
- "is not null"
882
- ]),
883
- number: /* @__PURE__ */ new Set([
884
- "between",
885
- "not between",
886
- "=",
887
- "!=",
888
- ">",
889
- ">=",
890
- "<",
891
- "<=",
892
- "in",
893
- "not in",
894
- "is null",
895
- "is not null"
896
- ]),
897
- string: /* @__PURE__ */ new Set([
898
- "=",
899
- "!=",
900
- "in",
901
- "not in",
902
- "like",
903
- "not like",
904
- "is null",
905
- "is not null"
906
- ]),
907
- boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
908
- };
909
- function Pe(e) {
910
- const t = R(e);
911
- return t === "number" || t === "boolean" ? t : t === "date" || t === "datetime" ? "date" : "string";
912
- }
913
- function rt(e, t) {
914
- return typeof t != "string" ? !1 : Oe[Pe(e)].has(t);
915
- }
916
- function X(e, t, n = (r) => {
917
- var i;
918
- return ((i = r.derivedField) == null ? void 0 : i.dataType) ?? r.dataType;
919
- }) {
920
- return t === "sql_param" || t === "presentation_currency" ? [] : t === "config_metric_selector" || t === "config_aggregation" ? e.measures.flatMap((r) => r.kind === "aggregate" ? [{ id: r.id, kind: "measure", measure: r }] : []) : ["rows", "columns"].flatMap((r) => e[r].filter((i) => t !== "config_grain" || ae(n(i.field))).map((i) => ({ id: i.id, kind: "level", axis: r, level: i })));
921
- }
922
- function it(e, t, n, r) {
923
- const i = [...e.rows, ...e.columns].find((o) => o.id === t);
924
- if (!i) throw new Error("Matrix level is no longer present.");
925
- if (r === t) return { kind: "structure", rows: e.rows, columns: e.columns };
926
- const s = e.rows.filter((o) => o.id !== t), d = e.columns.filter((o) => o.id !== t), a = n === "rows" ? s : d, l = r ? a.findIndex((o) => o.id === r) : -1;
927
- return a.splice(l < 0 ? a.length : l, 0, i), { kind: "structure", rows: s, columns: d };
928
- }
929
- function O(e, t) {
930
- const n = q(e), r = q(t), i = (a, l) => $(n[a][l]) === $(r[a][l]), s = (a) => {
931
- const l = n.rankings.find((m) => m.id === a), o = r.rankings.find((m) => m.id === a);
932
- return !!l && !!o && $(l) === $(o);
933
- };
934
- return (a, l, o = !1) => l.length <= t[a].length && l.every(
935
- (m, f) => {
936
- var u;
937
- return (m.member.kind === "value" || o && s(m.member.rankingId)) && m.levelId === ((u = t[a][f]) == null ? void 0 : u.id) && i(a, f);
938
- }
939
- );
940
- }
941
- function Q(e, t, n, r) {
942
- if (!n) return n;
943
- const i = O(e, t), s = new Set(t.measures.map((d) => d.id));
944
- return { ...n, rules: n.rules.filter((d) => {
945
- const a = d.target.matrix, l = !a || (a.levelId === void 0 || t[a.axis].some((m) => m.id === a.levelId)) && (a.oppositePath === void 0 || i(a.axis === "rows" ? "columns" : "rows", a.oppositePath, !0)), { validationRefs: o } = le(d);
946
- return l && o.every((m) => s.has(m)) ? !0 : (r.push({ kind: "conditional_format", id: d.id, message: "Removed a conditional rule whose measure, level or member path changed." }), !1);
947
- }) };
948
- }
949
- function Be(e, t, n = !1) {
950
- const r = { ...t }, i = [], s = O(e, r), d = new Set(r.measures.map((l) => l.id)), a = (l, o, m) => i.push({ kind: l, id: o, message: m });
951
- return r.sorts = r.sorts.filter((l) => {
952
- const o = r[l.axis].findIndex(
953
- (f) => f.id === l.levelId
954
- ), m = o >= 0 && (l.scope.kind === "level" || l.scope.parent.length === o && s(l.axis, l.scope.parent)) && (l.target.kind === "member" || d.has(l.target.measureId) && s(
955
- l.axis === "rows" ? "columns" : "rows",
956
- l.target.oppositePath
957
- ));
958
- return m || a(
959
- "sort",
960
- l.levelId,
961
- "Removed a sort whose level, measure or member path changed."
962
- ), m;
963
- }), r.rankings = r.rankings.filter((l) => {
964
- const o = r[l.axis].some((m) => m.id === l.levelId) && d.has(l.measureId) && s(
965
- l.axis === "rows" ? "columns" : "rows",
966
- l.oppositePath
967
- );
968
- return o || a(
969
- "ranking",
970
- l.id,
971
- "Removed a ranking whose level, measure or member path changed."
972
- ), o;
973
- }), { spec: (n ? oe : de).parse(r), notices: i };
974
- }
975
- function st(e, t, n = [], r, i = !1) {
976
- const s = [];
977
- if (t.kind !== "structure") {
978
- const c = t.kind === "presentation" ? { ...e, presentation: t.presentation } : t.kind === "defaults" ? { ...e, defaultView: t.defaultView } : t.kind === "sorts" ? { ...e, spec: { ...e.spec, sorts: t.sorts } } : {
979
- ...e,
980
- spec: { ...e.spec, rankings: t.rankings }
981
- };
982
- return t.kind === "rankings" && c.presentation.conditionalFormatting && (c.presentation = { ...c.presentation, conditionalFormatting: Q(e.spec, c.spec, c.presentation.conditionalFormatting, s) }), {
983
- config: (i ? j : L).parse(c),
984
- notices: s,
985
- removedBindings: [],
986
- bindings: n
987
- };
988
- }
989
- const d = Be(e.spec, {
990
- ...e.spec,
991
- rows: t.rows ?? e.spec.rows,
992
- columns: t.columns ?? e.spec.columns,
993
- measures: t.measures ?? e.spec.measures
994
- }, i), a = d.spec;
995
- s.push(...d.notices);
996
- const l = O(e.spec, a), o = new Set(a.measures.map((c) => c.id)), m = [...a.rows, ...a.columns], f = new Set(m.map((c) => c.id)), u = (c, _, g) => s.push({ kind: c, id: _, message: g }), p = [], F = n.flatMap((c) => {
997
- if (c.target === "sql_param" || c.target === "presentation_currency") return [c];
998
- const _ = X(e.spec, c.target, r), g = c.matrixTargetId ?? (_.length === 1 ? _[0].id : void 0);
999
- return X(a, c.target, r).some((h) => h.id === g) ? c.matrixTargetId ? [c] : (u("binding", c.controlId, "Pinned the control binding to its original Matrix target after a structural change."), [{ ...c, matrixTargetId: g }]) : (u(
1000
- "binding",
1001
- c.controlId,
1002
- "Removed a control binding whose original Matrix target is missing, ambiguous or no longer eligible."
1003
- ), p.push(c), []);
1004
- }), T = (c, _, g) => Object.fromEntries(
1005
- Object.entries(c).filter(([I]) => _.has(I) ? !0 : (u(g, I, `Removed a ${g} override for a removed field.`), !1))
1006
- ), k = {
1007
- ...e.presentation,
1008
- levelLabels: T(e.presentation.levelLabels, f, "label"),
1009
- measureLabels: T(
1010
- e.presentation.measureLabels,
1011
- o,
1012
- "label"
1013
- ),
1014
- levelFormats: T(
1015
- e.presentation.levelFormats,
1016
- f,
1017
- "format"
1018
- ),
1019
- measureFormats: T(
1020
- e.presentation.measureFormats,
1021
- o,
1022
- "format"
1023
- ),
1024
- totals: { ...e.presentation.totals }
1025
- };
1026
- k.levelFormats = Object.fromEntries(
1027
- Object.entries(k.levelFormats).filter(([c, _]) => {
1028
- const g = m.find((h) => h.id === c), I = [...e.spec.rows, ...e.spec.columns].find(
1029
- (h) => h.id === c
1030
- );
1031
- return _.type !== "temporal_bucket" || g.grain && g.grain === (I == null ? void 0 : I.grain) ? !0 : (u(
1032
- "format",
1033
- c,
1034
- "Removed a temporal format because its grain changed."
1035
- ), !1);
1036
- })
1037
- ), k.conditionalFormatting && (k.conditionalFormatting = Q(e.spec, a, k.conditionalFormatting, s));
1038
- const y = { ...e.defaultView };
1039
- for (const c of ["rows", "columns"]) {
1040
- const _ = {
1041
- ...e.presentation.totals.rows.levels,
1042
- ...e.presentation.totals.columns.levels
1043
- };
1044
- for (const h of Object.keys(e.presentation.totals[c].levels))
1045
- f.has(h) || u("total", h, "Removed subtotal settings for a removed level.");
1046
- k.totals[c] = {
1047
- ...e.presentation.totals[c],
1048
- levels: Object.fromEntries(
1049
- a[c].map((h) => [
1050
- h.id,
1051
- _[h.id] ?? { visible: !0, position: "before" }
1052
- ])
1053
- )
1054
- };
1055
- const g = e.defaultView[c], I = Math.min(g.depth, Math.max(0, a[c].length - 1));
1056
- I !== g.depth && u(
1057
- "depth",
1058
- c,
1059
- `Reduced ${c} expansion depth to fit the hierarchy.`
1060
- ), y[c] = {
1061
- depth: I,
1062
- overrides: g.overrides.filter((h) => h.path.length < a[c].length && l(c, h.path) ? !0 : (u(
1063
- "expansion",
1064
- c,
1065
- `Removed a ${c} expansion override whose path changed or became a leaf.`
1066
- ), !1))
1067
- };
1068
- }
1069
- return {
1070
- config: (i ? j : L).parse({
1071
- ...e,
1072
- spec: a,
1073
- presentation: k,
1074
- defaultView: y
1075
- }),
1076
- notices: s,
1077
- removedBindings: p,
1078
- bindings: F
1079
- };
1080
- }
1081
- function je(e) {
1082
- return !e.entityName || e.entityName === z || e.entityName === "calculated_fields" || e.qualifiedEntityName === z || e.qualifiedEntityName === "calculated_fields" ? "root" : e.qualifiedEntityName || e.entityName;
1083
- }
1084
- function at(e) {
1085
- return ["domain", e.role || "field", je(e), e.name].join("::");
1086
- }
1087
- export {
1088
- Je as A,
1089
- ee as B,
1090
- Ne as D,
1091
- Xe as a,
1092
- Qe as b,
1093
- M as c,
1094
- Fe as d,
1095
- Ze as e,
1096
- et as f,
1097
- X as g,
1098
- we as h,
1099
- tt as i,
1100
- nt as j,
1101
- Pe as k,
1102
- rt as l,
1103
- Ie as m,
1104
- Ce as n,
1105
- Ue as o,
1106
- Ye as p,
1107
- it as q,
1108
- Be as r,
1109
- Q as s,
1110
- je as t,
1111
- st as u,
1112
- at as v,
1113
- me as w,
1114
- he as x,
1115
- Ve as y,
1116
- Ke as z
1117
- };