react-semaphor 0.1.560 → 0.1.562

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 (168) hide show
  1. package/dist/analytics-protocol/index.js +450 -423
  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-BaIQrEzX.js} +221 -188
  7. package/dist/chunks/{assistant-chat-Bu2fFm_I.js → assistant-chat-R_yT8xH4.js} +116 -117
  8. package/dist/chunks/bookmark-impact-D4Kl4amw.js +75 -0
  9. package/dist/chunks/bookmark-state-CWeoGbrx.js +743 -0
  10. package/dist/chunks/{braces-Da41xfUd.js → braces-DzgoQC64.js} +1 -1
  11. package/dist/chunks/{comparison-window-caption-4FNkMrzE.js → comparison-window-caption-D1EUXzaR.js} +550 -425
  12. package/dist/chunks/{context-BgPDzLHZ.js → context-R31TSL5V.js} +1 -1
  13. package/dist/chunks/{dashboard-_MeBuy67.js → dashboard-Bp1y5oun.js} +1 -1
  14. package/dist/chunks/{dashboard-briefing-launcher-CEi4Pr_v.js → dashboard-briefing-launcher-S5FB3aUW.js} +236 -236
  15. package/dist/chunks/dashboard-controls-CfC_6Ztn.js +2277 -0
  16. package/dist/chunks/{dashboard-json-B1mU_OMa.js → dashboard-json-gYZT7ZQY.js} +5 -5
  17. package/dist/chunks/dates-DFY7Gfss.js +91 -0
  18. package/dist/chunks/{edit-dashboard-visual-0CJN31Y3.js → edit-dashboard-visual-u7OI_g8Q.js} +7119 -7198
  19. package/dist/chunks/filter-reach-copy-CvV7W5dd.js +3965 -0
  20. package/dist/chunks/{filter-value-text-CRC-K_l_.js → filter-value-text-CPwFkrMz.js} +11 -10
  21. package/dist/chunks/global-date-filter-utils-N1kcsOFE.js +16722 -0
  22. package/dist/chunks/{index-DtHidOPV.js → index-CNGkfUp4.js} +269 -264
  23. package/dist/chunks/{layout-grid-BvsH4RY2.js → layout-grid-BM65viQh.js} +1 -1
  24. package/dist/chunks/{list-filter-Dg0otx5E.js → list-filter-BoeLBfL3.js} +1 -1
  25. package/dist/chunks/{matrix-analytical-definition-CM18W8w6.js → matrix-analytical-definition-hEucouWM.js} +4 -4
  26. package/dist/chunks/{matrix-card-HPskLaPy.js → matrix-card-CCh9JjP1.js} +3 -3
  27. package/dist/chunks/{matrix-member-presentation-Bbrfrke4.js → matrix-member-presentation-DsAUbuoL.js} +1 -1
  28. package/dist/chunks/{matrix-operation-contract-WPv4R-H_.js → matrix-operation-contract-DsLdFdSa.js} +365 -349
  29. package/dist/chunks/{metric-comparison-ljMKYZKa.js → metric-comparison-Bnso1cm1.js} +6 -6
  30. package/dist/chunks/{model-change-Ccn1zaxl.js → model-change-T1cRkh3m.js} +1 -1
  31. package/dist/chunks/{palette-Bsh376zO.js → palette-p1XSJFgB.js} +1 -1
  32. package/dist/chunks/pivot-result-contract-expectations-B53jqszr.js +56 -0
  33. package/dist/chunks/{pivot-result-identity-vS9TSh4f.js → pivot-result-identity-Dq5jm-EC.js} +1 -1
  34. package/dist/chunks/{zoned-wall-clock-B1n_WjW3.js → raw-temporal-value-Bqz8wc7L.js} +97 -46
  35. package/dist/chunks/{report-preferences-dialog-BV8L0SeS.js → report-preferences-dialog-C4RAR8u5.js} +68 -63
  36. package/dist/chunks/{report-runtime-context-BZQh9ywy.js → report-runtime-context-BITkNSDa.js} +2 -2
  37. package/dist/chunks/resolve-dashboard-input-context-DaDrZGuA.js +8214 -0
  38. package/dist/chunks/{save-B5EAsgQF.js → save-CHV1B1fL.js} +1 -1
  39. package/dist/chunks/{saved-dashboard-context-n2Wn11cV.js → saved-dashboard-context-DFYBrE6O.js} +93 -94
  40. package/dist/chunks/{selection-filter-compiler-BKXmyLrS.js → selection-filter-compiler-CUDRnUxc.js} +19 -18
  41. package/dist/chunks/{selection-reducer-D0YnaAD9.js → selection-reducer-Bz5aywT4.js} +1 -1
  42. package/dist/chunks/{semaphor-ready-indicator-XLBLOJ2V.js → semaphor-ready-indicator-Cfuafnem.js} +38188 -40344
  43. package/dist/chunks/{shelf-drop-preview-context-DHMa54a-.js → shelf-drop-preview-context-BR2GEYog.js} +81 -82
  44. package/dist/chunks/{source-entity-resolution-dUG5VWRm.js → source-entity-resolution-DdDVXFB8.js} +6 -6
  45. package/dist/chunks/{switch-ByxH4M7t.js → switch-BW4yXSYs.js} +3 -3
  46. package/dist/chunks/{table-export-sheet-C_GdeTYU.js → table-export-sheet-bSXxGn-v.js} +1 -1
  47. package/dist/chunks/temporal-input-presentation-sk9gqLi6.js +4960 -0
  48. package/dist/chunks/{token-types-CQtXUVMy.js → token-types-BUK06hU2.js} +1 -1
  49. package/dist/chunks/{upload-wbR-NVzq.js → upload-BnmuyPqW.js} +1 -1
  50. package/dist/chunks/{use-create-flow-overlay-state-CEBaLOKC.js → use-create-flow-overlay-state-DyzhWvRJ.js} +6 -6
  51. package/dist/chunks/{validators-CXTneCA4.js → validators-BIM0FE31.js} +774 -895
  52. package/dist/dashboard/index.js +2 -2
  53. package/dist/dashboard-authoring/index.js +2477 -2685
  54. package/dist/data-app-sdk/index.js +30 -30
  55. package/dist/data-app-sdk-adapters/index.js +3 -3
  56. package/dist/data-app-sdk-validation/index.js +25 -25
  57. package/dist/format-utils/index.js +274 -267
  58. package/dist/index.js +59 -59
  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/briefings/attachment-outcomes.d.ts +1 -1
  63. package/dist/types/components/dashboard/dashboard-create-dialog.d.ts +23 -0
  64. package/dist/types/components/dashboard/summary-number-formatter.d.ts +6 -0
  65. package/dist/types/components/index.d.ts +1 -2
  66. package/dist/types/components/surfboard/filter/types.d.ts +3 -1
  67. package/dist/types/index.js +50 -51
  68. package/dist/types/lib/formatters/kpi-number-formatter.d.ts +41 -0
  69. package/dist/types/lib/formatters/raw-temporal-presentation.d.ts +59 -2
  70. package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +5 -0
  71. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +45 -0
  72. package/dist/types/lib/print/print-inputs.d.ts +2 -1
  73. package/dist/types/lib/query-context/assemble-card-query.d.ts +2 -0
  74. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -0
  75. package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
  76. package/dist/types/lib/stores/editor-store.d.ts +9 -1
  77. package/dist/types/lib/stores/table-actions.d.ts +0 -2
  78. package/dist/types/lib/types/common-types.d.ts +6 -0
  79. package/dist/types/lib/types/explorer-types.d.ts +7 -1
  80. package/dist/types/lib/types/interaction-types.d.ts +3 -1
  81. package/dist/types/lib/types/token-types.d.ts +0 -1
  82. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +13 -1
  83. package/dist/types/shared/analytics-protocol/contracts.d.ts +9 -40
  84. package/dist/types/shared/analytics-protocol/measure-aggregation-profile.d.ts +12 -0
  85. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +12 -2
  86. package/dist/types/shared/analytics-protocol/validators.d.ts +1 -2
  87. package/dist/types/shared/assistant-protocol/context.d.ts +8 -8
  88. package/dist/types/shared/dashboard-authoring/card-formats/sql-date-pattern.d.ts +7 -1
  89. package/dist/types/shared/dashboard-authoring/card-settings/apply-card-settings.d.ts +11 -0
  90. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +76 -0
  91. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +14 -0
  92. package/dist/types/shared/dashboard-authoring/card-settings/carry-column-settings.d.ts +3 -0
  93. package/dist/types/shared/dashboard-authoring/card-settings/column-format-write.d.ts +8 -0
  94. package/dist/types/shared/dashboard-authoring/card-settings/column-names.d.ts +51 -0
  95. package/dist/types/shared/dashboard-authoring/card-settings/column-polarity-write.d.ts +5 -0
  96. package/dist/types/shared/dashboard-authoring/card-settings/column-sources.d.ts +14 -0
  97. package/dist/types/shared/dashboard-authoring/card-settings/confirm-class.d.ts +9 -0
  98. package/dist/types/shared/dashboard-authoring/card-settings/highlight-inputs.d.ts +19 -0
  99. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +17 -0
  100. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +117 -0
  101. package/dist/types/shared/dashboard-authoring/card-settings/read-card-settings.d.ts +10 -0
  102. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +14 -0
  103. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-settings.d.ts +59 -0
  104. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +51 -0
  105. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +30 -0
  106. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
  107. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +32 -0
  108. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +3402 -4313
  109. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +49 -8
  110. package/dist/types/shared/dashboard-authoring/changes/field-ref.d.ts +91 -0
  111. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +7 -0
  112. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +52 -2
  113. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-create.d.ts +26 -0
  114. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +2 -1
  115. package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +1 -8
  116. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +20 -20
  117. package/dist/types/shared/dashboard-authoring/detail-date-presentation.d.ts +9 -0
  118. package/dist/types/shared/dashboard-authoring/index.d.ts +11 -6
  119. package/dist/types/shared/dashboard-authoring/kpi-figure.d.ts +123 -0
  120. package/dist/types/shared/dashboard-authoring/measure-calculations/apply.d.ts +8 -0
  121. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +16 -0
  122. package/dist/types/shared/dashboard-authoring/measure-calculations/dates.d.ts +41 -0
  123. package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +17 -0
  124. package/dist/types/shared/dashboard-authoring/measure-calculations/options.d.ts +63 -0
  125. package/dist/types/shared/dashboard-authoring/measure-calculations/read.d.ts +16 -0
  126. package/dist/types/shared/dashboard-authoring/measure-calculations/resolve.d.ts +79 -0
  127. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +934 -0
  128. package/dist/types/shared/dashboard-authoring/measure-calculations/sentences.d.ts +4 -0
  129. package/dist/types/shared/dashboard-authoring/measure-calculations/set.d.ts +11 -0
  130. package/dist/types/shared/dashboard-authoring/measure-calculations/transform.d.ts +63 -0
  131. package/dist/types/shared/dashboard-authoring/measure-calculations/window-transforms.d.ts +60 -0
  132. package/dist/types/shared/dashboard-authoring/new-card.d.ts +12 -1
  133. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +2 -1
  134. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +46 -0
  135. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +73 -3
  136. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +21 -3
  137. package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +58 -0
  138. package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +55 -0
  139. package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +18 -0
  140. package/dist/types/shared/dashboard-viewer/bookmark-impact.d.ts +33 -0
  141. package/dist/types/shared/format-utils/document-print.d.ts +82 -0
  142. package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +8 -1
  143. package/dist/types/shared/format-utils/index.d.ts +1 -0
  144. package/dist/types/shared/format-utils/raw-temporal.d.ts +18 -7
  145. package/dist/types/shared/temporal/index.d.ts +1 -0
  146. package/dist/types/shared/temporal/raw-temporal-equality.d.ts +19 -0
  147. package/dist/types/shared/temporal/raw-temporal-value.d.ts +29 -0
  148. package/dist/types/shared/temporal/zoned-wall-clock.d.ts +6 -0
  149. package/package.json +2 -2
  150. package/dist/chunks/bookmark-state-BFY9oNmr.js +0 -111
  151. package/dist/chunks/custom-visual-inputs-Dz-enUNR.js +0 -292
  152. package/dist/chunks/dashboard-controls-Bi7fyG-4.js +0 -2339
  153. package/dist/chunks/document-dashboard-inputs-CkWfDB8c.js +0 -3010
  154. package/dist/chunks/filter-reach-copy-BF4w4kI2.js +0 -3738
  155. package/dist/chunks/global-date-filter-utils-D8365uPH.js +0 -12889
  156. package/dist/chunks/pivot-result-contract-expectations-Bl5suy4-.js +0 -1832
  157. package/dist/chunks/raw-temporal-presentation-BHm7s-hz.js +0 -540
  158. package/dist/chunks/resolve-dashboard-input-context-CAMiWvyR.js +0 -5280
  159. package/dist/chunks/table-settings-Imz0FgWi.js +0 -637
  160. package/dist/chunks/temporal-input-presentation-uvNK_tM0.js +0 -3228
  161. package/dist/types/components/dashboard/ai-dashboard-create-dialog.d.ts +0 -38
  162. package/dist/types/components/dashboard/dashboard-create-template.d.ts +0 -10
  163. package/dist/types/lib/hooks/use-dashboard-authoring.d.ts +0 -49
  164. package/dist/types/shared/dashboard-authoring/artifact-compiler.d.ts +0 -6
  165. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -106
  166. package/dist/types/shared/dashboard-authoring/protocol-adapter.d.ts +0 -7
  167. package/dist/types/shared/dashboard-authoring/source-matching.d.ts +0 -34
  168. package/dist/types/shared/dashboard-authoring/validators.d.ts +0 -2
@@ -0,0 +1,4960 @@
1
+ var En = Object.defineProperty;
2
+ var Cn = (e, t, n) => t in e ? En(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
+ var $ = (e, t, n) => Cn(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 { b0 as Wt, a_ as Pn, aV as Yn, t as nt, H as zn, a3 as Un, b1 as An, l as Rn, a8 as Ln, a0 as q, o as Wn } from "./validators-BIM0FE31.js";
7
+ import "./matrix-operation-contract-DsLdFdSa.js";
8
+ import { k as jn, i as fe } from "./analytics-base-schemas-BaIQrEzX.js";
9
+ import { b as Hn } from "./report-runtime-context-BITkNSDa.js";
10
+ import { canonicalizeSupportedLocale as X, canonicalizeSupportedCurrencyCode as Ue, DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as qn } from "../value-format-preferences/index.js";
11
+ import { p as Zn, a as Kn, c as Vn, e as Bn } from "./raw-temporal-value-Bqz8wc7L.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 Ts(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
+ ], Ae = {
27
+ day: 864e5,
28
+ hour: 36e5,
29
+ minute: 6e4,
30
+ second: 1e3,
31
+ millisecond: 1
32
+ }, Xn = {
33
+ day: "d",
34
+ hour: "hr",
35
+ minute: "min",
36
+ second: "s",
37
+ millisecond: "ms"
38
+ }, Gn = {
39
+ day: ["day", "days"],
40
+ hour: ["hour", "hours"],
41
+ minute: ["minute", "minutes"],
42
+ second: ["second", "seconds"],
43
+ millisecond: ["millisecond", "milliseconds"]
44
+ };
45
+ function Qn(e) {
46
+ return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
47
+ }
48
+ function Ht(e, t) {
49
+ return Qn(e) ? e : t;
50
+ }
51
+ function rt(e, t) {
52
+ return jt.indexOf(Ht(e, t));
53
+ }
54
+ function Jn(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 er(e, t) {
59
+ return e * Ae[Ht(t, "second")];
60
+ }
61
+ function tr(e, t) {
62
+ const n = Jn(t.largestUnit, t.smallestUnit), r = n[n.length - 1], a = Ae[r];
63
+ let i = Math.round(e / a) * a;
64
+ return n.map((o) => {
65
+ const s = Ae[o], c = Math.floor(i / s);
66
+ return i -= c * s, { unit: o, value: c };
67
+ });
68
+ }
69
+ function nr(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}${Xn[i.unit]}`).join(" ");
72
+ }
73
+ function rr(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] = Gn[i.unit];
77
+ return `${i.value} ${i.value === 1 ? o : s}`;
78
+ }).join(" ");
79
+ }
80
+ function ar(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 ir(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(er(n, r)), s = tr(o, t), c = a === "digital" ? ar(s) : a === "long" ? rr(s, t.maxUnits) : nr(s, t.maxUnits);
100
+ return ir(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 or(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 sr(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 U(e, t) {
157
+ return typeof e == "number" ? t.format(e) : or(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 : Pn(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 cr(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 && cr(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 = U(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 = U(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 = `${U(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 = U(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 U(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 U(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 ur(e, t) {
281
+ const n = t ?? "auto", r = n === "never" ? Z(e) : e, a = !Q(r) && (n === "always" || n === "exceptZero" && !sr(r));
282
+ return { value: r, plus: a };
283
+ }
284
+ function Ds(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 = ur(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 xs(e, t) {
321
+ return t.type === "duration" ? e == null ? "" : Zt(e, t) : Ze(e, t);
322
+ }
323
+ function lr(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 bs(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, mr = 864e5, Jt = 6e4, en = 36e5, vs = 525600, re = 43200, ct = 1440;
384
+ let fr = {};
385
+ function L() {
386
+ return fr;
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 dr(e, t) {
423
+ const n = ut(e), r = ut(t), a = +n - ge(n), i = +r - ge(r);
424
+ return Math.round((a - i) / mr);
425
+ }
426
+ function hr(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 gr(e) {
435
+ return N(e, Date.now());
436
+ }
437
+ function yr(e) {
438
+ return e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]";
439
+ }
440
+ function pr(e) {
441
+ if (!yr(e) && typeof e != "number")
442
+ return !1;
443
+ const t = p(e);
444
+ return !isNaN(Number(t));
445
+ }
446
+ function wr(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 Tr(e) {
451
+ return (t) => {
452
+ const r = (e ? Math[e] : Math.trunc)(t);
453
+ return r === 0 ? 0 : r;
454
+ };
455
+ }
456
+ function Dr(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 br(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 vr(e) {
468
+ const t = p(e);
469
+ return +xr(t) == +br(t);
470
+ }
471
+ function Sr(e, t) {
472
+ const n = p(e), r = p(t), a = se(n, r), i = Math.abs(
473
+ wr(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
+ vr(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 Mr(e, t, n) {
486
+ const r = Dr(e, t) / 1e3;
487
+ return Tr(n == null ? void 0 : n.roundingMethod)(r);
488
+ }
489
+ function kr(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 _r = {
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
+ }, Nr = (e, t, n) => {
556
+ let r;
557
+ const a = _r[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 $r = {
567
+ full: "EEEE, MMMM do, y",
568
+ long: "MMMM do, y",
569
+ medium: "MMM d, y",
570
+ short: "MM/dd/yyyy"
571
+ }, Or = {
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
+ }, Ir = {
582
+ date: ke({
583
+ formats: $r,
584
+ defaultWidth: "full"
585
+ }),
586
+ time: ke({
587
+ formats: Or,
588
+ defaultWidth: "full"
589
+ }),
590
+ dateTime: ke({
591
+ formats: Fr,
592
+ defaultWidth: "full"
593
+ })
594
+ }, Er = {
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
+ }, Cr = (e, t, n, r) => Er[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 Pr = {
618
+ narrow: ["B", "A"],
619
+ abbreviated: ["BC", "AD"],
620
+ wide: ["Before Christ", "Anno Domini"]
621
+ }, Yr = {
622
+ narrow: ["1", "2", "3", "4"],
623
+ abbreviated: ["Q1", "Q2", "Q3", "Q4"],
624
+ wide: ["1st quarter", "2nd quarter", "3rd quarter", "4th quarter"]
625
+ }, zr = {
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
+ }, Ar = {
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
+ }, Rr = {
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
+ }, Lr = (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
+ }, Wr = {
743
+ ordinalNumber: Lr,
744
+ era: W({
745
+ values: Pr,
746
+ defaultWidth: "wide"
747
+ }),
748
+ quarter: W({
749
+ values: Yr,
750
+ defaultWidth: "wide",
751
+ argumentCallback: (e) => e - 1
752
+ }),
753
+ month: W({
754
+ values: zr,
755
+ defaultWidth: "wide"
756
+ }),
757
+ day: W({
758
+ values: Ur,
759
+ defaultWidth: "wide"
760
+ }),
761
+ dayPeriod: W({
762
+ values: Ar,
763
+ defaultWidth: "wide",
764
+ formattingValues: Rr,
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) ? Hr(s, (f) => f.test(o)) : (
774
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- I challange you to fix the type
775
+ jr(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 jr(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 Hr(e, t) {
792
+ for (let n = 0; n < e.length; n++)
793
+ if (t(e[n]))
794
+ return n;
795
+ }
796
+ function qr(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 Zr = /^(\d+)(th|st|nd|rd)?/i, Kr = /\d+/i, Vr = {
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
+ }, Br = {
813
+ any: [/^b/i, /^(a|c)/i]
814
+ }, Xr = {
815
+ narrow: /^[1234]/i,
816
+ abbreviated: /^q[1234]/i,
817
+ wide: /^[1234](th|st|nd|rd)? quarter/i
818
+ }, Gr = {
819
+ any: [/1/i, /2/i, /3/i, /4/i]
820
+ }, Qr = {
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
+ }, Jr = {
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
+ }, ea = {
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
+ }, ta = {
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
+ }, na = {
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
+ }, ra = {
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
+ }, aa = {
876
+ ordinalNumber: qr({
877
+ matchPattern: Zr,
878
+ parsePattern: Kr,
879
+ valueCallback: (e) => parseInt(e, 10)
880
+ }),
881
+ era: j({
882
+ matchPatterns: Vr,
883
+ defaultMatchWidth: "wide",
884
+ parsePatterns: Br,
885
+ defaultParseWidth: "any"
886
+ }),
887
+ quarter: j({
888
+ matchPatterns: Xr,
889
+ defaultMatchWidth: "wide",
890
+ parsePatterns: Gr,
891
+ defaultParseWidth: "any",
892
+ valueCallback: (e) => e + 1
893
+ }),
894
+ month: j({
895
+ matchPatterns: Qr,
896
+ defaultMatchWidth: "wide",
897
+ parsePatterns: Jr,
898
+ defaultParseWidth: "any"
899
+ }),
900
+ day: j({
901
+ matchPatterns: ea,
902
+ defaultMatchWidth: "wide",
903
+ parsePatterns: ta,
904
+ defaultParseWidth: "any"
905
+ }),
906
+ dayPeriod: j({
907
+ matchPatterns: na,
908
+ defaultMatchWidth: "any",
909
+ parsePatterns: ra,
910
+ defaultParseWidth: "any"
911
+ })
912
+ }, nn = {
913
+ code: "en-US",
914
+ formatDistance: Nr,
915
+ formatLong: Ir,
916
+ formatRelative: Cr,
917
+ localize: Wr,
918
+ match: aa,
919
+ options: {
920
+ weekStartsOn: 0,
921
+ firstWeekContainsDate: 1
922
+ }
923
+ };
924
+ function ia(e) {
925
+ const t = p(e);
926
+ return dr(t, kr(t)) + 1;
927
+ }
928
+ function oa(e) {
929
+ const t = p(e), n = +he(t) - +hr(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 sa(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 ca(e, t) {
947
+ const n = p(e), r = +K(n, t) - +sa(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 = ca(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 = oa(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 = ia(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 F(r);
1445
+ case "XXXXX":
1446
+ case "XXX":
1447
+ default:
1448
+ return F(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 F(r);
1460
+ case "xxxxx":
1461
+ case "xxx":
1462
+ default:
1463
+ return F(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" + F(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" + F(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) : F(e, t);
1509
+ }
1510
+ function F(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
+ }, ua = (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
+ }, la = {
1560
+ p: an,
1561
+ P: ua
1562
+ }, ma = /^D+$/, fa = /^Y+$/, da = ["D", "DD", "YY", "YYYY"];
1563
+ function ha(e) {
1564
+ return ma.test(e);
1565
+ }
1566
+ function ga(e) {
1567
+ return fa.test(e);
1568
+ }
1569
+ function ya(e, t, n) {
1570
+ const r = pa(e, t, n);
1571
+ if (console.warn(r), da.includes(e)) throw new RangeError(r);
1572
+ }
1573
+ function pa(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 wa = /[yYQqMLwIdDecihHKkms]o|(\w)\1*|''|'(''|[^'])+('|$)|./g, Ta = /P+p+|P+|p+|''|'(''|[^'])+('|$)|./g, Da = /^'([^]*?)'?$/, xa = /''/g, ba = /[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 (!pr(s))
1582
+ throw new RangeError("Invalid time value");
1583
+ let c = t.match(Ta).map((v) => {
1584
+ const b = v[0];
1585
+ if (b === "p" || b === "P") {
1586
+ const Me = la[b];
1587
+ return Me(v, a.formatLong);
1588
+ }
1589
+ return v;
1590
+ }).join("").match(wa).map((v) => {
1591
+ if (v === "''")
1592
+ return { isToken: !1, value: "'" };
1593
+ const b = v[0];
1594
+ if (b === "'")
1595
+ return { isToken: !1, value: va(v) };
1596
+ if (lt[b])
1597
+ return { isToken: !0, value: v };
1598
+ if (b.match(ba))
1599
+ throw new RangeError(
1600
+ "Format string contains an unescaped latin alphabet character `" + b + "`"
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 b = v.value;
1613
+ (!(n != null && n.useAdditionalWeekYearTokens) && ga(b) || !(n != null && n.useAdditionalDayOfYearTokens) && ha(b)) && ya(b, t, String(e));
1614
+ const Me = lt[b[0]];
1615
+ return Me(s, b, a.localize, u);
1616
+ }).join("");
1617
+ }
1618
+ function va(e) {
1619
+ const t = e.match(Da);
1620
+ return t ? t[1].replace(xa, "'") : e;
1621
+ }
1622
+ function Sa(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 = Mr(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 = Sr(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 Ma(e, t) {
1661
+ return Sa(e, gr(e), t);
1662
+ }
1663
+ function ka() {
1664
+ return Object.assign({}, L());
1665
+ }
1666
+ function Ss(e, t) {
1667
+ const r = Oa(e);
1668
+ let a;
1669
+ if (r.date) {
1670
+ const c = Fa(r.date, 2);
1671
+ a = Ia(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 = Ea(r.time), isNaN(o)))
1678
+ return /* @__PURE__ */ new Date(NaN);
1679
+ if (r.timezone) {
1680
+ if (s = Ca(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
+ }, _a = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, Na = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, $a = /^([+-])(\d{2})(?::?(\d{2}))?$/;
1702
+ function Oa(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 Ia(e, t) {
1728
+ if (t === null) return /* @__PURE__ */ new Date(NaN);
1729
+ const n = e.match(_a);
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 Aa(t, s, c) ? Pa(t, s, c) : /* @__PURE__ */ new Date(NaN);
1734
+ {
1735
+ const u = /* @__PURE__ */ new Date(0);
1736
+ return !za(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 Ea(e) {
1743
+ const t = e.match(Na);
1744
+ if (!t) return NaN;
1745
+ const n = _e(t[1]), r = _e(t[2]), a = _e(t[3]);
1746
+ return Ra(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 Ca(e) {
1752
+ if (e === "Z") return 0;
1753
+ const t = e.match($a);
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 La(r, a) ? n * (r * en + a * Jt) : NaN;
1757
+ }
1758
+ function Pa(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 Ya = [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 za(e, t, n) {
1769
+ return t >= 0 && t <= 11 && n >= 1 && n <= (Ya[t] || (on(e) ? 29 : 28));
1770
+ }
1771
+ function Ua(e, t) {
1772
+ return t >= 1 && t <= (on(e) ? 366 : 365);
1773
+ }
1774
+ function Aa(e, t, n) {
1775
+ return t >= 1 && t <= 53 && n >= 0 && n <= 6;
1776
+ }
1777
+ function Ra(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 La(e, t) {
1781
+ return t >= 0 && t <= 59;
1782
+ }
1783
+ function ht(e, t, n) {
1784
+ const r = ka(), a = Ha(e, n.timeZone, n.locale ?? r.locale);
1785
+ return "formatToParts" in a ? Wa(a, t) : ja(a, t);
1786
+ }
1787
+ function Wa(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 ja(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 Ha(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 qa(e, t) {
1804
+ const n = Xa(t);
1805
+ return "formatToParts" in n ? Ka(n, e) : Va(n, e);
1806
+ }
1807
+ const Za = {
1808
+ year: 0,
1809
+ month: 1,
1810
+ day: 2,
1811
+ hour: 3,
1812
+ minute: 4,
1813
+ second: 5
1814
+ };
1815
+ function Ka(e, t) {
1816
+ try {
1817
+ const n = e.formatToParts(t), r = [];
1818
+ for (let a = 0; a < n.length; a++) {
1819
+ const i = Za[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 Va(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")), Ba = gt === "06/25/2014, 00:00:00" || gt === "‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";
1850
+ function Xa(e) {
1851
+ return Ne[e] || (Ne[e] = Ba ? 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, Ga = 6e4, $e = {
1876
+ timezoneZ: /^(Z)$/,
1877
+ timezoneHH: /^([+-]\d{2})$/,
1878
+ timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
1879
+ };
1880
+ function xe(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 * Ga, r[1] === "+" ? -i : i) : NaN;
1893
+ }
1894
+ if (ei(e)) {
1895
+ t = new Date(t || Date.now());
1896
+ const o = n ? t : Qa(t), s = Le(o, e);
1897
+ return -(n ? s : Ja(t, s, e));
1898
+ }
1899
+ return NaN;
1900
+ }
1901
+ function Qa(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 = qa(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 Ja(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 ei(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 ti = 60 * 1e3, ni = {
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" + ri(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 ? xe(e, t, !0) / ti : (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 ri(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_]+)?)$/, Fe = 36e5, xt = 6e4, ai = 2, x = {
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 ? ai : 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 = ii(e), { year: a, restDateString: i } = oi(r.date, n), o = si(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 = ci(r.time), c === null || isNaN(c)))
2074
+ return /* @__PURE__ */ new Date(NaN);
2075
+ if (r.timeZone || t.timeZone) {
2076
+ if (u = xe(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 ii(e) {
2085
+ const t = {};
2086
+ let n = x.dateTimePattern.exec(e), r;
2087
+ if (n ? (t.date = n[1], r = n[3]) : (n = x.datePattern.exec(e), n ? (t.date = n[1], r = n[2]) : (t.date = null, r = e)), r) {
2088
+ const a = x.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 oi(e, t) {
2094
+ if (e) {
2095
+ const n = x.YYY[t], r = x.YYYYY[t];
2096
+ let a = x.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 = x.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 si(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 = x.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 = x.DDD.exec(e), i) {
2126
+ n = /* @__PURE__ */ new Date(0);
2127
+ const o = parseInt(i[1], 10);
2128
+ return mi(t, o) ? (n.setUTCFullYear(t, 0, o), n) : /* @__PURE__ */ new Date(NaN);
2129
+ }
2130
+ if (i = x.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 = x.Www.exec(e), i)
2136
+ return a = parseInt(i[1], 10) - 1, St(a) ? bt(t, a) : /* @__PURE__ */ new Date(NaN);
2137
+ if (i = x.WwwD.exec(e), i) {
2138
+ a = parseInt(i[1], 10) - 1;
2139
+ const o = parseInt(i[2], 10) - 1;
2140
+ return St(a, o) ? bt(t, a, o) : /* @__PURE__ */ new Date(NaN);
2141
+ }
2142
+ return null;
2143
+ }
2144
+ function ci(e) {
2145
+ let t, n, r = x.HH.exec(e);
2146
+ if (r)
2147
+ return t = parseFloat(r[1].replace(",", ".")), Ie(t) ? t % 24 * Fe : NaN;
2148
+ if (r = x.HHMM.exec(e), r)
2149
+ return t = parseInt(r[1], 10), n = parseFloat(r[2].replace(",", ".")), Ie(t, n) ? t % 24 * Fe + n * xt : NaN;
2150
+ if (r = x.HHMMSS.exec(e), r) {
2151
+ t = parseInt(r[1], 10), n = parseInt(r[2], 10);
2152
+ const a = parseFloat(r[3].replace(",", "."));
2153
+ return Ie(t, n, a) ? t % 24 * Fe + n * xt + a * 1e3 : NaN;
2154
+ }
2155
+ return null;
2156
+ }
2157
+ function bt(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 ui = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], li = [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 > li[t] || !r && n > ui[t])
2176
+ return !1;
2177
+ }
2178
+ return !0;
2179
+ }
2180
+ function mi(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 Ie(e, t, n) {
2190
+ return !(e < 0 || e >= 25 || t != null && (t < 0 || t >= 60) || n != null && (n < 0 || n >= 60));
2191
+ }
2192
+ const fi = /([xXOz]+)|''|'(''|[^'])+('|$)/g;
2193
+ function di(e, t, n = {}) {
2194
+ t = String(t);
2195
+ const r = t.match(fi);
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, "'" + ni[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 hi(e, t, n) {
2208
+ e = pe(e, n);
2209
+ const r = xe(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
+ }, di(hi(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 = xe(t, new Date(r));
2224
+ return new Date(r + a);
2225
+ }
2226
+ function Ms(e, t) {
2227
+ return e && e !== "auto" ? e : t;
2228
+ }
2229
+ function ks(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 _s(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 gi = "MM/dd/yyyy", yi = (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 : gi).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 Ns(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 pi = (e, t = "auto") => {
2292
+ if (!e)
2293
+ return "";
2294
+ try {
2295
+ const n = Be(e, t);
2296
+ return isNaN(n.getTime()) ? e : Ma(n, { addSuffix: !0 });
2297
+ } catch (n) {
2298
+ return console.error("Relative time formatting error:", n), e;
2299
+ }
2300
+ };
2301
+ function wi(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 pi(
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 yi(
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 = Yn(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 ? lr(
2326
+ i,
2327
+ t.numberFormat,
2328
+ n.locale
2329
+ ) : String(a);
2330
+ case "date":
2331
+ return wi(
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 $s(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 Ti = 5 * 1024 * 1024, Os = 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), Di = (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(Di))
2364
+ throw new Error("Invalid Matrix export artifact namespace.");
2365
+ return { attemptId: n[3], filename: n[4] };
2366
+ }
2367
+ function Fs(e, t, n) {
2368
+ const r = `exports/${e}/attempts/${t}/${n}`;
2369
+ return P(e, r), r;
2370
+ }
2371
+ const Is = 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
+ ], bi = 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."), vi = w.discriminatedUnion("kind", [
2386
+ w.object({ kind: w.literal("work"), sequence: Te, checkpointKey: w.string(), objects: w.array(bi).min(2).max(4), deadlineAt: we }),
2387
+ w.object({ kind: w.literal("committed"), sequence: Te, done: w.boolean(), deadlineAt: we })
2388
+ ]);
2389
+ function Si(e) {
2390
+ const t = JSON.stringify(e);
2391
+ if (t === void 0 || new TextEncoder().encode(t).byteLength > Ti)
2392
+ throw new RangeError("Matrix export batch exceeds its transport byte limit.");
2393
+ }
2394
+ function Es(e, t) {
2395
+ const n = vi.parse(e);
2396
+ if (Si(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 Mi = 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 Cs(e, t, n) {
2420
+ const r = Mi.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 ki = "en-US", Mt = [
2428
+ "compact",
2429
+ "maximumFractionDigits",
2430
+ "minimumFractionDigits",
2431
+ "negativeStyle",
2432
+ "type",
2433
+ "useGrouping"
2434
+ ];
2435
+ function _i(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 Ni(e) {
2455
+ return e === "currency" ? 2 : e === "percent" ? 1 : e === "scientific" ? 2 : 0;
2456
+ }
2457
+ function $i(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 = Ni(e);
2475
+ return {
2476
+ minimumFractionDigits: o,
2477
+ maximumFractionDigits: o
2478
+ };
2479
+ }
2480
+ function Oi(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 = Oi(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 = $i(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 || ki,
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 = jn.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 _i(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 Ii = Object.freeze({ source: "automatic" });
2612
+ function Ei(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 Ft(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 Ci(e, t) {
2636
+ if (t.kind === "field") return Ft(e, t.fieldId);
2637
+ if (t.kind === "pivot") return Ft(e, t.metricId);
2638
+ }
2639
+ function Pi(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 Yi(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" } : Ii;
2663
+ }
2664
+ function zi(e) {
2665
+ var o;
2666
+ const { card: t, column: n, surface: r } = e, a = Ci(t, n), i = n.kind === "field" ? n.fieldId : n.kind === "pivot" ? n.metricId : void 0;
2667
+ return Xe({
2668
+ surface: r ? Ei(t, r) : void 0,
2669
+ override: Pi(t, n, a),
2670
+ model: (i !== void 0 ? (o = e.modelFormats) == null ? void 0 : o[i] : void 0) ?? e.catalogFormat,
2671
+ snapshot: Yi(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 Ai = ["metricColumns", "groupByColumns", "detailColumns", "pivotByColumns"], It = /* @__PURE__ */ new WeakMap();
2681
+ function Ps(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 = It.get(e);
2685
+ if (r || It.set(e, r = /* @__PURE__ */ new WeakMap()), r.has(n)) return r.get(n);
2686
+ const a = Ri(e, n);
2687
+ return r.set(n, a), a;
2688
+ }
2689
+ function Ri(e, t) {
2690
+ const n = { config: e };
2691
+ let r;
2692
+ for (const a of Ai) {
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 = zi({ 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 Li = [
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 Wi(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(Li);
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 : Ue(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 ji(e) {
2800
+ const t = Wi(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 Ys(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 Hi(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 qi(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 Zi(e, t, n) {
2880
+ const r = X(e.locale) ?? t.locale, a = e.type === "number" || e.type === "currency" ? Ue(n) : void 0;
2881
+ if (!(e.type === "currency" || a !== void 0))
2882
+ return {
2883
+ ...e,
2884
+ locale: r,
2885
+ ...qi(e)
2886
+ };
2887
+ const o = a ?? Ue(e.currency) ?? t.defaultCurrency, s = Hi(
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 Ki = [
2907
+ "YYYY",
2908
+ "MMMM",
2909
+ "MMM",
2910
+ "YY",
2911
+ "MM",
2912
+ "DD",
2913
+ "HH",
2914
+ "mm",
2915
+ "ss"
2916
+ ], Vi = /* @__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 Bi(e) {
2935
+ return typeof e == "string" && Object.prototype.hasOwnProperty.call(mn, e);
2936
+ }
2937
+ function Xi(e, t) {
2938
+ return Ki.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 = Xi(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 (!Vi.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 Gi(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 Qi(e) {
2998
+ return new Set(e).size !== e.length;
2999
+ }
3000
+ function Ji(e, t) {
3001
+ if (Qi(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 ? Ji(
3034
+ Gi(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 zs(e, t) {
3043
+ if (!(!e || !t))
3044
+ return fn(e, t).ok ? e : void 0;
3045
+ }
3046
+ function eo(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 A extends Error {
3050
+ constructor(n, r) {
3051
+ super(r);
3052
+ $(this, "code");
3053
+ this.name = "RawTemporalFormatContractError", this.code = n;
3054
+ }
3055
+ }
3056
+ const to = [
3057
+ "SSSSSSSSS",
3058
+ "SSSSSSSS",
3059
+ "SSSSSSS",
3060
+ "SSSSSS",
3061
+ "SSSSS",
3062
+ "SSSS",
3063
+ "SSS",
3064
+ "SS",
3065
+ "S"
3066
+ ], no = [
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
+ ], ro = /* @__PURE__ */ new Set([
3089
+ "HH",
3090
+ "H",
3091
+ "hh",
3092
+ "h",
3093
+ "mm",
3094
+ "m",
3095
+ "ss",
3096
+ "s",
3097
+ "a",
3098
+ ...to
3099
+ ]), ao = /* @__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 A(
3105
+ "invalid_raw_temporal_format",
3106
+ e
3107
+ );
3108
+ }
3109
+ function dn(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 = no.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 hn(e, t) {
3173
+ if (e === "semaphor_tokens") {
3174
+ const n = ee(t);
3175
+ n.ok || g(n.message);
3176
+ return;
3177
+ }
3178
+ dn(t);
3179
+ }
3180
+ function io(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: io(e.presentation.styles)
3208
+ }
3209
+ } : g(
3210
+ "Automatic raw temporal presentation has unknown fields."
3211
+ ) : e.presentation.mode === "preset" ? !M(e.presentation, ["mode", "preset"]) || !Tn(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
+ ) : (hn(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 gn(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"]) || !Tn(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
+ hn(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 Us(e) {
3281
+ const t = /* @__PURE__ */ new Set();
3282
+ let n = !1;
3283
+ for (const r of e.values) {
3284
+ if (r === null) continue;
3285
+ n = !0;
3286
+ const a = Vn(r);
3287
+ a && t.add(a);
3288
+ }
3289
+ if (!n) return { status: "empty" };
3290
+ if (t.size === 0) return { status: "invalid_only" };
3291
+ if (t.size > 1)
3292
+ throw new A(
3293
+ "mixed_sql_temporal_semantics",
3294
+ `Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`
3295
+ );
3296
+ return {
3297
+ status: "classified",
3298
+ metadata: {
3299
+ kind: "raw_temporal",
3300
+ valueKind: [...t][0]
3301
+ }
3302
+ };
3303
+ }
3304
+ function As(e) {
3305
+ return {
3306
+ version: 1,
3307
+ columns: Object.fromEntries(
3308
+ [...e].map(([t, n]) => [
3309
+ t,
3310
+ n.status === "classified" ? n.metadata.valueKind : n.status
3311
+ ])
3312
+ )
3313
+ };
3314
+ }
3315
+ function oo(e) {
3316
+ if (!T(e) || e.version !== 1 || !T(e.columns) || Object.keys(e).some((r) => r !== "version" && r !== "columns"))
3317
+ throw new A(
3318
+ "invalid_raw_temporal_format",
3319
+ "Raw temporal chunk classification evidence is malformed."
3320
+ );
3321
+ const t = {}, n = /* @__PURE__ */ new Set([
3322
+ "empty",
3323
+ "invalid_only",
3324
+ "date",
3325
+ "wall_datetime",
3326
+ "instant"
3327
+ ]);
3328
+ for (const [r, a] of Object.entries(e.columns)) {
3329
+ if (!r.trim() || !n.has(a))
3330
+ throw new A(
3331
+ "invalid_raw_temporal_format",
3332
+ "Raw temporal chunk classification evidence contains an invalid column or status."
3333
+ );
3334
+ t[r] = a;
3335
+ }
3336
+ return { version: 1, columns: t };
3337
+ }
3338
+ function Rs(e) {
3339
+ if (e.length === 0) return;
3340
+ const t = e.map(oo), n = Object.keys(t[0].columns).sort();
3341
+ for (let r = 1; r < t.length; r += 1) {
3342
+ const a = Object.keys(t[r].columns).sort();
3343
+ if (a.length !== n.length || a.some((i, o) => i !== n[o]))
3344
+ throw new A(
3345
+ "invalid_raw_temporal_format",
3346
+ "Raw temporal chunk classification evidence has inconsistent columns."
3347
+ );
3348
+ }
3349
+ for (const r of n)
3350
+ if (new Set(
3351
+ t.map((i) => i.columns[r]).filter(
3352
+ (i) => i !== "empty" && i !== "invalid_only"
3353
+ )
3354
+ ).size > 1)
3355
+ throw new A(
3356
+ "mixed_sql_temporal_semantics",
3357
+ `Declared SQL temporal column "${r}" has inconsistent semantics across export chunks. Normalize it to one kind.`
3358
+ );
3359
+ }
3360
+ function We(e) {
3361
+ const t = /* @__PURE__ */ new Date(0);
3362
+ return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
3363
+ }
3364
+ function Qe(e, t) {
3365
+ const n = e.fraction ? `.${e.fraction.padEnd(3, "0").slice(0, 3)}` : "";
3366
+ return J(
3367
+ `${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}`,
3368
+ t
3369
+ );
3370
+ }
3371
+ function yn(e, t) {
3372
+ const n = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map();
3373
+ let a, i, o, s;
3374
+ return {
3375
+ number(c, u = 1) {
3376
+ let l = n.get(u);
3377
+ return l || (l = new Intl.NumberFormat(e, {
3378
+ useGrouping: !1,
3379
+ minimumIntegerDigits: u,
3380
+ maximumFractionDigits: 0
3381
+ }), n.set(u, l)), l.format(c);
3382
+ },
3383
+ month(c, u, l) {
3384
+ var h;
3385
+ const f = `${u}:${l ? "standalone" : "contextual"}`;
3386
+ let m = r.get(f);
3387
+ if (!m) {
3388
+ const d = {
3389
+ calendar: "gregory",
3390
+ timeZone: "UTC",
3391
+ month: u
3392
+ };
3393
+ l || (d.day = "numeric"), m = new Intl.DateTimeFormat(e, d), r.set(f, m);
3394
+ }
3395
+ return ((h = m.formatToParts(c).find((d) => d.type === "month")) == null ? void 0 : h.value) ?? "";
3396
+ },
3397
+ dayPeriod(c) {
3398
+ var u;
3399
+ return a ?? (a = new Intl.DateTimeFormat(e, {
3400
+ calendar: "gregory",
3401
+ timeZone: "UTC",
3402
+ hour: "numeric",
3403
+ hour12: !0
3404
+ })), ((u = a.formatToParts(c).find((l) => l.type === "dayPeriod")) == null ? void 0 : u.value) ?? "";
3405
+ },
3406
+ instantFields(c) {
3407
+ i ?? (i = new Intl.DateTimeFormat("en-CA", {
3408
+ calendar: "gregory",
3409
+ numberingSystem: "latn",
3410
+ timeZone: t,
3411
+ year: "numeric",
3412
+ month: "2-digit",
3413
+ day: "2-digit",
3414
+ hour: "2-digit",
3415
+ minute: "2-digit",
3416
+ second: "2-digit",
3417
+ hourCycle: "h23"
3418
+ }));
3419
+ const u = i.formatToParts(c), l = (f) => {
3420
+ var m;
3421
+ return Number((m = u.find((h) => h.type === f)) == null ? void 0 : m.value);
3422
+ };
3423
+ return {
3424
+ year: l("year"),
3425
+ month: l("month"),
3426
+ day: l("day"),
3427
+ hour: l("hour"),
3428
+ minute: l("minute"),
3429
+ second: l("second"),
3430
+ fraction: ""
3431
+ };
3432
+ },
3433
+ timezoneName(c) {
3434
+ var u;
3435
+ return o ?? (o = new Intl.DateTimeFormat(e, {
3436
+ calendar: "gregory",
3437
+ timeZone: t,
3438
+ timeZoneName: "short"
3439
+ })), ((u = o.formatToParts(c).find((l) => l.type === "timeZoneName")) == null ? void 0 : u.value) ?? "";
3440
+ },
3441
+ timezoneOffset(c) {
3442
+ var f;
3443
+ s ?? (s = new Intl.DateTimeFormat("en-US", {
3444
+ calendar: "gregory",
3445
+ timeZone: t,
3446
+ timeZoneName: "longOffset"
3447
+ }));
3448
+ const u = (f = s.formatToParts(c).find((m) => m.type === "timeZoneName")) == null ? void 0 : f.value;
3449
+ if (!u)
3450
+ return g("Unable to resolve the instant timezone offset.");
3451
+ const l = u.replace(/^GMT/, "");
3452
+ return l === "" || /^[+-]00:00$/.test(l) ? "Z" : l;
3453
+ }
3454
+ };
3455
+ }
3456
+ function so(e, t, n, r, a) {
3457
+ if (/^S{1,9}$/.test(e)) {
3458
+ const i = t.fraction.padEnd(e.length, "0").slice(0, e.length);
3459
+ return r.number(Number(i), e.length);
3460
+ }
3461
+ switch (e) {
3462
+ case "YYYY":
3463
+ case "yyyy":
3464
+ return r.number(t.year, 4);
3465
+ case "YY":
3466
+ case "yy":
3467
+ return r.number(t.year % 100, 2);
3468
+ case "MMMM":
3469
+ return r.month(n, "long", !1);
3470
+ case "LLLL":
3471
+ return r.month(n, "long", !0);
3472
+ case "MMM":
3473
+ return r.month(n, "short", !1);
3474
+ case "LLL":
3475
+ return r.month(n, "short", !0);
3476
+ case "MM":
3477
+ return r.number(t.month, 2);
3478
+ case "M":
3479
+ return r.number(t.month);
3480
+ case "DD":
3481
+ case "dd":
3482
+ return r.number(t.day, 2);
3483
+ case "d":
3484
+ return r.number(t.day);
3485
+ case "HH":
3486
+ return r.number(t.hour, 2);
3487
+ case "H":
3488
+ return r.number(t.hour);
3489
+ case "hh":
3490
+ return r.number(t.hour % 12 || 12, 2);
3491
+ case "h":
3492
+ return r.number(t.hour % 12 || 12);
3493
+ case "mm":
3494
+ return r.number(t.minute, 2);
3495
+ case "m":
3496
+ return r.number(t.minute);
3497
+ case "ss":
3498
+ return r.number(t.second, 2);
3499
+ case "s":
3500
+ return r.number(t.second);
3501
+ case "a":
3502
+ return r.dayPeriod(n);
3503
+ case "zzz":
3504
+ return a ? r.timezoneName(a) : g(
3505
+ "Timezone pattern tokens require an instant value."
3506
+ );
3507
+ case "XXX":
3508
+ return a ? r.timezoneOffset(a) : g(
3509
+ "Timezone pattern tokens require an instant value."
3510
+ );
3511
+ default:
3512
+ return g(
3513
+ `Unsupported raw temporal pattern token "${e}".`
3514
+ );
3515
+ }
3516
+ }
3517
+ function co(e, t, n, r) {
3518
+ const a = We(t);
3519
+ return e.map(
3520
+ (i) => i.kind === "literal" ? i.value : so(i.value, t, a, n, r)
3521
+ ).join("");
3522
+ }
3523
+ function pn(e, t, n) {
3524
+ const r = t === "date_fns" ? dn(n) : (() => {
3525
+ const i = ee(n);
3526
+ return i.ok ? i.segments : g(i.message);
3527
+ })(), a = r.filter((i) => i.kind === "token").map((i) => i.value);
3528
+ return e === "date" && a.some((i) => ro.has(i)) ? g("Date patterns cannot contain time tokens.") : e !== "instant" && a.some((i) => ao.has(i)) ? g("Timezone pattern tokens require an instant value.") : r;
3529
+ }
3530
+ function uo(e) {
3531
+ pn(
3532
+ e.valueKind ?? "instant",
3533
+ e.dialect,
3534
+ e.pattern
3535
+ );
3536
+ }
3537
+ function lo(e, t, n, r) {
3538
+ const a = pn(
3539
+ e.valueKind,
3540
+ n,
3541
+ r
3542
+ ), i = yn(t.locale, t.calendarTimezone);
3543
+ return (o) => {
3544
+ const s = e.valueKind === "wall_datetime" && t.sourceTimezone ? Qe(o.fields, t.sourceTimezone) : void 0, c = e.valueKind === "instant" ? {
3545
+ ...i.instantFields(o.instant),
3546
+ fraction: o.fields.fraction
3547
+ } : s ? {
3548
+ ...i.instantFields(s),
3549
+ fraction: o.fields.fraction
3550
+ } : o.fields;
3551
+ return co(a, c, i, o.instant ?? s);
3552
+ };
3553
+ }
3554
+ function wn(e, t) {
3555
+ const n = yn(t.locale, t.calendarTimezone);
3556
+ return (r) => {
3557
+ const a = e.valueKind === "instant" ? n.instantFields(r.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? n.instantFields(Qe(r.fields, t.sourceTimezone)) : r.fields;
3558
+ return {
3559
+ year: a.year,
3560
+ month: a.month,
3561
+ day: a.day,
3562
+ hour: a.hour,
3563
+ minute: a.minute,
3564
+ second: a.second
3565
+ };
3566
+ };
3567
+ }
3568
+ const mo = /* @__PURE__ */ new Set(["short", "long", "numeric", "iso"]);
3569
+ function Tn(e) {
3570
+ return typeof e == "string" && mo.has(e);
3571
+ }
3572
+ function fo(e, t, n) {
3573
+ const r = wn(e, t), a = e.valueKind !== "date", i = (s, c = 2) => String(s).padStart(c, "0");
3574
+ if (n === "iso")
3575
+ return (s) => {
3576
+ const c = r(s), u = `${i(c.year, 4)}-${i(c.month)}-${i(c.day)}`;
3577
+ return a ? `${u} ${i(c.hour)}:${i(c.minute)}` : u;
3578
+ };
3579
+ const o = new Intl.DateTimeFormat(t.locale, {
3580
+ calendar: "gregory",
3581
+ timeZone: "UTC",
3582
+ year: "numeric",
3583
+ month: n,
3584
+ day: "numeric",
3585
+ ...a ? { hour: "numeric", minute: "2-digit" } : {}
3586
+ });
3587
+ return (s) => {
3588
+ const c = r(s), u = /* @__PURE__ */ new Date(0);
3589
+ return u.setUTCFullYear(c.year, c.month - 1, c.day), u.setUTCHours(c.hour, c.minute, c.second, 0), o.format(u);
3590
+ };
3591
+ }
3592
+ function ho(e, t) {
3593
+ const n = t.presentation.mode === "auto" ? t.presentation.styles : g("Automatic raw temporal formatting requires styles.");
3594
+ if (e.valueKind === "date") {
3595
+ const o = new Intl.DateTimeFormat(t.locale, {
3596
+ calendar: "gregory",
3597
+ timeZone: "UTC",
3598
+ dateStyle: n.dateStyle
3599
+ });
3600
+ return (s) => o.format(We(s.fields));
3601
+ }
3602
+ const r = e.valueKind === "instant", a = !r && n.dateTime.timeStyle === "long" ? "medium" : n.dateTime.timeStyle, i = new Intl.DateTimeFormat(t.locale, {
3603
+ calendar: "gregory",
3604
+ timeZone: r || e.valueKind === "wall_datetime" && t.sourceTimezone ? t.calendarTimezone : "UTC",
3605
+ dateStyle: n.dateTime.dateStyle,
3606
+ timeStyle: a
3607
+ });
3608
+ 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));
3609
+ }
3610
+ function Ct(e, t, n) {
3611
+ return {
3612
+ ok: !1,
3613
+ text: e,
3614
+ diagnostic: {
3615
+ code: n,
3616
+ message: `Raw temporal ${t.valueKind} value is ${n === "invalid_raw_temporal_value" ? "malformed" : "out of range"}.`
3617
+ }
3618
+ };
3619
+ }
3620
+ function Dn(e) {
3621
+ const t = Zn(e.metadata), n = Ge(e.format), r = n.presentation.mode === "auto" ? ho(t, n) : n.presentation.mode === "preset" ? fo(t, n, n.presentation.preset) : lo(
3622
+ t,
3623
+ n,
3624
+ n.presentation.dialect,
3625
+ n.presentation.pattern
3626
+ ), a = wn(t, n);
3627
+ return (i) => {
3628
+ if (i === null)
3629
+ return { ok: !0, text: "", status: "empty" };
3630
+ const o = Kn(i, t.valueKind);
3631
+ 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") : {
3632
+ ok: !0,
3633
+ text: r(o),
3634
+ status: "formatted",
3635
+ wallClock: a(o)
3636
+ };
3637
+ };
3638
+ }
3639
+ function go(e) {
3640
+ return Dn({
3641
+ metadata: e.metadata,
3642
+ format: e.format
3643
+ })(e.value);
3644
+ }
3645
+ function yo(e) {
3646
+ const t = gn({ format: e.authored, preferences: e.preferences, calendar: e.calendar });
3647
+ return { format: t, formatValue: Dn({ metadata: e.metadata, format: t }) };
3648
+ }
3649
+ const po = {
3650
+ dateStyle: "short",
3651
+ dateTime: { dateStyle: "short", timeStyle: "short" }
3652
+ };
3653
+ class le extends Error {
3654
+ constructor(n, r) {
3655
+ super(r);
3656
+ $(this, "code");
3657
+ this.name = "TemporalBucketContractError", this.code = n;
3658
+ }
3659
+ }
3660
+ const wo = [
3661
+ "Jan",
3662
+ "Feb",
3663
+ "Mar",
3664
+ "Apr",
3665
+ "May",
3666
+ "Jun",
3667
+ "Jul",
3668
+ "Aug",
3669
+ "Sep",
3670
+ "Oct",
3671
+ "Nov",
3672
+ "Dec"
3673
+ ], To = [
3674
+ "January",
3675
+ "February",
3676
+ "March",
3677
+ "April",
3678
+ "May",
3679
+ "June",
3680
+ "July",
3681
+ "August",
3682
+ "September",
3683
+ "October",
3684
+ "November",
3685
+ "December"
3686
+ ];
3687
+ function Pe(e) {
3688
+ return {
3689
+ ok: !1,
3690
+ error: { code: "invalid_temporal_bucket_value", message: e }
3691
+ };
3692
+ }
3693
+ function Do(e) {
3694
+ return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
3695
+ }
3696
+ function xo(e, t) {
3697
+ return t === 2 ? Do(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
3698
+ }
3699
+ function bo(e, t, n) {
3700
+ const r = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], a = t < 3 ? e - 1 : e;
3701
+ return (a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) + r[t - 1] + n) % 7;
3702
+ }
3703
+ function be(e) {
3704
+ var t;
3705
+ return (t = e.calendar.fiscalCalendar) == null ? void 0 : t.yearStartMonth;
3706
+ }
3707
+ function vo(e, t) {
3708
+ return (e - t + 12) % 12 % 3 === 0;
3709
+ }
3710
+ function So(e, t) {
3711
+ const { granularity: n } = t, r = be(t) ?? 1;
3712
+ switch (n) {
3713
+ case "second":
3714
+ return !0;
3715
+ case "minute":
3716
+ return e.second === 0;
3717
+ case "hour":
3718
+ return e.minute === 0 && e.second === 0;
3719
+ case "day":
3720
+ return !0;
3721
+ case "week":
3722
+ return bo(e.year, e.month, e.day) === t.calendar.weekStart;
3723
+ case "month":
3724
+ return e.day === 1;
3725
+ case "quarter":
3726
+ return e.day === 1 && vo(e.month, r);
3727
+ case "year":
3728
+ return e.day === 1 && e.month === r;
3729
+ }
3730
+ }
3731
+ function xn(e, t) {
3732
+ if (e === null) return { ok: !0, value: null };
3733
+ 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);
3734
+ if (!r)
3735
+ return Pe(
3736
+ `Expected ${n ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${t.granularity} granularity.`
3737
+ );
3738
+ const a = {
3739
+ year: Number(r[1]),
3740
+ month: Number(r[2]),
3741
+ day: Number(r[3]),
3742
+ hour: n ? Number(r[4]) : 0,
3743
+ minute: n ? Number(r[5]) : 0,
3744
+ second: n ? Number(r[6]) : 0
3745
+ };
3746
+ return a.year < 1 || a.month < 1 || a.month > 12 || a.day < 1 || a.day > xo(a.year, a.month) || a.hour > 23 || a.minute > 59 || a.second > 59 ? Pe(`Invalid canonical ${t.granularity} bucket value ${e}.`) : So(a, t) ? { ok: !0, value: a } : Pe(
3747
+ `Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`
3748
+ );
3749
+ }
3750
+ function Ls(e) {
3751
+ 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`];
3752
+ t === "week" && a.push(`weeks starting on ${r({ weekday: "long" }, new Date(Date.UTC(2023, 0, 1 + n.weekStart)))}`);
3753
+ const i = be(e);
3754
+ 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`;
3755
+ }
3756
+ function bn(e) {
3757
+ if (!T(e))
3758
+ return {
3759
+ ok: !1,
3760
+ issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
3761
+ };
3762
+ const t = [], n = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
3763
+ for (const o of Object.keys(e))
3764
+ n.has(o) || t.push({ path: o, message: `Unknown property "${o}".` });
3765
+ e.type !== "temporal_bucket" && t.push({ path: "type", message: "Expected temporal_bucket." });
3766
+ const r = e.presentation;
3767
+ if (!T(r))
3768
+ t.push({ path: "presentation", message: "Expected a presentation object." });
3769
+ else {
3770
+ 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"]);
3771
+ for (const c of Object.keys(r))
3772
+ s.has(c) || t.push({
3773
+ path: `presentation.${c}`,
3774
+ message: `Unknown property "${c}".`
3775
+ });
3776
+ if (o === "preset")
3777
+ Bi(r.preset) || t.push({ path: "presentation.preset", message: "Expected a supported preset." });
3778
+ else if (o === "pattern")
3779
+ if (typeof r.pattern != "string" || !r.pattern)
3780
+ t.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
3781
+ else {
3782
+ const c = ee(r.pattern);
3783
+ c.ok || t.push({
3784
+ path: "presentation.pattern",
3785
+ message: c.message
3786
+ });
3787
+ }
3788
+ else if (o === "auto") {
3789
+ const c = r.styles;
3790
+ (!T(c) || !["short", "medium", "long"].includes(String(c.dateStyle)) || !T(c.dateTime) || !["short", "medium", "long"].includes(
3791
+ String(c.dateTime.dateStyle)
3792
+ ) || !["short", "medium", "long"].includes(
3793
+ String(c.dateTime.timeStyle)
3794
+ ) || Object.keys(c).some(
3795
+ (u) => u !== "dateStyle" && u !== "dateTime"
3796
+ ) || Object.keys(c.dateTime).some(
3797
+ (u) => u !== "dateStyle" && u !== "timeStyle"
3798
+ )) && t.push({
3799
+ path: "presentation.styles",
3800
+ message: "Expected complete resolved date and datetime styles."
3801
+ });
3802
+ } else
3803
+ t.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
3804
+ }
3805
+ const a = X(e.locale);
3806
+ if (a || t.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), t.length > 0 || !a || !T(r))
3807
+ return { ok: !1, issues: t };
3808
+ if (r.mode === "auto") {
3809
+ const o = r.styles;
3810
+ return {
3811
+ ok: !0,
3812
+ value: {
3813
+ type: "temporal_bucket",
3814
+ locale: a,
3815
+ presentation: {
3816
+ mode: "auto",
3817
+ styles: {
3818
+ dateStyle: o.dateStyle,
3819
+ dateTime: {
3820
+ dateStyle: o.dateTime.dateStyle,
3821
+ timeStyle: o.dateTime.timeStyle
3822
+ }
3823
+ }
3824
+ }
3825
+ }
3826
+ };
3827
+ }
3828
+ return {
3829
+ ok: !0,
3830
+ value: {
3831
+ type: "temporal_bucket",
3832
+ presentation: r.mode === "preset" ? {
3833
+ mode: "preset",
3834
+ preset: r.preset
3835
+ } : {
3836
+ mode: "pattern",
3837
+ pattern: r.pattern
3838
+ },
3839
+ locale: a
3840
+ }
3841
+ };
3842
+ }
3843
+ function Mo(e, t) {
3844
+ const n = !!t.calendar.fiscalCalendar;
3845
+ return e === "fiscal_quarter_short" || e === "fiscal_year" ? n : e === "quarter_short" || e === "quarter_long" || _n(e) && (t.granularity === "quarter" || t.granularity === "year") ? !n : !0;
3846
+ }
3847
+ function vn(e, t) {
3848
+ return fn(e, t.granularity).ok ? e.presentation.mode === "preset" ? Mo(e.presentation.preset, t) : !(e.presentation.mode === "pattern" && t.calendar.fiscalCalendar && (t.granularity === "quarter" || t.granularity === "year")) : !1;
3849
+ }
3850
+ function Pt(e, t) {
3851
+ if (!(!e || e.presentation.mode === "auto"))
3852
+ return vn(e, t) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
3853
+ }
3854
+ function Sn(e) {
3855
+ var a;
3856
+ const t = X(e.locale);
3857
+ if (!t)
3858
+ throw new le(
3859
+ "invalid_temporal_bucket_format",
3860
+ "Temporal bucket locale must be a supported base BCP 47 locale."
3861
+ );
3862
+ const n = Pt(e.cardFormat, e.metadata);
3863
+ if (n)
3864
+ return { format: { ...n, locale: t }, source: "card" };
3865
+ const r = ((a = e.semanticFormat) == null ? void 0 : a.granularity) === e.metadata.granularity ? Pt(e.semanticFormat.format, e.metadata) : void 0;
3866
+ return r ? { format: { ...r, locale: t }, source: "semantic" } : {
3867
+ format: {
3868
+ type: "temporal_bucket",
3869
+ locale: t,
3870
+ presentation: {
3871
+ mode: "auto",
3872
+ styles: e.styles ?? po
3873
+ }
3874
+ },
3875
+ source: "automatic"
3876
+ };
3877
+ }
3878
+ function D(e, t = 2) {
3879
+ return String(e).padStart(t, "0");
3880
+ }
3881
+ function V(e, t, n) {
3882
+ if (t === "en-US")
3883
+ return (n === "short" ? wo : To)[e - 1];
3884
+ const r = new Date(Date.UTC(2e3, e - 1, 15));
3885
+ return new Intl.DateTimeFormat(t, {
3886
+ calendar: "gregory",
3887
+ month: n,
3888
+ timeZone: "UTC"
3889
+ }).format(r);
3890
+ }
3891
+ function ko(e, t, n) {
3892
+ return t.map((r) => {
3893
+ if (r.kind === "literal") return r.value;
3894
+ switch (r.value) {
3895
+ case "YYYY":
3896
+ return D(e.year, 4);
3897
+ case "YY":
3898
+ return D(e.year % 100);
3899
+ case "MMMM":
3900
+ return V(e.month, n, "long");
3901
+ case "MMM":
3902
+ return V(e.month, n, "short");
3903
+ case "MM":
3904
+ return D(e.month);
3905
+ case "DD":
3906
+ return D(e.day);
3907
+ case "HH":
3908
+ return D(e.hour);
3909
+ case "mm":
3910
+ return D(e.minute);
3911
+ case "ss":
3912
+ return D(e.second);
3913
+ }
3914
+ }).join("");
3915
+ }
3916
+ const Yt = /* @__PURE__ */ new Map();
3917
+ function Y(e, t) {
3918
+ const n = `${e}:${JSON.stringify(t)}`, r = Yt.get(n);
3919
+ if (r) return r;
3920
+ const a = new Intl.DateTimeFormat(e, t);
3921
+ return Yt.set(n, a), a;
3922
+ }
3923
+ function B(e) {
3924
+ const t = /* @__PURE__ */ new Date(0);
3925
+ return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
3926
+ }
3927
+ function zt(e, t, n) {
3928
+ return Y(t, {
3929
+ calendar: "gregory",
3930
+ dateStyle: n,
3931
+ timeZone: "UTC"
3932
+ }).format(B(e));
3933
+ }
3934
+ function _o(e, t, n) {
3935
+ return Y(t, {
3936
+ calendar: "gregory",
3937
+ dateStyle: n.dateStyle,
3938
+ // Grouped buckets are civil values, not instants. Long time styles would
3939
+ // append a zone label that the canonical value does not semantically own.
3940
+ timeStyle: n.timeStyle === "long" ? "medium" : n.timeStyle,
3941
+ timeZone: "UTC"
3942
+ }).format(B(e));
3943
+ }
3944
+ function No(e, t, n) {
3945
+ var a;
3946
+ if (n === "short") {
3947
+ const i = B(e), o = Y(t, {
3948
+ calendar: "gregory",
3949
+ dateStyle: "short",
3950
+ timeZone: "UTC"
3951
+ }).formatToParts(i), s = o.findIndex((l) => l.type === "month"), c = o.findIndex((l) => l.type === "year"), u = (a = Y(t, {
3952
+ calendar: "gregory",
3953
+ timeZone: "UTC",
3954
+ year: "numeric"
3955
+ }).formatToParts(i).find((l) => l.type === "year")) == null ? void 0 : a.value;
3956
+ if (s >= 0 && c >= 0 && u) {
3957
+ const l = Math.min(s, c), f = Math.max(s, c);
3958
+ let m = !1;
3959
+ 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("");
3960
+ }
3961
+ }
3962
+ return Y(t, {
3963
+ calendar: "gregory",
3964
+ month: n === "short" ? "numeric" : n === "medium" ? "short" : "long",
3965
+ timeZone: "UTC",
3966
+ year: "numeric"
3967
+ }).format(B(e));
3968
+ }
3969
+ function Mn(e, t) {
3970
+ return Math.floor((e.month - t + 12) % 12 / 3) + 1;
3971
+ }
3972
+ function Ut(e, t) {
3973
+ return t === 1 || e.month < t ? e.year : e.year + 1;
3974
+ }
3975
+ function kn(e) {
3976
+ return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
3977
+ }
3978
+ function _n(e) {
3979
+ return e === "short" || e === "long" || e === "numeric" || e === "iso";
3980
+ }
3981
+ function Ye(e, t, n) {
3982
+ return t === "iso" ? `${D(e.year, 4)}-${D(e.month)}-${D(e.day)}` : Y(n, {
3983
+ calendar: "gregory",
3984
+ month: t === "numeric" ? "numeric" : t === "long" ? "long" : "short",
3985
+ day: "numeric",
3986
+ year: "numeric",
3987
+ timeZone: "UTC"
3988
+ }).format(B(e));
3989
+ }
3990
+ function $o(e, t, n, r) {
3991
+ const a = Mn(e, 1);
3992
+ switch (r) {
3993
+ case "week":
3994
+ return t === "numeric" || t === "iso" ? Ye(e, t, n) : `Week of ${Ye(e, t, n)}`;
3995
+ case "month":
3996
+ 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}`;
3997
+ case "quarter":
3998
+ return t === "iso" ? `${D(e.year, 4)}-Q${a}` : t === "long" ? `${kn(a)} Quarter ${e.year}` : `Q${a} ${e.year}`;
3999
+ case "year":
4000
+ return String(e.year);
4001
+ default:
4002
+ return Ye(e, t, n);
4003
+ }
4004
+ }
4005
+ function je(e, t, n, r) {
4006
+ if (_n(t))
4007
+ return $o(e, t, n, r.granularity);
4008
+ const a = be(r) ?? 1, i = Mn(e, a);
4009
+ switch (t) {
4010
+ case "week_of_short":
4011
+ return `Week of ${V(e.month, n, "short")} ${e.day}, ${e.year}`;
4012
+ case "week_of_long":
4013
+ return `Week of ${V(e.month, n, "long")} ${e.day}, ${e.year}`;
4014
+ case "quarter_short":
4015
+ return `Q${i} ${e.year}`;
4016
+ case "quarter_long":
4017
+ return `${kn(i)} Quarter ${e.year}`;
4018
+ case "fiscal_quarter_short":
4019
+ return `Q${i} FY${Ut(e, a)}`;
4020
+ case "fiscal_year":
4021
+ return `FY${Ut(e, a)}`;
4022
+ }
4023
+ }
4024
+ function Oo(e, t, n, r) {
4025
+ const a = be(t);
4026
+ switch (t.granularity) {
4027
+ case "second":
4028
+ case "minute":
4029
+ case "hour":
4030
+ return _o(e, n, r.dateTime);
4031
+ case "day":
4032
+ return zt(e, n, r.dateStyle);
4033
+ case "week":
4034
+ return `Week of ${zt(e, n, r.dateStyle)}`;
4035
+ case "month":
4036
+ return No(e, n, r.dateStyle);
4037
+ case "quarter":
4038
+ return je(
4039
+ e,
4040
+ a ? "fiscal_quarter_short" : "quarter_short",
4041
+ n,
4042
+ t
4043
+ );
4044
+ case "year":
4045
+ return a ? je(e, "fiscal_year", n, t) : String(e.year);
4046
+ }
4047
+ }
4048
+ function Ws(e, t) {
4049
+ if (t.granularity !== "second" && t.granularity !== "minute" && t.granularity !== "hour" && t.granularity !== "day" && t.granularity !== "month")
4050
+ return;
4051
+ const n = xn(e, t);
4052
+ if (!n.ok || n.value === null) return;
4053
+ const { year: r, month: a, day: i, hour: o, minute: s, second: c } = n.value;
4054
+ return { year: r, month: a, day: i, hour: o, minute: s, second: c };
4055
+ }
4056
+ function Nn(e) {
4057
+ const t = bn(e.format);
4058
+ if (!t.ok || !vn(t.value, e.metadata))
4059
+ throw new le(
4060
+ "invalid_temporal_bucket_format",
4061
+ "Resolved temporal bucket format is invalid or inapplicable to its metadata."
4062
+ );
4063
+ const n = xn(e.value, e.metadata);
4064
+ if (!n.ok)
4065
+ throw new le(
4066
+ n.error.code,
4067
+ n.error.message
4068
+ );
4069
+ if (n.value === null) return "(Blank)";
4070
+ const { presentation: r, locale: a } = t.value;
4071
+ if (r.mode === "auto")
4072
+ return Oo(
4073
+ n.value,
4074
+ e.metadata,
4075
+ a,
4076
+ r.styles
4077
+ );
4078
+ if (r.mode === "preset")
4079
+ return je(
4080
+ n.value,
4081
+ r.preset,
4082
+ a,
4083
+ e.metadata
4084
+ );
4085
+ const i = ee(r.pattern);
4086
+ if (!i.ok)
4087
+ throw new le(
4088
+ "invalid_temporal_bucket_format",
4089
+ i.message
4090
+ );
4091
+ return ko(n.value, i.segments, a);
4092
+ }
4093
+ function Fo(e, t) {
4094
+ var a;
4095
+ const n = e[e.length - 1];
4096
+ if (!n) return "";
4097
+ if (n.member.kind === "others") return "Others";
4098
+ const r = n.member.value;
4099
+ 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));
4100
+ }
4101
+ function Io(e, t, n) {
4102
+ return e === "grand_total" ? n ?? "Grand Total" : e === "subtotal" ? (n == null ? void 0 : n.split(Un).join(t)) ?? `${t} Total` : t;
4103
+ }
4104
+ function js(e, t, n, r) {
4105
+ var o;
4106
+ 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;
4107
+ return Io(t, Fo(e, r), i);
4108
+ }
4109
+ function Hs(e, t, n) {
4110
+ return e.kind === "value" ? (t == null ? void 0 : t(e.value)) ?? "" : e.kind === "null" ? n.nullText : n.emptyText;
4111
+ }
4112
+ function qs(e) {
4113
+ const { path: t, previousPath: n, role: r, repeatLabels: a, levelCount: i } = e;
4114
+ return Array.from({ length: i }, (o, s) => {
4115
+ 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);
4116
+ return {
4117
+ path: c,
4118
+ total: u,
4119
+ visible: u || t.length > s && (a || !l || s === t.length - 1)
4120
+ };
4121
+ });
4122
+ }
4123
+ function Eo(e) {
4124
+ return (e == null ? void 0 : e.type) === "date" ? { type: "raw_temporal", timezone: e.timezone, sourceTimezone: e.sourceTimezone, presentation: eo(e) } : void 0;
4125
+ }
4126
+ function Co(e, t) {
4127
+ return Fi(Xe({ override: e, model: t }).format, {
4128
+ preserveOmittedProperties: !0,
4129
+ numericInput: "canonical"
4130
+ });
4131
+ }
4132
+ function Zs(e, t, n) {
4133
+ const r = /* @__PURE__ */ new Map(), a = /* @__PURE__ */ new Map(), i = (o, s) => {
4134
+ const c = (s === "levels" ? t.levelFormats : t.measureFormats)[o.id], u = o.semanticFormat, l = Co(c, u);
4135
+ s === "measures" && r.set(o.id, {
4136
+ isNumeric: zn(o.column.dataType) === "number",
4137
+ // Use normalized affixes: a redundant percent suffix is already removed.
4138
+ hasTextAffixes: !!l && !!("prefix" in l && l.prefix || "suffix" in l && l.suffix)
4139
+ });
4140
+ const f = (m) => ln(m, void 0, {
4141
+ useFormattedValues: !0,
4142
+ timezone: n.calendar.tz,
4143
+ locale: n.valueFormat.locale,
4144
+ absence: t.absence
4145
+ });
4146
+ if (o.column.temporalBucket) {
4147
+ const m = o.column.temporalBucket, h = Sn({
4148
+ metadata: m,
4149
+ cardFormat: (c == null ? void 0 : c.type) === "temporal_bucket" ? c : void 0,
4150
+ semanticFormat: (u == null ? void 0 : u.type) === "temporal_bucket" ? { granularity: m.granularity, format: u } : void 0,
4151
+ locale: n.valueFormat.locale,
4152
+ styles: { dateStyle: n.valueFormat.dateStyle, dateTime: n.valueFormat.dateTime }
4153
+ });
4154
+ return (d) => typeof d == "string" ? Nn({ value: d, metadata: m, format: h.format }) : f(d);
4155
+ }
4156
+ if (o.column.rawTemporal) {
4157
+ const m = Xe({ override: c, model: u }).format, { formatValue: h } = yo({
4158
+ authored: Eo(m),
4159
+ metadata: o.column.rawTemporal,
4160
+ preferences: n.valueFormat,
4161
+ calendar: n.calendar
4162
+ });
4163
+ return (d) => {
4164
+ if (typeof d != "string") return f(d);
4165
+ const S = h(d);
4166
+ return S.ok ? S.text : f(d);
4167
+ };
4168
+ }
4169
+ if (G(l)) {
4170
+ const m = Zi(l, n.valueFormat);
4171
+ return s === "measures" && a.set(o.id, m), (h) => typeof h == "number" || typeof h == "object" && h !== null ? Ze(h, m) : f(h);
4172
+ }
4173
+ 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(
4174
+ typeof m == "object" ? m.value : m,
4175
+ l
4176
+ ) : f(m) : (l == null ? void 0 : l.type) === "string" ? (m) => m === null ? f(m) : `${l.prefix ?? ""}${f(m)}${l.suffix ?? ""}` : f;
4177
+ };
4178
+ return {
4179
+ levels: new Map(
4180
+ e.levels.map((o) => [o.id, i(o, "levels")])
4181
+ ),
4182
+ measures: new Map(
4183
+ e.measures.map((o) => [o.id, i(o, "measures")])
4184
+ ),
4185
+ measureSemantics: r,
4186
+ measureFormats: a,
4187
+ absence: t.absence
4188
+ };
4189
+ }
4190
+ function Ks(e, t) {
4191
+ return t.levelLabels[e.id] ?? e.field.label ?? e.field.name;
4192
+ }
4193
+ function Vs(e, t) {
4194
+ return t.measureLabels[e.id] ?? (e.kind === "aggregate" ? e.field.label ?? e.field.name : e.definition.label);
4195
+ }
4196
+ function Bs(e) {
4197
+ return Wn.parse(Po(e));
4198
+ }
4199
+ function Po(e) {
4200
+ const t = An.parse(e), n = (r) => ({
4201
+ grand: { visible: !0, position: "after" },
4202
+ levels: Object.fromEntries(
4203
+ r.map((a) => [
4204
+ a.id,
4205
+ { visible: !0, position: "before" }
4206
+ ])
4207
+ )
4208
+ });
4209
+ return Rn.parse({
4210
+ version: 1,
4211
+ spec: t,
4212
+ presentation: {
4213
+ layout: { kind: "compact" },
4214
+ absence: { emptyText: "—", nullText: "" },
4215
+ levelLabels: {},
4216
+ measureLabels: {},
4217
+ levelFormats: {},
4218
+ measureFormats: {},
4219
+ totals: { rows: n(t.rows), columns: n(t.columns) }
4220
+ },
4221
+ defaultView: {
4222
+ rows: { depth: 0, overrides: [] },
4223
+ columns: { depth: t.columns.length > 1 ? 1 : 0, overrides: [] }
4224
+ }
4225
+ });
4226
+ }
4227
+ function Yo(e, t) {
4228
+ const n = new Map(e.map((r) => [q(r), r]));
4229
+ for (const r of t ?? []) n.set(q(r), r);
4230
+ return [...n.values()];
4231
+ }
4232
+ function Xs(e) {
4233
+ const { spec: t, presentation: n, defaults: r, session: a } = Ln.parse(e), i = new Map(
4234
+ Yo(t.sorts, a == null ? void 0 : a.sorts).map((s) => [q(s), s])
4235
+ );
4236
+ for (const s of ["rows", "columns"])
4237
+ for (const c of t[s]) {
4238
+ const u = {
4239
+ axis: s,
4240
+ levelId: c.id,
4241
+ scope: { kind: "level" },
4242
+ target: { kind: "member" },
4243
+ direction: "asc",
4244
+ nulls: "last"
4245
+ };
4246
+ i.has(q(u)) || i.set(q(u), u);
4247
+ }
4248
+ const o = (s, c) => ({
4249
+ depth: Math.min(s.depth, Math.max(0, c - 1)),
4250
+ // Leaf toggles are valid but have no effect. Collapsed ancestors retain dormant overrides.
4251
+ overrides: s.overrides.filter(
4252
+ (u) => u.path.length < c
4253
+ )
4254
+ });
4255
+ return {
4256
+ spec: { ...t, sorts: [...i.values()] },
4257
+ presentation: n,
4258
+ view: {
4259
+ rows: o((a == null ? void 0 : a.rows) ?? r.rows, t.rows.length),
4260
+ columns: o(
4261
+ (a == null ? void 0 : a.columns) ?? r.columns,
4262
+ t.columns.length
4263
+ ),
4264
+ sorts: (a == null ? void 0 : a.sorts) ?? []
4265
+ }
4266
+ };
4267
+ }
4268
+ class At extends Error {
4269
+ constructor(n) {
4270
+ super(
4271
+ `invalid_presentation_execution_snapshot: ${n} Resave this report before running it again.`
4272
+ );
4273
+ $(this, "code", "invalid_presentation_execution_snapshot");
4274
+ $(this, "deliveryBlocking", !0);
4275
+ this.name = "PresentationExecutionSnapshotError";
4276
+ }
4277
+ }
4278
+ class Gs extends Error {
4279
+ constructor(n) {
4280
+ super(
4281
+ `missing_resolved_raw_temporal_format: Column "${n}" has no captured presentation. Resave this report before running it again.`
4282
+ );
4283
+ $(this, "code", "missing_resolved_raw_temporal_format");
4284
+ $(this, "deliveryBlocking", !0);
4285
+ this.name = "MissingResolvedRawTemporalFormatError";
4286
+ }
4287
+ }
4288
+ function I(e, t, n) {
4289
+ const r = new Set(t), a = Object.keys(e).find((i) => !r.has(i));
4290
+ if (a)
4291
+ throw new Error(`${n} contains unknown property "${a}"`);
4292
+ }
4293
+ function zo(e, t = "scope") {
4294
+ if (!T(e))
4295
+ throw new Error(`${t} must be an object`);
4296
+ I(
4297
+ e,
4298
+ ["dashboardId", "cardId", "attachmentIndex"],
4299
+ t
4300
+ );
4301
+ const n = typeof e.dashboardId == "string" ? e.dashboardId.trim() : "";
4302
+ if (!n)
4303
+ throw new Error(`${t}.dashboardId is required`);
4304
+ const r = typeof e.cardId == "string" ? e.cardId.trim() : void 0;
4305
+ if (e.cardId !== void 0 && !r)
4306
+ throw new Error(`${t}.cardId must be a non-empty string`);
4307
+ const a = e.attachmentIndex;
4308
+ if (a !== void 0 && (typeof a != "number" || !Number.isInteger(a) || a < 0))
4309
+ throw new Error(
4310
+ `${t}.attachmentIndex must be a non-negative integer`
4311
+ );
4312
+ return {
4313
+ dashboardId: n,
4314
+ ...r ? { cardId: r } : {},
4315
+ ...typeof a == "number" ? { attachmentIndex: a } : {}
4316
+ };
4317
+ }
4318
+ function z(e, t, n, r) {
4319
+ if (e.kind !== t) return;
4320
+ I(e, ["kind", n], r);
4321
+ const a = e[n];
4322
+ if (typeof a != "string" || !a.trim())
4323
+ throw new Error(`${r}.${n} is required`);
4324
+ return a;
4325
+ }
4326
+ function ze(e, t) {
4327
+ if (!T(e))
4328
+ throw new Error(`${t} must be an object`);
4329
+ const n = z(e, "metric", "metricId", t);
4330
+ if (n) return { kind: "metric", metricId: n };
4331
+ const r = z(e, "column", "columnKey", t);
4332
+ if (r) return { kind: "column", columnKey: r };
4333
+ const a = z(
4334
+ e,
4335
+ "matrix_measure",
4336
+ "measureId",
4337
+ t
4338
+ );
4339
+ if (a) return { kind: "matrix_measure", measureId: a };
4340
+ throw new Error(`${t} is not a valid numeric presentation target`);
4341
+ }
4342
+ const Uo = [
4343
+ "type",
4344
+ "inputUnit",
4345
+ "outputStyle",
4346
+ "largestUnit",
4347
+ "smallestUnit",
4348
+ "maxUnits",
4349
+ "prefix",
4350
+ "suffix",
4351
+ "negativeStyle"
4352
+ ];
4353
+ function Ao(e) {
4354
+ return e === "millisecond" || e === "second" || e === "minute" || e === "hour" || e === "day";
4355
+ }
4356
+ const Ro = ["type", "locale", "pattern", "timezone", "sourceTimezone"];
4357
+ function Lo(e, t) {
4358
+ if (I(e, Ro, t), typeof e.locale != "string" || !e.locale.trim())
4359
+ throw new Error(`${t}.locale must be a non-empty string`);
4360
+ for (const n of ["pattern", "timezone", "sourceTimezone"])
4361
+ if (e[n] !== void 0 && typeof e[n] != "string")
4362
+ throw new Error(`${t}.${n} must be a string`);
4363
+ return {
4364
+ type: "date",
4365
+ locale: e.locale,
4366
+ ...typeof e.pattern == "string" ? { pattern: e.pattern } : {},
4367
+ ...typeof e.timezone == "string" ? { timezone: e.timezone } : {},
4368
+ ...typeof e.sourceTimezone == "string" ? { sourceTimezone: e.sourceTimezone } : {}
4369
+ };
4370
+ }
4371
+ function Wo(e, t) {
4372
+ I(e, Uo, t);
4373
+ for (const i of ["inputUnit", "largestUnit", "smallestUnit"])
4374
+ if (e[i] !== void 0 && !Ao(e[i]))
4375
+ throw new Error(`${t}.${i} must be a duration unit`);
4376
+ const n = e.outputStyle;
4377
+ if (n !== void 0 && n !== "compact" && n !== "digital" && n !== "long")
4378
+ throw new Error(`${t}.outputStyle must be compact, digital, or long`);
4379
+ const r = e.maxUnits;
4380
+ if (r !== void 0 && (typeof r != "number" || !Number.isInteger(r) || r < 0 || r > 10))
4381
+ throw new Error(`${t}.maxUnits must be an integer from 0 to 10`);
4382
+ for (const i of ["prefix", "suffix"])
4383
+ if (e[i] !== void 0 && typeof e[i] != "string")
4384
+ throw new Error(`${t}.${i} must be a string`);
4385
+ const a = e.negativeStyle;
4386
+ if (a !== void 0 && a !== "minus" && a !== "parentheses")
4387
+ throw new Error(`${t}.negativeStyle must be minus or parentheses`);
4388
+ return {
4389
+ type: "duration",
4390
+ ...e.inputUnit !== void 0 ? { inputUnit: e.inputUnit } : {},
4391
+ ...n !== void 0 ? { outputStyle: n } : {},
4392
+ ...e.largestUnit !== void 0 ? { largestUnit: e.largestUnit } : {},
4393
+ ...e.smallestUnit !== void 0 ? { smallestUnit: e.smallestUnit } : {},
4394
+ ...r !== void 0 ? { maxUnits: r } : {},
4395
+ ...e.prefix !== void 0 ? { prefix: e.prefix } : {},
4396
+ ...e.suffix !== void 0 ? { suffix: e.suffix } : {},
4397
+ ...a !== void 0 ? { negativeStyle: a } : {}
4398
+ };
4399
+ }
4400
+ function jo(e, t) {
4401
+ if (!T(e))
4402
+ throw new Error(`${t} must be an object`);
4403
+ if (e.kind === "field") {
4404
+ I(e, ["kind", "fieldId", "role"], t);
4405
+ const a = typeof e.fieldId == "string" ? e.fieldId.trim() : "";
4406
+ if (!a)
4407
+ throw new Error(`${t}.fieldId is required`);
4408
+ const i = e.role;
4409
+ if (i !== void 0 && i !== "groupby" && i !== "pivotby")
4410
+ throw new Error(`${t}.role must be groupby or pivotby`);
4411
+ return {
4412
+ kind: "field",
4413
+ fieldId: a,
4414
+ ...i ? { role: i } : {}
4415
+ };
4416
+ }
4417
+ const n = z(e, "column", "columnKey", t);
4418
+ if (n) return { kind: "column", columnKey: n };
4419
+ const r = z(
4420
+ e,
4421
+ "matrix_axis",
4422
+ "axisInstanceId",
4423
+ t
4424
+ );
4425
+ if (r) return { kind: "matrix_axis", axisInstanceId: r };
4426
+ throw new Error(`${t} is not a valid temporal bucket presentation target`);
4427
+ }
4428
+ function Ho(e, t) {
4429
+ if (!T(e))
4430
+ throw new Error(`${t} must be an object`);
4431
+ const n = z(e, "column", "columnKey", t);
4432
+ if (!n)
4433
+ throw new Error(`${t} must identify a column`);
4434
+ return { kind: "column", columnKey: n };
4435
+ }
4436
+ function qo(e) {
4437
+ return [
4438
+ e.dashboardId,
4439
+ e.cardId ?? null,
4440
+ e.attachmentIndex ?? null
4441
+ ];
4442
+ }
4443
+ function De(e) {
4444
+ switch (e.kind) {
4445
+ case "metric":
4446
+ return [e.kind, e.metricId];
4447
+ case "column":
4448
+ return [e.kind, e.columnKey];
4449
+ case "matrix_measure":
4450
+ return [e.kind, e.measureId];
4451
+ case "field":
4452
+ return [e.kind, e.fieldId, e.role ?? ""];
4453
+ case "matrix_axis":
4454
+ return [e.kind, e.axisInstanceId];
4455
+ }
4456
+ }
4457
+ function ve(e, t) {
4458
+ return e.dashboardId === t.dashboardId && e.cardId === t.cardId && e.attachmentIndex === t.attachmentIndex;
4459
+ }
4460
+ function Se(e, t) {
4461
+ const n = De(e), r = De(t);
4462
+ return n.length === r.length && n.every((a, i) => a === r[i]);
4463
+ }
4464
+ function Zo(e) {
4465
+ if (!Array.isArray(e))
4466
+ throw new Error("resolvedFormats must be an array");
4467
+ const t = /* @__PURE__ */ new Set();
4468
+ return e.map((n, r) => {
4469
+ var c, u;
4470
+ const a = `resolvedFormats.${r}`;
4471
+ if (!T(n))
4472
+ throw new Error(`${a} must be an object`);
4473
+ I(n, ["scope", "target", "format"], a);
4474
+ const i = zo(n.scope, `${a}.scope`);
4475
+ if (!T(n.format))
4476
+ throw new Error(`${a}.format must be an object`);
4477
+ let o;
4478
+ switch (n.format.type) {
4479
+ case "temporal_bucket": {
4480
+ const l = bn(n.format);
4481
+ if (!l.ok)
4482
+ throw new Error(
4483
+ `${a}.format is invalid: ${((c = l.issues[0]) == null ? void 0 : c.message) ?? "invalid value"}`
4484
+ );
4485
+ o = {
4486
+ scope: i,
4487
+ target: jo(n.target, `${a}.target`),
4488
+ format: l.value
4489
+ };
4490
+ break;
4491
+ }
4492
+ case "raw_temporal":
4493
+ o = {
4494
+ scope: i,
4495
+ target: Ho(n.target, `${a}.target`),
4496
+ format: Ge(n.format)
4497
+ };
4498
+ break;
4499
+ case "number":
4500
+ case "currency":
4501
+ case "percent":
4502
+ case "scientific": {
4503
+ const l = ji(n.format);
4504
+ if (!l.ok)
4505
+ throw new Error(
4506
+ `${a}.format is invalid: ${((u = l.issues[0]) == null ? void 0 : u.message) ?? "invalid value"}`
4507
+ );
4508
+ o = {
4509
+ scope: i,
4510
+ target: ze(n.target, `${a}.target`),
4511
+ format: l.value
4512
+ };
4513
+ break;
4514
+ }
4515
+ case "date": {
4516
+ const l = ze(n.target, `${a}.target`);
4517
+ if (l.kind !== "column")
4518
+ throw new Error(`${a}.target must identify a column for a date format`);
4519
+ o = {
4520
+ scope: i,
4521
+ target: l,
4522
+ format: Lo(n.format, `${a}.format`)
4523
+ };
4524
+ break;
4525
+ }
4526
+ case "duration":
4527
+ o = {
4528
+ scope: i,
4529
+ target: ze(n.target, `${a}.target`),
4530
+ format: Wo(
4531
+ n.format,
4532
+ `${a}.format`
4533
+ )
4534
+ };
4535
+ break;
4536
+ default:
4537
+ throw new Error(`${a}.format.type is unsupported`);
4538
+ }
4539
+ const s = JSON.stringify([
4540
+ ...qo(o.scope),
4541
+ ...De(o.target)
4542
+ ]);
4543
+ if (t.has(s))
4544
+ throw new Error(
4545
+ `${a} duplicates a scoped presentation target`
4546
+ );
4547
+ return t.add(s), o;
4548
+ });
4549
+ }
4550
+ function Ko(e) {
4551
+ try {
4552
+ if (!T(e))
4553
+ throw new Error("presentation execution snapshot must be an object");
4554
+ if (I(
4555
+ e,
4556
+ ["version", "reportContext", "resolvedFormats"],
4557
+ "presentation execution snapshot"
4558
+ ), e.version !== 1)
4559
+ throw new Error("presentation execution snapshot version must be 1");
4560
+ const t = Hn(e.reportContext);
4561
+ if (!t.ok) {
4562
+ const n = t.issues[0];
4563
+ throw new Error(
4564
+ `presentation execution snapshot reportContext is invalid: ${n != null && n.path && n.path !== "$" ? `${n.path}: ` : ""}${(n == null ? void 0 : n.message) ?? "invalid value"}`
4565
+ );
4566
+ }
4567
+ return {
4568
+ version: 1,
4569
+ reportContext: t.value,
4570
+ resolvedFormats: Zo(e.resolvedFormats)
4571
+ };
4572
+ } catch (t) {
4573
+ throw t instanceof At ? t : new At(
4574
+ t instanceof Error ? t.message : "Snapshot is invalid."
4575
+ );
4576
+ }
4577
+ }
4578
+ function Qs(e) {
4579
+ return Ko({
4580
+ version: 1,
4581
+ reportContext: e.reportContext,
4582
+ resolvedFormats: [...e.resolvedFormats]
4583
+ });
4584
+ }
4585
+ function Js(e) {
4586
+ const t = Vo(e);
4587
+ return G(t) ? t : void 0;
4588
+ }
4589
+ function Vo(e) {
4590
+ const t = e.snapshot.resolvedFormats.find(
4591
+ (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)
4592
+ );
4593
+ return t == null ? void 0 : t.format;
4594
+ }
4595
+ function ec(e) {
4596
+ const t = e.snapshot.resolvedFormats.find(
4597
+ (n) => n.format.type === "date" && ve(n.scope, e.scope) && Se(n.target, e.target)
4598
+ );
4599
+ return t == null ? void 0 : t.format;
4600
+ }
4601
+ function tc(e) {
4602
+ const t = e.snapshot.resolvedFormats.find(
4603
+ (n) => n.format.type === "raw_temporal" && ve(n.scope, e.scope) && Se(n.target, e.target)
4604
+ );
4605
+ return t == null ? void 0 : t.format;
4606
+ }
4607
+ function nc(e) {
4608
+ const t = e.snapshot.resolvedFormats.find(
4609
+ (n) => n.format.type === "temporal_bucket" && ve(n.scope, e.scope) && Se(n.target, e.target)
4610
+ );
4611
+ return t == null ? void 0 : t.format;
4612
+ }
4613
+ function rc(e) {
4614
+ var a;
4615
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set();
4616
+ if (e.snapshot.resolvedFormats.forEach((i, o) => {
4617
+ if (i.scope.attachmentIndex !== void 0)
4618
+ throw new Error(
4619
+ `resolvedFormats.${o}.scope.attachmentIndex is not valid for a card export`
4620
+ );
4621
+ if (i.scope.dashboardId !== e.expectedScope.dashboardId || i.scope.cardId !== e.expectedScope.cardId)
4622
+ throw new Error(
4623
+ `resolvedFormats.${o}.scope must match the executing dashboard/card`
4624
+ );
4625
+ if (i.target.kind === "field" && i.format.type === "temporal_bucket") {
4626
+ const s = JSON.stringify(De(i.target));
4627
+ if (n.has(s))
4628
+ throw new Error(
4629
+ `resolvedFormats.${o} duplicates export field "${i.target.fieldId}"`
4630
+ );
4631
+ n.add(s);
4632
+ return;
4633
+ }
4634
+ if (i.target.kind !== "column")
4635
+ throw new Error(
4636
+ `resolvedFormats.${o}.target must identify an export column or temporal pivot field`
4637
+ );
4638
+ if (t.has(i.target.columnKey))
4639
+ throw new Error(
4640
+ `resolvedFormats.${o} duplicates export column "${i.target.columnKey}"`
4641
+ );
4642
+ t.add(i.target.columnKey);
4643
+ }), !e.useFormattedValues) return;
4644
+ if (!((a = e.visibleColumns) != null && a.length))
4645
+ throw new Error("visibleColumns must identify every formatted export column");
4646
+ const r = e.visibleColumns.find(
4647
+ (i) => !t.has(i)
4648
+ );
4649
+ if (r)
4650
+ throw new Error(
4651
+ `resolvedFormats is missing visible export column "${r}"`
4652
+ );
4653
+ }
4654
+ const Bo = /* @__PURE__ */ new Set(["short", "medium", "long"]), Xo = /^(\d{4})-(\d{2})-(\d{2})$/, Go = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/, Qo = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/, Je = " – ";
4655
+ function ac(e) {
4656
+ if (!T(e)) return;
4657
+ const t = Object.keys(e);
4658
+ if (e.mode === "period_label" && t.length === 1)
4659
+ return { mode: "period_label" };
4660
+ if (e.mode === "style" && t.length === 2 && typeof e.dateStyle == "string" && Bo.has(e.dateStyle))
4661
+ return { mode: "style", dateStyle: e.dateStyle };
4662
+ if (e.mode === "pattern" && t.length === 3 && e.dialect === "semaphor_tokens" && typeof e.pattern == "string" && Jo(e.pattern) === null)
4663
+ return {
4664
+ mode: "pattern",
4665
+ dialect: "semaphor_tokens",
4666
+ pattern: e.pattern
4667
+ };
4668
+ }
4669
+ function Jo(e) {
4670
+ try {
4671
+ return uo({ dialect: "semaphor_tokens", pattern: e }), null;
4672
+ } catch (t) {
4673
+ return t instanceof Error ? t.message : "The pattern is invalid.";
4674
+ }
4675
+ }
4676
+ function ic(e) {
4677
+ const { value: t, part: n, presentation: r, preferences: a, calendar: i } = e;
4678
+ if ((r == null ? void 0 : r.mode) === "period_label" && t.periodLabel && n === "range")
4679
+ return { ok: !0, text: t.periodLabel };
4680
+ const [o, s] = t.bounds, u = s === void 0 || n === "start" ? [{ raw: o, role: "start" }] : n === "end" ? [{ raw: s, role: "end" }] : [
4681
+ { raw: o, role: "start" },
4682
+ { raw: s, role: "end" }
4683
+ ], l = u.map(({ raw: d }) => rs(d, i.tz));
4684
+ if (l.some((d) => d === null))
4685
+ return {
4686
+ ok: !1,
4687
+ text: u.map(({ raw: d }) => d).join(Je),
4688
+ diagnostic: {
4689
+ code: "invalid_temporal_input_value",
4690
+ message: "A date input bound is not a date or an instant."
4691
+ }
4692
+ };
4693
+ const f = t.precision === "day" ? l.map(
4694
+ (d, S) => is(d, u[S].role, i.tz)
4695
+ ) : [], m = f.length > 0 && f.every((d) => d !== null) ? f : null;
4696
+ return { ok: !0, text: m ? es(m, r, a, i) : ts(
4697
+ l.map((d) => as(d, i.tz)),
4698
+ r,
4699
+ a,
4700
+ i
4701
+ ) };
4702
+ }
4703
+ function es(e, t, n, r) {
4704
+ const [a, i = a] = e;
4705
+ if ((t == null ? void 0 : t.mode) === "pattern")
4706
+ return Fn(
4707
+ e.map(
4708
+ (c) => On(He(c), "date", t.pattern, n, r)
4709
+ )
4710
+ );
4711
+ const o = (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : n.dateStyle;
4712
+ if (!t || t.mode === "period_label") {
4713
+ const c = os(a, i, r);
4714
+ if (c)
4715
+ return Nn({
4716
+ value: He(a),
4717
+ metadata: {
4718
+ kind: "temporal_bucket",
4719
+ granularity: c,
4720
+ calendar: { tz: r.tz, weekStart: r.weekStart ?? 1 }
4721
+ },
4722
+ format: Sn({
4723
+ metadata: {
4724
+ kind: "temporal_bucket",
4725
+ granularity: c,
4726
+ calendar: { tz: r.tz, weekStart: r.weekStart ?? 1 }
4727
+ },
4728
+ locale: n.locale,
4729
+ styles: { dateStyle: o, dateTime: { ...n.dateTime } }
4730
+ }).format
4731
+ });
4732
+ }
4733
+ const s = new Intl.DateTimeFormat(n.locale, {
4734
+ calendar: "gregory",
4735
+ timeZone: "UTC",
4736
+ dateStyle: o
4737
+ });
4738
+ return cs(a, i) ? s.format(me(a)) : $n(s, me(a), me(i));
4739
+ }
4740
+ function ts(e, t, n, r) {
4741
+ if ((t == null ? void 0 : t.mode) === "pattern")
4742
+ return Fn(
4743
+ e.map(
4744
+ (s) => On(
4745
+ s.toISOString(),
4746
+ "instant",
4747
+ t.pattern,
4748
+ n,
4749
+ r
4750
+ )
4751
+ )
4752
+ );
4753
+ const a = new Intl.DateTimeFormat(n.locale, {
4754
+ calendar: "gregory",
4755
+ timeZone: r.tz,
4756
+ dateStyle: (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : n.dateTime.dateStyle,
4757
+ timeStyle: n.dateTime.timeStyle
4758
+ }), [i, o] = e;
4759
+ return o && o.getTime() !== i.getTime() ? $n(a, i, o) : a.format(i);
4760
+ }
4761
+ function $n(e, t, n) {
4762
+ const r = e;
4763
+ return typeof r.formatRange == "function" ? r.formatRange(t, n) : `${e.format(t)}${Je}${e.format(n)}`;
4764
+ }
4765
+ function On(e, t, n, r, a) {
4766
+ const i = gn({
4767
+ format: {
4768
+ type: "raw_temporal",
4769
+ presentation: { mode: "pattern", dialect: "semaphor_tokens", pattern: n }
4770
+ },
4771
+ // Temporal formatting reads no currency.
4772
+ preferences: {
4773
+ ...r,
4774
+ defaultCurrency: qn.defaultCurrency
4775
+ },
4776
+ calendar: { tz: a.tz }
4777
+ }), o = t === "date" && ns(n) ? "instant" : t;
4778
+ return go({
4779
+ value: o === t ? e : J(`${e}T00:00:00`, a.tz).toISOString(),
4780
+ metadata: { kind: "raw_temporal", valueKind: o },
4781
+ format: i
4782
+ }).text;
4783
+ }
4784
+ function ns(e) {
4785
+ return /HH|mm|ss/.test(e);
4786
+ }
4787
+ function Fn(e) {
4788
+ return e[1] === void 0 || e[0] === e[1] ? e[0] : e.join(Je);
4789
+ }
4790
+ function rs(e, t) {
4791
+ const n = Xo.exec(e);
4792
+ if (n) {
4793
+ const a = {
4794
+ year: Number(n[1]),
4795
+ month: Number(n[2]),
4796
+ day: Number(n[3])
4797
+ };
4798
+ return us(a) ? { kind: "date", date: a } : null;
4799
+ }
4800
+ const r = Qo.test(e) ? new Date(e.replace(" ", "T")) : Go.test(e) ? J(e.replace(" ", "T"), t) : null;
4801
+ return r && !Number.isNaN(r.getTime()) ? { kind: "instant", instant: r } : null;
4802
+ }
4803
+ function as(e, t) {
4804
+ return e.kind === "instant" ? e.instant : J(`${He(e.date)}T00:00:00`, t);
4805
+ }
4806
+ function is(e, t, n) {
4807
+ if (e.kind === "date") return e.date;
4808
+ const r = Bn(e.instant, n), a = { year: r.year, month: r.month, day: r.day };
4809
+ if (r.hour === 0 && r.minute === 0 && r.second === 0 && e.instant.getUTCMilliseconds() === 0) return t === "start" ? a : ss(a, -1);
4810
+ const o = r.hour === 23 && r.minute === 59 && r.second === 59;
4811
+ return t === "end" && o ? a : null;
4812
+ }
4813
+ function os(e, t, n) {
4814
+ return n.fiscalCalendar || e.day !== 1 || e.year !== t.year || t.day !== In(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;
4815
+ }
4816
+ function He(e) {
4817
+ return `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
4818
+ }
4819
+ function me(e) {
4820
+ const t = /* @__PURE__ */ new Date(0);
4821
+ return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(0, 0, 0, 0), t;
4822
+ }
4823
+ function ss(e, t) {
4824
+ const n = me(e);
4825
+ return n.setUTCDate(n.getUTCDate() + t), {
4826
+ year: n.getUTCFullYear(),
4827
+ month: n.getUTCMonth() + 1,
4828
+ day: n.getUTCDate()
4829
+ };
4830
+ }
4831
+ function cs(e, t) {
4832
+ return e.year === t.year && e.month === t.month && e.day === t.day;
4833
+ }
4834
+ function In(e, t) {
4835
+ return new Date(Date.UTC(e, t, 0)).getUTCDate();
4836
+ }
4837
+ function us(e) {
4838
+ return e.year >= 1 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= In(e.year, e.month);
4839
+ }
4840
+ export {
4841
+ rc as $,
4842
+ Os as A,
4843
+ we as B,
4844
+ P as C,
4845
+ Fs as D,
4846
+ Is as E,
4847
+ vi as F,
4848
+ Si as G,
4849
+ Es as H,
4850
+ Mi as I,
4851
+ Cs as J,
4852
+ Zs as K,
4853
+ Wi as L,
4854
+ Ti as M,
4855
+ ji as N,
4856
+ Ys as O,
4857
+ Hi as P,
4858
+ Zi as Q,
4859
+ At as R,
4860
+ Gs as S,
4861
+ zo as T,
4862
+ Zo as U,
4863
+ Ko as V,
4864
+ Qs as W,
4865
+ Js as X,
4866
+ ec as Y,
4867
+ tc as Z,
4868
+ nc as _,
4869
+ xs as a,
4870
+ Io as a$,
4871
+ Ki as a0,
4872
+ Bi as a1,
4873
+ ee as a2,
4874
+ fn as a3,
4875
+ zs as a4,
4876
+ po as a5,
4877
+ le as a6,
4878
+ xn as a7,
4879
+ Ls as a8,
4880
+ bn as a9,
4881
+ Fo as aA,
4882
+ js as aB,
4883
+ qs as aC,
4884
+ Hs as aD,
4885
+ un as aE,
4886
+ Ss as aF,
4887
+ Ke as aG,
4888
+ Sa as aH,
4889
+ ki as aI,
4890
+ ur as aJ,
4891
+ L as aK,
4892
+ nn as aL,
4893
+ se as aM,
4894
+ p as aN,
4895
+ Tr as aO,
4896
+ ge as aP,
4897
+ ct as aQ,
4898
+ re as aR,
4899
+ vs as aS,
4900
+ Jt as aT,
4901
+ gr as aU,
4902
+ Co as aV,
4903
+ $t as aW,
4904
+ O as aX,
4905
+ Nt as aY,
4906
+ kt as aZ,
4907
+ Eo as a_,
4908
+ Sn as aa,
4909
+ Ws as ab,
4910
+ Nn as ac,
4911
+ eo as ad,
4912
+ A as ae,
4913
+ Ge as af,
4914
+ gn as ag,
4915
+ Us as ah,
4916
+ As as ai,
4917
+ oo as aj,
4918
+ Rs as ak,
4919
+ uo as al,
4920
+ Dn as am,
4921
+ go as an,
4922
+ yo as ao,
4923
+ ac as ap,
4924
+ Jo as aq,
4925
+ ic as ar,
4926
+ Xs as as,
4927
+ _i as at,
4928
+ Ks as au,
4929
+ Vs as av,
4930
+ Bs as aw,
4931
+ Po as ax,
4932
+ Yo as ay,
4933
+ Ds as az,
4934
+ Fi as b,
4935
+ J as b0,
4936
+ Ts as c,
4937
+ qe as d,
4938
+ Bt as e,
4939
+ Vo as f,
4940
+ Xt as g,
4941
+ Gt as h,
4942
+ G as i,
4943
+ Ze as j,
4944
+ lr as k,
4945
+ bs as l,
4946
+ qt as m,
4947
+ Zt as n,
4948
+ yi as o,
4949
+ Xe as p,
4950
+ pi as q,
4951
+ zi as r,
4952
+ Ns as s,
4953
+ Ms as t,
4954
+ ks as u,
4955
+ _s as v,
4956
+ Ps as w,
4957
+ Be as x,
4958
+ ln as y,
4959
+ $s as z
4960
+ };