@sisense/mcp-server 0.2.2 → 0.2.4

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 (26) hide show
  1. package/dist/{ai-hspmgr2c.js → ai-qt2rw4p0.js} +999 -959
  2. package/dist/{index-29n08mw7.js → index-0rmh0qta.js} +5 -5
  3. package/dist/{index-er0yspcy.js → index-6vz3bc2n.js} +552 -385
  4. package/dist/{index-vx54d05h.js → index-7ztxzw1b.js} +9 -9
  5. package/dist/{index-tqba2rwh.js → index-86j7fyp7.js} +406 -245
  6. package/dist/{index-p1pxtmwn.js → index-bgbnagw5.js} +18 -20
  7. package/dist/{index-d6843g0v.js → index-jatbeegy.js} +9 -7
  8. package/dist/{index-dxfb3krz.js → index-jgdfekw7.js} +375 -539
  9. package/dist/{index-qdth51hx.js → index-k71wsmah.js} +8 -1
  10. package/dist/{index-atgbxy7h.js → index-mxkgxy04.js} +28981 -27209
  11. package/dist/{index-vrapm0b4.js → index-p5hr1cfd.js} +458 -331
  12. package/dist/{index-dcrjg3fk.js → index-z44fq2x1.js} +3 -2
  13. package/dist/sse-server-0d83pnkk.js +54 -0
  14. package/dist/{sse-server-brx9qtyd.js → sse-server-22mq7fhc.js} +880 -757
  15. package/dist/{sse-server-3e0efmg2.js → sse-server-d3yx2z0r.js} +1845 -1825
  16. package/dist/{sse-server-4jjec4fz.js → sse-server-gcjj2741.js} +2081 -1695
  17. package/dist/{sse-server-rr3dp62e.js → sse-server-kpkj0hbc.js} +22749 -22399
  18. package/dist/{sse-server-36t17nga.js → sse-server-qhqncg7f.js} +3555 -3657
  19. package/dist/{sse-server-txz5g5t0.js → sse-server-rrtgkg21.js} +414 -177
  20. package/dist/{sse-server-nwjjjz6x.js → sse-server-wb2h6nz7.js} +3 -52
  21. package/dist/{sse-server-qj4zxq0f.js → sse-server-zmcz2c17.js} +12 -24
  22. package/dist/sse-server.js +96 -52
  23. package/dist/view.html +609 -544
  24. package/dist/{widget-renderer-66ws3xtk.js → widget-renderer-wjrpnwpy.js} +12 -12
  25. package/package.json +4 -4
  26. package/dist/sse-server-4b60tg0c.js +0 -136
@@ -1,72 +1,74 @@
1
1
  import {
2
- $r,
3
2
  Bi,
3
+ C,
4
4
  Cd,
5
- Cr,
6
- Ct,
5
+ Dr,
7
6
  E,
7
+ Ed,
8
8
  Fi,
9
9
  Gh,
10
- Hi,
10
+ Hh,
11
+ Ii,
11
12
  Jh,
12
13
  Kh,
13
- L,
14
- Ld,
15
- Md,
16
14
  Nd,
15
+ Ni,
17
16
  Nr,
18
- Nt,
19
- Qe,
17
+ Od,
18
+ Oe,
19
+ Or,
20
20
  Qh,
21
- Qt,
22
- Rd,
23
- Ri,
24
- Se,
25
- Sh,
21
+ Ui,
22
+ Ve,
26
23
  Vh,
24
+ Vt,
27
25
  Wh,
28
26
  Xh,
29
27
  Y,
30
28
  Yh,
31
29
  Z,
32
30
  Zh,
33
- _e,
34
- _r,
31
+ _d,
35
32
  ap,
36
33
  be,
34
+ bh,
37
35
  bp,
36
+ br,
38
37
  dp,
39
38
  ep,
39
+ fp,
40
+ ft,
40
41
  g,
41
- gp,
42
- gt,
43
42
  h1 as h,
44
43
  ip,
45
44
  ji,
46
45
  kh,
47
46
  m,
47
+ me,
48
48
  mp,
49
49
  ne,
50
- np,
50
+ pp,
51
51
  qh,
52
52
  rp,
53
53
  tp,
54
- vs,
55
54
  wd,
55
+ wr,
56
+ wt,
56
57
  xd,
58
+ xt,
57
59
  ye,
58
- yr,
59
- zi
60
- } from "./sse-server-3e0efmg2.js";
60
+ ys,
61
+ zh
62
+ } from "./sse-server-d3yx2z0r.js";
61
63
 
62
- // node_modules/@sisense/sdk-ui/dist/dimensions-Blw0p98x.js
63
- class c extends yr {
64
+ // node_modules/@sisense/sdk-ui/dist/dimensions-BiLyFpCg.js
65
+ class c extends br {
64
66
  constructor(e, t, s, r, u, m2, l, d, y, a) {
65
- if (super(e, u || E.Dimension, m2, d, y), this.__serializable = "DimensionalDimension", this._dimensions = [], this._attributes = [], this._sort = L.None, !y && t) {
66
- const { table: g2, column: b } = _e(t);
67
- this.composeCode = `${Ri}.${gt(g2)}.${gt(b)}`;
67
+ if (super(e, u || E.Dimension, m2, d, y), this.__serializable = "DimensionalDimension", this._dimensions = [], this._attributes = [], this._sort = C.None, !y && t) {
68
+ const { table: g2, column: b } = Oe(t);
69
+ this.composeCode = `${Ni}.${ft(g2)}.${ft(b)}`;
68
70
  }
69
- this._sort = l || L.None, this._expression = t, this.setDimensions(r || []), this.setAttributes(s), a && (this.defaultAttribute = a);
71
+ this._sort = l || C.None, this._expression = t, this.setDimensions(r || []), this.setAttributes(s), a && (this.defaultAttribute = a);
70
72
  }
71
73
  static parseType(e) {
72
74
  switch (e) {
@@ -84,21 +86,21 @@ class c extends yr {
84
86
  }
85
87
  getAttachedName(e, t) {
86
88
  let s = e;
87
- const r = be(e);
89
+ const r = me(e);
88
90
  return (r === "id" || r === "name" || Object.getOwnPropertyDescriptor(this, r) !== undefined || this[r] !== undefined) && (s = t), s;
89
91
  }
90
92
  setDimensions(e) {
91
93
  this._dimensions = e;
92
94
  for (let t = 0;t < e.length; t++) {
93
95
  const s = this.getAttachedName(e[t].name, e[t].attributes[0].expression);
94
- this[be(s)] = e[t], s != e[t].name && (e[t].name = s);
96
+ this[me(s)] = e[t], s != e[t].name && (e[t].name = s);
95
97
  }
96
98
  }
97
99
  setAttributes(e) {
98
100
  this._attributes = e || [];
99
101
  for (let t = 0;t < e.length; t++) {
100
102
  const s = this.getAttachedName(e[t].name, e[t].expression);
101
- this[be(s)] = e[t], e[t].name != s && (e[t].name = s);
103
+ this[me(s)] = e[t], e[t].name != s && (e[t].name = s);
102
104
  }
103
105
  }
104
106
  get id() {
@@ -132,10 +134,10 @@ class c extends yr {
132
134
  jaql: {
133
135
  title: this.name,
134
136
  dim: this.expression,
135
- datatype: vs(this.type)
137
+ datatype: ys(this.type)
136
138
  }
137
139
  };
138
- return this._sort != L.None && (t.jaql.sort = this._sort == L.Ascending ? "asc" : "desc"), e === true ? t.jaql : t;
140
+ return this._sort != C.None && (t.jaql.sort = this._sort == C.Ascending ? "asc" : "desc"), e === true ? t.jaql : t;
139
141
  }
140
142
  }
141
143
  var z = (i) => i && i.__serializable === "DimensionalDimension";
@@ -190,9 +192,9 @@ function R(i) {
190
192
  if (i.attributes) {
191
193
  let a;
192
194
  for (let g2 = 0;g2 < i.attributes.length; g2++)
193
- a = i.attributes[g2], l.push(new Qe(a.name, a.expression, a.type, a.description, a.sort, a.dataSource));
195
+ a = i.attributes[g2], l.push(new Ve(a.name, a.expression, a.type, a.description, a.sort, a.dataSource));
194
196
  } else
195
- s && l.push(new Qe(e, s, r, t, u, m2));
197
+ s && l.push(new Ve(e, s, r, t, u, m2));
196
198
  const d = Object.getOwnPropertyNames(i).map((a) => i[a]).filter((a) => E.isDimension(a == null ? undefined : a.type));
197
199
  if (d.length == 0 && i.dimensions)
198
200
  for (let a = 0;a < i.dimensions.length; a++)
@@ -206,24 +208,24 @@ function x(i) {
206
208
  }
207
209
 
208
210
  // node_modules/@sisense/sdk-ui/dist/analytics-composer/node.js
209
- var Qe2 = Object.defineProperty;
210
- var Ye = Object.defineProperties;
211
- var He = Object.getOwnPropertyDescriptors;
212
- var pe = Object.getOwnPropertySymbols;
213
- var Ze = Object.prototype.hasOwnProperty;
214
- var Ge = Object.prototype.propertyIsEnumerable;
215
- var ye2 = (e, r, t) => (r in e) ? Qe2(e, r, { enumerable: true, configurable: true, writable: true, value: t }) : e[r] = t;
216
- var b2 = (e, r) => {
211
+ var er = Object.defineProperty;
212
+ var rr = Object.defineProperties;
213
+ var tr = Object.getOwnPropertyDescriptors;
214
+ var ye2 = Object.getOwnPropertySymbols;
215
+ var sr = Object.prototype.hasOwnProperty;
216
+ var nr = Object.prototype.propertyIsEnumerable;
217
+ var ge = (e, r, t) => (r in e) ? er(e, r, { enumerable: true, configurable: true, writable: true, value: t }) : e[r] = t;
218
+ var g2 = (e, r) => {
217
219
  for (var t in r || (r = {}))
218
- Ze.call(r, t) && ye2(e, t, r[t]);
219
- if (pe)
220
- for (var t of pe(r))
221
- Ge.call(r, t) && ye2(e, t, r[t]);
220
+ sr.call(r, t) && ge(e, t, r[t]);
221
+ if (ye2)
222
+ for (var t of ye2(r))
223
+ nr.call(r, t) && ge(e, t, r[t]);
222
224
  return e;
223
225
  };
224
- var E3 = (e, r) => Ye(e, He(r));
226
+ var h2 = (e, r) => rr(e, tr(r));
225
227
 
226
- class Gr {
228
+ class st {
227
229
  constructor() {
228
230
  this.keyToValue = /* @__PURE__ */ new Map, this.valueToKey = /* @__PURE__ */ new Map;
229
231
  }
@@ -241,9 +243,9 @@ class Gr {
241
243
  }
242
244
  }
243
245
 
244
- class Ee {
246
+ class De {
245
247
  constructor(r) {
246
- this.generateIdentifier = r, this.kv = new Gr;
248
+ this.generateIdentifier = r, this.kv = new st;
247
249
  }
248
250
  register(r, t) {
249
251
  this.kv.getByValue(r) || (t || (t = this.generateIdentifier(r)), this.kv.set(t, r));
@@ -259,7 +261,7 @@ class Ee {
259
261
  }
260
262
  }
261
263
 
262
- class Xr extends Ee {
264
+ class nt extends De {
263
265
  constructor() {
264
266
  super((r) => r.name), this.classToAllowedProps = /* @__PURE__ */ new Map;
265
267
  }
@@ -270,7 +272,7 @@ class Xr extends Ee {
270
272
  return this.classToAllowedProps.get(r);
271
273
  }
272
274
  }
273
- function vr(e) {
275
+ function it(e) {
274
276
  if ("values" in Object)
275
277
  return Object.values(e);
276
278
  const r = [];
@@ -278,24 +280,24 @@ function vr(e) {
278
280
  e.hasOwnProperty(t) && r.push(e[t]);
279
281
  return r;
280
282
  }
281
- function et(e, r) {
282
- const t = vr(e);
283
+ function ot(e, r) {
284
+ const t = it(e);
283
285
  if ("find" in t)
284
286
  return t.find(r);
285
287
  const s = t;
286
288
  for (let n = 0;n < s.length; n++) {
287
- const a = s[n];
288
- if (r(a))
289
- return a;
289
+ const o = s[n];
290
+ if (r(o))
291
+ return o;
290
292
  }
291
293
  }
292
- function B(e, r) {
294
+ function z2(e, r) {
293
295
  Object.entries(e).forEach(([t, s]) => r(s, t));
294
296
  }
295
- function U(e, r) {
297
+ function j2(e, r) {
296
298
  return e.indexOf(r) !== -1;
297
299
  }
298
- function he(e, r) {
300
+ function be2(e, r) {
299
301
  for (let t = 0;t < e.length; t++) {
300
302
  const s = e[t];
301
303
  if (r(s))
@@ -303,7 +305,7 @@ function he(e, r) {
303
305
  }
304
306
  }
305
307
 
306
- class rt {
308
+ class at {
307
309
  constructor() {
308
310
  this.transfomers = {};
309
311
  }
@@ -311,54 +313,54 @@ class rt {
311
313
  this.transfomers[r.name] = r;
312
314
  }
313
315
  findApplicable(r) {
314
- return et(this.transfomers, (t) => t.isApplicable(r));
316
+ return ot(this.transfomers, (t) => t.isApplicable(r));
315
317
  }
316
318
  findByName(r) {
317
319
  return this.transfomers[r];
318
320
  }
319
321
  }
320
- var tt = (e) => Object.prototype.toString.call(e).slice(8, -1);
321
- var Ce = (e) => typeof e == "undefined";
322
- var st = (e) => e === null;
322
+ var ut = (e) => Object.prototype.toString.call(e).slice(8, -1);
323
+ var Me = (e) => typeof e == "undefined";
324
+ var ct = (e) => e === null;
323
325
  var k = (e) => typeof e != "object" || e === null || e === Object.prototype ? false : Object.getPrototypeOf(e) === null ? true : Object.getPrototypeOf(e) === Object.prototype;
324
- var G = (e) => k(e) && Object.keys(e).length === 0;
325
- var N = (e) => Array.isArray(e);
326
- var nt = (e) => typeof e == "string";
327
- var it = (e) => typeof e == "number" && !isNaN(e);
328
- var at = (e) => typeof e == "boolean";
329
- var ot = (e) => e instanceof RegExp;
330
- var _ = (e) => e instanceof Map;
331
- var L2 = (e) => e instanceof Set;
332
- var $e = (e) => tt(e) === "Symbol";
333
- var ut = (e) => e instanceof Date && !isNaN(e.valueOf());
334
- var lt = (e) => e instanceof Error;
335
- var be2 = (e) => typeof e == "number" && isNaN(e);
336
- var ct = (e) => at(e) || st(e) || Ce(e) || it(e) || nt(e) || $e(e);
337
- var ft = (e) => typeof e == "bigint";
338
- var dt = (e) => e === 1 / 0 || e === -1 / 0;
339
- var mt = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView);
340
- var pt = (e) => e instanceof URL;
341
- var xe = (e) => e.replace(/\./g, "\\.");
342
- var Y2 = (e) => e.map(String).map(xe).join(".");
326
+ var X = (e) => k(e) && Object.keys(e).length === 0;
327
+ var S = (e) => Array.isArray(e);
328
+ var lt = (e) => typeof e == "string";
329
+ var ft2 = (e) => typeof e == "number" && !isNaN(e);
330
+ var dt = (e) => typeof e == "boolean";
331
+ var mt = (e) => e instanceof RegExp;
332
+ var L = (e) => e instanceof Map;
333
+ var V = (e) => e instanceof Set;
334
+ var Se = (e) => ut(e) === "Symbol";
335
+ var pt = (e) => e instanceof Date && !isNaN(e.valueOf());
336
+ var yt = (e) => e instanceof Error;
337
+ var Fe = (e) => typeof e == "number" && isNaN(e);
338
+ var gt = (e) => dt(e) || ct(e) || Me(e) || ft2(e) || lt(e) || Se(e);
339
+ var ht = (e) => typeof e == "bigint";
340
+ var bt = (e) => e === 1 / 0 || e === -1 / 0;
341
+ var Ft = (e) => ArrayBuffer.isView(e) && !(e instanceof DataView);
342
+ var wt2 = (e) => e instanceof URL;
343
+ var Te = (e) => e.replace(/\./g, "\\.");
344
+ var Y2 = (e) => e.map(String).map(Te).join(".");
343
345
  var P = (e) => {
344
346
  const r = [];
345
347
  let t = "";
346
348
  for (let n = 0;n < e.length; n++) {
347
- let a = e.charAt(n);
348
- if (a === "\\" && e.charAt(n + 1) === ".") {
349
+ let o = e.charAt(n);
350
+ if (o === "\\" && e.charAt(n + 1) === ".") {
349
351
  t += ".", n++;
350
352
  continue;
351
353
  }
352
- if (a === ".") {
354
+ if (o === ".") {
353
355
  r.push(t), t = "";
354
356
  continue;
355
357
  }
356
- t += a;
358
+ t += o;
357
359
  }
358
360
  const s = t;
359
361
  return r.push(s), r;
360
362
  };
361
- function $(e, r, t, s) {
363
+ function A(e, r, t, s) {
362
364
  return {
363
365
  isApplicable: e,
364
366
  annotation: r,
@@ -366,11 +368,11 @@ function $(e, r, t, s) {
366
368
  untransform: s
367
369
  };
368
370
  }
369
- var Ae = [
370
- $(Ce, "undefined", () => null, () => {}),
371
- $(ft, "bigint", (e) => e.toString(), (e) => typeof BigInt != "undefined" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
372
- $(ut, "Date", (e) => e.toISOString(), (e) => new Date(e)),
373
- $(lt, "Error", (e, r) => {
371
+ var Ne = [
372
+ A(Me, "undefined", () => null, () => {}),
373
+ A(ht, "bigint", (e) => e.toString(), (e) => typeof BigInt != "undefined" ? BigInt(e) : (console.error("Please add a BigInt polyfill."), e)),
374
+ A(pt, "Date", (e) => e.toISOString(), (e) => new Date(e)),
375
+ A(yt, "Error", (e, r) => {
374
376
  const t = {
375
377
  name: e.name,
376
378
  message: e.message
@@ -384,17 +386,17 @@ var Ae = [
384
386
  t[s] = e[s];
385
387
  }), t;
386
388
  }),
387
- $(ot, "regexp", (e) => "" + e, (e) => {
389
+ A(mt, "regexp", (e) => "" + e, (e) => {
388
390
  const r = e.slice(1, e.lastIndexOf("/")), t = e.slice(e.lastIndexOf("/") + 1);
389
391
  return new RegExp(r, t);
390
392
  }),
391
- $(L2, "set", (e) => [...e.values()], (e) => new Set(e)),
392
- $(_, "map", (e) => [...e.entries()], (e) => new Map(e)),
393
- $((e) => be2(e) || dt(e), "number", (e) => be2(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
394
- $((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
395
- $(pt, "URL", (e) => e.toString(), (e) => new URL(e))
393
+ A(V, "set", (e) => [...e.values()], (e) => new Set(e)),
394
+ A(L, "map", (e) => [...e.entries()], (e) => new Map(e)),
395
+ A((e) => Fe(e) || bt(e), "number", (e) => Fe(e) ? "NaN" : e > 0 ? "Infinity" : "-Infinity", Number),
396
+ A((e) => e === 0 && 1 / e === -1 / 0, "number", () => "-0", Number),
397
+ A(wt2, "URL", (e) => e.toString(), (e) => new URL(e))
396
398
  ];
397
- function j2(e, r, t, s) {
399
+ function J(e, r, t, s) {
398
400
  return {
399
401
  isApplicable: e,
400
402
  annotation: r,
@@ -402,13 +404,13 @@ function j2(e, r, t, s) {
402
404
  untransform: s
403
405
  };
404
406
  }
405
- var De = j2((e, r) => $e(e) ? !!r.symbolRegistry.getIdentifier(e) : false, (e, r) => ["symbol", r.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, r, t) => {
407
+ var Re = J((e, r) => Se(e) ? !!r.symbolRegistry.getIdentifier(e) : false, (e, r) => ["symbol", r.symbolRegistry.getIdentifier(e)], (e) => e.description, (e, r, t) => {
406
408
  const s = t.symbolRegistry.getValue(r[1]);
407
409
  if (!s)
408
410
  throw new Error("Trying to deserialize unknown symbol");
409
411
  return s;
410
412
  });
411
- var yt = [
413
+ var qt = [
412
414
  Int8Array,
413
415
  Uint8Array,
414
416
  Int16Array,
@@ -419,19 +421,19 @@ var yt = [
419
421
  Float64Array,
420
422
  Uint8ClampedArray
421
423
  ].reduce((e, r) => (e[r.name] = r, e), {});
422
- var Me = j2(mt, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, r) => {
423
- const t = yt[r[1]];
424
+ var Oe2 = J(Ft, (e) => ["typed-array", e.constructor.name], (e) => [...e], (e, r) => {
425
+ const t = qt[r[1]];
424
426
  if (!t)
425
427
  throw new Error("Trying to deserialize unknown typed array");
426
428
  return new t(e);
427
429
  });
428
- function Ne(e, r) {
430
+ function Ie(e, r) {
429
431
  return e != null && e.constructor ? !!r.classRegistry.getIdentifier(e.constructor) : false;
430
432
  }
431
- var Re = j2(Ne, (e, r) => ["class", r.classRegistry.getIdentifier(e.constructor)], (e, r) => {
433
+ var ze = J(Ie, (e, r) => ["class", r.classRegistry.getIdentifier(e.constructor)], (e, r) => {
432
434
  const t = r.classRegistry.getAllowedProps(e.constructor);
433
435
  if (!t)
434
- return b2({}, e);
436
+ return g2({}, e);
435
437
  const s = {};
436
438
  return t.forEach((n) => {
437
439
  s[n] = e[n];
@@ -442,53 +444,53 @@ var Re = j2(Ne, (e, r) => ["class", r.classRegistry.getIdentifier(e.constructor)
442
444
  throw new Error(`Trying to deserialize unknown class '${r[1]}' - check https://github.com/blitz-js/superjson/issues/116#issuecomment-773996564`);
443
445
  return Object.assign(Object.create(s.prototype), e);
444
446
  });
445
- var Se2 = j2((e, r) => !!r.customTransformerRegistry.findApplicable(e), (e, r) => ["custom", r.customTransformerRegistry.findApplicable(e).name], (e, r) => r.customTransformerRegistry.findApplicable(e).serialize(e), (e, r, t) => {
447
+ var Be = J((e, r) => !!r.customTransformerRegistry.findApplicable(e), (e, r) => ["custom", r.customTransformerRegistry.findApplicable(e).name], (e, r) => r.customTransformerRegistry.findApplicable(e).serialize(e), (e, r, t) => {
446
448
  const s = t.customTransformerRegistry.findByName(r[1]);
447
449
  if (!s)
448
450
  throw new Error("Trying to deserialize unknown custom value");
449
451
  return s.deserialize(e);
450
452
  });
451
- var gt2 = [Re, De, Se2, Me];
452
- var Fe = (e, r) => {
453
- const t = he(gt2, (n) => n.isApplicable(e, r));
453
+ var Et = [ze, Re, Be, Oe2];
454
+ var we = (e, r) => {
455
+ const t = be2(Et, (n) => n.isApplicable(e, r));
454
456
  if (t)
455
457
  return {
456
458
  value: t.transform(e, r),
457
459
  type: t.annotation(e, r)
458
460
  };
459
- const s = he(Ae, (n) => n.isApplicable(e, r));
461
+ const s = be2(Ne, (n) => n.isApplicable(e, r));
460
462
  if (s)
461
463
  return {
462
464
  value: s.transform(e, r),
463
465
  type: s.annotation
464
466
  };
465
467
  };
466
- var Oe = {};
467
- Ae.forEach((e) => {
468
- Oe[e.annotation] = e;
468
+ var Pe = {};
469
+ Ne.forEach((e) => {
470
+ Pe[e.annotation] = e;
469
471
  });
470
- var ht = (e, r, t) => {
471
- if (N(r))
472
+ var Ct = (e, r, t) => {
473
+ if (S(r))
472
474
  switch (r[0]) {
473
475
  case "symbol":
474
- return De.untransform(e, r, t);
475
- case "class":
476
476
  return Re.untransform(e, r, t);
477
+ case "class":
478
+ return ze.untransform(e, r, t);
477
479
  case "custom":
478
- return Se2.untransform(e, r, t);
480
+ return Be.untransform(e, r, t);
479
481
  case "typed-array":
480
- return Me.untransform(e, r, t);
482
+ return Oe2.untransform(e, r, t);
481
483
  default:
482
484
  throw new Error("Unknown transformation: " + r);
483
485
  }
484
486
  else {
485
- const s = Oe[r];
487
+ const s = Pe[r];
486
488
  if (!s)
487
489
  throw new Error("Unknown transformation: " + r);
488
490
  return s.untransform(e, t);
489
491
  }
490
492
  };
491
- var I = (e, r) => {
493
+ var O = (e, r) => {
492
494
  if (r > e.size)
493
495
  throw new Error("index out of bounds");
494
496
  const t = e.keys();
@@ -496,23 +498,23 @@ var I = (e, r) => {
496
498
  t.next(), r--;
497
499
  return t.next().value;
498
500
  };
499
- function Te(e) {
500
- if (U(e, "__proto__"))
501
+ function ke(e) {
502
+ if (j2(e, "__proto__"))
501
503
  throw new Error("__proto__ is not allowed as a property");
502
- if (U(e, "prototype"))
504
+ if (j2(e, "prototype"))
503
505
  throw new Error("prototype is not allowed as a property");
504
- if (U(e, "constructor"))
506
+ if (j2(e, "constructor"))
505
507
  throw new Error("constructor is not allowed as a property");
506
508
  }
507
- var bt = (e, r) => {
508
- Te(r);
509
+ var $t = (e, r) => {
510
+ ke(r);
509
511
  for (let t = 0;t < r.length; t++) {
510
512
  const s = r[t];
511
- if (L2(e))
512
- e = I(e, +s);
513
- else if (_(e)) {
514
- const n = +s, a = +r[++t] == 0 ? "key" : "value", i = I(e, n);
515
- switch (a) {
513
+ if (V(e))
514
+ e = O(e, +s);
515
+ else if (L(e)) {
516
+ const n = +s, o = +r[++t] == 0 ? "key" : "value", i = O(e, n);
517
+ switch (o) {
516
518
  case "key":
517
519
  e = i;
518
520
  break;
@@ -525,25 +527,25 @@ var bt = (e, r) => {
525
527
  }
526
528
  return e;
527
529
  };
528
- var X = (e, r, t) => {
529
- if (Te(r), r.length === 0)
530
+ var v = (e, r, t) => {
531
+ if (ke(r), r.length === 0)
530
532
  return t(e);
531
533
  let s = e;
532
- for (let a = 0;a < r.length - 1; a++) {
533
- const i = r[a];
534
- if (N(s)) {
535
- const o = +i;
536
- s = s[o];
534
+ for (let o = 0;o < r.length - 1; o++) {
535
+ const i = r[o];
536
+ if (S(s)) {
537
+ const a = +i;
538
+ s = s[a];
537
539
  } else if (k(s))
538
540
  s = s[i];
539
- else if (L2(s)) {
540
- const o = +i;
541
- s = I(s, o);
542
- } else if (_(s)) {
543
- if (a === r.length - 2)
541
+ else if (V(s)) {
542
+ const a = +i;
543
+ s = O(s, a);
544
+ } else if (L(s)) {
545
+ if (o === r.length - 2)
544
546
  break;
545
- const u = +i, l = +r[++a] == 0 ? "key" : "value", p2 = I(s, u);
546
- switch (l) {
547
+ const u = +i, c2 = +r[++o] == 0 ? "key" : "value", p2 = O(s, u);
548
+ switch (c2) {
547
549
  case "key":
548
550
  s = p2;
549
551
  break;
@@ -554,12 +556,12 @@ var X = (e, r, t) => {
554
556
  }
555
557
  }
556
558
  const n = r[r.length - 1];
557
- if (N(s) ? s[+n] = t(s[+n]) : k(s) && (s[n] = t(s[n])), L2(s)) {
558
- const a = I(s, +n), i = t(a);
559
- a !== i && (s.delete(a), s.add(i));
559
+ if (S(s) ? s[+n] = t(s[+n]) : k(s) && (s[n] = t(s[n])), V(s)) {
560
+ const o = O(s, +n), i = t(o);
561
+ o !== i && (s.delete(o), s.add(i));
560
562
  }
561
- if (_(s)) {
562
- const a = +r[r.length - 2], i = I(s, a);
563
+ if (L(s)) {
564
+ const o = +r[r.length - 2], i = O(s, o);
563
565
  switch (+n == 0 ? "key" : "value") {
564
566
  case "key": {
565
567
  const u = t(i);
@@ -574,155 +576,155 @@ var X = (e, r, t) => {
574
576
  }
575
577
  return e;
576
578
  };
577
- function v(e, r, t = []) {
579
+ function ee(e, r, t = []) {
578
580
  if (!e)
579
581
  return;
580
- if (!N(e)) {
581
- B(e, (a, i) => v(a, r, [...t, ...P(i)]));
582
+ if (!S(e)) {
583
+ z2(e, (o, i) => ee(o, r, [...t, ...P(i)]));
582
584
  return;
583
585
  }
584
586
  const [s, n] = e;
585
- n && B(n, (a, i) => {
586
- v(a, r, [...t, ...P(i)]);
587
+ n && z2(n, (o, i) => {
588
+ ee(o, r, [...t, ...P(i)]);
587
589
  }), r(s, t);
588
590
  }
589
- function Ft(e, r, t) {
590
- return v(r, (s, n) => {
591
- e = X(e, n, (a) => ht(a, s, t));
591
+ function At(e, r, t) {
592
+ return ee(r, (s, n) => {
593
+ e = v(e, n, (o) => Ct(o, s, t));
592
594
  }), e;
593
595
  }
594
- function wt(e, r) {
596
+ function xt2(e, r) {
595
597
  function t(s, n) {
596
- const a = bt(e, P(n));
598
+ const o = $t(e, P(n));
597
599
  s.map(P).forEach((i) => {
598
- e = X(e, i, () => a);
600
+ e = v(e, i, () => o);
599
601
  });
600
602
  }
601
- if (N(r)) {
603
+ if (S(r)) {
602
604
  const [s, n] = r;
603
- s.forEach((a) => {
604
- e = X(e, P(a), () => e);
605
- }), n && B(n, t);
605
+ s.forEach((o) => {
606
+ e = v(e, P(o), () => e);
607
+ }), n && z2(n, t);
606
608
  } else
607
- B(r, t);
609
+ z2(r, t);
608
610
  return e;
609
611
  }
610
- var qt = (e, r) => k(e) || N(e) || _(e) || L2(e) || Ne(e, r);
611
- function Et(e, r, t) {
612
+ var Dt = (e, r) => k(e) || S(e) || L(e) || V(e) || Ie(e, r);
613
+ function Mt(e, r, t) {
612
614
  const s = t.get(e);
613
615
  s ? s.push(r) : t.set(e, [r]);
614
616
  }
615
- function Ct2(e, r) {
617
+ function St(e, r) {
616
618
  const t = {};
617
619
  let s;
618
620
  return e.forEach((n) => {
619
621
  if (n.length <= 1)
620
622
  return;
621
- r || (n = n.map((o) => o.map(String)).sort((o, u) => o.length - u.length));
622
- const [a, ...i] = n;
623
- a.length === 0 ? s = i.map(Y2) : t[Y2(a)] = i.map(Y2);
624
- }), s ? G(t) ? [s] : [s, t] : G(t) ? undefined : t;
625
- }
626
- var Ie = (e, r, t, s, n = [], a = [], i = /* @__PURE__ */ new Map) => {
627
- var F;
628
- const o = ct(e);
629
- if (!o) {
630
- Et(e, n, r);
631
- const d = i.get(e);
632
- if (d)
623
+ r || (n = n.map((a) => a.map(String)).sort((a, u) => a.length - u.length));
624
+ const [o, ...i] = n;
625
+ o.length === 0 ? s = i.map(Y2) : t[Y2(o)] = i.map(Y2);
626
+ }), s ? X(t) ? [s] : [s, t] : X(t) ? undefined : t;
627
+ }
628
+ var Le = (e, r, t, s, n = [], o = [], i = /* @__PURE__ */ new Map) => {
629
+ var x2;
630
+ const a = gt(e);
631
+ if (!a) {
632
+ Mt(e, n, r);
633
+ const f2 = i.get(e);
634
+ if (f2)
633
635
  return s ? {
634
636
  transformedValue: null
635
- } : d;
637
+ } : f2;
636
638
  }
637
- if (!qt(e, t)) {
638
- const d = Fe(e, t), f2 = d ? {
639
- transformedValue: d.value,
640
- annotations: [d.type]
639
+ if (!Dt(e, t)) {
640
+ const f2 = we(e, t), d = f2 ? {
641
+ transformedValue: f2.value,
642
+ annotations: [f2.type]
641
643
  } : {
642
644
  transformedValue: e
643
645
  };
644
- return o || i.set(e, f2), f2;
646
+ return a || i.set(e, d), d;
645
647
  }
646
- if (U(a, e))
648
+ if (j2(o, e))
647
649
  return {
648
650
  transformedValue: null
649
651
  };
650
- const u = Fe(e, t), l = (F = u == null ? undefined : u.value) != null ? F : e, p2 = N(l) ? [] : {}, m2 = {};
651
- B(l, (d, f2) => {
652
- if (f2 === "__proto__" || f2 === "constructor" || f2 === "prototype")
653
- throw new Error(`Detected property ${f2}. This is a prototype pollution risk, please remove it from your object.`);
654
- const w = Ie(d, r, t, s, [...n, f2], [...a, e], i);
655
- p2[f2] = w.transformedValue, N(w.annotations) ? m2[f2] = w.annotations : k(w.annotations) && B(w.annotations, (T2, A) => {
656
- m2[xe(f2) + "." + A] = T2;
652
+ const u = we(e, t), c2 = (x2 = u == null ? undefined : u.value) != null ? x2 : e, p2 = S(c2) ? [] : {}, m2 = {};
653
+ z2(c2, (f2, d) => {
654
+ if (d === "__proto__" || d === "constructor" || d === "prototype")
655
+ throw new Error(`Detected property ${d}. This is a prototype pollution risk, please remove it from your object.`);
656
+ const w = Le(f2, r, t, s, [...n, d], [...o, e], i);
657
+ p2[d] = w.transformedValue, S(w.annotations) ? m2[d] = w.annotations : k(w.annotations) && z2(w.annotations, ($, D) => {
658
+ m2[Te(d) + "." + D] = $;
657
659
  });
658
660
  });
659
- const y = G(m2) ? {
661
+ const y = X(m2) ? {
660
662
  transformedValue: p2,
661
663
  annotations: u ? [u.type] : undefined
662
664
  } : {
663
665
  transformedValue: p2,
664
666
  annotations: u ? [u.type, m2] : m2
665
667
  };
666
- return o || i.set(e, y), y;
668
+ return a || i.set(e, y), y;
667
669
  };
668
- function ze(e) {
670
+ function Ve2(e) {
669
671
  return Object.prototype.toString.call(e).slice(8, -1);
670
672
  }
671
- function we(e) {
672
- return ze(e) === "Array";
673
+ function qe(e) {
674
+ return Ve2(e) === "Array";
673
675
  }
674
- function $t(e) {
675
- if (ze(e) !== "Object")
676
+ function Tt(e) {
677
+ if (Ve2(e) !== "Object")
676
678
  return false;
677
679
  const r = Object.getPrototypeOf(e);
678
680
  return !!r && r.constructor === Object && r === Object.prototype;
679
681
  }
680
- function xt(e, r, t, s, n) {
681
- const a = {}.propertyIsEnumerable.call(s, r) ? "enumerable" : "nonenumerable";
682
- a === "enumerable" && (e[r] = t), n && a === "nonenumerable" && Object.defineProperty(e, r, {
682
+ function Nt(e, r, t, s, n) {
683
+ const o = {}.propertyIsEnumerable.call(s, r) ? "enumerable" : "nonenumerable";
684
+ o === "enumerable" && (e[r] = t), n && o === "nonenumerable" && Object.defineProperty(e, r, {
683
685
  value: t,
684
686
  enumerable: false,
685
687
  writable: true,
686
688
  configurable: true
687
689
  });
688
690
  }
689
- function ee(e, r = {}) {
690
- if (we(e))
691
- return e.map((n) => ee(n, r));
692
- if (!$t(e))
691
+ function re(e, r = {}) {
692
+ if (qe(e))
693
+ return e.map((n) => re(n, r));
694
+ if (!Tt(e))
693
695
  return e;
694
696
  const t = Object.getOwnPropertyNames(e), s = Object.getOwnPropertySymbols(e);
695
- return [...t, ...s].reduce((n, a) => {
696
- if (we(r.props) && !r.props.includes(a))
697
+ return [...t, ...s].reduce((n, o) => {
698
+ if (qe(r.props) && !r.props.includes(o))
697
699
  return n;
698
- const i = e[a], o = ee(i, r);
699
- return xt(n, a, o, e, r.nonenumerable), n;
700
+ const i = e[o], a = re(i, r);
701
+ return Nt(n, o, a, e, r.nonenumerable), n;
700
702
  }, {});
701
703
  }
702
704
 
703
- class c2 {
705
+ class l {
704
706
  constructor({ dedupe: r = false } = {}) {
705
- this.classRegistry = new Xr, this.symbolRegistry = new Ee((t) => {
707
+ this.classRegistry = new nt, this.symbolRegistry = new De((t) => {
706
708
  var s;
707
709
  return (s = t.description) != null ? s : "";
708
- }), this.customTransformerRegistry = new rt, this.allowedErrorProps = [], this.dedupe = r;
710
+ }), this.customTransformerRegistry = new at, this.allowedErrorProps = [], this.dedupe = r;
709
711
  }
710
712
  serialize(r) {
711
- const t = /* @__PURE__ */ new Map, s = Ie(r, t, this, this.dedupe), n = {
713
+ const t = /* @__PURE__ */ new Map, s = Le(r, t, this, this.dedupe), n = {
712
714
  json: s.transformedValue
713
715
  };
714
- s.annotations && (n.meta = E3(b2({}, n.meta), {
716
+ s.annotations && (n.meta = h2(g2({}, n.meta), {
715
717
  values: s.annotations
716
718
  }));
717
- const a = Ct2(t, this.dedupe);
718
- return a && (n.meta = E3(b2({}, n.meta), {
719
- referentialEqualities: a
719
+ const o = St(t, this.dedupe);
720
+ return o && (n.meta = h2(g2({}, n.meta), {
721
+ referentialEqualities: o
720
722
  })), n;
721
723
  }
722
724
  deserialize(r) {
723
725
  const { json: t, meta: s } = r;
724
- let n = ee(t);
725
- return s != null && s.values && (n = Ft(n, s.values, this)), s != null && s.referentialEqualities && (n = wt(n, s.referentialEqualities)), n;
726
+ let n = re(t);
727
+ return s != null && s.values && (n = At(n, s.values, this)), s != null && s.referentialEqualities && (n = xt2(n, s.referentialEqualities)), n;
726
728
  }
727
729
  stringify(r) {
728
730
  return JSON.stringify(this.serialize(r));
@@ -737,7 +739,7 @@ class c2 {
737
739
  this.symbolRegistry.register(r, t);
738
740
  }
739
741
  registerCustom(r, t) {
740
- this.customTransformerRegistry.register(b2({
742
+ this.customTransformerRegistry.register(g2({
741
743
  name: t
742
744
  }, r));
743
745
  }
@@ -745,236 +747,240 @@ class c2 {
745
747
  this.allowedErrorProps.push(...r);
746
748
  }
747
749
  }
748
- c2.defaultInstance = new c2;
749
- c2.serialize = c2.defaultInstance.serialize.bind(c2.defaultInstance);
750
- c2.deserialize = c2.defaultInstance.deserialize.bind(c2.defaultInstance);
751
- c2.stringify = c2.defaultInstance.stringify.bind(c2.defaultInstance);
752
- c2.parse = c2.defaultInstance.parse.bind(c2.defaultInstance);
753
- c2.registerClass = c2.defaultInstance.registerClass.bind(c2.defaultInstance);
754
- c2.registerSymbol = c2.defaultInstance.registerSymbol.bind(c2.defaultInstance);
755
- c2.registerCustom = c2.defaultInstance.registerCustom.bind(c2.defaultInstance);
756
- c2.allowErrorProps = c2.defaultInstance.allowErrorProps.bind(c2.defaultInstance);
757
- var O = (e) => e === undefined ? L.None : e;
758
- var At = (e) => new m(e.metadataItem, e.type);
759
- var ie = (e) => new Qe(e.name, e.expression, e.type, e.description, O(e.sort), e.dataSource, e.composeCode);
760
- var ae = (e) => new Y(e.name, e.expression, e.granularity, e.format, e.description, O(e.sort), e.dataSource, e.composeCode);
750
+ l.defaultInstance = new l;
751
+ l.serialize = l.defaultInstance.serialize.bind(l.defaultInstance);
752
+ l.deserialize = l.defaultInstance.deserialize.bind(l.defaultInstance);
753
+ l.stringify = l.defaultInstance.stringify.bind(l.defaultInstance);
754
+ l.parse = l.defaultInstance.parse.bind(l.defaultInstance);
755
+ l.registerClass = l.defaultInstance.registerClass.bind(l.defaultInstance);
756
+ l.registerSymbol = l.defaultInstance.registerSymbol.bind(l.defaultInstance);
757
+ l.registerCustom = l.defaultInstance.registerCustom.bind(l.defaultInstance);
758
+ l.allowErrorProps = l.defaultInstance.allowErrorProps.bind(l.defaultInstance);
759
+ var R2 = (e) => e === undefined ? C.None : e;
760
+ var Rt = (e) => new m(e.metadataItem, e.type);
761
+ var ae = (e) => new Ve(e.name, e.expression, e.type, e.description, R2(e.sort), e.dataSource, e.composeCode);
762
+ var ue = (e) => new Y(e.name, e.expression, e.granularity, e.format, e.description, R2(e.sort), e.dataSource, e.composeCode);
761
763
  var q3 = (e) => {
762
764
  switch (e.__serializable) {
763
765
  case "DimensionalAttribute":
764
- return ie(e);
765
- case "DimensionalLevelAttribute":
766
766
  return ae(e);
767
+ case "DimensionalLevelAttribute":
768
+ return ue(e);
767
769
  default:
768
770
  return e;
769
771
  }
770
772
  };
771
- var Be = (e) => new c(e.name, e.expression, e.attributes.map(q3), e.dimensions.map(Dt), e.type, e.description, O(e.sort), e.dataSource, e.composeCode, e.defaultAttribute ? q3(e.defaultAttribute) : undefined);
772
- var Pe = (e) => new p(e.name, e.expression, e.description, O(e.sort), e.dataSource, e.composeCode);
773
- var Dt = (e) => {
773
+ var _e = (e) => new c(e.name, e.expression, e.attributes.map(q3), e.dimensions.map(Ot), e.type, e.description, R2(e.sort), e.dataSource, e.composeCode, e.defaultAttribute ? q3(e.defaultAttribute) : undefined);
774
+ var Ue = (e) => new p(e.name, e.expression, e.description, R2(e.sort), e.dataSource, e.composeCode);
775
+ var Ot = (e) => {
774
776
  switch (e.__serializable) {
775
777
  case "DimensionalDimension":
776
- return Be(e);
778
+ return _e(e);
777
779
  case "DimensionalDateDimension":
778
- return Pe(e);
780
+ return Ue(e);
779
781
  default:
780
782
  return e;
781
783
  }
782
784
  };
783
- var oe = (e) => new ye(e.name, q3(e.attribute), e.aggregation, e.format, e.description, O(e.sort), e.dataSource, e.composeCode);
784
- var ue = (e) => {
785
+ var ce = (e) => new be(e.name, q3(e.attribute), e.aggregation, e.format, e.description, R2(e.sort), e.dataSource, e.composeCode);
786
+ var le = (e) => {
785
787
  const r = Object.fromEntries(Object.entries(e.context).map(([t, s]) => {
786
788
  if (s && typeof s == "object" && "__serializable" in s)
787
789
  switch (s.__serializable) {
788
790
  case "DimensionalAttribute":
789
- return [t, ie(s)];
790
- case "DimensionalLevelAttribute":
791
791
  return [t, ae(s)];
792
+ case "DimensionalLevelAttribute":
793
+ return [t, ue(s)];
792
794
  case "DimensionalBaseMeasure":
793
- return [t, oe(s)];
795
+ return [t, ce(s)];
794
796
  case "DimensionalCalculatedMeasure":
795
- return [t, ue(s)];
797
+ return [t, le(s)];
796
798
  default:
797
799
  return [t, s];
798
800
  }
799
801
  return [t, s];
800
802
  }));
801
- return new Z(e.name, e.expression, r, e.format, e.description, O(e.sort), e.dataSource, e.composeCode);
803
+ return new Z(e.name, e.expression, r, e.format, e.description, R2(e.sort), e.dataSource, e.composeCode);
802
804
  };
803
- var ke = (e) => new Qt(e.name, q3(e.attribute), e.format, e.description, O(e.sort), e.dataSource, e.composeCode);
805
+ var We = (e) => new Vt(e.name, q3(e.attribute), e.format, e.description, R2(e.sort), e.dataSource, e.composeCode);
804
806
  var H = (e) => {
805
807
  switch (e.__serializable) {
806
808
  case "DimensionalBaseMeasure":
807
- return oe(e);
809
+ return ce(e);
808
810
  case "DimensionalCalculatedMeasure":
809
- return ue(e);
811
+ return le(e);
810
812
  case "DimensionalMeasureTemplate":
811
- return ke(e);
813
+ return We(e);
812
814
  default:
813
815
  return e;
814
816
  }
815
817
  };
816
- var g2 = (e) => {
818
+ var b2 = (e) => {
817
819
  switch (e.__serializable) {
818
820
  case "MembersFilter":
819
- return new xd(q3(e.attribute), e.members, e.config.backgroundFilter ? E3(b2({}, e.config), { backgroundFilter: g2(e.config.backgroundFilter) }) : e.config, e.composeCode);
821
+ return new Ed(q3(e.attribute), e.members, e.config.backgroundFilter ? h2(g2({}, e.config), { backgroundFilter: b2(e.config.backgroundFilter) }) : e.config, e.composeCode);
820
822
  case "LogicalAttributeFilter":
821
- return new Bi(e.filters.map((t) => g2(t)), e.operator, e.config, e.composeCode);
823
+ return new Fi(e.filters.map((t) => b2(t)), e.operator, e.config, e.composeCode);
822
824
  case "CascadingFilter":
823
- return new wd(e._filters.map((t) => g2(t)), e.config, e.composeCode);
825
+ return new Od(e._filters.map((t) => b2(t)), e.config, e.composeCode);
824
826
  case "ExcludeFilter":
825
- return new Nd(g2(e.filter), e.input ? g2(e.input) : undefined, e.config, e.composeCode);
827
+ return new _d(b2(e.filter), e.input ? b2(e.input) : undefined, e.config, e.composeCode);
826
828
  case "MeasureFilter":
827
- return new Cd(q3(e.attribute), H(e.measure), e.operatorA, e.valueA, e.operatorB, e.valueB, e.config, e.composeCode);
829
+ return new xd(q3(e.attribute), H(e.measure), e.operatorA, e.valueA, e.operatorB, e.valueB, e.config, e.composeCode);
828
830
  case "RankingFilter":
829
- return new zi(q3(e.attribute), H(e.measure), e.operator, e.count, e.config, e.composeCode);
831
+ return new Ui(q3(e.attribute), H(e.measure), e.operator, e.count, e.config, e.composeCode);
830
832
  case "MeasureRankingFilter":
831
- return new Hi(H(e.measure), e.operator, e.count, e.config, e.composeCode);
833
+ return new Bi(H(e.measure), e.operator, e.count, e.config, e.composeCode);
832
834
  case "NumericFilter":
833
- return new Rd(q3(e.attribute), e.operatorA, e.valueA, e.operatorB, e.valueB, e.config, e.composeCode);
835
+ return new wd(q3(e.attribute), e.operatorA, e.valueA, e.operatorB, e.valueB, e.config, e.composeCode);
834
836
  case "TextFilter":
835
837
  return new ne(q3(e.attribute), e.operatorA, e.valueA, e.config, e.composeCode);
836
838
  case "DateRangeFilter": {
837
839
  const { valueA: t, valueB: s } = e;
838
- return new Ld(q3(e.attribute), t, s, e.config, e.composeCode);
840
+ return new Nd(q3(e.attribute), t, s, e.config, e.composeCode);
839
841
  }
840
842
  case "RelativeDateFilter":
841
- return new _r(q3(e.attribute), e.offset, e.count, e.operator, e.anchor, e.config, e.composeCode);
843
+ return new Or(q3(e.attribute), e.offset, e.count, e.operator, e.anchor, e.config, e.composeCode);
842
844
  case "CustomFilter":
843
- return new Md(q3(e.attribute), e.jaqlExpression, e.config, e.composeCode);
845
+ return new Cd(q3(e.attribute), e.jaqlExpression, e.config, e.composeCode);
844
846
  default:
845
847
  return e;
846
848
  }
847
849
  };
848
- c2.registerCustom({
850
+ l.registerCustom({
849
851
  isApplicable: h,
850
852
  serialize: (e) => e.serialize(),
851
- deserialize: (e) => At(e)
853
+ deserialize: (e) => Rt(e)
852
854
  }, "JaqlElement");
853
- c2.registerCustom({
854
- isApplicable: dp,
855
+ l.registerCustom({
856
+ isApplicable: fp,
855
857
  serialize: (e) => e.serialize(),
856
- deserialize: (e) => ie(e)
858
+ deserialize: (e) => ae(e)
857
859
  }, "DimensionalAttribute");
858
- c2.registerCustom({
859
- isApplicable: gp,
860
+ l.registerCustom({
861
+ isApplicable: dp,
860
862
  serialize: (e) => e.serialize(),
861
- deserialize: (e) => ae(e)
863
+ deserialize: (e) => ue(e)
862
864
  }, "DimensionalLevelAttribute");
863
- c2.registerCustom({
865
+ l.registerCustom({
864
866
  isApplicable: z,
865
867
  serialize: (e) => e.serialize(),
866
- deserialize: (e) => Be(e)
868
+ deserialize: (e) => _e(e)
867
869
  }, "DimensionalDimension");
868
- c2.registerCustom({
870
+ l.registerCustom({
869
871
  isApplicable: q,
870
872
  serialize: (e) => e.serialize(),
871
- deserialize: (e) => Pe(e)
873
+ deserialize: (e) => Ue(e)
872
874
  }, "DimensionalDateDimension");
873
- c2.registerCustom({
874
- isApplicable: ji,
875
+ l.registerCustom({
876
+ isApplicable: Ii,
875
877
  serialize: (e) => e.serialize(),
876
- deserialize: (e) => oe(e)
878
+ deserialize: (e) => ce(e)
877
879
  }, "DimensionalBaseMeasure");
878
- c2.registerCustom({
879
- isApplicable: kh,
880
+ l.registerCustom({
881
+ isApplicable: Hh,
880
882
  serialize: (e) => e.serialize(),
881
- deserialize: (e) => ue(e)
883
+ deserialize: (e) => le(e)
882
884
  }, "DimensionalCalculatedMeasure");
883
- c2.registerCustom({
884
- isApplicable: Wh,
885
+ l.registerCustom({
886
+ isApplicable: kh,
885
887
  serialize: (e) => e.serialize(),
886
- deserialize: (e) => ke(e)
888
+ deserialize: (e) => We(e)
887
889
  }, "DimensionalMeasureTemplate");
888
- c2.registerCustom({
889
- isApplicable: Vh,
890
+ l.registerCustom({
891
+ isApplicable: Wh,
890
892
  serialize: (e) => e.serialize(),
891
- deserialize: (e) => g2(e)
893
+ deserialize: (e) => b2(e)
892
894
  }, "MembersFilter");
893
- c2.registerCustom({
894
- isApplicable: Xh,
895
+ l.registerCustom({
896
+ isApplicable: Yh,
895
897
  serialize: (e) => e.serialize(),
896
- deserialize: (e) => g2(e)
898
+ deserialize: (e) => b2(e)
897
899
  }, "LogicalAttributeFilter");
898
- c2.registerCustom({
899
- isApplicable: Nt,
900
+ l.registerCustom({
901
+ isApplicable: xt,
900
902
  serialize: (e) => e.serialize(),
901
- deserialize: (e) => g2(e)
903
+ deserialize: (e) => b2(e)
902
904
  }, "CascadingFilter");
903
- c2.registerCustom({
904
- isApplicable: Zh,
905
+ l.registerCustom({
906
+ isApplicable: Jh,
905
907
  serialize: (e) => e.serialize(),
906
- deserialize: (e) => g2(e)
908
+ deserialize: (e) => b2(e)
907
909
  }, "ExcludeFilter");
908
- c2.registerCustom({
909
- isApplicable: Yh,
910
+ l.registerCustom({
911
+ isApplicable: Kh,
910
912
  serialize: (e) => e.serialize(),
911
- deserialize: (e) => g2(e)
913
+ deserialize: (e) => b2(e)
912
914
  }, "MeasureFilter");
913
- c2.registerCustom({
914
- isApplicable: Kh,
915
+ l.registerCustom({
916
+ isApplicable: Vh,
915
917
  serialize: (e) => e.serialize(),
916
- deserialize: (e) => g2(e)
918
+ deserialize: (e) => b2(e)
917
919
  }, "RankingFilter");
918
- c2.registerCustom({
919
- isApplicable: Jh,
920
+ l.registerCustom({
921
+ isApplicable: Qh,
920
922
  serialize: (e) => e.serialize(),
921
- deserialize: (e) => g2(e)
923
+ deserialize: (e) => b2(e)
922
924
  }, "MeasureRankingFilter");
923
- c2.registerCustom({
924
- isApplicable: Qh,
925
+ l.registerCustom({
926
+ isApplicable: Gh,
925
927
  serialize: (e) => e.serialize(),
926
- deserialize: (e) => g2(e)
928
+ deserialize: (e) => b2(e)
927
929
  }, "NumericFilter");
928
- c2.registerCustom({
929
- isApplicable: tp,
930
+ l.registerCustom({
931
+ isApplicable: Xh,
930
932
  serialize: (e) => e.serialize(),
931
- deserialize: (e) => g2(e)
933
+ deserialize: (e) => b2(e)
932
934
  }, "TextFilter");
933
- c2.registerCustom({
934
- isApplicable: rp,
935
+ l.registerCustom({
936
+ isApplicable: ep,
935
937
  serialize: (e) => e.serialize(),
936
- deserialize: (e) => g2(e)
938
+ deserialize: (e) => b2(e)
937
939
  }, "DateRangeFilter");
938
- c2.registerCustom({
939
- isApplicable: ep,
940
+ l.registerCustom({
941
+ isApplicable: Zh,
940
942
  serialize: (e) => e.serialize(),
941
- deserialize: (e) => g2(e)
943
+ deserialize: (e) => b2(e)
942
944
  }, "RelativeDateFilter");
943
- c2.registerCustom({
944
- isApplicable: Gh,
945
+ l.registerCustom({
946
+ isApplicable: qh,
945
947
  serialize: (e) => e.serialize(),
946
- deserialize: (e) => g2(e)
948
+ deserialize: (e) => b2(e)
947
949
  }, "CustomFilter");
948
- var Fs = c2;
949
- var h2 = "DM.";
950
- function x2(e) {
950
+ var Ps = l;
951
+ var F = "DM.";
952
+ function E3(e) {
951
953
  return typeof e == "object" && e !== null && "function" in e && "args" in e;
952
954
  }
953
- function le(e) {
954
- return e.every(x2);
955
+ function je(e) {
956
+ return e.every(E3);
955
957
  }
956
958
  function K(e) {
957
959
  return "attribute" in e && "config" in e;
958
960
  }
959
- function W(e) {
961
+ function U(e) {
960
962
  return "left" in e && "right" in e && "operator" in e;
961
963
  }
962
- function _e2(e) {
963
- return !K(e) && !W(e);
964
+ function fe(e) {
965
+ return !K(e) && !U(e);
966
+ }
967
+ function It(e) {
968
+ return typeof e == "object" && e !== null && "column" in e && typeof e.column == "string" && !(("function" in e) && ("args" in e));
964
969
  }
965
- function Mt(e) {
966
- return e.every((r) => typeof r == "string");
970
+ function zt(e) {
971
+ const r = e;
972
+ return typeof e != "object" || e === null || r === null || !("column" in r) ? false : E3(r.column);
967
973
  }
968
- function Nt2(e) {
969
- const r = [...e].sort((a, i) => i.name.length - a.name.length), t = /* @__PURE__ */ new Map, s = /* @__PURE__ */ new Map, n = /* @__PURE__ */ new Map;
970
- for (const a of e) {
971
- t.set(a.name, a);
972
- const i = [...a.columns].sort((u, l) => l.name.length - u.name.length);
973
- n.set(a.name, i);
974
- const o = /* @__PURE__ */ new Map;
975
- for (const u of a.columns)
976
- o.set(u.name, u);
977
- s.set(a.name, o);
974
+ function Bt(e) {
975
+ const r = [...e].sort((o, i) => i.name.length - o.name.length), t = /* @__PURE__ */ new Map, s = /* @__PURE__ */ new Map, n = /* @__PURE__ */ new Map;
976
+ for (const o of e) {
977
+ t.set(o.name, o);
978
+ const i = [...o.columns].sort((u, c2) => c2.name.length - u.name.length);
979
+ n.set(o.name, i);
980
+ const a = /* @__PURE__ */ new Map;
981
+ for (const u of o.columns)
982
+ a.set(u.name, u);
983
+ s.set(o.name, a);
978
984
  }
979
985
  return {
980
986
  sortedTables: r,
@@ -983,34 +989,34 @@ function Nt2(e) {
983
989
  columnMap: s
984
990
  };
985
991
  }
986
- function Le(e, r) {
987
- if (!e.startsWith(h2))
988
- throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${h2}TableName.ColumnName[.Level]"`);
989
- const t = e.slice(h2.length);
992
+ function Je(e, r) {
993
+ if (!e.startsWith(F))
994
+ throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
995
+ const t = e.slice(F.length);
990
996
  if (!t)
991
- throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${h2}TableName.ColumnName[.Level]"`);
997
+ throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
992
998
  let s, n;
993
999
  for (const m2 of r.sortedTables)
994
1000
  if (t.startsWith(m2.name + ".")) {
995
1001
  const y = t.slice(m2.name.length + 1);
996
1002
  if (!y)
997
- throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${h2}TableName.ColumnName[.Level]"`);
1003
+ throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
998
1004
  s = m2, n = y;
999
1005
  break;
1000
1006
  }
1001
1007
  if (!s) {
1002
1008
  const m2 = t.indexOf(".");
1003
1009
  if (m2 === -1)
1004
- throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${h2}TableName.ColumnName[.Level]"`);
1010
+ throw new Error(`Invalid dimensional element name format: "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
1005
1011
  const y = t.slice(0, m2);
1006
1012
  throw new Error(`Table "${y}" not found in the data model`);
1007
1013
  }
1008
- const a = r.tableColumnMap.get(s.name);
1009
- if (!a)
1014
+ const o = r.tableColumnMap.get(s.name);
1015
+ if (!o)
1010
1016
  throw new Error(`Table "${s.name}" found but has no columns`);
1011
- let i, o;
1017
+ let i, a;
1012
1018
  const u = g.all;
1013
- for (const m2 of a) {
1019
+ for (const m2 of o) {
1014
1020
  if (n === m2.name)
1015
1021
  return { table: s, column: m2 };
1016
1022
  if (!n.startsWith(m2.name + "."))
@@ -1018,55 +1024,55 @@ function Le(e, r) {
1018
1024
  const y = n.slice(m2.name.length + 1);
1019
1025
  if (!y)
1020
1026
  continue;
1021
- const F = u.includes(y), d = Nr(m2.dataType);
1022
- if (F) {
1023
- if (d)
1027
+ const x2 = u.includes(y), f2 = wr(m2.dataType);
1028
+ if (x2) {
1029
+ if (f2)
1024
1030
  return { table: s, column: m2, level: y };
1025
- i || (i = m2, o = y);
1031
+ i || (i = m2, a = y);
1026
1032
  continue;
1027
1033
  }
1028
- d && !i && (i = m2, o = y);
1034
+ f2 && !i && (i = m2, a = y);
1029
1035
  }
1030
- if (i && o)
1031
- throw u.includes(o) ? new Error(`Invalid date level "${o}" in dimensional element "${e}". Column "${s.name}.${i.name}" is not a datetime column`) : new Error(`Invalid date level "${o}" in dimensional element "${e}". Valid levels are: ${u.join(", ")}`);
1032
- const l = n.indexOf("."), p2 = l === -1 ? n : n.slice(0, l);
1036
+ if (i && a)
1037
+ throw u.includes(a) ? new Error(`Invalid date level "${a}" in dimensional element "${e}". Column "${s.name}.${i.name}" is not a datetime column`) : new Error(`Invalid date level "${a}" in dimensional element "${e}". Valid levels are: ${u.join(", ")}`);
1038
+ const c2 = n.indexOf("."), p2 = c2 === -1 ? n : n.slice(0, c2);
1033
1039
  throw new Error(`Column "${p2}" not found in table "${s.name}"`);
1034
1040
  }
1035
- function Rt(e, r) {
1036
- const { table: t, column: s, level: n } = Le(e, r);
1041
+ function Pt(e, r) {
1042
+ const { table: t, column: s, level: n } = Je(e, r);
1037
1043
  if (n) {
1038
- if (!Nr(s.dataType))
1044
+ if (!wr(s.dataType))
1039
1045
  throw new Error(`Invalid date level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is not a datetime column`);
1040
- const a = g.all;
1041
- if (!a.includes(n))
1042
- throw new Error(`Invalid date level "${n}" in dimensional element "${e}". Valid levels are: ${a.join(", ")}`);
1046
+ const o = g.all;
1047
+ if (!o.includes(n))
1048
+ throw new Error(`Invalid date level "${n}" in dimensional element "${e}". Valid levels are: ${o.join(", ")}`);
1043
1049
  const i = g.dateOnly;
1044
1050
  if (s.dataType === "date" && !i.includes(n))
1045
1051
  throw new Error(`Invalid level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is only a date column, not a datetime column`);
1046
- const o = g.timeOnly;
1047
- if (s.dataType === "time" && !o.includes(n))
1052
+ const a = g.timeOnly;
1053
+ if (s.dataType === "time" && !a.includes(n))
1048
1054
  throw new Error(`Invalid level "${n}" in dimensional element "${e}". Column "${t.name}.${s.name}" is only a time column, not a date column`);
1049
1055
  }
1050
1056
  return { column: s, level: n };
1051
1057
  }
1052
- function Ve(e) {
1058
+ function Ke(e) {
1053
1059
  return e.type === E.TextAttribute;
1054
1060
  }
1055
- function We(e) {
1061
+ function Ge(e) {
1056
1062
  return e.type === E.NumericAttribute;
1057
1063
  }
1058
- function St(e) {
1064
+ function kt(e) {
1059
1065
  return e.type === E.DateLevel;
1060
1066
  }
1061
- function Ot(e) {
1062
- return Ve(e) || We(e);
1067
+ function Lt(e) {
1068
+ return Ke(e) || Ge(e);
1063
1069
  }
1064
- function Q(e) {
1070
+ function G(e) {
1065
1071
  return e.type === E.TextAttribute ? "text" : e.type === E.NumericAttribute ? "numeric" : e.type === E.DateLevel ? "date/datetime" : "unknown";
1066
1072
  }
1067
- function ce(e, r, t) {
1068
- const { column: s, level: n } = Rt(e, t);
1069
- return Cr({
1073
+ function Q(e, r, t) {
1074
+ const { column: s, level: n } = Pt(e, t);
1075
+ return Nr({
1070
1076
  expression: s.expression,
1071
1077
  dataType: s.dataType,
1072
1078
  granularity: n,
@@ -1075,11 +1081,11 @@ function ce(e, r, t) {
1075
1081
  dataSource: r
1076
1082
  });
1077
1083
  }
1078
- function Tt(e, r, t) {
1079
- const { column: s, level: n } = Le(e, t);
1084
+ function Vt2(e, r, t) {
1085
+ const { column: s, level: n } = Je(e, t);
1080
1086
  if (n)
1081
- throw new Error(`Invalid DateDimension name format: "${e}". Expected format: "${h2}TableName.ColumnName"`);
1082
- if (!Nr(s.dataType))
1087
+ throw new Error(`Invalid DateDimension name format: "${e}". Expected format: "${F}TableName.ColumnName"`);
1088
+ if (!wr(s.dataType))
1083
1089
  throw new Error(`Invalid DateDimension name "${e}". Column "${s.name}" is not a datetime column (got ${s.dataType}).`);
1084
1090
  return x({
1085
1091
  name: s.name,
@@ -1091,11 +1097,31 @@ function M(e, r) {
1091
1097
  const t = e();
1092
1098
  return t.success ? t.data : (r.push(...t.errors), null);
1093
1099
  }
1094
- var It = (e) => {
1100
+ var _t = (e, r, t) => {
1101
+ if (!r)
1102
+ return { attribute: e };
1103
+ const s = typeof r == "object" ? r.direction : r;
1104
+ return mp(s) ? { attribute: e.sort(ap(s)) } : {
1105
+ attribute: e,
1106
+ error: h2(g2({}, t), {
1107
+ message: `Invalid sort type. Expected "sortAsc", "sortDesc", or "sortNone". Got: "${s}".`
1108
+ })
1109
+ };
1110
+ };
1111
+ var Ut = (e, r, t, s) => {
1112
+ const n = Q(e.column, r, t);
1113
+ return _t(n, e.sortType, s);
1114
+ };
1115
+ var Wt = (e, r, t, s) => typeof e == "string" ? { attribute: Q(e, r, t) } : It(e) ? Ut(e, r, t, s) : {
1116
+ error: h2(g2({}, s), {
1117
+ message: 'Invalid dimension item. Expected a string (composeCode) or object with "column" and optional "sortType".'
1118
+ })
1119
+ };
1120
+ var jt = (e) => {
1095
1121
  const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
1096
1122
  if (!r)
1097
1123
  return { success: true, data: [] };
1098
- if (!Mt(r))
1124
+ if (!Array.isArray(r))
1099
1125
  return {
1100
1126
  success: false,
1101
1127
  errors: [
@@ -1103,68 +1129,118 @@ var It = (e) => {
1103
1129
  category: "dimensions",
1104
1130
  index: -1,
1105
1131
  input: r,
1106
- message: "Invalid dimensions JSON. Expected an array of strings."
1132
+ message: "Invalid dimensions JSON. Expected an array."
1107
1133
  }
1108
1134
  ]
1109
1135
  };
1110
- const n = [], a = [];
1111
- return r.forEach((i, o) => {
1136
+ const n = [], o = [];
1137
+ return r.forEach((i, a) => {
1112
1138
  const u = {
1113
1139
  category: "dimensions",
1114
- index: o,
1140
+ index: a,
1115
1141
  input: i
1116
1142
  };
1117
1143
  try {
1118
- const l = ce(i, t, s);
1119
- n.push(l);
1120
- } catch (l) {
1121
- const p2 = l instanceof Error ? l.message : "Unknown error";
1122
- a.push(E3(b2({}, u), { message: p2 }));
1144
+ const c2 = Wt(i, t, s, u);
1145
+ if (c2.error) {
1146
+ o.push(c2.error);
1147
+ return;
1148
+ }
1149
+ c2.attribute && n.push(c2.attribute);
1150
+ } catch (c2) {
1151
+ const p2 = c2 instanceof Error ? c2.message : "Unknown error";
1152
+ o.push(h2(g2({}, u), { message: p2 }));
1123
1153
  }
1124
- }), a.length > 0 ? { success: false, errors: a } : { success: true, data: n };
1154
+ }), o.length > 0 ? { success: false, errors: o } : { success: true, data: n };
1125
1155
  };
1126
- function fe(e, r) {
1156
+ function de(e, r) {
1127
1157
  const t = Reflect.get(e, r);
1128
1158
  if (typeof t != "function")
1129
1159
  throw new Error(`Function "${r}" not found or is not a function`);
1130
1160
  return t;
1131
1161
  }
1132
- function zt(e, r) {
1133
- const t = e.replace("measureFactory.", ""), n = fe(qh, t)(...r);
1134
- if (!_e2(n))
1162
+ function Jt2(e, r) {
1163
+ const t = e.replace("measureFactory.", ""), n = de(zh, t)(...r);
1164
+ if (!fe(n))
1135
1165
  throw new Error(`Function "${e}" did not return a valid Measure`);
1136
1166
  return n;
1137
1167
  }
1138
- function Bt(e, r) {
1139
- const t = e.replace("filterFactory.logic.", ""), n = fe(Se, t)(...r);
1140
- if (!W(n))
1168
+ function Kt(e, r) {
1169
+ const t = e.replace("filterFactory.logic.", ""), n = de(ye, t)(...r);
1170
+ if (!U(n))
1141
1171
  throw new Error(`Function "${e}" did not return a valid FilterRelations`);
1142
1172
  return n;
1143
1173
  }
1144
- function Pt(e, r) {
1174
+ function Gt(e, r) {
1145
1175
  if (e.startsWith("filterFactory.logic."))
1146
- return Bt(e, r);
1147
- const t = e.replace("filterFactory.", ""), n = fe(np, t)(...r);
1148
- if (!K(n) && !W(n))
1176
+ return Kt(e, r);
1177
+ const t = e.replace("filterFactory.", ""), n = de(tp, t)(...r);
1178
+ if (!K(n) && !U(n))
1149
1179
  throw new Error(`Function "${e}" did not return a valid Filter or FilterRelations`);
1150
1180
  return n;
1151
1181
  }
1152
- function kt(e, r) {
1182
+ function Qt(e, r) {
1153
1183
  const s = e.split(".")[0];
1154
1184
  if (s === "measureFactory")
1155
- return zt(e, r);
1185
+ return Jt2(e, r);
1156
1186
  if (s === "filterFactory")
1157
- return Pt(e, r);
1187
+ return Gt(e, r);
1158
1188
  throw new Error(`Unsupported factory: "${s}". Supported factories: measureFactory, filterFactory`);
1159
1189
  }
1160
- var _t = /\[([a-zA-Z_][a-zA-Z0-9_.-]*)\]/g;
1161
- function Lt(e, r, t = {}) {
1190
+ var Yt = /\[(\w[\w.-]*)\]/g;
1191
+ var Qe = /* @__PURE__ */ new Set([
1192
+ "AVG",
1193
+ "COUNT",
1194
+ "DUPCOUNT",
1195
+ "LARGEST",
1196
+ "MAX",
1197
+ "MEDIAN",
1198
+ "MIN",
1199
+ "MODE",
1200
+ "SUM",
1201
+ "WTDAVG",
1202
+ "WTDSUM",
1203
+ "MTDAVG",
1204
+ "MTDSUM",
1205
+ "QTDAVG",
1206
+ "QTDSUM",
1207
+ "YTDAVG",
1208
+ "YTDSUM",
1209
+ "CORREL",
1210
+ "COVARP",
1211
+ "COVAR",
1212
+ "SKEWP",
1213
+ "SKEW",
1214
+ "SLOPE"
1215
+ ]);
1216
+ var Ht = new RegExp(`\\b(${Array.from(Qe).join("|")})\\s*\\(`, "i");
1217
+ function Zt(e) {
1218
+ return E3(e) ? true : typeof e == "string" && e.startsWith(F) ? false : e && typeof e == "object" && ("kind" in e) ? e.kind === "measure" : true;
1219
+ }
1220
+ function Xt(e) {
1221
+ const r = /\b(\w+)\s*\(/g, t = /* @__PURE__ */ new Set;
1222
+ let s;
1223
+ for (;(s = r.exec(e)) !== null; ) {
1224
+ const n = s[1];
1225
+ Qe.has(n.toUpperCase()) || t.add(n);
1226
+ }
1227
+ return Array.from(t);
1228
+ }
1229
+ function vt(e) {
1230
+ return e.length === 1 ? `[${e[0]}]` : e.map((r) => `[${r}]`).join(", ");
1231
+ }
1232
+ function es(e) {
1233
+ return e.length === 0 ? "" : e.length === 1 ? `${e[0]} is not an aggregative function. ` : `${e.join(", ")} are not aggregative functions. `;
1234
+ }
1235
+ var B = (e) => e.startsWith("[") ? e : `[${e}]`;
1236
+ var Ee = (e) => e.startsWith("[") && e.endsWith("]") ? e.slice(1, -1) : e;
1237
+ function rs(e, r, t = {}) {
1162
1238
  const {
1163
1239
  warnUnusedContext: s = true,
1164
1240
  errorOnUnusedContext: n = true,
1165
- allowEmptyFormula: a = false,
1241
+ allowEmptyFormula: o = false,
1166
1242
  errorPrefix: i = "customFormula validation"
1167
- } = t, o = {
1243
+ } = t, a = {
1168
1244
  isValid: true,
1169
1245
  errors: [],
1170
1246
  warnings: [],
@@ -1172,138 +1248,140 @@ function Lt(e, r, t = {}) {
1172
1248
  unusedContextKeys: []
1173
1249
  };
1174
1250
  if (!e || e.trim().length === 0)
1175
- return a || (o.errors.push(`${i}args[1]: Formula cannot be empty`), o.isValid = false), o;
1176
- const u = /\b\w+\s*\[/gi, l = e.match(u);
1177
- if (l) {
1178
- const f2 = l[0].replace(/\s*\[.*$/, "");
1179
- o.errors.push(`${i}args[1]: Invalid syntax: '${f2}' - operator cannot be used before bracket reference without parentheses`), o.isValid = false;
1180
- }
1181
- const p2 = _t, m2 = /* @__PURE__ */ new Set;
1182
- let y;
1183
- for (;(y = p2.exec(e)) !== null; ) {
1184
- const f2 = y[1];
1185
- m2.add(f2);
1186
- }
1187
- o.references = Array.from(m2);
1188
- const F = Object.keys(r);
1189
- if (o.references.length > 0 && (/\b\w+\s*\(/gi.test(e) || o.references.every((A) => {
1190
- if (!(A in r))
1191
- return false;
1192
- const D = r[A];
1193
- return x2(D) ? false : typeof D == "string" && D.startsWith(h2) ? true : D && typeof D == "object" && ("kind" in D) ? D.kind !== "measure" : false;
1194
- }) && (o.errors.push(`${i}args[1]: Formulas with bracket references must contain aggregate function calls`), o.isValid = false)), o.references.length === 0)
1195
- return o.warnings.push(`${i}args[1]: No bracket references found in formula - ensure this is intentional`), o;
1196
- if (F.length === 0)
1197
- return o.errors.push(`${i}args[2]: Context cannot be empty - custom formulas require context definitions`), o.isValid = false, o;
1198
- const d = [];
1199
- for (const f2 of o.references)
1200
- F.includes(f2) || d.push(f2);
1201
- if (d.length > 0 && (o.isValid = false, d.length === 1 ? o.errors.push(`${i}args[1]: Reference [${d[0]}] not found in context. Available keys: ${F.join(", ")}`) : o.errors.push(`${i}args[1]: References [${d.join("], [")}] not found in context. Available keys: ${F.join(", ")}`)), (s || n) && F.length > 0) {
1202
- const f2 = F.filter((w) => !o.references.includes(w));
1203
- if (o.unusedContextKeys = f2, f2.length > 0) {
1204
- const w = `${i}args[2]: Context keys [${f2.join(", ")}] are defined but not used in formula`;
1205
- n ? (o.errors.push(w), o.isValid = false) : s && o.warnings.push(w);
1251
+ return o || (a.errors.push(`${i}args[1]: Formula cannot be empty`), a.isValid = false), a;
1252
+ const u = /\b\w+\s*\[/gi, c2 = e.match(u);
1253
+ if (c2) {
1254
+ const f2 = c2[0].replace(/\s*\[.*$/, "");
1255
+ a.errors.push(`${i}args[1]: Invalid syntax: '${f2}' - operator cannot be used before bracket reference without parentheses`), a.isValid = false;
1256
+ }
1257
+ a.references = [
1258
+ ...new Set([...e.matchAll(new RegExp(Yt.source, "g"))].map((f2) => f2[1]))
1259
+ ];
1260
+ const p2 = Object.keys(r);
1261
+ if (a.references.length === 0)
1262
+ return a.warnings.push(`${i}args[1]: No bracket references found in formula - ensure this is intentional`), a;
1263
+ if (p2.length === 0)
1264
+ return a.errors.push(`${i}args[2]: Context cannot be empty - custom formulas require context definitions`), a.isValid = false, a;
1265
+ const m2 = new Set(p2.map(B)), y = a.references.filter((f2) => !m2.has(B(f2)));
1266
+ if (y.length > 0) {
1267
+ a.isValid = false;
1268
+ const f2 = p2.map((d) => `[${Ee(d)}]`).join(", ");
1269
+ y.length === 1 ? a.errors.push(`${i}args[1]: Reference [${y[0]}] not found in context. Available keys: ${f2}`) : a.errors.push(`${i}args[1]: References [${y.join("], [")}] not found in context. Available keys: ${f2}`);
1270
+ }
1271
+ if (!Ht.test(e)) {
1272
+ const f2 = a.references.filter((d) => {
1273
+ var $;
1274
+ const w = ($ = r[B(d)]) != null ? $ : r[d];
1275
+ return w !== undefined && !Zt(w);
1276
+ });
1277
+ f2.length > 0 && (a.errors.push(`${i}args[1]: ${es(Xt(e))}Bracket reference(s) ${vt(f2)} point to raw attributes and must be wrapped in an aggregative function (e.g. SUM, AVG)`), a.isValid = false);
1278
+ }
1279
+ if ((s || n) && p2.length > 0) {
1280
+ const f2 = new Set(a.references.map(B)), d = p2.filter((w) => !f2.has(B(w)));
1281
+ if (a.unusedContextKeys = d, d.length > 0) {
1282
+ const w = d.map((D) => `[${Ee(D)}]`).join(", "), $ = `${i}args[2]: Context keys ${w} are defined but not used in formula`;
1283
+ n ? (a.errors.push($), a.isValid = false) : s && a.warnings.push($);
1206
1284
  }
1207
1285
  }
1208
- return o;
1286
+ return a;
1209
1287
  }
1210
- function Vt(e, r, t = {}) {
1211
- const s = Lt(e, r, t);
1288
+ function ts(e, r, t = {}) {
1289
+ const s = rs(e, r, t);
1212
1290
  if (!s.isValid)
1213
1291
  throw new Error(s.errors.join("; "));
1214
1292
  s.warnings.length > 0 && console.warn("Formula validation warnings:", s.warnings.join("; "));
1215
1293
  }
1216
- function Wt(e, r) {
1294
+ function ss(e, r) {
1217
1295
  if (e.length < 3 || e.length > 5)
1218
1296
  throw new Error(`${r.pathPrefix}Expected 3, 4, or 5 arguments for customFormula (title, formula, context, format?, description?)`);
1219
1297
  const t = e[1], s = e[2];
1220
- Vt(t, s, {
1298
+ ts(t, s, {
1221
1299
  errorPrefix: `${r.pathPrefix}`,
1222
1300
  errorOnUnusedContext: true,
1223
1301
  allowEmptyFormula: false
1224
1302
  });
1225
1303
  const n = {};
1226
- for (const [a, i] of Object.entries(s)) {
1227
- const o = `args[2].${a}`;
1228
- if (x2(i))
1229
- n[`${a}`] = C({
1304
+ for (const [o, i] of Object.entries(s)) {
1305
+ const a = `args[2].${o}`;
1306
+ if (E3(i))
1307
+ n[`${o}`] = C2({
1230
1308
  data: i,
1231
1309
  context: {
1232
1310
  dataSource: r.dataSource,
1233
1311
  schemaIndex: r.schemaIndex,
1234
- pathPrefix: o
1312
+ pathPrefix: a
1235
1313
  }
1236
1314
  });
1237
- else if (typeof i == "string" && i.startsWith(h2))
1315
+ else if (typeof i == "string" && i.startsWith(F))
1238
1316
  try {
1239
- n[`${a}`] = ce(i, r.dataSource, r.schemaIndex);
1317
+ n[`${o}`] = Q(i, r.dataSource, r.schemaIndex);
1240
1318
  } catch (u) {
1241
- const l = u instanceof Error ? u.message : "Unknown error";
1242
- throw new Error(`${o}: ${l}`);
1319
+ const c2 = u instanceof Error ? u.message : "Unknown error";
1320
+ throw new Error(`${a}: ${c2}`);
1243
1321
  }
1244
1322
  else if (i && typeof i == "object" && "kind" in i)
1245
- n[`${a}`] = i;
1323
+ n[`${o}`] = i;
1246
1324
  else
1247
- throw new Error(`${o}: Invalid context value for key '${a}'. Expected a function call or attribute reference (${h2}...), but got: ${typeof i}`);
1325
+ throw new Error(`${a}: Invalid context value for key '${o}'. Expected a function call or attribute reference (${F}...), but got: ${typeof i}`);
1248
1326
  }
1249
1327
  e[2] = n;
1250
1328
  }
1251
- function de(e, r) {
1329
+ function me2(e, r) {
1252
1330
  const t = e[0];
1253
1331
  if (!t || typeof t != "object" || !("type" in t))
1254
1332
  throw new Error(`${r.pathPrefix}args[0]: Expected attribute as first argument`);
1255
1333
  return t;
1256
1334
  }
1257
- function qe(e, r) {
1258
- const t = de(e, r);
1259
- if (!Ot(t))
1260
- throw new Error(`${r.pathPrefix}args[0]: Attribute must be string or numeric type, got ${Q(t)} attribute`);
1335
+ function Ce(e, r) {
1336
+ const t = me2(e, r);
1337
+ if (!Lt(t))
1338
+ throw new Error(`${r.pathPrefix}args[0]: Attribute must be string or numeric type, got ${G(t)} attribute`);
1261
1339
  }
1262
- function R2(e, r) {
1263
- const t = de(e, r);
1264
- if (!We(t))
1265
- throw new Error(`${r.pathPrefix}args[0]: Attribute must be numeric type, got ${Q(t)} attribute`);
1340
+ function T2(e, r) {
1341
+ const t = me2(e, r);
1342
+ if (!Ge(t))
1343
+ throw new Error(`${r.pathPrefix}args[0]: Attribute must be numeric type, got ${G(t)} attribute`);
1266
1344
  }
1267
- function S(e, r) {
1268
- const t = de(e, r);
1269
- if (!Ve(t))
1270
- throw new Error(`${r.pathPrefix}args[0]: Attribute must be string type, got ${Q(t)} attribute`);
1345
+ function N(e, r) {
1346
+ const t = me2(e, r);
1347
+ if (!Ke(t))
1348
+ throw new Error(`${r.pathPrefix}args[0]: Attribute must be string type, got ${G(t)} attribute`);
1271
1349
  }
1272
- function Jt(e, r) {
1350
+ function ns(e, r) {
1273
1351
  const t = e[0];
1274
1352
  if (!t || typeof t != "object" || !("attribute" in t))
1275
1353
  throw new Error(`${r.pathPrefix}args[0]: Expected filter as first argument`);
1276
1354
  return t;
1277
1355
  }
1278
- function Ut(e, r) {
1279
- const t = Jt(e, r);
1280
- if (!Vh(t))
1356
+ function is(e, r) {
1357
+ const t = ns(e, r);
1358
+ if (!Wh(t))
1281
1359
  throw new Error(`${r.pathPrefix}args[0]: exclude filter only accepts members filter, got ${t.__serializable || "unknown"} filter`);
1282
1360
  }
1283
- var jt = {
1284
- "measureFactory.customFormula": Wt,
1285
- "filterFactory.equals": qe,
1286
- "filterFactory.doesntEqual": qe,
1287
- "filterFactory.greaterThan": R2,
1288
- "filterFactory.greaterThanOrEqual": R2,
1289
- "filterFactory.lessThan": R2,
1290
- "filterFactory.lessThanOrEqual": R2,
1291
- "filterFactory.between": R2,
1292
- "filterFactory.betweenNotEqual": R2,
1293
- "filterFactory.numeric": R2,
1294
- "filterFactory.contains": S,
1295
- "filterFactory.doesntContain": S,
1296
- "filterFactory.startsWith": S,
1297
- "filterFactory.doesntStartWith": S,
1298
- "filterFactory.endsWith": S,
1299
- "filterFactory.doesntEndWith": S,
1300
- "filterFactory.like": S,
1301
- "filterFactory.exclude": Ut
1361
+ var os = {
1362
+ "measureFactory.customFormula": ss,
1363
+ "filterFactory.equals": Ce,
1364
+ "filterFactory.doesntEqual": Ce,
1365
+ "filterFactory.greaterThan": T2,
1366
+ "filterFactory.greaterThanOrEqual": T2,
1367
+ "filterFactory.lessThan": T2,
1368
+ "filterFactory.lessThanOrEqual": T2,
1369
+ "filterFactory.between": T2,
1370
+ "filterFactory.betweenNotEqual": T2,
1371
+ "filterFactory.numeric": T2,
1372
+ "filterFactory.contains": N,
1373
+ "filterFactory.doesntContain": N,
1374
+ "filterFactory.startsWith": N,
1375
+ "filterFactory.doesntStartWith": N,
1376
+ "filterFactory.endsWith": N,
1377
+ "filterFactory.doesntEndWith": N,
1378
+ "filterFactory.like": N,
1379
+ "filterFactory.exclude": is
1302
1380
  };
1303
- function Kt(e) {
1304
- return jt[`${e}`];
1381
+ function as(e) {
1382
+ return os[`${e}`];
1305
1383
  }
1306
- var Qt2 = {
1384
+ var us = {
1307
1385
  "measureFactory.sum": [
1308
1386
  { type: "Attribute", required: true },
1309
1387
  { type: "string", required: false },
@@ -1722,18 +1800,18 @@ var Qt2 = {
1722
1800
  { type: "FilterRelationsNode", required: true }
1723
1801
  ]
1724
1802
  };
1725
- function me(e) {
1726
- return Qt2[`${e}`];
1803
+ function pe(e) {
1804
+ return us[`${e}`];
1727
1805
  }
1728
- function Yt2(e) {
1729
- const r = me(e);
1806
+ function cs(e) {
1807
+ const r = pe(e);
1730
1808
  return r ? r.filter((t) => t.required).length : 0;
1731
1809
  }
1732
- function Ht(e) {
1733
- const r = me(e);
1810
+ function ls(e) {
1811
+ const r = pe(e);
1734
1812
  return r ? r.length : 0;
1735
1813
  }
1736
- function Zt(e) {
1814
+ function fs(e) {
1737
1815
  if (typeof e != "string" || !/^\d{4}-\d{2}-\d{2}/.test(e))
1738
1816
  return false;
1739
1817
  const t = Date.parse(e);
@@ -1743,259 +1821,260 @@ function Zt(e) {
1743
1821
  return !isNaN(s.getTime());
1744
1822
  }
1745
1823
  function Z2(e, r, t, s) {
1746
- if (e.startsWith(h2))
1824
+ if (e.startsWith(F))
1747
1825
  try {
1748
- return ce(e, r, t);
1826
+ return Q(e, r, t);
1749
1827
  } catch (n) {
1750
- const a = n instanceof Error ? n.message : "Unknown error";
1751
- throw new Error(`${s}: ${a}`);
1828
+ const o = n instanceof Error ? n.message : "Unknown error";
1829
+ throw new Error(`${s}: ${o}`);
1752
1830
  }
1753
- throw new Error(`${s}: Invalid attribute "${e}". Expected format: "${h2}TableName.ColumnName[.Level]"`);
1831
+ throw new Error(`${s}: Invalid attribute "${e}". Expected format: "${F}TableName.ColumnName[.Level]"`);
1754
1832
  }
1755
- function Gt(e, r, t, s) {
1756
- if (e.startsWith(h2))
1833
+ function ds(e, r, t, s) {
1834
+ if (e.startsWith(F))
1757
1835
  try {
1758
- return Tt(e, r, t);
1836
+ return Vt2(e, r, t);
1759
1837
  } catch (n) {
1760
- const a = n instanceof Error ? n.message : "Unknown error";
1761
- throw new Error(`${s}: ${a}`);
1838
+ const o = n instanceof Error ? n.message : "Unknown error";
1839
+ throw new Error(`${s}: ${o}`);
1762
1840
  }
1763
- throw new Error(`${s}: Invalid date dimension string "${e}". Expected format: "${h2}TableName.ColumnName"`);
1841
+ throw new Error(`${s}: Invalid date dimension string "${e}". Expected format: "${F}TableName.ColumnName"`);
1764
1842
  }
1765
- function Xt(e) {
1766
- const r = e.data, { argSchema: t, dataSource: s, schemaIndex: n, pathPrefix: a } = e.context, i = a;
1843
+ function ms(e) {
1844
+ const r = e.data, { argSchema: t, dataSource: s, schemaIndex: n, pathPrefix: o } = e.context, i = o;
1767
1845
  if (r === undefined) {
1768
1846
  if (t.required)
1769
1847
  throw new Error(`${i}: Required argument is missing (expected ${t.type})`);
1770
1848
  return;
1771
1849
  }
1772
- switch (t.type) {
1773
- case "string":
1774
- if (typeof r != "string")
1775
- throw new Error(`${i}: Expected string, got ${typeof r}`);
1776
- return r;
1777
- case "number":
1778
- if (typeof r != "number")
1779
- throw new Error(`${i}: Expected number, got ${typeof r}`);
1780
- return r;
1781
- case "boolean":
1782
- if (typeof r != "boolean")
1783
- throw new Error(`${i}: Expected boolean, got ${typeof r}`);
1784
- return r;
1785
- case "string[]":
1786
- if (!Array.isArray(r))
1787
- throw new Error(`${i}: Expected array of strings, got ${typeof r}. Example: ["value1", "value2"]`);
1788
- if (!r.every((o) => typeof o == "string"))
1789
- throw new Error(`${i}: Expected array of strings, but contains non-string values`);
1790
- return r;
1791
- case "number[]":
1792
- if (!Array.isArray(r))
1793
- throw new Error(`${i}: Expected array of numbers, got ${typeof r}. Example: [10, 20]`);
1794
- if (!r.every((o) => typeof o == "number"))
1795
- throw new Error(`${i}: Expected array of numbers, but contains non-number values`);
1796
- return r;
1797
- case "Attribute":
1798
- if (typeof r != "string")
1799
- throw new Error(`${i}: Expected attribute string, got ${typeof r}. Example: "DM.Commerce.Revenue"`);
1800
- return Z2(r, s, n, i);
1801
- case "Attribute[]":
1802
- if (!Array.isArray(r))
1803
- throw new Error(`${i}: Expected array of attributes, got ${typeof r}. Example: ["DM.Commerce.AgeRange"]`);
1804
- return r.map((o, u) => {
1805
- if (typeof o != "string")
1806
- throw new Error(`${i}[${u}]: Expected attribute string, got ${typeof o}`);
1807
- return Z2(o, s, n, `${i}[${u}]`);
1808
- });
1809
- case "Measure":
1810
- case "BaseMeasure":
1811
- if (!x2(r))
1812
- throw new Error(`${i}: Expected measure function call, got ${typeof r}. Example: {"function": "measureFactory.sum", "args": ["DM.Commerce.Revenue"]}`);
1813
- return C({
1814
- data: r,
1815
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
1816
- });
1817
- case "Measure[]":
1818
- if (!Array.isArray(r))
1819
- throw new Error(`${i}: Expected array of measure function calls, got ${typeof r}`);
1820
- return r.map((o, u) => {
1821
- if (!x2(o))
1822
- throw new Error(`${i}[${u}]: Expected measure function call, got ${typeof o}`);
1823
- return C({
1824
- data: o,
1825
- context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
1850
+ if (!(r === null && !t.required))
1851
+ switch (t.type) {
1852
+ case "string":
1853
+ if (typeof r != "string")
1854
+ throw new Error(`${i}: Expected string, got ${typeof r}`);
1855
+ return r;
1856
+ case "number":
1857
+ if (typeof r != "number")
1858
+ throw new Error(`${i}: Expected number, got ${typeof r}`);
1859
+ return r;
1860
+ case "boolean":
1861
+ if (typeof r != "boolean")
1862
+ throw new Error(`${i}: Expected boolean, got ${typeof r}`);
1863
+ return r;
1864
+ case "string[]":
1865
+ if (!Array.isArray(r))
1866
+ throw new Error(`${i}: Expected array of strings, got ${typeof r}. Example: ["value1", "value2"]`);
1867
+ if (!r.every((a) => typeof a == "string"))
1868
+ throw new Error(`${i}: Expected array of strings, but contains non-string values`);
1869
+ return r;
1870
+ case "number[]":
1871
+ if (!Array.isArray(r))
1872
+ throw new Error(`${i}: Expected array of numbers, got ${typeof r}. Example: [10, 20]`);
1873
+ if (!r.every((a) => typeof a == "number"))
1874
+ throw new Error(`${i}: Expected array of numbers, but contains non-number values`);
1875
+ return r;
1876
+ case "Attribute":
1877
+ if (typeof r != "string")
1878
+ throw new Error(`${i}: Expected attribute string, got ${typeof r}. Example: "DM.Commerce.Revenue"`);
1879
+ return Z2(r, s, n, i);
1880
+ case "Attribute[]":
1881
+ if (!Array.isArray(r))
1882
+ throw new Error(`${i}: Expected array of attributes, got ${typeof r}. Example: ["DM.Commerce.AgeRange"]`);
1883
+ return r.map((a, u) => {
1884
+ if (typeof a != "string")
1885
+ throw new Error(`${i}[${u}]: Expected attribute string, got ${typeof a}`);
1886
+ return Z2(a, s, n, `${i}[${u}]`);
1826
1887
  });
1827
- });
1828
- case "Filter":
1829
- if (!x2(r))
1830
- throw new Error(`${i}: Expected filter function call, got ${typeof r}. Example: {"function": "filterFactory.contains", "args": ["DM.Brand.Brand", "Apple"]}`);
1831
- return C({
1832
- data: r,
1833
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
1834
- });
1835
- case "Filter[]":
1836
- if (!Array.isArray(r))
1837
- throw new Error(`${i}: Expected array of filter function calls, got ${typeof r}`);
1838
- return r.map((o, u) => {
1839
- if (!x2(o))
1840
- throw new Error(`${i}[${u}]: Expected filter function call, got ${typeof o}`);
1841
- return C({
1842
- data: o,
1843
- context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
1888
+ case "Measure":
1889
+ case "BaseMeasure":
1890
+ if (!E3(r))
1891
+ throw new Error(`${i}: Expected measure function call, got ${typeof r}. Example: {"function": "measureFactory.sum", "args": ["DM.Commerce.Revenue"]}`);
1892
+ return C2({
1893
+ data: r,
1894
+ context: { dataSource: s, schemaIndex: n, pathPrefix: i }
1844
1895
  });
1845
- });
1846
- case "FilterRelationsNode":
1847
- if (Array.isArray(r))
1848
- return r.map((o, u) => {
1849
- if (!x2(o))
1850
- throw new Error(`${i}[${u}]: Expected filter function call, got ${typeof o}`);
1851
- return C({
1852
- data: o,
1896
+ case "Measure[]":
1897
+ if (!Array.isArray(r))
1898
+ throw new Error(`${i}: Expected array of measure function calls, got ${typeof r}`);
1899
+ return r.map((a, u) => {
1900
+ if (!E3(a))
1901
+ throw new Error(`${i}[${u}]: Expected measure function call, got ${typeof a}`);
1902
+ return C2({
1903
+ data: a,
1853
1904
  context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
1854
1905
  });
1855
1906
  });
1856
- if (x2(r))
1857
- return C({
1907
+ case "Filter":
1908
+ if (!E3(r))
1909
+ throw new Error(`${i}: Expected filter function call, got ${typeof r}. Example: {"function": "filterFactory.contains", "args": ["DM.Brand.Brand", "Apple"]}`);
1910
+ return C2({
1858
1911
  data: r,
1859
1912
  context: { dataSource: s, schemaIndex: n, pathPrefix: i }
1860
1913
  });
1861
- throw new Error(`${i}: Expected filter function call or array of filters, got ${typeof r}`);
1862
- case "DateDimension":
1863
- if (typeof r != "string")
1864
- throw new Error(`${i}: Expected date dimension string, got ${typeof r}. Example: "DM.Commerce.Date"`);
1865
- return Gt(r, s, n, i);
1866
- case "LevelAttribute": {
1867
- if (typeof r != "string")
1868
- throw new Error(`${i}: Expected date attribute string, got ${typeof r}. Example: "DM.Commerce.Date.Years"`);
1869
- const o = Z2(r, s, n, i);
1870
- if (!St(o))
1871
- throw new Error(`${i}: Attribute must be date/datetime type, got ${Q(o)} attribute`);
1872
- return o;
1873
- }
1874
- case "Measure | number":
1875
- if (typeof r == "number")
1876
- return r;
1877
- if (x2(r))
1878
- return C({
1879
- data: r,
1880
- context: { dataSource: s, schemaIndex: n, pathPrefix: i }
1914
+ case "Filter[]":
1915
+ if (!Array.isArray(r))
1916
+ throw new Error(`${i}: Expected array of filter function calls, got ${typeof r}`);
1917
+ return r.map((a, u) => {
1918
+ if (!E3(a))
1919
+ throw new Error(`${i}[${u}]: Expected filter function call, got ${typeof a}`);
1920
+ return C2({
1921
+ data: a,
1922
+ context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
1923
+ });
1881
1924
  });
1882
- throw new Error(`${i}: Expected measure function call or number, got ${typeof r}`);
1883
- case "Date | string":
1884
- if (typeof r == "string") {
1885
- if (Zt(r))
1925
+ case "FilterRelationsNode":
1926
+ if (Array.isArray(r))
1927
+ return r.map((a, u) => {
1928
+ if (!E3(a))
1929
+ throw new Error(`${i}[${u}]: Expected filter function call, got ${typeof a}`);
1930
+ return C2({
1931
+ data: a,
1932
+ context: { dataSource: s, schemaIndex: n, pathPrefix: `${i}[${u}]` }
1933
+ });
1934
+ });
1935
+ if (E3(r))
1936
+ return C2({
1937
+ data: r,
1938
+ context: { dataSource: s, schemaIndex: n, pathPrefix: i }
1939
+ });
1940
+ throw new Error(`${i}: Expected filter function call or array of filters, got ${typeof r}`);
1941
+ case "DateDimension":
1942
+ if (typeof r != "string")
1943
+ throw new Error(`${i}: Expected date dimension string, got ${typeof r}. Example: "DM.Commerce.Date"`);
1944
+ return ds(r, s, n, i);
1945
+ case "LevelAttribute": {
1946
+ if (typeof r != "string")
1947
+ throw new Error(`${i}: Expected date attribute string, got ${typeof r}. Example: "DM.Commerce.Date.Years"`);
1948
+ const a = Z2(r, s, n, i);
1949
+ if (!kt(a))
1950
+ throw new Error(`${i}: Attribute must be date/datetime type, got ${G(a)} attribute`);
1951
+ return a;
1952
+ }
1953
+ case "Measure | number":
1954
+ if (typeof r == "number")
1886
1955
  return r;
1887
- throw new Error(`${i}: Expected valid ISO date string or Date object, got invalid date string "${r}"`);
1888
- } else {
1889
- if (r instanceof Date)
1956
+ if (E3(r))
1957
+ return C2({
1958
+ data: r,
1959
+ context: { dataSource: s, schemaIndex: n, pathPrefix: i }
1960
+ });
1961
+ throw new Error(`${i}: Expected measure function call or number, got ${typeof r}`);
1962
+ case "Date | string":
1963
+ if (typeof r == "string") {
1964
+ if (fs(r))
1965
+ return r;
1966
+ throw new Error(`${i}: Expected valid ISO date string or Date object, got invalid date string "${r}"`);
1967
+ } else {
1968
+ if (r instanceof Date)
1969
+ return r;
1970
+ throw new Error(`${i}: Expected date string or Date object, got ${typeof r}`);
1971
+ }
1972
+ case "string | number":
1973
+ if (typeof r == "string" || typeof r == "number")
1890
1974
  return r;
1891
- throw new Error(`${i}: Expected date string or Date object, got ${typeof r}`);
1892
- }
1893
- case "string | number":
1894
- if (typeof r == "string" || typeof r == "number")
1975
+ throw new Error(`${i}: Expected string or number, got ${typeof r}`);
1976
+ case "BaseFilterConfig":
1977
+ case "MembersFilterConfig":
1978
+ case "CustomFormulaContext":
1979
+ case "any":
1980
+ if (r == null && t.required)
1981
+ throw new Error(`${i}: Required argument is null/undefined`);
1895
1982
  return r;
1896
- throw new Error(`${i}: Expected string or number, got ${typeof r}`);
1897
- case "BaseFilterConfig":
1898
- case "MembersFilterConfig":
1899
- case "CustomFormulaContext":
1900
- case "any":
1901
- if (r == null && t.required)
1902
- throw new Error(`${i}: Required argument is null/undefined`);
1903
- return r;
1904
- default:
1905
- return r;
1906
- }
1983
+ default:
1984
+ return r;
1985
+ }
1907
1986
  }
1908
- function C(e) {
1909
- const { data: r } = e, { dataSource: t, schemaIndex: s, pathPrefix: n } = e.context, { function: a, args: i } = r, o = n ? `${n}.` : "", u = me(a);
1987
+ function C2(e) {
1988
+ const { data: r } = e, { dataSource: t, schemaIndex: s, pathPrefix: n } = e.context, { function: o, args: i } = r, a = n ? `${n}.` : "", u = pe(o);
1910
1989
  if (!u)
1911
- throw new Error(`${o}function: Unknown function "${a}"`);
1912
- const l = Yt2(a), p2 = Ht(a);
1913
- if (i.length < l)
1914
- throw new Error(`${o}function: Expected at least ${l} arguments, got ${i.length}`);
1990
+ throw new Error(`${a}function: Unknown function "${o}"`);
1991
+ const c2 = cs(o), p2 = ls(o);
1992
+ if (i.length < c2)
1993
+ throw new Error(`${a}function: Expected at least ${c2} arguments, got ${i.length}`);
1915
1994
  if (i.length > p2)
1916
- throw new Error(`${o}function: Expected at most ${p2} arguments, got ${i.length}`);
1995
+ throw new Error(`${a}function: Expected at most ${p2} arguments, got ${i.length}`);
1917
1996
  const m2 = [], y = [];
1918
- for (let d = 0;d < Math.max(i.length, u.length); d++) {
1919
- const f2 = u[`${d}`], w = i[`${d}`], T2 = o ? `${o}args[${d}]` : `args[${d}]`;
1997
+ for (let f2 = 0;f2 < Math.max(i.length, u.length); f2++) {
1998
+ const d = u[`${f2}`], w = i[`${f2}`], $ = a ? `${a}args[${f2}]` : `args[${f2}]`;
1920
1999
  if (w === undefined) {
1921
- f2 != null && f2.required && y.push(`${T2}: Missing required argument (expected ${f2.type})`);
2000
+ d != null && d.required && y.push(`${$}: Missing required argument (expected ${d.type})`);
1922
2001
  continue;
1923
2002
  }
1924
- if (!f2) {
1925
- y.push(`${T2}: Unexpected argument`);
2003
+ if (!d) {
2004
+ y.push(`${$}: Unexpected argument`);
1926
2005
  continue;
1927
2006
  }
1928
2007
  try {
1929
- const A = Xt({
2008
+ const D = ms({
1930
2009
  data: w,
1931
2010
  context: {
1932
2011
  dataSource: t,
1933
2012
  schemaIndex: s,
1934
- pathPrefix: T2,
1935
- argSchema: f2
2013
+ pathPrefix: $,
2014
+ argSchema: d
1936
2015
  }
1937
2016
  });
1938
- m2.push(A);
1939
- } catch (A) {
1940
- const D = A instanceof Error ? A.message : "Unknown error";
1941
- y.push(D);
2017
+ m2.push(D);
2018
+ } catch (D) {
2019
+ const ve = D instanceof Error ? D.message : "Unknown error";
2020
+ y.push(ve);
1942
2021
  }
1943
2022
  }
1944
2023
  if (y.length > 0) {
1945
- const d = y.join("; ");
1946
- throw new Error(d);
2024
+ const f2 = y.join("; ");
2025
+ throw new Error(f2);
1947
2026
  }
1948
- const F = Kt(a);
1949
- if (F)
2027
+ const x2 = as(o);
2028
+ if (x2)
1950
2029
  try {
1951
- F(m2, {
2030
+ x2(m2, {
1952
2031
  dataSource: t,
1953
2032
  schemaIndex: s,
1954
- pathPrefix: o
2033
+ pathPrefix: a
1955
2034
  });
1956
- } catch (d) {
1957
- const f2 = d instanceof Error ? d.message : "Unknown validation error";
1958
- throw new Error(f2);
2035
+ } catch (f2) {
2036
+ const d = f2 instanceof Error ? f2.message : "Unknown validation error";
2037
+ throw new Error(d);
1959
2038
  }
1960
- return kt(a, m2);
2039
+ return Qt(o, m2);
1961
2040
  }
1962
- function Je(e) {
2041
+ function Ye(e) {
1963
2042
  const { attribute: r, config: t } = e;
1964
- if (Vh(e) && mp(r)) {
1965
- const { granularity: s } = r, n = e.members.map((o) => s === "Years" && !isNaN(Number(o)) ? `${o}-01-01T00:00:00` : o), a = Fi(t), i = Object.keys(a).length === 0 ? undefined : a;
1966
- return Ct(r, n, i);
2043
+ if (Wh(e) && pp(r)) {
2044
+ const { granularity: s } = r, n = e.members.map((a) => s === "Years" && !isNaN(Number(a)) ? `${a}-01-01T00:00:00` : a), o = ji(t), i = Object.keys(o).length === 0 ? undefined : o;
2045
+ return wt(r, n, i);
1967
2046
  }
1968
2047
  return e;
1969
2048
  }
1970
- function vt(e) {
2049
+ function ps(e) {
1971
2050
  let r = [];
1972
2051
  for (const t of e)
1973
- W(t) ? r = bp(t, r) : r = bp([Je(t)], r);
2052
+ U(t) ? r = bp(t, r) : r = bp([Ye(t)], r);
1974
2053
  return r != null ? r : [];
1975
2054
  }
1976
- var es = (e) => {
1977
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], a = [];
1978
- return r.forEach((i, o) => {
2055
+ var ys2 = (e) => {
2056
+ const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], o = [];
2057
+ return r.forEach((i, a) => {
1979
2058
  const u = {
1980
2059
  category: "filters",
1981
- index: o,
2060
+ index: a,
1982
2061
  input: i
1983
2062
  };
1984
2063
  try {
1985
- const l = C({
2064
+ const c2 = C2({
1986
2065
  data: i,
1987
2066
  context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
1988
2067
  });
1989
- !W(l) && !K(l) ? a.push(E3(b2({}, u), { message: "Invalid filter JSON" })) : n.push(l);
1990
- } catch (l) {
1991
- const p2 = l instanceof Error ? l.message : "Unknown error";
1992
- a.push(E3(b2({}, u), { message: p2 }));
2068
+ !U(c2) && !K(c2) ? o.push(h2(g2({}, u), { message: "Invalid filter JSON" })) : n.push(c2);
2069
+ } catch (c2) {
2070
+ const p2 = c2 instanceof Error ? c2.message : "Unknown error";
2071
+ o.push(h2(g2({}, u), { message: p2 }));
1993
2072
  }
1994
- }), a.length > 0 ? { success: false, errors: a } : { success: true, data: vt(n) };
2073
+ }), o.length > 0 ? { success: false, errors: o } : { success: true, data: ps(n) };
1995
2074
  };
1996
- var rs = (e) => {
2075
+ var gs = (e) => {
1997
2076
  const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
1998
- return r ? le(r) ? es({
2077
+ return r ? je(r) ? ys2({
1999
2078
  data: r,
2000
2079
  context: { dataSource: t, schemaIndex: s }
2001
2080
  }) : {
@@ -2010,29 +2089,29 @@ var rs = (e) => {
2010
2089
  ]
2011
2090
  } : { success: true, data: [] };
2012
2091
  };
2013
- var ts = (e) => {
2014
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], a = [];
2015
- return r.forEach((i, o) => {
2092
+ var hs = (e) => {
2093
+ const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], o = [];
2094
+ return r.forEach((i, a) => {
2016
2095
  const u = {
2017
2096
  category: "highlights",
2018
- index: o,
2097
+ index: a,
2019
2098
  input: i
2020
2099
  };
2021
2100
  try {
2022
- const l = C({
2101
+ const c2 = C2({
2023
2102
  data: i,
2024
2103
  context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
2025
2104
  });
2026
- K(l) ? n.push(Je(l)) : a.push(E3(b2({}, u), { message: "Invalid filter JSON" }));
2027
- } catch (l) {
2028
- const p2 = l instanceof Error ? l.message : "Unknown error";
2029
- a.push(E3(b2({}, u), { message: p2 }));
2105
+ K(c2) ? n.push(Ye(c2)) : o.push(h2(g2({}, u), { message: "Invalid filter JSON" }));
2106
+ } catch (c2) {
2107
+ const p2 = c2 instanceof Error ? c2.message : "Unknown error";
2108
+ o.push(h2(g2({}, u), { message: p2 }));
2030
2109
  }
2031
- }), a.length > 0 ? { success: false, errors: a } : { success: true, data: n };
2110
+ }), o.length > 0 ? { success: false, errors: o } : { success: true, data: n };
2032
2111
  };
2033
- var ss = (e) => {
2112
+ var bs = (e) => {
2034
2113
  const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2035
- return r ? le(r) ? ts({
2114
+ return r ? je(r) ? hs({
2036
2115
  data: r,
2037
2116
  context: { dataSource: t, schemaIndex: s }
2038
2117
  }) : {
@@ -2047,73 +2126,117 @@ var ss = (e) => {
2047
2126
  ]
2048
2127
  } : { success: true, data: [] };
2049
2128
  };
2050
- var ns = (e) => {
2051
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context, n = [], a = [];
2052
- return r.forEach((i, o) => {
2129
+ var Fs = (e, r, t) => {
2130
+ const { dataSource: s, schemaIndex: n } = r;
2131
+ try {
2132
+ const o = C2({
2133
+ data: e,
2134
+ context: { dataSource: s, schemaIndex: n, pathPrefix: "" }
2135
+ });
2136
+ return fe(o) ? { success: true, data: o } : {
2137
+ success: false,
2138
+ errors: [h2(g2({}, t), { message: "Invalid measure JSON" })]
2139
+ };
2140
+ } catch (o) {
2141
+ const i = o instanceof Error ? o.message : "Unknown error";
2142
+ return {
2143
+ success: false,
2144
+ errors: [h2(g2({}, t), { message: i })]
2145
+ };
2146
+ }
2147
+ };
2148
+ var ws = (e, r, t) => r ? mp(r) ? { measure: e.sort(ap(r)) } : {
2149
+ measure: e,
2150
+ error: h2(g2({}, t), {
2151
+ message: `Invalid sort type. Expected "sortAsc", "sortDesc", or "sortNone". Got: "${r}".`
2152
+ })
2153
+ } : { measure: e };
2154
+ var qs = (e, r, t, s) => {
2155
+ const n = C2({
2156
+ data: e.column,
2157
+ context: { dataSource: r, schemaIndex: t, pathPrefix: "" }
2158
+ });
2159
+ return fe(n) ? ws(n, e.sortType, s) : { error: h2(g2({}, s), { message: "Invalid measure JSON" }) };
2160
+ };
2161
+ var Es = (e, r, t, s) => {
2162
+ if (zt(e))
2163
+ return qs(e, r, t, s);
2164
+ if (E3(e)) {
2165
+ const n = Fs(e, { dataSource: r, schemaIndex: t }, s);
2166
+ return n.success ? { measure: n.data } : { error: n.errors[0] };
2167
+ }
2168
+ return {
2169
+ error: h2(g2({}, s), {
2170
+ message: 'Invalid measure item. Expected a function call (function/args) or object with "column" and optional "sortType".'
2171
+ })
2172
+ };
2173
+ };
2174
+ var Cs = (e) => {
2175
+ const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2176
+ if (!r)
2177
+ return { success: true, data: [] };
2178
+ if (!Array.isArray(r))
2179
+ return {
2180
+ success: false,
2181
+ errors: [
2182
+ {
2183
+ category: "measures",
2184
+ index: -1,
2185
+ input: r,
2186
+ message: "Invalid measures JSON. Expected an array."
2187
+ }
2188
+ ]
2189
+ };
2190
+ const n = [], o = [];
2191
+ return r.forEach((i, a) => {
2053
2192
  const u = {
2054
2193
  category: "measures",
2055
- index: o,
2194
+ index: a,
2056
2195
  input: i
2057
2196
  };
2058
2197
  try {
2059
- const l = C({
2060
- data: i,
2061
- context: { dataSource: t, schemaIndex: s, pathPrefix: "" }
2062
- });
2063
- _e2(l) ? n.push(l) : a.push(E3(b2({}, u), { message: "Invalid measure JSON" }));
2064
- } catch (l) {
2065
- const p2 = l instanceof Error ? l.message : "Unknown error";
2066
- a.push(E3(b2({}, u), { message: p2 }));
2067
- }
2068
- }), a.length > 0 ? { success: false, errors: a } : { success: true, data: n };
2069
- };
2070
- var is = (e) => {
2071
- const { data: r } = e, { dataSource: t, schemaIndex: s } = e.context;
2072
- return r ? le(r) ? ns({
2073
- data: r,
2074
- context: { dataSource: t, schemaIndex: s }
2075
- }) : {
2076
- success: false,
2077
- errors: [
2078
- {
2079
- category: "measures",
2080
- index: -1,
2081
- input: r,
2082
- message: 'Invalid measures JSON. Expected an array of function calls with "function" and "args" properties.'
2198
+ const c2 = Es(i, t, s, u);
2199
+ if (c2.error) {
2200
+ o.push(c2.error);
2201
+ return;
2083
2202
  }
2084
- ]
2085
- } : { success: true, data: [] };
2203
+ c2.measure && n.push(c2.measure);
2204
+ } catch (c2) {
2205
+ const p2 = c2 instanceof Error ? c2.message : "Unknown error";
2206
+ o.push(h2(g2({}, u), { message: p2 }));
2207
+ }
2208
+ }), o.length > 0 ? { success: false, errors: o } : { success: true, data: n };
2086
2209
  };
2087
- var ws = (e) => {
2088
- const { data: r } = e, { dataSource: t, tables: s } = e.context, n = Nt2(s), a = [], i = M(() => It({
2210
+ var ks = (e) => {
2211
+ const { data: r } = e, { dataSource: t, tables: s } = e.context, n = Bt(s), o = [], i = M(() => jt({
2089
2212
  data: r.dimensions || [],
2090
2213
  context: { dataSource: t, schemaIndex: n }
2091
- }), a), o = M(() => is({
2214
+ }), o), a = M(() => Cs({
2092
2215
  data: r.measures || [],
2093
2216
  context: { dataSource: t, schemaIndex: n }
2094
- }), a), u = M(() => rs({
2217
+ }), o), u = M(() => gs({
2095
2218
  data: r.filters || [],
2096
2219
  context: { dataSource: t, schemaIndex: n }
2097
- }), a);
2098
- let l = null;
2099
- return r.highlights && (l = M(() => ss({
2220
+ }), o);
2221
+ let c2 = null;
2222
+ return r.highlights && (c2 = M(() => bs({
2100
2223
  data: r.highlights || [],
2101
2224
  context: { dataSource: t, schemaIndex: n }
2102
- }), a)), a.length > 0 ? {
2225
+ }), o)), o.length > 0 ? {
2103
2226
  success: false,
2104
- errors: a
2227
+ errors: o
2105
2228
  } : {
2106
2229
  success: true,
2107
- data: b2({
2108
- dataSource: ap(t),
2230
+ data: g2({
2231
+ dataSource: ip(t),
2109
2232
  dimensions: i || [],
2110
- measures: o || [],
2233
+ measures: a || [],
2111
2234
  filters: u || []
2112
- }, l && { highlights: l })
2235
+ }, c2 && { highlights: c2 })
2113
2236
  };
2114
2237
  };
2115
- function ps(e) {
2116
- const { filters: r, relations: t } = ip(e.filters || []);
2238
+ function Rs(e) {
2239
+ const { filters: r, relations: t } = rp(e.filters || []);
2117
2240
  return {
2118
2241
  dataSource: e.dataSource,
2119
2242
  dimensions: e.dimensions,
@@ -2123,9 +2246,9 @@ function ps(e) {
2123
2246
  highlights: e.highlights
2124
2247
  };
2125
2248
  }
2126
- function Es(e, r, t = false) {
2127
- const s = ps(e), n = $r(s, r);
2128
- return Sh(n, t);
2249
+ function Vs(e, r, t = false) {
2250
+ const s = Rs(e), n = Dr(s, r);
2251
+ return bh(n, t);
2129
2252
  }
2130
2253
 
2131
- export { c, R, x, Fs, ws, Es };
2254
+ export { c, R, x, Ps, ks, Vs };