UNPKG

49.6 kBJavaScriptView Raw
1/**
2 * @popperjs/core v2.11.5 - MIT License
3 */
4
5(function (global, factory) {
6 typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
7 typeof define === 'function' && define.amd ? define(['exports'], factory) :
8 (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Popper = {}));
9}(this, (function (exports) { 'use strict';
10
11 function getWindow(node) {
12 if (node == null) {
13 return window;
14 }
15
16 if (node.toString() !== '[object Window]') {
17 var ownerDocument = node.ownerDocument;
18 return ownerDocument ? ownerDocument.defaultView || window : window;
19 }
20
21 return node;
22 }
23
24 function isElement(node) {
25 var OwnElement = getWindow(node).Element;
26 return node instanceof OwnElement || node instanceof Element;
27 }
28
29 function isHTMLElement(node) {
30 var OwnElement = getWindow(node).HTMLElement;
31 return node instanceof OwnElement || node instanceof HTMLElement;
32 }
33
34 function isShadowRoot(node) {
35 // IE 11 has no ShadowRoot
36 if (typeof ShadowRoot === 'undefined') {
37 return false;
38 }
39
40 var OwnElement = getWindow(node).ShadowRoot;
41 return node instanceof OwnElement || node instanceof ShadowRoot;
42 }
43
44 var max = Math.max;
45 var min = Math.min;
46 var round = Math.round;
47
48 function getBoundingClientRect(element, includeScale) {
49 if (includeScale === void 0) {
50 includeScale = false;
51 }
52
53 var rect = element.getBoundingClientRect();
54 var scaleX = 1;
55 var scaleY = 1;
56
57 if (isHTMLElement(element) && includeScale) {
58 var offsetHeight = element.offsetHeight;
59 var offsetWidth = element.offsetWidth; // Do not attempt to divide by 0, otherwise we get `Infinity` as scale
60 // Fallback to 1 in case both values are `0`
61
62 if (offsetWidth > 0) {
63 scaleX = round(rect.width) / offsetWidth || 1;
64 }
65
66 if (offsetHeight > 0) {
67 scaleY = round(rect.height) / offsetHeight || 1;
68 }
69 }
70
71 return {
72 width: rect.width / scaleX,
73 height: rect.height / scaleY,
74 top: rect.top / scaleY,
75 right: rect.right / scaleX,
76 bottom: rect.bottom / scaleY,
77 left: rect.left / scaleX,
78 x: rect.left / scaleX,
79 y: rect.top / scaleY
80 };
81 }
82
83 function getWindowScroll(node) {
84 var win = getWindow(node);
85 var scrollLeft = win.pageXOffset;
86 var scrollTop = win.pageYOffset;
87 return {
88 scrollLeft: scrollLeft,
89 scrollTop: scrollTop
90 };
91 }
92
93 function getHTMLElementScroll(element) {
94 return {
95 scrollLeft: element.scrollLeft,
96 scrollTop: element.scrollTop
97 };
98 }
99
100 function getNodeScroll(node) {
101 if (node === getWindow(node) || !isHTMLElement(node)) {
102 return getWindowScroll(node);
103 } else {
104 return getHTMLElementScroll(node);
105 }
106 }
107
108 function getNodeName(element) {
109 return element ? (element.nodeName || '').toLowerCase() : null;
110 }
111
112 function getDocumentElement(element) {
113 // $FlowFixMe[incompatible-return]: assume body is always available
114 return ((isElement(element) ? element.ownerDocument : // $FlowFixMe[prop-missing]
115 element.document) || window.document).documentElement;
116 }
117
118 function getWindowScrollBarX(element) {
119 // If <html> has a CSS width greater than the viewport, then this will be
120 // incorrect for RTL.
121 // Popper 1 is broken in this case and never had a bug report so let's assume
122 // it's not an issue. I don't think anyone ever specifies width on <html>
123 // anyway.
124 // Browsers where the left scrollbar doesn't cause an issue report `0` for
125 // this (e.g. Edge 2019, IE11, Safari)
126 return getBoundingClientRect(getDocumentElement(element)).left + getWindowScroll(element).scrollLeft;
127 }
128
129 function getComputedStyle(element) {
130 return getWindow(element).getComputedStyle(element);
131 }
132
133 function isScrollParent(element) {
134 // Firefox wants us to check `-x` and `-y` variations as well
135 var _getComputedStyle = getComputedStyle(element),
136 overflow = _getComputedStyle.overflow,
137 overflowX = _getComputedStyle.overflowX,
138 overflowY = _getComputedStyle.overflowY;
139
140 return /auto|scroll|overlay|hidden/.test(overflow + overflowY + overflowX);
141 }
142
143 function isElementScaled(element) {
144 var rect = element.getBoundingClientRect();
145 var scaleX = round(rect.width) / element.offsetWidth || 1;
146 var scaleY = round(rect.height) / element.offsetHeight || 1;
147 return scaleX !== 1 || scaleY !== 1;
148 } // Returns the composite rect of an element relative to its offsetParent.
149 // Composite means it takes into account transforms as well as layout.
150
151
152 function getCompositeRect(elementOrVirtualElement, offsetParent, isFixed) {
153 if (isFixed === void 0) {
154 isFixed = false;
155 }
156
157 var isOffsetParentAnElement = isHTMLElement(offsetParent);
158 var offsetParentIsScaled = isHTMLElement(offsetParent) && isElementScaled(offsetParent);
159 var documentElement = getDocumentElement(offsetParent);
160 var rect = getBoundingClientRect(elementOrVirtualElement, offsetParentIsScaled);
161 var scroll = {
162 scrollLeft: 0,
163 scrollTop: 0
164 };
165 var offsets = {
166 x: 0,
167 y: 0
168 };
169
170 if (isOffsetParentAnElement || !isOffsetParentAnElement && !isFixed) {
171 if (getNodeName(offsetParent) !== 'body' || // https://github.com/popperjs/popper-core/issues/1078
172 isScrollParent(documentElement)) {
173 scroll = getNodeScroll(offsetParent);
174 }
175
176 if (isHTMLElement(offsetParent)) {
177 offsets = getBoundingClientRect(offsetParent, true);
178 offsets.x += offsetParent.clientLeft;
179 offsets.y += offsetParent.clientTop;
180 } else if (documentElement) {
181 offsets.x = getWindowScrollBarX(documentElement);
182 }
183 }
184
185 return {
186 x: rect.left + scroll.scrollLeft - offsets.x,
187 y: rect.top + scroll.scrollTop - offsets.y,
188 width: rect.width,
189 height: rect.height
190 };
191 }
192
193 // means it doesn't take into account transforms.
194
195 function getLayoutRect(element) {
196 var clientRect = getBoundingClientRect(element); // Use the clientRect sizes if it's not been transformed.
197 // Fixes https://github.com/popperjs/popper-core/issues/1223
198
199 var width = element.offsetWidth;
200 var height = element.offsetHeight;
201
202 if (Math.abs(clientRect.width - width) <= 1) {
203 width = clientRect.width;
204 }
205
206 if (Math.abs(clientRect.height - height) <= 1) {
207 height = clientRect.height;
208 }
209
210 return {
211 x: element.offsetLeft,
212 y: element.offsetTop,
213 width: width,
214 height: height
215 };
216 }
217
218 function getParentNode(element) {
219 if (getNodeName(element) === 'html') {
220 return element;
221 }
222
223 return (// this is a quicker (but less type safe) way to save quite some bytes from the bundle
224 // $FlowFixMe[incompatible-return]
225 // $FlowFixMe[prop-missing]
226 element.assignedSlot || // step into the shadow DOM of the parent of a slotted node
227 element.parentNode || ( // DOM Element detected
228 isShadowRoot(element) ? element.host : null) || // ShadowRoot detected
229 // $FlowFixMe[incompatible-call]: HTMLElement is a Node
230 getDocumentElement(element) // fallback
231
232 );
233 }
234
235 function getScrollParent(node) {
236 if (['html', 'body', '#document'].indexOf(getNodeName(node)) >= 0) {
237 // $FlowFixMe[incompatible-return]: assume body is always available
238 return node.ownerDocument.body;
239 }
240
241 if (isHTMLElement(node) && isScrollParent(node)) {
242 return node;
243 }
244
245 return getScrollParent(getParentNode(node));
246 }
247
248 /*
249 given a DOM element, return the list of all scroll parents, up the list of ancesors
250 until we get to the top window object. This list is what we attach scroll listeners
251 to, because if any of these parent elements scroll, we'll need to re-calculate the
252 reference element's position.
253 */
254
255 function listScrollParents(element, list) {
256 var _element$ownerDocumen;
257
258 if (list === void 0) {
259 list = [];
260 }
261
262 var scrollParent = getScrollParent(element);
263 var isBody = scrollParent === ((_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body);
264 var win = getWindow(scrollParent);
265 var target = isBody ? [win].concat(win.visualViewport || [], isScrollParent(scrollParent) ? scrollParent : []) : scrollParent;
266 var updatedList = list.concat(target);
267 return isBody ? updatedList : // $FlowFixMe[incompatible-call]: isBody tells us target will be an HTMLElement here
268 updatedList.concat(listScrollParents(getParentNode(target)));
269 }
270
271 function isTableElement(element) {
272 return ['table', 'td', 'th'].indexOf(getNodeName(element)) >= 0;
273 }
274
275 function getTrueOffsetParent(element) {
276 if (!isHTMLElement(element) || // https://github.com/popperjs/popper-core/issues/837
277 getComputedStyle(element).position === 'fixed') {
278 return null;
279 }
280
281 return element.offsetParent;
282 } // `.offsetParent` reports `null` for fixed elements, while absolute elements
283 // return the containing block
284
285
286 function getContainingBlock(element) {
287 var isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') !== -1;
288 var isIE = navigator.userAgent.indexOf('Trident') !== -1;
289
290 if (isIE && isHTMLElement(element)) {
291 // In IE 9, 10 and 11 fixed elements containing block is always established by the viewport
292 var elementCss = getComputedStyle(element);
293
294 if (elementCss.position === 'fixed') {
295 return null;
296 }
297 }
298
299 var currentNode = getParentNode(element);
300
301 if (isShadowRoot(currentNode)) {
302 currentNode = currentNode.host;
303 }
304
305 while (isHTMLElement(currentNode) && ['html', 'body'].indexOf(getNodeName(currentNode)) < 0) {
306 var css = getComputedStyle(currentNode); // This is non-exhaustive but covers the most common CSS properties that
307 // create a containing block.
308 // https://developer.mozilla.org/en-US/docs/Web/CSS/Containing_block#identifying_the_containing_block
309
310 if (css.transform !== 'none' || css.perspective !== 'none' || css.contain === 'paint' || ['transform', 'perspective'].indexOf(css.willChange) !== -1 || isFirefox && css.willChange === 'filter' || isFirefox && css.filter && css.filter !== 'none') {
311 return currentNode;
312 } else {
313 currentNode = currentNode.parentNode;
314 }
315 }
316
317 return null;
318 } // Gets the closest ancestor positioned element. Handles some edge cases,
319 // such as table ancestors and cross browser bugs.
320
321
322 function getOffsetParent(element) {
323 var window = getWindow(element);
324 var offsetParent = getTrueOffsetParent(element);
325
326 while (offsetParent && isTableElement(offsetParent) && getComputedStyle(offsetParent).position === 'static') {
327 offsetParent = getTrueOffsetParent(offsetParent);
328 }
329
330 if (offsetParent && (getNodeName(offsetParent) === 'html' || getNodeName(offsetParent) === 'body' && getComputedStyle(offsetParent).position === 'static')) {
331 return window;
332 }
333
334 return offsetParent || getContainingBlock(element) || window;
335 }
336
337 var top = 'top';
338 var bottom = 'bottom';
339 var right = 'right';
340 var left = 'left';
341 var auto = 'auto';
342 var basePlacements = [top, bottom, right, left];
343 var start = 'start';
344 var end = 'end';
345 var clippingParents = 'clippingParents';
346 var viewport = 'viewport';
347 var popper = 'popper';
348 var reference = 'reference';
349
350 var beforeRead = 'beforeRead';
351 var read = 'read';
352 var afterRead = 'afterRead'; // pure-logic modifiers
353
354 var beforeMain = 'beforeMain';
355 var main = 'main';
356 var afterMain = 'afterMain'; // modifier with the purpose to write to the DOM (or write into a framework state)
357
358 var beforeWrite = 'beforeWrite';
359 var write = 'write';
360 var afterWrite = 'afterWrite';
361 var modifierPhases = [beforeRead, read, afterRead, beforeMain, main, afterMain, beforeWrite, write, afterWrite];
362
363 function order(modifiers) {
364 var map = new Map();
365 var visited = new Set();
366 var result = [];
367 modifiers.forEach(function (modifier) {
368 map.set(modifier.name, modifier);
369 }); // On visiting object, check for its dependencies and visit them recursively
370
371 function sort(modifier) {
372 visited.add(modifier.name);
373 var requires = [].concat(modifier.requires || [], modifier.requiresIfExists || []);
374 requires.forEach(function (dep) {
375 if (!visited.has(dep)) {
376 var depModifier = map.get(dep);
377
378 if (depModifier) {
379 sort(depModifier);
380 }
381 }
382 });
383 result.push(modifier);
384 }
385
386 modifiers.forEach(function (modifier) {
387 if (!visited.has(modifier.name)) {
388 // check for visited object
389 sort(modifier);
390 }
391 });
392 return result;
393 }
394
395 function orderModifiers(modifiers) {
396 // order based on dependencies
397 var orderedModifiers = order(modifiers); // order based on phase
398
399 return modifierPhases.reduce(function (acc, phase) {
400 return acc.concat(orderedModifiers.filter(function (modifier) {
401 return modifier.phase === phase;
402 }));
403 }, []);
404 }
405
406 function debounce(fn) {
407 var pending;
408 return function () {
409 if (!pending) {
410 pending = new Promise(function (resolve) {
411 Promise.resolve().then(function () {
412 pending = undefined;
413 resolve(fn());
414 });
415 });
416 }
417
418 return pending;
419 };
420 }
421
422 function format(str) {
423 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
424 args[_key - 1] = arguments[_key];
425 }
426
427 return [].concat(args).reduce(function (p, c) {
428 return p.replace(/%s/, c);
429 }, str);
430 }
431
432 var INVALID_MODIFIER_ERROR = 'Popper: modifier "%s" provided an invalid %s property, expected %s but got %s';
433 var MISSING_DEPENDENCY_ERROR = 'Popper: modifier "%s" requires "%s", but "%s" modifier is not available';
434 var VALID_PROPERTIES = ['name', 'enabled', 'phase', 'fn', 'effect', 'requires', 'options'];
435 function validateModifiers(modifiers) {
436 modifiers.forEach(function (modifier) {
437 [].concat(Object.keys(modifier), VALID_PROPERTIES) // IE11-compatible replacement for `new Set(iterable)`
438 .filter(function (value, index, self) {
439 return self.indexOf(value) === index;
440 }).forEach(function (key) {
441 switch (key) {
442 case 'name':
443 if (typeof modifier.name !== 'string') {
444 console.error(format(INVALID_MODIFIER_ERROR, String(modifier.name), '"name"', '"string"', "\"" + String(modifier.name) + "\""));
445 }
446
447 break;
448
449 case 'enabled':
450 if (typeof modifier.enabled !== 'boolean') {
451 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"enabled"', '"boolean"', "\"" + String(modifier.enabled) + "\""));
452 }
453
454 break;
455
456 case 'phase':
457 if (modifierPhases.indexOf(modifier.phase) < 0) {
458 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"phase"', "either " + modifierPhases.join(', '), "\"" + String(modifier.phase) + "\""));
459 }
460
461 break;
462
463 case 'fn':
464 if (typeof modifier.fn !== 'function') {
465 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"fn"', '"function"', "\"" + String(modifier.fn) + "\""));
466 }
467
468 break;
469
470 case 'effect':
471 if (modifier.effect != null && typeof modifier.effect !== 'function') {
472 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"effect"', '"function"', "\"" + String(modifier.fn) + "\""));
473 }
474
475 break;
476
477 case 'requires':
478 if (modifier.requires != null && !Array.isArray(modifier.requires)) {
479 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requires"', '"array"', "\"" + String(modifier.requires) + "\""));
480 }
481
482 break;
483
484 case 'requiresIfExists':
485 if (!Array.isArray(modifier.requiresIfExists)) {
486 console.error(format(INVALID_MODIFIER_ERROR, modifier.name, '"requiresIfExists"', '"array"', "\"" + String(modifier.requiresIfExists) + "\""));
487 }
488
489 break;
490
491 case 'options':
492 case 'data':
493 break;
494
495 default:
496 console.error("PopperJS: an invalid property has been provided to the \"" + modifier.name + "\" modifier, valid properties are " + VALID_PROPERTIES.map(function (s) {
497 return "\"" + s + "\"";
498 }).join(', ') + "; but \"" + key + "\" was provided.");
499 }
500
501 modifier.requires && modifier.requires.forEach(function (requirement) {
502 if (modifiers.find(function (mod) {
503 return mod.name === requirement;
504 }) == null) {
505 console.error(format(MISSING_DEPENDENCY_ERROR, String(modifier.name), requirement, requirement));
506 }
507 });
508 });
509 });
510 }
511
512 function uniqueBy(arr, fn) {
513 var identifiers = new Set();
514 return arr.filter(function (item) {
515 var identifier = fn(item);
516
517 if (!identifiers.has(identifier)) {
518 identifiers.add(identifier);
519 return true;
520 }
521 });
522 }
523
524 function getBasePlacement(placement) {
525 return placement.split('-')[0];
526 }
527
528 function mergeByName(modifiers) {
529 var merged = modifiers.reduce(function (merged, current) {
530 var existing = merged[current.name];
531 merged[current.name] = existing ? Object.assign({}, existing, current, {
532 options: Object.assign({}, existing.options, current.options),
533 data: Object.assign({}, existing.data, current.data)
534 }) : current;
535 return merged;
536 }, {}); // IE11 does not support Object.values
537
538 return Object.keys(merged).map(function (key) {
539 return merged[key];
540 });
541 }
542
543 function getViewportRect(element) {
544 var win = getWindow(element);
545 var html = getDocumentElement(element);
546 var visualViewport = win.visualViewport;
547 var width = html.clientWidth;
548 var height = html.clientHeight;
549 var x = 0;
550 var y = 0; // NB: This isn't supported on iOS <= 12. If the keyboard is open, the popper
551 // can be obscured underneath it.
552 // Also, `html.clientHeight` adds the bottom bar height in Safari iOS, even
553 // if it isn't open, so if this isn't available, the popper will be detected
554 // to overflow the bottom of the screen too early.
555
556 if (visualViewport) {
557 width = visualViewport.width;
558 height = visualViewport.height; // Uses Layout Viewport (like Chrome; Safari does not currently)
559 // In Chrome, it returns a value very close to 0 (+/-) but contains rounding
560 // errors due to floating point numbers, so we need to check precision.
561 // Safari returns a number <= 0, usually < -1 when pinch-zoomed
562 // Feature detection fails in mobile emulation mode in Chrome.
563 // Math.abs(win.innerWidth / visualViewport.scale - visualViewport.width) <
564 // 0.001
565 // Fallback here: "Not Safari" userAgent
566
567 if (!/^((?!chrome|android).)*safari/i.test(navigator.userAgent)) {
568 x = visualViewport.offsetLeft;
569 y = visualViewport.offsetTop;
570 }
571 }
572
573 return {
574 width: width,
575 height: height,
576 x: x + getWindowScrollBarX(element),
577 y: y
578 };
579 }
580
581 // of the `<html>` and `<body>` rect bounds if horizontally scrollable
582
583 function getDocumentRect(element) {
584 var _element$ownerDocumen;
585
586 var html = getDocumentElement(element);
587 var winScroll = getWindowScroll(element);
588 var body = (_element$ownerDocumen = element.ownerDocument) == null ? void 0 : _element$ownerDocumen.body;
589 var width = max(html.scrollWidth, html.clientWidth, body ? body.scrollWidth : 0, body ? body.clientWidth : 0);
590 var height = max(html.scrollHeight, html.clientHeight, body ? body.scrollHeight : 0, body ? body.clientHeight : 0);
591 var x = -winScroll.scrollLeft + getWindowScrollBarX(element);
592 var y = -winScroll.scrollTop;
593
594 if (getComputedStyle(body || html).direction === 'rtl') {
595 x += max(html.clientWidth, body ? body.clientWidth : 0) - width;
596 }
597
598 return {
599 width: width,
600 height: height,
601 x: x,
602 y: y
603 };
604 }
605
606 function contains(parent, child) {
607 var rootNode = child.getRootNode && child.getRootNode(); // First, attempt with faster native method
608
609 if (parent.contains(child)) {
610 return true;
611 } // then fallback to custom implementation with Shadow DOM support
612 else if (rootNode && isShadowRoot(rootNode)) {
613 var next = child;
614
615 do {
616 if (next && parent.isSameNode(next)) {
617 return true;
618 } // $FlowFixMe[prop-missing]: need a better way to handle this...
619
620
621 next = next.parentNode || next.host;
622 } while (next);
623 } // Give up, the result is false
624
625
626 return false;
627 }
628
629 function rectToClientRect(rect) {
630 return Object.assign({}, rect, {
631 left: rect.x,
632 top: rect.y,
633 right: rect.x + rect.width,
634 bottom: rect.y + rect.height
635 });
636 }
637
638 function getInnerBoundingClientRect(element) {
639 var rect = getBoundingClientRect(element);
640 rect.top = rect.top + element.clientTop;
641 rect.left = rect.left + element.clientLeft;
642 rect.bottom = rect.top + element.clientHeight;
643 rect.right = rect.left + element.clientWidth;
644 rect.width = element.clientWidth;
645 rect.height = element.clientHeight;
646 rect.x = rect.left;
647 rect.y = rect.top;
648 return rect;
649 }
650
651 function getClientRectFromMixedType(element, clippingParent) {
652 return clippingParent === viewport ? rectToClientRect(getViewportRect(element)) : isElement(clippingParent) ? getInnerBoundingClientRect(clippingParent) : rectToClientRect(getDocumentRect(getDocumentElement(element)));
653 } // A "clipping parent" is an overflowable container with the characteristic of
654 // clipping (or hiding) overflowing elements with a position different from
655 // `initial`
656
657
658 function getClippingParents(element) {
659 var clippingParents = listScrollParents(getParentNode(element));
660 var canEscapeClipping = ['absolute', 'fixed'].indexOf(getComputedStyle(element).position) >= 0;
661 var clipperElement = canEscapeClipping && isHTMLElement(element) ? getOffsetParent(element) : element;
662
663 if (!isElement(clipperElement)) {
664 return [];
665 } // $FlowFixMe[incompatible-return]: https://github.com/facebook/flow/issues/1414
666
667
668 return clippingParents.filter(function (clippingParent) {
669 return isElement(clippingParent) && contains(clippingParent, clipperElement) && getNodeName(clippingParent) !== 'body';
670 });
671 } // Gets the maximum area that the element is visible in due to any number of
672 // clipping parents
673
674
675 function getClippingRect(element, boundary, rootBoundary) {
676 var mainClippingParents = boundary === 'clippingParents' ? getClippingParents(element) : [].concat(boundary);
677 var clippingParents = [].concat(mainClippingParents, [rootBoundary]);
678 var firstClippingParent = clippingParents[0];
679 var clippingRect = clippingParents.reduce(function (accRect, clippingParent) {
680 var rect = getClientRectFromMixedType(element, clippingParent);
681 accRect.top = max(rect.top, accRect.top);
682 accRect.right = min(rect.right, accRect.right);
683 accRect.bottom = min(rect.bottom, accRect.bottom);
684 accRect.left = max(rect.left, accRect.left);
685 return accRect;
686 }, getClientRectFromMixedType(element, firstClippingParent));
687 clippingRect.width = clippingRect.right - clippingRect.left;
688 clippingRect.height = clippingRect.bottom - clippingRect.top;
689 clippingRect.x = clippingRect.left;
690 clippingRect.y = clippingRect.top;
691 return clippingRect;
692 }
693
694 function getVariation(placement) {
695 return placement.split('-')[1];
696 }
697
698 function getMainAxisFromPlacement(placement) {
699 return ['top', 'bottom'].indexOf(placement) >= 0 ? 'x' : 'y';
700 }
701
702 function computeOffsets(_ref) {
703 var reference = _ref.reference,
704 element = _ref.element,
705 placement = _ref.placement;
706 var basePlacement = placement ? getBasePlacement(placement) : null;
707 var variation = placement ? getVariation(placement) : null;
708 var commonX = reference.x + reference.width / 2 - element.width / 2;
709 var commonY = reference.y + reference.height / 2 - element.height / 2;
710 var offsets;
711
712 switch (basePlacement) {
713 case top:
714 offsets = {
715 x: commonX,
716 y: reference.y - element.height
717 };
718 break;
719
720 case bottom:
721 offsets = {
722 x: commonX,
723 y: reference.y + reference.height
724 };
725 break;
726
727 case right:
728 offsets = {
729 x: reference.x + reference.width,
730 y: commonY
731 };
732 break;
733
734 case left:
735 offsets = {
736 x: reference.x - element.width,
737 y: commonY
738 };
739 break;
740
741 default:
742 offsets = {
743 x: reference.x,
744 y: reference.y
745 };
746 }
747
748 var mainAxis = basePlacement ? getMainAxisFromPlacement(basePlacement) : null;
749
750 if (mainAxis != null) {
751 var len = mainAxis === 'y' ? 'height' : 'width';
752
753 switch (variation) {
754 case start:
755 offsets[mainAxis] = offsets[mainAxis] - (reference[len] / 2 - element[len] / 2);
756 break;
757
758 case end:
759 offsets[mainAxis] = offsets[mainAxis] + (reference[len] / 2 - element[len] / 2);
760 break;
761 }
762 }
763
764 return offsets;
765 }
766
767 function getFreshSideObject() {
768 return {
769 top: 0,
770 right: 0,
771 bottom: 0,
772 left: 0
773 };
774 }
775
776 function mergePaddingObject(paddingObject) {
777 return Object.assign({}, getFreshSideObject(), paddingObject);
778 }
779
780 function expandToHashMap(value, keys) {
781 return keys.reduce(function (hashMap, key) {
782 hashMap[key] = value;
783 return hashMap;
784 }, {});
785 }
786
787 function detectOverflow(state, options) {
788 if (options === void 0) {
789 options = {};
790 }
791
792 var _options = options,
793 _options$placement = _options.placement,
794 placement = _options$placement === void 0 ? state.placement : _options$placement,
795 _options$boundary = _options.boundary,
796 boundary = _options$boundary === void 0 ? clippingParents : _options$boundary,
797 _options$rootBoundary = _options.rootBoundary,
798 rootBoundary = _options$rootBoundary === void 0 ? viewport : _options$rootBoundary,
799 _options$elementConte = _options.elementContext,
800 elementContext = _options$elementConte === void 0 ? popper : _options$elementConte,
801 _options$altBoundary = _options.altBoundary,
802 altBoundary = _options$altBoundary === void 0 ? false : _options$altBoundary,
803 _options$padding = _options.padding,
804 padding = _options$padding === void 0 ? 0 : _options$padding;
805 var paddingObject = mergePaddingObject(typeof padding !== 'number' ? padding : expandToHashMap(padding, basePlacements));
806 var altContext = elementContext === popper ? reference : popper;
807 var popperRect = state.rects.popper;
808 var element = state.elements[altBoundary ? altContext : elementContext];
809 var clippingClientRect = getClippingRect(isElement(element) ? element : element.contextElement || getDocumentElement(state.elements.popper), boundary, rootBoundary);
810 var referenceClientRect = getBoundingClientRect(state.elements.reference);
811 var popperOffsets = computeOffsets({
812 reference: referenceClientRect,
813 element: popperRect,
814 strategy: 'absolute',
815 placement: placement
816 });
817 var popperClientRect = rectToClientRect(Object.assign({}, popperRect, popperOffsets));
818 var elementClientRect = elementContext === popper ? popperClientRect : referenceClientRect; // positive = overflowing the clipping rect
819 // 0 or negative = within the clipping rect
820
821 var overflowOffsets = {
822 top: clippingClientRect.top - elementClientRect.top + paddingObject.top,
823 bottom: elementClientRect.bottom - clippingClientRect.bottom + paddingObject.bottom,
824 left: clippingClientRect.left - elementClientRect.left + paddingObject.left,
825 right: elementClientRect.right - clippingClientRect.right + paddingObject.right
826 };
827 var offsetData = state.modifiersData.offset; // Offsets can be applied only to the popper element
828
829 if (elementContext === popper && offsetData) {
830 var offset = offsetData[placement];
831 Object.keys(overflowOffsets).forEach(function (key) {
832 var multiply = [right, bottom].indexOf(key) >= 0 ? 1 : -1;
833 var axis = [top, bottom].indexOf(key) >= 0 ? 'y' : 'x';
834 overflowOffsets[key] += offset[axis] * multiply;
835 });
836 }
837
838 return overflowOffsets;
839 }
840
841 var INVALID_ELEMENT_ERROR = 'Popper: Invalid reference or popper argument provided. They must be either a DOM element or virtual element.';
842 var INFINITE_LOOP_ERROR = 'Popper: An infinite loop in the modifiers cycle has been detected! The cycle has been interrupted to prevent a browser crash.';
843 var DEFAULT_OPTIONS = {
844 placement: 'bottom',
845 modifiers: [],
846 strategy: 'absolute'
847 };
848
849 function areValidElements() {
850 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
851 args[_key] = arguments[_key];
852 }
853
854 return !args.some(function (element) {
855 return !(element && typeof element.getBoundingClientRect === 'function');
856 });
857 }
858
859 function popperGenerator(generatorOptions) {
860 if (generatorOptions === void 0) {
861 generatorOptions = {};
862 }
863
864 var _generatorOptions = generatorOptions,
865 _generatorOptions$def = _generatorOptions.defaultModifiers,
866 defaultModifiers = _generatorOptions$def === void 0 ? [] : _generatorOptions$def,
867 _generatorOptions$def2 = _generatorOptions.defaultOptions,
868 defaultOptions = _generatorOptions$def2 === void 0 ? DEFAULT_OPTIONS : _generatorOptions$def2;
869 return function createPopper(reference, popper, options) {
870 if (options === void 0) {
871 options = defaultOptions;
872 }
873
874 var state = {
875 placement: 'bottom',
876 orderedModifiers: [],
877 options: Object.assign({}, DEFAULT_OPTIONS, defaultOptions),
878 modifiersData: {},
879 elements: {
880 reference: reference,
881 popper: popper
882 },
883 attributes: {},
884 styles: {}
885 };
886 var effectCleanupFns = [];
887 var isDestroyed = false;
888 var instance = {
889 state: state,
890 setOptions: function setOptions(setOptionsAction) {
891 var options = typeof setOptionsAction === 'function' ? setOptionsAction(state.options) : setOptionsAction;
892 cleanupModifierEffects();
893 state.options = Object.assign({}, defaultOptions, state.options, options);
894 state.scrollParents = {
895 reference: isElement(reference) ? listScrollParents(reference) : reference.contextElement ? listScrollParents(reference.contextElement) : [],
896 popper: listScrollParents(popper)
897 }; // Orders the modifiers based on their dependencies and `phase`
898 // properties
899
900 var orderedModifiers = orderModifiers(mergeByName([].concat(defaultModifiers, state.options.modifiers))); // Strip out disabled modifiers
901
902 state.orderedModifiers = orderedModifiers.filter(function (m) {
903 return m.enabled;
904 }); // Validate the provided modifiers so that the consumer will get warned
905 // if one of the modifiers is invalid for any reason
906
907 {
908 var modifiers = uniqueBy([].concat(orderedModifiers, state.options.modifiers), function (_ref) {
909 var name = _ref.name;
910 return name;
911 });
912 validateModifiers(modifiers);
913
914 if (getBasePlacement(state.options.placement) === auto) {
915 var flipModifier = state.orderedModifiers.find(function (_ref2) {
916 var name = _ref2.name;
917 return name === 'flip';
918 });
919
920 if (!flipModifier) {
921 console.error(['Popper: "auto" placements require the "flip" modifier be', 'present and enabled to work.'].join(' '));
922 }
923 }
924
925 var _getComputedStyle = getComputedStyle(popper),
926 marginTop = _getComputedStyle.marginTop,
927 marginRight = _getComputedStyle.marginRight,
928 marginBottom = _getComputedStyle.marginBottom,
929 marginLeft = _getComputedStyle.marginLeft; // We no longer take into account `margins` on the popper, and it can
930 // cause bugs with positioning, so we'll warn the consumer
931
932
933 if ([marginTop, marginRight, marginBottom, marginLeft].some(function (margin) {
934 return parseFloat(margin);
935 })) {
936 console.warn(['Popper: CSS "margin" styles cannot be used to apply padding', 'between the popper and its reference element or boundary.', 'To replicate margin, use the `offset` modifier, as well as', 'the `padding` option in the `preventOverflow` and `flip`', 'modifiers.'].join(' '));
937 }
938 }
939
940 runModifierEffects();
941 return instance.update();
942 },
943 // Sync update – it will always be executed, even if not necessary. This
944 // is useful for low frequency updates where sync behavior simplifies the
945 // logic.
946 // For high frequency updates (e.g. `resize` and `scroll` events), always
947 // prefer the async Popper#update method
948 forceUpdate: function forceUpdate() {
949 if (isDestroyed) {
950 return;
951 }
952
953 var _state$elements = state.elements,
954 reference = _state$elements.reference,
955 popper = _state$elements.popper; // Don't proceed if `reference` or `popper` are not valid elements
956 // anymore
957
958 if (!areValidElements(reference, popper)) {
959 {
960 console.error(INVALID_ELEMENT_ERROR);
961 }
962
963 return;
964 } // Store the reference and popper rects to be read by modifiers
965
966
967 state.rects = {
968 reference: getCompositeRect(reference, getOffsetParent(popper), state.options.strategy === 'fixed'),
969 popper: getLayoutRect(popper)
970 }; // Modifiers have the ability to reset the current update cycle. The
971 // most common use case for this is the `flip` modifier changing the
972 // placement, which then needs to re-run all the modifiers, because the
973 // logic was previously ran for the previous placement and is therefore
974 // stale/incorrect
975
976 state.reset = false;
977 state.placement = state.options.placement; // On each update cycle, the `modifiersData` property for each modifier
978 // is filled with the initial data specified by the modifier. This means
979 // it doesn't persist and is fresh on each update.
980 // To ensure persistent data, use `${name}#persistent`
981
982 state.orderedModifiers.forEach(function (modifier) {
983 return state.modifiersData[modifier.name] = Object.assign({}, modifier.data);
984 });
985 var __debug_loops__ = 0;
986
987 for (var index = 0; index < state.orderedModifiers.length; index++) {
988 {
989 __debug_loops__ += 1;
990
991 if (__debug_loops__ > 100) {
992 console.error(INFINITE_LOOP_ERROR);
993 break;
994 }
995 }
996
997 if (state.reset === true) {
998 state.reset = false;
999 index = -1;
1000 continue;
1001 }
1002
1003 var _state$orderedModifie = state.orderedModifiers[index],
1004 fn = _state$orderedModifie.fn,
1005 _state$orderedModifie2 = _state$orderedModifie.options,
1006 _options = _state$orderedModifie2 === void 0 ? {} : _state$orderedModifie2,
1007 name = _state$orderedModifie.name;
1008
1009 if (typeof fn === 'function') {
1010 state = fn({
1011 state: state,
1012 options: _options,
1013 name: name,
1014 instance: instance
1015 }) || state;
1016 }
1017 }
1018 },
1019 // Async and optimistically optimized update – it will not be executed if
1020 // not necessary (debounced to run at most once-per-tick)
1021 update: debounce(function () {
1022 return new Promise(function (resolve) {
1023 instance.forceUpdate();
1024 resolve(state);
1025 });
1026 }),
1027 destroy: function destroy() {
1028 cleanupModifierEffects();
1029 isDestroyed = true;
1030 }
1031 };
1032
1033 if (!areValidElements(reference, popper)) {
1034 {
1035 console.error(INVALID_ELEMENT_ERROR);
1036 }
1037
1038 return instance;
1039 }
1040
1041 instance.setOptions(options).then(function (state) {
1042 if (!isDestroyed && options.onFirstUpdate) {
1043 options.onFirstUpdate(state);
1044 }
1045 }); // Modifiers have the ability to execute arbitrary code before the first
1046 // update cycle runs. They will be executed in the same order as the update
1047 // cycle. This is useful when a modifier adds some persistent data that
1048 // other modifiers need to use, but the modifier is run after the dependent
1049 // one.
1050
1051 function runModifierEffects() {
1052 state.orderedModifiers.forEach(function (_ref3) {
1053 var name = _ref3.name,
1054 _ref3$options = _ref3.options,
1055 options = _ref3$options === void 0 ? {} : _ref3$options,
1056 effect = _ref3.effect;
1057
1058 if (typeof effect === 'function') {
1059 var cleanupFn = effect({
1060 state: state,
1061 name: name,
1062 instance: instance,
1063 options: options
1064 });
1065
1066 var noopFn = function noopFn() {};
1067
1068 effectCleanupFns.push(cleanupFn || noopFn);
1069 }
1070 });
1071 }
1072
1073 function cleanupModifierEffects() {
1074 effectCleanupFns.forEach(function (fn) {
1075 return fn();
1076 });
1077 effectCleanupFns = [];
1078 }
1079
1080 return instance;
1081 };
1082 }
1083
1084 var passive = {
1085 passive: true
1086 };
1087
1088 function effect$1(_ref) {
1089 var state = _ref.state,
1090 instance = _ref.instance,
1091 options = _ref.options;
1092 var _options$scroll = options.scroll,
1093 scroll = _options$scroll === void 0 ? true : _options$scroll,
1094 _options$resize = options.resize,
1095 resize = _options$resize === void 0 ? true : _options$resize;
1096 var window = getWindow(state.elements.popper);
1097 var scrollParents = [].concat(state.scrollParents.reference, state.scrollParents.popper);
1098
1099 if (scroll) {
1100 scrollParents.forEach(function (scrollParent) {
1101 scrollParent.addEventListener('scroll', instance.update, passive);
1102 });
1103 }
1104
1105 if (resize) {
1106 window.addEventListener('resize', instance.update, passive);
1107 }
1108
1109 return function () {
1110 if (scroll) {
1111 scrollParents.forEach(function (scrollParent) {
1112 scrollParent.removeEventListener('scroll', instance.update, passive);
1113 });
1114 }
1115
1116 if (resize) {
1117 window.removeEventListener('resize', instance.update, passive);
1118 }
1119 };
1120 } // eslint-disable-next-line import/no-unused-modules
1121
1122
1123 var eventListeners = {
1124 name: 'eventListeners',
1125 enabled: true,
1126 phase: 'write',
1127 fn: function fn() {},
1128 effect: effect$1,
1129 data: {}
1130 };
1131
1132 function popperOffsets(_ref) {
1133 var state = _ref.state,
1134 name = _ref.name;
1135 // Offsets are the actual position the popper needs to have to be
1136 // properly positioned near its reference element
1137 // This is the most basic placement, and will be adjusted by
1138 // the modifiers in the next step
1139 state.modifiersData[name] = computeOffsets({
1140 reference: state.rects.reference,
1141 element: state.rects.popper,
1142 strategy: 'absolute',
1143 placement: state.placement
1144 });
1145 } // eslint-disable-next-line import/no-unused-modules
1146
1147
1148 var popperOffsets$1 = {
1149 name: 'popperOffsets',
1150 enabled: true,
1151 phase: 'read',
1152 fn: popperOffsets,
1153 data: {}
1154 };
1155
1156 var unsetSides = {
1157 top: 'auto',
1158 right: 'auto',
1159 bottom: 'auto',
1160 left: 'auto'
1161 }; // Round the offsets to the nearest suitable subpixel based on the DPR.
1162 // Zooming can change the DPR, but it seems to report a value that will
1163 // cleanly divide the values into the appropriate subpixels.
1164
1165 function roundOffsetsByDPR(_ref) {
1166 var x = _ref.x,
1167 y = _ref.y;
1168 var win = window;
1169 var dpr = win.devicePixelRatio || 1;
1170 return {
1171 x: round(x * dpr) / dpr || 0,
1172 y: round(y * dpr) / dpr || 0
1173 };
1174 }
1175
1176 function mapToStyles(_ref2) {
1177 var _Object$assign2;
1178
1179 var popper = _ref2.popper,
1180 popperRect = _ref2.popperRect,
1181 placement = _ref2.placement,
1182 variation = _ref2.variation,
1183 offsets = _ref2.offsets,
1184 position = _ref2.position,
1185 gpuAcceleration = _ref2.gpuAcceleration,
1186 adaptive = _ref2.adaptive,
1187 roundOffsets = _ref2.roundOffsets,
1188 isFixed = _ref2.isFixed;
1189 var _offsets$x = offsets.x,
1190 x = _offsets$x === void 0 ? 0 : _offsets$x,
1191 _offsets$y = offsets.y,
1192 y = _offsets$y === void 0 ? 0 : _offsets$y;
1193
1194 var _ref3 = typeof roundOffsets === 'function' ? roundOffsets({
1195 x: x,
1196 y: y
1197 }) : {
1198 x: x,
1199 y: y
1200 };
1201
1202 x = _ref3.x;
1203 y = _ref3.y;
1204 var hasX = offsets.hasOwnProperty('x');
1205 var hasY = offsets.hasOwnProperty('y');
1206 var sideX = left;
1207 var sideY = top;
1208 var win = window;
1209
1210 if (adaptive) {
1211 var offsetParent = getOffsetParent(popper);
1212 var heightProp = 'clientHeight';
1213 var widthProp = 'clientWidth';
1214
1215 if (offsetParent === getWindow(popper)) {
1216 offsetParent = getDocumentElement(popper);
1217
1218 if (getComputedStyle(offsetParent).position !== 'static' && position === 'absolute') {
1219 heightProp = 'scrollHeight';
1220 widthProp = 'scrollWidth';
1221 }
1222 } // $FlowFixMe[incompatible-cast]: force type refinement, we compare offsetParent with window above, but Flow doesn't detect it
1223
1224
1225 offsetParent = offsetParent;
1226
1227 if (placement === top || (placement === left || placement === right) && variation === end) {
1228 sideY = bottom;
1229 var offsetY = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.height : // $FlowFixMe[prop-missing]
1230 offsetParent[heightProp];
1231 y -= offsetY - popperRect.height;
1232 y *= gpuAcceleration ? 1 : -1;
1233 }
1234
1235 if (placement === left || (placement === top || placement === bottom) && variation === end) {
1236 sideX = right;
1237 var offsetX = isFixed && offsetParent === win && win.visualViewport ? win.visualViewport.width : // $FlowFixMe[prop-missing]
1238 offsetParent[widthProp];
1239 x -= offsetX - popperRect.width;
1240 x *= gpuAcceleration ? 1 : -1;
1241 }
1242 }
1243
1244 var commonStyles = Object.assign({
1245 position: position
1246 }, adaptive && unsetSides);
1247
1248 var _ref4 = roundOffsets === true ? roundOffsetsByDPR({
1249 x: x,
1250 y: y
1251 }) : {
1252 x: x,
1253 y: y
1254 };
1255
1256 x = _ref4.x;
1257 y = _ref4.y;
1258
1259 if (gpuAcceleration) {
1260 var _Object$assign;
1261
1262 return Object.assign({}, commonStyles, (_Object$assign = {}, _Object$assign[sideY] = hasY ? '0' : '', _Object$assign[sideX] = hasX ? '0' : '', _Object$assign.transform = (win.devicePixelRatio || 1) <= 1 ? "translate(" + x + "px, " + y + "px)" : "translate3d(" + x + "px, " + y + "px, 0)", _Object$assign));
1263 }
1264
1265 return Object.assign({}, commonStyles, (_Object$assign2 = {}, _Object$assign2[sideY] = hasY ? y + "px" : '', _Object$assign2[sideX] = hasX ? x + "px" : '', _Object$assign2.transform = '', _Object$assign2));
1266 }
1267
1268 function computeStyles(_ref5) {
1269 var state = _ref5.state,
1270 options = _ref5.options;
1271 var _options$gpuAccelerat = options.gpuAcceleration,
1272 gpuAcceleration = _options$gpuAccelerat === void 0 ? true : _options$gpuAccelerat,
1273 _options$adaptive = options.adaptive,
1274 adaptive = _options$adaptive === void 0 ? true : _options$adaptive,
1275 _options$roundOffsets = options.roundOffsets,
1276 roundOffsets = _options$roundOffsets === void 0 ? true : _options$roundOffsets;
1277
1278 {
1279 var transitionProperty = getComputedStyle(state.elements.popper).transitionProperty || '';
1280
1281 if (adaptive && ['transform', 'top', 'right', 'bottom', 'left'].some(function (property) {
1282 return transitionProperty.indexOf(property) >= 0;
1283 })) {
1284 console.warn(['Popper: Detected CSS transitions on at least one of the following', 'CSS properties: "transform", "top", "right", "bottom", "left".', '\n\n', 'Disable the "computeStyles" modifier\'s `adaptive` option to allow', 'for smooth transitions, or remove these properties from the CSS', 'transition declaration on the popper element if only transitioning', 'opacity or background-color for example.', '\n\n', 'We recommend using the popper element as a wrapper around an inner', 'element that can have any CSS property transitioned for animations.'].join(' '));
1285 }
1286 }
1287
1288 var commonStyles = {
1289 placement: getBasePlacement(state.placement),
1290 variation: getVariation(state.placement),
1291 popper: state.elements.popper,
1292 popperRect: state.rects.popper,
1293 gpuAcceleration: gpuAcceleration,
1294 isFixed: state.options.strategy === 'fixed'
1295 };
1296
1297 if (state.modifiersData.popperOffsets != null) {
1298 state.styles.popper = Object.assign({}, state.styles.popper, mapToStyles(Object.assign({}, commonStyles, {
1299 offsets: state.modifiersData.popperOffsets,
1300 position: state.options.strategy,
1301 adaptive: adaptive,
1302 roundOffsets: roundOffsets
1303 })));
1304 }
1305
1306 if (state.modifiersData.arrow != null) {
1307 state.styles.arrow = Object.assign({}, state.styles.arrow, mapToStyles(Object.assign({}, commonStyles, {
1308 offsets: state.modifiersData.arrow,
1309 position: 'absolute',
1310 adaptive: false,
1311 roundOffsets: roundOffsets
1312 })));
1313 }
1314
1315 state.attributes.popper = Object.assign({}, state.attributes.popper, {
1316 'data-popper-placement': state.placement
1317 });
1318 } // eslint-disable-next-line import/no-unused-modules
1319
1320
1321 var computeStyles$1 = {
1322 name: 'computeStyles',
1323 enabled: true,
1324 phase: 'beforeWrite',
1325 fn: computeStyles,
1326 data: {}
1327 };
1328
1329 // and applies them to the HTMLElements such as popper and arrow
1330
1331 function applyStyles(_ref) {
1332 var state = _ref.state;
1333 Object.keys(state.elements).forEach(function (name) {
1334 var style = state.styles[name] || {};
1335 var attributes = state.attributes[name] || {};
1336 var element = state.elements[name]; // arrow is optional + virtual elements
1337
1338 if (!isHTMLElement(element) || !getNodeName(element)) {
1339 return;
1340 } // Flow doesn't support to extend this property, but it's the most
1341 // effective way to apply styles to an HTMLElement
1342 // $FlowFixMe[cannot-write]
1343
1344
1345 Object.assign(element.style, style);
1346 Object.keys(attributes).forEach(function (name) {
1347 var value = attributes[name];
1348
1349 if (value === false) {
1350 element.removeAttribute(name);
1351 } else {
1352 element.setAttribute(name, value === true ? '' : value);
1353 }
1354 });
1355 });
1356 }
1357
1358 function effect(_ref2) {
1359 var state = _ref2.state;
1360 var initialStyles = {
1361 popper: {
1362 position: state.options.strategy,
1363 left: '0',
1364 top: '0',
1365 margin: '0'
1366 },
1367 arrow: {
1368 position: 'absolute'
1369 },
1370 reference: {}
1371 };
1372 Object.assign(state.elements.popper.style, initialStyles.popper);
1373 state.styles = initialStyles;
1374
1375 if (state.elements.arrow) {
1376 Object.assign(state.elements.arrow.style, initialStyles.arrow);
1377 }
1378
1379 return function () {
1380 Object.keys(state.elements).forEach(function (name) {
1381 var element = state.elements[name];
1382 var attributes = state.attributes[name] || {};
1383 var styleProperties = Object.keys(state.styles.hasOwnProperty(name) ? state.styles[name] : initialStyles[name]); // Set all values to an empty string to unset them
1384
1385 var style = styleProperties.reduce(function (style, property) {
1386 style[property] = '';
1387 return style;
1388 }, {}); // arrow is optional + virtual elements
1389
1390 if (!isHTMLElement(element) || !getNodeName(element)) {
1391 return;
1392 }
1393
1394 Object.assign(element.style, style);
1395 Object.keys(attributes).forEach(function (attribute) {
1396 element.removeAttribute(attribute);
1397 });
1398 });
1399 };
1400 } // eslint-disable-next-line import/no-unused-modules
1401
1402
1403 var applyStyles$1 = {
1404 name: 'applyStyles',
1405 enabled: true,
1406 phase: 'write',
1407 fn: applyStyles,
1408 effect: effect,
1409 requires: ['computeStyles']
1410 };
1411
1412 var defaultModifiers = [eventListeners, popperOffsets$1, computeStyles$1, applyStyles$1];
1413 var createPopper = /*#__PURE__*/popperGenerator({
1414 defaultModifiers: defaultModifiers
1415 }); // eslint-disable-next-line import/no-unused-modules
1416
1417 exports.createPopper = createPopper;
1418 exports.defaultModifiers = defaultModifiers;
1419 exports.detectOverflow = detectOverflow;
1420 exports.popperGenerator = popperGenerator;
1421
1422 Object.defineProperty(exports, '__esModule', { value: true });
1423
1424})));
1425//# sourceMappingURL=popper-lite.js.map