react-semaphor 0.1.507 → 0.1.509

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 (254) hide show
  1. package/DATA_APP_SDK.md +56 -0
  2. package/dist/analytics-protocol/index.cjs +1 -1
  3. package/dist/analytics-protocol/index.js +194 -172
  4. package/dist/appearance/index.cjs +1 -1
  5. package/dist/appearance/index.js +1 -1
  6. package/dist/appearance-runtime/index.cjs +1 -1
  7. package/dist/appearance-runtime/index.js +1 -1
  8. package/dist/brand-studio/index.cjs +2 -2
  9. package/dist/brand-studio/index.js +279 -250
  10. package/dist/briefings/index.cjs +1 -1
  11. package/dist/briefings/index.js +3 -3
  12. package/dist/chunks/appearance-context-DzqCdhB4.cjs +1 -0
  13. package/dist/chunks/{appearance-context-XviHOhWJ.js → appearance-context-VJdrKi7r.js} +2 -1
  14. package/dist/chunks/{appearance-runtime-provider-D0xVQWnH.js → appearance-runtime-provider-CC4HT2Gi.js} +2 -2
  15. package/dist/chunks/{appearance-runtime-provider-Ca8rxO86.cjs → appearance-runtime-provider-D5pkvgE4.cjs} +1 -1
  16. package/dist/chunks/calculated-field-identity-BiTGmnST.cjs +1 -0
  17. package/dist/chunks/calculated-field-identity-CJL54uFx.js +1373 -0
  18. package/dist/chunks/{constants-NUleP4DY.js → card-config-utils-Bq1enstT.js} +260 -260
  19. package/dist/chunks/card-config-utils-CMO4_zVs.cjs +1 -0
  20. package/dist/chunks/{dashboard-briefing-launcher-DXTpU85p.js → dashboard-briefing-launcher-B5AQu-Vb.js} +12 -12
  21. package/dist/chunks/{dashboard-briefing-launcher-C8nDSDnV.cjs → dashboard-briefing-launcher-BoXFrqq0.cjs} +1 -1
  22. package/dist/chunks/{dashboard-controls-CyL0yimg.js → dashboard-controls-CKKkSXEX.js} +16 -14
  23. package/dist/chunks/dashboard-controls-gUVkQm8o.cjs +52 -0
  24. package/dist/chunks/dashboard-json-B7fSi6_b.cjs +1 -0
  25. package/dist/chunks/{dashboard-json-5Jr3RudV.js → dashboard-json-CAJJquVx.js} +9 -9
  26. package/dist/chunks/edit-dashboard-visual-AZetLUv1.cjs +172 -0
  27. package/dist/chunks/{edit-dashboard-visual-C7X-um9g.js → edit-dashboard-visual-DCnbqRRn.js} +1986 -1990
  28. package/dist/chunks/{editor-action-buttons-CcDm8nA5.cjs → editor-action-buttons-CBQsVYdt.cjs} +2 -2
  29. package/dist/chunks/{editor-action-buttons-C5Wja_J4.js → editor-action-buttons-DDA5JGwO.js} +6 -6
  30. package/dist/chunks/field-aggregations-DUb0NU6c.js +1229 -0
  31. package/dist/chunks/field-aggregations-jSi77h9Z.cjs +1 -0
  32. package/dist/chunks/{field-dependencies-DVl2p1Nm.js → field-dependencies-Cl97kkHy.js} +30 -34
  33. package/dist/chunks/{field-dependencies-r_U0CGQ-.cjs → field-dependencies-DIab72rQ.cjs} +1 -1
  34. package/dist/chunks/{index-BVr4fcCB.js → index-0pdaQ9e1.js} +5 -5
  35. package/dist/chunks/{index-De2QNsqV.js → index-CL2lvhwk.js} +47783 -46019
  36. package/dist/chunks/{index-C9KXfCkC.js → index-CLIro-EG.js} +3 -0
  37. package/dist/chunks/index-Cx3qmRUB.cjs +1 -0
  38. package/dist/chunks/{index-BlYf8gNa.cjs → index-DhlVxvyI.cjs} +1 -1
  39. package/dist/chunks/index-DkEAikW8.cjs +1420 -0
  40. package/dist/chunks/{matrix-card-DACDwdTq.js → matrix-card-CnKQpnsj.js} +1 -1
  41. package/dist/chunks/{matrix-card-CRXcmAjp.cjs → matrix-card-U4c72doZ.cjs} +1 -1
  42. package/dist/chunks/{matrix-control-sources-ClQzIk7E.js → matrix-control-sources-CRRdP03Q.js} +165 -134
  43. package/dist/chunks/matrix-control-sources-FjxGIbqk.cjs +1 -0
  44. package/dist/chunks/{matrix-formatter-7GLTcBuy.cjs → matrix-formatter-CveLJo6S.cjs} +1 -1
  45. package/dist/chunks/{matrix-formatter-xsq7n_e6.js → matrix-formatter-ZVS5QOuq.js} +2 -2
  46. package/dist/chunks/matrix-member-presentation-CFHjdrxT.cjs +1 -0
  47. package/dist/chunks/matrix-member-presentation-CzGZJd3a.js +182 -0
  48. package/dist/chunks/matrix-operation-contract-DoiWTUbT.cjs +1 -0
  49. package/dist/chunks/matrix-operation-contract-xL8IhFzp.js +1802 -0
  50. package/dist/chunks/{pivot-header-presentation-3wqWChFd.cjs → pivot-header-presentation-Cxz8-06f.cjs} +1 -1
  51. package/dist/chunks/{pivot-header-presentation-D44ODZGn.js → pivot-header-presentation-DVylCBHB.js} +2 -2
  52. package/dist/chunks/{pivot-result-lifecycle-DZ0ZSMoM.cjs → pivot-result-lifecycle-BiERyXnS.cjs} +1 -1
  53. package/dist/chunks/{pivot-result-lifecycle-BSmqVkVG.js → pivot-result-lifecycle-CmjpW7qG.js} +1 -1
  54. package/dist/chunks/{report-preferences-dialog-xADifRXs.js → report-preferences-dialog-Bv2VIOKc.js} +4 -4
  55. package/dist/chunks/report-preferences-dialog-Wg9g9fIj.cjs +1 -0
  56. package/dist/chunks/{search-BHsQIWBV.js → selection-reducer-B94WgZ9V.js} +55 -11
  57. package/dist/chunks/selection-reducer-CGKKsaPa.cjs +26 -0
  58. package/dist/chunks/{semantic-format-BhIL1PXP.cjs → semantic-format-BzH69TRq.cjs} +1 -1
  59. package/dist/chunks/{semantic-format-C3amkGmY.js → semantic-format-CBlRO8Aw.js} +1 -1
  60. package/dist/chunks/{switch-DHGiC0aU.js → switch-CD4uGTZI.js} +7450 -7694
  61. package/dist/chunks/switch-iC1x2dcE.cjs +134 -0
  62. package/dist/chunks/token-types-Ahh5u4iT.cjs +1 -0
  63. package/dist/chunks/token-types-CPde8_LG.js +8 -0
  64. package/dist/chunks/{update-policy-Cc9h57pA.cjs → update-policy-COjFudhl.cjs} +1 -1
  65. package/dist/chunks/{update-policy-eTcz52jO.js → update-policy-D9q1Tz8k.js} +1 -1
  66. package/dist/dashboard/index.cjs +1 -1
  67. package/dist/dashboard/index.js +1 -1
  68. package/dist/dashboard-authoring/index.cjs +3 -3
  69. package/dist/dashboard-authoring/index.js +734 -622
  70. package/dist/data-app-builder/index.cjs +1 -1
  71. package/dist/data-app-builder/index.js +3 -3
  72. package/dist/data-app-codegen/index.cjs +1 -1
  73. package/dist/data-app-codegen/index.js +2 -2
  74. package/dist/data-app-codegen-node/index.cjs +94 -92
  75. package/dist/data-app-codegen-node/index.js +337 -333
  76. package/dist/data-app-sdk/index.cjs +9 -9
  77. package/dist/data-app-sdk/index.js +1091 -969
  78. package/dist/data-app-sdk-adapters/index.cjs +1 -1
  79. package/dist/data-app-sdk-adapters/index.js +104 -96
  80. package/dist/data-app-sdk-validation/index.cjs +1 -1
  81. package/dist/data-app-sdk-validation/index.js +2 -2
  82. package/dist/format-utils/index.cjs +1 -1
  83. package/dist/format-utils/index.js +8 -8
  84. package/dist/index.cjs +1 -1
  85. package/dist/index.js +15 -15
  86. package/dist/style.css +1 -1
  87. package/dist/surfboard/index.cjs +1 -1
  88. package/dist/surfboard/index.js +2 -2
  89. package/dist/types/brand-studio/brand-studio-draft.d.ts +3 -1
  90. package/dist/types/components/dashboard/card-selection-pill.d.ts +5 -0
  91. package/dist/types/components/dashboard/dashboard-container.d.ts +1 -1
  92. package/dist/types/components/dashboard/drill-breadcrumb.d.ts +1 -0
  93. package/dist/types/components/dashboard/drill-navigation-controls.d.ts +3 -3
  94. package/dist/types/components/interactions/applied-filters-display.d.ts +6 -1
  95. package/dist/types/components/interactions/click-to-filter-review-dialog.d.ts +21 -0
  96. package/dist/types/components/interactions/dashboard-drill-host.d.ts +13 -0
  97. package/dist/types/components/interactions/filter-badge-tooltip.d.ts +4 -4
  98. package/dist/types/components/interactions/insight-modal.d.ts +4 -14
  99. package/dist/types/components/interactions/insight-viewer.d.ts +7 -19
  100. package/dist/types/components/interactions/interactions-sheet.d.ts +6 -0
  101. package/dist/types/components/interactions/panels/click-to-filter-panel.d.ts +20 -0
  102. package/dist/types/components/interactions/reusable/interaction-selection-popover.d.ts +2 -2
  103. package/dist/types/components/interactions/sheet/action-editor.d.ts +17 -0
  104. package/dist/types/components/interactions/sheet/action-meta.d.ts +45 -0
  105. package/dist/types/components/interactions/sheet/action-picker.d.ts +7 -0
  106. package/dist/types/components/interactions/sheet/click-outcome-preview.d.ts +10 -0
  107. package/dist/types/components/interactions/sheet/interactions-home.d.ts +28 -0
  108. package/dist/types/components/interactions/sheet/sheet-parts.d.ts +37 -0
  109. package/dist/types/components/surfboard/filter/dashboard-filter-mapping-panel.d.ts +28 -1
  110. package/dist/types/components/surfboard/filter/selection-chip.d.ts +11 -0
  111. package/dist/types/components/surfboard/filter/selection-filter-section.d.ts +4 -0
  112. package/dist/types/components/surfboard/filter/use-dashboard-filter-mapping-popover.d.ts +3 -0
  113. package/dist/types/components/ui/resizable.d.ts +1 -1
  114. package/dist/types/components/visual/matrix-table/matrix-interaction-actions.d.ts +24 -3
  115. package/dist/types/components/visual/matrix-table/matrix-selection-click.d.ts +6 -0
  116. package/dist/types/components/visual/matrix-table/matrix-window-viewer.d.ts +1 -1
  117. package/dist/types/data-app-sdk/adapters.d.ts +3 -2
  118. package/dist/types/data-app-sdk/builders.d.ts +2 -1
  119. package/dist/types/data-app-sdk/contracts.d.ts +44 -2
  120. package/dist/types/data-app-sdk/index.d.ts +1 -0
  121. package/dist/types/data-app-sdk/query-request.d.ts +7 -2
  122. package/dist/types/data-app-sdk/selection.d.ts +2 -0
  123. package/dist/types/index.cjs +1 -1
  124. package/dist/types/index.js +24 -23
  125. package/dist/types/lib/appearance/types.d.ts +3 -1
  126. package/dist/types/lib/briefings/briefing-attachment-model.d.ts +0 -2
  127. package/dist/types/lib/contexts/interactions-popover-context.d.ts +1 -8
  128. package/dist/types/lib/dashboard/click-to-filter-card-references.d.ts +23 -0
  129. package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +16 -2
  130. package/dist/types/lib/dashboard-inputs/build-selection-dashboard-inputs.d.ts +31 -0
  131. package/dist/types/lib/dashboard-inputs/click-to-filter-emitted-fields.d.ts +17 -0
  132. package/dist/types/lib/dashboard-inputs/click-to-filter-mapping-draft.d.ts +99 -0
  133. package/dist/types/lib/dashboard-inputs/click-to-filter-sheet-reach.d.ts +12 -0
  134. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +18 -1
  135. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-candidate-metadata.d.ts +4 -1
  136. package/dist/types/lib/dashboard-inputs/dashboard-input-scope.d.ts +10 -0
  137. package/dist/types/lib/dashboard-inputs/dashboard-input-snapshot.d.ts +8 -1
  138. package/dist/types/lib/dashboard-inputs/index.d.ts +1 -0
  139. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +18 -7
  140. package/dist/types/lib/dashboard-inputs/resolve-field-date-comparison-coverage.d.ts +5 -2
  141. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +77 -0
  142. package/dist/types/lib/dashboard-inputs/selection-targets.d.ts +26 -0
  143. package/dist/types/lib/dashboard-inputs/transient-input-context.d.ts +102 -0
  144. package/dist/types/lib/dashboard-navigation/build-carried-click-context.d.ts +50 -0
  145. package/dist/types/lib/dashboard-navigation/describe-carried-context.d.ts +11 -0
  146. package/dist/types/lib/dashboard-navigation/index.d.ts +1 -0
  147. package/dist/types/lib/dashboard-navigation/navigation-state.d.ts +120 -0
  148. package/dist/types/lib/dashboard-navigation/run-one-off-drill.d.ts +11 -0
  149. package/dist/types/lib/dashboard-navigation/use-transient-contexts.d.ts +17 -0
  150. package/dist/types/lib/dashboard-view-state/card-view-state.d.ts +48 -0
  151. package/dist/types/lib/dashboard-view-state/drill-path.d.ts +20 -0
  152. package/dist/types/lib/dashboard-view-state/index.d.ts +2 -0
  153. package/dist/types/lib/download-pdf.d.ts +0 -3
  154. package/dist/types/lib/formatters/metric-formatting.d.ts +1 -1
  155. package/dist/types/lib/hooks/ai/dashboard-context.d.ts +15 -8
  156. package/dist/types/lib/hooks/chartjs/use-chart-blur.d.ts +10 -2
  157. package/dist/types/lib/hooks/interactions/{use-event-engine.d.ts → use-drill-actions.d.ts} +28 -7
  158. package/dist/types/lib/hooks/selection/use-active-selections.d.ts +15 -0
  159. package/dist/types/lib/hooks/selection/use-click-to-filter-mapping-draft.d.ts +20 -0
  160. package/dist/types/lib/hooks/selection/use-selection-click.d.ts +34 -0
  161. package/dist/types/lib/hooks/selection/use-selection-gestures.d.ts +38 -0
  162. package/dist/types/lib/hooks/selection/use-table-row-selection.d.ts +46 -0
  163. package/dist/types/lib/hooks/use-dashboard-card.d.ts +0 -2
  164. package/dist/types/lib/hooks/use-dashboard-filter-mapping-candidates.d.ts +18 -0
  165. package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +0 -1
  166. package/dist/types/lib/hooks/use-dashboard.d.ts +1 -3
  167. package/dist/types/lib/hooks/use-interactions-popover.d.ts +1 -8
  168. package/dist/types/lib/hooks/use-resolved-card-config.d.ts +6 -0
  169. package/dist/types/lib/interactions/click-outcome.d.ts +25 -0
  170. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +3 -1
  171. package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +1 -1
  172. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +7 -0
  173. package/dist/types/lib/interactions/interaction-utils.d.ts +17 -1
  174. package/dist/types/lib/matrix-table/build-matrix-drill-to-detail.d.ts +15 -0
  175. package/dist/types/lib/matrix-table/matrix-card-interactions.d.ts +14 -3
  176. package/dist/types/lib/matrix-table/matrix-runtime-types.d.ts +0 -3
  177. package/dist/types/lib/matrix-table/matrix-runtime.d.ts +0 -4
  178. package/dist/types/lib/matrix-table/{use-matrix-selection.d.ts → use-matrix-cell-focus.d.ts} +13 -17
  179. package/dist/types/lib/matrix-table/use-matrix.d.ts +0 -1
  180. package/dist/types/lib/query-context/build-card-query-context.d.ts +19 -8
  181. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -3
  182. package/dist/types/lib/query-context/build-dashboard-frame-base-query-contexts.d.ts +12 -4
  183. package/dist/types/lib/query-context/compile-selection-filters.d.ts +5 -0
  184. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +46 -0
  185. package/dist/types/lib/query-context/filter-group-utils.d.ts +3 -0
  186. package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +29 -0
  187. package/dist/types/lib/selection/click-to-filter-authoring-support.d.ts +9 -0
  188. package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
  189. package/dist/types/lib/selection/selection-labels.d.ts +3 -0
  190. package/dist/types/lib/selection/selection-notices.d.ts +9 -0
  191. package/dist/types/lib/selection/selection-reducer.d.ts +46 -0
  192. package/dist/types/lib/stores/dashboard-store.d.ts +62 -17
  193. package/dist/types/lib/stores/editor-store.d.ts +1 -2
  194. package/dist/types/lib/stores/index.d.ts +0 -2
  195. package/dist/types/lib/types/common-types.d.ts +60 -6
  196. package/dist/types/lib/types/explorer-types.d.ts +1 -22
  197. package/dist/types/lib/types/interaction-types.d.ts +6 -198
  198. package/dist/types/lib/utils/calculate-context-aware-filters.d.ts +21 -12
  199. package/dist/types/lib/utils/card-utils.d.ts +11 -0
  200. package/dist/types/lib/utils/date-hierarchy-utils.d.ts +3 -1
  201. package/dist/types/lib/utils/drag-and-drop-utils.d.ts +1 -1
  202. package/dist/types/lib/utils/interaction-icons.d.ts +1 -1
  203. package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +32 -32
  204. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  205. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +100 -0
  206. package/dist/types/shared/analytics-protocol/selection-filter-compiler.d.ts +12 -0
  207. package/dist/types/shared/dashboard-authoring/apply-group-by-override.d.ts +19 -0
  208. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +88 -0
  209. package/dist/types/shared/dashboard-authoring/contracts.d.ts +8 -0
  210. package/dist/types/shared/dashboard-authoring/index.d.ts +3 -0
  211. package/dist/types/shared/dashboard-authoring/linked-click-to-filter-overrides.d.ts +32 -0
  212. package/dist/types/shared/format-utils/matrix-continuation.d.ts +3 -3
  213. package/package.json +1 -1
  214. package/src/data-app-sdk/README.md +58 -1
  215. package/dist/chunks/appearance-context-tNjvTJj3.cjs +0 -1
  216. package/dist/chunks/calculated-field-identity-BTpUqfEu.js +0 -1276
  217. package/dist/chunks/calculated-field-identity-rMuXuzEY.cjs +0 -1
  218. package/dist/chunks/constants-vtu7_IUo.cjs +0 -1
  219. package/dist/chunks/dashboard-controls-DlxeddZN.cjs +0 -52
  220. package/dist/chunks/dashboard-json-DhS4yJfc.cjs +0 -1
  221. package/dist/chunks/edit-dashboard-visual-X3OCnivL.cjs +0 -172
  222. package/dist/chunks/field-aggregations-BU_3gHKR.js +0 -957
  223. package/dist/chunks/field-aggregations-CDCamEsQ.cjs +0 -1
  224. package/dist/chunks/index-C8XCKzB6.cjs +0 -1
  225. package/dist/chunks/index-DSa6RSdg.cjs +0 -1417
  226. package/dist/chunks/matrix-control-sources-CeC5EMyq.cjs +0 -1
  227. package/dist/chunks/matrix-member-presentation-E2B4k3ws.cjs +0 -1
  228. package/dist/chunks/matrix-member-presentation-qiHxv67e.js +0 -105
  229. package/dist/chunks/matrix-operation-contract-Cqy4EW2H.js +0 -1638
  230. package/dist/chunks/matrix-operation-contract-D9dLX-Wr.cjs +0 -1
  231. package/dist/chunks/report-preferences-dialog-7Vsc_fsG.cjs +0 -1
  232. package/dist/chunks/search-BqqhaMx9.cjs +0 -26
  233. package/dist/chunks/switch-BytP6QY8.cjs +0 -139
  234. package/dist/types/components/interactions/configuration-popover.d.ts +0 -1
  235. package/dist/types/components/interactions/interaction-card.d.ts +0 -59
  236. package/dist/types/components/interactions/interaction-event-handler.d.ts +0 -11
  237. package/dist/types/components/interactions/interactions-list.d.ts +0 -50
  238. package/dist/types/components/interactions/panels/cross-filter-panel.d.ts +0 -24
  239. package/dist/types/components/interactions/panels/inline-drill-panel.d.ts +0 -24
  240. package/dist/types/components/interactions/selectors/action-selector.d.ts +0 -31
  241. package/dist/types/components/interactions/selectors/trigger-selector.d.ts +0 -38
  242. package/dist/types/components/surfboard/filter/click-filter-section.d.ts +0 -5
  243. package/dist/types/lib/interactions/build-interaction-event.d.ts +0 -25
  244. package/dist/types/lib/interactions/convert-click-filters-to-filter-group.d.ts +0 -10
  245. package/dist/types/lib/interactions/execute-interaction-event.d.ts +0 -80
  246. package/dist/types/lib/interactions/field-utils.d.ts +0 -11
  247. package/dist/types/lib/interactions/handle-chart-click.d.ts +0 -75
  248. package/dist/types/lib/interactions/linked-interaction-utils.d.ts +0 -14
  249. package/dist/types/lib/interactions/source-card-filter-utils.d.ts +0 -9
  250. package/dist/types/lib/matrix-table/matrix-clipboard.d.ts +0 -45
  251. package/dist/types/lib/matrix-table/matrix-selection.d.ts +0 -20
  252. package/dist/types/lib/stores/drill-actions.d.ts +0 -139
  253. package/dist/types/lib/stores/interaction-store.d.ts +0 -113
  254. package/dist/types/lib/stores/pointer-interaction-store.d.ts +0 -18
@@ -1,1276 +0,0 @@
1
- var re = Object.defineProperty;
2
- var oe = (e, t, n) => t in e ? re(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
3
- var j = (e, t, n) => oe(e, typeof t != "symbol" ? t + "" : t, n);
4
- import { ah as w, ak as R, a_ as S, aa as se, A as P, am as ae, x as de, U as ce, r as L, t as z, bc as le, C as q } from "./validators-BDYzZFgs.js";
5
- import "./matrix-operation-contract-Cqy4EW2H.js";
6
- import { l as ue, f as fe, h as pe } from "./field-aggregations-BU_3gHKR.js";
7
- import { g as H } from "./matrix-analytical-definition-xesmc3Qa.js";
8
- import { s as T } from "./stable-serialize-CfqXeiBP.js";
9
- const me = (e, t) => {
10
- const n = {};
11
- if (e === null || t === null)
12
- return t;
13
- const i = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(t)]);
14
- for (const r of i) {
15
- if (!(r in e) && r in t) {
16
- n[r] = t[r];
17
- continue;
18
- }
19
- if (r in e && !(r in t)) {
20
- n[r] = void 0;
21
- continue;
22
- }
23
- const o = e[r], d = t[r];
24
- if (!E(o, d))
25
- if (Array.isArray(o) && Array.isArray(d))
26
- n[r] = d;
27
- else if (W(o) && W(d)) {
28
- const s = me(o, d);
29
- Object.keys(s).length > 0 && (n[r] = s);
30
- } else
31
- n[r] = d;
32
- }
33
- return n;
34
- }, E = (e, t) => {
35
- if (e === t) return !0;
36
- if (e && t && typeof e == "object" && typeof t == "object") {
37
- if (Array.isArray(e) && Array.isArray(t))
38
- return e.length !== t.length ? !1 : e.every((r, o) => E(r, t[o]));
39
- const n = Object.keys(e), i = Object.keys(t);
40
- return n.length !== i.length ? !1 : n.every((r) => E(e[r], t[r]));
41
- }
42
- return !1;
43
- }, W = (e) => e !== null && typeof e == "object" && !Array.isArray(e), O = (e) => {
44
- if (e === null || typeof e != "object")
45
- return e;
46
- if (e instanceof Date)
47
- return new Date(e);
48
- if (e instanceof RegExp)
49
- return new RegExp(e);
50
- if (Array.isArray(e))
51
- return e.map((n) => O(n));
52
- const t = {};
53
- for (const n in e)
54
- Object.prototype.hasOwnProperty.call(e, n) && (t[n] = O(e[n]));
55
- return t;
56
- }, U = /\[\[\s*param\.([A-Za-z0-9_.-]+)\s*\]\]/g, G = /\bparam\s*\(\s*(['"])([^'"]+)\1/g;
57
- function he(e) {
58
- const t = [];
59
- let n = 0;
60
- for (; n < e.length; ) {
61
- const i = e.indexOf("{{", n), r = e.indexOf("{%", n);
62
- let o = -1, d = "";
63
- if (i === -1 ? (o = r, d = "%}") : r === -1 || i < r ? (o = i, d = "}}") : (o = r, d = "%}"), o === -1)
64
- break;
65
- const s = e.indexOf(d, o + 2);
66
- if (s === -1) {
67
- n = o + 2;
68
- continue;
69
- }
70
- t.push(e.slice(o + 2, s)), n = s + 2;
71
- }
72
- return t;
73
- }
74
- function ee(e) {
75
- var i, r;
76
- if (!e)
77
- return [];
78
- const t = /* @__PURE__ */ new Set();
79
- let n;
80
- for (U.lastIndex = 0; (n = U.exec(e)) !== null; ) {
81
- const o = (i = n[1]) == null ? void 0 : i.trim();
82
- o && t.add(o);
83
- }
84
- for (const o of he(e))
85
- for (G.lastIndex = 0; (n = G.exec(o)) !== null; ) {
86
- const d = (r = n[2]) == null ? void 0 : r.trim();
87
- d && t.add(d);
88
- }
89
- return Array.from(t);
90
- }
91
- function et(e) {
92
- const t = /* @__PURE__ */ new Set(), n = /* @__PURE__ */ new Map();
93
- for (const i of e.controlBindings || [])
94
- t.add(i.controlId), i.target === "sql_param" && n.set(i.paramId, i.controlId);
95
- for (const i of ee(e.sql))
96
- t.add(n.get(i) ?? i);
97
- return Array.from(t);
98
- }
99
- function ge(e) {
100
- const t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
101
- for (const i of e.controlBindings || [])
102
- i.target === "sql_param" && n.set(i.paramId, i.controlId);
103
- for (const i of ee(e.sql))
104
- t.set(i, {
105
- paramId: i,
106
- controlId: n.get(i) ?? i
107
- });
108
- return Array.from(t.values());
109
- }
110
- function be(e, t) {
111
- var r;
112
- const n = (r = e.controlBindings) == null ? void 0 : r.map((o) => ({
113
- ...o,
114
- controlId: t.get(o.controlId) ?? o.controlId
115
- })), i = ge(e).flatMap(
116
- ({ paramId: o, controlId: d }) => {
117
- var c;
118
- const s = t.get(d);
119
- return !s || s === d || (c = e.controlBindings) != null && c.some(
120
- (a) => a.target === "sql_param" && a.paramId === o
121
- ) ? [] : [{ target: "sql_param", paramId: o, controlId: s }];
122
- }
123
- );
124
- return i.length ? [...n ?? [], ...i] : n;
125
- }
126
- function te(e, t) {
127
- var r, o;
128
- const n = e.source === "dashboardInputAlias" ? ((r = t.inputAliases) == null ? void 0 : r[e.variableName]) ?? e : e, i = e.source === "dashboardInputAlias" && n !== e ? { ...n, export: e.export ?? "label" } : n;
129
- return i.source === "dashboardInput" ? {
130
- ...i,
131
- inputId: ((o = t.inputIds) == null ? void 0 : o[i.inputId]) ?? i.inputId
132
- } : i;
133
- }
134
- function tt(e, t) {
135
- var r;
136
- const n = {};
137
- for (const o of [
138
- "cardIds",
139
- "sheetIds",
140
- "inputIds",
141
- "controlIds",
142
- "filterIds"
143
- ]) {
144
- const d = { ...t[o] };
145
- for (const [s, c] of Object.entries((e == null ? void 0 : e[o]) ?? {}))
146
- d[s] = ((r = t[o]) == null ? void 0 : r[c]) ?? c;
147
- Object.keys(d).length && (n[o] = d);
148
- }
149
- const i = { ...t.inputAliases };
150
- for (const [o, d] of Object.entries((e == null ? void 0 : e.inputAliases) ?? {}))
151
- i[o] = te(d, t);
152
- return Object.keys(i).length && (n.inputAliases = i), n;
153
- }
154
- function nt(e, t) {
155
- var r, o, d, s;
156
- const n = O(e);
157
- n.controlBindings = be(
158
- e,
159
- new Map(Object.entries(t.controlIds ?? {}))
160
- );
161
- for (const c of n.controls ?? [])
162
- c.id = ((r = t.controlIds) == null ? void 0 : r[c.id]) ?? c.id;
163
- for (const c of n.inlineFilters ?? [])
164
- c.id = ((o = t.filterIds) == null ? void 0 : o[c.id]) ?? c.id;
165
- const i = (c) => {
166
- var p, f, u;
167
- if (!c || typeof c != "object") return;
168
- if (Array.isArray(c)) {
169
- c.forEach(i);
170
- return;
171
- }
172
- const a = c;
173
- if (a.type === "variable" && a.ref && typeof a.ref == "object") {
174
- const m = a.ref;
175
- a.ref = m.source === "input" ? { ...m, inputId: ((p = t.inputIds) == null ? void 0 : p[m.inputId]) ?? m.inputId } : te(m, t);
176
- }
177
- if (typeof a.entityId == "string") {
178
- const m = a.entityId;
179
- a.fieldScope === "card" && (a.entityId = ((f = t.cardIds) == null ? void 0 : f[m]) ?? m), a.fieldScope === "sheet" && (a.entityId = ((u = t.sheetIds) == null ? void 0 : u[m]) ?? m);
180
- }
181
- for (const [m, _] of Object.entries(a))
182
- m !== "linkedReferenceOverrides" && i(_);
183
- };
184
- i(n);
185
- for (const c of Object.values(
186
- ((d = n.customCardPreferences) == null ? void 0 : d.dataInputCardIds) ?? {}
187
- ))
188
- c.cardId = ((s = t.cardIds) == null ? void 0 : s[c.cardId]) ?? c.cardId;
189
- return n;
190
- }
191
- function N(e) {
192
- return (e == null ? void 0 : e.trim()) || void 0;
193
- }
194
- function K(e) {
195
- return e.split(".").at(-1) || e;
196
- }
197
- function Y(e, t) {
198
- var c, a;
199
- const n = N(t);
200
- if (!n) return;
201
- const i = K(n), r = N((c = e.fieldMeta) == null ? void 0 : c.name);
202
- if (r && r !== n && r !== i)
203
- return;
204
- const o = N(
205
- (a = e.fieldMeta) == null ? void 0 : a.qualifiedFieldName
206
- );
207
- if (o && K(o) !== i)
208
- return;
209
- const d = n.includes(".") ? n : void 0, s = o != null && o.includes(".") ? o : void 0;
210
- if (!(d && s && d !== s))
211
- return {
212
- leafName: i,
213
- ...d || s ? {
214
- qualifiedFieldName: d || s
215
- } : {}
216
- };
217
- }
218
- function J(e, t) {
219
- return Y(e, t) || Y({}, t);
220
- }
221
- function V({
222
- source: e,
223
- sourceFieldName: t,
224
- target: n,
225
- targetFieldName: i
226
- }) {
227
- const r = J(
228
- e,
229
- t
230
- ), o = J(
231
- n,
232
- i
233
- );
234
- return !r || !o || r.leafName !== o.leafName ? !1 : o.qualifiedFieldName ? r.qualifiedFieldName === o.qualifiedFieldName : !0;
235
- }
236
- function x(e, t) {
237
- var r, o;
238
- const n = ye(e);
239
- if (n) return n;
240
- const i = (o = (r = e == null ? void 0 : e.fieldMeta) == null ? void 0 : r.nativeDataType) == null ? void 0 : o.trim();
241
- if (M(e == null ? void 0 : e.fieldMeta, t) && i && i !== "date" && i !== "datetime")
242
- return i;
243
- }
244
- function ye(e) {
245
- var n;
246
- const t = (n = e == null ? void 0 : e.nativeDataType) == null ? void 0 : n.trim();
247
- return t && t !== "date" && t !== "datetime" ? t : void 0;
248
- }
249
- function M(e, t) {
250
- var d, s;
251
- const n = t.trim();
252
- if (!n) return !1;
253
- const i = n.split(".").at(-1), r = (d = e == null ? void 0 : e.qualifiedFieldName) == null ? void 0 : d.trim();
254
- if (r && !(r === n || !r.includes(".") && r === i))
255
- return !1;
256
- const o = (s = e == null ? void 0 : e.name) == null ? void 0 : s.trim();
257
- return o && o !== n && o !== i ? !1 : !!(r || o);
258
- }
259
- function Ie({
260
- fieldName: e,
261
- definition: t,
262
- value: n
263
- }) {
264
- if ((t == null ? void 0 : t.column) === e) {
265
- const i = x(t, e);
266
- if (i)
267
- return i;
268
- }
269
- return (n == null ? void 0 : n.name) === e ? x(n, e) : void 0;
270
- }
271
- function ve({
272
- definition: e,
273
- value: t,
274
- sourceValue: n = t
275
- }) {
276
- const i = e && V({
277
- source: e,
278
- sourceFieldName: e.column,
279
- target: t,
280
- targetFieldName: t.name
281
- }) ? e : void 0, r = n && V({
282
- source: n,
283
- sourceFieldName: n.name,
284
- target: t,
285
- targetFieldName: t.name
286
- }) ? n : void 0, o = (i ? x(i, i.column) : void 0) || (r ? x(r, r.name) : void 0);
287
- return ne({
288
- carrier: t,
289
- nativeDataType: o,
290
- projectNestedNativeDataType: M(
291
- t.fieldMeta,
292
- t.name
293
- )
294
- });
295
- }
296
- function it({
297
- filterDefinitions: e,
298
- filterValues: t
299
- }) {
300
- if (!(e != null && e.length) || !t.length)
301
- return t;
302
- const n = new Map(
303
- e.map((o) => [o.id, o])
304
- );
305
- let i = !1;
306
- const r = t.map((o) => {
307
- if (typeof o.name != "string" || !o.name.trim())
308
- return o;
309
- const d = n.get(o.filterId);
310
- if (!d)
311
- return o;
312
- const s = ve({
313
- definition: d,
314
- value: o
315
- });
316
- return i || (i = s !== o), s;
317
- });
318
- return i ? r : t;
319
- }
320
- function rt(e) {
321
- const t = Ie({
322
- fieldName: e.column,
323
- definition: e
324
- });
325
- return ne({
326
- carrier: e,
327
- nativeDataType: t,
328
- projectNestedNativeDataType: M(
329
- e.fieldMeta,
330
- e.column
331
- )
332
- });
333
- }
334
- function ne({
335
- carrier: e,
336
- nativeDataType: t,
337
- projectNestedNativeDataType: n
338
- }) {
339
- var a;
340
- const i = (a = e.fieldMeta) == null ? void 0 : a.nativeDataType;
341
- if (t) {
342
- if (e.nativeDataType === t && (!e.fieldMeta || (n ? i === t : !i)))
343
- return e;
344
- const { nativeDataType: p, ...f } = e.fieldMeta || {};
345
- return {
346
- ...e,
347
- nativeDataType: t,
348
- ...e.fieldMeta ? {
349
- fieldMeta: n ? {
350
- ...e.fieldMeta,
351
- nativeDataType: t
352
- } : f
353
- } : {}
354
- };
355
- }
356
- if (e.nativeDataType === void 0 && i === void 0)
357
- return e;
358
- const {
359
- nativeDataType: r,
360
- fieldMeta: o,
361
- ...d
362
- } = e, { nativeDataType: s, ...c } = o || {};
363
- return {
364
- ...d,
365
- ...o ? { fieldMeta: c } : {}
366
- };
367
- }
368
- function X(e) {
369
- const t = /* @__PURE__ */ new Set();
370
- for (const n of [e.name, e.sourceField]) {
371
- if (!n) continue;
372
- const i = w(n);
373
- if (!i) continue;
374
- t.add(i);
375
- const r = i.split("."), o = r[r.length - 1];
376
- o && t.add(o);
377
- }
378
- return t;
379
- }
380
- function ie(e, t) {
381
- const n = R(e), i = R(t);
382
- return n === "unknown" || i === "unknown" ? !1 : (n === "date" || n === "datetime") && (i === "date" || i === "datetime") ? !0 : n === i;
383
- }
384
- function _e(e, t) {
385
- return S(e.field.source, t.field.source) && w(e.field.name) === w(t.field.name) && w(e.field.sourceField || e.field.name) === w(t.field.sourceField || t.field.name);
386
- }
387
- function Fe(e, t) {
388
- if (e.kind !== "field") return !1;
389
- const n = X(t), i = X(e.field);
390
- return ie(t.dataType, e.field.dataType) && [...i].some((r) => n.has(r));
391
- }
392
- function ot(e) {
393
- const t = e.candidates.filter(
394
- (n) => Fe(
395
- n,
396
- e.logicalValueField
397
- )
398
- );
399
- return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
400
- }
401
- function st(e) {
402
- const t = [];
403
- for (const n of e.acceptedTargets)
404
- !ie(
405
- e.logicalValueField.dataType,
406
- n.field.dataType
407
- ) || t.some(
408
- (i) => _e(i, n)
409
- ) || t.push(n);
410
- return t.length === 1 ? { status: "matched", target: t[0] } : t.length > 1 ? { status: "ambiguous" } : { status: "notApplicable" };
411
- }
412
- const ke = /\{\{-?\s*filters\s*\|\s*where\s*-?\}\}/i, De = /\{\{-?\s*filters\s*\|\s*and\s*-?\}\}/i, we = /\bwhere\b/i;
413
- function Te(e) {
414
- return e != null && e.trim() ? ke.test(e) || De.test(e) : !1;
415
- }
416
- function at(e) {
417
- return !(e != null && e.trim()) || Te(e) ? null : we.test(e) ? {
418
- helper: "{{ filters | and }}",
419
- description: "For queries with an existing WHERE clause."
420
- } : {
421
- helper: "{{ filters | where }}",
422
- description: "For queries without a WHERE clause."
423
- };
424
- }
425
- function $e(e) {
426
- return (e.field.sourceField || e.field.name).trim() || void 0;
427
- }
428
- function dt(e) {
429
- if (e.inventory.kind !== "sql" || e.target.kind !== "field")
430
- return { status: "ineligible" };
431
- const t = ue(
432
- e.inventory,
433
- e.target.field.source
434
- ), n = $e(e.target);
435
- if (!t || !n) return { status: "ineligible" };
436
- if (t.executionTable) {
437
- const d = [
438
- t.executionTable.databaseName,
439
- t.executionTable.schemaName,
440
- t.executionTable.tableName,
441
- n
442
- ].filter(Boolean).join(".");
443
- return {
444
- status: "eligible",
445
- source: t.source,
446
- executionIdentifier: d
447
- };
448
- }
449
- if (e.inventory.pinnedCatalogSources.length !== 1)
450
- return { status: "ineligible" };
451
- const i = w(n), r = (e.candidateTargets || []).filter(
452
- (d) => w(
453
- d.field.sourceField || d.field.name
454
- ) === i
455
- ), o = [];
456
- for (const d of r)
457
- o.some(
458
- (s) => S(s, d.field.source)
459
- ) || o.push(d.field.source);
460
- return o.length > 1 ? { status: "ineligible" } : {
461
- status: "eligible",
462
- source: t.source,
463
- executionIdentifier: n
464
- };
465
- }
466
- const Se = Object.freeze({ mode: "all_applicable" });
467
- function xe(e) {
468
- if (e === void 0)
469
- return { ok: !0, dependencies: { ...Se } };
470
- const t = se(e, "dashboard");
471
- if (!t.ok)
472
- return {
473
- ok: !1,
474
- error: "Invalid dashboard option dependency policy.",
475
- issues: t.errors.map((i) => i.message)
476
- };
477
- const n = e;
478
- switch (n.mode) {
479
- case "independent":
480
- return { ok: !0, dependencies: { mode: "independent" } };
481
- case "explicit":
482
- return {
483
- ok: !0,
484
- dependencies: {
485
- mode: "explicit",
486
- includeInputIds: [...n.includeInputIds || []]
487
- }
488
- };
489
- case "all_applicable":
490
- return {
491
- ok: !0,
492
- dependencies: {
493
- mode: "all_applicable",
494
- ...n.excludeInputIds ? { excludeInputIds: [...n.excludeInputIds] } : {}
495
- }
496
- };
497
- default:
498
- return {
499
- ok: !1,
500
- error: "Invalid dashboard option dependency policy.",
501
- issues: ["Dashboard option dependencies must declare a mode."]
502
- };
503
- }
504
- }
505
- function Ae(e) {
506
- if (e === void 0) return { ok: !0, population: void 0 };
507
- const t = { ok: !1, error: "Invalid option population." };
508
- if (!e || typeof e != "object" || Array.isArray(e)) return t;
509
- const n = e;
510
- if (n.kind === "option_source")
511
- return { ok: !0, population: { kind: "option_source" } };
512
- if (n.kind !== "related_population") return t;
513
- const i = n.baseSource;
514
- if (!i || i.kind !== "semantic" || !P(i))
515
- return t;
516
- const r = n.relationshipHint;
517
- return r !== void 0 && (!r || typeof r != "object" || r.relationshipIds !== void 0 && (!Array.isArray(r.relationshipIds) || r.relationshipIds.some(
518
- (o) => typeof o != "string" || !o.trim()
519
- ))) ? t : {
520
- ok: !0,
521
- population: {
522
- kind: "related_population",
523
- baseSource: i,
524
- ...r ? { relationshipHint: r } : {}
525
- }
526
- };
527
- }
528
- function ct(e) {
529
- const { dependencies: t } = e, n = /* @__PURE__ */ new Set([
530
- e.targetInputId,
531
- ...t.excludeInputIds || []
532
- ]);
533
- return t.mode === "independent" ? [] : t.mode === "explicit" ? (t.includeInputIds || []).filter(
534
- (i) => !n.has(i)
535
- ) : e.peerInputIds.filter((i) => !n.has(i));
536
- }
537
- function lt(e, t, n) {
538
- if (t === n) return e;
539
- let i = !1;
540
- const r = (d) => d != null && d.includes(t) ? (i = !0, Array.from(
541
- new Set(d.map((s) => s === t ? n : s))
542
- )) : d, o = e.map((d) => {
543
- const s = d.optionDependencies;
544
- if (!s) return d;
545
- const c = r(s.includeInputIds), a = r(s.excludeInputIds);
546
- return c === s.includeInputIds && a === s.excludeInputIds ? d : {
547
- ...d,
548
- optionDependencies: {
549
- ...s,
550
- ...c ? { includeInputIds: c } : {},
551
- ...a ? { excludeInputIds: a } : {}
552
- }
553
- };
554
- });
555
- return i ? o : e;
556
- }
557
- function ut(e, t) {
558
- const n = Ne(
559
- e.dependencies,
560
- t
561
- );
562
- return n === e.dependencies ? e : { ...e, dependencies: n };
563
- }
564
- function Ne(e, t) {
565
- if (!(t != null && t.length) || e.mode !== "explicit")
566
- return e;
567
- const n = new Set(e.includeInputIds || []), i = Array.from(new Set(t)).filter(
568
- (r) => n.has(r)
569
- );
570
- return i.length ? { ...e, omitInputIds: i } : e;
571
- }
572
- class Re extends Error {
573
- constructor(n) {
574
- super(n.map((i) => i.message).join(" "));
575
- j(this, "issues");
576
- this.name = "DashboardFilterMappingContractError", this.issues = n;
577
- }
578
- }
579
- const Ee = {
580
- string: !0,
581
- number: !0,
582
- boolean: !0,
583
- date: !0,
584
- datetime: !0
585
- };
586
- function v(e) {
587
- return typeof e == "string" && e.trim().length > 0;
588
- }
589
- function h(e) {
590
- return !!e && typeof e == "object" && !Array.isArray(e);
591
- }
592
- function $(e) {
593
- return Array.isArray(e) && e.every((t) => typeof t == "string");
594
- }
595
- function Oe(e) {
596
- if (!h(e)) return !1;
597
- switch (e.kind) {
598
- case "allSheets":
599
- return e.sheetKinds === void 0 || $(e.sheetKinds) && e.sheetKinds.every(
600
- (t) => t === "dashboard" || t === "document"
601
- );
602
- case "sheets":
603
- return $(e.sheetIds);
604
- case "cards":
605
- return $(e.cardIds);
606
- case "documentSections":
607
- return v(e.sheetId) && $(e.sectionIds);
608
- default:
609
- return !1;
610
- }
611
- }
612
- function Pe(e) {
613
- return e === "shared" || e === "perSheet" || e === "perCard" || e === "perDocumentSection";
614
- }
615
- function Me(e) {
616
- return h(e) ? v(e.id) && v(e.column) && v(e.dataType) : !1;
617
- }
618
- function Ce(e, t, n, i) {
619
- var s;
620
- if (!h(t)) {
621
- i.push({
622
- code: "invalid_option_source",
623
- path: n,
624
- message: `${n} must be a semantic or physical option source.`,
625
- inputId: e
626
- });
627
- return;
628
- }
629
- const r = t.source, o = [
630
- ["labelField", t.labelField],
631
- ["valueField", t.valueField],
632
- ["searchField", t.searchField]
633
- ];
634
- if (!h(r) || r.kind !== "semantic" && r.kind !== "physical" || !P(r) || !h(t.labelField) || !h(t.valueField) || t.searchField !== void 0 && !h(t.searchField) || t.disambiguationFields !== void 0 && (!Array.isArray(t.disambiguationFields) || !t.disambiguationFields.every(h))) {
635
- i.push({
636
- code: "invalid_option_source",
637
- path: n,
638
- message: `${n} must contain a valid semantic or physical source and field references.`,
639
- inputId: e
640
- });
641
- return;
642
- }
643
- for (const [c, a] of o)
644
- a !== void 0 && h(a) && (!v(a.name) || a.source !== void 0 && !S(
645
- a.source,
646
- r
647
- )) && i.push({
648
- code: "invalid_option_source",
649
- path: `${n}.${c}`,
650
- message: `${n}.${c} must be a named field belonging to the declared option source.`,
651
- inputId: e
652
- });
653
- for (const [c, a] of ((s = t.disambiguationFields) == null ? void 0 : s.entries()) || [])
654
- (!h(a) || !v(a.name) || a.source !== void 0 && !S(
655
- a.source,
656
- r
657
- )) && i.push({
658
- code: "invalid_option_source",
659
- path: `${n}.disambiguationFields[${c}]`,
660
- message: `${n}.disambiguationFields[${c}] must be a named field belonging to the declared option source.`,
661
- inputId: e
662
- });
663
- const d = t.valueField;
664
- ["string", "number", "boolean", "date", "datetime"].includes(
665
- String(d.dataType)
666
- ) || i.push({
667
- code: "invalid_option_source",
668
- path: `${n}.valueField.dataType`,
669
- message: `${n}.valueField.dataType must be a known option-value datatype.`,
670
- inputId: e
671
- });
672
- }
673
- function Be(e, t, n) {
674
- var i;
675
- if (e.optionDependencies !== void 0) {
676
- const r = xe(e.optionDependencies);
677
- r.ok ? h(e.optionDependencies) && e.optionDependencies.omitInputIds !== void 0 && n.push({
678
- code: "invalid_option_dependencies",
679
- path: `${t}.optionDependencies.omitInputIds`,
680
- message: `${t}.optionDependencies cannot persist a browse override (omitInputIds).`,
681
- inputId: e.id
682
- }) : n.push({
683
- code: "invalid_option_dependencies",
684
- path: `${t}.optionDependencies`,
685
- message: `${t}.optionDependencies ${r.issues.join("; ") || r.error}`,
686
- inputId: e.id
687
- });
688
- }
689
- if (e.optionPopulation !== void 0) {
690
- const r = Ae(e.optionPopulation);
691
- r.ok ? ((i = r.population) == null ? void 0 : i.kind) === "related_population" && !je(e.optionSource) && n.push({
692
- code: "invalid_option_population",
693
- path: `${t}.optionPopulation`,
694
- message: `${t}.optionPopulation related_population requires an authored semantic optionSource.`,
695
- inputId: e.id
696
- }) : n.push({
697
- code: "invalid_option_population",
698
- path: `${t}.optionPopulation`,
699
- message: `${t}.optionPopulation must be option_source or a related_population with a complete semantic baseSource.`,
700
- inputId: e.id
701
- });
702
- }
703
- }
704
- function je(e) {
705
- return h(e) && h(e.source) && e.source.kind === "semantic";
706
- }
707
- function Le(e, t, n, i, r, o) {
708
- var a;
709
- if (v(t.bindingId) || r.push({
710
- code: "invalid_binding_id",
711
- path: `${n}.bindingId`,
712
- message: `${n}.bindingId must be an opaque non-empty id.`,
713
- inputId: e,
714
- cardId: t.cardId
715
- }), ((a = t.target) == null ? void 0 : a.kind) !== "field") {
716
- r.push({
717
- code: "unsupported_target",
718
- path: `${n}.target`,
719
- message: `${n}.target must be one direct field target.`,
720
- inputId: e,
721
- cardId: t.cardId,
722
- bindingId: t.bindingId
723
- });
724
- return;
725
- }
726
- const d = t.target.field;
727
- if (!v(d == null ? void 0 : d.name) || !d.source || d.source.kind !== "semantic" && d.source.kind !== "physical" || !P(d.source)) {
728
- r.push({
729
- code: "invalid_target_field",
730
- path: `${n}.target.field`,
731
- message: `${n}.target.field must have a name and a source-qualified semantic or physical identity.`,
732
- inputId: e,
733
- cardId: t.cardId,
734
- bindingId: t.bindingId
735
- });
736
- return;
737
- }
738
- if (Object.prototype.hasOwnProperty.call(
739
- Ee,
740
- d.dataType
741
- ) || r.push({
742
- code: "unknown_target_data_type",
743
- path: `${n}.target.field.dataType`,
744
- message: `${n}.target.field.dataType must be known.`,
745
- inputId: e,
746
- cardId: t.cardId,
747
- bindingId: t.bindingId
748
- }), d.sourceField !== void 0 && !v(d.sourceField) && r.push({
749
- code: "invalid_target_field",
750
- path: `${n}.target.field.sourceField`,
751
- message: `${n}.target.field.sourceField must be a non-empty catalog-grounded column when provided.`,
752
- inputId: e,
753
- cardId: t.cardId,
754
- bindingId: t.bindingId
755
- }), !o) return;
756
- const s = i.get(t.cardId);
757
- if (!s) {
758
- r.push({
759
- code: "unknown_card",
760
- path: `${n}.cardId`,
761
- message: `${n}.cardId '${t.cardId}' does not exist.`,
762
- inputId: e,
763
- cardId: t.cardId,
764
- bindingId: t.bindingId
765
- });
766
- return;
767
- }
768
- const c = fe(s);
769
- (c.kind === "unconfigured" || !pe(c, d.source)) && r.push({
770
- code: "unavailable_card_source",
771
- path: `${n}.target.field.source`,
772
- message: `${n}.target field source is not declared by card '${s.id}'.`,
773
- inputId: e,
774
- cardId: s.id,
775
- bindingId: t.bindingId
776
- });
777
- }
778
- function ze(e, t, n, i, r, o) {
779
- if (t === void 0) return;
780
- if (!h(t) || t.kind !== "cardMappings" || !Array.isArray(t.cards)) {
781
- r.push({
782
- code: "invalid_application",
783
- path: n,
784
- message: `${n} must be a cardMappings application with a cards array.`,
785
- inputId: e
786
- });
787
- return;
788
- }
789
- const d = /* @__PURE__ */ new Set();
790
- t.cards.forEach((s, c) => {
791
- const a = `${n}.cards[${c}]`;
792
- if (!v(s == null ? void 0 : s.cardId)) {
793
- r.push({
794
- code: "unknown_card",
795
- path: `${a}.cardId`,
796
- message: `${a}.cardId is required.`,
797
- inputId: e
798
- });
799
- return;
800
- }
801
- if (d.has(s.cardId)) {
802
- r.push({
803
- code: "duplicate_card_application",
804
- path: `${a}.cardId`,
805
- message: `${n} contains more than one entry for card '${s.cardId}'.`,
806
- inputId: e,
807
- cardId: s.cardId
808
- });
809
- return;
810
- }
811
- if (d.add(s.cardId), o && !i.has(s.cardId)) {
812
- r.push({
813
- code: "unknown_card",
814
- path: `${a}.cardId`,
815
- message: `${a}.cardId '${s.cardId}' does not exist.`,
816
- inputId: e,
817
- cardId: s.cardId
818
- });
819
- return;
820
- }
821
- s.kind === "bound" ? Le(
822
- e,
823
- s,
824
- a,
825
- i,
826
- r,
827
- o
828
- ) : s.kind !== "excluded" && r.push({
829
- code: "invalid_application",
830
- path: a,
831
- message: `${a}.kind must be 'bound' or 'excluded'.`,
832
- inputId: e,
833
- cardId: s.cardId
834
- });
835
- });
836
- }
837
- function qe({
838
- inputs: e,
839
- dashboardFilters: t,
840
- cards: n = [],
841
- validateCardTargets: i = !1
842
- }) {
843
- const r = [], o = new Map(
844
- (t || []).map((a) => [a.id, a])
845
- ), d = new Map(
846
- i ? n.map((a) => [a.id, a]) : []
847
- ), s = [], c = /* @__PURE__ */ new Map();
848
- return e != null && !Array.isArray(e) ? (r.push({
849
- code: "invalid_input",
850
- path: "dashboard.inputs",
851
- message: "dashboard.inputs must be an array when present."
852
- }), { ok: !1, inputs: s, issues: r }) : ((Array.isArray(e) ? e : []).forEach((a, p) => {
853
- const f = `dashboard.inputs[${p}]`;
854
- if (!h(a) || a.kind !== "filter" && a.kind !== "control" || !v(a.id) || !v(a.label) || !v(a.variableName) || !Oe(a.scope) || !Pe(a.runtimeScope)) {
855
- r.push({
856
- code: "invalid_input",
857
- path: f,
858
- message: `${f} must be a complete filter or control Dashboard Input envelope.`,
859
- inputId: h(a) && typeof a.id == "string" ? a.id : void 0
860
- });
861
- return;
862
- }
863
- if (a.kind === "control" && !h(a.control)) {
864
- r.push({
865
- code: "invalid_input",
866
- path: `${f}.control`,
867
- message: `${f}.control must be a control definition.`,
868
- inputId: a.id
869
- });
870
- return;
871
- }
872
- const u = a;
873
- if (u.kind === "control") {
874
- s.push(u);
875
- return;
876
- }
877
- const m = u.filter, _ = u.filterReference, k = m !== void 0, D = !!_;
878
- if (k && D) {
879
- r.push({
880
- code: "both_filter_definitions",
881
- path: f,
882
- message: `${f} must contain either filter or filterReference, not both.`,
883
- inputId: u.id
884
- });
885
- return;
886
- }
887
- if (!k && !D) {
888
- r.push({
889
- code: "missing_filter_definition",
890
- path: f,
891
- message: `${f} must contain filter or filterReference.`,
892
- inputId: u.id
893
- });
894
- return;
895
- }
896
- if (k && !Me(m)) {
897
- r.push({
898
- code: "invalid_input",
899
- path: `${f}.filter`,
900
- message: `${f}.filter must be a complete dashboard filter definition.`,
901
- inputId: u.id
902
- });
903
- return;
904
- }
905
- let y, l;
906
- if (k)
907
- y = m, l = "embedded";
908
- else {
909
- if ((_ == null ? void 0 : _.kind) !== "dashboardFilter") {
910
- r.push({
911
- code: "invalid_filter_reference",
912
- path: `${f}.filterReference.kind`,
913
- message: `${f}.filterReference.kind must be 'dashboardFilter'.`,
914
- inputId: u.id
915
- });
916
- return;
917
- }
918
- const A = typeof (_ == null ? void 0 : _.filterId) == "string" ? _.filterId : void 0;
919
- if (y = A ? o.get(A) : void 0, l = "dashboardFilter", !y) {
920
- r.push({
921
- code: "orphaned_filter_reference",
922
- path: `${f}.filterReference.filterId`,
923
- message: `${f}.filterReference cannot resolve dashboard filter '${A || ""}'.`,
924
- inputId: u.id
925
- });
926
- return;
927
- }
928
- if (y.kind === "global-date") {
929
- r.push({
930
- code: "global_date_reference",
931
- path: `${f}.filterReference`,
932
- message: `${f}.filterReference cannot reference the Global Date filter.`,
933
- inputId: u.id
934
- });
935
- return;
936
- }
937
- const B = c.get(y.id);
938
- if (B) {
939
- r.push({
940
- code: "duplicate_filter_reference",
941
- path: `${f}.filterReference.filterId`,
942
- message: `${f}.filterReference duplicates dashboard filter '${y.id}' already owned by Dashboard Input '${B}'.`,
943
- inputId: u.id
944
- });
945
- return;
946
- }
947
- c.set(y.id, u.id);
948
- }
949
- if (!y) return;
950
- if (u.forceSelection !== void 0 && typeof u.forceSelection != "boolean" && r.push({
951
- code: "invalid_input",
952
- path: `${f}.forceSelection`,
953
- message: `${f}.forceSelection must be a boolean.`,
954
- inputId: u.id
955
- }), u.optionSource !== void 0 && Ce(
956
- u.id,
957
- u.optionSource,
958
- `${f}.optionSource`,
959
- r
960
- ), Be(u, f, r), u.application && y.kind === "global-date") {
961
- r.push({
962
- code: "global_date_reference",
963
- path: `${f}.application`,
964
- message: `${f}.application cannot map the Global Date filter.`,
965
- inputId: u.id
966
- });
967
- return;
968
- }
969
- u.application && u.scope.kind !== "allSheets" && u.scope.kind !== "sheets" && r.push({
970
- code: "unsupported_mapped_scope",
971
- path: `${f}.scope`,
972
- message: `${f}.scope must be allSheets or sheets when cardMappings are present.`,
973
- inputId: u.id
974
- }), ze(
975
- u.id,
976
- u.application,
977
- `${f}.application`,
978
- d,
979
- r,
980
- i
981
- );
982
- const {
983
- filter: F,
984
- filterReference: b,
985
- // A reference-backed authored input must shadow the generated
986
- // dashboard-filter compatibility input. Older writers may have copied
987
- // the compatibility marker onto the reference; never preserve it.
988
- compatibility: I,
989
- ...g
990
- } = u;
991
- s.push({
992
- ...g,
993
- filter: y,
994
- ...k && I ? { compatibility: I } : {},
995
- ...u.optionSource ? {
996
- optionSource: u.optionSource
997
- } : {},
998
- ...u.optionDependencies ? { optionDependencies: u.optionDependencies } : {},
999
- ...u.optionPopulation ? { optionPopulation: u.optionPopulation } : {},
1000
- definitionOrigin: l
1001
- });
1002
- }), r.length ? { ok: !1, inputs: s, issues: r } : { ok: !0, inputs: s });
1003
- }
1004
- function ft(e) {
1005
- const t = qe(e);
1006
- if (!t.ok) throw new Re(t.issues);
1007
- return t.inputs;
1008
- }
1009
- function pt(e = () => globalThis.crypto.randomUUID()) {
1010
- return e();
1011
- }
1012
- const He = {
1013
- date: /* @__PURE__ */ new Set([
1014
- "between",
1015
- "not between",
1016
- "=",
1017
- "!=",
1018
- ">",
1019
- ">=",
1020
- "<",
1021
- "<=",
1022
- "is null",
1023
- "is not null"
1024
- ]),
1025
- number: /* @__PURE__ */ new Set([
1026
- "between",
1027
- "not between",
1028
- "=",
1029
- "!=",
1030
- ">",
1031
- ">=",
1032
- "<",
1033
- "<=",
1034
- "in",
1035
- "not in",
1036
- "is null",
1037
- "is not null"
1038
- ]),
1039
- string: /* @__PURE__ */ new Set([
1040
- "=",
1041
- "!=",
1042
- "in",
1043
- "not in",
1044
- "like",
1045
- "not like",
1046
- "is null",
1047
- "is not null"
1048
- ]),
1049
- boolean: /* @__PURE__ */ new Set(["=", "!=", "in", "not in", "is null", "is not null"])
1050
- };
1051
- function We(e) {
1052
- const t = R(e);
1053
- return t === "number" || t === "boolean" ? t : t === "date" || t === "datetime" ? "date" : "string";
1054
- }
1055
- function mt(e, t) {
1056
- return typeof t != "string" ? !1 : He[We(e)].has(t);
1057
- }
1058
- function Q(e, t, n = (i) => {
1059
- var r;
1060
- return ((r = i.derivedField) == null ? void 0 : r.dataType) ?? i.dataType;
1061
- }) {
1062
- return t === "sql_param" || t === "presentation_currency" ? [] : t === "config_metric_selector" || t === "config_aggregation" ? e.measures.flatMap((i) => i.kind === "aggregate" ? [{ id: i.id, kind: "measure", measure: i }] : []) : ["rows", "columns"].flatMap((i) => e[i].filter((r) => t !== "config_grain" || ae(n(r.field))).map((r) => ({ id: r.id, kind: "level", axis: i, level: r })));
1063
- }
1064
- function ht(e, t, n, i) {
1065
- const r = [...e.rows, ...e.columns].find((a) => a.id === t);
1066
- if (!r) throw new Error("Matrix level is no longer present.");
1067
- if (i === t) return { kind: "structure", rows: e.rows, columns: e.columns };
1068
- const o = e.rows.filter((a) => a.id !== t), d = e.columns.filter((a) => a.id !== t), s = n === "rows" ? o : d, c = i ? s.findIndex((a) => a.id === i) : -1;
1069
- return s.splice(c < 0 ? s.length : c, 0, r), { kind: "structure", rows: o, columns: d };
1070
- }
1071
- function C(e, t) {
1072
- const n = H(e), i = H(t), r = (s, c) => T(n[s][c]) === T(i[s][c]), o = (s) => {
1073
- const c = n.rankings.find((p) => p.id === s), a = i.rankings.find((p) => p.id === s);
1074
- return !!c && !!a && T(c) === T(a);
1075
- };
1076
- return (s, c, a = !1) => c.length <= t[s].length && c.every(
1077
- (p, f) => {
1078
- var u;
1079
- return (p.member.kind === "value" || a && o(p.member.rankingId)) && p.levelId === ((u = t[s][f]) == null ? void 0 : u.id) && r(s, f);
1080
- }
1081
- );
1082
- }
1083
- function Z(e, t, n, i) {
1084
- if (!n) return n;
1085
- const r = C(e, t), o = new Set(t.measures.map((d) => d.id));
1086
- return { ...n, rules: n.rules.filter((d) => {
1087
- const s = d.target.matrix, c = !s || (s.levelId === void 0 || t[s.axis].some((p) => p.id === s.levelId)) && (s.oppositePath === void 0 || r(s.axis === "rows" ? "columns" : "rows", s.oppositePath, !0)), { validationRefs: a } = le(d);
1088
- return c && a.every((p) => o.has(p)) ? !0 : (i.push({ kind: "conditional_format", id: d.id, message: "Removed a conditional rule whose measure, level or member path changed." }), !1);
1089
- }) };
1090
- }
1091
- function Ue(e, t, n = !1) {
1092
- const i = { ...t }, r = [], o = C(e, i), d = new Set(i.measures.map((c) => c.id)), s = (c, a, p) => r.push({ kind: c, id: a, message: p });
1093
- return i.sorts = i.sorts.filter((c) => {
1094
- const a = i[c.axis].findIndex(
1095
- (f) => f.id === c.levelId
1096
- ), p = a >= 0 && (c.scope.kind === "level" || c.scope.parent.length === a && o(c.axis, c.scope.parent)) && (c.target.kind === "member" || d.has(c.target.measureId) && o(
1097
- c.axis === "rows" ? "columns" : "rows",
1098
- c.target.oppositePath
1099
- ));
1100
- return p || s(
1101
- "sort",
1102
- c.levelId,
1103
- "Removed a sort whose level, measure or member path changed."
1104
- ), p;
1105
- }), i.rankings = i.rankings.filter((c) => {
1106
- const a = i[c.axis].some((p) => p.id === c.levelId) && d.has(c.measureId) && o(
1107
- c.axis === "rows" ? "columns" : "rows",
1108
- c.oppositePath
1109
- );
1110
- return a || s(
1111
- "ranking",
1112
- c.id,
1113
- "Removed a ranking whose level, measure or member path changed."
1114
- ), a;
1115
- }), { spec: (n ? de : ce).parse(i), notices: r };
1116
- }
1117
- function gt(e, t, n = [], i, r = !1) {
1118
- const o = [];
1119
- if (t.kind !== "structure") {
1120
- const l = t.kind === "presentation" ? { ...e, presentation: t.presentation } : t.kind === "defaults" ? { ...e, defaultView: t.defaultView } : t.kind === "sorts" ? { ...e, spec: { ...e.spec, sorts: t.sorts } } : {
1121
- ...e,
1122
- spec: { ...e.spec, rankings: t.rankings }
1123
- };
1124
- return t.kind === "rankings" && l.presentation.conditionalFormatting && (l.presentation = { ...l.presentation, conditionalFormatting: Z(e.spec, l.spec, l.presentation.conditionalFormatting, o) }), {
1125
- config: (r ? L : z).parse(l),
1126
- notices: o,
1127
- removedBindings: [],
1128
- bindings: n
1129
- };
1130
- }
1131
- const d = Ue(e.spec, {
1132
- ...e.spec,
1133
- rows: t.rows ?? e.spec.rows,
1134
- columns: t.columns ?? e.spec.columns,
1135
- measures: t.measures ?? e.spec.measures
1136
- }, r), s = d.spec;
1137
- o.push(...d.notices);
1138
- const c = C(e.spec, s), a = new Set(s.measures.map((l) => l.id)), p = [...s.rows, ...s.columns], f = new Set(p.map((l) => l.id)), u = (l, F, b) => o.push({ kind: l, id: F, message: b }), m = [], _ = n.flatMap((l) => {
1139
- if (l.target === "sql_param" || l.target === "presentation_currency") return [l];
1140
- const F = Q(e.spec, l.target, i), b = l.matrixTargetId ?? (F.length === 1 ? F[0].id : void 0);
1141
- return Q(s, l.target, i).some((g) => g.id === b) ? l.matrixTargetId ? [l] : (u("binding", l.controlId, "Pinned the control binding to its original Matrix target after a structural change."), [{ ...l, matrixTargetId: b }]) : (u(
1142
- "binding",
1143
- l.controlId,
1144
- "Removed a control binding whose original Matrix target is missing, ambiguous or no longer eligible."
1145
- ), m.push(l), []);
1146
- }), k = (l, F, b) => Object.fromEntries(
1147
- Object.entries(l).filter(([I]) => F.has(I) ? !0 : (u(b, I, `Removed a ${b} override for a removed field.`), !1))
1148
- ), D = {
1149
- ...e.presentation,
1150
- levelLabels: k(e.presentation.levelLabels, f, "label"),
1151
- measureLabels: k(
1152
- e.presentation.measureLabels,
1153
- a,
1154
- "label"
1155
- ),
1156
- levelFormats: k(
1157
- e.presentation.levelFormats,
1158
- f,
1159
- "format"
1160
- ),
1161
- measureFormats: k(
1162
- e.presentation.measureFormats,
1163
- a,
1164
- "format"
1165
- ),
1166
- totals: { ...e.presentation.totals }
1167
- };
1168
- D.levelFormats = Object.fromEntries(
1169
- Object.entries(D.levelFormats).filter(([l, F]) => {
1170
- const b = p.find((g) => g.id === l), I = [...e.spec.rows, ...e.spec.columns].find(
1171
- (g) => g.id === l
1172
- );
1173
- return F.type !== "temporal_bucket" || b.grain && b.grain === (I == null ? void 0 : I.grain) ? !0 : (u(
1174
- "format",
1175
- l,
1176
- "Removed a temporal format because its grain changed."
1177
- ), !1);
1178
- })
1179
- ), D.conditionalFormatting && (D.conditionalFormatting = Z(e.spec, s, D.conditionalFormatting, o));
1180
- const y = { ...e.defaultView };
1181
- for (const l of ["rows", "columns"]) {
1182
- const F = {
1183
- ...e.presentation.totals.rows.levels,
1184
- ...e.presentation.totals.columns.levels
1185
- };
1186
- for (const g of Object.keys(e.presentation.totals[l].levels))
1187
- f.has(g) || u("total", g, "Removed subtotal settings for a removed level.");
1188
- D.totals[l] = {
1189
- ...e.presentation.totals[l],
1190
- levels: Object.fromEntries(
1191
- s[l].map((g) => [
1192
- g.id,
1193
- F[g.id] ?? { visible: !0, position: "before" }
1194
- ])
1195
- )
1196
- };
1197
- const b = e.defaultView[l], I = Math.min(b.depth, Math.max(0, s[l].length - 1));
1198
- I !== b.depth && u(
1199
- "depth",
1200
- l,
1201
- `Reduced ${l} expansion depth to fit the hierarchy.`
1202
- ), y[l] = {
1203
- depth: I,
1204
- overrides: b.overrides.filter((g) => g.path.length < s[l].length && c(l, g.path) ? !0 : (u(
1205
- "expansion",
1206
- l,
1207
- `Removed a ${l} expansion override whose path changed or became a leaf.`
1208
- ), !1))
1209
- };
1210
- }
1211
- return {
1212
- config: (r ? L : z).parse({
1213
- ...e,
1214
- spec: s,
1215
- presentation: D,
1216
- defaultView: y
1217
- }),
1218
- notices: o,
1219
- removedBindings: m,
1220
- bindings: _
1221
- };
1222
- }
1223
- function Ge(e) {
1224
- return !e.entityName || e.entityName === q || e.entityName === "calculated_fields" || e.qualifiedEntityName === q || e.qualifiedEntityName === "calculated_fields" ? "root" : e.qualifiedEntityName || e.entityName;
1225
- }
1226
- function Ke(e) {
1227
- return ["domain", e.role || "field", Ge(e), e.name].join("::");
1228
- }
1229
- function bt(e) {
1230
- var r, o;
1231
- if (e.fieldScope !== "domain") return;
1232
- const t = e.calculatedFieldOrigin;
1233
- if ((r = t == null ? void 0 : t.id) != null && r.startsWith("domain::")) return t.id;
1234
- const n = (o = e.derivedField) == null ? void 0 : o.resultRole, i = n === "measure" ? "metric" : n === "dimension" || n === "date" ? "groupby" : e.derivedField || t == null ? void 0 : t.role;
1235
- if (!(i !== "metric" && i !== "groupby"))
1236
- return Ke({ ...e, role: i });
1237
- }
1238
- export {
1239
- ct as A,
1240
- lt as B,
1241
- ut as C,
1242
- Re as D,
1243
- Ne as E,
1244
- me as F,
1245
- ge as G,
1246
- rt as H,
1247
- et as I,
1248
- it as J,
1249
- ee as K,
1250
- ot as a,
1251
- st as b,
1252
- O as c,
1253
- Fe as d,
1254
- at as e,
1255
- dt as f,
1256
- Q as g,
1257
- Te as h,
1258
- ft as i,
1259
- pt as j,
1260
- We as k,
1261
- mt as l,
1262
- ve as m,
1263
- qe as n,
1264
- tt as o,
1265
- nt as p,
1266
- ht as q,
1267
- Ue as r,
1268
- Z as s,
1269
- Ge as t,
1270
- gt as u,
1271
- Ke as v,
1272
- bt as w,
1273
- Se as x,
1274
- xe as y,
1275
- Ae as z
1276
- };