@hpcc-js/util 3.3.11 → 3.4.0

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