react-semaphor 0.1.537 → 0.1.538

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 (173) hide show
  1. package/dist/analytics-protocol/index.js +352 -341
  2. package/dist/assistant-context/index.js +10 -0
  3. package/dist/assistant-protocol/index.js +104 -0
  4. package/dist/brand-studio/index.js +35 -31
  5. package/dist/briefings/index.js +46 -45
  6. package/dist/chunks/_commonjsHelpers-BkfeUUK-.js +28 -0
  7. package/dist/chunks/add-to-dashboard-CxtTfISD.js +56 -0
  8. package/dist/chunks/aggregate-table-row-presentation-Qgpv6_G8.js +979 -0
  9. package/dist/chunks/analytics-base-schemas-BFAoRlkU.js +472 -0
  10. package/dist/chunks/apply-dashboard-operations-C-iahGka.js +402 -0
  11. package/dist/chunks/assistant-chat-BAqUIFp5.js +7966 -0
  12. package/dist/chunks/availability-Bp5Gfu1I.js +44 -0
  13. package/dist/chunks/{bookmark-state-B-I9BDD0.js → bookmark-state-k7y5SNGf.js} +9 -9
  14. package/dist/chunks/{braces-8TRlDwDw.js → braces-o9UiRQes.js} +1 -1
  15. package/dist/chunks/calculated-field-identity-DcBS2NPP.js +2161 -0
  16. package/dist/chunks/calendar-day-equality-Bpl15IBo.js +487 -0
  17. package/dist/chunks/class-utils-Df1OVOT1.js +2315 -0
  18. package/dist/chunks/{field-dependencies-CpRUwr9J.js → common-types-CUf03Htv.js} +65 -58
  19. package/dist/chunks/context-HD9usB1P.js +349 -0
  20. package/dist/chunks/conversation-sQiWYUOb.js +16 -0
  21. package/dist/chunks/csv-utils-GUfKyT1J.js +56 -0
  22. package/dist/chunks/custom-visual-inputs-BrUOIwln.js +3288 -0
  23. package/dist/chunks/{dashboard-BPJo-Fnd.js → dashboard-DTDDFQsS.js} +1 -1
  24. package/dist/chunks/{dashboard-briefing-launcher-A2uVpHCp.js → dashboard-briefing-launcher-Bb2QUqOa.js} +764 -740
  25. package/dist/chunks/{dashboard-controls-DxTuVis_.js → dashboard-controls-FpONU8QV.js} +683 -686
  26. package/dist/chunks/{common-types-g7yS12Cg.js → dashboard-filter-value-compatibility-D95O4nd7.js} +18 -24
  27. package/dist/chunks/dashboard-json-DazPhBU_.js +69 -0
  28. package/dist/chunks/document-dashboard-inputs-D96rlU7S.js +10678 -0
  29. package/dist/chunks/document-sheet-utils-C1eEldxs.js +1076 -0
  30. package/dist/chunks/{edit-dashboard-visual-ByV0OwSp.js → edit-dashboard-visual-CIhZodVH.js} +4744 -4746
  31. package/dist/chunks/editor-draft-sync-BN5qYHPF.js +15 -0
  32. package/dist/chunks/filter-value-text-BhWugPWE.js +163 -0
  33. package/dist/chunks/index-CqMiAkay.js +3164 -0
  34. package/dist/chunks/index-CuHybtft.js +51 -0
  35. package/dist/chunks/layout-grid-Bgzth8vd.js +16 -0
  36. package/dist/chunks/{matrix-analytical-definition-CgBTD6H8.js → matrix-analytical-definition-bcprSe4u.js} +1 -1
  37. package/dist/chunks/{matrix-card-CAdizkUl.js → matrix-card-CJn1hB5V.js} +13 -12
  38. package/dist/chunks/matrix-definition-DQDI2okF.js +206 -0
  39. package/dist/chunks/{matrix-formatter-DJCk8Znf.js → matrix-formatter-Bgw32tb3.js} +648 -457
  40. package/dist/chunks/matrix-member-presentation-BNPSDKBG.js +105 -0
  41. package/dist/chunks/{matrix-operation-contract-BKupLHXL.js → matrix-operation-contract-B8PBF1Gd.js} +134 -133
  42. package/dist/chunks/{metric-comparison-BKHyvnAy.js → metric-comparison-CojWeLqx.js} +1 -1
  43. package/dist/chunks/{palette-Cp1hqZtm.js → palette-D10o_yYX.js} +1 -1
  44. package/dist/chunks/pivot-header-presentation-MkcKnjn3.js +42 -0
  45. package/dist/chunks/{pivot-result-identity-Bs4tLtLo.js → pivot-result-identity-D6hhcRXi.js} +1 -1
  46. package/dist/chunks/pivot-result-lifecycle-8qCDmpKc.js +804 -0
  47. package/dist/chunks/raw-temporal-D61lr48Y.js +1464 -0
  48. package/dist/chunks/{raw-temporal-contract-mLFS-9wk.js → raw-temporal-contract-C51YG48G.js} +1 -1
  49. package/dist/chunks/report-preferences-dialog-BCGs4-AE.js +1808 -0
  50. package/dist/chunks/{report-runtime-context-CG_I0PPW.js → report-runtime-context-B984Nq1E.js} +8 -7
  51. package/dist/chunks/save-CfJpQQ68.js +21 -0
  52. package/dist/chunks/saved-dashboard-context-BrTkjcod.js +566 -0
  53. package/dist/chunks/{selection-reducer-CiDEtmAq.js → selection-reducer-vKIb_jS6.js} +2 -2
  54. package/dist/chunks/{semaphor-ready-indicator-CHu1L-lo.js → semaphor-ready-indicator-CHHoWhil.js} +65586 -62749
  55. package/dist/chunks/{shelf-drop-preview-context-i-H6DFyU.js → shelf-drop-preview-context-EsayECEC.js} +199 -196
  56. package/dist/chunks/{source-entity-resolution-C-oNyYMp.js → source-entity-resolution-CVA1a85c.js} +8 -8
  57. package/dist/chunks/switch-CvItuC1Q.js +8199 -0
  58. package/dist/chunks/{temporal-bucket-DlFuhCnT.js → temporal-bucket-D8JF7zKz.js} +86 -71
  59. package/dist/chunks/{temporal-bucket-contract-D2OuaVZ7.js → temporal-bucket-contract-DaOajRC7.js} +1 -1
  60. package/dist/chunks/{token-types-DtSJOUjh.js → token-types-bxUxXDX2.js} +1 -1
  61. package/dist/chunks/{upload-CAIpsti1.js → upload-BFX7apKV.js} +1 -1
  62. package/dist/chunks/{use-create-flow-overlay-state-Bj63WwHc.js → use-create-flow-overlay-state-BqA92GkX.js} +331 -339
  63. package/dist/chunks/{validators-DMSH81OM.js → validators-Ej1DdCXa.js} +1050 -1510
  64. package/dist/chunks/visual-choice-JiJ-_3bi.js +204 -0
  65. package/dist/chunks/x-4f5U2XwU.js +100 -0
  66. package/dist/chunks/{zoned-wall-clock-1qlWCE20.js → zoned-wall-clock-MulfA26h.js} +2 -2
  67. package/dist/dashboard/index.js +2 -2
  68. package/dist/dashboard-authoring/index.js +823 -661
  69. package/dist/data-app-sdk/index.js +32 -30
  70. package/dist/data-app-sdk-adapters/index.js +23 -22
  71. package/dist/data-app-sdk-validation/index.js +23 -22
  72. package/dist/format-utils/index.js +173 -168
  73. package/dist/index.js +267 -258
  74. package/dist/layouts/index.js +236 -24
  75. package/dist/report-runtime-context/index.js +2 -2
  76. package/dist/style.css +1 -1
  77. package/dist/surfboard/index.js +2 -2
  78. package/dist/types/assistant-context.d.ts +2 -0
  79. package/dist/types/assistant-protocol.d.ts +2 -0
  80. package/dist/types/components/assistant/assistant-entry-points.d.ts +18 -0
  81. package/dist/types/components/assistant/assistant-provider.d.ts +19 -0
  82. package/dist/types/components/assistant/assistant-store.d.ts +52 -0
  83. package/dist/types/components/assistant/use-assistant.d.ts +38 -0
  84. package/dist/types/components/index.d.ts +5 -1
  85. package/dist/types/components/surfboard/filter/types.d.ts +5 -2
  86. package/dist/types/index.js +50 -51
  87. package/dist/types/lib/api/invalidate-token.d.ts +7 -0
  88. package/dist/types/lib/charts/cartesian-fields.d.ts +64 -0
  89. package/dist/types/lib/charts/types.d.ts +7 -0
  90. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-storage-transition.d.ts +14 -2
  91. package/dist/types/lib/dashboard-inputs/dashboard-input-target-context.d.ts +5 -6
  92. package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +8 -3
  93. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +11 -6
  94. package/dist/types/lib/dashboard-pagination/dashboard-card-pagination.d.ts +7 -0
  95. package/dist/types/lib/dashboard-viewer/compatibility-input-storage.d.ts +79 -0
  96. package/dist/types/lib/dashboard-viewer/viewer-state.d.ts +3 -2
  97. package/dist/types/lib/document/document-table-data-policy.d.ts +15 -0
  98. package/dist/types/lib/filter-values/filter-mode.d.ts +22 -0
  99. package/dist/types/lib/hooks/use-calendar-context.d.ts +5 -0
  100. package/dist/types/lib/hooks/use-text-filter.d.ts +7 -0
  101. package/dist/types/lib/print/print-inputs.d.ts +4 -2
  102. package/dist/types/lib/query-context/build-card-query-context.d.ts +12 -4
  103. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +93 -0
  104. package/dist/types/lib/query-context/card-server-request.d.ts +72 -0
  105. package/dist/types/lib/query-context/compile-dashboard-card-filters.d.ts +7 -0
  106. package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +56 -0
  107. package/dist/types/lib/query-context/document-section-card-query.d.ts +45 -0
  108. package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +17 -2
  109. package/dist/types/lib/stores/dashboard-store.d.ts +34 -11
  110. package/dist/types/lib/stores/editor-store.d.ts +4 -2
  111. package/dist/types/lib/types/token-types.d.ts +11 -0
  112. package/dist/types/lib/utils/card-type-change.d.ts +30 -0
  113. package/dist/types/lib/utils/comparison-window-caption.d.ts +12 -0
  114. package/dist/types/lib/utils/filter-default-value-utils.d.ts +13 -2
  115. package/dist/types/shared/analytics-protocol/applied-constraints.d.ts +74 -0
  116. package/dist/types/shared/analytics-protocol/contracts.d.ts +3 -0
  117. package/dist/types/shared/analytics-protocol/filter-field-ownership.d.ts +43 -0
  118. package/dist/types/shared/analytics-protocol/index.d.ts +3 -0
  119. package/dist/types/shared/analytics-protocol/matrix-window-contract.d.ts +1 -1
  120. package/dist/types/shared/analytics-protocol/visual-choice.d.ts +75 -0
  121. package/dist/types/shared/assistant-context/index.d.ts +9 -0
  122. package/dist/types/shared/assistant-context/project-context.d.ts +55 -0
  123. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +130 -0
  124. package/dist/types/shared/assistant-protocol/add-to-dashboard.d.ts +17 -0
  125. package/dist/types/shared/assistant-protocol/artifact.d.ts +63 -0
  126. package/dist/types/shared/assistant-protocol/availability.d.ts +39 -0
  127. package/dist/types/shared/assistant-protocol/context.d.ts +952 -0
  128. package/dist/types/shared/assistant-protocol/conversation.d.ts +38 -0
  129. package/dist/types/shared/assistant-protocol/index.d.ts +16 -0
  130. package/dist/types/shared/assistant-protocol/limits.d.ts +53 -0
  131. package/dist/types/shared/assistant-protocol/parts.d.ts +131 -0
  132. package/dist/types/shared/assistant-protocol/request.d.ts +77 -0
  133. package/dist/types/shared/assistant-protocol/sources.d.ts +27 -0
  134. package/dist/types/shared/assistant-protocol/token-config.d.ts +32 -0
  135. package/dist/types/shared/assistant-protocol/transcript.d.ts +40 -0
  136. package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +112 -0
  137. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +1794 -0
  138. package/dist/types/shared/dashboard-authoring/index.d.ts +5 -0
  139. package/dist/types/shared/dashboard-authoring/new-card.d.ts +10 -0
  140. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +40 -0
  141. package/dist/types/shared/dashboard-authoring/resolved-primary-date-field-validation.d.ts +16 -0
  142. package/dist/types/shared/format-utils/filter-detail.d.ts +70 -0
  143. package/dist/types/shared/format-utils/filter-value-text.d.ts +15 -0
  144. package/dist/types/shared/format-utils/index.d.ts +3 -0
  145. package/dist/types/shared/format-utils/raw-temporal.d.ts +7 -0
  146. package/dist/types/shared/format-utils/temporal-bucket.d.ts +7 -0
  147. package/dist/types/shared/layouts/frame-layouts.d.ts +23 -0
  148. package/dist/types/shared/layouts/index.d.ts +1 -0
  149. package/package.json +12 -2
  150. package/dist/chunks/calculated-field-identity-BptYhyOP.js +0 -1326
  151. package/dist/chunks/calendar-day-equality-BRjN1S9h.js +0 -383
  152. package/dist/chunks/card-config-utils-BOM1dxCk.js +0 -1150
  153. package/dist/chunks/constants-DNWVy8Y3.js +0 -9
  154. package/dist/chunks/dashboard-json-B1dEQu98.js +0 -65
  155. package/dist/chunks/field-aggregations-CoLzYHeL.js +0 -1229
  156. package/dist/chunks/index-DTcTAGGM.js +0 -4101
  157. package/dist/chunks/matrix-continuation-C4sRcjZU.js +0 -72
  158. package/dist/chunks/matrix-control-sources-DTqcA2_L.js +0 -636
  159. package/dist/chunks/matrix-definition-D9iShKZI.js +0 -87
  160. package/dist/chunks/matrix-member-presentation-Ct8GuxHt.js +0 -209
  161. package/dist/chunks/numeric-presentation-CWu3gunq.js +0 -537
  162. package/dist/chunks/pivot-header-presentation-CHs2GFrM.js +0 -753
  163. package/dist/chunks/pivot-result-lifecycle-DQz_gjGu.js +0 -789
  164. package/dist/chunks/raw-temporal-iMXRK-Qz.js +0 -930
  165. package/dist/chunks/report-preferences-dialog-DXPjteCU.js +0 -1623
  166. package/dist/chunks/save-kO6cIaob.js +0 -34
  167. package/dist/chunks/semantic-format-DiqYeKwU.js +0 -192
  168. package/dist/chunks/switch-DO8a0EfJ.js +0 -25004
  169. package/dist/chunks/temporal-input-presentation-BD7YNUzu.js +0 -195
  170. package/dist/chunks/x-CXDkqdur.js +0 -149
  171. package/dist/types/lib/class-utils.d.ts +0 -2
  172. package/dist/types/lib/document/document-input-runtime.d.ts +0 -26
  173. package/dist/types/lib/utils.d.ts +0 -51
@@ -1,1326 +0,0 @@
1
- var de = Object.defineProperty;
2
- var ce = (e, t, n) => t in e ? de(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var z = (e, t, n) => ce(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { F as D, B as q, G as N, aq as le, N as C, az as ue, y as fe, aa as pe, r as H, t as W, bo as me, C as G } from "./validators-DMSH81OM.js";
5
- import "./matrix-operation-contract-BKupLHXL.js";
6
- import "zod";
7
- import { m as he, h as ge, j as Ie } from "./field-aggregations-CoLzYHeL.js";
8
- import { g as J } from "./matrix-analytical-definition-CgBTD6H8.js";
9
- import { s as w } from "./stable-serialize-CfqXeiBP.js";
10
- const ye = (e, t) => {
11
- const n = {};
12
- if (e === null || t === null)
13
- return t;
14
- const r = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
15
- for (const i of r) {
16
- if (!(i in e) && i in t) {
17
- n[i] = t[i];
18
- continue;
19
- }
20
- if (i in e && !(i in t)) {
21
- n[i] = void 0;
22
- continue;
23
- }
24
- const o = e[i], s = t[i];
25
- if (!O(o, s))
26
- if (Array.isArray(o) && Array.isArray(s))
27
- n[i] = s;
28
- else if (K(o) && K(s)) {
29
- const a = ye(o, s);
30
- Object.keys(a).length > 0 && (n[i] = a);
31
- } else
32
- n[i] = s;
33
- }
34
- return n;
35
- }, O = (e, t) => {
36
- if (e === t) return !0;
37
- if (e && t && typeof e == "object" && typeof t == "object") {
38
- if (Array.isArray(e) && Array.isArray(t))
39
- return e.length !== t.length ? !1 : e.every((i, o) => O(i, t[o]));
40
- const n = Object.keys(e), r = Object.keys(t);
41
- return n.length !== r.length ? !1 : n.every((i) => O(e[i], t[i]));
42
- }
43
- return !1;
44
- }, K = (e) => e !== null && typeof e == "object" && !Array.isArray(e), E = (e) => {
45
- if (e === null || typeof e != "object")
46
- return e;
47
- if (e instanceof Date)
48
- return new Date(e);
49
- if (e instanceof RegExp)
50
- return new RegExp(e);
51
- if (Array.isArray(e))
52
- return e.map((n) => E(n));
53
- const t = {};
54
- for (const n in e)
55
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = E(e[n]));
56
- return t;
57
- }, P = { kind: "allSheets" }, $ = (e, t) => (t == null ? void 0 : t[e]) ?? e;
58
- function re(e, t) {
59
- switch (e.kind) {
60
- case "cards":
61
- return {
62
- kind: "cards",
63
- cardIds: e.cardIds.map((n) => $(n, t.cardIds))
64
- };
65
- case "sheets":
66
- return {
67
- kind: "sheets",
68
- sheetIds: e.sheetIds.map((n) => $(n, t.sheetIds))
69
- };
70
- case "documentSections":
71
- return {
72
- ...e,
73
- sheetId: $(e.sheetId, t.sheetIds),
74
- sectionIds: e.sectionIds.map((n) => $(n, t.sectionIds))
75
- };
76
- default:
77
- return e;
78
- }
79
- }
80
- function be(e, t) {
81
- return {
82
- ...e,
83
- targets: re(e.targets, t),
84
- cardMappings: e.cardMappings.map((n) => ({
85
- ...n,
86
- cardId: $(n.cardId, t.cardIds)
87
- }))
88
- };
89
- }
90
- function it(e, t) {
91
- return {
92
- ...e.targets !== void 0 ? { targets: e.targets && re(e.targets, t) } : {},
93
- ...e.cardMappings !== void 0 ? {
94
- cardMappings: e.cardMappings && e.cardMappings.map((n) => ({
95
- ...n,
96
- cardId: $(n.cardId, t.cardIds)
97
- }))
98
- } : {}
99
- };
100
- }
101
- function ot(e, t) {
102
- return t ? {
103
- ...e,
104
- targets: t.targets === void 0 ? e.targets : t.targets ?? P,
105
- cardMappings: t.cardMappings === void 0 ? e.cardMappings : t.cardMappings ?? []
106
- } : e;
107
- }
108
- const R = (e, t) => JSON.stringify(e) === JSON.stringify(t);
109
- function at(e, t) {
110
- const n = {};
111
- return R(e.targets, t.targets) || (n.targets = R(e.targets, P) ? null : e.targets), R(e.cardMappings, t.cardMappings) || (n.cardMappings = e.cardMappings.length ? e.cardMappings : null), Object.keys(n).length ? n : void 0;
112
- }
113
- function st(e, t) {
114
- return {
115
- ...e,
116
- targets: (t == null ? void 0 : t.targets) ?? P,
117
- cardMappings: (t == null ? void 0 : t.cardMappings) ?? []
118
- };
119
- }
120
- function dt(e) {
121
- const t = Object.values(e.linkedInteractionTargetOverrides ?? {});
122
- if (!t.length) return;
123
- const n = {};
124
- if (t.some(
125
- (o) => o.applyToCardIds !== void 0
126
- )) {
127
- const o = t.flatMap(
128
- (s) => Array.isArray(s.applyToCardIds) ? [s.applyToCardIds] : []
129
- );
130
- n.targets = o.length === t.length ? { kind: "cards", cardIds: [...new Set(o.flat())] } : null;
131
- }
132
- const i = t.filter((o) => !Array.isArray(o.applyToCardIds));
133
- if (i.some((o) => o.excludeCardIds !== void 0)) {
134
- const o = [
135
- ...new Set(i.flatMap((s) => s.excludeCardIds ?? []))
136
- ].filter(
137
- (s) => i.every((a) => {
138
- var c;
139
- return (c = a.excludeCardIds) == null ? void 0 : c.includes(s);
140
- })
141
- );
142
- n.cardMappings = o.length ? o.map(
143
- (s) => ({ kind: "excluded", cardId: s })
144
- ) : null;
145
- }
146
- return Object.keys(n).length ? n : void 0;
147
- }
148
- const U = /\[\[\s*param\.([A-Za-z0-9_.-]+)\s*\]\]/g, Y = /\bparam\s*\(\s*(['"])([^'"]+)\1/g;
149
- function ve(e) {
150
- const t = [];
151
- let n = 0;
152
- for (; n < e.length; ) {
153
- const r = e.indexOf("{{", n), i = e.indexOf("{%", n);
154
- let o = -1, s = "";
155
- if (r === -1 ? (o = i, s = "%}") : i === -1 || r < i ? (o = r, s = "}}") : (o = i, s = "%}"), o === -1)
156
- break;
157
- const a = e.indexOf(s, o + 2);
158
- if (a === -1) {
159
- n = o + 2;
160
- continue;
161
- }
162
- t.push(e.slice(o + 2, a)), n = a + 2;
163
- }
164
- return t;
165
- }
166
- function ie(e) {
167
- var r, i;
168
- if (!e)
169
- return [];
170
- const t = /* @__PURE__ */ new Set();
171
- let n;
172
- for (U.lastIndex = 0; (n = U.exec(e)) !== null; ) {
173
- const o = (r = n[1]) == null ? void 0 : r.trim();
174
- o && t.add(o);
175
- }
176
- for (const o of ve(e))
177
- for (Y.lastIndex = 0; (n = Y.exec(o)) !== null; ) {
178
- const s = (i = n[2]) == null ? void 0 : i.trim();
179
- s && t.add(s);
180
- }
181
- return Array.from(t);
182
- }
183
- function ct(e) {
184
- const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
185
- for (const r of e.controlBindings || [])
186
- t.add(r.controlId), r.target === "sql_param" && n.set(r.paramId, r.controlId);
187
- for (const r of ie(e.sql))
188
- t.add(n.get(r) ?? r);
189
- return Array.from(t);
190
- }
191
- function ke(e) {
192
- const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
193
- for (const r of e.controlBindings || [])
194
- r.target === "sql_param" && n.set(r.paramId, r.controlId);
195
- for (const r of ie(e.sql))
196
- t.set(r, {
197
- paramId: r,
198
- controlId: n.get(r) ?? r
199
- });
200
- return Array.from(t.values());
201
- }
202
- function _e(e, t) {
203
- var i;
204
- const n = (i = e.controlBindings) == null ? void 0 : i.map((o) => ({
205
- ...o,
206
- controlId: t.get(o.controlId) ?? o.controlId
207
- })), r = ke(e).flatMap(
208
- ({ paramId: o, controlId: s }) => {
209
- var c;
210
- const a = t.get(s);
211
- return !a || a === s || (c = e.controlBindings) != null && c.some(
212
- (d) => d.target === "sql_param" && d.paramId === o
213
- ) ? [] : [{ target: "sql_param", paramId: o, controlId: a }];
214
- }
215
- );
216
- return r.length ? [...n ?? [], ...r] : n;
217
- }
218
- function oe(e, t) {
219
- var i, o;
220
- 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;
221
- return r.source === "dashboardInput" ? {
222
- ...r,
223
- inputId: ((o = t.inputIds) == null ? void 0 : o[r.inputId]) ?? r.inputId
224
- } : r;
225
- }
226
- function lt(e, t) {
227
- var i;
228
- const n = {};
229
- for (const o of [
230
- "cardIds",
231
- "sheetIds",
232
- "inputIds",
233
- "controlIds",
234
- "filterIds"
235
- ]) {
236
- const s = { ...t[o] };
237
- for (const [a, c] of Object.entries((e == null ? void 0 : e[o]) ?? {}))
238
- s[a] = ((i = t[o]) == null ? void 0 : i[c]) ?? c;
239
- Object.keys(s).length && (n[o] = s);
240
- }
241
- const r = { ...t.inputAliases };
242
- for (const [o, s] of Object.entries((e == null ? void 0 : e.inputAliases) ?? {}))
243
- r[o] = oe(s, t);
244
- return Object.keys(r).length && (n.inputAliases = r), n;
245
- }
246
- function ut(e, t) {
247
- var i, o, s, a;
248
- const n = E(e);
249
- n.controlBindings = _e(
250
- e,
251
- new Map(Object.entries(t.controlIds ?? {}))
252
- );
253
- for (const c of n.controls ?? [])
254
- c.id = ((i = t.controlIds) == null ? void 0 : i[c.id]) ?? c.id;
255
- for (const c of n.inlineFilters ?? [])
256
- c.id = ((o = t.filterIds) == null ? void 0 : o[c.id]) ?? c.id;
257
- const r = (c) => {
258
- var p, f, u;
259
- if (!c || typeof c != "object") return;
260
- if (Array.isArray(c)) {
261
- c.forEach(r);
262
- return;
263
- }
264
- const d = c;
265
- if (d.type === "variable" && d.ref && typeof d.ref == "object") {
266
- const m = d.ref;
267
- d.ref = m.source === "input" ? { ...m, inputId: ((p = t.inputIds) == null ? void 0 : p[m.inputId]) ?? m.inputId } : oe(m, t);
268
- }
269
- if (typeof d.entityId == "string") {
270
- const m = d.entityId;
271
- d.fieldScope === "card" && (d.entityId = ((f = t.cardIds) == null ? void 0 : f[m]) ?? m), d.fieldScope === "sheet" && (d.entityId = ((u = t.sheetIds) == null ? void 0 : u[m]) ?? m);
272
- }
273
- for (const [m, k] of Object.entries(d))
274
- m !== "linkedReferenceOverrides" && r(k);
275
- };
276
- r(n), n.clickToFilter && (n.clickToFilter = be(n.clickToFilter, t));
277
- for (const c of Object.values(
278
- ((s = n.customCardPreferences) == null ? void 0 : s.dataInputCardIds) ?? {}
279
- ))
280
- c.cardId = ((a = t.cardIds) == null ? void 0 : a[c.cardId]) ?? c.cardId;
281
- return n;
282
- }
283
- function S(e) {
284
- return (e == null ? void 0 : e.trim()) || void 0;
285
- }
286
- function V(e) {
287
- return e.split(".").at(-1) || e;
288
- }
289
- function X(e, t) {
290
- var c, d;
291
- const n = S(t);
292
- if (!n) return;
293
- const r = V(n), i = S((c = e.fieldMeta) == null ? void 0 : c.name);
294
- if (i && i !== n && i !== r)
295
- return;
296
- const o = S(
297
- (d = e.fieldMeta) == null ? void 0 : d.qualifiedFieldName
298
- );
299
- if (o && V(o) !== r)
300
- return;
301
- const s = n.includes(".") ? n : void 0, a = o != null && o.includes(".") ? o : void 0;
302
- if (!(s && a && s !== a))
303
- return {
304
- leafName: r,
305
- ...s || a ? {
306
- qualifiedFieldName: s || a
307
- } : {}
308
- };
309
- }
310
- function Q(e, t) {
311
- return X(e, t) || X({}, t);
312
- }
313
- function Z({
314
- source: e,
315
- sourceFieldName: t,
316
- target: n,
317
- targetFieldName: r
318
- }) {
319
- const i = Q(
320
- e,
321
- t
322
- ), o = Q(
323
- n,
324
- r
325
- );
326
- return !i || !o || i.leafName !== o.leafName ? !1 : o.qualifiedFieldName ? i.qualifiedFieldName === o.qualifiedFieldName : !0;
327
- }
328
- function A(e, t) {
329
- var i, o;
330
- const n = Fe(e);
331
- if (n) return n;
332
- const r = (o = (i = e == null ? void 0 : e.fieldMeta) == null ? void 0 : i.nativeDataType) == null ? void 0 : o.trim();
333
- if (j(e == null ? void 0 : e.fieldMeta, t) && r && r !== "date" && r !== "datetime")
334
- return r;
335
- }
336
- function Fe(e) {
337
- var n;
338
- const t = (n = e == null ? void 0 : e.nativeDataType) == null ? void 0 : n.trim();
339
- return t && t !== "date" && t !== "datetime" ? t : void 0;
340
- }
341
- function j(e, t) {
342
- var s, a;
343
- const n = t.trim();
344
- if (!n) return !1;
345
- const r = n.split(".").at(-1), i = (s = e == null ? void 0 : e.qualifiedFieldName) == null ? void 0 : s.trim();
346
- if (i && !(i === n || !i.includes(".") && i === r))
347
- return !1;
348
- const o = (a = e == null ? void 0 : e.name) == null ? void 0 : a.trim();
349
- return o && o !== n && o !== r ? !1 : !!(i || o);
350
- }
351
- function Te({
352
- fieldName: e,
353
- definition: t,
354
- value: n
355
- }) {
356
- if ((t == null ? void 0 : t.column) === e) {
357
- const r = A(t, e);
358
- if (r)
359
- return r;
360
- }
361
- return (n == null ? void 0 : n.name) === e ? A(n, e) : void 0;
362
- }
363
- function De({
364
- definition: e,
365
- value: t,
366
- sourceValue: n = t
367
- }) {
368
- const r = e && Z({
369
- source: e,
370
- sourceFieldName: e.column,
371
- target: t,
372
- targetFieldName: t.name
373
- }) ? e : void 0, i = n && Z({
374
- source: n,
375
- sourceFieldName: n.name,
376
- target: t,
377
- targetFieldName: t.name
378
- }) ? n : void 0, o = (r ? A(r, r.column) : void 0) || (i ? A(i, i.name) : void 0);
379
- return ae({
380
- carrier: t,
381
- nativeDataType: o,
382
- projectNestedNativeDataType: j(
383
- t.fieldMeta,
384
- t.name
385
- )
386
- });
387
- }
388
- function ft({
389
- filterDefinitions: e,
390
- filterValues: t
391
- }) {
392
- if (!(e != null && e.length) || !t.length)
393
- return t;
394
- const n = new Map(
395
- e.map((o) => [o.id, o])
396
- );
397
- let r = !1;
398
- const i = t.map((o) => {
399
- if (typeof o.name != "string" || !o.name.trim())
400
- return o;
401
- const s = n.get(o.filterId);
402
- if (!s)
403
- return o;
404
- const a = De({
405
- definition: s,
406
- value: o
407
- });
408
- return r || (r = a !== o), a;
409
- });
410
- return r ? i : t;
411
- }
412
- function pt(e) {
413
- const t = Te({
414
- fieldName: e.column,
415
- definition: e
416
- });
417
- return ae({
418
- carrier: e,
419
- nativeDataType: t,
420
- projectNestedNativeDataType: j(
421
- e.fieldMeta,
422
- e.column
423
- )
424
- });
425
- }
426
- function ae({
427
- carrier: e,
428
- nativeDataType: t,
429
- projectNestedNativeDataType: n
430
- }) {
431
- var d;
432
- const r = (d = e.fieldMeta) == null ? void 0 : d.nativeDataType;
433
- if (t) {
434
- if (e.nativeDataType === t && (!e.fieldMeta || (n ? r === t : !r)))
435
- return e;
436
- const { nativeDataType: p, ...f } = e.fieldMeta || {};
437
- return {
438
- ...e,
439
- nativeDataType: t,
440
- ...e.fieldMeta ? {
441
- fieldMeta: n ? {
442
- ...e.fieldMeta,
443
- nativeDataType: t
444
- } : f
445
- } : {}
446
- };
447
- }
448
- if (e.nativeDataType === void 0 && r === void 0)
449
- return e;
450
- const {
451
- nativeDataType: i,
452
- fieldMeta: o,
453
- ...s
454
- } = e, { nativeDataType: a, ...c } = o || {};
455
- return {
456
- ...s,
457
- ...o ? { fieldMeta: c } : {}
458
- };
459
- }
460
- function ee(e) {
461
- const t = /* @__PURE__ */ new Set();
462
- for (const n of [e.name, e.sourceField]) {
463
- if (!n) continue;
464
- const r = D(n);
465
- if (!r) continue;
466
- t.add(r);
467
- const i = r.split("."), o = i[i.length - 1];
468
- o && t.add(o);
469
- }
470
- return t;
471
- }
472
- function se(e, t) {
473
- const n = q(e), r = q(t);
474
- return n === "unknown" || r === "unknown" ? !1 : (n === "date" || n === "datetime") && (r === "date" || r === "datetime") ? !0 : n === r;
475
- }
476
- function $e(e, t) {
477
- return N(e.field.source, t.field.source) && D(e.field.name) === D(t.field.name) && D(e.field.sourceField || e.field.name) === D(t.field.sourceField || t.field.name);
478
- }
479
- function we(e, t) {
480
- if (e.kind !== "field") return !1;
481
- const n = ee(t), r = ee(e.field);
482
- return se(t.dataType, e.field.dataType) && [...r].some((i) => n.has(i));
483
- }
484
- function mt(e) {
485
- const t = e.candidates.filter(
486
- (n) => we(
487
- n,
488
- e.logicalValueField
489
- )
490
- );
491
- return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
492
- }
493
- function ht(e) {
494
- const t = [];
495
- for (const n of e.acceptedTargets)
496
- !se(
497
- e.logicalValueField.dataType,
498
- n.field.dataType
499
- ) || t.some(
500
- (r) => $e(r, n)
501
- ) || t.push(n);
502
- return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
503
- }
504
- const xe = /\{\{-?\s*filters\s*\|\s*where\s*-?\}\}/i, Ne = /\{\{-?\s*filters\s*\|\s*and\s*-?\}\}/i, Ae = /\bwhere\b/i;
505
- function Me(e) {
506
- return e != null && e.trim() ? xe.test(e) || Ne.test(e) : !1;
507
- }
508
- function gt(e) {
509
- return !(e != null && e.trim()) || Me(e) ? null : Ae.test(e) ? {
510
- helper: "{{ filters | and }}",
511
- description: "For queries with an existing WHERE clause."
512
- } : {
513
- helper: "{{ filters | where }}",
514
- description: "For queries without a WHERE clause."
515
- };
516
- }
517
- function Re(e) {
518
- return (e.field.sourceField || e.field.name).trim() || void 0;
519
- }
520
- function It(e) {
521
- if (e.inventory.kind !== "sql" || e.target.kind !== "field")
522
- return { status: "ineligible" };
523
- const t = he(
524
- e.inventory,
525
- e.target.field.source
526
- ), n = Re(e.target);
527
- if (!t || !n) return { status: "ineligible" };
528
- if (t.executionTable) {
529
- const s = [
530
- t.executionTable.databaseName,
531
- t.executionTable.schemaName,
532
- t.executionTable.tableName,
533
- n
534
- ].filter(Boolean).join(".");
535
- return {
536
- status: "eligible",
537
- source: t.source,
538
- executionIdentifier: s
539
- };
540
- }
541
- if (e.inventory.pinnedCatalogSources.length !== 1)
542
- return { status: "ineligible" };
543
- const r = D(n), i = (e.candidateTargets || []).filter(
544
- (s) => D(
545
- s.field.sourceField || s.field.name
546
- ) === r
547
- ), o = [];
548
- for (const s of i)
549
- o.some(
550
- (a) => N(a, s.field.source)
551
- ) || o.push(s.field.source);
552
- return o.length > 1 ? { status: "ineligible" } : {
553
- status: "eligible",
554
- source: t.source,
555
- executionIdentifier: n
556
- };
557
- }
558
- const Se = Object.freeze({ mode: "all_applicable" });
559
- function Oe(e) {
560
- if (e === void 0)
561
- return { ok: !0, dependencies: { ...Se } };
562
- const t = le(e, "dashboard");
563
- if (!t.ok)
564
- return {
565
- ok: !1,
566
- error: "Invalid dashboard option dependency policy.",
567
- issues: t.errors.map((r) => r.message)
568
- };
569
- const n = e;
570
- switch (n.mode) {
571
- case "independent":
572
- return { ok: !0, dependencies: { mode: "independent" } };
573
- case "explicit":
574
- return {
575
- ok: !0,
576
- dependencies: {
577
- mode: "explicit",
578
- includeInputIds: [...n.includeInputIds || []]
579
- }
580
- };
581
- case "all_applicable":
582
- return {
583
- ok: !0,
584
- dependencies: {
585
- mode: "all_applicable",
586
- ...n.excludeInputIds ? { excludeInputIds: [...n.excludeInputIds] } : {}
587
- }
588
- };
589
- default:
590
- return {
591
- ok: !1,
592
- error: "Invalid dashboard option dependency policy.",
593
- issues: ["Dashboard option dependencies must declare a mode."]
594
- };
595
- }
596
- }
597
- function Ee(e) {
598
- if (e === void 0) return { ok: !0, population: void 0 };
599
- const t = { ok: !1, error: "Invalid option population." };
600
- if (!e || typeof e != "object" || Array.isArray(e)) return t;
601
- const n = e;
602
- if (n.kind === "option_source")
603
- return { ok: !0, population: { kind: "option_source" } };
604
- if (n.kind !== "related_population") return t;
605
- const r = n.baseSource;
606
- if (!r || r.kind !== "semantic" || !C(r))
607
- return t;
608
- const i = n.relationshipHint;
609
- return i !== void 0 && (!i || typeof i != "object" || i.relationshipIds !== void 0 && (!Array.isArray(i.relationshipIds) || i.relationshipIds.some(
610
- (o) => typeof o != "string" || !o.trim()
611
- ))) ? t : {
612
- ok: !0,
613
- population: {
614
- kind: "related_population",
615
- baseSource: r,
616
- ...i ? { relationshipHint: i } : {}
617
- }
618
- };
619
- }
620
- function yt(e) {
621
- const { dependencies: t } = e, n = /* @__PURE__ */ new Set([
622
- e.targetInputId,
623
- ...t.excludeInputIds || []
624
- ]);
625
- return t.mode === "independent" ? [] : t.mode === "explicit" ? (t.includeInputIds || []).filter(
626
- (r) => !n.has(r)
627
- ) : e.peerInputIds.filter((r) => !n.has(r));
628
- }
629
- function bt(e, t, n) {
630
- if (t === n) return e;
631
- let r = !1;
632
- const i = (s) => s != null && s.includes(t) ? (r = !0, Array.from(
633
- new Set(s.map((a) => a === t ? n : a))
634
- )) : s, o = e.map((s) => {
635
- const a = s.optionDependencies;
636
- if (!a) return s;
637
- const c = i(a.includeInputIds), d = i(a.excludeInputIds);
638
- return c === a.includeInputIds && d === a.excludeInputIds ? s : {
639
- ...s,
640
- optionDependencies: {
641
- ...a,
642
- ...c ? { includeInputIds: c } : {},
643
- ...d ? { excludeInputIds: d } : {}
644
- }
645
- };
646
- });
647
- return r ? o : e;
648
- }
649
- function vt(e, t) {
650
- const n = Ce(
651
- e.dependencies,
652
- t
653
- );
654
- return n === e.dependencies ? e : { ...e, dependencies: n };
655
- }
656
- function Ce(e, t) {
657
- if (!(t != null && t.length) || e.mode !== "explicit")
658
- return e;
659
- const n = new Set(e.includeInputIds || []), r = Array.from(new Set(t)).filter(
660
- (i) => n.has(i)
661
- );
662
- return r.length ? { ...e, omitInputIds: r } : e;
663
- }
664
- class Pe extends Error {
665
- constructor(n) {
666
- super(n.map((r) => r.message).join(" "));
667
- z(this, "issues");
668
- this.name = "DashboardFilterMappingContractError", this.issues = n;
669
- }
670
- }
671
- const je = {
672
- string: !0,
673
- number: !0,
674
- boolean: !0,
675
- date: !0,
676
- datetime: !0
677
- };
678
- function v(e) {
679
- return typeof e == "string" && e.trim().length > 0;
680
- }
681
- function h(e) {
682
- return !!e && typeof e == "object" && !Array.isArray(e);
683
- }
684
- function x(e) {
685
- return Array.isArray(e) && e.every((t) => typeof t == "string");
686
- }
687
- function Le(e) {
688
- if (!h(e)) return !1;
689
- switch (e.kind) {
690
- case "allSheets":
691
- return e.sheetKinds === void 0 || x(e.sheetKinds) && e.sheetKinds.every(
692
- (t) => t === "dashboard" || t === "document"
693
- );
694
- case "sheets":
695
- return x(e.sheetIds);
696
- case "cards":
697
- return x(e.cardIds);
698
- case "documentSections":
699
- return v(e.sheetId) && x(e.sectionIds);
700
- default:
701
- return !1;
702
- }
703
- }
704
- function Be(e) {
705
- return e === "shared" || e === "perSheet" || e === "perCard" || e === "perDocumentSection";
706
- }
707
- function ze(e) {
708
- return h(e) ? v(e.id) && v(e.column) && v(e.dataType) : !1;
709
- }
710
- function qe(e, t, n, r) {
711
- var a;
712
- if (!h(t)) {
713
- r.push({
714
- code: "invalid_option_source",
715
- path: n,
716
- message: `${n} must be a semantic or physical option source.`,
717
- inputId: e
718
- });
719
- return;
720
- }
721
- const i = t.source, o = [
722
- ["labelField", t.labelField],
723
- ["valueField", t.valueField],
724
- ["searchField", t.searchField]
725
- ];
726
- if (!h(i) || i.kind !== "semantic" && i.kind !== "physical" || !C(i) || !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))) {
727
- r.push({
728
- code: "invalid_option_source",
729
- path: n,
730
- message: `${n} must contain a valid semantic or physical source and field references.`,
731
- inputId: e
732
- });
733
- return;
734
- }
735
- for (const [c, d] of o)
736
- d !== void 0 && h(d) && (!v(d.name) || d.source !== void 0 && !N(
737
- d.source,
738
- i
739
- )) && r.push({
740
- code: "invalid_option_source",
741
- path: `${n}.${c}`,
742
- message: `${n}.${c} must be a named field belonging to the declared option source.`,
743
- inputId: e
744
- });
745
- for (const [c, d] of ((a = t.disambiguationFields) == null ? void 0 : a.entries()) || [])
746
- (!h(d) || !v(d.name) || d.source !== void 0 && !N(
747
- d.source,
748
- i
749
- )) && r.push({
750
- code: "invalid_option_source",
751
- path: `${n}.disambiguationFields[${c}]`,
752
- message: `${n}.disambiguationFields[${c}] must be a named field belonging to the declared option source.`,
753
- inputId: e
754
- });
755
- const s = t.valueField;
756
- ["string", "number", "boolean", "date", "datetime"].includes(
757
- String(s.dataType)
758
- ) || r.push({
759
- code: "invalid_option_source",
760
- path: `${n}.valueField.dataType`,
761
- message: `${n}.valueField.dataType must be a known option-value datatype.`,
762
- inputId: e
763
- });
764
- }
765
- function He(e, t, n) {
766
- var r;
767
- if (e.optionDependencies !== void 0) {
768
- const i = Oe(e.optionDependencies);
769
- i.ok ? h(e.optionDependencies) && e.optionDependencies.omitInputIds !== void 0 && n.push({
770
- code: "invalid_option_dependencies",
771
- path: `${t}.optionDependencies.omitInputIds`,
772
- message: `${t}.optionDependencies cannot persist a browse override (omitInputIds).`,
773
- inputId: e.id
774
- }) : n.push({
775
- code: "invalid_option_dependencies",
776
- path: `${t}.optionDependencies`,
777
- message: `${t}.optionDependencies ${i.issues.join("; ") || i.error}`,
778
- inputId: e.id
779
- });
780
- }
781
- if (e.optionPopulation !== void 0) {
782
- const i = Ee(e.optionPopulation);
783
- i.ok ? ((r = i.population) == null ? void 0 : r.kind) === "related_population" && !We(e.optionSource) && n.push({
784
- code: "invalid_option_population",
785
- path: `${t}.optionPopulation`,
786
- message: `${t}.optionPopulation related_population requires an authored semantic optionSource.`,
787
- inputId: e.id
788
- }) : n.push({
789
- code: "invalid_option_population",
790
- path: `${t}.optionPopulation`,
791
- message: `${t}.optionPopulation must be option_source or a related_population with a complete semantic baseSource.`,
792
- inputId: e.id
793
- });
794
- }
795
- }
796
- function We(e) {
797
- return h(e) && h(e.source) && e.source.kind === "semantic";
798
- }
799
- function Ge(e, t, n, r, i, o) {
800
- var d;
801
- if (v(t.bindingId) || i.push({
802
- code: "invalid_binding_id",
803
- path: `${n}.bindingId`,
804
- message: `${n}.bindingId must be an opaque non-empty id.`,
805
- inputId: e,
806
- cardId: t.cardId
807
- }), ((d = t.target) == null ? void 0 : d.kind) !== "field") {
808
- i.push({
809
- code: "unsupported_target",
810
- path: `${n}.target`,
811
- message: `${n}.target must be one direct field target.`,
812
- inputId: e,
813
- cardId: t.cardId,
814
- bindingId: t.bindingId
815
- });
816
- return;
817
- }
818
- const s = t.target.field;
819
- if (!v(s == null ? void 0 : s.name) || !s.source || s.source.kind !== "semantic" && s.source.kind !== "physical" || !C(s.source)) {
820
- i.push({
821
- code: "invalid_target_field",
822
- path: `${n}.target.field`,
823
- message: `${n}.target.field must have a name and a source-qualified semantic or physical identity.`,
824
- inputId: e,
825
- cardId: t.cardId,
826
- bindingId: t.bindingId
827
- });
828
- return;
829
- }
830
- if (Object.prototype.hasOwnProperty.call(
831
- je,
832
- s.dataType
833
- ) || i.push({
834
- code: "unknown_target_data_type",
835
- path: `${n}.target.field.dataType`,
836
- message: `${n}.target.field.dataType must be known.`,
837
- inputId: e,
838
- cardId: t.cardId,
839
- bindingId: t.bindingId
840
- }), s.sourceField !== void 0 && !v(s.sourceField) && i.push({
841
- code: "invalid_target_field",
842
- path: `${n}.target.field.sourceField`,
843
- message: `${n}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,
844
- inputId: e,
845
- cardId: t.cardId,
846
- bindingId: t.bindingId
847
- }), !o) return;
848
- const a = r.get(t.cardId);
849
- if (!a) {
850
- i.push({
851
- code: "unknown_card",
852
- path: `${n}.cardId`,
853
- message: `${n}.cardId '${t.cardId}' does not exist.`,
854
- inputId: e,
855
- cardId: t.cardId,
856
- bindingId: t.bindingId
857
- });
858
- return;
859
- }
860
- const c = ge(a);
861
- (c.kind === "unconfigured" || !Ie(c, s.source)) && i.push({
862
- code: "unavailable_card_source",
863
- path: `${n}.target.field.source`,
864
- message: `${n}.target field source is not declared by card '${a.id}'.`,
865
- inputId: e,
866
- cardId: a.id,
867
- bindingId: t.bindingId
868
- });
869
- }
870
- function Je(e, t, n, r, i, o) {
871
- if (t === void 0) return;
872
- if (!h(t) || t.kind !== "cardMappings" || !Array.isArray(t.cards)) {
873
- i.push({
874
- code: "invalid_application",
875
- path: n,
876
- message: `${n} must be a cardMappings application with a cards array.`,
877
- inputId: e
878
- });
879
- return;
880
- }
881
- const s = /* @__PURE__ */ new Set();
882
- t.cards.forEach((a, c) => {
883
- const d = `${n}.cards[${c}]`;
884
- if (!v(a == null ? void 0 : a.cardId)) {
885
- i.push({
886
- code: "unknown_card",
887
- path: `${d}.cardId`,
888
- message: `${d}.cardId is required.`,
889
- inputId: e
890
- });
891
- return;
892
- }
893
- if (s.has(a.cardId)) {
894
- i.push({
895
- code: "duplicate_card_application",
896
- path: `${d}.cardId`,
897
- message: `${n} contains more than one entry for card '${a.cardId}'.`,
898
- inputId: e,
899
- cardId: a.cardId
900
- });
901
- return;
902
- }
903
- if (s.add(a.cardId), o && !r.has(a.cardId)) {
904
- i.push({
905
- code: "unknown_card",
906
- path: `${d}.cardId`,
907
- message: `${d}.cardId '${a.cardId}' does not exist.`,
908
- inputId: e,
909
- cardId: a.cardId
910
- });
911
- return;
912
- }
913
- a.kind === "bound" ? Ge(
914
- e,
915
- a,
916
- d,
917
- r,
918
- i,
919
- o
920
- ) : a.kind !== "excluded" && i.push({
921
- code: "invalid_application",
922
- path: d,
923
- message: `${d}.kind must be 'bound' or 'excluded'.`,
924
- inputId: e,
925
- cardId: a.cardId
926
- });
927
- });
928
- }
929
- function Ke({
930
- inputs: e,
931
- dashboardFilters: t,
932
- cards: n = [],
933
- validateCardTargets: r = !1
934
- }) {
935
- const i = [], o = new Map(
936
- (t || []).map((d) => [d.id, d])
937
- ), s = new Map(
938
- r ? n.map((d) => [d.id, d]) : []
939
- ), a = [], c = /* @__PURE__ */ new Map();
940
- return e != null && !Array.isArray(e) ? (i.push({
941
- code: "invalid_input",
942
- path: "dashboard.inputs",
943
- message: "dashboard.inputs must be an array when present."
944
- }), { ok: !1, inputs: a, issues: i }) : ((Array.isArray(e) ? e : []).forEach((d, p) => {
945
- const f = `dashboard.inputs[${p}]`;
946
- if (!h(d) || d.kind !== "filter" && d.kind !== "control" || !v(d.id) || !v(d.label) || !v(d.variableName) || !Le(d.scope) || !Be(d.runtimeScope)) {
947
- i.push({
948
- code: "invalid_input",
949
- path: f,
950
- message: `${f} must be a complete filter or control Dashboard Input envelope.`,
951
- inputId: h(d) && typeof d.id == "string" ? d.id : void 0
952
- });
953
- return;
954
- }
955
- if (d.kind === "control" && !h(d.control)) {
956
- i.push({
957
- code: "invalid_input",
958
- path: `${f}.control`,
959
- message: `${f}.control must be a control definition.`,
960
- inputId: d.id
961
- });
962
- return;
963
- }
964
- const u = d;
965
- if (u.kind === "control") {
966
- a.push(u);
967
- return;
968
- }
969
- const m = u.filter, k = u.filterReference, F = m !== void 0, T = !!k;
970
- if (F && T) {
971
- i.push({
972
- code: "both_filter_definitions",
973
- path: f,
974
- message: `${f} must contain either filter or filterReference, not both.`,
975
- inputId: u.id
976
- });
977
- return;
978
- }
979
- if (!F && !T) {
980
- i.push({
981
- code: "missing_filter_definition",
982
- path: f,
983
- message: `${f} must contain filter or filterReference.`,
984
- inputId: u.id
985
- });
986
- return;
987
- }
988
- if (F && !ze(m)) {
989
- i.push({
990
- code: "invalid_input",
991
- path: `${f}.filter`,
992
- message: `${f}.filter must be a complete dashboard filter definition.`,
993
- inputId: u.id
994
- });
995
- return;
996
- }
997
- let y, l;
998
- if (F)
999
- y = m, l = "embedded";
1000
- else {
1001
- if ((k == null ? void 0 : k.kind) !== "dashboardFilter") {
1002
- i.push({
1003
- code: "invalid_filter_reference",
1004
- path: `${f}.filterReference.kind`,
1005
- message: `${f}.filterReference.kind must be 'dashboardFilter'.`,
1006
- inputId: u.id
1007
- });
1008
- return;
1009
- }
1010
- const M = typeof (k == null ? void 0 : k.filterId) == "string" ? k.filterId : void 0;
1011
- if (y = M ? o.get(M) : void 0, l = "dashboardFilter", !y) {
1012
- i.push({
1013
- code: "orphaned_filter_reference",
1014
- path: `${f}.filterReference.filterId`,
1015
- message: `${f}.filterReference cannot resolve dashboard filter '${M || ""}'.`,
1016
- inputId: u.id
1017
- });
1018
- return;
1019
- }
1020
- if (y.kind === "global-date") {
1021
- i.push({
1022
- code: "global_date_reference",
1023
- path: `${f}.filterReference`,
1024
- message: `${f}.filterReference cannot reference the Global Date filter.`,
1025
- inputId: u.id
1026
- });
1027
- return;
1028
- }
1029
- const B = c.get(y.id);
1030
- if (B) {
1031
- i.push({
1032
- code: "duplicate_filter_reference",
1033
- path: `${f}.filterReference.filterId`,
1034
- message: `${f}.filterReference duplicates dashboard filter '${y.id}' already owned by Dashboard Input '${B}'.`,
1035
- inputId: u.id
1036
- });
1037
- return;
1038
- }
1039
- c.set(y.id, u.id);
1040
- }
1041
- if (!y) return;
1042
- if (u.forceSelection !== void 0 && typeof u.forceSelection != "boolean" && i.push({
1043
- code: "invalid_input",
1044
- path: `${f}.forceSelection`,
1045
- message: `${f}.forceSelection must be a boolean.`,
1046
- inputId: u.id
1047
- }), u.optionSource !== void 0 && qe(
1048
- u.id,
1049
- u.optionSource,
1050
- `${f}.optionSource`,
1051
- i
1052
- ), He(u, f, i), u.application && y.kind === "global-date") {
1053
- i.push({
1054
- code: "global_date_reference",
1055
- path: `${f}.application`,
1056
- message: `${f}.application cannot map the Global Date filter.`,
1057
- inputId: u.id
1058
- });
1059
- return;
1060
- }
1061
- u.application && u.scope.kind !== "allSheets" && u.scope.kind !== "sheets" && i.push({
1062
- code: "unsupported_mapped_scope",
1063
- path: `${f}.scope`,
1064
- message: `${f}.scope must be allSheets or sheets when cardMappings are present.`,
1065
- inputId: u.id
1066
- }), Je(
1067
- u.id,
1068
- u.application,
1069
- `${f}.application`,
1070
- s,
1071
- i,
1072
- r
1073
- );
1074
- const {
1075
- filter: _,
1076
- filterReference: I,
1077
- // A reference-backed authored input must shadow the generated
1078
- // dashboard-filter compatibility input. Older writers may have copied
1079
- // the compatibility marker onto the reference; never preserve it.
1080
- compatibility: b,
1081
- ...g
1082
- } = u;
1083
- a.push({
1084
- ...g,
1085
- filter: y,
1086
- ...F && b ? { compatibility: b } : {},
1087
- ...u.optionSource ? {
1088
- optionSource: u.optionSource
1089
- } : {},
1090
- ...u.optionDependencies ? { optionDependencies: u.optionDependencies } : {},
1091
- ...u.optionPopulation ? { optionPopulation: u.optionPopulation } : {},
1092
- definitionOrigin: l
1093
- });
1094
- }), i.length ? { ok: !1, inputs: a, issues: i } : { ok: !0, inputs: a });
1095
- }
1096
- function kt(e) {
1097
- const t = Ke(e);
1098
- if (!t.ok) throw new Pe(t.issues);
1099
- return t.inputs;
1100
- }
1101
- function _t(e = () => globalThis.crypto.randomUUID()) {
1102
- return e();
1103
- }
1104
- function te(e, t, n = (r) => {
1105
- var i;
1106
- return ((i = r.derivedField) == null ? void 0 : i.dataType) ?? r.dataType;
1107
- }) {
1108
- 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" || ue(n(i.field))).map((i) => ({ id: i.id, kind: "level", axis: r, level: i })));
1109
- }
1110
- function Ft(e, t, n, r) {
1111
- const i = [...e.rows, ...e.columns].find((d) => d.id === t);
1112
- if (!i) throw new Error("Matrix level is no longer present.");
1113
- if (r === t) return { kind: "structure", rows: e.rows, columns: e.columns };
1114
- const o = e.rows.filter((d) => d.id !== t), s = e.columns.filter((d) => d.id !== t), a = n === "rows" ? o : s, c = r ? a.findIndex((d) => d.id === r) : -1;
1115
- return a.splice(c < 0 ? a.length : c, 0, i), { kind: "structure", rows: o, columns: s };
1116
- }
1117
- function L(e, t) {
1118
- const n = J(e), r = J(t), i = (a, c) => w(n[a][c]) === w(r[a][c]), o = (a) => {
1119
- const c = n.rankings.find((p) => p.id === a), d = r.rankings.find((p) => p.id === a);
1120
- return !!c && !!d && w(c) === w(d);
1121
- };
1122
- return (a, c, d = !1) => c.length <= t[a].length && c.every(
1123
- (p, f) => {
1124
- var u;
1125
- return (p.member.kind === "value" || d && o(p.member.rankingId)) && p.levelId === ((u = t[a][f]) == null ? void 0 : u.id) && i(a, f);
1126
- }
1127
- );
1128
- }
1129
- function ne(e, t, n, r) {
1130
- if (!n) return n;
1131
- const i = L(e, t), o = new Set(t.measures.map((s) => s.id));
1132
- return { ...n, rules: n.rules.filter((s) => {
1133
- const a = s.target.matrix, c = !a || (a.levelId === void 0 || t[a.axis].some((p) => p.id === a.levelId)) && (a.oppositePath === void 0 || i(a.axis === "rows" ? "columns" : "rows", a.oppositePath, !0)), { validationRefs: d } = me(s);
1134
- return c && d.every((p) => o.has(p)) ? !0 : (r.push({ kind: "conditional_format", id: s.id, message: "Removed a conditional rule whose measure, level or member path changed." }), !1);
1135
- }) };
1136
- }
1137
- function Ue(e, t, n = !1) {
1138
- const r = { ...t }, i = [], o = L(e, r), s = new Set(r.measures.map((c) => c.id)), a = (c, d, p) => i.push({ kind: c, id: d, message: p });
1139
- return r.sorts = r.sorts.filter((c) => {
1140
- const d = r[c.axis].findIndex(
1141
- (f) => f.id === c.levelId
1142
- ), p = d >= 0 && (c.scope.kind === "level" || c.scope.parent.length === d && o(c.axis, c.scope.parent)) && (c.target.kind === "member" || s.has(c.target.measureId) && o(
1143
- c.axis === "rows" ? "columns" : "rows",
1144
- c.target.oppositePath
1145
- ));
1146
- return p || a(
1147
- "sort",
1148
- c.levelId,
1149
- "Removed a sort whose level, measure or member path changed."
1150
- ), p;
1151
- }), r.rankings = r.rankings.filter((c) => {
1152
- const d = r[c.axis].some((p) => p.id === c.levelId) && s.has(c.measureId) && o(
1153
- c.axis === "rows" ? "columns" : "rows",
1154
- c.oppositePath
1155
- );
1156
- return d || a(
1157
- "ranking",
1158
- c.id,
1159
- "Removed a ranking whose level, measure or member path changed."
1160
- ), d;
1161
- }), { spec: (n ? fe : pe).parse(r), notices: i };
1162
- }
1163
- function Tt(e, t, n = [], r, i = !1) {
1164
- const o = [];
1165
- if (t.kind !== "structure") {
1166
- 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 } } : {
1167
- ...e,
1168
- spec: { ...e.spec, rankings: t.rankings }
1169
- };
1170
- return t.kind === "rankings" && l.presentation.conditionalFormatting && (l.presentation = { ...l.presentation, conditionalFormatting: ne(e.spec, l.spec, l.presentation.conditionalFormatting, o) }), {
1171
- config: (i ? H : W).parse(l),
1172
- notices: o,
1173
- removedBindings: [],
1174
- bindings: n
1175
- };
1176
- }
1177
- const s = Ue(e.spec, {
1178
- ...e.spec,
1179
- rows: t.rows ?? e.spec.rows,
1180
- columns: t.columns ?? e.spec.columns,
1181
- measures: t.measures ?? e.spec.measures
1182
- }, i), a = s.spec;
1183
- o.push(...s.notices);
1184
- const c = L(e.spec, a), d = new Set(a.measures.map((l) => l.id)), p = [...a.rows, ...a.columns], f = new Set(p.map((l) => l.id)), u = (l, _, I) => o.push({ kind: l, id: _, message: I }), m = [], k = n.flatMap((l) => {
1185
- if (l.target === "sql_param" || l.target === "presentation_currency") return [l];
1186
- const _ = te(e.spec, l.target, r), I = l.matrixTargetId ?? (_.length === 1 ? _[0].id : void 0);
1187
- return te(a, l.target, r).some((g) => g.id === I) ? l.matrixTargetId ? [l] : (u("binding", l.controlId, "Pinned the control binding to its original Matrix target after a structural change."), [{ ...l, matrixTargetId: I }]) : (u(
1188
- "binding",
1189
- l.controlId,
1190
- "Removed a control binding whose original Matrix target is missing, ambiguous or no longer eligible."
1191
- ), m.push(l), []);
1192
- }), F = (l, _, I) => Object.fromEntries(
1193
- Object.entries(l).filter(([b]) => _.has(b) ? !0 : (u(I, b, `Removed a ${I} override for a removed field.`), !1))
1194
- ), T = {
1195
- ...e.presentation,
1196
- levelLabels: F(e.presentation.levelLabels, f, "label"),
1197
- measureLabels: F(
1198
- e.presentation.measureLabels,
1199
- d,
1200
- "label"
1201
- ),
1202
- levelFormats: F(
1203
- e.presentation.levelFormats,
1204
- f,
1205
- "format"
1206
- ),
1207
- measureFormats: F(
1208
- e.presentation.measureFormats,
1209
- d,
1210
- "format"
1211
- ),
1212
- totals: { ...e.presentation.totals }
1213
- };
1214
- T.levelFormats = Object.fromEntries(
1215
- Object.entries(T.levelFormats).filter(([l, _]) => {
1216
- const I = p.find((g) => g.id === l), b = [...e.spec.rows, ...e.spec.columns].find(
1217
- (g) => g.id === l
1218
- );
1219
- return _.type !== "temporal_bucket" || I.grain && I.grain === (b == null ? void 0 : b.grain) ? !0 : (u(
1220
- "format",
1221
- l,
1222
- "Removed a temporal format because its grain changed."
1223
- ), !1);
1224
- })
1225
- ), T.conditionalFormatting && (T.conditionalFormatting = ne(e.spec, a, T.conditionalFormatting, o));
1226
- const y = { ...e.defaultView };
1227
- for (const l of ["rows", "columns"]) {
1228
- const _ = {
1229
- ...e.presentation.totals.rows.levels,
1230
- ...e.presentation.totals.columns.levels
1231
- };
1232
- for (const g of Object.keys(e.presentation.totals[l].levels))
1233
- f.has(g) || u("total", g, "Removed subtotal settings for a removed level.");
1234
- T.totals[l] = {
1235
- ...e.presentation.totals[l],
1236
- levels: Object.fromEntries(
1237
- a[l].map((g) => [
1238
- g.id,
1239
- _[g.id] ?? { visible: !0, position: "before" }
1240
- ])
1241
- )
1242
- };
1243
- const I = e.defaultView[l], b = Math.min(I.depth, Math.max(0, a[l].length - 1));
1244
- b !== I.depth && u(
1245
- "depth",
1246
- l,
1247
- `Reduced ${l} expansion depth to fit the hierarchy.`
1248
- ), y[l] = {
1249
- depth: b,
1250
- overrides: I.overrides.filter((g) => g.path.length < a[l].length && c(l, g.path) ? !0 : (u(
1251
- "expansion",
1252
- l,
1253
- `Removed a ${l} expansion override whose path changed or became a leaf.`
1254
- ), !1))
1255
- };
1256
- }
1257
- return {
1258
- config: (i ? H : W).parse({
1259
- ...e,
1260
- spec: a,
1261
- presentation: T,
1262
- defaultView: y
1263
- }),
1264
- notices: o,
1265
- removedBindings: m,
1266
- bindings: k
1267
- };
1268
- }
1269
- function Ye(e) {
1270
- return !e.entityName || e.entityName === G || e.entityName === "calculated_fields" || e.qualifiedEntityName === G || e.qualifiedEntityName === "calculated_fields" ? "root" : e.qualifiedEntityName || e.entityName;
1271
- }
1272
- function Ve(e) {
1273
- return ["domain", e.role || "field", Ye(e), e.name].join("::");
1274
- }
1275
- function Dt(e) {
1276
- var i, o;
1277
- if (e.fieldScope !== "domain") return;
1278
- const t = e.calculatedFieldOrigin;
1279
- if ((i = t == null ? void 0 : t.id) != null && i.startsWith("domain::")) return t.id;
1280
- const n = (o = e.derivedField) == null ? void 0 : o.resultRole, r = n === "measure" ? "metric" : n === "dimension" || n === "date" ? "groupby" : e.derivedField || t == null ? void 0 : t.role;
1281
- if (!(r !== "metric" && r !== "groupby"))
1282
- return Ve({ ...e, role: r });
1283
- }
1284
- export {
1285
- Se as A,
1286
- Oe as B,
1287
- Ee as C,
1288
- Pe as D,
1289
- yt as E,
1290
- bt as F,
1291
- vt as G,
1292
- Ce as H,
1293
- E as I,
1294
- pt as J,
1295
- ft as K,
1296
- ye as L,
1297
- ke as M,
1298
- ct as N,
1299
- ie as O,
1300
- mt as a,
1301
- ht as b,
1302
- It as c,
1303
- we as d,
1304
- kt as e,
1305
- _t as f,
1306
- gt as g,
1307
- Me as h,
1308
- lt as i,
1309
- ut as j,
1310
- it as k,
1311
- ot as l,
1312
- De as m,
1313
- Ke as n,
1314
- at as o,
1315
- dt as p,
1316
- te as q,
1317
- be as r,
1318
- st as s,
1319
- Ft as t,
1320
- ne as u,
1321
- Ue as v,
1322
- Tt as w,
1323
- Ye as x,
1324
- Ve as y,
1325
- Dt as z
1326
- };