You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1991 lines
66 KiB

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