react-semaphor 0.1.477 → 0.1.479
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 +9 -9
- package/dist/brand-studio/index.cjs +1 -1
- package/dist/brand-studio/index.js +4 -4
- package/dist/briefings/index.cjs +1 -1
- package/dist/briefings/index.js +4 -4
- package/dist/chunks/{analyze-result-contract-OgPk-zGu.cjs → analyze-result-contract-BX_nQmPN.cjs} +1 -1
- package/dist/chunks/{analyze-result-contract-C8s8EUL5.js → analyze-result-contract-DsiAzCYn.js} +1 -1
- package/dist/chunks/{saved-temporal-bucket-format-CHsXUPJI.js → card-config-utils-CyDKaPNT.js} +190 -190
- package/dist/chunks/card-config-utils-D3Xuu0ub.cjs +1 -0
- package/dist/chunks/{common-types-C1IM7gao.cjs → common-types-BCSbPclk.cjs} +1 -1
- package/dist/chunks/{common-types-BLPy5_E0.js → common-types-D3r4PILe.js} +1 -1
- package/dist/chunks/{dashboard-briefing-launcher-CXHq6ime.cjs → dashboard-briefing-launcher-DWwSdfV7.cjs} +2 -2
- package/dist/chunks/{dashboard-briefing-launcher-C9d8CPxv.js → dashboard-briefing-launcher-Dk4yNOLY.js} +134 -134
- package/dist/chunks/{dashboard-controls-d7Yd2fJb.cjs → dashboard-controls-B0Pm_y8L.cjs} +10 -10
- package/dist/chunks/{dashboard-controls-BqDm4ARp.js → dashboard-controls-CIC5_549.js} +13 -12
- package/dist/chunks/{dashboard-input-contract-JFJZgenC.cjs → dashboard-date-comparison-definition-C93wv8Ua.cjs} +1 -1
- package/dist/chunks/{dashboard-input-contract-BrGdGFz0.js → dashboard-date-comparison-definition-KohOqBqR.js} +19 -19
- package/dist/chunks/dashboard-filter-value-compatibility-ByT__CYM.cjs +1 -0
- package/dist/chunks/dashboard-filter-value-compatibility-DQkUs41q.js +1220 -0
- package/dist/chunks/dashboard-json-Bk6nEHap.cjs +1 -0
- package/dist/chunks/{dashboard-json-CL_vgcWq.js → dashboard-json-YDTb3r4e.js} +7 -7
- package/dist/chunks/{edit-dashboard-visual-Dklel3MC.cjs → edit-dashboard-visual-B3oH-O0L.cjs} +6 -6
- package/dist/chunks/{edit-dashboard-visual-C0Zvyo-X.js → edit-dashboard-visual-q5Yj9dMP.js} +277 -277
- package/dist/chunks/{editor-action-buttons-BOyUtX9j.js → editor-action-buttons-BqelO0n9.js} +39 -39
- package/dist/chunks/{editor-action-buttons-AcaZsiDy.cjs → editor-action-buttons-vZ63-lN-.cjs} +1 -1
- package/dist/chunks/{format-types-CFHQoIuk.js → index-BS0_dp0l.js} +168 -168
- package/dist/chunks/{index-D9S3j7_z.js → index-BvRREsU9.js} +9 -9
- package/dist/chunks/index-ByQgqT9d.cjs +1 -0
- package/dist/chunks/{index-DrdF7QR7.js → index-CUCiMVzS.js} +34219 -35005
- package/dist/chunks/{index-v2MZLyus.cjs → index-CXeIDdjd.cjs} +1 -1
- package/dist/chunks/{index-Cd8qGOXl.cjs → index-DhDfPZUu.cjs} +232 -232
- package/dist/chunks/matrix-result-contract-CFPnlcLm.cjs +1 -0
- package/dist/chunks/{matrix-result-contract-BpzhImar.js → matrix-result-contract-DFfUvb1r.js} +3 -3
- package/dist/chunks/{temporal-bucket-CtP7hKLa.js → metric-comparison-CTexJ8V1.js} +705 -705
- package/dist/chunks/metric-comparison-x0lipytf.cjs +1 -0
- package/dist/chunks/pivot-header-presentation-8Ra1RfHg.cjs +4 -0
- package/dist/chunks/{pivot-header-presentation-CaERAWpl.js → pivot-header-presentation-tpb_J900.js} +118 -118
- package/dist/chunks/{pivot-result-identity-CIZXsI53.js → pivot-result-identity-BIeP9v8I.js} +1 -1
- package/dist/chunks/{pivot-result-identity-DRUlTWUq.cjs → pivot-result-identity-BVnhG2rR.cjs} +1 -1
- package/dist/chunks/pivot-result-lifecycle-D_bRCqaB.cjs +1 -0
- package/dist/chunks/{pivot-result-lifecycle-B9FTybxN.js → pivot-result-lifecycle-mjJ1rBvV.js} +7 -7
- package/dist/chunks/{raw-temporal-contract-U8J9RlEH.js → raw-temporal-contract-BuQIB31z.js} +1 -1
- package/dist/chunks/{raw-temporal-contract-D8YuxTAg.cjs → raw-temporal-contract-vnNwLy9R.cjs} +1 -1
- package/dist/chunks/report-preferences-dialog--aV7ITSE.cjs +1 -0
- package/dist/chunks/{report-preferences-dialog-BjygtSP3.js → report-preferences-dialog-DKq0k5BH.js} +25 -25
- package/dist/chunks/{report-runtime-context-DNbgCsko.js → report-runtime-context-B_pAmqxl.js} +1 -1
- package/dist/chunks/{report-runtime-context-RFiWq4wK.cjs → report-runtime-context-BfW4qiMJ.cjs} +1 -1
- package/dist/chunks/{source-entity-resolution-BDC-Qngk.cjs → source-entity-resolution-DCAAS-y8.cjs} +1 -1
- package/dist/chunks/{source-entity-resolution-ugN3sZUk.js → source-entity-resolution-WUstJID6.js} +1 -1
- package/dist/chunks/switch-D12C40LN.cjs +138 -0
- package/dist/chunks/{switch-C8NihGV4.js → switch-LucIPRtD.js} +13142 -11648
- package/dist/chunks/{temporal-bucket-authoring-DJ9kK2wD.js → temporal-bucket-authoring-CyTCHy1K.js} +3 -3
- package/dist/chunks/temporal-bucket-authoring-DueSgLJU.cjs +1 -0
- package/dist/chunks/{temporal-bucket-contract-CZl5D7FZ.js → temporal-bucket-contract-BeOx0uYe.js} +1 -1
- package/dist/chunks/{temporal-bucket-contract-BD862TAa.cjs → temporal-bucket-contract-Cp-usD9Z.cjs} +1 -1
- package/dist/chunks/{token-types-CoHsSJ4E.cjs → token-types-D9eN35rf.cjs} +1 -1
- package/dist/chunks/{token-types-DfDtCqlw.js → token-types-Dvomvqw0.js} +1 -1
- package/dist/chunks/{update-policy-BGNXFgBU.cjs → update-policy-Buw2LmvX.cjs} +1 -1
- package/dist/chunks/{update-policy-BybMiM61.js → update-policy-MWg0aH3d.js} +1 -1
- package/dist/chunks/{validators-D-T-2HOR.js → validators-D3AarM2T.js} +662 -663
- package/dist/chunks/validators-DqIM0B3C.cjs +1 -0
- 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 +81 -79
- package/dist/data-app-builder/index.cjs +1 -1
- package/dist/data-app-builder/index.js +2 -2
- 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 +3 -3
- package/dist/data-app-sdk-adapters/index.cjs +1 -1
- package/dist/data-app-sdk-adapters/index.js +2 -2
- package/dist/data-app-sdk-validation/index.cjs +1 -1
- package/dist/data-app-sdk-validation/index.js +3 -3
- package/dist/format-utils/index.cjs +3 -3
- package/dist/format-utils/index.js +9 -9
- package/dist/index.cjs +1 -1
- package/dist/index.js +177 -176
- package/dist/report-runtime-context/index.cjs +1 -1
- 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/briefings.d.ts +19 -2
- package/dist/types/dashboard-authoring.d.ts +26 -3
- package/dist/types/dashboard.d.ts +20 -3
- package/dist/types/index.cjs +1 -1
- package/dist/types/index.js +4 -4
- package/dist/types/main.d.ts +39 -18
- package/dist/types/shared.d.ts +19 -2
- package/dist/types/surfboard.d.ts +20 -3
- package/dist/types/types.d.ts +20 -3
- package/package.json +1 -1
- package/dist/chunks/dashboard-filter-value-compatibility-BCVF9IHg.js +0 -1026
- package/dist/chunks/dashboard-filter-value-compatibility-DLkdeypb.cjs +0 -1
- package/dist/chunks/dashboard-json-BYQjTmqD.cjs +0 -1
- package/dist/chunks/format-types-PSZZ7hG8.cjs +0 -1
- package/dist/chunks/matrix-result-contract-Bhg60NtS.cjs +0 -1
- package/dist/chunks/pivot-header-presentation-CePk1R6g.cjs +0 -4
- package/dist/chunks/pivot-result-lifecycle-CcGt_29N.cjs +0 -1
- package/dist/chunks/report-preferences-dialog-DW40ECz1.cjs +0 -1
- package/dist/chunks/saved-temporal-bucket-format-DNMtD77o.cjs +0 -1
- package/dist/chunks/switch-B1mZx2k9.cjs +0 -138
- package/dist/chunks/temporal-bucket-9Wz9Ds6H.cjs +0 -1
- package/dist/chunks/temporal-bucket-authoring-DSpzgXHc.cjs +0 -1
- package/dist/chunks/validators-DcshgK7w.cjs +0 -1
|
@@ -1,498 +1,125 @@
|
|
|
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 {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
4
|
+
import { canonicalizeSupportedLocale as O } from "../value-format-preferences/index.js";
|
|
5
|
+
import { ao as I, an as L, am as R, h as U } from "./validators-D3AarM2T.js";
|
|
6
|
+
function g(e) {
|
|
7
|
+
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
8
|
+
return !1;
|
|
9
|
+
const r = Object.getPrototypeOf(e);
|
|
10
|
+
if (r === null || r === Object.prototype) return !0;
|
|
11
|
+
const t = Object.prototype.hasOwnProperty.call(
|
|
12
|
+
r,
|
|
13
|
+
"constructor"
|
|
14
|
+
) ? r.constructor : void 0;
|
|
15
|
+
return typeof t == "function" && Function.prototype.toString.call(t) === Function.prototype.toString.call(Object);
|
|
15
16
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
...e.globalDateComparison.owner ? { owner: e.globalDateComparison.owner } : {}
|
|
26
|
-
};
|
|
17
|
+
const q = {
|
|
18
|
+
dateStyle: "short",
|
|
19
|
+
dateTime: { dateStyle: "short", timeStyle: "short" }
|
|
20
|
+
};
|
|
21
|
+
class _ extends Error {
|
|
22
|
+
constructor(t, o) {
|
|
23
|
+
super(o);
|
|
24
|
+
T(this, "code");
|
|
25
|
+
this.name = "TemporalBucketContractError", this.code = t;
|
|
27
26
|
}
|
|
28
27
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
28
|
+
const G = [
|
|
29
|
+
"Jan",
|
|
30
|
+
"Feb",
|
|
31
|
+
"Mar",
|
|
32
|
+
"Apr",
|
|
33
|
+
"May",
|
|
34
|
+
"Jun",
|
|
35
|
+
"Jul",
|
|
36
|
+
"Aug",
|
|
37
|
+
"Sep",
|
|
38
|
+
"Oct",
|
|
39
|
+
"Nov",
|
|
40
|
+
"Dec"
|
|
41
|
+
], V = [
|
|
42
|
+
"January",
|
|
43
|
+
"February",
|
|
44
|
+
"March",
|
|
45
|
+
"April",
|
|
46
|
+
"May",
|
|
47
|
+
"June",
|
|
48
|
+
"July",
|
|
49
|
+
"August",
|
|
50
|
+
"September",
|
|
51
|
+
"October",
|
|
52
|
+
"November",
|
|
53
|
+
"December"
|
|
54
|
+
];
|
|
55
|
+
function $(e) {
|
|
56
|
+
return {
|
|
57
|
+
ok: !1,
|
|
58
|
+
error: { code: "invalid_temporal_bucket_value", message: e }
|
|
59
|
+
};
|
|
45
60
|
}
|
|
46
|
-
function
|
|
47
|
-
return
|
|
61
|
+
function B(e) {
|
|
62
|
+
return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
|
|
48
63
|
}
|
|
49
|
-
function
|
|
50
|
-
|
|
51
|
-
r.includes(n) || o.push(
|
|
52
|
-
i(
|
|
53
|
-
"invalid_comparison_spec",
|
|
54
|
-
`Comparison kind does not accept field "${n}".`,
|
|
55
|
-
`${t}.${n}`
|
|
56
|
-
)
|
|
57
|
-
);
|
|
58
|
-
});
|
|
64
|
+
function H(e, r) {
|
|
65
|
+
return r === 2 ? B(e) ? 29 : 28 : [4, 6, 9, 11].includes(r) ? 30 : 31;
|
|
59
66
|
}
|
|
60
|
-
function
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"invalid_comparison_spec",
|
|
64
|
-
'Comparison alignment must be "calendar" or "weekday".',
|
|
65
|
-
`${r}.alignment`
|
|
66
|
-
)
|
|
67
|
-
), e.toDate !== void 0 && typeof e.toDate != "boolean" && t.push(
|
|
68
|
-
i(
|
|
69
|
-
"invalid_comparison_spec",
|
|
70
|
-
"Comparison toDate must be a boolean.",
|
|
71
|
-
`${r}.toDate`
|
|
72
|
-
)
|
|
73
|
-
);
|
|
67
|
+
function J(e, r, t) {
|
|
68
|
+
const o = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], n = r < 3 ? e - 1 : e;
|
|
69
|
+
return (n + Math.floor(n / 4) - Math.floor(n / 100) + Math.floor(n / 400) + o[r - 1] + t) % 7;
|
|
74
70
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
"invalid_comparison_spec",
|
|
79
|
-
"Comparison offset must be a positive safe integer.",
|
|
80
|
-
r
|
|
81
|
-
)
|
|
82
|
-
);
|
|
71
|
+
function S(e) {
|
|
72
|
+
var r;
|
|
73
|
+
return (r = e.calendar.fiscalCalendar) == null ? void 0 : r.yearStartMonth;
|
|
83
74
|
}
|
|
84
|
-
function
|
|
85
|
-
|
|
86
|
-
return d(e) ? (e.kind === "previous_period" ? (m(
|
|
87
|
-
e,
|
|
88
|
-
["kind", "offsetPeriods", "alignment", "toDate"],
|
|
89
|
-
r,
|
|
90
|
-
t
|
|
91
|
-
), D(e.offsetPeriods, `${r}.offsetPeriods`, t), M(e, r, t)) : e.kind === "previous_year" ? (m(
|
|
92
|
-
e,
|
|
93
|
-
["kind", "offsetYears", "alignment", "toDate"],
|
|
94
|
-
r,
|
|
95
|
-
t
|
|
96
|
-
), D(e.offsetYears, `${r}.offsetYears`, t), M(e, r, t)) : e.kind === "target" ? (m(e, ["kind", "targetValue"], r, t), (typeof e.targetValue != "number" || !Number.isFinite(e.targetValue)) && t.push(
|
|
97
|
-
i(
|
|
98
|
-
"invalid_comparison_spec",
|
|
99
|
-
"Target comparison requires a finite targetValue.",
|
|
100
|
-
`${r}.targetValue`
|
|
101
|
-
)
|
|
102
|
-
)) : t.push(
|
|
103
|
-
i(
|
|
104
|
-
"invalid_comparison_spec",
|
|
105
|
-
"Comparison kind must be previous_period, previous_year, or target.",
|
|
106
|
-
`${r}.kind`
|
|
107
|
-
)
|
|
108
|
-
), { ok: t.length === 0, errors: t, warnings: [] }) : {
|
|
109
|
-
ok: !1,
|
|
110
|
-
errors: [
|
|
111
|
-
i(
|
|
112
|
-
"invalid_comparison_spec",
|
|
113
|
-
"Comparison spec must be an object.",
|
|
114
|
-
r
|
|
115
|
-
)
|
|
116
|
-
],
|
|
117
|
-
warnings: []
|
|
118
|
-
};
|
|
75
|
+
function Z(e, r) {
|
|
76
|
+
return (e - r + 12) % 12 % 3 === 0;
|
|
119
77
|
}
|
|
120
|
-
function
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
), { ok: t.length === 0, errors: t, warnings: [] };
|
|
78
|
+
function z(e, r) {
|
|
79
|
+
const { granularity: t } = r, o = S(r) ?? 1;
|
|
80
|
+
switch (t) {
|
|
81
|
+
case "second":
|
|
82
|
+
return !0;
|
|
83
|
+
case "minute":
|
|
84
|
+
return e.second === 0;
|
|
85
|
+
case "hour":
|
|
86
|
+
return e.minute === 0 && e.second === 0;
|
|
87
|
+
case "day":
|
|
88
|
+
return !0;
|
|
89
|
+
case "week":
|
|
90
|
+
return J(e.year, e.month, e.day) === r.calendar.weekStart;
|
|
91
|
+
case "month":
|
|
92
|
+
return e.day === 1;
|
|
93
|
+
case "quarter":
|
|
94
|
+
return e.day === 1 && Z(e.month, o);
|
|
95
|
+
case "year":
|
|
96
|
+
return e.day === 1 && e.month === o;
|
|
97
|
+
}
|
|
141
98
|
}
|
|
142
|
-
function
|
|
143
|
-
if (
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
"invalid_global_date_comparison",
|
|
149
|
-
"Global Date comparison selection must be an object.",
|
|
150
|
-
r
|
|
151
|
-
)
|
|
152
|
-
],
|
|
153
|
-
warnings: []
|
|
154
|
-
};
|
|
155
|
-
const t = [];
|
|
156
|
-
if (e.mode === "off")
|
|
157
|
-
m(e, ["mode"], r, t);
|
|
158
|
-
else if (e.mode === "period") {
|
|
159
|
-
m(e, ["mode", "spec"], r, t);
|
|
160
|
-
const o = P(e.spec, `${r}.spec`);
|
|
161
|
-
t.push(...o.errors), d(e.spec) && e.spec.kind === "target" && t.push(
|
|
162
|
-
i(
|
|
163
|
-
"invalid_global_date_comparison",
|
|
164
|
-
"Global Date comparison supports previous_period or previous_year, not target.",
|
|
165
|
-
`${r}.spec.kind`
|
|
166
|
-
)
|
|
167
|
-
);
|
|
168
|
-
} else
|
|
169
|
-
t.push(
|
|
170
|
-
i(
|
|
171
|
-
"invalid_global_date_comparison",
|
|
172
|
-
"Global Date comparison mode must be off or period.",
|
|
173
|
-
`${r}.mode`
|
|
174
|
-
)
|
|
99
|
+
function Q(e, r) {
|
|
100
|
+
if (e === null) return { ok: !0, value: null };
|
|
101
|
+
const t = r.granularity === "second" || r.granularity === "minute" || r.granularity === "hour", o = t ? /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e) : /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
102
|
+
if (!o)
|
|
103
|
+
return $(
|
|
104
|
+
`Expected ${t ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${r.granularity} granularity.`
|
|
175
105
|
);
|
|
176
|
-
|
|
106
|
+
const n = {
|
|
107
|
+
year: Number(o[1]),
|
|
108
|
+
month: Number(o[2]),
|
|
109
|
+
day: Number(o[3]),
|
|
110
|
+
hour: t ? Number(o[4]) : 0,
|
|
111
|
+
minute: t ? Number(o[5]) : 0,
|
|
112
|
+
second: t ? Number(o[6]) : 0
|
|
113
|
+
};
|
|
114
|
+
return n.year < 1 || n.month < 1 || n.month > 12 || n.day < 1 || n.day > H(n.year, n.month) || n.hour > 23 || n.minute > 59 || n.second > 59 ? $(`Invalid canonical ${r.granularity} bucket value ${e}.`) : z(n, r) ? { ok: !0, value: n } : $(
|
|
115
|
+
`Canonical value ${e} is not aligned to ${r.granularity} granularity and its governed Calendar.`
|
|
116
|
+
);
|
|
177
117
|
}
|
|
178
|
-
function
|
|
179
|
-
if (!
|
|
118
|
+
function W(e) {
|
|
119
|
+
if (!g(e))
|
|
180
120
|
return {
|
|
181
121
|
ok: !1,
|
|
182
|
-
|
|
183
|
-
i(
|
|
184
|
-
"invalid_global_date_comparison",
|
|
185
|
-
"Global Date comparison context must be an object.",
|
|
186
|
-
r
|
|
187
|
-
)
|
|
188
|
-
],
|
|
189
|
-
warnings: []
|
|
190
|
-
};
|
|
191
|
-
const t = [];
|
|
192
|
-
return m(
|
|
193
|
-
e,
|
|
194
|
-
["selection", "inheritGlobalComparison", "owner", "referenceTime"],
|
|
195
|
-
r,
|
|
196
|
-
t
|
|
197
|
-
), t.push(
|
|
198
|
-
...V(
|
|
199
|
-
e.selection,
|
|
200
|
-
`${r}.selection`
|
|
201
|
-
).errors
|
|
202
|
-
), e.inheritGlobalComparison !== void 0 && e.inheritGlobalComparison !== !1 && t.push(
|
|
203
|
-
i(
|
|
204
|
-
"invalid_global_date_comparison",
|
|
205
|
-
"inheritGlobalComparison may only be false when present.",
|
|
206
|
-
`${r}.inheritGlobalComparison`
|
|
207
|
-
)
|
|
208
|
-
), e.owner !== void 0 && (d(e.owner) ? e.owner.kind === "global_date" ? m(e.owner, ["kind"], `${r}.owner`, t) : e.owner.kind === "field_date" ? (m(
|
|
209
|
-
e.owner,
|
|
210
|
-
["kind", "filterId", "label"],
|
|
211
|
-
`${r}.owner`,
|
|
212
|
-
t
|
|
213
|
-
), (typeof e.owner.filterId != "string" || !e.owner.filterId.trim()) && t.push(
|
|
214
|
-
i(
|
|
215
|
-
"invalid_global_date_comparison",
|
|
216
|
-
"Field Date comparison owner requires a non-empty filterId.",
|
|
217
|
-
`${r}.owner.filterId`
|
|
218
|
-
)
|
|
219
|
-
), (typeof e.owner.label != "string" || !e.owner.label.trim()) && t.push(
|
|
220
|
-
i(
|
|
221
|
-
"invalid_global_date_comparison",
|
|
222
|
-
"Field Date comparison owner requires a non-empty label.",
|
|
223
|
-
`${r}.owner.label`
|
|
224
|
-
)
|
|
225
|
-
)) : t.push(
|
|
226
|
-
i(
|
|
227
|
-
"invalid_global_date_comparison",
|
|
228
|
-
"Comparison owner kind must be global_date or field_date.",
|
|
229
|
-
`${r}.owner.kind`
|
|
230
|
-
)
|
|
231
|
-
) : t.push(
|
|
232
|
-
i(
|
|
233
|
-
"invalid_global_date_comparison",
|
|
234
|
-
"Comparison owner must be an object.",
|
|
235
|
-
`${r}.owner`
|
|
236
|
-
)
|
|
237
|
-
)), e.referenceTime !== void 0 && (typeof e.referenceTime != "string" || !G(e.referenceTime)) && t.push(
|
|
238
|
-
i(
|
|
239
|
-
"invalid_global_date_comparison",
|
|
240
|
-
"referenceTime must be a valid ISO date-time string when present.",
|
|
241
|
-
`${r}.referenceTime`
|
|
242
|
-
)
|
|
243
|
-
), { ok: t.length === 0, errors: t, warnings: [] };
|
|
244
|
-
}
|
|
245
|
-
function _e(e, r = "comparisonPolarity") {
|
|
246
|
-
return e === "higher_is_better" || e === "lower_is_better" || e === "neutral" ? { ok: !0, errors: [], warnings: [] } : {
|
|
247
|
-
ok: !1,
|
|
248
|
-
errors: [
|
|
249
|
-
i(
|
|
250
|
-
"invalid_comparison_polarity",
|
|
251
|
-
"Comparison polarity must be higher_is_better, lower_is_better, or neutral.",
|
|
252
|
-
r
|
|
253
|
-
)
|
|
254
|
-
],
|
|
255
|
-
warnings: []
|
|
256
|
-
};
|
|
257
|
-
}
|
|
258
|
-
function he(e, r = "comparisonPresentation") {
|
|
259
|
-
if (!d(e))
|
|
260
|
-
return {
|
|
261
|
-
ok: !1,
|
|
262
|
-
errors: [
|
|
263
|
-
i(
|
|
264
|
-
"invalid_comparison_presentation",
|
|
265
|
-
"Comparison presentation must be an object.",
|
|
266
|
-
r
|
|
267
|
-
)
|
|
268
|
-
],
|
|
269
|
-
warnings: []
|
|
270
|
-
};
|
|
271
|
-
const t = [], o = [
|
|
272
|
-
"displayMode",
|
|
273
|
-
"showComparison",
|
|
274
|
-
"precision",
|
|
275
|
-
"indicatorStyle",
|
|
276
|
-
"showColor",
|
|
277
|
-
"position",
|
|
278
|
-
"conditionalLabel",
|
|
279
|
-
"labelName",
|
|
280
|
-
"conditionalLabels",
|
|
281
|
-
"colors"
|
|
282
|
-
];
|
|
283
|
-
return Object.keys(e).forEach((a) => {
|
|
284
|
-
o.includes(a) || t.push(
|
|
285
|
-
i(
|
|
286
|
-
"invalid_comparison_presentation",
|
|
287
|
-
`Comparison presentation does not accept field "${a}".`,
|
|
288
|
-
`${r}.${a}`
|
|
289
|
-
)
|
|
290
|
-
);
|
|
291
|
-
}), [
|
|
292
|
-
["displayMode", ["difference", "percent_change", "both", "ratio"]],
|
|
293
|
-
["indicatorStyle", ["arrow_badge", "arrow", "badge", "none"]],
|
|
294
|
-
["position", ["left", "right", "top"]]
|
|
295
|
-
].forEach(([a, s]) => {
|
|
296
|
-
e[a] !== void 0 && !s.includes(e[a]) && t.push(
|
|
297
|
-
i(
|
|
298
|
-
"invalid_comparison_presentation",
|
|
299
|
-
`Comparison presentation ${a} is invalid.`,
|
|
300
|
-
`${r}.${a}`
|
|
301
|
-
)
|
|
302
|
-
);
|
|
303
|
-
}), ["showComparison", "showColor", "conditionalLabel"].forEach((a) => {
|
|
304
|
-
e[a] !== void 0 && typeof e[a] != "boolean" && t.push(
|
|
305
|
-
i(
|
|
306
|
-
"invalid_comparison_presentation",
|
|
307
|
-
`Comparison presentation ${a} must be a boolean.`,
|
|
308
|
-
`${r}.${a}`
|
|
309
|
-
)
|
|
310
|
-
);
|
|
311
|
-
}), e.precision !== void 0 && (typeof e.precision != "number" || !Number.isInteger(e.precision) || e.precision < 0 || e.precision > 6) && t.push(
|
|
312
|
-
i(
|
|
313
|
-
"invalid_comparison_presentation",
|
|
314
|
-
"Comparison presentation precision must be an integer from 0 through 6.",
|
|
315
|
-
`${r}.precision`
|
|
316
|
-
)
|
|
317
|
-
), e.labelName !== void 0 && typeof e.labelName != "string" && t.push(
|
|
318
|
-
i(
|
|
319
|
-
"invalid_comparison_presentation",
|
|
320
|
-
"Comparison presentation labelName must be a string.",
|
|
321
|
-
`${r}.labelName`
|
|
322
|
-
)
|
|
323
|
-
), ["conditionalLabels", "colors"].forEach((a) => {
|
|
324
|
-
const s = e[a];
|
|
325
|
-
if (s !== void 0) {
|
|
326
|
-
if (!d(s)) {
|
|
327
|
-
t.push(
|
|
328
|
-
i(
|
|
329
|
-
"invalid_comparison_presentation",
|
|
330
|
-
`Comparison presentation ${a} must be an object.`,
|
|
331
|
-
`${r}.${a}`
|
|
332
|
-
)
|
|
333
|
-
);
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
Object.keys(s).forEach((l) => {
|
|
337
|
-
["increase", "decrease", "neutral"].includes(l) || t.push(
|
|
338
|
-
i(
|
|
339
|
-
"invalid_comparison_presentation",
|
|
340
|
-
`Comparison presentation ${a} does not accept field "${l}".`,
|
|
341
|
-
`${r}.${a}.${l}`
|
|
342
|
-
)
|
|
343
|
-
);
|
|
344
|
-
}), Object.entries(s).forEach(([l, c]) => {
|
|
345
|
-
c !== void 0 && typeof c != "string" && t.push(
|
|
346
|
-
i(
|
|
347
|
-
"invalid_comparison_presentation",
|
|
348
|
-
`Comparison presentation ${a}.${l} must be a string.`,
|
|
349
|
-
`${r}.${a}.${l}`
|
|
350
|
-
)
|
|
351
|
-
);
|
|
352
|
-
});
|
|
353
|
-
}
|
|
354
|
-
}), { ok: t.length === 0, errors: t, warnings: [] };
|
|
355
|
-
}
|
|
356
|
-
function B(e) {
|
|
357
|
-
return e === null ? "unknown" : e > 0 ? "increase" : e < 0 ? "decrease" : "no_change";
|
|
358
|
-
}
|
|
359
|
-
function H(e, r) {
|
|
360
|
-
return e === "unknown" || e === "no_change" || r === "neutral" ? "neutral" : r === "higher_is_better" && e === "increase" || r === "lower_is_better" && e === "decrease" ? "favorable" : "unfavorable";
|
|
361
|
-
}
|
|
362
|
-
function we(e) {
|
|
363
|
-
const {
|
|
364
|
-
currentValue: r,
|
|
365
|
-
comparisonValue: t,
|
|
366
|
-
polarity: o = q
|
|
367
|
-
} = e, a = r !== null && t !== null ? r - t : null, s = a !== null && t !== null && t !== 0 ? a / Math.abs(t) : null, l = r !== null && t !== null && t !== 0 ? r / t : null, c = B(a);
|
|
368
|
-
return {
|
|
369
|
-
status: t === null ? "insufficient_history" : "available",
|
|
370
|
-
currentValue: r,
|
|
371
|
-
comparisonValue: t,
|
|
372
|
-
delta: a,
|
|
373
|
-
percentChange: s,
|
|
374
|
-
ratio: l,
|
|
375
|
-
direction: c,
|
|
376
|
-
sentiment: H(c, o)
|
|
377
|
-
};
|
|
378
|
-
}
|
|
379
|
-
function g(e) {
|
|
380
|
-
if (e === null || typeof e != "object" || Array.isArray(e))
|
|
381
|
-
return !1;
|
|
382
|
-
const r = Object.getPrototypeOf(e);
|
|
383
|
-
if (r === null || r === Object.prototype) return !0;
|
|
384
|
-
const t = Object.prototype.hasOwnProperty.call(
|
|
385
|
-
r,
|
|
386
|
-
"constructor"
|
|
387
|
-
) ? r.constructor : void 0;
|
|
388
|
-
return typeof t == "function" && Function.prototype.toString.call(t) === Function.prototype.toString.call(Object);
|
|
389
|
-
}
|
|
390
|
-
const J = {
|
|
391
|
-
dateStyle: "short",
|
|
392
|
-
dateTime: { dateStyle: "short", timeStyle: "short" }
|
|
393
|
-
};
|
|
394
|
-
class _ extends Error {
|
|
395
|
-
constructor(t, o) {
|
|
396
|
-
super(o);
|
|
397
|
-
T(this, "code");
|
|
398
|
-
this.name = "TemporalBucketContractError", this.code = t;
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
const Z = [
|
|
402
|
-
"Jan",
|
|
403
|
-
"Feb",
|
|
404
|
-
"Mar",
|
|
405
|
-
"Apr",
|
|
406
|
-
"May",
|
|
407
|
-
"Jun",
|
|
408
|
-
"Jul",
|
|
409
|
-
"Aug",
|
|
410
|
-
"Sep",
|
|
411
|
-
"Oct",
|
|
412
|
-
"Nov",
|
|
413
|
-
"Dec"
|
|
414
|
-
], z = [
|
|
415
|
-
"January",
|
|
416
|
-
"February",
|
|
417
|
-
"March",
|
|
418
|
-
"April",
|
|
419
|
-
"May",
|
|
420
|
-
"June",
|
|
421
|
-
"July",
|
|
422
|
-
"August",
|
|
423
|
-
"September",
|
|
424
|
-
"October",
|
|
425
|
-
"November",
|
|
426
|
-
"December"
|
|
427
|
-
];
|
|
428
|
-
function $(e) {
|
|
429
|
-
return {
|
|
430
|
-
ok: !1,
|
|
431
|
-
error: { code: "invalid_temporal_bucket_value", message: e }
|
|
432
|
-
};
|
|
433
|
-
}
|
|
434
|
-
function Q(e) {
|
|
435
|
-
return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
|
|
436
|
-
}
|
|
437
|
-
function W(e, r) {
|
|
438
|
-
return r === 2 ? Q(e) ? 29 : 28 : [4, 6, 9, 11].includes(r) ? 30 : 31;
|
|
439
|
-
}
|
|
440
|
-
function K(e, r, t) {
|
|
441
|
-
const o = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], n = r < 3 ? e - 1 : e;
|
|
442
|
-
return (n + Math.floor(n / 4) - Math.floor(n / 100) + Math.floor(n / 400) + o[r - 1] + t) % 7;
|
|
443
|
-
}
|
|
444
|
-
function S(e) {
|
|
445
|
-
var r;
|
|
446
|
-
return (r = e.calendar.fiscalCalendar) == null ? void 0 : r.yearStartMonth;
|
|
447
|
-
}
|
|
448
|
-
function X(e, r) {
|
|
449
|
-
return (e - r + 12) % 12 % 3 === 0;
|
|
450
|
-
}
|
|
451
|
-
function ee(e, r) {
|
|
452
|
-
const { granularity: t } = r, o = S(r) ?? 1;
|
|
453
|
-
switch (t) {
|
|
454
|
-
case "second":
|
|
455
|
-
return !0;
|
|
456
|
-
case "minute":
|
|
457
|
-
return e.second === 0;
|
|
458
|
-
case "hour":
|
|
459
|
-
return e.minute === 0 && e.second === 0;
|
|
460
|
-
case "day":
|
|
461
|
-
return !0;
|
|
462
|
-
case "week":
|
|
463
|
-
return K(e.year, e.month, e.day) === r.calendar.weekStart;
|
|
464
|
-
case "month":
|
|
465
|
-
return e.day === 1;
|
|
466
|
-
case "quarter":
|
|
467
|
-
return e.day === 1 && X(e.month, o);
|
|
468
|
-
case "year":
|
|
469
|
-
return e.day === 1 && e.month === o;
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
function re(e, r) {
|
|
473
|
-
if (e === null) return { ok: !0, value: null };
|
|
474
|
-
const t = r.granularity === "second" || r.granularity === "minute" || r.granularity === "hour", o = t ? /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e) : /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
|
|
475
|
-
if (!o)
|
|
476
|
-
return $(
|
|
477
|
-
`Expected ${t ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${r.granularity} granularity.`
|
|
478
|
-
);
|
|
479
|
-
const n = {
|
|
480
|
-
year: Number(o[1]),
|
|
481
|
-
month: Number(o[2]),
|
|
482
|
-
day: Number(o[3]),
|
|
483
|
-
hour: t ? Number(o[4]) : 0,
|
|
484
|
-
minute: t ? Number(o[5]) : 0,
|
|
485
|
-
second: t ? Number(o[6]) : 0
|
|
486
|
-
};
|
|
487
|
-
return n.year < 1 || n.month < 1 || n.month > 12 || n.day < 1 || n.day > W(n.year, n.month) || n.hour > 23 || n.minute > 59 || n.second > 59 ? $(`Invalid canonical ${r.granularity} bucket value ${e}.`) : ee(n, r) ? { ok: !0, value: n } : $(
|
|
488
|
-
`Canonical value ${e} is not aligned to ${r.granularity} granularity and its governed Calendar.`
|
|
489
|
-
);
|
|
490
|
-
}
|
|
491
|
-
function te(e) {
|
|
492
|
-
if (!g(e))
|
|
493
|
-
return {
|
|
494
|
-
ok: !1,
|
|
495
|
-
issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
|
|
122
|
+
issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
|
|
496
123
|
};
|
|
497
124
|
const r = [], t = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
|
|
498
125
|
for (const s of Object.keys(e))
|
|
@@ -509,12 +136,12 @@ function te(e) {
|
|
|
509
136
|
message: `Unknown property "${c}".`
|
|
510
137
|
});
|
|
511
138
|
if (s === "preset")
|
|
512
|
-
|
|
139
|
+
L(o.preset) || r.push({ path: "presentation.preset", message: "Expected a supported preset." });
|
|
513
140
|
else if (s === "pattern")
|
|
514
141
|
if (typeof o.pattern != "string" || !o.pattern)
|
|
515
142
|
r.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
|
|
516
143
|
else {
|
|
517
|
-
const c =
|
|
144
|
+
const c = I(o.pattern);
|
|
518
145
|
c.ok || r.push({
|
|
519
146
|
path: "presentation.pattern",
|
|
520
147
|
message: c.message
|
|
@@ -537,7 +164,7 @@ function te(e) {
|
|
|
537
164
|
} else
|
|
538
165
|
r.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
|
|
539
166
|
}
|
|
540
|
-
const n =
|
|
167
|
+
const n = O(e.locale);
|
|
541
168
|
if (n || r.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), r.length > 0 || !n || !g(o))
|
|
542
169
|
return { ok: !1, issues: r };
|
|
543
170
|
if (o.mode === "auto") {
|
|
@@ -560,251 +187,624 @@ function te(e) {
|
|
|
560
187
|
}
|
|
561
188
|
};
|
|
562
189
|
}
|
|
563
|
-
return {
|
|
564
|
-
ok: !0,
|
|
565
|
-
value: {
|
|
566
|
-
type: "temporal_bucket",
|
|
567
|
-
presentation: o.mode === "preset" ? {
|
|
568
|
-
mode: "preset",
|
|
569
|
-
preset: o.preset
|
|
570
|
-
} : {
|
|
571
|
-
mode: "pattern",
|
|
572
|
-
pattern: o.pattern
|
|
573
|
-
},
|
|
574
|
-
locale: n
|
|
575
|
-
}
|
|
576
|
-
};
|
|
190
|
+
return {
|
|
191
|
+
ok: !0,
|
|
192
|
+
value: {
|
|
193
|
+
type: "temporal_bucket",
|
|
194
|
+
presentation: o.mode === "preset" ? {
|
|
195
|
+
mode: "preset",
|
|
196
|
+
preset: o.preset
|
|
197
|
+
} : {
|
|
198
|
+
mode: "pattern",
|
|
199
|
+
pattern: o.pattern
|
|
200
|
+
},
|
|
201
|
+
locale: n
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
function K(e, r) {
|
|
206
|
+
const t = !!r.calendar.fiscalCalendar;
|
|
207
|
+
return e === "fiscal_quarter_short" || e === "fiscal_year" ? t : e === "quarter_short" || e === "quarter_long" ? !t : !0;
|
|
208
|
+
}
|
|
209
|
+
function P(e, r) {
|
|
210
|
+
return R(e, r.granularity).ok ? e.presentation.mode === "preset" ? K(e.presentation.preset, r) : !(e.presentation.mode === "pattern" && r.calendar.fiscalCalendar && (r.granularity === "quarter" || r.granularity === "year")) : !1;
|
|
211
|
+
}
|
|
212
|
+
function M(e, r) {
|
|
213
|
+
if (!(!e || e.presentation.mode === "auto"))
|
|
214
|
+
return P(e, r) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
|
|
215
|
+
}
|
|
216
|
+
function fe(e) {
|
|
217
|
+
var n;
|
|
218
|
+
const r = O(e.locale);
|
|
219
|
+
if (!r)
|
|
220
|
+
throw new _(
|
|
221
|
+
"invalid_temporal_bucket_format",
|
|
222
|
+
"Temporal bucket locale must be a supported base BCP 47 locale."
|
|
223
|
+
);
|
|
224
|
+
const t = M(e.cardFormat, e.metadata);
|
|
225
|
+
if (t)
|
|
226
|
+
return { format: { ...t, locale: r }, source: "card" };
|
|
227
|
+
const o = ((n = e.semanticFormat) == null ? void 0 : n.granularity) === e.metadata.granularity ? M(e.semanticFormat.format, e.metadata) : void 0;
|
|
228
|
+
return o ? { format: { ...o, locale: r }, source: "semantic" } : {
|
|
229
|
+
format: {
|
|
230
|
+
type: "temporal_bucket",
|
|
231
|
+
locale: r,
|
|
232
|
+
presentation: {
|
|
233
|
+
mode: "auto",
|
|
234
|
+
styles: e.styles ?? q
|
|
235
|
+
}
|
|
236
|
+
},
|
|
237
|
+
source: "automatic"
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
function p(e, r = 2) {
|
|
241
|
+
return String(e).padStart(r, "0");
|
|
242
|
+
}
|
|
243
|
+
function h(e, r, t) {
|
|
244
|
+
if (r === "en-US")
|
|
245
|
+
return (t === "short" ? G : V)[e - 1];
|
|
246
|
+
const o = new Date(Date.UTC(2e3, e - 1, 15));
|
|
247
|
+
return new Intl.DateTimeFormat(r, {
|
|
248
|
+
calendar: "gregory",
|
|
249
|
+
month: t,
|
|
250
|
+
timeZone: "UTC"
|
|
251
|
+
}).format(o);
|
|
252
|
+
}
|
|
253
|
+
function X(e, r, t) {
|
|
254
|
+
return r.map((o) => {
|
|
255
|
+
if (o.kind === "literal") return o.value;
|
|
256
|
+
switch (o.value) {
|
|
257
|
+
case "YYYY":
|
|
258
|
+
return p(e.year, 4);
|
|
259
|
+
case "YY":
|
|
260
|
+
return p(e.year % 100);
|
|
261
|
+
case "MMMM":
|
|
262
|
+
return h(e.month, t, "long");
|
|
263
|
+
case "MMM":
|
|
264
|
+
return h(e.month, t, "short");
|
|
265
|
+
case "MM":
|
|
266
|
+
return p(e.month);
|
|
267
|
+
case "DD":
|
|
268
|
+
return p(e.day);
|
|
269
|
+
case "HH":
|
|
270
|
+
return p(e.hour);
|
|
271
|
+
case "mm":
|
|
272
|
+
return p(e.minute);
|
|
273
|
+
case "ss":
|
|
274
|
+
return p(e.second);
|
|
275
|
+
}
|
|
276
|
+
}).join("");
|
|
277
|
+
}
|
|
278
|
+
const D = /* @__PURE__ */ new Map();
|
|
279
|
+
function y(e, r) {
|
|
280
|
+
const t = `${e}:${JSON.stringify(r)}`, o = D.get(t);
|
|
281
|
+
if (o) return o;
|
|
282
|
+
const n = new Intl.DateTimeFormat(e, r);
|
|
283
|
+
return D.set(t, n), n;
|
|
284
|
+
}
|
|
285
|
+
function w(e) {
|
|
286
|
+
const r = /* @__PURE__ */ new Date(0);
|
|
287
|
+
return r.setUTCFullYear(e.year, e.month - 1, e.day), r.setUTCHours(e.hour, e.minute, e.second, 0), r;
|
|
288
|
+
}
|
|
289
|
+
function v(e, r, t) {
|
|
290
|
+
return y(r, {
|
|
291
|
+
calendar: "gregory",
|
|
292
|
+
dateStyle: t,
|
|
293
|
+
timeZone: "UTC"
|
|
294
|
+
}).format(w(e));
|
|
295
|
+
}
|
|
296
|
+
function ee(e, r, t) {
|
|
297
|
+
return y(r, {
|
|
298
|
+
calendar: "gregory",
|
|
299
|
+
dateStyle: t.dateStyle,
|
|
300
|
+
// Grouped buckets are civil values, not instants. Long time styles would
|
|
301
|
+
// append a zone label that the canonical value does not semantically own.
|
|
302
|
+
timeStyle: t.timeStyle === "long" ? "medium" : t.timeStyle,
|
|
303
|
+
timeZone: "UTC"
|
|
304
|
+
}).format(w(e));
|
|
305
|
+
}
|
|
306
|
+
function re(e, r, t) {
|
|
307
|
+
var n;
|
|
308
|
+
if (t === "short") {
|
|
309
|
+
const a = w(e), s = y(r, {
|
|
310
|
+
calendar: "gregory",
|
|
311
|
+
dateStyle: "short",
|
|
312
|
+
timeZone: "UTC"
|
|
313
|
+
}).formatToParts(a), l = s.findIndex((f) => f.type === "month"), c = s.findIndex((f) => f.type === "year"), u = (n = y(r, {
|
|
314
|
+
calendar: "gregory",
|
|
315
|
+
timeZone: "UTC",
|
|
316
|
+
year: "numeric"
|
|
317
|
+
}).formatToParts(a).find((f) => f.type === "year")) == null ? void 0 : n.value;
|
|
318
|
+
if (l >= 0 && c >= 0 && u) {
|
|
319
|
+
const f = Math.min(l, c), x = Math.max(l, c);
|
|
320
|
+
let C = !1;
|
|
321
|
+
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("");
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
return y(r, {
|
|
325
|
+
calendar: "gregory",
|
|
326
|
+
month: t === "short" ? "numeric" : t === "medium" ? "short" : "long",
|
|
327
|
+
timeZone: "UTC",
|
|
328
|
+
year: "numeric"
|
|
329
|
+
}).format(w(e));
|
|
330
|
+
}
|
|
331
|
+
function te(e, r) {
|
|
332
|
+
return Math.floor((e.month - r + 12) % 12 / 3) + 1;
|
|
333
|
+
}
|
|
334
|
+
function N(e, r) {
|
|
335
|
+
return r === 1 || e.month < r ? e.year : e.year + 1;
|
|
336
|
+
}
|
|
337
|
+
function oe(e) {
|
|
338
|
+
return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
|
|
339
|
+
}
|
|
340
|
+
function k(e, r, t, o) {
|
|
341
|
+
const n = S(o) ?? 1, a = te(e, n);
|
|
342
|
+
switch (r) {
|
|
343
|
+
case "week_of_short":
|
|
344
|
+
return `Week of ${h(e.month, t, "short")} ${e.day}, ${e.year}`;
|
|
345
|
+
case "week_of_long":
|
|
346
|
+
return `Week of ${h(e.month, t, "long")} ${e.day}, ${e.year}`;
|
|
347
|
+
case "quarter_short":
|
|
348
|
+
return `Q${a} ${e.year}`;
|
|
349
|
+
case "quarter_long":
|
|
350
|
+
return `${oe(a)} Quarter ${e.year}`;
|
|
351
|
+
case "fiscal_quarter_short":
|
|
352
|
+
return `Q${a} FY${N(e, n)}`;
|
|
353
|
+
case "fiscal_year":
|
|
354
|
+
return `FY${N(e, n)}`;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
function ne(e, r, t, o) {
|
|
358
|
+
const n = S(r);
|
|
359
|
+
switch (r.granularity) {
|
|
360
|
+
case "second":
|
|
361
|
+
case "minute":
|
|
362
|
+
case "hour":
|
|
363
|
+
return ee(e, t, o.dateTime);
|
|
364
|
+
case "day":
|
|
365
|
+
return v(e, t, o.dateStyle);
|
|
366
|
+
case "week":
|
|
367
|
+
return `Week of ${v(e, t, o.dateStyle)}`;
|
|
368
|
+
case "month":
|
|
369
|
+
return re(e, t, o.dateStyle);
|
|
370
|
+
case "quarter":
|
|
371
|
+
return k(
|
|
372
|
+
e,
|
|
373
|
+
n ? "fiscal_quarter_short" : "quarter_short",
|
|
374
|
+
t,
|
|
375
|
+
r
|
|
376
|
+
);
|
|
377
|
+
case "year":
|
|
378
|
+
return n ? k(e, "fiscal_year", t, r) : String(e.year);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function pe(e) {
|
|
382
|
+
const r = W(e.format);
|
|
383
|
+
if (!r.ok || !P(r.value, e.metadata))
|
|
384
|
+
throw new _(
|
|
385
|
+
"invalid_temporal_bucket_format",
|
|
386
|
+
"Resolved temporal bucket format is invalid or inapplicable to its metadata."
|
|
387
|
+
);
|
|
388
|
+
const t = Q(e.value, e.metadata);
|
|
389
|
+
if (!t.ok)
|
|
390
|
+
throw new _(
|
|
391
|
+
t.error.code,
|
|
392
|
+
t.error.message
|
|
393
|
+
);
|
|
394
|
+
if (t.value === null) return "(Blank)";
|
|
395
|
+
const { presentation: o, locale: n } = r.value;
|
|
396
|
+
if (o.mode === "auto")
|
|
397
|
+
return ne(
|
|
398
|
+
t.value,
|
|
399
|
+
e.metadata,
|
|
400
|
+
n,
|
|
401
|
+
o.styles
|
|
402
|
+
);
|
|
403
|
+
if (o.mode === "preset")
|
|
404
|
+
return k(
|
|
405
|
+
t.value,
|
|
406
|
+
o.preset,
|
|
407
|
+
n,
|
|
408
|
+
e.metadata
|
|
409
|
+
);
|
|
410
|
+
const a = I(o.pattern);
|
|
411
|
+
if (!a.ok)
|
|
412
|
+
throw new _(
|
|
413
|
+
"invalid_temporal_bucket_format",
|
|
414
|
+
a.message
|
|
415
|
+
);
|
|
416
|
+
return X(t.value, a.segments, n);
|
|
417
|
+
}
|
|
418
|
+
const ae = "higher_is_better", be = {
|
|
419
|
+
displayMode: "difference",
|
|
420
|
+
showComparison: !0,
|
|
421
|
+
indicatorStyle: "arrow_badge",
|
|
422
|
+
showColor: !0,
|
|
423
|
+
conditionalLabel: !1
|
|
424
|
+
};
|
|
425
|
+
function ie(e) {
|
|
426
|
+
return U(e) !== null;
|
|
427
|
+
}
|
|
428
|
+
function ge(e) {
|
|
429
|
+
var r, t, o, n;
|
|
430
|
+
if (((r = e.metricComparison) == null ? void 0 : r.mode) !== "off") {
|
|
431
|
+
if (((t = e.metricComparison) == null ? void 0 : t.mode) === "explicit")
|
|
432
|
+
return { source: "explicit", spec: e.metricComparison.spec };
|
|
433
|
+
if (!((e.inheritGlobalComparison ?? ((o = e.globalDateComparison) == null ? void 0 : o.inheritGlobalComparison)) === !1 || ((n = e.globalDateComparison) == null ? void 0 : n.selection.mode) !== "period"))
|
|
434
|
+
return {
|
|
435
|
+
source: "inherited",
|
|
436
|
+
spec: e.globalDateComparison.selection.spec,
|
|
437
|
+
...e.globalDateComparison.owner ? { owner: e.globalDateComparison.owner } : {}
|
|
438
|
+
};
|
|
439
|
+
}
|
|
577
440
|
}
|
|
578
|
-
function
|
|
579
|
-
|
|
580
|
-
|
|
441
|
+
function ye(e) {
|
|
442
|
+
if (e.alias) return e.alias;
|
|
443
|
+
const r = e.entityName && e.entityName !== "SEMAPHOR_CALCULATED_FIELD" ? e.entityName : void 0, t = r && r !== e.name ? `${r}_` : "";
|
|
444
|
+
if (e.role !== "metric") return `${t}${e.name}`;
|
|
445
|
+
let o = e.aggregate || "metric";
|
|
446
|
+
if (e.expression) {
|
|
447
|
+
const n = e.expression.match(
|
|
448
|
+
/^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i
|
|
449
|
+
);
|
|
450
|
+
o = n ? n[1].toLowerCase() : "expr";
|
|
451
|
+
} else
|
|
452
|
+
o = o.toLowerCase();
|
|
453
|
+
return `${t}${e.name}_${o}`;
|
|
581
454
|
}
|
|
582
|
-
function
|
|
583
|
-
return
|
|
455
|
+
function i(e, r, t) {
|
|
456
|
+
return t ? { code: e, message: r, path: t } : { code: e, message: r };
|
|
584
457
|
}
|
|
585
|
-
function
|
|
586
|
-
|
|
587
|
-
return F(e, r) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
|
|
458
|
+
function d(e) {
|
|
459
|
+
return !!e && typeof e == "object" && !Array.isArray(e);
|
|
588
460
|
}
|
|
589
|
-
function
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
461
|
+
function m(e, r, t, o) {
|
|
462
|
+
Object.keys(e).forEach((n) => {
|
|
463
|
+
r.includes(n) || o.push(
|
|
464
|
+
i(
|
|
465
|
+
"invalid_comparison_spec",
|
|
466
|
+
`Comparison kind does not accept field "${n}".`,
|
|
467
|
+
`${t}.${n}`
|
|
468
|
+
)
|
|
596
469
|
);
|
|
597
|
-
|
|
598
|
-
if (t)
|
|
599
|
-
return { format: { ...t, locale: r }, source: "card" };
|
|
600
|
-
const o = ((n = e.semanticFormat) == null ? void 0 : n.granularity) === e.metadata.granularity ? v(e.semanticFormat.format, e.metadata) : void 0;
|
|
601
|
-
return o ? { format: { ...o, locale: r }, source: "semantic" } : {
|
|
602
|
-
format: {
|
|
603
|
-
type: "temporal_bucket",
|
|
604
|
-
locale: r,
|
|
605
|
-
presentation: {
|
|
606
|
-
mode: "auto",
|
|
607
|
-
styles: e.styles ?? J
|
|
608
|
-
}
|
|
609
|
-
},
|
|
610
|
-
source: "automatic"
|
|
611
|
-
};
|
|
470
|
+
});
|
|
612
471
|
}
|
|
613
|
-
function
|
|
614
|
-
|
|
472
|
+
function A(e, r, t) {
|
|
473
|
+
e.alignment !== void 0 && e.alignment !== "calendar" && e.alignment !== "weekday" && t.push(
|
|
474
|
+
i(
|
|
475
|
+
"invalid_comparison_spec",
|
|
476
|
+
'Comparison alignment must be "calendar" or "weekday".',
|
|
477
|
+
`${r}.alignment`
|
|
478
|
+
)
|
|
479
|
+
), e.toDate !== void 0 && typeof e.toDate != "boolean" && t.push(
|
|
480
|
+
i(
|
|
481
|
+
"invalid_comparison_spec",
|
|
482
|
+
"Comparison toDate must be a boolean.",
|
|
483
|
+
`${r}.toDate`
|
|
484
|
+
)
|
|
485
|
+
);
|
|
615
486
|
}
|
|
616
|
-
function
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
}).format(o);
|
|
487
|
+
function E(e, r, t) {
|
|
488
|
+
e !== void 0 && (typeof e != "number" || !Number.isSafeInteger(e) || e <= 0) && t.push(
|
|
489
|
+
i(
|
|
490
|
+
"invalid_comparison_spec",
|
|
491
|
+
"Comparison offset must be a positive safe integer.",
|
|
492
|
+
r
|
|
493
|
+
)
|
|
494
|
+
);
|
|
625
495
|
}
|
|
626
|
-
function
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
496
|
+
function F(e, r = "comparison") {
|
|
497
|
+
const t = [];
|
|
498
|
+
return d(e) ? (e.kind === "previous_period" ? (m(
|
|
499
|
+
e,
|
|
500
|
+
["kind", "offsetPeriods", "alignment", "toDate"],
|
|
501
|
+
r,
|
|
502
|
+
t
|
|
503
|
+
), E(e.offsetPeriods, `${r}.offsetPeriods`, t), A(e, r, t)) : e.kind === "previous_year" ? (m(
|
|
504
|
+
e,
|
|
505
|
+
["kind", "offsetYears", "alignment", "toDate"],
|
|
506
|
+
r,
|
|
507
|
+
t
|
|
508
|
+
), E(e.offsetYears, `${r}.offsetYears`, t), A(e, r, t)) : e.kind === "target" ? (m(e, ["kind", "targetValue"], r, t), (typeof e.targetValue != "number" || !Number.isFinite(e.targetValue)) && t.push(
|
|
509
|
+
i(
|
|
510
|
+
"invalid_comparison_spec",
|
|
511
|
+
"Target comparison requires a finite targetValue.",
|
|
512
|
+
`${r}.targetValue`
|
|
513
|
+
)
|
|
514
|
+
)) : t.push(
|
|
515
|
+
i(
|
|
516
|
+
"invalid_comparison_spec",
|
|
517
|
+
"Comparison kind must be previous_period, previous_year, or target.",
|
|
518
|
+
`${r}.kind`
|
|
519
|
+
)
|
|
520
|
+
), { ok: t.length === 0, errors: t, warnings: [] }) : {
|
|
521
|
+
ok: !1,
|
|
522
|
+
errors: [
|
|
523
|
+
i(
|
|
524
|
+
"invalid_comparison_spec",
|
|
525
|
+
"Comparison spec must be an object.",
|
|
526
|
+
r
|
|
527
|
+
)
|
|
528
|
+
],
|
|
529
|
+
warnings: []
|
|
530
|
+
};
|
|
650
531
|
}
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
532
|
+
function _e(e, r = "comparison") {
|
|
533
|
+
if (!d(e))
|
|
534
|
+
return {
|
|
535
|
+
ok: !1,
|
|
536
|
+
errors: [
|
|
537
|
+
i(
|
|
538
|
+
"invalid_comparison_config",
|
|
539
|
+
"Comparison config must be an object.",
|
|
540
|
+
r
|
|
541
|
+
)
|
|
542
|
+
],
|
|
543
|
+
warnings: []
|
|
544
|
+
};
|
|
545
|
+
const t = [];
|
|
546
|
+
return e.mode === "off" ? m(e, ["mode"], r, t) : e.mode === "explicit" ? (m(e, ["mode", "spec"], r, t), t.push(...F(e.spec, `${r}.spec`).errors)) : t.push(
|
|
547
|
+
i(
|
|
548
|
+
"invalid_comparison_config",
|
|
549
|
+
"Comparison mode must be off or explicit.",
|
|
550
|
+
`${r}.mode`
|
|
551
|
+
)
|
|
552
|
+
), { ok: t.length === 0, errors: t, warnings: [] };
|
|
657
553
|
}
|
|
658
|
-
function
|
|
659
|
-
|
|
660
|
-
|
|
554
|
+
function se(e, r = "comparisonSelection") {
|
|
555
|
+
if (!d(e))
|
|
556
|
+
return {
|
|
557
|
+
ok: !1,
|
|
558
|
+
errors: [
|
|
559
|
+
i(
|
|
560
|
+
"invalid_global_date_comparison",
|
|
561
|
+
"Global Date comparison selection must be an object.",
|
|
562
|
+
r
|
|
563
|
+
)
|
|
564
|
+
],
|
|
565
|
+
warnings: []
|
|
566
|
+
};
|
|
567
|
+
const t = [];
|
|
568
|
+
if (e.mode === "off")
|
|
569
|
+
m(e, ["mode"], r, t);
|
|
570
|
+
else if (e.mode === "period") {
|
|
571
|
+
m(e, ["mode", "spec"], r, t);
|
|
572
|
+
const o = F(e.spec, `${r}.spec`);
|
|
573
|
+
t.push(...o.errors), d(e.spec) && e.spec.kind === "target" && t.push(
|
|
574
|
+
i(
|
|
575
|
+
"invalid_global_date_comparison",
|
|
576
|
+
"Global Date comparison supports previous_period or previous_year, not target.",
|
|
577
|
+
`${r}.spec.kind`
|
|
578
|
+
)
|
|
579
|
+
);
|
|
580
|
+
} else
|
|
581
|
+
t.push(
|
|
582
|
+
i(
|
|
583
|
+
"invalid_global_date_comparison",
|
|
584
|
+
"Global Date comparison mode must be off or period.",
|
|
585
|
+
`${r}.mode`
|
|
586
|
+
)
|
|
587
|
+
);
|
|
588
|
+
return { ok: t.length === 0, errors: t, warnings: [] };
|
|
661
589
|
}
|
|
662
|
-
function
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
590
|
+
function he(e, r = "globalDateComparison") {
|
|
591
|
+
if (!d(e))
|
|
592
|
+
return {
|
|
593
|
+
ok: !1,
|
|
594
|
+
errors: [
|
|
595
|
+
i(
|
|
596
|
+
"invalid_global_date_comparison",
|
|
597
|
+
"Global Date comparison context must be an object.",
|
|
598
|
+
r
|
|
599
|
+
)
|
|
600
|
+
],
|
|
601
|
+
warnings: []
|
|
602
|
+
};
|
|
603
|
+
const t = [];
|
|
604
|
+
return m(
|
|
605
|
+
e,
|
|
606
|
+
["selection", "inheritGlobalComparison", "owner", "referenceTime"],
|
|
607
|
+
r,
|
|
608
|
+
t
|
|
609
|
+
), t.push(
|
|
610
|
+
...se(
|
|
611
|
+
e.selection,
|
|
612
|
+
`${r}.selection`
|
|
613
|
+
).errors
|
|
614
|
+
), e.inheritGlobalComparison !== void 0 && e.inheritGlobalComparison !== !1 && t.push(
|
|
615
|
+
i(
|
|
616
|
+
"invalid_global_date_comparison",
|
|
617
|
+
"inheritGlobalComparison may only be false when present.",
|
|
618
|
+
`${r}.inheritGlobalComparison`
|
|
619
|
+
)
|
|
620
|
+
), e.owner !== void 0 && (d(e.owner) ? e.owner.kind === "global_date" ? m(e.owner, ["kind"], `${r}.owner`, t) : e.owner.kind === "field_date" ? (m(
|
|
621
|
+
e.owner,
|
|
622
|
+
["kind", "filterId", "label"],
|
|
623
|
+
`${r}.owner`,
|
|
624
|
+
t
|
|
625
|
+
), (typeof e.owner.filterId != "string" || !e.owner.filterId.trim()) && t.push(
|
|
626
|
+
i(
|
|
627
|
+
"invalid_global_date_comparison",
|
|
628
|
+
"Field Date comparison owner requires a non-empty filterId.",
|
|
629
|
+
`${r}.owner.filterId`
|
|
630
|
+
)
|
|
631
|
+
), (typeof e.owner.label != "string" || !e.owner.label.trim()) && t.push(
|
|
632
|
+
i(
|
|
633
|
+
"invalid_global_date_comparison",
|
|
634
|
+
"Field Date comparison owner requires a non-empty label.",
|
|
635
|
+
`${r}.owner.label`
|
|
636
|
+
)
|
|
637
|
+
)) : t.push(
|
|
638
|
+
i(
|
|
639
|
+
"invalid_global_date_comparison",
|
|
640
|
+
"Comparison owner kind must be global_date or field_date.",
|
|
641
|
+
`${r}.owner.kind`
|
|
642
|
+
)
|
|
643
|
+
) : t.push(
|
|
644
|
+
i(
|
|
645
|
+
"invalid_global_date_comparison",
|
|
646
|
+
"Comparison owner must be an object.",
|
|
647
|
+
`${r}.owner`
|
|
648
|
+
)
|
|
649
|
+
)), e.referenceTime !== void 0 && (typeof e.referenceTime != "string" || !ie(e.referenceTime)) && t.push(
|
|
650
|
+
i(
|
|
651
|
+
"invalid_global_date_comparison",
|
|
652
|
+
"referenceTime must be a valid ISO date-time string when present.",
|
|
653
|
+
`${r}.referenceTime`
|
|
654
|
+
)
|
|
655
|
+
), { ok: t.length === 0, errors: t, warnings: [] };
|
|
668
656
|
}
|
|
669
|
-
function
|
|
670
|
-
return
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
657
|
+
function we(e, r = "comparisonPolarity") {
|
|
658
|
+
return e === "higher_is_better" || e === "lower_is_better" || e === "neutral" ? { ok: !0, errors: [], warnings: [] } : {
|
|
659
|
+
ok: !1,
|
|
660
|
+
errors: [
|
|
661
|
+
i(
|
|
662
|
+
"invalid_comparison_polarity",
|
|
663
|
+
"Comparison polarity must be higher_is_better, lower_is_better, or neutral.",
|
|
664
|
+
r
|
|
665
|
+
)
|
|
666
|
+
],
|
|
667
|
+
warnings: []
|
|
668
|
+
};
|
|
678
669
|
}
|
|
679
|
-
function
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
670
|
+
function Ce(e, r = "comparisonPresentation") {
|
|
671
|
+
if (!d(e))
|
|
672
|
+
return {
|
|
673
|
+
ok: !1,
|
|
674
|
+
errors: [
|
|
675
|
+
i(
|
|
676
|
+
"invalid_comparison_presentation",
|
|
677
|
+
"Comparison presentation must be an object.",
|
|
678
|
+
r
|
|
679
|
+
)
|
|
680
|
+
],
|
|
681
|
+
warnings: []
|
|
682
|
+
};
|
|
683
|
+
const t = [], o = [
|
|
684
|
+
"displayMode",
|
|
685
|
+
"showComparison",
|
|
686
|
+
"precision",
|
|
687
|
+
"indicatorStyle",
|
|
688
|
+
"showColor",
|
|
689
|
+
"position",
|
|
690
|
+
"conditionalLabel",
|
|
691
|
+
"labelName",
|
|
692
|
+
"conditionalLabels",
|
|
693
|
+
"colors"
|
|
694
|
+
];
|
|
695
|
+
return Object.keys(e).forEach((a) => {
|
|
696
|
+
o.includes(a) || t.push(
|
|
697
|
+
i(
|
|
698
|
+
"invalid_comparison_presentation",
|
|
699
|
+
`Comparison presentation does not accept field "${a}".`,
|
|
700
|
+
`${r}.${a}`
|
|
701
|
+
)
|
|
702
|
+
);
|
|
703
|
+
}), [
|
|
704
|
+
["displayMode", ["difference", "percent_change", "both", "ratio"]],
|
|
705
|
+
["indicatorStyle", ["arrow_badge", "arrow", "badge", "none"]],
|
|
706
|
+
["position", ["left", "right", "top"]]
|
|
707
|
+
].forEach(([a, s]) => {
|
|
708
|
+
e[a] !== void 0 && !s.includes(e[a]) && t.push(
|
|
709
|
+
i(
|
|
710
|
+
"invalid_comparison_presentation",
|
|
711
|
+
`Comparison presentation ${a} is invalid.`,
|
|
712
|
+
`${r}.${a}`
|
|
713
|
+
)
|
|
714
|
+
);
|
|
715
|
+
}), ["showComparison", "showColor", "conditionalLabel"].forEach((a) => {
|
|
716
|
+
e[a] !== void 0 && typeof e[a] != "boolean" && t.push(
|
|
717
|
+
i(
|
|
718
|
+
"invalid_comparison_presentation",
|
|
719
|
+
`Comparison presentation ${a} must be a boolean.`,
|
|
720
|
+
`${r}.${a}`
|
|
721
|
+
)
|
|
722
|
+
);
|
|
723
|
+
}), e.precision !== void 0 && (typeof e.precision != "number" || !Number.isInteger(e.precision) || e.precision < 0 || e.precision > 6) && t.push(
|
|
724
|
+
i(
|
|
725
|
+
"invalid_comparison_presentation",
|
|
726
|
+
"Comparison presentation precision must be an integer from 0 through 6.",
|
|
727
|
+
`${r}.precision`
|
|
728
|
+
)
|
|
729
|
+
), e.labelName !== void 0 && typeof e.labelName != "string" && t.push(
|
|
730
|
+
i(
|
|
731
|
+
"invalid_comparison_presentation",
|
|
732
|
+
"Comparison presentation labelName must be a string.",
|
|
733
|
+
`${r}.labelName`
|
|
734
|
+
)
|
|
735
|
+
), ["conditionalLabels", "colors"].forEach((a) => {
|
|
736
|
+
const s = e[a];
|
|
737
|
+
if (s !== void 0) {
|
|
738
|
+
if (!d(s)) {
|
|
739
|
+
t.push(
|
|
740
|
+
i(
|
|
741
|
+
"invalid_comparison_presentation",
|
|
742
|
+
`Comparison presentation ${a} must be an object.`,
|
|
743
|
+
`${r}.${a}`
|
|
744
|
+
)
|
|
745
|
+
);
|
|
746
|
+
return;
|
|
747
|
+
}
|
|
748
|
+
Object.keys(s).forEach((l) => {
|
|
749
|
+
["increase", "decrease", "neutral"].includes(l) || t.push(
|
|
750
|
+
i(
|
|
751
|
+
"invalid_comparison_presentation",
|
|
752
|
+
`Comparison presentation ${a} does not accept field "${l}".`,
|
|
753
|
+
`${r}.${a}.${l}`
|
|
754
|
+
)
|
|
755
|
+
);
|
|
756
|
+
}), Object.entries(s).forEach(([l, c]) => {
|
|
757
|
+
c !== void 0 && typeof c != "string" && t.push(
|
|
758
|
+
i(
|
|
759
|
+
"invalid_comparison_presentation",
|
|
760
|
+
`Comparison presentation ${a}.${l} must be a string.`,
|
|
761
|
+
`${r}.${a}.${l}`
|
|
762
|
+
)
|
|
763
|
+
);
|
|
764
|
+
});
|
|
695
765
|
}
|
|
696
|
-
}
|
|
697
|
-
return y(r, {
|
|
698
|
-
calendar: "gregory",
|
|
699
|
-
month: t === "short" ? "numeric" : t === "medium" ? "short" : "long",
|
|
700
|
-
timeZone: "UTC",
|
|
701
|
-
year: "numeric"
|
|
702
|
-
}).format(w(e));
|
|
703
|
-
}
|
|
704
|
-
function se(e, r) {
|
|
705
|
-
return Math.floor((e.month - r + 12) % 12 / 3) + 1;
|
|
706
|
-
}
|
|
707
|
-
function E(e, r) {
|
|
708
|
-
return r === 1 || e.month < r ? e.year : e.year + 1;
|
|
766
|
+
}), { ok: t.length === 0, errors: t, warnings: [] };
|
|
709
767
|
}
|
|
710
768
|
function ce(e) {
|
|
711
|
-
return e ===
|
|
712
|
-
}
|
|
713
|
-
function k(e, r, t, o) {
|
|
714
|
-
const n = S(o) ?? 1, a = se(e, n);
|
|
715
|
-
switch (r) {
|
|
716
|
-
case "week_of_short":
|
|
717
|
-
return `Week of ${h(e.month, t, "short")} ${e.day}, ${e.year}`;
|
|
718
|
-
case "week_of_long":
|
|
719
|
-
return `Week of ${h(e.month, t, "long")} ${e.day}, ${e.year}`;
|
|
720
|
-
case "quarter_short":
|
|
721
|
-
return `Q${a} ${e.year}`;
|
|
722
|
-
case "quarter_long":
|
|
723
|
-
return `${ce(a)} Quarter ${e.year}`;
|
|
724
|
-
case "fiscal_quarter_short":
|
|
725
|
-
return `Q${a} FY${E(e, n)}`;
|
|
726
|
-
case "fiscal_year":
|
|
727
|
-
return `FY${E(e, n)}`;
|
|
728
|
-
}
|
|
769
|
+
return e === null ? "unknown" : e > 0 ? "increase" : e < 0 ? "decrease" : "no_change";
|
|
729
770
|
}
|
|
730
|
-
function le(e, r
|
|
731
|
-
|
|
732
|
-
switch (r.granularity) {
|
|
733
|
-
case "second":
|
|
734
|
-
case "minute":
|
|
735
|
-
case "hour":
|
|
736
|
-
return ae(e, t, o.dateTime);
|
|
737
|
-
case "day":
|
|
738
|
-
return A(e, t, o.dateStyle);
|
|
739
|
-
case "week":
|
|
740
|
-
return `Week of ${A(e, t, o.dateStyle)}`;
|
|
741
|
-
case "month":
|
|
742
|
-
return ie(e, t, o.dateStyle);
|
|
743
|
-
case "quarter":
|
|
744
|
-
return k(
|
|
745
|
-
e,
|
|
746
|
-
n ? "fiscal_quarter_short" : "quarter_short",
|
|
747
|
-
t,
|
|
748
|
-
r
|
|
749
|
-
);
|
|
750
|
-
case "year":
|
|
751
|
-
return n ? k(e, "fiscal_year", t, r) : String(e.year);
|
|
752
|
-
}
|
|
771
|
+
function le(e, r) {
|
|
772
|
+
return e === "unknown" || e === "no_change" || r === "neutral" ? "neutral" : r === "higher_is_better" && e === "increase" || r === "lower_is_better" && e === "decrease" ? "favorable" : "unfavorable";
|
|
753
773
|
}
|
|
754
774
|
function $e(e) {
|
|
755
|
-
const
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
return le(
|
|
771
|
-
t.value,
|
|
772
|
-
e.metadata,
|
|
773
|
-
n,
|
|
774
|
-
o.styles
|
|
775
|
-
);
|
|
776
|
-
if (o.mode === "preset")
|
|
777
|
-
return k(
|
|
778
|
-
t.value,
|
|
779
|
-
o.preset,
|
|
780
|
-
n,
|
|
781
|
-
e.metadata
|
|
782
|
-
);
|
|
783
|
-
const a = O(o.pattern);
|
|
784
|
-
if (!a.ok)
|
|
785
|
-
throw new _(
|
|
786
|
-
"invalid_temporal_bucket_format",
|
|
787
|
-
a.message
|
|
788
|
-
);
|
|
789
|
-
return ne(t.value, a.segments, n);
|
|
775
|
+
const {
|
|
776
|
+
currentValue: r,
|
|
777
|
+
comparisonValue: t,
|
|
778
|
+
polarity: o = ae
|
|
779
|
+
} = e, a = r !== null && t !== null ? r - t : null, s = a !== null && t !== null && t !== 0 ? a / Math.abs(t) : null, l = r !== null && t !== null && t !== 0 ? r / t : null, c = ce(a);
|
|
780
|
+
return {
|
|
781
|
+
status: t === null ? "insufficient_history" : "available",
|
|
782
|
+
currentValue: r,
|
|
783
|
+
comparisonValue: t,
|
|
784
|
+
delta: a,
|
|
785
|
+
percentChange: s,
|
|
786
|
+
ratio: l,
|
|
787
|
+
direction: c,
|
|
788
|
+
sentiment: le(c, o)
|
|
789
|
+
};
|
|
790
790
|
}
|
|
791
791
|
export {
|
|
792
|
-
|
|
793
|
-
|
|
792
|
+
be as C,
|
|
793
|
+
ae as D,
|
|
794
794
|
_ as T,
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
795
|
+
ye as a,
|
|
796
|
+
_e as b,
|
|
797
|
+
se as c,
|
|
798
|
+
he as d,
|
|
799
|
+
we as e,
|
|
800
|
+
Ce as f,
|
|
801
|
+
$e as g,
|
|
802
|
+
pe as h,
|
|
803
|
+
q as i,
|
|
804
|
+
W as j,
|
|
805
|
+
fe as k,
|
|
806
806
|
g as l,
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
807
|
+
Q as p,
|
|
808
|
+
ge as r,
|
|
809
|
+
F as v
|
|
810
810
|
};
|