react-semaphor 0.1.560 → 0.1.562

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/dist/analytics-protocol/index.js +450 -423
  2. package/dist/assistant-context/index.js +1 -1
  3. package/dist/assistant-protocol/index.js +5 -5
  4. package/dist/brand-studio/index.js +9 -9
  5. package/dist/briefings/index.js +5 -5
  6. package/dist/chunks/{analytics-base-schemas-CHLxsPfX.js → analytics-base-schemas-BaIQrEzX.js} +221 -188
  7. package/dist/chunks/{assistant-chat-Bu2fFm_I.js → assistant-chat-R_yT8xH4.js} +116 -117
  8. package/dist/chunks/bookmark-impact-D4Kl4amw.js +75 -0
  9. package/dist/chunks/bookmark-state-CWeoGbrx.js +743 -0
  10. package/dist/chunks/{braces-Da41xfUd.js → braces-DzgoQC64.js} +1 -1
  11. package/dist/chunks/{comparison-window-caption-4FNkMrzE.js → comparison-window-caption-D1EUXzaR.js} +550 -425
  12. package/dist/chunks/{context-BgPDzLHZ.js → context-R31TSL5V.js} +1 -1
  13. package/dist/chunks/{dashboard-_MeBuy67.js → dashboard-Bp1y5oun.js} +1 -1
  14. package/dist/chunks/{dashboard-briefing-launcher-CEi4Pr_v.js → dashboard-briefing-launcher-S5FB3aUW.js} +236 -236
  15. package/dist/chunks/dashboard-controls-CfC_6Ztn.js +2277 -0
  16. package/dist/chunks/{dashboard-json-B1mU_OMa.js → dashboard-json-gYZT7ZQY.js} +5 -5
  17. package/dist/chunks/dates-DFY7Gfss.js +91 -0
  18. package/dist/chunks/{edit-dashboard-visual-0CJN31Y3.js → edit-dashboard-visual-u7OI_g8Q.js} +7119 -7198
  19. package/dist/chunks/filter-reach-copy-CvV7W5dd.js +3965 -0
  20. package/dist/chunks/{filter-value-text-CRC-K_l_.js → filter-value-text-CPwFkrMz.js} +11 -10
  21. package/dist/chunks/global-date-filter-utils-N1kcsOFE.js +16722 -0
  22. package/dist/chunks/{index-DtHidOPV.js → index-CNGkfUp4.js} +269 -264
  23. package/dist/chunks/{layout-grid-BvsH4RY2.js → layout-grid-BM65viQh.js} +1 -1
  24. package/dist/chunks/{list-filter-Dg0otx5E.js → list-filter-BoeLBfL3.js} +1 -1
  25. package/dist/chunks/{matrix-analytical-definition-CM18W8w6.js → matrix-analytical-definition-hEucouWM.js} +4 -4
  26. package/dist/chunks/{matrix-card-HPskLaPy.js → matrix-card-CCh9JjP1.js} +3 -3
  27. package/dist/chunks/{matrix-member-presentation-Bbrfrke4.js → matrix-member-presentation-DsAUbuoL.js} +1 -1
  28. package/dist/chunks/{matrix-operation-contract-WPv4R-H_.js → matrix-operation-contract-DsLdFdSa.js} +365 -349
  29. package/dist/chunks/{metric-comparison-ljMKYZKa.js → metric-comparison-Bnso1cm1.js} +6 -6
  30. package/dist/chunks/{model-change-Ccn1zaxl.js → model-change-T1cRkh3m.js} +1 -1
  31. package/dist/chunks/{palette-Bsh376zO.js → palette-p1XSJFgB.js} +1 -1
  32. package/dist/chunks/pivot-result-contract-expectations-B53jqszr.js +56 -0
  33. package/dist/chunks/{pivot-result-identity-vS9TSh4f.js → pivot-result-identity-Dq5jm-EC.js} +1 -1
  34. package/dist/chunks/{zoned-wall-clock-B1n_WjW3.js → raw-temporal-value-Bqz8wc7L.js} +97 -46
  35. package/dist/chunks/{report-preferences-dialog-BV8L0SeS.js → report-preferences-dialog-C4RAR8u5.js} +68 -63
  36. package/dist/chunks/{report-runtime-context-BZQh9ywy.js → report-runtime-context-BITkNSDa.js} +2 -2
  37. package/dist/chunks/resolve-dashboard-input-context-DaDrZGuA.js +8214 -0
  38. package/dist/chunks/{save-B5EAsgQF.js → save-CHV1B1fL.js} +1 -1
  39. package/dist/chunks/{saved-dashboard-context-n2Wn11cV.js → saved-dashboard-context-DFYBrE6O.js} +93 -94
  40. package/dist/chunks/{selection-filter-compiler-BKXmyLrS.js → selection-filter-compiler-CUDRnUxc.js} +19 -18
  41. package/dist/chunks/{selection-reducer-D0YnaAD9.js → selection-reducer-Bz5aywT4.js} +1 -1
  42. package/dist/chunks/{semaphor-ready-indicator-XLBLOJ2V.js → semaphor-ready-indicator-Cfuafnem.js} +38188 -40344
  43. package/dist/chunks/{shelf-drop-preview-context-DHMa54a-.js → shelf-drop-preview-context-BR2GEYog.js} +81 -82
  44. package/dist/chunks/{source-entity-resolution-dUG5VWRm.js → source-entity-resolution-DdDVXFB8.js} +6 -6
  45. package/dist/chunks/{switch-ByxH4M7t.js → switch-BW4yXSYs.js} +3 -3
  46. package/dist/chunks/{table-export-sheet-C_GdeTYU.js → table-export-sheet-bSXxGn-v.js} +1 -1
  47. package/dist/chunks/temporal-input-presentation-sk9gqLi6.js +4960 -0
  48. package/dist/chunks/{token-types-CQtXUVMy.js → token-types-BUK06hU2.js} +1 -1
  49. package/dist/chunks/{upload-wbR-NVzq.js → upload-BnmuyPqW.js} +1 -1
  50. package/dist/chunks/{use-create-flow-overlay-state-CEBaLOKC.js → use-create-flow-overlay-state-DyzhWvRJ.js} +6 -6
  51. package/dist/chunks/{validators-CXTneCA4.js → validators-BIM0FE31.js} +774 -895
  52. package/dist/dashboard/index.js +2 -2
  53. package/dist/dashboard-authoring/index.js +2477 -2685
  54. package/dist/data-app-sdk/index.js +30 -30
  55. package/dist/data-app-sdk-adapters/index.js +3 -3
  56. package/dist/data-app-sdk-validation/index.js +25 -25
  57. package/dist/format-utils/index.js +274 -267
  58. package/dist/index.js +59 -59
  59. package/dist/report-runtime-context/index.js +2 -2
  60. package/dist/style.css +1 -1
  61. package/dist/surfboard/index.js +2 -2
  62. package/dist/types/briefings/attachment-outcomes.d.ts +1 -1
  63. package/dist/types/components/dashboard/dashboard-create-dialog.d.ts +23 -0
  64. package/dist/types/components/dashboard/summary-number-formatter.d.ts +6 -0
  65. package/dist/types/components/index.d.ts +1 -2
  66. package/dist/types/components/surfboard/filter/types.d.ts +3 -1
  67. package/dist/types/index.js +50 -51
  68. package/dist/types/lib/formatters/kpi-number-formatter.d.ts +41 -0
  69. package/dist/types/lib/formatters/raw-temporal-presentation.d.ts +59 -2
  70. package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +5 -0
  71. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +45 -0
  72. package/dist/types/lib/print/print-inputs.d.ts +2 -1
  73. package/dist/types/lib/query-context/assemble-card-query.d.ts +2 -0
  74. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -0
  75. package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
  76. package/dist/types/lib/stores/editor-store.d.ts +9 -1
  77. package/dist/types/lib/stores/table-actions.d.ts +0 -2
  78. package/dist/types/lib/types/common-types.d.ts +6 -0
  79. package/dist/types/lib/types/explorer-types.d.ts +7 -1
  80. package/dist/types/lib/types/interaction-types.d.ts +3 -1
  81. package/dist/types/lib/types/token-types.d.ts +0 -1
  82. package/dist/types/shared/analytics-protocol/analytics-base-schemas.d.ts +13 -1
  83. package/dist/types/shared/analytics-protocol/contracts.d.ts +9 -40
  84. package/dist/types/shared/analytics-protocol/measure-aggregation-profile.d.ts +12 -0
  85. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +12 -2
  86. package/dist/types/shared/analytics-protocol/validators.d.ts +1 -2
  87. package/dist/types/shared/assistant-protocol/context.d.ts +8 -8
  88. package/dist/types/shared/dashboard-authoring/card-formats/sql-date-pattern.d.ts +7 -1
  89. package/dist/types/shared/dashboard-authoring/card-settings/apply-card-settings.d.ts +11 -0
  90. package/dist/types/shared/dashboard-authoring/card-settings/card-display-write.d.ts +76 -0
  91. package/dist/types/shared/dashboard-authoring/card-settings/card-kinds.d.ts +14 -0
  92. package/dist/types/shared/dashboard-authoring/card-settings/carry-column-settings.d.ts +3 -0
  93. package/dist/types/shared/dashboard-authoring/card-settings/column-format-write.d.ts +8 -0
  94. package/dist/types/shared/dashboard-authoring/card-settings/column-names.d.ts +51 -0
  95. package/dist/types/shared/dashboard-authoring/card-settings/column-polarity-write.d.ts +5 -0
  96. package/dist/types/shared/dashboard-authoring/card-settings/column-sources.d.ts +14 -0
  97. package/dist/types/shared/dashboard-authoring/card-settings/confirm-class.d.ts +9 -0
  98. package/dist/types/shared/dashboard-authoring/card-settings/highlight-inputs.d.ts +19 -0
  99. package/dist/types/shared/dashboard-authoring/card-settings/index.d.ts +17 -0
  100. package/dist/types/shared/dashboard-authoring/card-settings/inputs.d.ts +117 -0
  101. package/dist/types/shared/dashboard-authoring/card-settings/read-card-settings.d.ts +10 -0
  102. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +14 -0
  103. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-settings.d.ts +59 -0
  104. package/dist/types/shared/dashboard-authoring/card-settings/resolved.d.ts +51 -0
  105. package/dist/types/shared/dashboard-authoring/card-settings/views.d.ts +30 -0
  106. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +6 -0
  107. package/dist/types/shared/dashboard-authoring/changes/card-types.d.ts +32 -0
  108. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +3402 -4313
  109. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +49 -8
  110. package/dist/types/shared/dashboard-authoring/changes/field-ref.d.ts +91 -0
  111. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +7 -0
  112. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +52 -2
  113. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-create.d.ts +26 -0
  114. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +2 -1
  115. package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +1 -8
  116. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +20 -20
  117. package/dist/types/shared/dashboard-authoring/detail-date-presentation.d.ts +9 -0
  118. package/dist/types/shared/dashboard-authoring/index.d.ts +11 -6
  119. package/dist/types/shared/dashboard-authoring/kpi-figure.d.ts +123 -0
  120. package/dist/types/shared/dashboard-authoring/measure-calculations/apply.d.ts +8 -0
  121. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +16 -0
  122. package/dist/types/shared/dashboard-authoring/measure-calculations/dates.d.ts +41 -0
  123. package/dist/types/shared/dashboard-authoring/measure-calculations/index.d.ts +17 -0
  124. package/dist/types/shared/dashboard-authoring/measure-calculations/options.d.ts +63 -0
  125. package/dist/types/shared/dashboard-authoring/measure-calculations/read.d.ts +16 -0
  126. package/dist/types/shared/dashboard-authoring/measure-calculations/resolve.d.ts +79 -0
  127. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +934 -0
  128. package/dist/types/shared/dashboard-authoring/measure-calculations/sentences.d.ts +4 -0
  129. package/dist/types/shared/dashboard-authoring/measure-calculations/set.d.ts +11 -0
  130. package/dist/types/shared/dashboard-authoring/measure-calculations/transform.d.ts +63 -0
  131. package/dist/types/shared/dashboard-authoring/measure-calculations/window-transforms.d.ts +60 -0
  132. package/dist/types/shared/dashboard-authoring/new-card.d.ts +12 -1
  133. package/dist/types/shared/dashboard-authoring/operations/apply-dashboard-operations.d.ts +2 -1
  134. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +46 -0
  135. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +73 -3
  136. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +21 -3
  137. package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +58 -0
  138. package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +55 -0
  139. package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +18 -0
  140. package/dist/types/shared/dashboard-viewer/bookmark-impact.d.ts +33 -0
  141. package/dist/types/shared/format-utils/document-print.d.ts +82 -0
  142. package/dist/types/shared/format-utils/formatters/matrix-formatter.d.ts +8 -1
  143. package/dist/types/shared/format-utils/index.d.ts +1 -0
  144. package/dist/types/shared/format-utils/raw-temporal.d.ts +18 -7
  145. package/dist/types/shared/temporal/index.d.ts +1 -0
  146. package/dist/types/shared/temporal/raw-temporal-equality.d.ts +19 -0
  147. package/dist/types/shared/temporal/raw-temporal-value.d.ts +29 -0
  148. package/dist/types/shared/temporal/zoned-wall-clock.d.ts +6 -0
  149. package/package.json +2 -2
  150. package/dist/chunks/bookmark-state-BFY9oNmr.js +0 -111
  151. package/dist/chunks/custom-visual-inputs-Dz-enUNR.js +0 -292
  152. package/dist/chunks/dashboard-controls-Bi7fyG-4.js +0 -2339
  153. package/dist/chunks/document-dashboard-inputs-CkWfDB8c.js +0 -3010
  154. package/dist/chunks/filter-reach-copy-BF4w4kI2.js +0 -3738
  155. package/dist/chunks/global-date-filter-utils-D8365uPH.js +0 -12889
  156. package/dist/chunks/pivot-result-contract-expectations-Bl5suy4-.js +0 -1832
  157. package/dist/chunks/raw-temporal-presentation-BHm7s-hz.js +0 -540
  158. package/dist/chunks/resolve-dashboard-input-context-CAMiWvyR.js +0 -5280
  159. package/dist/chunks/table-settings-Imz0FgWi.js +0 -637
  160. package/dist/chunks/temporal-input-presentation-uvNK_tM0.js +0 -3228
  161. package/dist/types/components/dashboard/ai-dashboard-create-dialog.d.ts +0 -38
  162. package/dist/types/components/dashboard/dashboard-create-template.d.ts +0 -10
  163. package/dist/types/lib/hooks/use-dashboard-authoring.d.ts +0 -49
  164. package/dist/types/shared/dashboard-authoring/artifact-compiler.d.ts +0 -6
  165. package/dist/types/shared/dashboard-authoring/contracts.d.ts +0 -106
  166. package/dist/types/shared/dashboard-authoring/protocol-adapter.d.ts +0 -7
  167. package/dist/types/shared/dashboard-authoring/source-matching.d.ts +0 -34
  168. package/dist/types/shared/dashboard-authoring/validators.d.ts +0 -2
@@ -0,0 +1,743 @@
1
+ import { k as Y, u as H, H as W } from "./validators-BIM0FE31.js";
2
+ import { z as c } from "zod";
3
+ import { G as J, v as Z } from "./matrix-operation-contract-DsLdFdSa.js";
4
+ import { d as X } from "./metric-comparison-Bnso1cm1.js";
5
+ import "./analytics-base-schemas-BaIQrEzX.js";
6
+ const _ = 8, V = 6, C = Object.freeze([]);
7
+ function ee(e) {
8
+ switch (e.type) {
9
+ case "table":
10
+ case "chart":
11
+ return e.card ? [e.card] : C;
12
+ case "kpi":
13
+ return Array.isArray(e.cards) ? e.cards : C;
14
+ default:
15
+ return C;
16
+ }
17
+ }
18
+ function te(e, t) {
19
+ switch (e.type) {
20
+ case "table":
21
+ case "chart": {
22
+ if (!e.card) return e;
23
+ const n = t(e.card);
24
+ return n === e.card ? e : { ...e, card: n };
25
+ }
26
+ case "kpi": {
27
+ if (!Array.isArray(e.cards)) return e;
28
+ const n = e.cards.map(t);
29
+ return n.every((r, i) => r === e.cards[i]) ? e : { ...e, cards: n };
30
+ }
31
+ default:
32
+ return e;
33
+ }
34
+ }
35
+ function L(e) {
36
+ var n;
37
+ const t = [];
38
+ for (const r of e.sheets || []) {
39
+ const i = r.id;
40
+ for (const s of r.cards || [])
41
+ t.push({ kind: "sheetCard", sheetId: i, cardId: s.id, card: s });
42
+ for (const s of r.frames || [])
43
+ for (const a of s.cards || [])
44
+ t.push({
45
+ kind: "frameCard",
46
+ sheetId: i,
47
+ frameId: s.id,
48
+ cardId: a.id,
49
+ card: a
50
+ });
51
+ for (const s of ((n = r.document) == null ? void 0 : n.sections) || [])
52
+ for (const a of ee(s))
53
+ t.push({
54
+ kind: "documentSectionCard",
55
+ sheetId: i,
56
+ sectionId: s.id,
57
+ cardId: a.id,
58
+ card: a
59
+ });
60
+ }
61
+ return t;
62
+ }
63
+ function Fe(e, t) {
64
+ const n = (i, s) => {
65
+ const a = i.map((o) => t(o, s(o)));
66
+ return a.every((o, u) => o === i[u]) ? i : a;
67
+ }, r = (e.sheets || []).map((i) => {
68
+ var b, p, f;
69
+ const s = i.id, a = i.cards && n(i.cards, (d) => ({ kind: "sheetCard", sheetId: s, cardId: d.id, card: d })), o = (b = i.frames) == null ? void 0 : b.map((d) => {
70
+ if (!d.cards) return d;
71
+ const m = n(d.cards, (F) => ({ kind: "frameCard", sheetId: s, frameId: d.id, cardId: F.id, card: F }));
72
+ return m === d.cards ? d : { ...d, cards: m };
73
+ }), u = (f = (p = i.document) == null ? void 0 : p.sections) == null ? void 0 : f.map(
74
+ (d) => te(d, (m) => t(m, { kind: "documentSectionCard", sheetId: s, sectionId: d.id, cardId: m.id, card: m }))
75
+ ), l = !!o && o.some((d, m) => d !== i.frames[m]), h = !!u && u.some((d, m) => d !== i.document.sections[m]);
76
+ return a === i.cards && !l && !h ? i : {
77
+ ...i,
78
+ ...a === i.cards ? {} : { cards: a },
79
+ ...l ? { frames: o } : {},
80
+ ...h ? { document: { ...i.document, sections: u } } : {}
81
+ };
82
+ });
83
+ return r.every((i, s) => i === e.sheets[s]) ? e : { ...e, sheets: r };
84
+ }
85
+ function E(e) {
86
+ return !!e && typeof e == "object" && !Array.isArray(e);
87
+ }
88
+ function _e(e) {
89
+ if (!E(e))
90
+ return [{ path: "", message: "must be an object." }];
91
+ const t = [];
92
+ e.title !== void 0 && typeof e.title != "string" && t.push({ path: "title", message: "must be a string." });
93
+ const n = e.cards;
94
+ if (!Array.isArray(n))
95
+ t.push({ path: "cards", message: "must be an array of KPI cards." });
96
+ else {
97
+ (n.length < 1 || n.length > _) && t.push({
98
+ path: "cards",
99
+ message: `must hold 1 to ${_} KPI cards.`
100
+ });
101
+ const i = /* @__PURE__ */ new Set();
102
+ n.forEach((s, a) => {
103
+ if (!E(s)) {
104
+ t.push({ path: `cards[${a}]`, message: "must be a card." });
105
+ return;
106
+ }
107
+ typeof s.id != "string" || !s.id ? t.push({
108
+ path: `cards[${a}].id`,
109
+ message: "must be a non-empty string."
110
+ }) : i.has(s.id) ? t.push({
111
+ path: `cards[${a}].id`,
112
+ message: `duplicates card id '${s.id}'.`
113
+ }) : i.add(s.id), s.type !== "kpi" && t.push({ path: `cards[${a}].type`, message: "must be 'kpi'." });
114
+ });
115
+ }
116
+ const r = e.kpi;
117
+ return E(r) ? (r.layout !== "tiles" && r.layout !== "lines" ? t.push({
118
+ path: "kpi.layout",
119
+ message: "must be 'tiles' or 'lines'."
120
+ }) : r.layout === "tiles" && Array.isArray(n) && n.length > V && t.push({
121
+ path: "kpi.layout",
122
+ message: `must be 'lines' for more than ${V} KPI cards.`
123
+ }), 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;
124
+ }
125
+ const ne = ["new", "edit", "delete", "create", "update", "remove"];
126
+ function B(e, t) {
127
+ return (e.sheets || []).flatMap(
128
+ (n) => L({ sheets: [n] }).filter(t).map((r) => ({
129
+ card: r.card,
130
+ sheet: n,
131
+ ...r.kind === "frameCard" && { frameId: r.frameId },
132
+ ...r.kind === "documentSectionCard" && {
133
+ sectionId: r.sectionId
134
+ }
135
+ }))
136
+ );
137
+ }
138
+ function S(e) {
139
+ return B(e, (t) => t.kind !== "documentSectionCard");
140
+ }
141
+ function Ve(e) {
142
+ return [
143
+ ...S(e),
144
+ ...B(e, (t) => t.kind === "documentSectionCard")
145
+ ];
146
+ }
147
+ function $e(e) {
148
+ return S(e).map((t) => t.card);
149
+ }
150
+ function Re(e, t, n) {
151
+ return n && t === n ? !0 : !L(e).some(
152
+ (r) => r.cardId === t
153
+ );
154
+ }
155
+ function Me(e) {
156
+ 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) ? ne.includes(e.toLowerCase()) ? {
157
+ isValid: !1,
158
+ error: `"${e}" is a reserved keyword and cannot be used`
159
+ } : { isValid: !0 } : {
160
+ isValid: !1,
161
+ error: "Card ID must start with a letter or number"
162
+ } : {
163
+ isValid: !1,
164
+ error: "Card ID can only contain letters, numbers, hyphens, and underscores"
165
+ };
166
+ }
167
+ function Le(e, t) {
168
+ var n;
169
+ return (n = re(e, t)) == null ? void 0 : n.card;
170
+ }
171
+ function re(e, t) {
172
+ for (const n of S(e))
173
+ if (n.card.id === t)
174
+ return n;
175
+ }
176
+ function Be(e, t) {
177
+ for (const n of e.sheets || [])
178
+ for (const r of n.frames || [])
179
+ for (const i of r.cards || [])
180
+ if (i.id === t)
181
+ return { card: i, sheet: n };
182
+ }
183
+ const k = {
184
+ includeMetricFilterDatasets: !0,
185
+ preferQualifiedIdentity: !1
186
+ };
187
+ function P(e) {
188
+ if (!e) return;
189
+ if (e.kind === "semantic")
190
+ return { entityName: e.datasetName, entityId: e.datasetId, label: e.label };
191
+ const t = [e.databaseName, e.schemaName, e.tableName].filter((n) => !!(n && n.trim())).join(".");
192
+ return {
193
+ entityName: e.tableName,
194
+ qualifiedEntityName: t.includes(".") ? t : void 0,
195
+ label: e.label
196
+ };
197
+ }
198
+ function ie(e) {
199
+ var n;
200
+ const t = P(e.source);
201
+ return t ? `${(n = e.source) == null ? void 0 : n.kind}:${t.qualifiedEntityName || t.entityName}` : "";
202
+ }
203
+ function se(e) {
204
+ return [
205
+ e.id,
206
+ e.qualifiedEntityName,
207
+ e.entityId,
208
+ e.entityName,
209
+ e.qualifiedFieldName,
210
+ e.name,
211
+ // Source-only fields from different datasets can otherwise share a key
212
+ // and the second dataset would be silently dropped.
213
+ ie(e)
214
+ ].join("|");
215
+ }
216
+ function ae(e) {
217
+ return [e.entityName, e.qualifiedEntityName || "", e.entityId || ""].join("|");
218
+ }
219
+ function Pe(e) {
220
+ return e.entityName || e.qualifiedEntityName || "";
221
+ }
222
+ function oe(e) {
223
+ var t, n;
224
+ return !!(e.expression || e.derivedField || (n = (t = e.calculatedFormula) == null ? void 0 : t.inputFields) != null && n.length);
225
+ }
226
+ function ce(e) {
227
+ return Y(e) ? !0 : e.entityName || e.qualifiedEntityName ? !1 : !e.source || oe(e);
228
+ }
229
+ function w(e, t) {
230
+ const n = ae(t);
231
+ e.found.has(n) || e.found.set(n, t);
232
+ }
233
+ function I(e, t) {
234
+ var l, h, b;
235
+ if (!e) return;
236
+ const n = se(e);
237
+ if (t.visitedFields.has(n)) return;
238
+ t.visitedFields.add(n);
239
+ const r = ce(e);
240
+ if (!r) {
241
+ const p = !e.entityName && !e.qualifiedEntityName ? P(e.source) : void 0;
242
+ w(
243
+ t,
244
+ p || {
245
+ // May be empty for qualified-only metadata; identity then comes from
246
+ // `qualifiedEntityName` (see `identityFor` and the calculator).
247
+ entityName: e.entityName || "",
248
+ entityId: e.entityId,
249
+ qualifiedEntityName: e.qualifiedEntityName,
250
+ label: e.source && e.source.kind === "semantic" ? e.source.label : void 0
251
+ }
252
+ );
253
+ }
254
+ t.includeMetricFilterDatasets && "parameters" in e && ((l = e.parameters) != null && l.filters) && O(e.parameters.filters, t);
255
+ const i = (h = e.calculatedFormula) == null ? void 0 : h.inputFields, s = !!(i && i.length > 0);
256
+ s && i.forEach((p) => I(p, t));
257
+ let a = !1, o = !1;
258
+ const u = s || (b = e.derivedField) == null ? void 0 : b.inputs;
259
+ if (u && Object.keys(u).length > 0)
260
+ for (const p of Object.values(u)) {
261
+ const f = p.field.source;
262
+ if (!f) {
263
+ s || (o = !0);
264
+ continue;
265
+ }
266
+ if (f.kind === "sql") {
267
+ o = !0;
268
+ continue;
269
+ }
270
+ if (f.kind === "semantic")
271
+ w(t, {
272
+ entityName: f.datasetName,
273
+ entityId: f.datasetId,
274
+ label: f.label
275
+ });
276
+ else {
277
+ const d = [f.databaseName, f.schemaName, f.tableName].filter((m) => !!(m && m.trim())).join(".");
278
+ w(t, {
279
+ entityName: f.tableName,
280
+ qualifiedEntityName: d.includes(".") ? d : void 0,
281
+ label: f.label
282
+ });
283
+ }
284
+ a = !0;
285
+ }
286
+ o && (t.complete = !1), r && !s && !a && (t.complete = !1);
287
+ }
288
+ function O(e, t) {
289
+ if (e && !t.visitedGroups.has(e.id)) {
290
+ t.visitedGroups.add(e.id);
291
+ for (const n of e.conditions || [])
292
+ I(n.field, t);
293
+ for (const n of e.groups || [])
294
+ O(n, t);
295
+ }
296
+ }
297
+ function v(e, t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Set()) {
298
+ return {
299
+ found: /* @__PURE__ */ new Map(),
300
+ complete: !0,
301
+ visitedFields: t,
302
+ visitedGroups: n,
303
+ includeMetricFilterDatasets: e
304
+ };
305
+ }
306
+ function A(e, t) {
307
+ var r;
308
+ const n = (r = e.qualifiedEntityName) != null && r.includes(".") ? e.qualifiedEntityName : void 0;
309
+ return t === "qualifiedOnly" ? n : t === "preferQualified" ? n || e.entityName || void 0 : e.entityName || void 0;
310
+ }
311
+ function qe(e) {
312
+ const t = v(!1);
313
+ return I(e, t), { datasets: Array.from(t.found.values()), complete: t.complete };
314
+ }
315
+ function q(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = k) {
316
+ const s = { ...k, ...i }, a = v(s.includeMetricFilterDatasets, n, r);
317
+ I(e, a), a.found.forEach((o) => {
318
+ const u = A(o, s.preferQualifiedIdentity ? "preferQualified" : "name");
319
+ u && t.add(u);
320
+ });
321
+ }
322
+ function xe(e, t) {
323
+ q(e, t, /* @__PURE__ */ new Set(), /* @__PURE__ */ new Set(), {
324
+ preferQualifiedIdentity: !0
325
+ });
326
+ }
327
+ function Ke(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
328
+ const i = v(!0, n, r);
329
+ I(e, i), i.found.forEach((s) => {
330
+ const a = A(s, "qualifiedOnly");
331
+ a && t.add(a);
332
+ });
333
+ }
334
+ function je(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set()) {
335
+ q(e, t, n, r, {
336
+ includeMetricFilterDatasets: !1
337
+ });
338
+ }
339
+ function Ue(e, t, n = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), i = k) {
340
+ const s = { ...k, ...i }, a = v(s.includeMetricFilterDatasets, n, r);
341
+ O(e, a), a.found.forEach((o) => {
342
+ const u = A(o, s.preferQualifiedIdentity ? "preferQualified" : "name");
343
+ u && t.add(u);
344
+ });
345
+ }
346
+ function ze(e, t) {
347
+ 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());
348
+ }
349
+ const ue = {
350
+ date: /* @__PURE__ */ new Set([
351
+ "between",
352
+ "not between",
353
+ "=",
354
+ "!=",
355
+ ">",
356
+ ">=",
357
+ "<",
358
+ "<=",
359
+ "is null",
360
+ "is not null"
361
+ ]),
362
+ number: /* @__PURE__ */ new Set([
363
+ "between",
364
+ "not between",
365
+ "=",
366
+ "!=",
367
+ ">",
368
+ ">=",
369
+ "<",
370
+ "<=",
371
+ "in",
372
+ "not in",
373
+ "is null",
374
+ "is not null"
375
+ ]),
376
+ string: /* @__PURE__ */ new Set([
377
+ "=",
378
+ "!=",
379
+ "in",
380
+ "not in",
381
+ "like",
382
+ "not like",
383
+ "is null",
384
+ "is not null"
385
+ ]),
386
+ boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
387
+ };
388
+ function de(e) {
389
+ const t = W(e);
390
+ return t === "number" || t === "boolean" ? t : t === "date" || t === "datetime" ? "date" : "string";
391
+ }
392
+ function Qe(e, t) {
393
+ return typeof t != "string" ? !1 : ue[de(e)].has(t);
394
+ }
395
+ const le = /* @__PURE__ */ new Set([
396
+ "=",
397
+ ">",
398
+ "<",
399
+ ">=",
400
+ "<=",
401
+ "!=",
402
+ "in",
403
+ "not in",
404
+ "like",
405
+ "not like",
406
+ "between",
407
+ "not between",
408
+ "is null",
409
+ "is not null"
410
+ ]);
411
+ function fe(e, t) {
412
+ 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";
413
+ }
414
+ function me(e, t, n, r) {
415
+ if (H(e.relativeMeta)) {
416
+ r.push(
417
+ `${n}.relativeMeta counts back from the latest data; a dashboard filter's dates run to now. Use a period counted back from today.`
418
+ );
419
+ return;
420
+ }
421
+ pe(e.operation, e.values, t, `${n}.values`, r);
422
+ }
423
+ function pe(e, t, n, r, i) {
424
+ if (e === "is null" || e === "is not null") {
425
+ t.length !== 0 && i.push(`${r} must be empty for null filter operations.`);
426
+ return;
427
+ }
428
+ if (e === "between" || e === "not between") {
429
+ if (t.length !== 2) {
430
+ i.push(
431
+ `${r} must contain exactly two values for between operations.`
432
+ );
433
+ return;
434
+ }
435
+ } else if (e === "in" || e === "not in") {
436
+ if (t.length === 0) {
437
+ i.push(
438
+ `${r} must contain at least one value for set operations.`
439
+ );
440
+ return;
441
+ }
442
+ } else if (t.length !== 1) {
443
+ i.push(
444
+ `${r} must contain exactly one value for '${String(e)}' operations.`
445
+ );
446
+ return;
447
+ }
448
+ for (const s of t)
449
+ if (!fe(s, n)) {
450
+ i.push(
451
+ `${r} contains a value that is incompatible with valueType '${n}'.`
452
+ );
453
+ return;
454
+ }
455
+ }
456
+ const Ge = {
457
+ database: null,
458
+ schema: null,
459
+ table: null
460
+ }, Ye = "__card_default__", x = {
461
+ bookmarksPerViewerPerDashboard: 20,
462
+ bookmarkNameMaxChars: 100,
463
+ columnLabelMaxChars: 120,
464
+ tableSettingsMaxBytes: 65536,
465
+ rememberedTableSettingsMaxBytes: 262144,
466
+ bookmarkStateMaxBytes: 65536
467
+ }, K = 1;
468
+ function He(e) {
469
+ return new TextEncoder().encode(JSON.stringify(e ?? null)).length;
470
+ }
471
+ function he(e) {
472
+ const t = encodeURIComponent;
473
+ switch (e.kind) {
474
+ case "dimension":
475
+ return `dim:${e.role}:${t(e.fieldId)}`;
476
+ case "metric":
477
+ return `metric:${t(e.metricId)}:${t(
478
+ e.metricAlias
479
+ )}`;
480
+ case "result":
481
+ return `result:${t(e.key)}`;
482
+ }
483
+ }
484
+ function g(e) {
485
+ if (e)
486
+ try {
487
+ return decodeURIComponent(e);
488
+ } catch {
489
+ return;
490
+ }
491
+ }
492
+ function be(e) {
493
+ if (typeof e != "string") return;
494
+ const t = e.split(":");
495
+ let n;
496
+ if (t[0] === "dim" && t.length === 3) {
497
+ const r = t[1], i = g(t[2]);
498
+ (r === "detail" || r === "groupby") && i && (n = { kind: "dimension", role: r, fieldId: i });
499
+ } else if (t[0] === "metric" && t.length === 3) {
500
+ const r = g(t[1]), i = g(t[2]);
501
+ r && i && (n = { kind: "metric", metricId: r, metricAlias: i });
502
+ } else if (t[0] === "result" && t.length === 2) {
503
+ const r = g(t[1]);
504
+ r && (n = { kind: "result", key: r });
505
+ }
506
+ return n && he(n) === e ? n : void 0;
507
+ }
508
+ function T(e) {
509
+ return typeof e == "string" && be(e) !== void 0;
510
+ }
511
+ const $ = c.array(c.string()).max(2e3), ye = c.object({
512
+ order: $.optional(),
513
+ hidden: $.optional(),
514
+ labels: c.record(c.string(), c.string().max(x.columnLabelMaxChars)).optional(),
515
+ sort: c.array(
516
+ c.object({
517
+ columnId: c.string(),
518
+ direction: c.enum(["asc", "desc"])
519
+ }).strict()
520
+ ).max(2e3).optional()
521
+ }).strict();
522
+ function R(e) {
523
+ const t = /* @__PURE__ */ new Set(), n = [];
524
+ for (const r of e)
525
+ !T(r) || t.has(r) || (t.add(r), n.push(r));
526
+ return n;
527
+ }
528
+ function j(e) {
529
+ if (!e) return;
530
+ const t = e.order ? R(e.order) : void 0, n = e.hidden ? R(e.hidden) : void 0, r = Object.entries(e.labels ?? {}).flatMap(
531
+ ([o, u]) => {
532
+ const l = typeof u == "string" ? u.trim() : "";
533
+ return T(o) && l ? [
534
+ [
535
+ o,
536
+ l.slice(0, x.columnLabelMaxChars)
537
+ ]
538
+ ] : [];
539
+ }
540
+ ), i = /* @__PURE__ */ new Set(), s = e.sort ? e.sort.filter((o) => !T(o.columnId) || i.has(o.columnId) ? !1 : (i.add(o.columnId), !0)) : void 0, a = {};
541
+ return t != null && t.length && (a.order = t), n != null && n.length && (a.hidden = n), r.length && (a.labels = Object.fromEntries(r)), s && (a.sort = s.map(({ columnId: o, direction: u }) => ({
542
+ columnId: o,
543
+ direction: u
544
+ }))), Object.keys(a).length ? a : void 0;
545
+ }
546
+ function U(e) {
547
+ return j(e) === void 0;
548
+ }
549
+ function z(e, t) {
550
+ if (t !== K)
551
+ return {
552
+ ok: !1,
553
+ error: `Unsupported table settings version ${t}.`
554
+ };
555
+ const n = ye.safeParse(e);
556
+ return n.success ? {
557
+ ok: !0,
558
+ value: j(n.data) ?? {}
559
+ } : { ok: !1, error: "Table settings are invalid." };
560
+ }
561
+ function We(e, t, n) {
562
+ if (!e || typeof e != "object" || Array.isArray(e)) return {};
563
+ const r = {};
564
+ for (const [i, s] of Object.entries(
565
+ e
566
+ )) {
567
+ if (!n.has(i)) continue;
568
+ const a = z(s, t);
569
+ a.ok && !U(a.value) && (r[i] = a.value);
570
+ }
571
+ return r;
572
+ }
573
+ const Se = /* @__PURE__ */ new Set([
574
+ "table",
575
+ "detailTable"
576
+ ]);
577
+ function Q(e) {
578
+ return Se.has(e.type);
579
+ }
580
+ function Ie(e) {
581
+ var t, n;
582
+ return Q(e) && ((n = (t = e.preferences) == null ? void 0 : t.tablePrefs) == null ? void 0 : n.allowViewerColumnCustomization) !== !1;
583
+ }
584
+ function Je(e) {
585
+ return new Set(
586
+ S(e).filter(({ card: t }) => Q(t)).map(({ card: t }) => t.id)
587
+ );
588
+ }
589
+ function Ze(e) {
590
+ return new Set(
591
+ S(e).filter(({ card: t }) => Ie(t)).map(({ card: t }) => t.id)
592
+ );
593
+ }
594
+ const N = 1, Xe = ["PRIVATE", "TEAM", "DASHBOARD"], ge = c.object({
595
+ filterId: c.string().min(1),
596
+ name: c.string(),
597
+ operation: c.string(),
598
+ valueType: c.enum(["string", "number", "date", "boolean"]),
599
+ values: c.array(c.unknown())
600
+ }).passthrough().superRefine((e, t) => {
601
+ const n = [];
602
+ le.has(e.operation) ? me(e, e.valueType, "filterValue", n) : n.push("filterValue.operation must be a valid filter operation.");
603
+ for (const r of n) t.addIssue({ code: "custom", message: r });
604
+ }), D = c.unknown().superRefine((e, t) => {
605
+ for (const n of X(e).errors)
606
+ t.addIssue({ code: "custom", message: n.message });
607
+ }), ke = c.discriminatedUnion("kind", [
608
+ c.object({ kind: c.literal("filter"), filterValue: ge }).strict(),
609
+ c.object({ kind: c.literal("control"), value: c.unknown() }).strict(),
610
+ c.object({
611
+ kind: c.literal("selection"),
612
+ selection: J
613
+ }).strict()
614
+ ]), ve = c.union([
615
+ c.object({
616
+ status: c.literal("set"),
617
+ value: ke,
618
+ comparisonSelection: D.optional()
619
+ }).strict(),
620
+ c.object({
621
+ status: c.literal("cleared"),
622
+ comparisonSelection: D.optional()
623
+ }).strict(),
624
+ c.object({ comparisonSelection: D }).strict()
625
+ ]), G = ["bySheetId", "byCardId", "byDocumentSectionId"], Ce = /* @__PURE__ */ new Set(["version", "selectedSheetId", "inputs", "tableSettings"]), Ee = /* @__PURE__ */ new Set(["shared", ...G]), y = (e) => !!e && typeof e == "object" && !Array.isArray(e);
626
+ function M(e, t, n) {
627
+ if (e === void 0) return;
628
+ if (!y(e)) {
629
+ t.push({ target: "input", id: n });
630
+ return;
631
+ }
632
+ const r = {};
633
+ for (const [i, s] of Object.entries(e)) {
634
+ const a = i ? ve.safeParse(s) : void 0;
635
+ a != null && a.success ? r[i] = a.data : t.push({
636
+ target: Z(i) ? "selection" : "input",
637
+ id: i
638
+ });
639
+ }
640
+ return Object.keys(r).length ? r : void 0;
641
+ }
642
+ function we(e, t) {
643
+ if (t !== N)
644
+ return { ok: !1, error: `Unsupported bookmark version ${t}.` };
645
+ if (!y(e) || e.version !== N)
646
+ return { ok: !1, error: "The bookmark state is invalid." };
647
+ const n = [], r = Object.keys(e).filter((o) => !Ce.has(o));
648
+ let i;
649
+ typeof e.selectedSheetId == "string" && e.selectedSheetId ? i = e.selectedSheetId : e.selectedSheetId !== void 0 && n.push({ target: "sheet", id: String(e.selectedSheetId) });
650
+ const s = {};
651
+ if (y(e.inputs)) {
652
+ r.push(
653
+ ...Object.keys(e.inputs).filter((u) => !Ee.has(u)).map((u) => `inputs.${u}`)
654
+ );
655
+ const o = M(e.inputs.shared, n, "shared");
656
+ o && (s.shared = o);
657
+ for (const u of G) {
658
+ const l = e.inputs[u];
659
+ if (l === void 0) continue;
660
+ if (!y(l)) {
661
+ n.push({ target: "input", id: u });
662
+ continue;
663
+ }
664
+ const h = {};
665
+ for (const [b, p] of Object.entries(l)) {
666
+ const f = M(p, n, `${u}.${b}`);
667
+ f && (h[b] = f);
668
+ }
669
+ Object.keys(h).length && (s[u] = h);
670
+ }
671
+ } else e.inputs !== void 0 && r.push("inputs");
672
+ const a = {};
673
+ if (y(e.tableSettings))
674
+ for (const [o, u] of Object.entries(e.tableSettings)) {
675
+ const l = o ? z(u, K) : void 0;
676
+ l != null && l.ok ? U(l.value) || (a[o] = l.value) : n.push({ target: "card", id: o });
677
+ }
678
+ else e.tableSettings !== void 0 && r.push("tableSettings");
679
+ return {
680
+ ok: !0,
681
+ value: {
682
+ version: N,
683
+ ...i ? { selectedSheetId: i } : {},
684
+ ...Object.keys(s).length ? { inputs: s } : {},
685
+ ...Object.keys(a).length ? { tableSettings: a } : {}
686
+ },
687
+ issues: n,
688
+ unknownKeys: r
689
+ };
690
+ }
691
+ function et(e, t) {
692
+ const n = we(e, t);
693
+ 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;
694
+ }
695
+ export {
696
+ ee as A,
697
+ N as B,
698
+ Ye as C,
699
+ _ as D,
700
+ Ge as E,
701
+ V as F,
702
+ te as G,
703
+ Fe as H,
704
+ _e as I,
705
+ de as J,
706
+ Qe as K,
707
+ le as L,
708
+ me as M,
709
+ re as N,
710
+ $e as O,
711
+ S as P,
712
+ Ve as Q,
713
+ Re as R,
714
+ Me as S,
715
+ Be as T,
716
+ x as V,
717
+ Pe as a,
718
+ xe as b,
719
+ q as c,
720
+ P as d,
721
+ Ke as e,
722
+ je as f,
723
+ Ue as g,
724
+ ze as h,
725
+ we as i,
726
+ K as j,
727
+ be as k,
728
+ U as l,
729
+ He as m,
730
+ j as n,
731
+ z as o,
732
+ et as p,
733
+ We as q,
734
+ qe as r,
735
+ Q as s,
736
+ he as t,
737
+ Ie as u,
738
+ Je as v,
739
+ Ze as w,
740
+ Xe as x,
741
+ Le as y,
742
+ L as z
743
+ };