react-semaphor 0.1.541 → 0.1.542

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/dist/analytics-protocol/index.js +75 -75
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/brand-studio/index.js +3 -3
  4. package/dist/briefings/index.js +51 -49
  5. package/dist/chunks/apply-dashboard-operations-Btbp2-6v.js +2260 -0
  6. package/dist/chunks/{assistant-chat-D1fDZD6O.js → assistant-chat-oHF5lTjA.js} +12 -12
  7. package/dist/chunks/bookmark-state-CXw7lZ50.js +118 -0
  8. package/dist/chunks/{calendar-day-equality-Bpl15IBo.js → calendar-day-equality-BmJAWduY.js} +180 -207
  9. package/dist/chunks/comparison-window-caption-ChIyd_-L.js +1618 -0
  10. package/dist/chunks/custom-visual-inputs-DUtpYZOk.js +323 -0
  11. package/dist/chunks/{dashboard-briefing-launcher-DwjFpewq.js → dashboard-briefing-launcher-B-cm719R.js} +18 -18
  12. package/dist/chunks/{dashboard-controls-C_BI28ME.js → dashboard-controls-CIn22Qgp.js} +69 -70
  13. package/dist/chunks/{dashboard-filter-value-compatibility-D95O4nd7.js → dashboard-filter-value-compatibility-CwQ_iSNb.js} +2 -2
  14. package/dist/chunks/{dashboard-json-DDY15Trn.js → dashboard-json-ZUYsIExq.js} +4 -4
  15. package/dist/chunks/{dashboard-B6IrON_Q.js → dashboard-s5WJBcK8.js} +1 -1
  16. package/dist/chunks/{document-dashboard-inputs-DP_Op5mu.js → document-dashboard-inputs-C6MJVyoI.js} +2382 -4975
  17. package/dist/chunks/document-sheet-utils-BsZUnHRl.js +3619 -0
  18. package/dist/chunks/{edit-dashboard-visual-CH2dzWW-.js → edit-dashboard-visual-DLdereA7.js} +728 -728
  19. package/dist/chunks/{filter-value-text-BhWugPWE.js → filter-value-text-CYsVYPuD.js} +18 -19
  20. package/dist/chunks/{index-DaQlghLY.js → index-CV5rHq5D.js} +824 -1351
  21. package/dist/chunks/{matrix-analytical-definition-bcprSe4u.js → matrix-analytical-definition-C7Gb0e12.js} +1 -1
  22. package/dist/chunks/{matrix-card-CJn1hB5V.js → matrix-card-DjwWcCo8.js} +2 -2
  23. package/dist/chunks/{matrix-formatter-DQ8avoIQ.js → matrix-formatter-BnsTX90d.js} +430 -417
  24. package/dist/chunks/{matrix-member-presentation-BNPSDKBG.js → matrix-member-presentation-CQGdVks6.js} +1 -1
  25. package/dist/chunks/{matrix-operation-contract-B8PBF1Gd.js → matrix-operation-contract-8OIO4gob.js} +65 -65
  26. package/dist/chunks/metric-comparison-DEwi9uc2.js +498 -0
  27. package/dist/chunks/numeric-presentation-BSAqPpHt.js +5227 -0
  28. package/dist/chunks/{pivot-header-presentation-MkcKnjn3.js → pivot-header-presentation-DHcx1XGQ.js} +1 -1
  29. package/dist/chunks/{pivot-result-identity-D6hhcRXi.js → pivot-result-identity-DJhXXcns.js} +1 -1
  30. package/dist/chunks/pivot-result-lifecycle-BBlAfBA0.js +1155 -0
  31. package/dist/chunks/raw-temporal-presentation-CZ2r0Vb_.js +585 -0
  32. package/dist/chunks/{report-preferences-dialog-DpNkFfQO.js → report-preferences-dialog-MRUWpMcJ.js} +75 -75
  33. package/dist/chunks/{report-runtime-context-B984Nq1E.js → report-runtime-context-Dq8XyODK.js} +1 -1
  34. package/dist/chunks/{saved-dashboard-context-CJ2WpoMF.js → saved-dashboard-context-DjPqgFly.js} +233 -206
  35. package/dist/chunks/{selection-reducer-vKIb_jS6.js → selection-reducer-Dj_8xD69.js} +1 -1
  36. package/dist/chunks/{semaphor-ready-indicator-KT598QJq.js → semaphor-ready-indicator-BWSpRsPj.js} +37489 -39476
  37. package/dist/chunks/{shelf-drop-preview-context-BxV3Fl8h.js → shelf-drop-preview-context-CQbFLm3q.js} +6 -6
  38. package/dist/chunks/sort-target-MT1WK1vX.js +29 -0
  39. package/dist/chunks/{source-entity-resolution-CVA1a85c.js → source-entity-resolution-BYn9giz3.js} +1 -1
  40. package/dist/chunks/{switch-DWEWiv1J.js → switch-C3jLxlG0.js} +2 -2
  41. package/dist/chunks/table-export-sheet-BHSnuZHd.js +949 -0
  42. package/dist/chunks/table-settings-CLZocegs.js +501 -0
  43. package/dist/chunks/temporal-bucket-D7NBrrtL.js +2071 -0
  44. package/dist/chunks/{token-types-bxUxXDX2.js → token-types-DBbZVQsm.js} +1 -1
  45. package/dist/chunks/{use-create-flow-overlay-state-DdD12SMY.js → use-create-flow-overlay-state-BJDNqdOh.js} +151 -151
  46. package/dist/chunks/{validators-Ej1DdCXa.js → validators-DMHTpf7a.js} +73 -73
  47. package/dist/dashboard/index.js +2 -2
  48. package/dist/dashboard-authoring/index.js +462 -457
  49. package/dist/data-app-sdk/index.js +5 -5
  50. package/dist/data-app-sdk-adapters/index.js +2 -2
  51. package/dist/data-app-sdk-validation/index.js +9 -9
  52. package/dist/format-utils/index.js +346 -241
  53. package/dist/index.js +174 -175
  54. package/dist/report-runtime-context/index.js +1 -1
  55. package/dist/surfboard/index.js +2 -2
  56. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  57. package/dist/types/briefings/attachments.d.ts +17 -1
  58. package/dist/types/briefings/index.d.ts +5 -3
  59. package/dist/types/index.js +48 -48
  60. package/dist/types/lib/api/exports-api.d.ts +11 -65
  61. package/dist/types/lib/dashboard-inputs/control-contract-overrides.d.ts +17 -0
  62. package/dist/types/lib/dashboard-viewer/export-table-view.d.ts +2 -0
  63. package/dist/types/lib/hooks/use-dashboard.d.ts +3 -6
  64. package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +8 -2
  65. package/dist/types/lib/matrix-table/matrix-delivery.d.ts +8 -6
  66. package/dist/types/lib/query-context/build-dashboard-card-query-contract.d.ts +50 -0
  67. package/dist/types/lib/types/explorer-types.d.ts +6 -0
  68. package/dist/types/shared/analytics-protocol/matrix-definition-contract.d.ts +3 -3
  69. package/dist/types/shared/assistant-context/index.d.ts +1 -1
  70. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +23 -6
  71. package/dist/types/shared/dashboard-authoring/card-export-request.d.ts +173 -0
  72. package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
  73. package/dist/types/shared/dashboard-authoring/matrix-delivery.d.ts +4 -3
  74. package/dist/types/shared/format-utils/exporters/export-cells.d.ts +90 -0
  75. package/dist/types/shared/format-utils/exporters/export-file-format.d.ts +44 -0
  76. package/dist/types/shared/format-utils/exporters/index.d.ts +6 -0
  77. package/dist/types/shared/format-utils/exporters/xlsx-file.d.ts +90 -0
  78. package/dist/types/shared/format-utils/formatters/date-formatter.d.ts +8 -12
  79. package/dist/types/shared/format-utils/formatters/index.d.ts +1 -1
  80. package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +2 -0
  81. package/dist/types/shared/format-utils/index.d.ts +2 -0
  82. package/dist/types/shared/format-utils/matrix-continuation.d.ts +55 -9
  83. package/dist/types/shared/format-utils/matrix-export-presentation.d.ts +21 -1
  84. package/dist/types/shared/format-utils/matrix-export-xlsx.d.ts +27 -0
  85. package/dist/types/shared/format-utils/presentation-execution.d.ts +27 -2
  86. package/dist/types/shared/format-utils/raw-temporal.d.ts +8 -0
  87. package/dist/types/shared/format-utils/table-export/index.d.ts +8 -0
  88. package/dist/types/shared/format-utils/table-export/prepare-table-export.d.ts +50 -0
  89. package/dist/types/shared/format-utils/table-export/table-export-formatting.d.ts +47 -0
  90. package/dist/types/shared/format-utils/table-export/table-export-raw-temporal.d.ts +40 -0
  91. package/dist/types/shared/format-utils/table-export/table-export-result.d.ts +31 -0
  92. package/dist/types/shared/format-utils/table-export/table-export-sheet.d.ts +38 -0
  93. package/dist/types/shared/format-utils/temporal-bucket.d.ts +9 -0
  94. package/package.json +2 -1
  95. package/dist/chunks/aggregate-table-row-presentation-B_vQjYR3.js +0 -996
  96. package/dist/chunks/apply-dashboard-operations-C-iahGka.js +0 -402
  97. package/dist/chunks/bookmark-state-k7y5SNGf.js +0 -331
  98. package/dist/chunks/calculated-field-identity-DcBS2NPP.js +0 -2161
  99. package/dist/chunks/canonical-result-keys-CEQefvdO.js +0 -33
  100. package/dist/chunks/common-types-CUf03Htv.js +0 -288
  101. package/dist/chunks/csv-utils-GUfKyT1J.js +0 -56
  102. package/dist/chunks/custom-visual-inputs-BrUOIwln.js +0 -3288
  103. package/dist/chunks/document-sheet-utils-C1eEldxs.js +0 -1076
  104. package/dist/chunks/matrix-definition-DQDI2okF.js +0 -206
  105. package/dist/chunks/metric-comparison-CojWeLqx.js +0 -392
  106. package/dist/chunks/pivot-result-lifecycle-8qCDmpKc.js +0 -804
  107. package/dist/chunks/raw-temporal-D61lr48Y.js +0 -1464
  108. package/dist/chunks/temporal-bucket-D8JF7zKz.js +0 -575
  109. package/dist/chunks/temporal-bucket-contract-DaOajRC7.js +0 -108
@@ -1,575 +0,0 @@
1
- var q = Object.defineProperty;
2
- var x = (e, t, r) => t in e ? q(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var w = (e, t, r) => x(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { canonicalizeSupportedLocale as E } from "../value-format-preferences/index.js";
5
- const ue = 6048e5, le = 864e5, me = 6e4, de = 36e5, fe = 525600, pe = 43200, ye = 1440;
6
- function f(e) {
7
- if (e === null || typeof e != "object" || Array.isArray(e))
8
- return !1;
9
- const t = Object.getPrototypeOf(e);
10
- if (t === null || t === Object.prototype) return !0;
11
- const r = Object.prototype.hasOwnProperty.call(
12
- t,
13
- "constructor"
14
- ) ? t.constructor : void 0;
15
- return typeof r == "function" && Function.prototype.toString.call(r) === Function.prototype.toString.call(Object);
16
- }
17
- const N = [
18
- "YYYY",
19
- "MMMM",
20
- "MMM",
21
- "YY",
22
- "MM",
23
- "DD",
24
- "HH",
25
- "mm",
26
- "ss"
27
- ], H = /* @__PURE__ */ new Set([" ", "-", "/", ":", ".", ",", "T"]), P = {
28
- week_of_short: "week",
29
- week_of_long: "week",
30
- quarter_short: "quarter",
31
- quarter_long: "quarter",
32
- fiscal_quarter_short: "quarter",
33
- fiscal_year: "year"
34
- };
35
- function U(e) {
36
- return typeof e == "string" && Object.prototype.hasOwnProperty.call(P, e);
37
- }
38
- function j(e, t) {
39
- return N.find(
40
- (r) => e.startsWith(r, t)
41
- );
42
- }
43
- function M(e) {
44
- var a;
45
- if (!e || e.trim() !== e)
46
- return {
47
- ok: !1,
48
- code: "invalid_temporal_bucket_pattern",
49
- message: "Temporal bucket patterns must be non-empty and trimmed."
50
- };
51
- const t = [];
52
- let r = 0, n = !1;
53
- for (; r < e.length; ) {
54
- const s = j(e, r);
55
- if (s) {
56
- if (n)
57
- return {
58
- ok: !1,
59
- code: "invalid_temporal_bucket_pattern",
60
- message: "Adjacent temporal bucket tokens require a separator."
61
- };
62
- t.push({ kind: "token", value: s }), r += s.length, n = !0;
63
- continue;
64
- }
65
- const o = e[r];
66
- if (!H.has(o))
67
- return {
68
- ok: !1,
69
- code: "invalid_temporal_bucket_pattern",
70
- message: `Unsupported temporal bucket pattern character "${o}".`
71
- };
72
- if (t.length === 0)
73
- return {
74
- ok: !1,
75
- code: "invalid_temporal_bucket_pattern",
76
- message: "Temporal bucket patterns cannot begin with a separator."
77
- };
78
- const c = t[t.length - 1];
79
- c.kind === "literal" ? c.value += o : t.push({ kind: "literal", value: o }), r += 1, n = !1;
80
- }
81
- return ((a = t[t.length - 1]) == null ? void 0 : a.kind) !== "token" ? {
82
- ok: !1,
83
- code: "invalid_temporal_bucket_pattern",
84
- message: "Temporal bucket patterns cannot end with a separator."
85
- } : { ok: !0, segments: t };
86
- }
87
- function I(e) {
88
- return e.flatMap(
89
- (t) => t.kind === "token" ? [t.value] : []
90
- );
91
- }
92
- function v(e, t) {
93
- return e.filter((r) => t.includes(r)).length === 1;
94
- }
95
- function y(e, t) {
96
- return e.some((r) => t.includes(r));
97
- }
98
- function B(e) {
99
- return new Set(e).size !== e.length;
100
- }
101
- function R(e, t) {
102
- if (B(e)) return !1;
103
- const r = ["YYYY", "YY"], n = ["MMMM", "MMM", "MM"], a = ["HH", "mm", "ss"], s = v(e, r), o = v(e, n), c = e.includes("DD"), i = y(e, a);
104
- switch (t) {
105
- case "second":
106
- return e.includes("HH") && e.includes("mm") && e.includes("ss") && (!y(e, [...r, ...n, "DD"]) || s && o && c);
107
- case "minute":
108
- return e.includes("HH") && e.includes("mm") && (!y(e, [...r, ...n, "DD"]) || s && o && c);
109
- case "hour":
110
- return e.includes("HH") && (!y(e, [...r, ...n, "DD"]) || s && o && c);
111
- case "day":
112
- case "week":
113
- return s && o && c && !i;
114
- case "month":
115
- return s && o && !c && !i;
116
- case "quarter":
117
- return !1;
118
- case "year":
119
- return s && !o && !c && !i;
120
- }
121
- }
122
- function O(e, t) {
123
- if (e.presentation.mode === "auto")
124
- return { ok: !0 };
125
- if (e.presentation.mode === "preset") {
126
- const n = P[e.presentation.preset];
127
- return n === t ? { ok: !0 } : {
128
- ok: !1,
129
- code: "incompatible_temporal_bucket_preset",
130
- message: `Preset ${e.presentation.preset} requires ${n} granularity.`
131
- };
132
- }
133
- const r = M(e.presentation.pattern);
134
- return r.ok ? R(
135
- I(r.segments),
136
- t
137
- ) ? { ok: !0, segments: r.segments } : {
138
- ok: !1,
139
- code: "incompatible_temporal_bucket_pattern",
140
- message: `Pattern ${e.presentation.pattern} is not compatible with ${t} granularity.`
141
- } : r;
142
- }
143
- function he(e, t) {
144
- if (!(!e || !t))
145
- return O(e, t).ok ? e : void 0;
146
- }
147
- const L = {
148
- dateStyle: "short",
149
- dateTime: { dateStyle: "short", timeStyle: "short" }
150
- };
151
- class h extends Error {
152
- constructor(r, n) {
153
- super(n);
154
- w(this, "code");
155
- this.name = "TemporalBucketContractError", this.code = r;
156
- }
157
- }
158
- const z = [
159
- "Jan",
160
- "Feb",
161
- "Mar",
162
- "Apr",
163
- "May",
164
- "Jun",
165
- "Jul",
166
- "Aug",
167
- "Sep",
168
- "Oct",
169
- "Nov",
170
- "Dec"
171
- ], J = [
172
- "January",
173
- "February",
174
- "March",
175
- "April",
176
- "May",
177
- "June",
178
- "July",
179
- "August",
180
- "September",
181
- "October",
182
- "November",
183
- "December"
184
- ];
185
- function T(e) {
186
- return {
187
- ok: !1,
188
- error: { code: "invalid_temporal_bucket_value", message: e }
189
- };
190
- }
191
- function Z(e) {
192
- return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
193
- }
194
- function W(e, t) {
195
- return t === 2 ? Z(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
196
- }
197
- function G(e, t, r) {
198
- const n = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], a = t < 3 ? e - 1 : e;
199
- return (a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) + n[t - 1] + r) % 7;
200
- }
201
- function _(e) {
202
- var t;
203
- return (t = e.calendar.fiscalCalendar) == null ? void 0 : t.yearStartMonth;
204
- }
205
- function K(e, t) {
206
- return (e - t + 12) % 12 % 3 === 0;
207
- }
208
- function Q(e, t) {
209
- const { granularity: r } = t, n = _(t) ?? 1;
210
- switch (r) {
211
- case "second":
212
- return !0;
213
- case "minute":
214
- return e.second === 0;
215
- case "hour":
216
- return e.minute === 0 && e.second === 0;
217
- case "day":
218
- return !0;
219
- case "week":
220
- return G(e.year, e.month, e.day) === t.calendar.weekStart;
221
- case "month":
222
- return e.day === 1;
223
- case "quarter":
224
- return e.day === 1 && K(e.month, n);
225
- case "year":
226
- return e.day === 1 && e.month === n;
227
- }
228
- }
229
- function V(e, t) {
230
- if (e === null) return { ok: !0, value: null };
231
- const r = t.granularity === "second" || t.granularity === "minute" || t.granularity === "hour", n = r ? /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e) : /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
232
- if (!n)
233
- return T(
234
- `Expected ${r ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${t.granularity} granularity.`
235
- );
236
- const a = {
237
- year: Number(n[1]),
238
- month: Number(n[2]),
239
- day: Number(n[3]),
240
- hour: r ? Number(n[4]) : 0,
241
- minute: r ? Number(n[5]) : 0,
242
- second: r ? Number(n[6]) : 0
243
- };
244
- return a.year < 1 || a.month < 1 || a.month > 12 || a.day < 1 || a.day > W(a.year, a.month) || a.hour > 23 || a.minute > 59 || a.second > 59 ? T(`Invalid canonical ${t.granularity} bucket value ${e}.`) : Q(a, t) ? { ok: !0, value: a } : T(
245
- `Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`
246
- );
247
- }
248
- function ke(e) {
249
- const { granularity: t, calendar: r } = e, n = (o, c) => new Intl.DateTimeFormat("en-US", { ...o, timeZone: "UTC" }).format(c), a = [`by ${t} in the ${r.tz} calendar`];
250
- t === "week" && a.push(`weeks starting on ${n({ weekday: "long" }, new Date(Date.UTC(2023, 0, 1 + r.weekStart)))}`);
251
- const s = _(e);
252
- return s && (t === "quarter" || t === "year") && a.push(`the fiscal year starting in ${n({ month: "long" }, new Date(Date.UTC(2e3, s - 1, 1)))}`), `${a.join(", ")}; each value is a bucket's start`;
253
- }
254
- function X(e) {
255
- if (!f(e))
256
- return {
257
- ok: !1,
258
- issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
259
- };
260
- const t = [], r = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
261
- for (const o of Object.keys(e))
262
- r.has(o) || t.push({ path: o, message: `Unknown property "${o}".` });
263
- e.type !== "temporal_bucket" && t.push({ path: "type", message: "Expected temporal_bucket." });
264
- const n = e.presentation;
265
- if (!f(n))
266
- t.push({ path: "presentation", message: "Expected a presentation object." });
267
- else {
268
- const o = n.mode, c = o === "preset" ? /* @__PURE__ */ new Set(["mode", "preset"]) : o === "pattern" ? /* @__PURE__ */ new Set(["mode", "pattern"]) : o === "auto" ? /* @__PURE__ */ new Set(["mode", "styles"]) : /* @__PURE__ */ new Set(["mode"]);
269
- for (const i of Object.keys(n))
270
- c.has(i) || t.push({
271
- path: `presentation.${i}`,
272
- message: `Unknown property "${i}".`
273
- });
274
- if (o === "preset")
275
- U(n.preset) || t.push({ path: "presentation.preset", message: "Expected a supported preset." });
276
- else if (o === "pattern")
277
- if (typeof n.pattern != "string" || !n.pattern)
278
- t.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
279
- else {
280
- const i = M(n.pattern);
281
- i.ok || t.push({
282
- path: "presentation.pattern",
283
- message: i.message
284
- });
285
- }
286
- else if (o === "auto") {
287
- const i = n.styles;
288
- (!f(i) || !["short", "medium", "long"].includes(String(i.dateStyle)) || !f(i.dateTime) || !["short", "medium", "long"].includes(
289
- String(i.dateTime.dateStyle)
290
- ) || !["short", "medium", "long"].includes(
291
- String(i.dateTime.timeStyle)
292
- ) || Object.keys(i).some(
293
- (u) => u !== "dateStyle" && u !== "dateTime"
294
- ) || Object.keys(i.dateTime).some(
295
- (u) => u !== "dateStyle" && u !== "timeStyle"
296
- )) && t.push({
297
- path: "presentation.styles",
298
- message: "Expected complete resolved date and datetime styles."
299
- });
300
- } else
301
- t.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
302
- }
303
- const a = E(e.locale);
304
- if (a || t.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), t.length > 0 || !a || !f(n))
305
- return { ok: !1, issues: t };
306
- if (n.mode === "auto") {
307
- const o = n.styles;
308
- return {
309
- ok: !0,
310
- value: {
311
- type: "temporal_bucket",
312
- locale: a,
313
- presentation: {
314
- mode: "auto",
315
- styles: {
316
- dateStyle: o.dateStyle,
317
- dateTime: {
318
- dateStyle: o.dateTime.dateStyle,
319
- timeStyle: o.dateTime.timeStyle
320
- }
321
- }
322
- }
323
- }
324
- };
325
- }
326
- return {
327
- ok: !0,
328
- value: {
329
- type: "temporal_bucket",
330
- presentation: n.mode === "preset" ? {
331
- mode: "preset",
332
- preset: n.preset
333
- } : {
334
- mode: "pattern",
335
- pattern: n.pattern
336
- },
337
- locale: a
338
- }
339
- };
340
- }
341
- function ee(e, t) {
342
- const r = !!t.calendar.fiscalCalendar;
343
- return e === "fiscal_quarter_short" || e === "fiscal_year" ? r : e === "quarter_short" || e === "quarter_long" ? !r : !0;
344
- }
345
- function F(e, t) {
346
- return O(e, t.granularity).ok ? e.presentation.mode === "preset" ? ee(e.presentation.preset, t) : !(e.presentation.mode === "pattern" && t.calendar.fiscalCalendar && (t.granularity === "quarter" || t.granularity === "year")) : !1;
347
- }
348
- function D(e, t) {
349
- if (!(!e || e.presentation.mode === "auto"))
350
- return F(e, t) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
351
- }
352
- function ge(e) {
353
- var a;
354
- const t = E(e.locale);
355
- if (!t)
356
- throw new h(
357
- "invalid_temporal_bucket_format",
358
- "Temporal bucket locale must be a supported base BCP 47 locale."
359
- );
360
- const r = D(e.cardFormat, e.metadata);
361
- if (r)
362
- return { format: { ...r, locale: t }, source: "card" };
363
- const n = ((a = e.semanticFormat) == null ? void 0 : a.granularity) === e.metadata.granularity ? D(e.semanticFormat.format, e.metadata) : void 0;
364
- return n ? { format: { ...n, locale: t }, source: "semantic" } : {
365
- format: {
366
- type: "temporal_bucket",
367
- locale: t,
368
- presentation: {
369
- mode: "auto",
370
- styles: e.styles ?? L
371
- }
372
- },
373
- source: "automatic"
374
- };
375
- }
376
- function m(e, t = 2) {
377
- return String(e).padStart(t, "0");
378
- }
379
- function k(e, t, r) {
380
- if (t === "en-US")
381
- return (r === "short" ? z : J)[e - 1];
382
- const n = new Date(Date.UTC(2e3, e - 1, 15));
383
- return new Intl.DateTimeFormat(t, {
384
- calendar: "gregory",
385
- month: r,
386
- timeZone: "UTC"
387
- }).format(n);
388
- }
389
- function te(e, t, r) {
390
- return t.map((n) => {
391
- if (n.kind === "literal") return n.value;
392
- switch (n.value) {
393
- case "YYYY":
394
- return m(e.year, 4);
395
- case "YY":
396
- return m(e.year % 100);
397
- case "MMMM":
398
- return k(e.month, r, "long");
399
- case "MMM":
400
- return k(e.month, r, "short");
401
- case "MM":
402
- return m(e.month);
403
- case "DD":
404
- return m(e.day);
405
- case "HH":
406
- return m(e.hour);
407
- case "mm":
408
- return m(e.minute);
409
- case "ss":
410
- return m(e.second);
411
- }
412
- }).join("");
413
- }
414
- const $ = /* @__PURE__ */ new Map();
415
- function p(e, t) {
416
- const r = `${e}:${JSON.stringify(t)}`, n = $.get(r);
417
- if (n) return n;
418
- const a = new Intl.DateTimeFormat(e, t);
419
- return $.set(r, a), a;
420
- }
421
- function g(e) {
422
- const t = /* @__PURE__ */ new Date(0);
423
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
424
- }
425
- function Y(e, t, r) {
426
- return p(t, {
427
- calendar: "gregory",
428
- dateStyle: r,
429
- timeZone: "UTC"
430
- }).format(g(e));
431
- }
432
- function re(e, t, r) {
433
- return p(t, {
434
- calendar: "gregory",
435
- dateStyle: r.dateStyle,
436
- // Grouped buckets are civil values, not instants. Long time styles would
437
- // append a zone label that the canonical value does not semantically own.
438
- timeStyle: r.timeStyle === "long" ? "medium" : r.timeStyle,
439
- timeZone: "UTC"
440
- }).format(g(e));
441
- }
442
- function ne(e, t, r) {
443
- var a;
444
- if (r === "short") {
445
- const s = g(e), o = p(t, {
446
- calendar: "gregory",
447
- dateStyle: "short",
448
- timeZone: "UTC"
449
- }).formatToParts(s), c = o.findIndex((l) => l.type === "month"), i = o.findIndex((l) => l.type === "year"), u = (a = p(t, {
450
- calendar: "gregory",
451
- timeZone: "UTC",
452
- year: "numeric"
453
- }).formatToParts(s).find((l) => l.type === "year")) == null ? void 0 : a.value;
454
- if (c >= 0 && i >= 0 && u) {
455
- const l = Math.min(c, i), C = Math.max(c, i);
456
- let b = !1;
457
- return o.slice(l, C + 1).filter((d) => d.type === "day" ? (b = !0, !1) : b && d.type === "literal" ? (b = !1, !1) : !0).map((d) => d.type === "year" ? u : d.value).join("");
458
- }
459
- }
460
- return p(t, {
461
- calendar: "gregory",
462
- month: r === "short" ? "numeric" : r === "medium" ? "short" : "long",
463
- timeZone: "UTC",
464
- year: "numeric"
465
- }).format(g(e));
466
- }
467
- function ae(e, t) {
468
- return Math.floor((e.month - t + 12) % 12 / 3) + 1;
469
- }
470
- function A(e, t) {
471
- return t === 1 || e.month < t ? e.year : e.year + 1;
472
- }
473
- function oe(e) {
474
- return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
475
- }
476
- function S(e, t, r, n) {
477
- const a = _(n) ?? 1, s = ae(e, a);
478
- switch (t) {
479
- case "week_of_short":
480
- return `Week of ${k(e.month, r, "short")} ${e.day}, ${e.year}`;
481
- case "week_of_long":
482
- return `Week of ${k(e.month, r, "long")} ${e.day}, ${e.year}`;
483
- case "quarter_short":
484
- return `Q${s} ${e.year}`;
485
- case "quarter_long":
486
- return `${oe(s)} Quarter ${e.year}`;
487
- case "fiscal_quarter_short":
488
- return `Q${s} FY${A(e, a)}`;
489
- case "fiscal_year":
490
- return `FY${A(e, a)}`;
491
- }
492
- }
493
- function se(e, t, r, n) {
494
- const a = _(t);
495
- switch (t.granularity) {
496
- case "second":
497
- case "minute":
498
- case "hour":
499
- return re(e, r, n.dateTime);
500
- case "day":
501
- return Y(e, r, n.dateStyle);
502
- case "week":
503
- return `Week of ${Y(e, r, n.dateStyle)}`;
504
- case "month":
505
- return ne(e, r, n.dateStyle);
506
- case "quarter":
507
- return S(
508
- e,
509
- a ? "fiscal_quarter_short" : "quarter_short",
510
- r,
511
- t
512
- );
513
- case "year":
514
- return a ? S(e, "fiscal_year", r, t) : String(e.year);
515
- }
516
- }
517
- function _e(e) {
518
- const t = X(e.format);
519
- if (!t.ok || !F(t.value, e.metadata))
520
- throw new h(
521
- "invalid_temporal_bucket_format",
522
- "Resolved temporal bucket format is invalid or inapplicable to its metadata."
523
- );
524
- const r = V(e.value, e.metadata);
525
- if (!r.ok)
526
- throw new h(
527
- r.error.code,
528
- r.error.message
529
- );
530
- if (r.value === null) return "(Blank)";
531
- const { presentation: n, locale: a } = t.value;
532
- if (n.mode === "auto")
533
- return se(
534
- r.value,
535
- e.metadata,
536
- a,
537
- n.styles
538
- );
539
- if (n.mode === "preset")
540
- return S(
541
- r.value,
542
- n.preset,
543
- a,
544
- e.metadata
545
- );
546
- const s = M(n.pattern);
547
- if (!s.ok)
548
- throw new h(
549
- "invalid_temporal_bucket_format",
550
- s.message
551
- );
552
- return te(r.value, s.segments, a);
553
- }
554
- export {
555
- L as D,
556
- N as T,
557
- h as a,
558
- X as b,
559
- ge as c,
560
- ke as d,
561
- me as e,
562
- _e as f,
563
- f as g,
564
- ye as h,
565
- U as i,
566
- pe as j,
567
- fe as k,
568
- le as l,
569
- de as m,
570
- ue as n,
571
- V as p,
572
- he as r,
573
- M as t,
574
- O as v
575
- };
@@ -1,108 +0,0 @@
1
- import { t as i, T as l, a as u } from "./analytics-base-schemas-BFAoRlkU.js";
2
- function c(e) {
3
- const r = i.safeParse(e);
4
- return r.success ? { ok: !0, value: r.data } : {
5
- ok: !1,
6
- error: {
7
- code: l.invalidMetadata,
8
- message: "Temporal bucket metadata is invalid.",
9
- path: "temporalBucket"
10
- }
11
- };
12
- }
13
- function s(e, r) {
14
- if (!e.temporalBucket)
15
- return r.metadataRequired ? {
16
- ok: !1,
17
- error: {
18
- code: l.missingMetadata,
19
- message: "Activated temporal bucket result is missing metadata.",
20
- path: "temporalBucket"
21
- }
22
- } : { ok: !0 };
23
- const t = c(
24
- e.temporalBucket
25
- );
26
- if (!t.ok || !t.value)
27
- return t;
28
- const a = u(
29
- t.value.granularity
30
- );
31
- return e.dataType !== a ? {
32
- ok: !1,
33
- error: {
34
- code: l.invalidMetadata,
35
- message: `${t.value.granularity} temporal buckets require dataType ${a}.`,
36
- path: "dataType"
37
- }
38
- } : t;
39
- }
40
- function d(e, r) {
41
- var t, a, o, n;
42
- return e.granularity === r.granularity && e.calendar.tz === r.calendar.tz && e.calendar.weekStart === r.calendar.weekStart && ((t = e.calendar.fiscalCalendar) == null ? void 0 : t.kind) === ((a = r.calendar.fiscalCalendar) == null ? void 0 : a.kind) && ((o = e.calendar.fiscalCalendar) == null ? void 0 : o.yearStartMonth) === ((n = r.calendar.fiscalCalendar) == null ? void 0 : n.yearStartMonth);
43
- }
44
- function k(e, r) {
45
- const t = /* @__PURE__ */ new Map();
46
- for (const a of e) {
47
- if (t.has(a.key))
48
- return {
49
- ok: !1,
50
- error: {
51
- code: l.invalidMetadata,
52
- message: `Canonical result contains duplicate column key "${a.key}".`,
53
- path: "columns"
54
- }
55
- };
56
- if (t.set(a.key, a), a.temporalBucket) {
57
- const o = s(a, {
58
- metadataRequired: !1
59
- });
60
- if (!o.ok)
61
- return {
62
- ok: !1,
63
- error: {
64
- ...o.error,
65
- path: `columns.${a.key}.${o.error.path || "temporalBucket"}`
66
- }
67
- };
68
- }
69
- }
70
- for (const a of r) {
71
- const o = t.get(a.key);
72
- if (!o)
73
- return {
74
- ok: !1,
75
- error: {
76
- code: l.missingMetadata,
77
- message: `Activated temporal bucket result is missing column "${a.key}".`,
78
- path: `columns.${a.key}`
79
- }
80
- };
81
- const n = s(o, {
82
- metadataRequired: !0
83
- });
84
- if (!n.ok)
85
- return {
86
- ok: !1,
87
- error: {
88
- ...n.error,
89
- path: `columns.${a.key}.${n.error.path || "temporalBucket"}`
90
- }
91
- };
92
- if (!n.value || !d(n.value, a.metadata))
93
- return {
94
- ok: !1,
95
- error: {
96
- code: l.invalidMetadata,
97
- message: `Temporal bucket metadata for column "${a.key}" contradicts the governed query context.`,
98
- path: `columns.${a.key}.temporalBucket`
99
- }
100
- };
101
- }
102
- return { ok: !0, value: e };
103
- }
104
- export {
105
- s as a,
106
- k as b,
107
- c as v
108
- };