react-semaphor 0.1.472 → 0.1.474
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 +102 -94
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +4 -4
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{analyze-result-contract-B3agc2XU.js → analyze-result-contract-C8s8EUL5.js} +1 -1
- package/dist/chunks/{common-types-g_1fKJLK.js → common-types-BLPy5_E0.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-Lw4gjW_M.js → dashboard-briefing-launcher-B0f28WrK.js} +9 -9
- package/dist/chunks/{dashboard-briefing-launcher-8vxGyexK.cjs → dashboard-briefing-launcher-BjCkA5vw.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-BKR8g3M9.cjs → dashboard-controls-BRclCQEX.cjs} +1 -1
- package/dist/chunks/{dashboard-controls-CRgDlxdt.js → dashboard-controls-CMJqSLgo.js} +9 -9
- package/dist/chunks/{dashboard-filter-value-compatibility-ilbH2A31.js → dashboard-filter-value-compatibility-9W8Ckcle.js} +168 -158
- package/dist/chunks/dashboard-filter-value-compatibility-Co1dn9Bc.cjs +1 -0
- package/dist/chunks/{dashboard-input-contract-Vr_3ApfF.js → dashboard-input-contract-BrGdGFz0.js} +6 -6
- package/dist/chunks/{dashboard-json-BhhVg9mI.js → dashboard-json-1ohpjO_q.js} +7 -7
- package/dist/chunks/{dashboard-json-CUgAzrYq.cjs → dashboard-json-DmtGHdDq.cjs} +1 -1
- package/dist/chunks/{edit-dashboard-visual-DlQtYQOO.js → edit-dashboard-visual-D9oKtOo6.js} +12 -12
- package/dist/chunks/{edit-dashboard-visual-BxmanBVo.cjs → edit-dashboard-visual-DNqJHdHE.cjs} +1 -1
- package/dist/chunks/{editor-action-buttons-CRWacpxi.js → editor-action-buttons-C_B8Wzkf.js} +6 -6
- package/dist/chunks/{editor-action-buttons-DKcD0UQy.cjs → editor-action-buttons-DwI3FcSw.cjs} +1 -1
- package/dist/chunks/{index-xdqe-Zvd.cjs → index-B6zSYUN4.cjs} +167 -167
- package/dist/chunks/{index-0fmECZL2.js → index-DalKzjEZ.js} +31914 -31864
- package/dist/chunks/{index-oVXvCLH-.js → index-DsvIlrI-.js} +9 -9
- package/dist/chunks/matrix-result-contract-Bhg60NtS.cjs +1 -0
- package/dist/chunks/matrix-result-contract-BpzhImar.js +421 -0
- package/dist/chunks/{pivot-header-presentation-7XrwJYDm.js → pivot-header-presentation-Be3FyR0N.js} +2 -2
- package/dist/chunks/{pivot-result-identity-5v4hRVbc.js → pivot-result-identity-CIZXsI53.js} +1 -1
- package/dist/chunks/{pivot-result-lifecycle-O_roVguV.js → pivot-result-lifecycle-PxmbJWkm.js} +19 -19
- package/dist/chunks/{raw-temporal-contract-BEMf3avg.js → raw-temporal-contract-U8J9RlEH.js} +1 -1
- package/dist/chunks/{report-preferences-dialog-Dxt9XMpd.js → report-preferences-dialog-C9mJffNQ.js} +6 -6
- package/dist/chunks/{report-preferences-dialog-8KYKazoG.cjs → report-preferences-dialog-DGMd-eTT.cjs} +1 -1
- package/dist/chunks/{report-runtime-context-DnNbpkGo.js → report-runtime-context-DNbgCsko.js} +7 -7
- package/dist/chunks/{saved-temporal-bucket-format-CygnBDO2.js → saved-temporal-bucket-format-CHsXUPJI.js} +8 -8
- package/dist/chunks/source-entity-resolution-BDC-Qngk.cjs +1 -0
- package/dist/chunks/source-entity-resolution-ugN3sZUk.js +781 -0
- package/dist/chunks/{switch-CQN9Hzho.cjs → switch-B4eH4guz.cjs} +13 -13
- package/dist/chunks/{switch-n2yUNY8i.js → switch-D20CIzj6.js} +1460 -1455
- package/dist/chunks/{temporal-bucket-CUKJktCl.js → temporal-bucket-CtP7hKLa.js} +12 -12
- package/dist/chunks/{temporal-bucket-authoring-CZoJV2L6.js → temporal-bucket-authoring-DJ9kK2wD.js} +3 -3
- package/dist/chunks/{temporal-bucket-contract-Cno9TlYr.js → temporal-bucket-contract-CZl5D7FZ.js} +1 -1
- package/dist/chunks/{token-types-W3EHNW-D.js → token-types-DfDtCqlw.js} +1 -1
- package/dist/chunks/{update-policy-kRNJwwUV.js → update-policy-BybMiM61.js} +1 -1
- package/dist/chunks/{validators-B5t1s8oh.js → validators-D-T-2HOR.js} +50 -50
- package/dist/dashboard/index.cjs +1 -1
- package/dist/dashboard/index.js +2 -2
- package/dist/dashboard-authoring/index.cjs +3 -3
- package/dist/dashboard-authoring/index.js +355 -341
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- package/dist/data-app-codegen/index.js +2 -2
- package/dist/data-app-codegen-node/index.js +3 -3
- package/dist/data-app-sdk/index.js +3 -3
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.js +9 -9
- package/dist/format-utils/index.js +10 -10
- package/dist/index.cjs +1 -1
- package/dist/index.js +14 -14
- package/dist/report-runtime-context/index.js +2 -2
- package/dist/surfboard/index.cjs +1 -1
- package/dist/surfboard/index.js +3 -3
- package/dist/types/analytics-protocol.d.ts +141 -0
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +7 -0
- package/package.json +1 -1
- package/dist/chunks/dashboard-filter-value-compatibility-Dmh-NaPK.cjs +0 -1
- package/dist/chunks/matrix-result-contract-DoU9diAh.js +0 -822
- package/dist/chunks/matrix-result-contract-SrzyG_KQ.cjs +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var j = Object.defineProperty;
|
|
2
2
|
var Y = (e, r, t) => r in e ? j(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t;
|
|
3
3
|
var T = (e, r, t) => Y(e, typeof r != "symbol" ? r + "" : r, t);
|
|
4
|
-
import {
|
|
4
|
+
import { h as L, ao as O, an as R, am as U } from "./validators-D-T-2HOR.js";
|
|
5
5
|
import { canonicalizeSupportedLocale as I } from "../value-format-preferences/index.js";
|
|
6
6
|
const q = "higher_is_better", fe = {
|
|
7
7
|
displayMode: "difference",
|
|
@@ -26,7 +26,7 @@ function pe(e) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
|
-
function
|
|
29
|
+
function be(e) {
|
|
30
30
|
if (e.alias) return e.alias;
|
|
31
31
|
const r = e.entityName && e.entityName !== "SEMAPHOR_CALCULATED_FIELD" ? e.entityName : void 0, t = r && r !== e.name ? `${r}_` : "";
|
|
32
32
|
if (e.role !== "metric") return `${t}${e.name}`;
|
|
@@ -117,7 +117,7 @@ function P(e, r = "comparison") {
|
|
|
117
117
|
warnings: []
|
|
118
118
|
};
|
|
119
119
|
}
|
|
120
|
-
function
|
|
120
|
+
function ge(e, r = "comparison") {
|
|
121
121
|
if (!d(e))
|
|
122
122
|
return {
|
|
123
123
|
ok: !1,
|
|
@@ -376,7 +376,7 @@ function we(e) {
|
|
|
376
376
|
sentiment: H(c, o)
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
|
-
function
|
|
379
|
+
function g(e) {
|
|
380
380
|
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
381
381
|
return !1;
|
|
382
382
|
const r = Object.getPrototypeOf(e);
|
|
@@ -489,7 +489,7 @@ function re(e, r) {
|
|
|
489
489
|
);
|
|
490
490
|
}
|
|
491
491
|
function te(e) {
|
|
492
|
-
if (!
|
|
492
|
+
if (!g(e))
|
|
493
493
|
return {
|
|
494
494
|
ok: !1,
|
|
495
495
|
issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
|
|
@@ -499,7 +499,7 @@ function te(e) {
|
|
|
499
499
|
t.has(s) || r.push({ path: s, message: `Unknown property "${s}".` });
|
|
500
500
|
e.type !== "temporal_bucket" && r.push({ path: "type", message: "Expected temporal_bucket." });
|
|
501
501
|
const o = e.presentation;
|
|
502
|
-
if (!
|
|
502
|
+
if (!g(o))
|
|
503
503
|
r.push({ path: "presentation", message: "Expected a presentation object." });
|
|
504
504
|
else {
|
|
505
505
|
const s = o.mode, l = s === "preset" ? /* @__PURE__ */ new Set(["mode", "preset"]) : s === "pattern" ? /* @__PURE__ */ new Set(["mode", "pattern"]) : s === "auto" ? /* @__PURE__ */ new Set(["mode", "styles"]) : /* @__PURE__ */ new Set(["mode"]);
|
|
@@ -522,7 +522,7 @@ function te(e) {
|
|
|
522
522
|
}
|
|
523
523
|
else if (s === "auto") {
|
|
524
524
|
const c = o.styles;
|
|
525
|
-
(!
|
|
525
|
+
(!g(c) || !["short", "medium", "long"].includes(String(c.dateStyle)) || !g(c.dateTime) || !["short", "medium", "long"].includes(
|
|
526
526
|
String(c.dateTime.dateStyle)
|
|
527
527
|
) || !["short", "medium", "long"].includes(
|
|
528
528
|
String(c.dateTime.timeStyle)
|
|
@@ -538,7 +538,7 @@ function te(e) {
|
|
|
538
538
|
r.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
|
|
539
539
|
}
|
|
540
540
|
const n = I(e.locale);
|
|
541
|
-
if (n || r.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), r.length > 0 || !n || !
|
|
541
|
+
if (n || r.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), r.length > 0 || !n || !g(o))
|
|
542
542
|
return { ok: !1, issues: r };
|
|
543
543
|
if (o.mode === "auto") {
|
|
544
544
|
const s = o.styles;
|
|
@@ -691,7 +691,7 @@ function ie(e, r, t) {
|
|
|
691
691
|
if (l >= 0 && c >= 0 && u) {
|
|
692
692
|
const f = Math.min(l, c), x = Math.max(l, c);
|
|
693
693
|
let C = !1;
|
|
694
|
-
return s.slice(f, x + 1).filter((
|
|
694
|
+
return s.slice(f, x + 1).filter((b) => b.type === "day" ? (C = !0, !1) : C && b.type === "literal" ? (C = !1, !1) : !0).map((b) => b.type === "year" ? u : b.value).join("");
|
|
695
695
|
}
|
|
696
696
|
}
|
|
697
697
|
return y(r, {
|
|
@@ -792,8 +792,8 @@ export {
|
|
|
792
792
|
fe as C,
|
|
793
793
|
q as D,
|
|
794
794
|
_ as T,
|
|
795
|
-
|
|
796
|
-
|
|
795
|
+
be as a,
|
|
796
|
+
ge as b,
|
|
797
797
|
V as c,
|
|
798
798
|
ye as d,
|
|
799
799
|
_e as e,
|
|
@@ -803,7 +803,7 @@ export {
|
|
|
803
803
|
J as i,
|
|
804
804
|
te as j,
|
|
805
805
|
Ce as k,
|
|
806
|
-
|
|
806
|
+
g as l,
|
|
807
807
|
re as p,
|
|
808
808
|
pe as r,
|
|
809
809
|
P as v
|
package/dist/chunks/{temporal-bucket-authoring-CZoJV2L6.js → temporal-bucket-authoring-DJ9kK2wD.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { am as O, an as N } from "./validators-
|
|
2
|
-
import "./analyze-result-contract-
|
|
3
|
-
import { f as R, C as j, h as x } from "./temporal-bucket-
|
|
1
|
+
import { am as O, an as N } from "./validators-D-T-2HOR.js";
|
|
2
|
+
import "./analyze-result-contract-C8s8EUL5.js";
|
|
3
|
+
import { f as R, C as j, h as x } from "./temporal-bucket-CtP7hKLa.js";
|
|
4
4
|
import { DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as B } from "../value-format-preferences/index.js";
|
|
5
5
|
const M = /* @__PURE__ */ new Set([
|
|
6
6
|
"previous_period",
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { S as W, a as X, v as Z } from "./validators-
|
|
1
|
+
import { S as W, a as X, v as Z } from "./validators-D-T-2HOR.js";
|
|
2
2
|
import { toSemaphorInputOptionsIntent as ee, toSemaphorAnalysisQueryOptions as te, toSemaphorAnalysisIntent as re, toSemaphorMetricIntent as ne, toSemaphorRecordsIntent as ae, toSemaphorMatrixIntent as se, toSemaphorSqlIntent as ie } from "../data-app-sdk-adapters/index.js";
|
|
3
3
|
const Je = W, x = X, G = "semaphor-generated-data-app-contract/v1", T = "semaphor-generated-data-app-contract-manifest/v1";
|
|
4
4
|
function P(e) {
|
|
@@ -5030,42 +5030,42 @@ function Zn(e) {
|
|
|
5030
5030
|
return { ok: i.length === 0, errors: i, warnings: t };
|
|
5031
5031
|
}
|
|
5032
5032
|
export {
|
|
5033
|
-
|
|
5034
|
-
|
|
5035
|
-
|
|
5036
|
-
|
|
5037
|
-
|
|
5038
|
-
|
|
5039
|
-
|
|
5040
|
-
|
|
5041
|
-
|
|
5042
|
-
|
|
5043
|
-
|
|
5044
|
-
|
|
5045
|
-
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
|
|
5049
|
-
|
|
5050
|
-
|
|
5033
|
+
Pn as $,
|
|
5034
|
+
Qn as A,
|
|
5035
|
+
Zn as B,
|
|
5036
|
+
Se as C,
|
|
5037
|
+
ka as D,
|
|
5038
|
+
Ia as E,
|
|
5039
|
+
we as F,
|
|
5040
|
+
Ta as G,
|
|
5041
|
+
pi as H,
|
|
5042
|
+
mi as I,
|
|
5043
|
+
De as J,
|
|
5044
|
+
gi as K,
|
|
5045
|
+
Ln as L,
|
|
5046
|
+
Hn as M,
|
|
5047
|
+
jt as N,
|
|
5048
|
+
le as O,
|
|
5049
|
+
Dt as P,
|
|
5050
|
+
ai as Q,
|
|
5051
5051
|
Tn as R,
|
|
5052
5052
|
oe as S,
|
|
5053
5053
|
jn as T,
|
|
5054
|
-
|
|
5055
|
-
|
|
5056
|
-
|
|
5057
|
-
|
|
5058
|
-
|
|
5059
|
-
|
|
5060
|
-
|
|
5054
|
+
qt as U,
|
|
5055
|
+
Ot as V,
|
|
5056
|
+
N as W,
|
|
5057
|
+
T as X,
|
|
5058
|
+
ni as Y,
|
|
5059
|
+
ve as Z,
|
|
5060
|
+
O as _,
|
|
5061
5061
|
qn as a,
|
|
5062
|
-
|
|
5063
|
-
|
|
5064
|
-
|
|
5065
|
-
|
|
5066
|
-
|
|
5067
|
-
|
|
5068
|
-
|
|
5062
|
+
Bn as a0,
|
|
5063
|
+
ue as a1,
|
|
5064
|
+
oi as a2,
|
|
5065
|
+
Gt as a3,
|
|
5066
|
+
zt as a4,
|
|
5067
|
+
Yt as a5,
|
|
5068
|
+
Qt as a6,
|
|
5069
5069
|
ga as a7,
|
|
5070
5070
|
ha as a8,
|
|
5071
5071
|
ri as a9,
|
|
@@ -5088,27 +5088,27 @@ export {
|
|
|
5088
5088
|
Gn as aq,
|
|
5089
5089
|
Ei as b,
|
|
5090
5090
|
be as c,
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
|
|
5091
|
+
fa as d,
|
|
5092
|
+
ji as e,
|
|
5093
|
+
Ci as f,
|
|
5094
|
+
Kn as g,
|
|
5095
|
+
zn as h,
|
|
5096
5096
|
On as i,
|
|
5097
|
-
|
|
5098
|
-
|
|
5099
|
-
|
|
5100
|
-
|
|
5101
|
-
|
|
5102
|
-
|
|
5097
|
+
Fn as j,
|
|
5098
|
+
se as k,
|
|
5099
|
+
B as l,
|
|
5100
|
+
Ri as m,
|
|
5101
|
+
he as n,
|
|
5102
|
+
Mi as o,
|
|
5103
5103
|
Nn as p,
|
|
5104
|
-
|
|
5105
|
-
|
|
5104
|
+
Ti as q,
|
|
5105
|
+
En as r,
|
|
5106
5106
|
Di as s,
|
|
5107
5107
|
de as t,
|
|
5108
|
-
|
|
5108
|
+
pe as u,
|
|
5109
5109
|
Ye as v,
|
|
5110
|
-
|
|
5111
|
-
|
|
5112
|
-
|
|
5113
|
-
|
|
5110
|
+
kn as w,
|
|
5111
|
+
Yn as x,
|
|
5112
|
+
xi as y,
|
|
5113
|
+
xn as z
|
|
5114
5114
|
};
|
package/dist/dashboard/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("../chunks/index-B6zSYUN4.cjs"),e=require("../chunks/common-types-C1IM7gao.cjs");exports.Dashboard=o.Dashboard;exports.CONTROL_CARD_DEFAULT_VALUE=e.CONTROL_CARD_DEFAULT_VALUE;exports.EMPTY_SELECTION=e.EMPTY_SELECTION;
|
package/dist/dashboard/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { D as o } from "../chunks/index-
|
|
2
|
-
import { C as s, E as C } from "../chunks/common-types-
|
|
1
|
+
import { D as o } from "../chunks/index-DalKzjEZ.js";
|
|
2
|
+
import { C as s, E as C } from "../chunks/common-types-BLPy5_E0.js";
|
|
3
3
|
export {
|
|
4
4
|
s as CONTROL_CARD_DEFAULT_VALUE,
|
|
5
5
|
o as Dashboard,
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../chunks/contracts-CtB2VONT.cjs"),A=require("../chunks/temporal-bucket-authoring-DSpzgXHc.cjs"),w=require("../chunks/validators-DcshgK7w.cjs");require("../chunks/analyze-result-contract-OgPk-zGu.cjs");require("../value-format-preferences/index.cjs");const Te=require("../chunks/operators-DrTQsJXv.cjs"),X=require("../chunks/canonical-result-keys-Cb96edol.cjs"),m=require("../chunks/dashboard-filter-value-compatibility-Dmh-NaPK.cjs");function S(e){return e&&typeof e=="object"?e:null}function T(e){return typeof e=="string"?e:null}function de(e){var t,r,a;return!!(e&&typeof e=="object")&&(((t=S(e))==null?void 0:t.kind)==="semantic"||((r=S(e))==null?void 0:r.kind)==="physical"||((a=S(e))==null?void 0:a.kind)==="sql")}function M(e){return de(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function Fe(e){return w.semaphorSourceIdentityKey(e)}function Y(e,t){return w.semaphorSourcesReferToSameDataset(e,t)}function ce(e,t){return w.preferSemaphorSourceMetadata(e,t)}function B(e){const t=[];for(const r of e){const a=t.findIndex(o=>Y(o,r));a===-1?t.push(r):t[a]=ce(t[a],r)}return t}function ke(e){return B(e)[0]}function K(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!w.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function U(e){return M(e)?e:void 0}function oe(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&w.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function v(e,t){const r=U(e==null?void 0:e.source);return r?K(r,t):void 0}function le({explicitSource:e,field:t,defaultSource:r,fallbackSources:a}){const o=[r,...a||[]],n=U(e),i=n?K(n,oe(n,o)):void 0;if(i)return i;if(e!==void 0)return;const d=v(t,r),s=d?K(d,oe(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return U(r)}function xe(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=v(e),a=v(t);return!r||!a?!0:Y(r,a)}function x(e){var t;return T((t=S(e))==null?void 0:t.kind)}function ue(e){var t,r;return x(e)!=="semantic"?null:((r=T((t=S(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Re(e){var t;return x(e)!=="semantic"?null:T((t=S(e))==null?void 0:t.datasetName)}function Me(e){var t;return x(e)!=="semantic"?null:T((t=S(e))==null?void 0:t.datasetId)}function Ne(e){var t;return x(e)!=="physical"?null:T((t=S(e))==null?void 0:t.connectionId)}function Oe(e){var t;return x(e)!=="physical"?null:T((t=S(e))==null?void 0:t.tableName)}function Be(e){var t;return x(e)!=="physical"?"":T((t=S(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return x(e)!=="physical"?"":T((t=S(e))==null?void 0:t.schemaName)||""}function fe(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function pe({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(ue),a=new Set(r.filter(Boolean));return r.some(o=>!o)||a.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function z(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Me(e);return ue(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Re(e)===t.datasetName:!1}return t.kind==="physical"?Ne(e)===t.connectionId&&Oe(e)===t.tableName&&Be(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Pe(e,t){return e.find(r=>z(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function E(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function he({card:e,datasets:t,errors:r}){if(e.type==="text")return;const a=fe(e);if(!a){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>z(o,a))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function q(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function L(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function se(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Ee(e){var r,a;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...q([...L(e.measures),e.primaryMeasure,e.dateField,...L(e.dimensions),...se(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...q([...L(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...se(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...q([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...q(e.fields||[])),t}function me({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const a of Ee(e.analyticsIntent))if(a&&!t.some(o=>z(o,a))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function be({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=w.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const a of r.errors)t.push(p(a.code,a.path?`${a.path}: ${a.message}`:a.message,e.id))}function ge({datasets:e,errors:t,requireAtLeastOne:r}){const a=pe({datasets:e,requireAtLeastOne:r});if(!a.ok){if(a.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function Ie({input:e,errors:t}){var r;(r=e.filter.sql)!=null&&r.trim()&&t.push(p("generated_filter_sql_out_of_scope",`Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`))}function ye(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,a=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],n=Array.isArray(r.sheets)?r.sheets:[];ge({datasets:o,errors:t,requireAtLeastOne:!0}),n.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const i=n[0];i&&i.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(i==null?void 0:i.cards)||[];d.length>k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=E(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=E(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&a.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),he({card:l,datasets:o,errors:t}),be({card:l,errors:t}),me({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],y=h.map(l=>l.id),D=E(y);D&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${D}.`));const C=h.map(l=>l.variableName).filter(Boolean)||[],_=E(C);_&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${_}.`));for(const l of h)Ie({input:l,errors:t});const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:a}}function _e(e){var i;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,a=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(i=r.dashboardId)!=null&&i.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],n=Array.isArray(r.operations)?r.operations:[];ge({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of n){if(d.kind==="unsupported"){a.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(he({card:d.card,datasets:o,errors:t}),be({card:d.card,errors:t}),me({card:d.card,datasets:o,errors:t})),d.kind==="addFilterInput"&&Ie({input:d.input,errors:t}),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:a}}const qe={lg:48,md:36,sm:24,xs:12,xxs:6};function ze(e,t){let r=0,a=0,o=0;return e.map(n=>{const i=Math.min(n.w,t);r>0&&r+i>t&&(r=0,a+=o,o=0);const d={i:n.frameId,x:r,y:a,w:i,h:n.h,minW:Math.min(n.minW,t),minH:n.minH,static:!1};return r+=i,o=Math.max(o,n.h),d})}function He(e){const t=[...e].sort((s,u)=>s.priority-u.priority),r=t.filter(s=>s.role==="kpi"),a=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),n=t.filter(s=>s.role==="text"),i=n.slice(0,1),d=n.slice(i.length);return{kpis:r,introText:i,charts:a,tables:o,supportingText:d}}function Ve(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Le(e,t,r,a){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?a:a/2}function je(e){const{item:t,band:r,index:a,bandCount:o,breakpoint:n,columns:i}=e;return r==="kpi"?{...t,band:r,w:Ve(o,n,i),h:15,minW:Math.min(6,i),minH:12}:r==="table"?{...t,band:r,w:i,h:n==="xxs"||n==="xs"?34:38,minW:Math.min(12,i),minH:18}:r==="introText"?{...t,band:r,w:i,h:n==="xxs"||n==="xs"?12:10,minW:Math.min(12,i),minH:8}:r==="supportingText"?{...t,band:r,w:n==="lg"?i/2:i,h:n==="xxs"||n==="xs"?12:10,minW:Math.min(12,i),minH:8}:{...t,band:r,w:Le(a,o,n,i),h:n==="xxs"||n==="xs"?28:30,minW:Math.min(12,i),minH:16}}function N(e,t,r,a){return e.map((o,n)=>je({item:o,band:t,index:n,bandCount:e.length,breakpoint:r,columns:a}))}function H(e){const t=He(e);return Object.fromEntries(k.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const a=qe[r],o=[...N(t.introText,"introText",r,a),...N(t.kpis,"kpi",r,a),...N(t.charts,"chart",r,a),...N(t.tables,"table",r,a),...N(t.supportingText,"supportingText",r,a)];return[r,ze(o,a)]}))}function Ge(e){const t=w.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function Ke(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ue(e){return Ke(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function We(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Xe(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function Q(e,t){if(t===void 0)return;const r=Ge(e.dataType),a=e.operation||"in";if(Ue(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(a==="is null"||a==="is not null")return{filterId:e.id,name:e.column,operation:a,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],n=r==="date"?Xe(o):We(o);if(n.length!==0&&!((a==="between"||a==="not between")&&n.length<2))return{filterId:e.id,name:e.column,operation:a,valueType:r,values:n,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function Se(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ye(e,t,r){const a=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return a.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...a]}}function W(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Qe(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=W(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Je(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:W(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:W(e.excludeCardIds,t)}:{}}}function Ze(e,t){const r={},a=[];return{inputs:(e.filterInputs||[]).flatMap((n,i)=>{const d=Qe(n.scope,t);if(d===null)return a.push(Se("filter_input_scope_empty",`Filter input "${n.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=Q(n.filter,n.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[n.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:n.id,kind:"filter",label:n.label,variableName:n.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:i},exports:["label","value","start","end","range"],filter:Je(n.filter,t)}]}),warnings:a,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function et(e){var C,_;const t=ye(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
|
|
2
|
-
`)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],a=[...t.warnings],o=[],
|
|
3
|
-
`)||"Dashboard change plan is invalid.");const r=tt(e.dashboard),a=[...t.warnings],o=[],n=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),i=rt(r);if(!i)throw new Error("Dashboard has no editable dashboard sheet.");i.frames??(i.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((i.frames||[]).reduce((D,C)=>{var _;return D+(((_=C.cards)==null?void 0:_.length)||0)},0)>=k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(R("generated_card_limit_reached",`AI refinement is capped at ${k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const h=n.get(s.card.id);if(!h){o.push(R("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const y={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};i.frames.push(y),it(i,y);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const u={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(u),ot(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)i.calculatedFields??(i.calculatedFields=[]),i.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const u=s.field.targetCardId?j(r,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.card.calculatedFields.push(s.field.field)):o.push(R("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=j(r,s.cardId);if(!u){o.push(R("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}u.card.title=s.title,s.description!==void 0&&(u.card.description=s.description);break}case"reorderCards":{const u=new Map;for(let h=0;h<s.cardIds.length;h+=1){const y=s.cardIds[h],D=j(r,y);D&&u.set(D.frame.id,h)}De(i,u);break}case"reuseCalculatedField":a.push(R("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(R("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:a,skippedOperations:o}}function I(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Ce(e,t){if(!t.has(e))return t.add(e),e;let r=2,a=`${e}-${r}`;for(;t.has(a);)r+=1,a=`${e}-${r}`;return t.add(a),a}function $(e){return!!(e&&typeof e=="object")}function ve(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function J(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function Z(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function F(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const a=v(r);a&&t.push(a)}return t}function dt(e){var a,o,n;if(!e)return[];const t=[];if(M(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...F(e.measures));const i=v(e.dateField);i&&t.push(i),t.push(...F(e.dimensions)),t.push(...F((a=e.filters)==null?void 0:a.map(d=>d.field)))}else if(e.kind==="records"){const i=v(e.dateField);i&&t.push(i),t.push(...F(e.fields)),t.push(...F((o=e.filters)==null?void 0:o.map(d=>d.field)))}else e.kind==="inputOptions"?(((n=e.population)==null?void 0:n.kind)==="related_population"&&M(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...F([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(i=>!!i)))):e.kind==="sql"&&t.push(...F(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const i of r){const d=v(i.field);d&&t.push(d)}return t}function ct(e){const t=[];for(const r of ve(e)){const a=v(r.field);a&&t.push(a)}for(const r of J(e))for(const a of Z(r))t.push(...dt(a.analytics));return t}function lt(e){var r;const t=[];for(const a of J(e))for(const o of Z(a))M((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function ut(e,t){const r=B(e).filter(M);if(r.length===0)return t.push(I("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const a=r.every(n=>n.kind==="semantic"),o=Array.from(new Set(r.filter(n=>n.kind==="semantic").map(n=>n.domainId)));return r.length>1&&(!a||o.length!==1)?(t.push(I("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function ft(e,t){const r=J(e),a=ve(e),o=B(ct(e)),n=B(lt(e));return{sections:r,inputs:a,sources:o,primarySources:n,defaultSource:n.length===1?n[0]:void 0,datasets:ut(o,t)}}function pt(e){return e&&w.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function ht(e){var t;switch((t=e.presentation)==null?void 0:t.kind){case"kpi":return"kpi";case"lineChart":return"line";case"barChart":return"bar";case"areaChart":return"area";case"table":return"table";case"text":return"text";default:return null}}function mt(e){var t,r,a;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((a=e.presentation)==null?void 0:a.kind)==="text"?"text":"chart"}function bt(e){const t=Te.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function gt(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function It(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function yt(e,t,r,a,o,n){if(e.kind!=="filter")return n.push(I("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!$(e.field)||typeof e.field.name!="string")return n.push(I("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const i=le({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(i==null?void 0:i.kind)==="semantic"||(i==null?void 0:i.kind)==="physical"?i.connectionId:void 0;if(!d)return n.push(I("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${Ce(O(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:gt(e),qualifiedTableName:It(i),sql:"",operation:bt(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(i==null?void 0:i.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(i==null?void 0:i.kind)==="semantic"?{semanticDomainId:i.domainId,connectionId:i.connectionId}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:a,filter:h,defaultValue:Q(h,e.defaultValue)}}function G(e){const t=[],r=[];for(const a of e.viewIds){const o=e.viewIdToCardId.get(a);o?t.push(o):r.push(a)}return r.length>0&&e.warnings.push(I("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function _t(e){var a,o;if(!e.protocolScope){const n=Array.from(new Set(e.boundCardIds));return n.length>0&&n.length<e.allCardIds.length?{kind:"cards",cardIds:n}:void 0}if(e.protocolScope.level==="dashboard"){if(!((a=e.protocolScope.excludeViewIds)!=null&&a.length))return;const n=new Set(G({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(i=>!n.has(i))}}if(e.protocolScope.level==="view"){const n=G({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return n.length===0?(e.warnings.push(I("input_scope_has_no_materialized_cards",`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`)),null):{kind:"cards",cardIds:n}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(I("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(G({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(n=>!r.has(n))}}function St(e){var C,_,c;const t=[],r=w.validateSemaphorDashboardIntent(e);for(const f of r.warnings)t.push(I(f.code,f.message));for(const f of r.errors)t.push(I(f.code,f.message));const a=ft(e,t),o=[],n=new Map,i=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[f,g]of a.sections.entries()){const l=typeof g.title=="string"?g.title:`Section ${f+1}`,ee=g.id||O(l,`section-${f+1}`);i.set(ee,[]);for(const[te,b]of Z(g).entries()){const re=ht(b),V=O(b.id||`${l}-${b.title||`View ${te+1}`}`,`card-${f+1}-${te+1}`);if(!re){t.push(I("unsupported_presentation",`Dashboard presentation "${((C=b.presentation)==null?void 0:C.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${V}`));continue}if(((_=b.analytics)==null?void 0:_.kind)==="sql"){t.push(I("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${V}`));continue}const ae=Ce(V,s),P=`card-${ae}`;b.id&&n.set(b.id,P),(c=i.get(ee))==null||c.push(P);const we=b.analytics&&"inputs"in b.analytics?b.analytics.inputs:void 0;for(const ne of we||[]){const ie=d.get(ne.inputId)||[];ie.push(P),d.set(ne.inputId,ie)}o.push({id:P,frameId:`frame-${ae}`,title:b.title,description:b.description,type:re,role:mt(b),priority:h,section:l,analyticsIntent:pt(b.analytics),text:b.text}),h+=1}}const y=a.inputs.map(f=>{const g=_t({protocolScope:f.scope,inputLabel:f.label,allCardIds:o.map(l=>l.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:n,sectionIdToCardIds:i,warnings:t});return g===null?null:yt(f,a.defaultSource,a.sources,g,u,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${O(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:a.datasets,sheets:[{id:`sheet-${O(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:y.length?y:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(f=>f.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=k.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.AUTOMATIC_TEMPORAL_BUCKET_FORMAT=A.AUTOMATIC_TEMPORAL_BUCKET_FORMAT;exports.SEMAPHOR_CARTESIAN_CHART_TYPES=A.SEMAPHOR_CARTESIAN_CHART_TYPES;exports.getTemporalBucketAuthoringOptions=A.getTemporalBucketAuthoringOptions;exports.getTemporalBucketAuthoringSelection=A.getTemporalBucketAuthoringSelection;exports.isSemaphorCartesianChartType=A.isSemaphorCartesianChartType;exports.previewTemporalBucketAuthoringFormat=A.previewTemporalBucketAuthoringFormat;exports.reconcileTemporalBucketAuthoringFormat=A.reconcileTemporalBucketAuthoringFormat;exports.resolveTemporalBucketAuthoringFormat=A.resolveTemporalBucketAuthoringFormat;exports.resolveTemporalResultOwner=A.resolveTemporalResultOwner;exports.supportsCanonicalDashboardTemporalResult=A.supportsCanonicalDashboardTemporalResult;exports.transformComparisonDocument=A.transformComparisonDocument;exports.resolveCanonicalDetailResultRawKey=X.resolveCanonicalDetailResultRawKey;exports.resolveCanonicalResultOutputKey=X.resolveCanonicalResultOutputKey;exports.resolveCanonicalResultRawKey=X.resolveCanonicalResultRawKey;exports.DashboardFilterMappingContractError=m.DashboardFilterMappingContractError;exports.buildDashboardCardSourceIndex=m.buildDashboardCardSourceIndex;exports.createDashboardFilterBindingId=m.createDashboardFilterBindingId;exports.dashboardCardFilterSourceInventoryContains=m.dashboardCardFilterSourceInventoryContains;exports.dashboardFilterTargetMatchesLogicalValue=m.dashboardFilterTargetMatchesLogicalValue;exports.dashboardFilterValueTypeForDataType=m.dashboardFilterValueTypeForDataType;exports.findDashboardCardExecutableSource=m.findDashboardCardExecutableSource;exports.findDashboardCardPinnedCatalogSource=m.findDashboardCardPinnedCatalogSource;exports.findDashboardSqlPinnedCatalogSource=m.findDashboardSqlPinnedCatalogSource;exports.getDashboardFilterSubscriptionHint=m.getDashboardFilterSubscriptionHint;exports.hasDashboardFilterSubscription=m.hasDashboardFilterSubscription;exports.isDashboardFilterOperationCompatible=m.isDashboardFilterOperationCompatible;exports.normalizeDashboardInputs=m.normalizeDashboardInputs;exports.requireNormalizedDashboardInputs=m.requireNormalizedDashboardInputs;exports.resolveDashboardFilterAutomaticTarget=m.resolveDashboardFilterAutomaticTarget;exports.resolveDashboardFilterInheritedTarget=m.resolveDashboardFilterInheritedTarget;exports.resolveDashboardSqlFilterTarget=m.resolveDashboardSqlFilterTarget;exports.applyDashboardChangePlan=st;exports.compileDashboardFromPlan=et;exports.compileResponsiveDashboardLayouts=H;exports.dashboardAuthoringDatasetMatchesSource=z;exports.dashboardAuthoringFieldsReferToSameTarget=xe;exports.dashboardAuthoringSourceFromField=v;exports.dashboardAuthoringSourceKey=Fe;exports.dashboardAuthoringSourcesReferToSameDataset=Y;exports.dashboardPlanFromSemaphorDashboardIntent=St;exports.findDashboardAuthoringDatasetForSource=Pe;exports.getDashboardAuthoringCardSource=fe;exports.isMaterializableDashboardAuthoringSource=M;exports.isSemaphorSourceRef=de;exports.mergeDashboardAuthoringSources=B;exports.preferDashboardAuthoringSourceMetadata=ce;exports.preferredDashboardAuthoringSource=ke;exports.resolveDashboardAuthoringSource=le;exports.validateDashboardAuthoringDatasetScope=pe;exports.validateDashboardChangePlan=_e;exports.validateDashboardPlan=ye;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("../chunks/contracts-CtB2VONT.cjs"),A=require("../chunks/temporal-bucket-authoring-DSpzgXHc.cjs"),w=require("../chunks/validators-DcshgK7w.cjs");require("../chunks/analyze-result-contract-OgPk-zGu.cjs");require("../value-format-preferences/index.cjs");const Te=require("../chunks/operators-DrTQsJXv.cjs"),X=require("../chunks/canonical-result-keys-Cb96edol.cjs"),m=require("../chunks/dashboard-filter-value-compatibility-Co1dn9Bc.cjs");function S(e){return e&&typeof e=="object"?e:null}function T(e){return typeof e=="string"?e:null}function de(e){var t,r,a;return!!(e&&typeof e=="object")&&(((t=S(e))==null?void 0:t.kind)==="semantic"||((r=S(e))==null?void 0:r.kind)==="physical"||((a=S(e))==null?void 0:a.kind)==="sql")}function M(e){return de(e)?e.kind==="semantic"?!!(e.domainId&&e.datasetName):e.kind==="physical"?!!(e.connectionId&&e.tableName):!1:!1}function Fe(e){return w.semaphorSourceIdentityKey(e)}function Y(e,t){return w.semaphorSourcesReferToSameDataset(e,t)}function ce(e,t){return w.preferSemaphorSourceMetadata(e,t)}function B(e){const t=[];for(const r of e){const a=t.findIndex(o=>Y(o,r));a===-1?t.push(r):t[a]=ce(t[a],r)}return t}function ke(e){return B(e)[0]}function K(e,t){return e.kind!=="semantic"||e.connectionId||(t==null?void 0:t.kind)!=="semantic"||!w.semaphorSourcesReferToSameDataset(e,t)||!t.connectionId?e:{...e,connectionId:t.connectionId}}function U(e){return M(e)?e:void 0}function oe(e,t){if(!(e.kind!=="semantic"||e.connectionId))return t.find(r=>(r==null?void 0:r.kind)==="semantic"&&w.semaphorSourcesReferToSameDataset(e,r)&&!!r.connectionId)}function v(e,t){const r=U(e==null?void 0:e.source);return r?K(r,t):void 0}function le({explicitSource:e,field:t,defaultSource:r,fallbackSources:a}){const o=[r,...a||[]],i=U(e),n=i?K(i,oe(i,o)):void 0;if(n)return n;if(e!==void 0)return;const d=v(t,r),s=d?K(d,oe(d,o)):void 0;if(s)return s;if((t==null?void 0:t.source)===void 0)return U(r)}function xe(e,t){if(!(e!=null&&e.name)||!(t!=null&&t.name)||e.name!==t.name)return!1;const r=v(e),a=v(t);return!r||!a?!0:Y(r,a)}function x(e){var t;return T((t=S(e))==null?void 0:t.kind)}function ue(e){var t,r;return x(e)!=="semantic"?null:((r=T((t=S(e))==null?void 0:t.domainId))==null?void 0:r.trim())||null}function Re(e){var t;return x(e)!=="semantic"?null:T((t=S(e))==null?void 0:t.datasetName)}function Me(e){var t;return x(e)!=="semantic"?null:T((t=S(e))==null?void 0:t.datasetId)}function Ne(e){var t;return x(e)!=="physical"?null:T((t=S(e))==null?void 0:t.connectionId)}function Oe(e){var t;return x(e)!=="physical"?null:T((t=S(e))==null?void 0:t.tableName)}function Be(e){var t;return x(e)!=="physical"?"":T((t=S(e))==null?void 0:t.databaseName)||""}function $e(e){var t;return x(e)!=="physical"?"":T((t=S(e))==null?void 0:t.schemaName)||""}function fe(e){if(e.analyticsIntent&&typeof e.analyticsIntent=="object"&&"source"in e.analyticsIntent)return e.analyticsIntent.source}function pe({datasets:e,requireAtLeastOne:t}){if(t&&e.length<1)return{ok:!1,issue:"invalid_dataset_count"};if(e.length<=1)return{ok:!0};const r=e.map(ue),a=new Set(r.filter(Boolean));return r.some(o=>!o)||a.size!==1?{ok:!1,issue:"invalid_multi_dataset_scope"}:{ok:!0}}function z(e,t){if(!t)return!1;if(t.kind==="semantic"){const r=Me(e);return ue(e)===t.domainId?r&&t.datasetId?r===t.datasetId:Re(e)===t.datasetName:!1}return t.kind==="physical"?Ne(e)===t.connectionId&&Oe(e)===t.tableName&&Be(e)===(t.databaseName||"")&&$e(e)===(t.schemaName||""):!1}function Pe(e,t){return e.find(r=>z(r,t))}function p(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function E(e){const t=new Set;for(const r of e){if(t.has(r))return r;t.add(r)}return null}function he({card:e,datasets:t,errors:r}){if(e.type==="text")return;const a=fe(e);if(!a){if(t.length<=1)return;r.push(p("missing_card_analytics_source","Multi-dataset dashboard cards must include analytics intent with a source so the materializer can choose the correct dataset.",e.id));return}t.some(o=>z(o,a))||r.push(p("invalid_card_analytics_source","Dashboard cards with an explicit analytics source must use one of the selected datasets.",e.id))}function q(e){return e.map(t=>t==null?void 0:t.source).filter(t=>!!t)}function L(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function se(e){return Array.isArray(e)?e.filter(t=>!!(t&&typeof t=="object")):[]}function Ee(e){var r,a;if(!e)return[];const t=[e.source];return e.kind==="metric"?t.push(...q([...L(e.measures),e.primaryMeasure,e.dateField,...L(e.dimensions),...se(e.filters).map(o=>o.field)])):e.kind==="records"?t.push(...q([...L(e.fields),e.dateField,(r=e.orderBy)==null?void 0:r.field,...se(e.filters).map(o=>o.field)])):e.kind==="inputOptions"?(((a=e.population)==null?void 0:a.kind)==="related_population"&&t.push(e.population.baseSource),t.push(...q([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]]))):e.kind==="sql"&&t.push(...q(e.fields||[])),t}function me({card:e,datasets:t,errors:r}){if(e.type!=="text"){for(const a of Ee(e.analyticsIntent))if(a&&!t.some(o=>z(o,a))){r.push(p("invalid_card_query_source","Dashboard card query field references must use one of the selected datasets.",e.id));return}}}function be({card:e,errors:t}){if(e.type==="text"||!e.analyticsIntent)return;const r=w.validateSemaphorAnalyticsIntent(e.analyticsIntent);if(!r.ok)for(const a of r.errors)t.push(p(a.code,a.path?`${a.path}: ${a.message}`:a.message,e.id))}function ge({datasets:e,errors:t,requireAtLeastOne:r}){const a=pe({datasets:e,requireAtLeastOne:r});if(!a.ok){if(a.issue==="invalid_dataset_count"){t.push(p("invalid_dataset_count","Dashboard authoring requires at least one selected dataset."));return}t.push(p("invalid_multi_dataset_scope","Multi-dataset dashboard authoring is limited to semantic datasets from one domain."))}}function Ie({input:e,errors:t}){var r;(r=e.filter.sql)!=null&&r.trim()&&t.push(p("generated_filter_sql_out_of_scope",`Generated dashboard filter "${e.label}" must use grounded filter configuration; custom SQL is outside the dashboard-authoring contract.`))}function ye(e){var f,g;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_plan","Dashboard plan must be a structured object.")],warnings:[]};const r=e,a=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard plan version must be 1.")),(f=r.title)!=null&&f.trim()||t.push(p("missing_title","Dashboard plan needs a title."));const o=Array.isArray(r.datasets)?r.datasets:[],i=Array.isArray(r.sheets)?r.sheets:[];ge({datasets:o,errors:t,requireAtLeastOne:!0}),i.length!==1&&t.push(p("invalid_sheet_count","MVP dashboard authoring creates exactly one dashboard sheet."));const n=i[0];n&&n.kind!=="dashboard"&&t.push(p("invalid_sheet_kind",'Generated sheet must use kind "dashboard".'));const d=(n==null?void 0:n.cards)||[];d.length>k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS&&t.push(p("too_many_cards",`Generated dashboards can contain at most ${k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`));const s=E(d.map(l=>l.id));s&&t.push(p("duplicate_card_id",`Duplicate generated card id: ${s}.`));const u=E(d.map(l=>l.frameId));u&&t.push(p("duplicate_frame_id",`Duplicate generated frame id: ${u}.`));for(const l of d)(g=l.title)!=null&&g.trim()||t.push(p("missing_card_title","Card title is required.",l.id)),l.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",l.id)),l.type!=="text"&&!l.analyticsIntent&&a.push(p("missing_analytics_intent","Non-text card has no analytics intent and may be skipped by the app layer.",l.id)),he({card:l,datasets:o,errors:t}),be({card:l,errors:t}),me({card:l,datasets:o,errors:t});const h=Array.isArray(r.filterInputs)?r.filterInputs:[],y=h.map(l=>l.id),D=E(y);D&&t.push(p("duplicate_input_id",`Duplicate dashboard input id: ${D}.`));const C=h.map(l=>l.variableName).filter(Boolean)||[],_=E(C);_&&t.push(p("duplicate_input_variable",`Duplicate dashboard input variable name: ${_}.`));for(const l of h)Ie({input:l,errors:t});const c=Array.isArray(r.calculatedFields)?r.calculatedFields:[];for(const l of c)l.scope==="domain"&&l.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${l.name}" is outside MVP.`));return{ok:t.length===0,errors:t,warnings:a}}function _e(e){var n;const t=[];if(!e||typeof e!="object")return{ok:!1,errors:[p("invalid_change_plan","Dashboard change plan must be a structured object.")],warnings:[]};const r=e,a=[...r.warnings||[]];r.version!==1&&t.push(p("invalid_version","Dashboard change plan version must be 1.")),(n=r.dashboardId)!=null&&n.trim()||t.push(p("missing_dashboard_id","Dashboard change plan needs a dashboard id."));const o=Array.isArray(r.datasets)?r.datasets:[],i=Array.isArray(r.operations)?r.operations:[];ge({datasets:o,errors:t,requireAtLeastOne:!1});for(const d of i){if(d.kind==="unsupported"){a.push(p("unsupported_operation",d.reason||d.requestedAction));continue}d.kind==="addCard"&&d.card.type==="custom"&&t.push(p("custom_visual_out_of_scope","Whole-dashboard authoring supports built-in visual types only.",d.card.id)),d.kind==="addCard"&&(he({card:d.card,datasets:o,errors:t}),be({card:d.card,errors:t}),me({card:d.card,datasets:o,errors:t})),d.kind==="addFilterInput"&&Ie({input:d.input,errors:t}),d.kind==="addCalculatedField"&&d.field.scope==="domain"&&d.field.reuseOnly!==!0&&t.push(p("domain_calculated_field_create_out_of_scope",`Creating domain calculated field "${d.field.name}" is outside MVP.`))}return{ok:t.length===0,errors:t,warnings:a}}const qe={lg:48,md:36,sm:24,xs:12,xxs:6};function ze(e,t){let r=0,a=0,o=0;return e.map(i=>{const n=Math.min(i.w,t);r>0&&r+n>t&&(r=0,a+=o,o=0);const d={i:i.frameId,x:r,y:a,w:n,h:i.h,minW:Math.min(i.minW,t),minH:i.minH,static:!1};return r+=n,o=Math.max(o,i.h),d})}function He(e){const t=[...e].sort((s,u)=>s.priority-u.priority),r=t.filter(s=>s.role==="kpi"),a=t.filter(s=>s.role==="chart"),o=t.filter(s=>s.role==="table"),i=t.filter(s=>s.role==="text"),n=i.slice(0,1),d=i.slice(n.length);return{kpis:r,introText:n,charts:a,tables:o,supportingText:d}}function Ve(e,t,r){return t==="xxs"||t==="xs"?r:t==="sm"?Math.min(12,r):t==="md"?e<=1||e===2?18:12:e<=1||e===2?24:e===3?16:12}function Le(e,t,r,a){return r==="xxs"||r==="xs"||r==="sm"||r==="md"||t===1||t%2===1&&e===0?a:a/2}function je(e){const{item:t,band:r,index:a,bandCount:o,breakpoint:i,columns:n}=e;return r==="kpi"?{...t,band:r,w:Ve(o,i,n),h:15,minW:Math.min(6,n),minH:12}:r==="table"?{...t,band:r,w:n,h:i==="xxs"||i==="xs"?34:38,minW:Math.min(12,n),minH:18}:r==="introText"?{...t,band:r,w:n,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,n),minH:8}:r==="supportingText"?{...t,band:r,w:i==="lg"?n/2:n,h:i==="xxs"||i==="xs"?12:10,minW:Math.min(12,n),minH:8}:{...t,band:r,w:Le(a,o,i,n),h:i==="xxs"||i==="xs"?28:30,minW:Math.min(12,n),minH:16}}function N(e,t,r,a){return e.map((o,i)=>je({item:o,band:t,index:i,bandCount:e.length,breakpoint:r,columns:a}))}function H(e){const t=He(e);return Object.fromEntries(k.DASHBOARD_AUTHORING_BREAKPOINTS.map(r=>{const a=qe[r],o=[...N(t.introText,"introText",r,a),...N(t.kpis,"kpi",r,a),...N(t.charts,"chart",r,a),...N(t.tables,"table",r,a),...N(t.supportingText,"supportingText",r,a)];return[r,ze(o,a)]}))}function Ge(e){const t=w.normalizeAnalyticsCatalogDataType(e);return t==="datetime"?"date":t==="unknown"?"string":t}function Ke(e){return!!(e&&typeof e=="object"&&!Array.isArray(e))}function Ue(e){return Ke(e)&&typeof e.filterId=="string"&&typeof e.operation=="string"&&Array.isArray(e.values)}function We(e){return e.filter(t=>typeof t=="string"||typeof t=="number")}function Xe(e){return e.filter(t=>t instanceof Date||typeof t=="string")}function Q(e,t){if(t===void 0)return;const r=Ge(e.dataType),a=e.operation||"in";if(Ue(t))return{...t,filterId:e.id,name:t.name||e.column,valueType:r,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};if(a==="is null"||a==="is not null")return{filterId:e.id,name:e.column,operation:a,valueType:r,values:[],dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext};const o=Array.isArray(t)?t:[t],i=r==="date"?Xe(o):We(o);if(i.length!==0&&!((a==="between"||a==="not between")&&i.length<2))return{filterId:e.id,name:e.column,operation:a,valueType:r,values:i,dataType:e.dataType,fieldMeta:e.fieldMeta,semanticContext:e.semanticContext}}function Se(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function Ye(e,t,r){const a=(t||[]).filter(o=>o.scope==="card"&&o.targetCardId===r).map(o=>o.field).filter(Boolean);return a.length===0?e:{...e,calculatedFields:[...e.calculatedFields||[],...a]}}function W(e,t){return Array.from(new Set((e||[]).map(r=>t.get(r)).filter(r=>!!r)))}function Qe(e,t){if((e==null?void 0:e.kind)!=="cards")return e;const r=W(e.cardIds,t);return r.length>0?{...e,cardIds:r}:null}function Je(e,t){return!e.applyToCardIds&&!e.excludeCardIds?e:{...e,...e.applyToCardIds?{applyToCardIds:W(e.applyToCardIds,t)}:{},...e.excludeCardIds?{excludeCardIds:W(e.excludeCardIds,t)}:{}}}function Ze(e,t){const r={},a=[];return{inputs:(e.filterInputs||[]).flatMap((i,n)=>{const d=Qe(i.scope,t);if(d===null)return a.push(Se("filter_input_scope_empty",`Filter input "${i.label}" was skipped because all scoped cards were skipped during query validation.`)),[];const s=Q(i.filter,i.defaultValue);return s&&(r.shared??(r.shared={}),r.shared[i.id]={status:"set",value:{kind:"filter",filterValue:s}}),[{id:i.id,kind:"filter",label:i.label,variableName:i.variableName,scope:d||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:n},exports:["label","value","start","end","range"],filter:Je(i.filter,t)}]}),warnings:a,defaultInputValues:r.shared&&Object.keys(r.shared).length>0?r:void 0}}function et(e){var C,_;const t=ye(e.plan);if(!t.ok)throw new Error(t.errors.map(c=>c.message).join(`
|
|
2
|
+
`)||"Dashboard plan is invalid.");const r=e.plan.sheets[0],a=[...t.warnings],o=[],i=new Map(e.cardArtifacts.map(c=>[c.planCardId,c])),n=new Map(e.cardArtifacts.map(c=>[c.planCardId,c.card.id])),d=[];for(const c of r.cards){const f=i.get(c.id);if(!f){const l=Se("missing_card_artifact",`Card "${c.title}" was skipped because no generated artifact was supplied.`,c.id);o.push(l);continue}a.push(...f.warnings||[]);const g=Ye(f.card,e.plan.calculatedFields,c.id);d.push({id:c.frameId,cards:[g],activeCardId:g.id})}if(d.length===0)throw new Error("Dashboard plan did not produce any persistable cards.");const{inputs:s,defaultInputValues:u,warnings:h}=Ze(e.plan,n);a.push(...h);const y=H(r.cards.filter(c=>d.some(f=>f.id===c.frameId)).map(c=>({frameId:c.frameId,priority:c.priority,role:c.role})));return{dashboard:{id:e.dashboardId,title:e.plan.title,description:e.plan.description||"",sheets:[{id:r.id,kind:"dashboard",title:r.title,description:r.description,frames:d,layouts:y,calculatedFields:(C=e.plan.calculatedFields)==null?void 0:C.filter(c=>c.scope==="sheet"&&c.field).map(c=>c.field)}],calculatedFields:(_=e.plan.calculatedFields)==null?void 0:_.filter(c=>c.scope==="dashboard"&&c.field).map(c=>c.field),inputs:s,...u?{defaultInputValues:u}:{}},warnings:a,skippedOperations:o}}function R(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function tt(e){return JSON.parse(JSON.stringify(e))}function rt(e){var t;return(t=e.sheets)==null?void 0:t.find(r=>(r.kind||"dashboard")==="dashboard")}function j(e,t){var r;for(const a of e.sheets||[])for(const o of a.frames||[]){const i=(r=o.cards)==null?void 0:r.find(n=>n.id===t);if(i)return{sheet:a,frame:o,card:i}}return null}function Ae(e){var r,a;const t=(a=(r=e.cards)==null?void 0:r[0])==null?void 0:a.type;return t==="kpi"?"kpi":t==="table"||t==="detailTable"||t==="pivotTable"?"table":t==="text"?"text":"chart"}function at(e){var t;return new Map((((t=e.layouts)==null?void 0:t.lg)||[]).map((r,a)=>[r.i,a]))}function De(e,t=new Map){const r=at(e),a=Math.max(r.size,t.size),o=(e.frames||[]).map((i,n)=>({frameId:i.id,role:Ae(i),priority:t.get(i.id)??r.get(i.id)??a+n}));e.layouts=H(o)}function nt(e){return Object.values(e.layouts||{}).some(t=>t.length>0)}function it(e,t){if(!nt(e)){De(e);return}const r=H([{frameId:t.id,role:Ae(t),priority:0}]);e.layouts??(e.layouts={});for(const[a,o]of Object.entries(r)){const i=e.layouts[a]||[];if(i.some(s=>s.i===t.id))continue;const n=o[0];if(!n)continue;const d=i.reduce((s,u)=>Math.max(s,u.y+u.h),0);e.layouts[a]=[...i,{...n,y:d}]}}function ot(e,t){var a;const r=Q(t.filter,t.defaultValue);r&&(e.defaultInputValues??(e.defaultInputValues={}),(a=e.defaultInputValues).shared??(a.shared={}),e.defaultInputValues.shared[t.id]={status:"set",value:{kind:"filter",filterValue:r}})}function st(e){var d;const t=_e(e.changePlan);if(!t.ok)throw new Error(t.errors.map(s=>s.message).join(`
|
|
3
|
+
`)||"Dashboard change plan is invalid.");const r=tt(e.dashboard),a=[...t.warnings],o=[],i=new Map(e.cardArtifacts.map(s=>[s.planCardId,s])),n=rt(r);if(!n)throw new Error("Dashboard has no editable dashboard sheet.");n.frames??(n.frames=[]);for(const s of e.changePlan.operations)switch(s.kind){case"addCard":{if((n.frames||[]).reduce((D,C)=>{var _;return D+(((_=C.cards)==null?void 0:_.length)||0)},0)>=k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS){o.push(R("generated_card_limit_reached",`AI refinement is capped at ${k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS} cards.`,s.card.id));break}const h=i.get(s.card.id);if(!h){o.push(R("missing_card_artifact",`Card "${s.card.title}" was skipped because no generated artifact was supplied.`,s.card.id));break}const y={id:s.card.frameId,cards:[h.card],activeCardId:h.card.id};n.frames.push(y),it(n,y);break}case"addFilterInput":{r.inputs??(r.inputs=[]);const u={id:s.input.id,kind:"filter",label:s.input.label,variableName:s.input.variableName,scope:s.input.scope||{kind:"allSheets",sheetKinds:["dashboard"]},runtimeScope:"shared",presentation:{placement:"toolbar",order:r.inputs.length},exports:["label","value","start","end","range"],filter:s.input.filter};r.inputs.push(u),ot(r,s.input);break}case"addCalculatedField":{if(s.field.scope==="dashboard"&&s.field.field)r.calculatedFields??(r.calculatedFields=[]),r.calculatedFields.push(s.field.field);else if(s.field.scope==="sheet"&&s.field.field)n.calculatedFields??(n.calculatedFields=[]),n.calculatedFields.push(s.field.field);else if(s.field.scope==="card"&&s.field.field){const u=s.field.targetCardId?j(r,s.field.targetCardId):null;u?((d=u.card).calculatedFields??(d.calculatedFields=[]),u.card.calculatedFields.push(s.field.field)):o.push(R("missing_calculated_field_target",`Calculated field "${s.field.name}" needs a valid target card.`))}break}case"renameCard":{const u=j(r,s.cardId);if(!u){o.push(R("card_not_found",`Card "${s.cardId}" could not be renamed because it was not found.`,s.cardId));break}u.card.title=s.title,s.description!==void 0&&(u.card.description=s.description);break}case"reorderCards":{const u=new Map;for(let h=0;h<s.cardIds.length;h+=1){const y=s.cardIds[h],D=j(r,y);D&&u.set(D.frame.id,h)}De(n,u);break}case"reuseCalculatedField":a.push(R("reused_calculated_field",`Calculated field "${s.fieldId}" is reused by reference.`));break;case"unsupported":o.push(R("unsupported_operation",s.reason||s.requestedAction));break}return{dashboard:r,warnings:a,skippedOperations:o}}function I(e,t,r){return r?{code:e,message:t,cardId:r}:{code:e,message:t}}function O(e,t){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||t}function Ce(e,t){if(!t.has(e))return t.add(e),e;let r=2,a=`${e}-${r}`;for(;t.has(a);)r+=1,a=`${e}-${r}`;return t.add(a),a}function $(e){return!!(e&&typeof e=="object")}function ve(e){return Array.isArray(e.inputs)?e.inputs.filter(t=>$(t)&&typeof t.id=="string"):[]}function J(e){return Array.isArray(e.sections)?e.sections.filter(t=>$(t)):[]}function Z(e){return Array.isArray(e.views)?e.views.filter(t=>$(t)):[]}function F(e){if(!Array.isArray(e))return[];const t=[];for(const r of e){const a=v(r);a&&t.push(a)}return t}function dt(e){var a,o,i;if(!e)return[];const t=[];if(M(e.source)&&t.push(e.source),e.kind==="metric"){t.push(...F(e.measures));const n=v(e.dateField);n&&t.push(n),t.push(...F(e.dimensions)),t.push(...F((a=e.filters)==null?void 0:a.map(d=>d.field)))}else if(e.kind==="records"){const n=v(e.dateField);n&&t.push(n),t.push(...F(e.fields)),t.push(...F((o=e.filters)==null?void 0:o.map(d=>d.field)))}else e.kind==="inputOptions"?(((i=e.population)==null?void 0:i.kind)==="related_population"&&M(e.population.baseSource)&&t.push(e.population.baseSource),t.push(...F([e.labelField,e.valueField,e.searchField,...e.disambiguationFields||[]].filter(n=>!!n)))):e.kind==="sql"&&t.push(...F(e.fields));const r="inputs"in e&&Array.isArray(e.inputs)?e.inputs:[];for(const n of r){const d=v(n.field);d&&t.push(d)}return t}function ct(e){const t=[];for(const r of ve(e)){const a=v(r.field);a&&t.push(a)}for(const r of J(e))for(const a of Z(r))t.push(...dt(a.analytics));return t}function lt(e){var r;const t=[];for(const a of J(e))for(const o of Z(a))M((r=o.analytics)==null?void 0:r.source)&&t.push(o.analytics.source);return t}function ut(e,t){const r=B(e).filter(M);if(r.length===0)return t.push(I("missing_materializable_dataset","No semantic or physical source could be converted into the current dashboard authoring dataset reference.")),[];const a=r.every(i=>i.kind==="semantic"),o=Array.from(new Set(r.filter(i=>i.kind==="semantic").map(i=>i.domainId)));return r.length>1&&(!a||o.length!==1)?(t.push(I("multiple_datasets_out_of_scope","The dashboard authoring compiler supports multiple datasets only within one semantic domain; using the first source and deferring the rest.")),[r[0]]):r}function ft(e,t){const r=J(e),a=ve(e),o=B(ct(e)),i=B(lt(e));return{sections:r,inputs:a,sources:o,primarySources:i,defaultSource:i.length===1?i[0]:void 0,datasets:ut(o,t)}}function pt(e){return e&&w.validateSemaphorAnalyticsIntent(e).ok?e:void 0}function ht(e){var t;switch((t=e.presentation)==null?void 0:t.kind){case"kpi":return"kpi";case"lineChart":return"line";case"barChart":return"bar";case"areaChart":return"area";case"table":return"table";case"text":return"text";default:return null}}function mt(e){var t,r,a;return((t=e.presentation)==null?void 0:t.kind)==="kpi"?"kpi":((r=e.presentation)==null?void 0:r.kind)==="table"?"table":((a=e.presentation)==null?void 0:a.kind)==="text"?"text":"chart"}function bt(e){const t=Te.normalizeSemaphorInputOperator(e);switch(t){case"not_in":return"not in";case"not_between":return"not between";case"contains":return"like";case"not_contains":return"not like";default:return t||"in"}}function gt(e){return $(e.field)?e.field.dataType==="datetime"?"date":e.field.dataType||"string":"string"}function It(e){if(!(!e||e.kind!=="physical"))return[e.databaseName,e.schemaName,e.tableName].filter(Boolean).join(".")}function yt(e,t,r,a,o,i){if(e.kind!=="filter")return i.push(I("control_inputs_deferred",`Control input "${e.label}" is represented in the protocol but not yet materialized by the dashboard authoring adapter.`)),null;if(!$(e.field)||typeof e.field.name!="string")return i.push(I("filter_requires_field",`Filter "${e.label||e.id}" needs a field before the dashboard compiler can materialize it.`)),null;const n=le({explicitSource:void 0,field:e.field,defaultSource:t,fallbackSources:r}),d=(n==null?void 0:n.kind)==="semantic"||(n==null?void 0:n.kind)==="physical"?n.connectionId:void 0;if(!d)return i.push(I("filter_requires_connection_id",`Filter "${e.label}" needs a source connectionId before the dashboard compiler can materialize it.`)),null;const h={id:`filter-${Ce(O(e.id,e.field.name),o)}`,variableName:e.id,connectionId:d,title:e.label,column:e.field.name,dataType:gt(e),qualifiedTableName:It(n),sql:"",operation:bt(e.operator),type:e.multi===!1?"single":"multiple",location:"dashboard",displayMode:"toolbar",fieldMeta:(n==null?void 0:n.kind)==="semantic"?{name:e.field.name,qualifiedFieldName:e.field.name,dataType:e.field.dataType,role:e.field.role==="measure"?"metric":"groupby"}:void 0,semanticContext:(n==null?void 0:n.kind)==="semantic"?{semanticDomainId:n.domainId,connectionId:n.connectionId}:(n==null?void 0:n.kind)==="physical"?{connectionId:n.connectionId,connectionType:n.connectionType,selectedEntities:[{type:"table",connectionId:n.connectionId,connectionType:n.connectionType,dialect:n.dialect,database:n.databaseName,schema:n.schemaName,name:n.tableName}]}:void 0};return{id:e.id,label:e.label,variableName:e.id,scope:a,filter:h,defaultValue:Q(h,e.defaultValue)}}function G(e){const t=[],r=[];for(const a of e.viewIds){const o=e.viewIdToCardId.get(a);o?t.push(o):r.push(a)}return r.length>0&&e.warnings.push(I("input_scope_view_not_found",`Filter "${e.inputLabel}" referenced unknown view ids: ${r.join(", ")}.`)),Array.from(new Set(t))}function _t(e){var a,o;if(!e.protocolScope){const i=Array.from(new Set(e.boundCardIds));return i.length>0&&i.length<e.allCardIds.length?{kind:"cards",cardIds:i}:void 0}if(e.protocolScope.level==="dashboard"){if(!((a=e.protocolScope.excludeViewIds)!=null&&a.length))return;const i=new Set(G({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:e.allCardIds.filter(n=>!i.has(n))}}if(e.protocolScope.level==="view"){const i=G({inputLabel:e.inputLabel,viewIds:e.protocolScope.viewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings});return i.length===0?(e.warnings.push(I("input_scope_has_no_materialized_cards",`Filter "${e.inputLabel}" was deferred because its view scope does not match any materialized cards.`)),null):{kind:"cards",cardIds:i}}const t=e.sectionIdToCardIds.get(e.protocolScope.sectionId)||[];if(t.length===0)return e.warnings.push(I("input_scope_section_not_found",`Filter "${e.inputLabel}" was deferred because section "${e.protocolScope.sectionId}" does not match any materialized cards.`)),null;if(!((o=e.protocolScope.excludeViewIds)!=null&&o.length))return{kind:"cards",cardIds:t};const r=new Set(G({inputLabel:e.inputLabel,viewIds:e.protocolScope.excludeViewIds,viewIdToCardId:e.viewIdToCardId,warnings:e.warnings}));return{kind:"cards",cardIds:t.filter(i=>!r.has(i))}}function St(e){var C,_,c;const t=[],r=w.validateSemaphorDashboardIntent(e);for(const f of r.warnings)t.push(I(f.code,f.message));for(const f of r.errors)t.push(I(f.code,f.message));const a=ft(e,t),o=[],i=new Map,n=new Map,d=new Map,s=new Set,u=new Set;let h=0;for(const[f,g]of a.sections.entries()){const l=typeof g.title=="string"?g.title:`Section ${f+1}`,ee=g.id||O(l,`section-${f+1}`);n.set(ee,[]);for(const[te,b]of Z(g).entries()){const re=ht(b),V=O(b.id||`${l}-${b.title||`View ${te+1}`}`,`card-${f+1}-${te+1}`);if(!re){t.push(I("unsupported_presentation",`Dashboard presentation "${((C=b.presentation)==null?void 0:C.kind)||"unknown"}" is not supported by the dashboard authoring adapter.`,`card-${V}`));continue}if(((_=b.analytics)==null?void 0:_.kind)==="sql"){t.push(I("sql_intent_deferred","SQL analytics intent is valid protocol, but the current dashboard authoring adapter only materializes semantic and physical config-card intents.",`card-${V}`));continue}const ae=Ce(V,s),P=`card-${ae}`;b.id&&i.set(b.id,P),(c=n.get(ee))==null||c.push(P);const we=b.analytics&&"inputs"in b.analytics?b.analytics.inputs:void 0;for(const ne of we||[]){const ie=d.get(ne.inputId)||[];ie.push(P),d.set(ne.inputId,ie)}o.push({id:P,frameId:`frame-${ae}`,title:b.title,description:b.description,type:re,role:mt(b),priority:h,section:l,analyticsIntent:pt(b.analytics),text:b.text}),h+=1}}const y=a.inputs.map(f=>{const g=_t({protocolScope:f.scope,inputLabel:f.label,allCardIds:o.map(l=>l.id),boundCardIds:d.get(f.id)||[],viewIdToCardId:i,sectionIdToCardIds:n,warnings:t});return g===null?null:yt(f,a.defaultSource,a.sources,g,u,t)}).filter(f=>!!f);return{plan:{version:1,id:`plan-${O(e.title,"dashboard")}`,title:e.title,description:e.description,datasets:a.datasets,sheets:[{id:`sheet-${O(e.title,"dashboard")}`,title:e.title,description:e.description,kind:"dashboard",cards:o}],filterInputs:y.length?y:void 0,warnings:t.length?t:void 0,unresolvedRequests:r.ok?void 0:r.errors.map(f=>f.message)},warnings:t}}exports.DASHBOARD_AUTHORING_BREAKPOINTS=k.DASHBOARD_AUTHORING_BREAKPOINTS;exports.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS=k.DASHBOARD_AUTHORING_MAX_GENERATED_CARDS;exports.AUTOMATIC_TEMPORAL_BUCKET_FORMAT=A.AUTOMATIC_TEMPORAL_BUCKET_FORMAT;exports.SEMAPHOR_CARTESIAN_CHART_TYPES=A.SEMAPHOR_CARTESIAN_CHART_TYPES;exports.getTemporalBucketAuthoringOptions=A.getTemporalBucketAuthoringOptions;exports.getTemporalBucketAuthoringSelection=A.getTemporalBucketAuthoringSelection;exports.isSemaphorCartesianChartType=A.isSemaphorCartesianChartType;exports.previewTemporalBucketAuthoringFormat=A.previewTemporalBucketAuthoringFormat;exports.reconcileTemporalBucketAuthoringFormat=A.reconcileTemporalBucketAuthoringFormat;exports.resolveTemporalBucketAuthoringFormat=A.resolveTemporalBucketAuthoringFormat;exports.resolveTemporalResultOwner=A.resolveTemporalResultOwner;exports.supportsCanonicalDashboardTemporalResult=A.supportsCanonicalDashboardTemporalResult;exports.transformComparisonDocument=A.transformComparisonDocument;exports.resolveCanonicalDetailResultRawKey=X.resolveCanonicalDetailResultRawKey;exports.resolveCanonicalResultOutputKey=X.resolveCanonicalResultOutputKey;exports.resolveCanonicalResultRawKey=X.resolveCanonicalResultRawKey;exports.DashboardFilterMappingContractError=m.DashboardFilterMappingContractError;exports.buildDashboardCardSourceIndex=m.buildDashboardCardSourceIndex;exports.createDashboardFilterBindingId=m.createDashboardFilterBindingId;exports.dashboardCardFilterSourceInventoryContains=m.dashboardCardFilterSourceInventoryContains;exports.dashboardFilterTargetMatchesLogicalValue=m.dashboardFilterTargetMatchesLogicalValue;exports.dashboardFilterValueTypeForDataType=m.dashboardFilterValueTypeForDataType;exports.findDashboardCardExecutableSource=m.findDashboardCardExecutableSource;exports.findDashboardCardPinnedCatalogSource=m.findDashboardCardPinnedCatalogSource;exports.findDashboardSqlPinnedCatalogSource=m.findDashboardSqlPinnedCatalogSource;exports.getDashboardFilterSubscriptionHint=m.getDashboardFilterSubscriptionHint;exports.hasDashboardFilterSubscription=m.hasDashboardFilterSubscription;exports.isDashboardFilterOperationCompatible=m.isDashboardFilterOperationCompatible;exports.normalizeDashboardInputs=m.normalizeDashboardInputs;exports.requireNormalizedDashboardInputs=m.requireNormalizedDashboardInputs;exports.resolveDashboardFilterAutomaticTarget=m.resolveDashboardFilterAutomaticTarget;exports.resolveDashboardFilterInheritedTarget=m.resolveDashboardFilterInheritedTarget;exports.resolveDashboardSqlFilterTarget=m.resolveDashboardSqlFilterTarget;exports.applyDashboardChangePlan=st;exports.compileDashboardFromPlan=et;exports.compileResponsiveDashboardLayouts=H;exports.dashboardAuthoringDatasetMatchesSource=z;exports.dashboardAuthoringFieldsReferToSameTarget=xe;exports.dashboardAuthoringSourceFromField=v;exports.dashboardAuthoringSourceKey=Fe;exports.dashboardAuthoringSourcesReferToSameDataset=Y;exports.dashboardPlanFromSemaphorDashboardIntent=St;exports.findDashboardAuthoringDatasetForSource=Pe;exports.getDashboardAuthoringCardSource=fe;exports.isMaterializableDashboardAuthoringSource=M;exports.isSemaphorSourceRef=de;exports.mergeDashboardAuthoringSources=B;exports.preferDashboardAuthoringSourceMetadata=ce;exports.preferredDashboardAuthoringSource=ke;exports.resolveDashboardAuthoringSource=le;exports.validateDashboardAuthoringDatasetScope=pe;exports.validateDashboardChangePlan=_e;exports.validateDashboardPlan=ye;
|