@sisense/sdk-ui 2.22.0 → 2.24.0

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 (210) hide show
  1. package/dist/ai.cjs +19 -19
  2. package/dist/ai.js +59 -59
  3. package/dist/analytics-composer/node.cjs +1 -1
  4. package/dist/analytics-composer/node.js +2440 -1253
  5. package/dist/analytics-composer.cjs +47 -47
  6. package/dist/analytics-composer.js +135 -131
  7. package/dist/dimensions-C1R5YRt-.js +204 -0
  8. package/dist/dimensions-C7yXAoZs.cjs +1 -0
  9. package/dist/execute-query-0Y9Fn9Pf.cjs +1 -0
  10. package/dist/execute-query-b9oy2Egy.js +5869 -0
  11. package/dist/{index-NyouhE_A.cjs → index-Ck-0gJC9.cjs} +1 -1
  12. package/dist/{index-kxX21arA.js → index-r66Tjiqj.js} +39 -2
  13. package/dist/index.cjs +633 -616
  14. package/dist/index.js +18198 -17875
  15. package/dist/index.umd.js +1006 -949
  16. package/dist/packages/sdk-ui/src/domains/dashboarding/components/editable-layout/const.d.ts +1 -0
  17. package/dist/packages/sdk-ui/src/domains/dashboarding/components/editable-layout/smart-pointer-sensor.d.ts +17 -0
  18. package/dist/packages/sdk-ui/src/domains/dashboarding/dashboard-model/get-dashboard-model.d.ts +2 -1
  19. package/dist/packages/sdk-ui/src/domains/dashboarding/dashboard-model/use-dashboard-model/dashboard-model-reducer/types.d.ts +24 -2
  20. package/dist/packages/sdk-ui/src/domains/dashboarding/dashboard-model/use-dashboard-model/dashboard-model-reducer/utils.d.ts +2 -1
  21. package/dist/packages/sdk-ui/src/domains/dashboarding/dashboard-model/use-dashboard-model/use-dashboard-persistence.d.ts +2 -1
  22. package/dist/packages/sdk-ui/src/domains/dashboarding/hooks/jtd/jtd-types.d.ts +1 -1
  23. package/dist/packages/sdk-ui/src/domains/dashboarding/hooks/rename-widget/use-widget-renaming.d.ts +34 -0
  24. package/dist/packages/sdk-ui/src/domains/dashboarding/hooks/use-widget-csv-download.d.ts +24 -0
  25. package/dist/packages/sdk-ui/src/domains/dashboarding/types.d.ts +43 -1
  26. package/dist/packages/sdk-ui/src/domains/dashboarding/use-dashboard-theme.d.ts +1 -1
  27. package/dist/packages/sdk-ui/src/domains/data-browser/add-filter-popover/add-filter-data-browser.d.ts +2 -1
  28. package/dist/packages/sdk-ui/src/domains/data-browser/data-schema-browser/data-schema-browser.d.ts +2 -1
  29. package/dist/packages/sdk-ui/src/domains/data-browser/dimensions-browser/types.d.ts +9 -1
  30. package/dist/packages/sdk-ui/src/domains/formulas/fetch-formula.d.ts +1 -1
  31. package/dist/packages/sdk-ui/src/domains/query-execution/core/execute-query.d.ts +1 -1
  32. package/dist/packages/sdk-ui/src/domains/query-execution/hooks/use-execute-query-by-widget-id/use-execute-query-by-widget-id.d.ts +1 -1
  33. package/dist/packages/sdk-ui/src/domains/query-execution/hooks/use-query-cache/use-query-cache.d.ts +2 -1
  34. package/dist/packages/sdk-ui/src/domains/visualizations/components/boxplot-chart/boxplot-utils.d.ts +1 -1
  35. package/dist/packages/sdk-ui/src/domains/visualizations/components/chart/helpers/get-load-data-function.d.ts +1 -1
  36. package/dist/packages/sdk-ui/src/domains/visualizations/components/chart/helpers/use-translated-data-options.d.ts +12 -1
  37. package/dist/packages/sdk-ui/src/domains/visualizations/components/chart/restructured-charts/helpers/data-loading.d.ts +1 -1
  38. package/dist/packages/sdk-ui/src/domains/visualizations/components/chart/restructured-charts/types.d.ts +1 -1
  39. package/dist/packages/sdk-ui/src/domains/widgets/change-events.d.ts +73 -0
  40. package/dist/packages/sdk-ui/src/domains/widgets/components/chart-widget/types.d.ts +12 -2
  41. package/dist/packages/sdk-ui/src/domains/widgets/components/chart-widget/use-chart-widget-csv-download.d.ts +18 -0
  42. package/dist/packages/sdk-ui/src/domains/widgets/components/custom-widget/use-custom-widget-csv-download.d.ts +15 -0
  43. package/dist/packages/sdk-ui/src/domains/widgets/components/pivot-table-widget/types.d.ts +12 -2
  44. package/dist/packages/sdk-ui/src/domains/widgets/components/pivot-table-widget/use-pivot-widget-csv-download.d.ts +18 -0
  45. package/dist/packages/sdk-ui/src/domains/widgets/components/tabber-buttons-widget/types.d.ts +8 -8
  46. package/dist/packages/sdk-ui/src/domains/widgets/components/widget/types.d.ts +21 -1
  47. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/translate-dashboard-filters.d.ts +3 -1
  48. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/translate-widget-data-options.d.ts +1 -1
  49. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/translate-widget-style-options/to-widget-dto-style.d.ts +11 -2
  50. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/types.d.ts +1 -1
  51. package/dist/packages/sdk-ui/src/domains/widgets/components/widget-by-id/utils.d.ts +3 -2
  52. package/dist/packages/sdk-ui/src/domains/widgets/event-to-delta.d.ts +17 -0
  53. package/dist/packages/sdk-ui/src/domains/widgets/helpers/header-menu-utils.d.ts +14 -4
  54. package/dist/packages/sdk-ui/src/domains/widgets/helpers/index.d.ts +1 -0
  55. package/dist/packages/sdk-ui/src/domains/widgets/hooks/use-csv-query-file-loader.d.ts +16 -0
  56. package/dist/packages/sdk-ui/src/domains/widgets/hooks/use-title-renaming.d.ts +27 -0
  57. package/dist/packages/sdk-ui/src/domains/widgets/hooks/use-widget-header-management.d.ts +28 -0
  58. package/dist/packages/sdk-ui/src/domains/widgets/hooks/use-with-csv-download-menu-item.d.ts +22 -0
  59. package/dist/packages/sdk-ui/src/domains/widgets/shared/widget-container/widget-container.d.ts +3 -1
  60. package/dist/packages/sdk-ui/src/domains/widgets/shared/widget-header/types.d.ts +31 -0
  61. package/dist/packages/sdk-ui/src/domains/widgets/shared/widget-header/widget-header.d.ts +3 -1
  62. package/dist/packages/sdk-ui/src/domains/widgets/shared/widget-header/widget-menu-button.d.ts +1 -1
  63. package/dist/packages/sdk-ui/src/infra/api/rest-api.d.ts +4 -0
  64. package/dist/packages/sdk-ui/src/infra/api/types/dashboard-dto.d.ts +1 -1
  65. package/dist/packages/sdk-ui/src/infra/app/client-application.d.ts +5 -231
  66. package/dist/packages/sdk-ui/src/infra/app/helpers.d.ts +16 -0
  67. package/dist/packages/sdk-ui/src/infra/app/settings/settings.d.ts +1 -1
  68. package/dist/packages/sdk-ui/src/infra/app/settings/types/deployment-props.d.ts +3 -0
  69. package/dist/packages/sdk-ui/src/infra/app/settings/types/features.d.ts +2 -1
  70. package/dist/packages/sdk-ui/src/infra/app/types.d.ts +236 -0
  71. package/dist/packages/sdk-ui/src/infra/contexts/custom-widgets-provider/custom-widgets-provider-adapter.d.ts +2 -1
  72. package/dist/packages/sdk-ui/src/infra/contexts/custom-widgets-provider/use-custom-widgets.d.ts +11 -4
  73. package/dist/packages/sdk-ui/src/infra/contexts/sisense-context/sisense-context.d.ts +1 -1
  74. package/dist/packages/sdk-ui/src/infra/contexts/theme-provider/theme-context.d.ts +2 -1
  75. package/dist/packages/sdk-ui/src/infra/decorators/component-decorators/with-tracking/with-tracking.d.ts +1 -1
  76. package/dist/packages/sdk-ui/src/infra/decorators/hook-decorators/with-tracking.d.ts +1 -1
  77. package/dist/packages/sdk-ui/src/infra/plugins/custom-plugin-context-provider.d.ts +18 -0
  78. package/dist/packages/sdk-ui/src/infra/plugins/plugin-context.d.ts +29 -0
  79. package/dist/packages/sdk-ui/src/infra/{contexts/plugin-provider → plugins}/plugin-provider.d.ts +4 -2
  80. package/dist/packages/sdk-ui/src/infra/{contexts/plugin-provider → plugins}/types.d.ts +12 -4
  81. package/dist/packages/sdk-ui/src/infra/plugins/use-widget-plugin-registry.d.ts +7 -0
  82. package/dist/packages/sdk-ui/src/infra/{contexts/plugin-provider → plugins}/validate-plugins.d.ts +1 -1
  83. package/dist/packages/sdk-ui/src/infra/plugins/widget-plugins/types.d.ts +302 -0
  84. package/dist/packages/sdk-ui/src/infra/plugins/widget-plugins/widget-plugin-registry.d.ts +33 -0
  85. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/de-de.d.ts +37 -0
  86. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/en-us.d.ts +37 -0
  87. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/es-ar.d.ts +37 -0
  88. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/es-es.d.ts +37 -0
  89. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/fr-fr.d.ts +37 -0
  90. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/it-it.d.ts +37 -0
  91. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/ja-jp.d.ts +37 -0
  92. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/ko-kr.d.ts +37 -0
  93. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/nl-nl.d.ts +37 -0
  94. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/pt-br.d.ts +37 -0
  95. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/ru-ru.d.ts +37 -0
  96. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/tr-tr.d.ts +37 -0
  97. package/dist/packages/sdk-ui/src/infra/translation/resources/__external__/zh-cn.d.ts +37 -0
  98. package/dist/packages/sdk-ui/src/infra/translation/resources/en.d.ts +37 -0
  99. package/dist/packages/sdk-ui/src/infra/translation/resources/index.d.ts +74 -0
  100. package/dist/packages/sdk-ui/src/modules/ai/use-get-nlq-result.d.ts +1 -0
  101. package/dist/packages/sdk-ui/src/modules/ai/use-get-query-recommendations.d.ts +1 -0
  102. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/axis-type-detection.d.ts +17 -0
  103. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/chart-type-schemas.d.ts +37 -0
  104. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/index.d.ts +9 -0
  105. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/translate-data-options.d.ts +9 -0
  106. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/helpers/validate-chart-json.d.ts +19 -0
  107. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/translate-chart-from-json.d.ts +42 -0
  108. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/chart/translate-chart-to-json.d.ts +41 -0
  109. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/constructs/dimensions/translate-dimensions-from-json.d.ts +11 -0
  110. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/constructs/dimensions/translate-dimensions-to-json.d.ts +22 -0
  111. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-filters-from-json.d.ts → constructs/filters/translate-filters-from-json.d.ts} +2 -2
  112. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-filters-to-json.d.ts → constructs/filters/translate-filters-to-json.d.ts} +1 -1
  113. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-measures-from-json.d.ts → constructs/measures/translate-measures-from-json.d.ts} +4 -4
  114. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/constructs/measures/translate-measures-to-json.d.ts +22 -0
  115. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/index.d.ts +8 -3
  116. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/helpers/index.d.ts +7 -0
  117. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/helpers/translate-data-options.d.ts +14 -0
  118. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/helpers/validate-pivot-table-json.d.ts +19 -0
  119. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/translate-pivot-table-from-json.d.ts +12 -0
  120. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/pivot-table/translate-pivot-table-to-json.d.ts +12 -0
  121. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/query/constants.d.ts +8 -0
  122. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-query-from-json.d.ts → query/translate-query-from-json.d.ts} +3 -3
  123. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-query-to-jaql.d.ts → query/translate-query-to-jaql.d.ts} +1 -1
  124. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{translate-query-to-json.d.ts → query/translate-query-to-json.d.ts} +2 -2
  125. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/data-options/adapters.d.ts +19 -0
  126. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/data-options/index.d.ts +9 -0
  127. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/data-options/translate-axis-from-json.d.ts +24 -0
  128. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/data-options/translate-axis-to-json.d.ts +18 -0
  129. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/custom-formula/process-custom-formula.d.ts +1 -1
  130. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/custom-formula/validate-custom-formula.d.ts +25 -0
  131. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/execute-function.d.ts +1 -1
  132. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/factory-function-processors.d.ts +1 -1
  133. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/factory-function-schemas.d.ts +1 -1
  134. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/filter-processors.d.ts +1 -1
  135. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/expression/formula-function-schemas.d.ts +41 -0
  136. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/process-arg.d.ts +1 -1
  137. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/{process-function → shared/expression}/process-node.d.ts +1 -1
  138. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/attribute-helpers.d.ts +50 -0
  139. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/fuzzy-match.d.ts +16 -0
  140. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/parse-compose-code.d.ts +34 -0
  141. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/schema-index.d.ts +52 -0
  142. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/shared/utils/translation-helpers.d.ts +31 -0
  143. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/types.d.ts +115 -4
  144. package/dist/packages/sdk-ui/src/modules/analytics-composer/types.d.ts +6 -6
  145. package/dist/packages/sdk-ui/src/props.d.ts +20 -2
  146. package/dist/packages/sdk-ui/src/public-api/alpha.d.ts +1 -1
  147. package/dist/packages/sdk-ui/src/public-api/beta.d.ts +1 -1
  148. package/dist/packages/sdk-ui/src/public-api/internal.d.ts +10 -6
  149. package/dist/packages/sdk-ui/src/public-api/public.d.ts +2 -2
  150. package/dist/packages/sdk-ui/src/public-api/sisense-internal.d.ts +14 -5
  151. package/dist/packages/sdk-ui/src/shared/components/grouped-items-browser/types.d.ts +7 -1
  152. package/dist/packages/sdk-ui/src/shared/components/inline-text-editor/inline-text-editor.d.ts +26 -0
  153. package/dist/packages/sdk-ui/src/shared/components/inline-text-editor/use-blur-on-pointer-down-outside.d.ts +11 -0
  154. package/dist/packages/sdk-ui/src/shared/components/loading-indicator.d.ts +2 -1
  155. package/dist/packages/sdk-ui/src/shared/components/quota-notification/quota-notification.d.ts +2 -2
  156. package/dist/packages/sdk-ui/src/shared/const.d.ts +5 -0
  157. package/dist/packages/sdk-ui/src/shared/hooks/use-app-settings.d.ts +2 -1
  158. package/dist/packages/sdk-ui/src/shared/hooks/use-quota-notification.d.ts +4 -4
  159. package/dist/packages/sdk-ui/src/shared/hooks/use-should-load.d.ts +1 -1
  160. package/dist/packages/sdk-ui/src/shared/hooks/use-with-change-detection.d.ts +5 -5
  161. package/dist/packages/sdk-ui/src/shared/types/menu-item.d.ts +5 -1
  162. package/dist/packages/sdk-ui/src/shared/utils/menu-item-converters.d.ts +12 -0
  163. package/dist/packages/sdk-ui/src/types.d.ts +3 -3
  164. package/dist/quota-notification-BqRYSJ7r.cjs +713 -0
  165. package/dist/{quota-notification-D6oMJal8.js → quota-notification-CeKnEyQG.js} +18423 -17044
  166. package/dist/translations/de-de.cjs +1 -1
  167. package/dist/translations/de-de.js +40 -3
  168. package/dist/translations/en-us.cjs +1 -1
  169. package/dist/translations/en-us.js +1 -1
  170. package/dist/translations/es-ar.cjs +1 -1
  171. package/dist/translations/es-ar.js +40 -3
  172. package/dist/translations/es-es.cjs +1 -1
  173. package/dist/translations/es-es.js +40 -3
  174. package/dist/translations/fr-fr.cjs +1 -1
  175. package/dist/translations/fr-fr.js +40 -3
  176. package/dist/translations/it-it.cjs +1 -1
  177. package/dist/translations/it-it.js +42 -5
  178. package/dist/translations/ja-jp.cjs +1 -1
  179. package/dist/translations/ja-jp.js +42 -5
  180. package/dist/translations/ko-kr.cjs +1 -1
  181. package/dist/translations/ko-kr.js +42 -5
  182. package/dist/translations/nl-nl.cjs +1 -1
  183. package/dist/translations/nl-nl.js +42 -5
  184. package/dist/translations/pt-br.cjs +1 -1
  185. package/dist/translations/pt-br.js +40 -3
  186. package/dist/translations/ru-ru.cjs +1 -1
  187. package/dist/translations/ru-ru.js +42 -5
  188. package/dist/translations/tr-tr.cjs +1 -1
  189. package/dist/translations/tr-tr.js +40 -3
  190. package/dist/translations/zh-cn.cjs +1 -1
  191. package/dist/translations/zh-cn.js +42 -5
  192. package/dist/{types-CoY6F8Ma.cjs → types-C0QU2tsE.cjs} +1 -1
  193. package/dist/{types-ixSwJkxM.js → types-DJtC8_5_.js} +1 -1
  194. package/dist/{utils-BP-BglHE.js → utils-BCp2ISWh.js} +3745 -3773
  195. package/dist/{utils-C8YMrOdw.cjs → utils-D8O1_kl3.cjs} +33 -33
  196. package/dist/{widget-composer-DI4sHaNe.cjs → widget-composer-BkHZISs7.cjs} +1 -1
  197. package/dist/{widget-composer-CUUFoCb9.js → widget-composer-CDNL9_XF.js} +8 -8
  198. package/package.json +10 -8
  199. package/dist/dimensions-BiLyFpCg.js +0 -202
  200. package/dist/dimensions-X4_igtmO.cjs +0 -1
  201. package/dist/execute-query-BEeqqDl6.js +0 -5795
  202. package/dist/execute-query-DJDE0zRU.cjs +0 -1
  203. package/dist/packages/sdk-ui/src/infra/contexts/plugin-provider/index.d.ts +0 -5
  204. package/dist/packages/sdk-ui/src/infra/contexts/plugin-provider/plugin-context.d.ts +0 -15
  205. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/common.d.ts +0 -84
  206. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/parse-compose-code.d.ts +0 -15
  207. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/translate-dimensions-from-json.d.ts +0 -12
  208. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/translate-dimensions-to-json.d.ts +0 -13
  209. package/dist/packages/sdk-ui/src/modules/analytics-composer/nlq-v3-translator/translate-measures-to-json.d.ts +0 -13
  210. package/dist/quota-notification-z3dv2KoH.cjs +0 -672
@@ -1,186 +1,193 @@
1
- var er = Object.defineProperty, rr = Object.defineProperties;
2
- var tr = Object.getOwnPropertyDescriptors;
3
- var ye = Object.getOwnPropertySymbols;
4
- var sr = Object.prototype.hasOwnProperty, nr = Object.prototype.propertyIsEnumerable;
5
- var ge = (e, r, t) => r in e ? er(e, r, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[r] = t, g = (e, r) => {
6
- for (var t in r || (r = {}))
7
- sr.call(r, t) && ge(e, t, r[t]);
8
- if (ye)
9
- for (var t of ye(r))
10
- nr.call(r, t) && ge(e, t, r[t]);
1
+ var Vt = Object.defineProperty, Wt = Object.defineProperties;
2
+ var jt = Object.getOwnPropertyDescriptors;
3
+ var Ue = Object.getOwnPropertySymbols;
4
+ var Kt = Object.prototype.hasOwnProperty, Gt = Object.prototype.propertyIsEnumerable;
5
+ var _e = (e, t, r) => t in e ? Vt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, y = (e, t) => {
6
+ for (var r in t || (t = {}))
7
+ Kt.call(t, r) && _e(e, r, t[r]);
8
+ if (Ue)
9
+ for (var r of Ue(t))
10
+ Gt.call(t, r) && _e(e, r, t[r]);
11
11
  return e;
12
- }, h = (e, r) => rr(e, tr(r));
13
- import { f as ir, J as or } from "../types-ixSwJkxM.js";
14
- import { b as Ws, E as js, a as Js, i as Ks, e as Gs, d as Qs } from "../types-ixSwJkxM.js";
15
- import { bW as ar, bA as ur, bX as cr, bY as lr, bZ as fr, aw as ne, b_ as dr, av as mr, b$ as pr, b8 as yr, ax as gr, c0 as hr, bb as br, b9 as Fr, aL as wr, b7 as qr, ba as Er, d as Cr, c as $r, k as Ar, c1 as xr, c2 as Dr, c3 as Mr, c4 as Sr, c5 as Tr, c6 as Nr, c7 as Rr, c8 as Or, c9 as Ir, ca as zr, cb as Br, au as Pr, cc as kr, cd as Lr, S as ie, h as Vr, s as oe, b as W, M as I, aj as $e, bG as Ae, ce as _r, cf as Ur, cg as Wr, ch as jr, ci as Jr, aH as Kr, an as he, am as Gr, cj as xe, a6 as Qr, ck as Yr, x as Hr, v as Zr } from "../execute-query-BEeqqDl6.js";
16
- import { i as Xr, b as vr, D as et, d as rt, a as tt } from "../dimensions-BiLyFpCg.js";
17
- class st {
12
+ }, F = (e, t) => Wt(e, jt(t));
13
+ import { f as Yt, J as Jt } from "../types-DJtC8_5_.js";
14
+ import { b as pi, E as gi, a as yi, i as hi, e as bi, d as Ai } from "../types-DJtC8_5_.js";
15
+ import { cb as Ht, bK as Qt, cc as Xt, cd as Zt, ce as er, aG as Fe, cf as tr, aF as rr, cg as sr, bi as nr, aH as ir, ch as or, bl as ar, bj as ur, aV as cr, bh as lr, bk as fr, d as dr, c as mr, k as pr, ci as gr, cj as yr, ck as hr, cl as br, cm as Ar, cn as Fr, co as wr, cp as Er, cq as Cr, cr as Tr, cs as qr, aE as xr, ct as $r, cu as Sr, S as B, t as X, h as Or, b as $, av as _, at as se, cv as Dr, cw as Mr, cx as Nr, M as U, cy as Rr, cz as vr, aR as Ir, ax as Ve, aw as we, bQ as ne, U as Pr, V as kr, cA as it, ag as Br, A as zr, cB as Lr, y as Ur, x as _r } from "../execute-query-b9oy2Egy.js";
16
+ import { i as Vr, b as Wr, D as jr, d as Kr, a as Gr } from "../dimensions-C1R5YRt-.js";
17
+ function Yr(e, t) {
18
+ const r = e.length, s = t.length, n = Array.from({ length: r + 1 }, (i, o) => Array.from({ length: s + 1 }, (a, u) => o === 0 ? u : u === 0 ? o : 0));
19
+ for (let i = 1; i <= r; i++)
20
+ for (let o = 1; o <= s; o++)
21
+ n[i][o] = Math.min(n[i - 1][o] + 1, n[i][o - 1] + 1, n[i - 1][o - 1] + (e[i - 1] === t[o - 1] ? 0 : 1));
22
+ return n[r][s];
23
+ }
24
+ class Jr {
18
25
  constructor() {
19
26
  this.keyToValue = /* @__PURE__ */ new Map(), this.valueToKey = /* @__PURE__ */ new Map();
20
27
  }
21
- set(r, t) {
22
- this.keyToValue.set(r, t), this.valueToKey.set(t, r);
28
+ set(t, r) {
29
+ this.keyToValue.set(t, r), this.valueToKey.set(r, t);
23
30
  }
24
- getByKey(r) {
25
- return this.keyToValue.get(r);
31
+ getByKey(t) {
32
+ return this.keyToValue.get(t);
26
33
  }
27
- getByValue(r) {
28
- return this.valueToKey.get(r);
34
+ getByValue(t) {
35
+ return this.valueToKey.get(t);
29
36
  }
30
37
  clear() {
31
38
  this.keyToValue.clear(), this.valueToKey.clear();
32
39
  }
33
40
  }
34
- class De {
35
- constructor(r) {
36
- this.generateIdentifier = r, this.kv = new st();
41
+ class ot {
42
+ constructor(t) {
43
+ this.generateIdentifier = t, this.kv = new Jr();
37
44
  }
38
- register(r, t) {
39
- this.kv.getByValue(r) || (t || (t = this.generateIdentifier(r)), this.kv.set(t, r));
45
+ register(t, r) {
46
+ this.kv.getByValue(t) || (r || (r = this.generateIdentifier(t)), this.kv.set(r, t));
40
47
  }
41
48
  clear() {
42
49
  this.kv.clear();
43
50
  }
44
- getIdentifier(r) {
45
- return this.kv.getByValue(r);
51
+ getIdentifier(t) {
52
+ return this.kv.getByValue(t);
46
53
  }
47
- getValue(r) {
48
- return this.kv.getByKey(r);
54
+ getValue(t) {
55
+ return this.kv.getByKey(t);
49
56
  }
50
57
  }
51
- class nt extends De {
58
+ class Hr extends ot {
52
59
  constructor() {
53
- super((r) => r.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
60
+ super((t) => t.name), this.classToAllowedProps = /* @__PURE__ */ new Map();
54
61
  }
55
- register(r, t) {
56
- typeof t == "object" ? (t.allowProps && this.classToAllowedProps.set(r, t.allowProps), super.register(r, t.identifier)) : super.register(r, t);
62
+ register(t, r) {
63
+ typeof r == "object" ? (r.allowProps && this.classToAllowedProps.set(t, r.allowProps), super.register(t, r.identifier)) : super.register(t, r);
57
64
  }
58
- getAllowedProps(r) {
59
- return this.classToAllowedProps.get(r);
65
+ getAllowedProps(t) {
66
+ return this.classToAllowedProps.get(t);
60
67
  }
61
68
  }
62
- function it(e) {
69
+ function Qr(e) {
63
70
  if ("values" in Object)
64
71
  return Object.values(e);
65
- const r = [];
66
- for (const t in e)
67
- e.hasOwnProperty(t) && r.push(e[t]);
68
- return r;
72
+ const t = [];
73
+ for (const r in e)
74
+ e.hasOwnProperty(r) && t.push(e[r]);
75
+ return t;
69
76
  }
70
- function ot(e, r) {
71
- const t = it(e);
72
- if ("find" in t)
73
- return t.find(r);
74
- const s = t;
77
+ function Xr(e, t) {
78
+ const r = Qr(e);
79
+ if ("find" in r)
80
+ return r.find(t);
81
+ const s = r;
75
82
  for (let n = 0; n < s.length; n++) {
76
- const o = s[n];
77
- if (r(o))
78
- return o;
83
+ const i = s[n];
84
+ if (t(i))
85
+ return i;
79
86
  }
80
87
  }
81
- function z(e, r) {
82
- Object.entries(e).forEach(([t, s]) => r(s, t));
88
+ function V(e, t) {
89
+ Object.entries(e).forEach(([r, s]) => t(s, r));
83
90
  }
84
- function j(e, r) {
85
- return e.indexOf(r) !== -1;
91
+ function ee(e, t) {
92
+ return e.indexOf(t) !== -1;
86
93
  }
87
- function be(e, r) {
88
- for (let t = 0; t < e.length; t++) {
89
- const s = e[t];
90
- if (r(s))
94
+ function We(e, t) {
95
+ for (let r = 0; r < e.length; r++) {
96
+ const s = e[r];
97
+ if (t(s))
91
98
  return s;
92
99
  }
93
100
  }
94
- class at {
101
+ class Zr {
95
102
  constructor() {
96
103
  this.transfomers = {};
97
104
  }
98
- register(r) {
99
- this.transfomers[r.name] = r;
105
+ register(t) {
106
+ this.transfomers[t.name] = t;
100
107
  }
101
- findApplicable(r) {
102
- return ot(this.transfomers, (t) => t.isApplicable(r));
108
+ findApplicable(t) {
109
+ return Xr(this.transfomers, (r) => r.isApplicable(t));
103
110
  }
104
- findByName(r) {
105
- return this.transfomers[r];
111
+ findByName(t) {
112
+ return this.transfomers[t];
106
113
  }
107
114
  }
108
- const ut = (e) => Object.prototype.toString.call(e).slice(8, -1), Me = (e) => typeof e == "undefined", ct = (e) => e === null, k = (e) => typeof e != "object" || e === null || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null ? !0 : Object.getPrototypeOf(e) === Object.prototype, X = (e) => k(e) && Object.keys(e).length === 0, S = (e) => Array.isArray(e), lt = (e) => typeof e == "string", ft = (e) => typeof e == "number" && !isNaN(e), dt = (e) => typeof e == "boolean", mt = (e) => e instanceof RegExp, L = (e) => e instanceof Map, V = (e) => e instanceof Set, Se = (e) => ut(e) === "Symbol", pt = (e) => e instanceof Date && !isNaN(e.valueOf()), yt = (e) => e instanceof Error, Fe = (e) => typeof e == "number" && isNaN(e), gt = (e) => dt(e) || ct(e) || Me(e) || ft(e) || lt(e) || Se(e), ht = (e) => typeof e == "bigint", bt = (e) => e === 1 / 0 || e === -1 / 0, Ft = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), wt = (e) => e instanceof URL, Te = (e) => e.replace(/\./g, "\\."), Y = (e) => e.map(String).map(Te).join("."), P = (e) => {
109
- const r = [];
110
- let t = "";
115
+ const es = (e) => Object.prototype.toString.call(e).slice(8, -1), at = (e) => typeof e == "undefined", ts = (e) => e === null, G = (e) => typeof e != "object" || e === null || e === Object.prototype ? !1 : Object.getPrototypeOf(e) === null ? !0 : Object.getPrototypeOf(e) === Object.prototype, pe = (e) => G(e) && Object.keys(e).length === 0, I = (e) => Array.isArray(e), rs = (e) => typeof e == "string", ss = (e) => typeof e == "number" && !isNaN(e), ns = (e) => typeof e == "boolean", is = (e) => e instanceof RegExp, Y = (e) => e instanceof Map, J = (e) => e instanceof Set, ut = (e) => es(e) === "Symbol", os = (e) => e instanceof Date && !isNaN(e.valueOf()), as = (e) => e instanceof Error, je = (e) => typeof e == "number" && isNaN(e), us = (e) => ns(e) || ts(e) || at(e) || ss(e) || rs(e) || ut(e), cs = (e) => typeof e == "bigint", ls = (e) => e === 1 / 0 || e === -1 / 0, fs = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView), ds = (e) => e instanceof URL, ct = (e) => e.replace(/\./g, "\\."), ce = (e) => e.map(String).map(ct).join("."), K = (e) => {
116
+ const t = [];
117
+ let r = "";
111
118
  for (let n = 0; n < e.length; n++) {
112
- let o = e.charAt(n);
113
- if (o === "\\" && e.charAt(n + 1) === ".") {
114
- t += ".", n++;
119
+ let i = e.charAt(n);
120
+ if (i === "\\" && e.charAt(n + 1) === ".") {
121
+ r += ".", n++;
115
122
  continue;
116
123
  }
117
- if (o === ".") {
118
- r.push(t), t = "";
124
+ if (i === ".") {
125
+ t.push(r), r = "";
119
126
  continue;
120
127
  }
121
- t += o;
128
+ r += i;
122
129
  }
123
- const s = t;
124
- return r.push(s), r;
130
+ const s = r;
131
+ return t.push(s), t;
125
132
  };
126
- function A(e, r, t, s) {
133
+ function v(e, t, r, s) {
127
134
  return {
128
135
  isApplicable: e,
129
- annotation: r,
130
- transform: t,
136
+ annotation: t,
137
+ transform: r,
131
138
  untransform: s
132
139
  };
133
140
  }
134
- const Ne = [
135
- A(Me, "undefined", () => null, () => {
141
+ const lt = [
142
+ v(at, "undefined", () => null, () => {
136
143
  }),
137
- A(ht, "bigint", (e) => e.toString(), (e) => typeof BigInt != "undefined" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
138
- A(pt, "Date", (e) => e.toISOString(), (e) => new Date(e)),
139
- A(yt, "Error", (e, r) => {
140
- const t = {
144
+ v(cs, "bigint", (e) => e.toString(), (e) => typeof BigInt != "undefined" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
145
+ v(os, "Date", (e) => e.toISOString(), (e) => new Date(e)),
146
+ v(as, "Error", (e, t) => {
147
+ const r = {
141
148
  name: e.name,
142
149
  message: e.message
143
150
  };
144
- return r.allowedErrorProps.forEach((s) => {
145
- t[s] = e[s];
146
- }), t;
147
- }, (e, r) => {
148
- const t = new Error(e.message);
149
- return t.name = e.name, t.stack = e.stack, r.allowedErrorProps.forEach((s) => {
150
- t[s] = e[s];
151
- }), t;
151
+ return t.allowedErrorProps.forEach((s) => {
152
+ r[s] = e[s];
153
+ }), r;
154
+ }, (e, t) => {
155
+ const r = new Error(e.message);
156
+ return r.name = e.name, r.stack = e.stack, t.allowedErrorProps.forEach((s) => {
157
+ r[s] = e[s];
158
+ }), r;
152
159
  }),
153
- A(mt, "regexp", (e) => "" + e, (e) => {
154
- const r = e.slice(1, e.lastIndexOf("/")), t = e.slice(e.lastIndexOf("/") + 1);
155
- return new RegExp(r, t);
160
+ v(is, "regexp", (e) => "" + e, (e) => {
161
+ const t = e.slice(1, e.lastIndexOf("/")), r = e.slice(e.lastIndexOf("/") + 1);
162
+ return new RegExp(t, r);
156
163
  }),
157
- A(
158
- V,
164
+ v(
165
+ J,
159
166
  "set",
160
167
  // (sets only exist in es6+)
161
168
  // eslint-disable-next-line es5/no-es6-methods
162
169
  (e) => [...e.values()],
163
170
  (e) => new Set(e)
164
171
  ),
165
- A(L, "map", (e) => [...e.entries()], (e) => new Map(e)),
166
- A((e) => Fe(e) || bt(e), "number", (e) => Fe(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
167
- A((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
168
- A(wt, "URL", (e) => e.toString(), (e) => new URL(e))
172
+ v(Y, "map", (e) => [...e.entries()], (e) => new Map(e)),
173
+ v((e) => je(e) || ls(e), "number", (e) => je(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
174
+ v((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
175
+ v(ds, "URL", (e) => e.toString(), (e) => new URL(e))
169
176
  ];
170
- function J(e, r, t, s) {
177
+ function ie(e, t, r, s) {
171
178
  return {
172
179
  isApplicable: e,
173
- annotation: r,
174
- transform: t,
180
+ annotation: t,
181
+ transform: r,
175
182
  untransform: s
176
183
  };
177
184
  }
178
- const Re = J((e, r) => Se(e) ? !!r.symbolRegistry.getIdentifier(e) : !1, (e, r) => ["symbol", r.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, r, t) => {
179
- const s = t.symbolRegistry.getValue(r[1]);
185
+ const ft = ie((e, t) => ut(e) ? !!t.symbolRegistry.getIdentifier(e) : !1, (e, t) => ["symbol", t.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, t, r) => {
186
+ const s = r.symbolRegistry.getValue(t[1]);
180
187
  if (!s)
181
188
  throw new Error("Trying to deserialize unknown symbol");
182
189
  return s;
183
- }), qt = [
190
+ }), ms = [
184
191
  Int8Array,
185
192
  Uint8Array,
186
193
  Int16Array,
@@ -190,124 +197,124 @@ const Re = J((e, r) => Se(e) ? !!r.symbolRegistry.getIdentifier(e) : !1, (e, r)
190
197
  Float32Array,
191
198
  Float64Array,
192
199
  Uint8ClampedArray
193
- ].reduce((e, r) => (e[r.name] = r, e), {}), Oe = J(Ft, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, r) => {
194
- const t = qt[r[1]];
195
- if (!t)
200
+ ].reduce((e, t) => (e[t.name] = t, e), {}), dt = ie(fs, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, t) => {
201
+ const r = ms[t[1]];
202
+ if (!r)
196
203
  throw new Error("Trying to deserialize unknown typed array");
197
- return new t(e);
204
+ return new r(e);
198
205
  });
199
- function Ie(e, r) {
200
- return e != null && e.constructor ? !!r.classRegistry.getIdentifier(e.constructor) : !1;
206
+ function mt(e, t) {
207
+ return e != null && e.constructor ? !!t.classRegistry.getIdentifier(e.constructor) : !1;
201
208
  }
202
- const ze = J(Ie, (e, r) => ["class", r.classRegistry.getIdentifier(e.constructor)], (e, r) => {
203
- const t = r.classRegistry.getAllowedProps(e.constructor);
204
- if (!t)
205
- return g({}, e);
209
+ const pt = ie(mt, (e, t) => ["class", t.classRegistry.getIdentifier(e.constructor)], (e, t) => {
210
+ const r = t.classRegistry.getAllowedProps(e.constructor);
211
+ if (!r)
212
+ return y({}, e);
206
213
  const s = {};
207
- return t.forEach((n) => {
214
+ return r.forEach((n) => {
208
215
  s[n] = e[n];
209
216
  }), s;
210
- }, (e, r, t) => {
211
- const s = t.classRegistry.getValue(r[1]);
217
+ }, (e, t, r) => {
218
+ const s = r.classRegistry.getValue(t[1]);
212
219
  if (!s)
213
- throw new Error(`Trying to deserialize unknown class '${r[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
220
+ throw new Error(`Trying to deserialize unknown class '${t[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
214
221
  return Object.assign(Object.create(s.prototype), e);
215
- }), Be = J((e, r) => !!r.customTransformerRegistry.findApplicable(e), (e, r) => ["custom", r.customTransformerRegistry.findApplicable(e).name], (e, r) => r.customTransformerRegistry.findApplicable(e).serialize(e), (e, r, t) => {
216
- const s = t.customTransformerRegistry.findByName(r[1]);
222
+ }), gt = ie((e, t) => !!t.customTransformerRegistry.findApplicable(e), (e, t) => ["custom", t.customTransformerRegistry.findApplicable(e).name], (e, t) => t.customTransformerRegistry.findApplicable(e).serialize(e), (e, t, r) => {
223
+ const s = r.customTransformerRegistry.findByName(t[1]);
217
224
  if (!s)
218
225
  throw new Error("Trying to deserialize unknown custom value");
219
226
  return s.deserialize(e);
220
- }), Et = [ze, Re, Be, Oe], we = (e, r) => {
221
- const t = be(Et, (n) => n.isApplicable(e, r));
222
- if (t)
227
+ }), ps = [pt, ft, gt, dt], Ke = (e, t) => {
228
+ const r = We(ps, (n) => n.isApplicable(e, t));
229
+ if (r)
223
230
  return {
224
- value: t.transform(e, r),
225
- type: t.annotation(e, r)
231
+ value: r.transform(e, t),
232
+ type: r.annotation(e, t)
226
233
  };
227
- const s = be(Ne, (n) => n.isApplicable(e, r));
234
+ const s = We(lt, (n) => n.isApplicable(e, t));
228
235
  if (s)
229
236
  return {
230
- value: s.transform(e, r),
237
+ value: s.transform(e, t),
231
238
  type: s.annotation
232
239
  };
233
- }, Pe = {};
234
- Ne.forEach((e) => {
235
- Pe[e.annotation] = e;
240
+ }, yt = {};
241
+ lt.forEach((e) => {
242
+ yt[e.annotation] = e;
236
243
  });
237
- const Ct = (e, r, t) => {
238
- if (S(r))
239
- switch (r[0]) {
244
+ const gs = (e, t, r) => {
245
+ if (I(t))
246
+ switch (t[0]) {
240
247
  case "symbol":
241
- return Re.untransform(e, r, t);
248
+ return ft.untransform(e, t, r);
242
249
  case "class":
243
- return ze.untransform(e, r, t);
250
+ return pt.untransform(e, t, r);
244
251
  case "custom":
245
- return Be.untransform(e, r, t);
252
+ return gt.untransform(e, t, r);
246
253
  case "typed-array":
247
- return Oe.untransform(e, r, t);
254
+ return dt.untransform(e, t, r);
248
255
  default:
249
- throw new Error("Unknown transformation: " + r);
256
+ throw new Error("Unknown transformation: " + t);
250
257
  }
251
258
  else {
252
- const s = Pe[r];
259
+ const s = yt[t];
253
260
  if (!s)
254
- throw new Error("Unknown transformation: " + r);
255
- return s.untransform(e, t);
261
+ throw new Error("Unknown transformation: " + t);
262
+ return s.untransform(e, r);
256
263
  }
257
- }, O = (e, r) => {
258
- if (r > e.size)
264
+ }, L = (e, t) => {
265
+ if (t > e.size)
259
266
  throw new Error("index out of bounds");
260
- const t = e.keys();
261
- for (; r > 0; )
262
- t.next(), r--;
263
- return t.next().value;
267
+ const r = e.keys();
268
+ for (; t > 0; )
269
+ r.next(), t--;
270
+ return r.next().value;
264
271
  };
265
- function ke(e) {
266
- if (j(e, "__proto__"))
272
+ function ht(e) {
273
+ if (ee(e, "__proto__"))
267
274
  throw new Error("__proto__ is not allowed as a property");
268
- if (j(e, "prototype"))
275
+ if (ee(e, "prototype"))
269
276
  throw new Error("prototype is not allowed as a property");
270
- if (j(e, "constructor"))
277
+ if (ee(e, "constructor"))
271
278
  throw new Error("constructor is not allowed as a property");
272
279
  }
273
- const $t = (e, r) => {
274
- ke(r);
275
- for (let t = 0; t < r.length; t++) {
276
- const s = r[t];
277
- if (V(e))
278
- e = O(e, +s);
279
- else if (L(e)) {
280
- const n = +s, o = +r[++t] == 0 ? "key" : "value", i = O(e, n);
281
- switch (o) {
280
+ const ys = (e, t) => {
281
+ ht(t);
282
+ for (let r = 0; r < t.length; r++) {
283
+ const s = t[r];
284
+ if (J(e))
285
+ e = L(e, +s);
286
+ else if (Y(e)) {
287
+ const n = +s, i = +t[++r] == 0 ? "key" : "value", o = L(e, n);
288
+ switch (i) {
282
289
  case "key":
283
- e = i;
290
+ e = o;
284
291
  break;
285
292
  case "value":
286
- e = e.get(i);
293
+ e = e.get(o);
287
294
  break;
288
295
  }
289
296
  } else
290
297
  e = e[s];
291
298
  }
292
299
  return e;
293
- }, v = (e, r, t) => {
294
- if (ke(r), r.length === 0)
295
- return t(e);
300
+ }, ge = (e, t, r) => {
301
+ if (ht(t), t.length === 0)
302
+ return r(e);
296
303
  let s = e;
297
- for (let o = 0; o < r.length - 1; o++) {
298
- const i = r[o];
299
- if (S(s)) {
300
- const a = +i;
304
+ for (let i = 0; i < t.length - 1; i++) {
305
+ const o = t[i];
306
+ if (I(s)) {
307
+ const a = +o;
301
308
  s = s[a];
302
- } else if (k(s))
303
- s = s[i];
304
- else if (V(s)) {
305
- const a = +i;
306
- s = O(s, a);
307
- } else if (L(s)) {
308
- if (o === r.length - 2)
309
+ } else if (G(s))
310
+ s = s[o];
311
+ else if (J(s)) {
312
+ const a = +o;
313
+ s = L(s, a);
314
+ } else if (Y(s)) {
315
+ if (i === t.length - 2)
309
316
  break;
310
- const u = +i, c = +r[++o] == 0 ? "key" : "value", p = O(s, u);
317
+ const u = +o, c = +t[++i] == 0 ? "key" : "value", p = L(s, u);
311
318
  switch (c) {
312
319
  case "key":
313
320
  s = p;
@@ -318,352 +325,354 @@ const $t = (e, r) => {
318
325
  }
319
326
  }
320
327
  }
321
- const n = r[r.length - 1];
322
- if (S(s) ? s[+n] = t(s[+n]) : k(s) && (s[n] = t(s[n])), V(s)) {
323
- const o = O(s, +n), i = t(o);
324
- o !== i && (s.delete(o), s.add(i));
328
+ const n = t[t.length - 1];
329
+ if (I(s) ? s[+n] = r(s[+n]) : G(s) && (s[n] = r(s[n])), J(s)) {
330
+ const i = L(s, +n), o = r(i);
331
+ i !== o && (s.delete(i), s.add(o));
325
332
  }
326
- if (L(s)) {
327
- const o = +r[r.length - 2], i = O(s, o);
333
+ if (Y(s)) {
334
+ const i = +t[t.length - 2], o = L(s, i);
328
335
  switch (+n == 0 ? "key" : "value") {
329
336
  case "key": {
330
- const u = t(i);
331
- s.set(u, s.get(i)), u !== i && s.delete(i);
337
+ const u = r(o);
338
+ s.set(u, s.get(o)), u !== o && s.delete(o);
332
339
  break;
333
340
  }
334
341
  case "value": {
335
- s.set(i, t(s.get(i)));
342
+ s.set(o, r(s.get(o)));
336
343
  break;
337
344
  }
338
345
  }
339
346
  }
340
347
  return e;
341
348
  };
342
- function ee(e, r, t = []) {
349
+ function ye(e, t, r = []) {
343
350
  if (!e)
344
351
  return;
345
- if (!S(e)) {
346
- z(e, (o, i) => ee(o, r, [...t, ...P(i)]));
352
+ if (!I(e)) {
353
+ V(e, (i, o) => ye(i, t, [...r, ...K(o)]));
347
354
  return;
348
355
  }
349
356
  const [s, n] = e;
350
- n && z(n, (o, i) => {
351
- ee(o, r, [...t, ...P(i)]);
352
- }), r(s, t);
357
+ n && V(n, (i, o) => {
358
+ ye(i, t, [...r, ...K(o)]);
359
+ }), t(s, r);
353
360
  }
354
- function At(e, r, t) {
355
- return ee(r, (s, n) => {
356
- e = v(e, n, (o) => Ct(o, s, t));
361
+ function hs(e, t, r) {
362
+ return ye(t, (s, n) => {
363
+ e = ge(e, n, (i) => gs(i, s, r));
357
364
  }), e;
358
365
  }
359
- function xt(e, r) {
360
- function t(s, n) {
361
- const o = $t(e, P(n));
362
- s.map(P).forEach((i) => {
363
- e = v(e, i, () => o);
366
+ function bs(e, t) {
367
+ function r(s, n) {
368
+ const i = ys(e, K(n));
369
+ s.map(K).forEach((o) => {
370
+ e = ge(e, o, () => i);
364
371
  });
365
372
  }
366
- if (S(r)) {
367
- const [s, n] = r;
368
- s.forEach((o) => {
369
- e = v(e, P(o), () => e);
370
- }), n && z(n, t);
373
+ if (I(t)) {
374
+ const [s, n] = t;
375
+ s.forEach((i) => {
376
+ e = ge(e, K(i), () => e);
377
+ }), n && V(n, r);
371
378
  } else
372
- z(r, t);
379
+ V(t, r);
373
380
  return e;
374
381
  }
375
- const Dt = (e, r) => k(e) || S(e) || L(e) || V(e) || Ie(e, r);
376
- function Mt(e, r, t) {
377
- const s = t.get(e);
378
- s ? s.push(r) : t.set(e, [r]);
382
+ const As = (e, t) => G(e) || I(e) || Y(e) || J(e) || mt(e, t);
383
+ function Fs(e, t, r) {
384
+ const s = r.get(e);
385
+ s ? s.push(t) : r.set(e, [t]);
379
386
  }
380
- function St(e, r) {
381
- const t = {};
387
+ function ws(e, t) {
388
+ const r = {};
382
389
  let s;
383
390
  return e.forEach((n) => {
384
391
  if (n.length <= 1)
385
392
  return;
386
- r || (n = n.map((a) => a.map(String)).sort((a, u) => a.length - u.length));
387
- const [o, ...i] = n;
388
- o.length === 0 ? s = i.map(Y) : t[Y(o)] = i.map(Y);
389
- }), s ? X(t) ? [s] : [s, t] : X(t) ? void 0 : t;
390
- }
391
- const Le = (e, r, t, s, n = [], o = [], i = /* @__PURE__ */ new Map()) => {
392
- var x;
393
- const a = gt(e);
393
+ t || (n = n.map((a) => a.map(String)).sort((a, u) => a.length - u.length));
394
+ const [i, ...o] = n;
395
+ i.length === 0 ? s = o.map(ce) : r[ce(i)] = o.map(ce);
396
+ }), s ? pe(r) ? [s] : [s, r] : pe(r) ? void 0 : r;
397
+ }
398
+ const bt = (e, t, r, s, n = [], i = [], o = /* @__PURE__ */ new Map()) => {
399
+ var b;
400
+ const a = us(e);
394
401
  if (!a) {
395
- Mt(e, n, r);
396
- const f = i.get(e);
397
- if (f)
402
+ Fs(e, n, t);
403
+ const g = o.get(e);
404
+ if (g)
398
405
  return s ? {
399
406
  transformedValue: null
400
- } : f;
407
+ } : g;
401
408
  }
402
- if (!Dt(e, t)) {
403
- const f = we(e, t), d = f ? {
404
- transformedValue: f.value,
405
- annotations: [f.type]
409
+ if (!As(e, r)) {
410
+ const g = Ke(e, r), m = g ? {
411
+ transformedValue: g.value,
412
+ annotations: [g.type]
406
413
  } : {
407
414
  transformedValue: e
408
415
  };
409
- return a || i.set(e, d), d;
416
+ return a || o.set(e, m), m;
410
417
  }
411
- if (j(o, e))
418
+ if (ee(i, e))
412
419
  return {
413
420
  transformedValue: null
414
421
  };
415
- const u = we(e, t), c = (x = u == null ? void 0 : u.value) != null ? x : e, p = S(c) ? [] : {}, m = {};
416
- z(c, (f, d) => {
417
- if (d === "__proto__" || d === "constructor" || d === "prototype")
418
- throw new Error(`Detected property ${d}. This is a prototype pollution risk, please remove it from your object.`);
419
- const w = Le(f, r, t, s, [...n, d], [...o, e], i);
420
- p[d] = w.transformedValue, S(w.annotations) ? m[d] = w.annotations : k(w.annotations) && z(w.annotations, ($, D) => {
421
- m[Te(d) + "." + D] = $;
422
+ const u = Ke(e, r), c = (b = u == null ? void 0 : u.value) != null ? b : e, p = I(c) ? [] : {}, l = {};
423
+ V(c, (g, m) => {
424
+ if (m === "__proto__" || m === "constructor" || m === "prototype")
425
+ throw new Error(`Detected property ${m}. This is a prototype pollution risk, please remove it from your object.`);
426
+ const A = bt(g, t, r, s, [...n, m], [...i, e], o);
427
+ p[m] = A.transformedValue, I(A.annotations) ? l[m] = A.annotations : G(A.annotations) && V(A.annotations, (C, N) => {
428
+ l[ct(m) + "." + N] = C;
422
429
  });
423
430
  });
424
- const y = X(m) ? {
431
+ const d = pe(l) ? {
425
432
  transformedValue: p,
426
433
  annotations: u ? [u.type] : void 0
427
434
  } : {
428
435
  transformedValue: p,
429
- annotations: u ? [u.type, m] : m
436
+ annotations: u ? [u.type, l] : l
430
437
  };
431
- return a || i.set(e, y), y;
438
+ return a || o.set(e, d), d;
432
439
  };
433
- function Ve(e) {
440
+ function At(e) {
434
441
  return Object.prototype.toString.call(e).slice(8, -1);
435
442
  }
436
- function qe(e) {
437
- return Ve(e) === "Array";
443
+ function Ge(e) {
444
+ return At(e) === "Array";
438
445
  }
439
- function Tt(e) {
440
- if (Ve(e) !== "Object")
446
+ function Es(e) {
447
+ if (At(e) !== "Object")
441
448
  return !1;
442
- const r = Object.getPrototypeOf(e);
443
- return !!r && r.constructor === Object && r === Object.prototype;
449
+ const t = Object.getPrototypeOf(e);
450
+ return !!t && t.constructor === Object && t === Object.prototype;
444
451
  }
445
- function Nt(e, r, t, s, n) {
446
- const o = {}.propertyIsEnumerable.call(s, r) ? "enumerable" : "nonenumerable";
447
- o === "enumerable" && (e[r] = t), n && o === "nonenumerable" && Object.defineProperty(e, r, {
448
- value: t,
452
+ function Cs(e, t, r, s, n) {
453
+ const i = {}.propertyIsEnumerable.call(s, t) ? "enumerable" : "nonenumerable";
454
+ i === "enumerable" && (e[t] = r), n && i === "nonenumerable" && Object.defineProperty(e, t, {
455
+ value: r,
449
456
  enumerable: !1,
450
457
  writable: !0,
451
458
  configurable: !0
452
459
  });
453
460
  }
454
- function re(e, r = {}) {
455
- if (qe(e))
456
- return e.map((n) => re(n, r));
457
- if (!Tt(e))
461
+ function he(e, t = {}) {
462
+ if (Ge(e))
463
+ return e.map((n) => he(n, t));
464
+ if (!Es(e))
458
465
  return e;
459
- const t = Object.getOwnPropertyNames(e), s = Object.getOwnPropertySymbols(e);
460
- return [...t, ...s].reduce((n, o) => {
461
- if (qe(r.props) && !r.props.includes(o))
466
+ const r = Object.getOwnPropertyNames(e), s = Object.getOwnPropertySymbols(e);
467
+ return [...r, ...s].reduce((n, i) => {
468
+ if (Ge(t.props) && !t.props.includes(i))
462
469
  return n;
463
- const i = e[o], a = re(i, r);
464
- return Nt(n, o, a, e, r.nonenumerable), n;
470
+ const o = e[i], a = he(o, t);
471
+ return Cs(n, i, a, e, t.nonenumerable), n;
465
472
  }, {});
466
473
  }
467
- class l {
474
+ class h {
468
475
  /**
469
476
  * @param dedupeReferentialEqualities If true, SuperJSON will make sure only one instance of referentially equal objects are serialized and the rest are replaced with `null`.
470
477
  */
471
- constructor({ dedupe: r = !1 } = {}) {
472
- this.classRegistry = new nt(), this.symbolRegistry = new De((t) => {
478
+ constructor({ dedupe: t = !1 } = {}) {
479
+ this.classRegistry = new Hr(), this.symbolRegistry = new ot((r) => {
473
480
  var s;
474
- return (s = t.description) != null ? s : "";
475
- }), this.customTransformerRegistry = new at(), this.allowedErrorProps = [], this.dedupe = r;
481
+ return (s = r.description) != null ? s : "";
482
+ }), this.customTransformerRegistry = new Zr(), this.allowedErrorProps = [], this.dedupe = t;
476
483
  }
477
- serialize(r) {
478
- const t = /* @__PURE__ */ new Map(), s = Le(r, t, this, this.dedupe), n = {
484
+ serialize(t) {
485
+ const r = /* @__PURE__ */ new Map(), s = bt(t, r, this, this.dedupe), n = {
479
486
  json: s.transformedValue
480
487
  };
481
- s.annotations && (n.meta = h(g({}, n.meta), {
488
+ s.annotations && (n.meta = F(y({}, n.meta), {
482
489
  values: s.annotations
483
490
  }));
484
- const o = St(t, this.dedupe);
485
- return o && (n.meta = h(g({}, n.meta), {
486
- referentialEqualities: o
491
+ const i = ws(r, this.dedupe);
492
+ return i && (n.meta = F(y({}, n.meta), {
493
+ referentialEqualities: i
487
494
  })), n;
488
495
  }
489
- deserialize(r) {
490
- const { json: t, meta: s } = r;
491
- let n = re(t);
492
- return s != null && s.values && (n = At(n, s.values, this)), s != null && s.referentialEqualities && (n = xt(n, s.referentialEqualities)), n;
496
+ deserialize(t) {
497
+ const { json: r, meta: s } = t;
498
+ let n = he(r);
499
+ return s != null && s.values && (n = hs(n, s.values, this)), s != null && s.referentialEqualities && (n = bs(n, s.referentialEqualities)), n;
493
500
  }
494
- stringify(r) {
495
- return JSON.stringify(this.serialize(r));
501
+ stringify(t) {
502
+ return JSON.stringify(this.serialize(t));
496
503
  }
497
- parse(r) {
498
- return this.deserialize(JSON.parse(r));
504
+ parse(t) {
505
+ return this.deserialize(JSON.parse(t));
499
506
  }
500
- registerClass(r, t) {
501
- this.classRegistry.register(r, t);
507
+ registerClass(t, r) {
508
+ this.classRegistry.register(t, r);
502
509
  }
503
- registerSymbol(r, t) {
504
- this.symbolRegistry.register(r, t);
510
+ registerSymbol(t, r) {
511
+ this.symbolRegistry.register(t, r);
505
512
  }
506
- registerCustom(r, t) {
507
- this.customTransformerRegistry.register(g({
508
- name: t
509
- }, r));
513
+ registerCustom(t, r) {
514
+ this.customTransformerRegistry.register(y({
515
+ name: r
516
+ }, t));
510
517
  }
511
- allowErrorProps(...r) {
512
- this.allowedErrorProps.push(...r);
518
+ allowErrorProps(...t) {
519
+ this.allowedErrorProps.push(...t);
513
520
  }
514
521
  }
515
- l.defaultInstance = new l();
516
- l.serialize = l.defaultInstance.serialize.bind(l.defaultInstance);
517
- l.deserialize = l.defaultInstance.deserialize.bind(l.defaultInstance);
518
- l.stringify = l.defaultInstance.stringify.bind(l.defaultInstance);
519
- l.parse = l.defaultInstance.parse.bind(l.defaultInstance);
520
- l.registerClass = l.defaultInstance.registerClass.bind(l.defaultInstance);
521
- l.registerSymbol = l.defaultInstance.registerSymbol.bind(l.defaultInstance);
522
- l.registerCustom = l.defaultInstance.registerCustom.bind(l.defaultInstance);
523
- l.allowErrorProps = l.defaultInstance.allowErrorProps.bind(l.defaultInstance);
524
- const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem, e.type), ae = (e) => new Cr(
522
+ h.defaultInstance = new h();
523
+ h.serialize = h.defaultInstance.serialize.bind(h.defaultInstance);
524
+ h.deserialize = h.defaultInstance.deserialize.bind(h.defaultInstance);
525
+ h.stringify = h.defaultInstance.stringify.bind(h.defaultInstance);
526
+ h.parse = h.defaultInstance.parse.bind(h.defaultInstance);
527
+ h.registerClass = h.defaultInstance.registerClass.bind(h.defaultInstance);
528
+ h.registerSymbol = h.defaultInstance.registerSymbol.bind(h.defaultInstance);
529
+ h.registerCustom = h.defaultInstance.registerCustom.bind(h.defaultInstance);
530
+ h.allowErrorProps = h.defaultInstance.allowErrorProps.bind(h.defaultInstance);
531
+ const z = (e) => e === void 0 ? B.None : e, Ts = (e) => new Jt(e.metadataItem, e.type), Ee = (e) => new dr(
525
532
  e.name,
526
533
  e.expression,
527
534
  e.type,
528
535
  e.description,
529
- R(e.sort),
536
+ z(e.sort),
530
537
  e.dataSource,
531
538
  e.composeCode
532
- ), ue = (e) => new $r(
539
+ ), Ce = (e) => new mr(
533
540
  e.name,
534
541
  e.expression,
535
542
  e.granularity,
536
543
  e.format,
537
544
  e.description,
538
- R(e.sort),
545
+ z(e.sort),
539
546
  e.dataSource,
540
547
  e.composeCode
541
- ), q = (e) => {
548
+ ), O = (e) => {
542
549
  switch (e.__serializable) {
543
550
  case "DimensionalAttribute":
544
- return ae(e);
551
+ return Ee(e);
545
552
  case "DimensionalLevelAttribute":
546
- return ue(e);
553
+ return Ce(e);
547
554
  default:
548
555
  return e;
549
556
  }
550
- }, _e = (e) => new et(
557
+ }, Ft = (e) => new jr(
551
558
  e.name,
552
559
  e.expression,
553
- e.attributes.map(q),
554
- e.dimensions.map(Ot),
560
+ e.attributes.map(O),
561
+ e.dimensions.map(qs),
555
562
  e.type,
556
563
  e.description,
557
- R(e.sort),
564
+ z(e.sort),
558
565
  e.dataSource,
559
566
  e.composeCode,
560
- e.defaultAttribute ? q(e.defaultAttribute) : void 0
561
- ), Ue = (e) => new rt(
567
+ e.defaultAttribute ? O(e.defaultAttribute) : void 0
568
+ ), wt = (e) => new Kr(
562
569
  e.name,
563
570
  e.expression,
564
571
  e.description,
565
- R(e.sort),
572
+ z(e.sort),
566
573
  e.dataSource,
567
- e.composeCode
568
- ), Ot = (e) => {
574
+ e.composeCode,
575
+ e.indexed,
576
+ e.merged
577
+ ), qs = (e) => {
569
578
  switch (e.__serializable) {
570
579
  case "DimensionalDimension":
571
- return _e(e);
580
+ return Ft(e);
572
581
  case "DimensionalDateDimension":
573
- return Ue(e);
582
+ return wt(e);
574
583
  default:
575
584
  return e;
576
585
  }
577
- }, ce = (e) => new Ar(
586
+ }, Te = (e) => new pr(
578
587
  e.name,
579
- q(e.attribute),
588
+ O(e.attribute),
580
589
  e.aggregation,
581
590
  e.format,
582
591
  e.description,
583
- R(e.sort),
592
+ z(e.sort),
584
593
  e.dataSource,
585
594
  e.composeCode
586
- ), le = (e) => {
587
- const r = Object.fromEntries(
588
- Object.entries(e.context).map(([t, s]) => {
595
+ ), qe = (e) => {
596
+ const t = Object.fromEntries(
597
+ Object.entries(e.context).map(([r, s]) => {
589
598
  if (s && typeof s == "object" && "__serializable" in s)
590
599
  switch (s.__serializable) {
591
600
  case "DimensionalAttribute":
592
- return [t, ae(s)];
601
+ return [r, Ee(s)];
593
602
  case "DimensionalLevelAttribute":
594
- return [t, ue(s)];
603
+ return [r, Ce(s)];
595
604
  case "DimensionalBaseMeasure":
596
- return [t, ce(s)];
605
+ return [r, Te(s)];
597
606
  case "DimensionalCalculatedMeasure":
598
- return [t, le(s)];
607
+ return [r, qe(s)];
599
608
  default:
600
- return [t, s];
609
+ return [r, s];
601
610
  }
602
- return [t, s];
611
+ return [r, s];
603
612
  })
604
613
  );
605
- return new xr(
614
+ return new gr(
606
615
  e.name,
607
616
  e.expression,
608
- r,
617
+ t,
609
618
  e.format,
610
619
  e.description,
611
- R(e.sort),
620
+ z(e.sort),
612
621
  e.dataSource,
613
622
  e.composeCode
614
623
  );
615
- }, We = (e) => new Dr(
624
+ }, Et = (e) => new yr(
616
625
  e.name,
617
- q(e.attribute),
626
+ O(e.attribute),
618
627
  e.format,
619
628
  e.description,
620
- R(e.sort),
629
+ z(e.sort),
621
630
  e.dataSource,
622
631
  e.composeCode
623
- ), H = (e) => {
632
+ ), le = (e) => {
624
633
  switch (e.__serializable) {
625
634
  case "DimensionalBaseMeasure":
626
- return ce(e);
635
+ return Te(e);
627
636
  case "DimensionalCalculatedMeasure":
628
- return le(e);
637
+ return qe(e);
629
638
  case "DimensionalMeasureTemplate":
630
- return We(e);
639
+ return Et(e);
631
640
  default:
632
641
  return e;
633
642
  }
634
- }, b = (e) => {
643
+ }, T = (e) => {
635
644
  switch (e.__serializable) {
636
645
  case "MembersFilter":
637
- return new Lr(
638
- q(e.attribute),
646
+ return new Sr(
647
+ O(e.attribute),
639
648
  e.members,
640
- e.config.backgroundFilter ? h(g({}, e.config), { backgroundFilter: b(e.config.backgroundFilter) }) : e.config,
649
+ e.config.backgroundFilter ? F(y({}, e.config), { backgroundFilter: T(e.config.backgroundFilter) }) : e.config,
641
650
  e.composeCode
642
651
  );
643
652
  case "LogicalAttributeFilter":
644
- return new kr(
645
- e.filters.map((t) => b(t)),
653
+ return new $r(
654
+ e.filters.map((r) => T(r)),
646
655
  e.operator,
647
656
  e.config,
648
657
  e.composeCode
649
658
  );
650
659
  case "CascadingFilter":
651
- return new Pr(
652
- e._filters.map((t) => b(t)),
660
+ return new xr(
661
+ e._filters.map((r) => T(r)),
653
662
  e.config,
654
663
  e.composeCode
655
664
  );
656
665
  case "ExcludeFilter":
657
- return new Br(
658
- b(e.filter),
659
- e.input ? b(e.input) : void 0,
666
+ return new qr(
667
+ T(e.filter),
668
+ e.input ? T(e.input) : void 0,
660
669
  e.config,
661
670
  e.composeCode
662
671
  );
663
672
  case "MeasureFilter":
664
- return new zr(
665
- q(e.attribute),
666
- H(e.measure),
673
+ return new Tr(
674
+ O(e.attribute),
675
+ le(e.measure),
667
676
  e.operatorA,
668
677
  e.valueA,
669
678
  e.operatorB,
@@ -672,25 +681,25 @@ const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem,
672
681
  e.composeCode
673
682
  );
674
683
  case "RankingFilter":
675
- return new Ir(
676
- q(e.attribute),
677
- H(e.measure),
684
+ return new Cr(
685
+ O(e.attribute),
686
+ le(e.measure),
678
687
  e.operator,
679
688
  e.count,
680
689
  e.config,
681
690
  e.composeCode
682
691
  );
683
692
  case "MeasureRankingFilter":
684
- return new Or(
685
- H(e.measure),
693
+ return new Er(
694
+ le(e.measure),
686
695
  e.operator,
687
696
  e.count,
688
697
  e.config,
689
698
  e.composeCode
690
699
  );
691
700
  case "NumericFilter":
692
- return new Rr(
693
- q(e.attribute),
701
+ return new wr(
702
+ O(e.attribute),
694
703
  e.operatorA,
695
704
  e.valueA,
696
705
  e.operatorB,
@@ -699,26 +708,26 @@ const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem,
699
708
  e.composeCode
700
709
  );
701
710
  case "TextFilter":
702
- return new Nr(
703
- q(e.attribute),
711
+ return new Fr(
712
+ O(e.attribute),
704
713
  e.operatorA,
705
714
  e.valueA,
706
715
  e.config,
707
716
  e.composeCode
708
717
  );
709
718
  case "DateRangeFilter": {
710
- const { valueA: t, valueB: s } = e;
711
- return new Tr(
712
- q(e.attribute),
713
- t,
719
+ const { valueA: r, valueB: s } = e;
720
+ return new Ar(
721
+ O(e.attribute),
722
+ r,
714
723
  s,
715
724
  e.config,
716
725
  e.composeCode
717
726
  );
718
727
  }
719
728
  case "RelativeDateFilter":
720
- return new Sr(
721
- q(e.attribute),
729
+ return new br(
730
+ O(e.attribute),
722
731
  e.offset,
723
732
  e.count,
724
733
  e.operator,
@@ -727,8 +736,8 @@ const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem,
727
736
  e.composeCode
728
737
  );
729
738
  case "CustomFilter":
730
- return new Mr(
731
- q(e.attribute),
739
+ return new hr(
740
+ O(e.attribute),
732
741
  e.jaqlExpression,
733
742
  e.config,
734
743
  e.composeCode
@@ -737,438 +746,751 @@ const R = (e) => e === void 0 ? ie.None : e, Rt = (e) => new or(e.metadataItem,
737
746
  return e;
738
747
  }
739
748
  };
740
- l.registerCustom(
749
+ h.registerCustom(
741
750
  {
742
- isApplicable: ir,
751
+ isApplicable: Yt,
743
752
  serialize: (e) => e.serialize(),
744
- deserialize: (e) => Rt(e)
753
+ deserialize: (e) => Ts(e)
745
754
  },
746
755
  "JaqlElement"
747
756
  );
748
- l.registerCustom(
757
+ h.registerCustom(
749
758
  {
750
- isApplicable: ar,
759
+ isApplicable: Ht,
751
760
  serialize: (e) => e.serialize(),
752
- deserialize: (e) => ae(e)
761
+ deserialize: (e) => Ee(e)
753
762
  },
754
763
  "DimensionalAttribute"
755
764
  );
756
- l.registerCustom(
765
+ h.registerCustom(
757
766
  {
758
- isApplicable: ur,
767
+ isApplicable: Qt,
759
768
  serialize: (e) => e.serialize(),
760
- deserialize: (e) => ue(e)
769
+ deserialize: (e) => Ce(e)
761
770
  },
762
771
  "DimensionalLevelAttribute"
763
772
  );
764
- l.registerCustom(
773
+ h.registerCustom(
765
774
  {
766
- isApplicable: Xr,
775
+ isApplicable: Vr,
767
776
  serialize: (e) => e.serialize(),
768
- deserialize: (e) => _e(e)
777
+ deserialize: (e) => Ft(e)
769
778
  },
770
779
  "DimensionalDimension"
771
780
  );
772
- l.registerCustom(
781
+ h.registerCustom(
773
782
  {
774
- isApplicable: vr,
783
+ isApplicable: Wr,
775
784
  serialize: (e) => e.serialize(),
776
- deserialize: (e) => Ue(e)
785
+ deserialize: (e) => wt(e)
777
786
  },
778
787
  "DimensionalDateDimension"
779
788
  );
780
- l.registerCustom(
789
+ h.registerCustom(
781
790
  {
782
- isApplicable: cr,
791
+ isApplicable: Xt,
783
792
  serialize: (e) => e.serialize(),
784
- deserialize: (e) => ce(e)
793
+ deserialize: (e) => Te(e)
785
794
  },
786
795
  "DimensionalBaseMeasure"
787
796
  );
788
- l.registerCustom(
797
+ h.registerCustom(
789
798
  {
790
- isApplicable: lr,
799
+ isApplicable: Zt,
791
800
  serialize: (e) => e.serialize(),
792
- deserialize: (e) => le(e)
801
+ deserialize: (e) => qe(e)
793
802
  },
794
803
  "DimensionalCalculatedMeasure"
795
804
  );
796
- l.registerCustom(
805
+ h.registerCustom(
797
806
  {
798
- isApplicable: fr,
807
+ isApplicable: er,
799
808
  serialize: (e) => e.serialize(),
800
- deserialize: (e) => We(e)
809
+ deserialize: (e) => Et(e)
801
810
  },
802
811
  "DimensionalMeasureTemplate"
803
812
  );
804
- l.registerCustom(
813
+ h.registerCustom(
805
814
  {
806
- isApplicable: ne,
815
+ isApplicable: Fe,
807
816
  serialize: (e) => e.serialize(),
808
- deserialize: (e) => b(e)
817
+ deserialize: (e) => T(e)
809
818
  },
810
819
  "MembersFilter"
811
820
  );
812
- l.registerCustom(
821
+ h.registerCustom(
813
822
  {
814
- isApplicable: dr,
823
+ isApplicable: tr,
815
824
  serialize: (e) => e.serialize(),
816
- deserialize: (e) => b(e)
825
+ deserialize: (e) => T(e)
817
826
  },
818
827
  "LogicalAttributeFilter"
819
828
  );
820
- l.registerCustom(
829
+ h.registerCustom(
821
830
  {
822
- isApplicable: mr,
831
+ isApplicable: rr,
823
832
  serialize: (e) => e.serialize(),
824
- deserialize: (e) => b(e)
833
+ deserialize: (e) => T(e)
825
834
  },
826
835
  "CascadingFilter"
827
836
  );
828
- l.registerCustom(
837
+ h.registerCustom(
829
838
  {
830
- isApplicable: pr,
839
+ isApplicable: sr,
831
840
  serialize: (e) => e.serialize(),
832
- deserialize: (e) => b(e)
841
+ deserialize: (e) => T(e)
833
842
  },
834
843
  "ExcludeFilter"
835
844
  );
836
- l.registerCustom(
845
+ h.registerCustom(
837
846
  {
838
- isApplicable: yr,
847
+ isApplicable: nr,
839
848
  serialize: (e) => e.serialize(),
840
- deserialize: (e) => b(e)
849
+ deserialize: (e) => T(e)
841
850
  },
842
851
  "MeasureFilter"
843
852
  );
844
- l.registerCustom(
853
+ h.registerCustom(
845
854
  {
846
- isApplicable: gr,
855
+ isApplicable: ir,
847
856
  serialize: (e) => e.serialize(),
848
- deserialize: (e) => b(e)
857
+ deserialize: (e) => T(e)
849
858
  },
850
859
  "RankingFilter"
851
860
  );
852
- l.registerCustom(
861
+ h.registerCustom(
853
862
  {
854
- isApplicable: hr,
863
+ isApplicable: or,
855
864
  serialize: (e) => e.serialize(),
856
- deserialize: (e) => b(e)
865
+ deserialize: (e) => T(e)
857
866
  },
858
867
  "MeasureRankingFilter"
859
868
  );
860
- l.registerCustom(
869
+ h.registerCustom(
861
870
  {
862
- isApplicable: br,
871
+ isApplicable: ar,
863
872
  serialize: (e) => e.serialize(),
864
- deserialize: (e) => b(e)
873
+ deserialize: (e) => T(e)
865
874
  },
866
875
  "NumericFilter"
867
876
  );
868
- l.registerCustom(
877
+ h.registerCustom(
869
878
  {
870
- isApplicable: Fr,
879
+ isApplicable: ur,
871
880
  serialize: (e) => e.serialize(),
872
- deserialize: (e) => b(e)
881
+ deserialize: (e) => T(e)
873
882
  },
874
883
  "TextFilter"
875
884
  );
876
- l.registerCustom(
885
+ h.registerCustom(
877
886
  {
878
- isApplicable: wr,
887
+ isApplicable: cr,
879
888
  serialize: (e) => e.serialize(),
880
- deserialize: (e) => b(e)
889
+ deserialize: (e) => T(e)
881
890
  },
882
891
  "DateRangeFilter"
883
892
  );
884
- l.registerCustom(
893
+ h.registerCustom(
885
894
  {
886
- isApplicable: qr,
895
+ isApplicable: lr,
887
896
  serialize: (e) => e.serialize(),
888
- deserialize: (e) => b(e)
897
+ deserialize: (e) => T(e)
889
898
  },
890
899
  "RelativeDateFilter"
891
900
  );
892
- l.registerCustom(
901
+ h.registerCustom(
893
902
  {
894
- isApplicable: Er,
903
+ isApplicable: fr,
895
904
  serialize: (e) => e.serialize(),
896
- deserialize: (e) => b(e)
905
+ deserialize: (e) => T(e)
897
906
  },
898
907
  "CustomFilter"
899
908
  );
900
- const Ps = l, F = "DM.";
901
- function E(e) {
909
+ const ni = h, E = "DM.";
910
+ function S(e) {
911
+ return typeof e == "object" && e !== null;
912
+ }
913
+ function q(e) {
902
914
  return typeof e == "object" && e !== null && "function" in e && "args" in e;
903
915
  }
904
- function je(e) {
905
- return e.every(E);
916
+ function Ct(e) {
917
+ return e.every(q);
906
918
  }
907
- function K(e) {
919
+ function oe(e) {
908
920
  return "attribute" in e && "config" in e;
909
921
  }
910
- function U(e) {
922
+ function Z(e) {
911
923
  return "left" in e && "right" in e && "operator" in e;
912
924
  }
913
- function fe(e) {
914
- return !K(e) && !U(e);
915
- }
916
- function It(e) {
917
- return typeof e == "object" && e !== null && "column" in e && typeof e.column == "string" && !("function" in e && "args" in e);
925
+ function xe(e) {
926
+ return !oe(e) && !Z(e);
918
927
  }
919
- function zt(e) {
920
- const r = e;
921
- return typeof e != "object" || e === null || r === null || !("column" in r) ? !1 : E(r.column);
928
+ function xs(e) {
929
+ return S(e) && "column" in e && typeof e.column == "string" && !("function" in e && "args" in e);
922
930
  }
923
- function Bt(e) {
924
- const r = [...e].sort((o, i) => i.name.length - o.name.length), t = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
925
- for (const o of e) {
926
- t.set(o.name, o);
927
- const i = [...o.columns].sort((u, c) => c.name.length - u.name.length);
928
- n.set(o.name, i);
931
+ function $s(e) {
932
+ return !S(e) || !("column" in e) ? !1 : q(e.column);
933
+ }
934
+ const x = 3;
935
+ function R(e, t, r) {
936
+ if (t.length === 0) return;
937
+ let s = Number.MAX_SAFE_INTEGER, n;
938
+ for (const i of t) {
939
+ const o = r(i), a = Yr(e, o);
940
+ a < s && (s = a, n = i);
941
+ }
942
+ return n !== void 0 ? { best: n, distance: s } : void 0;
943
+ }
944
+ const Tt = "en";
945
+ function fe(e, t) {
946
+ return e.localeCompare(t, Tt, { sensitivity: "accent" }) === 0;
947
+ }
948
+ function Ye(e, t) {
949
+ return t.length <= e.length && e.slice(0, t.length).localeCompare(t, Tt, { sensitivity: "accent" }) === 0;
950
+ }
951
+ function $e(e) {
952
+ const t = [...e].sort((i, o) => o.name.length - i.name.length), r = /* @__PURE__ */ new Map(), s = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map();
953
+ for (const i of e) {
954
+ r.set(i.name, i);
955
+ const o = [...i.columns].sort((u, c) => c.name.length - u.name.length);
956
+ n.set(i.name, o);
929
957
  const a = /* @__PURE__ */ new Map();
930
- for (const u of o.columns)
958
+ for (const u of i.columns)
931
959
  a.set(u.name, u);
932
- s.set(o.name, a);
960
+ s.set(i.name, a);
933
961
  }
934
962
  return {
935
- sortedTables: r,
963
+ sortedTables: t,
936
964
  tableColumnMap: n,
937
- tableMap: t,
965
+ tableMap: r,
938
966
  columnMap: s
939
967
  };
940
968
  }
941
- function Je(e, r) {
942
- if (!e.startsWith(F))
969
+ function Se(e, t) {
970
+ if (!e.startsWith(E))
943
971
  throw new Error(
944
- `Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
972
+ `Invalid dimensional element name format: '${e}'. Expected format: '${E}TableName.ColumnName[.Level]'`
945
973
  );
946
- const t = e.slice(F.length);
947
- if (!t)
974
+ const r = e.slice(E.length);
975
+ if (!r)
948
976
  throw new Error(
949
- `Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
977
+ `Invalid dimensional element name format: '${e}'. Expected format: '${E}TableName.ColumnName[.Level]'`
950
978
  );
951
979
  let s, n;
952
- for (const m of r.sortedTables)
953
- if (t.startsWith(m.name + ".")) {
954
- const y = t.slice(m.name.length + 1);
955
- if (!y)
980
+ for (const m of t.sortedTables)
981
+ if (Ye(r, m.name + ".")) {
982
+ const A = r.slice(m.name.length + 1);
983
+ if (!A)
956
984
  throw new Error(
957
- `Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
985
+ `Invalid dimensional element name format: '${e}'. Expected format: '${E}TableName.ColumnName[.Level]'`
958
986
  );
959
- s = m, n = y;
987
+ s = m, n = A;
960
988
  break;
961
989
  }
962
990
  if (!s) {
963
- const m = t.indexOf(".");
991
+ const m = r.indexOf(".");
964
992
  if (m === -1)
965
993
  throw new Error(
966
- `Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
994
+ `Invalid dimensional element name format: '${e}'. Expected format: '${E}TableName.ColumnName[.Level]'`
967
995
  );
968
- const y = t.slice(0, m);
969
- throw new Error(`Table "${y}" not found in the data model`);
970
- }
971
- const o = r.tableColumnMap.get(s.name);
972
- if (!o)
973
- throw new Error(`Table "${s.name}" found but has no columns`);
974
- let i, a;
975
- const u = W.all;
976
- for (const m of o) {
977
- if (n === m.name)
996
+ const A = r.slice(0, m), C = R(A, t.sortedTables, (ue) => ue.name), N = C && C.distance <= x ? ` Did you mean '${C.best.name}'?` : "";
997
+ throw new Error(`Table '${A}' not found in the data model.${N}`);
998
+ }
999
+ const i = t.tableColumnMap.get(s.name);
1000
+ if (!i)
1001
+ throw new Error(`Table '${s.name}' found but has no columns`);
1002
+ let o, a;
1003
+ const u = $.all;
1004
+ for (const m of i) {
1005
+ if (fe(n, m.name))
978
1006
  return { table: s, column: m };
979
- if (!n.startsWith(m.name + "."))
1007
+ if (!Ye(n, m.name + "."))
980
1008
  continue;
981
- const y = n.slice(m.name.length + 1);
982
- if (!y)
1009
+ const A = n.slice(m.name.length + 1);
1010
+ if (!A)
983
1011
  continue;
984
- const x = u.includes(y), f = oe(m.dataType);
985
- if (x) {
986
- if (f)
987
- return { table: s, column: m, level: y };
988
- i || (i = m, a = y);
1012
+ const C = u.includes(A), N = X(m.dataType);
1013
+ if (C) {
1014
+ if (N)
1015
+ return { table: s, column: m, level: A };
1016
+ o || (o = m, a = A);
989
1017
  continue;
990
1018
  }
991
- f && !i && (i = m, a = y);
1019
+ N && !o && (o = m, a = A);
992
1020
  }
993
- if (i && a)
994
- throw u.includes(a) ? new Error(
995
- `Invalid date level "${a}" in dimensional element "${e}". Column "${s.name}.${i.name}" is not a datetime column`
996
- ) : new Error(
997
- `Invalid date level "${a}" in dimensional element "${e}". Valid levels are: ${u.join(
1021
+ if (o && a) {
1022
+ if (u.includes(a))
1023
+ throw new Error(
1024
+ `Invalid date level '${a}' in dimensional element '${e}'. Column '${s.name}.${o.name}' is not a datetime column`
1025
+ );
1026
+ const m = R(a, u, (C) => C), A = m && m.distance <= x ? ` Did you mean '${m.best}'?` : "";
1027
+ throw new Error(
1028
+ `Invalid date level '${a}' in dimensional element '${e}'. Valid levels are: ${u.join(
998
1029
  ", "
999
- )}`
1030
+ )}.${A}`
1000
1031
  );
1001
- const c = n.indexOf("."), p = c === -1 ? n : n.slice(0, c);
1002
- throw new Error(`Column "${p}" not found in table "${s.name}"`);
1032
+ }
1033
+ const c = n.indexOf("."), p = c === -1 ? n : n.slice(0, c), l = R(n, i, (m) => m.name), d = l && l.distance <= x && !fe(l.best.name, p), b = d ? ` Did you mean '${l.best.name}'?` : "", g = !d && n.endsWith(".") && l !== void 0 && fe(l.best.name, p) ? ` Use '${p}' without a trailing dot.` : "";
1034
+ throw new Error(
1035
+ `Column '${p}' not found in table '${s.name}'.${b}${g}`
1036
+ );
1003
1037
  }
1004
- function Pt(e, r) {
1005
- const { table: t, column: s, level: n } = Je(e, r);
1038
+ function Ss(e, t) {
1039
+ const { table: r, column: s, level: n } = Se(e, t);
1006
1040
  if (n) {
1007
- if (!oe(s.dataType))
1041
+ if (!X(s.dataType))
1008
1042
  throw new Error(
1009
- `Invalid date level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is not a datetime column`
1043
+ `Invalid date level '${n}' in dimensional element '${e}'. Column '${r.name}.${s.name}' is not a datetime column`
1010
1044
  );
1011
- const o = W.all;
1012
- if (!o.includes(n))
1045
+ const i = $.all;
1046
+ if (!i.includes(n))
1013
1047
  throw new Error(
1014
- `Invalid date level "${n}" in dimensional element "${e}". Valid levels are: ${o.join(
1048
+ `Invalid date level '${n}' in dimensional element '${e}'. Valid levels are: ${i.join(
1015
1049
  ", "
1016
1050
  )}`
1017
1051
  );
1018
- const i = W.dateOnly;
1019
- if (s.dataType === "date" && !i.includes(n))
1052
+ const o = $.dateOnly;
1053
+ if (s.dataType === "date" && !o.includes(n))
1020
1054
  throw new Error(
1021
- `Invalid level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is only a date column, not a datetime column`
1055
+ `Invalid level '${n}' in dimensional element '${e}'. Column '${r.name}.${s.name}' is only a date column, not a datetime column`
1022
1056
  );
1023
- const a = W.timeOnly;
1057
+ const a = $.timeOnly;
1024
1058
  if (s.dataType === "time" && !a.includes(n))
1025
1059
  throw new Error(
1026
- `Invalid level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is only a time column, not a date column`
1060
+ `Invalid level '${n}' in dimensional element '${e}'. Column '${r.name}.${s.name}' is only a time column, not a date column`
1027
1061
  );
1028
1062
  }
1029
- return { column: s, level: n };
1063
+ return { table: r, column: s, level: n };
1030
1064
  }
1031
- function Ke(e) {
1032
- return e.type === I.TextAttribute;
1033
- }
1034
- function Ge(e) {
1035
- return e.type === I.NumericAttribute;
1036
- }
1037
- function kt(e) {
1038
- return e.type === I.DateLevel;
1039
- }
1040
- function Lt(e) {
1041
- return Ke(e) || Ge(e);
1042
- }
1043
- function G(e) {
1044
- return e.type === I.TextAttribute ? "text" : e.type === I.NumericAttribute ? "numeric" : e.type === I.DateLevel ? "date/datetime" : "unknown";
1045
- }
1046
- function Q(e, r, t) {
1047
- const { column: s, level: n } = Pt(e, t);
1048
- return Vr({
1049
- expression: s.expression,
1050
- dataType: s.dataType,
1051
- granularity: n,
1065
+ function H(e, t, r, s) {
1066
+ const { table: n, column: i, level: o } = Ss(e, r);
1067
+ let a = o;
1068
+ if (X(i.dataType) && a === void 0 && (s != null && s.inferredDateLevel)) {
1069
+ const u = s.inferredDateLevel, c = $.all;
1070
+ if (!c.includes(u))
1071
+ throw new Error(
1072
+ `Invalid inferred date level '${u}'. Valid levels are: ${c.join(", ")}`
1073
+ );
1074
+ const p = `${e}.${u}`, l = $.dateOnly;
1075
+ if (i.dataType === "date" && !l.includes(u))
1076
+ throw new Error(
1077
+ `Invalid level '${u}' in dimensional element '${p}'. Column '${n.name}.${i.name}' is only a date column, not a datetime column`
1078
+ );
1079
+ const d = $.timeOnly;
1080
+ if (i.dataType === "time" && !d.includes(u))
1081
+ throw new Error(
1082
+ `Invalid level '${u}' in dimensional element '${p}'. Column '${n.name}.${i.name}' is only a time column, not a date column`
1083
+ );
1084
+ a = u;
1085
+ }
1086
+ return Or({
1087
+ expression: i.expression,
1088
+ dataType: i.dataType,
1089
+ granularity: a,
1052
1090
  format: void 0,
1053
1091
  sort: void 0,
1054
- dataSource: r
1092
+ dataSource: t
1055
1093
  });
1056
1094
  }
1057
- function Vt(e, r, t) {
1058
- const { column: s, level: n } = Je(e, t);
1095
+ function Os(e, t, r) {
1096
+ const { column: s, level: n } = Se(e, r);
1059
1097
  if (n)
1060
1098
  throw new Error(
1061
- `Invalid DateDimension name format: "${e}". Expected format: "${F}TableName.ColumnName"`
1099
+ `Invalid DateDimension name format: '${e}'. Expected format: '${E}TableName.ColumnName'`
1062
1100
  );
1063
- if (!oe(s.dataType))
1101
+ if (!X(s.dataType))
1064
1102
  throw new Error(
1065
- `Invalid DateDimension name "${e}". Column "${s.name}" is not a datetime column (got ${s.dataType}).`
1103
+ `Invalid DateDimension name '${e}'. Column '${s.name}' is not a datetime column (got ${s.dataType}).`
1066
1104
  );
1067
- return tt({
1105
+ return Gr({
1068
1106
  name: s.name,
1069
1107
  expression: s.expression,
1070
- dataSource: r
1108
+ dataSource: t
1071
1109
  });
1072
1110
  }
1073
- function M(e, r) {
1074
- const t = e();
1075
- return t.success ? t.data : (r.push(...t.errors), null);
1076
- }
1077
- const _t = (e, r, t) => {
1078
- if (!r)
1079
- return { attribute: e };
1080
- const s = typeof r == "object" ? r.direction : r;
1081
- return $e(s) ? { attribute: e.sort(Ae(s)) } : {
1082
- attribute: e,
1083
- error: h(g({}, t), {
1084
- message: `Invalid sort type. Expected "sortAsc", "sortDesc", or "sortNone". Got: "${s}".`
1085
- })
1086
- };
1087
- }, Ut = (e, r, t, s) => {
1088
- const n = Q(e.column, r, t);
1089
- return _t(n, e.sortType, s);
1090
- }, Wt = (e, r, t, s) => typeof e == "string" ? { attribute: Q(e, r, t) } : It(e) ? Ut(e, r, t, s) : {
1091
- error: h(g({}, s), {
1092
- message: 'Invalid dimension item. Expected a string (composeCode) or object with "column" and optional "sortType".'
1111
+ const Ds = (e, t) => {
1112
+ if (!e) return;
1113
+ const r = typeof e == "object" ? e.direction : e;
1114
+ if (!se(r))
1115
+ return F(y({}, t), {
1116
+ message: `Invalid sort type. Expected 'sortAsc', 'sortDesc', or 'sortNone'. Got: '${r}'.`
1117
+ });
1118
+ }, Ms = (e, t, r, s) => {
1119
+ const n = Ds(e.sortType, s);
1120
+ if (n)
1121
+ return {
1122
+ attribute: H(e.column, t, r),
1123
+ style: {},
1124
+ error: n
1125
+ };
1126
+ const i = H(e.column, t, r), o = _(e, "column");
1127
+ return { attribute: i, style: o };
1128
+ }, Ns = (e, t, r, s) => typeof e == "string" ? { attribute: H(e, t, r) } : xs(e) ? Ms(e, t, r, s) : {
1129
+ error: F(y({}, s), {
1130
+ message: "Invalid dimension item. Expected a string (composeCode) or object with 'column' and optional 'sortType'."
1093
1131
  })
1094
- }, jt = (e) => {
1095
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
1096
- if (!r)
1132
+ }, qt = (e) => {
1133
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context;
1134
+ if (!t)
1097
1135
  return { success: !0, data: [] };
1098
- if (!Array.isArray(r))
1136
+ if (!Array.isArray(t))
1099
1137
  return {
1100
1138
  success: !1,
1101
1139
  errors: [
1102
1140
  {
1103
1141
  category: "dimensions",
1104
1142
  index: -1,
1105
- input: r,
1143
+ input: t,
1106
1144
  message: "Invalid dimensions JSON. Expected an array."
1107
1145
  }
1108
1146
  ]
1109
1147
  };
1110
- const n = [], o = [];
1111
- return r.forEach((i, a) => {
1148
+ const n = [], i = [];
1149
+ return t.forEach((o, a) => {
1112
1150
  const u = {
1113
1151
  category: "dimensions",
1114
1152
  index: a,
1115
- input: i
1153
+ input: o
1116
1154
  };
1117
1155
  try {
1118
- const c = Wt(i, t, s, u);
1156
+ const c = Ns(o, r, s, u);
1119
1157
  if (c.error) {
1120
- o.push(c.error);
1158
+ i.push(c.error);
1121
1159
  return;
1122
1160
  }
1123
- c.attribute && n.push(c.attribute);
1161
+ c.attribute && n.push(
1162
+ c.style !== void 0 ? { attribute: c.attribute, style: c.style } : { attribute: c.attribute }
1163
+ );
1124
1164
  } catch (c) {
1125
1165
  const p = c instanceof Error ? c.message : "Unknown error";
1126
- o.push(h(g({}, u), { message: p }));
1166
+ i.push(F(y({}, u), { message: p }));
1127
1167
  }
1128
- }), o.length > 0 ? { success: !1, errors: o } : { success: !0, data: n };
1168
+ }), i.length > 0 ? { success: !1, errors: i } : { success: !0, data: n };
1129
1169
  };
1130
- function de(e, r) {
1131
- const t = Reflect.get(e, r);
1132
- if (typeof t != "function")
1133
- throw new Error(`Function "${r}" not found or is not a function`);
1134
- return t;
1170
+ function Oe(e, t) {
1171
+ const r = Reflect.get(e, t);
1172
+ if (typeof r != "function")
1173
+ throw new Error(`Function '${t}' not found or is not a function`);
1174
+ return r;
1135
1175
  }
1136
- function Jt(e, r) {
1137
- const t = e.replace("measureFactory.", ""), n = de(_r, t)(...r);
1138
- if (!fe(n))
1139
- throw new Error(`Function "${e}" did not return a valid Measure`);
1176
+ function Rs(e, t) {
1177
+ const r = e.replace("measureFactory.", ""), n = Oe(Dr, r)(...t);
1178
+ if (!xe(n))
1179
+ throw new Error(`Function '${e}' did not return a valid Measure`);
1140
1180
  return n;
1141
1181
  }
1142
- function Kt(e, r) {
1143
- const t = e.replace("filterFactory.logic.", ""), n = de(Ur, t)(...r);
1144
- if (!U(n))
1145
- throw new Error(`Function "${e}" did not return a valid FilterRelations`);
1182
+ function vs(e, t) {
1183
+ const r = e.replace("filterFactory.logic.", ""), n = Oe(Mr, r)(...t);
1184
+ if (!Z(n))
1185
+ throw new Error(`Function '${e}' did not return a valid FilterRelations`);
1146
1186
  return n;
1147
1187
  }
1148
- function Gt(e, r) {
1188
+ function Is(e, t) {
1149
1189
  if (e.startsWith("filterFactory.logic."))
1150
- return Kt(e, r);
1151
- const t = e.replace("filterFactory.", ""), n = de(Wr, t)(...r);
1152
- if (!K(n) && !U(n))
1153
- throw new Error(`Function "${e}" did not return a valid Filter or FilterRelations`);
1190
+ return vs(e, t);
1191
+ const r = e.replace("filterFactory.", ""), n = Oe(Nr, r)(...t);
1192
+ if (!oe(n) && !Z(n))
1193
+ throw new Error(`Function '${e}' did not return a valid Filter or FilterRelations`);
1154
1194
  return n;
1155
1195
  }
1156
- function Qt(e, r) {
1196
+ function Ps(e, t) {
1157
1197
  const s = e.split(".")[0];
1158
1198
  if (s === "measureFactory")
1159
- return Jt(e, r);
1199
+ return Rs(e, t);
1160
1200
  if (s === "filterFactory")
1161
- return Gt(e, r);
1201
+ return Is(e, t);
1162
1202
  throw new Error(
1163
- `Unsupported factory: "${s}". Supported factories: measureFactory, filterFactory`
1203
+ `Unsupported factory: '${s}'. Supported factories: measureFactory, filterFactory`
1164
1204
  );
1165
1205
  }
1166
- const Yt = /\[(\w[\w.-]*)\]/g, Qe = /* @__PURE__ */ new Set([
1206
+ const f = (e, t, r, s) => y({ category: e, minArgs: t, maxArgs: r }, s), ks = /* @__PURE__ */ new Set([
1207
+ "CORREL",
1208
+ "COVARP",
1209
+ "COVAR",
1210
+ "EXPONDIST",
1211
+ "INTERCEPT",
1212
+ "LARGEST",
1213
+ "NORMDIST",
1214
+ "POISSONDIST",
1215
+ "SKEWP",
1216
+ "SKEW",
1217
+ "SLOPE",
1218
+ "TDIST",
1219
+ "COSH",
1220
+ "SINH",
1221
+ "TANH",
1222
+ "ORDERING",
1223
+ "RDOUBLE",
1224
+ "RINT"
1225
+ ]), te = {
1226
+ // ── X-diff (datetime difference operators) ──
1227
+ SDIFF: f("xdiff", 2, 2, {
1228
+ requiredDateLevel: $.Seconds,
1229
+ argType: "datetime"
1230
+ }),
1231
+ MNDIFF: f("xdiff", 2, 2, {
1232
+ requiredDateLevel: $.Minutes,
1233
+ argType: "datetime"
1234
+ }),
1235
+ HDIFF: f("xdiff", 2, 2, {
1236
+ requiredDateLevel: $.Hours,
1237
+ argType: "datetime"
1238
+ }),
1239
+ DDIFF: f("xdiff", 2, 2, {
1240
+ requiredDateLevel: $.Days,
1241
+ argType: "datetime"
1242
+ }),
1243
+ MDIFF: f("xdiff", 2, 2, {
1244
+ requiredDateLevel: $.Months,
1245
+ argType: "datetime"
1246
+ }),
1247
+ QDIFF: f("xdiff", 2, 2, {
1248
+ requiredDateLevel: $.Quarters,
1249
+ argType: "datetime"
1250
+ }),
1251
+ YDIFF: f("xdiff", 2, 2, {
1252
+ requiredDateLevel: $.Years,
1253
+ argType: "datetime"
1254
+ }),
1255
+ // ── Aggregation ──
1256
+ ANYVALUE: f("aggregative", 1, 1),
1257
+ SUM: f("aggregative", 1, 2),
1258
+ AVG: f("aggregative", 1, 2),
1259
+ MIN: f("aggregative", 1, 2),
1260
+ MAX: f("aggregative", 1, 2),
1261
+ COUNT: f("aggregative", 1, 2),
1262
+ DUPCOUNT: f("aggregative", 1, 1),
1263
+ COUNTDUPLICATES: f("aggregative", 1, 1),
1264
+ STDEV: f("aggregative", 1, 2),
1265
+ STDEVP: f("aggregative", 1, 2),
1266
+ VAR: f("aggregative", 1, 2),
1267
+ VARP: f("aggregative", 1, 2),
1268
+ MEDIAN: f("aggregative", 1, 2),
1269
+ QUARTILE: f("aggregative", 2, 3),
1270
+ PERCENTILE: f("aggregative", 2, 3),
1271
+ LOWERWHISKERMAX_IQR: f("aggregative", 1, 1),
1272
+ LOWERWHISKERMAX_STDEVP: f("aggregative", 1, 1),
1273
+ UPPERWHISKERMIN_IQR: f("aggregative", 1, 1),
1274
+ UPPERWHISKERMIN_STDEVP: f("aggregative", 1, 1),
1275
+ OUTLIERSCOUNT_IQR: f("aggregative", 1, 1),
1276
+ OUTLIERSCOUNT_STDEVP: f("aggregative", 1, 1),
1277
+ MODE: f("aggregative", 1, 1),
1278
+ NOAGGFUNCTION: f("aggregative", 1, 1),
1279
+ // ── Window ──
1280
+ RANK: f("window", 0, Number.POSITIVE_INFINITY),
1281
+ RSUM: f("window", 1, 2),
1282
+ RAVG: f("window", 1, 2),
1283
+ YTDSUM: f("window", 1, 1),
1284
+ QTDSUM: f("window", 1, 1),
1285
+ MTDSUM: f("window", 1, 1),
1286
+ WTDSUM: f("window", 1, 1),
1287
+ YTDAVG: f("window", 1, 1),
1288
+ QTDAVG: f("window", 1, 1),
1289
+ MTDAVG: f("window", 1, 1),
1290
+ WTDAVG: f("window", 1, 1),
1291
+ // ── String ──
1292
+ CONCAT: f("string", 2, Number.POSITIVE_INFINITY),
1293
+ LEFT: f("string", 2, 2),
1294
+ RIGHT: f("string", 2, 2),
1295
+ // ── Scalar / math ──
1296
+ ABS: f("scalar", 1, 1),
1297
+ ACOS: f("scalar", 1, 1),
1298
+ ASIN: f("scalar", 1, 1),
1299
+ ATAN: f("scalar", 1, 1),
1300
+ CEILING: f("scalar", 1, 1),
1301
+ CONTRIBUTION: f("scalar", 1, 1),
1302
+ COS: f("scalar", 1, 1),
1303
+ COT: f("scalar", 1, 1),
1304
+ DIFFPASTDAY: f("scalar", 1, 1),
1305
+ DIFFPASTMONTH: f("scalar", 1, 1),
1306
+ DIFFPASTPERIOD: f("scalar", 1, 1),
1307
+ DIFFPASTQUARTER: f("scalar", 1, 1),
1308
+ DIFFPASTWEEK: f("scalar", 1, 1),
1309
+ DIFFPASTYEAR: f("scalar", 1, 1),
1310
+ EXP: f("scalar", 1, 1),
1311
+ FLOOR: f("scalar", 1, 1),
1312
+ GROWTH: f("growth", 1, 1),
1313
+ GROWTHPASTMONTH: f("growth", 1, 1),
1314
+ GROWTHPASTQUARTER: f("growth", 1, 1),
1315
+ GROWTHPASTWEEK: f("growth", 1, 1),
1316
+ GROWTHPASTYEAR: f("growth", 1, 1),
1317
+ GROWTHRATE: f("growth", 1, 1),
1318
+ LN: f("scalar", 1, 1),
1319
+ LOG10: f("scalar", 1, 1),
1320
+ MINUS: f("scalar", 1, 1),
1321
+ MOD: f("scalar", 2, 2),
1322
+ QUOTIENT: f("scalar", 2, 2),
1323
+ PASTDAY: f("date", 1, 2),
1324
+ PASTMONTH: f("date", 1, 2),
1325
+ PASTPERIOD: f("date", 1, 2),
1326
+ PASTQUARTER: f("date", 1, 2),
1327
+ PASTWEEK: f("date", 1, 2),
1328
+ PASTYEAR: f("date", 1, 2),
1329
+ PERCENTILEDISCFORINTERNALUSEONLY: f("scalar", 1, 1),
1330
+ PERCENTILECONTFORINTERNALUSEONLY: f("scalar", 1, 1),
1331
+ POWER: f("scalar", 2, 2),
1332
+ ROUND: f("scalar", 2, 2),
1333
+ SIN: f("scalar", 1, 1),
1334
+ SQRT: f("scalar", 1, 1),
1335
+ TAN: f("scalar", 1, 1)
1336
+ }, Bs = Object.keys(te).filter(
1337
+ (e) => te[e].category === "xdiff"
1338
+ );
1339
+ function xt() {
1340
+ return Bs;
1341
+ }
1342
+ function $t(e) {
1343
+ const t = te[e.toUpperCase()];
1344
+ return t == null ? void 0 : t.requiredDateLevel;
1345
+ }
1346
+ function zs(e, t) {
1347
+ return e === t ? e === 1 ? "1 parameter" : `${e} parameters` : t === Number.POSITIVE_INFINITY ? e <= 1 ? "any number of parameters" : `at least ${e} parameters` : `${e} or ${t} parameters`;
1348
+ }
1349
+ function De(e, t) {
1350
+ const r = [];
1351
+ let s = "", n = 0, i = !1, o = null;
1352
+ for (let a = 0; a < e.length; a++) {
1353
+ const u = e[a], c = e[a + 1];
1354
+ if (i) {
1355
+ if (u !== o) {
1356
+ s += u;
1357
+ continue;
1358
+ }
1359
+ if (c === o) {
1360
+ s += u + c, a++;
1361
+ continue;
1362
+ }
1363
+ i = !1, o = null, s += u;
1364
+ continue;
1365
+ } else {
1366
+ if (u === "'" || u === '"') {
1367
+ i = !0, o = u, s += u;
1368
+ continue;
1369
+ }
1370
+ if ("([{".includes(u) && n++, ")]}".includes(u) && n--, u === t && n === 0) {
1371
+ r.push(s.trim()), s = "";
1372
+ continue;
1373
+ }
1374
+ }
1375
+ s += u;
1376
+ }
1377
+ return s.trim() && r.push(s.trim()), r;
1378
+ }
1379
+ function Ls(e, t) {
1380
+ let r = 0, s = !1, n = null;
1381
+ for (let i = 0; i < e.length; i++) {
1382
+ const o = e[i], a = e[i + 1];
1383
+ if (s) {
1384
+ if (o !== n) continue;
1385
+ if (a === n) {
1386
+ i++;
1387
+ continue;
1388
+ }
1389
+ s = !1, n = null;
1390
+ } else {
1391
+ if (o === "'" || o === '"') {
1392
+ s = !0, n = o;
1393
+ continue;
1394
+ }
1395
+ if ("([{".includes(o) && r++, ")]}".includes(o) && r--, o === t && r === 0) return i;
1396
+ }
1397
+ }
1398
+ return -1;
1399
+ }
1400
+ function Us(e, t) {
1401
+ if (e[t] !== "(") return -1;
1402
+ let r = 1, s = t + 1, n = !1, i = null;
1403
+ for (; s < e.length; ) {
1404
+ const o = e[s], a = e[s + 1];
1405
+ if (n) {
1406
+ if (o !== i) {
1407
+ s++;
1408
+ continue;
1409
+ }
1410
+ if (a === i) {
1411
+ s += 2;
1412
+ continue;
1413
+ }
1414
+ n = !1, i = null, s++;
1415
+ } else {
1416
+ if (o === "'" || o === '"') {
1417
+ n = !0, i = o, s++;
1418
+ continue;
1419
+ }
1420
+ if ("([{".includes(o) && r++, ")]}".includes(o) && --r === 0) return s;
1421
+ s++;
1422
+ }
1423
+ }
1424
+ return -1;
1425
+ }
1426
+ function _s(e) {
1427
+ return e.startsWith("'") && e.endsWith("'") || e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e;
1428
+ }
1429
+ function W(e) {
1430
+ if (!e || typeof e != "string")
1431
+ throw new Error(`Invalid composeCode: expected non-empty string, got ${typeof e}`);
1432
+ const t = e.trim();
1433
+ if (!t)
1434
+ throw new Error("Invalid composeCode: empty string");
1435
+ const r = t.match(/^([a-zA-Z_$][a-zA-Z0-9_.$]*)\s*\((.*)\)$/);
1436
+ if (!r)
1437
+ throw new Error(`Invalid composeCode format: expected function call, got '${t}'`);
1438
+ const s = r[1], n = r[2], i = St(n);
1439
+ return {
1440
+ function: s,
1441
+ args: i
1442
+ };
1443
+ }
1444
+ function St(e) {
1445
+ return e.trim() ? De(e, ",").map(Ot) : [];
1446
+ }
1447
+ function Ot(e) {
1448
+ if (!e)
1449
+ throw new Error("Cannot parse empty argument value");
1450
+ if (e === "null")
1451
+ return null;
1452
+ if (e === "undefined")
1453
+ return;
1454
+ if (e === "true")
1455
+ return !0;
1456
+ if (e === "false")
1457
+ return !1;
1458
+ if (e.match(/^-?\d+(\.\d+)?$/))
1459
+ return parseFloat(e);
1460
+ if (e.startsWith("'") && e.endsWith("'") || e.startsWith('"') && e.endsWith('"')) {
1461
+ const r = e[0];
1462
+ return e.slice(1, -1).replace(new RegExp(`${r}${r}`, "g"), r);
1463
+ }
1464
+ if (e.startsWith("[") && e.endsWith("]")) {
1465
+ const r = e.slice(1, -1).trim();
1466
+ if (!r)
1467
+ return [];
1468
+ const s = St(r);
1469
+ return s.every((n) => typeof n == "string"), s;
1470
+ }
1471
+ if (e.startsWith("{") && e.endsWith("}")) {
1472
+ const r = e.slice(1, -1).trim();
1473
+ return r ? Ws(r) : {};
1474
+ }
1475
+ return e.includes("(") && e.includes(")") ? W(e) : (e.startsWith("DM."), e);
1476
+ }
1477
+ function Vs(e) {
1478
+ const t = Ls(e, ":");
1479
+ if (t === -1)
1480
+ throw new Error(`Invalid object property: expected 'key: value', got '${e}'`);
1481
+ const r = _s(e.slice(0, t).trim()), s = Ot(e.slice(t + 1).trim());
1482
+ return [r, s];
1483
+ }
1484
+ function Ws(e) {
1485
+ if (!e.trim()) return {};
1486
+ const t = De(e, ",").map(Vs).filter(([, r]) => r !== null);
1487
+ return Object.fromEntries(t);
1488
+ }
1489
+ const js = /\[(\w[\w.-]*)\]/g, Dt = /* @__PURE__ */ new Set([
1167
1490
  // Universal – Aggregative (per Sisense doc: (A) only; Statistical CONTRIBUTION, PERCENTILE, etc. are non-aggregative)
1168
1491
  "AVG",
1169
1492
  "COUNT",
1170
1493
  "DUPCOUNT",
1171
- "LARGEST",
1172
1494
  "MAX",
1173
1495
  "MEDIAN",
1174
1496
  "MIN",
@@ -1182,236 +1504,395 @@ const Yt = /\[(\w[\w.-]*)\]/g, Qe = /* @__PURE__ */ new Set([
1182
1504
  "QTDAVG",
1183
1505
  "QTDSUM",
1184
1506
  "YTDAVG",
1185
- "YTDSUM",
1507
+ "YTDSUM"
1186
1508
  // RAVG, RSUM are non-aggregative per Sisense doc (Other Functions, not (A))
1187
- // Elasticube Aggregative
1188
- "CORREL",
1189
- "COVARP",
1190
- "COVAR",
1191
- "SKEWP",
1192
- "SKEW",
1193
- "SLOPE"
1194
- ]), Ht = new RegExp(
1195
- `\\b(${Array.from(Qe).join("|")})\\s*\\(`,
1509
+ // CORREL, COVAR*, SKEW*, SLOPE, LARGEST are unsupported in custom formulas (see UNSUPPORTED_FORMULA_FUNCTIONS).
1510
+ ]), Ks = new RegExp(
1511
+ `\\b(${Array.from(Dt).join("|")})\\s*\\(`,
1196
1512
  "i"
1197
1513
  );
1198
- function Zt(e) {
1199
- return E(e) ? !0 : typeof e == "string" && e.startsWith(F) ? !1 : e && typeof e == "object" && "kind" in e ? e.kind === "measure" : !0;
1514
+ function Mt(e) {
1515
+ return q(e) ? !0 : typeof e == "string" && e.startsWith(E) ? !1 : S(e) && "kind" in e ? e.kind === "measure" : !0;
1200
1516
  }
1201
- function Xt(e) {
1202
- const r = /\b(\w+)\s*\(/g, t = /* @__PURE__ */ new Set();
1517
+ function Gs(e) {
1518
+ const t = /\b(\w+)\s*\(/g, r = /* @__PURE__ */ new Set();
1203
1519
  let s;
1204
- for (; (s = r.exec(e)) !== null; ) {
1520
+ for (; (s = t.exec(e)) !== null; ) {
1205
1521
  const n = s[1];
1206
- Qe.has(n.toUpperCase()) || t.add(n);
1522
+ Dt.has(n.toUpperCase()) || r.add(n);
1207
1523
  }
1208
- return Array.from(t);
1524
+ return Array.from(r);
1209
1525
  }
1210
- function vt(e) {
1211
- return e.length === 1 ? `[${e[0]}]` : e.map((r) => `[${r}]`).join(", ");
1526
+ function Ys(e) {
1527
+ return e.length === 1 ? `[${e[0]}]` : e.map((t) => `[${t}]`).join(", ");
1212
1528
  }
1213
- function es(e) {
1529
+ function Js(e) {
1214
1530
  return e.length === 0 ? "" : e.length === 1 ? `${e[0]} is not an aggregative function. ` : `${e.join(", ")} are not aggregative functions. `;
1215
1531
  }
1216
- const B = (e) => e.startsWith("[") ? e : `[${e}]`, Ee = (e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e;
1217
- function rs(e, r, t = {}) {
1218
- const {
1219
- warnUnusedContext: s = !0,
1220
- errorOnUnusedContext: n = !0,
1221
- allowEmptyFormula: o = !1,
1222
- errorPrefix: i = "customFormula validation"
1223
- } = t, a = {
1224
- isValid: !0,
1225
- errors: [],
1226
- warnings: [],
1227
- references: [],
1228
- unusedContextKeys: []
1532
+ const j = (e) => e.startsWith("[") ? e : `[${e}]`, Nt = (e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e;
1533
+ function Rt(e, t) {
1534
+ if (t.length === 0) return [];
1535
+ const r = t.map((n) => n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join("|"), s = new RegExp(
1536
+ `\\b(${r})\\s*\\(\\s*\\[([^\\]]+)\\]\\s*,\\s*\\[([^\\]]+)\\]\\s*\\)`,
1537
+ "gi"
1538
+ );
1539
+ return [...e.matchAll(s)].map((n) => ({
1540
+ functionName: n[1].toUpperCase(),
1541
+ ref1: n[2].trim(),
1542
+ ref2: n[3].trim()
1543
+ }));
1544
+ }
1545
+ function Hs(e, t, r) {
1546
+ var o, a, u;
1547
+ const s = Object.keys(t), n = ((o = r.errorPrefix) != null ? o : "customFormula validation").trim(), i = n === "" ? "" : n.endsWith(" ") ? n : `${n} `;
1548
+ return {
1549
+ formula: e,
1550
+ context: t,
1551
+ contextKeys: s,
1552
+ canonicalContextKeys: new Set(s.map(j)),
1553
+ errorPrefix: i,
1554
+ warnUnusedContext: (a = r.warnUnusedContext) != null ? a : !0,
1555
+ errorOnUnusedContext: (u = r.errorOnUnusedContext) != null ? u : !0,
1556
+ schemaIndex: r.schemaIndex,
1557
+ result: { isValid: !0, errors: [], warnings: [], references: [], unusedContextKeys: [] }
1229
1558
  };
1230
- if (!e || e.trim().length === 0)
1231
- return o || (a.errors.push(`${i}args[1]: Formula cannot be empty`), a.isValid = !1), a;
1232
- const u = /\b\w+\s*\[/gi, c = e.match(u);
1233
- if (c) {
1234
- const f = c[0].replace(/\s*\[.*$/, "");
1235
- a.errors.push(
1236
- `${i}args[1]: Invalid syntax: '${f}' - operator cannot be used before bracket reference without parentheses`
1237
- ), a.isValid = !1;
1559
+ }
1560
+ function M(e, t) {
1561
+ e.result.errors.push(t), e.result.isValid = !1;
1562
+ }
1563
+ const Qs = /* @__PURE__ */ new Set(["CASE", "WHEN", "THEN", "ELSE", "END", "AND", "OR"]);
1564
+ function Xs(e) {
1565
+ const t = /\b(\w+)\s*\[/gi, r = [...e.formula.matchAll(t)].find(
1566
+ (s) => !Qs.has(s[1].toUpperCase())
1567
+ );
1568
+ r && M(
1569
+ e,
1570
+ `${e.errorPrefix}args[1]: Invalid syntax: '${r[1]}' - operator cannot be used before bracket reference without parentheses`
1571
+ );
1572
+ }
1573
+ function Zs(e, t) {
1574
+ const r = e[t];
1575
+ let s = t + 1;
1576
+ for (; s < e.length; ) {
1577
+ const n = e[s], i = e[s + 1];
1578
+ if (n !== r) {
1579
+ s++;
1580
+ continue;
1581
+ }
1582
+ if (i === r) {
1583
+ s += 2;
1584
+ continue;
1585
+ }
1586
+ return s + 1;
1587
+ }
1588
+ return e.length;
1589
+ }
1590
+ function en(e) {
1591
+ return De(e, ",").filter((t) => t.trim().length > 0).length;
1592
+ }
1593
+ function tn(e, t, r, s) {
1594
+ for (; t < e.length && /\s/.test(e[t]); )
1595
+ t++;
1596
+ if (e[t] !== "(")
1597
+ return t;
1598
+ const n = t, i = Us(e, n);
1599
+ if (i === -1)
1600
+ return n + 1;
1601
+ const o = e.slice(n + 1, i);
1602
+ return s.push({ name: r.toUpperCase(), argCount: en(o) }), s.push(...vt(o)), i + 1;
1603
+ }
1604
+ function vt(e) {
1605
+ const t = [];
1606
+ let r = 0;
1607
+ for (; r < e.length; ) {
1608
+ const s = e[r];
1609
+ if (s === "'" || s === '"') {
1610
+ r = Zs(e, r);
1611
+ continue;
1612
+ }
1613
+ if (/[A-Za-z_]/.test(s)) {
1614
+ const n = r;
1615
+ for (r++; r < e.length && /[A-Za-z0-9_]/.test(e[r]); )
1616
+ r++;
1617
+ const i = e.slice(n, r);
1618
+ r = tn(e, r, i, t);
1619
+ continue;
1620
+ }
1621
+ r++;
1238
1622
  }
1239
- a.references = [
1623
+ return t;
1624
+ }
1625
+ function rn(e) {
1626
+ const t = vt(e.formula), r = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set();
1627
+ for (const { name: n, argCount: i } of t) {
1628
+ if (ks.has(n)) {
1629
+ r.has(n) || (r.add(n), M(
1630
+ e,
1631
+ `${e.errorPrefix}args[1]: Function ${n} is not supported in custom formulas`
1632
+ ));
1633
+ continue;
1634
+ }
1635
+ const o = te[n];
1636
+ if (o && (i < o.minArgs || i > o.maxArgs) && !s.has(n)) {
1637
+ s.add(n);
1638
+ const a = zs(o.minArgs, o.maxArgs);
1639
+ M(e, `${e.errorPrefix}args[1]: Function ${n} accepts ${a}`);
1640
+ }
1641
+ }
1642
+ }
1643
+ function sn(e) {
1644
+ return [
1240
1645
  ...new Set(
1241
- [...e.matchAll(new RegExp(Yt.source, "g"))].map((f) => f[1])
1646
+ [...e.matchAll(new RegExp(js.source, "g"))].map((t) => t[1])
1242
1647
  )
1243
1648
  ];
1244
- const p = Object.keys(r);
1245
- if (a.references.length === 0)
1246
- return a.warnings.push(
1247
- `${i}args[1]: No bracket references found in formula - ensure this is intentional`
1248
- ), a;
1249
- if (p.length === 0)
1250
- return a.errors.push(
1251
- `${i}args[2]: Context cannot be empty - custom formulas require context definitions`
1252
- ), a.isValid = !1, a;
1253
- const m = new Set(p.map(B)), y = a.references.filter(
1254
- (f) => !m.has(B(f))
1649
+ }
1650
+ function nn(e) {
1651
+ const t = e.result.references.filter(
1652
+ (n) => !e.canonicalContextKeys.has(j(n))
1255
1653
  );
1256
- if (y.length > 0) {
1257
- a.isValid = !1;
1258
- const f = p.map((d) => `[${Ee(d)}]`).join(", ");
1259
- y.length === 1 ? a.errors.push(
1260
- `${i}args[1]: Reference [${y[0]}] not found in context. Available keys: ${f}`
1261
- ) : a.errors.push(
1262
- `${i}args[1]: References [${y.join(
1263
- "], ["
1264
- )}] not found in context. Available keys: ${f}`
1654
+ if (t.length === 0) return;
1655
+ const r = e.contextKeys.map((n) => `[${Nt(n)}]`).join(", "), s = t.length === 1 ? `Reference [${t[0]}]` : `References [${t.join("], [")}]`;
1656
+ M(
1657
+ e,
1658
+ `${e.errorPrefix}args[1]: ${s} not found in context. Available keys: ${r}`
1659
+ );
1660
+ }
1661
+ function on(e) {
1662
+ if (Ks.test(e.formula)) return;
1663
+ const t = e.result.references.filter((r) => {
1664
+ var n;
1665
+ const s = (n = e.context[j(r)]) != null ? n : e.context[r];
1666
+ return s !== void 0 && !Mt(s);
1667
+ });
1668
+ t.length !== 0 && M(
1669
+ e,
1670
+ `${e.errorPrefix}args[1]: ${Js(
1671
+ Gs(e.formula)
1672
+ )}Bracket reference(s) ${Ys(
1673
+ t
1674
+ )} point to raw attributes and must be wrapped in an aggregative function (e.g. SUM, AVG)`
1675
+ );
1676
+ }
1677
+ function an(e) {
1678
+ if (!e.warnUnusedContext && !e.errorOnUnusedContext || e.contextKeys.length === 0) return;
1679
+ const t = new Set(e.result.references.map(j)), r = e.contextKeys.filter((i) => !t.has(j(i)));
1680
+ if (e.result.unusedContextKeys = r, r.length === 0) return;
1681
+ const s = r.map((i) => `[${Nt(i)}]`).join(", "), n = `${e.errorPrefix}args[2]: Context keys ${s} are defined but not used in formula`;
1682
+ e.errorOnUnusedContext ? M(e, n) : e.warnUnusedContext && e.result.warnings.push(n);
1683
+ }
1684
+ function Je(e, t, r, s) {
1685
+ var o;
1686
+ const n = (o = s.context[j(e)]) != null ? o : s.context[e];
1687
+ if (n === void 0) return;
1688
+ if (!(typeof n == "string" && n.startsWith(E))) {
1689
+ Mt(n) && M(
1690
+ s,
1691
+ `${s.errorPrefix}args[1]: ${t.functionName} requires datetime dimension attributes. Reference [${e}] points to a measure; use an attribute (e.g. ${E}Table.Column.Level).`
1265
1692
  );
1693
+ return;
1266
1694
  }
1267
- if (!Ht.test(e)) {
1268
- const f = a.references.filter((d) => {
1269
- var $;
1270
- const w = ($ = r[B(d)]) != null ? $ : r[d];
1271
- return w !== void 0 && !Zt(w);
1272
- });
1273
- f.length > 0 && (a.errors.push(
1274
- `${i}args[1]: ${es(
1275
- Xt(e)
1276
- )}Bracket reference(s) ${vt(
1277
- f
1278
- )} point to raw attributes and must be wrapped in an aggregative function (e.g. SUM, AVG)`
1279
- ), a.isValid = !1);
1280
- }
1281
- if ((s || n) && p.length > 0) {
1282
- const f = new Set(a.references.map(B)), d = p.filter((w) => !f.has(B(w)));
1283
- if (a.unusedContextKeys = d, d.length > 0) {
1284
- const w = d.map((D) => `[${Ee(D)}]`).join(", "), $ = `${i}args[2]: Context keys ${w} are defined but not used in formula`;
1285
- n ? (a.errors.push($), a.isValid = !1) : s && a.warnings.push($);
1695
+ if (s.schemaIndex)
1696
+ try {
1697
+ const a = Se(n, s.schemaIndex);
1698
+ X(a.column.dataType) ? r && a.level && a.level !== r && M(
1699
+ s,
1700
+ `${s.errorPrefix}args[1]: ${t.functionName} expects date level '${r}'. Reference [${e}] has level '${a.level}'.`
1701
+ ) : M(
1702
+ s,
1703
+ `${s.errorPrefix}args[1]: ${t.functionName} requires datetime dimensions. Reference [${e}] resolves to non-datetime column '${a.column.name}'.`
1704
+ );
1705
+ } catch (a) {
1706
+ const u = a instanceof Error ? a.message : "Unknown error";
1707
+ M(s, `${s.errorPrefix}args[1]: ${t.functionName} reference [${e}]: ${u}`);
1286
1708
  }
1287
- }
1288
- return a;
1289
1709
  }
1290
- function ts(e, r, t = {}) {
1291
- const s = rs(e, r, t);
1710
+ function un(e) {
1711
+ const t = xt(), r = Rt(e.formula, t);
1712
+ for (const s of r) {
1713
+ const n = $t(s.functionName);
1714
+ Je(s.ref1, s, n, e), Je(s.ref2, s, n, e);
1715
+ }
1716
+ }
1717
+ function cn(e, t, r = {}) {
1718
+ var n;
1719
+ const s = Hs(e, t, r);
1720
+ return !e || e.trim().length === 0 ? ((n = r.allowEmptyFormula) != null && n || M(s, `${s.errorPrefix}args[1]: Formula cannot be empty`), s.result) : (Xs(s), rn(s), s.result.references = sn(e), s.result.references.length === 0 ? (s.result.warnings.push(
1721
+ `${s.errorPrefix}args[1]: No bracket references found in formula - ensure this is intentional`
1722
+ ), s.result) : s.contextKeys.length === 0 ? (M(
1723
+ s,
1724
+ `${s.errorPrefix}args[2]: Context cannot be empty - custom formulas require context definitions`
1725
+ ), s.result) : (nn(s), on(s), an(s), un(s), s.result));
1726
+ }
1727
+ function ln(e, t, r = {}) {
1728
+ const s = cn(e, t, r);
1292
1729
  if (!s.isValid)
1293
1730
  throw new Error(s.errors.join("; "));
1294
1731
  s.warnings.length > 0 && console.warn("Formula validation warnings:", s.warnings.join("; "));
1295
1732
  }
1296
- function ss(e, r) {
1733
+ function fn(e, t) {
1297
1734
  if (e.length < 3 || e.length > 5)
1298
1735
  throw new Error(
1299
- `${r.pathPrefix}Expected 3, 4, or 5 arguments for customFormula (title, formula, context, format?, description?)`
1736
+ `${t.pathPrefix}Expected 3, 4, or 5 arguments for customFormula (title, formula, context, format?, description?)`
1737
+ );
1738
+ const r = e[1];
1739
+ if (typeof r != "string")
1740
+ throw new Error(
1741
+ `${t.pathPrefix}args[1]: Expected formula string, got ${typeof r}`
1742
+ );
1743
+ const s = r, n = e[2];
1744
+ if (!S(n))
1745
+ throw new Error(
1746
+ `${t.pathPrefix}args[2]: Expected context object, got ${n === null ? "null" : typeof n}`
1300
1747
  );
1301
- const t = e[1], s = e[2];
1302
- ts(t, s, {
1303
- errorPrefix: `${r.pathPrefix}`,
1748
+ const i = n;
1749
+ ln(s, i, {
1750
+ errorPrefix: `${t.pathPrefix}`,
1304
1751
  errorOnUnusedContext: !0,
1305
1752
  // Strict validation: all context keys must be used
1306
- allowEmptyFormula: !1
1753
+ allowEmptyFormula: !1,
1307
1754
  // Custom formulas must have content
1755
+ schemaIndex: t.schemaIndex
1308
1756
  });
1309
- const n = {};
1310
- for (const [o, i] of Object.entries(s)) {
1311
- const a = `args[2].${o}`;
1312
- if (E(i))
1313
- n[`${o}`] = C({
1314
- data: i,
1757
+ const o = dn(s), a = {};
1758
+ for (const [u, c] of Object.entries(i)) {
1759
+ const p = `args[2].${u}`;
1760
+ if (q(c))
1761
+ a[`${u}`] = D({
1762
+ data: c,
1315
1763
  context: {
1316
- dataSource: r.dataSource,
1317
- schemaIndex: r.schemaIndex,
1318
- pathPrefix: a
1764
+ dataSource: t.dataSource,
1765
+ schemaIndex: t.schemaIndex,
1766
+ pathPrefix: p
1319
1767
  }
1320
1768
  });
1321
- else if (typeof i == "string" && i.startsWith(F))
1769
+ else if (typeof c == "string" && c.startsWith(E)) {
1770
+ const l = u.startsWith("[") && u.endsWith("]") ? u.slice(1, -1) : u, d = o[l];
1322
1771
  try {
1323
- n[`${o}`] = Q(
1324
- i,
1325
- r.dataSource,
1326
- r.schemaIndex
1772
+ a[`${u}`] = H(
1773
+ c,
1774
+ t.dataSource,
1775
+ t.schemaIndex,
1776
+ d !== void 0 ? { inferredDateLevel: d } : void 0
1327
1777
  );
1328
- } catch (u) {
1329
- const c = u instanceof Error ? u.message : "Unknown error";
1330
- throw new Error(`${a}: ${c}`);
1778
+ } catch (b) {
1779
+ const g = b instanceof Error ? b.message : "Unknown error";
1780
+ throw new Error(`${p}: ${g}`);
1331
1781
  }
1332
- else if (i && typeof i == "object" && "kind" in i)
1333
- n[`${o}`] = i;
1782
+ } else if (c && typeof c == "object" && "kind" in c)
1783
+ a[`${u}`] = c;
1334
1784
  else
1335
1785
  throw new Error(
1336
- `${a}: Invalid context value for key '${o}'. Expected a function call or attribute reference (${F}...), but got: ${typeof i}`
1786
+ `${p}: Invalid context value for key '${u}'. Expected a function call or attribute reference (${E}...), but got: ${typeof c}`
1337
1787
  );
1338
1788
  }
1339
- e[2] = n;
1789
+ e[2] = a;
1340
1790
  }
1341
- function me(e, r) {
1342
- const t = e[0];
1343
- if (!t || typeof t != "object" || !("type" in t))
1344
- throw new Error(`${r.pathPrefix}args[0]: Expected attribute as first argument`);
1345
- return t;
1791
+ function dn(e) {
1792
+ const t = xt(), r = Rt(e, t), s = {};
1793
+ for (const n of r) {
1794
+ const i = $t(n.functionName);
1795
+ if (i !== void 0)
1796
+ for (const o of [n.ref1, n.ref2]) {
1797
+ const a = s[o];
1798
+ if (a !== void 0 && a !== i)
1799
+ throw new Error(
1800
+ `Reference [${o}] is used in xdiff functions with conflicting date levels ('${a}' and '${i}'). Specify the date level in the context (e.g. DM.Table.Column.${i}).`
1801
+ );
1802
+ s[o] = i;
1803
+ }
1804
+ }
1805
+ return s;
1806
+ }
1807
+ function It(e) {
1808
+ return e.type === U.TextAttribute;
1809
+ }
1810
+ function Pt(e) {
1811
+ return e.type === U.NumericAttribute;
1812
+ }
1813
+ function mn(e) {
1814
+ return e.type === U.DateLevel;
1815
+ }
1816
+ function pn(e) {
1817
+ return It(e) || Pt(e);
1346
1818
  }
1347
- function Ce(e, r) {
1348
- const t = me(e, r);
1349
- if (!Lt(t))
1819
+ function ae(e) {
1820
+ return e.type === U.TextAttribute ? "text" : e.type === U.NumericAttribute ? "numeric" : e.type === U.DateLevel ? "date/datetime" : "unknown";
1821
+ }
1822
+ function Me(e, t) {
1823
+ const r = e[0];
1824
+ if (!r || typeof r != "object" || !("type" in r))
1825
+ throw new Error(`${t.pathPrefix}args[0]: Expected attribute as first argument`);
1826
+ return r;
1827
+ }
1828
+ function He(e, t) {
1829
+ const r = Me(e, t);
1830
+ if (!pn(r))
1350
1831
  throw new Error(
1351
- `${r.pathPrefix}args[0]: Attribute must be string or numeric type, got ${G(
1352
- t
1832
+ `${t.pathPrefix}args[0]: Attribute must be string or numeric type, got ${ae(
1833
+ r
1353
1834
  )} attribute`
1354
1835
  );
1355
1836
  }
1356
- function T(e, r) {
1357
- const t = me(e, r);
1358
- if (!Ge(t))
1837
+ function P(e, t) {
1838
+ const r = Me(e, t);
1839
+ if (!Pt(r))
1359
1840
  throw new Error(
1360
- `${r.pathPrefix}args[0]: Attribute must be numeric type, got ${G(
1361
- t
1841
+ `${t.pathPrefix}args[0]: Attribute must be numeric type, got ${ae(
1842
+ r
1362
1843
  )} attribute`
1363
1844
  );
1364
1845
  }
1365
- function N(e, r) {
1366
- const t = me(e, r);
1367
- if (!Ke(t))
1846
+ function k(e, t) {
1847
+ const r = Me(e, t);
1848
+ if (!It(r))
1368
1849
  throw new Error(
1369
- `${r.pathPrefix}args[0]: Attribute must be string type, got ${G(
1370
- t
1850
+ `${t.pathPrefix}args[0]: Attribute must be string type, got ${ae(
1851
+ r
1371
1852
  )} attribute`
1372
1853
  );
1373
1854
  }
1374
- function ns(e, r) {
1375
- const t = e[0];
1376
- if (!t || typeof t != "object" || !("attribute" in t))
1377
- throw new Error(`${r.pathPrefix}args[0]: Expected filter as first argument`);
1378
- return t;
1855
+ function gn(e, t) {
1856
+ const r = e[0];
1857
+ if (!r || typeof r != "object" || !("attribute" in r))
1858
+ throw new Error(`${t.pathPrefix}args[0]: Expected filter as first argument`);
1859
+ return r;
1379
1860
  }
1380
- function is(e, r) {
1381
- const t = ns(e, r);
1382
- if (!ne(t))
1861
+ function yn(e, t) {
1862
+ const r = gn(e, t);
1863
+ if (!Fe(r))
1383
1864
  throw new Error(
1384
- `${r.pathPrefix}args[0]: exclude filter only accepts members filter, got ${t.__serializable || "unknown"} filter`
1865
+ `${t.pathPrefix}args[0]: exclude filter only accepts members filter, got ${r.__serializable || "unknown"} filter`
1385
1866
  );
1386
1867
  }
1387
- const os = {
1388
- "measureFactory.customFormula": ss,
1868
+ const hn = {
1869
+ "measureFactory.customFormula": fn,
1389
1870
  // String | Number filters
1390
- "filterFactory.equals": Ce,
1391
- "filterFactory.doesntEqual": Ce,
1871
+ "filterFactory.equals": He,
1872
+ "filterFactory.doesntEqual": He,
1392
1873
  // Numeric filters
1393
- "filterFactory.greaterThan": T,
1394
- "filterFactory.greaterThanOrEqual": T,
1395
- "filterFactory.lessThan": T,
1396
- "filterFactory.lessThanOrEqual": T,
1397
- "filterFactory.between": T,
1398
- "filterFactory.betweenNotEqual": T,
1399
- "filterFactory.numeric": T,
1874
+ "filterFactory.greaterThan": P,
1875
+ "filterFactory.greaterThanOrEqual": P,
1876
+ "filterFactory.lessThan": P,
1877
+ "filterFactory.lessThanOrEqual": P,
1878
+ "filterFactory.between": P,
1879
+ "filterFactory.betweenNotEqual": P,
1880
+ "filterFactory.numeric": P,
1400
1881
  // String filters
1401
- "filterFactory.contains": N,
1402
- "filterFactory.doesntContain": N,
1403
- "filterFactory.startsWith": N,
1404
- "filterFactory.doesntStartWith": N,
1405
- "filterFactory.endsWith": N,
1406
- "filterFactory.doesntEndWith": N,
1407
- "filterFactory.like": N,
1882
+ "filterFactory.contains": k,
1883
+ "filterFactory.doesntContain": k,
1884
+ "filterFactory.startsWith": k,
1885
+ "filterFactory.doesntStartWith": k,
1886
+ "filterFactory.endsWith": k,
1887
+ "filterFactory.doesntEndWith": k,
1888
+ "filterFactory.like": k,
1408
1889
  // Exclude filter
1409
- "filterFactory.exclude": is
1890
+ "filterFactory.exclude": yn
1410
1891
  };
1411
- function as(e) {
1412
- return os[`${e}`];
1892
+ function bn(e) {
1893
+ return hn[`${e}`];
1413
1894
  }
1414
- const us = {
1895
+ const kt = {
1415
1896
  // ==================== MEASURE FACTORY FUNCTIONS ====================
1416
1897
  // Basic aggregations
1417
1898
  "measureFactory.sum": [
@@ -1938,656 +2419,610 @@ const us = {
1938
2419
  { type: "FilterRelationsNode", required: !0 }
1939
2420
  ]
1940
2421
  };
1941
- function pe(e) {
1942
- return us[`${e}`];
2422
+ function Ne(e) {
2423
+ return kt[`${e}`];
1943
2424
  }
1944
- function cs(e) {
1945
- const r = pe(e);
1946
- return r ? r.filter((t) => t.required).length : 0;
2425
+ function An(e) {
2426
+ const t = Ne(e);
2427
+ return t ? t.filter((r) => r.required).length : 0;
1947
2428
  }
1948
- function ls(e) {
1949
- const r = pe(e);
1950
- return r ? r.length : 0;
2429
+ function Fn(e) {
2430
+ const t = Ne(e);
2431
+ return t ? t.length : 0;
1951
2432
  }
1952
- function fs(e) {
2433
+ function wn(e) {
1953
2434
  if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}/.test(e))
1954
2435
  return !1;
1955
- const t = Date.parse(e);
1956
- if (isNaN(t) || e.length < 10)
2436
+ const r = Date.parse(e);
2437
+ if (isNaN(r) || e.length < 10)
1957
2438
  return !1;
1958
2439
  const s = new Date(e);
1959
2440
  return !isNaN(s.getTime());
1960
2441
  }
1961
- function Z(e, r, t, s) {
1962
- if (e.startsWith(F))
2442
+ function de(e, t, r, s) {
2443
+ if (e.startsWith(E))
1963
2444
  try {
1964
- return Q(e, r, t);
2445
+ return H(e, t, r);
1965
2446
  } catch (n) {
1966
- const o = n instanceof Error ? n.message : "Unknown error";
1967
- throw new Error(`${s}: ${o}`);
2447
+ const i = n instanceof Error ? n.message : "Unknown error";
2448
+ throw new Error(`${s}: ${i}`);
1968
2449
  }
1969
2450
  throw new Error(
1970
- `${s}: Invalid attribute "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`
2451
+ `${s}: Invalid attribute '${e}'. Expected format: '${E}TableName.ColumnName[.Level]'`
1971
2452
  );
1972
2453
  }
1973
- function ds(e, r, t, s) {
1974
- if (e.startsWith(F))
2454
+ function En(e, t, r, s) {
2455
+ if (e.startsWith(E))
1975
2456
  try {
1976
- return Vt(e, r, t);
2457
+ return Os(e, t, r);
1977
2458
  } catch (n) {
1978
- const o = n instanceof Error ? n.message : "Unknown error";
1979
- throw new Error(`${s}: ${o}`);
2459
+ const i = n instanceof Error ? n.message : "Unknown error";
2460
+ throw new Error(`${s}: ${i}`);
1980
2461
  }
1981
2462
  throw new Error(
1982
- `${s}: Invalid date dimension string "${e}". Expected format: "${F}TableName.ColumnName"`
2463
+ `${s}: Invalid date dimension string '${e}'. Expected format: '${E}TableName.ColumnName'`
1983
2464
  );
1984
2465
  }
1985
- function ms(e) {
1986
- const r = e.data, { argSchema: t, dataSource: s, schemaIndex: n, pathPrefix: o } = e.context, i = o;
1987
- if (r === void 0) {
1988
- if (t.required)
1989
- throw new Error(`${i}: Required argument is missing (expected ${t.type})`);
2466
+ function Cn(e) {
2467
+ const t = e.data, { argSchema: r, dataSource: s, schemaIndex: n, pathPrefix: i } = e.context, o = i;
2468
+ if (t === void 0) {
2469
+ if (r.required)
2470
+ throw new Error(`${o}: Required argument is missing (expected ${r.type})`);
1990
2471
  return;
1991
2472
  }
1992
- if (!(r === null && !t.required))
1993
- switch (t.type) {
2473
+ if (!(t === null && !r.required))
2474
+ switch (r.type) {
1994
2475
  case "string":
1995
- if (typeof r != "string")
1996
- throw new Error(`${i}: Expected string, got ${typeof r}`);
1997
- return r;
2476
+ if (typeof t != "string")
2477
+ throw new Error(`${o}: Expected string, got ${typeof t}`);
2478
+ return t;
1998
2479
  case "number":
1999
- if (typeof r != "number")
2000
- throw new Error(`${i}: Expected number, got ${typeof r}`);
2001
- return r;
2480
+ if (typeof t != "number")
2481
+ throw new Error(`${o}: Expected number, got ${typeof t}`);
2482
+ return t;
2002
2483
  case "boolean":
2003
- if (typeof r != "boolean")
2004
- throw new Error(`${i}: Expected boolean, got ${typeof r}`);
2005
- return r;
2484
+ if (typeof t != "boolean")
2485
+ throw new Error(`${o}: Expected boolean, got ${typeof t}`);
2486
+ return t;
2006
2487
  case "string[]":
2007
- if (!Array.isArray(r))
2488
+ if (!Array.isArray(t))
2008
2489
  throw new Error(
2009
- `${i}: Expected array of strings, got ${typeof r}. Example: ["value1", "value2"]`
2490
+ `${o}: Expected array of strings, got ${typeof t}. Example: ['value1', 'value2']`
2010
2491
  );
2011
- if (!r.every((a) => typeof a == "string"))
2492
+ if (!t.every((a) => typeof a == "string"))
2012
2493
  throw new Error(
2013
- `${i}: Expected array of strings, but contains non-string values`
2494
+ `${o}: Expected array of strings, but contains non-string values`
2014
2495
  );
2015
- return r;
2496
+ return t;
2016
2497
  case "number[]":
2017
- if (!Array.isArray(r))
2498
+ if (!Array.isArray(t))
2018
2499
  throw new Error(
2019
- `${i}: Expected array of numbers, got ${typeof r}. Example: [10, 20]`
2500
+ `${o}: Expected array of numbers, got ${typeof t}. Example: [10, 20]`
2020
2501
  );
2021
- if (!r.every((a) => typeof a == "number"))
2502
+ if (!t.every((a) => typeof a == "number"))
2022
2503
  throw new Error(
2023
- `${i}: Expected array of numbers, but contains non-number values`
2504
+ `${o}: Expected array of numbers, but contains non-number values`
2024
2505
  );
2025
- return r;
2506
+ return t;
2026
2507
  case "Attribute":
2027
- if (typeof r != "string")
2508
+ if (typeof t != "string")
2028
2509
  throw new Error(
2029
- `${i}: Expected attribute string, got ${typeof r}. Example: "DM.Commerce.Revenue"`
2510
+ `${o}: Expected attribute string, got ${typeof t}. Example: 'DM.Commerce.Revenue'`
2030
2511
  );
2031
- return Z(r, s, n, i);
2512
+ return de(t, s, n, o);
2032
2513
  case "Attribute[]":
2033
- if (!Array.isArray(r))
2514
+ if (!Array.isArray(t))
2034
2515
  throw new Error(
2035
- `${i}: Expected array of attributes, got ${typeof r}. Example: ["DM.Commerce.AgeRange"]`
2516
+ `${o}: Expected array of attributes, got ${typeof t}. Example: ['DM.Commerce.AgeRange']`
2036
2517
  );
2037
- return r.map((a, u) => {
2518
+ return t.map((a, u) => {
2038
2519
  if (typeof a != "string")
2039
- throw new Error(`${i}[${u}]: Expected attribute string, got ${typeof a}`);
2040
- return Z(a, s, n, `${i}[${u}]`);
2520
+ throw new Error(`${o}[${u}]: Expected attribute string, got ${typeof a}`);
2521
+ return de(a, s, n, `${o}[${u}]`);
2041
2522
  });
2042
2523
  case "Measure":
2043
2524
  case "BaseMeasure":
2044
- if (!E(r))
2525
+ if (!q(t))
2045
2526
  throw new Error(
2046
- `${i}: Expected measure function call, got ${typeof r}. Example: {"function": "measureFactory.sum", "args": ["DM.Commerce.Revenue"]}`
2527
+ `${o}: Expected measure function call, got ${typeof t}. Example: {'function': 'measureFactory.sum', 'args': ['DM.Commerce.Revenue']}`
2047
2528
  );
2048
- return C({
2049
- data: r,
2050
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
2529
+ return D({
2530
+ data: t,
2531
+ context: { dataSource: s, schemaIndex: n, pathPrefix: o }
2051
2532
  });
2052
2533
  case "Measure[]":
2053
- if (!Array.isArray(r))
2534
+ if (!Array.isArray(t))
2054
2535
  throw new Error(
2055
- `${i}: Expected array of measure function calls, got ${typeof r}`
2536
+ `${o}: Expected array of measure function calls, got ${typeof t}`
2056
2537
  );
2057
- return r.map((a, u) => {
2058
- if (!E(a))
2538
+ return t.map((a, u) => {
2539
+ if (!q(a))
2059
2540
  throw new Error(
2060
- `${i}[${u}]: Expected measure function call, got ${typeof a}`
2541
+ `${o}[${u}]: Expected measure function call, got ${typeof a}`
2061
2542
  );
2062
- return C({
2543
+ return D({
2063
2544
  data: a,
2064
- context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
2545
+ context: { dataSource: s, schemaIndex: n, pathPrefix: `${o}[${u}]` }
2065
2546
  });
2066
2547
  });
2067
2548
  case "Filter":
2068
- if (!E(r))
2549
+ if (!q(t))
2069
2550
  throw new Error(
2070
- `${i}: Expected filter function call, got ${typeof r}. Example: {"function": "filterFactory.contains", "args": ["DM.Brand.Brand", "Apple"]}`
2551
+ `${o}: Expected filter function call, got ${typeof t}. Example: {'function': 'filterFactory.contains', 'args': ['DM.Brand.Brand', 'Apple']}`
2071
2552
  );
2072
- return C({
2073
- data: r,
2074
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
2553
+ return D({
2554
+ data: t,
2555
+ context: { dataSource: s, schemaIndex: n, pathPrefix: o }
2075
2556
  });
2076
2557
  case "Filter[]":
2077
- if (!Array.isArray(r))
2558
+ if (!Array.isArray(t))
2078
2559
  throw new Error(
2079
- `${i}: Expected array of filter function calls, got ${typeof r}`
2560
+ `${o}: Expected array of filter function calls, got ${typeof t}`
2080
2561
  );
2081
- return r.map((a, u) => {
2082
- if (!E(a))
2562
+ return t.map((a, u) => {
2563
+ if (!q(a))
2083
2564
  throw new Error(
2084
- `${i}[${u}]: Expected filter function call, got ${typeof a}`
2565
+ `${o}[${u}]: Expected filter function call, got ${typeof a}`
2085
2566
  );
2086
- return C({
2567
+ return D({
2087
2568
  data: a,
2088
- context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
2569
+ context: { dataSource: s, schemaIndex: n, pathPrefix: `${o}[${u}]` }
2089
2570
  });
2090
2571
  });
2091
2572
  case "FilterRelationsNode":
2092
- if (Array.isArray(r))
2093
- return r.map((a, u) => {
2094
- if (!E(a))
2573
+ if (Array.isArray(t))
2574
+ return t.map((a, u) => {
2575
+ if (!q(a))
2095
2576
  throw new Error(
2096
- `${i}[${u}]: Expected filter function call, got ${typeof a}`
2577
+ `${o}[${u}]: Expected filter function call, got ${typeof a}`
2097
2578
  );
2098
- return C({
2579
+ return D({
2099
2580
  data: a,
2100
- context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
2581
+ context: { dataSource: s, schemaIndex: n, pathPrefix: `${o}[${u}]` }
2101
2582
  });
2102
2583
  });
2103
- if (E(r))
2104
- return C({
2105
- data: r,
2106
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
2584
+ if (q(t))
2585
+ return D({
2586
+ data: t,
2587
+ context: { dataSource: s, schemaIndex: n, pathPrefix: o }
2107
2588
  });
2108
2589
  throw new Error(
2109
- `${i}: Expected filter function call or array of filters, got ${typeof r}`
2590
+ `${o}: Expected filter function call or array of filters, got ${typeof t}`
2110
2591
  );
2111
2592
  case "DateDimension":
2112
- if (typeof r != "string")
2593
+ if (typeof t != "string")
2113
2594
  throw new Error(
2114
- `${i}: Expected date dimension string, got ${typeof r}. Example: "DM.Commerce.Date"`
2595
+ `${o}: Expected date dimension string, got ${typeof t}. Example: 'DM.Commerce.Date'`
2115
2596
  );
2116
- return ds(r, s, n, i);
2597
+ return En(t, s, n, o);
2117
2598
  case "LevelAttribute": {
2118
- if (typeof r != "string")
2599
+ if (typeof t != "string")
2119
2600
  throw new Error(
2120
- `${i}: Expected date attribute string, got ${typeof r}. Example: "DM.Commerce.Date.Years"`
2601
+ `${o}: Expected date attribute string, got ${typeof t}. Example: 'DM.Commerce.Date.Years'`
2121
2602
  );
2122
- const a = Z(
2123
- r,
2603
+ const a = de(
2604
+ t,
2124
2605
  s,
2125
2606
  n,
2126
- i
2607
+ o
2127
2608
  );
2128
- if (!kt(a))
2609
+ if (!mn(a))
2129
2610
  throw new Error(
2130
- `${i}: Attribute must be date/datetime type, got ${G(
2611
+ `${o}: Attribute must be date/datetime type, got ${ae(
2131
2612
  a
2132
2613
  )} attribute`
2133
2614
  );
2134
2615
  return a;
2135
2616
  }
2136
2617
  case "Measure | number":
2137
- if (typeof r == "number")
2138
- return r;
2139
- if (E(r))
2140
- return C({
2141
- data: r,
2142
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
2618
+ if (typeof t == "number")
2619
+ return t;
2620
+ if (q(t))
2621
+ return D({
2622
+ data: t,
2623
+ context: { dataSource: s, schemaIndex: n, pathPrefix: o }
2143
2624
  });
2144
2625
  throw new Error(
2145
- `${i}: Expected measure function call or number, got ${typeof r}`
2626
+ `${o}: Expected measure function call or number, got ${typeof t}`
2146
2627
  );
2147
2628
  case "Date | string":
2148
- if (typeof r == "string") {
2149
- if (fs(r))
2150
- return r;
2629
+ if (typeof t == "string") {
2630
+ if (wn(t))
2631
+ return t;
2151
2632
  throw new Error(
2152
- `${i}: Expected valid ISO date string or Date object, got invalid date string "${r}"`
2633
+ `${o}: Expected valid ISO date string or Date object, got invalid date string '${t}'`
2153
2634
  );
2154
2635
  } else {
2155
- if (r instanceof Date)
2156
- return r;
2636
+ if (t instanceof Date)
2637
+ return t;
2157
2638
  throw new Error(
2158
- `${i}: Expected date string or Date object, got ${typeof r}`
2639
+ `${o}: Expected date string or Date object, got ${typeof t}`
2159
2640
  );
2160
2641
  }
2161
2642
  case "string | number":
2162
- if (typeof r == "string" || typeof r == "number")
2163
- return r;
2164
- throw new Error(`${i}: Expected string or number, got ${typeof r}`);
2643
+ if (typeof t == "string" || typeof t == "number")
2644
+ return t;
2645
+ throw new Error(`${o}: Expected string or number, got ${typeof t}`);
2165
2646
  case "BaseFilterConfig":
2166
2647
  case "MembersFilterConfig":
2167
2648
  case "CustomFormulaContext":
2168
2649
  case "any":
2169
- if (r == null && t.required)
2170
- throw new Error(`${i}: Required argument is null/undefined`);
2171
- return r;
2650
+ if (t == null && r.required)
2651
+ throw new Error(`${o}: Required argument is null/undefined`);
2652
+ return t;
2172
2653
  default:
2173
- return r;
2654
+ return t;
2174
2655
  }
2175
2656
  }
2176
- function C(e) {
2177
- const { data: r } = e, { dataSource: t, schemaIndex: s, pathPrefix: n } = e.context, { function: o, args: i } = r, a = n ? `${n}.` : "", u = pe(o);
2178
- if (!u)
2179
- throw new Error(`${a}function: Unknown function "${o}"`);
2180
- const c = cs(o), p = ls(o);
2181
- if (i.length < c)
2657
+ function D(e) {
2658
+ const { data: t } = e, { dataSource: r, schemaIndex: s, pathPrefix: n } = e.context, { function: i, args: o } = t, a = n ? `${n}.` : "", u = Ne(i);
2659
+ if (!u) {
2660
+ const g = Object.keys(kt), m = R(i, g, (C) => C), A = m && m.distance <= x ? ` Did you mean '${m.best}'?` : "";
2661
+ throw new Error(
2662
+ `${a}function: Unknown function '${i}'.${A}`
2663
+ );
2664
+ }
2665
+ const c = An(i), p = Fn(i);
2666
+ if (o.length < c)
2182
2667
  throw new Error(
2183
- `${a}function: Expected at least ${c} arguments, got ${i.length}`
2668
+ `${a}function: Expected at least ${c} arguments, got ${o.length}`
2184
2669
  );
2185
- if (i.length > p)
2670
+ if (o.length > p)
2186
2671
  throw new Error(
2187
- `${a}function: Expected at most ${p} arguments, got ${i.length}`
2672
+ `${a}function: Expected at most ${p} arguments, got ${o.length}`
2188
2673
  );
2189
- const m = [], y = [];
2190
- for (let f = 0; f < Math.max(i.length, u.length); f++) {
2191
- const d = u[`${f}`], w = i[`${f}`], $ = a ? `${a}args[${f}]` : `args[${f}]`;
2192
- if (w === void 0) {
2193
- d != null && d.required && y.push(`${$}: Missing required argument (expected ${d.type})`);
2674
+ const l = [], d = [];
2675
+ for (let g = 0; g < Math.max(o.length, u.length); g++) {
2676
+ const m = u[`${g}`], A = o[`${g}`], C = a ? `${a}args[${g}]` : `args[${g}]`;
2677
+ if (A === void 0) {
2678
+ m != null && m.required && d.push(`${C}: Missing required argument (expected ${m.type})`);
2194
2679
  continue;
2195
2680
  }
2196
- if (!d) {
2197
- y.push(`${$}: Unexpected argument`);
2681
+ if (!m) {
2682
+ d.push(`${C}: Unexpected argument`);
2198
2683
  continue;
2199
2684
  }
2200
2685
  try {
2201
- const D = ms({
2202
- data: w,
2686
+ const N = Cn({
2687
+ data: A,
2203
2688
  context: {
2204
- dataSource: t,
2689
+ dataSource: r,
2205
2690
  schemaIndex: s,
2206
- pathPrefix: $,
2207
- argSchema: d
2691
+ pathPrefix: C,
2692
+ argSchema: m
2208
2693
  }
2209
2694
  });
2210
- m.push(D);
2211
- } catch (D) {
2212
- const ve = D instanceof Error ? D.message : "Unknown error";
2213
- y.push(ve);
2695
+ l.push(N);
2696
+ } catch (N) {
2697
+ const ue = N instanceof Error ? N.message : "Unknown error";
2698
+ d.push(ue);
2214
2699
  }
2215
2700
  }
2216
- if (y.length > 0) {
2217
- const f = y.join("; ");
2218
- throw new Error(f);
2701
+ if (d.length > 0) {
2702
+ const g = d.join("; ");
2703
+ throw new Error(g);
2219
2704
  }
2220
- const x = as(o);
2221
- if (x)
2705
+ const b = bn(i);
2706
+ if (b)
2222
2707
  try {
2223
- x(m, {
2224
- dataSource: t,
2708
+ b(l, {
2709
+ dataSource: r,
2225
2710
  schemaIndex: s,
2226
2711
  pathPrefix: a
2227
2712
  });
2228
- } catch (f) {
2229
- const d = f instanceof Error ? f.message : "Unknown validation error";
2230
- throw new Error(d);
2713
+ } catch (g) {
2714
+ const m = g instanceof Error ? g.message : "Unknown validation error";
2715
+ throw new Error(m);
2231
2716
  }
2232
- return Qt(o, m);
2717
+ return Ps(i, l);
2233
2718
  }
2234
- function Ye(e) {
2235
- const { attribute: r, config: t } = e;
2236
- if (ne(e) && jr(r)) {
2237
- const { granularity: s } = r, n = e.members.map((a) => s === "Years" && !isNaN(Number(a)) ? `${a}-01-01T00:00:00` : a), o = Jr(t), i = Object.keys(o).length === 0 ? void 0 : o;
2238
- return Kr(r, n, i);
2719
+ function Bt(e) {
2720
+ const { attribute: t, config: r } = e;
2721
+ if (Fe(e) && Rr(t)) {
2722
+ const { granularity: s } = t, n = e.members.map((a) => s === "Years" && !isNaN(Number(a)) ? `${a}-01-01T00:00:00` : a), i = vr(r), o = Object.keys(i).length === 0 ? void 0 : i;
2723
+ return Ir(t, n, o);
2239
2724
  }
2240
2725
  return e;
2241
2726
  }
2242
- function ps(e) {
2243
- let r = [];
2244
- for (const t of e)
2245
- U(t) ? r = he(t, r) : r = he([Ye(t)], r);
2246
- return r != null ? r : [];
2727
+ function Tn(e) {
2728
+ let t = [];
2729
+ for (const r of e)
2730
+ Z(r) ? t = Ve(r, t) : t = Ve([Bt(r)], t);
2731
+ return t != null ? t : [];
2247
2732
  }
2248
- const ys = (e) => {
2249
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], o = [];
2250
- return r.forEach((i, a) => {
2733
+ const qn = (e) => {
2734
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context, n = [], i = [];
2735
+ return t.forEach((o, a) => {
2251
2736
  const u = {
2252
2737
  category: "filters",
2253
2738
  index: a,
2254
- input: i
2739
+ input: o
2255
2740
  };
2256
2741
  try {
2257
- const c = C({
2258
- data: i,
2259
- context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
2742
+ const c = D({
2743
+ data: o,
2744
+ context: { dataSource: r, schemaIndex: s, pathPrefix: "" }
2260
2745
  });
2261
- !U(c) && !K(c) ? o.push(h(g({}, u), { message: "Invalid filter JSON" })) : n.push(c);
2746
+ !Z(c) && !oe(c) ? i.push(F(y({}, u), { message: "Invalid filter JSON" })) : n.push(c);
2262
2747
  } catch (c) {
2263
2748
  const p = c instanceof Error ? c.message : "Unknown error";
2264
- o.push(h(g({}, u), { message: p }));
2749
+ i.push(F(y({}, u), { message: p }));
2265
2750
  }
2266
- }), o.length > 0 ? { success: !1, errors: o } : { success: !0, data: ps(n) };
2267
- }, gs = (e) => {
2268
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2269
- return r ? je(r) ? ys({
2270
- data: r,
2271
- context: { dataSource: t, schemaIndex: s }
2751
+ }), i.length > 0 ? { success: !1, errors: i } : { success: !0, data: Tn(n) };
2752
+ }, Re = (e) => {
2753
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context;
2754
+ return t ? Ct(t) ? qn({
2755
+ data: t,
2756
+ context: { dataSource: r, schemaIndex: s }
2272
2757
  }) : {
2273
2758
  success: !1,
2274
2759
  errors: [
2275
2760
  {
2276
2761
  category: "filters",
2277
2762
  index: -1,
2278
- input: r,
2279
- message: 'Invalid filters JSON. Expected an array of function calls with "function" and "args" properties.'
2763
+ input: t,
2764
+ message: "Invalid filters JSON. Expected an array of function calls with 'function' and 'args' properties."
2280
2765
  }
2281
2766
  ]
2282
2767
  } : { success: !0, data: [] };
2283
- }, hs = (e) => {
2284
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], o = [];
2285
- return r.forEach((i, a) => {
2768
+ }, xn = (e) => {
2769
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context, n = [], i = [];
2770
+ return t.forEach((o, a) => {
2286
2771
  const u = {
2287
2772
  category: "highlights",
2288
2773
  index: a,
2289
- input: i
2774
+ input: o
2290
2775
  };
2291
2776
  try {
2292
- const c = C({
2293
- data: i,
2294
- context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
2777
+ const c = D({
2778
+ data: o,
2779
+ context: { dataSource: r, schemaIndex: s, pathPrefix: "" }
2295
2780
  });
2296
- K(c) ? n.push(Ye(c)) : o.push(h(g({}, u), { message: "Invalid filter JSON" }));
2781
+ oe(c) ? n.push(Bt(c)) : i.push(F(y({}, u), { message: "Invalid filter JSON" }));
2297
2782
  } catch (c) {
2298
2783
  const p = c instanceof Error ? c.message : "Unknown error";
2299
- o.push(h(g({}, u), { message: p }));
2784
+ i.push(F(y({}, u), { message: p }));
2300
2785
  }
2301
- }), o.length > 0 ? { success: !1, errors: o } : { success: !0, data: n };
2302
- }, bs = (e) => {
2303
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2304
- return r ? je(r) ? hs({
2305
- data: r,
2306
- context: { dataSource: t, schemaIndex: s }
2786
+ }), i.length > 0 ? { success: !1, errors: i } : { success: !0, data: n };
2787
+ }, ve = (e) => {
2788
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context;
2789
+ return t ? Ct(t) ? xn({
2790
+ data: t,
2791
+ context: { dataSource: r, schemaIndex: s }
2307
2792
  }) : {
2308
2793
  success: !1,
2309
2794
  errors: [
2310
2795
  {
2311
2796
  category: "highlights",
2312
2797
  index: -1,
2313
- input: r,
2314
- message: 'Invalid highlights JSON. Expected an array of function calls with "function" and "args" properties.'
2798
+ input: t,
2799
+ message: "Invalid highlights JSON. Expected an array of function calls with 'function' and 'args' properties."
2315
2800
  }
2316
2801
  ]
2317
2802
  } : { success: !0, data: [] };
2318
- }, Fs = (e, r, t) => {
2319
- const { dataSource: s, schemaIndex: n } = r;
2803
+ }, $n = (e, t) => {
2804
+ if (e && !se(e))
2805
+ return F(y({}, t), {
2806
+ message: `Invalid sort type. Expected 'sortAsc', 'sortDesc', or 'sortNone'. Got: '${e}'.`
2807
+ });
2808
+ }, Sn = (e, t, r) => {
2809
+ const { dataSource: s, schemaIndex: n } = t;
2320
2810
  try {
2321
- const o = C({
2811
+ const i = D({
2322
2812
  data: e,
2323
2813
  context: { dataSource: s, schemaIndex: n, pathPrefix: "" }
2324
2814
  });
2325
- return fe(o) ? { success: !0, data: o } : {
2815
+ return xe(i) ? { success: !0, data: i } : {
2326
2816
  success: !1,
2327
- errors: [h(g({}, t), { message: "Invalid measure JSON" })]
2817
+ errors: [F(y({}, r), { message: "Invalid measure JSON" })]
2328
2818
  };
2329
- } catch (o) {
2330
- const i = o instanceof Error ? o.message : "Unknown error";
2819
+ } catch (i) {
2820
+ const o = i instanceof Error ? i.message : "Unknown error";
2331
2821
  return {
2332
2822
  success: !1,
2333
- errors: [h(g({}, t), { message: i })]
2823
+ errors: [F(y({}, r), { message: o })]
2334
2824
  };
2335
2825
  }
2336
- }, ws = (e, r, t) => r ? $e(r) ? { measure: e.sort(Ae(r)) } : {
2337
- measure: e,
2338
- error: h(g({}, t), {
2339
- message: `Invalid sort type. Expected "sortAsc", "sortDesc", or "sortNone". Got: "${r}".`
2340
- })
2341
- } : { measure: e }, qs = (e, r, t, s) => {
2342
- const n = C({
2826
+ }, On = (e, t, r, s) => {
2827
+ const n = D({
2343
2828
  data: e.column,
2344
- context: { dataSource: r, schemaIndex: t, pathPrefix: "" }
2829
+ context: { dataSource: t, schemaIndex: r, pathPrefix: "" }
2345
2830
  });
2346
- return fe(n) ? ws(n, e.sortType, s) : { error: h(g({}, s), { message: "Invalid measure JSON" }) };
2347
- }, Es = (e, r, t, s) => {
2348
- if (zt(e))
2349
- return qs(e, r, t, s);
2350
- if (E(e)) {
2351
- const n = Fs(
2831
+ if (!xe(n))
2832
+ return {
2833
+ style: {},
2834
+ error: F(y({}, s), { message: "Invalid measure JSON" })
2835
+ };
2836
+ const i = $n(e.sortType, s);
2837
+ if (i) {
2838
+ const a = _(e, "column");
2839
+ return { measure: n, style: a, error: i };
2840
+ }
2841
+ const o = _(e, "column");
2842
+ return { measure: n, style: o };
2843
+ }, Dn = (e, t, r, s) => {
2844
+ if ($s(e))
2845
+ return On(e, t, r, s);
2846
+ if (q(e)) {
2847
+ const n = Sn(
2352
2848
  e,
2353
- { dataSource: r, schemaIndex: t },
2849
+ { dataSource: t, schemaIndex: r },
2354
2850
  s
2355
2851
  );
2356
2852
  return n.success ? { measure: n.data } : { error: n.errors[0] };
2357
2853
  }
2358
2854
  return {
2359
- error: h(g({}, s), {
2360
- message: 'Invalid measure item. Expected a function call (function/args) or object with "column" and optional "sortType".'
2855
+ error: F(y({}, s), {
2856
+ message: "Invalid measure item. Expected a function call (function/args) or object with 'column' and optional 'sortType'."
2361
2857
  })
2362
2858
  };
2363
- }, Cs = (e) => {
2364
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2365
- if (!r)
2859
+ }, zt = (e) => {
2860
+ const { data: t } = e, { dataSource: r, schemaIndex: s } = e.context;
2861
+ if (!t)
2366
2862
  return { success: !0, data: [] };
2367
- if (!Array.isArray(r))
2863
+ if (!Array.isArray(t))
2368
2864
  return {
2369
2865
  success: !1,
2370
2866
  errors: [
2371
2867
  {
2372
2868
  category: "measures",
2373
2869
  index: -1,
2374
- input: r,
2870
+ input: t,
2375
2871
  message: "Invalid measures JSON. Expected an array."
2376
2872
  }
2377
2873
  ]
2378
2874
  };
2379
- const n = [], o = [];
2380
- return r.forEach((i, a) => {
2875
+ const n = [], i = [];
2876
+ return t.forEach((o, a) => {
2381
2877
  const u = {
2382
2878
  category: "measures",
2383
2879
  index: a,
2384
- input: i
2880
+ input: o
2385
2881
  };
2386
2882
  try {
2387
- const c = Es(i, t, s, u);
2883
+ const c = Dn(o, r, s, u);
2388
2884
  if (c.error) {
2389
- o.push(c.error);
2885
+ i.push(c.error);
2390
2886
  return;
2391
2887
  }
2392
- c.measure && n.push(c.measure);
2888
+ c.measure && n.push(
2889
+ c.style !== void 0 ? { measure: c.measure, style: c.style } : { measure: c.measure }
2890
+ );
2393
2891
  } catch (c) {
2394
2892
  const p = c instanceof Error ? c.message : "Unknown error";
2395
- o.push(h(g({}, u), { message: p }));
2893
+ i.push(F(y({}, u), { message: p }));
2396
2894
  }
2397
- }), o.length > 0 ? { success: !1, errors: o } : { success: !0, data: n };
2398
- }, ks = (e) => {
2399
- const { data: r } = e, { dataSource: t, tables: s } = e.context, n = Bt(s), o = [], i = M(
2400
- () => jt({
2401
- data: r.dimensions || [],
2402
- context: { dataSource: t, schemaIndex: n }
2403
- }),
2404
- o
2405
- ), a = M(
2406
- () => Cs({
2407
- data: r.measures || [],
2408
- context: { dataSource: t, schemaIndex: n }
2409
- }),
2410
- o
2411
- ), u = M(
2412
- () => gs({
2413
- data: r.filters || [],
2414
- context: { dataSource: t, schemaIndex: n }
2895
+ }), i.length > 0 ? { success: !1, errors: i } : { success: !0, data: n };
2896
+ };
2897
+ function Q(e) {
2898
+ return typeof e == "string" ? e.replace(/\[\[([^\]]+)\]\]/g, "$1") : Array.isArray(e) ? e.map(Q) : e !== null && typeof e == "object" ? Object.fromEntries(
2899
+ Object.entries(e).map(([t, r]) => [t, Q(r)])
2900
+ ) : e;
2901
+ }
2902
+ function w(e, t, r) {
2903
+ const s = e();
2904
+ if (!s.success) {
2905
+ const n = r ? s.errors.map(r) : s.errors;
2906
+ return t.push(...n), null;
2907
+ }
2908
+ return s.data;
2909
+ }
2910
+ const Ie = "$trend", Pe = "$forecast";
2911
+ function Mn(e) {
2912
+ return e.map(({ attribute: t, style: r }) => {
2913
+ const s = r == null ? void 0 : r.sortType;
2914
+ if (!s) return t;
2915
+ const n = typeof s == "object" ? s.direction : s;
2916
+ return se(n) ? t.sort(ne(n)) : t;
2917
+ });
2918
+ }
2919
+ function Nn(e) {
2920
+ var t, r;
2921
+ return (r = (t = e.composeCode) == null ? void 0 : t.includes("measureFactory.trend")) != null ? r : !1;
2922
+ }
2923
+ function Rn(e) {
2924
+ var t, r;
2925
+ return (r = (t = e.composeCode) == null ? void 0 : t.includes("measureFactory.forecast")) != null ? r : !1;
2926
+ }
2927
+ function vn(e) {
2928
+ var r, s;
2929
+ const t = [];
2930
+ for (const { measure: n, style: i } of e) {
2931
+ const o = i == null ? void 0 : i.sortType, a = o && se(o) ? n.sort(ne(o)) : n;
2932
+ t.push(a), i != null && i.trend && !Nn(n) && t.push(
2933
+ Pr(n, `${Ie}_${(r = n.name) != null ? r : "Measure"}`, i.trend)
2934
+ ), i != null && i.forecast && !Rn(n) && t.push(
2935
+ kr(
2936
+ n,
2937
+ `${Pe}_${(s = n.name) != null ? s : "Measure"}`,
2938
+ i.forecast
2939
+ )
2940
+ );
2941
+ }
2942
+ return t;
2943
+ }
2944
+ const ii = (e) => {
2945
+ const { data: t } = e, { dataSource: r, tables: s } = e.context, n = $e(s), i = [], o = w(
2946
+ () => qt({
2947
+ data: t.dimensions || [],
2948
+ context: { dataSource: r, schemaIndex: n }
2949
+ }),
2950
+ i
2951
+ ), a = w(
2952
+ () => zt({
2953
+ data: t.measures || [],
2954
+ context: { dataSource: r, schemaIndex: n }
2415
2955
  }),
2416
- o
2956
+ i
2957
+ ), u = w(
2958
+ () => Re({
2959
+ data: t.filters || [],
2960
+ context: { dataSource: r, schemaIndex: n }
2961
+ }),
2962
+ i
2417
2963
  );
2418
2964
  let c = null;
2419
- return r.highlights && (c = M(
2420
- () => bs({
2421
- data: r.highlights || [],
2422
- context: { dataSource: t, schemaIndex: n }
2965
+ return t.highlights && (c = w(
2966
+ () => ve({
2967
+ data: t.highlights || [],
2968
+ context: { dataSource: r, schemaIndex: n }
2423
2969
  }),
2424
- o
2425
- )), o.length > 0 ? {
2970
+ i
2971
+ )), i.length > 0 ? {
2426
2972
  success: !1,
2427
- errors: o
2973
+ errors: i
2428
2974
  } : {
2429
2975
  success: !0,
2430
- data: g({
2431
- dataSource: Gr(t),
2432
- dimensions: i || [],
2433
- measures: a || [],
2976
+ data: y({
2977
+ dataSource: we(r),
2978
+ dimensions: o ? Mn(o) : [],
2979
+ measures: a ? vn(a) : [],
2434
2980
  filters: u || []
2435
2981
  }, c && { highlights: c })
2436
2982
  };
2437
2983
  };
2438
- function $s(e) {
2439
- const r = [], t = [];
2984
+ function Qe(e) {
2985
+ return typeof e == "object" && e !== null && "column" in e && e.column !== void 0;
2986
+ }
2987
+ function ke(e) {
2988
+ const t = [], r = [];
2440
2989
  return e.forEach((s, n) => {
2441
- const o = () => typeof s.toJSON == "function" ? s.toJSON() : s;
2442
- if (!s.composeCode) {
2443
- t.push({
2990
+ var l, d, b;
2991
+ const i = Qe(s) ? s.column : s, o = Qe(s) ? s : void 0, a = () => typeof i.toJSON == "function" ? i.toJSON() : i;
2992
+ if (!i.composeCode) {
2993
+ r.push({
2444
2994
  category: "dimensions",
2445
2995
  index: n,
2446
- input: o(),
2447
- message: `Dimension at index ${n} (${s.name || "unnamed"}) is missing composeCode`
2996
+ input: a(),
2997
+ message: `Dimension at index ${n} (${i.name || "unnamed"}) is missing composeCode`
2448
2998
  });
2449
2999
  return;
2450
3000
  }
2451
- if (!s.composeCode.startsWith(F)) {
2452
- t.push({
3001
+ if (!i.composeCode.startsWith(E)) {
3002
+ r.push({
2453
3003
  category: "dimensions",
2454
3004
  index: n,
2455
- input: o(),
2456
- message: `Expected composeCode to start with "${F}" for dimension at index ${n} (${s.name || "unnamed"}). Got: "${s.composeCode}"`
3005
+ input: a(),
3006
+ message: `Expected composeCode to start with '${E}' for dimension at index ${n} (${i.name || "unnamed"}). Got: '${i.composeCode}'`
2457
3007
  });
2458
3008
  return;
2459
3009
  }
2460
- const i = s.getSort();
2461
- if (i !== void 0 && i !== ie.None) {
2462
- const a = {
2463
- column: s.composeCode,
2464
- sortType: xe(i)
2465
- };
2466
- r.push(a);
3010
+ const u = (b = o != null && o.sortType ? ne(o.sortType) : void 0) != null ? b : ((l = i.getSort) == null ? void 0 : l.call(i)) !== void 0 && ((d = i.getSort) == null ? void 0 : d.call(i)) !== B.None ? i.getSort() : void 0, c = o ? _(o, "column") : {};
3011
+ if (u !== void 0 && u !== B.None || o && Object.keys(c).length > 0) {
3012
+ const g = y(y({
3013
+ column: i.composeCode
3014
+ }, u !== void 0 && u !== B.None && { sortType: it(u) }), c);
3015
+ t.push(g);
2467
3016
  } else
2468
- r.push(s.composeCode);
2469
- }), t.length > 0 ? { success: !1, errors: t } : { success: !0, data: r };
2470
- }
2471
- function He(e, r) {
2472
- const t = [];
2473
- let s = "", n = 0, o = !1, i = null;
2474
- for (let a = 0; a < e.length; a++) {
2475
- const u = e[a], c = e[a + 1];
2476
- if (o) {
2477
- if (u !== i) {
2478
- s += u;
2479
- continue;
2480
- }
2481
- if (c === i) {
2482
- s += u + c, a++;
2483
- continue;
2484
- }
2485
- o = !1, i = null, s += u;
2486
- continue;
2487
- } else {
2488
- if (u === "'" || u === '"') {
2489
- o = !0, i = u, s += u;
2490
- continue;
2491
- }
2492
- if ("([{".includes(u) && n++, ")]}".includes(u) && n--, u === r && n === 0) {
2493
- t.push(s.trim()), s = "";
2494
- continue;
2495
- }
2496
- }
2497
- s += u;
2498
- }
2499
- return s.trim() && t.push(s.trim()), t;
2500
- }
2501
- function As(e, r) {
2502
- let t = 0, s = !1, n = null;
2503
- for (let o = 0; o < e.length; o++) {
2504
- const i = e[o], a = e[o + 1];
2505
- if (s) {
2506
- if (i !== n) continue;
2507
- if (a === n) {
2508
- o++;
2509
- continue;
2510
- }
2511
- s = !1, n = null;
2512
- } else {
2513
- if (i === "'" || i === '"') {
2514
- s = !0, n = i;
2515
- continue;
2516
- }
2517
- if ("([{".includes(i) && t++, ")]}".includes(i) && t--, i === r && t === 0) return o;
2518
- }
2519
- }
2520
- return -1;
2521
- }
2522
- function xs(e) {
2523
- return e.startsWith("'") && e.endsWith("'") || e.startsWith('"') && e.endsWith('"') ? e.slice(1, -1) : e;
2524
- }
2525
- function _(e) {
2526
- if (!e || typeof e != "string")
2527
- throw new Error(`Invalid composeCode: expected non-empty string, got ${typeof e}`);
2528
- const r = e.trim();
2529
- if (!r)
2530
- throw new Error("Invalid composeCode: empty string");
2531
- const t = r.match(/^([a-zA-Z_$][a-zA-Z0-9_.$]*)\s*\((.*)\)$/);
2532
- if (!t)
2533
- throw new Error(`Invalid composeCode format: expected function call, got "${r}"`);
2534
- const s = t[1], n = t[2], o = Ze(n);
2535
- return {
2536
- function: s,
2537
- args: o
2538
- };
2539
- }
2540
- function Ze(e) {
2541
- return e.trim() ? He(e, ",").map(Xe) : [];
2542
- }
2543
- function Xe(e) {
2544
- if (!e)
2545
- throw new Error("Cannot parse empty argument value");
2546
- if (e === "null")
2547
- return null;
2548
- if (e === "undefined")
2549
- return;
2550
- if (e === "true")
2551
- return !0;
2552
- if (e === "false")
2553
- return !1;
2554
- if (e.match(/^-?\d+(\.\d+)?$/))
2555
- return parseFloat(e);
2556
- if (e.startsWith("'") && e.endsWith("'") || e.startsWith('"') && e.endsWith('"')) {
2557
- const t = e[0];
2558
- return e.slice(1, -1).replace(new RegExp(`${t}${t}`, "g"), t);
2559
- }
2560
- if (e.startsWith("[") && e.endsWith("]")) {
2561
- const t = e.slice(1, -1).trim();
2562
- if (!t)
2563
- return [];
2564
- const s = Ze(t);
2565
- return s.every((n) => typeof n == "string"), s;
2566
- }
2567
- if (e.startsWith("{") && e.endsWith("}")) {
2568
- const t = e.slice(1, -1).trim();
2569
- return t ? Ms(t) : {};
2570
- }
2571
- return e.includes("(") && e.includes(")") ? _(e) : (e.startsWith("DM."), e);
2572
- }
2573
- function Ds(e) {
2574
- const r = As(e, ":");
2575
- if (r === -1)
2576
- throw new Error(`Invalid object property: expected "key: value", got "${e}"`);
2577
- const t = xs(e.slice(0, r).trim()), s = Xe(e.slice(r + 1).trim());
2578
- return [t, s];
2579
- }
2580
- function Ms(e) {
2581
- if (!e.trim()) return {};
2582
- const r = He(e, ",").map(Ds).filter(([, t]) => t !== null);
2583
- return Object.fromEntries(r);
3017
+ t.push(i.composeCode);
3018
+ }), r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
2584
3019
  }
2585
- const te = "Unknown error";
2586
- function Ss(e) {
3020
+ const be = "Unknown error";
3021
+ function Be(e) {
2587
3022
  if (!e)
2588
3023
  return { success: !0, data: [] };
2589
- const r = [];
2590
- if (Qr(e)) {
3024
+ const t = [];
3025
+ if (Br(e)) {
2591
3026
  if (!e.composeCode)
2592
3027
  return {
2593
3028
  success: !1,
@@ -2601,9 +3036,9 @@ function Ss(e) {
2601
3036
  ]
2602
3037
  };
2603
3038
  try {
2604
- return { success: !0, data: [_(e.composeCode)] };
3039
+ return { success: !0, data: [W(e.composeCode)] };
2605
3040
  } catch (s) {
2606
- const n = s instanceof Error ? s.message : te;
3041
+ const n = s instanceof Error ? s.message : be;
2607
3042
  return {
2608
3043
  success: !1,
2609
3044
  errors: [
@@ -2611,162 +3046,914 @@ function Ss(e) {
2611
3046
  category: "filters",
2612
3047
  index: -1,
2613
3048
  input: e,
2614
- message: `Failed to parse composeCode for FilterRelations: ${n}. ComposeCode: "${e.composeCode}"`
3049
+ message: `Failed to parse composeCode for FilterRelations: ${n}. ComposeCode: '${e.composeCode}'`
2615
3050
  }
2616
3051
  ]
2617
3052
  };
2618
3053
  }
2619
3054
  }
2620
- const t = [];
3055
+ const r = [];
2621
3056
  return e.forEach((s, n) => {
3057
+ var i;
2622
3058
  if (!s.composeCode) {
2623
- r.push({
3059
+ t.push({
2624
3060
  category: "filters",
2625
3061
  index: n,
2626
3062
  input: s,
2627
- message: `Filter at index ${n} (${s.name || "unnamed"}) is missing composeCode`
3063
+ message: `Filter at index ${n} (${(i = s.name) != null ? i : "unnamed"}) is missing composeCode`
2628
3064
  });
2629
3065
  return;
2630
3066
  }
2631
3067
  try {
2632
- const o = _(s.composeCode);
2633
- t.push(o);
3068
+ const o = W(s.composeCode);
3069
+ r.push(o);
2634
3070
  } catch (o) {
2635
- const i = o instanceof Error ? o.message : te;
2636
- r.push({
3071
+ const a = o instanceof Error ? o.message : be;
3072
+ t.push({
2637
3073
  category: "filters",
2638
3074
  index: n,
2639
3075
  input: s,
2640
- message: `Failed to parse composeCode for filter at index ${n}: ${i}. ComposeCode: "${s.composeCode}"`
3076
+ message: `Failed to parse composeCode for filter at index ${n}: ${a}. ComposeCode: '${s.composeCode}'`
2641
3077
  });
2642
3078
  }
2643
- }), r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
3079
+ }), t.length > 0 ? { success: !1, errors: t } : { success: !0, data: r };
2644
3080
  }
2645
- function Ts(e) {
3081
+ function ze(e) {
2646
3082
  if (!e)
2647
3083
  return { success: !0, data: [] };
2648
- const r = [], t = [];
3084
+ const t = [], r = [];
2649
3085
  return e.forEach((s, n) => {
3086
+ var i;
2650
3087
  if (!s.composeCode) {
2651
- t.push({
3088
+ r.push({
2652
3089
  category: "highlights",
2653
3090
  index: n,
2654
3091
  input: s,
2655
- message: `Highlight filter at index ${n} (${s.name || "unnamed"}) is missing composeCode`
3092
+ message: `Highlight filter at index ${n} (${(i = s.name) != null ? i : "unnamed"}) is missing composeCode`
2656
3093
  });
2657
3094
  return;
2658
3095
  }
2659
3096
  try {
2660
- const o = _(s.composeCode);
2661
- r.push(o);
3097
+ const o = W(s.composeCode);
3098
+ t.push(o);
2662
3099
  } catch (o) {
2663
- const i = o instanceof Error ? o.message : te;
2664
- t.push({
3100
+ const a = o instanceof Error ? o.message : be;
3101
+ r.push({
2665
3102
  category: "highlights",
2666
3103
  index: n,
2667
3104
  input: s,
2668
- message: `Failed to parse composeCode for highlight filter at index ${n}: ${i}. ComposeCode: "${s.composeCode}"`
3105
+ message: `Failed to parse composeCode for highlight filter at index ${n}: ${a}. ComposeCode: '${s.composeCode}'`
2669
3106
  });
2670
3107
  }
2671
- }), t.length > 0 ? { success: !1, errors: t } : { success: !0, data: r };
3108
+ }), r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
3109
+ }
3110
+ function Xe(e) {
3111
+ return typeof e == "object" && e !== null && "column" in e && e.column !== void 0;
2672
3112
  }
2673
- function Ns(e) {
2674
- const r = [], t = [];
3113
+ function Le(e) {
3114
+ const t = [], r = [];
2675
3115
  return e.forEach((s, n) => {
2676
- const o = () => typeof s.toJSON == "function" ? s.toJSON() : s;
2677
- if (!s.composeCode) {
2678
- t.push({
3116
+ var u, c, p;
3117
+ const i = Xe(s) ? s.column : s, o = Xe(s) ? s : void 0, a = () => typeof i.toJSON == "function" ? i.toJSON() : i;
3118
+ if (!i.composeCode) {
3119
+ r.push({
2679
3120
  category: "measures",
2680
3121
  index: n,
2681
- input: o(),
2682
- message: `Measure at index ${n} (${s.name || "unnamed"}) is missing composeCode`
3122
+ input: a(),
3123
+ message: `Measure at index ${n} (${i.name || "unnamed"}) is missing composeCode`
2683
3124
  });
2684
3125
  return;
2685
3126
  }
2686
3127
  try {
2687
- const i = _(s.composeCode), a = s.getSort();
2688
- if (a !== void 0 && a !== ie.None) {
2689
- const u = {
2690
- column: i,
2691
- sortType: xe(a)
2692
- };
2693
- r.push(u);
3128
+ const l = W(i.composeCode), d = (p = o != null && o.sortType ? ne(o.sortType) : void 0) != null ? p : ((u = i.getSort) == null ? void 0 : u.call(i)) !== void 0 && ((c = i.getSort) == null ? void 0 : c.call(i)) !== B.None ? i.getSort() : void 0;
3129
+ if (d !== void 0 && d !== B.None || o && Object.keys(_(o, "column")).length > 0) {
3130
+ const g = o ? _(o, "column") : {}, m = y(y({
3131
+ column: l
3132
+ }, d !== void 0 && d !== B.None && { sortType: it(d) }), g);
3133
+ t.push(m);
2694
3134
  } else
2695
- r.push(i);
2696
- } catch (i) {
2697
- const a = i instanceof Error ? i.message : "Unknown error";
2698
- t.push({
3135
+ t.push(l);
3136
+ } catch (l) {
3137
+ const d = l instanceof Error ? l.message : "Unknown error";
3138
+ r.push({
2699
3139
  category: "measures",
2700
3140
  index: n,
2701
- input: o(),
2702
- message: `Failed to parse composeCode for measure at index ${n} (${s.name || "unnamed"}): ${a}. ComposeCode: "${s.composeCode}"`
3141
+ input: a(),
3142
+ message: `Failed to parse composeCode for measure at index ${n} (${i.name || "unnamed"}): ${d}. ComposeCode: '${i.composeCode}'`
2703
3143
  });
2704
3144
  }
2705
- }), t.length > 0 ? { success: !1, errors: t } : { success: !0, data: r };
3145
+ }), r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
2706
3146
  }
2707
- function se(e) {
2708
- return typeof e == "string" ? e.replace(/\[\[([^\]]+)\]\]/g, "$1") : Array.isArray(e) ? e.map(se) : e !== null && typeof e == "object" ? Object.fromEntries(
2709
- Object.entries(e).map(([r, t]) => [r, se(t)])
2710
- ) : e;
3147
+ function Ze(e) {
3148
+ var t, r, s, n;
3149
+ return ((r = (t = e.composeCode) == null ? void 0 : t.includes("measureFactory.trend")) != null ? r : !1) || ((n = (s = e.name) == null ? void 0 : s.startsWith(Ie)) != null ? n : !1);
2711
3150
  }
2712
- function Ls(e) {
2713
- const r = [], t = M(
2714
- () => $s(e.dimensions || []),
2715
- r
2716
- ), s = M(
2717
- () => Ns(e.measures || []),
2718
- r
2719
- ), n = M(
2720
- () => Ss(e.filters),
2721
- r
3151
+ function et(e) {
3152
+ var t, r, s, n;
3153
+ return ((r = (t = e.composeCode) == null ? void 0 : t.includes("measureFactory.forecast")) != null ? r : !1) || ((n = (s = e.name) == null ? void 0 : s.startsWith(Pe)) != null ? n : !1);
3154
+ }
3155
+ function tt(e) {
3156
+ try {
3157
+ const t = W(e.trim());
3158
+ return t.args[2] != null && typeof t.args[2] == "object" ? t.args[2] : void 0;
3159
+ } catch (t) {
3160
+ return;
3161
+ }
3162
+ }
3163
+ function In(e) {
3164
+ var s, n, i;
3165
+ if (!(e != null && e.length)) return [];
3166
+ const t = /* @__PURE__ */ new Set(), r = [];
3167
+ for (let o = 0; o < e.length; o++) {
3168
+ if (t.has(o)) continue;
3169
+ const a = e[o];
3170
+ if (Ze(a) || et(a)) {
3171
+ r.push(a);
3172
+ continue;
3173
+ }
3174
+ const u = (s = a.name) != null ? s : "Measure", c = `${Ie}_${u}`, p = `${Pe}_${u}`;
3175
+ let l, d, b = o + 1;
3176
+ if (b < e.length && !t.has(b) && Ze(e[b]) && e[b].name === c) {
3177
+ const g = (n = e[b].composeCode) == null ? void 0 : n.trim();
3178
+ g && (l = tt(g), t.add(b), b++);
3179
+ }
3180
+ if (b < e.length && !t.has(b) && et(e[b]) && e[b].name === p) {
3181
+ const g = (i = e[b].composeCode) == null ? void 0 : i.trim();
3182
+ g && (d = tt(g), t.add(b));
3183
+ }
3184
+ l !== void 0 || d !== void 0 ? r.push(y(y({
3185
+ column: a
3186
+ }, l && Object.keys(l).length > 0 && { trend: l }), d && Object.keys(d).length > 0 && { forecast: d })) : r.push(a);
3187
+ }
3188
+ return r;
3189
+ }
3190
+ function oi(e) {
3191
+ const t = [], r = w(
3192
+ () => ke(e.dimensions || []),
3193
+ t
3194
+ ), s = In(e.measures || []), n = w(
3195
+ () => Le(s),
3196
+ t
3197
+ ), i = w(
3198
+ () => Be(e.filters),
3199
+ t
2722
3200
  );
2723
3201
  let o = null;
2724
- if (e.highlights && e.highlights.length > 0 && (o = M(
2725
- () => Ts(e.highlights),
2726
- r
2727
- )), r.length > 0)
3202
+ if (e.highlights && e.highlights.length > 0 && (o = w(
3203
+ () => ze(e.highlights),
3204
+ t
3205
+ )), t.length > 0)
2728
3206
  return {
2729
3207
  success: !1,
2730
- errors: r
3208
+ errors: t
2731
3209
  };
2732
- const i = g({
2733
- dimensions: t || [],
2734
- measures: s || [],
2735
- filters: n || []
3210
+ const a = y({
3211
+ dimensions: r || [],
3212
+ measures: n || [],
3213
+ filters: i || []
2736
3214
  }, o && { highlights: o });
2737
3215
  return {
2738
3216
  success: !0,
2739
3217
  // Strip [[delimiters]] from all strings to preserve original names with spaces
2740
- data: se(i)
3218
+ data: Q(a)
2741
3219
  };
2742
3220
  }
2743
- function Rs(e) {
2744
- const { filters: r, relations: t } = Zr(
3221
+ const Lt = new Set(
3222
+ zr.filter((e) => e !== "image")
3223
+ ), rt = Object.freeze([...Lt]), me = /* @__PURE__ */ new Set([
3224
+ "category",
3225
+ "value",
3226
+ "breakBy",
3227
+ "breakByPoint",
3228
+ "x",
3229
+ "y",
3230
+ "breakByColor",
3231
+ "size",
3232
+ "boxType",
3233
+ "outliers",
3234
+ "geo",
3235
+ "colorBy",
3236
+ "details",
3237
+ "color",
3238
+ "date",
3239
+ "columns",
3240
+ "rows",
3241
+ "values",
3242
+ "secondary",
3243
+ "min",
3244
+ "max",
3245
+ "seriesToColorMap"
3246
+ ]), Pn = {
3247
+ line: {
3248
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3249
+ requiredAxes: ["category", "value"]
3250
+ },
3251
+ area: {
3252
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3253
+ requiredAxes: ["category", "value"]
3254
+ },
3255
+ bar: {
3256
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3257
+ requiredAxes: ["category", "value"]
3258
+ },
3259
+ column: {
3260
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3261
+ requiredAxes: ["category", "value"]
3262
+ },
3263
+ streamgraph: {
3264
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3265
+ requiredAxes: ["category", "value"]
3266
+ },
3267
+ polar: {
3268
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3269
+ requiredAxes: ["category", "value"]
3270
+ },
3271
+ pie: {
3272
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "seriesToColorMap"]),
3273
+ requiredAxes: ["category", "value"]
3274
+ },
3275
+ funnel: {
3276
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "seriesToColorMap"]),
3277
+ requiredAxes: ["category", "value"]
3278
+ },
3279
+ treemap: {
3280
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "seriesToColorMap"]),
3281
+ requiredAxes: ["category", "value"]
3282
+ },
3283
+ sunburst: {
3284
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "seriesToColorMap"]),
3285
+ requiredAxes: ["category", "value"]
3286
+ },
3287
+ scatter: {
3288
+ validAxes: /* @__PURE__ */ new Set(["x", "y", "breakByPoint", "breakByColor", "size", "seriesToColorMap"]),
3289
+ requiredAxes: []
3290
+ },
3291
+ table: {
3292
+ validAxes: /* @__PURE__ */ new Set(["columns"]),
3293
+ requiredAxes: ["columns"]
3294
+ },
3295
+ indicator: {
3296
+ validAxes: /* @__PURE__ */ new Set(["value", "secondary", "min", "max"]),
3297
+ requiredAxes: []
3298
+ },
3299
+ boxplot: {
3300
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "boxType", "outliers"]),
3301
+ requiredAxes: ["value"]
3302
+ },
3303
+ areamap: {
3304
+ validAxes: /* @__PURE__ */ new Set(["geo", "color"]),
3305
+ requiredAxes: ["geo"]
3306
+ },
3307
+ scattermap: {
3308
+ validAxes: /* @__PURE__ */ new Set(["geo", "size", "colorBy", "details"]),
3309
+ requiredAxes: ["geo"]
3310
+ },
3311
+ "calendar-heatmap": {
3312
+ validAxes: /* @__PURE__ */ new Set(["date", "value"]),
3313
+ requiredAxes: ["date", "value"]
3314
+ },
3315
+ arearange: {
3316
+ validAxes: /* @__PURE__ */ new Set(["category", "value", "breakBy", "seriesToColorMap"]),
3317
+ requiredAxes: ["category", "value"]
3318
+ }
3319
+ }, kn = /* @__PURE__ */ new Set([
3320
+ "category",
3321
+ "breakBy",
3322
+ "breakByPoint",
3323
+ "rows",
3324
+ "geo",
3325
+ "details",
3326
+ "date"
3327
+ ]), Bn = /* @__PURE__ */ new Set([
3328
+ "value",
3329
+ "size",
3330
+ "colorBy",
3331
+ "boxType",
3332
+ "outliers",
3333
+ "values",
3334
+ "secondary",
3335
+ "min",
3336
+ "max",
3337
+ "color"
3338
+ ]);
3339
+ function zn(e) {
3340
+ const t = Pn[e];
3341
+ if (t)
3342
+ return {
3343
+ validAxes: new Set(t.validAxes),
3344
+ requiredAxes: Object.freeze([...t.requiredAxes])
3345
+ };
3346
+ }
3347
+ function Ut(e) {
3348
+ return typeof e == "string" && Lt.has(e);
3349
+ }
3350
+ function Ln(e, t, r) {
3351
+ if (r === "boxplot" && e === "value" || r === "calendar-heatmap" && e === "date" || kn.has(e))
3352
+ return !0;
3353
+ if (Bn.has(e))
3354
+ return !1;
3355
+ const s = Array.isArray(t) ? t[0] : t;
3356
+ if (!s)
3357
+ return !0;
3358
+ let n;
3359
+ return S(s) && "column" in s && (n = s.column), !(q(s) || n !== void 0 && q(n));
3360
+ }
3361
+ function Un(e) {
3362
+ const t = [], r = {
3363
+ chartType: "",
3364
+ dataOptions: {}
3365
+ };
3366
+ if (!S(e))
3367
+ return t.push({
3368
+ category: "chartType",
3369
+ index: -1,
3370
+ input: e,
3371
+ message: "Expected an object"
3372
+ }), { normalized: r, errors: t };
3373
+ const s = e.chartType;
3374
+ if (s === void 0) {
3375
+ const i = Object.keys(e), o = R("chartType", i, (c) => c), a = o && o.distance <= x ? ` Did you mean 'chartType'? (You may have typed '${o.best}')` : "", u = o && o.distance <= x ? { [o.best]: e[o.best] } : e;
3376
+ t.push({
3377
+ category: "chartType",
3378
+ index: -1,
3379
+ input: u,
3380
+ message: `chartType is required.${a}`
3381
+ });
3382
+ } else if (Ut(s))
3383
+ r.chartType = s;
3384
+ else {
3385
+ const i = R(String(s), rt, (u) => u), o = i && i.distance <= x ? ` Did you mean '${i.best}'?` : "", a = rt.slice(0, 8).join(", ");
3386
+ t.push({
3387
+ category: "chartType",
3388
+ index: -1,
3389
+ input: s,
3390
+ message: `Invalid chartType '${s}'. Valid types: ${a}, ...${o}`
3391
+ });
3392
+ }
3393
+ const n = e.dataOptions;
3394
+ if (n === void 0) {
3395
+ const i = Object.keys(e), o = R("dataOptions", i, (c) => c), a = o && o.distance <= x ? ` Did you mean 'dataOptions'? (You may have typed '${o.best}')` : "", u = o && o.distance <= x ? { [o.best]: e[o.best] } : e;
3396
+ t.push({
3397
+ category: "dataOptions",
3398
+ index: -1,
3399
+ input: u,
3400
+ message: `dataOptions is required.${a}`
3401
+ });
3402
+ } else n !== null && typeof n == "object" && (r.dataOptions = n);
3403
+ return e.styleOptions !== void 0 && (r.styleOptions = e.styleOptions), e.filters !== void 0 && Array.isArray(e.filters) && (r.filters = e.filters), e.highlights !== void 0 && Array.isArray(e.highlights) && (r.highlights = e.highlights), { normalized: r, errors: t };
3404
+ }
3405
+ function _n(e) {
3406
+ return e.map(
3407
+ ({ attribute: t, style: r }) => r ? y({ column: t }, r) : t
3408
+ );
3409
+ }
3410
+ function Vn(e) {
3411
+ return e.map(
3412
+ ({ measure: t, style: r }) => r ? y({ column: t }, r) : t
3413
+ );
3414
+ }
3415
+ function _t(e) {
3416
+ return Array.isArray(e) ? e : [e];
3417
+ }
3418
+ function Ae(e) {
3419
+ return (t) => F(y({}, t), {
3420
+ category: "dataOptions",
3421
+ index: e
3422
+ });
3423
+ }
3424
+ function re(e, t, r, s, n) {
3425
+ const i = t ? _t(
3426
+ t
3427
+ ) : [];
3428
+ if (i.length === 0)
3429
+ return [];
3430
+ if (r === "dimension") {
3431
+ const a = w(
3432
+ () => qt({
3433
+ data: i,
3434
+ context: s
3435
+ }),
3436
+ n,
3437
+ Ae(e)
3438
+ );
3439
+ return a !== null ? _n(a) : null;
3440
+ }
3441
+ const o = w(
3442
+ () => zt({
3443
+ data: i,
3444
+ context: s
3445
+ }),
3446
+ n,
3447
+ Ae(e)
3448
+ );
3449
+ return o !== null ? Vn(o) : null;
3450
+ }
3451
+ function st(e, t, r) {
3452
+ const s = Array.isArray(t) ? t : t != null ? [t] : [];
3453
+ if (r === "dimension") {
3454
+ const i = ke(
3455
+ s
3456
+ );
3457
+ return i.success ? { success: !0, data: i.data } : {
3458
+ success: !1,
3459
+ errors: i.errors.map((o) => F(y({}, o), {
3460
+ category: "dataOptions",
3461
+ index: e
3462
+ }))
3463
+ };
3464
+ }
3465
+ const n = Le(s);
3466
+ return n.success ? { success: !0, data: n.data } : {
3467
+ success: !1,
3468
+ errors: n.errors.map((i) => F(y({}, i), {
3469
+ category: "dataOptions",
3470
+ index: e
3471
+ }))
3472
+ };
3473
+ }
3474
+ function Wn(e, t) {
3475
+ let r;
3476
+ S(e) && "column" in e && (r = e.column);
3477
+ const n = !(q(e) || r !== void 0 && q(r)) ? "dimension" : "measure", i = [], o = re("columns", [e], n, t, i);
3478
+ return o !== null ? { success: !0, data: o } : { success: !1, errors: i };
3479
+ }
3480
+ function jn(e, t, r, s) {
3481
+ const n = [];
3482
+ for (const i of e) {
3483
+ const o = w(
3484
+ () => Wn(i, t),
3485
+ r,
3486
+ s
3487
+ );
3488
+ o && n.push(...o);
3489
+ }
3490
+ return n;
3491
+ }
3492
+ function Kn(e, t, r) {
3493
+ if (!e || !S(e))
3494
+ return r.push({
3495
+ category: "dataOptions",
3496
+ index: -1,
3497
+ input: e,
3498
+ message: "dataOptions is required"
3499
+ }), null;
3500
+ const s = {}, { chartType: n } = t, i = r.length, o = e, a = Object.keys(e), u = /* @__PURE__ */ new Map();
3501
+ for (const l of a)
3502
+ if (!me.has(l)) {
3503
+ const d = R(l, [...me], (g) => g), b = d && d.distance <= x ? ` Did you mean '${d.best}'?` : "";
3504
+ d && d.distance <= x && u.set(l, d.best), r.push({
3505
+ category: "dataOptions",
3506
+ index: l,
3507
+ input: o[l],
3508
+ message: `Unknown dataOptions key '${l}'.${b}`
3509
+ });
3510
+ }
3511
+ const c = n ? zn(n) : void 0;
3512
+ if (c) {
3513
+ for (const l of a)
3514
+ if (l !== "seriesToColorMap" && !c.validAxes.has(l) && me.has(l)) {
3515
+ const d = R(l, [...c.validAxes], (m) => m), b = d && d.distance <= x ? ` Did you mean '${d.best}'?` : "", g = [...c.validAxes].join(", ");
3516
+ r.push({
3517
+ category: "dataOptions",
3518
+ index: l,
3519
+ input: o[l],
3520
+ message: `Axis '${l}' is not valid for chart type '${n}'. Valid axes: ${g}.${b}`
3521
+ });
3522
+ }
3523
+ for (const l of c.requiredAxes)
3524
+ [...u.values()].includes(l) || (!(l in o) || o[l] == null) && r.push({
3525
+ category: "dataOptions",
3526
+ index: l,
3527
+ input: null,
3528
+ message: `Chart type '${n}' requires '${c.requiredAxes.join(
3529
+ "' and '"
3530
+ )}'. Missing: ${l}.`
3531
+ });
3532
+ n === "indicator" && (["value", "secondary", "min", "max"].some(
3533
+ (b) => b in o && o[b] != null
3534
+ ) || r.push({
3535
+ category: "dataOptions",
3536
+ index: -1,
3537
+ input: e,
3538
+ message: "Indicator chart requires at least one of: value, secondary, min, max."
3539
+ })), n === "scatter" && ("x" in e && e.x != null || "y" in e && e.y != null || r.push({
3540
+ category: "dataOptions",
3541
+ index: -1,
3542
+ input: e,
3543
+ message: "Scatter chart requires at least one of: x, y."
3544
+ }));
3545
+ }
3546
+ if (r.length > i)
3547
+ return null;
3548
+ const p = Object.entries(e);
3549
+ for (const [l, d] of p) {
3550
+ if (!d) continue;
3551
+ if (l === "seriesToColorMap") {
3552
+ s[l] = d;
3553
+ continue;
3554
+ }
3555
+ if (l === "columns") {
3556
+ s[l] = jn(
3557
+ _t(d),
3558
+ t,
3559
+ r,
3560
+ Ae("columns")
3561
+ );
3562
+ continue;
3563
+ }
3564
+ const b = Ln(l, d, n) ? "dimension" : "measure", g = re(
3565
+ l,
3566
+ d,
3567
+ b,
3568
+ t,
3569
+ r
3570
+ );
3571
+ if (g !== null) {
3572
+ const m = n === "calendar-heatmap" && l === "value";
3573
+ s[l] = m || !Array.isArray(d) ? g[0] : g;
3574
+ }
3575
+ }
3576
+ return r.length > i ? null : s;
3577
+ }
3578
+ function Gn(e) {
3579
+ if (typeof e != "string") return "iqr";
3580
+ const t = e.split("/")[1];
3581
+ return t === "iqr" || t === "extremums" || t === "standardDeviation" ? t : "iqr";
3582
+ }
3583
+ const ai = (e) => {
3584
+ var m;
3585
+ const { data: t, context: r } = e, { dataSource: s, tables: n } = r, { normalized: i, errors: o } = Un(t);
3586
+ if (o.length > 0)
3587
+ return { success: !1, errors: o };
3588
+ const a = i.chartType, u = $e(n), c = [];
3589
+ let p = Kn(
3590
+ i.dataOptions,
3591
+ { dataSource: s, schemaIndex: u, chartType: a },
3592
+ c
3593
+ );
3594
+ if (a === "boxplot" && p) {
3595
+ const A = Gn((m = i.styleOptions) == null ? void 0 : m.subtype), C = A === "iqr" || A === "standardDeviation";
3596
+ p = F(y({}, p), { boxType: A, outliersEnabled: C });
3597
+ }
3598
+ let l = null;
3599
+ i.filters && i.filters.length > 0 && (l = w(
3600
+ () => Re({
3601
+ data: i.filters || [],
3602
+ context: { dataSource: s, schemaIndex: u }
3603
+ }),
3604
+ c
3605
+ ));
3606
+ let d = null;
3607
+ if (i.highlights && i.highlights.length > 0 && (d = w(
3608
+ () => ve({
3609
+ data: i.highlights || [],
3610
+ context: { dataSource: s, schemaIndex: u }
3611
+ }),
3612
+ c
3613
+ )), c.length > 0 || p === null)
3614
+ return {
3615
+ success: !1,
3616
+ errors: c
3617
+ };
3618
+ if (!Ut(i.chartType))
3619
+ return {
3620
+ success: !1,
3621
+ errors: [
3622
+ {
3623
+ category: "chartType",
3624
+ index: -1,
3625
+ input: i.chartType,
3626
+ message: "Invalid chartType"
3627
+ }
3628
+ ]
3629
+ };
3630
+ const b = i.chartType;
3631
+ return {
3632
+ success: !0,
3633
+ data: y(y(y({
3634
+ dataSet: we(s),
3635
+ chartType: b,
3636
+ dataOptions: p
3637
+ }, i.styleOptions && {
3638
+ // Pass-through NLQ JSON; shape matches ChartStyleOptions.
3639
+ styleOptions: i.styleOptions
3640
+ }), l && { filters: l }), d && { highlights: d })
3641
+ };
3642
+ }, ui = (e) => {
3643
+ const t = [];
3644
+ if (!e.chartType)
3645
+ return {
3646
+ success: !1,
3647
+ errors: [
3648
+ {
3649
+ category: "dimensions",
3650
+ index: -1,
3651
+ input: e,
3652
+ message: "chartType is required"
3653
+ }
3654
+ ]
3655
+ };
3656
+ if (!e.dataOptions)
3657
+ return {
3658
+ success: !1,
3659
+ errors: [
3660
+ {
3661
+ category: "dimensions",
3662
+ index: -1,
3663
+ input: e,
3664
+ message: "dataOptions is required"
3665
+ }
3666
+ ]
3667
+ };
3668
+ let r = null;
3669
+ const s = Yn(e.dataOptions);
3670
+ s.success ? r = s.data : t.push(...s.errors);
3671
+ let n;
3672
+ if (e.filters) {
3673
+ const u = w(
3674
+ () => Be(e.filters),
3675
+ t
3676
+ );
3677
+ n = u != null ? u : void 0;
3678
+ }
3679
+ let i;
3680
+ if (e.highlights && e.highlights.length > 0) {
3681
+ const u = w(
3682
+ () => ze(e.highlights),
3683
+ t
3684
+ );
3685
+ i = u != null ? u : void 0;
3686
+ }
3687
+ if (t.length > 0 || r === null)
3688
+ return { success: !1, errors: t };
3689
+ const o = y(y(y({
3690
+ chartType: e.chartType,
3691
+ dataOptions: r
3692
+ }, e.styleOptions && {
3693
+ styleOptions: e.styleOptions
3694
+ }), n && n.length > 0 && { filters: n }), i && i.length > 0 && { highlights: i });
3695
+ return {
3696
+ success: !0,
3697
+ data: Q(
3698
+ o
3699
+ )
3700
+ };
3701
+ };
3702
+ function Yn(e) {
3703
+ const t = {}, r = [], s = /* @__PURE__ */ new Set(["seriesToColorMap", "boxType", "outliersEnabled", "valueTitle"]);
3704
+ for (const [n, i] of Object.entries(e)) {
3705
+ if (n === "seriesToColorMap" && i) {
3706
+ t[n] = i;
3707
+ continue;
3708
+ }
3709
+ if (s.has(n) || i == null) {
3710
+ i != null && (t[n] = i);
3711
+ continue;
3712
+ }
3713
+ const o = Array.isArray(i) ? i : [i], a = Array.isArray(i), u = [], c = [];
3714
+ for (let p = 0; p < o.length; p++) {
3715
+ const l = o[p], b = Jn(l) ? ke([
3716
+ l
3717
+ ]) : Le([l]);
3718
+ b.success ? u.push(...b.data) : b.errors.forEach((g) => {
3719
+ var m;
3720
+ c.push(F(y({}, g), { index: p, input: (m = g.input) != null ? m : l }));
3721
+ });
3722
+ }
3723
+ if (c.length > 0) {
3724
+ r.push(...c);
3725
+ continue;
3726
+ }
3727
+ t[n] = a ? u : u[0];
3728
+ }
3729
+ return r.length > 0 ? { success: !1, errors: r } : { success: !0, data: t };
3730
+ }
3731
+ function Jn(e) {
3732
+ const t = Array.isArray(e) ? e[0] : e;
3733
+ if (!t || !S(t))
3734
+ return !0;
3735
+ const r = "column" in t && t.column != null && S(t.column) ? t.column : t;
3736
+ if ("composeCode" in r) {
3737
+ const s = r.composeCode;
3738
+ if (typeof s == "string" && s.startsWith("DM."))
3739
+ return !0;
3740
+ if (typeof s == "string" && (s.includes("measureFactory") || s.includes("Formula")))
3741
+ return !1;
3742
+ }
3743
+ if ("type" in r) {
3744
+ const s = r.type;
3745
+ if (s === "basemeasure" || s === "calculatedmeasure")
3746
+ return !1;
3747
+ }
3748
+ return !("aggregation" in r || "attribute" in r && "aggregation" in r);
3749
+ }
3750
+ const nt = ["rows", "columns", "values", "grandTotals"];
3751
+ function Hn(e) {
3752
+ if (!S(e)) return !1;
3753
+ const t = Object.keys(e);
3754
+ return t.every((r) => r === "rows" || r === "columns") && t.every((r) => typeof e[r] == "boolean");
3755
+ }
3756
+ function Qn(e) {
3757
+ const t = [], r = {
3758
+ dataOptions: {}
3759
+ };
3760
+ if (!S(e))
3761
+ return t.push({
3762
+ category: "dataOptions",
3763
+ index: -1,
3764
+ input: e,
3765
+ message: "Expected an object"
3766
+ }), { normalized: r, errors: t };
3767
+ const s = e.dataOptions;
3768
+ if (s === void 0) {
3769
+ const n = Object.keys(e), i = R("dataOptions", n, (u) => u), o = i && i.distance <= x ? ` Did you mean 'dataOptions'? (You may have typed '${i.best}')` : "", a = i && i.distance <= x ? { [i.best]: e[i.best] } : e;
3770
+ t.push({
3771
+ category: "dataOptions",
3772
+ index: -1,
3773
+ input: a,
3774
+ message: `dataOptions is required.${o}`
3775
+ });
3776
+ } else if (S(s)) {
3777
+ const n = s;
3778
+ r.dataOptions = n;
3779
+ for (const o of Object.keys(n))
3780
+ if (!nt.includes(o)) {
3781
+ const a = R(o, [...nt], (c) => c), u = a && a.distance <= x ? ` Did you mean '${a.best}'?` : "";
3782
+ t.push({
3783
+ category: "dataOptions",
3784
+ index: o,
3785
+ input: n[o],
3786
+ message: `Unknown dataOptions key '${o}'. Valid keys: rows, columns, values, grandTotals.${u}`
3787
+ });
3788
+ }
3789
+ for (const o of ["rows", "columns", "values"]) {
3790
+ const a = n[o];
3791
+ a != null && !Array.isArray(a) && t.push({
3792
+ category: "dataOptions",
3793
+ index: o,
3794
+ input: a,
3795
+ message: `dataOptions.${o} must be an array`
3796
+ });
3797
+ }
3798
+ const i = n.grandTotals;
3799
+ i != null && !Hn(i) && t.push({
3800
+ category: "dataOptions",
3801
+ index: "grandTotals",
3802
+ input: i,
3803
+ message: "grandTotals must be an object with optional rows?: boolean, columns?: boolean"
3804
+ });
3805
+ }
3806
+ return e.styleOptions !== void 0 && (r.styleOptions = e.styleOptions), e.filters !== void 0 && Array.isArray(e.filters) && (r.filters = e.filters), e.highlights !== void 0 && Array.isArray(e.highlights) && (r.highlights = e.highlights), { normalized: r, errors: t };
3807
+ }
3808
+ function Xn(e, t, r) {
3809
+ if (!e || typeof e != "object")
3810
+ return r.push({
3811
+ category: "dataOptions",
3812
+ index: -1,
3813
+ input: e,
3814
+ message: "dataOptions is required"
3815
+ }), null;
3816
+ const s = {}, n = r.length;
3817
+ for (const o of ["rows", "columns"]) {
3818
+ const a = re(
3819
+ o,
3820
+ e[o],
3821
+ "dimension",
3822
+ t,
3823
+ r
3824
+ );
3825
+ a && (s[o] = a);
3826
+ }
3827
+ const i = re(
3828
+ "values",
3829
+ e.values,
3830
+ "measure",
3831
+ t,
3832
+ r
3833
+ );
3834
+ return i && (s.values = i), e.grandTotals !== void 0 && (s.grandTotals = e.grandTotals), r.length > n ? null : s;
3835
+ }
3836
+ const ci = (e) => {
3837
+ const { data: t, context: r } = e, { dataSource: s, tables: n } = r, { normalized: i, errors: o } = Qn(t);
3838
+ if (o.length > 0)
3839
+ return { success: !1, errors: o };
3840
+ const a = $e(n), u = [], c = Xn(
3841
+ i.dataOptions,
3842
+ { dataSource: s, schemaIndex: a },
3843
+ u
3844
+ );
3845
+ let p = null;
3846
+ i.filters && i.filters.length > 0 && (p = w(
3847
+ () => Re({
3848
+ data: i.filters || [],
3849
+ context: { dataSource: s, schemaIndex: a }
3850
+ }),
3851
+ u
3852
+ ));
3853
+ let l = null;
3854
+ return i.highlights && i.highlights.length > 0 && (l = w(
3855
+ () => ve({
3856
+ data: i.highlights || [],
3857
+ context: { dataSource: s, schemaIndex: a }
3858
+ }),
3859
+ u
3860
+ )), u.length > 0 || c === null ? {
3861
+ success: !1,
3862
+ errors: u
3863
+ } : {
3864
+ success: !0,
3865
+ data: y(y(y({
3866
+ dataSet: we(s),
3867
+ dataOptions: c
3868
+ }, i.styleOptions && { styleOptions: i.styleOptions }), p && { filters: p }), l && { highlights: l })
3869
+ };
3870
+ }, li = (e) => {
3871
+ const t = [];
3872
+ if (!e.dataOptions)
3873
+ return {
3874
+ success: !1,
3875
+ errors: [
3876
+ {
3877
+ category: "dataOptions",
3878
+ index: -1,
3879
+ input: e,
3880
+ message: "dataOptions is required"
3881
+ }
3882
+ ]
3883
+ };
3884
+ const r = e.dataOptions, s = {};
3885
+ for (const c of ["rows", "columns"]) {
3886
+ const p = r[c];
3887
+ if (p && p.length > 0) {
3888
+ const l = st(c, p, "dimension");
3889
+ l.success ? s[c] = l.data : t.push(...l.errors);
3890
+ }
3891
+ }
3892
+ const n = r.values;
3893
+ if (n && n.length > 0) {
3894
+ const c = st("values", n, "measure");
3895
+ c.success ? s.values = c.data : t.push(...c.errors);
3896
+ }
3897
+ r.grandTotals !== void 0 && (s.grandTotals = r.grandTotals);
3898
+ let i;
3899
+ if (e.filters) {
3900
+ const c = w(
3901
+ () => Be(e.filters),
3902
+ t
3903
+ );
3904
+ i = c != null ? c : void 0;
3905
+ }
3906
+ let o;
3907
+ if (e.highlights && e.highlights.length > 0) {
3908
+ const c = w(
3909
+ () => ze(e.highlights),
3910
+ t
3911
+ );
3912
+ o = c != null ? c : void 0;
3913
+ }
3914
+ if (t.length > 0)
3915
+ return { success: !1, errors: t };
3916
+ const a = y(y(y({
3917
+ dataOptions: s
3918
+ }, e.styleOptions && { styleOptions: e.styleOptions }), i && i.length > 0 && { filters: i }), o && o.length > 0 && { highlights: o });
3919
+ return {
3920
+ success: !0,
3921
+ data: Q(
3922
+ a
3923
+ )
3924
+ };
3925
+ };
3926
+ function Zn(e) {
3927
+ const { filters: t, relations: r } = _r(
2745
3928
  e.filters || []
2746
3929
  );
2747
3930
  return {
2748
3931
  dataSource: e.dataSource,
2749
3932
  dimensions: e.dimensions,
2750
3933
  measures: e.measures,
2751
- filters: r,
2752
- filterRelations: t,
3934
+ filters: t,
3935
+ filterRelations: r,
2753
3936
  highlights: e.highlights
2754
3937
  // No count/offset/ungroup - these are execution concerns, not translation concerns
2755
3938
  };
2756
3939
  }
2757
- function Vs(e, r, t = !1) {
2758
- const s = Rs(e), n = Yr(s, r);
2759
- return Hr(n, t);
3940
+ function fi(e, t, r = !1) {
3941
+ const s = Zn(e), n = Lr(s, t);
3942
+ return Ur(n, r);
2760
3943
  }
2761
3944
  export {
2762
- Ps as CustomSuperJSON,
2763
- Ws as EMPTY_EXPANDED_QUERY_MODEL,
2764
- js as EMPTY_SIMPLE_QUERY_MODEL,
2765
- Js as isByIdDashboardCodeParams,
2766
- Ks as isByIdWidgetCodeParams,
2767
- Gs as isClientSideDashboardCodeParams,
2768
- Qs as isClientSideWidgetCodeParams,
2769
- ks as translateQueryFromJSON,
2770
- Ls as translateQueryToJSON,
2771
- Vs as translateQueryToJaql
3945
+ ni as CustomSuperJSON,
3946
+ pi as EMPTY_EXPANDED_QUERY_MODEL,
3947
+ gi as EMPTY_SIMPLE_QUERY_MODEL,
3948
+ yi as isByIdDashboardCodeParams,
3949
+ hi as isByIdWidgetCodeParams,
3950
+ bi as isClientSideDashboardCodeParams,
3951
+ Ai as isClientSideWidgetCodeParams,
3952
+ ai as translateChartFromJSON,
3953
+ ui as translateChartToJSON,
3954
+ ci as translatePivotTableFromJSON,
3955
+ li as translatePivotTableToJSON,
3956
+ ii as translateQueryFromJSON,
3957
+ oi as translateQueryToJSON,
3958
+ fi as translateQueryToJaql
2772
3959
  };