@likec4/core 1.19.2 → 1.20.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/builder/index.cjs +881 -0
  2. package/dist/builder/index.d.cts +503 -0
  3. package/dist/builder/index.d.mts +4 -3
  4. package/dist/builder/index.d.ts +4 -3
  5. package/dist/builder/{index.js → index.mjs} +14 -4
  6. package/dist/compute-view/index.cjs +86 -0
  7. package/dist/compute-view/index.d.cts +23 -0
  8. package/dist/compute-view/index.d.mts +3 -2
  9. package/dist/compute-view/index.d.ts +3 -2
  10. package/dist/compute-view/{index.js → index.mjs} +6 -5
  11. package/dist/index.cjs +4320 -0
  12. package/dist/index.d.cts +270 -0
  13. package/dist/index.d.mts +130 -4
  14. package/dist/index.d.ts +130 -4
  15. package/dist/{index.js → index.mjs} +512 -7
  16. package/dist/model/index.cjs +40 -0
  17. package/dist/model/index.d.cts +259 -0
  18. package/dist/model/index.d.mts +3 -3
  19. package/dist/model/index.d.ts +3 -3
  20. package/dist/model/index.mjs +1 -0
  21. package/dist/shared/core.B2QYWlYe.cjs +435 -0
  22. package/dist/shared/core.B72vUaNB.d.cts +850 -0
  23. package/dist/shared/core.BGus30EM.cjs +8027 -0
  24. package/dist/shared/core.BRuJ3Wzf.d.mts +12 -0
  25. package/dist/shared/{core.CqXs9Frh.d.ts → core.BdbFkE_p.d.cts} +10 -4
  26. package/dist/shared/core.BvdNMbcA.d.cts +12 -0
  27. package/dist/shared/{object_hash.CE_oF3I3.js → core.BxvDITEI.mjs} +26 -389
  28. package/dist/shared/core.ByNgh-mC.d.cts +127 -0
  29. package/dist/shared/core.C9DCnJh8.cjs +908 -0
  30. package/dist/shared/{index.KOeaSlL8.js → core.CqCTxzMY.mjs} +787 -372
  31. package/dist/shared/core.D74xkKkG.d.cts +148 -0
  32. package/dist/shared/{core.DyJ41fBO.d.ts → core.D_Gc58Gt.d.ts} +12 -4
  33. package/dist/shared/core.Damrzla-.d.ts +12 -0
  34. package/dist/shared/{core.BL1oTk7-.d.mts → core.Dfzrh1VA.d.mts} +12 -4
  35. package/dist/shared/core.DsoCu540.cjs +26 -0
  36. package/dist/shared/{view.DrmaOfjr.js → core.DunIMHRf.mjs} +24 -1
  37. package/dist/shared/{core.2I-l5UtM.d.mts → core.ZWiGANIJ.d.ts} +10 -4
  38. package/dist/shared/core.gv1bMwCC.cjs +39 -0
  39. package/dist/shared/core.jy6z2iRn.d.mts +729 -0
  40. package/dist/shared/core.m3rCQAv6.mjs +37 -0
  41. package/dist/types/index.cjs +107 -0
  42. package/dist/types/index.d.cts +72 -0
  43. package/dist/types/index.d.mts +2 -2
  44. package/dist/types/index.d.ts +2 -2
  45. package/dist/types/{index.js → index.mjs} +1 -1
  46. package/dist/utils/index.cjs +95 -0
  47. package/dist/utils/index.d.cts +356 -0
  48. package/dist/utils/index.d.mts +1 -64
  49. package/dist/utils/index.d.ts +1 -64
  50. package/dist/utils/index.mjs +56 -0
  51. package/package.json +51 -25
  52. package/src/builder/Builder.view-common.ts +20 -1
  53. package/src/compute-view/deployment-view/predicates/relation-direct.ts +26 -29
  54. package/src/compute-view/deployment-view/predicates/relation-incoming.ts +1 -1
  55. package/src/compute-view/deployment-view/predicates/utils.ts +47 -16
  56. package/src/compute-view/element-view/__test__/fixture.ts +17 -4
  57. package/src/compute-view/element-view/compute.ts +3 -2
  58. package/src/compute-view/element-view/predicates.ts +520 -0
  59. package/src/compute-view/element-view/utils.ts +11 -7
  60. package/src/compute-view/index.ts +1 -0
  61. package/src/compute-view/relationships-view/_types.ts +16 -0
  62. package/src/compute-view/relationships-view/compute.ts +74 -0
  63. package/src/compute-view/relationships-view/layout.ts +357 -0
  64. package/src/compute-view/relationships-view/utils.ts +40 -0
  65. package/src/compute-view/utils/relationExpressionToPredicates.ts +11 -4
  66. package/src/index.ts +16 -0
  67. package/src/model/DeploymentElementModel.ts +4 -0
  68. package/src/model/ElementModel.ts +13 -0
  69. package/src/model/LikeC4Model.ts +2 -2
  70. package/src/model/RelationModel.ts +5 -0
  71. package/src/model/guards.ts +17 -1
  72. package/src/model/view/LikeC4ViewModel.ts +7 -1
  73. package/src/model/view/NodeModel.ts +5 -0
  74. package/src/types/operators.ts +42 -2
  75. package/src/types/view.ts +2 -2
  76. package/src/utils/index.ts +0 -5
  77. package/src/utils/iterable/unique.ts +1 -7
  78. package/dist/model/index.js +0 -1
  79. package/dist/utils/index.js +0 -347
  80. /package/dist/shared/{chunk-RAAYCPUM.M-JWF7SS.js → core.M-JWF7SS.mjs} +0 -0
@@ -1,13 +1,610 @@
1
- import { O as x, P as s$1, Q as a$4, k as hierarchyLevel, o as isAncestor, f as commonAncestor, r as sortNaturalByFqn, m as m$3, c as commonHead, R as getDefaultExportFromCjs, S as requireForeach, T as requireIterator, U as u$7, N as objectHash, J as intersection, H as difference, L as union, M as stringHash, I as equals, x as isString, q as isDescendantOf, a as isSameHierarchy, C as isome, y as ifilter, B as isIterable, G as toSet, u as sortParentsFirst, F as toArray, D as DefaultMap, A as imap, i as i$9, V as d$6, p as parentFqn, W as n$5, g as compareByFqnHierarchically, w as isNonEmptyArray, d as compareNatural, n as nameFromFqn, t as t$6, X as hasIntersection, l as l$7, s as sortByFqnHierarchically, e as ancestorsFqn, E as iunique, z as iflat, v as getOrCreate } from './object_hash.CE_oF3I3.js';
2
- import { e as DefaultElementShape, d as DefaultThemeColor, a7 as o$9, q as isElementWhere, M as whereOperatorAsPredicate, z as isWildcard, l as isElementKindExpr, p as isElementTagExpr, n as n$4, r as isExpandedElementExpr, m as isElementRef, h as isCustomElement, a5 as isViewRuleStyle, a8 as y$1, Q as ComputedNode, E as ElementKind, N as DefaultArrowType, F as FqnExpr, R as RelationExpr, o as o$a, a4 as isViewRulePredicate, a0 as isViewRuleAutoLayout, a3 as isViewRuleGroup, a1 as isViewRuleGlobalPredicateRef, a2 as isViewRuleGlobalStyle, a6 as stepEdgeId, _ as isDynamicViewParallelSteps, P as DefaultRelationshipColor, O as DefaultLineStyle, u as isOutgoing$1, s as isIncoming$1, t as isInOut, v as isRelation, y as isRelationWhere, j as isCustomRelationExpr, x as isRelationPredicateExpr, b as isElementPredicateExpr, a as isElementView, Z as isDynamicView, Y as isDeploymentView, D as DeploymentElement, U as extractStep, $ as isStepEdgeId, c as isScopedElementView } from './view.DrmaOfjr.js';
3
- import { u as u$6, a as nonNullable, i as invariant, n as nonexhaustive } from './chunk-RAAYCPUM.M-JWF7SS.js';
1
+ import { g as getDefaultExportFromCjs, P as x, Q as s$1, R as a$4, r as hierarchyLevel, s as isAncestor, j as commonAncestor, w as sortNaturalByFqn, m as m$3, e as commonHead, S as u$7, O as objectHash, K as intersection, I as difference, M as union, N as stringHash, J as equals, A as isString, u as isDescendantOf, c as isSameHierarchy, F as isome, B as ifilter, E as isIterable, t as toSet, x as sortParentsFirst, H as toArray, D as imap, a as i$9, T as d$6, p as parentFqn, U as n$5, k as compareByFqnHierarchically, z as isNonEmptyArray, f as compareNatural, n as nameFromFqn, b as t$6, V as hasIntersection, l as l$7, v as sortByFqnHierarchically, h as ancestorsFqn, G as iunique, C as iflat, y as getOrCreate, i as ifind } from './core.BxvDITEI.mjs';
2
+ import { e as DefaultElementShape, d as DefaultThemeColor, a7 as o$9, q as isElementWhere, M as whereOperatorAsPredicate, z as isWildcard, l as isElementKindExpr, p as isElementTagExpr, n as n$4, r as isExpandedElementExpr, m as isElementRef, h as isCustomElement, a5 as isViewRuleStyle, a8 as y$1, Q as ComputedNode, E as ElementKind, N as DefaultArrowType, F as FqnExpr, R as RelationExpr, o as o$a, a4 as isViewRulePredicate, a0 as isViewRuleAutoLayout, a3 as isViewRuleGroup, a1 as isViewRuleGlobalPredicateRef, a2 as isViewRuleGlobalStyle, a6 as stepEdgeId, _ as isDynamicViewParallelSteps, P as DefaultRelationshipColor, O as DefaultLineStyle, u as isOutgoing$1, s as isIncoming$1, t as isInOut, v as isRelation, y as isRelationWhere, j as isCustomRelationExpr, x as isRelationPredicateExpr, b as isElementPredicateExpr, a as isElementView, Z as isDynamicView, Y as isDeploymentView, D as DeploymentElement, U as extractStep, $ as isStepEdgeId, c as isScopedElementView } from './core.DunIMHRf.mjs';
3
+ import { u as u$6, a as nonNullable, i as invariant, n as nonexhaustive } from './core.M-JWF7SS.mjs';
4
4
 
5
- function r$3(...t){return u$6(Object.values,t)}
5
+ /**
6
+ * Mnemonist DefaultMap
7
+ * =====================
8
+ *
9
+ * JavaScript implementation of a default map that will return a constructed
10
+ * value any time one tries to access an inexisting key. It's quite similar
11
+ * to python's defaultdict.
12
+ */
6
13
 
7
- function d$5(...e){return e.length===2?(n,...r)=>t$5(n,...e,...r):t$5(...e)}var t$5=(e,n,r,...a)=>n(e,...a)?typeof r=="function"?r(e,...a):r.onTrue(e,...a):typeof r=="function"?e:r.onFalse(e,...a);
14
+ var defaultMap;
15
+ var hasRequiredDefaultMap;
16
+
17
+ function requireDefaultMap () {
18
+ if (hasRequiredDefaultMap) return defaultMap;
19
+ hasRequiredDefaultMap = 1;
20
+ /**
21
+ * DefaultMap.
22
+ *
23
+ * @constructor
24
+ */
25
+ function DefaultMap(factory) {
26
+ if (typeof factory !== 'function')
27
+ throw new Error('mnemonist/DefaultMap.constructor: expecting a function.');
28
+
29
+ this.items = new Map();
30
+ this.factory = factory;
31
+ this.size = 0;
32
+ }
33
+
34
+ /**
35
+ * Method used to clear the structure.
36
+ *
37
+ * @return {undefined}
38
+ */
39
+ DefaultMap.prototype.clear = function() {
40
+
41
+ // Properties
42
+ this.items.clear();
43
+ this.size = 0;
44
+ };
45
+
46
+ /**
47
+ * Method used to get the value set for given key. If the key does not exist,
48
+ * the value will be created using the provided factory.
49
+ *
50
+ * @param {any} key - Target key.
51
+ * @return {any}
52
+ */
53
+ DefaultMap.prototype.get = function(key) {
54
+ var value = this.items.get(key);
55
+
56
+ if (typeof value === 'undefined') {
57
+ value = this.factory(key, this.size);
58
+ this.items.set(key, value);
59
+ this.size++;
60
+ }
61
+
62
+ return value;
63
+ };
64
+
65
+ /**
66
+ * Method used to get the value set for given key. If the key does not exist,
67
+ * a value won't be created.
68
+ *
69
+ * @param {any} key - Target key.
70
+ * @return {any}
71
+ */
72
+ DefaultMap.prototype.peek = function(key) {
73
+ return this.items.get(key);
74
+ };
75
+
76
+ /**
77
+ * Method used to set a value for given key.
78
+ *
79
+ * @param {any} key - Target key.
80
+ * @param {any} value - Value.
81
+ * @return {DefaultMap}
82
+ */
83
+ DefaultMap.prototype.set = function(key, value) {
84
+ this.items.set(key, value);
85
+ this.size = this.items.size;
86
+
87
+ return this;
88
+ };
89
+
90
+ /**
91
+ * Method used to test the existence of a key in the map.
92
+ *
93
+ * @param {any} key - Target key.
94
+ * @return {boolean}
95
+ */
96
+ DefaultMap.prototype.has = function(key) {
97
+ return this.items.has(key);
98
+ };
99
+
100
+ /**
101
+ * Method used to delete target key.
102
+ *
103
+ * @param {any} key - Target key.
104
+ * @return {boolean}
105
+ */
106
+ DefaultMap.prototype.delete = function(key) {
107
+ var deleted = this.items.delete(key);
108
+
109
+ this.size = this.items.size;
110
+
111
+ return deleted;
112
+ };
113
+
114
+ /**
115
+ * Method used to iterate over each of the key/value pairs.
116
+ *
117
+ * @param {function} callback - Function to call for each item.
118
+ * @param {object} scope - Optional scope.
119
+ * @return {undefined}
120
+ */
121
+ DefaultMap.prototype.forEach = function(callback, scope) {
122
+ scope = arguments.length > 1 ? scope : this;
123
+
124
+ this.items.forEach(callback, scope);
125
+ };
126
+
127
+ /**
128
+ * Iterators.
129
+ */
130
+ DefaultMap.prototype.entries = function() {
131
+ return this.items.entries();
132
+ };
133
+
134
+ DefaultMap.prototype.keys = function() {
135
+ return this.items.keys();
136
+ };
137
+
138
+ DefaultMap.prototype.values = function() {
139
+ return this.items.values();
140
+ };
141
+
142
+ /**
143
+ * Attaching the #.entries method to Symbol.iterator if possible.
144
+ */
145
+ if (typeof Symbol !== 'undefined')
146
+ DefaultMap.prototype[Symbol.iterator] = DefaultMap.prototype.entries;
147
+
148
+ /**
149
+ * Convenience known methods.
150
+ */
151
+ DefaultMap.prototype.inspect = function() {
152
+ return this.items;
153
+ };
154
+
155
+ if (typeof Symbol !== 'undefined')
156
+ DefaultMap.prototype[Symbol.for('nodejs.util.inspect.custom')] = DefaultMap.prototype.inspect;
157
+
158
+ /**
159
+ * Typical factories.
160
+ */
161
+ DefaultMap.autoIncrement = function() {
162
+ var i = 0;
163
+
164
+ return function() {
165
+ return i++;
166
+ };
167
+ };
168
+
169
+ /**
170
+ * Exporting.
171
+ */
172
+ defaultMap = DefaultMap;
173
+ return defaultMap;
174
+ }
175
+
176
+ var defaultMapExports = requireDefaultMap();
177
+ const DefaultMap = /*@__PURE__*/getDefaultExportFromCjs(defaultMapExports);
178
+
179
+ /**
180
+ * Obliterator Iterator Class
181
+ * ===========================
182
+ *
183
+ * Simple class representing the library's iterators.
184
+ */
185
+
186
+ var iterator;
187
+ var hasRequiredIterator;
188
+
189
+ function requireIterator () {
190
+ if (hasRequiredIterator) return iterator;
191
+ hasRequiredIterator = 1;
192
+ /**
193
+ * Iterator class.
194
+ *
195
+ * @constructor
196
+ * @param {function} next - Next function.
197
+ */
198
+ function Iterator(next) {
199
+ if (typeof next !== 'function')
200
+ throw new Error('obliterator/iterator: expecting a function!');
201
+
202
+ this.next = next;
203
+ }
204
+
205
+ /**
206
+ * If symbols are supported, we add `next` to `Symbol.iterator`.
207
+ */
208
+ if (typeof Symbol !== 'undefined')
209
+ Iterator.prototype[Symbol.iterator] = function () {
210
+ return this;
211
+ };
212
+
213
+ /**
214
+ * Returning an iterator of the given values.
215
+ *
216
+ * @param {any...} values - Values.
217
+ * @return {Iterator}
218
+ */
219
+ Iterator.of = function () {
220
+ var args = arguments,
221
+ l = args.length,
222
+ i = 0;
223
+
224
+ return new Iterator(function () {
225
+ if (i >= l) return {done: true};
226
+
227
+ return {done: false, value: args[i++]};
228
+ });
229
+ };
230
+
231
+ /**
232
+ * Returning an empty iterator.
233
+ *
234
+ * @return {Iterator}
235
+ */
236
+ Iterator.empty = function () {
237
+ var iterator = new Iterator(function () {
238
+ return {done: true};
239
+ });
240
+
241
+ return iterator;
242
+ };
243
+
244
+ /**
245
+ * Returning an iterator over the given indexed sequence.
246
+ *
247
+ * @param {string|Array} sequence - Target sequence.
248
+ * @return {Iterator}
249
+ */
250
+ Iterator.fromSequence = function (sequence) {
251
+ var i = 0,
252
+ l = sequence.length;
253
+
254
+ return new Iterator(function () {
255
+ if (i >= l) return {done: true};
256
+
257
+ return {done: false, value: sequence[i++]};
258
+ });
259
+ };
260
+
261
+ /**
262
+ * Returning whether the given value is an iterator.
263
+ *
264
+ * @param {any} value - Value.
265
+ * @return {boolean}
266
+ */
267
+ Iterator.is = function (value) {
268
+ if (value instanceof Iterator) return true;
269
+
270
+ return (
271
+ typeof value === 'object' &&
272
+ value !== null &&
273
+ typeof value.next === 'function'
274
+ );
275
+ };
276
+
277
+ /**
278
+ * Exporting.
279
+ */
280
+ iterator = Iterator;
281
+ return iterator;
282
+ }
283
+
284
+ var support = {};
285
+
286
+ var hasRequiredSupport;
287
+
288
+ function requireSupport () {
289
+ if (hasRequiredSupport) return support;
290
+ hasRequiredSupport = 1;
291
+ support.ARRAY_BUFFER_SUPPORT = typeof ArrayBuffer !== 'undefined';
292
+ support.SYMBOL_SUPPORT = typeof Symbol !== 'undefined';
293
+ return support;
294
+ }
295
+
296
+ /**
297
+ * Obliterator ForEach Function
298
+ * =============================
299
+ *
300
+ * Helper function used to easily iterate over mixed values.
301
+ */
302
+
303
+ var foreach;
304
+ var hasRequiredForeach;
305
+
306
+ function requireForeach () {
307
+ if (hasRequiredForeach) return foreach;
308
+ hasRequiredForeach = 1;
309
+ var support = requireSupport();
310
+
311
+ var ARRAY_BUFFER_SUPPORT = support.ARRAY_BUFFER_SUPPORT;
312
+ var SYMBOL_SUPPORT = support.SYMBOL_SUPPORT;
313
+
314
+ /**
315
+ * Function able to iterate over almost any iterable JS value.
316
+ *
317
+ * @param {any} iterable - Iterable value.
318
+ * @param {function} callback - Callback function.
319
+ */
320
+ foreach = function forEach(iterable, callback) {
321
+ var iterator, k, i, l, s;
322
+
323
+ if (!iterable) throw new Error('obliterator/forEach: invalid iterable.');
324
+
325
+ if (typeof callback !== 'function')
326
+ throw new Error('obliterator/forEach: expecting a callback.');
327
+
328
+ // The target is an array or a string or function arguments
329
+ if (
330
+ Array.isArray(iterable) ||
331
+ (ARRAY_BUFFER_SUPPORT && ArrayBuffer.isView(iterable)) ||
332
+ typeof iterable === 'string' ||
333
+ iterable.toString() === '[object Arguments]'
334
+ ) {
335
+ for (i = 0, l = iterable.length; i < l; i++) callback(iterable[i], i);
336
+ return;
337
+ }
338
+
339
+ // The target has a #.forEach method
340
+ if (typeof iterable.forEach === 'function') {
341
+ iterable.forEach(callback);
342
+ return;
343
+ }
344
+
345
+ // The target is iterable
346
+ if (
347
+ SYMBOL_SUPPORT &&
348
+ Symbol.iterator in iterable &&
349
+ typeof iterable.next !== 'function'
350
+ ) {
351
+ iterable = iterable[Symbol.iterator]();
352
+ }
353
+
354
+ // The target is an iterator
355
+ if (typeof iterable.next === 'function') {
356
+ iterator = iterable;
357
+ i = 0;
358
+
359
+ while (((s = iterator.next()), s.done !== true)) {
360
+ callback(s.value, i);
361
+ i++;
362
+ }
363
+
364
+ return;
365
+ }
366
+
367
+ // The target is a plain object
368
+ for (k in iterable) {
369
+ if (iterable.hasOwnProperty(k)) {
370
+ callback(iterable[k], k);
371
+ }
372
+ }
373
+
374
+ return;
375
+ };
376
+ return foreach;
377
+ }
378
+
379
+ /**
380
+ * Mnemonist Stack
381
+ * ================
382
+ *
383
+ * Stack implementation relying on JavaScript arrays, which are fast enough &
384
+ * correctly optimized for this kind of work.
385
+ */
386
+
387
+ var stack;
388
+ var hasRequiredStack;
389
+
390
+ function requireStack () {
391
+ if (hasRequiredStack) return stack;
392
+ hasRequiredStack = 1;
393
+ var Iterator = requireIterator(),
394
+ forEach = requireForeach();
395
+
396
+ /**
397
+ * Stack
398
+ *
399
+ * @constructor
400
+ */
401
+ function Stack() {
402
+ this.clear();
403
+ }
404
+
405
+ /**
406
+ * Method used to clear the stack.
407
+ *
408
+ * @return {undefined}
409
+ */
410
+ Stack.prototype.clear = function() {
411
+
412
+ // Properties
413
+ this.items = [];
414
+ this.size = 0;
415
+ };
416
+
417
+ /**
418
+ * Method used to add an item to the stack.
419
+ *
420
+ * @param {any} item - Item to add.
421
+ * @return {number}
422
+ */
423
+ Stack.prototype.push = function(item) {
424
+ this.items.push(item);
425
+ return ++this.size;
426
+ };
427
+
428
+ /**
429
+ * Method used to retrieve & remove the last item of the stack.
430
+ *
431
+ * @return {any}
432
+ */
433
+ Stack.prototype.pop = function() {
434
+ if (this.size === 0)
435
+ return;
436
+
437
+ this.size--;
438
+ return this.items.pop();
439
+ };
440
+
441
+ /**
442
+ * Method used to get the last item of the stack.
443
+ *
444
+ * @return {any}
445
+ */
446
+ Stack.prototype.peek = function() {
447
+ return this.items[this.size - 1];
448
+ };
449
+
450
+ /**
451
+ * Method used to iterate over the stack.
452
+ *
453
+ * @param {function} callback - Function to call for each item.
454
+ * @param {object} scope - Optional scope.
455
+ * @return {undefined}
456
+ */
457
+ Stack.prototype.forEach = function(callback, scope) {
458
+ scope = arguments.length > 1 ? scope : this;
459
+
460
+ for (var i = 0, l = this.items.length; i < l; i++)
461
+ callback.call(scope, this.items[l - i - 1], i, this);
462
+ };
463
+
464
+ /**
465
+ * Method used to convert the stack to a JavaScript array.
466
+ *
467
+ * @return {array}
468
+ */
469
+ Stack.prototype.toArray = function() {
470
+ var array = new Array(this.size),
471
+ l = this.size - 1,
472
+ i = this.size;
473
+
474
+ while (i--)
475
+ array[i] = this.items[l - i];
476
+
477
+ return array;
478
+ };
479
+
480
+ /**
481
+ * Method used to create an iterator over a stack's values.
482
+ *
483
+ * @return {Iterator}
484
+ */
485
+ Stack.prototype.values = function() {
486
+ var items = this.items,
487
+ l = items.length,
488
+ i = 0;
489
+
490
+ return new Iterator(function() {
491
+ if (i >= l)
492
+ return {
493
+ done: true
494
+ };
495
+
496
+ var value = items[l - i - 1];
497
+ i++;
498
+
499
+ return {
500
+ value: value,
501
+ done: false
502
+ };
503
+ });
504
+ };
505
+
506
+ /**
507
+ * Method used to create an iterator over a stack's entries.
508
+ *
509
+ * @return {Iterator}
510
+ */
511
+ Stack.prototype.entries = function() {
512
+ var items = this.items,
513
+ l = items.length,
514
+ i = 0;
515
+
516
+ return new Iterator(function() {
517
+ if (i >= l)
518
+ return {
519
+ done: true
520
+ };
521
+
522
+ var value = items[l - i - 1];
523
+
524
+ return {
525
+ value: [i++, value],
526
+ done: false
527
+ };
528
+ });
529
+ };
530
+
531
+ /**
532
+ * Attaching the #.values method to Symbol.iterator if possible.
533
+ */
534
+ if (typeof Symbol !== 'undefined')
535
+ Stack.prototype[Symbol.iterator] = Stack.prototype.values;
536
+
537
+
538
+ /**
539
+ * Convenience known methods.
540
+ */
541
+ Stack.prototype.toString = function() {
542
+ return this.toArray().join(',');
543
+ };
544
+
545
+ Stack.prototype.toJSON = function() {
546
+ return this.toArray();
547
+ };
548
+
549
+ Stack.prototype.inspect = function() {
550
+ var array = this.toArray();
551
+
552
+ // Trick so that node displays the name of the constructor
553
+ Object.defineProperty(array, 'constructor', {
554
+ value: Stack,
555
+ enumerable: false
556
+ });
557
+
558
+ return array;
559
+ };
560
+
561
+ if (typeof Symbol !== 'undefined')
562
+ Stack.prototype[Symbol.for('nodejs.util.inspect.custom')] = Stack.prototype.inspect;
563
+
564
+ /**
565
+ * Static @.from function taking an arbitrary iterable & converting it into
566
+ * a stack.
567
+ *
568
+ * @param {Iterable} iterable - Target iterable.
569
+ * @return {Stack}
570
+ */
571
+ Stack.from = function(iterable) {
572
+ var stack = new Stack();
573
+
574
+ forEach(iterable, function(value) {
575
+ stack.push(value);
576
+ });
577
+
578
+ return stack;
579
+ };
580
+
581
+ /**
582
+ * Static @.of function taking an arbitrary number of arguments & converting it
583
+ * into a stack.
584
+ *
585
+ * @param {...any} args
586
+ * @return {Stack}
587
+ */
588
+ Stack.of = function() {
589
+ return Stack.from(arguments);
590
+ };
591
+
592
+ /**
593
+ * Exporting.
594
+ */
595
+ stack = Stack;
596
+ return stack;
597
+ }
598
+
599
+ var stackExports = requireStack();
600
+ const Stack = /*@__PURE__*/getDefaultExportFromCjs(stackExports);
8
601
 
9
602
  function f(t,i){let o=i.length-t.length;if(o===1){let[n,...r]=i;return x(n,{lazy:t,lazyArgs:r})}if(o===0){let n={lazy:t,lazyArgs:i};return Object.assign(e=>x(e,n),n)}throw new Error("Wrong number of arguments")}
10
603
 
604
+ function r$3(...t){return u$6(Object.values,t)}
605
+
606
+ function d$5(...e){return e.length===2?(n,...r)=>t$5(n,...e,...r):t$5(...e)}var t$5=(e,n,r,...a)=>n(e,...a)?typeof r=="function"?r(e,...a):r.onTrue(e,...a):typeof r=="function"?e:r.onFalse(e,...a);
607
+
11
608
  function i$8(...e){return f(o$8,e)}function o$8(){let e=new Set;return t=>e.has(t)?s$1:(e.add(t),{done:!1,hasNext:!0,next:t})}
12
609
 
13
610
  function l$6(...e){return u$6(o$7,e,u$5)}var o$7=(e,r)=>r<0?[]:e.slice(0,r);function u$5(e){if(e<=0)return a$4;let r=e;return a=>(r-=1,{done:r<=0,hasNext:!0,next:a})}
@@ -22,50 +619,50 @@ function l$5(...e){return u$6(u$3,e)}var u$3=(e,a,n)=>e.reduce(a,n);
22
619
 
23
620
  function t$4(...e){return u$6(r$2,e)}function r$2(e){return [...e].reverse()}
24
621
 
25
- function i$7(...e){return u$6(o$5,e)}function o$5(e,n){let t={};for(let r of n)r in e&&(t[r]=e[r]);return t}
622
+ function p$1(...e){return u$6(t$3,e)}var t$3=(e,o)=>e[o];
26
623
 
27
- function d$3(...e){return u$6(i$6,e)}function i$6(e,o){let t={};for(let[r,n]of Object.entries(e))o(n,r,e)&&(t[r]=n);return t}
624
+ function d$3(...r){return u$6(i$7,r)}var i$7=(r,t)=>{let a=[[],[]];for(let[o,e]of r.entries())t(e,o,r)?a[0].push(e):a[1].push(e);return a};
28
625
 
29
- function i$5(...n){return o=>x(o,...n)}
626
+ function i$6(...e){return u$6(o$5,e)}function o$5(e,n){let t={};for(let r of n)r in e&&(t[r]=e[r]);return t}
30
627
 
31
- function p$1(...n){return u$6(t$3,n)}var t$3=(n,e)=>n[e];
628
+ function d$2(...e){return u$6(i$5,e)}function i$5(e,o){let t={};for(let[r,n]of Object.entries(e))o(n,r,e)&&(t[r]=n);return t}
32
629
 
33
- function d$2(...e){return u$6(l$4,e)}function l$4(e,a){let t={...e};for(let[n,o]of Object.entries(t))a(o,n,e)&&delete t[n];return t}
630
+ function i$4(...n){return o=>x(o,...n)}
631
+
632
+ function d$1(...e){return u$6(l$4,e)}function l$4(e,a){let t={...e};for(let[n,o]of Object.entries(t))a(o,n,e)&&delete t[n];return t}
34
633
 
35
634
  function t$2(...n){return u$6(o$4,n)}var o$4=n=>n.length===1?n[0]:void 0;
36
635
 
37
- function d$1(...r){return u$6(i$4,r)}var i$4=(r,t)=>{let a=[[],[]];for(let[o,e]of r.entries())t(e,o,r)?a[0].push(e):a[1].push(e);return a};
636
+ function i$3(...e){return u$6(o$3,e)}function o$3(e,r){let a={};for(let[n,u]of Object.entries(e)){let l=r(u,n,e);a[n]=l;}return a}
38
637
 
39
- function a$2(...e){return u$6(n$2,e)}var n$2=e=>e.at(-1);
638
+ function n$2(e){return !!e}
40
639
 
41
- function l$3(...n){return u$6(d,n)}function d(n,o){let e={};for(let[a,t]of n.entries()){let[y,u]=o(t,a,n);e[y]=u;}return e}
640
+ function a$2(...e){return u$6(n$1,e)}var n$1=e=>e.at(-1);
42
641
 
43
- function i$3(...e){return u$6(o$3,e)}function o$3(e,r){let a={};for(let[n,u]of Object.entries(e)){let l=r(u,n,e);a[n]=l;}return a}
44
-
45
- function n$1(e){return !!e}
642
+ function l$3(...n){return u$6(d,n)}function d(n,o){let e={};for(let[a,t]of n.entries()){let[y,u]=o(t,a,n);e[y]=u;}return e}
46
643
 
47
644
  function e$1(r){return typeof r=="number"&&!Number.isNaN(r)}
48
645
 
646
+ function n(e){return e===void 0?!0:typeof e=="string"||Array.isArray(e)?e.length===0:Object.keys(e).length===0}
647
+
49
648
  function e(o){return typeof o=="boolean"}
50
649
 
51
- function n(e){return e===void 0?!0:typeof e=="string"||Array.isArray(e)?e.length===0:Object.keys(e).length===0}
650
+ function i$2(...e){return u$6(p,e)}var p=(e,a)=>{let n={};for(let[d,t]of e.entries()){let y=a(t,d,e);if(y!==void 0){let{[y]:r}=n;r===void 0&&(r=[],n[y]=r),r.push(t);}}return n};
52
651
 
53
652
  function k(...n){return u$6(u$2,n)}function u$2(n,e){if(n===e||Object.is(n,e))return !0;if(typeof n!="object"||typeof e!="object"||n===null||e===null||Object.getPrototypeOf(n)!==Object.getPrototypeOf(e))return !1;if(Array.isArray(n))return l$2(n,e);if(n instanceof Map)return a$1(n,e);if(n instanceof Set)return c(n,e);if(n instanceof Date)return n.getTime()===e.getTime();if(n instanceof RegExp)return n.toString()===e.toString();if(Object.keys(n).length!==Object.keys(e).length)return !1;for(let[r,t]of Object.entries(n))if(!(r in e)||!u$2(t,e[r]))return !1;return !0}function l$2(n,e){if(n.length!==e.length)return !1;for(let[r,t]of n.entries())if(!u$2(t,e[r]))return !1;return !0}function a$1(n,e){if(n.size!==e.size)return !1;for(let[r,t]of n.entries())if(!e.has(r)||!u$2(t,e.get(r)))return !1;return !0}function c(n,e){if(n.size!==e.size)return !1;let r=[...e];for(let t of n){let o=!1;for(let[s,f]of r.entries())if(u$2(t,f)){o=!0,r.splice(s,1);break}if(!o)return !1}return !0}
54
653
 
55
654
  function u$1(...a){return u$6(o$2,a,l$1)}var o$2=(a,r)=>a.flatMap(r),l$1=a=>(r,t,y)=>{let n=a(r,t,y);return Array.isArray(n)?{done:!1,hasNext:!0,hasMany:!0,next:n}:{done:!1,hasNext:!0,next:n}};
56
655
 
57
- function u(...e){return u$6(o$1,e,i$2)}function o$1(e,r){return e.forEach(r),e}var i$2=e=>(r,n,t)=>(e(r,n,t),{done:!1,hasNext:!0,next:r});
656
+ function u(...e){return u$6(o$1,e,i$1)}function o$1(e,r){return e.forEach(r),e}var i$1=e=>(r,n,t)=>(e(r,n,t),{done:!1,hasNext:!0,next:r});
58
657
 
59
- function i$1(...e){return u$6(p,e)}var p=(e,a)=>{let n={};for(let[d,t]of e.entries()){let y=a(t,d,e);if(y!==void 0){let{[y]:r}=n;r===void 0&&(r=[],n[y]=r),r.push(t);}}return n};
658
+ function t$1(...r){return u$6(Object.entries,r)}
60
659
 
61
660
  function T(...a){return u$6(l,a,y)}var l=(a,e)=>a.filter(e),y=a=>(e,t,o)=>a(e,t,o)?{done:!1,hasNext:!0,next:e}:s$1;
62
661
 
63
- function o(...e){return u$6(t$1,e)}var t$1=(e,r)=>{for(let n=e.length-1;n>=0;n--){let a=e[n];if(r(a,n,e))return a}};
662
+ function o(...e){return u$6(t,e)}var t=(e,r)=>{for(let n=e.length-1;n>=0;n--){let a=e[n];if(r(a,n,e))return a}};
64
663
 
65
664
  function m(...e){return u$6(i,e)}function i(e,t){for(let[n,o]of e.entries())if(!t(o,n,e))return e.slice(n);return []}
66
665
 
67
- function t(...r){return u$6(Object.entries,r)}
68
-
69
666
  function a(...e){return u$6(r$1,e)}var r$1=(e,t)=>[...e,...t];
70
667
 
71
668
  function r(n){return ()=>n}
@@ -91,6 +688,9 @@ class ElementModel {
91
688
  get color() {
92
689
  return this.$element.color ?? DefaultThemeColor;
93
690
  }
691
+ get icon() {
692
+ return this.$element.icon ?? null;
693
+ }
94
694
  get tags() {
95
695
  return this.$element.tags ?? [];
96
696
  }
@@ -109,6 +709,9 @@ class ElementModel {
109
709
  get defaultView() {
110
710
  return this.scopedViews().next().value ?? null;
111
711
  }
712
+ get isRoot() {
713
+ return this.parent === null;
714
+ }
112
715
  isAncestorOf(another) {
113
716
  return isAncestor(this, another);
114
717
  }
@@ -235,37 +838,40 @@ class ElementModel {
235
838
  * @returns true if the element is deployed
236
839
  */
237
840
  isDeployed() {
238
- return n$1(this.deployments().next().value);
841
+ return n$2(this.deployments().next().value);
239
842
  }
240
843
  deployments() {
241
844
  return this.$model.deployment.instancesOf(this);
242
845
  }
243
846
  }
847
+ function isElementModel(element) {
848
+ return element instanceof ElementModel;
849
+ }
244
850
 
245
851
  function buildElementNotations(nodes) {
246
852
  return x(
247
853
  nodes,
248
- i$1(p$1("notation")),
854
+ i$2(p$1("notation")),
249
855
  i$3(
250
- i$5(
251
- i$1(p$1("shape")),
856
+ i$4(
857
+ i$2(p$1("shape")),
252
858
  i$3(
253
- i$5(
254
- i$1(p$1("color")),
859
+ i$4(
860
+ i$2(p$1("color")),
255
861
  i$3(
256
- i$5(
862
+ i$4(
257
863
  m$3(p$1("kind")),
258
864
  i$8()
259
865
  )
260
866
  ),
261
- t(),
867
+ t$1(),
262
868
  m$3(([color, kinds]) => ({
263
869
  kinds,
264
870
  color
265
871
  }))
266
872
  )
267
873
  ),
268
- t(),
874
+ t$1(),
269
875
  u$1(
270
876
  ([shape, colors]) => colors.map(({ color, kinds }) => ({
271
877
  shape,
@@ -275,7 +881,7 @@ function buildElementNotations(nodes) {
275
881
  )
276
882
  )
277
883
  ),
278
- t(),
884
+ t$1(),
279
885
  u$1(
280
886
  ([title, shapes]) => shapes.map(({ shape, color, kinds }) => ({
281
887
  title,
@@ -1362,7 +1968,7 @@ function topologicalSort(param) {
1362
1968
  // // [prop('sourceLevel'), 'asc'],
1363
1969
  // ),
1364
1970
  );
1365
- const [edgesBetweenLeafs, edgesWithCompounds] = d$1(
1971
+ const [edgesBetweenLeafs, edgesWithCompounds] = d$3(
1366
1972
  enrichedEdges,
1367
1973
  ({ source, target }) => source.children.length === 0 && target.children.length === 0
1368
1974
  );
@@ -1446,12 +2052,12 @@ function calcViewLayoutHash(view) {
1446
2052
  autoLayout: view.autoLayout,
1447
2053
  nodes: x(
1448
2054
  view.nodes,
1449
- m$3(i$7(["id", "title", "description", "technology", "shape", "icon", "children"])),
1450
- l$3(({ id, icon, ...node }) => [id, { ...node, icon: n$1(icon) ? "Y" : "N" }])
2055
+ m$3(i$6(["id", "title", "description", "technology", "shape", "icon", "children"])),
2056
+ l$3(({ id, icon, ...node }) => [id, { ...node, icon: n$2(icon) ? "Y" : "N" }])
1451
2057
  ),
1452
2058
  edges: x(
1453
2059
  view.edges,
1454
- m$3(i$7(["source", "target", "label", "description", "technology", "dir", "head", "tail", "line"])),
2060
+ m$3(i$6(["source", "target", "label", "description", "technology", "dir", "head", "tail", "line"])),
1455
2061
  l$3(({ source, target, ...edge }) => [`${source}:${target}`, edge])
1456
2062
  )
1457
2063
  };
@@ -1935,6 +2541,9 @@ class DeploymentRelationModel {
1935
2541
  }
1936
2542
  return;
1937
2543
  }
2544
+ isDeploymentRelation() {
2545
+ return true;
2546
+ }
1938
2547
  }
1939
2548
  class RelationshipsAccum {
1940
2549
  /**
@@ -2784,7 +3393,7 @@ class AbstractStageInclude {
2784
3393
  let state = this.precommit(this.memory.mutableState());
2785
3394
  let fromConnections = /* @__PURE__ */ new Set();
2786
3395
  if (this._connections.length > 0) {
2787
- const [fromKnown, rest] = d$1(
3396
+ const [fromKnown, rest] = d$3(
2788
3397
  this._connections,
2789
3398
  (c) => state.final.has(c.source)
2790
3399
  );
@@ -2875,12 +3484,12 @@ function findCrossBoundarySameSourceOrTarget(connections) {
2875
3484
  { group: `$source-${conn.source.id}`, conn },
2876
3485
  { group: `$target-${conn.target.id}`, conn }
2877
3486
  ]),
2878
- i$1(p$1("group")),
3487
+ i$2(p$1("group")),
2879
3488
  r$3(),
2880
3489
  T(i$9(2)),
2881
3490
  u(
2882
3491
  // In each group, sort by hierarchy, first are deepest
2883
- i$5(
3492
+ i$4(
2884
3493
  m$3(p$1("conn")),
2885
3494
  sortConnectionsByBoundaryHierarchy("desc"),
2886
3495
  // Drop first, as it is the deepest
@@ -3340,31 +3949,31 @@ function mergePropsFromRelationships(relations, prefer) {
3340
3949
  relations,
3341
3950
  l$5(
3342
3951
  (acc, r) => {
3343
- if (n$1(r.title) && !acc.title.includes(r.title)) {
3952
+ if (n$2(r.title) && !acc.title.includes(r.title)) {
3344
3953
  acc.title.push(r.title);
3345
3954
  }
3346
- if (n$1(r.description) && !acc.description.includes(r.description)) {
3955
+ if (n$2(r.description) && !acc.description.includes(r.description)) {
3347
3956
  acc.description.push(r.description);
3348
3957
  }
3349
- if (n$1(r.technology) && !acc.technology.includes(r.technology)) {
3958
+ if (n$2(r.technology) && !acc.technology.includes(r.technology)) {
3350
3959
  acc.technology.push(r.technology);
3351
3960
  }
3352
- if (n$1(r.kind) && !acc.kind.includes(r.kind)) {
3961
+ if (n$2(r.kind) && !acc.kind.includes(r.kind)) {
3353
3962
  acc.kind.push(r.kind);
3354
3963
  }
3355
- if (n$1(r.color) && !acc.color.includes(r.color)) {
3964
+ if (n$2(r.color) && !acc.color.includes(r.color)) {
3356
3965
  acc.color.push(r.color);
3357
3966
  }
3358
- if (n$1(r.line) && !acc.line.includes(r.line)) {
3967
+ if (n$2(r.line) && !acc.line.includes(r.line)) {
3359
3968
  acc.line.push(r.line);
3360
3969
  }
3361
- if (n$1(r.head) && !acc.head.includes(r.head)) {
3970
+ if (n$2(r.head) && !acc.head.includes(r.head)) {
3362
3971
  acc.head.push(r.head);
3363
3972
  }
3364
- if (n$1(r.tail) && !acc.tail.includes(r.tail)) {
3973
+ if (n$2(r.tail) && !acc.tail.includes(r.tail)) {
3365
3974
  acc.tail.push(r.tail);
3366
3975
  }
3367
- if (n$1(r.navigateTo) && !acc.navigateTo.includes(r.navigateTo)) {
3976
+ if (n$2(r.navigateTo) && !acc.navigateTo.includes(r.navigateTo)) {
3368
3977
  acc.navigateTo.push(r.navigateTo);
3369
3978
  }
3370
3979
  if (r.tags) {
@@ -3393,7 +4002,7 @@ function mergePropsFromRelationships(relations, prefer) {
3393
4002
  let technology = t$2(allprops.technology);
3394
4003
  let title = t$2(allprops.title) ?? (allprops.title.length > 1 ? "[...]" : null);
3395
4004
  const tags = i$8(allprops.tags);
3396
- let merged = d$3(
4005
+ let merged = d$2(
3397
4006
  {
3398
4007
  // If there is no title, but there is technology, use technology as title
3399
4008
  title: title ?? (technology ? `[${technology}]` : null),
@@ -3408,12 +4017,12 @@ function mergePropsFromRelationships(relations, prefer) {
3408
4017
  ...isNonEmptyArray(allprops.links) && { links: allprops.links },
3409
4018
  ...isNonEmptyArray(tags) && { tags }
3410
4019
  },
3411
- n$1
4020
+ n$2
3412
4021
  );
3413
4022
  if (prefer) {
3414
4023
  return {
3415
4024
  ...merged,
3416
- ...d$3(pickRelationshipProps(prefer), n$1)
4025
+ ...d$2(pickRelationshipProps(prefer), n$2)
3417
4026
  };
3418
4027
  }
3419
4028
  return merged;
@@ -3744,6 +4353,19 @@ function findConnectedElements(stage) {
3744
4353
  );
3745
4354
  }
3746
4355
 
4356
+ function isDeploymentNode(model) {
4357
+ return model.isDeploymentNode();
4358
+ }
4359
+ function isDeployedInstance(model) {
4360
+ return model.isInstance();
4361
+ }
4362
+ function isNestedElementOfDeployedInstanceModel(model) {
4363
+ return !model.isInstance() && !model.isDeploymentNode();
4364
+ }
4365
+ function isDeploymentElementModel(x) {
4366
+ return x instanceof DeploymentNodeModel || x instanceof DeployedInstanceModel;
4367
+ }
4368
+
3747
4369
  const OutgoingRelationPredicate = {
3748
4370
  include: ({ expr, model, memory, stage, where }) => {
3749
4371
  const targets = [...memory.elements];
@@ -3806,7 +4428,7 @@ const InOutRelationPredicate$1 = {
3806
4428
  if (FqnExpr.isWildcard(expr.inout)) {
3807
4429
  for (const source of sources) {
3808
4430
  const targets2 = [...resolveAscendingSiblings(source)];
3809
- const toInclude = matchConnections$1(findConnectionsBetween(source, targets2, "both"), where);
4431
+ const toInclude = matchConnections(findConnectionsBetween(source, targets2, "both"), where);
3810
4432
  stage.addConnections(toInclude);
3811
4433
  }
3812
4434
  return stage;
@@ -3814,7 +4436,7 @@ const InOutRelationPredicate$1 = {
3814
4436
  invariant(FqnExpr.isDeploymentRef(expr.inout), "Only deployment refs are supported in include");
3815
4437
  const targets = resolveElements$1(model, expr.inout);
3816
4438
  for (const source of sources) {
3817
- const toInclude = matchConnections$1(findConnectionsBetween(source, targets, "both"), where);
4439
+ const toInclude = matchConnections(findConnectionsBetween(source, targets, "both"), where);
3818
4440
  stage.addConnections(toInclude);
3819
4441
  }
3820
4442
  return stage;
@@ -3927,7 +4549,7 @@ function excludeModelRelations(relationsToExclude, { stage, memory }, where, fil
3927
4549
  }
3928
4550
  return stage.excludeConnections(toExclude);
3929
4551
  }
3930
- function matchConnection$1(c, where) {
4552
+ function matchConnection(c, where) {
3931
4553
  return applyPredicate(c, where).nonEmpty();
3932
4554
  }
3933
4555
  function applyPredicate(...args) {
@@ -3941,30 +4563,48 @@ function applyPredicate(...args) {
3941
4563
  if (o$a(c)) {
3942
4564
  return c.map((x) => applyPredicate(x, where)).filter((x) => x.nonEmpty());
3943
4565
  }
3944
- const map2 = toFilterableRelation$1(c.source, c.target);
3945
4566
  return c.update({
3946
- model: new Set([...c.relations.model.values()].filter((r) => where(map2(r)))),
3947
- deployment: new Set([...c.relations.deployment.values()].filter((r) => where(map2(r))))
4567
+ model: new Set([...c.relations.model.values()].filter((r) => where(toFilterableRelation(c)(r)))),
4568
+ deployment: new Set([...c.relations.deployment.values()].filter((r) => where(toFilterableRelation(c)(r))))
3948
4569
  });
3949
4570
  }
3950
- function matchConnections$1(connections, where) {
4571
+ function matchConnections(connections, where) {
3951
4572
  if (!where) {
3952
4573
  return connections;
3953
4574
  }
3954
4575
  return x(
3955
4576
  connections,
3956
- T((c) => matchConnection$1(c, where))
4577
+ T((c) => matchConnection(c, where))
3957
4578
  );
3958
4579
  }
3959
- function elementToFilterable$1(element) {
3960
- return i$7(element, ["tags", "kind"]);
4580
+ function toFilterable(relationEndpoint, connectionEndpoint) {
4581
+ if (isElementModel(relationEndpoint)) {
4582
+ const deployedInstance = isDeploymentElementModel(connectionEndpoint) && isDeployedInstance(connectionEndpoint) ? connectionEndpoint : null;
4583
+ return {
4584
+ kind: relationEndpoint.kind,
4585
+ tags: [...relationEndpoint.tags, ...deployedInstance?.tags ?? []]
4586
+ };
4587
+ }
4588
+ if (isNestedElementOfDeployedInstanceModel(relationEndpoint)) {
4589
+ return i$6(relationEndpoint.element, ["tags", "kind"]);
4590
+ }
4591
+ if (isDeployedInstance(relationEndpoint)) {
4592
+ return {
4593
+ kind: relationEndpoint.element.kind,
4594
+ tags: [...relationEndpoint.tags, ...relationEndpoint.element.tags]
4595
+ };
4596
+ }
4597
+ if (isDeploymentNode(relationEndpoint)) {
4598
+ return i$6(relationEndpoint, ["tags", "kind"]);
4599
+ }
4600
+ nonexhaustive(relationEndpoint);
3961
4601
  }
3962
- function toFilterableRelation$1(source, target) {
4602
+ function toFilterableRelation(c) {
3963
4603
  return (relation) => ({
3964
4604
  tags: relation.tags,
3965
4605
  kind: relation.kind,
3966
- source: elementToFilterable$1(source),
3967
- target: elementToFilterable$1(target)
4606
+ source: toFilterable(relation.source, c.source),
4607
+ target: toFilterable(relation.target, c.target)
3968
4608
  });
3969
4609
  }
3970
4610
 
@@ -4041,10 +4681,14 @@ const DirectRelationPredicate = {
4041
4681
  switch (true) {
4042
4682
  // * -> *
4043
4683
  case (sourceIsWildcard && targetIsWildcard): {
4044
- connections = findConnectionsWithin(model.instances()).map((c) => {
4045
- stage.addImplicit(c.boundary);
4046
- return c;
4047
- });
4684
+ connections = x(
4685
+ findConnectionsWithin(model.instances()),
4686
+ applyPredicate(where),
4687
+ m$3((c) => {
4688
+ stage.addImplicit(c.boundary);
4689
+ return c;
4690
+ })
4691
+ );
4048
4692
  break;
4049
4693
  }
4050
4694
  // source -> *; source <-> *
@@ -4056,10 +4700,15 @@ const DirectRelationPredicate = {
4056
4700
  const isTarget = filterIncomingConnections(sources);
4057
4701
  postFilter = (c) => isSource(c) !== isTarget(c);
4058
4702
  }
4059
- connections = sources.flatMap((source2) => {
4060
- const targets = resolveAscendingSiblings(source2);
4061
- return findConnectionsBetween(source2, targets, dir);
4062
- }).filter(postFilter);
4703
+ connections = x(
4704
+ sources,
4705
+ u$1((source2) => {
4706
+ const targets = resolveAscendingSiblings(source2);
4707
+ return findConnectionsBetween(source2, targets, dir);
4708
+ }),
4709
+ T(postFilter),
4710
+ applyPredicate(where)
4711
+ );
4063
4712
  break;
4064
4713
  }
4065
4714
  // * -> target; * <-> target
@@ -4071,10 +4720,15 @@ const DirectRelationPredicate = {
4071
4720
  const isSource = filterOutgoingConnections(targets);
4072
4721
  postFilter = (c) => isSource(c) !== isTarget(c);
4073
4722
  }
4074
- connections = targets.flatMap((target2) => {
4075
- const sources = resolveAscendingSiblings(target2);
4076
- return [...sources].flatMap((source2) => findConnection(source2, target2, dir));
4077
- }).filter(postFilter);
4723
+ connections = x(
4724
+ targets,
4725
+ u$1((target2) => {
4726
+ const sources = resolveAscendingSiblings(target2);
4727
+ return [...sources].flatMap((source2) => findConnection(source2, target2, dir));
4728
+ }),
4729
+ T(postFilter),
4730
+ applyPredicate(where)
4731
+ );
4078
4732
  break;
4079
4733
  }
4080
4734
  default: {
@@ -4086,8 +4740,9 @@ const DirectRelationPredicate = {
4086
4740
  const isTarget = filterIncomingConnections(targets);
4087
4741
  connections = x(
4088
4742
  sources,
4089
- u$1((s) => matchConnections(findConnectionsBetween(s, targets, dir), where)),
4090
- T((c) => isSource(c) && isTarget(c))
4743
+ u$1((s) => findConnectionsBetween(s, targets, dir)),
4744
+ T((c) => isSource(c) && isTarget(c)),
4745
+ applyPredicate(where)
4091
4746
  );
4092
4747
  }
4093
4748
  }
@@ -4107,7 +4762,7 @@ const DirectRelationPredicate = {
4107
4762
  switch (true) {
4108
4763
  // * -> *
4109
4764
  case (FqnExpr.isWildcard(expr.source) && FqnExpr.isWildcard(expr.target)):
4110
- stage.excludeConnections(matchConnections(memory.connections, where));
4765
+ stage.excludeConnections(applyPredicate(memory.connections, where));
4111
4766
  return stage;
4112
4767
  // model -> model
4113
4768
  case (FqnExpr.isModelRef(expr.source) && FqnExpr.isModelRef(expr.target)):
@@ -4155,52 +4810,23 @@ const DirectRelationPredicate = {
4155
4810
  }
4156
4811
  stage.excludeConnections(deploymentRelationsToExclude);
4157
4812
  return stage;
4158
- }
4159
- }
4160
- };
4161
- function resolveRelationsBetweenModelElements({
4162
- source,
4163
- target,
4164
- expr,
4165
- model
4166
- }) {
4167
- const sources = resolveModelElements(model, source);
4168
- const targets = resolveModelElements(model, target);
4169
- const dir = expr.isBidirectional ? "both" : "directed";
4170
- const modelConnections = [];
4171
- for (const source2 of sources) {
4172
- modelConnections.push(...findConnectionsBetween$1(source2, targets, dir));
4173
- }
4174
- return new Set(modelConnections.flatMap((c) => [...c.relations]));
4175
- }
4176
- function elementToFilterable(element) {
4177
- return i$7(element, ["tags", "kind"]);
4178
- }
4179
- function toFilterableRelation(source, target) {
4180
- return (relation) => ({
4181
- tags: relation.tags,
4182
- kind: relation.kind,
4183
- source: elementToFilterable(source),
4184
- target: elementToFilterable(target)
4185
- });
4186
- }
4187
- function matchConnection(c, where) {
4188
- if (!where) {
4189
- return true;
4190
- }
4191
- return [
4192
- ...Array.from(c.relations.deployment.values()).map(toFilterableRelation(c.source, c.target)),
4193
- ...Array.from(c.relations.model.values()).map(toFilterableRelation(c.source, c.target))
4194
- ].filter(where).length > 0;
4195
- }
4196
- function matchConnections(connections, where) {
4197
- if (!where) {
4198
- return connections;
4813
+ }
4199
4814
  }
4200
- return x(
4201
- connections,
4202
- T((c) => matchConnection(c, where))
4203
- );
4815
+ };
4816
+ function resolveRelationsBetweenModelElements({
4817
+ source,
4818
+ target,
4819
+ expr,
4820
+ model
4821
+ }) {
4822
+ const sources = resolveModelElements(model, source);
4823
+ const targets = resolveModelElements(model, target);
4824
+ const dir = expr.isBidirectional ? "both" : "directed";
4825
+ const modelConnections = [];
4826
+ for (const source2 of sources) {
4827
+ modelConnections.push(...findConnectionsBetween$1(source2, targets, dir));
4828
+ }
4829
+ return new Set(modelConnections.flatMap((c) => [...c.relations]));
4204
4830
  }
4205
4831
 
4206
4832
  let StageFinal$1 = class StageFinal {
@@ -4451,7 +5077,7 @@ function applyCustomElementProperties(_rules, _nodes) {
4451
5077
  for (const {
4452
5078
  custom: { expr, ...props }
4453
5079
  } of rules) {
4454
- const { border, opacity, ...rest } = d$2(props, n$4);
5080
+ const { border, opacity, ...rest } = d$1(props, n$4);
4455
5081
  const notEmpty = !n(rest);
4456
5082
  const satisfies = elementExprToPredicate(expr);
4457
5083
  nodes.forEach((node, i) => {
@@ -4561,7 +5187,7 @@ class DynamicViewCompute {
4561
5187
  line,
4562
5188
  notation
4563
5189
  } = this.findRelations(source, target);
4564
- const navigateTo = n$1(stepNavigateTo) && stepNavigateTo !== this.view.id ? stepNavigateTo : derivedNavigateTo;
5190
+ const navigateTo = n$2(stepNavigateTo) && stepNavigateTo !== this.view.id ? stepNavigateTo : derivedNavigateTo;
4565
5191
  this.steps.push({
4566
5192
  id,
4567
5193
  ...step,
@@ -4705,7 +5331,7 @@ class DynamicViewCompute {
4705
5331
  const alltags = x(
4706
5332
  relationships,
4707
5333
  u$1((r) => r.tags),
4708
- T(n$1),
5334
+ T(n$2),
4709
5335
  i$8()
4710
5336
  );
4711
5337
  const tags = i$9(alltags, 1) ? alltags : null;
@@ -4715,7 +5341,7 @@ class DynamicViewCompute {
4715
5341
  const navigateTo = relationNavigateTo && relationNavigateTo !== this.view.id ? relationNavigateTo : x(
4716
5342
  relationships,
4717
5343
  m$3((r) => r.$relationship.navigateTo),
4718
- T(n$1),
5344
+ T(n$2),
4719
5345
  T((v) => v !== this.view.id),
4720
5346
  i$8(),
4721
5347
  t$2()
@@ -4723,11 +5349,11 @@ class DynamicViewCompute {
4723
5349
  const commonProperties = x(
4724
5350
  relationships,
4725
5351
  l$5((acc, { title, $relationship: r }) => {
4726
- n$1(title) && acc.title.add(title);
4727
- n$1(r.tail) && acc.tail.add(r.tail);
4728
- n$1(r.head) && acc.head.add(r.head);
4729
- n$1(r.color) && acc.color.add(r.color);
4730
- n$1(r.line) && acc.line.add(r.line);
5352
+ n$2(title) && acc.title.add(title);
5353
+ n$2(r.tail) && acc.tail.add(r.tail);
5354
+ n$2(r.head) && acc.head.add(r.head);
5355
+ n$2(r.color) && acc.color.add(r.color);
5356
+ n$2(r.line) && acc.line.add(r.line);
4731
5357
  return acc;
4732
5358
  }, {
4733
5359
  tail: /* @__PURE__ */ new Set(),
@@ -4760,7 +5386,12 @@ function relationExpressionToPredicates(expr) {
4760
5386
  case isRelationWhere(expr): {
4761
5387
  const predicate = relationExpressionToPredicates(expr.where.expr);
4762
5388
  const where = whereOperatorAsPredicate(expr.where.condition);
4763
- return (e) => predicate(e) && where(e);
5389
+ return (e) => predicate(e) && where({
5390
+ source: { tags: e.source.tags, kind: e.source.kind },
5391
+ target: { tags: e.target.tags, kind: e.target.kind },
5392
+ ...e.tags && { tags: e.tags },
5393
+ ...e.kind && { kind: e.kind }
5394
+ });
4764
5395
  }
4765
5396
  case isRelation(expr): {
4766
5397
  const isSource = elementExprToPredicate(expr.source);
@@ -4795,7 +5426,7 @@ function applyCustomRelationProperties(_rules, nodes, _edges) {
4795
5426
  for (const {
4796
5427
  customRelation: { relation, title, ...customprops }
4797
5428
  } of rules) {
4798
- const props = d$2(customprops, n$4);
5429
+ const props = d$1(customprops, n$4);
4799
5430
  const satisfies = relationExpressionToPredicates(relation);
4800
5431
  edges.forEach((edge, i) => {
4801
5432
  const source = nodes.find((n) => n.id === edge.source);
@@ -4803,7 +5434,7 @@ function applyCustomRelationProperties(_rules, nodes, _edges) {
4803
5434
  if (!source || !target) {
4804
5435
  return;
4805
5436
  }
4806
- if (satisfies({ source, target, ...i$7(edge, ["kind", "tags"]) })) {
5437
+ if (satisfies({ source, target, ...i$6(edge, ["kind", "tags"]) })) {
4807
5438
  edges[i] = {
4808
5439
  ...edge,
4809
5440
  ...props,
@@ -4816,229 +5447,6 @@ function applyCustomRelationProperties(_rules, nodes, _edges) {
4816
5447
  return edges;
4817
5448
  }
4818
5449
 
4819
- /**
4820
- * Mnemonist Stack
4821
- * ================
4822
- *
4823
- * Stack implementation relying on JavaScript arrays, which are fast enough &
4824
- * correctly optimized for this kind of work.
4825
- */
4826
-
4827
- var stack;
4828
- var hasRequiredStack;
4829
-
4830
- function requireStack () {
4831
- if (hasRequiredStack) return stack;
4832
- hasRequiredStack = 1;
4833
- var Iterator = requireIterator(),
4834
- forEach = requireForeach();
4835
-
4836
- /**
4837
- * Stack
4838
- *
4839
- * @constructor
4840
- */
4841
- function Stack() {
4842
- this.clear();
4843
- }
4844
-
4845
- /**
4846
- * Method used to clear the stack.
4847
- *
4848
- * @return {undefined}
4849
- */
4850
- Stack.prototype.clear = function() {
4851
-
4852
- // Properties
4853
- this.items = [];
4854
- this.size = 0;
4855
- };
4856
-
4857
- /**
4858
- * Method used to add an item to the stack.
4859
- *
4860
- * @param {any} item - Item to add.
4861
- * @return {number}
4862
- */
4863
- Stack.prototype.push = function(item) {
4864
- this.items.push(item);
4865
- return ++this.size;
4866
- };
4867
-
4868
- /**
4869
- * Method used to retrieve & remove the last item of the stack.
4870
- *
4871
- * @return {any}
4872
- */
4873
- Stack.prototype.pop = function() {
4874
- if (this.size === 0)
4875
- return;
4876
-
4877
- this.size--;
4878
- return this.items.pop();
4879
- };
4880
-
4881
- /**
4882
- * Method used to get the last item of the stack.
4883
- *
4884
- * @return {any}
4885
- */
4886
- Stack.prototype.peek = function() {
4887
- return this.items[this.size - 1];
4888
- };
4889
-
4890
- /**
4891
- * Method used to iterate over the stack.
4892
- *
4893
- * @param {function} callback - Function to call for each item.
4894
- * @param {object} scope - Optional scope.
4895
- * @return {undefined}
4896
- */
4897
- Stack.prototype.forEach = function(callback, scope) {
4898
- scope = arguments.length > 1 ? scope : this;
4899
-
4900
- for (var i = 0, l = this.items.length; i < l; i++)
4901
- callback.call(scope, this.items[l - i - 1], i, this);
4902
- };
4903
-
4904
- /**
4905
- * Method used to convert the stack to a JavaScript array.
4906
- *
4907
- * @return {array}
4908
- */
4909
- Stack.prototype.toArray = function() {
4910
- var array = new Array(this.size),
4911
- l = this.size - 1,
4912
- i = this.size;
4913
-
4914
- while (i--)
4915
- array[i] = this.items[l - i];
4916
-
4917
- return array;
4918
- };
4919
-
4920
- /**
4921
- * Method used to create an iterator over a stack's values.
4922
- *
4923
- * @return {Iterator}
4924
- */
4925
- Stack.prototype.values = function() {
4926
- var items = this.items,
4927
- l = items.length,
4928
- i = 0;
4929
-
4930
- return new Iterator(function() {
4931
- if (i >= l)
4932
- return {
4933
- done: true
4934
- };
4935
-
4936
- var value = items[l - i - 1];
4937
- i++;
4938
-
4939
- return {
4940
- value: value,
4941
- done: false
4942
- };
4943
- });
4944
- };
4945
-
4946
- /**
4947
- * Method used to create an iterator over a stack's entries.
4948
- *
4949
- * @return {Iterator}
4950
- */
4951
- Stack.prototype.entries = function() {
4952
- var items = this.items,
4953
- l = items.length,
4954
- i = 0;
4955
-
4956
- return new Iterator(function() {
4957
- if (i >= l)
4958
- return {
4959
- done: true
4960
- };
4961
-
4962
- var value = items[l - i - 1];
4963
-
4964
- return {
4965
- value: [i++, value],
4966
- done: false
4967
- };
4968
- });
4969
- };
4970
-
4971
- /**
4972
- * Attaching the #.values method to Symbol.iterator if possible.
4973
- */
4974
- if (typeof Symbol !== 'undefined')
4975
- Stack.prototype[Symbol.iterator] = Stack.prototype.values;
4976
-
4977
-
4978
- /**
4979
- * Convenience known methods.
4980
- */
4981
- Stack.prototype.toString = function() {
4982
- return this.toArray().join(',');
4983
- };
4984
-
4985
- Stack.prototype.toJSON = function() {
4986
- return this.toArray();
4987
- };
4988
-
4989
- Stack.prototype.inspect = function() {
4990
- var array = this.toArray();
4991
-
4992
- // Trick so that node displays the name of the constructor
4993
- Object.defineProperty(array, 'constructor', {
4994
- value: Stack,
4995
- enumerable: false
4996
- });
4997
-
4998
- return array;
4999
- };
5000
-
5001
- if (typeof Symbol !== 'undefined')
5002
- Stack.prototype[Symbol.for('nodejs.util.inspect.custom')] = Stack.prototype.inspect;
5003
-
5004
- /**
5005
- * Static @.from function taking an arbitrary iterable & converting it into
5006
- * a stack.
5007
- *
5008
- * @param {Iterable} iterable - Target iterable.
5009
- * @return {Stack}
5010
- */
5011
- Stack.from = function(iterable) {
5012
- var stack = new Stack();
5013
-
5014
- forEach(iterable, function(value) {
5015
- stack.push(value);
5016
- });
5017
-
5018
- return stack;
5019
- };
5020
-
5021
- /**
5022
- * Static @.of function taking an arbitrary number of arguments & converting it
5023
- * into a stack.
5024
- *
5025
- * @param {...any} args
5026
- * @return {Stack}
5027
- */
5028
- Stack.of = function() {
5029
- return Stack.from(arguments);
5030
- };
5031
-
5032
- /**
5033
- * Exporting.
5034
- */
5035
- stack = Stack;
5036
- return stack;
5037
- }
5038
-
5039
- var stackExports = requireStack();
5040
- const Stack = /*@__PURE__*/getDefaultExportFromCjs(stackExports);
5041
-
5042
5450
  class NodesGroup {
5043
5451
  constructor(id, viewRule, parent = null, elements = /* @__PURE__ */ new Set()) {
5044
5452
  this.id = id;
@@ -5609,7 +6017,11 @@ function toComputedEdges(connections) {
5609
6017
  ...props
5610
6018
  } = mergePropsFromRelationships(
5611
6019
  relations.map((r) => r.$relationship),
5612
- relations.find((r) => r.source.id === source && r.target.id === target)?.$relationship
6020
+ // Prefer only single relationship
6021
+ // https://github.com/likec4/likec4/issues/1423
6022
+ t$2(
6023
+ T(relations, (r) => r.source.id === source && r.target.id === target)
6024
+ )?.$relationship
5613
6025
  );
5614
6026
  const edge = {
5615
6027
  id: e.id,
@@ -5677,7 +6089,7 @@ const DirectRelationExprPredicate = {
5677
6089
  ifilter(where),
5678
6090
  iunique(),
5679
6091
  toArray(),
5680
- d$1((r) => r.source === source2),
6092
+ d$3((r) => r.source === source2),
5681
6093
  ([outgoing, incoming]) => a(
5682
6094
  x(
5683
6095
  outgoing,
@@ -5732,7 +6144,7 @@ const DirectRelationExprPredicate = {
5732
6144
  }),
5733
6145
  ifilter(where),
5734
6146
  toArray(),
5735
- d$1((r) => r.target === target2),
6147
+ d$3((r) => r.target === target2),
5736
6148
  ([incoming, outgoing]) => a(
5737
6149
  x(
5738
6150
  outgoing,
@@ -5799,7 +6211,7 @@ const DirectRelationExprPredicate = {
5799
6211
  case (sourceIsWildcard && targetIsWildcard): {
5800
6212
  relations = x(
5801
6213
  memory.connections,
5802
- u$1(i$5(
6214
+ u$1(i$4(
5803
6215
  p$1("relations"),
5804
6216
  ifilter(where),
5805
6217
  toArray()
@@ -6856,6 +7268,9 @@ class RelationshipModel {
6856
7268
  }
6857
7269
  return;
6858
7270
  }
7271
+ isDeploymentRelation() {
7272
+ return false;
7273
+ }
6859
7274
  }
6860
7275
 
6861
7276
  class EdgeModel {
@@ -6950,6 +7365,9 @@ class NodeModel {
6950
7365
  get color() {
6951
7366
  return this.$node.color;
6952
7367
  }
7368
+ get icon() {
7369
+ return this.$node.icon ?? null;
7370
+ }
6953
7371
  get tags() {
6954
7372
  return this.$node.tags ?? [];
6955
7373
  }
@@ -7166,6 +7584,10 @@ class LikeC4ViewModel {
7166
7584
  findNode(node) {
7167
7585
  return this.#nodes.get(getId(node)) ?? null;
7168
7586
  }
7587
+ findNodeWithElement(fqn) {
7588
+ const nd = ifind(this.#nodes.values(), (node) => node.element?.id === fqn) ?? null;
7589
+ return nd && nd.hasElement() ? nd : null;
7590
+ }
7169
7591
  /**
7170
7592
  * Iterate over all nodes.
7171
7593
  */
@@ -7405,7 +7827,7 @@ class LikeC4Model {
7405
7827
  return nonNullable(this.#views.get(viewId), `View ${viewId} not found`);
7406
7828
  }
7407
7829
  findView(viewId) {
7408
- return nonNullable(this.#views.get(viewId), `View ${viewId} not found`);
7830
+ return this.#views.get(viewId) ?? null;
7409
7831
  }
7410
7832
  /**
7411
7833
  * Returns the parent element of given element.
@@ -7557,11 +7979,4 @@ class LikeC4Model {
7557
7979
  }
7558
7980
  }
7559
7981
 
7560
- function isDeploymentNode(model) {
7561
- return model.isDeploymentNode();
7562
- }
7563
- function isDeployedInstance(model) {
7564
- return model.isInstance();
7565
- }
7566
-
7567
- export { sortConnectionsByBoundaryHierarchy as A, sortDeepestFirst as B, Connection as C, DeploymentConnectionModel as D, ElementModel as E, DeployedInstanceModel as F, Graph as G, DeploymentNodeModel as H, DeploymentRelationModel as I, EdgeModel as J, isDeployedInstance as K, LikeC4Model as L, isDeploymentNode as M, NodeModel as N, RelationshipModel as R, computeViews as a, LikeC4DeploymentModel as b, computeView as c, d$3 as d, LikeC4ViewModel as e, ConnectionModel as f, find as g, differenceConnections as h, i$3 as i, findAscendingConnections as j, findDeepestNestedConnection as k, l$3 as l, findDescendantConnections as m, hasSameSource as n, hasSameSourceTarget as o, hasSameTarget as p, isAnyInOut as q, r$3 as r, isIncoming as s, topologicalSortExports as t, unsafeComputeView as u, isNestedConnection as v, willCreateCycle as w, isOutgoing as x, mergeConnections as y, find$1 as z };
7982
+ export { isOutgoing as A, mergeConnections as B, Connection as C, DefaultMap as D, ElementModel as E, find$1 as F, Graph as G, sortConnectionsByBoundaryHierarchy as H, sortDeepestFirst as I, DeployedInstanceModel as J, DeploymentNodeModel as K, LikeC4Model as L, DeploymentRelationModel as M, EdgeModel as N, NodeModel as O, isDeployedInstance as P, isDeploymentNode as Q, RelationshipModel as R, Stack as S, computeViews as a, requireIterator as b, computeView as c, d$2 as d, requireForeach as e, LikeC4DeploymentModel as f, LikeC4ViewModel as g, ConnectionModel as h, i$3 as i, find as j, DeploymentConnectionModel as k, l$3 as l, differenceConnections as m, findAscendingConnections as n, findDeepestNestedConnection as o, findDescendantConnections as p, hasSameSource as q, r$3 as r, hasSameSourceTarget as s, topologicalSortExports as t, unsafeComputeView as u, hasSameTarget as v, willCreateCycle as w, isAnyInOut as x, isIncoming as y, isNestedConnection as z };