@vonage/vivid 3.0.0-next.3 → 3.0.0-next.32

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 (152) hide show
  1. package/README.md +49 -4
  2. package/accordion/index.js +61 -0
  3. package/accordion-item/index.js +133 -0
  4. package/action-group/index.js +49 -0
  5. package/badge/index.js +27 -22
  6. package/banner/index.js +148 -0
  7. package/breadcrumb/index.js +41 -150
  8. package/breadcrumb-item/index.js +18 -8
  9. package/button/index.js +40 -663
  10. package/calendar/index.js +1550 -0
  11. package/calendar-event/index.js +117 -0
  12. package/card/index.js +134 -0
  13. package/checkbox/index.js +176 -0
  14. package/dialog/index.js +277 -0
  15. package/divider/index.js +88 -0
  16. package/elevation/index.js +4 -38
  17. package/fab/index.js +101 -0
  18. package/focus/index.js +20 -3
  19. package/header/index.js +68 -0
  20. package/icon/index.js +40 -5
  21. package/index.d.ts +1 -0
  22. package/index.js +50 -14
  23. package/layout/index.js +5 -5
  24. package/lib/accordion/accordion.d.ts +9 -0
  25. package/lib/accordion/accordion.template.d.ts +4 -0
  26. package/lib/accordion/index.d.ts +2 -0
  27. package/lib/accordion-item/accordion-item.d.ts +13 -0
  28. package/lib/accordion-item/accordion-item.template.d.ts +4 -0
  29. package/lib/accordion-item/index.d.ts +4 -0
  30. package/lib/action-group/action-group.d.ts +10 -0
  31. package/lib/action-group/action-group.template.d.ts +4 -0
  32. package/lib/action-group/index.d.ts +2 -0
  33. package/lib/badge/badge.d.ts +8 -8
  34. package/lib/badge/index.d.ts +1 -1
  35. package/lib/banner/banner.d.ts +20 -0
  36. package/lib/banner/banner.template.d.ts +4 -0
  37. package/lib/banner/index.d.ts +3 -0
  38. package/lib/breadcrumb/breadcrumb.template.d.ts +4 -0
  39. package/lib/breadcrumb-item/breadcrumb-item.d.ts +1 -1
  40. package/lib/breadcrumb-item/breadcrumb-item.template.d.ts +0 -1
  41. package/lib/breadcrumb-item/index.d.ts +2 -0
  42. package/lib/button/button.d.ts +9 -8
  43. package/lib/button/index.d.ts +2 -19
  44. package/lib/calendar/calendar.d.ts +13 -0
  45. package/lib/calendar/calendar.template.d.ts +4 -0
  46. package/lib/calendar/helpers/calendar.date-functions.d.ts +2 -0
  47. package/lib/calendar/helpers/calendar.event-context.d.ts +6 -0
  48. package/lib/calendar/helpers/calendar.keyboard-interactions.d.ts +9 -0
  49. package/lib/calendar/index.d.ts +2 -0
  50. package/lib/calendar-event/calendar-event.d.ts +14 -0
  51. package/lib/calendar-event/calendar-event.template.d.ts +4 -0
  52. package/lib/calendar-event/index.d.ts +2 -0
  53. package/lib/card/card.d.ts +10 -0
  54. package/lib/card/card.template.d.ts +4 -0
  55. package/lib/card/index.d.ts +4 -0
  56. package/lib/checkbox/checkbox.d.ts +5 -0
  57. package/lib/checkbox/checkbox.template.d.ts +4 -0
  58. package/lib/checkbox/index.d.ts +4 -0
  59. package/lib/components.d.ts +23 -5
  60. package/lib/dialog/dialog.d.ts +20 -0
  61. package/lib/dialog/dialog.template.d.ts +4 -0
  62. package/lib/dialog/index.d.ts +5 -0
  63. package/lib/divider/divider.d.ts +3 -0
  64. package/lib/divider/divider.template.d.ts +4 -0
  65. package/lib/divider/index.d.ts +2 -0
  66. package/lib/elevation/elevation.d.ts +2 -1
  67. package/lib/elevation/index.d.ts +1 -1
  68. package/lib/enums.d.ts +14 -7
  69. package/lib/fab/fab.d.ts +13 -0
  70. package/lib/fab/fab.template.d.ts +4 -0
  71. package/lib/fab/index.d.ts +4 -0
  72. package/lib/focus/index.d.ts +1 -1
  73. package/lib/header/header.d.ts +5 -0
  74. package/lib/header/header.template.d.ts +4 -0
  75. package/lib/header/index.d.ts +3 -0
  76. package/lib/icon/icon.d.ts +4 -5
  77. package/lib/layout/index.d.ts +1 -1
  78. package/lib/layout/layout.d.ts +3 -3
  79. package/lib/note/index.d.ts +2 -0
  80. package/lib/note/note.d.ts +10 -0
  81. package/lib/note/note.template.d.ts +5 -0
  82. package/lib/popup/index.d.ts +4 -0
  83. package/lib/popup/popup.d.ts +17 -0
  84. package/lib/popup/popup.template.d.ts +4 -0
  85. package/lib/progress/index.d.ts +2 -0
  86. package/lib/progress/progress.d.ts +9 -0
  87. package/lib/progress/progress.template.d.ts +5 -0
  88. package/lib/progress-ring/index.d.ts +2 -0
  89. package/lib/progress-ring/progress-ring.d.ts +7 -0
  90. package/lib/progress-ring/progress-ring.template.d.ts +4 -0
  91. package/lib/side-drawer/index.d.ts +2 -0
  92. package/lib/side-drawer/side-drawer.d.ts +7 -0
  93. package/lib/side-drawer/side-drawer.template.d.ts +4 -0
  94. package/lib/sidenav/index.d.ts +2 -0
  95. package/lib/sidenav/sidenav.d.ts +3 -0
  96. package/lib/sidenav/sidenav.template.d.ts +4 -0
  97. package/lib/sidenav-item/index.d.ts +1 -0
  98. package/lib/sidenav-item/sidenav-item.d.ts +4 -5
  99. package/lib/text/index.d.ts +2 -0
  100. package/lib/text/text.d.ts +10 -0
  101. package/lib/text/text.template.d.ts +4 -0
  102. package/lib/text-anchor/text-anchor.d.ts +4 -1
  103. package/lib/text-field/index.d.ts +4 -0
  104. package/lib/text-field/text-field.d.ts +23 -0
  105. package/lib/text-field/text-field.template.d.ts +5 -0
  106. package/lib/tooltip/index.d.ts +3 -0
  107. package/lib/tooltip/tooltip.d.ts +8 -0
  108. package/lib/tooltip/tooltip.template.d.ts +4 -0
  109. package/note/index.js +68 -0
  110. package/package.json +39 -6
  111. package/popup/index.js +2118 -0
  112. package/progress/index.js +107 -0
  113. package/progress-ring/index.js +82 -0
  114. package/shared/_has.js +58 -0
  115. package/shared/affix.js +10 -25
  116. package/shared/anchor.js +10 -3
  117. package/shared/aria-global.js +20 -20
  118. package/shared/base-progress.js +70 -0
  119. package/shared/breadcrumb-item.js +2 -2
  120. package/shared/button.js +195 -0
  121. package/shared/calendar-event.js +26 -0
  122. package/shared/dialog-polyfill.esm.js +858 -0
  123. package/shared/enums.js +79 -0
  124. package/shared/es.object.assign.js +69 -0
  125. package/shared/export.js +972 -0
  126. package/shared/focus.js +5 -0
  127. package/shared/focus2.js +11 -0
  128. package/shared/form-associated.js +548 -0
  129. package/shared/icon.js +1389 -0
  130. package/shared/index.js +4940 -1426
  131. package/shared/index2.js +27 -4901
  132. package/shared/iterators.js +61 -0
  133. package/shared/object-keys.js +13 -0
  134. package/shared/patterns/affix.d.ts +3 -4
  135. package/shared/patterns/focus.d.ts +3 -0
  136. package/shared/patterns/index.d.ts +1 -0
  137. package/shared/slotted.js +119 -0
  138. package/shared/text-anchor.js +12 -0
  139. package/shared/text-anchor.template.js +16 -6
  140. package/shared/to-string.js +51 -0
  141. package/shared/web.dom-collections.iterator.js +46 -1059
  142. package/shared/when.js +15 -0
  143. package/side-drawer/index.js +82 -0
  144. package/sidenav/index.js +17 -0
  145. package/sidenav-item/index.js +24 -61
  146. package/styles/themes/dark.css +16 -4
  147. package/styles/themes/light.css +16 -4
  148. package/text/index.js +48 -0
  149. package/text-anchor/index.js +13 -13
  150. package/text-field/index.js +411 -0
  151. package/tooltip/index.js +70 -0
  152. package/shared/index3.js +0 -21
package/popup/index.js ADDED
@@ -0,0 +1,2118 @@
1
+ import '../shared/index2.js';
2
+ import '../button/index.js';
3
+ import { F as FoundationElement, c as __classPrivateFieldGet, i as __classPrivateFieldSet, _ as __decorate, a as attr, b as __metadata, h as html, d as designSystem } from '../shared/index.js';
4
+ import { s as speciesConstructor$1, f as functionApply } from '../shared/icon.js';
5
+ import { o as objectCreate } from '../shared/web.dom-collections.iterator.js';
6
+ import '../shared/es.object.assign.js';
7
+ import { j as anObject$3, e as fails$5, g as global$3, v as functionCall, f as functionUncurryThis, Q as shared$1, y as internalState, _ as _export, w as wellKnownSymbol$2, u as defineBuiltIn$1, K as createNonEnumerableProperty$1, x as isObject$1, c as classofRaw, B as requireObjectCoercible$2, R as toIntegerOrInfinity$1, S as toPropertyKey$1, o as objectDefineProperty, J as createPropertyDescriptor$1, A as lengthOfArrayLike$1, T as toAbsoluteIndex$1, i as isCallable$1, U as toLength$1, z as getMethod$1 } from '../shared/export.js';
8
+ import { t as toString$3 } from '../shared/to-string.js';
9
+ import { a as keyEscape } from '../shared/form-associated.js';
10
+ import { s as styleInject } from '../shared/style-inject.es.js';
11
+ import { w as when } from '../shared/when.js';
12
+ import { r as ref } from '../shared/aria-global.js';
13
+ import { c as classNames } from '../shared/class-names.js';
14
+ import '../icon/index.js';
15
+ import '../shared/iterators.js';
16
+ import '../shared/_has.js';
17
+ import '../focus/index.js';
18
+ import '../shared/focus.js';
19
+ import '../shared/affix.js';
20
+ import '../shared/button.js';
21
+ import '../shared/apply-mixins.js';
22
+ import '../shared/focus2.js';
23
+ import '../shared/object-keys.js';
24
+
25
+ var anObject$2 = anObject$3;
26
+
27
+ // `RegExp.prototype.flags` getter implementation
28
+ // https://tc39.es/ecma262/#sec-get-regexp.prototype.flags
29
+ var regexpFlags$1 = function () {
30
+ var that = anObject$2(this);
31
+ var result = '';
32
+ if (that.hasIndices) result += 'd';
33
+ if (that.global) result += 'g';
34
+ if (that.ignoreCase) result += 'i';
35
+ if (that.multiline) result += 'm';
36
+ if (that.dotAll) result += 's';
37
+ if (that.unicode) result += 'u';
38
+ if (that.sticky) result += 'y';
39
+ return result;
40
+ };
41
+
42
+ var fails$4 = fails$5;
43
+ var global$2 = global$3;
44
+
45
+ // babel-minify and Closure Compiler transpiles RegExp('a', 'y') -> /a/y and it causes SyntaxError
46
+ var $RegExp$2 = global$2.RegExp;
47
+
48
+ var UNSUPPORTED_Y$2 = fails$4(function () {
49
+ var re = $RegExp$2('a', 'y');
50
+ re.lastIndex = 2;
51
+ return re.exec('abcd') != null;
52
+ });
53
+
54
+ // UC Browser bug
55
+ // https://github.com/zloirock/core-js/issues/1008
56
+ var MISSED_STICKY = UNSUPPORTED_Y$2 || fails$4(function () {
57
+ return !$RegExp$2('a', 'y').sticky;
58
+ });
59
+
60
+ var BROKEN_CARET = UNSUPPORTED_Y$2 || fails$4(function () {
61
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=773687
62
+ var re = $RegExp$2('^r', 'gy');
63
+ re.lastIndex = 2;
64
+ return re.exec('str') != null;
65
+ });
66
+
67
+ var regexpStickyHelpers = {
68
+ BROKEN_CARET: BROKEN_CARET,
69
+ MISSED_STICKY: MISSED_STICKY,
70
+ UNSUPPORTED_Y: UNSUPPORTED_Y$2
71
+ };
72
+
73
+ var fails$3 = fails$5;
74
+ var global$1 = global$3;
75
+
76
+ // babel-minify and Closure Compiler transpiles RegExp('.', 's') -> /./s and it causes SyntaxError
77
+ var $RegExp$1 = global$1.RegExp;
78
+
79
+ var regexpUnsupportedDotAll = fails$3(function () {
80
+ var re = $RegExp$1('.', 's');
81
+ return !(re.dotAll && re.exec('\n') && re.flags === 's');
82
+ });
83
+
84
+ var fails$2 = fails$5;
85
+ var global = global$3;
86
+
87
+ // babel-minify and Closure Compiler transpiles RegExp('(?<a>b)', 'g') -> /(?<a>b)/g and it causes SyntaxError
88
+ var $RegExp = global.RegExp;
89
+
90
+ var regexpUnsupportedNcg = fails$2(function () {
91
+ var re = $RegExp('(?<a>b)', 'g');
92
+ return re.exec('b').groups.a !== 'b' ||
93
+ 'b'.replace(re, '$<a>c') !== 'bc';
94
+ });
95
+
96
+ /* eslint-disable regexp/no-empty-capturing-group, regexp/no-empty-group, regexp/no-lazy-ends -- testing */
97
+ /* eslint-disable regexp/no-useless-quantifier -- testing */
98
+ var call$2 = functionCall;
99
+ var uncurryThis$3 = functionUncurryThis;
100
+ var toString$2 = toString$3;
101
+ var regexpFlags = regexpFlags$1;
102
+ var stickyHelpers$1 = regexpStickyHelpers;
103
+ var shared = shared$1.exports;
104
+ var create = objectCreate;
105
+ var getInternalState = internalState.get;
106
+ var UNSUPPORTED_DOT_ALL = regexpUnsupportedDotAll;
107
+ var UNSUPPORTED_NCG = regexpUnsupportedNcg;
108
+
109
+ var nativeReplace = shared('native-string-replace', String.prototype.replace);
110
+ var nativeExec = RegExp.prototype.exec;
111
+ var patchedExec = nativeExec;
112
+ var charAt$2 = uncurryThis$3(''.charAt);
113
+ var indexOf = uncurryThis$3(''.indexOf);
114
+ var replace = uncurryThis$3(''.replace);
115
+ var stringSlice$2 = uncurryThis$3(''.slice);
116
+
117
+ var UPDATES_LAST_INDEX_WRONG = (function () {
118
+ var re1 = /a/;
119
+ var re2 = /b*/g;
120
+ call$2(nativeExec, re1, 'a');
121
+ call$2(nativeExec, re2, 'a');
122
+ return re1.lastIndex !== 0 || re2.lastIndex !== 0;
123
+ })();
124
+
125
+ var UNSUPPORTED_Y$1 = stickyHelpers$1.BROKEN_CARET;
126
+
127
+ // nonparticipating capturing group, copied from es5-shim's String#split patch.
128
+ var NPCG_INCLUDED = /()??/.exec('')[1] !== undefined;
129
+
130
+ var PATCH = UPDATES_LAST_INDEX_WRONG || NPCG_INCLUDED || UNSUPPORTED_Y$1 || UNSUPPORTED_DOT_ALL || UNSUPPORTED_NCG;
131
+
132
+ if (PATCH) {
133
+ patchedExec = function exec(string) {
134
+ var re = this;
135
+ var state = getInternalState(re);
136
+ var str = toString$2(string);
137
+ var raw = state.raw;
138
+ var result, reCopy, lastIndex, match, i, object, group;
139
+
140
+ if (raw) {
141
+ raw.lastIndex = re.lastIndex;
142
+ result = call$2(patchedExec, raw, str);
143
+ re.lastIndex = raw.lastIndex;
144
+ return result;
145
+ }
146
+
147
+ var groups = state.groups;
148
+ var sticky = UNSUPPORTED_Y$1 && re.sticky;
149
+ var flags = call$2(regexpFlags, re);
150
+ var source = re.source;
151
+ var charsAdded = 0;
152
+ var strCopy = str;
153
+
154
+ if (sticky) {
155
+ flags = replace(flags, 'y', '');
156
+ if (indexOf(flags, 'g') === -1) {
157
+ flags += 'g';
158
+ }
159
+
160
+ strCopy = stringSlice$2(str, re.lastIndex);
161
+ // Support anchored sticky behavior.
162
+ if (re.lastIndex > 0 && (!re.multiline || re.multiline && charAt$2(str, re.lastIndex - 1) !== '\n')) {
163
+ source = '(?: ' + source + ')';
164
+ strCopy = ' ' + strCopy;
165
+ charsAdded++;
166
+ }
167
+ // ^(? + rx + ) is needed, in combination with some str slicing, to
168
+ // simulate the 'y' flag.
169
+ reCopy = new RegExp('^(?:' + source + ')', flags);
170
+ }
171
+
172
+ if (NPCG_INCLUDED) {
173
+ reCopy = new RegExp('^' + source + '$(?!\\s)', flags);
174
+ }
175
+ if (UPDATES_LAST_INDEX_WRONG) lastIndex = re.lastIndex;
176
+
177
+ match = call$2(nativeExec, sticky ? reCopy : re, strCopy);
178
+
179
+ if (sticky) {
180
+ if (match) {
181
+ match.input = stringSlice$2(match.input, charsAdded);
182
+ match[0] = stringSlice$2(match[0], charsAdded);
183
+ match.index = re.lastIndex;
184
+ re.lastIndex += match[0].length;
185
+ } else re.lastIndex = 0;
186
+ } else if (UPDATES_LAST_INDEX_WRONG && match) {
187
+ re.lastIndex = re.global ? match.index + match[0].length : lastIndex;
188
+ }
189
+ if (NPCG_INCLUDED && match && match.length > 1) {
190
+ // Fix browsers whose `exec` methods don't consistently return `undefined`
191
+ // for NPCG, like IE8. NOTE: This doesn' work for /(.?)?/
192
+ call$2(nativeReplace, match[0], reCopy, function () {
193
+ for (i = 1; i < arguments.length - 2; i++) {
194
+ if (arguments[i] === undefined) match[i] = undefined;
195
+ }
196
+ });
197
+ }
198
+
199
+ if (match && groups) {
200
+ match.groups = object = create(null);
201
+ for (i = 0; i < groups.length; i++) {
202
+ group = groups[i];
203
+ object[group[0]] = match[group[1]];
204
+ }
205
+ }
206
+
207
+ return match;
208
+ };
209
+ }
210
+
211
+ var regexpExec$3 = patchedExec;
212
+
213
+ var $ = _export;
214
+ var exec$1 = regexpExec$3;
215
+
216
+ // `RegExp.prototype.exec` method
217
+ // https://tc39.es/ecma262/#sec-regexp.prototype.exec
218
+ $({ target: 'RegExp', proto: true, forced: /./.exec !== exec$1 }, {
219
+ exec: exec$1
220
+ });
221
+
222
+ // TODO: Remove from `core-js@4` since it's moved to entry points
223
+
224
+ var uncurryThis$2 = functionUncurryThis;
225
+ var defineBuiltIn = defineBuiltIn$1;
226
+ var regexpExec$2 = regexpExec$3;
227
+ var fails$1 = fails$5;
228
+ var wellKnownSymbol$1 = wellKnownSymbol$2;
229
+ var createNonEnumerableProperty = createNonEnumerableProperty$1;
230
+
231
+ var SPECIES = wellKnownSymbol$1('species');
232
+ var RegExpPrototype = RegExp.prototype;
233
+
234
+ var fixRegexpWellKnownSymbolLogic = function (KEY, exec, FORCED, SHAM) {
235
+ var SYMBOL = wellKnownSymbol$1(KEY);
236
+
237
+ var DELEGATES_TO_SYMBOL = !fails$1(function () {
238
+ // String methods call symbol-named RegEp methods
239
+ var O = {};
240
+ O[SYMBOL] = function () { return 7; };
241
+ return ''[KEY](O) != 7;
242
+ });
243
+
244
+ var DELEGATES_TO_EXEC = DELEGATES_TO_SYMBOL && !fails$1(function () {
245
+ // Symbol-named RegExp methods call .exec
246
+ var execCalled = false;
247
+ var re = /a/;
248
+
249
+ if (KEY === 'split') {
250
+ // We can't use real regex here since it causes deoptimization
251
+ // and serious performance degradation in V8
252
+ // https://github.com/zloirock/core-js/issues/306
253
+ re = {};
254
+ // RegExp[@@split] doesn't call the regex's exec method, but first creates
255
+ // a new one. We need to return the patched regex when creating the new one.
256
+ re.constructor = {};
257
+ re.constructor[SPECIES] = function () { return re; };
258
+ re.flags = '';
259
+ re[SYMBOL] = /./[SYMBOL];
260
+ }
261
+
262
+ re.exec = function () { execCalled = true; return null; };
263
+
264
+ re[SYMBOL]('');
265
+ return !execCalled;
266
+ });
267
+
268
+ if (
269
+ !DELEGATES_TO_SYMBOL ||
270
+ !DELEGATES_TO_EXEC ||
271
+ FORCED
272
+ ) {
273
+ var uncurriedNativeRegExpMethod = uncurryThis$2(/./[SYMBOL]);
274
+ var methods = exec(SYMBOL, ''[KEY], function (nativeMethod, regexp, str, arg2, forceStringMethod) {
275
+ var uncurriedNativeMethod = uncurryThis$2(nativeMethod);
276
+ var $exec = regexp.exec;
277
+ if ($exec === regexpExec$2 || $exec === RegExpPrototype.exec) {
278
+ if (DELEGATES_TO_SYMBOL && !forceStringMethod) {
279
+ // The native String method already delegates to @@method (this
280
+ // polyfilled function), leasing to infinite recursion.
281
+ // We avoid it by directly calling the native @@method method.
282
+ return { done: true, value: uncurriedNativeRegExpMethod(regexp, str, arg2) };
283
+ }
284
+ return { done: true, value: uncurriedNativeMethod(str, regexp, arg2) };
285
+ }
286
+ return { done: false };
287
+ });
288
+
289
+ defineBuiltIn(String.prototype, KEY, methods[0]);
290
+ defineBuiltIn(RegExpPrototype, SYMBOL, methods[1]);
291
+ }
292
+
293
+ if (SHAM) createNonEnumerableProperty(RegExpPrototype[SYMBOL], 'sham', true);
294
+ };
295
+
296
+ var isObject = isObject$1;
297
+ var classof$1 = classofRaw;
298
+ var wellKnownSymbol = wellKnownSymbol$2;
299
+
300
+ var MATCH = wellKnownSymbol('match');
301
+
302
+ // `IsRegExp` abstract operation
303
+ // https://tc39.es/ecma262/#sec-isregexp
304
+ var isRegexp = function (it) {
305
+ var isRegExp;
306
+ return isObject(it) && ((isRegExp = it[MATCH]) !== undefined ? !!isRegExp : classof$1(it) == 'RegExp');
307
+ };
308
+
309
+ var uncurryThis$1 = functionUncurryThis;
310
+ var toIntegerOrInfinity = toIntegerOrInfinity$1;
311
+ var toString$1 = toString$3;
312
+ var requireObjectCoercible$1 = requireObjectCoercible$2;
313
+
314
+ var charAt$1 = uncurryThis$1(''.charAt);
315
+ var charCodeAt = uncurryThis$1(''.charCodeAt);
316
+ var stringSlice$1 = uncurryThis$1(''.slice);
317
+
318
+ var createMethod = function (CONVERT_TO_STRING) {
319
+ return function ($this, pos) {
320
+ var S = toString$1(requireObjectCoercible$1($this));
321
+ var position = toIntegerOrInfinity(pos);
322
+ var size = S.length;
323
+ var first, second;
324
+ if (position < 0 || position >= size) return CONVERT_TO_STRING ? '' : undefined;
325
+ first = charCodeAt(S, position);
326
+ return first < 0xD800 || first > 0xDBFF || position + 1 === size
327
+ || (second = charCodeAt(S, position + 1)) < 0xDC00 || second > 0xDFFF
328
+ ? CONVERT_TO_STRING
329
+ ? charAt$1(S, position)
330
+ : first
331
+ : CONVERT_TO_STRING
332
+ ? stringSlice$1(S, position, position + 2)
333
+ : (first - 0xD800 << 10) + (second - 0xDC00) + 0x10000;
334
+ };
335
+ };
336
+
337
+ var stringMultibyte = {
338
+ // `String.prototype.codePointAt` method
339
+ // https://tc39.es/ecma262/#sec-string.prototype.codepointat
340
+ codeAt: createMethod(false),
341
+ // `String.prototype.at` method
342
+ // https://github.com/mathiasbynens/String.prototype.at
343
+ charAt: createMethod(true)
344
+ };
345
+
346
+ var charAt = stringMultibyte.charAt;
347
+
348
+ // `AdvanceStringIndex` abstract operation
349
+ // https://tc39.es/ecma262/#sec-advancestringindex
350
+ var advanceStringIndex$1 = function (S, index, unicode) {
351
+ return index + (unicode ? charAt(S, index).length : 1);
352
+ };
353
+
354
+ var toPropertyKey = toPropertyKey$1;
355
+ var definePropertyModule = objectDefineProperty;
356
+ var createPropertyDescriptor = createPropertyDescriptor$1;
357
+
358
+ var createProperty$1 = function (object, key, value) {
359
+ var propertyKey = toPropertyKey(key);
360
+ if (propertyKey in object) definePropertyModule.f(object, propertyKey, createPropertyDescriptor(0, value));
361
+ else object[propertyKey] = value;
362
+ };
363
+
364
+ var toAbsoluteIndex = toAbsoluteIndex$1;
365
+ var lengthOfArrayLike = lengthOfArrayLike$1;
366
+ var createProperty = createProperty$1;
367
+
368
+ var $Array = Array;
369
+ var max$2 = Math.max;
370
+
371
+ var arraySliceSimple = function (O, start, end) {
372
+ var length = lengthOfArrayLike(O);
373
+ var k = toAbsoluteIndex(start, length);
374
+ var fin = toAbsoluteIndex(end === undefined ? length : end, length);
375
+ var result = $Array(max$2(fin - k, 0));
376
+ for (var n = 0; k < fin; k++, n++) createProperty(result, n, O[k]);
377
+ result.length = n;
378
+ return result;
379
+ };
380
+
381
+ var call$1 = functionCall;
382
+ var anObject$1 = anObject$3;
383
+ var isCallable = isCallable$1;
384
+ var classof = classofRaw;
385
+ var regexpExec$1 = regexpExec$3;
386
+
387
+ var $TypeError = TypeError;
388
+
389
+ // `RegExpExec` abstract operation
390
+ // https://tc39.es/ecma262/#sec-regexpexec
391
+ var regexpExecAbstract = function (R, S) {
392
+ var exec = R.exec;
393
+ if (isCallable(exec)) {
394
+ var result = call$1(exec, R, S);
395
+ if (result !== null) anObject$1(result);
396
+ return result;
397
+ }
398
+ if (classof(R) === 'RegExp') return call$1(regexpExec$1, R, S);
399
+ throw $TypeError('RegExp#exec called on incompatible receiver');
400
+ };
401
+
402
+ var apply = functionApply;
403
+ var call = functionCall;
404
+ var uncurryThis = functionUncurryThis;
405
+ var fixRegExpWellKnownSymbolLogic = fixRegexpWellKnownSymbolLogic;
406
+ var isRegExp = isRegexp;
407
+ var anObject = anObject$3;
408
+ var requireObjectCoercible = requireObjectCoercible$2;
409
+ var speciesConstructor = speciesConstructor$1;
410
+ var advanceStringIndex = advanceStringIndex$1;
411
+ var toLength = toLength$1;
412
+ var toString = toString$3;
413
+ var getMethod = getMethod$1;
414
+ var arraySlice = arraySliceSimple;
415
+ var callRegExpExec = regexpExecAbstract;
416
+ var regexpExec = regexpExec$3;
417
+ var stickyHelpers = regexpStickyHelpers;
418
+ var fails = fails$5;
419
+
420
+ var UNSUPPORTED_Y = stickyHelpers.UNSUPPORTED_Y;
421
+ var MAX_UINT32 = 0xFFFFFFFF;
422
+ var min$2 = Math.min;
423
+ var $push = [].push;
424
+ var exec = uncurryThis(/./.exec);
425
+ var push = uncurryThis($push);
426
+ var stringSlice = uncurryThis(''.slice);
427
+
428
+ // Chrome 51 has a buggy "split" implementation when RegExp#exec !== nativeExec
429
+ // Weex JS has frozen built-in prototypes, so use try / catch wrapper
430
+ var SPLIT_WORKS_WITH_OVERWRITTEN_EXEC = !fails(function () {
431
+ // eslint-disable-next-line regexp/no-empty-group -- required for testing
432
+ var re = /(?:)/;
433
+ var originalExec = re.exec;
434
+ re.exec = function () { return originalExec.apply(this, arguments); };
435
+ var result = 'ab'.split(re);
436
+ return result.length !== 2 || result[0] !== 'a' || result[1] !== 'b';
437
+ });
438
+
439
+ // @@split logic
440
+ fixRegExpWellKnownSymbolLogic('split', function (SPLIT, nativeSplit, maybeCallNative) {
441
+ var internalSplit;
442
+ if (
443
+ 'abbc'.split(/(b)*/)[1] == 'c' ||
444
+ // eslint-disable-next-line regexp/no-empty-group -- required for testing
445
+ 'test'.split(/(?:)/, -1).length != 4 ||
446
+ 'ab'.split(/(?:ab)*/).length != 2 ||
447
+ '.'.split(/(.?)(.?)/).length != 4 ||
448
+ // eslint-disable-next-line regexp/no-empty-capturing-group, regexp/no-empty-group -- required for testing
449
+ '.'.split(/()()/).length > 1 ||
450
+ ''.split(/.?/).length
451
+ ) {
452
+ // based on es5-shim implementation, need to rework it
453
+ internalSplit = function (separator, limit) {
454
+ var string = toString(requireObjectCoercible(this));
455
+ var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
456
+ if (lim === 0) return [];
457
+ if (separator === undefined) return [string];
458
+ // If `separator` is not a regex, use native split
459
+ if (!isRegExp(separator)) {
460
+ return call(nativeSplit, string, separator, lim);
461
+ }
462
+ var output = [];
463
+ var flags = (separator.ignoreCase ? 'i' : '') +
464
+ (separator.multiline ? 'm' : '') +
465
+ (separator.unicode ? 'u' : '') +
466
+ (separator.sticky ? 'y' : '');
467
+ var lastLastIndex = 0;
468
+ // Make `global` and avoid `lastIndex` issues by working with a copy
469
+ var separatorCopy = new RegExp(separator.source, flags + 'g');
470
+ var match, lastIndex, lastLength;
471
+ while (match = call(regexpExec, separatorCopy, string)) {
472
+ lastIndex = separatorCopy.lastIndex;
473
+ if (lastIndex > lastLastIndex) {
474
+ push(output, stringSlice(string, lastLastIndex, match.index));
475
+ if (match.length > 1 && match.index < string.length) apply($push, output, arraySlice(match, 1));
476
+ lastLength = match[0].length;
477
+ lastLastIndex = lastIndex;
478
+ if (output.length >= lim) break;
479
+ }
480
+ if (separatorCopy.lastIndex === match.index) separatorCopy.lastIndex++; // Avoid an infinite loop
481
+ }
482
+ if (lastLastIndex === string.length) {
483
+ if (lastLength || !exec(separatorCopy, '')) push(output, '');
484
+ } else push(output, stringSlice(string, lastLastIndex));
485
+ return output.length > lim ? arraySlice(output, 0, lim) : output;
486
+ };
487
+ // Chakra, V8
488
+ } else if ('0'.split(undefined, 0).length) {
489
+ internalSplit = function (separator, limit) {
490
+ return separator === undefined && limit === 0 ? [] : call(nativeSplit, this, separator, limit);
491
+ };
492
+ } else internalSplit = nativeSplit;
493
+
494
+ return [
495
+ // `String.prototype.split` method
496
+ // https://tc39.es/ecma262/#sec-string.prototype.split
497
+ function split(separator, limit) {
498
+ var O = requireObjectCoercible(this);
499
+ var splitter = separator == undefined ? undefined : getMethod(separator, SPLIT);
500
+ return splitter
501
+ ? call(splitter, separator, O, limit)
502
+ : call(internalSplit, toString(O), separator, limit);
503
+ },
504
+ // `RegExp.prototype[@@split]` method
505
+ // https://tc39.es/ecma262/#sec-regexp.prototype-@@split
506
+ //
507
+ // NOTE: This cannot be properly polyfilled in engines that don't support
508
+ // the 'y' flag.
509
+ function (string, limit) {
510
+ var rx = anObject(this);
511
+ var S = toString(string);
512
+ var res = maybeCallNative(internalSplit, rx, S, limit, internalSplit !== nativeSplit);
513
+
514
+ if (res.done) return res.value;
515
+
516
+ var C = speciesConstructor(rx, RegExp);
517
+
518
+ var unicodeMatching = rx.unicode;
519
+ var flags = (rx.ignoreCase ? 'i' : '') +
520
+ (rx.multiline ? 'm' : '') +
521
+ (rx.unicode ? 'u' : '') +
522
+ (UNSUPPORTED_Y ? 'g' : 'y');
523
+
524
+ // ^(? + rx + ) is needed, in combination with some S slicing, to
525
+ // simulate the 'y' flag.
526
+ var splitter = new C(UNSUPPORTED_Y ? '^(?:' + rx.source + ')' : rx, flags);
527
+ var lim = limit === undefined ? MAX_UINT32 : limit >>> 0;
528
+ if (lim === 0) return [];
529
+ if (S.length === 0) return callRegExpExec(splitter, S) === null ? [S] : [];
530
+ var p = 0;
531
+ var q = 0;
532
+ var A = [];
533
+ while (q < S.length) {
534
+ splitter.lastIndex = UNSUPPORTED_Y ? 0 : q;
535
+ var z = callRegExpExec(splitter, UNSUPPORTED_Y ? stringSlice(S, q) : S);
536
+ var e;
537
+ if (
538
+ z === null ||
539
+ (e = min$2(toLength(splitter.lastIndex + (UNSUPPORTED_Y ? q : 0)), S.length)) === p
540
+ ) {
541
+ q = advanceStringIndex(S, q, unicodeMatching);
542
+ } else {
543
+ push(A, stringSlice(S, p, q));
544
+ if (A.length === lim) return A;
545
+ for (var i = 1; i <= z.length - 1; i++) {
546
+ push(A, z[i]);
547
+ if (A.length === lim) return A;
548
+ }
549
+ q = p = e;
550
+ }
551
+ }
552
+ push(A, stringSlice(S, p));
553
+ return A;
554
+ }
555
+ ];
556
+ }, !SPLIT_WORKS_WITH_OVERWRITTEN_EXEC, UNSUPPORTED_Y);
557
+
558
+ function getSide(placement) {
559
+ return placement.split('-')[0];
560
+ }
561
+
562
+ function getAlignment(placement) {
563
+ return placement.split('-')[1];
564
+ }
565
+
566
+ function getMainAxisFromPlacement(placement) {
567
+ return ['top', 'bottom'].includes(getSide(placement)) ? 'x' : 'y';
568
+ }
569
+
570
+ function getLengthFromAxis(axis) {
571
+ return axis === 'y' ? 'height' : 'width';
572
+ }
573
+
574
+ function computeCoordsFromPlacement(_ref, placement, rtl) {
575
+ let {
576
+ reference,
577
+ floating
578
+ } = _ref;
579
+ const commonX = reference.x + reference.width / 2 - floating.width / 2;
580
+ const commonY = reference.y + reference.height / 2 - floating.height / 2;
581
+ const mainAxis = getMainAxisFromPlacement(placement);
582
+ const length = getLengthFromAxis(mainAxis);
583
+ const commonAlign = reference[length] / 2 - floating[length] / 2;
584
+ const side = getSide(placement);
585
+ const isVertical = mainAxis === 'x';
586
+ let coords;
587
+
588
+ switch (side) {
589
+ case 'top':
590
+ coords = {
591
+ x: commonX,
592
+ y: reference.y - floating.height
593
+ };
594
+ break;
595
+
596
+ case 'bottom':
597
+ coords = {
598
+ x: commonX,
599
+ y: reference.y + reference.height
600
+ };
601
+ break;
602
+
603
+ case 'right':
604
+ coords = {
605
+ x: reference.x + reference.width,
606
+ y: commonY
607
+ };
608
+ break;
609
+
610
+ case 'left':
611
+ coords = {
612
+ x: reference.x - floating.width,
613
+ y: commonY
614
+ };
615
+ break;
616
+
617
+ default:
618
+ coords = {
619
+ x: reference.x,
620
+ y: reference.y
621
+ };
622
+ }
623
+
624
+ switch (getAlignment(placement)) {
625
+ case 'start':
626
+ coords[mainAxis] -= commonAlign * (rtl && isVertical ? -1 : 1);
627
+ break;
628
+
629
+ case 'end':
630
+ coords[mainAxis] += commonAlign * (rtl && isVertical ? -1 : 1);
631
+ break;
632
+ }
633
+
634
+ return coords;
635
+ }
636
+
637
+ /**
638
+ * Computes the `x` and `y` coordinates that will place the floating element
639
+ * next to a reference element when it is given a certain positioning strategy.
640
+ *
641
+ * This export does not have any `platform` interface logic. You will need to
642
+ * write one for the platform you are using Floating UI with.
643
+ */
644
+
645
+ const computePosition$1 = async (reference, floating, config) => {
646
+ const {
647
+ placement = 'bottom',
648
+ strategy = 'absolute',
649
+ middleware = [],
650
+ platform
651
+ } = config;
652
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(floating));
653
+
654
+ {
655
+ if (platform == null) {
656
+ console.error(['Floating UI: `platform` property was not passed to config. If you', 'want to use Floating UI on the web, install @floating-ui/dom', 'instead of the /core package. Otherwise, you can create your own', '`platform`: https://floating-ui.com/docs/platform'].join(' '));
657
+ }
658
+
659
+ if (middleware.filter(_ref => {
660
+ let {
661
+ name
662
+ } = _ref;
663
+ return name === 'autoPlacement' || name === 'flip';
664
+ }).length > 1) {
665
+ throw new Error(['Floating UI: duplicate `flip` and/or `autoPlacement`', 'middleware detected. This will lead to an infinite loop. Ensure only', 'one of either has been passed to the `middleware` array.'].join(' '));
666
+ }
667
+ }
668
+
669
+ let rects = await platform.getElementRects({
670
+ reference,
671
+ floating,
672
+ strategy
673
+ });
674
+ let {
675
+ x,
676
+ y
677
+ } = computeCoordsFromPlacement(rects, placement, rtl);
678
+ let statefulPlacement = placement;
679
+ let middlewareData = {};
680
+ let _debug_loop_count_ = 0;
681
+
682
+ for (let i = 0; i < middleware.length; i++) {
683
+ {
684
+ _debug_loop_count_++;
685
+
686
+ if (_debug_loop_count_ > 100) {
687
+ throw new Error(['Floating UI: The middleware lifecycle appears to be', 'running in an infinite loop. This is usually caused by a `reset`', 'continually being returned without a break condition.'].join(' '));
688
+ }
689
+ }
690
+
691
+ const {
692
+ name,
693
+ fn
694
+ } = middleware[i];
695
+ const {
696
+ x: nextX,
697
+ y: nextY,
698
+ data,
699
+ reset
700
+ } = await fn({
701
+ x,
702
+ y,
703
+ initialPlacement: placement,
704
+ placement: statefulPlacement,
705
+ strategy,
706
+ middlewareData,
707
+ rects,
708
+ platform,
709
+ elements: {
710
+ reference,
711
+ floating
712
+ }
713
+ });
714
+ x = nextX != null ? nextX : x;
715
+ y = nextY != null ? nextY : y;
716
+ middlewareData = { ...middlewareData,
717
+ [name]: { ...middlewareData[name],
718
+ ...data
719
+ }
720
+ };
721
+
722
+ if (reset) {
723
+ if (typeof reset === 'object') {
724
+ if (reset.placement) {
725
+ statefulPlacement = reset.placement;
726
+ }
727
+
728
+ if (reset.rects) {
729
+ rects = reset.rects === true ? await platform.getElementRects({
730
+ reference,
731
+ floating,
732
+ strategy
733
+ }) : reset.rects;
734
+ }
735
+
736
+ ({
737
+ x,
738
+ y
739
+ } = computeCoordsFromPlacement(rects, statefulPlacement, rtl));
740
+ }
741
+
742
+ i = -1;
743
+ continue;
744
+ }
745
+ }
746
+
747
+ return {
748
+ x,
749
+ y,
750
+ placement: statefulPlacement,
751
+ strategy,
752
+ middlewareData
753
+ };
754
+ };
755
+
756
+ function expandPaddingObject(padding) {
757
+ return {
758
+ top: 0,
759
+ right: 0,
760
+ bottom: 0,
761
+ left: 0,
762
+ ...padding
763
+ };
764
+ }
765
+
766
+ function getSideObjectFromPadding(padding) {
767
+ return typeof padding !== 'number' ? expandPaddingObject(padding) : {
768
+ top: padding,
769
+ right: padding,
770
+ bottom: padding,
771
+ left: padding
772
+ };
773
+ }
774
+
775
+ function rectToClientRect(rect) {
776
+ return { ...rect,
777
+ top: rect.y,
778
+ left: rect.x,
779
+ right: rect.x + rect.width,
780
+ bottom: rect.y + rect.height
781
+ };
782
+ }
783
+
784
+ /**
785
+ * Resolves with an object of overflow side offsets that determine how much the
786
+ * element is overflowing a given clipping boundary.
787
+ * - positive = overflowing the boundary by that number of pixels
788
+ * - negative = how many pixels left before it will overflow
789
+ * - 0 = lies flush with the boundary
790
+ * @see https://floating-ui.com/docs/detectOverflow
791
+ */
792
+ async function detectOverflow(middlewareArguments, options) {
793
+ var _await$platform$isEle;
794
+
795
+ if (options === void 0) {
796
+ options = {};
797
+ }
798
+
799
+ const {
800
+ x,
801
+ y,
802
+ platform,
803
+ rects,
804
+ elements,
805
+ strategy
806
+ } = middlewareArguments;
807
+ const {
808
+ boundary = 'clippingAncestors',
809
+ rootBoundary = 'viewport',
810
+ elementContext = 'floating',
811
+ altBoundary = false,
812
+ padding = 0
813
+ } = options;
814
+ const paddingObject = getSideObjectFromPadding(padding);
815
+ const altContext = elementContext === 'floating' ? 'reference' : 'floating';
816
+ const element = elements[altBoundary ? altContext : elementContext];
817
+ const clippingClientRect = rectToClientRect(await platform.getClippingRect({
818
+ element: ((_await$platform$isEle = await (platform.isElement == null ? void 0 : platform.isElement(element))) != null ? _await$platform$isEle : true) ? element : element.contextElement || (await (platform.getDocumentElement == null ? void 0 : platform.getDocumentElement(elements.floating))),
819
+ boundary,
820
+ rootBoundary,
821
+ strategy
822
+ }));
823
+ const elementClientRect = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
824
+ rect: elementContext === 'floating' ? { ...rects.floating,
825
+ x,
826
+ y
827
+ } : rects.reference,
828
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
829
+ strategy
830
+ }) : rects[elementContext]);
831
+ return {
832
+ top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
833
+ bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
834
+ left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
835
+ right: elementClientRect.right - clippingClientRect.right + paddingObject.right
836
+ };
837
+ }
838
+
839
+ const min$1 = Math.min;
840
+ const max$1 = Math.max;
841
+
842
+ function within(min$1$1, value, max$1$1) {
843
+ return max$1(min$1$1, min$1(value, max$1$1));
844
+ }
845
+
846
+ /**
847
+ * Positions an inner element of the floating element such that it is centered
848
+ * to the reference element.
849
+ * @see https://floating-ui.com/docs/arrow
850
+ */
851
+ const arrow = options => ({
852
+ name: 'arrow',
853
+ options,
854
+
855
+ async fn(middlewareArguments) {
856
+ // Since `element` is required, we don't Partial<> the type
857
+ const {
858
+ element,
859
+ padding = 0
860
+ } = options != null ? options : {};
861
+ const {
862
+ x,
863
+ y,
864
+ placement,
865
+ rects,
866
+ platform
867
+ } = middlewareArguments;
868
+
869
+ if (element == null) {
870
+ {
871
+ console.warn('Floating UI: No `element` was passed to the `arrow` middleware.');
872
+ }
873
+
874
+ return {};
875
+ }
876
+
877
+ const paddingObject = getSideObjectFromPadding(padding);
878
+ const coords = {
879
+ x,
880
+ y
881
+ };
882
+ const axis = getMainAxisFromPlacement(placement);
883
+ const alignment = getAlignment(placement);
884
+ const length = getLengthFromAxis(axis);
885
+ const arrowDimensions = await platform.getDimensions(element);
886
+ const minProp = axis === 'y' ? 'top' : 'left';
887
+ const maxProp = axis === 'y' ? 'bottom' : 'right';
888
+ const endDiff = rects.reference[length] + rects.reference[axis] - coords[axis] - rects.floating[length];
889
+ const startDiff = coords[axis] - rects.reference[axis];
890
+ const arrowOffsetParent = await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(element));
891
+ let clientSize = arrowOffsetParent ? axis === 'y' ? arrowOffsetParent.clientHeight || 0 : arrowOffsetParent.clientWidth || 0 : 0;
892
+
893
+ if (clientSize === 0) {
894
+ clientSize = rects.floating[length];
895
+ }
896
+
897
+ const centerToReference = endDiff / 2 - startDiff / 2; // Make sure the arrow doesn't overflow the floating element if the center
898
+ // point is outside the floating element's bounds
899
+
900
+ const min = paddingObject[minProp];
901
+ const max = clientSize - arrowDimensions[length] - paddingObject[maxProp];
902
+ const center = clientSize / 2 - arrowDimensions[length] / 2 + centerToReference;
903
+ const offset = within(min, center, max); // Make sure that arrow points at the reference
904
+
905
+ const alignmentPadding = alignment === 'start' ? paddingObject[minProp] : paddingObject[maxProp];
906
+ const shouldAddOffset = alignmentPadding > 0 && center !== offset && rects.reference[length] <= rects.floating[length];
907
+ const alignmentOffset = shouldAddOffset ? center < min ? min - center : max - center : 0;
908
+ return {
909
+ [axis]: coords[axis] - alignmentOffset,
910
+ data: {
911
+ [axis]: offset,
912
+ centerOffset: center - offset
913
+ }
914
+ };
915
+ }
916
+
917
+ });
918
+
919
+ const hash$1 = {
920
+ left: 'right',
921
+ right: 'left',
922
+ bottom: 'top',
923
+ top: 'bottom'
924
+ };
925
+ function getOppositePlacement(placement) {
926
+ return placement.replace(/left|right|bottom|top/g, matched => hash$1[matched]);
927
+ }
928
+
929
+ function getAlignmentSides(placement, rects, rtl) {
930
+ if (rtl === void 0) {
931
+ rtl = false;
932
+ }
933
+
934
+ const alignment = getAlignment(placement);
935
+ const mainAxis = getMainAxisFromPlacement(placement);
936
+ const length = getLengthFromAxis(mainAxis);
937
+ let mainAlignmentSide = mainAxis === 'x' ? alignment === (rtl ? 'end' : 'start') ? 'right' : 'left' : alignment === 'start' ? 'bottom' : 'top';
938
+
939
+ if (rects.reference[length] > rects.floating[length]) {
940
+ mainAlignmentSide = getOppositePlacement(mainAlignmentSide);
941
+ }
942
+
943
+ return {
944
+ main: mainAlignmentSide,
945
+ cross: getOppositePlacement(mainAlignmentSide)
946
+ };
947
+ }
948
+
949
+ const hash = {
950
+ start: 'end',
951
+ end: 'start'
952
+ };
953
+ function getOppositeAlignmentPlacement(placement) {
954
+ return placement.replace(/start|end/g, matched => hash[matched]);
955
+ }
956
+
957
+ const sides = ['top', 'right', 'bottom', 'left'];
958
+
959
+ function getExpandedPlacements(placement) {
960
+ const oppositePlacement = getOppositePlacement(placement);
961
+ return [getOppositeAlignmentPlacement(placement), oppositePlacement, getOppositeAlignmentPlacement(oppositePlacement)];
962
+ }
963
+
964
+ /**
965
+ * Changes the placement of the floating element to one that will fit if the
966
+ * initially specified `placement` does not.
967
+ * @see https://floating-ui.com/docs/flip
968
+ */
969
+ const flip = function (options) {
970
+ if (options === void 0) {
971
+ options = {};
972
+ }
973
+
974
+ return {
975
+ name: 'flip',
976
+ options,
977
+
978
+ async fn(middlewareArguments) {
979
+ var _middlewareData$flip;
980
+
981
+ const {
982
+ placement,
983
+ middlewareData,
984
+ rects,
985
+ initialPlacement,
986
+ platform,
987
+ elements
988
+ } = middlewareArguments;
989
+ const {
990
+ mainAxis: checkMainAxis = true,
991
+ crossAxis: checkCrossAxis = true,
992
+ fallbackPlacements: specifiedFallbackPlacements,
993
+ fallbackStrategy = 'bestFit',
994
+ flipAlignment = true,
995
+ ...detectOverflowOptions
996
+ } = options;
997
+ const side = getSide(placement);
998
+ const isBasePlacement = side === initialPlacement;
999
+ const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
1000
+ const placements = [initialPlacement, ...fallbackPlacements];
1001
+ const overflow = await detectOverflow(middlewareArguments, detectOverflowOptions);
1002
+ const overflows = [];
1003
+ let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
1004
+
1005
+ if (checkMainAxis) {
1006
+ overflows.push(overflow[side]);
1007
+ }
1008
+
1009
+ if (checkCrossAxis) {
1010
+ const {
1011
+ main,
1012
+ cross
1013
+ } = getAlignmentSides(placement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
1014
+ overflows.push(overflow[main], overflow[cross]);
1015
+ }
1016
+
1017
+ overflowsData = [...overflowsData, {
1018
+ placement,
1019
+ overflows
1020
+ }]; // One or more sides is overflowing
1021
+
1022
+ if (!overflows.every(side => side <= 0)) {
1023
+ var _middlewareData$flip$, _middlewareData$flip2;
1024
+
1025
+ const nextIndex = ((_middlewareData$flip$ = (_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) != null ? _middlewareData$flip$ : 0) + 1;
1026
+ const nextPlacement = placements[nextIndex];
1027
+
1028
+ if (nextPlacement) {
1029
+ // Try next placement and re-run the lifecycle
1030
+ return {
1031
+ data: {
1032
+ index: nextIndex,
1033
+ overflows: overflowsData
1034
+ },
1035
+ reset: {
1036
+ placement: nextPlacement
1037
+ }
1038
+ };
1039
+ }
1040
+
1041
+ let resetPlacement = 'bottom';
1042
+
1043
+ switch (fallbackStrategy) {
1044
+ case 'bestFit':
1045
+ {
1046
+ var _overflowsData$map$so;
1047
+
1048
+ const placement = (_overflowsData$map$so = overflowsData.map(d => [d, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0].placement;
1049
+
1050
+ if (placement) {
1051
+ resetPlacement = placement;
1052
+ }
1053
+
1054
+ break;
1055
+ }
1056
+
1057
+ case 'initialPlacement':
1058
+ resetPlacement = initialPlacement;
1059
+ break;
1060
+ }
1061
+
1062
+ if (placement !== resetPlacement) {
1063
+ return {
1064
+ reset: {
1065
+ placement: resetPlacement
1066
+ }
1067
+ };
1068
+ }
1069
+ }
1070
+
1071
+ return {};
1072
+ }
1073
+
1074
+ };
1075
+ };
1076
+
1077
+ function getSideOffsets(overflow, rect) {
1078
+ return {
1079
+ top: overflow.top - rect.height,
1080
+ right: overflow.right - rect.width,
1081
+ bottom: overflow.bottom - rect.height,
1082
+ left: overflow.left - rect.width
1083
+ };
1084
+ }
1085
+
1086
+ function isAnySideFullyClipped(overflow) {
1087
+ return sides.some(side => overflow[side] >= 0);
1088
+ }
1089
+
1090
+ /**
1091
+ * Provides data to hide the floating element in applicable situations, such as
1092
+ * when it is not in the same clipping context as the reference element.
1093
+ * @see https://floating-ui.com/docs/hide
1094
+ */
1095
+ const hide = function (_temp) {
1096
+ let {
1097
+ strategy = 'referenceHidden',
1098
+ ...detectOverflowOptions
1099
+ } = _temp === void 0 ? {} : _temp;
1100
+ return {
1101
+ name: 'hide',
1102
+
1103
+ async fn(middlewareArguments) {
1104
+ const {
1105
+ rects
1106
+ } = middlewareArguments;
1107
+
1108
+ switch (strategy) {
1109
+ case 'referenceHidden':
1110
+ {
1111
+ const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
1112
+ elementContext: 'reference'
1113
+ });
1114
+ const offsets = getSideOffsets(overflow, rects.reference);
1115
+ return {
1116
+ data: {
1117
+ referenceHiddenOffsets: offsets,
1118
+ referenceHidden: isAnySideFullyClipped(offsets)
1119
+ }
1120
+ };
1121
+ }
1122
+
1123
+ case 'escaped':
1124
+ {
1125
+ const overflow = await detectOverflow(middlewareArguments, { ...detectOverflowOptions,
1126
+ altBoundary: true
1127
+ });
1128
+ const offsets = getSideOffsets(overflow, rects.floating);
1129
+ return {
1130
+ data: {
1131
+ escapedOffsets: offsets,
1132
+ escaped: isAnySideFullyClipped(offsets)
1133
+ }
1134
+ };
1135
+ }
1136
+
1137
+ default:
1138
+ {
1139
+ return {};
1140
+ }
1141
+ }
1142
+ }
1143
+
1144
+ };
1145
+ };
1146
+
1147
+ async function convertValueToCoords(middlewareArguments, value) {
1148
+ const {
1149
+ placement,
1150
+ platform,
1151
+ elements
1152
+ } = middlewareArguments;
1153
+ const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
1154
+ const side = getSide(placement);
1155
+ const alignment = getAlignment(placement);
1156
+ const isVertical = getMainAxisFromPlacement(placement) === 'x';
1157
+ const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
1158
+ const crossAxisMulti = rtl && isVertical ? -1 : 1;
1159
+ const rawValue = typeof value === 'function' ? value(middlewareArguments) : value; // eslint-disable-next-line prefer-const
1160
+
1161
+ let {
1162
+ mainAxis,
1163
+ crossAxis,
1164
+ alignmentAxis
1165
+ } = typeof rawValue === 'number' ? {
1166
+ mainAxis: rawValue,
1167
+ crossAxis: 0,
1168
+ alignmentAxis: null
1169
+ } : {
1170
+ mainAxis: 0,
1171
+ crossAxis: 0,
1172
+ alignmentAxis: null,
1173
+ ...rawValue
1174
+ };
1175
+
1176
+ if (alignment && typeof alignmentAxis === 'number') {
1177
+ crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
1178
+ }
1179
+
1180
+ return isVertical ? {
1181
+ x: crossAxis * crossAxisMulti,
1182
+ y: mainAxis * mainAxisMulti
1183
+ } : {
1184
+ x: mainAxis * mainAxisMulti,
1185
+ y: crossAxis * crossAxisMulti
1186
+ };
1187
+ }
1188
+ /**
1189
+ * Displaces the floating element from its reference element.
1190
+ * @see https://floating-ui.com/docs/offset
1191
+ */
1192
+
1193
+ const offset = function (value) {
1194
+ if (value === void 0) {
1195
+ value = 0;
1196
+ }
1197
+
1198
+ return {
1199
+ name: 'offset',
1200
+ options: value,
1201
+
1202
+ async fn(middlewareArguments) {
1203
+ const {
1204
+ x,
1205
+ y
1206
+ } = middlewareArguments;
1207
+ const diffCoords = await convertValueToCoords(middlewareArguments, value);
1208
+ return {
1209
+ x: x + diffCoords.x,
1210
+ y: y + diffCoords.y,
1211
+ data: diffCoords
1212
+ };
1213
+ }
1214
+
1215
+ };
1216
+ };
1217
+
1218
+ /**
1219
+ * Provides improved positioning for inline reference elements that can span
1220
+ * over multiple lines, such as hyperlinks or range selections.
1221
+ * @see https://floating-ui.com/docs/inline
1222
+ */
1223
+ const inline = function (options) {
1224
+ if (options === void 0) {
1225
+ options = {};
1226
+ }
1227
+
1228
+ return {
1229
+ name: 'inline',
1230
+ options,
1231
+
1232
+ async fn(middlewareArguments) {
1233
+ var _await$platform$getCl;
1234
+
1235
+ const {
1236
+ placement,
1237
+ elements,
1238
+ rects,
1239
+ platform,
1240
+ strategy
1241
+ } = middlewareArguments; // A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
1242
+ // ClientRect's bounds, despite the event listener being triggered. A
1243
+ // padding of 2 seems to handle this issue.
1244
+
1245
+ const {
1246
+ padding = 2,
1247
+ x,
1248
+ y
1249
+ } = options;
1250
+ const fallback = rectToClientRect(platform.convertOffsetParentRelativeRectToViewportRelativeRect ? await platform.convertOffsetParentRelativeRectToViewportRelativeRect({
1251
+ rect: rects.reference,
1252
+ offsetParent: await (platform.getOffsetParent == null ? void 0 : platform.getOffsetParent(elements.floating)),
1253
+ strategy
1254
+ }) : rects.reference);
1255
+ const clientRects = (_await$platform$getCl = await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) != null ? _await$platform$getCl : [];
1256
+ const paddingObject = getSideObjectFromPadding(padding);
1257
+
1258
+ function getBoundingClientRect() {
1259
+ // There are two rects and they are disjoined
1260
+ if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
1261
+ var _clientRects$find;
1262
+
1263
+ // Find the first rect in which the point is fully inside
1264
+ return (_clientRects$find = clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom)) != null ? _clientRects$find : fallback;
1265
+ } // There are 2 or more connected rects
1266
+
1267
+
1268
+ if (clientRects.length >= 2) {
1269
+ if (getMainAxisFromPlacement(placement) === 'x') {
1270
+ const firstRect = clientRects[0];
1271
+ const lastRect = clientRects[clientRects.length - 1];
1272
+ const isTop = getSide(placement) === 'top';
1273
+ const top = firstRect.top;
1274
+ const bottom = lastRect.bottom;
1275
+ const left = isTop ? firstRect.left : lastRect.left;
1276
+ const right = isTop ? firstRect.right : lastRect.right;
1277
+ const width = right - left;
1278
+ const height = bottom - top;
1279
+ return {
1280
+ top,
1281
+ bottom,
1282
+ left,
1283
+ right,
1284
+ width,
1285
+ height,
1286
+ x: left,
1287
+ y: top
1288
+ };
1289
+ }
1290
+
1291
+ const isLeftSide = getSide(placement) === 'left';
1292
+ const maxRight = max$1(...clientRects.map(rect => rect.right));
1293
+ const minLeft = min$1(...clientRects.map(rect => rect.left));
1294
+ const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
1295
+ const top = measureRects[0].top;
1296
+ const bottom = measureRects[measureRects.length - 1].bottom;
1297
+ const left = minLeft;
1298
+ const right = maxRight;
1299
+ const width = right - left;
1300
+ const height = bottom - top;
1301
+ return {
1302
+ top,
1303
+ bottom,
1304
+ left,
1305
+ right,
1306
+ width,
1307
+ height,
1308
+ x: left,
1309
+ y: top
1310
+ };
1311
+ }
1312
+
1313
+ return fallback;
1314
+ }
1315
+
1316
+ const resetRects = await platform.getElementRects({
1317
+ reference: {
1318
+ getBoundingClientRect
1319
+ },
1320
+ floating: elements.floating,
1321
+ strategy
1322
+ });
1323
+
1324
+ if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
1325
+ return {
1326
+ reset: {
1327
+ rects: resetRects
1328
+ }
1329
+ };
1330
+ }
1331
+
1332
+ return {};
1333
+ }
1334
+
1335
+ };
1336
+ };
1337
+
1338
+ function isWindow(value) {
1339
+ return value && value.document && value.location && value.alert && value.setInterval;
1340
+ }
1341
+ function getWindow(node) {
1342
+ if (node == null) {
1343
+ return window;
1344
+ }
1345
+
1346
+ if (!isWindow(node)) {
1347
+ const ownerDocument = node.ownerDocument;
1348
+ return ownerDocument ? ownerDocument.defaultView || window : window;
1349
+ }
1350
+
1351
+ return node;
1352
+ }
1353
+
1354
+ function getComputedStyle$1(element) {
1355
+ return getWindow(element).getComputedStyle(element);
1356
+ }
1357
+
1358
+ function getNodeName(node) {
1359
+ return isWindow(node) ? '' : node ? (node.nodeName || '').toLowerCase() : '';
1360
+ }
1361
+
1362
+ function getUAString() {
1363
+ const uaData = navigator.userAgentData;
1364
+
1365
+ if (uaData != null && uaData.brands) {
1366
+ return uaData.brands.map(item => item.brand + "/" + item.version).join(' ');
1367
+ }
1368
+
1369
+ return navigator.userAgent;
1370
+ }
1371
+
1372
+ function isHTMLElement(value) {
1373
+ return value instanceof getWindow(value).HTMLElement;
1374
+ }
1375
+ function isElement(value) {
1376
+ return value instanceof getWindow(value).Element;
1377
+ }
1378
+ function isNode(value) {
1379
+ return value instanceof getWindow(value).Node;
1380
+ }
1381
+ function isShadowRoot(node) {
1382
+ // Browsers without `ShadowRoot` support
1383
+ if (typeof ShadowRoot === 'undefined') {
1384
+ return false;
1385
+ }
1386
+
1387
+ const OwnElement = getWindow(node).ShadowRoot;
1388
+ return node instanceof OwnElement || node instanceof ShadowRoot;
1389
+ }
1390
+ function isOverflowElement(element) {
1391
+ // Firefox wants us to check `-x` and `-y` variations as well
1392
+ const {
1393
+ overflow,
1394
+ overflowX,
1395
+ overflowY
1396
+ } = getComputedStyle$1(element);
1397
+ return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
1398
+ }
1399
+ function isTableElement(element) {
1400
+ return ['table', 'td', 'th'].includes(getNodeName(element));
1401
+ }
1402
+ function isContainingBlock(element) {
1403
+ // TODO: Try and use feature detection here instead
1404
+ const isFirefox = /firefox/i.test(getUAString());
1405
+ const css = getComputedStyle$1(element); // This is non-exhaustive but covers the most common CSS properties that
1406
+ // create a containing block.
1407
+ // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
1408
+
1409
+ return css.transform !== 'none' || css.perspective !== 'none' || // @ts-ignore (TS 4.1 compat)
1410
+ css.contain === 'paint' || ['transform', 'perspective'].includes(css.willChange) || isFirefox && css.willChange === 'filter' || isFirefox && (css.filter ? css.filter !== 'none' : false);
1411
+ }
1412
+ function isLayoutViewport() {
1413
+ // Not Safari
1414
+ return !/^((?!chrome|android).)*safari/i.test(getUAString()); // Feature detection for this fails in various ways
1415
+ // • Always-visible scrollbar or not
1416
+ // • Width of <html>, etc.
1417
+ // const vV = win.visualViewport;
1418
+ // return vV ? Math.abs(win.innerWidth / vV.scale - vV.width) < 0.5 : true;
1419
+ }
1420
+
1421
+ const min = Math.min;
1422
+ const max = Math.max;
1423
+ const round = Math.round;
1424
+
1425
+ function getBoundingClientRect(element, includeScale, isFixedStrategy) {
1426
+ var _win$visualViewport$o, _win$visualViewport, _win$visualViewport$o2, _win$visualViewport2;
1427
+
1428
+ if (includeScale === void 0) {
1429
+ includeScale = false;
1430
+ }
1431
+
1432
+ if (isFixedStrategy === void 0) {
1433
+ isFixedStrategy = false;
1434
+ }
1435
+
1436
+ const clientRect = element.getBoundingClientRect();
1437
+ let scaleX = 1;
1438
+ let scaleY = 1;
1439
+
1440
+ if (includeScale && isHTMLElement(element)) {
1441
+ scaleX = element.offsetWidth > 0 ? round(clientRect.width) / element.offsetWidth || 1 : 1;
1442
+ scaleY = element.offsetHeight > 0 ? round(clientRect.height) / element.offsetHeight || 1 : 1;
1443
+ }
1444
+
1445
+ const win = isElement(element) ? getWindow(element) : window;
1446
+ const addVisualOffsets = !isLayoutViewport() && isFixedStrategy;
1447
+ const x = (clientRect.left + (addVisualOffsets ? (_win$visualViewport$o = (_win$visualViewport = win.visualViewport) == null ? void 0 : _win$visualViewport.offsetLeft) != null ? _win$visualViewport$o : 0 : 0)) / scaleX;
1448
+ const y = (clientRect.top + (addVisualOffsets ? (_win$visualViewport$o2 = (_win$visualViewport2 = win.visualViewport) == null ? void 0 : _win$visualViewport2.offsetTop) != null ? _win$visualViewport$o2 : 0 : 0)) / scaleY;
1449
+ const width = clientRect.width / scaleX;
1450
+ const height = clientRect.height / scaleY;
1451
+ return {
1452
+ width,
1453
+ height,
1454
+ top: y,
1455
+ right: x + width,
1456
+ bottom: y + height,
1457
+ left: x,
1458
+ x,
1459
+ y
1460
+ };
1461
+ }
1462
+
1463
+ function getDocumentElement(node) {
1464
+ return ((isNode(node) ? node.ownerDocument : node.document) || window.document).documentElement;
1465
+ }
1466
+
1467
+ function getNodeScroll(element) {
1468
+ if (isElement(element)) {
1469
+ return {
1470
+ scrollLeft: element.scrollLeft,
1471
+ scrollTop: element.scrollTop
1472
+ };
1473
+ }
1474
+
1475
+ return {
1476
+ scrollLeft: element.pageXOffset,
1477
+ scrollTop: element.pageYOffset
1478
+ };
1479
+ }
1480
+
1481
+ function getWindowScrollBarX(element) {
1482
+ // If <html> has a CSS width greater than the viewport, then this will be
1483
+ // incorrect for RTL.
1484
+ return getBoundingClientRect(getDocumentElement(element)).left + getNodeScroll(element).scrollLeft;
1485
+ }
1486
+
1487
+ function isScaled(element) {
1488
+ const rect = getBoundingClientRect(element);
1489
+ return round(rect.width) !== element.offsetWidth || round(rect.height) !== element.offsetHeight;
1490
+ }
1491
+
1492
+ function getRectRelativeToOffsetParent(element, offsetParent, strategy) {
1493
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1494
+ const documentElement = getDocumentElement(offsetParent);
1495
+ const rect = getBoundingClientRect(element, // @ts-ignore - checked above (TS 4.1 compat)
1496
+ isOffsetParentAnElement && isScaled(offsetParent), strategy === 'fixed');
1497
+ let scroll = {
1498
+ scrollLeft: 0,
1499
+ scrollTop: 0
1500
+ };
1501
+ const offsets = {
1502
+ x: 0,
1503
+ y: 0
1504
+ };
1505
+
1506
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1507
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1508
+ scroll = getNodeScroll(offsetParent);
1509
+ }
1510
+
1511
+ if (isHTMLElement(offsetParent)) {
1512
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1513
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1514
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1515
+ } else if (documentElement) {
1516
+ offsets.x = getWindowScrollBarX(documentElement);
1517
+ }
1518
+ }
1519
+
1520
+ return {
1521
+ x: rect.left + scroll.scrollLeft - offsets.x,
1522
+ y: rect.top + scroll.scrollTop - offsets.y,
1523
+ width: rect.width,
1524
+ height: rect.height
1525
+ };
1526
+ }
1527
+
1528
+ function getParentNode(node) {
1529
+ if (getNodeName(node) === 'html') {
1530
+ return node;
1531
+ }
1532
+
1533
+ return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
1534
+ // @ts-ignore
1535
+ node.assignedSlot || // step into the shadow DOM of the parent of a slotted node
1536
+ node.parentNode || ( // DOM Element detected
1537
+ isShadowRoot(node) ? node.host : null) || // ShadowRoot detected
1538
+ getDocumentElement(node) // fallback
1539
+
1540
+ );
1541
+ }
1542
+
1543
+ function getTrueOffsetParent(element) {
1544
+ if (!isHTMLElement(element) || getComputedStyle(element).position === 'fixed') {
1545
+ return null;
1546
+ }
1547
+
1548
+ return element.offsetParent;
1549
+ }
1550
+
1551
+ function getContainingBlock(element) {
1552
+ let currentNode = getParentNode(element);
1553
+
1554
+ if (isShadowRoot(currentNode)) {
1555
+ currentNode = currentNode.host;
1556
+ }
1557
+
1558
+ while (isHTMLElement(currentNode) && !['html', 'body'].includes(getNodeName(currentNode))) {
1559
+ if (isContainingBlock(currentNode)) {
1560
+ return currentNode;
1561
+ } else {
1562
+ currentNode = currentNode.parentNode;
1563
+ }
1564
+ }
1565
+
1566
+ return null;
1567
+ } // Gets the closest ancestor positioned element. Handles some edge cases,
1568
+ // such as table ancestors and cross browser bugs.
1569
+
1570
+
1571
+ function getOffsetParent(element) {
1572
+ const window = getWindow(element);
1573
+ let offsetParent = getTrueOffsetParent(element);
1574
+
1575
+ while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
1576
+ offsetParent = getTrueOffsetParent(offsetParent);
1577
+ }
1578
+
1579
+ if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static' && !isContainingBlock(offsetParent))) {
1580
+ return window;
1581
+ }
1582
+
1583
+ return offsetParent || getContainingBlock(element) || window;
1584
+ }
1585
+
1586
+ function getDimensions(element) {
1587
+ if (isHTMLElement(element)) {
1588
+ return {
1589
+ width: element.offsetWidth,
1590
+ height: element.offsetHeight
1591
+ };
1592
+ }
1593
+
1594
+ const rect = getBoundingClientRect(element);
1595
+ return {
1596
+ width: rect.width,
1597
+ height: rect.height
1598
+ };
1599
+ }
1600
+
1601
+ function convertOffsetParentRelativeRectToViewportRelativeRect(_ref) {
1602
+ let {
1603
+ rect,
1604
+ offsetParent,
1605
+ strategy
1606
+ } = _ref;
1607
+ const isOffsetParentAnElement = isHTMLElement(offsetParent);
1608
+ const documentElement = getDocumentElement(offsetParent);
1609
+
1610
+ if (offsetParent === documentElement) {
1611
+ return rect;
1612
+ }
1613
+
1614
+ let scroll = {
1615
+ scrollLeft: 0,
1616
+ scrollTop: 0
1617
+ };
1618
+ const offsets = {
1619
+ x: 0,
1620
+ y: 0
1621
+ };
1622
+
1623
+ if (isOffsetParentAnElement || !isOffsetParentAnElement && strategy !== 'fixed') {
1624
+ if (getNodeName(offsetParent) !== 'body' || isOverflowElement(documentElement)) {
1625
+ scroll = getNodeScroll(offsetParent);
1626
+ }
1627
+
1628
+ if (isHTMLElement(offsetParent)) {
1629
+ const offsetRect = getBoundingClientRect(offsetParent, true);
1630
+ offsets.x = offsetRect.x + offsetParent.clientLeft;
1631
+ offsets.y = offsetRect.y + offsetParent.clientTop;
1632
+ } // This doesn't appear to be need to be negated.
1633
+ // else if (documentElement) {
1634
+ // offsets.x = getWindowScrollBarX(documentElement);
1635
+ // }
1636
+
1637
+ }
1638
+
1639
+ return { ...rect,
1640
+ x: rect.x - scroll.scrollLeft + offsets.x,
1641
+ y: rect.y - scroll.scrollTop + offsets.y
1642
+ };
1643
+ }
1644
+
1645
+ function getViewportRect(element, strategy) {
1646
+ const win = getWindow(element);
1647
+ const html = getDocumentElement(element);
1648
+ const visualViewport = win.visualViewport;
1649
+ let width = html.clientWidth;
1650
+ let height = html.clientHeight;
1651
+ let x = 0;
1652
+ let y = 0;
1653
+
1654
+ if (visualViewport) {
1655
+ width = visualViewport.width;
1656
+ height = visualViewport.height;
1657
+ const layoutViewport = isLayoutViewport();
1658
+
1659
+ if (layoutViewport || !layoutViewport && strategy === 'fixed') {
1660
+ x = visualViewport.offsetLeft;
1661
+ y = visualViewport.offsetTop;
1662
+ }
1663
+ }
1664
+
1665
+ return {
1666
+ width,
1667
+ height,
1668
+ x,
1669
+ y
1670
+ };
1671
+ }
1672
+
1673
+ // of the `<html>` and `<body>` rect bounds if horizontally scrollable
1674
+
1675
+ function getDocumentRect(element) {
1676
+ var _element$ownerDocumen;
1677
+
1678
+ const html = getDocumentElement(element);
1679
+ const scroll = getNodeScroll(element);
1680
+ const body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
1681
+ const width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
1682
+ const height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
1683
+ let x = -scroll.scrollLeft + getWindowScrollBarX(element);
1684
+ const y = -scroll.scrollTop;
1685
+
1686
+ if (getComputedStyle$1(body || html).direction === 'rtl') {
1687
+ x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
1688
+ }
1689
+
1690
+ return {
1691
+ width,
1692
+ height,
1693
+ x,
1694
+ y
1695
+ };
1696
+ }
1697
+
1698
+ function getNearestOverflowAncestor(node) {
1699
+ const parentNode = getParentNode(node);
1700
+
1701
+ if (['html', 'body', '#document'].includes(getNodeName(parentNode))) {
1702
+ // @ts-ignore assume body is always available
1703
+ return node.ownerDocument.body;
1704
+ }
1705
+
1706
+ if (isHTMLElement(parentNode) && isOverflowElement(parentNode)) {
1707
+ return parentNode;
1708
+ }
1709
+
1710
+ return getNearestOverflowAncestor(parentNode);
1711
+ }
1712
+
1713
+ function getOverflowAncestors(node, list) {
1714
+ var _node$ownerDocument;
1715
+
1716
+ if (list === void 0) {
1717
+ list = [];
1718
+ }
1719
+
1720
+ const scrollableAncestor = getNearestOverflowAncestor(node);
1721
+ const isBody = scrollableAncestor === ((_node$ownerDocument = node.ownerDocument) == null ? void 0 : _node$ownerDocument.body);
1722
+ const win = getWindow(scrollableAncestor);
1723
+ const target = isBody ? [win].concat(win.visualViewport || [], isOverflowElement(scrollableAncestor) ? scrollableAncestor : []) : scrollableAncestor;
1724
+ const updatedList = list.concat(target);
1725
+ return isBody ? updatedList : // @ts-ignore: isBody tells us target will be an HTMLElement here
1726
+ updatedList.concat(getOverflowAncestors(target));
1727
+ }
1728
+
1729
+ function contains(parent, child) {
1730
+ const rootNode = child.getRootNode == null ? void 0 : child.getRootNode(); // First, attempt with faster native method
1731
+
1732
+ if (parent.contains(child)) {
1733
+ return true;
1734
+ } // then fallback to custom implementation with Shadow DOM support
1735
+ else if (rootNode && isShadowRoot(rootNode)) {
1736
+ let next = child;
1737
+
1738
+ do {
1739
+ // use `===` replace node.isSameNode()
1740
+ if (next && parent === next) {
1741
+ return true;
1742
+ } // @ts-ignore: need a better way to handle this...
1743
+
1744
+
1745
+ next = next.parentNode || next.host;
1746
+ } while (next);
1747
+ }
1748
+
1749
+ return false;
1750
+ }
1751
+
1752
+ function getInnerBoundingClientRect(element, strategy) {
1753
+ const clientRect = getBoundingClientRect(element, false, strategy === 'fixed');
1754
+ const top = clientRect.top + element.clientTop;
1755
+ const left = clientRect.left + element.clientLeft;
1756
+ return {
1757
+ top,
1758
+ left,
1759
+ x: left,
1760
+ y: top,
1761
+ right: left + element.clientWidth,
1762
+ bottom: top + element.clientHeight,
1763
+ width: element.clientWidth,
1764
+ height: element.clientHeight
1765
+ };
1766
+ }
1767
+
1768
+ function getClientRectFromClippingAncestor(element, clippingParent, strategy) {
1769
+ if (clippingParent === 'viewport') {
1770
+ return rectToClientRect(getViewportRect(element, strategy));
1771
+ }
1772
+
1773
+ if (isElement(clippingParent)) {
1774
+ return getInnerBoundingClientRect(clippingParent, strategy);
1775
+ }
1776
+
1777
+ return rectToClientRect(getDocumentRect(getDocumentElement(element)));
1778
+ } // A "clipping ancestor" is an overflowable container with the characteristic of
1779
+ // clipping (or hiding) overflowing elements with a position different from
1780
+ // `initial`
1781
+
1782
+
1783
+ function getClippingAncestors(element) {
1784
+ const clippingAncestors = getOverflowAncestors(element);
1785
+ const canEscapeClipping = ['absolute', 'fixed'].includes(getComputedStyle$1(element).position);
1786
+ const clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
1787
+
1788
+ if (!isElement(clipperElement)) {
1789
+ return [];
1790
+ } // @ts-ignore isElement check ensures we return Array<Element>
1791
+
1792
+
1793
+ return clippingAncestors.filter(clippingAncestors => isElement(clippingAncestors) && contains(clippingAncestors, clipperElement) && getNodeName(clippingAncestors) !== 'body');
1794
+ } // Gets the maximum area that the element is visible in due to any number of
1795
+ // clipping ancestors
1796
+
1797
+
1798
+ function getClippingRect(_ref) {
1799
+ let {
1800
+ element,
1801
+ boundary,
1802
+ rootBoundary,
1803
+ strategy
1804
+ } = _ref;
1805
+ const mainClippingAncestors = boundary === 'clippingAncestors' ? getClippingAncestors(element) : [].concat(boundary);
1806
+ const clippingAncestors = [...mainClippingAncestors, rootBoundary];
1807
+ const firstClippingAncestor = clippingAncestors[0];
1808
+ const clippingRect = clippingAncestors.reduce((accRect, clippingAncestor) => {
1809
+ const rect = getClientRectFromClippingAncestor(element, clippingAncestor, strategy);
1810
+ accRect.top = max(rect.top, accRect.top);
1811
+ accRect.right = min(rect.right, accRect.right);
1812
+ accRect.bottom = min(rect.bottom, accRect.bottom);
1813
+ accRect.left = max(rect.left, accRect.left);
1814
+ return accRect;
1815
+ }, getClientRectFromClippingAncestor(element, firstClippingAncestor, strategy));
1816
+ return {
1817
+ width: clippingRect.right - clippingRect.left,
1818
+ height: clippingRect.bottom - clippingRect.top,
1819
+ x: clippingRect.left,
1820
+ y: clippingRect.top
1821
+ };
1822
+ }
1823
+
1824
+ const platform = {
1825
+ getClippingRect,
1826
+ convertOffsetParentRelativeRectToViewportRelativeRect,
1827
+ isElement,
1828
+ getDimensions,
1829
+ getOffsetParent,
1830
+ getDocumentElement,
1831
+ getElementRects: _ref => {
1832
+ let {
1833
+ reference,
1834
+ floating,
1835
+ strategy
1836
+ } = _ref;
1837
+ return {
1838
+ reference: getRectRelativeToOffsetParent(reference, getOffsetParent(floating), strategy),
1839
+ floating: { ...getDimensions(floating),
1840
+ x: 0,
1841
+ y: 0
1842
+ }
1843
+ };
1844
+ },
1845
+ getClientRects: element => Array.from(element.getClientRects()),
1846
+ isRTL: element => getComputedStyle$1(element).direction === 'rtl'
1847
+ };
1848
+
1849
+ /**
1850
+ * Automatically updates the position of the floating element when necessary.
1851
+ * @see https://floating-ui.com/docs/autoUpdate
1852
+ */
1853
+ function autoUpdate(reference, floating, update, options) {
1854
+ if (options === void 0) {
1855
+ options = {};
1856
+ }
1857
+
1858
+ const {
1859
+ ancestorScroll: _ancestorScroll = true,
1860
+ ancestorResize: _ancestorResize = true,
1861
+ elementResize = true,
1862
+ animationFrame = false
1863
+ } = options;
1864
+ const ancestorScroll = _ancestorScroll && !animationFrame;
1865
+ const ancestorResize = _ancestorResize && !animationFrame;
1866
+ const ancestors = ancestorScroll || ancestorResize ? [...(isElement(reference) ? getOverflowAncestors(reference) : []), ...getOverflowAncestors(floating)] : [];
1867
+ ancestors.forEach(ancestor => {
1868
+ ancestorScroll && ancestor.addEventListener('scroll', update, {
1869
+ passive: true
1870
+ });
1871
+ ancestorResize && ancestor.addEventListener('resize', update);
1872
+ });
1873
+ let observer = null;
1874
+
1875
+ if (elementResize) {
1876
+ observer = new ResizeObserver(update);
1877
+ isElement(reference) && !animationFrame && observer.observe(reference);
1878
+ observer.observe(floating);
1879
+ }
1880
+
1881
+ let frameId;
1882
+ let prevRefRect = animationFrame ? getBoundingClientRect(reference) : null;
1883
+
1884
+ if (animationFrame) {
1885
+ frameLoop();
1886
+ }
1887
+
1888
+ function frameLoop() {
1889
+ const nextRefRect = getBoundingClientRect(reference);
1890
+
1891
+ if (prevRefRect && (nextRefRect.x !== prevRefRect.x || nextRefRect.y !== prevRefRect.y || nextRefRect.width !== prevRefRect.width || nextRefRect.height !== prevRefRect.height)) {
1892
+ update();
1893
+ }
1894
+
1895
+ prevRefRect = nextRefRect;
1896
+ frameId = requestAnimationFrame(frameLoop);
1897
+ }
1898
+
1899
+ if (!elementResize) {
1900
+ update();
1901
+ }
1902
+
1903
+ return () => {
1904
+ var _observer;
1905
+
1906
+ ancestors.forEach(ancestor => {
1907
+ ancestorScroll && ancestor.removeEventListener('scroll', update);
1908
+ ancestorResize && ancestor.removeEventListener('resize', update);
1909
+ });
1910
+ (_observer = observer) == null ? void 0 : _observer.disconnect();
1911
+ observer = null;
1912
+
1913
+ if (animationFrame) {
1914
+ cancelAnimationFrame(frameId);
1915
+ }
1916
+ };
1917
+ }
1918
+
1919
+ /**
1920
+ * Computes the `x` and `y` coordinates that will place the floating element
1921
+ * next to a reference element when it is given a certain CSS positioning
1922
+ * strategy.
1923
+ */
1924
+
1925
+ const computePosition = (reference, floating, options) => computePosition$1(reference, floating, {
1926
+ platform,
1927
+ ...options
1928
+ });
1929
+
1930
+ var _Popup_instances, _Popup_arrowPosition_get, _Popup_padding_get, _Popup_distance_get, _Popup_strategy_get, _Popup_middleware_get, _Popup_cleanup, _Popup_anchorEl, _Popup_assignPopupPosition, _Popup_assignArrowPosition, _Popup_getAnchorById, _Popup_handleKeydown;
1931
+ class Popup extends FoundationElement {
1932
+ constructor() {
1933
+ super();
1934
+
1935
+ _Popup_instances.add(this);
1936
+
1937
+ _Popup_cleanup.set(this, void 0);
1938
+
1939
+ _Popup_anchorEl.set(this, void 0);
1940
+
1941
+ this.open = false;
1942
+ this.dismissible = false;
1943
+ this.arrow = false;
1944
+ this.alternate = false;
1945
+ this.corner = 'left';
1946
+ }
1947
+
1948
+ disconnectedCallback() {
1949
+ var _a, _b;
1950
+
1951
+ super.disconnectedCallback();
1952
+ (_a = __classPrivateFieldGet(this, _Popup_anchorEl, "f")) === null || _a === void 0 ? void 0 : _a.removeEventListener('keydown', e => __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_handleKeydown).call(this, e));
1953
+ (_b = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
1954
+ }
1955
+
1956
+ attributeChangedCallback(name, oldValue, newValue) {
1957
+ var _a, _b;
1958
+
1959
+ super.attributeChangedCallback(name, oldValue, newValue);
1960
+
1961
+ switch (name) {
1962
+ case 'anchor':
1963
+ {
1964
+ __classPrivateFieldSet(this, _Popup_anchorEl, __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_getAnchorById).call(this), "f");
1965
+
1966
+ (_a = __classPrivateFieldGet(this, _Popup_anchorEl, "f")) === null || _a === void 0 ? void 0 : _a.addEventListener('keydown', e => __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_handleKeydown).call(this, e));
1967
+ break;
1968
+ }
1969
+ }
1970
+
1971
+ if (__classPrivateFieldGet(this, _Popup_anchorEl, "f") && this.popupEl) {
1972
+ __classPrivateFieldSet(this, _Popup_cleanup, autoUpdate(__classPrivateFieldGet(this, _Popup_anchorEl, "f"), this.popupEl, () => this.updatePosition()), "f");
1973
+ } else {
1974
+ (_b = __classPrivateFieldGet(this, _Popup_cleanup, "f")) === null || _b === void 0 ? void 0 : _b.call(this);
1975
+ }
1976
+ }
1977
+
1978
+ async updatePosition() {
1979
+ if (!this.open || !__classPrivateFieldGet(this, _Popup_anchorEl, "f")) {
1980
+ return;
1981
+ }
1982
+
1983
+ const positionData = await computePosition(__classPrivateFieldGet(this, _Popup_anchorEl, "f"), this.popupEl, {
1984
+ placement: this.corner,
1985
+ strategy: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_strategy_get),
1986
+ middleware: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_middleware_get)
1987
+ });
1988
+
1989
+ __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignPopupPosition).call(this, positionData);
1990
+
1991
+ if (this.arrow) {
1992
+ __classPrivateFieldGet(this, _Popup_instances, "m", _Popup_assignArrowPosition).call(this, positionData);
1993
+ }
1994
+ }
1995
+
1996
+ }
1997
+ _Popup_cleanup = new WeakMap(), _Popup_anchorEl = new WeakMap(), _Popup_instances = new WeakSet(), _Popup_arrowPosition_get = function _Popup_arrowPosition_get() {
1998
+ return {
1999
+ top: 'bottom',
2000
+ right: 'left',
2001
+ bottom: 'top',
2002
+ left: 'right'
2003
+ };
2004
+ }, _Popup_padding_get = function _Popup_padding_get() {
2005
+ return 0;
2006
+ }, _Popup_distance_get = function _Popup_distance_get() {
2007
+ return 12;
2008
+ }, _Popup_strategy_get = function _Popup_strategy_get() {
2009
+ return 'fixed';
2010
+ }, _Popup_middleware_get = function _Popup_middleware_get() {
2011
+ const middleware = [flip(), hide(), inline()];
2012
+
2013
+ if (this.arrow) {
2014
+ middleware.push(arrow({
2015
+ element: this.arrowEl,
2016
+ padding: __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_padding_get)
2017
+ }), offset(__classPrivateFieldGet(this, _Popup_instances, "a", _Popup_distance_get)));
2018
+ }
2019
+
2020
+ return middleware;
2021
+ }, _Popup_assignPopupPosition = function _Popup_assignPopupPosition(data) {
2022
+ const {
2023
+ x: popupX,
2024
+ y: popupY
2025
+ } = data;
2026
+ const {
2027
+ referenceHidden
2028
+ } = data.middlewareData.hide;
2029
+ Object.assign(this.popupEl.style, {
2030
+ left: `${popupX}px`,
2031
+ top: `${popupY}px`,
2032
+ visibility: referenceHidden ? 'hidden' : 'visible'
2033
+ });
2034
+ }, _Popup_assignArrowPosition = function _Popup_assignArrowPosition(data) {
2035
+ const {
2036
+ x: arrowX,
2037
+ y: arrowY
2038
+ } = data.middlewareData.arrow;
2039
+
2040
+ const side = __classPrivateFieldGet(this, _Popup_instances, "a", _Popup_arrowPosition_get)[data.placement.split('-')[0]];
2041
+
2042
+ Object.assign(this.arrowEl.style, {
2043
+ left: `${arrowX}px`,
2044
+ top: `${arrowY}px`,
2045
+ right: '',
2046
+ bottom: '',
2047
+ [side]: '-4px'
2048
+ });
2049
+ }, _Popup_getAnchorById = function _Popup_getAnchorById() {
2050
+ return document.getElementById(this.anchor);
2051
+ }, _Popup_handleKeydown = function _Popup_handleKeydown({
2052
+ key
2053
+ }) {
2054
+ if (key === keyEscape) {
2055
+ this.open = false;
2056
+ }
2057
+ };
2058
+
2059
+ __decorate([attr({
2060
+ mode: 'boolean'
2061
+ }), __metadata("design:type", Object)], Popup.prototype, "open", void 0);
2062
+
2063
+ __decorate([attr({
2064
+ mode: 'boolean'
2065
+ }), __metadata("design:type", Object)], Popup.prototype, "dismissible", void 0);
2066
+
2067
+ __decorate([attr({
2068
+ mode: 'boolean'
2069
+ }), __metadata("design:type", Object)], Popup.prototype, "arrow", void 0);
2070
+
2071
+ __decorate([attr({
2072
+ mode: 'boolean'
2073
+ }), __metadata("design:type", Object)], Popup.prototype, "alternate", void 0);
2074
+
2075
+ __decorate([attr({
2076
+ mode: 'fromView'
2077
+ }), __metadata("design:type", String)], Popup.prototype, "corner", void 0);
2078
+
2079
+ __decorate([attr, __metadata("design:type", String)], Popup.prototype, "anchor", void 0);
2080
+
2081
+ var css_248z = ".control {\n background-color: var(--vvd-color-surface-4dp);\n border-radius: inherit;\n contain: layout;\n inline-size: -moz-fit-content;\n inline-size: fit-content;\n}\n.control:not(.open) {\n display: none;\n}\n\n.popup-wrapper {\n position: fixed;\n border-radius: 6px;\n}\n\n.popup-content {\n display: grid;\n color: var(--vvd-color-on-canvas); /* neutral-100 */\n}\n.dismissible .popup-content {\n align-content: start;\n grid-template-columns: 1fr auto;\n}\n\n.arrow {\n position: absolute;\n z-index: -1;\n width: 8px;\n height: 8px;\n background-color: var(--vvd-color-surface-4dp);\n transform: rotate(45deg);\n}\n\n.dismissible-button {\n align-self: flex-start;\n margin-block-start: 4px;\n margin-inline-end: 4px;\n}";
2082
+ styleInject(css_248z);
2083
+
2084
+ let _ = t => t,
2085
+ _t,
2086
+ _t2,
2087
+ _t3;
2088
+
2089
+ const getClasses = ({
2090
+ open,
2091
+ dismissible,
2092
+ alternate
2093
+ }) => classNames('control', ['open', Boolean(open)], ['dismissible', Boolean(dismissible)], ['alternate', Boolean(alternate)]);
2094
+
2095
+ const popupTemplate = () => html(_t || (_t = _`
2096
+ <vwc-elevation>
2097
+ <!--the popup-wrapper is needed for alternating the inside of the popup nd not its shadow-->
2098
+ <div class="popup-wrapper" ${0}>
2099
+ <div class="${0}" aria-hidden="${0}"
2100
+ part="${0}">
2101
+ <div class="popup-content">
2102
+ <slot></slot>
2103
+ ${0}
2104
+ </div>
2105
+ ${0}
2106
+ </div>
2107
+ </div>
2108
+ </vwc-elevation>`), ref('popupEl'), getClasses, x => x.open ? 'false' : 'true', x => x.alternate ? 'vvd-theme-alternate' : '', when(x => x.dismissible, html(_t2 || (_t2 = _`<vwc-button density="condensed" @click="${0}"
2109
+ class="dismissible-button" icon="close-small-solid" shape="pill"></vwc-button>`), x => x.open = false)), when(x => x.arrow, html(_t3 || (_t3 = _`<div class="arrow" ${0}></div>`), ref('arrowEl'))));
2110
+
2111
+ const vividPopup = Popup.compose({
2112
+ baseName: 'popup',
2113
+ template: popupTemplate,
2114
+ styles: css_248z
2115
+ });
2116
+ designSystem.register(vividPopup());
2117
+
2118
+ export { vividPopup };