popper-lite.js 45 KB

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