@vonage/vivid 3.0.0-test.0 → 3.0.1

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