react-semaphor 0.1.563 → 0.1.565

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 (139) hide show
  1. package/DATA_APP_SDK.md +3 -3
  2. package/README.md +2 -2
  3. package/dist/analytics-protocol/index.js +8 -8
  4. package/dist/assistant-context/index.js +3 -2
  5. package/dist/brand-studio/index.js +28 -29
  6. package/dist/briefings/index.js +4 -4
  7. package/dist/chunks/{assistant-chat-iIp02_77.js → assistant-chat-DNfb5fbF.js} +294 -294
  8. package/dist/chunks/{bookmark-impact-D4Kl4amw.js → bookmark-impact-CHr7b1J2.js} +2 -2
  9. package/dist/chunks/bookmark-state-ByODVqee.js +1613 -0
  10. package/dist/chunks/card-filter-builder-CcEcfaYz.js +4100 -0
  11. package/dist/chunks/{switch-BW4yXSYs.js → code-editor-DJNOsgJH.js} +463 -442
  12. package/dist/chunks/{comparison-window-caption-D1EUXzaR.js → comparison-window-caption-CMLb3mut.js} +451 -419
  13. package/dist/chunks/{dashboard-CmqeP3QZ.js → dashboard-CtIfxycc.js} +1 -1
  14. package/dist/chunks/dashboard-briefing-launcher-D3mc6peE.js +4910 -0
  15. package/dist/chunks/{dashboard-controls-B253nJS-.js → dashboard-controls-BFv0zdws.js} +684 -674
  16. package/dist/chunks/{dashboard-json-osQuinUZ.js → dashboard-json-CXn_3OYb.js} +4 -4
  17. package/dist/chunks/{dates-DFY7Gfss.js → dates-DcRxw17S.js} +13 -13
  18. package/dist/chunks/{edit-dashboard-visual-CMar-NhA.js → edit-dashboard-visual-Y6HatqBd.js} +7704 -10337
  19. package/dist/chunks/filter-reach-copy-DbggA5B7.js +4673 -0
  20. package/dist/chunks/{filter-value-text-CPwFkrMz.js → filter-value-text-7zhmth1S.js} +2 -2
  21. package/dist/chunks/{index-CNGkfUp4.js → index-DDa_rklN.js} +69 -64
  22. package/dist/chunks/index-RNaTnE3m.js +585 -0
  23. package/dist/chunks/{layout-grid-BM65viQh.js → layout-grid-0hIlqEtk.js} +1 -1
  24. package/dist/chunks/{list-filter-BoeLBfL3.js → list-filter-DkgoCeBm.js} +1 -1
  25. package/dist/chunks/{matrix-analytical-definition-hEucouWM.js → matrix-analytical-definition-C9xB_T84.js} +18 -18
  26. package/dist/chunks/{matrix-card-CCh9JjP1.js → matrix-card-BSUeSXpD.js} +2 -2
  27. package/dist/chunks/{matrix-member-presentation-DsAUbuoL.js → matrix-member-presentation-DZNgQpUq.js} +1 -1
  28. package/dist/chunks/{matrix-operation-contract-DsLdFdSa.js → matrix-operation-contract-Eb6elidS.js} +1 -1
  29. package/dist/chunks/{metric-comparison-Bnso1cm1.js → metric-comparison-ChXUFaZu.js} +1 -1
  30. package/dist/chunks/{palette-p1XSJFgB.js → palette-4vf2BEEg.js} +1 -1
  31. package/dist/chunks/{pivot-result-contract-expectations-B53jqszr.js → pivot-result-contract-expectations-Ddh1rNz5.js} +4 -4
  32. package/dist/chunks/{pivot-result-identity-Dq5jm-EC.js → pivot-result-identity-BlbLrqaC.js} +1 -1
  33. package/dist/chunks/{report-preferences-dialog-l54wJyYE.js → report-preferences-dialog-Db-b04B4.js} +122 -131
  34. package/dist/chunks/{report-runtime-context-BITkNSDa.js → report-runtime-context-DnA_PiKo.js} +1 -1
  35. package/dist/chunks/resolve-dashboard-input-context-C18J-YZC.js +21394 -0
  36. package/dist/chunks/{save-CHV1B1fL.js → save-D6pHmSSP.js} +1 -1
  37. package/dist/chunks/saved-dashboard-context-DhC_EVus.js +629 -0
  38. package/dist/chunks/{selection-reducer-Bz5aywT4.js → selection-reducer-OaJ-N5uN.js} +1 -1
  39. package/dist/chunks/{semaphor-ready-indicator-C3EQEiD9.js → semaphor-ready-indicator-T6TsiBMT.js} +80879 -80744
  40. package/dist/chunks/{shelf-drop-preview-context-BODiBlqT.js → shelf-drop-preview-context-CNWL_b0S.js} +407 -407
  41. package/dist/chunks/{source-entity-resolution-DdDVXFB8.js → source-entity-resolution-DF6GulDn.js} +1 -1
  42. package/dist/chunks/stored-dashboard-IdmtrNkA.js +5026 -0
  43. package/dist/chunks/{table-export-sheet-bSXxGn-v.js → table-export-sheet--DUKWk6o.js} +1 -1
  44. package/dist/chunks/{temporal-input-presentation-sk9gqLi6.js → temporal-input-presentation--2r9BLr0.js} +392 -377
  45. package/dist/chunks/{token-types-BUK06hU2.js → token-types-C8JymO8s.js} +1 -1
  46. package/dist/chunks/{upload-BnmuyPqW.js → upload-Cf3wXZT8.js} +1 -1
  47. package/dist/chunks/{validators-BIM0FE31.js → validators-wtjw0aw6.js} +7 -7
  48. package/dist/chunks/variable-draft-3xseULxR.js +241 -0
  49. package/dist/dashboard/index.js +2 -2
  50. package/dist/dashboard-authoring/index.js +2226 -1704
  51. package/dist/data-app-sdk/index.js +4 -4
  52. package/dist/data-app-sdk-adapters/index.js +2 -2
  53. package/dist/data-app-sdk-validation/index.js +5 -5
  54. package/dist/format-utils/index.js +174 -167
  55. package/dist/index.js +190 -188
  56. package/dist/layouts/index.js +1 -1
  57. package/dist/pdf-export-policy/index.js +80 -28
  58. package/dist/pdf-table-layout/index.js +65 -65
  59. package/dist/report-runtime-context/index.js +1 -1
  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/activity/activity-bell.d.ts +5 -1
  64. package/dist/types/components/activity/activity-types.d.ts +12 -4
  65. package/dist/types/components/dashboard-variables/data-variables-menu.d.ts +8 -0
  66. package/dist/types/components/dashboard-variables/variable-editor-host.d.ts +1 -0
  67. package/dist/types/components/index.d.ts +2 -0
  68. package/dist/types/index.js +5 -5
  69. package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +62 -0
  70. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +33 -2
  71. package/dist/types/lib/dashboard-inputs/filter-settings.d.ts +7 -2
  72. package/dist/types/lib/dashboard-inputs/prepare-loaded-dashboard.d.ts +4 -2
  73. package/dist/types/lib/dashboard-variables/data-text.d.ts +33 -0
  74. package/dist/types/lib/dashboard-variables/types.d.ts +207 -0
  75. package/dist/types/lib/document/document-edits.d.ts +16 -1
  76. package/dist/types/lib/document/document-panel-target.d.ts +1 -1
  77. package/dist/types/lib/document/document-section-query-options.d.ts +29 -0
  78. package/dist/types/lib/document/document-table-data-policy.d.ts +0 -1
  79. package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +92 -0
  80. package/dist/types/lib/query-context/build-card-query-context.d.ts +6 -0
  81. package/dist/types/lib/query-context/describe-card-execution-snapshot.d.ts +1 -0
  82. package/dist/types/lib/query-context/use-semantic-execution-payload-for-cards.d.ts +24 -0
  83. package/dist/types/lib/stores/dashboard-store.d.ts +36 -0
  84. package/dist/types/lib/text-variables/temporal-input-text.d.ts +28 -0
  85. package/dist/types/lib/text-variables/text-variable-types.d.ts +72 -0
  86. package/dist/types/lib/types/common-types.d.ts +155 -51
  87. package/dist/types/lib/utils/card-definition.d.ts +2 -2
  88. package/dist/types/shared/assistant-context/index.d.ts +1 -1
  89. package/dist/types/shared/assistant-context/saved-dashboard-context.d.ts +51 -1
  90. package/dist/types/shared/dashboard-authoring/card-query-request.d.ts +7 -1
  91. package/dist/types/shared/dashboard-authoring/card-settings/resolve-card-highlights.d.ts +10 -0
  92. package/dist/types/shared/dashboard-authoring/changes/card-query-part.d.ts +7 -1
  93. package/dist/types/shared/dashboard-authoring/changes/dashboard-change.d.ts +1088 -431
  94. package/dist/types/shared/dashboard-authoring/changes/diagnostics.d.ts +18 -1
  95. package/dist/types/shared/dashboard-authoring/changes/read-card-query.d.ts +8 -1
  96. package/dist/types/shared/dashboard-authoring/changes/resolve-dashboard-changes.d.ts +1 -1
  97. package/dist/types/shared/dashboard-authoring/conditional-formatting/kpi.d.ts +10 -0
  98. package/dist/types/shared/dashboard-authoring/conditional-formatting/schema.d.ts +40 -40
  99. package/dist/types/shared/dashboard-authoring/control-execution-contract.d.ts +16 -16
  100. package/dist/types/shared/dashboard-authoring/dashboard-card-source-index.d.ts +1 -0
  101. package/dist/types/shared/dashboard-authoring/dashboard-filter-targets.d.ts +29 -0
  102. package/dist/types/shared/dashboard-authoring/dashboard-input-scope.d.ts +7 -4
  103. package/dist/types/shared/dashboard-authoring/dashboard-variable-card.d.ts +159 -0
  104. package/dist/types/shared/dashboard-authoring/dashboard-variable-changes.d.ts +61 -0
  105. package/dist/types/shared/dashboard-authoring/document-section-cards.d.ts +7 -0
  106. package/dist/types/shared/dashboard-authoring/filter-model/index.d.ts +2 -0
  107. package/dist/types/shared/dashboard-authoring/filter-model/read-dashboard-filter-model.d.ts +10 -0
  108. package/dist/types/shared/dashboard-authoring/index.d.ts +6 -0
  109. package/dist/types/shared/dashboard-authoring/measure-calculations/comparison.d.ts +2 -0
  110. package/dist/types/shared/dashboard-authoring/measure-calculations/schemas.d.ts +1 -1
  111. package/dist/types/shared/dashboard-authoring/operations/operation-sentences.d.ts +1 -1
  112. package/dist/types/shared/dashboard-authoring/operations/operation-types.d.ts +50 -3
  113. package/dist/types/shared/dashboard-authoring/outline/outline-dashboard.d.ts +48 -1
  114. package/dist/types/shared/dashboard-authoring/outline/outline-filters.d.ts +2 -2
  115. package/dist/types/shared/dashboard-authoring/text-card-words/blocks.d.ts +87 -13
  116. package/dist/types/shared/dashboard-authoring/text-card-words/chip-colors.d.ts +23 -0
  117. package/dist/types/shared/dashboard-authoring/text-card-words/index.d.ts +90 -8
  118. package/dist/types/shared/dashboard-authoring/text-card-words/rich-content.d.ts +31 -3
  119. package/dist/types/shared/dashboard-authoring/text-card-words/variable-words.d.ts +8 -0
  120. package/dist/types/shared/dashboard-authoring/variable-draft.d.ts +125 -0
  121. package/dist/types/shared/dashboard-authoring/variable-editability.d.ts +24 -0
  122. package/dist/types/shared/dashboard-authoring/variable-references.d.ts +39 -0
  123. package/dist/types/shared/format-utils/document-print.d.ts +4 -2
  124. package/dist/types/shared/format-utils/index.d.ts +1 -0
  125. package/dist/types/shared/format-utils/pdf-capacity-lines.d.ts +17 -0
  126. package/dist/types/shared/format-utils/pdf-delivery.d.ts +8 -1
  127. package/dist/types/shared/format-utils/pdf-export-policy.d.ts +74 -6
  128. package/dist/types/shared/format-utils/presentation-execution.d.ts +9 -0
  129. package/package.json +2 -2
  130. package/src/data-app-sdk/README.md +3 -3
  131. package/dist/chunks/bookmark-state-CWeoGbrx.js +0 -743
  132. package/dist/chunks/braces-DzgoQC64.js +0 -23
  133. package/dist/chunks/dashboard-briefing-launcher-TYlSW77S.js +0 -3828
  134. package/dist/chunks/filter-reach-copy-CvV7W5dd.js +0 -3965
  135. package/dist/chunks/global-date-filter-utils-N1kcsOFE.js +0 -16722
  136. package/dist/chunks/index-CJW5BdWT.js +0 -583
  137. package/dist/chunks/resolve-dashboard-input-context-DaDrZGuA.js +0 -8214
  138. package/dist/chunks/saved-dashboard-context-DFYBrE6O.js +0 -564
  139. package/dist/chunks/use-create-flow-overlay-state-BXY8-Cyz.js +0 -1436
@@ -1,4 +1,4 @@
1
- import { c as a } from "./switch-BW4yXSYs.js";
1
+ import { c as a } from "./code-editor-DJNOsgJH.js";
2
2
  /**
3
3
  * @license lucide-react v0.453.0 - ISC
4
4
  *
@@ -0,0 +1,629 @@
1
+ var G = Object.defineProperty;
2
+ var Q = (e, t, a) => t in e ? G(e, t, { enumerable: !0, configurable: !0, writable: !0, value: a }) : e[t] = a;
3
+ var F = (e, t, a) => Q(e, typeof t != "symbol" ? t + "" : t, a);
4
+ import { z as S, A as U, D as K, F as W } from "./bookmark-state-ByODVqee.js";
5
+ import { s as X, i as Y, n as ee, f as te, j as ae, l as re, k as ne, m as se, o as oe, p as j, q as ie, t as de, u as le } from "./resolve-dashboard-input-context-C18J-YZC.js";
6
+ import { c as ce, e as L, d as ue, g as me, p as q, j as fe, k as he, r as _, m as O, n as pe, o as be, q as ge } from "./stored-dashboard-IdmtrNkA.js";
7
+ import { f as g, A as P, c as Ce, d as Ie, e as A } from "./context-R31TSL5V.js";
8
+ import { a as ye, T as ve, P as xe, o as I, d as B, b as D } from "./filter-value-text-7zhmth1S.js";
9
+ import { v as Ve, am as Se } from "./validators-wtjw0aw6.js";
10
+ import { a as $e } from "./metric-comparison-ChXUFaZu.js";
11
+ function ke(e) {
12
+ const t = e.qualifiedFieldName || e.name;
13
+ return e.label && e.label !== t ? `${e.label} (field ${t})` : t;
14
+ }
15
+ function qe(e, t = {}) {
16
+ if (!e) return [];
17
+ const a = N(e, t);
18
+ return a.length === 0 ? [] : e.logicalOperator === "AND" && !e.negate ? a : [z(e, a)];
19
+ }
20
+ function N(e, t) {
21
+ const a = e.groups.flatMap((r) => {
22
+ const n = N(r, t);
23
+ if (n.length === 0) return [];
24
+ const s = z(r, n);
25
+ return [n.length > 1 && !r.negate ? { ...s, text: `(${s.text})` } : s];
26
+ });
27
+ return [...e.conditions.map((r) => _e(r, t)), ...a];
28
+ }
29
+ function z(e, t) {
30
+ const a = t.map((r) => r.text).join(e.logicalOperator === "OR" ? " or " : " and ");
31
+ return {
32
+ text: e.negate ? `not (${a})` : a,
33
+ omittedValues: t.reduce((r, n) => r + n.omittedValues, 0)
34
+ };
35
+ }
36
+ function _e(e, t) {
37
+ const a = Array.isArray(e.value) ? e.value : [e.value];
38
+ return ye({
39
+ subject: ke(e.field),
40
+ operator: e.operator,
41
+ values: a,
42
+ reading: De(e),
43
+ relative: Ve(e.relativeMeta),
44
+ latestValue: e.latestValue,
45
+ shownAs: e.label
46
+ }, t);
47
+ }
48
+ function De(e) {
49
+ return e.temporalBucket ? { kind: "bucket", bucket: e.temporalBucket } : Se(e.field.dataType) ? ve : xe;
50
+ }
51
+ function H(e) {
52
+ if (e.kind === "target") return `a target of ${e.targetValue}`;
53
+ const t = e.kind === "previous_period" ? e.offsetPeriods : e.offsetYears, a = e.kind === "previous_period" ? t && t > 1 ? `the period ${t} periods earlier` : "the previous period" : t && t > 1 ? `the same period ${t} years earlier` : "the same period a year earlier", r = [
54
+ e.alignment === "weekday" ? "aligned by weekday" : void 0,
55
+ e.toDate ? "to date (the same elapsed part of the period)" : void 0
56
+ ].filter(Boolean);
57
+ return r.length ? `${a}, ${r.join(", ")}` : a;
58
+ }
59
+ function we(e) {
60
+ return (e == null ? void 0 : e.kind) === "field_date" ? `the ${JSON.stringify(e.label)} filter` : "the dashboard date";
61
+ }
62
+ function Fe(e, t) {
63
+ const a = t.source === "explicit" ? "set on the measure" : `from the dashboard date comparison on ${we(t.owner)}`;
64
+ return `${e} is compared with ${H(t.spec)} (${a})`;
65
+ }
66
+ function k(e) {
67
+ const t = X(e) ?? "undefined";
68
+ return `${M(t, 2654435769).toString(16)}${M(t, 2246822507).toString(16)}`;
69
+ }
70
+ function M(e, t) {
71
+ let a = 3735928559 ^ t, r = 1103547991 ^ t;
72
+ for (let n = 0; n < e.length; n++) {
73
+ const s = e.charCodeAt(n);
74
+ a = Math.imul(a ^ s, 2654435761), r = Math.imul(r ^ s, 1597334677);
75
+ }
76
+ return a = Math.imul(a ^ a >>> 16, 2246822507) ^ Math.imul(r ^ r >>> 13, 3266489909), r = Math.imul(r ^ r >>> 16, 2246822507) ^ Math.imul(a ^ a >>> 13, 3266489909), 4294967296 * (2097151 & r) + (a >>> 0);
77
+ }
78
+ const h = P;
79
+ function Ae(e, t, a) {
80
+ var y;
81
+ const r = t !== "pending" && (t == null ? void 0 : t.status) === "ready" ? t : void 0, n = Me(e, t);
82
+ if (n) {
83
+ const v = t !== "pending" && (t == null ? void 0 : t.status) === "blocked" ? Te(t) : void 0, $ = v ? g(v, h.textChars) : void 0;
84
+ return {
85
+ // A card that runs but is not described still changes when it runs differently.
86
+ fingerprint: k(r ? T(r, a.calendar) : { reason: n, message: $ }),
87
+ description: { status: "not_described", reason: n, ...$ ? { message: $ } : {} }
88
+ };
89
+ }
90
+ const s = r, l = s.queryContext, m = Re(s), o = Oe(s, a), c = Be(s), i = je(s), u = l.drillSteps.map((v) => g(
91
+ `${JSON.stringify(v.label)} (then by ${v.toField.label || v.toField.name})`,
92
+ h.textChars
93
+ )), d = (y = s.card.sql) == null ? void 0 : y.trim(), b = d ? Ne(s) : [], f = {
94
+ fields: I(m.length, h.cardFields),
95
+ filters: I(o.length, h.cardFilters),
96
+ controls: I(c.length, h.cardControls),
97
+ drillSteps: I(u.length, h.drillSteps),
98
+ sqlParameters: I(b.length, h.sqlParameters),
99
+ comparisons: I(i.length, h.cardFields)
100
+ }, p = Object.fromEntries(Object.entries(f).filter(([, v]) => v > 0));
101
+ return {
102
+ fingerprint: k(T(s, a.calendar)),
103
+ description: {
104
+ status: "described",
105
+ fields: m.slice(0, h.cardFields),
106
+ filters: o.slice(0, h.cardFilters),
107
+ controls: c.slice(0, h.cardControls),
108
+ drillPath: u.slice(0, h.drillSteps),
109
+ ...d ? {
110
+ sql: {
111
+ text: g(d, h.sqlChars),
112
+ parameters: b.slice(0, h.sqlParameters)
113
+ }
114
+ } : {},
115
+ ...i.length ? { comparisons: i.slice(0, h.cardFields) } : {},
116
+ ...Object.keys(p).length ? { omitted: p } : {}
117
+ }
118
+ };
119
+ }
120
+ function Me(e, t) {
121
+ if (e.type === "matrixTable") return "matrix";
122
+ if (e.type === "custom" || Y(e)) return "custom_visual";
123
+ if (ee(e.python ?? "").trim()) return "python";
124
+ if (t === "pending") return "snapshot_pending";
125
+ if ((t == null ? void 0 : t.status) !== "ready") return "snapshot_blocked";
126
+ }
127
+ function Te(e) {
128
+ if (e.message) return e.message;
129
+ const t = e.mappingDispositions.flatMap((a) => a.status === "block" ? [`${a.inputId} (${a.reason})`] : []);
130
+ return t.length ? `dashboard inputs that cannot apply to this card: ${t.join(", ")}` : void 0;
131
+ }
132
+ function T(e, t) {
133
+ return ce(e.card, e.queryContext, t).queryInputIdentity;
134
+ }
135
+ const Ee = [
136
+ ["row", "rows"],
137
+ ["column", "columns"],
138
+ ["measure", "metrics"],
139
+ ["detail", "details"]
140
+ ];
141
+ function Re(e) {
142
+ const { fields: t } = te({
143
+ type: e.card.type,
144
+ config: e.queryContext.finalConfig
145
+ });
146
+ return Ee.flatMap(([a, r]) => t[r].map((n) => {
147
+ const s = n.aggregate, l = n.granularity;
148
+ return {
149
+ role: a,
150
+ label: g(n.label || n.name, h.labelChars),
151
+ name: g(n.name, h.labelChars),
152
+ ...s ? { aggregate: s } : {},
153
+ ...l ? { granularity: l } : {}
154
+ };
155
+ }));
156
+ }
157
+ function je(e) {
158
+ const t = e.queryContext;
159
+ return (t.finalConfig.metricColumns ?? []).flatMap((a) => {
160
+ const r = $e({
161
+ metricComparison: a.comparison,
162
+ globalDateComparison: t.globalDateComparison
163
+ });
164
+ return r ? [g(Fe(Le(a.label || a.name), r), h.textChars)] : [];
165
+ });
166
+ }
167
+ function Le(e) {
168
+ return JSON.stringify(e);
169
+ }
170
+ function Oe(e, { calendar: t }) {
171
+ const a = e.queryContext, r = { maxListedValues: h.inputValues, timeZone: t.tz }, n = e.card.inlineFilters ?? [], s = new Set(n.map((i) => i.id)), l = new Map(
172
+ [...a.queryFilterDefinitions, ...n].map((i) => [i.id, i.title])
173
+ ), m = a.cardFilterValues.map((i) => {
174
+ const u = l.get(i.filterId) || i.name, d = i.dateOwner === "global_date" ? `${u} (the dashboard date, on this card's field ${i.name})` : `${u} (field ${i.name})`, b = B(i, d, r);
175
+ return {
176
+ origin: s.has(i.filterId) ? "card_input" : "dashboard_input",
177
+ text: g(b.text, h.textChars),
178
+ ...b.omittedValues ? { omittedValues: b.omittedValues } : {}
179
+ };
180
+ }), o = a.resolvedFilterParts, c = [["card", o.authored], ["drill", o.drill], ["selection", o.selections]].flatMap(([i, u]) => qe(u, r).map((d) => ({
181
+ origin: i,
182
+ text: g(d.text, h.textChars),
183
+ ...d.omittedValues ? { omittedValues: d.omittedValues } : {}
184
+ })));
185
+ return [...m, ...c];
186
+ }
187
+ function Pe(e) {
188
+ const t = e.queryContext, a = L({
189
+ sql: e.card.sql,
190
+ controlBindings: t.controlBindings
191
+ });
192
+ return [.../* @__PURE__ */ new Set([
193
+ ...t.controlBindings.map((n) => n.controlId),
194
+ ...a.map((n) => n.controlId)
195
+ ])].map((n) => ({
196
+ id: n,
197
+ bindings: t.controlBindings.filter((s) => s.controlId === n),
198
+ sqlParameterIds: a.filter((s) => s.controlId === n).map((s) => s.paramId)
199
+ }));
200
+ }
201
+ function Be(e) {
202
+ const t = e.queryContext, a = new Map(
203
+ [...t.controlDefinitions, ...t.cardControlDefinitions].map((r) => [r.id, r])
204
+ );
205
+ return Pe(e).map(({ id: r, bindings: n, sqlParameterIds: s }) => {
206
+ var o;
207
+ const l = t.controlValues[r], m = /* @__PURE__ */ new Set([
208
+ ...n.filter((c) => c.target !== "sql_param").map((c) => ze(c, l)),
209
+ ...s.map((c) => `SQL parameter ${c}`)
210
+ ]);
211
+ return {
212
+ label: g(((o = a.get(r)) == null ? void 0 : o.label) || r, h.labelChars),
213
+ valueText: g(
214
+ `${D(l, { maxListedValues: h.inputValues }).text}${m.size ? `; ${[...m].join("; ")}` : ""}`,
215
+ h.textChars
216
+ )
217
+ };
218
+ });
219
+ }
220
+ function Ne(e) {
221
+ const t = e.queryContext;
222
+ return L({ sql: e.card.sql, controlBindings: t.controlBindings }).map((a) => ({
223
+ name: g(a.paramId, h.labelChars),
224
+ valueText: g(
225
+ D(t.controlValues[a.controlId], { maxListedValues: h.inputValues }).text,
226
+ h.textChars
227
+ )
228
+ }));
229
+ }
230
+ function ze(e, t) {
231
+ const a = typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? String(t) : void 0;
232
+ switch (e.target) {
233
+ case "sql_param":
234
+ return `SQL parameter ${e.paramId}`;
235
+ case "presentation_currency":
236
+ return "display currency only";
237
+ case "config_aggregation":
238
+ return `sets the aggregation${a && e.mapping[a] ? ` to ${e.mapping[a]}` : ""}`;
239
+ case "config_grain":
240
+ return `sets the time grain${a && e.mapping[a] ? ` to ${e.mapping[a]}` : ""}`;
241
+ case "config_field_selector":
242
+ case "config_metric_selector": {
243
+ const r = a ? e.mapping[a] : void 0, n = e.target === "config_field_selector" ? "field" : "measure";
244
+ if (!r) return `chooses the ${n}`;
245
+ const s = "kind" in r ? `Matrix ${r.id}` : `${r.label || r.name}${"aggregate" in r && r.aggregate ? ` (${r.aggregate})` : ""}`;
246
+ return `chooses the ${n} ${JSON.stringify(s)}`;
247
+ }
248
+ }
249
+ }
250
+ class V extends Error {
251
+ constructor(a, r) {
252
+ super(r);
253
+ F(this, "code");
254
+ this.name = "AssistantContextSourceError", this.code = a;
255
+ }
256
+ }
257
+ const C = P, He = "Untitled";
258
+ function Je(e) {
259
+ var f;
260
+ if (e.surface === "none")
261
+ return E({
262
+ version: A,
263
+ surface: "none",
264
+ otherSheets: [],
265
+ activeInputs: [],
266
+ cards: [],
267
+ timeZone: e.timeZone
268
+ });
269
+ const { dashboard: t, sheetId: a, calendar: r } = e, n = t.sheets ?? [], s = n.find((p) => p.id === a);
270
+ if (a !== null && !s)
271
+ throw new V("sheet_not_found", `sheet ${a} is not on dashboard ${t.id}`);
272
+ const l = n.filter((p) => p.id !== a), m = s ? S(t).filter((p) => p.sheetId === a) : [], o = m.slice(0, C.summaryCards), c = e.selectedCard ? m.find((p) => p.cardId === e.selectedCard.cardId) : void 0, i = ((f = e.selectedCard) == null ? void 0 : f.card) ?? (c == null ? void 0 : c.card);
273
+ if (e.selectedCard && !i)
274
+ throw new V(
275
+ "card_not_on_sheet",
276
+ `card ${e.selectedCard.cardId} is not on sheet ${a}`
277
+ );
278
+ const u = s ? Qe(e, s, m) : [], d = {
279
+ otherSheets: I(l.length, C.otherSheets),
280
+ activeInputs: I(u.length, C.activeInputs),
281
+ cards: I(m.length, C.summaryCards)
282
+ }, b = Object.fromEntries(Object.entries(d).filter(([, p]) => p > 0));
283
+ return E({
284
+ version: A,
285
+ surface: e.editing ? "editor" : "dashboard",
286
+ dashboard: {
287
+ id: t.id,
288
+ title: x(t.title),
289
+ unsavedEdits: e.unsavedEdits
290
+ },
291
+ ...s ? { sheet: { id: s.id, title: x(s.title) } } : {},
292
+ otherSheets: l.slice(0, C.otherSheets).map((p) => ({ id: p.id, title: x(p.title) })),
293
+ activeInputs: u.slice(0, C.activeInputs),
294
+ cards: o.map((p) => J(p.card)),
295
+ ...i && e.selectedCard ? { selectedCard: Ze(i, e.selectedCard.snapshot, r) } : {},
296
+ ...e.editing ? { editing: e.editing } : {},
297
+ ...Object.keys(b).length ? { omitted: b } : {},
298
+ timeZone: r.tz
299
+ });
300
+ }
301
+ function Ze(e, t, a) {
302
+ return { ...J(e), ...Ae(e, t, { calendar: a }) };
303
+ }
304
+ function E(e) {
305
+ const t = Ce(e);
306
+ if (t > C.contextBytes) throw new Ie(t);
307
+ return e;
308
+ }
309
+ function x(e) {
310
+ return g((e == null ? void 0 : e.trim()) || He, C.labelChars);
311
+ }
312
+ function J(e) {
313
+ const t = Ge(e);
314
+ return {
315
+ id: e.id,
316
+ title: x(e.title),
317
+ visualType: e.type,
318
+ ...t ? { source: t } : {}
319
+ };
320
+ }
321
+ function Ge(e) {
322
+ var a;
323
+ const t = se(e);
324
+ if (t.kind === "config")
325
+ return t.executableSources.length === 1 ? t.executableSources[0] : void 0;
326
+ if (t.kind === "sql") {
327
+ const r = ((a = e.dataSource) == null ? void 0 : a.connectionId) || e.connectionId;
328
+ return r ? { kind: "sql", connectionId: r } : void 0;
329
+ }
330
+ }
331
+ function Qe(e, t, a) {
332
+ const { dashboard: r } = e, n = t.kind === "document" ? "document" : "dashboard", s = n === "document" ? void 0 : e.transientContexts, { shouldApplyDashboardFilters: l } = ue(s), m = (u, d) => ae({
333
+ dashboard: r,
334
+ sheetId: t.id,
335
+ card: u,
336
+ sectionId: d,
337
+ runtimeValues: e.runtimeValues,
338
+ transientContexts: s,
339
+ calendar: e.calendar
340
+ }), o = /* @__PURE__ */ new Map(), c = (u) => {
341
+ u.inputs.forEach((d, b) => {
342
+ if (R(d)) return;
343
+ const f = u.resolvedInputs[b], p = o.get(d.id) ?? { input: d };
344
+ !p.resolved && f && Ue(f) && (p.resolved = f), o.set(d.id, p);
345
+ });
346
+ };
347
+ c(m(null));
348
+ let i = re(r).filter((u) => {
349
+ var d;
350
+ return !R(u) && !((d = o.get(u.id)) != null && d.resolved);
351
+ });
352
+ for (const u of a) {
353
+ if (i.length === 0) break;
354
+ const d = u.kind === "documentSectionCard" ? u.sectionId : void 0, b = { sheetId: t.id, sheetKind: n, cardId: u.cardId, sectionId: d };
355
+ if (i.some((f) => U(f, b))) {
356
+ try {
357
+ c(m(u.card, d));
358
+ } catch {
359
+ continue;
360
+ }
361
+ i = i.filter((f) => {
362
+ var p;
363
+ return !((p = o.get(f.id)) != null && p.resolved);
364
+ });
365
+ }
366
+ }
367
+ return [...o.values()].flatMap((u) => {
368
+ if (!u.resolved) return [];
369
+ const d = u.input.kind === "filter" && !l && !K(u.input), b = Ke(u, e.calendar.tz, d);
370
+ return b ? [b] : [];
371
+ });
372
+ }
373
+ function R(e) {
374
+ var a;
375
+ const t = (a = e.compatibility) == null ? void 0 : a.source;
376
+ return t === "cardInlineFilter" || t === "cardControl";
377
+ }
378
+ function Ue(e) {
379
+ if (e.kind === "filter") return !!e.filterValue;
380
+ const t = e.controlValue;
381
+ return t == null ? !1 : typeof t == "string" ? t.trim().length > 0 : Array.isArray(t) ? t.length > 0 : !0;
382
+ }
383
+ function Ke(e, t, a) {
384
+ const { input: r, resolved: n } = e, s = x(r.label), l = {
385
+ inputId: r.id,
386
+ label: s,
387
+ ...r.kind === "filter" && ne(r.filter) ? { globalDate: !0 } : {}
388
+ };
389
+ if (r.runtimeScope === "perCard" || r.runtimeScope === "perDocumentSection")
390
+ return { ...l, value: { kind: "varies" } };
391
+ const m = { maxListedValues: C.inputValues, timeZone: t };
392
+ let o;
393
+ if ((n == null ? void 0 : n.kind) === "filter" && n.filterValue)
394
+ o = B(n.filterValue, s, m);
395
+ else if ((n == null ? void 0 : n.kind) === "control") {
396
+ const i = D(n.controlValue, m);
397
+ o = { text: `${s} is set to ${i.text}`, omittedValues: i.omittedValues };
398
+ }
399
+ if (!o) return;
400
+ const c = (n == null ? void 0 : n.kind) === "filter" ? n.comparisonSelection : void 0;
401
+ return (c == null ? void 0 : c.mode) === "period" && (o = { ...o, text: `${o.text}; compared with ${H(c.spec)}` }), {
402
+ ...l,
403
+ value: {
404
+ kind: "set",
405
+ text: g(o.text, C.textChars),
406
+ ...o.omittedValues ? { omittedValues: o.omittedValues } : {},
407
+ ...a ? { notApplied: "opened_from_another_dashboard" } : {},
408
+ // The resolved value itself, with any date comparison on it and whether
409
+ // the view applies it, so any change counts, shown or not.
410
+ fingerprint: k(
411
+ (n == null ? void 0 : n.kind) === "filter" ? { filter: n.filterValue, comparison: n.comparisonSelection ?? null, notApplied: a } : { control: n == null ? void 0 : n.controlValue }
412
+ )
413
+ }
414
+ };
415
+ }
416
+ function ct(e) {
417
+ return We(e).context;
418
+ }
419
+ function We(e) {
420
+ const { place: t, calendar: a } = e, r = q(e.dashboard), n = pe({ dashboard: r, host: {}, calendar: a, materializeInputs: !1 }), s = {
421
+ ..._({ dashboard: r, capture: {}, calendar: a }).runtimeValues,
422
+ cardViewState: t.cardViewState ?? {}
423
+ }, l = t.cardId ? Ye(r, t.cardId) : void 0, m = l ? Z({
424
+ dashboard: r,
425
+ location: l,
426
+ runtimeValues: s,
427
+ semanticExecutionPayload: e.semanticExecutionPayload,
428
+ calendar: a,
429
+ withRequest: !0
430
+ }) : void 0, o = Je({
431
+ surface: "dashboard",
432
+ dashboard: r,
433
+ // A sheet that does not hold the card is refused by the projection.
434
+ sheetId: t.sheetId ?? (l == null ? void 0 : l.sheetId) ?? n.selectedSheetId,
435
+ unsavedEdits: !1,
436
+ runtimeValues: s,
437
+ transientContexts: void 0,
438
+ ...l && m !== void 0 ? { selectedCard: { cardId: l.cardId, snapshot: m } } : {},
439
+ calendar: a
440
+ });
441
+ return {
442
+ context: o,
443
+ openDashboard: r,
444
+ ...o.selectedCard && m !== void 0 ? { cardReplay: Xe({ dashboard: r, cardId: o.selectedCard.id, snapshot: m }) } : {}
445
+ };
446
+ }
447
+ function Xe(e) {
448
+ const t = e.dashboard ? S(e.dashboard).find((r) => r.cardId === e.cardId) : void 0, a = w({
449
+ card: e.card ?? (t == null ? void 0 : t.card),
450
+ snapshot: e.snapshot,
451
+ documentSection: (t == null ? void 0 : t.kind) === "documentSectionCard"
452
+ });
453
+ return a.status === "ready" ? { selectedCardRequest: a.request } : {
454
+ selectedCardUnavailable: {
455
+ cardId: e.cardId,
456
+ reason: a.reason,
457
+ ...a.message ? { message: a.message } : {}
458
+ }
459
+ };
460
+ }
461
+ function Ye(e, t) {
462
+ const a = S(e).find((r) => r.cardId === t);
463
+ if (!a)
464
+ throw new V("card_not_found", `card ${t} is not on dashboard ${e.id}`);
465
+ return a;
466
+ }
467
+ function Z(e) {
468
+ const { dashboard: t, location: a, runtimeValues: r } = e, n = a.kind === "documentSectionCard" ? et(t, a) : void 0;
469
+ return O({
470
+ dashboard: t,
471
+ cardId: a.cardId,
472
+ cardOverride: a.card,
473
+ sheetId: a.sheetId,
474
+ transientContexts: e.transientContexts,
475
+ cardViewStates: r.cardViewState,
476
+ viewerTableSettings: void 0,
477
+ adHocFilterValues: r.adHocFilterValues,
478
+ inlineFilterValuesMap: r.inlineFilterValuesMap,
479
+ dashboardControlValues: r.controlValues,
480
+ cardControlValuesMap: r.cardControlValuesMap,
481
+ dashboardInputValues: r.dashboardInputValues,
482
+ semanticExecutionPayload: e.semanticExecutionPayload,
483
+ calendar: e.calendar,
484
+ ...n ? { documentSection: n } : {},
485
+ ...e.withRequest ? { withRequest: !0 } : {}
486
+ });
487
+ }
488
+ function w(e) {
489
+ var a;
490
+ const { snapshot: t } = e;
491
+ if (e.documentSection) return { status: "unavailable", reason: "document_section" };
492
+ if (((a = e.card) == null ? void 0 : a.type) === "matrixTable") return { status: "unavailable", reason: "matrix" };
493
+ if (t === "pending") return { status: "unavailable", reason: "pending" };
494
+ if (!t || t.status !== "ready")
495
+ return {
496
+ status: "unavailable",
497
+ reason: "blocked",
498
+ ...t != null && t.message ? { message: t.message } : {}
499
+ };
500
+ if (t.matrix) return { status: "unavailable", reason: "matrix" };
501
+ if (!t.request) return { status: "unavailable", reason: "no_query" };
502
+ try {
503
+ const { connectionId: r, requestPayloadBase: n } = me(t.card, t.request);
504
+ return { status: "ready", request: { cardId: t.card.id, connectionId: r, payload: n } };
505
+ } catch {
506
+ return { status: "unavailable", reason: "no_query" };
507
+ }
508
+ }
509
+ function ut(e) {
510
+ const { calendar: t } = e, a = e.host ?? {}, r = q(
511
+ a.controlContract ? fe(he(e.dashboard), {
512
+ controlContractOverrides: a.controlContract,
513
+ cardId: e.cardId
514
+ }) : e.dashboard
515
+ ), n = S(r).find((c) => c.cardId === e.cardId);
516
+ if (!n) return { status: "refused", reason: "card_not_found" };
517
+ if (n.kind === "documentSectionCard") return { status: "refused", reason: "document_section" };
518
+ const { runtimeValues: s, transientContexts: l } = _({
519
+ dashboard: r,
520
+ capture: a,
521
+ calendar: t
522
+ }), m = Z({
523
+ dashboard: r,
524
+ location: n,
525
+ runtimeValues: s,
526
+ semanticExecutionPayload: e.semanticExecutionPayload,
527
+ calendar: t,
528
+ transientContexts: l,
529
+ withRequest: !0
530
+ });
531
+ if (!m) return { status: "refused", reason: "card_not_found" };
532
+ const o = w({ card: n.card, snapshot: m, documentSection: !1 });
533
+ return o.status === "ready" ? { ...o, renderConfig: m.queryContext.finalConfig } : o.reason === "pending" ? { status: "refused", reason: "blocked" } : {
534
+ status: "refused",
535
+ reason: o.reason,
536
+ ...o.message ? { message: o.message } : {}
537
+ };
538
+ }
539
+ function et(e, t) {
540
+ var r, n, s;
541
+ const a = (r = e.sheets) == null ? void 0 : r.find((l) => l.id === t.sheetId);
542
+ if ((s = (n = a == null ? void 0 : a.document) == null ? void 0 : n.inputs) != null && s.length && j(e, t.sheetId).length === 0)
543
+ throw new V(
544
+ "document_inputs_not_built",
545
+ `card ${t.cardId} runs with the document's own inputs on sheet ${t.sheetId}, which only the page builds`
546
+ );
547
+ return {
548
+ sheetId: t.sheetId,
549
+ sectionId: t.sectionId,
550
+ documentFilterValues: [],
551
+ documentControlDefinitions: [],
552
+ documentControlValues: {}
553
+ };
554
+ }
555
+ function mt(e) {
556
+ const { calendar: t } = e, a = q(e.dashboard), r = a.variables ?? [], n = r.find((f) => f.name === e.name) ?? r.find((f) => f.id === e.name);
557
+ if (!n)
558
+ return { status: "refused", reason: "variable_unknown", message: `No variable named ${e.name} on this dashboard.`, available: r.map((f) => f.name) };
559
+ const s = (a.sheets ?? []).find((f) => f.id === e.sheetId);
560
+ if (!s)
561
+ return {
562
+ status: "refused",
563
+ reason: "place_unknown",
564
+ message: `No sheet ${e.sheetId} on this dashboard; a variable is derived at a tab or a Document.`,
565
+ available: (a.sheets ?? []).map((f) => f.id)
566
+ };
567
+ const l = W(a, n.id);
568
+ if ((l == null ? void 0 : l.kind) !== "variable") return { status: "refused", reason: "broken", message: `${n.name} has no card to run.` };
569
+ const m = oe(s) && s.document ? s.document : void 0, o = tt(a, s.id, !!m, e.inputs ?? {}, t);
570
+ if (!o.ok) return { status: "refused", reason: "broken", message: o.message };
571
+ const { runtimeValues: c, transientContexts: i } = _({ dashboard: a, capture: o.capture, calendar: t }), u = m ? { sheetId: s.id, sectionId: void 0, documentFilterValues: [], documentControlDefinitions: [], documentControlValues: {} } : void 0, d = O({
572
+ dashboard: a,
573
+ cardId: n.id,
574
+ cardOverride: l.card,
575
+ sheetId: s.id,
576
+ transientContexts: i,
577
+ cardViewStates: c.cardViewState,
578
+ viewerTableSettings: void 0,
579
+ adHocFilterValues: c.adHocFilterValues,
580
+ inlineFilterValuesMap: c.inlineFilterValuesMap,
581
+ dashboardControlValues: c.controlValues,
582
+ cardControlValuesMap: c.cardControlValuesMap,
583
+ dashboardInputValues: c.dashboardInputValues,
584
+ semanticExecutionPayload: e.semanticExecutionPayload,
585
+ calendar: t,
586
+ ...u ? { documentSection: u } : {},
587
+ withRequest: !0
588
+ });
589
+ if ((d == null ? void 0 : d.status) === "blocked")
590
+ return d.reason === "requiredInput" ? { status: "refused", reason: "held", message: `${n.name} waits for ${d.missingRequiredLabels.join(", ")}.`, missingRequired: d.missingRequiredLabels } : { status: "refused", reason: "broken", message: d.message ?? `${n.name} can't run until its filter mapping is resolved.` };
591
+ const b = w({ card: l.card, snapshot: d, documentSection: !1 });
592
+ return b.status !== "ready" ? { status: "refused", reason: "broken", message: b.message ?? `${n.name} has no query to run.` } : { status: "ready", variable: n, place: m ? "document" : "sheet", request: b.request };
593
+ }
594
+ function tt(e, t, a, r, n) {
595
+ const s = Object.keys(r);
596
+ if (!s.length) return { ok: !0, capture: {} };
597
+ if (!a) return { ok: !1, message: "Values are given for a Document's inputs; at a tab the variable runs with the saved defaults." };
598
+ const l = j(e, t), m = new Map(l.map((i) => [i.variableName, i])), o = s.filter((i) => !m.has(i));
599
+ if (o.length)
600
+ return { ok: !1, message: `This Document has no input named ${o.join(", ")}; its inputs are ${[...m.keys()].join(", ") || "none"}.` };
601
+ let c = be(e, { adHocFilterValues: [], controlOverrides: void 0, dashboardInputValues: {} }, n);
602
+ for (const [i, u] of Object.entries(r)) {
603
+ const d = m.get(i);
604
+ let b;
605
+ if (d.kind === "control")
606
+ b = le(u);
607
+ else {
608
+ const f = Array.isArray(u) ? u : [u];
609
+ if (!f.every((y) => typeof y == "string" || typeof y == "number" || typeof y == "boolean"))
610
+ return { ok: !1, message: `${i} takes a value or a list of values.` };
611
+ const p = f.every((y) => typeof y == "number") ? f : f.map(String);
612
+ b = ie(ge(d.filter, { filterId: d.filter.id, values: p }, n));
613
+ }
614
+ if (!b) return { ok: !1, message: `${i} has no usable value.` };
615
+ c = de(c, d, { sheetId: t }, b);
616
+ }
617
+ return { ok: !0, capture: { dashboardInputExecutionSnapshot: { mode: "document", sheetId: t, dashboardInputValues: c } } };
618
+ }
619
+ export {
620
+ V as A,
621
+ Xe as a,
622
+ ut as b,
623
+ mt as c,
624
+ w as d,
625
+ ct as e,
626
+ We as f,
627
+ Z as g,
628
+ Je as p
629
+ };
@@ -1,4 +1,4 @@
1
- import { s as p, S as h } from "./matrix-operation-contract-DsLdFdSa.js";
1
+ import { s as p, S as h } from "./matrix-operation-contract-Eb6elidS.js";
2
2
  function f(e, l, t) {
3
3
  return e.length === 1 && t(e[0]) === t(l) ? { tuples: [], outcome: "cleared" } : { tuples: [l], outcome: "selected" };
4
4
  }