react-semaphor 0.1.590 → 0.1.592

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 (87) hide show
  1. package/dist/analytics-protocol/index.js +254 -236
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/brand-studio/index.js +7 -7
  4. package/dist/briefings/index.js +4 -4
  5. package/dist/chunks/{aggregate-measure-field-BrkXsSJp.js → aggregate-measure-field-DHlDj0Pc.js} +2 -2
  6. package/dist/chunks/{assistant-chat-C_6dBLUk.js → assistant-chat-BusR-5uT.js} +13 -13
  7. package/dist/chunks/bookmark-impact-DozXJZDS.js +76 -0
  8. package/dist/chunks/{bookmark-state-Bn7k3ttp.js → bookmark-state-Be2W3s6t.js} +632 -592
  9. package/dist/chunks/{card-filter-builder-6vflbF9O.js → card-filter-builder-DBTJ74yy.js} +916 -897
  10. package/dist/chunks/{comparison-window-caption-fqijZdVd.js → comparison-window-caption-h8w3ySL6.js} +90 -91
  11. package/dist/chunks/{dashboard-DpgRl65K.js → dashboard-CmzJzmph.js} +1 -1
  12. package/dist/chunks/{dashboard-briefing-launcher-BLbhONJz.js → dashboard-briefing-launcher-BOQGpYr2.js} +160 -160
  13. package/dist/chunks/{dashboard-controls-kCTYEEsq.js → dashboard-controls-BxI3e2_o.js} +64 -64
  14. package/dist/chunks/{dashboard-json-CNIFresY.js → dashboard-json-BMqXV2Rx.js} +4 -4
  15. package/dist/chunks/{dates-BoeweqEo.js → dates-DBsscxL_.js} +8 -8
  16. package/dist/chunks/{edit-dashboard-visual-D0eWTlPL.js → edit-dashboard-visual-Dvc_Pkfg.js} +5443 -5417
  17. package/dist/chunks/filter-line-CYT7KIXb.js +133 -0
  18. package/dist/chunks/{filter-reach-copy-eMhDPTYH.js → filter-reach-copy-hEzlpBu7.js} +224 -224
  19. package/dist/chunks/filter-value-text-CHBm4IU7.js +153 -0
  20. package/dist/chunks/{index-D8LFjI8j.js → index-BoYJqc3F.js} +24 -24
  21. package/dist/chunks/{layout-grid-BG__sPkb.js → layout-grid-DoFIfQGd.js} +1 -1
  22. package/dist/chunks/{list-filter-Cb8i7N8f.js → list-filter-BeTQxjNy.js} +1 -1
  23. package/dist/chunks/{matrix-analytical-definition-D9Ll_9R-.js → matrix-analytical-definition-CyWOwLmE.js} +17 -17
  24. package/dist/chunks/{matrix-member-presentation-DVBJR0MA.js → matrix-member-presentation-Bj2YcHAP.js} +1 -1
  25. package/dist/chunks/{matrix-operation-contract-JSmproo9.js → matrix-operation-contract-CAanJeCj.js} +60 -60
  26. package/dist/chunks/{metric-comparison-xE_J6hkg.js → metric-comparison-BeKnUD08.js} +27 -31
  27. package/dist/chunks/{paintbrush-C310xSuR.js → paintbrush-KeaU1L1a.js} +1 -1
  28. package/dist/chunks/{palette-Ci5P91Zb.js → palette-BcFJLeXB.js} +1 -1
  29. package/dist/chunks/{pivot-result-contract-expectations-DbBahmgc.js → pivot-result-contract-expectations-CaS0y823.js} +522 -486
  30. package/dist/chunks/{pivot-result-identity-CUsMt_4r.js → pivot-result-identity-BKUjYO1u.js} +1 -1
  31. package/dist/chunks/raw-temporal-value-BzdgeDa7.js +454 -0
  32. package/dist/chunks/{report-preferences-dialog-dUlVLgEk.js → report-preferences-dialog-Cu_f-8Kw.js} +13 -13
  33. package/dist/chunks/{report-runtime-context-CrOgmuxO.js → report-runtime-context-g4Zp_TU9.js} +1 -1
  34. package/dist/chunks/{resolve-dashboard-input-context-NurwNg4I.js → resolve-dashboard-input-context-CkMk1RW6.js} +7600 -6398
  35. package/dist/chunks/{save-BhhXfp4s.js → save-C9CZAk6V.js} +1 -1
  36. package/dist/chunks/{saved-dashboard-context-CPp--vXU.js → saved-dashboard-context-RgBS_PIj.js} +19 -19
  37. package/dist/chunks/{selection-filter-compiler-CHG-8xnW.js → selection-filter-compiler-BclSpK3P.js} +1 -1
  38. package/dist/chunks/{semaphor-ready-indicator-CXojR95M.js → semaphor-ready-indicator-DXpTZJ7R.js} +31502 -31453
  39. package/dist/chunks/{shelf-drop-preview-context-BDScAUdq.js → shelf-drop-preview-context-qdlJKaH7.js} +5 -5
  40. package/dist/chunks/stored-dashboard-Baw6Bp2A.js +4029 -0
  41. package/dist/chunks/{style-sheet-parts-CmXmKqGw.js → style-sheet-parts-DM_Mw_sm.js} +45 -42
  42. package/dist/chunks/{table-export-sheet-ClSgERQC.js → table-export-sheet-Cd6z7SsG.js} +1 -1
  43. package/dist/chunks/{token-types-DTocOcwt.js → token-types-BB2ImFx6.js} +1 -1
  44. package/dist/chunks/{upload-DDYc1Qjj.js → upload-CMTCg47S.js} +1 -1
  45. package/dist/chunks/{validators-CrYXNnNE.js → validators-BlEWWX9O.js} +576 -562
  46. package/dist/chunks/{variable-draft-Bi3RlULA.js → variable-draft-BxtN6YcG.js} +4 -4
  47. package/dist/dashboard/index.js +2 -2
  48. package/dist/dashboard-authoring/index.js +1672 -1633
  49. package/dist/format-utils/index.js +217 -218
  50. package/dist/index.js +62 -62
  51. package/dist/report-runtime-context/index.js +1 -1
  52. package/dist/style.css +1 -1
  53. package/dist/surfboard/index.js +2 -2
  54. package/dist/types/components/surfboard/filter/types.d.ts +7 -5
  55. package/dist/types/components/visual/data-table/hooks/use-data-table-logic.d.ts +3 -3
  56. package/dist/types/components/visual/data-table/types/data-table.d.ts +24 -2
  57. package/dist/types/index.js +30 -29
  58. package/dist/types/lib/dashboard-inputs/dashboard-date-comparison-plan.d.ts +0 -1
  59. package/dist/types/lib/dashboard-viewer/table-view-edit.d.ts +27 -0
  60. package/dist/types/lib/dashboard-viewer/table-view.d.ts +37 -1
  61. package/dist/types/lib/formatters/raw-temporal-presentation.d.ts +0 -2
  62. package/dist/types/shared/analytics-protocol/agent-time-window.d.ts +1 -1
  63. package/dist/types/shared/analytics-protocol/relative-date/index.d.ts +2 -1
  64. package/dist/types/shared/analytics-protocol/relative-date/sentence.d.ts +81 -0
  65. package/dist/types/shared/analytics-protocol/relative-date/traits.d.ts +0 -9
  66. package/dist/types/shared/analytics-protocol/relative-date/window.d.ts +23 -2
  67. package/dist/types/shared/dashboard-authoring/canonical-result-keys.d.ts +20 -0
  68. package/dist/types/shared/dashboard-authoring/card-formats/detail-date-display.d.ts +84 -0
  69. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +1 -1
  70. package/dist/types/shared/dashboard-authoring/card-settings/column-names.d.ts +2 -0
  71. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +6 -0
  72. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +11 -0
  73. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +36 -36
  74. package/dist/types/shared/dashboard-authoring/filter-model/date-filter-default.d.ts +37 -0
  75. package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +1 -0
  76. package/dist/types/shared/dashboard-authoring/index.d.ts +1 -0
  77. package/dist/types/shared/dashboard-viewer/table-column-move.d.ts +56 -0
  78. package/dist/types/shared/dashboard-viewer/table-settings.d.ts +7 -0
  79. package/dist/types/shared/format-utils/filter-line.d.ts +2 -0
  80. package/package.json +1 -1
  81. package/dist/chunks/bookmark-impact-DkZABEd3.js +0 -75
  82. package/dist/chunks/filter-line-Dza3ee4w.js +0 -131
  83. package/dist/chunks/filter-value-text-DQw4v3nC.js +0 -146
  84. package/dist/chunks/pivot-header-presentation-D-DfPAjb.js +0 -42
  85. package/dist/chunks/raw-temporal-value-BnGCWJAL.js +0 -322
  86. package/dist/chunks/stored-dashboard-KkH4zOhq.js +0 -4998
  87. package/dist/types/components/visual/shared/utils/table-column-order.d.ts +0 -53
@@ -1,12 +1,12 @@
1
- import { a5 as G, f as Ve, r as Pe } from "./validators-CrYXNnNE.js";
1
+ import { a7 as Y, f as Pe, r as Le, k as qe } from "./validators-BlEWWX9O.js";
2
2
  import { z as l } from "zod";
3
- import { Q as B, F as Le, r as $e } from "./matrix-operation-contract-JSmproo9.js";
4
- import { D as qe, C as Be, a as j, r as je, e as Ue } from "./metric-comparison-xE_J6hkg.js";
3
+ import { Q as B, F as Be, r as je } from "./matrix-operation-contract-CAanJeCj.js";
4
+ import { D as Ue, C as ze, a as j, r as We, e as Qe } from "./metric-comparison-BeKnUD08.js";
5
5
  import "./analytics-base-schemas-8wz9vqn_.js";
6
- import { a as O } from "./applied-constraints-DU-wndZ7.js";
7
- import { r as ze } from "./pivot-result-identity-CUsMt_4r.js";
8
- const ne = 8, re = 6, V = Object.freeze([]);
9
- function We(e) {
6
+ import { a as N } from "./applied-constraints-DU-wndZ7.js";
7
+ import { r as Ge } from "./pivot-result-identity-BKUjYO1u.js";
8
+ const re = 8, se = 6, V = Object.freeze([]);
9
+ function Ye(e) {
10
10
  switch (e.type) {
11
11
  case "table":
12
12
  case "chart":
@@ -17,7 +17,7 @@ function We(e) {
17
17
  return V;
18
18
  }
19
19
  }
20
- function Qe(e, t) {
20
+ function Je(e, t) {
21
21
  switch (e.type) {
22
22
  case "table":
23
23
  case "chart": {
@@ -28,7 +28,7 @@ function Qe(e, t) {
28
28
  case "kpi": {
29
29
  if (!Array.isArray(e.cards)) return e;
30
30
  const n = e.cards.map(t);
31
- return n.every((r, a) => r === e.cards[a]) ? e : { ...e, cards: n };
31
+ return n.every((r, s) => r === e.cards[s]) ? e : { ...e, cards: n };
32
32
  }
33
33
  default:
34
34
  return e;
@@ -38,66 +38,66 @@ function _(e) {
38
38
  var n;
39
39
  const t = [];
40
40
  for (const r of e.sheets || []) {
41
- const a = r.id;
42
- for (const s of r.cards || [])
43
- t.push({ kind: "sheetCard", sheetId: a, cardId: s.id, card: s });
44
- for (const s of r.frames || [])
45
- for (const i of s.cards || [])
41
+ const s = r.id;
42
+ for (const a of r.cards || [])
43
+ t.push({ kind: "sheetCard", sheetId: s, cardId: a.id, card: a });
44
+ for (const a of r.frames || [])
45
+ for (const i of a.cards || [])
46
46
  t.push({
47
47
  kind: "frameCard",
48
- sheetId: a,
49
- frameId: s.id,
48
+ sheetId: s,
49
+ frameId: a.id,
50
50
  cardId: i.id,
51
51
  card: i
52
52
  });
53
- for (const s of ((n = r.document) == null ? void 0 : n.sections) || [])
54
- for (const i of We(s))
53
+ for (const a of ((n = r.document) == null ? void 0 : n.sections) || [])
54
+ for (const i of Ye(a))
55
55
  t.push({
56
56
  kind: "documentSectionCard",
57
- sheetId: a,
58
- sectionId: s.id,
57
+ sheetId: s,
58
+ sectionId: a.id,
59
59
  cardId: i.id,
60
60
  card: i
61
61
  });
62
62
  }
63
63
  return t;
64
64
  }
65
- function Zt(e, t, n) {
65
+ function nn(e, t, n) {
66
66
  let r = !1;
67
- const a = Ge(e, (i) => i.id !== n.id ? i : (r = !0, i === n ? i : n));
68
- if (r || !t) return a;
69
- const s = (a.sheets || []).map(
67
+ const s = He(e, (i) => i.id !== n.id ? i : (r = !0, i === n ? i : n));
68
+ if (r || !t) return s;
69
+ const a = (s.sheets || []).map(
70
70
  (i) => i.id === t && i.kind !== "document" ? { ...i, cards: [...i.cards ?? [], n] } : i
71
71
  );
72
- return { ...a, sheets: s };
72
+ return { ...s, sheets: a };
73
73
  }
74
- function Ge(e, t) {
75
- const n = (a, s) => {
76
- const i = a.map((o) => t(o, s(o)));
77
- return i.every((o, c) => o === a[c]) ? a : i;
78
- }, r = (e.sheets || []).map((a) => {
74
+ function He(e, t) {
75
+ const n = (s, a) => {
76
+ const i = s.map((o) => t(o, a(o)));
77
+ return i.every((o, c) => o === s[c]) ? s : i;
78
+ }, r = (e.sheets || []).map((s) => {
79
79
  var f, y, h;
80
- const s = a.id, i = a.cards && n(a.cards, (p) => ({ kind: "sheetCard", sheetId: s, cardId: p.id, card: p })), o = (f = a.frames) == null ? void 0 : f.map((p) => {
80
+ const a = s.id, i = s.cards && n(s.cards, (p) => ({ kind: "sheetCard", sheetId: a, cardId: p.id, card: p })), o = (f = s.frames) == null ? void 0 : f.map((p) => {
81
81
  if (!p.cards) return p;
82
- const I = n(p.cards, (g) => ({ kind: "frameCard", sheetId: s, frameId: p.id, cardId: g.id, card: g }));
82
+ const I = n(p.cards, (g) => ({ kind: "frameCard", sheetId: a, frameId: p.id, cardId: g.id, card: g }));
83
83
  return I === p.cards ? p : { ...p, cards: I };
84
- }), c = (h = (y = a.document) == null ? void 0 : y.sections) == null ? void 0 : h.map(
85
- (p) => Qe(p, (I) => t(I, { kind: "documentSectionCard", sheetId: s, sectionId: p.id, cardId: I.id, card: I }))
86
- ), u = !!o && o.some((p, I) => p !== a.frames[I]), d = !!c && c.some((p, I) => p !== a.document.sections[I]);
87
- return i === a.cards && !u && !d ? a : {
88
- ...a,
89
- ...i === a.cards ? {} : { cards: i },
84
+ }), c = (h = (y = s.document) == null ? void 0 : y.sections) == null ? void 0 : h.map(
85
+ (p) => Je(p, (I) => t(I, { kind: "documentSectionCard", sheetId: a, sectionId: p.id, cardId: I.id, card: I }))
86
+ ), u = !!o && o.some((p, I) => p !== s.frames[I]), d = !!c && c.some((p, I) => p !== s.document.sections[I]);
87
+ return i === s.cards && !u && !d ? s : {
88
+ ...s,
89
+ ...i === s.cards ? {} : { cards: i },
90
90
  ...u ? { frames: o } : {},
91
- ...d ? { document: { ...a.document, sections: c } } : {}
91
+ ...d ? { document: { ...s.document, sections: c } } : {}
92
92
  };
93
93
  });
94
- return r.every((a, s) => a === e.sheets[s]) ? e : { ...e, sheets: r };
94
+ return r.every((s, a) => s === e.sheets[a]) ? e : { ...e, sheets: r };
95
95
  }
96
- function P(e) {
96
+ function $(e) {
97
97
  return !!e && typeof e == "object" && !Array.isArray(e);
98
98
  }
99
- function en(e) {
100
- if (!P(e))
99
+ function rn(e) {
100
+ if (!$(e))
101
101
  return [{ path: "", message: "must be an object." }];
102
102
  const t = [];
103
103
  e.title !== void 0 && typeof e.title != "string" && t.push({ path: "title", message: "must be a string." });
@@ -105,65 +105,65 @@ function en(e) {
105
105
  if (!Array.isArray(n))
106
106
  t.push({ path: "cards", message: "must be an array of KPI cards." });
107
107
  else {
108
- (n.length < 1 || n.length > ne) && t.push({
108
+ (n.length < 1 || n.length > re) && t.push({
109
109
  path: "cards",
110
- message: `must hold 1 to ${ne} KPI cards.`
110
+ message: `must hold 1 to ${re} KPI cards.`
111
111
  });
112
- const a = /* @__PURE__ */ new Set();
113
- n.forEach((s, i) => {
114
- if (!P(s)) {
112
+ const s = /* @__PURE__ */ new Set();
113
+ n.forEach((a, i) => {
114
+ if (!$(a)) {
115
115
  t.push({ path: `cards[${i}]`, message: "must be a card." });
116
116
  return;
117
117
  }
118
- typeof s.id != "string" || !s.id ? t.push({
118
+ typeof a.id != "string" || !a.id ? t.push({
119
119
  path: `cards[${i}].id`,
120
120
  message: "must be a non-empty string."
121
- }) : a.has(s.id) ? t.push({
121
+ }) : s.has(a.id) ? t.push({
122
122
  path: `cards[${i}].id`,
123
- message: `duplicates card id '${s.id}'.`
124
- }) : a.add(s.id), s.type !== "kpi" && t.push({ path: `cards[${i}].type`, message: "must be 'kpi'." });
123
+ message: `duplicates card id '${a.id}'.`
124
+ }) : s.add(a.id), a.type !== "kpi" && t.push({ path: `cards[${i}].type`, message: "must be 'kpi'." });
125
125
  });
126
126
  }
127
127
  const r = e.kpi;
128
- return P(r) ? (r.layout !== "tiles" && r.layout !== "lines" ? t.push({
128
+ return $(r) ? (r.layout !== "tiles" && r.layout !== "lines" ? t.push({
129
129
  path: "kpi.layout",
130
130
  message: "must be 'tiles' or 'lines'."
131
- }) : r.layout === "tiles" && Array.isArray(n) && n.length > re && t.push({
131
+ }) : r.layout === "tiles" && Array.isArray(n) && n.length > se && t.push({
132
132
  path: "kpi.layout",
133
- message: `must be 'lines' for more than ${re} KPI cards.`
133
+ message: `must be 'lines' for more than ${se} KPI cards.`
134
134
  }), r.columns !== void 0 && r.columns !== 1 && r.columns !== 2 && t.push({ path: "kpi.columns", message: "must be 1 or 2." })) : t.push({ path: "kpi", message: "must be an object." }), t;
135
135
  }
136
136
  const Ie = "dashboardInput";
137
- function se(e) {
137
+ function ae(e) {
138
138
  return e === "label" || e === "value" || e === "start" || e === "end" || e === "range";
139
139
  }
140
- function Ye(e) {
140
+ function Xe(e) {
141
141
  return e === "generatedAt" || e === "pageNumber" || e === "pageCount";
142
142
  }
143
143
  function v(e) {
144
144
  if (!e || typeof e != "object" || Array.isArray(e)) return;
145
145
  const t = e;
146
146
  if (t.source === "input" || t.source === Ie)
147
- return typeof t.inputId == "string" && se(t.export) ? { source: "input", inputId: t.inputId, export: t.export } : void 0;
147
+ return typeof t.inputId == "string" && ae(t.export) ? { source: "input", inputId: t.inputId, export: t.export } : void 0;
148
148
  if (t.source === "dashboardInputAlias")
149
- return typeof t.variableName != "string" || t.export !== void 0 && !se(t.export) ? void 0 : {
149
+ return typeof t.variableName != "string" || t.export !== void 0 && !ae(t.export) ? void 0 : {
150
150
  source: "dashboardInputAlias",
151
151
  variableName: t.variableName,
152
152
  ...t.export ? { export: t.export } : {}
153
153
  };
154
154
  if (t.source === "documentMeta")
155
- return Ye(t.key) ? { source: "documentMeta", key: t.key } : void 0;
155
+ return Xe(t.key) ? { source: "documentMeta", key: t.key } : void 0;
156
156
  if (t.source === "data")
157
157
  return typeof t.variableId == "string" && typeof t.export == "string" ? { source: "data", variableId: t.variableId, export: t.export } : void 0;
158
158
  }
159
- function tn(e, t) {
159
+ function sn(e, t) {
160
160
  const n = v(e), r = v(t);
161
- return !n || !r ? JSON.stringify(e) === JSON.stringify(t) : [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(r)])].every((s) => n[s] === r[s]);
161
+ return !n || !r ? JSON.stringify(e) === JSON.stringify(t) : [.../* @__PURE__ */ new Set([...Object.keys(n), ...Object.keys(r)])].every((a) => n[a] === r[a]);
162
162
  }
163
- function Je(e) {
163
+ function Ze(e) {
164
164
  return x(e) ? e.type === "variable" ? e.ref === void 0 ? [] : [e.ref] : e.type === "when" && x(e.test) && e.test.ref !== void 0 ? [e.test.ref] : [] : [];
165
165
  }
166
- function He(e, t) {
166
+ function et(e, t) {
167
167
  if (!x(e)) return e;
168
168
  if (e.type === "variable" && e.ref !== void 0) {
169
169
  const n = t(e.ref);
@@ -178,81 +178,81 @@ function He(e, t) {
178
178
  function x(e) {
179
179
  return !!e && typeof e == "object" && !Array.isArray(e);
180
180
  }
181
- function ae(e) {
181
+ function ie(e) {
182
182
  return !!e && typeof e == "object" && e.source === Ie;
183
183
  }
184
- function nn(e) {
184
+ function an(e) {
185
185
  return U(e);
186
186
  }
187
187
  function U(e) {
188
188
  if (!e || typeof e != "object") return e;
189
189
  if (Array.isArray(e)) {
190
- let s = !1;
190
+ let a = !1;
191
191
  const i = e.map((o) => {
192
192
  const c = U(o);
193
- return c !== o && (s = !0), c;
193
+ return c !== o && (a = !0), c;
194
194
  });
195
- return s ? i : e;
195
+ return a ? i : e;
196
196
  }
197
197
  const t = e;
198
198
  let n;
199
- const r = (s, i) => {
200
- i !== t[s] && (n ?? (n = { ...t }), n[s] = i);
201
- }, a = He(
199
+ const r = (a, i) => {
200
+ i !== t[a] && (n ?? (n = { ...t }), n[a] = i);
201
+ }, s = et(
202
202
  t,
203
- (s) => ae(s) ? v(s) ?? s : s
203
+ (a) => ie(a) ? v(a) ?? a : a
204
204
  );
205
- if (a !== t && (a.ref !== t.ref && r("ref", a.ref), a.test !== t.test && r("test", a.test)), t.inputAliases && typeof t.inputAliases == "object") {
206
- const s = t.inputAliases;
205
+ if (s !== t && (s.ref !== t.ref && r("ref", s.ref), s.test !== t.test && r("test", s.test)), t.inputAliases && typeof t.inputAliases == "object") {
206
+ const a = t.inputAliases;
207
207
  let i = !1;
208
208
  const o = Object.fromEntries(
209
- Object.entries(s).map(([c, u]) => ae(u) ? (i = !0, [c, v(u) ?? u]) : [c, u])
209
+ Object.entries(a).map(([c, u]) => ie(u) ? (i = !0, [c, v(u) ?? u]) : [c, u])
210
210
  );
211
211
  i && r("inputAliases", o);
212
212
  }
213
- for (const [s, i] of Object.entries(t))
214
- s === "ref" && t.type === "variable" || s === "test" && t.type === "when" || s === "inputAliases" || r(s, U(i));
213
+ for (const [a, i] of Object.entries(t))
214
+ a === "ref" && t.type === "variable" || a === "test" && t.type === "when" || a === "inputAliases" || r(a, U(i));
215
215
  return n ?? e;
216
216
  }
217
- function rn(e) {
217
+ function on(e) {
218
218
  return b(e);
219
219
  }
220
220
  function b(e) {
221
221
  const t = [];
222
222
  for (const n of Array.isArray(e) ? e : [])
223
223
  if (!(!n || typeof n != "object")) {
224
- for (const r of Je(n)) {
225
- const a = v(r);
226
- a && t.push(a);
224
+ for (const r of Ze(n)) {
225
+ const s = v(r);
226
+ s && t.push(s);
227
227
  }
228
228
  n.type === "link" && t.push(...b(n.children), ...b(Array.isArray(n.url) ? n.url : [])), n.type === "when" && t.push(...b(n.then), ...b(n.else));
229
229
  }
230
230
  return t;
231
231
  }
232
- function Xe(e) {
232
+ function tt(e) {
233
233
  var r;
234
234
  const t = (r = e.preferences) == null ? void 0 : r.textVisualOptions, n = t == null ? void 0 : t.richContent;
235
235
  return n && Array.isArray(n.blocks) ? n.blocks.flatMap(
236
- (a) => (a == null ? void 0 : a.type) === "list" ? (Array.isArray(a.items) ? a.items : []).flatMap((s) => b(s)) : b(a == null ? void 0 : a.children)
236
+ (s) => (s == null ? void 0 : s.type) === "list" ? (Array.isArray(s.items) ? s.items : []).flatMap((a) => b(a)) : b(s == null ? void 0 : s.children)
237
237
  ) : b(t == null ? void 0 : t.content);
238
238
  }
239
239
  function be(e, t) {
240
- var a;
240
+ var s;
241
241
  const n = [], r = { kind: "document", sheetId: e };
242
- for (const s of ["header", "footer"])
243
- for (const i of ((a = t[s]) == null ? void 0 : a.blocks) ?? [])
242
+ for (const a of ["header", "footer"])
243
+ for (const i of ((s = t[a]) == null ? void 0 : s.blocks) ?? [])
244
244
  if (i.type === "text")
245
245
  for (const o of b(i.content))
246
- n.push({ ref: o, place: r, where: { kind: s, blockId: i.id } });
247
- for (const s of t.sections ?? [])
248
- if (s.type === "text")
249
- for (const i of b(s.content))
250
- n.push({ ref: i, place: r, where: { kind: "section", sectionId: s.id } });
246
+ n.push({ ref: o, place: r, where: { kind: a, blockId: i.id } });
247
+ for (const a of t.sections ?? [])
248
+ if (a.type === "text")
249
+ for (const i of b(a.content))
250
+ n.push({ ref: i, place: r, where: { kind: "section", sectionId: a.id } });
251
251
  return n;
252
252
  }
253
- const ie = /* @__PURE__ */ new WeakMap();
253
+ const oe = /* @__PURE__ */ new WeakMap();
254
254
  function Se(e) {
255
- const t = ie.get(e);
255
+ const t = oe.get(e);
256
256
  if (t) return t;
257
257
  const n = [];
258
258
  for (const r of e.sheets ?? []) {
@@ -260,13 +260,13 @@ function Se(e) {
260
260
  r.document && n.push(...be(r.id, r.document));
261
261
  continue;
262
262
  }
263
- const a = { kind: "sheet", sheetId: r.id }, s = [...r.cards ?? [], ...(r.frames ?? []).flatMap((i) => i.cards ?? [])];
264
- for (const i of s)
263
+ const s = { kind: "sheet", sheetId: r.id }, a = [...r.cards ?? [], ...(r.frames ?? []).flatMap((i) => i.cards ?? [])];
264
+ for (const i of a)
265
265
  if (i.type === "text")
266
- for (const o of Xe(i))
267
- n.push({ ref: o, place: a, where: { kind: "card", cardId: i.id } });
266
+ for (const o of tt(i))
267
+ n.push({ ref: o, place: s, where: { kind: "card", cardId: i.id } });
268
268
  }
269
- return ie.set(e, n), n;
269
+ return oe.set(e, n), n;
270
270
  }
271
271
  function Ce(e, t) {
272
272
  return e.kind === t.kind && e.sheetId === t.sheetId;
@@ -275,19 +275,19 @@ function ge(e, t) {
275
275
  const n = Se(e);
276
276
  return t ? n.filter((r) => Ce(r.place, t)) : [...n];
277
277
  }
278
- function Ze(e, t) {
278
+ function nt(e, t) {
279
279
  const n = [];
280
- for (const { ref: r, place: a } of Se(e))
281
- r.source !== "data" || r.variableId !== t || n.some((s) => Ce(s, a)) || n.push(a);
280
+ for (const { ref: r, place: s } of Se(e))
281
+ r.source !== "data" || r.variableId !== t || n.some((a) => Ce(a, s)) || n.push(s);
282
282
  return n;
283
283
  }
284
- function sn(e, t) {
284
+ function cn(e, t) {
285
285
  const n = /* @__PURE__ */ new Set();
286
286
  for (const { ref: r } of ge(e, t))
287
287
  r.source === "data" && n.add(r.variableId);
288
288
  return [...n];
289
289
  }
290
- function an(e, t) {
290
+ function un(e, t) {
291
291
  const n = be("", e).filter(
292
292
  ({ ref: r }) => r.source === "input" && r.inputId === t
293
293
  );
@@ -300,7 +300,7 @@ function an(e, t) {
300
300
  };
301
301
  }
302
302
  function ke(e, t) {
303
- const n = Ze(e, t);
303
+ const n = nt(e, t);
304
304
  return n.length ? n.map((r) => ({
305
305
  sheetId: r.sheetId,
306
306
  cardId: t,
@@ -309,14 +309,14 @@ function ke(e, t) {
309
309
  }
310
310
  function C(e, t) {
311
311
  var r;
312
- if (!rt(e, t))
312
+ if (!it(e, t))
313
313
  return !1;
314
314
  const n = e.scope;
315
315
  switch (n.kind) {
316
316
  case "allSheets":
317
- return ((r = n.sheetKinds) != null && r.length ? t.sheetKind ? n.sheetKinds.includes(t.sheetKind) : !1 : !!t.sheetId || !!t.cardId) && !nt(n.exceptSheetIds, t) && !ue(n.exceptCardIds, t);
317
+ return ((r = n.sheetKinds) != null && r.length ? t.sheetKind ? n.sheetKinds.includes(t.sheetKind) : !1 : !!t.sheetId || !!t.cardId) && !at(n.exceptSheetIds, t) && !de(n.exceptCardIds, t);
318
318
  case "sheets":
319
- return !!t.sheetId && n.sheetIds.includes(t.sheetId) && !ue(n.exceptCardIds, t);
319
+ return !!t.sheetId && n.sheetIds.includes(t.sheetId) && !de(n.exceptCardIds, t);
320
320
  case "cards":
321
321
  return !!t.cardId && n.cardIds.includes(t.cardId);
322
322
  case "documentSections":
@@ -325,7 +325,7 @@ function C(e, t) {
325
325
  return !1;
326
326
  }
327
327
  }
328
- function on(e, t) {
328
+ function dn(e, t) {
329
329
  if (C(e, {
330
330
  sheetId: t.sheetId,
331
331
  sheetKind: t.sheetKind
@@ -347,34 +347,34 @@ function on(e, t) {
347
347
  return !1;
348
348
  }
349
349
  }
350
- const oe = /* @__PURE__ */ new WeakMap();
351
- function et(e) {
352
- const t = oe.get(e);
350
+ const ce = /* @__PURE__ */ new WeakMap();
351
+ function rt(e) {
352
+ const t = ce.get(e);
353
353
  if (t) return t;
354
354
  const n = /* @__PURE__ */ new Map();
355
- for (const s of _(e)) {
356
- const i = n.get(s.sheetId) ?? /* @__PURE__ */ new Set();
357
- i.add(s.cardId), n.set(s.sheetId, i);
355
+ for (const a of _(e)) {
356
+ const i = n.get(a.sheetId) ?? /* @__PURE__ */ new Set();
357
+ i.add(a.cardId), n.set(a.sheetId, i);
358
358
  }
359
359
  const r = /* @__PURE__ */ new Map();
360
- for (const { ref: s, place: i } of ge(e)) {
361
- if (s.source !== "data") continue;
360
+ for (const { ref: a, place: i } of ge(e)) {
361
+ if (a.source !== "data") continue;
362
362
  const o = r.get(i.sheetId) ?? /* @__PURE__ */ new Set();
363
- o.add(s.variableId), r.set(i.sheetId, o);
363
+ o.add(a.variableId), r.set(i.sheetId, o);
364
364
  }
365
- const a = /* @__PURE__ */ new Map();
366
- for (const s of e.sheets ?? [])
367
- a.set(s.id, {
368
- sheetId: s.id,
369
- sheetKind: s.kind === "document" ? "document" : "dashboard",
370
- cardIds: n.get(s.id) ?? /* @__PURE__ */ new Set(),
371
- variableIds: r.get(s.id) ?? /* @__PURE__ */ new Set()
365
+ const s = /* @__PURE__ */ new Map();
366
+ for (const a of e.sheets ?? [])
367
+ s.set(a.id, {
368
+ sheetId: a.id,
369
+ sheetKind: a.kind === "document" ? "document" : "dashboard",
370
+ cardIds: n.get(a.id) ?? /* @__PURE__ */ new Set(),
371
+ variableIds: r.get(a.id) ?? /* @__PURE__ */ new Set()
372
372
  });
373
- return oe.set(e, a), a;
373
+ return ce.set(e, s), s;
374
374
  }
375
- function cn(e, t) {
376
- var a, s;
377
- const n = /* @__PURE__ */ new Set(), r = et(e);
375
+ function ln(e, t) {
376
+ var s, a;
377
+ const n = /* @__PURE__ */ new Set(), r = rt(e);
378
378
  for (const i of r.values())
379
379
  C(t, {
380
380
  sheetId: i.sheetId,
@@ -385,7 +385,7 @@ function cn(e, t) {
385
385
  sheetId: i.sheetId,
386
386
  cardId: i.cardId,
387
387
  ...i.kind === "documentSectionCard" ? { sectionId: i.sectionId } : {},
388
- sheetKind: ((a = r.get(i.sheetId)) == null ? void 0 : a.sheetKind) ?? "dashboard"
388
+ sheetKind: ((s = r.get(i.sheetId)) == null ? void 0 : s.sheetKind) ?? "dashboard"
389
389
  }) && n.add(`card:${i.cardId}`);
390
390
  for (const i of e.variables ?? [])
391
391
  ke(e, i.id).some(
@@ -393,7 +393,7 @@ function cn(e, t) {
393
393
  ) && n.add(`card:${i.id}`);
394
394
  for (const i of e.sheets ?? [])
395
395
  if (i.kind === "document")
396
- for (const o of ((s = i.document) == null ? void 0 : s.sections) ?? [])
396
+ for (const o of ((a = i.document) == null ? void 0 : a.sections) ?? [])
397
397
  C(t, {
398
398
  sheetId: i.id,
399
399
  sectionId: o.id,
@@ -401,17 +401,17 @@ function cn(e, t) {
401
401
  }) && n.add(`section:${o.id}`);
402
402
  return n;
403
403
  }
404
- function un(e) {
404
+ function fn(e) {
405
405
  return e.kind === "filter" && e.scope.kind === "cards";
406
406
  }
407
- function dn(e, t) {
408
- var s, i, o;
407
+ function mn(e, t) {
408
+ var a, i, o;
409
409
  const n = (c) => {
410
410
  var u, d;
411
- return ce(c, t.removedSheetIds, t.renamedSheetIds, !1, (u = t.copiedTab) == null ? void 0 : u.sheetIds, (d = t.copiedTab) == null ? void 0 : d.mode);
411
+ return ue(c, t.removedSheetIds, t.renamedSheetIds, !1, (u = t.copiedTab) == null ? void 0 : u.sheetIds, (d = t.copiedTab) == null ? void 0 : d.mode);
412
412
  }, r = (c) => {
413
413
  var u, d;
414
- return ce(
414
+ return ue(
415
415
  c,
416
416
  t.removedCardIds,
417
417
  t.renamedCardIds,
@@ -420,28 +420,28 @@ function dn(e, t) {
420
420
  (d = t.copiedTab) == null ? void 0 : d.mode
421
421
  );
422
422
  };
423
- let a;
423
+ let s;
424
424
  switch (e.kind) {
425
425
  case "allSheets":
426
- a = {
426
+ s = {
427
427
  ...e,
428
428
  ...e.exceptSheetIds ? { exceptSheetIds: n(e.exceptSheetIds) } : {},
429
429
  ...e.exceptCardIds ? { exceptCardIds: r(e.exceptCardIds) } : {}
430
430
  };
431
431
  break;
432
432
  case "sheets":
433
- a = {
433
+ s = {
434
434
  ...e,
435
435
  sheetIds: n(e.sheetIds),
436
436
  ...e.exceptCardIds ? { exceptCardIds: r(e.exceptCardIds) } : {}
437
437
  };
438
438
  break;
439
439
  case "cards":
440
- a = { ...e, cardIds: r(e.cardIds) };
440
+ s = { ...e, cardIds: r(e.cardIds) };
441
441
  break;
442
442
  case "documentSections": {
443
- if ((s = t.removedSheetIds) != null && s.has(e.sheetId)) {
444
- a = { ...e, sectionIds: [] };
443
+ if ((a = t.removedSheetIds) != null && a.has(e.sheetId)) {
444
+ s = { ...e, sectionIds: [] };
445
445
  break;
446
446
  }
447
447
  const c = {
@@ -449,7 +449,7 @@ function dn(e, t) {
449
449
  sheetId: ((i = t.renamedSheetIds) == null ? void 0 : i.get(e.sheetId)) ?? e.sheetId,
450
450
  sectionIds: (o = t.renamedSectionIds) != null && o.size ? e.sectionIds.map((d) => t.renamedSectionIds.get(d) ?? d) : e.sectionIds
451
451
  }, u = t.copiedTab;
452
- a = (u == null ? void 0 : u.mode) === "replace" && u.sheetIds.has(c.sheetId) ? {
452
+ s = (u == null ? void 0 : u.mode) === "replace" && u.sheetIds.has(c.sheetId) ? {
453
453
  ...c,
454
454
  sheetId: u.sheetIds.get(c.sheetId),
455
455
  sectionIds: c.sectionIds.map((d) => u.sectionIds.get(d) ?? d)
@@ -459,25 +459,25 @@ function dn(e, t) {
459
459
  default:
460
460
  return e;
461
461
  }
462
- return tt(e, a) ? e : a;
462
+ return st(e, s) ? e : s;
463
463
  }
464
- function ce(e, t, n, r, a, s) {
464
+ function ue(e, t, n, r, s, a) {
465
465
  let i = e;
466
- return t != null && t.size && (i = i.filter((o) => !t.has(o))), r && (i = i.filter((o) => n == null ? void 0 : n.has(o))), n != null && n.size && (i = i.map((o) => n.get(o) ?? o)), a != null && a.size && (i = s === "extend" ? [.../* @__PURE__ */ new Set([...i, ...i.flatMap((o) => a.has(o) ? [a.get(o)] : [])])] : i.map((o) => a.get(o) ?? o)), i;
466
+ return t != null && t.size && (i = i.filter((o) => !t.has(o))), r && (i = i.filter((o) => n == null ? void 0 : n.has(o))), n != null && n.size && (i = i.map((o) => n.get(o) ?? o)), s != null && s.size && (i = a === "extend" ? [.../* @__PURE__ */ new Set([...i, ...i.flatMap((o) => s.has(o) ? [s.get(o)] : [])])] : i.map((o) => s.get(o) ?? o)), i;
467
467
  }
468
- function tt(e, t) {
468
+ function st(e, t) {
469
469
  return JSON.stringify(e) === JSON.stringify(t);
470
470
  }
471
- function nt(e, t) {
471
+ function at(e, t) {
472
472
  return !!t.sheetId && !!(e != null && e.includes(t.sheetId));
473
473
  }
474
- function ue(e, t) {
474
+ function de(e, t) {
475
475
  return !!t.cardId && !!(e != null && e.includes(t.cardId));
476
476
  }
477
- function rt(e, t) {
477
+ function it(e, t) {
478
478
  return t.sheetKind !== "document" || !e.compatibility || e.compatibility.source === "documentInput" ? !0 : e.compatibility.source === "cardInlineFilter" || e.compatibility.source === "cardControl" ? !!t.cardId && e.compatibility.cardId === t.cardId : !1;
479
479
  }
480
- function ln(e, t, n) {
480
+ function pn(e, t, n) {
481
481
  switch (e.kind) {
482
482
  case "sheets":
483
483
  return e.sheetIds.length > 0 && e.sheetIds.every((r) => r === t);
@@ -489,52 +489,52 @@ function ln(e, t, n) {
489
489
  return !1;
490
490
  }
491
491
  }
492
- function fn(e) {
492
+ function hn(e) {
493
493
  return e.kind === "sheets" && e.sheetIds.length === 0 || e.kind === "cards" && e.cardIds.length === 0;
494
494
  }
495
- function st(e) {
495
+ function ot(e) {
496
496
  return e.kind === "allSheets" || e.kind === "sheets" ? e.exceptCardIds ?? [] : [];
497
497
  }
498
- function mn(e) {
498
+ function yn(e) {
499
499
  return e.kind === "allSheets" ? e.exceptSheetIds ?? [] : [];
500
500
  }
501
- function pn(e, t) {
502
- var s;
503
- if (e.kind !== "allSheets" && e.kind !== "sheets" || !((s = e.exceptCardIds) != null && s.includes(t))) return e;
504
- const n = e.exceptCardIds.filter((i) => i !== t), { exceptCardIds: r, ...a } = e;
505
- return n.length ? { ...a, exceptCardIds: n } : a;
501
+ function In(e, t) {
502
+ var a;
503
+ if (e.kind !== "allSheets" && e.kind !== "sheets" || !((a = e.exceptCardIds) != null && a.includes(t))) return e;
504
+ const n = e.exceptCardIds.filter((i) => i !== t), { exceptCardIds: r, ...s } = e;
505
+ return n.length ? { ...s, exceptCardIds: n } : s;
506
506
  }
507
- function hn(e, t, n) {
507
+ function bn(e, t, n) {
508
508
  var o;
509
509
  if (t.kind !== "allSheets" && t.kind !== "sheets") return t;
510
- const r = st(e), a = e.kind === "sheets" ? e.sheetIds.filter((c) => n.has(c)) : e.kind === "allSheets" && de(e) ? [...n].filter((c) => {
510
+ const r = ot(e), s = e.kind === "sheets" ? e.sheetIds.filter((c) => n.has(c)) : e.kind === "allSheets" && le(e) ? [...n].filter((c) => {
511
511
  var u;
512
512
  return !((u = e.exceptSheetIds) != null && u.includes(c));
513
- }) : [], s = [...n].filter((c) => !a.includes(c));
513
+ }) : [], a = [...n].filter((c) => !s.includes(c));
514
514
  if (t.kind === "sheets")
515
515
  return {
516
516
  ...t,
517
- sheetIds: [.../* @__PURE__ */ new Set([...t.sheetIds, ...a])],
517
+ sheetIds: [.../* @__PURE__ */ new Set([...t.sheetIds, ...s])],
518
518
  ...r.length ? { exceptCardIds: [...r] } : {}
519
519
  };
520
520
  const i = e.kind === "allSheets" ? ((o = e.exceptSheetIds) == null ? void 0 : o.filter((c) => n.has(c))) ?? [] : [];
521
521
  return {
522
522
  kind: "allSheets",
523
- ...e.kind === "allSheets" && de(e) ? {
523
+ ...e.kind === "allSheets" && le(e) ? {
524
524
  ...e.sheetKinds ? { sheetKinds: e.sheetKinds } : {},
525
525
  ...i.length ? { exceptSheetIds: i } : {}
526
- } : a.length ? {
526
+ } : s.length ? {
527
527
  sheetKinds: ["dashboard", "document"],
528
- ...s.length ? { exceptSheetIds: s } : {}
528
+ ...a.length ? { exceptSheetIds: a } : {}
529
529
  } : {},
530
530
  ...r.length ? { exceptCardIds: [...r] } : {}
531
531
  };
532
532
  }
533
- function de(e) {
533
+ function le(e) {
534
534
  var t;
535
535
  return e.kind === "allSheets" && (!((t = e.sheetKinds) != null && t.length) || e.sheetKinds.includes("document"));
536
536
  }
537
- function yn(e, t) {
537
+ function Sn(e, t) {
538
538
  switch (e.kind) {
539
539
  case "allSheets":
540
540
  case "sheets": {
@@ -547,51 +547,51 @@ function yn(e, t) {
547
547
  return;
548
548
  }
549
549
  }
550
- const at = 6;
551
- function In(e) {
550
+ const ct = 6;
551
+ function Cn(e) {
552
552
  if (!(e === void 0 || !Number.isFinite(e)) && Number.isInteger(e))
553
- return Math.max(0, Math.min(at, e));
553
+ return Math.max(0, Math.min(ct, e));
554
554
  }
555
555
  function we(e) {
556
556
  var t;
557
557
  return ((t = e == null ? void 0 : e.comparison) == null ? void 0 : t.mode) === "explicit" ? e.comparison.spec : void 0;
558
558
  }
559
- function it(e) {
559
+ function ut(e) {
560
560
  var t;
561
561
  return ((t = we(e)) == null ? void 0 : t.kind) || "none";
562
562
  }
563
- function bn(e) {
563
+ function gn(e) {
564
564
  const t = we(e);
565
565
  return (t == null ? void 0 : t.kind) === "target" ? t.targetValue : void 0;
566
566
  }
567
- function Sn(e) {
568
- return (e == null ? void 0 : e.semanticComparisonPolarity) || (e == null ? void 0 : e.comparisonPolarity) || qe;
567
+ function kn(e) {
568
+ return (e == null ? void 0 : e.semanticComparisonPolarity) || (e == null ? void 0 : e.comparisonPolarity) || Ue;
569
569
  }
570
- function Y(e, t) {
570
+ function J(e, t) {
571
571
  const n = Object.entries(e || {}).filter(
572
- ([s, i]) => i.output.outputId === s
572
+ ([a, i]) => i.output.outputId === a
573
573
  );
574
574
  if (!t.name) return;
575
575
  const r = j({
576
576
  ...t,
577
577
  name: t.name
578
- }), a = n.filter(
579
- ([, s]) => s.output.metricAlias === r
578
+ }), s = n.filter(
579
+ ([, a]) => a.output.metricAlias === r
580
580
  );
581
- return a.length === 1 ? a[0][1] : void 0;
581
+ return s.length === 1 ? s[0][1] : void 0;
582
582
  }
583
- function Cn(e, t) {
584
- const n = Y(e, t);
583
+ function wn(e, t) {
584
+ const n = J(e, t);
585
585
  return {
586
- comparisonKind: (n == null ? void 0 : n.type) ?? it(t),
586
+ comparisonKind: (n == null ? void 0 : n.type) ?? ut(t),
587
587
  metadata: n
588
588
  };
589
589
  }
590
- function gn(e) {
591
- return (e == null ? void 0 : e.showComparison) ?? Be.showComparison;
590
+ function An(e) {
591
+ return (e == null ? void 0 : e.showComparison) ?? ze.showComparison;
592
592
  }
593
- function kn(e) {
594
- const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
593
+ function vn(e) {
594
+ const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), o = /* @__PURE__ */ new Map();
595
595
  return Object.entries(e || {}).forEach(([c, u]) => {
596
596
  const d = u.output;
597
597
  d.outputId === c && (t.add(d.currentColumnKey), n.add(d.currentColumnKey), d.availability.status === "available" && (d.comparisonColumnKey && (r.add(d.comparisonColumnKey), o.set(
@@ -600,112 +600,136 @@ function kn(e) {
600
600
  metricName: u.displayName || d.metricId,
601
601
  comparisonLabel: u.displayLabel || "Comparison"
602
602
  }
603
- )), d.deltaColumnKey && (t.add(d.deltaColumnKey), a.add(d.deltaColumnKey)), d.percentChangeColumnKey && (t.add(d.percentChangeColumnKey), s.add(d.percentChangeColumnKey)), d.ratioColumnKey && (t.add(d.ratioColumnKey), i.add(d.ratioColumnKey)), d.rowStatusColumnKey && (t.add(d.rowStatusColumnKey), n.add(d.rowStatusColumnKey)), d.currentBucketColumnKey && (t.add(d.currentBucketColumnKey), n.add(d.currentBucketColumnKey)), d.comparisonSourceBucketColumnKey && (t.add(d.comparisonSourceBucketColumnKey), n.add(d.comparisonSourceBucketColumnKey))));
603
+ )), d.deltaColumnKey && (t.add(d.deltaColumnKey), s.add(d.deltaColumnKey)), d.percentChangeColumnKey && (t.add(d.percentChangeColumnKey), a.add(d.percentChangeColumnKey)), d.ratioColumnKey && (t.add(d.ratioColumnKey), i.add(d.ratioColumnKey)), d.rowStatusColumnKey && (t.add(d.rowStatusColumnKey), n.add(d.rowStatusColumnKey)), d.currentBucketColumnKey && (t.add(d.currentBucketColumnKey), n.add(d.currentBucketColumnKey)), d.comparisonSourceBucketColumnKey && (t.add(d.comparisonSourceBucketColumnKey), n.add(d.comparisonSourceBucketColumnKey))));
604
604
  }), {
605
605
  internalKeys: t,
606
606
  bookkeepingKeys: n,
607
607
  comparisonColumnKeys: r,
608
- deltaColumnKeys: a,
609
- percentChangeColumnKeys: s,
608
+ deltaColumnKeys: s,
609
+ percentChangeColumnKeys: a,
610
610
  ratioColumnKeys: i,
611
611
  comparisonSeriesLabels: o
612
612
  };
613
613
  }
614
- const ot = "SEMAPHOR_CALCULATED_FIELD";
615
- function J(e, t, n) {
614
+ const dt = "SEMAPHOR_CALCULATED_FIELD";
615
+ function H(e, t, n) {
616
616
  if (n && (t === "groupby" || t === "pivotby"))
617
617
  return n;
618
618
  if (t === "metric" && e.name === "*" && !e.expression)
619
619
  return e.alias || "count";
620
620
  if (e.alias) return e.alias;
621
- const r = e.entityName && e.entityName !== ot ? e.entityName : void 0;
621
+ const r = e.entityName && e.entityName !== dt ? e.entityName : void 0;
622
622
  if (e.role === "metric") {
623
- let a = e.aggregate || "metric";
623
+ let s = e.aggregate || "metric";
624
624
  if (e.expression) {
625
- const s = e.expression.match(
625
+ const a = e.expression.match(
626
626
  /^(COUNT|SUM|AVG|MIN|MAX|MEDIAN|DISTINCT)\s*\(/i
627
627
  );
628
- a = s ? s[1].toLowerCase() : "expr";
628
+ s = a ? a[1].toLowerCase() : "expr";
629
629
  } else
630
- a = a.toLowerCase();
631
- return r && r !== e.name ? `${r}_${e.name}_${a}` : `${e.name}_${a}`;
630
+ s = s.toLowerCase();
631
+ return r && r !== e.name ? `${r}_${e.name}_${s}` : `${e.name}_${s}`;
632
632
  }
633
633
  return r && r !== e.name ? `${r}_${e.name}` : e.name;
634
634
  }
635
- function wn(e) {
636
- return J(e, "detail");
635
+ function Ae(e) {
636
+ return H(e, "detail");
637
637
  }
638
- function ct(e) {
638
+ function lt(e) {
639
639
  const t = e.label;
640
640
  return t && e.labelCount === 1 && (t === e.rawKey || !e.rawKeys.has(t)) ? t : e.rawKey;
641
641
  }
642
- function An(e) {
642
+ function Tn(e) {
643
643
  const t = [
644
- ...(e.groupByColumns ?? []).map((s) => ({ field: s, role: "groupby" })),
645
- ...(e.metricColumns ?? []).map((s) => ({ field: s, role: "metric" })),
646
- ...(e.pivotByColumns ?? []).map((s) => ({ field: s, role: "pivotby" })),
647
- ...(e.detailColumns ?? []).map((s) => ({ field: s, role: "detail" }))
648
- ], n = new Map(t.map(({ field: s, role: i }) => [s, J(s, i)])), r = new Set(n.values()), a = /* @__PURE__ */ new Map();
649
- for (const { field: s } of t)
650
- s.label && a.set(s.label, (a.get(s.label) ?? 0) + 1);
644
+ ...(e.groupByColumns ?? []).map((o) => ({ field: o, role: "groupby" })),
645
+ ...(e.metricColumns ?? []).map((o) => ({ field: o, role: "metric" })),
646
+ ...(e.pivotByColumns ?? []).map((o) => ({ field: o, role: "pivotby" })),
647
+ ...(e.detailColumns ?? []).map((o) => ({ field: o, role: "detail" }))
648
+ ], n = ve(e.detailColumns ?? []), r = new Map((e.detailColumns ?? []).map((o, c) => [o, c])), s = new Map(
649
+ t.map(({ field: o, role: c }) => [
650
+ o,
651
+ c === "detail" ? n[r.get(o)] : H(o, c)
652
+ ])
653
+ ), a = new Set(s.values()), i = /* @__PURE__ */ new Map();
654
+ for (const { field: o } of t)
655
+ o.label && i.set(o.label, (i.get(o.label) ?? 0) + 1);
651
656
  return new Map(
652
- t.map(({ field: s }) => [
653
- s,
654
- ct({
655
- label: s.label,
656
- labelCount: s.label ? a.get(s.label) ?? 0 : 0,
657
- rawKey: n.get(s),
658
- rawKeys: r
657
+ t.map(({ field: o }) => [
658
+ o,
659
+ lt({
660
+ label: o.label,
661
+ labelCount: o.label ? i.get(o.label) ?? 0 : 0,
662
+ rawKey: s.get(o),
663
+ rawKeys: a
659
664
  })
660
665
  ])
661
666
  );
662
667
  }
663
- const Ae = "text", R = 100, ut = 10, S = "value", ve = ["previous", "change", "percentChange"];
664
- function dt(e) {
665
- return ve.includes(e);
668
+ function ve(e) {
669
+ const t = e.map((s) => Ae(s)), n = new Set(t), r = /* @__PURE__ */ new Map();
670
+ return t.forEach((s, a) => {
671
+ r.has(s) || r.set(s, a);
672
+ }), t.map((s, a) => {
673
+ if (r.get(s) === a) return s;
674
+ let i = 2;
675
+ for (; n.has(`${s}_${i}`); ) i += 1;
676
+ return n.add(`${s}_${i}`), `${s}_${i}`;
677
+ });
678
+ }
679
+ function En(e) {
680
+ const t = e.detailColumns;
681
+ if (!t || t.length < 2) return e;
682
+ const n = ve(t);
683
+ let r = !1;
684
+ const s = t.map((a, i) => Ae(a) === n[i] ? a : (r = !0, { ...a, alias: n[i] }));
685
+ return r ? { ...e, detailColumns: s } : e;
686
+ }
687
+ const Te = "text", M = 100, ft = 10, S = "value", Ee = ["previous", "change", "percentChange"];
688
+ function mt(e) {
689
+ return Ee.includes(e);
666
690
  }
667
- const lt = ["up", "down", "flat"];
668
- function vn(e, t, n) {
669
- const { signWords: r, absolute: a, percent: s, ...i } = t ?? {};
691
+ const pt = ["up", "down", "flat"];
692
+ function Kn(e, t, n) {
693
+ const { signWords: r, absolute: s, percent: a, ...i } = t ?? {};
670
694
  return e !== "change" && e !== "percentChange" ? i : {
671
695
  ...i,
672
- ...(n == null ? void 0 : n.signWords) === void 0 ? { signWords: lt } : {},
696
+ ...(n == null ? void 0 : n.signWords) === void 0 ? { signWords: pt } : {},
673
697
  ...(n == null ? void 0 : n.absolute) === void 0 ? { absolute: !0 } : {},
674
698
  ...e === "percentChange" && (n == null ? void 0 : n.percent) === void 0 ? { percent: !0 } : {}
675
699
  };
676
700
  }
677
- function H(e) {
678
- var r, a, s, i;
701
+ function X(e) {
702
+ var r, s, a, i;
679
703
  if (e.get.kind !== "aggregate" || (r = e.query.sql) != null && r.trim()) return;
680
- const t = (i = (s = (a = e.query.config) == null ? void 0 : a.metricColumns) == null ? void 0 : s[0]) == null ? void 0 : i.comparison;
704
+ const t = (i = (a = (s = e.query.config) == null ? void 0 : s.metricColumns) == null ? void 0 : a[0]) == null ? void 0 : i.comparison;
681
705
  if ((t == null ? void 0 : t.mode) !== "explicit") return;
682
706
  const n = t.spec;
683
707
  return n.kind === "previous_period" || n.kind === "previous_year" ? n : void 0;
684
708
  }
685
- function le(e, t) {
709
+ function fe(e, t) {
686
710
  if (t === "preview" && e.get.kind !== "aggregate")
687
- return R + 1;
711
+ return M + 1;
688
712
  switch (e.get.kind) {
689
713
  case "only":
690
714
  return 2;
691
715
  case "list":
692
- return R + 1;
716
+ return M + 1;
693
717
  default:
694
718
  return 1;
695
719
  }
696
720
  }
697
- const fe = {
721
+ const me = {
698
722
  answer: /* @__PURE__ */ new WeakMap(),
699
723
  preview: /* @__PURE__ */ new WeakMap()
700
724
  };
701
- function ft(e, t = "answer") {
702
- var s;
703
- const n = fe[t].get(e);
725
+ function ht(e, t = "answer") {
726
+ var a;
727
+ const n = me[t].get(e);
704
728
  if (n) return n;
705
- const { query: r } = e, a = {
729
+ const { query: r } = e, s = {
706
730
  id: e.id,
707
731
  title: e.name,
708
- type: Ae,
732
+ type: Te,
709
733
  respondsToSelections: !1,
710
734
  dataVariableId: e.id,
711
735
  // The viewer's dashboard comparison never changes a variable: its own
@@ -714,88 +738,88 @@ function ft(e, t = "answer") {
714
738
  ...r.connectionId ? { connectionId: r.connectionId } : {},
715
739
  ...r.dataSource ? { dataSource: r.dataSource } : {},
716
740
  ...r.calculatedFields ? { calculatedFields: r.calculatedFields } : {},
717
- ...(s = r.sql) != null && s.trim() ? { sql: r.sql, config: { rowLimit: le(e, t) } } : { config: { ...r.config, rowLimit: le(e, t) } }
741
+ ...(a = r.sql) != null && a.trim() ? { sql: r.sql, config: { rowLimit: fe(e, t) } } : { config: { ...r.config, rowLimit: fe(e, t) } }
718
742
  };
719
- return fe[t].set(e, a), a;
743
+ return me[t].set(e, s), s;
720
744
  }
721
- function Tn(e) {
722
- return e.type === Ae && typeof e.dataVariableId == "string" && e.dataVariableId.length > 0;
745
+ function Dn(e) {
746
+ return e.type === Te && typeof e.dataVariableId == "string" && e.dataVariableId.length > 0;
723
747
  }
724
- function En(e, t, n) {
748
+ function Nn(e, t, n) {
725
749
  var r;
726
750
  if (n === S && ((r = e.query.sql) != null && r.trim())) {
727
- const a = Object.keys(t)[0];
728
- return a === void 0 ? void 0 : t[a];
751
+ const s = Object.keys(t)[0];
752
+ return s === void 0 ? void 0 : t[s];
729
753
  }
730
754
  return n in t ? t[n] : void 0;
731
755
  }
732
756
  function z(e) {
733
- const t = G(e);
757
+ const t = Y(e);
734
758
  return t === "string" || t === "unknown" ? "text" : t;
735
759
  }
736
- function mt(e) {
760
+ function yt(e) {
737
761
  return typeof e == "number" ? "number" : typeof e == "boolean" ? "boolean" : "text";
738
762
  }
739
- function pt(e, t, n, r) {
763
+ function It(e, t, n, r) {
740
764
  var i, o;
741
- const a = ze(r, e.id, t);
765
+ const s = Ge(r, e.id, t);
742
766
  return [
743
- a == null ? void 0 : a.outputKey,
744
- a == null ? void 0 : a.rawKey,
767
+ s == null ? void 0 : s.outputKey,
768
+ s == null ? void 0 : s.rawKey,
745
769
  t === "metric" ? ((o = (i = r == null ? void 0 : r.byMetricAlias) == null ? void 0 : i[j(e)]) == null ? void 0 : o.outputKey) ?? j(e) : void 0,
746
- J(e, t === "metric" ? "metric" : "groupby"),
770
+ H(e, t === "metric" ? "metric" : "groupby"),
747
771
  e.label,
748
772
  e.name
749
773
  ].find((c) => !!c && n.has(c));
750
774
  }
751
- function Kn(e, t) {
775
+ function On(e, t) {
752
776
  var r;
753
777
  if (e.get.kind === "aggregate")
754
- return H(e) ? [S, ...ve] : [S];
778
+ return X(e) ? [S, ...Ee] : [S];
755
779
  if (e.get.kind === "list") return [S];
756
780
  if ((r = e.query.sql) != null && r.trim()) return [...t ?? []];
757
781
  const n = e.query.config;
758
- return ht([
759
- ...((n == null ? void 0 : n.groupByColumns) ?? []).map((a) => a.name),
760
- ...((n == null ? void 0 : n.metricColumns) ?? []).map((a) => a.name)
782
+ return bt([
783
+ ...((n == null ? void 0 : n.groupByColumns) ?? []).map((s) => s.name),
784
+ ...((n == null ? void 0 : n.metricColumns) ?? []).map((s) => s.name)
761
785
  ]);
762
786
  }
763
- function Nn(e, t) {
764
- var s, i, o, c;
787
+ function xn(e, t) {
788
+ var a, i, o, c;
765
789
  if (e.get.kind === "list") return "list";
766
- if ((s = e.query.sql) != null && s.trim()) return;
790
+ if ((a = e.query.sql) != null && a.trim()) return;
767
791
  const n = e.query.config, r = (u, d) => {
768
792
  if (!u) return;
769
793
  const f = d === "metric" ? B(u) : u.dataType;
770
- return G(f) === "unknown" ? void 0 : z(f);
794
+ return Y(f) === "unknown" ? void 0 : z(f);
771
795
  };
772
796
  if (e.get.kind === "aggregate")
773
- return dt(t) && H(e) ? "number" : t === S ? r((i = n == null ? void 0 : n.metricColumns) == null ? void 0 : i[0], "metric") : void 0;
774
- const a = (o = n == null ? void 0 : n.groupByColumns) == null ? void 0 : o.find((u) => u.name === t);
775
- return a ? r(a, "groupby") : r((c = n == null ? void 0 : n.metricColumns) == null ? void 0 : c.find((u) => u.name === t), "metric");
797
+ return mt(t) && X(e) ? "number" : t === S ? r((i = n == null ? void 0 : n.metricColumns) == null ? void 0 : i[0], "metric") : void 0;
798
+ const s = (o = n == null ? void 0 : n.groupByColumns) == null ? void 0 : o.find((u) => u.name === t);
799
+ return s ? r(s, "groupby") : r((c = n == null ? void 0 : n.metricColumns) == null ? void 0 : c.find((u) => u.name === t), "metric");
776
800
  }
777
- function ht(e) {
801
+ function bt(e) {
778
802
  return [...new Set(e)];
779
803
  }
780
- function yt(e, t, n) {
804
+ function St(e, t, n) {
781
805
  var p, I, g;
782
- const r = t[0] ?? {}, a = new Set(
806
+ const r = t[0] ?? {}, s = new Set(
783
807
  (p = n.columns) != null && p.length ? n.columns.map((m) => m.key) : Object.keys(r)
784
- ), s = new Map(
808
+ ), a = new Map(
785
809
  (n.columns ?? []).map((m) => [m.key, m.dataType])
786
- ), i = (m, k) => s.has(m) ? z(s.get(m)) : k !== void 0 ? z(k) : mt(r[m]);
810
+ ), i = (m, k) => a.has(m) ? z(a.get(m)) : k !== void 0 ? z(k) : yt(r[m]);
787
811
  if ((I = e.query.sql) != null && I.trim())
788
- return [...a].map((m) => ({ part: m, key: m, type: i(m, void 0) }));
789
- const o = e.query.config ?? {}, c = [], u = a.size === 1 ? [...a][0] : void 0, d = e.get.kind === "aggregate" || e.get.kind === "list", f = (m, k, te) => {
790
- if (c.some((Fe) => Fe.part === te)) return;
791
- const K = pt(m, k, a, n.columnKeyMap) ?? (d ? u : void 0);
812
+ return [...s].map((m) => ({ part: m, key: m, type: i(m, void 0) }));
813
+ const o = e.query.config ?? {}, c = [], u = s.size === 1 ? [...s][0] : void 0, d = e.get.kind === "aggregate" || e.get.kind === "list", f = (m, k, ne) => {
814
+ if (c.some(($e) => $e.part === ne)) return;
815
+ const K = It(m, k, s, n.columnKeyMap) ?? (d ? u : void 0);
792
816
  if (!K) return;
793
- const _e = k === "metric" ? i(K, B(m)) : i(K, m.dataType);
794
- c.push({ part: te, key: K, type: _e });
817
+ const Ve = k === "metric" ? i(K, B(m)) : i(K, m.dataType);
818
+ c.push({ part: ne, key: K, type: Ve });
795
819
  }, y = o.metricColumns ?? [];
796
820
  if (e.get.kind === "aggregate") {
797
- const m = y[0] ? (g = Y(n.comparisonMetadata, y[0])) == null ? void 0 : g.output.currentColumnKey : void 0;
798
- return m && a.has(m) ? c.push({ part: S, key: m, type: i(m, B(y[0])) }) : y[0] && f(y[0], "metric", S), c;
821
+ const m = y[0] ? (g = J(n.comparisonMetadata, y[0])) == null ? void 0 : g.output.currentColumnKey : void 0;
822
+ return m && s.has(m) ? c.push({ part: S, key: m, type: i(m, B(y[0])) }) : y[0] && f(y[0], "metric", S), c;
799
823
  }
800
824
  const h = o.groupByColumns ?? [];
801
825
  if (e.get.kind === "list")
@@ -810,9 +834,9 @@ function W(e, t) {
810
834
  function w(e) {
811
835
  return !!e && typeof e == "object" && !Array.isArray(e);
812
836
  }
813
- function On(e) {
837
+ function Mn(e) {
814
838
  if (!w(e)) return {};
815
- const t = w(e.data) ? e.data : e, n = O(e).length ? O(e) : O(t), r = w(t.metadata) ? t.metadata : void 0;
839
+ const t = w(e.data) ? e.data : e, n = N(e).length ? N(e) : N(t), r = w(t.metadata) ? t.metadata : void 0;
816
840
  return {
817
841
  ...t.records !== void 0 ? { records: t.records } : {},
818
842
  ...Array.isArray(t.columns) ? { columns: t.columns } : {},
@@ -822,98 +846,98 @@ function On(e) {
822
846
  ...typeof t.error == "string" && t.error ? { error: t.error } : {}
823
847
  };
824
848
  }
825
- function Dn(e, t, n = "answer") {
849
+ function Rn(e, t, n = "answer") {
826
850
  var d;
827
851
  const r = (Array.isArray(t.records) ? t.records : []).filter(
828
852
  (f) => !!f && typeof f == "object"
829
- ), a = O(t), s = n === "preview" ? { matched: r.length > R ? "beyondCap" : r.length } : {};
830
- if (!r.length) return { status: "none", why: "noRows", filterReach: a, ...s };
831
- const i = yt(e, r, t);
853
+ ), s = N(t), a = n === "preview" ? { matched: r.length > M ? "beyondCap" : r.length } : {};
854
+ if (!r.length) return { status: "none", why: "noRows", filterReach: s, ...a };
855
+ const i = St(e, r, t);
832
856
  if (e.get.kind === "list") {
833
- const f = i[0], y = r.length > R, h = f ? r.map((I) => W(I[f.key], f.type)).filter((I) => I.value !== null) : [];
834
- if (!h.length && !y) return { status: "none", why: "noRows", filterReach: a, ...s };
835
- const p = Math.max(1, e.get.limit ?? ut);
857
+ const f = i[0], y = r.length > M, h = f ? r.map((I) => W(I[f.key], f.type)).filter((I) => I.value !== null) : [];
858
+ if (!h.length && !y) return { status: "none", why: "noRows", filterReach: s, ...a };
859
+ const p = Math.max(1, e.get.limit ?? ft);
836
860
  return {
837
861
  status: "listed",
838
862
  items: h.slice(0, p),
839
863
  more: y ? "beyondCap" : Math.max(0, h.length - p),
840
- filterReach: a,
841
- ...s
864
+ filterReach: s,
865
+ ...a
842
866
  };
843
867
  }
844
868
  if (e.get.kind === "only" && r.length > 1)
845
- return { status: "none", why: "moreThanOne", filterReach: a, ...s };
869
+ return { status: "none", why: "moreThanOne", filterReach: s, ...a };
846
870
  const o = r[0], c = Object.fromEntries(
847
871
  i.map((f) => [f.part, W(o[f.key], f.type)])
848
872
  );
849
873
  if (e.get.kind === "aggregate" && ((d = c[S]) == null ? void 0 : d.value) == null)
850
- return { status: "none", why: "noRows", filterReach: a, ...s };
851
- const u = H(e) ? It(e, o, t) : void 0;
874
+ return { status: "none", why: "noRows", filterReach: s, ...a };
875
+ const u = X(e) ? Ct(e, o, t) : void 0;
852
876
  return {
853
877
  status: "answered",
854
878
  parts: u && "parts" in u ? { ...c, ...u.parts } : c,
855
- filterReach: a,
879
+ filterReach: s,
856
880
  ...u && "unavailable" in u ? { comparisonUnavailable: u.unavailable } : {},
857
- ...s
881
+ ...a
858
882
  };
859
883
  }
860
- function It(e, t, n) {
884
+ function Ct(e, t, n) {
861
885
  var o, c;
862
- const r = (c = (o = e.query.config) == null ? void 0 : o.metricColumns) == null ? void 0 : c[0], a = r ? Y(n.comparisonMetadata, r) : void 0, s = a == null ? void 0 : a.output;
863
- if (!s || s.availability.status !== "available" || !s.comparisonColumnKey)
864
- return { unavailable: (s == null ? void 0 : s.availability.status) === "unavailable" ? s.availability.reason : "temporal_binding_missing" };
886
+ const r = (c = (o = e.query.config) == null ? void 0 : o.metricColumns) == null ? void 0 : c[0], s = r ? J(n.comparisonMetadata, r) : void 0, a = s == null ? void 0 : s.output;
887
+ if (!a || a.availability.status !== "available" || !a.comparisonColumnKey)
888
+ return { unavailable: (a == null ? void 0 : a.availability.status) === "unavailable" ? a.availability.reason : "temporal_binding_missing" };
865
889
  const i = (u) => {
866
890
  const d = t[u], f = typeof d == "string" && d.trim() !== "" ? Number(d) : d;
867
891
  return W(typeof f == "number" && !Number.isFinite(f) ? null : f, "number");
868
892
  };
869
893
  return {
870
894
  parts: {
871
- previous: i(s.comparisonColumnKey),
872
- change: i(s.deltaColumnKey ?? ""),
873
- percentChange: i(s.percentChangeColumnKey ?? "")
895
+ previous: i(a.comparisonColumnKey),
896
+ change: i(a.deltaColumnKey ?? ""),
897
+ percentChange: i(a.percentChangeColumnKey ?? "")
874
898
  }
875
899
  };
876
900
  }
877
- const me = /* @__PURE__ */ new WeakMap();
878
- function X(e) {
879
- const t = me.get(e);
901
+ const pe = /* @__PURE__ */ new WeakMap();
902
+ function Z(e) {
903
+ const t = pe.get(e);
880
904
  if (t) return t;
881
905
  const n = new Map(
882
906
  (e.sheets ?? []).map(
883
- (s) => [s.id, s.kind === "document" ? "document" : "dashboard"]
907
+ (a) => [a.id, a.kind === "document" ? "document" : "dashboard"]
884
908
  )
885
909
  ), r = [
886
910
  ..._(e).map(
887
- (s) => ({
911
+ (a) => ({
888
912
  kind: "card",
889
- id: s.cardId,
890
- card: s.card,
891
- sheetId: s.sheetId,
892
- sheetKind: n.get(s.sheetId) ?? "dashboard",
893
- ...s.kind === "documentSectionCard" ? { sectionId: s.sectionId } : {}
913
+ id: a.cardId,
914
+ card: a.card,
915
+ sheetId: a.sheetId,
916
+ sheetKind: n.get(a.sheetId) ?? "dashboard",
917
+ ...a.kind === "documentSectionCard" ? { sectionId: a.sectionId } : {}
894
918
  })
895
919
  ),
896
920
  ...(e.variables ?? []).map(
897
- (s) => ({
921
+ (a) => ({
898
922
  kind: "variable",
899
- id: s.id,
900
- variable: s,
901
- card: ft(s)
923
+ id: a.id,
924
+ variable: a,
925
+ card: ht(a)
902
926
  })
903
927
  )
904
- ], a = { targets: r, byId: new Map(r.map((s) => [s.id, s])) };
905
- return me.set(e, a), a;
928
+ ], s = { targets: r, byId: new Map(r.map((a) => [a.id, a])) };
929
+ return pe.set(e, s), s;
906
930
  }
907
- function bt(e) {
908
- return X(e).targets;
931
+ function gt(e) {
932
+ return Z(e).targets;
909
933
  }
910
- function xn(e, t) {
911
- return X(e).byId.get(t);
934
+ function _n(e, t) {
935
+ return Z(e).byId.get(t);
912
936
  }
913
- function St(e, t) {
914
- return X(e).byId.has(t);
937
+ function kt(e, t) {
938
+ return Z(e).byId.has(t);
915
939
  }
916
- function Ct(e, t) {
940
+ function wt(e, t) {
917
941
  return t.kind === "card" ? [
918
942
  {
919
943
  sheetId: t.sheetId,
@@ -923,18 +947,18 @@ function Ct(e, t) {
923
947
  }
924
948
  ] : ke(e, t.id);
925
949
  }
926
- function gt(e, t, n) {
927
- return Ct(e, n).some(
950
+ function At(e, t, n) {
951
+ return wt(e, n).some(
928
952
  (r) => C(t, r)
929
953
  );
930
954
  }
931
- function Rn(e, t) {
932
- return bt(e).filter(
933
- (n) => n.kind === "variable" && gt(e, t, n)
955
+ function Fn(e, t) {
956
+ return gt(e).filter(
957
+ (n) => n.kind === "variable" && At(e, t, n)
934
958
  );
935
959
  }
936
- const kt = ["new", "edit", "delete", "create", "update", "remove"];
937
- function Te(e, t) {
960
+ const vt = ["new", "edit", "delete", "create", "update", "remove"];
961
+ function Ke(e, t) {
938
962
  return (e.sheets || []).flatMap(
939
963
  (n) => _({ sheets: [n] }).filter(t).map((r) => ({
940
964
  card: r.card,
@@ -947,22 +971,22 @@ function Te(e, t) {
947
971
  );
948
972
  }
949
973
  function T(e) {
950
- return Te(e, (t) => t.kind !== "documentSectionCard");
974
+ return Ke(e, (t) => t.kind !== "documentSectionCard");
951
975
  }
952
- function Mn(e) {
976
+ function Vn(e) {
953
977
  return [
954
978
  ...T(e),
955
- ...Te(e, (t) => t.kind === "documentSectionCard")
979
+ ...Ke(e, (t) => t.kind === "documentSectionCard")
956
980
  ];
957
981
  }
958
- function _n(e) {
982
+ function $n(e) {
959
983
  return T(e).map((t) => t.card);
960
984
  }
961
- function Fn(e, t, n) {
962
- return n && t === n ? !0 : !St(e, t);
985
+ function Pn(e, t, n) {
986
+ return n && t === n ? !0 : !kt(e, t);
963
987
  }
964
- function Vn(e) {
965
- return !e || e.trim().length === 0 ? { isValid: !1, error: "Card ID cannot be empty" } : e.length < 3 ? { isValid: !1, error: "Card ID must be at least 3 characters" } : e.length > 50 ? { isValid: !1, error: "Card ID must be less than 50 characters" } : /^[a-zA-Z0-9-_]+$/.test(e) ? /^[a-zA-Z0-9]/.test(e) ? kt.includes(e.toLowerCase()) ? {
988
+ function Ln(e) {
989
+ return !e || e.trim().length === 0 ? { isValid: !1, error: "Card ID cannot be empty" } : e.length < 3 ? { isValid: !1, error: "Card ID must be at least 3 characters" } : e.length > 50 ? { isValid: !1, error: "Card ID must be less than 50 characters" } : /^[a-zA-Z0-9-_]+$/.test(e) ? /^[a-zA-Z0-9]/.test(e) ? vt.includes(e.toLowerCase()) ? {
966
990
  isValid: !1,
967
991
  error: `"${e}" is a reserved keyword and cannot be used`
968
992
  } : { isValid: !0 } : {
@@ -973,27 +997,27 @@ function Vn(e) {
973
997
  error: "Card ID can only contain letters, numbers, hyphens, and underscores"
974
998
  };
975
999
  }
976
- function Pn(e, t) {
1000
+ function qn(e, t) {
977
1001
  var n;
978
- return (n = wt(e, t)) == null ? void 0 : n.card;
1002
+ return (n = Tt(e, t)) == null ? void 0 : n.card;
979
1003
  }
980
- function wt(e, t) {
1004
+ function Tt(e, t) {
981
1005
  for (const n of T(e))
982
1006
  if (n.card.id === t)
983
1007
  return n;
984
1008
  }
985
- function Ln(e, t) {
1009
+ function Bn(e, t) {
986
1010
  for (const n of e.sheets || [])
987
1011
  for (const r of n.frames || [])
988
- for (const a of r.cards || [])
989
- if (a.id === t)
990
- return { card: a, sheet: n };
1012
+ for (const s of r.cards || [])
1013
+ if (s.id === t)
1014
+ return { card: s, sheet: n };
991
1015
  }
992
- const M = {
1016
+ const R = {
993
1017
  includeMetricFilterDatasets: !0,
994
1018
  preferQualifiedIdentity: !1
995
1019
  };
996
- function Ee(e) {
1020
+ function De(e) {
997
1021
  if (!e) return;
998
1022
  if (e.kind === "semantic")
999
1023
  return { entityName: e.datasetName, entityId: e.datasetId, label: e.label };
@@ -1004,12 +1028,12 @@ function Ee(e) {
1004
1028
  label: e.label
1005
1029
  };
1006
1030
  }
1007
- function At(e) {
1031
+ function Et(e) {
1008
1032
  var n;
1009
- const t = Ee(e.source);
1033
+ const t = De(e.source);
1010
1034
  return t ? `${(n = e.source) == null ? void 0 : n.kind}:${t.qualifiedEntityName || t.entityName}` : "";
1011
1035
  }
1012
- function vt(e) {
1036
+ function Kt(e) {
1013
1037
  return [
1014
1038
  e.id,
1015
1039
  e.qualifiedEntityName,
@@ -1019,36 +1043,36 @@ function vt(e) {
1019
1043
  e.name,
1020
1044
  // Source-only fields from different datasets can otherwise share a key
1021
1045
  // and the second dataset would be silently dropped.
1022
- At(e)
1046
+ Et(e)
1023
1047
  ].join("|");
1024
1048
  }
1025
- function Tt(e) {
1049
+ function Dt(e) {
1026
1050
  return [e.entityName, e.qualifiedEntityName || "", e.entityId || ""].join("|");
1027
1051
  }
1028
- function $n(e) {
1052
+ function jn(e) {
1029
1053
  return e.entityName || e.qualifiedEntityName || "";
1030
1054
  }
1031
- function Et(e) {
1055
+ function Nt(e) {
1032
1056
  var t, n;
1033
1057
  return !!(e.expression || e.derivedField || (n = (t = e.calculatedFormula) == null ? void 0 : t.inputFields) != null && n.length);
1034
1058
  }
1035
- function Kt(e) {
1036
- return Ve(e) ? !0 : e.entityName || e.qualifiedEntityName ? !1 : !e.source || Et(e);
1059
+ function Ot(e) {
1060
+ return Pe(e) ? !0 : e.entityName || e.qualifiedEntityName ? !1 : !e.source || Nt(e);
1037
1061
  }
1038
- function L(e, t) {
1039
- const n = Tt(t);
1062
+ function P(e, t) {
1063
+ const n = Dt(t);
1040
1064
  e.found.has(n) || e.found.set(n, t);
1041
1065
  }
1042
1066
  function E(e, t) {
1043
1067
  var u, d, f;
1044
1068
  if (!e) return;
1045
- const n = vt(e);
1069
+ const n = Kt(e);
1046
1070
  if (t.visitedFields.has(n)) return;
1047
1071
  t.visitedFields.add(n);
1048
- const r = Kt(e);
1072
+ const r = Ot(e);
1049
1073
  if (!r) {
1050
- const y = !e.entityName && !e.qualifiedEntityName ? Ee(e.source) : void 0;
1051
- L(
1074
+ const y = !e.entityName && !e.qualifiedEntityName ? De(e.source) : void 0;
1075
+ P(
1052
1076
  t,
1053
1077
  y || {
1054
1078
  // May be empty for qualified-only metadata; identity then comes from
@@ -1060,16 +1084,16 @@ function E(e, t) {
1060
1084
  }
1061
1085
  );
1062
1086
  }
1063
- t.includeMetricFilterDatasets && "parameters" in e && ((u = e.parameters) != null && u.filters) && Z(e.parameters.filters, t);
1064
- const a = (d = e.calculatedFormula) == null ? void 0 : d.inputFields, s = !!(a && a.length > 0);
1065
- s && a.forEach((y) => E(y, t));
1087
+ t.includeMetricFilterDatasets && "parameters" in e && ((u = e.parameters) != null && u.filters) && ee(e.parameters.filters, t);
1088
+ const s = (d = e.calculatedFormula) == null ? void 0 : d.inputFields, a = !!(s && s.length > 0);
1089
+ a && s.forEach((y) => E(y, t));
1066
1090
  let i = !1, o = !1;
1067
- const c = s || (f = e.derivedField) == null ? void 0 : f.inputs;
1091
+ const c = a || (f = e.derivedField) == null ? void 0 : f.inputs;
1068
1092
  if (c && Object.keys(c).length > 0)
1069
1093
  for (const y of Object.values(c)) {
1070
1094
  const h = y.field.source;
1071
1095
  if (!h) {
1072
- s || (o = !0);
1096
+ a || (o = !0);
1073
1097
  continue;
1074
1098
  }
1075
1099
  if (h.kind === "sql") {
@@ -1077,14 +1101,14 @@ function E(e, t) {
1077
1101
  continue;
1078
1102
  }
1079
1103
  if (h.kind === "semantic")
1080
- L(t, {
1104
+ P(t, {
1081
1105
  entityName: h.datasetName,
1082
1106
  entityId: h.datasetId,
1083
1107
  label: h.label
1084
1108
  });
1085
1109
  else {
1086
1110
  const p = [h.databaseName, h.schemaName, h.tableName].filter((I) => !!(I && I.trim())).join(".");
1087
- L(t, {
1111
+ P(t, {
1088
1112
  entityName: h.tableName,
1089
1113
  qualifiedEntityName: p.includes(".") ? p : void 0,
1090
1114
  label: h.label
@@ -1092,15 +1116,15 @@ function E(e, t) {
1092
1116
  }
1093
1117
  i = !0;
1094
1118
  }
1095
- o && (t.complete = !1), r && !s && !i && (t.complete = !1);
1119
+ o && (t.complete = !1), r && !a && !i && (t.complete = !1);
1096
1120
  }
1097
- function Z(e, t) {
1121
+ function ee(e, t) {
1098
1122
  if (e && !t.visitedGroups.has(e.id)) {
1099
1123
  t.visitedGroups.add(e.id);
1100
1124
  for (const n of e.conditions || [])
1101
1125
  E(n.field, t);
1102
1126
  for (const n of e.groups || [])
1103
- Z(n, t);
1127
+ ee(n, t);
1104
1128
  }
1105
1129
  }
1106
1130
  function F(e, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set()) {
@@ -1112,54 +1136,54 @@ function F(e, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set()) {
1112
1136
  includeMetricFilterDatasets: e
1113
1137
  };
1114
1138
  }
1115
- function ee(e, t) {
1139
+ function te(e, t) {
1116
1140
  var r;
1117
1141
  const n = (r = e.qualifiedEntityName) != null && r.includes(".") ? e.qualifiedEntityName : void 0;
1118
1142
  return t === "qualifiedOnly" ? n : t === "preferQualified" ? n || e.entityName || void 0 : e.entityName || void 0;
1119
1143
  }
1120
- function qn(e) {
1144
+ function Un(e) {
1121
1145
  const t = F(!1);
1122
1146
  return E(e, t), { datasets: Array.from(t.found.values()), complete: t.complete };
1123
1147
  }
1124
- function Ke(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), a = M) {
1125
- const s = { ...M, ...a }, i = F(s.includeMetricFilterDatasets, n, r);
1148
+ function Ne(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = R) {
1149
+ const a = { ...R, ...s }, i = F(a.includeMetricFilterDatasets, n, r);
1126
1150
  E(e, i), i.found.forEach((o) => {
1127
- const c = ee(o, s.preferQualifiedIdentity ? "preferQualified" : "name");
1151
+ const c = te(o, a.preferQualifiedIdentity ? "preferQualified" : "name");
1128
1152
  c && t.add(c);
1129
1153
  });
1130
1154
  }
1131
- function Bn(e, t) {
1132
- Ke(e, t, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), {
1155
+ function zn(e, t) {
1156
+ Ne(e, t, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), {
1133
1157
  preferQualifiedIdentity: !0
1134
1158
  });
1135
1159
  }
1136
- function jn(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
1137
- const a = F(!0, n, r);
1138
- E(e, a), a.found.forEach((s) => {
1139
- const i = ee(s, "qualifiedOnly");
1160
+ function Wn(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
1161
+ const s = F(!0, n, r);
1162
+ E(e, s), s.found.forEach((a) => {
1163
+ const i = te(a, "qualifiedOnly");
1140
1164
  i && t.add(i);
1141
1165
  });
1142
1166
  }
1143
- function Un(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
1144
- Ke(e, t, n, r, {
1167
+ function Qn(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
1168
+ Ne(e, t, n, r, {
1145
1169
  includeMetricFilterDatasets: !1
1146
1170
  });
1147
1171
  }
1148
- function zn(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), a = M) {
1149
- const s = { ...M, ...a }, i = F(s.includeMetricFilterDatasets, n, r);
1150
- Z(e, i), i.found.forEach((o) => {
1151
- const c = ee(o, s.preferQualifiedIdentity ? "preferQualified" : "name");
1172
+ function Gn(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = R) {
1173
+ const a = { ...R, ...s }, i = F(a.includeMetricFilterDatasets, n, r);
1174
+ ee(e, i), i.found.forEach((o) => {
1175
+ const c = te(o, a.preferQualifiedIdentity ? "preferQualified" : "name");
1152
1176
  c && t.add(c);
1153
1177
  });
1154
1178
  }
1155
- function Wn(e, t) {
1179
+ function Yn(e, t) {
1156
1180
  return t != null && t[e] ? t[e] : (e.includes(".") ? e.slice(e.lastIndexOf(".") + 1) : e).replace(/[_-]+/g, " ").replace(/([a-z])([A-Z])/g, "$1 $2").replace(/\s+/g, " ").trim().replace(/\b\w/g, (r) => r.toUpperCase());
1157
1181
  }
1158
- const Qn = {
1182
+ const Jn = {
1159
1183
  database: null,
1160
1184
  schema: null,
1161
1185
  table: null
1162
- }, Gn = "__card_default__", Nt = {
1186
+ }, Hn = "__card_default__", xt = {
1163
1187
  date: /* @__PURE__ */ new Set([
1164
1188
  "between",
1165
1189
  "not between",
@@ -1198,14 +1222,14 @@ const Qn = {
1198
1222
  ]),
1199
1223
  boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
1200
1224
  };
1201
- function Ot(e) {
1202
- const t = G(e);
1225
+ function Mt(e) {
1226
+ const t = Y(e);
1203
1227
  return t === "number" || t === "boolean" ? t : t === "date" || t === "datetime" ? "date" : "string";
1204
1228
  }
1205
- function Yn(e, t) {
1206
- return typeof t != "string" ? !1 : Nt[Ot(e)].has(t);
1229
+ function Xn(e, t) {
1230
+ return typeof t != "string" ? !1 : xt[Mt(e)].has(t);
1207
1231
  }
1208
- const Dt = /* @__PURE__ */ new Set([
1232
+ const Rt = /* @__PURE__ */ new Set([
1209
1233
  "=",
1210
1234
  ">",
1211
1235
  "<",
@@ -1221,47 +1245,53 @@ const Dt = /* @__PURE__ */ new Set([
1221
1245
  "is null",
1222
1246
  "is not null"
1223
1247
  ]);
1224
- function xt(e, t) {
1248
+ function _t(e, t) {
1225
1249
  return t === "number" ? typeof e == "number" && Number.isFinite(e) : t === "boolean" ? typeof e == "boolean" : t === "date" ? e instanceof Date || typeof e == "string" && e.trim().length > 0 : typeof e == "string" || typeof e == "number" || typeof e == "boolean";
1226
1250
  }
1227
- function Rt(e, t, n, r) {
1228
- const a = Pe(e.relativeMeta);
1229
- if (a && je(a).dataAnchored) {
1251
+ function Ft(e, t, n, r) {
1252
+ const s = Le(e.relativeMeta);
1253
+ if (s && We(s).dataAnchored) {
1230
1254
  r.push(
1231
1255
  `${n}.relativeMeta counts back from the latest data; a dashboard filter's dates run to now. Use a period counted back from today.`
1232
1256
  );
1233
1257
  return;
1234
1258
  }
1235
- Mt(e.operation, e.values, t, `${n}.values`, r);
1259
+ if (s && !qe(String(e.operation), s)) {
1260
+ r.push(
1261
+ `${n}.relativeMeta runs only under between, not between, before, after, on or before, or on or after.`
1262
+ );
1263
+ return;
1264
+ }
1265
+ Vt(e.operation, e.values, t, `${n}.values`, r);
1236
1266
  }
1237
- function Mt(e, t, n, r, a) {
1267
+ function Vt(e, t, n, r, s) {
1238
1268
  if (e === "is null" || e === "is not null") {
1239
- t.length !== 0 && a.push(`${r} must be empty for null filter operations.`);
1269
+ t.length !== 0 && s.push(`${r} must be empty for null filter operations.`);
1240
1270
  return;
1241
1271
  }
1242
1272
  if (e === "between" || e === "not between") {
1243
1273
  if (t.length !== 2) {
1244
- a.push(
1274
+ s.push(
1245
1275
  `${r} must contain exactly two values for between operations.`
1246
1276
  );
1247
1277
  return;
1248
1278
  }
1249
1279
  } else if (e === "in" || e === "not in") {
1250
1280
  if (t.length === 0) {
1251
- a.push(
1281
+ s.push(
1252
1282
  `${r} must contain at least one value for set operations.`
1253
1283
  );
1254
1284
  return;
1255
1285
  }
1256
1286
  } else if (t.length !== 1) {
1257
- a.push(
1287
+ s.push(
1258
1288
  `${r} must contain exactly one value for '${String(e)}' operations.`
1259
1289
  );
1260
1290
  return;
1261
1291
  }
1262
- for (const s of t)
1263
- if (!xt(s, n)) {
1264
- a.push(
1292
+ for (const a of t)
1293
+ if (!_t(a, n)) {
1294
+ s.push(
1265
1295
  `${r} contains a value that is incompatible with valueType '${n}'.`
1266
1296
  );
1267
1297
  return;
@@ -1275,11 +1305,11 @@ const Q = {
1275
1305
  tableSettingsMaxBytes: 65536,
1276
1306
  rememberedTableSettingsMaxBytes: 262144,
1277
1307
  bookmarkStateMaxBytes: 65536
1278
- }, Ne = 1;
1279
- function Jn(e) {
1308
+ }, Oe = 1;
1309
+ function Zn(e) {
1280
1310
  return new TextEncoder().encode(JSON.stringify(e ?? null)).length;
1281
1311
  }
1282
- function _t(e) {
1312
+ function $t(e) {
1283
1313
  const t = encodeURIComponent;
1284
1314
  switch (e.kind) {
1285
1315
  case "dimension":
@@ -1292,7 +1322,7 @@ function _t(e) {
1292
1322
  return `result:${t(e.key)}`;
1293
1323
  }
1294
1324
  }
1295
- function N(e) {
1325
+ function D(e) {
1296
1326
  if (e)
1297
1327
  try {
1298
1328
  return decodeURIComponent(e);
@@ -1300,28 +1330,28 @@ function N(e) {
1300
1330
  return;
1301
1331
  }
1302
1332
  }
1303
- function Ft(e) {
1333
+ function Pt(e) {
1304
1334
  if (typeof e != "string") return;
1305
1335
  const t = e.split(":");
1306
1336
  let n;
1307
1337
  if (t[0] === "dim" && t.length === 3) {
1308
- const r = t[1], a = N(t[2]);
1309
- (r === "detail" || r === "groupby") && a && (n = { kind: "dimension", role: r, fieldId: a });
1338
+ const r = t[1], s = D(t[2]);
1339
+ (r === "detail" || r === "groupby") && s && (n = { kind: "dimension", role: r, fieldId: s });
1310
1340
  } else if (t[0] === "metric" && t.length === 3) {
1311
- const r = N(t[1]), a = N(t[2]);
1312
- r && a && (n = { kind: "metric", metricId: r, metricAlias: a });
1341
+ const r = D(t[1]), s = D(t[2]);
1342
+ r && s && (n = { kind: "metric", metricId: r, metricAlias: s });
1313
1343
  } else if (t[0] === "result" && t.length === 2) {
1314
- const r = N(t[1]);
1344
+ const r = D(t[1]);
1315
1345
  r && (n = { kind: "result", key: r });
1316
1346
  }
1317
- return n && _t(n) === e ? n : void 0;
1347
+ return n && $t(n) === e ? n : void 0;
1318
1348
  }
1319
- function D(e) {
1320
- return typeof e == "string" && Ft(e) !== void 0;
1349
+ function O(e) {
1350
+ return typeof e == "string" && Pt(e) !== void 0;
1321
1351
  }
1322
- const pe = l.array(l.string()).max(2e3), Vt = l.object({
1323
- order: pe.optional(),
1324
- hidden: pe.optional(),
1352
+ const he = l.array(l.string()).max(2e3), Lt = l.object({
1353
+ order: he.optional(),
1354
+ hidden: he.optional(),
1325
1355
  labels: l.record(l.string(), l.string().max(Q.columnLabelMaxChars)).optional(),
1326
1356
  sort: l.array(
1327
1357
  l.object({
@@ -1334,85 +1364,92 @@ const pe = l.array(l.string()).max(2e3), Vt = l.object({
1334
1364
  l.number().int().min(1).max(Q.columnWidthMaxPx)
1335
1365
  ).optional()
1336
1366
  }).strict();
1337
- function he(e) {
1367
+ function G(e) {
1338
1368
  const t = /* @__PURE__ */ new Set(), n = [];
1339
1369
  for (const r of e)
1340
- !D(r) || t.has(r) || (t.add(r), n.push(r));
1370
+ !O(r) || t.has(r) || (t.add(r), n.push(r));
1341
1371
  return n;
1342
1372
  }
1343
- function Oe(e) {
1373
+ function er(e) {
1374
+ if (!Array.isArray(e)) return;
1375
+ const t = G(
1376
+ e.filter((n) => typeof n == "string")
1377
+ );
1378
+ return t.length ? t : void 0;
1379
+ }
1380
+ function xe(e) {
1344
1381
  if (!e) return;
1345
- const t = e.order ? he(e.order) : void 0, n = e.hidden ? he(e.hidden) : void 0, r = Object.entries(e.labels ?? {}).flatMap(
1382
+ const t = e.order ? G(e.order) : void 0, n = e.hidden ? G(e.hidden) : void 0, r = Object.entries(e.labels ?? {}).flatMap(
1346
1383
  ([c, u]) => {
1347
1384
  const d = typeof u == "string" ? u.trim() : "";
1348
- return D(c) && d ? [
1385
+ return O(c) && d ? [
1349
1386
  [
1350
1387
  c,
1351
1388
  d.slice(0, Q.columnLabelMaxChars)
1352
1389
  ]
1353
1390
  ] : [];
1354
1391
  }
1355
- ), a = /* @__PURE__ */ new Set(), s = e.sort ? e.sort.filter((c) => !D(c.columnId) || a.has(c.columnId) ? !1 : (a.add(c.columnId), !0)) : void 0, i = Object.entries(e.widths ?? {}).filter(
1356
- ([c]) => D(c)
1392
+ ), s = /* @__PURE__ */ new Set(), a = e.sort ? e.sort.filter((c) => !O(c.columnId) || s.has(c.columnId) ? !1 : (s.add(c.columnId), !0)) : void 0, i = Object.entries(e.widths ?? {}).filter(
1393
+ ([c]) => O(c)
1357
1394
  ), o = {};
1358
- return t != null && t.length && (o.order = t), n != null && n.length && (o.hidden = n), r.length && (o.labels = Object.fromEntries(r)), s && (o.sort = s.map(({ columnId: c, direction: u }) => ({
1395
+ return t != null && t.length && (o.order = t), n != null && n.length && (o.hidden = n), r.length && (o.labels = Object.fromEntries(r)), a && (o.sort = a.map(({ columnId: c, direction: u }) => ({
1359
1396
  columnId: c,
1360
1397
  direction: u
1361
1398
  }))), i.length && (o.widths = Object.fromEntries(i)), Object.keys(o).length ? o : void 0;
1362
1399
  }
1363
- function Hn(e) {
1400
+ function tr(e) {
1364
1401
  var t, n;
1365
1402
  return !!((t = e == null ? void 0 : e.order) != null && t.length) || !!((n = e == null ? void 0 : e.hidden) != null && n.length) || Object.keys((e == null ? void 0 : e.labels) ?? {}).length > 0 || Object.keys((e == null ? void 0 : e.widths) ?? {}).length > 0;
1366
1403
  }
1367
- function De(e) {
1368
- return Oe(e) === void 0;
1404
+ function Me(e) {
1405
+ return xe(e) === void 0;
1369
1406
  }
1370
- function xe(e, t) {
1371
- if (t !== Ne)
1407
+ function Re(e, t) {
1408
+ if (t !== Oe)
1372
1409
  return {
1373
1410
  ok: !1,
1374
1411
  error: `Unsupported table settings version ${t}.`
1375
1412
  };
1376
- const n = Vt.safeParse(e);
1413
+ const n = Lt.safeParse(e);
1377
1414
  return n.success ? {
1378
1415
  ok: !0,
1379
- value: Oe(n.data) ?? {}
1416
+ value: xe(n.data) ?? {}
1380
1417
  } : { ok: !1, error: "Table settings are invalid." };
1381
1418
  }
1382
- function Xn(e, t, n) {
1419
+ function nr(e, t, n) {
1383
1420
  if (!e || typeof e != "object" || Array.isArray(e)) return {};
1384
1421
  const r = {};
1385
- for (const [a, s] of Object.entries(
1422
+ for (const [s, a] of Object.entries(
1386
1423
  e
1387
1424
  )) {
1388
- if (!n.has(a)) continue;
1389
- const i = xe(s, t);
1390
- i.ok && !De(i.value) && (r[a] = i.value);
1425
+ if (!n.has(s)) continue;
1426
+ const i = Re(a, t);
1427
+ i.ok && !Me(i.value) && (r[s] = i.value);
1391
1428
  }
1392
1429
  return r;
1393
1430
  }
1394
- const Pt = /* @__PURE__ */ new Set([
1431
+ const qt = /* @__PURE__ */ new Set([
1395
1432
  "table",
1396
1433
  "detailTable"
1397
1434
  ]);
1398
- function Re(e) {
1399
- return Pt.has(e.type);
1435
+ function _e(e) {
1436
+ return qt.has(e.type);
1400
1437
  }
1401
- function Lt(e) {
1438
+ function Bt(e) {
1402
1439
  var t, n;
1403
- return Re(e) && ((n = (t = e.preferences) == null ? void 0 : t.tablePrefs) == null ? void 0 : n.allowViewerColumnCustomization) !== !1;
1440
+ return _e(e) && ((n = (t = e.preferences) == null ? void 0 : t.tablePrefs) == null ? void 0 : n.allowViewerColumnCustomization) !== !1;
1404
1441
  }
1405
- function Zn(e) {
1442
+ function rr(e) {
1406
1443
  return new Set(
1407
- T(e).filter(({ card: t }) => Re(t)).map(({ card: t }) => t.id)
1444
+ T(e).filter(({ card: t }) => _e(t)).map(({ card: t }) => t.id)
1408
1445
  );
1409
1446
  }
1410
- function er(e) {
1447
+ function sr(e) {
1411
1448
  return new Set(
1412
- T(e).filter(({ card: t }) => Lt(t)).map(({ card: t }) => t.id)
1449
+ T(e).filter(({ card: t }) => Bt(t)).map(({ card: t }) => t.id)
1413
1450
  );
1414
1451
  }
1415
- const $ = 1, tr = ["PRIVATE", "TEAM", "DASHBOARD"], $t = l.object({
1452
+ const L = 1, ar = ["PRIVATE", "TEAM", "DASHBOARD"], jt = l.object({
1416
1453
  filterId: l.string().min(1),
1417
1454
  name: l.string(),
1418
1455
  operation: l.string(),
@@ -1420,22 +1457,22 @@ const $ = 1, tr = ["PRIVATE", "TEAM", "DASHBOARD"], $t = l.object({
1420
1457
  values: l.array(l.unknown())
1421
1458
  }).passthrough().superRefine((e, t) => {
1422
1459
  const n = [];
1423
- Dt.has(e.operation) ? Rt(e, e.valueType, "filterValue", n) : n.push("filterValue.operation must be a valid filter operation.");
1460
+ Rt.has(e.operation) ? Ft(e, e.valueType, "filterValue", n) : n.push("filterValue.operation must be a valid filter operation.");
1424
1461
  for (const r of n) t.addIssue({ code: "custom", message: r });
1425
1462
  }), q = l.unknown().superRefine((e, t) => {
1426
- for (const n of Ue(e).errors)
1463
+ for (const n of Qe(e).errors)
1427
1464
  t.addIssue({ code: "custom", message: n.message });
1428
- }), qt = l.discriminatedUnion("kind", [
1429
- l.object({ kind: l.literal("filter"), filterValue: $t }).strict(),
1465
+ }), Ut = l.discriminatedUnion("kind", [
1466
+ l.object({ kind: l.literal("filter"), filterValue: jt }).strict(),
1430
1467
  l.object({ kind: l.literal("control"), value: l.unknown() }).strict(),
1431
1468
  l.object({
1432
1469
  kind: l.literal("selection"),
1433
- selection: Le
1470
+ selection: Be
1434
1471
  }).strict()
1435
- ]), Bt = l.union([
1472
+ ]), zt = l.union([
1436
1473
  l.object({
1437
1474
  status: l.literal("set"),
1438
- value: qt,
1475
+ value: Ut,
1439
1476
  comparisonSelection: q.optional()
1440
1477
  }).strict(),
1441
1478
  l.object({
@@ -1443,7 +1480,7 @@ const $ = 1, tr = ["PRIVATE", "TEAM", "DASHBOARD"], $t = l.object({
1443
1480
  comparisonSelection: q.optional()
1444
1481
  }).strict(),
1445
1482
  l.object({ comparisonSelection: q }).strict()
1446
- ]), Me = ["bySheetId", "byCardId", "byDocumentSectionId"], jt = /* @__PURE__ */ new Set(["version", "selectedSheetId", "inputs", "tableSettings"]), Ut = /* @__PURE__ */ new Set(["shared", ...Me]), A = (e) => !!e && typeof e == "object" && !Array.isArray(e);
1483
+ ]), Fe = ["bySheetId", "byCardId", "byDocumentSectionId"], Wt = /* @__PURE__ */ new Set(["version", "selectedSheetId", "inputs", "tableSettings"]), Qt = /* @__PURE__ */ new Set(["shared", ...Fe]), A = (e) => !!e && typeof e == "object" && !Array.isArray(e);
1447
1484
  function ye(e, t, n) {
1448
1485
  if (e === void 0) return;
1449
1486
  if (!A(e)) {
@@ -1451,31 +1488,31 @@ function ye(e, t, n) {
1451
1488
  return;
1452
1489
  }
1453
1490
  const r = {};
1454
- for (const [a, s] of Object.entries(e)) {
1455
- const i = a ? Bt.safeParse(s) : void 0;
1456
- i != null && i.success ? r[a] = i.data : t.push({
1457
- target: $e(a) ? "selection" : "input",
1458
- id: a
1491
+ for (const [s, a] of Object.entries(e)) {
1492
+ const i = s ? zt.safeParse(a) : void 0;
1493
+ i != null && i.success ? r[s] = i.data : t.push({
1494
+ target: je(s) ? "selection" : "input",
1495
+ id: s
1459
1496
  });
1460
1497
  }
1461
1498
  return Object.keys(r).length ? r : void 0;
1462
1499
  }
1463
- function zt(e, t) {
1464
- if (t !== $)
1500
+ function Gt(e, t) {
1501
+ if (t !== L)
1465
1502
  return { ok: !1, error: `Unsupported bookmark version ${t}.` };
1466
- if (!A(e) || e.version !== $)
1503
+ if (!A(e) || e.version !== L)
1467
1504
  return { ok: !1, error: "The bookmark state is invalid." };
1468
- const n = [], r = Object.keys(e).filter((o) => !jt.has(o));
1469
- let a;
1470
- typeof e.selectedSheetId == "string" && e.selectedSheetId ? a = e.selectedSheetId : e.selectedSheetId !== void 0 && n.push({ target: "sheet", id: String(e.selectedSheetId) });
1471
- const s = {};
1505
+ const n = [], r = Object.keys(e).filter((o) => !Wt.has(o));
1506
+ let s;
1507
+ typeof e.selectedSheetId == "string" && e.selectedSheetId ? s = e.selectedSheetId : e.selectedSheetId !== void 0 && n.push({ target: "sheet", id: String(e.selectedSheetId) });
1508
+ const a = {};
1472
1509
  if (A(e.inputs)) {
1473
1510
  r.push(
1474
- ...Object.keys(e.inputs).filter((c) => !Ut.has(c)).map((c) => `inputs.${c}`)
1511
+ ...Object.keys(e.inputs).filter((c) => !Qt.has(c)).map((c) => `inputs.${c}`)
1475
1512
  );
1476
1513
  const o = ye(e.inputs.shared, n, "shared");
1477
- o && (s.shared = o);
1478
- for (const c of Me) {
1514
+ o && (a.shared = o);
1515
+ for (const c of Fe) {
1479
1516
  const u = e.inputs[c];
1480
1517
  if (u === void 0) continue;
1481
1518
  if (!A(u)) {
@@ -1487,140 +1524,143 @@ function zt(e, t) {
1487
1524
  const h = ye(y, n, `${c}.${f}`);
1488
1525
  h && (d[f] = h);
1489
1526
  }
1490
- Object.keys(d).length && (s[c] = d);
1527
+ Object.keys(d).length && (a[c] = d);
1491
1528
  }
1492
1529
  } else e.inputs !== void 0 && r.push("inputs");
1493
1530
  const i = {};
1494
1531
  if (A(e.tableSettings))
1495
1532
  for (const [o, c] of Object.entries(e.tableSettings)) {
1496
- const u = o ? xe(c, Ne) : void 0;
1497
- u != null && u.ok ? De(u.value) || (i[o] = u.value) : n.push({ target: "card", id: o });
1533
+ const u = o ? Re(c, Oe) : void 0;
1534
+ u != null && u.ok ? Me(u.value) || (i[o] = u.value) : n.push({ target: "card", id: o });
1498
1535
  }
1499
1536
  else e.tableSettings !== void 0 && r.push("tableSettings");
1500
1537
  return {
1501
1538
  ok: !0,
1502
1539
  value: {
1503
- version: $,
1504
- ...a ? { selectedSheetId: a } : {},
1505
- ...Object.keys(s).length ? { inputs: s } : {},
1540
+ version: L,
1541
+ ...s ? { selectedSheetId: s } : {},
1542
+ ...Object.keys(a).length ? { inputs: a } : {},
1506
1543
  ...Object.keys(i).length ? { tableSettings: i } : {}
1507
1544
  },
1508
1545
  issues: n,
1509
1546
  unknownKeys: r
1510
1547
  };
1511
1548
  }
1512
- function nr(e, t) {
1513
- const n = zt(e, t);
1549
+ function ir(e, t) {
1550
+ const n = Gt(e, t);
1514
1551
  return n.ok ? n.issues.some((r) => r.target === "card") ? { ok: !1, error: "The bookmark table settings are invalid." } : n.issues.length || n.unknownKeys.length ? { ok: !1, error: "The bookmark state is invalid." } : { ok: !0, value: n.value } : n;
1515
1552
  }
1516
1553
  export {
1517
- Zt as $,
1518
- _ as A,
1519
- $ as B,
1520
- Gn as C,
1521
- C as D,
1522
- Qn as E,
1523
- un as F,
1524
- xn as G,
1525
- An as H,
1526
- We as I,
1527
- wt as J,
1528
- st as K,
1529
- bt as L,
1530
- mn as M,
1531
- de as N,
1532
- et as O,
1533
- on as P,
1534
- ge as Q,
1535
- hn as R,
1536
- Kn as S,
1537
- In as T,
1538
- J as U,
1554
+ re as $,
1555
+ qn as A,
1556
+ L as B,
1557
+ Hn as C,
1558
+ _ as D,
1559
+ Jn as E,
1560
+ C as F,
1561
+ fn as G,
1562
+ _n as H,
1563
+ Tn as I,
1564
+ Ye as J,
1565
+ Tt as K,
1566
+ ot as L,
1567
+ gt as M,
1568
+ yn as N,
1569
+ le as O,
1570
+ rt as P,
1571
+ dn as Q,
1572
+ ge as R,
1573
+ bn as S,
1574
+ On as T,
1575
+ Cn as U,
1539
1576
  Q as V,
1540
- wn as W,
1541
- ct as X,
1542
- ne as Y,
1543
- re as Z,
1544
- Qe as _,
1545
- $n as a,
1546
- Ge as a0,
1547
- en as a1,
1548
- cn as a2,
1549
- dn as a3,
1550
- ln as a4,
1551
- fn as a5,
1552
- pn as a6,
1553
- yn as a7,
1554
- Ae as a8,
1555
- R as a9,
1556
- _n as aA,
1557
- nn as aB,
1558
- He as aC,
1559
- v as aD,
1560
- Y as aE,
1561
- Cn as aF,
1562
- kn as aG,
1563
- gn as aH,
1564
- T as aI,
1565
- it as aJ,
1566
- Sn as aK,
1567
- se as aL,
1568
- bn as aM,
1569
- Mn as aN,
1570
- Ye as aO,
1571
- Fn as aP,
1572
- Vn as aQ,
1573
- Ln as aR,
1574
- tn as aS,
1575
- ut as aa,
1576
- S as ab,
1577
- ve as ac,
1578
- dt as ad,
1579
- lt as ae,
1580
- vn as af,
1581
- H as ag,
1582
- ft as ah,
1583
- Tn as ai,
1584
- En as aj,
1585
- Nn as ak,
1586
- On as al,
1587
- Dn as am,
1588
- rn as an,
1589
- Ze as ao,
1590
- sn as ap,
1591
- an as aq,
1592
- ke as ar,
1593
- St as as,
1594
- Ct as at,
1595
- gt as au,
1596
- Rn as av,
1597
- Ot as aw,
1598
- Yn as ax,
1599
- Dt as ay,
1600
- Rt as az,
1601
- Bn as b,
1602
- Ke as c,
1603
- Ee as d,
1604
- jn as e,
1605
- Un as f,
1606
- zn as g,
1607
- Wn as h,
1608
- zt as i,
1609
- Ne as j,
1610
- Ft as k,
1611
- Hn as l,
1612
- Jn as m,
1613
- Oe as n,
1614
- De as o,
1615
- nr as p,
1616
- xe as q,
1617
- qn as r,
1618
- Xn as s,
1619
- _t as t,
1620
- Re as u,
1621
- Lt as v,
1622
- Zn as w,
1623
- er as x,
1624
- tr as y,
1625
- Pn as z
1577
+ H as W,
1578
+ Ae as X,
1579
+ lt as Y,
1580
+ ve as Z,
1581
+ En as _,
1582
+ jn as a,
1583
+ se as a0,
1584
+ Je as a1,
1585
+ nn as a2,
1586
+ He as a3,
1587
+ rn as a4,
1588
+ ln as a5,
1589
+ mn as a6,
1590
+ pn as a7,
1591
+ hn as a8,
1592
+ In as a9,
1593
+ Xn as aA,
1594
+ Rt as aB,
1595
+ Ft as aC,
1596
+ $n as aD,
1597
+ an as aE,
1598
+ et as aF,
1599
+ v as aG,
1600
+ T as aH,
1601
+ ut as aI,
1602
+ kn as aJ,
1603
+ J as aK,
1604
+ ae as aL,
1605
+ wn as aM,
1606
+ gn as aN,
1607
+ Vn as aO,
1608
+ vn as aP,
1609
+ An as aQ,
1610
+ Xe as aR,
1611
+ Pn as aS,
1612
+ Ln as aT,
1613
+ Bn as aU,
1614
+ sn as aV,
1615
+ Sn as aa,
1616
+ Te as ab,
1617
+ M as ac,
1618
+ ft as ad,
1619
+ S as ae,
1620
+ Ee as af,
1621
+ mt as ag,
1622
+ pt as ah,
1623
+ Kn as ai,
1624
+ X as aj,
1625
+ ht as ak,
1626
+ Dn as al,
1627
+ Nn as am,
1628
+ xn as an,
1629
+ Mn as ao,
1630
+ Rn as ap,
1631
+ on as aq,
1632
+ nt as ar,
1633
+ cn as as,
1634
+ un as at,
1635
+ ke as au,
1636
+ kt as av,
1637
+ wt as aw,
1638
+ At as ax,
1639
+ Fn as ay,
1640
+ Mt as az,
1641
+ zn as b,
1642
+ Ne as c,
1643
+ De as d,
1644
+ Wn as e,
1645
+ Qn as f,
1646
+ Gn as g,
1647
+ Yn as h,
1648
+ Gt as i,
1649
+ Oe as j,
1650
+ Pt as k,
1651
+ xe as l,
1652
+ Zn as m,
1653
+ er as n,
1654
+ tr as o,
1655
+ ir as p,
1656
+ Me as q,
1657
+ Un as r,
1658
+ Re as s,
1659
+ $t as t,
1660
+ nr as u,
1661
+ _e as v,
1662
+ Bt as w,
1663
+ rr as x,
1664
+ sr as y,
1665
+ ar as z
1626
1666
  };