react-semaphor 0.1.560 → 0.1.561

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 (107) hide show
  1. package/dist/analytics-protocol/index.js +353 -349
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +5 -5
  4. package/dist/brand-studio/index.js +9 -9
  5. package/dist/briefings/index.js +5 -5
  6. package/dist/chunks/{analytics-base-schemas-CHLxsPfX.js → analytics-base-schemas-CB3oFAXk.js} +199 -171
  7. package/dist/chunks/{assistant-chat-Bu2fFm_I.js → assistant-chat-DiVHY3Hw.js} +27 -28
  8. package/dist/chunks/bookmark-impact-CR09dpkn.js +75 -0
  9. package/dist/chunks/bookmark-state-BusLpkb7.js +743 -0
  10. package/dist/chunks/{braces-Da41xfUd.js → braces-u8VorWJc.js} +1 -1
  11. package/dist/chunks/{comparison-window-caption-4FNkMrzE.js → comparison-window-caption-DDsIWJYT.js} +108 -108
  12. package/dist/chunks/{context-BgPDzLHZ.js → context-TUjw9eqr.js} +1 -1
  13. package/dist/chunks/{custom-visual-inputs-Dz-enUNR.js → custom-visual-inputs-DfolidZ9.js} +1 -1
  14. package/dist/chunks/{dashboard-_MeBuy67.js → dashboard-BRdZBPqr.js} +1 -1
  15. package/dist/chunks/{dashboard-briefing-launcher-CEi4Pr_v.js → dashboard-briefing-launcher-CgvTLndW.js} +161 -162
  16. package/dist/chunks/{dashboard-controls-Bi7fyG-4.js → dashboard-controls-B4vfSzTF.js} +881 -945
  17. package/dist/chunks/{dashboard-json-B1mU_OMa.js → dashboard-json-Y3MF59g7.js} +5 -5
  18. package/dist/chunks/document-dashboard-inputs-CvBbFTUA.js +1718 -0
  19. package/dist/chunks/{edit-dashboard-visual-0CJN31Y3.js → edit-dashboard-visual-DwjZcxj-.js} +6112 -6146
  20. package/dist/chunks/{filter-reach-copy-BF4w4kI2.js → filter-reach-copy-bijwf_-b.js} +1250 -1392
  21. package/dist/chunks/{filter-value-text-CRC-K_l_.js → filter-value-text-DFnhwuEW.js} +3 -3
  22. package/dist/chunks/global-date-filter-utils-BXgCpvQM.js +15142 -0
  23. package/dist/chunks/{index-DtHidOPV.js → index-ClwbY3BL.js} +197 -198
  24. package/dist/chunks/{layout-grid-BvsH4RY2.js → layout-grid-CtvCBfOm.js} +1 -1
  25. package/dist/chunks/{list-filter-Dg0otx5E.js → list-filter-BklYgciR.js} +1 -1
  26. package/dist/chunks/{matrix-analytical-definition-CM18W8w6.js → matrix-analytical-definition-pU51-JmY.js} +4 -4
  27. package/dist/chunks/{matrix-card-HPskLaPy.js → matrix-card-CUorIB7Q.js} +3 -3
  28. package/dist/chunks/{matrix-member-presentation-Bbrfrke4.js → matrix-member-presentation-Df5UgCGN.js} +1 -1
  29. package/dist/chunks/{matrix-operation-contract-WPv4R-H_.js → matrix-operation-contract-BSiGEXVC.js} +255 -248
  30. package/dist/chunks/{metric-comparison-ljMKYZKa.js → metric-comparison-95aC0uEO.js} +6 -6
  31. package/dist/chunks/{model-change-Ccn1zaxl.js → model-change-B5wQhg5G.js} +1 -1
  32. package/dist/chunks/{palette-Bsh376zO.js → palette-DTnMhipt.js} +1 -1
  33. package/dist/chunks/pivot-result-contract-expectations-Bo-86vwS.js +56 -0
  34. package/dist/chunks/{pivot-result-identity-vS9TSh4f.js → pivot-result-identity-olvXJoB9.js} +1 -1
  35. package/dist/chunks/{report-preferences-dialog-BV8L0SeS.js → report-preferences-dialog-C2YUIwKG.js} +14 -14
  36. package/dist/chunks/{report-runtime-context-BZQh9ywy.js → report-runtime-context-DoIUr3MP.js} +2 -2
  37. package/dist/chunks/resolve-dashboard-input-context-q_iiNXE1.js +6503 -0
  38. package/dist/chunks/{save-B5EAsgQF.js → save-DH4RyrnG.js} +1 -1
  39. package/dist/chunks/{saved-dashboard-context-n2Wn11cV.js → saved-dashboard-context-8jqfI7hI.js} +12 -12
  40. package/dist/chunks/{selection-reducer-D0YnaAD9.js → selection-reducer-CV7K4FI6.js} +1 -1
  41. package/dist/chunks/{semaphor-ready-indicator-XLBLOJ2V.js → semaphor-ready-indicator-E2XWyibu.js} +30253 -31076
  42. package/dist/chunks/{shelf-drop-preview-context-DHMa54a-.js → shelf-drop-preview-context-C29EUzDp.js} +7 -7
  43. package/dist/chunks/{source-entity-resolution-dUG5VWRm.js → source-entity-resolution-BXI3nQ5Z.js} +1 -1
  44. package/dist/chunks/{switch-ByxH4M7t.js → switch-balDSHc7.js} +3 -3
  45. package/dist/chunks/{table-export-sheet-C_GdeTYU.js → table-export-sheet-CK8tvh4d.js} +1 -1
  46. package/dist/chunks/temporal-input-presentation-B77JsAzU.js +5002 -0
  47. package/dist/chunks/{token-types-CQtXUVMy.js → token-types-DhYH5YKb.js} +1 -1
  48. package/dist/chunks/{upload-wbR-NVzq.js → upload-Ufj8vjyn.js} +1 -1
  49. package/dist/chunks/{use-create-flow-overlay-state-CEBaLOKC.js → use-create-flow-overlay-state-9WsnzEO5.js} +6 -6
  50. package/dist/chunks/{validators-CXTneCA4.js → validators-BtaCFIEB.js} +37 -37
  51. package/dist/chunks/{zoned-wall-clock-B1n_WjW3.js → zoned-wall-clock-CGLVI40Q.js} +1 -1
  52. package/dist/dashboard/index.js +2 -2
  53. package/dist/dashboard-authoring/index.js +2400 -1856
  54. package/dist/data-app-sdk/index.js +20 -20
  55. package/dist/data-app-sdk-adapters/index.js +3 -3
  56. package/dist/data-app-sdk-validation/index.js +10 -10
  57. package/dist/format-utils/index.js +257 -256
  58. package/dist/index.js +214 -215
  59. package/dist/report-runtime-context/index.js +2 -2
  60. package/dist/style.css +1 -1
  61. package/dist/surfboard/index.js +2 -2
  62. package/dist/types/components/dashboard/summary-number-formatter.d.ts +6 -0
  63. package/dist/types/index.js +50 -51
  64. package/dist/types/lib/formatters/kpi-number-formatter.d.ts +41 -0
  65. package/dist/types/lib/stores/editor-store.d.ts +9 -1
  66. package/dist/types/lib/stores/table-actions.d.ts +0 -2
  67. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +10 -0
  68. package/dist/types/shared/analytics-protocol/measure-aggregation-profile.d.ts +12 -0
  69. package/dist/types/shared/dashboard-authoring/card-settings/apply-card-settings.d.ts +11 -0
  70. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +52 -0
  71. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +14 -0
  72. package/dist/types/shared/dashboard-authoring/card-settings/carry-column-settings.d.ts +3 -0
  73. package/dist/types/shared/dashboard-authoring/card-settings/column-format-write.d.ts +8 -0
  74. package/dist/types/shared/dashboard-authoring/card-settings/column-names.d.ts +51 -0
  75. package/dist/types/shared/dashboard-authoring/card-settings/column-sources.d.ts +14 -0
  76. package/dist/types/shared/dashboard-authoring/card-settings/confirm-class.d.ts +9 -0
  77. package/dist/types/shared/dashboard-authoring/card-settings/highlight-inputs.d.ts +19 -0
  78. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +15 -0
  79. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +102 -0
  80. package/dist/types/shared/dashboard-authoring/card-settings/read-card-settings.d.ts +10 -0
  81. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +14 -0
  82. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-settings.d.ts +59 -0
  83. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +40 -0
  84. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +28 -0
  85. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
  86. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +32 -0
  87. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +539 -22
  88. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +27 -8
  89. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +25 -1
  90. package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +1 -8
  91. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +10 -10
  92. package/dist/types/shared/dashboard-authoring/index.d.ts +3 -0
  93. package/dist/types/shared/dashboard-authoring/kpi-figure.d.ts +123 -0
  94. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +21 -1
  95. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +10 -4
  96. package/dist/types/shared/dashboard-viewer/bookmark-impact.d.ts +33 -0
  97. package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +8 -1
  98. package/dist/types/shared/format-utils/raw-temporal.d.ts +16 -0
  99. package/package.json +2 -2
  100. package/dist/chunks/bookmark-state-BFY9oNmr.js +0 -111
  101. package/dist/chunks/document-dashboard-inputs-CkWfDB8c.js +0 -3010
  102. package/dist/chunks/global-date-filter-utils-D8365uPH.js +0 -12889
  103. package/dist/chunks/pivot-result-contract-expectations-Bl5suy4-.js +0 -1832
  104. package/dist/chunks/raw-temporal-presentation-BHm7s-hz.js +0 -540
  105. package/dist/chunks/resolve-dashboard-input-context-CAMiWvyR.js +0 -5280
  106. package/dist/chunks/table-settings-Imz0FgWi.js +0 -637
  107. package/dist/chunks/temporal-input-presentation-uvNK_tM0.js +0 -3228
@@ -0,0 +1,5002 @@
1
+ var Yn = Object.defineProperty;
2
+ var zn = (e, t, n) => t in e ? Yn(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var $ = (e, t, n) => zn(e, typeof t != "symbol" ? t + "" : t, n);
4
+ import { z as w } from "zod";
5
+ import { E as Rt, l as Lt } from "./export-file-format-C-tJsxsf.js";
6
+ import { b1 as Wt, a$ as An, aW as Un, t as nt, aj as Rn, _ as Ln, b2 as Wn, l as jn, a3 as Hn, X as q, o as qn } from "./validators-BtaCFIEB.js";
7
+ import "./matrix-operation-contract-BSiGEXVC.js";
8
+ import { k as Zn, i as fe } from "./analytics-base-schemas-CB3oFAXk.js";
9
+ import { b as Kn } from "./report-runtime-context-DoIUr3MP.js";
10
+ import { canonicalizeSupportedLocale as X, canonicalizeSupportedCurrencyCode as Ae, DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as Vn } from "../value-format-preferences/index.js";
11
+ import { p as Bn, z as Xn } from "./zoned-wall-clock-CGLVI40Q.js";
12
+ function G(e) {
13
+ if (!e || typeof e != "object") return !1;
14
+ const t = e.type;
15
+ return t === "number" || t === "currency" || t === "percent" || t === "scientific";
16
+ }
17
+ function ks(e) {
18
+ return G(e) || !!e && typeof e == "object" && e.type === "duration";
19
+ }
20
+ const jt = [
21
+ "day",
22
+ "hour",
23
+ "minute",
24
+ "second",
25
+ "millisecond"
26
+ ], Ue = {
27
+ day: 864e5,
28
+ hour: 36e5,
29
+ minute: 6e4,
30
+ second: 1e3,
31
+ millisecond: 1
32
+ }, Gn = {
33
+ day: "d",
34
+ hour: "hr",
35
+ minute: "min",
36
+ second: "s",
37
+ millisecond: "ms"
38
+ }, Qn = {
39
+ day: ["day", "days"],
40
+ hour: ["hour", "hours"],
41
+ minute: ["minute", "minutes"],
42
+ second: ["second", "seconds"],
43
+ millisecond: ["millisecond", "milliseconds"]
44
+ };
45
+ function Jn(e) {
46
+ return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
47
+ }
48
+ function Ht(e, t) {
49
+ return Jn(e) ? e : t;
50
+ }
51
+ function rt(e, t) {
52
+ return jt.indexOf(Ht(e, t));
53
+ }
54
+ function er(e, t) {
55
+ const n = rt(e, "day"), r = rt(t, "second"), a = Math.min(n, r), i = Math.max(n, r);
56
+ return jt.slice(a, i + 1);
57
+ }
58
+ function tr(e, t) {
59
+ return e * Ue[Ht(t, "second")];
60
+ }
61
+ function nr(e, t) {
62
+ const n = er(t.largestUnit, t.smallestUnit), r = n[n.length - 1], a = Ue[r];
63
+ let i = Math.round(e / a) * a;
64
+ return n.map((o) => {
65
+ const s = Ue[o], c = Math.floor(i / s);
66
+ return i -= c * s, { unit: o, value: c };
67
+ });
68
+ }
69
+ function rr(e, t) {
70
+ const n = e.filter((i) => i.value !== 0), r = n.length > 0 ? n : [e[e.length - 1]], a = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : r.length;
71
+ return r.slice(0, a).map((i) => `${i.value}${Gn[i.unit]}`).join(" ");
72
+ }
73
+ function ar(e, t) {
74
+ const n = e.filter((i) => i.value !== 0), r = n.length > 0 ? n : [e[e.length - 1]], a = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : r.length;
75
+ return r.slice(0, a).map((i) => {
76
+ const [o, s] = Qn[i.unit];
77
+ return `${i.value} ${i.value === 1 ? o : s}`;
78
+ }).join(" ");
79
+ }
80
+ function ir(e) {
81
+ const t = e.some(
82
+ (c) => c.unit === "day" && c.value !== 0
83
+ ), n = e.some((c) => c.unit === "millisecond"), r = e.findIndex((c) => c.value !== 0), a = Math.max(0, e.length - 2), i = t ? 0 : r === -1 ? a : Math.min(r, a), o = r === -1 ? e.slice(a) : e.slice(i);
84
+ if (o.length === 0)
85
+ return "0";
86
+ const s = o.map((c, u) => c.unit === "millisecond" ? String(c.value).padStart(3, "0") : u === 0 ? String(c.value) : String(c.value).padStart(2, "0")).join(":");
87
+ return n ? s.replace(/:(\d{3})$/, ".$1") : s;
88
+ }
89
+ function or(e, t, n) {
90
+ const r = `${n.prefix || ""}${e}${n.suffix || ""}`;
91
+ return t ? n.negativeInParentheses ? `(${r})` : `-${r}` : r;
92
+ }
93
+ function qt(e, t = {}) {
94
+ if (e == null)
95
+ return "";
96
+ const n = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : NaN;
97
+ if (!Number.isFinite(n))
98
+ return "";
99
+ const r = t.inputUnit || "second", a = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", i = n < 0, o = Math.abs(tr(n, r)), s = nr(o, t), c = a === "digital" ? ir(s) : a === "long" ? ar(s, t.maxUnits) : rr(s, t.maxUnits);
100
+ return or(c, i, t);
101
+ }
102
+ function Zt(e, t) {
103
+ return qt(
104
+ e !== null && typeof e == "object" ? e.value : e,
105
+ {
106
+ inputUnit: t.inputUnit,
107
+ outputStyle: t.outputStyle,
108
+ largestUnit: t.largestUnit,
109
+ smallestUnit: t.smallestUnit,
110
+ maxUnits: t.maxUnits,
111
+ prefix: t.prefix,
112
+ suffix: t.suffix,
113
+ negativeInParentheses: t.negativeStyle === "parentheses"
114
+ }
115
+ );
116
+ }
117
+ let at;
118
+ function it(e, t) {
119
+ const n = e.format;
120
+ return n(t);
121
+ }
122
+ function sr(e, t) {
123
+ if (at ?? (at = it(
124
+ new Intl.NumberFormat("en-US", { useGrouping: !1, maximumFractionDigits: 6 }),
125
+ "9007199254740993.000009"
126
+ ) === "9007199254740993.000009"), !at)
127
+ throw new RangeError("This runtime cannot format exact decimal strings.");
128
+ const n = Number(e);
129
+ if (!Number.isFinite(n) || n === 0 && e !== "0")
130
+ throw new RangeError("Exact value is outside the Intl formatting range; use raw text.");
131
+ return it(t, e);
132
+ }
133
+ function Q(e) {
134
+ return typeof e == "number" ? e < 0 : e.value.startsWith("-");
135
+ }
136
+ function Z(e) {
137
+ return typeof e == "number" ? Math.abs(e) : Q(e) ? { ...e, value: e.value.slice(1) } : e;
138
+ }
139
+ function cr(e) {
140
+ return typeof e == "number" ? e === 0 : /^-?0*(\.0*)?$/.test(e.value);
141
+ }
142
+ function Kt(e, t) {
143
+ return typeof e == "number" ? e * t : {
144
+ kind: "exact_number",
145
+ type: "decimal",
146
+ value: Wt(e.value, t)
147
+ };
148
+ }
149
+ function de(e, t) {
150
+ return t === 0 ? e : typeof e == "number" ? e / 10 ** t : {
151
+ kind: "exact_number",
152
+ type: "decimal",
153
+ value: Wt(e.value, `1e-${t}`)
154
+ };
155
+ }
156
+ function A(e, t) {
157
+ return typeof e == "number" ? t.format(e) : sr(e.value, t);
158
+ }
159
+ function ot(e) {
160
+ if (!e) return !1;
161
+ const t = e.toLowerCase().replace("_", "-");
162
+ return t === "en-in" || t.startsWith("en-in-");
163
+ }
164
+ function st(e, t) {
165
+ const n = Z(e), r = (a) => typeof n == "number" ? n >= a : An(n.value, String(a)) >= 0;
166
+ return r(1e12) ? { power: 12, suffix: "T" } : r(1e9) ? { power: 9, suffix: "B" } : ot(t) && r(1e7) ? { power: 7, suffix: "Cr" } : r(1e6) ? { power: 6, suffix: "M" } : ot(t) && r(1e5) ? { power: 5, suffix: "L" } : r(1e3) ? { power: 3, suffix: "K" } : { power: 0, suffix: "" };
167
+ }
168
+ function Re(e, t) {
169
+ try {
170
+ const n = R(t);
171
+ return st(e, n);
172
+ } catch {
173
+ return st(e, "en-US");
174
+ }
175
+ }
176
+ const Vt = 500, te = /* @__PURE__ */ new Map(), ne = /* @__PURE__ */ new Map();
177
+ function _(e, t = {}) {
178
+ const n = `${e}|${JSON.stringify(t)}`;
179
+ let r = te.get(n);
180
+ return r || (r = new Intl.NumberFormat(e, t), te.size >= Vt && te.clear(), te.set(n, r)), r;
181
+ }
182
+ function ur(e) {
183
+ let t = ne.get(e);
184
+ if (t === void 0) {
185
+ try {
186
+ _(e), t = !0;
187
+ } catch {
188
+ t = !1;
189
+ }
190
+ ne.size >= Vt && ne.clear(), ne.set(e, t);
191
+ }
192
+ return t;
193
+ }
194
+ function R(e) {
195
+ return e && ur(e) ? e : "en-US";
196
+ }
197
+ function qe(e, t) {
198
+ if (e == null || Number.isNaN(e))
199
+ return "";
200
+ const n = R(t == null ? void 0 : t.locale);
201
+ let r = e;
202
+ if (t != null && t.multiplyBy && (r = Kt(r, t.multiplyBy)), t != null && t.useSuffix) {
203
+ const { power: i, suffix: o } = Re(r, n);
204
+ r = de(r, i);
205
+ const s = A(r, _(n, {
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
+ return `${(t == null ? void 0 : t.prefix) ?? ""}${s}${o}${(t == null ? void 0 : t.suffix) ?? ""}`;
211
+ }
212
+ const a = A(r, _(n, {
213
+ minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
214
+ maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
215
+ useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
216
+ }));
217
+ if (t != null && t.negativeInParentheses && Q(r)) {
218
+ const i = a.replace("-", "");
219
+ return `(${(t == null ? void 0 : t.prefix) ?? ""}${i}${(t == null ? void 0 : t.suffix) ?? ""})`;
220
+ }
221
+ return `${(t == null ? void 0 : t.prefix) ?? ""}${a}${(t == null ? void 0 : t.suffix) ?? ""}`;
222
+ }
223
+ function Bt(e, t) {
224
+ if (e == null || Number.isNaN(e))
225
+ return "";
226
+ const n = R(t == null ? void 0 : t.locale), r = (t == null ? void 0 : t.currency) || "USD", a = Q(e), i = !!(t != null && t.negativeInParentheses && a), o = i ? Z(e) : e;
227
+ try {
228
+ if (t != null && t.useSuffix) {
229
+ const { power: c, suffix: u } = Re(o, n), l = de(o, c), m = `${A(l, _(n, {
230
+ style: "currency",
231
+ currency: r,
232
+ minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
233
+ maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
234
+ useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
235
+ }))}${u}`;
236
+ return i ? `(${m})` : m;
237
+ }
238
+ const s = A(o, _(n, {
239
+ style: "currency",
240
+ currency: r,
241
+ minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
242
+ maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
243
+ useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
244
+ }));
245
+ return i ? `(${s})` : s;
246
+ } catch {
247
+ const s = Z(e), c = t != null && t.useSuffix ? Re(s, n) : { power: 0, suffix: "" }, u = qe(
248
+ de(s, c.power),
249
+ {
250
+ locale: n,
251
+ minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
252
+ maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
253
+ useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
254
+ }
255
+ ), l = `${r} ${u}${c.suffix}`;
256
+ return a ? t != null && t.negativeInParentheses ? `(${l})` : `-${l}` : l;
257
+ }
258
+ }
259
+ function Xt(e, t) {
260
+ if (e == null || Number.isNaN(e))
261
+ return "";
262
+ const n = R(t == null ? void 0 : t.locale), a = (t == null ? void 0 : t.alreadyPercent) ?? (t == null ? void 0 : t.percentValueMode) === "whole" ? de(e, 2) : e;
263
+ return A(a, _(n, {
264
+ style: "percent",
265
+ minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
266
+ maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
267
+ useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
268
+ }));
269
+ }
270
+ function Gt(e, t) {
271
+ if (e == null || Number.isNaN(e))
272
+ return "";
273
+ const n = R(t == null ? void 0 : t.locale);
274
+ return A(e, _(n, {
275
+ notation: "scientific",
276
+ minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
277
+ maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2
278
+ }));
279
+ }
280
+ function lr(e, t) {
281
+ const n = t ?? "auto", r = n === "never" ? Z(e) : e, a = !Q(r) && (n === "always" || n === "exceptZero" && !cr(r));
282
+ return { value: r, plus: a };
283
+ }
284
+ function _s(e) {
285
+ if (!e || !("signDisplay" in e)) return e;
286
+ const { signDisplay: t, ...n } = e;
287
+ return n;
288
+ }
289
+ function Ze(e, t) {
290
+ if (e == null || Number.isNaN(e))
291
+ return "";
292
+ const n = t.scale === void 0 ? e : Kt(e, t.scale), r = lr(n, t.signDisplay), a = r.value, i = r.plus ? "+" : "", o = t.negativeStyle === "parentheses" && Q(a), s = o ? Z(a) : a, c = {
293
+ style: t.type === "number" ? "decimal" : t.type,
294
+ locale: t.locale,
295
+ currency: t.currency,
296
+ minimumFractionDigits: t.minimumFractionDigits,
297
+ maximumFractionDigits: t.maximumFractionDigits,
298
+ useGrouping: t.useGrouping,
299
+ percentValueMode: t.percentValueMode,
300
+ useSuffix: t.compact
301
+ };
302
+ let u;
303
+ switch (t.type) {
304
+ case "currency":
305
+ u = Bt(s, c);
306
+ break;
307
+ case "percent":
308
+ u = Xt(s, c);
309
+ break;
310
+ case "scientific":
311
+ u = Gt(s, c);
312
+ break;
313
+ default:
314
+ u = qe(s, c);
315
+ break;
316
+ }
317
+ const l = `${t.prefix ?? ""}${i}${u}${t.suffix ?? ""}`;
318
+ return o ? `(${l})` : l;
319
+ }
320
+ function Ns(e, t) {
321
+ return t.type === "duration" ? e == null ? "" : Zt(e, t) : Ze(e, t);
322
+ }
323
+ function mr(e, t, n = "en-US") {
324
+ if (e == null || typeof e == "number" && isNaN(e))
325
+ return "";
326
+ if ((t == null ? void 0 : t.style) === "duration")
327
+ return Zt(e, {
328
+ ...t.duration,
329
+ prefix: t.prefix,
330
+ suffix: t.suffix,
331
+ negativeStyle: t.negativeStyle
332
+ });
333
+ const r = R((t == null ? void 0 : t.locale) || n), a = (t == null ? void 0 : t.style) || "decimal", i = a === "decimal" ? "number" : a;
334
+ return i === "currency" && _(r, {
335
+ style: "currency",
336
+ currency: (t == null ? void 0 : t.currency) || "USD"
337
+ }), Ze(e, {
338
+ type: i,
339
+ locale: r,
340
+ currency: i === "currency" ? (t == null ? void 0 : t.currency) || "USD" : void 0,
341
+ minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
342
+ maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
343
+ useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0,
344
+ percentValueMode: i === "percent" ? (t == null ? void 0 : t.percentValueMode) ?? "whole" : void 0,
345
+ scale: t == null ? void 0 : t.scale,
346
+ compact: t == null ? void 0 : t.compact,
347
+ negativeStyle: t == null ? void 0 : t.negativeStyle,
348
+ prefix: t == null ? void 0 : t.prefix,
349
+ suffix: t == null ? void 0 : t.suffix
350
+ });
351
+ }
352
+ function $s(e, t, n) {
353
+ const r = {
354
+ style: t === "currency" ? "currency" : t === "percent" ? "percent" : "decimal",
355
+ locale: n == null ? void 0 : n.locale,
356
+ currency: n == null ? void 0 : n.currency,
357
+ minimumFractionDigits: n == null ? void 0 : n.decimalPlaces,
358
+ maximumFractionDigits: n == null ? void 0 : n.decimalPlaces,
359
+ useSuffix: n == null ? void 0 : n.useSuffix,
360
+ prefix: n == null ? void 0 : n.prefix,
361
+ suffix: n == null ? void 0 : n.suffix,
362
+ negativeInParentheses: n == null ? void 0 : n.negativeInParentheses,
363
+ multiplyBy: n == null ? void 0 : n.multiplyBy
364
+ };
365
+ switch (t) {
366
+ case "currency":
367
+ return Bt(e, r);
368
+ case "percent":
369
+ return Xt(e, r);
370
+ case "scientific":
371
+ return Gt(e, r);
372
+ default:
373
+ return qe(e, r);
374
+ }
375
+ }
376
+ function p(e) {
377
+ const t = Object.prototype.toString.call(e);
378
+ return e instanceof Date || typeof e == "object" && t === "[object Date]" ? new e.constructor(+e) : typeof e == "number" || t === "[object Number]" || typeof e == "string" || t === "[object String]" ? new Date(e) : /* @__PURE__ */ new Date(NaN);
379
+ }
380
+ function N(e, t) {
381
+ return e instanceof Date ? new e.constructor(t) : new Date(t);
382
+ }
383
+ const Qt = 6048e5, fr = 864e5, Jt = 6e4, en = 36e5, Os = 525600, re = 43200, ct = 1440;
384
+ let dr = {};
385
+ function L() {
386
+ return dr;
387
+ }
388
+ function K(e, t) {
389
+ var s, c, u, l;
390
+ const n = L(), r = (t == null ? void 0 : t.weekStartsOn) ?? ((c = (s = t == null ? void 0 : t.locale) == null ? void 0 : s.options) == null ? void 0 : c.weekStartsOn) ?? n.weekStartsOn ?? ((l = (u = n.locale) == null ? void 0 : u.options) == null ? void 0 : l.weekStartsOn) ?? 0, a = p(e), i = a.getDay(), o = (i < r ? 7 : 0) + i - r;
391
+ return a.setDate(a.getDate() - o), a.setHours(0, 0, 0, 0), a;
392
+ }
393
+ function he(e) {
394
+ return K(e, { weekStartsOn: 1 });
395
+ }
396
+ function tn(e) {
397
+ const t = p(e), n = t.getFullYear(), r = N(e, 0);
398
+ r.setFullYear(n + 1, 0, 4), r.setHours(0, 0, 0, 0);
399
+ const a = he(r), i = N(e, 0);
400
+ i.setFullYear(n, 0, 4), i.setHours(0, 0, 0, 0);
401
+ const o = he(i);
402
+ return t.getTime() >= a.getTime() ? n + 1 : t.getTime() >= o.getTime() ? n : n - 1;
403
+ }
404
+ function ut(e) {
405
+ const t = p(e);
406
+ return t.setHours(0, 0, 0, 0), t;
407
+ }
408
+ function ge(e) {
409
+ const t = p(e), n = new Date(
410
+ Date.UTC(
411
+ t.getFullYear(),
412
+ t.getMonth(),
413
+ t.getDate(),
414
+ t.getHours(),
415
+ t.getMinutes(),
416
+ t.getSeconds(),
417
+ t.getMilliseconds()
418
+ )
419
+ );
420
+ return n.setUTCFullYear(t.getFullYear()), +e - +n;
421
+ }
422
+ function hr(e, t) {
423
+ const n = ut(e), r = ut(t), a = +n - ge(n), i = +r - ge(r);
424
+ return Math.round((a - i) / fr);
425
+ }
426
+ function gr(e) {
427
+ const t = tn(e), n = N(e, 0);
428
+ return n.setFullYear(t, 0, 4), n.setHours(0, 0, 0, 0), he(n);
429
+ }
430
+ function se(e, t) {
431
+ const n = p(e), r = p(t), a = n.getTime() - r.getTime();
432
+ return a < 0 ? -1 : a > 0 ? 1 : a;
433
+ }
434
+ function yr(e) {
435
+ return N(e, Date.now());
436
+ }
437
+ function pr(e) {
438
+ return e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]";
439
+ }
440
+ function wr(e) {
441
+ if (!pr(e) && typeof e != "number")
442
+ return !1;
443
+ const t = p(e);
444
+ return !isNaN(Number(t));
445
+ }
446
+ function Tr(e, t) {
447
+ const n = p(e), r = p(t), a = n.getFullYear() - r.getFullYear(), i = n.getMonth() - r.getMonth();
448
+ return a * 12 + i;
449
+ }
450
+ function Dr(e) {
451
+ return (t) => {
452
+ const r = (e ? Math[e] : Math.trunc)(t);
453
+ return r === 0 ? 0 : r;
454
+ };
455
+ }
456
+ function br(e, t) {
457
+ return +p(e) - +p(t);
458
+ }
459
+ function xr(e) {
460
+ const t = p(e);
461
+ return t.setHours(23, 59, 59, 999), t;
462
+ }
463
+ function vr(e) {
464
+ const t = p(e), n = t.getMonth();
465
+ return t.setFullYear(t.getFullYear(), n + 1, 0), t.setHours(23, 59, 59, 999), t;
466
+ }
467
+ function Sr(e) {
468
+ const t = p(e);
469
+ return +xr(t) == +vr(t);
470
+ }
471
+ function Mr(e, t) {
472
+ const n = p(e), r = p(t), a = se(n, r), i = Math.abs(
473
+ Tr(n, r)
474
+ );
475
+ let o;
476
+ if (i < 1)
477
+ o = 0;
478
+ else {
479
+ n.getMonth() === 1 && n.getDate() > 27 && n.setDate(30), n.setMonth(n.getMonth() - a * i);
480
+ let s = se(n, r) === -a;
481
+ Sr(p(e)) && i === 1 && se(e, r) === 1 && (s = !1), o = a * (i - Number(s));
482
+ }
483
+ return o === 0 ? 0 : o;
484
+ }
485
+ function kr(e, t, n) {
486
+ const r = br(e, t) / 1e3;
487
+ return Dr(n == null ? void 0 : n.roundingMethod)(r);
488
+ }
489
+ function _r(e) {
490
+ const t = p(e), n = N(e, 0);
491
+ return n.setFullYear(t.getFullYear(), 0, 1), n.setHours(0, 0, 0, 0), n;
492
+ }
493
+ const Nr = {
494
+ lessThanXSeconds: {
495
+ one: "less than a second",
496
+ other: "less than {{count}} seconds"
497
+ },
498
+ xSeconds: {
499
+ one: "1 second",
500
+ other: "{{count}} seconds"
501
+ },
502
+ halfAMinute: "half a minute",
503
+ lessThanXMinutes: {
504
+ one: "less than a minute",
505
+ other: "less than {{count}} minutes"
506
+ },
507
+ xMinutes: {
508
+ one: "1 minute",
509
+ other: "{{count}} minutes"
510
+ },
511
+ aboutXHours: {
512
+ one: "about 1 hour",
513
+ other: "about {{count}} hours"
514
+ },
515
+ xHours: {
516
+ one: "1 hour",
517
+ other: "{{count}} hours"
518
+ },
519
+ xDays: {
520
+ one: "1 day",
521
+ other: "{{count}} days"
522
+ },
523
+ aboutXWeeks: {
524
+ one: "about 1 week",
525
+ other: "about {{count}} weeks"
526
+ },
527
+ xWeeks: {
528
+ one: "1 week",
529
+ other: "{{count}} weeks"
530
+ },
531
+ aboutXMonths: {
532
+ one: "about 1 month",
533
+ other: "about {{count}} months"
534
+ },
535
+ xMonths: {
536
+ one: "1 month",
537
+ other: "{{count}} months"
538
+ },
539
+ aboutXYears: {
540
+ one: "about 1 year",
541
+ other: "about {{count}} years"
542
+ },
543
+ xYears: {
544
+ one: "1 year",
545
+ other: "{{count}} years"
546
+ },
547
+ overXYears: {
548
+ one: "over 1 year",
549
+ other: "over {{count}} years"
550
+ },
551
+ almostXYears: {
552
+ one: "almost 1 year",
553
+ other: "almost {{count}} years"
554
+ }
555
+ }, $r = (e, t, n) => {
556
+ let r;
557
+ const a = Nr[e];
558
+ return typeof a == "string" ? r = a : t === 1 ? r = a.one : r = a.other.replace("{{count}}", t.toString()), n != null && n.addSuffix ? n.comparison && n.comparison > 0 ? "in " + r : r + " ago" : r;
559
+ };
560
+ function ke(e) {
561
+ return (t = {}) => {
562
+ const n = t.width ? String(t.width) : e.defaultWidth;
563
+ return e.formats[n] || e.formats[e.defaultWidth];
564
+ };
565
+ }
566
+ const Or = {
567
+ full: "EEEE, MMMM do, y",
568
+ long: "MMMM do, y",
569
+ medium: "MMM d, y",
570
+ short: "MM/dd/yyyy"
571
+ }, Ir = {
572
+ full: "h:mm:ss a zzzz",
573
+ long: "h:mm:ss a z",
574
+ medium: "h:mm:ss a",
575
+ short: "h:mm a"
576
+ }, Fr = {
577
+ full: "{{date}} 'at' {{time}}",
578
+ long: "{{date}} 'at' {{time}}",
579
+ medium: "{{date}}, {{time}}",
580
+ short: "{{date}}, {{time}}"
581
+ }, Er = {
582
+ date: ke({
583
+ formats: Or,
584
+ defaultWidth: "full"
585
+ }),
586
+ time: ke({
587
+ formats: Ir,
588
+ defaultWidth: "full"
589
+ }),
590
+ dateTime: ke({
591
+ formats: Fr,
592
+ defaultWidth: "full"
593
+ })
594
+ }, Cr = {
595
+ lastWeek: "'last' eeee 'at' p",
596
+ yesterday: "'yesterday at' p",
597
+ today: "'today at' p",
598
+ tomorrow: "'tomorrow at' p",
599
+ nextWeek: "eeee 'at' p",
600
+ other: "P"
601
+ }, Pr = (e, t, n, r) => Cr[e];
602
+ function W(e) {
603
+ return (t, n) => {
604
+ const r = n != null && n.context ? String(n.context) : "standalone";
605
+ let a;
606
+ if (r === "formatting" && e.formattingValues) {
607
+ const o = e.defaultFormattingWidth || e.defaultWidth, s = n != null && n.width ? String(n.width) : o;
608
+ a = e.formattingValues[s] || e.formattingValues[o];
609
+ } else {
610
+ const o = e.defaultWidth, s = n != null && n.width ? String(n.width) : e.defaultWidth;
611
+ a = e.values[s] || e.values[o];
612
+ }
613
+ const i = e.argumentCallback ? e.argumentCallback(t) : t;
614
+ return a[i];
615
+ };
616
+ }
617
+ const Yr = {
618
+ narrow: ["B", "A"],
619
+ abbreviated: ["BC", "AD"],
620
+ wide: ["Before Christ", "Anno Domini"]
621
+ }, zr = {
622
+ narrow: ["1", "2", "3", "4"],
623
+ abbreviated: ["Q1", "Q2", "Q3", "Q4"],
624
+ wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
625
+ }, Ar = {
626
+ narrow: ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"],
627
+ abbreviated: [
628
+ "Jan",
629
+ "Feb",
630
+ "Mar",
631
+ "Apr",
632
+ "May",
633
+ "Jun",
634
+ "Jul",
635
+ "Aug",
636
+ "Sep",
637
+ "Oct",
638
+ "Nov",
639
+ "Dec"
640
+ ],
641
+ wide: [
642
+ "January",
643
+ "February",
644
+ "March",
645
+ "April",
646
+ "May",
647
+ "June",
648
+ "July",
649
+ "August",
650
+ "September",
651
+ "October",
652
+ "November",
653
+ "December"
654
+ ]
655
+ }, Ur = {
656
+ narrow: ["S", "M", "T", "W", "T", "F", "S"],
657
+ short: ["Su", "Mo", "Tu", "We", "Th", "Fr", "Sa"],
658
+ abbreviated: ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"],
659
+ wide: [
660
+ "Sunday",
661
+ "Monday",
662
+ "Tuesday",
663
+ "Wednesday",
664
+ "Thursday",
665
+ "Friday",
666
+ "Saturday"
667
+ ]
668
+ }, Rr = {
669
+ narrow: {
670
+ am: "a",
671
+ pm: "p",
672
+ midnight: "mi",
673
+ noon: "n",
674
+ morning: "morning",
675
+ afternoon: "afternoon",
676
+ evening: "evening",
677
+ night: "night"
678
+ },
679
+ abbreviated: {
680
+ am: "AM",
681
+ pm: "PM",
682
+ midnight: "midnight",
683
+ noon: "noon",
684
+ morning: "morning",
685
+ afternoon: "afternoon",
686
+ evening: "evening",
687
+ night: "night"
688
+ },
689
+ wide: {
690
+ am: "a.m.",
691
+ pm: "p.m.",
692
+ midnight: "midnight",
693
+ noon: "noon",
694
+ morning: "morning",
695
+ afternoon: "afternoon",
696
+ evening: "evening",
697
+ night: "night"
698
+ }
699
+ }, Lr = {
700
+ narrow: {
701
+ am: "a",
702
+ pm: "p",
703
+ midnight: "mi",
704
+ noon: "n",
705
+ morning: "in the morning",
706
+ afternoon: "in the afternoon",
707
+ evening: "in the evening",
708
+ night: "at night"
709
+ },
710
+ abbreviated: {
711
+ am: "AM",
712
+ pm: "PM",
713
+ midnight: "midnight",
714
+ noon: "noon",
715
+ morning: "in the morning",
716
+ afternoon: "in the afternoon",
717
+ evening: "in the evening",
718
+ night: "at night"
719
+ },
720
+ wide: {
721
+ am: "a.m.",
722
+ pm: "p.m.",
723
+ midnight: "midnight",
724
+ noon: "noon",
725
+ morning: "in the morning",
726
+ afternoon: "in the afternoon",
727
+ evening: "in the evening",
728
+ night: "at night"
729
+ }
730
+ }, Wr = (e, t) => {
731
+ const n = Number(e), r = n % 100;
732
+ if (r > 20 || r < 10)
733
+ switch (r % 10) {
734
+ case 1:
735
+ return n + "st";
736
+ case 2:
737
+ return n + "nd";
738
+ case 3:
739
+ return n + "rd";
740
+ }
741
+ return n + "th";
742
+ }, jr = {
743
+ ordinalNumber: Wr,
744
+ era: W({
745
+ values: Yr,
746
+ defaultWidth: "wide"
747
+ }),
748
+ quarter: W({
749
+ values: zr,
750
+ defaultWidth: "wide",
751
+ argumentCallback: (e) => e - 1
752
+ }),
753
+ month: W({
754
+ values: Ar,
755
+ defaultWidth: "wide"
756
+ }),
757
+ day: W({
758
+ values: Ur,
759
+ defaultWidth: "wide"
760
+ }),
761
+ dayPeriod: W({
762
+ values: Rr,
763
+ defaultWidth: "wide",
764
+ formattingValues: Lr,
765
+ defaultFormattingWidth: "wide"
766
+ })
767
+ };
768
+ function j(e) {
769
+ return (t, n = {}) => {
770
+ const r = n.width, a = r && e.matchPatterns[r] || e.matchPatterns[e.defaultMatchWidth], i = t.match(a);
771
+ if (!i)
772
+ return null;
773
+ const o = i[0], s = r && e.parsePatterns[r] || e.parsePatterns[e.defaultParseWidth], c = Array.isArray(s) ? qr(s, (f) => f.test(o)) : (
774
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
775
+ Hr(s, (f) => f.test(o))
776
+ );
777
+ let u;
778
+ u = e.valueCallback ? e.valueCallback(c) : c, u = n.valueCallback ? (
779
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
780
+ n.valueCallback(u)
781
+ ) : u;
782
+ const l = t.slice(o.length);
783
+ return { value: u, rest: l };
784
+ };
785
+ }
786
+ function Hr(e, t) {
787
+ for (const n in e)
788
+ if (Object.prototype.hasOwnProperty.call(e, n) && t(e[n]))
789
+ return n;
790
+ }
791
+ function qr(e, t) {
792
+ for (let n = 0; n < e.length; n++)
793
+ if (t(e[n]))
794
+ return n;
795
+ }
796
+ function Zr(e) {
797
+ return (t, n = {}) => {
798
+ const r = t.match(e.matchPattern);
799
+ if (!r) return null;
800
+ const a = r[0], i = t.match(e.parsePattern);
801
+ if (!i) return null;
802
+ let o = e.valueCallback ? e.valueCallback(i[0]) : i[0];
803
+ o = n.valueCallback ? n.valueCallback(o) : o;
804
+ const s = t.slice(a.length);
805
+ return { value: o, rest: s };
806
+ };
807
+ }
808
+ const Kr = /^(\d+)(th|st|nd|rd)?/i, Vr = /\d+/i, Br = {
809
+ narrow: /^(b|a)/i,
810
+ abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
811
+ wide: /^(before christ|before common era|anno domini|common era)/i
812
+ }, Xr = {
813
+ any: [/^b/i, /^(a|c)/i]
814
+ }, Gr = {
815
+ narrow: /^[1234]/i,
816
+ abbreviated: /^q[1234]/i,
817
+ wide: /^[1234](th|st|nd|rd)? quarter/i
818
+ }, Qr = {
819
+ any: [/1/i, /2/i, /3/i, /4/i]
820
+ }, Jr = {
821
+ narrow: /^[jfmasond]/i,
822
+ abbreviated: /^(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)/i,
823
+ wide: /^(january|february|march|april|may|june|july|august|september|october|november|december)/i
824
+ }, ea = {
825
+ narrow: [
826
+ /^j/i,
827
+ /^f/i,
828
+ /^m/i,
829
+ /^a/i,
830
+ /^m/i,
831
+ /^j/i,
832
+ /^j/i,
833
+ /^a/i,
834
+ /^s/i,
835
+ /^o/i,
836
+ /^n/i,
837
+ /^d/i
838
+ ],
839
+ any: [
840
+ /^ja/i,
841
+ /^f/i,
842
+ /^mar/i,
843
+ /^ap/i,
844
+ /^may/i,
845
+ /^jun/i,
846
+ /^jul/i,
847
+ /^au/i,
848
+ /^s/i,
849
+ /^o/i,
850
+ /^n/i,
851
+ /^d/i
852
+ ]
853
+ }, ta = {
854
+ narrow: /^[smtwf]/i,
855
+ short: /^(su|mo|tu|we|th|fr|sa)/i,
856
+ abbreviated: /^(sun|mon|tue|wed|thu|fri|sat)/i,
857
+ wide: /^(sunday|monday|tuesday|wednesday|thursday|friday|saturday)/i
858
+ }, na = {
859
+ narrow: [/^s/i, /^m/i, /^t/i, /^w/i, /^t/i, /^f/i, /^s/i],
860
+ any: [/^su/i, /^m/i, /^tu/i, /^w/i, /^th/i, /^f/i, /^sa/i]
861
+ }, ra = {
862
+ narrow: /^(a|p|mi|n|(in the|at) (morning|afternoon|evening|night))/i,
863
+ any: /^([ap]\.?\s?m\.?|midnight|noon|(in the|at) (morning|afternoon|evening|night))/i
864
+ }, aa = {
865
+ any: {
866
+ am: /^a/i,
867
+ pm: /^p/i,
868
+ midnight: /^mi/i,
869
+ noon: /^no/i,
870
+ morning: /morning/i,
871
+ afternoon: /afternoon/i,
872
+ evening: /evening/i,
873
+ night: /night/i
874
+ }
875
+ }, ia = {
876
+ ordinalNumber: Zr({
877
+ matchPattern: Kr,
878
+ parsePattern: Vr,
879
+ valueCallback: (e) => parseInt(e, 10)
880
+ }),
881
+ era: j({
882
+ matchPatterns: Br,
883
+ defaultMatchWidth: "wide",
884
+ parsePatterns: Xr,
885
+ defaultParseWidth: "any"
886
+ }),
887
+ quarter: j({
888
+ matchPatterns: Gr,
889
+ defaultMatchWidth: "wide",
890
+ parsePatterns: Qr,
891
+ defaultParseWidth: "any",
892
+ valueCallback: (e) => e + 1
893
+ }),
894
+ month: j({
895
+ matchPatterns: Jr,
896
+ defaultMatchWidth: "wide",
897
+ parsePatterns: ea,
898
+ defaultParseWidth: "any"
899
+ }),
900
+ day: j({
901
+ matchPatterns: ta,
902
+ defaultMatchWidth: "wide",
903
+ parsePatterns: na,
904
+ defaultParseWidth: "any"
905
+ }),
906
+ dayPeriod: j({
907
+ matchPatterns: ra,
908
+ defaultMatchWidth: "any",
909
+ parsePatterns: aa,
910
+ defaultParseWidth: "any"
911
+ })
912
+ }, nn = {
913
+ code: "en-US",
914
+ formatDistance: $r,
915
+ formatLong: Er,
916
+ formatRelative: Pr,
917
+ localize: jr,
918
+ match: ia,
919
+ options: {
920
+ weekStartsOn: 0,
921
+ firstWeekContainsDate: 1
922
+ }
923
+ };
924
+ function oa(e) {
925
+ const t = p(e);
926
+ return hr(t, _r(t)) + 1;
927
+ }
928
+ function sa(e) {
929
+ const t = p(e), n = +he(t) - +gr(t);
930
+ return Math.round(n / Qt) + 1;
931
+ }
932
+ function rn(e, t) {
933
+ var l, f, m, h;
934
+ const n = p(e), r = n.getFullYear(), a = L(), i = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((f = (l = t == null ? void 0 : t.locale) == null ? void 0 : l.options) == null ? void 0 : f.firstWeekContainsDate) ?? a.firstWeekContainsDate ?? ((h = (m = a.locale) == null ? void 0 : m.options) == null ? void 0 : h.firstWeekContainsDate) ?? 1, o = N(e, 0);
935
+ o.setFullYear(r + 1, 0, i), o.setHours(0, 0, 0, 0);
936
+ const s = K(o, t), c = N(e, 0);
937
+ c.setFullYear(r, 0, i), c.setHours(0, 0, 0, 0);
938
+ const u = K(c, t);
939
+ return n.getTime() >= s.getTime() ? r + 1 : n.getTime() >= u.getTime() ? r : r - 1;
940
+ }
941
+ function ca(e, t) {
942
+ var s, c, u, l;
943
+ const n = L(), r = (t == null ? void 0 : t.firstWeekContainsDate) ?? ((c = (s = t == null ? void 0 : t.locale) == null ? void 0 : s.options) == null ? void 0 : c.firstWeekContainsDate) ?? n.firstWeekContainsDate ?? ((l = (u = n.locale) == null ? void 0 : u.options) == null ? void 0 : l.firstWeekContainsDate) ?? 1, a = rn(e, t), i = N(e, 0);
944
+ return i.setFullYear(a, 0, r), i.setHours(0, 0, 0, 0), K(i, t);
945
+ }
946
+ function ua(e, t) {
947
+ const n = p(e), r = +K(n, t) - +ca(n, t);
948
+ return Math.round(r / Qt) + 1;
949
+ }
950
+ function y(e, t) {
951
+ const n = e < 0 ? "-" : "", r = Math.abs(e).toString().padStart(t, "0");
952
+ return n + r;
953
+ }
954
+ const k = {
955
+ // Year
956
+ y(e, t) {
957
+ const n = e.getFullYear(), r = n > 0 ? n : 1 - n;
958
+ return y(t === "yy" ? r % 100 : r, t.length);
959
+ },
960
+ // Month
961
+ M(e, t) {
962
+ const n = e.getMonth();
963
+ return t === "M" ? String(n + 1) : y(n + 1, 2);
964
+ },
965
+ // Day of the month
966
+ d(e, t) {
967
+ return y(e.getDate(), t.length);
968
+ },
969
+ // AM or PM
970
+ a(e, t) {
971
+ const n = e.getHours() / 12 >= 1 ? "pm" : "am";
972
+ switch (t) {
973
+ case "a":
974
+ case "aa":
975
+ return n.toUpperCase();
976
+ case "aaa":
977
+ return n;
978
+ case "aaaaa":
979
+ return n[0];
980
+ case "aaaa":
981
+ default:
982
+ return n === "am" ? "a.m." : "p.m.";
983
+ }
984
+ },
985
+ // Hour [1-12]
986
+ h(e, t) {
987
+ return y(e.getHours() % 12 || 12, t.length);
988
+ },
989
+ // Hour [0-23]
990
+ H(e, t) {
991
+ return y(e.getHours(), t.length);
992
+ },
993
+ // Minute
994
+ m(e, t) {
995
+ return y(e.getMinutes(), t.length);
996
+ },
997
+ // Second
998
+ s(e, t) {
999
+ return y(e.getSeconds(), t.length);
1000
+ },
1001
+ // Fraction of second
1002
+ S(e, t) {
1003
+ const n = t.length, r = e.getMilliseconds(), a = Math.trunc(
1004
+ r * Math.pow(10, n - 3)
1005
+ );
1006
+ return y(a, t.length);
1007
+ }
1008
+ }, E = {
1009
+ midnight: "midnight",
1010
+ noon: "noon",
1011
+ morning: "morning",
1012
+ afternoon: "afternoon",
1013
+ evening: "evening",
1014
+ night: "night"
1015
+ }, lt = {
1016
+ // Era
1017
+ G: function(e, t, n) {
1018
+ const r = e.getFullYear() > 0 ? 1 : 0;
1019
+ switch (t) {
1020
+ case "G":
1021
+ case "GG":
1022
+ case "GGG":
1023
+ return n.era(r, { width: "abbreviated" });
1024
+ case "GGGGG":
1025
+ return n.era(r, { width: "narrow" });
1026
+ case "GGGG":
1027
+ default:
1028
+ return n.era(r, { width: "wide" });
1029
+ }
1030
+ },
1031
+ // Year
1032
+ y: function(e, t, n) {
1033
+ if (t === "yo") {
1034
+ const r = e.getFullYear(), a = r > 0 ? r : 1 - r;
1035
+ return n.ordinalNumber(a, { unit: "year" });
1036
+ }
1037
+ return k.y(e, t);
1038
+ },
1039
+ // Local week-numbering year
1040
+ Y: function(e, t, n, r) {
1041
+ const a = rn(e, r), i = a > 0 ? a : 1 - a;
1042
+ if (t === "YY") {
1043
+ const o = i % 100;
1044
+ return y(o, 2);
1045
+ }
1046
+ return t === "Yo" ? n.ordinalNumber(i, { unit: "year" }) : y(i, t.length);
1047
+ },
1048
+ // ISO week-numbering year
1049
+ R: function(e, t) {
1050
+ const n = tn(e);
1051
+ return y(n, t.length);
1052
+ },
1053
+ // Extended year. This is a single number designating the year of this calendar system.
1054
+ // The main difference between `y` and `u` localizers are B.C. years:
1055
+ // | Year | `y` | `u` |
1056
+ // |------|-----|-----|
1057
+ // | AC 1 | 1 | 1 |
1058
+ // | BC 1 | 1 | 0 |
1059
+ // | BC 2 | 2 | -1 |
1060
+ // Also `yy` always returns the last two digits of a year,
1061
+ // while `uu` pads single digit years to 2 characters and returns other years unchanged.
1062
+ u: function(e, t) {
1063
+ const n = e.getFullYear();
1064
+ return y(n, t.length);
1065
+ },
1066
+ // Quarter
1067
+ Q: function(e, t, n) {
1068
+ const r = Math.ceil((e.getMonth() + 1) / 3);
1069
+ switch (t) {
1070
+ case "Q":
1071
+ return String(r);
1072
+ case "QQ":
1073
+ return y(r, 2);
1074
+ case "Qo":
1075
+ return n.ordinalNumber(r, { unit: "quarter" });
1076
+ case "QQQ":
1077
+ return n.quarter(r, {
1078
+ width: "abbreviated",
1079
+ context: "formatting"
1080
+ });
1081
+ case "QQQQQ":
1082
+ return n.quarter(r, {
1083
+ width: "narrow",
1084
+ context: "formatting"
1085
+ });
1086
+ case "QQQQ":
1087
+ default:
1088
+ return n.quarter(r, {
1089
+ width: "wide",
1090
+ context: "formatting"
1091
+ });
1092
+ }
1093
+ },
1094
+ // Stand-alone quarter
1095
+ q: function(e, t, n) {
1096
+ const r = Math.ceil((e.getMonth() + 1) / 3);
1097
+ switch (t) {
1098
+ case "q":
1099
+ return String(r);
1100
+ case "qq":
1101
+ return y(r, 2);
1102
+ case "qo":
1103
+ return n.ordinalNumber(r, { unit: "quarter" });
1104
+ case "qqq":
1105
+ return n.quarter(r, {
1106
+ width: "abbreviated",
1107
+ context: "standalone"
1108
+ });
1109
+ case "qqqqq":
1110
+ return n.quarter(r, {
1111
+ width: "narrow",
1112
+ context: "standalone"
1113
+ });
1114
+ case "qqqq":
1115
+ default:
1116
+ return n.quarter(r, {
1117
+ width: "wide",
1118
+ context: "standalone"
1119
+ });
1120
+ }
1121
+ },
1122
+ // Month
1123
+ M: function(e, t, n) {
1124
+ const r = e.getMonth();
1125
+ switch (t) {
1126
+ case "M":
1127
+ case "MM":
1128
+ return k.M(e, t);
1129
+ case "Mo":
1130
+ return n.ordinalNumber(r + 1, { unit: "month" });
1131
+ case "MMM":
1132
+ return n.month(r, {
1133
+ width: "abbreviated",
1134
+ context: "formatting"
1135
+ });
1136
+ case "MMMMM":
1137
+ return n.month(r, {
1138
+ width: "narrow",
1139
+ context: "formatting"
1140
+ });
1141
+ case "MMMM":
1142
+ default:
1143
+ return n.month(r, { width: "wide", context: "formatting" });
1144
+ }
1145
+ },
1146
+ // Stand-alone month
1147
+ L: function(e, t, n) {
1148
+ const r = e.getMonth();
1149
+ switch (t) {
1150
+ case "L":
1151
+ return String(r + 1);
1152
+ case "LL":
1153
+ return y(r + 1, 2);
1154
+ case "Lo":
1155
+ return n.ordinalNumber(r + 1, { unit: "month" });
1156
+ case "LLL":
1157
+ return n.month(r, {
1158
+ width: "abbreviated",
1159
+ context: "standalone"
1160
+ });
1161
+ case "LLLLL":
1162
+ return n.month(r, {
1163
+ width: "narrow",
1164
+ context: "standalone"
1165
+ });
1166
+ case "LLLL":
1167
+ default:
1168
+ return n.month(r, { width: "wide", context: "standalone" });
1169
+ }
1170
+ },
1171
+ // Local week of year
1172
+ w: function(e, t, n, r) {
1173
+ const a = ua(e, r);
1174
+ return t === "wo" ? n.ordinalNumber(a, { unit: "week" }) : y(a, t.length);
1175
+ },
1176
+ // ISO week of year
1177
+ I: function(e, t, n) {
1178
+ const r = sa(e);
1179
+ return t === "Io" ? n.ordinalNumber(r, { unit: "week" }) : y(r, t.length);
1180
+ },
1181
+ // Day of the month
1182
+ d: function(e, t, n) {
1183
+ return t === "do" ? n.ordinalNumber(e.getDate(), { unit: "date" }) : k.d(e, t);
1184
+ },
1185
+ // Day of year
1186
+ D: function(e, t, n) {
1187
+ const r = oa(e);
1188
+ return t === "Do" ? n.ordinalNumber(r, { unit: "dayOfYear" }) : y(r, t.length);
1189
+ },
1190
+ // Day of week
1191
+ E: function(e, t, n) {
1192
+ const r = e.getDay();
1193
+ switch (t) {
1194
+ case "E":
1195
+ case "EE":
1196
+ case "EEE":
1197
+ return n.day(r, {
1198
+ width: "abbreviated",
1199
+ context: "formatting"
1200
+ });
1201
+ case "EEEEE":
1202
+ return n.day(r, {
1203
+ width: "narrow",
1204
+ context: "formatting"
1205
+ });
1206
+ case "EEEEEE":
1207
+ return n.day(r, {
1208
+ width: "short",
1209
+ context: "formatting"
1210
+ });
1211
+ case "EEEE":
1212
+ default:
1213
+ return n.day(r, {
1214
+ width: "wide",
1215
+ context: "formatting"
1216
+ });
1217
+ }
1218
+ },
1219
+ // Local day of week
1220
+ e: function(e, t, n, r) {
1221
+ const a = e.getDay(), i = (a - r.weekStartsOn + 8) % 7 || 7;
1222
+ switch (t) {
1223
+ case "e":
1224
+ return String(i);
1225
+ case "ee":
1226
+ return y(i, 2);
1227
+ case "eo":
1228
+ return n.ordinalNumber(i, { unit: "day" });
1229
+ case "eee":
1230
+ return n.day(a, {
1231
+ width: "abbreviated",
1232
+ context: "formatting"
1233
+ });
1234
+ case "eeeee":
1235
+ return n.day(a, {
1236
+ width: "narrow",
1237
+ context: "formatting"
1238
+ });
1239
+ case "eeeeee":
1240
+ return n.day(a, {
1241
+ width: "short",
1242
+ context: "formatting"
1243
+ });
1244
+ case "eeee":
1245
+ default:
1246
+ return n.day(a, {
1247
+ width: "wide",
1248
+ context: "formatting"
1249
+ });
1250
+ }
1251
+ },
1252
+ // Stand-alone local day of week
1253
+ c: function(e, t, n, r) {
1254
+ const a = e.getDay(), i = (a - r.weekStartsOn + 8) % 7 || 7;
1255
+ switch (t) {
1256
+ case "c":
1257
+ return String(i);
1258
+ case "cc":
1259
+ return y(i, t.length);
1260
+ case "co":
1261
+ return n.ordinalNumber(i, { unit: "day" });
1262
+ case "ccc":
1263
+ return n.day(a, {
1264
+ width: "abbreviated",
1265
+ context: "standalone"
1266
+ });
1267
+ case "ccccc":
1268
+ return n.day(a, {
1269
+ width: "narrow",
1270
+ context: "standalone"
1271
+ });
1272
+ case "cccccc":
1273
+ return n.day(a, {
1274
+ width: "short",
1275
+ context: "standalone"
1276
+ });
1277
+ case "cccc":
1278
+ default:
1279
+ return n.day(a, {
1280
+ width: "wide",
1281
+ context: "standalone"
1282
+ });
1283
+ }
1284
+ },
1285
+ // ISO day of week
1286
+ i: function(e, t, n) {
1287
+ const r = e.getDay(), a = r === 0 ? 7 : r;
1288
+ switch (t) {
1289
+ case "i":
1290
+ return String(a);
1291
+ case "ii":
1292
+ return y(a, t.length);
1293
+ case "io":
1294
+ return n.ordinalNumber(a, { unit: "day" });
1295
+ case "iii":
1296
+ return n.day(r, {
1297
+ width: "abbreviated",
1298
+ context: "formatting"
1299
+ });
1300
+ case "iiiii":
1301
+ return n.day(r, {
1302
+ width: "narrow",
1303
+ context: "formatting"
1304
+ });
1305
+ case "iiiiii":
1306
+ return n.day(r, {
1307
+ width: "short",
1308
+ context: "formatting"
1309
+ });
1310
+ case "iiii":
1311
+ default:
1312
+ return n.day(r, {
1313
+ width: "wide",
1314
+ context: "formatting"
1315
+ });
1316
+ }
1317
+ },
1318
+ // AM or PM
1319
+ a: function(e, t, n) {
1320
+ const a = e.getHours() / 12 >= 1 ? "pm" : "am";
1321
+ switch (t) {
1322
+ case "a":
1323
+ case "aa":
1324
+ return n.dayPeriod(a, {
1325
+ width: "abbreviated",
1326
+ context: "formatting"
1327
+ });
1328
+ case "aaa":
1329
+ return n.dayPeriod(a, {
1330
+ width: "abbreviated",
1331
+ context: "formatting"
1332
+ }).toLowerCase();
1333
+ case "aaaaa":
1334
+ return n.dayPeriod(a, {
1335
+ width: "narrow",
1336
+ context: "formatting"
1337
+ });
1338
+ case "aaaa":
1339
+ default:
1340
+ return n.dayPeriod(a, {
1341
+ width: "wide",
1342
+ context: "formatting"
1343
+ });
1344
+ }
1345
+ },
1346
+ // AM, PM, midnight, noon
1347
+ b: function(e, t, n) {
1348
+ const r = e.getHours();
1349
+ let a;
1350
+ switch (r === 12 ? a = E.noon : r === 0 ? a = E.midnight : a = r / 12 >= 1 ? "pm" : "am", t) {
1351
+ case "b":
1352
+ case "bb":
1353
+ return n.dayPeriod(a, {
1354
+ width: "abbreviated",
1355
+ context: "formatting"
1356
+ });
1357
+ case "bbb":
1358
+ return n.dayPeriod(a, {
1359
+ width: "abbreviated",
1360
+ context: "formatting"
1361
+ }).toLowerCase();
1362
+ case "bbbbb":
1363
+ return n.dayPeriod(a, {
1364
+ width: "narrow",
1365
+ context: "formatting"
1366
+ });
1367
+ case "bbbb":
1368
+ default:
1369
+ return n.dayPeriod(a, {
1370
+ width: "wide",
1371
+ context: "formatting"
1372
+ });
1373
+ }
1374
+ },
1375
+ // in the morning, in the afternoon, in the evening, at night
1376
+ B: function(e, t, n) {
1377
+ const r = e.getHours();
1378
+ let a;
1379
+ switch (r >= 17 ? a = E.evening : r >= 12 ? a = E.afternoon : r >= 4 ? a = E.morning : a = E.night, t) {
1380
+ case "B":
1381
+ case "BB":
1382
+ case "BBB":
1383
+ return n.dayPeriod(a, {
1384
+ width: "abbreviated",
1385
+ context: "formatting"
1386
+ });
1387
+ case "BBBBB":
1388
+ return n.dayPeriod(a, {
1389
+ width: "narrow",
1390
+ context: "formatting"
1391
+ });
1392
+ case "BBBB":
1393
+ default:
1394
+ return n.dayPeriod(a, {
1395
+ width: "wide",
1396
+ context: "formatting"
1397
+ });
1398
+ }
1399
+ },
1400
+ // Hour [1-12]
1401
+ h: function(e, t, n) {
1402
+ if (t === "ho") {
1403
+ let r = e.getHours() % 12;
1404
+ return r === 0 && (r = 12), n.ordinalNumber(r, { unit: "hour" });
1405
+ }
1406
+ return k.h(e, t);
1407
+ },
1408
+ // Hour [0-23]
1409
+ H: function(e, t, n) {
1410
+ return t === "Ho" ? n.ordinalNumber(e.getHours(), { unit: "hour" }) : k.H(e, t);
1411
+ },
1412
+ // Hour [0-11]
1413
+ K: function(e, t, n) {
1414
+ const r = e.getHours() % 12;
1415
+ return t === "Ko" ? n.ordinalNumber(r, { unit: "hour" }) : y(r, t.length);
1416
+ },
1417
+ // Hour [1-24]
1418
+ k: function(e, t, n) {
1419
+ let r = e.getHours();
1420
+ return r === 0 && (r = 24), t === "ko" ? n.ordinalNumber(r, { unit: "hour" }) : y(r, t.length);
1421
+ },
1422
+ // Minute
1423
+ m: function(e, t, n) {
1424
+ return t === "mo" ? n.ordinalNumber(e.getMinutes(), { unit: "minute" }) : k.m(e, t);
1425
+ },
1426
+ // Second
1427
+ s: function(e, t, n) {
1428
+ return t === "so" ? n.ordinalNumber(e.getSeconds(), { unit: "second" }) : k.s(e, t);
1429
+ },
1430
+ // Fraction of second
1431
+ S: function(e, t) {
1432
+ return k.S(e, t);
1433
+ },
1434
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1435
+ X: function(e, t, n) {
1436
+ const r = e.getTimezoneOffset();
1437
+ if (r === 0)
1438
+ return "Z";
1439
+ switch (t) {
1440
+ case "X":
1441
+ return ft(r);
1442
+ case "XXXX":
1443
+ case "XX":
1444
+ return I(r);
1445
+ case "XXXXX":
1446
+ case "XXX":
1447
+ default:
1448
+ return I(r, ":");
1449
+ }
1450
+ },
1451
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1452
+ x: function(e, t, n) {
1453
+ const r = e.getTimezoneOffset();
1454
+ switch (t) {
1455
+ case "x":
1456
+ return ft(r);
1457
+ case "xxxx":
1458
+ case "xx":
1459
+ return I(r);
1460
+ case "xxxxx":
1461
+ case "xxx":
1462
+ default:
1463
+ return I(r, ":");
1464
+ }
1465
+ },
1466
+ // Timezone (GMT)
1467
+ O: function(e, t, n) {
1468
+ const r = e.getTimezoneOffset();
1469
+ switch (t) {
1470
+ case "O":
1471
+ case "OO":
1472
+ case "OOO":
1473
+ return "GMT" + mt(r, ":");
1474
+ case "OOOO":
1475
+ default:
1476
+ return "GMT" + I(r, ":");
1477
+ }
1478
+ },
1479
+ // Timezone (specific non-location)
1480
+ z: function(e, t, n) {
1481
+ const r = e.getTimezoneOffset();
1482
+ switch (t) {
1483
+ case "z":
1484
+ case "zz":
1485
+ case "zzz":
1486
+ return "GMT" + mt(r, ":");
1487
+ case "zzzz":
1488
+ default:
1489
+ return "GMT" + I(r, ":");
1490
+ }
1491
+ },
1492
+ // Seconds timestamp
1493
+ t: function(e, t, n) {
1494
+ const r = Math.trunc(e.getTime() / 1e3);
1495
+ return y(r, t.length);
1496
+ },
1497
+ // Milliseconds timestamp
1498
+ T: function(e, t, n) {
1499
+ const r = e.getTime();
1500
+ return y(r, t.length);
1501
+ }
1502
+ };
1503
+ function mt(e, t = "") {
1504
+ const n = e > 0 ? "-" : "+", r = Math.abs(e), a = Math.trunc(r / 60), i = r % 60;
1505
+ return i === 0 ? n + String(a) : n + String(a) + t + y(i, 2);
1506
+ }
1507
+ function ft(e, t) {
1508
+ return e % 60 === 0 ? (e > 0 ? "-" : "+") + y(Math.abs(e) / 60, 2) : I(e, t);
1509
+ }
1510
+ function I(e, t = "") {
1511
+ const n = e > 0 ? "-" : "+", r = Math.abs(e), a = y(Math.trunc(r / 60), 2), i = y(r % 60, 2);
1512
+ return n + a + t + i;
1513
+ }
1514
+ const dt = (e, t) => {
1515
+ switch (e) {
1516
+ case "P":
1517
+ return t.date({ width: "short" });
1518
+ case "PP":
1519
+ return t.date({ width: "medium" });
1520
+ case "PPP":
1521
+ return t.date({ width: "long" });
1522
+ case "PPPP":
1523
+ default:
1524
+ return t.date({ width: "full" });
1525
+ }
1526
+ }, an = (e, t) => {
1527
+ switch (e) {
1528
+ case "p":
1529
+ return t.time({ width: "short" });
1530
+ case "pp":
1531
+ return t.time({ width: "medium" });
1532
+ case "ppp":
1533
+ return t.time({ width: "long" });
1534
+ case "pppp":
1535
+ default:
1536
+ return t.time({ width: "full" });
1537
+ }
1538
+ }, la = (e, t) => {
1539
+ const n = e.match(/(P+)(p+)?/) || [], r = n[1], a = n[2];
1540
+ if (!a)
1541
+ return dt(e, t);
1542
+ let i;
1543
+ switch (r) {
1544
+ case "P":
1545
+ i = t.dateTime({ width: "short" });
1546
+ break;
1547
+ case "PP":
1548
+ i = t.dateTime({ width: "medium" });
1549
+ break;
1550
+ case "PPP":
1551
+ i = t.dateTime({ width: "long" });
1552
+ break;
1553
+ case "PPPP":
1554
+ default:
1555
+ i = t.dateTime({ width: "full" });
1556
+ break;
1557
+ }
1558
+ return i.replace("{{date}}", dt(r, t)).replace("{{time}}", an(a, t));
1559
+ }, ma = {
1560
+ p: an,
1561
+ P: la
1562
+ }, fa = /^D+$/, da = /^Y+$/, ha = ["D", "DD", "YY", "YYYY"];
1563
+ function ga(e) {
1564
+ return fa.test(e);
1565
+ }
1566
+ function ya(e) {
1567
+ return da.test(e);
1568
+ }
1569
+ function pa(e, t, n) {
1570
+ const r = wa(e, t, n);
1571
+ if (console.warn(r), ha.includes(e)) throw new RangeError(r);
1572
+ }
1573
+ function wa(e, t, n) {
1574
+ const r = e[0] === "Y" ? "years" : "days of the month";
1575
+ return `Use \`${e.toLowerCase()}\` instead of \`${e}\` (in \`${t}\`) for formatting ${r} to the input \`${n}\`; see: https://github.com/date-fns/date-fns/blob/master/docs/unicodeTokens.md`;
1576
+ }
1577
+ const Ta = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Da = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, ba = /^'([^]*?)'?$/, xa = /''/g, va = /[a-zA-Z]/;
1578
+ function Ke(e, t, n) {
1579
+ var l, f, m, h, d, S, et, tt;
1580
+ const r = L(), a = (n == null ? void 0 : n.locale) ?? r.locale ?? nn, i = (n == null ? void 0 : n.firstWeekContainsDate) ?? ((f = (l = n == null ? void 0 : n.locale) == null ? void 0 : l.options) == null ? void 0 : f.firstWeekContainsDate) ?? r.firstWeekContainsDate ?? ((h = (m = r.locale) == null ? void 0 : m.options) == null ? void 0 : h.firstWeekContainsDate) ?? 1, o = (n == null ? void 0 : n.weekStartsOn) ?? ((S = (d = n == null ? void 0 : n.locale) == null ? void 0 : d.options) == null ? void 0 : S.weekStartsOn) ?? r.weekStartsOn ?? ((tt = (et = r.locale) == null ? void 0 : et.options) == null ? void 0 : tt.weekStartsOn) ?? 0, s = p(e);
1581
+ if (!wr(s))
1582
+ throw new RangeError("Invalid time value");
1583
+ let c = t.match(Da).map((v) => {
1584
+ const x = v[0];
1585
+ if (x === "p" || x === "P") {
1586
+ const Me = ma[x];
1587
+ return Me(v, a.formatLong);
1588
+ }
1589
+ return v;
1590
+ }).join("").match(Ta).map((v) => {
1591
+ if (v === "''")
1592
+ return { isToken: !1, value: "'" };
1593
+ const x = v[0];
1594
+ if (x === "'")
1595
+ return { isToken: !1, value: Sa(v) };
1596
+ if (lt[x])
1597
+ return { isToken: !0, value: v };
1598
+ if (x.match(va))
1599
+ throw new RangeError(
1600
+ "Format string contains an unescaped latin alphabet character `" + x + "`"
1601
+ );
1602
+ return { isToken: !1, value: v };
1603
+ });
1604
+ a.localize.preprocessor && (c = a.localize.preprocessor(s, c));
1605
+ const u = {
1606
+ firstWeekContainsDate: i,
1607
+ weekStartsOn: o,
1608
+ locale: a
1609
+ };
1610
+ return c.map((v) => {
1611
+ if (!v.isToken) return v.value;
1612
+ const x = v.value;
1613
+ (!(n != null && n.useAdditionalWeekYearTokens) && ya(x) || !(n != null && n.useAdditionalDayOfYearTokens) && ga(x)) && pa(x, t, String(e));
1614
+ const Me = lt[x[0]];
1615
+ return Me(s, x, a.localize, u);
1616
+ }).join("");
1617
+ }
1618
+ function Sa(e) {
1619
+ const t = e.match(ba);
1620
+ return t ? t[1].replace(xa, "'") : e;
1621
+ }
1622
+ function Ma(e, t, n) {
1623
+ const r = L(), a = (n == null ? void 0 : n.locale) ?? r.locale ?? nn, i = 2520, o = se(e, t);
1624
+ if (isNaN(o))
1625
+ throw new RangeError("Invalid time value");
1626
+ const s = Object.assign({}, n, {
1627
+ addSuffix: n == null ? void 0 : n.addSuffix,
1628
+ comparison: o
1629
+ });
1630
+ let c, u;
1631
+ o > 0 ? (c = p(t), u = p(e)) : (c = p(e), u = p(t));
1632
+ const l = kr(u, c), f = (ge(u) - ge(c)) / 1e3, m = Math.round((l - f) / 60);
1633
+ let h;
1634
+ if (m < 2)
1635
+ return n != null && n.includeSeconds ? l < 5 ? a.formatDistance("lessThanXSeconds", 5, s) : l < 10 ? a.formatDistance("lessThanXSeconds", 10, s) : l < 20 ? a.formatDistance("lessThanXSeconds", 20, s) : l < 40 ? a.formatDistance("halfAMinute", 0, s) : l < 60 ? a.formatDistance("lessThanXMinutes", 1, s) : a.formatDistance("xMinutes", 1, s) : m === 0 ? a.formatDistance("lessThanXMinutes", 1, s) : a.formatDistance("xMinutes", m, s);
1636
+ if (m < 45)
1637
+ return a.formatDistance("xMinutes", m, s);
1638
+ if (m < 90)
1639
+ return a.formatDistance("aboutXHours", 1, s);
1640
+ if (m < ct) {
1641
+ const d = Math.round(m / 60);
1642
+ return a.formatDistance("aboutXHours", d, s);
1643
+ } else {
1644
+ if (m < i)
1645
+ return a.formatDistance("xDays", 1, s);
1646
+ if (m < re) {
1647
+ const d = Math.round(m / ct);
1648
+ return a.formatDistance("xDays", d, s);
1649
+ } else if (m < re * 2)
1650
+ return h = Math.round(m / re), a.formatDistance("aboutXMonths", h, s);
1651
+ }
1652
+ if (h = Mr(u, c), h < 12) {
1653
+ const d = Math.round(m / re);
1654
+ return a.formatDistance("xMonths", d, s);
1655
+ } else {
1656
+ const d = h % 12, S = Math.trunc(h / 12);
1657
+ return d < 3 ? a.formatDistance("aboutXYears", S, s) : d < 9 ? a.formatDistance("overXYears", S, s) : a.formatDistance("almostXYears", S + 1, s);
1658
+ }
1659
+ }
1660
+ function ka(e, t) {
1661
+ return Ma(e, yr(e), t);
1662
+ }
1663
+ function _a() {
1664
+ return Object.assign({}, L());
1665
+ }
1666
+ function Is(e, t) {
1667
+ const r = Ia(e);
1668
+ let a;
1669
+ if (r.date) {
1670
+ const c = Fa(r.date, 2);
1671
+ a = Ea(c.restDateString, c.year);
1672
+ }
1673
+ if (!a || isNaN(a.getTime()))
1674
+ return /* @__PURE__ */ new Date(NaN);
1675
+ const i = a.getTime();
1676
+ let o = 0, s;
1677
+ if (r.time && (o = Ca(r.time), isNaN(o)))
1678
+ return /* @__PURE__ */ new Date(NaN);
1679
+ if (r.timezone) {
1680
+ if (s = Pa(r.timezone), isNaN(s))
1681
+ return /* @__PURE__ */ new Date(NaN);
1682
+ } else {
1683
+ const c = new Date(i + o), u = /* @__PURE__ */ new Date(0);
1684
+ return u.setFullYear(
1685
+ c.getUTCFullYear(),
1686
+ c.getUTCMonth(),
1687
+ c.getUTCDate()
1688
+ ), u.setHours(
1689
+ c.getUTCHours(),
1690
+ c.getUTCMinutes(),
1691
+ c.getUTCSeconds(),
1692
+ c.getUTCMilliseconds()
1693
+ ), u;
1694
+ }
1695
+ return new Date(i + o + s);
1696
+ }
1697
+ const ae = {
1698
+ dateTimeDelimiter: /[T ]/,
1699
+ timeZoneDelimiter: /[Z ]/i,
1700
+ timezone: /([Z+-].*)$/
1701
+ }, Na = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, $a = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, Oa = /^([+-])(\d{2})(?::?(\d{2}))?$/;
1702
+ function Ia(e) {
1703
+ const t = {}, n = e.split(ae.dateTimeDelimiter);
1704
+ let r;
1705
+ if (n.length > 2)
1706
+ return t;
1707
+ if (/:/.test(n[0]) ? r = n[0] : (t.date = n[0], r = n[1], ae.timeZoneDelimiter.test(t.date) && (t.date = e.split(ae.timeZoneDelimiter)[0], r = e.substr(
1708
+ t.date.length,
1709
+ e.length
1710
+ ))), r) {
1711
+ const a = ae.timezone.exec(r);
1712
+ a ? (t.time = r.replace(a[1], ""), t.timezone = a[1]) : t.time = r;
1713
+ }
1714
+ return t;
1715
+ }
1716
+ function Fa(e, t) {
1717
+ const n = new RegExp(
1718
+ "^(?:(\\d{4}|[+-]\\d{" + (4 + t) + "})|(\\d{2}|[+-]\\d{" + (2 + t) + "})$)"
1719
+ ), r = e.match(n);
1720
+ if (!r) return { year: NaN, restDateString: "" };
1721
+ const a = r[1] ? parseInt(r[1]) : null, i = r[2] ? parseInt(r[2]) : null;
1722
+ return {
1723
+ year: i === null ? a : i * 100,
1724
+ restDateString: e.slice((r[1] || r[2]).length)
1725
+ };
1726
+ }
1727
+ function Ea(e, t) {
1728
+ if (t === null) return /* @__PURE__ */ new Date(NaN);
1729
+ const n = e.match(Na);
1730
+ if (!n) return /* @__PURE__ */ new Date(NaN);
1731
+ const r = !!n[4], a = H(n[1]), i = H(n[2]) - 1, o = H(n[3]), s = H(n[4]), c = H(n[5]) - 1;
1732
+ if (r)
1733
+ return Ra(t, s, c) ? Ya(t, s, c) : /* @__PURE__ */ new Date(NaN);
1734
+ {
1735
+ const u = /* @__PURE__ */ new Date(0);
1736
+ return !Aa(t, i, o) || !Ua(t, a) ? /* @__PURE__ */ new Date(NaN) : (u.setUTCFullYear(t, i, Math.max(a, o)), u);
1737
+ }
1738
+ }
1739
+ function H(e) {
1740
+ return e ? parseInt(e) : 1;
1741
+ }
1742
+ function Ca(e) {
1743
+ const t = e.match($a);
1744
+ if (!t) return NaN;
1745
+ const n = _e(t[1]), r = _e(t[2]), a = _e(t[3]);
1746
+ return La(n, r, a) ? n * en + r * Jt + a * 1e3 : NaN;
1747
+ }
1748
+ function _e(e) {
1749
+ return e && parseFloat(e.replace(",", ".")) || 0;
1750
+ }
1751
+ function Pa(e) {
1752
+ if (e === "Z") return 0;
1753
+ const t = e.match(Oa);
1754
+ if (!t) return 0;
1755
+ const n = t[1] === "+" ? -1 : 1, r = parseInt(t[2]), a = t[3] && parseInt(t[3]) || 0;
1756
+ return Wa(r, a) ? n * (r * en + a * Jt) : NaN;
1757
+ }
1758
+ function Ya(e, t, n) {
1759
+ const r = /* @__PURE__ */ new Date(0);
1760
+ r.setUTCFullYear(e, 0, 4);
1761
+ const a = r.getUTCDay() || 7, i = (t - 1) * 7 + n + 1 - a;
1762
+ return r.setUTCDate(r.getUTCDate() + i), r;
1763
+ }
1764
+ const za = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
1765
+ function on(e) {
1766
+ return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
1767
+ }
1768
+ function Aa(e, t, n) {
1769
+ return t >= 0 && t <= 11 && n >= 1 && n <= (za[t] || (on(e) ? 29 : 28));
1770
+ }
1771
+ function Ua(e, t) {
1772
+ return t >= 1 && t <= (on(e) ? 366 : 365);
1773
+ }
1774
+ function Ra(e, t, n) {
1775
+ return t >= 1 && t <= 53 && n >= 0 && n <= 6;
1776
+ }
1777
+ function La(e, t, n) {
1778
+ return e === 24 ? t === 0 && n === 0 : n >= 0 && n < 60 && t >= 0 && t < 60 && e >= 0 && e < 25;
1779
+ }
1780
+ function Wa(e, t) {
1781
+ return t >= 0 && t <= 59;
1782
+ }
1783
+ function ht(e, t, n) {
1784
+ const r = _a(), a = qa(e, n.timeZone, n.locale ?? r.locale);
1785
+ return "formatToParts" in a ? ja(a, t) : Ha(a, t);
1786
+ }
1787
+ function ja(e, t) {
1788
+ const n = e.formatToParts(t);
1789
+ for (let r = n.length - 1; r >= 0; --r)
1790
+ if (n[r].type === "timeZoneName")
1791
+ return n[r].value;
1792
+ }
1793
+ function Ha(e, t) {
1794
+ const n = e.format(t).replace(/\u200E/g, ""), r = / [\w-+ ]+$/.exec(n);
1795
+ return r ? r[0].substr(1) : "";
1796
+ }
1797
+ function qa(e, t, n) {
1798
+ return new Intl.DateTimeFormat(n ? [n.code, "en-US"] : void 0, {
1799
+ timeZone: t,
1800
+ timeZoneName: e
1801
+ });
1802
+ }
1803
+ function Za(e, t) {
1804
+ const n = Ga(t);
1805
+ return "formatToParts" in n ? Va(n, e) : Ba(n, e);
1806
+ }
1807
+ const Ka = {
1808
+ year: 0,
1809
+ month: 1,
1810
+ day: 2,
1811
+ hour: 3,
1812
+ minute: 4,
1813
+ second: 5
1814
+ };
1815
+ function Va(e, t) {
1816
+ try {
1817
+ const n = e.formatToParts(t), r = [];
1818
+ for (let a = 0; a < n.length; a++) {
1819
+ const i = Ka[n[a].type];
1820
+ i !== void 0 && (r[i] = parseInt(n[a].value, 10));
1821
+ }
1822
+ return r;
1823
+ } catch (n) {
1824
+ if (n instanceof RangeError)
1825
+ return [NaN];
1826
+ throw n;
1827
+ }
1828
+ }
1829
+ function Ba(e, t) {
1830
+ const n = e.format(t), r = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(n);
1831
+ return [
1832
+ parseInt(r[3], 10),
1833
+ parseInt(r[1], 10),
1834
+ parseInt(r[2], 10),
1835
+ parseInt(r[4], 10),
1836
+ parseInt(r[5], 10),
1837
+ parseInt(r[6], 10)
1838
+ ];
1839
+ }
1840
+ const Ne = {}, gt = new Intl.DateTimeFormat("en-US", {
1841
+ hourCycle: "h23",
1842
+ timeZone: "America/New_York",
1843
+ year: "numeric",
1844
+ month: "2-digit",
1845
+ day: "2-digit",
1846
+ hour: "2-digit",
1847
+ minute: "2-digit",
1848
+ second: "2-digit"
1849
+ }).format(/* @__PURE__ */ new Date("2014-06-25T04:00:00.123Z")), Xa = gt === "06/25/2014, 00:00:00" || gt === "‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";
1850
+ function Ga(e) {
1851
+ return Ne[e] || (Ne[e] = Xa ? new Intl.DateTimeFormat("en-US", {
1852
+ hourCycle: "h23",
1853
+ timeZone: e,
1854
+ year: "numeric",
1855
+ month: "numeric",
1856
+ day: "2-digit",
1857
+ hour: "2-digit",
1858
+ minute: "2-digit",
1859
+ second: "2-digit"
1860
+ }) : new Intl.DateTimeFormat("en-US", {
1861
+ hour12: !1,
1862
+ timeZone: e,
1863
+ year: "numeric",
1864
+ month: "numeric",
1865
+ day: "2-digit",
1866
+ hour: "2-digit",
1867
+ minute: "2-digit",
1868
+ second: "2-digit"
1869
+ })), Ne[e];
1870
+ }
1871
+ function Ve(e, t, n, r, a, i, o) {
1872
+ const s = /* @__PURE__ */ new Date(0);
1873
+ return s.setUTCFullYear(e, t, n), s.setUTCHours(r, a, i, o), s;
1874
+ }
1875
+ const yt = 36e5, Qa = 6e4, $e = {
1876
+ timezoneZ: /^(Z)$/,
1877
+ timezoneHH: /^([+-]\d{2})$/,
1878
+ timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
1879
+ };
1880
+ function be(e, t, n) {
1881
+ if (!e)
1882
+ return 0;
1883
+ let r = $e.timezoneZ.exec(e);
1884
+ if (r)
1885
+ return 0;
1886
+ let a, i;
1887
+ if (r = $e.timezoneHH.exec(e), r)
1888
+ return a = parseInt(r[1], 10), pt(a) ? -(a * yt) : NaN;
1889
+ if (r = $e.timezoneHHMM.exec(e), r) {
1890
+ a = parseInt(r[2], 10);
1891
+ const o = parseInt(r[3], 10);
1892
+ return pt(a, o) ? (i = Math.abs(a) * yt + o * Qa, r[1] === "+" ? -i : i) : NaN;
1893
+ }
1894
+ if (ti(e)) {
1895
+ t = new Date(t || Date.now());
1896
+ const o = n ? t : Ja(t), s = Le(o, e);
1897
+ return -(n ? s : ei(t, s, e));
1898
+ }
1899
+ return NaN;
1900
+ }
1901
+ function Ja(e) {
1902
+ return Ve(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds());
1903
+ }
1904
+ function Le(e, t) {
1905
+ const n = Za(e, t), r = Ve(n[0], n[1] - 1, n[2], n[3] % 24, n[4], n[5], 0).getTime();
1906
+ let a = e.getTime();
1907
+ const i = a % 1e3;
1908
+ return a -= i >= 0 ? i : 1e3 + i, r - a;
1909
+ }
1910
+ function ei(e, t, n) {
1911
+ let a = e.getTime() - t;
1912
+ const i = Le(new Date(a), n);
1913
+ if (t === i)
1914
+ return t;
1915
+ a -= i - t;
1916
+ const o = Le(new Date(a), n);
1917
+ return i === o ? i : Math.max(i, o);
1918
+ }
1919
+ function pt(e, t) {
1920
+ return -23 <= e && e <= 23 && (t == null || 0 <= t && t <= 59);
1921
+ }
1922
+ const wt = {};
1923
+ function ti(e) {
1924
+ if (wt[e])
1925
+ return !0;
1926
+ try {
1927
+ return new Intl.DateTimeFormat(void 0, { timeZone: e }), wt[e] = !0, !0;
1928
+ } catch {
1929
+ return !1;
1930
+ }
1931
+ }
1932
+ const ni = 60 * 1e3, ri = {
1933
+ // Timezone (ISO-8601. If offset is 0, output is always `'Z'`)
1934
+ X: function(e, t, n) {
1935
+ const r = Oe(n.timeZone, e);
1936
+ if (r === 0)
1937
+ return "Z";
1938
+ switch (t) {
1939
+ case "X":
1940
+ return Tt(r);
1941
+ case "XXXX":
1942
+ case "XX":
1943
+ return C(r);
1944
+ case "XXXXX":
1945
+ case "XXX":
1946
+ default:
1947
+ return C(r, ":");
1948
+ }
1949
+ },
1950
+ // Timezone (ISO-8601. If offset is 0, output is `'+00:00'` or equivalent)
1951
+ x: function(e, t, n) {
1952
+ const r = Oe(n.timeZone, e);
1953
+ switch (t) {
1954
+ case "x":
1955
+ return Tt(r);
1956
+ case "xxxx":
1957
+ case "xx":
1958
+ return C(r);
1959
+ case "xxxxx":
1960
+ case "xxx":
1961
+ default:
1962
+ return C(r, ":");
1963
+ }
1964
+ },
1965
+ // Timezone (GMT)
1966
+ O: function(e, t, n) {
1967
+ const r = Oe(n.timeZone, e);
1968
+ switch (t) {
1969
+ case "O":
1970
+ case "OO":
1971
+ case "OOO":
1972
+ return "GMT" + ai(r, ":");
1973
+ case "OOOO":
1974
+ default:
1975
+ return "GMT" + C(r, ":");
1976
+ }
1977
+ },
1978
+ // Timezone (specific non-location)
1979
+ z: function(e, t, n) {
1980
+ switch (t) {
1981
+ case "z":
1982
+ case "zz":
1983
+ case "zzz":
1984
+ return ht("short", e, n);
1985
+ case "zzzz":
1986
+ default:
1987
+ return ht("long", e, n);
1988
+ }
1989
+ }
1990
+ };
1991
+ function Oe(e, t) {
1992
+ const n = e ? be(e, t, !0) / ni : (t == null ? void 0 : t.getTimezoneOffset()) ?? 0;
1993
+ if (Number.isNaN(n))
1994
+ throw new RangeError("Invalid time zone specified: " + e);
1995
+ return n;
1996
+ }
1997
+ function ye(e, t) {
1998
+ const n = e < 0 ? "-" : "";
1999
+ let r = Math.abs(e).toString();
2000
+ for (; r.length < t; )
2001
+ r = "0" + r;
2002
+ return n + r;
2003
+ }
2004
+ function C(e, t = "") {
2005
+ const n = e > 0 ? "-" : "+", r = Math.abs(e), a = ye(Math.floor(r / 60), 2), i = ye(Math.floor(r % 60), 2);
2006
+ return n + a + t + i;
2007
+ }
2008
+ function Tt(e, t) {
2009
+ return e % 60 === 0 ? (e > 0 ? "-" : "+") + ye(Math.abs(e) / 60, 2) : C(e, t);
2010
+ }
2011
+ function ai(e, t = "") {
2012
+ const n = e > 0 ? "-" : "+", r = Math.abs(e), a = Math.floor(r / 60), i = r % 60;
2013
+ return i === 0 ? n + String(a) : n + String(a) + t + ye(i, 2);
2014
+ }
2015
+ function Dt(e) {
2016
+ const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()));
2017
+ return t.setUTCFullYear(e.getFullYear()), +e - +t;
2018
+ }
2019
+ const sn = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/, Ie = 36e5, bt = 6e4, ii = 2, b = {
2020
+ dateTimePattern: /^([0-9W+-]+)(T| )(.*)/,
2021
+ datePattern: /^([0-9W+-]+)(.*)/,
2022
+ // year tokens
2023
+ YY: /^(\d{2})$/,
2024
+ YYY: [
2025
+ /^([+-]\d{2})$/,
2026
+ // 0 additional digits
2027
+ /^([+-]\d{3})$/,
2028
+ // 1 additional digit
2029
+ /^([+-]\d{4})$/
2030
+ // 2 additional digits
2031
+ ],
2032
+ YYYY: /^(\d{4})/,
2033
+ YYYYY: [
2034
+ /^([+-]\d{4})/,
2035
+ // 0 additional digits
2036
+ /^([+-]\d{5})/,
2037
+ // 1 additional digit
2038
+ /^([+-]\d{6})/
2039
+ // 2 additional digits
2040
+ ],
2041
+ // date tokens
2042
+ MM: /^-(\d{2})$/,
2043
+ DDD: /^-?(\d{3})$/,
2044
+ MMDD: /^-?(\d{2})-?(\d{2})$/,
2045
+ Www: /^-?W(\d{2})$/,
2046
+ WwwD: /^-?W(\d{2})-?(\d{1})$/,
2047
+ HH: /^(\d{2}([.,]\d*)?)$/,
2048
+ HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/,
2049
+ HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,
2050
+ // time zone tokens (to identify the presence of a tz)
2051
+ timeZone: sn
2052
+ };
2053
+ function pe(e, t = {}) {
2054
+ if (arguments.length < 1)
2055
+ throw new TypeError("1 argument required, but only " + arguments.length + " present");
2056
+ if (e === null)
2057
+ return /* @__PURE__ */ new Date(NaN);
2058
+ const n = t.additionalDigits == null ? ii : Number(t.additionalDigits);
2059
+ if (n !== 2 && n !== 1 && n !== 0)
2060
+ throw new RangeError("additionalDigits must be 0, 1 or 2");
2061
+ if (e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]")
2062
+ return new Date(e.getTime());
2063
+ if (typeof e == "number" || Object.prototype.toString.call(e) === "[object Number]")
2064
+ return new Date(e);
2065
+ if (Object.prototype.toString.call(e) !== "[object String]")
2066
+ return /* @__PURE__ */ new Date(NaN);
2067
+ const r = oi(e), { year: a, restDateString: i } = si(r.date, n), o = ci(i, a);
2068
+ if (o === null || isNaN(o.getTime()))
2069
+ return /* @__PURE__ */ new Date(NaN);
2070
+ if (o) {
2071
+ const s = o.getTime();
2072
+ let c = 0, u;
2073
+ if (r.time && (c = ui(r.time), c === null || isNaN(c)))
2074
+ return /* @__PURE__ */ new Date(NaN);
2075
+ if (r.timeZone || t.timeZone) {
2076
+ if (u = be(r.timeZone || t.timeZone, new Date(s + c)), isNaN(u))
2077
+ return /* @__PURE__ */ new Date(NaN);
2078
+ } else
2079
+ u = Dt(new Date(s + c)), u = Dt(new Date(s + c + u));
2080
+ return new Date(s + c + u);
2081
+ } else
2082
+ return /* @__PURE__ */ new Date(NaN);
2083
+ }
2084
+ function oi(e) {
2085
+ const t = {};
2086
+ let n = b.dateTimePattern.exec(e), r;
2087
+ if (n ? (t.date = n[1], r = n[3]) : (n = b.datePattern.exec(e), n ? (t.date = n[1], r = n[2]) : (t.date = null, r = e)), r) {
2088
+ const a = b.timeZone.exec(r);
2089
+ a ? (t.time = r.replace(a[1], ""), t.timeZone = a[1].trim()) : t.time = r;
2090
+ }
2091
+ return t;
2092
+ }
2093
+ function si(e, t) {
2094
+ if (e) {
2095
+ const n = b.YYY[t], r = b.YYYYY[t];
2096
+ let a = b.YYYY.exec(e) || r.exec(e);
2097
+ if (a) {
2098
+ const i = a[1];
2099
+ return {
2100
+ year: parseInt(i, 10),
2101
+ restDateString: e.slice(i.length)
2102
+ };
2103
+ }
2104
+ if (a = b.YY.exec(e) || n.exec(e), a) {
2105
+ const i = a[1];
2106
+ return {
2107
+ year: parseInt(i, 10) * 100,
2108
+ restDateString: e.slice(i.length)
2109
+ };
2110
+ }
2111
+ }
2112
+ return {
2113
+ year: null
2114
+ };
2115
+ }
2116
+ function ci(e, t) {
2117
+ if (t === null)
2118
+ return null;
2119
+ let n, r, a;
2120
+ if (!e || !e.length)
2121
+ return n = /* @__PURE__ */ new Date(0), n.setUTCFullYear(t), n;
2122
+ let i = b.MM.exec(e);
2123
+ if (i)
2124
+ return n = /* @__PURE__ */ new Date(0), r = parseInt(i[1], 10) - 1, vt(t, r) ? (n.setUTCFullYear(t, r), n) : /* @__PURE__ */ new Date(NaN);
2125
+ if (i = b.DDD.exec(e), i) {
2126
+ n = /* @__PURE__ */ new Date(0);
2127
+ const o = parseInt(i[1], 10);
2128
+ return fi(t, o) ? (n.setUTCFullYear(t, 0, o), n) : /* @__PURE__ */ new Date(NaN);
2129
+ }
2130
+ if (i = b.MMDD.exec(e), i) {
2131
+ n = /* @__PURE__ */ new Date(0), r = parseInt(i[1], 10) - 1;
2132
+ const o = parseInt(i[2], 10);
2133
+ return vt(t, r, o) ? (n.setUTCFullYear(t, r, o), n) : /* @__PURE__ */ new Date(NaN);
2134
+ }
2135
+ if (i = b.Www.exec(e), i)
2136
+ return a = parseInt(i[1], 10) - 1, St(a) ? xt(t, a) : /* @__PURE__ */ new Date(NaN);
2137
+ if (i = b.WwwD.exec(e), i) {
2138
+ a = parseInt(i[1], 10) - 1;
2139
+ const o = parseInt(i[2], 10) - 1;
2140
+ return St(a, o) ? xt(t, a, o) : /* @__PURE__ */ new Date(NaN);
2141
+ }
2142
+ return null;
2143
+ }
2144
+ function ui(e) {
2145
+ let t, n, r = b.HH.exec(e);
2146
+ if (r)
2147
+ return t = parseFloat(r[1].replace(",", ".")), Fe(t) ? t % 24 * Ie : NaN;
2148
+ if (r = b.HHMM.exec(e), r)
2149
+ return t = parseInt(r[1], 10), n = parseFloat(r[2].replace(",", ".")), Fe(t, n) ? t % 24 * Ie + n * bt : NaN;
2150
+ if (r = b.HHMMSS.exec(e), r) {
2151
+ t = parseInt(r[1], 10), n = parseInt(r[2], 10);
2152
+ const a = parseFloat(r[3].replace(",", "."));
2153
+ return Fe(t, n, a) ? t % 24 * Ie + n * bt + a * 1e3 : NaN;
2154
+ }
2155
+ return null;
2156
+ }
2157
+ function xt(e, t, n) {
2158
+ t = t || 0, n = n || 0;
2159
+ const r = /* @__PURE__ */ new Date(0);
2160
+ r.setUTCFullYear(e, 0, 4);
2161
+ const a = r.getUTCDay() || 7, i = t * 7 + n + 1 - a;
2162
+ return r.setUTCDate(r.getUTCDate() + i), r;
2163
+ }
2164
+ const li = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], mi = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
2165
+ function cn(e) {
2166
+ return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
2167
+ }
2168
+ function vt(e, t, n) {
2169
+ if (t < 0 || t > 11)
2170
+ return !1;
2171
+ if (n != null) {
2172
+ if (n < 1)
2173
+ return !1;
2174
+ const r = cn(e);
2175
+ if (r && n > mi[t] || !r && n > li[t])
2176
+ return !1;
2177
+ }
2178
+ return !0;
2179
+ }
2180
+ function fi(e, t) {
2181
+ if (t < 1)
2182
+ return !1;
2183
+ const n = cn(e);
2184
+ return !(n && t > 366 || !n && t > 365);
2185
+ }
2186
+ function St(e, t) {
2187
+ return !(e < 0 || e > 52 || t != null && (t < 0 || t > 6));
2188
+ }
2189
+ function Fe(e, t, n) {
2190
+ return !(e < 0 || e >= 25 || t != null && (t < 0 || t >= 60) || n != null && (n < 0 || n >= 60));
2191
+ }
2192
+ const di = /([xXOz]+)|''|'(''|[^'])+('|$)/g;
2193
+ function hi(e, t, n = {}) {
2194
+ t = String(t);
2195
+ const r = t.match(di);
2196
+ if (r) {
2197
+ const a = pe(n.originalDate || e, n);
2198
+ t = r.reduce(function(i, o) {
2199
+ if (o[0] === "'")
2200
+ return i;
2201
+ const s = i.indexOf(o), c = i[s - 1] === "'", u = i.replace(o, "'" + ri[o[0]](a, o, n) + "'");
2202
+ return c ? u.substring(0, s - 1) + u.substring(s + 1) : u;
2203
+ }, t);
2204
+ }
2205
+ return Ke(e, t, n);
2206
+ }
2207
+ function gi(e, t, n) {
2208
+ e = pe(e, n);
2209
+ const r = be(t, e, !0), a = new Date(e.getTime() - r), i = /* @__PURE__ */ new Date(0);
2210
+ return i.setFullYear(a.getUTCFullYear(), a.getUTCMonth(), a.getUTCDate()), i.setHours(a.getUTCHours(), a.getUTCMinutes(), a.getUTCSeconds(), a.getUTCMilliseconds()), i;
2211
+ }
2212
+ function un(e, t, n, r) {
2213
+ return r = {
2214
+ ...r,
2215
+ timeZone: t,
2216
+ originalDate: e
2217
+ }, hi(gi(e, t, { timeZone: r.timeZone }), n, r);
2218
+ }
2219
+ function J(e, t, n) {
2220
+ if (typeof e == "string" && !e.match(sn))
2221
+ return pe(e, { ...n, timeZone: t });
2222
+ e = pe(e, n);
2223
+ const r = Ve(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()).getTime(), a = be(t, new Date(r));
2224
+ return new Date(r + a);
2225
+ }
2226
+ function Fs(e, t) {
2227
+ return e && e !== "auto" ? e : t;
2228
+ }
2229
+ function Es(e, t = /* @__PURE__ */ new Date()) {
2230
+ try {
2231
+ const n = {
2232
+ timeZone: e,
2233
+ timeZoneName: "short"
2234
+ }, a = new Intl.DateTimeFormat("en-US", n).formatToParts(t).find((i) => i.type === "timeZoneName");
2235
+ return (a == null ? void 0 : a.value) || e;
2236
+ } catch {
2237
+ return e;
2238
+ }
2239
+ }
2240
+ function Cs(e) {
2241
+ try {
2242
+ const t = {
2243
+ timeZone: e,
2244
+ timeZoneName: "long"
2245
+ }, r = new Intl.DateTimeFormat("en-US", t).formatToParts(
2246
+ /* @__PURE__ */ new Date()
2247
+ ).find((a) => a.type === "timeZoneName");
2248
+ return (r == null ? void 0 : r.value) || e;
2249
+ } catch {
2250
+ return e;
2251
+ }
2252
+ }
2253
+ function Be(e, t = "auto") {
2254
+ if (!e)
2255
+ return /* @__PURE__ */ new Date(NaN);
2256
+ const n = e.endsWith("Z"), r = /[+-]\d{2}:?\d{2}$/.test(e), a = /\([A-Z]{3,4}\)$/.test(e);
2257
+ if (t === "auto")
2258
+ return n || r || a ? new Date(e) : /* @__PURE__ */ new Date(e + "Z");
2259
+ if (t === "local") {
2260
+ if (n || r) {
2261
+ const i = e.replace(/Z$/, "").replace(/[+-]\d{2}:?\d{2}$/, "");
2262
+ return new Date(i);
2263
+ }
2264
+ return new Date(e);
2265
+ } else return t === "UTC" ? n ? new Date(e) : r ? new Date(e) : /* @__PURE__ */ new Date(e + "Z") : n || r || a ? new Date(e) : J(e, t);
2266
+ }
2267
+ const yi = "MM/dd/yyyy", pi = (e, t, n, r = "auto") => {
2268
+ if (!e)
2269
+ return "";
2270
+ try {
2271
+ const a = Be(e, r);
2272
+ if (isNaN(a.getTime()))
2273
+ return e;
2274
+ const o = (t && t.trim() ? t : yi).replace(/LLLL/g, "MMMM").replace(/LLL/g, "MMM");
2275
+ return n && n !== "auto" ? un(a, n, o) : Ke(a, o);
2276
+ } catch (a) {
2277
+ return console.error("Date formatting error:", a), e;
2278
+ }
2279
+ };
2280
+ function Ps(e, t, n = "auto") {
2281
+ if (e)
2282
+ try {
2283
+ const r = Be(e, n);
2284
+ if (isNaN(r.getTime())) return;
2285
+ const a = "yyyy M d H m s", i = t && t !== "auto" ? un(r, t, a) : Ke(r, a), [o, s, c, u, l, f] = i.split(" ").map(Number);
2286
+ return { year: o, month: s, day: c, hour: u, minute: l, second: f };
2287
+ } catch {
2288
+ return;
2289
+ }
2290
+ }
2291
+ const wi = (e, t = "auto") => {
2292
+ if (!e)
2293
+ return "";
2294
+ try {
2295
+ const n = Be(e, t);
2296
+ return isNaN(n.getTime()) ? e : ka(n, { addSuffix: !0 });
2297
+ } catch (n) {
2298
+ return console.error("Relative time formatting error:", n), e;
2299
+ }
2300
+ };
2301
+ function Ti(e, t, n, r) {
2302
+ const a = e instanceof Date ? e.toISOString() : String(e), i = (r == null ? void 0 : r.browserTimezone) || n, o = (r == null ? void 0 : r.isSqlCard) ?? !1;
2303
+ if (t != null && t.useRelativeTime)
2304
+ return wi(
2305
+ a,
2306
+ (t == null ? void 0 : t.sourceTimezone) || "auto"
2307
+ );
2308
+ const s = t != null && t.useCustomFormat && (t != null && t.customFormat) ? t.customFormat : (t == null ? void 0 : t.format) || "MM/dd/yyyy";
2309
+ return pi(
2310
+ a,
2311
+ s,
2312
+ t != null && t.timezone && (t == null ? void 0 : t.timezone) !== "auto" ? t.timezone : o ? i : n,
2313
+ (t == null ? void 0 : t.sourceTimezone) || "auto"
2314
+ );
2315
+ }
2316
+ function ln(e, t, n) {
2317
+ var o, s;
2318
+ if (e == null)
2319
+ return e === null ? ((o = n.absence) == null ? void 0 : o.nullText) ?? "" : ((s = n.absence) == null ? void 0 : s.emptyText) ?? "";
2320
+ const r = Un(e) ? e : void 0, a = r ? r.value : e, i = r ?? (typeof e == "number" ? e : void 0);
2321
+ if (!n.useFormattedValues || !t)
2322
+ return String(a);
2323
+ switch (t.type) {
2324
+ case "number":
2325
+ return i !== void 0 ? mr(
2326
+ i,
2327
+ t.numberFormat,
2328
+ n.locale
2329
+ ) : String(a);
2330
+ case "date":
2331
+ return Ti(
2332
+ a,
2333
+ t.dateFormat,
2334
+ n.timezone,
2335
+ {
2336
+ browserTimezone: n.browserTimezone,
2337
+ isSqlCard: n.isSqlCard
2338
+ }
2339
+ );
2340
+ case "progress":
2341
+ return i !== void 0 ? `${a}%` : String(a);
2342
+ case "badge":
2343
+ case "link":
2344
+ case "text":
2345
+ case "none":
2346
+ default:
2347
+ return String(a);
2348
+ }
2349
+ }
2350
+ function Ys(e, t) {
2351
+ return t.visibleColumns.map((n) => {
2352
+ const r = e[n], a = t.columnSettings[n];
2353
+ return ln(r, a, {
2354
+ useFormattedValues: t.useFormattedValues,
2355
+ timezone: t.timezone,
2356
+ locale: t.locale
2357
+ });
2358
+ });
2359
+ }
2360
+ const Di = 5 * 1024 * 1024, zs = 64 * 1024 * 1024, we = w.number().int().positive().max(Number.MAX_SAFE_INTEGER), ce = w.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER), Te = ce.refine((e) => e > 0), bi = (e) => !!e && e !== "." && e !== ".." && !e.includes("/") && !e.includes("\\");
2361
+ function P(e, t) {
2362
+ const n = t.split("/");
2363
+ if (n.length !== 5 || n[0] !== "exports" || n[1] !== e || n[2] !== "attempts" || !n.every(bi))
2364
+ throw new Error("Invalid Matrix export artifact namespace.");
2365
+ return { attemptId: n[3], filename: n[4] };
2366
+ }
2367
+ function As(e, t, n) {
2368
+ const r = `exports/${e}/attempts/${t}/${n}`;
2369
+ return P(e, r), r;
2370
+ }
2371
+ const Us = w.object({
2372
+ acquisition: w.literal("continuation"),
2373
+ jobId: w.string().min(1),
2374
+ sequence: Te,
2375
+ deadlineAt: we
2376
+ }), xi = [
2377
+ "application/json",
2378
+ ...Rt.map((e) => Lt(e).partContentType)
2379
+ ], vi = w.object({
2380
+ key: w.string(),
2381
+ content: w.string(),
2382
+ contentType: w.enum(xi),
2383
+ encoding: w.literal("gzip-base64").optional()
2384
+ // Transport-only compression: JSON (layout, sheet layout) and Excel rows. CSV travels as it always has.
2385
+ }).refine((e) => !e.encoding || e.contentType === "application/json" || e.contentType === Lt("xlsx").partContentType, "Unsupported Matrix artifact encoding."), Si = w.discriminatedUnion("kind", [
2386
+ w.object({ kind: w.literal("work"), sequence: Te, checkpointKey: w.string(), objects: w.array(vi).min(2).max(4), deadlineAt: we }),
2387
+ w.object({ kind: w.literal("committed"), sequence: Te, done: w.boolean(), deadlineAt: we })
2388
+ ]);
2389
+ function Mi(e) {
2390
+ const t = JSON.stringify(e);
2391
+ if (t === void 0 || new TextEncoder().encode(t).byteLength > Di)
2392
+ throw new RangeError("Matrix export batch exceeds its transport byte limit.");
2393
+ }
2394
+ function Rs(e, t) {
2395
+ const n = Si.parse(e);
2396
+ if (Mi(e), n.deadlineAt !== t.deadlineAt) throw new Error("Matrix deadline does not match the job.");
2397
+ if (n.sequence !== t.sequence + (n.kind === "committed" ? 1 : 0))
2398
+ throw new Error("Invalid Matrix batch sequence.");
2399
+ if (n.kind === "work") {
2400
+ P(t.jobId, n.checkpointKey);
2401
+ for (const r of n.objects)
2402
+ P(t.jobId, r.key);
2403
+ }
2404
+ return n;
2405
+ }
2406
+ const ki = w.object({
2407
+ acquisition: w.literal("continuation"),
2408
+ deadlineAt: we,
2409
+ chunks: w.array(w.object({ chunkNumber: Te, dataKey: w.string() })).min(1),
2410
+ totalRows: ce,
2411
+ totalBytes: ce,
2412
+ fileKey: w.string().min(1).optional(),
2413
+ fileSize: ce.optional(),
2414
+ /** The file the job writes; absent means CSV (manifests from before Excel). */
2415
+ format: w.enum(Rt).optional(),
2416
+ /** Excel only: the sheet layout the layout batch stored, which compaction wraps the rows in. */
2417
+ sheetKey: w.string().min(1).optional()
2418
+ }).refine((e) => e.fileKey === void 0 == (e.fileSize === void 0), "Incomplete published Matrix artifact.").refine((e) => e.format === "xlsx" == (e.sheetKey !== void 0), "An Excel Matrix manifest names its sheet layout, and only it does.");
2419
+ function Ls(e, t, n) {
2420
+ const r = ki.parse(e);
2421
+ if (r.deadlineAt !== n) throw new Error("Matrix deadline does not match the job.");
2422
+ return r.chunks.forEach((a, i) => {
2423
+ if (a.chunkNumber !== i + 1) throw new Error("Invalid committed Matrix chunk order.");
2424
+ P(t, a.dataKey);
2425
+ }), r.fileKey !== void 0 && P(t, r.fileKey), r.sheetKey !== void 0 && P(t, r.sheetKey), r;
2426
+ }
2427
+ const _i = "en-US", Mt = [
2428
+ "compact",
2429
+ "maximumFractionDigits",
2430
+ "minimumFractionDigits",
2431
+ "negativeStyle",
2432
+ "type",
2433
+ "useGrouping"
2434
+ ];
2435
+ function Ni(e) {
2436
+ if (e.type !== "currency" || Object.prototype.hasOwnProperty.call(e, "currency") || Object.prototype.hasOwnProperty.call(e, "locale"))
2437
+ return !1;
2438
+ const t = Object.keys(e).sort();
2439
+ return t.length === Mt.length && Mt.every(
2440
+ (n, r) => t[r] === n
2441
+ ) && typeof e.minimumFractionDigits == "number" && typeof e.maximumFractionDigits == "number" && e.useGrouping === !0 && e.negativeStyle === "minus" && typeof e.compact == "boolean";
2442
+ }
2443
+ function kt(e) {
2444
+ if (typeof e != "string")
2445
+ return;
2446
+ const t = e.trim();
2447
+ if (!(!t || t.toLowerCase() === "none"))
2448
+ return t;
2449
+ }
2450
+ function ue(e) {
2451
+ if (!(typeof e != "number" || !Number.isFinite(e)))
2452
+ return Math.max(0, Math.min(10, Math.trunc(e)));
2453
+ }
2454
+ function $i(e) {
2455
+ return e === "currency" ? 2 : e === "percent" ? 1 : e === "scientific" ? 2 : 0;
2456
+ }
2457
+ function Oi(e, t, n) {
2458
+ const r = ue(t.minimumFractionDigits), a = ue(t.maximumFractionDigits);
2459
+ if (typeof r == "number" || typeof a == "number") {
2460
+ const s = r ?? 0, c = a ?? Math.max(s, 2);
2461
+ return {
2462
+ minimumFractionDigits: Math.min(s, c),
2463
+ maximumFractionDigits: Math.max(s, c)
2464
+ };
2465
+ }
2466
+ const i = ue(t.decimals);
2467
+ if (typeof i == "number")
2468
+ return {
2469
+ minimumFractionDigits: i,
2470
+ maximumFractionDigits: i
2471
+ };
2472
+ if (n != null && n.preserveOmittedProperties)
2473
+ return {};
2474
+ const o = $i(e);
2475
+ return {
2476
+ minimumFractionDigits: o,
2477
+ maximumFractionDigits: o
2478
+ };
2479
+ }
2480
+ function Ii(e, t) {
2481
+ if (!(typeof t != "string" || e === "percent" && t === "%"))
2482
+ return t;
2483
+ }
2484
+ function _t(e) {
2485
+ const t = kt(e.locale), n = kt(e.currency), r = Ii(e.type, e.suffix);
2486
+ return {
2487
+ ...e,
2488
+ ...t !== e.locale ? { locale: t } : {},
2489
+ ...n !== e.currency ? { currency: n } : {},
2490
+ ...r !== e.suffix ? { suffix: r } : {}
2491
+ };
2492
+ }
2493
+ function O(e, t, n) {
2494
+ const r = { ...t, type: e };
2495
+ if ((n == null ? void 0 : n.numericInput) === "canonical" && G(r))
2496
+ return _t(r);
2497
+ const a = Oi(e, t, n), i = typeof t.prefix == "string" ? t.prefix : void 0, o = {
2498
+ type: e,
2499
+ locale: t.locale,
2500
+ minimumFractionDigits: a.minimumFractionDigits,
2501
+ maximumFractionDigits: a.maximumFractionDigits,
2502
+ useGrouping: typeof t.useGrouping == "boolean" ? t.useGrouping : typeof t.thousandsSeparator == "boolean" ? t.thousandsSeparator : !0,
2503
+ prefix: i,
2504
+ suffix: t.suffix,
2505
+ negativeStyle: t.negativeStyle || "minus",
2506
+ compact: !!t.compact,
2507
+ scale: typeof t.scale == "number" ? t.scale : void 0,
2508
+ ...t.signDisplay ? { signDisplay: t.signDisplay } : {}
2509
+ };
2510
+ return e === "currency" && t.currency && (o.currency = t.currency), e === "percent" && (o.percentValueMode = t.percentValueMode || "fraction"), _t(o);
2511
+ }
2512
+ function Nt(e) {
2513
+ return {
2514
+ type: "date",
2515
+ locale: e.locale || _i,
2516
+ pattern: e.pattern,
2517
+ // A stored pattern's token set and a preset carry to every reader (column formats ledger P5-45).
2518
+ ...e.dialect ? { dialect: e.dialect } : {},
2519
+ ...e.preset ? { preset: e.preset } : {},
2520
+ relative: !!e.relative,
2521
+ timezone: e.timezone,
2522
+ sourceTimezone: e.sourceTimezone,
2523
+ prefix: e.prefix,
2524
+ suffix: e.suffix
2525
+ };
2526
+ }
2527
+ function Ee(e) {
2528
+ return e === "millisecond" || e === "second" || e === "minute" || e === "hour" || e === "day";
2529
+ }
2530
+ function $t(e) {
2531
+ const t = ue(e.maxUnits);
2532
+ return {
2533
+ type: "duration",
2534
+ inputUnit: Ee(e.inputUnit) ? e.inputUnit : "second",
2535
+ outputStyle: e.outputStyle === "digital" || e.outputStyle === "long" ? e.outputStyle : "compact",
2536
+ largestUnit: Ee(e.largestUnit) ? e.largestUnit : void 0,
2537
+ smallestUnit: Ee(e.smallestUnit) ? e.smallestUnit : "second",
2538
+ maxUnits: t,
2539
+ prefix: e.prefix,
2540
+ suffix: e.suffix,
2541
+ negativeStyle: e.negativeStyle || "minus"
2542
+ };
2543
+ }
2544
+ function Ot(e) {
2545
+ return {
2546
+ type: "string",
2547
+ prefix: e.prefix,
2548
+ suffix: e.suffix
2549
+ };
2550
+ }
2551
+ function Fi(e, t) {
2552
+ if (!e)
2553
+ return;
2554
+ if (typeof e == "string") {
2555
+ const r = e.trim().toLowerCase();
2556
+ return r === "currency" ? O(
2557
+ "currency",
2558
+ { type: "currency" },
2559
+ t
2560
+ ) : r === "percentage" || r === "percent" ? O(
2561
+ "percent",
2562
+ {
2563
+ type: "percentage",
2564
+ percentValueMode: "fraction"
2565
+ },
2566
+ t
2567
+ ) : r === "scientific" ? O(
2568
+ "scientific",
2569
+ { type: "scientific" },
2570
+ t
2571
+ ) : r === "date" ? Nt({}) : r === "duration" ? $t({}) : r === "string" ? Ot({}) : r === "number" ? O(
2572
+ "number",
2573
+ { type: "number" },
2574
+ t
2575
+ ) : void 0;
2576
+ }
2577
+ if ("type" in e && e.type === "temporal_bucket") {
2578
+ const r = Zn.safeParse(e);
2579
+ return r.success ? r.data : void 0;
2580
+ }
2581
+ const n = e;
2582
+ if ((t == null ? void 0 : t.numericInput) === "canonical") {
2583
+ const r = n.type === "percentage" ? { ...n, type: "percent" } : n;
2584
+ if (G(r))
2585
+ return O(r.type, r, t);
2586
+ }
2587
+ if (n.type === "percentage")
2588
+ return O(
2589
+ "percent",
2590
+ {
2591
+ ...n,
2592
+ percentValueMode: n.percentValueMode || "fraction"
2593
+ },
2594
+ t
2595
+ );
2596
+ if (n.type === "number" || n.type === "currency" || n.type === "percent" || n.type === "scientific") {
2597
+ const r = O(
2598
+ n.type,
2599
+ n,
2600
+ t
2601
+ );
2602
+ return Ni(n) ? { ...r, currency: "USD" } : r;
2603
+ }
2604
+ if (n.type === "date")
2605
+ return Nt(n);
2606
+ if (n.type === "duration")
2607
+ return $t(n);
2608
+ if (n.type === "string")
2609
+ return Ot(n);
2610
+ }
2611
+ const Ei = Object.freeze({ source: "automatic" });
2612
+ function Ci(e, t) {
2613
+ var r, a;
2614
+ const n = e.preferences;
2615
+ switch (t) {
2616
+ case "tooltip":
2617
+ return (r = n == null ? void 0 : n.tooltipConfig) == null ? void 0 : r.valueFormat;
2618
+ case "dataLabel":
2619
+ case "pieLabel":
2620
+ return (a = n == null ? void 0 : n.dataLabelsConfig) == null ? void 0 : a.valueFormat;
2621
+ default:
2622
+ return;
2623
+ }
2624
+ }
2625
+ function It(e, t) {
2626
+ const n = e.config;
2627
+ if (n)
2628
+ return [
2629
+ ...n.metricColumns ?? [],
2630
+ ...n.groupByColumns ?? [],
2631
+ ...n.detailColumns ?? [],
2632
+ ...n.pivotByColumns ?? []
2633
+ ].find((r) => r.id === t);
2634
+ }
2635
+ function Pi(e, t) {
2636
+ if (t.kind === "field") return It(e, t.fieldId);
2637
+ if (t.kind === "pivot") return It(e, t.metricId);
2638
+ }
2639
+ function Yi(e, t, n) {
2640
+ var r, a, i, o, s, c, u, l, f;
2641
+ switch (t.kind) {
2642
+ case "field":
2643
+ case "pivot":
2644
+ return n != null && n.format && n.formatOrigin === "override" ? n.format : void 0;
2645
+ case "result":
2646
+ return (i = (a = (r = e.preferences) == null ? void 0 : r.sqlColumns) == null ? void 0 : a[t.key]) == null ? void 0 : i.format;
2647
+ case "sqlKpiValue":
2648
+ return (s = (o = e.preferences) == null ? void 0 : o.sqlKpiValue) == null ? void 0 : s.format;
2649
+ case "matrixMeasure":
2650
+ return (u = (c = e.config) == null ? void 0 : c.matrix) == null ? void 0 : u.presentation.measureFormats[t.measureId];
2651
+ case "matrixLevel":
2652
+ return (f = (l = e.config) == null ? void 0 : l.matrix) == null ? void 0 : f.presentation.levelFormats[t.levelId];
2653
+ }
2654
+ }
2655
+ function zi(e) {
2656
+ if (!e) return;
2657
+ if (e.format && e.formatOrigin !== "override") return e.format;
2658
+ const t = e.semanticTemporalPresentation;
2659
+ return t && t.granularity === e.granularity ? t.format : void 0;
2660
+ }
2661
+ function Xe(e) {
2662
+ return e.surface ? { format: e.surface, source: "surface" } : e.override ? { format: e.override, source: "override" } : e.model ? { format: e.model, source: "model" } : e.snapshot ? { format: e.snapshot, source: "snapshot" } : Ei;
2663
+ }
2664
+ function Ai(e) {
2665
+ var o;
2666
+ const { card: t, column: n, surface: r } = e, a = Pi(t, n), i = n.kind === "field" ? n.fieldId : n.kind === "pivot" ? n.metricId : void 0;
2667
+ return Xe({
2668
+ surface: r ? Ci(t, r) : void 0,
2669
+ override: Yi(t, n, a),
2670
+ model: (i !== void 0 ? (o = e.modelFormats) == null ? void 0 : o[i] : void 0) ?? e.catalogFormat,
2671
+ snapshot: zi(a)
2672
+ });
2673
+ }
2674
+ function Ui(e, t) {
2675
+ const n = (r) => r && typeof r == "object" && !Array.isArray(r) ? Object.fromEntries(
2676
+ Object.keys(r).sort().map((a) => [a, n(r[a])])
2677
+ ) : r;
2678
+ return JSON.stringify(n(e)) === JSON.stringify(n(t));
2679
+ }
2680
+ const Ri = ["metricColumns", "groupByColumns", "detailColumns", "pivotByColumns"], Ft = /* @__PURE__ */ new WeakMap();
2681
+ function Ws(e, t) {
2682
+ const n = t == null ? void 0 : t.modelFormats;
2683
+ if (!e || !n || Object.keys(n).length === 0) return e;
2684
+ let r = Ft.get(e);
2685
+ if (r || Ft.set(e, r = /* @__PURE__ */ new WeakMap()), r.has(n)) return r.get(n);
2686
+ const a = Li(e, n);
2687
+ return r.set(n, a), a;
2688
+ }
2689
+ function Li(e, t) {
2690
+ const n = { config: e };
2691
+ let r;
2692
+ for (const a of Ri) {
2693
+ const i = e[a];
2694
+ if (!(i != null && i.length)) continue;
2695
+ let o = !1;
2696
+ const s = i.map((c) => {
2697
+ const u = Ai({ card: n, column: { kind: "field", fieldId: c.id }, modelFormats: t });
2698
+ return u.source !== "model" || Ui(u.format, c.format) ? c : (o = !0, { ...c, format: u.format });
2699
+ });
2700
+ o && ((r ?? (r = { ...e }))[a] = s);
2701
+ }
2702
+ return r ?? e;
2703
+ }
2704
+ function T(e) {
2705
+ if (e === null || typeof e != "object" || Array.isArray(e))
2706
+ return !1;
2707
+ const t = Object.getPrototypeOf(e);
2708
+ if (t === null || t === Object.prototype) return !0;
2709
+ const n = Object.prototype.hasOwnProperty.call(
2710
+ t,
2711
+ "constructor"
2712
+ ) ? t.constructor : void 0;
2713
+ return typeof n == "function" && Function.prototype.toString.call(n) === Function.prototype.toString.call(Object);
2714
+ }
2715
+ const Wi = [
2716
+ "type",
2717
+ "locale",
2718
+ "minimumFractionDigits",
2719
+ "maximumFractionDigits",
2720
+ "useGrouping",
2721
+ "prefix",
2722
+ "suffix",
2723
+ "negativeStyle",
2724
+ "compact",
2725
+ "scale",
2726
+ "currency",
2727
+ "percentValueMode",
2728
+ "signDisplay"
2729
+ ];
2730
+ function ji(e) {
2731
+ if (!T(e))
2732
+ return {
2733
+ ok: !1,
2734
+ issues: [{ path: "$", message: "Numeric format must be an object." }]
2735
+ };
2736
+ const t = [], n = new Set(Wi);
2737
+ Object.keys(e).filter((i) => !n.has(i)).forEach(
2738
+ (i) => t.push({ path: i, message: `Unknown property "${i}".` })
2739
+ ), e.type !== "number" && e.type !== "currency" && e.type !== "percent" && e.type !== "scientific" && t.push({
2740
+ path: "type",
2741
+ message: "Expected number, currency, percent, or scientific."
2742
+ });
2743
+ const r = e.locale === void 0 ? void 0 : X(e.locale);
2744
+ e.locale !== void 0 && !r && t.push({ path: "locale", message: "Expected a supported BCP 47 locale." });
2745
+ const a = e.currency === void 0 ? void 0 : Ae(e.currency);
2746
+ e.currency !== void 0 && !a && t.push({
2747
+ path: "currency",
2748
+ message: "Expected a supported ISO 4217 currency code."
2749
+ });
2750
+ for (const i of ["minimumFractionDigits", "maximumFractionDigits"]) {
2751
+ const o = e[i];
2752
+ o !== void 0 && (!Number.isInteger(o) || typeof o != "number" || o < 0 || o > 20) && t.push({
2753
+ path: i,
2754
+ message: "Expected an integer from 0 to 20."
2755
+ });
2756
+ }
2757
+ typeof e.minimumFractionDigits == "number" && typeof e.maximumFractionDigits == "number" && e.minimumFractionDigits > e.maximumFractionDigits && t.push({
2758
+ path: "maximumFractionDigits",
2759
+ message: "Must be greater than or equal to minimumFractionDigits."
2760
+ });
2761
+ for (const i of ["useGrouping", "compact"])
2762
+ e[i] !== void 0 && typeof e[i] != "boolean" && t.push({ path: i, message: "Expected a boolean." });
2763
+ for (const i of ["prefix", "suffix"])
2764
+ e[i] !== void 0 && typeof e[i] != "string" && t.push({ path: i, message: "Expected a string." });
2765
+ return e.negativeStyle !== void 0 && e.negativeStyle !== "minus" && e.negativeStyle !== "parentheses" && t.push({
2766
+ path: "negativeStyle",
2767
+ message: "Expected minus or parentheses."
2768
+ }), e.percentValueMode !== void 0 && e.percentValueMode !== "fraction" && e.percentValueMode !== "whole" && t.push({
2769
+ path: "percentValueMode",
2770
+ message: "Expected fraction or whole."
2771
+ }), e.scale !== void 0 && (typeof e.scale != "number" || !Number.isFinite(e.scale)) && t.push({ path: "scale", message: "Expected a finite number." }), e.signDisplay !== void 0 && e.signDisplay !== "auto" && e.signDisplay !== "always" && e.signDisplay !== "exceptZero" && e.signDisplay !== "never" && t.push({
2772
+ path: "signDisplay",
2773
+ message: "Expected auto, always, exceptZero, or never."
2774
+ }), t.length > 0 ? { ok: !1, issues: t } : {
2775
+ ok: !0,
2776
+ value: {
2777
+ type: e.type,
2778
+ ...r ? { locale: r } : {},
2779
+ ...e.minimumFractionDigits !== void 0 ? { minimumFractionDigits: e.minimumFractionDigits } : {},
2780
+ ...e.maximumFractionDigits !== void 0 ? { maximumFractionDigits: e.maximumFractionDigits } : {},
2781
+ ...e.useGrouping !== void 0 ? { useGrouping: e.useGrouping } : {},
2782
+ ...e.prefix !== void 0 ? { prefix: e.prefix } : {},
2783
+ ...e.suffix !== void 0 ? { suffix: e.suffix } : {},
2784
+ ...e.negativeStyle !== void 0 ? {
2785
+ negativeStyle: e.negativeStyle
2786
+ } : {},
2787
+ ...e.compact !== void 0 ? { compact: e.compact } : {},
2788
+ ...e.scale !== void 0 ? { scale: e.scale } : {},
2789
+ ...a ? { currency: a } : {},
2790
+ ...e.percentValueMode !== void 0 ? {
2791
+ percentValueMode: e.percentValueMode
2792
+ } : {},
2793
+ ...e.signDisplay !== void 0 ? {
2794
+ signDisplay: e.signDisplay
2795
+ } : {}
2796
+ }
2797
+ };
2798
+ }
2799
+ function Hi(e) {
2800
+ const t = ji(e);
2801
+ if (!t.ok)
2802
+ return t;
2803
+ const n = [];
2804
+ return t.value.locale || n.push({
2805
+ path: "locale",
2806
+ message: "Resolved numeric formats require an explicit locale."
2807
+ }), t.value.minimumFractionDigits === void 0 && n.push({
2808
+ path: "minimumFractionDigits",
2809
+ message: "Resolved numeric formats require minimumFractionDigits."
2810
+ }), t.value.maximumFractionDigits === void 0 && n.push({
2811
+ path: "maximumFractionDigits",
2812
+ message: "Resolved numeric formats require maximumFractionDigits."
2813
+ }), t.value.type === "currency" && !t.value.currency && n.push({
2814
+ path: "currency",
2815
+ message: "Resolved currency formats require an explicit currency."
2816
+ }), n.length > 0 ? { ok: !1, issues: n } : t;
2817
+ }
2818
+ function js(e) {
2819
+ var r;
2820
+ const t = /* @__PURE__ */ new Set();
2821
+ if (e.snapshot.resolvedFormats.forEach((a, i) => {
2822
+ if (a.format.type !== "temporal_bucket") {
2823
+ if (a.scope.attachmentIndex !== void 0)
2824
+ throw new Error(
2825
+ `resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`
2826
+ );
2827
+ if (a.scope.dashboardId !== e.expectedScope.dashboardId || a.scope.cardId !== e.expectedScope.cardId)
2828
+ throw new Error(
2829
+ `resolvedFormats.${i}.scope must match the executing dashboard/card`
2830
+ );
2831
+ if (a.target.kind !== "column")
2832
+ throw new Error(
2833
+ `resolvedFormats.${i}.target must identify an export column`
2834
+ );
2835
+ if (t.has(a.target.columnKey))
2836
+ throw new Error(
2837
+ `resolvedFormats.${i} duplicates export column "${a.target.columnKey}"`
2838
+ );
2839
+ t.add(a.target.columnKey);
2840
+ }
2841
+ }), !e.useFormattedValues)
2842
+ return;
2843
+ if (!((r = e.visibleColumns) != null && r.length))
2844
+ throw new Error(
2845
+ "visibleColumns must identify every formatted export column"
2846
+ );
2847
+ const n = e.visibleColumns.find(
2848
+ (a) => !t.has(a)
2849
+ );
2850
+ if (n)
2851
+ throw new Error(
2852
+ `resolvedFormats is missing visible export column "${n}"`
2853
+ );
2854
+ }
2855
+ function qi(e, t) {
2856
+ const n = new Intl.NumberFormat(e, {
2857
+ style: "currency",
2858
+ currency: t
2859
+ }).resolvedOptions();
2860
+ return {
2861
+ minimumFractionDigits: n.minimumFractionDigits,
2862
+ maximumFractionDigits: n.maximumFractionDigits
2863
+ };
2864
+ }
2865
+ function Zi(e) {
2866
+ if (e.minimumFractionDigits !== void 0 || e.maximumFractionDigits !== void 0) {
2867
+ const n = e.minimumFractionDigits ?? 0;
2868
+ return {
2869
+ minimumFractionDigits: n,
2870
+ maximumFractionDigits: e.maximumFractionDigits ?? Math.max(n, 2)
2871
+ };
2872
+ }
2873
+ const t = e.type === "percent" ? 1 : e.type === "scientific" ? 2 : 0;
2874
+ return {
2875
+ minimumFractionDigits: t,
2876
+ maximumFractionDigits: t
2877
+ };
2878
+ }
2879
+ function Ki(e, t, n) {
2880
+ const r = X(e.locale) ?? t.locale, a = e.type === "number" || e.type === "currency" ? Ae(n) : void 0;
2881
+ if (!(e.type === "currency" || a !== void 0))
2882
+ return {
2883
+ ...e,
2884
+ locale: r,
2885
+ ...Zi(e)
2886
+ };
2887
+ const o = a ?? Ae(e.currency) ?? t.defaultCurrency, s = qi(
2888
+ r,
2889
+ o
2890
+ ), c = s.minimumFractionDigits ?? 0, u = s.maximumFractionDigits ?? c, l = e.minimumFractionDigits ?? Math.min(
2891
+ c,
2892
+ e.maximumFractionDigits ?? c
2893
+ ), f = e.maximumFractionDigits ?? Math.max(
2894
+ l,
2895
+ u
2896
+ );
2897
+ return {
2898
+ ...e,
2899
+ type: "currency",
2900
+ locale: r,
2901
+ currency: o,
2902
+ minimumFractionDigits: l,
2903
+ maximumFractionDigits: f
2904
+ };
2905
+ }
2906
+ const Vi = [
2907
+ "YYYY",
2908
+ "MMMM",
2909
+ "MMM",
2910
+ "YY",
2911
+ "MM",
2912
+ "DD",
2913
+ "HH",
2914
+ "mm",
2915
+ "ss"
2916
+ ], Bi = /* @__PURE__ */ new Set([" ", "-", "/", ":", ".", ",", "T"]), ie = [
2917
+ "day",
2918
+ "week",
2919
+ "month",
2920
+ "quarter",
2921
+ "year"
2922
+ ], mn = {
2923
+ week_of_short: ["week"],
2924
+ week_of_long: ["week"],
2925
+ quarter_short: ["quarter"],
2926
+ quarter_long: ["quarter"],
2927
+ fiscal_quarter_short: ["quarter"],
2928
+ fiscal_year: ["year"],
2929
+ short: ie,
2930
+ long: ie,
2931
+ numeric: ie,
2932
+ iso: ie
2933
+ };
2934
+ function Xi(e) {
2935
+ return typeof e == "string" && Object.prototype.hasOwnProperty.call(mn, e);
2936
+ }
2937
+ function Gi(e, t) {
2938
+ return Vi.find(
2939
+ (n) => e.startsWith(n, t)
2940
+ );
2941
+ }
2942
+ function ee(e) {
2943
+ var a;
2944
+ if (!e || e.trim() !== e)
2945
+ return {
2946
+ ok: !1,
2947
+ code: "invalid_temporal_bucket_pattern",
2948
+ message: "Temporal bucket patterns must be non-empty and trimmed."
2949
+ };
2950
+ const t = [];
2951
+ let n = 0, r = !1;
2952
+ for (; n < e.length; ) {
2953
+ const i = Gi(e, n);
2954
+ if (i) {
2955
+ if (r)
2956
+ return {
2957
+ ok: !1,
2958
+ code: "invalid_temporal_bucket_pattern",
2959
+ message: "Adjacent temporal bucket tokens require a separator."
2960
+ };
2961
+ t.push({ kind: "token", value: i }), n += i.length, r = !0;
2962
+ continue;
2963
+ }
2964
+ const o = e[n];
2965
+ if (!Bi.has(o))
2966
+ return {
2967
+ ok: !1,
2968
+ code: "invalid_temporal_bucket_pattern",
2969
+ message: `Unsupported temporal bucket pattern character "${o}".`
2970
+ };
2971
+ if (t.length === 0)
2972
+ return {
2973
+ ok: !1,
2974
+ code: "invalid_temporal_bucket_pattern",
2975
+ message: "Temporal bucket patterns cannot begin with a separator."
2976
+ };
2977
+ const s = t[t.length - 1];
2978
+ s.kind === "literal" ? s.value += o : t.push({ kind: "literal", value: o }), n += 1, r = !1;
2979
+ }
2980
+ return ((a = t[t.length - 1]) == null ? void 0 : a.kind) !== "token" ? {
2981
+ ok: !1,
2982
+ code: "invalid_temporal_bucket_pattern",
2983
+ message: "Temporal bucket patterns cannot end with a separator."
2984
+ } : { ok: !0, segments: t };
2985
+ }
2986
+ function Qi(e) {
2987
+ return e.flatMap(
2988
+ (t) => t.kind === "token" ? [t.value] : []
2989
+ );
2990
+ }
2991
+ function Et(e, t) {
2992
+ return e.filter((n) => t.includes(n)).length === 1;
2993
+ }
2994
+ function oe(e, t) {
2995
+ return e.some((n) => t.includes(n));
2996
+ }
2997
+ function Ji(e) {
2998
+ return new Set(e).size !== e.length;
2999
+ }
3000
+ function eo(e, t) {
3001
+ if (Ji(e)) return !1;
3002
+ const n = ["YYYY", "YY"], r = ["MMMM", "MMM", "MM"], a = ["HH", "mm", "ss"], i = Et(e, n), o = Et(e, r), s = e.includes("DD"), c = oe(e, a);
3003
+ switch (t) {
3004
+ case "second":
3005
+ return e.includes("HH") && e.includes("mm") && e.includes("ss") && (!oe(e, [...n, ...r, "DD"]) || i && o && s);
3006
+ case "minute":
3007
+ return e.includes("HH") && e.includes("mm") && (!oe(e, [...n, ...r, "DD"]) || i && o && s);
3008
+ case "hour":
3009
+ return e.includes("HH") && (!oe(e, [...n, ...r, "DD"]) || i && o && s);
3010
+ case "day":
3011
+ case "week":
3012
+ return i && o && s && !c;
3013
+ case "month":
3014
+ return i && o && !s && !c;
3015
+ case "quarter":
3016
+ return !1;
3017
+ case "year":
3018
+ return i && !o && !s && !c;
3019
+ }
3020
+ }
3021
+ function fn(e, t) {
3022
+ if (e.presentation.mode === "auto")
3023
+ return { ok: !0 };
3024
+ if (e.presentation.mode === "preset") {
3025
+ const r = mn[e.presentation.preset];
3026
+ return r.includes(t) ? { ok: !0 } : {
3027
+ ok: !1,
3028
+ code: "incompatible_temporal_bucket_preset",
3029
+ message: `Preset ${e.presentation.preset} requires ${r.join(", ")} granularity.`
3030
+ };
3031
+ }
3032
+ const n = ee(e.presentation.pattern);
3033
+ return n.ok ? eo(
3034
+ Qi(n.segments),
3035
+ t
3036
+ ) ? { ok: !0, segments: n.segments } : {
3037
+ ok: !1,
3038
+ code: "incompatible_temporal_bucket_pattern",
3039
+ message: `Pattern ${e.presentation.pattern} is not compatible with ${t} granularity.`
3040
+ } : n;
3041
+ }
3042
+ function Hs(e, t) {
3043
+ if (!(!e || !t))
3044
+ return fn(e, t).ok ? e : void 0;
3045
+ }
3046
+ function to(e) {
3047
+ return e.preset ? { mode: "preset", preset: e.preset } : e.pattern ? { mode: "pattern", dialect: e.dialect ?? "semaphor_tokens", pattern: e.pattern } : { mode: "auto" };
3048
+ }
3049
+ class U extends Error {
3050
+ constructor(n, r) {
3051
+ super(r);
3052
+ $(this, "code");
3053
+ this.name = "RawTemporalFormatContractError", this.code = n;
3054
+ }
3055
+ }
3056
+ const no = [
3057
+ "SSSSSSSSS",
3058
+ "SSSSSSSS",
3059
+ "SSSSSSS",
3060
+ "SSSSSS",
3061
+ "SSSSS",
3062
+ "SSSS",
3063
+ "SSS",
3064
+ "SS",
3065
+ "S"
3066
+ ], dn = /^(\d{4})-(\d{2})-(\d{2})$/, hn = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?$/, gn = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:\d{2})$/, ro = [
3067
+ "yyyy",
3068
+ "MMMM",
3069
+ "LLLL",
3070
+ "zzz",
3071
+ "XXX",
3072
+ "MMM",
3073
+ "LLL",
3074
+ "yy",
3075
+ "MM",
3076
+ "dd",
3077
+ "HH",
3078
+ "hh",
3079
+ "mm",
3080
+ "ss",
3081
+ "M",
3082
+ "d",
3083
+ "H",
3084
+ "h",
3085
+ "m",
3086
+ "s",
3087
+ "a"
3088
+ ], ao = /* @__PURE__ */ new Set([
3089
+ "HH",
3090
+ "H",
3091
+ "hh",
3092
+ "h",
3093
+ "mm",
3094
+ "m",
3095
+ "ss",
3096
+ "s",
3097
+ "a",
3098
+ ...no
3099
+ ]), io = /* @__PURE__ */ new Set(["zzz", "XXX"]), Ce = /* @__PURE__ */ new Set(["short", "medium", "long"]);
3100
+ function M(e, t) {
3101
+ return Object.keys(e).length === t.length && t.every((r) => r in e);
3102
+ }
3103
+ function g(e) {
3104
+ throw new U(
3105
+ "invalid_raw_temporal_format",
3106
+ e
3107
+ );
3108
+ }
3109
+ function yn(e) {
3110
+ if (!e || e.trim() !== e || e.length > 256)
3111
+ return g(
3112
+ "date_fns patterns must be non-empty, trimmed, and at most 256 characters."
3113
+ );
3114
+ const t = [], n = (a) => {
3115
+ const i = t[t.length - 1];
3116
+ (i == null ? void 0 : i.kind) === "literal" ? i.value += a : t.push({ kind: "literal", value: a });
3117
+ };
3118
+ let r = 0;
3119
+ for (; r < e.length; ) {
3120
+ if (e[r] === "'") {
3121
+ if (e[r + 1] === "'") {
3122
+ n("'"), r += 2;
3123
+ continue;
3124
+ }
3125
+ let o = "", s = !1;
3126
+ for (r += 1; r < e.length; ) {
3127
+ if (e[r] === "'") {
3128
+ if (e[r + 1] === "'") {
3129
+ o += "'", r += 2;
3130
+ continue;
3131
+ }
3132
+ s = !0, r += 1;
3133
+ break;
3134
+ }
3135
+ o += e[r], r += 1;
3136
+ }
3137
+ if (!s)
3138
+ return g("date_fns pattern has an unclosed quote.");
3139
+ n(o);
3140
+ continue;
3141
+ }
3142
+ if (e[r] === "S") {
3143
+ let o = r + 1;
3144
+ for (; e[o] === "S"; ) o += 1;
3145
+ const s = e.slice(r, o);
3146
+ if (s.length > 9)
3147
+ return g(
3148
+ "date_fns fractional-second tokens support at most nine digits."
3149
+ );
3150
+ t.push({
3151
+ kind: "token",
3152
+ value: s
3153
+ }), r = o;
3154
+ continue;
3155
+ }
3156
+ const a = ro.find(
3157
+ (o) => e.startsWith(o, r)
3158
+ );
3159
+ if (a) {
3160
+ t.push({ kind: "token", value: a }), r += a.length;
3161
+ continue;
3162
+ }
3163
+ const i = e[r];
3164
+ if (/[A-Za-z]/.test(i))
3165
+ return g(
3166
+ `Unsupported date_fns pattern token beginning at "${e.slice(r)}".`
3167
+ );
3168
+ n(i), r += 1;
3169
+ }
3170
+ return t.some((a) => a.kind === "token") ? t : g("date_fns patterns must contain at least one token.");
3171
+ }
3172
+ function pn(e, t) {
3173
+ if (e === "semaphor_tokens") {
3174
+ const n = ee(t);
3175
+ n.ok || g(n.message);
3176
+ return;
3177
+ }
3178
+ yn(t);
3179
+ }
3180
+ function oo(e) {
3181
+ return !T(e) || !M(e, ["dateStyle", "dateTime"]) ? g("Automatic raw temporal styles are incomplete.") : Ce.has(e.dateStyle) ? !T(e.dateTime) || !M(e.dateTime, ["dateStyle", "timeStyle"]) || !Ce.has(e.dateTime.dateStyle) || !Ce.has(e.dateTime.timeStyle) ? g(
3182
+ "Automatic dateTime styles are incomplete or invalid."
3183
+ ) : {
3184
+ dateStyle: e.dateStyle,
3185
+ dateTime: {
3186
+ dateStyle: e.dateTime.dateStyle,
3187
+ timeStyle: e.dateTime.timeStyle
3188
+ }
3189
+ } : g("Automatic dateStyle is invalid.");
3190
+ }
3191
+ function Ge(e) {
3192
+ const t = ["type", "locale", "calendarTimezone", "presentation"], n = [...t, "sourceTimezone"];
3193
+ if (!T(e) || !M(e, t) && !M(e, n) || e.type !== "raw_temporal")
3194
+ return g("Resolved raw temporal format has an invalid shape.");
3195
+ const r = X(e.locale);
3196
+ return r ? typeof e.calendarTimezone != "string" || !fe(e.calendarTimezone) ? g(
3197
+ "Raw temporal calendarTimezone must be a valid IANA timezone."
3198
+ ) : e.sourceTimezone !== void 0 && (typeof e.sourceTimezone != "string" || !fe(e.sourceTimezone)) ? g(
3199
+ "Raw temporal sourceTimezone must be a valid IANA timezone."
3200
+ ) : T(e.presentation) ? e.presentation.mode === "auto" ? M(e.presentation, ["mode", "styles"]) ? {
3201
+ type: "raw_temporal",
3202
+ locale: r,
3203
+ calendarTimezone: e.calendarTimezone,
3204
+ ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
3205
+ presentation: {
3206
+ mode: "auto",
3207
+ styles: oo(e.presentation.styles)
3208
+ }
3209
+ } : g(
3210
+ "Automatic raw temporal presentation has unknown fields."
3211
+ ) : e.presentation.mode === "preset" ? !M(e.presentation, ["mode", "preset"]) || !xn(e.presentation.preset) ? g("Preset raw temporal presentation has an invalid shape.") : {
3212
+ type: "raw_temporal",
3213
+ locale: r,
3214
+ calendarTimezone: e.calendarTimezone,
3215
+ ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
3216
+ presentation: { mode: "preset", preset: e.presentation.preset }
3217
+ } : e.presentation.mode !== "pattern" || !M(e.presentation, ["mode", "dialect", "pattern"]) || e.presentation.dialect !== "semaphor_tokens" && e.presentation.dialect !== "date_fns" || typeof e.presentation.pattern != "string" ? g(
3218
+ "Pattern raw temporal presentation has an invalid shape."
3219
+ ) : (pn(e.presentation.dialect, e.presentation.pattern), {
3220
+ type: "raw_temporal",
3221
+ locale: r,
3222
+ calendarTimezone: e.calendarTimezone,
3223
+ ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
3224
+ presentation: {
3225
+ mode: "pattern",
3226
+ dialect: e.presentation.dialect,
3227
+ pattern: e.presentation.pattern
3228
+ }
3229
+ }) : g("Raw temporal presentation must be an object.") : g("Raw temporal locale is invalid or unsupported.");
3230
+ }
3231
+ function wn(e) {
3232
+ var s, c, u;
3233
+ if (e.format) {
3234
+ if (!T(e.format))
3235
+ return g(
3236
+ "Authored raw temporal format has an invalid shape."
3237
+ );
3238
+ const l = Object.keys(e.format);
3239
+ if (!l.includes("type") || !l.includes("presentation") || l.some(
3240
+ (m) => m !== "type" && m !== "presentation" && m !== "timezone" && m !== "sourceTimezone"
3241
+ ) || e.format.type !== "raw_temporal" || !T(e.format.presentation))
3242
+ return g(
3243
+ "Authored raw temporal format has an invalid shape."
3244
+ );
3245
+ const f = e.format.presentation;
3246
+ if (f.mode === "auto") {
3247
+ if (!M(f, ["mode"]))
3248
+ return g(
3249
+ "Automatic authored raw temporal format has unknown fields."
3250
+ );
3251
+ } else if (f.mode === "preset") {
3252
+ if (!M(f, ["mode", "preset"]) || !xn(f.preset))
3253
+ return g("Authored raw temporal preset has an invalid shape.");
3254
+ } else {
3255
+ if (f.mode !== "pattern" || !M(f, ["mode", "dialect", "pattern"]) || f.dialect !== "semaphor_tokens" && f.dialect !== "date_fns" || typeof f.pattern != "string")
3256
+ return g(
3257
+ "Authored raw temporal pattern has an invalid shape."
3258
+ );
3259
+ pn(f.dialect, f.pattern);
3260
+ }
3261
+ }
3262
+ const t = (s = e.format) == null ? void 0 : s.timezone, n = (c = e.format) == null ? void 0 : c.sourceTimezone, r = t && t !== "auto" ? t : e.calendar.tz, a = n && n !== "auto" ? n === "local" ? Intl.DateTimeFormat().resolvedOptions().timeZone : n : void 0;
3263
+ if (t !== void 0 && t !== "auto" && !fe(r) || a !== void 0 && !fe(a))
3264
+ return g("Authored raw temporal timezone is invalid.");
3265
+ const i = ((u = e.format) == null ? void 0 : u.presentation) ?? { mode: "auto" }, o = {
3266
+ type: "raw_temporal",
3267
+ locale: e.preferences.locale,
3268
+ calendarTimezone: r,
3269
+ ...a ? { sourceTimezone: a } : {},
3270
+ presentation: i.mode === "pattern" || i.mode === "preset" ? { ...i } : {
3271
+ mode: "auto",
3272
+ styles: {
3273
+ dateStyle: e.preferences.dateStyle,
3274
+ dateTime: { ...e.preferences.dateTime }
3275
+ }
3276
+ }
3277
+ };
3278
+ return Ge(o);
3279
+ }
3280
+ function so(e) {
3281
+ if (dn.test(e)) return "date";
3282
+ if (gn.test(e)) return "instant";
3283
+ if (hn.test(e)) return "wall_datetime";
3284
+ }
3285
+ function qs(e) {
3286
+ const t = /* @__PURE__ */ new Set();
3287
+ let n = !1;
3288
+ for (const r of e.values) {
3289
+ if (r === null) continue;
3290
+ n = !0;
3291
+ const a = so(r);
3292
+ a && t.add(a);
3293
+ }
3294
+ if (!n) return { status: "empty" };
3295
+ if (t.size === 0) return { status: "invalid_only" };
3296
+ if (t.size > 1)
3297
+ throw new U(
3298
+ "mixed_sql_temporal_semantics",
3299
+ `Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`
3300
+ );
3301
+ return {
3302
+ status: "classified",
3303
+ metadata: {
3304
+ kind: "raw_temporal",
3305
+ valueKind: [...t][0]
3306
+ }
3307
+ };
3308
+ }
3309
+ function Zs(e) {
3310
+ return {
3311
+ version: 1,
3312
+ columns: Object.fromEntries(
3313
+ [...e].map(([t, n]) => [
3314
+ t,
3315
+ n.status === "classified" ? n.metadata.valueKind : n.status
3316
+ ])
3317
+ )
3318
+ };
3319
+ }
3320
+ function co(e) {
3321
+ if (!T(e) || e.version !== 1 || !T(e.columns) || Object.keys(e).some((r) => r !== "version" && r !== "columns"))
3322
+ throw new U(
3323
+ "invalid_raw_temporal_format",
3324
+ "Raw temporal chunk classification evidence is malformed."
3325
+ );
3326
+ const t = {}, n = /* @__PURE__ */ new Set([
3327
+ "empty",
3328
+ "invalid_only",
3329
+ "date",
3330
+ "wall_datetime",
3331
+ "instant"
3332
+ ]);
3333
+ for (const [r, a] of Object.entries(e.columns)) {
3334
+ if (!r.trim() || !n.has(a))
3335
+ throw new U(
3336
+ "invalid_raw_temporal_format",
3337
+ "Raw temporal chunk classification evidence contains an invalid column or status."
3338
+ );
3339
+ t[r] = a;
3340
+ }
3341
+ return { version: 1, columns: t };
3342
+ }
3343
+ function Ks(e) {
3344
+ if (e.length === 0) return;
3345
+ const t = e.map(co), n = Object.keys(t[0].columns).sort();
3346
+ for (let r = 1; r < t.length; r += 1) {
3347
+ const a = Object.keys(t[r].columns).sort();
3348
+ if (a.length !== n.length || a.some((i, o) => i !== n[o]))
3349
+ throw new U(
3350
+ "invalid_raw_temporal_format",
3351
+ "Raw temporal chunk classification evidence has inconsistent columns."
3352
+ );
3353
+ }
3354
+ for (const r of n)
3355
+ if (new Set(
3356
+ t.map((i) => i.columns[r]).filter(
3357
+ (i) => i !== "empty" && i !== "invalid_only"
3358
+ )
3359
+ ).size > 1)
3360
+ throw new U(
3361
+ "mixed_sql_temporal_semantics",
3362
+ `Declared SQL temporal column "${r}" has inconsistent semantics across export chunks. Normalize it to one kind.`
3363
+ );
3364
+ }
3365
+ function uo(e) {
3366
+ return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
3367
+ }
3368
+ function lo(e, t) {
3369
+ return t === 2 ? uo(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
3370
+ }
3371
+ function mo(e) {
3372
+ return e.year >= 1 && e.year <= 9999 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= lo(e.year, e.month) && e.hour >= 0 && e.hour <= 23 && e.minute >= 0 && e.minute <= 59 && e.second >= 0 && e.second <= 59;
3373
+ }
3374
+ function fo(e) {
3375
+ return {
3376
+ year: Number(e[1]),
3377
+ month: Number(e[2]),
3378
+ day: Number(e[3]),
3379
+ hour: Number(e[4] ?? 0),
3380
+ minute: Number(e[5] ?? 0),
3381
+ second: Number(e[6] ?? 0),
3382
+ fraction: e[7] ?? ""
3383
+ };
3384
+ }
3385
+ function ho(e, t) {
3386
+ const n = t === "date" ? e.match(dn) : t === "wall_datetime" ? e.match(hn) : e.match(gn);
3387
+ if (!n) return { status: "invalid_shape" };
3388
+ const r = fo(n);
3389
+ if (!mo(r)) return { status: "out_of_range" };
3390
+ if (t === "instant") {
3391
+ const a = n[8];
3392
+ if (a && a !== "Z") {
3393
+ const [o, s] = a.slice(1).split(":").map(Number);
3394
+ if (o > 23 || s > 59) return { status: "out_of_range" };
3395
+ }
3396
+ const i = new Date(e.replace(" ", "T"));
3397
+ return Number.isNaN(i.getTime()) ? { status: "out_of_range" } : { status: "valid", fields: r, instant: i };
3398
+ }
3399
+ return { status: "valid", fields: r };
3400
+ }
3401
+ function We(e) {
3402
+ const t = /* @__PURE__ */ new Date(0);
3403
+ return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
3404
+ }
3405
+ function Qe(e, t) {
3406
+ const n = e.fraction ? `.${e.fraction.padEnd(3, "0").slice(0, 3)}` : "";
3407
+ return J(
3408
+ `${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")}${n}`,
3409
+ t
3410
+ );
3411
+ }
3412
+ function Tn(e, t) {
3413
+ const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
3414
+ let a, i, o, s;
3415
+ return {
3416
+ number(c, u = 1) {
3417
+ let l = n.get(u);
3418
+ return l || (l = new Intl.NumberFormat(e, {
3419
+ useGrouping: !1,
3420
+ minimumIntegerDigits: u,
3421
+ maximumFractionDigits: 0
3422
+ }), n.set(u, l)), l.format(c);
3423
+ },
3424
+ month(c, u, l) {
3425
+ var h;
3426
+ const f = `${u}:${l ? "standalone" : "contextual"}`;
3427
+ let m = r.get(f);
3428
+ if (!m) {
3429
+ const d = {
3430
+ calendar: "gregory",
3431
+ timeZone: "UTC",
3432
+ month: u
3433
+ };
3434
+ l || (d.day = "numeric"), m = new Intl.DateTimeFormat(e, d), r.set(f, m);
3435
+ }
3436
+ return ((h = m.formatToParts(c).find((d) => d.type === "month")) == null ? void 0 : h.value) ?? "";
3437
+ },
3438
+ dayPeriod(c) {
3439
+ var u;
3440
+ return a ?? (a = new Intl.DateTimeFormat(e, {
3441
+ calendar: "gregory",
3442
+ timeZone: "UTC",
3443
+ hour: "numeric",
3444
+ hour12: !0
3445
+ })), ((u = a.formatToParts(c).find((l) => l.type === "dayPeriod")) == null ? void 0 : u.value) ?? "";
3446
+ },
3447
+ instantFields(c) {
3448
+ i ?? (i = new Intl.DateTimeFormat("en-CA", {
3449
+ calendar: "gregory",
3450
+ numberingSystem: "latn",
3451
+ timeZone: t,
3452
+ year: "numeric",
3453
+ month: "2-digit",
3454
+ day: "2-digit",
3455
+ hour: "2-digit",
3456
+ minute: "2-digit",
3457
+ second: "2-digit",
3458
+ hourCycle: "h23"
3459
+ }));
3460
+ const u = i.formatToParts(c), l = (f) => {
3461
+ var m;
3462
+ return Number((m = u.find((h) => h.type === f)) == null ? void 0 : m.value);
3463
+ };
3464
+ return {
3465
+ year: l("year"),
3466
+ month: l("month"),
3467
+ day: l("day"),
3468
+ hour: l("hour"),
3469
+ minute: l("minute"),
3470
+ second: l("second"),
3471
+ fraction: ""
3472
+ };
3473
+ },
3474
+ timezoneName(c) {
3475
+ var u;
3476
+ return o ?? (o = new Intl.DateTimeFormat(e, {
3477
+ calendar: "gregory",
3478
+ timeZone: t,
3479
+ timeZoneName: "short"
3480
+ })), ((u = o.formatToParts(c).find((l) => l.type === "timeZoneName")) == null ? void 0 : u.value) ?? "";
3481
+ },
3482
+ timezoneOffset(c) {
3483
+ var f;
3484
+ s ?? (s = new Intl.DateTimeFormat("en-US", {
3485
+ calendar: "gregory",
3486
+ timeZone: t,
3487
+ timeZoneName: "longOffset"
3488
+ }));
3489
+ const u = (f = s.formatToParts(c).find((m) => m.type === "timeZoneName")) == null ? void 0 : f.value;
3490
+ if (!u)
3491
+ return g("Unable to resolve the instant timezone offset.");
3492
+ const l = u.replace(/^GMT/, "");
3493
+ return l === "" || /^[+-]00:00$/.test(l) ? "Z" : l;
3494
+ }
3495
+ };
3496
+ }
3497
+ function go(e, t, n, r, a) {
3498
+ if (/^S{1,9}$/.test(e)) {
3499
+ const i = t.fraction.padEnd(e.length, "0").slice(0, e.length);
3500
+ return r.number(Number(i), e.length);
3501
+ }
3502
+ switch (e) {
3503
+ case "YYYY":
3504
+ case "yyyy":
3505
+ return r.number(t.year, 4);
3506
+ case "YY":
3507
+ case "yy":
3508
+ return r.number(t.year % 100, 2);
3509
+ case "MMMM":
3510
+ return r.month(n, "long", !1);
3511
+ case "LLLL":
3512
+ return r.month(n, "long", !0);
3513
+ case "MMM":
3514
+ return r.month(n, "short", !1);
3515
+ case "LLL":
3516
+ return r.month(n, "short", !0);
3517
+ case "MM":
3518
+ return r.number(t.month, 2);
3519
+ case "M":
3520
+ return r.number(t.month);
3521
+ case "DD":
3522
+ case "dd":
3523
+ return r.number(t.day, 2);
3524
+ case "d":
3525
+ return r.number(t.day);
3526
+ case "HH":
3527
+ return r.number(t.hour, 2);
3528
+ case "H":
3529
+ return r.number(t.hour);
3530
+ case "hh":
3531
+ return r.number(t.hour % 12 || 12, 2);
3532
+ case "h":
3533
+ return r.number(t.hour % 12 || 12);
3534
+ case "mm":
3535
+ return r.number(t.minute, 2);
3536
+ case "m":
3537
+ return r.number(t.minute);
3538
+ case "ss":
3539
+ return r.number(t.second, 2);
3540
+ case "s":
3541
+ return r.number(t.second);
3542
+ case "a":
3543
+ return r.dayPeriod(n);
3544
+ case "zzz":
3545
+ return a ? r.timezoneName(a) : g(
3546
+ "Timezone pattern tokens require an instant value."
3547
+ );
3548
+ case "XXX":
3549
+ return a ? r.timezoneOffset(a) : g(
3550
+ "Timezone pattern tokens require an instant value."
3551
+ );
3552
+ default:
3553
+ return g(
3554
+ `Unsupported raw temporal pattern token "${e}".`
3555
+ );
3556
+ }
3557
+ }
3558
+ function yo(e, t, n, r) {
3559
+ const a = We(t);
3560
+ return e.map(
3561
+ (i) => i.kind === "literal" ? i.value : go(i.value, t, a, n, r)
3562
+ ).join("");
3563
+ }
3564
+ function Dn(e, t, n) {
3565
+ const r = t === "date_fns" ? yn(n) : (() => {
3566
+ const i = ee(n);
3567
+ return i.ok ? i.segments : g(i.message);
3568
+ })(), a = r.filter((i) => i.kind === "token").map((i) => i.value);
3569
+ return e === "date" && a.some((i) => ao.has(i)) ? g("Date patterns cannot contain time tokens.") : e !== "instant" && a.some((i) => io.has(i)) ? g("Timezone pattern tokens require an instant value.") : r;
3570
+ }
3571
+ function po(e) {
3572
+ Dn(
3573
+ e.valueKind ?? "instant",
3574
+ e.dialect,
3575
+ e.pattern
3576
+ );
3577
+ }
3578
+ function wo(e, t, n, r) {
3579
+ const a = Dn(
3580
+ e.valueKind,
3581
+ n,
3582
+ r
3583
+ ), i = Tn(t.locale, t.calendarTimezone);
3584
+ return (o) => {
3585
+ const s = e.valueKind === "wall_datetime" && t.sourceTimezone ? Qe(o.fields, t.sourceTimezone) : void 0, c = e.valueKind === "instant" ? {
3586
+ ...i.instantFields(o.instant),
3587
+ fraction: o.fields.fraction
3588
+ } : s ? {
3589
+ ...i.instantFields(s),
3590
+ fraction: o.fields.fraction
3591
+ } : o.fields;
3592
+ return yo(a, c, i, o.instant ?? s);
3593
+ };
3594
+ }
3595
+ function bn(e, t) {
3596
+ const n = Tn(t.locale, t.calendarTimezone);
3597
+ return (r) => {
3598
+ const a = e.valueKind === "instant" ? n.instantFields(r.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? n.instantFields(Qe(r.fields, t.sourceTimezone)) : r.fields;
3599
+ return {
3600
+ year: a.year,
3601
+ month: a.month,
3602
+ day: a.day,
3603
+ hour: a.hour,
3604
+ minute: a.minute,
3605
+ second: a.second
3606
+ };
3607
+ };
3608
+ }
3609
+ const To = /* @__PURE__ */ new Set(["short", "long", "numeric", "iso"]);
3610
+ function xn(e) {
3611
+ return typeof e == "string" && To.has(e);
3612
+ }
3613
+ function Do(e, t, n) {
3614
+ const r = bn(e, t), a = e.valueKind !== "date", i = (s, c = 2) => String(s).padStart(c, "0");
3615
+ if (n === "iso")
3616
+ return (s) => {
3617
+ const c = r(s), u = `${i(c.year, 4)}-${i(c.month)}-${i(c.day)}`;
3618
+ return a ? `${u} ${i(c.hour)}:${i(c.minute)}` : u;
3619
+ };
3620
+ const o = new Intl.DateTimeFormat(t.locale, {
3621
+ calendar: "gregory",
3622
+ timeZone: "UTC",
3623
+ year: "numeric",
3624
+ month: n,
3625
+ day: "numeric",
3626
+ ...a ? { hour: "numeric", minute: "2-digit" } : {}
3627
+ });
3628
+ return (s) => {
3629
+ const c = r(s), u = /* @__PURE__ */ new Date(0);
3630
+ return u.setUTCFullYear(c.year, c.month - 1, c.day), u.setUTCHours(c.hour, c.minute, c.second, 0), o.format(u);
3631
+ };
3632
+ }
3633
+ function bo(e, t) {
3634
+ const n = t.presentation.mode === "auto" ? t.presentation.styles : g("Automatic raw temporal formatting requires styles.");
3635
+ if (e.valueKind === "date") {
3636
+ const o = new Intl.DateTimeFormat(t.locale, {
3637
+ calendar: "gregory",
3638
+ timeZone: "UTC",
3639
+ dateStyle: n.dateStyle
3640
+ });
3641
+ return (s) => o.format(We(s.fields));
3642
+ }
3643
+ const r = e.valueKind === "instant", a = !r && n.dateTime.timeStyle === "long" ? "medium" : n.dateTime.timeStyle, i = new Intl.DateTimeFormat(t.locale, {
3644
+ calendar: "gregory",
3645
+ timeZone: r || e.valueKind === "wall_datetime" && t.sourceTimezone ? t.calendarTimezone : "UTC",
3646
+ dateStyle: n.dateTime.dateStyle,
3647
+ timeStyle: a
3648
+ });
3649
+ return (o) => r ? i.format(o.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? i.format(Qe(o.fields, t.sourceTimezone)) : i.format(We(o.fields));
3650
+ }
3651
+ function Ct(e, t, n) {
3652
+ return {
3653
+ ok: !1,
3654
+ text: e,
3655
+ diagnostic: {
3656
+ code: n,
3657
+ message: `Raw temporal ${t.valueKind} value is ${n === "invalid_raw_temporal_value" ? "malformed" : "out of range"}.`
3658
+ }
3659
+ };
3660
+ }
3661
+ function vn(e) {
3662
+ const t = Bn(e.metadata), n = Ge(e.format), r = n.presentation.mode === "auto" ? bo(t, n) : n.presentation.mode === "preset" ? Do(t, n, n.presentation.preset) : wo(
3663
+ t,
3664
+ n,
3665
+ n.presentation.dialect,
3666
+ n.presentation.pattern
3667
+ ), a = bn(t, n);
3668
+ return (i) => {
3669
+ if (i === null)
3670
+ return { ok: !0, text: "", status: "empty" };
3671
+ const o = ho(i, t.valueKind);
3672
+ return o.status === "invalid_shape" ? Ct(i, t, "invalid_raw_temporal_value") : o.status === "out_of_range" ? Ct(i, t, "out_of_range_raw_temporal_value") : {
3673
+ ok: !0,
3674
+ text: r(o),
3675
+ status: "formatted",
3676
+ wallClock: a(o)
3677
+ };
3678
+ };
3679
+ }
3680
+ function xo(e) {
3681
+ return vn({
3682
+ metadata: e.metadata,
3683
+ format: e.format
3684
+ })(e.value);
3685
+ }
3686
+ function vo(e) {
3687
+ const t = wn({ format: e.authored, preferences: e.preferences, calendar: e.calendar });
3688
+ return { format: t, formatValue: vn({ metadata: e.metadata, format: t }) };
3689
+ }
3690
+ const So = {
3691
+ dateStyle: "short",
3692
+ dateTime: { dateStyle: "short", timeStyle: "short" }
3693
+ };
3694
+ class le extends Error {
3695
+ constructor(n, r) {
3696
+ super(r);
3697
+ $(this, "code");
3698
+ this.name = "TemporalBucketContractError", this.code = n;
3699
+ }
3700
+ }
3701
+ const Mo = [
3702
+ "Jan",
3703
+ "Feb",
3704
+ "Mar",
3705
+ "Apr",
3706
+ "May",
3707
+ "Jun",
3708
+ "Jul",
3709
+ "Aug",
3710
+ "Sep",
3711
+ "Oct",
3712
+ "Nov",
3713
+ "Dec"
3714
+ ], ko = [
3715
+ "January",
3716
+ "February",
3717
+ "March",
3718
+ "April",
3719
+ "May",
3720
+ "June",
3721
+ "July",
3722
+ "August",
3723
+ "September",
3724
+ "October",
3725
+ "November",
3726
+ "December"
3727
+ ];
3728
+ function Pe(e) {
3729
+ return {
3730
+ ok: !1,
3731
+ error: { code: "invalid_temporal_bucket_value", message: e }
3732
+ };
3733
+ }
3734
+ function _o(e) {
3735
+ return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
3736
+ }
3737
+ function No(e, t) {
3738
+ return t === 2 ? _o(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
3739
+ }
3740
+ function $o(e, t, n) {
3741
+ const r = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], a = t < 3 ? e - 1 : e;
3742
+ return (a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) + r[t - 1] + n) % 7;
3743
+ }
3744
+ function xe(e) {
3745
+ var t;
3746
+ return (t = e.calendar.fiscalCalendar) == null ? void 0 : t.yearStartMonth;
3747
+ }
3748
+ function Oo(e, t) {
3749
+ return (e - t + 12) % 12 % 3 === 0;
3750
+ }
3751
+ function Io(e, t) {
3752
+ const { granularity: n } = t, r = xe(t) ?? 1;
3753
+ switch (n) {
3754
+ case "second":
3755
+ return !0;
3756
+ case "minute":
3757
+ return e.second === 0;
3758
+ case "hour":
3759
+ return e.minute === 0 && e.second === 0;
3760
+ case "day":
3761
+ return !0;
3762
+ case "week":
3763
+ return $o(e.year, e.month, e.day) === t.calendar.weekStart;
3764
+ case "month":
3765
+ return e.day === 1;
3766
+ case "quarter":
3767
+ return e.day === 1 && Oo(e.month, r);
3768
+ case "year":
3769
+ return e.day === 1 && e.month === r;
3770
+ }
3771
+ }
3772
+ function Sn(e, t) {
3773
+ if (e === null) return { ok: !0, value: null };
3774
+ const n = t.granularity === "second" || t.granularity === "minute" || t.granularity === "hour", r = n ? /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e) : /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
3775
+ if (!r)
3776
+ return Pe(
3777
+ `Expected ${n ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${t.granularity} granularity.`
3778
+ );
3779
+ const a = {
3780
+ year: Number(r[1]),
3781
+ month: Number(r[2]),
3782
+ day: Number(r[3]),
3783
+ hour: n ? Number(r[4]) : 0,
3784
+ minute: n ? Number(r[5]) : 0,
3785
+ second: n ? Number(r[6]) : 0
3786
+ };
3787
+ return a.year < 1 || a.month < 1 || a.month > 12 || a.day < 1 || a.day > No(a.year, a.month) || a.hour > 23 || a.minute > 59 || a.second > 59 ? Pe(`Invalid canonical ${t.granularity} bucket value ${e}.`) : Io(a, t) ? { ok: !0, value: a } : Pe(
3788
+ `Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`
3789
+ );
3790
+ }
3791
+ function Vs(e) {
3792
+ const { granularity: t, calendar: n } = e, r = (o, s) => new Intl.DateTimeFormat("en-US", { ...o, timeZone: "UTC" }).format(s), a = [`by ${t} in the ${n.tz} calendar`];
3793
+ t === "week" && a.push(`weeks starting on ${r({ weekday: "long" }, new Date(Date.UTC(2023, 0, 1 + n.weekStart)))}`);
3794
+ const i = xe(e);
3795
+ return i && (t === "quarter" || t === "year") && a.push(`the fiscal year starting in ${r({ month: "long" }, new Date(Date.UTC(2e3, i - 1, 1)))}`), `${a.join(", ")}; each value is a bucket's start`;
3796
+ }
3797
+ function Mn(e) {
3798
+ if (!T(e))
3799
+ return {
3800
+ ok: !1,
3801
+ issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
3802
+ };
3803
+ const t = [], n = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
3804
+ for (const o of Object.keys(e))
3805
+ n.has(o) || t.push({ path: o, message: `Unknown property "${o}".` });
3806
+ e.type !== "temporal_bucket" && t.push({ path: "type", message: "Expected temporal_bucket." });
3807
+ const r = e.presentation;
3808
+ if (!T(r))
3809
+ t.push({ path: "presentation", message: "Expected a presentation object." });
3810
+ else {
3811
+ const o = r.mode, s = 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"]);
3812
+ for (const c of Object.keys(r))
3813
+ s.has(c) || t.push({
3814
+ path: `presentation.${c}`,
3815
+ message: `Unknown property "${c}".`
3816
+ });
3817
+ if (o === "preset")
3818
+ Xi(r.preset) || t.push({ path: "presentation.preset", message: "Expected a supported preset." });
3819
+ else if (o === "pattern")
3820
+ if (typeof r.pattern != "string" || !r.pattern)
3821
+ t.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
3822
+ else {
3823
+ const c = ee(r.pattern);
3824
+ c.ok || t.push({
3825
+ path: "presentation.pattern",
3826
+ message: c.message
3827
+ });
3828
+ }
3829
+ else if (o === "auto") {
3830
+ const c = r.styles;
3831
+ (!T(c) || !["short", "medium", "long"].includes(String(c.dateStyle)) || !T(c.dateTime) || !["short", "medium", "long"].includes(
3832
+ String(c.dateTime.dateStyle)
3833
+ ) || !["short", "medium", "long"].includes(
3834
+ String(c.dateTime.timeStyle)
3835
+ ) || Object.keys(c).some(
3836
+ (u) => u !== "dateStyle" && u !== "dateTime"
3837
+ ) || Object.keys(c.dateTime).some(
3838
+ (u) => u !== "dateStyle" && u !== "timeStyle"
3839
+ )) && t.push({
3840
+ path: "presentation.styles",
3841
+ message: "Expected complete resolved date and datetime styles."
3842
+ });
3843
+ } else
3844
+ t.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
3845
+ }
3846
+ const a = X(e.locale);
3847
+ if (a || t.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), t.length > 0 || !a || !T(r))
3848
+ return { ok: !1, issues: t };
3849
+ if (r.mode === "auto") {
3850
+ const o = r.styles;
3851
+ return {
3852
+ ok: !0,
3853
+ value: {
3854
+ type: "temporal_bucket",
3855
+ locale: a,
3856
+ presentation: {
3857
+ mode: "auto",
3858
+ styles: {
3859
+ dateStyle: o.dateStyle,
3860
+ dateTime: {
3861
+ dateStyle: o.dateTime.dateStyle,
3862
+ timeStyle: o.dateTime.timeStyle
3863
+ }
3864
+ }
3865
+ }
3866
+ }
3867
+ };
3868
+ }
3869
+ return {
3870
+ ok: !0,
3871
+ value: {
3872
+ type: "temporal_bucket",
3873
+ presentation: r.mode === "preset" ? {
3874
+ mode: "preset",
3875
+ preset: r.preset
3876
+ } : {
3877
+ mode: "pattern",
3878
+ pattern: r.pattern
3879
+ },
3880
+ locale: a
3881
+ }
3882
+ };
3883
+ }
3884
+ function Fo(e, t) {
3885
+ const n = !!t.calendar.fiscalCalendar;
3886
+ return e === "fiscal_quarter_short" || e === "fiscal_year" ? n : e === "quarter_short" || e === "quarter_long" || On(e) && (t.granularity === "quarter" || t.granularity === "year") ? !n : !0;
3887
+ }
3888
+ function kn(e, t) {
3889
+ return fn(e, t.granularity).ok ? e.presentation.mode === "preset" ? Fo(e.presentation.preset, t) : !(e.presentation.mode === "pattern" && t.calendar.fiscalCalendar && (t.granularity === "quarter" || t.granularity === "year")) : !1;
3890
+ }
3891
+ function Pt(e, t) {
3892
+ if (!(!e || e.presentation.mode === "auto"))
3893
+ return kn(e, t) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
3894
+ }
3895
+ function _n(e) {
3896
+ var a;
3897
+ const t = X(e.locale);
3898
+ if (!t)
3899
+ throw new le(
3900
+ "invalid_temporal_bucket_format",
3901
+ "Temporal bucket locale must be a supported base BCP 47 locale."
3902
+ );
3903
+ const n = Pt(e.cardFormat, e.metadata);
3904
+ if (n)
3905
+ return { format: { ...n, locale: t }, source: "card" };
3906
+ const r = ((a = e.semanticFormat) == null ? void 0 : a.granularity) === e.metadata.granularity ? Pt(e.semanticFormat.format, e.metadata) : void 0;
3907
+ return r ? { format: { ...r, locale: t }, source: "semantic" } : {
3908
+ format: {
3909
+ type: "temporal_bucket",
3910
+ locale: t,
3911
+ presentation: {
3912
+ mode: "auto",
3913
+ styles: e.styles ?? So
3914
+ }
3915
+ },
3916
+ source: "automatic"
3917
+ };
3918
+ }
3919
+ function D(e, t = 2) {
3920
+ return String(e).padStart(t, "0");
3921
+ }
3922
+ function V(e, t, n) {
3923
+ if (t === "en-US")
3924
+ return (n === "short" ? Mo : ko)[e - 1];
3925
+ const r = new Date(Date.UTC(2e3, e - 1, 15));
3926
+ return new Intl.DateTimeFormat(t, {
3927
+ calendar: "gregory",
3928
+ month: n,
3929
+ timeZone: "UTC"
3930
+ }).format(r);
3931
+ }
3932
+ function Eo(e, t, n) {
3933
+ return t.map((r) => {
3934
+ if (r.kind === "literal") return r.value;
3935
+ switch (r.value) {
3936
+ case "YYYY":
3937
+ return D(e.year, 4);
3938
+ case "YY":
3939
+ return D(e.year % 100);
3940
+ case "MMMM":
3941
+ return V(e.month, n, "long");
3942
+ case "MMM":
3943
+ return V(e.month, n, "short");
3944
+ case "MM":
3945
+ return D(e.month);
3946
+ case "DD":
3947
+ return D(e.day);
3948
+ case "HH":
3949
+ return D(e.hour);
3950
+ case "mm":
3951
+ return D(e.minute);
3952
+ case "ss":
3953
+ return D(e.second);
3954
+ }
3955
+ }).join("");
3956
+ }
3957
+ const Yt = /* @__PURE__ */ new Map();
3958
+ function Y(e, t) {
3959
+ const n = `${e}:${JSON.stringify(t)}`, r = Yt.get(n);
3960
+ if (r) return r;
3961
+ const a = new Intl.DateTimeFormat(e, t);
3962
+ return Yt.set(n, a), a;
3963
+ }
3964
+ function B(e) {
3965
+ const t = /* @__PURE__ */ new Date(0);
3966
+ return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
3967
+ }
3968
+ function zt(e, t, n) {
3969
+ return Y(t, {
3970
+ calendar: "gregory",
3971
+ dateStyle: n,
3972
+ timeZone: "UTC"
3973
+ }).format(B(e));
3974
+ }
3975
+ function Co(e, t, n) {
3976
+ return Y(t, {
3977
+ calendar: "gregory",
3978
+ dateStyle: n.dateStyle,
3979
+ // Grouped buckets are civil values, not instants. Long time styles would
3980
+ // append a zone label that the canonical value does not semantically own.
3981
+ timeStyle: n.timeStyle === "long" ? "medium" : n.timeStyle,
3982
+ timeZone: "UTC"
3983
+ }).format(B(e));
3984
+ }
3985
+ function Po(e, t, n) {
3986
+ var a;
3987
+ if (n === "short") {
3988
+ const i = B(e), o = Y(t, {
3989
+ calendar: "gregory",
3990
+ dateStyle: "short",
3991
+ timeZone: "UTC"
3992
+ }).formatToParts(i), s = o.findIndex((l) => l.type === "month"), c = o.findIndex((l) => l.type === "year"), u = (a = Y(t, {
3993
+ calendar: "gregory",
3994
+ timeZone: "UTC",
3995
+ year: "numeric"
3996
+ }).formatToParts(i).find((l) => l.type === "year")) == null ? void 0 : a.value;
3997
+ if (s >= 0 && c >= 0 && u) {
3998
+ const l = Math.min(s, c), f = Math.max(s, c);
3999
+ let m = !1;
4000
+ return o.slice(l, f + 1).filter((h) => h.type === "day" ? (m = !0, !1) : m && h.type === "literal" ? (m = !1, !1) : !0).map((h) => h.type === "year" ? u : h.value).join("");
4001
+ }
4002
+ }
4003
+ return Y(t, {
4004
+ calendar: "gregory",
4005
+ month: n === "short" ? "numeric" : n === "medium" ? "short" : "long",
4006
+ timeZone: "UTC",
4007
+ year: "numeric"
4008
+ }).format(B(e));
4009
+ }
4010
+ function Nn(e, t) {
4011
+ return Math.floor((e.month - t + 12) % 12 / 3) + 1;
4012
+ }
4013
+ function At(e, t) {
4014
+ return t === 1 || e.month < t ? e.year : e.year + 1;
4015
+ }
4016
+ function $n(e) {
4017
+ return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
4018
+ }
4019
+ function On(e) {
4020
+ return e === "short" || e === "long" || e === "numeric" || e === "iso";
4021
+ }
4022
+ function Ye(e, t, n) {
4023
+ return t === "iso" ? `${D(e.year, 4)}-${D(e.month)}-${D(e.day)}` : Y(n, {
4024
+ calendar: "gregory",
4025
+ month: t === "numeric" ? "numeric" : t === "long" ? "long" : "short",
4026
+ day: "numeric",
4027
+ year: "numeric",
4028
+ timeZone: "UTC"
4029
+ }).format(B(e));
4030
+ }
4031
+ function Yo(e, t, n, r) {
4032
+ const a = Nn(e, 1);
4033
+ switch (r) {
4034
+ case "week":
4035
+ return t === "numeric" || t === "iso" ? Ye(e, t, n) : `Week of ${Ye(e, t, n)}`;
4036
+ case "month":
4037
+ return t === "iso" ? `${D(e.year, 4)}-${D(e.month)}` : t === "numeric" ? `${D(e.month)}/${D(e.year, 4)}` : `${V(e.month, n, t === "long" ? "long" : "short")} ${e.year}`;
4038
+ case "quarter":
4039
+ return t === "iso" ? `${D(e.year, 4)}-Q${a}` : t === "long" ? `${$n(a)} Quarter ${e.year}` : `Q${a} ${e.year}`;
4040
+ case "year":
4041
+ return String(e.year);
4042
+ default:
4043
+ return Ye(e, t, n);
4044
+ }
4045
+ }
4046
+ function je(e, t, n, r) {
4047
+ if (On(t))
4048
+ return Yo(e, t, n, r.granularity);
4049
+ const a = xe(r) ?? 1, i = Nn(e, a);
4050
+ switch (t) {
4051
+ case "week_of_short":
4052
+ return `Week of ${V(e.month, n, "short")} ${e.day}, ${e.year}`;
4053
+ case "week_of_long":
4054
+ return `Week of ${V(e.month, n, "long")} ${e.day}, ${e.year}`;
4055
+ case "quarter_short":
4056
+ return `Q${i} ${e.year}`;
4057
+ case "quarter_long":
4058
+ return `${$n(i)} Quarter ${e.year}`;
4059
+ case "fiscal_quarter_short":
4060
+ return `Q${i} FY${At(e, a)}`;
4061
+ case "fiscal_year":
4062
+ return `FY${At(e, a)}`;
4063
+ }
4064
+ }
4065
+ function zo(e, t, n, r) {
4066
+ const a = xe(t);
4067
+ switch (t.granularity) {
4068
+ case "second":
4069
+ case "minute":
4070
+ case "hour":
4071
+ return Co(e, n, r.dateTime);
4072
+ case "day":
4073
+ return zt(e, n, r.dateStyle);
4074
+ case "week":
4075
+ return `Week of ${zt(e, n, r.dateStyle)}`;
4076
+ case "month":
4077
+ return Po(e, n, r.dateStyle);
4078
+ case "quarter":
4079
+ return je(
4080
+ e,
4081
+ a ? "fiscal_quarter_short" : "quarter_short",
4082
+ n,
4083
+ t
4084
+ );
4085
+ case "year":
4086
+ return a ? je(e, "fiscal_year", n, t) : String(e.year);
4087
+ }
4088
+ }
4089
+ function Bs(e, t) {
4090
+ if (t.granularity !== "second" && t.granularity !== "minute" && t.granularity !== "hour" && t.granularity !== "day" && t.granularity !== "month")
4091
+ return;
4092
+ const n = Sn(e, t);
4093
+ if (!n.ok || n.value === null) return;
4094
+ const { year: r, month: a, day: i, hour: o, minute: s, second: c } = n.value;
4095
+ return { year: r, month: a, day: i, hour: o, minute: s, second: c };
4096
+ }
4097
+ function In(e) {
4098
+ const t = Mn(e.format);
4099
+ if (!t.ok || !kn(t.value, e.metadata))
4100
+ throw new le(
4101
+ "invalid_temporal_bucket_format",
4102
+ "Resolved temporal bucket format is invalid or inapplicable to its metadata."
4103
+ );
4104
+ const n = Sn(e.value, e.metadata);
4105
+ if (!n.ok)
4106
+ throw new le(
4107
+ n.error.code,
4108
+ n.error.message
4109
+ );
4110
+ if (n.value === null) return "(Blank)";
4111
+ const { presentation: r, locale: a } = t.value;
4112
+ if (r.mode === "auto")
4113
+ return zo(
4114
+ n.value,
4115
+ e.metadata,
4116
+ a,
4117
+ r.styles
4118
+ );
4119
+ if (r.mode === "preset")
4120
+ return je(
4121
+ n.value,
4122
+ r.preset,
4123
+ a,
4124
+ e.metadata
4125
+ );
4126
+ const i = ee(r.pattern);
4127
+ if (!i.ok)
4128
+ throw new le(
4129
+ "invalid_temporal_bucket_format",
4130
+ i.message
4131
+ );
4132
+ return Eo(n.value, i.segments, a);
4133
+ }
4134
+ function Ao(e, t) {
4135
+ var a;
4136
+ const n = e[e.length - 1];
4137
+ if (!n) return "";
4138
+ if (n.member.kind === "others") return "Others";
4139
+ const r = n.member.value;
4140
+ return r === null ? "(Blank)" : ((a = t == null ? void 0 : t.get(n.levelId)) == null ? void 0 : a(r)) ?? (typeof r == "object" ? r.value : String(r));
4141
+ }
4142
+ function Uo(e, t, n) {
4143
+ return e === "grand_total" ? n ?? "Grand Total" : e === "subtotal" ? (n == null ? void 0 : n.split(Ln).join(t)) ?? `${t} Total` : t;
4144
+ }
4145
+ function Xs(e, t, n, r) {
4146
+ var o;
4147
+ const a = e[e.length - 1], i = t === "grand_total" ? n.grand.label : a ? (o = n.levels[a.levelId]) == null ? void 0 : o.label : void 0;
4148
+ return Uo(t, Ao(e, r), i);
4149
+ }
4150
+ function Gs(e, t, n) {
4151
+ return e.kind === "value" ? (t == null ? void 0 : t(e.value)) ?? "" : e.kind === "null" ? n.nullText : n.emptyText;
4152
+ }
4153
+ function Qs(e) {
4154
+ const { path: t, previousPath: n, role: r, repeatLabels: a, levelCount: i } = e;
4155
+ return Array.from({ length: i }, (o, s) => {
4156
+ const c = t.slice(0, s + 1), u = r === "grand_total" ? s === 0 : r === "subtotal" && s === t.length - 1, l = n && n.length > s && nt(n.slice(0, s + 1)) === nt(c);
4157
+ return {
4158
+ path: c,
4159
+ total: u,
4160
+ visible: u || t.length > s && (a || !l || s === t.length - 1)
4161
+ };
4162
+ });
4163
+ }
4164
+ function Ro(e) {
4165
+ return (e == null ? void 0 : e.type) === "date" ? { type: "raw_temporal", timezone: e.timezone, sourceTimezone: e.sourceTimezone, presentation: to(e) } : void 0;
4166
+ }
4167
+ function Lo(e, t) {
4168
+ return Fi(Xe({ override: e, model: t }).format, {
4169
+ preserveOmittedProperties: !0,
4170
+ numericInput: "canonical"
4171
+ });
4172
+ }
4173
+ function Js(e, t, n) {
4174
+ const r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = (o, s) => {
4175
+ const c = (s === "levels" ? t.levelFormats : t.measureFormats)[o.id], u = o.semanticFormat, l = Lo(c, u);
4176
+ s === "measures" && r.set(o.id, {
4177
+ isNumeric: Rn(o.column.dataType) === "number",
4178
+ // Use normalized affixes: a redundant percent suffix is already removed.
4179
+ hasTextAffixes: !!l && !!("prefix" in l && l.prefix || "suffix" in l && l.suffix)
4180
+ });
4181
+ const f = (m) => ln(m, void 0, {
4182
+ useFormattedValues: !0,
4183
+ timezone: n.calendar.tz,
4184
+ locale: n.valueFormat.locale,
4185
+ absence: t.absence
4186
+ });
4187
+ if (o.column.temporalBucket) {
4188
+ const m = o.column.temporalBucket, h = _n({
4189
+ metadata: m,
4190
+ cardFormat: (c == null ? void 0 : c.type) === "temporal_bucket" ? c : void 0,
4191
+ semanticFormat: (u == null ? void 0 : u.type) === "temporal_bucket" ? { granularity: m.granularity, format: u } : void 0,
4192
+ locale: n.valueFormat.locale,
4193
+ styles: { dateStyle: n.valueFormat.dateStyle, dateTime: n.valueFormat.dateTime }
4194
+ });
4195
+ return (d) => typeof d == "string" ? In({ value: d, metadata: m, format: h.format }) : f(d);
4196
+ }
4197
+ if (o.column.rawTemporal) {
4198
+ const m = Xe({ override: c, model: u }).format, { formatValue: h } = vo({
4199
+ authored: Ro(m),
4200
+ metadata: o.column.rawTemporal,
4201
+ preferences: n.valueFormat,
4202
+ calendar: n.calendar
4203
+ });
4204
+ return (d) => {
4205
+ if (typeof d != "string") return f(d);
4206
+ const S = h(d);
4207
+ return S.ok ? S.text : f(d);
4208
+ };
4209
+ }
4210
+ if (G(l)) {
4211
+ const m = Ki(l, n.valueFormat);
4212
+ return s === "measures" && a.set(o.id, m), (h) => typeof h == "number" || typeof h == "object" && h !== null ? Ze(h, m) : f(h);
4213
+ }
4214
+ return (l == null ? void 0 : l.type) === "duration" && s === "measures" && a.set(o.id, l), (l == null ? void 0 : l.type) === "duration" ? (m) => typeof m == "number" || typeof m == "string" || typeof m == "object" && m !== null ? qt(
4215
+ typeof m == "object" ? m.value : m,
4216
+ l
4217
+ ) : f(m) : (l == null ? void 0 : l.type) === "string" ? (m) => m === null ? f(m) : `${l.prefix ?? ""}${f(m)}${l.suffix ?? ""}` : f;
4218
+ };
4219
+ return {
4220
+ levels: new Map(
4221
+ e.levels.map((o) => [o.id, i(o, "levels")])
4222
+ ),
4223
+ measures: new Map(
4224
+ e.measures.map((o) => [o.id, i(o, "measures")])
4225
+ ),
4226
+ measureSemantics: r,
4227
+ measureFormats: a,
4228
+ absence: t.absence
4229
+ };
4230
+ }
4231
+ function ec(e, t) {
4232
+ return t.levelLabels[e.id] ?? e.field.label ?? e.field.name;
4233
+ }
4234
+ function tc(e, t) {
4235
+ return t.measureLabels[e.id] ?? (e.kind === "aggregate" ? e.field.label ?? e.field.name : e.definition.label);
4236
+ }
4237
+ function nc(e) {
4238
+ return qn.parse(Wo(e));
4239
+ }
4240
+ function Wo(e) {
4241
+ const t = Wn.parse(e), n = (r) => ({
4242
+ grand: { visible: !0, position: "after" },
4243
+ levels: Object.fromEntries(
4244
+ r.map((a) => [
4245
+ a.id,
4246
+ { visible: !0, position: "before" }
4247
+ ])
4248
+ )
4249
+ });
4250
+ return jn.parse({
4251
+ version: 1,
4252
+ spec: t,
4253
+ presentation: {
4254
+ layout: { kind: "compact" },
4255
+ absence: { emptyText: "—", nullText: "" },
4256
+ levelLabels: {},
4257
+ measureLabels: {},
4258
+ levelFormats: {},
4259
+ measureFormats: {},
4260
+ totals: { rows: n(t.rows), columns: n(t.columns) }
4261
+ },
4262
+ defaultView: {
4263
+ rows: { depth: 0, overrides: [] },
4264
+ columns: { depth: t.columns.length > 1 ? 1 : 0, overrides: [] }
4265
+ }
4266
+ });
4267
+ }
4268
+ function jo(e, t) {
4269
+ const n = new Map(e.map((r) => [q(r), r]));
4270
+ for (const r of t ?? []) n.set(q(r), r);
4271
+ return [...n.values()];
4272
+ }
4273
+ function rc(e) {
4274
+ const { spec: t, presentation: n, defaults: r, session: a } = Hn.parse(e), i = new Map(
4275
+ jo(t.sorts, a == null ? void 0 : a.sorts).map((s) => [q(s), s])
4276
+ );
4277
+ for (const s of ["rows", "columns"])
4278
+ for (const c of t[s]) {
4279
+ const u = {
4280
+ axis: s,
4281
+ levelId: c.id,
4282
+ scope: { kind: "level" },
4283
+ target: { kind: "member" },
4284
+ direction: "asc",
4285
+ nulls: "last"
4286
+ };
4287
+ i.has(q(u)) || i.set(q(u), u);
4288
+ }
4289
+ const o = (s, c) => ({
4290
+ depth: Math.min(s.depth, Math.max(0, c - 1)),
4291
+ // Leaf toggles are valid but have no effect. Collapsed ancestors retain dormant overrides.
4292
+ overrides: s.overrides.filter(
4293
+ (u) => u.path.length < c
4294
+ )
4295
+ });
4296
+ return {
4297
+ spec: { ...t, sorts: [...i.values()] },
4298
+ presentation: n,
4299
+ view: {
4300
+ rows: o((a == null ? void 0 : a.rows) ?? r.rows, t.rows.length),
4301
+ columns: o(
4302
+ (a == null ? void 0 : a.columns) ?? r.columns,
4303
+ t.columns.length
4304
+ ),
4305
+ sorts: (a == null ? void 0 : a.sorts) ?? []
4306
+ }
4307
+ };
4308
+ }
4309
+ class Ut extends Error {
4310
+ constructor(n) {
4311
+ super(
4312
+ `invalid_presentation_execution_snapshot: ${n} Resave this report before running it again.`
4313
+ );
4314
+ $(this, "code", "invalid_presentation_execution_snapshot");
4315
+ $(this, "deliveryBlocking", !0);
4316
+ this.name = "PresentationExecutionSnapshotError";
4317
+ }
4318
+ }
4319
+ class ac extends Error {
4320
+ constructor(n) {
4321
+ super(
4322
+ `missing_resolved_raw_temporal_format: Column "${n}" has no captured presentation. Resave this report before running it again.`
4323
+ );
4324
+ $(this, "code", "missing_resolved_raw_temporal_format");
4325
+ $(this, "deliveryBlocking", !0);
4326
+ this.name = "MissingResolvedRawTemporalFormatError";
4327
+ }
4328
+ }
4329
+ function F(e, t, n) {
4330
+ const r = new Set(t), a = Object.keys(e).find((i) => !r.has(i));
4331
+ if (a)
4332
+ throw new Error(`${n} contains unknown property "${a}"`);
4333
+ }
4334
+ function Ho(e, t = "scope") {
4335
+ if (!T(e))
4336
+ throw new Error(`${t} must be an object`);
4337
+ F(
4338
+ e,
4339
+ ["dashboardId", "cardId", "attachmentIndex"],
4340
+ t
4341
+ );
4342
+ const n = typeof e.dashboardId == "string" ? e.dashboardId.trim() : "";
4343
+ if (!n)
4344
+ throw new Error(`${t}.dashboardId is required`);
4345
+ const r = typeof e.cardId == "string" ? e.cardId.trim() : void 0;
4346
+ if (e.cardId !== void 0 && !r)
4347
+ throw new Error(`${t}.cardId must be a non-empty string`);
4348
+ const a = e.attachmentIndex;
4349
+ if (a !== void 0 && (typeof a != "number" || !Number.isInteger(a) || a < 0))
4350
+ throw new Error(
4351
+ `${t}.attachmentIndex must be a non-negative integer`
4352
+ );
4353
+ return {
4354
+ dashboardId: n,
4355
+ ...r ? { cardId: r } : {},
4356
+ ...typeof a == "number" ? { attachmentIndex: a } : {}
4357
+ };
4358
+ }
4359
+ function z(e, t, n, r) {
4360
+ if (e.kind !== t) return;
4361
+ F(e, ["kind", n], r);
4362
+ const a = e[n];
4363
+ if (typeof a != "string" || !a.trim())
4364
+ throw new Error(`${r}.${n} is required`);
4365
+ return a;
4366
+ }
4367
+ function ze(e, t) {
4368
+ if (!T(e))
4369
+ throw new Error(`${t} must be an object`);
4370
+ const n = z(e, "metric", "metricId", t);
4371
+ if (n) return { kind: "metric", metricId: n };
4372
+ const r = z(e, "column", "columnKey", t);
4373
+ if (r) return { kind: "column", columnKey: r };
4374
+ const a = z(
4375
+ e,
4376
+ "matrix_measure",
4377
+ "measureId",
4378
+ t
4379
+ );
4380
+ if (a) return { kind: "matrix_measure", measureId: a };
4381
+ throw new Error(`${t} is not a valid numeric presentation target`);
4382
+ }
4383
+ const qo = [
4384
+ "type",
4385
+ "inputUnit",
4386
+ "outputStyle",
4387
+ "largestUnit",
4388
+ "smallestUnit",
4389
+ "maxUnits",
4390
+ "prefix",
4391
+ "suffix",
4392
+ "negativeStyle"
4393
+ ];
4394
+ function Zo(e) {
4395
+ return e === "millisecond" || e === "second" || e === "minute" || e === "hour" || e === "day";
4396
+ }
4397
+ const Ko = ["type", "locale", "pattern", "timezone", "sourceTimezone"];
4398
+ function Vo(e, t) {
4399
+ if (F(e, Ko, t), typeof e.locale != "string" || !e.locale.trim())
4400
+ throw new Error(`${t}.locale must be a non-empty string`);
4401
+ for (const n of ["pattern", "timezone", "sourceTimezone"])
4402
+ if (e[n] !== void 0 && typeof e[n] != "string")
4403
+ throw new Error(`${t}.${n} must be a string`);
4404
+ return {
4405
+ type: "date",
4406
+ locale: e.locale,
4407
+ ...typeof e.pattern == "string" ? { pattern: e.pattern } : {},
4408
+ ...typeof e.timezone == "string" ? { timezone: e.timezone } : {},
4409
+ ...typeof e.sourceTimezone == "string" ? { sourceTimezone: e.sourceTimezone } : {}
4410
+ };
4411
+ }
4412
+ function Bo(e, t) {
4413
+ F(e, qo, t);
4414
+ for (const i of ["inputUnit", "largestUnit", "smallestUnit"])
4415
+ if (e[i] !== void 0 && !Zo(e[i]))
4416
+ throw new Error(`${t}.${i} must be a duration unit`);
4417
+ const n = e.outputStyle;
4418
+ if (n !== void 0 && n !== "compact" && n !== "digital" && n !== "long")
4419
+ throw new Error(`${t}.outputStyle must be compact, digital, or long`);
4420
+ const r = e.maxUnits;
4421
+ if (r !== void 0 && (typeof r != "number" || !Number.isInteger(r) || r < 0 || r > 10))
4422
+ throw new Error(`${t}.maxUnits must be an integer from 0 to 10`);
4423
+ for (const i of ["prefix", "suffix"])
4424
+ if (e[i] !== void 0 && typeof e[i] != "string")
4425
+ throw new Error(`${t}.${i} must be a string`);
4426
+ const a = e.negativeStyle;
4427
+ if (a !== void 0 && a !== "minus" && a !== "parentheses")
4428
+ throw new Error(`${t}.negativeStyle must be minus or parentheses`);
4429
+ return {
4430
+ type: "duration",
4431
+ ...e.inputUnit !== void 0 ? { inputUnit: e.inputUnit } : {},
4432
+ ...n !== void 0 ? { outputStyle: n } : {},
4433
+ ...e.largestUnit !== void 0 ? { largestUnit: e.largestUnit } : {},
4434
+ ...e.smallestUnit !== void 0 ? { smallestUnit: e.smallestUnit } : {},
4435
+ ...r !== void 0 ? { maxUnits: r } : {},
4436
+ ...e.prefix !== void 0 ? { prefix: e.prefix } : {},
4437
+ ...e.suffix !== void 0 ? { suffix: e.suffix } : {},
4438
+ ...a !== void 0 ? { negativeStyle: a } : {}
4439
+ };
4440
+ }
4441
+ function Xo(e, t) {
4442
+ if (!T(e))
4443
+ throw new Error(`${t} must be an object`);
4444
+ if (e.kind === "field") {
4445
+ F(e, ["kind", "fieldId", "role"], t);
4446
+ const a = typeof e.fieldId == "string" ? e.fieldId.trim() : "";
4447
+ if (!a)
4448
+ throw new Error(`${t}.fieldId is required`);
4449
+ const i = e.role;
4450
+ if (i !== void 0 && i !== "groupby" && i !== "pivotby")
4451
+ throw new Error(`${t}.role must be groupby or pivotby`);
4452
+ return {
4453
+ kind: "field",
4454
+ fieldId: a,
4455
+ ...i ? { role: i } : {}
4456
+ };
4457
+ }
4458
+ const n = z(e, "column", "columnKey", t);
4459
+ if (n) return { kind: "column", columnKey: n };
4460
+ const r = z(
4461
+ e,
4462
+ "matrix_axis",
4463
+ "axisInstanceId",
4464
+ t
4465
+ );
4466
+ if (r) return { kind: "matrix_axis", axisInstanceId: r };
4467
+ throw new Error(`${t} is not a valid temporal bucket presentation target`);
4468
+ }
4469
+ function Go(e, t) {
4470
+ if (!T(e))
4471
+ throw new Error(`${t} must be an object`);
4472
+ const n = z(e, "column", "columnKey", t);
4473
+ if (!n)
4474
+ throw new Error(`${t} must identify a column`);
4475
+ return { kind: "column", columnKey: n };
4476
+ }
4477
+ function Qo(e) {
4478
+ return [
4479
+ e.dashboardId,
4480
+ e.cardId ?? null,
4481
+ e.attachmentIndex ?? null
4482
+ ];
4483
+ }
4484
+ function De(e) {
4485
+ switch (e.kind) {
4486
+ case "metric":
4487
+ return [e.kind, e.metricId];
4488
+ case "column":
4489
+ return [e.kind, e.columnKey];
4490
+ case "matrix_measure":
4491
+ return [e.kind, e.measureId];
4492
+ case "field":
4493
+ return [e.kind, e.fieldId, e.role ?? ""];
4494
+ case "matrix_axis":
4495
+ return [e.kind, e.axisInstanceId];
4496
+ }
4497
+ }
4498
+ function ve(e, t) {
4499
+ return e.dashboardId === t.dashboardId && e.cardId === t.cardId && e.attachmentIndex === t.attachmentIndex;
4500
+ }
4501
+ function Se(e, t) {
4502
+ const n = De(e), r = De(t);
4503
+ return n.length === r.length && n.every((a, i) => a === r[i]);
4504
+ }
4505
+ function Jo(e) {
4506
+ if (!Array.isArray(e))
4507
+ throw new Error("resolvedFormats must be an array");
4508
+ const t = /* @__PURE__ */ new Set();
4509
+ return e.map((n, r) => {
4510
+ var c, u;
4511
+ const a = `resolvedFormats.${r}`;
4512
+ if (!T(n))
4513
+ throw new Error(`${a} must be an object`);
4514
+ F(n, ["scope", "target", "format"], a);
4515
+ const i = Ho(n.scope, `${a}.scope`);
4516
+ if (!T(n.format))
4517
+ throw new Error(`${a}.format must be an object`);
4518
+ let o;
4519
+ switch (n.format.type) {
4520
+ case "temporal_bucket": {
4521
+ const l = Mn(n.format);
4522
+ if (!l.ok)
4523
+ throw new Error(
4524
+ `${a}.format is invalid: ${((c = l.issues[0]) == null ? void 0 : c.message) ?? "invalid value"}`
4525
+ );
4526
+ o = {
4527
+ scope: i,
4528
+ target: Xo(n.target, `${a}.target`),
4529
+ format: l.value
4530
+ };
4531
+ break;
4532
+ }
4533
+ case "raw_temporal":
4534
+ o = {
4535
+ scope: i,
4536
+ target: Go(n.target, `${a}.target`),
4537
+ format: Ge(n.format)
4538
+ };
4539
+ break;
4540
+ case "number":
4541
+ case "currency":
4542
+ case "percent":
4543
+ case "scientific": {
4544
+ const l = Hi(n.format);
4545
+ if (!l.ok)
4546
+ throw new Error(
4547
+ `${a}.format is invalid: ${((u = l.issues[0]) == null ? void 0 : u.message) ?? "invalid value"}`
4548
+ );
4549
+ o = {
4550
+ scope: i,
4551
+ target: ze(n.target, `${a}.target`),
4552
+ format: l.value
4553
+ };
4554
+ break;
4555
+ }
4556
+ case "date": {
4557
+ const l = ze(n.target, `${a}.target`);
4558
+ if (l.kind !== "column")
4559
+ throw new Error(`${a}.target must identify a column for a date format`);
4560
+ o = {
4561
+ scope: i,
4562
+ target: l,
4563
+ format: Vo(n.format, `${a}.format`)
4564
+ };
4565
+ break;
4566
+ }
4567
+ case "duration":
4568
+ o = {
4569
+ scope: i,
4570
+ target: ze(n.target, `${a}.target`),
4571
+ format: Bo(
4572
+ n.format,
4573
+ `${a}.format`
4574
+ )
4575
+ };
4576
+ break;
4577
+ default:
4578
+ throw new Error(`${a}.format.type is unsupported`);
4579
+ }
4580
+ const s = JSON.stringify([
4581
+ ...Qo(o.scope),
4582
+ ...De(o.target)
4583
+ ]);
4584
+ if (t.has(s))
4585
+ throw new Error(
4586
+ `${a} duplicates a scoped presentation target`
4587
+ );
4588
+ return t.add(s), o;
4589
+ });
4590
+ }
4591
+ function es(e) {
4592
+ try {
4593
+ if (!T(e))
4594
+ throw new Error("presentation execution snapshot must be an object");
4595
+ if (F(
4596
+ e,
4597
+ ["version", "reportContext", "resolvedFormats"],
4598
+ "presentation execution snapshot"
4599
+ ), e.version !== 1)
4600
+ throw new Error("presentation execution snapshot version must be 1");
4601
+ const t = Kn(e.reportContext);
4602
+ if (!t.ok) {
4603
+ const n = t.issues[0];
4604
+ throw new Error(
4605
+ `presentation execution snapshot reportContext is invalid: ${n != null && n.path && n.path !== "$" ? `${n.path}: ` : ""}${(n == null ? void 0 : n.message) ?? "invalid value"}`
4606
+ );
4607
+ }
4608
+ return {
4609
+ version: 1,
4610
+ reportContext: t.value,
4611
+ resolvedFormats: Jo(e.resolvedFormats)
4612
+ };
4613
+ } catch (t) {
4614
+ throw t instanceof Ut ? t : new Ut(
4615
+ t instanceof Error ? t.message : "Snapshot is invalid."
4616
+ );
4617
+ }
4618
+ }
4619
+ function ic(e) {
4620
+ return es({
4621
+ version: 1,
4622
+ reportContext: e.reportContext,
4623
+ resolvedFormats: [...e.resolvedFormats]
4624
+ });
4625
+ }
4626
+ function oc(e) {
4627
+ const t = ts(e);
4628
+ return G(t) ? t : void 0;
4629
+ }
4630
+ function ts(e) {
4631
+ const t = e.snapshot.resolvedFormats.find(
4632
+ (n) => n.format.type !== "temporal_bucket" && n.format.type !== "raw_temporal" && n.format.type !== "date" && ve(n.scope, e.scope) && Se(n.target, e.target)
4633
+ );
4634
+ return t == null ? void 0 : t.format;
4635
+ }
4636
+ function sc(e) {
4637
+ const t = e.snapshot.resolvedFormats.find(
4638
+ (n) => n.format.type === "date" && ve(n.scope, e.scope) && Se(n.target, e.target)
4639
+ );
4640
+ return t == null ? void 0 : t.format;
4641
+ }
4642
+ function cc(e) {
4643
+ const t = e.snapshot.resolvedFormats.find(
4644
+ (n) => n.format.type === "raw_temporal" && ve(n.scope, e.scope) && Se(n.target, e.target)
4645
+ );
4646
+ return t == null ? void 0 : t.format;
4647
+ }
4648
+ function uc(e) {
4649
+ const t = e.snapshot.resolvedFormats.find(
4650
+ (n) => n.format.type === "temporal_bucket" && ve(n.scope, e.scope) && Se(n.target, e.target)
4651
+ );
4652
+ return t == null ? void 0 : t.format;
4653
+ }
4654
+ function lc(e) {
4655
+ var a;
4656
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
4657
+ if (e.snapshot.resolvedFormats.forEach((i, o) => {
4658
+ if (i.scope.attachmentIndex !== void 0)
4659
+ throw new Error(
4660
+ `resolvedFormats.${o}.scope.attachmentIndex is not valid for a card export`
4661
+ );
4662
+ if (i.scope.dashboardId !== e.expectedScope.dashboardId || i.scope.cardId !== e.expectedScope.cardId)
4663
+ throw new Error(
4664
+ `resolvedFormats.${o}.scope must match the executing dashboard/card`
4665
+ );
4666
+ if (i.target.kind === "field" && i.format.type === "temporal_bucket") {
4667
+ const s = JSON.stringify(De(i.target));
4668
+ if (n.has(s))
4669
+ throw new Error(
4670
+ `resolvedFormats.${o} duplicates export field "${i.target.fieldId}"`
4671
+ );
4672
+ n.add(s);
4673
+ return;
4674
+ }
4675
+ if (i.target.kind !== "column")
4676
+ throw new Error(
4677
+ `resolvedFormats.${o}.target must identify an export column or temporal pivot field`
4678
+ );
4679
+ if (t.has(i.target.columnKey))
4680
+ throw new Error(
4681
+ `resolvedFormats.${o} duplicates export column "${i.target.columnKey}"`
4682
+ );
4683
+ t.add(i.target.columnKey);
4684
+ }), !e.useFormattedValues) return;
4685
+ if (!((a = e.visibleColumns) != null && a.length))
4686
+ throw new Error("visibleColumns must identify every formatted export column");
4687
+ const r = e.visibleColumns.find(
4688
+ (i) => !t.has(i)
4689
+ );
4690
+ if (r)
4691
+ throw new Error(
4692
+ `resolvedFormats is missing visible export column "${r}"`
4693
+ );
4694
+ }
4695
+ const ns = /* @__PURE__ */ new Set(["short", "medium", "long"]), rs = /^(\d{4})-(\d{2})-(\d{2})$/, as = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/, is = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/, Je = " – ";
4696
+ function mc(e) {
4697
+ if (!T(e)) return;
4698
+ const t = Object.keys(e);
4699
+ if (e.mode === "period_label" && t.length === 1)
4700
+ return { mode: "period_label" };
4701
+ if (e.mode === "style" && t.length === 2 && typeof e.dateStyle == "string" && ns.has(e.dateStyle))
4702
+ return { mode: "style", dateStyle: e.dateStyle };
4703
+ if (e.mode === "pattern" && t.length === 3 && e.dialect === "semaphor_tokens" && typeof e.pattern == "string" && os(e.pattern) === null)
4704
+ return {
4705
+ mode: "pattern",
4706
+ dialect: "semaphor_tokens",
4707
+ pattern: e.pattern
4708
+ };
4709
+ }
4710
+ function os(e) {
4711
+ try {
4712
+ return po({ dialect: "semaphor_tokens", pattern: e }), null;
4713
+ } catch (t) {
4714
+ return t instanceof Error ? t.message : "The pattern is invalid.";
4715
+ }
4716
+ }
4717
+ function fc(e) {
4718
+ const { value: t, part: n, presentation: r, preferences: a, calendar: i } = e;
4719
+ if ((r == null ? void 0 : r.mode) === "period_label" && t.periodLabel && n === "range")
4720
+ return { ok: !0, text: t.periodLabel };
4721
+ const [o, s] = t.bounds, u = s === void 0 || n === "start" ? [{ raw: o, role: "start" }] : n === "end" ? [{ raw: s, role: "end" }] : [
4722
+ { raw: o, role: "start" },
4723
+ { raw: s, role: "end" }
4724
+ ], l = u.map(({ raw: d }) => ls(d, i.tz));
4725
+ if (l.some((d) => d === null))
4726
+ return {
4727
+ ok: !1,
4728
+ text: u.map(({ raw: d }) => d).join(Je),
4729
+ diagnostic: {
4730
+ code: "invalid_temporal_input_value",
4731
+ message: "A date input bound is not a date or an instant."
4732
+ }
4733
+ };
4734
+ const f = t.precision === "day" ? l.map(
4735
+ (d, S) => fs(d, u[S].role, i.tz)
4736
+ ) : [], m = f.length > 0 && f.every((d) => d !== null) ? f : null;
4737
+ return { ok: !0, text: m ? ss(m, r, a, i) : cs(
4738
+ l.map((d) => ms(d, i.tz)),
4739
+ r,
4740
+ a,
4741
+ i
4742
+ ) };
4743
+ }
4744
+ function ss(e, t, n, r) {
4745
+ const [a, i = a] = e;
4746
+ if ((t == null ? void 0 : t.mode) === "pattern")
4747
+ return Cn(
4748
+ e.map(
4749
+ (c) => En(He(c), "date", t.pattern, n, r)
4750
+ )
4751
+ );
4752
+ const o = (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : n.dateStyle;
4753
+ if (!t || t.mode === "period_label") {
4754
+ const c = ds(a, i, r);
4755
+ if (c)
4756
+ return In({
4757
+ value: He(a),
4758
+ metadata: {
4759
+ kind: "temporal_bucket",
4760
+ granularity: c,
4761
+ calendar: { tz: r.tz, weekStart: r.weekStart ?? 1 }
4762
+ },
4763
+ format: _n({
4764
+ metadata: {
4765
+ kind: "temporal_bucket",
4766
+ granularity: c,
4767
+ calendar: { tz: r.tz, weekStart: r.weekStart ?? 1 }
4768
+ },
4769
+ locale: n.locale,
4770
+ styles: { dateStyle: o, dateTime: { ...n.dateTime } }
4771
+ }).format
4772
+ });
4773
+ }
4774
+ const s = new Intl.DateTimeFormat(n.locale, {
4775
+ calendar: "gregory",
4776
+ timeZone: "UTC",
4777
+ dateStyle: o
4778
+ });
4779
+ return gs(a, i) ? s.format(me(a)) : Fn(s, me(a), me(i));
4780
+ }
4781
+ function cs(e, t, n, r) {
4782
+ if ((t == null ? void 0 : t.mode) === "pattern")
4783
+ return Cn(
4784
+ e.map(
4785
+ (s) => En(
4786
+ s.toISOString(),
4787
+ "instant",
4788
+ t.pattern,
4789
+ n,
4790
+ r
4791
+ )
4792
+ )
4793
+ );
4794
+ const a = new Intl.DateTimeFormat(n.locale, {
4795
+ calendar: "gregory",
4796
+ timeZone: r.tz,
4797
+ dateStyle: (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : n.dateTime.dateStyle,
4798
+ timeStyle: n.dateTime.timeStyle
4799
+ }), [i, o] = e;
4800
+ return o && o.getTime() !== i.getTime() ? Fn(a, i, o) : a.format(i);
4801
+ }
4802
+ function Fn(e, t, n) {
4803
+ const r = e;
4804
+ return typeof r.formatRange == "function" ? r.formatRange(t, n) : `${e.format(t)}${Je}${e.format(n)}`;
4805
+ }
4806
+ function En(e, t, n, r, a) {
4807
+ const i = wn({
4808
+ format: {
4809
+ type: "raw_temporal",
4810
+ presentation: { mode: "pattern", dialect: "semaphor_tokens", pattern: n }
4811
+ },
4812
+ // Temporal formatting reads no currency.
4813
+ preferences: {
4814
+ ...r,
4815
+ defaultCurrency: Vn.defaultCurrency
4816
+ },
4817
+ calendar: { tz: a.tz }
4818
+ }), o = t === "date" && us(n) ? "instant" : t;
4819
+ return xo({
4820
+ value: o === t ? e : J(`${e}T00:00:00`, a.tz).toISOString(),
4821
+ metadata: { kind: "raw_temporal", valueKind: o },
4822
+ format: i
4823
+ }).text;
4824
+ }
4825
+ function us(e) {
4826
+ return /HH|mm|ss/.test(e);
4827
+ }
4828
+ function Cn(e) {
4829
+ return e[1] === void 0 || e[0] === e[1] ? e[0] : e.join(Je);
4830
+ }
4831
+ function ls(e, t) {
4832
+ const n = rs.exec(e);
4833
+ if (n) {
4834
+ const a = {
4835
+ year: Number(n[1]),
4836
+ month: Number(n[2]),
4837
+ day: Number(n[3])
4838
+ };
4839
+ return ys(a) ? { kind: "date", date: a } : null;
4840
+ }
4841
+ const r = is.test(e) ? new Date(e.replace(" ", "T")) : as.test(e) ? J(e.replace(" ", "T"), t) : null;
4842
+ return r && !Number.isNaN(r.getTime()) ? { kind: "instant", instant: r } : null;
4843
+ }
4844
+ function ms(e, t) {
4845
+ return e.kind === "instant" ? e.instant : J(`${He(e.date)}T00:00:00`, t);
4846
+ }
4847
+ function fs(e, t, n) {
4848
+ if (e.kind === "date") return e.date;
4849
+ const r = Xn(e.instant, n), a = { year: r.year, month: r.month, day: r.day };
4850
+ if (r.hour === 0 && r.minute === 0 && r.second === 0 && e.instant.getUTCMilliseconds() === 0) return t === "start" ? a : hs(a, -1);
4851
+ const o = r.hour === 23 && r.minute === 59 && r.second === 59;
4852
+ return t === "end" && o ? a : null;
4853
+ }
4854
+ function ds(e, t, n) {
4855
+ return n.fiscalCalendar || e.day !== 1 || e.year !== t.year || t.day !== Pn(t.year, t.month) ? null : e.month === t.month ? "month" : e.month % 3 === 1 && t.month === e.month + 2 ? "quarter" : e.month === 1 && t.month === 12 ? "year" : null;
4856
+ }
4857
+ function He(e) {
4858
+ return `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
4859
+ }
4860
+ function me(e) {
4861
+ const t = /* @__PURE__ */ new Date(0);
4862
+ return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(0, 0, 0, 0), t;
4863
+ }
4864
+ function hs(e, t) {
4865
+ const n = me(e);
4866
+ return n.setUTCDate(n.getUTCDate() + t), {
4867
+ year: n.getUTCFullYear(),
4868
+ month: n.getUTCMonth() + 1,
4869
+ day: n.getUTCDate()
4870
+ };
4871
+ }
4872
+ function gs(e, t) {
4873
+ return e.year === t.year && e.month === t.month && e.day === t.day;
4874
+ }
4875
+ function Pn(e, t) {
4876
+ return new Date(Date.UTC(e, t, 0)).getUTCDate();
4877
+ }
4878
+ function ys(e) {
4879
+ return e.year >= 1 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= Pn(e.year, e.month);
4880
+ }
4881
+ export {
4882
+ lc as $,
4883
+ zs as A,
4884
+ we as B,
4885
+ P as C,
4886
+ As as D,
4887
+ Us as E,
4888
+ Si as F,
4889
+ Mi as G,
4890
+ Rs as H,
4891
+ ki as I,
4892
+ Ls as J,
4893
+ Js as K,
4894
+ ji as L,
4895
+ Di as M,
4896
+ Hi as N,
4897
+ js as O,
4898
+ qi as P,
4899
+ Ki as Q,
4900
+ Ut as R,
4901
+ ac as S,
4902
+ Ho as T,
4903
+ Jo as U,
4904
+ es as V,
4905
+ ic as W,
4906
+ oc as X,
4907
+ sc as Y,
4908
+ cc as Z,
4909
+ uc as _,
4910
+ Ns as a,
4911
+ Ro as a$,
4912
+ Vi as a0,
4913
+ Xi as a1,
4914
+ ee as a2,
4915
+ fn as a3,
4916
+ Hs as a4,
4917
+ So as a5,
4918
+ le as a6,
4919
+ Sn as a7,
4920
+ Vs as a8,
4921
+ Mn as a9,
4922
+ un as aA,
4923
+ Is as aB,
4924
+ Ni as aC,
4925
+ tc as aD,
4926
+ nc as aE,
4927
+ Wo as aF,
4928
+ jo as aG,
4929
+ Ke as aH,
4930
+ _i as aI,
4931
+ lr as aJ,
4932
+ Ma as aK,
4933
+ L as aL,
4934
+ nn as aM,
4935
+ se as aN,
4936
+ p as aO,
4937
+ Dr as aP,
4938
+ ge as aQ,
4939
+ ct as aR,
4940
+ re as aS,
4941
+ Os as aT,
4942
+ Jt as aU,
4943
+ yr as aV,
4944
+ Lo as aW,
4945
+ $t as aX,
4946
+ O as aY,
4947
+ Nt as aZ,
4948
+ kt as a_,
4949
+ _n as aa,
4950
+ Bs as ab,
4951
+ In as ac,
4952
+ to as ad,
4953
+ U as ae,
4954
+ Ge as af,
4955
+ wn as ag,
4956
+ so as ah,
4957
+ qs as ai,
4958
+ Zs as aj,
4959
+ co as ak,
4960
+ Ks as al,
4961
+ po as am,
4962
+ vn as an,
4963
+ xo as ao,
4964
+ vo as ap,
4965
+ mc as aq,
4966
+ os as ar,
4967
+ fc as as,
4968
+ rc as at,
4969
+ _s as au,
4970
+ Ao as av,
4971
+ Xs as aw,
4972
+ Qs as ax,
4973
+ Gs as ay,
4974
+ ec as az,
4975
+ Fi as b,
4976
+ Uo as b0,
4977
+ J as b1,
4978
+ ks as c,
4979
+ qe as d,
4980
+ Bt as e,
4981
+ ts as f,
4982
+ Xt as g,
4983
+ Gt as h,
4984
+ G as i,
4985
+ Ze as j,
4986
+ mr as k,
4987
+ $s as l,
4988
+ qt as m,
4989
+ Zt as n,
4990
+ pi as o,
4991
+ Xe as p,
4992
+ wi as q,
4993
+ Ai as r,
4994
+ Ps as s,
4995
+ Fs as t,
4996
+ Es as u,
4997
+ Cs as v,
4998
+ Ws as w,
4999
+ Be as x,
5000
+ ln as y,
5001
+ Ys as z
5002
+ };