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
@@ -1,3228 +0,0 @@
1
- var Pt = Object.defineProperty;
2
- var Lt = (e, t, r) => t in e ? Pt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var x = (e, t, r) => Lt(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { a$ as et, b0 as jt, b1 as Kt, l as Ht, a3 as Zt, X as F, o as qt } from "./validators-CXTneCA4.js";
5
- import { z as f } from "zod";
6
- import { E as tt, l as rt } from "./export-file-format-C-tJsxsf.js";
7
- import "./matrix-operation-contract-WPv4R-H_.js";
8
- import { k as Bt, i as V } from "./analytics-base-schemas-CHLxsPfX.js";
9
- import { b as Vt } from "./report-runtime-context-BZQh9ywy.js";
10
- import { canonicalizeSupportedLocale as A, canonicalizeSupportedCurrencyCode as ye, DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as Gt } from "../value-format-preferences/index.js";
11
- import { p as Wt, z as Xt } from "./zoned-wall-clock-B1n_WjW3.js";
12
- function Q(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 Ya(e) {
18
- return Q(e) || !!e && typeof e == "object" && e.type === "duration";
19
- }
20
- const nt = [
21
- "day",
22
- "hour",
23
- "minute",
24
- "second",
25
- "millisecond"
26
- ], ge = {
27
- day: 864e5,
28
- hour: 36e5,
29
- minute: 6e4,
30
- second: 1e3,
31
- millisecond: 1
32
- }, Jt = {
33
- day: "d",
34
- hour: "hr",
35
- minute: "min",
36
- second: "s",
37
- millisecond: "ms"
38
- }, Qt = {
39
- day: ["day", "days"],
40
- hour: ["hour", "hours"],
41
- minute: ["minute", "minutes"],
42
- second: ["second", "seconds"],
43
- millisecond: ["millisecond", "milliseconds"]
44
- };
45
- function er(e) {
46
- return e === "day" || e === "hour" || e === "minute" || e === "second" || e === "millisecond";
47
- }
48
- function at(e, t) {
49
- return er(e) ? e : t;
50
- }
51
- function be(e, t) {
52
- return nt.indexOf(at(e, t));
53
- }
54
- function tr(e, t) {
55
- const r = be(e, "day"), n = be(t, "second"), a = Math.min(r, n), i = Math.max(r, n);
56
- return nt.slice(a, i + 1);
57
- }
58
- function rr(e, t) {
59
- return e * ge[at(t, "second")];
60
- }
61
- function nr(e, t) {
62
- const r = tr(t.largestUnit, t.smallestUnit), n = r[r.length - 1], a = ge[n];
63
- let i = Math.round(e / a) * a;
64
- return r.map((o) => {
65
- const c = ge[o], s = Math.floor(i / c);
66
- return i -= s * c, { unit: o, value: s };
67
- });
68
- }
69
- function ar(e, t) {
70
- const r = e.filter((i) => i.value !== 0), n = r.length > 0 ? r : [e[e.length - 1]], a = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : n.length;
71
- return n.slice(0, a).map((i) => `${i.value}${Jt[i.unit]}`).join(" ");
72
- }
73
- function ir(e, t) {
74
- const r = e.filter((i) => i.value !== 0), n = r.length > 0 ? r : [e[e.length - 1]], a = typeof t == "number" && Number.isFinite(t) ? Math.max(1, Math.trunc(t)) : n.length;
75
- return n.slice(0, a).map((i) => {
76
- const [o, c] = Qt[i.unit];
77
- return `${i.value} ${i.value === 1 ? o : c}`;
78
- }).join(" ");
79
- }
80
- function or(e) {
81
- const t = e.some(
82
- (s) => s.unit === "day" && s.value !== 0
83
- ), r = e.some((s) => s.unit === "millisecond"), n = e.findIndex((s) => s.value !== 0), a = Math.max(0, e.length - 2), i = t ? 0 : n === -1 ? a : Math.min(n, a), o = n === -1 ? e.slice(a) : e.slice(i);
84
- if (o.length === 0)
85
- return "0";
86
- const c = o.map((s, u) => s.unit === "millisecond" ? String(s.value).padStart(3, "0") : u === 0 ? String(s.value) : String(s.value).padStart(2, "0")).join(":");
87
- return r ? c.replace(/:(\d{3})$/, ".$1") : c;
88
- }
89
- function sr(e, t, r) {
90
- const n = `${r.prefix || ""}${e}${r.suffix || ""}`;
91
- return t ? r.negativeInParentheses ? `(${n})` : `-${n}` : n;
92
- }
93
- function cr(e, t = {}) {
94
- if (e == null)
95
- return "";
96
- const r = typeof e == "number" ? e : typeof e == "string" && e.trim() ? Number(e) : NaN;
97
- if (!Number.isFinite(r))
98
- return "";
99
- const n = t.inputUnit || "second", a = t.outputStyle === "digital" || t.outputStyle === "long" ? t.outputStyle : "compact", i = r < 0, o = Math.abs(rr(r, n)), c = nr(o, t), s = a === "digital" ? or(c) : a === "long" ? ir(c, t.maxUnits) : ar(c, t.maxUnits);
100
- return sr(s, i, t);
101
- }
102
- function it(e, t) {
103
- return cr(
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 $e;
118
- function Me(e, t) {
119
- const r = e.format;
120
- return r(t);
121
- }
122
- function ur(e, t) {
123
- if ($e ?? ($e = Me(
124
- new Intl.NumberFormat("en-US", { useGrouping: !1, maximumFractionDigits: 6 }),
125
- "9007199254740993.000009"
126
- ) === "9007199254740993.000009"), !$e)
127
- throw new RangeError("This runtime cannot format exact decimal strings.");
128
- const r = Number(e);
129
- if (!Number.isFinite(r) || r === 0 && e !== "0")
130
- throw new RangeError("Exact value is outside the Intl formatting range; use raw text.");
131
- return Me(t, e);
132
- }
133
- function O(e) {
134
- return typeof e == "number" ? e < 0 : e.value.startsWith("-");
135
- }
136
- function C(e) {
137
- return typeof e == "number" ? Math.abs(e) : O(e) ? { ...e, value: e.value.slice(1) } : e;
138
- }
139
- function lr(e) {
140
- return typeof e == "number" ? e === 0 : /^-?0*(\.0*)?$/.test(e.value);
141
- }
142
- function ot(e, t) {
143
- return typeof e == "number" ? e * t : {
144
- kind: "exact_number",
145
- type: "decimal",
146
- value: et(e.value, t)
147
- };
148
- }
149
- function G(e, t) {
150
- return t === 0 ? e : typeof e == "number" ? e / 10 ** t : {
151
- kind: "exact_number",
152
- type: "decimal",
153
- value: et(e.value, `1e-${t}`)
154
- };
155
- }
156
- function M(e, t) {
157
- return typeof e == "number" ? t.format(e) : ur(e.value, t);
158
- }
159
- function Ne(e) {
160
- if (!e) return !1;
161
- const t = e.toLowerCase().replace("_", "-");
162
- return t === "en-in" || t.startsWith("en-in-");
163
- }
164
- function Ie(e, t) {
165
- const r = C(e), n = (a) => typeof r == "number" ? r >= a : jt(r.value, String(a)) >= 0;
166
- return n(1e12) ? { power: 12, suffix: "T" } : n(1e9) ? { power: 9, suffix: "B" } : Ne(t) && n(1e7) ? { power: 7, suffix: "Cr" } : n(1e6) ? { power: 6, suffix: "M" } : Ne(t) && n(1e5) ? { power: 5, suffix: "L" } : n(1e3) ? { power: 3, suffix: "K" } : { power: 0, suffix: "" };
167
- }
168
- function he(e, t) {
169
- try {
170
- const r = I(t);
171
- return Ie(e, r);
172
- } catch {
173
- return Ie(e, "en-US");
174
- }
175
- }
176
- const st = 500, Y = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map();
177
- function D(e, t = {}) {
178
- const r = `${e}|${JSON.stringify(t)}`;
179
- let n = Y.get(r);
180
- return n || (n = new Intl.NumberFormat(e, t), Y.size >= st && Y.clear(), Y.set(r, n)), n;
181
- }
182
- function mr(e) {
183
- let t = P.get(e);
184
- if (t === void 0) {
185
- try {
186
- D(e), t = !0;
187
- } catch {
188
- t = !1;
189
- }
190
- P.size >= st && P.clear(), P.set(e, t);
191
- }
192
- return t;
193
- }
194
- function I(e) {
195
- return e && mr(e) ? e : "en-US";
196
- }
197
- function De(e, t) {
198
- if (e == null || Number.isNaN(e))
199
- return "";
200
- const r = I(t == null ? void 0 : t.locale);
201
- let n = e;
202
- if (t != null && t.multiplyBy && (n = ot(n, t.multiplyBy)), t != null && t.useSuffix) {
203
- const { power: i, suffix: o } = he(n, r);
204
- n = G(n, i);
205
- const c = M(n, D(r, {
206
- minimumFractionDigits: (t == null ? void 0 : t.minimumFractionDigits) ?? 0,
207
- maximumFractionDigits: (t == null ? void 0 : t.maximumFractionDigits) ?? 2,
208
- useGrouping: (t == null ? void 0 : t.useGrouping) ?? !0
209
- }));
210
- return `${(t == null ? void 0 : t.prefix) ?? ""}${c}${o}${(t == null ? void 0 : t.suffix) ?? ""}`;
211
- }
212
- const a = M(n, D(r, {
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 && O(n)) {
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 ct(e, t) {
224
- if (e == null || Number.isNaN(e))
225
- return "";
226
- const r = I(t == null ? void 0 : t.locale), n = (t == null ? void 0 : t.currency) || "USD", a = O(e), i = !!(t != null && t.negativeInParentheses && a), o = i ? C(e) : e;
227
- try {
228
- if (t != null && t.useSuffix) {
229
- const { power: s, suffix: u } = he(o, r), l = G(o, s), y = `${M(l, D(r, {
230
- style: "currency",
231
- currency: n,
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 ? `(${y})` : y;
237
- }
238
- const c = M(o, D(r, {
239
- style: "currency",
240
- currency: n,
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 ? `(${c})` : c;
246
- } catch {
247
- const c = C(e), s = t != null && t.useSuffix ? he(c, r) : { power: 0, suffix: "" }, u = De(
248
- G(c, s.power),
249
- {
250
- locale: r,
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 = `${n} ${u}${s.suffix}`;
256
- return a ? t != null && t.negativeInParentheses ? `(${l})` : `-${l}` : l;
257
- }
258
- }
259
- function ut(e, t) {
260
- if (e == null || Number.isNaN(e))
261
- return "";
262
- const r = I(t == null ? void 0 : t.locale), a = (t == null ? void 0 : t.alreadyPercent) ?? (t == null ? void 0 : t.percentValueMode) === "whole" ? G(e, 2) : e;
263
- return M(a, D(r, {
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 lt(e, t) {
271
- if (e == null || Number.isNaN(e))
272
- return "";
273
- const r = I(t == null ? void 0 : t.locale);
274
- return M(e, D(r, {
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 dr(e, t) {
281
- const r = t ?? "auto", n = r === "never" ? C(e) : e, a = !O(n) && (r === "always" || r === "exceptZero" && !lr(n));
282
- return { value: n, plus: a };
283
- }
284
- function Pa(e) {
285
- if (!e || !("signDisplay" in e)) return e;
286
- const { signDisplay: t, ...r } = e;
287
- return r;
288
- }
289
- function mt(e, t) {
290
- if (e == null || Number.isNaN(e))
291
- return "";
292
- const r = t.scale === void 0 ? e : ot(e, t.scale), n = dr(r, t.signDisplay), a = n.value, i = n.plus ? "+" : "", o = t.negativeStyle === "parentheses" && O(a), c = o ? C(a) : a, s = {
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 = ct(c, s);
306
- break;
307
- case "percent":
308
- u = ut(c, s);
309
- break;
310
- case "scientific":
311
- u = lt(c, s);
312
- break;
313
- default:
314
- u = De(c, s);
315
- break;
316
- }
317
- const l = `${t.prefix ?? ""}${i}${u}${t.suffix ?? ""}`;
318
- return o ? `(${l})` : l;
319
- }
320
- function La(e, t) {
321
- return t.type === "duration" ? e == null ? "" : it(e, t) : mt(e, t);
322
- }
323
- function ja(e, t, r = "en-US") {
324
- if (e == null || typeof e == "number" && isNaN(e))
325
- return "";
326
- if ((t == null ? void 0 : t.style) === "duration")
327
- return it(e, {
328
- ...t.duration,
329
- prefix: t.prefix,
330
- suffix: t.suffix,
331
- negativeStyle: t.negativeStyle
332
- });
333
- const n = I((t == null ? void 0 : t.locale) || r), a = (t == null ? void 0 : t.style) || "decimal", i = a === "decimal" ? "number" : a;
334
- return i === "currency" && D(n, {
335
- style: "currency",
336
- currency: (t == null ? void 0 : t.currency) || "USD"
337
- }), mt(e, {
338
- type: i,
339
- locale: n,
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 Ka(e, t, r) {
353
- const n = {
354
- style: t === "currency" ? "currency" : t === "percent" ? "percent" : "decimal",
355
- locale: r == null ? void 0 : r.locale,
356
- currency: r == null ? void 0 : r.currency,
357
- minimumFractionDigits: r == null ? void 0 : r.decimalPlaces,
358
- maximumFractionDigits: r == null ? void 0 : r.decimalPlaces,
359
- useSuffix: r == null ? void 0 : r.useSuffix,
360
- prefix: r == null ? void 0 : r.prefix,
361
- suffix: r == null ? void 0 : r.suffix,
362
- negativeInParentheses: r == null ? void 0 : r.negativeInParentheses,
363
- multiplyBy: r == null ? void 0 : r.multiplyBy
364
- };
365
- switch (t) {
366
- case "currency":
367
- return ct(e, n);
368
- case "percent":
369
- return ut(e, n);
370
- case "scientific":
371
- return lt(e, n);
372
- default:
373
- return De(e, n);
374
- }
375
- }
376
- const Ha = 6048e5, Za = 864e5, dt = 6e4, ft = 36e5, qa = 525600, Ba = 43200, Va = 1440;
377
- function Ga(e, t) {
378
- const n = hr(e);
379
- let a;
380
- if (n.date) {
381
- const s = pr(n.date, 2);
382
- a = wr(s.restDateString, s.year);
383
- }
384
- if (!a || isNaN(a.getTime()))
385
- return /* @__PURE__ */ new Date(NaN);
386
- const i = a.getTime();
387
- let o = 0, c;
388
- if (n.time && (o = Tr(n.time), isNaN(o)))
389
- return /* @__PURE__ */ new Date(NaN);
390
- if (n.timezone) {
391
- if (c = Sr(n.timezone), isNaN(c))
392
- return /* @__PURE__ */ new Date(NaN);
393
- } else {
394
- const s = new Date(i + o), u = /* @__PURE__ */ new Date(0);
395
- return u.setFullYear(
396
- s.getUTCFullYear(),
397
- s.getUTCMonth(),
398
- s.getUTCDate()
399
- ), u.setHours(
400
- s.getUTCHours(),
401
- s.getUTCMinutes(),
402
- s.getUTCSeconds(),
403
- s.getUTCMilliseconds()
404
- ), u;
405
- }
406
- return new Date(i + o + c);
407
- }
408
- const L = {
409
- dateTimeDelimiter: /[T ]/,
410
- timeZoneDelimiter: /[Z ]/i,
411
- timezone: /([Z+-].*)$/
412
- }, fr = /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/, yr = /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/, gr = /^([+-])(\d{2})(?::?(\d{2}))?$/;
413
- function hr(e) {
414
- const t = {}, r = e.split(L.dateTimeDelimiter);
415
- let n;
416
- if (r.length > 2)
417
- return t;
418
- if (/:/.test(r[0]) ? n = r[0] : (t.date = r[0], n = r[1], L.timeZoneDelimiter.test(t.date) && (t.date = e.split(L.timeZoneDelimiter)[0], n = e.substr(
419
- t.date.length,
420
- e.length
421
- ))), n) {
422
- const a = L.timezone.exec(n);
423
- a ? (t.time = n.replace(a[1], ""), t.timezone = a[1]) : t.time = n;
424
- }
425
- return t;
426
- }
427
- function pr(e, t) {
428
- const r = new RegExp(
429
- "^(?:(\\d{4}|[+-]\\d{" + (4 + t) + "})|(\\d{2}|[+-]\\d{" + (2 + t) + "})$)"
430
- ), n = e.match(r);
431
- if (!n) return { year: NaN, restDateString: "" };
432
- const a = n[1] ? parseInt(n[1]) : null, i = n[2] ? parseInt(n[2]) : null;
433
- return {
434
- year: i === null ? a : i * 100,
435
- restDateString: e.slice((n[1] || n[2]).length)
436
- };
437
- }
438
- function wr(e, t) {
439
- if (t === null) return /* @__PURE__ */ new Date(NaN);
440
- const r = e.match(fr);
441
- if (!r) return /* @__PURE__ */ new Date(NaN);
442
- const n = !!r[4], a = E(r[1]), i = E(r[2]) - 1, o = E(r[3]), c = E(r[4]), s = E(r[5]) - 1;
443
- if (n)
444
- return _r(t, c, s) ? Dr(t, c, s) : /* @__PURE__ */ new Date(NaN);
445
- {
446
- const u = /* @__PURE__ */ new Date(0);
447
- return !vr(t, i, o) || !kr(t, a) ? /* @__PURE__ */ new Date(NaN) : (u.setUTCFullYear(t, i, Math.max(a, o)), u);
448
- }
449
- }
450
- function E(e) {
451
- return e ? parseInt(e) : 1;
452
- }
453
- function Tr(e) {
454
- const t = e.match(yr);
455
- if (!t) return NaN;
456
- const r = ae(t[1]), n = ae(t[2]), a = ae(t[3]);
457
- return br(r, n, a) ? r * ft + n * dt + a * 1e3 : NaN;
458
- }
459
- function ae(e) {
460
- return e && parseFloat(e.replace(",", ".")) || 0;
461
- }
462
- function Sr(e) {
463
- if (e === "Z") return 0;
464
- const t = e.match(gr);
465
- if (!t) return 0;
466
- const r = t[1] === "+" ? -1 : 1, n = parseInt(t[2]), a = t[3] && parseInt(t[3]) || 0;
467
- return $r(n, a) ? r * (n * ft + a * dt) : NaN;
468
- }
469
- function Dr(e, t, r) {
470
- const n = /* @__PURE__ */ new Date(0);
471
- n.setUTCFullYear(e, 0, 4);
472
- const a = n.getUTCDay() || 7, i = (t - 1) * 7 + r + 1 - a;
473
- return n.setUTCDate(n.getUTCDate() + i), n;
474
- }
475
- const xr = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
476
- function yt(e) {
477
- return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
478
- }
479
- function vr(e, t, r) {
480
- return t >= 0 && t <= 11 && r >= 1 && r <= (xr[t] || (yt(e) ? 29 : 28));
481
- }
482
- function kr(e, t) {
483
- return t >= 1 && t <= (yt(e) ? 366 : 365);
484
- }
485
- function _r(e, t, r) {
486
- return t >= 1 && t <= 53 && r >= 0 && r <= 6;
487
- }
488
- function br(e, t, r) {
489
- return e === 24 ? t === 0 && r === 0 : r >= 0 && r < 60 && t >= 0 && t < 60 && e >= 0 && e < 25;
490
- }
491
- function $r(e, t) {
492
- return t >= 0 && t <= 59;
493
- }
494
- function Mr(e, t) {
495
- const r = Cr(t);
496
- return "formatToParts" in r ? Ir(r, e) : Er(r, e);
497
- }
498
- const Nr = {
499
- year: 0,
500
- month: 1,
501
- day: 2,
502
- hour: 3,
503
- minute: 4,
504
- second: 5
505
- };
506
- function Ir(e, t) {
507
- try {
508
- const r = e.formatToParts(t), n = [];
509
- for (let a = 0; a < r.length; a++) {
510
- const i = Nr[r[a].type];
511
- i !== void 0 && (n[i] = parseInt(r[a].value, 10));
512
- }
513
- return n;
514
- } catch (r) {
515
- if (r instanceof RangeError)
516
- return [NaN];
517
- throw r;
518
- }
519
- }
520
- function Er(e, t) {
521
- const r = e.format(t), n = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(r);
522
- return [
523
- parseInt(n[3], 10),
524
- parseInt(n[1], 10),
525
- parseInt(n[2], 10),
526
- parseInt(n[4], 10),
527
- parseInt(n[5], 10),
528
- parseInt(n[6], 10)
529
- ];
530
- }
531
- const ie = {}, Ee = new Intl.DateTimeFormat("en-US", {
532
- hourCycle: "h23",
533
- timeZone: "America/New_York",
534
- year: "numeric",
535
- month: "2-digit",
536
- day: "2-digit",
537
- hour: "2-digit",
538
- minute: "2-digit",
539
- second: "2-digit"
540
- }).format(/* @__PURE__ */ new Date("2014-06-25T04:00:00.123Z")), Fr = Ee === "06/25/2014, 00:00:00" || Ee === "‎06‎/‎25‎/‎2014‎ ‎00‎:‎00‎:‎00";
541
- function Cr(e) {
542
- return ie[e] || (ie[e] = Fr ? new Intl.DateTimeFormat("en-US", {
543
- hourCycle: "h23",
544
- timeZone: e,
545
- year: "numeric",
546
- month: "numeric",
547
- day: "2-digit",
548
- hour: "2-digit",
549
- minute: "2-digit",
550
- second: "2-digit"
551
- }) : new Intl.DateTimeFormat("en-US", {
552
- hour12: !1,
553
- timeZone: e,
554
- year: "numeric",
555
- month: "numeric",
556
- day: "2-digit",
557
- hour: "2-digit",
558
- minute: "2-digit",
559
- second: "2-digit"
560
- })), ie[e];
561
- }
562
- function xe(e, t, r, n, a, i, o) {
563
- const c = /* @__PURE__ */ new Date(0);
564
- return c.setUTCFullYear(e, t, r), c.setUTCHours(n, a, i, o), c;
565
- }
566
- const Fe = 36e5, Ur = 6e4, oe = {
567
- timezoneZ: /^(Z)$/,
568
- timezoneHH: /^([+-]\d{2})$/,
569
- timezoneHHMM: /^([+-])(\d{2}):?(\d{2})$/
570
- };
571
- function gt(e, t, r) {
572
- if (!e)
573
- return 0;
574
- let n = oe.timezoneZ.exec(e);
575
- if (n)
576
- return 0;
577
- let a, i;
578
- if (n = oe.timezoneHH.exec(e), n)
579
- return a = parseInt(n[1], 10), Ce(a) ? -(a * Fe) : NaN;
580
- if (n = oe.timezoneHHMM.exec(e), n) {
581
- a = parseInt(n[2], 10);
582
- const o = parseInt(n[3], 10);
583
- return Ce(a, o) ? (i = Math.abs(a) * Fe + o * Ur, n[1] === "+" ? -i : i) : NaN;
584
- }
585
- if (Or(e)) {
586
- t = new Date(t || Date.now());
587
- const o = r ? t : zr(t), c = pe(o, e);
588
- return -(r ? c : Ar(t, c, e));
589
- }
590
- return NaN;
591
- }
592
- function zr(e) {
593
- return xe(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds());
594
- }
595
- function pe(e, t) {
596
- const r = Mr(e, t), n = xe(r[0], r[1] - 1, r[2], r[3] % 24, r[4], r[5], 0).getTime();
597
- let a = e.getTime();
598
- const i = a % 1e3;
599
- return a -= i >= 0 ? i : 1e3 + i, n - a;
600
- }
601
- function Ar(e, t, r) {
602
- let a = e.getTime() - t;
603
- const i = pe(new Date(a), r);
604
- if (t === i)
605
- return t;
606
- a -= i - t;
607
- const o = pe(new Date(a), r);
608
- return i === o ? i : Math.max(i, o);
609
- }
610
- function Ce(e, t) {
611
- return -23 <= e && e <= 23 && (t == null || 0 <= t && t <= 59);
612
- }
613
- const Ue = {};
614
- function Or(e) {
615
- if (Ue[e])
616
- return !0;
617
- try {
618
- return new Intl.DateTimeFormat(void 0, { timeZone: e }), Ue[e] = !0, !0;
619
- } catch {
620
- return !1;
621
- }
622
- }
623
- function ze(e) {
624
- const t = new Date(Date.UTC(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()));
625
- return t.setUTCFullYear(e.getFullYear()), +e - +t;
626
- }
627
- const ht = /(Z|[+-]\d{2}(?::?\d{2})?| UTC| [a-zA-Z]+\/[a-zA-Z_]+(?:\/[a-zA-Z_]+)?)$/, se = 36e5, Ae = 6e4, Rr = 2, w = {
628
- dateTimePattern: /^([0-9W+-]+)(T| )(.*)/,
629
- datePattern: /^([0-9W+-]+)(.*)/,
630
- // year tokens
631
- YY: /^(\d{2})$/,
632
- YYY: [
633
- /^([+-]\d{2})$/,
634
- // 0 additional digits
635
- /^([+-]\d{3})$/,
636
- // 1 additional digit
637
- /^([+-]\d{4})$/
638
- // 2 additional digits
639
- ],
640
- YYYY: /^(\d{4})/,
641
- YYYYY: [
642
- /^([+-]\d{4})/,
643
- // 0 additional digits
644
- /^([+-]\d{5})/,
645
- // 1 additional digit
646
- /^([+-]\d{6})/
647
- // 2 additional digits
648
- ],
649
- // date tokens
650
- MM: /^-(\d{2})$/,
651
- DDD: /^-?(\d{3})$/,
652
- MMDD: /^-?(\d{2})-?(\d{2})$/,
653
- Www: /^-?W(\d{2})$/,
654
- WwwD: /^-?W(\d{2})-?(\d{1})$/,
655
- HH: /^(\d{2}([.,]\d*)?)$/,
656
- HHMM: /^(\d{2}):?(\d{2}([.,]\d*)?)$/,
657
- HHMMSS: /^(\d{2}):?(\d{2}):?(\d{2}([.,]\d*)?)$/,
658
- // time zone tokens (to identify the presence of a tz)
659
- timeZone: ht
660
- };
661
- function Oe(e, t = {}) {
662
- if (arguments.length < 1)
663
- throw new TypeError("1 argument required, but only " + arguments.length + " present");
664
- if (e === null)
665
- return /* @__PURE__ */ new Date(NaN);
666
- const r = t.additionalDigits == null ? Rr : Number(t.additionalDigits);
667
- if (r !== 2 && r !== 1 && r !== 0)
668
- throw new RangeError("additionalDigits must be 0, 1 or 2");
669
- if (e instanceof Date || typeof e == "object" && Object.prototype.toString.call(e) === "[object Date]")
670
- return new Date(e.getTime());
671
- if (typeof e == "number" || Object.prototype.toString.call(e) === "[object Number]")
672
- return new Date(e);
673
- if (Object.prototype.toString.call(e) !== "[object String]")
674
- return /* @__PURE__ */ new Date(NaN);
675
- const n = Yr(e), { year: a, restDateString: i } = Pr(n.date, r), o = Lr(i, a);
676
- if (o === null || isNaN(o.getTime()))
677
- return /* @__PURE__ */ new Date(NaN);
678
- if (o) {
679
- const c = o.getTime();
680
- let s = 0, u;
681
- if (n.time && (s = jr(n.time), s === null || isNaN(s)))
682
- return /* @__PURE__ */ new Date(NaN);
683
- if (n.timeZone || t.timeZone) {
684
- if (u = gt(n.timeZone || t.timeZone, new Date(c + s)), isNaN(u))
685
- return /* @__PURE__ */ new Date(NaN);
686
- } else
687
- u = ze(new Date(c + s)), u = ze(new Date(c + s + u));
688
- return new Date(c + s + u);
689
- } else
690
- return /* @__PURE__ */ new Date(NaN);
691
- }
692
- function Yr(e) {
693
- const t = {};
694
- let r = w.dateTimePattern.exec(e), n;
695
- if (r ? (t.date = r[1], n = r[3]) : (r = w.datePattern.exec(e), r ? (t.date = r[1], n = r[2]) : (t.date = null, n = e)), n) {
696
- const a = w.timeZone.exec(n);
697
- a ? (t.time = n.replace(a[1], ""), t.timeZone = a[1].trim()) : t.time = n;
698
- }
699
- return t;
700
- }
701
- function Pr(e, t) {
702
- if (e) {
703
- const r = w.YYY[t], n = w.YYYYY[t];
704
- let a = w.YYYY.exec(e) || n.exec(e);
705
- if (a) {
706
- const i = a[1];
707
- return {
708
- year: parseInt(i, 10),
709
- restDateString: e.slice(i.length)
710
- };
711
- }
712
- if (a = w.YY.exec(e) || r.exec(e), a) {
713
- const i = a[1];
714
- return {
715
- year: parseInt(i, 10) * 100,
716
- restDateString: e.slice(i.length)
717
- };
718
- }
719
- }
720
- return {
721
- year: null
722
- };
723
- }
724
- function Lr(e, t) {
725
- if (t === null)
726
- return null;
727
- let r, n, a;
728
- if (!e || !e.length)
729
- return r = /* @__PURE__ */ new Date(0), r.setUTCFullYear(t), r;
730
- let i = w.MM.exec(e);
731
- if (i)
732
- return r = /* @__PURE__ */ new Date(0), n = parseInt(i[1], 10) - 1, Ye(t, n) ? (r.setUTCFullYear(t, n), r) : /* @__PURE__ */ new Date(NaN);
733
- if (i = w.DDD.exec(e), i) {
734
- r = /* @__PURE__ */ new Date(0);
735
- const o = parseInt(i[1], 10);
736
- return Zr(t, o) ? (r.setUTCFullYear(t, 0, o), r) : /* @__PURE__ */ new Date(NaN);
737
- }
738
- if (i = w.MMDD.exec(e), i) {
739
- r = /* @__PURE__ */ new Date(0), n = parseInt(i[1], 10) - 1;
740
- const o = parseInt(i[2], 10);
741
- return Ye(t, n, o) ? (r.setUTCFullYear(t, n, o), r) : /* @__PURE__ */ new Date(NaN);
742
- }
743
- if (i = w.Www.exec(e), i)
744
- return a = parseInt(i[1], 10) - 1, Pe(a) ? Re(t, a) : /* @__PURE__ */ new Date(NaN);
745
- if (i = w.WwwD.exec(e), i) {
746
- a = parseInt(i[1], 10) - 1;
747
- const o = parseInt(i[2], 10) - 1;
748
- return Pe(a, o) ? Re(t, a, o) : /* @__PURE__ */ new Date(NaN);
749
- }
750
- return null;
751
- }
752
- function jr(e) {
753
- let t, r, n = w.HH.exec(e);
754
- if (n)
755
- return t = parseFloat(n[1].replace(",", ".")), ce(t) ? t % 24 * se : NaN;
756
- if (n = w.HHMM.exec(e), n)
757
- return t = parseInt(n[1], 10), r = parseFloat(n[2].replace(",", ".")), ce(t, r) ? t % 24 * se + r * Ae : NaN;
758
- if (n = w.HHMMSS.exec(e), n) {
759
- t = parseInt(n[1], 10), r = parseInt(n[2], 10);
760
- const a = parseFloat(n[3].replace(",", "."));
761
- return ce(t, r, a) ? t % 24 * se + r * Ae + a * 1e3 : NaN;
762
- }
763
- return null;
764
- }
765
- function Re(e, t, r) {
766
- t = t || 0, r = r || 0;
767
- const n = /* @__PURE__ */ new Date(0);
768
- n.setUTCFullYear(e, 0, 4);
769
- const a = n.getUTCDay() || 7, i = t * 7 + r + 1 - a;
770
- return n.setUTCDate(n.getUTCDate() + i), n;
771
- }
772
- const Kr = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31], Hr = [31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
773
- function pt(e) {
774
- return e % 400 === 0 || e % 4 === 0 && e % 100 !== 0;
775
- }
776
- function Ye(e, t, r) {
777
- if (t < 0 || t > 11)
778
- return !1;
779
- if (r != null) {
780
- if (r < 1)
781
- return !1;
782
- const n = pt(e);
783
- if (n && r > Hr[t] || !n && r > Kr[t])
784
- return !1;
785
- }
786
- return !0;
787
- }
788
- function Zr(e, t) {
789
- if (t < 1)
790
- return !1;
791
- const r = pt(e);
792
- return !(r && t > 366 || !r && t > 365);
793
- }
794
- function Pe(e, t) {
795
- return !(e < 0 || e > 52 || t != null && (t < 0 || t > 6));
796
- }
797
- function ce(e, t, r) {
798
- return !(e < 0 || e >= 25 || t != null && (t < 0 || t >= 60) || r != null && (r < 0 || r >= 60));
799
- }
800
- function ee(e, t, r) {
801
- if (typeof e == "string" && !e.match(ht))
802
- return Oe(e, { ...r, timeZone: t });
803
- e = Oe(e, r);
804
- const n = xe(e.getFullYear(), e.getMonth(), e.getDate(), e.getHours(), e.getMinutes(), e.getSeconds(), e.getMilliseconds()).getTime(), a = gt(t, new Date(n));
805
- return new Date(n + a);
806
- }
807
- const qr = 5 * 1024 * 1024, Wa = 64 * 1024 * 1024, W = f.number().int().positive().max(Number.MAX_SAFE_INTEGER), H = f.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER), X = H.refine((e) => e > 0), Br = (e) => !!e && e !== "." && e !== ".." && !e.includes("/") && !e.includes("\\");
808
- function _(e, t) {
809
- const r = t.split("/");
810
- if (r.length !== 5 || r[0] !== "exports" || r[1] !== e || r[2] !== "attempts" || !r.every(Br))
811
- throw new Error("Invalid Matrix export artifact namespace.");
812
- return { attemptId: r[3], filename: r[4] };
813
- }
814
- function Xa(e, t, r) {
815
- const n = `exports/${e}/attempts/${t}/${r}`;
816
- return _(e, n), n;
817
- }
818
- const Ja = f.object({
819
- acquisition: f.literal("continuation"),
820
- jobId: f.string().min(1),
821
- sequence: X,
822
- deadlineAt: W
823
- }), Vr = [
824
- "application/json",
825
- ...tt.map((e) => rt(e).partContentType)
826
- ], Gr = f.object({
827
- key: f.string(),
828
- content: f.string(),
829
- contentType: f.enum(Vr),
830
- encoding: f.literal("gzip-base64").optional()
831
- // Transport-only compression: JSON (layout, sheet layout) and Excel rows. CSV travels as it always has.
832
- }).refine((e) => !e.encoding || e.contentType === "application/json" || e.contentType === rt("xlsx").partContentType, "Unsupported Matrix artifact encoding."), Wr = f.discriminatedUnion("kind", [
833
- f.object({ kind: f.literal("work"), sequence: X, checkpointKey: f.string(), objects: f.array(Gr).min(2).max(4), deadlineAt: W }),
834
- f.object({ kind: f.literal("committed"), sequence: X, done: f.boolean(), deadlineAt: W })
835
- ]);
836
- function Xr(e) {
837
- const t = JSON.stringify(e);
838
- if (t === void 0 || new TextEncoder().encode(t).byteLength > qr)
839
- throw new RangeError("Matrix export batch exceeds its transport byte limit.");
840
- }
841
- function Qa(e, t) {
842
- const r = Wr.parse(e);
843
- if (Xr(e), r.deadlineAt !== t.deadlineAt) throw new Error("Matrix deadline does not match the job.");
844
- if (r.sequence !== t.sequence + (r.kind === "committed" ? 1 : 0))
845
- throw new Error("Invalid Matrix batch sequence.");
846
- if (r.kind === "work") {
847
- _(t.jobId, r.checkpointKey);
848
- for (const n of r.objects)
849
- _(t.jobId, n.key);
850
- }
851
- return r;
852
- }
853
- const Jr = f.object({
854
- acquisition: f.literal("continuation"),
855
- deadlineAt: W,
856
- chunks: f.array(f.object({ chunkNumber: X, dataKey: f.string() })).min(1),
857
- totalRows: H,
858
- totalBytes: H,
859
- fileKey: f.string().min(1).optional(),
860
- fileSize: H.optional(),
861
- /** The file the job writes; absent means CSV (manifests from before Excel). */
862
- format: f.enum(tt).optional(),
863
- /** Excel only: the sheet layout the layout batch stored, which compaction wraps the rows in. */
864
- sheetKey: f.string().min(1).optional()
865
- }).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.");
866
- function ei(e, t, r) {
867
- const n = Jr.parse(e);
868
- if (n.deadlineAt !== r) throw new Error("Matrix deadline does not match the job.");
869
- return n.chunks.forEach((a, i) => {
870
- if (a.chunkNumber !== i + 1) throw new Error("Invalid committed Matrix chunk order.");
871
- _(t, a.dataKey);
872
- }), n.fileKey !== void 0 && _(t, n.fileKey), n.sheetKey !== void 0 && _(t, n.sheetKey), n;
873
- }
874
- const Qr = "en-US", Le = [
875
- "compact",
876
- "maximumFractionDigits",
877
- "minimumFractionDigits",
878
- "negativeStyle",
879
- "type",
880
- "useGrouping"
881
- ];
882
- function en(e) {
883
- if (e.type !== "currency" || Object.prototype.hasOwnProperty.call(e, "currency") || Object.prototype.hasOwnProperty.call(e, "locale"))
884
- return !1;
885
- const t = Object.keys(e).sort();
886
- return t.length === Le.length && Le.every(
887
- (r, n) => t[n] === r
888
- ) && typeof e.minimumFractionDigits == "number" && typeof e.maximumFractionDigits == "number" && e.useGrouping === !0 && e.negativeStyle === "minus" && typeof e.compact == "boolean";
889
- }
890
- function je(e) {
891
- if (typeof e != "string")
892
- return;
893
- const t = e.trim();
894
- if (!(!t || t.toLowerCase() === "none"))
895
- return t;
896
- }
897
- function Z(e) {
898
- if (!(typeof e != "number" || !Number.isFinite(e)))
899
- return Math.max(0, Math.min(10, Math.trunc(e)));
900
- }
901
- function tn(e) {
902
- return e === "currency" ? 2 : e === "percent" ? 1 : e === "scientific" ? 2 : 0;
903
- }
904
- function rn(e, t, r) {
905
- const n = Z(t.minimumFractionDigits), a = Z(t.maximumFractionDigits);
906
- if (typeof n == "number" || typeof a == "number") {
907
- const c = n ?? 0, s = a ?? Math.max(c, 2);
908
- return {
909
- minimumFractionDigits: Math.min(c, s),
910
- maximumFractionDigits: Math.max(c, s)
911
- };
912
- }
913
- const i = Z(t.decimals);
914
- if (typeof i == "number")
915
- return {
916
- minimumFractionDigits: i,
917
- maximumFractionDigits: i
918
- };
919
- if (r != null && r.preserveOmittedProperties)
920
- return {};
921
- const o = tn(e);
922
- return {
923
- minimumFractionDigits: o,
924
- maximumFractionDigits: o
925
- };
926
- }
927
- function nn(e, t) {
928
- if (!(typeof t != "string" || e === "percent" && t === "%"))
929
- return t;
930
- }
931
- function Ke(e) {
932
- const t = je(e.locale), r = je(e.currency), n = nn(e.type, e.suffix);
933
- return {
934
- ...e,
935
- ...t !== e.locale ? { locale: t } : {},
936
- ...r !== e.currency ? { currency: r } : {},
937
- ...n !== e.suffix ? { suffix: n } : {}
938
- };
939
- }
940
- function v(e, t, r) {
941
- const n = { ...t, type: e };
942
- if ((r == null ? void 0 : r.numericInput) === "canonical" && Q(n))
943
- return Ke(n);
944
- const a = rn(e, t, r), i = typeof t.prefix == "string" ? t.prefix : void 0, o = {
945
- type: e,
946
- locale: t.locale,
947
- minimumFractionDigits: a.minimumFractionDigits,
948
- maximumFractionDigits: a.maximumFractionDigits,
949
- useGrouping: typeof t.useGrouping == "boolean" ? t.useGrouping : typeof t.thousandsSeparator == "boolean" ? t.thousandsSeparator : !0,
950
- prefix: i,
951
- suffix: t.suffix,
952
- negativeStyle: t.negativeStyle || "minus",
953
- compact: !!t.compact,
954
- scale: typeof t.scale == "number" ? t.scale : void 0,
955
- ...t.signDisplay ? { signDisplay: t.signDisplay } : {}
956
- };
957
- return e === "currency" && t.currency && (o.currency = t.currency), e === "percent" && (o.percentValueMode = t.percentValueMode || "fraction"), Ke(o);
958
- }
959
- function He(e) {
960
- return {
961
- type: "date",
962
- locale: e.locale || Qr,
963
- pattern: e.pattern,
964
- // A stored pattern's token set and a preset carry to every reader (column formats ledger P5-45).
965
- ...e.dialect ? { dialect: e.dialect } : {},
966
- ...e.preset ? { preset: e.preset } : {},
967
- relative: !!e.relative,
968
- timezone: e.timezone,
969
- sourceTimezone: e.sourceTimezone,
970
- prefix: e.prefix,
971
- suffix: e.suffix
972
- };
973
- }
974
- function ue(e) {
975
- return e === "millisecond" || e === "second" || e === "minute" || e === "hour" || e === "day";
976
- }
977
- function Ze(e) {
978
- const t = Z(e.maxUnits);
979
- return {
980
- type: "duration",
981
- inputUnit: ue(e.inputUnit) ? e.inputUnit : "second",
982
- outputStyle: e.outputStyle === "digital" || e.outputStyle === "long" ? e.outputStyle : "compact",
983
- largestUnit: ue(e.largestUnit) ? e.largestUnit : void 0,
984
- smallestUnit: ue(e.smallestUnit) ? e.smallestUnit : "second",
985
- maxUnits: t,
986
- prefix: e.prefix,
987
- suffix: e.suffix,
988
- negativeStyle: e.negativeStyle || "minus"
989
- };
990
- }
991
- function qe(e) {
992
- return {
993
- type: "string",
994
- prefix: e.prefix,
995
- suffix: e.suffix
996
- };
997
- }
998
- function ti(e, t) {
999
- if (!e)
1000
- return;
1001
- if (typeof e == "string") {
1002
- const n = e.trim().toLowerCase();
1003
- return n === "currency" ? v(
1004
- "currency",
1005
- { type: "currency" },
1006
- t
1007
- ) : n === "percentage" || n === "percent" ? v(
1008
- "percent",
1009
- {
1010
- type: "percentage",
1011
- percentValueMode: "fraction"
1012
- },
1013
- t
1014
- ) : n === "scientific" ? v(
1015
- "scientific",
1016
- { type: "scientific" },
1017
- t
1018
- ) : n === "date" ? He({}) : n === "duration" ? Ze({}) : n === "string" ? qe({}) : n === "number" ? v(
1019
- "number",
1020
- { type: "number" },
1021
- t
1022
- ) : void 0;
1023
- }
1024
- if ("type" in e && e.type === "temporal_bucket") {
1025
- const n = Bt.safeParse(e);
1026
- return n.success ? n.data : void 0;
1027
- }
1028
- const r = e;
1029
- if ((t == null ? void 0 : t.numericInput) === "canonical") {
1030
- const n = r.type === "percentage" ? { ...r, type: "percent" } : r;
1031
- if (Q(n))
1032
- return v(n.type, n, t);
1033
- }
1034
- if (r.type === "percentage")
1035
- return v(
1036
- "percent",
1037
- {
1038
- ...r,
1039
- percentValueMode: r.percentValueMode || "fraction"
1040
- },
1041
- t
1042
- );
1043
- if (r.type === "number" || r.type === "currency" || r.type === "percent" || r.type === "scientific") {
1044
- const n = v(
1045
- r.type,
1046
- r,
1047
- t
1048
- );
1049
- return en(r) ? { ...n, currency: "USD" } : n;
1050
- }
1051
- if (r.type === "date")
1052
- return He(r);
1053
- if (r.type === "duration")
1054
- return Ze(r);
1055
- if (r.type === "string")
1056
- return qe(r);
1057
- }
1058
- function g(e) {
1059
- if (e === null || typeof e != "object" || Array.isArray(e))
1060
- return !1;
1061
- const t = Object.getPrototypeOf(e);
1062
- if (t === null || t === Object.prototype) return !0;
1063
- const r = Object.prototype.hasOwnProperty.call(
1064
- t,
1065
- "constructor"
1066
- ) ? t.constructor : void 0;
1067
- return typeof r == "function" && Function.prototype.toString.call(r) === Function.prototype.toString.call(Object);
1068
- }
1069
- const an = [
1070
- "type",
1071
- "locale",
1072
- "minimumFractionDigits",
1073
- "maximumFractionDigits",
1074
- "useGrouping",
1075
- "prefix",
1076
- "suffix",
1077
- "negativeStyle",
1078
- "compact",
1079
- "scale",
1080
- "currency",
1081
- "percentValueMode",
1082
- "signDisplay"
1083
- ];
1084
- function on(e) {
1085
- if (!g(e))
1086
- return {
1087
- ok: !1,
1088
- issues: [{ path: "$", message: "Numeric format must be an object." }]
1089
- };
1090
- const t = [], r = new Set(an);
1091
- Object.keys(e).filter((i) => !r.has(i)).forEach(
1092
- (i) => t.push({ path: i, message: `Unknown property "${i}".` })
1093
- ), e.type !== "number" && e.type !== "currency" && e.type !== "percent" && e.type !== "scientific" && t.push({
1094
- path: "type",
1095
- message: "Expected number, currency, percent, or scientific."
1096
- });
1097
- const n = e.locale === void 0 ? void 0 : A(e.locale);
1098
- e.locale !== void 0 && !n && t.push({ path: "locale", message: "Expected a supported BCP 47 locale." });
1099
- const a = e.currency === void 0 ? void 0 : ye(e.currency);
1100
- e.currency !== void 0 && !a && t.push({
1101
- path: "currency",
1102
- message: "Expected a supported ISO 4217 currency code."
1103
- });
1104
- for (const i of ["minimumFractionDigits", "maximumFractionDigits"]) {
1105
- const o = e[i];
1106
- o !== void 0 && (!Number.isInteger(o) || typeof o != "number" || o < 0 || o > 20) && t.push({
1107
- path: i,
1108
- message: "Expected an integer from 0 to 20."
1109
- });
1110
- }
1111
- typeof e.minimumFractionDigits == "number" && typeof e.maximumFractionDigits == "number" && e.minimumFractionDigits > e.maximumFractionDigits && t.push({
1112
- path: "maximumFractionDigits",
1113
- message: "Must be greater than or equal to minimumFractionDigits."
1114
- });
1115
- for (const i of ["useGrouping", "compact"])
1116
- e[i] !== void 0 && typeof e[i] != "boolean" && t.push({ path: i, message: "Expected a boolean." });
1117
- for (const i of ["prefix", "suffix"])
1118
- e[i] !== void 0 && typeof e[i] != "string" && t.push({ path: i, message: "Expected a string." });
1119
- return e.negativeStyle !== void 0 && e.negativeStyle !== "minus" && e.negativeStyle !== "parentheses" && t.push({
1120
- path: "negativeStyle",
1121
- message: "Expected minus or parentheses."
1122
- }), e.percentValueMode !== void 0 && e.percentValueMode !== "fraction" && e.percentValueMode !== "whole" && t.push({
1123
- path: "percentValueMode",
1124
- message: "Expected fraction or whole."
1125
- }), 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({
1126
- path: "signDisplay",
1127
- message: "Expected auto, always, exceptZero, or never."
1128
- }), t.length > 0 ? { ok: !1, issues: t } : {
1129
- ok: !0,
1130
- value: {
1131
- type: e.type,
1132
- ...n ? { locale: n } : {},
1133
- ...e.minimumFractionDigits !== void 0 ? { minimumFractionDigits: e.minimumFractionDigits } : {},
1134
- ...e.maximumFractionDigits !== void 0 ? { maximumFractionDigits: e.maximumFractionDigits } : {},
1135
- ...e.useGrouping !== void 0 ? { useGrouping: e.useGrouping } : {},
1136
- ...e.prefix !== void 0 ? { prefix: e.prefix } : {},
1137
- ...e.suffix !== void 0 ? { suffix: e.suffix } : {},
1138
- ...e.negativeStyle !== void 0 ? {
1139
- negativeStyle: e.negativeStyle
1140
- } : {},
1141
- ...e.compact !== void 0 ? { compact: e.compact } : {},
1142
- ...e.scale !== void 0 ? { scale: e.scale } : {},
1143
- ...a ? { currency: a } : {},
1144
- ...e.percentValueMode !== void 0 ? {
1145
- percentValueMode: e.percentValueMode
1146
- } : {},
1147
- ...e.signDisplay !== void 0 ? {
1148
- signDisplay: e.signDisplay
1149
- } : {}
1150
- }
1151
- };
1152
- }
1153
- function sn(e) {
1154
- const t = on(e);
1155
- if (!t.ok)
1156
- return t;
1157
- const r = [];
1158
- return t.value.locale || r.push({
1159
- path: "locale",
1160
- message: "Resolved numeric formats require an explicit locale."
1161
- }), t.value.minimumFractionDigits === void 0 && r.push({
1162
- path: "minimumFractionDigits",
1163
- message: "Resolved numeric formats require minimumFractionDigits."
1164
- }), t.value.maximumFractionDigits === void 0 && r.push({
1165
- path: "maximumFractionDigits",
1166
- message: "Resolved numeric formats require maximumFractionDigits."
1167
- }), t.value.type === "currency" && !t.value.currency && r.push({
1168
- path: "currency",
1169
- message: "Resolved currency formats require an explicit currency."
1170
- }), r.length > 0 ? { ok: !1, issues: r } : t;
1171
- }
1172
- function ri(e) {
1173
- var n;
1174
- const t = /* @__PURE__ */ new Set();
1175
- if (e.snapshot.resolvedFormats.forEach((a, i) => {
1176
- if (a.format.type !== "temporal_bucket") {
1177
- if (a.scope.attachmentIndex !== void 0)
1178
- throw new Error(
1179
- `resolvedFormats.${i}.scope.attachmentIndex is not valid for a card export`
1180
- );
1181
- if (a.scope.dashboardId !== e.expectedScope.dashboardId || a.scope.cardId !== e.expectedScope.cardId)
1182
- throw new Error(
1183
- `resolvedFormats.${i}.scope must match the executing dashboard/card`
1184
- );
1185
- if (a.target.kind !== "column")
1186
- throw new Error(
1187
- `resolvedFormats.${i}.target must identify an export column`
1188
- );
1189
- if (t.has(a.target.columnKey))
1190
- throw new Error(
1191
- `resolvedFormats.${i} duplicates export column "${a.target.columnKey}"`
1192
- );
1193
- t.add(a.target.columnKey);
1194
- }
1195
- }), !e.useFormattedValues)
1196
- return;
1197
- if (!((n = e.visibleColumns) != null && n.length))
1198
- throw new Error(
1199
- "visibleColumns must identify every formatted export column"
1200
- );
1201
- const r = e.visibleColumns.find(
1202
- (a) => !t.has(a)
1203
- );
1204
- if (r)
1205
- throw new Error(
1206
- `resolvedFormats is missing visible export column "${r}"`
1207
- );
1208
- }
1209
- function cn(e, t) {
1210
- const r = new Intl.NumberFormat(e, {
1211
- style: "currency",
1212
- currency: t
1213
- }).resolvedOptions();
1214
- return {
1215
- minimumFractionDigits: r.minimumFractionDigits,
1216
- maximumFractionDigits: r.maximumFractionDigits
1217
- };
1218
- }
1219
- function un(e) {
1220
- if (e.minimumFractionDigits !== void 0 || e.maximumFractionDigits !== void 0) {
1221
- const r = e.minimumFractionDigits ?? 0;
1222
- return {
1223
- minimumFractionDigits: r,
1224
- maximumFractionDigits: e.maximumFractionDigits ?? Math.max(r, 2)
1225
- };
1226
- }
1227
- const t = e.type === "percent" ? 1 : e.type === "scientific" ? 2 : 0;
1228
- return {
1229
- minimumFractionDigits: t,
1230
- maximumFractionDigits: t
1231
- };
1232
- }
1233
- function ni(e, t, r) {
1234
- const n = A(e.locale) ?? t.locale, a = e.type === "number" || e.type === "currency" ? ye(r) : void 0;
1235
- if (!(e.type === "currency" || a !== void 0))
1236
- return {
1237
- ...e,
1238
- locale: n,
1239
- ...un(e)
1240
- };
1241
- const o = a ?? ye(e.currency) ?? t.defaultCurrency, c = cn(
1242
- n,
1243
- o
1244
- ), s = c.minimumFractionDigits ?? 0, u = c.maximumFractionDigits ?? s, l = e.minimumFractionDigits ?? Math.min(
1245
- s,
1246
- e.maximumFractionDigits ?? s
1247
- ), d = e.maximumFractionDigits ?? Math.max(
1248
- l,
1249
- u
1250
- );
1251
- return {
1252
- ...e,
1253
- type: "currency",
1254
- locale: n,
1255
- currency: o,
1256
- minimumFractionDigits: l,
1257
- maximumFractionDigits: d
1258
- };
1259
- }
1260
- const ln = [
1261
- "YYYY",
1262
- "MMMM",
1263
- "MMM",
1264
- "YY",
1265
- "MM",
1266
- "DD",
1267
- "HH",
1268
- "mm",
1269
- "ss"
1270
- ], mn = /* @__PURE__ */ new Set([" ", "-", "/", ":", ".", ",", "T"]), j = [
1271
- "day",
1272
- "week",
1273
- "month",
1274
- "quarter",
1275
- "year"
1276
- ], wt = {
1277
- week_of_short: ["week"],
1278
- week_of_long: ["week"],
1279
- quarter_short: ["quarter"],
1280
- quarter_long: ["quarter"],
1281
- fiscal_quarter_short: ["quarter"],
1282
- fiscal_year: ["year"],
1283
- short: j,
1284
- long: j,
1285
- numeric: j,
1286
- iso: j
1287
- };
1288
- function dn(e) {
1289
- return typeof e == "string" && Object.prototype.hasOwnProperty.call(wt, e);
1290
- }
1291
- function fn(e, t) {
1292
- return ln.find(
1293
- (r) => e.startsWith(r, t)
1294
- );
1295
- }
1296
- function R(e) {
1297
- var a;
1298
- if (!e || e.trim() !== e)
1299
- return {
1300
- ok: !1,
1301
- code: "invalid_temporal_bucket_pattern",
1302
- message: "Temporal bucket patterns must be non-empty and trimmed."
1303
- };
1304
- const t = [];
1305
- let r = 0, n = !1;
1306
- for (; r < e.length; ) {
1307
- const i = fn(e, r);
1308
- if (i) {
1309
- if (n)
1310
- return {
1311
- ok: !1,
1312
- code: "invalid_temporal_bucket_pattern",
1313
- message: "Adjacent temporal bucket tokens require a separator."
1314
- };
1315
- t.push({ kind: "token", value: i }), r += i.length, n = !0;
1316
- continue;
1317
- }
1318
- const o = e[r];
1319
- if (!mn.has(o))
1320
- return {
1321
- ok: !1,
1322
- code: "invalid_temporal_bucket_pattern",
1323
- message: `Unsupported temporal bucket pattern character "${o}".`
1324
- };
1325
- if (t.length === 0)
1326
- return {
1327
- ok: !1,
1328
- code: "invalid_temporal_bucket_pattern",
1329
- message: "Temporal bucket patterns cannot begin with a separator."
1330
- };
1331
- const c = t[t.length - 1];
1332
- c.kind === "literal" ? c.value += o : t.push({ kind: "literal", value: o }), r += 1, n = !1;
1333
- }
1334
- return ((a = t[t.length - 1]) == null ? void 0 : a.kind) !== "token" ? {
1335
- ok: !1,
1336
- code: "invalid_temporal_bucket_pattern",
1337
- message: "Temporal bucket patterns cannot end with a separator."
1338
- } : { ok: !0, segments: t };
1339
- }
1340
- function yn(e) {
1341
- return e.flatMap(
1342
- (t) => t.kind === "token" ? [t.value] : []
1343
- );
1344
- }
1345
- function Be(e, t) {
1346
- return e.filter((r) => t.includes(r)).length === 1;
1347
- }
1348
- function K(e, t) {
1349
- return e.some((r) => t.includes(r));
1350
- }
1351
- function gn(e) {
1352
- return new Set(e).size !== e.length;
1353
- }
1354
- function hn(e, t) {
1355
- if (gn(e)) return !1;
1356
- const r = ["YYYY", "YY"], n = ["MMMM", "MMM", "MM"], a = ["HH", "mm", "ss"], i = Be(e, r), o = Be(e, n), c = e.includes("DD"), s = K(e, a);
1357
- switch (t) {
1358
- case "second":
1359
- return e.includes("HH") && e.includes("mm") && e.includes("ss") && (!K(e, [...r, ...n, "DD"]) || i && o && c);
1360
- case "minute":
1361
- return e.includes("HH") && e.includes("mm") && (!K(e, [...r, ...n, "DD"]) || i && o && c);
1362
- case "hour":
1363
- return e.includes("HH") && (!K(e, [...r, ...n, "DD"]) || i && o && c);
1364
- case "day":
1365
- case "week":
1366
- return i && o && c && !s;
1367
- case "month":
1368
- return i && o && !c && !s;
1369
- case "quarter":
1370
- return !1;
1371
- case "year":
1372
- return i && !o && !c && !s;
1373
- }
1374
- }
1375
- function Tt(e, t) {
1376
- if (e.presentation.mode === "auto")
1377
- return { ok: !0 };
1378
- if (e.presentation.mode === "preset") {
1379
- const n = wt[e.presentation.preset];
1380
- return n.includes(t) ? { ok: !0 } : {
1381
- ok: !1,
1382
- code: "incompatible_temporal_bucket_preset",
1383
- message: `Preset ${e.presentation.preset} requires ${n.join(", ")} granularity.`
1384
- };
1385
- }
1386
- const r = R(e.presentation.pattern);
1387
- return r.ok ? hn(
1388
- yn(r.segments),
1389
- t
1390
- ) ? { ok: !0, segments: r.segments } : {
1391
- ok: !1,
1392
- code: "incompatible_temporal_bucket_pattern",
1393
- message: `Pattern ${e.presentation.pattern} is not compatible with ${t} granularity.`
1394
- } : r;
1395
- }
1396
- function ai(e, t) {
1397
- if (!(!e || !t))
1398
- return Tt(e, t).ok ? e : void 0;
1399
- }
1400
- function ii(e) {
1401
- return e.preset ? { mode: "preset", preset: e.preset } : e.pattern ? { mode: "pattern", dialect: e.dialect ?? "semaphor_tokens", pattern: e.pattern } : { mode: "auto" };
1402
- }
1403
- class N extends Error {
1404
- constructor(r, n) {
1405
- super(n);
1406
- x(this, "code");
1407
- this.name = "RawTemporalFormatContractError", this.code = r;
1408
- }
1409
- }
1410
- const pn = [
1411
- "SSSSSSSSS",
1412
- "SSSSSSSS",
1413
- "SSSSSSS",
1414
- "SSSSSS",
1415
- "SSSSS",
1416
- "SSSS",
1417
- "SSS",
1418
- "SS",
1419
- "S"
1420
- ], St = /^(\d{4})-(\d{2})-(\d{2})$/, Dt = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?$/, xt = /^(\d{4})-(\d{2})-(\d{2})[T ](\d{2}):(\d{2})(?::(\d{2})(?:\.(\d{1,9}))?)?(Z|[+-]\d{2}:\d{2})$/, wn = [
1421
- "yyyy",
1422
- "MMMM",
1423
- "LLLL",
1424
- "zzz",
1425
- "XXX",
1426
- "MMM",
1427
- "LLL",
1428
- "yy",
1429
- "MM",
1430
- "dd",
1431
- "HH",
1432
- "hh",
1433
- "mm",
1434
- "ss",
1435
- "M",
1436
- "d",
1437
- "H",
1438
- "h",
1439
- "m",
1440
- "s",
1441
- "a"
1442
- ], Tn = /* @__PURE__ */ new Set([
1443
- "HH",
1444
- "H",
1445
- "hh",
1446
- "h",
1447
- "mm",
1448
- "m",
1449
- "ss",
1450
- "s",
1451
- "a",
1452
- ...pn
1453
- ]), Sn = /* @__PURE__ */ new Set(["zzz", "XXX"]), le = /* @__PURE__ */ new Set(["short", "medium", "long"]);
1454
- function S(e, t) {
1455
- return Object.keys(e).length === t.length && t.every((n) => n in e);
1456
- }
1457
- function m(e) {
1458
- throw new N(
1459
- "invalid_raw_temporal_format",
1460
- e
1461
- );
1462
- }
1463
- function vt(e) {
1464
- if (!e || e.trim() !== e || e.length > 256)
1465
- return m(
1466
- "date_fns patterns must be non-empty, trimmed, and at most 256 characters."
1467
- );
1468
- const t = [], r = (a) => {
1469
- const i = t[t.length - 1];
1470
- (i == null ? void 0 : i.kind) === "literal" ? i.value += a : t.push({ kind: "literal", value: a });
1471
- };
1472
- let n = 0;
1473
- for (; n < e.length; ) {
1474
- if (e[n] === "'") {
1475
- if (e[n + 1] === "'") {
1476
- r("'"), n += 2;
1477
- continue;
1478
- }
1479
- let o = "", c = !1;
1480
- for (n += 1; n < e.length; ) {
1481
- if (e[n] === "'") {
1482
- if (e[n + 1] === "'") {
1483
- o += "'", n += 2;
1484
- continue;
1485
- }
1486
- c = !0, n += 1;
1487
- break;
1488
- }
1489
- o += e[n], n += 1;
1490
- }
1491
- if (!c)
1492
- return m("date_fns pattern has an unclosed quote.");
1493
- r(o);
1494
- continue;
1495
- }
1496
- if (e[n] === "S") {
1497
- let o = n + 1;
1498
- for (; e[o] === "S"; ) o += 1;
1499
- const c = e.slice(n, o);
1500
- if (c.length > 9)
1501
- return m(
1502
- "date_fns fractional-second tokens support at most nine digits."
1503
- );
1504
- t.push({
1505
- kind: "token",
1506
- value: c
1507
- }), n = o;
1508
- continue;
1509
- }
1510
- const a = wn.find(
1511
- (o) => e.startsWith(o, n)
1512
- );
1513
- if (a) {
1514
- t.push({ kind: "token", value: a }), n += a.length;
1515
- continue;
1516
- }
1517
- const i = e[n];
1518
- if (/[A-Za-z]/.test(i))
1519
- return m(
1520
- `Unsupported date_fns pattern token beginning at "${e.slice(n)}".`
1521
- );
1522
- r(i), n += 1;
1523
- }
1524
- return t.some((a) => a.kind === "token") ? t : m("date_fns patterns must contain at least one token.");
1525
- }
1526
- function kt(e, t) {
1527
- if (e === "semaphor_tokens") {
1528
- const r = R(t);
1529
- r.ok || m(r.message);
1530
- return;
1531
- }
1532
- vt(t);
1533
- }
1534
- function Dn(e) {
1535
- return !g(e) || !S(e, ["dateStyle", "dateTime"]) ? m("Automatic raw temporal styles are incomplete.") : le.has(e.dateStyle) ? !g(e.dateTime) || !S(e.dateTime, ["dateStyle", "timeStyle"]) || !le.has(e.dateTime.dateStyle) || !le.has(e.dateTime.timeStyle) ? m(
1536
- "Automatic dateTime styles are incomplete or invalid."
1537
- ) : {
1538
- dateStyle: e.dateStyle,
1539
- dateTime: {
1540
- dateStyle: e.dateTime.dateStyle,
1541
- timeStyle: e.dateTime.timeStyle
1542
- }
1543
- } : m("Automatic dateStyle is invalid.");
1544
- }
1545
- function ve(e) {
1546
- const t = ["type", "locale", "calendarTimezone", "presentation"], r = [...t, "sourceTimezone"];
1547
- if (!g(e) || !S(e, t) && !S(e, r) || e.type !== "raw_temporal")
1548
- return m("Resolved raw temporal format has an invalid shape.");
1549
- const n = A(e.locale);
1550
- return n ? typeof e.calendarTimezone != "string" || !V(e.calendarTimezone) ? m(
1551
- "Raw temporal calendarTimezone must be a valid IANA timezone."
1552
- ) : e.sourceTimezone !== void 0 && (typeof e.sourceTimezone != "string" || !V(e.sourceTimezone)) ? m(
1553
- "Raw temporal sourceTimezone must be a valid IANA timezone."
1554
- ) : g(e.presentation) ? e.presentation.mode === "auto" ? S(e.presentation, ["mode", "styles"]) ? {
1555
- type: "raw_temporal",
1556
- locale: n,
1557
- calendarTimezone: e.calendarTimezone,
1558
- ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
1559
- presentation: {
1560
- mode: "auto",
1561
- styles: Dn(e.presentation.styles)
1562
- }
1563
- } : m(
1564
- "Automatic raw temporal presentation has unknown fields."
1565
- ) : e.presentation.mode === "preset" ? !S(e.presentation, ["mode", "preset"]) || !Mt(e.presentation.preset) ? m("Preset raw temporal presentation has an invalid shape.") : {
1566
- type: "raw_temporal",
1567
- locale: n,
1568
- calendarTimezone: e.calendarTimezone,
1569
- ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
1570
- presentation: { mode: "preset", preset: e.presentation.preset }
1571
- } : e.presentation.mode !== "pattern" || !S(e.presentation, ["mode", "dialect", "pattern"]) || e.presentation.dialect !== "semaphor_tokens" && e.presentation.dialect !== "date_fns" || typeof e.presentation.pattern != "string" ? m(
1572
- "Pattern raw temporal presentation has an invalid shape."
1573
- ) : (kt(e.presentation.dialect, e.presentation.pattern), {
1574
- type: "raw_temporal",
1575
- locale: n,
1576
- calendarTimezone: e.calendarTimezone,
1577
- ...e.sourceTimezone ? { sourceTimezone: e.sourceTimezone } : {},
1578
- presentation: {
1579
- mode: "pattern",
1580
- dialect: e.presentation.dialect,
1581
- pattern: e.presentation.pattern
1582
- }
1583
- }) : m("Raw temporal presentation must be an object.") : m("Raw temporal locale is invalid or unsupported.");
1584
- }
1585
- function xn(e) {
1586
- var c, s, u;
1587
- if (e.format) {
1588
- if (!g(e.format))
1589
- return m(
1590
- "Authored raw temporal format has an invalid shape."
1591
- );
1592
- const l = Object.keys(e.format);
1593
- if (!l.includes("type") || !l.includes("presentation") || l.some(
1594
- (y) => y !== "type" && y !== "presentation" && y !== "timezone" && y !== "sourceTimezone"
1595
- ) || e.format.type !== "raw_temporal" || !g(e.format.presentation))
1596
- return m(
1597
- "Authored raw temporal format has an invalid shape."
1598
- );
1599
- const d = e.format.presentation;
1600
- if (d.mode === "auto") {
1601
- if (!S(d, ["mode"]))
1602
- return m(
1603
- "Automatic authored raw temporal format has unknown fields."
1604
- );
1605
- } else if (d.mode === "preset") {
1606
- if (!S(d, ["mode", "preset"]) || !Mt(d.preset))
1607
- return m("Authored raw temporal preset has an invalid shape.");
1608
- } else {
1609
- if (d.mode !== "pattern" || !S(d, ["mode", "dialect", "pattern"]) || d.dialect !== "semaphor_tokens" && d.dialect !== "date_fns" || typeof d.pattern != "string")
1610
- return m(
1611
- "Authored raw temporal pattern has an invalid shape."
1612
- );
1613
- kt(d.dialect, d.pattern);
1614
- }
1615
- }
1616
- const t = (c = e.format) == null ? void 0 : c.timezone, r = (s = e.format) == null ? void 0 : s.sourceTimezone, n = t && t !== "auto" ? t : e.calendar.tz, a = r && r !== "auto" ? r === "local" ? Intl.DateTimeFormat().resolvedOptions().timeZone : r : void 0;
1617
- if (t !== void 0 && t !== "auto" && !V(n) || a !== void 0 && !V(a))
1618
- return m("Authored raw temporal timezone is invalid.");
1619
- const i = ((u = e.format) == null ? void 0 : u.presentation) ?? { mode: "auto" }, o = {
1620
- type: "raw_temporal",
1621
- locale: e.preferences.locale,
1622
- calendarTimezone: n,
1623
- ...a ? { sourceTimezone: a } : {},
1624
- presentation: i.mode === "pattern" || i.mode === "preset" ? { ...i } : {
1625
- mode: "auto",
1626
- styles: {
1627
- dateStyle: e.preferences.dateStyle,
1628
- dateTime: { ...e.preferences.dateTime }
1629
- }
1630
- }
1631
- };
1632
- return ve(o);
1633
- }
1634
- function vn(e) {
1635
- if (St.test(e)) return "date";
1636
- if (xt.test(e)) return "instant";
1637
- if (Dt.test(e)) return "wall_datetime";
1638
- }
1639
- function oi(e) {
1640
- const t = /* @__PURE__ */ new Set();
1641
- let r = !1;
1642
- for (const n of e.values) {
1643
- if (n === null) continue;
1644
- r = !0;
1645
- const a = vn(n);
1646
- a && t.add(a);
1647
- }
1648
- if (!r) return { status: "empty" };
1649
- if (t.size === 0) return { status: "invalid_only" };
1650
- if (t.size > 1)
1651
- throw new N(
1652
- "mixed_sql_temporal_semantics",
1653
- `Declared SQL temporal column "${e.columnKey}" mixes date, wall-datetime, or instant semantics. Normalize it to one kind.`
1654
- );
1655
- return {
1656
- status: "classified",
1657
- metadata: {
1658
- kind: "raw_temporal",
1659
- valueKind: [...t][0]
1660
- }
1661
- };
1662
- }
1663
- function si(e) {
1664
- return {
1665
- version: 1,
1666
- columns: Object.fromEntries(
1667
- [...e].map(([t, r]) => [
1668
- t,
1669
- r.status === "classified" ? r.metadata.valueKind : r.status
1670
- ])
1671
- )
1672
- };
1673
- }
1674
- function kn(e) {
1675
- if (!g(e) || e.version !== 1 || !g(e.columns) || Object.keys(e).some((n) => n !== "version" && n !== "columns"))
1676
- throw new N(
1677
- "invalid_raw_temporal_format",
1678
- "Raw temporal chunk classification evidence is malformed."
1679
- );
1680
- const t = {}, r = /* @__PURE__ */ new Set([
1681
- "empty",
1682
- "invalid_only",
1683
- "date",
1684
- "wall_datetime",
1685
- "instant"
1686
- ]);
1687
- for (const [n, a] of Object.entries(e.columns)) {
1688
- if (!n.trim() || !r.has(a))
1689
- throw new N(
1690
- "invalid_raw_temporal_format",
1691
- "Raw temporal chunk classification evidence contains an invalid column or status."
1692
- );
1693
- t[n] = a;
1694
- }
1695
- return { version: 1, columns: t };
1696
- }
1697
- function ci(e) {
1698
- if (e.length === 0) return;
1699
- const t = e.map(kn), r = Object.keys(t[0].columns).sort();
1700
- for (let n = 1; n < t.length; n += 1) {
1701
- const a = Object.keys(t[n].columns).sort();
1702
- if (a.length !== r.length || a.some((i, o) => i !== r[o]))
1703
- throw new N(
1704
- "invalid_raw_temporal_format",
1705
- "Raw temporal chunk classification evidence has inconsistent columns."
1706
- );
1707
- }
1708
- for (const n of r)
1709
- if (new Set(
1710
- t.map((i) => i.columns[n]).filter(
1711
- (i) => i !== "empty" && i !== "invalid_only"
1712
- )
1713
- ).size > 1)
1714
- throw new N(
1715
- "mixed_sql_temporal_semantics",
1716
- `Declared SQL temporal column "${n}" has inconsistent semantics across export chunks. Normalize it to one kind.`
1717
- );
1718
- }
1719
- function _n(e) {
1720
- return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
1721
- }
1722
- function bn(e, t) {
1723
- return t === 2 ? _n(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
1724
- }
1725
- function $n(e) {
1726
- return e.year >= 1 && e.year <= 9999 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= bn(e.year, e.month) && e.hour >= 0 && e.hour <= 23 && e.minute >= 0 && e.minute <= 59 && e.second >= 0 && e.second <= 59;
1727
- }
1728
- function Mn(e) {
1729
- return {
1730
- year: Number(e[1]),
1731
- month: Number(e[2]),
1732
- day: Number(e[3]),
1733
- hour: Number(e[4] ?? 0),
1734
- minute: Number(e[5] ?? 0),
1735
- second: Number(e[6] ?? 0),
1736
- fraction: e[7] ?? ""
1737
- };
1738
- }
1739
- function Nn(e, t) {
1740
- const r = t === "date" ? e.match(St) : t === "wall_datetime" ? e.match(Dt) : e.match(xt);
1741
- if (!r) return { status: "invalid_shape" };
1742
- const n = Mn(r);
1743
- if (!$n(n)) return { status: "out_of_range" };
1744
- if (t === "instant") {
1745
- const a = r[8];
1746
- if (a && a !== "Z") {
1747
- const [o, c] = a.slice(1).split(":").map(Number);
1748
- if (o > 23 || c > 59) return { status: "out_of_range" };
1749
- }
1750
- const i = new Date(e.replace(" ", "T"));
1751
- return Number.isNaN(i.getTime()) ? { status: "out_of_range" } : { status: "valid", fields: n, instant: i };
1752
- }
1753
- return { status: "valid", fields: n };
1754
- }
1755
- function we(e) {
1756
- const t = /* @__PURE__ */ new Date(0);
1757
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
1758
- }
1759
- function ke(e, t) {
1760
- const r = e.fraction ? `.${e.fraction.padEnd(3, "0").slice(0, 3)}` : "";
1761
- return ee(
1762
- `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}T${String(e.hour).padStart(2, "0")}:${String(e.minute).padStart(2, "0")}:${String(e.second).padStart(2, "0")}${r}`,
1763
- t
1764
- );
1765
- }
1766
- function _t(e, t) {
1767
- const r = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
1768
- let a, i, o, c;
1769
- return {
1770
- number(s, u = 1) {
1771
- let l = r.get(u);
1772
- return l || (l = new Intl.NumberFormat(e, {
1773
- useGrouping: !1,
1774
- minimumIntegerDigits: u,
1775
- maximumFractionDigits: 0
1776
- }), r.set(u, l)), l.format(s);
1777
- },
1778
- month(s, u, l) {
1779
- var T;
1780
- const d = `${u}:${l ? "standalone" : "contextual"}`;
1781
- let y = n.get(d);
1782
- if (!y) {
1783
- const h = {
1784
- calendar: "gregory",
1785
- timeZone: "UTC",
1786
- month: u
1787
- };
1788
- l || (h.day = "numeric"), y = new Intl.DateTimeFormat(e, h), n.set(d, y);
1789
- }
1790
- return ((T = y.formatToParts(s).find((h) => h.type === "month")) == null ? void 0 : T.value) ?? "";
1791
- },
1792
- dayPeriod(s) {
1793
- var u;
1794
- return a ?? (a = new Intl.DateTimeFormat(e, {
1795
- calendar: "gregory",
1796
- timeZone: "UTC",
1797
- hour: "numeric",
1798
- hour12: !0
1799
- })), ((u = a.formatToParts(s).find((l) => l.type === "dayPeriod")) == null ? void 0 : u.value) ?? "";
1800
- },
1801
- instantFields(s) {
1802
- i ?? (i = new Intl.DateTimeFormat("en-CA", {
1803
- calendar: "gregory",
1804
- numberingSystem: "latn",
1805
- timeZone: t,
1806
- year: "numeric",
1807
- month: "2-digit",
1808
- day: "2-digit",
1809
- hour: "2-digit",
1810
- minute: "2-digit",
1811
- second: "2-digit",
1812
- hourCycle: "h23"
1813
- }));
1814
- const u = i.formatToParts(s), l = (d) => {
1815
- var y;
1816
- return Number((y = u.find((T) => T.type === d)) == null ? void 0 : y.value);
1817
- };
1818
- return {
1819
- year: l("year"),
1820
- month: l("month"),
1821
- day: l("day"),
1822
- hour: l("hour"),
1823
- minute: l("minute"),
1824
- second: l("second"),
1825
- fraction: ""
1826
- };
1827
- },
1828
- timezoneName(s) {
1829
- var u;
1830
- return o ?? (o = new Intl.DateTimeFormat(e, {
1831
- calendar: "gregory",
1832
- timeZone: t,
1833
- timeZoneName: "short"
1834
- })), ((u = o.formatToParts(s).find((l) => l.type === "timeZoneName")) == null ? void 0 : u.value) ?? "";
1835
- },
1836
- timezoneOffset(s) {
1837
- var d;
1838
- c ?? (c = new Intl.DateTimeFormat("en-US", {
1839
- calendar: "gregory",
1840
- timeZone: t,
1841
- timeZoneName: "longOffset"
1842
- }));
1843
- const u = (d = c.formatToParts(s).find((y) => y.type === "timeZoneName")) == null ? void 0 : d.value;
1844
- if (!u)
1845
- return m("Unable to resolve the instant timezone offset.");
1846
- const l = u.replace(/^GMT/, "");
1847
- return l === "" || /^[+-]00:00$/.test(l) ? "Z" : l;
1848
- }
1849
- };
1850
- }
1851
- function In(e, t, r, n, a) {
1852
- if (/^S{1,9}$/.test(e)) {
1853
- const i = t.fraction.padEnd(e.length, "0").slice(0, e.length);
1854
- return n.number(Number(i), e.length);
1855
- }
1856
- switch (e) {
1857
- case "YYYY":
1858
- case "yyyy":
1859
- return n.number(t.year, 4);
1860
- case "YY":
1861
- case "yy":
1862
- return n.number(t.year % 100, 2);
1863
- case "MMMM":
1864
- return n.month(r, "long", !1);
1865
- case "LLLL":
1866
- return n.month(r, "long", !0);
1867
- case "MMM":
1868
- return n.month(r, "short", !1);
1869
- case "LLL":
1870
- return n.month(r, "short", !0);
1871
- case "MM":
1872
- return n.number(t.month, 2);
1873
- case "M":
1874
- return n.number(t.month);
1875
- case "DD":
1876
- case "dd":
1877
- return n.number(t.day, 2);
1878
- case "d":
1879
- return n.number(t.day);
1880
- case "HH":
1881
- return n.number(t.hour, 2);
1882
- case "H":
1883
- return n.number(t.hour);
1884
- case "hh":
1885
- return n.number(t.hour % 12 || 12, 2);
1886
- case "h":
1887
- return n.number(t.hour % 12 || 12);
1888
- case "mm":
1889
- return n.number(t.minute, 2);
1890
- case "m":
1891
- return n.number(t.minute);
1892
- case "ss":
1893
- return n.number(t.second, 2);
1894
- case "s":
1895
- return n.number(t.second);
1896
- case "a":
1897
- return n.dayPeriod(r);
1898
- case "zzz":
1899
- return a ? n.timezoneName(a) : m(
1900
- "Timezone pattern tokens require an instant value."
1901
- );
1902
- case "XXX":
1903
- return a ? n.timezoneOffset(a) : m(
1904
- "Timezone pattern tokens require an instant value."
1905
- );
1906
- default:
1907
- return m(
1908
- `Unsupported raw temporal pattern token "${e}".`
1909
- );
1910
- }
1911
- }
1912
- function En(e, t, r, n) {
1913
- const a = we(t);
1914
- return e.map(
1915
- (i) => i.kind === "literal" ? i.value : In(i.value, t, a, r, n)
1916
- ).join("");
1917
- }
1918
- function bt(e, t, r) {
1919
- const n = t === "date_fns" ? vt(r) : (() => {
1920
- const i = R(r);
1921
- return i.ok ? i.segments : m(i.message);
1922
- })(), a = n.filter((i) => i.kind === "token").map((i) => i.value);
1923
- return e === "date" && a.some((i) => Tn.has(i)) ? m("Date patterns cannot contain time tokens.") : e !== "instant" && a.some((i) => Sn.has(i)) ? m("Timezone pattern tokens require an instant value.") : n;
1924
- }
1925
- function Fn(e) {
1926
- bt(
1927
- e.valueKind ?? "instant",
1928
- e.dialect,
1929
- e.pattern
1930
- );
1931
- }
1932
- function Cn(e, t, r, n) {
1933
- const a = bt(
1934
- e.valueKind,
1935
- r,
1936
- n
1937
- ), i = _t(t.locale, t.calendarTimezone);
1938
- return (o) => {
1939
- const c = e.valueKind === "wall_datetime" && t.sourceTimezone ? ke(o.fields, t.sourceTimezone) : void 0, s = e.valueKind === "instant" ? {
1940
- ...i.instantFields(o.instant),
1941
- fraction: o.fields.fraction
1942
- } : c ? {
1943
- ...i.instantFields(c),
1944
- fraction: o.fields.fraction
1945
- } : o.fields;
1946
- return En(a, s, i, o.instant ?? c);
1947
- };
1948
- }
1949
- function $t(e, t) {
1950
- const r = _t(t.locale, t.calendarTimezone);
1951
- return (n) => {
1952
- const a = e.valueKind === "instant" ? r.instantFields(n.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? r.instantFields(ke(n.fields, t.sourceTimezone)) : n.fields;
1953
- return {
1954
- year: a.year,
1955
- month: a.month,
1956
- day: a.day,
1957
- hour: a.hour,
1958
- minute: a.minute,
1959
- second: a.second
1960
- };
1961
- };
1962
- }
1963
- const Un = /* @__PURE__ */ new Set(["short", "long", "numeric", "iso"]);
1964
- function Mt(e) {
1965
- return typeof e == "string" && Un.has(e);
1966
- }
1967
- function zn(e, t, r) {
1968
- const n = $t(e, t), a = e.valueKind !== "date", i = (c, s = 2) => String(c).padStart(s, "0");
1969
- if (r === "iso")
1970
- return (c) => {
1971
- const s = n(c), u = `${i(s.year, 4)}-${i(s.month)}-${i(s.day)}`;
1972
- return a ? `${u} ${i(s.hour)}:${i(s.minute)}` : u;
1973
- };
1974
- const o = new Intl.DateTimeFormat(t.locale, {
1975
- calendar: "gregory",
1976
- timeZone: "UTC",
1977
- year: "numeric",
1978
- month: r,
1979
- day: "numeric",
1980
- ...a ? { hour: "numeric", minute: "2-digit" } : {}
1981
- });
1982
- return (c) => {
1983
- const s = n(c), u = /* @__PURE__ */ new Date(0);
1984
- return u.setUTCFullYear(s.year, s.month - 1, s.day), u.setUTCHours(s.hour, s.minute, s.second, 0), o.format(u);
1985
- };
1986
- }
1987
- function An(e, t) {
1988
- const r = t.presentation.mode === "auto" ? t.presentation.styles : m("Automatic raw temporal formatting requires styles.");
1989
- if (e.valueKind === "date") {
1990
- const o = new Intl.DateTimeFormat(t.locale, {
1991
- calendar: "gregory",
1992
- timeZone: "UTC",
1993
- dateStyle: r.dateStyle
1994
- });
1995
- return (c) => o.format(we(c.fields));
1996
- }
1997
- const n = e.valueKind === "instant", a = !n && r.dateTime.timeStyle === "long" ? "medium" : r.dateTime.timeStyle, i = new Intl.DateTimeFormat(t.locale, {
1998
- calendar: "gregory",
1999
- timeZone: n || e.valueKind === "wall_datetime" && t.sourceTimezone ? t.calendarTimezone : "UTC",
2000
- dateStyle: r.dateTime.dateStyle,
2001
- timeStyle: a
2002
- });
2003
- return (o) => n ? i.format(o.instant) : e.valueKind === "wall_datetime" && t.sourceTimezone ? i.format(ke(o.fields, t.sourceTimezone)) : i.format(we(o.fields));
2004
- }
2005
- function Ve(e, t, r) {
2006
- return {
2007
- ok: !1,
2008
- text: e,
2009
- diagnostic: {
2010
- code: r,
2011
- message: `Raw temporal ${t.valueKind} value is ${r === "invalid_raw_temporal_value" ? "malformed" : "out of range"}.`
2012
- }
2013
- };
2014
- }
2015
- function On(e) {
2016
- const t = Wt(e.metadata), r = ve(e.format), n = r.presentation.mode === "auto" ? An(t, r) : r.presentation.mode === "preset" ? zn(t, r, r.presentation.preset) : Cn(
2017
- t,
2018
- r,
2019
- r.presentation.dialect,
2020
- r.presentation.pattern
2021
- ), a = $t(t, r);
2022
- return (i) => {
2023
- if (i === null)
2024
- return { ok: !0, text: "", status: "empty" };
2025
- const o = Nn(i, t.valueKind);
2026
- return o.status === "invalid_shape" ? Ve(i, t, "invalid_raw_temporal_value") : o.status === "out_of_range" ? Ve(i, t, "out_of_range_raw_temporal_value") : {
2027
- ok: !0,
2028
- text: n(o),
2029
- status: "formatted",
2030
- wallClock: a(o)
2031
- };
2032
- };
2033
- }
2034
- function Rn(e) {
2035
- return On({
2036
- metadata: e.metadata,
2037
- format: e.format
2038
- })(e.value);
2039
- }
2040
- const Yn = {
2041
- dateStyle: "short",
2042
- dateTime: { dateStyle: "short", timeStyle: "short" }
2043
- };
2044
- class q extends Error {
2045
- constructor(r, n) {
2046
- super(n);
2047
- x(this, "code");
2048
- this.name = "TemporalBucketContractError", this.code = r;
2049
- }
2050
- }
2051
- const Pn = [
2052
- "Jan",
2053
- "Feb",
2054
- "Mar",
2055
- "Apr",
2056
- "May",
2057
- "Jun",
2058
- "Jul",
2059
- "Aug",
2060
- "Sep",
2061
- "Oct",
2062
- "Nov",
2063
- "Dec"
2064
- ], Ln = [
2065
- "January",
2066
- "February",
2067
- "March",
2068
- "April",
2069
- "May",
2070
- "June",
2071
- "July",
2072
- "August",
2073
- "September",
2074
- "October",
2075
- "November",
2076
- "December"
2077
- ];
2078
- function me(e) {
2079
- return {
2080
- ok: !1,
2081
- error: { code: "invalid_temporal_bucket_value", message: e }
2082
- };
2083
- }
2084
- function jn(e) {
2085
- return e % 4 === 0 && (e % 100 !== 0 || e % 400 === 0);
2086
- }
2087
- function Kn(e, t) {
2088
- return t === 2 ? jn(e) ? 29 : 28 : [4, 6, 9, 11].includes(t) ? 30 : 31;
2089
- }
2090
- function Hn(e, t, r) {
2091
- const n = [0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4], a = t < 3 ? e - 1 : e;
2092
- return (a + Math.floor(a / 4) - Math.floor(a / 100) + Math.floor(a / 400) + n[t - 1] + r) % 7;
2093
- }
2094
- function te(e) {
2095
- var t;
2096
- return (t = e.calendar.fiscalCalendar) == null ? void 0 : t.yearStartMonth;
2097
- }
2098
- function Zn(e, t) {
2099
- return (e - t + 12) % 12 % 3 === 0;
2100
- }
2101
- function qn(e, t) {
2102
- const { granularity: r } = t, n = te(t) ?? 1;
2103
- switch (r) {
2104
- case "second":
2105
- return !0;
2106
- case "minute":
2107
- return e.second === 0;
2108
- case "hour":
2109
- return e.minute === 0 && e.second === 0;
2110
- case "day":
2111
- return !0;
2112
- case "week":
2113
- return Hn(e.year, e.month, e.day) === t.calendar.weekStart;
2114
- case "month":
2115
- return e.day === 1;
2116
- case "quarter":
2117
- return e.day === 1 && Zn(e.month, n);
2118
- case "year":
2119
- return e.day === 1 && e.month === n;
2120
- }
2121
- }
2122
- function Nt(e, t) {
2123
- if (e === null) return { ok: !0, value: null };
2124
- const r = t.granularity === "second" || t.granularity === "minute" || t.granularity === "hour", n = r ? /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})$/.exec(e) : /^(\d{4})-(\d{2})-(\d{2})$/.exec(e);
2125
- if (!n)
2126
- return me(
2127
- `Expected ${r ? "YYYY-MM-DDTHH:mm:ss" : "YYYY-MM-DD"} for ${t.granularity} granularity.`
2128
- );
2129
- const a = {
2130
- year: Number(n[1]),
2131
- month: Number(n[2]),
2132
- day: Number(n[3]),
2133
- hour: r ? Number(n[4]) : 0,
2134
- minute: r ? Number(n[5]) : 0,
2135
- second: r ? Number(n[6]) : 0
2136
- };
2137
- return a.year < 1 || a.month < 1 || a.month > 12 || a.day < 1 || a.day > Kn(a.year, a.month) || a.hour > 23 || a.minute > 59 || a.second > 59 ? me(`Invalid canonical ${t.granularity} bucket value ${e}.`) : qn(a, t) ? { ok: !0, value: a } : me(
2138
- `Canonical value ${e} is not aligned to ${t.granularity} granularity and its governed Calendar.`
2139
- );
2140
- }
2141
- function ui(e) {
2142
- const { granularity: t, calendar: r } = e, n = (o, c) => new Intl.DateTimeFormat("en-US", { ...o, timeZone: "UTC" }).format(c), a = [`by ${t} in the ${r.tz} calendar`];
2143
- t === "week" && a.push(`weeks starting on ${n({ weekday: "long" }, new Date(Date.UTC(2023, 0, 1 + r.weekStart)))}`);
2144
- const i = te(e);
2145
- return i && (t === "quarter" || t === "year") && a.push(`the fiscal year starting in ${n({ month: "long" }, new Date(Date.UTC(2e3, i - 1, 1)))}`), `${a.join(", ")}; each value is a bucket's start`;
2146
- }
2147
- function It(e) {
2148
- if (!g(e))
2149
- return {
2150
- ok: !1,
2151
- issues: [{ path: "$", message: "Resolved temporal bucket format must be an object." }]
2152
- };
2153
- const t = [], r = /* @__PURE__ */ new Set(["type", "presentation", "locale"]);
2154
- for (const o of Object.keys(e))
2155
- r.has(o) || t.push({ path: o, message: `Unknown property "${o}".` });
2156
- e.type !== "temporal_bucket" && t.push({ path: "type", message: "Expected temporal_bucket." });
2157
- const n = e.presentation;
2158
- if (!g(n))
2159
- t.push({ path: "presentation", message: "Expected a presentation object." });
2160
- else {
2161
- const o = n.mode, c = o === "preset" ? /* @__PURE__ */ new Set(["mode", "preset"]) : o === "pattern" ? /* @__PURE__ */ new Set(["mode", "pattern"]) : o === "auto" ? /* @__PURE__ */ new Set(["mode", "styles"]) : /* @__PURE__ */ new Set(["mode"]);
2162
- for (const s of Object.keys(n))
2163
- c.has(s) || t.push({
2164
- path: `presentation.${s}`,
2165
- message: `Unknown property "${s}".`
2166
- });
2167
- if (o === "preset")
2168
- dn(n.preset) || t.push({ path: "presentation.preset", message: "Expected a supported preset." });
2169
- else if (o === "pattern")
2170
- if (typeof n.pattern != "string" || !n.pattern)
2171
- t.push({ path: "presentation.pattern", message: "Expected a non-empty pattern." });
2172
- else {
2173
- const s = R(n.pattern);
2174
- s.ok || t.push({
2175
- path: "presentation.pattern",
2176
- message: s.message
2177
- });
2178
- }
2179
- else if (o === "auto") {
2180
- const s = n.styles;
2181
- (!g(s) || !["short", "medium", "long"].includes(String(s.dateStyle)) || !g(s.dateTime) || !["short", "medium", "long"].includes(
2182
- String(s.dateTime.dateStyle)
2183
- ) || !["short", "medium", "long"].includes(
2184
- String(s.dateTime.timeStyle)
2185
- ) || Object.keys(s).some(
2186
- (u) => u !== "dateStyle" && u !== "dateTime"
2187
- ) || Object.keys(s.dateTime).some(
2188
- (u) => u !== "dateStyle" && u !== "timeStyle"
2189
- )) && t.push({
2190
- path: "presentation.styles",
2191
- message: "Expected complete resolved date and datetime styles."
2192
- });
2193
- } else
2194
- t.push({ path: "presentation.mode", message: "Expected auto, preset, or pattern." });
2195
- }
2196
- const a = A(e.locale);
2197
- if (a || t.push({ path: "locale", message: "Expected a supported base BCP 47 locale." }), t.length > 0 || !a || !g(n))
2198
- return { ok: !1, issues: t };
2199
- if (n.mode === "auto") {
2200
- const o = n.styles;
2201
- return {
2202
- ok: !0,
2203
- value: {
2204
- type: "temporal_bucket",
2205
- locale: a,
2206
- presentation: {
2207
- mode: "auto",
2208
- styles: {
2209
- dateStyle: o.dateStyle,
2210
- dateTime: {
2211
- dateStyle: o.dateTime.dateStyle,
2212
- timeStyle: o.dateTime.timeStyle
2213
- }
2214
- }
2215
- }
2216
- }
2217
- };
2218
- }
2219
- return {
2220
- ok: !0,
2221
- value: {
2222
- type: "temporal_bucket",
2223
- presentation: n.mode === "preset" ? {
2224
- mode: "preset",
2225
- preset: n.preset
2226
- } : {
2227
- mode: "pattern",
2228
- pattern: n.pattern
2229
- },
2230
- locale: a
2231
- }
2232
- };
2233
- }
2234
- function Bn(e, t) {
2235
- const r = !!t.calendar.fiscalCalendar;
2236
- return e === "fiscal_quarter_short" || e === "fiscal_year" ? r : e === "quarter_short" || e === "quarter_long" || Ut(e) && (t.granularity === "quarter" || t.granularity === "year") ? !r : !0;
2237
- }
2238
- function Et(e, t) {
2239
- return Tt(e, t.granularity).ok ? e.presentation.mode === "preset" ? Bn(e.presentation.preset, t) : !(e.presentation.mode === "pattern" && t.calendar.fiscalCalendar && (t.granularity === "quarter" || t.granularity === "year")) : !1;
2240
- }
2241
- function Ge(e, t) {
2242
- if (!(!e || e.presentation.mode === "auto"))
2243
- return Et(e, t) ? { type: "temporal_bucket", presentation: e.presentation } : void 0;
2244
- }
2245
- function Vn(e) {
2246
- var a;
2247
- const t = A(e.locale);
2248
- if (!t)
2249
- throw new q(
2250
- "invalid_temporal_bucket_format",
2251
- "Temporal bucket locale must be a supported base BCP 47 locale."
2252
- );
2253
- const r = Ge(e.cardFormat, e.metadata);
2254
- if (r)
2255
- return { format: { ...r, locale: t }, source: "card" };
2256
- const n = ((a = e.semanticFormat) == null ? void 0 : a.granularity) === e.metadata.granularity ? Ge(e.semanticFormat.format, e.metadata) : void 0;
2257
- return n ? { format: { ...n, locale: t }, source: "semantic" } : {
2258
- format: {
2259
- type: "temporal_bucket",
2260
- locale: t,
2261
- presentation: {
2262
- mode: "auto",
2263
- styles: e.styles ?? Yn
2264
- }
2265
- },
2266
- source: "automatic"
2267
- };
2268
- }
2269
- function p(e, t = 2) {
2270
- return String(e).padStart(t, "0");
2271
- }
2272
- function U(e, t, r) {
2273
- if (t === "en-US")
2274
- return (r === "short" ? Pn : Ln)[e - 1];
2275
- const n = new Date(Date.UTC(2e3, e - 1, 15));
2276
- return new Intl.DateTimeFormat(t, {
2277
- calendar: "gregory",
2278
- month: r,
2279
- timeZone: "UTC"
2280
- }).format(n);
2281
- }
2282
- function Gn(e, t, r) {
2283
- return t.map((n) => {
2284
- if (n.kind === "literal") return n.value;
2285
- switch (n.value) {
2286
- case "YYYY":
2287
- return p(e.year, 4);
2288
- case "YY":
2289
- return p(e.year % 100);
2290
- case "MMMM":
2291
- return U(e.month, r, "long");
2292
- case "MMM":
2293
- return U(e.month, r, "short");
2294
- case "MM":
2295
- return p(e.month);
2296
- case "DD":
2297
- return p(e.day);
2298
- case "HH":
2299
- return p(e.hour);
2300
- case "mm":
2301
- return p(e.minute);
2302
- case "ss":
2303
- return p(e.second);
2304
- }
2305
- }).join("");
2306
- }
2307
- const We = /* @__PURE__ */ new Map();
2308
- function b(e, t) {
2309
- const r = `${e}:${JSON.stringify(t)}`, n = We.get(r);
2310
- if (n) return n;
2311
- const a = new Intl.DateTimeFormat(e, t);
2312
- return We.set(r, a), a;
2313
- }
2314
- function z(e) {
2315
- const t = /* @__PURE__ */ new Date(0);
2316
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(e.hour, e.minute, e.second, 0), t;
2317
- }
2318
- function Xe(e, t, r) {
2319
- return b(t, {
2320
- calendar: "gregory",
2321
- dateStyle: r,
2322
- timeZone: "UTC"
2323
- }).format(z(e));
2324
- }
2325
- function Wn(e, t, r) {
2326
- return b(t, {
2327
- calendar: "gregory",
2328
- dateStyle: r.dateStyle,
2329
- // Grouped buckets are civil values, not instants. Long time styles would
2330
- // append a zone label that the canonical value does not semantically own.
2331
- timeStyle: r.timeStyle === "long" ? "medium" : r.timeStyle,
2332
- timeZone: "UTC"
2333
- }).format(z(e));
2334
- }
2335
- function Xn(e, t, r) {
2336
- var a;
2337
- if (r === "short") {
2338
- const i = z(e), o = b(t, {
2339
- calendar: "gregory",
2340
- dateStyle: "short",
2341
- timeZone: "UTC"
2342
- }).formatToParts(i), c = o.findIndex((l) => l.type === "month"), s = o.findIndex((l) => l.type === "year"), u = (a = b(t, {
2343
- calendar: "gregory",
2344
- timeZone: "UTC",
2345
- year: "numeric"
2346
- }).formatToParts(i).find((l) => l.type === "year")) == null ? void 0 : a.value;
2347
- if (c >= 0 && s >= 0 && u) {
2348
- const l = Math.min(c, s), d = Math.max(c, s);
2349
- let y = !1;
2350
- return o.slice(l, d + 1).filter((T) => T.type === "day" ? (y = !0, !1) : y && T.type === "literal" ? (y = !1, !1) : !0).map((T) => T.type === "year" ? u : T.value).join("");
2351
- }
2352
- }
2353
- return b(t, {
2354
- calendar: "gregory",
2355
- month: r === "short" ? "numeric" : r === "medium" ? "short" : "long",
2356
- timeZone: "UTC",
2357
- year: "numeric"
2358
- }).format(z(e));
2359
- }
2360
- function Ft(e, t) {
2361
- return Math.floor((e.month - t + 12) % 12 / 3) + 1;
2362
- }
2363
- function Je(e, t) {
2364
- return t === 1 || e.month < t ? e.year : e.year + 1;
2365
- }
2366
- function Ct(e) {
2367
- return e === 1 ? "1st" : e === 2 ? "2nd" : e === 3 ? "3rd" : `${e}th`;
2368
- }
2369
- function Ut(e) {
2370
- return e === "short" || e === "long" || e === "numeric" || e === "iso";
2371
- }
2372
- function de(e, t, r) {
2373
- return t === "iso" ? `${p(e.year, 4)}-${p(e.month)}-${p(e.day)}` : b(r, {
2374
- calendar: "gregory",
2375
- month: t === "numeric" ? "numeric" : t === "long" ? "long" : "short",
2376
- day: "numeric",
2377
- year: "numeric",
2378
- timeZone: "UTC"
2379
- }).format(z(e));
2380
- }
2381
- function Jn(e, t, r, n) {
2382
- const a = Ft(e, 1);
2383
- switch (n) {
2384
- case "week":
2385
- return t === "numeric" || t === "iso" ? de(e, t, r) : `Week of ${de(e, t, r)}`;
2386
- case "month":
2387
- return t === "iso" ? `${p(e.year, 4)}-${p(e.month)}` : t === "numeric" ? `${p(e.month)}/${p(e.year, 4)}` : `${U(e.month, r, t === "long" ? "long" : "short")} ${e.year}`;
2388
- case "quarter":
2389
- return t === "iso" ? `${p(e.year, 4)}-Q${a}` : t === "long" ? `${Ct(a)} Quarter ${e.year}` : `Q${a} ${e.year}`;
2390
- case "year":
2391
- return String(e.year);
2392
- default:
2393
- return de(e, t, r);
2394
- }
2395
- }
2396
- function Te(e, t, r, n) {
2397
- if (Ut(t))
2398
- return Jn(e, t, r, n.granularity);
2399
- const a = te(n) ?? 1, i = Ft(e, a);
2400
- switch (t) {
2401
- case "week_of_short":
2402
- return `Week of ${U(e.month, r, "short")} ${e.day}, ${e.year}`;
2403
- case "week_of_long":
2404
- return `Week of ${U(e.month, r, "long")} ${e.day}, ${e.year}`;
2405
- case "quarter_short":
2406
- return `Q${i} ${e.year}`;
2407
- case "quarter_long":
2408
- return `${Ct(i)} Quarter ${e.year}`;
2409
- case "fiscal_quarter_short":
2410
- return `Q${i} FY${Je(e, a)}`;
2411
- case "fiscal_year":
2412
- return `FY${Je(e, a)}`;
2413
- }
2414
- }
2415
- function Qn(e, t, r, n) {
2416
- const a = te(t);
2417
- switch (t.granularity) {
2418
- case "second":
2419
- case "minute":
2420
- case "hour":
2421
- return Wn(e, r, n.dateTime);
2422
- case "day":
2423
- return Xe(e, r, n.dateStyle);
2424
- case "week":
2425
- return `Week of ${Xe(e, r, n.dateStyle)}`;
2426
- case "month":
2427
- return Xn(e, r, n.dateStyle);
2428
- case "quarter":
2429
- return Te(
2430
- e,
2431
- a ? "fiscal_quarter_short" : "quarter_short",
2432
- r,
2433
- t
2434
- );
2435
- case "year":
2436
- return a ? Te(e, "fiscal_year", r, t) : String(e.year);
2437
- }
2438
- }
2439
- function li(e, t) {
2440
- if (t.granularity !== "second" && t.granularity !== "minute" && t.granularity !== "hour" && t.granularity !== "day" && t.granularity !== "month")
2441
- return;
2442
- const r = Nt(e, t);
2443
- if (!r.ok || r.value === null) return;
2444
- const { year: n, month: a, day: i, hour: o, minute: c, second: s } = r.value;
2445
- return { year: n, month: a, day: i, hour: o, minute: c, second: s };
2446
- }
2447
- function ea(e) {
2448
- const t = It(e.format);
2449
- if (!t.ok || !Et(t.value, e.metadata))
2450
- throw new q(
2451
- "invalid_temporal_bucket_format",
2452
- "Resolved temporal bucket format is invalid or inapplicable to its metadata."
2453
- );
2454
- const r = Nt(e.value, e.metadata);
2455
- if (!r.ok)
2456
- throw new q(
2457
- r.error.code,
2458
- r.error.message
2459
- );
2460
- if (r.value === null) return "(Blank)";
2461
- const { presentation: n, locale: a } = t.value;
2462
- if (n.mode === "auto")
2463
- return Qn(
2464
- r.value,
2465
- e.metadata,
2466
- a,
2467
- n.styles
2468
- );
2469
- if (n.mode === "preset")
2470
- return Te(
2471
- r.value,
2472
- n.preset,
2473
- a,
2474
- e.metadata
2475
- );
2476
- const i = R(n.pattern);
2477
- if (!i.ok)
2478
- throw new q(
2479
- "invalid_temporal_bucket_format",
2480
- i.message
2481
- );
2482
- return Gn(r.value, i.segments, a);
2483
- }
2484
- function mi(e, t) {
2485
- return t.levelLabels[e.id] ?? e.field.label ?? e.field.name;
2486
- }
2487
- function di(e, t) {
2488
- return t.measureLabels[e.id] ?? (e.kind === "aggregate" ? e.field.label ?? e.field.name : e.definition.label);
2489
- }
2490
- function fi(e) {
2491
- return qt.parse(ta(e));
2492
- }
2493
- function ta(e) {
2494
- const t = Kt.parse(e), r = (n) => ({
2495
- grand: { visible: !0, position: "after" },
2496
- levels: Object.fromEntries(
2497
- n.map((a) => [
2498
- a.id,
2499
- { visible: !0, position: "before" }
2500
- ])
2501
- )
2502
- });
2503
- return Ht.parse({
2504
- version: 1,
2505
- spec: t,
2506
- presentation: {
2507
- layout: { kind: "compact" },
2508
- absence: { emptyText: "—", nullText: "" },
2509
- levelLabels: {},
2510
- measureLabels: {},
2511
- levelFormats: {},
2512
- measureFormats: {},
2513
- totals: { rows: r(t.rows), columns: r(t.columns) }
2514
- },
2515
- defaultView: {
2516
- rows: { depth: 0, overrides: [] },
2517
- columns: { depth: t.columns.length > 1 ? 1 : 0, overrides: [] }
2518
- }
2519
- });
2520
- }
2521
- function ra(e, t) {
2522
- const r = new Map(e.map((n) => [F(n), n]));
2523
- for (const n of t ?? []) r.set(F(n), n);
2524
- return [...r.values()];
2525
- }
2526
- function yi(e) {
2527
- const { spec: t, presentation: r, defaults: n, session: a } = Zt.parse(e), i = new Map(
2528
- ra(t.sorts, a == null ? void 0 : a.sorts).map((c) => [F(c), c])
2529
- );
2530
- for (const c of ["rows", "columns"])
2531
- for (const s of t[c]) {
2532
- const u = {
2533
- axis: c,
2534
- levelId: s.id,
2535
- scope: { kind: "level" },
2536
- target: { kind: "member" },
2537
- direction: "asc",
2538
- nulls: "last"
2539
- };
2540
- i.has(F(u)) || i.set(F(u), u);
2541
- }
2542
- const o = (c, s) => ({
2543
- depth: Math.min(c.depth, Math.max(0, s - 1)),
2544
- // Leaf toggles are valid but have no effect. Collapsed ancestors retain dormant overrides.
2545
- overrides: c.overrides.filter(
2546
- (u) => u.path.length < s
2547
- )
2548
- });
2549
- return {
2550
- spec: { ...t, sorts: [...i.values()] },
2551
- presentation: r,
2552
- view: {
2553
- rows: o((a == null ? void 0 : a.rows) ?? n.rows, t.rows.length),
2554
- columns: o(
2555
- (a == null ? void 0 : a.columns) ?? n.columns,
2556
- t.columns.length
2557
- ),
2558
- sorts: (a == null ? void 0 : a.sorts) ?? []
2559
- }
2560
- };
2561
- }
2562
- class Qe extends Error {
2563
- constructor(r) {
2564
- super(
2565
- `invalid_presentation_execution_snapshot: ${r} Resave this report before running it again.`
2566
- );
2567
- x(this, "code", "invalid_presentation_execution_snapshot");
2568
- x(this, "deliveryBlocking", !0);
2569
- this.name = "PresentationExecutionSnapshotError";
2570
- }
2571
- }
2572
- class gi extends Error {
2573
- constructor(r) {
2574
- super(
2575
- `missing_resolved_raw_temporal_format: Column "${r}" has no captured presentation. Resave this report before running it again.`
2576
- );
2577
- x(this, "code", "missing_resolved_raw_temporal_format");
2578
- x(this, "deliveryBlocking", !0);
2579
- this.name = "MissingResolvedRawTemporalFormatError";
2580
- }
2581
- }
2582
- function k(e, t, r) {
2583
- const n = new Set(t), a = Object.keys(e).find((i) => !n.has(i));
2584
- if (a)
2585
- throw new Error(`${r} contains unknown property "${a}"`);
2586
- }
2587
- function na(e, t = "scope") {
2588
- if (!g(e))
2589
- throw new Error(`${t} must be an object`);
2590
- k(
2591
- e,
2592
- ["dashboardId", "cardId", "attachmentIndex"],
2593
- t
2594
- );
2595
- const r = typeof e.dashboardId == "string" ? e.dashboardId.trim() : "";
2596
- if (!r)
2597
- throw new Error(`${t}.dashboardId is required`);
2598
- const n = typeof e.cardId == "string" ? e.cardId.trim() : void 0;
2599
- if (e.cardId !== void 0 && !n)
2600
- throw new Error(`${t}.cardId must be a non-empty string`);
2601
- const a = e.attachmentIndex;
2602
- if (a !== void 0 && (typeof a != "number" || !Number.isInteger(a) || a < 0))
2603
- throw new Error(
2604
- `${t}.attachmentIndex must be a non-negative integer`
2605
- );
2606
- return {
2607
- dashboardId: r,
2608
- ...n ? { cardId: n } : {},
2609
- ...typeof a == "number" ? { attachmentIndex: a } : {}
2610
- };
2611
- }
2612
- function $(e, t, r, n) {
2613
- if (e.kind !== t) return;
2614
- k(e, ["kind", r], n);
2615
- const a = e[r];
2616
- if (typeof a != "string" || !a.trim())
2617
- throw new Error(`${n}.${r} is required`);
2618
- return a;
2619
- }
2620
- function fe(e, t) {
2621
- if (!g(e))
2622
- throw new Error(`${t} must be an object`);
2623
- const r = $(e, "metric", "metricId", t);
2624
- if (r) return { kind: "metric", metricId: r };
2625
- const n = $(e, "column", "columnKey", t);
2626
- if (n) return { kind: "column", columnKey: n };
2627
- const a = $(
2628
- e,
2629
- "matrix_measure",
2630
- "measureId",
2631
- t
2632
- );
2633
- if (a) return { kind: "matrix_measure", measureId: a };
2634
- throw new Error(`${t} is not a valid numeric presentation target`);
2635
- }
2636
- const aa = [
2637
- "type",
2638
- "inputUnit",
2639
- "outputStyle",
2640
- "largestUnit",
2641
- "smallestUnit",
2642
- "maxUnits",
2643
- "prefix",
2644
- "suffix",
2645
- "negativeStyle"
2646
- ];
2647
- function ia(e) {
2648
- return e === "millisecond" || e === "second" || e === "minute" || e === "hour" || e === "day";
2649
- }
2650
- const oa = ["type", "locale", "pattern", "timezone", "sourceTimezone"];
2651
- function sa(e, t) {
2652
- if (k(e, oa, t), typeof e.locale != "string" || !e.locale.trim())
2653
- throw new Error(`${t}.locale must be a non-empty string`);
2654
- for (const r of ["pattern", "timezone", "sourceTimezone"])
2655
- if (e[r] !== void 0 && typeof e[r] != "string")
2656
- throw new Error(`${t}.${r} must be a string`);
2657
- return {
2658
- type: "date",
2659
- locale: e.locale,
2660
- ...typeof e.pattern == "string" ? { pattern: e.pattern } : {},
2661
- ...typeof e.timezone == "string" ? { timezone: e.timezone } : {},
2662
- ...typeof e.sourceTimezone == "string" ? { sourceTimezone: e.sourceTimezone } : {}
2663
- };
2664
- }
2665
- function ca(e, t) {
2666
- k(e, aa, t);
2667
- for (const i of ["inputUnit", "largestUnit", "smallestUnit"])
2668
- if (e[i] !== void 0 && !ia(e[i]))
2669
- throw new Error(`${t}.${i} must be a duration unit`);
2670
- const r = e.outputStyle;
2671
- if (r !== void 0 && r !== "compact" && r !== "digital" && r !== "long")
2672
- throw new Error(`${t}.outputStyle must be compact, digital, or long`);
2673
- const n = e.maxUnits;
2674
- if (n !== void 0 && (typeof n != "number" || !Number.isInteger(n) || n < 0 || n > 10))
2675
- throw new Error(`${t}.maxUnits must be an integer from 0 to 10`);
2676
- for (const i of ["prefix", "suffix"])
2677
- if (e[i] !== void 0 && typeof e[i] != "string")
2678
- throw new Error(`${t}.${i} must be a string`);
2679
- const a = e.negativeStyle;
2680
- if (a !== void 0 && a !== "minus" && a !== "parentheses")
2681
- throw new Error(`${t}.negativeStyle must be minus or parentheses`);
2682
- return {
2683
- type: "duration",
2684
- ...e.inputUnit !== void 0 ? { inputUnit: e.inputUnit } : {},
2685
- ...r !== void 0 ? { outputStyle: r } : {},
2686
- ...e.largestUnit !== void 0 ? { largestUnit: e.largestUnit } : {},
2687
- ...e.smallestUnit !== void 0 ? { smallestUnit: e.smallestUnit } : {},
2688
- ...n !== void 0 ? { maxUnits: n } : {},
2689
- ...e.prefix !== void 0 ? { prefix: e.prefix } : {},
2690
- ...e.suffix !== void 0 ? { suffix: e.suffix } : {},
2691
- ...a !== void 0 ? { negativeStyle: a } : {}
2692
- };
2693
- }
2694
- function ua(e, t) {
2695
- if (!g(e))
2696
- throw new Error(`${t} must be an object`);
2697
- if (e.kind === "field") {
2698
- k(e, ["kind", "fieldId", "role"], t);
2699
- const a = typeof e.fieldId == "string" ? e.fieldId.trim() : "";
2700
- if (!a)
2701
- throw new Error(`${t}.fieldId is required`);
2702
- const i = e.role;
2703
- if (i !== void 0 && i !== "groupby" && i !== "pivotby")
2704
- throw new Error(`${t}.role must be groupby or pivotby`);
2705
- return {
2706
- kind: "field",
2707
- fieldId: a,
2708
- ...i ? { role: i } : {}
2709
- };
2710
- }
2711
- const r = $(e, "column", "columnKey", t);
2712
- if (r) return { kind: "column", columnKey: r };
2713
- const n = $(
2714
- e,
2715
- "matrix_axis",
2716
- "axisInstanceId",
2717
- t
2718
- );
2719
- if (n) return { kind: "matrix_axis", axisInstanceId: n };
2720
- throw new Error(`${t} is not a valid temporal bucket presentation target`);
2721
- }
2722
- function la(e, t) {
2723
- if (!g(e))
2724
- throw new Error(`${t} must be an object`);
2725
- const r = $(e, "column", "columnKey", t);
2726
- if (!r)
2727
- throw new Error(`${t} must identify a column`);
2728
- return { kind: "column", columnKey: r };
2729
- }
2730
- function ma(e) {
2731
- return [
2732
- e.dashboardId,
2733
- e.cardId ?? null,
2734
- e.attachmentIndex ?? null
2735
- ];
2736
- }
2737
- function J(e) {
2738
- switch (e.kind) {
2739
- case "metric":
2740
- return [e.kind, e.metricId];
2741
- case "column":
2742
- return [e.kind, e.columnKey];
2743
- case "matrix_measure":
2744
- return [e.kind, e.measureId];
2745
- case "field":
2746
- return [e.kind, e.fieldId, e.role ?? ""];
2747
- case "matrix_axis":
2748
- return [e.kind, e.axisInstanceId];
2749
- }
2750
- }
2751
- function re(e, t) {
2752
- return e.dashboardId === t.dashboardId && e.cardId === t.cardId && e.attachmentIndex === t.attachmentIndex;
2753
- }
2754
- function ne(e, t) {
2755
- const r = J(e), n = J(t);
2756
- return r.length === n.length && r.every((a, i) => a === n[i]);
2757
- }
2758
- function da(e) {
2759
- if (!Array.isArray(e))
2760
- throw new Error("resolvedFormats must be an array");
2761
- const t = /* @__PURE__ */ new Set();
2762
- return e.map((r, n) => {
2763
- var s, u;
2764
- const a = `resolvedFormats.${n}`;
2765
- if (!g(r))
2766
- throw new Error(`${a} must be an object`);
2767
- k(r, ["scope", "target", "format"], a);
2768
- const i = na(r.scope, `${a}.scope`);
2769
- if (!g(r.format))
2770
- throw new Error(`${a}.format must be an object`);
2771
- let o;
2772
- switch (r.format.type) {
2773
- case "temporal_bucket": {
2774
- const l = It(r.format);
2775
- if (!l.ok)
2776
- throw new Error(
2777
- `${a}.format is invalid: ${((s = l.issues[0]) == null ? void 0 : s.message) ?? "invalid value"}`
2778
- );
2779
- o = {
2780
- scope: i,
2781
- target: ua(r.target, `${a}.target`),
2782
- format: l.value
2783
- };
2784
- break;
2785
- }
2786
- case "raw_temporal":
2787
- o = {
2788
- scope: i,
2789
- target: la(r.target, `${a}.target`),
2790
- format: ve(r.format)
2791
- };
2792
- break;
2793
- case "number":
2794
- case "currency":
2795
- case "percent":
2796
- case "scientific": {
2797
- const l = sn(r.format);
2798
- if (!l.ok)
2799
- throw new Error(
2800
- `${a}.format is invalid: ${((u = l.issues[0]) == null ? void 0 : u.message) ?? "invalid value"}`
2801
- );
2802
- o = {
2803
- scope: i,
2804
- target: fe(r.target, `${a}.target`),
2805
- format: l.value
2806
- };
2807
- break;
2808
- }
2809
- case "date": {
2810
- const l = fe(r.target, `${a}.target`);
2811
- if (l.kind !== "column")
2812
- throw new Error(`${a}.target must identify a column for a date format`);
2813
- o = {
2814
- scope: i,
2815
- target: l,
2816
- format: sa(r.format, `${a}.format`)
2817
- };
2818
- break;
2819
- }
2820
- case "duration":
2821
- o = {
2822
- scope: i,
2823
- target: fe(r.target, `${a}.target`),
2824
- format: ca(
2825
- r.format,
2826
- `${a}.format`
2827
- )
2828
- };
2829
- break;
2830
- default:
2831
- throw new Error(`${a}.format.type is unsupported`);
2832
- }
2833
- const c = JSON.stringify([
2834
- ...ma(o.scope),
2835
- ...J(o.target)
2836
- ]);
2837
- if (t.has(c))
2838
- throw new Error(
2839
- `${a} duplicates a scoped presentation target`
2840
- );
2841
- return t.add(c), o;
2842
- });
2843
- }
2844
- function fa(e) {
2845
- try {
2846
- if (!g(e))
2847
- throw new Error("presentation execution snapshot must be an object");
2848
- if (k(
2849
- e,
2850
- ["version", "reportContext", "resolvedFormats"],
2851
- "presentation execution snapshot"
2852
- ), e.version !== 1)
2853
- throw new Error("presentation execution snapshot version must be 1");
2854
- const t = Vt(e.reportContext);
2855
- if (!t.ok) {
2856
- const r = t.issues[0];
2857
- throw new Error(
2858
- `presentation execution snapshot reportContext is invalid: ${r != null && r.path && r.path !== "$" ? `${r.path}: ` : ""}${(r == null ? void 0 : r.message) ?? "invalid value"}`
2859
- );
2860
- }
2861
- return {
2862
- version: 1,
2863
- reportContext: t.value,
2864
- resolvedFormats: da(e.resolvedFormats)
2865
- };
2866
- } catch (t) {
2867
- throw t instanceof Qe ? t : new Qe(
2868
- t instanceof Error ? t.message : "Snapshot is invalid."
2869
- );
2870
- }
2871
- }
2872
- function hi(e) {
2873
- return fa({
2874
- version: 1,
2875
- reportContext: e.reportContext,
2876
- resolvedFormats: [...e.resolvedFormats]
2877
- });
2878
- }
2879
- function pi(e) {
2880
- const t = ya(e);
2881
- return Q(t) ? t : void 0;
2882
- }
2883
- function ya(e) {
2884
- const t = e.snapshot.resolvedFormats.find(
2885
- (r) => r.format.type !== "temporal_bucket" && r.format.type !== "raw_temporal" && r.format.type !== "date" && re(r.scope, e.scope) && ne(r.target, e.target)
2886
- );
2887
- return t == null ? void 0 : t.format;
2888
- }
2889
- function wi(e) {
2890
- const t = e.snapshot.resolvedFormats.find(
2891
- (r) => r.format.type === "date" && re(r.scope, e.scope) && ne(r.target, e.target)
2892
- );
2893
- return t == null ? void 0 : t.format;
2894
- }
2895
- function Ti(e) {
2896
- const t = e.snapshot.resolvedFormats.find(
2897
- (r) => r.format.type === "raw_temporal" && re(r.scope, e.scope) && ne(r.target, e.target)
2898
- );
2899
- return t == null ? void 0 : t.format;
2900
- }
2901
- function Si(e) {
2902
- const t = e.snapshot.resolvedFormats.find(
2903
- (r) => r.format.type === "temporal_bucket" && re(r.scope, e.scope) && ne(r.target, e.target)
2904
- );
2905
- return t == null ? void 0 : t.format;
2906
- }
2907
- function Di(e) {
2908
- var a;
2909
- const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set();
2910
- if (e.snapshot.resolvedFormats.forEach((i, o) => {
2911
- if (i.scope.attachmentIndex !== void 0)
2912
- throw new Error(
2913
- `resolvedFormats.${o}.scope.attachmentIndex is not valid for a card export`
2914
- );
2915
- if (i.scope.dashboardId !== e.expectedScope.dashboardId || i.scope.cardId !== e.expectedScope.cardId)
2916
- throw new Error(
2917
- `resolvedFormats.${o}.scope must match the executing dashboard/card`
2918
- );
2919
- if (i.target.kind === "field" && i.format.type === "temporal_bucket") {
2920
- const c = JSON.stringify(J(i.target));
2921
- if (r.has(c))
2922
- throw new Error(
2923
- `resolvedFormats.${o} duplicates export field "${i.target.fieldId}"`
2924
- );
2925
- r.add(c);
2926
- return;
2927
- }
2928
- if (i.target.kind !== "column")
2929
- throw new Error(
2930
- `resolvedFormats.${o}.target must identify an export column or temporal pivot field`
2931
- );
2932
- if (t.has(i.target.columnKey))
2933
- throw new Error(
2934
- `resolvedFormats.${o} duplicates export column "${i.target.columnKey}"`
2935
- );
2936
- t.add(i.target.columnKey);
2937
- }), !e.useFormattedValues) return;
2938
- if (!((a = e.visibleColumns) != null && a.length))
2939
- throw new Error("visibleColumns must identify every formatted export column");
2940
- const n = e.visibleColumns.find(
2941
- (i) => !t.has(i)
2942
- );
2943
- if (n)
2944
- throw new Error(
2945
- `resolvedFormats is missing visible export column "${n}"`
2946
- );
2947
- }
2948
- const ga = /* @__PURE__ */ new Set(["short", "medium", "long"]), ha = /^(\d{4})-(\d{2})-(\d{2})$/, pa = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/, wa = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/, _e = " – ";
2949
- function xi(e) {
2950
- if (!g(e)) return;
2951
- const t = Object.keys(e);
2952
- if (e.mode === "period_label" && t.length === 1)
2953
- return { mode: "period_label" };
2954
- if (e.mode === "style" && t.length === 2 && typeof e.dateStyle == "string" && ga.has(e.dateStyle))
2955
- return { mode: "style", dateStyle: e.dateStyle };
2956
- if (e.mode === "pattern" && t.length === 3 && e.dialect === "semaphor_tokens" && typeof e.pattern == "string" && Ta(e.pattern) === null)
2957
- return {
2958
- mode: "pattern",
2959
- dialect: "semaphor_tokens",
2960
- pattern: e.pattern
2961
- };
2962
- }
2963
- function Ta(e) {
2964
- try {
2965
- return Fn({ dialect: "semaphor_tokens", pattern: e }), null;
2966
- } catch (t) {
2967
- return t instanceof Error ? t.message : "The pattern is invalid.";
2968
- }
2969
- }
2970
- function vi(e) {
2971
- const { value: t, part: r, presentation: n, preferences: a, calendar: i } = e;
2972
- if ((n == null ? void 0 : n.mode) === "period_label" && t.periodLabel && r === "range")
2973
- return { ok: !0, text: t.periodLabel };
2974
- const [o, c] = t.bounds, u = c === void 0 || r === "start" ? [{ raw: o, role: "start" }] : r === "end" ? [{ raw: c, role: "end" }] : [
2975
- { raw: o, role: "start" },
2976
- { raw: c, role: "end" }
2977
- ], l = u.map(({ raw: h }) => va(h, i.tz));
2978
- if (l.some((h) => h === null))
2979
- return {
2980
- ok: !1,
2981
- text: u.map(({ raw: h }) => h).join(_e),
2982
- diagnostic: {
2983
- code: "invalid_temporal_input_value",
2984
- message: "A date input bound is not a date or an instant."
2985
- }
2986
- };
2987
- const d = t.precision === "day" ? l.map(
2988
- (h, Yt) => _a(h, u[Yt].role, i.tz)
2989
- ) : [], y = d.length > 0 && d.every((h) => h !== null) ? d : null;
2990
- return { ok: !0, text: y ? Sa(y, n, a, i) : Da(
2991
- l.map((h) => ka(h, i.tz)),
2992
- n,
2993
- a,
2994
- i
2995
- ) };
2996
- }
2997
- function Sa(e, t, r, n) {
2998
- const [a, i = a] = e;
2999
- if ((t == null ? void 0 : t.mode) === "pattern")
3000
- return Ot(
3001
- e.map(
3002
- (s) => At(Se(s), "date", t.pattern, r, n)
3003
- )
3004
- );
3005
- const o = (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : r.dateStyle;
3006
- if (!t || t.mode === "period_label") {
3007
- const s = ba(a, i, n);
3008
- if (s)
3009
- return ea({
3010
- value: Se(a),
3011
- metadata: {
3012
- kind: "temporal_bucket",
3013
- granularity: s,
3014
- calendar: { tz: n.tz, weekStart: n.weekStart ?? 1 }
3015
- },
3016
- format: Vn({
3017
- metadata: {
3018
- kind: "temporal_bucket",
3019
- granularity: s,
3020
- calendar: { tz: n.tz, weekStart: n.weekStart ?? 1 }
3021
- },
3022
- locale: r.locale,
3023
- styles: { dateStyle: o, dateTime: { ...r.dateTime } }
3024
- }).format
3025
- });
3026
- }
3027
- const c = new Intl.DateTimeFormat(r.locale, {
3028
- calendar: "gregory",
3029
- timeZone: "UTC",
3030
- dateStyle: o
3031
- });
3032
- return Ma(a, i) ? c.format(B(a)) : zt(c, B(a), B(i));
3033
- }
3034
- function Da(e, t, r, n) {
3035
- if ((t == null ? void 0 : t.mode) === "pattern")
3036
- return Ot(
3037
- e.map(
3038
- (c) => At(
3039
- c.toISOString(),
3040
- "instant",
3041
- t.pattern,
3042
- r,
3043
- n
3044
- )
3045
- )
3046
- );
3047
- const a = new Intl.DateTimeFormat(r.locale, {
3048
- calendar: "gregory",
3049
- timeZone: n.tz,
3050
- dateStyle: (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : r.dateTime.dateStyle,
3051
- timeStyle: r.dateTime.timeStyle
3052
- }), [i, o] = e;
3053
- return o && o.getTime() !== i.getTime() ? zt(a, i, o) : a.format(i);
3054
- }
3055
- function zt(e, t, r) {
3056
- const n = e;
3057
- return typeof n.formatRange == "function" ? n.formatRange(t, r) : `${e.format(t)}${_e}${e.format(r)}`;
3058
- }
3059
- function At(e, t, r, n, a) {
3060
- const i = xn({
3061
- format: {
3062
- type: "raw_temporal",
3063
- presentation: { mode: "pattern", dialect: "semaphor_tokens", pattern: r }
3064
- },
3065
- // Temporal formatting reads no currency.
3066
- preferences: {
3067
- ...n,
3068
- defaultCurrency: Gt.defaultCurrency
3069
- },
3070
- calendar: { tz: a.tz }
3071
- }), o = t === "date" && xa(r) ? "instant" : t;
3072
- return Rn({
3073
- value: o === t ? e : ee(`${e}T00:00:00`, a.tz).toISOString(),
3074
- metadata: { kind: "raw_temporal", valueKind: o },
3075
- format: i
3076
- }).text;
3077
- }
3078
- function xa(e) {
3079
- return /HH|mm|ss/.test(e);
3080
- }
3081
- function Ot(e) {
3082
- return e[1] === void 0 || e[0] === e[1] ? e[0] : e.join(_e);
3083
- }
3084
- function va(e, t) {
3085
- const r = ha.exec(e);
3086
- if (r) {
3087
- const a = {
3088
- year: Number(r[1]),
3089
- month: Number(r[2]),
3090
- day: Number(r[3])
3091
- };
3092
- return Na(a) ? { kind: "date", date: a } : null;
3093
- }
3094
- const n = wa.test(e) ? new Date(e.replace(" ", "T")) : pa.test(e) ? ee(e.replace(" ", "T"), t) : null;
3095
- return n && !Number.isNaN(n.getTime()) ? { kind: "instant", instant: n } : null;
3096
- }
3097
- function ka(e, t) {
3098
- return e.kind === "instant" ? e.instant : ee(`${Se(e.date)}T00:00:00`, t);
3099
- }
3100
- function _a(e, t, r) {
3101
- if (e.kind === "date") return e.date;
3102
- const n = Xt(e.instant, r), a = { year: n.year, month: n.month, day: n.day };
3103
- if (n.hour === 0 && n.minute === 0 && n.second === 0 && e.instant.getUTCMilliseconds() === 0) return t === "start" ? a : $a(a, -1);
3104
- const o = n.hour === 23 && n.minute === 59 && n.second === 59;
3105
- return t === "end" && o ? a : null;
3106
- }
3107
- function ba(e, t, r) {
3108
- return r.fiscalCalendar || e.day !== 1 || e.year !== t.year || t.day !== Rt(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;
3109
- }
3110
- function Se(e) {
3111
- return `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
3112
- }
3113
- function B(e) {
3114
- const t = /* @__PURE__ */ new Date(0);
3115
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(0, 0, 0, 0), t;
3116
- }
3117
- function $a(e, t) {
3118
- const r = B(e);
3119
- return r.setUTCDate(r.getUTCDate() + t), {
3120
- year: r.getUTCFullYear(),
3121
- month: r.getUTCMonth() + 1,
3122
- day: r.getUTCDate()
3123
- };
3124
- }
3125
- function Ma(e, t) {
3126
- return e.year === t.year && e.month === t.month && e.day === t.day;
3127
- }
3128
- function Rt(e, t) {
3129
- return new Date(Date.UTC(e, t, 0)).getUTCDate();
3130
- }
3131
- function Na(e) {
3132
- return e.year >= 1 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= Rt(e.year, e.month);
3133
- }
3134
- export {
3135
- q as $,
3136
- Wr as A,
3137
- Xr as B,
3138
- Qa as C,
3139
- Jr as D,
3140
- ei as E,
3141
- on as F,
3142
- sn as G,
3143
- ri as H,
3144
- cn as I,
3145
- ni as J,
3146
- na as K,
3147
- da as L,
3148
- gi as M,
3149
- fa as N,
3150
- hi as O,
3151
- Qe as P,
3152
- pi as Q,
3153
- N as R,
3154
- wi as S,
3155
- Si as T,
3156
- Di as U,
3157
- ln as V,
3158
- dn as W,
3159
- R as X,
3160
- Tt as Y,
3161
- ai as Z,
3162
- Yn as _,
3163
- ya as a,
3164
- Nt as a0,
3165
- ui as a1,
3166
- It as a2,
3167
- Vn as a3,
3168
- li as a4,
3169
- ea as a5,
3170
- ve as a6,
3171
- vn as a7,
3172
- si as a8,
3173
- kn as a9,
3174
- v as aA,
3175
- He as aB,
3176
- je as aC,
3177
- ci as aa,
3178
- Rn as ab,
3179
- xi as ac,
3180
- Ta as ad,
3181
- vi as ae,
3182
- yi as af,
3183
- Pa as ag,
3184
- mi as ah,
3185
- Ga as ai,
3186
- en as aj,
3187
- di as ak,
3188
- fi as al,
3189
- ta as am,
3190
- ra as an,
3191
- Qr as ao,
3192
- dr as ap,
3193
- Va as aq,
3194
- Ba as ar,
3195
- qa as as,
3196
- dt as at,
3197
- Za as au,
3198
- Ha as av,
3199
- gt as aw,
3200
- Oe as ax,
3201
- ee as ay,
3202
- Ze as az,
3203
- La as b,
3204
- oi as c,
3205
- ti as d,
3206
- Ya as e,
3207
- Ti as f,
3208
- De as g,
3209
- ct as h,
3210
- Q as i,
3211
- ut as j,
3212
- lt as k,
3213
- mt as l,
3214
- ja as m,
3215
- Ka as n,
3216
- cr as o,
3217
- On as p,
3218
- it as q,
3219
- xn as r,
3220
- ii as s,
3221
- qr as t,
3222
- Wa as u,
3223
- Fn as v,
3224
- W as w,
3225
- _ as x,
3226
- Xa as y,
3227
- Ja as z
3228
- };