react-semaphor 0.1.544 → 0.1.546

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