drizzle-cube 0.3.25 → 0.3.28

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 (113) hide show
  1. package/README.md +6 -0
  2. package/dist/adapters/express/index.cjs +1 -1
  3. package/dist/adapters/express/index.js +1 -1
  4. package/dist/adapters/fastify/index.cjs +1 -1
  5. package/dist/adapters/fastify/index.js +1 -1
  6. package/dist/adapters/hono/index.cjs +1 -1
  7. package/dist/adapters/hono/index.js +1 -1
  8. package/dist/adapters/{mcp-transport-B4BZSsMC.js → mcp-transport-CXGL1hg7.js} +1655 -1624
  9. package/dist/adapters/{mcp-transport-C8pLznZG.cjs → mcp-transport-ConlvewL.cjs} +73 -73
  10. package/dist/adapters/nextjs/index.cjs +1 -1
  11. package/dist/adapters/nextjs/index.js +1 -1
  12. package/dist/adapters/utils.cjs +1 -1
  13. package/dist/adapters/utils.js +5 -5
  14. package/dist/client/charts.js +12 -12
  15. package/dist/client/chunks/{DashboardEditModal-CVMSvpJ-.js → DashboardEditModal-t5XeTZom.js} +45 -45
  16. package/dist/client/chunks/DashboardEditModal-t5XeTZom.js.map +1 -0
  17. package/dist/client/chunks/{RetentionCombinedChart-BVKWmxc-.js → RetentionCombinedChart-SsBGHJWi.js} +9 -9
  18. package/dist/client/chunks/RetentionCombinedChart-SsBGHJWi.js.map +1 -0
  19. package/dist/client/chunks/{RetentionHeatmap-BiqfhGYk.js → RetentionHeatmap-BHYU8MXY.js} +8 -8
  20. package/dist/client/chunks/RetentionHeatmap-BHYU8MXY.js.map +1 -0
  21. package/dist/client/chunks/{analysis-builder-CuTR61Ct.js → analysis-builder-CKVYG9jJ.js} +67 -67
  22. package/dist/client/chunks/analysis-builder-CKVYG9jJ.js.map +1 -0
  23. package/dist/client/chunks/{analysis-builder-shared-D7iqklYk.js → analysis-builder-shared-CF8Vx1oD.js} +8 -8
  24. package/dist/client/chunks/analysis-builder-shared-CF8Vx1oD.js.map +1 -0
  25. package/dist/client/chunks/{chart-activity-grid-BcMRkaq4.js → chart-activity-grid-Bpu_-8uT.js} +5 -5
  26. package/dist/client/chunks/{chart-activity-grid-BcMRkaq4.js.map → chart-activity-grid-Bpu_-8uT.js.map} +1 -1
  27. package/dist/client/chunks/{chart-area-KlBSb_ur.js → chart-area-DcvLkvGb.js} +8 -8
  28. package/dist/client/chunks/chart-area-DcvLkvGb.js.map +1 -0
  29. package/dist/client/chunks/{chart-bar-D1i2jmIg.js → chart-bar-CNfm5iMY.js} +7 -7
  30. package/dist/client/chunks/chart-bar-CNfm5iMY.js.map +1 -0
  31. package/dist/client/chunks/{chart-bubble-BFjnOwNZ.js → chart-bubble-KA-RYWR8.js} +4 -4
  32. package/dist/client/chunks/{chart-bubble-BFjnOwNZ.js.map → chart-bubble-KA-RYWR8.js.map} +1 -1
  33. package/dist/client/chunks/{chart-data-table-CYMMAHau.js → chart-data-table-Cq14arji.js} +9 -9
  34. package/dist/client/chunks/chart-data-table-Cq14arji.js.map +1 -0
  35. package/dist/client/chunks/{chart-funnel-BH7r4HWZ.js → chart-funnel-DFKWS49U.js} +7 -7
  36. package/dist/client/chunks/chart-funnel-DFKWS49U.js.map +1 -0
  37. package/dist/client/chunks/{chart-heat-map-DyGtODLE.js → chart-heat-map-D2g0dbKz.js} +5 -5
  38. package/dist/client/chunks/chart-heat-map-D2g0dbKz.js.map +1 -0
  39. package/dist/client/chunks/{chart-kpi-delta-Bk396suk.js → chart-kpi-delta-Cc-jiBd0.js} +30 -30
  40. package/dist/client/chunks/chart-kpi-delta-Cc-jiBd0.js.map +1 -0
  41. package/dist/client/chunks/{chart-kpi-number-CIGqZ5Dw.js → chart-kpi-number-BXolYaZA.js} +8 -8
  42. package/dist/client/chunks/chart-kpi-number-BXolYaZA.js.map +1 -0
  43. package/dist/client/chunks/{chart-kpi-text-iwlaSQCi.js → chart-kpi-text-PA8oyypA.js} +7 -7
  44. package/dist/client/chunks/chart-kpi-text-PA8oyypA.js.map +1 -0
  45. package/dist/client/chunks/{chart-line-BKqhoW9A.js → chart-line-BOrtUdOD.js} +8 -8
  46. package/dist/client/chunks/chart-line-BOrtUdOD.js.map +1 -0
  47. package/dist/client/chunks/{chart-markdown-CiPhRY9s.js → chart-markdown-Cget3iEq.js} +6 -6
  48. package/dist/client/chunks/chart-markdown-Cget3iEq.js.map +1 -0
  49. package/dist/client/chunks/{chart-pie-BNr-GgTh.js → chart-pie-B-Sbsvd2.js} +7 -7
  50. package/dist/client/chunks/chart-pie-B-Sbsvd2.js.map +1 -0
  51. package/dist/client/chunks/{chart-radar-CYrGVYEQ.js → chart-radar-CezgvXhm.js} +6 -6
  52. package/dist/client/chunks/chart-radar-CezgvXhm.js.map +1 -0
  53. package/dist/client/chunks/{chart-radial-bar-2PR3ucIR.js → chart-radial-bar-COBPiBxm.js} +6 -6
  54. package/dist/client/chunks/chart-radial-bar-COBPiBxm.js.map +1 -0
  55. package/dist/client/chunks/{chart-sankey-C7w7h2ZV.js → chart-sankey-O4WQBRDk.js} +27 -27
  56. package/dist/client/chunks/{chart-sankey-C7w7h2ZV.js.map → chart-sankey-O4WQBRDk.js.map} +1 -1
  57. package/dist/client/chunks/{chart-scatter-D3Z9bl8H.js → chart-scatter-BVF0n9DR.js} +22 -22
  58. package/dist/client/chunks/chart-scatter-BVF0n9DR.js.map +1 -0
  59. package/dist/client/chunks/{chart-sunburst-C4ydFeaK.js → chart-sunburst-DZzVj_6S.js} +4 -4
  60. package/dist/client/chunks/{chart-sunburst-C4ydFeaK.js.map → chart-sunburst-DZzVj_6S.js.map} +1 -1
  61. package/dist/client/chunks/{chart-tree-map-DCCmMyz1.js → chart-tree-map-CeEtNuo6.js} +6 -6
  62. package/dist/client/chunks/chart-tree-map-CeEtNuo6.js.map +1 -0
  63. package/dist/client/chunks/{charts-core-DIW3Dd7n.js → charts-core-DF99lItO.js} +4 -4
  64. package/dist/client/chunks/charts-core-DF99lItO.js.map +1 -0
  65. package/dist/client/chunks/{charts-loader-BCBnMYjH.js → charts-loader-AkRviD9H.js} +22 -22
  66. package/dist/client/chunks/{charts-loader-BCBnMYjH.js.map → charts-loader-AkRviD9H.js.map} +1 -1
  67. package/dist/client/chunks/{core-BITzuqYm.js → core-Bso4ultM.js} +2 -2
  68. package/dist/client/chunks/{core-BITzuqYm.js.map → core-Bso4ultM.js.map} +1 -1
  69. package/dist/client/chunks/{hooks-Dd_nnv0J.js → hooks-B69r8rwU.js} +4 -4
  70. package/dist/client/chunks/{hooks-Dd_nnv0J.js.map → hooks-B69r8rwU.js.map} +1 -1
  71. package/dist/client/chunks/{providers-BjxD1ZmC.js → providers-CxlSRYvE.js} +2 -2
  72. package/dist/client/chunks/{providers-BjxD1ZmC.js.map → providers-CxlSRYvE.js.map} +1 -1
  73. package/dist/client/chunks/{syntaxHighlighting-Cmqp7_Mx.js → syntaxHighlighting-yTdSle2t.js} +2 -2
  74. package/dist/client/chunks/{syntaxHighlighting-Cmqp7_Mx.js.map → syntaxHighlighting-yTdSle2t.js.map} +1 -1
  75. package/dist/client/chunks/{useDirtyStateTracking-B5g-bw7a.js → useDirtyStateTracking-GZtwGRu7.js} +3 -3
  76. package/dist/client/chunks/{useDirtyStateTracking-B5g-bw7a.js.map → useDirtyStateTracking-GZtwGRu7.js.map} +1 -1
  77. package/dist/client/chunks/{vendor-CJRtj0__.js → vendor-B_H-VRhj.js} +97 -99
  78. package/dist/client/chunks/vendor-B_H-VRhj.js.map +1 -0
  79. package/dist/client/components.js +4 -4
  80. package/dist/client/components.js.map +1 -1
  81. package/dist/client/hooks.js +3 -3
  82. package/dist/client/index.js +10 -10
  83. package/dist/client/index.js.map +1 -1
  84. package/dist/client/providers.js +1 -1
  85. package/dist/client/styles.css +1 -1
  86. package/dist/client/utils.js +6 -6
  87. package/dist/client-bundle-stats.html +1 -1
  88. package/dist/server/index.cjs +20 -20
  89. package/dist/server/index.d.ts +10 -0
  90. package/dist/server/index.js +674 -643
  91. package/package.json +1 -1
  92. package/dist/client/chunks/DashboardEditModal-CVMSvpJ-.js.map +0 -1
  93. package/dist/client/chunks/RetentionCombinedChart-BVKWmxc-.js.map +0 -1
  94. package/dist/client/chunks/RetentionHeatmap-BiqfhGYk.js.map +0 -1
  95. package/dist/client/chunks/analysis-builder-CuTR61Ct.js.map +0 -1
  96. package/dist/client/chunks/analysis-builder-shared-D7iqklYk.js.map +0 -1
  97. package/dist/client/chunks/chart-area-KlBSb_ur.js.map +0 -1
  98. package/dist/client/chunks/chart-bar-D1i2jmIg.js.map +0 -1
  99. package/dist/client/chunks/chart-data-table-CYMMAHau.js.map +0 -1
  100. package/dist/client/chunks/chart-funnel-BH7r4HWZ.js.map +0 -1
  101. package/dist/client/chunks/chart-heat-map-DyGtODLE.js.map +0 -1
  102. package/dist/client/chunks/chart-kpi-delta-Bk396suk.js.map +0 -1
  103. package/dist/client/chunks/chart-kpi-number-CIGqZ5Dw.js.map +0 -1
  104. package/dist/client/chunks/chart-kpi-text-iwlaSQCi.js.map +0 -1
  105. package/dist/client/chunks/chart-line-BKqhoW9A.js.map +0 -1
  106. package/dist/client/chunks/chart-markdown-CiPhRY9s.js.map +0 -1
  107. package/dist/client/chunks/chart-pie-BNr-GgTh.js.map +0 -1
  108. package/dist/client/chunks/chart-radar-CYrGVYEQ.js.map +0 -1
  109. package/dist/client/chunks/chart-radial-bar-2PR3ucIR.js.map +0 -1
  110. package/dist/client/chunks/chart-scatter-D3Z9bl8H.js.map +0 -1
  111. package/dist/client/chunks/chart-tree-map-DCCmMyz1.js.map +0 -1
  112. package/dist/client/chunks/charts-core-DIW3Dd7n.js.map +0 -1
  113. package/dist/client/chunks/vendor-CJRtj0__.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { sql as o, eq as v, and as y, SQL as yE, gte as Te, lte as ae, arrayContained as bE, arrayOverlaps as FE, arrayContains as BE, isNotNull as Ct, ne as lt, or as Ce, isNull as ut, notInArray as Lt, inArray as Ge, lt as ye, gt as be, StringChunk as HE, sum as x, max as q, min as le, count as rt, countDistinct as YE, desc as VE, asc as _t } from "drizzle-orm";
1
+ import { sql as o, eq as X, and as y, SQL as yE, gte as ae, lte as oe, arrayContained as bE, arrayOverlaps as FE, arrayContains as BE, isNotNull as Ct, ne as lt, or as Ce, isNull as ut, notInArray as Lt, inArray as Ge, lt as ye, gt as be, StringChunk as HE, sum as J, max as Z, min as le, count as rt, countDistinct as YE, desc as VE, asc as _t } from "drizzle-orm";
2
2
  class Ue {
3
3
  /**
4
4
  * Default implementation returns template unchanged
@@ -2007,7 +2007,7 @@ function Dt(n, e, t) {
2007
2007
  return ct(n, e);
2008
2008
  throw new Error("Unable to determine database engine type. Please specify engineType parameter.");
2009
2009
  }
2010
- function J(n) {
2010
+ function Q(n) {
2011
2011
  return typeof n == "function" ? n() : n;
2012
2012
  }
2013
2013
  function Tt(n, e) {
@@ -2032,7 +2032,7 @@ function Tt(n, e) {
2032
2032
  function at(n) {
2033
2033
  return n && typeof n == "object" ? o`${o`${n}`}` : n;
2034
2034
  }
2035
- function F(n, e) {
2035
+ function b(n, e) {
2036
2036
  const t = typeof n == "function" ? n(e) : n;
2037
2037
  return at(t);
2038
2038
  }
@@ -2054,12 +2054,12 @@ function Ts(n, e) {
2054
2054
  throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
2055
2055
  const { table: t, sourceKey: E, targetKey: s, securitySql: i } = n.through, r = [];
2056
2056
  for (const R of E) {
2057
- const S = R.as || v;
2057
+ const S = R.as || X;
2058
2058
  r.push(S(R.source, R.target));
2059
2059
  }
2060
2060
  const T = [];
2061
2061
  for (const R of s) {
2062
- const S = R.as || v;
2062
+ const S = R.as || X;
2063
2063
  T.push(S(R.source, R.target));
2064
2064
  }
2065
2065
  let A;
@@ -2174,7 +2174,7 @@ function os(n) {
2174
2174
  return {
2175
2175
  measures: n.measures ? [...n.measures].sort() : void 0,
2176
2176
  dimensions: n.dimensions ? [...n.dimensions].sort() : void 0,
2177
- filters: n.filters ? X(n.filters) : void 0,
2177
+ filters: n.filters ? K(n.filters) : void 0,
2178
2178
  timeDimensions: n.timeDimensions ? Is(n.timeDimensions) : void 0,
2179
2179
  limit: n.limit,
2180
2180
  offset: n.offset,
@@ -2196,7 +2196,7 @@ function As(n) {
2196
2196
  steps: n.steps.map((e) => {
2197
2197
  const t = {
2198
2198
  name: e.name,
2199
- filter: e.filter ? Array.isArray(e.filter) ? X(e.filter) : X([e.filter])[0] : void 0,
2199
+ filter: e.filter ? Array.isArray(e.filter) ? K(e.filter) : K([e.filter])[0] : void 0,
2200
2200
  timeToConvert: e.timeToConvert
2201
2201
  };
2202
2202
  return "cube" in e && e.cube && (t.cube = e.cube), t;
@@ -2213,7 +2213,7 @@ function Rs(n) {
2213
2213
  // Normalize starting step - sort filters for consistent hashing
2214
2214
  startingStep: {
2215
2215
  name: n.startingStep.name,
2216
- filter: n.startingStep.filter ? Array.isArray(n.startingStep.filter) ? X(n.startingStep.filter) : X([n.startingStep.filter])[0] : void 0
2216
+ filter: n.startingStep.filter ? Array.isArray(n.startingStep.filter) ? K(n.startingStep.filter) : K([n.startingStep.filter])[0] : void 0
2217
2217
  },
2218
2218
  // CRITICAL: Include step counts in cache key
2219
2219
  stepsBefore: n.stepsBefore,
@@ -2235,18 +2235,18 @@ function Ss(n) {
2235
2235
  periods: n.periods,
2236
2236
  retentionType: n.retentionType,
2237
2237
  // Normalize filters for consistent hashing
2238
- cohortFilters: n.cohortFilters ? Array.isArray(n.cohortFilters) ? X(n.cohortFilters) : X([n.cohortFilters])[0] : void 0,
2239
- activityFilters: n.activityFilters ? Array.isArray(n.activityFilters) ? X(n.activityFilters) : X([n.activityFilters])[0] : void 0,
2238
+ cohortFilters: n.cohortFilters ? Array.isArray(n.cohortFilters) ? K(n.cohortFilters) : K([n.cohortFilters])[0] : void 0,
2239
+ activityFilters: n.activityFilters ? Array.isArray(n.activityFilters) ? K(n.activityFilters) : K([n.activityFilters])[0] : void 0,
2240
2240
  // Include breakdown dimensions for cache key
2241
2241
  breakdownDimensions: n.breakdownDimensions
2242
2242
  };
2243
2243
  }
2244
- function X(n) {
2244
+ function K(n) {
2245
2245
  return [...n].map((e) => {
2246
2246
  if ("and" in e && e.and)
2247
- return { and: X(e.and) };
2247
+ return { and: K(e.and) };
2248
2248
  if ("or" in e && e.or)
2249
- return { or: X(e.or) };
2249
+ return { or: K(e.or) };
2250
2250
  const t = e;
2251
2251
  return {
2252
2252
  ...t,
@@ -2280,7 +2280,7 @@ function Pt(n) {
2280
2280
  function Qa(n, e) {
2281
2281
  return `${e ?? "drizzle-cube:"}*${n}*`;
2282
2282
  }
2283
- class Ie {
2283
+ class Ne {
2284
2284
  constructor(e) {
2285
2285
  this.databaseAdapter = e;
2286
2286
  }
@@ -2288,7 +2288,7 @@ class Ie {
2288
2288
  * Build time dimension expression with granularity using database adapter
2289
2289
  */
2290
2290
  buildTimeDimensionExpression(e, t, E) {
2291
- const s = F(e, E);
2291
+ const s = b(e, E);
2292
2292
  return t ? this.databaseAdapter.buildTimeDimension(t, s) : s instanceof yE ? s : o`${s}`;
2293
2293
  }
2294
2294
  /**
@@ -2305,8 +2305,8 @@ class Ie {
2305
2305
  r.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? s = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(r.getTime() / 1e3) : r.getTime() : s = r.toISOString();
2306
2306
  }
2307
2307
  return y(
2308
- Te(e, E),
2309
- ae(e, s)
2308
+ ae(e, E),
2309
+ oe(e, s)
2310
2310
  );
2311
2311
  }
2312
2312
  if (typeof t == "string") {
@@ -2314,8 +2314,8 @@ class Ie {
2314
2314
  if (E) {
2315
2315
  let R, S;
2316
2316
  return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (R = Math.floor(E.start.getTime() / 1e3), S = Math.floor(E.end.getTime() / 1e3)) : (R = E.start.getTime(), S = E.end.getTime()) : (R = E.start.toISOString(), S = E.end.toISOString()), y(
2317
- Te(e, R),
2318
- ae(e, S)
2317
+ ae(e, R),
2318
+ oe(e, S)
2319
2319
  );
2320
2320
  }
2321
2321
  const s = this.normalizeDate(t);
@@ -2326,8 +2326,8 @@ class Ie {
2326
2326
  T.setUTCHours(23, 59, 59, 999);
2327
2327
  let A, a;
2328
2328
  return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (A = Math.floor(r.getTime() / 1e3), a = Math.floor(T.getTime() / 1e3)) : (A = r.getTime(), a = T.getTime()) : (A = r.toISOString(), a = T.toISOString()), y(
2329
- Te(e, A),
2330
- ae(e, a)
2329
+ ae(e, A),
2330
+ oe(e, a)
2331
2331
  );
2332
2332
  }
2333
2333
  return null;
@@ -2476,7 +2476,7 @@ class he {
2476
2476
  return Ge(e, r);
2477
2477
  } else if (r.length === 1) {
2478
2478
  const A = s?.type === "time" && this.dateTimeBuilder.normalizeDate(T) || T;
2479
- return v(e, A);
2479
+ return X(e, A);
2480
2480
  }
2481
2481
  return this.databaseAdapter.buildBooleanLiteral(!1);
2482
2482
  case "notEquals":
@@ -2492,11 +2492,11 @@ class he {
2492
2492
  case "gt":
2493
2493
  return be(e, T);
2494
2494
  case "gte":
2495
- return Te(e, T);
2495
+ return ae(e, T);
2496
2496
  case "lt":
2497
2497
  return ye(e, T);
2498
2498
  case "lte":
2499
- return ae(e, T);
2499
+ return oe(e, T);
2500
2500
  case "set":
2501
2501
  return Ct(e);
2502
2502
  case "notSet":
@@ -2512,8 +2512,8 @@ class he {
2512
2512
  I.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? a = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(I.getTime() / 1e3) : I.getTime() : a = I.toISOString();
2513
2513
  }
2514
2514
  return y(
2515
- Te(e, A),
2516
- ae(e, a)
2515
+ ae(e, A),
2516
+ oe(e, a)
2517
2517
  );
2518
2518
  }
2519
2519
  }
@@ -2528,8 +2528,8 @@ class he {
2528
2528
  }
2529
2529
  case "between":
2530
2530
  return r.length >= 2 ? y(
2531
- Te(e, r[0]),
2532
- ae(e, r[1])
2531
+ ae(e, r[0]),
2532
+ oe(e, r[1])
2533
2533
  ) : null;
2534
2534
  case "notBetween":
2535
2535
  return r.length >= 2 ? Ce(
@@ -2553,7 +2553,7 @@ class he {
2553
2553
  case "isEmpty":
2554
2554
  return Ce(
2555
2555
  ut(e),
2556
- v(e, "")
2556
+ X(e, "")
2557
2557
  );
2558
2558
  case "isNotEmpty":
2559
2559
  return y(
@@ -2598,7 +2598,7 @@ class he {
2598
2598
  if (!T) return null;
2599
2599
  const A = T.dimensions?.[r];
2600
2600
  if (!A) return null;
2601
- const a = F(A.sql, E);
2601
+ const a = b(A.sql, E);
2602
2602
  return this.buildFilterCondition(
2603
2603
  a,
2604
2604
  s.operator,
@@ -2608,7 +2608,7 @@ class he {
2608
2608
  );
2609
2609
  }
2610
2610
  }
2611
- class te {
2611
+ class se {
2612
2612
  dependencyGraph;
2613
2613
  cubes;
2614
2614
  constructor(e) {
@@ -2836,13 +2836,13 @@ function Ns(n, e) {
2836
2836
  throw new Error(
2837
2837
  `Cannot substitute {${I}}: cube '${C}' not found`
2838
2838
  );
2839
- const l = `${C}.${O}`, c = s.get(l);
2840
- if (!c)
2839
+ const l = `${C}.${O}`, _ = s.get(l);
2840
+ if (!_)
2841
2841
  throw new Error(
2842
2842
  `Cannot substitute {${I}}: measure '${l}' not resolved yet. Ensure measures are resolved in dependency order.`
2843
2843
  );
2844
- const D = c(), p = o`${D}`;
2845
- r.set(I, p);
2844
+ const U = _(), D = o`${U}`;
2845
+ r.set(I, D);
2846
2846
  }
2847
2847
  const T = [], A = [];
2848
2848
  let a = 0;
@@ -2914,7 +2914,7 @@ function Fe(n, e) {
2914
2914
  }
2915
2915
  return Array.from(E);
2916
2916
  }
2917
- class B {
2917
+ class H {
2918
2918
  constructor(e) {
2919
2919
  this.databaseAdapter = e;
2920
2920
  }
@@ -2930,23 +2930,23 @@ class B {
2930
2930
  * @returns Map of measure names to SQL builder functions
2931
2931
  */
2932
2932
  buildResolvedMeasures(e, t, E, s) {
2933
- const i = /* @__PURE__ */ new Map(), r = [], T = [], A = new Set(e), a = new te(t);
2933
+ const i = /* @__PURE__ */ new Map(), r = [], T = [], A = new Set(e), a = new se(t);
2934
2934
  for (const R of t.values())
2935
2935
  a.buildGraph(R);
2936
2936
  for (const R of e) {
2937
2937
  const [S, I] = R.split("."), N = t.get(S);
2938
2938
  if (N && N.measures && N.measures[I]) {
2939
2939
  const O = N.measures[I];
2940
- if (B.isPostAggregationWindow(O)) {
2941
- const C = B.getWindowBaseMeasure(O, S);
2940
+ if (H.isPostAggregationWindow(O)) {
2941
+ const C = H.getWindowBaseMeasure(O, S);
2942
2942
  C && A.add(C);
2943
2943
  continue;
2944
2944
  }
2945
- te.isCalculatedMeasure(O) ? (T.push(R), Fe(O.calculatedSql, S).forEach((l) => A.add(l)), a.getAllDependencies(R).forEach((l) => {
2946
- const [c, D] = l.split("."), p = t.get(c);
2947
- if (p && p.measures[D]) {
2948
- const m = p.measures[D];
2949
- te.isCalculatedMeasure(m) && Fe(m.calculatedSql, c).forEach((M) => A.add(M));
2945
+ se.isCalculatedMeasure(O) ? (T.push(R), Fe(O.calculatedSql, S).forEach((l) => A.add(l)), a.getAllDependencies(R).forEach((l) => {
2946
+ const [_, U] = l.split("."), D = t.get(_);
2947
+ if (D && D.measures[U]) {
2948
+ const m = D.measures[U];
2949
+ se.isCalculatedMeasure(m) && Fe(m.calculatedSql, _).forEach((M) => A.add(M));
2950
2950
  }
2951
2951
  })) : r.push(R);
2952
2952
  }
@@ -2955,9 +2955,9 @@ class B {
2955
2955
  const [S, I] = R.split("."), N = t.get(S);
2956
2956
  if (N && N.measures && N.measures[I]) {
2957
2957
  const O = N.measures[I];
2958
- if (B.isPostAggregationWindow(O))
2958
+ if (H.isPostAggregationWindow(O))
2959
2959
  continue;
2960
- te.isCalculatedMeasure(O) ? T.includes(R) || T.push(R) : r.includes(R) || r.push(R);
2960
+ se.isCalculatedMeasure(O) ? T.includes(R) || T.push(R) : r.includes(R) || r.push(R);
2961
2961
  }
2962
2962
  }
2963
2963
  for (const R of r) {
@@ -3030,7 +3030,7 @@ class B {
3030
3030
  case "count":
3031
3031
  case "countDistinct":
3032
3032
  case "sum":
3033
- O = x(N);
3033
+ O = J(N);
3034
3034
  break;
3035
3035
  case "avg":
3036
3036
  O = this.databaseAdapter.buildAvg(N);
@@ -3039,13 +3039,13 @@ class B {
3039
3039
  O = le(N);
3040
3040
  break;
3041
3041
  case "max":
3042
- O = q(N);
3042
+ O = Z(N);
3043
3043
  break;
3044
3044
  case "number":
3045
- O = x(N);
3045
+ O = J(N);
3046
3046
  break;
3047
3047
  default:
3048
- O = x(N);
3048
+ O = J(N);
3049
3049
  }
3050
3050
  r.set(A, () => O);
3051
3051
  }
@@ -3087,17 +3087,17 @@ class B {
3087
3087
  case "count":
3088
3088
  case "countDistinct":
3089
3089
  case "sum":
3090
- return x(T);
3090
+ return J(T);
3091
3091
  case "avg":
3092
3092
  return this.databaseAdapter.buildAvg(T);
3093
3093
  case "min":
3094
3094
  return le(T);
3095
3095
  case "max":
3096
- return q(T);
3096
+ return Z(T);
3097
3097
  case "number":
3098
- return x(T);
3098
+ return J(T);
3099
3099
  default:
3100
- return x(T);
3100
+ return J(T);
3101
3101
  }
3102
3102
  }
3103
3103
  }
@@ -3116,7 +3116,7 @@ class B {
3116
3116
  throw new Error(
3117
3117
  `Cannot build calculated measure '${e.name}' directly. Use buildCalculatedMeasure instead.`
3118
3118
  );
3119
- if (B.isPostAggregationWindow(e))
3119
+ if (H.isPostAggregationWindow(e))
3120
3120
  throw new Error(
3121
3121
  `Post-aggregation window measure '${e.name}' should be built via buildPostAggregationWindowExpression, not buildMeasureExpression.`
3122
3122
  );
@@ -3124,7 +3124,7 @@ class B {
3124
3124
  throw new Error(
3125
3125
  `Measure '${e.name}' of type '${e.type}' is missing required 'sql' property. Only calculated measures and post-aggregation window functions can omit 'sql'.`
3126
3126
  );
3127
- let s = F(e.sql, t);
3127
+ let s = b(e.sql, t);
3128
3128
  if (e.filters && e.filters.length > 0) {
3129
3129
  const i = e.filters.map((r) => {
3130
3130
  const T = r(t);
@@ -3143,13 +3143,13 @@ class B {
3143
3143
  case "countDistinct":
3144
3144
  return YE(s);
3145
3145
  case "sum":
3146
- return x(s);
3146
+ return J(s);
3147
3147
  case "avg":
3148
3148
  return this.databaseAdapter.buildAvg(s);
3149
3149
  case "min":
3150
3150
  return le(s);
3151
3151
  case "max":
3152
- return q(s);
3152
+ return Z(s);
3153
3153
  case "number":
3154
3154
  return s;
3155
3155
  // Statistical functions (Phase 1)
@@ -3200,7 +3200,7 @@ class B {
3200
3200
  if (i.partitionBy && i.partitionBy.length > 0 && E) {
3201
3201
  const a = i.partitionBy.map((R) => {
3202
3202
  const S = R.includes(".") ? R.split(".")[1] : R, I = E.dimensions?.[S];
3203
- return I ? F(I.sql, t) : (console.warn(`[drizzle-cube] Window function partition dimension '${R}' not found in cube '${E.name}'`), null);
3203
+ return I ? b(I.sql, t) : (console.warn(`[drizzle-cube] Window function partition dimension '${R}' not found in cube '${E.name}'`), null);
3204
3204
  }).filter((R) => R !== null);
3205
3205
  a.length > 0 && (r = a);
3206
3206
  }
@@ -3210,12 +3210,12 @@ class B {
3210
3210
  const S = R.field.includes(".") ? R.field.split(".")[1] : R.field, I = E.dimensions?.[S];
3211
3211
  if (I)
3212
3212
  return {
3213
- field: F(I.sql, t),
3213
+ field: b(I.sql, t),
3214
3214
  direction: R.direction
3215
3215
  };
3216
3216
  const N = E.measures?.[S];
3217
3217
  return N && N.sql ? {
3218
- field: F(N.sql, t),
3218
+ field: b(N.sql, t),
3219
3219
  direction: R.direction
3220
3220
  } : (console.warn(`[drizzle-cube] Window function order field '${R.field}' not found in cube '${E.name}'`), null);
3221
3221
  }).filter((R) => R !== null);
@@ -3264,7 +3264,7 @@ class B {
3264
3264
  * @returns true if this is a window function type
3265
3265
  */
3266
3266
  static isWindowFunction(e) {
3267
- return B.WINDOW_FUNCTION_TYPES.includes(e);
3267
+ return H.WINDOW_FUNCTION_TYPES.includes(e);
3268
3268
  }
3269
3269
  /**
3270
3270
  * Categorize measures into window functions and regular aggregates
@@ -3280,7 +3280,7 @@ class B {
3280
3280
  const [r, T] = i.split("."), A = t.get(r);
3281
3281
  if (A?.measures?.[T]) {
3282
3282
  const a = A.measures[T];
3283
- B.isWindowFunction(a.type) ? E.push(i) : s.push(i);
3283
+ H.isWindowFunction(a.type) ? E.push(i) : s.push(i);
3284
3284
  }
3285
3285
  }
3286
3286
  return { windowMeasures: E, aggregateMeasures: s };
@@ -3292,7 +3292,7 @@ class B {
3292
3292
  * @returns true if any measure is a window function
3293
3293
  */
3294
3294
  static hasWindowFunctions(e, t) {
3295
- const { windowMeasures: E } = B.categorizeMeasures(e, t);
3295
+ const { windowMeasures: E } = H.categorizeMeasures(e, t);
3296
3296
  return E.length > 0;
3297
3297
  }
3298
3298
  // ============================================================================
@@ -3307,7 +3307,7 @@ class B {
3307
3307
  * @returns true if this is a post-aggregation window function
3308
3308
  */
3309
3309
  static isPostAggregationWindow(e) {
3310
- return B.isWindowFunction(e.type) && e.windowConfig?.measure !== void 0;
3310
+ return H.isWindowFunction(e.type) && e.windowConfig?.measure !== void 0;
3311
3311
  }
3312
3312
  /**
3313
3313
  * Get the base measure reference for a post-aggregation window function.
@@ -3358,11 +3358,11 @@ class B {
3358
3358
  const [T, A] = r.split("."), a = t.get(T);
3359
3359
  if (a?.measures?.[A]) {
3360
3360
  const R = a.measures[A];
3361
- if (B.isPostAggregationWindow(R)) {
3361
+ if (H.isPostAggregationWindow(R)) {
3362
3362
  s.push(r);
3363
- const S = B.getWindowBaseMeasure(R, T);
3363
+ const S = H.getWindowBaseMeasure(R, T);
3364
3364
  S && i.add(S);
3365
- } else B.isWindowFunction(R.type) || E.push(r);
3365
+ } else H.isWindowFunction(R.type) || E.push(r);
3366
3366
  }
3367
3367
  }
3368
3368
  return { aggregateMeasures: E, postAggWindowMeasures: s, requiredBaseMeasures: i };
@@ -3375,7 +3375,7 @@ class B {
3375
3375
  * @returns true if any measure is a post-aggregation window function
3376
3376
  */
3377
3377
  static hasPostAggregationWindows(e, t) {
3378
- const { postAggWindowMeasures: E } = B.categorizeForPostAggregation(
3378
+ const { postAggWindowMeasures: E } = H.categorizeForPostAggregation(
3379
3379
  e,
3380
3380
  t
3381
3381
  );
@@ -3447,11 +3447,11 @@ class Cs {
3447
3447
  R = !0;
3448
3448
  break;
3449
3449
  }
3450
- if (B.isPostAggregationWindow(C)) {
3451
- const u = B.getWindowBaseMeasure(C, I);
3450
+ if (H.isPostAggregationWindow(C)) {
3451
+ const u = H.getWindowBaseMeasure(C, I);
3452
3452
  if (u) {
3453
- const [l, c] = u.split("."), p = r.get(l)?.measures?.[c];
3454
- if (p && this.isAggregateFunctionType(p.type)) {
3453
+ const [l, _] = u.split("."), D = r.get(l)?.measures?.[_];
3454
+ if (D && this.isAggregateFunctionType(D.type)) {
3455
3455
  R = !0;
3456
3456
  break;
3457
3457
  }
@@ -3466,15 +3466,15 @@ class Cs {
3466
3466
  const [I, N] = S.split("."), O = r.get(I);
3467
3467
  if (O && O.dimensions && O.dimensions[N])
3468
3468
  if (s?.preAggregationCTEs?.some((u) => u.cube.name === I)) {
3469
- const u = s.preAggregationCTEs.find((c) => c.cube.name === I), l = u.joinKeys.find((c) => c.targetColumn === N);
3469
+ const u = s.preAggregationCTEs.find((_) => _.cube.name === I), l = u.joinKeys.find((_) => _.targetColumn === N);
3470
3470
  if (l && l.sourceColumnObj)
3471
3471
  i.push(l.sourceColumnObj);
3472
3472
  else {
3473
- const c = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
3474
- i.push(c);
3473
+ const _ = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
3474
+ i.push(_);
3475
3475
  }
3476
3476
  } else {
3477
- const u = O.dimensions[N], l = F(u.sql, E);
3477
+ const u = O.dimensions[N], l = b(u.sql, E);
3478
3478
  i.push(l);
3479
3479
  }
3480
3480
  }
@@ -3483,17 +3483,17 @@ class Cs {
3483
3483
  const [I, N] = S.dimension.split("."), O = r.get(I);
3484
3484
  if (O && O.dimensions && O.dimensions[N])
3485
3485
  if (s?.preAggregationCTEs?.some((u) => u.cube.name === I)) {
3486
- const u = s.preAggregationCTEs.find((c) => c.cube.name === I), l = u.joinKeys.find((c) => c.targetColumn === N);
3486
+ const u = s.preAggregationCTEs.find((_) => _.cube.name === I), l = u.joinKeys.find((_) => _.targetColumn === N);
3487
3487
  if (l && l.sourceColumnObj) {
3488
- const c = this.dateTimeBuilder.buildTimeDimensionExpression(
3488
+ const _ = this.dateTimeBuilder.buildTimeDimensionExpression(
3489
3489
  l.sourceColumnObj,
3490
3490
  S.granularity,
3491
3491
  E
3492
3492
  );
3493
- i.push(c);
3493
+ i.push(_);
3494
3494
  } else {
3495
- const c = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
3496
- i.push(c);
3495
+ const _ = o`${o.identifier(u.cteAlias)}.${o.identifier(N)}`;
3496
+ i.push(_);
3497
3497
  }
3498
3498
  } else {
3499
3499
  const u = O.dimensions[N], l = this.dateTimeBuilder.buildTimeDimensionExpression(
@@ -3513,7 +3513,7 @@ class ls {
3513
3513
  groupByBuilder;
3514
3514
  measureBuilder;
3515
3515
  constructor(e) {
3516
- this.dateTimeBuilder = new Ie(e), this.filterBuilder = new he(e, this.dateTimeBuilder), this.groupByBuilder = new Cs(this.dateTimeBuilder), this.measureBuilder = new B(e);
3516
+ this.dateTimeBuilder = new Ne(e), this.filterBuilder = new he(e, this.dateTimeBuilder), this.groupByBuilder = new Cs(this.dateTimeBuilder), this.measureBuilder = new H(e);
3517
3517
  }
3518
3518
  /**
3519
3519
  * Build resolvedMeasures map for a set of measures
@@ -3533,7 +3533,7 @@ class ls {
3533
3533
  for (const r of t.dimensions) {
3534
3534
  const [T, A] = r.split("."), a = i.get(T);
3535
3535
  if (a && a.dimensions && a.dimensions[A]) {
3536
- const R = a.dimensions[A], S = F(R.sql, E);
3536
+ const R = a.dimensions[A], S = b(R.sql, E);
3537
3537
  s[r] = o`${S}`.as(r);
3538
3538
  }
3539
3539
  }
@@ -3634,7 +3634,7 @@ class ls {
3634
3634
  continue;
3635
3635
  }
3636
3636
  }
3637
- const N = I.dimensions[S], O = F(N.sql, E), C = this.buildDateRangeCondition(O, a.dateRange);
3637
+ const N = I.dimensions[S], O = b(N.sql, E), C = this.buildDateRangeCondition(O, a.dateRange);
3638
3638
  C && r.push(C);
3639
3639
  }
3640
3640
  }
@@ -3682,7 +3682,7 @@ class ls {
3682
3682
  if (u)
3683
3683
  return u;
3684
3684
  }
3685
- const O = N ? typeof R.sql == "function" ? R.sql(E) : R.sql : F(R.sql, E);
3685
+ const O = N ? typeof R.sql == "function" ? R.sql(E) : R.sql : b(R.sql, E);
3686
3686
  return this.buildFilterCondition(
3687
3687
  O,
3688
3688
  r.operator,
@@ -3835,7 +3835,7 @@ class ue {
3835
3835
  const { cube: A, path: a } = r.shift(), R = this.cubes.get(A);
3836
3836
  if (R?.joins)
3837
3837
  for (const [, S] of Object.entries(R.joins)) {
3838
- const N = J(S.targetCube).name;
3838
+ const N = Q(S.targetCube).name;
3839
3839
  if (T.has(N))
3840
3840
  continue;
3841
3841
  const O = [
@@ -3915,7 +3915,7 @@ class ue {
3915
3915
  const R = this.cubes.get(T);
3916
3916
  if (R?.joins)
3917
3917
  for (const [, S] of Object.entries(R.joins)) {
3918
- const N = J(S.targetCube).name;
3918
+ const N = Q(S.targetCube).name;
3919
3919
  if (a.has(N))
3920
3920
  continue;
3921
3921
  const O = [
@@ -3963,7 +3963,7 @@ class ue {
3963
3963
  buildJoinCondition(e, t, E) {
3964
3964
  const s = [];
3965
3965
  for (const i of e.on) {
3966
- const r = t ? o`${o.identifier(t)}.${o.identifier(i.source.name)}` : at(i.source), T = E ? o`${o.identifier(E)}.${o.identifier(i.target.name)}` : at(i.target), A = i.as || v;
3966
+ const r = t ? o`${o.identifier(t)}.${o.identifier(i.source.name)}` : at(i.source), T = E ? o`${o.identifier(E)}.${o.identifier(i.target.name)}` : at(i.target), A = i.as || X;
3967
3967
  s.push(A(r, T));
3968
3968
  }
3969
3969
  return y(...s);
@@ -3981,7 +3981,7 @@ class ue {
3981
3981
  const s = E.shift(), i = this.cubes.get(s);
3982
3982
  if (i?.joins)
3983
3983
  for (const [, r] of Object.entries(i.joins)) {
3984
- const A = J(r.targetCube).name;
3984
+ const A = Q(r.targetCube).name;
3985
3985
  t.has(A) || (t.add(A), E.push(A));
3986
3986
  }
3987
3987
  }
@@ -4165,35 +4165,35 @@ class CE {
4165
4165
  if (!l)
4166
4166
  throw new Error(`Cube '${C}' not found`);
4167
4167
  if (u.relationship === "belongsToMany" && u.through) {
4168
- const c = Ts(u, s.securityContext);
4168
+ const _ = Ts(u, s.securityContext);
4169
4169
  T.push({
4170
4170
  cube: l,
4171
4171
  alias: `${C.toLowerCase()}_cube`,
4172
- joinType: c.junctionJoins[1].joinType,
4172
+ joinType: _.junctionJoins[1].joinType,
4173
4173
  // Use the target join type
4174
- joinCondition: c.junctionJoins[1].condition,
4174
+ joinCondition: _.junctionJoins[1].condition,
4175
4175
  // Target join condition
4176
4176
  junctionTable: {
4177
4177
  table: u.through.table,
4178
4178
  alias: `junction_${C.toLowerCase()}`,
4179
- joinType: c.junctionJoins[0].joinType,
4180
- joinCondition: c.junctionJoins[0].condition,
4179
+ joinType: _.junctionJoins[0].joinType,
4180
+ joinCondition: _.junctionJoins[0].condition,
4181
4181
  securitySql: u.through.securitySql
4182
4182
  }
4183
4183
  });
4184
4184
  } else {
4185
- const c = r.buildJoinCondition(
4185
+ const _ = r.buildJoinCondition(
4186
4186
  u,
4187
4187
  null,
4188
4188
  // No source alias needed - use the actual column
4189
4189
  null
4190
4190
  // No target alias needed - use the actual column
4191
- ), D = Tt(u.relationship, u.sqlJoinType);
4191
+ ), U = Tt(u.relationship, u.sqlJoinType);
4192
4192
  T.push({
4193
4193
  cube: l,
4194
4194
  alias: `${C.toLowerCase()}_cube`,
4195
- joinType: D,
4196
- joinCondition: c
4195
+ joinType: U,
4196
+ joinCondition: _
4197
4197
  });
4198
4198
  }
4199
4199
  A.add(C);
@@ -4252,14 +4252,14 @@ class CE {
4252
4252
  if (u.length === 0)
4253
4253
  continue;
4254
4254
  const l = this.analyzeJoinPathToPrimary(e, t, R.name, i);
4255
- let c, D;
4255
+ let _, U;
4256
4256
  if (l?.hasIntermediateHasMany && l.intermediateJoins.length > 0)
4257
- c = l.correctJoinKeys, D = l.intermediateJoins;
4257
+ _ = l.correctJoinKeys, U = l.intermediateJoins;
4258
4258
  else {
4259
4259
  const h = I ? this.findJoinInfoToCube(e, t.name) : this.findJoinInfoForCube(e, t, R.name);
4260
4260
  if (!h)
4261
4261
  continue;
4262
- c = I ? h.joinDef.on.map((G) => ({
4262
+ _ = I ? h.joinDef.on.map((G) => ({
4263
4263
  sourceColumn: G.target.name,
4264
4264
  targetColumn: G.source.name,
4265
4265
  sourceColumnObj: G.target,
@@ -4269,9 +4269,9 @@ class CE {
4269
4269
  targetColumn: G.target.name,
4270
4270
  sourceColumnObj: G.source,
4271
4271
  targetColumnObj: G.target
4272
- })), D = void 0;
4272
+ })), U = void 0;
4273
4273
  }
4274
- const p = this.findPropagatingFilters(s, R, e), m = /* @__PURE__ */ new Map([[R.name, R]]), { aggregateMeasures: P, requiredBaseMeasures: M } = B.categorizeForPostAggregation(
4274
+ const D = this.findPropagatingFilters(s, R, e), m = /* @__PURE__ */ new Map([[R.name, R]]), { aggregateMeasures: P, requiredBaseMeasures: M } = H.categorizeForPostAggregation(
4275
4275
  u,
4276
4276
  m
4277
4277
  ), g = [.../* @__PURE__ */ new Set([
@@ -4291,11 +4291,11 @@ class CE {
4291
4291
  cube: R,
4292
4292
  alias: S,
4293
4293
  cteAlias: `${R.name.toLowerCase()}_agg`,
4294
- joinKeys: c,
4294
+ joinKeys: _,
4295
4295
  measures: h,
4296
- propagatingFilters: p.length > 0 ? p : void 0,
4296
+ propagatingFilters: D.length > 0 ? D : void 0,
4297
4297
  downstreamJoinKeys: G.length > 0 ? G : void 0,
4298
- intermediateJoins: D && D.length > 0 ? D : void 0,
4298
+ intermediateJoins: U && U.length > 0 ? U : void 0,
4299
4299
  cteType: "aggregate",
4300
4300
  cteReason: N
4301
4301
  });
@@ -4311,7 +4311,7 @@ class CE {
4311
4311
  for (const [, E] of e)
4312
4312
  if (E.name !== t && E.joins) {
4313
4313
  for (const [, s] of Object.entries(E.joins))
4314
- if (J(s.targetCube).name === t)
4314
+ if (Q(s.targetCube).name === t)
4315
4315
  return { sourceCube: E, joinDef: s };
4316
4316
  }
4317
4317
  return null;
@@ -4351,13 +4351,13 @@ class CE {
4351
4351
  for (let N = 0; N < T.length - 1; N++) {
4352
4352
  const O = T[N], C = T[N + 1], u = e.get(O.toCube);
4353
4353
  if (!u) continue;
4354
- const c = u.sql(s).where, D = C.joinDef.on[0]?.source, p = O.joinDef.on[0]?.target;
4354
+ const _ = u.sql(s).where, U = C.joinDef.on[0]?.source, D = O.joinDef.on[0]?.target;
4355
4355
  R.push({
4356
4356
  cube: u,
4357
4357
  joinDef: C.joinDef,
4358
- securityFilter: c,
4359
- primaryJoinColumn: p,
4360
- cteJoinColumn: D
4358
+ securityFilter: _,
4359
+ primaryJoinColumn: D,
4360
+ cteJoinColumn: U
4361
4361
  });
4362
4362
  }
4363
4363
  const I = T[0].joinDef.on.map((N) => ({
@@ -4396,7 +4396,7 @@ class CE {
4396
4396
  if (!i.has(T) && (i.add(T), !!A.joins)) {
4397
4397
  for (const [, a] of Object.entries(A.joins))
4398
4398
  if (a.relationship === "hasMany") {
4399
- const R = J(a.targetCube);
4399
+ const R = Q(a.targetCube);
4400
4400
  (r.has(T) || r.has(R.name)) && s.push({
4401
4401
  fromCube: T,
4402
4402
  toCube: R.name,
@@ -4437,13 +4437,13 @@ class CE {
4437
4437
  findJoinInfoForCube(e, t, E) {
4438
4438
  if (t.joins) {
4439
4439
  for (const [, s] of Object.entries(t.joins))
4440
- if (J(s.targetCube).name === E)
4440
+ if (Q(s.targetCube).name === E)
4441
4441
  return { sourceCube: t, joinDef: s };
4442
4442
  }
4443
4443
  for (const [, s] of e)
4444
4444
  if (s.name !== t.name && s.joins) {
4445
4445
  for (const [, i] of Object.entries(s.joins))
4446
- if (J(i.targetCube).name === E)
4446
+ if (Q(i.targetCube).name === E)
4447
4447
  return { sourceCube: s, joinDef: i };
4448
4448
  }
4449
4449
  return null;
@@ -4475,7 +4475,7 @@ class CE {
4475
4475
  }
4476
4476
  if (e.joins)
4477
4477
  for (const [, r] of Object.entries(e.joins)) {
4478
- const A = J(r.targetCube).name;
4478
+ const A = Q(r.targetCube).name;
4479
4479
  if (i.has(A)) {
4480
4480
  const a = r.on.map((R) => ({
4481
4481
  sourceColumn: R.source.name,
@@ -4531,7 +4531,7 @@ class CE {
4531
4531
  if (!e.joins)
4532
4532
  return null;
4533
4533
  for (const [, E] of Object.entries(e.joins))
4534
- if (J(E.targetCube).name === t && E.relationship === "hasMany")
4534
+ if (Q(E.targetCube).name === t && E.relationship === "hasMany")
4535
4535
  return E;
4536
4536
  return null;
4537
4537
  }
@@ -4559,7 +4559,7 @@ class CE {
4559
4559
  const T = E.get(r);
4560
4560
  if (T?.joins) {
4561
4561
  for (const [, A] of Object.entries(T.joins))
4562
- if (J(A.targetCube).name === t.name && A.relationship === "hasMany") {
4562
+ if (Q(A.targetCube).name === t.name && A.relationship === "hasMany") {
4563
4563
  const R = this.extractFiltersForCube(e.filters, r), S = this.extractTimeDimensionFiltersForCube(e, r), I = [...R, ...S];
4564
4564
  I.length > 0 && A.on.length > 0 && s.push({
4565
4565
  sourceCube: T,
@@ -4727,7 +4727,7 @@ class CE {
4727
4727
  const u = e.get(C);
4728
4728
  u && N.set(C, u);
4729
4729
  }
4730
- const O = B.hasPostAggregationWindows(
4730
+ const O = H.hasPostAggregationWindows(
4731
4731
  t.measures || [],
4732
4732
  N
4733
4733
  );
@@ -4859,26 +4859,26 @@ class CE {
4859
4859
  if (!A)
4860
4860
  continue;
4861
4861
  const a = s.measures.filter(
4862
- (c) => c.startsWith(r + ".")
4862
+ (_) => _.startsWith(r + ".")
4863
4863
  ), R = this.extractMeasuresFromFilters(s, A), S = [.../* @__PURE__ */ new Set([...a, ...R])];
4864
4864
  if (S.length === 0)
4865
4865
  continue;
4866
- const I = T.on.map((c) => ({
4867
- sourceColumn: c.source.name,
4868
- targetColumn: c.target.name
4869
- })), N = /* @__PURE__ */ new Map([[r, A]]), { aggregateMeasures: O, postAggWindowMeasures: C, requiredBaseMeasures: u } = B.categorizeForPostAggregation(
4866
+ const I = T.on.map((_) => ({
4867
+ sourceColumn: _.source.name,
4868
+ targetColumn: _.target.name
4869
+ })), N = /* @__PURE__ */ new Map([[r, A]]), { aggregateMeasures: O, postAggWindowMeasures: C, requiredBaseMeasures: u } = H.categorizeForPostAggregation(
4870
4870
  S,
4871
4871
  N
4872
4872
  ), l = [.../* @__PURE__ */ new Set([
4873
4873
  ...O,
4874
- ...Array.from(u).filter((c) => c.startsWith(r + "."))
4874
+ ...Array.from(u).filter((_) => _.startsWith(r + "."))
4875
4875
  ])];
4876
4876
  if (l.length > 0) {
4877
- const c = C.length > 0;
4877
+ const _ = C.length > 0;
4878
4878
  i.push({
4879
4879
  cubeName: r,
4880
4880
  cteAlias: `${r.toLowerCase()}_agg`,
4881
- reason: c ? `hasMany relationship from ${t.name} - requires pre-aggregation; includes base measures for post-aggregation window functions` : `hasMany relationship from ${t.name} - requires pre-aggregation to prevent row duplication (fan-out)`,
4881
+ reason: _ ? `hasMany relationship from ${t.name} - requires pre-aggregation; includes base measures for post-aggregation window functions` : `hasMany relationship from ${t.name} - requires pre-aggregation to prevent row duplication (fan-out)`,
4882
4882
  reasonType: "hasMany",
4883
4883
  measures: l,
4884
4884
  joinKeys: I,
@@ -5002,7 +5002,7 @@ class us {
5002
5002
  let N = E.db.select(a).from(T.from);
5003
5003
  if (A && e.intermediateJoins)
5004
5004
  for (const m of e.intermediateJoins) {
5005
- const P = m.cube.sql(E), g = [v(m.cteJoinColumn, m.joinDef.on[0]?.target)];
5005
+ const P = m.cube.sql(E), g = [X(m.cteJoinColumn, m.joinDef.on[0]?.target)];
5006
5006
  m.securityFilter && g.push(m.securityFilter), N = N.leftJoin(
5007
5007
  P.from,
5008
5008
  y(...g)
@@ -5027,8 +5027,8 @@ class us {
5027
5027
  if (M === R && r.dimensions && r.dimensions[g]) {
5028
5028
  const h = r.dimensions[g];
5029
5029
  if (P.operator === "inDateRange") {
5030
- const G = this.queryBuilder.buildMeasureExpression({ sql: h.sql, type: "number" }, E), b = this.queryBuilder.buildDateRangeCondition(G, P.values);
5031
- b && u.push(b);
5030
+ const G = this.queryBuilder.buildMeasureExpression({ sql: h.sql, type: "number" }, E), B = this.queryBuilder.buildDateRangeCondition(G, P.values);
5031
+ B && u.push(B);
5032
5032
  }
5033
5033
  }
5034
5034
  }
@@ -5046,26 +5046,26 @@ class us {
5046
5046
  const m = l.length === 1 ? l[0] : y(...l);
5047
5047
  N = N.where(m);
5048
5048
  }
5049
- const c = [], D = /* @__PURE__ */ new Set(), p = (m) => {
5049
+ const _ = [], U = /* @__PURE__ */ new Set(), D = (m) => {
5050
5050
  const P = m?.name || (typeof m == "string" ? m : null);
5051
- P && !D.has(P) ? (D.add(P), c.push(m)) : P || c.push(m);
5051
+ P && !U.has(P) ? (U.add(P), _.push(m)) : P || _.push(m);
5052
5052
  };
5053
5053
  if (A && e.intermediateJoins) {
5054
5054
  const m = e.intermediateJoins[0];
5055
- m.primaryJoinColumn && p(m.primaryJoinColumn);
5055
+ m.primaryJoinColumn && D(m.primaryJoinColumn);
5056
5056
  } else
5057
5057
  for (const m of e.joinKeys)
5058
- m.targetColumnObj && p(m.targetColumnObj);
5058
+ m.targetColumnObj && D(m.targetColumnObj);
5059
5059
  if (e.downstreamJoinKeys)
5060
5060
  for (const m of e.downstreamJoinKeys)
5061
5061
  for (const P of m.joinKeys)
5062
- P.sourceColumnObj && p(P.sourceColumnObj);
5062
+ P.sourceColumnObj && D(P.sourceColumnObj);
5063
5063
  if (t.dimensions)
5064
5064
  for (const m of t.dimensions) {
5065
5065
  const [P, M] = m.split(".");
5066
5066
  if (P === R && r.dimensions && r.dimensions[M]) {
5067
- const g = r.dimensions[M], h = F(g.sql, E);
5068
- c.push(h);
5067
+ const g = r.dimensions[M], h = b(g.sql, E);
5068
+ _.push(h);
5069
5069
  }
5070
5070
  }
5071
5071
  if (t.timeDimensions)
@@ -5073,10 +5073,10 @@ class us {
5073
5073
  const [P, M] = m.dimension.split(".");
5074
5074
  if (P === R && r.dimensions && r.dimensions[M]) {
5075
5075
  const g = r.dimensions[M], h = this.queryBuilder.buildTimeDimensionExpression(g.sql, m.granularity, E);
5076
- c.push(h);
5076
+ _.push(h);
5077
5077
  }
5078
5078
  }
5079
- return c.length > 0 && (N = N.groupBy(...c)), E.db.$with(e.cteAlias).as(N);
5079
+ return _.length > 0 && (N = N.groupBy(..._)), E.db.$with(e.cteAlias).as(N);
5080
5080
  }
5081
5081
  /**
5082
5082
  * Build join condition for CTE
@@ -5096,11 +5096,11 @@ class us {
5096
5096
  const i = [];
5097
5097
  if (s.intermediateJoins && s.intermediateJoins.length > 0) {
5098
5098
  const r = s.intermediateJoins[0], T = s.joinKeys[0]?.sourceColumnObj, A = o`${o.identifier(t)}.${o.identifier(r.primaryJoinColumn.name)}`;
5099
- i.push(v(T, A));
5099
+ i.push(X(T, A));
5100
5100
  } else
5101
5101
  for (const r of s.joinKeys) {
5102
5102
  const T = r.sourceColumnObj || o.identifier(r.sourceColumn), A = o`${o.identifier(t)}.${o.identifier(r.targetColumn)}`;
5103
- i.push(v(T, A));
5103
+ i.push(X(T, A));
5104
5104
  }
5105
5105
  return i.length === 1 ? i[0] : y(...i);
5106
5106
  }
@@ -5136,7 +5136,7 @@ class us {
5136
5136
  const { source: A, target: a } = T[0], R = t.db.select({ pk: A }).from(s.from).where(r);
5137
5137
  return o`${a} IN ${R}`;
5138
5138
  } else {
5139
- const A = T.map((S) => v(S.source, S.target)), a = y(
5139
+ const A = T.map((S) => X(S.source, S.target)), a = y(
5140
5140
  ...A,
5141
5141
  r
5142
5142
  ), R = t.db.select({ one: o`1` }).from(s.from).where(a);
@@ -5251,10 +5251,10 @@ function Ds(n, e) {
5251
5251
  [t]: C
5252
5252
  };
5253
5253
  if (N)
5254
- for (const c of T)
5255
- l[c] = N[c];
5256
- for (const c of r)
5257
- l[c] = i;
5254
+ for (const _ of T)
5255
+ l[_] = N[_];
5256
+ for (const _ of r)
5257
+ l[_] = i;
5258
5258
  R.push(l);
5259
5259
  }
5260
5260
  }
@@ -5303,7 +5303,7 @@ function Mt(n, e, t) {
5303
5303
  class Ps {
5304
5304
  dateTimeBuilder;
5305
5305
  constructor(e) {
5306
- this.dateTimeBuilder = new Ie(e);
5306
+ this.dateTimeBuilder = new Ne(e);
5307
5307
  }
5308
5308
  /**
5309
5309
  * Check if a query contains compareDateRange
@@ -5486,7 +5486,7 @@ class Ps {
5486
5486
  }
5487
5487
  class ps {
5488
5488
  constructor(e) {
5489
- this.databaseAdapter = e, this.dateTimeBuilder = new Ie(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
5489
+ this.databaseAdapter = e, this.dateTimeBuilder = new Ne(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
5490
5490
  }
5491
5491
  filterBuilder;
5492
5492
  dateTimeBuilder;
@@ -5670,7 +5670,7 @@ class ps {
5670
5670
  const [, T] = e.bindingKey.split("."), A = t.dimensions?.[T];
5671
5671
  if (!A)
5672
5672
  throw new Error(`Binding key dimension not found: ${e.bindingKey}`);
5673
- return F(A.sql, E);
5673
+ return b(A.sql, E);
5674
5674
  }
5675
5675
  const s = e.bindingKey.find((T) => T.cube === t.name);
5676
5676
  if (!s)
@@ -5678,7 +5678,7 @@ class ps {
5678
5678
  const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
5679
5679
  if (!r)
5680
5680
  throw new Error(`Binding key dimension not found: ${s.dimension}`);
5681
- return F(r.sql, E);
5681
+ return b(r.sql, E);
5682
5682
  }
5683
5683
  /**
5684
5684
  * Resolve time dimension expression for a cube
@@ -5688,7 +5688,7 @@ class ps {
5688
5688
  const [, T] = e.timeDimension.split("."), A = t.dimensions?.[T];
5689
5689
  if (!A)
5690
5690
  throw new Error(`Time dimension not found: ${e.timeDimension}`);
5691
- return F(A.sql, E);
5691
+ return b(A.sql, E);
5692
5692
  }
5693
5693
  const s = e.timeDimension.find((T) => T.cube === t.name);
5694
5694
  if (!s)
@@ -5696,7 +5696,7 @@ class ps {
5696
5696
  const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
5697
5697
  if (!r)
5698
5698
  throw new Error(`Time dimension not found: ${s.dimension}`);
5699
- return F(r.sql, E);
5699
+ return b(r.sql, E);
5700
5700
  }
5701
5701
  /**
5702
5702
  * Build filter conditions for a step
@@ -5730,17 +5730,17 @@ class ps {
5730
5730
  if (r) {
5731
5731
  const l = e;
5732
5732
  u = l.type === "and";
5733
- for (const c of l.filters || []) {
5734
- const D = this.buildFilterCondition(c, t, E, s);
5735
- D && C.push(D);
5733
+ for (const _ of l.filters || []) {
5734
+ const U = this.buildFilterCondition(_, t, E, s);
5735
+ U && C.push(U);
5736
5736
  }
5737
5737
  } else {
5738
5738
  const l = e;
5739
5739
  u = "and" in l && !!l.and;
5740
- const c = l.and || l.or || [];
5741
- for (const D of c) {
5742
- const p = this.buildFilterCondition(D, t, E, s);
5743
- p && C.push(p);
5740
+ const _ = l.and || l.or || [];
5741
+ for (const U of _) {
5742
+ const D = this.buildFilterCondition(U, t, E, s);
5743
+ D && C.push(D);
5744
5744
  }
5745
5745
  }
5746
5746
  return C.length === 0 ? null : C.length === 1 ? C[0] : u ? y(...C) : o`(${o.join(C, o` OR `)})`;
@@ -5760,7 +5760,7 @@ class ps {
5760
5760
  }
5761
5761
  const N = I.dimensions?.[a];
5762
5762
  if (!N) return null;
5763
- const O = F(N.sql, s);
5763
+ const O = b(N.sql, s);
5764
5764
  return this.filterBuilder.buildFilterCondition(
5765
5765
  O,
5766
5766
  T.operator,
@@ -5848,7 +5848,7 @@ class ps {
5848
5848
  for (const r of i.joinPath) {
5849
5849
  const T = r.joinDef, A = [];
5850
5850
  for (const I of T.on)
5851
- I.as ? A.push(I.as(I.source, I.target)) : A.push(v(I.source, I.target));
5851
+ I.as ? A.push(I.as(I.source, I.target)) : A.push(X(I.source, I.target));
5852
5852
  const a = A.length === 1 ? A[0] : y(...A), S = i.cube.sql(E);
5853
5853
  e = e.leftJoin(S.from, a), S.where && s.push(S.where);
5854
5854
  }
@@ -5927,7 +5927,7 @@ class Ms {
5927
5927
  dateTimeBuilder;
5928
5928
  databaseAdapter;
5929
5929
  constructor(e) {
5930
- this.databaseAdapter = e, this.dateTimeBuilder = new Ie(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
5930
+ this.databaseAdapter = e, this.dateTimeBuilder = new Ne(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
5931
5931
  }
5932
5932
  /**
5933
5933
  * Check if query contains flow configuration
@@ -6098,7 +6098,7 @@ class Ms {
6098
6098
  const [, T] = e.bindingKey.split("."), A = t.dimensions?.[T];
6099
6099
  if (!A)
6100
6100
  throw new Error(`Binding key dimension not found: ${e.bindingKey}`);
6101
- return F(A.sql, E);
6101
+ return b(A.sql, E);
6102
6102
  }
6103
6103
  const s = e.bindingKey.find((T) => T.cube === t.name);
6104
6104
  if (!s)
@@ -6106,7 +6106,7 @@ class Ms {
6106
6106
  const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
6107
6107
  if (!r)
6108
6108
  throw new Error(`Binding key dimension not found: ${s.dimension}`);
6109
- return F(r.sql, E);
6109
+ return b(r.sql, E);
6110
6110
  }
6111
6111
  /**
6112
6112
  * Resolve time dimension expression
@@ -6116,7 +6116,7 @@ class Ms {
6116
6116
  const [, T] = e.timeDimension.split("."), A = t.dimensions?.[T];
6117
6117
  if (!A)
6118
6118
  throw new Error(`Time dimension not found: ${e.timeDimension}`);
6119
- return F(A.sql, E);
6119
+ return b(A.sql, E);
6120
6120
  }
6121
6121
  const s = e.timeDimension.find((T) => T.cube === t.name);
6122
6122
  if (!s)
@@ -6124,7 +6124,7 @@ class Ms {
6124
6124
  const [, i] = s.dimension.split("."), r = t.dimensions?.[i];
6125
6125
  if (!r)
6126
6126
  throw new Error(`Time dimension not found: ${s.dimension}`);
6127
- return F(r.sql, E);
6127
+ return b(r.sql, E);
6128
6128
  }
6129
6129
  /**
6130
6130
  * Resolve event dimension expression
@@ -6133,7 +6133,7 @@ class Ms {
6133
6133
  const [, s] = e.eventDimension.split("."), i = t.dimensions?.[s];
6134
6134
  if (!i)
6135
6135
  throw new Error(`Event dimension not found: ${e.eventDimension}`);
6136
- return F(i.sql, E);
6136
+ return b(i.sql, E);
6137
6137
  }
6138
6138
  /**
6139
6139
  * Build filter conditions for the starting step
@@ -6170,7 +6170,7 @@ class Ms {
6170
6170
  }
6171
6171
  const s = e, [, i] = s.member.split("."), r = t.dimensions?.[i];
6172
6172
  if (!r) return null;
6173
- const T = F(r.sql, E);
6173
+ const T = b(r.sql, E);
6174
6174
  return this.filterBuilder.buildFilterCondition(
6175
6175
  T,
6176
6176
  s.operator,
@@ -6220,7 +6220,7 @@ class Ms {
6220
6220
  step_time: o`${r}`.as("step_time"),
6221
6221
  event_type: o`${T}`.as("event_type"),
6222
6222
  event_path: u.as("event_path")
6223
- }).from(s.from).where(C).orderBy(o`${r} DESC`).limit(1), c = E.db.$with(N).as(
6223
+ }).from(s.from).where(C).orderBy(o`${r} DESC`).limit(1), _ = E.db.$with(N).as(
6224
6224
  E.db.select({
6225
6225
  binding_key: o`e.binding_key`.as("binding_key"),
6226
6226
  step_time: o`e.step_time`.as("step_time"),
@@ -6228,7 +6228,7 @@ class Ms {
6228
6228
  event_path: o`e.event_path`.as("event_path")
6229
6229
  }).from(o`${o.identifier(S)}`).crossJoinLateral(l.as("e"))
6230
6230
  );
6231
- A.push(c);
6231
+ A.push(_);
6232
6232
  }
6233
6233
  return A;
6234
6234
  }
@@ -6249,7 +6249,7 @@ class Ms {
6249
6249
  step_time: o`${r}`.as("step_time"),
6250
6250
  event_type: o`${T}`.as("event_type"),
6251
6251
  event_path: u.as("event_path")
6252
- }).from(s.from).where(C).orderBy(o`${r} ASC`).limit(1), c = E.db.$with(N).as(
6252
+ }).from(s.from).where(C).orderBy(o`${r} ASC`).limit(1), _ = E.db.$with(N).as(
6253
6253
  E.db.select({
6254
6254
  binding_key: o`e.binding_key`.as("binding_key"),
6255
6255
  step_time: o`e.step_time`.as("step_time"),
@@ -6257,7 +6257,7 @@ class Ms {
6257
6257
  event_path: o`e.event_path`.as("event_path")
6258
6258
  }).from(o`${o.identifier(S)}`).crossJoinLateral(l.as("e"))
6259
6259
  );
6260
- A.push(c);
6260
+ A.push(_);
6261
6261
  }
6262
6262
  return A;
6263
6263
  }
@@ -6284,13 +6284,13 @@ class Ms {
6284
6284
  }).from(s.from).innerJoin(
6285
6285
  o`${o.identifier(S)}`,
6286
6286
  o`${i} = ${o.identifier(S)}.binding_key`
6287
- ).where(C), c = E.db.select({
6287
+ ).where(C), _ = E.db.select({
6288
6288
  binding_key: o`binding_key`.as("binding_key"),
6289
6289
  step_time: o`step_time`.as("step_time"),
6290
6290
  event_type: o`event_type`.as("event_type"),
6291
6291
  event_path: o`event_path`.as("event_path")
6292
6292
  }).from(l.as("ranked")).where(o`rn = 1`);
6293
- A.push(E.db.$with(N).as(c));
6293
+ A.push(E.db.$with(N).as(_));
6294
6294
  }
6295
6295
  return A;
6296
6296
  }
@@ -6317,13 +6317,13 @@ class Ms {
6317
6317
  }).from(s.from).innerJoin(
6318
6318
  o`${o.identifier(S)}`,
6319
6319
  o`${i} = ${o.identifier(S)}.binding_key`
6320
- ).where(C), c = E.db.select({
6320
+ ).where(C), _ = E.db.select({
6321
6321
  binding_key: o`binding_key`.as("binding_key"),
6322
6322
  step_time: o`step_time`.as("step_time"),
6323
6323
  event_type: o`event_type`.as("event_type"),
6324
6324
  event_path: o`event_path`.as("event_path")
6325
6325
  }).from(l.as("ranked")).where(o`rn = 1`);
6326
- A.push(E.db.$with(N).as(c));
6326
+ A.push(E.db.$with(N).as(_));
6327
6327
  }
6328
6328
  return A;
6329
6329
  }
@@ -6548,7 +6548,7 @@ function ht(n) {
6548
6548
  }
6549
6549
  class Us {
6550
6550
  constructor(e) {
6551
- this.databaseAdapter = e, this.dateTimeBuilder = new Ie(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
6551
+ this.databaseAdapter = e, this.dateTimeBuilder = new Ne(e), this.filterBuilder = new he(e, this.dateTimeBuilder);
6552
6552
  }
6553
6553
  filterBuilder;
6554
6554
  dateTimeBuilder;
@@ -6687,12 +6687,12 @@ class Us {
6687
6687
  const T = r.dimensions?.[i];
6688
6688
  if (!T)
6689
6689
  throw new Error(`Time dimension not found: ${i}`);
6690
- const A = F(T.sql, E), a = this.resolveBindingKey(e.bindingKey, r, t, E), R = this.buildFilterConditions(e.cohortFilters, r, t, E), S = this.buildFilterConditions(e.activityFilters, r, t, E), I = [];
6690
+ const A = b(T.sql, E), a = this.resolveBindingKey(e.bindingKey, r, t, E), R = this.buildFilterConditions(e.cohortFilters, r, t, E), S = this.buildFilterConditions(e.activityFilters, r, t, E), I = [];
6691
6691
  if (e.breakdownDimensions && e.breakdownDimensions.length > 0)
6692
6692
  for (const N of e.breakdownDimensions) {
6693
6693
  const [O, C] = N.split("."), u = t.get(O);
6694
6694
  if (u && u.dimensions?.[C]) {
6695
- const l = F(u.dimensions[C].sql, E);
6695
+ const l = b(u.dimensions[C].sql, E);
6696
6696
  I.push({ dimension: N, expr: l });
6697
6697
  }
6698
6698
  }
@@ -6712,7 +6712,7 @@ class Us {
6712
6712
  const I = S.dimensions?.[R];
6713
6713
  if (!I)
6714
6714
  throw new Error(`Binding key dimension not found: ${a.dimension}`);
6715
- return F(I.sql, s);
6715
+ return b(I.sql, s);
6716
6716
  }
6717
6717
  const [i, r] = e.split("."), T = E.get(i);
6718
6718
  if (!T)
@@ -6720,7 +6720,7 @@ class Us {
6720
6720
  const A = T.dimensions?.[r];
6721
6721
  if (!A)
6722
6722
  throw new Error(`Binding key dimension not found: ${e}`);
6723
- return F(A.sql, s);
6723
+ return b(A.sql, s);
6724
6724
  }
6725
6725
  /**
6726
6726
  * Build filter conditions from config filters
@@ -6750,7 +6750,7 @@ class Us {
6750
6750
  if (!A) return null;
6751
6751
  const a = A.dimensions?.[T];
6752
6752
  if (!a) return null;
6753
- const R = F(a.sql, s);
6753
+ const R = b(a.sql, s);
6754
6754
  return this.filterBuilder.buildFilterCondition(
6755
6755
  R,
6756
6756
  i.operator,
@@ -6934,7 +6934,7 @@ class Us {
6934
6934
  return t.length > 1 ? t[1] : t[0];
6935
6935
  }
6936
6936
  }
6937
- class z {
6937
+ class te {
6938
6938
  constructor(e, t) {
6939
6939
  if (this.dbExecutor = e, this.databaseAdapter = e.databaseAdapter, !this.databaseAdapter)
6940
6940
  throw new Error("DatabaseExecutor must have a databaseAdapter property");
@@ -6982,19 +6982,19 @@ class z {
6982
6982
  });
6983
6983
  else
6984
6984
  try {
6985
- const l = Date.now(), c = await this.cacheConfig.provider.get(i);
6986
- if (c)
6985
+ const l = Date.now(), _ = await this.cacheConfig.provider.get(i);
6986
+ if (_)
6987
6987
  return this.cacheConfig.onCacheEvent?.({
6988
6988
  type: "hit",
6989
6989
  key: i,
6990
6990
  durationMs: Date.now() - l
6991
6991
  }), {
6992
- ...c.value,
6993
- cache: c.metadata ? {
6992
+ ..._.value,
6993
+ cache: _.metadata ? {
6994
6994
  hit: !0,
6995
- cachedAt: new Date(c.metadata.cachedAt).toISOString(),
6996
- ttlMs: c.metadata.ttlMs,
6997
- ttlRemainingMs: c.metadata.ttlRemainingMs
6995
+ cachedAt: new Date(_.metadata.cachedAt).toISOString(),
6996
+ ttlMs: _.metadata.ttlMs,
6997
+ ttlRemainingMs: _.metadata.ttlRemainingMs
6998
6998
  } : {
6999
6999
  hit: !0,
7000
7000
  cachedAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -7028,19 +7028,19 @@ class z {
7028
7028
  const A = this.queryPlanner.createQueryPlan(e, t, T);
7029
7029
  this.validateSecurityContext(A, T);
7030
7030
  const a = this.buildUnifiedQuery(A, t, T), R = this.queryBuilder.collectNumericFields(e, t), S = await this.dbExecutor.execute(a, R), I = Array.isArray(S) ? S.map((l) => {
7031
- const c = { ...l };
7031
+ const _ = { ...l };
7032
7032
  if (t.timeDimensions) {
7033
- for (const D of t.timeDimensions)
7034
- if (D.dimension in c) {
7035
- let p = c[D.dimension];
7036
- if (typeof p == "string" && p.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
7037
- const m = p.replace(" ", "T"), P = !m.endsWith("Z") && !m.includes("+") ? m + "Z" : m;
7038
- p = new Date(P);
7033
+ for (const U of t.timeDimensions)
7034
+ if (U.dimension in _) {
7035
+ let D = _[U.dimension];
7036
+ if (typeof D == "string" && D.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
7037
+ const m = D.replace(" ", "T"), P = !m.endsWith("Z") && !m.includes("+") ? m + "Z" : m;
7038
+ D = new Date(P);
7039
7039
  }
7040
- p = this.databaseAdapter.convertTimeDimensionResult(p), c[D.dimension] = p;
7040
+ D = this.databaseAdapter.convertTimeDimensionResult(D), _[U.dimension] = D;
7041
7041
  }
7042
7042
  }
7043
- return c;
7043
+ return _;
7044
7044
  }) : [S], N = t.measures || [], O = Mt(I, t, N), C = this.generateAnnotations(A, t), u = {
7045
7045
  data: O,
7046
7046
  annotation: C,
@@ -7319,8 +7319,8 @@ class z {
7319
7319
  if (u.dimension in C) {
7320
7320
  let l = C[u.dimension];
7321
7321
  if (typeof l == "string" && l.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
7322
- const c = l.replace(" ", "T"), D = !c.endsWith("Z") && !c.includes("+") ? c + "Z" : c;
7323
- l = new Date(D);
7322
+ const _ = l.replace(" ", "T"), U = !_.endsWith("Z") && !_.includes("+") ? _ + "Z" : _;
7323
+ l = new Date(U);
7324
7324
  }
7325
7325
  l = this.databaseAdapter.convertTimeDimensionResult(l), C[u.dimension] = l;
7326
7326
  }
@@ -7369,234 +7369,235 @@ class z {
7369
7369
  if (e.preAggregationCTEs && e.preAggregationCTEs.length > 0) {
7370
7370
  for (const D of e.preAggregationCTEs)
7371
7371
  if (D.propagatingFilters && D.propagatingFilters.length > 0)
7372
- for (const p of D.propagatingFilters) {
7373
- const m = p.sourceCube.name;
7374
- if (!s.has(m)) {
7375
- const M = {
7376
- filters: p.filters
7377
- }, g = /* @__PURE__ */ new Map([[m, p.sourceCube]]), h = this.queryBuilder.buildWhereConditions(
7372
+ for (const m of D.propagatingFilters) {
7373
+ const P = m.sourceCube.name;
7374
+ if (!s.has(P)) {
7375
+ const g = {
7376
+ filters: m.filters
7377
+ }, h = /* @__PURE__ */ new Map([[P, m.sourceCube]]), G = this.queryBuilder.buildWhereConditions(
7378
+ h,
7378
7379
  g,
7379
- M,
7380
7380
  E
7381
7381
  );
7382
- s.set(m, h);
7382
+ s.set(P, G);
7383
7383
  }
7384
- const P = s.get(m);
7385
- P && P.length > 0 && (p.preBuiltFilterSQL = P.length === 1 ? P[0] : y(...P));
7384
+ const M = s.get(P);
7385
+ M && M.length > 0 && (m.preBuiltFilterSQL = M.length === 1 ? M[0] : y(...M));
7386
7386
  }
7387
7387
  }
7388
7388
  const i = [], r = /* @__PURE__ */ new Map(), T = /* @__PURE__ */ new Map();
7389
7389
  if (e.preAggregationCTEs && e.preAggregationCTEs.length > 0)
7390
7390
  for (const D of e.preAggregationCTEs) {
7391
- const p = this.cteBuilder.buildPreAggregationCTE(D, t, E, e, s);
7392
- if (p && (i.push(p), r.set(D.cube.name, D.cteAlias), D.downstreamJoinKeys))
7393
- for (const m of D.downstreamJoinKeys)
7394
- T.set(m.targetCubeName, {
7391
+ const m = this.cteBuilder.buildPreAggregationCTE(D, t, E, e, s);
7392
+ if (m && (i.push(m), r.set(D.cube.name, D.cteAlias), D.downstreamJoinKeys))
7393
+ for (const P of D.downstreamJoinKeys)
7394
+ T.set(P.targetCubeName, {
7395
7395
  cteAlias: D.cteAlias,
7396
- joinKeys: m.joinKeys
7396
+ joinKeys: P.joinKeys
7397
7397
  });
7398
7398
  }
7399
- const A = e.primaryCube.sql(E), R = { ...this.queryBuilder.buildSelections(
7400
- e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
7399
+ const A = e.primaryCube.sql(E), a = e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : /* @__PURE__ */ new Map([[e.primaryCube.name, e.primaryCube]]), S = { ...this.queryBuilder.buildSelections(
7400
+ e.joinCubes.length > 0 ? a : e.primaryCube,
7401
7401
  // Single cube
7402
7402
  t,
7403
7403
  E
7404
7404
  ) };
7405
7405
  if (e.preAggregationCTEs)
7406
7406
  for (const D of e.preAggregationCTEs) {
7407
- const p = D.cube.name;
7408
- for (const m of D.measures)
7409
- if (R[m]) {
7410
- const [, P] = m.split("."), M = this.getCubesFromPlan(e).get(p);
7411
- if (M && M.measures && M.measures[P]) {
7412
- const g = M.measures[P], h = o`${o.identifier(D.cteAlias)}.${o.identifier(P)}`;
7413
- let G;
7414
- if (g.type === "calculated" && g.calculatedSql) {
7415
- const b = this.getCubesFromPlan(e);
7416
- G = this.queryBuilder.buildCTECalculatedMeasure(
7407
+ const m = D.cube.name;
7408
+ for (const P of D.measures)
7409
+ if (S[P]) {
7410
+ const [, M] = P.split("."), g = a.get(m);
7411
+ if (g && g.measures && g.measures[M]) {
7412
+ const h = g.measures[M], G = o`${o.identifier(D.cteAlias)}.${o.identifier(M)}`;
7413
+ let B;
7414
+ if (h.type === "calculated" && h.calculatedSql)
7415
+ B = this.queryBuilder.buildCTECalculatedMeasure(
7416
+ h,
7417
7417
  g,
7418
- M,
7419
7418
  D,
7420
- b,
7419
+ a,
7421
7420
  E
7422
7421
  );
7423
- } else {
7424
- const b = D.cteReason === "fanOutPrevention";
7425
- switch (g.type) {
7422
+ else {
7423
+ const F = D.cteReason === "fanOutPrevention", W = this.shouldUseMaxForHasManyAtJoinKeyGrain(
7424
+ D,
7425
+ t,
7426
+ a
7427
+ ), V = F || W;
7428
+ switch (h.type) {
7426
7429
  case "count":
7427
7430
  case "countDistinct":
7428
7431
  case "sum":
7429
- G = b ? q(h) : x(h);
7432
+ B = V ? Z(G) : J(G);
7430
7433
  break;
7431
7434
  case "avg":
7432
- G = b ? q(h) : this.databaseAdapter.buildAvg(h);
7435
+ B = V ? Z(G) : this.databaseAdapter.buildAvg(G);
7433
7436
  break;
7434
7437
  case "min":
7435
- G = le(h);
7438
+ B = le(G);
7436
7439
  break;
7437
7440
  case "max":
7438
- G = q(h);
7441
+ B = Z(G);
7439
7442
  break;
7440
7443
  case "number":
7441
- G = b ? q(h) : x(h);
7444
+ B = V ? Z(G) : J(G);
7442
7445
  break;
7443
7446
  default:
7444
- G = b ? q(h) : x(h);
7447
+ B = V ? Z(G) : J(G);
7445
7448
  }
7446
7449
  }
7447
- R[m] = o`${G}`.as(m);
7450
+ S[P] = o`${B}`.as(P);
7448
7451
  }
7449
7452
  }
7450
- for (const m in R) {
7451
- const [P, M] = m.split(".");
7452
- if (P === p) {
7453
- const g = this.getCubesFromPlan(e).get(p), h = g && g.dimensions?.[M], G = m.startsWith(p + ".");
7454
- if (h || G) {
7455
- let b = D.joinKeys.find(($) => $.targetColumn === M);
7456
- if (!b && g?.dimensions?.[M]) {
7457
- const $ = g.dimensions[M].sql;
7458
- b = D.joinKeys.find((W) => W.targetColumnObj === $);
7453
+ for (const P in S) {
7454
+ const [M, g] = P.split(".");
7455
+ if (M === m) {
7456
+ const h = a.get(m), G = h && h.dimensions?.[g], B = P.startsWith(m + ".");
7457
+ if (G || B) {
7458
+ let F = D.joinKeys.find((W) => W.targetColumn === g);
7459
+ if (!F && h?.dimensions?.[g]) {
7460
+ const W = h.dimensions[g].sql;
7461
+ F = D.joinKeys.find((V) => V.targetColumnObj === W);
7459
7462
  }
7460
- b ? R[m] = o`${o.identifier(D.cteAlias)}.${o.identifier(M)}`.as(m) : G && g?.dimensions?.[M] && (R[m] = o`${o.identifier(D.cteAlias)}.${o.identifier(M)}`.as(m));
7463
+ F ? S[P] = o`${o.identifier(D.cteAlias)}.${o.identifier(g)}`.as(P) : B && h?.dimensions?.[g] && (S[P] = o`${o.identifier(D.cteAlias)}.${o.identifier(g)}`.as(P));
7461
7464
  }
7462
7465
  }
7463
7466
  }
7464
7467
  }
7465
- if (t.measures) {
7466
- const D = this.getCubesFromPlan(e);
7467
- for (const p of t.measures) {
7468
- const [m, P] = p.split("."), M = D.get(m);
7468
+ if (t.measures)
7469
+ for (const D of t.measures) {
7470
+ const [m, P] = D.split("."), M = a.get(m);
7469
7471
  if (M?.measures?.[P]) {
7470
7472
  const g = M.measures[P];
7471
- if (B.isPostAggregationWindow(g)) {
7472
- const h = B.getWindowBaseMeasure(g, m);
7473
+ if (H.isPostAggregationWindow(g)) {
7474
+ const h = H.getWindowBaseMeasure(g, m);
7473
7475
  if (h) {
7474
- const [G, b] = h.split("."), $ = D.get(G);
7475
- if ($?.measures?.[b]) {
7476
- const W = $.measures[b], se = e.preAggregationCTEs?.find(
7477
- (Oe) => Oe.cube?.name === G && Oe.measures?.includes(h)
7476
+ const [G, B] = h.split("."), F = a.get(G);
7477
+ if (F?.measures?.[B]) {
7478
+ const W = F.measures[B], V = e.preAggregationCTEs?.find(
7479
+ (ie) => ie.cube?.name === G && ie.measures?.includes(h)
7478
7480
  );
7479
- let ne;
7480
- if (se) {
7481
- const Oe = o`${o.identifier(se.cteAlias)}.${o.identifier(b)}`;
7482
- ne = o`sum(${Oe})`;
7481
+ let j;
7482
+ if (V) {
7483
+ const ie = o`${o.identifier(V.cteAlias)}.${o.identifier(B)}`;
7484
+ j = o`sum(${ie})`;
7483
7485
  } else
7484
- ne = this.queryBuilder.buildMeasureExpression(W, E, $);
7485
- R[h] || (R[h] = o`${ne}`.as(h));
7486
- const Ne = this.buildPostAggregationWindowExpression(
7486
+ j = this.queryBuilder.buildMeasureExpression(W, E, F);
7487
+ S[h] || (S[h] = o`${j}`.as(h));
7488
+ const Oe = this.buildPostAggregationWindowExpression(
7487
7489
  g,
7488
- ne,
7490
+ j,
7489
7491
  t,
7490
7492
  E,
7491
7493
  M,
7492
7494
  e
7493
7495
  );
7494
- Ne && (R[p] = o`${Ne}`.as(p));
7496
+ Oe && (S[D] = o`${Oe}`.as(D));
7495
7497
  }
7496
7498
  }
7497
7499
  }
7498
7500
  }
7499
7501
  }
7500
- }
7501
- const S = [];
7502
- let I = E.db.select(R).from(A.from);
7503
- if (i.length > 0 && (I = E.db.with(...i).select(R).from(A.from)), A.joins)
7502
+ const I = [];
7503
+ let N = E.db.select(S).from(A.from);
7504
+ if (i.length > 0 && (N = E.db.with(...i).select(S).from(A.from)), A.joins)
7504
7505
  for (const D of A.joins)
7505
7506
  switch (D.type || "left") {
7506
7507
  case "left":
7507
- I = I.leftJoin(D.table, D.on);
7508
+ N = N.leftJoin(D.table, D.on);
7508
7509
  break;
7509
7510
  case "inner":
7510
- I = I.innerJoin(D.table, D.on);
7511
+ N = N.innerJoin(D.table, D.on);
7511
7512
  break;
7512
7513
  case "right":
7513
- I = I.rightJoin(D.table, D.on);
7514
+ N = N.rightJoin(D.table, D.on);
7514
7515
  break;
7515
7516
  case "full":
7516
- I = I.fullJoin(D.table, D.on);
7517
+ N = N.fullJoin(D.table, D.on);
7517
7518
  break;
7518
7519
  }
7519
- const N = /* @__PURE__ */ new Set(), O = /* @__PURE__ */ new Set();
7520
+ const O = /* @__PURE__ */ new Set(), C = /* @__PURE__ */ new Set();
7520
7521
  if (e.preAggregationCTEs) {
7521
7522
  for (const D of e.preAggregationCTEs)
7522
7523
  if (D.intermediateJoins && D.intermediateJoins.length > 0)
7523
- for (const p of D.intermediateJoins)
7524
- O.add(p.cube.name);
7524
+ for (const m of D.intermediateJoins)
7525
+ C.add(m.cube.name);
7525
7526
  }
7526
7527
  if (e.joinCubes && e.joinCubes.length > 0)
7527
7528
  for (const D of e.joinCubes) {
7528
- const p = D.cube.name;
7529
- if (O.has(p) && !r.has(p))
7529
+ const m = D.cube.name;
7530
+ if (C.has(m) && !r.has(m))
7530
7531
  continue;
7531
- const m = r.get(D.cube.name);
7532
+ const P = r.get(D.cube.name);
7532
7533
  if (D.junctionTable) {
7533
- const b = D.junctionTable, $ = [];
7534
- if (b.securitySql) {
7535
- const W = b.securitySql(E.securityContext);
7536
- Array.isArray(W) ? $.push(...W) : $.push(W);
7534
+ const F = D.junctionTable, W = [];
7535
+ if (F.securitySql) {
7536
+ const V = F.securitySql(E.securityContext);
7537
+ Array.isArray(V) ? W.push(...V) : W.push(V);
7537
7538
  }
7538
7539
  try {
7539
- switch (b.joinType || "left") {
7540
+ switch (F.joinType || "left") {
7540
7541
  case "left":
7541
- I = I.leftJoin(b.table, b.joinCondition);
7542
+ N = N.leftJoin(F.table, F.joinCondition);
7542
7543
  break;
7543
7544
  case "inner":
7544
- I = I.innerJoin(b.table, b.joinCondition);
7545
+ N = N.innerJoin(F.table, F.joinCondition);
7545
7546
  break;
7546
7547
  case "right":
7547
- I = I.rightJoin(b.table, b.joinCondition);
7548
+ N = N.rightJoin(F.table, F.joinCondition);
7548
7549
  break;
7549
7550
  case "full":
7550
- I = I.fullJoin(b.table, b.joinCondition);
7551
+ N = N.fullJoin(F.table, F.joinCondition);
7551
7552
  break;
7552
7553
  }
7553
- $.length > 0 && S.push(...$);
7554
+ W.length > 0 && I.push(...W);
7554
7555
  } catch {
7555
7556
  }
7556
7557
  }
7557
- let P, M, g;
7558
- if (m)
7559
- P = o`${o.identifier(m)}`, M = this.cteBuilder.buildCTEJoinCondition(D, m, e), g = void 0;
7558
+ let M, g, h;
7559
+ if (P)
7560
+ M = o`${o.identifier(P)}`, g = this.cteBuilder.buildCTEJoinCondition(D, P, e), h = void 0;
7560
7561
  else {
7561
- const b = T.get(D.cube.name), $ = D.cube.sql(E);
7562
- if (P = $.from, g = $.where, b) {
7563
- const W = [];
7564
- for (const se of b.joinKeys) {
7565
- const ne = o`${o.identifier(b.cteAlias)}.${o.identifier(se.sourceColumn)}`, Ne = se.targetColumnObj || o.identifier(se.targetColumn);
7566
- W.push(v(ne, Ne));
7562
+ const F = T.get(D.cube.name), W = D.cube.sql(E);
7563
+ if (M = W.from, h = W.where, F) {
7564
+ const V = [];
7565
+ for (const j of F.joinKeys) {
7566
+ const Oe = o`${o.identifier(F.cteAlias)}.${o.identifier(j.sourceColumn)}`, ie = j.targetColumnObj || o.identifier(j.targetColumn);
7567
+ V.push(X(Oe, ie));
7567
7568
  }
7568
- M = W.length === 1 ? W[0] : y(...W);
7569
+ g = V.length === 1 ? V[0] : y(...V);
7569
7570
  } else
7570
- M = D.joinCondition;
7571
+ g = D.joinCondition;
7571
7572
  }
7572
- const h = D.joinType || "left", G = h !== "inner" && g ? y(M, g) : M;
7573
+ const G = D.joinType || "left", B = G !== "inner" && h ? y(g, h) : g;
7573
7574
  try {
7574
- switch (h) {
7575
+ switch (G) {
7575
7576
  case "left":
7576
- I = I.leftJoin(P, G), g && N.add(D.cube.name);
7577
+ N = N.leftJoin(M, B), h && O.add(D.cube.name);
7577
7578
  break;
7578
7579
  case "inner":
7579
- I = I.innerJoin(P, M);
7580
+ N = N.innerJoin(M, g);
7580
7581
  break;
7581
7582
  case "right":
7582
- I = I.rightJoin(P, G), g && N.add(D.cube.name);
7583
+ N = N.rightJoin(M, B), h && O.add(D.cube.name);
7583
7584
  break;
7584
7585
  case "full":
7585
- I = I.fullJoin(P, G), g && N.add(D.cube.name);
7586
+ N = N.fullJoin(M, B), h && O.add(D.cube.name);
7586
7587
  break;
7587
7588
  }
7588
7589
  } catch {
7589
7590
  }
7590
7591
  }
7591
- if (A.where && S.push(A.where), e.joinCubes && e.joinCubes.length > 0)
7592
+ if (A.where && I.push(A.where), e.joinCubes && e.joinCubes.length > 0)
7592
7593
  for (const D of e.joinCubes) {
7593
- const p = D.cube.name;
7594
- if (r.get(p) || O.has(p) || N.has(p))
7594
+ const m = D.cube.name;
7595
+ if (r.get(m) || C.has(m) || O.has(m))
7595
7596
  continue;
7596
- const P = D.cube.sql(E);
7597
- P.where && S.push(P.where);
7597
+ const M = D.cube.sql(E);
7598
+ M.where && I.push(M.where);
7598
7599
  }
7599
- const C = this.queryBuilder.buildWhereConditions(
7600
+ const u = this.queryBuilder.buildWhereConditions(
7600
7601
  e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
7601
7602
  // Single cube
7602
7603
  t,
@@ -7606,11 +7607,11 @@ class z {
7606
7607
  s
7607
7608
  // Reuse pre-built filters for parameter deduplication
7608
7609
  );
7609
- if (C.length > 0 && S.push(...C), S.length > 0) {
7610
- const D = S.length === 1 ? S[0] : y(...S);
7611
- I = I.where(D);
7610
+ if (u.length > 0 && I.push(...u), I.length > 0) {
7611
+ const D = I.length === 1 ? I[0] : y(...I);
7612
+ N = N.where(D);
7612
7613
  }
7613
- const u = this.queryBuilder.buildGroupByFields(
7614
+ const l = this.queryBuilder.buildGroupByFields(
7614
7615
  e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
7615
7616
  // Single cube
7616
7617
  t,
@@ -7618,8 +7619,8 @@ class z {
7618
7619
  e
7619
7620
  // Pass the queryPlan to handle CTE scenarios
7620
7621
  );
7621
- u.length > 0 && (I = I.groupBy(...u));
7622
- const l = this.queryBuilder.buildHavingConditions(
7622
+ l.length > 0 && (N = N.groupBy(...l));
7623
+ const _ = this.queryBuilder.buildHavingConditions(
7623
7624
  e.joinCubes.length > 0 ? this.getCubesFromPlan(e) : e.primaryCube,
7624
7625
  // Single cube
7625
7626
  t,
@@ -7627,12 +7628,12 @@ class z {
7627
7628
  e
7628
7629
  // Pass the queryPlan to handle CTE scenarios
7629
7630
  );
7630
- if (l.length > 0) {
7631
- const D = l.length === 1 ? l[0] : y(...l);
7632
- I = I.having(D);
7631
+ if (_.length > 0) {
7632
+ const D = _.length === 1 ? _[0] : y(..._);
7633
+ N = N.having(D);
7633
7634
  }
7634
- const c = this.queryBuilder.buildOrderBy(t);
7635
- return c.length > 0 && (I = I.orderBy(...c)), I = this.queryBuilder.applyLimitAndOffset(I, t), I;
7635
+ const U = this.queryBuilder.buildOrderBy(t);
7636
+ return U.length > 0 && (N = N.orderBy(...U)), N = this.queryBuilder.applyLimitAndOffset(N, t), N;
7636
7637
  }
7637
7638
  /**
7638
7639
  * Convert query plan to cube map for QueryBuilder methods
@@ -7644,6 +7645,36 @@ class z {
7644
7645
  t.set(E.cube.name, E.cube);
7645
7646
  return t;
7646
7647
  }
7648
+ /**
7649
+ * For hasMany CTEs, detect when the outer query grain already matches the CTE join key.
7650
+ * In that case, re-aggregation should use MAX (not SUM) to avoid multiplying values by
7651
+ * lower-grain primary cube rows.
7652
+ */
7653
+ shouldUseMaxForHasManyAtJoinKeyGrain(e, t, E) {
7654
+ return e.cteReason !== "hasMany" || e.downstreamJoinKeys && e.downstreamJoinKeys.length > 0 || e.intermediateJoins && e.intermediateJoins.length > 0 || !!!(t.dimensions && t.dimensions.length > 0 || t.timeDimensions && t.timeDimensions.length > 0) || !!(t.dimensions?.some((r) => r.startsWith(`${e.cube.name}.`)) || t.timeDimensions?.some((r) => r.dimension.startsWith(`${e.cube.name}.`))) ? !1 : e.joinKeys.length > 0 && e.joinKeys.every(
7655
+ (r) => !!r.sourceColumnObj && this.queryGroupsByColumn(r.sourceColumnObj, t, E)
7656
+ );
7657
+ }
7658
+ /**
7659
+ * Checks whether query grouping includes a dimension backed by the given column.
7660
+ */
7661
+ queryGroupsByColumn(e, t, E) {
7662
+ if (t.dimensions)
7663
+ for (const s of t.dimensions) {
7664
+ const [i, r] = s.split(".");
7665
+ if (E.get(i)?.dimensions?.[r]?.sql === e)
7666
+ return !0;
7667
+ }
7668
+ if (t.timeDimensions)
7669
+ for (const s of t.timeDimensions) {
7670
+ if (s.granularity)
7671
+ continue;
7672
+ const [i, r] = s.dimension.split(".");
7673
+ if (E.get(i)?.dimensions?.[r]?.sql === e)
7674
+ return !0;
7675
+ }
7676
+ return !1;
7677
+ }
7647
7678
  /**
7648
7679
  * Generate raw SQL for debugging (without execution) - unified approach
7649
7680
  */
@@ -7809,7 +7840,7 @@ class z {
7809
7840
  const S = R.dimensions?.[a];
7810
7841
  if (!S || ["arrayContains", "arrayOverlaps", "arrayContained"].includes(r.operator))
7811
7842
  continue;
7812
- const N = F(S.sql, s), O = this.queryBuilder.buildFilterConditionPublic(
7843
+ const N = b(S.sql, s), O = this.queryBuilder.buildFilterConditionPublic(
7813
7844
  N,
7814
7845
  r.operator,
7815
7846
  r.values,
@@ -7828,7 +7859,7 @@ class z {
7828
7859
  if (!a) continue;
7829
7860
  const R = a.dimensions?.[A];
7830
7861
  if (!R) continue;
7831
- const S = F(R.sql, s), I = this.queryBuilder.buildDateRangeCondition(S, i.dateRange);
7862
+ const S = b(R.sql, s), I = this.queryBuilder.buildDateRangeCondition(S, i.dateRange);
7832
7863
  I && t.set(r, I);
7833
7864
  }
7834
7865
  }
@@ -7860,15 +7891,15 @@ class z {
7860
7891
  const O = N.field.includes(".") ? N.field.split(".")[1] : N.field;
7861
7892
  if (E.timeDimensions)
7862
7893
  for (const l of E.timeDimensions) {
7863
- const [c, D] = l.dimension.split(".");
7864
- if (D === O) {
7865
- const p = A(c, O);
7866
- if (p)
7894
+ const [_, U] = l.dimension.split(".");
7895
+ if (U === O) {
7896
+ const D = A(_, O);
7897
+ if (D)
7867
7898
  return {
7868
- field: p,
7899
+ field: D,
7869
7900
  direction: N.direction
7870
7901
  };
7871
- const m = i.dimensions?.[D];
7902
+ const m = i.dimensions?.[U];
7872
7903
  if (m)
7873
7904
  return {
7874
7905
  field: this.queryBuilder.buildTimeDimensionExpression(
@@ -7883,7 +7914,7 @@ class z {
7883
7914
  const C = i.dimensions?.[O];
7884
7915
  if (C)
7885
7916
  return {
7886
- field: F(C.sql, s),
7917
+ field: b(C.sql, s),
7887
7918
  direction: N.direction
7888
7919
  };
7889
7920
  const u = T.measure?.includes(".") ? T.measure.split(".")[1] : T.measure;
@@ -7902,10 +7933,10 @@ class z {
7902
7933
  else {
7903
7934
  const l = i.name === O ? i : void 0;
7904
7935
  if (l?.dimensions?.[C]) {
7905
- const c = l.dimensions[C];
7936
+ const _ = l.dimensions[C];
7906
7937
  a = [{
7907
7938
  field: this.queryBuilder.buildTimeDimensionExpression(
7908
- c.sql,
7939
+ _.sql,
7909
7940
  N.granularity,
7910
7941
  s
7911
7942
  ),
@@ -7917,7 +7948,7 @@ class z {
7917
7948
  let R;
7918
7949
  T.partitionBy && T.partitionBy.length > 0 && (R = T.partitionBy.map((N) => {
7919
7950
  const O = N.includes(".") ? N.split(".")[1] : N, C = i.dimensions?.[O];
7920
- return C ? F(C.sql, s) : null;
7951
+ return C ? b(C.sql, s) : null;
7921
7952
  }).filter((N) => N !== null));
7922
7953
  const S = this.databaseAdapter.buildWindowFunction(
7923
7954
  e.type,
@@ -7933,7 +7964,7 @@ class z {
7933
7964
  );
7934
7965
  if (!S)
7935
7966
  return null;
7936
- switch (T.operation || B.getDefaultWindowOperation(e.type)) {
7967
+ switch (T.operation || H.getDefaultWindowOperation(e.type)) {
7937
7968
  case "difference":
7938
7969
  return o`${t} - ${S}`;
7939
7970
  case "ratio":
@@ -8019,13 +8050,13 @@ const uE = (n) => ({
8019
8050
  raw: "«EOF»",
8020
8051
  text: "«EOF»",
8021
8052
  start: n
8022
- }), j = uE(1 / 0), ie = (n) => (e) => e.type === n.type && e.text === n.text, Z = {
8023
- ARRAY: ie({ text: "ARRAY", type: d.RESERVED_DATA_TYPE }),
8024
- BY: ie({ text: "BY", type: d.RESERVED_KEYWORD }),
8025
- SET: ie({ text: "SET", type: d.RESERVED_CLAUSE }),
8026
- STRUCT: ie({ text: "STRUCT", type: d.RESERVED_DATA_TYPE }),
8027
- WINDOW: ie({ text: "WINDOW", type: d.RESERVED_CLAUSE }),
8028
- VALUES: ie({ text: "VALUES", type: d.RESERVED_CLAUSE })
8053
+ }), z = uE(1 / 0), re = (n) => (e) => e.type === n.type && e.text === n.text, ee = {
8054
+ ARRAY: re({ text: "ARRAY", type: d.RESERVED_DATA_TYPE }),
8055
+ BY: re({ text: "BY", type: d.RESERVED_KEYWORD }),
8056
+ SET: re({ text: "SET", type: d.RESERVED_CLAUSE }),
8057
+ STRUCT: re({ text: "STRUCT", type: d.RESERVED_DATA_TYPE }),
8058
+ WINDOW: re({ text: "WINDOW", type: d.RESERVED_CLAUSE }),
8059
+ VALUES: re({ text: "VALUES", type: d.RESERVED_CLAUSE })
8029
8060
  }, LE = (n) => n === d.RESERVED_DATA_TYPE || n === d.RESERVED_KEYWORD || n === d.RESERVED_FUNCTION_NAME || n === d.RESERVED_KEYWORD_PHRASE || n === d.RESERVED_DATA_TYPE_PHRASE || n === d.RESERVED_CLAUSE || n === d.RESERVED_SELECT || n === d.RESERVED_SET_OPERATION || n === d.RESERVED_JOIN || n === d.ARRAY_KEYWORD || n === d.CASE || n === d.END || n === d.WHEN || n === d.ELSE || n === d.THEN || n === d.LIMIT || n === d.BETWEEN || n === d.AND || n === d.OR || n === d.XOR, Hs = (n) => n === d.AND || n === d.OR || n === d.XOR, Ys = [
8030
8061
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
8031
8062
  "KEYS.NEW_KEYSET",
@@ -8881,7 +8912,7 @@ function Qs(n) {
8881
8912
  return ks(qs(n));
8882
8913
  }
8883
8914
  function ks(n) {
8884
- let e = j;
8915
+ let e = z;
8885
8916
  return n.map((t) => t.text === "OFFSET" && e.text === "[" ? (e = t, Object.assign(Object.assign({}, t), { type: d.RESERVED_FUNCTION_NAME })) : (e = t, t));
8886
8917
  }
8887
8918
  function qs(n) {
@@ -8889,7 +8920,7 @@ function qs(n) {
8889
8920
  const t = [];
8890
8921
  for (let E = 0; E < n.length; E++) {
8891
8922
  const s = n[E];
8892
- if ((Z.ARRAY(s) || Z.STRUCT(s)) && ((e = n[E + 1]) === null || e === void 0 ? void 0 : e.text) === "<") {
8923
+ if ((ee.ARRAY(s) || ee.STRUCT(s)) && ((e = n[E + 1]) === null || e === void 0 ? void 0 : e.text) === "<") {
8893
8924
  const i = js(n, E + 1), r = n.slice(E, i + 1);
8894
8925
  t.push({
8895
8926
  type: d.IDENTIFIER,
@@ -11480,8 +11511,8 @@ const Zs = [
11480
11511
  };
11481
11512
  function an(n) {
11482
11513
  return n.map((e, t) => {
11483
- const E = n[t + 1] || j, s = n[t - 1] || j;
11484
- return e.type === d.RESERVED_SELECT && (E.type === d.COMMA || s.type === d.RESERVED_CLAUSE || s.type === d.COMMA) ? Object.assign(Object.assign({}, e), { type: d.RESERVED_KEYWORD }) : Z.SET(e) && E.type === d.OPEN_PAREN ? Object.assign(Object.assign({}, e), { type: d.RESERVED_FUNCTION_NAME }) : e;
11514
+ const E = n[t + 1] || z, s = n[t - 1] || z;
11515
+ return e.type === d.RESERVED_SELECT && (E.type === d.COMMA || s.type === d.RESERVED_CLAUSE || s.type === d.COMMA) ? Object.assign(Object.assign({}, e), { type: d.RESERVED_KEYWORD }) : ee.SET(e) && E.type === d.OPEN_PAREN ? Object.assign(Object.assign({}, e), { type: d.RESERVED_FUNCTION_NAME }) : e;
11485
11516
  });
11486
11517
  }
11487
11518
  const on = [
@@ -15223,11 +15254,11 @@ const on = [
15223
15254
  };
15224
15255
  function ge(n) {
15225
15256
  return n.map((e, t) => {
15226
- const E = n[t + 1] || j;
15227
- if (Z.SET(e) && E.text === "(")
15257
+ const E = n[t + 1] || z;
15258
+ if (ee.SET(e) && E.text === "(")
15228
15259
  return Object.assign(Object.assign({}, e), { type: d.RESERVED_FUNCTION_NAME });
15229
- const s = n[t - 1] || j;
15230
- return Z.VALUES(e) && s.text === "=" ? Object.assign(Object.assign({}, e), { type: d.RESERVED_FUNCTION_NAME }) : e;
15260
+ const s = n[t - 1] || z;
15261
+ return ee.VALUES(e) && s.text === "=" ? Object.assign(Object.assign({}, e), { type: d.RESERVED_FUNCTION_NAME }) : e;
15231
15262
  });
15232
15263
  }
15233
15264
  const kn = [
@@ -16535,7 +16566,7 @@ const kn = [
16535
16566
  "MBRTOUCHES",
16536
16567
  "MBRWITHIN",
16537
16568
  "MD5",
16538
- "MEMBER OF",
16569
+ // 'MEMBER OF',
16539
16570
  "MICROSECOND",
16540
16571
  "MID",
16541
16572
  "MIN",
@@ -16547,10 +16578,10 @@ const kn = [
16547
16578
  "MULTIPOINT",
16548
16579
  "MULTIPOLYGON",
16549
16580
  "NAME_CONST",
16550
- "NOT",
16551
- "NOT IN",
16552
- "NOT LIKE",
16553
- "NOT REGEXP",
16581
+ // 'NOT',
16582
+ // 'NOT IN',
16583
+ // 'NOT LIKE',
16584
+ // 'NOT REGEXP',
16554
16585
  "NOW",
16555
16586
  "NTH_VALUE",
16556
16587
  "NTILE",
@@ -19033,8 +19064,8 @@ const kn = [
19033
19064
  }
19034
19065
  };
19035
19066
  function Ki(n) {
19036
- let e = j;
19037
- return n.map((t) => Z.SET(t) && Z.BY(e) ? Object.assign(Object.assign({}, t), { type: d.RESERVED_KEYWORD }) : (LE(t.type) && (e = t), t));
19067
+ let e = z;
19068
+ return n.map((t) => ee.SET(t) && ee.BY(e) ? Object.assign(Object.assign({}, t), { type: d.RESERVED_KEYWORD }) : (LE(t.type) && (e = t), t));
19038
19069
  }
19039
19070
  const xi = [
19040
19071
  // https://www.postgresql.org/docs/14/functions.html
@@ -21720,8 +21751,8 @@ const xi = [
21720
21751
  };
21721
21752
  function dr(n) {
21722
21753
  return n.map((e, t) => {
21723
- const E = n[t - 1] || j, s = n[t + 1] || j;
21724
- return Z.WINDOW(e) && s.type === d.OPEN_PAREN ? Object.assign(Object.assign({}, e), { type: d.RESERVED_FUNCTION_NAME }) : e.text === "ITEMS" && e.type === d.RESERVED_KEYWORD && !(E.text === "COLLECTION" && s.text === "TERMINATED") ? Object.assign(Object.assign({}, e), { type: d.IDENTIFIER, text: e.raw }) : e;
21754
+ const E = n[t - 1] || z, s = n[t + 1] || z;
21755
+ return ee.WINDOW(e) && s.type === d.OPEN_PAREN ? Object.assign(Object.assign({}, e), { type: d.RESERVED_FUNCTION_NAME }) : e.text === "ITEMS" && e.type === d.RESERVED_KEYWORD && !(E.text === "COLLECTION" && s.text === "TERMINATED") ? Object.assign(Object.assign({}, e), { type: d.IDENTIFIER, text: e.raw }) : e;
21725
21756
  });
21726
21757
  }
21727
21758
  const Dr = [
@@ -26038,28 +26069,28 @@ const Dr = [
26038
26069
  tidb: mi,
26039
26070
  transactsql: aT,
26040
26071
  trino: Zr
26041
- }, Symbol.toStringTag, { value: "Module" })), Se = (n) => n[n.length - 1], _E = (n) => n.sort((e, t) => t.length - e.length || e.localeCompare(t)), _e = (n) => n.replace(/\s+/gu, " "), tt = (n) => /\n/.test(n), K = (n) => n.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), Zt = /\s+/uy, Ee = (n) => new RegExp(`(?:${n})`, "uy"), hT = (n) => n.split("").map((e) => / /gu.test(e) ? "\\s+" : `[${e.toUpperCase()}${e.toLowerCase()}]`).join(""), gT = (n) => n + "(?:-" + n + ")*", GT = ({ prefixes: n, requirePrefix: e }) => `(?:${n.map(hT).join("|")}${e ? "" : "|"})`, yT = (n) => new RegExp(`(?:${n.map(K).join("|")}).*?(?=\r
26072
+ }, Symbol.toStringTag, { value: "Module" })), Ie = (n) => n[n.length - 1], _E = (n) => n.sort((e, t) => t.length - e.length || e.localeCompare(t)), _e = (n) => n.replace(/\s+/gu, " "), tt = (n) => /\n/.test(n), x = (n) => n.replace(/[.*+?^${}()|[\]\\]/gu, "\\$&"), Zt = /\s+/uy, ne = (n) => new RegExp(`(?:${n})`, "uy"), hT = (n) => n.split("").map((e) => / /gu.test(e) ? "\\s+" : `[${e.toUpperCase()}${e.toLowerCase()}]`).join(""), gT = (n) => n + "(?:-" + n + ")*", GT = ({ prefixes: n, requirePrefix: e }) => `(?:${n.map(hT).join("|")}${e ? "" : "|"})`, yT = (n) => new RegExp(`(?:${n.map(x).join("|")}).*?(?=\r
26042
26073
  |\r|
26043
26074
  |$)`, "uy"), zt = (n, e = []) => {
26044
26075
  const t = n === "open" ? 0 : 1, E = ["()", ...e].map((s) => s[t]);
26045
- return Ee(E.map(K).join("|"));
26046
- }, eE = (n) => Ee(`${_E(n).map(K).join("|")}`), bT = ({ rest: n, dashes: e }) => n || e ? `(?![${n || ""}${e ? "-" : ""}])` : "", Q = (n, e = {}) => {
26076
+ return ne(E.map(x).join("|"));
26077
+ }, eE = (n) => ne(`${_E(n).map(x).join("|")}`), bT = ({ rest: n, dashes: e }) => n || e ? `(?![${n || ""}${e ? "-" : ""}])` : "", k = (n, e = {}) => {
26047
26078
  if (n.length === 0)
26048
26079
  return /^\b$/u;
26049
- const t = bT(e), E = _E(n).map(K).join("|").replace(/ /gu, "\\s+");
26080
+ const t = bT(e), E = _E(n).map(x).join("|").replace(/ /gu, "\\s+");
26050
26081
  return new RegExp(`(?:${E})${t}\\b`, "iuy");
26051
26082
  }, Et = (n, e) => {
26052
26083
  if (!n.length)
26053
26084
  return;
26054
- const t = n.map(K).join("|");
26055
- return Ee(`(?:${t})(?:${e})`);
26085
+ const t = n.map(x).join("|");
26086
+ return ne(`(?:${t})(?:${e})`);
26056
26087
  }, FT = () => {
26057
26088
  const n = {
26058
26089
  "<": ">",
26059
26090
  "[": "]",
26060
26091
  "(": ")",
26061
26092
  "{": "}"
26062
- }, e = "{left}(?:(?!{right}').)*?{right}", t = Object.entries(n).map(([r, T]) => e.replace(/{left}/g, K(r)).replace(/{right}/g, K(T))), E = K(Object.keys(n).join(""));
26093
+ }, e = "{left}(?:(?!{right}').)*?{right}", t = Object.entries(n).map(([r, T]) => e.replace(/{left}/g, x(r)).replace(/{right}/g, x(T))), E = x(Object.keys(n).join(""));
26063
26094
  return `[Qq]'(?:${String.raw`(?<tag>[^\s${E}])(?:(?!\k<tag>').)*?\k<tag>`}|${t.join("|")})'`;
26064
26095
  }, tE = {
26065
26096
  // - backtick quoted (using `` to escape)
@@ -26086,8 +26117,8 @@ const Dr = [
26086
26117
  "{}": String.raw`(?:\{[^\}]*\})`,
26087
26118
  // Oracle q'' strings: q'<text>' q'|text|' ...
26088
26119
  "q''": FT()
26089
- }, cE = (n) => typeof n == "string" ? tE[n] : "regex" in n ? n.regex : GT(n) + tE[n.quote], BT = (n) => Ee(n.map((e) => "regex" in e ? e.regex : cE(e)).join("|")), dE = (n) => n.map(cE).join("|"), EE = (n) => Ee(dE(n)), HT = (n = {}) => Ee(DE(n)), DE = ({ first: n, rest: e, dashes: t, allowFirstCharNumber: E } = {}) => {
26090
- const s = "\\p{Alphabetic}\\p{Mark}_", i = "\\p{Decimal_Number}", r = K(n ?? ""), T = K(e ?? ""), A = E ? `[${s}${i}${r}][${s}${i}${T}]*` : `[${s}${r}][${s}${i}${T}]*`;
26120
+ }, cE = (n) => typeof n == "string" ? tE[n] : "regex" in n ? n.regex : GT(n) + tE[n.quote], BT = (n) => ne(n.map((e) => "regex" in e ? e.regex : cE(e)).join("|")), dE = (n) => n.map(cE).join("|"), EE = (n) => ne(dE(n)), HT = (n = {}) => ne(DE(n)), DE = ({ first: n, rest: e, dashes: t, allowFirstCharNumber: E } = {}) => {
26121
+ const s = "\\p{Alphabetic}\\p{Mark}_", i = "\\p{Decimal_Number}", r = x(n ?? ""), T = x(e ?? ""), A = E ? `[${s}${i}${r}][${s}${i}${T}]*` : `[${s}${r}][${s}${i}${T}]*`;
26091
26122
  return t ? gT(A) : A;
26092
26123
  };
26093
26124
  function mE(n, e) {
@@ -26225,83 +26256,83 @@ class WT {
26225
26256
  // to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
26226
26257
  {
26227
26258
  type: d.RESERVED_KEYWORD_PHRASE,
26228
- regex: Q((E = e.reservedKeywordPhrases) !== null && E !== void 0 ? E : [], e.identChars),
26229
- text: H
26259
+ regex: k((E = e.reservedKeywordPhrases) !== null && E !== void 0 ? E : [], e.identChars),
26260
+ text: Y
26230
26261
  },
26231
26262
  {
26232
26263
  type: d.RESERVED_DATA_TYPE_PHRASE,
26233
- regex: Q((s = e.reservedDataTypePhrases) !== null && s !== void 0 ? s : [], e.identChars),
26234
- text: H
26264
+ regex: k((s = e.reservedDataTypePhrases) !== null && s !== void 0 ? s : [], e.identChars),
26265
+ text: Y
26235
26266
  },
26236
26267
  {
26237
26268
  type: d.CASE,
26238
26269
  regex: /CASE\b/iuy,
26239
- text: H
26270
+ text: Y
26240
26271
  },
26241
26272
  {
26242
26273
  type: d.END,
26243
26274
  regex: /END\b/iuy,
26244
- text: H
26275
+ text: Y
26245
26276
  },
26246
26277
  {
26247
26278
  type: d.BETWEEN,
26248
26279
  regex: /BETWEEN\b/iuy,
26249
- text: H
26280
+ text: Y
26250
26281
  },
26251
26282
  {
26252
26283
  type: d.LIMIT,
26253
26284
  regex: e.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
26254
- text: H
26285
+ text: Y
26255
26286
  },
26256
26287
  {
26257
26288
  type: d.RESERVED_CLAUSE,
26258
- regex: Q(e.reservedClauses, e.identChars),
26259
- text: H
26289
+ regex: k(e.reservedClauses, e.identChars),
26290
+ text: Y
26260
26291
  },
26261
26292
  {
26262
26293
  type: d.RESERVED_SELECT,
26263
- regex: Q(e.reservedSelect, e.identChars),
26264
- text: H
26294
+ regex: k(e.reservedSelect, e.identChars),
26295
+ text: Y
26265
26296
  },
26266
26297
  {
26267
26298
  type: d.RESERVED_SET_OPERATION,
26268
- regex: Q(e.reservedSetOperations, e.identChars),
26269
- text: H
26299
+ regex: k(e.reservedSetOperations, e.identChars),
26300
+ text: Y
26270
26301
  },
26271
26302
  {
26272
26303
  type: d.WHEN,
26273
26304
  regex: /WHEN\b/iuy,
26274
- text: H
26305
+ text: Y
26275
26306
  },
26276
26307
  {
26277
26308
  type: d.ELSE,
26278
26309
  regex: /ELSE\b/iuy,
26279
- text: H
26310
+ text: Y
26280
26311
  },
26281
26312
  {
26282
26313
  type: d.THEN,
26283
26314
  regex: /THEN\b/iuy,
26284
- text: H
26315
+ text: Y
26285
26316
  },
26286
26317
  {
26287
26318
  type: d.RESERVED_JOIN,
26288
- regex: Q(e.reservedJoins, e.identChars),
26289
- text: H
26319
+ regex: k(e.reservedJoins, e.identChars),
26320
+ text: Y
26290
26321
  },
26291
26322
  {
26292
26323
  type: d.AND,
26293
26324
  regex: /AND\b/iuy,
26294
- text: H
26325
+ text: Y
26295
26326
  },
26296
26327
  {
26297
26328
  type: d.OR,
26298
26329
  regex: /OR\b/iuy,
26299
- text: H
26330
+ text: Y
26300
26331
  },
26301
26332
  {
26302
26333
  type: d.XOR,
26303
26334
  regex: e.supportsXor ? /XOR\b/iuy : void 0,
26304
- text: H
26335
+ text: Y
26305
26336
  },
26306
26337
  ...e.operatorKeyword ? [
26307
26338
  {
@@ -26311,18 +26342,18 @@ class WT {
26311
26342
  ] : [],
26312
26343
  {
26313
26344
  type: d.RESERVED_FUNCTION_NAME,
26314
- regex: Q(e.reservedFunctionNames, e.identChars),
26315
- text: H
26345
+ regex: k(e.reservedFunctionNames, e.identChars),
26346
+ text: Y
26316
26347
  },
26317
26348
  {
26318
26349
  type: d.RESERVED_DATA_TYPE,
26319
- regex: Q(e.reservedDataTypes, e.identChars),
26320
- text: H
26350
+ regex: k(e.reservedDataTypes, e.identChars),
26351
+ text: Y
26321
26352
  },
26322
26353
  {
26323
26354
  type: d.RESERVED_KEYWORD,
26324
- regex: Q(e.reservedKeywords, e.identChars),
26325
- text: H
26355
+ regex: k(e.reservedKeywords, e.identChars),
26356
+ text: Y
26326
26357
  }
26327
26358
  ]);
26328
26359
  }
@@ -26394,7 +26425,7 @@ class WT {
26394
26425
  {
26395
26426
  type: d.QUOTED_PARAMETER,
26396
26427
  regex: Et(A.quoted, dE(e.identTypes)),
26397
- key: (a) => (({ tokenKey: R, quoteChar: S }) => R.replace(new RegExp(K("\\" + S), "gu"), S))({
26428
+ key: (a) => (({ tokenKey: R, quoteChar: S }) => R.replace(new RegExp(x("\\" + S), "gu"), S))({
26398
26429
  tokenKey: a.slice(2, -1),
26399
26430
  quoteChar: a.slice(-1)
26400
26431
  })
@@ -26412,7 +26443,7 @@ class WT {
26412
26443
  var R;
26413
26444
  return {
26414
26445
  type: d.CUSTOM_PARAMETER,
26415
- regex: Ee(a.regex),
26446
+ regex: ne(a.regex),
26416
26447
  key: (R = a.key) !== null && R !== void 0 ? R : ((S) => S)
26417
26448
  };
26418
26449
  })
@@ -26423,7 +26454,7 @@ class WT {
26423
26454
  return e.filter((t) => !!t.regex);
26424
26455
  }
26425
26456
  }
26426
- const H = (n) => _e(n.toUpperCase()), nE = /* @__PURE__ */ new Map(), vT = (n) => {
26457
+ const Y = (n) => _e(n.toUpperCase()), nE = /* @__PURE__ */ new Map(), vT = (n) => {
26427
26458
  let e = nE.get(n);
26428
26459
  return e || (e = XT(n), nE.set(n, e)), e;
26429
26460
  }, XT = (n) => ({
@@ -26440,7 +26471,7 @@ const H = (n) => _e(n.toUpperCase()), nE = /* @__PURE__ */ new Map(), vT = (n) =
26440
26471
  function xT(n) {
26441
26472
  return n.indentStyle === "tabularLeft" || n.indentStyle === "tabularRight" ? " ".repeat(10) : n.useTabs ? " " : " ".repeat(n.tabWidth);
26442
26473
  }
26443
- function re(n) {
26474
+ function Te(n) {
26444
26475
  return n.indentStyle === "tabularLeft" || n.indentStyle === "tabularRight";
26445
26476
  }
26446
26477
  class JT {
@@ -26512,24 +26543,24 @@ function qT() {
26512
26543
  this.complete(l, O);
26513
26544
  }
26514
26545
  if (O.reference === this.index) {
26515
- var c = O.rule.name;
26516
- (this.completed[c] = this.completed[c] || []).push(O);
26546
+ var _ = O.rule.name;
26547
+ (this.completed[_] = this.completed[_] || []).push(O);
26517
26548
  }
26518
26549
  }
26519
26550
  } else {
26520
- var c = O.rule.symbols[O.dot];
26521
- if (typeof c != "string") {
26551
+ var _ = O.rule.symbols[O.dot];
26552
+ if (typeof _ != "string") {
26522
26553
  this.scannable.push(O);
26523
26554
  continue;
26524
26555
  }
26525
- if (S[c]) {
26526
- if (S[c].push(O), I.hasOwnProperty(c))
26527
- for (var D = I[c], u = 0; u < D.length; u++) {
26528
- var p = D[u];
26529
- this.complete(O, p);
26556
+ if (S[_]) {
26557
+ if (S[_].push(O), I.hasOwnProperty(_))
26558
+ for (var U = I[_], u = 0; u < U.length; u++) {
26559
+ var D = U[u];
26560
+ this.complete(O, D);
26530
26561
  }
26531
26562
  } else
26532
- S[c] = [O], this.predict(c);
26563
+ S[_] = [O], this.predict(_);
26533
26564
  }
26534
26565
  }
26535
26566
  }, E.prototype.predict = function(a) {
@@ -26585,17 +26616,17 @@ function qT() {
26585
26616
  var O = this.index - this.lastLineBreak, C = String(this.line).length;
26586
26617
  return R += " at line " + this.line + " col " + O + `:
26587
26618
 
26588
- `, R += I.map(function(l, c) {
26589
- return u(this.line - I.length + c + 1, C) + " " + l;
26619
+ `, R += I.map(function(l, _) {
26620
+ return u(this.line - I.length + _ + 1, C) + " " + l;
26590
26621
  }, this).join(`
26591
26622
  `), R += `
26592
26623
  ` + u("", C + O) + `^
26593
26624
  `, R;
26594
26625
  } else
26595
26626
  return R + " at index " + (this.index - 1);
26596
- function u(l, c) {
26597
- var D = String(l);
26598
- return Array(c - D.length + 1).join(" ") + D;
26627
+ function u(l, _) {
26628
+ var U = String(l);
26629
+ return Array(_ - U.length + 1).join(" ") + U;
26599
26630
  }
26600
26631
  };
26601
26632
  function r(a, R, S) {
@@ -26630,10 +26661,10 @@ function qT() {
26630
26661
  this.options.keepHistory || delete this.table[this.current - 1];
26631
26662
  var O = this.current + 1, C = new E(this.grammar, O);
26632
26663
  this.table.push(C);
26633
- for (var u = S.text !== void 0 ? S.text : S.value, l = R.constructor === i ? S.value : S, c = N.scannable, D = c.length; D--; ) {
26634
- var p = c[D], m = p.rule.symbols[p.dot];
26664
+ for (var u = S.text !== void 0 ? S.text : S.value, l = R.constructor === i ? S.value : S, _ = N.scannable, U = _.length; U--; ) {
26665
+ var D = _[U], m = D.rule.symbols[D.dot];
26635
26666
  if (m.test ? m.test(l) : m.type ? m.type === S.type : m.literal === u) {
26636
- var P = p.nextState({ data: l, token: S, isToken: !0, reference: O - 1 });
26667
+ var P = D.nextState({ data: l, token: S, isToken: !0, reference: O - 1 });
26637
26668
  C.states.push(P);
26638
26669
  }
26639
26670
  }
@@ -26667,8 +26698,8 @@ function qT() {
26667
26698
  return this.buildFirstStateStack(u, []) || [u];
26668
26699
  }, this);
26669
26700
  C.forEach(function(u) {
26670
- var l = u[0], c = l.rule.symbols[l.dot], D = this.getSymbolDisplay(c);
26671
- S.push("A " + D + " based on:"), this.displayStateStack(u, S);
26701
+ var l = u[0], _ = l.rule.symbols[l.dot], U = this.getSymbolDisplay(_);
26702
+ S.push("A " + U + " based on:"), this.displayStateStack(u, S);
26672
26703
  }, this);
26673
26704
  }
26674
26705
  return S.push(""), S.join(`
@@ -26755,40 +26786,40 @@ const ea = (n, e, t) => {
26755
26786
  const E = ia(t, e);
26756
26787
  if (E && E.type === d.PROPERTY_ACCESS_OPERATOR)
26757
26788
  return Object.assign(Object.assign({}, n), { type: d.IDENTIFIER, text: n.raw });
26758
- const s = Ae(t, e);
26789
+ const s = Re(t, e);
26759
26790
  if (s && s.type === d.PROPERTY_ACCESS_OPERATOR)
26760
26791
  return Object.assign(Object.assign({}, n), { type: d.IDENTIFIER, text: n.raw });
26761
26792
  }
26762
26793
  return n;
26763
26794
  }, ta = (n, e, t) => {
26764
26795
  if (n.type === d.RESERVED_FUNCTION_NAME) {
26765
- const E = Ae(t, e);
26796
+ const E = Re(t, e);
26766
26797
  if (!E || !PE(E))
26767
26798
  return Object.assign(Object.assign({}, n), { type: d.IDENTIFIER, text: n.raw });
26768
26799
  }
26769
26800
  return n;
26770
26801
  }, Ea = (n, e, t) => {
26771
26802
  if (n.type === d.RESERVED_DATA_TYPE) {
26772
- const E = Ae(t, e);
26803
+ const E = Re(t, e);
26773
26804
  if (E && PE(E))
26774
26805
  return Object.assign(Object.assign({}, n), { type: d.RESERVED_PARAMETERIZED_DATA_TYPE });
26775
26806
  }
26776
26807
  return n;
26777
26808
  }, sa = (n, e, t) => {
26778
26809
  if (n.type === d.IDENTIFIER) {
26779
- const E = Ae(t, e);
26810
+ const E = Re(t, e);
26780
26811
  if (E && pE(E))
26781
26812
  return Object.assign(Object.assign({}, n), { type: d.ARRAY_IDENTIFIER });
26782
26813
  }
26783
26814
  return n;
26784
26815
  }, na = (n, e, t) => {
26785
26816
  if (n.type === d.RESERVED_DATA_TYPE) {
26786
- const E = Ae(t, e);
26817
+ const E = Re(t, e);
26787
26818
  if (E && pE(E))
26788
26819
  return Object.assign(Object.assign({}, n), { type: d.ARRAY_KEYWORD });
26789
26820
  }
26790
26821
  return n;
26791
- }, ia = (n, e) => Ae(n, e, -1), Ae = (n, e, t = 1) => {
26822
+ }, ia = (n, e) => Re(n, e, -1), Re = (n, e, t = 1) => {
26792
26823
  let E = 1;
26793
26824
  for (; n[e + E * t] && ra(n[e + E * t]); )
26794
26825
  E++;
@@ -26814,30 +26845,30 @@ class ME {
26814
26845
  return e in d;
26815
26846
  }
26816
26847
  }
26817
- var U;
26848
+ var p;
26818
26849
  (function(n) {
26819
26850
  n.statement = "statement", n.clause = "clause", n.set_operation = "set_operation", n.function_call = "function_call", n.parameterized_data_type = "parameterized_data_type", n.array_subscript = "array_subscript", n.property_access = "property_access", n.parenthesis = "parenthesis", n.between_predicate = "between_predicate", n.case_expression = "case_expression", n.case_when = "case_when", n.case_else = "case_else", n.limit_clause = "limit_clause", n.all_columns_asterisk = "all_columns_asterisk", n.literal = "literal", n.identifier = "identifier", n.keyword = "keyword", n.data_type = "data_type", n.parameter = "parameter", n.operator = "operator", n.comma = "comma", n.line_comment = "line_comment", n.block_comment = "block_comment", n.disable_comment = "disable_comment";
26820
- })(U = U || (U = {}));
26851
+ })(p = p || (p = {}));
26821
26852
  function st(n) {
26822
26853
  return n[0];
26823
26854
  }
26824
- const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26825
- type: U.keyword,
26855
+ const f = new ME((n) => []), Ee = ([[n]]) => n, $ = (n) => ({
26856
+ type: p.keyword,
26826
26857
  tokenType: n.type,
26827
26858
  text: n.text,
26828
26859
  raw: n.raw
26829
26860
  }), rE = (n) => ({
26830
- type: U.data_type,
26861
+ type: p.data_type,
26831
26862
  text: n.text,
26832
26863
  raw: n.raw
26833
- }), V = (n, { leading: e, trailing: t }) => (e?.length && (n = Object.assign(Object.assign({}, n), { leadingComments: e })), t?.length && (n = Object.assign(Object.assign({}, n), { trailingComments: t })), n), Ta = (n, { leading: e, trailing: t }) => {
26864
+ }), w = (n, { leading: e, trailing: t }) => (e?.length && (n = Object.assign(Object.assign({}, n), { leadingComments: e })), t?.length && (n = Object.assign(Object.assign({}, n), { trailingComments: t })), n), Ta = (n, { leading: e, trailing: t }) => {
26834
26865
  if (e?.length) {
26835
26866
  const [E, ...s] = n;
26836
- n = [V(E, { leading: e }), ...s];
26867
+ n = [w(E, { leading: e }), ...s];
26837
26868
  }
26838
26869
  if (t?.length) {
26839
26870
  const E = n.slice(0, -1), s = n[n.length - 1];
26840
- n = [...E, V(s, { trailing: t })];
26871
+ n = [...E, w(s, { trailing: t })];
26841
26872
  }
26842
26873
  return n;
26843
26874
  }, aa = {
@@ -26859,7 +26890,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26859
26890
  name: "statement",
26860
26891
  symbols: ["expressions_or_clauses", "statement$subexpression$1"],
26861
26892
  postprocess: ([n, [e]]) => ({
26862
- type: U.statement,
26893
+ type: p.statement,
26863
26894
  children: n,
26864
26895
  hasSemicolon: e.type === d.DELIMITER
26865
26896
  })
@@ -26877,7 +26908,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26877
26908
  { name: "clause$subexpression$1", symbols: ["select_clause"] },
26878
26909
  { name: "clause$subexpression$1", symbols: ["other_clause"] },
26879
26910
  { name: "clause$subexpression$1", symbols: ["set_operation"] },
26880
- { name: "clause", symbols: ["clause$subexpression$1"], postprocess: ee },
26911
+ { name: "clause", symbols: ["clause$subexpression$1"], postprocess: Ee },
26881
26912
  { name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["free_form_sql"] },
26882
26913
  { name: "limit_clause$ebnf$1$subexpression$1$ebnf$1", symbols: ["limit_clause$ebnf$1$subexpression$1$ebnf$1", "free_form_sql"], postprocess: (n) => n[0].concat([n[1]]) },
26883
26914
  { name: "limit_clause$ebnf$1$subexpression$1", symbols: [f.has("COMMA") ? { type: "COMMA" } : COMMA, "limit_clause$ebnf$1$subexpression$1$ebnf$1"] },
@@ -26890,15 +26921,15 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26890
26921
  if (E) {
26891
26922
  const [s, i] = E;
26892
26923
  return {
26893
- type: U.limit_clause,
26894
- limitKw: V(Y(n), { trailing: e }),
26924
+ type: p.limit_clause,
26925
+ limitKw: w($(n), { trailing: e }),
26895
26926
  offset: t,
26896
26927
  count: i
26897
26928
  };
26898
26929
  } else
26899
26930
  return {
26900
- type: U.limit_clause,
26901
- limitKw: V(Y(n), { trailing: e }),
26931
+ type: p.limit_clause,
26932
+ limitKw: w($(n), { trailing: e }),
26902
26933
  count: t
26903
26934
  };
26904
26935
  }
@@ -26913,8 +26944,8 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26913
26944
  name: "select_clause",
26914
26945
  symbols: [f.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT, "select_clause$subexpression$1"],
26915
26946
  postprocess: ([n, [e, t]]) => ({
26916
- type: U.clause,
26917
- nameKw: Y(n),
26947
+ type: p.clause,
26948
+ nameKw: $(n),
26918
26949
  children: [e, ...t]
26919
26950
  })
26920
26951
  },
@@ -26922,15 +26953,15 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26922
26953
  name: "select_clause",
26923
26954
  symbols: [f.has("RESERVED_SELECT") ? { type: "RESERVED_SELECT" } : RESERVED_SELECT],
26924
26955
  postprocess: ([n]) => ({
26925
- type: U.clause,
26926
- nameKw: Y(n),
26956
+ type: p.clause,
26957
+ nameKw: $(n),
26927
26958
  children: []
26928
26959
  })
26929
26960
  },
26930
26961
  {
26931
26962
  name: "all_columns_asterisk",
26932
26963
  symbols: [f.has("ASTERISK") ? { type: "ASTERISK" } : ASTERISK],
26933
- postprocess: () => ({ type: U.all_columns_asterisk })
26964
+ postprocess: () => ({ type: p.all_columns_asterisk })
26934
26965
  },
26935
26966
  { name: "other_clause$ebnf$1", symbols: [] },
26936
26967
  { name: "other_clause$ebnf$1", symbols: ["other_clause$ebnf$1", "free_form_sql"], postprocess: (n) => n[0].concat([n[1]]) },
@@ -26938,8 +26969,8 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26938
26969
  name: "other_clause",
26939
26970
  symbols: [f.has("RESERVED_CLAUSE") ? { type: "RESERVED_CLAUSE" } : RESERVED_CLAUSE, "other_clause$ebnf$1"],
26940
26971
  postprocess: ([n, e]) => ({
26941
- type: U.clause,
26942
- nameKw: Y(n),
26972
+ type: p.clause,
26973
+ nameKw: $(n),
26943
26974
  children: e
26944
26975
  })
26945
26976
  },
@@ -26949,8 +26980,8 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26949
26980
  name: "set_operation",
26950
26981
  symbols: [f.has("RESERVED_SET_OPERATION") ? { type: "RESERVED_SET_OPERATION" } : RESERVED_SET_OPERATION, "set_operation$ebnf$1"],
26951
26982
  postprocess: ([n, e]) => ({
26952
- type: U.set_operation,
26953
- nameKw: Y(n),
26983
+ type: p.set_operation,
26984
+ nameKw: $(n),
26954
26985
  children: e
26955
26986
  })
26956
26987
  },
@@ -26974,37 +27005,37 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
26974
27005
  {
26975
27006
  name: "expression_with_comments_",
26976
27007
  symbols: ["expression", "_"],
26977
- postprocess: ([n, e]) => V(n, { trailing: e })
27008
+ postprocess: ([n, e]) => w(n, { trailing: e })
26978
27009
  },
26979
27010
  {
26980
27011
  name: "_expression_with_comments",
26981
27012
  symbols: ["_", "expression"],
26982
- postprocess: ([n, e]) => V(e, { leading: n })
27013
+ postprocess: ([n, e]) => w(e, { leading: n })
26983
27014
  },
26984
27015
  {
26985
27016
  name: "_andless_expression_with_comments",
26986
27017
  symbols: ["_", "andless_expression"],
26987
- postprocess: ([n, e]) => V(e, { leading: n })
27018
+ postprocess: ([n, e]) => w(e, { leading: n })
26988
27019
  },
26989
27020
  { name: "free_form_sql$subexpression$1", symbols: ["asteriskless_free_form_sql"] },
26990
27021
  { name: "free_form_sql$subexpression$1", symbols: ["asterisk"] },
26991
- { name: "free_form_sql", symbols: ["free_form_sql$subexpression$1"], postprocess: ee },
27022
+ { name: "free_form_sql", symbols: ["free_form_sql$subexpression$1"], postprocess: Ee },
26992
27023
  { name: "asteriskless_free_form_sql$subexpression$1", symbols: ["asteriskless_andless_expression"] },
26993
27024
  { name: "asteriskless_free_form_sql$subexpression$1", symbols: ["logic_operator"] },
26994
27025
  { name: "asteriskless_free_form_sql$subexpression$1", symbols: ["comma"] },
26995
27026
  { name: "asteriskless_free_form_sql$subexpression$1", symbols: ["comment"] },
26996
27027
  { name: "asteriskless_free_form_sql$subexpression$1", symbols: ["other_keyword"] },
26997
- { name: "asteriskless_free_form_sql", symbols: ["asteriskless_free_form_sql$subexpression$1"], postprocess: ee },
27028
+ { name: "asteriskless_free_form_sql", symbols: ["asteriskless_free_form_sql$subexpression$1"], postprocess: Ee },
26998
27029
  { name: "expression$subexpression$1", symbols: ["andless_expression"] },
26999
27030
  { name: "expression$subexpression$1", symbols: ["logic_operator"] },
27000
- { name: "expression", symbols: ["expression$subexpression$1"], postprocess: ee },
27031
+ { name: "expression", symbols: ["expression$subexpression$1"], postprocess: Ee },
27001
27032
  { name: "andless_expression$subexpression$1", symbols: ["asteriskless_andless_expression"] },
27002
27033
  { name: "andless_expression$subexpression$1", symbols: ["asterisk"] },
27003
- { name: "andless_expression", symbols: ["andless_expression$subexpression$1"], postprocess: ee },
27034
+ { name: "andless_expression", symbols: ["andless_expression$subexpression$1"], postprocess: Ee },
27004
27035
  { name: "asteriskless_andless_expression$subexpression$1", symbols: ["atomic_expression"] },
27005
27036
  { name: "asteriskless_andless_expression$subexpression$1", symbols: ["between_predicate"] },
27006
27037
  { name: "asteriskless_andless_expression$subexpression$1", symbols: ["case_expression"] },
27007
- { name: "asteriskless_andless_expression", symbols: ["asteriskless_andless_expression$subexpression$1"], postprocess: ee },
27038
+ { name: "asteriskless_andless_expression", symbols: ["asteriskless_andless_expression$subexpression$1"], postprocess: Ee },
27008
27039
  { name: "atomic_expression$subexpression$1", symbols: ["array_subscript"] },
27009
27040
  { name: "atomic_expression$subexpression$1", symbols: ["function_call"] },
27010
27041
  { name: "atomic_expression$subexpression$1", symbols: ["property_access"] },
@@ -27017,13 +27048,13 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27017
27048
  { name: "atomic_expression$subexpression$1", symbols: ["literal"] },
27018
27049
  { name: "atomic_expression$subexpression$1", symbols: ["data_type"] },
27019
27050
  { name: "atomic_expression$subexpression$1", symbols: ["keyword"] },
27020
- { name: "atomic_expression", symbols: ["atomic_expression$subexpression$1"], postprocess: ee },
27051
+ { name: "atomic_expression", symbols: ["atomic_expression$subexpression$1"], postprocess: Ee },
27021
27052
  {
27022
27053
  name: "array_subscript",
27023
27054
  symbols: [f.has("ARRAY_IDENTIFIER") ? { type: "ARRAY_IDENTIFIER" } : ARRAY_IDENTIFIER, "_", "square_brackets"],
27024
27055
  postprocess: ([n, e, t]) => ({
27025
- type: U.array_subscript,
27026
- array: V({ type: U.identifier, quoted: !1, text: n.text }, { trailing: e }),
27056
+ type: p.array_subscript,
27057
+ array: w({ type: p.identifier, quoted: !1, text: n.text }, { trailing: e }),
27027
27058
  parenthesis: t
27028
27059
  })
27029
27060
  },
@@ -27031,8 +27062,8 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27031
27062
  name: "array_subscript",
27032
27063
  symbols: [f.has("ARRAY_KEYWORD") ? { type: "ARRAY_KEYWORD" } : ARRAY_KEYWORD, "_", "square_brackets"],
27033
27064
  postprocess: ([n, e, t]) => ({
27034
- type: U.array_subscript,
27035
- array: V(Y(n), { trailing: e }),
27065
+ type: p.array_subscript,
27066
+ array: w($(n), { trailing: e }),
27036
27067
  parenthesis: t
27037
27068
  })
27038
27069
  },
@@ -27040,8 +27071,8 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27040
27071
  name: "function_call",
27041
27072
  symbols: [f.has("RESERVED_FUNCTION_NAME") ? { type: "RESERVED_FUNCTION_NAME" } : RESERVED_FUNCTION_NAME, "_", "parenthesis"],
27042
27073
  postprocess: ([n, e, t]) => ({
27043
- type: U.function_call,
27044
- nameKw: V(Y(n), { trailing: e }),
27074
+ type: p.function_call,
27075
+ nameKw: w($(n), { trailing: e }),
27045
27076
  parenthesis: t
27046
27077
  })
27047
27078
  },
@@ -27049,7 +27080,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27049
27080
  name: "parenthesis",
27050
27081
  symbols: [{ literal: "(" }, "expressions_or_clauses", { literal: ")" }],
27051
27082
  postprocess: ([n, e, t]) => ({
27052
- type: U.parenthesis,
27083
+ type: p.parenthesis,
27053
27084
  children: e,
27054
27085
  openParen: "(",
27055
27086
  closeParen: ")"
@@ -27061,7 +27092,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27061
27092
  name: "curly_braces",
27062
27093
  symbols: [{ literal: "{" }, "curly_braces$ebnf$1", { literal: "}" }],
27063
27094
  postprocess: ([n, e, t]) => ({
27064
- type: U.parenthesis,
27095
+ type: p.parenthesis,
27065
27096
  children: e,
27066
27097
  openParen: "{",
27067
27098
  closeParen: "}"
@@ -27073,7 +27104,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27073
27104
  name: "square_brackets",
27074
27105
  symbols: [{ literal: "[" }, "square_brackets$ebnf$1", { literal: "]" }],
27075
27106
  postprocess: ([n, e, t]) => ({
27076
- type: U.parenthesis,
27107
+ type: p.parenthesis,
27077
27108
  children: e,
27078
27109
  openParen: "[",
27079
27110
  closeParen: "]"
@@ -27092,10 +27123,10 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27092
27123
  // but we currently can't do that because of another hack that requires
27093
27124
  // %ARRAY_IDENTIFIER on the left side of <array_subscript>.
27094
27125
  ([n, e, t, E, [s]]) => ({
27095
- type: U.property_access,
27096
- object: V(n, { trailing: e }),
27126
+ type: p.property_access,
27127
+ object: w(n, { trailing: e }),
27097
27128
  operator: t.text,
27098
- property: V(s, { leading: E })
27129
+ property: w(s, { leading: E })
27099
27130
  })
27100
27131
  )
27101
27132
  },
@@ -27103,11 +27134,11 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27103
27134
  name: "between_predicate",
27104
27135
  symbols: [f.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", f.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
27105
27136
  postprocess: ([n, e, t, E, s, i, r]) => ({
27106
- type: U.between_predicate,
27107
- betweenKw: Y(n),
27137
+ type: p.between_predicate,
27138
+ betweenKw: $(n),
27108
27139
  expr1: Ta(t, { leading: e, trailing: E }),
27109
- andKw: Y(s),
27110
- expr2: [V(r, { leading: i })]
27140
+ andKw: $(s),
27141
+ expr2: [w(r, { leading: i })]
27111
27142
  })
27112
27143
  },
27113
27144
  { name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: st },
@@ -27118,9 +27149,9 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27118
27149
  name: "case_expression",
27119
27150
  symbols: [f.has("CASE") ? { type: "CASE" } : CASE, "_", "case_expression$ebnf$1", "case_expression$ebnf$2", f.has("END") ? { type: "END" } : END],
27120
27151
  postprocess: ([n, e, t, E, s]) => ({
27121
- type: U.case_expression,
27122
- caseKw: V(Y(n), { trailing: e }),
27123
- endKw: Y(s),
27152
+ type: p.case_expression,
27153
+ caseKw: w($(n), { trailing: e }),
27154
+ endKw: $(s),
27124
27155
  expr: t || [],
27125
27156
  clauses: E
27126
27157
  })
@@ -27129,9 +27160,9 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27129
27160
  name: "case_clause",
27130
27161
  symbols: [f.has("WHEN") ? { type: "WHEN" } : WHEN, "_", "expression_chain_", f.has("THEN") ? { type: "THEN" } : THEN, "_", "expression_chain_"],
27131
27162
  postprocess: ([n, e, t, E, s, i]) => ({
27132
- type: U.case_when,
27133
- whenKw: V(Y(n), { trailing: e }),
27134
- thenKw: V(Y(E), { trailing: s }),
27163
+ type: p.case_when,
27164
+ whenKw: w($(n), { trailing: e }),
27165
+ thenKw: w($(E), { trailing: s }),
27135
27166
  condition: t,
27136
27167
  result: i
27137
27168
  })
@@ -27140,37 +27171,37 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27140
27171
  name: "case_clause",
27141
27172
  symbols: [f.has("ELSE") ? { type: "ELSE" } : ELSE, "_", "expression_chain_"],
27142
27173
  postprocess: ([n, e, t]) => ({
27143
- type: U.case_else,
27144
- elseKw: V(Y(n), { trailing: e }),
27174
+ type: p.case_else,
27175
+ elseKw: w($(n), { trailing: e }),
27145
27176
  result: t
27146
27177
  })
27147
27178
  },
27148
27179
  { name: "comma$subexpression$1", symbols: [f.has("COMMA") ? { type: "COMMA" } : COMMA] },
27149
- { name: "comma", symbols: ["comma$subexpression$1"], postprocess: ([[n]]) => ({ type: U.comma }) },
27180
+ { name: "comma", symbols: ["comma$subexpression$1"], postprocess: ([[n]]) => ({ type: p.comma }) },
27150
27181
  { name: "asterisk$subexpression$1", symbols: [f.has("ASTERISK") ? { type: "ASTERISK" } : ASTERISK] },
27151
- { name: "asterisk", symbols: ["asterisk$subexpression$1"], postprocess: ([[n]]) => ({ type: U.operator, text: n.text }) },
27182
+ { name: "asterisk", symbols: ["asterisk$subexpression$1"], postprocess: ([[n]]) => ({ type: p.operator, text: n.text }) },
27152
27183
  { name: "operator$subexpression$1", symbols: [f.has("OPERATOR") ? { type: "OPERATOR" } : OPERATOR] },
27153
- { name: "operator", symbols: ["operator$subexpression$1"], postprocess: ([[n]]) => ({ type: U.operator, text: n.text }) },
27184
+ { name: "operator", symbols: ["operator$subexpression$1"], postprocess: ([[n]]) => ({ type: p.operator, text: n.text }) },
27154
27185
  { name: "identifier$subexpression$1", symbols: [f.has("IDENTIFIER") ? { type: "IDENTIFIER" } : IDENTIFIER] },
27155
27186
  { name: "identifier$subexpression$1", symbols: [f.has("QUOTED_IDENTIFIER") ? { type: "QUOTED_IDENTIFIER" } : QUOTED_IDENTIFIER] },
27156
27187
  { name: "identifier$subexpression$1", symbols: [f.has("VARIABLE") ? { type: "VARIABLE" } : VARIABLE] },
27157
- { name: "identifier", symbols: ["identifier$subexpression$1"], postprocess: ([[n]]) => ({ type: U.identifier, quoted: n.type !== "IDENTIFIER", text: n.text }) },
27188
+ { name: "identifier", symbols: ["identifier$subexpression$1"], postprocess: ([[n]]) => ({ type: p.identifier, quoted: n.type !== "IDENTIFIER", text: n.text }) },
27158
27189
  { name: "parameter$subexpression$1", symbols: [f.has("NAMED_PARAMETER") ? { type: "NAMED_PARAMETER" } : NAMED_PARAMETER] },
27159
27190
  { name: "parameter$subexpression$1", symbols: [f.has("QUOTED_PARAMETER") ? { type: "QUOTED_PARAMETER" } : QUOTED_PARAMETER] },
27160
27191
  { name: "parameter$subexpression$1", symbols: [f.has("NUMBERED_PARAMETER") ? { type: "NUMBERED_PARAMETER" } : NUMBERED_PARAMETER] },
27161
27192
  { name: "parameter$subexpression$1", symbols: [f.has("POSITIONAL_PARAMETER") ? { type: "POSITIONAL_PARAMETER" } : POSITIONAL_PARAMETER] },
27162
27193
  { name: "parameter$subexpression$1", symbols: [f.has("CUSTOM_PARAMETER") ? { type: "CUSTOM_PARAMETER" } : CUSTOM_PARAMETER] },
27163
- { name: "parameter", symbols: ["parameter$subexpression$1"], postprocess: ([[n]]) => ({ type: U.parameter, key: n.key, text: n.text }) },
27194
+ { name: "parameter", symbols: ["parameter$subexpression$1"], postprocess: ([[n]]) => ({ type: p.parameter, key: n.key, text: n.text }) },
27164
27195
  { name: "literal$subexpression$1", symbols: [f.has("NUMBER") ? { type: "NUMBER" } : NUMBER] },
27165
27196
  { name: "literal$subexpression$1", symbols: [f.has("STRING") ? { type: "STRING" } : STRING] },
27166
- { name: "literal", symbols: ["literal$subexpression$1"], postprocess: ([[n]]) => ({ type: U.literal, text: n.text }) },
27197
+ { name: "literal", symbols: ["literal$subexpression$1"], postprocess: ([[n]]) => ({ type: p.literal, text: n.text }) },
27167
27198
  { name: "keyword$subexpression$1", symbols: [f.has("RESERVED_KEYWORD") ? { type: "RESERVED_KEYWORD" } : RESERVED_KEYWORD] },
27168
27199
  { name: "keyword$subexpression$1", symbols: [f.has("RESERVED_KEYWORD_PHRASE") ? { type: "RESERVED_KEYWORD_PHRASE" } : RESERVED_KEYWORD_PHRASE] },
27169
27200
  { name: "keyword$subexpression$1", symbols: [f.has("RESERVED_JOIN") ? { type: "RESERVED_JOIN" } : RESERVED_JOIN] },
27170
27201
  {
27171
27202
  name: "keyword",
27172
27203
  symbols: ["keyword$subexpression$1"],
27173
- postprocess: ([[n]]) => Y(n)
27204
+ postprocess: ([[n]]) => $(n)
27174
27205
  },
27175
27206
  { name: "data_type$subexpression$1", symbols: [f.has("RESERVED_DATA_TYPE") ? { type: "RESERVED_DATA_TYPE" } : RESERVED_DATA_TYPE] },
27176
27207
  { name: "data_type$subexpression$1", symbols: [f.has("RESERVED_DATA_TYPE_PHRASE") ? { type: "RESERVED_DATA_TYPE_PHRASE" } : RESERVED_DATA_TYPE_PHRASE] },
@@ -27183,8 +27214,8 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27183
27214
  name: "data_type",
27184
27215
  symbols: [f.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
27185
27216
  postprocess: ([n, e, t]) => ({
27186
- type: U.parameterized_data_type,
27187
- dataType: V(rE(n), { trailing: e }),
27217
+ type: p.parameterized_data_type,
27218
+ dataType: w(rE(n), { trailing: e }),
27188
27219
  parenthesis: t
27189
27220
  })
27190
27221
  },
@@ -27194,7 +27225,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27194
27225
  {
27195
27226
  name: "logic_operator",
27196
27227
  symbols: ["logic_operator$subexpression$1"],
27197
- postprocess: ([[n]]) => Y(n)
27228
+ postprocess: ([[n]]) => $(n)
27198
27229
  },
27199
27230
  { name: "other_keyword$subexpression$1", symbols: [f.has("WHEN") ? { type: "WHEN" } : WHEN] },
27200
27231
  { name: "other_keyword$subexpression$1", symbols: [f.has("THEN") ? { type: "THEN" } : THEN] },
@@ -27203,7 +27234,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27203
27234
  {
27204
27235
  name: "other_keyword",
27205
27236
  symbols: ["other_keyword$subexpression$1"],
27206
- postprocess: ([[n]]) => Y(n)
27237
+ postprocess: ([[n]]) => $(n)
27207
27238
  },
27208
27239
  { name: "_$ebnf$1", symbols: [] },
27209
27240
  { name: "_$ebnf$1", symbols: ["_$ebnf$1", "comment"], postprocess: (n) => n[0].concat([n[1]]) },
@@ -27212,7 +27243,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27212
27243
  name: "comment",
27213
27244
  symbols: [f.has("LINE_COMMENT") ? { type: "LINE_COMMENT" } : LINE_COMMENT],
27214
27245
  postprocess: ([n]) => ({
27215
- type: U.line_comment,
27246
+ type: p.line_comment,
27216
27247
  text: n.text,
27217
27248
  precedingWhitespace: n.precedingWhitespace
27218
27249
  })
@@ -27221,7 +27252,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27221
27252
  name: "comment",
27222
27253
  symbols: [f.has("BLOCK_COMMENT") ? { type: "BLOCK_COMMENT" } : BLOCK_COMMENT],
27223
27254
  postprocess: ([n]) => ({
27224
- type: U.block_comment,
27255
+ type: p.block_comment,
27225
27256
  text: n.text,
27226
27257
  precedingWhitespace: n.precedingWhitespace
27227
27258
  })
@@ -27230,7 +27261,7 @@ const f = new ME((n) => []), ee = ([[n]]) => n, Y = (n) => ({
27230
27261
  name: "comment",
27231
27262
  symbols: [f.has("DISABLE_COMMENT") ? { type: "DISABLE_COMMENT" } : DISABLE_COMMENT],
27232
27263
  postprocess: ([n]) => ({
27233
- type: U.disable_comment,
27264
+ type: p.disable_comment,
27234
27265
  text: n.text,
27235
27266
  precedingWhitespace: n.precedingWhitespace
27236
27267
  })
@@ -27255,10 +27286,10 @@ ${JSON.stringify(r, void 0, 2)}`);
27255
27286
  }
27256
27287
  };
27257
27288
  }
27258
- var _;
27289
+ var c;
27259
27290
  (function(n) {
27260
27291
  n[n.SPACE = 0] = "SPACE", n[n.NO_SPACE = 1] = "NO_SPACE", n[n.NO_NEWLINE = 2] = "NO_NEWLINE", n[n.NEWLINE = 3] = "NEWLINE", n[n.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", n[n.INDENT = 5] = "INDENT", n[n.SINGLE_INDENT = 6] = "SINGLE_INDENT";
27261
- })(_ = _ || (_ = {}));
27292
+ })(c = c || (c = {}));
27262
27293
  class UE {
27263
27294
  constructor(e) {
27264
27295
  this.indentation = e, this.items = [];
@@ -27269,46 +27300,46 @@ class UE {
27269
27300
  add(...e) {
27270
27301
  for (const t of e)
27271
27302
  switch (t) {
27272
- case _.SPACE:
27273
- this.items.push(_.SPACE);
27303
+ case c.SPACE:
27304
+ this.items.push(c.SPACE);
27274
27305
  break;
27275
- case _.NO_SPACE:
27306
+ case c.NO_SPACE:
27276
27307
  this.trimHorizontalWhitespace();
27277
27308
  break;
27278
- case _.NO_NEWLINE:
27309
+ case c.NO_NEWLINE:
27279
27310
  this.trimWhitespace();
27280
27311
  break;
27281
- case _.NEWLINE:
27282
- this.trimHorizontalWhitespace(), this.addNewline(_.NEWLINE);
27312
+ case c.NEWLINE:
27313
+ this.trimHorizontalWhitespace(), this.addNewline(c.NEWLINE);
27283
27314
  break;
27284
- case _.MANDATORY_NEWLINE:
27285
- this.trimHorizontalWhitespace(), this.addNewline(_.MANDATORY_NEWLINE);
27315
+ case c.MANDATORY_NEWLINE:
27316
+ this.trimHorizontalWhitespace(), this.addNewline(c.MANDATORY_NEWLINE);
27286
27317
  break;
27287
- case _.INDENT:
27318
+ case c.INDENT:
27288
27319
  this.addIndentation();
27289
27320
  break;
27290
- case _.SINGLE_INDENT:
27291
- this.items.push(_.SINGLE_INDENT);
27321
+ case c.SINGLE_INDENT:
27322
+ this.items.push(c.SINGLE_INDENT);
27292
27323
  break;
27293
27324
  default:
27294
27325
  this.items.push(t);
27295
27326
  }
27296
27327
  }
27297
27328
  trimHorizontalWhitespace() {
27298
- for (; Sa(Se(this.items)); )
27329
+ for (; Sa(Ie(this.items)); )
27299
27330
  this.items.pop();
27300
27331
  }
27301
27332
  trimWhitespace() {
27302
- for (; Ia(Se(this.items)); )
27333
+ for (; Ia(Ie(this.items)); )
27303
27334
  this.items.pop();
27304
27335
  }
27305
27336
  addNewline(e) {
27306
27337
  if (this.items.length > 0)
27307
- switch (Se(this.items)) {
27308
- case _.NEWLINE:
27338
+ switch (Ie(this.items)) {
27339
+ case c.NEWLINE:
27309
27340
  this.items.pop(), this.items.push(e);
27310
27341
  break;
27311
- case _.MANDATORY_NEWLINE:
27342
+ case c.MANDATORY_NEWLINE:
27312
27343
  break;
27313
27344
  default:
27314
27345
  this.items.push(e);
@@ -27317,7 +27348,7 @@ class UE {
27317
27348
  }
27318
27349
  addIndentation() {
27319
27350
  for (let e = 0; e < this.indentation.getLevel(); e++)
27320
- this.items.push(_.SINGLE_INDENT);
27351
+ this.items.push(c.SINGLE_INDENT);
27321
27352
  }
27322
27353
  /**
27323
27354
  * Returns the final SQL string.
@@ -27333,20 +27364,20 @@ class UE {
27333
27364
  }
27334
27365
  itemToString(e) {
27335
27366
  switch (e) {
27336
- case _.SPACE:
27367
+ case c.SPACE:
27337
27368
  return " ";
27338
- case _.NEWLINE:
27339
- case _.MANDATORY_NEWLINE:
27369
+ case c.NEWLINE:
27370
+ case c.MANDATORY_NEWLINE:
27340
27371
  return `
27341
27372
  `;
27342
- case _.SINGLE_INDENT:
27373
+ case c.SINGLE_INDENT:
27343
27374
  return this.indentation.getSingleIndent();
27344
27375
  default:
27345
27376
  return e;
27346
27377
  }
27347
27378
  }
27348
27379
  }
27349
- const Sa = (n) => n === _.SPACE || n === _.SINGLE_INDENT, Ia = (n) => n === _.SPACE || n === _.SINGLE_INDENT || n === _.NEWLINE;
27380
+ const Sa = (n) => n === c.SPACE || n === c.SINGLE_INDENT, Ia = (n) => n === c.SPACE || n === c.SINGLE_INDENT || n === c.NEWLINE;
27350
27381
  function TE(n, e) {
27351
27382
  if (e === "standard")
27352
27383
  return n;
@@ -27393,7 +27424,7 @@ class fE {
27393
27424
  * Does nothing when the previous indent is not top-level.
27394
27425
  */
27395
27426
  decreaseTopLevel() {
27396
- this.indentTypes.length > 0 && Se(this.indentTypes) === nt && this.indentTypes.pop();
27427
+ this.indentTypes.length > 0 && Ie(this.indentTypes) === nt && this.indentTypes.pop();
27397
27428
  }
27398
27429
  /**
27399
27430
  * Decreases indentation by one block-level indent.
@@ -27418,9 +27449,9 @@ class Oa extends UE {
27418
27449
  if (typeof e == "string")
27419
27450
  this.length += e.length, this.trailingSpace = !1;
27420
27451
  else {
27421
- if (e === _.MANDATORY_NEWLINE || e === _.NEWLINE)
27452
+ if (e === c.MANDATORY_NEWLINE || e === c.NEWLINE)
27422
27453
  throw new At();
27423
- e === _.INDENT || e === _.SINGLE_INDENT || e === _.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (e === _.NO_NEWLINE || e === _.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
27454
+ e === c.INDENT || e === c.SINGLE_INDENT || e === c.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (e === c.NO_NEWLINE || e === c.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
27424
27455
  }
27425
27456
  }
27426
27457
  }
@@ -27440,51 +27471,51 @@ class Pe {
27440
27471
  }
27441
27472
  formatNodeWithoutComments(e) {
27442
27473
  switch (e.type) {
27443
- case U.function_call:
27474
+ case p.function_call:
27444
27475
  return this.formatFunctionCall(e);
27445
- case U.parameterized_data_type:
27476
+ case p.parameterized_data_type:
27446
27477
  return this.formatParameterizedDataType(e);
27447
- case U.array_subscript:
27478
+ case p.array_subscript:
27448
27479
  return this.formatArraySubscript(e);
27449
- case U.property_access:
27480
+ case p.property_access:
27450
27481
  return this.formatPropertyAccess(e);
27451
- case U.parenthesis:
27482
+ case p.parenthesis:
27452
27483
  return this.formatParenthesis(e);
27453
- case U.between_predicate:
27484
+ case p.between_predicate:
27454
27485
  return this.formatBetweenPredicate(e);
27455
- case U.case_expression:
27486
+ case p.case_expression:
27456
27487
  return this.formatCaseExpression(e);
27457
- case U.case_when:
27488
+ case p.case_when:
27458
27489
  return this.formatCaseWhen(e);
27459
- case U.case_else:
27490
+ case p.case_else:
27460
27491
  return this.formatCaseElse(e);
27461
- case U.clause:
27492
+ case p.clause:
27462
27493
  return this.formatClause(e);
27463
- case U.set_operation:
27494
+ case p.set_operation:
27464
27495
  return this.formatSetOperation(e);
27465
- case U.limit_clause:
27496
+ case p.limit_clause:
27466
27497
  return this.formatLimitClause(e);
27467
- case U.all_columns_asterisk:
27498
+ case p.all_columns_asterisk:
27468
27499
  return this.formatAllColumnsAsterisk(e);
27469
- case U.literal:
27500
+ case p.literal:
27470
27501
  return this.formatLiteral(e);
27471
- case U.identifier:
27502
+ case p.identifier:
27472
27503
  return this.formatIdentifier(e);
27473
- case U.parameter:
27504
+ case p.parameter:
27474
27505
  return this.formatParameter(e);
27475
- case U.operator:
27506
+ case p.operator:
27476
27507
  return this.formatOperator(e);
27477
- case U.comma:
27508
+ case p.comma:
27478
27509
  return this.formatComma(e);
27479
- case U.line_comment:
27510
+ case p.line_comment:
27480
27511
  return this.formatLineComment(e);
27481
- case U.block_comment:
27512
+ case p.block_comment:
27482
27513
  return this.formatBlockComment(e);
27483
- case U.disable_comment:
27514
+ case p.disable_comment:
27484
27515
  return this.formatBlockComment(e);
27485
- case U.data_type:
27516
+ case p.data_type:
27486
27517
  return this.formatDataType(e);
27487
- case U.keyword:
27518
+ case p.keyword:
27488
27519
  return this.formatKeywordNode(e);
27489
27520
  }
27490
27521
  }
@@ -27501,10 +27532,10 @@ class Pe {
27501
27532
  formatArraySubscript(e) {
27502
27533
  let t;
27503
27534
  switch (e.array.type) {
27504
- case U.data_type:
27535
+ case p.data_type:
27505
27536
  t = this.showDataType(e.array);
27506
27537
  break;
27507
- case U.keyword:
27538
+ case p.keyword:
27508
27539
  t = this.showKw(e.array);
27509
27540
  break;
27510
27541
  default:
@@ -27516,80 +27547,80 @@ class Pe {
27516
27547
  }), this.formatNode(e.parenthesis);
27517
27548
  }
27518
27549
  formatPropertyAccess(e) {
27519
- this.formatNode(e.object), this.layout.add(_.NO_SPACE, e.operator), this.formatNode(e.property);
27550
+ this.formatNode(e.object), this.layout.add(c.NO_SPACE, e.operator), this.formatNode(e.property);
27520
27551
  }
27521
27552
  formatParenthesis(e) {
27522
27553
  const t = this.formatInlineExpression(e.children);
27523
- t ? (this.layout.add(e.openParen), this.layout.add(...t.getLayoutItems()), this.layout.add(_.NO_SPACE, e.closeParen, _.SPACE)) : (this.layout.add(e.openParen, _.NEWLINE), re(this.cfg) ? (this.layout.add(_.INDENT), this.layout = this.formatSubExpression(e.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(_.INDENT), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(_.NEWLINE, _.INDENT, e.closeParen, _.SPACE));
27554
+ t ? (this.layout.add(e.openParen), this.layout.add(...t.getLayoutItems()), this.layout.add(c.NO_SPACE, e.closeParen, c.SPACE)) : (this.layout.add(e.openParen, c.NEWLINE), Te(this.cfg) ? (this.layout.add(c.INDENT), this.layout = this.formatSubExpression(e.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(c.INDENT), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(c.NEWLINE, c.INDENT, e.closeParen, c.SPACE));
27524
27555
  }
27525
27556
  formatBetweenPredicate(e) {
27526
- this.layout.add(this.showKw(e.betweenKw), _.SPACE), this.layout = this.formatSubExpression(e.expr1), this.layout.add(_.NO_SPACE, _.SPACE, this.showNonTabularKw(e.andKw), _.SPACE), this.layout = this.formatSubExpression(e.expr2), this.layout.add(_.SPACE);
27557
+ this.layout.add(this.showKw(e.betweenKw), c.SPACE), this.layout = this.formatSubExpression(e.expr1), this.layout.add(c.NO_SPACE, c.SPACE, this.showNonTabularKw(e.andKw), c.SPACE), this.layout = this.formatSubExpression(e.expr2), this.layout.add(c.SPACE);
27527
27558
  }
27528
27559
  formatCaseExpression(e) {
27529
- this.formatNode(e.caseKw), this.layout.indentation.increaseBlockLevel(), this.layout = this.formatSubExpression(e.expr), this.layout = this.formatSubExpression(e.clauses), this.layout.indentation.decreaseBlockLevel(), this.layout.add(_.NEWLINE, _.INDENT), this.formatNode(e.endKw);
27560
+ this.formatNode(e.caseKw), this.layout.indentation.increaseBlockLevel(), this.layout = this.formatSubExpression(e.expr), this.layout = this.formatSubExpression(e.clauses), this.layout.indentation.decreaseBlockLevel(), this.layout.add(c.NEWLINE, c.INDENT), this.formatNode(e.endKw);
27530
27561
  }
27531
27562
  formatCaseWhen(e) {
27532
- this.layout.add(_.NEWLINE, _.INDENT), this.formatNode(e.whenKw), this.layout = this.formatSubExpression(e.condition), this.formatNode(e.thenKw), this.layout = this.formatSubExpression(e.result);
27563
+ this.layout.add(c.NEWLINE, c.INDENT), this.formatNode(e.whenKw), this.layout = this.formatSubExpression(e.condition), this.formatNode(e.thenKw), this.layout = this.formatSubExpression(e.result);
27533
27564
  }
27534
27565
  formatCaseElse(e) {
27535
- this.layout.add(_.NEWLINE, _.INDENT), this.formatNode(e.elseKw), this.layout = this.formatSubExpression(e.result);
27566
+ this.layout.add(c.NEWLINE, c.INDENT), this.formatNode(e.elseKw), this.layout = this.formatSubExpression(e.result);
27536
27567
  }
27537
27568
  formatClause(e) {
27538
- this.isOnelineClause(e) ? this.formatClauseInOnelineStyle(e) : re(this.cfg) ? this.formatClauseInTabularStyle(e) : this.formatClauseInIndentedStyle(e);
27569
+ this.isOnelineClause(e) ? this.formatClauseInOnelineStyle(e) : Te(this.cfg) ? this.formatClauseInTabularStyle(e) : this.formatClauseInIndentedStyle(e);
27539
27570
  }
27540
27571
  isOnelineClause(e) {
27541
- return re(this.cfg) ? this.dialectCfg.tabularOnelineClauses[e.nameKw.text] : this.dialectCfg.onelineClauses[e.nameKw.text];
27572
+ return Te(this.cfg) ? this.dialectCfg.tabularOnelineClauses[e.nameKw.text] : this.dialectCfg.onelineClauses[e.nameKw.text];
27542
27573
  }
27543
27574
  formatClauseInIndentedStyle(e) {
27544
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.nameKw), _.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(_.INDENT), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseTopLevel();
27575
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.nameKw), c.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(c.INDENT), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseTopLevel();
27545
27576
  }
27546
27577
  formatClauseInOnelineStyle(e) {
27547
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.nameKw), _.SPACE), this.layout = this.formatSubExpression(e.children);
27578
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.nameKw), c.SPACE), this.layout = this.formatSubExpression(e.children);
27548
27579
  }
27549
27580
  formatClauseInTabularStyle(e) {
27550
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.nameKw), _.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseTopLevel();
27581
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.nameKw), c.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(e.children), this.layout.indentation.decreaseTopLevel();
27551
27582
  }
27552
27583
  formatSetOperation(e) {
27553
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.nameKw), _.NEWLINE), this.layout.add(_.INDENT), this.layout = this.formatSubExpression(e.children);
27584
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.nameKw), c.NEWLINE), this.layout.add(c.INDENT), this.layout = this.formatSubExpression(e.children);
27554
27585
  }
27555
27586
  formatLimitClause(e) {
27556
27587
  this.withComments(e.limitKw, () => {
27557
- this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e.limitKw));
27558
- }), this.layout.indentation.increaseTopLevel(), re(this.cfg) ? this.layout.add(_.SPACE) : this.layout.add(_.NEWLINE, _.INDENT), e.offset ? (this.layout = this.formatSubExpression(e.offset), this.layout.add(_.NO_SPACE, ",", _.SPACE), this.layout = this.formatSubExpression(e.count)) : this.layout = this.formatSubExpression(e.count), this.layout.indentation.decreaseTopLevel();
27588
+ this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e.limitKw));
27589
+ }), this.layout.indentation.increaseTopLevel(), Te(this.cfg) ? this.layout.add(c.SPACE) : this.layout.add(c.NEWLINE, c.INDENT), e.offset ? (this.layout = this.formatSubExpression(e.offset), this.layout.add(c.NO_SPACE, ",", c.SPACE), this.layout = this.formatSubExpression(e.count)) : this.layout = this.formatSubExpression(e.count), this.layout.indentation.decreaseTopLevel();
27559
27590
  }
27560
27591
  formatAllColumnsAsterisk(e) {
27561
- this.layout.add("*", _.SPACE);
27592
+ this.layout.add("*", c.SPACE);
27562
27593
  }
27563
27594
  formatLiteral(e) {
27564
- this.layout.add(e.text, _.SPACE);
27595
+ this.layout.add(e.text, c.SPACE);
27565
27596
  }
27566
27597
  formatIdentifier(e) {
27567
- this.layout.add(this.showIdentifier(e), _.SPACE);
27598
+ this.layout.add(this.showIdentifier(e), c.SPACE);
27568
27599
  }
27569
27600
  formatParameter(e) {
27570
- this.layout.add(this.params.get(e), _.SPACE);
27601
+ this.layout.add(this.params.get(e), c.SPACE);
27571
27602
  }
27572
27603
  formatOperator({ text: e }) {
27573
- this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(e) ? this.layout.add(_.NO_SPACE, e) : e === ":" ? this.layout.add(_.NO_SPACE, e, _.SPACE) : this.layout.add(e, _.SPACE);
27604
+ this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(e) ? this.layout.add(c.NO_SPACE, e) : e === ":" ? this.layout.add(c.NO_SPACE, e, c.SPACE) : this.layout.add(e, c.SPACE);
27574
27605
  }
27575
27606
  formatComma(e) {
27576
- this.inline ? this.layout.add(_.NO_SPACE, ",", _.SPACE) : this.layout.add(_.NO_SPACE, ",", _.NEWLINE, _.INDENT);
27607
+ this.inline ? this.layout.add(c.NO_SPACE, ",", c.SPACE) : this.layout.add(c.NO_SPACE, ",", c.NEWLINE, c.INDENT);
27577
27608
  }
27578
27609
  withComments(e, t) {
27579
27610
  this.formatComments(e.leadingComments), t(), this.formatComments(e.trailingComments);
27580
27611
  }
27581
27612
  formatComments(e) {
27582
27613
  e && e.forEach((t) => {
27583
- t.type === U.line_comment ? this.formatLineComment(t) : this.formatBlockComment(t);
27614
+ t.type === p.line_comment ? this.formatLineComment(t) : this.formatBlockComment(t);
27584
27615
  });
27585
27616
  }
27586
27617
  formatLineComment(e) {
27587
- tt(e.precedingWhitespace || "") ? this.layout.add(_.NEWLINE, _.INDENT, e.text, _.MANDATORY_NEWLINE, _.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(_.NO_NEWLINE, _.SPACE, e.text, _.MANDATORY_NEWLINE, _.INDENT) : this.layout.add(e.text, _.MANDATORY_NEWLINE, _.INDENT);
27618
+ tt(e.precedingWhitespace || "") ? this.layout.add(c.NEWLINE, c.INDENT, e.text, c.MANDATORY_NEWLINE, c.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(c.NO_NEWLINE, c.SPACE, e.text, c.MANDATORY_NEWLINE, c.INDENT) : this.layout.add(e.text, c.MANDATORY_NEWLINE, c.INDENT);
27588
27619
  }
27589
27620
  formatBlockComment(e) {
27590
- e.type === U.block_comment && this.isMultilineBlockComment(e) ? (this.splitBlockComment(e.text).forEach((t) => {
27591
- this.layout.add(_.NEWLINE, _.INDENT, t);
27592
- }), this.layout.add(_.NEWLINE, _.INDENT)) : this.layout.add(e.text, _.SPACE);
27621
+ e.type === p.block_comment && this.isMultilineBlockComment(e) ? (this.splitBlockComment(e.text).forEach((t) => {
27622
+ this.layout.add(c.NEWLINE, c.INDENT, t);
27623
+ }), this.layout.add(c.NEWLINE, c.INDENT)) : this.layout.add(e.text, c.SPACE);
27593
27624
  }
27594
27625
  isMultilineBlockComment(e) {
27595
27626
  return tt(e.text) || tt(e.precedingWhitespace || "");
@@ -27600,7 +27631,7 @@ class Pe {
27600
27631
  // first line starts with /* or /**
27601
27632
  /^\/\*\*?$/.test(t[0]) && // intermediate lines start with *
27602
27633
  t.slice(1, t.length - 1).every((E) => /^\s*\*/.test(E)) && // last line ends with */
27603
- /^\s*\*\/$/.test(Se(t))
27634
+ /^\s*\*\/$/.test(Ie(t))
27604
27635
  );
27605
27636
  }
27606
27637
  // Breaks up block comment to multiple lines.
@@ -27673,16 +27704,16 @@ class Pe {
27673
27704
  }
27674
27705
  }
27675
27706
  formatJoin(e) {
27676
- re(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e), _.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e), _.SPACE);
27707
+ Te(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e), c.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e), c.SPACE);
27677
27708
  }
27678
27709
  formatKeyword(e) {
27679
- this.layout.add(this.showKw(e), _.SPACE);
27710
+ this.layout.add(this.showKw(e), c.SPACE);
27680
27711
  }
27681
27712
  formatLogicalOperator(e) {
27682
- this.cfg.logicalOperatorNewline === "before" ? re(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e), _.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(_.NEWLINE, _.INDENT, this.showKw(e), _.SPACE) : this.layout.add(this.showKw(e), _.NEWLINE, _.INDENT);
27713
+ this.cfg.logicalOperatorNewline === "before" ? Te(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e), c.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(c.NEWLINE, c.INDENT, this.showKw(e), c.SPACE) : this.layout.add(this.showKw(e), c.NEWLINE, c.INDENT);
27683
27714
  }
27684
27715
  formatDataType(e) {
27685
- this.layout.add(this.showDataType(e), _.SPACE);
27716
+ this.layout.add(this.showDataType(e), c.SPACE);
27686
27717
  }
27687
27718
  showKw(e) {
27688
27719
  return aE(e.tokenType) ? TE(this.showNonTabularKw(e), this.cfg.indentStyle) : this.showNonTabularKw(e);
@@ -27762,7 +27793,7 @@ class Ca {
27762
27793
  params: this.params,
27763
27794
  layout: new UE(new fE(xT(this.cfg)))
27764
27795
  }).format(e.children);
27765
- return e.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? t.add(_.NEWLINE, ";") : t.add(_.NO_NEWLINE, ";")), t.toString();
27796
+ return e.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? t.add(c.NEWLINE, ";") : t.add(c.NO_NEWLINE, ";")), t.toString();
27766
27797
  }
27767
27798
  }
27768
27799
  class de extends Error {
@@ -27846,7 +27877,7 @@ const hE = {
27846
27877
  const s = la(Object.assign(Object.assign({}, da), E));
27847
27878
  return new Ca(vT(t), s).format(n);
27848
27879
  };
27849
- function Re(n, e) {
27880
+ function Se(n, e) {
27850
27881
  try {
27851
27882
  return Da(n, {
27852
27883
  language: {
@@ -27907,7 +27938,7 @@ class Nt {
27907
27938
  * Validates calculated measures during registration
27908
27939
  */
27909
27940
  registerCube(e) {
27910
- e.meta && console.log(`[DEBUG] registerCube: ${e.name} has meta:`, JSON.stringify(e.meta)), this.validateCalculatedMeasures(e), new te(this.cubes).populateDependencies(e), this.cubes.set(e.name, e), this.invalidateMetadataCache();
27941
+ e.meta && console.log(`[DEBUG] registerCube: ${e.name} has meta:`, JSON.stringify(e.meta)), this.validateCalculatedMeasures(e), new se(this.cubes).populateDependencies(e), this.cubes.set(e.name, e), this.invalidateMetadataCache();
27911
27942
  }
27912
27943
  /**
27913
27944
  * Validate calculated measures in a cube
@@ -27932,7 +27963,7 @@ class Nt {
27932
27963
  }
27933
27964
  const r = new Map(this.cubes);
27934
27965
  r.set(e.name, e);
27935
- const T = new te(r);
27966
+ const T = new se(r);
27936
27967
  try {
27937
27968
  T.validateDependencies(e);
27938
27969
  } catch (A) {
@@ -27942,7 +27973,7 @@ class Nt {
27942
27973
  if (t.length === 0) {
27943
27974
  const E = new Map(this.cubes);
27944
27975
  E.set(e.name, e);
27945
- const s = new te(E);
27976
+ const s = new se(E);
27946
27977
  s.buildGraph(e);
27947
27978
  const i = s.detectCycle();
27948
27979
  i && t.push(
@@ -27981,7 +28012,7 @@ ${t.join(`
27981
28012
  async execute(e, t, E) {
27982
28013
  if (!this.dbExecutor)
27983
28014
  throw new Error("Database executor not configured");
27984
- return new z(this.dbExecutor, this.cacheConfig).execute(this.cubes, e, t, E);
28015
+ return new te(this.dbExecutor, this.cacheConfig).execute(this.cubes, e, t, E);
27985
28016
  }
27986
28017
  /**
27987
28018
  * Execute a multi-cube query
@@ -28118,9 +28149,9 @@ ${t.join(`
28118
28149
  throw new Error(`Cube '${e}' not found`);
28119
28150
  if (!this.dbExecutor)
28120
28151
  throw new Error("Database executor not configured");
28121
- const r = await new z(this.dbExecutor).generateSQL(s, t, E), T = this.dbExecutor.getEngineType();
28152
+ const r = await new te(this.dbExecutor).generateSQL(s, t, E), T = this.dbExecutor.getEngineType();
28122
28153
  return {
28123
- sql: Re(r.sql, T),
28154
+ sql: Se(r.sql, T),
28124
28155
  params: r.params
28125
28156
  };
28126
28157
  }
@@ -28130,9 +28161,9 @@ ${t.join(`
28130
28161
  async generateMultiCubeSQL(e, t) {
28131
28162
  if (!this.dbExecutor)
28132
28163
  throw new Error("Database executor not configured");
28133
- const s = await new z(this.dbExecutor).generateMultiCubeSQL(this.cubes, e, t), i = this.dbExecutor.getEngineType();
28164
+ const s = await new te(this.dbExecutor).generateMultiCubeSQL(this.cubes, e, t), i = this.dbExecutor.getEngineType();
28134
28165
  return {
28135
- sql: Re(s.sql, i),
28166
+ sql: Se(s.sql, i),
28136
28167
  params: s.params
28137
28168
  };
28138
28169
  }
@@ -28143,9 +28174,9 @@ ${t.join(`
28143
28174
  async dryRunFunnel(e, t) {
28144
28175
  if (!this.dbExecutor)
28145
28176
  throw new Error("Database executor not configured");
28146
- const s = await new z(this.dbExecutor).dryRunFunnel(this.cubes, e, t), i = this.dbExecutor.getEngineType();
28177
+ const s = await new te(this.dbExecutor).dryRunFunnel(this.cubes, e, t), i = this.dbExecutor.getEngineType();
28147
28178
  return {
28148
- sql: Re(s.sql, i),
28179
+ sql: Se(s.sql, i),
28149
28180
  params: s.params
28150
28181
  };
28151
28182
  }
@@ -28156,9 +28187,9 @@ ${t.join(`
28156
28187
  async dryRunFlow(e, t) {
28157
28188
  if (!this.dbExecutor)
28158
28189
  throw new Error("Database executor not configured");
28159
- const s = await new z(this.dbExecutor).dryRunFlow(this.cubes, e, t), i = this.dbExecutor.getEngineType();
28190
+ const s = await new te(this.dbExecutor).dryRunFlow(this.cubes, e, t), i = this.dbExecutor.getEngineType();
28160
28191
  return {
28161
- sql: Re(s.sql, i),
28192
+ sql: Se(s.sql, i),
28162
28193
  params: s.params
28163
28194
  };
28164
28195
  }
@@ -28169,9 +28200,9 @@ ${t.join(`
28169
28200
  async dryRunRetention(e, t) {
28170
28201
  if (!this.dbExecutor)
28171
28202
  throw new Error("Database executor not configured");
28172
- const s = await new z(this.dbExecutor).dryRunRetention(this.cubes, e, t), i = this.dbExecutor.getEngineType();
28203
+ const s = await new te(this.dbExecutor).dryRunRetention(this.cubes, e, t), i = this.dbExecutor.getEngineType();
28173
28204
  return {
28174
- sql: Re(s.sql, i),
28205
+ sql: Se(s.sql, i),
28175
28206
  params: s.params
28176
28207
  };
28177
28208
  }
@@ -28183,7 +28214,7 @@ ${t.join(`
28183
28214
  async explainQuery(e, t, E) {
28184
28215
  if (!this.dbExecutor)
28185
28216
  throw new Error("Database executor not configured");
28186
- return new z(this.dbExecutor).explainQuery(this.cubes, e, t, E);
28217
+ return new te(this.dbExecutor).explainQuery(this.cubes, e, t, E);
28187
28218
  }
28188
28219
  /**
28189
28220
  * Check if a cube exists
@@ -29148,7 +29179,7 @@ function ga(n, e) {
29148
29179
  );
29149
29180
  return t[e.length][n.length];
29150
29181
  }
29151
- function w(n, e) {
29182
+ function v(n, e) {
29152
29183
  const t = n.toLowerCase().trim(), E = e.toLowerCase().trim();
29153
29184
  if (t === E) return 1;
29154
29185
  if (E.includes(t)) return 0.9;
@@ -29163,7 +29194,7 @@ function w(n, e) {
29163
29194
  function pe(n, e) {
29164
29195
  let t = 0;
29165
29196
  for (const E of e) {
29166
- const s = w(n, E);
29197
+ const s = v(n, E);
29167
29198
  s > t && (t = s);
29168
29199
  }
29169
29200
  return t;
@@ -29266,22 +29297,22 @@ function ya(n, e) {
29266
29297
  let t = 0;
29267
29298
  const E = [], s = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map();
29268
29299
  for (const a of e) {
29269
- const R = w(a, n.name);
29300
+ const R = v(a, n.name);
29270
29301
  R > 0.5 && (t += R * 2, E.includes("name") || E.push("name"));
29271
- const S = w(a, n.title);
29302
+ const S = v(a, n.title);
29272
29303
  if (S > 0.5 && (t += S * 1.5, E.includes("title") || E.push("title")), n.description) {
29273
- const I = w(a, n.description);
29304
+ const I = v(a, n.description);
29274
29305
  I > 0.3 && (t += I, E.includes("description") || E.push("description"));
29275
29306
  }
29276
29307
  if (n.exampleQuestions)
29277
29308
  for (const I of n.exampleQuestions) {
29278
- const N = w(a, I);
29309
+ const N = v(a, I);
29279
29310
  N > 0.3 && (t += N * 1.5, E.includes("exampleQuestions") || E.push("exampleQuestions"));
29280
29311
  }
29281
29312
  for (const I of n.measures) {
29282
29313
  let N = 0;
29283
29314
  const O = I.name.split(".").pop() || I.name;
29284
- if (N = Math.max(N, w(a, O)), N = Math.max(N, w(a, I.title)), I.description && (N = Math.max(N, w(a, I.description) * 0.8)), I.synonyms && (N = Math.max(N, pe(a, I.synonyms))), N > 0.4) {
29315
+ if (N = Math.max(N, v(a, O)), N = Math.max(N, v(a, I.title)), I.description && (N = Math.max(N, v(a, I.description) * 0.8)), I.synonyms && (N = Math.max(N, pe(a, I.synonyms))), N > 0.4) {
29285
29316
  t += N, E.includes("measures") || E.push("measures");
29286
29317
  const C = s.get(I.name) || 0;
29287
29318
  s.set(I.name, Math.max(C, N));
@@ -29290,7 +29321,7 @@ function ya(n, e) {
29290
29321
  for (const I of n.dimensions) {
29291
29322
  let N = 0;
29292
29323
  const O = I.name.split(".").pop() || I.name;
29293
- if (N = Math.max(N, w(a, O)), N = Math.max(N, w(a, I.title)), I.description && (N = Math.max(N, w(a, I.description) * 0.8)), I.synonyms && (N = Math.max(N, pe(a, I.synonyms))), N > 0.4) {
29324
+ if (N = Math.max(N, v(a, O)), N = Math.max(N, v(a, I.title)), I.description && (N = Math.max(N, v(a, I.description) * 0.8)), I.synonyms && (N = Math.max(N, pe(a, I.synonyms))), N > 0.4) {
29294
29325
  t += N, E.includes("dimensions") || E.push("dimensions");
29295
29326
  const C = i.get(I.name) || 0;
29296
29327
  i.set(I.name, Math.max(C, N));
@@ -29415,14 +29446,14 @@ function Ot(n, e, t) {
29415
29446
  if (!t || t === "measure")
29416
29447
  for (const i of s.measures) {
29417
29448
  const r = i.name.split(".").pop() || i.name;
29418
- let T = w(e, r);
29419
- T = Math.max(T, w(e, i.title)), i.synonyms && (T = Math.max(T, pe(e, i.synonyms))), T > 0.5 && (!E || T > E.score) && (E = { field: i.name, cube: s.name, score: T, type: "measure" });
29449
+ let T = v(e, r);
29450
+ T = Math.max(T, v(e, i.title)), i.synonyms && (T = Math.max(T, pe(e, i.synonyms))), T > 0.5 && (!E || T > E.score) && (E = { field: i.name, cube: s.name, score: T, type: "measure" });
29420
29451
  }
29421
29452
  if (!t || t === "dimension")
29422
29453
  for (const i of s.dimensions) {
29423
29454
  const r = i.name.split(".").pop() || i.name;
29424
- let T = w(e, r);
29425
- T = Math.max(T, w(e, i.title)), i.synonyms && (T = Math.max(T, pe(e, i.synonyms))), T > 0.5 && (!E || T > E.score) && (E = { field: i.name, cube: s.name, score: T, type: "dimension" });
29455
+ let T = v(e, r);
29456
+ T = Math.max(T, v(e, i.title)), i.synonyms && (T = Math.max(T, pe(e, i.synonyms))), T > 0.5 && (!E || T > E.score) && (E = { field: i.name, cube: s.name, score: T, type: "dimension" });
29426
29457
  }
29427
29458
  }
29428
29459
  return E;
@@ -29645,7 +29676,7 @@ function so(n, e, t) {
29645
29676
  const u = n.find((l) => l.name === t);
29646
29677
  u ? (T = [u], E.push(`Using specified cube: ${t}`)) : (s.push(`Specified cube '${t}' not found`), T = []);
29647
29678
  } else
29648
- T = ba(n, { intent: e, limit: 3 }).map((l) => n.find((c) => c.name === l.cube)).filter((l) => l !== void 0), T.length > 0 && E.push(`Identified relevant cubes: ${T.map((l) => l.name).join(", ")}`);
29679
+ T = ba(n, { intent: e, limit: 3 }).map((l) => n.find((_) => _.name === l.cube)).filter((l) => l !== void 0), T.length > 0 && E.push(`Identified relevant cubes: ${T.map((l) => l.name).join(", ")}`);
29649
29680
  if (T.length === 0) {
29650
29681
  const u = r !== "query", l = u ? SE(r, void 0) : void 0;
29651
29682
  return {
@@ -29663,14 +29694,14 @@ function so(n, e, t) {
29663
29694
  R && (E.push(`Detected ${R.type} aggregation intent`), a += 0.1);
29664
29695
  const S = [], I = e.toLowerCase();
29665
29696
  for (const u of A.measures) {
29666
- const c = [
29697
+ const _ = [
29667
29698
  (u.name.split(".").pop() || u.name).toLowerCase(),
29668
29699
  u.title.toLowerCase(),
29669
- ...(u.synonyms || []).map((D) => D.toLowerCase())
29700
+ ...(u.synonyms || []).map((U) => U.toLowerCase())
29670
29701
  ];
29671
- for (const D of c)
29672
- if (I.includes(D)) {
29673
- S.push(u.name), E.push(`Matched measure '${u.name}' via keyword '${D}'`), a += 0.15;
29702
+ for (const U of _)
29703
+ if (I.includes(U)) {
29704
+ S.push(u.name), E.push(`Matched measure '${u.name}' via keyword '${U}'`), a += 0.15;
29674
29705
  break;
29675
29706
  }
29676
29707
  }
@@ -29680,7 +29711,7 @@ function so(n, e, t) {
29680
29711
  S.push(u[0].name), E.push(`Suggested ${u[0].name} based on ${R.type} intent`);
29681
29712
  else if (R.type === "count") {
29682
29713
  const l = A.measures.find(
29683
- (c) => c.type === "count" || c.type === "countDistinct"
29714
+ (_) => _.type === "count" || _.type === "countDistinct"
29684
29715
  );
29685
29716
  l && (S.push(l.name), E.push(`Suggested ${l.name} for counting`));
29686
29717
  }
@@ -29693,13 +29724,13 @@ function so(n, e, t) {
29693
29724
  }
29694
29725
  for (const u of T)
29695
29726
  for (const l of u.dimensions) {
29696
- const D = [
29727
+ const U = [
29697
29728
  (l.name.split(".").pop() || l.name).toLowerCase(),
29698
29729
  l.title.toLowerCase(),
29699
- ...(l.synonyms || []).map((p) => p.toLowerCase())
29730
+ ...(l.synonyms || []).map((D) => D.toLowerCase())
29700
29731
  ];
29701
- for (const p of D)
29702
- if (I.includes(p) && !O.includes(l.name) && (I.includes(`by ${p}`) || I.includes(`per ${p}`))) {
29732
+ for (const D of U)
29733
+ if (I.includes(D) && !O.includes(l.name) && (I.includes(`by ${D}`) || I.includes(`per ${D}`))) {
29703
29734
  O.push(l.name), E.push(`Matched dimension '${l.name}' as grouping`), a += 0.1;
29704
29735
  break;
29705
29736
  }
@@ -29754,7 +29785,7 @@ function $a(n, e) {
29754
29785
  );
29755
29786
  return t[e.length][n.length];
29756
29787
  }
29757
- function oe(n, e) {
29788
+ function Ae(n, e) {
29758
29789
  let t = null;
29759
29790
  for (const E of e) {
29760
29791
  const s = $a(n.toLowerCase(), E.toLowerCase());
@@ -29774,7 +29805,7 @@ function wa(n, e, t, E) {
29774
29805
  }
29775
29806
  const [i, r] = s, T = e.find((a) => a.name === i);
29776
29807
  if (!T) {
29777
- const a = e.map((S) => S.name), R = oe(i, a);
29808
+ const a = e.map((S) => S.name), R = Ae(i, a);
29778
29809
  R ? (t.push({
29779
29810
  type: "cube_not_found",
29780
29811
  message: `Cube '${i}' not found`,
@@ -29800,7 +29831,7 @@ function wa(n, e, t, E) {
29800
29831
  correctedValue: a.field
29801
29832
  }), E.set(n, a.field);
29802
29833
  else {
29803
- const R = T.measures.map((I) => I.name.split(".").pop()), S = oe(r, R);
29834
+ const R = T.measures.map((I) => I.name.split(".").pop()), S = Ae(r, R);
29804
29835
  if (S) {
29805
29836
  const I = `${i}.${S.field}`;
29806
29837
  t.push({
@@ -29820,7 +29851,7 @@ function wa(n, e, t, E) {
29820
29851
  }
29821
29852
  }
29822
29853
  }
29823
- function k(n, e, t, E) {
29854
+ function q(n, e, t, E) {
29824
29855
  const s = n.split(".");
29825
29856
  if (s.length !== 2) {
29826
29857
  t.push({
@@ -29832,7 +29863,7 @@ function k(n, e, t, E) {
29832
29863
  }
29833
29864
  const [i, r] = s, T = e.find((a) => a.name === i);
29834
29865
  if (!T) {
29835
- const a = e.map((S) => S.name), R = oe(i, a);
29866
+ const a = e.map((S) => S.name), R = Ae(i, a);
29836
29867
  R ? (t.push({
29837
29868
  type: "cube_not_found",
29838
29869
  message: `Cube '${i}' not found`,
@@ -29858,7 +29889,7 @@ function k(n, e, t, E) {
29858
29889
  correctedValue: a.field
29859
29890
  }), E.set(n, a.field);
29860
29891
  else {
29861
- const R = T.dimensions.map((I) => I.name.split(".").pop()), S = oe(r, R);
29892
+ const R = T.dimensions.map((I) => I.name.split(".").pop()), S = Ae(r, R);
29862
29893
  if (S) {
29863
29894
  const I = `${i}.${S.field}`;
29864
29895
  t.push({
@@ -29900,7 +29931,7 @@ function Me(n, e, t, E) {
29900
29931
  }
29901
29932
  const [T, A] = r, a = e.find((I) => I.name === T);
29902
29933
  if (!a) {
29903
- const I = e.map((O) => O.name), N = oe(T, I);
29934
+ const I = e.map((O) => O.name), N = Ae(T, I);
29904
29935
  N && E.set(i, `${N.field}.${A}`), t.push({
29905
29936
  type: "cube_not_found",
29906
29937
  message: `Cube '${T}' not found in filter`,
@@ -29915,7 +29946,7 @@ function Me(n, e, t, E) {
29915
29946
  const I = [
29916
29947
  ...a.dimensions.map((O) => O.name.split(".").pop()),
29917
29948
  ...a.measures.map((O) => O.name.split(".").pop())
29918
- ], N = oe(A, I);
29949
+ ], N = Ae(A, I);
29919
29950
  if (N) {
29920
29951
  const O = `${T}.${N.field}`;
29921
29952
  E.set(i, O), t.push({
@@ -29938,10 +29969,10 @@ function Me(n, e, t, E) {
29938
29969
  function Wa(n, e, t, E, s) {
29939
29970
  const i = n.funnel;
29940
29971
  if (i)
29941
- if (i.bindingKey ? typeof i.bindingKey == "string" && k(i.bindingKey, e, t, s) : t.push({
29972
+ if (i.bindingKey ? typeof i.bindingKey == "string" && q(i.bindingKey, e, t, s) : t.push({
29942
29973
  type: "syntax_error",
29943
29974
  message: "funnel.bindingKey is required"
29944
- }), i.timeDimension ? typeof i.timeDimension == "string" && k(i.timeDimension, e, t, s) : t.push({
29975
+ }), i.timeDimension ? typeof i.timeDimension == "string" && q(i.timeDimension, e, t, s) : t.push({
29945
29976
  type: "syntax_error",
29946
29977
  message: "funnel.timeDimension is required"
29947
29978
  }), !i.steps || !Array.isArray(i.steps))
@@ -29966,13 +29997,13 @@ function Wa(n, e, t, E, s) {
29966
29997
  }
29967
29998
  function va(n, e, t, E, s) {
29968
29999
  const i = n.flow;
29969
- i && (i.bindingKey ? typeof i.bindingKey == "string" && k(i.bindingKey, e, t, s) : t.push({
30000
+ i && (i.bindingKey ? typeof i.bindingKey == "string" && q(i.bindingKey, e, t, s) : t.push({
29970
30001
  type: "syntax_error",
29971
30002
  message: "flow.bindingKey is required"
29972
- }), i.timeDimension ? typeof i.timeDimension == "string" && k(i.timeDimension, e, t, s) : t.push({
30003
+ }), i.timeDimension ? typeof i.timeDimension == "string" && q(i.timeDimension, e, t, s) : t.push({
29973
30004
  type: "syntax_error",
29974
30005
  message: "flow.timeDimension is required"
29975
- }), i.eventDimension ? typeof i.eventDimension == "string" && k(i.eventDimension, e, t, s) : t.push({
30006
+ }), i.eventDimension ? typeof i.eventDimension == "string" && q(i.eventDimension, e, t, s) : t.push({
29976
30007
  type: "syntax_error",
29977
30008
  message: "flow.eventDimension is required"
29978
30009
  }), i.stepsBefore === void 0 && i.stepsAfter === void 0 && E.push({
@@ -29983,10 +30014,10 @@ function va(n, e, t, E, s) {
29983
30014
  }
29984
30015
  function Xa(n, e, t, E, s) {
29985
30016
  const i = n.retention;
29986
- i && (i.bindingKey ? typeof i.bindingKey == "string" && k(i.bindingKey, e, t, s) : t.push({
30017
+ i && (i.bindingKey ? typeof i.bindingKey == "string" && q(i.bindingKey, e, t, s) : t.push({
29987
30018
  type: "syntax_error",
29988
30019
  message: "retention.bindingKey is required"
29989
- }), i.timeDimension ? typeof i.timeDimension == "string" && k(i.timeDimension, e, t, s) : t.push({
30020
+ }), i.timeDimension ? typeof i.timeDimension == "string" && q(i.timeDimension, e, t, s) : t.push({
29990
30021
  type: "syntax_error",
29991
30022
  message: "retention.timeDimension is required"
29992
30023
  }), i.granularity || E.push({
@@ -30028,10 +30059,10 @@ function no(n, e) {
30028
30059
  wa(r, e, t, s);
30029
30060
  if (n.dimensions)
30030
30061
  for (const r of n.dimensions)
30031
- k(r, e, t, s);
30062
+ q(r, e, t, s);
30032
30063
  if (n.timeDimensions)
30033
30064
  for (const r of n.timeDimensions) {
30034
- k(r.dimension, e, t, s);
30065
+ q(r.dimension, e, t, s);
30035
30066
  const [T] = r.dimension.split("."), A = e.find((a) => a.name === T);
30036
30067
  if (A) {
30037
30068
  const a = A.dimensions.find((R) => R.name === r.dimension);
@@ -30084,7 +30115,7 @@ export {
30084
30115
  NE as MySQLExecutor,
30085
30116
  JE as PostgresExecutor,
30086
30117
  ls as QueryBuilder,
30087
- z as QueryExecutor,
30118
+ te as QueryExecutor,
30088
30119
  CE as QueryPlanner,
30089
30120
  zE as SQLiteExecutor,
30090
30121
  pa as STEP0_VALIDATION_PROMPT,
@@ -30115,7 +30146,7 @@ export {
30115
30146
  Qa as getCubeInvalidationPattern,
30116
30147
  Tt as getJoinType,
30117
30148
  os as normalizeQuery,
30118
- J as resolveCubeReference,
30119
- F as resolveSqlExpression,
30149
+ Q as resolveCubeReference,
30150
+ b as resolveSqlExpression,
30120
30151
  so as suggestQuery
30121
30152
  };