@likec4/core 1.43.0 → 1.45.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.
Files changed (72) hide show
  1. package/dist/builder/index.d.mts +15 -14
  2. package/dist/builder/index.mjs +35 -18
  3. package/dist/compute-view/index.d.mts +9 -9
  4. package/dist/compute-view/index.mjs +8 -7
  5. package/dist/compute-view/relationships-view/index.d.mts +7 -7
  6. package/dist/compute-view/relationships-view/index.mjs +2 -2
  7. package/dist/index.d.mts +27 -7
  8. package/dist/index.mjs +8 -7
  9. package/dist/model/connection/deployment/index.d.mts +9 -9
  10. package/dist/model/connection/deployment/index.mjs +2 -2
  11. package/dist/model/connection/index.d.mts +10 -10
  12. package/dist/model/connection/index.mjs +3 -3
  13. package/dist/model/connection/model/index.d.mts +9 -9
  14. package/dist/model/connection/model/index.mjs +2 -2
  15. package/dist/model/index.d.mts +11 -11
  16. package/dist/model/index.mjs +4 -4
  17. package/dist/shared/{core.CDvVInBp.d.mts → core.0zAQeenX.d.mts} +3 -3
  18. package/dist/shared/core.3ZhnKAlZ.mjs +106 -0
  19. package/dist/shared/{core.CwsG7hOw.d.mts → core.5ZQ-r3Oa.d.mts} +1 -1
  20. package/dist/shared/{core.hNWo20Ym.d.mts → core.B73yxfPi.d.mts} +55 -36
  21. package/dist/shared/{core.Cq2kxOI-.d.mts → core.BGFjN3nv.d.mts} +3 -3
  22. package/dist/shared/{core.rCeaAqgW.mjs → core.BdPcbSkN.mjs} +1 -1
  23. package/dist/shared/core.BhNcrwzK.mjs +7 -0
  24. package/dist/shared/core.BkVA6gjl.mjs +5 -0
  25. package/dist/shared/core.BuQZczj6.mjs +38 -0
  26. package/dist/shared/{core.2N_9BzyD.mjs → core.CQPEY2wQ.mjs} +5 -4
  27. package/dist/shared/{core.DFi2dOTl.mjs → core.CR3PmPzr.mjs} +85 -1
  28. package/dist/shared/{core.DyToofsP.mjs → core.CRI1AjFj.mjs} +276 -145
  29. package/dist/shared/{core.CXWsKEDr.mjs → core.CWwSgOzF.mjs} +268 -631
  30. package/dist/shared/{core.727Qoh_W.mjs → core.CdNCAwq7.mjs} +2 -101
  31. package/dist/shared/{core.QJD_fcrc.mjs → core.CmPXpJ8l.mjs} +1 -14
  32. package/dist/shared/{core.DTdfiejA.d.mts → core.Cog93roC.d.mts} +2 -2
  33. package/dist/shared/core.Coi_LOUZ.mjs +7 -0
  34. package/dist/shared/{core.CcJ1FZ7h.d.mts → core.CpURdWRM.d.mts} +174 -76
  35. package/dist/shared/{core.D5fzJWbF.d.mts → core.DB0Ue5Wx.d.mts} +1 -1
  36. package/dist/shared/{core.DNbUPnve.mjs → core.DEieYfbG.mjs} +27 -25
  37. package/dist/shared/{core.BYNkXQ8A.mjs → core.DH7TXqXf.mjs} +30 -1
  38. package/dist/shared/{core.DMMOWQqc.mjs → core.DIE3F6sw.mjs} +2 -2
  39. package/dist/shared/{core.D0NziuvN.mjs → core.DViDmiAu.mjs} +5 -5
  40. package/dist/shared/{core.Be05qJwN.mjs → core.D_f4F48-.mjs} +41 -18
  41. package/dist/shared/{core.C2TiyjI6.mjs → core.DbfO90vF.mjs} +20 -31
  42. package/dist/shared/{core.BT-9gaqQ.d.mts → core.DnCLhN8C.d.mts} +83 -94
  43. package/dist/shared/{core.BouyJs63.mjs → core.DqlrMlsf.mjs} +1 -1
  44. package/dist/shared/{core.CNgZvKb8.mjs → core.DrUt0Lbi.mjs} +1 -1
  45. package/dist/shared/{core.CT1xBp4R.d.mts → core.Dvh1H0T2.d.mts} +2 -2
  46. package/dist/shared/core.M9ayqQZa.mjs +1207 -0
  47. package/dist/shared/{core.CvLjw3bH.d.mts → core.mUnpvHtA.d.mts} +96 -12
  48. package/dist/shared/core.oSV6SRfk.mjs +13 -0
  49. package/dist/shared/core.q10OP9oJ.mjs +5 -0
  50. package/dist/shared/{core.BXs4wY7R.d.mts → core.t3qfsVvn.d.mts} +4 -4
  51. package/dist/shared/core.uFk_o9X6.mjs +13 -0
  52. package/dist/shared/core.vzLtp8i3.mjs +1282 -0
  53. package/dist/styles/index.d.mts +18 -8
  54. package/dist/styles/index.mjs +63 -1
  55. package/dist/types/_aux.d.mts +2 -2
  56. package/dist/types/_aux.mjs +8 -1
  57. package/dist/types/expression-model.d.mts +3 -3
  58. package/dist/types/expression.d.mts +3 -3
  59. package/dist/types/fqnRef.d.mts +7 -8
  60. package/dist/types/index.d.mts +17 -13
  61. package/dist/types/index.mjs +51 -14
  62. package/dist/utils/graphology/index.mjs +1 -1
  63. package/dist/utils/index.d.mts +3 -2
  64. package/dist/utils/index.mjs +9 -6
  65. package/dist/utils/iterable/index.d.mts +1 -1
  66. package/dist/utils/iterable/index.mjs +2 -1
  67. package/package.json +18 -17
  68. package/dist/shared/core.01VTr9qu.mjs +0 -170
  69. package/dist/shared/core.1vX5a9AY.mjs +0 -86
  70. package/dist/shared/core.BazD6cot.mjs +0 -14
  71. package/dist/shared/core.BzTakU3I.mjs +0 -67
  72. package/dist/shared/core.OHD4KXm9.mjs +0 -5
@@ -0,0 +1,1207 @@
1
+ import { t as t$1 } from './core.BsSXS-_R.mjs';
2
+ import { g as getDefaultExportFromCjs } from './core.B85MJLTf.mjs';
3
+ import { r as requireIterator } from './core.BdPcbSkN.mjs';
4
+ import { r as requireForeach, a as markdownToText, m as markdownToHtml } from './core.CR3PmPzr.mjs';
5
+ import { m as memoizeProp } from './core.BR4zXDH-.mjs';
6
+ import { n as nonexhaustive } from './core.D4npX2q8.mjs';
7
+
8
+ function t(...t){return t$1(n,t)}function n(e,t){let n={...e};for(let[r,i]of Object.entries(n))t(i,r,e)&&delete n[r];return n}
9
+
10
+ var typedArrays = {};
11
+
12
+ /**
13
+ * Mnemonist Typed Array Helpers
14
+ * ==============================
15
+ *
16
+ * Miscellaneous helpers related to typed arrays.
17
+ */
18
+
19
+ var hasRequiredTypedArrays;
20
+
21
+ function requireTypedArrays () {
22
+ if (hasRequiredTypedArrays) return typedArrays;
23
+ hasRequiredTypedArrays = 1;
24
+ (function (exports$1) {
25
+ /**
26
+ * When using an unsigned integer array to store pointers, one might want to
27
+ * choose the optimal word size in regards to the actual numbers of pointers
28
+ * to store.
29
+ *
30
+ * This helpers does just that.
31
+ *
32
+ * @param {number} size - Expected size of the array to map.
33
+ * @return {TypedArray}
34
+ */
35
+ var MAX_8BIT_INTEGER = Math.pow(2, 8) - 1,
36
+ MAX_16BIT_INTEGER = Math.pow(2, 16) - 1,
37
+ MAX_32BIT_INTEGER = Math.pow(2, 32) - 1;
38
+
39
+ var MAX_SIGNED_8BIT_INTEGER = Math.pow(2, 7) - 1,
40
+ MAX_SIGNED_16BIT_INTEGER = Math.pow(2, 15) - 1,
41
+ MAX_SIGNED_32BIT_INTEGER = Math.pow(2, 31) - 1;
42
+
43
+ exports$1.getPointerArray = function(size) {
44
+ var maxIndex = size - 1;
45
+
46
+ if (maxIndex <= MAX_8BIT_INTEGER)
47
+ return Uint8Array;
48
+
49
+ if (maxIndex <= MAX_16BIT_INTEGER)
50
+ return Uint16Array;
51
+
52
+ if (maxIndex <= MAX_32BIT_INTEGER)
53
+ return Uint32Array;
54
+
55
+ throw new Error('mnemonist: Pointer Array of size > 4294967295 is not supported.');
56
+ };
57
+
58
+ exports$1.getSignedPointerArray = function(size) {
59
+ var maxIndex = size - 1;
60
+
61
+ if (maxIndex <= MAX_SIGNED_8BIT_INTEGER)
62
+ return Int8Array;
63
+
64
+ if (maxIndex <= MAX_SIGNED_16BIT_INTEGER)
65
+ return Int16Array;
66
+
67
+ if (maxIndex <= MAX_SIGNED_32BIT_INTEGER)
68
+ return Int32Array;
69
+
70
+ return Float64Array;
71
+ };
72
+
73
+ /**
74
+ * Function returning the minimal type able to represent the given number.
75
+ *
76
+ * @param {number} value - Value to test.
77
+ * @return {TypedArrayClass}
78
+ */
79
+ exports$1.getNumberType = function(value) {
80
+
81
+ // <= 32 bits itnteger?
82
+ if (value === (value | 0)) {
83
+
84
+ // Negative
85
+ if (Math.sign(value) === -1) {
86
+ if (value <= 127 && value >= -128)
87
+ return Int8Array;
88
+
89
+ if (value <= 32767 && value >= -32768)
90
+ return Int16Array;
91
+
92
+ return Int32Array;
93
+ }
94
+ else {
95
+
96
+ if (value <= 255)
97
+ return Uint8Array;
98
+
99
+ if (value <= 65535)
100
+ return Uint16Array;
101
+
102
+ return Uint32Array;
103
+ }
104
+ }
105
+
106
+ // 53 bits integer & floats
107
+ // NOTE: it's kinda hard to tell whether we could use 32bits or not...
108
+ return Float64Array;
109
+ };
110
+
111
+ /**
112
+ * Function returning the minimal type able to represent the given array
113
+ * of JavaScript numbers.
114
+ *
115
+ * @param {array} array - Array to represent.
116
+ * @param {function} getter - Optional getter.
117
+ * @return {TypedArrayClass}
118
+ */
119
+ var TYPE_PRIORITY = {
120
+ Uint8Array: 1,
121
+ Int8Array: 2,
122
+ Uint16Array: 3,
123
+ Int16Array: 4,
124
+ Uint32Array: 5,
125
+ Int32Array: 6,
126
+ Float32Array: 7,
127
+ Float64Array: 8
128
+ };
129
+
130
+ // TODO: make this a one-shot for one value
131
+ exports$1.getMinimalRepresentation = function(array, getter) {
132
+ var maxType = null,
133
+ maxPriority = 0,
134
+ p,
135
+ t,
136
+ v,
137
+ i,
138
+ l;
139
+
140
+ for (i = 0, l = array.length; i < l; i++) {
141
+ v = getter ? getter(array[i]) : array[i];
142
+ t = exports$1.getNumberType(v);
143
+ p = TYPE_PRIORITY[t.name];
144
+
145
+ if (p > maxPriority) {
146
+ maxPriority = p;
147
+ maxType = t;
148
+ }
149
+ }
150
+
151
+ return maxType;
152
+ };
153
+
154
+ /**
155
+ * Function returning whether the given value is a typed array.
156
+ *
157
+ * @param {any} value - Value to test.
158
+ * @return {boolean}
159
+ */
160
+ exports$1.isTypedArray = function(value) {
161
+ return typeof ArrayBuffer !== 'undefined' && ArrayBuffer.isView(value);
162
+ };
163
+
164
+ /**
165
+ * Function used to concat byte arrays.
166
+ *
167
+ * @param {...ByteArray}
168
+ * @return {ByteArray}
169
+ */
170
+ exports$1.concat = function() {
171
+ var length = 0,
172
+ i,
173
+ o,
174
+ l;
175
+
176
+ for (i = 0, l = arguments.length; i < l; i++)
177
+ length += arguments[i].length;
178
+
179
+ var array = new (arguments[0].constructor)(length);
180
+
181
+ for (i = 0, o = 0; i < l; i++) {
182
+ array.set(arguments[i], o);
183
+ o += arguments[i].length;
184
+ }
185
+
186
+ return array;
187
+ };
188
+
189
+ /**
190
+ * Function used to initialize a byte array of indices.
191
+ *
192
+ * @param {number} length - Length of target.
193
+ * @return {ByteArray}
194
+ */
195
+ exports$1.indices = function(length) {
196
+ var PointerArray = exports$1.getPointerArray(length);
197
+
198
+ var array = new PointerArray(length);
199
+
200
+ for (var i = 0; i < length; i++)
201
+ array[i] = i;
202
+
203
+ return array;
204
+ };
205
+ } (typedArrays));
206
+ return typedArrays;
207
+ }
208
+
209
+ var iterables = {};
210
+
211
+ /**
212
+ * Mnemonist Iterable Function
213
+ * ============================
214
+ *
215
+ * Harmonized iteration helpers over mixed iterable targets.
216
+ */
217
+
218
+ var hasRequiredIterables;
219
+
220
+ function requireIterables () {
221
+ if (hasRequiredIterables) return iterables;
222
+ hasRequiredIterables = 1;
223
+ var forEach = requireForeach();
224
+
225
+ var typed = /*@__PURE__*/ requireTypedArrays();
226
+
227
+ /**
228
+ * Function used to determine whether the given object supports array-like
229
+ * random access.
230
+ *
231
+ * @param {any} target - Target object.
232
+ * @return {boolean}
233
+ */
234
+ function isArrayLike(target) {
235
+ return Array.isArray(target) || typed.isTypedArray(target);
236
+ }
237
+
238
+ /**
239
+ * Function used to guess the length of the structure over which we are going
240
+ * to iterate.
241
+ *
242
+ * @param {any} target - Target object.
243
+ * @return {number|undefined}
244
+ */
245
+ function guessLength(target) {
246
+ if (typeof target.length === 'number')
247
+ return target.length;
248
+
249
+ if (typeof target.size === 'number')
250
+ return target.size;
251
+
252
+ return;
253
+ }
254
+
255
+ /**
256
+ * Function used to convert an iterable to an array.
257
+ *
258
+ * @param {any} target - Iteration target.
259
+ * @return {array}
260
+ */
261
+ function toArray(target) {
262
+ var l = guessLength(target);
263
+
264
+ var array = typeof l === 'number' ? new Array(l) : [];
265
+
266
+ var i = 0;
267
+
268
+ // TODO: we could optimize when given target is array like
269
+ forEach(target, function(value) {
270
+ array[i++] = value;
271
+ });
272
+
273
+ return array;
274
+ }
275
+
276
+ /**
277
+ * Same as above but returns a supplementary indices array.
278
+ *
279
+ * @param {any} target - Iteration target.
280
+ * @return {array}
281
+ */
282
+ function toArrayWithIndices(target) {
283
+ var l = guessLength(target);
284
+
285
+ var IndexArray = typeof l === 'number' ?
286
+ typed.getPointerArray(l) :
287
+ Array;
288
+
289
+ var array = typeof l === 'number' ? new Array(l) : [];
290
+ var indices = typeof l === 'number' ? new IndexArray(l) : [];
291
+
292
+ var i = 0;
293
+
294
+ // TODO: we could optimize when given target is array like
295
+ forEach(target, function(value) {
296
+ array[i] = value;
297
+ indices[i] = i++;
298
+ });
299
+
300
+ return [array, indices];
301
+ }
302
+
303
+ /**
304
+ * Exporting.
305
+ */
306
+ iterables.isArrayLike = isArrayLike;
307
+ iterables.guessLength = guessLength;
308
+ iterables.toArray = toArray;
309
+ iterables.toArrayWithIndices = toArrayWithIndices;
310
+ return iterables;
311
+ }
312
+
313
+ /**
314
+ * Mnemonist LRUCache
315
+ * ===================
316
+ *
317
+ * JavaScript implementation of the LRU Cache data structure. To save up
318
+ * memory and allocations this implementation represents its underlying
319
+ * doubly-linked list as static arrays and pointers. Thus, memory is allocated
320
+ * only once at instantiation and JS objects are never created to serve as
321
+ * pointers. This also means this implementation does not trigger too many
322
+ * garbage collections.
323
+ *
324
+ * Note that to save up memory, a LRU Cache can be implemented using a singly
325
+ * linked list by storing predecessors' pointers as hashmap values.
326
+ * However, this means more hashmap lookups and would probably slow the whole
327
+ * thing down. What's more, pointers are not the things taking most space in
328
+ * memory.
329
+ */
330
+
331
+ var lruCache;
332
+ var hasRequiredLruCache;
333
+
334
+ function requireLruCache () {
335
+ if (hasRequiredLruCache) return lruCache;
336
+ hasRequiredLruCache = 1;
337
+ var Iterator = requireIterator(),
338
+ forEach = requireForeach(),
339
+ typed = /*@__PURE__*/ requireTypedArrays(),
340
+ iterables = /*@__PURE__*/ requireIterables();
341
+
342
+ /**
343
+ * LRUCache.
344
+ *
345
+ * @constructor
346
+ * @param {function} Keys - Array class for storing keys.
347
+ * @param {function} Values - Array class for storing values.
348
+ * @param {number} capacity - Desired capacity.
349
+ */
350
+ function LRUCache(Keys, Values, capacity) {
351
+ if (arguments.length < 2) {
352
+ capacity = Keys;
353
+ Keys = null;
354
+ Values = null;
355
+ }
356
+
357
+ this.capacity = capacity;
358
+
359
+ if (typeof this.capacity !== 'number' || this.capacity <= 0)
360
+ throw new Error('mnemonist/lru-cache: capacity should be positive number.');
361
+ else if (!isFinite(this.capacity) || Math.floor(this.capacity) !== this.capacity)
362
+ throw new Error('mnemonist/lru-cache: capacity should be a finite positive integer.');
363
+
364
+ var PointerArray = typed.getPointerArray(capacity);
365
+
366
+ this.forward = new PointerArray(capacity);
367
+ this.backward = new PointerArray(capacity);
368
+ this.K = typeof Keys === 'function' ? new Keys(capacity) : new Array(capacity);
369
+ this.V = typeof Values === 'function' ? new Values(capacity) : new Array(capacity);
370
+
371
+ // Properties
372
+ this.size = 0;
373
+ this.head = 0;
374
+ this.tail = 0;
375
+ this.items = {};
376
+ }
377
+
378
+ /**
379
+ * Method used to clear the structure.
380
+ *
381
+ * @return {undefined}
382
+ */
383
+ LRUCache.prototype.clear = function() {
384
+ this.size = 0;
385
+ this.head = 0;
386
+ this.tail = 0;
387
+ this.items = {};
388
+ };
389
+
390
+ /**
391
+ * Method used to splay a value on top.
392
+ *
393
+ * @param {number} pointer - Pointer of the value to splay on top.
394
+ * @return {LRUCache}
395
+ */
396
+ LRUCache.prototype.splayOnTop = function(pointer) {
397
+ var oldHead = this.head;
398
+
399
+ if (this.head === pointer)
400
+ return this;
401
+
402
+ var previous = this.backward[pointer],
403
+ next = this.forward[pointer];
404
+
405
+ if (this.tail === pointer) {
406
+ this.tail = previous;
407
+ }
408
+ else {
409
+ this.backward[next] = previous;
410
+ }
411
+
412
+ this.forward[previous] = next;
413
+
414
+ this.backward[oldHead] = pointer;
415
+ this.head = pointer;
416
+ this.forward[pointer] = oldHead;
417
+
418
+ return this;
419
+ };
420
+
421
+ /**
422
+ * Method used to set the value for the given key in the cache.
423
+ *
424
+ * @param {any} key - Key.
425
+ * @param {any} value - Value.
426
+ * @return {undefined}
427
+ */
428
+ LRUCache.prototype.set = function(key, value) {
429
+
430
+ var pointer = this.items[key];
431
+
432
+ // The key already exists, we just need to update the value and splay on top
433
+ if (typeof pointer !== 'undefined') {
434
+ this.splayOnTop(pointer);
435
+ this.V[pointer] = value;
436
+
437
+ return;
438
+ }
439
+
440
+ // The cache is not yet full
441
+ if (this.size < this.capacity) {
442
+ pointer = this.size++;
443
+ }
444
+
445
+ // Cache is full, we need to drop the last value
446
+ else {
447
+ pointer = this.tail;
448
+ this.tail = this.backward[pointer];
449
+ delete this.items[this.K[pointer]];
450
+ }
451
+
452
+ // Storing key & value
453
+ this.items[key] = pointer;
454
+ this.K[pointer] = key;
455
+ this.V[pointer] = value;
456
+
457
+ // Moving the item at the front of the list
458
+ this.forward[pointer] = this.head;
459
+ this.backward[this.head] = pointer;
460
+ this.head = pointer;
461
+ };
462
+
463
+ /**
464
+ * Method used to set the value for the given key in the cache
465
+ *
466
+ * @param {any} key - Key.
467
+ * @param {any} value - Value.
468
+ * @return {{evicted: boolean, key: any, value: any}} An object containing the
469
+ * key and value of an item that was overwritten or evicted in the set
470
+ * operation, as well as a boolean indicating whether it was evicted due to
471
+ * limited capacity. Return value is null if nothing was evicted or overwritten
472
+ * during the set operation.
473
+ */
474
+ LRUCache.prototype.setpop = function(key, value) {
475
+ var oldValue = null;
476
+ var oldKey = null;
477
+
478
+ var pointer = this.items[key];
479
+
480
+ // The key already exists, we just need to update the value and splay on top
481
+ if (typeof pointer !== 'undefined') {
482
+ this.splayOnTop(pointer);
483
+ oldValue = this.V[pointer];
484
+ this.V[pointer] = value;
485
+ return {evicted: false, key: key, value: oldValue};
486
+ }
487
+
488
+ // The cache is not yet full
489
+ if (this.size < this.capacity) {
490
+ pointer = this.size++;
491
+ }
492
+
493
+ // Cache is full, we need to drop the last value
494
+ else {
495
+ pointer = this.tail;
496
+ this.tail = this.backward[pointer];
497
+ oldValue = this.V[pointer];
498
+ oldKey = this.K[pointer];
499
+ delete this.items[oldKey];
500
+ }
501
+
502
+ // Storing key & value
503
+ this.items[key] = pointer;
504
+ this.K[pointer] = key;
505
+ this.V[pointer] = value;
506
+
507
+ // Moving the item at the front of the list
508
+ this.forward[pointer] = this.head;
509
+ this.backward[this.head] = pointer;
510
+ this.head = pointer;
511
+
512
+ // Return object if eviction took place, otherwise return null
513
+ if (oldKey) {
514
+ return {evicted: true, key: oldKey, value: oldValue};
515
+ }
516
+ else {
517
+ return null;
518
+ }
519
+ };
520
+
521
+ /**
522
+ * Method used to check whether the key exists in the cache.
523
+ *
524
+ * @param {any} key - Key.
525
+ * @return {boolean}
526
+ */
527
+ LRUCache.prototype.has = function(key) {
528
+ return key in this.items;
529
+ };
530
+
531
+ /**
532
+ * Method used to get the value attached to the given key. Will move the
533
+ * related key to the front of the underlying linked list.
534
+ *
535
+ * @param {any} key - Key.
536
+ * @return {any}
537
+ */
538
+ LRUCache.prototype.get = function(key) {
539
+ var pointer = this.items[key];
540
+
541
+ if (typeof pointer === 'undefined')
542
+ return;
543
+
544
+ this.splayOnTop(pointer);
545
+
546
+ return this.V[pointer];
547
+ };
548
+
549
+ /**
550
+ * Method used to get the value attached to the given key. Does not modify
551
+ * the ordering of the underlying linked list.
552
+ *
553
+ * @param {any} key - Key.
554
+ * @return {any}
555
+ */
556
+ LRUCache.prototype.peek = function(key) {
557
+ var pointer = this.items[key];
558
+
559
+ if (typeof pointer === 'undefined')
560
+ return;
561
+
562
+ return this.V[pointer];
563
+ };
564
+
565
+ /**
566
+ * Method used to iterate over the cache's entries using a callback.
567
+ *
568
+ * @param {function} callback - Function to call for each item.
569
+ * @param {object} scope - Optional scope.
570
+ * @return {undefined}
571
+ */
572
+ LRUCache.prototype.forEach = function(callback, scope) {
573
+ scope = arguments.length > 1 ? scope : this;
574
+
575
+ var i = 0,
576
+ l = this.size;
577
+
578
+ var pointer = this.head,
579
+ keys = this.K,
580
+ values = this.V,
581
+ forward = this.forward;
582
+
583
+ while (i < l) {
584
+
585
+ callback.call(scope, values[pointer], keys[pointer], this);
586
+ pointer = forward[pointer];
587
+
588
+ i++;
589
+ }
590
+ };
591
+
592
+ /**
593
+ * Method used to create an iterator over the cache's keys from most
594
+ * recently used to least recently used.
595
+ *
596
+ * @return {Iterator}
597
+ */
598
+ LRUCache.prototype.keys = function() {
599
+ var i = 0,
600
+ l = this.size;
601
+
602
+ var pointer = this.head,
603
+ keys = this.K,
604
+ forward = this.forward;
605
+
606
+ return new Iterator(function() {
607
+ if (i >= l)
608
+ return {done: true};
609
+
610
+ var key = keys[pointer];
611
+
612
+ i++;
613
+
614
+ if (i < l)
615
+ pointer = forward[pointer];
616
+
617
+ return {
618
+ done: false,
619
+ value: key
620
+ };
621
+ });
622
+ };
623
+
624
+ /**
625
+ * Method used to create an iterator over the cache's values from most
626
+ * recently used to least recently used.
627
+ *
628
+ * @return {Iterator}
629
+ */
630
+ LRUCache.prototype.values = function() {
631
+ var i = 0,
632
+ l = this.size;
633
+
634
+ var pointer = this.head,
635
+ values = this.V,
636
+ forward = this.forward;
637
+
638
+ return new Iterator(function() {
639
+ if (i >= l)
640
+ return {done: true};
641
+
642
+ var value = values[pointer];
643
+
644
+ i++;
645
+
646
+ if (i < l)
647
+ pointer = forward[pointer];
648
+
649
+ return {
650
+ done: false,
651
+ value: value
652
+ };
653
+ });
654
+ };
655
+
656
+ /**
657
+ * Method used to create an iterator over the cache's entries from most
658
+ * recently used to least recently used.
659
+ *
660
+ * @return {Iterator}
661
+ */
662
+ LRUCache.prototype.entries = function() {
663
+ var i = 0,
664
+ l = this.size;
665
+
666
+ var pointer = this.head,
667
+ keys = this.K,
668
+ values = this.V,
669
+ forward = this.forward;
670
+
671
+ return new Iterator(function() {
672
+ if (i >= l)
673
+ return {done: true};
674
+
675
+ var key = keys[pointer],
676
+ value = values[pointer];
677
+
678
+ i++;
679
+
680
+ if (i < l)
681
+ pointer = forward[pointer];
682
+
683
+ return {
684
+ done: false,
685
+ value: [key, value]
686
+ };
687
+ });
688
+ };
689
+
690
+ /**
691
+ * Attaching the #.entries method to Symbol.iterator if possible.
692
+ */
693
+ if (typeof Symbol !== 'undefined')
694
+ LRUCache.prototype[Symbol.iterator] = LRUCache.prototype.entries;
695
+
696
+ /**
697
+ * Convenience known methods.
698
+ */
699
+ LRUCache.prototype.inspect = function() {
700
+ var proxy = new Map();
701
+
702
+ var iterator = this.entries(),
703
+ step;
704
+
705
+ while ((step = iterator.next(), !step.done))
706
+ proxy.set(step.value[0], step.value[1]);
707
+
708
+ // Trick so that node displays the name of the constructor
709
+ Object.defineProperty(proxy, 'constructor', {
710
+ value: LRUCache,
711
+ enumerable: false
712
+ });
713
+
714
+ return proxy;
715
+ };
716
+
717
+ if (typeof Symbol !== 'undefined')
718
+ LRUCache.prototype[Symbol.for('nodejs.util.inspect.custom')] = LRUCache.prototype.inspect;
719
+
720
+ /**
721
+ * Static @.from function taking an arbitrary iterable & converting it into
722
+ * a structure.
723
+ *
724
+ * @param {Iterable} iterable - Target iterable.
725
+ * @param {function} Keys - Array class for storing keys.
726
+ * @param {function} Values - Array class for storing values.
727
+ * @param {number} capacity - Cache's capacity.
728
+ * @return {LRUCache}
729
+ */
730
+ LRUCache.from = function(iterable, Keys, Values, capacity) {
731
+ if (arguments.length < 2) {
732
+ capacity = iterables.guessLength(iterable);
733
+
734
+ if (typeof capacity !== 'number')
735
+ throw new Error('mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.');
736
+ }
737
+ else if (arguments.length === 2) {
738
+ capacity = Keys;
739
+ Keys = null;
740
+ Values = null;
741
+ }
742
+
743
+ var cache = new LRUCache(Keys, Values, capacity);
744
+
745
+ forEach(iterable, function(value, key) {
746
+ cache.set(key, value);
747
+ });
748
+
749
+ return cache;
750
+ };
751
+
752
+ /**
753
+ * Exporting.
754
+ */
755
+ lruCache = LRUCache;
756
+ return lruCache;
757
+ }
758
+
759
+ /**
760
+ * Mnemonist LRUMap
761
+ * =================
762
+ *
763
+ * Variant of the LRUCache class that leverages an ES6 Map instead of an object.
764
+ * It might be faster for some use case but it is still hard to understand
765
+ * when a Map can outperform an object in v8.
766
+ */
767
+
768
+ var lruMap;
769
+ var hasRequiredLruMap;
770
+
771
+ function requireLruMap () {
772
+ if (hasRequiredLruMap) return lruMap;
773
+ hasRequiredLruMap = 1;
774
+ var LRUCache = /*@__PURE__*/ requireLruCache(),
775
+ forEach = requireForeach(),
776
+ typed = /*@__PURE__*/ requireTypedArrays(),
777
+ iterables = /*@__PURE__*/ requireIterables();
778
+
779
+ /**
780
+ * LRUMap.
781
+ *
782
+ * @constructor
783
+ * @param {function} Keys - Array class for storing keys.
784
+ * @param {function} Values - Array class for storing values.
785
+ * @param {number} capacity - Desired capacity.
786
+ */
787
+ function LRUMap(Keys, Values, capacity) {
788
+ if (arguments.length < 2) {
789
+ capacity = Keys;
790
+ Keys = null;
791
+ Values = null;
792
+ }
793
+
794
+ this.capacity = capacity;
795
+
796
+ if (typeof this.capacity !== 'number' || this.capacity <= 0)
797
+ throw new Error('mnemonist/lru-map: capacity should be positive number.');
798
+ else if (!isFinite(this.capacity) || Math.floor(this.capacity) !== this.capacity)
799
+ throw new Error('mnemonist/lru-map: capacity should be a finite positive integer.');
800
+
801
+ var PointerArray = typed.getPointerArray(capacity);
802
+
803
+ this.forward = new PointerArray(capacity);
804
+ this.backward = new PointerArray(capacity);
805
+ this.K = typeof Keys === 'function' ? new Keys(capacity) : new Array(capacity);
806
+ this.V = typeof Values === 'function' ? new Values(capacity) : new Array(capacity);
807
+
808
+ // Properties
809
+ this.size = 0;
810
+ this.head = 0;
811
+ this.tail = 0;
812
+ this.items = new Map();
813
+ }
814
+
815
+ /**
816
+ * Method used to clear the structure.
817
+ *
818
+ * @return {undefined}
819
+ */
820
+ LRUMap.prototype.clear = function() {
821
+ this.size = 0;
822
+ this.head = 0;
823
+ this.tail = 0;
824
+ this.items.clear();
825
+ };
826
+
827
+ /**
828
+ * Method used to set the value for the given key in the cache.
829
+ *
830
+ * @param {any} key - Key.
831
+ * @param {any} value - Value.
832
+ * @return {undefined}
833
+ */
834
+ LRUMap.prototype.set = function(key, value) {
835
+
836
+ var pointer = this.items.get(key);
837
+
838
+ // The key already exists, we just need to update the value and splay on top
839
+ if (typeof pointer !== 'undefined') {
840
+ this.splayOnTop(pointer);
841
+ this.V[pointer] = value;
842
+
843
+ return;
844
+ }
845
+
846
+ // The cache is not yet full
847
+ if (this.size < this.capacity) {
848
+ pointer = this.size++;
849
+ }
850
+
851
+ // Cache is full, we need to drop the last value
852
+ else {
853
+ pointer = this.tail;
854
+ this.tail = this.backward[pointer];
855
+ this.items.delete(this.K[pointer]);
856
+ }
857
+
858
+ // Storing key & value
859
+ this.items.set(key, pointer);
860
+ this.K[pointer] = key;
861
+ this.V[pointer] = value;
862
+
863
+ // Moving the item at the front of the list
864
+ this.forward[pointer] = this.head;
865
+ this.backward[this.head] = pointer;
866
+ this.head = pointer;
867
+ };
868
+
869
+ /**
870
+ * Method used to set the value for the given key in the cache.
871
+ *
872
+ * @param {any} key - Key.
873
+ * @param {any} value - Value.
874
+ * @return {{evicted: boolean, key: any, value: any}} An object containing the
875
+ * key and value of an item that was overwritten or evicted in the set
876
+ * operation, as well as a boolean indicating whether it was evicted due to
877
+ * limited capacity. Return value is null if nothing was evicted or overwritten
878
+ * during the set operation.
879
+ */
880
+ LRUMap.prototype.setpop = function(key, value) {
881
+ var oldValue = null;
882
+ var oldKey = null;
883
+
884
+ var pointer = this.items.get(key);
885
+
886
+ // The key already exists, we just need to update the value and splay on top
887
+ if (typeof pointer !== 'undefined') {
888
+ this.splayOnTop(pointer);
889
+ oldValue = this.V[pointer];
890
+ this.V[pointer] = value;
891
+ return {evicted: false, key: key, value: oldValue};
892
+ }
893
+
894
+ // The cache is not yet full
895
+ if (this.size < this.capacity) {
896
+ pointer = this.size++;
897
+ }
898
+
899
+ // Cache is full, we need to drop the last value
900
+ else {
901
+ pointer = this.tail;
902
+ this.tail = this.backward[pointer];
903
+ oldValue = this.V[pointer];
904
+ oldKey = this.K[pointer];
905
+ this.items.delete(oldKey);
906
+ }
907
+
908
+ // Storing key & value
909
+ this.items.set(key, pointer);
910
+ this.K[pointer] = key;
911
+ this.V[pointer] = value;
912
+
913
+ // Moving the item at the front of the list
914
+ this.forward[pointer] = this.head;
915
+ this.backward[this.head] = pointer;
916
+ this.head = pointer;
917
+
918
+ // Return object if eviction took place, otherwise return null
919
+ if (oldKey) {
920
+ return {evicted: true, key: oldKey, value: oldValue};
921
+ }
922
+ else {
923
+ return null;
924
+ }
925
+ };
926
+
927
+ /**
928
+ * Method used to check whether the key exists in the cache.
929
+ *
930
+ * @param {any} key - Key.
931
+ * @return {boolean}
932
+ */
933
+ LRUMap.prototype.has = function(key) {
934
+ return this.items.has(key);
935
+ };
936
+
937
+ /**
938
+ * Method used to get the value attached to the given key. Will move the
939
+ * related key to the front of the underlying linked list.
940
+ *
941
+ * @param {any} key - Key.
942
+ * @return {any}
943
+ */
944
+ LRUMap.prototype.get = function(key) {
945
+ var pointer = this.items.get(key);
946
+
947
+ if (typeof pointer === 'undefined')
948
+ return;
949
+
950
+ this.splayOnTop(pointer);
951
+
952
+ return this.V[pointer];
953
+ };
954
+
955
+ /**
956
+ * Method used to get the value attached to the given key. Does not modify
957
+ * the ordering of the underlying linked list.
958
+ *
959
+ * @param {any} key - Key.
960
+ * @return {any}
961
+ */
962
+ LRUMap.prototype.peek = function(key) {
963
+ var pointer = this.items.get(key);
964
+
965
+ if (typeof pointer === 'undefined')
966
+ return;
967
+
968
+ return this.V[pointer];
969
+ };
970
+
971
+ /**
972
+ * Methods that can be reused as-is from LRUCache.
973
+ */
974
+ LRUMap.prototype.splayOnTop = LRUCache.prototype.splayOnTop;
975
+ LRUMap.prototype.forEach = LRUCache.prototype.forEach;
976
+ LRUMap.prototype.keys = LRUCache.prototype.keys;
977
+ LRUMap.prototype.values = LRUCache.prototype.values;
978
+ LRUMap.prototype.entries = LRUCache.prototype.entries;
979
+
980
+ /**
981
+ * Attaching the #.entries method to Symbol.iterator if possible.
982
+ */
983
+ if (typeof Symbol !== 'undefined')
984
+ LRUMap.prototype[Symbol.iterator] = LRUMap.prototype.entries;
985
+
986
+ /**
987
+ * Convenience known methods.
988
+ */
989
+ LRUMap.prototype.inspect = LRUCache.prototype.inspect;
990
+
991
+ /**
992
+ * Static @.from function taking an arbitrary iterable & converting it into
993
+ * a structure.
994
+ *
995
+ * @param {Iterable} iterable - Target iterable.
996
+ * @param {function} Keys - Array class for storing keys.
997
+ * @param {function} Values - Array class for storing values.
998
+ * @param {number} capacity - Cache's capacity.
999
+ * @return {LRUMap}
1000
+ */
1001
+ LRUMap.from = function(iterable, Keys, Values, capacity) {
1002
+ if (arguments.length < 2) {
1003
+ capacity = iterables.guessLength(iterable);
1004
+
1005
+ if (typeof capacity !== 'number')
1006
+ throw new Error('mnemonist/lru-cache.from: could not guess iterable length. Please provide desired capacity as last argument.');
1007
+ }
1008
+ else if (arguments.length === 2) {
1009
+ capacity = Keys;
1010
+ Keys = null;
1011
+ Values = null;
1012
+ }
1013
+
1014
+ var cache = new LRUMap(Keys, Values, capacity);
1015
+
1016
+ forEach(iterable, function(value, key) {
1017
+ cache.set(key, value);
1018
+ });
1019
+
1020
+ return cache;
1021
+ };
1022
+
1023
+ /**
1024
+ * Exporting.
1025
+ */
1026
+ lruMap = LRUMap;
1027
+ return lruMap;
1028
+ }
1029
+
1030
+ var lruMapExports = /*@__PURE__*/ requireLruMap();
1031
+ const LRUMap = /*@__PURE__*/getDefaultExportFromCjs(lruMapExports);
1032
+
1033
+ function exact(a) {
1034
+ return t(a, (v) => v === void 0);
1035
+ }
1036
+
1037
+ const symb_text = Symbol.for("text");
1038
+ const symb_html = Symbol.for("html");
1039
+ const emptyTxt = "";
1040
+ const mdcache = new LRUMap(500);
1041
+ const txtcache = new LRUMap(500);
1042
+ class RichText {
1043
+ static getOrCreateFromText(txt) {
1044
+ if (txt.trim() === emptyTxt) {
1045
+ return RichText.EMPTY;
1046
+ }
1047
+ let cached = txtcache.get(txt);
1048
+ if (cached) {
1049
+ return cached;
1050
+ }
1051
+ cached = new RichText({ txt });
1052
+ txtcache.set(txt, cached);
1053
+ return cached;
1054
+ }
1055
+ static getOrCreateFromMarkdown(md) {
1056
+ if (md.trim() === emptyTxt) {
1057
+ return RichText.EMPTY;
1058
+ }
1059
+ let cached = mdcache.get(md);
1060
+ if (cached) {
1061
+ return cached;
1062
+ }
1063
+ cached = new RichText({ md });
1064
+ mdcache.set(md, cached);
1065
+ return cached;
1066
+ }
1067
+ /**
1068
+ * Creates and memoizes a RichText instance.
1069
+ * @see ElementModel.description
1070
+ * @example
1071
+ *
1072
+ * get description(): RichTextOrEmpty {
1073
+ * return RichText.memoize(this, 'description', this.$element.description)
1074
+ * }
1075
+ */
1076
+ static memoize(obj, tag, source) {
1077
+ return memoizeProp(obj, tag, () => RichText.from(source));
1078
+ }
1079
+ /**
1080
+ * Creates a RichText instance from a source.
1081
+ */
1082
+ static from(source) {
1083
+ if (source === null || source === void 0 || source === RichText.EMPTY) {
1084
+ return RichText.EMPTY;
1085
+ }
1086
+ if (source instanceof RichText) {
1087
+ return source;
1088
+ }
1089
+ if (typeof source === "string") {
1090
+ return this.getOrCreateFromText(source);
1091
+ }
1092
+ if ("isEmpty" in source && source.isEmpty) {
1093
+ return RichText.EMPTY;
1094
+ }
1095
+ if ("md" in source) {
1096
+ return this.getOrCreateFromMarkdown(source.md);
1097
+ }
1098
+ return this.getOrCreateFromText(source.txt);
1099
+ }
1100
+ /**
1101
+ * This is a workaround for the fact that we need instance of RichText for `instanceof` checks
1102
+ * It is invalid inheritance (returning `null` from getters), and we cast to @see RichTextEmpty
1103
+ */
1104
+ static EMPTY = new class extends RichText {
1105
+ isEmpty = true;
1106
+ nonEmpty = false;
1107
+ isMarkdown = false;
1108
+ $source = null;
1109
+ constructor() {
1110
+ super({ txt: emptyTxt });
1111
+ }
1112
+ get text() {
1113
+ return null;
1114
+ }
1115
+ get md() {
1116
+ return null;
1117
+ }
1118
+ get html() {
1119
+ return null;
1120
+ }
1121
+ }();
1122
+ $source;
1123
+ isEmpty;
1124
+ nonEmpty;
1125
+ isMarkdown;
1126
+ /**
1127
+ * Private constructor to prevent direct instantiation.
1128
+ * Use {@link RichText.from} or {@link RichText.memoize} instead.
1129
+ */
1130
+ constructor(source) {
1131
+ this.isMarkdown = false;
1132
+ if (typeof source === "string") {
1133
+ this.$source = { txt: source };
1134
+ this.isEmpty = source.trim() === emptyTxt;
1135
+ } else {
1136
+ this.$source = source;
1137
+ this.isEmpty = true;
1138
+ if ("md" in source) {
1139
+ this.isEmpty = source.md === emptyTxt;
1140
+ this.isMarkdown = true;
1141
+ } else {
1142
+ this.isEmpty = source.txt === emptyTxt;
1143
+ }
1144
+ }
1145
+ this.nonEmpty = !this.isEmpty;
1146
+ }
1147
+ /**
1148
+ * Returns the text content of the rich text.
1149
+ * If the source is a string, it returns the string.
1150
+ * If the source is a markdown, it returns the markdown.
1151
+ */
1152
+ get text() {
1153
+ if (this.isEmpty || this.$source === null) {
1154
+ return emptyTxt;
1155
+ }
1156
+ const source = this.$source;
1157
+ if ("txt" in source) {
1158
+ return source.txt;
1159
+ }
1160
+ return memoizeProp(this, symb_text, () => markdownToText(source.md));
1161
+ }
1162
+ /**
1163
+ * Returns the markdown content of the rich text.
1164
+ * If the source is a string, it returns the string.
1165
+ * If the source is a markdown, it returns the markdown.
1166
+ */
1167
+ get md() {
1168
+ if (this.isEmpty || this.$source === null) {
1169
+ return emptyTxt;
1170
+ }
1171
+ const source = this.$source;
1172
+ if ("md" in source) {
1173
+ return source.md;
1174
+ }
1175
+ if ("txt" in source) {
1176
+ return source.txt;
1177
+ }
1178
+ nonexhaustive(source);
1179
+ }
1180
+ /**
1181
+ * Returns the html content of the rich text.
1182
+ * If the source is a string, it returns the string.
1183
+ * If the source is a markdown, it returns the HTML.
1184
+ */
1185
+ get html() {
1186
+ if (this.isEmpty || this.$source === null) {
1187
+ return emptyTxt;
1188
+ }
1189
+ const source = this.$source;
1190
+ if ("txt" in source) {
1191
+ return source.txt;
1192
+ }
1193
+ return memoizeProp(this, symb_html, () => markdownToHtml(source.md));
1194
+ }
1195
+ equals(other) {
1196
+ if (this === other) return true;
1197
+ if (!(other instanceof RichText)) return false;
1198
+ if (this.isEmpty && other.isEmpty) return true;
1199
+ if (this.isEmpty !== other.isEmpty || this.isMarkdown !== other.isMarkdown) return false;
1200
+ if (this.isMarkdown) {
1201
+ return this.$source?.md === other.$source?.md;
1202
+ }
1203
+ return this.$source?.txt === other.$source?.txt;
1204
+ }
1205
+ }
1206
+
1207
+ export { RichText as R, exact as e, requireIterables as r, t };