react-semaphor 0.1.556 → 0.1.557

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 (75) hide show
  1. package/DATA_APP_SDK.md +6 -29
  2. package/dist/analytics-protocol/index.js +19 -20
  3. package/dist/assistant-context/index.js +1 -1
  4. package/dist/brand-studio/index.js +28 -29
  5. package/dist/briefings/index.js +55 -56
  6. package/dist/chunks/{assistant-chat-C7Acww1T.js → assistant-chat-WMTpYirZ.js} +78 -80
  7. package/dist/chunks/{bookmark-state-7iZErWnR.js → bookmark-state-PjQpxbG7.js} +3 -3
  8. package/dist/chunks/{braces-o9UiRQes.js → braces-BOErQVyi.js} +1 -1
  9. package/dist/chunks/{comparison-window-caption-BseG5aOZ.js → comparison-window-caption-Dc7BaCMz.js} +186 -189
  10. package/dist/chunks/{custom-visual-inputs-ChuKjx27.js → custom-visual-inputs-CxYI-gFa.js} +1 -1
  11. package/dist/chunks/{dashboard-BU6rE5kV.js → dashboard-4D8Vy4pL.js} +1 -1
  12. package/dist/chunks/{dashboard-briefing-launcher-qrYd2zkN.js → dashboard-briefing-launcher-C4EmOfxs.js} +147 -149
  13. package/dist/chunks/{dashboard-controls-BsapXI2H.js → dashboard-controls-DBWykmvL.js} +170 -172
  14. package/dist/chunks/{dashboard-json-CJqPqYnI.js → dashboard-json-DiX-p0F7.js} +20 -21
  15. package/dist/chunks/{document-dashboard-inputs-BNSprf5_.js → document-dashboard-inputs-DP5hquBR.js} +30 -30
  16. package/dist/chunks/{edit-dashboard-visual-CjAdV-WG.js → edit-dashboard-visual-n1jLV_7V.js} +4773 -4802
  17. package/dist/chunks/{filter-reach-copy-BTrqtFkh.js → filter-reach-copy-BB9iakLA.js} +147 -148
  18. package/dist/chunks/{filter-value-text-CJTJDCym.js → filter-value-text-CUBpotVN.js} +3 -3
  19. package/dist/chunks/{global-date-filter-utils-CTVf3dG3.js → global-date-filter-utils-Cc5tqkoW.js} +585 -591
  20. package/dist/chunks/{index-B_vIRa-q.js → index-CgjhzkKM.js} +69 -70
  21. package/dist/chunks/{layout-grid-Bgzth8vd.js → layout-grid-CcNklCwL.js} +1 -1
  22. package/dist/chunks/{list-filter-DsaTbM3J.js → list-filter-Ds_4UTpD.js} +1 -1
  23. package/dist/chunks/{matrix-analytical-definition-Cg0ioFGQ.js → matrix-analytical-definition-4GTUDheD.js} +3 -3
  24. package/dist/chunks/{matrix-card-yYibXSw1.js → matrix-card-fS_4O7zA.js} +2 -2
  25. package/dist/chunks/{matrix-member-presentation-DEEauKXC.js → matrix-member-presentation-Dj7HaAHC.js} +1 -1
  26. package/dist/chunks/{matrix-operation-contract-C1G6AJNh.js → matrix-operation-contract-CpgLZ7E5.js} +21 -21
  27. package/dist/chunks/{metric-comparison-BfcmwxM1.js → metric-comparison-C8LY7GG5.js} +1 -1
  28. package/dist/chunks/{palette-D10o_yYX.js → palette-DMkIhagj.js} +1 -1
  29. package/dist/chunks/{matrix-formatter-C2kjsCDf.js → pivot-result-contract-expectations-DMk-mKhG.js} +444 -395
  30. package/dist/chunks/{pivot-result-identity-CWi5WrrY.js → pivot-result-identity-CrQ54Xbj.js} +1 -1
  31. package/dist/chunks/{raw-temporal-presentation-DWzLIHc3.js → raw-temporal-presentation-DdEpgPRB.js} +24 -25
  32. package/dist/chunks/report-preferences-dialog-CFg5VFLk.js +2109 -0
  33. package/dist/chunks/{report-runtime-context-BgM-iNWB.js → report-runtime-context-CohdtiMg.js} +1 -1
  34. package/dist/chunks/{resolve-dashboard-input-context-Df8V5QHW.js → resolve-dashboard-input-context-Djl3kCFL.js} +224 -226
  35. package/dist/chunks/{save-CfJpQQ68.js → save-D1EpMcwT.js} +1 -1
  36. package/dist/chunks/{saved-dashboard-context-VvXI6r03.js → saved-dashboard-context-umlQFevH.js} +8 -8
  37. package/dist/chunks/selection-reducer-_d6aKJnj.js +46 -0
  38. package/dist/chunks/{semaphor-ready-indicator-fejZmdq9.js → semaphor-ready-indicator-4cOp6sla.js} +40458 -43400
  39. package/dist/chunks/{shelf-drop-preview-context-BuTCXe-S.js → shelf-drop-preview-context-DAtRuvR7.js} +6 -6
  40. package/dist/chunks/{source-entity-resolution-B46EZIzX.js → source-entity-resolution-DXW1HpKf.js} +1 -1
  41. package/dist/chunks/{switch-Bq92UGId.js → switch-9CJt5EF_.js} +1430 -1341
  42. package/dist/chunks/{table-export-sheet-noKl8-en.js → table-export-sheet-CTCTA_bd.js} +1 -1
  43. package/dist/chunks/{table-settings-PpINOzw8.js → table-settings-DF1gdVQR.js} +2 -2
  44. package/dist/chunks/temporal-input-presentation-DoSniQj1.js +2939 -0
  45. package/dist/chunks/{token-types--0bgRCaO.js → token-types-DFyLflLY.js} +1 -1
  46. package/dist/chunks/{upload-BFX7apKV.js → upload-LSNKpt0w.js} +1 -1
  47. package/dist/chunks/{use-create-flow-overlay-state-Cz-ve64t.js → use-create-flow-overlay-state-esyMT9vU.js} +124 -126
  48. package/dist/chunks/{validators-CZo_H4E6.js → validators-hmfNNQz8.js} +5 -5
  49. package/dist/chunks/zoned-wall-clock-E35Frf9v.js +191 -0
  50. package/dist/dashboard/index.js +2 -2
  51. package/dist/dashboard-authoring/index.js +130 -131
  52. package/dist/data-app-sdk/index.js +788 -4153
  53. package/dist/data-app-sdk-adapters/index.js +2 -2
  54. package/dist/data-app-sdk-validation/index.js +5 -5
  55. package/dist/format-utils/index.js +230 -233
  56. package/dist/index.js +216 -217
  57. package/dist/report-runtime-context/index.js +1 -1
  58. package/dist/style.css +1 -1
  59. package/dist/surfboard/index.js +2 -2
  60. package/dist/types/data-app-sdk/contracts.d.ts +0 -146
  61. package/dist/types/data-app-sdk/index.d.ts +0 -2
  62. package/dist/types/index.js +6 -6
  63. package/dist/types/shared/dashboard-authoring/filter-model/filter-definitions.d.ts +1 -7
  64. package/package.json +1 -3
  65. package/src/data-app-sdk/README.md +7 -31
  66. package/dist/chunks/pivot-result-contract-expectations-fKBHFPfz.js +0 -56
  67. package/dist/chunks/raw-temporal-contract-CjHaUIsE.js +0 -64
  68. package/dist/chunks/report-preferences-dialog-D_wrbIQt.js +0 -2261
  69. package/dist/chunks/selection-reducer-By4CSmEF.js +0 -111
  70. package/dist/chunks/temporal-bucket-DzyadxVY.js +0 -2071
  71. package/dist/chunks/temporal-input-presentation-CJWS4d0L.js +0 -879
  72. package/dist/chunks/x-4f5U2XwU.js +0 -100
  73. package/dist/chunks/zoned-wall-clock-MulfA26h.js +0 -129
  74. package/dist/types/data-app-sdk/devtools/index.d.ts +0 -49
  75. package/dist/types/data-app-sdk/devtools.d.ts +0 -1
@@ -1,2071 +0,0 @@
1
- var Ke = Object.defineProperty;
2
- var Ve = (e, t, r) => t in e ? Ke(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var O = (e, t, r) => Ve(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { aP as we, aQ as Ge } from "./validators-CZo_H4E6.js";
5
- import { canonicalizeSupportedLocale as _, canonicalizeSupportedCurrencyCode as q } from "../value-format-preferences/index.js";
6
- import { i as F } from "./analytics-base-schemas-BUFUoO6G.js";
7
- import { p as Be } from "./raw-temporal-contract-CjHaUIsE.js";
8
- function We(e) {
9
- if (!e || typeof e != "object") return !1;
10
- const t = e.type;
11
- return t === "number" || t === "currency" || t === "percent" || t === "scientific";
12
- }
13
- function kr(e) {
14
- return We(e) || !!e && typeof e == "object" && e.type === "duration";
15
- }
16
- const xe = [
17
- "day",
18
- "hour",
19
- "minute",
20
- "second",
21
- "millisecond"
22
- ], K = {
23
- day: 864e5,
24
- hour: 36e5,
25
- minute: 6e4,
26
- second: 1e3,
27
- millisecond: 1
28
- }, Je = {
29
- day: "d",
30
- hour: "hr",
31
- minute: "min",
32
- second: "s",
33
- millisecond: "ms"
34
- }, Xe = {
35
- day: ["day", "days"],
36
- hour: ["hour", "hours"],
37
- minute: ["minute", "minutes"],
38
- second: ["second", "seconds"],
39
- millisecond: ["millisecond", "milliseconds"]
40
- };
41
- function Qe(e) {
42
- return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
43
- }
44
- function ve(e, t) {
45
- return Qe(e) ? e : t;
46
- }
47
- function ee(e, t) {
48
- return xe.indexOf(ve(e, t));
49
- }
50
- function et(e, t) {
51
- const r = ee(e, "day"), n = ee(t, "second"), a = Math.min(r, n), i = Math.max(r, n);
52
- return xe.slice(a, i + 1);
53
- }
54
- function tt(e, t) {
55
- return e * K[ve(t, "second")];
56
- }
57
- function rt(e, t) {
58
- const r = et(t.largestUnit, t.smallestUnit), n = r[r.length - 1], a = K[n];
59
- let i = Math.round(e / a) * a;
60
- return r.map((s) => {
61
- const c = K[s], o = Math.floor(i / c);
62
- return i -= o * c, { unit: s, value: o };
63
- });
64
- }
65
- function nt(e, t) {
66
- const r = e.filter((i) => i.value !== 0), n = r.length > 0 ? r : [e[e.length - 1]], a = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : n.length;
67
- return n.slice(0, a).map((i) => `${i.value}${Je[i.unit]}`).join(" ");
68
- }
69
- function at(e, t) {
70
- const r = e.filter((i) => i.value !== 0), n = r.length > 0 ? r : [e[e.length - 1]], a = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : n.length;
71
- return n.slice(0, a).map((i) => {
72
- const [s, c] = Xe[i.unit];
73
- return `${i.value} ${i.value === 1 ? s : c}`;
74
- }).join(" ");
75
- }
76
- function it(e) {
77
- const t = e.some(
78
- (o) => o.unit === "day" && o.value !== 0
79
- ), r = e.some((o) => o.unit === "millisecond"), n = e.findIndex((o) => o.value !== 0), a = Math.max(0, e.length - 2), i = t ? 0 : n === -1 ? a : Math.min(n, a), s = n === -1 ? e.slice(a) : e.slice(i);
80
- if (s.length === 0)
81
- return "0";
82
- const c = s.map((o, u) => o.unit === "millisecond" ? String(o.value).padStart(3, "0") : u === 0 ? String(o.value) : String(o.value).padStart(2, "0")).join(":");
83
- return r ? c.replace(/:(\d{3})$/, ".$1") : c;
84
- }
85
- function st(e, t, r) {
86
- const n = `${r.prefix || ""}${e}${r.suffix || ""}`;
87
- return t ? r.negativeInParentheses ? `(${n})` : `-${n}` : n;
88
- }
89
- function ct(e, t = {}) {
90
- if (e == null)
91
- return "";
92
- const r = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : NaN;
93
- if (!Number.isFinite(r))
94
- return "";
95
- const n = t.inputUnit || "second", a = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", i = r < 0, s = Math.abs(tt(r, n)), c = rt(s, t), o = a === "digital" ? it(c) : a === "long" ? at(c, t.maxUnits) : nt(c, t.maxUnits);
96
- return st(o, i, t);
97
- }
98
- function _e(e, t) {
99
- return ct(
100
- e !== null && typeof e == "object" ? e.value : e,
101
- {
102
- inputUnit: t.inputUnit,
103
- outputStyle: t.outputStyle,
104
- largestUnit: t.largestUnit,
105
- smallestUnit: t.smallestUnit,
106
- maxUnits: t.maxUnits,
107
- prefix: t.prefix,
108
- suffix: t.suffix,
109
- negativeInParentheses: t.negativeStyle === "parentheses"
110
- }
111
- );
112
- }
113
- let te;
114
- function re(e, t) {
115
- const r = e.format;
116
- return r(t);
117
- }
118
- function ot(e, t) {
119
- if (te ?? (te = re(
120
- new Intl.NumberFormat("en-US", { useGrouping: !1, maximumFractionDigits: 6 }),
121
- "9007199254740993.000009"
122
- ) === "9007199254740993.000009"), !te)
123
- throw new RangeError("This runtime cannot format exact decimal strings.");
124
- const r = Number(e);
125
- if (!Number.isFinite(r) || r === 0 && e !== "0")
126
- throw new RangeError("Exact value is outside the Intl formatting range; use raw text.");
127
- return re(t, e);
128
- }
129
- function P(e) {
130
- return typeof e == "number" ? e < 0 : e.value.startsWith("-");
131
- }
132
- function C(e) {
133
- return typeof e == "number" ? Math.abs(e) : P(e) ? { ...e, value: e.value.slice(1) } : e;
134
- }
135
- function ke(e, t) {
136
- return typeof e == "number" ? e * t : {
137
- kind: "exact_number",
138
- type: "decimal",
139
- value: we(e.value, t)
140
- };
141
- }
142
- function Y(e, t) {
143
- return t === 0 ? e : typeof e == "number" ? e / 10 ** t : {
144
- kind: "exact_number",
145
- type: "decimal",
146
- value: we(e.value, `1e-${t}`)
147
- };
148
- }
149
- function S(e, t) {
150
- return typeof e == "number" ? t.format(e) : ot(e.value, t);
151
- }
152
- function ne(e) {
153
- if (!e) return !1;
154
- const t = e.toLowerCase().replace("_", "-");
155
- return t === "en-in" || t.startsWith("en-in-");
156
- }
157
- function ae(e, t) {
158
- const r = C(e), n = (a) => typeof r == "number" ? r >= a : Ge(r.value, String(a)) >= 0;
159
- return n(1e12) ? { power: 12, suffix: "T" } : n(1e9) ? { power: 9, suffix: "B" } : ne(t) && n(1e7) ? { power: 7, suffix: "Cr" } : n(1e6) ? { power: 6, suffix: "M" } : ne(t) && n(1e5) ? { power: 5, suffix: "L" } : n(1e3) ? { power: 3, suffix: "K" } : { power: 0, suffix: "" };
160
- }
161
- function V(e, t) {
162
- try {
163
- const r = x(t);
164
- return ae(e, r);
165
- } catch {
166
- return ae(e, "en-US");
167
- }
168
- }
169
- const Me = 500, N = /* @__PURE__ */ new Map(), b = /* @__PURE__ */ new Map();
170
- function T(e, t = {}) {
171
- const r = `${e}|${JSON.stringify(t)}`;
172
- let n = N.get(r);
173
- return n || (n = new Intl.NumberFormat(e, t), N.size >= Me && N.clear(), N.set(r, n)), n;
174
- }
175
- function ut(e) {
176
- let t = b.get(e);
177
- if (t === void 0) {
178
- try {
179
- T(e), t = !0;
180
- } catch {
181
- t = !1;
182
- }
183
- b.size >= Me && b.clear(), b.set(e, t);
184
- }
185
- return t;
186
- }
187
- function x(e) {
188
- return e && ut(e) ? e : "en-US";
189
- }
190
- function J(e, t) {
191
- if (e == null || Number.isNaN(e))
192
- return "";
193
- const r = x(t == null ? void 0 : t.locale);
194
- let n = e;
195
- if (t != null && t.multiplyBy && (n = ke(n, t.multiplyBy)), t != null && t.useSuffix) {
196
- const { power: i, suffix: s } = V(n, r);
197
- n = Y(n, i);
198
- const c = S(n, T(r, {
199
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
200
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
201
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
202
- }));
203
- return `${(t == null ? void 0 : t.prefix) ?? ""}${c}${s}${(t == null ? void 0 : t.suffix) ?? ""}`;
204
- }
205
- const a = S(n, T(r, {
206
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
207
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
208
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
209
- }));
210
- if (t != null && t.negativeInParentheses && P(n)) {
211
- const i = a.replace("-", "");
212
- return `(${(t == null ? void 0 : t.prefix) ?? ""}${i}${(t == null ? void 0 : t.suffix) ?? ""})`;
213
- }
214
- return `${(t == null ? void 0 : t.prefix) ?? ""}${a}${(t == null ? void 0 : t.suffix) ?? ""}`;
215
- }
216
- function Ne(e, t) {
217
- if (e == null || Number.isNaN(e))
218
- return "";
219
- const r = x(t == null ? void 0 : t.locale), n = (t == null ? void 0 : t.currency) || "USD", a = P(e), i = !!(t != null && t.negativeInParentheses && a), s = i ? C(e) : e;
220
- try {
221
- if (t != null && t.useSuffix) {
222
- const { power: o, suffix: u } = V(s, r), l = Y(s, o), d = `${S(l, T(r, {
223
- style: "currency",
224
- currency: n,
225
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
226
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
227
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
228
- }))}${u}`;
229
- return i ? `(${d})` : d;
230
- }
231
- const c = S(s, T(r, {
232
- style: "currency",
233
- currency: n,
234
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
235
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
236
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
237
- }));
238
- return i ? `(${c})` : c;
239
- } catch {
240
- const c = C(e), o = t != null && t.useSuffix ? V(c, r) : { power: 0, suffix: "" }, u = J(
241
- Y(c, o.power),
242
- {
243
- locale: r,
244
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
245
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
246
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
247
- }
248
- ), l = `${n} ${u}${o.suffix}`;
249
- return a ? t != null && t.negativeInParentheses ? `(${l})` : `-${l}` : l;
250
- }
251
- }
252
- function be(e, t) {
253
- if (e == null || Number.isNaN(e))
254
- return "";
255
- const r = x(t == null ? void 0 : t.locale), a = (t == null ? void 0 : t.alreadyPercent) ?? (t == null ? void 0 : t.percentValueMode) === "whole" ? Y(e, 2) : e;
256
- return S(a, T(r, {
257
- style: "percent",
258
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
259
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
260
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
261
- }));
262
- }
263
- function $e(e, t) {
264
- if (e == null || Number.isNaN(e))
265
- return "";
266
- const r = x(t == null ? void 0 : t.locale);
267
- return S(e, T(r, {
268
- notation: "scientific",
269
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
270
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2
271
- }));
272
- }
273
- function Ie(e, t) {
274
- if (e == null || Number.isNaN(e))
275
- return "";
276
- const r = t.scale === void 0 ? e : ke(e, t.scale), n = t.negativeStyle === "parentheses" && P(r), a = n ? C(r) : r, i = {
277
- style: t.type === "number" ? "decimal" : t.type,
278
- locale: t.locale,
279
- currency: t.currency,
280
- minimumFractionDigits: t.minimumFractionDigits,
281
- maximumFractionDigits: t.maximumFractionDigits,
282
- useGrouping: t.useGrouping,
283
- percentValueMode: t.percentValueMode,
284
- useSuffix: t.compact
285
- };
286
- let s;
287
- switch (t.type) {
288
- case "currency":
289
- s = Ne(a, i);
290
- break;
291
- case "percent":
292
- s = be(a, i);
293
- break;
294
- case "scientific":
295
- s = $e(a, i);
296
- break;
297
- default:
298
- s = J(a, i);
299
- break;
300
- }
301
- const c = `${t.prefix ?? ""}${s}${t.suffix ?? ""}`;
302
- return n ? `(${c})` : c;
303
- }
304
- function Mr(e, t) {
305
- return t.type === "duration" ? e == null ? "" : _e(e, t) : Ie(e, t);
306
- }
307
- function Nr(e, t, r = "en-US") {
308
- if (e == null || typeof e == "number" && isNaN(e))
309
- return "";
310
- if ((t == null ? void 0 : t.style) === "duration")
311
- return _e(e, {
312
- ...t.duration,
313
- prefix: t.prefix,
314
- suffix: t.suffix,
315
- negativeStyle: t.negativeStyle
316
- });
317
- const n = x((t == null ? void 0 : t.locale) || r), a = (t == null ? void 0 : t.style) || "decimal", i = a === "decimal" ? "number" : a;
318
- return i === "currency" && T(n, {
319
- style: "currency",
320
- currency: (t == null ? void 0 : t.currency) || "USD"
321
- }), Ie(e, {
322
- type: i,
323
- locale: n,
324
- currency: i === "currency" ? (t == null ? void 0 : t.currency) || "USD" : void 0,
325
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
326
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
327
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0,
328
- percentValueMode: i === "percent" ? (t == null ? void 0 : t.percentValueMode) ?? "whole" : void 0,
329
- scale: t == null ? void 0 : t.scale,
330
- compact: t == null ? void 0 : t.compact,
331
- negativeStyle: t == null ? void 0 : t.negativeStyle,
332
- prefix: t == null ? void 0 : t.prefix,
333
- suffix: t == null ? void 0 : t.suffix
334
- });
335
- }
336
- function br(e, t, r) {
337
- const n = {
338
- style: t === "currency" ? "currency" : t === "percent" ? "percent" : "decimal",
339
- locale: r == null ? void 0 : r.locale,
340
- currency: r == null ? void 0 : r.currency,
341
- minimumFractionDigits: r == null ? void 0 : r.decimalPlaces,
342
- maximumFractionDigits: r == null ? void 0 : r.decimalPlaces,
343
- useSuffix: r == null ? void 0 : r.useSuffix,
344
- prefix: r == null ? void 0 : r.prefix,
345
- suffix: r == null ? void 0 : r.suffix,
346
- negativeInParentheses: r == null ? void 0 : r.negativeInParentheses,
347
- multiplyBy: r == null ? void 0 : r.multiplyBy
348
- };
349
- switch (t) {
350
- case "currency":
351
- return Ne(e, n);
352
- case "percent":
353
- return be(e, n);
354
- case "scientific":
355
- return $e(e, n);
356
- default:
357
- return J(e, n);
358
- }
359
- }
360
- const $r = 6048e5, Ir = 864e5, Fr = 6e4, Cr = 36e5, Yr = 525600, Er = 43200, zr = 1440;
361
- function lt(e, t) {
362
- const r = gt(t);
363
- return "formatToParts" in r ? ft(r, e) : dt(r, e);
364
- }
365
- const mt = {
366
- year: 0,
367
- month: 1,
368
- day: 2,
369
- hour: 3,
370
- minute: 4,
371
- second: 5
372
- };
373
- function ft(e, t) {
374
- try {
375
- const r = e.formatToParts(t), n = [];
376
- for (let a = 0; a < r.length; a++) {
377
- const i = mt[r[a].type];
378
- i !== void 0 && (n[i] = parseInt(r[a].value, 10));
379
- }
380
- return n;
381
- } catch (r) {
382
- if (r instanceof RangeError)
383
- return [NaN];
384
- throw r;
385
- }
386
- }
387
- function dt(e, t) {
388
- const r = e.format(t), n = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(r);
389
- return [
390
- parseInt(n[3], 10),
391
- parseInt(n[1], 10),
392
- parseInt(n[2], 10),
393
- parseInt(n[4], 10),
394
- parseInt(n[5], 10),
395
- parseInt(n[6], 10)
396
- ];
397
- }
398
- const U = {}, ie = new Intl.DateTimeFormat("en-US", {
399
- hourCycle: "h23",
400
- timeZone: "America/New_York",
401
- year: "numeric",
402
- month: "2-digit",
403
- day: "2-digit",
404
- hour: "2-digit",
405
- minute: "2-digit",
406
- second: "2-digit"
407
- }).format(/* @__PURE__ */ new Date("2014-06-25T04:00:00.123Z")), yt = ie === "06/25/2014, 00:00:00" || ie === "‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";
408
- function gt(e) {
409
- return U[e] || (U[e] = yt ? new Intl.DateTimeFormat("en-US", {
410
- hourCycle: "h23",
411
- timeZone: e,
412
- year: "numeric",
413
- month: "numeric",
414
- day: "2-digit",
415
- hour: "2-digit",
416
- minute: "2-digit",
417
- second: "2-digit"
418
- }) : new Intl.DateTimeFormat("en-US", {
419
- hour12: !1,
420
- timeZone: e,
421
- year: "numeric",
422
- month: "numeric",
423
- day: "2-digit",
424
- hour: "2-digit",
425
- minute: "2-digit",
426
- second: "2-digit"
427
- })), U[e];
428
- }
429
- function X(e, t, r, n, a, i, s) {
430
- const c = /* @__PURE__ */ new Date(0);
431
- return c.setUTCFullYear(e, t, r), c.setUTCHours(n, a, i, s), c;
432
- }
433
- const se = 36e5, ht = 6e4, L = {
434
- timezoneZ: /^(Z)$/,
435
- timezoneHH: /^([+-]\d{2})$/,
436
- timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
437
- };
438
- function Fe(e, t, r) {
439
- if (!e)
440
- return 0;
441
- let n = L.timezoneZ.exec(e);
442
- if (n)
443
- return 0;
444
- let a, i;
445
- if (n = L.timezoneHH.exec(e), n)
446
- return a = parseInt(n[1], 10), ce(a) ? -(a * se) : NaN;
447
- if (n = L.timezoneHHMM.exec(e), n) {
448
- a = parseInt(n[2], 10);
449
- const s = parseInt(n[3], 10);
450
- return ce(a, s) ? (i = Math.abs(a) * se + s * ht, n[1] === "+" ? -i : i) : NaN;
451
- }
452
- if (Dt(e)) {
453
- t = new Date(t || Date.now());
454
- const s = r ? t : pt(t), c = G(s, e);
455
- return -(r ? c : Tt(t, c, e));
456
- }
457
- return NaN;
458
- }
459
- function pt(e) {
460
- return X(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds());
461
- }
462
- function G(e, t) {
463
- const r = lt(e, t), n = X(r[0], r[1] - 1, r[2], r[3] % 24, r[4], r[5], 0).getTime();
464
- let a = e.getTime();
465
- const i = a % 1e3;
466
- return a -= i >= 0 ? i : 1e3 + i, n - a;
467
- }
468
- function Tt(e, t, r) {
469
- let a = e.getTime() - t;
470
- const i = G(new Date(a), r);
471
- if (t === i)
472
- return t;
473
- a -= i - t;
474
- const s = G(new Date(a), r);
475
- return i === s ? i : Math.max(i, s);
476
- }
477
- function ce(e, t) {
478
- return -23 <= e && e <= 23 && (t == null || 0 <= t && t <= 59);
479
- }
480
- const oe = {};
481
- function Dt(e) {
482
- if (oe[e])
483
- return !0;
484
- try {
485
- return new Intl.DateTimeFormat(void 0, { timeZone: e }), oe[e] = !0, !0;
486
- } catch {
487
- return !1;
488
- }
489
- }
490
- function ue(e) {
491
- const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()));
492
- return t.setUTCFullYear(e.getFullYear()), +e - +t;
493
- }
494
- const Ce = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/, R = 36e5, le = 6e4, St = 2, y = {
495
- dateTimePattern: /^([0-9W+-]+)(T| )(.*)/,
496
- datePattern: /^([0-9W+-]+)(.*)/,
497
- // year tokens
498
- YY: /^(\d{2})$/,
499
- YYY: [
500
- /^([+-]\d{2})$/,
501
- // 0 additional digits
502
- /^([+-]\d{3})$/,
503
- // 1 additional digit
504
- /^([+-]\d{4})$/
505
- // 2 additional digits
506
- ],
507
- YYYY: /^(\d{4})/,
508
- YYYYY: [
509
- /^([+-]\d{4})/,
510
- // 0 additional digits
511
- /^([+-]\d{5})/,
512
- // 1 additional digit
513
- /^([+-]\d{6})/
514
- // 2 additional digits
515
- ],
516
- // date tokens
517
- MM: /^-(\d{2})$/,
518
- DDD: /^-?(\d{3})$/,
519
- MMDD: /^-?(\d{2})-?(\d{2})$/,
520
- Www: /^-?W(\d{2})$/,
521
- WwwD: /^-?W(\d{2})-?(\d{1})$/,
522
- HH: /^(\d{2}([.,]\d*)?)$/,
523
- HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/,
524
- HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,
525
- // time zone tokens (to identify the presence of a tz)
526
- timeZone: Ce
527
- };
528
- function me(e, t = {}) {
529
- if (arguments.length < 1)
530
- throw new TypeError("1 argument required, but only " + arguments.length + " present");
531
- if (e === null)
532
- return /* @__PURE__ */ new Date(NaN);
533
- const r = t.additionalDigits == null ? St : Number(t.additionalDigits);
534
- if (r !== 2 && r !== 1 && r !== 0)
535
- throw new RangeError("additionalDigits must be 0, 1 or 2");
536
- if (e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]")
537
- return new Date(e.getTime());
538
- if (typeof e == "number" || Object.prototype.toString.call(e) === "[object Number]")
539
- return new Date(e);
540
- if (Object.prototype.toString.call(e) !== "[object String]")
541
- return /* @__PURE__ */ new Date(NaN);
542
- const n = wt(e), { year: a, restDateString: i } = xt(n.date, r), s = vt(i, a);
543
- if (s === null || isNaN(s.getTime()))
544
- return /* @__PURE__ */ new Date(NaN);
545
- if (s) {
546
- const c = s.getTime();
547
- let o = 0, u;
548
- if (n.time && (o = _t(n.time), o === null || isNaN(o)))
549
- return /* @__PURE__ */ new Date(NaN);
550
- if (n.timeZone || t.timeZone) {
551
- if (u = Fe(n.timeZone || t.timeZone, new Date(c + o)), isNaN(u))
552
- return /* @__PURE__ */ new Date(NaN);
553
- } else
554
- u = ue(new Date(c + o)), u = ue(new Date(c + o + u));
555
- return new Date(c + o + u);
556
- } else
557
- return /* @__PURE__ */ new Date(NaN);
558
- }
559
- function wt(e) {
560
- const t = {};
561
- let r = y.dateTimePattern.exec(e), n;
562
- if (r ? (t.date = r[1], n = r[3]) : (r = y.datePattern.exec(e), r ? (t.date = r[1], n = r[2]) : (t.date = null, n = e)), n) {
563
- const a = y.timeZone.exec(n);
564
- a ? (t.time = n.replace(a[1], ""), t.timeZone = a[1].trim()) : t.time = n;
565
- }
566
- return t;
567
- }
568
- function xt(e, t) {
569
- if (e) {
570
- const r = y.YYY[t], n = y.YYYYY[t];
571
- let a = y.YYYY.exec(e) || n.exec(e);
572
- if (a) {
573
- const i = a[1];
574
- return {
575
- year: parseInt(i, 10),
576
- restDateString: e.slice(i.length)
577
- };
578
- }
579
- if (a = y.YY.exec(e) || r.exec(e), a) {
580
- const i = a[1];
581
- return {
582
- year: parseInt(i, 10) * 100,
583
- restDateString: e.slice(i.length)
584
- };
585
- }
586
- }
587
- return {
588
- year: null
589
- };
590
- }
591
- function vt(e, t) {
592
- if (t === null)
593
- return null;
594
- let r, n, a;
595
- if (!e || !e.length)
596
- return r = /* @__PURE__ */ new Date(0), r.setUTCFullYear(t), r;
597
- let i = y.MM.exec(e);
598
- if (i)
599
- return r = /* @__PURE__ */ new Date(0), n = parseInt(i[1], 10) - 1, de(t, n) ? (r.setUTCFullYear(t, n), r) : /* @__PURE__ */ new Date(NaN);
600
- if (i = y.DDD.exec(e), i) {
601
- r = /* @__PURE__ */ new Date(0);
602
- const s = parseInt(i[1], 10);
603
- return Nt(t, s) ? (r.setUTCFullYear(t, 0, s), r) : /* @__PURE__ */ new Date(NaN);
604
- }
605
- if (i = y.MMDD.exec(e), i) {
606
- r = /* @__PURE__ */ new Date(0), n = parseInt(i[1], 10) - 1;
607
- const s = parseInt(i[2], 10);
608
- return de(t, n, s) ? (r.setUTCFullYear(t, n, s), r) : /* @__PURE__ */ new Date(NaN);
609
- }
610
- if (i = y.Www.exec(e), i)
611
- return a = parseInt(i[1], 10) - 1, ye(a) ? fe(t, a) : /* @__PURE__ */ new Date(NaN);
612
- if (i = y.WwwD.exec(e), i) {
613
- a = parseInt(i[1], 10) - 1;
614
- const s = parseInt(i[2], 10) - 1;
615
- return ye(a, s) ? fe(t, a, s) : /* @__PURE__ */ new Date(NaN);
616
- }
617
- return null;
618
- }
619
- function _t(e) {
620
- let t, r, n = y.HH.exec(e);
621
- if (n)
622
- return t = parseFloat(n[1].replace(",", ".")), H(t) ? t % 24 * R : NaN;
623
- if (n = y.HHMM.exec(e), n)
624
- return t = parseInt(n[1], 10), r = parseFloat(n[2].replace(",", ".")), H(t, r) ? t % 24 * R + r * le : NaN;
625
- if (n = y.HHMMSS.exec(e), n) {
626
- t = parseInt(n[1], 10), r = parseInt(n[2], 10);
627
- const a = parseFloat(n[3].replace(",", "."));
628
- return H(t, r, a) ? t % 24 * R + r * le + a * 1e3 : NaN;
629
- }
630
- return null;
631
- }
632
- function fe(e, t, r) {
633
- t = t || 0, r = r || 0;
634
- const n = /* @__PURE__ */ new Date(0);
635
- n.setUTCFullYear(e, 0, 4);
636
- const a = n.getUTCDay() || 7, i = t * 7 + r + 1 - a;
637
- return n.setUTCDate(n.getUTCDate() + i), n;
638
- }
639
- const kt = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], Mt = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
640
- function Ye(e) {
641
- return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
642
- }
643
- function de(e, t, r) {
644
- if (t < 0 || t > 11)
645
- return !1;
646
- if (r != null) {
647
- if (r < 1)
648
- return !1;
649
- const n = Ye(e);
650
- if (n && r > Mt[t] || !n && r > kt[t])
651
- return !1;
652
- }
653
- return !0;
654
- }
655
- function Nt(e, t) {
656
- if (t < 1)
657
- return !1;
658
- const r = Ye(e);
659
- return !(r && t > 366 || !r && t > 365);
660
- }
661
- function ye(e, t) {
662
- return !(e < 0 || e > 52 || t != null && (t < 0 || t > 6));
663
- }
664
- function H(e, t, r) {
665
- return !(e < 0 || e >= 25 || t != null && (t < 0 || t >= 60) || r != null && (r < 0 || r >= 60));
666
- }
667
- function bt(e, t, r) {
668
- if (typeof e == "string" && !e.match(Ce))
669
- return me(e, { ...r, timeZone: t });
670
- e = me(e, r);
671
- const n = X(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()).getTime(), a = Fe(t, new Date(n));
672
- return new Date(n + a);
673
- }
674
- function g(e) {
675
- if (e === null || typeof e != "object" || Array.isArray(e))
676
- return !1;
677
- const t = Object.getPrototypeOf(e);
678
- if (t === null || t === Object.prototype) return !0;
679
- const r = Object.prototype.hasOwnProperty.call(
680
- t,
681
- "constructor"
682
- ) ? t.constructor : void 0;
683
- return typeof r == "function" && Function.prototype.toString.call(r) === Function.prototype.toString.call(Object);
684
- }
685
- const $t = [
686
- "type",
687
- "locale",
688
- "minimumFractionDigits",
689
- "maximumFractionDigits",
690
- "useGrouping",
691
- "prefix",
692
- "suffix",
693
- "negativeStyle",
694
- "compact",
695
- "scale",
696
- "currency",
697
- "percentValueMode"
698
- ];
699
- function It(e) {
700
- if (!g(e))
701
- return {
702
- ok: !1,
703
- issues: [{ path: "$", message: "Numeric format must be an object." }]
704
- };
705
- const t = [], r = new Set($t);
706
- Object.keys(e).filter((i) => !r.has(i)).forEach(
707
- (i) => t.push({ path: i, message: `Unknown property "${i}".` })
708
- ), e.type !== "number" && e.type !== "currency" && e.type !== "percent" && e.type !== "scientific" && t.push({
709
- path: "type",
710
- message: "Expected number, currency, percent, or scientific."
711
- });
712
- const n = e.locale === void 0 ? void 0 : _(e.locale);
713
- e.locale !== void 0 && !n && t.push({ path: "locale", message: "Expected a supported BCP 47 locale." });
714
- const a = e.currency === void 0 ? void 0 : q(e.currency);
715
- e.currency !== void 0 && !a && t.push({
716
- path: "currency",
717
- message: "Expected a supported ISO 4217 currency code."
718
- });
719
- for (const i of ["minimumFractionDigits", "maximumFractionDigits"]) {
720
- const s = e[i];
721
- s !== void 0 && (!Number.isInteger(s) || typeof s != "number" || s < 0 || s > 20) && t.push({
722
- path: i,
723
- message: "Expected an integer from 0 to 20."
724
- });
725
- }
726
- typeof e.minimumFractionDigits == "number" && typeof e.maximumFractionDigits == "number" && e.minimumFractionDigits > e.maximumFractionDigits && t.push({
727
- path: "maximumFractionDigits",
728
- message: "Must be greater than or equal to minimumFractionDigits."
729
- });
730
- for (const i of ["useGrouping", "compact"])
731
- e[i] !== void 0 && typeof e[i] != "boolean" && t.push({ path: i, message: "Expected a boolean." });
732
- for (const i of ["prefix", "suffix"])
733
- e[i] !== void 0 && typeof e[i] != "string" && t.push({ path: i, message: "Expected a string." });
734
- return e.negativeStyle !== void 0 && e.negativeStyle !== "minus" && e.negativeStyle !== "parentheses" && t.push({
735
- path: "negativeStyle",
736
- message: "Expected minus or parentheses."
737
- }), e.percentValueMode !== void 0 && e.percentValueMode !== "fraction" && e.percentValueMode !== "whole" && t.push({
738
- path: "percentValueMode",
739
- message: "Expected fraction or whole."
740
- }), e.scale !== void 0 && (typeof e.scale != "number" || !Number.isFinite(e.scale)) && t.push({ path: "scale", message: "Expected a finite number." }), t.length > 0 ? { ok: !1, issues: t } : {
741
- ok: !0,
742
- value: {
743
- type: e.type,
744
- ...n ? { locale: n } : {},
745
- ...e.minimumFractionDigits !== void 0 ? { minimumFractionDigits: e.minimumFractionDigits } : {},
746
- ...e.maximumFractionDigits !== void 0 ? { maximumFractionDigits: e.maximumFractionDigits } : {},
747
- ...e.useGrouping !== void 0 ? { useGrouping: e.useGrouping } : {},
748
- ...e.prefix !== void 0 ? { prefix: e.prefix } : {},
749
- ...e.suffix !== void 0 ? { suffix: e.suffix } : {},
750
- ...e.negativeStyle !== void 0 ? {
751
- negativeStyle: e.negativeStyle
752
- } : {},
753
- ...e.compact !== void 0 ? { compact: e.compact } : {},
754
- ...e.scale !== void 0 ? { scale: e.scale } : {},
755
- ...a ? { currency: a } : {},
756
- ...e.percentValueMode !== void 0 ? {
757
- percentValueMode: e.percentValueMode
758
- } : {}
759
- }
760
- };
761
- }
762
- function Pr(e) {
763
- const t = It(e);
764
- if (!t.ok)
765
- return t;
766
- const r = [];
767
- return t.value.locale || r.push({
768
- path: "locale",
769
- message: "Resolved numeric formats require an explicit locale."
770
- }), t.value.minimumFractionDigits === void 0 && r.push({
771
- path: "minimumFractionDigits",
772
- message: "Resolved numeric formats require minimumFractionDigits."
773
- }), t.value.maximumFractionDigits === void 0 && r.push({
774
- path: "maximumFractionDigits",
775
- message: "Resolved numeric formats require maximumFractionDigits."
776
- }), t.value.type === "currency" && !t.value.currency && r.push({
777
- path: "currency",
778
- message: "Resolved currency formats require an explicit currency."
779
- }), r.length > 0 ? { ok: !1, issues: r } : t;
780
- }
781
- function Ar(e) {
782
- var n;
783
- const t = /* @__PURE__ */ new Set();
784
- if (e.snapshot.resolvedFormats.forEach((a, i) => {
785
- if (a.format.type !== "temporal_bucket") {
786
- if (a.scope.attachmentIndex !== void 0)
787
- throw new Error(
788
- `resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`
789
- );
790
- if (a.scope.dashboardId !== e.expectedScope.dashboardId || a.scope.cardId !== e.expectedScope.cardId)
791
- throw new Error(
792
- `resolvedFormats.${i}.scope must match the executing dashboard/card`
793
- );
794
- if (a.target.kind !== "column")
795
- throw new Error(
796
- `resolvedFormats.${i}.target must identify an export column`
797
- );
798
- if (t.has(a.target.columnKey))
799
- throw new Error(
800
- `resolvedFormats.${i} duplicates export column "${a.target.columnKey}"`
801
- );
802
- t.add(a.target.columnKey);
803
- }
804
- }), !e.useFormattedValues)
805
- return;
806
- if (!((n = e.visibleColumns) != null && n.length))
807
- throw new Error(
808
- "visibleColumns must identify every formatted export column"
809
- );
810
- const r = e.visibleColumns.find(
811
- (a) => !t.has(a)
812
- );
813
- if (r)
814
- throw new Error(
815
- `resolvedFormats is missing visible export column "${r}"`
816
- );
817
- }
818
- function Ft(e, t) {
819
- const r = new Intl.NumberFormat(e, {
820
- style: "currency",
821
- currency: t
822
- }).resolvedOptions();
823
- return {
824
- minimumFractionDigits: r.minimumFractionDigits,
825
- maximumFractionDigits: r.maximumFractionDigits
826
- };
827
- }
828
- function Ct(e) {
829
- if (e.minimumFractionDigits !== void 0 || e.maximumFractionDigits !== void 0) {
830
- const r = e.minimumFractionDigits ?? 0;
831
- return {
832
- minimumFractionDigits: r,
833
- maximumFractionDigits: e.maximumFractionDigits ?? Math.max(r, 2)
834
- };
835
- }
836
- const t = e.type === "percent" ? 1 : e.type === "scientific" ? 2 : 0;
837
- return {
838
- minimumFractionDigits: t,
839
- maximumFractionDigits: t
840
- };
841
- }
842
- function Or(e, t, r) {
843
- const n = _(e.locale) ?? t.locale, a = e.type === "number" || e.type === "currency" ? q(r) : void 0;
844
- if (!(e.type === "currency" || a !== void 0))
845
- return {
846
- ...e,
847
- locale: n,
848
- ...Ct(e)
849
- };
850
- const s = a ?? q(e.currency) ?? t.defaultCurrency, c = Ft(
851
- n,
852
- s
853
- ), o = c.minimumFractionDigits ?? 0, u = c.maximumFractionDigits ?? o, l = e.minimumFractionDigits ?? Math.min(
854
- o,
855
- e.maximumFractionDigits ?? o
856
- ), f = e.maximumFractionDigits ?? Math.max(
857
- l,
858
- u
859
- );
860
- return {
861
- ...e,
862
- type: "currency",
863
- locale: n,
864
- currency: s,
865
- minimumFractionDigits: l,
866
- maximumFractionDigits: f
867
- };
868
- }
869
- const Yt = [
870
- "YYYY",
871
- "MMMM",
872
- "MMM",
873
- "YY",
874
- "MM",
875
- "DD",
876
- "HH",
877
- "mm",
878
- "ss"
879
- ], Et = /* @__PURE__ */ new Set([" ", "-", "/", ":", ".", ",", "T"]), Ee = {
880
- week_of_short: "week",
881
- week_of_long: "week",
882
- quarter_short: "quarter",
883
- quarter_long: "quarter",
884
- fiscal_quarter_short: "quarter",
885
- fiscal_year: "year"
886
- };
887
- function zt(e) {
888
- return typeof e == "string" && Object.prototype.hasOwnProperty.call(Ee, e);
889
- }
890
- function Pt(e, t) {
891
- return Yt.find(
892
- (r) => e.startsWith(r, t)
893
- );
894
- }
895
- function k(e) {
896
- var a;
897
- if (!e || e.trim() !== e)
898
- return {
899
- ok: !1,
900
- code: "invalid_temporal_bucket_pattern",
901
- message: "Temporal bucket patterns must be non-empty and trimmed."
902
- };
903
- const t = [];
904
- let r = 0, n = !1;
905
- for (; r < e.length; ) {
906
- const i = Pt(e, r);
907
- if (i) {
908
- if (n)
909
- return {
910
- ok: !1,
911
- code: "invalid_temporal_bucket_pattern",
912
- message: "Adjacent temporal bucket tokens require a separator."
913
- };
914
- t.push({ kind: "token", value: i }), r += i.length, n = !0;
915
- continue;
916
- }
917
- const s = e[r];
918
- if (!Et.has(s))
919
- return {
920
- ok: !1,
921
- code: "invalid_temporal_bucket_pattern",
922
- message: `Unsupported temporal bucket pattern character "${s}".`
923
- };
924
- if (t.length === 0)
925
- return {
926
- ok: !1,
927
- code: "invalid_temporal_bucket_pattern",
928
- message: "Temporal bucket patterns cannot begin with a separator."
929
- };
930
- const c = t[t.length - 1];
931
- c.kind === "literal" ? c.value += s : t.push({ kind: "literal", value: s }), r += 1, n = !1;
932
- }
933
- return ((a = t[t.length - 1]) == null ? void 0 : a.kind) !== "token" ? {
934
- ok: !1,
935
- code: "invalid_temporal_bucket_pattern",
936
- message: "Temporal bucket patterns cannot end with a separator."
937
- } : { ok: !0, segments: t };
938
- }
939
- function At(e) {
940
- return e.flatMap(
941
- (t) => t.kind === "token" ? [t.value] : []
942
- );
943
- }
944
- function ge(e, t) {
945
- return e.filter((r) => t.includes(r)).length === 1;
946
- }
947
- function $(e, t) {
948
- return e.some((r) => t.includes(r));
949
- }
950
- function Ot(e) {
951
- return new Set(e).size !== e.length;
952
- }
953
- function Ut(e, t) {
954
- if (Ot(e)) return !1;
955
- const r = ["YYYY", "YY"], n = ["MMMM", "MMM", "MM"], a = ["HH", "mm", "ss"], i = ge(e, r), s = ge(e, n), c = e.includes("DD"), o = $(e, a);
956
- switch (t) {
957
- case "second":
958
- return e.includes("HH") && e.includes("mm") && e.includes("ss") && (!$(e, [...r, ...n, "DD"]) || i && s && c);
959
- case "minute":
960
- return e.includes("HH") && e.includes("mm") && (!$(e, [...r, ...n, "DD"]) || i && s && c);
961
- case "hour":
962
- return e.includes("HH") && (!$(e, [...r, ...n, "DD"]) || i && s && c);
963
- case "day":
964
- case "week":
965
- return i && s && c && !o;
966
- case "month":
967
- return i && s && !c && !o;
968
- case "quarter":
969
- return !1;
970
- case "year":
971
- return i && !s && !c && !o;
972
- }
973
- }
974
- function ze(e, t) {
975
- if (e.presentation.mode === "auto")
976
- return { ok: !0 };
977
- if (e.presentation.mode === "preset") {
978
- const n = Ee[e.presentation.preset];
979
- return n === t ? { ok: !0 } : {
980
- ok: !1,
981
- code: "incompatible_temporal_bucket_preset",
982
- message: `Preset ${e.presentation.preset} requires ${n} granularity.`
983
- };
984
- }
985
- const r = k(e.presentation.pattern);
986
- return r.ok ? Ut(
987
- At(r.segments),
988
- t
989
- ) ? { ok: !0, segments: r.segments } : {
990
- ok: !1,
991
- code: "incompatible_temporal_bucket_pattern",
992
- message: `Pattern ${e.presentation.pattern} is not compatible with ${t} granularity.`
993
- } : r;
994
- }
995
- function Ur(e, t) {
996
- if (!(!e || !t))
997
- return ze(e, t).ok ? e : void 0;
998
- }
999
- class w extends Error {
1000
- constructor(r, n) {
1001
- super(n);
1002
- O(this, "code");
1003
- this.name = "RawTemporalFormatContractError", this.code = r;
1004
- }
1005
- }
1006
- const Lt = [
1007
- "SSSSSSSSS",
1008
- "SSSSSSSS",
1009
- "SSSSSSS",
1010
- "SSSSSS",
1011
- "SSSSS",
1012
- "SSSS",
1013
- "SSS",
1014
- "SS",
1015
- "S"
1016
- ], Pe = /^(\d{4})-(\d{2})-(\d{2})$/, Ae = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?$/, Oe = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:\d{2})$/, Rt = [
1017
- "yyyy",
1018
- "MMMM",
1019
- "LLLL",
1020
- "zzz",
1021
- "XXX",
1022
- "MMM",
1023
- "LLL",
1024
- "yy",
1025
- "MM",
1026
- "dd",
1027
- "HH",
1028
- "hh",
1029
- "mm",
1030
- "ss",
1031
- "M",
1032
- "d",
1033
- "H",
1034
- "h",
1035
- "m",
1036
- "s",
1037
- "a"
1038
- ], Ht = /* @__PURE__ */ new Set([
1039
- "HH",
1040
- "H",
1041
- "hh",
1042
- "h",
1043
- "mm",
1044
- "m",
1045
- "ss",
1046
- "s",
1047
- "a",
1048
- ...Lt
1049
- ]), Zt = /* @__PURE__ */ new Set(["zzz", "XXX"]), Z = /* @__PURE__ */ new Set(["short", "medium", "long"]);
1050
- function p(e, t) {
1051
- return Object.keys(e).length === t.length && t.every((n) => n in e);
1052
- }
1053
- function m(e) {
1054
- throw new w(
1055
- "invalid_raw_temporal_format",
1056
- e
1057
- );
1058
- }
1059
- function Ue(e) {
1060
- if (!e || e.trim() !== e || e.length > 256)
1061
- return m(
1062
- "date_fns patterns must be non-empty, trimmed, and at most 256 characters."
1063
- );
1064
- const t = [], r = (a) => {
1065
- const i = t[t.length - 1];
1066
- (i == null ? void 0 : i.kind) === "literal" ? i.value += a : t.push({ kind: "literal", value: a });
1067
- };
1068
- let n = 0;
1069
- for (; n < e.length; ) {
1070
- if (e[n] === "'") {
1071
- if (e[n + 1] === "'") {
1072
- r("'"), n += 2;
1073
- continue;
1074
- }
1075
- let s = "", c = !1;
1076
- for (n += 1; n < e.length; ) {
1077
- if (e[n] === "'") {
1078
- if (e[n + 1] === "'") {
1079
- s += "'", n += 2;
1080
- continue;
1081
- }
1082
- c = !0, n += 1;
1083
- break;
1084
- }
1085
- s += e[n], n += 1;
1086
- }
1087
- if (!c)
1088
- return m("date_fns pattern has an unclosed quote.");
1089
- r(s);
1090
- continue;
1091
- }
1092
- if (e[n] === "S") {
1093
- let s = n + 1;
1094
- for (; e[s] === "S"; ) s += 1;
1095
- const c = e.slice(n, s);
1096
- if (c.length > 9)
1097
- return m(
1098
- "date_fns fractional-second tokens support at most nine digits."
1099
- );
1100
- t.push({
1101
- kind: "token",
1102
- value: c
1103
- }), n = s;
1104
- continue;
1105
- }
1106
- const a = Rt.find(
1107
- (s) => e.startsWith(s, n)
1108
- );
1109
- if (a) {
1110
- t.push({ kind: "token", value: a }), n += a.length;
1111
- continue;
1112
- }
1113
- const i = e[n];
1114
- if (/[A-Za-z]/.test(i))
1115
- return m(
1116
- `Unsupported date_fns pattern token beginning at "${e.slice(n)}".`
1117
- );
1118
- r(i), n += 1;
1119
- }
1120
- return t.some((a) => a.kind === "token") ? t : m("date_fns patterns must contain at least one token.");
1121
- }
1122
- function Le(e, t) {
1123
- if (e === "semaphor_tokens") {
1124
- const r = k(t);
1125
- r.ok || m(r.message);
1126
- return;
1127
- }
1128
- Ue(t);
1129
- }
1130
- function jt(e) {
1131
- return !g(e) || !p(e, ["dateStyle", "dateTime"]) ? m("Automatic raw temporal styles are incomplete.") : Z.has(e.dateStyle) ? !g(e.dateTime) || !p(e.dateTime, ["dateStyle", "timeStyle"]) || !Z.has(e.dateTime.dateStyle) || !Z.has(e.dateTime.timeStyle) ? m(
1132
- "Automatic dateTime styles are incomplete or invalid."
1133
- ) : {
1134
- dateStyle: e.dateStyle,
1135
- dateTime: {
1136
- dateStyle: e.dateTime.dateStyle,
1137
- timeStyle: e.dateTime.timeStyle
1138
- }
1139
- } : m("Automatic dateStyle is invalid.");
1140
- }
1141
- function Re(e) {
1142
- const t = ["type", "locale", "calendarTimezone", "presentation"], r = [...t, "sourceTimezone"];
1143
- if (!g(e) || !p(e, t) && !p(e, r) || e.type !== "raw_temporal")
1144
- return m("Resolved raw temporal format has an invalid shape.");
1145
- const n = _(e.locale);
1146
- return n ? typeof e.calendarTimezone != "string" || !F(e.calendarTimezone) ? m(
1147
- "Raw temporal calendarTimezone must be a valid IANA timezone."
1148
- ) : e.sourceTimezone !== void 0 && (typeof e.sourceTimezone != "string" || !F(e.sourceTimezone)) ? m(
1149
- "Raw temporal sourceTimezone must be a valid IANA timezone."
1150
- ) : g(e.presentation) ? e.presentation.mode === "auto" ? p(e.presentation, ["mode", "styles"]) ? {
1151
- type: "raw_temporal",
1152
- locale: n,
1153
- calendarTimezone: e.calendarTimezone,
1154
- ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
1155
- presentation: {
1156
- mode: "auto",
1157
- styles: jt(e.presentation.styles)
1158
- }
1159
- } : m(
1160
- "Automatic raw temporal presentation has unknown fields."
1161
- ) : e.presentation.mode !== "pattern" || !p(e.presentation, ["mode", "dialect", "pattern"]) || e.presentation.dialect !== "semaphor_tokens" && e.presentation.dialect !== "date_fns" || typeof e.presentation.pattern != "string" ? m(
1162
- "Pattern raw temporal presentation has an invalid shape."
1163
- ) : (Le(e.presentation.dialect, e.presentation.pattern), {
1164
- type: "raw_temporal",
1165
- locale: n,
1166
- calendarTimezone: e.calendarTimezone,
1167
- ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
1168
- presentation: {
1169
- mode: "pattern",
1170
- dialect: e.presentation.dialect,
1171
- pattern: e.presentation.pattern
1172
- }
1173
- }) : m("Raw temporal presentation must be an object.") : m("Raw temporal locale is invalid or unsupported.");
1174
- }
1175
- function Lr(e) {
1176
- var c, o, u;
1177
- if (e.format) {
1178
- if (!g(e.format))
1179
- return m(
1180
- "Authored raw temporal format has an invalid shape."
1181
- );
1182
- const l = Object.keys(e.format);
1183
- if (!l.includes("type") || !l.includes("presentation") || l.some(
1184
- (d) => d !== "type" && d !== "presentation" && d !== "timezone" && d !== "sourceTimezone"
1185
- ) || e.format.type !== "raw_temporal" || !g(e.format.presentation))
1186
- return m(
1187
- "Authored raw temporal format has an invalid shape."
1188
- );
1189
- const f = e.format.presentation;
1190
- if (f.mode === "auto") {
1191
- if (!p(f, ["mode"]))
1192
- return m(
1193
- "Automatic authored raw temporal format has unknown fields."
1194
- );
1195
- } else {
1196
- if (f.mode !== "pattern" || !p(f, ["mode", "dialect", "pattern"]) || f.dialect !== "semaphor_tokens" && f.dialect !== "date_fns" || typeof f.pattern != "string")
1197
- return m(
1198
- "Authored raw temporal pattern has an invalid shape."
1199
- );
1200
- Le(f.dialect, f.pattern);
1201
- }
1202
- }
1203
- const t = (c = e.format) == null ? void 0 : c.timezone, r = (o = e.format) == null ? void 0 : o.sourceTimezone, n = t && t !== "auto" ? t : e.calendar.tz, a = r && r !== "auto" ? r === "local" ? Intl.DateTimeFormat().resolvedOptions().timeZone : r : void 0;
1204
- if (t !== void 0 && t !== "auto" && !F(n) || a !== void 0 && !F(a))
1205
- return m("Authored raw temporal timezone is invalid.");
1206
- const i = ((u = e.format) == null ? void 0 : u.presentation) ?? { mode: "auto" }, s = {
1207
- type: "raw_temporal",
1208
- locale: e.preferences.locale,
1209
- calendarTimezone: n,
1210
- ...a ? { sourceTimezone: a } : {},
1211
- presentation: i.mode === "pattern" ? { ...i } : {
1212
- mode: "auto",
1213
- styles: {
1214
- dateStyle: e.preferences.dateStyle,
1215
- dateTime: { ...e.preferences.dateTime }
1216
- }
1217
- }
1218
- };
1219
- return Re(s);
1220
- }
1221
- function qt(e) {
1222
- if (Pe.test(e)) return "date";
1223
- if (Oe.test(e)) return "instant";
1224
- if (Ae.test(e)) return "wall_datetime";
1225
- }
1226
- function Rr(e) {
1227
- const t = /* @__PURE__ */ new Set();
1228
- let r = !1;
1229
- for (const n of e.values) {
1230
- if (n === null) continue;
1231
- r = !0;
1232
- const a = qt(n);
1233
- a && t.add(a);
1234
- }
1235
- if (!r) return { status: "empty" };
1236
- if (t.size === 0) return { status: "invalid_only" };
1237
- if (t.size > 1)
1238
- throw new w(
1239
- "mixed_sql_temporal_semantics",
1240
- `Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`
1241
- );
1242
- return {
1243
- status: "classified",
1244
- metadata: {
1245
- kind: "raw_temporal",
1246
- valueKind: [...t][0]
1247
- }
1248
- };
1249
- }
1250
- function Hr(e) {
1251
- return {
1252
- version: 1,
1253
- columns: Object.fromEntries(
1254
- [...e].map(([t, r]) => [
1255
- t,
1256
- r.status === "classified" ? r.metadata.valueKind : r.status
1257
- ])
1258
- )
1259
- };
1260
- }
1261
- function Kt(e) {
1262
- if (!g(e) || e.version !== 1 || !g(e.columns) || Object.keys(e).some((n) => n !== "version" && n !== "columns"))
1263
- throw new w(
1264
- "invalid_raw_temporal_format",
1265
- "Raw temporal chunk classification evidence is malformed."
1266
- );
1267
- const t = {}, r = /* @__PURE__ */ new Set([
1268
- "empty",
1269
- "invalid_only",
1270
- "date",
1271
- "wall_datetime",
1272
- "instant"
1273
- ]);
1274
- for (const [n, a] of Object.entries(e.columns)) {
1275
- if (!n.trim() || !r.has(a))
1276
- throw new w(
1277
- "invalid_raw_temporal_format",
1278
- "Raw temporal chunk classification evidence contains an invalid column or status."
1279
- );
1280
- t[n] = a;
1281
- }
1282
- return { version: 1, columns: t };
1283
- }
1284
- function Zr(e) {
1285
- if (e.length === 0) return;
1286
- const t = e.map(Kt), r = Object.keys(t[0].columns).sort();
1287
- for (let n = 1; n < t.length; n += 1) {
1288
- const a = Object.keys(t[n].columns).sort();
1289
- if (a.length !== r.length || a.some((i, s) => i !== r[s]))
1290
- throw new w(
1291
- "invalid_raw_temporal_format",
1292
- "Raw temporal chunk classification evidence has inconsistent columns."
1293
- );
1294
- }
1295
- for (const n of r)
1296
- if (new Set(
1297
- t.map((i) => i.columns[n]).filter(
1298
- (i) => i !== "empty" && i !== "invalid_only"
1299
- )
1300
- ).size > 1)
1301
- throw new w(
1302
- "mixed_sql_temporal_semantics",
1303
- `Declared SQL temporal column "${n}" has inconsistent semantics across export chunks. Normalize it to one kind.`
1304
- );
1305
- }
1306
- function Vt(e) {
1307
- return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
1308
- }
1309
- function Gt(e, t) {
1310
- return t === 2 ? Vt(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
1311
- }
1312
- function Bt(e) {
1313
- return e.year >= 1 && e.year <= 9999 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= Gt(e.year, e.month) && e.hour >= 0 && e.hour <= 23 && e.minute >= 0 && e.minute <= 59 && e.second >= 0 && e.second <= 59;
1314
- }
1315
- function Wt(e) {
1316
- return {
1317
- year: Number(e[1]),
1318
- month: Number(e[2]),
1319
- day: Number(e[3]),
1320
- hour: Number(e[4] ?? 0),
1321
- minute: Number(e[5] ?? 0),
1322
- second: Number(e[6] ?? 0),
1323
- fraction: e[7] ?? ""
1324
- };
1325
- }
1326
- function Jt(e, t) {
1327
- const r = t === "date" ? e.match(Pe) : t === "wall_datetime" ? e.match(Ae) : e.match(Oe);
1328
- if (!r) return { status: "invalid_shape" };
1329
- const n = Wt(r);
1330
- if (!Bt(n)) return { status: "out_of_range" };
1331
- if (t === "instant") {
1332
- const a = r[8];
1333
- if (a && a !== "Z") {
1334
- const [s, c] = a.slice(1).split(":").map(Number);
1335
- if (s > 23 || c > 59) return { status: "out_of_range" };
1336
- }
1337
- const i = new Date(e.replace(" ", "T"));
1338
- return Number.isNaN(i.getTime()) ? { status: "out_of_range" } : { status: "valid", fields: n, instant: i };
1339
- }
1340
- return { status: "valid", fields: n };
1341
- }
1342
- function B(e) {
1343
- const t = /* @__PURE__ */ new Date(0);
1344
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
1345
- }
1346
- function Q(e, t) {
1347
- const r = e.fraction ? `.${e.fraction.padEnd(3, "0").slice(0, 3)}` : "";
1348
- return bt(
1349
- `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}T${String(e.hour).padStart(2, "0")}:${String(e.minute).padStart(2, "0")}:${String(e.second).padStart(2, "0")}${r}`,
1350
- t
1351
- );
1352
- }
1353
- function He(e, t) {
1354
- const r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
1355
- let a, i, s, c;
1356
- return {
1357
- number(o, u = 1) {
1358
- let l = r.get(u);
1359
- return l || (l = new Intl.NumberFormat(e, {
1360
- useGrouping: !1,
1361
- minimumIntegerDigits: u,
1362
- maximumFractionDigits: 0
1363
- }), r.set(u, l)), l.format(o);
1364
- },
1365
- month(o, u, l) {
1366
- var h;
1367
- const f = `${u}:${l ? "standalone" : "contextual"}`;
1368
- let d = n.get(f);
1369
- if (!d) {
1370
- const M = {
1371
- calendar: "gregory",
1372
- timeZone: "UTC",
1373
- month: u
1374
- };
1375
- l || (M.day = "numeric"), d = new Intl.DateTimeFormat(e, M), n.set(f, d);
1376
- }
1377
- return ((h = d.formatToParts(o).find((M) => M.type === "month")) == null ? void 0 : h.value) ?? "";
1378
- },
1379
- dayPeriod(o) {
1380
- var u;
1381
- return a ?? (a = new Intl.DateTimeFormat(e, {
1382
- calendar: "gregory",
1383
- timeZone: "UTC",
1384
- hour: "numeric",
1385
- hour12: !0
1386
- })), ((u = a.formatToParts(o).find((l) => l.type === "dayPeriod")) == null ? void 0 : u.value) ?? "";
1387
- },
1388
- instantFields(o) {
1389
- i ?? (i = new Intl.DateTimeFormat("en-CA", {
1390
- calendar: "gregory",
1391
- numberingSystem: "latn",
1392
- timeZone: t,
1393
- year: "numeric",
1394
- month: "2-digit",
1395
- day: "2-digit",
1396
- hour: "2-digit",
1397
- minute: "2-digit",
1398
- second: "2-digit",
1399
- hourCycle: "h23"
1400
- }));
1401
- const u = i.formatToParts(o), l = (f) => {
1402
- var d;
1403
- return Number((d = u.find((h) => h.type === f)) == null ? void 0 : d.value);
1404
- };
1405
- return {
1406
- year: l("year"),
1407
- month: l("month"),
1408
- day: l("day"),
1409
- hour: l("hour"),
1410
- minute: l("minute"),
1411
- second: l("second"),
1412
- fraction: ""
1413
- };
1414
- },
1415
- timezoneName(o) {
1416
- var u;
1417
- return s ?? (s = new Intl.DateTimeFormat(e, {
1418
- calendar: "gregory",
1419
- timeZone: t,
1420
- timeZoneName: "short"
1421
- })), ((u = s.formatToParts(o).find((l) => l.type === "timeZoneName")) == null ? void 0 : u.value) ?? "";
1422
- },
1423
- timezoneOffset(o) {
1424
- var f;
1425
- c ?? (c = new Intl.DateTimeFormat("en-US", {
1426
- calendar: "gregory",
1427
- timeZone: t,
1428
- timeZoneName: "longOffset"
1429
- }));
1430
- const u = (f = c.formatToParts(o).find((d) => d.type === "timeZoneName")) == null ? void 0 : f.value;
1431
- if (!u)
1432
- return m("Unable to resolve the instant timezone offset.");
1433
- const l = u.replace(/^GMT/, "");
1434
- return l === "" || /^[+-]00:00$/.test(l) ? "Z" : l;
1435
- }
1436
- };
1437
- }
1438
- function Xt(e, t, r, n, a) {
1439
- if (/^S{1,9}$/.test(e)) {
1440
- const i = t.fraction.padEnd(e.length, "0").slice(0, e.length);
1441
- return n.number(Number(i), e.length);
1442
- }
1443
- switch (e) {
1444
- case "YYYY":
1445
- case "yyyy":
1446
- return n.number(t.year, 4);
1447
- case "YY":
1448
- case "yy":
1449
- return n.number(t.year % 100, 2);
1450
- case "MMMM":
1451
- return n.month(r, "long", !1);
1452
- case "LLLL":
1453
- return n.month(r, "long", !0);
1454
- case "MMM":
1455
- return n.month(r, "short", !1);
1456
- case "LLL":
1457
- return n.month(r, "short", !0);
1458
- case "MM":
1459
- return n.number(t.month, 2);
1460
- case "M":
1461
- return n.number(t.month);
1462
- case "DD":
1463
- case "dd":
1464
- return n.number(t.day, 2);
1465
- case "d":
1466
- return n.number(t.day);
1467
- case "HH":
1468
- return n.number(t.hour, 2);
1469
- case "H":
1470
- return n.number(t.hour);
1471
- case "hh":
1472
- return n.number(t.hour % 12 || 12, 2);
1473
- case "h":
1474
- return n.number(t.hour % 12 || 12);
1475
- case "mm":
1476
- return n.number(t.minute, 2);
1477
- case "m":
1478
- return n.number(t.minute);
1479
- case "ss":
1480
- return n.number(t.second, 2);
1481
- case "s":
1482
- return n.number(t.second);
1483
- case "a":
1484
- return n.dayPeriod(r);
1485
- case "zzz":
1486
- return a ? n.timezoneName(a) : m(
1487
- "Timezone pattern tokens require an instant value."
1488
- );
1489
- case "XXX":
1490
- return a ? n.timezoneOffset(a) : m(
1491
- "Timezone pattern tokens require an instant value."
1492
- );
1493
- default:
1494
- return m(
1495
- `Unsupported raw temporal pattern token "${e}".`
1496
- );
1497
- }
1498
- }
1499
- function Qt(e, t, r, n) {
1500
- const a = B(t);
1501
- return e.map(
1502
- (i) => i.kind === "literal" ? i.value : Xt(i.value, t, a, r, n)
1503
- ).join("");
1504
- }
1505
- function Ze(e, t, r) {
1506
- const n = t === "date_fns" ? Ue(r) : (() => {
1507
- const i = k(r);
1508
- return i.ok ? i.segments : m(i.message);
1509
- })(), a = n.filter((i) => i.kind === "token").map((i) => i.value);
1510
- return e === "date" && a.some((i) => Ht.has(i)) ? m("Date patterns cannot contain time tokens.") : e !== "instant" && a.some((i) => Zt.has(i)) ? m("Timezone pattern tokens require an instant value.") : n;
1511
- }
1512
- function jr(e) {
1513
- Ze(
1514
- e.valueKind ?? "instant",
1515
- e.dialect,
1516
- e.pattern
1517
- );
1518
- }
1519
- function er(e, t, r, n) {
1520
- const a = Ze(
1521
- e.valueKind,
1522
- r,
1523
- n
1524
- ), i = He(t.locale, t.calendarTimezone);
1525
- return (s) => {
1526
- const c = e.valueKind === "wall_datetime" && t.sourceTimezone ? Q(s.fields, t.sourceTimezone) : void 0, o = e.valueKind === "instant" ? {
1527
- ...i.instantFields(s.instant),
1528
- fraction: s.fields.fraction
1529
- } : c ? {
1530
- ...i.instantFields(c),
1531
- fraction: s.fields.fraction
1532
- } : s.fields;
1533
- return Qt(a, o, i, s.instant ?? c);
1534
- };
1535
- }
1536
- function tr(e, t) {
1537
- const r = He(t.locale, t.calendarTimezone);
1538
- return (n) => {
1539
- const a = e.valueKind === "instant" ? r.instantFields(n.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? r.instantFields(Q(n.fields, t.sourceTimezone)) : n.fields;
1540
- return {
1541
- year: a.year,
1542
- month: a.month,
1543
- day: a.day,
1544
- hour: a.hour,
1545
- minute: a.minute,
1546
- second: a.second
1547
- };
1548
- };
1549
- }
1550
- function rr(e, t) {
1551
- const r = t.presentation.mode === "auto" ? t.presentation.styles : m("Automatic raw temporal formatting requires styles.");
1552
- if (e.valueKind === "date") {
1553
- const s = new Intl.DateTimeFormat(t.locale, {
1554
- calendar: "gregory",
1555
- timeZone: "UTC",
1556
- dateStyle: r.dateStyle
1557
- });
1558
- return (c) => s.format(B(c.fields));
1559
- }
1560
- const n = e.valueKind === "instant", a = !n && r.dateTime.timeStyle === "long" ? "medium" : r.dateTime.timeStyle, i = new Intl.DateTimeFormat(t.locale, {
1561
- calendar: "gregory",
1562
- timeZone: n || e.valueKind === "wall_datetime" && t.sourceTimezone ? t.calendarTimezone : "UTC",
1563
- dateStyle: r.dateTime.dateStyle,
1564
- timeStyle: a
1565
- });
1566
- return (s) => n ? i.format(s.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? i.format(Q(s.fields, t.sourceTimezone)) : i.format(B(s.fields));
1567
- }
1568
- function he(e, t, r) {
1569
- return {
1570
- ok: !1,
1571
- text: e,
1572
- diagnostic: {
1573
- code: r,
1574
- message: `Raw temporal ${t.valueKind} value is ${r === "invalid_raw_temporal_value" ? "malformed" : "out of range"}.`
1575
- }
1576
- };
1577
- }
1578
- function nr(e) {
1579
- const t = Be(e.metadata), r = Re(e.format), n = r.presentation.mode === "auto" ? rr(t, r) : er(
1580
- t,
1581
- r,
1582
- r.presentation.dialect,
1583
- r.presentation.pattern
1584
- ), a = tr(t, r);
1585
- return (i) => {
1586
- if (i === null)
1587
- return { ok: !0, text: "", status: "empty" };
1588
- const s = Jt(i, t.valueKind);
1589
- return s.status === "invalid_shape" ? he(i, t, "invalid_raw_temporal_value") : s.status === "out_of_range" ? he(i, t, "out_of_range_raw_temporal_value") : {
1590
- ok: !0,
1591
- text: n(s),
1592
- status: "formatted",
1593
- wallClock: a(s)
1594
- };
1595
- };
1596
- }
1597
- function qr(e) {
1598
- return nr({
1599
- metadata: e.metadata,
1600
- format: e.format
1601
- })(e.value);
1602
- }
1603
- const ar = {
1604
- dateStyle: "short",
1605
- dateTime: { dateStyle: "short", timeStyle: "short" }
1606
- };
1607
- class I extends Error {
1608
- constructor(r, n) {
1609
- super(n);
1610
- O(this, "code");
1611
- this.name = "TemporalBucketContractError", this.code = r;
1612
- }
1613
- }
1614
- const ir = [
1615
- "Jan",
1616
- "Feb",
1617
- "Mar",
1618
- "Apr",
1619
- "May",
1620
- "Jun",
1621
- "Jul",
1622
- "Aug",
1623
- "Sep",
1624
- "Oct",
1625
- "Nov",
1626
- "Dec"
1627
- ], sr = [
1628
- "January",
1629
- "February",
1630
- "March",
1631
- "April",
1632
- "May",
1633
- "June",
1634
- "July",
1635
- "August",
1636
- "September",
1637
- "October",
1638
- "November",
1639
- "December"
1640
- ];
1641
- function j(e) {
1642
- return {
1643
- ok: !1,
1644
- error: { code: "invalid_temporal_bucket_value", message: e }
1645
- };
1646
- }
1647
- function cr(e) {
1648
- return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
1649
- }
1650
- function or(e, t) {
1651
- return t === 2 ? cr(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
1652
- }
1653
- function ur(e, t, r) {
1654
- const n = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], a = t < 3 ? e - 1 : e;
1655
- return (a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) + n[t - 1] + r) % 7;
1656
- }
1657
- function A(e) {
1658
- var t;
1659
- return (t = e.calendar.fiscalCalendar) == null ? void 0 : t.yearStartMonth;
1660
- }
1661
- function lr(e, t) {
1662
- return (e - t + 12) % 12 % 3 === 0;
1663
- }
1664
- function mr(e, t) {
1665
- const { granularity: r } = t, n = A(t) ?? 1;
1666
- switch (r) {
1667
- case "second":
1668
- return !0;
1669
- case "minute":
1670
- return e.second === 0;
1671
- case "hour":
1672
- return e.minute === 0 && e.second === 0;
1673
- case "day":
1674
- return !0;
1675
- case "week":
1676
- return ur(e.year, e.month, e.day) === t.calendar.weekStart;
1677
- case "month":
1678
- return e.day === 1;
1679
- case "quarter":
1680
- return e.day === 1 && lr(e.month, n);
1681
- case "year":
1682
- return e.day === 1 && e.month === n;
1683
- }
1684
- }
1685
- function je(e, t) {
1686
- if (e === null) return { ok: !0, value: null };
1687
- 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);
1688
- if (!n)
1689
- return j(
1690
- `Expected ${r ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${t.granularity} granularity.`
1691
- );
1692
- const a = {
1693
- year: Number(n[1]),
1694
- month: Number(n[2]),
1695
- day: Number(n[3]),
1696
- hour: r ? Number(n[4]) : 0,
1697
- minute: r ? Number(n[5]) : 0,
1698
- second: r ? Number(n[6]) : 0
1699
- };
1700
- return a.year < 1 || a.month < 1 || a.month > 12 || a.day < 1 || a.day > or(a.year, a.month) || a.hour > 23 || a.minute > 59 || a.second > 59 ? j(`Invalid canonical ${t.granularity} bucket value ${e}.`) : mr(a, t) ? { ok: !0, value: a } : j(
1701
- `Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`
1702
- );
1703
- }
1704
- function Kr(e) {
1705
- const { granularity: t, calendar: r } = e, n = (s, c) => new Intl.DateTimeFormat("en-US", { ...s, timeZone: "UTC" }).format(c), a = [`by ${t} in the ${r.tz} calendar`];
1706
- t === "week" && a.push(`weeks starting on ${n({ weekday: "long" }, new Date(Date.UTC(2023, 0, 1 + r.weekStart)))}`);
1707
- const i = A(e);
1708
- return i && (t === "quarter" || t === "year") && a.push(`the fiscal year starting in ${n({ month: "long" }, new Date(Date.UTC(2e3, i - 1, 1)))}`), `${a.join(", ")}; each value is a bucket's start`;
1709
- }
1710
- function fr(e) {
1711
- if (!g(e))
1712
- return {
1713
- ok: !1,
1714
- issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
1715
- };
1716
- const t = [], r = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
1717
- for (const s of Object.keys(e))
1718
- r.has(s) || t.push({ path: s, message: `Unknown property "${s}".` });
1719
- e.type !== "temporal_bucket" && t.push({ path: "type", message: "Expected temporal_bucket." });
1720
- const n = e.presentation;
1721
- if (!g(n))
1722
- t.push({ path: "presentation", message: "Expected a presentation object." });
1723
- else {
1724
- const s = n.mode, c = 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"]);
1725
- for (const o of Object.keys(n))
1726
- c.has(o) || t.push({
1727
- path: `presentation.${o}`,
1728
- message: `Unknown property "${o}".`
1729
- });
1730
- if (s === "preset")
1731
- zt(n.preset) || t.push({ path: "presentation.preset", message: "Expected a supported preset." });
1732
- else if (s === "pattern")
1733
- if (typeof n.pattern != "string" || !n.pattern)
1734
- t.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
1735
- else {
1736
- const o = k(n.pattern);
1737
- o.ok || t.push({
1738
- path: "presentation.pattern",
1739
- message: o.message
1740
- });
1741
- }
1742
- else if (s === "auto") {
1743
- const o = n.styles;
1744
- (!g(o) || !["short", "medium", "long"].includes(String(o.dateStyle)) || !g(o.dateTime) || !["short", "medium", "long"].includes(
1745
- String(o.dateTime.dateStyle)
1746
- ) || !["short", "medium", "long"].includes(
1747
- String(o.dateTime.timeStyle)
1748
- ) || Object.keys(o).some(
1749
- (u) => u !== "dateStyle" && u !== "dateTime"
1750
- ) || Object.keys(o.dateTime).some(
1751
- (u) => u !== "dateStyle" && u !== "timeStyle"
1752
- )) && t.push({
1753
- path: "presentation.styles",
1754
- message: "Expected complete resolved date and datetime styles."
1755
- });
1756
- } else
1757
- t.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
1758
- }
1759
- const a = _(e.locale);
1760
- if (a || t.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), t.length > 0 || !a || !g(n))
1761
- return { ok: !1, issues: t };
1762
- if (n.mode === "auto") {
1763
- const s = n.styles;
1764
- return {
1765
- ok: !0,
1766
- value: {
1767
- type: "temporal_bucket",
1768
- locale: a,
1769
- presentation: {
1770
- mode: "auto",
1771
- styles: {
1772
- dateStyle: s.dateStyle,
1773
- dateTime: {
1774
- dateStyle: s.dateTime.dateStyle,
1775
- timeStyle: s.dateTime.timeStyle
1776
- }
1777
- }
1778
- }
1779
- }
1780
- };
1781
- }
1782
- return {
1783
- ok: !0,
1784
- value: {
1785
- type: "temporal_bucket",
1786
- presentation: n.mode === "preset" ? {
1787
- mode: "preset",
1788
- preset: n.preset
1789
- } : {
1790
- mode: "pattern",
1791
- pattern: n.pattern
1792
- },
1793
- locale: a
1794
- }
1795
- };
1796
- }
1797
- function dr(e, t) {
1798
- const r = !!t.calendar.fiscalCalendar;
1799
- return e === "fiscal_quarter_short" || e === "fiscal_year" ? r : e === "quarter_short" || e === "quarter_long" ? !r : !0;
1800
- }
1801
- function qe(e, t) {
1802
- return ze(e, t.granularity).ok ? e.presentation.mode === "preset" ? dr(e.presentation.preset, t) : !(e.presentation.mode === "pattern" && t.calendar.fiscalCalendar && (t.granularity === "quarter" || t.granularity === "year")) : !1;
1803
- }
1804
- function pe(e, t) {
1805
- if (!(!e || e.presentation.mode === "auto"))
1806
- return qe(e, t) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
1807
- }
1808
- function Vr(e) {
1809
- var a;
1810
- const t = _(e.locale);
1811
- if (!t)
1812
- throw new I(
1813
- "invalid_temporal_bucket_format",
1814
- "Temporal bucket locale must be a supported base BCP 47 locale."
1815
- );
1816
- const r = pe(e.cardFormat, e.metadata);
1817
- if (r)
1818
- return { format: { ...r, locale: t }, source: "card" };
1819
- const n = ((a = e.semanticFormat) == null ? void 0 : a.granularity) === e.metadata.granularity ? pe(e.semanticFormat.format, e.metadata) : void 0;
1820
- return n ? { format: { ...n, locale: t }, source: "semantic" } : {
1821
- format: {
1822
- type: "temporal_bucket",
1823
- locale: t,
1824
- presentation: {
1825
- mode: "auto",
1826
- styles: e.styles ?? ar
1827
- }
1828
- },
1829
- source: "automatic"
1830
- };
1831
- }
1832
- function D(e, t = 2) {
1833
- return String(e).padStart(t, "0");
1834
- }
1835
- function E(e, t, r) {
1836
- if (t === "en-US")
1837
- return (r === "short" ? ir : sr)[e - 1];
1838
- const n = new Date(Date.UTC(2e3, e - 1, 15));
1839
- return new Intl.DateTimeFormat(t, {
1840
- calendar: "gregory",
1841
- month: r,
1842
- timeZone: "UTC"
1843
- }).format(n);
1844
- }
1845
- function yr(e, t, r) {
1846
- return t.map((n) => {
1847
- if (n.kind === "literal") return n.value;
1848
- switch (n.value) {
1849
- case "YYYY":
1850
- return D(e.year, 4);
1851
- case "YY":
1852
- return D(e.year % 100);
1853
- case "MMMM":
1854
- return E(e.month, r, "long");
1855
- case "MMM":
1856
- return E(e.month, r, "short");
1857
- case "MM":
1858
- return D(e.month);
1859
- case "DD":
1860
- return D(e.day);
1861
- case "HH":
1862
- return D(e.hour);
1863
- case "mm":
1864
- return D(e.minute);
1865
- case "ss":
1866
- return D(e.second);
1867
- }
1868
- }).join("");
1869
- }
1870
- const Te = /* @__PURE__ */ new Map();
1871
- function v(e, t) {
1872
- const r = `${e}:${JSON.stringify(t)}`, n = Te.get(r);
1873
- if (n) return n;
1874
- const a = new Intl.DateTimeFormat(e, t);
1875
- return Te.set(r, a), a;
1876
- }
1877
- function z(e) {
1878
- const t = /* @__PURE__ */ new Date(0);
1879
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
1880
- }
1881
- function De(e, t, r) {
1882
- return v(t, {
1883
- calendar: "gregory",
1884
- dateStyle: r,
1885
- timeZone: "UTC"
1886
- }).format(z(e));
1887
- }
1888
- function gr(e, t, r) {
1889
- return v(t, {
1890
- calendar: "gregory",
1891
- dateStyle: r.dateStyle,
1892
- // Grouped buckets are civil values, not instants. Long time styles would
1893
- // append a zone label that the canonical value does not semantically own.
1894
- timeStyle: r.timeStyle === "long" ? "medium" : r.timeStyle,
1895
- timeZone: "UTC"
1896
- }).format(z(e));
1897
- }
1898
- function hr(e, t, r) {
1899
- var a;
1900
- if (r === "short") {
1901
- const i = z(e), s = v(t, {
1902
- calendar: "gregory",
1903
- dateStyle: "short",
1904
- timeZone: "UTC"
1905
- }).formatToParts(i), c = s.findIndex((l) => l.type === "month"), o = s.findIndex((l) => l.type === "year"), u = (a = v(t, {
1906
- calendar: "gregory",
1907
- timeZone: "UTC",
1908
- year: "numeric"
1909
- }).formatToParts(i).find((l) => l.type === "year")) == null ? void 0 : a.value;
1910
- if (c >= 0 && o >= 0 && u) {
1911
- const l = Math.min(c, o), f = Math.max(c, o);
1912
- let d = !1;
1913
- return s.slice(l, f + 1).filter((h) => h.type === "day" ? (d = !0, !1) : d && h.type === "literal" ? (d = !1, !1) : !0).map((h) => h.type === "year" ? u : h.value).join("");
1914
- }
1915
- }
1916
- return v(t, {
1917
- calendar: "gregory",
1918
- month: r === "short" ? "numeric" : r === "medium" ? "short" : "long",
1919
- timeZone: "UTC",
1920
- year: "numeric"
1921
- }).format(z(e));
1922
- }
1923
- function pr(e, t) {
1924
- return Math.floor((e.month - t + 12) % 12 / 3) + 1;
1925
- }
1926
- function Se(e, t) {
1927
- return t === 1 || e.month < t ? e.year : e.year + 1;
1928
- }
1929
- function Tr(e) {
1930
- return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
1931
- }
1932
- function W(e, t, r, n) {
1933
- const a = A(n) ?? 1, i = pr(e, a);
1934
- switch (t) {
1935
- case "week_of_short":
1936
- return `Week of ${E(e.month, r, "short")} ${e.day}, ${e.year}`;
1937
- case "week_of_long":
1938
- return `Week of ${E(e.month, r, "long")} ${e.day}, ${e.year}`;
1939
- case "quarter_short":
1940
- return `Q${i} ${e.year}`;
1941
- case "quarter_long":
1942
- return `${Tr(i)} Quarter ${e.year}`;
1943
- case "fiscal_quarter_short":
1944
- return `Q${i} FY${Se(e, a)}`;
1945
- case "fiscal_year":
1946
- return `FY${Se(e, a)}`;
1947
- }
1948
- }
1949
- function Dr(e, t, r, n) {
1950
- const a = A(t);
1951
- switch (t.granularity) {
1952
- case "second":
1953
- case "minute":
1954
- case "hour":
1955
- return gr(e, r, n.dateTime);
1956
- case "day":
1957
- return De(e, r, n.dateStyle);
1958
- case "week":
1959
- return `Week of ${De(e, r, n.dateStyle)}`;
1960
- case "month":
1961
- return hr(e, r, n.dateStyle);
1962
- case "quarter":
1963
- return W(
1964
- e,
1965
- a ? "fiscal_quarter_short" : "quarter_short",
1966
- r,
1967
- t
1968
- );
1969
- case "year":
1970
- return a ? W(e, "fiscal_year", r, t) : String(e.year);
1971
- }
1972
- }
1973
- function Gr(e, t) {
1974
- if (t.granularity !== "second" && t.granularity !== "minute" && t.granularity !== "hour" && t.granularity !== "day" && t.granularity !== "month")
1975
- return;
1976
- const r = je(e, t);
1977
- if (!r.ok || r.value === null) return;
1978
- const { year: n, month: a, day: i, hour: s, minute: c, second: o } = r.value;
1979
- return { year: n, month: a, day: i, hour: s, minute: c, second: o };
1980
- }
1981
- function Br(e) {
1982
- const t = fr(e.format);
1983
- if (!t.ok || !qe(t.value, e.metadata))
1984
- throw new I(
1985
- "invalid_temporal_bucket_format",
1986
- "Resolved temporal bucket format is invalid or inapplicable to its metadata."
1987
- );
1988
- const r = je(e.value, e.metadata);
1989
- if (!r.ok)
1990
- throw new I(
1991
- r.error.code,
1992
- r.error.message
1993
- );
1994
- if (r.value === null) return "(Blank)";
1995
- const { presentation: n, locale: a } = t.value;
1996
- if (n.mode === "auto")
1997
- return Dr(
1998
- r.value,
1999
- e.metadata,
2000
- a,
2001
- n.styles
2002
- );
2003
- if (n.mode === "preset")
2004
- return W(
2005
- r.value,
2006
- n.preset,
2007
- a,
2008
- e.metadata
2009
- );
2010
- const i = k(n.pattern);
2011
- if (!i.ok)
2012
- throw new I(
2013
- "invalid_temporal_bucket_format",
2014
- i.message
2015
- );
2016
- return yr(r.value, i.segments, a);
2017
- }
2018
- export {
2019
- je as A,
2020
- Kr as B,
2021
- fr as C,
2022
- ar as D,
2023
- Vr as E,
2024
- Gr as F,
2025
- Br as G,
2026
- Re as H,
2027
- qt as I,
2028
- Hr as J,
2029
- Kt as K,
2030
- Zr as L,
2031
- qr as M,
2032
- Cr as N,
2033
- Fr as O,
2034
- g as P,
2035
- bt as Q,
2036
- w as R,
2037
- zr as S,
2038
- Yt as T,
2039
- Er as U,
2040
- Yr as V,
2041
- Ir as W,
2042
- $r as X,
2043
- Fe as Y,
2044
- me as Z,
2045
- kr as a,
2046
- J as b,
2047
- Rr as c,
2048
- Ne as d,
2049
- be as e,
2050
- Mr as f,
2051
- $e as g,
2052
- Ie as h,
2053
- We as i,
2054
- Nr as j,
2055
- br as k,
2056
- ct as l,
2057
- _e as m,
2058
- It as n,
2059
- Pr as o,
2060
- nr as p,
2061
- Ar as q,
2062
- Lr as r,
2063
- Ft as s,
2064
- Or as t,
2065
- zt as u,
2066
- jr as v,
2067
- k as w,
2068
- ze as x,
2069
- Ur as y,
2070
- I as z
2071
- };