react-semaphor 0.1.470 → 0.1.472

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 (41) hide show
  1. package/README.md +10 -0
  2. package/dist/brand-studio/index.cjs +1 -1
  3. package/dist/brand-studio/index.js +1 -1
  4. package/dist/chunks/dashboard-briefing-launcher-8vxGyexK.cjs +26 -0
  5. package/dist/chunks/{dashboard-briefing-launcher-DEVbQCQE.js → dashboard-briefing-launcher-Lw4gjW_M.js} +5 -5
  6. package/dist/chunks/{dashboard-controls-8D1m_ECN.cjs → dashboard-controls-BKR8g3M9.cjs} +1 -1
  7. package/dist/chunks/{dashboard-controls-DPK-CRWL.js → dashboard-controls-CRgDlxdt.js} +4 -4
  8. package/dist/chunks/dashboard-filter-value-compatibility-Dmh-NaPK.cjs +1 -0
  9. package/dist/chunks/dashboard-filter-value-compatibility-ilbH2A31.js +836 -0
  10. package/dist/chunks/{dashboard-json-DVWLTmIJ.js → dashboard-json-BhhVg9mI.js} +2 -2
  11. package/dist/chunks/{dashboard-json-DhKOoHwK.cjs → dashboard-json-CUgAzrYq.cjs} +1 -1
  12. package/dist/chunks/{edit-dashboard-visual-B6zidwTu.cjs → edit-dashboard-visual-BxmanBVo.cjs} +33 -33
  13. package/dist/chunks/{edit-dashboard-visual-CxEC3bPx.js → edit-dashboard-visual-DlQtYQOO.js} +3609 -3711
  14. package/dist/chunks/{editor-action-buttons-HfJ-Bohl.js → editor-action-buttons-CRWacpxi.js} +2 -2
  15. package/dist/chunks/{editor-action-buttons-B3S00DsB.cjs → editor-action-buttons-DKcD0UQy.cjs} +1 -1
  16. package/dist/chunks/{index-tsB3LfTQ.js → index-0fmECZL2.js} +28713 -28753
  17. package/dist/chunks/{index-DVBYvkj0.cjs → index-xdqe-Zvd.cjs} +224 -224
  18. package/dist/chunks/{pivot-header-presentation-BW0Ay7WV.js → pivot-header-presentation-7XrwJYDm.js} +101 -94
  19. package/dist/chunks/pivot-header-presentation-Cr6pU5JL.cjs +4 -0
  20. package/dist/chunks/{report-preferences-dialog-DvNWNrlj.cjs → report-preferences-dialog-8KYKazoG.cjs} +1 -1
  21. package/dist/chunks/{report-preferences-dialog-D-VpoQJz.js → report-preferences-dialog-Dxt9XMpd.js} +2 -2
  22. package/dist/chunks/{switch-NAbuOQNg.cjs → switch-CQN9Hzho.cjs} +19 -19
  23. package/dist/chunks/{switch-DnbD-yCM.js → switch-n2yUNY8i.js} +383 -370
  24. package/dist/dashboard/index.cjs +1 -1
  25. package/dist/dashboard/index.js +1 -1
  26. package/dist/dashboard-authoring/index.cjs +1 -1
  27. package/dist/dashboard-authoring/index.js +1 -1
  28. package/dist/data-app-builder/index.cjs +1 -1
  29. package/dist/data-app-builder/index.js +2 -2
  30. package/dist/format-utils/index.cjs +3 -3
  31. package/dist/format-utils/index.js +71 -68
  32. package/dist/index.cjs +1 -1
  33. package/dist/index.js +6 -6
  34. package/dist/surfboard/index.cjs +1 -1
  35. package/dist/surfboard/index.js +2 -2
  36. package/dist/types/format-utils.d.ts +9 -0
  37. package/package.json +1 -1
  38. package/dist/chunks/dashboard-briefing-launcher-exfJnSop.cjs +0 -26
  39. package/dist/chunks/dashboard-filter-value-compatibility-BAaqJGjt.js +0 -692
  40. package/dist/chunks/dashboard-filter-value-compatibility-CYrWe1U6.cjs +0 -1
  41. package/dist/chunks/pivot-header-presentation-DVBTHug2.cjs +0 -4
@@ -0,0 +1,836 @@
1
+ var K = Object.defineProperty;
2
+ var Q = (e, n, t) => n in e ? K(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
3
+ var H = (e, n, t) => Q(e, typeof n != "symbol" ? n + "" : n, t);
4
+ import { ai as I, ak as Y, h as z, af as G, ah as S, B as $, E as R } from "./validators-B5t1s8oh.js";
5
+ import "./analyze-result-contract-B3agc2XU.js";
6
+ import "../value-format-preferences/index.js";
7
+ function c(e) {
8
+ return typeof e == "string" && e.trim().length > 0 ? e.trim() : null;
9
+ }
10
+ function J(e) {
11
+ return Array.from(new Set(e.filter((n) => !!n)));
12
+ }
13
+ function X(e) {
14
+ const n = c(e.table), t = c(e.schema), s = c(e.catalog) || c(e.database);
15
+ return n ? J([
16
+ n,
17
+ t ? `${t}.${n}` : null,
18
+ s ? `${s}.${n}` : null,
19
+ s && t ? `${s}.${t}.${n}` : null
20
+ ]) : [];
21
+ }
22
+ function L(e) {
23
+ const n = c(e.table) || c(e.tableName);
24
+ return J([
25
+ c(e.name),
26
+ c(e.alias),
27
+ ...X({
28
+ table: n,
29
+ schema: c(e.schema) || c(e.schemaName),
30
+ catalog: c(e.catalog),
31
+ database: c(e.database) || c(e.databaseName)
32
+ })
33
+ ]);
34
+ }
35
+ function Z(e, n) {
36
+ const t = c(e.domainId), s = c(n.domainId);
37
+ if (t && s && t !== s)
38
+ return !0;
39
+ if (e.type === "dataset")
40
+ return !1;
41
+ const i = c(e.id), d = c(n.id);
42
+ if (i && d && i !== d)
43
+ return !0;
44
+ const a = c(e.connectionId), o = c(n.connectionId);
45
+ return !!(a && o && a !== o);
46
+ }
47
+ function x(e, n = !1) {
48
+ return c(e.table) || c(e.tableName) || (e.type !== "dataset" || n ? c(e.name) : null);
49
+ }
50
+ function w(e) {
51
+ return c(e.catalog) || c(e.database) || c(e.databaseName);
52
+ }
53
+ function B(e) {
54
+ return c(e.schema) || c(e.schemaName);
55
+ }
56
+ function T(e) {
57
+ return e.length === 1 ? e[0] : void 0;
58
+ }
59
+ function ee(e, n) {
60
+ const t = x(n, !0), s = w(n), i = B(n);
61
+ if (!(!t || !s && !i))
62
+ return T(
63
+ e.filter((d) => {
64
+ const a = d;
65
+ return !(x(a) !== t || s && w(a) !== s || i && B(a) !== i);
66
+ })
67
+ );
68
+ }
69
+ function E(e, n) {
70
+ if (!n || !(e != null && e.length))
71
+ return;
72
+ const t = e.filter(
73
+ (o) => !Z(o, n)
74
+ );
75
+ if (n.type === "dataset") {
76
+ const o = c(n.id);
77
+ if (o)
78
+ return T(
79
+ t.filter(
80
+ (r) => r.type === "dataset" && c(r.id) === o
81
+ )
82
+ );
83
+ if (c(n.domainId)) {
84
+ const r = c(n.name);
85
+ return T(
86
+ t.filter(
87
+ (g) => g.type === "dataset" && c(g.name) === r
88
+ )
89
+ );
90
+ }
91
+ }
92
+ let s = [];
93
+ if (n.type === "dataset") {
94
+ const o = c(n.name);
95
+ if (s = t.filter(
96
+ (l) => l.type === "dataset" && c(l.name) === o
97
+ ), s.length === 1)
98
+ return s[0];
99
+ }
100
+ if (!!(x(n, !0) && (w(n) || B(n))))
101
+ return ee(t, n);
102
+ if (s.length > 1)
103
+ return;
104
+ const d = L(n);
105
+ if (d.length === 0)
106
+ return;
107
+ const a = t.filter((o) => L(
108
+ o
109
+ ).some(
110
+ (r) => d.includes(r)
111
+ ));
112
+ return T(a);
113
+ }
114
+ function C(e, n) {
115
+ const t = E(e, n);
116
+ return t ? { ...n, ...t } : n;
117
+ }
118
+ function De(e, n) {
119
+ const t = n || [];
120
+ return t.length === 0 ? e : {
121
+ ...e,
122
+ baseEntity: C(t, e.baseEntity),
123
+ joins: e.joins.map((s) => ({
124
+ ...s,
125
+ source: C(t, s.source),
126
+ target: C(t, s.target)
127
+ }))
128
+ };
129
+ }
130
+ function Ae(e, n) {
131
+ if (!(e != null && e.joins.length))
132
+ return [];
133
+ const t = [
134
+ e.baseEntity,
135
+ ...e.joins.flatMap((i) => [i.source, i.target])
136
+ ], s = [];
137
+ return t.forEach((i) => {
138
+ !E(n, i) && !E(s, i) && s.push(i);
139
+ }), s;
140
+ }
141
+ function y(e) {
142
+ return !!e && typeof e == "object" && !Array.isArray(e);
143
+ }
144
+ function k(e) {
145
+ return y(e) && typeof e.name == "string";
146
+ }
147
+ function v(e) {
148
+ return !y(e) || e.kind !== "semantic" && e.kind !== "physical" || (e.kind === "semantic" ? [e.datasetId, e.datasetName, e.connectionId] : [e.databaseName, e.schemaName]).some(
149
+ (t) => t !== void 0 && typeof t != "string"
150
+ ) ? !1 : z(
151
+ e
152
+ );
153
+ }
154
+ function M(e, n) {
155
+ var r, g;
156
+ const t = Array.isArray(n == null ? void 0 : n.selectedEntities) ? n.selectedEntities.filter(k) : void 0, s = E(t, e), i = s ? { ...e, ...s } : e, d = i.type === "dataset" && "domainId" in i && typeof i.domainId == "string" && !!i.domainId.trim();
157
+ if ((n == null ? void 0 : n.mode) === "semanticDomain" && !d)
158
+ return;
159
+ if ((n == null ? void 0 : n.mode) !== "database" && i.type === "dataset" && "domainId" in i && i.domainId) {
160
+ const f = i, u = {
161
+ kind: "semantic",
162
+ domainId: f.domainId,
163
+ datasetId: G(f),
164
+ datasetName: f.name,
165
+ connectionId: f.connectionId || (n == null ? void 0 : n.connectionId),
166
+ label: f.label
167
+ };
168
+ return v(u) ? S(u) : void 0;
169
+ }
170
+ const a = i.connectionId || (n == null ? void 0 : n.connectionId), o = i.type === "dataset" && "table" in i && i.table ? i.table : i.name;
171
+ if (!a || !o)
172
+ return;
173
+ const l = {
174
+ kind: "physical",
175
+ connectionId: a,
176
+ connectionType: i.connectionType || (n == null ? void 0 : n.connectionType),
177
+ tableName: o,
178
+ databaseName: i.database || ((r = n == null ? void 0 : n.dbSelection) == null ? void 0 : r.database),
179
+ schemaName: i.schema || ((g = n == null ? void 0 : n.dbSelection) == null ? void 0 : g.schema),
180
+ dialect: i.dialect
181
+ };
182
+ return v(l) ? l : void 0;
183
+ }
184
+ function ne(e, n) {
185
+ var o, l;
186
+ const t = M(e, n);
187
+ if (!t) return;
188
+ const s = e.type === "dataset" && "table" in e && typeof e.table == "string" ? e.table.trim() : void 0, i = t.kind === "physical" ? t.tableName : s, d = e.connectionId || (n == null ? void 0 : n.connectionId), a = i && d ? {
189
+ connectionId: d,
190
+ databaseName: e.database || ((o = n == null ? void 0 : n.dbSelection) == null ? void 0 : o.database),
191
+ schemaName: e.schema || ((l = n == null ? void 0 : n.dbSelection) == null ? void 0 : l.schema),
192
+ tableName: i
193
+ } : void 0;
194
+ return { source: t, ...a ? { executionTable: a } : {} };
195
+ }
196
+ function te(e) {
197
+ const n = y(e.dataSource) ? e.dataSource : void 0;
198
+ if (typeof e.sql == "string" && e.sql.trim()) {
199
+ const a = [], o = Array.isArray(n == null ? void 0 : n.selectedEntities) ? n.selectedEntities : [];
200
+ for (const l of o) {
201
+ if (!k(l)) continue;
202
+ const r = ne(l, n);
203
+ r && !a.some(
204
+ (g) => I(
205
+ g.source,
206
+ r.source
207
+ )
208
+ ) && a.push(r);
209
+ }
210
+ return {
211
+ cardId: e.id,
212
+ kind: "sql",
213
+ pinnedCatalogSources: a
214
+ };
215
+ }
216
+ if (!y(e.config))
217
+ return { cardId: e.id, kind: "unconfigured" };
218
+ const t = [], s = y(e.config.matrixIntent) ? e.config.matrixIntent : void 0, i = e.type === "matrixTable" ? (s == null ? void 0 : s.kind) === "matrix" ? s.source : e.config.source : void 0;
219
+ v(i) && t.push(i);
220
+ const d = y(e.config.joinPlan) ? e.config.joinPlan : void 0;
221
+ if (d) {
222
+ const a = Array.isArray(d.joins) ? d.joins : [], o = [d.baseEntity];
223
+ for (const r of a)
224
+ y(r) && o.push(r.source, r.target);
225
+ let l = !1;
226
+ for (const r of o) {
227
+ if (!k(r)) {
228
+ l = !0;
229
+ continue;
230
+ }
231
+ const g = M(r, n);
232
+ g ? t.push(g) : l = !0;
233
+ }
234
+ l && (t.length = 0);
235
+ } else if (e.type !== "matrixTable") {
236
+ const a = Array.isArray(n == null ? void 0 : n.selectedEntities) ? n.selectedEntities : [];
237
+ if (a.length === 1 && k(a[0])) {
238
+ const o = M(a[0], n);
239
+ o && t.push(o);
240
+ }
241
+ }
242
+ if (!t.length && !d && e.type !== "matrixTable") {
243
+ const a = e.config.queryBaseSource;
244
+ v(a) && t.push(a);
245
+ }
246
+ return {
247
+ cardId: e.id,
248
+ kind: "config",
249
+ executableSources: Y(t)
250
+ };
251
+ }
252
+ function ie(e, n) {
253
+ return (e.kind === "config" ? e.executableSources : e.kind === "sql" ? e.pinnedCatalogSources.map((s) => s.source) : []).some(
254
+ (s) => I(s, n)
255
+ );
256
+ }
257
+ function Ce(e, n) {
258
+ if (e.kind === "config")
259
+ return e.executableSources.find(
260
+ (t) => I(t, n)
261
+ );
262
+ }
263
+ function Re(e, n) {
264
+ var t;
265
+ return (t = U(e, n)) == null ? void 0 : t.source;
266
+ }
267
+ function U(e, n) {
268
+ if (e.kind === "sql")
269
+ return e.pinnedCatalogSources.find(
270
+ (t) => I(t.source, n)
271
+ );
272
+ }
273
+ function j(e) {
274
+ const n = /* @__PURE__ */ new Set();
275
+ for (const t of [e.name, e.sourceField]) {
276
+ if (!t) continue;
277
+ const s = $(t);
278
+ if (!s) continue;
279
+ n.add(s);
280
+ const i = s.split("."), d = i[i.length - 1];
281
+ d && n.add(d);
282
+ }
283
+ return n;
284
+ }
285
+ function V(e, n) {
286
+ const t = R(e), s = R(n);
287
+ return t === "unknown" || s === "unknown" ? !1 : (t === "date" || t === "datetime") && (s === "date" || s === "datetime") ? !0 : t === s;
288
+ }
289
+ function se(e, n) {
290
+ return I(e.field.source, n.field.source) && $(e.field.name) === $(n.field.name) && $(e.field.sourceField || e.field.name) === $(n.field.sourceField || n.field.name);
291
+ }
292
+ function re(e, n) {
293
+ if (e.kind !== "field") return !1;
294
+ const t = j(n), s = j(e.field);
295
+ return V(n.dataType, e.field.dataType) && [...s].some((i) => t.has(i));
296
+ }
297
+ function xe(e) {
298
+ const n = e.candidates.filter(
299
+ (t) => re(
300
+ t,
301
+ e.logicalValueField
302
+ )
303
+ );
304
+ return n.length === 1 ? { status: "matched", target: n[0] } : n.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
305
+ }
306
+ function we(e) {
307
+ const n = [];
308
+ for (const t of e.acceptedTargets)
309
+ !V(
310
+ e.logicalValueField.dataType,
311
+ t.field.dataType
312
+ ) || n.some(
313
+ (s) => se(s, t)
314
+ ) || n.push(t);
315
+ return n.length === 1 ? { status: "matched", target: n[0] } : n.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
316
+ }
317
+ const oe = /\{\{-?\s*filters\s*\|\s*where\s*-?\}\}/i, ae = /\{\{-?\s*filters\s*\|\s*and\s*-?\}\}/i, de = /\bwhere\b/i;
318
+ function ce(e) {
319
+ return e != null && e.trim() ? oe.test(e) || ae.test(e) : !1;
320
+ }
321
+ function Be(e) {
322
+ return !(e != null && e.trim()) || ce(e) ? null : de.test(e) ? {
323
+ helper: "{{ filters | and }}",
324
+ description: "For queries with an existing WHERE clause."
325
+ } : {
326
+ helper: "{{ filters | where }}",
327
+ description: "For queries without a WHERE clause."
328
+ };
329
+ }
330
+ function le(e) {
331
+ return (e.field.sourceField || e.field.name).trim() || void 0;
332
+ }
333
+ function Me(e) {
334
+ if (e.inventory.kind !== "sql" || e.target.kind !== "field")
335
+ return { status: "ineligible" };
336
+ const n = U(
337
+ e.inventory,
338
+ e.target.field.source
339
+ ), t = le(e.target);
340
+ if (!n || !t) return { status: "ineligible" };
341
+ if (n.executionTable) {
342
+ const a = [
343
+ n.executionTable.databaseName,
344
+ n.executionTable.schemaName,
345
+ n.executionTable.tableName,
346
+ t
347
+ ].filter(Boolean).join(".");
348
+ return {
349
+ status: "eligible",
350
+ source: n.source,
351
+ executionIdentifier: a
352
+ };
353
+ }
354
+ if (e.inventory.pinnedCatalogSources.length !== 1)
355
+ return { status: "ineligible" };
356
+ const s = $(t), i = (e.candidateTargets || []).filter(
357
+ (a) => $(
358
+ a.field.sourceField || a.field.name
359
+ ) === s
360
+ ), d = [];
361
+ for (const a of i)
362
+ d.some(
363
+ (o) => I(o, a.field.source)
364
+ ) || d.push(a.field.source);
365
+ return d.length > 1 ? { status: "ineligible" } : {
366
+ status: "eligible",
367
+ source: n.source,
368
+ executionIdentifier: t
369
+ };
370
+ }
371
+ class fe extends Error {
372
+ constructor(t) {
373
+ super(t.map((s) => s.message).join(" "));
374
+ H(this, "issues");
375
+ this.name = "DashboardFilterMappingContractError", this.issues = t;
376
+ }
377
+ }
378
+ const ue = {
379
+ string: !0,
380
+ number: !0,
381
+ boolean: !0,
382
+ date: !0,
383
+ datetime: !0
384
+ };
385
+ function h(e) {
386
+ return typeof e == "string" && e.trim().length > 0;
387
+ }
388
+ function m(e) {
389
+ return !!e && typeof e == "object" && !Array.isArray(e);
390
+ }
391
+ function F(e) {
392
+ return Array.isArray(e) && e.every((n) => typeof n == "string");
393
+ }
394
+ function me(e) {
395
+ if (!m(e)) return !1;
396
+ switch (e.kind) {
397
+ case "allSheets":
398
+ return e.sheetKinds === void 0 || F(e.sheetKinds) && e.sheetKinds.every(
399
+ (n) => n === "dashboard" || n === "document"
400
+ );
401
+ case "sheets":
402
+ return F(e.sheetIds);
403
+ case "cards":
404
+ return F(e.cardIds);
405
+ case "documentSections":
406
+ return h(e.sheetId) && F(e.sectionIds);
407
+ default:
408
+ return !1;
409
+ }
410
+ }
411
+ function he(e) {
412
+ return e === "shared" || e === "perSheet" || e === "perCard" || e === "perDocumentSection";
413
+ }
414
+ function ge(e) {
415
+ return m(e) ? h(e.id) && h(e.column) && h(e.dataType) : !1;
416
+ }
417
+ function be(e, n, t, s) {
418
+ var o;
419
+ if (!m(n)) {
420
+ s.push({
421
+ code: "invalid_option_source",
422
+ path: t,
423
+ message: `${t} must be a semantic or physical option source.`,
424
+ inputId: e
425
+ });
426
+ return;
427
+ }
428
+ const i = n.source, d = [
429
+ ["labelField", n.labelField],
430
+ ["valueField", n.valueField],
431
+ ["searchField", n.searchField]
432
+ ];
433
+ if (!m(i) || i.kind !== "semantic" && i.kind !== "physical" || !z(i) || !m(n.labelField) || !m(n.valueField) || n.searchField !== void 0 && !m(n.searchField) || n.disambiguationFields !== void 0 && (!Array.isArray(n.disambiguationFields) || !n.disambiguationFields.every(m))) {
434
+ s.push({
435
+ code: "invalid_option_source",
436
+ path: t,
437
+ message: `${t} must contain a valid semantic or physical source and field references.`,
438
+ inputId: e
439
+ });
440
+ return;
441
+ }
442
+ for (const [l, r] of d)
443
+ r !== void 0 && m(r) && (!h(r.name) || r.source !== void 0 && !I(
444
+ r.source,
445
+ i
446
+ )) && s.push({
447
+ code: "invalid_option_source",
448
+ path: `${t}.${l}`,
449
+ message: `${t}.${l} must be a named field belonging to the declared option source.`,
450
+ inputId: e
451
+ });
452
+ for (const [l, r] of ((o = n.disambiguationFields) == null ? void 0 : o.entries()) || [])
453
+ (!m(r) || !h(r.name) || r.source !== void 0 && !I(
454
+ r.source,
455
+ i
456
+ )) && s.push({
457
+ code: "invalid_option_source",
458
+ path: `${t}.disambiguationFields[${l}]`,
459
+ message: `${t}.disambiguationFields[${l}] must be a named field belonging to the declared option source.`,
460
+ inputId: e
461
+ });
462
+ const a = n.valueField;
463
+ ["string", "number", "boolean", "date", "datetime"].includes(
464
+ String(a.dataType)
465
+ ) || s.push({
466
+ code: "invalid_option_source",
467
+ path: `${t}.valueField.dataType`,
468
+ message: `${t}.valueField.dataType must be a known option-value datatype.`,
469
+ inputId: e
470
+ });
471
+ }
472
+ function pe(e, n, t, s, i, d) {
473
+ var r;
474
+ if (h(n.bindingId) || i.push({
475
+ code: "invalid_binding_id",
476
+ path: `${t}.bindingId`,
477
+ message: `${t}.bindingId must be an opaque non-empty id.`,
478
+ inputId: e,
479
+ cardId: n.cardId
480
+ }), ((r = n.target) == null ? void 0 : r.kind) !== "field") {
481
+ i.push({
482
+ code: "unsupported_target",
483
+ path: `${t}.target`,
484
+ message: `${t}.target must be one direct field target.`,
485
+ inputId: e,
486
+ cardId: n.cardId,
487
+ bindingId: n.bindingId
488
+ });
489
+ return;
490
+ }
491
+ const a = n.target.field;
492
+ if (!h(a == null ? void 0 : a.name) || !a.source || a.source.kind !== "semantic" && a.source.kind !== "physical" || !z(a.source)) {
493
+ i.push({
494
+ code: "invalid_target_field",
495
+ path: `${t}.target.field`,
496
+ message: `${t}.target.field must have a name and a source-qualified semantic or physical identity.`,
497
+ inputId: e,
498
+ cardId: n.cardId,
499
+ bindingId: n.bindingId
500
+ });
501
+ return;
502
+ }
503
+ if (Object.prototype.hasOwnProperty.call(
504
+ ue,
505
+ a.dataType
506
+ ) || i.push({
507
+ code: "unknown_target_data_type",
508
+ path: `${t}.target.field.dataType`,
509
+ message: `${t}.target.field.dataType must be known.`,
510
+ inputId: e,
511
+ cardId: n.cardId,
512
+ bindingId: n.bindingId
513
+ }), a.sourceField !== void 0 && !h(a.sourceField) && i.push({
514
+ code: "invalid_target_field",
515
+ path: `${t}.target.field.sourceField`,
516
+ message: `${t}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,
517
+ inputId: e,
518
+ cardId: n.cardId,
519
+ bindingId: n.bindingId
520
+ }), !d) return;
521
+ const o = s.get(n.cardId);
522
+ if (!o) {
523
+ i.push({
524
+ code: "unknown_card",
525
+ path: `${t}.cardId`,
526
+ message: `${t}.cardId '${n.cardId}' does not exist.`,
527
+ inputId: e,
528
+ cardId: n.cardId,
529
+ bindingId: n.bindingId
530
+ });
531
+ return;
532
+ }
533
+ const l = te(o);
534
+ (l.kind === "unconfigured" || !ie(l, a.source)) && i.push({
535
+ code: "unavailable_card_source",
536
+ path: `${t}.target.field.source`,
537
+ message: `${t}.target field source is not declared by card '${o.id}'.`,
538
+ inputId: e,
539
+ cardId: o.id,
540
+ bindingId: n.bindingId
541
+ });
542
+ }
543
+ function Ie(e, n, t, s, i, d) {
544
+ if (n === void 0) return;
545
+ if (!m(n) || n.kind !== "cardMappings" || !Array.isArray(n.cards)) {
546
+ i.push({
547
+ code: "invalid_application",
548
+ path: t,
549
+ message: `${t} must be a cardMappings application with a cards array.`,
550
+ inputId: e
551
+ });
552
+ return;
553
+ }
554
+ const a = /* @__PURE__ */ new Set();
555
+ n.cards.forEach((o, l) => {
556
+ const r = `${t}.cards[${l}]`;
557
+ if (!h(o == null ? void 0 : o.cardId)) {
558
+ i.push({
559
+ code: "unknown_card",
560
+ path: `${r}.cardId`,
561
+ message: `${r}.cardId is required.`,
562
+ inputId: e
563
+ });
564
+ return;
565
+ }
566
+ if (a.has(o.cardId)) {
567
+ i.push({
568
+ code: "duplicate_card_application",
569
+ path: `${r}.cardId`,
570
+ message: `${t} contains more than one entry for card '${o.cardId}'.`,
571
+ inputId: e,
572
+ cardId: o.cardId
573
+ });
574
+ return;
575
+ }
576
+ if (a.add(o.cardId), d && !s.has(o.cardId)) {
577
+ i.push({
578
+ code: "unknown_card",
579
+ path: `${r}.cardId`,
580
+ message: `${r}.cardId '${o.cardId}' does not exist.`,
581
+ inputId: e,
582
+ cardId: o.cardId
583
+ });
584
+ return;
585
+ }
586
+ o.kind === "bound" ? pe(
587
+ e,
588
+ o,
589
+ r,
590
+ s,
591
+ i,
592
+ d
593
+ ) : o.kind !== "excluded" && i.push({
594
+ code: "invalid_application",
595
+ path: r,
596
+ message: `${r}.kind must be 'bound' or 'excluded'.`,
597
+ inputId: e,
598
+ cardId: o.cardId
599
+ });
600
+ });
601
+ }
602
+ function ye({
603
+ inputs: e,
604
+ dashboardFilters: n,
605
+ cards: t = [],
606
+ validateCardTargets: s = !1
607
+ }) {
608
+ const i = [], d = new Map(
609
+ (n || []).map((r) => [r.id, r])
610
+ ), a = new Map(
611
+ s ? t.map((r) => [r.id, r]) : []
612
+ ), o = [], l = /* @__PURE__ */ new Map();
613
+ return e != null && !Array.isArray(e) ? (i.push({
614
+ code: "invalid_input",
615
+ path: "dashboard.inputs",
616
+ message: "dashboard.inputs must be an array when present."
617
+ }), { ok: !1, inputs: o, issues: i }) : ((Array.isArray(e) ? e : []).forEach((r, g) => {
618
+ const f = `dashboard.inputs[${g}]`;
619
+ if (!m(r) || r.kind !== "filter" && r.kind !== "control" || !h(r.id) || !h(r.label) || !h(r.variableName) || !me(r.scope) || !he(r.runtimeScope)) {
620
+ i.push({
621
+ code: "invalid_input",
622
+ path: f,
623
+ message: `${f} must be a complete filter or control Dashboard Input envelope.`,
624
+ inputId: m(r) && typeof r.id == "string" ? r.id : void 0
625
+ });
626
+ return;
627
+ }
628
+ if (r.kind === "control" && !m(r.control)) {
629
+ i.push({
630
+ code: "invalid_input",
631
+ path: `${f}.control`,
632
+ message: `${f}.control must be a control definition.`,
633
+ inputId: r.id
634
+ });
635
+ return;
636
+ }
637
+ const u = r;
638
+ if (u.kind === "control") {
639
+ o.push(u);
640
+ return;
641
+ }
642
+ const N = u.filter, p = u.filterReference, _ = N !== void 0, P = !!p;
643
+ if (_ && P) {
644
+ i.push({
645
+ code: "both_filter_definitions",
646
+ path: f,
647
+ message: `${f} must contain either filter or filterReference, not both.`,
648
+ inputId: u.id
649
+ });
650
+ return;
651
+ }
652
+ if (!_ && !P) {
653
+ i.push({
654
+ code: "missing_filter_definition",
655
+ path: f,
656
+ message: `${f} must contain filter or filterReference.`,
657
+ inputId: u.id
658
+ });
659
+ return;
660
+ }
661
+ if (_ && !ge(N)) {
662
+ i.push({
663
+ code: "invalid_input",
664
+ path: `${f}.filter`,
665
+ message: `${f}.filter must be a complete dashboard filter definition.`,
666
+ inputId: u.id
667
+ });
668
+ return;
669
+ }
670
+ let b, D;
671
+ if (_)
672
+ b = N, D = "embedded";
673
+ else {
674
+ if ((p == null ? void 0 : p.kind) !== "dashboardFilter") {
675
+ i.push({
676
+ code: "invalid_filter_reference",
677
+ path: `${f}.filterReference.kind`,
678
+ message: `${f}.filterReference.kind must be 'dashboardFilter'.`,
679
+ inputId: u.id
680
+ });
681
+ return;
682
+ }
683
+ const A = typeof (p == null ? void 0 : p.filterId) == "string" ? p.filterId : void 0;
684
+ if (b = A ? d.get(A) : void 0, D = "dashboardFilter", !b) {
685
+ i.push({
686
+ code: "orphaned_filter_reference",
687
+ path: `${f}.filterReference.filterId`,
688
+ message: `${f}.filterReference cannot resolve dashboard filter '${A || ""}'.`,
689
+ inputId: u.id
690
+ });
691
+ return;
692
+ }
693
+ if (b.kind === "global-date") {
694
+ i.push({
695
+ code: "global_date_reference",
696
+ path: `${f}.filterReference`,
697
+ message: `${f}.filterReference cannot reference the Global Date filter.`,
698
+ inputId: u.id
699
+ });
700
+ return;
701
+ }
702
+ const q = l.get(b.id);
703
+ if (q) {
704
+ i.push({
705
+ code: "duplicate_filter_reference",
706
+ path: `${f}.filterReference.filterId`,
707
+ message: `${f}.filterReference duplicates dashboard filter '${b.id}' already owned by Dashboard Input '${q}'.`,
708
+ inputId: u.id
709
+ });
710
+ return;
711
+ }
712
+ l.set(b.id, u.id);
713
+ }
714
+ if (!b) return;
715
+ if (u.optionSource !== void 0 && be(
716
+ u.id,
717
+ u.optionSource,
718
+ `${f}.optionSource`,
719
+ i
720
+ ), u.application && b.kind === "global-date") {
721
+ i.push({
722
+ code: "global_date_reference",
723
+ path: `${f}.application`,
724
+ message: `${f}.application cannot map the Global Date filter.`,
725
+ inputId: u.id
726
+ });
727
+ return;
728
+ }
729
+ u.application && u.scope.kind !== "allSheets" && u.scope.kind !== "sheets" && i.push({
730
+ code: "unsupported_mapped_scope",
731
+ path: `${f}.scope`,
732
+ message: `${f}.scope must be allSheets or sheets when cardMappings are present.`,
733
+ inputId: u.id
734
+ }), Ie(
735
+ u.id,
736
+ u.application,
737
+ `${f}.application`,
738
+ a,
739
+ i,
740
+ s
741
+ );
742
+ const {
743
+ filter: Fe,
744
+ filterReference: Te,
745
+ // A reference-backed authored input must shadow the generated
746
+ // dashboard-filter compatibility input. Older writers may have copied
747
+ // the compatibility marker onto the reference; never preserve it.
748
+ compatibility: O,
749
+ ...W
750
+ } = u;
751
+ o.push({
752
+ ...W,
753
+ filter: b,
754
+ ..._ && O ? { compatibility: O } : {},
755
+ ...u.optionSource ? {
756
+ optionSource: u.optionSource
757
+ } : {},
758
+ definitionOrigin: D
759
+ });
760
+ }), i.length ? { ok: !1, inputs: o, issues: i } : { ok: !0, inputs: o });
761
+ }
762
+ function ze(e) {
763
+ const n = ye(e);
764
+ if (!n.ok) throw new fe(n.issues);
765
+ return n.inputs;
766
+ }
767
+ function Pe(e = () => globalThis.crypto.randomUUID()) {
768
+ return e();
769
+ }
770
+ const $e = {
771
+ date: /* @__PURE__ */ new Set([
772
+ "between",
773
+ "not between",
774
+ "=",
775
+ "!=",
776
+ ">",
777
+ ">=",
778
+ "<",
779
+ "<=",
780
+ "is null",
781
+ "is not null"
782
+ ]),
783
+ number: /* @__PURE__ */ new Set([
784
+ "between",
785
+ "not between",
786
+ "=",
787
+ "!=",
788
+ ">",
789
+ ">=",
790
+ "<",
791
+ "<=",
792
+ "in",
793
+ "not in",
794
+ "is null",
795
+ "is not null"
796
+ ]),
797
+ string: /* @__PURE__ */ new Set([
798
+ "=",
799
+ "!=",
800
+ "in",
801
+ "not in",
802
+ "like",
803
+ "not like",
804
+ "is null",
805
+ "is not null"
806
+ ]),
807
+ boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
808
+ };
809
+ function _e(e) {
810
+ const n = R(e);
811
+ return n === "number" || n === "boolean" ? n : n === "date" || n === "datetime" ? "date" : "string";
812
+ }
813
+ function Oe(e, n) {
814
+ return typeof n != "string" ? !1 : $e[_e(e)].has(n);
815
+ }
816
+ export {
817
+ fe as D,
818
+ Re as a,
819
+ te as b,
820
+ U as c,
821
+ ie as d,
822
+ re as e,
823
+ Ce as f,
824
+ we as g,
825
+ ce as h,
826
+ Be as i,
827
+ Me as j,
828
+ ze as k,
829
+ Pe as l,
830
+ _e as m,
831
+ ye as n,
832
+ Oe as o,
833
+ De as p,
834
+ Ae as q,
835
+ xe as r
836
+ };