@hpcc-js/util 3.3.8 → 3.3.9

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,22 +1,31 @@
1
1
  var __defProp = Object.defineProperty;
2
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: !0, configurable: !0, writable: !0, value }) : obj[key] = value;
3
- var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key != "symbol" ? key + "" : key, value);
4
- const PKG_NAME = "@hpcc-js/util", PKG_VERSION = "3.2.0", BUILD_VERSION = "3.2.1";
2
+ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
5
+ var _a, _b, _c, _d;
6
+ const PKG_NAME = "@hpcc-js/util";
7
+ const PKG_VERSION = "3.2.0";
8
+ const BUILD_VERSION = "3.2.1";
5
9
  function find(o, predicate) {
6
- if (o == null)
10
+ if (o == null) {
7
11
  throw new TypeError('"o" is null or not defined');
12
+ }
8
13
  const len = o.length >>> 0;
9
- if (typeof predicate != "function")
14
+ if (typeof predicate !== "function") {
10
15
  throw new TypeError("predicate must be a function");
16
+ }
11
17
  const thisArg = arguments[1];
12
18
  let k = 0;
13
- for (; k < len; ) {
19
+ while (k < len) {
14
20
  const kValue = o[k];
15
- if (predicate.call(thisArg, kValue, k))
21
+ if (predicate.call(thisArg, kValue, k)) {
16
22
  return kValue;
23
+ }
17
24
  k++;
18
25
  }
26
+ return void 0;
19
27
  }
28
+ __name(find, "find");
20
29
  function compare(before, after) {
21
30
  const retVal = {
22
31
  update: [],
@@ -25,58 +34,101 @@ function compare(before, after) {
25
34
  };
26
35
  for (const row of before) {
27
36
  const otherIdx = retVal.enter.indexOf(row);
28
- otherIdx >= 0 ? (retVal.update.push(row), retVal.enter.splice(otherIdx, 1)) : retVal.exit.push(row);
37
+ if (otherIdx >= 0) {
38
+ retVal.update.push(row);
39
+ retVal.enter.splice(otherIdx, 1);
40
+ } else {
41
+ retVal.exit.push(row);
42
+ }
29
43
  }
30
44
  return retVal;
31
45
  }
46
+ __name(compare, "compare");
32
47
  function compare2(before, after, idFunc, updateFunc = (before2, after2) => after2) {
33
48
  const retVal = {
34
49
  update: [],
35
50
  exit: [],
36
51
  enter: []
37
52
  };
38
- if (before === after)
39
- return retVal.update = before, retVal;
53
+ if (before === after) {
54
+ retVal.update = before;
55
+ return retVal;
56
+ }
40
57
  const unknownMap = {};
41
58
  after.forEach((item) => {
42
59
  unknownMap[idFunc(item)] = item;
43
60
  });
44
61
  for (const row of before) {
45
- const id = idFunc(row), item = unknownMap[id];
46
- item !== void 0 ? (delete unknownMap[id], retVal.update.push(updateFunc(row, item))) : retVal.exit.push(row);
62
+ const id = idFunc(row);
63
+ const item = unknownMap[id];
64
+ if (item !== void 0) {
65
+ delete unknownMap[id];
66
+ retVal.update.push(updateFunc(row, item));
67
+ } else {
68
+ retVal.exit.push(row);
69
+ }
47
70
  }
48
- for (const key in unknownMap)
71
+ for (const key in unknownMap) {
49
72
  retVal.enter.push(unknownMap[key]);
73
+ }
50
74
  return retVal;
51
75
  }
76
+ __name(compare2, "compare2");
52
77
  function pad(hash, len) {
53
- for (; hash.length < len; )
78
+ while (hash.length < len) {
54
79
  hash = "0" + hash;
80
+ }
55
81
  return hash;
56
82
  }
83
+ __name(pad, "pad");
57
84
  function fold(hash, text) {
58
- if (text.length === 0)
85
+ if (text.length === 0) {
59
86
  return hash;
87
+ }
60
88
  for (let i = 0; i < text.length; ++i) {
61
89
  const chr = text.charCodeAt(i);
62
- hash = (hash << 5) - hash + chr, hash |= 0;
90
+ hash = (hash << 5) - hash + chr;
91
+ hash |= 0;
63
92
  }
64
93
  return hash < 0 ? hash * -2 : hash;
65
94
  }
95
+ __name(fold, "fold");
66
96
  function foldObject(hash, o, seen) {
67
- return typeof o.hashSum == "function" ? o.hashSum() : Object.keys(o).sort().reduce((input, key) => foldValue(input, o[key], key, seen), hash);
97
+ if (typeof o.hashSum === "function") {
98
+ return o.hashSum();
99
+ }
100
+ return Object.keys(o).sort().reduce((input, key) => {
101
+ return foldValue(input, o[key], key, seen);
102
+ }, hash);
68
103
  }
104
+ __name(foldObject, "foldObject");
69
105
  function foldValue(input, value, key, seen) {
70
106
  const hash = fold(fold(fold(input, key), toString(value)), typeof value);
71
- return value === null ? fold(hash, "null") : value === void 0 ? fold(hash, "undefined") : typeof value == "object" ? seen.indexOf(value) !== -1 ? fold(hash, "[Circular]" + key) : (seen.push(value), foldObject(hash, value, seen)) : fold(hash, value.toString());
107
+ if (value === null) {
108
+ return fold(hash, "null");
109
+ }
110
+ if (value === void 0) {
111
+ return fold(hash, "undefined");
112
+ }
113
+ if (typeof value === "object") {
114
+ if (seen.indexOf(value) !== -1) {
115
+ return fold(hash, "[Circular]" + key);
116
+ }
117
+ seen.push(value);
118
+ return foldObject(hash, value, seen);
119
+ }
120
+ return fold(hash, value.toString());
72
121
  }
122
+ __name(foldValue, "foldValue");
73
123
  function toString(o) {
74
124
  return Object.prototype.toString.call(o);
75
125
  }
126
+ __name(toString, "toString");
76
127
  function hashSum(o) {
77
128
  return pad(foldValue(0, o, "", []).toString(16), 8);
78
129
  }
79
- class Cache {
130
+ __name(hashSum, "hashSum");
131
+ const _Cache = class _Cache {
80
132
  constructor(calcID) {
81
133
  __publicField(this, "_cache", {});
82
134
  __publicField(this, "_calcID");
@@ -89,14 +141,20 @@ class Cache {
89
141
  return this._calcID(espObj) in this._cache;
90
142
  }
91
143
  set(obj) {
92
- return this._cache[this._calcID(obj)] = obj, obj;
144
+ this._cache[this._calcID(obj)] = obj;
145
+ return obj;
93
146
  }
94
147
  get(espObj, factory) {
95
148
  const retVal = this._cache[this._calcID(espObj)];
96
- return retVal || (factory ? this.set(factory()) : null);
149
+ if (!retVal) {
150
+ return factory ? this.set(factory()) : null;
151
+ }
152
+ return retVal;
97
153
  }
98
- }
99
- class AsyncCache {
154
+ };
155
+ __name(_Cache, "Cache");
156
+ let Cache = _Cache;
157
+ const _AsyncCache = class _AsyncCache {
100
158
  constructor(calcID) {
101
159
  __publicField(this, "_cache", {});
102
160
  __publicField(this, "_calcID");
@@ -109,42 +167,66 @@ class AsyncCache {
109
167
  return this._calcID(espObj) in this._cache;
110
168
  }
111
169
  set(espObj, obj) {
112
- return this._cache[this._calcID(espObj)] = obj, obj;
170
+ this._cache[this._calcID(espObj)] = obj;
171
+ return obj;
113
172
  }
114
173
  get(espObj, factory) {
115
174
  const retVal = this._cache[this._calcID(espObj)];
116
- return retVal || (factory ? this.set(espObj, factory()) : Promise.resolve(null));
175
+ if (!retVal) {
176
+ return factory ? this.set(espObj, factory()) : Promise.resolve(null);
177
+ }
178
+ return retVal;
117
179
  }
118
- }
180
+ };
181
+ __name(_AsyncCache, "AsyncCache");
182
+ let AsyncCache = _AsyncCache;
119
183
  function debounce(fn, timeout) {
120
184
  const promises = {};
121
185
  return (...params) => {
122
186
  const hash = hashSum(params);
123
- return promises[hash] || (promises[hash] = {
124
- clockStart: Date.now(),
125
- promise: fn(...params).then((response) => (timeout === void 0 ? promises[hash] = null : setTimeout(() => {
126
- promises[hash] = null;
127
- }, Math.max(timeout - (Date.now() - promises[hash].clockStart), 0)), response)).catch((e) => {
128
- throw promises[hash] = null, e;
129
- })
130
- }), promises[hash].promise;
187
+ if (!promises[hash]) {
188
+ promises[hash] = {
189
+ clockStart: Date.now(),
190
+ promise: fn(...params).then((response) => {
191
+ if (timeout === void 0) {
192
+ promises[hash] = null;
193
+ } else {
194
+ setTimeout(() => {
195
+ promises[hash] = null;
196
+ }, Math.max(timeout - (Date.now() - promises[hash].clockStart), 0));
197
+ }
198
+ return response;
199
+ }).catch((e) => {
200
+ promises[hash] = null;
201
+ throw e;
202
+ })
203
+ };
204
+ }
205
+ return promises[hash].promise;
131
206
  };
132
207
  }
208
+ __name(debounce, "debounce");
133
209
  function promiseTimeout(ms, promise) {
134
210
  let id;
135
211
  const timeout = new Promise((resolve, reject) => {
136
212
  id = setTimeout(() => {
137
- clearTimeout(id), reject("Timed out in " + ms + "ms.");
213
+ clearTimeout(id);
214
+ reject("Timed out in " + ms + "ms.");
138
215
  }, ms);
139
216
  });
140
217
  return Promise.race([
141
218
  promise,
142
219
  timeout
143
- ]).then((response) => (clearTimeout(id), response)).catch((e) => {
144
- throw clearTimeout(id), e;
220
+ ]).then((response) => {
221
+ clearTimeout(id);
222
+ return response;
223
+ }).catch((e) => {
224
+ clearTimeout(id);
225
+ throw e;
145
226
  });
146
227
  }
147
- class AsyncOrderedQueue {
228
+ __name(promiseTimeout, "promiseTimeout");
229
+ const _AsyncOrderedQueue = class _AsyncOrderedQueue {
148
230
  constructor() {
149
231
  __publicField(this, "_q", []);
150
232
  }
@@ -152,29 +234,46 @@ class AsyncOrderedQueue {
152
234
  return this._q[0] === p;
153
235
  }
154
236
  push(p) {
155
- const retVal = p.then((response) => this.isTop(retVal) ? (this._q.shift(), response) : new Promise((resolve, reject) => {
156
- const intervalHandler = setInterval(() => {
157
- this.isTop(retVal) && (clearInterval(intervalHandler), this._q.shift(), resolve(response));
158
- }, 20);
159
- }));
160
- return this._q.push(retVal), retVal;
237
+ const retVal = p.then((response) => {
238
+ if (this.isTop(retVal)) {
239
+ this._q.shift();
240
+ return response;
241
+ }
242
+ return new Promise((resolve, reject) => {
243
+ const intervalHandler = setInterval(() => {
244
+ if (this.isTop(retVal)) {
245
+ clearInterval(intervalHandler);
246
+ this._q.shift();
247
+ resolve(response);
248
+ }
249
+ }, 20);
250
+ });
251
+ });
252
+ this._q.push(retVal);
253
+ return retVal;
161
254
  }
162
- }
255
+ };
256
+ __name(_AsyncOrderedQueue, "AsyncOrderedQueue");
257
+ let AsyncOrderedQueue = _AsyncOrderedQueue;
163
258
  function sleep(ms) {
164
259
  return new Promise((resolve) => {
165
260
  setTimeout(() => resolve(), ms);
166
261
  });
167
262
  }
168
- class Dictionary {
263
+ __name(sleep, "sleep");
264
+ const _Dictionary = class _Dictionary {
169
265
  constructor(attrs) {
170
266
  __publicField(this, "store", {});
171
- if (attrs)
172
- for (const key in attrs)
267
+ if (attrs) {
268
+ for (const key in attrs) {
173
269
  this.set(key, attrs[key]);
270
+ }
271
+ }
174
272
  }
175
273
  set(key, value) {
176
274
  const retVal = this.store[key];
177
- return this.store[key] = value, retVal;
275
+ this.store[key] = value;
276
+ return retVal;
178
277
  }
179
278
  get(key) {
180
279
  return this.store[key];
@@ -187,18 +286,22 @@ class Dictionary {
187
286
  }
188
287
  keys() {
189
288
  const retVal = [];
190
- for (const key in this.store)
289
+ for (const key in this.store) {
191
290
  retVal.push(key);
291
+ }
192
292
  return retVal;
193
293
  }
194
294
  values() {
195
295
  const retVal = [];
196
- for (const key in this.store)
296
+ for (const key in this.store) {
197
297
  retVal.push(this.store[key]);
298
+ }
198
299
  return retVal;
199
300
  }
200
- }
201
- class DictionaryNoCase extends Dictionary {
301
+ };
302
+ __name(_Dictionary, "Dictionary");
303
+ let Dictionary = _Dictionary;
304
+ const _DictionaryNoCase = class _DictionaryNoCase extends Dictionary {
202
305
  constructor(attrs) {
203
306
  super(attrs);
204
307
  }
@@ -214,113 +317,145 @@ class DictionaryNoCase extends Dictionary {
214
317
  remove(key) {
215
318
  return super.remove(key.toLowerCase());
216
319
  }
217
- }
320
+ };
321
+ __name(_DictionaryNoCase, "DictionaryNoCase");
322
+ let DictionaryNoCase = _DictionaryNoCase;
218
323
  function espTime2Seconds(duration) {
219
- if (duration) {
220
- if (!isNaN(Number(duration)))
221
- return Number(duration);
222
- } else
324
+ if (!duration) {
223
325
  return 0;
326
+ } else {
327
+ if (!isNaN(Number(duration))) {
328
+ return Number(duration);
329
+ }
330
+ }
224
331
  const nsIndex = duration.indexOf("ns");
225
- if (nsIndex !== -1)
332
+ if (nsIndex !== -1) {
226
333
  return parseFloat(duration.substr(0, nsIndex)) / 1e9;
334
+ }
227
335
  const msIndex = duration.indexOf("ms");
228
- if (msIndex !== -1)
336
+ if (msIndex !== -1) {
229
337
  return parseFloat(duration.substr(0, msIndex)) / 1e3;
338
+ }
230
339
  const sIndex = duration.indexOf("s");
231
- if (sIndex !== -1 && duration.indexOf("days") === -1)
340
+ if (sIndex !== -1 && duration.indexOf("days") === -1) {
232
341
  return parseFloat(duration.substr(0, sIndex));
233
- const dayTimeParts = duration.split(" days "), days = dayTimeParts.length > 1 ? parseFloat(dayTimeParts[0]) : 0, time = dayTimeParts.length > 1 ? dayTimeParts[1] : dayTimeParts[0];
342
+ }
343
+ const dayTimeParts = duration.split(" days ");
344
+ const days = dayTimeParts.length > 1 ? parseFloat(dayTimeParts[0]) : 0;
345
+ const time = dayTimeParts.length > 1 ? dayTimeParts[1] : dayTimeParts[0];
234
346
  let secs = 0;
235
347
  const timeParts = time.split(":").reverse();
236
- for (let j = 0; j < timeParts.length; ++j)
348
+ for (let j = 0; j < timeParts.length; ++j) {
237
349
  secs += parseFloat(timeParts[j]) * Math.pow(60, j);
350
+ }
238
351
  return days * 24 * 60 * 60 + secs;
239
352
  }
240
- let GraphItem$1 = class {
353
+ __name(espTime2Seconds, "espTime2Seconds");
354
+ let GraphItem$1 = (_a = class {
241
355
  constructor(graph, parent) {
242
356
  __publicField(this, "_graph");
243
357
  __publicField(this, "parent");
244
358
  __publicField(this, "props", {});
245
- this._graph = graph, this.parent = parent;
359
+ this._graph = graph;
360
+ this.parent = parent;
246
361
  }
247
- }, Subgraph$1 = class Subgraph extends GraphItem$1 {
362
+ }, __name(_a, "GraphItem"), _a);
363
+ let Subgraph$1 = (_b = class extends GraphItem$1 {
248
364
  constructor(graph, parent, _) {
249
365
  super(graph, parent);
250
366
  __publicField(this, "subgraphs", []);
251
367
  __publicField(this, "vertices", []);
252
368
  __publicField(this, "edges", []);
253
369
  __publicField(this, "_");
254
- parent && parent._addSubgraph(this), this._ = _;
370
+ if (parent) {
371
+ parent._addSubgraph(this);
372
+ }
373
+ this._ = _;
255
374
  }
256
- remove(full = !0) {
375
+ remove(full = true) {
257
376
  this._graph.removeSubgraph(this, full);
258
377
  }
259
378
  createSubgraph(_) {
260
379
  return this._graph.createSubgraph(this, _);
261
380
  }
262
381
  _addSubgraph(subgraph) {
263
- if (this.subgraphs.indexOf(subgraph) >= 0)
382
+ if (this.subgraphs.indexOf(subgraph) >= 0) {
264
383
  throw new Error("Subgraph already exists");
384
+ }
265
385
  this.subgraphs.push(subgraph);
266
386
  }
267
387
  _removeSubgraph(subgraph) {
268
388
  const idx = this.subgraphs.indexOf(subgraph);
269
- if (idx < 0)
389
+ if (idx < 0) {
270
390
  throw new Error("Subgraph does not exist");
391
+ }
271
392
  this.subgraphs.splice(idx, 1);
272
393
  }
273
394
  removeAllSubgraphs() {
274
- for (let i = this.subgraphs.length - 1; i >= 0; --i)
275
- this._graph.removeSubgraph(this.subgraphs[i], !0);
395
+ for (let i = this.subgraphs.length - 1; i >= 0; --i) {
396
+ this._graph.removeSubgraph(this.subgraphs[i], true);
397
+ }
276
398
  }
277
399
  createVertex(_) {
278
400
  return this._graph.createVertex(this, _);
279
401
  }
280
402
  _addVertex(vertex) {
281
- if (this.vertices.indexOf(vertex) >= 0)
403
+ if (this.vertices.indexOf(vertex) >= 0) {
282
404
  throw new Error("Vertex already exists");
405
+ }
283
406
  this.vertices.push(vertex);
284
407
  }
285
408
  _removeVertex(vertex) {
286
409
  const idx = this.vertices.indexOf(vertex);
287
- if (idx < 0)
410
+ if (idx < 0) {
288
411
  throw new Error("Vertex does not exist");
412
+ }
289
413
  this.vertices.splice(idx, 1);
290
414
  }
291
415
  removeAllVertices() {
292
- for (let i = this.vertices.length - 1; i >= 0; --i)
293
- this._graph.removeVertex(this.vertices[i], !0);
416
+ for (let i = this.vertices.length - 1; i >= 0; --i) {
417
+ this._graph.removeVertex(this.vertices[i], true);
418
+ }
294
419
  }
295
420
  createEdge(source, target, _) {
296
421
  return this._graph.createEdge(this, source, target, _);
297
422
  }
298
423
  _addEdge(edge) {
299
- if (this.edges.indexOf(edge) >= 0)
424
+ if (this.edges.indexOf(edge) >= 0) {
300
425
  throw new Error("Edge already exists");
426
+ }
301
427
  this.edges.push(edge);
302
428
  }
303
429
  _removeEdge(edge) {
304
430
  const idx = this.edges.indexOf(edge);
305
- if (idx < 0)
431
+ if (idx < 0) {
306
432
  throw new Error("Edge does not exist");
433
+ }
307
434
  this.edges.splice(idx, 1);
308
435
  }
309
436
  _add(item) {
310
- item instanceof Subgraph ? this._addSubgraph(item) : item instanceof Vertex$1 ? this._addVertex(item) : this._addEdge(item);
437
+ if (item instanceof _b) {
438
+ this._addSubgraph(item);
439
+ } else if (item instanceof Vertex$1) {
440
+ this._addVertex(item);
441
+ } else {
442
+ this._addEdge(item);
443
+ }
311
444
  }
312
- }, Vertex$1 = class extends GraphItem$1 {
445
+ }, __name(_b, "Subgraph"), _b);
446
+ let Vertex$1 = (_c = class extends GraphItem$1 {
313
447
  constructor(graph, parent, _) {
314
448
  super(graph, parent);
315
449
  __publicField(this, "inEdges", []);
316
450
  __publicField(this, "outEdges", []);
317
451
  __publicField(this, "_");
318
- parent._addVertex(this), this._ = _;
452
+ parent._addVertex(this);
453
+ this._ = _;
319
454
  }
320
455
  get edges() {
321
456
  return [...this.inEdges, ...this.outEdges];
322
457
  }
323
- remove(full = !0, _) {
458
+ remove(full = true, _) {
324
459
  return this._graph.removeVertex(this, full, _);
325
460
  }
326
461
  addInEdge(edge) {
@@ -328,8 +463,9 @@ let GraphItem$1 = class {
328
463
  }
329
464
  removeInEdge(edge) {
330
465
  const idx = this.inEdges.indexOf(edge);
331
- if (idx < 0)
466
+ if (idx < 0) {
332
467
  throw new Error("In edge does not exist");
468
+ }
333
469
  this.inEdges.splice(idx, 1);
334
470
  }
335
471
  addOutEdge(edge) {
@@ -337,27 +473,36 @@ let GraphItem$1 = class {
337
473
  }
338
474
  removeOutEdge(edge) {
339
475
  const idx = this.outEdges.indexOf(edge);
340
- if (idx < 0)
476
+ if (idx < 0) {
341
477
  throw new Error("Out edge does not exist");
478
+ }
342
479
  this.outEdges.splice(idx, 1);
343
480
  }
344
- }, Edge$1 = class extends GraphItem$1 {
481
+ }, __name(_c, "Vertex"), _c);
482
+ let Edge$1 = (_d = class extends GraphItem$1 {
345
483
  constructor(graph, parent, source, target, _) {
346
484
  super(graph, parent);
347
485
  __publicField(this, "source");
348
486
  __publicField(this, "target");
349
487
  __publicField(this, "_");
350
- if (!source)
488
+ if (!source) {
351
489
  throw new Error("Missing source vertex");
352
- if (!target)
490
+ }
491
+ if (!target) {
353
492
  throw new Error("Missing target vertex");
354
- parent._addEdge(this), this.source = source, this.source.addOutEdge(this), this.target = target, this.target.addInEdge(this), this._ = _;
493
+ }
494
+ parent._addEdge(this);
495
+ this.source = source;
496
+ this.source.addOutEdge(this);
497
+ this.target = target;
498
+ this.target.addInEdge(this);
499
+ this._ = _;
355
500
  }
356
501
  remove() {
357
502
  this._graph.removeEdge(this);
358
503
  }
359
- };
360
- class Graph {
504
+ }, __name(_d, "Edge"), _d);
505
+ const _Graph = class _Graph {
361
506
  constructor(idOf = (item) => "" + item._, _) {
362
507
  __publicField(this, "root");
363
508
  __publicField(this, "_allSubgraphs", []);
@@ -367,17 +512,28 @@ class Graph {
367
512
  __publicField(this, "_allEdges", []);
368
513
  __publicField(this, "_allEdgesMap", {});
369
514
  __publicField(this, "idOf");
370
- this.root = new Subgraph$1(this, null, _), this.idOf = idOf;
515
+ this.root = new Subgraph$1(this, null, _);
516
+ this.idOf = idOf;
371
517
  }
372
518
  createSubgraph(parent, _) {
373
519
  const retVal = new Subgraph$1(this, parent || this.root, _);
374
- return this._allSubgraphs.push(retVal), this._allSubgraphsMap[this.idOf(retVal)] = retVal, retVal;
520
+ this._allSubgraphs.push(retVal);
521
+ this._allSubgraphsMap[this.idOf(retVal)] = retVal;
522
+ return retVal;
375
523
  }
376
- removeSubgraph(subgraph, full = !0) {
524
+ removeSubgraph(subgraph, full = true) {
377
525
  const idx = this._allSubgraphs.indexOf(subgraph);
378
- if (idx < 0)
526
+ if (idx < 0) {
379
527
  throw new Error("Subgraph does not exist");
380
- this._allSubgraphs.splice(idx, 1), delete this._allSubgraphsMap[this.idOf(subgraph)], subgraph.parent && subgraph.parent._removeSubgraph(subgraph), subgraph.edges.forEach((edge) => full ? this.removeEdge(edge) : subgraph.parent._addEdge(edge)), subgraph.vertices.forEach((vertex) => full ? this.removeVertex(vertex, full) : subgraph.parent._addVertex(vertex)), subgraph.subgraphs.forEach(
528
+ }
529
+ this._allSubgraphs.splice(idx, 1);
530
+ delete this._allSubgraphsMap[this.idOf(subgraph)];
531
+ if (subgraph.parent) {
532
+ subgraph.parent._removeSubgraph(subgraph);
533
+ }
534
+ subgraph.edges.forEach((edge) => full ? this.removeEdge(edge) : subgraph.parent._addEdge(edge));
535
+ subgraph.vertices.forEach((vertex) => full ? this.removeVertex(vertex, full) : subgraph.parent._addVertex(vertex));
536
+ subgraph.subgraphs.forEach(
381
537
  (childSubgraph) => full ? this.removeSubgraph(childSubgraph, full) : subgraph.parent._addSubgraph(childSubgraph)
382
538
  );
383
539
  }
@@ -389,17 +545,29 @@ class Graph {
389
545
  }
390
546
  createVertex(parent, _) {
391
547
  const retVal = new Vertex$1(this, parent, _);
392
- return this._allVertices.push(retVal), this._allVerticesMap[this.idOf(retVal)] = retVal, retVal;
548
+ this._allVertices.push(retVal);
549
+ this._allVerticesMap[this.idOf(retVal)] = retVal;
550
+ return retVal;
393
551
  }
394
- removeVertex(vertex, full = !0, _) {
552
+ removeVertex(vertex, full = true, _) {
395
553
  const idx = this._allVertices.indexOf(vertex);
396
- if (idx < 0)
554
+ if (idx < 0) {
397
555
  throw new Error("Vertex does not exist");
398
- this._allVertices.splice(idx, 1), delete this._allVerticesMap[this.idOf(vertex)], vertex.parent && vertex.parent._removeVertex(vertex), full || vertex.inEdges.forEach((inEdge) => {
399
- vertex.outEdges.forEach((outEdge) => {
400
- this.createEdge(this.root, inEdge.source, outEdge.target, _ ? _(inEdge.source._, outEdge.target._) : void 0);
556
+ }
557
+ this._allVertices.splice(idx, 1);
558
+ delete this._allVerticesMap[this.idOf(vertex)];
559
+ if (vertex.parent) {
560
+ vertex.parent._removeVertex(vertex);
561
+ }
562
+ if (!full) {
563
+ vertex.inEdges.forEach((inEdge) => {
564
+ vertex.outEdges.forEach((outEdge) => {
565
+ this.createEdge(this.root, inEdge.source, outEdge.target, _ ? _(inEdge.source._, outEdge.target._) : void 0);
566
+ });
401
567
  });
402
- }), vertex.inEdges.forEach((edge) => this.removeEdge(edge)), vertex.outEdges.forEach((edge) => this.removeEdge(edge));
568
+ }
569
+ vertex.inEdges.forEach((edge) => this.removeEdge(edge));
570
+ vertex.outEdges.forEach((edge) => this.removeEdge(edge));
403
571
  }
404
572
  get vertices() {
405
573
  return this._allVertices;
@@ -409,13 +577,22 @@ class Graph {
409
577
  }
410
578
  createEdge(parent, source, target, _) {
411
579
  const retVal = new Edge$1(this, parent, source, target, _);
412
- return this._allEdges.push(retVal), this._allEdgesMap[this.idOf(retVal)] = retVal, retVal;
580
+ this._allEdges.push(retVal);
581
+ this._allEdgesMap[this.idOf(retVal)] = retVal;
582
+ return retVal;
413
583
  }
414
584
  removeEdge(edge) {
415
585
  const idx = this._allEdges.indexOf(edge);
416
- if (idx < 0)
586
+ if (idx < 0) {
417
587
  throw new Error("Edge does not exist");
418
- this._allEdges.splice(idx, 1), delete this._allEdgesMap[this.idOf(edge)], edge.parent && edge.parent._removeEdge(edge), edge.source.removeOutEdge(edge), edge.target.removeInEdge(edge);
588
+ }
589
+ this._allEdges.splice(idx, 1);
590
+ delete this._allEdgesMap[this.idOf(edge)];
591
+ if (edge.parent) {
592
+ edge.parent._removeEdge(edge);
593
+ }
594
+ edge.source.removeOutEdge(edge);
595
+ edge.target.removeInEdge(edge);
419
596
  }
420
597
  get edges() {
421
598
  return this._allEdges;
@@ -424,73 +601,109 @@ class Graph {
424
601
  return this._allEdgesMap[id];
425
602
  }
426
603
  _walk(parent, visitor) {
427
- for (const subgraph of parent.subgraphs)
604
+ for (const subgraph of parent.subgraphs) {
428
605
  switch (visitor(subgraph)) {
429
606
  case "abort":
430
- return !0;
607
+ return true;
431
608
  case "stepover":
432
609
  break;
433
610
  default:
434
- if (this._walk(subgraph, visitor)) return !0;
611
+ if (this._walk(subgraph, visitor)) return true;
435
612
  }
436
- for (const vertex of parent.vertices)
437
- if (visitor(vertex) === "abort") return !0;
613
+ }
614
+ for (const vertex of parent.vertices) {
615
+ if (visitor(vertex) === "abort") return true;
616
+ }
438
617
  }
439
618
  walk(visitor) {
440
619
  this._walk(this.root, visitor);
441
- for (const edge of this._allEdges)
442
- if (visitor(edge) === "abort") return !0;
620
+ for (const edge of this._allEdges) {
621
+ if (visitor(edge) === "abort") return true;
622
+ }
443
623
  }
444
624
  clone() {
445
- const ctor = this.constructor, retVal = new ctor(this.idOf, this.root._), map = ObjMap();
446
- return map.put(this.root, retVal.root), this.walk((item) => {
625
+ const ctor = this.constructor;
626
+ const retVal = new ctor(this.idOf, this.root._);
627
+ const map = ObjMap();
628
+ map.put(this.root, retVal.root);
629
+ this.walk((item) => {
447
630
  const parent = map.get(item.parent);
448
- if (item instanceof Subgraph$1)
631
+ if (item instanceof Subgraph$1) {
449
632
  map.put(item, parent.createSubgraph(item._));
450
- else if (item instanceof Vertex$1)
633
+ } else if (item instanceof Vertex$1) {
451
634
  map.put(item, parent.createVertex(item._));
452
- else if (item instanceof Edge$1) {
453
- const source = map.get(item.source), target = map.get(item.target);
635
+ } else if (item instanceof Edge$1) {
636
+ const source = map.get(item.source);
637
+ const target = map.get(item.target);
454
638
  parent.createEdge(source, target, item._);
455
639
  }
456
- }), retVal;
640
+ });
641
+ return retVal;
457
642
  }
458
- }
643
+ };
644
+ __name(_Graph, "Graph");
645
+ let Graph = _Graph;
459
646
  function ObjMap() {
460
- const keys = [], values = [];
647
+ const keys = [];
648
+ const values = [];
461
649
  return {
462
650
  put(key, value) {
463
651
  const index = keys.indexOf(key);
464
- index === -1 ? (keys.push(key), values.push(value)) : values[index] = value;
652
+ if (index === -1) {
653
+ keys.push(key);
654
+ values.push(value);
655
+ } else {
656
+ values[index] = value;
657
+ }
465
658
  },
466
659
  get(key) {
467
660
  return values[keys.indexOf(key)];
468
661
  }
469
662
  };
470
663
  }
471
- class GraphItem2 {
664
+ __name(ObjMap, "ObjMap");
665
+ const _GraphItem = class _GraphItem {
472
666
  constructor(g, _) {
473
667
  __publicField(this, "_graph");
474
668
  __publicField(this, "_");
475
- this._graph = g, this._ = _;
669
+ this._graph = g;
670
+ this._ = _;
476
671
  }
477
672
  id() {
478
673
  return this._graph.id(this._);
479
674
  }
480
- }
481
- class ChildGraphItem extends GraphItem2 {
675
+ };
676
+ __name(_GraphItem, "GraphItem");
677
+ let GraphItem = _GraphItem;
678
+ const _ChildGraphItem = class _ChildGraphItem extends GraphItem {
482
679
  constructor(g, _) {
483
680
  super(g, _);
484
681
  __publicField(this, "_parent");
485
682
  }
486
683
  clearParent() {
487
- return this._parent && (this._parent.removeChild(this), delete this._parent), this;
684
+ if (this._parent) {
685
+ this._parent.removeChild(this);
686
+ delete this._parent;
687
+ }
688
+ return this;
488
689
  }
489
690
  parent(_) {
490
- return arguments.length === 0 ? this._parent : (this._parent !== _ && (this._parent && this._parent.removeChild(this), this._parent = _, this._parent && this._parent.addChild(this)), this);
691
+ if (arguments.length === 0) return this._parent;
692
+ if (this._parent !== _) {
693
+ if (this._parent) {
694
+ this._parent.removeChild(this);
695
+ }
696
+ this._parent = _;
697
+ if (this._parent) {
698
+ this._parent.addChild(this);
699
+ }
700
+ }
701
+ return this;
491
702
  }
492
- }
493
- class Subgraph2 extends ChildGraphItem {
703
+ };
704
+ __name(_ChildGraphItem, "ChildGraphItem");
705
+ let ChildGraphItem = _ChildGraphItem;
706
+ const _Subgraph = class _Subgraph extends ChildGraphItem {
494
707
  constructor(g, _) {
495
708
  super(g, _);
496
709
  __publicField(this, "_children", []);
@@ -504,8 +717,10 @@ class Subgraph2 extends ChildGraphItem {
504
717
  removeChild(_) {
505
718
  this._children = this._children.filter((row) => row.id !== _.id);
506
719
  }
507
- }
508
- class Vertex2 extends ChildGraphItem {
720
+ };
721
+ __name(_Subgraph, "Subgraph");
722
+ let Subgraph = _Subgraph;
723
+ const _Vertex = class _Vertex extends ChildGraphItem {
509
724
  constructor(g, _) {
510
725
  super(g, _);
511
726
  __publicField(this, "_inEdges", []);
@@ -535,57 +750,74 @@ class Vertex2 extends ChildGraphItem {
535
750
  removeOutEdge(id) {
536
751
  this._outEdges = this._outEdges.filter((e) => e._.id !== id);
537
752
  }
538
- }
539
- class Edge2 extends ChildGraphItem {
753
+ };
754
+ __name(_Vertex, "Vertex");
755
+ let Vertex = _Vertex;
756
+ const _Edge = class _Edge extends ChildGraphItem {
540
757
  constructor(g, _, source, target) {
541
758
  super(g, _);
542
759
  __publicField(this, "_source");
543
760
  __publicField(this, "_target");
544
- this._source = source, this._target = target;
761
+ this._source = source;
762
+ this._target = target;
545
763
  }
546
- }
547
- class Graph2 {
548
- constructor(directed = !0) {
764
+ };
765
+ __name(_Edge, "Edge");
766
+ let Edge = _Edge;
767
+ const _Graph2 = class _Graph2 {
768
+ constructor(directed = true) {
549
769
  __publicField(this, "_directed");
550
770
  __publicField(this, "_subgraphMap", {});
551
771
  __publicField(this, "_vertexMap", {});
552
772
  __publicField(this, "_edgeMap", {});
553
- __publicField(this, "_idFunc", (_) => typeof _.id == "function" ? _.id() : _.id);
554
- __publicField(this, "_sourceFunc", (_) => typeof _.source == "function" ? _.source() : _.source);
555
- __publicField(this, "_targetFunc", (_) => typeof _.target == "function" ? _.target() : _.target);
556
- __publicField(this, "_updateFunc", (before, after) => after);
773
+ __publicField(this, "_idFunc", /* @__PURE__ */ __name((_) => typeof _.id === "function" ? _.id() : _.id, "_idFunc"));
774
+ __publicField(this, "_sourceFunc", /* @__PURE__ */ __name((_) => typeof _.source === "function" ? _.source() : _.source, "_sourceFunc"));
775
+ __publicField(this, "_targetFunc", /* @__PURE__ */ __name((_) => typeof _.target === "function" ? _.target() : _.target, "_targetFunc"));
776
+ __publicField(this, "_updateFunc", /* @__PURE__ */ __name((before, after) => after, "_updateFunc"));
557
777
  this._directed = directed;
558
778
  }
559
779
  clear() {
560
- return this._subgraphMap = {}, this._vertexMap = {}, this._edgeMap = {}, this;
780
+ this._subgraphMap = {};
781
+ this._vertexMap = {};
782
+ this._edgeMap = {};
783
+ return this;
561
784
  }
562
785
  clearParents() {
563
- for (const key in this._subgraphMap)
786
+ for (const key in this._subgraphMap) {
564
787
  this._subgraphMap[key].clearParent();
565
- for (const key in this._vertexMap)
788
+ }
789
+ for (const key in this._vertexMap) {
566
790
  this._vertexMap[key].clearParent();
791
+ }
567
792
  return this;
568
793
  }
569
794
  isDirected() {
570
795
  return this._directed;
571
796
  }
572
797
  idFunc(_) {
573
- return this._idFunc = _, this;
798
+ this._idFunc = _;
799
+ return this;
574
800
  }
575
801
  sourceFunc(_) {
576
- return this._sourceFunc = _, this;
802
+ this._sourceFunc = _;
803
+ return this;
577
804
  }
578
805
  targetFunc(_) {
579
- return this._targetFunc = _, this;
806
+ this._targetFunc = _;
807
+ return this;
580
808
  }
581
809
  updateFunc(_) {
582
- return this._updateFunc = _, this;
810
+ this._updateFunc = _;
811
+ return this;
583
812
  }
584
813
  id(_) {
585
814
  return this._idFunc(_);
586
815
  }
587
816
  type(id) {
588
- return this.subgraphExists(id) ? "S" : this.vertexExists(id) ? "V" : this.edgeExists(id) ? "E" : "";
817
+ if (this.subgraphExists(id)) return "S";
818
+ if (this.vertexExists(id)) return "V";
819
+ if (this.edgeExists(id)) return "E";
820
+ return "";
589
821
  }
590
822
  isSubgraph(_) {
591
823
  return this.subgraphExists(this.id(_));
@@ -603,6 +835,7 @@ class Graph2 {
603
835
  if (this.subgraphExists(id)) return this.subgraph(id);
604
836
  if (this.vertexExists(id)) return this.vertex(id);
605
837
  if (this.edgeExists(id)) return this.edge(id);
838
+ return void 0;
606
839
  }
607
840
  itemExists(id) {
608
841
  return this.edgeExists(id) || this.vertexExists(id) || this.subgraphExists(id);
@@ -610,14 +843,18 @@ class Graph2 {
610
843
  // Subgraphs ---
611
844
  allSubgraphs() {
612
845
  const retVal = [];
613
- for (const key in this._subgraphMap)
846
+ for (const key in this._subgraphMap) {
614
847
  retVal.push(this._subgraphMap[key]._);
848
+ }
615
849
  return retVal;
616
850
  }
617
851
  subgraphs() {
618
852
  const retVal = [];
619
- for (const key in this._subgraphMap)
620
- this._subgraphMap[key].parent() === void 0 && retVal.push(this._subgraphMap[key]._);
853
+ for (const key in this._subgraphMap) {
854
+ if (this._subgraphMap[key].parent() === void 0) {
855
+ retVal.push(this._subgraphMap[key]._);
856
+ }
857
+ }
621
858
  return retVal;
622
859
  }
623
860
  subgraphExists(id) {
@@ -638,29 +875,45 @@ class Graph2 {
638
875
  addSubgraph(s, parent) {
639
876
  const s_id = this._idFunc(s);
640
877
  if (this._subgraphMap[s_id]) throw new Error(`Subgraph '${s_id}' already exists.`);
641
- const subgraph = new Subgraph2(this, s);
878
+ const subgraph = new Subgraph(this, s);
642
879
  if (parent) {
643
880
  const p_id = this._idFunc(parent);
644
881
  if (!this._subgraphMap[p_id]) throw new Error(`Subgraph '${p_id}' does not exist.`);
645
882
  subgraph.parent(this._subgraphMap[p_id]);
646
883
  }
647
- return this._subgraphMap[s_id] = subgraph, this;
884
+ this._subgraphMap[s_id] = subgraph;
885
+ return this;
648
886
  }
649
887
  mergeSubgraphs(_subgraphs = []) {
650
888
  const sgDiff = compare2(this.allSubgraphs(), _subgraphs, (sg) => this._idFunc(sg), this._updateFunc);
651
- return sgDiff.exit.forEach((sg) => this.removeSubgraph(this._idFunc(sg))), sgDiff.enter.forEach((sg) => this.addSubgraph(sg)), sgDiff.update.forEach((sg) => this.updateSubgraph(sg)), this;
889
+ sgDiff.exit.forEach((sg) => this.removeSubgraph(this._idFunc(sg)));
890
+ sgDiff.enter.forEach((sg) => this.addSubgraph(sg));
891
+ sgDiff.update.forEach((sg) => this.updateSubgraph(sg));
892
+ return this;
652
893
  }
653
894
  updateSubgraph(sg) {
654
- const sg_id = this._idFunc(sg), subgraph = this._subgraphMap[sg_id];
895
+ const sg_id = this._idFunc(sg);
896
+ const subgraph = this._subgraphMap[sg_id];
655
897
  if (!subgraph) throw new Error(`Subgraph '${sg_id}' does not exist.`);
656
- return subgraph._ = sg, this;
898
+ subgraph._ = sg;
899
+ return this;
657
900
  }
658
- removeSubgraph(id, promoteChildren = !0) {
901
+ removeSubgraph(id, promoteChildren = true) {
659
902
  const sg = this._subgraphMap[id];
660
903
  if (!sg) throw new Error(`Subgraph '${id}' does not exist.`);
661
- return sg.children().forEach((child) => {
662
- promoteChildren ? child.parent(sg.parent()) : child instanceof Subgraph2 ? this.removeSubgraph(child.id()) : this.removeVertex(child.id());
663
- }), delete this._subgraphMap[id], this;
904
+ sg.children().forEach((child) => {
905
+ if (promoteChildren) {
906
+ child.parent(sg.parent());
907
+ } else {
908
+ if (child instanceof Subgraph) {
909
+ this.removeSubgraph(child.id());
910
+ } else {
911
+ this.removeVertex(child.id());
912
+ }
913
+ }
914
+ });
915
+ delete this._subgraphMap[id];
916
+ return this;
664
917
  }
665
918
  subgraphParent(id, parentID) {
666
919
  const item = this._subgraphMap[id];
@@ -671,19 +924,24 @@ class Graph2 {
671
924
  }
672
925
  const parent = this._subgraphMap[parentID];
673
926
  if (!parent) throw new Error(`Vertex parent '${parent}' does not exist.`);
674
- return item.parent(parent), this;
927
+ item.parent(parent);
928
+ return this;
675
929
  }
676
930
  // Vertices ---
677
931
  allVertices() {
678
932
  const retVal = [];
679
- for (const key in this._vertexMap)
933
+ for (const key in this._vertexMap) {
680
934
  retVal.push(this._vertexMap[key]._);
935
+ }
681
936
  return retVal;
682
937
  }
683
938
  vertices() {
684
939
  const retVal = [];
685
- for (const key in this._vertexMap)
686
- this._vertexMap[key].parent() === void 0 && retVal.push(this._vertexMap[key]._);
940
+ for (const key in this._vertexMap) {
941
+ if (this._vertexMap[key].parent() === void 0) {
942
+ retVal.push(this._vertexMap[key]._);
943
+ }
944
+ }
687
945
  return retVal;
688
946
  }
689
947
  vertexExists(id) {
@@ -694,14 +952,18 @@ class Graph2 {
694
952
  }
695
953
  allEdges() {
696
954
  const retVal = [];
697
- for (const key in this._edgeMap)
955
+ for (const key in this._edgeMap) {
698
956
  retVal.push(this._edgeMap[key]._);
957
+ }
699
958
  return retVal;
700
959
  }
701
960
  edges() {
702
961
  const retVal = [];
703
- for (const key in this._edgeMap)
704
- this._edgeMap[key].parent() === void 0 && retVal.push(this._edgeMap[key]._);
962
+ for (const key in this._edgeMap) {
963
+ if (this._edgeMap[key].parent() === void 0) {
964
+ retVal.push(this._edgeMap[key]._);
965
+ }
966
+ }
705
967
  return retVal;
706
968
  }
707
969
  vertexEdges(vertexID) {
@@ -725,29 +987,37 @@ class Graph2 {
725
987
  addVertex(v, parent) {
726
988
  const v_id = this._idFunc(v);
727
989
  if (this._vertexMap[v_id]) throw new Error(`Vertex '${v_id}' already exists.`);
728
- const vertex = new Vertex2(this, v);
990
+ const vertex = new Vertex(this, v);
729
991
  if (parent) {
730
992
  const p_id = this._idFunc(parent);
731
993
  if (!this.subgraphExists(p_id)) throw new Error(`Subgraph '${p_id}' does not exist.`);
732
994
  vertex.parent(this._subgraphMap[p_id]);
733
995
  }
734
- return this._vertexMap[v_id] = vertex, this;
996
+ this._vertexMap[v_id] = vertex;
997
+ return this;
735
998
  }
736
999
  mergeVertices(_vertices) {
737
1000
  const vDiff = compare2(this.allVertices(), _vertices, (v) => this._idFunc(v), this._updateFunc);
738
- return vDiff.exit.forEach((v) => this.removeVertex(this._idFunc(v))), vDiff.enter.forEach((v) => this.addVertex(v)), vDiff.update.forEach((v) => this.updateVertex(v)), this;
1001
+ vDiff.exit.forEach((v) => this.removeVertex(this._idFunc(v)));
1002
+ vDiff.enter.forEach((v) => this.addVertex(v));
1003
+ vDiff.update.forEach((v) => this.updateVertex(v));
1004
+ return this;
739
1005
  }
740
1006
  updateVertex(v) {
741
- const v_id = this._idFunc(v), vertex = this._vertexMap[v_id];
1007
+ const v_id = this._idFunc(v);
1008
+ const vertex = this._vertexMap[v_id];
742
1009
  if (!vertex) throw new Error(`Vertex '${v_id}' does not exist.`);
743
- return vertex._ = v, this;
1010
+ vertex._ = v;
1011
+ return this;
744
1012
  }
745
1013
  removeVertex(id) {
746
1014
  const v = this._vertexMap[id];
747
1015
  if (!v) throw new Error(`Vertex '${id}' does not exist.`);
748
- return v.edges().forEach((e) => {
1016
+ v.edges().forEach((e) => {
749
1017
  this.removeEdge(e.id());
750
- }), delete this._vertexMap[id], this;
1018
+ });
1019
+ delete this._vertexMap[id];
1020
+ return this;
751
1021
  }
752
1022
  vertexParent(id, parentID) {
753
1023
  const item = this._vertexMap[id];
@@ -758,7 +1028,8 @@ class Graph2 {
758
1028
  }
759
1029
  const parent = this._subgraphMap[parentID];
760
1030
  if (!parent) throw new Error(`Vertex parent '${parent}' does not exist.`);
761
- return item.parent(parent), this;
1031
+ item.parent(parent);
1032
+ return this;
762
1033
  }
763
1034
  // Edges ---
764
1035
  edgeExists(id) {
@@ -768,30 +1039,51 @@ class Graph2 {
768
1039
  return this._edgeMap[id]._;
769
1040
  }
770
1041
  addEdge(e, parent) {
771
- const e_id = this._idFunc(e), e_source = this._sourceFunc(e), e_target = this._targetFunc(e);
1042
+ const e_id = this._idFunc(e);
1043
+ const e_source = this._sourceFunc(e);
1044
+ const e_target = this._targetFunc(e);
772
1045
  if (this._edgeMap[e_id]) throw new Error(`Edge '${e_id}' already exists.`);
773
1046
  if (!this.vertexExists(e_source)) throw new Error(`Edge Source '${e_source}' does not exist.`);
774
1047
  if (!this.vertexExists(e_target)) throw new Error(`Edge Target '${e_target}' does not exist.`);
775
- const edge = new Edge2(this, e, this._vertexMap[e_source], this._vertexMap[e_target]);
1048
+ const edge = new Edge(this, e, this._vertexMap[e_source], this._vertexMap[e_target]);
776
1049
  if (parent) {
777
1050
  const p_id = this._idFunc(parent);
778
1051
  if (!this.subgraphExists(p_id)) throw new Error(`Subgraph '${p_id}' does not exist.`);
779
1052
  edge.parent(this._subgraphMap[p_id]);
780
1053
  }
781
- return this._edgeMap[e_id] = edge, this._vertexMap[e_source].addOutEdge(edge), this._vertexMap[e_target].addInEdge(edge), this;
1054
+ this._edgeMap[e_id] = edge;
1055
+ this._vertexMap[e_source].addOutEdge(edge);
1056
+ this._vertexMap[e_target].addInEdge(edge);
1057
+ return this;
782
1058
  }
783
1059
  mergeEdges(_edges) {
784
1060
  const eDiff = compare2(this.allEdges(), _edges, (e) => this._idFunc(e), this._updateFunc);
785
- return eDiff.exit.forEach((e) => this.removeEdge(this._idFunc(e))), eDiff.enter.forEach((e) => this.addEdge(e)), eDiff.update.forEach((e) => this.updateEdge(e)), this;
1061
+ eDiff.exit.forEach((e) => this.removeEdge(this._idFunc(e)));
1062
+ eDiff.enter.forEach((e) => this.addEdge(e));
1063
+ eDiff.update.forEach((e) => this.updateEdge(e));
1064
+ return this;
786
1065
  }
787
1066
  updateEdge(e) {
788
- var _a, _b, _c, _d;
789
- const e_id = this._idFunc(e), edge = this._edgeMap[e_id];
1067
+ var _a2, _b2, _c2, _d2;
1068
+ const e_id = this._idFunc(e);
1069
+ const edge = this._edgeMap[e_id];
790
1070
  if (!edge) throw new Error(`Edge '${e_id}' does not exist.`);
791
- const old_source = edge._source.id(), new_source = this._sourceFunc(e);
792
- old_source !== new_source && ((_a = this._vertexMap[old_source]) == null || _a.removeOutEdge(e_id), (_b = this._vertexMap[new_source]) == null || _b.addOutEdge(edge));
793
- const old_target = edge._target.id(), new_target = this._targetFunc(e);
794
- return old_target !== new_target && ((_c = this._vertexMap[old_target]) == null || _c.removeInEdge(e_id), (_d = this._vertexMap[new_target]) == null || _d.addInEdge(edge)), edge._ = e, edge._source = this._vertexMap[new_source], edge._target = this._vertexMap[new_target], this;
1071
+ const old_source = edge._source.id();
1072
+ const new_source = this._sourceFunc(e);
1073
+ if (old_source !== new_source) {
1074
+ (_a2 = this._vertexMap[old_source]) == null ? void 0 : _a2.removeOutEdge(e_id);
1075
+ (_b2 = this._vertexMap[new_source]) == null ? void 0 : _b2.addOutEdge(edge);
1076
+ }
1077
+ const old_target = edge._target.id();
1078
+ const new_target = this._targetFunc(e);
1079
+ if (old_target !== new_target) {
1080
+ (_c2 = this._vertexMap[old_target]) == null ? void 0 : _c2.removeInEdge(e_id);
1081
+ (_d2 = this._vertexMap[new_target]) == null ? void 0 : _d2.addInEdge(edge);
1082
+ }
1083
+ edge._ = e;
1084
+ edge._source = this._vertexMap[new_source];
1085
+ edge._target = this._vertexMap[new_target];
1086
+ return this;
795
1087
  }
796
1088
  removeEdge(id) {
797
1089
  const e = this._edgeMap[id];
@@ -801,68 +1093,117 @@ class Graph2 {
801
1093
  this._vertexMap[e_sourceID].removeOutEdge(id);
802
1094
  const e_targetID = this._idFunc(e._target._);
803
1095
  if (!this.vertexExists(e_targetID)) throw new Error(`Edge Target'${e_targetID}' does not exist.`);
804
- return this._vertexMap[e_targetID].removeInEdge(id), delete this._edgeMap[id], this;
1096
+ this._vertexMap[e_targetID].removeInEdge(id);
1097
+ delete this._edgeMap[id];
1098
+ return this;
805
1099
  }
806
1100
  _hwalk(item, formatter) {
807
- return item instanceof Subgraph2 ? formatter("subgraph", item._, item.children().map((child) => this._hwalk(child, formatter))) : formatter("vertex", item._);
1101
+ if (item instanceof Subgraph) {
1102
+ return formatter("subgraph", item._, item.children().map((child) => this._hwalk(child, formatter)));
1103
+ } else {
1104
+ return formatter("vertex", item._);
1105
+ }
808
1106
  }
809
1107
  hierarchy(formatter) {
810
1108
  const retVal = [];
811
1109
  for (const id in this._subgraphMap) {
812
1110
  const sg = this._subgraphMap[id];
813
- sg.parent() === void 0 && retVal.push(this._hwalk(sg, formatter));
1111
+ if (sg.parent() === void 0) {
1112
+ retVal.push(this._hwalk(sg, formatter));
1113
+ }
814
1114
  }
815
1115
  for (const id in this._vertexMap) {
816
1116
  const v = this._vertexMap[id];
817
- v.parent() === void 0 && retVal.push(this._hwalk(v, formatter));
1117
+ if (v.parent() === void 0) {
1118
+ retVal.push(this._hwalk(v, formatter));
1119
+ }
818
1120
  }
819
1121
  return retVal;
820
1122
  }
821
1123
  dijkstra(source, target) {
822
- const edges = this.allEdges(), Q = new Set(), prev = {}, dist = {}, adj = {};
1124
+ const edges = this.allEdges();
1125
+ const Q = new Set();
1126
+ const prev = {};
1127
+ const dist = {};
1128
+ const adj = {};
823
1129
  function vertex_with_min_dist(Q2, dist2) {
824
- let min_distance = 1 / 0, u2 = null;
825
- return Q2.forEach((v) => {
826
- dist2[v] < min_distance && (min_distance = dist2[v], u2 = v);
827
- }), u2;
1130
+ let min_distance = Infinity;
1131
+ let u2 = null;
1132
+ Q2.forEach((v) => {
1133
+ if (dist2[v] < min_distance) {
1134
+ min_distance = dist2[v];
1135
+ u2 = v;
1136
+ }
1137
+ });
1138
+ return u2;
828
1139
  }
1140
+ __name(vertex_with_min_dist, "vertex_with_min_dist");
829
1141
  for (let i = 0; i < edges.length; i++) {
830
- const v1 = this._sourceFunc(edges[i]), v2 = this._targetFunc(edges[i]), len2 = 1;
831
- Q.add(v1), Q.add(v2), dist[v1] = 1 / 0, dist[v2] = 1 / 0, adj[v1] === void 0 && (adj[v1] = {}), adj[v2] === void 0 && (adj[v2] = {}), adj[v1][v2] = len2, adj[v2][v1] = len2;
1142
+ const v1 = this._sourceFunc(edges[i]);
1143
+ const v2 = this._targetFunc(edges[i]);
1144
+ const len2 = 1;
1145
+ Q.add(v1);
1146
+ Q.add(v2);
1147
+ dist[v1] = Infinity;
1148
+ dist[v2] = Infinity;
1149
+ if (adj[v1] === void 0) adj[v1] = {};
1150
+ if (adj[v2] === void 0) adj[v2] = {};
1151
+ adj[v1][v2] = len2;
1152
+ adj[v2][v1] = len2;
832
1153
  }
833
- for (dist[source] = 0; Q.size; ) {
1154
+ dist[source] = 0;
1155
+ while (Q.size) {
834
1156
  const u2 = vertex_with_min_dist(Q, dist);
835
1157
  if (u2 === null) break;
836
1158
  const neighbors = Object.keys(adj[u2]).filter((v) => Q.has(v));
837
- if (Q.delete(u2), u2 === target) break;
1159
+ Q.delete(u2);
1160
+ if (u2 === target) break;
838
1161
  for (const v of neighbors) {
839
1162
  const alt = dist[u2] + adj[u2][v];
840
- alt < dist[v] && (dist[v] = alt, prev[v] = u2);
1163
+ if (alt < dist[v]) {
1164
+ dist[v] = alt;
1165
+ prev[v] = u2;
1166
+ }
841
1167
  }
842
1168
  }
843
1169
  let u = target;
844
1170
  const ids = [u];
845
1171
  let len = 0;
846
- for (; prev[u] !== void 0; )
847
- ids.unshift(prev[u]), len += adj[u][prev[u]], u = prev[u];
1172
+ while (prev[u] !== void 0) {
1173
+ ids.unshift(prev[u]);
1174
+ len += adj[u][prev[u]];
1175
+ u = prev[u];
1176
+ }
848
1177
  return { ids, len };
849
1178
  }
850
1179
  sort(v_id) {
851
- const retVal = [], visited = {}, visit = (vertex, ancestors = []) => {
1180
+ const retVal = [];
1181
+ const visited = {};
1182
+ const visit = /* @__PURE__ */ __name((vertex, ancestors = []) => {
852
1183
  const v_id2 = vertex.id();
853
- visited[v_id2] || (visited[v_id2] = !0, ancestors.push(vertex), vertex.outEdges().forEach((e) => {
854
- ancestors.indexOf(e._target) < 0 && visit(e._target, [...ancestors]);
855
- }), retVal.unshift(vertex._));
856
- };
857
- if (v_id)
1184
+ if (visited[v_id2]) return;
1185
+ visited[v_id2] = true;
1186
+ ancestors.push(vertex);
1187
+ vertex.outEdges().forEach((e) => {
1188
+ if (ancestors.indexOf(e._target) < 0) {
1189
+ visit(e._target, [...ancestors]);
1190
+ }
1191
+ });
1192
+ retVal.unshift(vertex._);
1193
+ }, "visit");
1194
+ if (v_id) {
858
1195
  visit(this._vertexMap[v_id]);
859
- else
860
- for (const key in this._vertexMap)
1196
+ } else {
1197
+ for (const key in this._vertexMap) {
861
1198
  visit(this._vertexMap[key]);
1199
+ }
1200
+ }
862
1201
  return retVal;
863
1202
  }
864
- }
865
- class Set {
1203
+ };
1204
+ __name(_Graph2, "Graph2");
1205
+ let Graph2 = _Graph2;
1206
+ const _Set = class _Set {
866
1207
  constructor() {
867
1208
  __publicField(this, "_content", []);
868
1209
  }
@@ -873,114 +1214,175 @@ class Set {
873
1214
  return this._content.indexOf(_) >= 0;
874
1215
  }
875
1216
  add(_) {
876
- this.has(_) || this._content.push(_);
1217
+ if (!this.has(_)) {
1218
+ this._content.push(_);
1219
+ }
877
1220
  }
878
1221
  delete(_) {
879
1222
  const idx = this._content.indexOf(_);
880
- idx >= 0 && this._content.splice(idx, 1);
1223
+ if (idx >= 0) {
1224
+ this._content.splice(idx, 1);
1225
+ }
881
1226
  }
882
1227
  forEach(_) {
883
1228
  this._content.forEach(_);
884
1229
  }
885
- }
886
- const isArray$1 = Array.isArray, keyList = Object.keys, hasProp = Object.prototype.hasOwnProperty;
887
- function verboseDeepEquals(a, b, functionRefCompare = !1) {
888
- if (a === b) return !0;
1230
+ };
1231
+ __name(_Set, "Set");
1232
+ let Set = _Set;
1233
+ const isArray$1 = Array.isArray;
1234
+ const keyList = Object.keys;
1235
+ const hasProp = Object.prototype.hasOwnProperty;
1236
+ function verboseDeepEquals(a, b, functionRefCompare = false) {
1237
+ if (a === b) return true;
889
1238
  if (a && b) {
890
- if (typeof a == "object" && typeof b == "object") {
891
- const arrA = isArray$1(a), arrB = isArray$1(b);
892
- let i, length, key;
1239
+ if (typeof a === "object" && typeof b === "object") {
1240
+ const arrA = isArray$1(a);
1241
+ const arrB = isArray$1(b);
1242
+ let i;
1243
+ let length;
1244
+ let key;
893
1245
  if (arrA && arrB) {
894
- if (length = a.length, length !== b.length)
895
- return console.warn(`lengths not equal: ${length} !== ${b.length}`), !1;
1246
+ length = a.length;
1247
+ if (length !== b.length) {
1248
+ console.warn(`lengths not equal: ${length} !== ${b.length}`);
1249
+ return false;
1250
+ }
896
1251
  for (i = length; i-- !== 0; )
897
- if (!verboseDeepEquals(a[i], b[i], functionRefCompare))
898
- return !1;
899
- return !0;
1252
+ if (!verboseDeepEquals(a[i], b[i], functionRefCompare)) {
1253
+ return false;
1254
+ }
1255
+ return true;
1256
+ }
1257
+ if (arrA !== arrB) {
1258
+ console.warn(`arrays not equal: ${arrA} !== ${arrB}`);
1259
+ return false;
1260
+ }
1261
+ const dateA = a instanceof Date;
1262
+ const dateB = b instanceof Date;
1263
+ if (dateA !== dateB) {
1264
+ console.warn(`dates not equal: ${dateA} !== ${dateB}`);
1265
+ return false;
900
1266
  }
901
- if (arrA !== arrB)
902
- return console.warn(`arrays not equal: ${arrA} !== ${arrB}`), !1;
903
- const dateA = a instanceof Date, dateB = b instanceof Date;
904
- if (dateA !== dateB)
905
- return console.warn(`dates not equal: ${dateA} !== ${dateB}`), !1;
906
1267
  if (dateA && dateB) {
907
1268
  const retVal2 = a.getTime() === b.getTime();
908
- return retVal2 || console.warn(`dates not equal: ${a.getTime()} !== ${b.getTime()}`), retVal2;
1269
+ if (!retVal2) {
1270
+ console.warn(`dates not equal: ${a.getTime()} !== ${b.getTime()}`);
1271
+ }
1272
+ return retVal2;
1273
+ }
1274
+ const regexpA = a instanceof RegExp;
1275
+ const regexpB = b instanceof RegExp;
1276
+ if (regexpA !== regexpB) {
1277
+ console.warn(`regexps not equal: ${regexpA} !== ${regexpB}`);
1278
+ return false;
909
1279
  }
910
- const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;
911
- if (regexpA !== regexpB)
912
- return console.warn(`regexps not equal: ${regexpA} !== ${regexpB}`), !1;
913
1280
  if (regexpA && regexpB) {
914
1281
  const retVal2 = a.toString() === b.toString();
915
- return retVal2 || console.warn(`regexps not equal: ${a.toString()} !== ${b.toString()}`), retVal2;
1282
+ if (!retVal2) {
1283
+ console.warn(`regexps not equal: ${a.toString()} !== ${b.toString()}`);
1284
+ }
1285
+ return retVal2;
916
1286
  }
917
1287
  const keys = keyList(a);
918
- if (length = keys.length, length !== keyList(b).length)
919
- return console.warn(`key lengths not equal: ${length} !== ${keyList(b).length}`), !1;
920
- for (i = length; i-- !== 0; )
921
- if (!hasProp.call(b, keys[i]))
922
- return console.warn(`${keys[i]} in a but not b`), !1;
1288
+ length = keys.length;
1289
+ if (length !== keyList(b).length) {
1290
+ console.warn(`key lengths not equal: ${length} !== ${keyList(b).length}`);
1291
+ return false;
1292
+ }
923
1293
  for (i = length; i-- !== 0; )
924
- if (key = keys[i], !verboseDeepEquals(a[key], b[key], functionRefCompare))
925
- return !1;
926
- return !0;
927
- } else if (!functionRefCompare && typeof a == "function" && typeof b == "function") {
1294
+ if (!hasProp.call(b, keys[i])) {
1295
+ console.warn(`${keys[i]} in a but not b`);
1296
+ return false;
1297
+ }
1298
+ for (i = length; i-- !== 0; ) {
1299
+ key = keys[i];
1300
+ if (!verboseDeepEquals(a[key], b[key], functionRefCompare)) {
1301
+ return false;
1302
+ }
1303
+ }
1304
+ return true;
1305
+ } else if (!functionRefCompare && typeof a === "function" && typeof b === "function") {
928
1306
  const retVal2 = a.toString() === b.toString();
929
- return retVal2 || console.warn(`functions not equal: ${a.toString()} !== ${b.toString()}`), retVal2;
1307
+ if (!retVal2) {
1308
+ console.warn(`functions not equal: ${a.toString()} !== ${b.toString()}`);
1309
+ }
1310
+ return retVal2;
930
1311
  }
931
1312
  }
932
1313
  const retVal = a !== a && b !== b;
933
- return retVal || console.warn(`values not equal: ${a} !== ${b}`), retVal;
1314
+ if (!retVal) {
1315
+ console.warn(`values not equal: ${a} !== ${b}`);
1316
+ }
1317
+ return retVal;
934
1318
  }
935
- function deepEquals(a, b, functionRefCompare = !1) {
936
- if (a === b) return !0;
1319
+ __name(verboseDeepEquals, "verboseDeepEquals");
1320
+ function deepEquals(a, b, functionRefCompare = false) {
1321
+ if (a === b) return true;
937
1322
  if (a && b) {
938
- if (typeof a == "object" && typeof b == "object") {
939
- const arrA = isArray$1(a), arrB = isArray$1(b);
940
- let i, length, key;
1323
+ if (typeof a === "object" && typeof b === "object") {
1324
+ const arrA = isArray$1(a);
1325
+ const arrB = isArray$1(b);
1326
+ let i;
1327
+ let length;
1328
+ let key;
941
1329
  if (arrA && arrB) {
942
- if (length = a.length, length !== b.length) return !1;
1330
+ length = a.length;
1331
+ if (length !== b.length) return false;
943
1332
  for (i = length; i-- !== 0; )
944
- if (!deepEquals(a[i], b[i], functionRefCompare)) return !1;
945
- return !0;
1333
+ if (!deepEquals(a[i], b[i], functionRefCompare)) return false;
1334
+ return true;
946
1335
  }
947
- if (arrA !== arrB) return !1;
948
- const dateA = a instanceof Date, dateB = b instanceof Date;
949
- if (dateA !== dateB) return !1;
1336
+ if (arrA !== arrB) return false;
1337
+ const dateA = a instanceof Date;
1338
+ const dateB = b instanceof Date;
1339
+ if (dateA !== dateB) return false;
950
1340
  if (dateA && dateB) return a.getTime() === b.getTime();
951
- const regexpA = a instanceof RegExp, regexpB = b instanceof RegExp;
952
- if (regexpA !== regexpB) return !1;
1341
+ const regexpA = a instanceof RegExp;
1342
+ const regexpB = b instanceof RegExp;
1343
+ if (regexpA !== regexpB) return false;
953
1344
  if (regexpA && regexpB) return a.toString() === b.toString();
954
1345
  const keys = keyList(a);
955
- if (length = keys.length, length !== keyList(b).length)
956
- return !1;
957
- for (i = length; i-- !== 0; )
958
- if (!hasProp.call(b, keys[i])) return !1;
1346
+ length = keys.length;
1347
+ if (length !== keyList(b).length)
1348
+ return false;
959
1349
  for (i = length; i-- !== 0; )
960
- if (key = keys[i], !deepEquals(a[key], b[key], functionRefCompare)) return !1;
961
- return !0;
962
- } else if (!functionRefCompare && typeof a == "function" && typeof b == "function")
1350
+ if (!hasProp.call(b, keys[i])) return false;
1351
+ for (i = length; i-- !== 0; ) {
1352
+ key = keys[i];
1353
+ if (!deepEquals(a[key], b[key], functionRefCompare)) return false;
1354
+ }
1355
+ return true;
1356
+ } else if (!functionRefCompare && typeof a === "function" && typeof b === "function") {
963
1357
  return a.toString() === b.toString();
1358
+ }
964
1359
  }
965
1360
  return a !== a && b !== b;
966
1361
  }
967
- function update(origItem, newItem, functionRefCompare = !1) {
1362
+ __name(deepEquals, "deepEquals");
1363
+ function update(origItem, newItem, functionRefCompare = false) {
968
1364
  return deepEquals(origItem, newItem, functionRefCompare) ? origItem : newItem;
969
1365
  }
970
- const root = typeof globalThis < "u" ? globalThis : window, isBrowser = typeof window < "u" && root === window, isNode = typeof process < "u" && process.versions != null && process.versions.node != null, isCI = isNode && process.env != null && (process.env.TRAVIS != null || process.env.GITHUB_ACTIONS != null);
1366
+ __name(update, "update");
1367
+ const root = typeof globalThis !== "undefined" ? globalThis : window;
1368
+ const isBrowser = typeof window !== "undefined" && root === window;
1369
+ const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
1370
+ const isCI = isNode && process.env != null && (process.env.TRAVIS != null || process.env.GITHUB_ACTIONS != null || process.env.CI != null);
971
1371
  function getScriptSrc(partial) {
972
1372
  const scripts = document.scripts || [];
973
1373
  for (let i = document.scripts.length - 1; i >= 0; --i) {
974
1374
  const script = scripts[i];
975
1375
  if (script.src) {
976
1376
  const idx = script.src.indexOf(partial);
977
- if (idx >= 0)
1377
+ if (idx >= 0) {
978
1378
  return script.src.substring(0, idx);
1379
+ }
979
1380
  }
980
1381
  }
981
1382
  return "";
982
1383
  }
983
- class Stack {
1384
+ __name(getScriptSrc, "getScriptSrc");
1385
+ const _Stack = class _Stack {
984
1386
  constructor() {
985
1387
  __publicField(this, "stack", []);
986
1388
  }
@@ -990,7 +1392,8 @@ class Stack {
990
1392
  * @param e - element to push
991
1393
  */
992
1394
  push(e) {
993
- return this.stack.push(e), e;
1395
+ this.stack.push(e);
1396
+ return e;
994
1397
  }
995
1398
  /**
996
1399
  * Pop element off the stack
@@ -1014,8 +1417,20 @@ class Stack {
1014
1417
  depth() {
1015
1418
  return this.stack.length;
1016
1419
  }
1017
- }
1018
- var Level = /* @__PURE__ */ ((Level2) => (Level2[Level2.debug = 0] = "debug", Level2[Level2.info = 1] = "info", Level2[Level2.notice = 2] = "notice", Level2[Level2.warning = 3] = "warning", Level2[Level2.error = 4] = "error", Level2[Level2.critical = 5] = "critical", Level2[Level2.alert = 6] = "alert", Level2[Level2.emergency = 7] = "emergency", Level2))(Level || {});
1420
+ };
1421
+ __name(_Stack, "Stack");
1422
+ let Stack = _Stack;
1423
+ var Level = /* @__PURE__ */ ((Level2) => {
1424
+ Level2[Level2["debug"] = 0] = "debug";
1425
+ Level2[Level2["info"] = 1] = "info";
1426
+ Level2[Level2["notice"] = 2] = "notice";
1427
+ Level2[Level2["warning"] = 3] = "warning";
1428
+ Level2[Level2["error"] = 4] = "error";
1429
+ Level2[Level2["critical"] = 5] = "critical";
1430
+ Level2[Level2["alert"] = 6] = "alert";
1431
+ Level2[Level2["emergency"] = 7] = "emergency";
1432
+ return Level2;
1433
+ })(Level || {});
1019
1434
  const colours = {
1020
1435
  debug: "cyan",
1021
1436
  info: "green",
@@ -1026,12 +1441,18 @@ const colours = {
1026
1441
  alert: "magenta",
1027
1442
  emergency: "magenta"
1028
1443
  };
1029
- class ConsoleWriter {
1444
+ const _ConsoleWriter = class _ConsoleWriter {
1030
1445
  write(dateTime, level, id, msg) {
1031
- isNode ? console.log(`[${dateTime}] ${Level[level].toUpperCase()} ${id}: ${msg}`) : console.log(`[${dateTime}] %c${Level[level].toUpperCase()}%c ${id}: ${msg}`, `color:${colours[Level[level]]}`, "");
1446
+ if (isNode) {
1447
+ console.log(`[${dateTime}] ${Level[level].toUpperCase()} ${id}: ${msg}`);
1448
+ } else {
1449
+ console.log(`[${dateTime}] %c${Level[level].toUpperCase()}%c ${id}: ${msg}`, `color:${colours[Level[level]]}`, "");
1450
+ }
1032
1451
  }
1033
- }
1034
- class Logging {
1452
+ };
1453
+ __name(_ConsoleWriter, "ConsoleWriter");
1454
+ let ConsoleWriter = _ConsoleWriter;
1455
+ const _Logging = class _Logging {
1035
1456
  constructor() {
1036
1457
  __publicField(this, "_levelStack", new Stack());
1037
1458
  __publicField(this, "_level", 1);
@@ -1044,21 +1465,34 @@ class Logging {
1044
1465
  stringify(obj) {
1045
1466
  const cache = [];
1046
1467
  return JSON.stringify(obj, function(_key, value) {
1047
- if (typeof value == "object" && value !== null) {
1048
- if (cache.indexOf(value) !== -1)
1468
+ if (typeof value === "object" && value !== null) {
1469
+ if (cache.indexOf(value) !== -1) {
1049
1470
  return;
1471
+ }
1050
1472
  cache.push(value);
1051
1473
  }
1052
1474
  return value;
1053
1475
  }, 2);
1054
1476
  }
1055
1477
  writer(_) {
1056
- return _ === void 0 ? this._writer : (this._writer = _, this);
1478
+ if (_ === void 0) return this._writer;
1479
+ this._writer = _;
1480
+ return this;
1057
1481
  }
1058
1482
  log(level, id, msg) {
1059
- if (level < this._level || this._filter && this._filter !== id) return;
1483
+ if (level < this._level) return;
1484
+ if (this._filter && this._filter !== id) return;
1060
1485
  const dateTime = (/* @__PURE__ */ new Date()).toISOString();
1061
- this._writer.rawWrite ? this._writer.rawWrite(dateTime, level, id, msg) : (typeof msg != "string" && (msg = this.stringify(msg)), this._writer.write && this._writer.write(dateTime, level, id, msg));
1486
+ if (this._writer.rawWrite) {
1487
+ this._writer.rawWrite(dateTime, level, id, msg);
1488
+ } else {
1489
+ if (typeof msg !== "string") {
1490
+ msg = this.stringify(msg);
1491
+ }
1492
+ if (this._writer.write) {
1493
+ this._writer.write(dateTime, level, id, msg);
1494
+ }
1495
+ }
1062
1496
  }
1063
1497
  debug(id, msg) {
1064
1498
  this.log(0, id, msg);
@@ -1085,21 +1519,30 @@ class Logging {
1085
1519
  this.log(7, id, msg);
1086
1520
  }
1087
1521
  level(_) {
1088
- return _ === void 0 ? this._level : (this._level = _, this);
1522
+ if (_ === void 0) return this._level;
1523
+ this._level = _;
1524
+ return this;
1089
1525
  }
1090
1526
  pushLevel(_) {
1091
- return this._levelStack.push(this._level), this._level = _, this;
1527
+ this._levelStack.push(this._level);
1528
+ this._level = _;
1529
+ return this;
1092
1530
  }
1093
1531
  popLevel() {
1094
- return this._level = this._levelStack.pop(), this;
1532
+ this._level = this._levelStack.pop();
1533
+ return this;
1095
1534
  }
1096
1535
  filter(_) {
1097
- return _ === void 0 ? this._filter : (this._filter = _, this);
1536
+ if (_ === void 0) return this._filter;
1537
+ this._filter = _;
1538
+ return this;
1098
1539
  }
1099
- }
1100
- __publicField(Logging, "_instance");
1540
+ };
1541
+ __name(_Logging, "Logging");
1542
+ __publicField(_Logging, "_instance");
1543
+ let Logging = _Logging;
1101
1544
  const logger = Logging.Instance();
1102
- class ScopedLogging {
1545
+ const _ScopedLogging = class _ScopedLogging {
1103
1546
  constructor(scopeID) {
1104
1547
  __publicField(this, "_scopeID");
1105
1548
  this._scopeID = scopeID;
@@ -1129,102 +1572,141 @@ class ScopedLogging {
1129
1572
  logger.emergency(this._scopeID, msg);
1130
1573
  }
1131
1574
  pushLevel(_) {
1132
- return logger.pushLevel(_), this;
1575
+ logger.pushLevel(_);
1576
+ return this;
1133
1577
  }
1134
1578
  popLevel() {
1135
- return logger.popLevel(), this;
1579
+ logger.popLevel();
1580
+ return this;
1136
1581
  }
1582
+ };
1583
+ __name(_ScopedLogging, "ScopedLogging");
1584
+ let ScopedLogging = _ScopedLogging;
1585
+ function scopedLogger(scopeID, filter = false) {
1586
+ if (filter) {
1587
+ logger.filter(scopeID);
1588
+ }
1589
+ return new ScopedLogging(scopeID);
1137
1590
  }
1138
- function scopedLogger(scopeID, filter = !1) {
1139
- return filter && logger.filter(scopeID), new ScopedLogging(scopeID);
1140
- }
1591
+ __name(scopedLogger, "scopedLogger");
1141
1592
  function degreesToRadians(degrees) {
1142
1593
  return degrees * (Math.PI / 180);
1143
1594
  }
1595
+ __name(degreesToRadians, "degreesToRadians");
1144
1596
  function radiansToDegrees(radians) {
1145
1597
  return radians * (180 / Math.PI);
1146
1598
  }
1599
+ __name(radiansToDegrees, "radiansToDegrees");
1147
1600
  function polarToCartesian(r, theta) {
1148
1601
  return {
1149
1602
  x: r * Math.cos(theta),
1150
1603
  y: r * Math.sin(theta)
1151
1604
  };
1152
1605
  }
1606
+ __name(polarToCartesian, "polarToCartesian");
1153
1607
  function cartesianToPolar(x, y) {
1154
1608
  return {
1155
1609
  r: Math.sqrt(x * x + y * y),
1156
1610
  theta: Math.atan2(y, x)
1157
1611
  };
1158
1612
  }
1613
+ __name(cartesianToPolar, "cartesianToPolar");
1159
1614
  function normalizeRadians(radians, min = -Math.PI, max = Math.PI) {
1160
1615
  return normalize(radians, min, max);
1161
1616
  }
1617
+ __name(normalizeRadians, "normalizeRadians");
1162
1618
  function normalizeDegrees(degrees, min = -180, max = 180) {
1163
1619
  return normalize(degrees, min, max);
1164
1620
  }
1621
+ __name(normalizeDegrees, "normalizeDegrees");
1165
1622
  function normalize(value, min, max) {
1166
- const spread = max - min, offsetValue = value - min;
1623
+ const spread = max - min;
1624
+ const offsetValue = value - min;
1167
1625
  return offsetValue - Math.floor(offsetValue / spread) * spread + min;
1168
1626
  }
1627
+ __name(normalize, "normalize");
1169
1628
  function inner(prop, obj) {
1170
- if (!(prop === void 0 || obj === void 0)) {
1171
- for (const item of prop.split(".")) {
1172
- if (!obj.hasOwnProperty(item))
1173
- return;
1174
- obj = obj[item];
1629
+ if (prop === void 0 || obj === void 0) return void 0;
1630
+ for (const item of prop.split(".")) {
1631
+ if (!obj.hasOwnProperty(item)) {
1632
+ return void 0;
1175
1633
  }
1176
- return obj;
1634
+ obj = obj[item];
1177
1635
  }
1636
+ return obj;
1178
1637
  }
1638
+ __name(inner, "inner");
1179
1639
  function exists(prop, obj) {
1180
1640
  return inner(prop, obj) !== void 0;
1181
1641
  }
1642
+ __name(exists, "exists");
1182
1643
  function _mixin(dest, source) {
1183
1644
  const empty = {};
1184
1645
  for (const key in source) {
1185
- if (!source.hasOwnProperty(key) || key === "__proto__" || key === "constructor") continue;
1646
+ if (!source.hasOwnProperty(key)) continue;
1647
+ if (key === "__proto__" || key === "constructor") continue;
1186
1648
  let s = source[key];
1187
- s instanceof Array || typeof s == "object" && (s = deepMixin(dest[key], s)), (!(key in dest) || dest[key] !== s && (!(key in empty) || empty[key] !== s)) && (dest[key] = s);
1649
+ if (s instanceof Array) ;
1650
+ else if (typeof s === "object") {
1651
+ s = deepMixin(dest[key], s);
1652
+ }
1653
+ if (!(key in dest) || dest[key] !== s && (!(key in empty) || empty[key] !== s)) {
1654
+ dest[key] = s;
1655
+ }
1188
1656
  }
1189
1657
  return dest;
1190
1658
  }
1659
+ __name(_mixin, "_mixin");
1191
1660
  function deepMixin(dest = {}, ...sources) {
1192
- if (typeof dest != "object") throw new Error(`Destination "${dest}" must be an object.`);
1193
- for (const source of sources)
1661
+ if (typeof dest !== "object") throw new Error(`Destination "${dest}" must be an object.`);
1662
+ for (const source of sources) {
1194
1663
  _mixin(dest, source);
1664
+ }
1195
1665
  return dest;
1196
1666
  }
1667
+ __name(deepMixin, "deepMixin");
1197
1668
  function deepMixinT(dest = {}, ...sources) {
1198
1669
  return deepMixin(dest, ...sources);
1199
1670
  }
1671
+ __name(deepMixinT, "deepMixinT");
1200
1672
  function safeStringify(obj) {
1201
1673
  const cache = [];
1202
1674
  return JSON.stringify(obj, function(key, value) {
1203
- if (typeof value == "object" && value !== null) {
1204
- if (cache.indexOf(value) !== -1)
1675
+ if (typeof value === "object" && value !== null) {
1676
+ if (cache.indexOf(value) !== -1) {
1205
1677
  return;
1678
+ }
1206
1679
  cache.push(value);
1207
1680
  }
1208
1681
  return value;
1209
1682
  });
1210
1683
  }
1684
+ __name(safeStringify, "safeStringify");
1211
1685
  function isArray(arg) {
1212
- return Array.isArray !== void 0 ? Array.isArray(arg) : Object.prototype.toString.call(arg) === "[object Array]";
1686
+ if (Array.isArray !== void 0) {
1687
+ return Array.isArray(arg);
1688
+ }
1689
+ return Object.prototype.toString.call(arg) === "[object Array]";
1213
1690
  }
1691
+ __name(isArray, "isArray");
1214
1692
  function classID2Meta(classID) {
1215
- const info = classID.split("_"), classInfo = info[1].split(".");
1693
+ const info = classID.split("_");
1694
+ const classInfo = info[1].split(".");
1216
1695
  return {
1217
1696
  module: `@hpcc-js/${info[0]}`,
1218
1697
  file: classInfo[0],
1219
1698
  class: classInfo[1] || classInfo[0]
1220
1699
  };
1221
1700
  }
1222
- class ObserverHandle {
1701
+ __name(classID2Meta, "classID2Meta");
1702
+ const _ObserverHandle = class _ObserverHandle {
1223
1703
  constructor(eventTarget, eventID, callback) {
1224
1704
  __publicField(this, "eventTarget");
1225
1705
  __publicField(this, "eventID");
1226
1706
  __publicField(this, "callback");
1227
- this.eventTarget = eventTarget, this.eventID = eventID, this.callback = callback;
1707
+ this.eventTarget = eventTarget;
1708
+ this.eventID = eventID;
1709
+ this.callback = callback;
1228
1710
  }
1229
1711
  release() {
1230
1712
  this.eventTarget.removeObserver(this.eventID, this.callback);
@@ -1232,69 +1714,94 @@ class ObserverHandle {
1232
1714
  unwatch() {
1233
1715
  this.release();
1234
1716
  }
1235
- }
1236
- class Observable {
1717
+ };
1718
+ __name(_ObserverHandle, "ObserverHandle");
1719
+ let ObserverHandle = _ObserverHandle;
1720
+ const _Observable = class _Observable {
1237
1721
  constructor(...events) {
1238
1722
  __publicField(this, "_eventObservers", {});
1239
1723
  }
1240
1724
  addObserver(eventID, callback) {
1241
1725
  let eventObservers = this._eventObservers[eventID];
1242
- return eventObservers || (eventObservers = [], this._eventObservers[eventID] = eventObservers), eventObservers.push(callback), new ObserverHandle(this, eventID, callback);
1726
+ if (!eventObservers) {
1727
+ eventObservers = [];
1728
+ this._eventObservers[eventID] = eventObservers;
1729
+ }
1730
+ eventObservers.push(callback);
1731
+ return new ObserverHandle(this, eventID, callback);
1243
1732
  }
1244
1733
  removeObserver(eventID, callback) {
1245
1734
  const eventObservers = this._eventObservers[eventID];
1246
- if (eventObservers)
1247
- for (let i = eventObservers.length - 1; i >= 0; --i)
1248
- eventObservers[i] === callback && eventObservers.splice(i, 1);
1735
+ if (eventObservers) {
1736
+ for (let i = eventObservers.length - 1; i >= 0; --i) {
1737
+ if (eventObservers[i] === callback) {
1738
+ eventObservers.splice(i, 1);
1739
+ }
1740
+ }
1741
+ }
1249
1742
  return this;
1250
1743
  }
1251
1744
  dispatchEvent(eventID, ...args) {
1252
1745
  const eventObservers = this._eventObservers[eventID];
1253
- if (eventObservers)
1254
- for (const observer of eventObservers)
1746
+ if (eventObservers) {
1747
+ for (const observer of eventObservers) {
1255
1748
  observer(...args);
1749
+ }
1750
+ }
1256
1751
  return this;
1257
1752
  }
1258
1753
  _hasObserver(eventID) {
1259
1754
  const eventObservers = this._eventObservers[eventID];
1260
- for (const observer in eventObservers)
1261
- if (eventObservers[observer])
1262
- return !0;
1263
- return !1;
1755
+ for (const observer in eventObservers) {
1756
+ if (eventObservers[observer]) {
1757
+ return true;
1758
+ }
1759
+ }
1760
+ return false;
1264
1761
  }
1265
1762
  hasObserver(_eventID) {
1266
- if (_eventID !== void 0)
1763
+ if (_eventID !== void 0) {
1267
1764
  return this._hasObserver(_eventID);
1268
- for (const eventID in this._eventObservers)
1269
- if (this._hasObserver(eventID))
1270
- return !0;
1271
- return !1;
1765
+ }
1766
+ for (const eventID in this._eventObservers) {
1767
+ if (this._hasObserver(eventID)) {
1768
+ return true;
1769
+ }
1770
+ }
1771
+ return false;
1272
1772
  }
1273
- }
1773
+ };
1774
+ __name(_Observable, "Observable");
1775
+ let Observable = _Observable;
1274
1776
  let requestAnimationFrame;
1275
1777
  (function() {
1276
- if (root.requestAnimationFrame)
1778
+ if (root.requestAnimationFrame) {
1277
1779
  requestAnimationFrame = root.requestAnimationFrame;
1278
- else {
1780
+ } else {
1279
1781
  let lastTime = 0;
1280
- requestAnimationFrame = function(callback) {
1281
- const currTime = (/* @__PURE__ */ new Date()).getTime(), timeToCall = Math.max(0, 16 - (currTime - lastTime)), id = setTimeout(() => callback(currTime + timeToCall), timeToCall);
1282
- return lastTime = currTime + timeToCall, id;
1283
- };
1782
+ requestAnimationFrame = /* @__PURE__ */ __name(function(callback) {
1783
+ const currTime = (/* @__PURE__ */ new Date()).getTime();
1784
+ const timeToCall = Math.max(0, 16 - (currTime - lastTime));
1785
+ const id = setTimeout(() => callback(currTime + timeToCall), timeToCall);
1786
+ lastTime = currTime + timeToCall;
1787
+ return id;
1788
+ }, "requestAnimationFrame");
1284
1789
  }
1285
1790
  })();
1286
- class Message {
1791
+ const _Message = class _Message {
1287
1792
  get canConflate() {
1288
- return !1;
1793
+ return false;
1289
1794
  }
1290
1795
  conflate(other) {
1291
- return !1;
1796
+ return false;
1292
1797
  }
1293
1798
  void() {
1294
- return !1;
1799
+ return false;
1295
1800
  }
1296
- }
1297
- class Dispatch {
1801
+ };
1802
+ __name(_Message, "Message");
1803
+ let Message = _Message;
1804
+ const _Dispatch = class _Dispatch {
1298
1805
  constructor() {
1299
1806
  __publicField(this, "_observerID", 0);
1300
1807
  __publicField(this, "_observers", []);
@@ -1305,17 +1812,24 @@ class Dispatch {
1305
1812
  }
1306
1813
  messages() {
1307
1814
  const retVal = [];
1308
- return this._messageBuffer.forEach((msg) => {
1309
- retVal.some((msg2) => msg2.canConflate && msg2.conflate(msg)) || retVal.push(msg);
1310
- }), retVal;
1815
+ this._messageBuffer.forEach((msg) => {
1816
+ if (!retVal.some((msg2) => msg2.canConflate && msg2.conflate(msg))) {
1817
+ retVal.push(msg);
1818
+ }
1819
+ });
1820
+ return retVal;
1311
1821
  }
1312
1822
  dispatchAll() {
1313
- this.dispatch(this.messages()), this.flush();
1823
+ this.dispatch(this.messages());
1824
+ this.flush();
1314
1825
  }
1315
1826
  dispatch(messages) {
1316
- messages.length !== 0 && this.observers().forEach((o) => {
1827
+ if (messages.length === 0) return;
1828
+ this.observers().forEach((o) => {
1317
1829
  const msgs = messages.filter((m) => !m.void() && (o.type === void 0 || m instanceof o.type));
1318
- msgs.length && o.callback(msgs);
1830
+ if (msgs.length) {
1831
+ o.callback(msgs);
1832
+ }
1319
1833
  });
1320
1834
  }
1321
1835
  hasObserver() {
@@ -1328,11 +1842,14 @@ class Dispatch {
1328
1842
  this.dispatch([msg]);
1329
1843
  }
1330
1844
  post(msg) {
1331
- this._messageBuffer.push(msg), requestAnimationFrame(() => this.dispatchAll());
1845
+ this._messageBuffer.push(msg);
1846
+ requestAnimationFrame(() => this.dispatchAll());
1332
1847
  }
1333
1848
  attach(callback, type) {
1334
- const context = this, id = ++this._observerID;
1335
- return this._observers.push({ id, type, callback }), {
1849
+ const context = this;
1850
+ const id = ++this._observerID;
1851
+ this._observers.push({ id, type, callback });
1852
+ return {
1336
1853
  release() {
1337
1854
  context._observers = context._observers.filter((o) => o.id !== id);
1338
1855
  },
@@ -1341,8 +1858,10 @@ class Dispatch {
1341
1858
  }
1342
1859
  };
1343
1860
  }
1344
- }
1345
- class XMLNode {
1861
+ };
1862
+ __name(_Dispatch, "Dispatch");
1863
+ let Dispatch = _Dispatch;
1864
+ const _XMLNode = class _XMLNode {
1346
1865
  constructor(name) {
1347
1866
  __publicField(this, "name", "");
1348
1867
  __publicField(this, "$", {});
@@ -1360,35 +1879,57 @@ class XMLNode {
1360
1879
  this._children.push(child);
1361
1880
  }
1362
1881
  children(tag) {
1363
- return tag === void 0 ? this._children : this._children.filter((xmlNode) => xmlNode.name === tag);
1882
+ if (tag === void 0) {
1883
+ return this._children;
1884
+ }
1885
+ return this._children.filter((xmlNode) => {
1886
+ return xmlNode.name === tag;
1887
+ });
1364
1888
  }
1365
- }
1366
- class SAXStackParser {
1889
+ };
1890
+ __name(_XMLNode, "XMLNode");
1891
+ let XMLNode = _XMLNode;
1892
+ const _SAXStackParser = class _SAXStackParser {
1367
1893
  constructor() {
1368
1894
  __publicField(this, "root");
1369
1895
  __publicField(this, "stack", new Stack());
1370
1896
  }
1371
1897
  walkDoc(node) {
1372
1898
  const xmlNode = this._startXMLNode(node);
1373
- if (node.attributes)
1899
+ if (node.attributes) {
1374
1900
  for (let i = 0; i < node.attributes.length; ++i) {
1375
1901
  const attribute = node.attributes.item(i);
1376
1902
  this.attributes(attribute.nodeName, attribute.nodeValue);
1377
1903
  }
1378
- if (this.startXMLNode(xmlNode), node.childNodes)
1904
+ }
1905
+ this.startXMLNode(xmlNode);
1906
+ if (node.childNodes) {
1379
1907
  for (let i = 0; i < node.childNodes.length; ++i) {
1380
1908
  const childNode = node.childNodes.item(i);
1381
- childNode.nodeType === childNode.TEXT_NODE ? this.characters(childNode.nodeValue) : this.walkDoc(childNode);
1909
+ if (childNode.nodeType === childNode.TEXT_NODE) {
1910
+ this.characters(childNode.nodeValue);
1911
+ } else {
1912
+ this.walkDoc(childNode);
1913
+ }
1382
1914
  }
1915
+ }
1383
1916
  this.endXMLNode(this.stack.pop());
1384
1917
  }
1385
1918
  _startXMLNode(node) {
1386
1919
  const newNode = new XMLNode(node.nodeName);
1387
- return this.stack.depth() ? this.stack.top().appendChild(newNode) : this.root = newNode, this.stack.push(newNode);
1920
+ if (!this.stack.depth()) {
1921
+ this.root = newNode;
1922
+ } else {
1923
+ this.stack.top().appendChild(newNode);
1924
+ }
1925
+ return this.stack.push(newNode);
1388
1926
  }
1389
1927
  parse(xml) {
1390
- const doc = new DOMParser().parseFromString(xml, "application/xml");
1391
- this.startDocument(), this.walkDoc(doc), this.endDocument();
1928
+ const domParser = new DOMParser();
1929
+ const doc = domParser.parseFromString(xml, "application/xml");
1930
+ this.startDocument();
1931
+ this.walkDoc(doc);
1932
+ this.endDocument();
1392
1933
  }
1393
1934
  // Callbacks ---
1394
1935
  startDocument() {
@@ -1405,10 +1946,13 @@ class SAXStackParser {
1405
1946
  characters(text) {
1406
1947
  this.stack.top().appendContent(text);
1407
1948
  }
1408
- }
1409
- class XML2JSONParser extends SAXStackParser {
1949
+ };
1950
+ __name(_SAXStackParser, "SAXStackParser");
1951
+ let SAXStackParser = _SAXStackParser;
1952
+ const _XML2JSONParser = class _XML2JSONParser extends SAXStackParser {
1410
1953
  startXMLNode(node) {
1411
- switch (super.startXMLNode(node), node.name) {
1954
+ super.startXMLNode(node);
1955
+ switch (node.name) {
1412
1956
  }
1413
1957
  }
1414
1958
  endXMLNode(node) {
@@ -1416,26 +1960,39 @@ class XML2JSONParser extends SAXStackParser {
1416
1960
  }
1417
1961
  super.endXMLNode(node);
1418
1962
  }
1419
- }
1963
+ };
1964
+ __name(_XML2JSONParser, "XML2JSONParser");
1965
+ let XML2JSONParser = _XML2JSONParser;
1420
1966
  function xml2json(xml) {
1421
1967
  const saxParser = new XML2JSONParser();
1422
- return saxParser.parse(xml), saxParser.root;
1968
+ saxParser.parse(xml);
1969
+ return saxParser.root;
1423
1970
  }
1424
- class PropChangedMessage extends Message {
1971
+ __name(xml2json, "xml2json");
1972
+ const _PropChangedMessage = class _PropChangedMessage extends Message {
1425
1973
  constructor(property, newValue, oldValue) {
1426
- super(), this.property = property, this.newValue = newValue, this.oldValue = oldValue;
1974
+ super();
1975
+ this.property = property;
1976
+ this.newValue = newValue;
1977
+ this.oldValue = oldValue;
1427
1978
  }
1428
1979
  get canConflate() {
1429
- return !0;
1980
+ return true;
1430
1981
  }
1431
1982
  conflate(other) {
1432
- return this.property === other.property ? (this.newValue = other.newValue, !0) : !1;
1983
+ if (this.property === other.property) {
1984
+ this.newValue = other.newValue;
1985
+ return true;
1986
+ }
1987
+ return false;
1433
1988
  }
1434
1989
  void() {
1435
1990
  return deepEquals(this.newValue, this.oldValue);
1436
1991
  }
1437
- }
1438
- class StateObject {
1992
+ };
1993
+ __name(_PropChangedMessage, "PropChangedMessage");
1994
+ let PropChangedMessage = _PropChangedMessage;
1995
+ const _StateObject = class _StateObject {
1439
1996
  constructor() {
1440
1997
  __publicField(this, "_espState", {});
1441
1998
  __publicField(this, "_dispatch", new Dispatch());
@@ -1443,23 +2000,35 @@ class StateObject {
1443
2000
  __publicField(this, "_monitorTickCount", 0);
1444
2001
  }
1445
2002
  clear(newVals) {
1446
- this._espState = {}, newVals !== void 0 && this.set(newVals), this._monitorTickCount = 0;
2003
+ this._espState = {};
2004
+ if (newVals !== void 0) {
2005
+ this.set(newVals);
2006
+ }
2007
+ this._monitorTickCount = 0;
1447
2008
  }
1448
2009
  get(key, defValue) {
1449
- return key === void 0 ? this._espState : this.has(key) ? this._espState[key] : defValue;
2010
+ if (key === void 0) {
2011
+ return this._espState;
2012
+ }
2013
+ return this.has(key) ? this._espState[key] : defValue;
1450
2014
  }
1451
2015
  set(keyOrNewVals, newVal) {
1452
- if (typeof keyOrNewVals == "string")
2016
+ if (typeof keyOrNewVals === "string") {
1453
2017
  return this.setSingle(keyOrNewVals, newVal);
2018
+ }
1454
2019
  this.setAll(keyOrNewVals);
1455
2020
  }
1456
2021
  setSingle(key, newVal) {
1457
2022
  const oldVal = this._espState[key];
1458
- this._espState[key] = newVal, this._dispatch.post(new PropChangedMessage(key, newVal, oldVal));
2023
+ this._espState[key] = newVal;
2024
+ this._dispatch.post(new PropChangedMessage(key, newVal, oldVal));
1459
2025
  }
1460
2026
  setAll(_) {
1461
- for (const key in _)
1462
- _.hasOwnProperty(key) && this.setSingle(key, _[key]);
2027
+ for (const key in _) {
2028
+ if (_.hasOwnProperty(key)) {
2029
+ this.setSingle(key, _[key]);
2030
+ }
2031
+ }
1463
2032
  }
1464
2033
  has(key) {
1465
2034
  return this._espState[key] !== void 0;
@@ -1479,7 +2048,9 @@ class StateObject {
1479
2048
  return this._dispatch.attach((messages) => {
1480
2049
  const filteredMessages = messages.filter((m) => m.property === propIDOrCallback);
1481
2050
  if (filteredMessages.length) {
1482
- filteredMessages.length > 1 && console.warn("Should only be 1 message?");
2051
+ if (filteredMessages.length > 1) {
2052
+ console.warn("Should only be 1 message?");
2053
+ }
1483
2054
  const event = filteredMessages[filteredMessages.length - 1];
1484
2055
  callback({
1485
2056
  id: event.property,
@@ -1491,17 +2062,19 @@ class StateObject {
1491
2062
  }
1492
2063
  }
1493
2064
  on(eventID, propIDOrCallback, callback) {
1494
- return this.addObserver(eventID, propIDOrCallback, callback), this;
2065
+ this.addObserver(eventID, propIDOrCallback, callback);
2066
+ return this;
1495
2067
  }
1496
2068
  isCallback(propIDOrCallback) {
1497
- return typeof propIDOrCallback == "function";
2069
+ return typeof propIDOrCallback === "function";
1498
2070
  }
1499
2071
  hasEventListener() {
1500
2072
  return this._dispatch.hasObserver();
1501
2073
  }
1502
2074
  // Monitoring ---
1503
- async refresh(full = !1) {
1504
- return await Promise.resolve(), this;
2075
+ async refresh(full = false) {
2076
+ await Promise.resolve();
2077
+ return this;
1505
2078
  }
1506
2079
  _monitor() {
1507
2080
  if (this._monitorHandle) {
@@ -1509,56 +2082,91 @@ class StateObject {
1509
2082
  return;
1510
2083
  }
1511
2084
  this._monitorHandle = setTimeout(() => {
1512
- (this.hasEventListener() ? this.refresh() : Promise.resolve()).then(() => {
2085
+ const refreshPromise = this.hasEventListener() ? this.refresh() : Promise.resolve();
2086
+ refreshPromise.then(() => {
1513
2087
  this._monitor();
1514
- }), delete this._monitorHandle;
2088
+ });
2089
+ delete this._monitorHandle;
1515
2090
  }, this._monitorTimeoutDuration());
1516
2091
  }
1517
2092
  _monitorTimeoutDuration() {
1518
- return ++this._monitorTickCount, this._monitorTickCount <= 1 ? 0 : 3e4;
2093
+ ++this._monitorTickCount;
2094
+ if (this._monitorTickCount <= 1) {
2095
+ return 0;
2096
+ }
2097
+ return 3e4;
1519
2098
  }
1520
- watch(callback, triggerChange = !0) {
1521
- if (typeof callback != "function")
2099
+ watch(callback, triggerChange = true) {
2100
+ if (typeof callback !== "function") {
1522
2101
  throw new Error("Invalid Callback");
1523
- triggerChange && setTimeout(() => {
1524
- const props = this.get(), changes = [];
1525
- for (const key in props)
1526
- props.hasOwnProperty(props) && changes.push({ id: key, newValue: props[key], oldValue: void 0 });
1527
- callback(changes);
1528
- }, 0);
2102
+ }
2103
+ if (triggerChange) {
2104
+ setTimeout(() => {
2105
+ const props = this.get();
2106
+ const changes = [];
2107
+ for (const key in props) {
2108
+ if (props.hasOwnProperty(props)) {
2109
+ changes.push({ id: key, newValue: props[key], oldValue: void 0 });
2110
+ }
2111
+ }
2112
+ callback(changes);
2113
+ }, 0);
2114
+ }
1529
2115
  const retVal = this.addObserver("changed", callback);
1530
- return this._monitor(), retVal;
2116
+ this._monitor();
2117
+ return retVal;
1531
2118
  }
1532
- }
2119
+ };
2120
+ __name(_StateObject, "StateObject");
2121
+ let StateObject = _StateObject;
1533
2122
  function trim(str, char) {
1534
- if (typeof char != "string" || char.length === 0) return str;
1535
- for (; str.indexOf(char) === 0; )
2123
+ if (typeof char !== "string") return str;
2124
+ if (char.length === 0) return str;
2125
+ while (str.indexOf(char) === 0) {
1536
2126
  str = str.substring(1);
1537
- for (; endsWith(str, char); )
2127
+ }
2128
+ while (endsWith(str, char)) {
1538
2129
  str = str.substring(0, str.length - 1);
2130
+ }
1539
2131
  return str;
1540
2132
  }
2133
+ __name(trim, "trim");
1541
2134
  function endsWith(origString, searchString, position) {
1542
2135
  const subjectString = origString.toString();
1543
- (typeof position != "number" || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) && (position = subjectString.length), position -= searchString.length;
2136
+ if (typeof position !== "number" || !isFinite(position) || Math.floor(position) !== position || position > subjectString.length) {
2137
+ position = subjectString.length;
2138
+ }
2139
+ position -= searchString.length;
1544
2140
  const lastIndex = subjectString.lastIndexOf(searchString, position);
1545
2141
  return lastIndex !== -1 && lastIndex === position;
1546
2142
  }
2143
+ __name(endsWith, "endsWith");
1547
2144
  function join(...segments) {
1548
- const parts = segments.reduce((parts2, segment) => (parts2.length > 0 && (segment = segment.replace(/^\//, "")), segment = segment.replace(/\/$/, ""), [...parts2, ...segment.split("/")]), []), resultParts = [];
1549
- for (const part of parts)
1550
- if (part !== ".") {
1551
- if (part === "..") {
1552
- resultParts.pop();
1553
- continue;
1554
- }
1555
- resultParts.push(part);
2145
+ const parts = segments.reduce((parts2, segment) => {
2146
+ if (parts2.length > 0) {
2147
+ segment = segment.replace(/^\//, "");
2148
+ }
2149
+ segment = segment.replace(/\/$/, "");
2150
+ return [...parts2, ...segment.split("/")];
2151
+ }, []);
2152
+ const resultParts = [];
2153
+ for (const part of parts) {
2154
+ if (part === ".") {
2155
+ continue;
1556
2156
  }
2157
+ if (part === "..") {
2158
+ resultParts.pop();
2159
+ continue;
2160
+ }
2161
+ resultParts.push(part);
2162
+ }
1557
2163
  return resultParts.join("/");
1558
2164
  }
2165
+ __name(join, "join");
1559
2166
  function dirname(path) {
1560
2167
  return join(path, "..");
1561
2168
  }
2169
+ __name(dirname, "dirname");
1562
2170
  export {
1563
2171
  AsyncCache,
1564
2172
  AsyncOrderedQueue,