react-semaphor 0.1.545 → 0.1.547

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 (159) hide show
  1. package/dist/analytics-protocol/index.js +408 -442
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +100 -76
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.js +6 -6
  6. package/dist/chunks/{add-to-dashboard-BuAqfA2Y.js → add-to-dashboard-BQRAAnc3.js} +55 -33
  7. package/dist/chunks/{analytics-base-schemas-BFAoRlkU.js → analytics-base-schemas-BKs3flFS.js} +2 -2
  8. package/dist/chunks/applied-constraints-DU-wndZ7.js +47 -0
  9. package/dist/chunks/{assistant-chat-D7sWTypJ.js → assistant-chat-CK84cPAB.js} +2826 -2595
  10. package/dist/chunks/{bookmark-state-CXw7lZ50.js → bookmark-state-Cu-a5ie_.js} +8 -15
  11. package/dist/chunks/comparison-window-caption-C2xF-eWw.js +1433 -0
  12. package/dist/chunks/{context-ClREvqCZ.js → context-BerEBuFR.js} +11 -6
  13. package/dist/chunks/custom-visual-inputs-ChL54gGm.js +295 -0
  14. package/dist/chunks/{dashboard-B1tMju0u.js → dashboard-DCk26-6i.js} +1 -1
  15. package/dist/chunks/{dashboard-briefing-launcher-CePgIu0Z.js → dashboard-briefing-launcher-CQ1eYsGy.js} +1291 -1277
  16. package/dist/chunks/dashboard-controls-BMeZjF7r.js +2307 -0
  17. package/dist/chunks/{dashboard-json-CoYRPqxx.js → dashboard-json-BZqCoanC.js} +5 -5
  18. package/dist/chunks/{document-dashboard-inputs-BesAHZvB.js → document-dashboard-inputs-tYd7ao0o.js} +877 -979
  19. package/dist/chunks/{edit-dashboard-visual-JPtNfJRb.js → edit-dashboard-visual-Bv3MHM_G.js} +2157 -2243
  20. package/dist/chunks/filter-reach-copy-CGWsL_ez.js +3480 -0
  21. package/dist/chunks/{filter-value-text-ff7osJr7.js → filter-value-text-Ddf55Ku1.js} +9 -9
  22. package/dist/chunks/global-date-filter-utils-BhAu8zIM.js +12137 -0
  23. package/dist/chunks/index-CtoK1Lgu.js +586 -0
  24. package/dist/chunks/{index-DRWiuqyd.js → index-DmrLP5Ro.js} +105 -104
  25. package/dist/chunks/list-filter-DsaTbM3J.js +15 -0
  26. package/dist/chunks/matrix-analytical-definition-B9vW-osb.js +717 -0
  27. package/dist/chunks/{matrix-card-DjwWcCo8.js → matrix-card-LiMEipvq.js} +3 -3
  28. package/dist/chunks/{matrix-formatter-DnCyRXJE.js → matrix-formatter-DWEeC0_c.js} +44 -44
  29. package/dist/chunks/{matrix-member-presentation-CQGdVks6.js → matrix-member-presentation-DqzG-UhQ.js} +1 -1
  30. package/dist/chunks/{matrix-operation-contract-8OIO4gob.js → matrix-operation-contract-D6vYkZK4.js} +72 -72
  31. package/dist/chunks/{metric-comparison-DEwi9uc2.js → metric-comparison-zpGw4lD6.js} +2 -2
  32. package/dist/chunks/normalize-dashboard-for-dirty-check-XKgH3GFX.js +119 -0
  33. package/dist/chunks/{pivot-header-presentation-DHcx1XGQ.js → pivot-header-presentation-CQnIDtUv.js} +1 -1
  34. package/dist/chunks/{pivot-result-identity-DJhXXcns.js → pivot-result-identity-C-Q1j1Wb.js} +1 -1
  35. package/dist/chunks/{pivot-result-lifecycle-DM4CyGKs.js → pivot-result-lifecycle-pwq3b7LC.js} +571 -380
  36. package/dist/chunks/{raw-temporal-contract-C51YG48G.js → raw-temporal-contract-WuXA8jBP.js} +1 -1
  37. package/dist/chunks/{raw-temporal-presentation-C3mUgnEx.js → raw-temporal-presentation-DypB7sMX.js} +8 -8
  38. package/dist/chunks/{report-preferences-dialog-DUtuUL_5.js → report-preferences-dialog-DoVyriYC.js} +154 -155
  39. package/dist/chunks/{report-runtime-context-Dq8XyODK.js → report-runtime-context-hWiTCzFV.js} +2 -2
  40. package/dist/chunks/resolve-dashboard-input-context-D0JDUa4h.js +5576 -0
  41. package/dist/chunks/{saved-dashboard-context-LrF_kW0l.js → saved-dashboard-context-BfAH5j4L.js} +34 -34
  42. package/dist/chunks/{selection-reducer-Dj_8xD69.js → selection-reducer-CJzkTZio.js} +15 -15
  43. package/dist/chunks/{semaphor-ready-indicator-BxF96Yhv.js → semaphor-ready-indicator-CRm17oIP.js} +51771 -52574
  44. package/dist/chunks/{shelf-drop-preview-context-CNaM_Gmh.js → shelf-drop-preview-context-vy6P9THz.js} +7 -7
  45. package/dist/chunks/{source-entity-resolution-BYn9giz3.js → source-entity-resolution-BIGRvtbG.js} +13 -13
  46. package/dist/chunks/{switch-uDtPgQlQ.js → switch-CEBOR4n7.js} +3 -3
  47. package/dist/chunks/{table-export-sheet-YzMioA7Y.js → table-export-sheet-4X9mAG3V.js} +1 -1
  48. package/dist/chunks/table-settings-WysCBj62.js +614 -0
  49. package/dist/chunks/{temporal-bucket-D7NBrrtL.js → temporal-bucket-CQOSbv9-.js} +26 -26
  50. package/dist/chunks/{token-types-DBbZVQsm.js → token-types-BMqRmT-C.js} +1 -1
  51. package/dist/chunks/{use-create-flow-overlay-state-CjB7ig1o.js → use-create-flow-overlay-state-Csx_Xjsh.js} +101 -101
  52. package/dist/chunks/{validators-DMHTpf7a.js → validators-C-aOQlTB.js} +713 -658
  53. package/dist/chunks/{relative-date-label-Bk2j94pA.js → zoned-wall-clock-MulfA26h.js} +64 -21
  54. package/dist/dashboard/index.js +2 -2
  55. package/dist/dashboard-authoring/index.js +1895 -1163
  56. package/dist/data-app-sdk/index.js +6 -6
  57. package/dist/data-app-sdk-adapters/index.js +3 -3
  58. package/dist/data-app-sdk-validation/index.js +14 -14
  59. package/dist/format-utils/index.js +133 -133
  60. package/dist/index.js +192 -186
  61. package/dist/layouts/index.js +5 -242
  62. package/dist/report-runtime-context/index.js +2 -2
  63. package/dist/shared/index.js +4 -5
  64. package/dist/style.css +1 -1
  65. package/dist/surfboard/index.js +2 -2
  66. package/dist/types/components/index.d.ts +2 -0
  67. package/dist/types/components/surfboard/arrange-layout-button.d.ts +8 -0
  68. package/dist/types/components/surfboard/filter/types.d.ts +7 -0
  69. package/dist/types/components/surfboard/screen-size-preview-button.d.ts +10 -0
  70. package/dist/types/components/visual/matrix-table/matrix-card-view.d.ts +3 -0
  71. package/dist/types/index.js +6 -6
  72. package/dist/types/lib/charts/table-chart-types.d.ts +4 -0
  73. package/dist/types/lib/charts/types.d.ts +2 -2
  74. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +346 -21
  75. package/dist/types/lib/dashboard-inputs/dashboard-filter-value-identity.d.ts +65 -0
  76. package/dist/types/lib/dashboard-inputs/dashboard-input-values.d.ts +6 -0
  77. package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +2 -0
  78. package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +15 -0
  79. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +3 -3
  80. package/dist/types/lib/hooks/use-dashboard-card.d.ts +2 -0
  81. package/dist/types/lib/matrix-table/matrix-delivery-policy.d.ts +1 -1
  82. package/dist/types/lib/matrix-table/matrix-editor.d.ts +52 -0
  83. package/dist/types/lib/matrix-table/matrix-runtime-types.d.ts +9 -1
  84. package/dist/types/lib/matrix-table/matrix-runtime.d.ts +5 -1
  85. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +149 -10
  86. package/dist/types/lib/stores/dashboard-store.d.ts +137 -6
  87. package/dist/types/lib/types/common-types.d.ts +8 -0
  88. package/dist/types/lib/types/explorer-types.d.ts +10 -0
  89. package/dist/types/lib/types/semantic-types.d.ts +84 -0
  90. package/dist/types/lib/utils/build-saved-editor-card.d.ts +20 -0
  91. package/dist/types/lib/utils/card-type-change.d.ts +16 -0
  92. package/dist/types/lib/utils/field-availability-context.d.ts +25 -0
  93. package/dist/types/lib/utils/field-placement.d.ts +96 -0
  94. package/dist/types/lib/utils/field-state-calculator.d.ts +161 -0
  95. package/dist/types/lib/utils/qualified-entity-name.d.ts +2 -0
  96. package/dist/types/shared/analytics-protocol/applied-constraints.d.ts +57 -1
  97. package/dist/types/shared/analytics-protocol/field-provenance.d.ts +89 -0
  98. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  99. package/dist/types/shared/analytics-protocol/query-policies.d.ts +52 -0
  100. package/dist/types/shared/analytics-protocol/time-window-schema.d.ts +1 -1
  101. package/dist/types/shared/analytics-protocol/time-window.d.ts +40 -1
  102. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +4 -1
  103. package/dist/types/shared/assistant-protocol/answer-text.d.ts +20 -0
  104. package/dist/types/shared/assistant-protocol/context.d.ts +29 -29
  105. package/dist/types/shared/assistant-protocol/index.d.ts +1 -0
  106. package/dist/types/shared/assistant-protocol/limits.d.ts +6 -1
  107. package/dist/types/shared/assistant-protocol/parts.d.ts +43 -3
  108. package/dist/types/shared/assistant-protocol/request.d.ts +14 -2
  109. package/dist/types/shared/dashboard-authoring/calculated-field-identity.d.ts +3 -0
  110. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +487 -0
  111. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +34 -0
  112. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +7886 -0
  113. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +45 -0
  114. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +54 -0
  115. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +96 -0
  116. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +3 -3
  117. package/dist/types/shared/dashboard-authoring/column-catalog.d.ts +32 -0
  118. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -55
  119. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +24 -14
  120. package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +9 -1
  121. package/dist/types/shared/dashboard-authoring/dashboard-filter-automatic-target.d.ts +4 -4
  122. package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-contract.d.ts +3 -1
  123. package/dist/types/shared/dashboard-authoring/dashboard-filter-mapping-types.d.ts +27 -1
  124. package/dist/types/shared/dashboard-authoring/dashboard-filter-value-compatibility.d.ts +12 -3
  125. package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +26 -0
  126. package/dist/types/shared/dashboard-authoring/filter-applicability.d.ts +75 -0
  127. package/dist/types/shared/dashboard-authoring/filter-reach-copy.d.ts +18 -0
  128. package/dist/types/shared/dashboard-authoring/filter-reach-preview.d.ts +97 -0
  129. package/dist/types/shared/dashboard-authoring/index.d.ts +22 -2
  130. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +10 -37
  131. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +189 -0
  132. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +101 -0
  133. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +100 -0
  134. package/dist/types/shared/dashboard-authoring/semantic-auto-join-card.d.ts +22 -0
  135. package/dist/types/shared/dashboard-authoring/validators.d.ts +1 -2
  136. package/dist/types/shared/layouts/engine/grid.d.ts +25 -0
  137. package/dist/types/shared/layouts/engine/index.d.ts +4 -0
  138. package/dist/types/shared/layouts/engine/sheet-layout.d.ts +7 -0
  139. package/dist/types/shared/layouts/engine/types.d.ts +125 -0
  140. package/dist/types/shared/layouts/index.d.ts +1 -2
  141. package/package.json +2 -2
  142. package/dist/chunks/apply-dashboard-operations-CZEMsx8E.js +0 -2080
  143. package/dist/chunks/calendar-day-equality-dvoQp1xW.js +0 -410
  144. package/dist/chunks/comparison-window-caption-D4E6IHPD.js +0 -1624
  145. package/dist/chunks/custom-visual-inputs-DLCD9Y5V.js +0 -329
  146. package/dist/chunks/dashboard-controls-Cq05n3e0.js +0 -2315
  147. package/dist/chunks/dashboard-filter-value-compatibility-CwQ_iSNb.js +0 -108
  148. package/dist/chunks/matrix-analytical-definition-C7Gb0e12.js +0 -117
  149. package/dist/chunks/normalize-dashboard-for-dirty-check-Bk3VYv_q.js +0 -67
  150. package/dist/chunks/numeric-presentation-7X_IrD58.js +0 -5226
  151. package/dist/chunks/resolve-dashboard-input-context-DJ2tICwz.js +0 -9415
  152. package/dist/chunks/stable-serialize-CfqXeiBP.js +0 -6
  153. package/dist/chunks/table-settings-CLZocegs.js +0 -501
  154. package/dist/chunks/use-debounced-dirty-check-BwAbnX_5.js +0 -59
  155. package/dist/chunks/zoned-wall-clock-BkxV9jS2.js +0 -46
  156. package/dist/types/shared/dashboard-authoring/change-compiler.d.ts +0 -7
  157. package/dist/types/shared/dashboard-authoring/layout-compiler.d.ts +0 -2
  158. package/dist/types/shared/layouts/create-frame-layouts.d.ts +0 -27
  159. package/dist/types/shared/layouts/frame-layouts.d.ts +0 -23
@@ -1,1624 +0,0 @@
1
- var Qe = Object.defineProperty;
2
- var et = (e, t, r) => t in e ? Qe(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
- var fe = (e, t, r) => et(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { i as tt, j as V, m as rt, Q as ne, f as Ie, F as $e, P as ot, r as nt, M as at, v as st, c as it, p as lt, J as ct, a as j, G as ut, I as mt } from "./temporal-bucket-D7NBrrtL.js";
5
- import { i as _e, m as te, j as De, k as dt, l as Re, a as ge, d as ft, n as $ } from "./matrix-formatter-DnCyRXJE.js";
6
- import { h as Z, e as gt, p as pt, k as yt } from "./export-file-format-C-tJsxsf.js";
7
- import { aC as U, l as ht, w as X, aB as bt, y as ae, x as wt } from "./validators-DMHTpf7a.js";
8
- import "./matrix-operation-contract-8OIO4gob.js";
9
- import "./analytics-base-schemas-BFAoRlkU.js";
10
- import "zod";
11
- import { A as Pe, a as vt, t as pe, s as Tt, P as ye, l as Ct, o as xt, v as St, G as O } from "./pivot-result-lifecycle-DM4CyGKs.js";
12
- import { PDF_SAFETY_LIMIT_EXCEEDED as Ne, getUtf8ByteLength as Et, FAST_PDF_POLICY as kt } from "../pdf-export-policy/index.js";
13
- import { DEFAULT_RESOLVED_VALUE_FORMAT_PREFERENCES as At } from "../value-format-preferences/index.js";
14
- import { z as Lt } from "./zoned-wall-clock-BkxV9jS2.js";
15
- import { p as Ft } from "./pivot-header-presentation-DHcx1XGQ.js";
16
- import { d as Mt, c as he } from "./pivot-result-identity-DJhXXcns.js";
17
- import { v as It } from "./raw-temporal-contract-C51YG48G.js";
18
- import { g as $t } from "./relative-date-label-Bk2j94pA.js";
19
- function _t(e, t, r) {
20
- const o = {
21
- ...t,
22
- locale: t.locale ?? r
23
- };
24
- if (o.type === "number")
25
- return V(e, o);
26
- const { prefix: n, suffix: i, ...a } = o;
27
- return `${n ?? ""}${V(e, {
28
- ...a,
29
- negativeStyle: o.type === "currency" ? o.negativeStyle : "minus"
30
- })}${i ?? ""}`;
31
- }
32
- function q(e, t, r) {
33
- return e === null ? { value: e, text: null } : !t || !tt(t) && t.type !== "duration" ? {
34
- value: e,
35
- text: V(e, { type: "number", locale: r })
36
- } : t.type === "duration" ? {
37
- value: e,
38
- text: rt(e, {
39
- inputUnit: t.inputUnit,
40
- outputStyle: t.outputStyle,
41
- largestUnit: t.largestUnit,
42
- smallestUnit: t.smallestUnit,
43
- maxUnits: t.maxUnits,
44
- prefix: t.prefix,
45
- suffix: t.suffix,
46
- negativeInParentheses: t.negativeStyle === "parentheses"
47
- })
48
- } : { value: e, text: _t(e, t, r) };
49
- }
50
- function be(e, t, r, o) {
51
- return e === null ? { value: e, text: null } : o === "percent" ? {
52
- value: e,
53
- text: V(e, {
54
- type: "percent",
55
- locale: r,
56
- minimumFractionDigits: t,
57
- maximumFractionDigits: t,
58
- percentValueMode: "fraction"
59
- })
60
- } : {
61
- value: e,
62
- text: V(e, {
63
- type: "number",
64
- locale: r,
65
- minimumFractionDigits: t,
66
- maximumFractionDigits: t,
67
- suffix: "×"
68
- })
69
- };
70
- }
71
- function we(e, t) {
72
- if (e === void 0) return t;
73
- if (!Number.isInteger(e) || e < 0 || e > 6)
74
- throw new RangeError("Comparison precision must be an integer from 0 to 6.");
75
- return e;
76
- }
77
- function fo(e, t) {
78
- const r = {
79
- mode: t.displayMode,
80
- current: q(
81
- e.currentValue,
82
- t.metricFormat,
83
- t.locale
84
- ),
85
- comparison: q(
86
- e.comparisonValue,
87
- t.metricFormat,
88
- t.locale
89
- )
90
- };
91
- return (t.displayMode === "difference" || t.displayMode === "both") && (r.difference = q(
92
- e.delta,
93
- t.metricFormat,
94
- t.locale
95
- )), (t.displayMode === "percent_change" || t.displayMode === "both") && (r.percentChange = be(
96
- e.percentChange,
97
- we(t.precision, 1),
98
- t.locale,
99
- "percent"
100
- )), t.displayMode === "ratio" && (r.ratio = be(
101
- e.ratio,
102
- we(t.precision, 2),
103
- t.locale,
104
- "ratio"
105
- )), r;
106
- }
107
- const Dt = /* @__PURE__ */ new Set(["second", "minute", "hour", "day", "month"]);
108
- function Rt(e) {
109
- const { presentation: t } = e;
110
- return e.formattedValues ? (t == null ? void 0 : t.kind) === "text" || (t == null ? void 0 : t.kind) === "measure" && t.format.type === "duration" ? "text" : (t == null ? void 0 : t.kind) === "temporal_bucket" ? Dt.has(t.grain) ? "date" : "text" : (t == null ? void 0 : t.kind) === "datetime" ? "date" : e.dataType === "number" ? "number" : e.dataType === "boolean" ? "boolean" : e.dataType === "unknown" ? "by_value" : "text" : "by_value";
111
- }
112
- function Pt(e) {
113
- const t = (n, i) => Number.isInteger(n) ? Math.min(20, Math.max(0, n)) : i, r = t(e.minimumFractionDigits, 0), o = Math.max(r, t(e.maximumFractionDigits, 2));
114
- return o === 0 ? "" : `.${"0".repeat(o)}`;
115
- }
116
- function J(e) {
117
- return `"${e.replace(/"/g, "")}"`;
118
- }
119
- function Nt(e) {
120
- let t;
121
- try {
122
- t = new Intl.NumberFormat(e.locale ?? "en-US", {
123
- style: "currency",
124
- currency: e.currency || "USD"
125
- }).formatToParts(1);
126
- } catch {
127
- return;
128
- }
129
- const r = t.findIndex((i) => i.type === "currency"), o = t.findIndex((i) => i.type === "integer");
130
- if (r < 0 || o < 0) return;
131
- const n = (i, a) => t.slice(i, a).filter((l) => l.type === "literal").map((l) => l.value.replace(/\s/g, " ")).join("");
132
- return r < o ? { side: "before", text: t[r].value + n(r + 1, o) } : {
133
- side: "after",
134
- text: n(o + 1, r) + t[r].value
135
- };
136
- }
137
- function Ot(e) {
138
- const t = Pt(e);
139
- let r;
140
- if (e.type === "scientific")
141
- r = `0${t}E+00`;
142
- else {
143
- const o = `${e.useGrouping === !1 ? "0" : "#,##0"}${t}`;
144
- if (e.type === "currency") {
145
- const n = Nt(e);
146
- r = n ? n.side === "before" ? `${J(n.text)}${o}` : `${o}${J(n.text)}` : o;
147
- } else e.type === "percent" ? r = e.percentValueMode === "whole" ? `${o}${J("%")}` : `${o}%` : r = o;
148
- }
149
- return e.negativeStyle === "parentheses" ? `${r};(${r})` : r;
150
- }
151
- function Vt(e, t) {
152
- if (!e.formattedValues) return;
153
- const { presentation: r } = e;
154
- if (t === "number" || t === "by_value")
155
- return (r == null ? void 0 : r.kind) !== "measure" || r.format.type === "duration" ? void 0 : Ot(r.format);
156
- if (t === "date") {
157
- if ((r == null ? void 0 : r.kind) === "temporal_bucket")
158
- return r.grain === "day" ? "yyyy-mm-dd" : r.grain === "month" ? "mmm yyyy" : "yyyy-mm-dd hh:mm";
159
- if ((r == null ? void 0 : r.kind) === "datetime")
160
- return r.dateOnly ? "yyyy-mm-dd" : "yyyy-mm-dd hh:mm:ss";
161
- }
162
- }
163
- function ve(e) {
164
- const t = Rt(e), r = Vt(e, t);
165
- return Object.freeze({
166
- key: e.key,
167
- label: e.label,
168
- cellType: t,
169
- ...r === void 0 ? {} : { numberFormat: r }
170
- });
171
- }
172
- const Ut = 15, Kt = /^-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?$/;
173
- function Oe(e) {
174
- return Kt.test(e) ? e : void 0;
175
- }
176
- function Te(e) {
177
- const r = e.replace(/^-/, "").replace(/[eE].*$/, "").replace(".", "").replace(/^0+/, "").replace(/0+$/, "");
178
- if (r.length > Ut) return !1;
179
- const o = Number(e);
180
- return Number.isFinite(o) && (o !== 0 || r.length === 0);
181
- }
182
- const Bt = Date.UTC(1900, 2, 1), zt = Date.UTC(1e4, 0, 1), jt = Date.UTC(1899, 11, 30), Gt = 864e5;
183
- function Ht(e) {
184
- const t = Date.UTC(
185
- e.year,
186
- e.month - 1,
187
- e.day,
188
- e.hour,
189
- e.minute,
190
- e.second
191
- );
192
- if (!(e.year < 1900 || !Number.isFinite(t)) && !(t < Bt || t >= zt))
193
- return (t - jt) / Gt;
194
- }
195
- function Ce(e, t, r) {
196
- if (typeof e == "number")
197
- return Number.isFinite(e) ? { kind: "number", text: t, value: e } : void 0;
198
- if (U(e))
199
- return Te(e.value) ? { kind: "number", text: t, value: e } : void 0;
200
- if (r && typeof e == "string") {
201
- const o = Oe(e);
202
- return o !== void 0 && Te(o) ? { kind: "number", text: t, value: o } : void 0;
203
- }
204
- }
205
- function P(e) {
206
- const { value: t, text: r, column: o } = e;
207
- if (r === "") return { kind: "empty" };
208
- const n = { kind: "text", text: r };
209
- switch (o.cellType) {
210
- case "text":
211
- return n;
212
- case "date": {
213
- const i = e.wallClock ? Ht(e.wallClock) : void 0;
214
- return i === void 0 ? n : { kind: "date", text: r, serial: i };
215
- }
216
- case "number":
217
- return Ce(t, r, !0) ?? n;
218
- case "boolean":
219
- return typeof t == "boolean" ? { kind: "boolean", text: r, value: t } : n;
220
- case "by_value":
221
- return typeof t == "boolean" ? { kind: "boolean", text: r, value: t } : Ce(t, r, !1) ?? n;
222
- }
223
- }
224
- function go(e) {
225
- return e.kind === "empty" ? "" : e.text;
226
- }
227
- const Ve = 1e4, Xt = 1e6, po = 5e6, yo = 1024 ** 3, ho = 1024 ** 3;
228
- function bo(e) {
229
- return e > Ve;
230
- }
231
- function wo(e) {
232
- return e.cardType === "matrixTable" ? "try-direct" : e.loadedRowCount === null || e.loadedRowCount <= Ve ? "direct" : e.loadedRowCount <= Xt ? "background" : "blocked";
233
- }
234
- const vo = {
235
- rowLabels: "tabular",
236
- subtotals: "after"
237
- };
238
- function To(e, t) {
239
- const r = t.rowLabels === "outline" ? { kind: "compact" } : e.layout.kind === "tabular" ? e.layout : { kind: "tabular", repeatLabels: !1 }, o = e.totals.rows;
240
- return {
241
- ...e,
242
- layout: r,
243
- totals: {
244
- ...e.totals,
245
- rows: {
246
- ...o,
247
- levels: Object.fromEntries(
248
- Object.entries(o.levels).map(([n, i]) => [
249
- n,
250
- { ...i, position: t.subtotals }
251
- ])
252
- )
253
- }
254
- }
255
- };
256
- }
257
- const Wt = 2;
258
- function Yt(e) {
259
- return typeof e == "number" ? Number.isInteger(e) : U(e) ? !e.value.includes(".") : !0;
260
- }
261
- function Zt(e, t, r) {
262
- const o = e.descriptors.measures.filter(
263
- (a) => r.measureFormats[a.id] === void 0 && a.semanticFormat === void 0 && ht(a.column.dataType) === "number"
264
- );
265
- if (o.length === 0) return r;
266
- const n = /* @__PURE__ */ new Set();
267
- e.columns.forEach((a, l) => {
268
- if (!(a.kind !== "measure" || n.has(a.measureId)))
269
- for (const m of t) {
270
- const u = m.values[l];
271
- if ((u == null ? void 0 : u.kind) === "value" && !Yt(u.value)) {
272
- n.add(a.measureId);
273
- return;
274
- }
275
- }
276
- });
277
- const i = { ...r.measureFormats };
278
- for (const { id: a } of o) {
279
- const l = n.has(a) ? Wt : 0;
280
- i[a] = {
281
- type: "number",
282
- minimumFractionDigits: l,
283
- maximumFractionDigits: l,
284
- useGrouping: !0
285
- };
286
- }
287
- return { ...r, measureFormats: i };
288
- }
289
- function G(e) {
290
- return X(e.slice(0, -1));
291
- }
292
- function qt(e, t) {
293
- return t.length > e.length && X(t.slice(0, e.length)) === X(e);
294
- }
295
- function Jt(e) {
296
- return e.map((t, r) => {
297
- if (r === 0 || t.kind !== "layout") return !1;
298
- const o = e[r - 1];
299
- if (o.kind !== "layout") return !1;
300
- if (t.role !== "member" || qt(o.rowPath, t.rowPath)) return !0;
301
- const n = e[r - 2];
302
- return o.role === "member" && (!n || n.kind !== "layout" || n.role !== "member" || G(n.rowPath) !== G(o.rowPath)) && t.rowPath.length === o.rowPath.length && G(t.rowPath) === G(o.rowPath);
303
- });
304
- }
305
- const Qt = "pdf-group-continuation";
306
- function er(e) {
307
- if (!e.previousRow || e.row.isSubtotal === !0 || e.row.isGrandTotal === !0 || e.previousRow.isSubtotal === !0 || e.previousRow.isGrandTotal === !0)
308
- return !0;
309
- for (let t = 0; t <= e.levelIndex; t++)
310
- if (e.getValue(e.row, t) !== e.getValue(e.previousRow, t))
311
- return !0;
312
- return !1;
313
- }
314
- function Ue(e, t, r) {
315
- return !(r != null && r.hasTextAffixes) && t.kind === "value" && (typeof t.value == "number" || U(t.value)) ? e : Z(e);
316
- }
317
- function tr(e, t, r) {
318
- const o = _e(e.descriptors, t.presentation, r), n = e.columns.map((d) => {
319
- var s;
320
- return d.kind === "measure" && ((s = o.measureSemantics.get(d.measureId)) == null ? void 0 : s.isNumeric) === !0;
321
- }), i = (d) => te([d], o.levels), a = (d, s, f) => De(d, s, t.presentation.totals[f], o.levels), l = e.columns.map((d) => {
322
- if (d.kind !== "measure") return d.label;
323
- const s = d.columnPath.map(i);
324
- return d.role !== "member" && s.push(a(d.columnPath, d.role, "columns")), [...s, d.label].join(" / ");
325
- }), m = Math.min(t.spec.columns.length, Math.max(
326
- 0,
327
- ...e.columns.map((d) => d.kind === "measure" ? d.columnPath.length + (d.role !== "member" ? 1 : 0) : 0)
328
- )), u = Array.from({ length: m + 1 }, (d, s) => e.columns.map((f) => s === m ? f.label : f.kind !== "measure" ? "" : s < f.columnPath.length ? i(f.columnPath[s]) : s === f.columnPath.length && f.role !== "member" ? a(f.columnPath, f.role, "columns") : "")), g = (d, s) => dt({
329
- path: d.rowPath,
330
- role: d.kind === "layout" ? d.role : "member",
331
- levelCount: Math.max(1, t.spec.rows.length),
332
- repeatLabels: t.presentation.layout.kind !== "tabular" || t.presentation.layout.repeatLabels,
333
- previousPath: s == null ? void 0 : s.rowPath
334
- }), p = (d, s) => {
335
- if (d.kind !== "layout") throw new Error("Layout presentation requires layout rows.");
336
- if (d.values.length !== e.columns.length) throw new Error("Matrix row does not match its frozen layout.");
337
- const f = g(d, s);
338
- return e.columns.map((b, y) => {
339
- if (b.kind === "hierarchy")
340
- return `${" ".repeat(Math.max(0, d.rowPath.length - 1))}${a(d.rowPath, d.role, "rows")}`;
341
- if (b.kind === "level") {
342
- const C = t.spec.rows.findIndex((F) => F.id === b.levelId), x = f[C];
343
- return x != null && x.visible ? x.total ? a(d.rowPath, d.role, "rows") : te(x.path, o.levels) : "";
344
- }
345
- const S = d.values[y], w = o.measures.get(b.measureId);
346
- if (S.kind === "value" && !w)
347
- throw new Error("Matrix value is missing its measure descriptor.");
348
- return Re(S, w, t.presentation.absence);
349
- });
350
- }, v = (d, s) => p(d, s).map((f, b) => {
351
- const y = e.columns[b];
352
- return y.kind === "measure" ? Ue(f, d.values[b], o.measureSemantics.get(y.measureId)) : Z(f);
353
- });
354
- return {
355
- headers: l,
356
- headerBands: u,
357
- numericColumns: n,
358
- /** The card's prepared formats this presentation formats with (the Excel form reads its measure formats). */
359
- formatting: o,
360
- /** A row's cells; after `previous`, a tabular layout prints each label once. */
361
- row: (d, s) => p(d, s),
362
- /**
363
- * Level columns whose group label the row above shows, so this row
364
- * continues the group (Plan 2, 2d, C8). Only a member row after a member
365
- * row continues one: a total prints as a band, and its rules stay whole
366
- * above and below it.
367
- */
368
- continuedColumns: (d, s) => {
369
- const f = (y) => (y == null ? void 0 : y.kind) === "layout" && y.role === "member";
370
- if (!f(d) || !f(s)) return [];
371
- const b = g(d, s);
372
- return e.columns.flatMap((y, S) => {
373
- var C;
374
- if (y.kind !== "level") return [];
375
- const w = t.spec.rows.findIndex((x) => x.id === y.levelId);
376
- return w < d.rowPath.length && ((C = b[w]) == null ? void 0 : C.visible) === !1 ? [S] : [];
377
- });
378
- },
379
- csvRow: (d) => v(d),
380
- /**
381
- * `previousRow` is the row before `data[0]`, carried by the export's
382
- * continuation, so a tabular layout prints each label once across the
383
- * whole file. Retries are pure: suppression never relies on mutable
384
- * formatter state or an earlier worker. Without it, the first row prints
385
- * its labels.
386
- */
387
- csvRows: (d, s) => d.map((f, b) => v(f, b ? d[b - 1] : s ?? void 0))
388
- };
389
- }
390
- function Co(e) {
391
- return e.columns.map((t) => Z(t.label));
392
- }
393
- function xo(e, t, r) {
394
- return rr(e, t, r).map((o, n) => {
395
- const i = t.columns[n];
396
- return i.kind === "measure" ? Ue(o, e.values[n], r.measureSemantics.get(i.measureId)) : Z(o);
397
- });
398
- }
399
- function rr(e, t, r) {
400
- if (e.kind !== "flat") throw new Error("Flat Matrix CSV requires flat rows.");
401
- if (e.values.length !== t.columns.length) throw new Error("Matrix row does not match its frozen layout.");
402
- const o = [...e.rowPath, ...e.columnPath];
403
- return t.columns.map((n, i) => {
404
- if (n.kind === "measure") {
405
- const l = e.values[i], m = r.measures.get(n.measureId);
406
- if (l.kind === "value" && !m) throw new Error("Matrix value is missing its measure descriptor.");
407
- return Re(l, m, r.absence);
408
- }
409
- const a = n.kind === "level" ? o.find((l) => l.levelId === n.levelId) : void 0;
410
- if (!a) throw new Error("Flat Matrix row does not match its frozen layout.");
411
- return te([a], r.levels);
412
- });
413
- }
414
- function or(e) {
415
- const t = tr(e.layout, e.request, e.report), r = e.layout.columns.map((a, l) => ({
416
- index: l,
417
- columnId: `matrix:${l}`,
418
- label: t.headers[l],
419
- isNumeric: t.numericColumns[l]
420
- })), o = (a, l, m) => ({
421
- text: a,
422
- colspan: 1,
423
- rowspan: 1,
424
- columnId: r[l].columnId,
425
- isHeader: m,
426
- isNumeric: r[l].isNumeric,
427
- className: r[l].isNumeric ? "numeric" : e.layout.columns[l].kind === "hierarchy" ? "matrix-hierarchy" : ""
428
- }), n = [], i = e.layout.columns.findIndex((a) => a.kind === "measure");
429
- e.request.spec.columns.length && i >= 0 && n.push({
430
- repeatHeader: !0,
431
- headerType: "pivot-axis",
432
- headerRowIndex: 0,
433
- cells: [
434
- ...i ? [{ ...o("", 0, !0), colspan: i }] : [],
435
- {
436
- ...o(e.request.spec.columns.map((a) => Pe(a, e.request.presentation)).join(" / "), i, !0),
437
- colspan: e.layout.columns.length - i,
438
- isNumeric: !1,
439
- className: ""
440
- }
441
- ]
442
- });
443
- for (const [a, l] of t.headerBands.entries())
444
- n.push({
445
- repeatHeader: !0,
446
- headerType: a === t.headerBands.length - 1 ? "metrics" : "pivot-level",
447
- headerRowIndex: n.length,
448
- cells: l.map((m, u) => o(m, u, !0))
449
- });
450
- return {
451
- headers: n,
452
- rows: e.rows.map((a, l) => {
453
- const m = new Set(t.continuedColumns(a, e.rows[l - 1]));
454
- return {
455
- index: l,
456
- type: a.kind === "layout" && a.role !== "member" ? "subtotal" : "data",
457
- subtotalLevel: String(a.rowPath.length),
458
- // A tabular layout prints each label once unless it repeats them; the
459
- // blank cell continues its group, so a grid draws no rule above it.
460
- cells: t.row(a, e.rows[l - 1]).map((u, g) => m.has(g) ? { ...o(u, g, !1), className: Qt } : o(u, g, !1))
461
- };
462
- }),
463
- grandTotal: null,
464
- // Totals are already in the ordered body at their authored position.
465
- metadata: {
466
- tableType: "pivot",
467
- totalRows: e.rows.length,
468
- totalColumns: r.length,
469
- rowLevels: e.layout.columns.filter((a) => a.kind !== "measure").length,
470
- pivotLevels: e.request.spec.columns.length,
471
- hasGrandTotal: !1,
472
- columnOrder: r.map((a) => a.columnId),
473
- columns: r
474
- }
475
- };
476
- }
477
- function nr(e, t, r) {
478
- const { levels: o } = _e(e.descriptors, t.presentation, r), n = t.spec.columns.length > 0, i = [], a = [], l = e.columns.map((u, g) => {
479
- if (u.kind !== "measure") return null;
480
- const p = n ? `${u.role}:${X(u.columnPath)}` : `measure:${g}`;
481
- let v = i.indexOf(p);
482
- return v < 0 && (v = i.push(p) - 1, a.push(n ? De(u.columnPath, u.role, t.presentation.totals.columns, o) : u.label)), v;
483
- }), m = t.spec.columns[t.spec.columns.length - 1];
484
- return {
485
- columnGroups: l,
486
- groupLabels: a,
487
- /** What bands name their groups by: the innermost column level, or "Measures". */
488
- groupLevelLabel: m ? Pe(m, t.presentation) : "Measures"
489
- };
490
- }
491
- function So(e) {
492
- const { layout: t, rows: r, report: o } = e, n = {
493
- ...e.request,
494
- presentation: Zt(t, r, e.request.presentation)
495
- }, i = or({ layout: t, rows: r, request: n, report: o }), a = Jt(r), l = nr(t, n, o), m = {
496
- ...i,
497
- rows: i.rows.map((u, g) => ({ ...u, keepWithPrevious: a[g] })),
498
- metadata: { ...i.metadata, ...l }
499
- };
500
- return { request: n, table: m, ...l };
501
- }
502
- class ar extends Error {
503
- constructor() {
504
- super(...arguments);
505
- fe(this, "code", Ne);
506
- }
507
- }
508
- function xe(e) {
509
- if (!e || typeof e != "object")
510
- return;
511
- const { error: t, message: r, detail: o } = e;
512
- for (const n of [t, r, o])
513
- if (typeof n == "string" && n.trim())
514
- return n.trim();
515
- }
516
- async function sr(e) {
517
- const t = `PDF request failed: ${e.status} ${e.statusText}`.trim(), r = e.headers.get("content-type") || "";
518
- try {
519
- if (r.includes("application/json")) {
520
- const n = await e.json(), i = typeof n.code == "string" ? n.code : typeof n.errorCode == "string" ? n.errorCode : void 0;
521
- return { message: xe(n) || t, code: i };
522
- }
523
- const o = await e.text();
524
- if (!o.trim())
525
- return { message: t };
526
- try {
527
- const n = JSON.parse(o), i = typeof n.code == "string" ? n.code : typeof n.errorCode == "string" ? n.errorCode : void 0;
528
- return {
529
- message: xe(n) || o.trim(),
530
- code: i
531
- };
532
- } catch {
533
- return { message: o.trim() };
534
- }
535
- } catch {
536
- return { message: t };
537
- }
538
- }
539
- async function Eo(e) {
540
- if (!e.token) throw new Error("Missing auth token for PDF export");
541
- if (Et(e.serializedPayload) > kt.maxRequestBytes)
542
- throw new Error("Fast-path PDF request exceeds the structured body limit");
543
- const t = await (e.fetchImpl ?? fetch)(e.url, {
544
- method: "POST",
545
- headers: { "Content-Type": "application/json", Authorization: `Bearer ${e.token}` },
546
- body: e.serializedPayload,
547
- signal: e.signal
548
- });
549
- if (!t.ok) {
550
- const o = await sr(t);
551
- throw o.code === Ne ? new ar(o.message) : new Error(o.message);
552
- }
553
- const r = await t.json();
554
- if (r != null && r.error) throw new Error(r.error);
555
- if (typeof (r == null ? void 0 : r.url) != "string" || !r.url.trim())
556
- throw new Error("Fast-path PDF response missing download URL");
557
- return r;
558
- }
559
- const ir = /* @__PURE__ */ new Set(["short", "medium", "long"]), lr = /^(\d{4})-(\d{2})-(\d{2})$/, cr = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?$/, ur = /^\d{4}-\d{2}-\d{2}[T ]\d{2}:\d{2}(?::\d{2}(?:\.\d{1,9})?)?(?:Z|[+-]\d{2}:\d{2})$/, se = " – ";
560
- function ko(e) {
561
- if (!ot(e)) return;
562
- const t = Object.keys(e);
563
- if (e.mode === "period_label" && t.length === 1)
564
- return { mode: "period_label" };
565
- if (e.mode === "style" && t.length === 2 && typeof e.dateStyle == "string" && ir.has(e.dateStyle))
566
- return { mode: "style", dateStyle: e.dateStyle };
567
- if (e.mode === "pattern" && t.length === 3 && e.dialect === "semaphor_tokens" && typeof e.pattern == "string" && mr(e.pattern) === null)
568
- return {
569
- mode: "pattern",
570
- dialect: "semaphor_tokens",
571
- pattern: e.pattern
572
- };
573
- }
574
- function mr(e) {
575
- try {
576
- return st({ dialect: "semaphor_tokens", pattern: e }), null;
577
- } catch (t) {
578
- return t instanceof Error ? t.message : "The pattern is invalid.";
579
- }
580
- }
581
- function Ao(e) {
582
- const { value: t, part: r, presentation: o, preferences: n, calendar: i } = e;
583
- if ((o == null ? void 0 : o.mode) === "period_label" && t.periodLabel && r === "range")
584
- return { ok: !0, text: t.periodLabel };
585
- const [a, l] = t.bounds, u = l === void 0 || r === "start" ? [{ raw: a, role: "start" }] : r === "end" ? [{ raw: l, role: "end" }] : [
586
- { raw: a, role: "start" },
587
- { raw: l, role: "end" }
588
- ], g = u.map(({ raw: s }) => pr(s, i.tz));
589
- if (g.some((s) => s === null))
590
- return {
591
- ok: !1,
592
- text: u.map(({ raw: s }) => s).join(se),
593
- diagnostic: {
594
- code: "invalid_temporal_input_value",
595
- message: "A date input bound is not a date or an instant."
596
- }
597
- };
598
- const p = t.precision === "day" ? g.map(
599
- (s, f) => hr(s, u[f].role, i.tz)
600
- ) : [], v = p.length > 0 && p.every((s) => s !== null) ? p : null;
601
- return { ok: !0, text: v ? dr(v, o, n, i) : fr(
602
- g.map((s) => yr(s, i.tz)),
603
- o,
604
- n,
605
- i
606
- ) };
607
- }
608
- function dr(e, t, r, o) {
609
- const [n, i = n] = e;
610
- if ((t == null ? void 0 : t.mode) === "pattern")
611
- return ze(
612
- e.map(
613
- (m) => Be(re(m), "date", t.pattern, r, o)
614
- )
615
- );
616
- const a = (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : r.dateStyle;
617
- if (!t || t.mode === "period_label") {
618
- const m = br(n, i, o);
619
- if (m)
620
- return Ie({
621
- value: re(n),
622
- metadata: {
623
- kind: "temporal_bucket",
624
- granularity: m,
625
- calendar: { tz: o.tz, weekStart: o.weekStart ?? 1 }
626
- },
627
- format: $e({
628
- metadata: {
629
- kind: "temporal_bucket",
630
- granularity: m,
631
- calendar: { tz: o.tz, weekStart: o.weekStart ?? 1 }
632
- },
633
- locale: r.locale,
634
- styles: { dateStyle: a, dateTime: { ...r.dateTime } }
635
- }).format
636
- });
637
- }
638
- const l = new Intl.DateTimeFormat(r.locale, {
639
- calendar: "gregory",
640
- timeZone: "UTC",
641
- dateStyle: a
642
- });
643
- return vr(n, i) ? l.format(H(n)) : Ke(l, H(n), H(i));
644
- }
645
- function fr(e, t, r, o) {
646
- if ((t == null ? void 0 : t.mode) === "pattern")
647
- return ze(
648
- e.map(
649
- (l) => Be(
650
- l.toISOString(),
651
- "instant",
652
- t.pattern,
653
- r,
654
- o
655
- )
656
- )
657
- );
658
- const n = new Intl.DateTimeFormat(r.locale, {
659
- calendar: "gregory",
660
- timeZone: o.tz,
661
- dateStyle: (t == null ? void 0 : t.mode) === "style" ? t.dateStyle : r.dateTime.dateStyle,
662
- timeStyle: r.dateTime.timeStyle
663
- }), [i, a] = e;
664
- return a && a.getTime() !== i.getTime() ? Ke(n, i, a) : n.format(i);
665
- }
666
- function Ke(e, t, r) {
667
- const o = e;
668
- return typeof o.formatRange == "function" ? o.formatRange(t, r) : `${e.format(t)}${se}${e.format(r)}`;
669
- }
670
- function Be(e, t, r, o, n) {
671
- const i = nt({
672
- format: {
673
- type: "raw_temporal",
674
- presentation: { mode: "pattern", dialect: "semaphor_tokens", pattern: r }
675
- },
676
- // Temporal formatting reads no currency.
677
- preferences: {
678
- ...o,
679
- defaultCurrency: At.defaultCurrency
680
- },
681
- calendar: { tz: n.tz }
682
- }), a = t === "date" && gr(r) ? "instant" : t;
683
- return at({
684
- value: a === t ? e : ne(`${e}T00:00:00`, n.tz).toISOString(),
685
- metadata: { kind: "raw_temporal", valueKind: a },
686
- format: i
687
- }).text;
688
- }
689
- function gr(e) {
690
- return /HH|mm|ss/.test(e);
691
- }
692
- function ze(e) {
693
- return e[1] === void 0 || e[0] === e[1] ? e[0] : e.join(se);
694
- }
695
- function pr(e, t) {
696
- const r = lr.exec(e);
697
- if (r) {
698
- const n = {
699
- year: Number(r[1]),
700
- month: Number(r[2]),
701
- day: Number(r[3])
702
- };
703
- return Tr(n) ? { kind: "date", date: n } : null;
704
- }
705
- const o = ur.test(e) ? new Date(e.replace(" ", "T")) : cr.test(e) ? ne(e.replace(" ", "T"), t) : null;
706
- return o && !Number.isNaN(o.getTime()) ? { kind: "instant", instant: o } : null;
707
- }
708
- function yr(e, t) {
709
- return e.kind === "instant" ? e.instant : ne(`${re(e.date)}T00:00:00`, t);
710
- }
711
- function hr(e, t, r) {
712
- if (e.kind === "date") return e.date;
713
- const o = Lt(e.instant, r), n = { year: o.year, month: o.month, day: o.day };
714
- if (o.hour === 0 && o.minute === 0 && o.second === 0 && e.instant.getUTCMilliseconds() === 0) return t === "start" ? n : wr(n, -1);
715
- const a = o.hour === 23 && o.minute === 59 && o.second === 59;
716
- return t === "end" && a ? n : null;
717
- }
718
- function br(e, t, r) {
719
- return r.fiscalCalendar || e.day !== 1 || e.year !== t.year || t.day !== je(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;
720
- }
721
- function re(e) {
722
- return `${String(e.year).padStart(4, "0")}-${String(e.month).padStart(2, "0")}-${String(e.day).padStart(2, "0")}`;
723
- }
724
- function H(e) {
725
- const t = /* @__PURE__ */ new Date(0);
726
- return t.setUTCFullYear(e.year, e.month - 1, e.day), t.setUTCHours(0, 0, 0, 0), t;
727
- }
728
- function wr(e, t) {
729
- const r = H(e);
730
- return r.setUTCDate(r.getUTCDate() + t), {
731
- year: r.getUTCFullYear(),
732
- month: r.getUTCMonth() + 1,
733
- day: r.getUTCDate()
734
- };
735
- }
736
- function vr(e, t) {
737
- return e.year === t.year && e.month === t.month && e.day === t.day;
738
- }
739
- function je(e, t) {
740
- return new Date(Date.UTC(e, t, 0)).getUTCDate();
741
- }
742
- function Tr(e) {
743
- return e.year >= 1 && e.month >= 1 && e.month <= 12 && e.day >= 1 && e.day <= je(e.year, e.month);
744
- }
745
- const Cr = "__TOTAL__";
746
- function W(e) {
747
- return typeof e == "object" && e !== null && !Array.isArray(e);
748
- }
749
- function oe(e) {
750
- return e === Cr;
751
- }
752
- function xr(e) {
753
- const t = /* @__PURE__ */ new Map(), r = (e.groupByColumns ?? []).map((n, i) => {
754
- var u, g, p;
755
- if (!W(n))
756
- throw new Error(`Aggregate groupByColumns[${i}] is invalid`);
757
- const a = typeof n.id == "string" && n.id.length > 0 ? n.id : void 0, l = a ? (p = (g = (u = e.columnKeyMap) == null ? void 0 : u.byRole) == null ? void 0 : g.groupby) == null ? void 0 : p[a] : void 0, m = (l == null ? void 0 : l.outputKey) || (l == null ? void 0 : l.rawKey) || (typeof n.alias == "string" && n.alias.length > 0 ? n.alias : typeof n.name == "string" && n.name.length > 0 ? n.name : void 0);
758
- if (!m)
759
- throw new Error(`Aggregate groupByColumns[${i}] has no output key`);
760
- return [a, n.alias, n.name, m].forEach((v) => {
761
- typeof v == "string" && v.length > 0 && t.set(v, m);
762
- }), m;
763
- }), o = (e.rowAggregates ?? []).flatMap((n) => !W(n) || typeof n.function != "string" || typeof n.groupLevel != "string" ? [] : [
764
- {
765
- function: n.function,
766
- groupLevel: n.groupLevel === "ALL" ? "ALL" : t.get(n.groupLevel) || n.groupLevel,
767
- ...typeof n.label == "string" ? { label: n.label } : {}
768
- }
769
- ]);
770
- return { groupColumnKeys: r, rowAggregates: o };
771
- }
772
- function Ge(e) {
773
- return e === "SUM" ? "Total" : e.charAt(0).toUpperCase() + e.slice(1).toLowerCase();
774
- }
775
- function Sr(e) {
776
- var r;
777
- if (e.customLabel) return e.customLabel;
778
- const t = Ge(e.aggregateFunction);
779
- if (e.levelValue !== void 0 && !oe(e.levelValue)) {
780
- if (e.levelValue === null) {
781
- const n = (r = e.formatValue) == null ? void 0 : r.call(e, null);
782
- return n ? `Subtotal ${n}` : `Subtotal ${t}`;
783
- }
784
- const o = e.formatValue ? e.formatValue(e.levelValue) : String(e.levelValue);
785
- if (o) return `Subtotal (${o})`;
786
- }
787
- return `Subtotal ${t}`;
788
- }
789
- function Er(e, t) {
790
- return t || `Grand ${Ge(e)}`;
791
- }
792
- function Lo(e) {
793
- const t = e.context.groupColumnKeys.indexOf(e.columnKey);
794
- if (t < 0)
795
- throw new Error(
796
- `Aggregate group column "${e.columnKey}" is unknown`
797
- );
798
- return er({
799
- row: e.row,
800
- previousRow: e.previousRow,
801
- levelIndex: t,
802
- getValue: (r, o) => r[e.context.groupColumnKeys[o]]
803
- });
804
- }
805
- function He(e) {
806
- var o, n;
807
- const t = e.context.groupColumnKeys, r = typeof e.row.aggregate == "string" ? e.row.aggregate : "SUM";
808
- if (e.row.isGrandTotal === !0) {
809
- const i = (o = e.context.rowAggregates.find(
810
- (a) => a.groupLevel === "ALL"
811
- )) == null ? void 0 : o.label;
812
- return {
813
- kind: "grand-total",
814
- cells: t.map((a, l) => ({
815
- columnKey: a,
816
- text: l === 0 ? Er(r, i) : "",
817
- placement: l === 0 ? "label" : "empty",
818
- colSpan: l === 0 ? t.length : 1
819
- }))
820
- };
821
- }
822
- if (e.row.isSubtotal === !0) {
823
- if (typeof e.row.subtotalLevel != "string")
824
- throw new Error("Aggregate subtotal row is missing subtotalLevel");
825
- const i = t.indexOf(e.row.subtotalLevel);
826
- if (i < 0)
827
- throw new Error(
828
- `Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`
829
- );
830
- const a = W(e.row.subtotalContext) ? e.row.subtotalContext : void 0, l = W(a == null ? void 0 : a.groupByValues) ? a.groupByValues : {}, m = (n = e.context.rowAggregates.find(
831
- (u) => u.groupLevel === e.row.subtotalLevel && u.function === r
832
- )) == null ? void 0 : n.label;
833
- return {
834
- kind: "subtotal",
835
- cells: t.map((u, g) => {
836
- if (g > i)
837
- return {
838
- columnKey: u,
839
- text: "",
840
- placement: "empty",
841
- colSpan: 1
842
- };
843
- if (g < i) {
844
- const p = e.row[u];
845
- return {
846
- columnKey: u,
847
- text: p === void 0 || oe(p) ? "" : e.formatValue(p, u),
848
- placement: "value",
849
- colSpan: 1
850
- };
851
- }
852
- return {
853
- columnKey: u,
854
- text: Sr({
855
- aggregateFunction: r,
856
- customLabel: m,
857
- levelValue: l[u],
858
- formatValue: (p) => e.formatLabelValue ? e.formatLabelValue(p, u) : String(e.formatValue(p, u) ?? "")
859
- }),
860
- placement: "label",
861
- colSpan: t.length - i
862
- };
863
- })
864
- };
865
- }
866
- return {
867
- kind: "data",
868
- cells: t.map((i) => {
869
- const a = e.row[i];
870
- return {
871
- columnKey: i,
872
- text: a === void 0 || oe(a) ? "" : e.formatValue(a, i),
873
- placement: "value",
874
- colSpan: 1
875
- };
876
- })
877
- };
878
- }
879
- function Fo(e) {
880
- const t = He(e).cells.find(
881
- (r) => r.columnKey === e.columnKey
882
- );
883
- if (!t)
884
- throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);
885
- return t.text;
886
- }
887
- function kr(e) {
888
- return He(e).cells.map((t) => t.text);
889
- }
890
- function Ar(e) {
891
- return typeof e == "object" && e !== null && !Array.isArray(e);
892
- }
893
- function Lr(e, t) {
894
- if ((e == null ? void 0 : e.cardType) !== "aggregateTable") return;
895
- const r = Ar(e.cardConfig) ? e.cardConfig : void 0, o = r == null ? void 0 : r.groupByColumns, n = r == null ? void 0 : r.rowAggregates;
896
- if (o !== void 0 && !Array.isArray(o))
897
- throw new Error("Aggregate export groupByColumns is invalid");
898
- if (n !== void 0 && !Array.isArray(n))
899
- throw new Error("Aggregate export rowAggregates is invalid");
900
- return xr({
901
- groupByColumns: o,
902
- rowAggregates: n,
903
- columnKeyMap: t
904
- });
905
- }
906
- function Fr(e) {
907
- if (!e.aggregateContext || !e.useFormattedValues || e.row.isSubtotal !== !0 && e.row.isGrandTotal !== !0)
908
- return;
909
- const t = kr({
910
- row: e.row,
911
- context: e.aggregateContext,
912
- formatValue: (r, o) => e.visibleColumnKeys.has(o) ? e.formatGroupValue(r, o) : ""
913
- });
914
- return new Map(
915
- e.aggregateContext.groupColumnKeys.map((r, o) => [
916
- r,
917
- t[o]
918
- ])
919
- );
920
- }
921
- function Mr(e, t) {
922
- return e.dashboardId === t.dashboardId && e.cardId === t.cardId && e.attachmentIndex === void 0;
923
- }
924
- function Xe(e) {
925
- return new Map(
926
- e.presentationExecutionSnapshot.resolvedFormats.flatMap(
927
- (t) => t.format.type === "raw_temporal" && t.target.kind === "column" && Mr(t.scope, e.scope) ? [[t.target.columnKey, t.format]] : []
928
- )
929
- );
930
- }
931
- function We(e) {
932
- const t = e == null ? void 0 : e.sql, r = e == null ? void 0 : e.python;
933
- return (e == null ? void 0 : e.resultOwner) === "freeform" && typeof t == "string" && !!t.trim() && (typeof r != "string" || !r.trim());
934
- }
935
- function Mo(e) {
936
- return e.formatting.useFormattedValues !== !1 && We(e.queryPayload) && Xe(e.formatting).size > 0;
937
- }
938
- function Ir(e, t) {
939
- return e.map((r, o) => {
940
- if (!Object.prototype.hasOwnProperty.call(r, t) || r[t] === void 0)
941
- throw new Error(
942
- `missing_raw_temporal_result_contract: Row ${o} is missing declared temporal column "${t}".`
943
- );
944
- const n = r[t];
945
- return n === null || typeof n == "string" ? n : String(n);
946
- });
947
- }
948
- function $r(e) {
949
- if (e.formatting.useFormattedValues === !1)
950
- return {
951
- activatedColumnKeys: /* @__PURE__ */ new Set(),
952
- byColumnKey: /* @__PURE__ */ new Map()
953
- };
954
- const t = Xe(e.formatting), r = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
955
- if (t.size === 0)
956
- return { activatedColumnKeys: r, byColumnKey: o };
957
- const n = new Map(
958
- e.columns.flatMap((l) => {
959
- const m = l.key || l.field;
960
- return m ? [[m, l]] : [];
961
- })
962
- ), i = We(e.queryPayload), a = /* @__PURE__ */ new Map();
963
- for (const [l, m] of t) {
964
- const u = n.get(l);
965
- let g;
966
- if (u != null && u.rawTemporal)
967
- g = It(u, {
968
- metadataRequired: !0
969
- }), r.add(l);
970
- else if (i) {
971
- r.add(l);
972
- const p = it({
973
- columnKey: l,
974
- values: Ir(e.records, l)
975
- });
976
- a.set(l, p), p.status === "classified" && (g = p.metadata);
977
- } else
978
- continue;
979
- g && o.set(l, {
980
- metadata: g,
981
- format: m,
982
- formatValue: lt({ metadata: g, format: m })
983
- });
984
- }
985
- return {
986
- activatedColumnKeys: r,
987
- byColumnKey: o,
988
- ...i ? {
989
- sqlChunkEvidence: ct(a)
990
- } : {}
991
- };
992
- }
993
- function _r(e) {
994
- if (!e.resolution.activatedColumnKeys.has(e.columnKey))
995
- return;
996
- if (e.value === void 0)
997
- throw new Error(
998
- `missing_raw_temporal_result_contract: Row ${e.rowIndex} is missing temporal column "${e.columnKey}".`
999
- );
1000
- const t = e.resolution.byColumnKey.get(e.columnKey);
1001
- if (!t)
1002
- return { text: e.value === null ? "" : String(e.value) };
1003
- if (e.value !== null && typeof e.value != "string")
1004
- return { text: String(e.value) };
1005
- const r = t.formatValue(e.value);
1006
- return r.ok && r.wallClock ? { text: r.text, wallClock: r.wallClock } : { text: r.text };
1007
- }
1008
- function Se(e, t) {
1009
- const r = e.byColumnKey.get(t);
1010
- return r ? r.metadata.valueKind === "date" : void 0;
1011
- }
1012
- const Dr = /* @__PURE__ */ new Set(["string", "number", "boolean", "date", "datetime"]), Rr = /^\d{4}-\d{2}-\d{2}|^\d{2}\/\d{2}\/\d{4}/, Pr = /^\d{4}-\d{2}-\d{2}$/, Ye = "MM/dd/yyyy";
1013
- function Y(e) {
1014
- return typeof e == "object" && e !== null && !Array.isArray(e);
1015
- }
1016
- function N(e) {
1017
- return e.key || e.field || void 0;
1018
- }
1019
- function Q(e) {
1020
- return e == null ? "" : typeof e == "string" ? e : U(e) ? e.value : e instanceof Date ? e.toISOString() : typeof e == "object" ? JSON.stringify(e) : String(e);
1021
- }
1022
- function Ee(e, t) {
1023
- var o;
1024
- const r = (o = e.columnSettings) == null ? void 0 : o[t];
1025
- if (!(!Y(r) || r.type !== "date"))
1026
- return Y(r.dateFormat) ? r.dateFormat : {};
1027
- }
1028
- function ke(e) {
1029
- return e.useCustomFormat && e.customFormat ? e.customFormat : e.format || Ye;
1030
- }
1031
- function Ae(e, t) {
1032
- return e && e !== "auto" ? e : t;
1033
- }
1034
- function Nr(e) {
1035
- return !/[HhKkmsSa]/.test(e.replace(/'[^']*'/g, ""));
1036
- }
1037
- function Or(e) {
1038
- if (typeof e == "number") return Number.isFinite(e) ? e : null;
1039
- if (typeof e != "string" || !e.trim()) return null;
1040
- const t = Number(e);
1041
- return Number.isFinite(t) ? t : null;
1042
- }
1043
- function Vr(e) {
1044
- const t = Oe(e);
1045
- if (t !== void 0)
1046
- try {
1047
- return bt(t, /[.eE]/.test(t) ? "decimal" : "integer");
1048
- } catch {
1049
- return;
1050
- }
1051
- }
1052
- function Ur(e) {
1053
- return e.calendar.fiscalCalendar && (e.granularity === "quarter" || e.granularity === "year") ? "fiscal" : e.granularity;
1054
- }
1055
- function Io(e) {
1056
- const { formatting: t, queryPayload: r } = e, o = t.useFormattedValues, n = t.scope, i = (s) => vt({ snapshot: t.presentationExecutionSnapshot, scope: n, target: { kind: "column", columnKey: s } }), a = (s) => Tt({ snapshot: t.presentationExecutionSnapshot, scope: n, target: { kind: "column", columnKey: s } });
1057
- function l(s) {
1058
- var b;
1059
- if ((b = t.visibleColumns) != null && b.length) return t.visibleColumns;
1060
- const f = s.columns.map(N).filter((y) => !!y);
1061
- return f.length > 0 ? f : s.records[0] ? Object.keys(s.records[0]) : [];
1062
- }
1063
- function m(s, f) {
1064
- return t.columnLabels && Object.prototype.hasOwnProperty.call(t.columnLabels, s) && t.columnLabels[s] || void 0 || u(f) || (f == null ? void 0 : f.label) || (f == null ? void 0 : f.headerName) || s;
1065
- }
1066
- function u(s, f) {
1067
- const b = s == null ? void 0 : s.pivotIdentity;
1068
- if (!b || !b.members || b.members.length === 0) return;
1069
- const y = he({ identity: b, columnKey: (s == null ? void 0 : s.key) || (s == null ? void 0 : s.field) || "" });
1070
- return Ft({
1071
- members: y,
1072
- metricLabel: (s == null ? void 0 : s.label) || (s == null ? void 0 : s.headerName),
1073
- mode: o ? "formatted" : "canonical",
1074
- resolveTemporalFormat: (S) => {
1075
- const w = y.find((x) => x.fieldId === S);
1076
- if (!(w != null && w.temporalBucket)) return;
1077
- const C = pe({
1078
- snapshot: t.presentationExecutionSnapshot,
1079
- scope: n,
1080
- target: { kind: "field", fieldId: S, role: "pivotby" }
1081
- });
1082
- return C ? g(w.temporalBucket, C) : void 0;
1083
- }
1084
- }).flattenedLabel;
1085
- }
1086
- function g(s, f) {
1087
- return $e({
1088
- metadata: s,
1089
- cardFormat: f,
1090
- locale: f.locale,
1091
- ...f.presentation.mode === "auto" ? { styles: f.presentation.styles } : {}
1092
- }).format;
1093
- }
1094
- function p(s, f) {
1095
- const { records: b, columns: y } = s, S = Y(r.cardConfig) ? r.cardConfig : void 0;
1096
- if (s.pivotResultKind === "not_pivot") {
1097
- const c = S == null ? void 0 : S.pivotByColumns, h = Array.isArray(c) ? c.flatMap(
1098
- (T) => Y(T) && typeof T.id == "string" && T.id ? [T.id] : []
1099
- ) : [];
1100
- Mt(
1101
- y.map((T) => ({ key: N(T) || "<unknown>", pivotIdentity: T.pivotIdentity })),
1102
- {
1103
- expectedPivotFieldIds: h,
1104
- columnClassifications: s.columnMetadata
1105
- }
1106
- );
1107
- }
1108
- const w = l(s), C = new Set(w), x = new Map(
1109
- y.flatMap((c) => {
1110
- const h = N(c);
1111
- return h ? [[h, c]] : [];
1112
- })
1113
- ), F = new Map(s.resultColumns.map((c) => [c.key, c.dataType])), M = $r({
1114
- records: b,
1115
- columns: y,
1116
- formatting: t,
1117
- queryPayload: r
1118
- }), K = new Map(
1119
- y.flatMap((c) => {
1120
- const h = N(c);
1121
- return h && c.temporalBucket ? [[h, c.temporalBucket]] : [];
1122
- })
1123
- ), le = /* @__PURE__ */ new Map();
1124
- for (const c of w) {
1125
- const h = pe({
1126
- snapshot: t.presentationExecutionSnapshot,
1127
- scope: n,
1128
- target: { kind: "column", columnKey: c }
1129
- }), T = K.get(c);
1130
- if (o) {
1131
- if (h && !T) throw new Error(`Missing temporal bucket metadata for column "${c}"`);
1132
- if (T && !h) throw new Error(`Missing resolved temporal presentation for column "${c}"`);
1133
- }
1134
- h && T && le.set(c, g(T, h));
1135
- }
1136
- const qe = K.size > 0 && e.cardType === "aggregateTable" ? Lr(r, s.columnKeyMap) : void 0, B = w.map((c) => {
1137
- const h = F.get(c), T = h && Dr.has(h) ? h : "unknown", E = o ? v(c, M, K) : void 0, k = m(c, x.get(c)), A = o && M.activatedColumnKeys.has(c) && Se(M, c) === void 0;
1138
- return {
1139
- key: c,
1140
- label: k,
1141
- dataType: T,
1142
- ...E ? { presentation: E } : {},
1143
- xlsx: ve({ key: c, label: k, formattedValues: o, dataType: T, presentation: E }),
1144
- ...A ? { xlsxPending: !0 } : {}
1145
- };
1146
- });
1147
- function ce(c, h, T, E) {
1148
- if (!o) return { text: Q(c), value: c };
1149
- const k = _r({ value: c, columnKey: h, rowIndex: T, resolution: M });
1150
- if (k !== void 0) return { text: k.text, value: c, ...k.wallClock ? { wallClock: k.wallClock } : {} };
1151
- const A = K.get(h);
1152
- if (A) {
1153
- const L = le.get(h);
1154
- if (!L) throw new Error(`Missing resolved temporal presentation for column "${h}"`);
1155
- if (c != null && typeof c != "string")
1156
- throw new Error(`Canonical temporal column "${h}" must contain a string or null`);
1157
- const D = c ?? null, R = ut(D, A);
1158
- return {
1159
- text: Ie({ value: D, metadata: A, format: L }),
1160
- value: c,
1161
- ...R ? { wallClock: R } : {}
1162
- };
1163
- }
1164
- if (c == null) return { text: "", value: c };
1165
- const _ = a(h);
1166
- if (_ && typeof c == "number" && Number.isFinite(c))
1167
- return {
1168
- text: ge(
1169
- new Date(c).toISOString(),
1170
- _.pattern || Ye,
1171
- Ae(_.timezone, t.timezone),
1172
- "UTC"
1173
- ),
1174
- value: c
1175
- };
1176
- const I = i(h);
1177
- if (typeof c == "number")
1178
- return { text: I ? j(c, I) : String(c), value: c };
1179
- if (U(c))
1180
- return { text: I ? j(c, I) : c.value, value: c };
1181
- const z = Ee(t, h);
1182
- if (z && (c instanceof Date || typeof c == "string" && Rr.test(c))) {
1183
- const L = c instanceof Date ? c.toISOString() : c, D = typeof c == "string" && Pr.test(c), R = D ? "UTC" : Ae(z.timezone, t.timezone), me = D ? "UTC" : z.sourceTimezone || "auto", de = ft(L, R, me);
1184
- return {
1185
- text: ge(L, ke(z), R, me),
1186
- value: c,
1187
- ...de ? { wallClock: de } : {}
1188
- };
1189
- }
1190
- if (typeof c == "string" && I && E.dataType === "number") {
1191
- const L = Vr(c);
1192
- if (L) return { text: j(L, I), value: c };
1193
- }
1194
- return { text: Q(c), value: c };
1195
- }
1196
- const Je = b.map((c, h) => {
1197
- const T = Fr({
1198
- row: c,
1199
- aggregateContext: qe,
1200
- useFormattedValues: o,
1201
- visibleColumnKeys: C,
1202
- formatGroupValue: (E, k) => {
1203
- const A = B.find((_) => _.key === k);
1204
- return A ? ce(E, k, h, A).text : Q(E);
1205
- }
1206
- });
1207
- return B.map((E) => {
1208
- const k = T == null ? void 0 : T.get(E.key);
1209
- if (k !== void 0) return P({ value: k, text: k, column: E.xlsx });
1210
- const A = ce(c[E.key], E.key, h, E);
1211
- return P({ value: A.value, text: A.text, column: E.xlsx, wallClock: A.wallClock });
1212
- });
1213
- }), ue = (f == null ? void 0 : f.withHeader) !== !1 && t.includeHeaders;
1214
- if (ue && s.pivotResultKind === "not_pivot")
1215
- for (const c of w) {
1216
- const h = x.get(c);
1217
- h != null && h.pivotIdentity && he({ identity: h.pivotIdentity, columnKey: N(h) || c });
1218
- }
1219
- return {
1220
- ...ue ? { header: B.map((c) => c.label) } : {},
1221
- columns: B,
1222
- rows: Je,
1223
- ...M.sqlChunkEvidence ? { rawTemporalClassification: M.sqlChunkEvidence } : {}
1224
- };
1225
- }
1226
- function v(s, f, b) {
1227
- if (f.activatedColumnKeys.has(s)) {
1228
- const C = Se(f, s);
1229
- return C === void 0 ? { kind: "text" } : { kind: "datetime", dateOnly: C };
1230
- }
1231
- const y = b.get(s);
1232
- if (y) return { kind: "temporal_bucket", grain: Ur(y) };
1233
- if (a(s)) return { kind: "text" };
1234
- const S = Ee(t, s);
1235
- if (S) return { kind: "datetime", dateOnly: Nr(ke(S)) };
1236
- const w = i(s);
1237
- return w ? { kind: "measure", format: w } : void 0;
1238
- }
1239
- function d(s, f) {
1240
- if (!Number.isInteger(f) || f < 0)
1241
- throw new Error("totalRows must be a non-negative integer");
1242
- return f === 0 ? void 0 : (t.visibleColumns ?? Object.keys(s)).map((y) => {
1243
- const w = Object.prototype.hasOwnProperty.call(s, y) ? s[y] : y === t.tableTotalsLabelColumnKey ? "Total" : null, C = o ? i(y) : void 0, x = ve({
1244
- key: y,
1245
- label: y,
1246
- formattedValues: o,
1247
- dataType: "unknown",
1248
- ...C ? { presentation: { kind: "measure", format: C } } : {}
1249
- });
1250
- if (w == null) return { kind: "empty" };
1251
- if (!o) return P({ value: w, text: String(w), column: x });
1252
- const F = C ? Or(w) : null;
1253
- return P(C && F !== null ? { value: F, text: j(F, C), column: x } : { value: w, text: String(w), column: x });
1254
- });
1255
- }
1256
- return { format: p, totals: d };
1257
- }
1258
- const Kr = /* @__PURE__ */ new Set([
1259
- "scope",
1260
- "useFormattedValues",
1261
- "timezone",
1262
- "presentationExecutionSnapshot",
1263
- "delimiter",
1264
- "csvEncoding",
1265
- "includeHeaders",
1266
- "columnSettings",
1267
- "visibleColumns",
1268
- "columnLabels",
1269
- "tableTotalsLabelColumnKey",
1270
- "fileFormat",
1271
- "title"
1272
- ]);
1273
- function ie(e) {
1274
- return e !== null && typeof e == "object" && !Array.isArray(e);
1275
- }
1276
- function Le(e, t) {
1277
- if (e !== void 0) {
1278
- if (!ie(e))
1279
- throw new Error(`formatting.${t} must be an object`);
1280
- return e;
1281
- }
1282
- }
1283
- function $o(e) {
1284
- if (!ie(e))
1285
- throw new Error("formatting must be an object");
1286
- const t = ["reportContext", "resolvedFormats"].find(
1287
- (s) => Object.prototype.hasOwnProperty.call(e, s)
1288
- );
1289
- if (t)
1290
- throw new ye(
1291
- `formatting.${t} is retired; formatting.presentationExecutionSnapshot is authoritative.`
1292
- );
1293
- const r = Object.keys(e).find((s) => !Kr.has(s));
1294
- if (r)
1295
- throw new Error(`formatting contains unknown property "${r}"`);
1296
- const o = typeof e.timezone == "string" ? e.timezone.trim() : "";
1297
- if (!o)
1298
- throw new Error("formatting.timezone must be a non-empty string");
1299
- const n = gt(e.delimiter);
1300
- if (!n)
1301
- throw new Error("formatting.delimiter must be a comma, semicolon or tab");
1302
- const i = pt(e.csvEncoding);
1303
- if (!i)
1304
- throw new Error("formatting.csvEncoding must be 'utf-8-bom' or 'utf-8'");
1305
- if (typeof e.includeHeaders != "boolean")
1306
- throw new Error("formatting.includeHeaders must be a boolean");
1307
- if (e.useFormattedValues !== void 0 && typeof e.useFormattedValues != "boolean")
1308
- throw new Error("formatting.useFormattedValues must be a boolean");
1309
- const a = e.fileFormat === void 0 ? void 0 : yt(e.fileFormat);
1310
- if (e.fileFormat !== void 0 && !a)
1311
- throw new Error("formatting.fileFormat must be 'csv' or 'xlsx'");
1312
- if (e.title !== void 0 && typeof e.title != "string")
1313
- throw new Error("formatting.title must be a string");
1314
- const l = e.visibleColumns === void 0 ? void 0 : Array.isArray(e.visibleColumns) && e.visibleColumns.every((s) => typeof s == "string") ? e.visibleColumns : void 0;
1315
- if (e.visibleColumns !== void 0 && !l)
1316
- throw new Error("formatting.visibleColumns must be an array of strings");
1317
- const m = Le(e.columnLabels, "columnLabels");
1318
- if (m && Object.values(m).some((s) => typeof s != "string"))
1319
- throw new Error("formatting.columnLabels values must be strings");
1320
- const u = Le(e.columnSettings, "columnSettings"), g = e.tableTotalsLabelColumnKey === void 0 ? void 0 : typeof e.tableTotalsLabelColumnKey == "string" && e.tableTotalsLabelColumnKey.trim() ? e.tableTotalsLabelColumnKey : null;
1321
- if (g === null)
1322
- throw new Error("formatting.tableTotalsLabelColumnKey must be a non-empty string");
1323
- if (g && !(l != null && l.includes(g)))
1324
- throw new Error("formatting.tableTotalsLabelColumnKey must identify a visible column");
1325
- const p = Ct(e.scope, "formatting.scope");
1326
- if (!p.cardId || p.attachmentIndex !== void 0)
1327
- throw new Error("formatting.scope must identify exactly one dashboard card");
1328
- const v = e.useFormattedValues !== !1, d = xt(e.presentationExecutionSnapshot);
1329
- if (o !== d.reportContext.calendar.tz)
1330
- throw new Error(
1331
- "formatting.timezone must equal presentationExecutionSnapshot.reportContext.calendar.tz"
1332
- );
1333
- try {
1334
- St({
1335
- snapshot: d,
1336
- expectedScope: { dashboardId: p.dashboardId, cardId: p.cardId },
1337
- visibleColumns: l,
1338
- useFormattedValues: v
1339
- });
1340
- } catch (s) {
1341
- throw new ye(
1342
- `formatting.presentationExecutionSnapshot.${s instanceof Error ? s.message : String(s)}`
1343
- );
1344
- }
1345
- return {
1346
- scope: { dashboardId: p.dashboardId, cardId: p.cardId },
1347
- useFormattedValues: v,
1348
- timezone: o,
1349
- presentationExecutionSnapshot: d,
1350
- delimiter: n,
1351
- csvEncoding: i,
1352
- includeHeaders: e.includeHeaders,
1353
- ...u ? { columnSettings: u } : {},
1354
- ...l ? { visibleColumns: l } : {},
1355
- ...m ? { columnLabels: m } : {},
1356
- ...g ? { tableTotalsLabelColumnKey: g } : {},
1357
- ...a ? { fileFormat: a } : {},
1358
- ...typeof e.title == "string" ? { title: e.title } : {}
1359
- };
1360
- }
1361
- function _o(e) {
1362
- const t = e.formatOptions, r = (o) => ie(o) ? o : void 0;
1363
- return {
1364
- scope: { dashboardId: e.dashboardId, cardId: e.cardId },
1365
- useFormattedValues: t.useFormattedValues !== !1,
1366
- timezone: t.presentationExecutionSnapshot.reportContext.calendar.tz,
1367
- presentationExecutionSnapshot: t.presentationExecutionSnapshot,
1368
- delimiter: typeof t.delimiter == "string" ? t.delimiter : ",",
1369
- csvEncoding: t.csvEncoding,
1370
- includeHeaders: t.includeHeaders !== !1,
1371
- columnSettings: r(t.columnSettings),
1372
- visibleColumns: Array.isArray(t.visibleColumns) ? t.visibleColumns : void 0,
1373
- columnLabels: r(t.columnLabels),
1374
- tableTotalsLabelColumnKey: typeof t.tableTotalsLabelColumnKey == "string" ? t.tableTotalsLabelColumnKey : void 0,
1375
- ...e.fileFormat ? { fileFormat: e.fileFormat } : {},
1376
- ...typeof e.title == "string" ? { title: e.title } : {}
1377
- };
1378
- }
1379
- const Br = /^\d{4}-\d{2}-\d{2}$/;
1380
- function Ze(e) {
1381
- const t = e.split(".");
1382
- return t[t.length - 1].replace(/_/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").split(" ").map((n) => n.charAt(0).toUpperCase() + n.slice(1).toLowerCase()).join(" ");
1383
- }
1384
- const Fe = 10;
1385
- function ee(e, t) {
1386
- const r = e.slice(0, Fe).map(t).join(", "), o = e.length - Fe;
1387
- return o > 0 ? `${r}, and ${o} more` : r;
1388
- }
1389
- function zr(e) {
1390
- if (e.valueType !== "date" || e.operation !== "between" && e.operation !== "not between")
1391
- return;
1392
- const t = ae(e.relativeMeta);
1393
- if (t)
1394
- return wt(t) || t.unit === "quarter" || t.unit === "year" ? t : void 0;
1395
- }
1396
- function jr(e, t) {
1397
- if (t !== "label") return zr(e);
1398
- if (!(e.valueType !== "date" || e.operation !== "between" && e.operation !== "not between"))
1399
- return ae(e.relativeMeta);
1400
- }
1401
- function Me(e, t = {}) {
1402
- const { name: r, operation: o, values: n, valueType: i } = e, a = t.label ?? Ze(r), l = jr(e, t.relativeDates);
1403
- if (l) {
1404
- const u = $t(l);
1405
- if (u)
1406
- return o === "between" ? `${a}: ${u}` : `${a} not in ${u}`;
1407
- }
1408
- if (!n || n.length === 0)
1409
- return o === "is null" ? `${a} is empty` : o === "is not null" ? `${a} is not empty` : "";
1410
- const m = (u) => {
1411
- if (i === "date" && u) {
1412
- const g = e.temporalPrecision === "minute", p = {
1413
- year: "numeric",
1414
- month: "short",
1415
- day: "numeric",
1416
- ...g ? {
1417
- hour: "numeric",
1418
- minute: "2-digit"
1419
- } : {}
1420
- };
1421
- if (typeof u == "string" && Br.test(u)) {
1422
- const [d, s, f] = u.split("-").map(Number);
1423
- return new Intl.DateTimeFormat(void 0, {
1424
- year: "numeric",
1425
- month: "short",
1426
- day: "numeric",
1427
- timeZone: "UTC"
1428
- }).format(new Date(Date.UTC(d, s - 1, f)));
1429
- }
1430
- if (typeof u == "string" && mt(u) === "wall_datetime") {
1431
- const [d, s, f, b, y] = u.split(/[-T :.]/).map(Number);
1432
- return new Intl.DateTimeFormat(void 0, {
1433
- ...p,
1434
- timeZone: "UTC"
1435
- }).format(new Date(Date.UTC(d, s - 1, f, b, y)));
1436
- }
1437
- const v = new Date(u);
1438
- if (!isNaN(v.getTime()))
1439
- try {
1440
- return new Intl.DateTimeFormat(void 0, {
1441
- ...p,
1442
- ...t.timezone ? { timeZone: t.timezone } : {}
1443
- }).format(v);
1444
- } catch {
1445
- return g ? v.toLocaleString(void 0, p) : v.toLocaleDateString(void 0, p);
1446
- }
1447
- }
1448
- return String(u);
1449
- };
1450
- switch (o) {
1451
- case "=":
1452
- return `${a}: ${m(n[0])}`;
1453
- case "!=":
1454
- return `${a} ≠ ${m(n[0])}`;
1455
- case ">":
1456
- return `${a} > ${m(n[0])}`;
1457
- case "<":
1458
- return `${a} < ${m(n[0])}`;
1459
- case ">=":
1460
- return `${a} ≥ ${m(n[0])}`;
1461
- case "<=":
1462
- return `${a} ≤ ${m(n[0])}`;
1463
- case "between":
1464
- case "not between": {
1465
- const u = `${m(n[0])} - ${m(n[1])}`;
1466
- return o === "between" ? `${a}: ${u}` : `${a} not in ${u}`;
1467
- }
1468
- case "in":
1469
- return n.length === 1 ? `${a}: ${m(n[0])}` : `${a}: ${ee(n, m)}`;
1470
- case "not in":
1471
- return `${a} not in (${ee(n, m)})`;
1472
- case "like":
1473
- return `${a} contains "${n[0]}"`;
1474
- case "not like":
1475
- return `${a} doesn't contain "${n[0]}"`;
1476
- default:
1477
- return `${a}: ${ee(n, m)}`;
1478
- }
1479
- }
1480
- function Do(e, t = {}) {
1481
- if (!e || e.length === 0)
1482
- return "";
1483
- const r = /* @__PURE__ */ new Map();
1484
- e.forEach((n) => {
1485
- const i = r.get(n.name) || [];
1486
- i.push(n), r.set(n.name, i);
1487
- });
1488
- const o = [];
1489
- return r.forEach((n, i) => {
1490
- if (n.length === 1) {
1491
- const a = Me(n[0], t);
1492
- a && o.push(a);
1493
- } else {
1494
- const a = Ze(i), l = n.map((m) => Me(m, t).replace(`${a}: `, "").replace(`${a} `, "")).filter(Boolean);
1495
- l.length > 0 && o.push(`${a}: ${l.join(" and ")}`);
1496
- }
1497
- }), o.join(" | ");
1498
- }
1499
- function Ro(e) {
1500
- return ((e == null ? void 0 : e.filterValues) ?? []).filter(Gr).map(Hr);
1501
- }
1502
- function Gr(e) {
1503
- return !!e && typeof e == "object" && typeof e.name == "string" && Array.isArray(e.values);
1504
- }
1505
- function Hr(e) {
1506
- if (!("relativeMeta" in e) || e.relativeMeta === void 0) return e;
1507
- const { relativeMeta: t, ...r } = e, o = ae(t);
1508
- return o ? { ...r, relativeMeta: o } : r;
1509
- }
1510
- const Xr = /* @__PURE__ */ new Set([
1511
- "day",
1512
- "week",
1513
- "month",
1514
- "quarter",
1515
- "year"
1516
- ]);
1517
- function Wr(e, t) {
1518
- try {
1519
- const r = $(
1520
- O(e),
1521
- t,
1522
- "yyyy-MM-dd"
1523
- ), [o, n, i] = r.split("-").map(Number), a = new Date(Date.UTC(o, n - 1, i));
1524
- return a.setUTCDate(a.getUTCDate() - 1), $(a, "UTC", "yyyy-MM-dd");
1525
- } catch {
1526
- return;
1527
- }
1528
- }
1529
- function Po(e, t, r, o = !1) {
1530
- const n = Yr(
1531
- e,
1532
- t,
1533
- r,
1534
- o
1535
- );
1536
- return `${n.start} - ${n.end}`;
1537
- }
1538
- function Yr(e, t, r, o = !1) {
1539
- try {
1540
- if (r && Xr.has(r)) {
1541
- const n = Wr(e.end, t);
1542
- if (n) {
1543
- const i = o ? "MMM d" : "MMM d, yyyy";
1544
- return {
1545
- start: $(
1546
- O(e.start),
1547
- t,
1548
- i
1549
- ),
1550
- end: $(
1551
- O(`${n}T00:00:00Z`),
1552
- "UTC",
1553
- "MMM d, yyyy"
1554
- )
1555
- };
1556
- }
1557
- }
1558
- if (r === "second" || r === "minute" || r === "hour") {
1559
- const n = o ? "MMM d, h:mm a" : "MMM d, yyyy, h:mm a";
1560
- return {
1561
- start: $(O(e.start), t, n),
1562
- end: `before ${$(
1563
- O(e.end),
1564
- t,
1565
- n
1566
- )}`
1567
- };
1568
- }
1569
- } catch {
1570
- }
1571
- return { start: e.start, end: `before ${e.end}` };
1572
- }
1573
- export {
1574
- Io as A,
1575
- $o as B,
1576
- _o as C,
1577
- Ve as D,
1578
- Mo as E,
1579
- Xt as F,
1580
- Fe as G,
1581
- zr as H,
1582
- Me as I,
1583
- Do as J,
1584
- Ro as K,
1585
- Cr as L,
1586
- po as M,
1587
- oe as N,
1588
- xr as O,
1589
- Qt as P,
1590
- Sr as Q,
1591
- Er as R,
1592
- Lo as S,
1593
- He as T,
1594
- Fo as U,
1595
- kr as V,
1596
- er as W,
1597
- Yr as X,
1598
- fo as a,
1599
- yo as b,
1600
- ho as c,
1601
- bo as d,
1602
- go as e,
1603
- Po as f,
1604
- wo as g,
1605
- Co as h,
1606
- xo as i,
1607
- or as j,
1608
- So as k,
1609
- vo as l,
1610
- rr as m,
1611
- To as n,
1612
- Wt as o,
1613
- tr as p,
1614
- Zt as q,
1615
- ve as r,
1616
- Jt as s,
1617
- P as t,
1618
- ar as u,
1619
- sr as v,
1620
- Eo as w,
1621
- ko as x,
1622
- mr as y,
1623
- Ao as z
1624
- };