react-semaphor 0.1.507 → 0.1.508

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 (247) 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 +139 -119
  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-B9l0ZAbv.js} +12 -12
  21. package/dist/chunks/{dashboard-briefing-launcher-C8nDSDnV.cjs → dashboard-briefing-launcher-C4zsM3Hd.cjs} +1 -1
  22. package/dist/chunks/{dashboard-controls-CyL0yimg.js → dashboard-controls-BCQv4xWM.js} +16 -14
  23. package/dist/chunks/dashboard-controls-CWwllVOe.cjs +52 -0
  24. package/dist/chunks/{dashboard-json-5Jr3RudV.js → dashboard-json-BtU_q_0A.js} +9 -9
  25. package/dist/chunks/dashboard-json-DVj2xLsH.cjs +1 -0
  26. package/dist/chunks/edit-dashboard-visual-CO2IVBOq.cjs +172 -0
  27. package/dist/chunks/{edit-dashboard-visual-C7X-um9g.js → edit-dashboard-visual-RgFUx-py.js} +1986 -1990
  28. package/dist/chunks/{editor-action-buttons-CcDm8nA5.cjs → editor-action-buttons-BE8Fby6n.cjs} +2 -2
  29. package/dist/chunks/{editor-action-buttons-C5Wja_J4.js → editor-action-buttons-D-MaqTIs.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-BaIrLSBb.cjs +1422 -0
  36. package/dist/chunks/{index-De2QNsqV.js → index-ByiS9sB4.js} +45343 -43665
  37. package/dist/chunks/{index-C9KXfCkC.js → index-CLIro-EG.js} +3 -0
  38. package/dist/chunks/index-Cx3qmRUB.cjs +1 -0
  39. package/dist/chunks/{index-BlYf8gNa.cjs → index-DhlVxvyI.cjs} +1 -1
  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-BbkXcnnn.js} +4 -4
  55. package/dist/chunks/report-preferences-dialog-C9rpWgQZ.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 +13 -1
  115. package/dist/types/components/visual/matrix-table/matrix-selection-click.d.ts +6 -0
  116. package/dist/types/data-app-sdk/adapters.d.ts +3 -2
  117. package/dist/types/data-app-sdk/builders.d.ts +2 -1
  118. package/dist/types/data-app-sdk/contracts.d.ts +44 -2
  119. package/dist/types/data-app-sdk/index.d.ts +1 -0
  120. package/dist/types/data-app-sdk/query-request.d.ts +7 -2
  121. package/dist/types/data-app-sdk/selection.d.ts +2 -0
  122. package/dist/types/index.cjs +1 -1
  123. package/dist/types/index.js +24 -23
  124. package/dist/types/lib/appearance/types.d.ts +3 -1
  125. package/dist/types/lib/briefings/briefing-attachment-model.d.ts +0 -2
  126. package/dist/types/lib/contexts/interactions-popover-context.d.ts +1 -8
  127. package/dist/types/lib/dashboard/click-to-filter-card-references.d.ts +23 -0
  128. package/dist/types/lib/dashboard-inputs/build-normalized-dashboard-inputs.d.ts +16 -2
  129. package/dist/types/lib/dashboard-inputs/build-selection-dashboard-inputs.d.ts +31 -0
  130. package/dist/types/lib/dashboard-inputs/click-to-filter-emitted-fields.d.ts +17 -0
  131. package/dist/types/lib/dashboard-inputs/click-to-filter-mapping-draft.d.ts +99 -0
  132. package/dist/types/lib/dashboard-inputs/click-to-filter-sheet-reach.d.ts +12 -0
  133. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-authoring.d.ts +18 -1
  134. package/dist/types/lib/dashboard-inputs/dashboard-filter-mapping-candidate-metadata.d.ts +4 -1
  135. package/dist/types/lib/dashboard-inputs/dashboard-input-scope.d.ts +10 -0
  136. package/dist/types/lib/dashboard-inputs/dashboard-input-snapshot.d.ts +8 -1
  137. package/dist/types/lib/dashboard-inputs/index.d.ts +1 -0
  138. package/dist/types/lib/dashboard-inputs/resolve-dashboard-input-context.d.ts +18 -7
  139. package/dist/types/lib/dashboard-inputs/resolve-field-date-comparison-coverage.d.ts +5 -2
  140. package/dist/types/lib/dashboard-inputs/resolve-selection-input.d.ts +77 -0
  141. package/dist/types/lib/dashboard-inputs/selection-targets.d.ts +26 -0
  142. package/dist/types/lib/dashboard-inputs/transient-input-context.d.ts +102 -0
  143. package/dist/types/lib/dashboard-navigation/build-carried-click-context.d.ts +50 -0
  144. package/dist/types/lib/dashboard-navigation/describe-carried-context.d.ts +11 -0
  145. package/dist/types/lib/dashboard-navigation/index.d.ts +1 -0
  146. package/dist/types/lib/dashboard-navigation/navigation-state.d.ts +120 -0
  147. package/dist/types/lib/dashboard-navigation/run-one-off-drill.d.ts +11 -0
  148. package/dist/types/lib/dashboard-navigation/use-transient-contexts.d.ts +17 -0
  149. package/dist/types/lib/dashboard-view-state/card-view-state.d.ts +48 -0
  150. package/dist/types/lib/dashboard-view-state/drill-path.d.ts +20 -0
  151. package/dist/types/lib/dashboard-view-state/index.d.ts +2 -0
  152. package/dist/types/lib/download-pdf.d.ts +0 -3
  153. package/dist/types/lib/formatters/metric-formatting.d.ts +1 -1
  154. package/dist/types/lib/hooks/ai/dashboard-context.d.ts +15 -8
  155. package/dist/types/lib/hooks/chartjs/use-chart-blur.d.ts +10 -2
  156. package/dist/types/lib/hooks/interactions/{use-event-engine.d.ts → use-drill-actions.d.ts} +28 -7
  157. package/dist/types/lib/hooks/selection/use-active-selections.d.ts +15 -0
  158. package/dist/types/lib/hooks/selection/use-click-to-filter-mapping-draft.d.ts +20 -0
  159. package/dist/types/lib/hooks/selection/use-selection-click.d.ts +34 -0
  160. package/dist/types/lib/hooks/selection/use-selection-gestures.d.ts +38 -0
  161. package/dist/types/lib/hooks/selection/use-table-row-selection.d.ts +46 -0
  162. package/dist/types/lib/hooks/use-dashboard-card.d.ts +0 -2
  163. package/dist/types/lib/hooks/use-dashboard-filter-mapping-candidates.d.ts +18 -0
  164. package/dist/types/lib/hooks/use-dashboard-frame-query.d.ts +0 -1
  165. package/dist/types/lib/hooks/use-dashboard.d.ts +1 -3
  166. package/dist/types/lib/hooks/use-interactions-popover.d.ts +1 -8
  167. package/dist/types/lib/hooks/use-resolved-card-config.d.ts +6 -0
  168. package/dist/types/lib/interactions/click-outcome.d.ts +25 -0
  169. package/dist/types/lib/interactions/get-click-context-from-chartjs.d.ts +3 -1
  170. package/dist/types/lib/interactions/get-click-context-from-matrix.d.ts +1 -1
  171. package/dist/types/lib/interactions/get-click-context-from-table.d.ts +7 -0
  172. package/dist/types/lib/interactions/interaction-utils.d.ts +17 -1
  173. package/dist/types/lib/matrix-table/build-matrix-drill-to-detail.d.ts +15 -0
  174. package/dist/types/lib/matrix-table/matrix-card-interactions.d.ts +14 -3
  175. package/dist/types/lib/query-context/build-card-query-context.d.ts +19 -8
  176. package/dist/types/lib/query-context/build-dashboard-execution-snapshot.d.ts +5 -3
  177. package/dist/types/lib/query-context/build-dashboard-frame-base-query-contexts.d.ts +12 -4
  178. package/dist/types/lib/query-context/compile-selection-filters.d.ts +5 -0
  179. package/dist/types/lib/query-context/dashboard-filter-mapping-resolution.d.ts +46 -0
  180. package/dist/types/lib/query-context/filter-group-utils.d.ts +3 -0
  181. package/dist/types/lib/query-context/resolve-runtime-card-filters.d.ts +29 -0
  182. package/dist/types/lib/selection/click-to-filter-authoring-support.d.ts +9 -0
  183. package/dist/types/lib/selection/selection-from-click-context.d.ts +41 -0
  184. package/dist/types/lib/selection/selection-labels.d.ts +3 -0
  185. package/dist/types/lib/selection/selection-notices.d.ts +9 -0
  186. package/dist/types/lib/selection/selection-reducer.d.ts +46 -0
  187. package/dist/types/lib/stores/dashboard-store.d.ts +62 -17
  188. package/dist/types/lib/stores/editor-store.d.ts +1 -2
  189. package/dist/types/lib/stores/index.d.ts +0 -2
  190. package/dist/types/lib/types/common-types.d.ts +60 -6
  191. package/dist/types/lib/types/explorer-types.d.ts +1 -22
  192. package/dist/types/lib/types/interaction-types.d.ts +6 -198
  193. package/dist/types/lib/utils/calculate-context-aware-filters.d.ts +21 -12
  194. package/dist/types/lib/utils/card-utils.d.ts +11 -0
  195. package/dist/types/lib/utils/date-hierarchy-utils.d.ts +3 -1
  196. package/dist/types/lib/utils/drag-and-drop-utils.d.ts +1 -1
  197. package/dist/types/lib/utils/interaction-icons.d.ts +1 -1
  198. package/dist/types/shared/analytics-protocol/execution-input-schemas.d.ts +32 -32
  199. package/dist/types/shared/analytics-protocol/index.d.ts +2 -0
  200. package/dist/types/shared/analytics-protocol/selection-contract.d.ts +100 -0
  201. package/dist/types/shared/analytics-protocol/selection-filter-compiler.d.ts +12 -0
  202. package/dist/types/shared/dashboard-authoring/apply-group-by-override.d.ts +19 -0
  203. package/dist/types/shared/dashboard-authoring/click-to-filter-settings.d.ts +88 -0
  204. package/dist/types/shared/dashboard-authoring/contracts.d.ts +8 -0
  205. package/dist/types/shared/dashboard-authoring/index.d.ts +3 -0
  206. package/dist/types/shared/dashboard-authoring/linked-click-to-filter-overrides.d.ts +32 -0
  207. package/dist/types/shared/format-utils/matrix-continuation.d.ts +3 -3
  208. package/package.json +1 -1
  209. package/src/data-app-sdk/README.md +58 -1
  210. package/dist/chunks/appearance-context-tNjvTJj3.cjs +0 -1
  211. package/dist/chunks/calculated-field-identity-BTpUqfEu.js +0 -1276
  212. package/dist/chunks/calculated-field-identity-rMuXuzEY.cjs +0 -1
  213. package/dist/chunks/constants-vtu7_IUo.cjs +0 -1
  214. package/dist/chunks/dashboard-controls-DlxeddZN.cjs +0 -52
  215. package/dist/chunks/dashboard-json-DhS4yJfc.cjs +0 -1
  216. package/dist/chunks/edit-dashboard-visual-X3OCnivL.cjs +0 -172
  217. package/dist/chunks/field-aggregations-BU_3gHKR.js +0 -957
  218. package/dist/chunks/field-aggregations-CDCamEsQ.cjs +0 -1
  219. package/dist/chunks/index-C8XCKzB6.cjs +0 -1
  220. package/dist/chunks/index-DSa6RSdg.cjs +0 -1417
  221. package/dist/chunks/matrix-control-sources-CeC5EMyq.cjs +0 -1
  222. package/dist/chunks/matrix-member-presentation-E2B4k3ws.cjs +0 -1
  223. package/dist/chunks/matrix-member-presentation-qiHxv67e.js +0 -105
  224. package/dist/chunks/matrix-operation-contract-Cqy4EW2H.js +0 -1638
  225. package/dist/chunks/matrix-operation-contract-D9dLX-Wr.cjs +0 -1
  226. package/dist/chunks/report-preferences-dialog-7Vsc_fsG.cjs +0 -1
  227. package/dist/chunks/search-BqqhaMx9.cjs +0 -26
  228. package/dist/chunks/switch-BytP6QY8.cjs +0 -139
  229. package/dist/types/components/interactions/configuration-popover.d.ts +0 -1
  230. package/dist/types/components/interactions/interaction-card.d.ts +0 -59
  231. package/dist/types/components/interactions/interaction-event-handler.d.ts +0 -11
  232. package/dist/types/components/interactions/interactions-list.d.ts +0 -50
  233. package/dist/types/components/interactions/panels/cross-filter-panel.d.ts +0 -24
  234. package/dist/types/components/interactions/panels/inline-drill-panel.d.ts +0 -24
  235. package/dist/types/components/interactions/selectors/action-selector.d.ts +0 -31
  236. package/dist/types/components/interactions/selectors/trigger-selector.d.ts +0 -38
  237. package/dist/types/components/surfboard/filter/click-filter-section.d.ts +0 -5
  238. package/dist/types/lib/interactions/build-interaction-event.d.ts +0 -25
  239. package/dist/types/lib/interactions/convert-click-filters-to-filter-group.d.ts +0 -10
  240. package/dist/types/lib/interactions/execute-interaction-event.d.ts +0 -80
  241. package/dist/types/lib/interactions/field-utils.d.ts +0 -11
  242. package/dist/types/lib/interactions/handle-chart-click.d.ts +0 -75
  243. package/dist/types/lib/interactions/linked-interaction-utils.d.ts +0 -14
  244. package/dist/types/lib/interactions/source-card-filter-utils.d.ts +0 -9
  245. package/dist/types/lib/stores/drill-actions.d.ts +0 -139
  246. package/dist/types/lib/stores/interaction-store.d.ts +0 -113
  247. package/dist/types/lib/stores/pointer-interaction-store.d.ts +0 -18
@@ -0,0 +1,1802 @@
1
+ import { z as r } from "zod";
2
+ import { K as g, E as se, U as B, ba as L, S as v, M as Ce, b2 as te, bb as je, aL as qe, F as Ee, m as Fe, l as xe, b0 as Ke, aQ as Ne, aR as Oe, aU as Be, aV as Te, aE as q, aJ as P, ax as Me, aO as De, aP as ie, av as Pe, at as m, au as Ve, aK as Ue, aB as ze, aC as Le, v as re, aG as Ge, k as Qe, q as ne, ah as He } from "./validators-BDYzZFgs.js";
3
+ const V = {
4
+ answerSummary: "string",
5
+ responseDetail: "responseDetail",
6
+ mode: "string",
7
+ comparisonKind: "string",
8
+ executionResult: "executionResult",
9
+ compiledQuery: "unknown",
10
+ data: "unknown",
11
+ resultSets: "record",
12
+ analysisWarnings: "unknownArray",
13
+ columns: "unknownArray",
14
+ records: "recordArray",
15
+ rowCount: "number",
16
+ rowLimitExceeded: "boolean",
17
+ output: "string",
18
+ querySpec: "unknown",
19
+ metadata: "record",
20
+ validation: "validationResult",
21
+ coverage: "coverage",
22
+ diagnosticFeedback: "diagnosticFeedback",
23
+ missingFields: "stringArray",
24
+ warnings: "unknownArray",
25
+ comparison: "unknown",
26
+ population: "population",
27
+ comparisons: "recordArray",
28
+ fieldsUsed: "compactExecutionFieldArray",
29
+ primary: "recordArray",
30
+ contributors: "recordArray",
31
+ segments: "recordArray",
32
+ periodChanges: "recordArray",
33
+ changes: "recordArray",
34
+ largestNegativeChanges: "recordArray",
35
+ largestPositiveChanges: "recordArray",
36
+ drivers: "recordArray",
37
+ absoluteDeltaDrivers: "recordArray",
38
+ largestNegativeDrivers: "recordArray",
39
+ largestPositiveDrivers: "recordArray",
40
+ periodRows: "recordArray",
41
+ sql: "unknown",
42
+ omitted: "stringArray"
43
+ }, gt = Object.freeze({ coordinates: 2e4 }), w = r.string().uuid(), p = r.string().min(1), We = r.number().int().positive().max(Number.MAX_SAFE_INTEGER);
44
+ function c(t, s, e) {
45
+ t.addIssue({ code: "custom", path: s, message: e });
46
+ }
47
+ function y(t, s, e) {
48
+ new Set(t).size !== t.length && c(s, e, "Duplicate identity.");
49
+ }
50
+ const Ye = r.object({
51
+ id: p,
52
+ axis: se,
53
+ parent: g,
54
+ position: r.union([
55
+ r.object({ kind: r.literal("first") }).strict(),
56
+ r.object({ kind: r.enum(["after", "before"]), cursor: p }).strict()
57
+ ]),
58
+ size: We
59
+ }).strict(), G = r.object({
60
+ paths: r.array(g).readonly(),
61
+ pageIds: r.array(p).readonly()
62
+ }).strict(), Je = r.object({
63
+ id: p,
64
+ rows: G,
65
+ columns: G,
66
+ measureIds: r.array(w).min(1).readonly()
67
+ }).strict(), ae = r.object({
68
+ pages: r.array(Ye).readonly(),
69
+ blocks: r.array(Je).readonly()
70
+ }).strict().superRefine((t, s) => {
71
+ !t.pages.length && !t.blocks.length && c(s, [], "Request at least one page or block."), y(
72
+ [...t.pages, ...t.blocks].map((e) => e.id),
73
+ s,
74
+ []
75
+ );
76
+ for (const e of t.blocks) {
77
+ y(e.measureIds, s, ["blocks", e.id, "measureIds"]);
78
+ for (const i of ["rows", "columns"])
79
+ for (const n of e[i].pageIds)
80
+ t.pages.some(
81
+ (a) => a.id === n && a.axis === i
82
+ ) || c(
83
+ s,
84
+ ["blocks", e.id, i],
85
+ "Page reference must name a page on this axis in this operation."
86
+ );
87
+ }
88
+ }), bt = r.object({ spec: B, request: ae }).strict().superRefine(({ spec: t, request: s }, e) => {
89
+ for (const i of s.pages)
90
+ L(
91
+ t,
92
+ i.axis,
93
+ i.parent,
94
+ e,
95
+ ["pages", i.id],
96
+ !0
97
+ ), i.parent.length >= t[i.axis].length && c(
98
+ e,
99
+ ["pages", i.id],
100
+ "Cannot request children of a leaf or empty axis."
101
+ );
102
+ for (const i of s.blocks) {
103
+ i.measureIds.some((n) => !t.measures.some((a) => a.id === n)) && c(e, ["blocks", i.id], "Unknown block measure.");
104
+ for (const n of ["rows", "columns"])
105
+ for (const a of i[n].paths)
106
+ L(t, n, a, e, ["blocks", i.id, n]);
107
+ }
108
+ }), Ze = r.object({
109
+ requestId: p,
110
+ axis: se,
111
+ parent: g,
112
+ members: r.array(r.object({ path: g }).strict()).readonly(),
113
+ before: p.nullable(),
114
+ after: p.nullable(),
115
+ exactCount: r.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER).optional()
116
+ }).strict().superRefine((t, s) => {
117
+ t.parent.some((i) => i.member.kind === "others") && c(s, ["parent"], "Others has no children.");
118
+ const e = t.members.filter(
119
+ ({ path: i }) => {
120
+ var n;
121
+ return ((n = i[i.length - 1]) == null ? void 0 : n.member.kind) === "others";
122
+ }
123
+ );
124
+ e.length > 1 && c(s, ["members"], "A page may contain Others only once."), e.length && (t.members[t.members.length - 1] !== e[0] && c(s, ["members"], "Others must be the last page member."), t.after !== null && c(s, ["after"], "Others must end the branch.")), new Set(
125
+ t.members.map(
126
+ (i) => {
127
+ var n;
128
+ return (n = i.path[i.path.length - 1]) == null ? void 0 : n.levelId;
129
+ }
130
+ )
131
+ ).size > 1 && c(s, ["members"], "One page must contain one child level."), y(
132
+ t.members.map((i) => v(i.path)),
133
+ s,
134
+ ["members"]
135
+ );
136
+ for (const i of t.members)
137
+ (i.path.length !== t.parent.length + 1 || v(i.path.slice(0, -1)) !== v(t.parent)) && c(s, ["members"], "Page members must be immediate children.");
138
+ }), Xe = r.object({
139
+ requestId: p,
140
+ coverage: r.object({
141
+ rowPaths: r.array(g).readonly(),
142
+ columnPaths: r.array(g).readonly(),
143
+ measureIds: r.array(w).readonly()
144
+ }).strict(),
145
+ cells: r.array(
146
+ Ce.extend({ value: te }).strict()
147
+ ).readonly()
148
+ }).strict().superRefine((t, s) => {
149
+ const e = t.coverage.rowPaths.map(v), i = t.coverage.columnPaths.map(v);
150
+ y(e, s, ["coverage", "rowPaths"]), y(i, s, ["coverage", "columnPaths"]), y(t.coverage.measureIds, s, ["coverage", "measureIds"]);
151
+ const n = new Set(e), a = new Set(i), l = new Set(t.coverage.measureIds);
152
+ y(
153
+ t.cells.map(
154
+ (u) => JSON.stringify([
155
+ v(u.rowPath),
156
+ v(u.columnPath),
157
+ u.measureId
158
+ ])
159
+ ),
160
+ s,
161
+ ["cells"]
162
+ );
163
+ for (const u of t.cells)
164
+ (!n.has(v(u.rowPath)) || !a.has(v(u.columnPath)) || !l.has(u.measureId)) && c(s, ["cells"], "Cell is outside certified coverage.");
165
+ }), Q = r.object({
166
+ id: w,
167
+ column: qe,
168
+ nativeDataType: p,
169
+ semanticFormat: je.optional()
170
+ }).strict(), oe = r.object({
171
+ levels: r.array(Q).readonly(),
172
+ measures: r.array(Q).readonly()
173
+ }).strict(), U = r.object({
174
+ code: r.enum([
175
+ "invalid_request",
176
+ "unsupported_capability",
177
+ "stale_cursor",
178
+ "forbidden",
179
+ "budget_exceeded",
180
+ "source_truncated",
181
+ "execution_failed",
182
+ "cancelled"
183
+ ]),
184
+ message: p,
185
+ /** Technical cause for dashboard owners; never shown as the primary copy. */
186
+ detail: p.optional(),
187
+ retryable: r.boolean(),
188
+ scope: r.union([
189
+ r.object({ kind: r.literal("operation") }).strict(),
190
+ r.object({ kind: r.enum(["page", "block"]), requestId: p }).strict()
191
+ ])
192
+ }).strict(), es = r.object({
193
+ dialect: r.enum(["postgres", "clickhouse", "duckdb"]),
194
+ aggregates: r.array(Ee).readonly()
195
+ }).strict(), ue = r.object({
196
+ queryIdentity: p,
197
+ descriptors: oe,
198
+ capabilities: es,
199
+ pages: r.array(Ze).readonly(),
200
+ blocks: r.array(Xe).readonly(),
201
+ failures: r.array(U).readonly()
202
+ }).strict().superRefine((t, s) => {
203
+ const e = new Set(
204
+ t.descriptors.levels.map((a) => a.id)
205
+ ), i = new Set(
206
+ t.descriptors.measures.map((a) => a.id)
207
+ ), n = t.pages.flatMap((a) => [
208
+ a.parent,
209
+ ...a.members.map((l) => l.path)
210
+ ]);
211
+ for (const a of t.blocks)
212
+ n.push(...a.coverage.rowPaths, ...a.coverage.columnPaths), a.coverage.measureIds.some((l) => !i.has(l)) && c(
213
+ s,
214
+ ["blocks", a.requestId],
215
+ "Coverage references an unknown measure descriptor."
216
+ );
217
+ n.some((a) => a.some((l) => !e.has(l.levelId))) && c(s, ["descriptors"], "Acquired paths require level descriptors."), y(
218
+ [...t.descriptors.levels, ...t.descriptors.measures].map(
219
+ (a) => a.id
220
+ ),
221
+ s,
222
+ ["descriptors"]
223
+ ), y(
224
+ [...t.pages, ...t.blocks].map((a) => a.requestId),
225
+ s,
226
+ []
227
+ ), y(
228
+ t.failures.map(
229
+ (a) => a.scope.kind === "operation" ? "operation" : a.scope.requestId
230
+ ),
231
+ s,
232
+ ["failures"]
233
+ );
234
+ for (const a of t.failures)
235
+ if (a.scope.kind === "operation")
236
+ c(
237
+ s,
238
+ ["failures"],
239
+ "Operation failure cannot accompany acquired data."
240
+ );
241
+ else {
242
+ const l = a.scope.requestId;
243
+ [...t.pages, ...t.blocks].some(
244
+ (u) => u.requestId === l
245
+ ) && c(
246
+ s,
247
+ ["failures"],
248
+ "A requested unit cannot both succeed and fail."
249
+ );
250
+ }
251
+ }), vt = r.union([
252
+ r.object({
253
+ status: r.enum(["success", "partial"]),
254
+ window: ue
255
+ }).strict(),
256
+ r.object({ status: r.literal("failed"), failure: U }).strict()
257
+ ]).superRefine((t, s) => {
258
+ if (t.status === "failed") return;
259
+ const { window: e } = t;
260
+ !e.pages.length && !e.blocks.length && c(
261
+ s,
262
+ ["window"],
263
+ "A window outcome requires successful acquired work."
264
+ ), t.status === "success" != (e.failures.length === 0) && c(s, ["status"], "Status must match failure coverage.");
265
+ }), le = r.object({
266
+ kind: r.literal("matrix"),
267
+ window: ue
268
+ }).strict(), de = r.enum(["member", "subtotal", "grand_total"]), ss = r.discriminatedUnion("kind", [
269
+ r.object({ kind: r.literal("hierarchy"), label: r.string() }).strict(),
270
+ r.object({ kind: r.literal("level"), levelId: w, label: r.string() }).strict(),
271
+ r.object({
272
+ kind: r.literal("measure"),
273
+ measureId: w,
274
+ columnPath: g,
275
+ role: de,
276
+ label: r.string()
277
+ }).strict()
278
+ ]), ts = r.object({
279
+ columns: r.array(ss).readonly(),
280
+ descriptors: oe
281
+ }).strict(), H = r.union([
282
+ r.object({
283
+ kind: r.literal("value"),
284
+ value: te.refine(
285
+ (t) => t !== null
286
+ )
287
+ }).strict(),
288
+ r.object({ kind: r.enum(["null", "empty"]) }).strict()
289
+ ]), is = r.discriminatedUnion("kind", [
290
+ r.object({
291
+ kind: r.literal("layout"),
292
+ rowPath: g,
293
+ role: de,
294
+ values: r.array(H).readonly()
295
+ }).strict(),
296
+ r.object({
297
+ kind: r.literal("flat"),
298
+ rowPath: g,
299
+ columnPath: g,
300
+ values: r.array(H).readonly()
301
+ }).strict()
302
+ ]), St = r.discriminatedUnion("kind", [
303
+ r.object({
304
+ kind: r.literal("layout"),
305
+ layout: ts,
306
+ next: p
307
+ }).strict(),
308
+ r.object({
309
+ kind: r.literal("rows"),
310
+ rows: r.array(is).readonly(),
311
+ next: p.nullable()
312
+ }).strict()
313
+ ]), ce = r.object({
314
+ intent: Fe,
315
+ matrixWindowRequest: ae
316
+ }).strict(), T = "semaphor-data-app-codegen-summary/v1", $t = "semaphor-data-app-codegen-summary-validator/v2", rs = /* @__PURE__ */ new Set([
317
+ "metric",
318
+ "records",
319
+ "matrix",
320
+ "analysis",
321
+ "sql_fallback"
322
+ ]), ns = /* @__PURE__ */ new Set([
323
+ "semaphor.metric",
324
+ "semaphor.records",
325
+ "semaphor.matrix",
326
+ "semaphor.analysis",
327
+ "semaphor.sql"
328
+ ]), as = /* @__PURE__ */ new Set([
329
+ "SUM",
330
+ "COUNT",
331
+ "AVG",
332
+ "MIN",
333
+ "MAX",
334
+ "MEDIAN",
335
+ "DISTINCT"
336
+ ]), os = /* @__PURE__ */ new Set([
337
+ "absolute_delta",
338
+ "largest_negative",
339
+ "largest_positive",
340
+ "positive_and_negative",
341
+ "all"
342
+ ]), pe = /* @__PURE__ */ new Set([
343
+ "source",
344
+ "id",
345
+ "label",
346
+ "measures",
347
+ "primaryMeasure",
348
+ "dateField",
349
+ "timeGrain",
350
+ "dimensions",
351
+ "comparison",
352
+ "orderBy",
353
+ "filters",
354
+ "relationshipHint",
355
+ "limit",
356
+ "derivedFields"
357
+ ]), us = /* @__PURE__ */ new Set([
358
+ ...pe,
359
+ "analysis",
360
+ "timeWindow",
361
+ "filters",
362
+ "driverMode",
363
+ "includePopulation",
364
+ "calendarContext",
365
+ "chartTitle",
366
+ "chartType"
367
+ ]), ls = /* @__PURE__ */ new Set([
368
+ "source",
369
+ "id",
370
+ "label",
371
+ "fields",
372
+ "dateField",
373
+ "timeGrain",
374
+ "timeWindow",
375
+ "filters",
376
+ "orderBy",
377
+ "relationshipHint",
378
+ "limit",
379
+ "pagination",
380
+ "totals",
381
+ "derivedFields"
382
+ ]), ds = /* @__PURE__ */ new Set([
383
+ "source",
384
+ "id",
385
+ "label",
386
+ "sql",
387
+ "defaultParameters",
388
+ "pythonCode",
389
+ "fields",
390
+ "limit",
391
+ "pagination",
392
+ "rationale"
393
+ ]), cs = /* @__PURE__ */ new Set([
394
+ "kpi",
395
+ "line_chart",
396
+ "bar_chart",
397
+ "stacked_bar_chart",
398
+ "pie_chart",
399
+ "donut_chart",
400
+ "area_chart",
401
+ "table",
402
+ "matrix",
403
+ "narrative",
404
+ "text_block",
405
+ "custom"
406
+ ]), ps = /* @__PURE__ */ new Set([
407
+ "missing_measure",
408
+ "missing_dimension",
409
+ "missing_date",
410
+ "missing_relationship",
411
+ "missing_semantic_role",
412
+ "missing_current_app_state",
413
+ "raw_identifier_filter_options",
414
+ "unsupported_change_intent",
415
+ "ambiguous_field_grounding",
416
+ "bounded_intent_unavailable",
417
+ "invalid_bounded_intent_output",
418
+ "latest_snapshot_selector_not_modeled",
419
+ "unsupported_grain",
420
+ "requires_sql_escape_hatch",
421
+ "unsupported_sdk_capability"
422
+ ]);
423
+ function kt(t) {
424
+ return me(t).ok;
425
+ }
426
+ function me(t) {
427
+ const s = [];
428
+ if (!t || typeof t != "object")
429
+ return { ok: !1, issues: ["Summary must be an object."] };
430
+ const e = t;
431
+ return e.schemaVersion !== T && s.push(
432
+ `schemaVersion must be ${T}.`
433
+ ), (typeof e.title != "string" || !e.title.trim()) && s.push("title is required."), Array.isArray(e.sources) || s.push("sources must be an array."), Array.isArray(e.inputs) || s.push("inputs must be an array."), Array.isArray(e.views) || s.push("views must be an array."), Array.isArray(e.filterContracts) || s.push("filterContracts must be an array."), (!e.implementationChecklist || typeof e.implementationChecklist != "object") && s.push("implementationChecklist must be an object."), e.implementationChecklist && typeof e.implementationChecklist == "object" && s.push(
434
+ ...fs(e.implementationChecklist)
435
+ ), Array.isArray(e.sources) && e.sources.forEach((i, n) => {
436
+ s.push(...C(i, `sources.${n}`));
437
+ }), Array.isArray(e.inputs) && e.inputs.forEach((i, n) => {
438
+ s.push(...ys(i, `inputs.${n}`));
439
+ }), Array.isArray(e.views) && e.views.forEach((i, n) => {
440
+ s.push(...hs(i, `views.${n}`));
441
+ }), Array.isArray(e.filterContracts) && e.filterContracts.forEach((i, n) => {
442
+ s.push(
443
+ ..._s(i, `filterContracts.${n}`)
444
+ );
445
+ }), e.unsupportedInsights !== void 0 && (Array.isArray(e.unsupportedInsights) ? e.unsupportedInsights.forEach((i, n) => {
446
+ s.push(
447
+ ...Ps(
448
+ i,
449
+ `unsupportedInsights.${n}`
450
+ )
451
+ );
452
+ }) : s.push("unsupportedInsights must be an array.")), s.push(...ms(e)), { ok: s.length === 0, issues: s };
453
+ }
454
+ function ms(t) {
455
+ const s = Array.isArray(t.unsupportedInsights) && t.unsupportedInsights.some(
456
+ (l) => {
457
+ var u;
458
+ return W.has((u = o(l)) == null ? void 0 : u.reason);
459
+ }
460
+ ), e = Array.isArray(t.views) && t.views.some((l) => {
461
+ var d;
462
+ const u = o((d = o(l)) == null ? void 0 : d.computation);
463
+ return (u == null ? void 0 : u.kind) === "unsupported" && W.has(u.reason);
464
+ });
465
+ if (!s && !e)
466
+ return [];
467
+ const i = [], n = o(t.validation);
468
+ (n == null ? void 0 : n.status) !== "blocked" && i.push(
469
+ "validation.status must be blocked when semantic model repair gaps are present."
470
+ );
471
+ const a = o(t.nextRequiredTool);
472
+ return (a == null ? void 0 : a.name) !== "semaphor_propose_semantic_model_change" && i.push(
473
+ "nextRequiredTool.name must be semaphor_propose_semantic_model_change when semantic model repair gaps are present."
474
+ ), i;
475
+ }
476
+ const W = /* @__PURE__ */ new Set([
477
+ "missing_relationship",
478
+ "raw_identifier_filter_options"
479
+ ]);
480
+ function C(t, s) {
481
+ const e = o(t);
482
+ return e ? e.kind === "semantic" ? typeof e.domainId == "string" && e.domainId.trim() && typeof e.datasetName == "string" && e.datasetName.trim() ? [] : [`${s} must include sourceKey or a supported source identity.`] : typeof e.sourceKey == "string" && e.sourceKey.trim() ? [] : e.kind === "physical" && typeof e.tableName == "string" && e.tableName.trim() && typeof e.connectionId == "string" && e.connectionId.trim() ? [] : e.kind === "sql" && typeof e.connectionId == "string" && e.connectionId.trim() ? [] : [`${s} must include sourceKey or a supported source identity.`] : [`${s} must be an object.`];
483
+ }
484
+ function fs(t) {
485
+ const s = o(t);
486
+ if (!s)
487
+ return ["implementationChecklist must be an object."];
488
+ const e = [], i = [
489
+ "requiredDevtools",
490
+ "requiredInputOptions",
491
+ "filterScopeByInput",
492
+ "bindingsByView",
493
+ "validationCommands",
494
+ "browserSmokeChecks"
495
+ ];
496
+ for (const a of i)
497
+ a in s || e.push(`implementationChecklist.${a} is required.`);
498
+ const n = o(s.requiredDevtools);
499
+ return n ? typeof n.mountRootDevtools != "boolean" && e.push(
500
+ "implementationChecklist.requiredDevtools.mountRootDevtools must be a boolean."
501
+ ) : e.push("implementationChecklist.requiredDevtools must be an object."), Array.isArray(s.requiredInputOptions) || e.push(
502
+ "implementationChecklist.requiredInputOptions must be an array."
503
+ ), Array.isArray(s.filterScopeByInput) || e.push("implementationChecklist.filterScopeByInput must be an array."), o(s.bindingsByView) || e.push("implementationChecklist.bindingsByView must be an object."), h(s.validationCommands) || e.push(
504
+ "implementationChecklist.validationCommands must be an array of strings."
505
+ ), h(s.browserSmokeChecks) || e.push(
506
+ "implementationChecklist.browserSmokeChecks must be an array of strings."
507
+ ), e;
508
+ }
509
+ function ys(t, s) {
510
+ const e = o(t);
511
+ if (!e)
512
+ return [`${s} must be an object.`];
513
+ const i = [];
514
+ return (typeof e.id != "string" || !e.id.trim()) && i.push(`${s}.id is required.`), e.fieldRef && i.push(...f(e.fieldRef, `${s}.fieldRef`)), i.push(...ye(e.optionQuery, `${s}.optionQuery`)), h(e.appliesToViewIds) || i.push(`${s}.appliesToViewIds must be an array of strings.`), e.bindings !== void 0 && !Array.isArray(e.bindings) && i.push(`${s}.bindings must be an array.`), Array.isArray(e.bindings) && e.bindings.forEach((n, a) => {
515
+ const l = o(n);
516
+ if (!l) {
517
+ i.push(`${s}.bindings.${a} must be an object.`);
518
+ return;
519
+ }
520
+ h(l.appliesToViewIds) || i.push(
521
+ `${s}.bindings.${a}.appliesToViewIds must be an array of strings.`
522
+ ), i.push(
523
+ ...f(
524
+ l.fieldRef,
525
+ `${s}.bindings.${a}.fieldRef`
526
+ )
527
+ );
528
+ }), i;
529
+ }
530
+ function hs(t, s) {
531
+ const e = o(t);
532
+ if (!e)
533
+ return [`${s} must be an object.`];
534
+ const i = [];
535
+ if ((typeof e.id != "string" || !e.id.trim()) && i.push(`${s}.id is required.`), e.visualSpec !== void 0 && i.push(...Ks(e.visualSpec, `${s}.visualSpec`)), e.computation !== void 0 && i.push(
536
+ ...Ds(e.computation, `${s}.computation`)
537
+ ), xs(e))
538
+ return i.push(...E(e, `${s}`)), e.fields !== void 0 && (Array.isArray(e.fields) ? e.fields.forEach((d, b) => {
539
+ i.push(
540
+ ...f(d, `${s}.fields.${b}`)
541
+ );
542
+ }) : i.push(`${s}.fields must be an array.`)), e.queryKind !== void 0 && i.push(`${s}.queryKind is not allowed for non-executable views.`), e.sdkBuilder !== void 0 && i.push(
543
+ `${s}.sdkBuilder is not allowed for non-executable views.`
544
+ ), e.sdkSpec !== void 0 && i.push(`${s}.sdkSpec is not allowed for non-executable views.`), i;
545
+ if (!Array.isArray(e.fields))
546
+ return i.push(`${s}.fields must be an array.`), (e.sdkSpec !== void 0 || e.sdkBuilder !== void 0) && i.push(`${s}.fields must be an array for executable views.`), i.push(...E(e, `${s}`)), i;
547
+ e.fields.forEach((d, b) => {
548
+ i.push(...f(d, `${s}.fields.${b}`));
549
+ }), k(e.queryKind) || i.push(`${s}.queryKind must be a supported codegen query kind.`), e.sdkBuilder !== void 0 && !ge(e.sdkBuilder) && i.push(`${s}.sdkBuilder must be a supported SDK builder.`), e.metricBindingKeys !== void 0 && (Array.isArray(e.metricBindingKeys) ? e.metricBindingKeys.some(
550
+ (d) => typeof d != "string" || d.trim().length === 0
551
+ ) && i.push(`${s}.metricBindingKeys must be an array of strings.`) : i.push(`${s}.metricBindingKeys must be an array of strings.`));
552
+ const n = o(e.sdkSpec), a = (n == null ? void 0 : n.builder) === "semaphor.metric";
553
+ a && (!Array.isArray(e.metricBindingKeys) || e.metricBindingKeys.length === 0) && i.push(`${s}.metricBindingKeys is required for metric views.`);
554
+ const l = gs(e);
555
+ a && Array.isArray(e.metricBindingKeys) && l && JSON.stringify(e.metricBindingKeys) !== JSON.stringify(l) && i.push(
556
+ `${s}.metricBindingKeys must match the generated metric field binding keys in order.`
557
+ );
558
+ const u = o(e.computation);
559
+ return (u == null ? void 0 : u.kind) === "server_query" && k(e.queryKind) && k(u.queryKind) && u.queryKind !== e.queryKind && i.push(`${s}.computation.queryKind must match queryKind.`), i.push(
560
+ ...Rs({
561
+ value: e.sdkSpec,
562
+ path: `${s}.sdkSpec`,
563
+ queryKind: typeof e.queryKind == "string" ? e.queryKind : void 0,
564
+ sdkBuilder: typeof e.sdkBuilder == "string" ? e.sdkBuilder : void 0
565
+ }),
566
+ ...E(e, `${s}`)
567
+ ), i;
568
+ }
569
+ function gs(t) {
570
+ const s = o(t.sdkSpec);
571
+ if ((s == null ? void 0 : s.builder) !== "semaphor.metric")
572
+ return;
573
+ const e = o(s.spec);
574
+ if (!e)
575
+ return;
576
+ const n = [
577
+ e.primaryMeasure,
578
+ ...Array.isArray(e.measures) ? e.measures : []
579
+ ].map(bs).filter(
580
+ (a) => !!a
581
+ );
582
+ return Array.from(
583
+ new Map(n.map((a) => [a.identity, a.bindingKey])).values()
584
+ );
585
+ }
586
+ function bs(t) {
587
+ const s = o(t);
588
+ if (!s || typeof s.name != "string" || !s.name.trim())
589
+ return;
590
+ const e = vs(s);
591
+ return e ? {
592
+ identity: JSON.stringify({
593
+ source: e,
594
+ name: s.name,
595
+ aggregate: fe(s)
596
+ }),
597
+ bindingKey: Ss(s)
598
+ } : void 0;
599
+ }
600
+ function vs(t) {
601
+ if (typeof t.sourceKey == "string" && t.sourceKey.trim())
602
+ return { sourceKey: t.sourceKey };
603
+ const s = o(t.source);
604
+ if (s)
605
+ return {
606
+ kind: s.kind,
607
+ domainId: s.domainId,
608
+ datasetId: s.datasetId,
609
+ datasetName: s.datasetName,
610
+ name: s.name
611
+ };
612
+ }
613
+ function Ss(t) {
614
+ return typeof t.sourceKey == "string" && t.sourceKey.trim() ? [t.sourceKey, fe(t), t.name].filter(Boolean).join(":") : Ke(t);
615
+ }
616
+ function fe(t) {
617
+ return xe(t);
618
+ }
619
+ function E(t, s) {
620
+ var b;
621
+ const e = o((b = o(t.visualSpec)) == null ? void 0 : b.tableBehavior), i = o(t.sdkSpec), n = o(i == null ? void 0 : i.spec), a = typeof (i == null ? void 0 : i.builder) == "string" ? i.builder : void 0, l = a === "semaphor.records" ? o(n == null ? void 0 : n.totals) : void 0, u = [];
622
+ if (!e)
623
+ return l && u.push(
624
+ `${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
625
+ ), u;
626
+ const d = o(e.totals);
627
+ return d ? (d.mode === "server" && (a !== "semaphor.records" && u.push(
628
+ `${s}.visualSpec.tableBehavior.totals.mode server is only supported for semaphor.records views.`
629
+ ), !l || l.mode !== "server" ? u.push(
630
+ `${s}.sdkSpec.spec.totals.mode must be server when tableBehavior.totals.mode is server.`
631
+ ) : u.push(
632
+ ...$s({
633
+ left: d.measures,
634
+ right: l.measures,
635
+ leftPath: `${s}.visualSpec.tableBehavior.totals.measures`,
636
+ rightPath: `${s}.sdkSpec.spec.totals.measures`
637
+ })
638
+ )), d.mode !== "server" && l && u.push(
639
+ `${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
640
+ ), a === "semaphor.sql" && d.mode !== "none" && u.push(
641
+ `${s}.visualSpec.tableBehavior.totals.mode must be none for semaphor.sql views.`
642
+ ), a === "semaphor.sql" && o(n == null ? void 0 : n.totals) && u.push(
643
+ `${s}.sdkSpec.spec.totals is not supported for semaphor.sql.`
644
+ ), u) : (l && u.push(
645
+ `${s}.sdkSpec.spec.totals is only allowed when tableBehavior.totals.mode is server.`
646
+ ), u);
647
+ }
648
+ function $s({
649
+ left: t,
650
+ right: s,
651
+ leftPath: e,
652
+ rightPath: i
653
+ }) {
654
+ if (!Array.isArray(t) || !Array.isArray(s))
655
+ return [`${i} must match ${e}.`];
656
+ const n = [];
657
+ return t.length !== s.length ? (n.push(`${i} must match ${e}.`), n) : (t.forEach((a, l) => {
658
+ ks(o(a), o(s[l])) || n.push(`${i}.${l} must match ${e}.${l}.`);
659
+ }), n);
660
+ }
661
+ function ks(t, s) {
662
+ return !t || !s ? !1 : t.name === s.name && (t.role || "measure") === (s.role || "measure") && Y(t) === Y(s) && ws(t, s);
663
+ }
664
+ function Y(t) {
665
+ return typeof t.aggregate == "string" ? t.aggregate.toUpperCase() : "SUM";
666
+ }
667
+ function ws(t, s) {
668
+ const e = o(t.source), i = o(s.source);
669
+ if (Is(e, i))
670
+ return !1;
671
+ const n = J(t), a = J(s);
672
+ if (n.size > 0 || a.size > 0) {
673
+ for (const l of n)
674
+ if (a.has(l))
675
+ return !0;
676
+ return !1;
677
+ }
678
+ return !e || !i || e.kind !== i.kind ? !1 : e.kind === "semantic" ? e.domainId === i.domainId && e.datasetName === i.datasetName && (e.datasetId === void 0 || i.datasetId === void 0 || e.datasetId === i.datasetId) : e.kind === "physical" ? e.connectionId === i.connectionId && e.tableName === i.tableName : e.kind === "sql" ? e.connectionId === i.connectionId : !1;
679
+ }
680
+ function Is(t, s) {
681
+ if (!t || !s || t.kind !== "semantic" || s.kind !== "semantic")
682
+ return !1;
683
+ const e = typeof t.datasetId == "string" ? t.datasetId.trim() : "", i = typeof s.datasetId == "string" ? s.datasetId.trim() : "";
684
+ return !!(e && i && e !== i);
685
+ }
686
+ function J(t) {
687
+ const s = typeof t.sourceKey == "string" ? t.sourceKey.trim() : "";
688
+ return s ? /* @__PURE__ */ new Set([s]) : As(o(t.source));
689
+ }
690
+ function As(t) {
691
+ const s = /* @__PURE__ */ new Set();
692
+ if (!t)
693
+ return s;
694
+ const e = typeof t.sourceKey == "string" ? t.sourceKey.trim() : "";
695
+ if (e && s.add(e), t.kind === "semantic") {
696
+ const i = typeof t.domainId == "string" ? t.domainId : "", n = typeof t.datasetName == "string" ? t.datasetName : "", a = typeof t.datasetId == "string" ? t.datasetId : "";
697
+ i && a && s.add(`semantic:${i}:datasetId:${a}`), i && n && s.add(`semantic:${i}:datasetName:${n}`);
698
+ }
699
+ if (t.kind === "physical") {
700
+ const i = typeof t.connectionId == "string" ? t.connectionId : "", n = typeof t.tableName == "string" ? t.tableName : "", a = typeof t.databaseName == "string" ? t.databaseName : "", l = typeof t.schemaName == "string" ? t.schemaName : "";
701
+ i && n && (s.add(
702
+ ["physical", i, a, l, n].join(
703
+ ":"
704
+ )
705
+ ), s.add(`physical:${i}:${n}`));
706
+ }
707
+ if (t.kind === "sql") {
708
+ const i = typeof t.connectionId == "string" ? t.connectionId : "", n = typeof t.dialect == "string" ? t.dialect : "", a = typeof t.label == "string" ? t.label : "";
709
+ i && (s.add(["sql", i, n, a].join(":")), s.add(`sql:${i}`));
710
+ }
711
+ return s;
712
+ }
713
+ function _s(t, s) {
714
+ const e = o(t);
715
+ if (!e)
716
+ return [`${s} must be an object.`];
717
+ const i = [];
718
+ if (e.fieldRef && i.push(
719
+ ...f(e.fieldRef, `${s}.fieldRef`)
720
+ ), (typeof e.inputId != "string" || !e.inputId.trim()) && i.push(`${s}.inputId is required.`), i.push(
721
+ ...ye(e.optionQuery, `${s}.optionQuery`)
722
+ ), h(e.appliesToViewIds) || i.push(`${s}.appliesToViewIds must be an array of strings.`), h(e.notAppliedToViewIds) || i.push(`${s}.notAppliedToViewIds must be an array of strings.`), !Array.isArray(e.bindings))
723
+ i.push(`${s}.bindings must be an array.`);
724
+ else {
725
+ const n = h(e.appliesToViewIds) ? new Set(e.appliesToViewIds) : void 0, a = h(
726
+ e.notAppliedToViewIds
727
+ ) ? new Set(e.notAppliedToViewIds) : void 0;
728
+ e.bindings.forEach((l, u) => {
729
+ const d = o(l);
730
+ if (!d) {
731
+ i.push(`${s}.bindings.${u} must be an object.`);
732
+ return;
733
+ }
734
+ typeof d.viewId != "string" || !d.viewId ? i.push(`${s}.bindings.${u}.viewId is required.`) : (n && !n.has(d.viewId) && i.push(
735
+ `${s}.bindings.${u}.viewId must be included in appliesToViewIds.`
736
+ ), a != null && a.has(d.viewId) && i.push(
737
+ `${s}.bindings.${u}.viewId must not be listed in notAppliedToViewIds.`
738
+ )), i.push(
739
+ ...f(
740
+ d.fieldRef,
741
+ `${s}.bindings.${u}.fieldRef`
742
+ )
743
+ );
744
+ });
745
+ }
746
+ return i;
747
+ }
748
+ function ye(t, s) {
749
+ if (t === void 0)
750
+ return [];
751
+ const e = o(t);
752
+ if (!e)
753
+ return [`${s} must be an object.`];
754
+ const i = [
755
+ ...S(
756
+ e.valueFieldRef,
757
+ `${s}.valueFieldRef`
758
+ ),
759
+ ...S(
760
+ e.labelFieldRef,
761
+ `${s}.labelFieldRef`
762
+ ),
763
+ ...S(
764
+ e.filterFieldRef,
765
+ `${s}.filterFieldRef`
766
+ )
767
+ ];
768
+ if (e.builder !== "semaphor.inputOptions" && i.push(`${s}.builder must be semaphor.inputOptions.`), typeof e.sourceKey != "string" && e.source === void 0 && i.push(`${s} must include source or sourceKey.`), e.source !== void 0) {
769
+ const n = o(e.source);
770
+ !n || n.kind !== "semantic" && n.kind !== "physical" ? i.push(`${s}.source.kind must be semantic or physical.`) : i.push(...C(e.source, `${s}.source`));
771
+ }
772
+ return o(e.valueFieldRef) || i.push(`${s}.valueFieldRef is required.`), o(e.labelFieldRef) || i.push(`${s}.labelFieldRef is required.`), e.limit !== void 0 && (typeof e.limit != "number" || !Number.isInteger(e.limit) || e.limit <= 0) && i.push(`${s}.limit must be a positive integer.`), i;
773
+ }
774
+ function Rs(t) {
775
+ var n;
776
+ const s = o(t.value);
777
+ if (!s)
778
+ return [`${t.path} is required for executable views.`];
779
+ const e = [];
780
+ if (!ge(s.builder))
781
+ return e.push(`${t.path}.builder must be a supported SDK builder.`), e;
782
+ t.sdkBuilder && s.builder !== t.sdkBuilder && e.push(`${t.path}.builder must match sdkBuilder.`), t.queryKind && k(t.queryKind) && s.builder !== Fs(t.queryKind) && e.push(`${t.path}.builder must match queryKind.`);
783
+ const i = o(s.spec);
784
+ if (!i)
785
+ return e.push(`${t.path}.spec must be an object.`), e;
786
+ switch (s.builder) {
787
+ case "semaphor.metric":
788
+ e.push(
789
+ ...A(
790
+ i,
791
+ pe,
792
+ `${t.path}.spec`
793
+ ),
794
+ ..._(i, t.path),
795
+ ...F(i.measures, `${t.path}.spec.measures`),
796
+ ...S(
797
+ i.primaryMeasure,
798
+ `${t.path}.spec.primaryMeasure`
799
+ ),
800
+ ...S(
801
+ i.dateField,
802
+ `${t.path}.spec.dateField`
803
+ ),
804
+ ...x(
805
+ i.dimensions,
806
+ `${t.path}.spec.dimensions`
807
+ ),
808
+ ...K(i.orderBy, `${t.path}.spec.orderBy`),
809
+ ...N(i.filters, `${t.path}.spec.filters`)
810
+ );
811
+ break;
812
+ case "semaphor.analysis":
813
+ e.push(
814
+ ...A(
815
+ i,
816
+ us,
817
+ `${t.path}.spec`
818
+ ),
819
+ ..._(i, t.path),
820
+ ...F(i.measures, `${t.path}.spec.measures`),
821
+ ...S(
822
+ i.primaryMeasure,
823
+ `${t.path}.spec.primaryMeasure`
824
+ ),
825
+ ...S(
826
+ i.dateField,
827
+ `${t.path}.spec.dateField`
828
+ ),
829
+ ...x(
830
+ i.dimensions,
831
+ `${t.path}.spec.dimensions`
832
+ ),
833
+ ...K(i.orderBy, `${t.path}.spec.orderBy`),
834
+ ...N(i.filters, `${t.path}.spec.filters`),
835
+ ...Cs(i, `${t.path}.spec`)
836
+ );
837
+ break;
838
+ case "semaphor.records":
839
+ e.push(
840
+ ...A(
841
+ i,
842
+ ls,
843
+ `${t.path}.spec`
844
+ ),
845
+ ..._(i, t.path),
846
+ ...F(i.fields, `${t.path}.spec.fields`),
847
+ ...S(
848
+ i.dateField,
849
+ `${t.path}.spec.dateField`
850
+ ),
851
+ ...K(i.orderBy, `${t.path}.spec.orderBy`),
852
+ ...N(i.filters, `${t.path}.spec.filters`),
853
+ ...js(
854
+ i.totals,
855
+ `${t.path}.spec.totals`
856
+ )
857
+ );
858
+ break;
859
+ case "semaphor.matrix": {
860
+ const { id: a, label: l, matrixWindowRequest: u, ...d } = i;
861
+ for (const [I, j] of Object.entries({ id: a, label: l }))
862
+ j !== void 0 && (typeof j != "string" || !j.trim()) && e.push(`${t.path}.spec.${I} must be a nonempty string.`);
863
+ const b = ce.safeParse({
864
+ intent: { ...d, kind: "matrix" },
865
+ matrixWindowRequest: u
866
+ });
867
+ b.success || e.push(...b.error.issues.map((I) => `${t.path}.spec.${I.path.join(".")}: ${I.message}`));
868
+ break;
869
+ }
870
+ case "semaphor.sql":
871
+ e.push(
872
+ ...A(
873
+ i,
874
+ ds,
875
+ `${t.path}.spec`
876
+ ),
877
+ ..._(i, t.path)
878
+ ), ((n = o(i.source)) == null ? void 0 : n.kind) !== "sql" && e.push(`${t.path}.spec.source.kind must be sql.`), (typeof i.sql != "string" || !i.sql.trim()) && e.push(`${t.path}.spec.sql is required.`), e.push(
879
+ ...x(
880
+ i.fields,
881
+ `${t.path}.spec.fields`
882
+ )
883
+ );
884
+ break;
885
+ }
886
+ return e;
887
+ }
888
+ function Cs(t, s) {
889
+ const e = [];
890
+ if (t.driverMode !== void 0 && !os.has(t.driverMode) && e.push(`${s}.driverMode must be a supported analysis driver mode.`), t.includePopulation !== void 0 && typeof t.includePopulation != "boolean" && e.push(`${s}.includePopulation must be a boolean.`), t.calendarContext !== void 0) {
891
+ const i = o(t.calendarContext);
892
+ if (!i)
893
+ e.push(`${s}.calendarContext must be an object.`);
894
+ else {
895
+ i.tz !== void 0 && typeof i.tz != "string" && e.push(`${s}.calendarContext.tz must be a string.`), i.weekStart !== void 0 && (typeof i.weekStart != "number" || !Number.isInteger(i.weekStart) || i.weekStart < 0 || i.weekStart > 6) && e.push(
896
+ `${s}.calendarContext.weekStart must be an integer between 0 and 6.`
897
+ );
898
+ const n = i.anchor;
899
+ if (n !== void 0 && n !== "now") {
900
+ const a = o(n);
901
+ (!a || typeof a.iso != "string" || !a.iso.trim()) && e.push(`${s}.calendarContext.anchor must be now or { iso }.`);
902
+ }
903
+ }
904
+ }
905
+ return e;
906
+ }
907
+ function js(t, s) {
908
+ if (t === void 0)
909
+ return [];
910
+ const e = o(t);
911
+ if (!e)
912
+ return [`${s} must be an object.`];
913
+ const i = [];
914
+ return e.mode !== "server" && i.push(`${s}.mode must be server.`), !Array.isArray(e.measures) || e.measures.length === 0 ? i.push(`${s}.measures must include at least one measure.`) : e.measures.forEach((n, a) => {
915
+ var l;
916
+ i.push(
917
+ ...be(
918
+ n,
919
+ `${s}.measures.${a}`
920
+ )
921
+ ), ((l = o(n)) == null ? void 0 : l.role) !== "measure" && i.push(`${s}.measures.${a}.role must be measure.`);
922
+ }), i;
923
+ }
924
+ function A(t, s, e) {
925
+ const i = [];
926
+ return Object.keys(t).forEach((n) => {
927
+ s.has(n) || i.push(`${e}.${n} is not supported for this SDK builder.`);
928
+ }), i;
929
+ }
930
+ function _(t, s) {
931
+ return o(t.source) ? C(t.source, `${s}.spec.source`) : [`${s}.spec.source must be an object.`];
932
+ }
933
+ function F(t, s) {
934
+ const e = Es(t, s);
935
+ return Array.isArray(t) && t.forEach((i, n) => {
936
+ e.push(...f(i, `${s}.${n}`));
937
+ }), e;
938
+ }
939
+ function x(t, s) {
940
+ if (t === void 0)
941
+ return [];
942
+ if (!Array.isArray(t))
943
+ return [`${s} must be an array.`];
944
+ const e = [];
945
+ return t.forEach((i, n) => {
946
+ e.push(...f(i, `${s}.${n}`));
947
+ }), e;
948
+ }
949
+ function K(t, s) {
950
+ if (t === void 0)
951
+ return [];
952
+ const e = o(t);
953
+ return e ? [
954
+ ...f(e.field, `${s}.field`),
955
+ ...qs(e.direction, `${s}.direction`)
956
+ ] : [`${s} must be an object.`];
957
+ }
958
+ function qs(t, s) {
959
+ return t === "asc" || t === "desc" ? [] : [`${s} must be asc or desc.`];
960
+ }
961
+ function N(t, s) {
962
+ if (t === void 0)
963
+ return [];
964
+ if (!Array.isArray(t))
965
+ return [`${s} must be an array.`];
966
+ const e = [];
967
+ return t.forEach((i, n) => {
968
+ const a = o(i);
969
+ if (!a) {
970
+ e.push(`${s}.${n} must be an object.`);
971
+ return;
972
+ }
973
+ e.push(
974
+ ...f(a.field, `${s}.${n}.field`)
975
+ );
976
+ }), e;
977
+ }
978
+ function Es(t, s) {
979
+ return !Array.isArray(t) || t.length === 0 ? [`${s} must be a non-empty array.`] : [];
980
+ }
981
+ function Fs(t) {
982
+ switch (t) {
983
+ case "metric":
984
+ return "semaphor.metric";
985
+ case "records":
986
+ return "semaphor.records";
987
+ case "matrix":
988
+ return "semaphor.matrix";
989
+ case "analysis":
990
+ return "semaphor.analysis";
991
+ case "sql_fallback":
992
+ return "semaphor.sql";
993
+ }
994
+ }
995
+ function xs(t) {
996
+ const s = o(t.computation), e = o(t.visualSpec);
997
+ return (s == null ? void 0 : s.kind) === "presentation_only" || (s == null ? void 0 : s.kind) === "derived" || (s == null ? void 0 : s.kind) === "unsupported" || t.visual === "text_block" || (e == null ? void 0 : e.visualType) === "text_block";
998
+ }
999
+ function Ks(t, s) {
1000
+ const e = o(t);
1001
+ if (!e)
1002
+ return [`${s} must be an object.`];
1003
+ const i = [];
1004
+ return cs.has(e.visualType) || i.push(`${s}.visualType must be a supported visual type.`), e.limit !== void 0 && (typeof e.limit != "number" || !Number.isInteger(e.limit) || e.limit <= 0) && i.push(`${s}.limit must be a positive integer.`), e.tableBehavior !== void 0 && i.push(
1005
+ ...Ns(
1006
+ e.tableBehavior,
1007
+ `${s}.tableBehavior`
1008
+ )
1009
+ ), i;
1010
+ }
1011
+ function Ns(t, s) {
1012
+ const e = o(t);
1013
+ if (!e)
1014
+ return [`${s} must be an object.`];
1015
+ const i = [];
1016
+ return e.tableMode !== "bounded" && e.tableMode !== "server_paginated" && e.tableMode !== "server_windowed" && i.push(`${s}.tableMode must be a supported table mode.`), i.push(
1017
+ ...Os(e.height, `${s}.height`),
1018
+ ...Bs(e.pagination, `${s}.pagination`),
1019
+ ...Ts(e.sorting, `${s}.sorting`),
1020
+ ...Ms(e.totals, `${s}.totals`)
1021
+ ), typeof e.serverSideRequired != "boolean" && i.push(`${s}.serverSideRequired must be a boolean.`), i;
1022
+ }
1023
+ function Os(t, s) {
1024
+ const e = o(t);
1025
+ if (!e)
1026
+ return [`${s} must be an object.`];
1027
+ const i = [];
1028
+ return (typeof e.maxPx != "number" || !Number.isInteger(e.maxPx) || e.maxPx <= 0) && i.push(`${s}.maxPx must be a positive integer.`), e.scroll !== "vertical" && e.scroll !== "both" && i.push(`${s}.scroll must be vertical or both.`), typeof e.stickyHeader != "boolean" && i.push(`${s}.stickyHeader must be a boolean.`), i;
1029
+ }
1030
+ function Bs(t, s) {
1031
+ const e = o(t);
1032
+ if (!e)
1033
+ return [`${s} must be an object.`];
1034
+ const i = [];
1035
+ return e.mode !== "none" && e.mode !== "server" && e.mode !== "client_for_bounded_rows" && i.push(`${s}.mode must be a supported pagination mode.`), e.pageSize !== void 0 && (typeof e.pageSize != "number" || !Number.isInteger(e.pageSize) || e.pageSize <= 0) && i.push(`${s}.pageSize must be a positive integer.`), e.readsFrom !== void 0 && e.readsFrom !== "result.pagination" && i.push(`${s}.readsFrom must be result.pagination.`), i;
1036
+ }
1037
+ function Ts(t, s) {
1038
+ const e = o(t);
1039
+ if (!e)
1040
+ return [`${s} must be an object.`];
1041
+ const i = [];
1042
+ return e.mode !== "server" && e.mode !== "client_for_bounded_rows" && i.push(`${s}.mode must be a supported sorting mode.`), e.defaultField !== void 0 && (typeof e.defaultField != "string" || !e.defaultField.trim()) && i.push(`${s}.defaultField must be a non-empty string.`), e.defaultDirection !== void 0 && e.defaultDirection !== "asc" && e.defaultDirection !== "desc" && i.push(`${s}.defaultDirection must be asc or desc.`), e.resetPageOnChange !== void 0 && typeof e.resetPageOnChange != "boolean" && i.push(`${s}.resetPageOnChange must be a boolean.`), i;
1043
+ }
1044
+ function Ms(t, s) {
1045
+ const e = o(t);
1046
+ if (!e)
1047
+ return [`${s} must be an object.`];
1048
+ const i = [];
1049
+ return e.mode !== "none" && e.mode !== "server" && e.mode !== "local" ? (i.push(`${s}.mode must be none, server, or local.`), i) : e.mode === "none" ? (e.measures !== void 0 && i.push(`${s}.measures is not allowed when mode is none.`), e.label !== void 0 && i.push(`${s}.label is not allowed when mode is none.`), i) : e.mode === "server" ? (!Array.isArray(e.measures) || e.measures.length === 0 ? i.push(
1050
+ `${s}.measures must include at least one measure when mode is server.`
1051
+ ) : e.measures.forEach((n, a) => {
1052
+ var l;
1053
+ i.push(
1054
+ ...be(
1055
+ n,
1056
+ `${s}.measures.${a}`
1057
+ )
1058
+ ), ((l = o(n)) == null ? void 0 : l.role) !== "measure" && i.push(`${s}.measures.${a}.role must be measure.`);
1059
+ }), e.label !== void 0 && i.push(`${s}.label is not allowed when mode is server.`), i) : (e.mode === "local" && (e.label !== "Displayed rows" && e.label !== "Current page" && i.push(
1060
+ `${s}.label must be Displayed rows or Current page when mode is local.`
1061
+ ), e.measures !== void 0 && i.push(`${s}.measures is not allowed when mode is local.`)), i);
1062
+ }
1063
+ function Ds(t, s) {
1064
+ const e = o(t);
1065
+ if (!e)
1066
+ return [`${s} must be an object.`];
1067
+ const i = [];
1068
+ switch (e.kind) {
1069
+ case "server_query":
1070
+ k(e.queryKind) || i.push(
1071
+ `${s}.queryKind must be a supported codegen query kind.`
1072
+ ), e.queryOwnership !== void 0 && e.queryOwnership !== "view_owned" && e.queryOwnership !== "shared_query" && i.push(
1073
+ `${s}.queryOwnership must be view_owned or shared_query.`
1074
+ ), e.sourceKeys !== void 0 && !h(e.sourceKeys) && i.push(`${s}.sourceKeys must be an array of strings.`), e.fieldNames !== void 0 && !h(e.fieldNames) && i.push(`${s}.fieldNames must be an array of strings.`);
1075
+ break;
1076
+ case "derived":
1077
+ (typeof e.upstreamViewId != "string" || !e.upstreamViewId.trim()) && i.push(`${s}.upstreamViewId is required.`), (typeof e.derivation != "string" || !e.derivation.trim()) && i.push(`${s}.derivation is required.`);
1078
+ break;
1079
+ case "presentation_only":
1080
+ break;
1081
+ case "unsupported":
1082
+ (typeof e.reason != "string" || !e.reason.trim()) && i.push(`${s}.reason is required.`), (typeof e.suggestedModelingFix != "string" || !e.suggestedModelingFix.trim()) && i.push(`${s}.suggestedModelingFix is required.`);
1083
+ break;
1084
+ default:
1085
+ i.push(`${s}.kind must be a supported computation kind.`);
1086
+ }
1087
+ return i;
1088
+ }
1089
+ function Ps(t, s) {
1090
+ const e = o(t);
1091
+ if (!e)
1092
+ return [`${s} must be an object.`];
1093
+ const i = [];
1094
+ for (const a of ["title", "requestedQuestion", "suggestedModelingFix"])
1095
+ (typeof e[a] != "string" || !e[a].trim()) && i.push(`${s}.${a} is required.`);
1096
+ return ps.has(e.reason) || i.push(
1097
+ `${s}.reason must be a supported unsupported insight reason.`
1098
+ ), (e.relationshipCandidate !== void 0 || e.nextRepairAction !== void 0) && e.reason !== "missing_relationship" && i.push(
1099
+ `${s} relationship repair metadata is only valid for missing_relationship unsupported insights.`
1100
+ ), e.diagnostic !== void 0 && i.push(
1101
+ ...Vs(
1102
+ e.diagnostic,
1103
+ `${s}.diagnostic`,
1104
+ e.reason
1105
+ )
1106
+ ), e.relationshipCandidate !== void 0 && i.push(
1107
+ ...zs(
1108
+ e.relationshipCandidate,
1109
+ `${s}.relationshipCandidate`
1110
+ )
1111
+ ), e.nextRepairAction !== void 0 && i.push(
1112
+ ...Us(
1113
+ e.nextRepairAction,
1114
+ `${s}.nextRepairAction`
1115
+ )
1116
+ ), i;
1117
+ }
1118
+ function Vs(t, s, e) {
1119
+ const i = o(t);
1120
+ if (!i)
1121
+ return [`${s} must be an object.`];
1122
+ const n = [], a = /* @__PURE__ */ new Set([
1123
+ "kind",
1124
+ "inputId",
1125
+ "inputLabel",
1126
+ "optionSource",
1127
+ "optionField",
1128
+ "missingEvidence"
1129
+ ]);
1130
+ Object.keys(i).forEach((u) => {
1131
+ a.has(u) || n.push(
1132
+ `${s}.${u} is not supported; raw identifier diagnostics support only kind, inputId, inputLabel, optionSource, optionField, and missingEvidence.`
1133
+ );
1134
+ }), e !== "raw_identifier_filter_options" && n.push(
1135
+ `${s} is only valid for raw_identifier_filter_options unsupported insights.`
1136
+ ), i.kind !== "raw_identifier_filter_options" && n.push(`${s}.kind must be raw_identifier_filter_options.`);
1137
+ for (const u of ["inputId", "inputLabel"])
1138
+ (typeof i[u] != "string" || !i[u].trim()) && n.push(`${s}.${u} must be a non-empty string.`);
1139
+ n.push(
1140
+ ...M(
1141
+ i.optionSource,
1142
+ `${s}.optionSource`
1143
+ )
1144
+ ), n.push(
1145
+ ...he(
1146
+ i.optionField,
1147
+ `${s}.optionField`
1148
+ )
1149
+ );
1150
+ const l = /* @__PURE__ */ new Set([
1151
+ "display_field",
1152
+ "relationship_display_path"
1153
+ ]);
1154
+ return !Array.isArray(i.missingEvidence) || i.missingEvidence.length === 0 ? n.push(`${s}.missingEvidence must be a non-empty evidence array.`) : i.missingEvidence.forEach((u, d) => {
1155
+ l.has(u) || n.push(
1156
+ `${s}.missingEvidence.${d} must be display_field or relationship_display_path.`
1157
+ );
1158
+ }), n;
1159
+ }
1160
+ function Us(t, s) {
1161
+ const e = o(t);
1162
+ if (!e)
1163
+ return [`${s} must be an object.`];
1164
+ const i = [], n = /* @__PURE__ */ new Set(["tool", "reason"]);
1165
+ return Object.keys(e).forEach((a) => {
1166
+ n.has(a) || i.push(
1167
+ `${s}.${a} is not supported; repair actions support only tool and reason.`
1168
+ );
1169
+ }), e.tool !== "semaphor_propose_semantic_model_change" && i.push(`${s}.tool must be semaphor_propose_semantic_model_change.`), e.reason !== "missing_relationship" && i.push(`${s}.reason must be missing_relationship.`), i;
1170
+ }
1171
+ function zs(t, s) {
1172
+ const e = o(t);
1173
+ if (!e)
1174
+ return [`${s} must be an object.`];
1175
+ const i = [], n = /* @__PURE__ */ new Set([
1176
+ "source",
1177
+ "sourceFields",
1178
+ "target",
1179
+ "targetFields"
1180
+ ]);
1181
+ Object.keys(e).forEach((a) => {
1182
+ n.has(a) || i.push(
1183
+ `${s}.${a} is not supported; relationship candidates support only source, sourceFields, target, and targetFields.`
1184
+ );
1185
+ }), i.push(
1186
+ ...M(e.source, `${s}.source`)
1187
+ ), i.push(
1188
+ ...M(e.target, `${s}.target`)
1189
+ );
1190
+ for (const a of ["sourceFields", "targetFields"]) {
1191
+ const l = e[a];
1192
+ if (!Array.isArray(l) || l.length === 0) {
1193
+ i.push(`${s}.${a} must be a non-empty endpoint field array.`);
1194
+ continue;
1195
+ }
1196
+ l.forEach((u, d) => {
1197
+ i.push(
1198
+ ...he(u, `${s}.${a}.${d}`)
1199
+ );
1200
+ });
1201
+ }
1202
+ return i;
1203
+ }
1204
+ function he(t, s) {
1205
+ const e = o(t);
1206
+ if (!e)
1207
+ return [`${s} must be an object.`];
1208
+ const i = [], n = /* @__PURE__ */ new Set(["name", "label", "role", "dataType"]);
1209
+ return Object.keys(e).forEach((a) => {
1210
+ n.has(a) || i.push(
1211
+ `${s}.${a} is not supported; relationship candidate fields are scoped by their endpoint and support only name, label, role, and dataType.`
1212
+ );
1213
+ }), (typeof e.name != "string" || !e.name.trim()) && i.push(`${s}.name must be a non-empty string.`), e.role !== void 0 && (typeof e.role != "string" || !["dimension", "measure", "date", "id", "unknown"].includes(e.role)) && i.push(
1214
+ `${s}.role must be dimension, measure, date, id, or unknown.`
1215
+ ), e.dataType !== void 0 && (typeof e.dataType != "string" || !["string", "number", "boolean", "date", "datetime", "unknown"].includes(
1216
+ e.dataType
1217
+ )) && i.push(
1218
+ `${s}.dataType must be string, number, boolean, date, datetime, or unknown.`
1219
+ ), i;
1220
+ }
1221
+ function M(t, s) {
1222
+ const e = o(t);
1223
+ if (!e)
1224
+ return [`${s} must be an object.`];
1225
+ const i = [], n = /* @__PURE__ */ new Set([
1226
+ "kind",
1227
+ "domainId",
1228
+ "datasetName",
1229
+ "datasetId",
1230
+ "label",
1231
+ "sourceKey"
1232
+ ]);
1233
+ return Object.keys(e).forEach((a) => {
1234
+ n.has(a) || i.push(
1235
+ `${s}.${a} is not supported; relationship candidate sources support only semantic identity fields.`
1236
+ );
1237
+ }), e.kind !== "semantic" && i.push(`${s} must use semantic source identity.`), (typeof e.domainId != "string" || !e.domainId.trim() || typeof e.datasetName != "string" || !e.datasetName.trim()) && i.push(`${s} must include semantic domainId and datasetName.`), i;
1238
+ }
1239
+ function k(t) {
1240
+ return rs.has(t);
1241
+ }
1242
+ function ge(t) {
1243
+ return ns.has(t);
1244
+ }
1245
+ function S(t, s) {
1246
+ return t === void 0 ? [] : f(t, s);
1247
+ }
1248
+ function f(t, s) {
1249
+ const e = o(t);
1250
+ if (!e)
1251
+ return [`${s} must be an object.`];
1252
+ const i = [];
1253
+ return (typeof e.name != "string" || !e.name.trim()) && i.push(`${s}.name is required.`), !e.source && typeof e.sourceKey != "string" && i.push(`${s} must include source or sourceKey.`), e.aggregate !== void 0 && !as.has(e.aggregate) && i.push(`${s}.aggregate must be a supported aggregate function.`), i;
1254
+ }
1255
+ function be(t, s) {
1256
+ const e = o(t), i = f(t, s);
1257
+ if (!e || typeof e.sourceKey == "string" && e.sourceKey.trim())
1258
+ return i;
1259
+ if (e.source !== void 0) {
1260
+ const a = C(
1261
+ e.source,
1262
+ `${s}.source`
1263
+ );
1264
+ return a.length === 0 || i.push(...a), i;
1265
+ }
1266
+ return i.includes(`${s} must include source or sourceKey.`) || i.push(`${s} must include source or sourceKey.`), i;
1267
+ }
1268
+ function o(t) {
1269
+ return t && typeof t == "object" && !Array.isArray(t) ? t : void 0;
1270
+ }
1271
+ function h(t) {
1272
+ return Array.isArray(t) && t.every((s) => typeof s == "string");
1273
+ }
1274
+ const Ls = r.union([
1275
+ Ne,
1276
+ Oe,
1277
+ Be,
1278
+ Te,
1279
+ le
1280
+ ]), Gs = r.object({
1281
+ status: r.enum([
1282
+ "not_required",
1283
+ "resolved",
1284
+ "missing",
1285
+ "ambiguous",
1286
+ "fanout_risk",
1287
+ "unknown"
1288
+ ]),
1289
+ requiredSources: r.array(q).optional(),
1290
+ relationshipsUsed: r.array(r.string()).optional(),
1291
+ missingSources: r.array(r.string()).optional(),
1292
+ warnings: r.array(r.string()).optional(),
1293
+ message: r.string().optional(),
1294
+ recommendedNextStep: r.string().optional(),
1295
+ joinPlanSummary: r.object({
1296
+ baseSource: q.optional(),
1297
+ joinedSources: r.array(q).optional(),
1298
+ joinCount: r.number().optional()
1299
+ }).passthrough().optional(),
1300
+ fanoutRisk: r.object({
1301
+ status: r.enum(["none", "warning", "error", "unknown"]),
1302
+ message: r.string().optional()
1303
+ }).passthrough().optional()
1304
+ }).passthrough(), Z = r.enum([
1305
+ "ambiguous_fields",
1306
+ "empty_result",
1307
+ "missing_grounded_fields",
1308
+ "missing_relationship",
1309
+ "no_grounded_query",
1310
+ "partial_result",
1311
+ "presentation_incomplete",
1312
+ "query_validation_failed",
1313
+ "unsafe_join"
1314
+ ]), ve = r.object({
1315
+ version: r.literal(1),
1316
+ status: r.enum(["answered", "partial", "blocked"]),
1317
+ summary: r.string(),
1318
+ answered: r.array(
1319
+ r.object({
1320
+ slotId: r.string().optional(),
1321
+ queryId: r.string().optional(),
1322
+ summary: r.string(),
1323
+ evidenceIds: r.array(r.string()).optional(),
1324
+ fieldsUsed: r.array(P).optional()
1325
+ }).passthrough()
1326
+ ),
1327
+ blocked: r.array(
1328
+ r.object({
1329
+ slotId: r.string().optional(),
1330
+ queryId: r.string().optional(),
1331
+ reasonCode: Z,
1332
+ message: r.string(),
1333
+ missingFields: r.array(r.string()).optional(),
1334
+ availableFields: r.array(r.string()).optional(),
1335
+ ambiguousFields: r.array(r.string()).optional(),
1336
+ missingRelationships: r.array(r.string()).optional(),
1337
+ evidenceIds: r.array(r.string()).optional(),
1338
+ neededFromUser: r.array(r.string()).optional(),
1339
+ recommendedNextStep: r.string().optional()
1340
+ }).passthrough()
1341
+ ),
1342
+ semanticModelRecommendations: r.array(
1343
+ r.object({
1344
+ reasonCode: Z,
1345
+ message: r.string(),
1346
+ recommendedNextStep: r.string().optional()
1347
+ }).passthrough()
1348
+ ).optional()
1349
+ }).passthrough(), Se = r.object({
1350
+ scope: r.literal("filtered_query"),
1351
+ measures: r.record(Me)
1352
+ }).passthrough(), $e = r.object({
1353
+ answeredObligations: r.array(r.string()),
1354
+ missingObligations: r.array(r.string()),
1355
+ warnings: r.array(De).optional()
1356
+ }).passthrough(), ke = r.object({
1357
+ intentId: r.string().optional(),
1358
+ queryId: r.string().optional(),
1359
+ status: r.enum(["answered", "partial", "failed"]),
1360
+ resultShape: r.enum([
1361
+ "metric",
1362
+ "records",
1363
+ "inputOptions",
1364
+ "sql",
1365
+ "matrix",
1366
+ "period_change",
1367
+ "analysis"
1368
+ ]).optional(),
1369
+ intent: r.unknown().optional(),
1370
+ compiledQuery: r.unknown().optional(),
1371
+ fieldsUsed: r.array(P).optional(),
1372
+ result: Ls.optional(),
1373
+ validation: ie,
1374
+ coverage: $e.optional(),
1375
+ missingFields: r.array(r.string()).optional(),
1376
+ warnings: r.array(r.string()).optional(),
1377
+ relationshipDiagnostics: Gs.optional(),
1378
+ diagnosticFeedback: ve.optional(),
1379
+ population: Se.optional(),
1380
+ metadata: r.record(r.string(), r.unknown()).optional()
1381
+ }).passthrough(), Qs = ke;
1382
+ function Hs(t) {
1383
+ switch (t) {
1384
+ case "boolean":
1385
+ return r.boolean().optional();
1386
+ case "compactExecutionFieldArray":
1387
+ return r.array(Ue).optional();
1388
+ case "coverage":
1389
+ return $e.optional();
1390
+ case "diagnosticFeedback":
1391
+ return ve.optional();
1392
+ case "executionFieldArray":
1393
+ return r.array(P).optional();
1394
+ case "executionResult":
1395
+ return Qs.optional();
1396
+ case "number":
1397
+ return r.number().finite().optional();
1398
+ case "population":
1399
+ return Se.optional();
1400
+ case "record":
1401
+ return m.optional();
1402
+ case "recordArray":
1403
+ return Ve.optional();
1404
+ case "responseDetail":
1405
+ return r.enum(["compact", "standard", "debug"]).optional();
1406
+ case "string":
1407
+ return r.string().optional();
1408
+ case "stringArray":
1409
+ return r.array(r.string()).optional();
1410
+ case "unknown":
1411
+ return r.unknown().optional();
1412
+ case "unknownArray":
1413
+ return r.array(r.unknown()).optional();
1414
+ case "validationResult":
1415
+ return ie.optional();
1416
+ }
1417
+ }
1418
+ const Ws = Object.fromEntries(
1419
+ Object.entries(V).map(
1420
+ ([t, s]) => [t, Hs(s)]
1421
+ )
1422
+ ), Ys = r.object(Ws).strict(), z = r.object({
1423
+ sourceKey: r.string().optional(),
1424
+ kind: r.enum(["semantic", "physical", "sql"]).optional(),
1425
+ domainId: r.string().optional(),
1426
+ datasetName: r.string().optional(),
1427
+ datasetId: r.string().optional(),
1428
+ connectionId: r.string().optional(),
1429
+ tableName: r.string().optional(),
1430
+ label: r.string().optional()
1431
+ }).passthrough(), $ = r.object({
1432
+ name: r.string(),
1433
+ label: r.string().optional(),
1434
+ role: r.enum(["dimension", "measure", "date", "id", "unknown"]).optional(),
1435
+ dataType: r.enum(["string", "number", "boolean", "date", "datetime", "unknown"]).optional(),
1436
+ aggregate: Pe.optional(),
1437
+ sourceKey: r.string().optional(),
1438
+ source: z.optional()
1439
+ }).passthrough(), we = r.object({
1440
+ id: r.string().optional(),
1441
+ builder: r.literal("semaphor.inputOptions"),
1442
+ source: z.optional(),
1443
+ sourceKey: r.string().optional(),
1444
+ valueFieldRef: $,
1445
+ labelFieldRef: $,
1446
+ filterFieldRef: $.optional(),
1447
+ population: r.unknown().optional(),
1448
+ dependencies: r.unknown().optional(),
1449
+ limit: r.number().int().positive().optional(),
1450
+ spec: m.optional()
1451
+ }).passthrough(), Ie = r.object({
1452
+ appliesToViewIds: r.array(r.string()).optional(),
1453
+ viewId: r.string().optional(),
1454
+ fieldRef: $,
1455
+ relationshipHint: r.unknown().optional(),
1456
+ relationshipsUsed: r.array(m).optional()
1457
+ }).passthrough(), Js = r.object({
1458
+ id: r.string(),
1459
+ label: r.string().optional(),
1460
+ type: r.string().optional(),
1461
+ serverSide: r.boolean().optional(),
1462
+ fieldRef: $.optional(),
1463
+ optionQuery: we.optional(),
1464
+ bindings: r.array(Ie).optional(),
1465
+ appliesToViewIds: r.array(r.string()),
1466
+ relationshipHint: r.unknown().optional(),
1467
+ relationshipsUsed: r.array(m).optional()
1468
+ }).passthrough(), Zs = r.object({
1469
+ builder: r.enum([
1470
+ "semaphor.metric",
1471
+ "semaphor.records",
1472
+ "semaphor.matrix",
1473
+ "semaphor.analysis",
1474
+ "semaphor.sql"
1475
+ ]),
1476
+ spec: m,
1477
+ fallbackReason: m.optional()
1478
+ }).passthrough(), Xs = r.object({
1479
+ id: r.string(),
1480
+ title: r.string().optional(),
1481
+ purpose: r.string().optional(),
1482
+ sourcePresentation: r.object({
1483
+ sourceKeys: r.array(r.string()).optional(),
1484
+ sourceLabels: r.array(r.string()).optional()
1485
+ }).passthrough().optional(),
1486
+ visual: r.string().optional(),
1487
+ visualSpec: m.optional(),
1488
+ queryKind: r.enum(["metric", "records", "matrix", "analysis", "sql_fallback"]).optional(),
1489
+ sdkBuilder: r.enum([
1490
+ "semaphor.metric",
1491
+ "semaphor.records",
1492
+ "semaphor.matrix",
1493
+ "semaphor.analysis",
1494
+ "semaphor.sql"
1495
+ ]).optional(),
1496
+ sdkSpec: Zs.optional(),
1497
+ fields: r.array($).optional(),
1498
+ computation: m.optional(),
1499
+ uxExpectations: r.array(r.string()).optional(),
1500
+ validation: m.optional()
1501
+ }).passthrough(), et = r.object({
1502
+ inputId: r.string(),
1503
+ label: r.string().optional(),
1504
+ type: r.string().optional(),
1505
+ serverSide: r.boolean().optional(),
1506
+ fieldRef: $.optional(),
1507
+ optionQuery: we.optional(),
1508
+ bindings: r.array(Ie),
1509
+ appliesToViewIds: r.array(r.string()),
1510
+ notAppliedToViewIds: r.array(r.string())
1511
+ }).passthrough(), wt = r.object({
1512
+ schemaVersion: r.literal(T),
1513
+ title: r.string(),
1514
+ purpose: r.string().optional(),
1515
+ userGoal: r.string().optional(),
1516
+ nextStep: r.string().optional(),
1517
+ sources: r.array(z),
1518
+ inputs: r.array(Js),
1519
+ views: r.array(Xs),
1520
+ filterContracts: r.array(et),
1521
+ implementationChecklist: r.object({
1522
+ schemaVersion: r.string().optional(),
1523
+ requiredDevtools: r.object({
1524
+ mountRootDevtools: r.boolean(),
1525
+ providerDebugBridge: r.string().optional(),
1526
+ panelPosition: r.string().optional(),
1527
+ forbidden: r.array(r.string()).optional()
1528
+ }).passthrough(),
1529
+ requiredInputOptions: r.array(m),
1530
+ filterScopeByInput: r.array(m),
1531
+ bindingsByView: r.record(r.string(), r.array(m)),
1532
+ validationCommands: r.array(r.string()),
1533
+ browserSmokeChecks: r.array(r.string())
1534
+ }).passthrough(),
1535
+ nextRequiredTool: r.object({
1536
+ name: r.string(),
1537
+ reason: r.string().optional()
1538
+ }).optional(),
1539
+ unsupportedInsights: r.array(
1540
+ r.object({
1541
+ title: r.string(),
1542
+ requestedQuestion: r.string(),
1543
+ reason: r.string(),
1544
+ suggestedModelingFix: r.string()
1545
+ }).passthrough()
1546
+ ).optional(),
1547
+ assumptions: r.array(r.string()).optional(),
1548
+ validation: m.optional()
1549
+ }).passthrough().superRefine((t, s) => {
1550
+ const e = me(t);
1551
+ for (const i of e.issues)
1552
+ s.addIssue({
1553
+ code: r.ZodIssueCode.custom,
1554
+ message: i
1555
+ });
1556
+ }), st = new Set(
1557
+ Object.keys(V)
1558
+ );
1559
+ function It() {
1560
+ return Object.keys(
1561
+ V
1562
+ );
1563
+ }
1564
+ function tt(t) {
1565
+ return st.has(t);
1566
+ }
1567
+ function At(t) {
1568
+ if (!t || typeof t != "object" || Array.isArray(t))
1569
+ throw new Error("Semaphor analyze result must be an object.");
1570
+ const e = Object.keys(t).filter(
1571
+ (i) => !tt(i)
1572
+ );
1573
+ if (e.length)
1574
+ throw new Error(
1575
+ `Semaphor analyze result contains unsupported top-level field(s): ${e.join(", ")}.`
1576
+ );
1577
+ return Ys.parse(t);
1578
+ }
1579
+ const Ae = 100, R = "selection:";
1580
+ function _e(t) {
1581
+ return [
1582
+ ne(t.source),
1583
+ He(t.name),
1584
+ t.sourceField ?? ""
1585
+ ].join("::");
1586
+ }
1587
+ function _t(t) {
1588
+ return `${R}${t}`;
1589
+ }
1590
+ function it(t) {
1591
+ return t.startsWith(R) && t.length > R.length;
1592
+ }
1593
+ function Rt(t) {
1594
+ return it(t) ? t.slice(R.length) : void 0;
1595
+ }
1596
+ function Re(t) {
1597
+ if (!t) return "";
1598
+ const s = t.calendar.fiscalCalendar;
1599
+ return JSON.stringify([
1600
+ t.granularity,
1601
+ t.calendar.tz,
1602
+ t.calendar.weekStart,
1603
+ s ? [s.kind, s.yearStartMonth] : null
1604
+ ]);
1605
+ }
1606
+ function rt(t) {
1607
+ return JSON.stringify([
1608
+ _e(t.field),
1609
+ t.operator,
1610
+ t.operator === "isNull" ? null : t.value,
1611
+ Re(t.temporalBucket)
1612
+ ]);
1613
+ }
1614
+ function X(t) {
1615
+ return JSON.stringify(t.conditions.map(rt).sort());
1616
+ }
1617
+ function D(t) {
1618
+ return JSON.stringify([
1619
+ ne(t.field.source),
1620
+ t.field.name,
1621
+ t.operator,
1622
+ t.operator === "isNull" ? null : t.value,
1623
+ Re(t.temporalBucket)
1624
+ ]);
1625
+ }
1626
+ function ee(t) {
1627
+ return JSON.stringify(
1628
+ t.conditions.map(D).sort()
1629
+ );
1630
+ }
1631
+ function Ct(t) {
1632
+ const s = t.map((e) => e.id);
1633
+ if (new Set(s).size !== s.length)
1634
+ throw new Error("Data App selections require one active selection per id.");
1635
+ return t.map((e) => ({
1636
+ ...e,
1637
+ tuples: e.tuples.map((i) => ({
1638
+ ...i,
1639
+ conditions: [...i.conditions].sort(
1640
+ (n, a) => O(
1641
+ D(n),
1642
+ D(a)
1643
+ )
1644
+ )
1645
+ })).sort(
1646
+ (i, n) => O(
1647
+ ee(i),
1648
+ ee(n)
1649
+ )
1650
+ )
1651
+ })).sort((e, i) => O(e.id, i.id));
1652
+ }
1653
+ function O(t, s) {
1654
+ return t < s ? -1 : t > s ? 1 : 0;
1655
+ }
1656
+ function jt(t, s) {
1657
+ return X(t) === X(s);
1658
+ }
1659
+ const nt = "(Blank)";
1660
+ function qt(t) {
1661
+ return t.conditions.map((s) => s.label ? s.label : s.operator === "isNull" || s.value === null ? nt : String(s.value)).join(" · ");
1662
+ }
1663
+ const at = r.union([
1664
+ ze,
1665
+ Le
1666
+ ]), ot = r.object({
1667
+ name: r.string().min(1),
1668
+ source: at,
1669
+ dataType: r.enum(["string", "number", "boolean", "date", "datetime"]),
1670
+ sourceField: r.string().min(1).optional()
1671
+ }).strict(), ut = r.object({
1672
+ field: ot,
1673
+ operator: r.enum(["=", "isNull"]),
1674
+ value: r.union([r.string(), r.number().finite(), r.null()]),
1675
+ label: r.string().optional(),
1676
+ temporalBucket: re.optional()
1677
+ }).strict().superRefine((t, s) => {
1678
+ t.operator === "isNull" != (t.value === null) && s.addIssue({
1679
+ code: r.ZodIssueCode.custom,
1680
+ message: "isNull carries a null value, and only isNull does.",
1681
+ path: ["value"]
1682
+ });
1683
+ }), lt = r.object({
1684
+ conditions: r.array(ut).min(1)
1685
+ }).strict().superRefine((t, s) => {
1686
+ const e = t.conditions.map((i) => _e(i.field));
1687
+ new Set(e).size !== e.length && s.addIssue({
1688
+ code: r.ZodIssueCode.custom,
1689
+ message: "A tuple holds one condition per field.",
1690
+ path: ["conditions"]
1691
+ });
1692
+ }), Et = r.object({
1693
+ kind: r.literal("selection"),
1694
+ sourceCardId: r.string().min(1),
1695
+ tuples: r.array(lt).min(1).max(Ae)
1696
+ }).strict(), dt = r.object({
1697
+ field: Ge,
1698
+ operator: r.enum(["=", "isNull"]),
1699
+ value: r.union([r.string(), r.number().finite(), r.null()]),
1700
+ temporalBucket: re.optional()
1701
+ }).strict().superRefine((t, s) => {
1702
+ t.operator === "isNull" != (t.value === null) && s.addIssue({
1703
+ code: r.ZodIssueCode.custom,
1704
+ message: "isNull carries a null value, and only isNull does.",
1705
+ path: ["value"]
1706
+ });
1707
+ }), ct = r.object({
1708
+ conditions: r.array(dt).min(1)
1709
+ }).strict().superRefine((t, s) => {
1710
+ for (let e = 0; e < t.conditions.length; e += 1) {
1711
+ const i = t.conditions[e];
1712
+ t.conditions.findIndex(
1713
+ (a, l) => l < e && Qe(a.field, i.field)
1714
+ ) !== -1 && s.addIssue({
1715
+ code: r.ZodIssueCode.custom,
1716
+ message: "A selection tuple can contain only one condition per field.",
1717
+ path: ["conditions", e, "field"]
1718
+ });
1719
+ }
1720
+ }), Ft = r.object({
1721
+ id: r.string().min(1),
1722
+ tuples: r.array(ct).min(1).max(Ae)
1723
+ }).strict(), pt = r.object({
1724
+ runtimeFilters: B.innerType().shape.filters,
1725
+ runtimeSorts: B.innerType().shape.sorts.optional()
1726
+ });
1727
+ function xt(t) {
1728
+ return pt.parse(t);
1729
+ }
1730
+ const mt = {
1731
+ // A window executes a governed statement set, not one compiled query.
1732
+ compiledQuery: r.never().optional(),
1733
+ intent: ce.shape.intent,
1734
+ resultShape: r.literal("matrix"),
1735
+ result: le.optional(),
1736
+ metadata: r.object({ rowLimitExceeded: r.boolean(), matrixFailure: U.optional() }).passthrough()
1737
+ }, ft = ke.extend(mt), Kt = ft.superRefine((t, s) => {
1738
+ t.status === "failed" == !!t.result && s.addIssue({ code: "custom", message: "Only answered or partial Matrix execution carries a window." }), t.result && t.status === "partial" != t.result.window.failures.length > 0 && s.addIssue({ code: "custom", message: "Matrix execution status must match acquired window failures." });
1739
+ });
1740
+ export {
1741
+ ts as $,
1742
+ rt as A,
1743
+ X as B,
1744
+ D as C,
1745
+ ee as D,
1746
+ jt as E,
1747
+ qt as F,
1748
+ ot as G,
1749
+ ut as H,
1750
+ lt as I,
1751
+ Et as J,
1752
+ dt as K,
1753
+ ct as L,
1754
+ gt as M,
1755
+ Ye as N,
1756
+ G as O,
1757
+ Je as P,
1758
+ ae as Q,
1759
+ bt as R,
1760
+ T as S,
1761
+ Ze as T,
1762
+ Xe as U,
1763
+ Q as V,
1764
+ U as W,
1765
+ es as X,
1766
+ ue as Y,
1767
+ vt as Z,
1768
+ ss as _,
1769
+ $t as a,
1770
+ H as a0,
1771
+ is as a1,
1772
+ St as a2,
1773
+ pt as a3,
1774
+ xt as a4,
1775
+ Kt as a5,
1776
+ ce as a6,
1777
+ Ft as b,
1778
+ Ct as c,
1779
+ tt as d,
1780
+ V as e,
1781
+ Gs as f,
1782
+ It as g,
1783
+ ve as h,
1784
+ kt as i,
1785
+ Se as j,
1786
+ $e as k,
1787
+ ke as l,
1788
+ Qs as m,
1789
+ Ws as n,
1790
+ Ys as o,
1791
+ At as p,
1792
+ wt as q,
1793
+ le as r,
1794
+ Ls as s,
1795
+ Ae as t,
1796
+ _e as u,
1797
+ me as v,
1798
+ _t as w,
1799
+ it as x,
1800
+ Rt as y,
1801
+ Re as z
1802
+ };