interaqt 0.4.12 → 0.4.13

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.
package/dist/index.js CHANGED
@@ -1,63 +1,63 @@
1
- import { uuidv7 as pe } from "uuidv7";
2
- import { parse as Me } from "acorn";
3
- import { AsyncLocalStorage as fe } from "async_hooks";
4
- import $e from "better-sqlite3";
5
- import Pe from "pg";
6
- import { PGlite as De } from "@electric-sql/pglite";
7
- import ae from "mysql2/promise";
8
- function me(u) {
1
+ import { uuidv7 as Pe } from "uuidv7";
2
+ import { parse as De } from "acorn";
3
+ import { AsyncLocalStorage as ye } from "async_hooks";
4
+ import Oe from "better-sqlite3";
5
+ import Fe from "pg";
6
+ import { PGlite as Ve } from "@electric-sql/pglite";
7
+ import ne from "mysql2/promise";
8
+ function ge(u) {
9
9
  return u !== null && typeof u == "object";
10
10
  }
11
- function ye(u) {
12
- if (!me(u)) return !1;
11
+ function be(u) {
12
+ if (!ge(u)) return !1;
13
13
  const t = Object.getPrototypeOf(u);
14
14
  return t === null ? !0 : t === Object.prototype || t === null;
15
15
  }
16
- function Oe(u, t) {
16
+ function Qe(u, t) {
17
17
  const e = {};
18
18
  for (const r of u)
19
19
  r && r[t] !== void 0 && (e[String(r[t])] = r);
20
20
  return e;
21
21
  }
22
22
  function w(u) {
23
- return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u : me(u) && !ye(u) ? `uuid::${u.uuid}` : u;
23
+ return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u : ge(u) && !be(u) ? `uuid::${u.uuid}` : u;
24
24
  }
25
- function Rt(u, t) {
25
+ function wt(u, t) {
26
26
  if (u == null || typeof u != "object") return u;
27
- if (Array.isArray(u)) return u.map((r) => Rt(r, t));
28
- if (ye(u))
29
- return Object.fromEntries(Object.entries(u).map(([r, i]) => [r, Rt(i, t)]));
27
+ if (Array.isArray(u)) return u.map((r) => wt(r, t));
28
+ if (be(u))
29
+ return Object.fromEntries(Object.entries(u).map(([r, i]) => [r, wt(i, t)]));
30
30
  if (u instanceof Set)
31
- return new Set(Array.from(u.values()).map((r) => Rt(r, t)));
31
+ return new Set(Array.from(u.values()).map((r) => wt(r, t)));
32
32
  if (u instanceof Map)
33
- return new Map(Array.from(u.entries()).map(([r, i]) => [r, Rt(i, t)]));
33
+ return new Map(Array.from(u.entries()).map(([r, i]) => [r, wt(i, t)]));
34
34
  const e = u;
35
35
  return t && e._type && e.constructor?.clone ? e.constructor.clone(u, t) : u;
36
36
  }
37
- function Ni(...u) {
37
+ function Ci(...u) {
38
38
  for (const t of u)
39
39
  t.instances.length = 0;
40
40
  }
41
- function Ti() {
41
+ function xi() {
42
42
  }
43
- const _t = /* @__PURE__ */ new Map();
44
- function Fe(u, t) {
45
- t && t.isKlass && t.displayName && _t.set(u, t);
43
+ const Bt = /* @__PURE__ */ new Map();
44
+ function Le(u, t) {
45
+ t && t.isKlass && t.displayName && Bt.set(u, t);
46
46
  }
47
- function Si() {
47
+ function Mi() {
48
48
  const u = [];
49
- return Array.from(_t.entries()).forEach(([, t]) => {
49
+ return Array.from(Bt.entries()).forEach(([, t]) => {
50
50
  t.instances && Array.isArray(t.instances) && t.stringify && u.push(...t.instances.map((e) => t.stringify(e)));
51
51
  }), `[${u.join(",")}]`;
52
52
  }
53
- function vi(u) {
53
+ function $i(u) {
54
54
  const t = JSON.parse(u);
55
- return Qe(t);
55
+ return _e(t);
56
56
  }
57
- function Qe(u) {
57
+ function _e(u) {
58
58
  const t = /* @__PURE__ */ new Map();
59
59
  return u.forEach(({ type: e, options: r = {}, uuid: i, public: s }) => {
60
- const a = _t.get(e);
60
+ const a = Bt.get(e);
61
61
  if (!a) {
62
62
  console.warn(`Class ${e} not found in KlassByName`);
63
63
  return;
@@ -66,10 +66,10 @@ function Qe(u) {
66
66
  t.set(i, o);
67
67
  }), t;
68
68
  }
69
- function ki(u) {
69
+ function Pi(u) {
70
70
  return console.warn("createClass is deprecated in refactored code"), null;
71
71
  }
72
- class Ai {
72
+ class Di {
73
73
  static {
74
74
  this.isKlass = !0;
75
75
  }
@@ -92,9 +92,9 @@ class Ai {
92
92
  }
93
93
  }
94
94
  function S(u) {
95
- return u?.uuid || pe();
95
+ return u?.uuid || Pe();
96
96
  }
97
- const Ve = /^[a-zA-Z0-9_]+$/;
97
+ const qe = /^[a-zA-Z0-9_]+$/;
98
98
  class C {
99
99
  // for Merged Entity
100
100
  constructor(t, e) {
@@ -115,7 +115,7 @@ class C {
115
115
  type: "string",
116
116
  required: !0,
117
117
  constraints: {
118
- nameFormat: ({ name: t }) => Ve.test(t)
118
+ nameFormat: ({ name: t }) => qe.test(t)
119
119
  }
120
120
  },
121
121
  properties: {
@@ -196,9 +196,9 @@ class C {
196
196
  return this.create(e.public, e.options);
197
197
  }
198
198
  }
199
- var qt = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(qt || {});
200
- const Le = /^[a-zA-Z0-9_]+$/;
201
- class Bt {
199
+ var Wt = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(Wt || {});
200
+ const Be = /^[a-zA-Z0-9_]+$/;
201
+ class Jt {
202
202
  constructor(t, e) {
203
203
  this._type = "Dictionary", this._options = e, this.uuid = S(e), this.name = t.name, this.type = t.type, this.collection = t.collection ?? !1, this.args = t.args, this.defaultValue = t.defaultValue, this.computation = t.computation;
204
204
  }
@@ -218,7 +218,7 @@ class Bt {
218
218
  required: !0,
219
219
  collection: !1,
220
220
  constraints: {
221
- format: ({ name: t }) => Le.test(t),
221
+ format: ({ name: t }) => Be.test(t),
222
222
  length: ({ name: t }) => t.length > 1 && t.length < 5
223
223
  }
224
224
  },
@@ -226,7 +226,7 @@ class Bt {
226
226
  type: "string",
227
227
  required: !0,
228
228
  collection: !1,
229
- options: Array.from(Object.values(qt))
229
+ options: Array.from(Object.values(Wt))
230
230
  },
231
231
  collection: {
232
232
  type: "boolean",
@@ -252,7 +252,7 @@ class Bt {
252
252
  };
253
253
  }
254
254
  static create(t, e) {
255
- const r = new Bt(t, e);
255
+ const r = new Jt(t, e);
256
256
  if (this.instances.find((s) => s.uuid === r.uuid))
257
257
  throw new Error(`duplicate uuid in options ${r.uuid}, Dictionary`);
258
258
  return this.instances.push(r), r;
@@ -291,7 +291,7 @@ class Bt {
291
291
  return this.create(e.public, e.options);
292
292
  }
293
293
  }
294
- const _e = /^[a-zA-Z0-9_]+$/;
294
+ const We = /^[a-zA-Z0-9_]+$/;
295
295
  class T {
296
296
  constructor(t, e) {
297
297
  this._type = "Property", this._options = e, this.uuid = S(e), this.name = t.name, this.type = t.type, this.collection = t.collection, this.defaultValue = t.defaultValue, this.computed = t.computed, this.computation = t.computation;
@@ -311,14 +311,14 @@ class T {
311
311
  type: "string",
312
312
  required: !0,
313
313
  constraints: {
314
- format: ({ name: t }) => _e.test(t),
314
+ format: ({ name: t }) => We.test(t),
315
315
  length: ({ name: t }) => t.length > 1 && t.length < 5
316
316
  }
317
317
  },
318
318
  type: {
319
319
  type: "string",
320
320
  required: !0,
321
- options: () => Object.values(qt)
321
+ options: () => Object.values(Wt)
322
322
  },
323
323
  collection: {
324
324
  type: "boolean",
@@ -557,7 +557,7 @@ class P {
557
557
  return this.create(e.public, e.options);
558
558
  }
559
559
  }
560
- class Wt {
560
+ class jt {
561
561
  constructor(t, e) {
562
562
  this._type = "Interaction", this._options = e, this.uuid = S(e), this.name = t.name, this.conditions = t.conditions, this.userAttributives = t.userAttributives, this.userRef = t.userRef, this.action = t.action, this.payload = t.payload, this.sideEffects = t.sideEffects || [], this.data = t.data, this.query = t.query;
563
563
  }
@@ -618,7 +618,7 @@ class Wt {
618
618
  };
619
619
  }
620
620
  static create(t, e) {
621
- const r = new Wt(t, e);
621
+ const r = new jt(t, e);
622
622
  if (this.instances.find((s) => s.uuid === r.uuid))
623
623
  throw new Error(`duplicate uuid in options ${r.uuid}, Interaction`);
624
624
  return this.instances.push(r), r;
@@ -655,7 +655,7 @@ class Wt {
655
655
  return this.create(e.public, e.options);
656
656
  }
657
657
  }
658
- class Jt {
658
+ class Ut {
659
659
  constructor(t, e) {
660
660
  this._type = "Activity", this._options = e, this.uuid = S(e), this.name = t.name, this.interactions = t.interactions || [], this.gateways = t.gateways || [], this.transfers = t.transfers || [], this.groups = t.groups || [], this.events = t.events || [];
661
661
  }
@@ -703,7 +703,7 @@ class Jt {
703
703
  };
704
704
  }
705
705
  static create(t, e) {
706
- const r = new Jt(t, e);
706
+ const r = new Ut(t, e);
707
707
  if (this.instances.find((s) => s.uuid === r.uuid))
708
708
  throw new Error(`duplicate uuid in options ${r.uuid}, Activity`);
709
709
  return this.instances.push(r), r;
@@ -741,7 +741,7 @@ class Jt {
741
741
  return this.create(e.public, e.options);
742
742
  }
743
743
  }
744
- class rt {
744
+ class it {
745
745
  constructor(t, e) {
746
746
  this._type = "ActivityGroup", this._options = e, this.uuid = S(e), this.type = t.type, this.activities = t.activities || [];
747
747
  }
@@ -770,7 +770,7 @@ class rt {
770
770
  };
771
771
  }
772
772
  static create(t, e) {
773
- const r = new rt(t, e);
773
+ const r = new it(t, e);
774
774
  if (this.instances.find((s) => s.uuid === r.uuid))
775
775
  throw new Error(`duplicate uuid in options ${r.uuid}, ActivityGroup`);
776
776
  return this.instances.push(r), r;
@@ -804,7 +804,7 @@ class rt {
804
804
  return this.create(e.public, e.options);
805
805
  }
806
806
  }
807
- class ge {
807
+ class Re {
808
808
  constructor(t, e) {
809
809
  this._type = "Transfer", this._options = e, this.uuid = S(e), this.name = t.name, this.source = t.source, this.target = t.target;
810
810
  }
@@ -837,7 +837,7 @@ class ge {
837
837
  };
838
838
  }
839
839
  static create(t, e) {
840
- const r = new ge(t, e);
840
+ const r = new Re(t, e);
841
841
  if (this.instances.find((s) => s.uuid === r.uuid))
842
842
  throw new Error(`duplicate uuid in options ${r.uuid}, Transfer`);
843
843
  return this.instances.push(r), r;
@@ -873,19 +873,19 @@ class ge {
873
873
  return this.create(e.public, e.options);
874
874
  }
875
875
  }
876
- function be(u, t, e) {
876
+ function we(u, t, e) {
877
877
  u.interactions.forEach((r) => t(r, e)), u.groups.forEach((r) => {
878
- r.activities?.forEach((i) => be(i, t, r));
878
+ r.activities?.forEach((i) => we(i, t, r));
879
879
  });
880
880
  }
881
- function Ei(u) {
881
+ function Oi(u) {
882
882
  const t = [];
883
- return be(u, (e) => t.push(e)), t;
883
+ return we(u, (e) => t.push(e)), t;
884
884
  }
885
- function Ii(u) {
885
+ function Fi(u) {
886
886
  return null;
887
887
  }
888
- class ot {
888
+ class nt {
889
889
  constructor(t, e) {
890
890
  this._type = "BoolAtomData", this._options = e, this.uuid = S(e), this.type = t.type || "atom", this.data = t.data;
891
891
  }
@@ -914,7 +914,7 @@ class ot {
914
914
  };
915
915
  }
916
916
  static create(t, e) {
917
- const r = new ot(t, e);
917
+ const r = new nt(t, e);
918
918
  if (this.instances.find((s) => s.uuid === r.uuid))
919
919
  throw new Error(`duplicate uuid in options ${r.uuid}, BoolAtomData`);
920
920
  return this.instances.push(r), r;
@@ -948,7 +948,7 @@ class ot {
948
948
  return this.create(e.public, e.options);
949
949
  }
950
950
  }
951
- class nt {
951
+ class ct {
952
952
  constructor(t, e) {
953
953
  this._type = "BoolExpressionData", this._options = e, this.uuid = S(e), this.type = t.type || "expression", this.operator = t.operator || "and", this.left = t.left, this.right = t.right;
954
954
  }
@@ -989,7 +989,7 @@ class nt {
989
989
  };
990
990
  }
991
991
  static create(t, e) {
992
- const r = new nt(t, e);
992
+ const r = new ct(t, e);
993
993
  if (this.instances.find((s) => s.uuid === r.uuid))
994
994
  throw new Error(`duplicate uuid in options ${r.uuid}, BoolExpressionData`);
995
995
  return this.instances.push(r), r;
@@ -1175,21 +1175,21 @@ class R {
1175
1175
  throw new Error(`invalid bool expression type: ${JSON.stringify(this.raw)}`);
1176
1176
  }
1177
1177
  }
1178
- const qe = {
1178
+ const Je = {
1179
1179
  "&&": "and",
1180
1180
  "||": "or",
1181
1181
  "!": "not"
1182
1182
  };
1183
- function Be(u) {
1183
+ function je(u) {
1184
1184
  return { key: u };
1185
1185
  }
1186
- function wt(u, t, e) {
1186
+ function Tt(u, t, e) {
1187
1187
  if (u.type === "LogicalExpression")
1188
1188
  return {
1189
1189
  type: "expression",
1190
- operator: qe[u.operator],
1191
- left: wt(u.left, t, e),
1192
- right: wt(u.right, t, e)
1190
+ operator: Je[u.operator],
1191
+ left: Tt(u.left, t, e),
1192
+ right: Tt(u.right, t, e)
1193
1193
  };
1194
1194
  if (u.type === "Identifier")
1195
1195
  return {
@@ -1200,17 +1200,17 @@ function wt(u, t, e) {
1200
1200
  return {
1201
1201
  type: "expression",
1202
1202
  operator: "not",
1203
- left: wt(u.argument, t, e)
1203
+ left: Tt(u.argument, t, e)
1204
1204
  };
1205
1205
  throw new Error("unknown ast node type");
1206
1206
  }
1207
- function Ci(u, t = [], e = Be) {
1208
- const r = Oe(t, "name"), i = Me(u, { ecmaVersion: 2020 });
1207
+ function Vi(u, t = [], e = je) {
1208
+ const r = Qe(t, "name"), i = De(u, { ecmaVersion: 2020 });
1209
1209
  return new R(
1210
- wt(i.body[0].expression, r, e)
1210
+ Tt(i.body[0].expression, r, e)
1211
1211
  );
1212
1212
  }
1213
- class X {
1213
+ class Y {
1214
1214
  constructor(t, e) {
1215
1215
  this._type = "Attributive", this._options = e, this.uuid = S(e), this.stringContent = t.stringContent, this.content = t.content, this.name = t.name, this.isRef = t.isRef;
1216
1216
  }
@@ -1242,7 +1242,7 @@ class X {
1242
1242
  };
1243
1243
  }
1244
1244
  static create(t, e) {
1245
- const r = new X(t, e);
1245
+ const r = new Y(t, e);
1246
1246
  if (this.instances.find((s) => s.uuid === r.uuid))
1247
1247
  throw new Error(`duplicate uuid in options ${r.uuid}, Attributive`);
1248
1248
  return this.instances.push(r), r;
@@ -1278,7 +1278,7 @@ class X {
1278
1278
  return r.content && typeof r.content == "string" && r.content.startsWith("func::") && (r.content = new Function("return " + r.content.substring(6))()), this.create(r, e.options);
1279
1279
  }
1280
1280
  }
1281
- class Et {
1281
+ class Ct {
1282
1282
  constructor(t, e) {
1283
1283
  this._type = "Attributives", this._options = e, this.uuid = S(e), this.content = t.content;
1284
1284
  }
@@ -1301,7 +1301,7 @@ class Et {
1301
1301
  };
1302
1302
  }
1303
1303
  static create(t, e) {
1304
- const r = new Et(t, e);
1304
+ const r = new Ct(t, e);
1305
1305
  if (this.instances.find((s) => s.uuid === r.uuid))
1306
1306
  throw new Error(`duplicate uuid in options ${r.uuid}, Attributives`);
1307
1307
  return this.instances.push(r), r;
@@ -1332,24 +1332,24 @@ class Et {
1332
1332
  return this.create(e.public, e.options);
1333
1333
  }
1334
1334
  }
1335
- function Ot(u) {
1335
+ function Vt(u) {
1336
1336
  if (!u) return;
1337
1337
  if (u.raw.type === "atom")
1338
- return ot.create({
1338
+ return nt.create({
1339
1339
  type: "atom",
1340
1340
  data: u.raw.data
1341
1341
  });
1342
1342
  const t = u.raw;
1343
- return nt.create({
1343
+ return ct.create({
1344
1344
  type: "expression",
1345
1345
  operator: t.operator,
1346
- left: Ot(u.left),
1347
- right: Ot(u.right)
1346
+ left: Vt(u.left),
1347
+ right: Vt(u.right)
1348
1348
  });
1349
1349
  }
1350
- function xi(u) {
1351
- return Et.create({
1352
- content: Ot(u)
1350
+ function Qi(u) {
1351
+ return Ct.create({
1352
+ content: Vt(u)
1353
1353
  });
1354
1354
  }
1355
1355
  class Ht {
@@ -1412,7 +1412,7 @@ class Ht {
1412
1412
  return r.content && typeof r.content == "string" && r.content.startsWith("func::") && (r.content = new Function("return " + r.content.substring(6))()), this.create(r, e.options);
1413
1413
  }
1414
1414
  }
1415
- class jt {
1415
+ class Gt {
1416
1416
  constructor(t, e) {
1417
1417
  this._type = "DataAttributive", this._options = e, this.uuid = S(e), this.content = t.content, this.name = t.name;
1418
1418
  }
@@ -1438,7 +1438,7 @@ class jt {
1438
1438
  };
1439
1439
  }
1440
1440
  static create(t, e) {
1441
- const r = new jt(t, e);
1441
+ const r = new Gt(t, e);
1442
1442
  if (this.instances.find((s) => s.uuid === r.uuid))
1443
1443
  throw new Error(`duplicate uuid in options ${r.uuid}, DataAttributive`);
1444
1444
  return this.instances.push(r), r;
@@ -1472,7 +1472,7 @@ class jt {
1472
1472
  return r.content && typeof r.content == "string" && r.content.startsWith("func::") && (r.content = new Function("return " + r.content.substring(6))()), this.create(r, e.options);
1473
1473
  }
1474
1474
  }
1475
- class Re {
1475
+ class Ne {
1476
1476
  constructor(t, e) {
1477
1477
  this._type = "QueryItem", this._options = e, this.uuid = S(e), this.name = t.name, this.value = t.value;
1478
1478
  }
@@ -1500,7 +1500,7 @@ class Re {
1500
1500
  };
1501
1501
  }
1502
1502
  static create(t, e) {
1503
- const r = new Re(t, e);
1503
+ const r = new Ne(t, e);
1504
1504
  if (this.instances.find((s) => s.uuid === r.uuid))
1505
1505
  throw new Error(`duplicate uuid in options ${r.uuid}, QueryItem`);
1506
1506
  return this.instances.push(r), r;
@@ -1534,7 +1534,7 @@ class Re {
1534
1534
  return this.create(e.public, e.options);
1535
1535
  }
1536
1536
  }
1537
- class we {
1537
+ class Te {
1538
1538
  constructor(t, e) {
1539
1539
  this._type = "Query", this._options = e, this.uuid = S(e), this.items = t.items;
1540
1540
  }
@@ -1557,7 +1557,7 @@ class we {
1557
1557
  };
1558
1558
  }
1559
1559
  static create(t, e) {
1560
- const r = new we(t, e);
1560
+ const r = new Te(t, e);
1561
1561
  if (this.instances.find((s) => s.uuid === r.uuid))
1562
1562
  throw new Error(`duplicate uuid in options ${r.uuid}, Query`);
1563
1563
  return this.instances.push(r), r;
@@ -1589,7 +1589,7 @@ class we {
1589
1589
  return this.create(e.public, e.options);
1590
1590
  }
1591
1591
  }
1592
- class It {
1592
+ class xt {
1593
1593
  constructor(t, e) {
1594
1594
  this._type = "Action", this._options = e, this.uuid = S(e), this.name = t.name;
1595
1595
  }
@@ -1611,7 +1611,7 @@ class It {
1611
1611
  };
1612
1612
  }
1613
1613
  static create(t, e) {
1614
- const r = new It(t, e);
1614
+ const r = new xt(t, e);
1615
1615
  if (this.instances.find((s) => s.uuid === r.uuid))
1616
1616
  throw new Error(`duplicate uuid in options ${r.uuid}, Action`);
1617
1617
  return this.instances.push(r), r;
@@ -1643,8 +1643,8 @@ class It {
1643
1643
  return this.create(e.public, e.options);
1644
1644
  }
1645
1645
  }
1646
- const We = It.create({ name: "get" });
1647
- class it {
1646
+ const Ue = xt.create({ name: "get" });
1647
+ class st {
1648
1648
  constructor(t, e) {
1649
1649
  this._type = "Gateway", this._options = e, this.uuid = S(e), this.name = t.name;
1650
1650
  }
@@ -1666,7 +1666,7 @@ class it {
1666
1666
  };
1667
1667
  }
1668
1668
  static create(t, e) {
1669
- const r = new it(t, e);
1669
+ const r = new st(t, e);
1670
1670
  if (this.instances.find((s) => s.uuid === r.uuid))
1671
1671
  throw new Error(`duplicate uuid in options ${r.uuid}, Gateway`);
1672
1672
  return this.instances.push(r), r;
@@ -1698,7 +1698,7 @@ class it {
1698
1698
  return this.create(e.public, e.options);
1699
1699
  }
1700
1700
  }
1701
- class Ut {
1701
+ class Kt {
1702
1702
  constructor(t, e) {
1703
1703
  this._type = "Event", this._options = e, this.uuid = S(e), this.name = t.name;
1704
1704
  }
@@ -1720,7 +1720,7 @@ class Ut {
1720
1720
  };
1721
1721
  }
1722
1722
  static create(t, e) {
1723
- const r = new Ut(t, e);
1723
+ const r = new Kt(t, e);
1724
1724
  if (this.instances.find((s) => s.uuid === r.uuid))
1725
1725
  throw new Error(`duplicate uuid in options ${r.uuid}, Event`);
1726
1726
  return this.instances.push(r), r;
@@ -1752,7 +1752,7 @@ class Ut {
1752
1752
  return this.create(e.public, e.options);
1753
1753
  }
1754
1754
  }
1755
- class Y {
1755
+ class z {
1756
1756
  constructor(t, e) {
1757
1757
  this._type = "StateNode", this._options = e, this.uuid = S(e), this.name = t.name, this.computeValue = t.computeValue;
1758
1758
  }
@@ -1780,7 +1780,7 @@ class Y {
1780
1780
  };
1781
1781
  }
1782
1782
  static create(t, e) {
1783
- const r = new Y(t, e);
1783
+ const r = new z(t, e);
1784
1784
  if (this.instances.find((s) => s.uuid === r.uuid))
1785
1785
  throw new Error(`duplicate uuid in options ${r.uuid}, StateNode`);
1786
1786
  return this.instances.push(r), r;
@@ -1815,7 +1815,7 @@ class Y {
1815
1815
  return this.create(e.public, e.options);
1816
1816
  }
1817
1817
  }
1818
- class Gt {
1818
+ class Xt {
1819
1819
  constructor(t, e) {
1820
1820
  this._type = "StateTransfer", this._options = e, this.uuid = S(e), this.trigger = t.trigger, this.current = t.current, this.next = t.next, this.computeTarget = t.computeTarget;
1821
1821
  }
@@ -1853,7 +1853,7 @@ class Gt {
1853
1853
  };
1854
1854
  }
1855
1855
  static create(t, e) {
1856
- const r = new Gt(t, e);
1856
+ const r = new Xt(t, e);
1857
1857
  if (this.instances.find((s) => s.uuid === r.uuid))
1858
1858
  throw new Error(`duplicate uuid in options ${r.uuid}, StateTransfer`);
1859
1859
  return this.instances.push(r), r;
@@ -1892,7 +1892,7 @@ class Gt {
1892
1892
  return this.create(e.public, e.options);
1893
1893
  }
1894
1894
  }
1895
- class ct {
1895
+ class lt {
1896
1896
  constructor(t, e) {
1897
1897
  this._type = "StateMachine", this._options = e, this.uuid = S(e), this.states = t.states, this.transfers = t.transfers, this.defaultState = t.defaultState;
1898
1898
  }
@@ -1925,7 +1925,7 @@ class ct {
1925
1925
  };
1926
1926
  }
1927
1927
  static create(t, e) {
1928
- const r = new ct(t, e);
1928
+ const r = new lt(t, e);
1929
1929
  if (this.instances.find((s) => s.uuid === r.uuid))
1930
1930
  throw new Error(`duplicate uuid in options ${r.uuid}, StateMachine`);
1931
1931
  return this.instances.push(r), r;
@@ -1961,7 +1961,7 @@ class ct {
1961
1961
  return this.create(e.public, e.options);
1962
1962
  }
1963
1963
  }
1964
- class lt {
1964
+ class ut {
1965
1965
  constructor(t, e) {
1966
1966
  this._type = "WeightedSummation", this._options = e, this.uuid = S(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.callback = t.callback, this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps;
1967
1967
  }
@@ -2009,7 +2009,7 @@ class lt {
2009
2009
  };
2010
2010
  }
2011
2011
  static create(t, e) {
2012
- const r = new lt(t, e);
2012
+ const r = new ut(t, e);
2013
2013
  if (this.instances.find((s) => s.uuid === r.uuid))
2014
2014
  throw new Error(`duplicate uuid in options ${r.uuid}, WeightedSummation`);
2015
2015
  return this.instances.push(r), r;
@@ -2051,7 +2051,7 @@ class lt {
2051
2051
  return r.callback && typeof r.callback == "string" && r.callback.startsWith("func::") && (r.callback = new Function("return " + r.callback.substring(6))()), this.create(r, e.options);
2052
2052
  }
2053
2053
  }
2054
- class ut {
2054
+ class dt {
2055
2055
  constructor(t, e) {
2056
2056
  this._type = "Count", this._options = e, this.uuid = S(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.callback = t.callback, this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps;
2057
2057
  }
@@ -2094,7 +2094,7 @@ class ut {
2094
2094
  };
2095
2095
  }
2096
2096
  static create(t, e) {
2097
- const r = new ut(t, e);
2097
+ const r = new dt(t, e);
2098
2098
  if (this.instances.find((s) => s.uuid === r.uuid))
2099
2099
  throw new Error(`duplicate uuid in options ${r.uuid}, Count`);
2100
2100
  return this.instances.push(r), r;
@@ -2135,7 +2135,7 @@ class ut {
2135
2135
  return r.callback && typeof r.callback == "string" && r.callback.startsWith("func::") && (r.callback = new Function("return " + r.callback.substring(6))()), this.create(r, e.options);
2136
2136
  }
2137
2137
  }
2138
- class dt {
2138
+ class ht {
2139
2139
  constructor(t, e) {
2140
2140
  this._type = "Summation", this._options = e, this.uuid = S(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.attributeQuery = t.attributeQuery;
2141
2141
  }
@@ -2168,7 +2168,7 @@ class dt {
2168
2168
  };
2169
2169
  }
2170
2170
  static create(t, e) {
2171
- const r = new dt(t, e);
2171
+ const r = new ht(t, e);
2172
2172
  if (this.instances.find((s) => s.uuid === r.uuid))
2173
2173
  throw new Error(`duplicate uuid in options ${r.uuid}, Summation`);
2174
2174
  return this.instances.push(r), r;
@@ -2203,7 +2203,7 @@ class dt {
2203
2203
  return this.create(e.public, e.options);
2204
2204
  }
2205
2205
  }
2206
- class ht {
2206
+ class pt {
2207
2207
  constructor(t, e) {
2208
2208
  this._type = "Average", this._options = e, this.uuid = S(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.attributeQuery = t.attributeQuery;
2209
2209
  }
@@ -2236,7 +2236,7 @@ class ht {
2236
2236
  };
2237
2237
  }
2238
2238
  static create(t, e) {
2239
- const r = new ht(t, e);
2239
+ const r = new pt(t, e);
2240
2240
  if (this.instances.find((s) => s.uuid === r.uuid))
2241
2241
  throw new Error(`duplicate uuid in options ${r.uuid}, Average`);
2242
2242
  return this.instances.push(r), r;
@@ -2271,7 +2271,7 @@ class ht {
2271
2271
  return this.create(e.public, e.options);
2272
2272
  }
2273
2273
  }
2274
- class pt {
2274
+ class ft {
2275
2275
  constructor(t, e) {
2276
2276
  this._type = "Every", this._options = e, this.uuid = S(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.callback = t.callback, this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps, this.notEmpty = t.notEmpty;
2277
2277
  }
@@ -2319,7 +2319,7 @@ class pt {
2319
2319
  };
2320
2320
  }
2321
2321
  static create(t, e) {
2322
- const r = new pt(t, e);
2322
+ const r = new ft(t, e);
2323
2323
  if (this.instances.find((s) => s.uuid === r.uuid))
2324
2324
  throw new Error(`duplicate uuid in options ${r.uuid}, Every`);
2325
2325
  return this.instances.push(r), r;
@@ -2356,7 +2356,7 @@ class pt {
2356
2356
  return r.callback && typeof r.callback == "string" && r.callback.startsWith("func::") && (r.callback = new Function("return " + r.callback.substring(6))()), this.create(r, e.options);
2357
2357
  }
2358
2358
  }
2359
- class ft {
2359
+ class mt {
2360
2360
  constructor(t, e) {
2361
2361
  this._type = "Any", this._options = e, this.uuid = S(e), this.record = t.record, this.property = t.property, this.direction = t.direction, this.callback = t.callback, this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps;
2362
2362
  }
@@ -2404,7 +2404,7 @@ class ft {
2404
2404
  };
2405
2405
  }
2406
2406
  static create(t, e) {
2407
- const r = new ft(t, e);
2407
+ const r = new mt(t, e);
2408
2408
  if (this.instances.find((s) => s.uuid === r.uuid))
2409
2409
  throw new Error(`duplicate uuid in options ${r.uuid}, Any`);
2410
2410
  return this.instances.push(r), r;
@@ -2446,7 +2446,7 @@ class ft {
2446
2446
  return r.callback && typeof r.callback == "string" && r.callback.startsWith("func::") && (r.callback = new Function("return " + r.callback.substring(6))()), this.create(r, e.options);
2447
2447
  }
2448
2448
  }
2449
- class Ct {
2449
+ class Mt {
2450
2450
  constructor(t, e) {
2451
2451
  this._type = "Transform", this._options = e, this.uuid = S(e), this.record = t.record, this.eventDeps = t.eventDeps, this.attributeQuery = t.attributeQuery, this.callback = t.callback;
2452
2452
  }
@@ -2479,7 +2479,7 @@ class Ct {
2479
2479
  };
2480
2480
  }
2481
2481
  static create(t, e) {
2482
- const r = new Ct(t, e);
2482
+ const r = new Mt(t, e);
2483
2483
  if (this.instances.find((s) => s.uuid === r.uuid))
2484
2484
  throw new Error(`duplicate uuid in options ${r.uuid}, Transform`);
2485
2485
  return this.instances.push(r), r;
@@ -2516,7 +2516,7 @@ class Ct {
2516
2516
  return typeof r.callback == "string" && r.callback.startsWith("func::") && (r.callback = new Function("return " + r.callback.substring(6))()), this.create(r, e.options);
2517
2517
  }
2518
2518
  }
2519
- class mt {
2519
+ class yt {
2520
2520
  constructor(t, e) {
2521
2521
  this._type = "RealTimeValue", this._options = e, this.uuid = S(e), this.attributeQuery = t.attributeQuery, this.dataDeps = t.dataDeps, this.nextRecomputeTime = t.nextRecomputeTime, this.callback = t.callback;
2522
2522
  }
@@ -2554,7 +2554,7 @@ class mt {
2554
2554
  };
2555
2555
  }
2556
2556
  static create(t, e) {
2557
- const r = new mt(t, e);
2557
+ const r = new yt(t, e);
2558
2558
  if (this.instances.find((s) => s.uuid === r.uuid))
2559
2559
  throw new Error(`duplicate uuid in options ${r.uuid}, RealTimeValue`);
2560
2560
  return this.instances.push(r), r;
@@ -2589,7 +2589,7 @@ class mt {
2589
2589
  return typeof r.callback == "string" && r.callback.startsWith("func::") && (r.callback = new Function("return " + r.callback.substring(6))()), typeof r.nextRecomputeTime == "string" && r.nextRecomputeTime.startsWith("func::") && (r.nextRecomputeTime = new Function("return " + r.nextRecomputeTime.substring(6))()), this.create(r, e.options);
2590
2590
  }
2591
2591
  }
2592
- class Kt {
2592
+ class Yt {
2593
2593
  constructor(t, e) {
2594
2594
  this._type = "PayloadItem", this._options = e, this.uuid = S(e), this.name = t.name, this.base = t.base, this.type = t.type, this.isRef = t.isRef ?? !1, this.required = t.required ?? !1, this.isCollection = t.isCollection ?? !1, this.itemRef = t.itemRef;
2595
2595
  }
@@ -2640,7 +2640,7 @@ class Kt {
2640
2640
  };
2641
2641
  }
2642
2642
  static create(t, e) {
2643
- const r = new Kt(t, e);
2643
+ const r = new Yt(t, e);
2644
2644
  if (this.instances.find((s) => s.uuid === r.uuid))
2645
2645
  throw new Error(`duplicate uuid in options ${r.uuid}, PayloadItem`);
2646
2646
  return this.instances.push(r), r;
@@ -2679,7 +2679,7 @@ class Kt {
2679
2679
  return this.create(e.public, e.options);
2680
2680
  }
2681
2681
  }
2682
- class Xt {
2682
+ class zt {
2683
2683
  constructor(t, e) {
2684
2684
  this._type = "Payload", this._options = e, this.uuid = S(e), this.items = t.items || [];
2685
2685
  }
@@ -2703,7 +2703,7 @@ class Xt {
2703
2703
  };
2704
2704
  }
2705
2705
  static create(t, e) {
2706
- const r = new Xt(t, e);
2706
+ const r = new zt(t, e);
2707
2707
  if (this.instances.find((s) => s.uuid === r.uuid))
2708
2708
  throw new Error(`duplicate uuid in options ${r.uuid}, Payload`);
2709
2709
  return this.instances.push(r), r;
@@ -2735,7 +2735,7 @@ class Xt {
2735
2735
  return this.create(e.public, e.options);
2736
2736
  }
2737
2737
  }
2738
- class Yt {
2738
+ class Zt {
2739
2739
  constructor(t, e) {
2740
2740
  this._type = "SideEffect", this._options = e, this.uuid = S(e), this.name = t.name, this.handle = t.handle;
2741
2741
  }
@@ -2763,7 +2763,7 @@ class Yt {
2763
2763
  };
2764
2764
  }
2765
2765
  static create(t, e) {
2766
- const r = new Yt(t, e);
2766
+ const r = new Zt(t, e);
2767
2767
  if (this.instances.find((s) => s.uuid === r.uuid))
2768
2768
  throw new Error(`duplicate uuid in options ${r.uuid}, SideEffect`);
2769
2769
  return this.instances.push(r), r;
@@ -2797,24 +2797,24 @@ class Yt {
2797
2797
  return r.handle && typeof r.handle == "string" && r.handle.startsWith("func::") && (r.handle = new Function("return " + r.handle.substring(6))()), this.create(r, e.options);
2798
2798
  }
2799
2799
  }
2800
- function Ft(u) {
2800
+ function Qt(u) {
2801
2801
  if (!u) return;
2802
2802
  if (u.raw.type === "atom")
2803
- return ot.create({
2803
+ return nt.create({
2804
2804
  type: "atom",
2805
2805
  data: u.raw.data
2806
2806
  });
2807
2807
  const t = u.raw;
2808
- return nt.create({
2808
+ return ct.create({
2809
2809
  type: "expression",
2810
2810
  operator: t.operator,
2811
- left: Ft(u.left),
2812
- right: Ft(u.right)
2811
+ left: Qt(u.left),
2812
+ right: Qt(u.right)
2813
2813
  });
2814
2814
  }
2815
- class xt {
2815
+ class $t {
2816
2816
  constructor(t, e) {
2817
- this._type = "Conditions", this._options = e, this.uuid = S(e), t.content && t.content instanceof R ? this.content = Ft(t.content) : this.content = t.content;
2817
+ this._type = "Conditions", this._options = e, this.uuid = S(e), t.content && t.content instanceof R ? this.content = Qt(t.content) : this.content = t.content;
2818
2818
  }
2819
2819
  static {
2820
2820
  this.isKlass = !0;
@@ -2835,7 +2835,7 @@ class xt {
2835
2835
  };
2836
2836
  }
2837
2837
  static create(t, e) {
2838
- const r = new xt(t, e);
2838
+ const r = new $t(t, e);
2839
2839
  if (this.instances.find((s) => s.uuid === r.uuid))
2840
2840
  throw new Error(`duplicate uuid in options ${r.uuid}, Conditions`);
2841
2841
  return this.instances.push(r), r;
@@ -2866,7 +2866,7 @@ class xt {
2866
2866
  return this.create(e.public, e.options);
2867
2867
  }
2868
2868
  }
2869
- class zt {
2869
+ class te {
2870
2870
  constructor(t, e) {
2871
2871
  this._type = "DataAttributives", this._options = e, this.uuid = S(e), this.content = t.content;
2872
2872
  }
@@ -2889,7 +2889,7 @@ class zt {
2889
2889
  };
2890
2890
  }
2891
2891
  static create(t, e) {
2892
- const r = new zt(t, e);
2892
+ const r = new te(t, e);
2893
2893
  if (this.instances.find((s) => s.uuid === r.uuid))
2894
2894
  throw new Error(`duplicate uuid in options ${r.uuid}, DataAttributives`);
2895
2895
  return this.instances.push(r), r;
@@ -2920,42 +2920,42 @@ class zt {
2920
2920
  return this.create(e.public, e.options);
2921
2921
  }
2922
2922
  }
2923
- const Je = [
2923
+ const He = [
2924
2924
  C,
2925
2925
  P,
2926
2926
  T,
2927
- Wt,
2928
- Jt,
2929
- X,
2930
- Ht,
2931
2927
  jt,
2932
- It,
2933
- it,
2934
2928
  Ut,
2935
2929
  Y,
2930
+ Ht,
2936
2931
  Gt,
2937
- ct,
2932
+ xt,
2933
+ st,
2934
+ Kt,
2935
+ z,
2936
+ Xt,
2938
2937
  lt,
2939
2938
  ut,
2940
2939
  dt,
2941
2940
  ht,
2942
2941
  pt,
2943
2942
  ft,
2944
- Ct,
2945
2943
  mt,
2946
- Kt,
2947
- Xt,
2944
+ Mt,
2945
+ yt,
2948
2946
  Yt,
2949
- Bt,
2950
- ot,
2947
+ zt,
2948
+ Zt,
2949
+ Jt,
2951
2950
  nt,
2952
- xt,
2953
- zt
2951
+ ct,
2952
+ $t,
2953
+ te
2954
2954
  ];
2955
- Je.forEach((u) => {
2956
- u && u.displayName && Fe(u.displayName, u);
2955
+ He.forEach((u) => {
2956
+ u && u.displayName && Le(u.displayName, u);
2957
2957
  });
2958
- class Zt {
2958
+ class ee {
2959
2959
  constructor(t, e) {
2960
2960
  this._type = "Custom", this._options = e, this.uuid = S(e), this.name = t.name, this.dataDeps = t.dataDeps, this.compute = t.compute, this.incrementalCompute = t.incrementalCompute, this.incrementalPatchCompute = t.incrementalPatchCompute, this.createState = t.createState, this.getDefaultValue = t.getDefaultValue, this.asyncReturn = t.asyncReturn, this.useLastValue = t.useLastValue;
2961
2961
  }
@@ -3018,7 +3018,7 @@ class Zt {
3018
3018
  };
3019
3019
  }
3020
3020
  static create(t, e) {
3021
- const r = new Zt(t, e);
3021
+ const r = new ee(t, e);
3022
3022
  if (this.instances.find((s) => s.uuid === r.uuid))
3023
3023
  throw new Error(`duplicate uuid in options ${r.uuid}, Custom`);
3024
3024
  return this.instances.push(r), r;
@@ -3062,7 +3062,7 @@ class Zt {
3062
3062
  }), this.create(r, e.options);
3063
3063
  }
3064
3064
  }
3065
- class Ne {
3065
+ class Se {
3066
3066
  constructor(t = [], e = []) {
3067
3067
  this.clonedEntities = /* @__PURE__ */ new Map(), this.clonedRelations = /* @__PURE__ */ new Map(), this.reverseEntityMap = /* @__PURE__ */ new Map(), this.reverseRelationMap = /* @__PURE__ */ new Map(), this.originalEntities = [...t], this.originalRelations = [...e], (t.length > 0 || e.length > 0) && this.initializeClones();
3068
3068
  }
@@ -3273,8 +3273,8 @@ class Ne {
3273
3273
  return null;
3274
3274
  }
3275
3275
  }
3276
- function Mi({ name: u, isRef: t = !1 }, e) {
3277
- return X.create({
3276
+ function Li({ name: u, isRef: t = !1 }, e) {
3277
+ return Y.create({
3278
3278
  name: u,
3279
3279
  content: u ? new Function("user", `return user.roles.includes('${u}')`) : function() {
3280
3280
  return !0;
@@ -3286,7 +3286,7 @@ function g(u, t) {
3286
3286
  if (!u)
3287
3287
  throw new Error(t);
3288
3288
  }
3289
- function $t(u, t, e) {
3289
+ function Dt(u, t, e) {
3290
3290
  const r = [...t];
3291
3291
  let i = u, s;
3292
3292
  const a = r.pop();
@@ -3646,7 +3646,7 @@ class m {
3646
3646
  );
3647
3647
  }
3648
3648
  }
3649
- class He {
3649
+ class Ge {
3650
3650
  constructor(t, e, r, i) {
3651
3651
  this.recordName = t, this.map = e, this.data = r, this.fromRelation = i;
3652
3652
  }
@@ -3682,7 +3682,7 @@ class M {
3682
3682
  e,
3683
3683
  N,
3684
3684
  new x(h, e, r.attributeQuery || [], s, a),
3685
- new He(h, e, r.modifier),
3685
+ new Ge(h, e, r.modifier),
3686
3686
  i,
3687
3687
  s,
3688
3688
  a,
@@ -3776,7 +3776,7 @@ class _ {
3776
3776
  }), this.parentLinkQueryTree && (t[f] = this.parentLinkQueryTree.getData()), t;
3777
3777
  }
3778
3778
  }
3779
- const f = "&", je = "*";
3779
+ const f = "&", Ke = "*";
3780
3780
  class x {
3781
3781
  constructor(t, e, r = [], i, s, a) {
3782
3782
  this.recordName = t, this.map = e, this.data = r, this.parentRecord = i, this.attributeName = s, this.shouldQueryParentLinkData = a, this.relatedRecords = [], this.xToManyRecords = [], this.xToOneRecords = [], this.valueAttributes = [], this.id = Math.random();
@@ -3789,7 +3789,7 @@ class x {
3789
3789
  this.parentLinkRecordQuery = M.create(y.linkName, this.map, d, void 0);
3790
3790
  return;
3791
3791
  }
3792
- if (l === je) {
3792
+ if (l === Ke) {
3793
3793
  o = new Set(this.map.getRecordInfo(this.recordName).valueAttributes.map((y) => y.attributeName));
3794
3794
  return;
3795
3795
  }
@@ -3798,10 +3798,10 @@ class x {
3798
3798
  let y = l, N = d;
3799
3799
  if (p.isLinkFiltered()) {
3800
3800
  y = p.getBaseAttributeInfo().attributeName;
3801
- const k = d.matchExpression, F = p.getLinkInfo().getBaseLinkInfo(), se = new m(F.name, this.map, p.getMatchExpression()).rebase(p.isRecordSource() ? "target" : "source"), xe = k ? se.and(k.data) : se;
3801
+ const k = d.matchExpression, F = p.getLinkInfo().getBaseLinkInfo(), oe = new m(F.name, this.map, p.getMatchExpression()).rebase(p.isRecordSource() ? "target" : "source"), $e = k ? oe.and(k.data) : oe;
3802
3802
  N = {
3803
3803
  ...d,
3804
- matchExpression: xe.data
3804
+ matchExpression: $e.data
3805
3805
  };
3806
3806
  }
3807
3807
  const b = M.create(p.recordName, this.map, N, void 0, this.recordName, y, h, !1, l);
@@ -3919,7 +3919,7 @@ class x {
3919
3919
  return this.parentLinkRecordQuery ? new x(this.recordName, this.map, this.data, this.parentRecord, this.attributeName, !0) : this;
3920
3920
  }
3921
3921
  }
3922
- function Ue(u) {
3922
+ function Xe(u) {
3923
3923
  const t = [];
3924
3924
  return u.forEach((e) => t.push(...Array.isArray(e) ? e : [e])), t;
3925
3925
  }
@@ -3929,7 +3929,7 @@ class L {
3929
3929
  const s = this.map.getRecordInfo(e);
3930
3930
  this.recordName = s.isFilteredEntity || s.isFilteredRelation ? s.resolvedBaseRecordName : e;
3931
3931
  const [a, o, n] = this.map.groupAttributes(this.recordName, r ? Object.keys(r) : []);
3932
- this.relatedEntitiesData = Ue(o.map(
3932
+ this.relatedEntitiesData = Xe(o.map(
3933
3933
  (l) => Array.isArray(r[l.attributeName]) ? r[l.attributeName].map((d) => new L(this.map, l.recordName, d, l)) : new L(this.map, l.recordName, r[l.attributeName], l)
3934
3934
  )), this.valueAttributes = a, this.entityIdAttributes = n;
3935
3935
  const c = this.map.getRecordInfo(this.recordName);
@@ -4006,7 +4006,7 @@ class L {
4006
4006
  }), r;
4007
4007
  }
4008
4008
  }
4009
- class Ge {
4009
+ class Ye {
4010
4010
  constructor(t, e) {
4011
4011
  this.map = t, this.queryAgent = e, this.dependencies = /* @__PURE__ */ new Map();
4012
4012
  }
@@ -4232,7 +4232,7 @@ class Ge {
4232
4232
  }
4233
4233
  }
4234
4234
  }
4235
- class Ke {
4235
+ class ze {
4236
4236
  constructor() {
4237
4237
  this.aliasToPath = /* @__PURE__ */ new Map(), this.pathStrToAlias = /* @__PURE__ */ new Map(), this.aliasPlaceholder = 0;
4238
4238
  }
@@ -4246,24 +4246,24 @@ class Ke {
4246
4246
  return this.aliasToPath.get(t);
4247
4247
  }
4248
4248
  }
4249
- const Te = ":root";
4250
- class Tt {
4249
+ const ve = ":root";
4250
+ class vt {
4251
4251
  constructor(t, e, r = []) {
4252
4252
  this.label = t, this.parent = e, this.stack = r;
4253
4253
  }
4254
4254
  concat(t) {
4255
- return new Tt(this.label, this.parent, [...this.stack, t]);
4255
+ return new vt(this.label, this.parent, [...this.stack, t]);
4256
4256
  }
4257
4257
  getStack(t) {
4258
4258
  return [...this.stack];
4259
4259
  }
4260
4260
  spawn(t) {
4261
- return new Tt(t, this);
4261
+ return new vt(t, this);
4262
4262
  }
4263
4263
  }
4264
- class Xe {
4264
+ class Ze {
4265
4265
  constructor(t) {
4266
- this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(Te, t), this.recursiveSaveLabelledRecordQuery(t);
4266
+ this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(ve, t), this.recursiveSaveLabelledRecordQuery(t);
4267
4267
  }
4268
4268
  recursiveSaveLabelledRecordQuery(t) {
4269
4269
  t.attributeQuery?.relatedRecords.forEach((e) => {
@@ -4277,9 +4277,9 @@ class Xe {
4277
4277
  return this.recordQueryByName.get(t);
4278
4278
  }
4279
4279
  }
4280
- class Ye {
4280
+ class tr {
4281
4281
  constructor(t, e) {
4282
- this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (r) => "?"), this.filteredEntityManager = new Ge(t, this), this.initializeFilteredEntityDependencies();
4282
+ this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (r) => "?"), this.filteredEntityManager = new Ye(t, this), this.initializeFilteredEntityDependencies();
4283
4283
  }
4284
4284
  /**
4285
4285
  * 初始化所有 filtered entity 的依赖关系
@@ -4331,15 +4331,15 @@ ${b}
4331
4331
  const s = {};
4332
4332
  return Object.entries(i).forEach(([a, o]) => {
4333
4333
  const n = r.getPath(a).slice(1, 1 / 0);
4334
- n.length === 1 && e.includes(n[0]) && typeof o == "string" && (o = JSON.parse(o)), o !== null && $t(s, n, o);
4334
+ n.length === 1 && e.includes(n[0]) && typeof o == "string" && (o = JSON.parse(o)), o !== null && Dt(s, n, o);
4335
4335
  }), s;
4336
4336
  });
4337
4337
  }
4338
4338
  // 查 entity 和 查 relation 都是一样的。具体在 entityQuery 里面区别。
4339
4339
  // TODO 为了性能,也可以把信息丢到客户端,然客户端去结构化???
4340
4340
  // CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
4341
- async findRecords(t, e = "", r, i = new Tt(Te)) {
4342
- if (r || (r = new Xe(t)), t.goto) {
4341
+ async findRecords(t, e = "", r, i = new vt(ve)) {
4342
+ if (r || (r = new Ze(t)), t.goto) {
4343
4343
  if (t.exit && await t.exit(i))
4344
4344
  return [];
4345
4345
  const l = r.get(t.goto);
@@ -4378,7 +4378,7 @@ ${b}
4378
4378
  value: ["=", b]
4379
4379
  })
4380
4380
  }), F = t.label ? c.concat(N) : c;
4381
- $t(
4381
+ Dt(
4382
4382
  N,
4383
4383
  [l.alias || l.attributeName, f, h.attributeName],
4384
4384
  await this.findRecords(
@@ -4465,8 +4465,8 @@ ${b}
4465
4465
  if (N)
4466
4466
  for (let b of N.attributeQuery.xToManyRecords)
4467
4467
  for (let k of p) {
4468
- const F = k[f].id, ie = d.label ? y.concat(k) : y;
4469
- $t(
4468
+ const F = k[f].id, ae = d.label ? y.concat(k) : y;
4469
+ Dt(
4470
4470
  k,
4471
4471
  [f, b.attributeName],
4472
4472
  await this.findXToManyRelatedRecords(
@@ -4475,7 +4475,7 @@ ${b}
4475
4475
  F,
4476
4476
  b,
4477
4477
  s,
4478
- ie
4478
+ ae
4479
4479
  )
4480
4480
  );
4481
4481
  }
@@ -4548,7 +4548,7 @@ ${b}
4548
4548
  return t ? `${t}___` : "";
4549
4549
  }
4550
4550
  buildSelectClause(t, e = "") {
4551
- const r = new Ke();
4551
+ const r = new ze();
4552
4552
  return t.length ? [t.map(({ tableAliasAndField: s, attribute: a, nameContext: o }) => {
4553
4553
  const n = [
4554
4554
  `${this.withPrefix(e)}${o[0]}`,
@@ -5120,9 +5120,9 @@ WHERE "${s.idField}" = ${l()}
5120
5120
  return p ? [N, ...p] : void 0;
5121
5121
  }
5122
5122
  }
5123
- class ze {
5123
+ class er {
5124
5124
  constructor(t, e) {
5125
- this.map = t, this.database = e, this.agent = new Ye(t, e);
5125
+ this.map = t, this.database = e, this.agent = new tr(t, e);
5126
5126
  }
5127
5127
  async findOne(t, e, r = {}, i) {
5128
5128
  const s = {
@@ -5191,7 +5191,7 @@ class ze {
5191
5191
  return this.map.getInfo(t, e).recordName;
5192
5192
  }
5193
5193
  }
5194
- class st {
5194
+ class at {
5195
5195
  constructor(t, e) {
5196
5196
  this.name = t, this.map = e, this.data = this.map.data.records[t];
5197
5197
  }
@@ -5262,7 +5262,7 @@ class st {
5262
5262
  return this.data.matchExpression;
5263
5263
  }
5264
5264
  get filteredBy() {
5265
- return this.data.filteredBy?.map((t) => new st(t, this.map));
5265
+ return this.data.filteredBy?.map((t) => new at(t, this.map));
5266
5266
  }
5267
5267
  get isFilteredEntity() {
5268
5268
  return this.data?.isFilteredEntity;
@@ -5280,7 +5280,7 @@ class st {
5280
5280
  return this.data?.resolvedMatchExpression;
5281
5281
  }
5282
5282
  }
5283
- class St {
5283
+ class kt {
5284
5284
  constructor(t, e, r, i = !0) {
5285
5285
  this.name = t, this.data = e, this.map = r, this.isFromSource = i;
5286
5286
  }
@@ -5309,10 +5309,10 @@ class St {
5309
5309
  return this.data.sourceRecord;
5310
5310
  }
5311
5311
  get sourceRecordInfo() {
5312
- return new st(this.data.sourceRecord, this.map);
5312
+ return new at(this.data.sourceRecord, this.map);
5313
5313
  }
5314
5314
  get targetRecordInfo() {
5315
- return new st(this.data.targetRecord, this.map);
5315
+ return new at(this.data.targetRecord, this.map);
5316
5316
  }
5317
5317
  get targetRecord() {
5318
5318
  return this.data.targetRecord;
@@ -5368,7 +5368,7 @@ class St {
5368
5368
  getBaseLinkInfo() {
5369
5369
  g(this.isFilteredRelation(), "only filtered relation can get base link info");
5370
5370
  const t = this.data.baseLinkName;
5371
- return new St(t, this.map.data.links[t], this.map);
5371
+ return new kt(t, this.map.data.links[t], this.map);
5372
5372
  }
5373
5373
  getMatchExpression() {
5374
5374
  if (this.isFilteredRelation())
@@ -5382,7 +5382,7 @@ class St {
5382
5382
  return g(this.isFilteredRelation(), "only filtered relation can get resolved record name"), this.data.resolvedBaseRecordName;
5383
5383
  }
5384
5384
  }
5385
- class Ze {
5385
+ class rr {
5386
5386
  constructor(t) {
5387
5387
  this.data = t;
5388
5388
  }
@@ -5396,7 +5396,7 @@ class Ze {
5396
5396
  return this.data.records[t].attributes[this.getAttributeAndSymmetricDirection(e)[0]];
5397
5397
  }
5398
5398
  getRecordInfo(t) {
5399
- return new st(t, this);
5399
+ return new at(t, this);
5400
5400
  }
5401
5401
  getInfo(t, e) {
5402
5402
  const r = this.getInfoByPath([t, ...e.split(".")]);
@@ -5407,10 +5407,10 @@ class Ze {
5407
5407
  }
5408
5408
  getLinkInfo(t, e) {
5409
5409
  const r = this.getAttributeAndSymmetricDirection(e)[0], { linkName: i, isSource: s } = this.data.records[t].attributes[r];
5410
- return g(!!i, `cannot find relation ${t} ${r}`), new St(i, this.data.links[i], this, !!s);
5410
+ return g(!!i, `cannot find relation ${t} ${r}`), new kt(i, this.data.links[i], this, !!s);
5411
5411
  }
5412
5412
  getLinkInfoByName(t) {
5413
- return g(!!this.data.links[t], `cannot find link ${t}`), new St(t, this.data.links[t], this);
5413
+ return g(!!this.data.links[t], `cannot find link ${t}`), new kt(t, this.data.links[t], this);
5414
5414
  }
5415
5415
  getInfoByPath(t) {
5416
5416
  const [e, ...r] = t;
@@ -5578,7 +5578,7 @@ class Ze {
5578
5578
  return i.join(".");
5579
5579
  }
5580
5580
  }
5581
- function tr(u) {
5581
+ function ir(u) {
5582
5582
  const t = /* @__PURE__ */ new Map();
5583
5583
  for (const e of u)
5584
5584
  if (e.inputEntities)
@@ -5589,7 +5589,7 @@ function tr(u) {
5589
5589
  }
5590
5590
  return t;
5591
5591
  }
5592
- function er(u) {
5592
+ function sr(u) {
5593
5593
  const t = /* @__PURE__ */ new Map();
5594
5594
  for (const e of u) {
5595
5595
  const r = e.name || `${e.source.name}_${e.sourceProperty}_${e.targetProperty}_${e.target.name}`;
@@ -5603,46 +5603,46 @@ function er(u) {
5603
5603
  }
5604
5604
  return t;
5605
5605
  }
5606
- function rr(u, t) {
5607
- const e = new Ne(u, t), r = tr(u), i = er(t);
5608
- return oe(
5606
+ function ar(u, t) {
5607
+ const e = new Se(u, t), r = ir(u), i = sr(t);
5608
+ return ce(
5609
5609
  u,
5610
5610
  e,
5611
5611
  r,
5612
5612
  "entity"
5613
- ), oe(
5613
+ ), ce(
5614
5614
  t,
5615
5615
  e,
5616
5616
  i,
5617
5617
  "relation"
5618
5618
  ), e.getAll();
5619
5619
  }
5620
- function oe(u, t, e, r) {
5620
+ function ce(u, t, e, r) {
5621
5621
  const i = u.filter((s) => {
5622
- const a = gt(s);
5622
+ const a = bt(s);
5623
5623
  return a && a.length > 0;
5624
5624
  });
5625
5625
  if (i.length !== 0)
5626
5626
  for (const s of i)
5627
- ir(
5627
+ or(
5628
5628
  s,
5629
5629
  t,
5630
5630
  r,
5631
5631
  e
5632
5632
  );
5633
5633
  }
5634
- function ir(u, t, e, r) {
5635
- const i = e === "entity", a = `__${z(u)}_input_${e}`, o = i ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = cr(
5634
+ function or(u, t, e, r) {
5635
+ const i = e === "entity", a = `__${Z(u)}_input_${e}`, o = i ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = dr(
5636
5636
  o,
5637
5637
  a,
5638
5638
  r,
5639
5639
  t
5640
5640
  );
5641
5641
  t.replace(n, u), c !== n && t.add(c);
5642
- const l = gt(u);
5642
+ const l = bt(u);
5643
5643
  if (l)
5644
5644
  for (const d of l)
5645
- sr(
5645
+ nr(
5646
5646
  d,
5647
5647
  c,
5648
5648
  a,
@@ -5650,22 +5650,22 @@ function ir(u, t, e, r) {
5650
5650
  i
5651
5651
  );
5652
5652
  }
5653
- function sr(u, t, e, r, i) {
5654
- const [s, a] = lr(
5653
+ function nr(u, t, e, r, i) {
5654
+ const [s, a] = hr(
5655
5655
  u,
5656
5656
  t,
5657
5657
  e
5658
5658
  );
5659
5659
  if (!i && s === u)
5660
5660
  return;
5661
- const o = z(a), n = i ? r.getEntityByName(o) : r.getRelationByName(o);
5661
+ const o = Z(a), n = i ? r.getEntityByName(o) : r.getRelationByName(o);
5662
5662
  n && r.replace(s, n);
5663
5663
  }
5664
- function ar(u, t) {
5665
- const e = /* @__PURE__ */ new Map(), r = gt(u);
5664
+ function cr(u, t) {
5665
+ const e = /* @__PURE__ */ new Map(), r = bt(u);
5666
5666
  if (r && r.length > 0)
5667
5667
  for (const i of r) {
5668
- const s = z(i), a = [...t.get(s) || []], o = e.get(s) || [];
5668
+ const s = Z(i), a = [...t.get(s) || []], o = e.get(s) || [];
5669
5669
  for (o.push(s), e.set(s, o); a.length; ) {
5670
5670
  const n = a.shift(), c = e.get(n) || [];
5671
5671
  c.push(...o), e.set(n, c);
@@ -5675,27 +5675,27 @@ function ar(u, t) {
5675
5675
  }
5676
5676
  return e;
5677
5677
  }
5678
- function or(u, t, e) {
5679
- const r = ar(t, e);
5678
+ function lr(u, t, e) {
5679
+ const r = cr(t, e);
5680
5680
  return T.create({
5681
5681
  name: u,
5682
5682
  type: "json",
5683
5683
  defaultValue: (i, s) => {
5684
- const a = gt(t), n = (r.get(s) || []).filter(
5685
- (c) => a.some((l) => z(l) === c)
5684
+ const a = bt(t), n = (r.get(s) || []).filter(
5685
+ (c) => a.some((l) => Z(l) === c)
5686
5686
  );
5687
5687
  return n.length > 0 ? n : [s];
5688
5688
  }
5689
5689
  });
5690
5690
  }
5691
- function nr(u, t, e) {
5692
- const r = gt(u), i = [], s = /* @__PURE__ */ new Map(), a = {};
5691
+ function ur(u, t, e) {
5692
+ const r = bt(u), i = [], s = /* @__PURE__ */ new Map(), a = {};
5693
5693
  for (const o of r) {
5694
5694
  let n = o;
5695
- if (yt(n))
5695
+ if (gt(n))
5696
5696
  for (; n.baseEntity && n.properties.length === 0; )
5697
5697
  n = n.baseEntity;
5698
- else if (dr(n))
5698
+ else if (fr(n))
5699
5699
  for (; n.baseRelation && n.properties.length === 0; )
5700
5700
  n = n.baseRelation;
5701
5701
  const c = Object.fromEntries(n.properties.map((h) => [h.name, h]));
@@ -5725,13 +5725,13 @@ function nr(u, t, e) {
5725
5725
  }
5726
5726
  return i;
5727
5727
  }
5728
- function cr(u, t, e, r) {
5729
- const i = or(
5728
+ function dr(u, t, e, r) {
5729
+ const i = lr(
5730
5730
  t,
5731
5731
  u,
5732
5732
  e
5733
5733
  ), s = [
5734
- ...nr(
5734
+ ...ur(
5735
5735
  u,
5736
5736
  e,
5737
5737
  r
@@ -5739,7 +5739,7 @@ function cr(u, t, e, r) {
5739
5739
  i,
5740
5740
  ...u.properties
5741
5741
  ];
5742
- if (yt(u)) {
5742
+ if (gt(u)) {
5743
5743
  const a = r.getEntityByName(u.name), o = C.create({
5744
5744
  name: a.name
5745
5745
  });
@@ -5777,7 +5777,7 @@ function cr(u, t, e, r) {
5777
5777
  properties: s
5778
5778
  }), o.baseRelation = n, o.sourceProperty = a.sourceProperty, o.targetProperty = a.targetProperty, o.matchExpression = m.fromArray(
5779
5779
  a.inputRelations.map((l) => {
5780
- const d = z(l);
5780
+ const d = Z(l);
5781
5781
  return {
5782
5782
  key: t,
5783
5783
  value: ["contains", d]
@@ -5789,8 +5789,8 @@ function cr(u, t, e, r) {
5789
5789
  return [o, n || o];
5790
5790
  }
5791
5791
  }
5792
- function lr(u, t, e) {
5793
- if (yt(u)) {
5792
+ function hr(u, t, e) {
5793
+ if (gt(u)) {
5794
5794
  const r = u, i = t;
5795
5795
  let s = r;
5796
5796
  if (r.baseEntity)
@@ -5802,8 +5802,8 @@ function lr(u, t, e) {
5802
5802
  value: ["contains", r.name]
5803
5803
  }), [a, s];
5804
5804
  } else {
5805
- const r = u, i = t, s = z(r);
5806
- return r.baseRelation ? [r, ur(r)] : [P.create({
5805
+ const r = u, i = t, s = Z(r);
5806
+ return r.baseRelation ? [r, pr(r)] : [P.create({
5807
5807
  name: s,
5808
5808
  baseRelation: i,
5809
5809
  sourceProperty: r.sourceProperty,
@@ -5815,25 +5815,25 @@ function lr(u, t, e) {
5815
5815
  }), r];
5816
5816
  }
5817
5817
  }
5818
- function ur(u) {
5818
+ function pr(u) {
5819
5819
  let t = u;
5820
5820
  for (; t.baseRelation; )
5821
5821
  t = t.baseRelation;
5822
5822
  return t;
5823
5823
  }
5824
- function yt(u) {
5824
+ function gt(u) {
5825
5825
  return "inputEntities" in u || !("sourceProperty" in u);
5826
5826
  }
5827
- function dr(u) {
5827
+ function fr(u) {
5828
5828
  return "sourceProperty" in u;
5829
5829
  }
5830
- function gt(u) {
5831
- return yt(u) ? u.inputEntities || [] : u.inputRelations || [];
5830
+ function bt(u) {
5831
+ return gt(u) ? u.inputEntities || [] : u.inputRelations || [];
5832
5832
  }
5833
- function z(u) {
5834
- return yt(u), u.name;
5833
+ function Z(u) {
5834
+ return gt(u), u.name;
5835
5835
  }
5836
- class hr {
5836
+ class mr {
5837
5837
  constructor(t, e, r, i = []) {
5838
5838
  this.entities = t, this.relations = e, this.database = r, this.mergeLinks = i, this.fieldNameMap = /* @__PURE__ */ new Map(), this.usedFieldNames = /* @__PURE__ */ new Set(), this.fieldCounter = 1, this.recordToTableMap = /* @__PURE__ */ new Map(), this.tableToRecordsMap = /* @__PURE__ */ new Map(), this.mergeLog = [], this.tables = {}, this.map = { links: {}, records: {} }, this.buildMap(), this.buildTables();
5839
5839
  }
@@ -5928,8 +5928,8 @@ class hr {
5928
5928
  }
5929
5929
  ];
5930
5930
  }));
5931
- e && g(!r.source && !r.target, "source and target is reserved name for relation attributes"), r[ne] = {
5932
- name: ne,
5931
+ e && g(!r.source && !r.target, "source and target is reserved name for relation attributes"), r[le] = {
5932
+ name: le,
5933
5933
  type: "id",
5934
5934
  fieldType: this.database.mapToDBFieldType("pk")
5935
5935
  };
@@ -6112,7 +6112,7 @@ class hr {
6112
6112
  * 统一处理 merged entities 和 merged relations
6113
6113
  */
6114
6114
  processMergedItems() {
6115
- const t = rr(
6115
+ const t = ar(
6116
6116
  this.entities,
6117
6117
  this.relations
6118
6118
  );
@@ -6181,8 +6181,8 @@ class hr {
6181
6181
  buildTables() {
6182
6182
  Object.entries(this.map.records).forEach(([t, e]) => {
6183
6183
  this.tables[e.table] || (this.tables[e.table] = { columns: {
6184
- [at]: {
6185
- name: at,
6184
+ [ot]: {
6185
+ name: ot,
6186
6186
  type: "pk",
6187
6187
  fieldType: this.database.mapToDBFieldType("pk")
6188
6188
  }
@@ -6226,8 +6226,8 @@ ${Object.values(this.tables[t].columns).map((r) => ` "${r.name}" ${r.fieldTyp
6226
6226
  return this.fieldCounter++, this.fieldNameMap.set(t, i), this.usedFieldNames.add(i), i;
6227
6227
  }
6228
6228
  }
6229
- const tt = "_System_", q = "_Dictionary_", ne = "id", at = "_rowId", pr = C.create({
6230
- name: tt,
6229
+ const et = "_System_", q = "_Dictionary_", le = "id", ot = "_rowId", yr = C.create({
6230
+ name: et,
6231
6231
  properties: [
6232
6232
  T.create({
6233
6233
  name: "concept",
@@ -6245,7 +6245,7 @@ const tt = "_System_", q = "_Dictionary_", ne = "id", at = "_rowId", pr = C.crea
6245
6245
  collection: !1
6246
6246
  })
6247
6247
  ]
6248
- }), fr = C.create({
6248
+ }), gr = C.create({
6249
6249
  name: q,
6250
6250
  properties: [
6251
6251
  T.create({
@@ -6259,8 +6259,8 @@ const tt = "_System_", q = "_Dictionary_", ne = "id", at = "_rowId", pr = C.crea
6259
6259
  collection: !1
6260
6260
  })
6261
6261
  ]
6262
- }), $i = 0, Pt = 1, Pi = 2;
6263
- class mr {
6262
+ }), _i = 0, Ot = 1, qi = 2;
6263
+ class br {
6264
6264
  constructor(t, e) {
6265
6265
  this.controller = t, this.scheduler = e, this.sourceMaps = [], this.sourceMapTree = {};
6266
6266
  }
@@ -6274,18 +6274,18 @@ class mr {
6274
6274
  if (this.scheduler.isDataBasedComputation(r)) {
6275
6275
  if (Object.entries(r.dataDeps).forEach(([i, s]) => {
6276
6276
  const a = this.convertDataDepToERMutationEventsSourceMap(i, s, r);
6277
- e[s.phase || Pt].push(...a);
6277
+ e[s.phase || Ot].push(...a);
6278
6278
  }), r.dataContext.type === "property" && Object.values(r.dataDeps).some((i) => i.type === "global")) {
6279
6279
  const i = {
6280
6280
  type: "records",
6281
6281
  source: r.dataContext.host
6282
6282
  };
6283
- e[Pt].push(...this.convertDataDepToERMutationEventsSourceMap("_self", i, r, "create"));
6283
+ e[Ot].push(...this.convertDataDepToERMutationEventsSourceMap("_self", i, r, "create"));
6284
6284
  }
6285
6285
  } else {
6286
6286
  const { eventDeps: i } = r;
6287
6287
  for (const s of Object.values(i))
6288
- e[s.phase || Pt].push({
6288
+ e[s.phase || Ot].push({
6289
6289
  type: s.type,
6290
6290
  recordName: s.recordName,
6291
6291
  record: s.record,
@@ -6487,31 +6487,31 @@ class mr {
6487
6487
  }
6488
6488
  class A {
6489
6489
  static {
6490
- this.skip = () => new vt();
6490
+ this.skip = () => new At();
6491
6491
  }
6492
6492
  static {
6493
- this.resolved = (t, e) => new ke(t, e);
6493
+ this.resolved = (t, e) => new Ee(t, e);
6494
6494
  }
6495
6495
  static {
6496
- this.async = (t) => new ve(t);
6496
+ this.async = (t) => new Ae(t);
6497
6497
  }
6498
6498
  static {
6499
- this.fullRecompute = (t) => new Se(t);
6499
+ this.fullRecompute = (t) => new ke(t);
6500
6500
  }
6501
6501
  }
6502
- class vt extends A {
6502
+ class At extends A {
6503
6503
  }
6504
- class Se extends A {
6504
+ class ke extends A {
6505
6505
  constructor(t) {
6506
6506
  super(), this.reason = t;
6507
6507
  }
6508
6508
  }
6509
- class ve extends A {
6509
+ class Ae extends A {
6510
6510
  constructor(t) {
6511
6511
  super(), this.args = t;
6512
6512
  }
6513
6513
  }
6514
- class ke extends A {
6514
+ class Ee extends A {
6515
6515
  constructor(t, e) {
6516
6516
  super(), this.result = t, this.args = e;
6517
6517
  }
@@ -6542,18 +6542,18 @@ class B {
6542
6542
  return await this.controller.system.storage.dict.get(this.key);
6543
6543
  }
6544
6544
  }
6545
- function Qt(u, t) {
6545
+ function Lt(u, t) {
6546
6546
  if (t == null || u === t) return !0;
6547
6547
  if (typeof t != "object" || t === null)
6548
6548
  return u === t;
6549
6549
  if (typeof u != "object" || u === null)
6550
6550
  return !1;
6551
6551
  for (const e in t)
6552
- if (!(e in u) || !Qt(u[e], t[e]))
6552
+ if (!(e in u) || !Lt(u[e], t[e]))
6553
6553
  return !1;
6554
6554
  return !0;
6555
6555
  }
6556
- class Ae {
6556
+ class Ie {
6557
6557
  constructor(t) {
6558
6558
  this.data = t, this.map = {};
6559
6559
  for (const e of t.transfers)
@@ -6566,45 +6566,45 @@ class Ae {
6566
6566
  const r = this.map[t];
6567
6567
  if (r) {
6568
6568
  for (const i of r)
6569
- if (Qt(e, i.trigger))
6569
+ if (Lt(e, i.trigger))
6570
6570
  return i.next;
6571
6571
  }
6572
6572
  return null;
6573
6573
  }
6574
6574
  findTransfers(t) {
6575
- return this.data.transfers.filter((e) => Qt(t, e.trigger));
6575
+ return this.data.transfers.filter((e) => Lt(t, e.trigger));
6576
6576
  }
6577
6577
  }
6578
6578
  function v(u, t) {
6579
6579
  if (!u)
6580
6580
  throw new Error(t);
6581
6581
  }
6582
- function Di(u, t) {
6582
+ function Bi(u, t) {
6583
6583
  return new Map(Array.from(u.entries()).map(([e, r]) => [e, t(e, r)]));
6584
6584
  }
6585
- function Oi(u, t) {
6585
+ function Wi(u, t) {
6586
6586
  return Object.fromEntries(Object.entries(u).map(([e, r]) => [e, t(e, r)]));
6587
6587
  }
6588
- async function Fi(u, t) {
6588
+ async function Ji(u, t) {
6589
6589
  for (let e of u)
6590
6590
  if (!await t(e)) return !1;
6591
6591
  return !0;
6592
6592
  }
6593
- async function yr(u, t) {
6593
+ async function Rr(u, t) {
6594
6594
  for (let e of u)
6595
6595
  if (await t(e)) return !0;
6596
6596
  return !1;
6597
6597
  }
6598
- async function gr(u, t) {
6598
+ async function wr(u, t) {
6599
6599
  for (let e of u) {
6600
6600
  const r = await t(e);
6601
6601
  if (r !== !0) return r;
6602
6602
  }
6603
6603
  return !0;
6604
6604
  }
6605
- class br {
6605
+ class Nr {
6606
6606
  constructor(t, e, r) {
6607
- this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ae(this.args), this.defaultState = this.args.defaultState;
6607
+ this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ie(this.args), this.defaultState = this.args.defaultState;
6608
6608
  for (const i of this.args.transfers) {
6609
6609
  const s = `${i.trigger.recordName}_${i.trigger.type}`;
6610
6610
  this.eventDeps[s] = {
@@ -6614,7 +6614,7 @@ class br {
6614
6614
  }
6615
6615
  }
6616
6616
  static {
6617
- this.computationType = ct;
6617
+ this.computationType = lt;
6618
6618
  }
6619
6619
  static {
6620
6620
  this.contextType = "global";
@@ -6633,9 +6633,9 @@ class br {
6633
6633
  return s ? (await this.state.currentState.set(s.name), s.computeValue ? await s.computeValue.call(this.controller, t, e) : s.name) : A.skip();
6634
6634
  }
6635
6635
  }
6636
- class Rr {
6636
+ class Tr {
6637
6637
  constructor(t, e, r) {
6638
- this.controller = t, this.args = e, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ae(this.args), this.defaultState = this.args.defaultState, this.dataContext = r;
6638
+ this.controller = t, this.args = e, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ie(this.args), this.defaultState = this.args.defaultState, this.dataContext = r;
6639
6639
  for (const i of this.args.transfers) {
6640
6640
  const s = `${i.trigger.recordName}_${i.trigger.type}`;
6641
6641
  this.eventDeps[s] = {
@@ -6645,7 +6645,7 @@ class Rr {
6645
6645
  }
6646
6646
  }
6647
6647
  static {
6648
- this.computationType = ct;
6648
+ this.computationType = lt;
6649
6649
  }
6650
6650
  static {
6651
6651
  this.contextType = "property";
@@ -6681,17 +6681,17 @@ Or if you want to use state name as value, you should not set ${this.dataContext
6681
6681
  };
6682
6682
  }
6683
6683
  }
6684
- const Qi = Y.create({
6684
+ const ji = z.create({
6685
6685
  name: "nonExistent",
6686
6686
  computeValue: () => null
6687
- }), Vi = Y.create({
6687
+ }), Ui = z.create({
6688
6688
  name: "nonDeleted",
6689
6689
  computeValue: () => !1
6690
- }), Li = Y.create({
6690
+ }), Hi = z.create({
6691
6691
  name: "deleted",
6692
6692
  computeValue: () => !0
6693
- }), wr = [br, Rr];
6694
- class Nr {
6693
+ }), Sr = [Nr, Tr];
6694
+ class vr {
6695
6695
  constructor(t, e, r) {
6696
6696
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.matchRecordToWeight = this.args.callback.bind(this.controller), this.record = this.args.record, this.dataDeps = {
6697
6697
  main: {
@@ -6703,7 +6703,7 @@ class Nr {
6703
6703
  };
6704
6704
  }
6705
6705
  static {
6706
- this.computationType = lt;
6706
+ this.computationType = ut;
6707
6707
  }
6708
6708
  static {
6709
6709
  this.contextType = "global";
@@ -6744,7 +6744,7 @@ class Nr {
6744
6744
  return r;
6745
6745
  }
6746
6746
  }
6747
- class Tr {
6747
+ class kr {
6748
6748
  constructor(t, e, r) {
6749
6749
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.matchRecordToWeight = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === r.host && a.sourceProperty === this.args.property || a.target === r.host && a.targetProperty === this.args.property), v(this.relation, "weighted summation computation must specify property"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === r.host.name, v(this.isSource ? this.relation.source === r.host : this.relation.target === r.host, "weighted summation computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6750
6750
  const i = this.args.attributeQuery || [];
@@ -6762,7 +6762,7 @@ class Tr {
6762
6762
  };
6763
6763
  }
6764
6764
  static {
6765
- this.computationType = lt;
6765
+ this.computationType = ut;
6766
6766
  }
6767
6767
  static {
6768
6768
  this.contextType = "property";
@@ -6820,8 +6820,8 @@ class Tr {
6820
6820
  return s;
6821
6821
  }
6822
6822
  }
6823
- const Sr = [Nr, Tr];
6824
- class vr {
6823
+ const Ar = [vr, kr];
6824
+ class Er {
6825
6825
  constructor(t, e, r) {
6826
6826
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.dataDeps = {
6827
6827
  main: {
@@ -6833,7 +6833,7 @@ class vr {
6833
6833
  }, this.defaultValue = !this.args.notEmpty;
6834
6834
  }
6835
6835
  static {
6836
- this.computationType = pt;
6836
+ this.computationType = ft;
6837
6837
  }
6838
6838
  static {
6839
6839
  this.contextType = "global";
@@ -6874,7 +6874,7 @@ class vr {
6874
6874
  return a === s;
6875
6875
  }
6876
6876
  }
6877
- class kr {
6877
+ class Ir {
6878
6878
  constructor(t, e, r) {
6879
6879
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((a) => a.source === r.host && a.sourceProperty === this.args.property || a.target === r.host && a.targetProperty === this.args.property), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === r.host.name, v(this.isSource ? this.relation.source === r.host : this.relation.target === r.host, "every computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
6880
6880
  const i = this.args.attributeQuery || [];
@@ -6893,7 +6893,7 @@ class kr {
6893
6893
  };
6894
6894
  }
6895
6895
  static {
6896
- this.computationType = pt;
6896
+ this.computationType = ft;
6897
6897
  }
6898
6898
  static {
6899
6899
  this.contextType = "property";
@@ -6948,8 +6948,8 @@ class kr {
6948
6948
  return a === o;
6949
6949
  }
6950
6950
  }
6951
- const Ar = [vr, kr];
6952
- class Er {
6951
+ const Cr = [Er, Ir];
6952
+ class xr {
6953
6953
  constructor(t, e, r) {
6954
6954
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.dataDeps = {
6955
6955
  main: {
@@ -6961,7 +6961,7 @@ class Er {
6961
6961
  };
6962
6962
  }
6963
6963
  static {
6964
- this.computationType = ft;
6964
+ this.computationType = mt;
6965
6965
  }
6966
6966
  static {
6967
6967
  this.contextType = "global";
@@ -7002,7 +7002,7 @@ class Er {
7002
7002
  return s > 0;
7003
7003
  }
7004
7004
  }
7005
- class Ir {
7005
+ class Mr {
7006
7006
  constructor(t, e, r) {
7007
7007
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback.bind(this.controller), this.relation = this.controller.relations.find((n) => n.source === r.host && n.sourceProperty === this.args.property || n.target === r.host && n.targetProperty === this.args.property), v(this.relation, `cannot find relation for property ${this.args.property} in "Any" computation`), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === r.host.name, v(this.isSource ? this.relation.source === r.host : this.relation.target === r.host, "any computation relation direction error");
7008
7008
  let i = this.relation.baseRelation || this.relation;
@@ -7025,7 +7025,7 @@ class Ir {
7025
7025
  };
7026
7026
  }
7027
7027
  static {
7028
- this.computationType = ft;
7028
+ this.computationType = mt;
7029
7029
  }
7030
7030
  static {
7031
7031
  this.contextType = "property";
@@ -7078,8 +7078,8 @@ class Ir {
7078
7078
  return s > 0;
7079
7079
  }
7080
7080
  }
7081
- const Cr = [Er, Ir];
7082
- class xr {
7081
+ const $r = [xr, Mr];
7082
+ class Pr {
7083
7083
  constructor(t, e, r) {
7084
7084
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.record = this.args.record, this.callback = this.args.callback?.bind(this) || (() => !0), this.dataDeps = {
7085
7085
  main: {
@@ -7091,7 +7091,7 @@ class xr {
7091
7091
  };
7092
7092
  }
7093
7093
  static {
7094
- this.computationType = ut;
7094
+ this.computationType = dt;
7095
7095
  }
7096
7096
  static {
7097
7097
  this.contextType = "global";
@@ -7129,7 +7129,7 @@ class xr {
7129
7129
  return s = Math.max(0, s), await this.state.count.set(s), s;
7130
7130
  }
7131
7131
  }
7132
- class Mr {
7132
+ class Dr {
7133
7133
  constructor(t, e, r) {
7134
7134
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.callback = this.args.callback?.bind(this.controller), this.args.property ? this.relation = this.controller.relations.find((a) => a.source === r.host && a.sourceProperty === this.args.property || a.target === r.host && a.targetProperty === this.args.property) : this.relation = this.args.record, this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === r.host.name, v(this.isSource ? this.relation.source === r.host : this.relation.target === r.host, "count computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
7135
7135
  const i = this.args.attributeQuery || [];
@@ -7147,7 +7147,7 @@ class Mr {
7147
7147
  };
7148
7148
  }
7149
7149
  static {
7150
- this.computationType = ut;
7150
+ this.computationType = dt;
7151
7151
  }
7152
7152
  static {
7153
7153
  this.contextType = "property";
@@ -7211,8 +7211,8 @@ class Mr {
7211
7211
  return a;
7212
7212
  }
7213
7213
  }
7214
- const $r = [xr, Mr];
7215
- class Pr {
7214
+ const Or = [Pr, Dr];
7215
+ class Fr {
7216
7216
  constructor(t, e, r) {
7217
7217
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, v(!(this.args.record && this.args.eventDeps), "Transform must have either record or eventDep"), v(!(this.args.dataDeps && this.args.eventDeps), "Transform must have either dataDeps or eventDeps"), this.transformCallback = this.args.callback.bind(this.controller), this.args.eventDeps ? this.eventDeps = this.args.eventDeps : (v(this.args.dataDeps?._source === void 0, "dataDep name `_source` is reserved for Transform"), this.dataDeps = {
7218
7218
  ...this.args.dataDeps || {},
@@ -7224,7 +7224,7 @@ class Pr {
7224
7224
  });
7225
7225
  }
7226
7226
  static {
7227
- this.computationType = Ct;
7227
+ this.computationType = Mt;
7228
7228
  }
7229
7229
  static {
7230
7230
  this.contextType = ["entity", "relation"];
@@ -7320,7 +7320,7 @@ class Pr {
7320
7320
  return i;
7321
7321
  }
7322
7322
  }
7323
- const Dr = [Pr];
7323
+ const Vr = [Fr];
7324
7324
  class $ {
7325
7325
  constructor(t) {
7326
7326
  this.node = t;
@@ -7419,13 +7419,13 @@ class $ {
7419
7419
  }
7420
7420
  }
7421
7421
  gt(t) {
7422
- return new kt(this, ">", t);
7422
+ return new Et(this, ">", t);
7423
7423
  }
7424
7424
  lt(t) {
7425
- return new kt(this, "<", t);
7425
+ return new Et(this, "<", t);
7426
7426
  }
7427
7427
  eq(t) {
7428
- return new te(this, t);
7428
+ return new re(this, t);
7429
7429
  }
7430
7430
  getVariables() {
7431
7431
  const t = /* @__PURE__ */ new Set();
@@ -7522,7 +7522,7 @@ class $ {
7522
7522
  }
7523
7523
  }
7524
7524
  }
7525
- class kt {
7525
+ class Et {
7526
7526
  constructor(t, e, r) {
7527
7527
  this.left = t, this.operator = e, this.right = r;
7528
7528
  }
@@ -7557,7 +7557,7 @@ class kt {
7557
7557
  }
7558
7558
  }
7559
7559
  }
7560
- class te {
7560
+ class re {
7561
7561
  constructor(t, e) {
7562
7562
  this.left = t, this.right = e;
7563
7563
  }
@@ -7592,12 +7592,12 @@ class te {
7592
7592
  }
7593
7593
  }
7594
7594
  }
7595
- class Or {
7595
+ class Qr {
7596
7596
  constructor(t, e, r) {
7597
7597
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !1, this.dataDeps = this.args.dataDeps ?? {}, this.callback = (i, s) => this.args.callback.call(this.controller, i, s), this.nextRecomputeTime = this.args.nextRecomputeTime ? (i, s) => this.args.nextRecomputeTime.call(this.controller, i, s) : void 0;
7598
7598
  }
7599
7599
  static {
7600
- this.computationType = mt;
7600
+ this.computationType = yt;
7601
7601
  }
7602
7602
  static {
7603
7603
  this.contextType = "global";
@@ -7617,14 +7617,14 @@ class Or {
7617
7617
  let i, s;
7618
7618
  if (e instanceof $)
7619
7619
  i = e.evaluate({ now: r }), s = r + this.nextRecomputeTime(r, t);
7620
- else if (e instanceof kt || e instanceof te)
7620
+ else if (e instanceof Et || e instanceof re)
7621
7621
  i = e.evaluate({ now: r }), s = e.solve();
7622
7622
  else
7623
7623
  throw new Error("Invalid result type");
7624
7624
  return await this.state.lastRecomputeTime.set(r), await this.state.nextRecomputeTime.set(s), i;
7625
7625
  }
7626
7626
  }
7627
- class Fr {
7627
+ class Lr {
7628
7628
  constructor(t, e, r) {
7629
7629
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !1, this.dataDeps = {
7630
7630
  _current: {
@@ -7635,7 +7635,7 @@ class Fr {
7635
7635
  }, this.isResultNumber = this.dataContext.id.type === "number", this.callback = (i, s) => this.args.callback.call(this.controller, i, s), this.nextRecomputeTime = this.args.nextRecomputeTime ? (i, s) => this.args.nextRecomputeTime.call(this.controller, i, s) : void 0;
7636
7636
  }
7637
7637
  static {
7638
- this.computationType = mt;
7638
+ this.computationType = yt;
7639
7639
  }
7640
7640
  static {
7641
7641
  this.contextType = "property";
@@ -7655,15 +7655,15 @@ class Fr {
7655
7655
  let s, a;
7656
7656
  if (r instanceof $)
7657
7657
  s = r.evaluate({ now: i }), a = i + this.nextRecomputeTime(i, t);
7658
- else if (r instanceof kt || r instanceof te)
7658
+ else if (r instanceof Et || r instanceof re)
7659
7659
  s = r.evaluate({ now: i }), a = r.solve();
7660
7660
  else
7661
7661
  throw new Error("Invalid result type");
7662
7662
  return await this.state.lastRecomputeTime.set(e, i), await this.state.nextRecomputeTime.set(e, a), s;
7663
7663
  }
7664
7664
  }
7665
- const Qr = [Or, Fr];
7666
- class Vr {
7665
+ const _r = [Qr, Lr];
7666
+ class qr {
7667
7667
  constructor(t, e, r) {
7668
7668
  if (this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.record = this.args.record, !this.args.attributeQuery || this.args.attributeQuery.length === 0)
7669
7669
  throw new Error("Sum computation requires attributeQuery with at least one field");
@@ -7680,7 +7680,7 @@ class Vr {
7680
7680
  };
7681
7681
  }
7682
7682
  static {
7683
- this.computationType = dt;
7683
+ this.computationType = ht;
7684
7684
  }
7685
7685
  static {
7686
7686
  this.contextType = "global";
@@ -7724,7 +7724,7 @@ class Vr {
7724
7724
  return s;
7725
7725
  }
7726
7726
  }
7727
- class Lr {
7727
+ class Br {
7728
7728
  constructor(t, e, r) {
7729
7729
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.relation = this.controller.relations.find((o) => o.source === r.host && o.sourceProperty === this.args.property || o.target === r.host && o.targetProperty === this.args.property), v(this.relation, "summation computation must specify either property or record"), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === r.host.name, v(this.isSource ? this.relation.source === r.host : this.relation.target === r.host, "summation computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
7730
7730
  const i = this.args.attributeQuery || [];
@@ -7745,7 +7745,7 @@ class Lr {
7745
7745
  };
7746
7746
  }
7747
7747
  static {
7748
- this.computationType = dt;
7748
+ this.computationType = ht;
7749
7749
  }
7750
7750
  static {
7751
7751
  this.contextType = "property";
@@ -7813,8 +7813,8 @@ class Lr {
7813
7813
  return a;
7814
7814
  }
7815
7815
  }
7816
- const _r = [Vr, Lr];
7817
- class qr {
7816
+ const Wr = [qr, Br];
7817
+ class Jr {
7818
7818
  constructor(t, e, r) {
7819
7819
  if (this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.record = this.args.record, !this.args.attributeQuery || this.args.attributeQuery.length === 0)
7820
7820
  throw new Error("Average computation requires attributeQuery with at least one field");
@@ -7831,7 +7831,7 @@ class qr {
7831
7831
  };
7832
7832
  }
7833
7833
  static {
7834
- this.computationType = ht;
7834
+ this.computationType = pt;
7835
7835
  }
7836
7836
  static {
7837
7837
  this.contextType = "global";
@@ -7887,7 +7887,7 @@ class qr {
7887
7887
  return await this.state.sum.set(a), await this.state.count.set(s), s > 0 ? a / s : 0;
7888
7888
  }
7889
7889
  }
7890
- class Br {
7890
+ class jr {
7891
7891
  constructor(t, e, r) {
7892
7892
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.dataDeps = {}, this.relation = this.controller.relations.find((o) => o.source === r.host && o.sourceProperty === this.args.property || o.target === r.host && o.targetProperty === this.args.property), this.isSource = this.args.direction ? this.args.direction === "source" : this.relation.source.name === r.host.name, v(this.isSource ? this.relation.source === r.host : this.relation.target === r.host, "average computation relation direction error"), this.relationAttr = this.isSource ? this.relation.sourceProperty : this.relation.targetProperty, this.relatedRecordName = this.isSource ? this.relation.target.name : this.relation.source.name, this.property = this.args.property || this.relationAttr, this.reverseProperty = this.isSource ? this.relation.targetProperty : this.relation.sourceProperty;
7893
7893
  const i = this.args.attributeQuery || [];
@@ -7908,7 +7908,7 @@ class Br {
7908
7908
  };
7909
7909
  }
7910
7910
  static {
7911
- this.computationType = ht;
7911
+ this.computationType = pt;
7912
7912
  }
7913
7913
  static {
7914
7914
  this.contextType = "property";
@@ -7971,8 +7971,8 @@ class Br {
7971
7971
  return await this.state.count.set(e.record, a), a > 0 ? o / a : 0;
7972
7972
  }
7973
7973
  }
7974
- const Wr = [qr, Br];
7975
- class Mt {
7974
+ const Ur = [Jr, jr];
7975
+ class Pt {
7976
7976
  constructor(t, e, r) {
7977
7977
  this.controller = t, this.args = e, this.dataContext = r, this.state = {}, this.dataDeps = {}, this.useLastValue = e.useLastValue !== void 0 ? e.useLastValue : !0, e.dataDeps && (this.dataDeps = e.dataDeps), e.compute && (this.computeCallback = e.compute, this.compute = async (...i) => {
7978
7978
  if (this.computeCallback) {
@@ -8016,7 +8016,7 @@ class Mt {
8016
8016
  }));
8017
8017
  }
8018
8018
  static {
8019
- this.computationType = Zt;
8019
+ this.computationType = ee;
8020
8020
  }
8021
8021
  createState() {
8022
8022
  if (this.createStateCallback) {
@@ -8043,22 +8043,22 @@ class Mt {
8043
8043
  return A.skip();
8044
8044
  }
8045
8045
  }
8046
- class Jr extends Mt {
8046
+ class Hr extends Pt {
8047
8047
  static {
8048
8048
  this.contextType = "global";
8049
8049
  }
8050
8050
  }
8051
- class Hr extends Mt {
8051
+ class Gr extends Pt {
8052
8052
  static {
8053
8053
  this.contextType = "entity";
8054
8054
  }
8055
8055
  }
8056
- class jr extends Mt {
8056
+ class Kr extends Pt {
8057
8057
  static {
8058
8058
  this.contextType = "relation";
8059
8059
  }
8060
8060
  }
8061
- class Ur extends Mt {
8061
+ class Xr extends Pt {
8062
8062
  static {
8063
8063
  this.contextType = "property";
8064
8064
  }
@@ -8073,13 +8073,13 @@ If you want to use aggregated data from all records in the entity/relation, you
8073
8073
  super(t, e, r);
8074
8074
  }
8075
8075
  }
8076
- const Gr = [
8077
- Jr,
8076
+ const Yr = [
8078
8077
  Hr,
8079
- jr,
8080
- Ur
8078
+ Gr,
8079
+ Kr,
8080
+ Xr
8081
8081
  ];
8082
- class j extends Error {
8082
+ class H extends Error {
8083
8083
  constructor(t, e = {}) {
8084
8084
  super(`${t}. Caused by: ${e.causedBy?.message}`), this.name = this.constructor.name, this.timestamp = /* @__PURE__ */ new Date(), this.errorId = this.generateErrorId(), this.errorType = e.errorType || this.constructor.name, this.context = e.context || {}, this.causedBy = e.causedBy, this.stackTrace = this.stack, Object.setPrototypeOf(this, new.target.prototype);
8085
8085
  }
@@ -8092,7 +8092,7 @@ class j extends Error {
8092
8092
  getErrorChain() {
8093
8093
  const t = [this];
8094
8094
  let e = this.causedBy;
8095
- for (; e && (t.push(e), e instanceof j); )
8095
+ for (; e && (t.push(e), e instanceof H); )
8096
8096
  e = e.causedBy;
8097
8097
  return t;
8098
8098
  }
@@ -8196,13 +8196,13 @@ Stack trace:`, i.stack.split(`
8196
8196
  return null;
8197
8197
  }
8198
8198
  }
8199
- var V = /* @__PURE__ */ ((u) => (u.LOW = "low", u.MEDIUM = "medium", u.HIGH = "high", u.CRITICAL = "critical", u))(V || {}), Z = /* @__PURE__ */ ((u) => (u.VALIDATION = "validation", u.PERMISSION = "permission", u.COMPUTATION = "computation", u.STORAGE = "storage", u.INTERACTION = "interaction", u.ACTIVITY = "activity", u.SYSTEM = "system", u.CONFIGURATION = "configuration", u))(Z || {});
8200
- class U extends j {
8199
+ var Q = /* @__PURE__ */ ((u) => (u.LOW = "low", u.MEDIUM = "medium", u.HIGH = "high", u.CRITICAL = "critical", u))(Q || {}), tt = /* @__PURE__ */ ((u) => (u.VALIDATION = "validation", u.PERMISSION = "permission", u.COMPUTATION = "computation", u.STORAGE = "storage", u.INTERACTION = "interaction", u.ACTIVITY = "activity", u.SYSTEM = "system", u.CONFIGURATION = "configuration", u))(tt || {});
8200
+ class G extends H {
8201
8201
  constructor(t, e = {}) {
8202
8202
  super(t, {
8203
8203
  errorType: e.context?.errorType || "InteractionExecutionError",
8204
8204
  context: {
8205
- category: Z.INTERACTION,
8205
+ category: tt.INTERACTION,
8206
8206
  interactionName: e.interactionName,
8207
8207
  userId: e.userId,
8208
8208
  payload: e.payload,
@@ -8210,15 +8210,15 @@ class U extends j {
8210
8210
  ...e.context
8211
8211
  },
8212
8212
  causedBy: e.causedBy
8213
- }), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || V.HIGH;
8213
+ }), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || Q.HIGH;
8214
8214
  }
8215
8215
  }
8216
- class ce extends j {
8216
+ class ue extends H {
8217
8217
  constructor(t, e = {}) {
8218
8218
  super(t, {
8219
8219
  errorType: e.context?.errorType || "ActivityError",
8220
8220
  context: {
8221
- category: Z.ACTIVITY,
8221
+ category: tt.ACTIVITY,
8222
8222
  activityName: e.activityName,
8223
8223
  activityId: e.activityId,
8224
8224
  activityInstanceId: e.activityInstanceId,
@@ -8226,15 +8226,15 @@ class ce extends j {
8226
8226
  ...e.context
8227
8227
  },
8228
8228
  causedBy: e.causedBy
8229
- }), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || V.MEDIUM;
8229
+ }), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || Q.MEDIUM;
8230
8230
  }
8231
8231
  }
8232
- class Q extends j {
8232
+ class V extends H {
8233
8233
  constructor(t, e = {}) {
8234
8234
  super(t, {
8235
8235
  errorType: e.context?.errorType || "ComputationError",
8236
8236
  context: {
8237
- category: Z.COMPUTATION,
8237
+ category: tt.COMPUTATION,
8238
8238
  handleName: e.handleName,
8239
8239
  computationName: e.computationName,
8240
8240
  dataContext: e.dataContext,
@@ -8242,14 +8242,14 @@ class Q extends j {
8242
8242
  ...e.context
8243
8243
  },
8244
8244
  causedBy: e.causedBy
8245
- }), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || V.MEDIUM;
8245
+ }), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || Q.MEDIUM;
8246
8246
  }
8247
8247
  }
8248
- class le extends Q {
8248
+ class de extends V {
8249
8249
  constructor(t, e = {}) {
8250
8250
  super(t, {
8251
8251
  ...e,
8252
- severity: V.HIGH,
8252
+ severity: Q.HIGH,
8253
8253
  context: {
8254
8254
  errorType: "ComputationStateError",
8255
8255
  stateKey: e.stateKey,
@@ -8260,11 +8260,11 @@ class le extends Q {
8260
8260
  }), this.stateKey = e.stateKey, this.stateValue = e.stateValue, this.expectedStateType = e.expectedStateType, this.actualStateType = e.actualStateType;
8261
8261
  }
8262
8262
  }
8263
- class J extends Q {
8263
+ class J extends V {
8264
8264
  constructor(t, e = {}) {
8265
8265
  super(t, {
8266
8266
  ...e,
8267
- severity: V.MEDIUM,
8267
+ severity: Q.MEDIUM,
8268
8268
  context: {
8269
8269
  errorType: "ComputationDataDepError",
8270
8270
  depName: e.depName,
@@ -8275,26 +8275,26 @@ class J extends Q {
8275
8275
  }), this.depName = e.depName, this.depType = e.depType, this.missingData = e.missingData, this.invalidData = e.invalidData;
8276
8276
  }
8277
8277
  }
8278
- class H extends j {
8278
+ class j extends H {
8279
8279
  constructor(t, e = {}) {
8280
8280
  super(t, {
8281
8281
  errorType: e.context?.errorType || "SchedulerError",
8282
8282
  context: {
8283
- category: Z.SYSTEM,
8283
+ category: tt.SYSTEM,
8284
8284
  schedulingPhase: e.schedulingPhase,
8285
8285
  failedComputations: e.failedComputations,
8286
8286
  ...e.context
8287
8287
  },
8288
8288
  causedBy: e.causedBy
8289
- }), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = V.HIGH;
8289
+ }), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = Q.HIGH;
8290
8290
  }
8291
8291
  }
8292
- class O extends j {
8292
+ class O extends H {
8293
8293
  constructor(t, e) {
8294
8294
  super(t, {
8295
8295
  errorType: e.context?.errorType || "ConditionError",
8296
8296
  context: {
8297
- category: Z.PERMISSION,
8297
+ category: tt.PERMISSION,
8298
8298
  checkType: e.checkType,
8299
8299
  fieldName: e.fieldName,
8300
8300
  payload: e.payload,
@@ -8302,7 +8302,7 @@ class O extends j {
8302
8302
  ...e.context
8303
8303
  },
8304
8304
  causedBy: e.causedBy
8305
- }), this.checkType = e.checkType, this.fieldName = e.fieldName, this.payload = e.payload, this.evaluationError = e.evaluationError, this.error = e.evaluationError, this.type = e.type || t, this.severity = e.severity || V.HIGH;
8305
+ }), this.checkType = e.checkType, this.fieldName = e.fieldName, this.payload = e.payload, this.evaluationError = e.evaluationError, this.error = e.evaluationError, this.type = e.type || t, this.severity = e.severity || Q.HIGH;
8306
8306
  }
8307
8307
  /**
8308
8308
  * Helper factory methods for common condition error scenarios
@@ -8311,7 +8311,7 @@ class O extends j {
8311
8311
  return new O("User check failed", {
8312
8312
  checkType: "user",
8313
8313
  evaluationError: t,
8314
- severity: V.HIGH,
8314
+ severity: Q.HIGH,
8315
8315
  context: e,
8316
8316
  type: "check user failed"
8317
8317
  // For backward compatibility
@@ -8324,7 +8324,7 @@ class O extends j {
8324
8324
  fieldName: t,
8325
8325
  payload: r,
8326
8326
  evaluationError: i,
8327
- severity: V.MEDIUM,
8327
+ severity: Q.MEDIUM,
8328
8328
  type: s
8329
8329
  // For backward compatibility
8330
8330
  });
@@ -8333,7 +8333,7 @@ class O extends j {
8333
8333
  return new O(`Condition check failed: ${t.data.name}`, {
8334
8334
  checkType: "condition",
8335
8335
  evaluationError: t,
8336
- severity: V.HIGH,
8336
+ severity: Q.HIGH,
8337
8337
  context: e,
8338
8338
  type: "condition check failed"
8339
8339
  // For backward compatibility
@@ -8346,7 +8346,7 @@ class O extends j {
8346
8346
  fieldName: t,
8347
8347
  payload: r,
8348
8348
  evaluationError: i,
8349
- severity: V.MEDIUM,
8349
+ severity: Q.MEDIUM,
8350
8350
  type: s
8351
8351
  // For backward compatibility
8352
8352
  });
@@ -8356,16 +8356,16 @@ class O extends j {
8356
8356
  checkType: "concept",
8357
8357
  fieldName: t,
8358
8358
  evaluationError: e,
8359
- severity: V.MEDIUM,
8359
+ severity: Q.MEDIUM,
8360
8360
  type: `${t} check concept failed`
8361
8361
  // For backward compatibility
8362
8362
  });
8363
8363
  }
8364
8364
  }
8365
- const Dt = "_ASYNC_TASK_";
8366
- class Kr {
8365
+ const Ft = "_ASYNC_TASK_";
8366
+ class zr {
8367
8367
  constructor(t, e, r, i, s) {
8368
- this.controller = t, this.computationsHandles = /* @__PURE__ */ new Map(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.sourceMapManager = new mr(this.controller, this), this.buildComputationHandleMap(s);
8368
+ this.controller = t, this.computationsHandles = /* @__PURE__ */ new Map(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.sourceMapManager = new br(this.controller, this), this.buildComputationHandleMap(s);
8369
8369
  const a = [];
8370
8370
  i.forEach((o) => {
8371
8371
  o.computation && a.push({ dataContext: { type: "global", id: o }, args: o.computation });
@@ -8653,7 +8653,7 @@ class Kr {
8653
8653
  try {
8654
8654
  this.isDataBasedComputation(t.computation) ? r = await this.computeDataBasedDirtyRecordsAndEvents(t, e) : r = await this.computeEventBasedDirtyRecordsAndEvents(t, e);
8655
8655
  } catch (i) {
8656
- throw new Q("Failed to compute dirty records and events", {
8656
+ throw new V("Failed to compute dirty records and events", {
8657
8657
  handleName: t.computation.constructor.name,
8658
8658
  computationName: t.computation.args.constructor.displayName,
8659
8659
  dataContext: t.computation.dataContext,
@@ -8665,7 +8665,7 @@ class Kr {
8665
8665
  try {
8666
8666
  await this.runComputation(t.computation, s, i);
8667
8667
  } catch (a) {
8668
- throw new Q("Failed to run computation for dirty record", {
8668
+ throw new V("Failed to run computation for dirty record", {
8669
8669
  handleName: t.computation.constructor.name,
8670
8670
  computationName: t.computation.args.constructor.displayName,
8671
8671
  dataContext: t.computation.dataContext,
@@ -8676,7 +8676,7 @@ class Kr {
8676
8676
  }
8677
8677
  }
8678
8678
  } catch (r) {
8679
- throw r instanceof Q ? r : new H("Unexpected error in dirty records computation", {
8679
+ throw r instanceof V ? r : new j("Unexpected error in dirty records computation", {
8680
8680
  schedulingPhase: "dirty-records-processing",
8681
8681
  failedComputations: [t.computation.args.constructor.displayName],
8682
8682
  causedBy: r instanceof Error ? r : new Error(String(r))
@@ -8686,8 +8686,8 @@ class Kr {
8686
8686
  getAsyncTaskRecordKey(t) {
8687
8687
  if (t.dataContext.type === "property") {
8688
8688
  const e = t.dataContext;
8689
- return `${Dt}_${e.host.name}_${e.id.name}`;
8690
- } else return t.dataContext.type === "global" ? `${Dt}_${t.dataContext.id.name}` : `${Dt}_${t.dataContext.type}_${t.dataContext.id?.name}`;
8689
+ return `${Ft}_${e.host.name}_${e.id.name}`;
8690
+ } else return t.dataContext.type === "global" ? `${Ft}_${t.dataContext.id.name}` : `${Ft}_${t.dataContext.type}_${t.dataContext.id?.name}`;
8691
8691
  }
8692
8692
  async createAsyncTask(t, e, r, i) {
8693
8693
  if (t.dataContext.type === "property")
@@ -8756,7 +8756,7 @@ class Kr {
8756
8756
  try {
8757
8757
  o = await this.controller.retrieveLastValue(t.dataContext, r);
8758
8758
  } catch (n) {
8759
- throw new le("Failed to retrieve last value for incremental computation", {
8759
+ throw new de("Failed to retrieve last value for incremental computation", {
8760
8760
  handleName: t.constructor.name,
8761
8761
  computationName: t.args.constructor.displayName,
8762
8762
  dataContext: t.dataContext,
@@ -8770,7 +8770,7 @@ class Kr {
8770
8770
  try {
8771
8771
  o = await this.controller.retrieveLastValue(t.dataContext, r);
8772
8772
  } catch (n) {
8773
- throw new le("Failed to retrieve last value for incremental patch computation", {
8773
+ throw new de("Failed to retrieve last value for incremental patch computation", {
8774
8774
  handleName: t.constructor.name,
8775
8775
  computationName: t.args.constructor.displayName,
8776
8776
  dataContext: t.dataContext,
@@ -8779,16 +8779,16 @@ class Kr {
8779
8779
  }
8780
8780
  s = await t.incrementalPatchCompute(o, e, r, a);
8781
8781
  } else
8782
- throw new Q(`Unknown computation type: ${t.constructor.name}`, {
8782
+ throw new V(`Unknown computation type: ${t.constructor.name}`, {
8783
8783
  handleName: t.constructor.name,
8784
8784
  computationName: t.args.constructor.displayName,
8785
8785
  dataContext: t.dataContext,
8786
8786
  computationPhase: "type-validation"
8787
8787
  });
8788
- if (s instanceof Se) {
8788
+ if (s instanceof ke) {
8789
8789
  const o = t;
8790
8790
  if (!o.compute)
8791
- throw new Q("compute must be defined for computation when incrementalCompute returns ComputationResultFullRecompute", {
8791
+ throw new V("compute must be defined for computation when incrementalCompute returns ComputationResultFullRecompute", {
8792
8792
  handleName: t.constructor.name,
8793
8793
  computationName: t.args.constructor.displayName,
8794
8794
  dataContext: t.dataContext,
@@ -8798,7 +8798,7 @@ class Kr {
8798
8798
  }
8799
8799
  }
8800
8800
  } catch (o) {
8801
- throw o instanceof Q ? o : new Q("Computation execution failed", {
8801
+ throw o instanceof V ? o : new V("Computation execution failed", {
8802
8802
  handleName: t.constructor.name,
8803
8803
  computationName: t.args.constructor.displayName,
8804
8804
  dataContext: t.dataContext,
@@ -8806,13 +8806,13 @@ class Kr {
8806
8806
  causedBy: o instanceof Error ? o : new Error(String(o))
8807
8807
  });
8808
8808
  }
8809
- if (s instanceof vt)
8809
+ if (s instanceof At)
8810
8810
  return;
8811
- if (s instanceof ve)
8811
+ if (s instanceof Ae)
8812
8812
  try {
8813
8813
  return await this.createAsyncTask(t, s.args, r);
8814
8814
  } catch (o) {
8815
- throw new Q("Failed to create async task", {
8815
+ throw new V("Failed to create async task", {
8816
8816
  handleName: t.constructor.name,
8817
8817
  computationName: t.args.constructor.displayName,
8818
8818
  dataContext: t.dataContext,
@@ -8821,10 +8821,10 @@ class Kr {
8821
8821
  });
8822
8822
  }
8823
8823
  try {
8824
- const o = s instanceof ke ? await t.asyncReturn(s.result, s.args) : s;
8824
+ const o = s instanceof Ee ? await t.asyncReturn(s.result, s.args) : s;
8825
8825
  t.incrementalPatchCompute ? await this.controller.applyResultPatch(t.dataContext, o, r) : await this.controller.applyResult(t.dataContext, o, r);
8826
8826
  } catch (o) {
8827
- throw new Q("Failed to apply computation result", {
8827
+ throw new V("Failed to apply computation result", {
8828
8828
  handleName: t.constructor.name,
8829
8829
  computationName: t.args.constructor.displayName,
8830
8830
  dataContext: t.dataContext,
@@ -8833,7 +8833,7 @@ class Kr {
8833
8833
  });
8834
8834
  }
8835
8835
  } catch (s) {
8836
- throw s instanceof Q ? s : new Q("Unexpected error during computation execution", {
8836
+ throw s instanceof V ? s : new V("Unexpected error during computation execution", {
8837
8837
  handleName: t.constructor.name,
8838
8838
  computationName: t.args.constructor.displayName,
8839
8839
  dataContext: t.dataContext,
@@ -8905,7 +8905,7 @@ class Kr {
8905
8905
  try {
8906
8906
  await this.setupDefaultValues();
8907
8907
  } catch (t) {
8908
- throw new H("Failed to setup computation default values", {
8908
+ throw new j("Failed to setup computation default values", {
8909
8909
  schedulingPhase: "default-values-setup",
8910
8910
  causedBy: t instanceof Error ? t : new Error(String(t))
8911
8911
  });
@@ -8913,7 +8913,7 @@ class Kr {
8913
8913
  try {
8914
8914
  await this.setupGlobalBoundStateDefaultValues();
8915
8915
  } catch (t) {
8916
- throw new H("Failed to setup computation state default values", {
8916
+ throw new j("Failed to setup computation state default values", {
8917
8917
  schedulingPhase: "state-default-values-setup",
8918
8918
  causedBy: t instanceof Error ? t : new Error(String(t))
8919
8919
  });
@@ -8921,7 +8921,7 @@ class Kr {
8921
8921
  try {
8922
8922
  await this.setupMutationListeners();
8923
8923
  } catch (t) {
8924
- throw new H("Failed to setup mutation listeners for computations", {
8924
+ throw new j("Failed to setup mutation listeners for computations", {
8925
8925
  schedulingPhase: "mutation-listeners-setup",
8926
8926
  causedBy: t instanceof Error ? t : new Error(String(t))
8927
8927
  });
@@ -8929,20 +8929,20 @@ class Kr {
8929
8929
  try {
8930
8930
  await this.setupGlobalDict();
8931
8931
  } catch (t) {
8932
- throw new H("Failed to setup global dictionary", {
8932
+ throw new j("Failed to setup global dictionary", {
8933
8933
  schedulingPhase: "global-dict-setup",
8934
8934
  causedBy: t instanceof Error ? t : new Error(String(t))
8935
8935
  });
8936
8936
  }
8937
8937
  } catch (t) {
8938
- throw t instanceof H ? t : new H("Unexpected error during scheduler setup", {
8938
+ throw t instanceof j ? t : new j("Unexpected error during scheduler setup", {
8939
8939
  schedulingPhase: "top-level-setup",
8940
8940
  causedBy: t instanceof Error ? t : new Error(String(t))
8941
8941
  });
8942
8942
  }
8943
8943
  }
8944
8944
  }
8945
- class Ee {
8945
+ class Ce {
8946
8946
  constructor(t, e, r) {
8947
8947
  this.interaction = t, this.controller = e, this.activitySeqCall = r, this.system = e.system;
8948
8948
  }
@@ -8970,7 +8970,7 @@ class Ee {
8970
8970
  async checkUser(t, e, r) {
8971
8971
  let i;
8972
8972
  if (!this.interaction.userAttributives) return !0;
8973
- const s = Et.is(this.interaction.userAttributives) ? R.fromValue(
8973
+ const s = Ct.is(this.interaction.userAttributives) ? R.fromValue(
8974
8974
  this.interaction.userAttributives.content
8975
8975
  ) : R.atom(
8976
8976
  this.interaction.userAttributives
@@ -8996,12 +8996,12 @@ class Ee {
8996
8996
  }
8997
8997
  if (this.isConceptAlias(e)) {
8998
8998
  const s = [];
8999
- return await yr(e.for, async (o) => {
8999
+ return await Rr(e.for, async (o) => {
9000
9000
  const n = await this.isConcept(t, o);
9001
9001
  return n === !0 ? !0 : (s.push(n), !1);
9002
9002
  }) ? !0 : { name: e.name, type: "conceptAlias", stack: i, error: s };
9003
9003
  } else {
9004
- if (X.is(e))
9004
+ if (Y.is(e))
9005
9005
  return await this.checkAttributive(e, void 0, t) ? !0 : { name: e.name, type: "conceptCheck", stack: i, error: "role check error" };
9006
9006
  const s = e.constructor?.check;
9007
9007
  return s ? s(t) ? !0 : { name: e.name, type: "conceptCheck", stack: i, error: "constructor check error" } : e.constructor && typeof e.constructor.check == "function" ? e.constructor.check(t) ? !0 : { name: e.name || "", type: "conceptCheck", stack: i, error: "constructor check error" } : C.is(e) ? t && typeof t == "object" && "id" in t || t && typeof t == "object" ? !0 : { name: e.name || "", type: "conceptCheck", stack: i, error: "invalid entity data" } : t && typeof t == "object" ? !0 : typeof e == "function" ? t instanceof e ? !0 : { name: e.name, type: "conceptCheck", stack: i, error: "instanceof check error" } : (console.warn(`unknown concept ${e}, cannot check ${t}. pass.`), !0);
@@ -9036,7 +9036,7 @@ class Ee {
9036
9036
  throw O.payloadValidationFailed(i.name, "data is not a ref", s);
9037
9037
  if (i.base)
9038
9038
  if (i.isCollection) {
9039
- const a = await gr(s, (o) => this.checkConcept(o, i.base));
9039
+ const a = await wr(s, (o) => this.checkConcept(o, i.base));
9040
9040
  if (a !== !0)
9041
9041
  throw O.conceptCheckFailed(i.name, a);
9042
9042
  } else {
@@ -9058,7 +9058,7 @@ class Ee {
9058
9058
  }
9059
9059
  async checkCondition(t) {
9060
9060
  if (this.interaction.conditions) {
9061
- const e = xt.is(this.interaction.conditions) ? new R(this.interaction.conditions.content) : R.atom(this.interaction.conditions), r = async (s) => {
9061
+ const e = $t.is(this.interaction.conditions) ? new R(this.interaction.conditions.content) : R.atom(this.interaction.conditions), r = async (s) => {
9062
9062
  if (!s) return !0;
9063
9063
  if (s.content) {
9064
9064
  const a = s.content;
@@ -9092,7 +9092,7 @@ class Ee {
9092
9092
  v(!r.sideEffects[o], `sideEffect ${o} already exists`), r.sideEffects[o] = { result: n, error: c };
9093
9093
  }
9094
9094
  isGetInteraction() {
9095
- return this.interaction.action === We;
9095
+ return this.interaction.action === Ue;
9096
9096
  }
9097
9097
  async saveEvent(t) {
9098
9098
  return await this.controller.activityManager.saveEvent(t);
@@ -9138,7 +9138,7 @@ class Ee {
9138
9138
  return s;
9139
9139
  }
9140
9140
  }
9141
- class G {
9141
+ class K {
9142
9142
  constructor(t, e) {
9143
9143
  this.graph = t, this.parent = e;
9144
9144
  }
@@ -9148,7 +9148,7 @@ class G {
9148
9148
  };
9149
9149
  }
9150
9150
  static create(t, e, r) {
9151
- const i = new G(e, r);
9151
+ const i = new K(e, r);
9152
9152
  return t.current && (i.current = D.create(t.current, e, i)), i;
9153
9153
  }
9154
9154
  isInteractionAvailable(t) {
@@ -9182,13 +9182,13 @@ class D {
9182
9182
  }
9183
9183
  static createInitialState(t) {
9184
9184
  const e = { uuid: t.uuid };
9185
- return rt.is(t.content) && (e.children = t.childSeqs.map((r) => G.createInitialState(r.head))), e;
9185
+ return it.is(t.content) && (e.children = t.childSeqs.map((r) => K.createInitialState(r.head))), e;
9186
9186
  }
9187
9187
  static create(t, e, r) {
9188
9188
  const i = e.getNodeByUUID(t.uuid);
9189
- if (rt.is(i.content)) {
9189
+ if (it.is(i.content)) {
9190
9190
  const a = D.GroupStateNodeType.get(i.content.type), o = new a(i, e, r);
9191
- return o.isGroup = !0, o.children = t?.children?.map((n) => G.create(n, e, o)), o;
9191
+ return o.isGroup = !0, o.children = t?.children?.map((n) => K.create(n, e, o)), o;
9192
9192
  } else
9193
9193
  return new D(i, e, r);
9194
9194
  }
@@ -9208,12 +9208,12 @@ class D {
9208
9208
  this.parent.transferToNext(this.node.uuid);
9209
9209
  }
9210
9210
  }
9211
- class ue {
9211
+ class he {
9212
9212
  constructor(t, e) {
9213
- this.graph = e, this.root = G.create(t, this.graph);
9213
+ this.graph = e, this.root = K.create(t, this.graph);
9214
9214
  }
9215
9215
  static createInitialState(t) {
9216
- return G.createInitialState(t);
9216
+ return K.createInitialState(t);
9217
9217
  }
9218
9218
  isInteractionAvailable(t) {
9219
9219
  return this.root.isInteractionAvailable(t);
@@ -9225,7 +9225,7 @@ class ue {
9225
9225
  return this.root.toJSON();
9226
9226
  }
9227
9227
  }
9228
- class et {
9228
+ class rt {
9229
9229
  constructor(t, e) {
9230
9230
  this.activity = t, this.controller = e, this.uuidToNode = /* @__PURE__ */ new Map(), this.uuidToInteractionCall = /* @__PURE__ */ new Map(), this.interactionCallByName = /* @__PURE__ */ new Map(), this.rawToNode = /* @__PURE__ */ new Map(), this.checkUserRef = async (r, i, s) => (v(r.isRef, "attributive must be ref"), ((await this.getActivity(s))?.refs)[r.name] === i.id), this.system = e.system, this.graph = this.buildGraph(t);
9231
9231
  }
@@ -9234,8 +9234,8 @@ class et {
9234
9234
  }
9235
9235
  static {
9236
9236
  this.from = (t, e) => {
9237
- let r = et.cache.get(t);
9238
- return r || (r = new et(t, e), et.cache.set(t, r)), r;
9237
+ let r = rt.cache.get(t);
9238
+ return r || (r = new rt(t, e), rt.cache.set(t, r)), r;
9239
9239
  };
9240
9240
  }
9241
9241
  buildGraph(t, e) {
@@ -9243,7 +9243,7 @@ class et {
9243
9243
  for (let o of t.interactions) {
9244
9244
  const n = { content: o, next: null, uuid: o.uuid, parentGroup: e, parentSeq: i };
9245
9245
  this.uuidToNode.set(o.uuid, n), this.rawToNode.set(o, n);
9246
- const c = new Ee(o, this.controller, this);
9246
+ const c = new Ce(o, this.controller, this);
9247
9247
  this.uuidToInteractionCall.set(o.uuid, c), o.name && this.interactionCallByName.set(o.name, c);
9248
9248
  }
9249
9249
  for (let o of t.gateways) {
@@ -9263,7 +9263,7 @@ class et {
9263
9263
  const s = /* @__PURE__ */ new Set([...Object.values(t.interactions), ...Object.values(t.groups)]), a = /* @__PURE__ */ new Set([...Object.values(t.interactions), ...Object.values(t.groups)]);
9264
9264
  if (t.transfers?.forEach((o) => {
9265
9265
  const n = this.rawToNode.get(o.source) || r.get(o.source), c = this.rawToNode.get(o.target) || r.get(o.target);
9266
- v(!!n, `cannot find source ${o.source.name}`), v(!!c, `cannot find target ${o.source.name}`), it.is(n) ? n.next.push(c) : n.next = c, it.is(c) ? c.prev.push(n) : c.prev = n, a.delete(o.source), s.delete(o.target);
9266
+ v(!!n, `cannot find source ${o.source.name}`), v(!!c, `cannot find target ${o.source.name}`), st.is(n) ? n.next.push(c) : n.next = c, st.is(c) ? c.prev.push(n) : c.prev = n, a.delete(o.source), s.delete(o.target);
9267
9267
  }), s.size !== 1) throw new Error(`start node must one, current: ${s.size}`);
9268
9268
  if (a.size !== 1) throw new Error(`end node must be one, current: ${a.size}`);
9269
9269
  return Object.assign(i, {
@@ -9272,7 +9272,7 @@ class et {
9272
9272
  }), i;
9273
9273
  }
9274
9274
  async create() {
9275
- const t = ue.createInitialState(this.graph.head);
9275
+ const t = he.createInitialState(this.graph.head);
9276
9276
  return {
9277
9277
  activityId: (await this.controller.activityManager.createActivity({
9278
9278
  name: this.activity.name,
@@ -9319,7 +9319,7 @@ class et {
9319
9319
  return e.parentSeq.tail === e;
9320
9320
  }
9321
9321
  isActivityHead(t, e = this.graph.head) {
9322
- return rt.is(this.graph.head.content) ? !!this.graph.head.childSeqs?.some((r) => this.isActivityHead(t, r.head)) : t === this.graph.head.content;
9322
+ return it.is(this.graph.head.content) ? !!this.graph.head.childSeqs?.some((r) => this.isActivityHead(t, r.head)) : t === this.graph.head.content;
9323
9323
  }
9324
9324
  async callInteraction(t, e, r) {
9325
9325
  const i = this.uuidToInteractionCall.get(e);
@@ -9331,7 +9331,7 @@ class et {
9331
9331
  s = (await this.create()).activityId;
9332
9332
  }
9333
9333
  } else if (!t) return { error: "activityId must be provided for non-head interaction of an activity" };
9334
- const a = new ue(await this.getState(s), this);
9334
+ const a = new he(await this.getState(s), this);
9335
9335
  if (!a.isInteractionAvailable(e)) return { error: `interaction ${e} not available` };
9336
9336
  const o = await i.call(r, s, this.checkUserRef);
9337
9337
  if (o.error)
@@ -9352,14 +9352,14 @@ class et {
9352
9352
  async saveUserRefs(t, e, r) {
9353
9353
  const i = (await this.getActivity(t))?.refs || {};
9354
9354
  e.interaction.userRef?.name && (i[e.interaction.userRef?.name] = r.user.id), e.interaction.payload?.items.forEach((s) => {
9355
- if (X.is(s.itemRef) && s.itemRef?.name && r.payload[s.name]) {
9355
+ if (Y.is(s.itemRef) && s.itemRef?.name && r.payload[s.name]) {
9356
9356
  const a = r.payload[s.name];
9357
9357
  s.isCollection ? (i[s.itemRef.name] || (i[s.itemRef.name] = []), i[s.itemRef.name].push(a.id)) : i[s.itemRef.name] = a.id;
9358
9358
  }
9359
9359
  }), await this.setActivity(t, { refs: i });
9360
9360
  }
9361
9361
  }
9362
- class Xr extends D {
9362
+ class Zr extends D {
9363
9363
  onChange(t, e) {
9364
9364
  if (this.graph.isStartNode(t)) {
9365
9365
  if (e)
@@ -9370,25 +9370,25 @@ class Xr extends D {
9370
9370
  }
9371
9371
  }
9372
9372
  }
9373
- D.GroupStateNodeType.set("any", Xr);
9374
- class Yr extends D {
9373
+ D.GroupStateNodeType.set("any", Zr);
9374
+ class ti extends D {
9375
9375
  onChange(t, e) {
9376
9376
  this.isGroupCompleted() && this.complete();
9377
9377
  }
9378
9378
  }
9379
- D.GroupStateNodeType.set("every", Yr);
9380
- class zr extends D {
9379
+ D.GroupStateNodeType.set("every", ti);
9380
+ class ei extends D {
9381
9381
  onChange(t, e) {
9382
9382
  this.graph.isEndNode(t) && this.complete();
9383
9383
  }
9384
9384
  }
9385
- D.GroupStateNodeType.set("race", zr);
9386
- class Zr extends D {
9385
+ D.GroupStateNodeType.set("race", ei);
9386
+ class ri extends D {
9387
9387
  // 可以根据 group 上的具体配置逻辑,来动态决定。
9388
9388
  }
9389
- D.GroupStateNodeType.set("program", Zr);
9390
- const I = new fe(), Vt = "_Interaction_", Nt = "_Activity_", Ie = C.create({
9391
- name: Vt,
9389
+ D.GroupStateNodeType.set("program", ri);
9390
+ const I = new ye(), _t = "_Interaction_", St = "_Activity_", xe = C.create({
9391
+ name: _t,
9392
9392
  properties: [
9393
9393
  T.create({
9394
9394
  name: "interactionId",
@@ -9416,8 +9416,8 @@ const I = new fe(), Vt = "_Interaction_", Nt = "_Activity_", Ie = C.create({
9416
9416
  collection: !1
9417
9417
  })
9418
9418
  ]
9419
- }), Ce = C.create({
9420
- name: Nt,
9419
+ }), Me = C.create({
9420
+ name: St,
9421
9421
  properties: [
9422
9422
  T.create({
9423
9423
  name: "name",
@@ -9440,21 +9440,21 @@ const I = new fe(), Vt = "_Interaction_", Nt = "_Activity_", Ie = C.create({
9440
9440
  collection: !1
9441
9441
  })
9442
9442
  ]
9443
- }), ti = P.create({
9443
+ }), ii = P.create({
9444
9444
  name: "activityInteraction",
9445
- source: Ce,
9445
+ source: Me,
9446
9446
  sourceProperty: "interaction",
9447
- target: Ie,
9447
+ target: xe,
9448
9448
  targetProperty: "activity",
9449
9449
  type: "1:n"
9450
9450
  });
9451
- class ei {
9451
+ class si {
9452
9452
  constructor(t, e, r) {
9453
- this.controller = t, this.activityCalls = /* @__PURE__ */ new Map(), this.activityCallsByName = /* @__PURE__ */ new Map(), this.interactionCallsByName = /* @__PURE__ */ new Map(), this.interactionCalls = /* @__PURE__ */ new Map(), this.controller.entities.push(Ce, Ie), this.controller.relations.push(ti), e.forEach((i) => {
9454
- const s = new et(i, t);
9453
+ this.controller = t, this.activityCalls = /* @__PURE__ */ new Map(), this.activityCallsByName = /* @__PURE__ */ new Map(), this.interactionCallsByName = /* @__PURE__ */ new Map(), this.interactionCalls = /* @__PURE__ */ new Map(), this.controller.entities.push(Me, xe), this.controller.relations.push(ii), e.forEach((i) => {
9454
+ const s = new rt(i, t);
9455
9455
  this.activityCalls.set(i.uuid, s), i.name && (v(!this.activityCallsByName.has(i.name), `activity name ${i.name} is duplicated`), this.activityCallsByName.set(i.name, s));
9456
9456
  }), r.forEach((i) => {
9457
- const s = new Ee(i, t);
9457
+ const s = new Ce(i, t);
9458
9458
  this.interactionCalls.set(i.uuid, s), i.name && (v(!this.interactionCallsByName.has(i.name), `interaction name ${i.name} is duplicated`), this.interactionCallsByName.set(i.name, s));
9459
9459
  });
9460
9460
  }
@@ -9463,7 +9463,7 @@ class ei {
9463
9463
  try {
9464
9464
  const s = this.interactionCallsByName.get(t);
9465
9465
  if (!s)
9466
- throw new U(`Cannot find interaction for ${t}`, {
9466
+ throw new G(`Cannot find interaction for ${t}`, {
9467
9467
  interactionName: t,
9468
9468
  userId: e.user?.id,
9469
9469
  payload: e.payload,
@@ -9475,7 +9475,7 @@ class ei {
9475
9475
  o = await s.call(e);
9476
9476
  } catch (n) {
9477
9477
  a = n, o = {
9478
- error: new U("Interaction execution failed", {
9478
+ error: new G("Interaction execution failed", {
9479
9479
  interactionName: t,
9480
9480
  userId: e.user?.id,
9481
9481
  payload: e.payload,
@@ -9492,7 +9492,7 @@ class ei {
9492
9492
  }
9493
9493
  return o;
9494
9494
  } catch (s) {
9495
- throw new U("Unexpected error during interaction call", {
9495
+ throw new G("Unexpected error during interaction call", {
9496
9496
  interactionName: t,
9497
9497
  userId: e.user?.id,
9498
9498
  payload: e.payload,
@@ -9506,7 +9506,7 @@ class ei {
9506
9506
  try {
9507
9507
  const o = this.activityCallsByName.get(t);
9508
9508
  if (!o)
9509
- throw new ce(`Cannot find activity for ${t}`, {
9509
+ throw new ue(`Cannot find activity for ${t}`, {
9510
9510
  activityName: t,
9511
9511
  context: {
9512
9512
  interactionName: e,
@@ -9517,7 +9517,7 @@ class ei {
9517
9517
  a.info({ label: "activity", message: o.activity.name }), await this.controller.system.storage.beginTransaction(o.activity.name);
9518
9518
  const n = o.interactionCallByName.get(e);
9519
9519
  if (!n) {
9520
- const l = new U(`Cannot find interaction ${e} in activity ${t}`, {
9520
+ const l = new G(`Cannot find interaction ${e} in activity ${t}`, {
9521
9521
  interactionName: e,
9522
9522
  userId: i.user?.id,
9523
9523
  payload: i.payload,
@@ -9529,7 +9529,7 @@ class ei {
9529
9529
  const c = await o.callInteraction(r, n.interaction.uuid, i);
9530
9530
  return c.error ? (a.error({ label: "activity", message: o.activity.name }), await this.controller.system.storage.rollbackTransaction(o.activity.name)) : (await this.controller.system.storage.commitTransaction(o.activity.name), await this.runRecordChangeSideEffects(c, a)), c;
9531
9531
  } catch (o) {
9532
- throw new ce("Unexpected error during activity interaction call", {
9532
+ throw new ue("Unexpected error during activity interaction call", {
9533
9533
  activityName: t,
9534
9534
  context: {
9535
9535
  interactionName: e,
@@ -9548,7 +9548,7 @@ class ei {
9548
9548
  t.sideEffects || (t.sideEffects = {});
9549
9549
  for (let a of s)
9550
9550
  try {
9551
- if (a instanceof K)
9551
+ if (a instanceof X)
9552
9552
  t.sideEffects[a.name] = {
9553
9553
  result: await a.content(i)
9554
9554
  };
@@ -9560,7 +9560,7 @@ class ei {
9560
9560
  }
9561
9561
  } catch (o) {
9562
9562
  let n = "unknown";
9563
- a instanceof K ? n = a.name : n = a.name || "unknown", e.error({ label: "recordMutationSideEffect", message: n }), t.sideEffects[n] = {
9563
+ a instanceof X ? n = a.name : n = a.name || "unknown", e.error({ label: "recordMutationSideEffect", message: n }), t.sideEffects[n] = {
9564
9564
  error: o
9565
9565
  };
9566
9566
  }
@@ -9568,7 +9568,7 @@ class ei {
9568
9568
  }
9569
9569
  }
9570
9570
  async createActivity(t) {
9571
- return this.controller.system.storage.create(Nt, {
9571
+ return this.controller.system.storage.create(St, {
9572
9572
  ...t,
9573
9573
  state: t.state,
9574
9574
  refs: t.refs
@@ -9578,20 +9578,20 @@ class ei {
9578
9578
  const r = {
9579
9579
  ...e
9580
9580
  };
9581
- return delete r.state, delete r.refs, e.state && (r.state = e.state), e.refs && (r.refs = e.refs), this.controller.system.storage.update(Nt, t, r);
9581
+ return delete r.state, delete r.refs, e.state && (r.state = e.state), e.refs && (r.refs = e.refs), this.controller.system.storage.update(St, t, r);
9582
9582
  }
9583
9583
  async getActivity(t) {
9584
- return (await this.controller.system.storage.find(Nt, t, void 0, ["*"])).map((e) => ({
9584
+ return (await this.controller.system.storage.find(St, t, void 0, ["*"])).map((e) => ({
9585
9585
  ...e,
9586
9586
  state: e.state,
9587
9587
  refs: e.refs
9588
9588
  }));
9589
9589
  }
9590
9590
  async saveEvent(t) {
9591
- return this.controller.system.storage.create(Vt, t);
9591
+ return this.controller.system.storage.create(_t, t);
9592
9592
  }
9593
9593
  async getEvent(t) {
9594
- return (await this.controller.system.storage.find(Vt, t, void 0, ["*"])).map((e) => ({
9594
+ return (await this.controller.system.storage.find(_t, t, void 0, ["*"])).map((e) => ({
9595
9595
  ...e
9596
9596
  }));
9597
9597
  }
@@ -9608,32 +9608,32 @@ class ei {
9608
9608
  return this.interactionCallsByName.get(t);
9609
9609
  }
9610
9610
  }
9611
- const At = new fe();
9612
- function ri() {
9613
- return At.getStore()?.effects;
9611
+ const It = new ye();
9612
+ function ai() {
9613
+ return It.getStore()?.effects;
9614
9614
  }
9615
- function de(u) {
9616
- const t = At.getStore();
9615
+ function pe(u) {
9616
+ const t = It.getStore();
9617
9617
  t?.effects && t.effects.push(...u);
9618
9618
  }
9619
- const _i = "User";
9620
- class K {
9619
+ const Gi = "User";
9620
+ class X {
9621
9621
  constructor(t) {
9622
9622
  this.name = t.name, this.record = t.record, this.content = t.content;
9623
9623
  }
9624
9624
  static create(t) {
9625
- return new K(t);
9625
+ return new X(t);
9626
9626
  }
9627
9627
  }
9628
- const Lt = "_isDeleted_", qi = {
9628
+ const qt = "_isDeleted_", Ki = {
9629
9629
  create() {
9630
9630
  return T.create({
9631
- name: Lt,
9631
+ name: qt,
9632
9632
  type: "boolean"
9633
9633
  });
9634
9634
  }
9635
9635
  };
9636
- class Bi {
9636
+ class Xi {
9637
9637
  constructor(t) {
9638
9638
  this.recordNameToSideEffects = /* @__PURE__ */ new Map(), this.globals = {
9639
9639
  BoolExp: R,
@@ -9652,21 +9652,21 @@ class Bi {
9652
9652
  forceThtrowInteractionError: d = !1
9653
9653
  // 会 catch 住 error,并在 result 中返回。
9654
9654
  } = t;
9655
- this.system = e, this.ignorePermission = l, this.forceThtrowInteractionError = d, this.entities = [...r], this.relations = [...i], this.activities = [...s], this.interactions = [...a], this.dict = [...o], this.recordMutationSideEffects = [...n], this.activityManager = new ei(this, s, a);
9655
+ this.system = e, this.ignorePermission = l, this.forceThtrowInteractionError = d, this.entities = [...r], this.relations = [...i], this.activities = [...s], this.interactions = [...a], this.dict = [...o], this.recordMutationSideEffects = [...n], this.activityManager = new si(this, s, a);
9656
9656
  const h = [
9657
+ ...Or,
9658
+ ...Vr,
9657
9659
  ...$r,
9658
- ...Dr,
9659
9660
  ...Cr,
9660
9661
  ...Ar,
9661
- ...Sr,
9662
- ..._r,
9663
9662
  ...Wr,
9664
- ...Qr,
9665
- ...wr,
9666
- ...Gr,
9663
+ ...Ur,
9664
+ ..._r,
9665
+ ...Sr,
9666
+ ...Yr,
9667
9667
  ...c
9668
9668
  ];
9669
- this.scheduler = new Kr(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
9669
+ this.scheduler = new zr(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
9670
9670
  let y = this.recordNameToSideEffects.get(p.record.name);
9671
9671
  y || this.recordNameToSideEffects.set(p.record.name, y = /* @__PURE__ */ new Set()), y.add(p);
9672
9672
  });
@@ -9686,7 +9686,7 @@ class Bi {
9686
9686
  }
9687
9687
  }
9688
9688
  async applyResult(t, e, r) {
9689
- if (!(e instanceof vt)) {
9689
+ if (!(e instanceof At)) {
9690
9690
  if (t.type === "global")
9691
9691
  return this.system.storage.dict.set(t.id.name, e);
9692
9692
  if (t.type === "entity") {
@@ -9705,12 +9705,12 @@ class Bi {
9705
9705
  await this.system.storage.create(i.id.name, a);
9706
9706
  } else {
9707
9707
  const i = t;
9708
- i.id.name === Lt && e ? await this.system.storage.delete(i.host.name, R.atom({ key: "id", value: ["=", r.id] })) : await this.system.storage.update(i.host.name, R.atom({ key: "id", value: ["=", r.id] }), { [i.id.name]: e });
9708
+ i.id.name === qt && e ? await this.system.storage.delete(i.host.name, R.atom({ key: "id", value: ["=", r.id] })) : await this.system.storage.update(i.host.name, R.atom({ key: "id", value: ["=", r.id] }), { [i.id.name]: e });
9709
9709
  }
9710
9710
  }
9711
9711
  }
9712
9712
  async applyResultPatch(t, e, r) {
9713
- if (e instanceof vt || e === void 0) return;
9713
+ if (e instanceof At || e === void 0) return;
9714
9714
  const i = Array.isArray(e) ? e : [e];
9715
9715
  for (const s of i) {
9716
9716
  if (t.type === "global")
@@ -9728,18 +9728,18 @@ class Bi {
9728
9728
  }
9729
9729
  } else {
9730
9730
  const a = t;
9731
- a.id.name === Lt && s.data ? (v(s.type !== "delete", "Hard deletion property cannot be deleted"), await this.system.storage.delete(a.host.name, R.atom({ key: "id", value: ["=", r.id] }))) : s.type === "insert" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", r.id] }), { [a.id.name]: s.data }) : s.type === "update" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", r.id] }), { [a.id.name]: s.data }) : s.type === "delete" && await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", r.id] }), { [a.id.name]: null });
9731
+ a.id.name === qt && s.data ? (v(s.type !== "delete", "Hard deletion property cannot be deleted"), await this.system.storage.delete(a.host.name, R.atom({ key: "id", value: ["=", r.id] }))) : s.type === "insert" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", r.id] }), { [a.id.name]: s.data }) : s.type === "update" ? await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", r.id] }), { [a.id.name]: s.data }) : s.type === "delete" && await this.system.storage.update(a.host.name, R.atom({ key: "id", value: ["=", r.id] }), { [a.id.name]: null });
9732
9732
  }
9733
9733
  }
9734
9734
  }
9735
9735
  async callInteraction(t, e) {
9736
9736
  try {
9737
- const r = { effects: [] }, i = await At.run(r, async () => await this.activityManager.callInteraction(t, e));
9737
+ const r = { effects: [] }, i = await It.run(r, async () => await this.activityManager.callInteraction(t, e));
9738
9738
  if (i.effects = r.effects, i.error && this.forceThtrowInteractionError)
9739
9739
  throw i.error;
9740
9740
  return i;
9741
9741
  } catch (r) {
9742
- throw new U("Failed to call interaction", {
9742
+ throw new G("Failed to call interaction", {
9743
9743
  interactionName: t,
9744
9744
  userId: e.user?.id,
9745
9745
  payload: e.payload,
@@ -9750,7 +9750,7 @@ class Bi {
9750
9750
  }
9751
9751
  async callActivityInteraction(t, e, r, i) {
9752
9752
  try {
9753
- const s = { effects: [] }, a = await At.run(s, async () => await this.activityManager.callActivityInteraction(t, e, r, i));
9753
+ const s = { effects: [] }, a = await It.run(s, async () => await this.activityManager.callActivityInteraction(t, e, r, i));
9754
9754
  if (a.effects && s.effects.length > 0) {
9755
9755
  const o = s.effects.filter(
9756
9756
  (n) => !a.effects.some(
@@ -9763,7 +9763,7 @@ class Bi {
9763
9763
  throw a.error;
9764
9764
  return a;
9765
9765
  } catch (s) {
9766
- throw new U("Failed to call activity interaction", {
9766
+ throw new G("Failed to call activity interaction", {
9767
9767
  interactionName: e,
9768
9768
  userId: i.user?.id,
9769
9769
  payload: i.payload,
@@ -9780,7 +9780,7 @@ class Bi {
9780
9780
  if (s)
9781
9781
  for (let a of s)
9782
9782
  try {
9783
- if (a instanceof K)
9783
+ if (a instanceof X)
9784
9784
  t.sideEffects[a.name] = {
9785
9785
  result: await a.content(i)
9786
9786
  };
@@ -9792,7 +9792,7 @@ class Bi {
9792
9792
  }
9793
9793
  } catch (o) {
9794
9794
  let n = "unknown";
9795
- a instanceof K ? n = a.name : n = a.name || "unknown", e.error({ label: "recordMutationSideEffect", message: n }), t.sideEffects[n] = {
9795
+ a instanceof X ? n = a.name : n = a.name || "unknown", e.error({ label: "recordMutationSideEffect", message: n }), t.sideEffects[n] = {
9796
9796
  error: o
9797
9797
  };
9798
9798
  }
@@ -9803,7 +9803,7 @@ class Bi {
9803
9803
  this.callbacks.has(t) || this.callbacks.set(t, /* @__PURE__ */ new Set()), this.callbacks.get(t).add(e);
9804
9804
  }
9805
9805
  }
9806
- let ii = class {
9806
+ let oi = class {
9807
9807
  constructor(t) {
9808
9808
  this.db = t;
9809
9809
  }
@@ -9815,12 +9815,12 @@ let ii = class {
9815
9815
  return e === void 0 ? await this.db.scheme(`INSERT INTO _IDS_ (name, last) VALUES ('${t}', ${r})`, i) : await this.db.update("UPDATE _IDS_ SET last = ? WHERE name = ?", [r, t], void 0, i), r;
9816
9816
  }
9817
9817
  };
9818
- class si {
9818
+ class ni {
9819
9819
  constructor(t = ":memory:", e) {
9820
- this.file = t, this.options = e, this.idSystem = new ii(this), this.logger = this.options?.logger || bt;
9820
+ this.file = t, this.options = e, this.idSystem = new oi(this), this.logger = this.options?.logger || Rt;
9821
9821
  }
9822
9822
  async open() {
9823
- this.db = new $e(this.file, this.options), await this.idSystem.setup();
9823
+ this.db = new Oe(this.file, this.options), await this.idSystem.setup();
9824
9824
  }
9825
9825
  async query(t, e = [], r = "") {
9826
9826
  const i = I.getStore(), s = this.logger.child(i?.logContext || {}), a = e.map((o) => o === !1 ? 0 : o === !0 ? 1 : o);
@@ -9847,7 +9847,7 @@ class si {
9847
9847
  name: r,
9848
9848
  sql: t,
9849
9849
  params: a
9850
- }), this.db.prepare(`${t} RETURNING ${at}`).run(...a);
9850
+ }), this.db.prepare(`${t} RETURNING ${ot}`).run(...a);
9851
9851
  }
9852
9852
  async delete(t, e, r = "") {
9853
9853
  const i = I.getStore(), s = this.logger.child(i?.logContext || {}), a = e.map((o) => o === !1 ? 0 : o === !0 ? 1 : o);
@@ -9887,13 +9887,13 @@ class si {
9887
9887
  return t === "pk" ? "INTEGER PRIMARY KEY" : t === "id" ? "INT" : e || t === "object" || t === "json" ? "JSON" : t === "string" ? "TEXT" : t === "boolean" ? "INT(2)" : t === "number" || t === "timestamp" ? "INT" : t;
9888
9888
  }
9889
9889
  }
9890
- function ai(u) {
9890
+ function ci(u) {
9891
9891
  return encodeURI(JSON.stringify(u));
9892
9892
  }
9893
- function oi(u) {
9893
+ function li(u) {
9894
9894
  return u === void 0 ? void 0 : JSON.parse(decodeURI(u));
9895
9895
  }
9896
- class ni {
9896
+ class ui {
9897
9897
  constructor(t) {
9898
9898
  this.db = t, this.callbacks = /* @__PURE__ */ new Set(), this.dict = {
9899
9899
  get: async (e) => {
@@ -9917,21 +9917,21 @@ class ni {
9917
9917
  }
9918
9918
  // CAUTION kv 结构数据的实现也用 er。这是系统约定,因为也需要 Record 事件!
9919
9919
  async get(t, e, r) {
9920
- const i = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] }), s = (await this.queryHandle.findOne(tt, i, void 0, ["value"]))?.value;
9921
- return s === void 0 ? r : oi(s);
9920
+ const i = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] }), s = (await this.queryHandle.findOne(et, i, void 0, ["value"]))?.value;
9921
+ return s === void 0 ? r : li(s);
9922
9922
  }
9923
9923
  async set(t, e, r, i) {
9924
9924
  const s = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] });
9925
- return await this.queryHandle.findOne(tt, s, void 0, ["value"]) ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [tt, s, { concept: t, key: e.toString(), value: ai(r) }], i) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [tt, { concept: t, key: e.toString(), value: encodeURI(JSON.stringify(r)) }], i);
9925
+ return await this.queryHandle.findOne(et, s, void 0, ["value"]) ? this.callWithEvents(this.queryHandle.update.bind(this.queryHandle), [et, s, { concept: t, key: e.toString(), value: ci(r) }], i) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [et, { concept: t, key: e.toString(), value: encodeURI(JSON.stringify(r)) }], i);
9926
9926
  }
9927
9927
  async setup(t, e, r = !1) {
9928
9928
  await this.db.open(r);
9929
- const i = new hr(
9929
+ const i = new mr(
9930
9930
  t,
9931
9931
  e,
9932
9932
  this.db
9933
9933
  );
9934
- r && await i.createTables(), this.queryHandle = new ze(new Ze(i.map), this.db), this.map = i.map;
9934
+ r && await i.createTables(), this.queryHandle = new er(new rr(i.map), this.db), this.map = i.map;
9935
9935
  }
9936
9936
  findOne(...t) {
9937
9937
  return this.queryHandle.findOne(...t);
@@ -9951,8 +9951,8 @@ class ni {
9951
9951
  async callWithEvents(t, e, r = []) {
9952
9952
  const i = [], s = await t(...e, i), a = await this.dispatch(i);
9953
9953
  r.push(...i, ...a);
9954
- const o = ri();
9955
- return o && i.length > 0 && de(i), o && a.length > 0 && de(a), s;
9954
+ const o = ai();
9955
+ return o && i.length > 0 && pe(i), o && a.length > 0 && pe(a), s;
9956
9956
  }
9957
9957
  findRelationByName(...t) {
9958
9958
  return this.queryHandle.findRelationByName(...t);
@@ -9990,8 +9990,8 @@ class ni {
9990
9990
  return this.db.close();
9991
9991
  }
9992
9992
  }
9993
- var ci = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(ci || {});
9994
- class ee {
9993
+ var di = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(di || {});
9994
+ class ie {
9995
9995
  constructor(t = 0) {
9996
9996
  this.level = t;
9997
9997
  }
@@ -10002,11 +10002,11 @@ class ee {
10002
10002
  this.level >= 0 && console.error({ type: t, name: e, sql: r, params: i, error: s });
10003
10003
  }
10004
10004
  child() {
10005
- return new ee(this.level);
10005
+ return new ie(this.level);
10006
10006
  }
10007
10007
  }
10008
- var li = /* @__PURE__ */ ((u) => (u[u.MUTE = -1] = "MUTE", u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u[u.DEBUG = 2] = "DEBUG", u))(li || {});
10009
- class re {
10008
+ var hi = /* @__PURE__ */ ((u) => (u[u.MUTE = -1] = "MUTE", u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u[u.DEBUG = 2] = "DEBUG", u))(hi || {});
10009
+ class se {
10010
10010
  constructor(t = 0) {
10011
10011
  this.level = t;
10012
10012
  }
@@ -10020,16 +10020,16 @@ class re {
10020
10020
  this.level >= 2 && console.debug(`[DEBUG] ${t}: ${e}`, r);
10021
10021
  }
10022
10022
  child(t) {
10023
- return new re(this.level);
10023
+ return new se(this.level);
10024
10024
  }
10025
10025
  }
10026
- const bt = new ee(), ui = new re();
10027
- class Ji {
10028
- constructor(t = new si(void 0, { logger: bt }), e = ui) {
10029
- this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new ni(t);
10026
+ const Rt = new ie(), pi = new se();
10027
+ class zi {
10028
+ constructor(t = new ni(void 0, { logger: Rt }), e = pi) {
10029
+ this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new ui(t);
10030
10030
  }
10031
10031
  setup(t, e, r, i = !1) {
10032
- const s = new Ne(t, e), { entities: a, relations: o } = s.getAll();
10032
+ const s = new Se(t, e), { entities: a, relations: o } = s.getAll();
10033
10033
  return r.forEach(({ dataContext: n, state: c }) => {
10034
10034
  Object.entries(c).forEach(([l, d]) => {
10035
10035
  if (d instanceof E) {
@@ -10055,7 +10055,7 @@ class Ji {
10055
10055
  }
10056
10056
  });
10057
10057
  }), this.storage.setup(
10058
- [...a, fr, pr],
10058
+ [...a, gr, yr],
10059
10059
  o,
10060
10060
  i
10061
10061
  );
@@ -10064,8 +10064,8 @@ class Ji {
10064
10064
  this.storage.destroy();
10065
10065
  }
10066
10066
  }
10067
- const { Client: he } = Pe;
10068
- let di = class {
10067
+ const { Client: fe } = Fe;
10068
+ let fi = class {
10069
10069
  constructor(t) {
10070
10070
  this.db = t;
10071
10071
  }
@@ -10077,14 +10077,14 @@ let di = class {
10077
10077
  return e === void 0 ? await this.db.scheme(`INSERT INTO "_IDS_" (name, last) VALUES ('${t}', ${r})`, i) : await this.db.update('UPDATE "_IDS_" SET last = $1 WHERE name = $2', [r, t], void 0, i), r;
10078
10078
  }
10079
10079
  };
10080
- class ji {
10080
+ class ts {
10081
10081
  constructor(t, e = {}) {
10082
- this.database = t, this.options = e, this.idSystem = new di(this), this.logger = this.options?.logger || bt, this.db = new he({
10082
+ this.database = t, this.options = e, this.idSystem = new fi(this), this.logger = this.options?.logger || Rt, this.db = new fe({
10083
10083
  ...e
10084
10084
  });
10085
10085
  }
10086
10086
  async open(t = !1) {
10087
- await this.db.connect(), (await this.db.query(`SELECT FROM pg_database WHERE datname = '${this.database}'`)).rows.length === 0 ? await this.db.query(`CREATE DATABASE ${this.database}`) : (t && (await this.db.query(`DROP DATABASE ${this.database}`), await this.db.query(`CREATE DATABASE ${this.database}`)), this.db = new he({
10087
+ await this.db.connect(), (await this.db.query(`SELECT FROM pg_database WHERE datname = '${this.database}'`)).rows.length === 0 ? await this.db.query(`CREATE DATABASE ${this.database}`) : (t && (await this.db.query(`DROP DATABASE ${this.database}`), await this.db.query(`CREATE DATABASE ${this.database}`)), this.db = new fe({
10088
10088
  ...this.options,
10089
10089
  database: this.database
10090
10090
  }), await this.db.connect()), await this.idSystem.setup();
@@ -10115,7 +10115,7 @@ class ji {
10115
10115
  sql: t,
10116
10116
  params: a
10117
10117
  });
10118
- const o = `${t} RETURNING "${at}"`;
10118
+ const o = `${t} RETURNING "${ot}"`;
10119
10119
  return (await this.db.query(o, a)).rows[0];
10120
10120
  }
10121
10121
  async delete(t, e, r = "") {
@@ -10158,7 +10158,279 @@ class ji {
10158
10158
  return t === "pk" ? "INT GENERATED ALWAYS AS IDENTITY" : t === "id" ? "INT" : e || t === "object" ? "JSON" : t === "string" ? "TEXT" : t === "boolean" ? "BOOLEAN" : t === "number" ? "INT" : t === "timestamp" ? "TIMESTAMP" : t;
10159
10159
  }
10160
10160
  }
10161
- let hi = class {
10161
+ /**
10162
+ * uuidv7: A JavaScript implementation of UUID version 7
10163
+ *
10164
+ * Copyright 2021-2024 LiosK
10165
+ *
10166
+ * @license Apache-2.0
10167
+ * @packageDocumentation
10168
+ */
10169
+ const Nt = "0123456789abcdef";
10170
+ class U {
10171
+ /** @param bytes - The 16-byte byte array representation. */
10172
+ constructor(t) {
10173
+ this.bytes = t;
10174
+ }
10175
+ /**
10176
+ * Creates an object from the internal representation, a 16-byte byte array
10177
+ * containing the binary UUID representation in the big-endian byte order.
10178
+ *
10179
+ * This method does NOT shallow-copy the argument, and thus the created object
10180
+ * holds the reference to the underlying buffer.
10181
+ *
10182
+ * @throws TypeError if the length of the argument is not 16.
10183
+ */
10184
+ static ofInner(t) {
10185
+ if (t.length !== 16)
10186
+ throw new TypeError("not 128-bit length");
10187
+ return new U(t);
10188
+ }
10189
+ /**
10190
+ * Builds a byte array from UUIDv7 field values.
10191
+ *
10192
+ * @param unixTsMs - A 48-bit `unix_ts_ms` field value.
10193
+ * @param randA - A 12-bit `rand_a` field value.
10194
+ * @param randBHi - The higher 30 bits of 62-bit `rand_b` field value.
10195
+ * @param randBLo - The lower 32 bits of 62-bit `rand_b` field value.
10196
+ * @throws RangeError if any field value is out of the specified range.
10197
+ */
10198
+ static fromFieldsV7(t, e, r, i) {
10199
+ if (!Number.isInteger(t) || !Number.isInteger(e) || !Number.isInteger(r) || !Number.isInteger(i) || t < 0 || e < 0 || r < 0 || i < 0 || t > 281474976710655 || e > 4095 || r > 1073741823 || i > 4294967295)
10200
+ throw new RangeError("invalid field value");
10201
+ const s = new Uint8Array(16);
10202
+ return s[0] = t / 2 ** 40, s[1] = t / 2 ** 32, s[2] = t / 2 ** 24, s[3] = t / 2 ** 16, s[4] = t / 2 ** 8, s[5] = t, s[6] = 112 | e >>> 8, s[7] = e, s[8] = 128 | r >>> 24, s[9] = r >>> 16, s[10] = r >>> 8, s[11] = r, s[12] = i >>> 24, s[13] = i >>> 16, s[14] = i >>> 8, s[15] = i, new U(s);
10203
+ }
10204
+ /**
10205
+ * Builds a byte array from a string representation.
10206
+ *
10207
+ * This method accepts the following formats:
10208
+ *
10209
+ * - 32-digit hexadecimal format without hyphens: `0189dcd553117d408db09496a2eef37b`
10210
+ * - 8-4-4-4-12 hyphenated format: `0189dcd5-5311-7d40-8db0-9496a2eef37b`
10211
+ * - Hyphenated format with surrounding braces: `{0189dcd5-5311-7d40-8db0-9496a2eef37b}`
10212
+ * - RFC 9562 URN format: `urn:uuid:0189dcd5-5311-7d40-8db0-9496a2eef37b`
10213
+ *
10214
+ * Leading and trailing whitespaces represents an error.
10215
+ *
10216
+ * @throws SyntaxError if the argument could not parse as a valid UUID string.
10217
+ */
10218
+ static parse(t) {
10219
+ var e, r, i, s;
10220
+ let a;
10221
+ switch (t.length) {
10222
+ case 32:
10223
+ a = (e = /^[0-9a-f]{32}$/i.exec(t)) === null || e === void 0 ? void 0 : e[0];
10224
+ break;
10225
+ case 36:
10226
+ a = (r = /^([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)) === null || r === void 0 ? void 0 : r.slice(1, 6).join("");
10227
+ break;
10228
+ case 38:
10229
+ a = (i = /^\{([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})\}$/i.exec(t)) === null || i === void 0 ? void 0 : i.slice(1, 6).join("");
10230
+ break;
10231
+ case 45:
10232
+ a = (s = /^urn:uuid:([0-9a-f]{8})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{4})-([0-9a-f]{12})$/i.exec(t)) === null || s === void 0 ? void 0 : s.slice(1, 6).join("");
10233
+ break;
10234
+ }
10235
+ if (a) {
10236
+ const o = new Uint8Array(16);
10237
+ for (let n = 0; n < 16; n += 4) {
10238
+ const c = parseInt(a.substring(2 * n, 2 * n + 8), 16);
10239
+ o[n + 0] = c >>> 24, o[n + 1] = c >>> 16, o[n + 2] = c >>> 8, o[n + 3] = c;
10240
+ }
10241
+ return new U(o);
10242
+ } else
10243
+ throw new SyntaxError("could not parse UUID string");
10244
+ }
10245
+ /**
10246
+ * @returns The 8-4-4-4-12 canonical hexadecimal string representation
10247
+ * (`0189dcd5-5311-7d40-8db0-9496a2eef37b`).
10248
+ */
10249
+ toString() {
10250
+ let t = "";
10251
+ for (let e = 0; e < this.bytes.length; e++)
10252
+ t += Nt.charAt(this.bytes[e] >>> 4), t += Nt.charAt(this.bytes[e] & 15), (e === 3 || e === 5 || e === 7 || e === 9) && (t += "-");
10253
+ return t;
10254
+ }
10255
+ /**
10256
+ * @returns The 32-digit hexadecimal representation without hyphens
10257
+ * (`0189dcd553117d408db09496a2eef37b`).
10258
+ */
10259
+ toHex() {
10260
+ let t = "";
10261
+ for (let e = 0; e < this.bytes.length; e++)
10262
+ t += Nt.charAt(this.bytes[e] >>> 4), t += Nt.charAt(this.bytes[e] & 15);
10263
+ return t;
10264
+ }
10265
+ /** @returns The 8-4-4-4-12 canonical hexadecimal string representation. */
10266
+ toJSON() {
10267
+ return this.toString();
10268
+ }
10269
+ /**
10270
+ * Reports the variant field value of the UUID or, if appropriate, "NIL" or
10271
+ * "MAX".
10272
+ *
10273
+ * For convenience, this method reports "NIL" or "MAX" if `this` represents
10274
+ * the Nil or Max UUID, although the Nil and Max UUIDs are technically
10275
+ * subsumed under the variants `0b0` and `0b111`, respectively.
10276
+ */
10277
+ getVariant() {
10278
+ const t = this.bytes[8] >>> 4;
10279
+ if (t < 0)
10280
+ throw new Error("unreachable");
10281
+ if (t <= 7)
10282
+ return this.bytes.every((e) => e === 0) ? "NIL" : "VAR_0";
10283
+ if (t <= 11)
10284
+ return "VAR_10";
10285
+ if (t <= 13)
10286
+ return "VAR_110";
10287
+ if (t <= 15)
10288
+ return this.bytes.every((e) => e === 255) ? "MAX" : "VAR_RESERVED";
10289
+ throw new Error("unreachable");
10290
+ }
10291
+ /**
10292
+ * Returns the version field value of the UUID or `undefined` if the UUID does
10293
+ * not have the variant field value of `0b10`.
10294
+ */
10295
+ getVersion() {
10296
+ return this.getVariant() === "VAR_10" ? this.bytes[6] >>> 4 : void 0;
10297
+ }
10298
+ /** Creates an object from `this`. */
10299
+ clone() {
10300
+ return new U(this.bytes.slice(0));
10301
+ }
10302
+ /** Returns true if `this` is equivalent to `other`. */
10303
+ equals(t) {
10304
+ return this.compareTo(t) === 0;
10305
+ }
10306
+ /**
10307
+ * Returns a negative integer, zero, or positive integer if `this` is less
10308
+ * than, equal to, or greater than `other`, respectively.
10309
+ */
10310
+ compareTo(t) {
10311
+ for (let e = 0; e < 16; e++) {
10312
+ const r = this.bytes[e] - t.bytes[e];
10313
+ if (r !== 0)
10314
+ return Math.sign(r);
10315
+ }
10316
+ return 0;
10317
+ }
10318
+ }
10319
+ class mi {
10320
+ /**
10321
+ * Creates a generator object with the default random number generator, or
10322
+ * with the specified one if passed as an argument. The specified random
10323
+ * number generator should be cryptographically strong and securely seeded.
10324
+ */
10325
+ constructor(t) {
10326
+ this.timestamp = 0, this.counter = 0, this.random = t ?? yi();
10327
+ }
10328
+ /**
10329
+ * Generates a new UUIDv7 object from the current timestamp, or resets the
10330
+ * generator upon significant timestamp rollback.
10331
+ *
10332
+ * This method returns a monotonically increasing UUID by reusing the previous
10333
+ * timestamp even if the up-to-date timestamp is smaller than the immediately
10334
+ * preceding UUID's. However, when such a clock rollback is considered
10335
+ * significant (i.e., by more than ten seconds), this method resets the
10336
+ * generator and returns a new UUID based on the given timestamp, breaking the
10337
+ * increasing order of UUIDs.
10338
+ *
10339
+ * See {@link generateOrAbort} for the other mode of generation and
10340
+ * {@link generateOrResetCore} for the low-level primitive.
10341
+ */
10342
+ generate() {
10343
+ return this.generateOrResetCore(Date.now(), 1e4);
10344
+ }
10345
+ /**
10346
+ * Generates a new UUIDv7 object from the current timestamp, or returns
10347
+ * `undefined` upon significant timestamp rollback.
10348
+ *
10349
+ * This method returns a monotonically increasing UUID by reusing the previous
10350
+ * timestamp even if the up-to-date timestamp is smaller than the immediately
10351
+ * preceding UUID's. However, when such a clock rollback is considered
10352
+ * significant (i.e., by more than ten seconds), this method aborts and
10353
+ * returns `undefined` immediately.
10354
+ *
10355
+ * See {@link generate} for the other mode of generation and
10356
+ * {@link generateOrAbortCore} for the low-level primitive.
10357
+ */
10358
+ generateOrAbort() {
10359
+ return this.generateOrAbortCore(Date.now(), 1e4);
10360
+ }
10361
+ /**
10362
+ * Generates a new UUIDv7 object from the `unixTsMs` passed, or resets the
10363
+ * generator upon significant timestamp rollback.
10364
+ *
10365
+ * This method is equivalent to {@link generate} except that it takes a custom
10366
+ * timestamp and clock rollback allowance.
10367
+ *
10368
+ * @param rollbackAllowance - The amount of `unixTsMs` rollback that is
10369
+ * considered significant. A suggested value is `10_000` (milliseconds).
10370
+ * @throws RangeError if `unixTsMs` is not a 48-bit positive integer.
10371
+ */
10372
+ generateOrResetCore(t, e) {
10373
+ let r = this.generateOrAbortCore(t, e);
10374
+ return r === void 0 && (this.timestamp = 0, r = this.generateOrAbortCore(t, e)), r;
10375
+ }
10376
+ /**
10377
+ * Generates a new UUIDv7 object from the `unixTsMs` passed, or returns
10378
+ * `undefined` upon significant timestamp rollback.
10379
+ *
10380
+ * This method is equivalent to {@link generateOrAbort} except that it takes a
10381
+ * custom timestamp and clock rollback allowance.
10382
+ *
10383
+ * @param rollbackAllowance - The amount of `unixTsMs` rollback that is
10384
+ * considered significant. A suggested value is `10_000` (milliseconds).
10385
+ * @throws RangeError if `unixTsMs` is not a 48-bit positive integer.
10386
+ */
10387
+ generateOrAbortCore(t, e) {
10388
+ if (!Number.isInteger(t) || t < 0 || t > 281474976710655)
10389
+ throw new RangeError("`unixTsMs` must be a 48-bit positive integer");
10390
+ if (e < 0 || e > 281474976710655)
10391
+ throw new RangeError("`rollbackAllowance` out of reasonable range");
10392
+ if (t > this.timestamp)
10393
+ this.timestamp = t, this.resetCounter();
10394
+ else if (t + e >= this.timestamp)
10395
+ this.counter++, this.counter > 4398046511103 && (this.timestamp++, this.resetCounter());
10396
+ else
10397
+ return;
10398
+ return U.fromFieldsV7(this.timestamp, Math.trunc(this.counter / 2 ** 30), this.counter & 2 ** 30 - 1, this.random.nextUint32());
10399
+ }
10400
+ /** Initializes the counter at a 42-bit random integer. */
10401
+ resetCounter() {
10402
+ this.counter = this.random.nextUint32() * 1024 + (this.random.nextUint32() & 1023);
10403
+ }
10404
+ /**
10405
+ * Generates a new UUIDv4 object utilizing the random number generator inside.
10406
+ *
10407
+ * @internal
10408
+ */
10409
+ generateV4() {
10410
+ const t = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
10411
+ return t[6] = 64 | t[6] >>> 4, t[8] = 128 | t[8] >>> 2, U.ofInner(t);
10412
+ }
10413
+ }
10414
+ const yi = () => {
10415
+ if (typeof crypto < "u" && typeof crypto.getRandomValues < "u")
10416
+ return new gi();
10417
+ if (typeof UUIDV7_DENY_WEAK_RNG < "u" && UUIDV7_DENY_WEAK_RNG)
10418
+ throw new Error("no cryptographically strong RNG available");
10419
+ return {
10420
+ nextUint32: () => Math.trunc(Math.random() * 65536) * 65536 + Math.trunc(Math.random() * 65536)
10421
+ };
10422
+ };
10423
+ class gi {
10424
+ constructor() {
10425
+ this.buffer = new Uint32Array(8), this.cursor = 65535;
10426
+ }
10427
+ nextUint32() {
10428
+ return this.cursor >= this.buffer.length && (crypto.getRandomValues(this.buffer), this.cursor = 0), this.buffer[this.cursor++];
10429
+ }
10430
+ }
10431
+ let me;
10432
+ const bi = () => Ri().toString(), Ri = () => (me || (me = new mi())).generate();
10433
+ let wi = class {
10162
10434
  constructor(t) {
10163
10435
  this.db = t;
10164
10436
  }
@@ -10166,12 +10438,12 @@ let hi = class {
10166
10438
  return this.db.scheme('CREATE Table IF NOT EXISTS "_IDS_" (last INTEGER, name TEXT)');
10167
10439
  }
10168
10440
  async getAutoId(t) {
10169
- return pe();
10441
+ return bi();
10170
10442
  }
10171
10443
  };
10172
- class Gi {
10444
+ class rs {
10173
10445
  constructor(t, e = {}) {
10174
- this.database = t, this.options = e, this.idSystem = new hi(this), this.logger = this.options?.logger || bt, this.db = new De(this.database);
10446
+ this.database = t, this.options = e, this.idSystem = new wi(this), this.logger = this.options?.logger || Rt, this.db = new Ve(this.database);
10175
10447
  }
10176
10448
  async open(t = !1) {
10177
10449
  if (t) {
@@ -10223,7 +10495,7 @@ class Gi {
10223
10495
  sql: t,
10224
10496
  params: a
10225
10497
  });
10226
- const o = `${t} RETURNING "${at}"`;
10498
+ const o = `${t} RETURNING "${ot}"`;
10227
10499
  try {
10228
10500
  return (await this.db.query(o, a)).rows[0];
10229
10501
  } catch (n) {
@@ -10286,7 +10558,7 @@ class Gi {
10286
10558
  return t === "pk" ? "SERIAL PRIMARY KEY" : t === "id" ? "UUID" : e || t === "object" ? "JSON" : t === "string" ? "TEXT" : t === "boolean" ? "BOOL" : t === "number" ? "INT" : t === "timestamp" ? "TIMESTAMP" : t;
10287
10559
  }
10288
10560
  }
10289
- class pi {
10561
+ class Ni {
10290
10562
  constructor(t) {
10291
10563
  this.db = t;
10292
10564
  }
@@ -10298,16 +10570,16 @@ class pi {
10298
10570
  return e === void 0 ? await this.db.scheme(`INSERT INTO "_IDS_" (name, last) VALUES ('${t}', ${r})`, i) : await this.db.update('UPDATE "_IDS_" SET last = ? WHERE name = ?', [r, t], void 0, i), r;
10299
10571
  }
10300
10572
  }
10301
- class Ki {
10573
+ class is {
10302
10574
  constructor(t, e = {}) {
10303
- this.database = t, this.options = e, this.idSystem = new pi(this), this.logger = this.options?.logger || bt;
10575
+ this.database = t, this.options = e, this.idSystem = new Ni(this), this.logger = this.options?.logger || Rt;
10304
10576
  }
10305
10577
  async open(t = !1) {
10306
- ({ ...this.options }, this.db = await ae.createConnection({
10578
+ ({ ...this.options }, this.db = await ne.createConnection({
10307
10579
  ...this.options
10308
10580
  })), await this.db.connect();
10309
10581
  const [e] = await this.db.query(`SHOW DATABASES LIKE '${this.database}'`);
10310
- e.length === 0 ? await this.db.query(`CREATE DATABASE ${this.database}`) : (t && (await this.db.query(`DROP DATABASE ${this.database}`), await this.db.query(`CREATE DATABASE ${this.database}`)), this.db = await ae.createConnection({
10582
+ e.length === 0 ? await this.db.query(`CREATE DATABASE ${this.database}`) : (t && (await this.db.query(`DROP DATABASE ${this.database}`), await this.db.query(`CREATE DATABASE ${this.database}`)), this.db = await ne.createConnection({
10311
10583
  ...this.options,
10312
10584
  database: this.database
10313
10585
  }), await this.db.connect()), await this.db.query("SET sql_mode='ANSI_QUOTES'"), await this.idSystem.setup();
@@ -10379,176 +10651,176 @@ class Ki {
10379
10651
  }
10380
10652
  }
10381
10653
  export {
10382
- Nt as ACTIVITY_RECORD,
10383
- je as ALL_ATTR_SYMBOL,
10384
- Dt as ASYNC_TASK_RECORD,
10385
- It as Action,
10386
- Jt as Activity,
10387
- et as ActivityCall,
10388
- rt as ActivityGroup,
10389
- ti as ActivityInteractionRelation,
10390
- ei as ActivityManager,
10391
- Ce as ActivityStateEntity,
10392
- ft as Any,
10393
- Cr as AnyHandles,
10654
+ St as ACTIVITY_RECORD,
10655
+ Ke as ALL_ATTR_SYMBOL,
10656
+ Ft as ASYNC_TASK_RECORD,
10657
+ xt as Action,
10658
+ Ut as Activity,
10659
+ rt as ActivityCall,
10660
+ it as ActivityGroup,
10661
+ ii as ActivityInteractionRelation,
10662
+ si as ActivityManager,
10663
+ Me as ActivityStateEntity,
10664
+ mt as Any,
10665
+ $r as AnyHandles,
10394
10666
  W as AttributeInfo,
10395
10667
  x as AttributeQuery,
10396
- X as Attributive,
10397
- Et as Attributives,
10398
- ht as Average,
10399
- Wr as AverageHandles,
10400
- Ai as BaseKlass,
10401
- ot as BoolAtomData,
10668
+ Y as Attributive,
10669
+ Ct as Attributives,
10670
+ pt as Average,
10671
+ Ur as AverageHandles,
10672
+ Di as BaseKlass,
10673
+ nt as BoolAtomData,
10402
10674
  R as BoolExp,
10403
- nt as BoolExpressionData,
10675
+ ct as BoolExpressionData,
10404
10676
  J as ComputationDataDepError,
10405
- Q as ComputationError,
10677
+ V as ComputationError,
10406
10678
  A as ComputationResult,
10407
- ve as ComputationResultAsync,
10408
- Se as ComputationResultFullRecompute,
10409
- ke as ComputationResultResolved,
10410
- vt as ComputationResultSkip,
10411
- le as ComputationStateError,
10679
+ Ae as ComputationResultAsync,
10680
+ ke as ComputationResultFullRecompute,
10681
+ Ee as ComputationResultResolved,
10682
+ At as ComputationResultSkip,
10683
+ de as ComputationStateError,
10412
10684
  Ht as Condition,
10413
10685
  O as ConditionError,
10414
- xt as Conditions,
10415
- Bi as Controller,
10416
- ut as Count,
10417
- $r as CountHandles,
10418
- Zt as Custom,
10419
- Gr as CustomHandles,
10420
- ee as DBConsoleLogger,
10421
- ci as DBLogLevel,
10422
- hr as DBSetup,
10423
- Li as DELETED_STATE,
10686
+ $t as Conditions,
10687
+ Xi as Controller,
10688
+ dt as Count,
10689
+ Or as CountHandles,
10690
+ ee as Custom,
10691
+ Yr as CustomHandles,
10692
+ ie as DBConsoleLogger,
10693
+ di as DBLogLevel,
10694
+ mr as DBSetup,
10695
+ Hi as DELETED_STATE,
10424
10696
  q as DICTIONARY_RECORD,
10425
- jt as DataAttributive,
10426
- zt as DataAttributives,
10427
- Bt as Dictionary,
10428
- fr as DictionaryEntity,
10697
+ Gt as DataAttributive,
10698
+ te as DataAttributives,
10699
+ Jt as Dictionary,
10700
+ gr as DictionaryEntity,
10429
10701
  C as Entity,
10430
- Hr as EntityCustomHandle,
10431
- ze as EntityQueryHandle,
10432
- Ze as EntityToTableMap,
10433
- te as Equation,
10434
- Ut as Event,
10435
- pt as Every,
10436
- Ar as EveryHandles,
10702
+ Gr as EntityCustomHandle,
10703
+ er as EntityQueryHandle,
10704
+ rr as EntityToTableMap,
10705
+ re as Equation,
10706
+ Kt as Event,
10707
+ ft as Every,
10708
+ Cr as EveryHandles,
10437
10709
  $ as Expression,
10438
- it as Gateway,
10439
- We as GetAction,
10440
- Er as GlobalAnyHandle,
10441
- qr as GlobalAverageHandle,
10710
+ st as Gateway,
10711
+ Ue as GetAction,
10712
+ xr as GlobalAnyHandle,
10713
+ Jr as GlobalAverageHandle,
10442
10714
  B as GlobalBoundState,
10443
- xr as GlobalCountHandle,
10444
- Jr as GlobalCustomHandle,
10445
- vr as GlobalEveryHandle,
10446
- Or as GlobalRealTimeComputation,
10447
- br as GlobalStateMachineHandle,
10448
- Vr as GlobalSumHandle,
10449
- Nr as GlobalWeightedSummationHandle,
10450
- Lt as HARD_DELETION_PROPERTY_NAME,
10451
- qi as HardDeletionProperty,
10452
- ne as ID_ATTR,
10453
- Vt as INTERACTION_RECORD,
10454
- kt as Inequality,
10455
- Wt as Interaction,
10456
- Ee as InteractionCall,
10457
- Ie as InteractionEventEntity,
10458
- _t as KlassByName,
10715
+ Pr as GlobalCountHandle,
10716
+ Hr as GlobalCustomHandle,
10717
+ Er as GlobalEveryHandle,
10718
+ Qr as GlobalRealTimeComputation,
10719
+ Nr as GlobalStateMachineHandle,
10720
+ qr as GlobalSumHandle,
10721
+ vr as GlobalWeightedSummationHandle,
10722
+ qt as HARD_DELETION_PROPERTY_NAME,
10723
+ Ki as HardDeletionProperty,
10724
+ le as ID_ATTR,
10725
+ _t as INTERACTION_RECORD,
10726
+ Et as Inequality,
10727
+ jt as Interaction,
10728
+ Ce as InteractionCall,
10729
+ xe as InteractionEventEntity,
10730
+ Bt as KlassByName,
10459
10731
  f as LINK_SYMBOL,
10460
- St as LinkInfo,
10732
+ kt as LinkInfo,
10461
10733
  m as MatchExp,
10462
- He as Modifier,
10463
- Ji as MonoSystem,
10464
- Ki as MysqlDB,
10465
- Vi as NON_DELETED_STATE,
10466
- Qi as NON_EXIST_STATE,
10734
+ Ge as Modifier,
10735
+ zi as MonoSystem,
10736
+ is as MysqlDB,
10737
+ Ui as NON_DELETED_STATE,
10738
+ ji as NON_EXIST_STATE,
10467
10739
  L as NewRecordData,
10468
- Gi as PGLiteDB,
10469
- Pi as PHASE_AFTER_ALL,
10470
- $i as PHASE_BEFORE_ALL,
10471
- Pt as PHASE_NORMAL,
10472
- Xt as Payload,
10473
- Kt as PayloadItem,
10474
- ji as PostgreSQLDB,
10740
+ rs as PGLiteDB,
10741
+ qi as PHASE_AFTER_ALL,
10742
+ _i as PHASE_BEFORE_ALL,
10743
+ Ot as PHASE_NORMAL,
10744
+ zt as Payload,
10745
+ Yt as PayloadItem,
10746
+ ts as PostgreSQLDB,
10475
10747
  T as Property,
10476
- Ir as PropertyAnyHandle,
10477
- Br as PropertyAverageHandle,
10478
- Mr as PropertyCountHandle,
10479
- Ur as PropertyCustomHandle,
10480
- kr as PropertyEveryHandle,
10481
- Fr as PropertyRealTimeComputation,
10482
- Rr as PropertyStateMachineHandle,
10483
- Lr as PropertySumHandle,
10484
- qt as PropertyTypes,
10485
- Tr as PropertyWeightedSummationHandle,
10486
- we as Query,
10487
- Re as QueryItem,
10488
- Te as ROOT_LABEL,
10489
- at as ROW_ID_ATTR,
10490
- mt as RealTime,
10491
- Qr as RealTimeHandles,
10748
+ Mr as PropertyAnyHandle,
10749
+ jr as PropertyAverageHandle,
10750
+ Dr as PropertyCountHandle,
10751
+ Xr as PropertyCustomHandle,
10752
+ Ir as PropertyEveryHandle,
10753
+ Lr as PropertyRealTimeComputation,
10754
+ Tr as PropertyStateMachineHandle,
10755
+ Br as PropertySumHandle,
10756
+ Wt as PropertyTypes,
10757
+ kr as PropertyWeightedSummationHandle,
10758
+ Te as Query,
10759
+ Ne as QueryItem,
10760
+ ve as ROOT_LABEL,
10761
+ ot as ROW_ID_ATTR,
10762
+ yt as RealTime,
10763
+ _r as RealTimeHandles,
10492
10764
  E as RecordBoundState,
10493
- st as RecordInfo,
10494
- K as RecordMutationSideEffect,
10765
+ at as RecordInfo,
10766
+ X as RecordMutationSideEffect,
10495
10767
  M as RecordQuery,
10496
- Ye as RecordQueryAgent,
10768
+ tr as RecordQueryAgent,
10497
10769
  _ as RecordQueryTree,
10498
- Pr as RecordsTransformHandle,
10499
- Tt as RecursiveContext,
10500
- Ne as RefContainer,
10770
+ Fr as RecordsTransformHandle,
10771
+ vt as RecursiveContext,
10772
+ Se as RefContainer,
10501
10773
  P as Relation,
10502
- jr as RelationCustomHandle,
10503
- si as SQLiteDB,
10504
- tt as SYSTEM_RECORD,
10505
- Kr as Scheduler,
10506
- Yt as SideEffect,
10507
- ct as StateMachine,
10508
- wr as StateMachineHandles,
10509
- Y as StateNode,
10510
- Gt as StateTransfer,
10511
- dt as Summation,
10512
- _r as SummationHandles,
10513
- re as SystemConsoleLogger,
10514
- pr as SystemEntity,
10515
- li as SystemLogLevel,
10516
- ge as Transfer,
10517
- Ct as Transform,
10518
- Dr as TransformHandles,
10519
- _i as USER_ENTITY,
10520
- lt as WeightedSummation,
10521
- Sr as WeightedSummationHandles,
10522
- de as addToCurrentEffects,
10774
+ Kr as RelationCustomHandle,
10775
+ ni as SQLiteDB,
10776
+ et as SYSTEM_RECORD,
10777
+ zr as Scheduler,
10778
+ Zt as SideEffect,
10779
+ lt as StateMachine,
10780
+ Sr as StateMachineHandles,
10781
+ z as StateNode,
10782
+ Xt as StateTransfer,
10783
+ ht as Summation,
10784
+ Wr as SummationHandles,
10785
+ se as SystemConsoleLogger,
10786
+ yr as SystemEntity,
10787
+ hi as SystemLogLevel,
10788
+ Re as Transfer,
10789
+ Mt as Transform,
10790
+ Vr as TransformHandles,
10791
+ Gi as USER_ENTITY,
10792
+ ut as WeightedSummation,
10793
+ Ar as WeightedSummationHandles,
10794
+ pe as addToCurrentEffects,
10523
10795
  v as assert,
10524
- At as asyncEffectsContext,
10796
+ It as asyncEffectsContext,
10525
10797
  I as asyncInteractionContext,
10526
- xi as boolExpToAttributives,
10527
- Ni as clearAllInstances,
10528
- ki as createClass,
10529
- Qe as createInstances,
10530
- vi as createInstancesFromString,
10531
- Mi as createUserRoleAttributive,
10532
- bt as dbConsoleLogger,
10533
- Rt as deepClone,
10534
- Fi as everyAsync,
10535
- gr as everyWithErrorAsync,
10536
- Di as filterMap,
10537
- Ii as findRootActivity,
10538
- be as forEachInteraction,
10798
+ Qi as boolExpToAttributives,
10799
+ Ci as clearAllInstances,
10800
+ Pi as createClass,
10801
+ _e as createInstances,
10802
+ $i as createInstancesFromString,
10803
+ Li as createUserRoleAttributive,
10804
+ Rt as dbConsoleLogger,
10805
+ wt as deepClone,
10806
+ Ji as everyAsync,
10807
+ wr as everyWithErrorAsync,
10808
+ Bi as filterMap,
10809
+ Fi as findRootActivity,
10810
+ we as forEachInteraction,
10539
10811
  S as generateUUID,
10540
- ri as getCurrentEffects,
10541
- Ei as getInteractions,
10542
- Oe as indexBy,
10543
- me as isObject,
10544
- ye as isPlainObject,
10545
- Oi as mapObject,
10546
- Ci as parse,
10547
- Fe as registerKlass,
10548
- Ti as removeAllInstance,
10549
- yr as someAsync,
10550
- Si as stringifyAllInstances,
10812
+ ai as getCurrentEffects,
10813
+ Oi as getInteractions,
10814
+ Qe as indexBy,
10815
+ ge as isObject,
10816
+ be as isPlainObject,
10817
+ Wi as mapObject,
10818
+ Vi as parse,
10819
+ Le as registerKlass,
10820
+ xi as removeAllInstance,
10821
+ Rr as someAsync,
10822
+ Mi as stringifyAllInstances,
10551
10823
  w as stringifyAttribute,
10552
- ui as systemConsoleLogger
10824
+ pi as systemConsoleLogger
10553
10825
  };
10554
10826
  //# sourceMappingURL=index.js.map