popper.js 60 KB

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