@vonage/vivid 3.0.0-next.2 → 3.0.0-next.20

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 (122) hide show
  1. package/README.md +49 -4
  2. package/accordion/index.js +61 -0
  3. package/accordion-item/index.js +120 -0
  4. package/action-group/index.js +34 -0
  5. package/badge/index.js +24 -22
  6. package/banner/index.js +148 -0
  7. package/breadcrumb/index.js +102 -0
  8. package/breadcrumb-item/index.js +14 -9
  9. package/button/index.js +36 -663
  10. package/calendar/index.js +1526 -0
  11. package/card/index.js +139 -0
  12. package/elevation/index.js +8 -15
  13. package/fab/index.js +94 -0
  14. package/focus/index.js +20 -3
  15. package/icon/index.js +38 -5
  16. package/index.d.ts +1 -0
  17. package/index.js +43 -12
  18. package/layout/index.js +5 -5
  19. package/lib/accordion/accordion.d.ts +9 -0
  20. package/lib/accordion/accordion.template.d.ts +4 -0
  21. package/lib/accordion/index.d.ts +2 -0
  22. package/lib/accordion-item/accordion-item.d.ts +13 -0
  23. package/lib/accordion-item/accordion-item.template.d.ts +4 -0
  24. package/lib/accordion-item/index.d.ts +3 -0
  25. package/lib/action-group/action-group.d.ts +9 -0
  26. package/lib/action-group/action-group.template.d.ts +4 -0
  27. package/lib/action-group/index.d.ts +2 -0
  28. package/lib/badge/badge.d.ts +8 -8
  29. package/lib/badge/index.d.ts +1 -1
  30. package/lib/banner/banner.d.ts +20 -0
  31. package/lib/banner/banner.template.d.ts +6 -0
  32. package/lib/banner/index.d.ts +2 -0
  33. package/lib/breadcrumb/breadcrumb.d.ts +3 -0
  34. package/lib/breadcrumb/index.d.ts +2 -0
  35. package/lib/breadcrumb-item/breadcrumb-item.d.ts +3 -3
  36. package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +0 -1
  37. package/lib/breadcrumb-item/index.d.ts +1 -0
  38. package/lib/button/button.d.ts +9 -8
  39. package/lib/button/index.d.ts +2 -19
  40. package/lib/calendar/calendar.d.ts +11 -0
  41. package/lib/calendar/calendar.template.d.ts +4 -0
  42. package/lib/calendar/helpers/calendar.date-functions.d.ts +2 -0
  43. package/lib/calendar/helpers/calendar.event-context.d.ts +6 -0
  44. package/lib/calendar/helpers/calendar.keyboard-interactions.d.ts +9 -0
  45. package/lib/calendar/index.d.ts +3 -0
  46. package/lib/card/card.d.ts +10 -0
  47. package/lib/card/card.template.d.ts +4 -0
  48. package/lib/card/index.d.ts +5 -0
  49. package/lib/components.d.ts +19 -3
  50. package/lib/elevation/elevation.d.ts +1 -1
  51. package/lib/elevation/index.d.ts +1 -1
  52. package/lib/enums.d.ts +14 -7
  53. package/lib/fab/fab.d.ts +10 -0
  54. package/lib/fab/fab.template.d.ts +4 -0
  55. package/lib/fab/index.d.ts +4 -0
  56. package/lib/focus/index.d.ts +1 -1
  57. package/lib/icon/icon.d.ts +4 -5
  58. package/lib/layout/index.d.ts +1 -1
  59. package/lib/layout/layout.d.ts +3 -3
  60. package/lib/note/index.d.ts +2 -0
  61. package/lib/note/note.d.ts +10 -0
  62. package/lib/note/note.template.d.ts +5 -0
  63. package/lib/popup/index.d.ts +4 -0
  64. package/lib/popup/popup.d.ts +17 -0
  65. package/lib/popup/popup.template.d.ts +4 -0
  66. package/lib/progress/index.d.ts +2 -0
  67. package/lib/progress/progress.d.ts +9 -0
  68. package/lib/progress/progress.template.d.ts +5 -0
  69. package/lib/progress-ring/index.d.ts +2 -0
  70. package/lib/progress-ring/progress-ring.d.ts +7 -0
  71. package/lib/progress-ring/progress-ring.template.d.ts +4 -0
  72. package/lib/side-drawer/index.d.ts +2 -0
  73. package/lib/side-drawer/side-drawer.d.ts +8 -0
  74. package/lib/side-drawer/side-drawer.template.d.ts +4 -0
  75. package/lib/sidenav-item/sidenav-item.d.ts +4 -5
  76. package/lib/text/index.d.ts +2 -0
  77. package/lib/text/text.d.ts +10 -0
  78. package/lib/text/text.template.d.ts +4 -0
  79. package/lib/text-anchor/text-anchor.d.ts +4 -1
  80. package/lib/text-field/index.d.ts +4 -0
  81. package/lib/text-field/text-field.d.ts +20 -0
  82. package/lib/text-field/text-field.template.d.ts +5 -0
  83. package/lib/tooltip/index.d.ts +3 -0
  84. package/lib/tooltip/tooltip.d.ts +8 -0
  85. package/lib/tooltip/tooltip.template.d.ts +4 -0
  86. package/note/index.js +65 -0
  87. package/package.json +33 -6
  88. package/popup/index.js +2106 -0
  89. package/progress/index.js +99 -0
  90. package/progress-ring/index.js +82 -0
  91. package/shared/_has.js +58 -0
  92. package/shared/affix.js +10 -25
  93. package/shared/anchor.js +11 -4
  94. package/shared/aria-global.js +20 -20
  95. package/shared/base-progress.js +70 -0
  96. package/shared/breadcrumb-item.js +25 -0
  97. package/shared/button.js +195 -0
  98. package/shared/enums.js +79 -0
  99. package/shared/es.object.assign.js +69 -0
  100. package/shared/focus.js +5 -0
  101. package/shared/focus2.js +468 -0
  102. package/shared/icon.js +1435 -0
  103. package/shared/index.js +4940 -1426
  104. package/shared/object-set-prototype-of.js +1030 -0
  105. package/shared/patterns/affix.d.ts +3 -4
  106. package/shared/patterns/focus.d.ts +3 -0
  107. package/shared/patterns/index.d.ts +1 -0
  108. package/shared/slotted.js +119 -0
  109. package/shared/text-anchor.js +12 -0
  110. package/shared/text-anchor.template.js +14 -19
  111. package/shared/web.dom-collections.iterator.js +46 -1051
  112. package/shared/when.js +15 -0
  113. package/side-drawer/index.js +82 -0
  114. package/sidenav-item/index.js +17 -57
  115. package/styles/themes/dark.css +16 -4
  116. package/styles/themes/light.css +16 -4
  117. package/text/index.js +46 -0
  118. package/text-anchor/index.js +7 -2
  119. package/text-field/index.js +389 -0
  120. package/tooltip/index.js +66 -0
  121. package/shared/index2.js +0 -4911
  122. package/shared/index3.js +0 -21
@@ -0,0 +1,1526 @@
1
+ import '../elevation/index.js';
2
+ import { e as emptyArray, O as Observable, S as SubscriberSet, D as DOM, H as HTMLDirective, f as HTMLView, F as FoundationElement, _ as __decorate, a as attr, b as __metadata, h as html, d as designSystem } from '../shared/index.js';
3
+ import { s as styleInject } from '../shared/style-inject.es.js';
4
+ import '../shared/web.dom-collections.iterator.js';
5
+ import '../shared/es.object.assign.js';
6
+ import { b as _has, _ as _curry1, a as _curry2 } from '../shared/_has.js';
7
+ import '../shared/class-names.js';
8
+ import '../shared/object-set-prototype-of.js';
9
+
10
+ /** @internal */
11
+ function newSplice(index, removed, addedCount) {
12
+ return {
13
+ index: index,
14
+ removed: removed,
15
+ addedCount: addedCount,
16
+ };
17
+ }
18
+ const EDIT_LEAVE = 0;
19
+ const EDIT_UPDATE = 1;
20
+ const EDIT_ADD = 2;
21
+ const EDIT_DELETE = 3;
22
+ // Note: This function is *based* on the computation of the Levenshtein
23
+ // "edit" distance. The one change is that "updates" are treated as two
24
+ // edits - not one. With Array splices, an update is really a delete
25
+ // followed by an add. By retaining this, we optimize for "keeping" the
26
+ // maximum array items in the original array. For example:
27
+ //
28
+ // 'xxxx123' -> '123yyyy'
29
+ //
30
+ // With 1-edit updates, the shortest path would be just to update all seven
31
+ // characters. With 2-edit updates, we delete 4, leave 3, and add 4. This
32
+ // leaves the substring '123' intact.
33
+ function calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd) {
34
+ // "Deletion" columns
35
+ const rowCount = oldEnd - oldStart + 1;
36
+ const columnCount = currentEnd - currentStart + 1;
37
+ const distances = new Array(rowCount);
38
+ let north;
39
+ let west;
40
+ // "Addition" rows. Initialize null column.
41
+ for (let i = 0; i < rowCount; ++i) {
42
+ distances[i] = new Array(columnCount);
43
+ distances[i][0] = i;
44
+ }
45
+ // Initialize null row
46
+ for (let j = 0; j < columnCount; ++j) {
47
+ distances[0][j] = j;
48
+ }
49
+ for (let i = 1; i < rowCount; ++i) {
50
+ for (let j = 1; j < columnCount; ++j) {
51
+ if (current[currentStart + j - 1] === old[oldStart + i - 1]) {
52
+ distances[i][j] = distances[i - 1][j - 1];
53
+ }
54
+ else {
55
+ north = distances[i - 1][j] + 1;
56
+ west = distances[i][j - 1] + 1;
57
+ distances[i][j] = north < west ? north : west;
58
+ }
59
+ }
60
+ }
61
+ return distances;
62
+ }
63
+ // This starts at the final weight, and walks "backward" by finding
64
+ // the minimum previous weight recursively until the origin of the weight
65
+ // matrix.
66
+ function spliceOperationsFromEditDistances(distances) {
67
+ let i = distances.length - 1;
68
+ let j = distances[0].length - 1;
69
+ let current = distances[i][j];
70
+ const edits = [];
71
+ while (i > 0 || j > 0) {
72
+ if (i === 0) {
73
+ edits.push(EDIT_ADD);
74
+ j--;
75
+ continue;
76
+ }
77
+ if (j === 0) {
78
+ edits.push(EDIT_DELETE);
79
+ i--;
80
+ continue;
81
+ }
82
+ const northWest = distances[i - 1][j - 1];
83
+ const west = distances[i - 1][j];
84
+ const north = distances[i][j - 1];
85
+ let min;
86
+ if (west < north) {
87
+ min = west < northWest ? west : northWest;
88
+ }
89
+ else {
90
+ min = north < northWest ? north : northWest;
91
+ }
92
+ if (min === northWest) {
93
+ if (northWest === current) {
94
+ edits.push(EDIT_LEAVE);
95
+ }
96
+ else {
97
+ edits.push(EDIT_UPDATE);
98
+ current = northWest;
99
+ }
100
+ i--;
101
+ j--;
102
+ }
103
+ else if (min === west) {
104
+ edits.push(EDIT_DELETE);
105
+ i--;
106
+ current = west;
107
+ }
108
+ else {
109
+ edits.push(EDIT_ADD);
110
+ j--;
111
+ current = north;
112
+ }
113
+ }
114
+ edits.reverse();
115
+ return edits;
116
+ }
117
+ function sharedPrefix(current, old, searchLength) {
118
+ for (let i = 0; i < searchLength; ++i) {
119
+ if (current[i] !== old[i]) {
120
+ return i;
121
+ }
122
+ }
123
+ return searchLength;
124
+ }
125
+ function sharedSuffix(current, old, searchLength) {
126
+ let index1 = current.length;
127
+ let index2 = old.length;
128
+ let count = 0;
129
+ while (count < searchLength && current[--index1] === old[--index2]) {
130
+ count++;
131
+ }
132
+ return count;
133
+ }
134
+ function intersect(start1, end1, start2, end2) {
135
+ // Disjoint
136
+ if (end1 < start2 || end2 < start1) {
137
+ return -1;
138
+ }
139
+ // Adjacent
140
+ if (end1 === start2 || end2 === start1) {
141
+ return 0;
142
+ }
143
+ // Non-zero intersect, span1 first
144
+ if (start1 < start2) {
145
+ if (end1 < end2) {
146
+ return end1 - start2; // Overlap
147
+ }
148
+ return end2 - start2; // Contained
149
+ }
150
+ // Non-zero intersect, span2 first
151
+ if (end2 < end1) {
152
+ return end2 - start1; // Overlap
153
+ }
154
+ return end1 - start1; // Contained
155
+ }
156
+ /**
157
+ * Splice Projection functions:
158
+ *
159
+ * A splice map is a representation of how a previous array of items
160
+ * was transformed into a new array of items. Conceptually it is a list of
161
+ * tuples of
162
+ *
163
+ * <index, removed, addedCount>
164
+ *
165
+ * which are kept in ascending index order of. The tuple represents that at
166
+ * the |index|, |removed| sequence of items were removed, and counting forward
167
+ * from |index|, |addedCount| items were added.
168
+ */
169
+ /**
170
+ * @internal
171
+ * @remarks
172
+ * Lacking individual splice mutation information, the minimal set of
173
+ * splices can be synthesized given the previous state and final state of an
174
+ * array. The basic approach is to calculate the edit distance matrix and
175
+ * choose the shortest path through it.
176
+ *
177
+ * Complexity: O(l * p)
178
+ * l: The length of the current array
179
+ * p: The length of the old array
180
+ */
181
+ function calcSplices(current, currentStart, currentEnd, old, oldStart, oldEnd) {
182
+ let prefixCount = 0;
183
+ let suffixCount = 0;
184
+ const minLength = Math.min(currentEnd - currentStart, oldEnd - oldStart);
185
+ if (currentStart === 0 && oldStart === 0) {
186
+ prefixCount = sharedPrefix(current, old, minLength);
187
+ }
188
+ if (currentEnd === current.length && oldEnd === old.length) {
189
+ suffixCount = sharedSuffix(current, old, minLength - prefixCount);
190
+ }
191
+ currentStart += prefixCount;
192
+ oldStart += prefixCount;
193
+ currentEnd -= suffixCount;
194
+ oldEnd -= suffixCount;
195
+ if (currentEnd - currentStart === 0 && oldEnd - oldStart === 0) {
196
+ return emptyArray;
197
+ }
198
+ if (currentStart === currentEnd) {
199
+ const splice = newSplice(currentStart, [], 0);
200
+ while (oldStart < oldEnd) {
201
+ splice.removed.push(old[oldStart++]);
202
+ }
203
+ return [splice];
204
+ }
205
+ else if (oldStart === oldEnd) {
206
+ return [newSplice(currentStart, [], currentEnd - currentStart)];
207
+ }
208
+ const ops = spliceOperationsFromEditDistances(calcEditDistances(current, currentStart, currentEnd, old, oldStart, oldEnd));
209
+ const splices = [];
210
+ let splice = void 0;
211
+ let index = currentStart;
212
+ let oldIndex = oldStart;
213
+ for (let i = 0; i < ops.length; ++i) {
214
+ switch (ops[i]) {
215
+ case EDIT_LEAVE:
216
+ if (splice !== void 0) {
217
+ splices.push(splice);
218
+ splice = void 0;
219
+ }
220
+ index++;
221
+ oldIndex++;
222
+ break;
223
+ case EDIT_UPDATE:
224
+ if (splice === void 0) {
225
+ splice = newSplice(index, [], 0);
226
+ }
227
+ splice.addedCount++;
228
+ index++;
229
+ splice.removed.push(old[oldIndex]);
230
+ oldIndex++;
231
+ break;
232
+ case EDIT_ADD:
233
+ if (splice === void 0) {
234
+ splice = newSplice(index, [], 0);
235
+ }
236
+ splice.addedCount++;
237
+ index++;
238
+ break;
239
+ case EDIT_DELETE:
240
+ if (splice === void 0) {
241
+ splice = newSplice(index, [], 0);
242
+ }
243
+ splice.removed.push(old[oldIndex]);
244
+ oldIndex++;
245
+ break;
246
+ // no default
247
+ }
248
+ }
249
+ if (splice !== void 0) {
250
+ splices.push(splice);
251
+ }
252
+ return splices;
253
+ }
254
+ const $push = Array.prototype.push;
255
+ function mergeSplice(splices, index, removed, addedCount) {
256
+ const splice = newSplice(index, removed, addedCount);
257
+ let inserted = false;
258
+ let insertionOffset = 0;
259
+ for (let i = 0; i < splices.length; i++) {
260
+ const current = splices[i];
261
+ current.index += insertionOffset;
262
+ if (inserted) {
263
+ continue;
264
+ }
265
+ const intersectCount = intersect(splice.index, splice.index + splice.removed.length, current.index, current.index + current.addedCount);
266
+ if (intersectCount >= 0) {
267
+ // Merge the two splices
268
+ splices.splice(i, 1);
269
+ i--;
270
+ insertionOffset -= current.addedCount - current.removed.length;
271
+ splice.addedCount += current.addedCount - intersectCount;
272
+ const deleteCount = splice.removed.length + current.removed.length - intersectCount;
273
+ if (!splice.addedCount && !deleteCount) {
274
+ // merged splice is a noop. discard.
275
+ inserted = true;
276
+ }
277
+ else {
278
+ let currentRemoved = current.removed;
279
+ if (splice.index < current.index) {
280
+ // some prefix of splice.removed is prepended to current.removed.
281
+ const prepend = splice.removed.slice(0, current.index - splice.index);
282
+ $push.apply(prepend, currentRemoved);
283
+ currentRemoved = prepend;
284
+ }
285
+ if (splice.index + splice.removed.length >
286
+ current.index + current.addedCount) {
287
+ // some suffix of splice.removed is appended to current.removed.
288
+ const append = splice.removed.slice(current.index + current.addedCount - splice.index);
289
+ $push.apply(currentRemoved, append);
290
+ }
291
+ splice.removed = currentRemoved;
292
+ if (current.index < splice.index) {
293
+ splice.index = current.index;
294
+ }
295
+ }
296
+ }
297
+ else if (splice.index < current.index) {
298
+ // Insert splice here.
299
+ inserted = true;
300
+ splices.splice(i, 0, splice);
301
+ i++;
302
+ const offset = splice.addedCount - splice.removed.length;
303
+ current.index += offset;
304
+ insertionOffset += offset;
305
+ }
306
+ }
307
+ if (!inserted) {
308
+ splices.push(splice);
309
+ }
310
+ }
311
+ function createInitialSplices(changeRecords) {
312
+ const splices = [];
313
+ for (let i = 0, ii = changeRecords.length; i < ii; i++) {
314
+ const record = changeRecords[i];
315
+ mergeSplice(splices, record.index, record.removed, record.addedCount);
316
+ }
317
+ return splices;
318
+ }
319
+ /** @internal */
320
+ function projectArraySplices(array, changeRecords) {
321
+ let splices = [];
322
+ const initialSplices = createInitialSplices(changeRecords);
323
+ for (let i = 0, ii = initialSplices.length; i < ii; ++i) {
324
+ const splice = initialSplices[i];
325
+ if (splice.addedCount === 1 && splice.removed.length === 1) {
326
+ if (splice.removed[0] !== array[splice.index]) {
327
+ splices.push(splice);
328
+ }
329
+ continue;
330
+ }
331
+ splices = splices.concat(calcSplices(array, splice.index, splice.index + splice.addedCount, splice.removed, 0, splice.removed.length));
332
+ }
333
+ return splices;
334
+ }
335
+
336
+ let arrayObservationEnabled = false;
337
+ function adjustIndex(changeRecord, array) {
338
+ let index = changeRecord.index;
339
+ const arrayLength = array.length;
340
+ if (index > arrayLength) {
341
+ index = arrayLength - changeRecord.addedCount;
342
+ }
343
+ else if (index < 0) {
344
+ index =
345
+ arrayLength + changeRecord.removed.length + index - changeRecord.addedCount;
346
+ }
347
+ if (index < 0) {
348
+ index = 0;
349
+ }
350
+ changeRecord.index = index;
351
+ return changeRecord;
352
+ }
353
+ class ArrayObserver extends SubscriberSet {
354
+ constructor(source) {
355
+ super(source);
356
+ this.oldCollection = void 0;
357
+ this.splices = void 0;
358
+ this.needsQueue = true;
359
+ this.call = this.flush;
360
+ Reflect.defineProperty(source, "$fastController", {
361
+ value: this,
362
+ enumerable: false,
363
+ });
364
+ }
365
+ subscribe(subscriber) {
366
+ this.flush();
367
+ super.subscribe(subscriber);
368
+ }
369
+ addSplice(splice) {
370
+ if (this.splices === void 0) {
371
+ this.splices = [splice];
372
+ }
373
+ else {
374
+ this.splices.push(splice);
375
+ }
376
+ if (this.needsQueue) {
377
+ this.needsQueue = false;
378
+ DOM.queueUpdate(this);
379
+ }
380
+ }
381
+ reset(oldCollection) {
382
+ this.oldCollection = oldCollection;
383
+ if (this.needsQueue) {
384
+ this.needsQueue = false;
385
+ DOM.queueUpdate(this);
386
+ }
387
+ }
388
+ flush() {
389
+ const splices = this.splices;
390
+ const oldCollection = this.oldCollection;
391
+ if (splices === void 0 && oldCollection === void 0) {
392
+ return;
393
+ }
394
+ this.needsQueue = true;
395
+ this.splices = void 0;
396
+ this.oldCollection = void 0;
397
+ const finalSplices = oldCollection === void 0
398
+ ? projectArraySplices(this.source, splices)
399
+ : calcSplices(this.source, 0, this.source.length, oldCollection, 0, oldCollection.length);
400
+ this.notify(finalSplices);
401
+ }
402
+ }
403
+ /* eslint-disable prefer-rest-params */
404
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
405
+ /**
406
+ * Enables the array observation mechanism.
407
+ * @remarks
408
+ * Array observation is enabled automatically when using the
409
+ * {@link RepeatDirective}, so calling this API manually is
410
+ * not typically necessary.
411
+ * @public
412
+ */
413
+ function enableArrayObservation() {
414
+ if (arrayObservationEnabled) {
415
+ return;
416
+ }
417
+ arrayObservationEnabled = true;
418
+ Observable.setArrayObserverFactory((collection) => {
419
+ return new ArrayObserver(collection);
420
+ });
421
+ const proto = Array.prototype;
422
+ // Don't patch Array if it has already been patched
423
+ // by another copy of fast-element.
424
+ if (proto.$fastPatch) {
425
+ return;
426
+ }
427
+ Reflect.defineProperty(proto, "$fastPatch", {
428
+ value: 1,
429
+ enumerable: false,
430
+ });
431
+ const pop = proto.pop;
432
+ const push = proto.push;
433
+ const reverse = proto.reverse;
434
+ const shift = proto.shift;
435
+ const sort = proto.sort;
436
+ const splice = proto.splice;
437
+ const unshift = proto.unshift;
438
+ proto.pop = function () {
439
+ const notEmpty = this.length > 0;
440
+ const methodCallResult = pop.apply(this, arguments);
441
+ const o = this.$fastController;
442
+ if (o !== void 0 && notEmpty) {
443
+ o.addSplice(newSplice(this.length, [methodCallResult], 0));
444
+ }
445
+ return methodCallResult;
446
+ };
447
+ proto.push = function () {
448
+ const methodCallResult = push.apply(this, arguments);
449
+ const o = this.$fastController;
450
+ if (o !== void 0) {
451
+ o.addSplice(adjustIndex(newSplice(this.length - arguments.length, [], arguments.length), this));
452
+ }
453
+ return methodCallResult;
454
+ };
455
+ proto.reverse = function () {
456
+ let oldArray;
457
+ const o = this.$fastController;
458
+ if (o !== void 0) {
459
+ o.flush();
460
+ oldArray = this.slice();
461
+ }
462
+ const methodCallResult = reverse.apply(this, arguments);
463
+ if (o !== void 0) {
464
+ o.reset(oldArray);
465
+ }
466
+ return methodCallResult;
467
+ };
468
+ proto.shift = function () {
469
+ const notEmpty = this.length > 0;
470
+ const methodCallResult = shift.apply(this, arguments);
471
+ const o = this.$fastController;
472
+ if (o !== void 0 && notEmpty) {
473
+ o.addSplice(newSplice(0, [methodCallResult], 0));
474
+ }
475
+ return methodCallResult;
476
+ };
477
+ proto.sort = function () {
478
+ let oldArray;
479
+ const o = this.$fastController;
480
+ if (o !== void 0) {
481
+ o.flush();
482
+ oldArray = this.slice();
483
+ }
484
+ const methodCallResult = sort.apply(this, arguments);
485
+ if (o !== void 0) {
486
+ o.reset(oldArray);
487
+ }
488
+ return methodCallResult;
489
+ };
490
+ proto.splice = function () {
491
+ const methodCallResult = splice.apply(this, arguments);
492
+ const o = this.$fastController;
493
+ if (o !== void 0) {
494
+ o.addSplice(adjustIndex(newSplice(+arguments[0], methodCallResult, arguments.length > 2 ? arguments.length - 2 : 0), this));
495
+ }
496
+ return methodCallResult;
497
+ };
498
+ proto.unshift = function () {
499
+ const methodCallResult = unshift.apply(this, arguments);
500
+ const o = this.$fastController;
501
+ if (o !== void 0) {
502
+ o.addSplice(adjustIndex(newSplice(0, [], arguments.length), this));
503
+ }
504
+ return methodCallResult;
505
+ };
506
+ }
507
+ /* eslint-enable prefer-rest-params */
508
+ /* eslint-enable @typescript-eslint/explicit-function-return-type */
509
+
510
+ const defaultRepeatOptions = Object.freeze({
511
+ positioning: false,
512
+ recycle: true,
513
+ });
514
+ function bindWithoutPositioning(view, items, index, context) {
515
+ view.bind(items[index], context);
516
+ }
517
+ function bindWithPositioning(view, items, index, context) {
518
+ const childContext = Object.create(context);
519
+ childContext.index = index;
520
+ childContext.length = items.length;
521
+ view.bind(items[index], childContext);
522
+ }
523
+ /**
524
+ * A behavior that renders a template for each item in an array.
525
+ * @public
526
+ */
527
+ class RepeatBehavior {
528
+ /**
529
+ * Creates an instance of RepeatBehavior.
530
+ * @param location - The location in the DOM to render the repeat.
531
+ * @param itemsBinding - The array to render.
532
+ * @param isItemsBindingVolatile - Indicates whether the items binding has volatile dependencies.
533
+ * @param templateBinding - The template to render for each item.
534
+ * @param isTemplateBindingVolatile - Indicates whether the template binding has volatile dependencies.
535
+ * @param options - Options used to turn on special repeat features.
536
+ */
537
+ constructor(location, itemsBinding, isItemsBindingVolatile, templateBinding, isTemplateBindingVolatile, options) {
538
+ this.location = location;
539
+ this.itemsBinding = itemsBinding;
540
+ this.templateBinding = templateBinding;
541
+ this.options = options;
542
+ this.source = null;
543
+ this.views = [];
544
+ this.items = null;
545
+ this.itemsObserver = null;
546
+ this.originalContext = void 0;
547
+ this.childContext = void 0;
548
+ this.bindView = bindWithoutPositioning;
549
+ this.itemsBindingObserver = Observable.binding(itemsBinding, this, isItemsBindingVolatile);
550
+ this.templateBindingObserver = Observable.binding(templateBinding, this, isTemplateBindingVolatile);
551
+ if (options.positioning) {
552
+ this.bindView = bindWithPositioning;
553
+ }
554
+ }
555
+ /**
556
+ * Bind this behavior to the source.
557
+ * @param source - The source to bind to.
558
+ * @param context - The execution context that the binding is operating within.
559
+ */
560
+ bind(source, context) {
561
+ this.source = source;
562
+ this.originalContext = context;
563
+ this.childContext = Object.create(context);
564
+ this.childContext.parent = source;
565
+ this.childContext.parentContext = this.originalContext;
566
+ this.items = this.itemsBindingObserver.observe(source, this.originalContext);
567
+ this.template = this.templateBindingObserver.observe(source, this.originalContext);
568
+ this.observeItems(true);
569
+ this.refreshAllViews();
570
+ }
571
+ /**
572
+ * Unbinds this behavior from the source.
573
+ * @param source - The source to unbind from.
574
+ */
575
+ unbind() {
576
+ this.source = null;
577
+ this.items = null;
578
+ if (this.itemsObserver !== null) {
579
+ this.itemsObserver.unsubscribe(this);
580
+ }
581
+ this.unbindAllViews();
582
+ this.itemsBindingObserver.disconnect();
583
+ this.templateBindingObserver.disconnect();
584
+ }
585
+ /** @internal */
586
+ handleChange(source, args) {
587
+ if (source === this.itemsBinding) {
588
+ this.items = this.itemsBindingObserver.observe(this.source, this.originalContext);
589
+ this.observeItems();
590
+ this.refreshAllViews();
591
+ }
592
+ else if (source === this.templateBinding) {
593
+ this.template = this.templateBindingObserver.observe(this.source, this.originalContext);
594
+ this.refreshAllViews(true);
595
+ }
596
+ else {
597
+ this.updateViews(args);
598
+ }
599
+ }
600
+ observeItems(force = false) {
601
+ if (!this.items) {
602
+ this.items = emptyArray;
603
+ return;
604
+ }
605
+ const oldObserver = this.itemsObserver;
606
+ const newObserver = (this.itemsObserver = Observable.getNotifier(this.items));
607
+ const hasNewObserver = oldObserver !== newObserver;
608
+ if (hasNewObserver && oldObserver !== null) {
609
+ oldObserver.unsubscribe(this);
610
+ }
611
+ if (hasNewObserver || force) {
612
+ newObserver.subscribe(this);
613
+ }
614
+ }
615
+ updateViews(splices) {
616
+ const childContext = this.childContext;
617
+ const views = this.views;
618
+ const totalRemoved = [];
619
+ const bindView = this.bindView;
620
+ let removeDelta = 0;
621
+ for (let i = 0, ii = splices.length; i < ii; ++i) {
622
+ const splice = splices[i];
623
+ const removed = splice.removed;
624
+ totalRemoved.push(...views.splice(splice.index + removeDelta, removed.length));
625
+ removeDelta -= splice.addedCount;
626
+ }
627
+ const items = this.items;
628
+ const template = this.template;
629
+ for (let i = 0, ii = splices.length; i < ii; ++i) {
630
+ const splice = splices[i];
631
+ let addIndex = splice.index;
632
+ const end = addIndex + splice.addedCount;
633
+ for (; addIndex < end; ++addIndex) {
634
+ const neighbor = views[addIndex];
635
+ const location = neighbor ? neighbor.firstChild : this.location;
636
+ const view = this.options.recycle && totalRemoved.length > 0
637
+ ? totalRemoved.shift()
638
+ : template.create();
639
+ views.splice(addIndex, 0, view);
640
+ bindView(view, items, addIndex, childContext);
641
+ view.insertBefore(location);
642
+ }
643
+ }
644
+ for (let i = 0, ii = totalRemoved.length; i < ii; ++i) {
645
+ totalRemoved[i].dispose();
646
+ }
647
+ if (this.options.positioning) {
648
+ for (let i = 0, ii = views.length; i < ii; ++i) {
649
+ const currentContext = views[i].context;
650
+ currentContext.length = ii;
651
+ currentContext.index = i;
652
+ }
653
+ }
654
+ }
655
+ refreshAllViews(templateChanged = false) {
656
+ const items = this.items;
657
+ const childContext = this.childContext;
658
+ const template = this.template;
659
+ const location = this.location;
660
+ const bindView = this.bindView;
661
+ let itemsLength = items.length;
662
+ let views = this.views;
663
+ let viewsLength = views.length;
664
+ if (itemsLength === 0 || templateChanged) {
665
+ // all views need to be removed
666
+ HTMLView.disposeContiguousBatch(views);
667
+ viewsLength = 0;
668
+ }
669
+ if (viewsLength === 0) {
670
+ // all views need to be created
671
+ this.views = views = new Array(itemsLength);
672
+ for (let i = 0; i < itemsLength; ++i) {
673
+ const view = template.create();
674
+ bindView(view, items, i, childContext);
675
+ views[i] = view;
676
+ view.insertBefore(location);
677
+ }
678
+ }
679
+ else {
680
+ // attempt to reuse existing views with new data
681
+ let i = 0;
682
+ for (; i < itemsLength; ++i) {
683
+ if (i < viewsLength) {
684
+ const view = views[i];
685
+ bindView(view, items, i, childContext);
686
+ }
687
+ else {
688
+ const view = template.create();
689
+ bindView(view, items, i, childContext);
690
+ views.push(view);
691
+ view.insertBefore(location);
692
+ }
693
+ }
694
+ const removed = views.splice(i, viewsLength - i);
695
+ for (i = 0, itemsLength = removed.length; i < itemsLength; ++i) {
696
+ removed[i].dispose();
697
+ }
698
+ }
699
+ }
700
+ unbindAllViews() {
701
+ const views = this.views;
702
+ for (let i = 0, ii = views.length; i < ii; ++i) {
703
+ views[i].unbind();
704
+ }
705
+ }
706
+ }
707
+ /**
708
+ * A directive that configures list rendering.
709
+ * @public
710
+ */
711
+ class RepeatDirective extends HTMLDirective {
712
+ /**
713
+ * Creates an instance of RepeatDirective.
714
+ * @param itemsBinding - The binding that provides the array to render.
715
+ * @param templateBinding - The template binding used to obtain a template to render for each item in the array.
716
+ * @param options - Options used to turn on special repeat features.
717
+ */
718
+ constructor(itemsBinding, templateBinding, options) {
719
+ super();
720
+ this.itemsBinding = itemsBinding;
721
+ this.templateBinding = templateBinding;
722
+ this.options = options;
723
+ /**
724
+ * Creates a placeholder string based on the directive's index within the template.
725
+ * @param index - The index of the directive within the template.
726
+ */
727
+ this.createPlaceholder = DOM.createBlockPlaceholder;
728
+ enableArrayObservation();
729
+ this.isItemsBindingVolatile = Observable.isVolatileBinding(itemsBinding);
730
+ this.isTemplateBindingVolatile = Observable.isVolatileBinding(templateBinding);
731
+ }
732
+ /**
733
+ * Creates a behavior for the provided target node.
734
+ * @param target - The node instance to create the behavior for.
735
+ */
736
+ createBehavior(target) {
737
+ return new RepeatBehavior(target, this.itemsBinding, this.isItemsBindingVolatile, this.templateBinding, this.isTemplateBindingVolatile, this.options);
738
+ }
739
+ }
740
+ /**
741
+ * A directive that enables list rendering.
742
+ * @param itemsBinding - The array to render.
743
+ * @param templateOrTemplateBinding - The template or a template binding used obtain a template
744
+ * to render for each item in the array.
745
+ * @param options - Options used to turn on special repeat features.
746
+ * @public
747
+ */
748
+ function repeat(itemsBinding, templateOrTemplateBinding, options = defaultRepeatOptions) {
749
+ const templateBinding = typeof templateOrTemplateBinding === "function"
750
+ ? templateOrTemplateBinding
751
+ : () => templateOrTemplateBinding;
752
+ return new RepeatDirective(itemsBinding, templateBinding, options);
753
+ }
754
+
755
+ /**
756
+ * Tests whether or not an object is an array.
757
+ *
758
+ * @private
759
+ * @param {*} val The object to test.
760
+ * @return {Boolean} `true` if `val` is an array, `false` otherwise.
761
+ * @example
762
+ *
763
+ * _isArray([]); //=> true
764
+ * _isArray(null); //=> false
765
+ * _isArray({}); //=> false
766
+ */
767
+ var _isArray = Array.isArray || function _isArray(val) {
768
+ return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]';
769
+ };
770
+
771
+ function _isString(x) {
772
+ return Object.prototype.toString.call(x) === '[object String]';
773
+ }
774
+
775
+ var toString = Object.prototype.toString;
776
+
777
+ var _isArguments =
778
+ /*#__PURE__*/
779
+ function () {
780
+ return toString.call(arguments) === '[object Arguments]' ? function _isArguments(x) {
781
+ return toString.call(x) === '[object Arguments]';
782
+ } : function _isArguments(x) {
783
+ return _has('callee', x);
784
+ };
785
+ }();
786
+
787
+ var _isArguments$1 = _isArguments;
788
+
789
+ var hasEnumBug = !
790
+ /*#__PURE__*/
791
+ {
792
+ toString: null
793
+ }.propertyIsEnumerable('toString');
794
+ var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug
795
+
796
+ var hasArgsEnumBug =
797
+ /*#__PURE__*/
798
+ function () {
799
+
800
+ return arguments.propertyIsEnumerable('length');
801
+ }();
802
+
803
+ var contains = function contains(list, item) {
804
+ var idx = 0;
805
+
806
+ while (idx < list.length) {
807
+ if (list[idx] === item) {
808
+ return true;
809
+ }
810
+
811
+ idx += 1;
812
+ }
813
+
814
+ return false;
815
+ };
816
+ /**
817
+ * Returns a list containing the names of all the enumerable own properties of
818
+ * the supplied object.
819
+ * Note that the order of the output array is not guaranteed to be consistent
820
+ * across different JS platforms.
821
+ *
822
+ * @func
823
+ * @memberOf R
824
+ * @since v0.1.0
825
+ * @category Object
826
+ * @sig {k: v} -> [k]
827
+ * @param {Object} obj The object to extract properties from
828
+ * @return {Array} An array of the object's own properties.
829
+ * @see R.keysIn, R.values
830
+ * @example
831
+ *
832
+ * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c']
833
+ */
834
+
835
+
836
+ var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ?
837
+ /*#__PURE__*/
838
+ _curry1(function keys(obj) {
839
+ return Object(obj) !== obj ? [] : Object.keys(obj);
840
+ }) :
841
+ /*#__PURE__*/
842
+ _curry1(function keys(obj) {
843
+ if (Object(obj) !== obj) {
844
+ return [];
845
+ }
846
+
847
+ var prop, nIdx;
848
+ var ks = [];
849
+
850
+ var checkArgsLength = hasArgsEnumBug && _isArguments$1(obj);
851
+
852
+ for (prop in obj) {
853
+ if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
854
+ ks[ks.length] = prop;
855
+ }
856
+ }
857
+
858
+ if (hasEnumBug) {
859
+ nIdx = nonEnumerableProps.length - 1;
860
+
861
+ while (nIdx >= 0) {
862
+ prop = nonEnumerableProps[nIdx];
863
+
864
+ if (_has(prop, obj) && !contains(ks, prop)) {
865
+ ks[ks.length] = prop;
866
+ }
867
+
868
+ nIdx -= 1;
869
+ }
870
+ }
871
+
872
+ return ks;
873
+ });
874
+ var keys$1 = keys;
875
+
876
+ /**
877
+ * Gives a single-word string description of the (native) type of a value,
878
+ * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
879
+ * attempt to distinguish user Object types any further, reporting them all as
880
+ * 'Object'.
881
+ *
882
+ * @func
883
+ * @memberOf R
884
+ * @since v0.8.0
885
+ * @category Type
886
+ * @sig (* -> {*}) -> String
887
+ * @param {*} val The value to test
888
+ * @return {String}
889
+ * @example
890
+ *
891
+ * R.type({}); //=> "Object"
892
+ * R.type(1); //=> "Number"
893
+ * R.type(false); //=> "Boolean"
894
+ * R.type('s'); //=> "String"
895
+ * R.type(null); //=> "Null"
896
+ * R.type([]); //=> "Array"
897
+ * R.type(/[A-z]/); //=> "RegExp"
898
+ * R.type(() => {}); //=> "Function"
899
+ * R.type(undefined); //=> "Undefined"
900
+ */
901
+
902
+ var type =
903
+ /*#__PURE__*/
904
+ _curry1(function type(val) {
905
+ return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
906
+ });
907
+
908
+ var type$1 = type;
909
+
910
+ /**
911
+ * A function that returns the `!` of its argument. It will return `true` when
912
+ * passed false-y value, and `false` when passed a truth-y one.
913
+ *
914
+ * @func
915
+ * @memberOf R
916
+ * @since v0.1.0
917
+ * @category Logic
918
+ * @sig * -> Boolean
919
+ * @param {*} a any value
920
+ * @return {Boolean} the logical inverse of passed argument.
921
+ * @see R.complement
922
+ * @example
923
+ *
924
+ * R.not(true); //=> false
925
+ * R.not(false); //=> true
926
+ * R.not(0); //=> true
927
+ * R.not(1); //=> false
928
+ */
929
+
930
+ var not =
931
+ /*#__PURE__*/
932
+ _curry1(function not(a) {
933
+ return !a;
934
+ });
935
+
936
+ var not$1 = not;
937
+
938
+ function _arrayFromIterator(iter) {
939
+ var list = [];
940
+ var next;
941
+
942
+ while (!(next = iter.next()).done) {
943
+ list.push(next.value);
944
+ }
945
+
946
+ return list;
947
+ }
948
+
949
+ function _includesWith(pred, x, list) {
950
+ var idx = 0;
951
+ var len = list.length;
952
+
953
+ while (idx < len) {
954
+ if (pred(x, list[idx])) {
955
+ return true;
956
+ }
957
+
958
+ idx += 1;
959
+ }
960
+
961
+ return false;
962
+ }
963
+
964
+ function _functionName(f) {
965
+ // String(x => x) evaluates to "x => x", so the pattern may not match.
966
+ var match = String(f).match(/^function (\w*)/);
967
+ return match == null ? '' : match[1];
968
+ }
969
+
970
+ // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
971
+ function _objectIs(a, b) {
972
+ // SameValue algorithm
973
+ if (a === b) {
974
+ // Steps 1-5, 7-10
975
+ // Steps 6.b-6.e: +0 != -0
976
+ return a !== 0 || 1 / a === 1 / b;
977
+ } else {
978
+ // Step 6.a: NaN == NaN
979
+ return a !== a && b !== b;
980
+ }
981
+ }
982
+
983
+ var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
984
+
985
+ /**
986
+ * private _uniqContentEquals function.
987
+ * That function is checking equality of 2 iterator contents with 2 assumptions
988
+ * - iterators lengths are the same
989
+ * - iterators values are unique
990
+ *
991
+ * false-positive result will be returned for comparision of, e.g.
992
+ * - [1,2,3] and [1,2,3,4]
993
+ * - [1,1,1] and [1,2,3]
994
+ * */
995
+
996
+ function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
997
+ var a = _arrayFromIterator(aIterator);
998
+
999
+ var b = _arrayFromIterator(bIterator);
1000
+
1001
+ function eq(_a, _b) {
1002
+ return _equals(_a, _b, stackA.slice(), stackB.slice());
1003
+ } // if *a* array contains any element that is not included in *b*
1004
+
1005
+
1006
+ return !_includesWith(function (b, aItem) {
1007
+ return !_includesWith(eq, aItem, b);
1008
+ }, b, a);
1009
+ }
1010
+
1011
+ function _equals(a, b, stackA, stackB) {
1012
+ if (_objectIs$1(a, b)) {
1013
+ return true;
1014
+ }
1015
+
1016
+ var typeA = type$1(a);
1017
+
1018
+ if (typeA !== type$1(b)) {
1019
+ return false;
1020
+ }
1021
+
1022
+ if (a == null || b == null) {
1023
+ return false;
1024
+ }
1025
+
1026
+ if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
1027
+ return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a);
1028
+ }
1029
+
1030
+ if (typeof a.equals === 'function' || typeof b.equals === 'function') {
1031
+ return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a);
1032
+ }
1033
+
1034
+ switch (typeA) {
1035
+ case 'Arguments':
1036
+ case 'Array':
1037
+ case 'Object':
1038
+ if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') {
1039
+ return a === b;
1040
+ }
1041
+
1042
+ break;
1043
+
1044
+ case 'Boolean':
1045
+ case 'Number':
1046
+ case 'String':
1047
+ if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
1048
+ return false;
1049
+ }
1050
+
1051
+ break;
1052
+
1053
+ case 'Date':
1054
+ if (!_objectIs$1(a.valueOf(), b.valueOf())) {
1055
+ return false;
1056
+ }
1057
+
1058
+ break;
1059
+
1060
+ case 'Error':
1061
+ return a.name === b.name && a.message === b.message;
1062
+
1063
+ case 'RegExp':
1064
+ if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
1065
+ return false;
1066
+ }
1067
+
1068
+ break;
1069
+ }
1070
+
1071
+ var idx = stackA.length - 1;
1072
+
1073
+ while (idx >= 0) {
1074
+ if (stackA[idx] === a) {
1075
+ return stackB[idx] === b;
1076
+ }
1077
+
1078
+ idx -= 1;
1079
+ }
1080
+
1081
+ switch (typeA) {
1082
+ case 'Map':
1083
+ if (a.size !== b.size) {
1084
+ return false;
1085
+ }
1086
+
1087
+ return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
1088
+
1089
+ case 'Set':
1090
+ if (a.size !== b.size) {
1091
+ return false;
1092
+ }
1093
+
1094
+ return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
1095
+
1096
+ case 'Arguments':
1097
+ case 'Array':
1098
+ case 'Object':
1099
+ case 'Boolean':
1100
+ case 'Number':
1101
+ case 'String':
1102
+ case 'Date':
1103
+ case 'Error':
1104
+ case 'RegExp':
1105
+ case 'Int8Array':
1106
+ case 'Uint8Array':
1107
+ case 'Uint8ClampedArray':
1108
+ case 'Int16Array':
1109
+ case 'Uint16Array':
1110
+ case 'Int32Array':
1111
+ case 'Uint32Array':
1112
+ case 'Float32Array':
1113
+ case 'Float64Array':
1114
+ case 'ArrayBuffer':
1115
+ break;
1116
+
1117
+ default:
1118
+ // Values of other types are only equal if identical.
1119
+ return false;
1120
+ }
1121
+
1122
+ var keysA = keys$1(a);
1123
+
1124
+ if (keysA.length !== keys$1(b).length) {
1125
+ return false;
1126
+ }
1127
+
1128
+ var extendedStackA = stackA.concat([a]);
1129
+ var extendedStackB = stackB.concat([b]);
1130
+ idx = keysA.length - 1;
1131
+
1132
+ while (idx >= 0) {
1133
+ var key = keysA[idx];
1134
+
1135
+ if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
1136
+ return false;
1137
+ }
1138
+
1139
+ idx -= 1;
1140
+ }
1141
+
1142
+ return true;
1143
+ }
1144
+
1145
+ /**
1146
+ * Returns `true` if its arguments are equivalent, `false` otherwise. Handles
1147
+ * cyclical data structures.
1148
+ *
1149
+ * Dispatches symmetrically to the `equals` methods of both arguments, if
1150
+ * present.
1151
+ *
1152
+ * @func
1153
+ * @memberOf R
1154
+ * @since v0.15.0
1155
+ * @category Relation
1156
+ * @sig a -> b -> Boolean
1157
+ * @param {*} a
1158
+ * @param {*} b
1159
+ * @return {Boolean}
1160
+ * @example
1161
+ *
1162
+ * R.equals(1, 1); //=> true
1163
+ * R.equals(1, '1'); //=> false
1164
+ * R.equals([1, 2, 3], [1, 2, 3]); //=> true
1165
+ *
1166
+ * const a = {}; a.v = a;
1167
+ * const b = {}; b.v = b;
1168
+ * R.equals(a, b); //=> true
1169
+ */
1170
+
1171
+ var equals =
1172
+ /*#__PURE__*/
1173
+ _curry2(function equals(a, b) {
1174
+ return _equals(a, b, [], []);
1175
+ });
1176
+
1177
+ var equals$1 = equals;
1178
+
1179
+ function _isObject(x) {
1180
+ return Object.prototype.toString.call(x) === '[object Object]';
1181
+ }
1182
+
1183
+ /**
1184
+ * Returns the empty value of its argument's type. Ramda defines the empty
1185
+ * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other
1186
+ * types are supported if they define `<Type>.empty`,
1187
+ * `<Type>.prototype.empty` or implement the
1188
+ * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid).
1189
+ *
1190
+ * Dispatches to the `empty` method of the first argument, if present.
1191
+ *
1192
+ * @func
1193
+ * @memberOf R
1194
+ * @since v0.3.0
1195
+ * @category Function
1196
+ * @sig a -> a
1197
+ * @param {*} x
1198
+ * @return {*}
1199
+ * @example
1200
+ *
1201
+ * R.empty(Just(42)); //=> Nothing()
1202
+ * R.empty([1, 2, 3]); //=> []
1203
+ * R.empty('unicorns'); //=> ''
1204
+ * R.empty({x: 1, y: 2}); //=> {}
1205
+ */
1206
+
1207
+ var empty =
1208
+ /*#__PURE__*/
1209
+ _curry1(function empty(x) {
1210
+ return x != null && typeof x['fantasy-land/empty'] === 'function' ? x['fantasy-land/empty']() : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function' ? x.constructor['fantasy-land/empty']() : x != null && typeof x.empty === 'function' ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === 'function' ? x.constructor.empty() : _isArray(x) ? [] : _isString(x) ? '' : _isObject(x) ? {} : _isArguments$1(x) ? function () {
1211
+ return arguments;
1212
+ }() : void 0 // else
1213
+ ;
1214
+ });
1215
+
1216
+ var empty$1 = empty;
1217
+
1218
+ /**
1219
+ * Returns `true` if the given value is its type's empty value; `false`
1220
+ * otherwise.
1221
+ *
1222
+ * @func
1223
+ * @memberOf R
1224
+ * @since v0.1.0
1225
+ * @category Logic
1226
+ * @sig a -> Boolean
1227
+ * @param {*} x
1228
+ * @return {Boolean}
1229
+ * @see R.empty
1230
+ * @example
1231
+ *
1232
+ * R.isEmpty([1, 2, 3]); //=> false
1233
+ * R.isEmpty([]); //=> true
1234
+ * R.isEmpty(''); //=> true
1235
+ * R.isEmpty(null); //=> false
1236
+ * R.isEmpty({}); //=> true
1237
+ * R.isEmpty({length: 0}); //=> false
1238
+ */
1239
+
1240
+ var isEmpty =
1241
+ /*#__PURE__*/
1242
+ _curry1(function isEmpty(x) {
1243
+ return x != null && equals$1(x, empty$1(x));
1244
+ });
1245
+
1246
+ var isEmpty$1 = isEmpty;
1247
+
1248
+ var css_248z = "/*\n Do not edit directly\n Generated on Wed, 27 Apr 2022 11:58:36 GMT\n*/\nol {\n padding: 0;\n margin: 0;\n list-style: none;\n}\n\n[role=grid i] {\n position: relative;\n z-index: 0;\n display: grid;\n margin: auto;\n grid-template-areas: \". column-headers\" \"row-headers calendar\";\n grid-template-columns: min-content auto;\n inline-size: max(100%, 500px);\n min-inline-size: 880px;\n}\n\n.row-headers {\n display: grid;\n grid-area: row-headers;\n grid-template-rows: repeat(24, 1fr);\n margin-inline-end: 2px;\n}\n.row-headers > [role=rowheader i] {\n display: flex;\n align-items: flex-end;\n justify-content: flex-end;\n}\n.row-headers > [role=rowheader i] > time {\n font: 400 ultra-condensed 12px / 16px SpeziaWebVariable;\n letter-spacing: 0px;\n text-decoration: none;\n text-transform: none;\n font-size: small;\n line-height: 1;\n text-transform: uppercase;\n white-space: nowrap;\n}\n\n.calendar-row {\n display: contents;\n}\n\n.calendar-grid-presentation {\n display: grid;\n overflow: hidden;\n background-color: var(--vvd-color-surface-2dp);\n border-radius: 6px;\n counter-reset: listing;\n filter: var(--vvd-shadow-surface-2dp);\n gap: 1px;\n grid-area: calendar;\n grid-auto-flow: column;\n grid-template: repeat(24, 1fr)/repeat(7, 1fr);\n}\n\n.hours {\n display: contents;\n}\n.hours > [role=listitem i] {\n position: relative;\n grid-column: 1/8;\n grid-row: var(--row);\n min-block-size: 48px;\n pointer-events: none;\n}\n.hours > [role=listitem i]:not(:first-child)::after {\n position: absolute;\n border-block-end: var(--vvd-color-neutral-20) 1px solid;\n content: \"\";\n inline-size: 100%;\n margin-block-start: -1px;\n}\n.hours > [role=listitem i]:nth-child(24n+1) {\n --row: 1;\n}\n.hours > [role=listitem i]:nth-child(24n+2) {\n --row: 2;\n}\n.hours > [role=listitem i]:nth-child(24n+3) {\n --row: 3;\n}\n.hours > [role=listitem i]:nth-child(24n+4) {\n --row: 4;\n}\n.hours > [role=listitem i]:nth-child(24n+5) {\n --row: 5;\n}\n.hours > [role=listitem i]:nth-child(24n+6) {\n --row: 6;\n}\n.hours > [role=listitem i]:nth-child(24n+7) {\n --row: 7;\n}\n.hours > [role=listitem i]:nth-child(24n+8) {\n --row: 8;\n}\n.hours > [role=listitem i]:nth-child(24n+9) {\n --row: 9;\n}\n.hours > [role=listitem i]:nth-child(24n+10) {\n --row: 10;\n}\n.hours > [role=listitem i]:nth-child(24n+11) {\n --row: 11;\n}\n.hours > [role=listitem i]:nth-child(24n+12) {\n --row: 12;\n}\n.hours > [role=listitem i]:nth-child(24n+13) {\n --row: 13;\n}\n.hours > [role=listitem i]:nth-child(24n+14) {\n --row: 14;\n}\n.hours > [role=listitem i]:nth-child(24n+15) {\n --row: 15;\n}\n.hours > [role=listitem i]:nth-child(24n+16) {\n --row: 16;\n}\n.hours > [role=listitem i]:nth-child(24n+17) {\n --row: 17;\n}\n.hours > [role=listitem i]:nth-child(24n+18) {\n --row: 18;\n}\n.hours > [role=listitem i]:nth-child(24n+19) {\n --row: 19;\n}\n.hours > [role=listitem i]:nth-child(24n+20) {\n --row: 20;\n}\n.hours > [role=listitem i]:nth-child(24n+21) {\n --row: 21;\n}\n.hours > [role=listitem i]:nth-child(24n+22) {\n --row: 22;\n}\n.hours > [role=listitem i]:nth-child(24n+23) {\n --row: 23;\n}\n.hours > [role=listitem i]:nth-child(24n+24) {\n --row: 24;\n}\n\n[role=gridcell i] {\n display: grid;\n gap: 1px;\n grid-auto-flow: column;\n}\n\n[role=gridcell i],\n[role=columnheader i],\n[role=columnheader i] [role=button i] {\n position: relative;\n}\n[role=gridcell i]::before,\n[role=columnheader i]::before,\n[role=columnheader i] [role=button i]::before {\n position: absolute;\n z-index: -1;\n background-color: var(--vvd-color-info-10);\n content: \"\";\n}\n@supports (inset: 0) {\n [role=gridcell i]::before,\n[role=columnheader i]::before,\n[role=columnheader i] [role=button i]::before {\n inset: 0;\n }\n}\n@supports not (inset: 0) {\n [role=gridcell i]::before,\n[role=columnheader i]::before,\n[role=columnheader i] [role=button i]::before {\n top: 0;\n right: 0;\n bottom: 0;\n left: 0;\n }\n}\n[role=gridcell i]:focus,\n[role=columnheader i]:focus,\n[role=columnheader i] [role=button i]:focus {\n outline: none;\n}\n[role=gridcell i]:not(:focus)::before,\n[role=columnheader i]:not(:focus)::before,\n[role=columnheader i] [role=button i]:not(:focus)::before {\n display: none;\n}\n\n.columns {\n display: contents;\n}\n.columns > [role=gridcell i] {\n position: relative;\n grid-column: var(--column);\n grid-row: 1/25;\n}\n.columns > [role=gridcell i]:nth-child(1) {\n --column: 1;\n}\n.columns > [role=gridcell i]:nth-child(2) {\n --column: 2;\n}\n.columns > [role=gridcell i]:nth-child(3) {\n --column: 3;\n}\n.columns > [role=gridcell i]:nth-child(4) {\n --column: 4;\n}\n.columns > [role=gridcell i]:nth-child(5) {\n --column: 5;\n}\n.columns > [role=gridcell i]:nth-child(6) {\n --column: 6;\n}\n.columns > [role=gridcell i]:nth-child(7) {\n --column: 7;\n}\n.columns > [role=gridcell i]:not(:first-child)::after {\n position: absolute;\n block-size: 100%;\n border-inline-end: var(--vvd-color-neutral-20) 1px solid;\n content: \"\";\n margin-inline-start: -1px;\n}\n\n.column-headers {\n display: grid;\n grid-area: column-headers;\n grid-template-columns: repeat(7, 1fr);\n}\n.column-headers [role=columnheader i] h2 {\n font: 500 condensed 20px / 28px SpeziaWebVariable;\n letter-spacing: 0px;\n text-decoration: none;\n text-transform: none;\n display: grid;\n align-items: baseline;\n margin: 0;\n grid-template-columns: 1fr auto 1fr;\n}\n.column-headers [role=columnheader i] h2 > em {\n font: inherit;\n inline-size: min-content;\n}\n@supports (inset: 0) {\n .column-headers [role=columnheader i] h2 > em {\n inset-inline-start: 0;\n }\n}\n@supports not (inset: 0) {\n .column-headers [role=columnheader i] h2 > em {\n left: 0;\n }\n}\n.column-headers [role=columnheader i] h2 > small {\n font: 400 ultra-condensed 12px / 16px SpeziaWebVariable;\n letter-spacing: 0px;\n text-decoration: none;\n text-transform: none;\n text-transform: uppercase;\n}";
1249
+ styleInject(css_248z);
1250
+
1251
+ const ARROW_UP = 'ArrowUp';
1252
+ const ARROW_RIGHT = 'ArrowRight';
1253
+ const ARROW_DOWN = 'ArrowDown';
1254
+ const ARROW_LEFT = 'ArrowLeft';
1255
+ function isCellOrHeader(el) {
1256
+ return el instanceof HTMLElement && (el.matches('[role="gridcell"i]') || el.matches('[role="columnheader"i]'));
1257
+ }
1258
+
1259
+ const getCellOrHeader = f => f.matches('[role="columnheader"i]') ? '[role="gridcell"i]' : '[role="columnheader"i]';
1260
+
1261
+ function getNextFocusableGridElement(key, activeElement) {
1262
+ if (activeElement.parentNode instanceof HTMLElement) {
1263
+ switch (key) {
1264
+ case ARROW_RIGHT:
1265
+ return activeElement.nextElementSibling || activeElement.parentNode.firstElementChild;
1266
+
1267
+ case ARROW_LEFT:
1268
+ return activeElement.previousElementSibling || activeElement.parentNode.lastElementChild;
1269
+
1270
+ case ARROW_UP:
1271
+ case ARROW_DOWN:
1272
+ {
1273
+ const {
1274
+ children
1275
+ } = activeElement.parentNode;
1276
+ const i = Array.from(children).indexOf(activeElement);
1277
+ return this.shadowRoot.querySelector(`${getCellOrHeader(activeElement)}:nth-child(${i + 1})`);
1278
+ }
1279
+ }
1280
+ }
1281
+ }
1282
+ function getHeaderDescendantGridCell(key, activeElement) {
1283
+ if (key !== ARROW_DOWN) {
1284
+ return;
1285
+ }
1286
+
1287
+ const header = activeElement.closest('[role="columnheader"i]');
1288
+ const columnHeaders = this.shadowRoot.querySelectorAll('[role="columnheader"i]');
1289
+ const i = Array.from(columnHeaders).indexOf(header);
1290
+ return this.shadowRoot.querySelector(`[role="gridcell"i]:nth-child(${i + 1})`);
1291
+ }
1292
+
1293
+ function getDay(el) {
1294
+ const cellOrHeader = el.closest('[role="gridcell"i], [role="columnheader"i]');
1295
+
1296
+ if (cellOrHeader) {
1297
+ const {
1298
+ parentElement
1299
+ } = cellOrHeader;
1300
+
1301
+ if (parentElement) {
1302
+ return parentElement.children && Array.from(parentElement.children).indexOf(cellOrHeader);
1303
+ }
1304
+ }
1305
+ }
1306
+
1307
+ function getHour(e, el, hours) {
1308
+ const rowHeaderOrCell = el.closest('[role="rowheader"], [role="gridcell"i]');
1309
+
1310
+ if (rowHeaderOrCell) {
1311
+ const DOMRect = rowHeaderOrCell.getBoundingClientRect();
1312
+ const offsetY = e.clientY - DOMRect.y;
1313
+ const hourHeight = DOMRect.height / hours;
1314
+ const hour = offsetY / hourHeight;
1315
+ return Math.round((hour + Number.EPSILON) * 100) / 100;
1316
+ }
1317
+ }
1318
+
1319
+ const getEventContext = function getEventContext(e) {
1320
+ if (!(e instanceof KeyboardEvent || e instanceof MouseEvent)) {
1321
+ throw new Error('Invalid event. Event must be instance of KeyboardEvent or MouseEvent');
1322
+ }
1323
+
1324
+ const [el] = e.composedPath();
1325
+
1326
+ if (!(el && el instanceof HTMLElement && this.shadowRoot.contains(el))) {
1327
+ throw new Error('Invalid event. Event must contain a target object which is a direct descendant of calendar');
1328
+ }
1329
+
1330
+ const day = getDay(el);
1331
+ let hour;
1332
+
1333
+ if (e instanceof MouseEvent) {
1334
+ hour = getHour(e, el, this._hours);
1335
+ }
1336
+
1337
+ const context = Object.assign(Object.assign({}, day != undefined && {
1338
+ day
1339
+ }), hour != undefined && {
1340
+ hour
1341
+ });
1342
+ return not$1(isEmpty$1(context)) ? context : null;
1343
+ };
1344
+
1345
+ class Calendar extends FoundationElement {
1346
+ constructor() {
1347
+ super(...arguments);
1348
+ this.hour12 = false;
1349
+ this._hours = 24;
1350
+ this._days = 7;
1351
+ this.hoursAsDatetime = Array.from({
1352
+ length: this._hours - 1
1353
+ }).fill(new Date(new Date().setHours(0, 0, 0))).map((d, i) => new Date(d.setHours(++i)));
1354
+
1355
+ this._generateDaysArr = dateArr => {
1356
+ if (dateArr.length == this._days) {
1357
+ return dateArr;
1358
+ }
1359
+
1360
+ const lastDate = new Date(dateArr[dateArr.length - 1]);
1361
+ lastDate.setDate(lastDate.getDate() + 1);
1362
+ return this._generateDaysArr([...dateArr, lastDate]);
1363
+ };
1364
+
1365
+ this.getEventContext = getEventContext;
1366
+ }
1367
+
1368
+ arrowKeysInteractions(key) {
1369
+ const activeElement = this.shadowRoot.activeElement;
1370
+ let focusNext;
1371
+
1372
+ if (isCellOrHeader(activeElement)) {
1373
+ focusNext = getNextFocusableGridElement.call(this, key, activeElement);
1374
+ } else if (activeElement === null || activeElement === void 0 ? void 0 : activeElement.matches('em[role="button"i]')) {
1375
+ focusNext = getHeaderDescendantGridCell.call(this, key, activeElement);
1376
+ } else {
1377
+ focusNext = this.shadowRoot.querySelector('[role="columnheader"i]');
1378
+ }
1379
+
1380
+ this.moveTo(focusNext);
1381
+ }
1382
+
1383
+ moveTo(el) {
1384
+ const onBlur = ({
1385
+ target
1386
+ }) => target.setAttribute('tabindex', '-1');
1387
+
1388
+ el === null || el === void 0 ? void 0 : el.addEventListener('blur', onBlur, {
1389
+ once: true
1390
+ });
1391
+ el === null || el === void 0 ? void 0 : el.setAttribute('tabindex', '0');
1392
+ el === null || el === void 0 ? void 0 : el.focus();
1393
+ }
1394
+
1395
+ onKeydown({
1396
+ key
1397
+ }) {
1398
+ const isArrow = [ARROW_UP, ARROW_RIGHT, ARROW_DOWN, ARROW_LEFT].some(predefinedKey => predefinedKey == key);
1399
+
1400
+ if (isArrow) {
1401
+ this.arrowKeysInteractions(key);
1402
+ }
1403
+
1404
+ return !isArrow;
1405
+ }
1406
+
1407
+ }
1408
+
1409
+ __decorate([attr, __metadata("design:type", Object)], Calendar.prototype, "datetime", void 0);
1410
+
1411
+ __decorate([attr({
1412
+ attribute: 'start-day'
1413
+ }), __metadata("design:type", String)], Calendar.prototype, "startDay", void 0);
1414
+
1415
+ __decorate([attr, __metadata("design:type", Object)], Calendar.prototype, "locales", void 0);
1416
+
1417
+ __decorate([attr({
1418
+ mode: 'boolean'
1419
+ }), __metadata("design:type", Object)], Calendar.prototype, "hour12", void 0);
1420
+
1421
+ function getValidDateString(date) {
1422
+ const twoDigit = num => `0${num}`.slice(-2);
1423
+
1424
+ return `${date.getFullYear()}-${twoDigit(date.getMonth() + 1)}-${twoDigit(date.getDate())}`;
1425
+ }
1426
+ const weekdaysMap = new Map([['sunday', 0], ['monday', 1]]);
1427
+ function getFirstDateOfTheWeek(date = new Date(), startDay) {
1428
+ date = new Date(date);
1429
+ let num = weekdaysMap.get(startDay);
1430
+ num !== null && num !== void 0 ? num : num = 1;
1431
+ const day = date.getDate() - (date.getDay() + 7 - num) % 7;
1432
+ return new Date(date.setDate(day));
1433
+ }
1434
+
1435
+ let _2 = t => t,
1436
+ _t,
1437
+ _t2,
1438
+ _t3,
1439
+ _t4,
1440
+ _t5,
1441
+ _t6,
1442
+ _t7;
1443
+
1444
+ const HoursTemplate = () => {
1445
+ return html(_t || (_t = _2`
1446
+ <div class="row-headers" role="presentation">
1447
+ ${0}
1448
+ </div>`), repeat(x => x.hoursAsDatetime, html(_t2 || (_t2 = _2`<span role="rowheader">
1449
+ <time datetime="${0}">
1450
+ ${0}
1451
+ </time>
1452
+ </span>`), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
1453
+ hour: 'numeric',
1454
+ minute: 'numeric',
1455
+ hour12: false
1456
+ }).format(x), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
1457
+ hour: 'numeric',
1458
+ hour12: c.parent.hour12
1459
+ }).format(x))));
1460
+ };
1461
+
1462
+ const DaysTemplate = () => {
1463
+ return html(_t3 || (_t3 = _2`
1464
+ <div class="column-headers" role="row">
1465
+ ${0}
1466
+ </div>`), repeat(x => x._generateDaysArr([getFirstDateOfTheWeek(x.datetime, x.startDay)]), html(_t4 || (_t4 = _2`
1467
+ <div role="columnheader" tabindex="-1">
1468
+ <time datetime=${0}>
1469
+ <h2>
1470
+ <!-- TODO add to column aria-labelledby or describedby to count
1471
+ events and related day e.g. "3 events, Sunday, March 8" -->
1472
+ <em tabindex="0" role="button" aria-label=${0}>
1473
+ ${0}
1474
+ </em>
1475
+ <small aria-hidden="true">
1476
+ ${0}
1477
+ </small>
1478
+ </h2>
1479
+ </time>
1480
+ </div>`), x => getValidDateString(x), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
1481
+ weekday: 'long',
1482
+ month: 'long',
1483
+ day: 'numeric'
1484
+ }).format(x), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
1485
+ day: '2-digit'
1486
+ }).format(x), (x, c) => new Intl.DateTimeFormat(c.parent.locales, {
1487
+ weekday: 'short'
1488
+ }).format(x))));
1489
+ };
1490
+
1491
+ const ColumnTemplate = html(_t5 || (_t5 = _2`
1492
+ <div role="gridcell" tabindex="-1">
1493
+ <slot name="day-${0}"></slot>
1494
+ </div>
1495
+ `), (_, c) => c.index);
1496
+ const CalendarTemplate = () => html(_t6 || (_t6 = _2`
1497
+ <div role="grid" @keydown=${0}>
1498
+ ${0}
1499
+ <div role="row" class="calendar-row">
1500
+ ${0}
1501
+ <div class="calendar-grid-presentation" role="presentation">
1502
+ <div class="hours" role="list">
1503
+ ${0}
1504
+ </div>
1505
+ <div class="columns" role="presentation">
1506
+ ${0}
1507
+ </div>
1508
+ <slot></slot>
1509
+ </div>
1510
+ </div>
1511
+ </div>
1512
+ `), (x, c) => x.onKeydown(c.event), DaysTemplate, HoursTemplate, repeat(x => Array.from({
1513
+ length: x.hoursAsDatetime.length + 1
1514
+ }), html(_t7 || (_t7 = _2`
1515
+ <div role="listitem"></div>`))), repeat(x => Array.from(Array(x._days)), ColumnTemplate, {
1516
+ positioning: true
1517
+ }));
1518
+
1519
+ const vividCalendar = Calendar.compose({
1520
+ baseName: 'calendar',
1521
+ template: CalendarTemplate,
1522
+ styles: css_248z
1523
+ });
1524
+ designSystem.register(vividCalendar());
1525
+
1526
+ export { vividCalendar };