react-semaphor 0.1.459 → 0.1.461

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 (114) hide show
  1. package/dist/analytics-protocol/index.cjs +1 -1
  2. package/dist/analytics-protocol/index.js +32 -32
  3. package/dist/brand-studio/index.cjs +1 -1
  4. package/dist/brand-studio/index.js +4 -4
  5. package/dist/briefings/index.cjs +1 -1
  6. package/dist/briefings/index.js +4 -4
  7. package/dist/chunks/{analyze-result-contract-BbRJ-C06.js → analyze-result-contract-DROq4vgY.js} +1 -1
  8. package/dist/chunks/{analyze-result-contract-LPDNldic.cjs → analyze-result-contract-DSGoFuXQ.cjs} +1 -1
  9. package/dist/chunks/canonical-result-keys-CEQefvdO.js +33 -0
  10. package/dist/chunks/canonical-result-keys-Cb96edol.cjs +1 -0
  11. package/dist/chunks/{common-types-H51FLKB7.js → common-types-BHVKgxRR.js} +1 -1
  12. package/dist/chunks/{common-types-C57kJ59w.cjs → common-types-BcV9PD9D.cjs} +1 -1
  13. package/dist/chunks/{dashboard-briefing-launcher-ClCj98sq.js → dashboard-briefing-launcher-3owMxX5K.js} +60 -61
  14. package/dist/chunks/{dashboard-briefing-launcher-DHtEouuH.cjs → dashboard-briefing-launcher-xuGrw8H3.cjs} +2 -2
  15. package/dist/chunks/{dashboard-controls-B8gsKlxc.js → dashboard-controls-B4GvjGr1.js} +44 -45
  16. package/dist/chunks/{dashboard-controls-VRShl9J0.cjs → dashboard-controls-Bpm_xOXQ.cjs} +1 -1
  17. package/dist/chunks/dashboard-filter-value-compatibility-KXIyvbhc.js +677 -0
  18. package/dist/chunks/dashboard-filter-value-compatibility-UapptYnn.cjs +1 -0
  19. package/dist/chunks/dashboard-input-contract-BkRFQ7Tq.cjs +1 -0
  20. package/dist/chunks/{dashboard-date-comparison-definition-DC3ekV2S.js → dashboard-input-contract-D5dxTWJ5.js} +41 -25
  21. package/dist/chunks/{dashboard-json-i_Auue_K.js → dashboard-json-DzyxoBp-.js} +13 -14
  22. package/dist/chunks/dashboard-json-yLM01xK4.cjs +1 -0
  23. package/dist/chunks/{edit-dashboard-visual-DWWyT55u.cjs → edit-dashboard-visual-1T278Nr_.cjs} +28 -28
  24. package/dist/chunks/{edit-dashboard-visual-B3JF0fe4.js → edit-dashboard-visual-nwSasO_j.js} +880 -894
  25. package/dist/chunks/{editor-action-buttons-BTlCsP63.cjs → editor-action-buttons-CX1Pken3.cjs} +2 -2
  26. package/dist/chunks/{editor-action-buttons-C9x3nGnb.js → editor-action-buttons-Dqw0asfA.js} +28 -28
  27. package/dist/chunks/index-B1qplNxl.cjs +1392 -0
  28. package/dist/chunks/{index-BS2-ZZGf.js → index-DazD5k0F.js} +45362 -42931
  29. package/dist/chunks/{index-BIFLI8ul.js → index-De_7nrwb.js} +10 -10
  30. package/dist/chunks/index-DjjKJPDy.cjs +4 -0
  31. package/dist/chunks/{matrix-result-contract-CofATICL.js → matrix-result-contract-BTpPuHOc.js} +88 -104
  32. package/dist/chunks/matrix-result-contract-ZRNfeIbI.cjs +1 -0
  33. package/dist/chunks/{pivot-header-presentation-B9nXXKlW.cjs → pivot-header-presentation-BijPbP33.cjs} +1 -1
  34. package/dist/chunks/{pivot-header-presentation-D-0jvUwn.js → pivot-header-presentation-DW0gKG8g.js} +2 -2
  35. package/dist/chunks/{pivot-result-identity-Bb4EixVN.cjs → pivot-result-identity-DxHtiKVj.cjs} +1 -1
  36. package/dist/chunks/{pivot-result-identity-DU1v-5Xk.js → pivot-result-identity-Z9tN2tEV.js} +1 -1
  37. package/dist/chunks/{pivot-result-lifecycle-DTLRuDEW.cjs → pivot-result-lifecycle-BXzIlQVu.cjs} +1 -1
  38. package/dist/chunks/{pivot-result-lifecycle-CHWEGU2o.js → pivot-result-lifecycle-g2U-vzQb.js} +7 -7
  39. package/dist/chunks/{raw-temporal-contract-BtjH_G-d.cjs → raw-temporal-contract-DfAvqNMo.cjs} +1 -1
  40. package/dist/chunks/{raw-temporal-contract-CxncLze5.js → raw-temporal-contract-UtAqoOZO.js} +1 -1
  41. package/dist/chunks/{report-preferences-dialog-BK0yAJnQ.cjs → report-preferences-dialog-DKPyjiCt.cjs} +1 -1
  42. package/dist/chunks/{report-preferences-dialog-BDpkcUtz.js → report-preferences-dialog-Dv3vCCFt.js} +6 -6
  43. package/dist/chunks/{report-runtime-context-DqxS4wbi.cjs → report-runtime-context-C0NfLPfc.cjs} +1 -1
  44. package/dist/chunks/{report-runtime-context-SM6YO61_.js → report-runtime-context-CNncA3VD.js} +11 -11
  45. package/dist/chunks/{saved-temporal-bucket-format-CFfWXRl9.cjs → saved-temporal-bucket-format-3QKveR3v.cjs} +1 -1
  46. package/dist/chunks/{saved-temporal-bucket-format-SGAV0ivR.js → saved-temporal-bucket-format-Dd2eixTH.js} +11 -11
  47. package/dist/chunks/switch-DBZsEV0U.cjs +138 -0
  48. package/dist/chunks/{switch-DQR-Va05.js → switch-kPUJEC1A.js} +6615 -5219
  49. package/dist/chunks/{temporal-bucket-5UYEotyQ.js → temporal-bucket-C85rmFmC.js} +4 -4
  50. package/dist/chunks/temporal-bucket-authoring-1fZuPAVb.js +653 -0
  51. package/dist/chunks/temporal-bucket-authoring-BK1UhYpD.cjs +1 -0
  52. package/dist/chunks/{temporal-bucket-contract-D5d-xEl3.js → temporal-bucket-contract-DXXNZssK.js} +1 -1
  53. package/dist/chunks/{temporal-bucket-contract-D2-93DGr.cjs → temporal-bucket-contract-xFkvboaw.cjs} +1 -1
  54. package/dist/chunks/{temporal-bucket-DHY1y9lq.cjs → temporal-bucket-pMfghsLX.cjs} +1 -1
  55. package/dist/chunks/{token-types-GbxRUozo.js → token-types-BLxc7UwR.js} +1 -1
  56. package/dist/chunks/{token-types-D7CaaI80.cjs → token-types-BYYO109W.cjs} +1 -1
  57. package/dist/chunks/{update-policy-hednMF-0.js → update-policy-CB8XJIoY.js} +1 -1
  58. package/dist/chunks/{update-policy-BmiOd0PB.cjs → update-policy-DMjjGjQY.cjs} +1 -1
  59. package/dist/chunks/{validators-DEmd8Sin.js → validators-DVd8s3qY.js} +416 -350
  60. package/dist/chunks/validators-dJlwubP4.cjs +1 -0
  61. package/dist/dashboard/index.cjs +1 -1
  62. package/dist/dashboard/index.js +2 -2
  63. package/dist/dashboard-authoring/index.cjs +3 -3
  64. package/dist/dashboard-authoring/index.js +328 -311
  65. package/dist/data-app-builder/index.cjs +1 -1
  66. package/dist/data-app-builder/index.js +2 -2
  67. package/dist/data-app-codegen/index.cjs +1 -1
  68. package/dist/data-app-codegen/index.js +2 -2
  69. package/dist/data-app-codegen-node/index.cjs +1 -1
  70. package/dist/data-app-codegen-node/index.js +3 -3
  71. package/dist/data-app-sdk/index.cjs +1 -1
  72. package/dist/data-app-sdk/index.js +55 -55
  73. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  74. package/dist/data-app-sdk-adapters/index.js +61 -56
  75. package/dist/data-app-sdk-validation/index.cjs +1 -1
  76. package/dist/data-app-sdk-validation/index.js +9 -9
  77. package/dist/format-utils/index.cjs +1 -1
  78. package/dist/format-utils/index.js +15 -15
  79. package/dist/index.cjs +1 -1
  80. package/dist/index.js +154 -155
  81. package/dist/report-runtime-context/index.cjs +1 -1
  82. package/dist/report-runtime-context/index.js +2 -2
  83. package/dist/style.css +1 -1
  84. package/dist/surfboard/index.cjs +1 -1
  85. package/dist/surfboard/index.js +3 -3
  86. package/dist/types/analytics-protocol.d.ts +16 -8
  87. package/dist/types/briefings.d.ts +95 -13
  88. package/dist/types/dashboard-assistant.d.ts +11 -6
  89. package/dist/types/dashboard-authoring.d.ts +257 -19
  90. package/dist/types/dashboard.d.ts +109 -14
  91. package/dist/types/data-app-builder.d.ts +11 -6
  92. package/dist/types/data-app-codegen-node.d.ts +16 -8
  93. package/dist/types/data-app-codegen.d.ts +16 -8
  94. package/dist/types/data-app-sdk-adapters.d.ts +17 -11
  95. package/dist/types/data-app-sdk-validation.d.ts +17 -11
  96. package/dist/types/data-app-sdk.d.ts +17 -11
  97. package/dist/types/index.cjs +1 -1
  98. package/dist/types/index.js +4 -4
  99. package/dist/types/main.d.ts +225 -20
  100. package/dist/types/shared.d.ts +95 -13
  101. package/dist/types/surfboard.d.ts +109 -14
  102. package/dist/types/types.d.ts +109 -14
  103. package/package.json +1 -1
  104. package/dist/chunks/canonical-result-keys-BA0HCP4e.cjs +0 -1
  105. package/dist/chunks/canonical-result-keys-D6avdjpA.js +0 -467
  106. package/dist/chunks/dashboard-date-comparison-definition-Ces4alFm.cjs +0 -1
  107. package/dist/chunks/dashboard-json-BhvPMpZA.cjs +0 -1
  108. package/dist/chunks/index-DHF-2AqS.cjs +0 -1392
  109. package/dist/chunks/index-k8tEp0ys.cjs +0 -4
  110. package/dist/chunks/matrix-result-contract-zamd9euI.cjs +0 -1
  111. package/dist/chunks/switch-f3TuZNLr.cjs +0 -138
  112. package/dist/chunks/temporal-bucket-authoring-K1kE6R_z.js +0 -222
  113. package/dist/chunks/temporal-bucket-authoring-o3Emn05L.cjs +0 -1
  114. package/dist/chunks/validators-BDYprKI9.cjs +0 -1
@@ -1,22 +1,10 @@
1
1
  var _ = Object.defineProperty;
2
2
  var B = (e, t, a) => t in e ? _(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
3
  var x = (e, t, a) => B(e, typeof t != "symbol" ? t + "" : t, a);
4
- import { p as S } from "./temporal-bucket-5UYEotyQ.js";
5
- import { k as T } from "./validators-DEmd8Sin.js";
6
- import { v as k } from "./temporal-bucket-contract-D5d-xEl3.js";
7
- function V(e) {
8
- return `compat-filter:${e}`;
9
- }
10
- function J(e) {
11
- return `compat-control:${e}`;
12
- }
13
- function L(e, t) {
14
- return `compat-inline-filter:${e}:${t}`;
15
- }
16
- function D(e, t) {
17
- return `compat-card-control:${e}:${t}`;
18
- }
19
- class v extends Error {
4
+ import { p as S } from "./temporal-bucket-C85rmFmC.js";
5
+ import { d as T } from "./validators-DVd8s3qY.js";
6
+ import { v as k } from "./temporal-bucket-contract-DXXNZssK.js";
7
+ class g extends Error {
20
8
  constructor(a) {
21
9
  super(a.message);
22
10
  x(this, "code");
@@ -24,11 +12,11 @@ class v extends Error {
24
12
  this.name = "MatrixResultContractError", this.code = a.code, this.path = a.path;
25
13
  }
26
14
  }
27
- function F(e) {
15
+ function V(e) {
28
16
  var u, m, p;
29
17
  const t = G(e);
30
18
  if (t !== 2)
31
- throw new v({
19
+ throw new g({
32
20
  code: "unsupported_matrix_result_version",
33
21
  message: `Canonical Matrix results require schemaVersion 2; received ${String(t)}.`,
34
22
  path: "schemaVersion"
@@ -42,41 +30,41 @@ function F(e) {
42
30
  );
43
31
  }
44
32
  const r = a.data, s = {
45
- row: y(r.axes.rows.levels, "axes.rows.levels"),
46
- column: y(
33
+ row: I(r.axes.rows.levels, "axes.rows.levels"),
34
+ column: I(
47
35
  r.axes.columns.levels,
48
36
  "axes.columns.levels"
49
37
  )
50
38
  };
51
- O(r), $(r, "row"), $(r, "column");
52
- const n = /* @__PURE__ */ new Set([
39
+ C(r), $(r, "row"), $(r, "column");
40
+ const i = /* @__PURE__ */ new Set([
53
41
  ...r.axes.rows.nodeIds,
54
42
  ...r.axes.columns.nodeIds
55
- ]), i = /* @__PURE__ */ new Set();
43
+ ]), n = /* @__PURE__ */ new Set();
56
44
  for (const [d, l] of Object.entries(r.nodesById)) {
57
45
  if (l.id !== d)
58
46
  throw o(
59
47
  "Matrix node directory key must equal node.id.",
60
48
  `nodesById.${d}.id`
61
49
  );
62
- if (!n.has(d))
50
+ if (!i.has(d))
63
51
  throw o(
64
52
  "Matrix node directory cannot contain nodes omitted from both axes.",
65
53
  `nodesById.${d}`
66
54
  );
67
- C(l, s[l.axis], `nodesById.${d}`);
55
+ R(l, s[l.axis], `nodesById.${d}`);
68
56
  const f = JSON.stringify([
69
57
  l.axis,
70
58
  l.path,
71
59
  l.isSubtotal === !0,
72
60
  l.isGrandTotal === !0
73
61
  ]);
74
- if (i.has(f))
62
+ if (n.has(f))
75
63
  throw o(
76
64
  "Matrix nodes must have unique canonical path and total-role identity.",
77
65
  `nodesById.${d}`
78
66
  );
79
- i.add(f), q(r, l, `nodesById.${d}`);
67
+ n.add(f), O(r, l, `nodesById.${d}`);
80
68
  }
81
69
  const c = /* @__PURE__ */ new Set();
82
70
  for (const [d, l] of r.cells.entries()) {
@@ -95,7 +83,7 @@ function F(e) {
95
83
  "Matrix cell measureId must reference a measure.",
96
84
  `cells.${d}.measureId`
97
85
  );
98
- const f = R(
86
+ const f = K(
99
87
  r.nodesById[l.rowId],
100
88
  l.columnId ? r.nodesById[l.columnId] : void 0
101
89
  );
@@ -104,58 +92,58 @@ function F(e) {
104
92
  "Matrix cell role must match its referenced row and column total roles.",
105
93
  `cells.${d}.role`
106
94
  );
107
- const w = JSON.stringify([
95
+ const y = JSON.stringify([
108
96
  l.rowId,
109
97
  l.columnId ?? null,
110
98
  l.measureId
111
99
  ]);
112
- if (c.has(w))
100
+ if (c.has(y))
113
101
  throw o(
114
102
  "Matrix result cannot contain duplicate physical cell addresses.",
115
103
  `cells.${d}`
116
104
  );
117
- c.add(w);
105
+ c.add(y);
118
106
  }
119
- return K(r, s), r;
107
+ return q(r, s), r;
120
108
  }
121
- function y(e, t) {
109
+ function I(e, t) {
122
110
  var r;
123
111
  const a = /* @__PURE__ */ new Map();
124
- for (const [s, n] of e.entries()) {
125
- const i = `${t}.${s}`;
126
- if (a.has(n.instanceId))
112
+ for (const [s, i] of e.entries()) {
113
+ const n = `${t}.${s}`;
114
+ if (a.has(i.instanceId))
127
115
  throw o(
128
116
  "Matrix axis level ids must be unique.",
129
- `${i}.instanceId`
117
+ `${n}.instanceId`
130
118
  );
131
- a.set(n.instanceId, n);
132
- const c = n.field.role === "date" || n.field.dataType === "date" || n.field.dataType === "datetime", u = n.field.dataType === "string" || n.field.dataType === "number" || n.field.dataType === "boolean";
133
- if (c && !n.grain)
119
+ a.set(i.instanceId, i);
120
+ const c = i.field.role === "date" || i.field.dataType === "date" || i.field.dataType === "datetime", u = i.field.dataType === "string" || i.field.dataType === "number" || i.field.dataType === "boolean";
121
+ if (c && !i.grain)
134
122
  throw o(
135
123
  "Temporal Matrix axis level is missing its explicit grain.",
136
- `${i}.grain`
124
+ `${n}.grain`
137
125
  );
138
- if (u && n.grain)
126
+ if (u && i.grain)
139
127
  throw o(
140
128
  "Non-temporal Matrix axis level cannot carry a grain.",
141
- `${i}.grain`
129
+ `${n}.grain`
142
130
  );
143
- if (n.grain) {
144
- if (!n.temporalBucket)
131
+ if (i.grain) {
132
+ if (!i.temporalBucket)
145
133
  throw o(
146
134
  "Temporal Matrix axis level is missing governed bucket metadata.",
147
- `${i}.temporalBucket`
135
+ `${n}.temporalBucket`
148
136
  );
149
- const m = k(n.temporalBucket);
150
- if (!m.ok || ((r = m.value) == null ? void 0 : r.granularity) !== n.grain)
137
+ const m = k(i.temporalBucket);
138
+ if (!m.ok || ((r = m.value) == null ? void 0 : r.granularity) !== i.grain)
151
139
  throw o(
152
140
  "Matrix axis grain and temporal metadata must agree.",
153
- `${i}.temporalBucket`
141
+ `${n}.temporalBucket`
154
142
  );
155
- } else if (n.temporalBucket)
143
+ } else if (i.temporalBucket)
156
144
  throw o(
157
145
  "Non-temporal Matrix axis levels cannot carry temporal bucket metadata.",
158
- i
146
+ n
159
147
  );
160
148
  }
161
149
  return a;
@@ -163,20 +151,20 @@ function y(e, t) {
163
151
  function $(e, t) {
164
152
  var s;
165
153
  const a = t === "row" ? e.axes.rows : e.axes.columns, r = /* @__PURE__ */ new Set();
166
- for (const [n, i] of a.nodeIds.entries()) {
167
- if (r.has(i))
154
+ for (const [i, n] of a.nodeIds.entries()) {
155
+ if (r.has(n))
168
156
  throw o(
169
157
  "Matrix axis node ids must be unique.",
170
- `axes.${t === "row" ? "rows" : "columns"}.nodeIds.${n}`
158
+ `axes.${t === "row" ? "rows" : "columns"}.nodeIds.${i}`
171
159
  );
172
- if (r.add(i), ((s = e.nodesById[i]) == null ? void 0 : s.axis) !== t)
160
+ if (r.add(n), ((s = e.nodesById[n]) == null ? void 0 : s.axis) !== t)
173
161
  throw o(
174
162
  "Matrix axis node id references the wrong axis.",
175
- `axes.${t === "row" ? "rows" : "columns"}.nodeIds.${n}`
163
+ `axes.${t === "row" ? "rows" : "columns"}.nodeIds.${i}`
176
164
  );
177
165
  }
178
166
  }
179
- function C(e, t, a) {
167
+ function R(e, t, a) {
180
168
  if (e.isGrandTotal) {
181
169
  if (e.isSubtotal)
182
170
  throw o(
@@ -228,25 +216,25 @@ function C(e, t, a) {
228
216
  );
229
217
  M(c, m, `${a}.path.${u}`);
230
218
  });
231
- const s = e.path[e.path.length - 1], n = s.instanceId === "__matrix_remaining__" && s.fieldKey === "__matrix_remaining__" && s.value === "__matrix_remaining__";
232
- if (!I(e.value, s.value))
219
+ const s = e.path[e.path.length - 1], i = s.instanceId === "__matrix_remaining__" && s.fieldKey === "__matrix_remaining__" && s.value === "__matrix_remaining__";
220
+ if (!w(e.value, s.value))
233
221
  throw o(
234
222
  "Matrix node value must equal its final canonical path member.",
235
223
  `${a}.value`
236
224
  );
237
- const i = r[e.path.length - 1];
238
- if (i != null && i.temporalBucket && !e.isSubtotal && !n && e.label !== void 0)
225
+ const n = r[e.path.length - 1];
226
+ if (n != null && n.temporalBucket && !e.isSubtotal && !i && e.label !== void 0)
239
227
  throw o(
240
228
  "Temporal Matrix nodes cannot transport display labels.",
241
229
  `${a}.label`
242
230
  );
243
- if ((!(i != null && i.temporalBucket) || n) && typeof e.label != "string")
231
+ if ((!(n != null && n.temporalBucket) || i) && typeof e.label != "string")
244
232
  throw o(
245
233
  "Non-temporal Matrix nodes require a display label.",
246
234
  `${a}.label`
247
235
  );
248
236
  }
249
- function R(e, t) {
237
+ function K(e, t) {
250
238
  return e.isGrandTotal && (t != null && t.isGrandTotal) ? "matrixGrandTotal" : e.isGrandTotal ? "rowGrandTotal" : t != null && t.isGrandTotal ? "columnGrandTotal" : e.isSubtotal && (t != null && t.isSubtotal) ? "subtotalIntersection" : e.isSubtotal ? "rowSubtotal" : t != null && t.isSubtotal ? "columnSubtotal" : "value";
251
239
  }
252
240
  function M(e, t, a) {
@@ -273,62 +261,62 @@ function M(e, t, a) {
273
261
  `${a}.label`
274
262
  );
275
263
  }
276
- function K(e, t) {
264
+ function q(e, t) {
277
265
  const a = [...t.row.values()];
278
266
  if (e.layout.rowHeaderLevels.length !== a.length)
279
267
  throw o(
280
268
  "Matrix row-header layout must describe every row-axis level exactly once.",
281
269
  "layout.rowHeaderLevels"
282
270
  );
283
- e.layout.rowHeaderLevels.forEach((s, n) => {
284
- var i;
285
- if (s.fieldInstanceId !== ((i = a[n]) == null ? void 0 : i.instanceId))
271
+ e.layout.rowHeaderLevels.forEach((s, i) => {
272
+ var n;
273
+ if (s.fieldInstanceId !== ((n = a[i]) == null ? void 0 : n.instanceId))
286
274
  throw o(
287
275
  "Matrix row-header layout must follow authored row-axis order.",
288
- `layout.rowHeaderLevels.${n}.fieldInstanceId`
276
+ `layout.rowHeaderLevels.${i}.fieldInstanceId`
289
277
  );
290
278
  });
291
- for (const [s, n] of e.layout.columnHeaderRows.entries())
292
- for (const [i, c] of n.cells.entries()) {
279
+ for (const [s, i] of e.layout.columnHeaderRows.entries())
280
+ for (const [n, c] of i.cells.entries()) {
293
281
  if (b(
294
282
  c.columnPath,
295
283
  t.column,
296
- `layout.columnHeaderRows.${s}.cells.${i}.columnPath`
284
+ `layout.columnHeaderRows.${s}.cells.${n}.columnPath`
297
285
  ), c.measureInstanceId && !e.measuresById[c.measureInstanceId])
298
286
  throw o(
299
287
  "Matrix header measureInstanceId must reference a measure.",
300
- `layout.columnHeaderRows.${s}.cells.${i}.measureInstanceId`
288
+ `layout.columnHeaderRows.${s}.cells.${n}.measureInstanceId`
301
289
  );
302
290
  if (c.role === "columnHeader" && c.label !== void 0)
303
291
  throw o(
304
292
  "Matrix member headers cannot transport composed display labels.",
305
- `layout.columnHeaderRows.${s}.cells.${i}.label`
293
+ `layout.columnHeaderRows.${s}.cells.${n}.label`
306
294
  );
307
295
  }
308
296
  const r = /* @__PURE__ */ new Set();
309
- for (const [s, n] of e.layout.columns.entries()) {
310
- if (r.has(n.id))
297
+ for (const [s, i] of e.layout.columns.entries()) {
298
+ if (r.has(i.id))
311
299
  throw o(
312
300
  "Matrix layout column ids must be unique.",
313
301
  `layout.columns.${s}.id`
314
302
  );
315
- if (r.add(n.id), b(
316
- n.columnPath,
303
+ if (r.add(i.id), b(
304
+ i.columnPath,
317
305
  t.column,
318
306
  `layout.columns.${s}.columnPath`
319
- ), n.role === "value" && n.columnPath.length > 0 && n.label !== void 0)
307
+ ), i.role === "value" && i.columnPath.length > 0 && i.label !== void 0)
320
308
  throw o(
321
309
  "Matrix value columns with member paths cannot transport composed display labels.",
322
310
  `layout.columns.${s}.label`
323
311
  );
324
- if (!e.measuresById[n.measureInstanceId])
312
+ if (!e.measuresById[i.measureInstanceId])
325
313
  throw o(
326
314
  "Matrix layout column measureInstanceId must reference a measure.",
327
315
  `layout.columns.${s}.measureInstanceId`
328
316
  );
329
- if (n.columnNodeId) {
330
- const i = e.nodesById[n.columnNodeId];
331
- if ((i == null ? void 0 : i.axis) !== "column" || !I(i.path, n.columnPath))
317
+ if (i.columnNodeId) {
318
+ const n = e.nodesById[i.columnNodeId];
319
+ if ((n == null ? void 0 : n.axis) !== "column" || !w(n.path, i.columnPath))
332
320
  throw o(
333
321
  "Matrix layout column must match its referenced column node path.",
334
322
  `layout.columns.${s}.columnNodeId`
@@ -347,17 +335,17 @@ function b(e, t, a) {
347
335
  "Matrix layout path exceeds its authored axis depth.",
348
336
  a
349
337
  );
350
- e.forEach((s, n) => {
351
- const i = r[n];
352
- if (!i || s.instanceId !== i.instanceId || s.fieldKey !== i.fieldKey)
338
+ e.forEach((s, i) => {
339
+ const n = r[i];
340
+ if (!n || s.instanceId !== n.instanceId || s.fieldKey !== n.fieldKey)
353
341
  throw o(
354
342
  "Matrix layout path must follow authored axis order and identity.",
355
- `${a}.${n}`
343
+ `${a}.${i}`
356
344
  );
357
- M(s, i, `${a}.${n}`);
345
+ M(s, n, `${a}.${i}`);
358
346
  });
359
347
  }
360
- function q(e, t, a) {
348
+ function O(e, t, a) {
361
349
  if (!t.parentId) return;
362
350
  const r = e.nodesById[t.parentId];
363
351
  if (!r)
@@ -365,24 +353,24 @@ function q(e, t, a) {
365
353
  "Matrix parentId must reference an existing node.",
366
354
  `${a}.parentId`
367
355
  );
368
- if (r.axis !== t.axis || r.path.length !== t.path.length - 1 || !I(r.path, t.path.slice(0, -1)))
356
+ if (r.axis !== t.axis || r.path.length !== t.path.length - 1 || !w(r.path, t.path.slice(0, -1)))
369
357
  throw o(
370
358
  "Matrix parentId must reference the immediate same-axis path prefix.",
371
359
  `${a}.parentId`
372
360
  );
373
361
  }
374
- function O(e) {
362
+ function C(e) {
375
363
  for (const [t, a] of [
376
364
  ["rows", e.axes.rows],
377
365
  ["columns", e.axes.columns]
378
366
  ]) {
379
367
  const r = t === "rows" ? "row" : "column";
380
- a.levels.forEach((s, n) => {
381
- const i = e.fieldsById[s.instanceId];
382
- if (!i || i.instanceId !== s.instanceId || i.fieldKey !== s.fieldKey || i.role !== r || !g(i.field, s.field))
368
+ a.levels.forEach((s, i) => {
369
+ const n = e.fieldsById[s.instanceId];
370
+ if (!n || n.instanceId !== s.instanceId || n.fieldKey !== s.fieldKey || n.role !== r || !v(n.field, s.field))
383
371
  throw o(
384
372
  "Matrix axis level must have one matching role-scoped field descriptor.",
385
- `axes.${t}.levels.${n}`
373
+ `axes.${t}.levels.${i}`
386
374
  );
387
375
  });
388
376
  }
@@ -393,7 +381,7 @@ function O(e) {
393
381
  `measuresById.${t}.instanceId`
394
382
  );
395
383
  const r = e.fieldsById[t];
396
- if (!r || r.instanceId !== t || r.fieldKey !== a.fieldKey || r.role !== "measure" || !g(r.field, a.field))
384
+ if (!r || r.instanceId !== t || r.fieldKey !== a.fieldKey || r.role !== "measure" || !v(r.field, a.field))
397
385
  throw o(
398
386
  "Matrix measure must have one matching field descriptor.",
399
387
  `measuresById.${t}`
@@ -403,10 +391,10 @@ function O(e) {
403
391
  function G(e) {
404
392
  return e && typeof e == "object" ? e.schemaVersion : void 0;
405
393
  }
406
- function I(e, t) {
394
+ function w(e, t) {
407
395
  return JSON.stringify(e) === JSON.stringify(t);
408
396
  }
409
- function g(e, t) {
397
+ function v(e, t) {
410
398
  return h(e) === h(t);
411
399
  }
412
400
  function h(e) {
@@ -421,17 +409,13 @@ function h(e) {
421
409
  return e === void 0 ? "undefined" : JSON.stringify(e);
422
410
  }
423
411
  function o(e, t) {
424
- return new v({
412
+ return new g({
425
413
  code: "invalid_matrix_result_contract",
426
414
  message: e,
427
415
  path: t
428
416
  });
429
417
  }
430
418
  export {
431
- v as M,
432
- J as a,
433
- L as b,
434
- D as c,
435
- V as g,
436
- F as p
419
+ g as M,
420
+ V as p
437
421
  };
@@ -0,0 +1 @@
1
+ "use strict";var _=Object.defineProperty;var B=(e,t,a)=>t in e?_(e,t,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[t]=a;var p=(e,t,a)=>B(e,typeof t!="symbol"?t+"":t,a);const S=require("./temporal-bucket-pMfghsLX.cjs"),T=require("./validators-dJlwubP4.cjs"),k=require("./temporal-bucket-contract-xFkvboaw.cjs");class w extends Error{constructor(a){super(a.message);p(this,"code");p(this,"path");this.name="MatrixResultContractError",this.code=a.code,this.path=a.path}}function R(e){var u,m,x;const t=H(e);if(t!==2)throw new w({code:"unsupported_matrix_result_version",message:`Canonical Matrix results require schemaVersion 2; received ${String(t)}.`,path:"schemaVersion"});const a=T.semaphorMatrixResultSchema.safeParse(e);if(!a.success){const d=a.error.issues[0];throw o((d==null?void 0:d.message)||"Canonical Matrix result has an invalid shape.",d==null?void 0:d.path.join("."))}const r=a.data,s={row:$(r.axes.rows.levels,"axes.rows.levels"),column:$(r.axes.columns.levels,"axes.columns.levels")};G(r),b(r,"row"),b(r,"column");const i=new Set([...r.axes.rows.nodeIds,...r.axes.columns.nodeIds]),n=new Set;for(const[d,l]of Object.entries(r.nodesById)){if(l.id!==d)throw o("Matrix node directory key must equal node.id.",`nodesById.${d}.id`);if(!i.has(d))throw o("Matrix node directory cannot contain nodes omitted from both axes.",`nodesById.${d}`);q(l,s[l.axis],`nodesById.${d}`);const f=JSON.stringify([l.axis,l.path,l.isSubtotal===!0,l.isGrandTotal===!0]);if(n.has(f))throw o("Matrix nodes must have unique canonical path and total-role identity.",`nodesById.${d}`);n.add(f),O(r,l,`nodesById.${d}`)}const c=new Set;for(const[d,l]of r.cells.entries()){if(!((u=r.nodesById[l.rowId])!=null&&u.axis)||((m=r.nodesById[l.rowId])==null?void 0:m.axis)!=="row")throw o("Matrix cell rowId must reference a row node.",`cells.${d}.rowId`);if(l.columnId&&((x=r.nodesById[l.columnId])==null?void 0:x.axis)!=="column")throw o("Matrix cell columnId must reference a column node.",`cells.${d}.columnId`);if(!r.measuresById[l.measureId])throw o("Matrix cell measureId must reference a measure.",`cells.${d}.measureId`);const f=K(r.nodesById[l.rowId],l.columnId?r.nodesById[l.columnId]:void 0);if(l.role!==f)throw o("Matrix cell role must match its referenced row and column total roles.",`cells.${d}.role`);const I=JSON.stringify([l.rowId,l.columnId??null,l.measureId]);if(c.has(I))throw o("Matrix result cannot contain duplicate physical cell addresses.",`cells.${d}`);c.add(I)}return C(r,s),r}function $(e,t){var r;const a=new Map;for(const[s,i]of e.entries()){const n=`${t}.${s}`;if(a.has(i.instanceId))throw o("Matrix axis level ids must be unique.",`${n}.instanceId`);a.set(i.instanceId,i);const c=i.field.role==="date"||i.field.dataType==="date"||i.field.dataType==="datetime",u=i.field.dataType==="string"||i.field.dataType==="number"||i.field.dataType==="boolean";if(c&&!i.grain)throw o("Temporal Matrix axis level is missing its explicit grain.",`${n}.grain`);if(u&&i.grain)throw o("Non-temporal Matrix axis level cannot carry a grain.",`${n}.grain`);if(i.grain){if(!i.temporalBucket)throw o("Temporal Matrix axis level is missing governed bucket metadata.",`${n}.temporalBucket`);const m=k.validateTemporalBucketMetadata(i.temporalBucket);if(!m.ok||((r=m.value)==null?void 0:r.granularity)!==i.grain)throw o("Matrix axis grain and temporal metadata must agree.",`${n}.temporalBucket`)}else if(i.temporalBucket)throw o("Non-temporal Matrix axis levels cannot carry temporal bucket metadata.",n)}return a}function b(e,t){var s;const a=t==="row"?e.axes.rows:e.axes.columns,r=new Set;for(const[i,n]of a.nodeIds.entries()){if(r.has(n))throw o("Matrix axis node ids must be unique.",`axes.${t==="row"?"rows":"columns"}.nodeIds.${i}`);if(r.add(n),((s=e.nodesById[n])==null?void 0:s.axis)!==t)throw o("Matrix axis node id references the wrong axis.",`axes.${t==="row"?"rows":"columns"}.nodeIds.${i}`)}}function q(e,t,a){if(e.isGrandTotal){if(e.isSubtotal)throw o("Matrix nodes cannot be both subtotal and grand total.",a);if(e.path.length!==0)throw o("Matrix grand-total nodes must have an empty member path.",`${a}.path`);return}if(!e.path.length||e.level!==e.path.length-1)throw o("Ordinary and subtotal Matrix nodes require a level-aligned non-empty path.",a);const r=[...t.values()];if(e.path.length>r.length)throw o("Matrix node path exceeds its authored axis depth.",`${a}.path`);if(e.isSubtotal&&e.path.length>=r.length)throw o("Matrix subtotal nodes must identify a proper authored-axis prefix.",`${a}.path`);e.path.forEach((c,u)=>{const m=r[u];if(c.instanceId==="__matrix_remaining__"&&c.fieldKey==="__matrix_remaining__"&&c.value==="__matrix_remaining__"){if(u!==e.path.length-1)throw o("Matrix remaining-member identity must be the terminal path segment.",`${a}.path.${u}`);if(typeof c.label!="string")throw o("Matrix remaining-member paths require their explicit display label.",`${a}.path.${u}.label`);return}if(!m||c.instanceId!==m.instanceId||c.fieldKey!==m.fieldKey)throw o("Matrix member path must follow authored axis order and identity.",`${a}.path.${u}`);g(c,m,`${a}.path.${u}`)});const s=e.path[e.path.length-1],i=s.instanceId==="__matrix_remaining__"&&s.fieldKey==="__matrix_remaining__"&&s.value==="__matrix_remaining__";if(!y(e.value,s.value))throw o("Matrix node value must equal its final canonical path member.",`${a}.value`);const n=r[e.path.length-1];if(n!=null&&n.temporalBucket&&!e.isSubtotal&&!i&&e.label!==void 0)throw o("Temporal Matrix nodes cannot transport display labels.",`${a}.label`);if((!(n!=null&&n.temporalBucket)||i)&&typeof e.label!="string")throw o("Non-temporal Matrix nodes require a display label.",`${a}.label`)}function K(e,t){return e.isGrandTotal&&(t!=null&&t.isGrandTotal)?"matrixGrandTotal":e.isGrandTotal?"rowGrandTotal":t!=null&&t.isGrandTotal?"columnGrandTotal":e.isSubtotal&&(t!=null&&t.isSubtotal)?"subtotalIntersection":e.isSubtotal?"rowSubtotal":t!=null&&t.isSubtotal?"columnSubtotal":"value"}function g(e,t,a){if(t.temporalBucket){if(e.label!==void 0)throw o("Temporal Matrix path members cannot transport display labels.",`${a}.label`);if(e.value!==null&&typeof e.value!="string")throw o("Temporal Matrix member values must be canonical strings or null.",`${a}.value`);const r=S.parseTemporalBucketValue(e.value,t.temporalBucket);if(!r.ok)throw o(r.error.message,`${a}.value`)}else if(typeof e.label!="string")throw o("Non-temporal Matrix path members require a display label.",`${a}.label`)}function C(e,t){const a=[...t.row.values()];if(e.layout.rowHeaderLevels.length!==a.length)throw o("Matrix row-header layout must describe every row-axis level exactly once.","layout.rowHeaderLevels");e.layout.rowHeaderLevels.forEach((s,i)=>{var n;if(s.fieldInstanceId!==((n=a[i])==null?void 0:n.instanceId))throw o("Matrix row-header layout must follow authored row-axis order.",`layout.rowHeaderLevels.${i}.fieldInstanceId`)});for(const[s,i]of e.layout.columnHeaderRows.entries())for(const[n,c]of i.cells.entries()){if(v(c.columnPath,t.column,`layout.columnHeaderRows.${s}.cells.${n}.columnPath`),c.measureInstanceId&&!e.measuresById[c.measureInstanceId])throw o("Matrix header measureInstanceId must reference a measure.",`layout.columnHeaderRows.${s}.cells.${n}.measureInstanceId`);if(c.role==="columnHeader"&&c.label!==void 0)throw o("Matrix member headers cannot transport composed display labels.",`layout.columnHeaderRows.${s}.cells.${n}.label`)}const r=new Set;for(const[s,i]of e.layout.columns.entries()){if(r.has(i.id))throw o("Matrix layout column ids must be unique.",`layout.columns.${s}.id`);if(r.add(i.id),v(i.columnPath,t.column,`layout.columns.${s}.columnPath`),i.role==="value"&&i.columnPath.length>0&&i.label!==void 0)throw o("Matrix value columns with member paths cannot transport composed display labels.",`layout.columns.${s}.label`);if(!e.measuresById[i.measureInstanceId])throw o("Matrix layout column measureInstanceId must reference a measure.",`layout.columns.${s}.measureInstanceId`);if(i.columnNodeId){const n=e.nodesById[i.columnNodeId];if((n==null?void 0:n.axis)!=="column"||!y(n.path,i.columnPath))throw o("Matrix layout column must match its referenced column node path.",`layout.columns.${s}.columnNodeId`)}else if(t.column.size>0)throw o("Matrix columns with an authored column axis require a columnNodeId.",`layout.columns.${s}.columnNodeId`)}}function v(e,t,a){const r=[...t.values()];if(e.length>r.length)throw o("Matrix layout path exceeds its authored axis depth.",a);e.forEach((s,i)=>{const n=r[i];if(!n||s.instanceId!==n.instanceId||s.fieldKey!==n.fieldKey)throw o("Matrix layout path must follow authored axis order and identity.",`${a}.${i}`);g(s,n,`${a}.${i}`)})}function O(e,t,a){if(!t.parentId)return;const r=e.nodesById[t.parentId];if(!r)throw o("Matrix parentId must reference an existing node.",`${a}.parentId`);if(r.axis!==t.axis||r.path.length!==t.path.length-1||!y(r.path,t.path.slice(0,-1)))throw o("Matrix parentId must reference the immediate same-axis path prefix.",`${a}.parentId`)}function G(e){for(const[t,a]of[["rows",e.axes.rows],["columns",e.axes.columns]]){const r=t==="rows"?"row":"column";a.levels.forEach((s,i)=>{const n=e.fieldsById[s.instanceId];if(!n||n.instanceId!==s.instanceId||n.fieldKey!==s.fieldKey||n.role!==r||!M(n.field,s.field))throw o("Matrix axis level must have one matching role-scoped field descriptor.",`axes.${t}.levels.${i}`)})}for(const[t,a]of Object.entries(e.measuresById)){if(a.instanceId!==t)throw o("Matrix measure directory key must equal measure.instanceId.",`measuresById.${t}.instanceId`);const r=e.fieldsById[t];if(!r||r.instanceId!==t||r.fieldKey!==a.fieldKey||r.role!=="measure"||!M(r.field,a.field))throw o("Matrix measure must have one matching field descriptor.",`measuresById.${t}`)}}function H(e){return e&&typeof e=="object"?e.schemaVersion:void 0}function y(e,t){return JSON.stringify(e)===JSON.stringify(t)}function M(e,t){return h(e)===h(t)}function h(e){if(Array.isArray(e))return`[${e.map(h).join(",")}]`;if(e&&typeof e=="object"){const t=e;return`{${Object.keys(t).filter(a=>t[a]!==void 0).sort().map(a=>`${JSON.stringify(a)}:${h(t[a])}`).join(",")}}`}return e===void 0?"undefined":JSON.stringify(e)}function o(e,t){return new w({code:"invalid_matrix_result_contract",message:e,path:t})}exports.MatrixResultContractError=w;exports.parseCanonicalMatrixResult=R;
@@ -1,4 +1,4 @@
1
- "use strict";var k=Object.defineProperty;var G=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A=(e,t,n)=>G(e,typeof t!="symbol"?t+"":t,n);const c=require("./format-types-PSZZ7hG8.cjs"),M=require("./pivot-result-lifecycle-DTLRuDEW.cjs"),B=require("./index-F25jnH0p.cjs"),j=require("./temporal-bucket-DHY1y9lq.cjs");function y(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getTime()-o.getTime();return r<0?-1:r>0?1:r}function X(e){return c.constructFrom(e,Date.now())}function H(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getFullYear()-o.getFullYear(),a=n.getMonth()-o.getMonth();return r*12+a}function Y(e){return t=>{const o=(e?Math[e]:Math.trunc)(t);return o===0?0:o}}function q(e,t){return+c.toDate(e)-+c.toDate(t)}function W(e){const t=c.toDate(e);return t.setHours(23,59,59,999),t}function K(e){const t=c.toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function J(e){const t=c.toDate(e);return+W(t)==+K(t)}function Q(e,t){const n=c.toDate(e),o=c.toDate(t),r=y(n,o),a=Math.abs(H(n,o));let i;if(a<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let s=y(n,o)===-r;J(c.toDate(e))&&a===1&&y(e,o)===1&&(s=!1),i=r*(a-Number(s))}return i===0?0:i}function z(e,t,n){const o=q(e,t)/1e3;return Y(n==null?void 0:n.roundingMethod)(o)}function ee(e,t,n){const o=c.getDefaultOptions(),r=(n==null?void 0:n.locale)??o.locale??c.enUS,a=2520,i=y(e,t);if(isNaN(i))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:i});let l,u;i>0?(l=c.toDate(t),u=c.toDate(e)):(l=c.toDate(e),u=c.toDate(t));const g=z(u,l),m=(c.getTimezoneOffsetInMilliseconds(u)-c.getTimezoneOffsetInMilliseconds(l))/1e3,f=Math.round((g-m)/60);let h;if(f<2)return n!=null&&n.includeSeconds?g<5?r.formatDistance("lessThanXSeconds",5,s):g<10?r.formatDistance("lessThanXSeconds",10,s):g<20?r.formatDistance("lessThanXSeconds",20,s):g<40?r.formatDistance("halfAMinute",0,s):g<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):f===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",f,s);if(f<45)return r.formatDistance("xMinutes",f,s);if(f<90)return r.formatDistance("aboutXHours",1,s);if(f<c.minutesInDay){const d=Math.round(f/60);return r.formatDistance("aboutXHours",d,s)}else{if(f<a)return r.formatDistance("xDays",1,s);if(f<c.minutesInMonth){const d=Math.round(f/c.minutesInDay);return r.formatDistance("xDays",d,s)}else if(f<c.minutesInMonth*2)return h=Math.round(f/c.minutesInMonth),r.formatDistance("aboutXMonths",h,s)}if(h=Q(u,l),h<12){const d=Math.round(f/c.minutesInMonth);return r.formatDistance("xMonths",d,s)}else{const d=h%12,w=Math.trunc(h/12);return d<3?r.formatDistance("aboutXYears",w,s):d<9?r.formatDistance("overXYears",w,s):r.formatDistance("almostXYears",w+1,s)}}function C(e,t){return ee(e,X(e),t)}const I=["day","hour","minute","second","millisecond"],L={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},te={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},ne={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function re(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function V(e,t){return re(e)?e:t}function S(e,t){return I.indexOf(V(e,t))}function oe(e,t){const n=S(e,"day"),o=S(t,"second"),r=Math.min(n,o),a=Math.max(n,o);return I.slice(r,a+1)}function ae(e,t){return e*L[V(t,"second")]}function se(e,t){const n=oe(t.largestUnit,t.smallestUnit),o=n[n.length-1],r=L[o];let a=Math.round(e/r)*r;return n.map(i=>{const s=L[i],l=Math.floor(a/s);return a-=l*s,{unit:i,value:l}})}function ie(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>`${a.value}${te[a.unit]}`).join(" ")}function le(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>{const[i,s]=ne[a.unit];return`${a.value} ${a.value===1?i:s}`}).join(" ")}function ce(e){const t=e.some(l=>l.unit==="day"&&l.value!==0),n=e.some(l=>l.unit==="millisecond"),o=e.findIndex(l=>l.value!==0),r=Math.max(0,e.length-2),a=t?0:o===-1?r:Math.min(o,r),i=o===-1?e.slice(r):e.slice(a);if(i.length===0)return"0";const s=i.map((l,u)=>l.unit==="millisecond"?String(l.value).padStart(3,"0"):u===0?String(l.value):String(l.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s}function ue(e,t,n){const o=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${o})`:`-${o}`:o}function E(e,t={}){if(e==null)return"";const n=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):NaN;if(!Number.isFinite(n))return"";const o=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",a=n<0,i=Math.abs(ae(n,o)),s=se(i,t),l=r==="digital"?ce(s):r==="long"?le(s,t.maxUnits):ie(s,t.maxUnits);return ue(l,a,t)}function fe(e,t,n){const o={...t,locale:t.locale??n};if(o.type==="number")return M.formatNumericCanonical(e,o);const{prefix:r,suffix:a,...i}=o;return`${r??""}${M.formatNumericCanonical(e,{...i,negativeStyle:o.type==="currency"?o.negativeStyle:"minus"})}${a??""}`}function p(e,t,n){return e===null?{value:e,text:null}:!t||!c.isNumericCanonicalFormat(t)&&t.type!=="duration"?{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n})}:t.type==="duration"?{value:e,text:E(e,{inputUnit:t.inputUnit,outputStyle:t.outputStyle,largestUnit:t.largestUnit,smallestUnit:t.smallestUnit,maxUnits:t.maxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeStyle==="parentheses"})}:{value:e,text:fe(e,t,n)}}function v(e,t,n,o){return e===null?{value:e,text:null}:o==="percent"?{value:e,text:M.formatNumericCanonical(e,{type:"percent",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,percentValueMode:"fraction"})}:{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,suffix:"×"})}}function N(e,t){if(e===void 0)return t;if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("Comparison precision must be an integer from 0 to 6.");return e}function me(e,t){const n={mode:t.displayMode,current:p(e.currentValue,t.metricFormat,t.locale),comparison:p(e.comparisonValue,t.metricFormat,t.locale)};return(t.displayMode==="difference"||t.displayMode==="both")&&(n.difference=p(e.delta,t.metricFormat,t.locale)),(t.displayMode==="percent_change"||t.displayMode==="both")&&(n.percentChange=v(e.percentChange,N(t.precision,1),t.locale,"percent")),t.displayMode==="ratio"&&(n.ratio=v(e.ratio,N(t.precision,2),t.locale,"ratio")),n}function ge(e,t){return e&&e!=="auto"?e:t}function de(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(a=>a.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function he(e){try{const t={timeZone:e,timeZoneName:"long"},o=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(o==null?void 0:o.value)||e}catch{return e}}function T(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),o=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||o||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||o){const a=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(a)}return new Date(e)}else return t==="UTC"?n?new Date(e):o?new Date(e):new Date(e+"Z"):n||o||r?new Date(e):B.fromZonedTime(e,t)}const Me="MM/dd/yyyy",ye=(e,t,n,o="auto")=>{if(!e)return"";try{const r=T(e,o);if(isNaN(r.getTime()))return e;const i=(t&&t.trim()?t:Me).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?c.formatInTimeZone(r,n,i):c.format(r,i)}catch(r){return console.error("Date formatting error:",r),e}},De=(e,t="auto")=>{if(!e)return"";try{const n=T(e,t);return isNaN(n.getTime())?e:C(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function R(e,t=","){if(e==null)return"";const n=String(e);return n.includes(t)||n.includes('"')||n.includes(`
1
+ "use strict";var k=Object.defineProperty;var G=(e,t,n)=>t in e?k(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var A=(e,t,n)=>G(e,typeof t!="symbol"?t+"":t,n);const c=require("./format-types-PSZZ7hG8.cjs"),M=require("./pivot-result-lifecycle-BXzIlQVu.cjs"),B=require("./index-F25jnH0p.cjs"),j=require("./temporal-bucket-pMfghsLX.cjs");function y(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getTime()-o.getTime();return r<0?-1:r>0?1:r}function X(e){return c.constructFrom(e,Date.now())}function H(e,t){const n=c.toDate(e),o=c.toDate(t),r=n.getFullYear()-o.getFullYear(),a=n.getMonth()-o.getMonth();return r*12+a}function Y(e){return t=>{const o=(e?Math[e]:Math.trunc)(t);return o===0?0:o}}function q(e,t){return+c.toDate(e)-+c.toDate(t)}function W(e){const t=c.toDate(e);return t.setHours(23,59,59,999),t}function K(e){const t=c.toDate(e),n=t.getMonth();return t.setFullYear(t.getFullYear(),n+1,0),t.setHours(23,59,59,999),t}function J(e){const t=c.toDate(e);return+W(t)==+K(t)}function Q(e,t){const n=c.toDate(e),o=c.toDate(t),r=y(n,o),a=Math.abs(H(n,o));let i;if(a<1)i=0;else{n.getMonth()===1&&n.getDate()>27&&n.setDate(30),n.setMonth(n.getMonth()-r*a);let s=y(n,o)===-r;J(c.toDate(e))&&a===1&&y(e,o)===1&&(s=!1),i=r*(a-Number(s))}return i===0?0:i}function z(e,t,n){const o=q(e,t)/1e3;return Y(n==null?void 0:n.roundingMethod)(o)}function ee(e,t,n){const o=c.getDefaultOptions(),r=(n==null?void 0:n.locale)??o.locale??c.enUS,a=2520,i=y(e,t);if(isNaN(i))throw new RangeError("Invalid time value");const s=Object.assign({},n,{addSuffix:n==null?void 0:n.addSuffix,comparison:i});let l,u;i>0?(l=c.toDate(t),u=c.toDate(e)):(l=c.toDate(e),u=c.toDate(t));const g=z(u,l),m=(c.getTimezoneOffsetInMilliseconds(u)-c.getTimezoneOffsetInMilliseconds(l))/1e3,f=Math.round((g-m)/60);let h;if(f<2)return n!=null&&n.includeSeconds?g<5?r.formatDistance("lessThanXSeconds",5,s):g<10?r.formatDistance("lessThanXSeconds",10,s):g<20?r.formatDistance("lessThanXSeconds",20,s):g<40?r.formatDistance("halfAMinute",0,s):g<60?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",1,s):f===0?r.formatDistance("lessThanXMinutes",1,s):r.formatDistance("xMinutes",f,s);if(f<45)return r.formatDistance("xMinutes",f,s);if(f<90)return r.formatDistance("aboutXHours",1,s);if(f<c.minutesInDay){const d=Math.round(f/60);return r.formatDistance("aboutXHours",d,s)}else{if(f<a)return r.formatDistance("xDays",1,s);if(f<c.minutesInMonth){const d=Math.round(f/c.minutesInDay);return r.formatDistance("xDays",d,s)}else if(f<c.minutesInMonth*2)return h=Math.round(f/c.minutesInMonth),r.formatDistance("aboutXMonths",h,s)}if(h=Q(u,l),h<12){const d=Math.round(f/c.minutesInMonth);return r.formatDistance("xMonths",d,s)}else{const d=h%12,w=Math.trunc(h/12);return d<3?r.formatDistance("aboutXYears",w,s):d<9?r.formatDistance("overXYears",w,s):r.formatDistance("almostXYears",w+1,s)}}function C(e,t){return ee(e,X(e),t)}const I=["day","hour","minute","second","millisecond"],L={day:864e5,hour:36e5,minute:6e4,second:1e3,millisecond:1},te={day:"d",hour:"hr",minute:"min",second:"s",millisecond:"ms"},ne={day:["day","days"],hour:["hour","hours"],minute:["minute","minutes"],second:["second","seconds"],millisecond:["millisecond","milliseconds"]};function re(e){return e==="day"||e==="hour"||e==="minute"||e==="second"||e==="millisecond"}function V(e,t){return re(e)?e:t}function S(e,t){return I.indexOf(V(e,t))}function oe(e,t){const n=S(e,"day"),o=S(t,"second"),r=Math.min(n,o),a=Math.max(n,o);return I.slice(r,a+1)}function ae(e,t){return e*L[V(t,"second")]}function se(e,t){const n=oe(t.largestUnit,t.smallestUnit),o=n[n.length-1],r=L[o];let a=Math.round(e/r)*r;return n.map(i=>{const s=L[i],l=Math.floor(a/s);return a-=l*s,{unit:i,value:l}})}function ie(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>`${a.value}${te[a.unit]}`).join(" ")}function le(e,t){const n=e.filter(a=>a.value!==0),o=n.length>0?n:[e[e.length-1]],r=typeof t=="number"&&Number.isFinite(t)?Math.max(1,Math.trunc(t)):o.length;return o.slice(0,r).map(a=>{const[i,s]=ne[a.unit];return`${a.value} ${a.value===1?i:s}`}).join(" ")}function ce(e){const t=e.some(l=>l.unit==="day"&&l.value!==0),n=e.some(l=>l.unit==="millisecond"),o=e.findIndex(l=>l.value!==0),r=Math.max(0,e.length-2),a=t?0:o===-1?r:Math.min(o,r),i=o===-1?e.slice(r):e.slice(a);if(i.length===0)return"0";const s=i.map((l,u)=>l.unit==="millisecond"?String(l.value).padStart(3,"0"):u===0?String(l.value):String(l.value).padStart(2,"0")).join(":");return n?s.replace(/:(\d{3})$/,".$1"):s}function ue(e,t,n){const o=`${n.prefix||""}${e}${n.suffix||""}`;return t?n.negativeInParentheses?`(${o})`:`-${o}`:o}function E(e,t={}){if(e==null)return"";const n=typeof e=="number"?e:typeof e=="string"&&e.trim()?Number(e):NaN;if(!Number.isFinite(n))return"";const o=t.inputUnit||"second",r=t.outputStyle==="digital"||t.outputStyle==="long"?t.outputStyle:"compact",a=n<0,i=Math.abs(ae(n,o)),s=se(i,t),l=r==="digital"?ce(s):r==="long"?le(s,t.maxUnits):ie(s,t.maxUnits);return ue(l,a,t)}function fe(e,t,n){const o={...t,locale:t.locale??n};if(o.type==="number")return M.formatNumericCanonical(e,o);const{prefix:r,suffix:a,...i}=o;return`${r??""}${M.formatNumericCanonical(e,{...i,negativeStyle:o.type==="currency"?o.negativeStyle:"minus"})}${a??""}`}function p(e,t,n){return e===null?{value:e,text:null}:!t||!c.isNumericCanonicalFormat(t)&&t.type!=="duration"?{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n})}:t.type==="duration"?{value:e,text:E(e,{inputUnit:t.inputUnit,outputStyle:t.outputStyle,largestUnit:t.largestUnit,smallestUnit:t.smallestUnit,maxUnits:t.maxUnits,prefix:t.prefix,suffix:t.suffix,negativeInParentheses:t.negativeStyle==="parentheses"})}:{value:e,text:fe(e,t,n)}}function v(e,t,n,o){return e===null?{value:e,text:null}:o==="percent"?{value:e,text:M.formatNumericCanonical(e,{type:"percent",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,percentValueMode:"fraction"})}:{value:e,text:M.formatNumericCanonical(e,{type:"number",locale:n,minimumFractionDigits:t,maximumFractionDigits:t,suffix:"×"})}}function N(e,t){if(e===void 0)return t;if(!Number.isInteger(e)||e<0||e>6)throw new RangeError("Comparison precision must be an integer from 0 to 6.");return e}function me(e,t){const n={mode:t.displayMode,current:p(e.currentValue,t.metricFormat,t.locale),comparison:p(e.comparisonValue,t.metricFormat,t.locale)};return(t.displayMode==="difference"||t.displayMode==="both")&&(n.difference=p(e.delta,t.metricFormat,t.locale)),(t.displayMode==="percent_change"||t.displayMode==="both")&&(n.percentChange=v(e.percentChange,N(t.precision,1),t.locale,"percent")),t.displayMode==="ratio"&&(n.ratio=v(e.ratio,N(t.precision,2),t.locale,"ratio")),n}function ge(e,t){return e&&e!=="auto"?e:t}function de(e,t=new Date){try{const n={timeZone:e,timeZoneName:"short"},r=new Intl.DateTimeFormat("en-US",n).formatToParts(t).find(a=>a.type==="timeZoneName");return(r==null?void 0:r.value)||e}catch{return e}}function he(e){try{const t={timeZone:e,timeZoneName:"long"},o=new Intl.DateTimeFormat("en-US",t).formatToParts(new Date).find(r=>r.type==="timeZoneName");return(o==null?void 0:o.value)||e}catch{return e}}function T(e,t="auto"){if(!e)return new Date(NaN);const n=e.endsWith("Z"),o=/[+-]\d{2}:?\d{2}$/.test(e),r=/\([A-Z]{3,4}\)$/.test(e);if(t==="auto")return n||o||r?new Date(e):new Date(e+"Z");if(t==="local"){if(n||o){const a=e.replace(/Z$/,"").replace(/[+-]\d{2}:?\d{2}$/,"");return new Date(a)}return new Date(e)}else return t==="UTC"?n?new Date(e):o?new Date(e):new Date(e+"Z"):n||o||r?new Date(e):B.fromZonedTime(e,t)}const Me="MM/dd/yyyy",ye=(e,t,n,o="auto")=>{if(!e)return"";try{const r=T(e,o);if(isNaN(r.getTime()))return e;const i=(t&&t.trim()?t:Me).replace(/LLLL/g,"MMMM").replace(/LLL/g,"MMM");return n&&n!=="auto"?c.formatInTimeZone(r,n,i):c.format(r,i)}catch(r){return console.error("Date formatting error:",r),e}},De=(e,t="auto")=>{if(!e)return"";try{const n=T(e,t);return isNaN(n.getTime())?e:C(n,{addSuffix:!0})}catch(n){return console.error("Relative time formatting error:",n),e}};function R(e,t=","){if(e==null)return"";const n=String(e);return n.includes(t)||n.includes('"')||n.includes(`
2
2
  `)||n.includes("\r")?`"${n.replace(/"/g,'""')}"`:n}function $(e,t=","){return e.map(n=>R(n,t)).join(t)}function _(e,t={}){const{delimiter:n=",",lineEnding:o=`
3
3
  `}=t;return e.map(r=>$(r,n)).join(o)}function be(e,t={}){if(e.length===0)return"";const{delimiter:n=",",lineEnding:o=`
4
4
  `,includeHeaders:r=!0,columns:a}=t,i=a||Object.keys(e[0]),s=[];r&&s.push(i);for(const l of e){const u=i.map(g=>{const m=l[g];return m==null?"":String(m)});s.push(u)}return _(s,{delimiter:n,lineEnding:o})}const F="__TOTAL__";function D(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}function b(e){return e===F}function we(e){const t=new Map,n=(e.groupByColumns??[]).map((r,a)=>{var u,g,m;if(!D(r))throw new Error(`Aggregate groupByColumns[${a}] is invalid`);const i=typeof r.id=="string"&&r.id.length>0?r.id:void 0,s=i?(m=(g=(u=e.columnKeyMap)==null?void 0:u.byRole)==null?void 0:g.groupby)==null?void 0:m[i]:void 0,l=(s==null?void 0:s.outputKey)||(s==null?void 0:s.rawKey)||(typeof r.alias=="string"&&r.alias.length>0?r.alias:typeof r.name=="string"&&r.name.length>0?r.name:void 0);if(!l)throw new Error(`Aggregate groupByColumns[${a}] has no output key`);return[i,r.alias,r.name,l].forEach(f=>{typeof f=="string"&&f.length>0&&t.set(f,l)}),l}),o=(e.rowAggregates??[]).flatMap(r=>!D(r)||typeof r.function!="string"||typeof r.groupLevel!="string"?[]:[{function:r.function,groupLevel:r.groupLevel==="ALL"?"ALL":t.get(r.groupLevel)||r.groupLevel,...typeof r.label=="string"?{label:r.label}:{}}]);return{groupColumnKeys:n,rowAggregates:o}}function P(e){return e==="SUM"?"Total":e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}function U(e){var n;if(e.customLabel)return e.customLabel;const t=P(e.aggregateFunction);if(e.levelValue!==void 0&&!b(e.levelValue)){if(e.levelValue===null){const r=(n=e.formatValue)==null?void 0:n.call(e,null);return r?`Subtotal ${r}`:`Subtotal ${t}`}const o=e.formatValue?e.formatValue(e.levelValue):String(e.levelValue);if(o)return`Subtotal (${o})`}return`Subtotal ${t}`}function O(e,t){return t||`Grand ${P(e)}`}function x(e){var o,r;const t=e.context.groupColumnKeys,n=typeof e.row.aggregate=="string"?e.row.aggregate:"SUM";if(e.row.isGrandTotal===!0){const a=(o=e.context.rowAggregates.find(i=>i.groupLevel==="ALL"))==null?void 0:o.label;return{kind:"grand-total",cells:t.map((i,s)=>({columnKey:i,text:s===0?O(n,a):"",placement:s===0?"label":"empty",colSpan:s===0?t.length:1}))}}if(e.row.isSubtotal===!0){if(typeof e.row.subtotalLevel!="string")throw new Error("Aggregate subtotal row is missing subtotalLevel");const a=t.indexOf(e.row.subtotalLevel);if(a<0)throw new Error(`Aggregate subtotal level "${e.row.subtotalLevel}" has no group column`);const i=D(e.row.subtotalContext)?e.row.subtotalContext:void 0,s=D(i==null?void 0:i.groupByValues)?i.groupByValues:{},l=(r=e.context.rowAggregates.find(u=>u.groupLevel===e.row.subtotalLevel&&u.function===n))==null?void 0:r.label;return{kind:"subtotal",cells:t.map((u,g)=>{if(g>a)return{columnKey:u,text:"",placement:"empty",colSpan:1};if(g<a){const m=e.row[u];return{columnKey:u,text:m===void 0||b(m)?"":e.formatValue(m,u),placement:"value",colSpan:1}}return{columnKey:u,text:U({aggregateFunction:n,customLabel:l,levelValue:s[u],formatValue:m=>e.formatLabelValue?e.formatLabelValue(m,u):String(e.formatValue(m,u)??"")}),placement:"label",colSpan:t.length-a}})}}return{kind:"data",cells:t.map(a=>{const i=e.row[a];return{columnKey:a,text:i===void 0||b(i)?"":e.formatValue(i,a),placement:"value",colSpan:1}})}}function pe(e){const t=x(e).cells.find(n=>n.columnKey===e.columnKey);if(!t)throw new Error(`Aggregate group column "${e.columnKey}" is unknown`);return t.text}function Le(e){return x(e).cells.map(t=>t.text)}class Z extends Error{constructor(n,o){super(`${n}: ${o}`);A(this,"deliveryBlocking",!0);this.code=n,this.name="PivotHeaderPresentationError"}}function Te(e){var r;const t=e.mode??"formatted",n=e.members.map(a=>{var s;if(t==="canonical"||!a.temporalBucket)return a.value===null?"":String(a.value);const i=(s=e.resolveTemporalFormat)==null?void 0:s.call(e,a.fieldId);if(!i)throw new Z("missing_resolved_temporal_format",`Missing resolved temporal presentation for pivot field "${a.fieldId}"`);return j.formatTemporalBucket({value:a.value,metadata:a.temporalBucket,format:i})}),o=((r=e.metricLabel)==null?void 0:r.trim())||void 0;return{memberLabels:n,...o?{metricLabel:o}:{},flattenedLabel:[...n,...o?[o]:[]].join(" / ")}}exports.AGGREGATE_TOTAL_MEMBER_MARKER=F;exports.PivotHeaderPresentationError=Z;exports.arrayToCSV=_;exports.arrayToCSVRow=$;exports.escapeCSVValue=R;exports.formatAggregateGrandTotalLabel=O;exports.formatAggregateGroupCell=pe;exports.formatAggregateGroupRow=Le;exports.formatAggregateSubtotalLabel=U;exports.formatDate=ye;exports.formatDistanceToNow=C;exports.formatDuration=E;exports.formatMetricComparison=me;exports.formatRelativeTime=De;exports.getTimezoneAbbreviation=de;exports.getTimezoneName=he;exports.isAggregateTotalMemberMarker=b;exports.objectsToCSV=be;exports.parseWithSourceTimezone=T;exports.presentAggregateGroupRow=x;exports.presentPivotHeader=Te;exports.resolveAggregateTablePresentationContext=we;exports.resolveTimezone=ge;
@@ -2,9 +2,9 @@ var U = Object.defineProperty;
2
2
  var E = (e, t, n) => t in e ? U(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
3
  var A = (e, t, n) => E(e, typeof t != "symbol" ? t + "" : t, n);
4
4
  import { t as f, c as P, g as R, e as O, a as T, m as S, b as M, i as Z, f as k, d as B } from "./format-types-CFHQoIuk.js";
5
- import { b as y } from "./pivot-result-lifecycle-CHWEGU2o.js";
5
+ import { b as y } from "./pivot-result-lifecycle-g2U-vzQb.js";
6
6
  import { f as j } from "./index-CACdoqu3.js";
7
- import { f as X } from "./temporal-bucket-5UYEotyQ.js";
7
+ import { h as X } from "./temporal-bucket-C85rmFmC.js";
8
8
  function b(e, t) {
9
9
  const n = f(e), o = f(t), r = n.getTime() - o.getTime();
10
10
  return r < 0 ? -1 : r > 0 ? 1 : r;
@@ -1 +1 @@
1
- "use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-D2-93DGr.cjs");function y(t){return!!(t!=null&&t.isSubtotal&&t.subtotalScope==="pivot-value")}function c(t){var e;return t.expectedPivotFieldIds.length===0?!0:!!((e=t.classification)!=null&&e.isSubtotal&&t.classification.subtotalScope==="grand-total")}class u extends Error{constructor(r){super(`missing_pivot_member_identity: ${r}`);n(this,"deliveryBlocking",!0);n(this,"code","missing_pivot_member_identity");this.name="PivotResultIdentityError"}}function d(t){const{identity:e,columnKey:r,expectedPivotFieldIds:i,allowPrefix:l=!1}=t,s=t.allowEmpty??((i==null?void 0:i.length)||0)===0;if(!e||typeof e!="object"||Array.isArray(e)||typeof e.metricId!="string"||!e.metricId||typeof e.metricAlias!="string"||!e.metricAlias||!Array.isArray(e.members))throw new u(`Physical pivot column "${r}" is missing stable metric or member identity.`);if(e.members.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o)||typeof o.fieldId!="string"||!o.fieldId||o.value!==null&&typeof o.value!="string"||o.temporalBucket!==void 0&&!f.validateTemporalBucketMetadata(o.temporalBucket).ok)throw new u(`Physical pivot column "${r}" has invalid identity for member ${a}.`);if(i&&o.fieldId!==i[a])throw new u(`Physical pivot column "${r}" has member "${o.fieldId}" at tuple position ${a}; expected "${i[a]||"no member"}".`)}),e.members.length===0){if(s)return e.members;throw new u(`Physical pivot column "${r}" is missing its required pivot tuple.`)}if(i&&(!l&&e.members.length!==i.length||e.members.length>i.length))throw new u(`Physical pivot column "${r}" has ${e.members.length} members; expected ${l?"at most ":""}${i.length}.`);return e.members}function p(t,e){t.forEach(r=>{var l,s,o;if(r.pivotIdentity===void 0)return;const i=(l=e.columnClassifications)==null?void 0:l[r.key];d({identity:r.pivotIdentity,columnKey:r.key,expectedPivotFieldIds:e.expectedPivotFieldIds,allowPrefix:((s=e.allowPrefixForColumn)==null?void 0:s.call(e,r))??y(i),allowEmpty:((o=e.allowEmptyForColumn)==null?void 0:o.call(e,r))??c({expectedPivotFieldIds:e.expectedPivotFieldIds,classification:i})})})}function h(t,e,r){var l;const i=t==null?void 0:t.byRole;if(!(!i||typeof i!="object"||Array.isArray(i)))return(l=i[r])==null?void 0:l[e]}function P(t,e){if(!t)return;const r=t.byRole;if(!r||typeof r!="object"||Array.isArray(r))return;const i=Object.values(r).flatMap(s=>{const o=s==null?void 0:s[e];return o?[o]:[]});if(i.length!==1)return;const[l]=i;if(!(l.role==="metric"&&Object.values(t.byMetricAlias??{}).some(s=>s.role===l.role&&s.rawKey===l.rawKey&&s.outputKey===l.outputKey)))return l}exports.PivotResultIdentityError=u;exports.isPivotEmptyTupleAllowed=c;exports.isPivotSubtotalPrefix=y;exports.requirePivotHeaderMembers=d;exports.requirePivotResultColumnIdentities=p;exports.resolveQueryColumnKeyMapEntry=h;exports.resolveUniqueQueryColumnKeyMapEntry=P;
1
+ "use strict";var v=Object.defineProperty;var m=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var n=(t,e,r)=>m(t,typeof e!="symbol"?e+"":e,r);const f=require("./temporal-bucket-contract-xFkvboaw.cjs");function y(t){return!!(t!=null&&t.isSubtotal&&t.subtotalScope==="pivot-value")}function c(t){var e;return t.expectedPivotFieldIds.length===0?!0:!!((e=t.classification)!=null&&e.isSubtotal&&t.classification.subtotalScope==="grand-total")}class u extends Error{constructor(r){super(`missing_pivot_member_identity: ${r}`);n(this,"deliveryBlocking",!0);n(this,"code","missing_pivot_member_identity");this.name="PivotResultIdentityError"}}function d(t){const{identity:e,columnKey:r,expectedPivotFieldIds:i,allowPrefix:l=!1}=t,s=t.allowEmpty??((i==null?void 0:i.length)||0)===0;if(!e||typeof e!="object"||Array.isArray(e)||typeof e.metricId!="string"||!e.metricId||typeof e.metricAlias!="string"||!e.metricAlias||!Array.isArray(e.members))throw new u(`Physical pivot column "${r}" is missing stable metric or member identity.`);if(e.members.forEach((o,a)=>{if(!o||typeof o!="object"||Array.isArray(o)||typeof o.fieldId!="string"||!o.fieldId||o.value!==null&&typeof o.value!="string"||o.temporalBucket!==void 0&&!f.validateTemporalBucketMetadata(o.temporalBucket).ok)throw new u(`Physical pivot column "${r}" has invalid identity for member ${a}.`);if(i&&o.fieldId!==i[a])throw new u(`Physical pivot column "${r}" has member "${o.fieldId}" at tuple position ${a}; expected "${i[a]||"no member"}".`)}),e.members.length===0){if(s)return e.members;throw new u(`Physical pivot column "${r}" is missing its required pivot tuple.`)}if(i&&(!l&&e.members.length!==i.length||e.members.length>i.length))throw new u(`Physical pivot column "${r}" has ${e.members.length} members; expected ${l?"at most ":""}${i.length}.`);return e.members}function p(t,e){t.forEach(r=>{var l,s,o;if(r.pivotIdentity===void 0)return;const i=(l=e.columnClassifications)==null?void 0:l[r.key];d({identity:r.pivotIdentity,columnKey:r.key,expectedPivotFieldIds:e.expectedPivotFieldIds,allowPrefix:((s=e.allowPrefixForColumn)==null?void 0:s.call(e,r))??y(i),allowEmpty:((o=e.allowEmptyForColumn)==null?void 0:o.call(e,r))??c({expectedPivotFieldIds:e.expectedPivotFieldIds,classification:i})})})}function h(t,e,r){var l;const i=t==null?void 0:t.byRole;if(!(!i||typeof i!="object"||Array.isArray(i)))return(l=i[r])==null?void 0:l[e]}function P(t,e){if(!t)return;const r=t.byRole;if(!r||typeof r!="object"||Array.isArray(r))return;const i=Object.values(r).flatMap(s=>{const o=s==null?void 0:s[e];return o?[o]:[]});if(i.length!==1)return;const[l]=i;if(!(l.role==="metric"&&Object.values(t.byMetricAlias??{}).some(s=>s.role===l.role&&s.rawKey===l.rawKey&&s.outputKey===l.outputKey)))return l}exports.PivotResultIdentityError=u;exports.isPivotEmptyTupleAllowed=c;exports.isPivotSubtotalPrefix=y;exports.requirePivotHeaderMembers=d;exports.requirePivotResultColumnIdentities=p;exports.resolveQueryColumnKeyMapEntry=h;exports.resolveUniqueQueryColumnKeyMapEntry=P;
@@ -1,7 +1,7 @@
1
1
  var y = Object.defineProperty;
2
2
  var c = (t, e, r) => e in t ? y(t, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : t[e] = r;
3
3
  var u = (t, e, r) => c(t, typeof e != "symbol" ? e + "" : e, r);
4
- import { v as d } from "./temporal-bucket-contract-D5d-xEl3.js";
4
+ import { v as d } from "./temporal-bucket-contract-DXXNZssK.js";
5
5
  function f(t) {
6
6
  return !!(t != null && t.isSubtotal && t.subtotalScope === "pivot-value");
7
7
  }