drizzle-cube 0.1.41 → 0.1.43

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 (33) hide show
  1. package/dist/adapters/{compiler-CkjmApqo.js → compiler-B57cLx38.js} +1148 -1118
  2. package/dist/adapters/express/index.js +1 -1
  3. package/dist/adapters/fastify/index.js +1 -1
  4. package/dist/adapters/hono/index.js +1 -1
  5. package/dist/adapters/nextjs/index.js +1 -1
  6. package/dist/client/charts.js +1 -1
  7. package/dist/client/chunks/{charts-VcPFhxyE.js → charts-DgmZAw3A.js} +2 -2
  8. package/dist/client/chunks/{charts-VcPFhxyE.js.map → charts-DgmZAw3A.js.map} +1 -1
  9. package/dist/client/chunks/{components-DnCh4Y4N.js → components-BI1Xc4js.js} +8972 -8015
  10. package/dist/client/chunks/components-BI1Xc4js.js.map +1 -0
  11. package/dist/client/chunks/{icons-MNJ50ahP.js → icons-oifcbJCc.js} +309 -255
  12. package/dist/client/chunks/icons-oifcbJCc.js.map +1 -0
  13. package/dist/client/chunks/{providers-DwDirAYo.js → providers-ChcxFwXu.js} +66 -64
  14. package/dist/client/chunks/providers-ChcxFwXu.js.map +1 -0
  15. package/dist/client/components/AnalyticsDashboard.d.ts +1 -1
  16. package/dist/client/components/DashboardFilterPanel.d.ts +15 -0
  17. package/dist/client/components/DashboardGrid.d.ts +5 -2
  18. package/dist/client/components/PortletFilterConfigModal.d.ts +11 -0
  19. package/dist/client/components.js +2 -2
  20. package/dist/client/hooks.js +17 -17
  21. package/dist/client/hooks.js.map +1 -1
  22. package/dist/client/index.js +3 -3
  23. package/dist/client/providers.js +1 -1
  24. package/dist/client/styles.css +1 -1
  25. package/dist/client/types.d.ts +12 -0
  26. package/dist/client/utils/filterUtils.d.ts +40 -0
  27. package/dist/client-bundle-stats.html +1 -1
  28. package/dist/server/index.d.ts +1 -0
  29. package/dist/server/index.js +854 -824
  30. package/package.json +1 -1
  31. package/dist/client/chunks/components-DnCh4Y4N.js.map +0 -1
  32. package/dist/client/chunks/icons-MNJ50ahP.js.map +0 -1
  33. package/dist/client/chunks/providers-DwDirAYo.js.map +0 -1
@@ -174,74 +174,74 @@ class H {
174
174
  }), {
175
175
  casing: A,
176
176
  escapeName: S,
177
- escapeParam: N,
177
+ escapeParam: I,
178
178
  prepareTyping: t,
179
- inlineParams: C,
179
+ inlineParams: s,
180
180
  paramStartIndex: O
181
181
  } = R;
182
- return De(E.map((I) => {
183
- if (d(I, f))
184
- return { sql: I.value.join(""), params: [] };
185
- if (d(I, ZE))
186
- return { sql: S(I.value), params: [] };
187
- if (I === void 0)
182
+ return De(E.map((N) => {
183
+ if (d(N, f))
184
+ return { sql: N.value.join(""), params: [] };
185
+ if (d(N, ZE))
186
+ return { sql: S(N.value), params: [] };
187
+ if (N === void 0)
188
188
  return { sql: "", params: [] };
189
- if (Array.isArray(I)) {
190
- const s = [new f("(")];
191
- for (const [r, _] of I.entries())
192
- s.push(_), r < I.length - 1 && s.push(new f(", "));
193
- return s.push(new f(")")), this.buildQueryFromSourceParams(s, R);
189
+ if (Array.isArray(N)) {
190
+ const C = [new f("(")];
191
+ for (const [L, n] of N.entries())
192
+ C.push(n), L < N.length - 1 && C.push(new f(", "));
193
+ return C.push(new f(")")), this.buildQueryFromSourceParams(C, R);
194
194
  }
195
- if (d(I, H))
196
- return this.buildQueryFromSourceParams(I.queryChunks, {
195
+ if (d(N, H))
196
+ return this.buildQueryFromSourceParams(N.queryChunks, {
197
197
  ...R,
198
- inlineParams: C || I.shouldInlineParams
198
+ inlineParams: s || N.shouldInlineParams
199
199
  });
200
- if (d(I, W)) {
201
- const s = I[W.Symbol.Schema], r = I[W.Symbol.Name];
200
+ if (d(N, W)) {
201
+ const C = N[W.Symbol.Schema], L = N[W.Symbol.Name];
202
202
  return {
203
- sql: s === void 0 || I[sE] ? S(r) : S(s) + "." + S(r),
203
+ sql: C === void 0 || N[sE] ? S(L) : S(C) + "." + S(L),
204
204
  params: []
205
205
  };
206
206
  }
207
- if (d(I, RE)) {
208
- const s = A.getColumnCasing(I);
207
+ if (d(N, RE)) {
208
+ const C = A.getColumnCasing(N);
209
209
  if (e.invokeSource === "indexes")
210
- return { sql: S(s), params: [] };
211
- const r = I.table[W.Symbol.Schema];
210
+ return { sql: S(C), params: [] };
211
+ const L = N.table[W.Symbol.Schema];
212
212
  return {
213
- sql: I.table[sE] || r === void 0 ? S(I.table[W.Symbol.Name]) + "." + S(s) : S(r) + "." + S(I.table[W.Symbol.Name]) + "." + S(s),
213
+ sql: N.table[sE] || L === void 0 ? S(N.table[W.Symbol.Name]) + "." + S(C) : S(L) + "." + S(N.table[W.Symbol.Name]) + "." + S(C),
214
214
  params: []
215
215
  };
216
216
  }
217
- if (d(I, qT)) {
218
- const s = I[TE].schema, r = I[TE].name;
217
+ if (d(N, qT)) {
218
+ const C = N[TE].schema, L = N[TE].name;
219
219
  return {
220
- sql: s === void 0 || I[TE].isAlias ? S(r) : S(s) + "." + S(r),
220
+ sql: C === void 0 || N[TE].isAlias ? S(L) : S(C) + "." + S(L),
221
221
  params: []
222
222
  };
223
223
  }
224
- if (d(I, CE)) {
225
- if (d(I.value, rE))
226
- return { sql: N(O.value++, I), params: [I], typings: ["none"] };
227
- const s = I.value === null ? null : I.encoder.mapToDriverValue(I.value);
228
- if (d(s, H))
229
- return this.buildQueryFromSourceParams([s], R);
230
- if (C)
231
- return { sql: this.mapInlineParam(s, R), params: [] };
232
- let r = ["none"];
233
- return t && (r = [t(I.encoder)]), { sql: N(O.value++, s), params: [s], typings: r };
224
+ if (d(N, CE)) {
225
+ if (d(N.value, rE))
226
+ return { sql: I(O.value++, N), params: [N], typings: ["none"] };
227
+ const C = N.value === null ? null : N.encoder.mapToDriverValue(N.value);
228
+ if (d(C, H))
229
+ return this.buildQueryFromSourceParams([C], R);
230
+ if (s)
231
+ return { sql: this.mapInlineParam(C, R), params: [] };
232
+ let L = ["none"];
233
+ return t && (L = [t(N.encoder)]), { sql: I(O.value++, C), params: [C], typings: L };
234
234
  }
235
- return d(I, rE) ? { sql: N(O.value++, I), params: [I], typings: ["none"] } : d(I, H.Aliased) && I.fieldAlias !== void 0 ? { sql: S(I.fieldAlias), params: [] } : d(I, xT) ? I._.isWith ? { sql: S(I._.alias), params: [] } : this.buildQueryFromSourceParams([
235
+ return d(N, rE) ? { sql: I(O.value++, N), params: [N], typings: ["none"] } : d(N, H.Aliased) && N.fieldAlias !== void 0 ? { sql: S(N.fieldAlias), params: [] } : d(N, xT) ? N._.isWith ? { sql: S(N._.alias), params: [] } : this.buildQueryFromSourceParams([
236
236
  new f("("),
237
- I._.sql,
237
+ N._.sql,
238
238
  new f(") "),
239
- new ZE(I._.alias)
240
- ], R) : ie(I) ? I.schema ? { sql: S(I.schema) + "." + S(I.enumName), params: [] } : { sql: S(I.enumName), params: [] } : vT(I) ? I.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([I.getSQL()], R) : this.buildQueryFromSourceParams([
239
+ new ZE(N._.alias)
240
+ ], R) : ie(N) ? N.schema ? { sql: S(N.schema) + "." + S(N.enumName), params: [] } : { sql: S(N.enumName), params: [] } : vT(N) ? N.shouldOmitSQLParens?.() ? this.buildQueryFromSourceParams([N.getSQL()], R) : this.buildQueryFromSourceParams([
241
241
  new f("("),
242
- I.getSQL(),
242
+ N.getSQL(),
243
243
  new f(")")
244
- ], R) : C ? { sql: this.mapInlineParam(I, R), params: [] } : { sql: N(O.value++, I), params: [I], typings: ["none"] };
244
+ ], R) : s ? { sql: this.mapInlineParam(N, R), params: [] } : { sql: I(O.value++, N), params: [N], typings: ["none"] };
245
245
  }));
246
246
  }
247
247
  mapInlineParam(E, { escapeString: e }) {
@@ -315,7 +315,7 @@ class CE {
315
315
  return new H([this]);
316
316
  }
317
317
  }
318
- function L(T, ...E) {
318
+ function r(T, ...E) {
319
319
  const e = [];
320
320
  (E.length > 0 || T.length > 0 && T[0] !== "") && e.push(new f(T[0]));
321
321
  for (const [R, A] of E.entries())
@@ -327,34 +327,34 @@ function L(T, ...E) {
327
327
  return new H([]);
328
328
  }
329
329
  T.empty = E;
330
- function e(C) {
331
- return new H(C);
330
+ function e(s) {
331
+ return new H(s);
332
332
  }
333
333
  T.fromList = e;
334
- function R(C) {
335
- return new H([new f(C)]);
334
+ function R(s) {
335
+ return new H([new f(s)]);
336
336
  }
337
337
  T.raw = R;
338
- function A(C, O) {
339
- const I = [];
340
- for (const [s, r] of C.entries())
341
- s > 0 && O !== void 0 && I.push(O), I.push(r);
342
- return new H(I);
338
+ function A(s, O) {
339
+ const N = [];
340
+ for (const [C, L] of s.entries())
341
+ C > 0 && O !== void 0 && N.push(O), N.push(L);
342
+ return new H(N);
343
343
  }
344
344
  T.join = A;
345
- function S(C) {
346
- return new ZE(C);
345
+ function S(s) {
346
+ return new ZE(s);
347
347
  }
348
348
  T.identifier = S;
349
- function N(C) {
350
- return new rE(C);
349
+ function I(s) {
350
+ return new rE(s);
351
351
  }
352
- T.placeholder = N;
353
- function t(C, O) {
354
- return new CE(C, O);
352
+ T.placeholder = I;
353
+ function t(s, O) {
354
+ return new CE(s, O);
355
355
  }
356
356
  T.param = t;
357
- })(L || (L = {}));
357
+ })(r || (r = {}));
358
358
  ((T) => {
359
359
  class E {
360
360
  constructor(R, A) {
@@ -413,10 +413,10 @@ W.prototype.getSQL = function() {
413
413
  xT.prototype.getSQL = function() {
414
414
  return new H([this]);
415
415
  };
416
- function K(T, E) {
416
+ function g(T, E) {
417
417
  return Pe(E) && !vT(T) && !d(T, CE) && !d(T, rE) && !d(T, RE) && !d(T, W) && !d(T, qT) ? new CE(T, E) : T;
418
418
  }
419
- const k = (T, E) => L`${T} = ${K(E, T)}`, ST = (T, E) => L`${T} <> ${K(E, T)}`;
419
+ const k = (T, E) => r`${T} = ${g(E, T)}`, ST = (T, E) => r`${T} <> ${g(E, T)}`;
420
420
  function h(...T) {
421
421
  const E = T.filter(
422
422
  (e) => e !== void 0
@@ -424,7 +424,7 @@ function h(...T) {
424
424
  if (E.length !== 0)
425
425
  return E.length === 1 ? new H(E) : new H([
426
426
  new f("("),
427
- L.join(E, new f(" and ")),
427
+ r.join(E, new f(" and ")),
428
428
  new f(")")
429
429
  ]);
430
430
  }
@@ -435,43 +435,43 @@ function PE(...T) {
435
435
  if (E.length !== 0)
436
436
  return E.length === 1 ? new H(E) : new H([
437
437
  new f("("),
438
- L.join(E, new f(" or ")),
438
+ r.join(E, new f(" or ")),
439
439
  new f(")")
440
440
  ]);
441
441
  }
442
- const ME = (T, E) => L`${T} > ${K(E, T)}`, Q = (T, E) => L`${T} >= ${K(E, T)}`, UE = (T, E) => L`${T} < ${K(E, T)}`, Z = (T, E) => L`${T} <= ${K(E, T)}`;
442
+ const ME = (T, E) => r`${T} > ${g(E, T)}`, Q = (T, E) => r`${T} >= ${g(E, T)}`, UE = (T, E) => r`${T} < ${g(E, T)}`, Z = (T, E) => r`${T} <= ${g(E, T)}`;
443
443
  function lE(T, E) {
444
- return Array.isArray(E) ? E.length === 0 ? L`false` : L`${T} in ${E.map((e) => K(e, T))}` : L`${T} in ${K(E, T)}`;
444
+ return Array.isArray(E) ? E.length === 0 ? r`false` : r`${T} in ${E.map((e) => g(e, T))}` : r`${T} in ${g(E, T)}`;
445
445
  }
446
446
  function IT(T, E) {
447
- return Array.isArray(E) ? E.length === 0 ? L`true` : L`${T} not in ${E.map((e) => K(e, T))}` : L`${T} not in ${K(E, T)}`;
447
+ return Array.isArray(E) ? E.length === 0 ? r`true` : r`${T} not in ${E.map((e) => g(e, T))}` : r`${T} not in ${g(E, T)}`;
448
448
  }
449
449
  function NT(T) {
450
- return L`${T} is null`;
450
+ return r`${T} is null`;
451
451
  }
452
452
  function OT(T) {
453
- return L`${T} is not null`;
453
+ return r`${T} is not null`;
454
454
  }
455
455
  function tT(T) {
456
- return L`${T} asc`;
456
+ return r`${T} asc`;
457
457
  }
458
458
  function Ue(T) {
459
- return L`${T} desc`;
459
+ return r`${T} desc`;
460
460
  }
461
461
  function cE(T) {
462
- return L`count(${T || L.raw("*")})`.mapWith(Number);
462
+ return r`count(${T || r.raw("*")})`.mapWith(Number);
463
463
  }
464
464
  function le(T) {
465
- return L`count(distinct ${T})`.mapWith(Number);
465
+ return r`count(distinct ${T})`.mapWith(Number);
466
466
  }
467
467
  function y(T) {
468
- return L`sum(${T})`.mapWith(String);
468
+ return r`sum(${T})`.mapWith(String);
469
469
  }
470
470
  function AE(T) {
471
- return L`max(${T})`.mapWith(d(T, RE) ? T : String);
471
+ return r`max(${T})`.mapWith(d(T, RE) ? T : String);
472
472
  }
473
473
  function SE(T) {
474
- return L`min(${T})`.mapWith(d(T, RE) ? T : String);
474
+ return r`min(${T})`.mapWith(d(T, RE) ? T : String);
475
475
  }
476
476
  class jE {
477
477
  /**
@@ -510,21 +510,21 @@ class ce extends jE {
510
510
  buildTimeDimension(E, e) {
511
511
  switch (E) {
512
512
  case "year":
513
- return L`DATE_TRUNC('year', ${e}::timestamp)`;
513
+ return r`DATE_TRUNC('year', ${e}::timestamp)`;
514
514
  case "quarter":
515
- return L`DATE_TRUNC('quarter', ${e}::timestamp)`;
515
+ return r`DATE_TRUNC('quarter', ${e}::timestamp)`;
516
516
  case "month":
517
- return L`DATE_TRUNC('month', ${e}::timestamp)`;
517
+ return r`DATE_TRUNC('month', ${e}::timestamp)`;
518
518
  case "week":
519
- return L`DATE_TRUNC('week', ${e}::timestamp)`;
519
+ return r`DATE_TRUNC('week', ${e}::timestamp)`;
520
520
  case "day":
521
- return L`DATE_TRUNC('day', ${e}::timestamp)::timestamp`;
521
+ return r`DATE_TRUNC('day', ${e}::timestamp)::timestamp`;
522
522
  case "hour":
523
- return L`DATE_TRUNC('hour', ${e}::timestamp)`;
523
+ return r`DATE_TRUNC('hour', ${e}::timestamp)`;
524
524
  case "minute":
525
- return L`DATE_TRUNC('minute', ${e}::timestamp)`;
525
+ return r`DATE_TRUNC('minute', ${e}::timestamp)`;
526
526
  case "second":
527
- return L`DATE_TRUNC('second', ${e}::timestamp)`;
527
+ return r`DATE_TRUNC('second', ${e}::timestamp)`;
528
528
  default:
529
529
  return e;
530
530
  }
@@ -536,23 +536,23 @@ class ce extends jE {
536
536
  buildStringCondition(E, e, R) {
537
537
  switch (e) {
538
538
  case "contains":
539
- return L`${E} ILIKE ${`%${R}%`}`;
539
+ return r`${E} ILIKE ${`%${R}%`}`;
540
540
  case "notContains":
541
- return L`${E} NOT ILIKE ${`%${R}%`}`;
541
+ return r`${E} NOT ILIKE ${`%${R}%`}`;
542
542
  case "startsWith":
543
- return L`${E} ILIKE ${`${R}%`}`;
543
+ return r`${E} ILIKE ${`${R}%`}`;
544
544
  case "endsWith":
545
- return L`${E} ILIKE ${`%${R}`}`;
545
+ return r`${E} ILIKE ${`%${R}`}`;
546
546
  case "like":
547
- return L`${E} LIKE ${R}`;
547
+ return r`${E} LIKE ${R}`;
548
548
  case "notLike":
549
- return L`${E} NOT LIKE ${R}`;
549
+ return r`${E} NOT LIKE ${R}`;
550
550
  case "ilike":
551
- return L`${E} ILIKE ${R}`;
551
+ return r`${E} ILIKE ${R}`;
552
552
  case "regex":
553
- return L`${E} ~* ${R}`;
553
+ return r`${E} ~* ${R}`;
554
554
  case "notRegex":
555
- return L`${E} !~* ${R}`;
555
+ return r`${E} !~* ${R}`;
556
556
  default:
557
557
  throw new Error(`Unsupported string operator: ${e}`);
558
558
  }
@@ -564,11 +564,11 @@ class ce extends jE {
564
564
  castToType(E, e) {
565
565
  switch (e) {
566
566
  case "timestamp":
567
- return L`${E}::timestamp`;
567
+ return r`${E}::timestamp`;
568
568
  case "decimal":
569
- return L`${E}::decimal`;
569
+ return r`${E}::decimal`;
570
570
  case "integer":
571
- return L`${E}::integer`;
571
+ return r`${E}::integer`;
572
572
  default:
573
573
  throw new Error(`Unsupported cast type: ${e}`);
574
574
  }
@@ -579,21 +579,21 @@ class ce extends jE {
579
579
  * Extracted from multi-cube-builder.ts:284
580
580
  */
581
581
  buildAvg(E) {
582
- return L`COALESCE(AVG(${E}), 0)`;
582
+ return r`COALESCE(AVG(${E}), 0)`;
583
583
  }
584
584
  /**
585
585
  * Build PostgreSQL CASE WHEN conditional expression
586
586
  */
587
587
  buildCaseWhen(E, e) {
588
- const R = E.map((A) => L`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => L`${A} ${S}`);
589
- return e !== void 0 ? L`CASE ${R} ELSE ${e} END` : L`CASE ${R} END`;
588
+ const R = E.map((A) => r`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => r`${A} ${S}`);
589
+ return e !== void 0 ? r`CASE ${R} ELSE ${e} END` : r`CASE ${R} END`;
590
590
  }
591
591
  /**
592
592
  * Build PostgreSQL boolean literal
593
593
  * PostgreSQL uses TRUE/FALSE keywords
594
594
  */
595
595
  buildBooleanLiteral(E) {
596
- return E ? L`TRUE` : L`FALSE`;
596
+ return E ? r`TRUE` : r`FALSE`;
597
597
  }
598
598
  /**
599
599
  * Convert filter values - PostgreSQL uses native types
@@ -646,12 +646,12 @@ class jT extends jE {
646
646
  };
647
647
  switch (E) {
648
648
  case "quarter":
649
- return L`DATE_ADD(MAKEDATE(YEAR(${e}), 1), INTERVAL (QUARTER(${e}) - 1) * 3 MONTH)`;
649
+ return r`DATE_ADD(MAKEDATE(YEAR(${e}), 1), INTERVAL (QUARTER(${e}) - 1) * 3 MONTH)`;
650
650
  case "week":
651
- return L`DATE_SUB(${e}, INTERVAL WEEKDAY(${e}) DAY)`;
651
+ return r`DATE_SUB(${e}, INTERVAL WEEKDAY(${e}) DAY)`;
652
652
  default:
653
653
  const A = R[E];
654
- return A ? L`STR_TO_DATE(DATE_FORMAT(${e}, ${A}), '%Y-%m-%d %H:%i:%s')` : e;
654
+ return A ? r`STR_TO_DATE(DATE_FORMAT(${e}, ${A}), '%Y-%m-%d %H:%i:%s')` : e;
655
655
  }
656
656
  }
657
657
  /**
@@ -662,23 +662,23 @@ class jT extends jE {
662
662
  buildStringCondition(E, e, R) {
663
663
  switch (e) {
664
664
  case "contains":
665
- return L`LOWER(${E}) LIKE ${`%${R.toLowerCase()}%`}`;
665
+ return r`LOWER(${E}) LIKE ${`%${R.toLowerCase()}%`}`;
666
666
  case "notContains":
667
- return L`LOWER(${E}) NOT LIKE ${`%${R.toLowerCase()}%`}`;
667
+ return r`LOWER(${E}) NOT LIKE ${`%${R.toLowerCase()}%`}`;
668
668
  case "startsWith":
669
- return L`LOWER(${E}) LIKE ${`${R.toLowerCase()}%`}`;
669
+ return r`LOWER(${E}) LIKE ${`${R.toLowerCase()}%`}`;
670
670
  case "endsWith":
671
- return L`LOWER(${E}) LIKE ${`%${R.toLowerCase()}`}`;
671
+ return r`LOWER(${E}) LIKE ${`%${R.toLowerCase()}`}`;
672
672
  case "like":
673
- return L`${E} LIKE ${R}`;
673
+ return r`${E} LIKE ${R}`;
674
674
  case "notLike":
675
- return L`${E} NOT LIKE ${R}`;
675
+ return r`${E} NOT LIKE ${R}`;
676
676
  case "ilike":
677
- return L`LOWER(${E}) LIKE ${R.toLowerCase()}`;
677
+ return r`LOWER(${E}) LIKE ${R.toLowerCase()}`;
678
678
  case "regex":
679
- return L`${E} REGEXP ${R}`;
679
+ return r`${E} REGEXP ${R}`;
680
680
  case "notRegex":
681
- return L`${E} NOT REGEXP ${R}`;
681
+ return r`${E} NOT REGEXP ${R}`;
682
682
  default:
683
683
  throw new Error(`Unsupported string operator: ${e}`);
684
684
  }
@@ -690,11 +690,11 @@ class jT extends jE {
690
690
  castToType(E, e) {
691
691
  switch (e) {
692
692
  case "timestamp":
693
- return L`CAST(${E} AS DATETIME)`;
693
+ return r`CAST(${E} AS DATETIME)`;
694
694
  case "decimal":
695
- return L`CAST(${E} AS DECIMAL(10,2))`;
695
+ return r`CAST(${E} AS DECIMAL(10,2))`;
696
696
  case "integer":
697
- return L`CAST(${E} AS SIGNED INTEGER)`;
697
+ return r`CAST(${E} AS SIGNED INTEGER)`;
698
698
  default:
699
699
  throw new Error(`Unsupported cast type: ${e}`);
700
700
  }
@@ -704,21 +704,21 @@ class jT extends jE {
704
704
  * MySQL AVG returns NULL for empty sets, using IFNULL for consistency
705
705
  */
706
706
  buildAvg(E) {
707
- return L`IFNULL(AVG(${E}), 0)`;
707
+ return r`IFNULL(AVG(${E}), 0)`;
708
708
  }
709
709
  /**
710
710
  * Build MySQL CASE WHEN conditional expression
711
711
  */
712
712
  buildCaseWhen(E, e) {
713
- const R = E.map((A) => L`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => L`${A} ${S}`);
714
- return e !== void 0 ? L`CASE ${R} ELSE ${e} END` : L`CASE ${R} END`;
713
+ const R = E.map((A) => r`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => r`${A} ${S}`);
714
+ return e !== void 0 ? r`CASE ${R} ELSE ${e} END` : r`CASE ${R} END`;
715
715
  }
716
716
  /**
717
717
  * Build MySQL boolean literal
718
718
  * MySQL uses TRUE/FALSE keywords (equivalent to 1/0)
719
719
  */
720
720
  buildBooleanLiteral(E) {
721
- return E ? L`TRUE` : L`FALSE`;
721
+ return E ? r`TRUE` : r`FALSE`;
722
722
  }
723
723
  /**
724
724
  * Convert filter values - MySQL uses native types
@@ -761,28 +761,28 @@ class ue extends jE {
761
761
  buildTimeDimension(E, e) {
762
762
  switch (E) {
763
763
  case "year":
764
- return L`datetime(${e}, 'unixepoch', 'start of year')`;
764
+ return r`datetime(${e}, 'unixepoch', 'start of year')`;
765
765
  case "quarter":
766
- const R = L`datetime(${e}, 'unixepoch')`;
767
- return L`datetime(${R}, 'start of year',
766
+ const R = r`datetime(${e}, 'unixepoch')`;
767
+ return r`datetime(${R}, 'start of year',
768
768
  '+' || (((CAST(strftime('%m', ${R}) AS INTEGER) - 1) / 3) * 3) || ' months')`;
769
769
  case "month":
770
- return L`datetime(${e}, 'unixepoch', 'start of month')`;
770
+ return r`datetime(${e}, 'unixepoch', 'start of month')`;
771
771
  case "week":
772
- return L`date(datetime(${e}, 'unixepoch'), 'weekday 1', '-6 days')`;
772
+ return r`date(datetime(${e}, 'unixepoch'), 'weekday 1', '-6 days')`;
773
773
  case "day":
774
- return L`datetime(${e}, 'unixepoch', 'start of day')`;
774
+ return r`datetime(${e}, 'unixepoch', 'start of day')`;
775
775
  case "hour":
776
- const A = L`datetime(${e}, 'unixepoch')`;
777
- return L`datetime(strftime('%Y-%m-%d %H:00:00', ${A}))`;
776
+ const A = r`datetime(${e}, 'unixepoch')`;
777
+ return r`datetime(strftime('%Y-%m-%d %H:00:00', ${A}))`;
778
778
  case "minute":
779
- const S = L`datetime(${e}, 'unixepoch')`;
780
- return L`datetime(strftime('%Y-%m-%d %H:%M:00', ${S}))`;
779
+ const S = r`datetime(${e}, 'unixepoch')`;
780
+ return r`datetime(strftime('%Y-%m-%d %H:%M:00', ${S}))`;
781
781
  case "second":
782
- const N = L`datetime(${e}, 'unixepoch')`;
783
- return L`datetime(strftime('%Y-%m-%d %H:%M:%S', ${N}))`;
782
+ const I = r`datetime(${e}, 'unixepoch')`;
783
+ return r`datetime(strftime('%Y-%m-%d %H:%M:%S', ${I}))`;
784
784
  default:
785
- return L`datetime(${e}, 'unixepoch')`;
785
+ return r`datetime(${e}, 'unixepoch')`;
786
786
  }
787
787
  }
788
788
  /**
@@ -792,23 +792,23 @@ class ue extends jE {
792
792
  buildStringCondition(E, e, R) {
793
793
  switch (e) {
794
794
  case "contains":
795
- return L`LOWER(${E}) LIKE ${`%${R.toLowerCase()}%`}`;
795
+ return r`LOWER(${E}) LIKE ${`%${R.toLowerCase()}%`}`;
796
796
  case "notContains":
797
- return L`LOWER(${E}) NOT LIKE ${`%${R.toLowerCase()}%`}`;
797
+ return r`LOWER(${E}) NOT LIKE ${`%${R.toLowerCase()}%`}`;
798
798
  case "startsWith":
799
- return L`LOWER(${E}) LIKE ${`${R.toLowerCase()}%`}`;
799
+ return r`LOWER(${E}) LIKE ${`${R.toLowerCase()}%`}`;
800
800
  case "endsWith":
801
- return L`LOWER(${E}) LIKE ${`%${R.toLowerCase()}`}`;
801
+ return r`LOWER(${E}) LIKE ${`%${R.toLowerCase()}`}`;
802
802
  case "like":
803
- return L`${E} LIKE ${R}`;
803
+ return r`${E} LIKE ${R}`;
804
804
  case "notLike":
805
- return L`${E} NOT LIKE ${R}`;
805
+ return r`${E} NOT LIKE ${R}`;
806
806
  case "ilike":
807
- return L`LOWER(${E}) LIKE ${R.toLowerCase()}`;
807
+ return r`LOWER(${E}) LIKE ${R.toLowerCase()}`;
808
808
  case "regex":
809
- return L`${E} GLOB ${R}`;
809
+ return r`${E} GLOB ${R}`;
810
810
  case "notRegex":
811
- return L`${E} NOT GLOB ${R}`;
811
+ return r`${E} NOT GLOB ${R}`;
812
812
  default:
813
813
  throw new Error(`Unsupported string operator: ${e}`);
814
814
  }
@@ -820,11 +820,11 @@ class ue extends jE {
820
820
  castToType(E, e) {
821
821
  switch (e) {
822
822
  case "timestamp":
823
- return L`datetime(${E} / 1000, 'unixepoch')`;
823
+ return r`datetime(${E} / 1000, 'unixepoch')`;
824
824
  case "decimal":
825
- return L`CAST(${E} AS REAL)`;
825
+ return r`CAST(${E} AS REAL)`;
826
826
  case "integer":
827
- return L`CAST(${E} AS INTEGER)`;
827
+ return r`CAST(${E} AS INTEGER)`;
828
828
  default:
829
829
  throw new Error(`Unsupported cast type: ${e}`);
830
830
  }
@@ -834,21 +834,21 @@ class ue extends jE {
834
834
  * SQLite AVG returns NULL for empty sets, using IFNULL for consistency
835
835
  */
836
836
  buildAvg(E) {
837
- return L`IFNULL(AVG(${E}), 0)`;
837
+ return r`IFNULL(AVG(${E}), 0)`;
838
838
  }
839
839
  /**
840
840
  * Build SQLite CASE WHEN conditional expression
841
841
  */
842
842
  buildCaseWhen(E, e) {
843
- const R = E.map((A) => A.then && typeof A.then == "object" && (A.then.queryChunks || A.then._ || A.then.sql) ? L`WHEN ${A.when} THEN ${L.raw("(")}${A.then}${L.raw(")")}` : L`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => L`${A} ${S}`);
844
- return e !== void 0 ? e && typeof e == "object" && (e.queryChunks || e._ || e.sql) ? L`CASE ${R} ELSE ${L.raw("(")}${e}${L.raw(")")} END` : L`CASE ${R} ELSE ${e} END` : L`CASE ${R} END`;
843
+ const R = E.map((A) => A.then && typeof A.then == "object" && (A.then.queryChunks || A.then._ || A.then.sql) ? r`WHEN ${A.when} THEN ${r.raw("(")}${A.then}${r.raw(")")}` : r`WHEN ${A.when} THEN ${A.then}`).reduce((A, S) => r`${A} ${S}`);
844
+ return e !== void 0 ? e && typeof e == "object" && (e.queryChunks || e._ || e.sql) ? r`CASE ${R} ELSE ${r.raw("(")}${e}${r.raw(")")} END` : r`CASE ${R} ELSE ${e} END` : r`CASE ${R} END`;
845
845
  }
846
846
  /**
847
847
  * Build SQLite boolean literal
848
848
  * SQLite uses 1/0 for true/false
849
849
  */
850
850
  buildBooleanLiteral(E) {
851
- return E ? L`1` : L`0`;
851
+ return E ? r`1` : r`0`;
852
852
  }
853
853
  /**
854
854
  * Preprocess calculated measure templates for SQLite-specific handling
@@ -1131,7 +1131,7 @@ function zT(T, E) {
1131
1131
  }
1132
1132
  }
1133
1133
  function Ye(T) {
1134
- return T && typeof T == "object" ? L`${L`${T}`}` : T;
1134
+ return T && typeof T == "object" ? r`${r`${T}`}` : T;
1135
1135
  }
1136
1136
  function w(T, E) {
1137
1137
  const e = typeof T == "function" ? T(E) : T;
@@ -1140,20 +1140,20 @@ function w(T, E) {
1140
1140
  function fe(T, E) {
1141
1141
  if (T.relationship !== "belongsToMany" || !T.through)
1142
1142
  throw new Error("expandBelongsToManyJoin can only be called on belongsToMany relationships with through configuration");
1143
- const { table: e, sourceKey: R, targetKey: A, securitySql: S } = T.through, N = [];
1144
- for (const I of R) {
1145
- const s = I.as || k;
1146
- N.push(s(I.source, I.target));
1143
+ const { table: e, sourceKey: R, targetKey: A, securitySql: S } = T.through, I = [];
1144
+ for (const N of R) {
1145
+ const C = N.as || k;
1146
+ I.push(C(N.source, N.target));
1147
1147
  }
1148
1148
  const t = [];
1149
- for (const I of A) {
1150
- const s = I.as || k;
1151
- t.push(s(I.source, I.target));
1149
+ for (const N of A) {
1150
+ const C = N.as || k;
1151
+ t.push(C(N.source, N.target));
1152
1152
  }
1153
- let C;
1153
+ let s;
1154
1154
  if (S) {
1155
- const I = S(E);
1156
- C = Array.isArray(I) ? I : [I];
1155
+ const N = S(E);
1156
+ s = Array.isArray(N) ? N : [N];
1157
1157
  }
1158
1158
  const O = zT("belongsToMany", T.sqlJoinType);
1159
1159
  return {
@@ -1161,7 +1161,7 @@ function fe(T, E) {
1161
1161
  {
1162
1162
  joinType: O,
1163
1163
  table: e,
1164
- condition: h(...N)
1164
+ condition: h(...I)
1165
1165
  },
1166
1166
  {
1167
1167
  joinType: O,
@@ -1170,7 +1170,7 @@ function fe(T, E) {
1170
1170
  condition: h(...t)
1171
1171
  }
1172
1172
  ],
1173
- junctionSecurityConditions: C
1173
+ junctionSecurityConditions: s
1174
1174
  };
1175
1175
  }
1176
1176
  class J {
@@ -1189,19 +1189,19 @@ class J {
1189
1189
  extractDependencies(E) {
1190
1190
  const e = /\{([^}]+)\}/g, R = E.matchAll(e), A = [];
1191
1191
  for (const S of R) {
1192
- const N = S[1].trim();
1193
- if (N.includes(".")) {
1194
- const [t, C] = N.split(".");
1192
+ const I = S[1].trim();
1193
+ if (I.includes(".")) {
1194
+ const [t, s] = I.split(".");
1195
1195
  A.push({
1196
- measureName: N,
1196
+ measureName: I,
1197
1197
  cubeName: t.trim(),
1198
- fieldName: C.trim()
1198
+ fieldName: s.trim()
1199
1199
  });
1200
1200
  } else
1201
1201
  A.push({
1202
- measureName: N,
1202
+ measureName: I,
1203
1203
  cubeName: null,
1204
- fieldName: N
1204
+ fieldName: I
1205
1205
  });
1206
1206
  }
1207
1207
  return A;
@@ -1214,14 +1214,14 @@ class J {
1214
1214
  buildGraph(E) {
1215
1215
  for (const [e, R] of Object.entries(E.measures))
1216
1216
  if (R.type === "calculated" && R.calculatedSql) {
1217
- const A = `${E.name}.${e}`, S = this.extractDependencies(R.calculatedSql), N = /* @__PURE__ */ new Set();
1217
+ const A = `${E.name}.${e}`, S = this.extractDependencies(R.calculatedSql), I = /* @__PURE__ */ new Set();
1218
1218
  for (const t of S) {
1219
1219
  const O = `${t.cubeName || E.name}.${t.fieldName}`;
1220
- N.add(O);
1220
+ I.add(O);
1221
1221
  }
1222
1222
  this.dependencyGraph.set(A, {
1223
1223
  id: A,
1224
- dependencies: N,
1224
+ dependencies: I,
1225
1225
  inDegree: 0
1226
1226
  });
1227
1227
  }
@@ -1259,27 +1259,27 @@ class J {
1259
1259
  topologicalSort(E) {
1260
1260
  const e = /* @__PURE__ */ new Map(), R = [], A = [];
1261
1261
  for (const S of E) {
1262
- const N = this.dependencyGraph.get(S);
1263
- N && e.set(S, {
1264
- id: N.id,
1265
- dependencies: new Set(N.dependencies),
1262
+ const I = this.dependencyGraph.get(S);
1263
+ I && e.set(S, {
1264
+ id: I.id,
1265
+ dependencies: new Set(I.dependencies),
1266
1266
  inDegree: 0
1267
1267
  // Will recalculate below
1268
1268
  });
1269
1269
  }
1270
1270
  for (const S of e.values()) {
1271
- let N = 0;
1271
+ let I = 0;
1272
1272
  for (const t of S.dependencies)
1273
- e.has(t) && N++;
1274
- S.inDegree = N;
1273
+ e.has(t) && I++;
1274
+ S.inDegree = I;
1275
1275
  }
1276
- for (const [S, N] of e)
1277
- N.inDegree === 0 && R.push(S);
1276
+ for (const [S, I] of e)
1277
+ I.inDegree === 0 && R.push(S);
1278
1278
  for (; R.length > 0; ) {
1279
1279
  const S = R.shift();
1280
1280
  A.push(S);
1281
- for (const [N, t] of e)
1282
- t.dependencies.has(S) && (t.inDegree--, t.inDegree === 0 && R.push(N));
1281
+ for (const [I, t] of e)
1282
+ t.dependencies.has(S) && (t.inDegree--, t.inDegree === 0 && R.push(I));
1283
1283
  }
1284
1284
  if (A.length < e.size) {
1285
1285
  const S = this.detectCycle();
@@ -1313,14 +1313,14 @@ class J {
1313
1313
  const S = this.dependencyGraph.get(E);
1314
1314
  if (!S)
1315
1315
  return A.pop(), R.delete(E), null;
1316
- for (const N of S.dependencies)
1317
- if (e.has(N)) {
1318
- if (R.has(N)) {
1319
- const t = A.indexOf(N);
1320
- return [...A.slice(t), N];
1316
+ for (const I of S.dependencies)
1317
+ if (e.has(I)) {
1318
+ if (R.has(I)) {
1319
+ const t = A.indexOf(I);
1320
+ return [...A.slice(t), I];
1321
1321
  }
1322
1322
  } else {
1323
- const t = this.dfs(N, e, R, A);
1323
+ const t = this.dfs(I, e, R, A);
1324
1324
  if (t)
1325
1325
  return t;
1326
1326
  }
@@ -1336,9 +1336,9 @@ class J {
1336
1336
  const e = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Set(), A = (S) => {
1337
1337
  if (R.has(S)) return;
1338
1338
  R.add(S);
1339
- const N = this.dependencyGraph.get(S);
1340
- if (N)
1341
- for (const t of N.dependencies)
1339
+ const I = this.dependencyGraph.get(S);
1340
+ if (I)
1341
+ for (const t of I.dependencies)
1342
1342
  e.add(t), A(t);
1343
1343
  };
1344
1344
  return A(E), e;
@@ -1354,16 +1354,16 @@ class J {
1354
1354
  if (R.type === "calculated" && R.calculatedSql) {
1355
1355
  const A = this.extractDependencies(R.calculatedSql);
1356
1356
  for (const S of A) {
1357
- const N = S.cubeName || E.name, t = this.cubes.get(N);
1357
+ const I = S.cubeName || E.name, t = this.cubes.get(I);
1358
1358
  if (!t)
1359
1359
  throw new Error(
1360
- `Calculated measure '${E.name}.${e}' references unknown cube '${N}'`
1360
+ `Calculated measure '${E.name}.${e}' references unknown cube '${I}'`
1361
1361
  );
1362
1362
  if (!t.measures[S.fieldName])
1363
1363
  throw new Error(
1364
1364
  `Calculated measure '${E.name}.${e}' references unknown measure '${S.measureName}'`
1365
1365
  );
1366
- if (N === E.name && S.fieldName === e)
1366
+ if (I === E.name && S.fieldName === e)
1367
1367
  throw new Error(
1368
1368
  `Calculated measure '${E.name}.${e}' cannot reference itself`
1369
1369
  );
@@ -1394,47 +1394,47 @@ class J {
1394
1394
  }
1395
1395
  }
1396
1396
  function he(T, E) {
1397
- const { cube: e, allCubes: R, resolvedMeasures: A } = E, S = zE(T), N = /* @__PURE__ */ new Map();
1398
- for (const s of S) {
1399
- const { originalRef: r, cubeName: _, fieldName: D } = s, o = _ || e.name;
1397
+ const { cube: e, allCubes: R, resolvedMeasures: A } = E, S = zE(T), I = /* @__PURE__ */ new Map();
1398
+ for (const C of S) {
1399
+ const { originalRef: L, cubeName: n, fieldName: i } = C, o = n || e.name;
1400
1400
  if (!R.get(o))
1401
1401
  throw new Error(
1402
- `Cannot substitute {${r}}: cube '${o}' not found`
1402
+ `Cannot substitute {${L}}: cube '${o}' not found`
1403
1403
  );
1404
- const P = `${o}.${D}`, l = A.get(P);
1404
+ const P = `${o}.${i}`, l = A.get(P);
1405
1405
  if (!l)
1406
1406
  throw new Error(
1407
- `Cannot substitute {${r}}: measure '${P}' not resolved yet. Ensure measures are resolved in dependency order.`
1407
+ `Cannot substitute {${L}}: measure '${P}' not resolved yet. Ensure measures are resolved in dependency order.`
1408
1408
  );
1409
- const M = l(), G = L`${M}`;
1410
- N.set(r, G);
1409
+ const M = l(), G = r`${M}`;
1410
+ I.set(L, G);
1411
1411
  }
1412
- const t = [], C = [];
1412
+ const t = [], s = [];
1413
1413
  let O = 0;
1414
- for (const s of S) {
1415
- const r = `{${s.originalRef}}`, _ = T.indexOf(r, O);
1416
- if (_ >= 0) {
1417
- t.push(T.substring(O, _));
1418
- const D = N.get(s.originalRef);
1419
- D && C.push(D), O = _ + r.length;
1414
+ for (const C of S) {
1415
+ const L = `{${C.originalRef}}`, n = T.indexOf(L, O);
1416
+ if (n >= 0) {
1417
+ t.push(T.substring(O, n));
1418
+ const i = I.get(C.originalRef);
1419
+ i && s.push(i), O = n + L.length;
1420
1420
  }
1421
1421
  }
1422
- if (t.push(T.substring(O)), C.length === 0)
1423
- return L.raw(T);
1424
- const I = [];
1425
- for (let s = 0; s < t.length; s++)
1426
- t[s] && I.push(new f(t[s])), s < C.length && I.push(C[s]);
1427
- return L.join(I, L.raw(""));
1422
+ if (t.push(T.substring(O)), s.length === 0)
1423
+ return r.raw(T);
1424
+ const N = [];
1425
+ for (let C = 0; C < t.length; C++)
1426
+ t[C] && N.push(new f(t[C])), C < s.length && N.push(s[C]);
1427
+ return r.join(N, r.raw(""));
1428
1428
  }
1429
1429
  function zE(T) {
1430
1430
  const E = /\{([^}]+)\}/g, e = T.matchAll(E), R = [];
1431
1431
  for (const A of e) {
1432
1432
  const S = A[1].trim();
1433
1433
  if (S.includes(".")) {
1434
- const [N, t] = S.split(".").map((C) => C.trim());
1434
+ const [I, t] = S.split(".").map((s) => s.trim());
1435
1435
  R.push({
1436
1436
  originalRef: S,
1437
- cubeName: N,
1437
+ cubeName: I,
1438
1438
  fieldName: t
1439
1439
  });
1440
1440
  } else
@@ -1449,21 +1449,21 @@ function zE(T) {
1449
1449
  function Ve(T) {
1450
1450
  const E = [];
1451
1451
  let e = 0;
1452
- for (let N = 0; N < T.length; N++)
1453
- if (T[N] === "{")
1452
+ for (let I = 0; I < T.length; I++)
1453
+ if (T[I] === "{")
1454
1454
  e++;
1455
- else if (T[N] === "}" && (e--, e < 0)) {
1456
- E.push(`Unmatched closing brace at position ${N}`);
1455
+ else if (T[I] === "}" && (e--, e < 0)) {
1456
+ E.push(`Unmatched closing brace at position ${I}`);
1457
1457
  break;
1458
1458
  }
1459
1459
  e > 0 && E.push("Unmatched opening brace in template"), /\{\s*\}/.test(T) && E.push("Empty member reference {} found in template"), /\{[^}]*\{/.test(T) && E.push("Nested braces are not allowed in member references");
1460
1460
  const S = zE(T);
1461
- for (const N of S) {
1462
- const t = N.cubeName ? `${N.cubeName}.${N.fieldName}` : N.fieldName;
1461
+ for (const I of S) {
1462
+ const t = I.cubeName ? `${I.cubeName}.${I.fieldName}` : I.fieldName;
1463
1463
  /^[a-zA-Z_][a-zA-Z0-9_.]*$/.test(t) || E.push(
1464
- `Invalid member reference {${N.originalRef}}: must start with letter or underscore, and contain only letters, numbers, underscores, and dots`
1464
+ `Invalid member reference {${I.originalRef}}: must start with letter or underscore, and contain only letters, numbers, underscores, and dots`
1465
1465
  ), t.split(".").length > 2 && E.push(
1466
- `Invalid member reference {${N.originalRef}}: only one dot allowed (Cube.measure format)`
1466
+ `Invalid member reference {${I.originalRef}}: only one dot allowed (Cube.measure format)`
1467
1467
  );
1468
1468
  }
1469
1469
  return {
@@ -1474,8 +1474,8 @@ function Ve(T) {
1474
1474
  function uE(T, E) {
1475
1475
  const e = zE(T), R = /* @__PURE__ */ new Set();
1476
1476
  for (const A of e) {
1477
- const N = `${A.cubeName || E}.${A.fieldName}`;
1478
- R.add(N);
1477
+ const I = `${A.cubeName || E}.${A.fieldName}`;
1478
+ R.add(I);
1479
1479
  }
1480
1480
  return Array.from(R);
1481
1481
  }
@@ -1495,44 +1495,44 @@ class We {
1495
1495
  * @returns Map of measure names to SQL builder functions
1496
1496
  */
1497
1497
  buildResolvedMeasures(E, e, R, A) {
1498
- const S = /* @__PURE__ */ new Map(), N = [], t = [], C = new Set(E), O = new J(e);
1499
- for (const I of e.values())
1500
- O.buildGraph(I);
1501
- for (const I of E) {
1502
- const [s, r] = I.split("."), _ = e.get(s);
1503
- if (_ && _.measures && _.measures[r]) {
1504
- const D = _.measures[r];
1505
- J.isCalculatedMeasure(D) ? (t.push(I), uE(D.calculatedSql, s).forEach((P) => C.add(P)), O.getAllDependencies(I).forEach((P) => {
1498
+ const S = /* @__PURE__ */ new Map(), I = [], t = [], s = new Set(E), O = new J(e);
1499
+ for (const N of e.values())
1500
+ O.buildGraph(N);
1501
+ for (const N of E) {
1502
+ const [C, L] = N.split("."), n = e.get(C);
1503
+ if (n && n.measures && n.measures[L]) {
1504
+ const i = n.measures[L];
1505
+ J.isCalculatedMeasure(i) ? (t.push(N), uE(i.calculatedSql, C).forEach((P) => s.add(P)), O.getAllDependencies(N).forEach((P) => {
1506
1506
  const [l, M] = P.split("."), G = e.get(l);
1507
1507
  if (G && G.measures[M]) {
1508
1508
  const m = G.measures[M];
1509
- J.isCalculatedMeasure(m) && uE(m.calculatedSql, l).forEach((b) => C.add(b));
1509
+ J.isCalculatedMeasure(m) && uE(m.calculatedSql, l).forEach((b) => s.add(b));
1510
1510
  }
1511
- })) : N.push(I);
1511
+ })) : I.push(N);
1512
1512
  }
1513
1513
  }
1514
- for (const I of C) {
1515
- const [s, r] = I.split("."), _ = e.get(s);
1516
- if (_ && _.measures && _.measures[r]) {
1517
- const D = _.measures[r];
1518
- J.isCalculatedMeasure(D) ? t.includes(I) || t.push(I) : N.includes(I) || N.push(I);
1514
+ for (const N of s) {
1515
+ const [C, L] = N.split("."), n = e.get(C);
1516
+ if (n && n.measures && n.measures[L]) {
1517
+ const i = n.measures[L];
1518
+ J.isCalculatedMeasure(i) ? t.includes(N) || t.push(N) : I.includes(N) || I.push(N);
1519
1519
  }
1520
1520
  }
1521
- for (const I of N) {
1522
- const [s, r] = I.split("."), _ = e.get(s), D = _.measures[r];
1521
+ for (const N of I) {
1522
+ const [C, L] = N.split("."), n = e.get(C), i = n.measures[L];
1523
1523
  if (A) {
1524
- const o = A(I, D, _);
1525
- S.set(I, () => o);
1524
+ const o = A(N, i, n);
1525
+ S.set(N, () => o);
1526
1526
  } else
1527
- S.set(I, () => this.buildMeasureExpression(D, R));
1527
+ S.set(N, () => this.buildMeasureExpression(i, R));
1528
1528
  }
1529
1529
  if (t.length > 0) {
1530
- const I = O.topologicalSort(t);
1531
- for (const s of I) {
1532
- const [r, _] = s.split("."), D = e.get(r), o = D.measures[_];
1533
- S.set(s, () => this.buildCalculatedMeasure(
1530
+ const N = O.topologicalSort(t);
1531
+ for (const C of N) {
1532
+ const [L, n] = C.split("."), i = e.get(L), o = i.measures[n];
1533
+ S.set(C, () => this.buildCalculatedMeasure(
1534
1534
  o,
1535
- D,
1535
+ i,
1536
1536
  e,
1537
1537
  S,
1538
1538
  R
@@ -1549,37 +1549,37 @@ class We {
1549
1549
  buildSelections(E, e, R) {
1550
1550
  const A = {}, S = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1551
1551
  if (e.dimensions)
1552
- for (const N of e.dimensions) {
1553
- const [t, C] = N.split("."), O = S.get(t);
1554
- if (O && O.dimensions && O.dimensions[C]) {
1555
- const I = O.dimensions[C], s = w(I.sql, R);
1556
- A[N] = L`${s}`.as(N);
1552
+ for (const I of e.dimensions) {
1553
+ const [t, s] = I.split("."), O = S.get(t);
1554
+ if (O && O.dimensions && O.dimensions[s]) {
1555
+ const N = O.dimensions[s], C = w(N.sql, R);
1556
+ A[I] = r`${C}`.as(I);
1557
1557
  }
1558
1558
  }
1559
1559
  if (e.measures) {
1560
- const N = this.buildResolvedMeasures(
1560
+ const I = this.buildResolvedMeasures(
1561
1561
  e.measures,
1562
1562
  S,
1563
1563
  R
1564
1564
  );
1565
1565
  for (const t of e.measures) {
1566
- const C = N.get(t);
1567
- if (C) {
1568
- const O = C();
1569
- A[t] = L`${O}`.as(t);
1566
+ const s = I.get(t);
1567
+ if (s) {
1568
+ const O = s();
1569
+ A[t] = r`${O}`.as(t);
1570
1570
  }
1571
1571
  }
1572
1572
  }
1573
1573
  if (e.timeDimensions)
1574
- for (const N of e.timeDimensions) {
1575
- const [t, C] = N.dimension.split("."), O = S.get(t);
1576
- if (O && O.dimensions && O.dimensions[C]) {
1577
- const I = O.dimensions[C], s = this.buildTimeDimensionExpression(
1578
- I.sql,
1579
- N.granularity,
1574
+ for (const I of e.timeDimensions) {
1575
+ const [t, s] = I.dimension.split("."), O = S.get(t);
1576
+ if (O && O.dimensions && O.dimensions[s]) {
1577
+ const N = O.dimensions[s], C = this.buildTimeDimensionExpression(
1578
+ N.sql,
1579
+ I.granularity,
1580
1580
  R
1581
1581
  );
1582
- A[N.dimension] = L`${s}`.as(N.dimension);
1582
+ A[I.dimension] = r`${C}`.as(I.dimension);
1583
1583
  }
1584
1584
  }
1585
1585
  return Object.keys(A).length === 0 && (A.count = cE()), A;
@@ -1593,8 +1593,8 @@ class We {
1593
1593
  throw new Error(
1594
1594
  `Calculated measure '${e.name}.${E.name}' missing calculatedSql property`
1595
1595
  );
1596
- const N = this.databaseAdapter.preprocessCalculatedTemplate(E.calculatedSql);
1597
- return he(N, {
1596
+ const I = this.databaseAdapter.preprocessCalculatedTemplate(E.calculatedSql);
1597
+ return he(I, {
1598
1598
  cube: e,
1599
1599
  allCubes: R,
1600
1600
  resolvedMeasures: A
@@ -1619,36 +1619,36 @@ class We {
1619
1619
  throw new Error(
1620
1620
  `Calculated measure '${e.name}.${E.name || "unknown"}' missing calculatedSql property`
1621
1621
  );
1622
- const N = /* @__PURE__ */ new Map(), t = uE(E.calculatedSql, e.name);
1623
- for (const C of t) {
1624
- const [O, I] = C.split("."), s = A.get(O);
1625
- if (s && s.measures[I]) {
1626
- const r = s.measures[I];
1627
- if (R.measures.includes(C)) {
1628
- const _ = L`${L.identifier(R.cteAlias)}.${L.identifier(I)}`;
1629
- let D;
1630
- switch (r.type) {
1622
+ const I = /* @__PURE__ */ new Map(), t = uE(E.calculatedSql, e.name);
1623
+ for (const s of t) {
1624
+ const [O, N] = s.split("."), C = A.get(O);
1625
+ if (C && C.measures[N]) {
1626
+ const L = C.measures[N];
1627
+ if (R.measures.includes(s)) {
1628
+ const n = r`${r.identifier(R.cteAlias)}.${r.identifier(N)}`;
1629
+ let i;
1630
+ switch (L.type) {
1631
1631
  case "count":
1632
1632
  case "countDistinct":
1633
1633
  case "sum":
1634
- D = y(_);
1634
+ i = y(n);
1635
1635
  break;
1636
1636
  case "avg":
1637
- D = this.databaseAdapter.buildAvg(_);
1637
+ i = this.databaseAdapter.buildAvg(n);
1638
1638
  break;
1639
1639
  case "min":
1640
- D = SE(_);
1640
+ i = SE(n);
1641
1641
  break;
1642
1642
  case "max":
1643
- D = AE(_);
1643
+ i = AE(n);
1644
1644
  break;
1645
1645
  case "number":
1646
- D = y(_);
1646
+ i = y(n);
1647
1647
  break;
1648
1648
  default:
1649
- D = y(_);
1649
+ i = y(n);
1650
1650
  }
1651
- N.set(C, () => D);
1651
+ I.set(s, () => i);
1652
1652
  }
1653
1653
  }
1654
1654
  }
@@ -1656,7 +1656,7 @@ class We {
1656
1656
  E,
1657
1657
  e,
1658
1658
  A,
1659
- N,
1659
+ I,
1660
1660
  S
1661
1661
  );
1662
1662
  }
@@ -1665,25 +1665,25 @@ class We {
1665
1665
  */
1666
1666
  buildHavingMeasureExpression(E, e, R, A, S) {
1667
1667
  if (S && S.preAggregationCTEs) {
1668
- const N = S.preAggregationCTEs.find((t) => t.cube.name === E);
1669
- if (N && N.measures.includes(`${E}.${e}`))
1668
+ const I = S.preAggregationCTEs.find((t) => t.cube.name === E);
1669
+ if (I && I.measures.includes(`${E}.${e}`))
1670
1670
  if (R.type === "calculated" && R.calculatedSql) {
1671
1671
  const t = S.primaryCube.name === E ? S.primaryCube : S.joinCubes?.find((O) => O.cube.name === E)?.cube;
1672
1672
  if (!t)
1673
1673
  throw new Error(`Cube ${E} not found in query plan`);
1674
- const C = /* @__PURE__ */ new Map([[S.primaryCube.name, S.primaryCube]]);
1674
+ const s = /* @__PURE__ */ new Map([[S.primaryCube.name, S.primaryCube]]);
1675
1675
  if (S.joinCubes)
1676
1676
  for (const O of S.joinCubes)
1677
- C.set(O.cube.name, O.cube);
1677
+ s.set(O.cube.name, O.cube);
1678
1678
  return this.buildCTECalculatedMeasure(
1679
1679
  R,
1680
1680
  t,
1681
- N,
1682
- C,
1681
+ I,
1682
+ s,
1683
1683
  A
1684
1684
  );
1685
1685
  } else {
1686
- const t = L`${L.identifier(N.cteAlias)}.${L.identifier(e)}`;
1686
+ const t = r`${r.identifier(I.cteAlias)}.${r.identifier(e)}`;
1687
1687
  switch (R.type) {
1688
1688
  case "count":
1689
1689
  case "countDistinct":
@@ -1720,8 +1720,8 @@ class We {
1720
1720
  let R = w(E.sql, e);
1721
1721
  if (E.filters && E.filters.length > 0) {
1722
1722
  const A = E.filters.map((S) => {
1723
- const N = S(e);
1724
- return N ? L`(${N})` : void 0;
1723
+ const I = S(e);
1724
+ return I ? r`(${I})` : void 0;
1725
1725
  }).filter(Boolean);
1726
1726
  if (A.length > 0) {
1727
1727
  const S = A.length === 1 ? A[0] : h(...A);
@@ -1754,27 +1754,27 @@ class We {
1754
1754
  */
1755
1755
  buildTimeDimensionExpression(E, e, R) {
1756
1756
  const A = w(E, R);
1757
- return e ? this.databaseAdapter.buildTimeDimension(e, A) : A instanceof H ? A : L`${A}`;
1757
+ return e ? this.databaseAdapter.buildTimeDimension(e, A) : A instanceof H ? A : r`${A}`;
1758
1758
  }
1759
1759
  /**
1760
1760
  * Build WHERE conditions from semantic query filters (dimensions only)
1761
1761
  * Works for both single and multi-cube queries
1762
1762
  */
1763
1763
  buildWhereConditions(E, e, R, A) {
1764
- const S = [], N = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1764
+ const S = [], I = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1765
1765
  if (e.filters && e.filters.length > 0)
1766
1766
  for (const t of e.filters) {
1767
- const C = this.processFilter(t, N, R, "where", A);
1768
- C && S.push(C);
1767
+ const s = this.processFilter(t, I, R, "where", A);
1768
+ s && S.push(s);
1769
1769
  }
1770
1770
  if (e.timeDimensions)
1771
1771
  for (const t of e.timeDimensions) {
1772
- const [C, O] = t.dimension.split("."), I = N.get(C);
1773
- if (I && I.dimensions[O] && t.dateRange) {
1774
- if (A?.preAggregationCTEs && A.preAggregationCTEs.some((o) => o.cube.name === C))
1772
+ const [s, O] = t.dimension.split("."), N = I.get(s);
1773
+ if (N && N.dimensions[O] && t.dateRange) {
1774
+ if (A?.preAggregationCTEs && A.preAggregationCTEs.some((o) => o.cube.name === s))
1775
1775
  continue;
1776
- const s = I.dimensions[O], r = w(s.sql, R), _ = this.buildDateRangeCondition(r, t.dateRange);
1777
- _ && S.push(_);
1776
+ const C = N.dimensions[O], L = w(C.sql, R), n = this.buildDateRangeCondition(L, t.dateRange);
1777
+ n && S.push(n);
1778
1778
  }
1779
1779
  }
1780
1780
  return S;
@@ -1784,11 +1784,11 @@ class We {
1784
1784
  * Works for both single and multi-cube queries
1785
1785
  */
1786
1786
  buildHavingConditions(E, e, R, A) {
1787
- const S = [], N = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1787
+ const S = [], I = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
1788
1788
  if (e.filters && e.filters.length > 0)
1789
1789
  for (const t of e.filters) {
1790
- const C = this.processFilter(t, N, R, "having", A);
1791
- C && S.push(C);
1790
+ const s = this.processFilter(t, I, R, "having", A);
1791
+ s && S.push(s);
1792
1792
  }
1793
1793
  return S;
1794
1794
  }
@@ -1798,31 +1798,43 @@ class We {
1798
1798
  */
1799
1799
  processFilter(E, e, R, A, S) {
1800
1800
  if ("and" in E || "or" in E) {
1801
- const _ = E;
1802
- if (_.and) {
1803
- const D = _.and.map((o) => this.processFilter(o, e, R, A, S)).filter((o) => o !== null);
1804
- return D.length > 0 ? h(...D) : null;
1801
+ const n = E;
1802
+ if (n.and) {
1803
+ const i = n.and.map((o) => this.processFilter(o, e, R, A, S)).filter((o) => o !== null);
1804
+ return i.length > 0 ? h(...i) : null;
1805
1805
  }
1806
- if (_.or) {
1807
- const D = _.or.map((o) => this.processFilter(o, e, R, A, S)).filter((o) => o !== null);
1808
- return D.length > 0 ? PE(...D) : null;
1806
+ if (n.or) {
1807
+ const i = n.or.map((o) => this.processFilter(o, e, R, A, S)).filter((o) => o !== null);
1808
+ return i.length > 0 ? PE(...i) : null;
1809
1809
  }
1810
1810
  }
1811
- const N = E, [t, C] = N.member.split("."), O = e.get(t);
1811
+ const I = E, [t, s] = I.member.split("."), O = e.get(t);
1812
1812
  if (!O) return null;
1813
- const I = O.dimensions[C], s = O.measures[C], r = I || s;
1814
- if (!r) return null;
1815
- if (A === "where" && I) {
1813
+ const N = O.dimensions[s], C = O.measures[s], L = N || C;
1814
+ if (!L) return null;
1815
+ if (A === "where" && N) {
1816
1816
  if (S?.preAggregationCTEs && S.preAggregationCTEs.some((o) => o.cube.name === t))
1817
1817
  return null;
1818
- const _ = w(I.sql, R);
1819
- return this.buildFilterCondition(_, N.operator, N.values, r);
1818
+ const n = w(N.sql, R);
1819
+ return this.buildFilterCondition(
1820
+ n,
1821
+ I.operator,
1822
+ I.values,
1823
+ L,
1824
+ I.dateRange
1825
+ );
1820
1826
  } else {
1821
- if (A === "where" && s)
1827
+ if (A === "where" && C)
1822
1828
  return null;
1823
- if (A === "having" && s) {
1824
- const _ = this.buildHavingMeasureExpression(t, C, s, R, S);
1825
- return this.buildFilterCondition(_, N.operator, N.values, r);
1829
+ if (A === "having" && C) {
1830
+ const n = this.buildHavingMeasureExpression(t, s, C, R, S);
1831
+ return this.buildFilterCondition(
1832
+ n,
1833
+ I.operator,
1834
+ I.values,
1835
+ L,
1836
+ I.dateRange
1837
+ );
1826
1838
  }
1827
1839
  }
1828
1840
  return null;
@@ -1830,97 +1842,108 @@ class We {
1830
1842
  /**
1831
1843
  * Build filter condition using Drizzle operators
1832
1844
  */
1833
- buildFilterCondition(E, e, R, A) {
1845
+ buildFilterCondition(E, e, R, A, S) {
1846
+ if (S !== void 0) {
1847
+ if (e !== "inDateRange")
1848
+ throw new Error(
1849
+ `dateRange can only be used with 'inDateRange' operator, but got '${e}'. Use explicit date values in the 'values' array for other date operators.`
1850
+ );
1851
+ if (A && A.type !== "time")
1852
+ throw new Error(
1853
+ `dateRange can only be used on time dimensions, but field '${A.name || "unknown"}' has type '${A.type}'`
1854
+ );
1855
+ return this.buildDateRangeCondition(E, S);
1856
+ }
1834
1857
  if (!R || R.length === 0)
1835
1858
  return e === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1836
- const S = R.filter((t) => !(t == null || t === "" || typeof t == "string" && t.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1837
- if (S.length === 0 && !["set", "notSet"].includes(e))
1859
+ const I = R.filter((s) => !(s == null || s === "" || typeof s == "string" && s.includes("\0"))).map(this.databaseAdapter.convertFilterValue);
1860
+ if (I.length === 0 && !["set", "notSet"].includes(e))
1838
1861
  return e === "equals" ? this.databaseAdapter.buildBooleanLiteral(!1) : null;
1839
- const N = S[0];
1862
+ const t = I[0];
1840
1863
  switch (e) {
1841
1864
  case "equals":
1842
- if (S.length > 1) {
1865
+ if (I.length > 1) {
1843
1866
  if (A?.type === "time") {
1844
- const t = S.map((C) => this.normalizeDate(C) || C);
1845
- return lE(E, t);
1867
+ const s = I.map((O) => this.normalizeDate(O) || O);
1868
+ return lE(E, s);
1846
1869
  }
1847
- return lE(E, S);
1848
- } else if (S.length === 1) {
1849
- const t = A?.type === "time" && this.normalizeDate(N) || N;
1850
- return k(E, t);
1870
+ return lE(E, I);
1871
+ } else if (I.length === 1) {
1872
+ const s = A?.type === "time" && this.normalizeDate(t) || t;
1873
+ return k(E, s);
1851
1874
  }
1852
1875
  return this.databaseAdapter.buildBooleanLiteral(!1);
1853
1876
  case "notEquals":
1854
- return S.length > 1 ? IT(E, S) : S.length === 1 ? ST(E, N) : null;
1877
+ return I.length > 1 ? IT(E, I) : I.length === 1 ? ST(E, t) : null;
1855
1878
  case "contains":
1856
- return this.databaseAdapter.buildStringCondition(E, "contains", N);
1879
+ return this.databaseAdapter.buildStringCondition(E, "contains", t);
1857
1880
  case "notContains":
1858
- return this.databaseAdapter.buildStringCondition(E, "notContains", N);
1881
+ return this.databaseAdapter.buildStringCondition(E, "notContains", t);
1859
1882
  case "startsWith":
1860
- return this.databaseAdapter.buildStringCondition(E, "startsWith", N);
1883
+ return this.databaseAdapter.buildStringCondition(E, "startsWith", t);
1861
1884
  case "endsWith":
1862
- return this.databaseAdapter.buildStringCondition(E, "endsWith", N);
1885
+ return this.databaseAdapter.buildStringCondition(E, "endsWith", t);
1863
1886
  case "gt":
1864
- return ME(E, N);
1887
+ return ME(E, t);
1865
1888
  case "gte":
1866
- return Q(E, N);
1889
+ return Q(E, t);
1867
1890
  case "lt":
1868
- return UE(E, N);
1891
+ return UE(E, t);
1869
1892
  case "lte":
1870
- return Z(E, N);
1893
+ return Z(E, t);
1871
1894
  case "set":
1872
1895
  return OT(E);
1873
1896
  case "notSet":
1874
1897
  return NT(E);
1875
1898
  case "inDateRange":
1876
- if (S.length >= 2) {
1877
- const t = this.normalizeDate(S[0]);
1878
- let C = this.normalizeDate(S[1]);
1879
- if (t && C) {
1880
- const O = R[1];
1881
- if (typeof O == "string" && /^\d{4}-\d{2}-\d{2}$/.test(O.trim())) {
1882
- const I = typeof C == "number" ? new Date(C * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(C), s = new Date(I);
1883
- s.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? C = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(s.getTime() / 1e3) : s.getTime() : C = s.toISOString();
1899
+ if (I.length >= 2) {
1900
+ const s = this.normalizeDate(I[0]);
1901
+ let O = this.normalizeDate(I[1]);
1902
+ if (s && O) {
1903
+ const N = R[1];
1904
+ if (typeof N == "string" && /^\d{4}-\d{2}-\d{2}$/.test(N.trim())) {
1905
+ const C = typeof O == "number" ? new Date(O * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(O), L = new Date(C);
1906
+ L.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? O = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(L.getTime() / 1e3) : L.getTime() : O = L.toISOString();
1884
1907
  }
1885
1908
  return h(
1886
- Q(E, t),
1887
- Z(E, C)
1909
+ Q(E, s),
1910
+ Z(E, O)
1888
1911
  );
1889
1912
  }
1890
1913
  }
1891
1914
  return null;
1892
1915
  case "beforeDate": {
1893
- const t = this.normalizeDate(N);
1894
- return t ? UE(E, t) : null;
1916
+ const s = this.normalizeDate(t);
1917
+ return s ? UE(E, s) : null;
1895
1918
  }
1896
1919
  case "afterDate": {
1897
- const t = this.normalizeDate(N);
1898
- return t ? ME(E, t) : null;
1920
+ const s = this.normalizeDate(t);
1921
+ return s ? ME(E, s) : null;
1899
1922
  }
1900
1923
  case "between":
1901
- return S.length >= 2 ? h(
1902
- Q(E, S[0]),
1903
- Z(E, S[1])
1924
+ return I.length >= 2 ? h(
1925
+ Q(E, I[0]),
1926
+ Z(E, I[1])
1904
1927
  ) : null;
1905
1928
  case "notBetween":
1906
- return S.length >= 2 ? PE(
1907
- UE(E, S[0]),
1908
- ME(E, S[1])
1929
+ return I.length >= 2 ? PE(
1930
+ UE(E, I[0]),
1931
+ ME(E, I[1])
1909
1932
  ) : null;
1910
1933
  case "in":
1911
- return S.length > 0 ? lE(E, S) : null;
1934
+ return I.length > 0 ? lE(E, I) : null;
1912
1935
  case "notIn":
1913
- return S.length > 0 ? IT(E, S) : null;
1936
+ return I.length > 0 ? IT(E, I) : null;
1914
1937
  case "like":
1915
- return this.databaseAdapter.buildStringCondition(E, "like", N);
1938
+ return this.databaseAdapter.buildStringCondition(E, "like", t);
1916
1939
  case "notLike":
1917
- return this.databaseAdapter.buildStringCondition(E, "notLike", N);
1940
+ return this.databaseAdapter.buildStringCondition(E, "notLike", t);
1918
1941
  case "ilike":
1919
- return this.databaseAdapter.buildStringCondition(E, "ilike", N);
1942
+ return this.databaseAdapter.buildStringCondition(E, "ilike", t);
1920
1943
  case "regex":
1921
- return this.databaseAdapter.buildStringCondition(E, "regex", N);
1944
+ return this.databaseAdapter.buildStringCondition(E, "regex", t);
1922
1945
  case "notRegex":
1923
- return this.databaseAdapter.buildStringCondition(E, "notRegex", N);
1946
+ return this.databaseAdapter.buildStringCondition(E, "notRegex", t);
1924
1947
  case "isEmpty":
1925
1948
  return PE(
1926
1949
  NT(E),
@@ -1945,8 +1968,8 @@ class We {
1945
1968
  let A = this.normalizeDate(e[1]);
1946
1969
  if (!R || !A) return null;
1947
1970
  if (typeof e[1] == "string" && /^\d{4}-\d{2}-\d{2}$/.test(e[1].trim())) {
1948
- const S = typeof A == "number" ? new Date(A * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(A), N = new Date(S);
1949
- N.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? A = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(N.getTime() / 1e3) : N.getTime() : A = N.toISOString();
1971
+ const S = typeof A == "number" ? new Date(A * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(A), I = new Date(S);
1972
+ I.setUTCHours(23, 59, 59, 999), this.databaseAdapter.isTimestampInteger() ? A = this.databaseAdapter.getEngineType() === "sqlite" ? Math.floor(I.getTime() / 1e3) : I.getTime() : A = I.toISOString();
1950
1973
  }
1951
1974
  return h(
1952
1975
  Q(E, R),
@@ -1956,21 +1979,21 @@ class We {
1956
1979
  if (typeof e == "string") {
1957
1980
  const R = this.parseRelativeDateRange(e);
1958
1981
  if (R) {
1959
- let I, s;
1960
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (I = Math.floor(R.start.getTime() / 1e3), s = Math.floor(R.end.getTime() / 1e3)) : (I = R.start.getTime(), s = R.end.getTime()) : (I = R.start.toISOString(), s = R.end.toISOString()), h(
1961
- Q(E, I),
1962
- Z(E, s)
1982
+ let N, C;
1983
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (N = Math.floor(R.start.getTime() / 1e3), C = Math.floor(R.end.getTime() / 1e3)) : (N = R.start.getTime(), C = R.end.getTime()) : (N = R.start.toISOString(), C = R.end.toISOString()), h(
1984
+ Q(E, N),
1985
+ Z(E, C)
1963
1986
  );
1964
1987
  }
1965
1988
  const A = this.normalizeDate(e);
1966
1989
  if (!A) return null;
1967
- const S = typeof A == "number" ? new Date(A * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(A), N = new Date(S);
1968
- N.setUTCHours(0, 0, 0, 0);
1990
+ const S = typeof A == "number" ? new Date(A * (this.databaseAdapter.getEngineType() === "sqlite" ? 1e3 : 1)) : new Date(A), I = new Date(S);
1991
+ I.setUTCHours(0, 0, 0, 0);
1969
1992
  const t = new Date(S);
1970
1993
  t.setUTCHours(23, 59, 59, 999);
1971
- let C, O;
1972
- return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (C = Math.floor(N.getTime() / 1e3), O = Math.floor(t.getTime() / 1e3)) : (C = N.getTime(), O = t.getTime()) : (C = N.toISOString(), O = t.toISOString()), h(
1973
- Q(E, C),
1994
+ let s, O;
1995
+ return this.databaseAdapter.isTimestampInteger() ? this.databaseAdapter.getEngineType() === "sqlite" ? (s = Math.floor(I.getTime() / 1e3), O = Math.floor(t.getTime() / 1e3)) : (s = I.getTime(), O = t.getTime()) : (s = I.toISOString(), O = t.toISOString()), h(
1996
+ Q(E, s),
1974
1997
  Z(E, O)
1975
1998
  );
1976
1999
  }
@@ -1981,75 +2004,82 @@ class We {
1981
2004
  * Handles all 14 DATE_RANGE_OPTIONS from the client
1982
2005
  */
1983
2006
  parseRelativeDateRange(E) {
1984
- const e = /* @__PURE__ */ new Date(), R = E.toLowerCase().trim(), A = e.getUTCFullYear(), S = e.getUTCMonth(), N = e.getUTCDate(), t = e.getUTCDay();
2007
+ const e = /* @__PURE__ */ new Date(), R = E.toLowerCase().trim(), A = e.getUTCFullYear(), S = e.getUTCMonth(), I = e.getUTCDate(), t = e.getUTCDay();
1985
2008
  if (R === "today") {
1986
- const s = new Date(e);
1987
- s.setUTCHours(0, 0, 0, 0);
1988
- const r = new Date(e);
1989
- return r.setUTCHours(23, 59, 59, 999), { start: s, end: r };
2009
+ const L = new Date(e);
2010
+ L.setUTCHours(0, 0, 0, 0);
2011
+ const n = new Date(e);
2012
+ return n.setUTCHours(23, 59, 59, 999), { start: L, end: n };
1990
2013
  }
1991
2014
  if (R === "yesterday") {
1992
- const s = new Date(e);
1993
- s.setUTCDate(N - 1), s.setUTCHours(0, 0, 0, 0);
1994
- const r = new Date(e);
1995
- return r.setUTCDate(N - 1), r.setUTCHours(23, 59, 59, 999), { start: s, end: r };
2015
+ const L = new Date(e);
2016
+ L.setUTCDate(I - 1), L.setUTCHours(0, 0, 0, 0);
2017
+ const n = new Date(e);
2018
+ return n.setUTCDate(I - 1), n.setUTCHours(23, 59, 59, 999), { start: L, end: n };
1996
2019
  }
1997
2020
  if (R === "this week") {
1998
- const s = t === 0 ? -6 : 1 - t, r = new Date(e);
1999
- r.setUTCDate(N + s), r.setUTCHours(0, 0, 0, 0);
2000
- const _ = new Date(r);
2001
- return _.setUTCDate(r.getUTCDate() + 6), _.setUTCHours(23, 59, 59, 999), { start: r, end: _ };
2021
+ const L = t === 0 ? -6 : 1 - t, n = new Date(e);
2022
+ n.setUTCDate(I + L), n.setUTCHours(0, 0, 0, 0);
2023
+ const i = new Date(n);
2024
+ return i.setUTCDate(n.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: n, end: i };
2002
2025
  }
2003
2026
  if (R === "this month") {
2004
- const s = new Date(Date.UTC(A, S, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(A, S + 1, 0, 23, 59, 59, 999));
2005
- return { start: s, end: r };
2027
+ const L = new Date(Date.UTC(A, S, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(A, S + 1, 0, 23, 59, 59, 999));
2028
+ return { start: L, end: n };
2006
2029
  }
2007
2030
  if (R === "this quarter") {
2008
- const s = Math.floor(S / 3), r = new Date(Date.UTC(A, s * 3, 1, 0, 0, 0, 0)), _ = new Date(Date.UTC(A, s * 3 + 3, 0, 23, 59, 59, 999));
2009
- return { start: r, end: _ };
2031
+ const L = Math.floor(S / 3), n = new Date(Date.UTC(A, L * 3, 1, 0, 0, 0, 0)), i = new Date(Date.UTC(A, L * 3 + 3, 0, 23, 59, 59, 999));
2032
+ return { start: n, end: i };
2010
2033
  }
2011
2034
  if (R === "this year") {
2012
- const s = new Date(Date.UTC(A, 0, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(A, 11, 31, 23, 59, 59, 999));
2013
- return { start: s, end: r };
2035
+ const L = new Date(Date.UTC(A, 0, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(A, 11, 31, 23, 59, 59, 999));
2036
+ return { start: L, end: n };
2014
2037
  }
2015
- const C = R.match(/^last\s+(\d+)\s+days?$/);
2016
- if (C) {
2017
- const s = parseInt(C[1], 10), r = new Date(e);
2018
- r.setUTCDate(N - s + 1), r.setUTCHours(0, 0, 0, 0);
2019
- const _ = new Date(e);
2020
- return _.setUTCHours(23, 59, 59, 999), { start: r, end: _ };
2038
+ const s = R.match(/^last\s+(\d+)\s+days?$/);
2039
+ if (s) {
2040
+ const L = parseInt(s[1], 10), n = new Date(e);
2041
+ n.setUTCDate(I - L + 1), n.setUTCHours(0, 0, 0, 0);
2042
+ const i = new Date(e);
2043
+ return i.setUTCHours(23, 59, 59, 999), { start: n, end: i };
2044
+ }
2045
+ const O = R.match(/^last\s+(\d+)\s+weeks?$/);
2046
+ if (O) {
2047
+ const n = parseInt(O[1], 10) * 7, i = new Date(e);
2048
+ i.setUTCDate(I - n + 1), i.setUTCHours(0, 0, 0, 0);
2049
+ const o = new Date(e);
2050
+ return o.setUTCHours(23, 59, 59, 999), { start: i, end: o };
2021
2051
  }
2022
2052
  if (R === "last week") {
2023
- const s = t === 0 ? -13 : -6 - t, r = new Date(e);
2024
- r.setUTCDate(N + s), r.setUTCHours(0, 0, 0, 0);
2025
- const _ = new Date(r);
2026
- return _.setUTCDate(r.getUTCDate() + 6), _.setUTCHours(23, 59, 59, 999), { start: r, end: _ };
2053
+ const L = t === 0 ? -13 : -6 - t, n = new Date(e);
2054
+ n.setUTCDate(I + L), n.setUTCHours(0, 0, 0, 0);
2055
+ const i = new Date(n);
2056
+ return i.setUTCDate(n.getUTCDate() + 6), i.setUTCHours(23, 59, 59, 999), { start: n, end: i };
2027
2057
  }
2028
2058
  if (R === "last month") {
2029
- const s = new Date(Date.UTC(A, S - 1, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(A, S, 0, 23, 59, 59, 999));
2030
- return { start: s, end: r };
2059
+ const L = new Date(Date.UTC(A, S - 1, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(A, S, 0, 23, 59, 59, 999));
2060
+ return { start: L, end: n };
2031
2061
  }
2032
2062
  if (R === "last quarter") {
2033
- const s = Math.floor(S / 3), r = s === 0 ? 3 : s - 1, _ = s === 0 ? A - 1 : A, D = new Date(Date.UTC(_, r * 3, 1, 0, 0, 0, 0)), o = new Date(Date.UTC(_, r * 3 + 3, 0, 23, 59, 59, 999));
2034
- return { start: D, end: o };
2063
+ const L = Math.floor(S / 3), n = L === 0 ? 3 : L - 1, i = L === 0 ? A - 1 : A, o = new Date(Date.UTC(i, n * 3, 1, 0, 0, 0, 0)), u = new Date(Date.UTC(i, n * 3 + 3, 0, 23, 59, 59, 999));
2064
+ return { start: o, end: u };
2035
2065
  }
2036
2066
  if (R === "last year") {
2037
- const s = new Date(Date.UTC(A - 1, 0, 1, 0, 0, 0, 0)), r = new Date(Date.UTC(A - 1, 11, 31, 23, 59, 59, 999));
2038
- return { start: s, end: r };
2067
+ const L = new Date(Date.UTC(A - 1, 0, 1, 0, 0, 0, 0)), n = new Date(Date.UTC(A - 1, 11, 31, 23, 59, 59, 999));
2068
+ return { start: L, end: n };
2039
2069
  }
2040
2070
  if (R === "last 12 months") {
2041
- const s = new Date(Date.UTC(A, S - 11, 1, 0, 0, 0, 0)), r = new Date(e);
2042
- return r.setUTCHours(23, 59, 59, 999), { start: s, end: r };
2071
+ const L = new Date(Date.UTC(A, S - 11, 1, 0, 0, 0, 0)), n = new Date(e);
2072
+ return n.setUTCHours(23, 59, 59, 999), { start: L, end: n };
2043
2073
  }
2044
- const O = R.match(/^last\s+(\d+)\s+months?$/);
2045
- if (O) {
2046
- const s = parseInt(O[1], 10), r = new Date(Date.UTC(A, S - s + 1, 1, 0, 0, 0, 0)), _ = new Date(e);
2047
- return _.setUTCHours(23, 59, 59, 999), { start: r, end: _ };
2074
+ const N = R.match(/^last\s+(\d+)\s+months?$/);
2075
+ if (N) {
2076
+ const L = parseInt(N[1], 10), n = new Date(Date.UTC(A, S - L + 1, 1, 0, 0, 0, 0)), i = new Date(e);
2077
+ return i.setUTCHours(23, 59, 59, 999), { start: n, end: i };
2048
2078
  }
2049
- const I = R.match(/^last\s+(\d+)\s+years?$/);
2050
- if (I) {
2051
- const s = parseInt(I[1], 10), r = new Date(Date.UTC(A - s, 0, 1, 0, 0, 0, 0)), _ = new Date(e);
2052
- return _.setUTCHours(23, 59, 59, 999), { start: r, end: _ };
2079
+ const C = R.match(/^last\s+(\d+)\s+years?$/);
2080
+ if (C) {
2081
+ const L = parseInt(C[1], 10), n = new Date(Date.UTC(A - L, 0, 1, 0, 0, 0, 0)), i = new Date(e);
2082
+ return i.setUTCHours(23, 59, 59, 999), { start: n, end: i };
2053
2083
  }
2054
2084
  return null;
2055
2085
  }
@@ -2087,46 +2117,46 @@ class We {
2087
2117
  return [];
2088
2118
  const t = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
2089
2119
  if (e.dimensions)
2090
- for (const C of e.dimensions) {
2091
- const [O, I] = C.split("."), s = t.get(O);
2092
- if (s && s.dimensions && s.dimensions[I])
2093
- if (A?.preAggregationCTEs?.some((_) => _.cube.name === O)) {
2094
- const _ = A.preAggregationCTEs.find((o) => o.cube.name === O), D = _.joinKeys.find((o) => o.targetColumn === I);
2095
- if (D && D.sourceColumnObj)
2096
- S.push(D.sourceColumnObj);
2120
+ for (const s of e.dimensions) {
2121
+ const [O, N] = s.split("."), C = t.get(O);
2122
+ if (C && C.dimensions && C.dimensions[N])
2123
+ if (A?.preAggregationCTEs?.some((n) => n.cube.name === O)) {
2124
+ const n = A.preAggregationCTEs.find((o) => o.cube.name === O), i = n.joinKeys.find((o) => o.targetColumn === N);
2125
+ if (i && i.sourceColumnObj)
2126
+ S.push(i.sourceColumnObj);
2097
2127
  else {
2098
- const o = L`${L.identifier(_.cteAlias)}.${L.identifier(I)}`;
2128
+ const o = r`${r.identifier(n.cteAlias)}.${r.identifier(N)}`;
2099
2129
  S.push(o);
2100
2130
  }
2101
2131
  } else {
2102
- const _ = s.dimensions[I], D = w(_.sql, R);
2103
- S.push(D);
2132
+ const n = C.dimensions[N], i = w(n.sql, R);
2133
+ S.push(i);
2104
2134
  }
2105
2135
  }
2106
2136
  if (e.timeDimensions)
2107
- for (const C of e.timeDimensions) {
2108
- const [O, I] = C.dimension.split("."), s = t.get(O);
2109
- if (s && s.dimensions && s.dimensions[I])
2110
- if (A?.preAggregationCTEs?.some((_) => _.cube.name === O)) {
2111
- const _ = A.preAggregationCTEs.find((o) => o.cube.name === O), D = _.joinKeys.find((o) => o.targetColumn === I);
2112
- if (D && D.sourceColumnObj) {
2137
+ for (const s of e.timeDimensions) {
2138
+ const [O, N] = s.dimension.split("."), C = t.get(O);
2139
+ if (C && C.dimensions && C.dimensions[N])
2140
+ if (A?.preAggregationCTEs?.some((n) => n.cube.name === O)) {
2141
+ const n = A.preAggregationCTEs.find((o) => o.cube.name === O), i = n.joinKeys.find((o) => o.targetColumn === N);
2142
+ if (i && i.sourceColumnObj) {
2113
2143
  const o = this.buildTimeDimensionExpression(
2114
- D.sourceColumnObj,
2115
- C.granularity,
2144
+ i.sourceColumnObj,
2145
+ s.granularity,
2116
2146
  R
2117
2147
  );
2118
2148
  S.push(o);
2119
2149
  } else {
2120
- const o = L`${L.identifier(_.cteAlias)}.${L.identifier(I)}`;
2150
+ const o = r`${r.identifier(n.cteAlias)}.${r.identifier(N)}`;
2121
2151
  S.push(o);
2122
2152
  }
2123
2153
  } else {
2124
- const _ = s.dimensions[I], D = this.buildTimeDimensionExpression(
2125
- _.sql,
2126
- C.granularity,
2154
+ const n = C.dimensions[N], i = this.buildTimeDimensionExpression(
2155
+ n.sql,
2156
+ s.granularity,
2127
2157
  R
2128
2158
  );
2129
- S.push(D);
2159
+ S.push(i);
2130
2160
  }
2131
2161
  }
2132
2162
  return S;
@@ -2141,18 +2171,18 @@ class We {
2141
2171
  ...E.timeDimensions?.map((S) => S.dimension) || []
2142
2172
  ];
2143
2173
  if (E.order && Object.keys(E.order).length > 0)
2144
- for (const [S, N] of Object.entries(E.order)) {
2174
+ for (const [S, I] of Object.entries(E.order)) {
2145
2175
  if (!A.includes(S))
2146
2176
  throw new Error(`Cannot order by '${S}': field is not selected in the query`);
2147
- const t = N === "desc" ? Ue(L.identifier(S)) : tT(L.identifier(S));
2177
+ const t = I === "desc" ? Ue(r.identifier(S)) : tT(r.identifier(S));
2148
2178
  R.push(t);
2149
2179
  }
2150
2180
  if (E.timeDimensions && E.timeDimensions.length > 0) {
2151
- const S = new Set(Object.keys(E.order || {})), N = [...E.timeDimensions].sort(
2152
- (t, C) => t.dimension.localeCompare(C.dimension)
2181
+ const S = new Set(Object.keys(E.order || {})), I = [...E.timeDimensions].sort(
2182
+ (t, s) => t.dimension.localeCompare(s.dimension)
2153
2183
  );
2154
- for (const t of N)
2155
- S.has(t.dimension) || R.push(tT(L.identifier(t.dimension)));
2184
+ for (const t of I)
2185
+ S.has(t.dimension) || R.push(tT(r.identifier(t.dimension)));
2156
2186
  }
2157
2187
  return R;
2158
2188
  }
@@ -2164,9 +2194,9 @@ class We {
2164
2194
  const R = [], A = E instanceof Map ? E : /* @__PURE__ */ new Map([[E.name, E]]);
2165
2195
  if (e.measures && R.push(...e.measures), e.dimensions)
2166
2196
  for (const S of e.dimensions) {
2167
- const [N, t] = S.split("."), C = A.get(N);
2168
- if (C) {
2169
- const O = C.dimensions[t];
2197
+ const [I, t] = S.split("."), s = A.get(I);
2198
+ if (s) {
2199
+ const O = s.dimensions[t];
2170
2200
  O && O.type === "number" && R.push(S);
2171
2201
  }
2172
2202
  }
@@ -2267,9 +2297,9 @@ class be {
2267
2297
  const A = this.analyzeCubeUsage(e), S = Array.from(A);
2268
2298
  if (S.length === 0)
2269
2299
  throw new Error("No cubes found in query");
2270
- const N = this.choosePrimaryCube(S, e, E), t = E.get(N);
2300
+ const I = this.choosePrimaryCube(S, e, E), t = E.get(I);
2271
2301
  if (!t)
2272
- throw new Error(`Primary cube '${N}' not found`);
2302
+ throw new Error(`Primary cube '${I}' not found`);
2273
2303
  if (S.length === 1)
2274
2304
  return {
2275
2305
  primaryCube: t,
@@ -2282,10 +2312,10 @@ class be {
2282
2312
  groupByFields: []
2283
2313
  // Will be built by QueryBuilder
2284
2314
  };
2285
- const C = this.buildJoinPlan(E, t, S, R), O = this.planPreAggregationCTEs(E, t, C, e);
2315
+ const s = this.buildJoinPlan(E, t, S, R), O = this.planPreAggregationCTEs(E, t, s, e);
2286
2316
  return {
2287
2317
  primaryCube: t,
2288
- joinCubes: C,
2318
+ joinCubes: s,
2289
2319
  selections: {},
2290
2320
  // Will be built by QueryBuilder
2291
2321
  whereConditions: [],
@@ -2301,21 +2331,21 @@ class be {
2301
2331
  */
2302
2332
  choosePrimaryCube(E, e, R) {
2303
2333
  if (e.dimensions && e.dimensions.length > 0 && R) {
2304
- const A = e.dimensions.map((N) => N.split(".")[0]), S = /* @__PURE__ */ new Map();
2305
- for (const N of A)
2306
- S.set(N, (S.get(N) || 0) + 1);
2334
+ const A = e.dimensions.map((I) => I.split(".")[0]), S = /* @__PURE__ */ new Map();
2335
+ for (const I of A)
2336
+ S.set(I, (S.get(I) || 0) + 1);
2307
2337
  if (S.size > 0) {
2308
- const N = Math.max(...S.values()), t = [...S.entries()].filter(([, C]) => C === N).map(([C]) => C).sort();
2309
- for (const C of t)
2310
- if (this.canReachAllCubes(C, E, R))
2311
- return C;
2338
+ const I = Math.max(...S.values()), t = [...S.entries()].filter(([, s]) => s === I).map(([s]) => s).sort();
2339
+ for (const s of t)
2340
+ if (this.canReachAllCubes(s, E, R))
2341
+ return s;
2312
2342
  }
2313
2343
  }
2314
2344
  if (R) {
2315
2345
  const A = /* @__PURE__ */ new Map();
2316
2346
  for (const S of E)
2317
2347
  if (this.canReachAllCubes(S, E, R)) {
2318
- const N = R.get(S), t = N?.joins ? Object.keys(N.joins).length : 0;
2348
+ const I = R.get(S), t = I?.joins ? Object.keys(I.joins).length : 0;
2319
2349
  A.set(S, t);
2320
2350
  }
2321
2351
  if (A.size > 0) {
@@ -2331,8 +2361,8 @@ class be {
2331
2361
  canReachAllCubes(E, e, R) {
2332
2362
  const A = e.filter((S) => S !== E);
2333
2363
  for (const S of A) {
2334
- const N = this.findJoinPath(R, E, S, /* @__PURE__ */ new Set());
2335
- if (!N || N.length === 0)
2364
+ const I = this.findJoinPath(R, E, S, /* @__PURE__ */ new Set());
2365
+ if (!I || I.length === 0)
2336
2366
  return !1;
2337
2367
  }
2338
2368
  return !0;
@@ -2342,52 +2372,52 @@ class be {
2342
2372
  * Supports both direct joins and transitive joins through intermediate cubes
2343
2373
  */
2344
2374
  buildJoinPlan(E, e, R, A) {
2345
- const S = [], N = /* @__PURE__ */ new Set([e.name]), t = R.filter((C) => C !== e.name);
2346
- for (const C of t) {
2347
- if (N.has(C))
2375
+ const S = [], I = /* @__PURE__ */ new Set([e.name]), t = R.filter((s) => s !== e.name);
2376
+ for (const s of t) {
2377
+ if (I.has(s))
2348
2378
  continue;
2349
- const O = this.findJoinPath(E, e.name, C, N);
2379
+ const O = this.findJoinPath(E, e.name, s, I);
2350
2380
  if (!O || O.length === 0)
2351
- throw new Error(`No join path found from '${e.name}' to '${C}'`);
2352
- for (const { toCube: I, joinDef: s } of O) {
2353
- if (N.has(I))
2381
+ throw new Error(`No join path found from '${e.name}' to '${s}'`);
2382
+ for (const { toCube: N, joinDef: C } of O) {
2383
+ if (I.has(N))
2354
2384
  continue;
2355
- const r = E.get(I);
2356
- if (!r)
2357
- throw new Error(`Cube '${I}' not found`);
2358
- if (s.relationship === "belongsToMany" && s.through) {
2359
- const _ = fe(s, A.securityContext);
2385
+ const L = E.get(N);
2386
+ if (!L)
2387
+ throw new Error(`Cube '${N}' not found`);
2388
+ if (C.relationship === "belongsToMany" && C.through) {
2389
+ const n = fe(C, A.securityContext);
2360
2390
  S.push({
2361
- cube: r,
2362
- alias: `${I.toLowerCase()}_cube`,
2363
- joinType: _.junctionJoins[1].joinType,
2391
+ cube: L,
2392
+ alias: `${N.toLowerCase()}_cube`,
2393
+ joinType: n.junctionJoins[1].joinType,
2364
2394
  // Use the target join type
2365
- joinCondition: _.junctionJoins[1].condition,
2395
+ joinCondition: n.junctionJoins[1].condition,
2366
2396
  // Target join condition
2367
2397
  junctionTable: {
2368
- table: s.through.table,
2369
- alias: `junction_${I.toLowerCase()}`,
2370
- joinType: _.junctionJoins[0].joinType,
2371
- joinCondition: _.junctionJoins[0].condition,
2372
- securitySql: s.through.securitySql
2398
+ table: C.through.table,
2399
+ alias: `junction_${N.toLowerCase()}`,
2400
+ joinType: n.junctionJoins[0].joinType,
2401
+ joinCondition: n.junctionJoins[0].condition,
2402
+ securitySql: C.through.securitySql
2373
2403
  }
2374
2404
  });
2375
2405
  } else {
2376
- const _ = this.buildJoinCondition(
2377
- s,
2406
+ const n = this.buildJoinCondition(
2407
+ C,
2378
2408
  null,
2379
2409
  // No source alias needed - use the actual column
2380
2410
  null
2381
2411
  // No target alias needed - use the actual column
2382
- ), D = zT(s.relationship, s.sqlJoinType);
2412
+ ), i = zT(C.relationship, C.sqlJoinType);
2383
2413
  S.push({
2384
- cube: r,
2385
- alias: `${I.toLowerCase()}_cube`,
2386
- joinType: D,
2387
- joinCondition: _
2414
+ cube: L,
2415
+ alias: `${N.toLowerCase()}_cube`,
2416
+ joinType: i,
2417
+ joinCondition: n
2388
2418
  });
2389
2419
  }
2390
- N.add(I);
2420
+ I.add(N);
2391
2421
  }
2392
2422
  }
2393
2423
  return S;
@@ -2398,8 +2428,8 @@ class be {
2398
2428
  buildJoinCondition(E, e, R) {
2399
2429
  const A = [];
2400
2430
  for (const S of E.on) {
2401
- const N = e ? L`${L.identifier(e)}.${L.identifier(S.source.name)}` : S.source, t = R ? L`${L.identifier(R)}.${L.identifier(S.target.name)}` : S.target, C = S.as || k;
2402
- A.push(C(N, t));
2431
+ const I = e ? r`${r.identifier(e)}.${r.identifier(S.source.name)}` : S.source, t = R ? r`${r.identifier(R)}.${r.identifier(S.target.name)}` : S.target, s = S.as || k;
2432
+ A.push(s(I, t));
2403
2433
  }
2404
2434
  return h(...A);
2405
2435
  }
@@ -2412,22 +2442,22 @@ class be {
2412
2442
  return [];
2413
2443
  const S = [
2414
2444
  { cube: e, path: [] }
2415
- ], N = /* @__PURE__ */ new Set([e, ...A]);
2445
+ ], I = /* @__PURE__ */ new Set([e, ...A]);
2416
2446
  for (; S.length > 0; ) {
2417
- const { cube: t, path: C } = S.shift(), O = E.get(t);
2447
+ const { cube: t, path: s } = S.shift(), O = E.get(t);
2418
2448
  if (O?.joins)
2419
- for (const [, I] of Object.entries(O.joins)) {
2420
- const r = LT(I.targetCube).name;
2421
- if (N.has(r))
2449
+ for (const [, N] of Object.entries(O.joins)) {
2450
+ const L = LT(N.targetCube).name;
2451
+ if (I.has(L))
2422
2452
  continue;
2423
- const _ = [...C, {
2453
+ const n = [...s, {
2424
2454
  fromCube: t,
2425
- toCube: r,
2426
- joinDef: I
2455
+ toCube: L,
2456
+ joinDef: N
2427
2457
  }];
2428
- if (r === R)
2429
- return _;
2430
- N.add(r), S.push({ cube: r, path: _ });
2458
+ if (L === R)
2459
+ return n;
2460
+ I.add(L), S.push({ cube: L, path: n });
2431
2461
  }
2432
2462
  }
2433
2463
  return null;
@@ -2441,30 +2471,30 @@ class be {
2441
2471
  const S = [];
2442
2472
  if (!A.measures || A.measures.length === 0)
2443
2473
  return S;
2444
- for (const N of R) {
2445
- const t = this.findHasManyJoinDef(e, N.cube.name);
2474
+ for (const I of R) {
2475
+ const t = this.findHasManyJoinDef(e, I.cube.name);
2446
2476
  if (!t)
2447
2477
  continue;
2448
- const C = A.measures ? A.measures.filter(
2449
- (_) => _.startsWith(N.cube.name + ".")
2450
- ) : [], O = this.extractMeasuresFromFilters(A, N.cube.name), I = [.../* @__PURE__ */ new Set([...C, ...O])];
2451
- if (I.length === 0)
2478
+ const s = A.measures ? A.measures.filter(
2479
+ (n) => n.startsWith(I.cube.name + ".")
2480
+ ) : [], O = this.extractMeasuresFromFilters(A, I.cube.name), N = [.../* @__PURE__ */ new Set([...s, ...O])];
2481
+ if (N.length === 0)
2452
2482
  continue;
2453
- const s = this.expandCalculatedMeasureDependencies(
2454
- N.cube,
2455
- I
2456
- ), r = t.on.map((_) => ({
2457
- sourceColumn: _.source.name,
2458
- targetColumn: _.target.name,
2459
- sourceColumnObj: _.source,
2460
- targetColumnObj: _.target
2483
+ const C = this.expandCalculatedMeasureDependencies(
2484
+ I.cube,
2485
+ N
2486
+ ), L = t.on.map((n) => ({
2487
+ sourceColumn: n.source.name,
2488
+ targetColumn: n.target.name,
2489
+ sourceColumnObj: n.source,
2490
+ targetColumnObj: n.target
2461
2491
  }));
2462
2492
  S.push({
2463
- cube: N.cube,
2464
- alias: N.alias,
2465
- cteAlias: `${N.cube.name.toLowerCase()}_agg`,
2466
- joinKeys: r,
2467
- measures: s
2493
+ cube: I.cube,
2494
+ alias: I.alias,
2495
+ cteAlias: `${I.cube.name.toLowerCase()}_agg`,
2496
+ joinKeys: L,
2497
+ measures: C
2468
2498
  });
2469
2499
  }
2470
2500
  return S;
@@ -2479,13 +2509,13 @@ class be {
2479
2509
  if (R.has(S))
2480
2510
  continue;
2481
2511
  R.add(S);
2482
- const [, N] = S.split(".");
2483
- if (!E.measures || !E.measures[N])
2512
+ const [, I] = S.split(".");
2513
+ if (!E.measures || !E.measures[I])
2484
2514
  continue;
2485
- const t = E.measures[N];
2515
+ const t = E.measures[I];
2486
2516
  if (t.type === "calculated" && t.calculatedSql) {
2487
- const C = this.extractDependenciesFromTemplate(t.calculatedSql, E.name);
2488
- for (const O of C)
2517
+ const s = this.extractDependenciesFromTemplate(t.calculatedSql, E.name);
2518
+ for (const O of s)
2489
2519
  R.has(O) || A.push(O);
2490
2520
  }
2491
2521
  }
@@ -2496,8 +2526,8 @@ class be {
2496
2526
  */
2497
2527
  extractDependenciesFromTemplate(E, e) {
2498
2528
  const R = /\{([^}]+)\}/g, A = E.matchAll(R), S = [];
2499
- for (const N of A) {
2500
- const t = N[1].trim();
2529
+ for (const I of A) {
2530
+ const t = I[1].trim();
2501
2531
  t.includes(".") ? S.push(t) : S.push(`${e}.${t}`);
2502
2532
  }
2503
2533
  return S;
@@ -2535,24 +2565,24 @@ class GE {
2535
2565
  db: this.dbExecutor.db,
2536
2566
  schema: this.dbExecutor.schema,
2537
2567
  securityContext: R
2538
- }, N = this.queryPlanner.createQueryPlan(E, e, S), t = this.buildUnifiedQuery(N, e, S), C = this.queryBuilder.collectNumericFields(E, e), O = await this.dbExecutor.execute(t, C), I = Array.isArray(O) ? O.map((r) => {
2539
- const _ = { ...r };
2568
+ }, I = this.queryPlanner.createQueryPlan(E, e, S), t = this.buildUnifiedQuery(I, e, S), s = this.queryBuilder.collectNumericFields(E, e), O = await this.dbExecutor.execute(t, s), N = Array.isArray(O) ? O.map((L) => {
2569
+ const n = { ...L };
2540
2570
  if (e.timeDimensions) {
2541
- for (const D of e.timeDimensions)
2542
- if (D.dimension in _) {
2543
- let o = _[D.dimension];
2571
+ for (const i of e.timeDimensions)
2572
+ if (i.dimension in n) {
2573
+ let o = n[i.dimension];
2544
2574
  if (typeof o == "string" && o.match(/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)) {
2545
2575
  const u = o.replace(" ", "T"), P = !u.endsWith("Z") && !u.includes("+") ? u + "Z" : u;
2546
2576
  o = new Date(P);
2547
2577
  }
2548
- o = this.databaseAdapter.convertTimeDimensionResult(o), _[D.dimension] = o;
2578
+ o = this.databaseAdapter.convertTimeDimensionResult(o), n[i.dimension] = o;
2549
2579
  }
2550
2580
  }
2551
- return _;
2552
- }) : [O], s = this.generateAnnotations(N, e);
2581
+ return n;
2582
+ }) : [O], C = this.generateAnnotations(I, e);
2553
2583
  return {
2554
- data: I,
2555
- annotation: s
2584
+ data: N,
2585
+ annotation: C
2556
2586
  };
2557
2587
  } catch (A) {
2558
2588
  throw new Error(`Query execution failed: ${A instanceof Error ? A.message : "Unknown error"}`);
@@ -2569,73 +2599,73 @@ class GE {
2569
2599
  * Build pre-aggregation CTE for hasMany relationships
2570
2600
  */
2571
2601
  buildPreAggregationCTE(E, e, R, A) {
2572
- const S = E.cube, N = S.sql(R), t = {};
2602
+ const S = E.cube, I = S.sql(R), t = {};
2573
2603
  for (const P of E.joinKeys)
2574
2604
  if (P.targetColumnObj) {
2575
2605
  t[P.targetColumn] = P.targetColumnObj;
2576
2606
  for (const [l, M] of Object.entries(S.dimensions || {}))
2577
- M.sql === P.targetColumnObj && l !== P.targetColumn && (t[l] = L`${P.targetColumnObj}`.as(l));
2607
+ M.sql === P.targetColumnObj && l !== P.targetColumn && (t[l] = r`${P.targetColumnObj}`.as(l));
2578
2608
  }
2579
- const C = S.name, O = /* @__PURE__ */ new Map([[C, S]]), I = this.queryBuilder.buildResolvedMeasures(
2609
+ const s = S.name, O = /* @__PURE__ */ new Map([[s, S]]), N = this.queryBuilder.buildResolvedMeasures(
2580
2610
  E.measures,
2581
2611
  O,
2582
2612
  R
2583
2613
  );
2584
2614
  for (const P of E.measures) {
2585
- const [, l] = P.split("."), M = I.get(P);
2615
+ const [, l] = P.split("."), M = N.get(P);
2586
2616
  if (M) {
2587
2617
  const G = M();
2588
- t[l] = L`${G}`.as(l);
2618
+ t[l] = r`${G}`.as(l);
2589
2619
  }
2590
2620
  }
2591
2621
  if (e.dimensions)
2592
2622
  for (const P of e.dimensions) {
2593
2623
  const [l, M] = P.split(".");
2594
- if (l === C && S.dimensions && S.dimensions[M]) {
2624
+ if (l === s && S.dimensions && S.dimensions[M]) {
2595
2625
  const G = S.dimensions[M], m = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R);
2596
- t[M] = L`${m}`.as(M);
2626
+ t[M] = r`${m}`.as(M);
2597
2627
  }
2598
2628
  }
2599
2629
  if (e.timeDimensions)
2600
2630
  for (const P of e.timeDimensions) {
2601
2631
  const [l, M] = P.dimension.split(".");
2602
- if (l === C && S.dimensions && S.dimensions[M]) {
2632
+ if (l === s && S.dimensions && S.dimensions[M]) {
2603
2633
  const G = S.dimensions[M], m = this.queryBuilder.buildTimeDimensionExpression(G.sql, P.granularity, R);
2604
- t[M] = L`${m}`.as(M);
2634
+ t[M] = r`${m}`.as(M);
2605
2635
  }
2606
2636
  }
2607
2637
  if (Object.keys(t).length === 0)
2608
2638
  return null;
2609
- let s = R.db.select(t).from(N.from);
2610
- const r = A ? {
2639
+ let C = R.db.select(t).from(I.from);
2640
+ const L = A ? {
2611
2641
  ...A,
2612
2642
  preAggregationCTEs: A.preAggregationCTEs?.filter((P) => P.cube.name !== S.name)
2613
- } : void 0, _ = this.queryBuilder.buildWhereConditions(S, e, R, r), D = [];
2643
+ } : void 0, n = this.queryBuilder.buildWhereConditions(S, e, R, L), i = [];
2614
2644
  if (e.timeDimensions)
2615
2645
  for (const P of e.timeDimensions) {
2616
2646
  const [l, M] = P.dimension.split(".");
2617
- if (l === C && S.dimensions && S.dimensions[M] && P.dateRange) {
2647
+ if (l === s && S.dimensions && S.dimensions[M] && P.dateRange) {
2618
2648
  const G = S.dimensions[M], m = this.queryBuilder.buildMeasureExpression({ sql: G.sql, type: "number" }, R), B = this.queryBuilder.buildDateRangeCondition(m, P.dateRange);
2619
- B && D.push(B);
2649
+ B && i.push(B);
2620
2650
  }
2621
2651
  }
2622
2652
  if (e.filters) {
2623
2653
  for (const P of e.filters)
2624
2654
  if (!("and" in P) && !("or" in P) && "member" in P && "operator" in P) {
2625
2655
  const l = P, [M, G] = l.member.split(".");
2626
- if (M === C && S.dimensions && S.dimensions[G]) {
2656
+ if (M === s && S.dimensions && S.dimensions[G]) {
2627
2657
  const m = S.dimensions[G];
2628
2658
  if (l.operator === "inDateRange") {
2629
2659
  const B = this.queryBuilder.buildMeasureExpression({ sql: m.sql, type: "number" }, R), b = this.queryBuilder.buildDateRangeCondition(B, l.values);
2630
- b && D.push(b);
2660
+ b && i.push(b);
2631
2661
  }
2632
2662
  }
2633
2663
  }
2634
2664
  }
2635
2665
  const o = [];
2636
- if (N.where && o.push(N.where), o.push(..._, ...D), o.length > 0) {
2666
+ if (I.where && o.push(I.where), o.push(...n, ...i), o.length > 0) {
2637
2667
  const P = o.length === 1 ? o[0] : h(...o);
2638
- s = s.where(P);
2668
+ C = C.where(P);
2639
2669
  }
2640
2670
  const u = [];
2641
2671
  for (const P of E.joinKeys)
@@ -2643,7 +2673,7 @@ class GE {
2643
2673
  if (e.dimensions)
2644
2674
  for (const P of e.dimensions) {
2645
2675
  const [l, M] = P.split(".");
2646
- if (l === C && S.dimensions && S.dimensions[M]) {
2676
+ if (l === s && S.dimensions && S.dimensions[M]) {
2647
2677
  const G = S.dimensions[M], m = w(G.sql, R);
2648
2678
  u.push(m);
2649
2679
  }
@@ -2651,25 +2681,25 @@ class GE {
2651
2681
  if (e.timeDimensions)
2652
2682
  for (const P of e.timeDimensions) {
2653
2683
  const [l, M] = P.dimension.split(".");
2654
- if (l === C && S.dimensions && S.dimensions[M]) {
2684
+ if (l === s && S.dimensions && S.dimensions[M]) {
2655
2685
  const G = S.dimensions[M], m = this.queryBuilder.buildTimeDimensionExpression(G.sql, P.granularity, R);
2656
2686
  u.push(m);
2657
2687
  }
2658
2688
  }
2659
- return u.length > 0 && (s = s.groupBy(...u)), R.db.$with(E.cteAlias).as(s);
2689
+ return u.length > 0 && (C = C.groupBy(...u)), R.db.$with(E.cteAlias).as(C);
2660
2690
  }
2661
2691
  // Removed unused getActualJoinTargetColumn method
2662
2692
  /**
2663
2693
  * Build join condition for CTE
2664
2694
  */
2665
2695
  buildCTEJoinCondition(E, e, R) {
2666
- const A = R.preAggregationCTEs?.find((N) => N.cube.name === E.cube.name);
2696
+ const A = R.preAggregationCTEs?.find((I) => I.cube.name === E.cube.name);
2667
2697
  if (!A)
2668
2698
  throw new Error(`CTE info not found for cube ${E.cube.name}`);
2669
2699
  const S = [];
2670
- for (const N of A.joinKeys) {
2671
- const t = N.sourceColumnObj || L.identifier(N.sourceColumn), C = L`${L.identifier(e)}.${L.identifier(N.targetColumn)}`;
2672
- S.push(k(t, C));
2700
+ for (const I of A.joinKeys) {
2701
+ const t = I.sourceColumnObj || r.identifier(I.sourceColumn), s = r`${r.identifier(e)}.${r.identifier(I.targetColumn)}`;
2702
+ S.push(k(t, s));
2673
2703
  }
2674
2704
  return S.length === 1 ? S[0] : h(...S);
2675
2705
  }
@@ -2683,7 +2713,7 @@ class GE {
2683
2713
  const u = this.buildPreAggregationCTE(o, e, R, E);
2684
2714
  u && (A.push(u), S.set(o.cube.name, o.cteAlias));
2685
2715
  }
2686
- const N = E.primaryCube.sql(R), C = { ...this.queryBuilder.buildSelections(
2716
+ const I = E.primaryCube.sql(R), s = { ...this.queryBuilder.buildSelections(
2687
2717
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2688
2718
  // Single cube
2689
2719
  e,
@@ -2693,7 +2723,7 @@ class GE {
2693
2723
  for (const o of E.preAggregationCTEs) {
2694
2724
  const u = o.cube.name;
2695
2725
  for (const P of o.measures)
2696
- if (C[P]) {
2726
+ if (s[P]) {
2697
2727
  const [, l] = P.split("."), M = this.getCubesFromPlan(E).get(u);
2698
2728
  if (M && M.measures && M.measures[l]) {
2699
2729
  const G = M.measures[l];
@@ -2708,7 +2738,7 @@ class GE {
2708
2738
  R
2709
2739
  );
2710
2740
  } else {
2711
- const B = L`${L.identifier(o.cteAlias)}.${L.identifier(l)}`;
2741
+ const B = r`${r.identifier(o.cteAlias)}.${r.identifier(l)}`;
2712
2742
  switch (G.type) {
2713
2743
  case "count":
2714
2744
  case "countDistinct":
@@ -2731,10 +2761,10 @@ class GE {
2731
2761
  m = y(B);
2732
2762
  }
2733
2763
  }
2734
- C[P] = L`${m}`.as(P);
2764
+ s[P] = r`${m}`.as(P);
2735
2765
  }
2736
2766
  }
2737
- for (const P in C) {
2767
+ for (const P in s) {
2738
2768
  const [l, M] = P.split(".");
2739
2769
  if (l === u) {
2740
2770
  const G = this.getCubesFromPlan(E).get(u), m = G && G.dimensions?.[M], B = P.startsWith(u + ".");
@@ -2744,27 +2774,27 @@ class GE {
2744
2774
  const _E = G.dimensions[M].sql;
2745
2775
  b = o.joinKeys.find((_e) => _e.targetColumnObj === _E);
2746
2776
  }
2747
- b ? C[P] = L`${L.identifier(o.cteAlias)}.${L.identifier(M)}`.as(P) : B && G?.dimensions?.[M] && (C[P] = L`${L.identifier(o.cteAlias)}.${L.identifier(M)}`.as(P));
2777
+ b ? s[P] = r`${r.identifier(o.cteAlias)}.${r.identifier(M)}`.as(P) : B && G?.dimensions?.[M] && (s[P] = r`${r.identifier(o.cteAlias)}.${r.identifier(M)}`.as(P));
2748
2778
  }
2749
2779
  }
2750
2780
  }
2751
2781
  }
2752
2782
  const O = [];
2753
- let I = R.db.select(C).from(N.from);
2754
- if (A.length > 0 && (I = R.db.with(...A).select(C).from(N.from)), N.joins)
2755
- for (const o of N.joins)
2783
+ let N = R.db.select(s).from(I.from);
2784
+ if (A.length > 0 && (N = R.db.with(...A).select(s).from(I.from)), I.joins)
2785
+ for (const o of I.joins)
2756
2786
  switch (o.type || "left") {
2757
2787
  case "left":
2758
- I = I.leftJoin(o.table, o.on);
2788
+ N = N.leftJoin(o.table, o.on);
2759
2789
  break;
2760
2790
  case "inner":
2761
- I = I.innerJoin(o.table, o.on);
2791
+ N = N.innerJoin(o.table, o.on);
2762
2792
  break;
2763
2793
  case "right":
2764
- I = I.rightJoin(o.table, o.on);
2794
+ N = N.rightJoin(o.table, o.on);
2765
2795
  break;
2766
2796
  case "full":
2767
- I = I.fullJoin(o.table, o.on);
2797
+ N = N.fullJoin(o.table, o.on);
2768
2798
  break;
2769
2799
  }
2770
2800
  if (E.joinCubes && E.joinCubes.length > 0)
@@ -2779,16 +2809,16 @@ class GE {
2779
2809
  try {
2780
2810
  switch (M.joinType || "left") {
2781
2811
  case "left":
2782
- I = I.leftJoin(M.table, M.joinCondition);
2812
+ N = N.leftJoin(M.table, M.joinCondition);
2783
2813
  break;
2784
2814
  case "inner":
2785
- I = I.innerJoin(M.table, M.joinCondition);
2815
+ N = N.innerJoin(M.table, M.joinCondition);
2786
2816
  break;
2787
2817
  case "right":
2788
- I = I.rightJoin(M.table, M.joinCondition);
2818
+ N = N.rightJoin(M.table, M.joinCondition);
2789
2819
  break;
2790
2820
  case "full":
2791
- I = I.fullJoin(M.table, M.joinCondition);
2821
+ N = N.fullJoin(M.table, M.joinCondition);
2792
2822
  break;
2793
2823
  }
2794
2824
  G.length > 0 && O.push(...G);
@@ -2796,33 +2826,33 @@ class GE {
2796
2826
  }
2797
2827
  }
2798
2828
  let P, l;
2799
- u ? (P = L`${L.identifier(u)}`, l = this.buildCTEJoinCondition(o, u, E)) : (P = o.cube.sql(R).from, l = o.joinCondition);
2829
+ u ? (P = r`${r.identifier(u)}`, l = this.buildCTEJoinCondition(o, u, E)) : (P = o.cube.sql(R).from, l = o.joinCondition);
2800
2830
  try {
2801
2831
  switch (o.joinType || "left") {
2802
2832
  case "left":
2803
- I = I.leftJoin(P, l);
2833
+ N = N.leftJoin(P, l);
2804
2834
  break;
2805
2835
  case "inner":
2806
- I = I.innerJoin(P, l);
2836
+ N = N.innerJoin(P, l);
2807
2837
  break;
2808
2838
  case "right":
2809
- I = I.rightJoin(P, l);
2839
+ N = N.rightJoin(P, l);
2810
2840
  break;
2811
2841
  case "full":
2812
- I = I.fullJoin(P, l);
2842
+ N = N.fullJoin(P, l);
2813
2843
  break;
2814
2844
  }
2815
2845
  } catch {
2816
2846
  }
2817
2847
  }
2818
- if (N.where && O.push(N.where), E.joinCubes && E.joinCubes.length > 0)
2848
+ if (I.where && O.push(I.where), E.joinCubes && E.joinCubes.length > 0)
2819
2849
  for (const o of E.joinCubes) {
2820
2850
  if (S.get(o.cube.name))
2821
2851
  continue;
2822
2852
  const P = o.cube.sql(R);
2823
2853
  P.where && O.push(P.where);
2824
2854
  }
2825
- const s = this.queryBuilder.buildWhereConditions(
2855
+ const C = this.queryBuilder.buildWhereConditions(
2826
2856
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2827
2857
  // Single cube
2828
2858
  e,
@@ -2830,11 +2860,11 @@ class GE {
2830
2860
  E
2831
2861
  // Pass the queryPlan to handle CTE scenarios
2832
2862
  );
2833
- if (s.length > 0 && O.push(...s), O.length > 0) {
2863
+ if (C.length > 0 && O.push(...C), O.length > 0) {
2834
2864
  const o = O.length === 1 ? O[0] : h(...O);
2835
- I = I.where(o);
2865
+ N = N.where(o);
2836
2866
  }
2837
- const r = this.queryBuilder.buildGroupByFields(
2867
+ const L = this.queryBuilder.buildGroupByFields(
2838
2868
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2839
2869
  // Single cube
2840
2870
  e,
@@ -2842,8 +2872,8 @@ class GE {
2842
2872
  E
2843
2873
  // Pass the queryPlan to handle CTE scenarios
2844
2874
  );
2845
- r.length > 0 && (I = I.groupBy(...r));
2846
- const _ = this.queryBuilder.buildHavingConditions(
2875
+ L.length > 0 && (N = N.groupBy(...L));
2876
+ const n = this.queryBuilder.buildHavingConditions(
2847
2877
  E.joinCubes.length > 0 ? this.getCubesFromPlan(E) : E.primaryCube,
2848
2878
  // Single cube
2849
2879
  e,
@@ -2851,12 +2881,12 @@ class GE {
2851
2881
  E
2852
2882
  // Pass the queryPlan to handle CTE scenarios
2853
2883
  );
2854
- if (_.length > 0) {
2855
- const o = _.length === 1 ? _[0] : h(..._);
2856
- I = I.having(o);
2884
+ if (n.length > 0) {
2885
+ const o = n.length === 1 ? n[0] : h(...n);
2886
+ N = N.having(o);
2857
2887
  }
2858
- const D = this.queryBuilder.buildOrderBy(e);
2859
- return D.length > 0 && (I = I.orderBy(...D)), I = this.queryBuilder.applyLimitAndOffset(I, e), I;
2888
+ const i = this.queryBuilder.buildOrderBy(e);
2889
+ return i.length > 0 && (N = N.orderBy(...i)), N = this.queryBuilder.applyLimitAndOffset(N, e), N;
2860
2890
  }
2861
2891
  /**
2862
2892
  * Convert query plan to cube map for QueryBuilder methods
@@ -2899,40 +2929,40 @@ class GE {
2899
2929
  * Generate annotations for UI metadata - unified approach
2900
2930
  */
2901
2931
  generateAnnotations(E, e) {
2902
- const R = {}, A = {}, S = {}, N = [E.primaryCube];
2903
- if (E.joinCubes && E.joinCubes.length > 0 && N.push(...E.joinCubes.map((t) => t.cube)), e.measures)
2932
+ const R = {}, A = {}, S = {}, I = [E.primaryCube];
2933
+ if (E.joinCubes && E.joinCubes.length > 0 && I.push(...E.joinCubes.map((t) => t.cube)), e.measures)
2904
2934
  for (const t of e.measures) {
2905
- const [C, O] = t.split("."), I = N.find((s) => s.name === C);
2906
- if (I && I.measures[O]) {
2907
- const s = I.measures[O];
2935
+ const [s, O] = t.split("."), N = I.find((C) => C.name === s);
2936
+ if (N && N.measures[O]) {
2937
+ const C = N.measures[O];
2908
2938
  R[t] = {
2909
- title: s.title || O,
2910
- shortTitle: s.title || O,
2911
- type: s.type
2939
+ title: C.title || O,
2940
+ shortTitle: C.title || O,
2941
+ type: C.type
2912
2942
  };
2913
2943
  }
2914
2944
  }
2915
2945
  if (e.dimensions)
2916
2946
  for (const t of e.dimensions) {
2917
- const [C, O] = t.split("."), I = N.find((s) => s.name === C);
2918
- if (I && I.dimensions[O]) {
2919
- const s = I.dimensions[O];
2947
+ const [s, O] = t.split("."), N = I.find((C) => C.name === s);
2948
+ if (N && N.dimensions[O]) {
2949
+ const C = N.dimensions[O];
2920
2950
  A[t] = {
2921
- title: s.title || O,
2922
- shortTitle: s.title || O,
2923
- type: s.type
2951
+ title: C.title || O,
2952
+ shortTitle: C.title || O,
2953
+ type: C.type
2924
2954
  };
2925
2955
  }
2926
2956
  }
2927
2957
  if (e.timeDimensions)
2928
2958
  for (const t of e.timeDimensions) {
2929
- const [C, O] = t.dimension.split("."), I = N.find((s) => s.name === C);
2930
- if (I && I.dimensions && I.dimensions[O]) {
2931
- const s = I.dimensions[O];
2959
+ const [s, O] = t.dimension.split("."), N = I.find((C) => C.name === s);
2960
+ if (N && N.dimensions && N.dimensions[O]) {
2961
+ const C = N.dimensions[O];
2932
2962
  S[t.dimension] = {
2933
- title: s.title || O,
2934
- shortTitle: s.title || O,
2935
- type: s.type,
2963
+ title: C.title || O,
2964
+ shortTitle: C.title || O,
2965
+ type: C.type,
2936
2966
  granularity: t.granularity
2937
2967
  };
2938
2968
  }
@@ -2945,13 +2975,13 @@ class GE {
2945
2975
  };
2946
2976
  }
2947
2977
  }
2948
- const n = (T) => T.flatMap(Xe), Xe = (T) => IE(Ke(T)).map(ye), ye = (T) => T.replace(/ +/g, " ").trim(), Ke = (T) => ({
2978
+ const _ = (T) => T.flatMap(Xe), Xe = (T) => IE(ge(T)).map(ye), ye = (T) => T.replace(/ +/g, " ").trim(), ge = (T) => ({
2949
2979
  type: "mandatory_block",
2950
2980
  items: ET(T, 0)[0]
2951
2981
  }), ET = (T, E, e) => {
2952
2982
  const R = [];
2953
2983
  for (; T[E]; ) {
2954
- const [A, S] = ge(T, E);
2984
+ const [A, S] = Ke(T, E);
2955
2985
  if (R.push(A), E = S, T[E] === "|")
2956
2986
  E++;
2957
2987
  else if (T[E] === "}" || T[E] === "]") {
@@ -2966,7 +2996,7 @@ const n = (T) => T.flatMap(Xe), Xe = (T) => IE(Ke(T)).map(ye), ye = (T) => T.rep
2966
2996
  throw new Error(`Unexpected "${T[E]}"`);
2967
2997
  }
2968
2998
  return [R, E];
2969
- }, ge = (T, E) => {
2999
+ }, Ke = (T, E) => {
2970
3000
  const e = [];
2971
3001
  for (; ; ) {
2972
3002
  const [R, A] = $e(T, E);
@@ -3010,23 +3040,23 @@ const n = (T) => T.flatMap(Xe), Xe = (T) => IE(Ke(T)).map(ye), ye = (T) => T.rep
3010
3040
  e.push(R + A);
3011
3041
  return e;
3012
3042
  };
3013
- var a;
3043
+ var D;
3014
3044
  (function(T) {
3015
3045
  T.QUOTED_IDENTIFIER = "QUOTED_IDENTIFIER", T.IDENTIFIER = "IDENTIFIER", T.STRING = "STRING", T.VARIABLE = "VARIABLE", T.RESERVED_DATA_TYPE = "RESERVED_DATA_TYPE", T.RESERVED_PARAMETERIZED_DATA_TYPE = "RESERVED_PARAMETERIZED_DATA_TYPE", T.RESERVED_KEYWORD = "RESERVED_KEYWORD", T.RESERVED_FUNCTION_NAME = "RESERVED_FUNCTION_NAME", T.RESERVED_KEYWORD_PHRASE = "RESERVED_KEYWORD_PHRASE", T.RESERVED_DATA_TYPE_PHRASE = "RESERVED_DATA_TYPE_PHRASE", T.RESERVED_SET_OPERATION = "RESERVED_SET_OPERATION", T.RESERVED_CLAUSE = "RESERVED_CLAUSE", T.RESERVED_SELECT = "RESERVED_SELECT", T.RESERVED_JOIN = "RESERVED_JOIN", T.ARRAY_IDENTIFIER = "ARRAY_IDENTIFIER", T.ARRAY_KEYWORD = "ARRAY_KEYWORD", T.CASE = "CASE", T.END = "END", T.WHEN = "WHEN", T.ELSE = "ELSE", T.THEN = "THEN", T.LIMIT = "LIMIT", T.BETWEEN = "BETWEEN", T.AND = "AND", T.OR = "OR", T.XOR = "XOR", T.OPERATOR = "OPERATOR", T.COMMA = "COMMA", T.ASTERISK = "ASTERISK", T.PROPERTY_ACCESS_OPERATOR = "PROPERTY_ACCESS_OPERATOR", T.OPEN_PAREN = "OPEN_PAREN", T.CLOSE_PAREN = "CLOSE_PAREN", T.LINE_COMMENT = "LINE_COMMENT", T.BLOCK_COMMENT = "BLOCK_COMMENT", T.DISABLE_COMMENT = "DISABLE_COMMENT", T.NUMBER = "NUMBER", T.NAMED_PARAMETER = "NAMED_PARAMETER", T.QUOTED_PARAMETER = "QUOTED_PARAMETER", T.NUMBERED_PARAMETER = "NUMBERED_PARAMETER", T.POSITIONAL_PARAMETER = "POSITIONAL_PARAMETER", T.CUSTOM_PARAMETER = "CUSTOM_PARAMETER", T.DELIMITER = "DELIMITER", T.EOF = "EOF";
3016
- })(a = a || (a = {}));
3046
+ })(D = D || (D = {}));
3017
3047
  const Ee = (T) => ({
3018
- type: a.EOF,
3048
+ type: D.EOF,
3019
3049
  raw: "«EOF»",
3020
3050
  text: "«EOF»",
3021
3051
  start: T
3022
3052
  }), z = Ee(1 / 0), q = (T) => (E) => E.type === T.type && E.text === T.text, x = {
3023
- ARRAY: q({ text: "ARRAY", type: a.RESERVED_DATA_TYPE }),
3024
- BY: q({ text: "BY", type: a.RESERVED_KEYWORD }),
3025
- SET: q({ text: "SET", type: a.RESERVED_CLAUSE }),
3026
- STRUCT: q({ text: "STRUCT", type: a.RESERVED_DATA_TYPE }),
3027
- WINDOW: q({ text: "WINDOW", type: a.RESERVED_CLAUSE }),
3028
- VALUES: q({ text: "VALUES", type: a.RESERVED_CLAUSE })
3029
- }, Te = (T) => T === a.RESERVED_DATA_TYPE || T === a.RESERVED_KEYWORD || T === a.RESERVED_FUNCTION_NAME || T === a.RESERVED_KEYWORD_PHRASE || T === a.RESERVED_DATA_TYPE_PHRASE || T === a.RESERVED_CLAUSE || T === a.RESERVED_SELECT || T === a.RESERVED_SET_OPERATION || T === a.RESERVED_JOIN || T === a.ARRAY_KEYWORD || T === a.CASE || T === a.END || T === a.WHEN || T === a.ELSE || T === a.THEN || T === a.LIMIT || T === a.BETWEEN || T === a.AND || T === a.OR || T === a.XOR, ve = (T) => T === a.AND || T === a.OR || T === a.XOR, Qe = [
3053
+ ARRAY: q({ text: "ARRAY", type: D.RESERVED_DATA_TYPE }),
3054
+ BY: q({ text: "BY", type: D.RESERVED_KEYWORD }),
3055
+ SET: q({ text: "SET", type: D.RESERVED_CLAUSE }),
3056
+ STRUCT: q({ text: "STRUCT", type: D.RESERVED_DATA_TYPE }),
3057
+ WINDOW: q({ text: "WINDOW", type: D.RESERVED_CLAUSE }),
3058
+ VALUES: q({ text: "VALUES", type: D.RESERVED_CLAUSE })
3059
+ }, Te = (T) => T === D.RESERVED_DATA_TYPE || T === D.RESERVED_KEYWORD || T === D.RESERVED_FUNCTION_NAME || T === D.RESERVED_KEYWORD_PHRASE || T === D.RESERVED_DATA_TYPE_PHRASE || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.ARRAY_KEYWORD || T === D.CASE || T === D.END || T === D.WHEN || T === D.ELSE || T === D.THEN || T === D.LIMIT || T === D.BETWEEN || T === D.AND || T === D.OR || T === D.XOR, ve = (T) => T === D.AND || T === D.OR || T === D.XOR, Qe = [
3030
3060
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/aead_encryption_functions
3031
3061
  "KEYS.NEW_KEYSET",
3032
3062
  "KEYS.ADD_KEY_FROM_RAW_BYTES",
@@ -3703,7 +3733,7 @@ const Ee = (T) => ({
3703
3733
  "STRUCT",
3704
3734
  "TIME",
3705
3735
  "TIMEZONE"
3706
- ], je = n(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), ke = n([
3736
+ ], je = _(["SELECT [ALL | DISTINCT] [AS STRUCT | AS VALUE]"]), ke = _([
3707
3737
  // Queries: https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax
3708
3738
  "WITH [RECURSIVE]",
3709
3739
  "FROM",
@@ -3732,9 +3762,9 @@ const Ee = (T) => ({
3732
3762
  "WITH CONNECTION",
3733
3763
  "WITH PARTITION COLUMNS",
3734
3764
  "REMOTE WITH CONNECTION"
3735
- ]), nT = n([
3765
+ ]), nT = _([
3736
3766
  "CREATE [OR REPLACE] [TEMP|TEMPORARY|SNAPSHOT|EXTERNAL] TABLE [IF NOT EXISTS]"
3737
- ]), mE = n([
3767
+ ]), mE = _([
3738
3768
  // - create:
3739
3769
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
3740
3770
  "CREATE [OR REPLACE] [MATERIALIZED] VIEW [IF NOT EXISTS]",
@@ -3822,15 +3852,15 @@ const Ee = (T) => ({
3822
3852
  "ASSERT",
3823
3853
  // Other, https://cloud.google.com/bigquery/docs/reference/standard-sql/other-statements
3824
3854
  "EXPORT DATA"
3825
- ]), ze = n([
3855
+ ]), ze = _([
3826
3856
  "UNION {ALL | DISTINCT}",
3827
3857
  "EXCEPT DISTINCT",
3828
3858
  "INTERSECT DISTINCT"
3829
- ]), ER = n([
3859
+ ]), ER = _([
3830
3860
  "JOIN",
3831
3861
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
3832
3862
  "{INNER | CROSS} JOIN"
3833
- ]), TR = n([
3863
+ ]), TR = _([
3834
3864
  // https://cloud.google.com/bigquery/docs/reference/standard-sql/query-syntax#tablesample_operator
3835
3865
  "TABLESAMPLE SYSTEM",
3836
3866
  // From DDL: https://cloud.google.com/bigquery/docs/reference/standard-sql/data-definition-language
@@ -3841,7 +3871,7 @@ const Ee = (T) => ({
3841
3871
  "{ROWS | RANGE} BETWEEN",
3842
3872
  // comparison operator
3843
3873
  "IS [NOT] DISTINCT FROM"
3844
- ]), eR = n([]), RR = {
3874
+ ]), eR = _([]), RR = {
3845
3875
  name: "bigquery",
3846
3876
  tokenizerOptions: {
3847
3877
  reservedSelect: je,
@@ -3882,7 +3912,7 @@ function AR(T) {
3882
3912
  }
3883
3913
  function SR(T) {
3884
3914
  let E = z;
3885
- return T.map((e) => e.text === "OFFSET" && E.text === "[" ? (E = e, Object.assign(Object.assign({}, e), { type: a.RESERVED_FUNCTION_NAME })) : (E = e, e));
3915
+ return T.map((e) => e.text === "OFFSET" && E.text === "[" ? (E = e, Object.assign(Object.assign({}, e), { type: D.RESERVED_FUNCTION_NAME })) : (E = e, e));
3886
3916
  }
3887
3917
  function IR(T) {
3888
3918
  var E;
@@ -3890,11 +3920,11 @@ function IR(T) {
3890
3920
  for (let R = 0; R < T.length; R++) {
3891
3921
  const A = T[R];
3892
3922
  if ((x.ARRAY(A) || x.STRUCT(A)) && ((E = T[R + 1]) === null || E === void 0 ? void 0 : E.text) === "<") {
3893
- const S = NR(T, R + 1), N = T.slice(R, S + 1);
3923
+ const S = NR(T, R + 1), I = T.slice(R, S + 1);
3894
3924
  e.push({
3895
- type: a.IDENTIFIER,
3896
- raw: N.map(_T("raw")).join(""),
3897
- text: N.map(_T("text")).join(""),
3925
+ type: D.IDENTIFIER,
3926
+ raw: I.map(_T("raw")).join(""),
3927
+ text: I.map(_T("text")).join(""),
3898
3928
  start: A.start
3899
3929
  }), R = S;
3900
3930
  } else
@@ -3902,7 +3932,7 @@ function IR(T) {
3902
3932
  }
3903
3933
  return e;
3904
3934
  }
3905
- const _T = (T) => (E) => E.type === a.IDENTIFIER || E.type === a.COMMA ? E[T] + " " : E[T];
3935
+ const _T = (T) => (E) => E.type === D.IDENTIFIER || E.type === D.COMMA ? E[T] + " " : E[T];
3906
3936
  function NR(T, E) {
3907
3937
  let e = 0;
3908
3938
  for (let R = E; R < T.length; R++) {
@@ -4675,7 +4705,7 @@ const tR = [
4675
4705
  "VARBINARY",
4676
4706
  "VARCHAR",
4677
4707
  "VARGRAPHIC"
4678
- ], rR = n(["SELECT [ALL | DISTINCT]"]), LR = n([
4708
+ ], rR = _(["SELECT [ALL | DISTINCT]"]), LR = _([
4679
4709
  // queries
4680
4710
  "WITH",
4681
4711
  "FROM",
@@ -4704,9 +4734,9 @@ const tR = [
4704
4734
  "WHEN [NOT] MATCHED [THEN]",
4705
4735
  "UPDATE SET",
4706
4736
  "INSERT"
4707
- ]), iT = n([
4737
+ ]), iT = _([
4708
4738
  "CREATE [GLOBAL TEMPORARY | EXTERNAL] TABLE [IF NOT EXISTS]"
4709
- ]), HE = n([
4739
+ ]), HE = _([
4710
4740
  // - create:
4711
4741
  "CREATE [OR REPLACE] VIEW",
4712
4742
  // - update:
@@ -4909,16 +4939,16 @@ const tR = [
4909
4939
  "TRANSFER OWNERSHIP OF",
4910
4940
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}",
4911
4941
  "WHILE"
4912
- ]), nR = n(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), _R = n([
4942
+ ]), nR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), _R = _([
4913
4943
  "JOIN",
4914
4944
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
4915
4945
  "{INNER | CROSS} JOIN"
4916
- ]), iR = n([
4946
+ ]), iR = _([
4917
4947
  "ON DELETE",
4918
4948
  "ON UPDATE",
4919
4949
  "SET NULL",
4920
4950
  "{ROWS | RANGE} BETWEEN"
4921
- ]), aR = n([]), oR = {
4951
+ ]), aR = _([]), oR = {
4922
4952
  name: "db2",
4923
4953
  tokenizerOptions: {
4924
4954
  reservedSelect: rR,
@@ -5829,7 +5859,7 @@ const tR = [
5829
5859
  "VARCHAR",
5830
5860
  "VARGRAPHIC",
5831
5861
  "XML"
5832
- ], UR = n(["SELECT [ALL | DISTINCT]"]), lR = n([
5862
+ ], UR = _(["SELECT [ALL | DISTINCT]"]), lR = _([
5833
5863
  // queries
5834
5864
  "WITH [RECURSIVE]",
5835
5865
  "INTO",
@@ -5859,7 +5889,7 @@ const tR = [
5859
5889
  "INSERT",
5860
5890
  // Data definition - table
5861
5891
  "FOR SYSTEM NAME"
5862
- ]), aT = n(["CREATE [OR REPLACE] TABLE"]), dE = n([
5892
+ ]), aT = _(["CREATE [OR REPLACE] TABLE"]), dE = _([
5863
5893
  // - create:
5864
5894
  "CREATE [OR REPLACE] [RECURSIVE] VIEW",
5865
5895
  // - update:
@@ -5955,17 +5985,17 @@ const tR = [
5955
5985
  "TAG",
5956
5986
  "TRANSFER OWNERSHIP OF",
5957
5987
  "WHENEVER {NOT FOUND | SQLERROR | SQLWARNING}"
5958
- ]), cR = n(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), uR = n([
5988
+ ]), cR = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), uR = _([
5959
5989
  "JOIN",
5960
5990
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
5961
5991
  "[LEFT | RIGHT] EXCEPTION JOIN",
5962
5992
  "{INNER | CROSS} JOIN"
5963
- ]), GR = n([
5993
+ ]), GR = _([
5964
5994
  "ON DELETE",
5965
5995
  "ON UPDATE",
5966
5996
  "SET NULL",
5967
5997
  "{ROWS | RANGE} BETWEEN"
5968
- ]), mR = n([]), HR = {
5998
+ ]), mR = _([]), HR = {
5969
5999
  name: "db2i",
5970
6000
  tokenizerOptions: {
5971
6001
  reservedSelect: UR,
@@ -6818,7 +6848,7 @@ const tR = [
6818
6848
  "UUID",
6819
6849
  "VARBINARY",
6820
6850
  "VARCHAR"
6821
- ], FR = n(["SELECT [ALL | DISTINCT]"]), YR = n([
6851
+ ], FR = _(["SELECT [ALL | DISTINCT]"]), YR = _([
6822
6852
  // queries
6823
6853
  "WITH [RECURSIVE]",
6824
6854
  "FROM",
@@ -6842,9 +6872,9 @@ const tR = [
6842
6872
  "SET",
6843
6873
  // other:
6844
6874
  "RETURNING"
6845
- ]), oT = n([
6875
+ ]), oT = _([
6846
6876
  "CREATE [OR REPLACE] [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"
6847
- ]), BE = n([
6877
+ ]), BE = _([
6848
6878
  // TABLE
6849
6879
  // - update:
6850
6880
  "UPDATE",
@@ -6922,11 +6952,11 @@ const tR = [
6922
6952
  "PREPARE",
6923
6953
  "EXECUTE",
6924
6954
  "DEALLOCATE [PREPARE]"
6925
- ]), fR = n([
6955
+ ]), fR = _([
6926
6956
  "UNION [ALL | BY NAME]",
6927
6957
  "EXCEPT [ALL]",
6928
6958
  "INTERSECT [ALL]"
6929
- ]), hR = n([
6959
+ ]), hR = _([
6930
6960
  "JOIN",
6931
6961
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
6932
6962
  "{INNER | CROSS} JOIN",
@@ -6935,11 +6965,11 @@ const tR = [
6935
6965
  "POSITIONAL JOIN",
6936
6966
  "ANTI JOIN",
6937
6967
  "SEMI JOIN"
6938
- ]), VR = n([
6968
+ ]), VR = _([
6939
6969
  "{ROWS | RANGE | GROUPS} BETWEEN",
6940
6970
  "SIMILAR TO",
6941
6971
  "IS [NOT] DISTINCT FROM"
6942
- ]), WR = n(["TIMESTAMP WITH TIME ZONE"]), bR = {
6972
+ ]), WR = _(["TIMESTAMP WITH TIME ZONE"]), bR = {
6943
6973
  name: "duckdb",
6944
6974
  tokenizerOptions: {
6945
6975
  reservedSelect: FR,
@@ -7538,7 +7568,7 @@ const tR = [
7538
7568
  "JSONFILE",
7539
7569
  "INPUTFORMAT",
7540
7570
  "OUTPUTFORMAT"
7541
- ], KR = [
7571
+ ], gR = [
7542
7572
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Types
7543
7573
  "ARRAY",
7544
7574
  "BIGINT",
@@ -7559,7 +7589,7 @@ const tR = [
7559
7589
  "STRUCT",
7560
7590
  "TIMESTAMP",
7561
7591
  "VARCHAR"
7562
- ], gR = n(["SELECT [ALL | DISTINCT]"]), $R = n([
7592
+ ], KR = _(["SELECT [ALL | DISTINCT]"]), $R = _([
7563
7593
  // queries
7564
7594
  "WITH",
7565
7595
  "FROM",
@@ -7593,9 +7623,9 @@ const tR = [
7593
7623
  // https://cwiki.apache.org/confluence/display/Hive/LanguageManual+DML#LanguageManualDML-Loadingfilesintotables
7594
7624
  "LOAD DATA [LOCAL] INPATH",
7595
7625
  "[OVERWRITE] INTO TABLE"
7596
- ]), DT = n([
7626
+ ]), DT = _([
7597
7627
  "CREATE [TEMPORARY] [EXTERNAL] TABLE [IF NOT EXISTS]"
7598
- ]), pE = n([
7628
+ ]), pE = _([
7599
7629
  // - create:
7600
7630
  "CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
7601
7631
  // - update:
@@ -7620,23 +7650,23 @@ const tR = [
7620
7650
  "STORED AS",
7621
7651
  "STORED BY",
7622
7652
  "ROW FORMAT"
7623
- ]), wR = n(["UNION [ALL | DISTINCT]"]), JR = n([
7653
+ ]), wR = _(["UNION [ALL | DISTINCT]"]), JR = _([
7624
7654
  "JOIN",
7625
7655
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
7626
7656
  "{INNER | CROSS} JOIN",
7627
7657
  // non-standard joins
7628
7658
  "LEFT SEMI JOIN"
7629
- ]), xR = n(["{ROWS | RANGE} BETWEEN"]), vR = n([]), QR = {
7659
+ ]), xR = _(["{ROWS | RANGE} BETWEEN"]), vR = _([]), QR = {
7630
7660
  name: "hive",
7631
7661
  tokenizerOptions: {
7632
- reservedSelect: gR,
7662
+ reservedSelect: KR,
7633
7663
  reservedClauses: [...$R, ...DT, ...pE],
7634
7664
  reservedSetOperations: wR,
7635
7665
  reservedJoins: JR,
7636
7666
  reservedKeywordPhrases: xR,
7637
7667
  reservedDataTypePhrases: vR,
7638
7668
  reservedKeywords: yR,
7639
- reservedDataTypes: KR,
7669
+ reservedDataTypes: gR,
7640
7670
  reservedFunctionNames: XR,
7641
7671
  extraParens: ["[]"],
7642
7672
  stringTypes: ['""-bs', "''-bs"],
@@ -7653,9 +7683,9 @@ function nE(T) {
7653
7683
  return T.map((E, e) => {
7654
7684
  const R = T[e + 1] || z;
7655
7685
  if (x.SET(E) && R.text === "(")
7656
- return Object.assign(Object.assign({}, E), { type: a.RESERVED_FUNCTION_NAME });
7686
+ return Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME });
7657
7687
  const A = T[e - 1] || z;
7658
- return x.VALUES(E) && A.text === "=" ? Object.assign(Object.assign({}, E), { type: a.RESERVED_FUNCTION_NAME }) : E;
7688
+ return x.VALUES(E) && A.text === "=" ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E;
7659
7689
  });
7660
7690
  }
7661
7691
  const ZR = [
@@ -8164,7 +8194,7 @@ const ZR = [
8164
8194
  // CASE expression shorthands
8165
8195
  "COALESCE",
8166
8196
  "NULLIF"
8167
- ], kR = n(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), zR = n([
8197
+ ], kR = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), zR = _([
8168
8198
  // queries
8169
8199
  "WITH [RECURSIVE]",
8170
8200
  "FROM",
@@ -8186,9 +8216,9 @@ const ZR = [
8186
8216
  "SET",
8187
8217
  // other
8188
8218
  "RETURNING"
8189
- ]), PT = n([
8219
+ ]), PT = _([
8190
8220
  "CREATE [OR REPLACE] [TEMPORARY] TABLE [IF NOT EXISTS]"
8191
- ]), FE = n([
8221
+ ]), FE = _([
8192
8222
  // - create:
8193
8223
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
8194
8224
  // - update:
@@ -8395,12 +8425,12 @@ const ZR = [
8395
8425
  "XA RECOVER",
8396
8426
  "XA ROLLBACK",
8397
8427
  "XA START"
8398
- ]), EA = n([
8428
+ ]), EA = _([
8399
8429
  "UNION [ALL | DISTINCT]",
8400
8430
  "EXCEPT [ALL | DISTINCT]",
8401
8431
  "INTERSECT [ALL | DISTINCT]",
8402
8432
  "MINUS [ALL | DISTINCT]"
8403
- ]), TA = n([
8433
+ ]), TA = _([
8404
8434
  "JOIN",
8405
8435
  "{LEFT | RIGHT} [OUTER] JOIN",
8406
8436
  "{INNER | CROSS} JOIN",
@@ -8408,12 +8438,12 @@ const ZR = [
8408
8438
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
8409
8439
  // non-standard joins
8410
8440
  "STRAIGHT_JOIN"
8411
- ]), eA = n([
8441
+ ]), eA = _([
8412
8442
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
8413
8443
  "CHARACTER SET",
8414
8444
  "{ROWS | RANGE} BETWEEN",
8415
8445
  "IDENTIFIED BY"
8416
- ]), RA = n([]), AA = {
8446
+ ]), RA = _([]), AA = {
8417
8447
  name: "mariadb",
8418
8448
  tokenizerOptions: {
8419
8449
  reservedSelect: kR,
@@ -9170,7 +9200,7 @@ const ZR = [
9170
9200
  // 'XOR',
9171
9201
  "YEAR",
9172
9202
  "YEARWEEK"
9173
- ], OA = n(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), tA = n([
9203
+ ], OA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), tA = _([
9174
9204
  // queries
9175
9205
  "WITH [RECURSIVE]",
9176
9206
  "FROM",
@@ -9190,7 +9220,7 @@ const ZR = [
9190
9220
  "ON DUPLICATE KEY UPDATE",
9191
9221
  // - update:
9192
9222
  "SET"
9193
- ]), MT = n(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), YE = n([
9223
+ ]), MT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), YE = _([
9194
9224
  // - create:
9195
9225
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
9196
9226
  // - update:
@@ -9371,7 +9401,7 @@ const ZR = [
9371
9401
  "REPEAT",
9372
9402
  "RETURN",
9373
9403
  "WHILE"
9374
- ]), sA = n(["UNION [ALL | DISTINCT]"]), CA = n([
9404
+ ]), sA = _(["UNION [ALL | DISTINCT]"]), CA = _([
9375
9405
  "JOIN",
9376
9406
  "{LEFT | RIGHT} [OUTER] JOIN",
9377
9407
  "{INNER | CROSS} JOIN",
@@ -9379,12 +9409,12 @@ const ZR = [
9379
9409
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
9380
9410
  // non-standard joins
9381
9411
  "STRAIGHT_JOIN"
9382
- ]), rA = n([
9412
+ ]), rA = _([
9383
9413
  "ON {UPDATE | DELETE} [SET NULL]",
9384
9414
  "CHARACTER SET",
9385
9415
  "{ROWS | RANGE} BETWEEN",
9386
9416
  "IDENTIFIED BY"
9387
- ]), LA = n([]), nA = {
9417
+ ]), LA = _([]), nA = {
9388
9418
  name: "mysql",
9389
9419
  tokenizerOptions: {
9390
9420
  reservedSelect: OA,
@@ -10002,7 +10032,7 @@ const ZR = [
10002
10032
  // 'XOR',
10003
10033
  "YEAR",
10004
10034
  "YEARWEEK"
10005
- ], oA = n(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), DA = n([
10035
+ ], oA = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), DA = _([
10006
10036
  // queries
10007
10037
  "WITH [RECURSIVE]",
10008
10038
  "FROM",
@@ -10022,7 +10052,7 @@ const ZR = [
10022
10052
  "ON DUPLICATE KEY UPDATE",
10023
10053
  // - update:
10024
10054
  "SET"
10025
- ]), UT = n(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), fE = n([
10055
+ ]), UT = _(["CREATE [TEMPORARY] TABLE [IF NOT EXISTS]"]), fE = _([
10026
10056
  // https://docs.pingcap.com/tidb/stable/sql-statement-create-view
10027
10057
  "CREATE [OR REPLACE] [SQL SECURITY DEFINER | SQL SECURITY INVOKER] VIEW [IF NOT EXISTS]",
10028
10058
  // https://docs.pingcap.com/tidb/stable/sql-statement-update
@@ -10137,7 +10167,7 @@ const ZR = [
10137
10167
  "UNLOCK TABLES",
10138
10168
  // https://docs.pingcap.com/tidb/stable/sql-statement-use
10139
10169
  "USE"
10140
- ]), PA = n(["UNION [ALL | DISTINCT]"]), MA = n([
10170
+ ]), PA = _(["UNION [ALL | DISTINCT]"]), MA = _([
10141
10171
  "JOIN",
10142
10172
  "{LEFT | RIGHT} [OUTER] JOIN",
10143
10173
  "{INNER | CROSS} JOIN",
@@ -10145,12 +10175,12 @@ const ZR = [
10145
10175
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
10146
10176
  // non-standard joins
10147
10177
  "STRAIGHT_JOIN"
10148
- ]), UA = n([
10178
+ ]), UA = _([
10149
10179
  "ON {UPDATE | DELETE} [SET NULL]",
10150
10180
  "CHARACTER SET",
10151
10181
  "{ROWS | RANGE} BETWEEN",
10152
10182
  "IDENTIFIED BY"
10153
- ]), lA = n([]), cA = {
10183
+ ]), lA = _([]), cA = {
10154
10184
  name: "tidb",
10155
10185
  tokenizerOptions: {
10156
10186
  reservedSelect: oA,
@@ -10648,7 +10678,7 @@ const ZR = [
10648
10678
  // which it actually doesn't use.
10649
10679
  //
10650
10680
  // https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/datatypes.html
10651
- ], HA = n(["SELECT [ALL | DISTINCT]"]), dA = n([
10681
+ ], HA = _(["SELECT [ALL | DISTINCT]"]), dA = _([
10652
10682
  // queries
10653
10683
  "WITH",
10654
10684
  "FROM",
@@ -10675,7 +10705,7 @@ const ZR = [
10675
10705
  "NEST",
10676
10706
  "UNNEST",
10677
10707
  "RETURNING"
10678
- ]), lT = n([
10708
+ ]), lT = _([
10679
10709
  // - update:
10680
10710
  "UPDATE",
10681
10711
  // - delete:
@@ -10715,7 +10745,7 @@ const ZR = [
10715
10745
  "SET CURRENT SCHEMA",
10716
10746
  "SHOW",
10717
10747
  "USE [PRIMARY] KEYS"
10718
- ]), BA = n(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), pA = n(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), FA = n(["{ROWS | RANGE | GROUPS} BETWEEN"]), YA = n([]), fA = {
10748
+ ]), BA = _(["UNION [ALL]", "EXCEPT [ALL]", "INTERSECT [ALL]"]), pA = _(["JOIN", "{LEFT | RIGHT} [OUTER] JOIN", "INNER JOIN"]), FA = _(["{ROWS | RANGE | GROUPS} BETWEEN"]), YA = _([]), fA = {
10719
10749
  name: "n1ql",
10720
10750
  tokenizerOptions: {
10721
10751
  reservedSelect: HA,
@@ -11349,7 +11379,7 @@ const ZR = [
11349
11379
  "PRESENTNNV",
11350
11380
  "PRESENTV",
11351
11381
  "PREVIOUS"
11352
- ], bA = n(["SELECT [ALL | DISTINCT | UNIQUE]"]), XA = n([
11382
+ ], bA = _(["SELECT [ALL | DISTINCT | UNIQUE]"]), XA = _([
11353
11383
  // queries
11354
11384
  "WITH",
11355
11385
  "FROM",
@@ -11373,9 +11403,9 @@ const ZR = [
11373
11403
  "UPDATE SET",
11374
11404
  // other
11375
11405
  "RETURNING"
11376
- ]), cT = n([
11406
+ ]), cT = _([
11377
11407
  "CREATE [GLOBAL TEMPORARY | PRIVATE TEMPORARY | SHARDED | DUPLICATED | IMMUTABLE BLOCKCHAIN | BLOCKCHAIN | IMMUTABLE] TABLE"
11378
- ]), hE = n([
11408
+ ]), hE = _([
11379
11409
  // - create:
11380
11410
  "CREATE [OR REPLACE] [NO FORCE | FORCE] [EDITIONING | EDITIONABLE | EDITIONABLE EDITIONING | NONEDITIONABLE] VIEW",
11381
11411
  "CREATE MATERIALIZED VIEW",
@@ -11403,7 +11433,7 @@ const ZR = [
11403
11433
  "EXCEPTION",
11404
11434
  "LOOP",
11405
11435
  "START WITH"
11406
- ]), yA = n(["UNION [ALL]", "MINUS", "INTERSECT"]), KA = n([
11436
+ ]), yA = _(["UNION [ALL]", "MINUS", "INTERSECT"]), gA = _([
11407
11437
  "JOIN",
11408
11438
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
11409
11439
  "{INNER | CROSS} JOIN",
@@ -11411,18 +11441,18 @@ const ZR = [
11411
11441
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN",
11412
11442
  // non-standard joins
11413
11443
  "{CROSS | OUTER} APPLY"
11414
- ]), gA = n([
11444
+ ]), KA = _([
11415
11445
  "ON {UPDATE | DELETE} [SET NULL]",
11416
11446
  "ON COMMIT",
11417
11447
  "{ROWS | RANGE} BETWEEN"
11418
- ]), $A = n([]), wA = {
11448
+ ]), $A = _([]), wA = {
11419
11449
  name: "plsql",
11420
11450
  tokenizerOptions: {
11421
11451
  reservedSelect: bA,
11422
11452
  reservedClauses: [...XA, ...cT, ...hE],
11423
11453
  reservedSetOperations: yA,
11424
- reservedJoins: KA,
11425
- reservedKeywordPhrases: gA,
11454
+ reservedJoins: gA,
11455
+ reservedKeywordPhrases: KA,
11426
11456
  reservedDataTypePhrases: $A,
11427
11457
  supportsXor: !0,
11428
11458
  reservedKeywords: hA,
@@ -11462,7 +11492,7 @@ const ZR = [
11462
11492
  };
11463
11493
  function JA(T) {
11464
11494
  let E = z;
11465
- return T.map((e) => x.SET(e) && x.BY(E) ? Object.assign(Object.assign({}, e), { type: a.RESERVED_KEYWORD }) : (Te(e.type) && (E = e), e));
11495
+ return T.map((e) => x.SET(e) && x.BY(E) ? Object.assign(Object.assign({}, e), { type: D.RESERVED_KEYWORD }) : (Te(e.type) && (E = e), e));
11466
11496
  }
11467
11497
  const xA = [
11468
11498
  // https://www.postgresql.org/docs/14/functions.html
@@ -12301,7 +12331,7 @@ const xA = [
12301
12331
  "VARCHAR",
12302
12332
  "XML",
12303
12333
  "ZONE"
12304
- ], ZA = n(["SELECT [ALL | DISTINCT]"]), qA = n([
12334
+ ], ZA = _(["SELECT [ALL | DISTINCT]"]), qA = _([
12305
12335
  // queries
12306
12336
  "WITH [RECURSIVE]",
12307
12337
  "FROM",
@@ -12324,9 +12354,9 @@ const xA = [
12324
12354
  "SET",
12325
12355
  // other
12326
12356
  "RETURNING"
12327
- ]), uT = n([
12357
+ ]), uT = _([
12328
12358
  "CREATE [GLOBAL | LOCAL] [TEMPORARY | TEMP | UNLOGGED] TABLE [IF NOT EXISTS]"
12329
- ]), VE = n([
12359
+ ]), VE = _([
12330
12360
  // - create
12331
12361
  "CREATE [OR REPLACE] [TEMP | TEMPORARY] [RECURSIVE] VIEW",
12332
12362
  "CREATE [MATERIALIZED] VIEW [IF NOT EXISTS]",
@@ -12524,17 +12554,17 @@ const xA = [
12524
12554
  "START TRANSACTION",
12525
12555
  "UNLISTEN",
12526
12556
  "VACUUM"
12527
- ]), jA = n([
12557
+ ]), jA = _([
12528
12558
  "UNION [ALL | DISTINCT]",
12529
12559
  "EXCEPT [ALL | DISTINCT]",
12530
12560
  "INTERSECT [ALL | DISTINCT]"
12531
- ]), kA = n([
12561
+ ]), kA = _([
12532
12562
  "JOIN",
12533
12563
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
12534
12564
  "{INNER | CROSS} JOIN",
12535
12565
  "NATURAL [INNER] JOIN",
12536
12566
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
12537
- ]), zA = n([
12567
+ ]), zA = _([
12538
12568
  "PRIMARY KEY",
12539
12569
  "GENERATED {ALWAYS | BY DEFAULT} AS IDENTITY",
12540
12570
  "ON {UPDATE | DELETE} [NO ACTION | RESTRICT | CASCADE | SET NULL | SET DEFAULT]",
@@ -12545,7 +12575,7 @@ const xA = [
12545
12575
  "IS [NOT] DISTINCT FROM",
12546
12576
  "NULLS {FIRST | LAST}",
12547
12577
  "WITH ORDINALITY"
12548
- ]), ES = n([
12578
+ ]), ES = _([
12549
12579
  // https://www.postgresql.org/docs/current/datatype-datetime.html
12550
12580
  "[TIMESTAMP | TIME] {WITH | WITHOUT} TIME ZONE"
12551
12581
  ]), TS = {
@@ -13230,7 +13260,7 @@ const xA = [
13230
13260
  "TEXT",
13231
13261
  "VARBYTE",
13232
13262
  "VARCHAR"
13233
- ], SS = n(["SELECT [ALL | DISTINCT]"]), IS = n([
13263
+ ], SS = _(["SELECT [ALL | DISTINCT]"]), IS = _([
13234
13264
  // queries
13235
13265
  "WITH [RECURSIVE]",
13236
13266
  "FROM",
@@ -13248,9 +13278,9 @@ const xA = [
13248
13278
  "VALUES",
13249
13279
  // - update:
13250
13280
  "SET"
13251
- ]), GT = n([
13281
+ ]), GT = _([
13252
13282
  "CREATE [TEMPORARY | TEMP | LOCAL TEMPORARY | LOCAL TEMP] TABLE [IF NOT EXISTS]"
13253
- ]), WE = n([
13283
+ ]), WE = _([
13254
13284
  // - create:
13255
13285
  "CREATE [OR REPLACE | MATERIALIZED] VIEW",
13256
13286
  // - update:
@@ -13341,13 +13371,13 @@ const xA = [
13341
13371
  "START TRANSACTION",
13342
13372
  "UNLOAD",
13343
13373
  "VACUUM"
13344
- ]), NS = n(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), OS = n([
13374
+ ]), NS = _(["UNION [ALL]", "EXCEPT", "INTERSECT", "MINUS"]), OS = _([
13345
13375
  "JOIN",
13346
13376
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
13347
13377
  "{INNER | CROSS} JOIN",
13348
13378
  "NATURAL [INNER] JOIN",
13349
13379
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
13350
- ]), tS = n([
13380
+ ]), tS = _([
13351
13381
  // https://docs.aws.amazon.com/redshift/latest/dg/copy-parameters-data-conversion.html
13352
13382
  "NULL AS",
13353
13383
  // https://docs.aws.amazon.com/redshift/latest/dg/r_CREATE_EXTERNAL_SCHEMA.html
@@ -13355,7 +13385,7 @@ const xA = [
13355
13385
  "HIVE METASTORE",
13356
13386
  // in window specifications
13357
13387
  "{ROWS | RANGE} BETWEEN"
13358
- ]), sS = n([]), CS = {
13388
+ ]), sS = _([]), CS = {
13359
13389
  name: "redshift",
13360
13390
  tokenizerOptions: {
13361
13391
  reservedSelect: SS,
@@ -14011,7 +14041,7 @@ const xA = [
14011
14041
  // Shorthand functions to use in place of CASE expression
14012
14042
  "COALESCE",
14013
14043
  "NULLIF"
14014
- ], _S = n(["SELECT [ALL | DISTINCT]"]), iS = n([
14044
+ ], _S = _(["SELECT [ALL | DISTINCT]"]), iS = _([
14015
14045
  // queries
14016
14046
  "WITH",
14017
14047
  "FROM",
@@ -14036,7 +14066,7 @@ const xA = [
14036
14066
  // https://spark.apache.org/docs/latest/sql-ref-syntax-dml-load.html
14037
14067
  "LOAD DATA [LOCAL] INPATH",
14038
14068
  "[OVERWRITE] INTO TABLE"
14039
- ]), mT = n(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), bE = n([
14069
+ ]), mT = _(["CREATE [EXTERNAL] TABLE [IF NOT EXISTS]"]), bE = _([
14040
14070
  // - create:
14041
14071
  "CREATE [OR REPLACE] [GLOBAL TEMPORARY | TEMPORARY] VIEW [IF NOT EXISTS]",
14042
14072
  // - drop table:
@@ -14092,11 +14122,11 @@ const xA = [
14092
14122
  "SHOW TBLPROPERTIES",
14093
14123
  "SHOW VIEWS",
14094
14124
  "UNCACHE TABLE"
14095
- ]), aS = n([
14125
+ ]), aS = _([
14096
14126
  "UNION [ALL | DISTINCT]",
14097
14127
  "EXCEPT [ALL | DISTINCT]",
14098
14128
  "INTERSECT [ALL | DISTINCT]"
14099
- ]), oS = n([
14129
+ ]), oS = _([
14100
14130
  "JOIN",
14101
14131
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14102
14132
  "{INNER | CROSS} JOIN",
@@ -14105,12 +14135,12 @@ const xA = [
14105
14135
  // non-standard-joins
14106
14136
  "[LEFT] {ANTI | SEMI} JOIN",
14107
14137
  "NATURAL [LEFT] {ANTI | SEMI} JOIN"
14108
- ]), DS = n([
14138
+ ]), DS = _([
14109
14139
  "ON DELETE",
14110
14140
  "ON UPDATE",
14111
14141
  "CURRENT ROW",
14112
14142
  "{ROWS | RANGE} BETWEEN"
14113
- ]), PS = n([]), MS = {
14143
+ ]), PS = _([]), MS = {
14114
14144
  name: "spark",
14115
14145
  tokenizerOptions: {
14116
14146
  reservedSelect: _S,
@@ -14144,7 +14174,7 @@ const xA = [
14144
14174
  function US(T) {
14145
14175
  return T.map((E, e) => {
14146
14176
  const R = T[e - 1] || z, A = T[e + 1] || z;
14147
- return x.WINDOW(E) && A.type === a.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: a.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === a.RESERVED_KEYWORD && !(R.text === "COLLECTION" && A.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: a.IDENTIFIER, text: E.raw }) : E;
14177
+ return x.WINDOW(E) && A.type === D.OPEN_PAREN ? Object.assign(Object.assign({}, E), { type: D.RESERVED_FUNCTION_NAME }) : E.text === "ITEMS" && E.type === D.RESERVED_KEYWORD && !(R.text === "COLLECTION" && A.text === "TERMINATED") ? Object.assign(Object.assign({}, E), { type: D.IDENTIFIER, text: E.raw }) : E;
14148
14178
  });
14149
14179
  }
14150
14180
  const lS = [
@@ -14445,7 +14475,7 @@ const lS = [
14445
14475
  "TEXT",
14446
14476
  "VARCHAR",
14447
14477
  "VARYING CHARACTER"
14448
- ], GS = n(["SELECT [ALL | DISTINCT]"]), mS = n([
14478
+ ], GS = _(["SELECT [ALL | DISTINCT]"]), mS = _([
14449
14479
  // queries
14450
14480
  "WITH [RECURSIVE]",
14451
14481
  "FROM",
@@ -14466,7 +14496,7 @@ const lS = [
14466
14496
  "SET",
14467
14497
  // other:
14468
14498
  "RETURNING"
14469
- ]), HT = n(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), XE = n([
14499
+ ]), HT = _(["CREATE [TEMPORARY | TEMP] TABLE [IF NOT EXISTS]"]), XE = _([
14470
14500
  // - create:
14471
14501
  "CREATE [TEMPORARY | TEMP] VIEW [IF NOT EXISTS]",
14472
14502
  // - update:
@@ -14485,17 +14515,17 @@ const lS = [
14485
14515
  "RENAME TO",
14486
14516
  // - set schema
14487
14517
  "SET SCHEMA"
14488
- ]), HS = n(["UNION [ALL]", "EXCEPT", "INTERSECT"]), dS = n([
14518
+ ]), HS = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), dS = _([
14489
14519
  "JOIN",
14490
14520
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14491
14521
  "{INNER | CROSS} JOIN",
14492
14522
  "NATURAL [INNER] JOIN",
14493
14523
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14494
- ]), BS = n([
14524
+ ]), BS = _([
14495
14525
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14496
14526
  "{ROWS | RANGE | GROUPS} BETWEEN",
14497
14527
  "DO UPDATE"
14498
- ]), pS = n([]), FS = {
14528
+ ]), pS = _([]), FS = {
14499
14529
  name: "sqlite",
14500
14530
  tokenizerOptions: {
14501
14531
  reservedSelect: GS,
@@ -14857,7 +14887,7 @@ const lS = [
14857
14887
  "TIMESTAMP",
14858
14888
  "VARBINARY",
14859
14889
  "VARCHAR"
14860
- ], VS = n(["SELECT [ALL | DISTINCT]"]), WS = n([
14890
+ ], VS = _(["SELECT [ALL | DISTINCT]"]), WS = _([
14861
14891
  // queries
14862
14892
  "WITH [RECURSIVE]",
14863
14893
  "FROM",
@@ -14876,7 +14906,7 @@ const lS = [
14876
14906
  "VALUES",
14877
14907
  // - update:
14878
14908
  "SET"
14879
- ]), dT = n(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), yE = n([
14909
+ ]), dT = _(["CREATE [GLOBAL TEMPORARY | LOCAL TEMPORARY] TABLE"]), yE = _([
14880
14910
  // - create:
14881
14911
  "CREATE [RECURSIVE] VIEW",
14882
14912
  // - update:
@@ -14901,20 +14931,20 @@ const lS = [
14901
14931
  "TRUNCATE TABLE",
14902
14932
  // other
14903
14933
  "SET SCHEMA"
14904
- ]), bS = n([
14934
+ ]), bS = _([
14905
14935
  "UNION [ALL | DISTINCT]",
14906
14936
  "EXCEPT [ALL | DISTINCT]",
14907
14937
  "INTERSECT [ALL | DISTINCT]"
14908
- ]), XS = n([
14938
+ ]), XS = _([
14909
14939
  "JOIN",
14910
14940
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
14911
14941
  "{INNER | CROSS} JOIN",
14912
14942
  "NATURAL [INNER] JOIN",
14913
14943
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
14914
- ]), yS = n([
14944
+ ]), yS = _([
14915
14945
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
14916
14946
  "{ROWS | RANGE} BETWEEN"
14917
- ]), KS = n([]), gS = {
14947
+ ]), gS = _([]), KS = {
14918
14948
  name: "sql",
14919
14949
  tokenizerOptions: {
14920
14950
  reservedSelect: VS,
@@ -14922,7 +14952,7 @@ const lS = [
14922
14952
  reservedSetOperations: bS,
14923
14953
  reservedJoins: XS,
14924
14954
  reservedKeywordPhrases: yS,
14925
- reservedDataTypePhrases: KS,
14955
+ reservedDataTypePhrases: gS,
14926
14956
  reservedKeywords: fS,
14927
14957
  reservedDataTypes: hS,
14928
14958
  reservedFunctionNames: YS,
@@ -15648,7 +15678,7 @@ const lS = [
15648
15678
  "CODEPOINTS",
15649
15679
  "FUNCTION",
15650
15680
  "JSONPATH"
15651
- ], xS = n(["SELECT [ALL | DISTINCT]"]), vS = n([
15681
+ ], xS = _(["SELECT [ALL | DISTINCT]"]), vS = _([
15652
15682
  // queries
15653
15683
  "WITH [RECURSIVE]",
15654
15684
  "FROM",
@@ -15676,7 +15706,7 @@ const lS = [
15676
15706
  "PATTERN",
15677
15707
  "SUBSET",
15678
15708
  "DEFINE"
15679
- ]), BT = n(["CREATE TABLE [IF NOT EXISTS]"]), KE = n([
15709
+ ]), BT = _(["CREATE TABLE [IF NOT EXISTS]"]), gE = _([
15680
15710
  // - create:
15681
15711
  "CREATE [OR REPLACE] [MATERIALIZED] VIEW",
15682
15712
  // - update:
@@ -15734,25 +15764,25 @@ const lS = [
15734
15764
  "SHOW ROLE GRANTS",
15735
15765
  "SHOW FUNCTIONS",
15736
15766
  "SHOW SESSION"
15737
- ]), QS = n([
15767
+ ]), QS = _([
15738
15768
  "UNION [ALL | DISTINCT]",
15739
15769
  "EXCEPT [ALL | DISTINCT]",
15740
15770
  "INTERSECT [ALL | DISTINCT]"
15741
- ]), ZS = n([
15771
+ ]), ZS = _([
15742
15772
  "JOIN",
15743
15773
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
15744
15774
  "{INNER | CROSS} JOIN",
15745
15775
  "NATURAL [INNER] JOIN",
15746
15776
  "NATURAL {LEFT | RIGHT | FULL} [OUTER] JOIN"
15747
- ]), qS = n([
15777
+ ]), qS = _([
15748
15778
  "{ROWS | RANGE | GROUPS} BETWEEN",
15749
15779
  // comparison operator
15750
15780
  "IS [NOT] DISTINCT FROM"
15751
- ]), jS = n([]), kS = {
15781
+ ]), jS = _([]), kS = {
15752
15782
  name: "trino",
15753
15783
  tokenizerOptions: {
15754
15784
  reservedSelect: xS,
15755
- reservedClauses: [...vS, ...BT, ...KE],
15785
+ reservedClauses: [...vS, ...BT, ...gE],
15756
15786
  reservedSetOperations: QS,
15757
15787
  reservedJoins: ZS,
15758
15788
  reservedKeywordPhrases: qS,
@@ -15788,8 +15818,8 @@ const lS = [
15788
15818
  ]
15789
15819
  },
15790
15820
  formatOptions: {
15791
- onelineClauses: [...BT, ...KE],
15792
- tabularOnelineClauses: KE
15821
+ onelineClauses: [...BT, ...gE],
15822
+ tabularOnelineClauses: gE
15793
15823
  }
15794
15824
  }, zS = [
15795
15825
  // https://docs.microsoft.com/en-us/sql/t-sql/functions/functions?view=sql-server-ver15
@@ -16304,7 +16334,7 @@ const lS = [
16304
16334
  "TIMESTAMP",
16305
16335
  "VARBINARY",
16306
16336
  "VARCHAR"
16307
- ], eI = n(["SELECT [ALL | DISTINCT]"]), RI = n([
16337
+ ], eI = _(["SELECT [ALL | DISTINCT]"]), RI = _([
16308
16338
  // queries
16309
16339
  "WITH",
16310
16340
  "INTO",
@@ -16329,7 +16359,7 @@ const lS = [
16329
16359
  "MERGE [INTO]",
16330
16360
  "WHEN [NOT] MATCHED [BY TARGET | BY SOURCE] [THEN]",
16331
16361
  "UPDATE SET"
16332
- ]), pT = n(["CREATE TABLE"]), gE = n([
16362
+ ]), pT = _(["CREATE TABLE"]), KE = _([
16333
16363
  // - create:
16334
16364
  "CREATE [OR ALTER] [MATERIALIZED] VIEW",
16335
16365
  // - update:
@@ -16509,20 +16539,20 @@ const lS = [
16509
16539
  "XACT_ABORT",
16510
16540
  "XML INDEX",
16511
16541
  "XML SCHEMA COLLECTION"
16512
- ]), AI = n(["UNION [ALL]", "EXCEPT", "INTERSECT"]), SI = n([
16542
+ ]), AI = _(["UNION [ALL]", "EXCEPT", "INTERSECT"]), SI = _([
16513
16543
  "JOIN",
16514
16544
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
16515
16545
  "{INNER | CROSS} JOIN",
16516
16546
  // non-standard joins
16517
16547
  "{CROSS | OUTER} APPLY"
16518
- ]), II = n([
16548
+ ]), II = _([
16519
16549
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]",
16520
16550
  "{ROWS | RANGE} BETWEEN"
16521
- ]), NI = n([]), OI = {
16551
+ ]), NI = _([]), OI = {
16522
16552
  name: "transactsql",
16523
16553
  tokenizerOptions: {
16524
16554
  reservedSelect: eI,
16525
- reservedClauses: [...RI, ...pT, ...gE],
16555
+ reservedClauses: [...RI, ...pT, ...KE],
16526
16556
  reservedSetOperations: AI,
16527
16557
  reservedJoins: SI,
16528
16558
  reservedKeywordPhrases: II,
@@ -16559,8 +16589,8 @@ const lS = [
16559
16589
  },
16560
16590
  formatOptions: {
16561
16591
  alwaysDenseOperators: ["::"],
16562
- onelineClauses: [...pT, ...gE],
16563
- tabularOnelineClauses: gE
16592
+ onelineClauses: [...pT, ...KE],
16593
+ tabularOnelineClauses: KE
16564
16594
  }
16565
16595
  }, tI = [
16566
16596
  // List of all keywords taken from:
@@ -17104,7 +17134,7 @@ const lS = [
17104
17134
  "WEEKDAY",
17105
17135
  "WEEKOFYEAR",
17106
17136
  "YEAR"
17107
- ], rI = n(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), LI = n([
17137
+ ], rI = _(["SELECT [ALL | DISTINCT | DISTINCTROW]"]), LI = _([
17108
17138
  // queries
17109
17139
  "WITH",
17110
17140
  "FROM",
@@ -17126,9 +17156,9 @@ const lS = [
17126
17156
  // Data definition
17127
17157
  "CREATE [OR REPLACE] [TEMPORARY] PROCEDURE [IF NOT EXISTS]",
17128
17158
  "CREATE [OR REPLACE] [EXTERNAL] FUNCTION"
17129
- ]), FT = n([
17159
+ ]), FT = _([
17130
17160
  "CREATE [ROWSTORE] [REFERENCE | TEMPORARY | GLOBAL TEMPORARY] TABLE [IF NOT EXISTS]"
17131
- ]), $E = n([
17161
+ ]), $E = _([
17132
17162
  // - create:
17133
17163
  "CREATE VIEW",
17134
17164
  // - update:
@@ -17305,25 +17335,25 @@ const lS = [
17305
17335
  "REPEAT",
17306
17336
  "RETURN",
17307
17337
  "WHILE"
17308
- ]), nI = n([
17338
+ ]), nI = _([
17309
17339
  "UNION [ALL | DISTINCT]",
17310
17340
  "EXCEPT",
17311
17341
  "INTERSECT",
17312
17342
  "MINUS"
17313
- ]), _I = n([
17343
+ ]), _I = _([
17314
17344
  "JOIN",
17315
17345
  "{LEFT | RIGHT | FULL} [OUTER] JOIN",
17316
17346
  "{INNER | CROSS} JOIN",
17317
17347
  "NATURAL {LEFT | RIGHT} [OUTER] JOIN",
17318
17348
  // non-standard joins
17319
17349
  "STRAIGHT_JOIN"
17320
- ]), iI = n([
17350
+ ]), iI = _([
17321
17351
  "ON DELETE",
17322
17352
  "ON UPDATE",
17323
17353
  "CHARACTER SET",
17324
17354
  "{ROWS | RANGE} BETWEEN",
17325
17355
  "IDENTIFIED BY"
17326
- ]), aI = n([]), oI = {
17356
+ ]), aI = _([]), oI = {
17327
17357
  name: "singlestoredb",
17328
17358
  tokenizerOptions: {
17329
17359
  reservedSelect: rI,
@@ -18116,7 +18146,7 @@ const lS = [
18116
18146
  "ARRAY",
18117
18147
  "GEOGRAPHY",
18118
18148
  "GEOMETRY"
18119
- ], UI = n(["SELECT [ALL | DISTINCT]"]), lI = n([
18149
+ ], UI = _(["SELECT [ALL | DISTINCT]"]), lI = _([
18120
18150
  // queries
18121
18151
  "WITH [RECURSIVE]",
18122
18152
  "FROM",
@@ -18144,10 +18174,10 @@ const lS = [
18144
18174
  "WHEN MATCHED [AND]",
18145
18175
  "THEN {UPDATE SET | DELETE}",
18146
18176
  "WHEN NOT MATCHED THEN INSERT"
18147
- ]), YT = n([
18177
+ ]), YT = _([
18148
18178
  "CREATE [OR REPLACE] [VOLATILE] TABLE [IF NOT EXISTS]",
18149
18179
  "CREATE [OR REPLACE] [LOCAL | GLOBAL] {TEMP|TEMPORARY} TABLE [IF NOT EXISTS]"
18150
- ]), wE = n([
18180
+ ]), wE = _([
18151
18181
  // - create:
18152
18182
  "CREATE [OR REPLACE] [SECURE] [RECURSIVE] VIEW [IF NOT EXISTS]",
18153
18183
  // - update:
@@ -18388,14 +18418,14 @@ const lS = [
18388
18418
  "USE SCHEMA",
18389
18419
  "USE SECONDARY ROLES",
18390
18420
  "USE WAREHOUSE"
18391
- ]), cI = n(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), uI = n([
18421
+ ]), cI = _(["UNION [ALL]", "MINUS", "EXCEPT", "INTERSECT"]), uI = _([
18392
18422
  "[INNER] JOIN",
18393
18423
  "[NATURAL] {LEFT | RIGHT | FULL} [OUTER] JOIN",
18394
18424
  "{CROSS | NATURAL} JOIN"
18395
- ]), GI = n([
18425
+ ]), GI = _([
18396
18426
  "{ROWS | RANGE} BETWEEN",
18397
18427
  "ON {UPDATE | DELETE} [SET NULL | SET DEFAULT]"
18398
- ]), mI = n([]), HI = {
18428
+ ]), mI = _([]), HI = {
18399
18429
  name: "snowflake",
18400
18430
  tokenizerOptions: {
18401
18431
  reservedSelect: UI,
@@ -18455,7 +18485,7 @@ const lS = [
18455
18485
  singlestoredb: oI,
18456
18486
  snowflake: HI,
18457
18487
  spark: MS,
18458
- sql: gS,
18488
+ sql: KS,
18459
18489
  sqlite: FS,
18460
18490
  tidb: cA,
18461
18491
  transactsql: OI,
@@ -18465,7 +18495,7 @@ const lS = [
18465
18495
  |$)`, "uy"), hT = (T, E = []) => {
18466
18496
  const e = T === "open" ? 0 : 1, R = ["()", ...E].map((A) => A[e]);
18467
18497
  return v(R.map(X).join("|"));
18468
- }, VT = (T) => v(`${ee(T).map(X).join("|")}`), fI = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", g = (T, E = {}) => {
18498
+ }, VT = (T) => v(`${ee(T).map(X).join("|")}`), fI = ({ rest: T, dashes: E }) => T || E ? `(?![${T || ""}${E ? "-" : ""}])` : "", K = (T, E = {}) => {
18469
18499
  if (T.length === 0)
18470
18500
  return /^\b$/u;
18471
18501
  const e = fI(E), R = ee(T).map(X).join("|").replace(/ /gu, "\\s+");
@@ -18481,7 +18511,7 @@ const lS = [
18481
18511
  "[": "]",
18482
18512
  "(": ")",
18483
18513
  "{": "}"
18484
- }, E = "{left}(?:(?!{right}').)*?{right}", e = Object.entries(T).map(([N, t]) => E.replace(/{left}/g, X(N)).replace(/{right}/g, X(t))), R = X(Object.keys(T).join(""));
18514
+ }, E = "{left}(?:(?!{right}').)*?{right}", e = Object.entries(T).map(([I, t]) => E.replace(/{left}/g, X(I)).replace(/{right}/g, X(t))), R = X(Object.keys(T).join(""));
18485
18515
  return `[Qq]'(?:${String.raw`(?<tag>[^\s${R}])(?:(?!\k<tag>').)*?\k<tag>`}|${e.join("|")})'`;
18486
18516
  }, WT = {
18487
18517
  // - backtick quoted (using `` to escape)
@@ -18509,8 +18539,8 @@ const lS = [
18509
18539
  // Oracle q'' strings: q'<text>' q'|text|' ...
18510
18540
  "q''": hI()
18511
18541
  }, Re = (T) => typeof T == "string" ? WT[T] : "regex" in T ? T.regex : FI(T) + WT[T.quote], VI = (T) => v(T.map((E) => "regex" in E ? E.regex : Re(E)).join("|")), Ae = (T) => T.map(Re).join("|"), bT = (T) => v(Ae(T)), WI = (T = {}) => v(Se(T)), Se = ({ first: T, rest: E, dashes: e, allowFirstCharNumber: R } = {}) => {
18512
- const A = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", N = X(T ?? ""), t = X(E ?? ""), C = R ? `[${A}${S}${N}][${A}${S}${t}]*` : `[${A}${N}][${A}${S}${t}]*`;
18513
- return e ? pI(C) : C;
18542
+ const A = "\\p{Alphabetic}\\p{Mark}_", S = "\\p{Decimal_Number}", I = X(T ?? ""), t = X(E ?? ""), s = R ? `[${A}${S}${I}][${A}${S}${t}]*` : `[${A}${I}][${A}${S}${t}]*`;
18543
+ return e ? pI(s) : s;
18514
18544
  };
18515
18545
  function Ie(T, E) {
18516
18546
  const e = T.slice(0, E).split(/\n/);
@@ -18579,7 +18609,7 @@ If possible, please select a more specific dialect (like sqlite, postgresql, etc
18579
18609
  }
18580
18610
  }
18581
18611
  const XT = /\/\*/uy, XI = /[\s\S]/uy, yI = /\*\//uy;
18582
- class KI {
18612
+ class gI {
18583
18613
  constructor() {
18584
18614
  this.lastIndex = 0;
18585
18615
  }
@@ -18606,7 +18636,7 @@ class KI {
18606
18636
  return R && (this.lastIndex += R[0].length), R ? R[0] : null;
18607
18637
  }
18608
18638
  }
18609
- class gI {
18639
+ class KI {
18610
18640
  constructor(E, e) {
18611
18641
  this.cfg = E, this.dialectName = e, this.rulesBeforeParams = this.buildRulesBeforeParams(E), this.rulesAfterParams = this.buildRulesAfterParams(E);
18612
18642
  }
@@ -18624,126 +18654,126 @@ class gI {
18624
18654
  var e, R, A;
18625
18655
  return this.validRules([
18626
18656
  {
18627
- type: a.DISABLE_COMMENT,
18657
+ type: D.DISABLE_COMMENT,
18628
18658
  regex: /(\/\* *sql-formatter-disable *\*\/[\s\S]*?(?:\/\* *sql-formatter-enable *\*\/|$))/uy
18629
18659
  },
18630
18660
  {
18631
- type: a.BLOCK_COMMENT,
18632
- regex: E.nestedBlockComments ? new KI() : /(\/\*[^]*?\*\/)/uy
18661
+ type: D.BLOCK_COMMENT,
18662
+ regex: E.nestedBlockComments ? new gI() : /(\/\*[^]*?\*\/)/uy
18633
18663
  },
18634
18664
  {
18635
- type: a.LINE_COMMENT,
18665
+ type: D.LINE_COMMENT,
18636
18666
  regex: YI((e = E.lineCommentTypes) !== null && e !== void 0 ? e : ["--"])
18637
18667
  },
18638
18668
  {
18639
- type: a.QUOTED_IDENTIFIER,
18669
+ type: D.QUOTED_IDENTIFIER,
18640
18670
  regex: bT(E.identTypes)
18641
18671
  },
18642
18672
  {
18643
- type: a.NUMBER,
18673
+ type: D.NUMBER,
18644
18674
  regex: E.underscoresInNumbers ? /(?:0x[0-9a-fA-F_]+|0b[01_]+|(?:-\s*)?(?:[0-9_]*\.[0-9_]+|[0-9_]+(?:\.[0-9_]*)?)(?:[eE][-+]?[0-9_]+(?:\.[0-9_]+)?)?)(?![\w\p{Alphabetic}])/uy : /(?:0x[0-9a-fA-F]+|0b[01]+|(?:-\s*)?(?:[0-9]*\.[0-9]+|[0-9]+(?:\.[0-9]*)?)(?:[eE][-+]?[0-9]+(?:\.[0-9]+)?)?)(?![\w\p{Alphabetic}])/uy
18645
18675
  },
18646
18676
  // RESERVED_KEYWORD_PHRASE and RESERVED_DATA_TYPE_PHRASE is matched before all other keyword tokens
18647
18677
  // to e.g. prioritize matching "TIMESTAMP WITH TIME ZONE" phrase over "WITH" clause.
18648
18678
  {
18649
- type: a.RESERVED_KEYWORD_PHRASE,
18650
- regex: g((R = E.reservedKeywordPhrases) !== null && R !== void 0 ? R : [], E.identChars),
18679
+ type: D.RESERVED_KEYWORD_PHRASE,
18680
+ regex: K((R = E.reservedKeywordPhrases) !== null && R !== void 0 ? R : [], E.identChars),
18651
18681
  text: p
18652
18682
  },
18653
18683
  {
18654
- type: a.RESERVED_DATA_TYPE_PHRASE,
18655
- regex: g((A = E.reservedDataTypePhrases) !== null && A !== void 0 ? A : [], E.identChars),
18684
+ type: D.RESERVED_DATA_TYPE_PHRASE,
18685
+ regex: K((A = E.reservedDataTypePhrases) !== null && A !== void 0 ? A : [], E.identChars),
18656
18686
  text: p
18657
18687
  },
18658
18688
  {
18659
- type: a.CASE,
18689
+ type: D.CASE,
18660
18690
  regex: /CASE\b/iuy,
18661
18691
  text: p
18662
18692
  },
18663
18693
  {
18664
- type: a.END,
18694
+ type: D.END,
18665
18695
  regex: /END\b/iuy,
18666
18696
  text: p
18667
18697
  },
18668
18698
  {
18669
- type: a.BETWEEN,
18699
+ type: D.BETWEEN,
18670
18700
  regex: /BETWEEN\b/iuy,
18671
18701
  text: p
18672
18702
  },
18673
18703
  {
18674
- type: a.LIMIT,
18704
+ type: D.LIMIT,
18675
18705
  regex: E.reservedClauses.includes("LIMIT") ? /LIMIT\b/iuy : void 0,
18676
18706
  text: p
18677
18707
  },
18678
18708
  {
18679
- type: a.RESERVED_CLAUSE,
18680
- regex: g(E.reservedClauses, E.identChars),
18709
+ type: D.RESERVED_CLAUSE,
18710
+ regex: K(E.reservedClauses, E.identChars),
18681
18711
  text: p
18682
18712
  },
18683
18713
  {
18684
- type: a.RESERVED_SELECT,
18685
- regex: g(E.reservedSelect, E.identChars),
18714
+ type: D.RESERVED_SELECT,
18715
+ regex: K(E.reservedSelect, E.identChars),
18686
18716
  text: p
18687
18717
  },
18688
18718
  {
18689
- type: a.RESERVED_SET_OPERATION,
18690
- regex: g(E.reservedSetOperations, E.identChars),
18719
+ type: D.RESERVED_SET_OPERATION,
18720
+ regex: K(E.reservedSetOperations, E.identChars),
18691
18721
  text: p
18692
18722
  },
18693
18723
  {
18694
- type: a.WHEN,
18724
+ type: D.WHEN,
18695
18725
  regex: /WHEN\b/iuy,
18696
18726
  text: p
18697
18727
  },
18698
18728
  {
18699
- type: a.ELSE,
18729
+ type: D.ELSE,
18700
18730
  regex: /ELSE\b/iuy,
18701
18731
  text: p
18702
18732
  },
18703
18733
  {
18704
- type: a.THEN,
18734
+ type: D.THEN,
18705
18735
  regex: /THEN\b/iuy,
18706
18736
  text: p
18707
18737
  },
18708
18738
  {
18709
- type: a.RESERVED_JOIN,
18710
- regex: g(E.reservedJoins, E.identChars),
18739
+ type: D.RESERVED_JOIN,
18740
+ regex: K(E.reservedJoins, E.identChars),
18711
18741
  text: p
18712
18742
  },
18713
18743
  {
18714
- type: a.AND,
18744
+ type: D.AND,
18715
18745
  regex: /AND\b/iuy,
18716
18746
  text: p
18717
18747
  },
18718
18748
  {
18719
- type: a.OR,
18749
+ type: D.OR,
18720
18750
  regex: /OR\b/iuy,
18721
18751
  text: p
18722
18752
  },
18723
18753
  {
18724
- type: a.XOR,
18754
+ type: D.XOR,
18725
18755
  regex: E.supportsXor ? /XOR\b/iuy : void 0,
18726
18756
  text: p
18727
18757
  },
18728
18758
  ...E.operatorKeyword ? [
18729
18759
  {
18730
- type: a.OPERATOR,
18760
+ type: D.OPERATOR,
18731
18761
  regex: /OPERATOR *\([^)]+\)/iuy
18732
18762
  }
18733
18763
  ] : [],
18734
18764
  {
18735
- type: a.RESERVED_FUNCTION_NAME,
18736
- regex: g(E.reservedFunctionNames, E.identChars),
18765
+ type: D.RESERVED_FUNCTION_NAME,
18766
+ regex: K(E.reservedFunctionNames, E.identChars),
18737
18767
  text: p
18738
18768
  },
18739
18769
  {
18740
- type: a.RESERVED_DATA_TYPE,
18741
- regex: g(E.reservedDataTypes, E.identChars),
18770
+ type: D.RESERVED_DATA_TYPE,
18771
+ regex: K(E.reservedDataTypes, E.identChars),
18742
18772
  text: p
18743
18773
  },
18744
18774
  {
18745
- type: a.RESERVED_KEYWORD,
18746
- regex: g(E.reservedKeywords, E.identChars),
18775
+ type: D.RESERVED_KEYWORD,
18776
+ regex: K(E.reservedKeywords, E.identChars),
18747
18777
  text: p
18748
18778
  }
18749
18779
  ]);
@@ -18754,26 +18784,26 @@ class gI {
18754
18784
  var e, R;
18755
18785
  return this.validRules([
18756
18786
  {
18757
- type: a.VARIABLE,
18787
+ type: D.VARIABLE,
18758
18788
  regex: E.variableTypes ? VI(E.variableTypes) : void 0
18759
18789
  },
18760
- { type: a.STRING, regex: bT(E.stringTypes) },
18790
+ { type: D.STRING, regex: bT(E.stringTypes) },
18761
18791
  {
18762
- type: a.IDENTIFIER,
18792
+ type: D.IDENTIFIER,
18763
18793
  regex: WI(E.identChars)
18764
18794
  },
18765
- { type: a.DELIMITER, regex: /[;]/uy },
18766
- { type: a.COMMA, regex: /[,]/y },
18795
+ { type: D.DELIMITER, regex: /[;]/uy },
18796
+ { type: D.COMMA, regex: /[,]/y },
18767
18797
  {
18768
- type: a.OPEN_PAREN,
18798
+ type: D.OPEN_PAREN,
18769
18799
  regex: hT("open", E.extraParens)
18770
18800
  },
18771
18801
  {
18772
- type: a.CLOSE_PAREN,
18802
+ type: D.CLOSE_PAREN,
18773
18803
  regex: hT("close", E.extraParens)
18774
18804
  },
18775
18805
  {
18776
- type: a.OPERATOR,
18806
+ type: D.OPERATOR,
18777
18807
  regex: VT([
18778
18808
  // standard operators
18779
18809
  "+",
@@ -18789,9 +18819,9 @@ class gI {
18789
18819
  ...(e = E.operators) !== null && e !== void 0 ? e : []
18790
18820
  ])
18791
18821
  },
18792
- { type: a.ASTERISK, regex: /[*]/uy },
18822
+ { type: D.ASTERISK, regex: /[*]/uy },
18793
18823
  {
18794
- type: a.PROPERTY_ACCESS_OPERATOR,
18824
+ type: D.PROPERTY_ACCESS_OPERATOR,
18795
18825
  regex: VT([".", ...(R = E.propertyAccessOperators) !== null && R !== void 0 ? R : []])
18796
18826
  }
18797
18827
  ]);
@@ -18799,43 +18829,43 @@ class gI {
18799
18829
  // These rules can't be blindly cached as the paramTypesOverrides object
18800
18830
  // can differ on each invocation of the format() function.
18801
18831
  buildParamRules(E, e) {
18802
- var R, A, S, N, t;
18803
- const C = {
18832
+ var R, A, S, I, t;
18833
+ const s = {
18804
18834
  named: e?.named || ((R = E.paramTypes) === null || R === void 0 ? void 0 : R.named) || [],
18805
18835
  quoted: e?.quoted || ((A = E.paramTypes) === null || A === void 0 ? void 0 : A.quoted) || [],
18806
18836
  numbered: e?.numbered || ((S = E.paramTypes) === null || S === void 0 ? void 0 : S.numbered) || [],
18807
- positional: typeof e?.positional == "boolean" ? e.positional : (N = E.paramTypes) === null || N === void 0 ? void 0 : N.positional,
18837
+ positional: typeof e?.positional == "boolean" ? e.positional : (I = E.paramTypes) === null || I === void 0 ? void 0 : I.positional,
18808
18838
  custom: e?.custom || ((t = E.paramTypes) === null || t === void 0 ? void 0 : t.custom) || []
18809
18839
  };
18810
18840
  return this.validRules([
18811
18841
  {
18812
- type: a.NAMED_PARAMETER,
18813
- regex: xE(C.named, Se(E.paramChars || E.identChars)),
18842
+ type: D.NAMED_PARAMETER,
18843
+ regex: xE(s.named, Se(E.paramChars || E.identChars)),
18814
18844
  key: (O) => O.slice(1)
18815
18845
  },
18816
18846
  {
18817
- type: a.QUOTED_PARAMETER,
18818
- regex: xE(C.quoted, Ae(E.identTypes)),
18819
- key: (O) => (({ tokenKey: I, quoteChar: s }) => I.replace(new RegExp(X("\\" + s), "gu"), s))({
18847
+ type: D.QUOTED_PARAMETER,
18848
+ regex: xE(s.quoted, Ae(E.identTypes)),
18849
+ key: (O) => (({ tokenKey: N, quoteChar: C }) => N.replace(new RegExp(X("\\" + C), "gu"), C))({
18820
18850
  tokenKey: O.slice(2, -1),
18821
18851
  quoteChar: O.slice(-1)
18822
18852
  })
18823
18853
  },
18824
18854
  {
18825
- type: a.NUMBERED_PARAMETER,
18826
- regex: xE(C.numbered, "[0-9]+"),
18855
+ type: D.NUMBERED_PARAMETER,
18856
+ regex: xE(s.numbered, "[0-9]+"),
18827
18857
  key: (O) => O.slice(1)
18828
18858
  },
18829
18859
  {
18830
- type: a.POSITIONAL_PARAMETER,
18831
- regex: C.positional ? /[?]/y : void 0
18860
+ type: D.POSITIONAL_PARAMETER,
18861
+ regex: s.positional ? /[?]/y : void 0
18832
18862
  },
18833
- ...C.custom.map((O) => {
18834
- var I;
18863
+ ...s.custom.map((O) => {
18864
+ var N;
18835
18865
  return {
18836
- type: a.CUSTOM_PARAMETER,
18866
+ type: D.CUSTOM_PARAMETER,
18837
18867
  regex: v(O.regex),
18838
- key: (I = O.key) !== null && I !== void 0 ? I : ((s) => s)
18868
+ key: (N = O.key) !== null && N !== void 0 ? N : ((C) => C)
18839
18869
  };
18840
18870
  })
18841
18871
  ]);
@@ -18849,7 +18879,7 @@ const p = (T) => NE(T.toUpperCase()), yT = /* @__PURE__ */ new Map(), $I = (T) =
18849
18879
  let E = yT.get(T);
18850
18880
  return E || (E = wI(T), yT.set(T, E)), E;
18851
18881
  }, wI = (T) => ({
18852
- tokenizer: new gI(T.tokenizerOptions, T.name),
18882
+ tokenizer: new KI(T.tokenizerOptions, T.name),
18853
18883
  formatOptions: JI(T.formatOptions)
18854
18884
  }), JI = (T) => {
18855
18885
  var E;
@@ -18891,98 +18921,98 @@ class vI {
18891
18921
  function QI(T) {
18892
18922
  return T && T.__esModule && Object.prototype.hasOwnProperty.call(T, "default") ? T.default : T;
18893
18923
  }
18894
- var OE = { exports: {} }, ZI = OE.exports, KT;
18924
+ var OE = { exports: {} }, ZI = OE.exports, gT;
18895
18925
  function qI() {
18896
- return KT || (KT = 1, (function(T) {
18926
+ return gT || (gT = 1, (function(T) {
18897
18927
  (function(E, e) {
18898
18928
  T.exports ? T.exports = e() : E.nearley = e();
18899
18929
  })(ZI, function() {
18900
- function E(O, I, s) {
18901
- return this.id = ++E.highestId, this.name = O, this.symbols = I, this.postprocess = s, this;
18930
+ function E(O, N, C) {
18931
+ return this.id = ++E.highestId, this.name = O, this.symbols = N, this.postprocess = C, this;
18902
18932
  }
18903
18933
  E.highestId = 0, E.prototype.toString = function(O) {
18904
- var I = typeof O > "u" ? this.symbols.map(C).join(" ") : this.symbols.slice(0, O).map(C).join(" ") + " ● " + this.symbols.slice(O).map(C).join(" ");
18905
- return this.name + " → " + I;
18934
+ var N = typeof O > "u" ? this.symbols.map(s).join(" ") : this.symbols.slice(0, O).map(s).join(" ") + " ● " + this.symbols.slice(O).map(s).join(" ");
18935
+ return this.name + " → " + N;
18906
18936
  };
18907
- function e(O, I, s, r) {
18908
- this.rule = O, this.dot = I, this.reference = s, this.data = [], this.wantedBy = r, this.isComplete = this.dot === O.symbols.length;
18937
+ function e(O, N, C, L) {
18938
+ this.rule = O, this.dot = N, this.reference = C, this.data = [], this.wantedBy = L, this.isComplete = this.dot === O.symbols.length;
18909
18939
  }
18910
18940
  e.prototype.toString = function() {
18911
18941
  return "{" + this.rule.toString(this.dot) + "}, from: " + (this.reference || 0);
18912
18942
  }, e.prototype.nextState = function(O) {
18913
- var I = new e(this.rule, this.dot + 1, this.reference, this.wantedBy);
18914
- return I.left = this, I.right = O, I.isComplete && (I.data = I.build(), I.right = void 0), I;
18943
+ var N = new e(this.rule, this.dot + 1, this.reference, this.wantedBy);
18944
+ return N.left = this, N.right = O, N.isComplete && (N.data = N.build(), N.right = void 0), N;
18915
18945
  }, e.prototype.build = function() {
18916
- var O = [], I = this;
18946
+ var O = [], N = this;
18917
18947
  do
18918
- O.push(I.right.data), I = I.left;
18919
- while (I.left);
18948
+ O.push(N.right.data), N = N.left;
18949
+ while (N.left);
18920
18950
  return O.reverse(), O;
18921
18951
  }, e.prototype.finish = function() {
18922
- this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, N.fail));
18952
+ this.rule.postprocess && (this.data = this.rule.postprocess(this.data, this.reference, I.fail));
18923
18953
  };
18924
- function R(O, I) {
18925
- this.grammar = O, this.index = I, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18954
+ function R(O, N) {
18955
+ this.grammar = O, this.index = N, this.states = [], this.wants = {}, this.scannable = [], this.completed = {};
18926
18956
  }
18927
18957
  R.prototype.process = function(O) {
18928
- for (var I = this.states, s = this.wants, r = this.completed, _ = 0; _ < I.length; _++) {
18929
- var D = I[_];
18930
- if (D.isComplete) {
18931
- if (D.finish(), D.data !== N.fail) {
18932
- for (var o = D.wantedBy, u = o.length; u--; ) {
18958
+ for (var N = this.states, C = this.wants, L = this.completed, n = 0; n < N.length; n++) {
18959
+ var i = N[n];
18960
+ if (i.isComplete) {
18961
+ if (i.finish(), i.data !== I.fail) {
18962
+ for (var o = i.wantedBy, u = o.length; u--; ) {
18933
18963
  var P = o[u];
18934
- this.complete(P, D);
18964
+ this.complete(P, i);
18935
18965
  }
18936
- if (D.reference === this.index) {
18937
- var l = D.rule.name;
18938
- (this.completed[l] = this.completed[l] || []).push(D);
18966
+ if (i.reference === this.index) {
18967
+ var l = i.rule.name;
18968
+ (this.completed[l] = this.completed[l] || []).push(i);
18939
18969
  }
18940
18970
  }
18941
18971
  } else {
18942
- var l = D.rule.symbols[D.dot];
18972
+ var l = i.rule.symbols[i.dot];
18943
18973
  if (typeof l != "string") {
18944
- this.scannable.push(D);
18974
+ this.scannable.push(i);
18945
18975
  continue;
18946
18976
  }
18947
- if (s[l]) {
18948
- if (s[l].push(D), r.hasOwnProperty(l))
18949
- for (var M = r[l], u = 0; u < M.length; u++) {
18977
+ if (C[l]) {
18978
+ if (C[l].push(i), L.hasOwnProperty(l))
18979
+ for (var M = L[l], u = 0; u < M.length; u++) {
18950
18980
  var G = M[u];
18951
- this.complete(D, G);
18981
+ this.complete(i, G);
18952
18982
  }
18953
18983
  } else
18954
- s[l] = [D], this.predict(l);
18984
+ C[l] = [i], this.predict(l);
18955
18985
  }
18956
18986
  }
18957
18987
  }, R.prototype.predict = function(O) {
18958
- for (var I = this.grammar.byName[O] || [], s = 0; s < I.length; s++) {
18959
- var r = I[s], _ = this.wants[O], D = new e(r, 0, this.index, _);
18960
- this.states.push(D);
18988
+ for (var N = this.grammar.byName[O] || [], C = 0; C < N.length; C++) {
18989
+ var L = N[C], n = this.wants[O], i = new e(L, 0, this.index, n);
18990
+ this.states.push(i);
18961
18991
  }
18962
- }, R.prototype.complete = function(O, I) {
18963
- var s = O.nextState(I);
18964
- this.states.push(s);
18992
+ }, R.prototype.complete = function(O, N) {
18993
+ var C = O.nextState(N);
18994
+ this.states.push(C);
18965
18995
  };
18966
- function A(O, I) {
18967
- this.rules = O, this.start = I || this.rules[0].name;
18968
- var s = this.byName = {};
18969
- this.rules.forEach(function(r) {
18970
- s.hasOwnProperty(r.name) || (s[r.name] = []), s[r.name].push(r);
18996
+ function A(O, N) {
18997
+ this.rules = O, this.start = N || this.rules[0].name;
18998
+ var C = this.byName = {};
18999
+ this.rules.forEach(function(L) {
19000
+ C.hasOwnProperty(L.name) || (C[L.name] = []), C[L.name].push(L);
18971
19001
  });
18972
19002
  }
18973
- A.fromCompiled = function(r, I) {
18974
- var s = r.Lexer;
18975
- r.ParserStart && (I = r.ParserStart, r = r.ParserRules);
18976
- var r = r.map(function(D) {
18977
- return new E(D.name, D.symbols, D.postprocess);
18978
- }), _ = new A(r, I);
18979
- return _.lexer = s, _;
19003
+ A.fromCompiled = function(L, N) {
19004
+ var C = L.Lexer;
19005
+ L.ParserStart && (N = L.ParserStart, L = L.ParserRules);
19006
+ var L = L.map(function(i) {
19007
+ return new E(i.name, i.symbols, i.postprocess);
19008
+ }), n = new A(L, N);
19009
+ return n.lexer = C, n;
18980
19010
  };
18981
19011
  function S() {
18982
19012
  this.reset("");
18983
19013
  }
18984
- S.prototype.reset = function(O, I) {
18985
- this.buffer = O, this.index = 0, this.line = I ? I.line : 1, this.lastLineBreak = I ? -I.col : 0;
19014
+ S.prototype.reset = function(O, N) {
19015
+ this.buffer = O, this.index = 0, this.line = N ? N.line : 1, this.lastLineBreak = N ? -N.col : 0;
18986
19016
  }, S.prototype.next = function() {
18987
19017
  if (this.index < this.buffer.length) {
18988
19018
  var O = this.buffer[this.index++];
@@ -18994,144 +19024,144 @@ function qI() {
18994
19024
  line: this.line,
18995
19025
  col: this.index - this.lastLineBreak
18996
19026
  };
18997
- }, S.prototype.formatError = function(O, I) {
18998
- var s = this.buffer;
18999
- if (typeof s == "string") {
19000
- var r = s.split(`
19027
+ }, S.prototype.formatError = function(O, N) {
19028
+ var C = this.buffer;
19029
+ if (typeof C == "string") {
19030
+ var L = C.split(`
19001
19031
  `).slice(
19002
19032
  Math.max(0, this.line - 5),
19003
19033
  this.line
19004
- ), _ = s.indexOf(`
19034
+ ), n = C.indexOf(`
19005
19035
  `, this.index);
19006
- _ === -1 && (_ = s.length);
19007
- var D = this.index - this.lastLineBreak, o = String(this.line).length;
19008
- return I += " at line " + this.line + " col " + D + `:
19036
+ n === -1 && (n = C.length);
19037
+ var i = this.index - this.lastLineBreak, o = String(this.line).length;
19038
+ return N += " at line " + this.line + " col " + i + `:
19009
19039
 
19010
- `, I += r.map(function(P, l) {
19011
- return u(this.line - r.length + l + 1, o) + " " + P;
19040
+ `, N += L.map(function(P, l) {
19041
+ return u(this.line - L.length + l + 1, o) + " " + P;
19012
19042
  }, this).join(`
19013
- `), I += `
19014
- ` + u("", o + D) + `^
19015
- `, I;
19043
+ `), N += `
19044
+ ` + u("", o + i) + `^
19045
+ `, N;
19016
19046
  } else
19017
- return I + " at index " + (this.index - 1);
19047
+ return N + " at index " + (this.index - 1);
19018
19048
  function u(P, l) {
19019
19049
  var M = String(P);
19020
19050
  return Array(l - M.length + 1).join(" ") + M;
19021
19051
  }
19022
19052
  };
19023
- function N(O, I, s) {
19053
+ function I(O, N, C) {
19024
19054
  if (O instanceof A)
19025
- var r = O, s = I;
19055
+ var L = O, C = N;
19026
19056
  else
19027
- var r = A.fromCompiled(O, I);
19028
- this.grammar = r, this.options = {
19057
+ var L = A.fromCompiled(O, N);
19058
+ this.grammar = L, this.options = {
19029
19059
  keepHistory: !1,
19030
- lexer: r.lexer || new S()
19060
+ lexer: L.lexer || new S()
19031
19061
  };
19032
- for (var _ in s || {})
19033
- this.options[_] = s[_];
19062
+ for (var n in C || {})
19063
+ this.options[n] = C[n];
19034
19064
  this.lexer = this.options.lexer, this.lexerState = void 0;
19035
- var D = new R(r, 0);
19036
- this.table = [D], D.wants[r.start] = [], D.predict(r.start), D.process(), this.current = 0;
19065
+ var i = new R(L, 0);
19066
+ this.table = [i], i.wants[L.start] = [], i.predict(L.start), i.process(), this.current = 0;
19037
19067
  }
19038
- N.fail = {}, N.prototype.feed = function(O) {
19039
- var I = this.lexer;
19040
- I.reset(O, this.lexerState);
19041
- for (var s; ; ) {
19068
+ I.fail = {}, I.prototype.feed = function(O) {
19069
+ var N = this.lexer;
19070
+ N.reset(O, this.lexerState);
19071
+ for (var C; ; ) {
19042
19072
  try {
19043
- if (s = I.next(), !s)
19073
+ if (C = N.next(), !C)
19044
19074
  break;
19045
19075
  } catch (b) {
19046
19076
  var o = new R(this.grammar, this.current + 1);
19047
19077
  this.table.push(o);
19048
- var r = new Error(this.reportLexerError(b));
19049
- throw r.offset = this.current, r.token = b.token, r;
19078
+ var L = new Error(this.reportLexerError(b));
19079
+ throw L.offset = this.current, L.token = b.token, L;
19050
19080
  }
19051
- var _ = this.table[this.current];
19081
+ var n = this.table[this.current];
19052
19082
  this.options.keepHistory || delete this.table[this.current - 1];
19053
- var D = this.current + 1, o = new R(this.grammar, D);
19083
+ var i = this.current + 1, o = new R(this.grammar, i);
19054
19084
  this.table.push(o);
19055
- for (var u = s.text !== void 0 ? s.text : s.value, P = I.constructor === S ? s.value : s, l = _.scannable, M = l.length; M--; ) {
19085
+ for (var u = C.text !== void 0 ? C.text : C.value, P = N.constructor === S ? C.value : C, l = n.scannable, M = l.length; M--; ) {
19056
19086
  var G = l[M], m = G.rule.symbols[G.dot];
19057
- if (m.test ? m.test(P) : m.type ? m.type === s.type : m.literal === u) {
19058
- var B = G.nextState({ data: P, token: s, isToken: !0, reference: D - 1 });
19087
+ if (m.test ? m.test(P) : m.type ? m.type === C.type : m.literal === u) {
19088
+ var B = G.nextState({ data: P, token: C, isToken: !0, reference: i - 1 });
19059
19089
  o.states.push(B);
19060
19090
  }
19061
19091
  }
19062
19092
  if (o.process(), o.states.length === 0) {
19063
- var r = new Error(this.reportError(s));
19064
- throw r.offset = this.current, r.token = s, r;
19093
+ var L = new Error(this.reportError(C));
19094
+ throw L.offset = this.current, L.token = C, L;
19065
19095
  }
19066
- this.options.keepHistory && (_.lexerState = I.save()), this.current++;
19096
+ this.options.keepHistory && (n.lexerState = N.save()), this.current++;
19067
19097
  }
19068
- return _ && (this.lexerState = I.save()), this.results = this.finish(), this;
19069
- }, N.prototype.reportLexerError = function(O) {
19070
- var I, s, r = O.token;
19071
- return r ? (I = "input " + JSON.stringify(r.text[0]) + " (lexer error)", s = this.lexer.formatError(r, "Syntax error")) : (I = "input (lexer error)", s = O.message), this.reportErrorCommon(s, I);
19072
- }, N.prototype.reportError = function(O) {
19073
- var I = (O.type ? O.type + " token: " : "") + JSON.stringify(O.value !== void 0 ? O.value : O), s = this.lexer.formatError(O, "Syntax error");
19074
- return this.reportErrorCommon(s, I);
19075
- }, N.prototype.reportErrorCommon = function(O, I) {
19076
- var s = [];
19077
- s.push(O);
19078
- var r = this.table.length - 2, _ = this.table[r], D = _.states.filter(function(u) {
19098
+ return n && (this.lexerState = N.save()), this.results = this.finish(), this;
19099
+ }, I.prototype.reportLexerError = function(O) {
19100
+ var N, C, L = O.token;
19101
+ return L ? (N = "input " + JSON.stringify(L.text[0]) + " (lexer error)", C = this.lexer.formatError(L, "Syntax error")) : (N = "input (lexer error)", C = O.message), this.reportErrorCommon(C, N);
19102
+ }, I.prototype.reportError = function(O) {
19103
+ var N = (O.type ? O.type + " token: " : "") + JSON.stringify(O.value !== void 0 ? O.value : O), C = this.lexer.formatError(O, "Syntax error");
19104
+ return this.reportErrorCommon(C, N);
19105
+ }, I.prototype.reportErrorCommon = function(O, N) {
19106
+ var C = [];
19107
+ C.push(O);
19108
+ var L = this.table.length - 2, n = this.table[L], i = n.states.filter(function(u) {
19079
19109
  var P = u.rule.symbols[u.dot];
19080
19110
  return P && typeof P != "string";
19081
19111
  });
19082
- if (D.length === 0)
19083
- s.push("Unexpected " + I + `. I did not expect any more input. Here is the state of my parse table:
19084
- `), this.displayStateStack(_.states, s);
19112
+ if (i.length === 0)
19113
+ C.push("Unexpected " + N + `. I did not expect any more input. Here is the state of my parse table:
19114
+ `), this.displayStateStack(n.states, C);
19085
19115
  else {
19086
- s.push("Unexpected " + I + `. Instead, I was expecting to see one of the following:
19116
+ C.push("Unexpected " + N + `. Instead, I was expecting to see one of the following:
19087
19117
  `);
19088
- var o = D.map(function(u) {
19118
+ var o = i.map(function(u) {
19089
19119
  return this.buildFirstStateStack(u, []) || [u];
19090
19120
  }, this);
19091
19121
  o.forEach(function(u) {
19092
19122
  var P = u[0], l = P.rule.symbols[P.dot], M = this.getSymbolDisplay(l);
19093
- s.push("A " + M + " based on:"), this.displayStateStack(u, s);
19123
+ C.push("A " + M + " based on:"), this.displayStateStack(u, C);
19094
19124
  }, this);
19095
19125
  }
19096
- return s.push(""), s.join(`
19126
+ return C.push(""), C.join(`
19097
19127
  `);
19098
- }, N.prototype.displayStateStack = function(O, I) {
19099
- for (var s, r = 0, _ = 0; _ < O.length; _++) {
19100
- var D = O[_], o = D.rule.toString(D.dot);
19101
- o === s ? r++ : (r > 0 && I.push(" ^ " + r + " more lines identical to this"), r = 0, I.push(" " + o)), s = o;
19128
+ }, I.prototype.displayStateStack = function(O, N) {
19129
+ for (var C, L = 0, n = 0; n < O.length; n++) {
19130
+ var i = O[n], o = i.rule.toString(i.dot);
19131
+ o === C ? L++ : (L > 0 && N.push(" ^ " + L + " more lines identical to this"), L = 0, N.push(" " + o)), C = o;
19102
19132
  }
19103
- }, N.prototype.getSymbolDisplay = function(O) {
19133
+ }, I.prototype.getSymbolDisplay = function(O) {
19104
19134
  return t(O);
19105
- }, N.prototype.buildFirstStateStack = function(O, I) {
19106
- if (I.indexOf(O) !== -1)
19135
+ }, I.prototype.buildFirstStateStack = function(O, N) {
19136
+ if (N.indexOf(O) !== -1)
19107
19137
  return null;
19108
19138
  if (O.wantedBy.length === 0)
19109
19139
  return [O];
19110
- var s = O.wantedBy[0], r = [O].concat(I), _ = this.buildFirstStateStack(s, r);
19111
- return _ === null ? null : [O].concat(_);
19112
- }, N.prototype.save = function() {
19140
+ var C = O.wantedBy[0], L = [O].concat(N), n = this.buildFirstStateStack(C, L);
19141
+ return n === null ? null : [O].concat(n);
19142
+ }, I.prototype.save = function() {
19113
19143
  var O = this.table[this.current];
19114
19144
  return O.lexerState = this.lexerState, O;
19115
- }, N.prototype.restore = function(O) {
19116
- var I = O.index;
19117
- this.current = I, this.table[I] = O, this.table.splice(I + 1), this.lexerState = O.lexerState, this.results = this.finish();
19118
- }, N.prototype.rewind = function(O) {
19145
+ }, I.prototype.restore = function(O) {
19146
+ var N = O.index;
19147
+ this.current = N, this.table[N] = O, this.table.splice(N + 1), this.lexerState = O.lexerState, this.results = this.finish();
19148
+ }, I.prototype.rewind = function(O) {
19119
19149
  if (!this.options.keepHistory)
19120
19150
  throw new Error("set option `keepHistory` to enable rewinding");
19121
19151
  this.restore(this.table[O]);
19122
- }, N.prototype.finish = function() {
19123
- var O = [], I = this.grammar.start, s = this.table[this.table.length - 1];
19124
- return s.states.forEach(function(r) {
19125
- r.rule.name === I && r.dot === r.rule.symbols.length && r.reference === 0 && r.data !== N.fail && O.push(r);
19126
- }), O.map(function(r) {
19127
- return r.data;
19152
+ }, I.prototype.finish = function() {
19153
+ var O = [], N = this.grammar.start, C = this.table[this.table.length - 1];
19154
+ return C.states.forEach(function(L) {
19155
+ L.rule.name === N && L.dot === L.rule.symbols.length && L.reference === 0 && L.data !== I.fail && O.push(L);
19156
+ }), O.map(function(L) {
19157
+ return L.data;
19128
19158
  });
19129
19159
  };
19130
19160
  function t(O) {
19131
- var I = typeof O;
19132
- if (I === "string")
19161
+ var N = typeof O;
19162
+ if (N === "string")
19133
19163
  return O;
19134
- if (I === "object") {
19164
+ if (N === "object") {
19135
19165
  if (O.literal)
19136
19166
  return JSON.stringify(O.literal);
19137
19167
  if (O instanceof RegExp)
@@ -19143,11 +19173,11 @@ function qI() {
19143
19173
  throw new Error("Unknown symbol type: " + O);
19144
19174
  }
19145
19175
  }
19146
- function C(O) {
19147
- var I = typeof O;
19148
- if (I === "string")
19176
+ function s(O) {
19177
+ var N = typeof O;
19178
+ if (N === "string")
19149
19179
  return O;
19150
- if (I === "object") {
19180
+ if (N === "object") {
19151
19181
  if (O.literal)
19152
19182
  return JSON.stringify(O.literal);
19153
19183
  if (O instanceof RegExp)
@@ -19160,7 +19190,7 @@ function qI() {
19160
19190
  }
19161
19191
  }
19162
19192
  return {
19163
- Parser: N,
19193
+ Parser: I,
19164
19194
  Grammar: A,
19165
19195
  Rule: E
19166
19196
  };
@@ -19175,39 +19205,39 @@ function zI(T) {
19175
19205
  const EN = (T, E, e) => {
19176
19206
  if (Te(T.type)) {
19177
19207
  const R = SN(e, E);
19178
- if (R && R.type === a.PROPERTY_ACCESS_OPERATOR)
19179
- return Object.assign(Object.assign({}, T), { type: a.IDENTIFIER, text: T.raw });
19208
+ if (R && R.type === D.PROPERTY_ACCESS_OPERATOR)
19209
+ return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
19180
19210
  const A = EE(e, E);
19181
- if (A && A.type === a.PROPERTY_ACCESS_OPERATOR)
19182
- return Object.assign(Object.assign({}, T), { type: a.IDENTIFIER, text: T.raw });
19211
+ if (A && A.type === D.PROPERTY_ACCESS_OPERATOR)
19212
+ return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
19183
19213
  }
19184
19214
  return T;
19185
19215
  }, TN = (T, E, e) => {
19186
- if (T.type === a.RESERVED_FUNCTION_NAME) {
19216
+ if (T.type === D.RESERVED_FUNCTION_NAME) {
19187
19217
  const R = EE(e, E);
19188
19218
  if (!R || !Ne(R))
19189
- return Object.assign(Object.assign({}, T), { type: a.IDENTIFIER, text: T.raw });
19219
+ return Object.assign(Object.assign({}, T), { type: D.IDENTIFIER, text: T.raw });
19190
19220
  }
19191
19221
  return T;
19192
19222
  }, eN = (T, E, e) => {
19193
- if (T.type === a.RESERVED_DATA_TYPE) {
19223
+ if (T.type === D.RESERVED_DATA_TYPE) {
19194
19224
  const R = EE(e, E);
19195
19225
  if (R && Ne(R))
19196
- return Object.assign(Object.assign({}, T), { type: a.RESERVED_PARAMETERIZED_DATA_TYPE });
19226
+ return Object.assign(Object.assign({}, T), { type: D.RESERVED_PARAMETERIZED_DATA_TYPE });
19197
19227
  }
19198
19228
  return T;
19199
19229
  }, RN = (T, E, e) => {
19200
- if (T.type === a.IDENTIFIER) {
19230
+ if (T.type === D.IDENTIFIER) {
19201
19231
  const R = EE(e, E);
19202
19232
  if (R && Oe(R))
19203
- return Object.assign(Object.assign({}, T), { type: a.ARRAY_IDENTIFIER });
19233
+ return Object.assign(Object.assign({}, T), { type: D.ARRAY_IDENTIFIER });
19204
19234
  }
19205
19235
  return T;
19206
19236
  }, AN = (T, E, e) => {
19207
- if (T.type === a.RESERVED_DATA_TYPE) {
19237
+ if (T.type === D.RESERVED_DATA_TYPE) {
19208
19238
  const R = EE(e, E);
19209
19239
  if (R && Oe(R))
19210
- return Object.assign(Object.assign({}, T), { type: a.ARRAY_KEYWORD });
19240
+ return Object.assign(Object.assign({}, T), { type: D.ARRAY_KEYWORD });
19211
19241
  }
19212
19242
  return T;
19213
19243
  }, SN = (T, E) => EE(T, E, -1), EE = (T, E, e = 1) => {
@@ -19215,7 +19245,7 @@ const EN = (T, E, e) => {
19215
19245
  for (; T[E + R * e] && IN(T[E + R * e]); )
19216
19246
  R++;
19217
19247
  return T[E + R * e];
19218
- }, Ne = (T) => T.type === a.OPEN_PAREN && T.text === "(", Oe = (T) => T.type === a.OPEN_PAREN && T.text === "[", IN = (T) => T.type === a.BLOCK_COMMENT || T.type === a.LINE_COMMENT;
19248
+ }, Ne = (T) => T.type === D.OPEN_PAREN && T.text === "(", Oe = (T) => T.type === D.OPEN_PAREN && T.text === "[", IN = (T) => T.type === D.BLOCK_COMMENT || T.type === D.LINE_COMMENT;
19219
19249
  class te {
19220
19250
  constructor(E) {
19221
19251
  this.tokenize = E, this.index = 0, this.tokens = [], this.input = "";
@@ -19233,7 +19263,7 @@ class te {
19233
19263
  return `Parse error at token: ${E.text} at line ${e} column ${R}`;
19234
19264
  }
19235
19265
  has(E) {
19236
- return E in a;
19266
+ return E in D;
19237
19267
  }
19238
19268
  }
19239
19269
  var U;
@@ -19248,7 +19278,7 @@ const c = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
19248
19278
  tokenType: T.type,
19249
19279
  text: T.text,
19250
19280
  raw: T.raw
19251
- }), gT = (T) => ({
19281
+ }), KT = (T) => ({
19252
19282
  type: U.data_type,
19253
19283
  text: T.text,
19254
19284
  raw: T.raw
@@ -19283,7 +19313,7 @@ const c = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
19283
19313
  postprocess: ([T, [E]]) => ({
19284
19314
  type: U.statement,
19285
19315
  children: T,
19286
- hasSemicolon: E.type === a.DELIMITER
19316
+ hasSemicolon: E.type === D.DELIMITER
19287
19317
  })
19288
19318
  },
19289
19319
  { name: "expressions_or_clauses$ebnf$1", symbols: [] },
@@ -19524,12 +19554,12 @@ const c = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
19524
19554
  {
19525
19555
  name: "between_predicate",
19526
19556
  symbols: [c.has("BETWEEN") ? { type: "BETWEEN" } : BETWEEN, "_", "andless_expression_chain", "_", c.has("AND") ? { type: "AND" } : AND, "_", "andless_expression"],
19527
- postprocess: ([T, E, e, R, A, S, N]) => ({
19557
+ postprocess: ([T, E, e, R, A, S, I]) => ({
19528
19558
  type: U.between_predicate,
19529
19559
  betweenKw: F(T),
19530
19560
  expr1: NN(e, { leading: E, trailing: R }),
19531
19561
  andKw: F(A),
19532
- expr2: [Y(N, { leading: S })]
19562
+ expr2: [Y(I, { leading: S })]
19533
19563
  })
19534
19564
  },
19535
19565
  { name: "case_expression$ebnf$1", symbols: ["expression_chain_"], postprocess: vE },
@@ -19599,14 +19629,14 @@ const c = new te((T) => []), $ = ([[T]]) => T, F = (T) => ({
19599
19629
  {
19600
19630
  name: "data_type",
19601
19631
  symbols: ["data_type$subexpression$1"],
19602
- postprocess: ([[T]]) => gT(T)
19632
+ postprocess: ([[T]]) => KT(T)
19603
19633
  },
19604
19634
  {
19605
19635
  name: "data_type",
19606
19636
  symbols: [c.has("RESERVED_PARAMETERIZED_DATA_TYPE") ? { type: "RESERVED_PARAMETERIZED_DATA_TYPE" } : RESERVED_PARAMETERIZED_DATA_TYPE, "_", "parenthesis"],
19607
19637
  postprocess: ([T, E, e]) => ({
19608
19638
  type: U.parameterized_data_type,
19609
- dataType: Y(gT(T), { trailing: E }),
19639
+ dataType: Y(KT(T), { trailing: E }),
19610
19640
  parenthesis: e
19611
19641
  })
19612
19642
  },
@@ -19669,18 +19699,18 @@ function CN(T) {
19669
19699
  return {
19670
19700
  parse: (A, S) => {
19671
19701
  E = S;
19672
- const { results: N } = R.feed(A);
19673
- if (N.length === 1)
19674
- return N[0];
19675
- throw N.length === 0 ? new Error("Parse error: Invalid SQL") : new Error(`Parse error: Ambiguous grammar
19676
- ${JSON.stringify(N, void 0, 2)}`);
19702
+ const { results: I } = R.feed(A);
19703
+ if (I.length === 1)
19704
+ return I[0];
19705
+ throw I.length === 0 ? new Error("Parse error: Invalid SQL") : new Error(`Parse error: Ambiguous grammar
19706
+ ${JSON.stringify(I, void 0, 2)}`);
19677
19707
  }
19678
19708
  };
19679
19709
  }
19680
- var i;
19710
+ var a;
19681
19711
  (function(T) {
19682
19712
  T[T.SPACE = 0] = "SPACE", T[T.NO_SPACE = 1] = "NO_SPACE", T[T.NO_NEWLINE = 2] = "NO_NEWLINE", T[T.NEWLINE = 3] = "NEWLINE", T[T.MANDATORY_NEWLINE = 4] = "MANDATORY_NEWLINE", T[T.INDENT = 5] = "INDENT", T[T.SINGLE_INDENT = 6] = "SINGLE_INDENT";
19683
- })(i = i || (i = {}));
19713
+ })(a = a || (a = {}));
19684
19714
  class se {
19685
19715
  constructor(E) {
19686
19716
  this.indentation = E, this.items = [];
@@ -19691,26 +19721,26 @@ class se {
19691
19721
  add(...E) {
19692
19722
  for (const e of E)
19693
19723
  switch (e) {
19694
- case i.SPACE:
19695
- this.items.push(i.SPACE);
19724
+ case a.SPACE:
19725
+ this.items.push(a.SPACE);
19696
19726
  break;
19697
- case i.NO_SPACE:
19727
+ case a.NO_SPACE:
19698
19728
  this.trimHorizontalWhitespace();
19699
19729
  break;
19700
- case i.NO_NEWLINE:
19730
+ case a.NO_NEWLINE:
19701
19731
  this.trimWhitespace();
19702
19732
  break;
19703
- case i.NEWLINE:
19704
- this.trimHorizontalWhitespace(), this.addNewline(i.NEWLINE);
19733
+ case a.NEWLINE:
19734
+ this.trimHorizontalWhitespace(), this.addNewline(a.NEWLINE);
19705
19735
  break;
19706
- case i.MANDATORY_NEWLINE:
19707
- this.trimHorizontalWhitespace(), this.addNewline(i.MANDATORY_NEWLINE);
19736
+ case a.MANDATORY_NEWLINE:
19737
+ this.trimHorizontalWhitespace(), this.addNewline(a.MANDATORY_NEWLINE);
19708
19738
  break;
19709
- case i.INDENT:
19739
+ case a.INDENT:
19710
19740
  this.addIndentation();
19711
19741
  break;
19712
- case i.SINGLE_INDENT:
19713
- this.items.push(i.SINGLE_INDENT);
19742
+ case a.SINGLE_INDENT:
19743
+ this.items.push(a.SINGLE_INDENT);
19714
19744
  break;
19715
19745
  default:
19716
19746
  this.items.push(e);
@@ -19727,10 +19757,10 @@ class se {
19727
19757
  addNewline(E) {
19728
19758
  if (this.items.length > 0)
19729
19759
  switch (eE(this.items)) {
19730
- case i.NEWLINE:
19760
+ case a.NEWLINE:
19731
19761
  this.items.pop(), this.items.push(E);
19732
19762
  break;
19733
- case i.MANDATORY_NEWLINE:
19763
+ case a.MANDATORY_NEWLINE:
19734
19764
  break;
19735
19765
  default:
19736
19766
  this.items.push(E);
@@ -19739,7 +19769,7 @@ class se {
19739
19769
  }
19740
19770
  addIndentation() {
19741
19771
  for (let E = 0; E < this.indentation.getLevel(); E++)
19742
- this.items.push(i.SINGLE_INDENT);
19772
+ this.items.push(a.SINGLE_INDENT);
19743
19773
  }
19744
19774
  /**
19745
19775
  * Returns the final SQL string.
@@ -19755,20 +19785,20 @@ class se {
19755
19785
  }
19756
19786
  itemToString(E) {
19757
19787
  switch (E) {
19758
- case i.SPACE:
19788
+ case a.SPACE:
19759
19789
  return " ";
19760
- case i.NEWLINE:
19761
- case i.MANDATORY_NEWLINE:
19790
+ case a.NEWLINE:
19791
+ case a.MANDATORY_NEWLINE:
19762
19792
  return `
19763
19793
  `;
19764
- case i.SINGLE_INDENT:
19794
+ case a.SINGLE_INDENT:
19765
19795
  return this.indentation.getSingleIndent();
19766
19796
  default:
19767
19797
  return E;
19768
19798
  }
19769
19799
  }
19770
19800
  }
19771
- const rN = (T) => T === i.SPACE || T === i.SINGLE_INDENT, LN = (T) => T === i.SPACE || T === i.SINGLE_INDENT || T === i.NEWLINE;
19801
+ const rN = (T) => T === a.SPACE || T === a.SINGLE_INDENT, LN = (T) => T === a.SPACE || T === a.SINGLE_INDENT || T === a.NEWLINE;
19772
19802
  function $T(T, E) {
19773
19803
  if (E === "standard")
19774
19804
  return T;
@@ -19776,7 +19806,7 @@ function $T(T, E) {
19776
19806
  return T.length >= 10 && T.includes(" ") && ([T, ...e] = T.split(" ")), E === "tabularLeft" ? T = T.padEnd(9, " ") : T = T.padStart(9, " "), T + ["", ...e].join(" ");
19777
19807
  }
19778
19808
  function wT(T) {
19779
- return ve(T) || T === a.RESERVED_CLAUSE || T === a.RESERVED_SELECT || T === a.RESERVED_SET_OPERATION || T === a.RESERVED_JOIN || T === a.LIMIT;
19809
+ return ve(T) || T === D.RESERVED_CLAUSE || T === D.RESERVED_SELECT || T === D.RESERVED_SET_OPERATION || T === D.RESERVED_JOIN || T === D.LIMIT;
19780
19810
  }
19781
19811
  const QE = "top-level", nN = "block-level";
19782
19812
  class Ce {
@@ -19840,9 +19870,9 @@ class _N extends se {
19840
19870
  if (typeof E == "string")
19841
19871
  this.length += E.length, this.trailingSpace = !1;
19842
19872
  else {
19843
- if (E === i.MANDATORY_NEWLINE || E === i.NEWLINE)
19873
+ if (E === a.MANDATORY_NEWLINE || E === a.NEWLINE)
19844
19874
  throw new qE();
19845
- E === i.INDENT || E === i.SINGLE_INDENT || E === i.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (E === i.NO_NEWLINE || E === i.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
19875
+ E === a.INDENT || E === a.SINGLE_INDENT || E === a.SPACE ? this.trailingSpace || (this.length++, this.trailingSpace = !0) : (E === a.NO_NEWLINE || E === a.NO_SPACE) && this.trailingSpace && (this.trailingSpace = !1, this.length--);
19846
19876
  }
19847
19877
  }
19848
19878
  }
@@ -19938,23 +19968,23 @@ class LE {
19938
19968
  }), this.formatNode(E.parenthesis);
19939
19969
  }
19940
19970
  formatPropertyAccess(E) {
19941
- this.formatNode(E.object), this.layout.add(i.NO_SPACE, E.operator), this.formatNode(E.property);
19971
+ this.formatNode(E.object), this.layout.add(a.NO_SPACE, E.operator), this.formatNode(E.property);
19942
19972
  }
19943
19973
  formatParenthesis(E) {
19944
19974
  const e = this.formatInlineExpression(E.children);
19945
- e ? (this.layout.add(E.openParen), this.layout.add(...e.getLayoutItems()), this.layout.add(i.NO_SPACE, E.closeParen, i.SPACE)) : (this.layout.add(E.openParen, i.NEWLINE), j(this.cfg) ? (this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(i.NEWLINE, i.INDENT, E.closeParen, i.SPACE));
19975
+ e ? (this.layout.add(E.openParen), this.layout.add(...e.getLayoutItems()), this.layout.add(a.NO_SPACE, E.closeParen, a.SPACE)) : (this.layout.add(E.openParen, a.NEWLINE), j(this.cfg) ? (this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children)) : (this.layout.indentation.increaseBlockLevel(), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseBlockLevel()), this.layout.add(a.NEWLINE, a.INDENT, E.closeParen, a.SPACE));
19946
19976
  }
19947
19977
  formatBetweenPredicate(E) {
19948
- this.layout.add(this.showKw(E.betweenKw), i.SPACE), this.layout = this.formatSubExpression(E.expr1), this.layout.add(i.NO_SPACE, i.SPACE, this.showNonTabularKw(E.andKw), i.SPACE), this.layout = this.formatSubExpression(E.expr2), this.layout.add(i.SPACE);
19978
+ this.layout.add(this.showKw(E.betweenKw), a.SPACE), this.layout = this.formatSubExpression(E.expr1), this.layout.add(a.NO_SPACE, a.SPACE, this.showNonTabularKw(E.andKw), a.SPACE), this.layout = this.formatSubExpression(E.expr2), this.layout.add(a.SPACE);
19949
19979
  }
19950
19980
  formatCaseExpression(E) {
19951
- 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(i.NEWLINE, i.INDENT), this.formatNode(E.endKw);
19981
+ 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(a.NEWLINE, a.INDENT), this.formatNode(E.endKw);
19952
19982
  }
19953
19983
  formatCaseWhen(E) {
19954
- this.layout.add(i.NEWLINE, i.INDENT), this.formatNode(E.whenKw), this.layout = this.formatSubExpression(E.condition), this.formatNode(E.thenKw), this.layout = this.formatSubExpression(E.result);
19984
+ this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.whenKw), this.layout = this.formatSubExpression(E.condition), this.formatNode(E.thenKw), this.layout = this.formatSubExpression(E.result);
19955
19985
  }
19956
19986
  formatCaseElse(E) {
19957
- this.layout.add(i.NEWLINE, i.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
19987
+ this.layout.add(a.NEWLINE, a.INDENT), this.formatNode(E.elseKw), this.layout = this.formatSubExpression(E.result);
19958
19988
  }
19959
19989
  formatClause(E) {
19960
19990
  this.isOnelineClause(E) ? this.formatClauseInOnelineStyle(E) : j(this.cfg) ? this.formatClauseInTabularStyle(E) : this.formatClauseInIndentedStyle(E);
@@ -19963,39 +19993,39 @@ class LE {
19963
19993
  return j(this.cfg) ? this.dialectCfg.tabularOnelineClauses[E.nameKw.text] : this.dialectCfg.onelineClauses[E.nameKw.text];
19964
19994
  }
19965
19995
  formatClauseInIndentedStyle(E) {
19966
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19996
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.NEWLINE), this.layout.indentation.increaseTopLevel(), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19967
19997
  }
19968
19998
  formatClauseInOnelineStyle(E) {
19969
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.SPACE), this.layout = this.formatSubExpression(E.children);
19999
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.SPACE), this.layout = this.formatSubExpression(E.children);
19970
20000
  }
19971
20001
  formatClauseInTabularStyle(E) {
19972
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
20002
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.SPACE), this.layout.indentation.increaseTopLevel(), this.layout = this.formatSubExpression(E.children), this.layout.indentation.decreaseTopLevel();
19973
20003
  }
19974
20004
  formatSetOperation(E) {
19975
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.nameKw), i.NEWLINE), this.layout.add(i.INDENT), this.layout = this.formatSubExpression(E.children);
20005
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.nameKw), a.NEWLINE), this.layout.add(a.INDENT), this.layout = this.formatSubExpression(E.children);
19976
20006
  }
19977
20007
  formatLimitClause(E) {
19978
20008
  this.withComments(E.limitKw, () => {
19979
- this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E.limitKw));
19980
- }), this.layout.indentation.increaseTopLevel(), j(this.cfg) ? this.layout.add(i.SPACE) : this.layout.add(i.NEWLINE, i.INDENT), E.offset ? (this.layout = this.formatSubExpression(E.offset), this.layout.add(i.NO_SPACE, ",", i.SPACE), this.layout = this.formatSubExpression(E.count)) : this.layout = this.formatSubExpression(E.count), this.layout.indentation.decreaseTopLevel();
20009
+ this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E.limitKw));
20010
+ }), this.layout.indentation.increaseTopLevel(), j(this.cfg) ? this.layout.add(a.SPACE) : this.layout.add(a.NEWLINE, a.INDENT), E.offset ? (this.layout = this.formatSubExpression(E.offset), this.layout.add(a.NO_SPACE, ",", a.SPACE), this.layout = this.formatSubExpression(E.count)) : this.layout = this.formatSubExpression(E.count), this.layout.indentation.decreaseTopLevel();
19981
20011
  }
19982
20012
  formatAllColumnsAsterisk(E) {
19983
- this.layout.add("*", i.SPACE);
20013
+ this.layout.add("*", a.SPACE);
19984
20014
  }
19985
20015
  formatLiteral(E) {
19986
- this.layout.add(E.text, i.SPACE);
20016
+ this.layout.add(E.text, a.SPACE);
19987
20017
  }
19988
20018
  formatIdentifier(E) {
19989
- this.layout.add(this.showIdentifier(E), i.SPACE);
20019
+ this.layout.add(this.showIdentifier(E), a.SPACE);
19990
20020
  }
19991
20021
  formatParameter(E) {
19992
- this.layout.add(this.params.get(E), i.SPACE);
20022
+ this.layout.add(this.params.get(E), a.SPACE);
19993
20023
  }
19994
20024
  formatOperator({ text: E }) {
19995
- this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(i.NO_SPACE, E) : E === ":" ? this.layout.add(i.NO_SPACE, E, i.SPACE) : this.layout.add(E, i.SPACE);
20025
+ this.cfg.denseOperators || this.dialectCfg.alwaysDenseOperators.includes(E) ? this.layout.add(a.NO_SPACE, E) : E === ":" ? this.layout.add(a.NO_SPACE, E, a.SPACE) : this.layout.add(E, a.SPACE);
19996
20026
  }
19997
20027
  formatComma(E) {
19998
- this.inline ? this.layout.add(i.NO_SPACE, ",", i.SPACE) : this.layout.add(i.NO_SPACE, ",", i.NEWLINE, i.INDENT);
20028
+ this.inline ? this.layout.add(a.NO_SPACE, ",", a.SPACE) : this.layout.add(a.NO_SPACE, ",", a.NEWLINE, a.INDENT);
19999
20029
  }
20000
20030
  withComments(E, e) {
20001
20031
  this.formatComments(E.leadingComments), e(), this.formatComments(E.trailingComments);
@@ -20006,12 +20036,12 @@ class LE {
20006
20036
  });
20007
20037
  }
20008
20038
  formatLineComment(E) {
20009
- JE(E.precedingWhitespace || "") ? this.layout.add(i.NEWLINE, i.INDENT, E.text, i.MANDATORY_NEWLINE, i.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(i.NO_NEWLINE, i.SPACE, E.text, i.MANDATORY_NEWLINE, i.INDENT) : this.layout.add(E.text, i.MANDATORY_NEWLINE, i.INDENT);
20039
+ JE(E.precedingWhitespace || "") ? this.layout.add(a.NEWLINE, a.INDENT, E.text, a.MANDATORY_NEWLINE, a.INDENT) : this.layout.getLayoutItems().length > 0 ? this.layout.add(a.NO_NEWLINE, a.SPACE, E.text, a.MANDATORY_NEWLINE, a.INDENT) : this.layout.add(E.text, a.MANDATORY_NEWLINE, a.INDENT);
20010
20040
  }
20011
20041
  formatBlockComment(E) {
20012
20042
  E.type === U.block_comment && this.isMultilineBlockComment(E) ? (this.splitBlockComment(E.text).forEach((e) => {
20013
- this.layout.add(i.NEWLINE, i.INDENT, e);
20014
- }), this.layout.add(i.NEWLINE, i.INDENT)) : this.layout.add(E.text, i.SPACE);
20043
+ this.layout.add(a.NEWLINE, a.INDENT, e);
20044
+ }), this.layout.add(a.NEWLINE, a.INDENT)) : this.layout.add(E.text, a.SPACE);
20015
20045
  }
20016
20046
  isMultilineBlockComment(E) {
20017
20047
  return JE(E.text) || JE(E.precedingWhitespace || "");
@@ -20084,27 +20114,27 @@ class LE {
20084
20114
  }
20085
20115
  formatKeywordNode(E) {
20086
20116
  switch (E.tokenType) {
20087
- case a.RESERVED_JOIN:
20117
+ case D.RESERVED_JOIN:
20088
20118
  return this.formatJoin(E);
20089
- case a.AND:
20090
- case a.OR:
20091
- case a.XOR:
20119
+ case D.AND:
20120
+ case D.OR:
20121
+ case D.XOR:
20092
20122
  return this.formatLogicalOperator(E);
20093
20123
  default:
20094
20124
  return this.formatKeyword(E);
20095
20125
  }
20096
20126
  }
20097
20127
  formatJoin(E) {
20098
- j(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E), i.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E), i.SPACE);
20128
+ j(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE);
20099
20129
  }
20100
20130
  formatKeyword(E) {
20101
- this.layout.add(this.showKw(E), i.SPACE);
20131
+ this.layout.add(this.showKw(E), a.SPACE);
20102
20132
  }
20103
20133
  formatLogicalOperator(E) {
20104
- this.cfg.logicalOperatorNewline === "before" ? j(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E), i.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(i.NEWLINE, i.INDENT, this.showKw(E), i.SPACE) : this.layout.add(this.showKw(E), i.NEWLINE, i.INDENT);
20134
+ this.cfg.logicalOperatorNewline === "before" ? j(this.cfg) ? (this.layout.indentation.decreaseTopLevel(), this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE), this.layout.indentation.increaseTopLevel()) : this.layout.add(a.NEWLINE, a.INDENT, this.showKw(E), a.SPACE) : this.layout.add(this.showKw(E), a.NEWLINE, a.INDENT);
20105
20135
  }
20106
20136
  formatDataType(E) {
20107
- this.layout.add(this.showDataType(E), i.SPACE);
20137
+ this.layout.add(this.showDataType(E), a.SPACE);
20108
20138
  }
20109
20139
  showKw(E) {
20110
20140
  return wT(E.tokenType) ? $T(this.showNonTabularKw(E), this.cfg.indentStyle) : this.showNonTabularKw(E);
@@ -20184,7 +20214,7 @@ class iN {
20184
20214
  params: this.params,
20185
20215
  layout: new se(new Ce(xI(this.cfg)))
20186
20216
  }).format(E.children);
20187
- return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? e.add(i.NEWLINE, ";") : e.add(i.NO_NEWLINE, ";")), e.toString();
20217
+ return E.hasSemicolon && (this.cfg.newlineBeforeSemicolon ? e.add(a.NEWLINE, ";") : e.add(a.NO_NEWLINE, ";")), e.toString();
20188
20218
  }
20189
20219
  }
20190
20220
  class tE extends Error {
@@ -20313,34 +20343,34 @@ async function BN(T, E, e) {
20313
20343
  if (!R.isValid)
20314
20344
  throw new Error(`Query validation failed: ${R.errors.join(", ")}`);
20315
20345
  const A = /* @__PURE__ */ new Set();
20316
- T.measures?.forEach((C) => {
20317
- const O = C.split(".")[0];
20346
+ T.measures?.forEach((s) => {
20347
+ const O = s.split(".")[0];
20318
20348
  A.add(O);
20319
- }), T.dimensions?.forEach((C) => {
20320
- const O = C.split(".")[0];
20349
+ }), T.dimensions?.forEach((s) => {
20350
+ const O = s.split(".")[0];
20321
20351
  A.add(O);
20322
- }), T.timeDimensions?.forEach((C) => {
20323
- const O = C.dimension.split(".")[0];
20352
+ }), T.timeDimensions?.forEach((s) => {
20353
+ const O = s.dimension.split(".")[0];
20324
20354
  A.add(O);
20325
- }), T.filters?.forEach((C) => {
20326
- if ("member" in C) {
20327
- const O = C.member.split(".")[0];
20355
+ }), T.filters?.forEach((s) => {
20356
+ if ("member" in s) {
20357
+ const O = s.member.split(".")[0];
20328
20358
  A.add(O);
20329
20359
  }
20330
20360
  });
20331
20361
  const S = A.size > 1;
20332
- let N;
20362
+ let I;
20333
20363
  if (S)
20334
- N = await e.generateMultiCubeSQL(T, E);
20364
+ I = await e.generateMultiCubeSQL(T, E);
20335
20365
  else {
20336
- const C = Array.from(A)[0];
20337
- N = await e.generateSQL(C, T, E);
20366
+ const s = Array.from(A)[0];
20367
+ I = await e.generateSQL(s, T, E);
20338
20368
  }
20339
- const t = Array.from(A).map((C) => ({
20340
- cube: C,
20369
+ const t = Array.from(A).map((s) => ({
20370
+ cube: s,
20341
20371
  query: {
20342
- measures: T.measures?.filter((O) => O.startsWith(C + ".")) || [],
20343
- dimensions: T.dimensions?.filter((O) => O.startsWith(C + ".")) || [],
20372
+ measures: T.measures?.filter((O) => O.startsWith(s + ".")) || [],
20373
+ dimensions: T.dimensions?.filter((O) => O.startsWith(s + ".")) || [],
20344
20374
  filters: T.filters || [],
20345
20375
  timeDimensions: T.timeDimensions || [],
20346
20376
  order: T.order || {},
@@ -20358,8 +20388,8 @@ async function BN(T, E, e) {
20358
20388
  cubes: Array.from(A)
20359
20389
  },
20360
20390
  sql: {
20361
- sql: [N.sql],
20362
- params: N.params || []
20391
+ sql: [I.sql],
20392
+ params: I.params || []
20363
20393
  },
20364
20394
  complexity: uN(T),
20365
20395
  valid: !0,
@@ -20369,14 +20399,14 @@ async function BN(T, E, e) {
20369
20399
  };
20370
20400
  }
20371
20401
  function pN(T, E, e) {
20372
- const R = HN(e), A = GN(), S = (/* @__PURE__ */ new Date()).toISOString(), N = mN(T);
20402
+ const R = HN(e), A = GN(), S = (/* @__PURE__ */ new Date()).toISOString(), I = mN(T);
20373
20403
  return {
20374
20404
  queryType: "regularQuery",
20375
20405
  results: [{
20376
20406
  query: T,
20377
20407
  lastRefreshTime: S,
20378
20408
  usedPreAggregations: {},
20379
- transformedQuery: N,
20409
+ transformedQuery: I,
20380
20410
  requestId: A,
20381
20411
  annotation: E.annotation,
20382
20412
  dataSource: "default",
@@ -20495,13 +20525,13 @@ class dN {
20495
20525
  );
20496
20526
  continue;
20497
20527
  }
20498
- const N = new Map(this.cubes);
20499
- N.set(E.name, E);
20500
- const t = new J(N);
20528
+ const I = new Map(this.cubes);
20529
+ I.set(E.name, E);
20530
+ const t = new J(I);
20501
20531
  try {
20502
20532
  t.validateDependencies(E);
20503
- } catch (C) {
20504
- e.push(C instanceof Error ? C.message : String(C));
20533
+ } catch (s) {
20534
+ e.push(s instanceof Error ? s.message : String(s));
20505
20535
  }
20506
20536
  }
20507
20537
  if (e.length === 0) {
@@ -20595,11 +20625,11 @@ ${e.join(`
20595
20625
  generateCubeMetadata(E) {
20596
20626
  const e = Object.keys(E.measures), R = Object.keys(E.dimensions), A = new Array(e.length), S = new Array(R.length);
20597
20627
  for (let t = 0; t < e.length; t++) {
20598
- const C = e[t], O = E.measures[C];
20628
+ const s = e[t], O = E.measures[s];
20599
20629
  A[t] = {
20600
- name: `${E.name}.${C}`,
20601
- title: O.title || C,
20602
- shortTitle: O.title || C,
20630
+ name: `${E.name}.${s}`,
20631
+ title: O.title || s,
20632
+ shortTitle: O.title || s,
20603
20633
  type: O.type,
20604
20634
  format: void 0,
20605
20635
  // Measure doesn't have format field
@@ -20607,23 +20637,23 @@ ${e.join(`
20607
20637
  };
20608
20638
  }
20609
20639
  for (let t = 0; t < R.length; t++) {
20610
- const C = R[t], O = E.dimensions[C];
20640
+ const s = R[t], O = E.dimensions[s];
20611
20641
  S[t] = {
20612
- name: `${E.name}.${C}`,
20613
- title: O.title || C,
20614
- shortTitle: O.title || C,
20642
+ name: `${E.name}.${s}`,
20643
+ title: O.title || s,
20644
+ shortTitle: O.title || s,
20615
20645
  type: O.type,
20616
20646
  format: void 0,
20617
20647
  // Dimension doesn't have format field
20618
20648
  description: O.description
20619
20649
  };
20620
20650
  }
20621
- const N = [];
20651
+ const I = [];
20622
20652
  if (E.joins)
20623
20653
  for (const [, t] of Object.entries(E.joins)) {
20624
- const C = typeof t.targetCube == "function" ? t.targetCube() : t.targetCube;
20625
- N.push({
20626
- targetCube: C.name,
20654
+ const s = typeof t.targetCube == "function" ? t.targetCube() : t.targetCube;
20655
+ I.push({
20656
+ targetCube: s.name,
20627
20657
  relationship: t.relationship,
20628
20658
  joinFields: t.on.map((O) => ({
20629
20659
  sourceField: this.getColumnName(O.source),
@@ -20639,7 +20669,7 @@ ${e.join(`
20639
20669
  dimensions: S,
20640
20670
  segments: [],
20641
20671
  // Add segments support later if needed
20642
- relationships: N.length > 0 ? N : void 0
20672
+ relationships: I.length > 0 ? I : void 0
20643
20673
  };
20644
20674
  }
20645
20675
  /**
@@ -20651,10 +20681,10 @@ ${e.join(`
20651
20681
  throw new Error(`Cube '${E}' not found`);
20652
20682
  if (!this.dbExecutor)
20653
20683
  throw new Error("Database executor not configured");
20654
- const N = await new GE(this.dbExecutor).generateSQL(A, e, R), t = this.dbExecutor.getEngineType();
20684
+ const I = await new GE(this.dbExecutor).generateSQL(A, e, R), t = this.dbExecutor.getEngineType();
20655
20685
  return {
20656
- sql: JT(N.sql, t),
20657
- params: N.params
20686
+ sql: JT(I.sql, t),
20687
+ params: I.params
20658
20688
  };
20659
20689
  }
20660
20690
  /**
@@ -20713,8 +20743,8 @@ function Le(T, E) {
20713
20743
  const e = [], R = /* @__PURE__ */ new Set();
20714
20744
  if (E.measures)
20715
20745
  for (const A of E.measures) {
20716
- const [S, N] = A.split(".");
20717
- if (!S || !N) {
20746
+ const [S, I] = A.split(".");
20747
+ if (!S || !I) {
20718
20748
  e.push(`Invalid measure format: ${A}. Expected format: 'CubeName.fieldName'`);
20719
20749
  continue;
20720
20750
  }
@@ -20724,12 +20754,12 @@ function Le(T, E) {
20724
20754
  e.push(`Cube '${S}' not found (referenced in measure '${A}')`);
20725
20755
  continue;
20726
20756
  }
20727
- t.measures[N] || e.push(`Measure '${N}' not found on cube '${S}'`);
20757
+ t.measures[I] || e.push(`Measure '${I}' not found on cube '${S}'`);
20728
20758
  }
20729
20759
  if (E.dimensions)
20730
20760
  for (const A of E.dimensions) {
20731
- const [S, N] = A.split(".");
20732
- if (!S || !N) {
20761
+ const [S, I] = A.split(".");
20762
+ if (!S || !I) {
20733
20763
  e.push(`Invalid dimension format: ${A}. Expected format: 'CubeName.fieldName'`);
20734
20764
  continue;
20735
20765
  }
@@ -20739,12 +20769,12 @@ function Le(T, E) {
20739
20769
  e.push(`Cube '${S}' not found (referenced in dimension '${A}')`);
20740
20770
  continue;
20741
20771
  }
20742
- t.dimensions[N] || e.push(`Dimension '${N}' not found on cube '${S}'`);
20772
+ t.dimensions[I] || e.push(`Dimension '${I}' not found on cube '${S}'`);
20743
20773
  }
20744
20774
  if (E.timeDimensions)
20745
20775
  for (const A of E.timeDimensions) {
20746
- const [S, N] = A.dimension.split(".");
20747
- if (!S || !N) {
20776
+ const [S, I] = A.dimension.split(".");
20777
+ if (!S || !I) {
20748
20778
  e.push(`Invalid timeDimension format: ${A.dimension}. Expected format: 'CubeName.fieldName'`);
20749
20779
  continue;
20750
20780
  }
@@ -20754,7 +20784,7 @@ function Le(T, E) {
20754
20784
  e.push(`Cube '${S}' not found (referenced in timeDimension '${A.dimension}')`);
20755
20785
  continue;
20756
20786
  }
20757
- t.dimensions[N] || e.push(`TimeDimension '${N}' not found on cube '${S}' (must be a dimension with time type)`);
20787
+ t.dimensions[I] || e.push(`TimeDimension '${I}' not found on cube '${S}' (must be a dimension with time type)`);
20758
20788
  }
20759
20789
  if (E.filters)
20760
20790
  for (const A of E.filters)
@@ -20767,8 +20797,8 @@ function Le(T, E) {
20767
20797
  function ne(T, E, e, R) {
20768
20798
  if ("and" in T || "or" in T) {
20769
20799
  const t = T.and || T.or || [];
20770
- for (const C of t)
20771
- ne(C, E, e, R);
20800
+ for (const s of t)
20801
+ ne(s, E, e, R);
20772
20802
  return;
20773
20803
  }
20774
20804
  if (!("member" in T)) {
@@ -20781,12 +20811,12 @@ function ne(T, E, e, R) {
20781
20811
  return;
20782
20812
  }
20783
20813
  R.add(A);
20784
- const N = E.get(A);
20785
- if (!N) {
20814
+ const I = E.get(A);
20815
+ if (!I) {
20786
20816
  e.push(`Cube '${A}' not found (referenced in filter '${T.member}')`);
20787
20817
  return;
20788
20818
  }
20789
- !N.dimensions[S] && !N.measures[S] && e.push(`Filter field '${S}' not found on cube '${A}' (must be a dimension or measure)`);
20819
+ !I.dimensions[S] && !I.measures[S] && e.push(`Filter field '${S}' not found on cube '${A}' (must be a dimension or measure)`);
20790
20820
  }
20791
20821
  new dN();
20792
20822
  export {