react-semaphor 0.1.424 → 0.1.426
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/analytics-protocol/index.cjs +1 -1
- package/dist/analytics-protocol/index.js +246 -91
- package/dist/appearance/index.cjs +1 -1
- package/dist/appearance/index.js +1 -1
- package/dist/brand-studio/index.cjs +2 -2
- package/dist/brand-studio/index.js +8 -8
- package/dist/chunks/{analyze-result-contract-D7pjjYPy.js → analyze-result-contract-DnfF8kBb.js} +434 -427
- package/dist/chunks/analyze-result-contract-ege_u6Nl.js +1 -0
- package/dist/chunks/{braces-8TRlDwDw.js → braces-BdbUk_r9.js} +1 -1
- package/dist/chunks/{braces-D2tStQjF.js → braces-CbO-aIwH.js} +1 -1
- package/dist/chunks/calendar-preferences-dialog-C-gN-vlq.js +1 -0
- package/dist/chunks/{calendar-preferences-dialog-D5mABNDT.js → calendar-preferences-dialog-tBSngRN-.js} +4 -4
- package/dist/chunks/{catalog-field-grounding-CJKAqtiC.js → catalog-field-grounding-AOGwWu0K.js} +11 -11
- package/dist/chunks/{switch-2bh3Hka1.js → code-editor-Pod1s6SK.js} +9927 -9098
- package/dist/chunks/code-editor-tfzm8LWW.js +138 -0
- package/dist/chunks/{common-types-4bjoIgvm.js → common-types-ClkOI-3O.js} +4 -4
- package/dist/chunks/comparison-document-migration-BJH1idOd.js +414 -0
- package/dist/chunks/comparison-document-migration-b6c3xiWh.js +1 -0
- package/dist/chunks/dashboard-JNK2ly_e.js +1402 -0
- package/dist/chunks/{index-Dzz6jXSY.js → dashboard-ZoKNg47G.js} +67158 -65267
- package/dist/chunks/{dashboard-briefing-launcher-DuWgwtxX.js → dashboard-briefing-launcher-0kR-QThz.js} +11 -6
- package/dist/chunks/{dashboard-briefing-launcher-BNDzMjjt.js → dashboard-briefing-launcher-BE-sNAzW.js} +226 -209
- package/dist/chunks/dashboard-controls-BUYTVauu.js +36 -0
- package/dist/chunks/dashboard-controls-Ce_Bps8f.js +2196 -0
- package/dist/chunks/dashboard-date-comparison-definition-BaYxjLi5.js +167 -0
- package/dist/chunks/dashboard-date-comparison-definition-DGZr3m-b.js +1 -0
- package/dist/chunks/dashboard-input-contract-BFpERluO.js +18 -0
- package/dist/chunks/dashboard-input-contract-DV3cshjz.js +1 -0
- package/dist/chunks/{dashboard-json-CkTEDNtH.js → dashboard-json-4quaFoSw.js} +16 -15
- package/dist/chunks/dashboard-json-81uc8aVR.js +1 -0
- package/dist/chunks/date-formatter-BTTYdAik.js +1 -0
- package/dist/chunks/date-formatter-D-89jTjG.js +514 -0
- package/dist/chunks/{edit-dashboard-visual-CRjVRZLk.js → edit-dashboard-visual-DqQsH7rN.js} +8470 -8520
- package/dist/chunks/edit-dashboard-visual-nVRXv1Lq.js +182 -0
- package/dist/chunks/{index-CjzRe2su.js → index-CnujJ3fa.js} +3 -3
- package/dist/chunks/{index-DRlMUglg.js → index-Dpm_VET4.js} +2 -2
- package/dist/chunks/{index-CJdxSyQq.js → index-If0wlXGi.js} +308 -308
- package/dist/chunks/index-jSrCwPQz.js +31 -0
- package/dist/chunks/{x-CXDkqdur.js → index-xHCrHprY.js} +59 -59
- package/dist/chunks/{layout-grid-C0OI-MRn.js → layout-grid-B08pP7v6.js} +1 -1
- package/dist/chunks/{layout-grid-CiubineE.js → layout-grid-D5tYJg1-.js} +1 -1
- package/dist/chunks/metric-comparison-BKgkMy9r.js +1 -0
- package/dist/chunks/metric-comparison-CWweq9RG.js +387 -0
- package/dist/chunks/{palette-C4KTXOug.js → palette-C0yjT5Tv.js} +1 -1
- package/dist/chunks/{palette-Cp1hqZtm.js → palette-jqaAcwiQ.js} +1 -1
- package/dist/chunks/{save-DgMfP0j8.js → save-HCJjjzdX.js} +1 -1
- package/dist/chunks/{save-C__QggEE.js → save-Xdc4pnys.js} +1 -1
- package/dist/chunks/{search-BHsQIWBV.js → search-DHZCro8B.js} +1 -1
- package/dist/chunks/{search-DNCejM7Z.js → search-Dcud9ajy.js} +1 -1
- package/dist/chunks/{update-policy-C1pmhLz9.js → update-policy-BgONreNd.js} +1 -1
- package/dist/chunks/{update-policy-BCJc0oI5.js → update-policy-CY2k-pJP.js} +9 -9
- package/dist/chunks/{use-create-flow-overlay-state-B-bYbtix.js → use-create-flow-overlay-state-CoANTEXS.js} +2 -2
- package/dist/chunks/{use-create-flow-overlay-state-B9vArrvr.js → use-create-flow-overlay-state-DUVIsF0y.js} +62 -62
- package/dist/chunks/validators-B4VMLX3_.js +1 -0
- package/dist/chunks/{validators-PXkij33j.js → validators-Cz-XuORM.js} +123 -119
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +2 -2
- package/dist/dashboard-authoring/index.js +6 -4
- package/dist/data-app-builder/index.cjs +6 -6
- package/dist/data-app-builder/index.js +5 -5
- package/dist/data-app-codegen/index.cjs +1 -1
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.cjs +1 -1
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.cjs +1 -1
- package/dist/data-app-sdk/index.js +6 -6
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +1 -1
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +65 -68
- package/dist/format-utils/index.cjs +2 -2
- package/dist/format-utils/index.js +59 -58
- package/dist/index.cjs +1 -1
- package/dist/index.js +19 -19
- package/dist/style.css +1 -1
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +337 -3
- package/dist/types/brand-studio.d.ts +2 -2
- package/dist/types/briefings.d.ts +65 -41
- package/dist/types/dashboard-assistant.d.ts +28 -7
- package/dist/types/dashboard-authoring.d.ts +123 -43
- package/dist/types/dashboard.d.ts +122 -48
- package/dist/types/data-app-builder.d.ts +2 -2
- package/dist/types/data-app-sdk.d.ts +1 -1
- package/dist/types/format-utils.d.ts +98 -10
- package/dist/types/index.js +1 -1
- package/dist/types/main.d.ts +264 -100
- package/dist/types/shared.d.ts +84 -43
- package/dist/types/surfboard.d.ts +124 -49
- package/dist/types/types.d.ts +135 -50
- package/package.json +2 -1
- package/dist/chunks/analyze-result-contract-DpDcImgk.js +0 -1
- package/dist/chunks/calendar-preferences-dialog-iokD3HbE.js +0 -1
- package/dist/chunks/contracts-CoCOpd_i.js +0 -11
- package/dist/chunks/contracts-CtB2VONT.js +0 -1
- package/dist/chunks/dashboard-controls-bbEF-AbK.js +0 -52
- package/dist/chunks/dashboard-controls-id39vb7G.js +0 -2322
- package/dist/chunks/dashboard-json-DVoqS1ks.js +0 -1
- package/dist/chunks/date-formatter-B4EBSe9C.js +0 -1
- package/dist/chunks/date-formatter-BlhBftA9.js +0 -416
- package/dist/chunks/edit-dashboard-visual-CkrxZCcp.js +0 -178
- package/dist/chunks/index-S1CGUcSz.js +0 -1406
- package/dist/chunks/switch-DMT7qf_R.js +0 -138
- package/dist/chunks/validators-DMlVbd1p.js +0 -1
- package/dist/chunks/x-B6ghREd2.js +0 -31
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { useState as H, useEffect as ie, useCallback as B, useMemo as P, useRef as Se, Fragment as gt } from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { b5 as
|
|
2
|
+
import { E as de, D as _e, u as Z, F as M, a4 as yt, Q as vt, V as xt, W as Ct, c as fe, Y as St, a5 as kt, B as q, d as Nt, e as Ze, a6 as wt, a7 as Dt, a8 as Et, a9 as pe, aa as je, ab as Re, ac as ke, ad as Ne, ae as It, af as Qe, ag as Ft, ah as Vt, ai as me, aj as Tt, ak as $e, al as et, am as tt, an as rt, L as oe, Z as at, _ as we, $ as De, a0 as Ee, a1 as Ie, a2 as Fe, ao as st, ap as _t, aq as Pe, ar as Lt, as as We, at as At, au as qt, av as Ve } from "./code-editor-Pod1s6SK.js";
|
|
3
|
+
import { b5 as Mt, u as Ot, b6 as ce, b7 as Ut, b8 as Le, b9 as zt, ba as Bt, bb as jt, p as j, bc as Rt, bd as Qt, be as nt, bf as $t, bg as Pt, bh as Wt, bi as Kt, bj as Ht, aG as Yt, bk as Gt, bl as ot, bm as lt, bn as Xt, bo as Jt, bp as Zt, bq as er, br as it, bs as dt, bt as tr, bu as rr, bv as ar, bw as sr, bx as nr, aX as or, by as lr, bz as ir } from "./dashboard-ZoKNg47G.js";
|
|
4
4
|
import { jsx as r, jsxs as m, Fragment as ae } from "react/jsx-runtime";
|
|
5
|
-
import { c as ct, X as ut, C as Ke } from "./
|
|
6
|
-
import "./analyze-result-contract-
|
|
7
|
-
import { S as pt } from "./save-
|
|
8
|
-
import { C as He } from "./search-
|
|
5
|
+
import { c as ct, X as ut, C as Ke } from "./index-xHCrHprY.js";
|
|
6
|
+
import "./analyze-result-contract-DnfF8kBb.js";
|
|
7
|
+
import { S as pt } from "./save-HCJjjzdX.js";
|
|
8
|
+
import { C as He } from "./search-DHZCro8B.js";
|
|
9
9
|
/**
|
|
10
10
|
* @license lucide-react v0.453.0 - ISC
|
|
11
11
|
*
|
|
@@ -30,7 +30,7 @@ const cr = ct("Link2", [
|
|
|
30
30
|
["line", { x1: "8", x2: "16", y1: "12", y2: "12", key: "1jonct" }]
|
|
31
31
|
]);
|
|
32
32
|
function ur(t) {
|
|
33
|
-
const [a, n] = H(null), [s, l] = H(null), d =
|
|
33
|
+
const [a, n] = H(null), [s, l] = H(null), d = Mt();
|
|
34
34
|
return ie(() => {
|
|
35
35
|
if (!t || t.trim() === "") {
|
|
36
36
|
n(null), l(null);
|
|
@@ -158,7 +158,7 @@ function hr(t, a) {
|
|
|
158
158
|
const l = (p = s.cards) == null ? void 0 : p.find(
|
|
159
159
|
(f) => f.id === s.activeCardId
|
|
160
160
|
);
|
|
161
|
-
return l ? (
|
|
161
|
+
return l ? (Rt({
|
|
162
162
|
...a,
|
|
163
163
|
frame: s,
|
|
164
164
|
card: l,
|
|
@@ -206,8 +206,8 @@ function br() {
|
|
|
206
206
|
};
|
|
207
207
|
}, [a]) };
|
|
208
208
|
}
|
|
209
|
-
function
|
|
210
|
-
const { authToken: t, tokenProps: a } =
|
|
209
|
+
function Ae() {
|
|
210
|
+
const { authToken: t, tokenProps: a } = Ot(), n = ce(), s = Ut(), l = Le(), { selectVisual: d } = zt(), {
|
|
211
211
|
setFrame: p,
|
|
212
212
|
setCard: f,
|
|
213
213
|
setIsDevMode: u,
|
|
@@ -229,9 +229,9 @@ function Le() {
|
|
|
229
229
|
setIsVisualEditing: o,
|
|
230
230
|
setSelectedFrameId: D,
|
|
231
231
|
clearSelectedFrameId: V
|
|
232
|
-
} = _e(), U = Z((_) => _.selectedSheetId), W = Z((_) => _.selectedFrameId), J = Z((_) => _.dashboard), te = Z((_) => _.filterValues),
|
|
232
|
+
} = _e(), U = Z((_) => _.selectedSheetId), W = Z((_) => _.selectedFrameId), J = Z((_) => _.dashboard), te = Z((_) => _.filterValues), L = Z(
|
|
233
233
|
(_) => _.inlineFilterValuesMap
|
|
234
|
-
), Q =
|
|
234
|
+
), Q = Bt((l == null ? void 0 : l.id) || "", {
|
|
235
235
|
enabled: !!(l != null && l.id) && !!(t != null && t.accessToken)
|
|
236
236
|
}), Y = B(
|
|
237
237
|
async (_) => {
|
|
@@ -266,7 +266,7 @@ function Le() {
|
|
|
266
266
|
selectedSheetId: U,
|
|
267
267
|
selectedFrameId: W,
|
|
268
268
|
filterValues: te,
|
|
269
|
-
inlineFilterValuesMap:
|
|
269
|
+
inlineFilterValuesMap: L
|
|
270
270
|
}))
|
|
271
271
|
throw new Error("Failed to setup editor with visual data");
|
|
272
272
|
return { success: !0, fromCache: K };
|
|
@@ -302,29 +302,29 @@ function Le() {
|
|
|
302
302
|
U,
|
|
303
303
|
W,
|
|
304
304
|
te,
|
|
305
|
-
|
|
305
|
+
L
|
|
306
306
|
]
|
|
307
307
|
), be = B(
|
|
308
308
|
async (_) => {
|
|
309
309
|
var K;
|
|
310
|
-
const E = (
|
|
310
|
+
const E = (A) => (j.error(A), { success: !1, error: A });
|
|
311
311
|
try {
|
|
312
312
|
if (d(_), !U)
|
|
313
313
|
return E("No sheet selected. Please select a sheet first.");
|
|
314
|
-
const { data:
|
|
314
|
+
const { data: A, fromCache: ge } = await Ye(
|
|
315
315
|
a.apiServiceUrl,
|
|
316
316
|
(t == null ? void 0 : t.accessToken) || "",
|
|
317
317
|
_.id,
|
|
318
318
|
n,
|
|
319
319
|
"Adding visual to dashboard..."
|
|
320
|
-
), ue = (
|
|
320
|
+
), ue = (A == null ? void 0 : A.frameObject) ?? ((K = A == null ? void 0 : A.visual) == null ? void 0 : K.frameObject);
|
|
321
321
|
if (!ue)
|
|
322
322
|
return E("Visual has no frame data");
|
|
323
323
|
const $ = mt(ue);
|
|
324
324
|
if (!($ != null && $.cards) || $.cards.length === 0)
|
|
325
325
|
return E("Visual frame is malformed");
|
|
326
326
|
const le = {
|
|
327
|
-
...
|
|
327
|
+
...jt($),
|
|
328
328
|
visualId: _.id
|
|
329
329
|
// Link this frame to the library visual
|
|
330
330
|
};
|
|
@@ -333,9 +333,9 @@ function Le() {
|
|
|
333
333
|
le,
|
|
334
334
|
"end"
|
|
335
335
|
), O(!0), D(le.id), { success: !0, fromCache: ge };
|
|
336
|
-
} catch (
|
|
337
|
-
return console.error("Error adding visual:",
|
|
338
|
-
|
|
336
|
+
} catch (A) {
|
|
337
|
+
return console.error("Error adding visual:", A), E(
|
|
338
|
+
A instanceof Error ? A.message : "Failed to add visual to dashboard"
|
|
339
339
|
);
|
|
340
340
|
}
|
|
341
341
|
},
|
|
@@ -372,7 +372,7 @@ function Tr() {
|
|
|
372
372
|
ie(() => {
|
|
373
373
|
var w;
|
|
374
374
|
if (!t) return;
|
|
375
|
-
const { tableName: p, schemaName: f, databaseName: u, connectionId: v } =
|
|
375
|
+
const { tableName: p, schemaName: f, databaseName: u, connectionId: v } = Qt(t), g = (w = t.selectedEntities) == null ? void 0 : w[0], x = (g == null ? void 0 : g.type) === "model" && "id" in g ? g.id : "";
|
|
376
376
|
a(v || ""), n(u || ""), s(f || ""), l(p || ""), d(x);
|
|
377
377
|
}, [
|
|
378
378
|
t,
|
|
@@ -388,7 +388,7 @@ function ft() {
|
|
|
388
388
|
const t = M((g) => g.card), a = M((g) => g.frame), n = P(
|
|
389
389
|
() => nt(a, t),
|
|
390
390
|
[a, t]
|
|
391
|
-
), { manifest: s } =
|
|
391
|
+
), { manifest: s } = $t(
|
|
392
392
|
((u = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : u.url) || ""
|
|
393
393
|
), l = P(
|
|
394
394
|
() => {
|
|
@@ -401,8 +401,8 @@ function ft() {
|
|
|
401
401
|
);
|
|
402
402
|
},
|
|
403
403
|
[s, (v = n == null ? void 0 : n.customCardPreferences) == null ? void 0 : v.componentName]
|
|
404
|
-
), d =
|
|
405
|
-
() =>
|
|
404
|
+
), d = Pt(n, l), p = P(
|
|
405
|
+
() => Wt({
|
|
406
406
|
frame: a,
|
|
407
407
|
configCard: n,
|
|
408
408
|
isMultiInputVisual: d === "multiple"
|
|
@@ -412,9 +412,9 @@ function ft() {
|
|
|
412
412
|
const g = p.findIndex(
|
|
413
413
|
(h) => (h == null ? void 0 : h.id) === t.id
|
|
414
414
|
);
|
|
415
|
-
return g < 0 ? -1 :
|
|
415
|
+
return g < 0 ? -1 : Kt(t, g);
|
|
416
416
|
}, [p, t]);
|
|
417
|
-
return P(() => !n || d !== "multiple" || f < 0 ? t.type :
|
|
417
|
+
return P(() => !n || d !== "multiple" || f < 0 ? t.type : Ht(
|
|
418
418
|
t,
|
|
419
419
|
f,
|
|
420
420
|
l == null ? void 0 : l.slots
|
|
@@ -427,7 +427,7 @@ function _r({
|
|
|
427
427
|
showLabel: s = !1,
|
|
428
428
|
showLocal: l = !1
|
|
429
429
|
}) {
|
|
430
|
-
const d = Z((N) => N.selectedFrameId), p =
|
|
430
|
+
const d = Z((N) => N.selectedFrameId), p = Yt((N) => N.selectedVisual), f = M((N) => N.frame);
|
|
431
431
|
let u;
|
|
432
432
|
if (t)
|
|
433
433
|
u = t;
|
|
@@ -472,7 +472,7 @@ function _r({
|
|
|
472
472
|
};
|
|
473
473
|
return /* @__PURE__ */ r(vt, { children: /* @__PURE__ */ m(xt, { delayDuration: 300, children: [
|
|
474
474
|
/* @__PURE__ */ r(Ct, { asChild: !0, children: /* @__PURE__ */ m(
|
|
475
|
-
|
|
475
|
+
Gt,
|
|
476
476
|
{
|
|
477
477
|
variant: "outline",
|
|
478
478
|
className: fe(
|
|
@@ -516,14 +516,14 @@ function gr(t, a) {
|
|
|
516
516
|
};
|
|
517
517
|
}
|
|
518
518
|
function qe(t) {
|
|
519
|
-
const a =
|
|
519
|
+
const a = Dt(t);
|
|
520
520
|
return a ? (j.error(a), !1) : !0;
|
|
521
521
|
}
|
|
522
|
-
function
|
|
522
|
+
function Lr({
|
|
523
523
|
className: t,
|
|
524
524
|
variant: a = "outline"
|
|
525
525
|
}) {
|
|
526
|
-
const n = M((d) => d.onSave), { getUpdatedFrame: s } =
|
|
526
|
+
const n = M((d) => d.onSave), { getUpdatedFrame: s } = Ae();
|
|
527
527
|
function l() {
|
|
528
528
|
const d = s();
|
|
529
529
|
qe(d) && (n == null || n(d));
|
|
@@ -542,11 +542,11 @@ function Ar({
|
|
|
542
542
|
}
|
|
543
543
|
);
|
|
544
544
|
}
|
|
545
|
-
function
|
|
545
|
+
function Ar({
|
|
546
546
|
className: t,
|
|
547
547
|
variant: a = "default"
|
|
548
548
|
}) {
|
|
549
|
-
const n = ce(), [s, l] = H(!1), { setIsVisualEditing: d } = _e(), { getUpdatedFrame: p } =
|
|
549
|
+
const n = ce(), [s, l] = H(!1), { setIsVisualEditing: d } = _e(), { getUpdatedFrame: p } = Ae(), f = Le(), u = M((h) => h.frame), v = lt();
|
|
550
550
|
return /* @__PURE__ */ r(
|
|
551
551
|
q,
|
|
552
552
|
{
|
|
@@ -595,7 +595,7 @@ function Lr({
|
|
|
595
595
|
function qr({
|
|
596
596
|
className: t
|
|
597
597
|
}) {
|
|
598
|
-
const a = ce(), [n, s] = H(!1), l =
|
|
598
|
+
const a = ce(), [n, s] = H(!1), l = Le(), d = M((S) => S.frame), p = Z((S) => S.selectedSheetId), f = Z((S) => S.dashboard), { updateFrame: u, setIsVisualEditing: v } = _e(), { getUpdatedFrame: g } = Ae(), h = lt(), x = Xt();
|
|
599
599
|
return /* @__PURE__ */ r(
|
|
600
600
|
q,
|
|
601
601
|
{
|
|
@@ -620,7 +620,7 @@ function qr({
|
|
|
620
620
|
...N,
|
|
621
621
|
visualId: S
|
|
622
622
|
// Keep the link to library visual
|
|
623
|
-
}, R =
|
|
623
|
+
}, R = wt(f, F.id), G = await x(F, {
|
|
624
624
|
previousFrame: R
|
|
625
625
|
});
|
|
626
626
|
await h.mutateAsync({
|
|
@@ -697,13 +697,13 @@ function Or({
|
|
|
697
697
|
setActiveTabCardId: X
|
|
698
698
|
} = de();
|
|
699
699
|
function se() {
|
|
700
|
-
var J, te,
|
|
700
|
+
var J, te, L, Q;
|
|
701
701
|
const O = l.getQueryData(v);
|
|
702
702
|
d != null && d.queryData || s({
|
|
703
703
|
queryKey: v,
|
|
704
704
|
queryData: O
|
|
705
705
|
}), l.setQueryData(v, null), l.removeQueries({ queryKey: v, exact: !0 }), g(""), h({}), N(), F(void 0), x(""), w(""), S({});
|
|
706
|
-
const o = M.getState().frame, D = M.getState().card, V = nt(o, D), U = ((J = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : J.visualType) === "multiple" || !!((te = V == null ? void 0 : V.customCardPreferences) != null && te.dataInputCardIds) || (((
|
|
706
|
+
const o = M.getState().frame, D = M.getState().card, V = nt(o, D), U = ((J = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : J.visualType) === "multiple" || !!((te = V == null ? void 0 : V.customCardPreferences) != null && te.dataInputCardIds) || (((L = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : L.minInputs) || 0) > 1 || (((Q = V == null ? void 0 : V.customCardPreferences) == null ? void 0 : Q.maxInputs) || 0) > 1, W = gr(D, U);
|
|
707
707
|
G({
|
|
708
708
|
...o,
|
|
709
709
|
cards: o.cards.map(
|
|
@@ -1012,7 +1012,7 @@ function Ur({
|
|
|
1012
1012
|
const F = P(
|
|
1013
1013
|
() => new Set(n || []),
|
|
1014
1014
|
[n]
|
|
1015
|
-
), R =
|
|
1015
|
+
), R = At(t), G = Et(t), [ee, X] = H(
|
|
1016
1016
|
null
|
|
1017
1017
|
), [se, O] = H(
|
|
1018
1018
|
null
|
|
@@ -1040,7 +1040,7 @@ function Ur({
|
|
|
1040
1040
|
return c.filter((b) => i.has(b.value));
|
|
1041
1041
|
},
|
|
1042
1042
|
[w, x, t]
|
|
1043
|
-
),
|
|
1043
|
+
), L = B(
|
|
1044
1044
|
(e) => t === "dashboard" && (e === "field_selector" || e === "metric_selector"),
|
|
1045
1045
|
[t]
|
|
1046
1046
|
), Q = P(
|
|
@@ -1055,7 +1055,7 @@ function Ur({
|
|
|
1055
1055
|
fields: u || [],
|
|
1056
1056
|
metrics: v || []
|
|
1057
1057
|
};
|
|
1058
|
-
if (!
|
|
1058
|
+
if (!L(o.control.type))
|
|
1059
1059
|
return {
|
|
1060
1060
|
fields: u || [],
|
|
1061
1061
|
metrics: v || []
|
|
@@ -1079,7 +1079,7 @@ function Ur({
|
|
|
1079
1079
|
u,
|
|
1080
1080
|
v,
|
|
1081
1081
|
o,
|
|
1082
|
-
|
|
1082
|
+
L,
|
|
1083
1083
|
g
|
|
1084
1084
|
]);
|
|
1085
1085
|
ie(() => {
|
|
@@ -1092,7 +1092,7 @@ function Ur({
|
|
|
1092
1092
|
}), O(null), X(null));
|
|
1093
1093
|
}, [a, p, F, t]);
|
|
1094
1094
|
const be = (e) => {
|
|
1095
|
-
if (!
|
|
1095
|
+
if (!L(e.type))
|
|
1096
1096
|
return {
|
|
1097
1097
|
fields: u || [],
|
|
1098
1098
|
metrics: v || []
|
|
@@ -1119,7 +1119,7 @@ function Ur({
|
|
|
1119
1119
|
})) : []
|
|
1120
1120
|
};
|
|
1121
1121
|
}, _ = (e) => {
|
|
1122
|
-
if (!
|
|
1122
|
+
if (!L(e.control.type))
|
|
1123
1123
|
return {
|
|
1124
1124
|
nextControl: e.control,
|
|
1125
1125
|
cardBindingsById: void 0
|
|
@@ -1128,7 +1128,7 @@ function Ur({
|
|
|
1128
1128
|
controlType: e.control.type,
|
|
1129
1129
|
participants: g || [],
|
|
1130
1130
|
selectedCardIds: e.nextSelectedCardIds
|
|
1131
|
-
}), b =
|
|
1131
|
+
}), b = qt({
|
|
1132
1132
|
control: e.control,
|
|
1133
1133
|
choices: i.choices
|
|
1134
1134
|
}), C = Object.fromEntries(
|
|
@@ -1150,7 +1150,7 @@ function Ur({
|
|
|
1150
1150
|
const b = e.map((C) => (Ne({
|
|
1151
1151
|
control: C,
|
|
1152
1152
|
defaultValues: c
|
|
1153
|
-
}),
|
|
1153
|
+
}), It(
|
|
1154
1154
|
C
|
|
1155
1155
|
)));
|
|
1156
1156
|
l(b, c, i);
|
|
@@ -1203,7 +1203,7 @@ function Ur({
|
|
|
1203
1203
|
cardBindingsById: k,
|
|
1204
1204
|
affectedBindingControlIds: y
|
|
1205
1205
|
});
|
|
1206
|
-
},
|
|
1206
|
+
}, A = (e, c) => {
|
|
1207
1207
|
if (!c.trim())
|
|
1208
1208
|
return;
|
|
1209
1209
|
const i = lr(c);
|
|
@@ -1268,12 +1268,12 @@ function Ur({
|
|
|
1268
1268
|
}, ye = (() => {
|
|
1269
1269
|
if (!o)
|
|
1270
1270
|
return !1;
|
|
1271
|
-
if (o.step === 2 &&
|
|
1271
|
+
if (o.step === 2 && L(o.control.type))
|
|
1272
1272
|
return (o.selectedCardIds || []).length > 0;
|
|
1273
1273
|
if (o.step !== 2 && o.step !== 3 || !o.control.label.trim())
|
|
1274
1274
|
return !1;
|
|
1275
1275
|
const c = o.control.source.kind === "sql_query" ? o.control : Qe(o.control);
|
|
1276
|
-
if (c.source.kind === "manual" && (
|
|
1276
|
+
if (c.source.kind === "manual" && (Ft(c) && c.source.options.length === 0 || c.source.options.some(
|
|
1277
1277
|
(b) => b.label.trim().length === 0 || b.value.trim().length === 0
|
|
1278
1278
|
)))
|
|
1279
1279
|
return !1;
|
|
@@ -1281,14 +1281,14 @@ function Ur({
|
|
|
1281
1281
|
const { connectionId: i, sql: b, valueColumn: C } = c.source;
|
|
1282
1282
|
return i.trim().length > 0 && b.trim().length > 0 && C.trim().length > 0;
|
|
1283
1283
|
}
|
|
1284
|
-
return
|
|
1284
|
+
return Vt(
|
|
1285
1285
|
me(c, o.defaultValue)
|
|
1286
1286
|
);
|
|
1287
1287
|
})(), Me = () => {
|
|
1288
1288
|
var k;
|
|
1289
1289
|
if (!o)
|
|
1290
1290
|
return;
|
|
1291
|
-
const e = Qe(o.control), c =
|
|
1291
|
+
const e = Qe(o.control), c = Lt({
|
|
1292
1292
|
label: e.label,
|
|
1293
1293
|
fallbackId: e.id,
|
|
1294
1294
|
existingControls: a,
|
|
@@ -1355,7 +1355,7 @@ function Ur({
|
|
|
1355
1355
|
}
|
|
1356
1356
|
);
|
|
1357
1357
|
O(c), D(null), N == null || N();
|
|
1358
|
-
}, [a, o, s, E, N]), bt = o ?
|
|
1358
|
+
}, [a, o, s, E, N]), bt = o ? L(o.control.type) ? ["Choose type", "Select cards", "Configure", "Finish"] : ["Choose type", "Configure", "Finish"] : [], Ue = o != null && o.createdControlId ? `[[param.${o.createdControlId}]]` : o ? `[[param.${Tt(o.control.label) || o.control.id}]]` : "", xe = $e({
|
|
1359
1359
|
controls: a,
|
|
1360
1360
|
defaultValues: s
|
|
1361
1361
|
}), Ce = o ? [...a, o.control] : a, ze = o ? $e({
|
|
@@ -1439,7 +1439,7 @@ function Ur({
|
|
|
1439
1439
|
)
|
|
1440
1440
|
] });
|
|
1441
1441
|
})(),
|
|
1442
|
-
o.step === 2 &&
|
|
1442
|
+
o.step === 2 && L(o.control.type) && /* @__PURE__ */ m("div", { className: "space-y-3", children: [
|
|
1443
1443
|
/* @__PURE__ */ m("div", { className: "space-y-3", children: [
|
|
1444
1444
|
/* @__PURE__ */ r(
|
|
1445
1445
|
ht,
|
|
@@ -1523,7 +1523,7 @@ function Ur({
|
|
|
1523
1523
|
}
|
|
1524
1524
|
)
|
|
1525
1525
|
] }),
|
|
1526
|
-
o.step === 2 && !
|
|
1526
|
+
o.step === 2 && !L(o.control.type) && /* @__PURE__ */ r(
|
|
1527
1527
|
Ge,
|
|
1528
1528
|
{
|
|
1529
1529
|
control: o.control,
|
|
@@ -1548,7 +1548,7 @@ function Ur({
|
|
|
1548
1548
|
nextDisabled: !ye
|
|
1549
1549
|
}
|
|
1550
1550
|
),
|
|
1551
|
-
o.step === 3 &&
|
|
1551
|
+
o.step === 3 && L(o.control.type) && /* @__PURE__ */ r(
|
|
1552
1552
|
Ge,
|
|
1553
1553
|
{
|
|
1554
1554
|
control: o.control,
|
|
@@ -1573,7 +1573,7 @@ function Ur({
|
|
|
1573
1573
|
nextDisabled: !ye
|
|
1574
1574
|
}
|
|
1575
1575
|
),
|
|
1576
|
-
o.step === 3 && !
|
|
1576
|
+
o.step === 3 && !L(o.control.type) && /* @__PURE__ */ r(
|
|
1577
1577
|
Je,
|
|
1578
1578
|
{
|
|
1579
1579
|
control: o.control,
|
|
@@ -1597,7 +1597,7 @@ function Ur({
|
|
|
1597
1597
|
onDone: Oe
|
|
1598
1598
|
}
|
|
1599
1599
|
),
|
|
1600
|
-
o.step === 4 &&
|
|
1600
|
+
o.step === 4 && L(o.control.type) && /* @__PURE__ */ r(
|
|
1601
1601
|
Je,
|
|
1602
1602
|
{
|
|
1603
1603
|
control: o.control,
|
|
@@ -1737,7 +1737,7 @@ function Ur({
|
|
|
1737
1737
|
)
|
|
1738
1738
|
] })
|
|
1739
1739
|
] }),
|
|
1740
|
-
|
|
1740
|
+
L(e.type) ? /* @__PURE__ */ r(
|
|
1741
1741
|
er,
|
|
1742
1742
|
{
|
|
1743
1743
|
type: e.type,
|
|
@@ -1825,7 +1825,7 @@ function Ur({
|
|
|
1825
1825
|
sr,
|
|
1826
1826
|
{
|
|
1827
1827
|
controlId: e.id,
|
|
1828
|
-
onCommit: (y) =>
|
|
1828
|
+
onCommit: (y) => A(e.id, y)
|
|
1829
1829
|
},
|
|
1830
1830
|
e.id
|
|
1831
1831
|
)
|
|
@@ -1923,11 +1923,11 @@ function zr(t) {
|
|
|
1923
1923
|
}
|
|
1924
1924
|
export {
|
|
1925
1925
|
Ur as C,
|
|
1926
|
-
|
|
1926
|
+
Lr as E,
|
|
1927
1927
|
dr as L,
|
|
1928
1928
|
_r as V,
|
|
1929
1929
|
Mr as a,
|
|
1930
|
-
|
|
1930
|
+
Ar as b,
|
|
1931
1931
|
qr as c,
|
|
1932
1932
|
cr as d,
|
|
1933
1933
|
zr as e,
|
|
@@ -1936,5 +1936,5 @@ export {
|
|
|
1936
1936
|
mr as h,
|
|
1937
1937
|
Or as i,
|
|
1938
1938
|
Vr as r,
|
|
1939
|
-
|
|
1939
|
+
Ae as u
|
|
1940
1940
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const L=require("./analyze-result-contract-ege_u6Nl.js");function a(e,i,t){return t?{code:e,message:i,path:t}:{code:e,message:i}}function W(e){for(let i=0;i<e.length;i+=1){const t=e[i];if(e.some((n,o)=>o!==i&&V(n,t)))return!1}return!0}function U(e,i){return L.semaphorFieldRefsMatch(e,i)}function V(e,i){return U(e,i)&&g(e)===g(i)}function ee(e){return`Metric intent has duplicate measure "${e.name}" with the same aggregate (${g(e)}). Use different aggregates to request both, or remove one entry.`}function E(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null}function ie(e,i,t){if(e!==void 0){if(!e||typeof e!="object"||Array.isArray(e)){t.push(a("invalid_sql_default_parameters","SQL defaultParameters must be an object keyed by parameter name.",i));return}Object.entries(e).forEach(([n,o])=>{if(!n.trim()){t.push(a("invalid_sql_default_parameter_name","SQL defaultParameters names must be non-empty strings.",`${i}.${n}`));return}(Array.isArray(o)?o.every(E):E(o))||t.push(a("invalid_sql_default_parameter_value","SQL defaultParameters values must be strings, numbers, booleans, nulls, or arrays of those scalar values.",`${i}.${n}`))})}}function te(e,i){return M(e,i).length===1}function ae(e,i){return M(e,i).length===1}function M(e,i){return i.filter(n=>ne(e,n))}function ne(e,i){return se(e,i)?e.source?U(i,e):!0:!1}function se(e,i){return!(i.name!==e.name||e.role!==void 0&&i.role!==void 0&&i.role!==e.role||oe(e,i)&&g(i)!==g(e))}function oe(e,i){return e.role==="measure"||i.role==="measure"||e.aggregate!==void 0||i.aggregate!==void 0}function g(e){return L.semaphorMetricAggregate(e)}const re=/^(\d{4})-(\d{2})-(\d{2})$/,G=/^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})(?::(\d{2})(?:\.(\d+))?)?(Z|[+-]\d{2}:\d{2})$/;function x(e){if(typeof e!="string")return null;const i=e.trim(),t=re.exec(i);if(t){const[,y,P,T]=t;return N(y,P,T)?new Date(Date.UTC(Number(y),Number(P)-1,Number(T))):null}const n=G.exec(i);if(!n)return null;const[,o,s,r,c,d,p="00",,f]=n;if(!N(o,s,r)||!v(c,0,23)||!v(d,0,59)||!v(p,0,59)||!le(f))return null;const b=new Date(i);return Number.isFinite(b.getTime())?b:null}function de(e){return typeof e!="string"||!G.test(e.trim())?null:x(e)}function N(e,i,t){const n=Number(e),o=Number(i),s=Number(t);if(!Number.isInteger(n)||!Number.isInteger(o)||!Number.isInteger(s)||o<1||o>12)return!1;const r=new Date(Date.UTC(n,o-1,s));return r.getUTCFullYear()===n&&r.getUTCMonth()===o-1&&r.getUTCDate()===s}function v(e,i,t){const n=Number(e);return Number.isInteger(n)&&n>=i&&n<=t}function le(e){if(e==="Z")return!0;const i=/^([+-])(\d{2}):(\d{2})$/.exec(e);return!!(i&&v(i[2],0,23)&&v(i[3],0,59))}function l(e){return typeof e=="string"&&e.trim().length>0}function ue(e){const i=new Set;let t=0;for(;t<e.length;){const n=e[t];if(n==="'"||n==='"'){t=ce(e,t);continue}if(n==="{"){const o=e.indexOf("}",t+1);if(o===-1){t+=1;continue}const s=e.slice(t+1,o);/^[A-Za-z_][A-Za-z0-9_]*$/.test(s)&&i.add(s),t=o+1;continue}t+=1}return Array.from(i)}function ce(e,i){const t=e[i];let n=i+1;for(;n<e.length;){if(e[n]===t){if(e[n+1]===t){n+=2;continue}return n+1}n+=1}return e.length}function u(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function O(e,i,t){if(e!==void 0){if(!u(e)){t.push(a("invalid_pagination","Pagination must be an object with positive integer page and pageSize.",i));return}(!Number.isInteger(e.page)||typeof e.page!="number"||e.page<1)&&t.push(a("invalid_pagination_page","Pagination page must be a positive integer.",`${i}.page`)),(!Number.isInteger(e.pageSize)||typeof e.pageSize!="number"||e.pageSize<1)&&t.push(a("invalid_pagination_page_size","Pagination pageSize must be a positive integer.",`${i}.pageSize`))}}function I(e){const i=new Set;for(const t of e){if(i.has(t))return t;i.add(t)}return null}function $(e,i,t,n){I(e.filter(s=>l(s)))&&n.push(a("duplicate_matrix_public_id",`Matrix ${t} ids must be unique so sort and expansion references are unambiguous.`,i))}const pe=new Set(["SUM","COUNT","AVG","MIN","MAX","MEDIAN","DISTINCT"]);function k(e,i,t){if(!e||typeof e!="object"){t.push(a("missing_source","Analytics intent needs a source.",i));return}if(e.kind==="semantic"){l(e.domainId)||t.push(a("missing_semantic_domain","Semantic source needs a domainId.",`${i}.domainId`)),l(e.datasetName)||t.push(a("missing_dataset_name","Semantic source needs a datasetName.",`${i}.datasetName`));return}if(e.kind==="physical"){l(e.connectionId)||t.push(a("missing_connection_id","Physical source needs a connectionId.",`${i}.connectionId`)),l(e.tableName)||t.push(a("missing_table_name","Physical source needs a tableName.",`${i}.tableName`));return}if(e.kind==="sql"){l(e.connectionId)||t.push(a("missing_connection_id","SQL source needs a connectionId.",`${i}.connectionId`));return}t.push(a("invalid_source_kind","Source kind is not supported.",i))}function m(e,i,t,n={}){if(!e||!u(e)){n.required&&t.push(a("missing_field_ref","Field reference needs a name.",i));return}l(e.name)||t.push(a("missing_field_ref","Field reference needs a name.",`${i}.name`)),e.source!==void 0&&k(e.source,`${i}.source`,t),_(e.aggregate,`${i}.aggregate`,t)}function me(e,i,t){if(!u(e)){t.push(a("invalid_input_binding","Input bindings must be structured objects.",i));return}l(e.inputId)||t.push(a("invalid_input_binding","Input bindings need a non-empty inputId.",`${i}.inputId`)),e.kind!==void 0&&e.kind!=="filter"&&e.kind!=="control"&&t.push(a("invalid_input_binding","Input binding kind must be filter or control.",`${i}.kind`)),e.field!==void 0&&m(e.field,`${i}.field`,t),e.relationshipHint!==void 0&&R(e.relationshipHint,`${i}.relationshipHint`,t)}function R(e,i,t){if(!u(e)){t.push(a("invalid_relationship_hint","Relationship hints must be structured objects.",i));return}e.relationshipIds!==void 0&&(!Array.isArray(e.relationshipIds)||e.relationshipIds.some(n=>!l(n)))&&t.push(a("invalid_relationship_hint","Relationship hint relationshipIds must be non-empty strings.",`${i}.relationshipIds`))}function fe(e,i){if(l(e.inputId)||i.push(a("missing_input_options_input_id","Input options intent needs the inputId it populates.","inputId")),(!e.labelField||!l(e.labelField.name))&&i.push(a("missing_input_options_label_field","Input options intent needs a labelField.","labelField")),m(e.labelField,"labelField",i,{required:!0}),(!e.valueField||!l(e.valueField.name))&&i.push(a("missing_input_options_value_field","Input options intent needs a valueField.","valueField")),m(e.valueField,"valueField",i,{required:!0}),e.searchField!==void 0&&m(e.searchField,"searchField",i,{required:!0}),e.disambiguationFields!==void 0&&(Array.isArray(e.disambiguationFields)?e.disambiguationFields.forEach((t,n)=>{m(t,`disambiguationFields.${n}`,i,{required:!0})}):i.push(a("invalid_input_options_disambiguation_fields","Input options disambiguationFields must be an array of field refs.","disambiguationFields"))),e.dependencies!==void 0){const t=e.dependencies;if(!u(t))i.push(a("invalid_input_options_dependencies","Input options dependencies must be a structured object.","dependencies"));else{const n=t.mode;n!==void 0&&n!=="independent"&&n!=="explicit"&&i.push(a("invalid_input_options_dependencies","Input options dependencies mode must be independent or explicit.","dependencies.mode")),j(t.includeInputIds,"dependencies.includeInputIds",i,"Input options includeInputIds must be non-empty strings."),j(t.excludeInputIds,"dependencies.excludeInputIds",i,"Input options excludeInputIds must be non-empty strings."),ve(e,i)}}if(e.population!==void 0){const t=e.population;if(!u(t))i.push(a("invalid_input_options_population","Input options population must be a structured object.","population"));else{const n=t.kind;n!=="option_source"&&n!=="related_population"&&i.push(a("invalid_input_options_population","Input options population kind must be option_source or related_population.","population.kind")),n==="option_source"&&t.baseSource!==void 0&&i.push(a("invalid_input_options_population","Input options population baseSource is only valid for related_population.","population.baseSource")),n==="option_source"&&t.relationshipHint!==void 0&&i.push(a("invalid_input_options_population","Input options population relationshipHint is only valid for related_population.","population.relationshipHint")),n==="related_population"&&(k(t.baseSource,"population.baseSource",i),t.relationshipHint!==void 0&&R(t.relationshipHint,"population.relationshipHint",i))}}}function _e(e,i){if(!(!("inputs"in e)||e.inputs===void 0)){if(!Array.isArray(e.inputs)){i.push(a("invalid_input_binding","Analytics intent inputs must be an array of input bindings.","inputs"));return}e.inputs.forEach((t,n)=>me(t,`inputs.${n}`,i))}}function ve(e,i){var n,o;const t=new Set(Array.isArray(e.inputs)?e.inputs.map(s=>u(s)?s.inputId:void 0).filter(s=>typeof s=="string"):[]);for(const s of((n=e.dependencies)==null?void 0:n.includeInputIds)||[])t.has(s)||i.push(a("invalid_input_options_dependencies",`Input options dependency "${s}" is not declared in inputs.`,"dependencies.includeInputIds"));for(const s of((o=e.dependencies)==null?void 0:o.excludeInputIds)||[])s!==e.inputId&&!t.has(s)&&i.push(a("invalid_input_options_dependencies",`Input options dependency exclusion "${s}" is not the populated inputId and is not declared in inputs.`,"dependencies.excludeInputIds"))}function j(e,i,t,n){e!==void 0&&(!Array.isArray(e)||e.some(o=>!l(o)))&&t.push(a("invalid_input_options_dependencies",n,i))}function _(e,i,t){e!==void 0&&(typeof e!="string"||!pe.has(e))&&t.push(a("invalid_aggregate","Field aggregate must be SUM, COUNT, AVG, MIN, MAX, MEDIAN, or DISTINCT.",i))}const ge=new Set(["measure","dimension","date","id","unknown"]),be=new Set(["row","aggregate"]),z=new Set(["string","number","boolean","date","datetime","unknown"]),ye=new Set(["number","currency","percent","percentage","scientific","date","datetime","duration","string"]),he=new Set(["millisecond","second","minute","hour","day"]),xe=new Set(["compact","digital","long"]);function D(e,i,t){if(e===void 0)return;if(!u(e)){t.push(a("invalid_value_format","Value format must be a structured object.",i));return}const n=e;(typeof n.type!="string"||!ye.has(n.type))&&t.push(a("invalid_value_format_type","Value format type must be number, currency, percent, scientific, date, datetime, duration, or string.",`${i}.type`)),h(e.minimumFractionDigits,`${i}.minimumFractionDigits`,t),h(e.maximumFractionDigits,`${i}.maximumFractionDigits`,t),h(e.scale,`${i}.scale`,t),h(e.maxUnits,`${i}.maxUnits`,t),e.useGrouping!==void 0&&typeof e.useGrouping!="boolean"&&t.push(a("invalid_value_format_use_grouping","Value format useGrouping must be boolean.",`${i}.useGrouping`)),e.negativeStyle!==void 0&&e.negativeStyle!=="minus"&&e.negativeStyle!=="parentheses"&&t.push(a("invalid_value_format_negative_style","Value format negativeStyle must be minus or parentheses.",`${i}.negativeStyle`)),e.percentValueMode!==void 0&&e.percentValueMode!=="fraction"&&e.percentValueMode!=="whole"&&t.push(a("invalid_value_format_percent_mode","Value format percentValueMode must be fraction or whole.",`${i}.percentValueMode`));for(const o of["inputUnit","largestUnit","smallestUnit"]){const s=e[o];s!==void 0&&(typeof s!="string"||!he.has(s))&&t.push(a("invalid_value_format_duration_unit","Duration format units must be millisecond, second, minute, hour, or day.",`${i}.${o}`))}e.outputStyle!==void 0&&(typeof e.outputStyle!="string"||!xe.has(e.outputStyle))&&t.push(a("invalid_value_format_duration_style","Duration format outputStyle must be compact, digital, or long.",`${i}.outputStyle`))}function h(e,i,t){e!==void 0&&(typeof e!="number"||!Number.isFinite(e))&&t.push(a("invalid_value_format_number","Value format numeric options must be finite numbers.",i))}const we=new Set(["additive","non_additive","ratio_of_sums","weighted","pre_aggregated","snapshot"]),$e=new Set(["default","symmetric_aggregate","aggregate_then_join","weighted"]);function Ie(e,i,t){if(!e||!u(e)){t.push(a("invalid_derived_field_input","Derived field inputs must be structured input references.",i));return}if(e.kind==="field"){m(e.field,`${i}.field`,t,{required:!0}),_(e.aggregate,`${i}.aggregate`,t);return}t.push(a("invalid_derived_field_input","Derived field input kind must be field.",`${i}.kind`))}function B(e,i,t){if(!u(e)){t.push(a("invalid_result_column_ref","Result calculation references must use columnKey or field.",i));return}const n=l(e.columnKey),o=u(e.field);if(n===o){t.push(a("invalid_result_column_ref","Result calculation references must identify exactly one of columnKey or field.",i));return}o&&m(e.field,`${i}.field`,t,{required:!0})}function Ae(e,i,t){if(!u(e)){t.push(a("invalid_result_calculation_output","Result calculation output must be a structured object.",i));return}l(e.key)||t.push(a("invalid_result_calculation_output","Result calculation output needs a stable key.",`${i}.key`)),e.dataType!==void 0&&(typeof e.dataType!="string"||!z.has(e.dataType))&&t.push(a("invalid_result_calculation_output","Result calculation output dataType must be string, number, boolean, date, datetime, or unknown.",`${i}.dataType`)),D(e.format,`${i}.format`,t)}function Se(e,i,t){e!==void 0&&e!=="hour"&&e!=="day"&&e!=="week"&&e!=="month"&&e!=="quarter"&&e!=="year"&&t.push(a("invalid_time_grain","Time grain must be hour, day, week, month, quarter, or year.",i))}function Q(e,i,t,n){e!=="asc"&&e!=="desc"&&t.push(a(n,"Sort direction must be asc or desc.",i))}function Y(e,i,t,n){e!==void 0&&e!=="warehouseDefault"&&e!=="first"&&e!=="last"&&t.push(a(n,"Null ordering must be warehouseDefault, first, or last.",i))}function K(e,i,t,n){e!==void 0&&e!=="global"&&e!=="withinParent"&&t.push(a(n,"Sort scope must be global or withinParent.",i))}function Me(e,i,t){e.enabled!==void 0&&typeof e.enabled!="boolean"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal enabled must be a boolean.",`${i}.enabled`)),e.position!==void 0&&e.position!=="before"&&e.position!=="after"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal position must be before or after.",`${i}.position`)),e.label!==void 0&&typeof e.label!="string"&&t.push(a("invalid_matrix_subtotal","Matrix subtotal label must be a string.",`${i}.label`))}function ke(e,i,t){if(Q(e.direction,`${i}.direction`,t,"invalid_matrix_sort_direction"),Y(e.nulls,`${i}.nulls`,t,"invalid_matrix_sort_nulls"),K(e.scope,`${i}.scope`,t,"invalid_matrix_sort_scope"),!u(e.by)){t.push(a("invalid_matrix_sort_by","Matrix sort by must be a structured object.",`${i}.by`));return}if(e.by.kind!=="label"){if(e.by.kind==="field"){m(e.by.field,`${i}.by.field`,t,{required:!0}),_(e.by.aggregate,`${i}.by.aggregate`,t);return}t.push(a("invalid_matrix_sort_by","Matrix axis sort by must be label or field.",`${i}.by.kind`))}}function q(e,i,t,n){if(!Array.isArray(e))return n.required?t.push(a("missing_matrix_rows","Matrix intent needs at least one row axis level.",i)):e!==void 0&&t.push(a("invalid_matrix_columns","Matrix columns must be an array of axis levels.",i)),[];n.required&&e.length===0&&t.push(a("missing_matrix_rows","Matrix intent needs at least one row axis level.",i));const o=[];return e.forEach((s,r)=>{const c=`${i}.${r}`;if(!u(s)){t.push(a("invalid_matrix_axis_level","Matrix axis levels must be structured objects.",c));return}const d=s;o.push(d),d.id!==void 0&&!l(d.id)&&t.push(a("invalid_matrix_axis_level_id","Matrix axis level id must be a non-empty string.",`${c}.id`)),m(d.field,`${c}.field`,t,{required:!0}),Se(d.grain,`${c}.grain`,t),d.label!==void 0&&typeof d.label!="string"&&t.push(a("invalid_matrix_axis_label","Matrix axis level label must be a string.",`${c}.label`)),d.subtotal!==void 0&&typeof d.subtotal!="boolean"&&(u(d.subtotal)?Me(d.subtotal,`${c}.subtotal`,t):t.push(a("invalid_matrix_subtotal","Matrix subtotal must be a boolean or structured options object.",`${c}.subtotal`))),d.sortBy!==void 0&&(u(d.sortBy)?ke(d.sortBy,`${c}.sortBy`,t):t.push(a("invalid_matrix_sort_by","Matrix axis sortBy must be a structured object.",`${c}.sortBy`)))}),o}function Re(e,i,t){if(!u(e)){t.push(a("invalid_matrix_total_behavior","Matrix total behavior must be a structured object.",i));return}if(e.kind!=="defaultAggregate"&&e.kind!=="blank"&&e.kind!=="labelOnly"&&e.kind!=="customAggregate"&&e.kind!=="percentOfParent"&&e.kind!=="percentOfGrandTotal"&&e.kind!=="customExpression"){t.push(a("invalid_matrix_total_behavior","Matrix total behavior kind is not supported.",`${i}.kind`));return}e.kind==="customAggregate"&&(Object.prototype.hasOwnProperty.call(e,"aggregate")?_(e.aggregate,`${i}.aggregate`,t):t.push(a("invalid_matrix_total_behavior","Custom matrix total behavior needs an aggregate.",`${i}.aggregate`))),e.kind==="customExpression"&&!l(e.expressionId)&&t.push(a("invalid_matrix_total_behavior","Custom matrix total behavior needs an expressionId.",`${i}.expressionId`)),e.kind==="labelOnly"&&e.label!==void 0&&typeof e.label!="string"&&t.push(a("invalid_matrix_total_behavior","Matrix label-only total behavior label must be a string.",`${i}.label`))}function De(e,i,t){if(!Array.isArray(e)||e.length===0)return t.push(a("missing_matrix_values","Matrix intent needs at least one value field.",i)),[];const n=[];return e.forEach((o,s)=>{const r=`${i}.${s}`;if(!u(o)){t.push(a("invalid_matrix_value","Matrix values must be structured objects.",r));return}const c=o;n.push(c),c.id!==void 0&&!l(c.id)&&t.push(a("invalid_matrix_value_id","Matrix value id must be a non-empty string.",`${r}.id`)),m(c.field,`${r}.field`,t,{required:!0}),_(c.aggregate,`${r}.aggregate`,t),D(c.format,`${r}.format`,t),c.label!==void 0&&typeof c.label!="string"&&t.push(a("invalid_matrix_value_label","Matrix value label must be a string.",`${r}.label`)),c.totalBehavior!==void 0&&Re(c.totalBehavior,`${r}.totalBehavior`,t)}),n}function Fe(e,i,t){if(!u(e)){t.push(a("invalid_matrix_totals","Matrix totals must be a structured object.",i));return}for(const n of["rows","columns"]){const o=e[n];o!==void 0&&o!==!0&&o!==!1&&o!=="perLevel"&&t.push(a("invalid_matrix_totals","Matrix total axis setting must be a boolean or perLevel.",`${i}.${n}`))}if(e.grandTotal!==void 0&&typeof e.grandTotal!="boolean")if(!u(e.grandTotal))t.push(a("invalid_matrix_totals","Matrix grandTotal must be a boolean or structured object.",`${i}.grandTotal`));else for(const n of["rows","columns"]){const o=e.grandTotal[n];o!==void 0&&typeof o!="boolean"&&t.push(a("invalid_matrix_totals","Matrix grandTotal rows/columns must be booleans.",`${i}.grandTotal.${n}`))}e.rowPosition!==void 0&&e.rowPosition!=="top"&&e.rowPosition!=="bottom"&&t.push(a("invalid_matrix_totals","Matrix row total position must be top or bottom.",`${i}.rowPosition`)),e.columnPosition!==void 0&&e.columnPosition!=="left"&&e.columnPosition!=="right"&&t.push(a("invalid_matrix_totals","Matrix column total position must be left or right.",`${i}.columnPosition`))}function A(e,i,t,n){if(!Array.isArray(e)){n.push(a("invalid_matrix_path","Matrix member path must be an array of path segments.",i));return}e.forEach((o,s)=>{const r=`${i}.${s}`;if(!u(o)){n.push(a("invalid_matrix_path","Matrix path segment must be a structured object.",r));return}const c=o;if(!l(c.levelId)){n.push(a("stable_id_required","Matrix path segments must reference an explicit public axis level id.",`${r}.levelId`));return}Object.prototype.hasOwnProperty.call(o,"value")||n.push(a("invalid_matrix_path","Matrix path segments must include a value property; use explicit null for null members.",`${r}.value`)),t.has(c.levelId)||n.push(a("stable_id_required","Matrix path segment levelId must match an explicit public axis level id.",`${r}.levelId`))})}function H(e,i,t,n){if(!u(e)){n.push(a("invalid_matrix_expansion","Matrix expansion axis options must be structured objects.",i));return}e.defaultDepth!==void 0&&(typeof e.defaultDepth!="number"||!Number.isInteger(e.defaultDepth)||e.defaultDepth<0)&&n.push(a("invalid_matrix_expansion","Matrix expansion defaultDepth must be a non-negative integer.",`${i}.defaultDepth`)),e.lazy!==void 0&&typeof e.lazy!="boolean"&&n.push(a("invalid_matrix_expansion","Matrix expansion lazy must be a boolean.",`${i}.lazy`)),e.expandedPaths!==void 0&&(Array.isArray(e.expandedPaths)?e.expandedPaths.forEach((o,s)=>{A(o,`${i}.expandedPaths.${s}`,t,n)}):n.push(a("invalid_matrix_expansion","Matrix expandedPaths must be an array of member paths.",`${i}.expandedPaths`)))}function Pe(e,i,t,n){if(e!==void 0){if(!u(e)){n.push(a("invalid_matrix_expansion","Matrix expansion must be a structured object.","expansion"));return}e.rows!==void 0&&H(e.rows,"expansion.rows",i,n),e.columns!==void 0&&H(e.columns,"expansion.columns",t,n)}}function Te(e,i,t,n,o){if(e!==void 0){if(!Array.isArray(e)){o.push(a("invalid_matrix_sort","Matrix sort must be an array of sort rules.","sort"));return}e.forEach((s,r)=>{const c=`sort.${r}`;if(!u(s)){o.push(a("invalid_matrix_sort","Matrix sort rule must be a structured object.",c));return}const d=s;d.axis!=="row"&&d.axis!=="column"&&o.push(a("invalid_matrix_sort","Matrix sort axis must be row or column.",`${c}.axis`));const p=d.axis==="column"?t:i;if(d.targetId!==void 0&&!p.has(d.targetId)&&o.push(a("stable_id_required","Matrix sort targetId must reference an explicit public axis level id.",`${c}.targetId`)),Q(d.direction,`${c}.direction`,o,"invalid_matrix_sort_direction"),Y(d.nulls,`${c}.nulls`,o,"invalid_matrix_sort_nulls"),K(d.scope,`${c}.scope`,o,"invalid_matrix_sort_scope"),!u(d.by)){o.push(a("invalid_matrix_sort_by","Matrix sort by must be a structured object.",`${c}.by`));return}if(d.by.kind!=="label"){if(d.by.kind==="field"){m(d.by.field,`${c}.by.field`,o,{required:!0}),_(d.by.aggregate,`${c}.by.aggregate`,o);return}if(d.by.kind==="value"){(!l(d.by.valueId)||!n.has(d.by.valueId))&&o.push(a("stable_id_required","Matrix value sort must reference an explicit public value id.",`${c}.by.valueId`)),d.by.rowPath!==void 0&&A(d.by.rowPath,`${c}.by.rowPath`,i,o),d.by.columnPath!==void 0&&A(d.by.columnPath,`${c}.by.columnPath`,t,o);return}o.push(a("invalid_matrix_sort_by","Matrix sort by must be label, field, or value.",`${c}.by.kind`))}})}}function Ee(e,i){if(e!==void 0){if(!u(e)){i.push(a("invalid_matrix_layout","Matrix layout must be a structured object.","layout"));return}e.hierarchy!==void 0&&e.hierarchy!=="compact"&&e.hierarchy!=="tabular"&&e.hierarchy!=="outline"&&i.push(a("invalid_matrix_layout","Matrix hierarchy layout must be compact, tabular, or outline.","layout.hierarchy")),e.valuesPlacement!==void 0&&e.valuesPlacement!=="columns"&&e.valuesPlacement!=="rows"&&i.push(a("invalid_matrix_layout","Matrix valuesPlacement must be columns or rows.","layout.valuesPlacement")),e.stickyRowHeaders!==void 0&&typeof e.stickyRowHeaders!="boolean"&&i.push(a("invalid_matrix_layout","Matrix stickyRowHeaders must be a boolean.","layout.stickyRowHeaders")),e.stickyColumnHeaders!==void 0&&typeof e.stickyColumnHeaders!="boolean"&&i.push(a("invalid_matrix_layout","Matrix stickyColumnHeaders must be a boolean.","layout.stickyColumnHeaders"))}}function C(e,i,t){if(!u(e)){t.push(a("invalid_matrix_display_limits","Matrix display limit must be a structured object.",i));return}(typeof e.limit!="number"||!Number.isInteger(e.limit)||e.limit<1)&&t.push(a("invalid_matrix_display_limits","Matrix display limit must be a positive integer.",`${i}.limit`));for(const n of Object.keys(e))n!=="limit"&&t.push(a("invalid_matrix_display_limits",`Matrix display limit ${n} is not supported in v1; use count-only { limit } display limits.`,`${i}.${n}`))}function Ne(e,i){if(e!==void 0){if(!u(e)){i.push(a("invalid_matrix_display_limits","Matrix displayLimits must be a structured object.","displayLimits"));return}e.rows!==void 0&&C(e.rows,"displayLimits.rows",i),e.columns!==void 0&&C(e.columns,"displayLimits.columns",i);for(const t of Object.keys(e))t==="rows"||t==="columns"||i.push(a("invalid_matrix_display_limits",`Matrix displayLimits ${t} is not supported in v1; use rows and columns count limits only.`,`displayLimits.${t}`))}}function Oe(e,i){var d;((d=e.source)==null?void 0:d.kind)==="sql"&&i.push(a("unsupported_matrix_sql_source","Matrix analytics intent does not support raw SQL sources.","source.kind"));const t=q(e.rows,"rows",i,{required:!0}),n=q(e.columns,"columns",i,{required:!1}),o=De(e.values,"values",i);w(e.filters,"filters",i),e.totals!==void 0&&Fe(e.totals,"totals",i),$(t.map(p=>p.id),"rows","row axis level",i),$(n.map(p=>p.id),"columns","column axis level",i),$(o.map(p=>p.id),"values","value",i);const s=new Set(t.map(p=>p.id).filter(p=>l(p))),r=new Set(n.map(p=>p.id).filter(p=>l(p))),c=new Set(o.map(p=>p.id).filter(p=>l(p)));Te(e.sort,s,r,c,i),Pe(e.expansion,s,r,i),Ee(e.layout,i),Ne(e.displayLimits,i)}function je(e,i){if(e.analysis===void 0)return;if(!u(e.analysis)){i.push(a("invalid_measure_analysis","Metric analysis must be a structured object.","analysis"));return}if(e.analysis.kind!=="period_change"){i.push(a("invalid_measure_analysis","Metric analysis kind is not supported.","analysis.kind"));return}e.dateField||i.push(a("missing_analysis_date_field","Period-change analysis needs a dateField.","dateField")),e.timeGrain||i.push(a("missing_analysis_time_grain","Period-change analysis needs a timeGrain.","timeGrain")),e.analysis.orderBy!==void 0&&e.analysis.orderBy!=="absolute_change"&&e.analysis.orderBy!=="positive_change"&&e.analysis.orderBy!=="negative_change"&&e.analysis.orderBy!=="period"&&i.push(a("invalid_measure_analysis","Period-change analysis orderBy must be absolute_change, positive_change, negative_change, or period.","analysis.orderBy"));const{timeWindow:t}=e.analysis;t!==void 0&&S(t,"analysis.timeWindow",i)}function S(e,i,t){if(!u(e)){t.push(a("invalid_time_window","Time window must be a structured object.",i));return}if(e.kind!==void 0&&e.kind!=="relative"&&e.kind!=="absolute"&&t.push(a("invalid_time_window","Time window kind must be relative or absolute.",`${i}.kind`)),e.kind==="absolute"){if(l(e.start)||t.push(a("invalid_time_window","Absolute time window start must be a non-empty ISO date or timestamp string.",`${i}.start`)),l(e.end)||t.push(a("invalid_time_window","Absolute time window end must be a non-empty ISO date or timestamp string.",`${i}.end`)),l(e.start)&&l(e.end)){const n=x(e.start),o=x(e.end);n||t.push(a("invalid_time_window","Absolute time window start must be a valid ISO date or timestamp.",`${i}.start`)),o||t.push(a("invalid_time_window","Absolute time window end must be a valid ISO date or timestamp.",`${i}.end`)),n&&o&&n.getTime()>o.getTime()&&t.push(a("invalid_time_window","Absolute time window start must be before or equal to end.",i))}return}e.unit!=="second"&&e.unit!=="minute"&&e.unit!=="hour"&&e.unit!=="day"&&e.unit!=="week"&&e.unit!=="month"&&e.unit!=="quarter"&&e.unit!=="year"&&t.push(a("invalid_time_window","Time window unit must be second, minute, hour, day, week, month, quarter, or year.",`${i}.unit`)),(typeof e.value!="number"||!Number.isFinite(e.value)||e.value<=0)&&t.push(a("invalid_time_window","Time window value must be a positive number.",`${i}.value`)),e.anchor!==void 0&&e.anchor!=="now"&&e.anchor!=="latest_available"&&t.push(a("invalid_time_window","Time window anchor must be now or latest_available.",`${i}.anchor`)),e.completeness!==void 0&&e.completeness!=="include_partial"&&e.completeness!=="complete_periods"&&t.push(a("invalid_time_window","Time window completeness must be include_partial or complete_periods.",`${i}.completeness`))}function w(e,i,t){if(e!==void 0){if(!Array.isArray(e)){t.push(a("invalid_analytics_filters","Analytics filters must be an array.",i));return}e.forEach((n,o)=>{var d;const s=`${i}.${o}`;if(!u(n)){t.push(a("invalid_analytics_filter","Analytics filter must be a structured object.",s));return}const r=n;m(r.field,`${s}.field`,t,{required:!0}),r.scope!==void 0&&r.scope!=="row"&&r.scope!=="aggregate"&&t.push(a("invalid_analytics_filter_scope","Analytics filter scope must be row or aggregate.",`${s}.scope`)),r.scope==="aggregate"&&((d=r.field)==null?void 0:d.role)!==void 0&&r.field.role!=="measure"&&t.push(a("invalid_analytics_filter_scope","Aggregate-scope analytics filters must target a measure field.",`${s}.scope`));const c=r.operator==="is_null"||r.operator==="is_not_null";if(r.operator!==void 0&&r.operator!=="="&&r.operator!=="!="&&r.operator!=="in"&&r.operator!=="not_in"&&r.operator!=="contains"&&r.operator!=="not_contains"&&r.operator!=="between"&&r.operator!=="not_between"&&r.operator!==">"&&r.operator!==">="&&r.operator!=="<"&&r.operator!=="<="&&r.operator!=="is_null"&&r.operator!=="is_not_null"&&t.push(a("invalid_analytics_filter_operator","Analytics filter operator is not supported.",`${s}.operator`)),r.values===void 0&&!c&&t.push(a("missing_analytics_filter_value","Analytics filter needs values unless it is a null check.",s)),c&&r.values!==void 0){t.push(a("invalid_analytics_filter_values","Null-check analytics filters must not include values.",`${s}.values`));return}if(r.values!==void 0&&!Array.isArray(r.values)){t.push(a("invalid_analytics_filter_values","Analytics filter values must be an array when provided.",`${s}.values`));return}if(r.values!==void 0){const p=r.values.length;if(r.operator==="between"||r.operator==="not_between"){p!==2&&t.push(a("invalid_analytics_filter_values","Between analytics filters must include exactly two values.",`${s}.values`));return}(r.operator==="contains"||r.operator==="not_contains"||r.operator==="="||r.operator==="!="||r.operator===">"||r.operator===">="||r.operator==="<"||r.operator==="<="||r.operator===void 0)&&p!==1&&t.push(a("invalid_analytics_filter_values","Scalar analytics filters must include exactly one value. Use in/not_in for multiple values.",`${s}.values`))}})}}function X(e){const i=[];if(!u(e))return i.push(a("invalid_derived_field","Derived field definition must be a structured object.")),{ok:!1,errors:i,warnings:[]};if(e.kind!=="derived_field"&&i.push(a("invalid_derived_field_kind","Derived field kind must be derived_field.","kind")),l(e.name)||i.push(a("invalid_derived_field_name","Derived field needs a name.","name")),l(e.label)||i.push(a("invalid_derived_field_label","Derived field needs a label.","label")),ge.has(e.resultRole)||i.push(a("invalid_derived_field_role","Derived field resultRole must be measure, dimension, date, id, or unknown.","resultRole")),z.has(e.dataType)||i.push(a("invalid_derived_field_data_type","Derived field dataType must be string, number, boolean, date, datetime, or unknown.","dataType")),be.has(e.computeStage)||i.push(a("invalid_derived_field_compute_stage","Derived field computeStage must be row or aggregate.","computeStage")),e.computeStage==="aggregate"&&e.resultRole!=="measure"&&i.push(a("invalid_derived_field_compute_stage","Aggregate-stage derived fields must have resultRole measure.","computeStage")),e.resultRole!=="measure"&&e.defaultAggregate!==void 0&&i.push(a("invalid_derived_field_aggregate","Only measure derived fields may declare defaultAggregate.","defaultAggregate")),e.computeStage==="row"&&e.resultRole==="measure"&&e.defaultAggregate===void 0&&i.push(a("missing_derived_field_default_aggregate","Row-stage measure derived fields must declare defaultAggregate so row results have explicit rollup semantics.","defaultAggregate")),_(e.defaultAggregate,"defaultAggregate",i),e.aggregationBehavior!==void 0&&!we.has(e.aggregationBehavior)&&i.push(a("invalid_derived_field_aggregation_behavior","Derived field aggregationBehavior is not supported.","aggregationBehavior")),e.aggregationStrategy!==void 0&&!$e.has(e.aggregationStrategy)&&i.push(a("invalid_derived_field_aggregation_strategy","Derived field aggregationStrategy is not supported.","aggregationStrategy")),l(e.expression)||i.push(a("invalid_derived_field_expression","Derived field needs a named-token expression.","expression")),e.expressionLanguage!==void 0&&e.expressionLanguage!=="semaphor_sql_template"&&i.push(a("invalid_derived_field_expression_language","Derived field expressionLanguage must be semaphor_sql_template.","expressionLanguage")),!u(e.inputs)||Object.keys(e.inputs).length===0?i.push(a("invalid_derived_field_inputs","Derived field needs at least one typed input.","inputs")):Object.entries(e.inputs).forEach(([t,n])=>{if(!l(t)){i.push(a("invalid_derived_field_input_name","Derived field input names must be non-empty strings.","inputs"));return}Ie(n,`inputs.${t}`,i)}),l(e.expression)&&u(e.inputs)){const t=ue(e.expression),n=new Set(t),o=Object.keys(e.inputs).filter(s=>l(s));t.forEach(s=>{Object.prototype.hasOwnProperty.call(e.inputs,s)||i.push(a("invalid_derived_field_expression_token",`Derived field expression token "{${s}}" needs a matching inputs.${s} entry.`,"expression"))}),o.forEach(s=>{n.has(s)||i.push(a("unused_derived_field_input",`Derived field input "${s}" is not referenced by expression.`,`inputs.${s}`))})}return D(e.format,"format",i),e.tags!==void 0&&(!Array.isArray(e.tags)||e.tags.some(t=>!l(t)))&&i.push(a("invalid_derived_field_tags","Derived field tags must be non-empty strings.","tags")),{ok:i.length===0,errors:i,warnings:[]}}function Be(e){const i=[];if(!u(e))return i.push(a("invalid_result_calculation","Result calculation must be a structured object.")),{ok:!1,errors:i,warnings:[]};if(l(e.id)||i.push(a("invalid_result_calculation_id","Result calculation needs an id.","id")),l(e.label)||i.push(a("invalid_result_calculation_label","Result calculation needs a label.","label")),e.kind!=="percent_of_total"&&e.kind!=="rank"&&e.kind!=="running_total"&&e.kind!=="previous_row_delta"&&i.push(a("invalid_result_calculation_kind","Result calculation kind must be percent_of_total, rank, running_total, or previous_row_delta.","kind")),B(e.input,"input",i),Ae(e.output,"output",i),e.kind==="percent_of_total"){const t=e.denominator;t!==void 0&&(u(t)?t.scope==="population"?(m(t.metric,"denominator.metric",i,{required:!0}),w(t.filters,"denominator.filters",i)):t.scope!=="returned_result"&&i.push(a("invalid_result_calculation_denominator","Percent-of-total denominator scope must be returned_result or population.","denominator.scope")):i.push(a("invalid_result_calculation_denominator","Percent-of-total denominator must be a structured object.","denominator")))}return e.kind==="rank"&&e.order!==void 0&&e.order!=="asc"&&e.order!=="desc"&&i.push(a("invalid_result_calculation_order","Rank result calculation order must be asc or desc.","order")),(e.kind==="running_total"||e.kind==="previous_row_delta")&&e.orderBy!==void 0&&B(e.orderBy,"orderBy",i),{ok:i.length===0,errors:i,warnings:[]}}function F(e){var n;const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_analytics_intent","Analytics intent must be a structured object.")],warnings:t,repairHints:[{code:"invalid_analytics_intent",recommendedNextStep:"Send one structured analytics intent object with kind, source, and required fields."}]};if(e.version!==void 0&&e.version!==1&&i.push(a("invalid_version","Analytics intent version must be 1.","version")),k(e.source,"source",i),qe(e,i),_e(e,i),"relationshipHint"in e&&e.relationshipHint!==void 0&&R(e.relationshipHint,"relationshipHint",i),e.kind==="metric"){const o=Array.isArray(e.measures)?e.measures.filter(s=>u(s)&&l(s.name)):[];if(!Array.isArray(e.measures)||e.measures.length===0?i.push(a("missing_measure","Metric intent needs at least one measure.","measures")):e.measures.some(s=>!u(s)||!l(s.name))&&i.push(a("invalid_measure_list","Metric intent measures must be an array of field references with names.","measures")),o.forEach((s,r)=>{m(s,`measures.${r}`,i,{required:!0})}),o.length>0&&!W(o)){const s=o.find((r,c)=>o.some((d,p)=>p!==c&&V(d,r)));s&&i.push(a("duplicate_measure",ee(s),"measures"))}if(u(e.primaryMeasure)&&l(e.primaryMeasure.name)&&M(e.primaryMeasure,o).length>1&&i.push(a("ambiguous_primary_measure","Metric intent primaryMeasure must identify exactly one selected measure.","primaryMeasure")),e.primaryMeasure!==void 0&&(m(e.primaryMeasure,"primaryMeasure",i,{required:!0}),u(e.primaryMeasure)&&l(e.primaryMeasure.name)&&o.length>0&&!te(e.primaryMeasure,o)&&i.push(a("invalid_primary_measure","Metric intent primaryMeasure must match one measure field reference.","primaryMeasure"))),e.dimensions!==void 0&&!Array.isArray(e.dimensions)?i.push(a("invalid_measure_dimensions","Metric intent dimensions must be an array of field references.","dimensions")):Array.isArray(e.dimensions)&&e.dimensions.some(s=>!u(s)||!l(s.name))&&i.push(a("invalid_measure_dimensions","Metric intent dimensions must be an array of field references with names.","dimensions")),e.dateField!==void 0&&m(e.dateField,"dateField",i),e.timeWindow!==void 0&&(S(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Metric timeWindow needs a dateField.","dateField"))),w(e.filters,"filters",i),Array.isArray(e.dimensions)&&e.dimensions.forEach((s,r)=>{m(s,`dimensions.${r}`,i)}),e.orderBy!==void 0){if(!u(e.orderBy))i.push(a("invalid_measure_order_by","Metric intent orderBy must be a structured object.","orderBy"));else if(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_measure_order_direction","Metric intent orderBy direction must be asc or desc.","orderBy.direction")),u(e.orderBy.field)&&l(e.orderBy.field.name)){const s=[...o,...e.timeGrain&&e.dateField&&u(e.dateField)?[e.dateField]:[],...Array.isArray(e.dimensions)?e.dimensions.filter(r=>u(r)&&l(r.name)):[]];s.length>0&&!ae(e.orderBy.field,s)&&i.push(a("invalid_measure_order_by","Metric intent orderBy.field must match one selected measure, grouped dateField, or dimension.","orderBy.field"))}}je(e,i)}else if(e.kind==="records"){if(!Array.isArray(e.fields)||e.fields.length===0?i.push(a("missing_record_fields","Records intent needs at least one field.","fields")):e.fields.some(o=>!u(o)||!l(o.name))&&i.push(a("invalid_record_fields","Records intent fields must be field references with names.","fields")),Array.isArray(e.fields)&&e.fields.forEach((o,s)=>{m(o,`fields.${s}`,i)}),e.dateField!==void 0&&m(e.dateField,"dateField",i),O(e.pagination,"pagination",i),e.timeWindow!==void 0&&(S(e.timeWindow,"timeWindow",i),e.dateField||i.push(a("missing_time_window_date_field","Records timeWindow needs a dateField.","dateField"))),w(e.filters,"filters",i),Array.isArray(e.filters)&&e.filters.forEach((o,s)=>{u(o)&&o.scope==="aggregate"&&i.push(a("unsupported_record_filter_scope","Records intents support row-scope filters only. Use a metric intent for aggregate-scope filters.",`filters.${s}.scope`))}),e.orderBy!==void 0&&(u(e.orderBy)?(m(e.orderBy.field,"orderBy.field",i,{required:!0}),e.orderBy.direction!=="asc"&&e.orderBy.direction!=="desc"&&i.push(a("invalid_record_order_direction","Records intent orderBy direction must be asc or desc.","orderBy.direction"))):i.push(a("invalid_record_order_by","Records intent orderBy must be a structured object.","orderBy"))),e.totals!==void 0)if(!u(e.totals))i.push(a("invalid_records_totals","Records totals must be a structured server totals request.","totals"));else{e.totals.mode!=="server"&&i.push(a("invalid_records_totals","Records totals mode must be server.","totals.mode"));const o=e.totals.measures;!Array.isArray(o)||o.length===0?i.push(a("missing_records_totals_measures","Records server totals need at least one measure.","totals.measures")):o.forEach((s,r)=>{m(s,`totals.measures.${r}`,i,{required:!0}),(!u(s)||s.role!=="measure")&&i.push(a("invalid_records_totals_measure","Records server totals measures must be measure field references.",`totals.measures.${r}.role`))})}}else e.kind==="inputOptions"?fe(e,i):e.kind==="matrix"?Oe(e,i):e.kind==="sql"?(((n=e.source)==null?void 0:n.kind)!=="sql"&&i.push(a("invalid_sql_source","SQL analytics intent must use a SQL execution source.","source")),l(e.sql)||i.push(a("missing_sql","SQL analytics intent needs SQL text.","sql")),ie(e.defaultParameters,"defaultParameters",i),Array.isArray(e.fields)&&e.fields.forEach((o,s)=>{m(o,`fields.${s}`,i)}),O(e.pagination,"pagination",i)):i.push(a("invalid_analytics_kind","Analytics kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:Ce(i)}}function qe(e,i){if(!(!("derivedFields"in e)||e.derivedFields===void 0)){if(!Array.isArray(e.derivedFields)){i.push(a("invalid_derived_fields","Analytics intent derivedFields must be an array of derived field definitions.","derivedFields"));return}e.derivedFields.forEach((t,n)=>{X(t).errors.forEach(s=>{i.push({...s,path:s.path?`derivedFields.${n}.${s.path}`:`derivedFields.${n}`})})})}}function Z(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_operation_intent","Operation intent must be a structured object.")],warnings:t,repairHints:[{code:"invalid_operation_intent",recommendedNextStep:"Send one typed operation intent with version, kind, and required operation fields."}]};if(e.version!==1&&i.push(a("invalid_version","Operation intent version must be 1.","version")),e.kind==="answer_obligations")!Array.isArray(e.obligations)||e.obligations.length===0?i.push(a("missing_obligations","Answer-obligations operation intent needs at least one obligation.","obligations")):e.obligations.forEach((n,o)=>{l(n.id)||i.push(a("missing_obligation_id","Each analytics obligation needs an id.",`obligations.${o}.id`)),l(n.prompt)||i.push(a("missing_obligation_prompt","Each analytics obligation needs a prompt.",`obligations.${o}.prompt`))});else if(e.kind==="dashboard_change"||e.kind==="data_app_change"){if(l(e.instruction)||i.push(a("missing_instruction","Change operation intent needs an instruction.","instruction")),e.analyticsIntent){const n=F(e.analyticsIntent);i.push(...n.errors),t.push(...n.warnings)}}else i.push(a("invalid_operation_kind","Operation intent kind is not supported.","kind"));return{ok:i.length===0,errors:i,warnings:t,repairHints:J(i)}}function He(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_recovery_plan","Analytics recovery plan must be a structured object.")],warnings:t,repairHints:[{code:"invalid_recovery_plan",recommendedNextStep:"Return a typed recovery plan with operationIntent and plannedToolCalls."}]};e.version!==1&&i.push(a("invalid_version","Recovery plan version must be 1.","version")),e.kind!=="analytics_recovery_plan"&&i.push(a("invalid_recovery_plan_kind","Recovery plan kind must be analytics_recovery_plan.","kind"));const n=Z(e.operationIntent);return i.push(...n.errors),t.push(...n.warnings),Array.isArray(e.plannedToolCalls)||i.push(a("invalid_planned_tool_calls","Recovery plan plannedToolCalls must be an array.","plannedToolCalls")),{ok:i.length===0,errors:i,warnings:t,repairHints:J(i)}}function J(e){return e.map(i=>({code:i.code,recommendedNextStep:i.code==="missing_obligations"?"Normalize the user request into one or more typed analytics obligations before recovery planning.":"Correct the operation/recovery contract shape before planning execution."}))}function Ce(e){return e.map(i=>{switch(i.code){case"missing_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Provide a semantic, physical, or SQL source before executing analytics."};case"missing_measure":return{code:i.code,fieldRole:"measure",recommendedNextStep:"Choose one exact measure from the grounded schema candidates."};case"missing_record_fields":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide at least one field for the records intent."};case"missing_matrix_rows":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Choose at least one row axis level for the matrix table."};case"missing_matrix_values":return{code:i.code,fieldRole:"measure",recommendedNextStep:"Choose at least one value field for the matrix table."};case"unsupported_matrix_sql_source":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use a semantic or explorer-backed source for matrix tables; raw SQL matrix tables are not supported."};case"missing_input_options_input_id":return{code:i.code,fieldRole:"input",recommendedNextStep:"Provide the inputId that these option values populate."};case"missing_input_options_label_field":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide the human-readable field used as option labels."};case"missing_input_options_value_field":return{code:i.code,fieldRole:"dimension",recommendedNextStep:"Provide the stable field used as option values."};case"missing_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Provide bounded read-only SQL with an explicit outer LIMIT."};case"conflicting_sql":return{code:i.code,fieldRole:"sql",recommendedNextStep:"Use one canonical SQL text location for the intent; prefer top-level sql."};case"missing_semantic_domain":case"missing_dataset_name":case"missing_connection_id":case"missing_table_name":return{code:i.code,fieldRole:"source",recommendedNextStep:"Use grounded catalog metadata to fill the missing source reference."};default:return}}).filter(i=>!!i)}function Le(e,i,t,n){if(!e||typeof e!="object"){t.push(a("invalid_view","Dashboard view must be an object.",i));return}if(l(e.title)||t.push(a("missing_view_title","Dashboard view needs a title.",i)),!e.presentation||typeof e.presentation!="object"){t.push(a("missing_presentation","Dashboard view needs a presentation.",`${i}.presentation`));return}if(e.presentation.kind==="text"){l(e.text)||n.push(a("missing_text_content","Text views should include text content.",`${i}.text`));return}if(!e.analytics){t.push(a("missing_view_analytics","Non-text dashboard views need analytics intent.",`${i}.analytics`));return}e.presentation.kind==="matrixTable"&&e.analytics.kind!=="matrix"&&t.push(a("invalid_matrix_view_analytics","Matrix table views need matrix analytics intent.",`${i}.analytics.kind`));const o=F(e.analytics);for(const s of o.errors)t.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`));for(const s of o.warnings)n.push(a(s.code,s.message,`${i}.analytics${s.path?`.${s.path}`:""}`))}function Ue(e){const i=[],t=[];if(!e||typeof e!="object")return{ok:!1,errors:[a("invalid_dashboard_intent","Dashboard intent must be a structured object.")],warnings:t};e.version!==1&&i.push(a("invalid_version","Dashboard intent version must be 1.")),e.kind!=="dashboard"&&i.push(a("invalid_kind","Experience intent kind must be dashboard.")),l(e.title)||i.push(a("missing_title","Dashboard intent needs a title.","title"));const n=Array.isArray(e.inputs)?e.inputs:[],o=I(n.filter(u).map(d=>d.id).filter(d=>typeof d=="string"));o&&i.push(a("duplicate_input_id",`Duplicate input id: ${o}.`,"inputs"));for(const[d,p]of n.entries()){const f=`inputs.${d}`;if(!u(p)){i.push(a("invalid_input","Dashboard input must be an object.",f));continue}l(p.id)||i.push(a("missing_input_id","Input needs an id.",`${f}.id`)),l(p.label)||i.push(a("missing_input_label","Input needs a label.",`${f}.label`)),!p.field||!l(p.field.name)?i.push(a("missing_input_field","Input needs a field.",`${f}.field`)):m(p.field,`${f}.field`,i)}const s=Array.isArray(e.sections)?e.sections:[];s.length===0&&i.push(a("missing_sections","Dashboard intent needs at least one section.","sections"));const r=s.flatMap(d=>d&&typeof d=="object"&&Array.isArray(d.views)?d.views.filter(u).map(p=>p.id).filter(p=>!!p):[]),c=I(r);c&&i.push(a("duplicate_view_id",`Duplicate dashboard view id: ${c}.`,"sections"));for(const[d,p]of s.entries()){const f=`sections.${d}`;if(!p||typeof p!="object"){i.push(a("invalid_section","Dashboard section must be an object.",f));continue}if(l(p.title)||i.push(a("missing_section_title","Dashboard section needs a title.",f)),!Array.isArray(p.views)||p.views.length===0){i.push(a("missing_section_views","Dashboard section needs at least one view.",`${f}.views`));continue}for(const[b,y]of p.views.entries())Le(y,`${f}.views.${b}`,i,t)}return{ok:i.length===0,errors:i,warnings:t}}exports.parseSemaphorIsoInstant=de;exports.parseSemaphorIsoTimeWindowBoundary=x;exports.validateSemaphorAnalyticsIntent=F;exports.validateSemaphorAnalyticsRecoveryPlan=He;exports.validateSemaphorDashboardIntent=Ue;exports.validateSemaphorDerivedFieldDefinition=X;exports.validateSemaphorOperationIntent=Z;exports.validateSemaphorResultCalculation=Be;
|