interaqt 0.4.12 → 0.4.14

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,62 @@
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 { parse as De } from "acorn";
2
+ import { AsyncLocalStorage as ye } from "async_hooks";
3
+ import Oe from "better-sqlite3";
4
+ import Fe from "pg";
5
+ import { PGlite as Ve } from "@electric-sql/pglite";
6
+ import ne from "mysql2/promise";
7
+ function ge(u) {
9
8
  return u !== null && typeof u == "object";
10
9
  }
11
- function ye(u) {
12
- if (!me(u)) return !1;
10
+ function be(u) {
11
+ if (!ge(u)) return !1;
13
12
  const t = Object.getPrototypeOf(u);
14
13
  return t === null ? !0 : t === Object.prototype || t === null;
15
14
  }
16
- function Oe(u, t) {
15
+ function Qe(u, t) {
17
16
  const e = {};
18
17
  for (const r of u)
19
18
  r && r[t] !== void 0 && (e[String(r[t])] = r);
20
19
  return e;
21
20
  }
22
21
  function w(u) {
23
- return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u : me(u) && !ye(u) ? `uuid::${u.uuid}` : u;
22
+ return typeof u == "function" ? `func::${u.toString()}` : Array.isArray(u) ? u : ge(u) && !be(u) ? `uuid::${u.uuid}` : u;
24
23
  }
25
- function Rt(u, t) {
24
+ function wt(u, t) {
26
25
  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)]));
26
+ if (Array.isArray(u)) return u.map((r) => wt(r, t));
27
+ if (be(u))
28
+ return Object.fromEntries(Object.entries(u).map(([r, i]) => [r, wt(i, t)]));
30
29
  if (u instanceof Set)
31
- return new Set(Array.from(u.values()).map((r) => Rt(r, t)));
30
+ return new Set(Array.from(u.values()).map((r) => wt(r, t)));
32
31
  if (u instanceof Map)
33
- return new Map(Array.from(u.entries()).map(([r, i]) => [r, Rt(i, t)]));
32
+ return new Map(Array.from(u.entries()).map(([r, i]) => [r, wt(i, t)]));
34
33
  const e = u;
35
34
  return t && e._type && e.constructor?.clone ? e.constructor.clone(u, t) : u;
36
35
  }
37
- function Ni(...u) {
36
+ function Ei(...u) {
38
37
  for (const t of u)
39
38
  t.instances.length = 0;
40
39
  }
41
- function Ti() {
40
+ function Ii() {
42
41
  }
43
- const _t = /* @__PURE__ */ new Map();
44
- function Fe(u, t) {
45
- t && t.isKlass && t.displayName && _t.set(u, t);
42
+ const Bt = /* @__PURE__ */ new Map();
43
+ function Le(u, t) {
44
+ t && t.isKlass && t.displayName && Bt.set(u, t);
46
45
  }
47
- function Si() {
46
+ function Ci() {
48
47
  const u = [];
49
- return Array.from(_t.entries()).forEach(([, t]) => {
48
+ return Array.from(Bt.entries()).forEach(([, t]) => {
50
49
  t.instances && Array.isArray(t.instances) && t.stringify && u.push(...t.instances.map((e) => t.stringify(e)));
51
50
  }), `[${u.join(",")}]`;
52
51
  }
53
- function vi(u) {
52
+ function xi(u) {
54
53
  const t = JSON.parse(u);
55
- return Qe(t);
54
+ return _e(t);
56
55
  }
57
- function Qe(u) {
56
+ function _e(u) {
58
57
  const t = /* @__PURE__ */ new Map();
59
58
  return u.forEach(({ type: e, options: r = {}, uuid: i, public: s }) => {
60
- const a = _t.get(e);
59
+ const a = Bt.get(e);
61
60
  if (!a) {
62
61
  console.warn(`Class ${e} not found in KlassByName`);
63
62
  return;
@@ -66,10 +65,282 @@ function Qe(u) {
66
65
  t.set(i, o);
67
66
  }), t;
68
67
  }
69
- function ki(u) {
68
+ function Mi(u) {
70
69
  return console.warn("createClass is deprecated in refactored code"), null;
71
70
  }
72
- class Ai {
71
+ /**
72
+ * uuidv7: A JavaScript implementation of UUID version 7
73
+ *
74
+ * Copyright 2021-2024 LiosK
75
+ *
76
+ * @license Apache-2.0
77
+ * @packageDocumentation
78
+ */
79
+ const Nt = "0123456789abcdef";
80
+ class U {
81
+ /** @param bytes - The 16-byte byte array representation. */
82
+ constructor(t) {
83
+ this.bytes = t;
84
+ }
85
+ /**
86
+ * Creates an object from the internal representation, a 16-byte byte array
87
+ * containing the binary UUID representation in the big-endian byte order.
88
+ *
89
+ * This method does NOT shallow-copy the argument, and thus the created object
90
+ * holds the reference to the underlying buffer.
91
+ *
92
+ * @throws TypeError if the length of the argument is not 16.
93
+ */
94
+ static ofInner(t) {
95
+ if (t.length !== 16)
96
+ throw new TypeError("not 128-bit length");
97
+ return new U(t);
98
+ }
99
+ /**
100
+ * Builds a byte array from UUIDv7 field values.
101
+ *
102
+ * @param unixTsMs - A 48-bit `unix_ts_ms` field value.
103
+ * @param randA - A 12-bit `rand_a` field value.
104
+ * @param randBHi - The higher 30 bits of 62-bit `rand_b` field value.
105
+ * @param randBLo - The lower 32 bits of 62-bit `rand_b` field value.
106
+ * @throws RangeError if any field value is out of the specified range.
107
+ */
108
+ static fromFieldsV7(t, e, r, i) {
109
+ 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)
110
+ throw new RangeError("invalid field value");
111
+ const s = new Uint8Array(16);
112
+ 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);
113
+ }
114
+ /**
115
+ * Builds a byte array from a string representation.
116
+ *
117
+ * This method accepts the following formats:
118
+ *
119
+ * - 32-digit hexadecimal format without hyphens: `0189dcd553117d408db09496a2eef37b`
120
+ * - 8-4-4-4-12 hyphenated format: `0189dcd5-5311-7d40-8db0-9496a2eef37b`
121
+ * - Hyphenated format with surrounding braces: `{0189dcd5-5311-7d40-8db0-9496a2eef37b}`
122
+ * - RFC 9562 URN format: `urn:uuid:0189dcd5-5311-7d40-8db0-9496a2eef37b`
123
+ *
124
+ * Leading and trailing whitespaces represents an error.
125
+ *
126
+ * @throws SyntaxError if the argument could not parse as a valid UUID string.
127
+ */
128
+ static parse(t) {
129
+ var e, r, i, s;
130
+ let a;
131
+ switch (t.length) {
132
+ case 32:
133
+ a = (e = /^[0-9a-f]{32}$/i.exec(t)) === null || e === void 0 ? void 0 : e[0];
134
+ break;
135
+ case 36:
136
+ 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("");
137
+ break;
138
+ case 38:
139
+ 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("");
140
+ break;
141
+ case 45:
142
+ 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("");
143
+ break;
144
+ }
145
+ if (a) {
146
+ const o = new Uint8Array(16);
147
+ for (let n = 0; n < 16; n += 4) {
148
+ const c = parseInt(a.substring(2 * n, 2 * n + 8), 16);
149
+ o[n + 0] = c >>> 24, o[n + 1] = c >>> 16, o[n + 2] = c >>> 8, o[n + 3] = c;
150
+ }
151
+ return new U(o);
152
+ } else
153
+ throw new SyntaxError("could not parse UUID string");
154
+ }
155
+ /**
156
+ * @returns The 8-4-4-4-12 canonical hexadecimal string representation
157
+ * (`0189dcd5-5311-7d40-8db0-9496a2eef37b`).
158
+ */
159
+ toString() {
160
+ let t = "";
161
+ for (let e = 0; e < this.bytes.length; e++)
162
+ t += Nt.charAt(this.bytes[e] >>> 4), t += Nt.charAt(this.bytes[e] & 15), (e === 3 || e === 5 || e === 7 || e === 9) && (t += "-");
163
+ return t;
164
+ }
165
+ /**
166
+ * @returns The 32-digit hexadecimal representation without hyphens
167
+ * (`0189dcd553117d408db09496a2eef37b`).
168
+ */
169
+ toHex() {
170
+ let t = "";
171
+ for (let e = 0; e < this.bytes.length; e++)
172
+ t += Nt.charAt(this.bytes[e] >>> 4), t += Nt.charAt(this.bytes[e] & 15);
173
+ return t;
174
+ }
175
+ /** @returns The 8-4-4-4-12 canonical hexadecimal string representation. */
176
+ toJSON() {
177
+ return this.toString();
178
+ }
179
+ /**
180
+ * Reports the variant field value of the UUID or, if appropriate, "NIL" or
181
+ * "MAX".
182
+ *
183
+ * For convenience, this method reports "NIL" or "MAX" if `this` represents
184
+ * the Nil or Max UUID, although the Nil and Max UUIDs are technically
185
+ * subsumed under the variants `0b0` and `0b111`, respectively.
186
+ */
187
+ getVariant() {
188
+ const t = this.bytes[8] >>> 4;
189
+ if (t < 0)
190
+ throw new Error("unreachable");
191
+ if (t <= 7)
192
+ return this.bytes.every((e) => e === 0) ? "NIL" : "VAR_0";
193
+ if (t <= 11)
194
+ return "VAR_10";
195
+ if (t <= 13)
196
+ return "VAR_110";
197
+ if (t <= 15)
198
+ return this.bytes.every((e) => e === 255) ? "MAX" : "VAR_RESERVED";
199
+ throw new Error("unreachable");
200
+ }
201
+ /**
202
+ * Returns the version field value of the UUID or `undefined` if the UUID does
203
+ * not have the variant field value of `0b10`.
204
+ */
205
+ getVersion() {
206
+ return this.getVariant() === "VAR_10" ? this.bytes[6] >>> 4 : void 0;
207
+ }
208
+ /** Creates an object from `this`. */
209
+ clone() {
210
+ return new U(this.bytes.slice(0));
211
+ }
212
+ /** Returns true if `this` is equivalent to `other`. */
213
+ equals(t) {
214
+ return this.compareTo(t) === 0;
215
+ }
216
+ /**
217
+ * Returns a negative integer, zero, or positive integer if `this` is less
218
+ * than, equal to, or greater than `other`, respectively.
219
+ */
220
+ compareTo(t) {
221
+ for (let e = 0; e < 16; e++) {
222
+ const r = this.bytes[e] - t.bytes[e];
223
+ if (r !== 0)
224
+ return Math.sign(r);
225
+ }
226
+ return 0;
227
+ }
228
+ }
229
+ class qe {
230
+ /**
231
+ * Creates a generator object with the default random number generator, or
232
+ * with the specified one if passed as an argument. The specified random
233
+ * number generator should be cryptographically strong and securely seeded.
234
+ */
235
+ constructor(t) {
236
+ this.timestamp = 0, this.counter = 0, this.random = t ?? Be();
237
+ }
238
+ /**
239
+ * Generates a new UUIDv7 object from the current timestamp, or resets the
240
+ * generator upon significant timestamp rollback.
241
+ *
242
+ * This method returns a monotonically increasing UUID by reusing the previous
243
+ * timestamp even if the up-to-date timestamp is smaller than the immediately
244
+ * preceding UUID's. However, when such a clock rollback is considered
245
+ * significant (i.e., by more than ten seconds), this method resets the
246
+ * generator and returns a new UUID based on the given timestamp, breaking the
247
+ * increasing order of UUIDs.
248
+ *
249
+ * See {@link generateOrAbort} for the other mode of generation and
250
+ * {@link generateOrResetCore} for the low-level primitive.
251
+ */
252
+ generate() {
253
+ return this.generateOrResetCore(Date.now(), 1e4);
254
+ }
255
+ /**
256
+ * Generates a new UUIDv7 object from the current timestamp, or returns
257
+ * `undefined` upon significant timestamp rollback.
258
+ *
259
+ * This method returns a monotonically increasing UUID by reusing the previous
260
+ * timestamp even if the up-to-date timestamp is smaller than the immediately
261
+ * preceding UUID's. However, when such a clock rollback is considered
262
+ * significant (i.e., by more than ten seconds), this method aborts and
263
+ * returns `undefined` immediately.
264
+ *
265
+ * See {@link generate} for the other mode of generation and
266
+ * {@link generateOrAbortCore} for the low-level primitive.
267
+ */
268
+ generateOrAbort() {
269
+ return this.generateOrAbortCore(Date.now(), 1e4);
270
+ }
271
+ /**
272
+ * Generates a new UUIDv7 object from the `unixTsMs` passed, or resets the
273
+ * generator upon significant timestamp rollback.
274
+ *
275
+ * This method is equivalent to {@link generate} except that it takes a custom
276
+ * timestamp and clock rollback allowance.
277
+ *
278
+ * @param rollbackAllowance - The amount of `unixTsMs` rollback that is
279
+ * considered significant. A suggested value is `10_000` (milliseconds).
280
+ * @throws RangeError if `unixTsMs` is not a 48-bit positive integer.
281
+ */
282
+ generateOrResetCore(t, e) {
283
+ let r = this.generateOrAbortCore(t, e);
284
+ return r === void 0 && (this.timestamp = 0, r = this.generateOrAbortCore(t, e)), r;
285
+ }
286
+ /**
287
+ * Generates a new UUIDv7 object from the `unixTsMs` passed, or returns
288
+ * `undefined` upon significant timestamp rollback.
289
+ *
290
+ * This method is equivalent to {@link generateOrAbort} except that it takes a
291
+ * custom timestamp and clock rollback allowance.
292
+ *
293
+ * @param rollbackAllowance - The amount of `unixTsMs` rollback that is
294
+ * considered significant. A suggested value is `10_000` (milliseconds).
295
+ * @throws RangeError if `unixTsMs` is not a 48-bit positive integer.
296
+ */
297
+ generateOrAbortCore(t, e) {
298
+ if (!Number.isInteger(t) || t < 0 || t > 281474976710655)
299
+ throw new RangeError(`\`unixTsMs\` must be a 48-bit positive integer, got ${t}`);
300
+ if (e < 0 || e > 281474976710655)
301
+ throw new RangeError(`\`rollbackAllowance\` out of reasonable range, got ${e}`);
302
+ if (t > this.timestamp)
303
+ this.timestamp = t, this.resetCounter();
304
+ else if (t + e >= this.timestamp)
305
+ this.counter++, this.counter > 4398046511103 && (this.timestamp++, this.resetCounter());
306
+ else
307
+ return;
308
+ return U.fromFieldsV7(this.timestamp, Math.trunc(this.counter / 2 ** 30), this.counter & 2 ** 30 - 1, this.random.nextUint32());
309
+ }
310
+ /** Initializes the counter at a 42-bit random integer. */
311
+ resetCounter() {
312
+ this.counter = this.random.nextUint32() * 1024 + (this.random.nextUint32() & 1023);
313
+ }
314
+ /**
315
+ * Generates a new UUIDv4 object utilizing the random number generator inside.
316
+ *
317
+ * @internal
318
+ */
319
+ generateV4() {
320
+ const t = new Uint8Array(Uint32Array.of(this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32(), this.random.nextUint32()).buffer);
321
+ return t[6] = 64 | t[6] >>> 4, t[8] = 128 | t[8] >>> 2, U.ofInner(t);
322
+ }
323
+ }
324
+ const Be = () => {
325
+ if (typeof crypto < "u" && typeof crypto.getRandomValues < "u")
326
+ return new We();
327
+ if (typeof UUIDV7_DENY_WEAK_RNG < "u" && UUIDV7_DENY_WEAK_RNG)
328
+ throw new Error("no cryptographically strong RNG available");
329
+ return {
330
+ nextUint32: () => Math.trunc(Math.random() * 65536) * 65536 + Math.trunc(Math.random() * 65536)
331
+ };
332
+ };
333
+ class We {
334
+ constructor() {
335
+ this.buffer = new Uint32Array(8), this.cursor = 65535;
336
+ }
337
+ nextUint32() {
338
+ return this.cursor >= this.buffer.length && (crypto.getRandomValues(this.buffer), this.cursor = 0), this.buffer[this.cursor++];
339
+ }
340
+ }
341
+ let ce;
342
+ const Re = () => Je().toString(), Je = () => (ce || (ce = new qe())).generate();
343
+ class $i {
73
344
  static {
74
345
  this.isKlass = !0;
75
346
  }
@@ -92,9 +363,9 @@ class Ai {
92
363
  }
93
364
  }
94
365
  function S(u) {
95
- return u?.uuid || pe();
366
+ return u?.uuid || Re();
96
367
  }
97
- const Ve = /^[a-zA-Z0-9_]+$/;
368
+ const je = /^[a-zA-Z0-9_]+$/;
98
369
  class C {
99
370
  // for Merged Entity
100
371
  constructor(t, e) {
@@ -115,7 +386,7 @@ class C {
115
386
  type: "string",
116
387
  required: !0,
117
388
  constraints: {
118
- nameFormat: ({ name: t }) => Ve.test(t)
389
+ nameFormat: ({ name: t }) => je.test(t)
119
390
  }
120
391
  },
121
392
  properties: {
@@ -196,9 +467,9 @@ class C {
196
467
  return this.create(e.public, e.options);
197
468
  }
198
469
  }
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 {
470
+ var Wt = /* @__PURE__ */ ((u) => (u.String = "string", u.Number = "number", u.Boolean = "boolean", u.Timestamp = "timestamp", u))(Wt || {});
471
+ const Ue = /^[a-zA-Z0-9_]+$/;
472
+ class Jt {
202
473
  constructor(t, e) {
203
474
  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
475
  }
@@ -218,7 +489,7 @@ class Bt {
218
489
  required: !0,
219
490
  collection: !1,
220
491
  constraints: {
221
- format: ({ name: t }) => Le.test(t),
492
+ format: ({ name: t }) => Ue.test(t),
222
493
  length: ({ name: t }) => t.length > 1 && t.length < 5
223
494
  }
224
495
  },
@@ -226,7 +497,7 @@ class Bt {
226
497
  type: "string",
227
498
  required: !0,
228
499
  collection: !1,
229
- options: Array.from(Object.values(qt))
500
+ options: Array.from(Object.values(Wt))
230
501
  },
231
502
  collection: {
232
503
  type: "boolean",
@@ -252,7 +523,7 @@ class Bt {
252
523
  };
253
524
  }
254
525
  static create(t, e) {
255
- const r = new Bt(t, e);
526
+ const r = new Jt(t, e);
256
527
  if (this.instances.find((s) => s.uuid === r.uuid))
257
528
  throw new Error(`duplicate uuid in options ${r.uuid}, Dictionary`);
258
529
  return this.instances.push(r), r;
@@ -291,7 +562,7 @@ class Bt {
291
562
  return this.create(e.public, e.options);
292
563
  }
293
564
  }
294
- const _e = /^[a-zA-Z0-9_]+$/;
565
+ const He = /^[a-zA-Z0-9_]+$/;
295
566
  class T {
296
567
  constructor(t, e) {
297
568
  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 +582,14 @@ class T {
311
582
  type: "string",
312
583
  required: !0,
313
584
  constraints: {
314
- format: ({ name: t }) => _e.test(t),
585
+ format: ({ name: t }) => He.test(t),
315
586
  length: ({ name: t }) => t.length > 1 && t.length < 5
316
587
  }
317
588
  },
318
589
  type: {
319
590
  type: "string",
320
591
  required: !0,
321
- options: () => Object.values(qt)
592
+ options: () => Object.values(Wt)
322
593
  },
323
594
  collection: {
324
595
  type: "boolean",
@@ -557,7 +828,7 @@ class P {
557
828
  return this.create(e.public, e.options);
558
829
  }
559
830
  }
560
- class Wt {
831
+ class jt {
561
832
  constructor(t, e) {
562
833
  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
834
  }
@@ -618,7 +889,7 @@ class Wt {
618
889
  };
619
890
  }
620
891
  static create(t, e) {
621
- const r = new Wt(t, e);
892
+ const r = new jt(t, e);
622
893
  if (this.instances.find((s) => s.uuid === r.uuid))
623
894
  throw new Error(`duplicate uuid in options ${r.uuid}, Interaction`);
624
895
  return this.instances.push(r), r;
@@ -655,7 +926,7 @@ class Wt {
655
926
  return this.create(e.public, e.options);
656
927
  }
657
928
  }
658
- class Jt {
929
+ class Ut {
659
930
  constructor(t, e) {
660
931
  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
932
  }
@@ -703,7 +974,7 @@ class Jt {
703
974
  };
704
975
  }
705
976
  static create(t, e) {
706
- const r = new Jt(t, e);
977
+ const r = new Ut(t, e);
707
978
  if (this.instances.find((s) => s.uuid === r.uuid))
708
979
  throw new Error(`duplicate uuid in options ${r.uuid}, Activity`);
709
980
  return this.instances.push(r), r;
@@ -741,7 +1012,7 @@ class Jt {
741
1012
  return this.create(e.public, e.options);
742
1013
  }
743
1014
  }
744
- class rt {
1015
+ class it {
745
1016
  constructor(t, e) {
746
1017
  this._type = "ActivityGroup", this._options = e, this.uuid = S(e), this.type = t.type, this.activities = t.activities || [];
747
1018
  }
@@ -770,7 +1041,7 @@ class rt {
770
1041
  };
771
1042
  }
772
1043
  static create(t, e) {
773
- const r = new rt(t, e);
1044
+ const r = new it(t, e);
774
1045
  if (this.instances.find((s) => s.uuid === r.uuid))
775
1046
  throw new Error(`duplicate uuid in options ${r.uuid}, ActivityGroup`);
776
1047
  return this.instances.push(r), r;
@@ -804,7 +1075,7 @@ class rt {
804
1075
  return this.create(e.public, e.options);
805
1076
  }
806
1077
  }
807
- class ge {
1078
+ class we {
808
1079
  constructor(t, e) {
809
1080
  this._type = "Transfer", this._options = e, this.uuid = S(e), this.name = t.name, this.source = t.source, this.target = t.target;
810
1081
  }
@@ -837,7 +1108,7 @@ class ge {
837
1108
  };
838
1109
  }
839
1110
  static create(t, e) {
840
- const r = new ge(t, e);
1111
+ const r = new we(t, e);
841
1112
  if (this.instances.find((s) => s.uuid === r.uuid))
842
1113
  throw new Error(`duplicate uuid in options ${r.uuid}, Transfer`);
843
1114
  return this.instances.push(r), r;
@@ -873,19 +1144,19 @@ class ge {
873
1144
  return this.create(e.public, e.options);
874
1145
  }
875
1146
  }
876
- function be(u, t, e) {
1147
+ function Ne(u, t, e) {
877
1148
  u.interactions.forEach((r) => t(r, e)), u.groups.forEach((r) => {
878
- r.activities?.forEach((i) => be(i, t, r));
1149
+ r.activities?.forEach((i) => Ne(i, t, r));
879
1150
  });
880
1151
  }
881
- function Ei(u) {
1152
+ function Pi(u) {
882
1153
  const t = [];
883
- return be(u, (e) => t.push(e)), t;
1154
+ return Ne(u, (e) => t.push(e)), t;
884
1155
  }
885
- function Ii(u) {
1156
+ function Di(u) {
886
1157
  return null;
887
1158
  }
888
- class ot {
1159
+ class nt {
889
1160
  constructor(t, e) {
890
1161
  this._type = "BoolAtomData", this._options = e, this.uuid = S(e), this.type = t.type || "atom", this.data = t.data;
891
1162
  }
@@ -914,7 +1185,7 @@ class ot {
914
1185
  };
915
1186
  }
916
1187
  static create(t, e) {
917
- const r = new ot(t, e);
1188
+ const r = new nt(t, e);
918
1189
  if (this.instances.find((s) => s.uuid === r.uuid))
919
1190
  throw new Error(`duplicate uuid in options ${r.uuid}, BoolAtomData`);
920
1191
  return this.instances.push(r), r;
@@ -948,7 +1219,7 @@ class ot {
948
1219
  return this.create(e.public, e.options);
949
1220
  }
950
1221
  }
951
- class nt {
1222
+ class ct {
952
1223
  constructor(t, e) {
953
1224
  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
1225
  }
@@ -989,7 +1260,7 @@ class nt {
989
1260
  };
990
1261
  }
991
1262
  static create(t, e) {
992
- const r = new nt(t, e);
1263
+ const r = new ct(t, e);
993
1264
  if (this.instances.find((s) => s.uuid === r.uuid))
994
1265
  throw new Error(`duplicate uuid in options ${r.uuid}, BoolExpressionData`);
995
1266
  return this.instances.push(r), r;
@@ -1175,21 +1446,21 @@ class R {
1175
1446
  throw new Error(`invalid bool expression type: ${JSON.stringify(this.raw)}`);
1176
1447
  }
1177
1448
  }
1178
- const qe = {
1449
+ const Ge = {
1179
1450
  "&&": "and",
1180
1451
  "||": "or",
1181
1452
  "!": "not"
1182
1453
  };
1183
- function Be(u) {
1454
+ function Ke(u) {
1184
1455
  return { key: u };
1185
1456
  }
1186
- function wt(u, t, e) {
1457
+ function Tt(u, t, e) {
1187
1458
  if (u.type === "LogicalExpression")
1188
1459
  return {
1189
1460
  type: "expression",
1190
- operator: qe[u.operator],
1191
- left: wt(u.left, t, e),
1192
- right: wt(u.right, t, e)
1461
+ operator: Ge[u.operator],
1462
+ left: Tt(u.left, t, e),
1463
+ right: Tt(u.right, t, e)
1193
1464
  };
1194
1465
  if (u.type === "Identifier")
1195
1466
  return {
@@ -1200,17 +1471,17 @@ function wt(u, t, e) {
1200
1471
  return {
1201
1472
  type: "expression",
1202
1473
  operator: "not",
1203
- left: wt(u.argument, t, e)
1474
+ left: Tt(u.argument, t, e)
1204
1475
  };
1205
1476
  throw new Error("unknown ast node type");
1206
1477
  }
1207
- function Ci(u, t = [], e = Be) {
1208
- const r = Oe(t, "name"), i = Me(u, { ecmaVersion: 2020 });
1478
+ function Oi(u, t = [], e = Ke) {
1479
+ const r = Qe(t, "name"), i = De(u, { ecmaVersion: 2020 });
1209
1480
  return new R(
1210
- wt(i.body[0].expression, r, e)
1481
+ Tt(i.body[0].expression, r, e)
1211
1482
  );
1212
1483
  }
1213
- class X {
1484
+ class Y {
1214
1485
  constructor(t, e) {
1215
1486
  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
1487
  }
@@ -1242,7 +1513,7 @@ class X {
1242
1513
  };
1243
1514
  }
1244
1515
  static create(t, e) {
1245
- const r = new X(t, e);
1516
+ const r = new Y(t, e);
1246
1517
  if (this.instances.find((s) => s.uuid === r.uuid))
1247
1518
  throw new Error(`duplicate uuid in options ${r.uuid}, Attributive`);
1248
1519
  return this.instances.push(r), r;
@@ -1278,7 +1549,7 @@ class X {
1278
1549
  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
1550
  }
1280
1551
  }
1281
- class Et {
1552
+ class Ct {
1282
1553
  constructor(t, e) {
1283
1554
  this._type = "Attributives", this._options = e, this.uuid = S(e), this.content = t.content;
1284
1555
  }
@@ -1301,7 +1572,7 @@ class Et {
1301
1572
  };
1302
1573
  }
1303
1574
  static create(t, e) {
1304
- const r = new Et(t, e);
1575
+ const r = new Ct(t, e);
1305
1576
  if (this.instances.find((s) => s.uuid === r.uuid))
1306
1577
  throw new Error(`duplicate uuid in options ${r.uuid}, Attributives`);
1307
1578
  return this.instances.push(r), r;
@@ -1332,24 +1603,24 @@ class Et {
1332
1603
  return this.create(e.public, e.options);
1333
1604
  }
1334
1605
  }
1335
- function Ot(u) {
1606
+ function Vt(u) {
1336
1607
  if (!u) return;
1337
1608
  if (u.raw.type === "atom")
1338
- return ot.create({
1609
+ return nt.create({
1339
1610
  type: "atom",
1340
1611
  data: u.raw.data
1341
1612
  });
1342
1613
  const t = u.raw;
1343
- return nt.create({
1614
+ return ct.create({
1344
1615
  type: "expression",
1345
1616
  operator: t.operator,
1346
- left: Ot(u.left),
1347
- right: Ot(u.right)
1617
+ left: Vt(u.left),
1618
+ right: Vt(u.right)
1348
1619
  });
1349
1620
  }
1350
- function xi(u) {
1351
- return Et.create({
1352
- content: Ot(u)
1621
+ function Fi(u) {
1622
+ return Ct.create({
1623
+ content: Vt(u)
1353
1624
  });
1354
1625
  }
1355
1626
  class Ht {
@@ -1412,7 +1683,7 @@ class Ht {
1412
1683
  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
1684
  }
1414
1685
  }
1415
- class jt {
1686
+ class Gt {
1416
1687
  constructor(t, e) {
1417
1688
  this._type = "DataAttributive", this._options = e, this.uuid = S(e), this.content = t.content, this.name = t.name;
1418
1689
  }
@@ -1438,7 +1709,7 @@ class jt {
1438
1709
  };
1439
1710
  }
1440
1711
  static create(t, e) {
1441
- const r = new jt(t, e);
1712
+ const r = new Gt(t, e);
1442
1713
  if (this.instances.find((s) => s.uuid === r.uuid))
1443
1714
  throw new Error(`duplicate uuid in options ${r.uuid}, DataAttributive`);
1444
1715
  return this.instances.push(r), r;
@@ -1472,7 +1743,7 @@ class jt {
1472
1743
  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
1744
  }
1474
1745
  }
1475
- class Re {
1746
+ class Te {
1476
1747
  constructor(t, e) {
1477
1748
  this._type = "QueryItem", this._options = e, this.uuid = S(e), this.name = t.name, this.value = t.value;
1478
1749
  }
@@ -1500,7 +1771,7 @@ class Re {
1500
1771
  };
1501
1772
  }
1502
1773
  static create(t, e) {
1503
- const r = new Re(t, e);
1774
+ const r = new Te(t, e);
1504
1775
  if (this.instances.find((s) => s.uuid === r.uuid))
1505
1776
  throw new Error(`duplicate uuid in options ${r.uuid}, QueryItem`);
1506
1777
  return this.instances.push(r), r;
@@ -1534,7 +1805,7 @@ class Re {
1534
1805
  return this.create(e.public, e.options);
1535
1806
  }
1536
1807
  }
1537
- class we {
1808
+ class Se {
1538
1809
  constructor(t, e) {
1539
1810
  this._type = "Query", this._options = e, this.uuid = S(e), this.items = t.items;
1540
1811
  }
@@ -1557,7 +1828,7 @@ class we {
1557
1828
  };
1558
1829
  }
1559
1830
  static create(t, e) {
1560
- const r = new we(t, e);
1831
+ const r = new Se(t, e);
1561
1832
  if (this.instances.find((s) => s.uuid === r.uuid))
1562
1833
  throw new Error(`duplicate uuid in options ${r.uuid}, Query`);
1563
1834
  return this.instances.push(r), r;
@@ -1589,7 +1860,7 @@ class we {
1589
1860
  return this.create(e.public, e.options);
1590
1861
  }
1591
1862
  }
1592
- class It {
1863
+ class xt {
1593
1864
  constructor(t, e) {
1594
1865
  this._type = "Action", this._options = e, this.uuid = S(e), this.name = t.name;
1595
1866
  }
@@ -1611,7 +1882,7 @@ class It {
1611
1882
  };
1612
1883
  }
1613
1884
  static create(t, e) {
1614
- const r = new It(t, e);
1885
+ const r = new xt(t, e);
1615
1886
  if (this.instances.find((s) => s.uuid === r.uuid))
1616
1887
  throw new Error(`duplicate uuid in options ${r.uuid}, Action`);
1617
1888
  return this.instances.push(r), r;
@@ -1643,8 +1914,8 @@ class It {
1643
1914
  return this.create(e.public, e.options);
1644
1915
  }
1645
1916
  }
1646
- const We = It.create({ name: "get" });
1647
- class it {
1917
+ const Xe = xt.create({ name: "get" });
1918
+ class st {
1648
1919
  constructor(t, e) {
1649
1920
  this._type = "Gateway", this._options = e, this.uuid = S(e), this.name = t.name;
1650
1921
  }
@@ -1666,7 +1937,7 @@ class it {
1666
1937
  };
1667
1938
  }
1668
1939
  static create(t, e) {
1669
- const r = new it(t, e);
1940
+ const r = new st(t, e);
1670
1941
  if (this.instances.find((s) => s.uuid === r.uuid))
1671
1942
  throw new Error(`duplicate uuid in options ${r.uuid}, Gateway`);
1672
1943
  return this.instances.push(r), r;
@@ -1698,7 +1969,7 @@ class it {
1698
1969
  return this.create(e.public, e.options);
1699
1970
  }
1700
1971
  }
1701
- class Ut {
1972
+ class Kt {
1702
1973
  constructor(t, e) {
1703
1974
  this._type = "Event", this._options = e, this.uuid = S(e), this.name = t.name;
1704
1975
  }
@@ -1720,7 +1991,7 @@ class Ut {
1720
1991
  };
1721
1992
  }
1722
1993
  static create(t, e) {
1723
- const r = new Ut(t, e);
1994
+ const r = new Kt(t, e);
1724
1995
  if (this.instances.find((s) => s.uuid === r.uuid))
1725
1996
  throw new Error(`duplicate uuid in options ${r.uuid}, Event`);
1726
1997
  return this.instances.push(r), r;
@@ -1752,7 +2023,7 @@ class Ut {
1752
2023
  return this.create(e.public, e.options);
1753
2024
  }
1754
2025
  }
1755
- class Y {
2026
+ class z {
1756
2027
  constructor(t, e) {
1757
2028
  this._type = "StateNode", this._options = e, this.uuid = S(e), this.name = t.name, this.computeValue = t.computeValue;
1758
2029
  }
@@ -1780,7 +2051,7 @@ class Y {
1780
2051
  };
1781
2052
  }
1782
2053
  static create(t, e) {
1783
- const r = new Y(t, e);
2054
+ const r = new z(t, e);
1784
2055
  if (this.instances.find((s) => s.uuid === r.uuid))
1785
2056
  throw new Error(`duplicate uuid in options ${r.uuid}, StateNode`);
1786
2057
  return this.instances.push(r), r;
@@ -1815,7 +2086,7 @@ class Y {
1815
2086
  return this.create(e.public, e.options);
1816
2087
  }
1817
2088
  }
1818
- class Gt {
2089
+ class Xt {
1819
2090
  constructor(t, e) {
1820
2091
  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
2092
  }
@@ -1853,7 +2124,7 @@ class Gt {
1853
2124
  };
1854
2125
  }
1855
2126
  static create(t, e) {
1856
- const r = new Gt(t, e);
2127
+ const r = new Xt(t, e);
1857
2128
  if (this.instances.find((s) => s.uuid === r.uuid))
1858
2129
  throw new Error(`duplicate uuid in options ${r.uuid}, StateTransfer`);
1859
2130
  return this.instances.push(r), r;
@@ -1892,7 +2163,7 @@ class Gt {
1892
2163
  return this.create(e.public, e.options);
1893
2164
  }
1894
2165
  }
1895
- class ct {
2166
+ class lt {
1896
2167
  constructor(t, e) {
1897
2168
  this._type = "StateMachine", this._options = e, this.uuid = S(e), this.states = t.states, this.transfers = t.transfers, this.defaultState = t.defaultState;
1898
2169
  }
@@ -1925,7 +2196,7 @@ class ct {
1925
2196
  };
1926
2197
  }
1927
2198
  static create(t, e) {
1928
- const r = new ct(t, e);
2199
+ const r = new lt(t, e);
1929
2200
  if (this.instances.find((s) => s.uuid === r.uuid))
1930
2201
  throw new Error(`duplicate uuid in options ${r.uuid}, StateMachine`);
1931
2202
  return this.instances.push(r), r;
@@ -1961,7 +2232,7 @@ class ct {
1961
2232
  return this.create(e.public, e.options);
1962
2233
  }
1963
2234
  }
1964
- class lt {
2235
+ class ut {
1965
2236
  constructor(t, e) {
1966
2237
  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
2238
  }
@@ -2009,7 +2280,7 @@ class lt {
2009
2280
  };
2010
2281
  }
2011
2282
  static create(t, e) {
2012
- const r = new lt(t, e);
2283
+ const r = new ut(t, e);
2013
2284
  if (this.instances.find((s) => s.uuid === r.uuid))
2014
2285
  throw new Error(`duplicate uuid in options ${r.uuid}, WeightedSummation`);
2015
2286
  return this.instances.push(r), r;
@@ -2051,7 +2322,7 @@ class lt {
2051
2322
  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
2323
  }
2053
2324
  }
2054
- class ut {
2325
+ class dt {
2055
2326
  constructor(t, e) {
2056
2327
  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
2328
  }
@@ -2094,7 +2365,7 @@ class ut {
2094
2365
  };
2095
2366
  }
2096
2367
  static create(t, e) {
2097
- const r = new ut(t, e);
2368
+ const r = new dt(t, e);
2098
2369
  if (this.instances.find((s) => s.uuid === r.uuid))
2099
2370
  throw new Error(`duplicate uuid in options ${r.uuid}, Count`);
2100
2371
  return this.instances.push(r), r;
@@ -2135,7 +2406,7 @@ class ut {
2135
2406
  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
2407
  }
2137
2408
  }
2138
- class dt {
2409
+ class ht {
2139
2410
  constructor(t, e) {
2140
2411
  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
2412
  }
@@ -2168,7 +2439,7 @@ class dt {
2168
2439
  };
2169
2440
  }
2170
2441
  static create(t, e) {
2171
- const r = new dt(t, e);
2442
+ const r = new ht(t, e);
2172
2443
  if (this.instances.find((s) => s.uuid === r.uuid))
2173
2444
  throw new Error(`duplicate uuid in options ${r.uuid}, Summation`);
2174
2445
  return this.instances.push(r), r;
@@ -2203,7 +2474,7 @@ class dt {
2203
2474
  return this.create(e.public, e.options);
2204
2475
  }
2205
2476
  }
2206
- class ht {
2477
+ class pt {
2207
2478
  constructor(t, e) {
2208
2479
  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
2480
  }
@@ -2236,7 +2507,7 @@ class ht {
2236
2507
  };
2237
2508
  }
2238
2509
  static create(t, e) {
2239
- const r = new ht(t, e);
2510
+ const r = new pt(t, e);
2240
2511
  if (this.instances.find((s) => s.uuid === r.uuid))
2241
2512
  throw new Error(`duplicate uuid in options ${r.uuid}, Average`);
2242
2513
  return this.instances.push(r), r;
@@ -2271,7 +2542,7 @@ class ht {
2271
2542
  return this.create(e.public, e.options);
2272
2543
  }
2273
2544
  }
2274
- class pt {
2545
+ class ft {
2275
2546
  constructor(t, e) {
2276
2547
  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
2548
  }
@@ -2319,7 +2590,7 @@ class pt {
2319
2590
  };
2320
2591
  }
2321
2592
  static create(t, e) {
2322
- const r = new pt(t, e);
2593
+ const r = new ft(t, e);
2323
2594
  if (this.instances.find((s) => s.uuid === r.uuid))
2324
2595
  throw new Error(`duplicate uuid in options ${r.uuid}, Every`);
2325
2596
  return this.instances.push(r), r;
@@ -2356,7 +2627,7 @@ class pt {
2356
2627
  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
2628
  }
2358
2629
  }
2359
- class ft {
2630
+ class mt {
2360
2631
  constructor(t, e) {
2361
2632
  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
2633
  }
@@ -2404,7 +2675,7 @@ class ft {
2404
2675
  };
2405
2676
  }
2406
2677
  static create(t, e) {
2407
- const r = new ft(t, e);
2678
+ const r = new mt(t, e);
2408
2679
  if (this.instances.find((s) => s.uuid === r.uuid))
2409
2680
  throw new Error(`duplicate uuid in options ${r.uuid}, Any`);
2410
2681
  return this.instances.push(r), r;
@@ -2446,7 +2717,7 @@ class ft {
2446
2717
  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
2718
  }
2448
2719
  }
2449
- class Ct {
2720
+ class Mt {
2450
2721
  constructor(t, e) {
2451
2722
  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
2723
  }
@@ -2479,7 +2750,7 @@ class Ct {
2479
2750
  };
2480
2751
  }
2481
2752
  static create(t, e) {
2482
- const r = new Ct(t, e);
2753
+ const r = new Mt(t, e);
2483
2754
  if (this.instances.find((s) => s.uuid === r.uuid))
2484
2755
  throw new Error(`duplicate uuid in options ${r.uuid}, Transform`);
2485
2756
  return this.instances.push(r), r;
@@ -2516,7 +2787,7 @@ class Ct {
2516
2787
  return typeof r.callback == "string" && r.callback.startsWith("func::") && (r.callback = new Function("return " + r.callback.substring(6))()), this.create(r, e.options);
2517
2788
  }
2518
2789
  }
2519
- class mt {
2790
+ class yt {
2520
2791
  constructor(t, e) {
2521
2792
  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
2793
  }
@@ -2554,7 +2825,7 @@ class mt {
2554
2825
  };
2555
2826
  }
2556
2827
  static create(t, e) {
2557
- const r = new mt(t, e);
2828
+ const r = new yt(t, e);
2558
2829
  if (this.instances.find((s) => s.uuid === r.uuid))
2559
2830
  throw new Error(`duplicate uuid in options ${r.uuid}, RealTimeValue`);
2560
2831
  return this.instances.push(r), r;
@@ -2589,7 +2860,7 @@ class mt {
2589
2860
  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
2861
  }
2591
2862
  }
2592
- class Kt {
2863
+ class Yt {
2593
2864
  constructor(t, e) {
2594
2865
  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
2866
  }
@@ -2640,7 +2911,7 @@ class Kt {
2640
2911
  };
2641
2912
  }
2642
2913
  static create(t, e) {
2643
- const r = new Kt(t, e);
2914
+ const r = new Yt(t, e);
2644
2915
  if (this.instances.find((s) => s.uuid === r.uuid))
2645
2916
  throw new Error(`duplicate uuid in options ${r.uuid}, PayloadItem`);
2646
2917
  return this.instances.push(r), r;
@@ -2679,7 +2950,7 @@ class Kt {
2679
2950
  return this.create(e.public, e.options);
2680
2951
  }
2681
2952
  }
2682
- class Xt {
2953
+ class zt {
2683
2954
  constructor(t, e) {
2684
2955
  this._type = "Payload", this._options = e, this.uuid = S(e), this.items = t.items || [];
2685
2956
  }
@@ -2703,7 +2974,7 @@ class Xt {
2703
2974
  };
2704
2975
  }
2705
2976
  static create(t, e) {
2706
- const r = new Xt(t, e);
2977
+ const r = new zt(t, e);
2707
2978
  if (this.instances.find((s) => s.uuid === r.uuid))
2708
2979
  throw new Error(`duplicate uuid in options ${r.uuid}, Payload`);
2709
2980
  return this.instances.push(r), r;
@@ -2735,7 +3006,7 @@ class Xt {
2735
3006
  return this.create(e.public, e.options);
2736
3007
  }
2737
3008
  }
2738
- class Yt {
3009
+ class Zt {
2739
3010
  constructor(t, e) {
2740
3011
  this._type = "SideEffect", this._options = e, this.uuid = S(e), this.name = t.name, this.handle = t.handle;
2741
3012
  }
@@ -2763,7 +3034,7 @@ class Yt {
2763
3034
  };
2764
3035
  }
2765
3036
  static create(t, e) {
2766
- const r = new Yt(t, e);
3037
+ const r = new Zt(t, e);
2767
3038
  if (this.instances.find((s) => s.uuid === r.uuid))
2768
3039
  throw new Error(`duplicate uuid in options ${r.uuid}, SideEffect`);
2769
3040
  return this.instances.push(r), r;
@@ -2797,24 +3068,24 @@ class Yt {
2797
3068
  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
3069
  }
2799
3070
  }
2800
- function Ft(u) {
3071
+ function Qt(u) {
2801
3072
  if (!u) return;
2802
3073
  if (u.raw.type === "atom")
2803
- return ot.create({
3074
+ return nt.create({
2804
3075
  type: "atom",
2805
3076
  data: u.raw.data
2806
3077
  });
2807
3078
  const t = u.raw;
2808
- return nt.create({
3079
+ return ct.create({
2809
3080
  type: "expression",
2810
3081
  operator: t.operator,
2811
- left: Ft(u.left),
2812
- right: Ft(u.right)
3082
+ left: Qt(u.left),
3083
+ right: Qt(u.right)
2813
3084
  });
2814
3085
  }
2815
- class xt {
3086
+ class $t {
2816
3087
  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;
3088
+ 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
3089
  }
2819
3090
  static {
2820
3091
  this.isKlass = !0;
@@ -2835,7 +3106,7 @@ class xt {
2835
3106
  };
2836
3107
  }
2837
3108
  static create(t, e) {
2838
- const r = new xt(t, e);
3109
+ const r = new $t(t, e);
2839
3110
  if (this.instances.find((s) => s.uuid === r.uuid))
2840
3111
  throw new Error(`duplicate uuid in options ${r.uuid}, Conditions`);
2841
3112
  return this.instances.push(r), r;
@@ -2866,7 +3137,7 @@ class xt {
2866
3137
  return this.create(e.public, e.options);
2867
3138
  }
2868
3139
  }
2869
- class zt {
3140
+ class te {
2870
3141
  constructor(t, e) {
2871
3142
  this._type = "DataAttributives", this._options = e, this.uuid = S(e), this.content = t.content;
2872
3143
  }
@@ -2889,7 +3160,7 @@ class zt {
2889
3160
  };
2890
3161
  }
2891
3162
  static create(t, e) {
2892
- const r = new zt(t, e);
3163
+ const r = new te(t, e);
2893
3164
  if (this.instances.find((s) => s.uuid === r.uuid))
2894
3165
  throw new Error(`duplicate uuid in options ${r.uuid}, DataAttributives`);
2895
3166
  return this.instances.push(r), r;
@@ -2920,42 +3191,42 @@ class zt {
2920
3191
  return this.create(e.public, e.options);
2921
3192
  }
2922
3193
  }
2923
- const Je = [
3194
+ const Ye = [
2924
3195
  C,
2925
3196
  P,
2926
3197
  T,
2927
- Wt,
2928
- Jt,
2929
- X,
2930
- Ht,
2931
3198
  jt,
2932
- It,
2933
- it,
2934
3199
  Ut,
2935
3200
  Y,
3201
+ Ht,
2936
3202
  Gt,
2937
- ct,
3203
+ xt,
3204
+ st,
3205
+ Kt,
3206
+ z,
3207
+ Xt,
2938
3208
  lt,
2939
3209
  ut,
2940
3210
  dt,
2941
3211
  ht,
2942
3212
  pt,
2943
3213
  ft,
2944
- Ct,
2945
3214
  mt,
2946
- Kt,
2947
- Xt,
3215
+ Mt,
3216
+ yt,
2948
3217
  Yt,
2949
- Bt,
2950
- ot,
3218
+ zt,
3219
+ Zt,
3220
+ Jt,
2951
3221
  nt,
2952
- xt,
2953
- zt
3222
+ ct,
3223
+ $t,
3224
+ te
2954
3225
  ];
2955
- Je.forEach((u) => {
2956
- u && u.displayName && Fe(u.displayName, u);
3226
+ Ye.forEach((u) => {
3227
+ u && u.displayName && Le(u.displayName, u);
2957
3228
  });
2958
- class Zt {
3229
+ class ee {
2959
3230
  constructor(t, e) {
2960
3231
  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
3232
  }
@@ -3018,7 +3289,7 @@ class Zt {
3018
3289
  };
3019
3290
  }
3020
3291
  static create(t, e) {
3021
- const r = new Zt(t, e);
3292
+ const r = new ee(t, e);
3022
3293
  if (this.instances.find((s) => s.uuid === r.uuid))
3023
3294
  throw new Error(`duplicate uuid in options ${r.uuid}, Custom`);
3024
3295
  return this.instances.push(r), r;
@@ -3062,7 +3333,7 @@ class Zt {
3062
3333
  }), this.create(r, e.options);
3063
3334
  }
3064
3335
  }
3065
- class Ne {
3336
+ class ve {
3066
3337
  constructor(t = [], e = []) {
3067
3338
  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
3339
  }
@@ -3273,8 +3544,8 @@ class Ne {
3273
3544
  return null;
3274
3545
  }
3275
3546
  }
3276
- function Mi({ name: u, isRef: t = !1 }, e) {
3277
- return X.create({
3547
+ function Vi({ name: u, isRef: t = !1 }, e) {
3548
+ return Y.create({
3278
3549
  name: u,
3279
3550
  content: u ? new Function("user", `return user.roles.includes('${u}')`) : function() {
3280
3551
  return !0;
@@ -3286,7 +3557,7 @@ function g(u, t) {
3286
3557
  if (!u)
3287
3558
  throw new Error(t);
3288
3559
  }
3289
- function $t(u, t, e) {
3560
+ function Dt(u, t, e) {
3290
3561
  const r = [...t];
3291
3562
  let i = u, s;
3292
3563
  const a = r.pop();
@@ -3646,7 +3917,7 @@ class m {
3646
3917
  );
3647
3918
  }
3648
3919
  }
3649
- class He {
3920
+ class ze {
3650
3921
  constructor(t, e, r, i) {
3651
3922
  this.recordName = t, this.map = e, this.data = r, this.fromRelation = i;
3652
3923
  }
@@ -3682,7 +3953,7 @@ class M {
3682
3953
  e,
3683
3954
  N,
3684
3955
  new x(h, e, r.attributeQuery || [], s, a),
3685
- new He(h, e, r.modifier),
3956
+ new ze(h, e, r.modifier),
3686
3957
  i,
3687
3958
  s,
3688
3959
  a,
@@ -3776,7 +4047,7 @@ class _ {
3776
4047
  }), this.parentLinkQueryTree && (t[f] = this.parentLinkQueryTree.getData()), t;
3777
4048
  }
3778
4049
  }
3779
- const f = "&", je = "*";
4050
+ const f = "&", Ze = "*";
3780
4051
  class x {
3781
4052
  constructor(t, e, r = [], i, s, a) {
3782
4053
  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 +4060,7 @@ class x {
3789
4060
  this.parentLinkRecordQuery = M.create(y.linkName, this.map, d, void 0);
3790
4061
  return;
3791
4062
  }
3792
- if (l === je) {
4063
+ if (l === Ze) {
3793
4064
  o = new Set(this.map.getRecordInfo(this.recordName).valueAttributes.map((y) => y.attributeName));
3794
4065
  return;
3795
4066
  }
@@ -3798,10 +4069,10 @@ class x {
3798
4069
  let y = l, N = d;
3799
4070
  if (p.isLinkFiltered()) {
3800
4071
  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;
4072
+ const k = d.matchExpression, F = p.getLinkInfo().getBaseLinkInfo(), oe = new m(F.name, this.map, p.getMatchExpression()).rebase(p.isRecordSource() ? "target" : "source"), Pe = k ? oe.and(k.data) : oe;
3802
4073
  N = {
3803
4074
  ...d,
3804
- matchExpression: xe.data
4075
+ matchExpression: Pe.data
3805
4076
  };
3806
4077
  }
3807
4078
  const b = M.create(p.recordName, this.map, N, void 0, this.recordName, y, h, !1, l);
@@ -3919,7 +4190,7 @@ class x {
3919
4190
  return this.parentLinkRecordQuery ? new x(this.recordName, this.map, this.data, this.parentRecord, this.attributeName, !0) : this;
3920
4191
  }
3921
4192
  }
3922
- function Ue(u) {
4193
+ function tr(u) {
3923
4194
  const t = [];
3924
4195
  return u.forEach((e) => t.push(...Array.isArray(e) ? e : [e])), t;
3925
4196
  }
@@ -3929,7 +4200,7 @@ class L {
3929
4200
  const s = this.map.getRecordInfo(e);
3930
4201
  this.recordName = s.isFilteredEntity || s.isFilteredRelation ? s.resolvedBaseRecordName : e;
3931
4202
  const [a, o, n] = this.map.groupAttributes(this.recordName, r ? Object.keys(r) : []);
3932
- this.relatedEntitiesData = Ue(o.map(
4203
+ this.relatedEntitiesData = tr(o.map(
3933
4204
  (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
4205
  )), this.valueAttributes = a, this.entityIdAttributes = n;
3935
4206
  const c = this.map.getRecordInfo(this.recordName);
@@ -4006,7 +4277,7 @@ class L {
4006
4277
  }), r;
4007
4278
  }
4008
4279
  }
4009
- class Ge {
4280
+ class er {
4010
4281
  constructor(t, e) {
4011
4282
  this.map = t, this.queryAgent = e, this.dependencies = /* @__PURE__ */ new Map();
4012
4283
  }
@@ -4232,7 +4503,7 @@ class Ge {
4232
4503
  }
4233
4504
  }
4234
4505
  }
4235
- class Ke {
4506
+ class rr {
4236
4507
  constructor() {
4237
4508
  this.aliasToPath = /* @__PURE__ */ new Map(), this.pathStrToAlias = /* @__PURE__ */ new Map(), this.aliasPlaceholder = 0;
4238
4509
  }
@@ -4246,24 +4517,24 @@ class Ke {
4246
4517
  return this.aliasToPath.get(t);
4247
4518
  }
4248
4519
  }
4249
- const Te = ":root";
4250
- class Tt {
4520
+ const ke = ":root";
4521
+ class vt {
4251
4522
  constructor(t, e, r = []) {
4252
4523
  this.label = t, this.parent = e, this.stack = r;
4253
4524
  }
4254
4525
  concat(t) {
4255
- return new Tt(this.label, this.parent, [...this.stack, t]);
4526
+ return new vt(this.label, this.parent, [...this.stack, t]);
4256
4527
  }
4257
4528
  getStack(t) {
4258
4529
  return [...this.stack];
4259
4530
  }
4260
4531
  spawn(t) {
4261
- return new Tt(t, this);
4532
+ return new vt(t, this);
4262
4533
  }
4263
4534
  }
4264
- class Xe {
4535
+ class ir {
4265
4536
  constructor(t) {
4266
- this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(Te, t), this.recursiveSaveLabelledRecordQuery(t);
4537
+ this.recordQuery = t, this.recordQueryByName = /* @__PURE__ */ new Map(), this.set(ke, t), this.recursiveSaveLabelledRecordQuery(t);
4267
4538
  }
4268
4539
  recursiveSaveLabelledRecordQuery(t) {
4269
4540
  t.attributeQuery?.relatedRecords.forEach((e) => {
@@ -4277,9 +4548,9 @@ class Xe {
4277
4548
  return this.recordQueryByName.get(t);
4278
4549
  }
4279
4550
  }
4280
- class Ye {
4551
+ class sr {
4281
4552
  constructor(t, e) {
4282
- this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (r) => "?"), this.filteredEntityManager = new Ge(t, this), this.initializeFilteredEntityDependencies();
4553
+ this.map = t, this.database = e, this.getPlaceholder = e.getPlaceholder || (() => (r) => "?"), this.filteredEntityManager = new er(t, this), this.initializeFilteredEntityDependencies();
4283
4554
  }
4284
4555
  /**
4285
4556
  * 初始化所有 filtered entity 的依赖关系
@@ -4331,15 +4602,15 @@ ${b}
4331
4602
  const s = {};
4332
4603
  return Object.entries(i).forEach(([a, o]) => {
4333
4604
  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);
4605
+ n.length === 1 && e.includes(n[0]) && typeof o == "string" && (o = JSON.parse(o)), o !== null && Dt(s, n, o);
4335
4606
  }), s;
4336
4607
  });
4337
4608
  }
4338
4609
  // 查 entity 和 查 relation 都是一样的。具体在 entityQuery 里面区别。
4339
4610
  // TODO 为了性能,也可以把信息丢到客户端,然客户端去结构化???
4340
4611
  // CAUTION findRelatedRecords 中的递归调用会使得 includeRelationData 变为 true
4341
- async findRecords(t, e = "", r, i = new Tt(Te)) {
4342
- if (r || (r = new Xe(t)), t.goto) {
4612
+ async findRecords(t, e = "", r, i = new vt(ke)) {
4613
+ if (r || (r = new ir(t)), t.goto) {
4343
4614
  if (t.exit && await t.exit(i))
4344
4615
  return [];
4345
4616
  const l = r.get(t.goto);
@@ -4378,7 +4649,7 @@ ${b}
4378
4649
  value: ["=", b]
4379
4650
  })
4380
4651
  }), F = t.label ? c.concat(N) : c;
4381
- $t(
4652
+ Dt(
4382
4653
  N,
4383
4654
  [l.alias || l.attributeName, f, h.attributeName],
4384
4655
  await this.findRecords(
@@ -4465,8 +4736,8 @@ ${b}
4465
4736
  if (N)
4466
4737
  for (let b of N.attributeQuery.xToManyRecords)
4467
4738
  for (let k of p) {
4468
- const F = k[f].id, ie = d.label ? y.concat(k) : y;
4469
- $t(
4739
+ const F = k[f].id, ae = d.label ? y.concat(k) : y;
4740
+ Dt(
4470
4741
  k,
4471
4742
  [f, b.attributeName],
4472
4743
  await this.findXToManyRelatedRecords(
@@ -4475,7 +4746,7 @@ ${b}
4475
4746
  F,
4476
4747
  b,
4477
4748
  s,
4478
- ie
4749
+ ae
4479
4750
  )
4480
4751
  );
4481
4752
  }
@@ -4548,7 +4819,7 @@ ${b}
4548
4819
  return t ? `${t}___` : "";
4549
4820
  }
4550
4821
  buildSelectClause(t, e = "") {
4551
- const r = new Ke();
4822
+ const r = new rr();
4552
4823
  return t.length ? [t.map(({ tableAliasAndField: s, attribute: a, nameContext: o }) => {
4553
4824
  const n = [
4554
4825
  `${this.withPrefix(e)}${o[0]}`,
@@ -5120,9 +5391,9 @@ WHERE "${s.idField}" = ${l()}
5120
5391
  return p ? [N, ...p] : void 0;
5121
5392
  }
5122
5393
  }
5123
- class ze {
5394
+ class ar {
5124
5395
  constructor(t, e) {
5125
- this.map = t, this.database = e, this.agent = new Ye(t, e);
5396
+ this.map = t, this.database = e, this.agent = new sr(t, e);
5126
5397
  }
5127
5398
  async findOne(t, e, r = {}, i) {
5128
5399
  const s = {
@@ -5191,7 +5462,7 @@ class ze {
5191
5462
  return this.map.getInfo(t, e).recordName;
5192
5463
  }
5193
5464
  }
5194
- class st {
5465
+ class at {
5195
5466
  constructor(t, e) {
5196
5467
  this.name = t, this.map = e, this.data = this.map.data.records[t];
5197
5468
  }
@@ -5262,7 +5533,7 @@ class st {
5262
5533
  return this.data.matchExpression;
5263
5534
  }
5264
5535
  get filteredBy() {
5265
- return this.data.filteredBy?.map((t) => new st(t, this.map));
5536
+ return this.data.filteredBy?.map((t) => new at(t, this.map));
5266
5537
  }
5267
5538
  get isFilteredEntity() {
5268
5539
  return this.data?.isFilteredEntity;
@@ -5280,7 +5551,7 @@ class st {
5280
5551
  return this.data?.resolvedMatchExpression;
5281
5552
  }
5282
5553
  }
5283
- class St {
5554
+ class kt {
5284
5555
  constructor(t, e, r, i = !0) {
5285
5556
  this.name = t, this.data = e, this.map = r, this.isFromSource = i;
5286
5557
  }
@@ -5309,10 +5580,10 @@ class St {
5309
5580
  return this.data.sourceRecord;
5310
5581
  }
5311
5582
  get sourceRecordInfo() {
5312
- return new st(this.data.sourceRecord, this.map);
5583
+ return new at(this.data.sourceRecord, this.map);
5313
5584
  }
5314
5585
  get targetRecordInfo() {
5315
- return new st(this.data.targetRecord, this.map);
5586
+ return new at(this.data.targetRecord, this.map);
5316
5587
  }
5317
5588
  get targetRecord() {
5318
5589
  return this.data.targetRecord;
@@ -5368,7 +5639,7 @@ class St {
5368
5639
  getBaseLinkInfo() {
5369
5640
  g(this.isFilteredRelation(), "only filtered relation can get base link info");
5370
5641
  const t = this.data.baseLinkName;
5371
- return new St(t, this.map.data.links[t], this.map);
5642
+ return new kt(t, this.map.data.links[t], this.map);
5372
5643
  }
5373
5644
  getMatchExpression() {
5374
5645
  if (this.isFilteredRelation())
@@ -5382,7 +5653,7 @@ class St {
5382
5653
  return g(this.isFilteredRelation(), "only filtered relation can get resolved record name"), this.data.resolvedBaseRecordName;
5383
5654
  }
5384
5655
  }
5385
- class Ze {
5656
+ class or {
5386
5657
  constructor(t) {
5387
5658
  this.data = t;
5388
5659
  }
@@ -5396,7 +5667,7 @@ class Ze {
5396
5667
  return this.data.records[t].attributes[this.getAttributeAndSymmetricDirection(e)[0]];
5397
5668
  }
5398
5669
  getRecordInfo(t) {
5399
- return new st(t, this);
5670
+ return new at(t, this);
5400
5671
  }
5401
5672
  getInfo(t, e) {
5402
5673
  const r = this.getInfoByPath([t, ...e.split(".")]);
@@ -5407,10 +5678,10 @@ class Ze {
5407
5678
  }
5408
5679
  getLinkInfo(t, e) {
5409
5680
  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);
5681
+ return g(!!i, `cannot find relation ${t} ${r}`), new kt(i, this.data.links[i], this, !!s);
5411
5682
  }
5412
5683
  getLinkInfoByName(t) {
5413
- return g(!!this.data.links[t], `cannot find link ${t}`), new St(t, this.data.links[t], this);
5684
+ return g(!!this.data.links[t], `cannot find link ${t}`), new kt(t, this.data.links[t], this);
5414
5685
  }
5415
5686
  getInfoByPath(t) {
5416
5687
  const [e, ...r] = t;
@@ -5578,7 +5849,7 @@ class Ze {
5578
5849
  return i.join(".");
5579
5850
  }
5580
5851
  }
5581
- function tr(u) {
5852
+ function nr(u) {
5582
5853
  const t = /* @__PURE__ */ new Map();
5583
5854
  for (const e of u)
5584
5855
  if (e.inputEntities)
@@ -5589,7 +5860,7 @@ function tr(u) {
5589
5860
  }
5590
5861
  return t;
5591
5862
  }
5592
- function er(u) {
5863
+ function cr(u) {
5593
5864
  const t = /* @__PURE__ */ new Map();
5594
5865
  for (const e of u) {
5595
5866
  const r = e.name || `${e.source.name}_${e.sourceProperty}_${e.targetProperty}_${e.target.name}`;
@@ -5603,46 +5874,46 @@ function er(u) {
5603
5874
  }
5604
5875
  return t;
5605
5876
  }
5606
- function rr(u, t) {
5607
- const e = new Ne(u, t), r = tr(u), i = er(t);
5608
- return oe(
5877
+ function lr(u, t) {
5878
+ const e = new ve(u, t), r = nr(u), i = cr(t);
5879
+ return le(
5609
5880
  u,
5610
5881
  e,
5611
5882
  r,
5612
5883
  "entity"
5613
- ), oe(
5884
+ ), le(
5614
5885
  t,
5615
5886
  e,
5616
5887
  i,
5617
5888
  "relation"
5618
5889
  ), e.getAll();
5619
5890
  }
5620
- function oe(u, t, e, r) {
5891
+ function le(u, t, e, r) {
5621
5892
  const i = u.filter((s) => {
5622
- const a = gt(s);
5893
+ const a = bt(s);
5623
5894
  return a && a.length > 0;
5624
5895
  });
5625
5896
  if (i.length !== 0)
5626
5897
  for (const s of i)
5627
- ir(
5898
+ ur(
5628
5899
  s,
5629
5900
  t,
5630
5901
  r,
5631
5902
  e
5632
5903
  );
5633
5904
  }
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(
5905
+ function ur(u, t, e, r) {
5906
+ const i = e === "entity", a = `__${Z(u)}_input_${e}`, o = i ? t.getEntityByName(u.name) : t.getRelationByName(u.name), [n, c] = mr(
5636
5907
  o,
5637
5908
  a,
5638
5909
  r,
5639
5910
  t
5640
5911
  );
5641
5912
  t.replace(n, u), c !== n && t.add(c);
5642
- const l = gt(u);
5913
+ const l = bt(u);
5643
5914
  if (l)
5644
5915
  for (const d of l)
5645
- sr(
5916
+ dr(
5646
5917
  d,
5647
5918
  c,
5648
5919
  a,
@@ -5650,22 +5921,22 @@ function ir(u, t, e, r) {
5650
5921
  i
5651
5922
  );
5652
5923
  }
5653
- function sr(u, t, e, r, i) {
5654
- const [s, a] = lr(
5924
+ function dr(u, t, e, r, i) {
5925
+ const [s, a] = yr(
5655
5926
  u,
5656
5927
  t,
5657
5928
  e
5658
5929
  );
5659
5930
  if (!i && s === u)
5660
5931
  return;
5661
- const o = z(a), n = i ? r.getEntityByName(o) : r.getRelationByName(o);
5932
+ const o = Z(a), n = i ? r.getEntityByName(o) : r.getRelationByName(o);
5662
5933
  n && r.replace(s, n);
5663
5934
  }
5664
- function ar(u, t) {
5665
- const e = /* @__PURE__ */ new Map(), r = gt(u);
5935
+ function hr(u, t) {
5936
+ const e = /* @__PURE__ */ new Map(), r = bt(u);
5666
5937
  if (r && r.length > 0)
5667
5938
  for (const i of r) {
5668
- const s = z(i), a = [...t.get(s) || []], o = e.get(s) || [];
5939
+ const s = Z(i), a = [...t.get(s) || []], o = e.get(s) || [];
5669
5940
  for (o.push(s), e.set(s, o); a.length; ) {
5670
5941
  const n = a.shift(), c = e.get(n) || [];
5671
5942
  c.push(...o), e.set(n, c);
@@ -5675,27 +5946,27 @@ function ar(u, t) {
5675
5946
  }
5676
5947
  return e;
5677
5948
  }
5678
- function or(u, t, e) {
5679
- const r = ar(t, e);
5949
+ function pr(u, t, e) {
5950
+ const r = hr(t, e);
5680
5951
  return T.create({
5681
5952
  name: u,
5682
5953
  type: "json",
5683
5954
  defaultValue: (i, s) => {
5684
- const a = gt(t), n = (r.get(s) || []).filter(
5685
- (c) => a.some((l) => z(l) === c)
5955
+ const a = bt(t), n = (r.get(s) || []).filter(
5956
+ (c) => a.some((l) => Z(l) === c)
5686
5957
  );
5687
5958
  return n.length > 0 ? n : [s];
5688
5959
  }
5689
5960
  });
5690
5961
  }
5691
- function nr(u, t, e) {
5692
- const r = gt(u), i = [], s = /* @__PURE__ */ new Map(), a = {};
5962
+ function fr(u, t, e) {
5963
+ const r = bt(u), i = [], s = /* @__PURE__ */ new Map(), a = {};
5693
5964
  for (const o of r) {
5694
5965
  let n = o;
5695
- if (yt(n))
5966
+ if (gt(n))
5696
5967
  for (; n.baseEntity && n.properties.length === 0; )
5697
5968
  n = n.baseEntity;
5698
- else if (dr(n))
5969
+ else if (br(n))
5699
5970
  for (; n.baseRelation && n.properties.length === 0; )
5700
5971
  n = n.baseRelation;
5701
5972
  const c = Object.fromEntries(n.properties.map((h) => [h.name, h]));
@@ -5725,13 +5996,13 @@ function nr(u, t, e) {
5725
5996
  }
5726
5997
  return i;
5727
5998
  }
5728
- function cr(u, t, e, r) {
5729
- const i = or(
5999
+ function mr(u, t, e, r) {
6000
+ const i = pr(
5730
6001
  t,
5731
6002
  u,
5732
6003
  e
5733
6004
  ), s = [
5734
- ...nr(
6005
+ ...fr(
5735
6006
  u,
5736
6007
  e,
5737
6008
  r
@@ -5739,7 +6010,7 @@ function cr(u, t, e, r) {
5739
6010
  i,
5740
6011
  ...u.properties
5741
6012
  ];
5742
- if (yt(u)) {
6013
+ if (gt(u)) {
5743
6014
  const a = r.getEntityByName(u.name), o = C.create({
5744
6015
  name: a.name
5745
6016
  });
@@ -5777,7 +6048,7 @@ function cr(u, t, e, r) {
5777
6048
  properties: s
5778
6049
  }), o.baseRelation = n, o.sourceProperty = a.sourceProperty, o.targetProperty = a.targetProperty, o.matchExpression = m.fromArray(
5779
6050
  a.inputRelations.map((l) => {
5780
- const d = z(l);
6051
+ const d = Z(l);
5781
6052
  return {
5782
6053
  key: t,
5783
6054
  value: ["contains", d]
@@ -5789,8 +6060,8 @@ function cr(u, t, e, r) {
5789
6060
  return [o, n || o];
5790
6061
  }
5791
6062
  }
5792
- function lr(u, t, e) {
5793
- if (yt(u)) {
6063
+ function yr(u, t, e) {
6064
+ if (gt(u)) {
5794
6065
  const r = u, i = t;
5795
6066
  let s = r;
5796
6067
  if (r.baseEntity)
@@ -5802,8 +6073,8 @@ function lr(u, t, e) {
5802
6073
  value: ["contains", r.name]
5803
6074
  }), [a, s];
5804
6075
  } else {
5805
- const r = u, i = t, s = z(r);
5806
- return r.baseRelation ? [r, ur(r)] : [P.create({
6076
+ const r = u, i = t, s = Z(r);
6077
+ return r.baseRelation ? [r, gr(r)] : [P.create({
5807
6078
  name: s,
5808
6079
  baseRelation: i,
5809
6080
  sourceProperty: r.sourceProperty,
@@ -5815,25 +6086,25 @@ function lr(u, t, e) {
5815
6086
  }), r];
5816
6087
  }
5817
6088
  }
5818
- function ur(u) {
6089
+ function gr(u) {
5819
6090
  let t = u;
5820
6091
  for (; t.baseRelation; )
5821
6092
  t = t.baseRelation;
5822
6093
  return t;
5823
6094
  }
5824
- function yt(u) {
6095
+ function gt(u) {
5825
6096
  return "inputEntities" in u || !("sourceProperty" in u);
5826
6097
  }
5827
- function dr(u) {
6098
+ function br(u) {
5828
6099
  return "sourceProperty" in u;
5829
6100
  }
5830
- function gt(u) {
5831
- return yt(u) ? u.inputEntities || [] : u.inputRelations || [];
6101
+ function bt(u) {
6102
+ return gt(u) ? u.inputEntities || [] : u.inputRelations || [];
5832
6103
  }
5833
- function z(u) {
5834
- return yt(u), u.name;
6104
+ function Z(u) {
6105
+ return gt(u), u.name;
5835
6106
  }
5836
- class hr {
6107
+ class Rr {
5837
6108
  constructor(t, e, r, i = []) {
5838
6109
  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
6110
  }
@@ -5928,8 +6199,8 @@ class hr {
5928
6199
  }
5929
6200
  ];
5930
6201
  }));
5931
- e && g(!r.source && !r.target, "source and target is reserved name for relation attributes"), r[ne] = {
5932
- name: ne,
6202
+ e && g(!r.source && !r.target, "source and target is reserved name for relation attributes"), r[ue] = {
6203
+ name: ue,
5933
6204
  type: "id",
5934
6205
  fieldType: this.database.mapToDBFieldType("pk")
5935
6206
  };
@@ -6112,7 +6383,7 @@ class hr {
6112
6383
  * 统一处理 merged entities 和 merged relations
6113
6384
  */
6114
6385
  processMergedItems() {
6115
- const t = rr(
6386
+ const t = lr(
6116
6387
  this.entities,
6117
6388
  this.relations
6118
6389
  );
@@ -6181,8 +6452,8 @@ class hr {
6181
6452
  buildTables() {
6182
6453
  Object.entries(this.map.records).forEach(([t, e]) => {
6183
6454
  this.tables[e.table] || (this.tables[e.table] = { columns: {
6184
- [at]: {
6185
- name: at,
6455
+ [ot]: {
6456
+ name: ot,
6186
6457
  type: "pk",
6187
6458
  fieldType: this.database.mapToDBFieldType("pk")
6188
6459
  }
@@ -6226,8 +6497,8 @@ ${Object.values(this.tables[t].columns).map((r) => ` "${r.name}" ${r.fieldTyp
6226
6497
  return this.fieldCounter++, this.fieldNameMap.set(t, i), this.usedFieldNames.add(i), i;
6227
6498
  }
6228
6499
  }
6229
- const tt = "_System_", q = "_Dictionary_", ne = "id", at = "_rowId", pr = C.create({
6230
- name: tt,
6500
+ const et = "_System_", q = "_Dictionary_", ue = "id", ot = "_rowId", wr = C.create({
6501
+ name: et,
6231
6502
  properties: [
6232
6503
  T.create({
6233
6504
  name: "concept",
@@ -6245,7 +6516,7 @@ const tt = "_System_", q = "_Dictionary_", ne = "id", at = "_rowId", pr = C.crea
6245
6516
  collection: !1
6246
6517
  })
6247
6518
  ]
6248
- }), fr = C.create({
6519
+ }), Nr = C.create({
6249
6520
  name: q,
6250
6521
  properties: [
6251
6522
  T.create({
@@ -6259,8 +6530,8 @@ const tt = "_System_", q = "_Dictionary_", ne = "id", at = "_rowId", pr = C.crea
6259
6530
  collection: !1
6260
6531
  })
6261
6532
  ]
6262
- }), $i = 0, Pt = 1, Pi = 2;
6263
- class mr {
6533
+ }), Qi = 0, Ot = 1, Li = 2;
6534
+ class Tr {
6264
6535
  constructor(t, e) {
6265
6536
  this.controller = t, this.scheduler = e, this.sourceMaps = [], this.sourceMapTree = {};
6266
6537
  }
@@ -6274,18 +6545,18 @@ class mr {
6274
6545
  if (this.scheduler.isDataBasedComputation(r)) {
6275
6546
  if (Object.entries(r.dataDeps).forEach(([i, s]) => {
6276
6547
  const a = this.convertDataDepToERMutationEventsSourceMap(i, s, r);
6277
- e[s.phase || Pt].push(...a);
6548
+ e[s.phase || Ot].push(...a);
6278
6549
  }), r.dataContext.type === "property" && Object.values(r.dataDeps).some((i) => i.type === "global")) {
6279
6550
  const i = {
6280
6551
  type: "records",
6281
6552
  source: r.dataContext.host
6282
6553
  };
6283
- e[Pt].push(...this.convertDataDepToERMutationEventsSourceMap("_self", i, r, "create"));
6554
+ e[Ot].push(...this.convertDataDepToERMutationEventsSourceMap("_self", i, r, "create"));
6284
6555
  }
6285
6556
  } else {
6286
6557
  const { eventDeps: i } = r;
6287
6558
  for (const s of Object.values(i))
6288
- e[s.phase || Pt].push({
6559
+ e[s.phase || Ot].push({
6289
6560
  type: s.type,
6290
6561
  recordName: s.recordName,
6291
6562
  record: s.record,
@@ -6487,31 +6758,31 @@ class mr {
6487
6758
  }
6488
6759
  class A {
6489
6760
  static {
6490
- this.skip = () => new vt();
6761
+ this.skip = () => new At();
6491
6762
  }
6492
6763
  static {
6493
- this.resolved = (t, e) => new ke(t, e);
6764
+ this.resolved = (t, e) => new Ie(t, e);
6494
6765
  }
6495
6766
  static {
6496
- this.async = (t) => new ve(t);
6767
+ this.async = (t) => new Ee(t);
6497
6768
  }
6498
6769
  static {
6499
- this.fullRecompute = (t) => new Se(t);
6770
+ this.fullRecompute = (t) => new Ae(t);
6500
6771
  }
6501
6772
  }
6502
- class vt extends A {
6773
+ class At extends A {
6503
6774
  }
6504
- class Se extends A {
6775
+ class Ae extends A {
6505
6776
  constructor(t) {
6506
6777
  super(), this.reason = t;
6507
6778
  }
6508
6779
  }
6509
- class ve extends A {
6780
+ class Ee extends A {
6510
6781
  constructor(t) {
6511
6782
  super(), this.args = t;
6512
6783
  }
6513
6784
  }
6514
- class ke extends A {
6785
+ class Ie extends A {
6515
6786
  constructor(t, e) {
6516
6787
  super(), this.result = t, this.args = e;
6517
6788
  }
@@ -6542,18 +6813,18 @@ class B {
6542
6813
  return await this.controller.system.storage.dict.get(this.key);
6543
6814
  }
6544
6815
  }
6545
- function Qt(u, t) {
6816
+ function Lt(u, t) {
6546
6817
  if (t == null || u === t) return !0;
6547
6818
  if (typeof t != "object" || t === null)
6548
6819
  return u === t;
6549
6820
  if (typeof u != "object" || u === null)
6550
6821
  return !1;
6551
6822
  for (const e in t)
6552
- if (!(e in u) || !Qt(u[e], t[e]))
6823
+ if (!(e in u) || !Lt(u[e], t[e]))
6553
6824
  return !1;
6554
6825
  return !0;
6555
6826
  }
6556
- class Ae {
6827
+ class Ce {
6557
6828
  constructor(t) {
6558
6829
  this.data = t, this.map = {};
6559
6830
  for (const e of t.transfers)
@@ -6566,45 +6837,45 @@ class Ae {
6566
6837
  const r = this.map[t];
6567
6838
  if (r) {
6568
6839
  for (const i of r)
6569
- if (Qt(e, i.trigger))
6840
+ if (Lt(e, i.trigger))
6570
6841
  return i.next;
6571
6842
  }
6572
6843
  return null;
6573
6844
  }
6574
6845
  findTransfers(t) {
6575
- return this.data.transfers.filter((e) => Qt(t, e.trigger));
6846
+ return this.data.transfers.filter((e) => Lt(t, e.trigger));
6576
6847
  }
6577
6848
  }
6578
6849
  function v(u, t) {
6579
6850
  if (!u)
6580
6851
  throw new Error(t);
6581
6852
  }
6582
- function Di(u, t) {
6853
+ function _i(u, t) {
6583
6854
  return new Map(Array.from(u.entries()).map(([e, r]) => [e, t(e, r)]));
6584
6855
  }
6585
- function Oi(u, t) {
6856
+ function qi(u, t) {
6586
6857
  return Object.fromEntries(Object.entries(u).map(([e, r]) => [e, t(e, r)]));
6587
6858
  }
6588
- async function Fi(u, t) {
6859
+ async function Bi(u, t) {
6589
6860
  for (let e of u)
6590
6861
  if (!await t(e)) return !1;
6591
6862
  return !0;
6592
6863
  }
6593
- async function yr(u, t) {
6864
+ async function Sr(u, t) {
6594
6865
  for (let e of u)
6595
6866
  if (await t(e)) return !0;
6596
6867
  return !1;
6597
6868
  }
6598
- async function gr(u, t) {
6869
+ async function vr(u, t) {
6599
6870
  for (let e of u) {
6600
6871
  const r = await t(e);
6601
6872
  if (r !== !0) return r;
6602
6873
  }
6603
6874
  return !0;
6604
6875
  }
6605
- class br {
6876
+ class kr {
6606
6877
  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;
6878
+ this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ce(this.args), this.defaultState = this.args.defaultState;
6608
6879
  for (const i of this.args.transfers) {
6609
6880
  const s = `${i.trigger.recordName}_${i.trigger.type}`;
6610
6881
  this.eventDeps[s] = {
@@ -6614,7 +6885,7 @@ class br {
6614
6885
  }
6615
6886
  }
6616
6887
  static {
6617
- this.computationType = ct;
6888
+ this.computationType = lt;
6618
6889
  }
6619
6890
  static {
6620
6891
  this.contextType = "global";
@@ -6633,9 +6904,9 @@ class br {
6633
6904
  return s ? (await this.state.currentState.set(s.name), s.computeValue ? await s.computeValue.call(this.controller, t, e) : s.name) : A.skip();
6634
6905
  }
6635
6906
  }
6636
- class Rr {
6907
+ class Ar {
6637
6908
  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;
6909
+ this.controller = t, this.args = e, this.useLastValue = !0, this.eventDeps = {}, this.useMutationEvent = !0, this.transitionFinder = new Ce(this.args), this.defaultState = this.args.defaultState, this.dataContext = r;
6639
6910
  for (const i of this.args.transfers) {
6640
6911
  const s = `${i.trigger.recordName}_${i.trigger.type}`;
6641
6912
  this.eventDeps[s] = {
@@ -6645,7 +6916,7 @@ class Rr {
6645
6916
  }
6646
6917
  }
6647
6918
  static {
6648
- this.computationType = ct;
6919
+ this.computationType = lt;
6649
6920
  }
6650
6921
  static {
6651
6922
  this.contextType = "property";
@@ -6681,17 +6952,17 @@ Or if you want to use state name as value, you should not set ${this.dataContext
6681
6952
  };
6682
6953
  }
6683
6954
  }
6684
- const Qi = Y.create({
6955
+ const Wi = z.create({
6685
6956
  name: "nonExistent",
6686
6957
  computeValue: () => null
6687
- }), Vi = Y.create({
6958
+ }), Ji = z.create({
6688
6959
  name: "nonDeleted",
6689
6960
  computeValue: () => !1
6690
- }), Li = Y.create({
6961
+ }), ji = z.create({
6691
6962
  name: "deleted",
6692
6963
  computeValue: () => !0
6693
- }), wr = [br, Rr];
6694
- class Nr {
6964
+ }), Er = [kr, Ar];
6965
+ class Ir {
6695
6966
  constructor(t, e, r) {
6696
6967
  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
6968
  main: {
@@ -6703,7 +6974,7 @@ class Nr {
6703
6974
  };
6704
6975
  }
6705
6976
  static {
6706
- this.computationType = lt;
6977
+ this.computationType = ut;
6707
6978
  }
6708
6979
  static {
6709
6980
  this.contextType = "global";
@@ -6744,7 +7015,7 @@ class Nr {
6744
7015
  return r;
6745
7016
  }
6746
7017
  }
6747
- class Tr {
7018
+ class Cr {
6748
7019
  constructor(t, e, r) {
6749
7020
  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
7021
  const i = this.args.attributeQuery || [];
@@ -6762,7 +7033,7 @@ class Tr {
6762
7033
  };
6763
7034
  }
6764
7035
  static {
6765
- this.computationType = lt;
7036
+ this.computationType = ut;
6766
7037
  }
6767
7038
  static {
6768
7039
  this.contextType = "property";
@@ -6820,8 +7091,8 @@ class Tr {
6820
7091
  return s;
6821
7092
  }
6822
7093
  }
6823
- const Sr = [Nr, Tr];
6824
- class vr {
7094
+ const xr = [Ir, Cr];
7095
+ class Mr {
6825
7096
  constructor(t, e, r) {
6826
7097
  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
7098
  main: {
@@ -6833,7 +7104,7 @@ class vr {
6833
7104
  }, this.defaultValue = !this.args.notEmpty;
6834
7105
  }
6835
7106
  static {
6836
- this.computationType = pt;
7107
+ this.computationType = ft;
6837
7108
  }
6838
7109
  static {
6839
7110
  this.contextType = "global";
@@ -6874,7 +7145,7 @@ class vr {
6874
7145
  return a === s;
6875
7146
  }
6876
7147
  }
6877
- class kr {
7148
+ class $r {
6878
7149
  constructor(t, e, r) {
6879
7150
  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
7151
  const i = this.args.attributeQuery || [];
@@ -6893,7 +7164,7 @@ class kr {
6893
7164
  };
6894
7165
  }
6895
7166
  static {
6896
- this.computationType = pt;
7167
+ this.computationType = ft;
6897
7168
  }
6898
7169
  static {
6899
7170
  this.contextType = "property";
@@ -6948,8 +7219,8 @@ class kr {
6948
7219
  return a === o;
6949
7220
  }
6950
7221
  }
6951
- const Ar = [vr, kr];
6952
- class Er {
7222
+ const Pr = [Mr, $r];
7223
+ class Dr {
6953
7224
  constructor(t, e, r) {
6954
7225
  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
7226
  main: {
@@ -6961,7 +7232,7 @@ class Er {
6961
7232
  };
6962
7233
  }
6963
7234
  static {
6964
- this.computationType = ft;
7235
+ this.computationType = mt;
6965
7236
  }
6966
7237
  static {
6967
7238
  this.contextType = "global";
@@ -7002,7 +7273,7 @@ class Er {
7002
7273
  return s > 0;
7003
7274
  }
7004
7275
  }
7005
- class Ir {
7276
+ class Or {
7006
7277
  constructor(t, e, r) {
7007
7278
  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
7279
  let i = this.relation.baseRelation || this.relation;
@@ -7025,7 +7296,7 @@ class Ir {
7025
7296
  };
7026
7297
  }
7027
7298
  static {
7028
- this.computationType = ft;
7299
+ this.computationType = mt;
7029
7300
  }
7030
7301
  static {
7031
7302
  this.contextType = "property";
@@ -7078,8 +7349,8 @@ class Ir {
7078
7349
  return s > 0;
7079
7350
  }
7080
7351
  }
7081
- const Cr = [Er, Ir];
7082
- class xr {
7352
+ const Fr = [Dr, Or];
7353
+ class Vr {
7083
7354
  constructor(t, e, r) {
7084
7355
  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
7356
  main: {
@@ -7091,7 +7362,7 @@ class xr {
7091
7362
  };
7092
7363
  }
7093
7364
  static {
7094
- this.computationType = ut;
7365
+ this.computationType = dt;
7095
7366
  }
7096
7367
  static {
7097
7368
  this.contextType = "global";
@@ -7129,7 +7400,7 @@ class xr {
7129
7400
  return s = Math.max(0, s), await this.state.count.set(s), s;
7130
7401
  }
7131
7402
  }
7132
- class Mr {
7403
+ class Qr {
7133
7404
  constructor(t, e, r) {
7134
7405
  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
7406
  const i = this.args.attributeQuery || [];
@@ -7147,7 +7418,7 @@ class Mr {
7147
7418
  };
7148
7419
  }
7149
7420
  static {
7150
- this.computationType = ut;
7421
+ this.computationType = dt;
7151
7422
  }
7152
7423
  static {
7153
7424
  this.contextType = "property";
@@ -7211,8 +7482,8 @@ class Mr {
7211
7482
  return a;
7212
7483
  }
7213
7484
  }
7214
- const $r = [xr, Mr];
7215
- class Pr {
7485
+ const Lr = [Vr, Qr];
7486
+ class _r {
7216
7487
  constructor(t, e, r) {
7217
7488
  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
7489
  ...this.args.dataDeps || {},
@@ -7224,7 +7495,7 @@ class Pr {
7224
7495
  });
7225
7496
  }
7226
7497
  static {
7227
- this.computationType = Ct;
7498
+ this.computationType = Mt;
7228
7499
  }
7229
7500
  static {
7230
7501
  this.contextType = ["entity", "relation"];
@@ -7320,7 +7591,7 @@ class Pr {
7320
7591
  return i;
7321
7592
  }
7322
7593
  }
7323
- const Dr = [Pr];
7594
+ const qr = [_r];
7324
7595
  class $ {
7325
7596
  constructor(t) {
7326
7597
  this.node = t;
@@ -7419,13 +7690,13 @@ class $ {
7419
7690
  }
7420
7691
  }
7421
7692
  gt(t) {
7422
- return new kt(this, ">", t);
7693
+ return new Et(this, ">", t);
7423
7694
  }
7424
7695
  lt(t) {
7425
- return new kt(this, "<", t);
7696
+ return new Et(this, "<", t);
7426
7697
  }
7427
7698
  eq(t) {
7428
- return new te(this, t);
7699
+ return new re(this, t);
7429
7700
  }
7430
7701
  getVariables() {
7431
7702
  const t = /* @__PURE__ */ new Set();
@@ -7522,7 +7793,7 @@ class $ {
7522
7793
  }
7523
7794
  }
7524
7795
  }
7525
- class kt {
7796
+ class Et {
7526
7797
  constructor(t, e, r) {
7527
7798
  this.left = t, this.operator = e, this.right = r;
7528
7799
  }
@@ -7557,7 +7828,7 @@ class kt {
7557
7828
  }
7558
7829
  }
7559
7830
  }
7560
- class te {
7831
+ class re {
7561
7832
  constructor(t, e) {
7562
7833
  this.left = t, this.right = e;
7563
7834
  }
@@ -7592,12 +7863,12 @@ class te {
7592
7863
  }
7593
7864
  }
7594
7865
  }
7595
- class Or {
7866
+ class Br {
7596
7867
  constructor(t, e, r) {
7597
7868
  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
7869
  }
7599
7870
  static {
7600
- this.computationType = mt;
7871
+ this.computationType = yt;
7601
7872
  }
7602
7873
  static {
7603
7874
  this.contextType = "global";
@@ -7617,14 +7888,14 @@ class Or {
7617
7888
  let i, s;
7618
7889
  if (e instanceof $)
7619
7890
  i = e.evaluate({ now: r }), s = r + this.nextRecomputeTime(r, t);
7620
- else if (e instanceof kt || e instanceof te)
7891
+ else if (e instanceof Et || e instanceof re)
7621
7892
  i = e.evaluate({ now: r }), s = e.solve();
7622
7893
  else
7623
7894
  throw new Error("Invalid result type");
7624
7895
  return await this.state.lastRecomputeTime.set(r), await this.state.nextRecomputeTime.set(s), i;
7625
7896
  }
7626
7897
  }
7627
- class Fr {
7898
+ class Wr {
7628
7899
  constructor(t, e, r) {
7629
7900
  this.controller = t, this.args = e, this.dataContext = r, this.useLastValue = !1, this.dataDeps = {
7630
7901
  _current: {
@@ -7635,7 +7906,7 @@ class Fr {
7635
7906
  }, 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
7907
  }
7637
7908
  static {
7638
- this.computationType = mt;
7909
+ this.computationType = yt;
7639
7910
  }
7640
7911
  static {
7641
7912
  this.contextType = "property";
@@ -7655,15 +7926,15 @@ class Fr {
7655
7926
  let s, a;
7656
7927
  if (r instanceof $)
7657
7928
  s = r.evaluate({ now: i }), a = i + this.nextRecomputeTime(i, t);
7658
- else if (r instanceof kt || r instanceof te)
7929
+ else if (r instanceof Et || r instanceof re)
7659
7930
  s = r.evaluate({ now: i }), a = r.solve();
7660
7931
  else
7661
7932
  throw new Error("Invalid result type");
7662
7933
  return await this.state.lastRecomputeTime.set(e, i), await this.state.nextRecomputeTime.set(e, a), s;
7663
7934
  }
7664
7935
  }
7665
- const Qr = [Or, Fr];
7666
- class Vr {
7936
+ const Jr = [Br, Wr];
7937
+ class jr {
7667
7938
  constructor(t, e, r) {
7668
7939
  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
7940
  throw new Error("Sum computation requires attributeQuery with at least one field");
@@ -7680,7 +7951,7 @@ class Vr {
7680
7951
  };
7681
7952
  }
7682
7953
  static {
7683
- this.computationType = dt;
7954
+ this.computationType = ht;
7684
7955
  }
7685
7956
  static {
7686
7957
  this.contextType = "global";
@@ -7724,7 +7995,7 @@ class Vr {
7724
7995
  return s;
7725
7996
  }
7726
7997
  }
7727
- class Lr {
7998
+ class Ur {
7728
7999
  constructor(t, e, r) {
7729
8000
  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
8001
  const i = this.args.attributeQuery || [];
@@ -7745,7 +8016,7 @@ class Lr {
7745
8016
  };
7746
8017
  }
7747
8018
  static {
7748
- this.computationType = dt;
8019
+ this.computationType = ht;
7749
8020
  }
7750
8021
  static {
7751
8022
  this.contextType = "property";
@@ -7813,8 +8084,8 @@ class Lr {
7813
8084
  return a;
7814
8085
  }
7815
8086
  }
7816
- const _r = [Vr, Lr];
7817
- class qr {
8087
+ const Hr = [jr, Ur];
8088
+ class Gr {
7818
8089
  constructor(t, e, r) {
7819
8090
  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
8091
  throw new Error("Average computation requires attributeQuery with at least one field");
@@ -7831,7 +8102,7 @@ class qr {
7831
8102
  };
7832
8103
  }
7833
8104
  static {
7834
- this.computationType = ht;
8105
+ this.computationType = pt;
7835
8106
  }
7836
8107
  static {
7837
8108
  this.contextType = "global";
@@ -7887,7 +8158,7 @@ class qr {
7887
8158
  return await this.state.sum.set(a), await this.state.count.set(s), s > 0 ? a / s : 0;
7888
8159
  }
7889
8160
  }
7890
- class Br {
8161
+ class Kr {
7891
8162
  constructor(t, e, r) {
7892
8163
  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
8164
  const i = this.args.attributeQuery || [];
@@ -7908,7 +8179,7 @@ class Br {
7908
8179
  };
7909
8180
  }
7910
8181
  static {
7911
- this.computationType = ht;
8182
+ this.computationType = pt;
7912
8183
  }
7913
8184
  static {
7914
8185
  this.contextType = "property";
@@ -7971,8 +8242,8 @@ class Br {
7971
8242
  return await this.state.count.set(e.record, a), a > 0 ? o / a : 0;
7972
8243
  }
7973
8244
  }
7974
- const Wr = [qr, Br];
7975
- class Mt {
8245
+ const Xr = [Gr, Kr];
8246
+ class Pt {
7976
8247
  constructor(t, e, r) {
7977
8248
  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
8249
  if (this.computeCallback) {
@@ -8016,7 +8287,7 @@ class Mt {
8016
8287
  }));
8017
8288
  }
8018
8289
  static {
8019
- this.computationType = Zt;
8290
+ this.computationType = ee;
8020
8291
  }
8021
8292
  createState() {
8022
8293
  if (this.createStateCallback) {
@@ -8043,22 +8314,22 @@ class Mt {
8043
8314
  return A.skip();
8044
8315
  }
8045
8316
  }
8046
- class Jr extends Mt {
8317
+ class Yr extends Pt {
8047
8318
  static {
8048
8319
  this.contextType = "global";
8049
8320
  }
8050
8321
  }
8051
- class Hr extends Mt {
8322
+ class zr extends Pt {
8052
8323
  static {
8053
8324
  this.contextType = "entity";
8054
8325
  }
8055
8326
  }
8056
- class jr extends Mt {
8327
+ class Zr extends Pt {
8057
8328
  static {
8058
8329
  this.contextType = "relation";
8059
8330
  }
8060
8331
  }
8061
- class Ur extends Mt {
8332
+ class ti extends Pt {
8062
8333
  static {
8063
8334
  this.contextType = "property";
8064
8335
  }
@@ -8073,13 +8344,13 @@ If you want to use aggregated data from all records in the entity/relation, you
8073
8344
  super(t, e, r);
8074
8345
  }
8075
8346
  }
8076
- const Gr = [
8077
- Jr,
8078
- Hr,
8079
- jr,
8080
- Ur
8347
+ const ei = [
8348
+ Yr,
8349
+ zr,
8350
+ Zr,
8351
+ ti
8081
8352
  ];
8082
- class j extends Error {
8353
+ class H extends Error {
8083
8354
  constructor(t, e = {}) {
8084
8355
  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
8356
  }
@@ -8092,7 +8363,7 @@ class j extends Error {
8092
8363
  getErrorChain() {
8093
8364
  const t = [this];
8094
8365
  let e = this.causedBy;
8095
- for (; e && (t.push(e), e instanceof j); )
8366
+ for (; e && (t.push(e), e instanceof H); )
8096
8367
  e = e.causedBy;
8097
8368
  return t;
8098
8369
  }
@@ -8196,13 +8467,13 @@ Stack trace:`, i.stack.split(`
8196
8467
  return null;
8197
8468
  }
8198
8469
  }
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 {
8470
+ 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 || {});
8471
+ class G extends H {
8201
8472
  constructor(t, e = {}) {
8202
8473
  super(t, {
8203
8474
  errorType: e.context?.errorType || "InteractionExecutionError",
8204
8475
  context: {
8205
- category: Z.INTERACTION,
8476
+ category: tt.INTERACTION,
8206
8477
  interactionName: e.interactionName,
8207
8478
  userId: e.userId,
8208
8479
  payload: e.payload,
@@ -8210,15 +8481,15 @@ class U extends j {
8210
8481
  ...e.context
8211
8482
  },
8212
8483
  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;
8484
+ }), this.interactionName = e.interactionName, this.userId = e.userId, this.payload = e.payload, this.executionPhase = e.executionPhase, this.severity = e.severity || Q.HIGH;
8214
8485
  }
8215
8486
  }
8216
- class ce extends j {
8487
+ class de extends H {
8217
8488
  constructor(t, e = {}) {
8218
8489
  super(t, {
8219
8490
  errorType: e.context?.errorType || "ActivityError",
8220
8491
  context: {
8221
- category: Z.ACTIVITY,
8492
+ category: tt.ACTIVITY,
8222
8493
  activityName: e.activityName,
8223
8494
  activityId: e.activityId,
8224
8495
  activityInstanceId: e.activityInstanceId,
@@ -8226,15 +8497,15 @@ class ce extends j {
8226
8497
  ...e.context
8227
8498
  },
8228
8499
  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;
8500
+ }), this.activityName = e.activityName, this.activityId = e.activityId, this.activityInstanceId = e.activityInstanceId, this.currentState = e.currentState, this.severity = e.severity || Q.MEDIUM;
8230
8501
  }
8231
8502
  }
8232
- class Q extends j {
8503
+ class V extends H {
8233
8504
  constructor(t, e = {}) {
8234
8505
  super(t, {
8235
8506
  errorType: e.context?.errorType || "ComputationError",
8236
8507
  context: {
8237
- category: Z.COMPUTATION,
8508
+ category: tt.COMPUTATION,
8238
8509
  handleName: e.handleName,
8239
8510
  computationName: e.computationName,
8240
8511
  dataContext: e.dataContext,
@@ -8242,14 +8513,14 @@ class Q extends j {
8242
8513
  ...e.context
8243
8514
  },
8244
8515
  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;
8516
+ }), this.handleName = e.handleName, this.computationName = e.computationName, this.dataContext = e.dataContext, this.computationPhase = e.computationPhase, this.severity = e.severity || Q.MEDIUM;
8246
8517
  }
8247
8518
  }
8248
- class le extends Q {
8519
+ class he extends V {
8249
8520
  constructor(t, e = {}) {
8250
8521
  super(t, {
8251
8522
  ...e,
8252
- severity: V.HIGH,
8523
+ severity: Q.HIGH,
8253
8524
  context: {
8254
8525
  errorType: "ComputationStateError",
8255
8526
  stateKey: e.stateKey,
@@ -8260,11 +8531,11 @@ class le extends Q {
8260
8531
  }), this.stateKey = e.stateKey, this.stateValue = e.stateValue, this.expectedStateType = e.expectedStateType, this.actualStateType = e.actualStateType;
8261
8532
  }
8262
8533
  }
8263
- class J extends Q {
8534
+ class J extends V {
8264
8535
  constructor(t, e = {}) {
8265
8536
  super(t, {
8266
8537
  ...e,
8267
- severity: V.MEDIUM,
8538
+ severity: Q.MEDIUM,
8268
8539
  context: {
8269
8540
  errorType: "ComputationDataDepError",
8270
8541
  depName: e.depName,
@@ -8275,26 +8546,26 @@ class J extends Q {
8275
8546
  }), this.depName = e.depName, this.depType = e.depType, this.missingData = e.missingData, this.invalidData = e.invalidData;
8276
8547
  }
8277
8548
  }
8278
- class H extends j {
8549
+ class j extends H {
8279
8550
  constructor(t, e = {}) {
8280
8551
  super(t, {
8281
8552
  errorType: e.context?.errorType || "SchedulerError",
8282
8553
  context: {
8283
- category: Z.SYSTEM,
8554
+ category: tt.SYSTEM,
8284
8555
  schedulingPhase: e.schedulingPhase,
8285
8556
  failedComputations: e.failedComputations,
8286
8557
  ...e.context
8287
8558
  },
8288
8559
  causedBy: e.causedBy
8289
- }), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = V.HIGH;
8560
+ }), this.schedulingPhase = e.schedulingPhase, this.failedComputations = e.failedComputations, this.severity = Q.HIGH;
8290
8561
  }
8291
8562
  }
8292
- class O extends j {
8563
+ class O extends H {
8293
8564
  constructor(t, e) {
8294
8565
  super(t, {
8295
8566
  errorType: e.context?.errorType || "ConditionError",
8296
8567
  context: {
8297
- category: Z.PERMISSION,
8568
+ category: tt.PERMISSION,
8298
8569
  checkType: e.checkType,
8299
8570
  fieldName: e.fieldName,
8300
8571
  payload: e.payload,
@@ -8302,7 +8573,7 @@ class O extends j {
8302
8573
  ...e.context
8303
8574
  },
8304
8575
  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;
8576
+ }), 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
8577
  }
8307
8578
  /**
8308
8579
  * Helper factory methods for common condition error scenarios
@@ -8311,7 +8582,7 @@ class O extends j {
8311
8582
  return new O("User check failed", {
8312
8583
  checkType: "user",
8313
8584
  evaluationError: t,
8314
- severity: V.HIGH,
8585
+ severity: Q.HIGH,
8315
8586
  context: e,
8316
8587
  type: "check user failed"
8317
8588
  // For backward compatibility
@@ -8324,7 +8595,7 @@ class O extends j {
8324
8595
  fieldName: t,
8325
8596
  payload: r,
8326
8597
  evaluationError: i,
8327
- severity: V.MEDIUM,
8598
+ severity: Q.MEDIUM,
8328
8599
  type: s
8329
8600
  // For backward compatibility
8330
8601
  });
@@ -8333,7 +8604,7 @@ class O extends j {
8333
8604
  return new O(`Condition check failed: ${t.data.name}`, {
8334
8605
  checkType: "condition",
8335
8606
  evaluationError: t,
8336
- severity: V.HIGH,
8607
+ severity: Q.HIGH,
8337
8608
  context: e,
8338
8609
  type: "condition check failed"
8339
8610
  // For backward compatibility
@@ -8346,7 +8617,7 @@ class O extends j {
8346
8617
  fieldName: t,
8347
8618
  payload: r,
8348
8619
  evaluationError: i,
8349
- severity: V.MEDIUM,
8620
+ severity: Q.MEDIUM,
8350
8621
  type: s
8351
8622
  // For backward compatibility
8352
8623
  });
@@ -8356,16 +8627,16 @@ class O extends j {
8356
8627
  checkType: "concept",
8357
8628
  fieldName: t,
8358
8629
  evaluationError: e,
8359
- severity: V.MEDIUM,
8630
+ severity: Q.MEDIUM,
8360
8631
  type: `${t} check concept failed`
8361
8632
  // For backward compatibility
8362
8633
  });
8363
8634
  }
8364
8635
  }
8365
- const Dt = "_ASYNC_TASK_";
8366
- class Kr {
8636
+ const Ft = "_ASYNC_TASK_";
8637
+ class ri {
8367
8638
  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);
8639
+ this.controller = t, this.computationsHandles = /* @__PURE__ */ new Map(), this.computationHandleMap = /* @__PURE__ */ new Map(), this.erMutationEventSources = [], this.dataSourceMapTree = {}, this.sourceMapManager = new Tr(this.controller, this), this.buildComputationHandleMap(s);
8369
8640
  const a = [];
8370
8641
  i.forEach((o) => {
8371
8642
  o.computation && a.push({ dataContext: { type: "global", id: o }, args: o.computation });
@@ -8653,7 +8924,7 @@ class Kr {
8653
8924
  try {
8654
8925
  this.isDataBasedComputation(t.computation) ? r = await this.computeDataBasedDirtyRecordsAndEvents(t, e) : r = await this.computeEventBasedDirtyRecordsAndEvents(t, e);
8655
8926
  } catch (i) {
8656
- throw new Q("Failed to compute dirty records and events", {
8927
+ throw new V("Failed to compute dirty records and events", {
8657
8928
  handleName: t.computation.constructor.name,
8658
8929
  computationName: t.computation.args.constructor.displayName,
8659
8930
  dataContext: t.computation.dataContext,
@@ -8665,7 +8936,7 @@ class Kr {
8665
8936
  try {
8666
8937
  await this.runComputation(t.computation, s, i);
8667
8938
  } catch (a) {
8668
- throw new Q("Failed to run computation for dirty record", {
8939
+ throw new V("Failed to run computation for dirty record", {
8669
8940
  handleName: t.computation.constructor.name,
8670
8941
  computationName: t.computation.args.constructor.displayName,
8671
8942
  dataContext: t.computation.dataContext,
@@ -8676,7 +8947,7 @@ class Kr {
8676
8947
  }
8677
8948
  }
8678
8949
  } catch (r) {
8679
- throw r instanceof Q ? r : new H("Unexpected error in dirty records computation", {
8950
+ throw r instanceof V ? r : new j("Unexpected error in dirty records computation", {
8680
8951
  schedulingPhase: "dirty-records-processing",
8681
8952
  failedComputations: [t.computation.args.constructor.displayName],
8682
8953
  causedBy: r instanceof Error ? r : new Error(String(r))
@@ -8686,8 +8957,8 @@ class Kr {
8686
8957
  getAsyncTaskRecordKey(t) {
8687
8958
  if (t.dataContext.type === "property") {
8688
8959
  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}`;
8960
+ return `${Ft}_${e.host.name}_${e.id.name}`;
8961
+ } else return t.dataContext.type === "global" ? `${Ft}_${t.dataContext.id.name}` : `${Ft}_${t.dataContext.type}_${t.dataContext.id?.name}`;
8691
8962
  }
8692
8963
  async createAsyncTask(t, e, r, i) {
8693
8964
  if (t.dataContext.type === "property")
@@ -8756,7 +9027,7 @@ class Kr {
8756
9027
  try {
8757
9028
  o = await this.controller.retrieveLastValue(t.dataContext, r);
8758
9029
  } catch (n) {
8759
- throw new le("Failed to retrieve last value for incremental computation", {
9030
+ throw new he("Failed to retrieve last value for incremental computation", {
8760
9031
  handleName: t.constructor.name,
8761
9032
  computationName: t.args.constructor.displayName,
8762
9033
  dataContext: t.dataContext,
@@ -8770,7 +9041,7 @@ class Kr {
8770
9041
  try {
8771
9042
  o = await this.controller.retrieveLastValue(t.dataContext, r);
8772
9043
  } catch (n) {
8773
- throw new le("Failed to retrieve last value for incremental patch computation", {
9044
+ throw new he("Failed to retrieve last value for incremental patch computation", {
8774
9045
  handleName: t.constructor.name,
8775
9046
  computationName: t.args.constructor.displayName,
8776
9047
  dataContext: t.dataContext,
@@ -8779,16 +9050,16 @@ class Kr {
8779
9050
  }
8780
9051
  s = await t.incrementalPatchCompute(o, e, r, a);
8781
9052
  } else
8782
- throw new Q(`Unknown computation type: ${t.constructor.name}`, {
9053
+ throw new V(`Unknown computation type: ${t.constructor.name}`, {
8783
9054
  handleName: t.constructor.name,
8784
9055
  computationName: t.args.constructor.displayName,
8785
9056
  dataContext: t.dataContext,
8786
9057
  computationPhase: "type-validation"
8787
9058
  });
8788
- if (s instanceof Se) {
9059
+ if (s instanceof Ae) {
8789
9060
  const o = t;
8790
9061
  if (!o.compute)
8791
- throw new Q("compute must be defined for computation when incrementalCompute returns ComputationResultFullRecompute", {
9062
+ throw new V("compute must be defined for computation when incrementalCompute returns ComputationResultFullRecompute", {
8792
9063
  handleName: t.constructor.name,
8793
9064
  computationName: t.args.constructor.displayName,
8794
9065
  dataContext: t.dataContext,
@@ -8798,7 +9069,7 @@ class Kr {
8798
9069
  }
8799
9070
  }
8800
9071
  } catch (o) {
8801
- throw o instanceof Q ? o : new Q("Computation execution failed", {
9072
+ throw o instanceof V ? o : new V("Computation execution failed", {
8802
9073
  handleName: t.constructor.name,
8803
9074
  computationName: t.args.constructor.displayName,
8804
9075
  dataContext: t.dataContext,
@@ -8806,13 +9077,13 @@ class Kr {
8806
9077
  causedBy: o instanceof Error ? o : new Error(String(o))
8807
9078
  });
8808
9079
  }
8809
- if (s instanceof vt)
9080
+ if (s instanceof At)
8810
9081
  return;
8811
- if (s instanceof ve)
9082
+ if (s instanceof Ee)
8812
9083
  try {
8813
9084
  return await this.createAsyncTask(t, s.args, r);
8814
9085
  } catch (o) {
8815
- throw new Q("Failed to create async task", {
9086
+ throw new V("Failed to create async task", {
8816
9087
  handleName: t.constructor.name,
8817
9088
  computationName: t.args.constructor.displayName,
8818
9089
  dataContext: t.dataContext,
@@ -8821,10 +9092,10 @@ class Kr {
8821
9092
  });
8822
9093
  }
8823
9094
  try {
8824
- const o = s instanceof ke ? await t.asyncReturn(s.result, s.args) : s;
9095
+ const o = s instanceof Ie ? await t.asyncReturn(s.result, s.args) : s;
8825
9096
  t.incrementalPatchCompute ? await this.controller.applyResultPatch(t.dataContext, o, r) : await this.controller.applyResult(t.dataContext, o, r);
8826
9097
  } catch (o) {
8827
- throw new Q("Failed to apply computation result", {
9098
+ throw new V("Failed to apply computation result", {
8828
9099
  handleName: t.constructor.name,
8829
9100
  computationName: t.args.constructor.displayName,
8830
9101
  dataContext: t.dataContext,
@@ -8833,7 +9104,7 @@ class Kr {
8833
9104
  });
8834
9105
  }
8835
9106
  } catch (s) {
8836
- throw s instanceof Q ? s : new Q("Unexpected error during computation execution", {
9107
+ throw s instanceof V ? s : new V("Unexpected error during computation execution", {
8837
9108
  handleName: t.constructor.name,
8838
9109
  computationName: t.args.constructor.displayName,
8839
9110
  dataContext: t.dataContext,
@@ -8905,7 +9176,7 @@ class Kr {
8905
9176
  try {
8906
9177
  await this.setupDefaultValues();
8907
9178
  } catch (t) {
8908
- throw new H("Failed to setup computation default values", {
9179
+ throw new j("Failed to setup computation default values", {
8909
9180
  schedulingPhase: "default-values-setup",
8910
9181
  causedBy: t instanceof Error ? t : new Error(String(t))
8911
9182
  });
@@ -8913,7 +9184,7 @@ class Kr {
8913
9184
  try {
8914
9185
  await this.setupGlobalBoundStateDefaultValues();
8915
9186
  } catch (t) {
8916
- throw new H("Failed to setup computation state default values", {
9187
+ throw new j("Failed to setup computation state default values", {
8917
9188
  schedulingPhase: "state-default-values-setup",
8918
9189
  causedBy: t instanceof Error ? t : new Error(String(t))
8919
9190
  });
@@ -8921,7 +9192,7 @@ class Kr {
8921
9192
  try {
8922
9193
  await this.setupMutationListeners();
8923
9194
  } catch (t) {
8924
- throw new H("Failed to setup mutation listeners for computations", {
9195
+ throw new j("Failed to setup mutation listeners for computations", {
8925
9196
  schedulingPhase: "mutation-listeners-setup",
8926
9197
  causedBy: t instanceof Error ? t : new Error(String(t))
8927
9198
  });
@@ -8929,20 +9200,20 @@ class Kr {
8929
9200
  try {
8930
9201
  await this.setupGlobalDict();
8931
9202
  } catch (t) {
8932
- throw new H("Failed to setup global dictionary", {
9203
+ throw new j("Failed to setup global dictionary", {
8933
9204
  schedulingPhase: "global-dict-setup",
8934
9205
  causedBy: t instanceof Error ? t : new Error(String(t))
8935
9206
  });
8936
9207
  }
8937
9208
  } catch (t) {
8938
- throw t instanceof H ? t : new H("Unexpected error during scheduler setup", {
9209
+ throw t instanceof j ? t : new j("Unexpected error during scheduler setup", {
8939
9210
  schedulingPhase: "top-level-setup",
8940
9211
  causedBy: t instanceof Error ? t : new Error(String(t))
8941
9212
  });
8942
9213
  }
8943
9214
  }
8944
9215
  }
8945
- class Ee {
9216
+ class xe {
8946
9217
  constructor(t, e, r) {
8947
9218
  this.interaction = t, this.controller = e, this.activitySeqCall = r, this.system = e.system;
8948
9219
  }
@@ -8970,7 +9241,7 @@ class Ee {
8970
9241
  async checkUser(t, e, r) {
8971
9242
  let i;
8972
9243
  if (!this.interaction.userAttributives) return !0;
8973
- const s = Et.is(this.interaction.userAttributives) ? R.fromValue(
9244
+ const s = Ct.is(this.interaction.userAttributives) ? R.fromValue(
8974
9245
  this.interaction.userAttributives.content
8975
9246
  ) : R.atom(
8976
9247
  this.interaction.userAttributives
@@ -8996,12 +9267,12 @@ class Ee {
8996
9267
  }
8997
9268
  if (this.isConceptAlias(e)) {
8998
9269
  const s = [];
8999
- return await yr(e.for, async (o) => {
9270
+ return await Sr(e.for, async (o) => {
9000
9271
  const n = await this.isConcept(t, o);
9001
9272
  return n === !0 ? !0 : (s.push(n), !1);
9002
9273
  }) ? !0 : { name: e.name, type: "conceptAlias", stack: i, error: s };
9003
9274
  } else {
9004
- if (X.is(e))
9275
+ if (Y.is(e))
9005
9276
  return await this.checkAttributive(e, void 0, t) ? !0 : { name: e.name, type: "conceptCheck", stack: i, error: "role check error" };
9006
9277
  const s = e.constructor?.check;
9007
9278
  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 +9307,7 @@ class Ee {
9036
9307
  throw O.payloadValidationFailed(i.name, "data is not a ref", s);
9037
9308
  if (i.base)
9038
9309
  if (i.isCollection) {
9039
- const a = await gr(s, (o) => this.checkConcept(o, i.base));
9310
+ const a = await vr(s, (o) => this.checkConcept(o, i.base));
9040
9311
  if (a !== !0)
9041
9312
  throw O.conceptCheckFailed(i.name, a);
9042
9313
  } else {
@@ -9058,7 +9329,7 @@ class Ee {
9058
9329
  }
9059
9330
  async checkCondition(t) {
9060
9331
  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) => {
9332
+ const e = $t.is(this.interaction.conditions) ? new R(this.interaction.conditions.content) : R.atom(this.interaction.conditions), r = async (s) => {
9062
9333
  if (!s) return !0;
9063
9334
  if (s.content) {
9064
9335
  const a = s.content;
@@ -9092,7 +9363,7 @@ class Ee {
9092
9363
  v(!r.sideEffects[o], `sideEffect ${o} already exists`), r.sideEffects[o] = { result: n, error: c };
9093
9364
  }
9094
9365
  isGetInteraction() {
9095
- return this.interaction.action === We;
9366
+ return this.interaction.action === Xe;
9096
9367
  }
9097
9368
  async saveEvent(t) {
9098
9369
  return await this.controller.activityManager.saveEvent(t);
@@ -9138,7 +9409,7 @@ class Ee {
9138
9409
  return s;
9139
9410
  }
9140
9411
  }
9141
- class G {
9412
+ class K {
9142
9413
  constructor(t, e) {
9143
9414
  this.graph = t, this.parent = e;
9144
9415
  }
@@ -9148,7 +9419,7 @@ class G {
9148
9419
  };
9149
9420
  }
9150
9421
  static create(t, e, r) {
9151
- const i = new G(e, r);
9422
+ const i = new K(e, r);
9152
9423
  return t.current && (i.current = D.create(t.current, e, i)), i;
9153
9424
  }
9154
9425
  isInteractionAvailable(t) {
@@ -9182,13 +9453,13 @@ class D {
9182
9453
  }
9183
9454
  static createInitialState(t) {
9184
9455
  const e = { uuid: t.uuid };
9185
- return rt.is(t.content) && (e.children = t.childSeqs.map((r) => G.createInitialState(r.head))), e;
9456
+ return it.is(t.content) && (e.children = t.childSeqs.map((r) => K.createInitialState(r.head))), e;
9186
9457
  }
9187
9458
  static create(t, e, r) {
9188
9459
  const i = e.getNodeByUUID(t.uuid);
9189
- if (rt.is(i.content)) {
9460
+ if (it.is(i.content)) {
9190
9461
  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;
9462
+ return o.isGroup = !0, o.children = t?.children?.map((n) => K.create(n, e, o)), o;
9192
9463
  } else
9193
9464
  return new D(i, e, r);
9194
9465
  }
@@ -9208,12 +9479,12 @@ class D {
9208
9479
  this.parent.transferToNext(this.node.uuid);
9209
9480
  }
9210
9481
  }
9211
- class ue {
9482
+ class pe {
9212
9483
  constructor(t, e) {
9213
- this.graph = e, this.root = G.create(t, this.graph);
9484
+ this.graph = e, this.root = K.create(t, this.graph);
9214
9485
  }
9215
9486
  static createInitialState(t) {
9216
- return G.createInitialState(t);
9487
+ return K.createInitialState(t);
9217
9488
  }
9218
9489
  isInteractionAvailable(t) {
9219
9490
  return this.root.isInteractionAvailable(t);
@@ -9225,7 +9496,7 @@ class ue {
9225
9496
  return this.root.toJSON();
9226
9497
  }
9227
9498
  }
9228
- class et {
9499
+ class rt {
9229
9500
  constructor(t, e) {
9230
9501
  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
9502
  }
@@ -9234,8 +9505,8 @@ class et {
9234
9505
  }
9235
9506
  static {
9236
9507
  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;
9508
+ let r = rt.cache.get(t);
9509
+ return r || (r = new rt(t, e), rt.cache.set(t, r)), r;
9239
9510
  };
9240
9511
  }
9241
9512
  buildGraph(t, e) {
@@ -9243,7 +9514,7 @@ class et {
9243
9514
  for (let o of t.interactions) {
9244
9515
  const n = { content: o, next: null, uuid: o.uuid, parentGroup: e, parentSeq: i };
9245
9516
  this.uuidToNode.set(o.uuid, n), this.rawToNode.set(o, n);
9246
- const c = new Ee(o, this.controller, this);
9517
+ const c = new xe(o, this.controller, this);
9247
9518
  this.uuidToInteractionCall.set(o.uuid, c), o.name && this.interactionCallByName.set(o.name, c);
9248
9519
  }
9249
9520
  for (let o of t.gateways) {
@@ -9263,7 +9534,7 @@ class et {
9263
9534
  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
9535
  if (t.transfers?.forEach((o) => {
9265
9536
  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);
9537
+ 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
9538
  }), s.size !== 1) throw new Error(`start node must one, current: ${s.size}`);
9268
9539
  if (a.size !== 1) throw new Error(`end node must be one, current: ${a.size}`);
9269
9540
  return Object.assign(i, {
@@ -9272,7 +9543,7 @@ class et {
9272
9543
  }), i;
9273
9544
  }
9274
9545
  async create() {
9275
- const t = ue.createInitialState(this.graph.head);
9546
+ const t = pe.createInitialState(this.graph.head);
9276
9547
  return {
9277
9548
  activityId: (await this.controller.activityManager.createActivity({
9278
9549
  name: this.activity.name,
@@ -9319,7 +9590,7 @@ class et {
9319
9590
  return e.parentSeq.tail === e;
9320
9591
  }
9321
9592
  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;
9593
+ return it.is(this.graph.head.content) ? !!this.graph.head.childSeqs?.some((r) => this.isActivityHead(t, r.head)) : t === this.graph.head.content;
9323
9594
  }
9324
9595
  async callInteraction(t, e, r) {
9325
9596
  const i = this.uuidToInteractionCall.get(e);
@@ -9331,7 +9602,7 @@ class et {
9331
9602
  s = (await this.create()).activityId;
9332
9603
  }
9333
9604
  } 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);
9605
+ const a = new pe(await this.getState(s), this);
9335
9606
  if (!a.isInteractionAvailable(e)) return { error: `interaction ${e} not available` };
9336
9607
  const o = await i.call(r, s, this.checkUserRef);
9337
9608
  if (o.error)
@@ -9352,14 +9623,14 @@ class et {
9352
9623
  async saveUserRefs(t, e, r) {
9353
9624
  const i = (await this.getActivity(t))?.refs || {};
9354
9625
  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]) {
9626
+ if (Y.is(s.itemRef) && s.itemRef?.name && r.payload[s.name]) {
9356
9627
  const a = r.payload[s.name];
9357
9628
  s.isCollection ? (i[s.itemRef.name] || (i[s.itemRef.name] = []), i[s.itemRef.name].push(a.id)) : i[s.itemRef.name] = a.id;
9358
9629
  }
9359
9630
  }), await this.setActivity(t, { refs: i });
9360
9631
  }
9361
9632
  }
9362
- class Xr extends D {
9633
+ class ii extends D {
9363
9634
  onChange(t, e) {
9364
9635
  if (this.graph.isStartNode(t)) {
9365
9636
  if (e)
@@ -9370,25 +9641,25 @@ class Xr extends D {
9370
9641
  }
9371
9642
  }
9372
9643
  }
9373
- D.GroupStateNodeType.set("any", Xr);
9374
- class Yr extends D {
9644
+ D.GroupStateNodeType.set("any", ii);
9645
+ class si extends D {
9375
9646
  onChange(t, e) {
9376
9647
  this.isGroupCompleted() && this.complete();
9377
9648
  }
9378
9649
  }
9379
- D.GroupStateNodeType.set("every", Yr);
9380
- class zr extends D {
9650
+ D.GroupStateNodeType.set("every", si);
9651
+ class ai extends D {
9381
9652
  onChange(t, e) {
9382
9653
  this.graph.isEndNode(t) && this.complete();
9383
9654
  }
9384
9655
  }
9385
- D.GroupStateNodeType.set("race", zr);
9386
- class Zr extends D {
9656
+ D.GroupStateNodeType.set("race", ai);
9657
+ class oi extends D {
9387
9658
  // 可以根据 group 上的具体配置逻辑,来动态决定。
9388
9659
  }
9389
- D.GroupStateNodeType.set("program", Zr);
9390
- const I = new fe(), Vt = "_Interaction_", Nt = "_Activity_", Ie = C.create({
9391
- name: Vt,
9660
+ D.GroupStateNodeType.set("program", oi);
9661
+ const I = new ye(), _t = "_Interaction_", St = "_Activity_", Me = C.create({
9662
+ name: _t,
9392
9663
  properties: [
9393
9664
  T.create({
9394
9665
  name: "interactionId",
@@ -9416,8 +9687,8 @@ const I = new fe(), Vt = "_Interaction_", Nt = "_Activity_", Ie = C.create({
9416
9687
  collection: !1
9417
9688
  })
9418
9689
  ]
9419
- }), Ce = C.create({
9420
- name: Nt,
9690
+ }), $e = C.create({
9691
+ name: St,
9421
9692
  properties: [
9422
9693
  T.create({
9423
9694
  name: "name",
@@ -9440,21 +9711,21 @@ const I = new fe(), Vt = "_Interaction_", Nt = "_Activity_", Ie = C.create({
9440
9711
  collection: !1
9441
9712
  })
9442
9713
  ]
9443
- }), ti = P.create({
9714
+ }), ni = P.create({
9444
9715
  name: "activityInteraction",
9445
- source: Ce,
9716
+ source: $e,
9446
9717
  sourceProperty: "interaction",
9447
- target: Ie,
9718
+ target: Me,
9448
9719
  targetProperty: "activity",
9449
9720
  type: "1:n"
9450
9721
  });
9451
- class ei {
9722
+ class ci {
9452
9723
  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);
9724
+ 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($e, Me), this.controller.relations.push(ni), e.forEach((i) => {
9725
+ const s = new rt(i, t);
9455
9726
  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
9727
  }), r.forEach((i) => {
9457
- const s = new Ee(i, t);
9728
+ const s = new xe(i, t);
9458
9729
  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
9730
  });
9460
9731
  }
@@ -9463,7 +9734,7 @@ class ei {
9463
9734
  try {
9464
9735
  const s = this.interactionCallsByName.get(t);
9465
9736
  if (!s)
9466
- throw new U(`Cannot find interaction for ${t}`, {
9737
+ throw new G(`Cannot find interaction for ${t}`, {
9467
9738
  interactionName: t,
9468
9739
  userId: e.user?.id,
9469
9740
  payload: e.payload,
@@ -9475,7 +9746,7 @@ class ei {
9475
9746
  o = await s.call(e);
9476
9747
  } catch (n) {
9477
9748
  a = n, o = {
9478
- error: new U("Interaction execution failed", {
9749
+ error: new G("Interaction execution failed", {
9479
9750
  interactionName: t,
9480
9751
  userId: e.user?.id,
9481
9752
  payload: e.payload,
@@ -9492,7 +9763,7 @@ class ei {
9492
9763
  }
9493
9764
  return o;
9494
9765
  } catch (s) {
9495
- throw new U("Unexpected error during interaction call", {
9766
+ throw new G("Unexpected error during interaction call", {
9496
9767
  interactionName: t,
9497
9768
  userId: e.user?.id,
9498
9769
  payload: e.payload,
@@ -9506,7 +9777,7 @@ class ei {
9506
9777
  try {
9507
9778
  const o = this.activityCallsByName.get(t);
9508
9779
  if (!o)
9509
- throw new ce(`Cannot find activity for ${t}`, {
9780
+ throw new de(`Cannot find activity for ${t}`, {
9510
9781
  activityName: t,
9511
9782
  context: {
9512
9783
  interactionName: e,
@@ -9517,7 +9788,7 @@ class ei {
9517
9788
  a.info({ label: "activity", message: o.activity.name }), await this.controller.system.storage.beginTransaction(o.activity.name);
9518
9789
  const n = o.interactionCallByName.get(e);
9519
9790
  if (!n) {
9520
- const l = new U(`Cannot find interaction ${e} in activity ${t}`, {
9791
+ const l = new G(`Cannot find interaction ${e} in activity ${t}`, {
9521
9792
  interactionName: e,
9522
9793
  userId: i.user?.id,
9523
9794
  payload: i.payload,
@@ -9529,7 +9800,7 @@ class ei {
9529
9800
  const c = await o.callInteraction(r, n.interaction.uuid, i);
9530
9801
  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
9802
  } catch (o) {
9532
- throw new ce("Unexpected error during activity interaction call", {
9803
+ throw new de("Unexpected error during activity interaction call", {
9533
9804
  activityName: t,
9534
9805
  context: {
9535
9806
  interactionName: e,
@@ -9548,7 +9819,7 @@ class ei {
9548
9819
  t.sideEffects || (t.sideEffects = {});
9549
9820
  for (let a of s)
9550
9821
  try {
9551
- if (a instanceof K)
9822
+ if (a instanceof X)
9552
9823
  t.sideEffects[a.name] = {
9553
9824
  result: await a.content(i)
9554
9825
  };
@@ -9560,7 +9831,7 @@ class ei {
9560
9831
  }
9561
9832
  } catch (o) {
9562
9833
  let n = "unknown";
9563
- a instanceof K ? n = a.name : n = a.name || "unknown", e.error({ label: "recordMutationSideEffect", message: n }), t.sideEffects[n] = {
9834
+ a instanceof X ? n = a.name : n = a.name || "unknown", e.error({ label: "recordMutationSideEffect", message: n }), t.sideEffects[n] = {
9564
9835
  error: o
9565
9836
  };
9566
9837
  }
@@ -9568,7 +9839,7 @@ class ei {
9568
9839
  }
9569
9840
  }
9570
9841
  async createActivity(t) {
9571
- return this.controller.system.storage.create(Nt, {
9842
+ return this.controller.system.storage.create(St, {
9572
9843
  ...t,
9573
9844
  state: t.state,
9574
9845
  refs: t.refs
@@ -9578,20 +9849,20 @@ class ei {
9578
9849
  const r = {
9579
9850
  ...e
9580
9851
  };
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);
9852
+ 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
9853
  }
9583
9854
  async getActivity(t) {
9584
- return (await this.controller.system.storage.find(Nt, t, void 0, ["*"])).map((e) => ({
9855
+ return (await this.controller.system.storage.find(St, t, void 0, ["*"])).map((e) => ({
9585
9856
  ...e,
9586
9857
  state: e.state,
9587
9858
  refs: e.refs
9588
9859
  }));
9589
9860
  }
9590
9861
  async saveEvent(t) {
9591
- return this.controller.system.storage.create(Vt, t);
9862
+ return this.controller.system.storage.create(_t, t);
9592
9863
  }
9593
9864
  async getEvent(t) {
9594
- return (await this.controller.system.storage.find(Vt, t, void 0, ["*"])).map((e) => ({
9865
+ return (await this.controller.system.storage.find(_t, t, void 0, ["*"])).map((e) => ({
9595
9866
  ...e
9596
9867
  }));
9597
9868
  }
@@ -9608,32 +9879,32 @@ class ei {
9608
9879
  return this.interactionCallsByName.get(t);
9609
9880
  }
9610
9881
  }
9611
- const At = new fe();
9612
- function ri() {
9613
- return At.getStore()?.effects;
9882
+ const It = new ye();
9883
+ function li() {
9884
+ return It.getStore()?.effects;
9614
9885
  }
9615
- function de(u) {
9616
- const t = At.getStore();
9886
+ function fe(u) {
9887
+ const t = It.getStore();
9617
9888
  t?.effects && t.effects.push(...u);
9618
9889
  }
9619
- const _i = "User";
9620
- class K {
9890
+ const Ui = "User";
9891
+ class X {
9621
9892
  constructor(t) {
9622
9893
  this.name = t.name, this.record = t.record, this.content = t.content;
9623
9894
  }
9624
9895
  static create(t) {
9625
- return new K(t);
9896
+ return new X(t);
9626
9897
  }
9627
9898
  }
9628
- const Lt = "_isDeleted_", qi = {
9899
+ const qt = "_isDeleted_", Hi = {
9629
9900
  create() {
9630
9901
  return T.create({
9631
- name: Lt,
9902
+ name: qt,
9632
9903
  type: "boolean"
9633
9904
  });
9634
9905
  }
9635
9906
  };
9636
- class Bi {
9907
+ class Gi {
9637
9908
  constructor(t) {
9638
9909
  this.recordNameToSideEffects = /* @__PURE__ */ new Map(), this.globals = {
9639
9910
  BoolExp: R,
@@ -9652,21 +9923,21 @@ class Bi {
9652
9923
  forceThtrowInteractionError: d = !1
9653
9924
  // 会 catch 住 error,并在 result 中返回。
9654
9925
  } = 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);
9926
+ 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 ci(this, s, a);
9656
9927
  const h = [
9657
- ...$r,
9658
- ...Dr,
9659
- ...Cr,
9660
- ...Ar,
9661
- ...Sr,
9662
- ..._r,
9663
- ...Wr,
9664
- ...Qr,
9665
- ...wr,
9666
- ...Gr,
9928
+ ...Lr,
9929
+ ...qr,
9930
+ ...Fr,
9931
+ ...Pr,
9932
+ ...xr,
9933
+ ...Hr,
9934
+ ...Xr,
9935
+ ...Jr,
9936
+ ...Er,
9937
+ ...ei,
9667
9938
  ...c
9668
9939
  ];
9669
- this.scheduler = new Kr(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
9940
+ this.scheduler = new ri(this, this.entities, this.relations, this.dict, h), n.forEach((p) => {
9670
9941
  let y = this.recordNameToSideEffects.get(p.record.name);
9671
9942
  y || this.recordNameToSideEffects.set(p.record.name, y = /* @__PURE__ */ new Set()), y.add(p);
9672
9943
  });
@@ -9686,7 +9957,7 @@ class Bi {
9686
9957
  }
9687
9958
  }
9688
9959
  async applyResult(t, e, r) {
9689
- if (!(e instanceof vt)) {
9960
+ if (!(e instanceof At)) {
9690
9961
  if (t.type === "global")
9691
9962
  return this.system.storage.dict.set(t.id.name, e);
9692
9963
  if (t.type === "entity") {
@@ -9705,12 +9976,12 @@ class Bi {
9705
9976
  await this.system.storage.create(i.id.name, a);
9706
9977
  } else {
9707
9978
  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 });
9979
+ 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
9980
  }
9710
9981
  }
9711
9982
  }
9712
9983
  async applyResultPatch(t, e, r) {
9713
- if (e instanceof vt || e === void 0) return;
9984
+ if (e instanceof At || e === void 0) return;
9714
9985
  const i = Array.isArray(e) ? e : [e];
9715
9986
  for (const s of i) {
9716
9987
  if (t.type === "global")
@@ -9728,18 +9999,18 @@ class Bi {
9728
9999
  }
9729
10000
  } else {
9730
10001
  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 });
10002
+ 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
10003
  }
9733
10004
  }
9734
10005
  }
9735
10006
  async callInteraction(t, e) {
9736
10007
  try {
9737
- const r = { effects: [] }, i = await At.run(r, async () => await this.activityManager.callInteraction(t, e));
10008
+ const r = { effects: [] }, i = await It.run(r, async () => await this.activityManager.callInteraction(t, e));
9738
10009
  if (i.effects = r.effects, i.error && this.forceThtrowInteractionError)
9739
10010
  throw i.error;
9740
10011
  return i;
9741
10012
  } catch (r) {
9742
- throw new U("Failed to call interaction", {
10013
+ throw new G("Failed to call interaction", {
9743
10014
  interactionName: t,
9744
10015
  userId: e.user?.id,
9745
10016
  payload: e.payload,
@@ -9750,7 +10021,7 @@ class Bi {
9750
10021
  }
9751
10022
  async callActivityInteraction(t, e, r, i) {
9752
10023
  try {
9753
- const s = { effects: [] }, a = await At.run(s, async () => await this.activityManager.callActivityInteraction(t, e, r, i));
10024
+ const s = { effects: [] }, a = await It.run(s, async () => await this.activityManager.callActivityInteraction(t, e, r, i));
9754
10025
  if (a.effects && s.effects.length > 0) {
9755
10026
  const o = s.effects.filter(
9756
10027
  (n) => !a.effects.some(
@@ -9763,7 +10034,7 @@ class Bi {
9763
10034
  throw a.error;
9764
10035
  return a;
9765
10036
  } catch (s) {
9766
- throw new U("Failed to call activity interaction", {
10037
+ throw new G("Failed to call activity interaction", {
9767
10038
  interactionName: e,
9768
10039
  userId: i.user?.id,
9769
10040
  payload: i.payload,
@@ -9780,7 +10051,7 @@ class Bi {
9780
10051
  if (s)
9781
10052
  for (let a of s)
9782
10053
  try {
9783
- if (a instanceof K)
10054
+ if (a instanceof X)
9784
10055
  t.sideEffects[a.name] = {
9785
10056
  result: await a.content(i)
9786
10057
  };
@@ -9792,7 +10063,7 @@ class Bi {
9792
10063
  }
9793
10064
  } catch (o) {
9794
10065
  let n = "unknown";
9795
- a instanceof K ? n = a.name : n = a.name || "unknown", e.error({ label: "recordMutationSideEffect", message: n }), t.sideEffects[n] = {
10066
+ a instanceof X ? n = a.name : n = a.name || "unknown", e.error({ label: "recordMutationSideEffect", message: n }), t.sideEffects[n] = {
9796
10067
  error: o
9797
10068
  };
9798
10069
  }
@@ -9803,7 +10074,7 @@ class Bi {
9803
10074
  this.callbacks.has(t) || this.callbacks.set(t, /* @__PURE__ */ new Set()), this.callbacks.get(t).add(e);
9804
10075
  }
9805
10076
  }
9806
- let ii = class {
10077
+ let ui = class {
9807
10078
  constructor(t) {
9808
10079
  this.db = t;
9809
10080
  }
@@ -9815,12 +10086,12 @@ let ii = class {
9815
10086
  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
10087
  }
9817
10088
  };
9818
- class si {
10089
+ class di {
9819
10090
  constructor(t = ":memory:", e) {
9820
- this.file = t, this.options = e, this.idSystem = new ii(this), this.logger = this.options?.logger || bt;
10091
+ this.file = t, this.options = e, this.idSystem = new ui(this), this.logger = this.options?.logger || Rt;
9821
10092
  }
9822
10093
  async open() {
9823
- this.db = new $e(this.file, this.options), await this.idSystem.setup();
10094
+ this.db = new Oe(this.file, this.options), await this.idSystem.setup();
9824
10095
  }
9825
10096
  async query(t, e = [], r = "") {
9826
10097
  const i = I.getStore(), s = this.logger.child(i?.logContext || {}), a = e.map((o) => o === !1 ? 0 : o === !0 ? 1 : o);
@@ -9847,7 +10118,7 @@ class si {
9847
10118
  name: r,
9848
10119
  sql: t,
9849
10120
  params: a
9850
- }), this.db.prepare(`${t} RETURNING ${at}`).run(...a);
10121
+ }), this.db.prepare(`${t} RETURNING ${ot}`).run(...a);
9851
10122
  }
9852
10123
  async delete(t, e, r = "") {
9853
10124
  const i = I.getStore(), s = this.logger.child(i?.logContext || {}), a = e.map((o) => o === !1 ? 0 : o === !0 ? 1 : o);
@@ -9887,13 +10158,13 @@ class si {
9887
10158
  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
10159
  }
9889
10160
  }
9890
- function ai(u) {
10161
+ function hi(u) {
9891
10162
  return encodeURI(JSON.stringify(u));
9892
10163
  }
9893
- function oi(u) {
10164
+ function pi(u) {
9894
10165
  return u === void 0 ? void 0 : JSON.parse(decodeURI(u));
9895
10166
  }
9896
- class ni {
10167
+ class fi {
9897
10168
  constructor(t) {
9898
10169
  this.db = t, this.callbacks = /* @__PURE__ */ new Set(), this.dict = {
9899
10170
  get: async (e) => {
@@ -9917,21 +10188,21 @@ class ni {
9917
10188
  }
9918
10189
  // CAUTION kv 结构数据的实现也用 er。这是系统约定,因为也需要 Record 事件!
9919
10190
  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);
10191
+ const i = m.atom({ key: "key", value: ["=", e] }).and({ key: "concept", value: ["=", t] }), s = (await this.queryHandle.findOne(et, i, void 0, ["value"]))?.value;
10192
+ return s === void 0 ? r : pi(s);
9922
10193
  }
9923
10194
  async set(t, e, r, i) {
9924
10195
  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);
10196
+ 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: hi(r) }], i) : this.callWithEvents(this.queryHandle.create.bind(this.queryHandle), [et, { concept: t, key: e.toString(), value: encodeURI(JSON.stringify(r)) }], i);
9926
10197
  }
9927
10198
  async setup(t, e, r = !1) {
9928
10199
  await this.db.open(r);
9929
- const i = new hr(
10200
+ const i = new Rr(
9930
10201
  t,
9931
10202
  e,
9932
10203
  this.db
9933
10204
  );
9934
- r && await i.createTables(), this.queryHandle = new ze(new Ze(i.map), this.db), this.map = i.map;
10205
+ r && await i.createTables(), this.queryHandle = new ar(new or(i.map), this.db), this.map = i.map;
9935
10206
  }
9936
10207
  findOne(...t) {
9937
10208
  return this.queryHandle.findOne(...t);
@@ -9951,8 +10222,8 @@ class ni {
9951
10222
  async callWithEvents(t, e, r = []) {
9952
10223
  const i = [], s = await t(...e, i), a = await this.dispatch(i);
9953
10224
  r.push(...i, ...a);
9954
- const o = ri();
9955
- return o && i.length > 0 && de(i), o && a.length > 0 && de(a), s;
10225
+ const o = li();
10226
+ return o && i.length > 0 && fe(i), o && a.length > 0 && fe(a), s;
9956
10227
  }
9957
10228
  findRelationByName(...t) {
9958
10229
  return this.queryHandle.findRelationByName(...t);
@@ -9990,8 +10261,8 @@ class ni {
9990
10261
  return this.db.close();
9991
10262
  }
9992
10263
  }
9993
- var ci = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(ci || {});
9994
- class ee {
10264
+ var mi = /* @__PURE__ */ ((u) => (u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u))(mi || {});
10265
+ class ie {
9995
10266
  constructor(t = 0) {
9996
10267
  this.level = t;
9997
10268
  }
@@ -10002,11 +10273,11 @@ class ee {
10002
10273
  this.level >= 0 && console.error({ type: t, name: e, sql: r, params: i, error: s });
10003
10274
  }
10004
10275
  child() {
10005
- return new ee(this.level);
10276
+ return new ie(this.level);
10006
10277
  }
10007
10278
  }
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 {
10279
+ var yi = /* @__PURE__ */ ((u) => (u[u.MUTE = -1] = "MUTE", u[u.ERROR = 0] = "ERROR", u[u.INFO = 1] = "INFO", u[u.DEBUG = 2] = "DEBUG", u))(yi || {});
10280
+ class se {
10010
10281
  constructor(t = 0) {
10011
10282
  this.level = t;
10012
10283
  }
@@ -10020,16 +10291,16 @@ class re {
10020
10291
  this.level >= 2 && console.debug(`[DEBUG] ${t}: ${e}`, r);
10021
10292
  }
10022
10293
  child(t) {
10023
- return new re(this.level);
10294
+ return new se(this.level);
10024
10295
  }
10025
10296
  }
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);
10297
+ const Rt = new ie(), gi = new se();
10298
+ class Xi {
10299
+ constructor(t = new di(void 0, { logger: Rt }), e = gi) {
10300
+ this.logger = e, this.conceptClass = /* @__PURE__ */ new Map(), this.storage = new fi(t);
10030
10301
  }
10031
10302
  setup(t, e, r, i = !1) {
10032
- const s = new Ne(t, e), { entities: a, relations: o } = s.getAll();
10303
+ const s = new ve(t, e), { entities: a, relations: o } = s.getAll();
10033
10304
  return r.forEach(({ dataContext: n, state: c }) => {
10034
10305
  Object.entries(c).forEach(([l, d]) => {
10035
10306
  if (d instanceof E) {
@@ -10055,7 +10326,7 @@ class Ji {
10055
10326
  }
10056
10327
  });
10057
10328
  }), this.storage.setup(
10058
- [...a, fr, pr],
10329
+ [...a, Nr, wr],
10059
10330
  o,
10060
10331
  i
10061
10332
  );
@@ -10064,8 +10335,8 @@ class Ji {
10064
10335
  this.storage.destroy();
10065
10336
  }
10066
10337
  }
10067
- const { Client: he } = Pe;
10068
- let di = class {
10338
+ const { Client: me } = Fe;
10339
+ let bi = class {
10069
10340
  constructor(t) {
10070
10341
  this.db = t;
10071
10342
  }
@@ -10077,14 +10348,14 @@ let di = class {
10077
10348
  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
10349
  }
10079
10350
  };
10080
- class ji {
10351
+ class zi {
10081
10352
  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({
10353
+ this.database = t, this.options = e, this.idSystem = new bi(this), this.logger = this.options?.logger || Rt, this.db = new me({
10083
10354
  ...e
10084
10355
  });
10085
10356
  }
10086
10357
  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({
10358
+ 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 me({
10088
10359
  ...this.options,
10089
10360
  database: this.database
10090
10361
  }), await this.db.connect()), await this.idSystem.setup();
@@ -10115,7 +10386,7 @@ class ji {
10115
10386
  sql: t,
10116
10387
  params: a
10117
10388
  });
10118
- const o = `${t} RETURNING "${at}"`;
10389
+ const o = `${t} RETURNING "${ot}"`;
10119
10390
  return (await this.db.query(o, a)).rows[0];
10120
10391
  }
10121
10392
  async delete(t, e, r = "") {
@@ -10158,7 +10429,7 @@ class ji {
10158
10429
  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
10430
  }
10160
10431
  }
10161
- let hi = class {
10432
+ let Ri = class {
10162
10433
  constructor(t) {
10163
10434
  this.db = t;
10164
10435
  }
@@ -10166,12 +10437,12 @@ let hi = class {
10166
10437
  return this.db.scheme('CREATE Table IF NOT EXISTS "_IDS_" (last INTEGER, name TEXT)');
10167
10438
  }
10168
10439
  async getAutoId(t) {
10169
- return pe();
10440
+ return Re();
10170
10441
  }
10171
10442
  };
10172
- class Gi {
10443
+ class ts {
10173
10444
  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);
10445
+ this.database = t, this.options = e, this.idSystem = new Ri(this), this.logger = this.options?.logger || Rt, this.db = new Ve(this.database);
10175
10446
  }
10176
10447
  async open(t = !1) {
10177
10448
  if (t) {
@@ -10223,7 +10494,7 @@ class Gi {
10223
10494
  sql: t,
10224
10495
  params: a
10225
10496
  });
10226
- const o = `${t} RETURNING "${at}"`;
10497
+ const o = `${t} RETURNING "${ot}"`;
10227
10498
  try {
10228
10499
  return (await this.db.query(o, a)).rows[0];
10229
10500
  } catch (n) {
@@ -10286,7 +10557,7 @@ class Gi {
10286
10557
  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
10558
  }
10288
10559
  }
10289
- class pi {
10560
+ class wi {
10290
10561
  constructor(t) {
10291
10562
  this.db = t;
10292
10563
  }
@@ -10298,16 +10569,16 @@ class pi {
10298
10569
  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
10570
  }
10300
10571
  }
10301
- class Ki {
10572
+ class es {
10302
10573
  constructor(t, e = {}) {
10303
- this.database = t, this.options = e, this.idSystem = new pi(this), this.logger = this.options?.logger || bt;
10574
+ this.database = t, this.options = e, this.idSystem = new wi(this), this.logger = this.options?.logger || Rt;
10304
10575
  }
10305
10576
  async open(t = !1) {
10306
- ({ ...this.options }, this.db = await ae.createConnection({
10577
+ ({ ...this.options }, this.db = await ne.createConnection({
10307
10578
  ...this.options
10308
10579
  })), await this.db.connect();
10309
10580
  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({
10581
+ 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
10582
  ...this.options,
10312
10583
  database: this.database
10313
10584
  }), await this.db.connect()), await this.db.query("SET sql_mode='ANSI_QUOTES'"), await this.idSystem.setup();
@@ -10379,176 +10650,176 @@ class Ki {
10379
10650
  }
10380
10651
  }
10381
10652
  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,
10653
+ St as ACTIVITY_RECORD,
10654
+ Ze as ALL_ATTR_SYMBOL,
10655
+ Ft as ASYNC_TASK_RECORD,
10656
+ xt as Action,
10657
+ Ut as Activity,
10658
+ rt as ActivityCall,
10659
+ it as ActivityGroup,
10660
+ ni as ActivityInteractionRelation,
10661
+ ci as ActivityManager,
10662
+ $e as ActivityStateEntity,
10663
+ mt as Any,
10664
+ Fr as AnyHandles,
10394
10665
  W as AttributeInfo,
10395
10666
  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,
10667
+ Y as Attributive,
10668
+ Ct as Attributives,
10669
+ pt as Average,
10670
+ Xr as AverageHandles,
10671
+ $i as BaseKlass,
10672
+ nt as BoolAtomData,
10402
10673
  R as BoolExp,
10403
- nt as BoolExpressionData,
10674
+ ct as BoolExpressionData,
10404
10675
  J as ComputationDataDepError,
10405
- Q as ComputationError,
10676
+ V as ComputationError,
10406
10677
  A as ComputationResult,
10407
- ve as ComputationResultAsync,
10408
- Se as ComputationResultFullRecompute,
10409
- ke as ComputationResultResolved,
10410
- vt as ComputationResultSkip,
10411
- le as ComputationStateError,
10678
+ Ee as ComputationResultAsync,
10679
+ Ae as ComputationResultFullRecompute,
10680
+ Ie as ComputationResultResolved,
10681
+ At as ComputationResultSkip,
10682
+ he as ComputationStateError,
10412
10683
  Ht as Condition,
10413
10684
  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,
10685
+ $t as Conditions,
10686
+ Gi as Controller,
10687
+ dt as Count,
10688
+ Lr as CountHandles,
10689
+ ee as Custom,
10690
+ ei as CustomHandles,
10691
+ ie as DBConsoleLogger,
10692
+ mi as DBLogLevel,
10693
+ Rr as DBSetup,
10694
+ ji as DELETED_STATE,
10424
10695
  q as DICTIONARY_RECORD,
10425
- jt as DataAttributive,
10426
- zt as DataAttributives,
10427
- Bt as Dictionary,
10428
- fr as DictionaryEntity,
10696
+ Gt as DataAttributive,
10697
+ te as DataAttributives,
10698
+ Jt as Dictionary,
10699
+ Nr as DictionaryEntity,
10429
10700
  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,
10701
+ zr as EntityCustomHandle,
10702
+ ar as EntityQueryHandle,
10703
+ or as EntityToTableMap,
10704
+ re as Equation,
10705
+ Kt as Event,
10706
+ ft as Every,
10707
+ Pr as EveryHandles,
10437
10708
  $ as Expression,
10438
- it as Gateway,
10439
- We as GetAction,
10440
- Er as GlobalAnyHandle,
10441
- qr as GlobalAverageHandle,
10709
+ st as Gateway,
10710
+ Xe as GetAction,
10711
+ Dr as GlobalAnyHandle,
10712
+ Gr as GlobalAverageHandle,
10442
10713
  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,
10714
+ Vr as GlobalCountHandle,
10715
+ Yr as GlobalCustomHandle,
10716
+ Mr as GlobalEveryHandle,
10717
+ Br as GlobalRealTimeComputation,
10718
+ kr as GlobalStateMachineHandle,
10719
+ jr as GlobalSumHandle,
10720
+ Ir as GlobalWeightedSummationHandle,
10721
+ qt as HARD_DELETION_PROPERTY_NAME,
10722
+ Hi as HardDeletionProperty,
10723
+ ue as ID_ATTR,
10724
+ _t as INTERACTION_RECORD,
10725
+ Et as Inequality,
10726
+ jt as Interaction,
10727
+ xe as InteractionCall,
10728
+ Me as InteractionEventEntity,
10729
+ Bt as KlassByName,
10459
10730
  f as LINK_SYMBOL,
10460
- St as LinkInfo,
10731
+ kt as LinkInfo,
10461
10732
  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,
10733
+ ze as Modifier,
10734
+ Xi as MonoSystem,
10735
+ es as MysqlDB,
10736
+ Ji as NON_DELETED_STATE,
10737
+ Wi as NON_EXIST_STATE,
10467
10738
  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,
10739
+ ts as PGLiteDB,
10740
+ Li as PHASE_AFTER_ALL,
10741
+ Qi as PHASE_BEFORE_ALL,
10742
+ Ot as PHASE_NORMAL,
10743
+ zt as Payload,
10744
+ Yt as PayloadItem,
10745
+ zi as PostgreSQLDB,
10475
10746
  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,
10747
+ Or as PropertyAnyHandle,
10748
+ Kr as PropertyAverageHandle,
10749
+ Qr as PropertyCountHandle,
10750
+ ti as PropertyCustomHandle,
10751
+ $r as PropertyEveryHandle,
10752
+ Wr as PropertyRealTimeComputation,
10753
+ Ar as PropertyStateMachineHandle,
10754
+ Ur as PropertySumHandle,
10755
+ Wt as PropertyTypes,
10756
+ Cr as PropertyWeightedSummationHandle,
10757
+ Se as Query,
10758
+ Te as QueryItem,
10759
+ ke as ROOT_LABEL,
10760
+ ot as ROW_ID_ATTR,
10761
+ yt as RealTime,
10762
+ Jr as RealTimeHandles,
10492
10763
  E as RecordBoundState,
10493
- st as RecordInfo,
10494
- K as RecordMutationSideEffect,
10764
+ at as RecordInfo,
10765
+ X as RecordMutationSideEffect,
10495
10766
  M as RecordQuery,
10496
- Ye as RecordQueryAgent,
10767
+ sr as RecordQueryAgent,
10497
10768
  _ as RecordQueryTree,
10498
- Pr as RecordsTransformHandle,
10499
- Tt as RecursiveContext,
10500
- Ne as RefContainer,
10769
+ _r as RecordsTransformHandle,
10770
+ vt as RecursiveContext,
10771
+ ve as RefContainer,
10501
10772
  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,
10773
+ Zr as RelationCustomHandle,
10774
+ di as SQLiteDB,
10775
+ et as SYSTEM_RECORD,
10776
+ ri as Scheduler,
10777
+ Zt as SideEffect,
10778
+ lt as StateMachine,
10779
+ Er as StateMachineHandles,
10780
+ z as StateNode,
10781
+ Xt as StateTransfer,
10782
+ ht as Summation,
10783
+ Hr as SummationHandles,
10784
+ se as SystemConsoleLogger,
10785
+ wr as SystemEntity,
10786
+ yi as SystemLogLevel,
10787
+ we as Transfer,
10788
+ Mt as Transform,
10789
+ qr as TransformHandles,
10790
+ Ui as USER_ENTITY,
10791
+ ut as WeightedSummation,
10792
+ xr as WeightedSummationHandles,
10793
+ fe as addToCurrentEffects,
10523
10794
  v as assert,
10524
- At as asyncEffectsContext,
10795
+ It as asyncEffectsContext,
10525
10796
  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,
10797
+ Fi as boolExpToAttributives,
10798
+ Ei as clearAllInstances,
10799
+ Mi as createClass,
10800
+ _e as createInstances,
10801
+ xi as createInstancesFromString,
10802
+ Vi as createUserRoleAttributive,
10803
+ Rt as dbConsoleLogger,
10804
+ wt as deepClone,
10805
+ Bi as everyAsync,
10806
+ vr as everyWithErrorAsync,
10807
+ _i as filterMap,
10808
+ Di as findRootActivity,
10809
+ Ne as forEachInteraction,
10539
10810
  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,
10811
+ li as getCurrentEffects,
10812
+ Pi as getInteractions,
10813
+ Qe as indexBy,
10814
+ ge as isObject,
10815
+ be as isPlainObject,
10816
+ qi as mapObject,
10817
+ Oi as parse,
10818
+ Le as registerKlass,
10819
+ Ii as removeAllInstance,
10820
+ Sr as someAsync,
10821
+ Ci as stringifyAllInstances,
10551
10822
  w as stringifyAttribute,
10552
- ui as systemConsoleLogger
10823
+ gi as systemConsoleLogger
10553
10824
  };
10554
10825
  //# sourceMappingURL=index.js.map