@dcupl/common 2.0.0-beta.1 → 2.0.0-beta.10

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 (36) hide show
  1. package/dist/esm/analytics.controller.d.ts +1 -1
  2. package/dist/esm/changeDetection.d.ts +2 -2
  3. package/dist/esm/computeSuggestions.d.ts +2 -2
  4. package/dist/esm/deep-query.service.d.ts +26 -1
  5. package/dist/esm/getAggregation.d.ts +1 -1
  6. package/dist/esm/getFacets.d.ts +26 -3
  7. package/dist/esm/helper.d.ts +1 -1
  8. package/dist/esm/index.d.ts +23 -22
  9. package/dist/esm/index.js +766 -599
  10. package/dist/esm/index.js.map +1 -1
  11. package/dist/esm/indices.controller.d.ts +1 -1
  12. package/dist/esm/logger/index.d.ts +2 -2
  13. package/dist/esm/pivot.d.ts +2 -2
  14. package/dist/esm/property-parser.d.ts +27 -2
  15. package/dist/esm/query-builder.d.ts +2 -2
  16. package/dist/esm/query.helper.d.ts +1 -1
  17. package/dist/esm/queryData.d.ts +2 -2
  18. package/dist/esm/resource-id.d.ts +43 -0
  19. package/dist/esm/types/app-loader.types.d.ts +94 -4
  20. package/dist/esm/types/data.types.d.ts +7 -3
  21. package/dist/esm/types/dcupl.types.d.ts +21 -9
  22. package/dist/esm/types/facets.types.d.ts +6 -1
  23. package/dist/esm/types/filter.types.d.ts +3 -3
  24. package/dist/esm/types/group-by.types.d.ts +2 -2
  25. package/dist/esm/types/index.d.ts +17 -16
  26. package/dist/esm/types/internal.types.d.ts +1 -1
  27. package/dist/esm/types/key-property.types.d.ts +11 -0
  28. package/dist/esm/types/list.types.d.ts +20 -4
  29. package/dist/esm/types/model.types.d.ts +54 -5
  30. package/dist/esm/types/quality.types.d.ts +59 -1
  31. package/dist/esm/types/query.types.d.ts +19 -10
  32. package/dist/esm/types/section.types.d.ts +2 -2
  33. package/dist/esm/types/suggestion.types.d.ts +1 -1
  34. package/dist/node/index.cjs +2 -2
  35. package/dist/node/index.cjs.map +1 -1
  36. package/package.json +2 -2
package/dist/esm/index.js CHANGED
@@ -1,47 +1,47 @@
1
- import { cloneDeep as y, get as v, every as B, findIndex as C, size as W, isEqual as E, differenceBy as q, startsWith as L, endsWith as H, isEqualWith as b, isMatch as U, find as V } from "lodash-es";
2
- function I(o) {
3
- const e = K(o);
4
- return J(e);
1
+ import { cloneDeep as v, get as I, every as z, findIndex as E, size as W, isEqual as $, differenceBy as O, startsWith as H, endsWith as U, isEqualWith as S, isMatch as V, find as J } from "lodash-es";
2
+ function K(n) {
3
+ const e = k(n);
4
+ return Z(e);
5
5
  }
6
- function K(o) {
7
- if (typeof o != "object" || o === null)
8
- return String(o);
9
- if (Array.isArray(o))
10
- return "[" + o.map(K).join(",") + "]";
11
- const e = Object.keys(o).sort();
6
+ function k(n) {
7
+ if (typeof n != "object" || n === null)
8
+ return String(n);
9
+ if (Array.isArray(n))
10
+ return "[" + n.map(k).join(",") + "]";
11
+ const e = Object.keys(n).sort();
12
12
  let t = "{";
13
13
  for (let r = 0; r < e.length; r++) {
14
14
  const s = e[r];
15
- t += s + ":" + K(o[s]), r < e.length - 1 && (t += ",");
15
+ t += s + ":" + k(n[s]), r < e.length - 1 && (t += ",");
16
16
  }
17
17
  return t += "}", t;
18
18
  }
19
- function J(o) {
19
+ function Z(n) {
20
20
  let e = 0;
21
- for (let t = 0; t < o.length; t++) {
22
- const r = o.charCodeAt(t);
21
+ for (let t = 0; t < n.length; t++) {
22
+ const r = n.charCodeAt(t);
23
23
  e = (e << 5) - e + r, e |= 0;
24
24
  }
25
25
  return e.toString(16);
26
26
  }
27
- const x = {
27
+ const b = {
28
28
  now: () => typeof performance < "u" && performance.now ? performance.now() : (/* @__PURE__ */ new Date()).getTime(),
29
- mark: (o) => {
30
- typeof performance < "u" && performance.mark && performance.mark(o);
29
+ mark: (n) => {
30
+ typeof performance < "u" && performance.mark && performance.mark(n);
31
31
  },
32
- measure: (o, e, t) => {
33
- typeof performance < "u" && performance.measure && performance.measure(o, e, t);
32
+ measure: (n, e, t) => {
33
+ typeof performance < "u" && performance.measure && performance.measure(n, e, t);
34
34
  },
35
- getEntriesByName(o) {
35
+ getEntriesByName(n) {
36
36
  if (typeof performance < "u" && performance.getEntriesByName)
37
- return performance.getEntriesByName(o);
37
+ return performance.getEntriesByName(n);
38
38
  },
39
- getEntriesByType(o) {
39
+ getEntriesByType(n) {
40
40
  if (typeof performance < "u" && performance.getEntriesByType)
41
- return performance.getEntriesByType(o);
41
+ return performance.getEntriesByType(n);
42
42
  }
43
43
  };
44
- class De {
44
+ class Re {
45
45
  data;
46
46
  enabled = !1;
47
47
  constructor() {
@@ -59,7 +59,7 @@ class De {
59
59
  const t = this.getKey(e.name, e.context), r = {
60
60
  name: e.name,
61
61
  type: "mark",
62
- value: x.now(),
62
+ value: b.now(),
63
63
  createdAt: Date.now()
64
64
  };
65
65
  return this.data.set(t, r), r;
@@ -69,21 +69,21 @@ class De {
69
69
  const t = this.getKey(e.name, e.context), r = this.data.get(this.getKey(e.start, e.context)), s = this.data.get(this.getKey(e.end, e.context));
70
70
  if (!r || !s)
71
71
  return;
72
- const i = s.value - r.value, n = Math.round(i * 100) / 100, a = this.data.get(t);
72
+ const i = s.value - r.value, o = Math.round(i * 100) / 100, a = this.data.get(t);
73
73
  if (a && e.sum) {
74
- const c = a.value + n, f = {
74
+ const u = a.value + o, f = {
75
75
  ...a,
76
- value: c
76
+ value: u
77
77
  };
78
78
  return this.data.set(t, f), f;
79
79
  }
80
- const u = {
80
+ const c = {
81
81
  name: e.name,
82
82
  type: "measure",
83
- value: n,
83
+ value: o,
84
84
  createdAt: Date.now()
85
85
  };
86
- return e.detail && (u.detail = e.detail), this.data.set(t, u), u;
86
+ return e.detail && (c.detail = e.detail), this.data.set(t, c), c;
87
87
  }
88
88
  update(e) {
89
89
  if (!this.enabled) return e.value;
@@ -96,7 +96,7 @@ class De {
96
96
  return this.data.get(t);
97
97
  }
98
98
  getResourceInfosFromPerformanceAPI() {
99
- return typeof performance > "u" ? [] : x.getEntriesByType("resource");
99
+ return typeof performance > "u" ? [] : b.getEntriesByType("resource");
100
100
  }
101
101
  get(e) {
102
102
  const t = this.getKey(e.name, e.context);
@@ -114,11 +114,11 @@ class De {
114
114
  getKey(e, t) {
115
115
  if (!t)
116
116
  return e;
117
- const r = I(t);
117
+ const r = K(t);
118
118
  return e + "_" + r;
119
119
  }
120
120
  }
121
- let Z = class T {
121
+ let X = class _ {
122
122
  nodes;
123
123
  edges;
124
124
  nodeKinds = /* @__PURE__ */ new Map();
@@ -200,8 +200,8 @@ let Z = class T {
200
200
  t.add(s);
201
201
  const i = this.edges.get(s);
202
202
  if (i) {
203
- for (let n of i)
204
- if (r(n))
203
+ for (let o of i)
204
+ if (r(o))
205
205
  return !0;
206
206
  }
207
207
  return t.delete(s), e.add(s), !1;
@@ -225,24 +225,24 @@ let Z = class T {
225
225
  return r.slice(a).concat([i]);
226
226
  }
227
227
  t.add(i), r.push(i);
228
- const n = this.edges.get(i);
229
- if (n)
230
- for (let a of n) {
231
- const u = s(a);
232
- if (u)
233
- return u;
228
+ const o = this.edges.get(i);
229
+ if (o)
230
+ for (let a of o) {
231
+ const c = s(a);
232
+ if (c)
233
+ return c;
234
234
  }
235
235
  return r.pop(), t.delete(i), e.add(i), null;
236
236
  };
237
237
  for (let i of this.nodes) {
238
- const n = s(i);
239
- if (n)
240
- return { hasCycle: !0, path: n };
238
+ const o = s(i);
239
+ if (o)
240
+ return { hasCycle: !0, path: o };
241
241
  }
242
242
  return { hasCycle: !1 };
243
243
  }
244
244
  order(e) {
245
- const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [], i = e?.allowCycles ?? !1, n = (a) => {
245
+ const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = [], i = e?.allowCycles ?? !1, o = (a) => {
246
246
  if (t.has(a))
247
247
  return;
248
248
  if (r.has(a)) {
@@ -251,14 +251,14 @@ let Z = class T {
251
251
  throw new Error("Graph has a cycle.");
252
252
  }
253
253
  r.add(a);
254
- const u = this.edges.get(a);
255
- if (u)
256
- for (let c of u)
257
- n(c);
254
+ const c = this.edges.get(a);
255
+ if (c)
256
+ for (let u of c)
257
+ o(u);
258
258
  r.delete(a), t.add(a), s.push(a);
259
259
  };
260
260
  for (let a of this.nodes)
261
- t.has(a) || n(a);
261
+ t.has(a) || o(a);
262
262
  return s;
263
263
  }
264
264
  clear() {
@@ -326,30 +326,30 @@ let Z = class T {
326
326
  */
327
327
  plan(e) {
328
328
  const t = /* @__PURE__ */ new Map();
329
- for (const n of this.nodes) t.set(n, 0);
330
- for (const n of this.edges.values())
331
- for (const a of n) t.set(a, (t.get(a) || 0) + 1);
329
+ for (const o of this.nodes) t.set(o, 0);
330
+ for (const o of this.edges.values())
331
+ for (const a of o) t.set(a, (t.get(a) || 0) + 1);
332
332
  const r = [];
333
- let s = Array.from(this.nodes).filter((n) => (t.get(n) || 0) === 0);
333
+ let s = Array.from(this.nodes).filter((o) => (t.get(o) || 0) === 0);
334
334
  const i = /* @__PURE__ */ new Set();
335
335
  for (; s.length > 0; ) {
336
- const n = s.slice();
337
- r.push(n), s = [];
338
- for (const a of n) {
336
+ const o = s.slice();
337
+ r.push(o), s = [];
338
+ for (const a of o) {
339
339
  if (i.has(a)) continue;
340
340
  i.add(a);
341
- const u = this.edges.get(a);
342
- if (u)
343
- for (const c of u)
344
- t.set(c, (t.get(c) || 0) - 1), (t.get(c) || 0) === 0 && s.push(c);
341
+ const c = this.edges.get(a);
342
+ if (c)
343
+ for (const u of c)
344
+ t.set(u, (t.get(u) || 0) - 1), (t.get(u) || 0) === 0 && s.push(u);
345
345
  }
346
346
  }
347
347
  if (i.size !== this.nodes.size)
348
348
  throw new Error("Graph has a cycle.");
349
349
  if (e?.filterKinds && e.filterKinds.length > 0) {
350
- const n = new Set(e.filterKinds);
350
+ const o = new Set(e.filterKinds);
351
351
  return {
352
- batches: r.map((a) => a.filter((u) => n.has(this.nodeKinds.get(u))))
352
+ batches: r.map((a) => a.filter((c) => o.has(this.nodeKinds.get(c))))
353
353
  };
354
354
  }
355
355
  return { batches: r };
@@ -362,26 +362,26 @@ let Z = class T {
362
362
  * - 'both': union of upstream and downstream
363
363
  */
364
364
  getImpactedNodes(e, t = "downstream", r) {
365
- const s = new Set(e), i = (c) => !r || r.length === 0 || r.includes(this.nodeKinds.get(c) ?? void 0), n = () => {
366
- const c = /* @__PURE__ */ new Set(), f = Array.from(s);
365
+ const s = new Set(e), i = (u) => !r || r.length === 0 || r.includes(this.nodeKinds.get(u) ?? void 0), o = () => {
366
+ const u = /* @__PURE__ */ new Set(), f = Array.from(s);
367
367
  for (; f.length; ) {
368
- const d = f.shift();
369
- for (const [l, h] of this.edges)
370
- h.has(d) && !c.has(l) && (c.add(l), f.push(l));
368
+ const l = f.shift();
369
+ for (const [d, h] of this.edges)
370
+ h.has(l) && !u.has(d) && (u.add(d), f.push(d));
371
371
  }
372
- return c;
372
+ return u;
373
373
  }, a = () => {
374
- const c = /* @__PURE__ */ new Set(), f = Array.from(s);
374
+ const u = /* @__PURE__ */ new Set(), f = Array.from(s);
375
375
  for (; f.length; ) {
376
- const d = f.shift(), l = this.edges.get(d);
377
- if (l)
378
- for (const h of l)
379
- c.has(h) || (c.add(h), f.push(h));
376
+ const l = f.shift(), d = this.edges.get(l);
377
+ if (d)
378
+ for (const h of d)
379
+ u.has(h) || (u.add(h), f.push(h));
380
380
  }
381
- return c;
381
+ return u;
382
382
  };
383
- let u;
384
- return t === "both" ? u = /* @__PURE__ */ new Set([...n(), ...a()]) : t === "upstream" ? u = a() : u = n(), Array.from(u).filter(i);
383
+ let c;
384
+ return t === "both" ? c = /* @__PURE__ */ new Set([...o(), ...a()]) : t === "upstream" ? c = a() : c = o(), Array.from(c).filter(i);
385
385
  }
386
386
  toJSON() {
387
387
  const e = Array.from(this.nodes).map((r) => ({
@@ -392,7 +392,7 @@ let Z = class T {
392
392
  return { nodes: e, edges: t };
393
393
  }
394
394
  static fromJSON(e) {
395
- const t = new T();
395
+ const t = new _();
396
396
  for (const r of e.nodes)
397
397
  t.addNode(r.name, { kind: r.kind, meta: r.meta });
398
398
  for (const r of e.edges)
@@ -400,19 +400,19 @@ let Z = class T {
400
400
  return t;
401
401
  }
402
402
  diff(e) {
403
- const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((d) => !t.has(d)), i = Array.from(t).filter((d) => !r.has(d)), n = new Set(this.getAllEdges().map((d) => d.join("→"))), a = new Set(e.getAllEdges().map((d) => d.join("→"))), u = Array.from(a).filter((d) => !n.has(d)).map((d) => d.split("→")), c = Array.from(n).filter((d) => !a.has(d)).map((d) => d.split("→")), f = [];
404
- for (const d of /* @__PURE__ */ new Set([...t, ...r])) {
405
- const l = this.nodeKinds.get(d), h = e.nodeKinds.get(d);
406
- l !== h && f.push({ name: d, from: l, to: h });
403
+ const t = new Set(this.getNodes()), r = new Set(e.getNodes()), s = Array.from(r).filter((l) => !t.has(l)), i = Array.from(t).filter((l) => !r.has(l)), o = new Set(this.getAllEdges().map((l) => l.join("→"))), a = new Set(e.getAllEdges().map((l) => l.join("→"))), c = Array.from(a).filter((l) => !o.has(l)).map((l) => l.split("→")), u = Array.from(o).filter((l) => !a.has(l)).map((l) => l.split("→")), f = [];
404
+ for (const l of /* @__PURE__ */ new Set([...t, ...r])) {
405
+ const d = this.nodeKinds.get(l), h = e.nodeKinds.get(l);
406
+ d !== h && f.push({ name: l, from: d, to: h });
407
407
  }
408
- return { addedNodes: s, removedNodes: i, addedEdges: u, removedEdges: c, kindChanges: f };
408
+ return { addedNodes: s, removedNodes: i, addedEdges: c, removedEdges: u, kindChanges: f };
409
409
  }
410
410
  };
411
- class Ke {
411
+ class Te {
412
412
  graph;
413
413
  nodeIndex;
414
414
  constructor() {
415
- this.graph = new Z(), this.nodeIndex = /* @__PURE__ */ new Map();
415
+ this.graph = new X(), this.nodeIndex = /* @__PURE__ */ new Map();
416
416
  }
417
417
  /**
418
418
  * Creates a unique ID for an attribute node
@@ -454,10 +454,10 @@ class Ke {
454
454
  * @returns Array of all impacted attribute nodes (including the changed ones)
455
455
  */
456
456
  getImpactedAttributes(e) {
457
- const t = e.map((a) => this.getNodeId(a.modelKey, a.attributeKey)), s = this.graph.getImpactedNodes(t, "downstream").map((a) => this.nodeIndex.get(a)).filter((a) => a !== void 0), i = [...e, ...s], n = /* @__PURE__ */ new Set();
457
+ const t = e.map((a) => this.getNodeId(a.modelKey, a.attributeKey)), s = this.graph.getImpactedNodes(t, "downstream").map((a) => this.nodeIndex.get(a)).filter((a) => a !== void 0), i = [...e, ...s], o = /* @__PURE__ */ new Set();
458
458
  return i.filter((a) => {
459
- const u = this.getNodeId(a.modelKey, a.attributeKey);
460
- return n.has(u) ? !1 : (n.add(u), !0);
459
+ const c = this.getNodeId(a.modelKey, a.attributeKey);
460
+ return o.has(c) ? !1 : (o.add(c), !0);
461
461
  });
462
462
  }
463
463
  /**
@@ -470,10 +470,10 @@ class Ke {
470
470
  getProcessingOrder(e) {
471
471
  const t = /* @__PURE__ */ new Map(), r = [...e].sort((s, i) => s.processingStep - i.processingStep);
472
472
  for (const s of r) {
473
- const { modelKey: i, attributeKey: n, processingStep: a } = s;
473
+ const { modelKey: i, attributeKey: o, processingStep: a } = s;
474
474
  t.has(i) || t.set(i, /* @__PURE__ */ new Map());
475
- const u = t.get(i);
476
- u.has(a) || u.set(a, /* @__PURE__ */ new Set()), u.get(a).add(n);
475
+ const c = t.get(i);
476
+ c.has(a) || c.set(a, /* @__PURE__ */ new Set()), c.get(a).add(o);
477
477
  }
478
478
  return t;
479
479
  }
@@ -530,12 +530,12 @@ class Ke {
530
530
  s.add(r);
531
531
  const i = this.graph.getDependencies(r);
532
532
  if (i.length === 0) return 1;
533
- let n = 0;
533
+ let o = 0;
534
534
  for (const a of i) {
535
- const u = t(a, new Set(s));
536
- n = Math.max(n, u);
535
+ const c = t(a, new Set(s));
536
+ o = Math.max(o, c);
537
537
  }
538
- return n + 1;
538
+ return o + 1;
539
539
  };
540
540
  for (const r of this.graph.getNodes()) {
541
541
  const s = t(r);
@@ -555,8 +555,8 @@ class Ke {
555
555
  const t = [];
556
556
  for (const [r, s] of e)
557
557
  for (const i of s) {
558
- const n = this.getNodeId(r, i);
559
- this.hasNode(n) || t.push({ modelKey: r, attributeKey: i });
558
+ const o = this.getNodeId(r, i);
559
+ this.hasNode(o) || t.push({ modelKey: r, attributeKey: i });
560
560
  }
561
561
  return {
562
562
  isComplete: t.length === 0,
@@ -600,7 +600,7 @@ class Ke {
600
600
  };
601
601
  }
602
602
  }
603
- const O = {
603
+ const q = {
604
604
  silent: 0,
605
605
  error: 1,
606
606
  warn: 2,
@@ -663,20 +663,20 @@ class p {
663
663
  }
664
664
  shouldLog(e) {
665
665
  const t = this.getEffectiveLevel();
666
- return O[e] <= O[t];
666
+ return q[e] <= q[t];
667
667
  }
668
668
  formatMessage(e) {
669
669
  if (this.config.format === "json") {
670
- const n = {
670
+ const o = {
671
671
  timestamp: new Date(e.timestamp).toISOString(),
672
672
  level: e.level,
673
673
  message: e.message
674
674
  };
675
- return e.prefix && (n.module = e.prefix), e.context && (n.context = e.context), e.error && (n.error = {
675
+ return e.prefix && (o.module = e.prefix), e.context && (o.context = e.context), e.error && (o.error = {
676
676
  name: e.error.name,
677
677
  message: e.error.message,
678
678
  stack: e.error.stack
679
- }), JSON.stringify(n);
679
+ }), JSON.stringify(o);
680
680
  }
681
681
  const t = new Date(e.timestamp).toISOString().substring(11, 23), r = e.prefix ? `[${e.prefix}]` : "", s = this.getLevelIcon(e.level), i = e.context ? ` ${JSON.stringify(e.context)}` : "";
682
682
  return `${t} ${s} ${r} ${e.message}${i}`.trim();
@@ -710,20 +710,20 @@ class p {
710
710
  this.config.onLog(i);
711
711
  return;
712
712
  }
713
- const n = this.formatMessage(i);
713
+ const o = this.formatMessage(i);
714
714
  if (typeof console < "u")
715
715
  switch (e) {
716
716
  case "error":
717
- s ? console.error(n, s) : console.error(n);
717
+ s ? console.error(o, s) : console.error(o);
718
718
  break;
719
719
  case "warn":
720
- console.warn(n);
720
+ console.warn(o);
721
721
  break;
722
722
  case "debug":
723
- console.debug ? console.debug(n) : console.log(n);
723
+ console.debug ? console.debug(o) : console.log(o);
724
724
  break;
725
725
  default:
726
- console.log(n);
726
+ console.log(o);
727
727
  }
728
728
  }
729
729
  /**
@@ -800,10 +800,11 @@ class p {
800
800
  }
801
801
  }
802
802
  const Y = new p();
803
- class Se {
803
+ class Ge {
804
804
  constructor(e) {
805
805
  this.enabled = e, this.cache = /* @__PURE__ */ new Map(), this.cacheDependencies = /* @__PURE__ */ new Map();
806
806
  }
807
+ enabled;
807
808
  cache;
808
809
  // Track which models and attributes each cache entry depends on
809
810
  cacheDependencies;
@@ -838,12 +839,12 @@ class Se {
838
839
  const t = [];
839
840
  for (const [r, s] of this.cacheDependencies) {
840
841
  let i = !1;
841
- for (const [n, a] of e) {
842
- if (s.models.has(n))
843
- if (s.modelAttributes.has(n)) {
844
- const u = s.modelAttributes.get(n);
845
- for (const c of a)
846
- if (u.has(c)) {
842
+ for (const [o, a] of e) {
843
+ if (s.models.has(o))
844
+ if (s.modelAttributes.has(o)) {
845
+ const c = s.modelAttributes.get(o);
846
+ for (const u of a)
847
+ if (c.has(u)) {
847
848
  i = !0;
848
849
  break;
849
850
  }
@@ -864,8 +865,8 @@ class Se {
864
865
  if (!this.enabled) return;
865
866
  const t = new Set(e), r = [];
866
867
  for (const [s, i] of this.cacheDependencies)
867
- for (const n of t)
868
- if (i.models.has(n)) {
868
+ for (const o of t)
869
+ if (i.models.has(o)) {
869
870
  r.push(s);
870
871
  break;
871
872
  }
@@ -915,13 +916,13 @@ class Se {
915
916
  }
916
917
  generateContext(e) {
917
918
  try {
918
- return y(e);
919
+ return v(e);
919
920
  } catch (t) {
920
921
  return this.log.error("Error in cache generateContext", t), e;
921
922
  }
922
923
  }
923
924
  getCacheName(e, t) {
924
- const r = I(t);
925
+ const r = K(t);
925
926
  return e + "_" + r;
926
927
  }
927
928
  /**
@@ -939,42 +940,42 @@ class Se {
939
940
  };
940
941
  }
941
942
  }
942
- const Ie = (o, e = "") => `${o}#${e}`, Qe = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Me = (o) => `${o.gt}_${o.gte}_${o.lt}_${o.lte}_${o.eq}_${o.ne}`, Ne = (o, e) => {
943
+ const ze = (n, e = "") => `${n}#${e}`, _e = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, Be = (n) => `${n.gt}_${n.gte}_${n.lt}_${n.lte}_${n.eq}_${n.ne}`, je = (n, e) => {
943
944
  const t = typeof e == "function" ? e : (r) => r[e];
944
945
  return [
945
- ...o.reduce((r, s) => {
946
+ ...n.reduce((r, s) => {
946
947
  const i = s == null ? s : t(s);
947
948
  return r.has(i) || r.set(i, s), r;
948
949
  }, /* @__PURE__ */ new Map()).values()
949
950
  ];
950
- }, ke = (o, e) => o.reduce(function(t, r) {
951
+ }, Pe = (n, e) => n.reduce(function(t, r) {
951
952
  const s = typeof e == "function" ? e(r) : r[e];
952
953
  return Object.prototype.hasOwnProperty.call(t, s) || (t[s] = []), t[s].push(r), t;
953
954
  }, {});
954
- function X(o = 10) {
955
+ function ee(n = 10) {
955
956
  let e = "";
956
957
  const t = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
957
- for (let r = 0; r < o; r++) e += t.charAt(Math.floor(Math.random() * t.length));
958
+ for (let r = 0; r < n; r++) e += t.charAt(Math.floor(Math.random() * t.length));
958
959
  return e;
959
960
  }
960
- const Ce = (o) => o.replace(/\/+$/, ""), ee = (o) => typeof o != "string" ? "" : o.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), Ee = (o) => typeof o != "string" ? "" : o.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), qe = (o, e) => {
961
+ const Le = (n) => n.replace(/\/+$/, ""), te = (n) => typeof n != "string" ? "" : n.replace(/[[\]{}()*+?.,\\^$|#]/g, "\\$&"), We = (n) => typeof n != "string" ? "" : n.replace(/\\([[\]{}()*+?.,\\^$|#])/g, "$1"), He = (n, e) => {
961
962
  try {
962
- return te(o, e) >= 0;
963
+ return re(n, e) >= 0;
963
964
  } catch {
964
965
  return !1;
965
966
  }
966
- }, te = (o, e) => {
967
- if (!$(o) || !$(e))
968
- throw new Error(`Invalid version format: v1="${o}", v2="${e}". Expected format: "x.y.z"`);
969
- const t = o.split(".").map(Number), r = e.split(".").map(Number);
967
+ }, re = (n, e) => {
968
+ if (!F(n) || !F(e))
969
+ throw new Error(`Invalid version format: v1="${n}", v2="${e}". Expected format: "x.y.z"`);
970
+ const t = n.split(".").map(Number), r = e.split(".").map(Number);
970
971
  for (let s = 0; s < 3; s++) {
971
- const i = t[s] || 0, n = r[s] || 0;
972
- if (i > n) return 1;
973
- if (i < n) return -1;
972
+ const i = t[s] || 0, o = r[s] || 0;
973
+ if (i > o) return 1;
974
+ if (i < o) return -1;
974
975
  }
975
976
  return 0;
976
- }, $ = (o) => /^\d+(\.\d+){0,2}$/.test(o);
977
- class Oe {
977
+ }, F = (n) => /^\d+(\.\d+){0,2}$/.test(n);
978
+ class Ue {
978
979
  key;
979
980
  parentCd;
980
981
  dcuplInitOptions;
@@ -1000,7 +1001,7 @@ class Oe {
1000
1001
  this.off && this.off();
1001
1002
  }
1002
1003
  trigger(e) {
1003
- e.originCdRefKey || (e.originCdRefKey = this.key), e.key || (this.increaseCounter(), e.key = this.getCounter()), e.end || (e.end = x.now(), e.duration = e.start - e.end), this.updateListener.forEach((t) => {
1004
+ e.originCdRefKey || (e.originCdRefKey = this.key), e.key || (this.increaseCounter(), e.key = this.getCounter()), e.end || (e.end = b.now(), e.duration = e.start - e.end), this.updateListener.forEach((t) => {
1004
1005
  t(e);
1005
1006
  });
1006
1007
  }
@@ -1010,17 +1011,17 @@ class Oe {
1010
1011
  };
1011
1012
  }
1012
1013
  }
1013
- const j = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : y(o) : o, F = (o, e, t, r, s, i) => {
1014
+ const B = (n, e) => e ? typeof structuredClone < "u" ? structuredClone(n) : v(n) : n, R = (n, e, t, r, s, i) => {
1014
1015
  try {
1015
- const n = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = j(i, n);
1016
- if (t.scope === "list" && (t.listKey = o.cdRef?.key || o.key, t.modelKey = o.model?.key || o.modelKey), t.type === "list_created" && t.args[0].listKey.startsWith("__global_list__") || t.listKey?.startsWith("__global_list__"))
1016
+ const o = !!e.dcuplInitOptions.performance?.clone?.enabled && !!t.cloneResult, a = B(i, o);
1017
+ if (t.scope === "list" && (t.listKey = n.cdRef?.key || n.key, t.modelKey = n.model?.key || n.modelKey), t.type === "list_created" && t.args[0].listKey.startsWith("__global_list__") || t.listKey?.startsWith("__global_list__"))
1017
1018
  return a;
1018
- const u = x.now(), c = u - r, f = Math.round(c * 1e3) / 1e3;
1019
- t.duration = f, t.start = r, t.end = u;
1020
- const d = {
1019
+ const c = b.now(), u = c - r, f = Math.round(u * 1e3) / 1e3;
1020
+ t.duration = f, t.start = r, t.end = c;
1021
+ const l = {
1021
1022
  duration: t.duration
1022
1023
  };
1023
- return t.modelKey && (d.model = t.modelKey), t.connectMessageResult && (t.result = a), t.args && (d.args = t.args), e?.trigger(t), e.analyticsController.mark({
1024
+ return t.modelKey && (l.model = t.modelKey), t.connectMessageResult && (t.result = a), t.args && (l.args = t.args), e?.trigger(t), e.analyticsController.mark({
1024
1025
  name: `${t.type}:end`,
1025
1026
  context: s
1026
1027
  }), e.analyticsController.measure({
@@ -1028,59 +1029,59 @@ const j = (o, e) => e ? typeof structuredClone < "u" ? structuredClone(o) : y(o)
1028
1029
  start: `${t.type}:start`,
1029
1030
  end: `${t.type}:end`,
1030
1031
  context: s,
1031
- detail: d
1032
+ detail: l
1032
1033
  }), a;
1033
1034
  } catch {
1034
1035
  return i;
1035
1036
  }
1036
- }, $e = (o) => (t, r, s) => {
1037
+ }, Ve = (n) => (t, r, s) => {
1037
1038
  const i = s.value;
1038
- return s.value = function(...n) {
1039
- const a = x.now(), u = this.cdRef, c = j(o, !0);
1040
- c.key || (u.increaseCounter(), c.key = u.getCounter());
1041
- const f = X();
1042
- u.analyticsController.mark({
1043
- name: `${c.type}:start`,
1039
+ return s.value = function(...o) {
1040
+ const a = b.now(), c = this.cdRef, u = B(n, !0);
1041
+ u.key || (c.increaseCounter(), u.key = c.getCounter());
1042
+ const f = ee();
1043
+ c.analyticsController.mark({
1044
+ name: `${u.type}:start`,
1044
1045
  context: f
1045
1046
  });
1046
- const d = this.model?.key;
1047
- !c.originCdRefKey && u.key && (c.originCdRefKey = u.key), d && (c.modelKey = d);
1048
- const l = i.apply(this, n);
1049
- return c.method = r, c.args = n, l && typeof l == "object" && "then" in l ? l.then((h) => F(this, u, c, a, f, h)) : F(this, u, c, a, f, l);
1047
+ const l = this.model?.key;
1048
+ !u.originCdRefKey && c.key && (u.originCdRefKey = c.key), l && (u.modelKey = l);
1049
+ const d = i.apply(this, o);
1050
+ return u.method = r, u.args = o, d && typeof d == "object" && "then" in d ? d.then((h) => R(this, c, u, a, f, h)) : R(this, c, u, a, f, d);
1050
1051
  }, s;
1051
1052
  };
1052
- function Fe(o, e, t, r) {
1053
+ function Je(n, e, t, r) {
1053
1054
  t.max || (t.max = 20);
1054
1055
  const s = [], i = t.transform ? r.transformValue(t.value, t.transform) : t.value;
1055
- for (const [n, a] of e.entries()) {
1056
- const u = Array.from(a).some((f) => o.has(f)), c = t.transform ? r.transformValue(n, t.transform) : n;
1057
- if (!(t.excludeUndefineds && typeof n > "u") && !(t.excludeNulls && n === null)) {
1058
- if (u && (i === "" || i === "//")) {
1056
+ for (const [o, a] of e.entries()) {
1057
+ const c = Array.from(a).some((f) => n.has(f)), u = t.transform ? r.transformValue(o, t.transform) : o;
1058
+ if (!(t.excludeUndefineds && typeof o > "u") && !(t.excludeNulls && o === null)) {
1059
+ if (c && (i === "" || i === "//")) {
1059
1060
  const f = {
1060
- value: n,
1061
+ value: o,
1061
1062
  keys: t.calculateResultKeys ? Array.from(a) : []
1062
1063
  };
1063
1064
  s.push(f);
1064
- } else if (u && typeof i == "string" && i.startsWith("/") && i.endsWith("/")) {
1065
- if (r.queryFind(c, i, "some")) {
1065
+ } else if (c && typeof i == "string" && i.startsWith("/") && i.endsWith("/")) {
1066
+ if (r.queryFind(u, i, "some")) {
1066
1067
  const f = {
1067
- value: n,
1068
+ value: o,
1068
1069
  keys: t.calculateResultKeys ? Array.from(a) : []
1069
1070
  };
1070
1071
  s.push(f);
1071
1072
  }
1072
- } else if (u && typeof i == "string") {
1073
- const f = String(c ?? ""), d = i;
1074
- if (f.toLowerCase().startsWith(d.toLowerCase())) {
1075
- const l = {
1076
- value: n,
1073
+ } else if (c && typeof i == "string") {
1074
+ const f = String(u ?? ""), l = i;
1075
+ if (f.toLowerCase().startsWith(l.toLowerCase())) {
1076
+ const d = {
1077
+ value: o,
1077
1078
  keys: t.calculateResultKeys ? Array.from(a) : []
1078
1079
  };
1079
- s.push(l);
1080
+ s.push(d);
1080
1081
  }
1081
- } else if (u && r.queryFind(c, i, "some")) {
1082
+ } else if (c && r.queryFind(u, i, "some")) {
1082
1083
  const f = {
1083
- value: n,
1084
+ value: o,
1084
1085
  keys: t.calculateResultKeys ? Array.from(a) : []
1085
1086
  };
1086
1087
  s.push(f);
@@ -1091,13 +1092,13 @@ function Fe(o, e, t, r) {
1091
1092
  }
1092
1093
  return s;
1093
1094
  }
1094
- function re(o) {
1095
- return o instanceof Date;
1095
+ function se(n) {
1096
+ return n instanceof Date;
1096
1097
  }
1097
- function se(o) {
1098
- return o instanceof Date && !isNaN(o.getTime());
1098
+ function ne(n) {
1099
+ return n instanceof Date && !isNaN(n.getTime());
1099
1100
  }
1100
- const ne = {
1101
+ const ie = {
1101
1102
  yyyy: { type: "year", pattern: "yyyy", regex: "(\\d{4})" },
1102
1103
  yy: { type: "year", pattern: "yy", regex: "(\\d{2})" },
1103
1104
  MM: { type: "month", pattern: "MM", regex: "(\\d{2})" },
@@ -1112,28 +1113,28 @@ const ne = {
1112
1113
  s: { type: "second", pattern: "s", regex: "(\\d{1,2})" },
1113
1114
  SSS: { type: "millisecond", pattern: "SSS", regex: "(\\d{3})" }
1114
1115
  };
1115
- function ie(o) {
1116
+ function oe(n) {
1116
1117
  let e = "^";
1117
1118
  const t = [];
1118
- let r = o;
1119
- const s = Object.entries(ne).sort((i, n) => n[0].length - i[0].length);
1119
+ let r = n;
1120
+ const s = Object.entries(ie).sort((i, o) => o[0].length - i[0].length);
1120
1121
  for (; r.length > 0; ) {
1121
1122
  let i = !1;
1122
- for (const [n, a] of s)
1123
- if (r.startsWith(n)) {
1124
- e += a.regex, t.push({ type: a.type, pattern: n }), r = r.slice(n.length), i = !0;
1123
+ for (const [o, a] of s)
1124
+ if (r.startsWith(o)) {
1125
+ e += a.regex, t.push({ type: a.type, pattern: o }), r = r.slice(o.length), i = !0;
1125
1126
  break;
1126
1127
  }
1127
1128
  if (!i) {
1128
- const n = r[0];
1129
- if (!n)
1129
+ const o = r[0];
1130
+ if (!o)
1130
1131
  break;
1131
- e += n.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), r = r.slice(1);
1132
+ e += o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), r = r.slice(1);
1132
1133
  }
1133
1134
  }
1134
1135
  return e += "$", { regex: new RegExp(e), tokenOrder: t };
1135
1136
  }
1136
- function oe(o, e) {
1137
+ function ae(n, e) {
1137
1138
  const t = {
1138
1139
  year: 1970,
1139
1140
  month: 1,
@@ -1144,52 +1145,52 @@ function oe(o, e) {
1144
1145
  millisecond: 0
1145
1146
  };
1146
1147
  for (let r = 0; r < e.length; r++) {
1147
- const s = o[r + 1];
1148
+ const s = n[r + 1];
1148
1149
  if (!s)
1149
1150
  continue;
1150
- const i = parseInt(s, 10), n = e[r];
1151
- n && (n.type === "year" && n.pattern === "yy" ? t.year = 2e3 + i : t[n.type] = i);
1151
+ const i = parseInt(s, 10), o = e[r];
1152
+ o && (o.type === "year" && o.pattern === "yy" ? t.year = 2e3 + i : t[o.type] = i);
1152
1153
  }
1153
1154
  return t;
1154
1155
  }
1155
- function ae(o) {
1156
- if (o.month < 1 || o.month > 12)
1156
+ function ce(n) {
1157
+ if (n.month < 1 || n.month > 12)
1157
1158
  return /* @__PURE__ */ new Date(NaN);
1158
- if (o.day < 1 || o.day > 31)
1159
+ if (n.day < 1 || n.day > 31)
1159
1160
  return /* @__PURE__ */ new Date(NaN);
1160
- if (o.hour < 0 || o.hour > 23)
1161
+ if (n.hour < 0 || n.hour > 23)
1161
1162
  return /* @__PURE__ */ new Date(NaN);
1162
- if (o.minute < 0 || o.minute > 59)
1163
+ if (n.minute < 0 || n.minute > 59)
1163
1164
  return /* @__PURE__ */ new Date(NaN);
1164
- if (o.second < 0 || o.second > 59)
1165
+ if (n.second < 0 || n.second > 59)
1165
1166
  return /* @__PURE__ */ new Date(NaN);
1166
- if (o.millisecond < 0 || o.millisecond > 999)
1167
+ if (n.millisecond < 0 || n.millisecond > 999)
1167
1168
  return /* @__PURE__ */ new Date(NaN);
1168
1169
  const e = new Date(
1169
- o.year,
1170
- o.month - 1,
1171
- o.day,
1172
- o.hour,
1173
- o.minute,
1174
- o.second,
1175
- o.millisecond
1170
+ n.year,
1171
+ n.month - 1,
1172
+ n.day,
1173
+ n.hour,
1174
+ n.minute,
1175
+ n.second,
1176
+ n.millisecond
1176
1177
  );
1177
- return se(e) ? e.getFullYear() !== o.year || e.getMonth() !== o.month - 1 || e.getDate() !== o.day ? /* @__PURE__ */ new Date(NaN) : e : /* @__PURE__ */ new Date(NaN);
1178
+ return ne(e) ? e.getFullYear() !== n.year || e.getMonth() !== n.month - 1 || e.getDate() !== n.day ? /* @__PURE__ */ new Date(NaN) : e : /* @__PURE__ */ new Date(NaN);
1178
1179
  }
1179
- function Ge(o, e, t) {
1180
- if (o = o.trim(), e === "t") {
1181
- const a = Number(o);
1180
+ function Ze(n, e, t) {
1181
+ if (n = n.trim(), e === "t") {
1182
+ const a = Number(n);
1182
1183
  return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a * 1e3);
1183
1184
  }
1184
1185
  if (e === "T") {
1185
- const a = Number(o);
1186
+ const a = Number(n);
1186
1187
  return isNaN(a) ? /* @__PURE__ */ new Date(NaN) : new Date(a);
1187
1188
  }
1188
- const { regex: r, tokenOrder: s } = ie(e), i = o.match(r);
1189
+ const { regex: r, tokenOrder: s } = oe(e), i = n.match(r);
1189
1190
  if (!i)
1190
1191
  return /* @__PURE__ */ new Date(NaN);
1191
- const n = oe(i, s);
1192
- return ae(n);
1192
+ const o = ae(i, s);
1193
+ return ce(o);
1193
1194
  }
1194
1195
  class ue {
1195
1196
  cache;
@@ -1234,7 +1235,7 @@ class ue {
1234
1235
  };
1235
1236
  }
1236
1237
  }
1237
- class ce {
1238
+ class fe {
1238
1239
  graph;
1239
1240
  constructor() {
1240
1241
  this.graph = /* @__PURE__ */ new Map();
@@ -1246,9 +1247,9 @@ class ce {
1246
1247
  if (e.length === 0) return !1;
1247
1248
  const t = /* @__PURE__ */ new Set(), r = /* @__PURE__ */ new Set(), s = (i) => {
1248
1249
  t.add(i), r.add(i);
1249
- const n = this.graph.get(i);
1250
- if (n) {
1251
- for (const a of n)
1250
+ const o = this.graph.get(i);
1251
+ if (o) {
1252
+ for (const a of o)
1252
1253
  if (t.has(a)) {
1253
1254
  if (r.has(a))
1254
1255
  return !0;
@@ -1258,8 +1259,8 @@ class ce {
1258
1259
  return r.delete(i), !1;
1259
1260
  };
1260
1261
  for (let i = 0; i < e.length - 1; i++) {
1261
- const n = e[i], a = e[i + 1];
1262
- n && a && this.addDependency(n, a);
1262
+ const o = e[i], a = e[i + 1];
1263
+ o && a && this.addDependency(o, a);
1263
1264
  }
1264
1265
  for (const i of e)
1265
1266
  if (!t.has(i) && s(i))
@@ -1270,13 +1271,13 @@ class ce {
1270
1271
  this.graph.clear();
1271
1272
  }
1272
1273
  }
1273
- class fe {
1274
+ class le {
1274
1275
  parseCache;
1275
1276
  circularRefDetector;
1276
1277
  cacheHits = 0;
1277
1278
  cacheMisses = 0;
1278
1279
  constructor(e = 1e3) {
1279
- this.parseCache = new ue(e), this.circularRefDetector = new ce();
1280
+ this.parseCache = new ue(e), this.circularRefDetector = new fe();
1280
1281
  }
1281
1282
  /**
1282
1283
  * Parse an attribute string into its components
@@ -1301,18 +1302,21 @@ class fe {
1301
1302
  return this.cacheHits++, this.parseCache.get(e);
1302
1303
  this.cacheMisses++;
1303
1304
  let t, r;
1304
- const s = e.includes("."), i = e.includes("["), n = s || i;
1305
- if (n)
1306
- if (r = e.split(/[.[]/)[0], i) {
1307
- const u = e.indexOf("]");
1308
- if (u > -1) {
1309
- const c = e.indexOf(".", u + 1);
1310
- c > -1 ? t = e.substring(c + 1) : t = void 0;
1311
- } else s && (t = e.substring(e.indexOf(".") + 1));
1312
- } else s && (t = e.substring(e.indexOf(".") + 1));
1305
+ const s = e.includes("."), i = e.includes("["), o = s || i;
1306
+ if (o) {
1307
+ r = e.split(/[.[]/)[0];
1308
+ const c = e.indexOf("."), u = e.indexOf("[");
1309
+ if (i && (c === -1 || u < c)) {
1310
+ const l = e.indexOf("]");
1311
+ if (l > -1) {
1312
+ const d = e.indexOf(".", l + 1);
1313
+ d > -1 ? t = e.substring(d + 1) : t = void 0;
1314
+ } else s && (t = e.substring(c + 1));
1315
+ } else s && (t = e.substring(c + 1));
1316
+ }
1313
1317
  const a = {
1314
1318
  attribute: e,
1315
- isDeepQuery: n
1319
+ isDeepQuery: o
1316
1320
  };
1317
1321
  return r && (a.reference = r), typeof t < "u" && t !== "" && (a.referenceAttribute = t), this.parseCache.set(e, a), a;
1318
1322
  }
@@ -1367,16 +1371,16 @@ class fe {
1367
1371
  (e.startsWith(".") || e.endsWith(".")) && r.push(`Invalid path: Leading or trailing dots are not allowed: ${e}`), e.includes("..") && r.push(`Invalid path: Consecutive dots are not allowed: ${e}`);
1368
1372
  const s = (e.match(/\[/g) || []).length, i = (e.match(/]/g) || []).length;
1369
1373
  s !== i && r.push(`Invalid bracket notation: Mismatched brackets in ${e}`), e.includes("[]") && r.push(`Invalid bracket notation: Empty brackets not allowed: ${e}`);
1370
- const n = /\[([^\]]+)\]/g;
1374
+ const o = /\[([^\]]+)\]/g;
1371
1375
  let a;
1372
- for (; (a = n.exec(e)) !== null; ) {
1376
+ for (; (a = o.exec(e)) !== null; ) {
1373
1377
  const f = a[1];
1374
1378
  f && f !== "*" && !/^\d+$/.test(f) && r.push(`Invalid bracket content: Must be a number or '*', got '${f}' in ${e}`);
1375
1379
  }
1376
- const u = (e.match(/\./g) || []).length + 1;
1377
- u > t && r.push(`Path too deep: Maximum depth is ${t}, got ${u} in ${e}`);
1378
- const c = e.match(/[^a-zA-Z0-9._[\]*-]/g);
1379
- return c && r.push(`Invalid characters in path: ${c.join(", ")} in ${e}`), {
1380
+ const c = (e.match(/\./g) || []).length + 1;
1381
+ c > t && r.push(`Path too deep: Maximum depth is ${t}, got ${c} in ${e}`);
1382
+ const u = e.match(/[^a-zA-Z0-9._[\]*-]/g);
1383
+ return u && r.push(`Invalid characters in path: ${u.join(", ")} in ${e}`), {
1380
1384
  valid: r.length === 0,
1381
1385
  errors: r.length > 0 ? r : void 0
1382
1386
  };
@@ -1435,49 +1439,103 @@ class fe {
1435
1439
  return this.getPathSegments(e).length;
1436
1440
  }
1437
1441
  }
1438
- const g = new fe();
1439
- function D(o) {
1442
+ const y = new le();
1443
+ function x(n, e) {
1444
+ if (e.includes("[*]")) {
1445
+ const i = e.indexOf("[*]"), o = e.substring(0, i), a = e.substring(i + 3), c = o ? I(n, o) : n;
1446
+ if (!Array.isArray(c)) return [];
1447
+ const u = [];
1448
+ for (const f of c)
1449
+ !a || a === "" ? f !== void 0 && u.push(f) : a.startsWith(".") && u.push(...x(f, a.slice(1)));
1450
+ return u;
1451
+ }
1452
+ const t = e.split(".");
1453
+ let r = [n];
1454
+ for (const i of t) {
1455
+ const o = [];
1456
+ for (const a of r)
1457
+ if (a != null)
1458
+ if (Array.isArray(a))
1459
+ for (const c of a) {
1460
+ if (c == null) continue;
1461
+ const u = c[i];
1462
+ u !== void 0 && o.push(u);
1463
+ }
1464
+ else {
1465
+ const c = a[i];
1466
+ c !== void 0 && o.push(c);
1467
+ }
1468
+ if (r = o, r.length === 0) return [];
1469
+ }
1470
+ const s = [];
1471
+ for (const i of r)
1472
+ if (Array.isArray(i))
1473
+ for (const o of i) o !== void 0 && s.push(o);
1474
+ else i !== void 0 && s.push(i);
1475
+ return s;
1476
+ }
1477
+ function Q(n) {
1440
1478
  let e = 0;
1441
- for (let t of o) {
1479
+ for (let t of n) {
1442
1480
  const r = t.toString().split(".")[1];
1443
1481
  r && (e = Math.max(e, r.length));
1444
1482
  }
1445
1483
  return Math.pow(10, e);
1446
1484
  }
1447
- function G(o, e, t) {
1448
- return (o * t + e * t) / t;
1485
+ function T(n, e, t) {
1486
+ return (n * t + e * t) / t;
1449
1487
  }
1450
- function de(o, e, t) {
1451
- return o * t / (e * t);
1488
+ function de(n, e, t) {
1489
+ return n * t / (e * t);
1452
1490
  }
1453
- const Q = (o, e, t, r) => {
1491
+ const C = (n, e, t, r) => {
1454
1492
  if (!r)
1455
1493
  throw new Error("Attribute not found");
1456
1494
  const s = {
1457
1495
  attribute: r,
1458
- types: o.types
1496
+ types: n.types
1459
1497
  };
1460
1498
  let i;
1461
- (s.types.includes("sum") || s.types.includes("avg") || s.types.includes("count")) && (i = pe(r, e));
1462
- let n;
1463
- return (s.types.includes("min") || s.types.includes("max")) && (n = le(r, e)), o.types.forEach((a) => {
1464
- a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.average : a === "count" ? s.count = i?.count : a === "min" ? s.min = n && n[0] : a === "max" ? s.max = n && n[1] : a === "distinct" ? s.distinct = ge(o, e, t) : a === "group" && (s.group = he(o, e));
1499
+ (s.types.includes("sum") || s.types.includes("avg")) && (i = ye(r, e));
1500
+ let o;
1501
+ return (s.types.includes("min") || s.types.includes("max")) && (o = pe(r, e)), n.types.forEach((a) => {
1502
+ a === "sum" ? s.sum = i?.sum : a === "avg" ? s.avg = i?.average : a === "count" ? s.count = he(r, e) : a === "min" ? s.min = o && o[0] : a === "max" ? s.max = o && o[1] : a === "distinct" ? s.distinct = me(n, e, t) : a === "group" && (s.group = ge(n, e));
1465
1503
  }), s;
1466
- }, le = (o, e) => {
1504
+ }, he = (n, e) => {
1505
+ const r = y.parse(n).isDeepQuery;
1506
+ let s = 0;
1507
+ for (const i of e.values())
1508
+ if (i)
1509
+ if (r)
1510
+ s += x(i, n).filter((o) => o != null).length;
1511
+ else {
1512
+ const o = i[n];
1513
+ if (o == null) continue;
1514
+ Array.isArray(o) ? s += o.filter((a) => a != null).length : s++;
1515
+ }
1516
+ return s;
1517
+ }, pe = (n, e) => {
1467
1518
  let t, r;
1468
- const i = g.parse(o).isDeepQuery;
1469
- for (const n of e.values())
1470
- if (n) {
1471
- const a = i ? v(n, o) : n[o];
1472
- (t === void 0 || a < t) && (t = a), (r === void 0 || a > r) && (r = a);
1519
+ const i = y.parse(n).isDeepQuery;
1520
+ for (const o of e.values()) {
1521
+ if (!o) continue;
1522
+ let a;
1523
+ if (i)
1524
+ a = x(o, n);
1525
+ else {
1526
+ const c = o[n];
1527
+ c === void 0 ? a = [] : Array.isArray(c) ? a = c.filter((u) => u !== void 0) : a = [c];
1473
1528
  }
1529
+ for (const c of a)
1530
+ c == null || typeof c == "object" || ((t === void 0 || c < t) && (t = c), (r === void 0 || c > r) && (r = c));
1531
+ }
1474
1532
  if (!(t === void 0 || r === void 0))
1475
1533
  return [t, r];
1476
- }, he = (o, e) => {
1534
+ }, ge = (n, e) => {
1477
1535
  const t = [];
1478
- o.groupOptions?.groups?.forEach((n) => {
1536
+ n.groupOptions?.groups?.forEach((o) => {
1479
1537
  t.push({
1480
- option: n,
1538
+ option: o,
1481
1539
  count: 0,
1482
1540
  keys: []
1483
1541
  });
@@ -1486,50 +1544,61 @@ const Q = (o, e, t, r) => {
1486
1544
  option: { value: ["$dcupl_not_found"] },
1487
1545
  count: 0,
1488
1546
  keys: []
1489
- }, i = g.parse(o.attribute).isDeepQuery;
1490
- for (const n of e.values()) {
1491
- const a = i ? v(n, o.attribute) : n[o.attribute];
1492
- for (const u of t)
1493
- typeof u.option.value < "u" && u.option.value.includes(a) || typeof u.option.from < "u" && u.option.from < a && typeof u.option.to < "u" && u.option.to > a ? (u.count++, u.keys.push(n.key)) : o?.groupOptions?.calculateNotFound && (r.count++, r.keys.push(n.key));
1494
- }
1495
- return o?.groupOptions?.calculateNotFound && t.push(r), t;
1496
- }, pe = (o, e) => {
1547
+ }, i = y.parse(n.attribute).isDeepQuery;
1548
+ for (const o of e.values()) {
1549
+ let a;
1550
+ i ? a = x(o, n.attribute) : a = [o[n.attribute]];
1551
+ let c = !1;
1552
+ for (const u of a)
1553
+ for (const f of t)
1554
+ (typeof f.option.value < "u" && f.option.value.includes(u) || typeof f.option.from < "u" && f.option.from < u && typeof f.option.to < "u" && f.option.to > u) && (f.keys.includes(o.key) || (f.count++, f.keys.push(o.key)), c = !0);
1555
+ !c && n?.groupOptions?.calculateNotFound && (r.count++, r.keys.push(o.key));
1556
+ }
1557
+ return n?.groupOptions?.calculateNotFound && t.push(r), t;
1558
+ }, ye = (n, e) => {
1497
1559
  let t = 0, r = 0;
1498
- const i = g.parse(o).isDeepQuery;
1499
- for (const u of e.values()) {
1500
- if (!u) continue;
1501
- const c = i ? v(u, o) : u[o];
1502
- if (Array.isArray(c))
1503
- for (const f of c)
1504
- typeof f == "number" && (t = G(t, f, D([t, f])), r++);
1505
- else typeof c == "number" && (t = G(t, c, D([t, c])), r++);
1506
- }
1507
- return r === 0 || r === 0 ? void 0 : {
1508
- average: de(t, r, D([t, r])),
1509
- count: e.size,
1560
+ const i = y.parse(n).isDeepQuery;
1561
+ for (const a of e.values()) {
1562
+ if (!a) continue;
1563
+ let c;
1564
+ if (i)
1565
+ c = x(a, n);
1566
+ else {
1567
+ const u = a[n];
1568
+ u === void 0 ? c = [] : Array.isArray(u) ? c = u : c = [u];
1569
+ }
1570
+ for (const u of c)
1571
+ if (Array.isArray(u))
1572
+ for (const f of u)
1573
+ typeof f == "number" && (t = T(t, f, Q([t, f])), r++);
1574
+ else typeof u == "number" && (t = T(t, u, Q([t, u])), r++);
1575
+ }
1576
+ return r === 0 ? void 0 : {
1577
+ average: de(t, r, Q([t, r])),
1578
+ count: r,
1510
1579
  sum: t
1511
1580
  };
1512
- }, ge = (o, e, t) => {
1581
+ }, me = (n, e, t) => {
1513
1582
  const r = [];
1514
1583
  for (const [s, i] of t)
1515
- if (!(o.excludeUndefineds && typeof s > "u") && Array.from(i).find((n) => e.has(n))) {
1516
- const n = {
1584
+ if (!(n.excludeUndefineds && typeof s > "u") && Array.from(i).find((o) => e.has(o))) {
1585
+ const o = {
1517
1586
  value: s,
1518
1587
  count: i.size
1519
1588
  };
1520
- if (o.distinctOptions?.skipKeys || (n.keys = Array.from(i)), r.push(n), o.distinctOptions?.limit && r.length >= o.distinctOptions.limit)
1589
+ if (n.distinctOptions?.skipKeys || (o.keys = Array.from(i)), r.push(o), n.distinctOptions?.limit && r.length >= n.distinctOptions.limit)
1521
1590
  break;
1522
1591
  }
1523
1592
  return r;
1524
1593
  };
1525
- class w extends Error {
1594
+ class A extends Error {
1526
1595
  query;
1527
1596
  constructor(e, t) {
1528
1597
  const r = `Query Error: ${e} in ${JSON.stringify(t, null, 2)}`;
1529
1598
  super(r), this.query = t, this.name = "DcuplQueryError";
1530
1599
  }
1531
1600
  }
1532
- class P {
1601
+ class j {
1533
1602
  _defaultQueryOptions = {
1534
1603
  modelKey: "",
1535
1604
  groupKey: "root",
@@ -1537,10 +1606,10 @@ class P {
1537
1606
  queries: []
1538
1607
  };
1539
1608
  _initOptions;
1540
- currentQuery = y(this._defaultQueryOptions);
1609
+ currentQuery = v(this._defaultQueryOptions);
1541
1610
  deepQueryService;
1542
1611
  constructor(e) {
1543
- this.deepQueryService = e || g;
1612
+ this.deepQueryService = e || y;
1544
1613
  }
1545
1614
  /**
1546
1615
  * Initialize the query builder.
@@ -1566,7 +1635,7 @@ class P {
1566
1635
  * });
1567
1636
  */
1568
1637
  init(e) {
1569
- this._initOptions = y(e), this.currentQuery = y(this._defaultQueryOptions), this.currentQuery.modelKey = e.modelKey, "queries" in e && Array.isArray(e.queries) && (e.groupType && (this.currentQuery.groupType = e.groupType), e.queries && (this.currentQuery.queries = y(e.queries)), e.count !== void 0 && (this.currentQuery.count = e.count), e.start !== void 0 && (this.currentQuery.start = e.start), e.sort && (this.currentQuery.sort = e.sort), e.projection && (this.currentQuery.projection = e.projection));
1638
+ this._initOptions = v(e), this.currentQuery = v(this._defaultQueryOptions), this.currentQuery.modelKey = e.modelKey, "queries" in e && Array.isArray(e.queries) && (e.groupType && (this.currentQuery.groupType = e.groupType), e.queries && (this.currentQuery.queries = v(e.queries)), e.count !== void 0 && (this.currentQuery.count = e.count), e.start !== void 0 && (this.currentQuery.start = e.start), e.sort && (this.currentQuery.sort = e.sort), e.projection && (this.currentQuery.projection = e.projection));
1570
1639
  }
1571
1640
  reset() {
1572
1641
  return this.init(this._initOptions), this.getQuery();
@@ -1575,7 +1644,7 @@ class P {
1575
1644
  return "attribute" in e;
1576
1645
  }
1577
1646
  isQueryGroup(e) {
1578
- return "groupKey" in e;
1647
+ return "queries" in e || "groupKey" in e;
1579
1648
  }
1580
1649
  isRootQueryGroup(e) {
1581
1650
  return this.isQueryGroup(e) && e.groupKey === "root";
@@ -1584,7 +1653,7 @@ class P {
1584
1653
  return this.currentQuery.queries.find((t) => this.isQueryGroup(t) && t.groupKey === e);
1585
1654
  }
1586
1655
  getQuery() {
1587
- return y(this.currentQuery);
1656
+ return v(this.currentQuery);
1588
1657
  }
1589
1658
  hasQueryGroup(e) {
1590
1659
  return this.currentQuery.queries.some((t) => this.isQueryGroup(t) && t.groupKey === e);
@@ -1600,7 +1669,7 @@ class P {
1600
1669
  }
1601
1670
  validate(e) {
1602
1671
  const t = e.queries.map((s) => this.validateQuery(s));
1603
- return { valid: B(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
1672
+ return { valid: z(t, (s) => s.valid), errors: t.map((s) => s.errors).flat() };
1604
1673
  }
1605
1674
  applyOptions(e, t = "update") {
1606
1675
  return t === "set" ? (this.currentQuery.count = e.count, this.currentQuery.start = e.start, this.currentQuery.sort = e.sort, this.currentQuery.projection = e.projection) : (typeof e?.sort < "u" && (this.currentQuery.sort = e.sort), typeof e?.count < "u" && (this.currentQuery.count = e.count), typeof e?.start < "u" && (this.currentQuery.start = e?.start), typeof e?.projection < "u" && (this.currentQuery.projection = e?.projection)), this.getQuery();
@@ -1682,7 +1751,7 @@ class P {
1682
1751
  (s) => this.isQueryGroup(s) && s.groupKey === e.attribute
1683
1752
  );
1684
1753
  if (r > -1) {
1685
- const s = t.queries[r], i = C(s.queries, e);
1754
+ const s = t.queries[r], i = E(s.queries, e);
1686
1755
  i > -1 && s.queries.splice(i, 1), s.queries.length === 0 && t.queries.splice(r, 1);
1687
1756
  }
1688
1757
  } else if (this.isQueryGroup(e)) {
@@ -1695,8 +1764,8 @@ class P {
1695
1764
  else {
1696
1765
  const s = t.queries[r];
1697
1766
  for (const i of e.queries) {
1698
- const n = C(s.queries, i);
1699
- n > -1 && s.queries.splice(n, 1);
1767
+ const o = E(s.queries, i);
1768
+ o > -1 && s.queries.splice(o, 1);
1700
1769
  }
1701
1770
  s.queries.length === 0 && t.queries.splice(r, 1);
1702
1771
  }
@@ -1706,12 +1775,12 @@ class P {
1706
1775
  validateQuery(e) {
1707
1776
  const t = [];
1708
1777
  if (this.isQuery(e))
1709
- return e.attribute || t.push(new w("Missing attribute", e)), e.operator || t.push(new w("Missing operator", e)), typeof e.value > "u" && t.push(new w("Missing value", e)), e.operator === "find" && Array.isArray(e.value) && t.push(new w("find operator cannot have array value", e)), t.length > 0 ? { valid: !1, errors: t } : { valid: !0 };
1778
+ return e.attribute || t.push(new A("Missing attribute", e)), e.operator || t.push(new A("Missing operator", e)), typeof e.value > "u" && t.push(new A("Missing value", e)), e.operator === "find" && Array.isArray(e.value) && t.push(new A("find operator cannot have array value", e)), t.length > 0 ? { valid: !1, errors: t } : { valid: !0 };
1710
1779
  if (this.isQueryGroup(e)) {
1711
- const i = e.queries.map((n) => this.validateQuery(n)).filter((n) => !n.valid).map((n) => n.errors).flat();
1780
+ const i = e.queries.map((o) => this.validateQuery(o)).filter((o) => !o.valid).map((o) => o.errors).flat();
1712
1781
  return i.length > 0 ? { valid: !1, errors: i } : { valid: !0 };
1713
1782
  }
1714
- return t.push(new w("Invalid query definition", e)), { valid: !1, errors: t };
1783
+ return t.push(new A("Invalid query definition", e)), { valid: !1, errors: t };
1715
1784
  }
1716
1785
  /**
1717
1786
  * Get all attribute names used in the query.
@@ -1722,8 +1791,8 @@ class P {
1722
1791
  */
1723
1792
  getQueryAttributes(e) {
1724
1793
  const t = [], r = /* @__PURE__ */ new Set(), s = (i) => {
1725
- for (const n of i)
1726
- this.isQuery(n) ? n.attribute && !r.has(n.attribute) && (t.push(n.attribute), r.add(n.attribute)) : this.isQueryGroup(n) && s(n.queries);
1794
+ for (const o of i)
1795
+ this.isQuery(o) ? o.attribute && !r.has(o.attribute) && (t.push(o.attribute), r.add(o.attribute)) : this.isQueryGroup(o) && s(o.queries);
1727
1796
  };
1728
1797
  return s(e?.queries || this.currentQuery.queries), t;
1729
1798
  }
@@ -1736,13 +1805,13 @@ class P {
1736
1805
  */
1737
1806
  extractQueryAttributes(e) {
1738
1807
  const t = [], r = /* @__PURE__ */ new Set(), s = (i) => {
1739
- for (const n of i)
1740
- if (this.isQuery(n)) {
1741
- if (n.attribute && !r.has(n.attribute)) {
1742
- const a = this.getQueryAttributeForString(n.attribute);
1743
- t.push(a), r.add(n.attribute);
1808
+ for (const o of i)
1809
+ if (this.isQuery(o)) {
1810
+ if (o.attribute && !r.has(o.attribute)) {
1811
+ const a = this.getQueryAttributeForString(o.attribute);
1812
+ t.push(a), r.add(o.attribute);
1744
1813
  }
1745
- } else this.isQueryGroup(n) && s(n.queries);
1814
+ } else this.isQueryGroup(o) && s(o.queries);
1746
1815
  };
1747
1816
  return s(e?.queries || this.currentQuery.queries), t;
1748
1817
  }
@@ -1784,8 +1853,8 @@ class P {
1784
1853
  const s = this.deepQueryService.parse(r.referenceAttribute);
1785
1854
  if (s.isDeepQuery && r.reference) {
1786
1855
  const i = this.getProjectionForAttributeEntries([s]);
1787
- Object.keys(i).forEach((n) => {
1788
- n !== "$" && r.reference && (t[r.reference][n] = i[n]);
1856
+ Object.keys(i).forEach((o) => {
1857
+ o !== "$" && r.reference && (t[r.reference][o] = i[o]);
1789
1858
  });
1790
1859
  } else r.reference && (t[r.reference][r.referenceAttribute] = !0);
1791
1860
  } else
@@ -2084,8 +2153,8 @@ class P {
2084
2153
  for (const s of r)
2085
2154
  if (this.isQuery(s)) {
2086
2155
  let i = !0;
2087
- for (const n in e)
2088
- if (s[n] !== e[n]) {
2156
+ for (const o in e)
2157
+ if (s[o] !== e[o]) {
2089
2158
  i = !1;
2090
2159
  break;
2091
2160
  }
@@ -2210,48 +2279,89 @@ class P {
2210
2279
  return e(this.currentQuery.queries);
2211
2280
  }
2212
2281
  }
2213
- const S = new P();
2214
- function Be(o, e, t, r, s, i, n) {
2215
- const a = [], u = S.removeQuery({ groupKey: s }, y(r)), c = n.queryData(o, u, !1, i), f = e ? [...e.keys()] : [], d = new Set(f), l = i.get(s);
2282
+ const N = new j();
2283
+ function Xe(n, e, t, r, s, i, o) {
2284
+ const a = N.removeQuery({ groupKey: s }, v(r)), c = o.queryData(n, a, !1, i), u = e ? [...e.keys()] : [], f = new Set(u), l = i.get(s) ?? /* @__PURE__ */ new Map();
2216
2285
  if (!t.excludeUnresolved)
2217
2286
  for (const h of l.keys())
2218
- d.add(h);
2219
- t.excludeUndefineds ? d.delete(void 0) : d.add(void 0);
2220
- for (const h of d.values()) {
2221
- const A = /* @__PURE__ */ new Map(), _ = l.get(h) || /* @__PURE__ */ new Set();
2222
- for (const N of _) {
2223
- const k = c.get(N);
2224
- if (k && (A.set(N, k), !t?.calculateFacets))
2225
- break;
2226
- }
2227
- const M = {
2228
- key: String(h),
2229
- value: h,
2230
- selected: ye(s, h, r),
2231
- enabled: A.size > 0,
2232
- size: A.size,
2233
- entry: e.get(h),
2234
- resultKeys: Array.from(A.keys())
2235
- };
2236
- if (!(t?.excludeZeros && M.size === 0)) {
2237
- if (t?.count && a.length === t?.count)
2238
- return a;
2239
- a.push(M);
2287
+ f.add(h);
2288
+ if (t.excludeUndefineds ? f.delete(void 0) : f.add(void 0), t.sort) {
2289
+ const h = [];
2290
+ for (const m of f.values())
2291
+ h.push(G(m, l, c, e, s, r, !0));
2292
+ const g = t.excludeZeros ? h.filter((m) => m.size > 0) : h;
2293
+ return g.sort(ve(t.sort)), t.count ? g.slice(0, t.count) : g;
2294
+ }
2295
+ const d = [];
2296
+ for (const h of f.values()) {
2297
+ const g = G(
2298
+ h,
2299
+ l,
2300
+ c,
2301
+ e,
2302
+ s,
2303
+ r,
2304
+ !!t?.calculateFacets
2305
+ );
2306
+ if (!(t?.excludeZeros && g.size === 0)) {
2307
+ if (t?.count && d.length === t?.count)
2308
+ return d;
2309
+ d.push(g);
2240
2310
  }
2241
2311
  }
2242
- return a;
2312
+ return d;
2243
2313
  }
2244
- const ye = (o, e, t) => {
2245
- const r = t.queries.findIndex((s) => S.isQueryGroup(s) && s.groupKey === o);
2314
+ function G(n, e, t, r, s, i, o) {
2315
+ const a = /* @__PURE__ */ new Map(), c = e.get(n) || /* @__PURE__ */ new Set();
2316
+ for (const u of c) {
2317
+ const f = t.get(u);
2318
+ if (f && (a.set(u, f), !o))
2319
+ break;
2320
+ }
2321
+ return {
2322
+ key: String(n),
2323
+ value: n,
2324
+ selected: we(s, n, i),
2325
+ enabled: a.size > 0,
2326
+ size: a.size,
2327
+ entry: r?.get(n),
2328
+ resultKeys: Array.from(a.keys())
2329
+ };
2330
+ }
2331
+ function D(n, e) {
2332
+ if (n === void 0 && e === void 0) return 0;
2333
+ if (n === void 0) return 1;
2334
+ if (e === void 0) return -1;
2335
+ const t = typeof n, r = typeof e;
2336
+ if (t !== r) return t < r ? -1 : 1;
2337
+ if (t === "number") return n - e;
2338
+ if (t === "string") return n.localeCompare(e);
2339
+ const s = String(n), i = String(e);
2340
+ return s < i ? -1 : s > i ? 1 : 0;
2341
+ }
2342
+ function ve(n) {
2343
+ switch (n) {
2344
+ case "size-desc":
2345
+ return (e, t) => t.size - e.size || D(e.value, t.value);
2346
+ case "size-asc":
2347
+ return (e, t) => e.size - t.size || D(e.value, t.value);
2348
+ case "value-asc":
2349
+ return (e, t) => D(e.value, t.value);
2350
+ case "value-desc":
2351
+ return (e, t) => e.value === void 0 && t.value === void 0 ? 0 : e.value === void 0 ? 1 : t.value === void 0 ? -1 : -D(e.value, t.value);
2352
+ }
2353
+ }
2354
+ const we = (n, e, t) => {
2355
+ const r = t.queries.findIndex((s) => N.isQueryGroup(s) && s.groupKey === n);
2246
2356
  return r > -1 ? !!t.queries[r].queries.find((i) => {
2247
- if (S.isQuery(i)) {
2248
- const n = i.value?.key || i.value;
2249
- return i.attribute === o && n === e;
2357
+ if (N.isQuery(i)) {
2358
+ const o = i.value?.key || i.value;
2359
+ return i.attribute === n && o === e;
2250
2360
  }
2251
2361
  return !1;
2252
2362
  }) : !1;
2253
2363
  };
2254
- class me {
2364
+ class xe {
2255
2365
  indexMap = /* @__PURE__ */ new Map();
2256
2366
  // Possible performance gain*
2257
2367
  dataMap = /* @__PURE__ */ new Map();
@@ -2273,8 +2383,8 @@ class me {
2273
2383
  this.fillDataMap(e, [a]);
2274
2384
  return;
2275
2385
  } else s instanceof Date ? i = s.toISOString() : i = s;
2276
- let n = r.get(i);
2277
- n || (n = { key: i }, this.dataMap.get(e)?.set(i, n));
2386
+ let o = r.get(i);
2387
+ o || (o = { key: i }, this.dataMap.get(e)?.set(i, o));
2278
2388
  }
2279
2389
  }
2280
2390
  fillInverseIndex(e, t, r) {
@@ -2282,16 +2392,16 @@ class me {
2282
2392
  return;
2283
2393
  const s = this.indexMap.get(e) || /* @__PURE__ */ new Map();
2284
2394
  for (const i of r) {
2285
- let n;
2395
+ let o;
2286
2396
  if (typeof i == "object" && i && i.key)
2287
- n = i.key;
2397
+ o = i.key;
2288
2398
  else if (Array.isArray(i)) {
2289
- for (const u of i)
2290
- this.fillInverseIndex(e, t, [u]);
2399
+ for (const c of i)
2400
+ this.fillInverseIndex(e, t, [c]);
2291
2401
  return;
2292
- } else i instanceof Date ? n = i.toISOString() : n = i;
2293
- let a = s.get(n);
2294
- a || (a = /* @__PURE__ */ new Set(), s.set(n, a)), a.add(t);
2402
+ } else i instanceof Date ? o = i.toISOString() : o = i;
2403
+ let a = s.get(o);
2404
+ a || (a = /* @__PURE__ */ new Set(), s.set(o, a)), a.add(t);
2295
2405
  }
2296
2406
  this.indexMap.set(e, s);
2297
2407
  }
@@ -2306,31 +2416,31 @@ class me {
2306
2416
  getOrCreateIndex(e, t, r) {
2307
2417
  const s = this.getIndexName(e, r);
2308
2418
  let i = this.getIndex(s);
2309
- const n = this.indexMetadata.get(s);
2310
- if (n)
2311
- n.lastAccessedAt = Date.now();
2419
+ const o = this.indexMetadata.get(s);
2420
+ if (o)
2421
+ o.lastAccessedAt = Date.now();
2312
2422
  else if (!i) {
2313
- const u = g.parse(e).isDeepQuery ?? !1;
2423
+ const c = y.parse(e).isDeepQuery ?? !1;
2314
2424
  this.indexMetadata.set(s, {
2315
2425
  createdAt: Date.now(),
2316
2426
  lastAccessedAt: Date.now(),
2317
2427
  context: r,
2318
- type: u ? "deep" : "shallow"
2428
+ type: c ? "deep" : "shallow"
2319
2429
  });
2320
2430
  }
2321
2431
  if (!i) {
2322
2432
  this.reset(s), this.indexMap.set(s, /* @__PURE__ */ new Map());
2323
- const u = g.parse(e).isDeepQuery;
2324
- for (const c of t.values()) {
2325
- const f = u ? v(c, e) : c[e];
2326
- this.fillInverseIndex(s, c.key, [f]), this.fillDataMap(s, [f]);
2433
+ const c = y.parse(e).isDeepQuery;
2434
+ for (const u of t.values()) {
2435
+ let f;
2436
+ c ? (f = x(u, e), f.length === 0 && (f = [void 0])) : f = [u[e]], this.fillInverseIndex(s, u.key, f), this.fillDataMap(s, f);
2327
2437
  }
2328
2438
  i = this.getIndex(s) || /* @__PURE__ */ new Map();
2329
2439
  }
2330
2440
  return i;
2331
2441
  }
2332
2442
  getIndexName(e, t) {
2333
- return t ? e + "_" + I(t) : e;
2443
+ return t ? e + "_" + K(t) : e;
2334
2444
  }
2335
2445
  // ========== PARTIAL UPDATE METHODS ==========
2336
2446
  /**
@@ -2343,16 +2453,16 @@ class me {
2343
2453
  const s = this.indexMap.get(e);
2344
2454
  if (s)
2345
2455
  for (const i of r) {
2346
- let n;
2456
+ let o;
2347
2457
  if (typeof i == "object" && i && i.key)
2348
- n = i.key;
2458
+ o = i.key;
2349
2459
  else if (Array.isArray(i)) {
2350
- for (const u of i)
2351
- this.removeFromInverseIndex(e, t, [u]);
2460
+ for (const c of i)
2461
+ this.removeFromInverseIndex(e, t, [c]);
2352
2462
  return;
2353
- } else i instanceof Date ? n = i.toISOString() : n = i;
2354
- const a = s.get(n);
2355
- a && (a.delete(t), a.size === 0 && s.delete(n));
2463
+ } else i instanceof Date ? o = i.toISOString() : o = i;
2464
+ const a = s.get(o);
2465
+ a && (a.delete(t), a.size === 0 && s.delete(o));
2356
2466
  }
2357
2467
  }
2358
2468
  /**
@@ -2378,8 +2488,8 @@ class me {
2378
2488
  if (typeof s == "object" && s && s.key)
2379
2489
  i = s.key;
2380
2490
  else if (Array.isArray(s)) {
2381
- for (const n of s)
2382
- this.removeFromDataMap(e, [n]);
2491
+ for (const o of s)
2492
+ this.removeFromDataMap(e, [o]);
2383
2493
  return;
2384
2494
  } else s instanceof Date ? i = s.toISOString() : i = s;
2385
2495
  r.delete(i);
@@ -2424,7 +2534,7 @@ class me {
2424
2534
  isDeepQueryIndex(e) {
2425
2535
  const t = e.includes("_") ? e.split("_")[0] : e;
2426
2536
  try {
2427
- return g.parse(t).isDeepQuery ?? !1;
2537
+ return y.parse(t).isDeepQuery ?? !1;
2428
2538
  } catch {
2429
2539
  return !1;
2430
2540
  }
@@ -2485,8 +2595,8 @@ class me {
2485
2595
  getStats() {
2486
2596
  const e = this.getIndexCount(), t = Date.now();
2487
2597
  let r = 0, s = 0;
2488
- for (const n of this.indexMetadata.values()) {
2489
- const a = t - n.createdAt;
2598
+ for (const o of this.indexMetadata.values()) {
2599
+ const a = t - o.createdAt;
2490
2600
  r += a, a > s && (s = a);
2491
2601
  }
2492
2602
  const i = this.indexMetadata.size > 0 ? r / this.indexMetadata.size : 0;
@@ -2499,153 +2609,165 @@ class me {
2499
2609
  };
2500
2610
  }
2501
2611
  }
2502
- const m = "__";
2503
- function R(o, e, t = { key: "root" }, r = "root", s = new me(), i) {
2504
- const n = i || o;
2612
+ const w = "__";
2613
+ function P(n, e, t = { key: "root" }, r = "root", s = new xe(), i) {
2614
+ const o = i || n;
2505
2615
  for (const a of e.columns)
2506
- a.attribute && (g.parse(a.attribute), s.getOrCreateIndex(a.attribute, n));
2616
+ a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
2507
2617
  for (const a of e.rows)
2508
- a.attribute && (g.parse(a.attribute), s.getOrCreateIndex(a.attribute, n));
2618
+ a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
2509
2619
  for (const a of e.values)
2510
- a.attribute && (g.parse(a.attribute), s.getOrCreateIndex(a.attribute, n));
2620
+ a.attribute && (y.parse(a.attribute), s.getOrCreateIndex(a.attribute, o));
2511
2621
  if (e.rows && e.rows.length > 0) {
2512
2622
  t.rows = t.rows || [];
2513
- const a = ve(o, e.rows[0], e, s, r, i);
2623
+ const a = Ae(n, e.rows[0], e, s, r, i);
2514
2624
  t.rows.push(a);
2515
2625
  }
2516
2626
  if (e.columns && e.columns.length > 0) {
2517
2627
  t.columns = t.columns || [];
2518
- const a = z(o, e.columns[0], e, s, r, i);
2628
+ const a = L(n, e.columns[0], e, s, r, i);
2519
2629
  t.columns.push(a);
2520
2630
  }
2521
2631
  if (t.key === "root")
2522
2632
  for (const a of e.values) {
2523
2633
  if (t.values = t.values || [], r === "root" && e.options?.calculateTotals === !1)
2524
2634
  continue;
2525
- const u = Q(a, o, s.getIndex(a.attribute), a.attribute);
2526
- t.values.push(u);
2635
+ const c = C(a, n, s.getIndex(a.attribute), a.attribute);
2636
+ t.values.push(c);
2527
2637
  }
2528
2638
  return t;
2529
2639
  }
2530
- function ve(o, e, t, r, s = "", i) {
2531
- const n = { key: e.attribute }, a = r.getIndex(e.attribute);
2640
+ function Ae(n, e, t, r, s = "", i) {
2641
+ const o = { key: e.attribute }, a = r.getIndex(e.attribute);
2532
2642
  if (!a)
2533
- return n;
2534
- for (const [u, c] of a.entries()) {
2643
+ return o;
2644
+ for (const [c, u] of a.entries()) {
2535
2645
  const f = {
2536
- key: u,
2537
- value: u
2538
- }, d = /* @__PURE__ */ new Map();
2539
- for (const l of c)
2540
- o.has(l) && d.set(l, o.get(l));
2541
- if (d.size) {
2542
- for (const l of t.values) {
2646
+ key: c,
2647
+ value: c
2648
+ }, l = /* @__PURE__ */ new Map();
2649
+ for (const d of u)
2650
+ n.has(d) && l.set(d, n.get(d));
2651
+ if (l.size) {
2652
+ for (const d of t.values) {
2543
2653
  if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
2544
2654
  continue;
2545
- const h = Q(l, d, r.getIndex(l.attribute), l.attribute);
2655
+ const h = C(d, l, r.getIndex(d.attribute), d.attribute);
2546
2656
  f.values.push(h);
2547
2657
  }
2548
- if (n.rows = n.rows || [], n.rows.push(f), t.rows.length > 1) {
2549
- const l = { ...t, rows: t.rows.slice(1) };
2550
- R(
2551
- d,
2658
+ if (o.rows = o.rows || [], o.rows.push(f), t.rows.length > 1) {
2659
+ const d = { ...t, rows: t.rows.slice(1) };
2660
+ P(
2552
2661
  l,
2662
+ d,
2553
2663
  f,
2554
- s + m + e.attribute + m + u,
2664
+ s + w + e.attribute + w + c,
2555
2665
  r,
2556
2666
  i
2557
2667
  );
2558
2668
  } else if (t.columns)
2559
- for (const l of t.columns) {
2669
+ for (const d of t.columns) {
2560
2670
  f.columns = f.columns || [];
2561
- const h = z(
2562
- d,
2671
+ const h = L(
2563
2672
  l,
2673
+ d,
2564
2674
  t,
2565
2675
  r,
2566
- s + m + e.attribute + m + u,
2676
+ s + w + e.attribute + w + c,
2567
2677
  i
2568
2678
  );
2569
2679
  f.columns.push(h);
2570
2680
  }
2571
2681
  }
2572
2682
  }
2573
- return n;
2683
+ return o;
2574
2684
  }
2575
- function z(o, e, t, r, s = "", i) {
2576
- const n = { key: e.attribute }, a = r.getIndex(e.attribute);
2685
+ function L(n, e, t, r, s = "", i) {
2686
+ const o = { key: e.attribute }, a = r.getIndex(e.attribute);
2577
2687
  if (!a)
2578
- return n;
2579
- for (const [u, c] of a.entries()) {
2688
+ return o;
2689
+ for (const [c, u] of a.entries()) {
2580
2690
  const f = {
2581
- key: u,
2582
- value: u
2583
- }, d = /* @__PURE__ */ new Map();
2584
- for (const l of c)
2585
- o.has(l) && d.set(l, o.get(l));
2586
- if (d.size) {
2587
- for (const l of t.values) {
2691
+ key: c,
2692
+ value: c
2693
+ }, l = /* @__PURE__ */ new Map();
2694
+ for (const d of u)
2695
+ n.has(d) && l.set(d, n.get(d));
2696
+ if (l.size) {
2697
+ for (const d of t.values) {
2588
2698
  if (f.values = f.values || [], s === "root" && e?.calculateTotals === !1)
2589
2699
  continue;
2590
- const h = Q(l, d, r.getIndex(l.attribute), l.attribute);
2700
+ const h = C(d, l, r.getIndex(d.attribute), d.attribute);
2591
2701
  f.values.push(h);
2592
2702
  }
2593
- if (n.columns = n.columns || [], n.columns.push(f), t.columns.length > 1) {
2594
- const l = { ...t, columns: t.columns.slice(1) };
2595
- R(
2596
- d,
2703
+ if (o.columns = o.columns || [], o.columns.push(f), t.columns.length > 1) {
2704
+ const d = { ...t, columns: t.columns.slice(1) };
2705
+ P(
2597
2706
  l,
2707
+ d,
2598
2708
  f,
2599
- s + m + e.attribute + m + u,
2709
+ s + w + e.attribute + w + c,
2600
2710
  r,
2601
2711
  i
2602
2712
  );
2603
2713
  }
2604
2714
  }
2605
2715
  }
2606
- return n;
2716
+ return o;
2607
2717
  }
2608
- const Te = (o, e) => {
2609
- const t = [];
2610
- for (const r of o) {
2611
- for (const [s, i] of Object.entries(r)) {
2612
- const n = t.find((u) => u.key === s), a = Ae(i);
2613
- if (n)
2614
- n.type !== a && (n.type = "any");
2615
- else {
2616
- const u = {
2617
- key: s,
2618
- type: a
2619
- };
2620
- t.push(u);
2718
+ const be = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/, Se = /^-?\d+$/, De = /^-?\d+\.\d+$/, Ie = /^\d{1,2}([/.-])\d{1,2}\1\d{2,4}$/, Ke = (n) => n === "true" || n === "false" ? "boolean" : Se.test(n) ? "int" : De.test(n) ? "float" : be.test(n) && !Number.isNaN(Date.parse(n)) ? "date" : "string", Qe = (n) => Ie.test(n), Me = (n) => n == null || n === "", ke = (n) => {
2719
+ const e = [...n];
2720
+ return e.length <= 1 ? { type: e[0] ?? "any", conflict: !1 } : e.every((t) => t === "int" || t === "float") ? { type: "float", conflict: !1 } : { type: "any", conflict: !0 };
2721
+ }, Ne = (n, e = {}) => {
2722
+ const r = e.deep ?? (e.sampleSize !== void 0 && e.sampleSize > 1) ? e.sampleSize ?? 1 / 0 : 1, s = e.coerceStrings ?? !0, i = /* @__PURE__ */ new Map(), o = [], a = Math.min(n.length, r);
2723
+ for (let f = 0; f < a; f++) {
2724
+ const l = n[f];
2725
+ if (l)
2726
+ for (const [d, h] of Object.entries(l)) {
2727
+ let g = i.get(d);
2728
+ if (g || (g = { observed: /* @__PURE__ */ new Set(), empty: 0, scanned: 0 }, i.set(d, g), o.push(d)), g.scanned++, Me(h)) {
2729
+ g.empty++;
2730
+ continue;
2731
+ }
2732
+ let m;
2733
+ typeof h == "string" && s ? (m = Ke(h), m === "string" && !g.hint && Qe(h) && (g.hint = "column looks date-like (non-ISO) — review manually")) : m = $e(h), g.observed.add(m);
2621
2734
  }
2622
- }
2623
- if (!e)
2624
- break;
2625
2735
  }
2626
- return t;
2627
- }, we = (o) => Number(o) === o && o % 1 === 0, xe = (o) => Number(o) === o && o % 1 !== 0, Ae = (o) => {
2628
- switch (typeof o) {
2736
+ const c = [], u = [];
2737
+ for (const f of o) {
2738
+ const l = i.get(f), { type: d, conflict: h } = ke(l.observed.size ? l.observed : /* @__PURE__ */ new Set(["string"]));
2739
+ c.push({ key: f, type: d }), u.push({
2740
+ column: f,
2741
+ inferredType: d,
2742
+ observedTypes: [...l.observed].sort(),
2743
+ emptyRate: l.scanned === 0 ? 0 : l.empty / l.scanned,
2744
+ conflict: h,
2745
+ hint: l.hint
2746
+ });
2747
+ }
2748
+ return { properties: c, diagnostics: u };
2749
+ }, Ye = (n, e = !1) => Ne(n, typeof e == "boolean" ? { deep: e } : e).properties, Ce = (n) => Number(n) === n && n % 1 === 0, Ee = (n) => Number(n) === n && n % 1 !== 0, $e = (n) => {
2750
+ switch (typeof n) {
2629
2751
  case "string":
2630
2752
  return "string";
2631
2753
  case "number":
2632
- return we(o) ? "int" : xe(o) ? "float" : "any";
2754
+ return Ce(n) ? "int" : Ee(n) ? "float" : "any";
2633
2755
  case "boolean":
2634
2756
  return "boolean";
2635
2757
  case "object":
2636
- return re(o) ? "date" : "json";
2758
+ return se(n) ? "date" : "json";
2637
2759
  default:
2638
2760
  return "any";
2639
2761
  }
2640
- }, je = (o, e) => {
2641
- const t = ee(o.text || ""), r = e?.attributeKey || o.filterKey;
2762
+ }, et = (n, e) => {
2763
+ const t = te(n.text || ""), r = e?.attributeKey || n.filterKey;
2642
2764
  let s;
2643
2765
  const i = e?.comparisonType || "containsIgnoreCase";
2644
2766
  return i === "containsIgnoreCase" ? s = {
2645
- groupKey: o.filterKey,
2767
+ groupKey: n.filterKey,
2646
2768
  queries: [
2647
2769
  {
2648
- queryKey: o.text,
2770
+ queryKey: n.text,
2649
2771
  attribute: r,
2650
2772
  value: `/${t}/`,
2651
2773
  operator: "find",
@@ -2655,10 +2777,10 @@ const Te = (o, e) => {
2655
2777
  }
2656
2778
  ]
2657
2779
  } : i === "containsIgnoreCaseAndWhitespace" ? s = {
2658
- groupKey: o.filterKey,
2780
+ groupKey: n.filterKey,
2659
2781
  queries: [
2660
2782
  {
2661
- queryKey: o.text,
2783
+ queryKey: n.text,
2662
2784
  attribute: r,
2663
2785
  value: `/${t}/`,
2664
2786
  operator: "find",
@@ -2668,32 +2790,32 @@ const Te = (o, e) => {
2668
2790
  }
2669
2791
  ]
2670
2792
  } : i === "contains" ? s = {
2671
- groupKey: o.filterKey,
2793
+ groupKey: n.filterKey,
2672
2794
  queries: [
2673
2795
  {
2674
- queryKey: o.text,
2796
+ queryKey: n.text,
2675
2797
  attribute: r,
2676
2798
  value: `/${t}/`,
2677
2799
  operator: "find"
2678
2800
  }
2679
2801
  ]
2680
2802
  } : i === "equal" ? s = {
2681
- groupKey: o.filterKey,
2803
+ groupKey: n.filterKey,
2682
2804
  queries: [
2683
2805
  {
2684
- queryKey: o.text,
2806
+ queryKey: n.text,
2685
2807
  attribute: r,
2686
- value: o.text,
2808
+ value: n.text,
2687
2809
  operator: "eq"
2688
2810
  }
2689
2811
  ]
2690
2812
  } : i === "equalIgnoreCase" && (s = {
2691
- groupKey: o.filterKey,
2813
+ groupKey: n.filterKey,
2692
2814
  queries: [
2693
2815
  {
2694
- queryKey: o.text,
2816
+ queryKey: n.text,
2695
2817
  attribute: r,
2696
- value: o.text,
2818
+ value: n.text,
2697
2819
  operator: "eq",
2698
2820
  options: {
2699
2821
  transform: ["lowercase"]
@@ -2701,40 +2823,40 @@ const Te = (o, e) => {
2701
2823
  }
2702
2824
  ]
2703
2825
  }), s;
2704
- }, Pe = (o, e) => {
2705
- const t = e?.attributeKey || o.filterKey;
2826
+ }, tt = (n, e) => {
2827
+ const t = e?.attributeKey || n.filterKey;
2706
2828
  return {
2707
- groupKey: o.filterKey,
2829
+ groupKey: n.filterKey,
2708
2830
  queries: [
2709
2831
  {
2710
- queryKey: o.value,
2832
+ queryKey: n.value,
2711
2833
  attribute: t,
2712
- value: o.value,
2834
+ value: n.value,
2713
2835
  operator: "eq"
2714
2836
  }
2715
2837
  ]
2716
2838
  };
2717
- }, Re = (o, e) => {
2718
- const t = e?.attributeKey || o.filterKey, r = {
2719
- groupKey: o.filterKey,
2839
+ }, rt = (n, e) => {
2840
+ const t = e?.attributeKey || n.filterKey, r = {
2841
+ groupKey: n.filterKey,
2720
2842
  queries: []
2721
2843
  };
2722
- return typeof o.eq < "u" && (r.groupType = "or", Array.isArray(o.eq) ? o.eq.forEach((s) => {
2844
+ return typeof n.eq < "u" && (r.groupType = "or", Array.isArray(n.eq) ? n.eq.forEach((s) => {
2723
2845
  r.queries.push({ attribute: t, value: s, operator: "eq" });
2724
- }) : r.queries.push({ attribute: t, value: o.eq, operator: "eq" })), typeof o.ne < "u" && (r.groupType = "and", Array.isArray(o.ne) ? o.ne.forEach((s) => {
2846
+ }) : r.queries.push({ attribute: t, value: n.eq, operator: "eq" })), typeof n.ne < "u" && (r.groupType = "and", Array.isArray(n.ne) ? n.ne.forEach((s) => {
2725
2847
  r.queries.push({ attribute: t, value: s, operator: "eq", options: { invert: !0 } });
2726
2848
  }) : r.queries.push({
2727
2849
  attribute: t,
2728
- value: o.ne,
2850
+ value: n.ne,
2729
2851
  operator: "eq",
2730
2852
  options: { invert: !0 }
2731
- })), typeof o.gt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.gt, operator: "gt" })), typeof o.lt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.lt, operator: "lt" })), typeof o.gte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.gte, operator: "gte" })), typeof o.lte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: o.lte, operator: "lte" })), r;
2732
- }, ze = (o, e) => {
2733
- const t = e?.attributeKey || o.filterKey, r = {
2734
- groupKey: o.filterKey,
2853
+ })), typeof n.gt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.gt, operator: "gt" })), typeof n.lt < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.lt, operator: "lt" })), typeof n.gte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.gte, operator: "gte" })), typeof n.lte < "u" && (r.groupType = "and", r.queries.push({ attribute: t, value: n.lte, operator: "lte" })), r;
2854
+ }, st = (n, e) => {
2855
+ const t = e?.attributeKey || n.filterKey, r = {
2856
+ groupKey: n.filterKey,
2735
2857
  queries: []
2736
2858
  };
2737
- return o.itemKeys.forEach((s) => {
2859
+ return n.itemKeys.forEach((s) => {
2738
2860
  r.queries.push({
2739
2861
  queryKey: s,
2740
2862
  attribute: t,
@@ -2742,13 +2864,16 @@ const Te = (o, e) => {
2742
2864
  operator: "eq"
2743
2865
  });
2744
2866
  }), r;
2745
- }, _e = (o) => !(typeof o.modelKey != "string" || !Array.isArray(o.queries));
2746
- class We {
2867
+ }, nt = (n) => !(typeof n.modelKey != "string" || !Array.isArray(n.queries));
2868
+ class it {
2747
2869
  constructor(e, t, r) {
2748
2870
  this.scriptController = e, this.globalItemService = t, this.modelParser = r;
2749
2871
  }
2872
+ scriptController;
2873
+ globalItemService;
2874
+ modelParser;
2750
2875
  registeredCustomOperator = /* @__PURE__ */ new Map();
2751
- queryBuilder = new P();
2876
+ queryBuilder = new j();
2752
2877
  registerCustomOperator(e, t) {
2753
2878
  this.registeredCustomOperator.set(e, t);
2754
2879
  }
@@ -2764,83 +2889,83 @@ class We {
2764
2889
  evaluateQuery(e, t) {
2765
2890
  let r, s = e.value;
2766
2891
  const i = e.options?.arrayValueHandling || "some";
2767
- if (Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (s = this.transformValue(s, e.options.transform)), e.attribute.includes(".") || e.attribute.includes("[") ? r = v(t, e.attribute) : r = t[e.attribute], Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (r = this.transformValue(r, e.options.transform)), (typeof r > "u" || r === null) && !["typeof", "isTruthy", "eq"].includes(e.operator))
2892
+ if (Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (s = this.transformValue(s, e.options.transform)), e.attribute.includes(".") || e.attribute.includes("[") ? r = I(t, e.attribute) : r = t[e.attribute], Array.isArray(e.options?.transform) && e.options.transform.length > 0 && (r = this.transformValue(r, e.options.transform)), (typeof r > "u" || r === null) && !["typeof", "isTruthy", "eq"].includes(e.operator))
2768
2893
  return !1;
2769
2894
  switch (e.operator) {
2770
2895
  case "eq":
2771
- return e.options?.invert ? !E(r, s) : E(r, s);
2896
+ return e.options?.invert ? !$(r, s) : $(r, s);
2772
2897
  case "find":
2773
2898
  return e.options?.invert ? !this.queryFind(r, s, i) : this.queryFind(r, s, i);
2774
2899
  case "lt":
2775
- return Array.isArray(r) ? i === "some" ? r.some((n) => n < s) : r.every((n) => n < s) : r < s;
2900
+ return Array.isArray(r) ? i === "some" ? r.some((o) => o < s) : r.every((o) => o < s) : r < s;
2776
2901
  case "gt":
2777
- return Array.isArray(r) ? i === "some" ? r.some((n) => n > s) : r.every((n) => n > s) : r > s;
2902
+ return Array.isArray(r) ? i === "some" ? r.some((o) => o > s) : r.every((o) => o > s) : r > s;
2778
2903
  case "lte":
2779
- return Array.isArray(r) ? i === "some" ? r.some((n) => n <= s) : r.every((n) => n <= s) : r <= s;
2904
+ return Array.isArray(r) ? i === "some" ? r.some((o) => o <= s) : r.every((o) => o <= s) : r <= s;
2780
2905
  case "gte":
2781
- return Array.isArray(r) ? i === "some" ? r.some((n) => n >= s) : r.every((n) => n >= s) : r >= s;
2906
+ return Array.isArray(r) ? i === "some" ? r.some((o) => o >= s) : r.every((o) => o >= s) : r >= s;
2782
2907
  case "typeof":
2783
- return e.options?.invert ? typeof r !== s : Array.isArray(r) ? i === "some" ? r.some((n) => typeof n === s) : r.every((n) => typeof n === s) : typeof r === s;
2908
+ return e.options?.invert ? typeof r !== s : Array.isArray(r) ? i === "some" ? r.some((o) => typeof o === s) : r.every((o) => typeof o === s) : typeof r === s;
2784
2909
  case "isTruthy":
2785
- return s === !0 ? Array.isArray(r) ? i === "some" ? r.some((n) => typeof !!n) : r.every((n) => typeof !!n) : !!r : !r;
2910
+ return s === !0 ? Array.isArray(r) ? i === "some" ? r.some((o) => typeof !!o) : r.every((o) => typeof !!o) : !!r : !r;
2786
2911
  case "size":
2787
2912
  return typeof r == "string" ? r.length === s : W(r) === s;
2788
2913
  default:
2789
2914
  if (this.scriptController.hasScript(e.operator))
2790
2915
  return this.scriptController.executeScript(e.operator, "operator", { query: e, item: t });
2791
2916
  if (this.registeredCustomOperator.has(e.operator)) {
2792
- const n = this.registeredCustomOperator.get(e.operator);
2793
- if (typeof n == "function")
2794
- return n(e, t);
2917
+ const o = this.registeredCustomOperator.get(e.operator);
2918
+ if (typeof o == "function")
2919
+ return o(e, t);
2795
2920
  }
2796
2921
  }
2797
2922
  return !1;
2798
2923
  }
2799
2924
  evaluateEqOperator(e, t, r, s) {
2800
- const i = /* @__PURE__ */ new Map(), n = s.get(t.attribute);
2801
- if (n) {
2925
+ const i = /* @__PURE__ */ new Map(), o = s.get(t.attribute);
2926
+ if (o) {
2802
2927
  let a;
2803
2928
  if (typeof t.value == "string" ? a = t.value : t.value?.key && Object.keys(t.value).length === 1 && (a = t.value.key), typeof a < "u") {
2804
- const u = n.get(a);
2805
- if (u)
2806
- if (u.forEach((c) => {
2807
- r.has(c) && i.set(c, r.get(c));
2929
+ const c = o.get(a);
2930
+ if (c)
2931
+ if (c.forEach((u) => {
2932
+ r.has(u) && i.set(u, r.get(u));
2808
2933
  }), t.options?.invert) {
2809
- const c = q(Array.from(r.values()), Array.from(i.values()), "key"), f = /* @__PURE__ */ new Map();
2810
- return c.forEach((d) => {
2811
- f.set(d.key, d);
2934
+ const u = O(Array.from(r.values()), Array.from(i.values()), "key"), f = /* @__PURE__ */ new Map();
2935
+ return u.forEach((l) => {
2936
+ f.set(l.key, l);
2812
2937
  }), f;
2813
2938
  } else
2814
2939
  return i;
2815
2940
  }
2816
2941
  }
2817
- for (let [a, u] of r) {
2818
- const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2819
- if (c.some((f) => f.isDeepQuery)) {
2942
+ for (let [a, c] of r) {
2943
+ const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2944
+ if (u.some((f) => f.isDeepQuery)) {
2820
2945
  const f = this.queryBuilder.getProjectionForAttributeEntries(
2821
- c.filter((d) => d.isDeepQuery)
2946
+ u.filter((l) => l.isDeepQuery)
2822
2947
  );
2823
- u = this.globalItemService.getProjectedData(
2948
+ c = this.globalItemService.getProjectedData(
2824
2949
  f,
2825
2950
  this.modelParser.models.get(e.modelKey),
2826
- u
2951
+ c
2827
2952
  );
2828
2953
  }
2829
- this.evaluateQuery(t, u) && i.set(a, u);
2954
+ this.evaluateQuery(t, c) && i.set(a, c);
2830
2955
  }
2831
2956
  return i;
2832
2957
  }
2833
2958
  equalRegexFn(e, t) {
2834
- if (typeof t == "string" && L(t, "/") && H(t, "/"))
2959
+ if (typeof t == "string" && H(t, "/") && U(t, "/"))
2835
2960
  try {
2836
2961
  return new RegExp(t.slice(1, -1)).test(e);
2837
2962
  } catch {
2838
2963
  return !1;
2839
2964
  }
2840
- else return Array.isArray(e) ? !!e.find((r) => b(r, t, this.equalRegexFn)) : typeof t == "object" ? U(e, t) : e === t;
2965
+ else return Array.isArray(e) ? !!e.find((r) => S(r, t, this.equalRegexFn)) : typeof t == "object" ? V(e, t) : e === t;
2841
2966
  }
2842
2967
  queryFind(e, t, r) {
2843
- return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) => b(s, t, this.equalRegexFn)) : e.every((s) => b(s, t, this.equalRegexFn)) : !!V(e, t) : b(e, t, this.equalRegexFn);
2968
+ return Array.isArray(e) ? typeof t == "string" || typeof t == "number" || typeof t == "boolean" ? r === "some" ? e.some((s) => S(s, t, this.equalRegexFn)) : e.every((s) => S(s, t, this.equalRegexFn)) : !!J(e, t) : S(e, t, this.equalRegexFn);
2844
2969
  }
2845
2970
  validateQuery(e) {
2846
2971
  if (this.queryBuilder.isQuery(e)) {
@@ -2851,45 +2976,56 @@ class We {
2851
2976
  return !0;
2852
2977
  } else {
2853
2978
  if (this.queryBuilder.isQueryGroup(e))
2854
- return B(e.queries, (t) => this.validateQuery(t));
2979
+ return z(e.queries, (t) => this.validateQuery(t));
2855
2980
  throw new Error("invalid query - missing query or attribute");
2856
2981
  }
2857
2982
  }
2858
2983
  getEvaluatedQueryDataset(e, t, r, s) {
2859
2984
  const i = /* @__PURE__ */ new Map();
2860
- if (t.attribute.includes("[*]"))
2861
- for (let n of r.values()) {
2862
- const a = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2863
- if (a.some((c) => c.isDeepQuery)) {
2864
- const c = this.queryBuilder.getProjectionForAttributeEntries(
2865
- a.filter((f) => f.isDeepQuery)
2985
+ if (t.attribute.includes("[*]")) {
2986
+ const o = t.options?.invert === !0, a = /* @__PURE__ */ new Set();
2987
+ for (let c of r.values()) {
2988
+ const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2989
+ if (u.some((d) => d.isDeepQuery)) {
2990
+ const d = this.queryBuilder.getProjectionForAttributeEntries(
2991
+ u.filter((h) => h.isDeepQuery)
2866
2992
  );
2867
- n = this.globalItemService.getProjectedData(
2868
- c,
2993
+ c = this.globalItemService.getProjectedData(
2994
+ d,
2869
2995
  this.modelParser.models.get(e.modelKey),
2870
- n
2996
+ c
2871
2997
  );
2872
2998
  }
2873
- const u = this.handleArrayStarQuery(t, n);
2874
- for (const c of u.queries)
2875
- this.evaluateQuery(c, n) && i.set(n.key, n);
2999
+ const f = this.handleArrayStarQuery(t, c);
3000
+ let l = !1;
3001
+ for (const d of f.queries) {
3002
+ const h = { ...d, options: { ...d.options, invert: !1 } };
3003
+ if (this.evaluateQuery(h, c)) {
3004
+ l = !0;
3005
+ break;
3006
+ }
3007
+ }
3008
+ l && (a.add(c.key), o || i.set(c.key, c));
2876
3009
  }
2877
- else {
3010
+ if (o)
3011
+ for (const [c, u] of r)
3012
+ a.has(c) || i.set(c, u);
3013
+ } else {
2878
3014
  if (t.operator === "eq")
2879
3015
  return this.evaluateEqOperator(e, t, r, s);
2880
- for (let [n, a] of r) {
2881
- const u = this.queryBuilder.extractQueryAttributes({ queries: [t] });
2882
- if (u.some((c) => c.isDeepQuery)) {
2883
- const c = this.queryBuilder.getProjectionForAttributeEntries(
2884
- u.filter((f) => f.isDeepQuery)
3016
+ for (let [o, a] of r) {
3017
+ const c = this.queryBuilder.extractQueryAttributes({ queries: [t] });
3018
+ if (c.some((u) => u.isDeepQuery)) {
3019
+ const u = this.queryBuilder.getProjectionForAttributeEntries(
3020
+ c.filter((f) => f.isDeepQuery)
2885
3021
  );
2886
3022
  a = this.globalItemService.getProjectedData(
2887
- c,
3023
+ u,
2888
3024
  this.modelParser.models.get(e.modelKey),
2889
3025
  a
2890
3026
  );
2891
3027
  }
2892
- this.evaluateQuery(t, a) && i.set(n, a);
3028
+ this.evaluateQuery(t, a) && i.set(o, a);
2893
3029
  }
2894
3030
  }
2895
3031
  return i;
@@ -2901,37 +3037,38 @@ class We {
2901
3037
  queries: []
2902
3038
  };
2903
3039
  if (r !== -1) {
2904
- const i = e.attribute.substring(0, r), n = t[i];
2905
- if (Array.isArray(n))
2906
- for (let a = 0; a < n.length; a++) {
2907
- const u = e.attribute.replace("[*]", `[${a}]`);
3040
+ const i = e.attribute.substring(0, r), o = i.includes(".") ? I(t, i) : t[i];
3041
+ if (Array.isArray(o))
3042
+ for (let a = 0; a < o.length; a++) {
3043
+ const c = e.attribute.replace("[*]", `[${a}]`);
2908
3044
  s.queries.push({
2909
- attribute: u,
3045
+ attribute: c,
2910
3046
  operator: e.operator,
2911
- value: e.value
3047
+ value: e.value,
3048
+ options: e.options
2912
3049
  });
2913
3050
  }
2914
3051
  }
2915
3052
  return s;
2916
3053
  }
2917
3054
  evaluateQueryGroup(e, t, r, s, i) {
2918
- let n = /* @__PURE__ */ new Map(), a = r;
3055
+ let o = /* @__PURE__ */ new Map(), a = r;
2919
3056
  if (!t.queries || t.queries?.length === 0)
2920
3057
  return a;
2921
- for (const u of t.queries) {
2922
- let c = /* @__PURE__ */ new Map();
2923
- if (this.queryBuilder.isQuery(u) ? c = this.getEvaluatedQueryDataset(e, u, a, i) : c = this.evaluateQueryGroup(e, u, a, s, i), n.size === 0 && (n = c), t.groupType === "or")
2924
- c.forEach((f) => {
2925
- n.set(f.key, f);
3058
+ for (const c of t.queries) {
3059
+ let u = /* @__PURE__ */ new Map();
3060
+ if (this.queryBuilder.isQuery(c) ? u = this.getEvaluatedQueryDataset(e, c, a, i) : u = this.evaluateQueryGroup(e, c, a, s, i), o.size === 0 && (o = u), t.groupType === "or")
3061
+ u.forEach((f) => {
3062
+ o.set(f.key, f);
2926
3063
  });
2927
3064
  else {
2928
- const f = q(Array.from(n.values()), Array.from(c.values()), "key");
2929
- for (const d of f)
2930
- n.delete(d.key);
3065
+ const f = O(Array.from(o.values()), Array.from(u.values()), "key");
3066
+ for (const l of f)
3067
+ o.delete(l.key);
2931
3068
  }
2932
- t.groupType === "and" ? a = n : a = r;
3069
+ t.groupType === "and" ? a = o : a = r;
2933
3070
  }
2934
- return n;
3071
+ return o;
2935
3072
  }
2936
3073
  queryData(e, t, r, s) {
2937
3074
  const i = new Map(e);
@@ -2971,7 +3108,29 @@ class We {
2971
3108
  // }
2972
3109
  // }
2973
3110
  }
2974
- class Le {
3111
+ const Oe = "k:", qe = "h:";
3112
+ function M(n, e = 0) {
3113
+ if (n.key)
3114
+ return `${Oe}${n.key}`;
3115
+ const t = K({
3116
+ type: n.type,
3117
+ url: n.rawUrl ?? n.url,
3118
+ model: n.model ?? "",
3119
+ occurrence: e
3120
+ });
3121
+ return `${qe}${t}`;
3122
+ }
3123
+ function ot(n) {
3124
+ const e = /* @__PURE__ */ new Map(), t = /* @__PURE__ */ new Set();
3125
+ return n.map((r) => {
3126
+ const s = `${r.key ?? ""}|${r.type}|${r.rawUrl ?? r.url}|${r.model ?? ""}`;
3127
+ let i = e.get(s) ?? 0, o = M(r, i);
3128
+ for (; t.has(o); )
3129
+ i += 1, o = r.key ? `${M(r)}#${i}` : M(r, i);
3130
+ return e.set(s, i + 1), t.add(o), o;
3131
+ });
3132
+ }
3133
+ class at {
2975
3134
  scripts = /* @__PURE__ */ new Map();
2976
3135
  scriptFunctions = /* @__PURE__ */ new Map();
2977
3136
  constructor() {
@@ -3010,14 +3169,14 @@ class Le {
3010
3169
  if (!this.getScript(e))
3011
3170
  throw new Error(`Script ${e} not found`);
3012
3171
  r.context || (r.context = r.options || {});
3013
- const i = Object.keys(r), n = Object.values(r);
3014
- return this.getScriptAsFn(e, i)(t, ...n);
3172
+ const i = Object.keys(r), o = Object.values(r);
3173
+ return this.getScriptAsFn(e, i)(t, ...o);
3015
3174
  }
3016
3175
  }
3017
- const He = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => v(e, r.trim(), ""))) : "", Ue = (o) => {
3176
+ const ct = (n, e) => n ? (e || (e = {}), n.replace(/\$\{(.*?)\}/g, (t, r) => I(e, r.trim(), ""))) : "", ut = (n) => {
3018
3177
  const e = /* @__PURE__ */ new Set();
3019
- return o.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
3020
- }, Ve = [
3178
+ return n.replace(/\$\{(.*?)\}/g, (r, s) => (e.add(s.trim()), "")), { variables: Array.from(e).map((r) => ({ name: r })) };
3179
+ }, ft = [
3021
3180
  "any",
3022
3181
  "Array<date>",
3023
3182
  "Array<float>",
@@ -3029,7 +3188,7 @@ const He = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => v(e
3029
3188
  "int",
3030
3189
  "json",
3031
3190
  "string"
3032
- ], Je = ["int", "float", "Array<int>", "Array<float>"], Ze = ["date", "Array<date>"], Ye = [
3191
+ ], lt = ["int", "float", "Array<int>", "Array<float>"], dt = ["date", "Array<date>"], ht = [
3033
3192
  "eq",
3034
3193
  "find",
3035
3194
  "gt",
@@ -3041,56 +3200,64 @@ const He = (o, e) => o ? (e || (e = {}), o.replace(/\$\{(.*?)\}/g, (t, r) => v(e
3041
3200
  "size"
3042
3201
  ];
3043
3202
  export {
3044
- De as AnalyticsController,
3045
- Ke as AttributeDependencyGraph,
3046
- Se as CacheController,
3047
- Oe as ChangeDetector,
3048
- Ze as DatePropertyTypes,
3049
- P as DcuplQueryBuilder,
3050
- Ye as DcuplQueryOperatorsAsArray,
3051
- fe as DeepQueryService,
3052
- Z as DependencyGraph,
3053
- me as IndicesController,
3203
+ Oe as AUTHORED_RESOURCE_ID_PREFIX,
3204
+ Re as AnalyticsController,
3205
+ Te as AttributeDependencyGraph,
3206
+ Ge as CacheController,
3207
+ Ue as ChangeDetector,
3208
+ qe as DERIVED_RESOURCE_ID_PREFIX,
3209
+ dt as DatePropertyTypes,
3210
+ j as DcuplQueryBuilder,
3211
+ ht as DcuplQueryOperatorsAsArray,
3212
+ le as DeepQueryService,
3213
+ X as DependencyGraph,
3214
+ xe as IndicesController,
3054
3215
  p as Logger,
3055
- Je as NumberPropertyTypes,
3056
- Ve as PropertyTypesAsArray,
3057
- We as QueryManager,
3058
- Le as ScriptController,
3059
- j as clone,
3060
- te as compareVersions,
3061
- Fe as computeSuggestions,
3062
- g as deepQueryService,
3063
- ee as escapeRegExp,
3064
- He as evaluateTemplate,
3065
- Pe as generateBooleanQuery,
3066
- X as generateKey,
3067
- Re as generateNumberAndDateQuery,
3068
- ze as generateReferenceQuery,
3069
- je as generateTextQuery,
3070
- Q as getAggregation,
3071
- Me as getDateConstraintUid,
3072
- Ae as getDcuplPropertyTypeForNativeType,
3073
- ge as getDistinct,
3074
- Be as getFacets,
3075
- Ie as getFilterEntryId,
3076
- Qe as getNumberConstraintUid,
3077
- Te as getPropertiesForData,
3078
- ke as groupBy,
3079
- qe as hasMinimumVersion,
3080
- re as isDateInstance,
3081
- xe as isFloat,
3082
- we as isInt,
3083
- se as isValidDate,
3084
- _e as isValidQueryStatement,
3085
- $ as isValidVersion,
3216
+ lt as NumberPropertyTypes,
3217
+ ft as PropertyTypesAsArray,
3218
+ it as QueryManager,
3219
+ at as ScriptController,
3220
+ B as clone,
3221
+ Ke as coerceStringType,
3222
+ re as compareVersions,
3223
+ Je as computeSuggestions,
3224
+ y as deepQueryService,
3225
+ te as escapeRegExp,
3226
+ ct as evaluateTemplate,
3227
+ tt as generateBooleanQuery,
3228
+ ee as generateKey,
3229
+ rt as generateNumberAndDateQuery,
3230
+ st as generateReferenceQuery,
3231
+ et as generateTextQuery,
3232
+ C as getAggregation,
3233
+ Be as getDateConstraintUid,
3234
+ $e as getDcuplPropertyTypeForNativeType,
3235
+ x as getDeepPathValues,
3236
+ me as getDistinct,
3237
+ Xe as getFacets,
3238
+ ze as getFilterEntryId,
3239
+ _e as getNumberConstraintUid,
3240
+ Ye as getPropertiesForData,
3241
+ Pe as groupBy,
3242
+ He as hasMinimumVersion,
3243
+ Ne as inferModel,
3244
+ se as isDateInstance,
3245
+ Ee as isFloat,
3246
+ Ce as isInt,
3247
+ ne as isValidDate,
3248
+ nt as isValidQueryStatement,
3249
+ F as isValidVersion,
3086
3250
  Y as logger,
3087
- Ge as parseDate,
3088
- Ue as parseTemplate,
3089
- x as perf,
3090
- R as pivot,
3091
- Ce as removeTrailingSlash,
3092
- $e as trigger,
3093
- Ee as unescapeRegExp,
3094
- Ne as uniqBy
3251
+ Qe as looksDateLike,
3252
+ Ze as parseDate,
3253
+ ut as parseTemplate,
3254
+ b as perf,
3255
+ P as pivot,
3256
+ Le as removeTrailingSlash,
3257
+ M as resolveResourceId,
3258
+ ot as resolveResourceIds,
3259
+ Ve as trigger,
3260
+ We as unescapeRegExp,
3261
+ je as uniqBy
3095
3262
  };
3096
3263
  //# sourceMappingURL=index.js.map