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
@@ -0,0 +1,1266 @@
1
+ var re = Object.defineProperty;
2
+ var oe = (e, t, n) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var j = (e, t, n) => oe(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { ad as w, ag as R, aW as S, a6 as se, w as P, ai as ae, r as de, N as ce, l as L, n as z, b8 as le, C as q } from "./validators-D-_IT-Xw.js";
5
+ import "./matrix-operation-contract-0Nor-C71.js";
6
+ import { l as ue, f as fe, h as pe } from "./field-aggregations-C8kZqMTD.js";
7
+ import { g as H } from "./matrix-analytical-definition-B1xhoCak.js";
8
+ import { s as T } from "./stable-serialize-CfqXeiBP.js";
9
+ const me = (e, t) => {
10
+ const n = {};
11
+ if (e === null || t === null)
12
+ return t;
13
+ const i = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
14
+ for (const r of i) {
15
+ if (!(r in e) && r in t) {
16
+ n[r] = t[r];
17
+ continue;
18
+ }
19
+ if (r in e && !(r in t)) {
20
+ n[r] = void 0;
21
+ continue;
22
+ }
23
+ const o = e[r], d = t[r];
24
+ if (!E(o, d))
25
+ if (Array.isArray(o) && Array.isArray(d))
26
+ n[r] = d;
27
+ else if (W(o) && W(d)) {
28
+ const s = me(o, d);
29
+ Object.keys(s).length > 0 && (n[r] = s);
30
+ } else
31
+ n[r] = 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((r, o) => E(r, t[o]));
39
+ const n = Object.keys(e), i = Object.keys(t);
40
+ return n.length !== i.length ? !1 : n.every((r) => E(e[r], t[r]));
41
+ }
42
+ return !1;
43
+ }, W = (e) => e !== null && typeof e == "object" && !Array.isArray(e), O = (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) => O(n));
52
+ const t = {};
53
+ for (const n in e)
54
+ Object.prototype.hasOwnProperty.call(e, n) && (t[n] = O(e[n]));
55
+ return t;
56
+ }, G = /\[\[\s*param\.([A-Za-z0-9_.-]+)\s*\]\]/g, U = /\bparam\s*\(\s*(['"])([^'"]+)\1/g;
57
+ function he(e) {
58
+ const t = [];
59
+ let n = 0;
60
+ for (; n < e.length; ) {
61
+ const i = e.indexOf("{{", n), r = e.indexOf("{%", n);
62
+ let o = -1, d = "";
63
+ if (i === -1 ? (o = r, d = "%}") : r === -1 || i < r ? (o = i, d = "}}") : (o = r, d = "%}"), o === -1)
64
+ break;
65
+ const s = e.indexOf(d, o + 2);
66
+ if (s === -1) {
67
+ n = o + 2;
68
+ continue;
69
+ }
70
+ t.push(e.slice(o + 2, s)), n = s + 2;
71
+ }
72
+ return t;
73
+ }
74
+ function ee(e) {
75
+ var i, r;
76
+ if (!e)
77
+ return [];
78
+ const t = /* @__PURE__ */ new Set();
79
+ let n;
80
+ for (G.lastIndex = 0; (n = G.exec(e)) !== null; ) {
81
+ const o = (i = n[1]) == null ? void 0 : i.trim();
82
+ o && t.add(o);
83
+ }
84
+ for (const o of he(e))
85
+ for (U.lastIndex = 0; (n = U.exec(o)) !== null; ) {
86
+ const d = (r = n[2]) == null ? void 0 : r.trim();
87
+ d && t.add(d);
88
+ }
89
+ return Array.from(t);
90
+ }
91
+ function Ze(e) {
92
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
93
+ for (const i of e.controlBindings || [])
94
+ t.add(i.controlId), i.target === "sql_param" && n.set(i.paramId, i.controlId);
95
+ for (const i of ee(e.sql))
96
+ t.add(n.get(i) ?? i);
97
+ return Array.from(t);
98
+ }
99
+ function ge(e) {
100
+ const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
101
+ for (const i of e.controlBindings || [])
102
+ i.target === "sql_param" && n.set(i.paramId, i.controlId);
103
+ for (const i of ee(e.sql))
104
+ t.set(i, {
105
+ paramId: i,
106
+ controlId: n.get(i) ?? i
107
+ });
108
+ return Array.from(t.values());
109
+ }
110
+ function be(e, t) {
111
+ var r;
112
+ const n = (r = e.controlBindings) == null ? void 0 : r.map((o) => ({
113
+ ...o,
114
+ controlId: t.get(o.controlId) ?? o.controlId
115
+ })), i = ge(e).flatMap(
116
+ ({ paramId: o, controlId: d }) => {
117
+ var c;
118
+ const s = t.get(d);
119
+ return !s || s === d || (c = e.controlBindings) != null && c.some(
120
+ (a) => a.target === "sql_param" && a.paramId === o
121
+ ) ? [] : [{ target: "sql_param", paramId: o, controlId: s }];
122
+ }
123
+ );
124
+ return i.length ? [...n ?? [], ...i] : n;
125
+ }
126
+ function te(e, t) {
127
+ var r, o;
128
+ const n = e.source === "dashboardInputAlias" ? ((r = t.inputAliases) == null ? void 0 : r[e.variableName]) ?? e : e, i = e.source === "dashboardInputAlias" && n !== e ? { ...n, export: e.export ?? "label" } : n;
129
+ return i.source === "dashboardInput" ? {
130
+ ...i,
131
+ inputId: ((o = t.inputIds) == null ? void 0 : o[i.inputId]) ?? i.inputId
132
+ } : i;
133
+ }
134
+ function et(e, t) {
135
+ var r;
136
+ const n = {};
137
+ for (const o of [
138
+ "cardIds",
139
+ "sheetIds",
140
+ "inputIds",
141
+ "controlIds",
142
+ "filterIds"
143
+ ]) {
144
+ const d = { ...t[o] };
145
+ for (const [s, c] of Object.entries((e == null ? void 0 : e[o]) ?? {}))
146
+ d[s] = ((r = t[o]) == null ? void 0 : r[c]) ?? c;
147
+ Object.keys(d).length && (n[o] = d);
148
+ }
149
+ const i = { ...t.inputAliases };
150
+ for (const [o, d] of Object.entries((e == null ? void 0 : e.inputAliases) ?? {}))
151
+ i[o] = te(d, t);
152
+ return Object.keys(i).length && (n.inputAliases = i), n;
153
+ }
154
+ function tt(e, t) {
155
+ var r, o, d, s;
156
+ const n = O(e);
157
+ n.controlBindings = be(
158
+ e,
159
+ new Map(Object.entries(t.controlIds ?? {}))
160
+ );
161
+ for (const c of n.controls ?? [])
162
+ c.id = ((r = t.controlIds) == null ? void 0 : r[c.id]) ?? c.id;
163
+ for (const c of n.inlineFilters ?? [])
164
+ c.id = ((o = t.filterIds) == null ? void 0 : o[c.id]) ?? c.id;
165
+ const i = (c) => {
166
+ var p, f, u;
167
+ if (!c || typeof c != "object") return;
168
+ if (Array.isArray(c)) {
169
+ c.forEach(i);
170
+ return;
171
+ }
172
+ const a = c;
173
+ if (a.type === "variable" && a.ref && typeof a.ref == "object") {
174
+ const m = a.ref;
175
+ a.ref = m.source === "input" ? { ...m, inputId: ((p = t.inputIds) == null ? void 0 : p[m.inputId]) ?? m.inputId } : te(m, t);
176
+ }
177
+ if (typeof a.entityId == "string") {
178
+ const m = a.entityId;
179
+ a.fieldScope === "card" && (a.entityId = ((f = t.cardIds) == null ? void 0 : f[m]) ?? m), a.fieldScope === "sheet" && (a.entityId = ((u = t.sheetIds) == null ? void 0 : u[m]) ?? m);
180
+ }
181
+ for (const [m, _] of Object.entries(a))
182
+ m !== "linkedReferenceOverrides" && i(_);
183
+ };
184
+ i(n);
185
+ for (const c of Object.values(
186
+ ((d = n.customCardPreferences) == null ? void 0 : d.dataInputCardIds) ?? {}
187
+ ))
188
+ c.cardId = ((s = t.cardIds) == null ? void 0 : s[c.cardId]) ?? c.cardId;
189
+ return n;
190
+ }
191
+ function A(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 Y(e, t) {
198
+ var c, a;
199
+ const n = A(t);
200
+ if (!n) return;
201
+ const i = K(n), r = A((c = e.fieldMeta) == null ? void 0 : c.name);
202
+ if (r && r !== n && r !== i)
203
+ return;
204
+ const o = A(
205
+ (a = e.fieldMeta) == null ? void 0 : a.qualifiedFieldName
206
+ );
207
+ if (o && K(o) !== i)
208
+ return;
209
+ const d = n.includes(".") ? n : void 0, s = o != null && o.includes(".") ? o : void 0;
210
+ if (!(d && s && d !== s))
211
+ return {
212
+ leafName: i,
213
+ ...d || s ? {
214
+ qualifiedFieldName: d || s
215
+ } : {}
216
+ };
217
+ }
218
+ function J(e, t) {
219
+ return Y(e, t) || Y({}, t);
220
+ }
221
+ function V({
222
+ source: e,
223
+ sourceFieldName: t,
224
+ target: n,
225
+ targetFieldName: i
226
+ }) {
227
+ const r = J(
228
+ e,
229
+ t
230
+ ), o = J(
231
+ n,
232
+ i
233
+ );
234
+ return !r || !o || r.leafName !== o.leafName ? !1 : o.qualifiedFieldName ? r.qualifiedFieldName === o.qualifiedFieldName : !0;
235
+ }
236
+ function x(e, t) {
237
+ var r, o;
238
+ const n = ye(e);
239
+ if (n) return n;
240
+ const i = (o = (r = e == null ? void 0 : e.fieldMeta) == null ? void 0 : r.nativeDataType) == null ? void 0 : o.trim();
241
+ if (M(e == null ? void 0 : e.fieldMeta, t) && i && i !== "date" && i !== "datetime")
242
+ return i;
243
+ }
244
+ function ye(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 M(e, t) {
250
+ var d, s;
251
+ const n = t.trim();
252
+ if (!n) return !1;
253
+ const i = n.split(".").at(-1), r = (d = e == null ? void 0 : e.qualifiedFieldName) == null ? void 0 : d.trim();
254
+ if (r && !(r === n || !r.includes(".") && r === i))
255
+ return !1;
256
+ const o = (s = e == null ? void 0 : e.name) == null ? void 0 : s.trim();
257
+ return o && o !== n && o !== i ? !1 : !!(r || o);
258
+ }
259
+ function Ie({
260
+ fieldName: e,
261
+ definition: t,
262
+ value: n
263
+ }) {
264
+ if ((t == null ? void 0 : t.column) === e) {
265
+ const i = x(t, e);
266
+ if (i)
267
+ return i;
268
+ }
269
+ return (n == null ? void 0 : n.name) === e ? x(n, e) : void 0;
270
+ }
271
+ function ve({
272
+ definition: e,
273
+ value: t,
274
+ sourceValue: n = t
275
+ }) {
276
+ const i = e && V({
277
+ source: e,
278
+ sourceFieldName: e.column,
279
+ target: t,
280
+ targetFieldName: t.name
281
+ }) ? e : void 0, r = n && V({
282
+ source: n,
283
+ sourceFieldName: n.name,
284
+ target: t,
285
+ targetFieldName: t.name
286
+ }) ? n : void 0, o = (i ? x(i, i.column) : void 0) || (r ? x(r, r.name) : void 0);
287
+ return ne({
288
+ carrier: t,
289
+ nativeDataType: o,
290
+ projectNestedNativeDataType: M(
291
+ t.fieldMeta,
292
+ t.name
293
+ )
294
+ });
295
+ }
296
+ function nt({
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((o) => [o.id, o])
304
+ );
305
+ let i = !1;
306
+ const r = t.map((o) => {
307
+ if (typeof o.name != "string" || !o.name.trim())
308
+ return o;
309
+ const d = n.get(o.filterId);
310
+ if (!d)
311
+ return o;
312
+ const s = ve({
313
+ definition: d,
314
+ value: o
315
+ });
316
+ return i || (i = s !== o), s;
317
+ });
318
+ return i ? r : t;
319
+ }
320
+ function it(e) {
321
+ const t = Ie({
322
+ fieldName: e.column,
323
+ definition: e
324
+ });
325
+ return ne({
326
+ carrier: e,
327
+ nativeDataType: t,
328
+ projectNestedNativeDataType: M(
329
+ e.fieldMeta,
330
+ e.column
331
+ )
332
+ });
333
+ }
334
+ function ne({
335
+ carrier: e,
336
+ nativeDataType: t,
337
+ projectNestedNativeDataType: n
338
+ }) {
339
+ var a;
340
+ const i = (a = e.fieldMeta) == null ? void 0 : a.nativeDataType;
341
+ if (t) {
342
+ if (e.nativeDataType === t && (!e.fieldMeta || (n ? i === t : !i)))
343
+ return e;
344
+ const { nativeDataType: p, ...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 && i === void 0)
357
+ return e;
358
+ const {
359
+ nativeDataType: r,
360
+ fieldMeta: o,
361
+ ...d
362
+ } = e, { nativeDataType: s, ...c } = o || {};
363
+ return {
364
+ ...d,
365
+ ...o ? { fieldMeta: c } : {}
366
+ };
367
+ }
368
+ function X(e) {
369
+ const t = /* @__PURE__ */ new Set();
370
+ for (const n of [e.name, e.sourceField]) {
371
+ if (!n) continue;
372
+ const i = w(n);
373
+ if (!i) continue;
374
+ t.add(i);
375
+ const r = i.split("."), o = r[r.length - 1];
376
+ o && t.add(o);
377
+ }
378
+ return t;
379
+ }
380
+ function ie(e, t) {
381
+ const n = R(e), i = R(t);
382
+ return n === "unknown" || i === "unknown" ? !1 : (n === "date" || n === "datetime") && (i === "date" || i === "datetime") ? !0 : n === i;
383
+ }
384
+ function _e(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 = X(t), i = X(e.field);
390
+ return ie(t.dataType, e.field.dataType) && [...i].some((r) => n.has(r));
391
+ }
392
+ function rt(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 ot(e) {
402
+ const t = [];
403
+ for (const n of e.acceptedTargets)
404
+ !ie(
405
+ e.logicalValueField.dataType,
406
+ n.field.dataType
407
+ ) || t.some(
408
+ (i) => _e(i, 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 ke = /\{\{-?\s*filters\s*\|\s*where\s*-?\}\}/i, De = /\{\{-?\s*filters\s*\|\s*and\s*-?\}\}/i, we = /\bwhere\b/i;
413
+ function Te(e) {
414
+ return e != null && e.trim() ? ke.test(e) || De.test(e) : !1;
415
+ }
416
+ function st(e) {
417
+ return !(e != null && e.trim()) || Te(e) ? null : we.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 at(e) {
429
+ if (e.inventory.kind !== "sql" || e.target.kind !== "field")
430
+ return { status: "ineligible" };
431
+ const t = ue(
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 i = w(n), r = (e.candidateTargets || []).filter(
452
+ (d) => w(
453
+ d.field.sourceField || d.field.name
454
+ ) === i
455
+ ), o = [];
456
+ for (const d of r)
457
+ o.some(
458
+ (s) => S(s, d.field.source)
459
+ ) || o.push(d.field.source);
460
+ return o.length > 1 ? { status: "ineligible" } : {
461
+ status: "eligible",
462
+ source: t.source,
463
+ executionIdentifier: n
464
+ };
465
+ }
466
+ const Se = Object.freeze({ mode: "all_applicable" });
467
+ function xe(e) {
468
+ if (e === void 0)
469
+ return { ok: !0, dependencies: { ...Se } };
470
+ const t = se(e, "dashboard");
471
+ if (!t.ok)
472
+ return {
473
+ ok: !1,
474
+ error: "Invalid dashboard option dependency policy.",
475
+ issues: t.errors.map((i) => i.message)
476
+ };
477
+ const n = e;
478
+ switch (n.mode) {
479
+ case "independent":
480
+ return { ok: !0, dependencies: { mode: "independent" } };
481
+ case "explicit":
482
+ return {
483
+ ok: !0,
484
+ dependencies: {
485
+ mode: "explicit",
486
+ includeInputIds: [...n.includeInputIds || []]
487
+ }
488
+ };
489
+ case "all_applicable":
490
+ return {
491
+ ok: !0,
492
+ dependencies: {
493
+ mode: "all_applicable",
494
+ ...n.excludeInputIds ? { excludeInputIds: [...n.excludeInputIds] } : {}
495
+ }
496
+ };
497
+ default:
498
+ return {
499
+ ok: !1,
500
+ error: "Invalid dashboard option dependency policy.",
501
+ issues: ["Dashboard option dependencies must declare a mode."]
502
+ };
503
+ }
504
+ }
505
+ function Ne(e) {
506
+ if (e === void 0) return { ok: !0, population: void 0 };
507
+ const t = { ok: !1, error: "Invalid option population." };
508
+ if (!e || typeof e != "object" || Array.isArray(e)) return t;
509
+ const n = e;
510
+ if (n.kind === "option_source")
511
+ return { ok: !0, population: { kind: "option_source" } };
512
+ if (n.kind !== "related_population") return t;
513
+ const i = n.baseSource;
514
+ if (!i || i.kind !== "semantic" || !P(i))
515
+ return t;
516
+ const r = n.relationshipHint;
517
+ return r !== void 0 && (!r || typeof r != "object" || r.relationshipIds !== void 0 && (!Array.isArray(r.relationshipIds) || r.relationshipIds.some(
518
+ (o) => typeof o != "string" || !o.trim()
519
+ ))) ? t : {
520
+ ok: !0,
521
+ population: {
522
+ kind: "related_population",
523
+ baseSource: i,
524
+ ...r ? { relationshipHint: r } : {}
525
+ }
526
+ };
527
+ }
528
+ function dt(e) {
529
+ const { dependencies: t } = e, n = /* @__PURE__ */ new Set([
530
+ e.targetInputId,
531
+ ...t.excludeInputIds || []
532
+ ]);
533
+ return t.mode === "independent" ? [] : t.mode === "explicit" ? (t.includeInputIds || []).filter(
534
+ (i) => !n.has(i)
535
+ ) : e.peerInputIds.filter((i) => !n.has(i));
536
+ }
537
+ function ct(e, t, n) {
538
+ if (t === n) return e;
539
+ let i = !1;
540
+ const r = (d) => d != null && d.includes(t) ? (i = !0, Array.from(
541
+ new Set(d.map((s) => s === t ? n : s))
542
+ )) : d, o = e.map((d) => {
543
+ const s = d.optionDependencies;
544
+ if (!s) return d;
545
+ const c = r(s.includeInputIds), a = r(s.excludeInputIds);
546
+ return c === s.includeInputIds && a === s.excludeInputIds ? d : {
547
+ ...d,
548
+ optionDependencies: {
549
+ ...s,
550
+ ...c ? { includeInputIds: c } : {},
551
+ ...a ? { excludeInputIds: a } : {}
552
+ }
553
+ };
554
+ });
555
+ return i ? o : e;
556
+ }
557
+ function lt(e, t) {
558
+ const n = Ae(
559
+ e.dependencies,
560
+ t
561
+ );
562
+ return n === e.dependencies ? e : { ...e, dependencies: n };
563
+ }
564
+ function Ae(e, t) {
565
+ if (!(t != null && t.length) || e.mode !== "explicit")
566
+ return e;
567
+ const n = new Set(e.includeInputIds || []), i = Array.from(new Set(t)).filter(
568
+ (r) => n.has(r)
569
+ );
570
+ return i.length ? { ...e, omitInputIds: i } : e;
571
+ }
572
+ class Re extends Error {
573
+ constructor(n) {
574
+ super(n.map((i) => i.message).join(" "));
575
+ j(this, "issues");
576
+ this.name = "DashboardFilterMappingContractError", this.issues = n;
577
+ }
578
+ }
579
+ const Ee = {
580
+ string: !0,
581
+ number: !0,
582
+ boolean: !0,
583
+ date: !0,
584
+ datetime: !0
585
+ };
586
+ function v(e) {
587
+ return typeof e == "string" && e.trim().length > 0;
588
+ }
589
+ function h(e) {
590
+ return !!e && typeof e == "object" && !Array.isArray(e);
591
+ }
592
+ function $(e) {
593
+ return Array.isArray(e) && e.every((t) => typeof t == "string");
594
+ }
595
+ function Oe(e) {
596
+ if (!h(e)) return !1;
597
+ switch (e.kind) {
598
+ case "allSheets":
599
+ return e.sheetKinds === void 0 || $(e.sheetKinds) && e.sheetKinds.every(
600
+ (t) => t === "dashboard" || t === "document"
601
+ );
602
+ case "sheets":
603
+ return $(e.sheetIds);
604
+ case "cards":
605
+ return $(e.cardIds);
606
+ case "documentSections":
607
+ return v(e.sheetId) && $(e.sectionIds);
608
+ default:
609
+ return !1;
610
+ }
611
+ }
612
+ function Pe(e) {
613
+ return e === "shared" || e === "perSheet" || e === "perCard" || e === "perDocumentSection";
614
+ }
615
+ function Me(e) {
616
+ return h(e) ? v(e.id) && v(e.column) && v(e.dataType) : !1;
617
+ }
618
+ function Ce(e, t, n, i) {
619
+ var s;
620
+ if (!h(t)) {
621
+ i.push({
622
+ code: "invalid_option_source",
623
+ path: n,
624
+ message: `${n} must be a semantic or physical option source.`,
625
+ inputId: e
626
+ });
627
+ return;
628
+ }
629
+ const r = t.source, o = [
630
+ ["labelField", t.labelField],
631
+ ["valueField", t.valueField],
632
+ ["searchField", t.searchField]
633
+ ];
634
+ if (!h(r) || r.kind !== "semantic" && r.kind !== "physical" || !P(r) || !h(t.labelField) || !h(t.valueField) || t.searchField !== void 0 && !h(t.searchField) || t.disambiguationFields !== void 0 && (!Array.isArray(t.disambiguationFields) || !t.disambiguationFields.every(h))) {
635
+ i.push({
636
+ code: "invalid_option_source",
637
+ path: n,
638
+ message: `${n} must contain a valid semantic or physical source and field references.`,
639
+ inputId: e
640
+ });
641
+ return;
642
+ }
643
+ for (const [c, a] of o)
644
+ a !== void 0 && h(a) && (!v(a.name) || a.source !== void 0 && !S(
645
+ a.source,
646
+ r
647
+ )) && i.push({
648
+ code: "invalid_option_source",
649
+ path: `${n}.${c}`,
650
+ message: `${n}.${c} must be a named field belonging to the declared option source.`,
651
+ inputId: e
652
+ });
653
+ for (const [c, a] of ((s = t.disambiguationFields) == null ? void 0 : s.entries()) || [])
654
+ (!h(a) || !v(a.name) || a.source !== void 0 && !S(
655
+ a.source,
656
+ r
657
+ )) && i.push({
658
+ code: "invalid_option_source",
659
+ path: `${n}.disambiguationFields[${c}]`,
660
+ message: `${n}.disambiguationFields[${c}] must be a named field belonging to the declared option source.`,
661
+ inputId: e
662
+ });
663
+ const d = t.valueField;
664
+ ["string", "number", "boolean", "date", "datetime"].includes(
665
+ String(d.dataType)
666
+ ) || i.push({
667
+ code: "invalid_option_source",
668
+ path: `${n}.valueField.dataType`,
669
+ message: `${n}.valueField.dataType must be a known option-value datatype.`,
670
+ inputId: e
671
+ });
672
+ }
673
+ function Be(e, t, n) {
674
+ var i;
675
+ if (e.optionDependencies !== void 0) {
676
+ const r = xe(e.optionDependencies);
677
+ r.ok ? h(e.optionDependencies) && e.optionDependencies.omitInputIds !== void 0 && n.push({
678
+ code: "invalid_option_dependencies",
679
+ path: `${t}.optionDependencies.omitInputIds`,
680
+ message: `${t}.optionDependencies cannot persist a browse override (omitInputIds).`,
681
+ inputId: e.id
682
+ }) : n.push({
683
+ code: "invalid_option_dependencies",
684
+ path: `${t}.optionDependencies`,
685
+ message: `${t}.optionDependencies ${r.issues.join("; ") || r.error}`,
686
+ inputId: e.id
687
+ });
688
+ }
689
+ if (e.optionPopulation !== void 0) {
690
+ const r = Ne(e.optionPopulation);
691
+ r.ok ? ((i = r.population) == null ? void 0 : i.kind) === "related_population" && !je(e.optionSource) && n.push({
692
+ code: "invalid_option_population",
693
+ path: `${t}.optionPopulation`,
694
+ message: `${t}.optionPopulation related_population requires an authored semantic optionSource.`,
695
+ inputId: e.id
696
+ }) : n.push({
697
+ code: "invalid_option_population",
698
+ path: `${t}.optionPopulation`,
699
+ message: `${t}.optionPopulation must be option_source or a related_population with a complete semantic baseSource.`,
700
+ inputId: e.id
701
+ });
702
+ }
703
+ }
704
+ function je(e) {
705
+ return h(e) && h(e.source) && e.source.kind === "semantic";
706
+ }
707
+ function Le(e, t, n, i, r, o) {
708
+ var a;
709
+ if (v(t.bindingId) || r.push({
710
+ code: "invalid_binding_id",
711
+ path: `${n}.bindingId`,
712
+ message: `${n}.bindingId must be an opaque non-empty id.`,
713
+ inputId: e,
714
+ cardId: t.cardId
715
+ }), ((a = t.target) == null ? void 0 : a.kind) !== "field") {
716
+ r.push({
717
+ code: "unsupported_target",
718
+ path: `${n}.target`,
719
+ message: `${n}.target must be one direct field target.`,
720
+ inputId: e,
721
+ cardId: t.cardId,
722
+ bindingId: t.bindingId
723
+ });
724
+ return;
725
+ }
726
+ const d = t.target.field;
727
+ if (!v(d == null ? void 0 : d.name) || !d.source || d.source.kind !== "semantic" && d.source.kind !== "physical" || !P(d.source)) {
728
+ r.push({
729
+ code: "invalid_target_field",
730
+ path: `${n}.target.field`,
731
+ message: `${n}.target.field must have a name and a source-qualified semantic or physical identity.`,
732
+ inputId: e,
733
+ cardId: t.cardId,
734
+ bindingId: t.bindingId
735
+ });
736
+ return;
737
+ }
738
+ if (Object.prototype.hasOwnProperty.call(
739
+ Ee,
740
+ d.dataType
741
+ ) || r.push({
742
+ code: "unknown_target_data_type",
743
+ path: `${n}.target.field.dataType`,
744
+ message: `${n}.target.field.dataType must be known.`,
745
+ inputId: e,
746
+ cardId: t.cardId,
747
+ bindingId: t.bindingId
748
+ }), d.sourceField !== void 0 && !v(d.sourceField) && r.push({
749
+ code: "invalid_target_field",
750
+ path: `${n}.target.field.sourceField`,
751
+ message: `${n}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,
752
+ inputId: e,
753
+ cardId: t.cardId,
754
+ bindingId: t.bindingId
755
+ }), !o) return;
756
+ const s = i.get(t.cardId);
757
+ if (!s) {
758
+ r.push({
759
+ code: "unknown_card",
760
+ path: `${n}.cardId`,
761
+ message: `${n}.cardId '${t.cardId}' does not exist.`,
762
+ inputId: e,
763
+ cardId: t.cardId,
764
+ bindingId: t.bindingId
765
+ });
766
+ return;
767
+ }
768
+ const c = fe(s);
769
+ (c.kind === "unconfigured" || !pe(c, d.source)) && r.push({
770
+ code: "unavailable_card_source",
771
+ path: `${n}.target.field.source`,
772
+ message: `${n}.target field source is not declared by card '${s.id}'.`,
773
+ inputId: e,
774
+ cardId: s.id,
775
+ bindingId: t.bindingId
776
+ });
777
+ }
778
+ function ze(e, t, n, i, r, o) {
779
+ if (t === void 0) return;
780
+ if (!h(t) || t.kind !== "cardMappings" || !Array.isArray(t.cards)) {
781
+ r.push({
782
+ code: "invalid_application",
783
+ path: n,
784
+ message: `${n} must be a cardMappings application with a cards array.`,
785
+ inputId: e
786
+ });
787
+ return;
788
+ }
789
+ const d = /* @__PURE__ */ new Set();
790
+ t.cards.forEach((s, c) => {
791
+ const a = `${n}.cards[${c}]`;
792
+ if (!v(s == null ? void 0 : s.cardId)) {
793
+ r.push({
794
+ code: "unknown_card",
795
+ path: `${a}.cardId`,
796
+ message: `${a}.cardId is required.`,
797
+ inputId: e
798
+ });
799
+ return;
800
+ }
801
+ if (d.has(s.cardId)) {
802
+ r.push({
803
+ code: "duplicate_card_application",
804
+ path: `${a}.cardId`,
805
+ message: `${n} contains more than one entry for card '${s.cardId}'.`,
806
+ inputId: e,
807
+ cardId: s.cardId
808
+ });
809
+ return;
810
+ }
811
+ if (d.add(s.cardId), o && !i.has(s.cardId)) {
812
+ r.push({
813
+ code: "unknown_card",
814
+ path: `${a}.cardId`,
815
+ message: `${a}.cardId '${s.cardId}' does not exist.`,
816
+ inputId: e,
817
+ cardId: s.cardId
818
+ });
819
+ return;
820
+ }
821
+ s.kind === "bound" ? Le(
822
+ e,
823
+ s,
824
+ a,
825
+ i,
826
+ r,
827
+ o
828
+ ) : s.kind !== "excluded" && r.push({
829
+ code: "invalid_application",
830
+ path: a,
831
+ message: `${a}.kind must be 'bound' or 'excluded'.`,
832
+ inputId: e,
833
+ cardId: s.cardId
834
+ });
835
+ });
836
+ }
837
+ function qe({
838
+ inputs: e,
839
+ dashboardFilters: t,
840
+ cards: n = [],
841
+ validateCardTargets: i = !1
842
+ }) {
843
+ const r = [], o = new Map(
844
+ (t || []).map((a) => [a.id, a])
845
+ ), d = new Map(
846
+ i ? n.map((a) => [a.id, a]) : []
847
+ ), s = [], c = /* @__PURE__ */ new Map();
848
+ return e != null && !Array.isArray(e) ? (r.push({
849
+ code: "invalid_input",
850
+ path: "dashboard.inputs",
851
+ message: "dashboard.inputs must be an array when present."
852
+ }), { ok: !1, inputs: s, issues: r }) : ((Array.isArray(e) ? e : []).forEach((a, p) => {
853
+ const f = `dashboard.inputs[${p}]`;
854
+ if (!h(a) || a.kind !== "filter" && a.kind !== "control" || !v(a.id) || !v(a.label) || !v(a.variableName) || !Oe(a.scope) || !Pe(a.runtimeScope)) {
855
+ r.push({
856
+ code: "invalid_input",
857
+ path: f,
858
+ message: `${f} must be a complete filter or control Dashboard Input envelope.`,
859
+ inputId: h(a) && typeof a.id == "string" ? a.id : void 0
860
+ });
861
+ return;
862
+ }
863
+ if (a.kind === "control" && !h(a.control)) {
864
+ r.push({
865
+ code: "invalid_input",
866
+ path: `${f}.control`,
867
+ message: `${f}.control must be a control definition.`,
868
+ inputId: a.id
869
+ });
870
+ return;
871
+ }
872
+ const u = a;
873
+ if (u.kind === "control") {
874
+ s.push(u);
875
+ return;
876
+ }
877
+ const m = u.filter, _ = u.filterReference, k = m !== void 0, D = !!_;
878
+ if (k && D) {
879
+ r.push({
880
+ code: "both_filter_definitions",
881
+ path: f,
882
+ message: `${f} must contain either filter or filterReference, not both.`,
883
+ inputId: u.id
884
+ });
885
+ return;
886
+ }
887
+ if (!k && !D) {
888
+ r.push({
889
+ code: "missing_filter_definition",
890
+ path: f,
891
+ message: `${f} must contain filter or filterReference.`,
892
+ inputId: u.id
893
+ });
894
+ return;
895
+ }
896
+ if (k && !Me(m)) {
897
+ r.push({
898
+ code: "invalid_input",
899
+ path: `${f}.filter`,
900
+ message: `${f}.filter must be a complete dashboard filter definition.`,
901
+ inputId: u.id
902
+ });
903
+ return;
904
+ }
905
+ let y, l;
906
+ if (k)
907
+ y = m, l = "embedded";
908
+ else {
909
+ if ((_ == null ? void 0 : _.kind) !== "dashboardFilter") {
910
+ r.push({
911
+ code: "invalid_filter_reference",
912
+ path: `${f}.filterReference.kind`,
913
+ message: `${f}.filterReference.kind must be 'dashboardFilter'.`,
914
+ inputId: u.id
915
+ });
916
+ return;
917
+ }
918
+ const N = typeof (_ == null ? void 0 : _.filterId) == "string" ? _.filterId : void 0;
919
+ if (y = N ? o.get(N) : void 0, l = "dashboardFilter", !y) {
920
+ r.push({
921
+ code: "orphaned_filter_reference",
922
+ path: `${f}.filterReference.filterId`,
923
+ message: `${f}.filterReference cannot resolve dashboard filter '${N || ""}'.`,
924
+ inputId: u.id
925
+ });
926
+ return;
927
+ }
928
+ if (y.kind === "global-date") {
929
+ r.push({
930
+ code: "global_date_reference",
931
+ path: `${f}.filterReference`,
932
+ message: `${f}.filterReference cannot reference the Global Date filter.`,
933
+ inputId: u.id
934
+ });
935
+ return;
936
+ }
937
+ const B = c.get(y.id);
938
+ if (B) {
939
+ r.push({
940
+ code: "duplicate_filter_reference",
941
+ path: `${f}.filterReference.filterId`,
942
+ message: `${f}.filterReference duplicates dashboard filter '${y.id}' already owned by Dashboard Input '${B}'.`,
943
+ inputId: u.id
944
+ });
945
+ return;
946
+ }
947
+ c.set(y.id, u.id);
948
+ }
949
+ if (!y) return;
950
+ if (u.forceSelection !== void 0 && typeof u.forceSelection != "boolean" && r.push({
951
+ code: "invalid_input",
952
+ path: `${f}.forceSelection`,
953
+ message: `${f}.forceSelection must be a boolean.`,
954
+ inputId: u.id
955
+ }), u.optionSource !== void 0 && Ce(
956
+ u.id,
957
+ u.optionSource,
958
+ `${f}.optionSource`,
959
+ r
960
+ ), Be(u, f, r), u.application && y.kind === "global-date") {
961
+ r.push({
962
+ code: "global_date_reference",
963
+ path: `${f}.application`,
964
+ message: `${f}.application cannot map the Global Date filter.`,
965
+ inputId: u.id
966
+ });
967
+ return;
968
+ }
969
+ u.application && u.scope.kind !== "allSheets" && u.scope.kind !== "sheets" && r.push({
970
+ code: "unsupported_mapped_scope",
971
+ path: `${f}.scope`,
972
+ message: `${f}.scope must be allSheets or sheets when cardMappings are present.`,
973
+ inputId: u.id
974
+ }), ze(
975
+ u.id,
976
+ u.application,
977
+ `${f}.application`,
978
+ d,
979
+ r,
980
+ i
981
+ );
982
+ const {
983
+ filter: F,
984
+ filterReference: b,
985
+ // A reference-backed authored input must shadow the generated
986
+ // dashboard-filter compatibility input. Older writers may have copied
987
+ // the compatibility marker onto the reference; never preserve it.
988
+ compatibility: I,
989
+ ...g
990
+ } = u;
991
+ s.push({
992
+ ...g,
993
+ filter: y,
994
+ ...k && I ? { compatibility: I } : {},
995
+ ...u.optionSource ? {
996
+ optionSource: u.optionSource
997
+ } : {},
998
+ ...u.optionDependencies ? { optionDependencies: u.optionDependencies } : {},
999
+ ...u.optionPopulation ? { optionPopulation: u.optionPopulation } : {},
1000
+ definitionOrigin: l
1001
+ });
1002
+ }), r.length ? { ok: !1, inputs: s, issues: r } : { ok: !0, inputs: s });
1003
+ }
1004
+ function ut(e) {
1005
+ const t = qe(e);
1006
+ if (!t.ok) throw new Re(t.issues);
1007
+ return t.inputs;
1008
+ }
1009
+ function ft(e = () => globalThis.crypto.randomUUID()) {
1010
+ return e();
1011
+ }
1012
+ const He = {
1013
+ date: /* @__PURE__ */ new Set([
1014
+ "between",
1015
+ "not between",
1016
+ "=",
1017
+ "!=",
1018
+ ">",
1019
+ ">=",
1020
+ "<",
1021
+ "<=",
1022
+ "is null",
1023
+ "is not null"
1024
+ ]),
1025
+ number: /* @__PURE__ */ new Set([
1026
+ "between",
1027
+ "not between",
1028
+ "=",
1029
+ "!=",
1030
+ ">",
1031
+ ">=",
1032
+ "<",
1033
+ "<=",
1034
+ "in",
1035
+ "not in",
1036
+ "is null",
1037
+ "is not null"
1038
+ ]),
1039
+ string: /* @__PURE__ */ new Set([
1040
+ "=",
1041
+ "!=",
1042
+ "in",
1043
+ "not in",
1044
+ "like",
1045
+ "not like",
1046
+ "is null",
1047
+ "is not null"
1048
+ ]),
1049
+ boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
1050
+ };
1051
+ function We(e) {
1052
+ const t = R(e);
1053
+ return t === "number" || t === "boolean" ? t : t === "date" || t === "datetime" ? "date" : "string";
1054
+ }
1055
+ function pt(e, t) {
1056
+ return typeof t != "string" ? !1 : He[We(e)].has(t);
1057
+ }
1058
+ function Q(e, t, n = (i) => {
1059
+ var r;
1060
+ return ((r = i.derivedField) == null ? void 0 : r.dataType) ?? i.dataType;
1061
+ }) {
1062
+ return t === "sql_param" || t === "presentation_currency" ? [] : t === "config_metric_selector" || t === "config_aggregation" ? e.measures.flatMap((i) => i.kind === "aggregate" ? [{ id: i.id, kind: "measure", measure: i }] : []) : ["rows", "columns"].flatMap((i) => e[i].filter((r) => t !== "config_grain" || ae(n(r.field))).map((r) => ({ id: r.id, kind: "level", axis: i, level: r })));
1063
+ }
1064
+ function mt(e, t, n, i) {
1065
+ const r = [...e.rows, ...e.columns].find((a) => a.id === t);
1066
+ if (!r) throw new Error("Matrix level is no longer present.");
1067
+ if (i === t) return { kind: "structure", rows: e.rows, columns: e.columns };
1068
+ const o = e.rows.filter((a) => a.id !== t), d = e.columns.filter((a) => a.id !== t), s = n === "rows" ? o : d, c = i ? s.findIndex((a) => a.id === i) : -1;
1069
+ return s.splice(c < 0 ? s.length : c, 0, r), { kind: "structure", rows: o, columns: d };
1070
+ }
1071
+ function C(e, t) {
1072
+ const n = H(e), i = H(t), r = (s, c) => T(n[s][c]) === T(i[s][c]), o = (s) => {
1073
+ const c = n.rankings.find((p) => p.id === s), a = i.rankings.find((p) => p.id === s);
1074
+ return !!c && !!a && T(c) === T(a);
1075
+ };
1076
+ return (s, c, a = !1) => c.length <= t[s].length && c.every(
1077
+ (p, f) => {
1078
+ var u;
1079
+ return (p.member.kind === "value" || a && o(p.member.rankingId)) && p.levelId === ((u = t[s][f]) == null ? void 0 : u.id) && r(s, f);
1080
+ }
1081
+ );
1082
+ }
1083
+ function Z(e, t, n, i) {
1084
+ if (!n) return n;
1085
+ const r = C(e, t), o = new Set(t.measures.map((d) => d.id));
1086
+ return { ...n, rules: n.rules.filter((d) => {
1087
+ const s = d.target.matrix, c = !s || (s.levelId === void 0 || t[s.axis].some((p) => p.id === s.levelId)) && (s.oppositePath === void 0 || r(s.axis === "rows" ? "columns" : "rows", s.oppositePath, !0)), { validationRefs: a } = le(d);
1088
+ return c && a.every((p) => o.has(p)) ? !0 : (i.push({ kind: "conditional_format", id: d.id, message: "Removed a conditional rule whose measure, level or member path changed." }), !1);
1089
+ }) };
1090
+ }
1091
+ function Ge(e, t, n = !1) {
1092
+ const i = { ...t }, r = [], o = C(e, i), d = new Set(i.measures.map((c) => c.id)), s = (c, a, p) => r.push({ kind: c, id: a, message: p });
1093
+ return i.sorts = i.sorts.filter((c) => {
1094
+ const a = i[c.axis].findIndex(
1095
+ (f) => f.id === c.levelId
1096
+ ), p = a >= 0 && (c.scope.kind === "level" || c.scope.parent.length === a && o(c.axis, c.scope.parent)) && (c.target.kind === "member" || d.has(c.target.measureId) && o(
1097
+ c.axis === "rows" ? "columns" : "rows",
1098
+ c.target.oppositePath
1099
+ ));
1100
+ return p || s(
1101
+ "sort",
1102
+ c.levelId,
1103
+ "Removed a sort whose level, measure or member path changed."
1104
+ ), p;
1105
+ }), i.rankings = i.rankings.filter((c) => {
1106
+ const a = i[c.axis].some((p) => p.id === c.levelId) && d.has(c.measureId) && o(
1107
+ c.axis === "rows" ? "columns" : "rows",
1108
+ c.oppositePath
1109
+ );
1110
+ return a || s(
1111
+ "ranking",
1112
+ c.id,
1113
+ "Removed a ranking whose level, measure or member path changed."
1114
+ ), a;
1115
+ }), { spec: (n ? de : ce).parse(i), notices: r };
1116
+ }
1117
+ function ht(e, t, n = [], i, r = !1) {
1118
+ const o = [];
1119
+ if (t.kind !== "structure") {
1120
+ const l = t.kind === "presentation" ? { ...e, presentation: t.presentation } : t.kind === "defaults" ? { ...e, defaultView: t.defaultView } : t.kind === "sorts" ? { ...e, spec: { ...e.spec, sorts: t.sorts } } : {
1121
+ ...e,
1122
+ spec: { ...e.spec, rankings: t.rankings }
1123
+ };
1124
+ return t.kind === "rankings" && l.presentation.conditionalFormatting && (l.presentation = { ...l.presentation, conditionalFormatting: Z(e.spec, l.spec, l.presentation.conditionalFormatting, o) }), {
1125
+ config: (r ? L : z).parse(l),
1126
+ notices: o,
1127
+ removedBindings: [],
1128
+ bindings: n
1129
+ };
1130
+ }
1131
+ const d = Ge(e.spec, {
1132
+ ...e.spec,
1133
+ rows: t.rows ?? e.spec.rows,
1134
+ columns: t.columns ?? e.spec.columns,
1135
+ measures: t.measures ?? e.spec.measures
1136
+ }, r), s = d.spec;
1137
+ o.push(...d.notices);
1138
+ const c = C(e.spec, s), a = new Set(s.measures.map((l) => l.id)), p = [...s.rows, ...s.columns], f = new Set(p.map((l) => l.id)), u = (l, F, b) => o.push({ kind: l, id: F, message: b }), m = [], _ = n.flatMap((l) => {
1139
+ if (l.target === "sql_param" || l.target === "presentation_currency") return [l];
1140
+ const F = Q(e.spec, l.target, i), b = l.matrixTargetId ?? (F.length === 1 ? F[0].id : void 0);
1141
+ return Q(s, l.target, i).some((g) => g.id === b) ? l.matrixTargetId ? [l] : (u("binding", l.controlId, "Pinned the control binding to its original Matrix target after a structural change."), [{ ...l, matrixTargetId: b }]) : (u(
1142
+ "binding",
1143
+ l.controlId,
1144
+ "Removed a control binding whose original Matrix target is missing, ambiguous or no longer eligible."
1145
+ ), m.push(l), []);
1146
+ }), k = (l, F, b) => Object.fromEntries(
1147
+ Object.entries(l).filter(([I]) => F.has(I) ? !0 : (u(b, I, `Removed a ${b} override for a removed field.`), !1))
1148
+ ), D = {
1149
+ ...e.presentation,
1150
+ levelLabels: k(e.presentation.levelLabels, f, "label"),
1151
+ measureLabels: k(
1152
+ e.presentation.measureLabels,
1153
+ a,
1154
+ "label"
1155
+ ),
1156
+ levelFormats: k(
1157
+ e.presentation.levelFormats,
1158
+ f,
1159
+ "format"
1160
+ ),
1161
+ measureFormats: k(
1162
+ e.presentation.measureFormats,
1163
+ a,
1164
+ "format"
1165
+ ),
1166
+ totals: { ...e.presentation.totals }
1167
+ };
1168
+ D.levelFormats = Object.fromEntries(
1169
+ Object.entries(D.levelFormats).filter(([l, F]) => {
1170
+ const b = p.find((g) => g.id === l), I = [...e.spec.rows, ...e.spec.columns].find(
1171
+ (g) => g.id === l
1172
+ );
1173
+ return F.type !== "temporal_bucket" || b.grain && b.grain === (I == null ? void 0 : I.grain) ? !0 : (u(
1174
+ "format",
1175
+ l,
1176
+ "Removed a temporal format because its grain changed."
1177
+ ), !1);
1178
+ })
1179
+ ), D.conditionalFormatting && (D.conditionalFormatting = Z(e.spec, s, D.conditionalFormatting, o));
1180
+ const y = { ...e.defaultView };
1181
+ for (const l of ["rows", "columns"]) {
1182
+ const F = {
1183
+ ...e.presentation.totals.rows.levels,
1184
+ ...e.presentation.totals.columns.levels
1185
+ };
1186
+ for (const g of Object.keys(e.presentation.totals[l].levels))
1187
+ f.has(g) || u("total", g, "Removed subtotal settings for a removed level.");
1188
+ D.totals[l] = {
1189
+ ...e.presentation.totals[l],
1190
+ levels: Object.fromEntries(
1191
+ s[l].map((g) => [
1192
+ g.id,
1193
+ F[g.id] ?? { visible: !0, position: "before" }
1194
+ ])
1195
+ )
1196
+ };
1197
+ const b = e.defaultView[l], I = Math.min(b.depth, Math.max(0, s[l].length - 1));
1198
+ I !== b.depth && u(
1199
+ "depth",
1200
+ l,
1201
+ `Reduced ${l} expansion depth to fit the hierarchy.`
1202
+ ), y[l] = {
1203
+ depth: I,
1204
+ overrides: b.overrides.filter((g) => g.path.length < s[l].length && c(l, g.path) ? !0 : (u(
1205
+ "expansion",
1206
+ l,
1207
+ `Removed a ${l} expansion override whose path changed or became a leaf.`
1208
+ ), !1))
1209
+ };
1210
+ }
1211
+ return {
1212
+ config: (r ? L : z).parse({
1213
+ ...e,
1214
+ spec: s,
1215
+ presentation: D,
1216
+ defaultView: y
1217
+ }),
1218
+ notices: o,
1219
+ removedBindings: m,
1220
+ bindings: _
1221
+ };
1222
+ }
1223
+ function Ue(e) {
1224
+ return !e.entityName || e.entityName === q || e.entityName === "calculated_fields" || e.qualifiedEntityName === q || e.qualifiedEntityName === "calculated_fields" ? "root" : e.qualifiedEntityName || e.entityName;
1225
+ }
1226
+ function gt(e) {
1227
+ return ["domain", e.role || "field", Ue(e), e.name].join("::");
1228
+ }
1229
+ export {
1230
+ ct as A,
1231
+ lt as B,
1232
+ Ae as C,
1233
+ Re as D,
1234
+ me as E,
1235
+ ge as F,
1236
+ it as G,
1237
+ Ze as H,
1238
+ nt as I,
1239
+ ee as J,
1240
+ rt as a,
1241
+ ot as b,
1242
+ O as c,
1243
+ Fe as d,
1244
+ st as e,
1245
+ at as f,
1246
+ Q as g,
1247
+ Te as h,
1248
+ ut as i,
1249
+ ft as j,
1250
+ We as k,
1251
+ pt as l,
1252
+ ve as m,
1253
+ qe as n,
1254
+ et as o,
1255
+ tt as p,
1256
+ mt as q,
1257
+ Ge as r,
1258
+ Z as s,
1259
+ Ue as t,
1260
+ ht as u,
1261
+ gt as v,
1262
+ Se as w,
1263
+ xe as x,
1264
+ Ne as y,
1265
+ dt as z
1266
+ };